@uniformdev/mesh-sdk-react 12.2.1-alpha.107

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.
@@ -0,0 +1,55 @@
1
+ import * as _uniformdev_mesh_sdk from '@uniformdev/mesh-sdk';
2
+ import { UniformMeshSDK, MeshLocation } from '@uniformdev/mesh-sdk';
3
+ export * from '@uniformdev/mesh-sdk';
4
+ import React from 'react';
5
+
6
+ /**
7
+ * Provides convenient access to the current Uniform Mesh location via React hook.
8
+ * Intended to be used within a UniformMeshLocationContextProvider.
9
+ */
10
+ declare function useUniformMeshLocation<TLocationMethodsValue = unknown, TLocationMethodsMetadata = unknown>(): {
11
+ value: TLocationMethodsValue;
12
+ setValue: (value: TLocationMethodsValue) => Promise<void>;
13
+ metadata: TLocationMethodsMetadata;
14
+ };
15
+
16
+ interface UseUniformMeshSdkOptions {
17
+ autoResizingDisabled?: boolean;
18
+ }
19
+ /**
20
+ * Provides a React-hook wrapper around Uniform Mesh SDK initialization.
21
+ * NOTE: initialization is an async operation and should be handled as such.
22
+ */
23
+ declare const useInitializeUniformMeshSdk: ({ autoResizingDisabled }?: UseUniformMeshSdkOptions) => {
24
+ initializing: boolean;
25
+ error: Error | undefined;
26
+ sdk: UniformMeshSDK | undefined;
27
+ };
28
+
29
+ /**
30
+ * Provides convenient access to the current Uniform Mesh SDK instance via React hook.
31
+ * Intended to be used within a UniformMeshSdkContextProvider.
32
+ */
33
+ declare function useUniformMeshSdk(): _uniformdev_mesh_sdk.UniformMeshSDK;
34
+
35
+ interface UniformMeshSdkContextValue {
36
+ sdk: UniformMeshSDK;
37
+ }
38
+ declare const UniformMeshSdkContext: React.Context<UniformMeshSdkContextValue | undefined>;
39
+ declare const UniformMeshSdkContextProvider: React.FC;
40
+ /**
41
+ * Provides access to the current (initialized) Uniform Mesh SDK context value.
42
+ */
43
+ declare const useUniformMeshSdkContext: () => UniformMeshSdkContextValue;
44
+
45
+ interface UniformMeshLocationContextValue<TLocationValue = unknown, TLocationMetadata = unknown> {
46
+ location: MeshLocation<TLocationValue, TLocationMetadata>;
47
+ }
48
+ declare const UniformMeshLocationContext: React.Context<UniformMeshLocationContextValue<unknown, unknown> | undefined>;
49
+ declare const UniformMeshLocationContextProvider: React.FC;
50
+ /**
51
+ * Provides access to the current UniformMeshLocationContext value.
52
+ */
53
+ declare const useUniformMeshLocationContext: <TLocationValue, TLocationMetadata>() => UniformMeshLocationContextValue<TLocationValue, TLocationMetadata>;
54
+
55
+ export { UniformMeshLocationContext, UniformMeshLocationContextProvider, UniformMeshLocationContextValue, UniformMeshSdkContext, UniformMeshSdkContextProvider, UniformMeshSdkContextValue, UseUniformMeshSdkOptions, useInitializeUniformMeshSdk, useUniformMeshLocation, useUniformMeshLocationContext, useUniformMeshSdk, useUniformMeshSdkContext };
@@ -0,0 +1 @@
1
+ import x,{createContext as U,useContext as p,useState as L}from"react";var f=U(void 0),d=({children:e})=>{let[o,a]=L(),t;if(typeof window!="undefined"&&typeof window.UniformMeshSDK!="undefined"){let n=o||window.UniformMeshSDK.getCurrentLocation();t={location:{getValue:n.getValue,getMetadata:n.getMetadata,setValue:async i=>{await n.setValue(i),a(window.UniformMeshSDK.getCurrentLocation())}}}}return x.createElement(f.Provider,{value:t},e)},m=()=>{let e=p(f);if(!e)throw new Error("useUniformMeshLocationContext must be used within a UniformMeshLocationContextProvider");return e};function D(){let{location:e}=m();return{value:e==null?void 0:e.getValue(),setValue:e==null?void 0:e.setValue,metadata:e==null?void 0:e.getMetadata()}}import{initializeUniformMeshSDK as C}from"@uniformdev/mesh-sdk";import{useEffect as k,useState as u}from"react";var y=({autoResizingDisabled:e}={})=>{let[o,a]=u(),[t,n]=u();return k(()=>{typeof window=="undefined"||t||(typeof window.UniformMeshSDK=="undefined"?C({autoResizingDisabled:e}).then(i=>{n(i)}).catch(i=>{a(i)}):n(window.UniformMeshSDK))},[]),{initializing:!t&&!o,error:o,sdk:t}};import c,{createContext as l,useContext as S}from"react";var h=l(void 0),R=({children:e})=>{let o;return typeof window!="undefined"&&typeof window.UniformMeshSDK!="undefined"&&(o={sdk:window.UniformMeshSDK}),c.createElement(h.Provider,{value:o},c.createElement(d,null,e))},M=()=>{let e=S(h);if(!e)throw new Error("useUniformMeshSdkContext must be used within a UniformMeshSdkContextProvider");return e};function O(){let{sdk:e}=M();return e}export*from"@uniformdev/mesh-sdk";export{f as UniformMeshLocationContext,d as UniformMeshLocationContextProvider,h as UniformMeshSdkContext,R as UniformMeshSdkContextProvider,y as useInitializeUniformMeshSdk,D as useUniformMeshLocation,m as useUniformMeshLocationContext,O as useUniformMeshSdk,M as useUniformMeshSdkContext};
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ var k=Object.create;var c=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var L=e=>c(e,"__esModule",{value:!0});var v=(e,o)=>{L(e);for(var i in o)c(e,i,{get:o[i],enumerable:!0})},n=(e,o,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of S(o))!V.call(e,t)&&t!=="default"&&c(e,t,{get:()=>o[t],enumerable:!(i=l(o,t))||i.enumerable});return e},d=e=>n(L(c(e!=null?k(w(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);v(exports,{UniformMeshLocationContext:()=>h,UniformMeshLocationContextProvider:()=>M,UniformMeshSdkContext:()=>U,UniformMeshSdkContextProvider:()=>T,useInitializeUniformMeshSdk:()=>K,useUniformMeshLocation:()=>D,useUniformMeshLocationContext:()=>x,useUniformMeshSdk:()=>g,useUniformMeshSdkContext:()=>p});var r=d(require("react")),h=(0,r.createContext)(void 0),M=({children:e})=>{let[o,i]=(0,r.useState)(),t;if(typeof window!="undefined"&&typeof window.UniformMeshSDK!="undefined"){let a=o||window.UniformMeshSDK.getCurrentLocation();t={location:{getValue:a.getValue,getMetadata:a.getMetadata,setValue:async f=>{await a.setValue(f),i(window.UniformMeshSDK.getCurrentLocation())}}}}return r.default.createElement(h.Provider,{value:t},e)},x=()=>{let e=(0,r.useContext)(h);if(!e)throw new Error("useUniformMeshLocationContext must be used within a UniformMeshLocationContextProvider");return e};function D(){let{location:e}=x();return{value:e==null?void 0:e.getValue(),setValue:e==null?void 0:e.setValue,metadata:e==null?void 0:e.getMetadata()}}var C=d(require("@uniformdev/mesh-sdk")),u=d(require("react")),K=({autoResizingDisabled:e}={})=>{let[o,i]=(0,u.useState)(),[t,a]=(0,u.useState)();return(0,u.useEffect)(()=>{typeof window=="undefined"||t||(typeof window.UniformMeshSDK=="undefined"?(0,C.initializeUniformMeshSDK)({autoResizingDisabled:e}).then(f=>{a(f)}).catch(f=>{i(f)}):a(window.UniformMeshSDK))},[]),{initializing:!t&&!o,error:o,sdk:t}};var s=d(require("react"));var U=(0,s.createContext)(void 0),T=({children:e})=>{let o;return typeof window!="undefined"&&typeof window.UniformMeshSDK!="undefined"&&(o={sdk:window.UniformMeshSDK}),s.default.createElement(U.Provider,{value:o},s.default.createElement(M,null,e))},p=()=>{let e=(0,s.useContext)(U);if(!e)throw new Error("useUniformMeshSdkContext must be used within a UniformMeshSdkContextProvider");return e};function g(){let{sdk:e}=p();return e}n(exports,d(require("@uniformdev/mesh-sdk")));0&&(module.exports={UniformMeshLocationContext,UniformMeshLocationContextProvider,UniformMeshSdkContext,UniformMeshSdkContextProvider,useInitializeUniformMeshSdk,useUniformMeshLocation,useUniformMeshLocationContext,useUniformMeshSdk,useUniformMeshSdkContext});
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import x,{createContext as U,useContext as p,useState as L}from"react";var f=U(void 0),d=({children:e})=>{let[o,a]=L(),t;if(typeof window!="undefined"&&typeof window.UniformMeshSDK!="undefined"){let n=o||window.UniformMeshSDK.getCurrentLocation();t={location:{getValue:n.getValue,getMetadata:n.getMetadata,setValue:async i=>{await n.setValue(i),a(window.UniformMeshSDK.getCurrentLocation())}}}}return x.createElement(f.Provider,{value:t},e)},m=()=>{let e=p(f);if(!e)throw new Error("useUniformMeshLocationContext must be used within a UniformMeshLocationContextProvider");return e};function D(){let{location:e}=m();return{value:e==null?void 0:e.getValue(),setValue:e==null?void 0:e.setValue,metadata:e==null?void 0:e.getMetadata()}}import{initializeUniformMeshSDK as C}from"@uniformdev/mesh-sdk";import{useEffect as k,useState as u}from"react";var y=({autoResizingDisabled:e}={})=>{let[o,a]=u(),[t,n]=u();return k(()=>{typeof window=="undefined"||t||(typeof window.UniformMeshSDK=="undefined"?C({autoResizingDisabled:e}).then(i=>{n(i)}).catch(i=>{a(i)}):n(window.UniformMeshSDK))},[]),{initializing:!t&&!o,error:o,sdk:t}};import c,{createContext as l,useContext as S}from"react";var h=l(void 0),R=({children:e})=>{let o;return typeof window!="undefined"&&typeof window.UniformMeshSDK!="undefined"&&(o={sdk:window.UniformMeshSDK}),c.createElement(h.Provider,{value:o},c.createElement(d,null,e))},M=()=>{let e=S(h);if(!e)throw new Error("useUniformMeshSdkContext must be used within a UniformMeshSdkContextProvider");return e};function O(){let{sdk:e}=M();return e}export*from"@uniformdev/mesh-sdk";export{f as UniformMeshLocationContext,d as UniformMeshLocationContextProvider,h as UniformMeshSdkContext,R as UniformMeshSdkContextProvider,y as useInitializeUniformMeshSdk,D as useUniformMeshLocation,m as useUniformMeshLocationContext,O as useUniformMeshSdk,M as useUniformMeshSdkContext};
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@uniformdev/mesh-sdk-react",
3
+ "version": "12.2.1-alpha.107+b30768d5",
4
+ "description": "Uniform Mesh Framework SDK for React",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.esm.js",
8
+ "exports": {
9
+ "import": {
10
+ "node": "./dist/index.mjs",
11
+ "default": "./dist/index.esm.js"
12
+ },
13
+ "require": "./dist/index.js"
14
+ },
15
+ "types": "./dist/index.d.ts",
16
+ "sideEffects": false,
17
+ "scripts": {
18
+ "build": "tsup",
19
+ "dev": "tsup --watch",
20
+ "clean": "rimraf dist",
21
+ "test": "jest --maxWorkers=1 --passWithNoTests",
22
+ "lint": "eslint \"src/**/*.{js,ts,tsx}\"",
23
+ "format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
24
+ "ci:verify": "run-p lint test",
25
+ "ci:build": "tsup --minify --clean"
26
+ },
27
+ "dependencies": {
28
+ "@uniformdev/mesh-sdk": "^12.2.1-alpha.107+b30768d5"
29
+ },
30
+ "peerDependencies": {
31
+ "react": ">= 16"
32
+ },
33
+ "devDependencies": {
34
+ "@types/jest": "27.0.3",
35
+ "@types/node": "16.11.18",
36
+ "eslint": "8.4.1",
37
+ "eslint-plugin-react": "7.27.1",
38
+ "eslint-plugin-react-hooks": "4.3.0",
39
+ "jest": "27.4.5",
40
+ "npm-run-all": "4.1.5",
41
+ "rimraf": "3.0.2",
42
+ "ts-jest": "27.1.1",
43
+ "tsup": "5.11.10"
44
+ },
45
+ "files": [
46
+ "/dist"
47
+ ],
48
+ "gitHead": "b30768d5d58d4c75b390274042724d50c1ee1041"
49
+ }