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.1 to 1.0.2

dist/utils/page-info.d.ts

2

dist/hook/useOption.js

@@ -48,3 +48,3 @@ import useApp from './useApp';

else if (id === 'display') {
fieldToListen = `${me.id}_display_option`;
fieldToListen = `${me.id}_display_${app.colorScheme.value ? app.colorScheme.value + '_' : ''}option`;
}

@@ -51,0 +51,0 @@ return app.on(fieldToListen, refetch);

import { useState } from 'react';
import btoa from '../utils/btoa';
import useApp from './useApp';

@@ -8,3 +7,4 @@ export default function useUser() {

const login = () => {
return app.fetch('user/get').then((data) => app.set('user', btoa(data)).then(() => app.syncUser().then((val) => {
// 先清空 access_token 再登录
return app.syncUser({ ...app.user, access_token: '' }).then(() => app.fetch('user/get').then((data) => app.syncUser(data).then((val) => {
setUser({ ...val });

@@ -19,6 +19,8 @@ return Promise.resolve(true);

logout() {
return app.set('user', btoa({ uid: user.uid, roles: [] })).then(() => app.syncUser().then((val) => {
return app
.syncUser({ uid: user.uid, roles: [], access_token: '' })
.then((val) => {
setUser({ ...val });
return Promise.resolve(true);
}));
});
},

@@ -25,0 +27,0 @@ regcode(regcode_code, mail = '') {

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

export { default as useOption } from './hook/useOption';
export { default as webdav } from './webdav';
export { default as nid } from './utils/nid';
export { default as url } from './utils/url';
export { default as attr } from './utils/attr';
export { default as unix } from './utils/unix';
export { default as each } from './utils/each';
export { default as noop } from './utils/noop';
export { default as atou } from './utils/atou';
export { default as btoa } from './utils/btoa';
export { parse, stringify } from './utils/json';
export { getHash, setHash } from './utils/hash';
export { default as alert } from './utils/alert';
export { default as isTag } from './utils/istag';
export { default as style } from './utils/style';
export { default as remove } from './utils/remove';
export { default as brower } from './utils/brower';
export { default as create } from './utils/create';
export { default as zIndex } from './utils/zindex';
export { default as observe } from './utils/observe';

@@ -29,7 +22,7 @@ export { default as iterator } from './utils/iterator';

export { default as nodeText } from './utils/node-text';
export { default as pageInfo } from './utils/page-info';
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, isNumber, isObject, isString, isElement, isBoolean, isChinese, isFunction, isTextNode, isUndefined, isAsyncFunction, } from './utils/is';
export { isTag, isType, isNumber, isObject, isString, isElement, isBoolean, isChinese, isFunction, isTextNode, isUndefined, isAsyncFunction, } from './utils/is';

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

export { default as useOption } from './hook/useOption';
export { default as webdav } from './webdav';
export { default as nid } from './utils/nid';
export { default as url } from './utils/url';
export { default as attr } from './utils/attr';
export { default as unix } from './utils/unix';
export { default as each } from './utils/each';
export { default as noop } from './utils/noop';
export { default as atou } from './utils/atou';
export { default as btoa } from './utils/btoa';
export { parse, stringify } from './utils/json';
export { getHash, setHash } from './utils/hash';
export { default as alert } from './utils/alert';
export { default as isTag } from './utils/istag';
export { default as style } from './utils/style';
export { default as remove } from './utils/remove';
export { default as brower } from './utils/brower';
export { default as create } from './utils/create';
export { default as zIndex } from './utils/zindex';
export { default as observe } from './utils/observe';

@@ -29,6 +22,6 @@ export { default as iterator } from './utils/iterator';

export { default as nodeText } from './utils/node-text';
export { default as pageInfo } from './utils/page-info';
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 { isTag, isType, isNumber, isObject, isString, isElement, isBoolean, isChinese, isFunction, isTextNode, isUndefined, isAsyncFunction, } from './utils/is';

@@ -9,2 +9,3 @@ export interface User {

access_token?: string;
is_logged_in?: boolean;
}

@@ -22,3 +23,3 @@ export interface Plugin {

author?: string;
pro?: boolean;
access?: 'member' | 'premium';
homepage?: string;

@@ -56,2 +57,3 @@ dependencies?: string[];

export interface App {
v3: boolean;
version: string;

@@ -106,2 +108,3 @@ language: string;

path: (id?: string) => string;
match: (data: Array<any>, match?: string) => any;
isExtPage: (url?: string) => boolean;

@@ -131,12 +134,22 @@ field: (id?: string | Array<string> | {

id: string;
label?: string;
checked?: boolean;
type?: string;
label: string;
action?: boolean;
checked: boolean;
priority?: number;
contexts?: [string];
} | Array<{
id: string;
type?: string;
label: string;
action?: boolean;
checked: boolean;
priority?: number;
checked: boolean;
global?: boolean;
contexts?: [string];
}>) => Promise<any>;
tabs: (action: 'create' | 'update' | 'remove' | 'captureVisibleTab' | 'query', value?: any) => Promise<any>;
fontSettings: (action: 'list') => Promise<Array<{
displayName: string;
fontId: string;
}>>;
windows: (action: 'current' | 'create' | 'get' | 'update' | 'remove', value?: number | {

@@ -148,16 +161,17 @@ id?: number;

}) => Promise<any>;
warning: (...args: Array<string>) => void;
info: (...args: Array<string>) => void;
error: (...args: Array<string>) => void;
success: (...args: Array<string>) => void;
syncUser: () => Promise<User>;
cron: (force?: boolean) => Promise<boolean>;
getApp(id: string | Plugin): Promise<Plugin>;
warning: (...args: Array<string>) => () => void;
info: (...args: Array<string>) => () => void;
error: (...args: Array<string>) => () => void;
success: (...args: Array<string>) => () => void;
loading: (...args: Array<string>) => () => void;
syncUser: (user?: User) => Promise<User>;
cron: (callback: () => void, duration?: number) => Promise<boolean>;
getApp(id: string | Array<string> | Plugin | Array<Plugin>): Promise<Plugin>;
listApp: (match?: Match, pager?: Pager) => Promise<Array<Plugin>>;
enable: (id: string | Plugin) => Promise<boolean>;
disable: (id: string | Plugin) => Promise<boolean>;
uninstall: (id: string | Plugin) => Promise<boolean>;
install: (id: string | Plugin) => Promise<boolean>;
apply: (runAt: string, scope?: string) => Promise<boolean>;
dynamicRun(id: string | Plugin): Promise<boolean>;
enable: (id: string | Array<string> | Plugin | Array<Plugin>) => Promise<boolean>;
disable: (id: string | Array<string> | Plugin | Array<Plugin>) => Promise<boolean>;
uninstall: (id: string | Array<string> | Plugin | Array<Plugin>) => Promise<boolean>;
install: (id: string | Array<string> | Plugin | Array<Plugin>) => Promise<boolean>;
apply: (runAt: string) => Promise<boolean>;
dynamicRun(id: string): Promise<boolean>;
i18n: (...args: Array<string>) => string;

@@ -164,0 +178,0 @@ fetch: (url: string, options?: {

import { App } from '../interface';
export default function dataFromTemplate(app: App, templateId?: string, part?: string): Promise<any>;
export default function dataFromTemplate<T>(app: App, templateId: T, args: {
id: string;
format?: boolean;
part?: string | HTMLElement;
option?: {
[index: string]: string;
};
}): Promise<T>;
import templateContext from './template-context';
import { isObject, isUndefined, isString, isNumber } from './is';
export default function dataFromTemplate(app, templateId = 'template', part) {
return app.option('option').then((option) => {
const templateValue = option && option[templateId] ? option[templateId] : '';
if (!isString(templateValue) || templateValue.length <= 0) {
return Promise.resolve('Export template not found');
}
const context = templateContext(app, part);
return Promise.resolve(templateValue.replace(/\[(.*?)\]/g, (match, key) => {
const [scope, attr, start, end] = key.trim().split(':');
if (scope && attr) {
const scopeValue = context[scope];
if (isObject(scopeValue) && !isUndefined(scopeValue[attr])) {
const valueToReturn = `${scopeValue[attr]}`;
if (start && end) {
const startVal = parseFloat(start);
const endVal = parseFloat(end);
if (isNumber(startVal) &&
startVal >= 0 &&
isNumber(endVal) &&
endVal > 0 &&
endVal > startVal) {
const valToReturn = valueToReturn.slice(startVal, endVal);
if (endVal < valueToReturn.length) {
return `${valToReturn}...`;
import { isObject, isUndefined, isNumber } from './is';
export default function dataFromTemplate(app, templateId, args) {
return (args.option ? Promise.resolve(args.option) : app.option('option')).then((result) => {
const returnValue = [];
const context = templateContext(app, args.part, args.format);
(Array.isArray(templateId) ? templateId : [templateId]).forEach((template) => {
const templateValue = result && result[template]
? result[template]
: 'Export template not found';
const data = templateValue.replace(/\[([^[|^\]]+)\]/g, (match, key) => {
const [scope, attr, start, end] = key.trim().split(':');
if (scope && attr) {
const scopeValue = context[scope];
if (isObject(scopeValue)) {
const value = scopeValue[attr];
if (isUndefined(value)) {
return '';
}
const valueToReturn = `${value}`;
if (start && end) {
const startVal = parseFloat(start);
const endVal = parseFloat(end);
if (isNumber(startVal) &&
startVal >= 0 &&
isNumber(endVal) &&
endVal > 0 &&
endVal > startVal) {
const valToReturn = valueToReturn.slice(startVal, endVal);
if (endVal < valueToReturn.length) {
return `${valToReturn}...`;
}
return valToReturn;
}
return valToReturn;
return valueToReturn;
}
return valueToReturn;
}
return valueToReturn;
return match;
}
return match;
}
return match;
}));
});
returnValue.push(app.applyFilter(template, data, args.id));
});
return Promise.resolve(returnValue.length === 1 ? returnValue[0] : returnValue);
});
}

@@ -5,2 +5,3 @@ export declare function isType(value: any, type: string): boolean;

export declare function isTextNode(value: any): boolean;
export declare function isTag(node: Element | null, name: string): boolean | "" | null;
export declare function isElement(value: any): any;

@@ -7,0 +8,0 @@ export declare function isNumber(value: any): boolean;

@@ -13,2 +13,5 @@ export function isType(value, type) {

}
export function isTag(node, name) {
return node && node.tagName && node.tagName.toLowerCase() === name;
}
export function isElement(value) {

@@ -15,0 +18,0 @@ return value && value.nodeType && value.nodeType === 1;

import { App } from '../interface';
export default function pageNode(app: App): any[];
export default function pageNode(app: App, format?: boolean): any[];
import url from './url';
import each from './each';
import remove from './remove';
import { isElement } from './is';
import { isElement, isString } from './is';
import iterator from './iterator';
export default function pageNode(app) {
function formatFN(app, node) {
const images = node.getElementsByTagName('img');
if (images.length > 0) {
const contentClone = iterator(node);
const container = app.field('container');
if (isElement(container) &&
container.style.cssText.indexOf('imagehide: none') >= 0) {
each(contentClone.getElementsByTagName('img'), (item) => item && item.parentElement && item.parentElement.removeChild(item));
}
else {
each(contentClone.getElementsByTagName('img'), (item) => {
const target = item._mirrorElement && item._mirrorElement._mirrorElement
? item._mirrorElement._mirrorElement
: item;
const attrToRemove = [];
each(item.attributes, (attribute) => {
const name = attribute.nodeName;
!['class', 'src'].includes(name) && attrToRemove.push(name);
});
each(attrToRemove, (attr) => {
item.removeAttribute(attr);
});
const width = Math.min(target.width, 410);
item.width = width;
item.height = target.height * (width / target.width);
item.src = item.src.replace('https', 'http');
});
}
return contentClone;
}
return node;
}
export default function pageNode(app, format = true) {
const data = app.field('node');
const currentUrl = url();
if (Array.isArray(data)) {
return data.map((item) => {
if (item.url === currentUrl) {
if (isElement(item.content)) {
const images = item.content.getElementsByTagName('img');
if (images.length > 0) {
const contentClone = iterator(item.content);
const container = app.field('container');
if (isElement(container) &&
container.style.cssText.indexOf('imagehide: none') >= 0) {
each(contentClone.getElementsByTagName('img'), (item) => remove(item));
}
else {
each(contentClone.getElementsByTagName('img'), (item) => {
const attrToRemove = [];
each(item.attributes, (attribute) => {
const name = attribute.nodeName;
!['class', 'src'].includes(name) && attrToRemove.push(name);
});
each(attrToRemove, (attr) => {
item.removeAttribute(attr);
});
const width = Math.min(item.width, 410);
item.width = width;
item.height = item.height * (width / item.width);
item.src = item.src.replace('https', 'http');
});
}
item.content = contentClone;
if (Array.isArray(item.content)) {
let data = '';
item.content.forEach((node) => {
if (isString(node.content)) {
data += node.content;
}
}
return item;
else if (isElement(node.content)) {
data += (format ? formatFN(app, node.content) : node.content)
.innerHTML;
}
});
const wrapper = document.createElement('div');
wrapper.innerHTML = data;
item.content = wrapper;
}
else if (isElement(item.content)) {
item.content = format ? formatFN(app, item.content) : item.content;
}
if (!item.title) {

@@ -50,3 +67,3 @@ item.title = `${app.i18n('name')} - ${app.i18n('description')}`;

{
url: currentUrl,
url: url(),
title: document.title,

@@ -53,0 +70,0 @@ content: document.body,

import each from './each';
import isTag from './istag';
import { isElement } from './is';
import { isTag, isElement } from './is';
export default function pageStyle(app) {

@@ -5,0 +4,0 @@ const container = app.field('container');

import { App } from '../interface';
export default function templateContext(app: App, content?: string): {
export default function templateContext(app: App, content?: string | HTMLElement, format?: boolean): {
[index: string]: {

@@ -4,0 +4,0 @@ [index: string]: number | string;

import pageNode from './page-node';
import { isElement, isString } from './is';
export default function templateContext(app, content) {
export default function templateContext(app, content, format) {
const pageFields = pageNode(app);

@@ -13,5 +13,16 @@ const pageField = Array.isArray(pageFields) && pageFields.length > 0 ? pageFields[0] : {};

let htmlToReturn = '';
if (content && isString(content) && content.length > 0) {
textToReturn = content;
htmlToReturn = content;
if (content) {
// @ts-ignore
if (isString(content) && content.length > 0) {
// @ts-ignore
const value = format ? content.replace(/\n+/g, '<br />') : content;
textToReturn = value;
htmlToReturn = value;
}
else if (isElement(content)) {
// @ts-ignore
textToReturn = content.innerText;
// @ts-ignore
htmlToReturn = content.innerHTML;
}
}

@@ -18,0 +29,0 @@ else {

{
"name": "circle-ihk",
"version": "1.0.1",
"version": "1.0.2",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "Circle Reader Component Library",

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