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

circle-ihk

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

circle-ihk - npm Package Compare versions

Comparing version 1.0.0-11 to 1.0.1

dist/utils/data-from-template.d.ts

31

dist/hook/useQuery.d.ts
/// <reference types="react" />
import { Match, Pager } from '../interface';
interface IProps extends Pager {
import { Match } from '../interface';
interface IProps {
field?: string;
keyRange?: any | Array<any>;
start?: number;
limit?: number;
searchIn?: string | Array<string>;

@@ -8,2 +12,3 @@ search?: string;

match?: Match;
table?: string;
}

@@ -14,4 +19,22 @@ export default function useQuery(props: IProps): {

data: any[];
query: IProps;
onQuery: import("react").Dispatch<import("react").SetStateAction<IProps>>;
query: {
field?: string | undefined;
keyRange?: any;
start?: number | undefined;
limit?: number | undefined;
searchIn?: string | string[] | undefined;
search?: string | undefined;
order?: "DESC" | "ASC" | undefined;
match?: Match | undefined;
};
onQuery: import("react").Dispatch<import("react").SetStateAction<{
field?: string | undefined;
keyRange?: any;
start?: number | undefined;
limit?: number | undefined;
searchIn?: string | string[] | undefined;
search?: string | undefined;
order?: "DESC" | "ASC" | undefined;
match?: Match | undefined;
}>>;
onChange: (value: any, key: string, callback?: ((error?: string) => void) | undefined) => void;

@@ -18,0 +41,0 @@ loading: boolean;

9

dist/hook/useQuery.js

@@ -5,6 +5,7 @@ import { useRef, useState, useEffect } from 'react';

export default function useQuery(props) {
const { table = 'node', ...prop } = props;
const { app, me, container } = useApp();
const done = useRef(false);
const [loading, setLoading] = useState(false);
const [query, onQuery] = useState(props);
const [query, onQuery] = useState(prop);
const [data, setData] = useState([]);

@@ -15,3 +16,3 @@ const refetch = (callback) => {

app
.list(reset, { start, limit })
.list(reset, { start, limit }, table)
.then((results = []) => {

@@ -46,5 +47,5 @@ if (!Array.isArray(results)) {

app
.set(value, key, 'node')
.set(value, key, table)
.then((id) => {
app.get(id, 'node').then((val) => {
app.get(id, table).then((val) => {
const index = data.findIndex((prop) => prop.id === key);

@@ -51,0 +52,0 @@ if (index >= 0) {

@@ -5,5 +5,5 @@ import { User } from '../interface';

user: User;
sync: () => Promise<boolean>;
logout(): Promise<any>;
login: () => Promise<boolean>;
logout(): Promise<boolean>;
regcode(regcode_code: string, mail?: string): Promise<boolean>;
};

@@ -7,159 +7,18 @@ import { useState } from 'react';

const [user, setUser] = useState(app.user);
const getToken = () => {
return new Promise((resolve, reject) => {
if (user.token) {
resolve(user.token);
return;
}
app
.fetch('user/token.json', {
method: 'POST',
})
.then((data) => {
app
.set('user', btoa({
...user,
token: data.token,
}))
.then(() => {
app.syncUser().then((val) => {
setUser(val);
resolve(data.token);
});
});
})
.catch(reject);
});
const login = () => {
return app.fetch('user/get').then((data) => app.set('user', btoa(data)).then(() => app.syncUser().then((val) => {
setUser({ ...val });
return Promise.resolve(true);
})));
};
const sync = () => {
return getToken()
.then((token) => app
.fetch('user/current', {
headers: {
'X-CSRF-Token': token,
'Content-Type': 'application/json',
},
})
.then((current) => Promise.resolve({
...current,
token,
})))
.then((result) => {
return app
.set('user', btoa({
...user,
...result,
}))
.then(() => {
return app.syncUser().then((val) => {
setUser(val);
return Promise.resolve(true);
});
});
});
};
return {
app,
user,
sync,
// login(
// {
// username,
// password,
// }: {
// username: string;
// password: string;
// },
// remeberMe?: boolean
// ) {
// return token()
// .then((token) => {
// return app.fetch('user/login', {
// method: 'POST',
// headers: {
// token: btoa({
// username,
// password,
// }),
// 'X-CSRF-Token': token,
// 'Content-Type': 'application/json',
// },
// });
// })
// .then((result) => {
// const loginData = {
// ...result,
// };
// if (!remeberMe && loginData.auth) {
// delete loginData.auth;
// }
// return app.set('user', btoa(loginData)).then(() => {
// return app.syncUser().then((val) => {
// setUser(val);
// return Promise.resolve(true);
// });
// });
// })
// .catch(() => Promise.resolve(false));
// },
login,
logout() {
return getToken().then((token) => app
.fetch('user/logout.json', {
method: 'POST',
headers: {
'X-CSRF-Token': token,
'Content-Type': 'application/json',
},
})
.finally(() => {
return app
.set('user', btoa({ uid: user.uid, roles: [] }))
.then(() => {
return app.syncUser().then((val) => {
setUser(val);
return Promise.resolve(true);
});
});
return app.set('user', btoa({ uid: user.uid, roles: [] })).then(() => app.syncUser().then((val) => {
setUser({ ...val });
return Promise.resolve(true);
}));
},
// resetPwd(
// {
// username,
// password,
// newpassword,
// }: {
// username: string;
// password: string;
// newpassword: string;
// },
// remeberMe?: boolean
// ) {
// return app
// .fetch('user/resetpwd', {
// method: 'POST',
// headers: {
// token: btoa({
// username,
// password,
// newpassword,
// }),
// 'Content-Type': 'application/json',
// },
// })
// .then((result) => {
// const resetData = {
// ...user,
// };
// if (remeberMe) {
// resetData.auth = result.auth;
// }
// return app.set('user', btoa(resetData)).then(() => {
// return app.syncUser().then((val) => {
// setUser(val);
// return Promise.resolve(true);
// });
// });
// })
// .catch(() => Promise.resolve(false));
// },
regcode(regcode_code, mail = '') {

@@ -180,5 +39,5 @@ if (!regcode_code) {

})
.then(sync);
.then(login);
},
};
}

@@ -7,2 +7,3 @@ export { default as AppContext } from './hook';

export { default as useOption } from './hook/useOption';
export { default as nid } from './utils/nid';
export { default as url } from './utils/url';

@@ -25,6 +26,10 @@ export { default as attr } from './utils/attr';

export { default as observe } from './utils/observe';
export { default as iterator } from './utils/iterator';
export { default as keyboard } from './utils/keyboard';
export { default as nodeText } from './utils/node-text';
export { default as queryTitle } from './utils/query-title';
export { default as pageNode } from './utils/page-node';
export { default as pageStyle } from './utils/page-style';
export { default as dataFromTemplate } from './utils/data-from-template';
export { default as filterPluginField } from './utils/filter-plugin-field';
export { User, App, Plugin, IData, Match, Query, Pager } from './interface';
export { isType, isTextNode, isChinese, isUndefined, isString, isElement, isNumber, isFunction, isBoolean, isObject, isAsyncFunction, } from './utils/is';
export { isType, isNumber, isObject, isString, isElement, isBoolean, isChinese, isFunction, isTextNode, isUndefined, isAsyncFunction, } from './utils/is';

@@ -7,2 +7,3 @@ export { default as AppContext } from './hook';

export { default as useOption } from './hook/useOption';
export { default as nid } from './utils/nid';
export { default as url } from './utils/url';

@@ -25,5 +26,9 @@ export { default as attr } from './utils/attr';

export { default as observe } from './utils/observe';
export { default as iterator } from './utils/iterator';
export { default as keyboard } from './utils/keyboard';
export { default as nodeText } from './utils/node-text';
export { default as queryTitle } from './utils/query-title';
export { isType, isTextNode, isChinese, isUndefined, isString, isElement, isNumber, isFunction, isBoolean, isObject, isAsyncFunction, } from './utils/is';
export { default as pageNode } from './utils/page-node';
export { default as pageStyle } from './utils/page-style';
export { default as dataFromTemplate } from './utils/data-from-template';
export { default as filterPluginField } from './utils/filter-plugin-field';
export { isType, isNumber, isObject, isString, isElement, isBoolean, isChinese, isFunction, isTextNode, isUndefined, isAsyncFunction, } from './utils/is';
export interface User {
auth?: string;
token?: string;
uid?: string;
uid: string;
name?: string;

@@ -10,2 +8,3 @@ expire?: string;

roles: Array<string>;
access_token?: string;
}

@@ -20,3 +19,2 @@ export interface Plugin {

version?: string;
preset?: boolean;
priority?: number;

@@ -96,7 +94,12 @@ description?: string;

user: User;
colorScheme: '' | 'light' | 'dark';
getURL: (path: string) => string;
colorScheme: {
value: '' | 'light' | 'dark';
};
tables: Array<{
table: 'apps' | 'option' | 'node';
indexs: string | Array<string>;
freeze: Array<string>;
}>;
url2json: (url: string) => any;
path: (id?: string) => string;

@@ -123,9 +126,15 @@ isExtPage: (url?: string) => boolean;

data: any;
}) => Promise<any>;
}, type?: string) => Promise<any>;
reset: (value?: string) => Promise<any>;
contextMenus: (action: 'create' | 'update' | 'remove' | 'destory' | 'rebuild', value: string | {
contextMenus: (action: 'create' | 'update' | 'remove' | 'destory' | 'rebuild', value?: string | {
id: string;
title: string;
enabled?: boolean;
}) => Promise<any>;
label?: string;
checked?: boolean;
} | Array<{
id: string;
label: string;
priority?: number;
checked: boolean;
global?: boolean;
}>) => Promise<any>;
tabs: (action: 'create' | 'update' | 'remove' | 'captureVisibleTab' | 'query', value?: any) => Promise<any>;

@@ -132,0 +141,0 @@ windows: (action: 'current' | 'create' | 'get' | 'update' | 'remove', value?: number | {

import { App } from '../interface';
export default function (app: App, callback?: (grant?: any) => void, btnText?: string): void;
export default function (app: App, callback?: (pass?: boolean) => void, btnText?: string): void;
export default function (app, callback, btnText) {
app.get('alert').then((data) => {
if (data) {
callback && callback();
callback && callback(true);
return;

@@ -13,5 +13,5 @@ }

}, () => {
app.set('alert', true).then(callback);
app.set('alert', true);
});
});
}
{
"name": "circle-ihk",
"version": "1.0.0-11",
"version": "1.0.1",
"license": "MIT",

@@ -24,2 +24,3 @@ "description": "Circle Reader Component Library",

"dependencies": {
"nanoid": "^5.0.5",
"react": "^18.2.0"

@@ -26,0 +27,0 @@ },

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