@perspect3vism/ad4m-connect
Advanced tools
Comparing version 0.0.11-11 to 0.0.11-12
@@ -29,3 +29,2 @@ import { ApolloClient, NormalizedCacheObject } from "@apollo/client/core"; | ||
appDomain: string; | ||
url: string; | ||
capabilities: { | ||
@@ -36,2 +35,6 @@ [x: string]: any; | ||
constructor({ appName, appDesc, appDomain, capabilities, port, token, url, }: Ad4mConnectOptions); | ||
get token(): string | null; | ||
set token(token: string); | ||
get url(): string | null; | ||
set url(url: string); | ||
onStateChange(listener: (...args: any[]) => void): void; | ||
@@ -44,4 +47,2 @@ notifyStateChange(val: ClientStates): void; | ||
setPort(port: number): void; | ||
get token(): string | null; | ||
set token(token: string); | ||
setPortSearchState(state: PortSearchStateType): void; | ||
@@ -48,0 +49,0 @@ buildClient(): void; |
@@ -1,1 +0,1 @@ | ||
var m=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var T=(o,e)=>{for(var t in e)m(o,t,{get:e[t],enumerable:!0})},j=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of L(e))!S.call(o,n)&&n!==t&&m(o,n,{get:()=>e[n],enumerable:!(r=E(e,n))||r.enumerable});return o};var C=o=>j(m({},"__esModule",{value:!0}),o);var h=(o,e,t)=>new Promise((r,n)=>{var a=c=>{try{s(t.next(c))}catch(u){n(u)}},p=c=>{try{s(t.throw(c))}catch(u){n(u)}},s=c=>c.done?r(c.value):Promise.resolve(c.value).then(a,p);s((t=t.apply(o,e)).next())});var v={};T(v,{ad4mConnect:()=>P});module.exports=C(v);var{ipcMain:y,BrowserWindow:_}=require("electron"),i=require("path"),l=require("fs"),{homedir:R}=require("os"),A=i.join(R(),".ad4m"),w="capability-token",b="executor-url";function F(o){l.existsSync(o)===!1&&l.mkdirSync(o,777)}function N(o,e){F(e),l.writeFileSync(i.join(e,b),o)}function q(o){let e;try{e=l.readFileSync(i.join(o,b),{encoding:"utf8",flag:"r"}),console.log("Found executor URL in config file:",e)}catch(t){try{let r=i.join(A,"executor-port");console.log("No executor URL config file found. Trying to read local ad4m executor port from file:",r);let n=l.readFileSync(r,{flag:"r"}).toString();console.log("Found port:",n),e=`ws://localhost:${n}/graphql`,console.log("Using executor URL:",e)}catch(r){console.error(r),console.log("Couldn't read executor port from file. User has to enter URL manually"),e=""}}return e}function I(o,e){F(e),l.writeFileSync(i.join(e,w),o)}function O(o){try{let e=l.readFileSync(i.join(o,w),{encoding:"utf8",flag:"r"});return console.log("Found capability token in config file."),e}catch(e){return console.log("No capability token found."),""}}function P(o){let{appName:e,appDesc:t,appIconPath:r,capabilities:n,dataPath:a}=o;return new Promise((p,s)=>h(this,null,function*(){let c=q(a),u=O(a),f;y.on("get",(g,d)=>{g.returnValue={appName:e,appDesc:t,appIconPath:r,executorUrl:c,capabilityToken:u,capabilities:n}}),y.on("resolve",(g,d)=>{let{executorUrl:x,capabilityToken:U,client:k}=d;N(x,a),I(U,a),f.close(),p({executorUrl:x,capabilityToken:U,client:k})}),y.on("reject",(g,d)=>{f.close(),s()}),f=new _({width:1200,height:800,webPreferences:{nodeIntegration:!0,contextIsolation:!1,webSecurity:!1},minimizable:!0,alwaysOnTop:!1,frame:!0,transparent:!1,icon:i.join(__dirname,"../public","Ad4mLogo.png")}),f.loadURL(`file://${__dirname}/../public/dialog.html`)}))}0&&(module.exports={ad4mConnect}); | ||
var m=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var C=(o,e)=>{for(var t in e)m(o,t,{get:e[t],enumerable:!0})},_=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of T(e))!j.call(o,n)&&n!==t&&m(o,n,{get:()=>e[n],enumerable:!(r=S(e,n))||r.enumerable});return o};var R=o=>_(m({},"__esModule",{value:!0}),o);var h=(o,e,t)=>new Promise((r,n)=>{var p=c=>{try{s(t.next(c))}catch(u){n(u)}},a=c=>{try{s(t.throw(c))}catch(u){n(u)}},s=c=>c.done?r(c.value):Promise.resolve(c.value).then(p,a);s((t=t.apply(o,e)).next())});var v={};C(v,{ad4mConnect:()=>P});module.exports=R(v);var{ipcMain:y,BrowserWindow:A}=require("electron"),i=require("path"),l=require("fs"),{homedir:N}=require("os"),w=i.join(N(),".ad4m"),b="capability-token",F="executor-url";function k(o){l.existsSync(o)===!1&&l.mkdirSync(o,777)}function q(o,e){k(e),l.writeFileSync(i.join(e,F),o)}function I(o){let e;try{e=l.readFileSync(i.join(o,F),{encoding:"utf8",flag:"r"}),console.log("Found executor URL in config file:",e)}catch(t){try{let r=i.join(w,"executor-port");console.log("No executor URL config file found. Trying to read local ad4m executor port from file:",r);let n=l.readFileSync(r,{flag:"r"}).toString();console.log("Found port:",n),e=`ws://localhost:${n}/graphql`,console.log("Using executor URL:",e)}catch(r){console.error(r),console.log("Couldn't read executor port from file. User has to enter URL manually"),e=""}}return e}function O(o,e){k(e),l.writeFileSync(i.join(e,b),o)}function D(o){try{let e=l.readFileSync(i.join(o,b),{encoding:"utf8",flag:"r"});return console.log("Found capability token in config file."),e}catch(e){return console.log("No capability token found."),""}}function P(o){let{appName:e,appDesc:t,appDomain:r,appIconPath:n,capabilities:p,dataPath:a=w}=o;return new Promise((s,c)=>h(this,null,function*(){let u=I(a),E=D(a),f;y.on("get",(g,d)=>{g.returnValue={appName:e,appDesc:t,appIconPath:n,appDomain:r,executorUrl:u,capabilityToken:E,capabilities:p}}),y.on("resolve",(g,d)=>{let{executorUrl:x,capabilityToken:U,client:L}=d;q(x,a),O(U,a),f.close(),s({executorUrl:x,capabilityToken:U,client:L})}),y.on("reject",(g,d)=>{f.close(),c()}),f=new A({width:1200,height:800,webPreferences:{nodeIntegration:!0,contextIsolation:!1,webSecurity:!1},minimizable:!0,alwaysOnTop:!1,frame:!0,transparent:!1,icon:i.join(__dirname,"../public","Ad4mLogo.png")}),f.loadURL(`file://${__dirname}/../public/dialog.html`)}))}0&&(module.exports={ad4mConnect}); |
@@ -1,1 +0,1 @@ | ||
var l=(t,e,n)=>new Promise((r,s)=>{var u=o=>{try{c(n.next(o))}catch(i){s(i)}},a=o=>{try{c(n.throw(o))}catch(i){s(i)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(u,a);c((n=n.apply(t,e)).next())});function m(){let t=new AbortController;return setTimeout(()=>t.abort(),20),t}function C(t){return l(this,null,function*(){try{return(yield fetch(`http://localhost:${t}/graphql/`,{signal:m().signal,mode:"no-cors"})).status===0?t:null}catch(e){throw e}})}function f(){return new Promise((t,e)=>{let n=document.querySelector("ad4m-connect"),r=n==null?void 0:n.getAd4mClient();r?t(r):e("No Ad4mClient found")})}function h(t){let e=document.querySelector("ad4m-connect");e==null||e.addEventListener("authStateChange",n=>{t(n.detail)})}function g(){return document.querySelector("ad4m-connect").connected()}export{C as checkPort,f as getAd4mClient,g as isConnected,h as onAuthStateChanged}; | ||
var l=(t,e,n)=>new Promise((r,s)=>{var u=o=>{try{c(n.next(o))}catch(i){s(i)}},a=o=>{try{c(n.throw(o))}catch(i){s(i)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(u,a);c((n=n.apply(t,e)).next())});function m(){let t=new AbortController;return setTimeout(()=>t.abort(),20),t}function C(t){return l(this,null,function*(){try{return(yield fetch(`http://localhost:${t}/graphql/`,{signal:m().signal,mode:"no-cors"})).status===400?t:null}catch(e){throw e}})}function f(){return new Promise((t,e)=>{let n=document.querySelector("ad4m-connect"),r=n==null?void 0:n.getAd4mClient();r?t(r):e("No Ad4mClient found")})}function h(t){let e=document.querySelector("ad4m-connect");e==null||e.addEventListener("authStateChange",n=>{t(n.detail)})}function g(){return document.querySelector("ad4m-connect").connected()}export{C as checkPort,f as getAd4mClient,g as isConnected,h as onAuthStateChanged}; |
{ | ||
"name": "@perspect3vism/ad4m-connect", | ||
"version": "0.0.11-11", | ||
"version": "0.0.11-12", | ||
"description": "Lib for handling everything needed to setup a connection to a local or remote ad4m-executor", | ||
@@ -8,3 +8,4 @@ "license": "CAL-1.0", | ||
"files": [ | ||
"dist" | ||
"dist", | ||
"public" | ||
], | ||
@@ -30,3 +31,3 @@ "scripts": { | ||
"@apollo/client": "^3.6.9", | ||
"@perspect3vism/ad4m": "0.1.37", | ||
"@perspect3vism/ad4m": "0.1.40", | ||
"@rollup/plugin-commonjs": "^14.0.0", | ||
@@ -39,3 +40,3 @@ "@rollup/plugin-node-resolve": "^8.0.0", | ||
"graphql-ws": "^5.10.1", | ||
"ipfs-core-types": "^0.8.4", | ||
"ipfs-core-types": "^0.10.1", | ||
"node-sass": "^7.0.0", | ||
@@ -42,0 +43,0 @@ "np": "^7.6.2", |
@@ -16,3 +16,3 @@ # AD4M connection library and wizard for apps | ||
```js | ||
import { ad4mConnect } from "@perspect3vism/ad4m-connect/electron"; | ||
import { ad4mConnect } from '@perspect3vism/ad4m-connect/dist/electron' | ||
``` | ||
@@ -23,3 +23,3 @@ | ||
```js | ||
const { ad4mConnect } = require("@perspect3vism/ad4m-connect/electron"); | ||
const { ad4mConnect } = require('@perspect3vism/ad4m-connect/dist/electron') | ||
``` | ||
@@ -26,0 +26,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
7287231
30
6787