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

@waline/client

Package Overview
Dependencies
Maintainers
2
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@waline/client - npm Package Compare versions

Comparing version 2.13.1 to 2.14.0

src/styles/normalize.scss

94

dist/api.d.ts

@@ -15,2 +15,16 @@ interface BaseAPIOptions {

}
interface ErrorStatusResponse {
/**
* 错误代码
*
* Error number
*/
errno: number;
/**
* 错误消息
*
* Error msg
*/
errmsg: string;
}

@@ -97,6 +111,2 @@ interface GetArticleCounterOptions extends BaseAPIOptions {

/**
* edit comment id
*/
eid?: string;
/**
* Comment link

@@ -142,3 +152,3 @@ */

/**
* 待获取评论列hi奥德路径
* 待获取评论列表的 path
*

@@ -151,7 +161,7 @@ * Path of comment list

*
* Comment panination number
* Comment pagination number
*/
page: number;
/**
* 评论每页个数
* 每页评论个数
*

@@ -180,3 +190,3 @@ * Comment number per page

}
interface GetCommentResponse {
interface GetCommentResponse extends ErrorStatusResponse {
/**

@@ -189,2 +199,14 @@ * 评论数量

/**
* 评论分页数
*
* Comment pagination number
*/
page: number;
/**
* 每页评论个数
*
* Comment number per page
*/
pageSize: number;
/**
* 评论数据

@@ -217,3 +239,3 @@ *

}
interface AddCommentResponse {
interface AddCommentResponse extends ErrorStatusResponse {
/**

@@ -225,4 +247,2 @@ * 渲染好的评论数据

data?: WalineComment;
/** 错误原因 */
errmsg?: string;
}

@@ -234,18 +254,6 @@ declare const addComment: ({ serverURL, lang, token, comment, }: AddCommentOptions) => Promise<AddCommentResponse>;

}
declare const deleteComment: ({ serverURL, lang, token, objectId, }: DeleteCommentOptions) => Promise<void>;
interface LikeCommentOptions extends BaseAPIOptions {
/**
* 评论的 ID
*
* Comment ID
*/
objectId: number | string;
/**
* 点赞还是取消点赞
*
* Like or dislike
*/
like: boolean;
interface DeleteCommentResponse extends ErrorStatusResponse {
data: '';
}
declare const likeComment: ({ serverURL, lang, objectId, like, }: LikeCommentOptions) => Promise<void>;
declare const deleteComment: ({ serverURL, lang, token, objectId, }: DeleteCommentOptions) => Promise<DeleteCommentResponse>;
interface UpdateCommentOptions extends BaseAPIOptions {

@@ -265,2 +273,14 @@ /**

/**
* 评论数据
*
* Comment data
*/
comment?: WalineCommentData;
/**
* 点赞还是取消点赞
*
* Like or dislike
*/
like?: boolean;
/**
* 评论的状态

@@ -280,3 +300,11 @@ *

}
declare const updateComment: ({ serverURL, lang, token, objectId, ...data }: UpdateCommentOptions) => Promise<void>;
interface UpdateCommentResponse extends ErrorStatusResponse {
/**
* 更新后的评论数据
*
* Comment data rendered
*/
data: WalineComment;
}
declare const updateComment: ({ serverURL, lang, token, objectId, ...data }: UpdateCommentOptions) => Promise<UpdateCommentResponse>;

@@ -367,3 +395,3 @@ interface GetCommentCountOptions extends BaseAPIOptions {

}
declare const getPageviews: ({ serverURL, lang, paths, signal, }: GetPageviewOptions) => Promise<number[]>;
declare const getPageview: ({ serverURL, lang, paths, signal, }: GetPageviewOptions) => Promise<number[]>;
interface UpdatePageviewOptions extends BaseAPIOptions {

@@ -377,3 +405,3 @@ /**

}
declare const updatePageviews: (options: UpdatePageviewOptions) => Promise<number>;
declare const updatePageview: (options: UpdatePageviewOptions) => Promise<number>;

@@ -384,3 +412,3 @@ interface GetRecentCommentOptions extends BaseAPIOptions {

*
* Comment numebr to be fetched
* Comment number to be fetched
*/

@@ -420,5 +448,3 @@ count: number;

}
interface GetUserListResponse {
errno: number;
message: string;
interface GetUserListResponse extends ErrorStatusResponse {
data: WalineUser[];

@@ -428,2 +454,2 @@ }

export { AddCommentOptions, AddCommentResponse, DeleteCommentOptions, GetArticleCounterOptions, GetArticleCounterResponse, GetCommentCountOptions, GetCommentOptions, GetCommentResponse, GetRecentCommentOptions, GetUserListOptions, GetUserListResponse, LikeCommentOptions, UpdateArticleCounterOptions, UpdateCommentOptions, UpdatePageviewOptions, UserInfo, WalineUser, addComment, deleteComment, fetchCommentCount, getArticleCounter, getComment, getPageviews, getRecentComment, getUserList, likeComment, login, updateArticleCounter, updateComment, updatePageviews };
export { AddCommentOptions, AddCommentResponse, DeleteCommentOptions, DeleteCommentResponse, GetArticleCounterOptions, GetArticleCounterResponse, GetCommentCountOptions, GetCommentOptions, GetCommentResponse, GetRecentCommentOptions, GetUserListOptions, GetUserListResponse, UpdateArticleCounterOptions, UpdateCommentOptions, UpdateCommentResponse, UpdatePageviewOptions, UserInfo, WalineUser, addComment, deleteComment, fetchCommentCount, getArticleCounter, getComment, getPageview, getRecentComment, getUserList, login, updateArticleCounter, updateComment, updatePageview };

@@ -13,3 +13,3 @@ type WalineAbort = (reason?: any) => void;

*
* Commment count CSS selector
* Comment count CSS selector
*

@@ -16,0 +16,0 @@ * @default '.waline-comment-count'

@@ -20,56 +20,51 @@ (function (global, factory) {

_exports.version = _exports.commentCount = void 0;
const e = _ref => {
let {
serverURL: e,
lang: t,
paths: r,
signal: n
} = _ref;
return fetch(`${e}/comment?type=count&url=${encodeURIComponent(r.join(","))}&lang=${t}`, {
signal: n
}).then(e => e.json()).then(e => function (e) {
let t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
if ("object" == typeof e && e.errno) throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);
return e;
}(e, "comment count")).then(e => Array.isArray(e) ? e : [e]);
const t = t => {
const e = function () {
let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return t.replace(/\/$/u, "");
}(t);
return /^(https?:)?\/\//.test(e) ? e : `https://${e}`;
},
t = e => {
const t = function () {
let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return e.replace(/\/$/u, "");
}(e);
return /^(https?:)?\/\//.test(t) ? t : `https://${t}`;
e = t => {
"AbortError" !== t.name && console.error(t.message);
},
r = e => {
"AbortError" !== e.name && console.error(e.message);
},
n = _ref2 => {
r = _ref => {
let {
serverURL: n,
path: o = window.location.pathname,
selector: a = ".waline-comment-count",
lang: c = "zh-CN"
} = _ref2;
serverURL: r,
path: n = window.location.pathname,
selector: o = ".waline-comment-count",
lang: a = "zh-CN"
} = _ref;
const s = new AbortController(),
l = document.querySelectorAll(a);
return l.length && e({
serverURL: t(n),
paths: Array.from(l).map(e => (e => {
c = document.querySelectorAll(o);
return c.length && (_ref2 => {
let {
serverURL: t,
lang: e,
paths: r,
signal: n
} = _ref2;
return fetch(`${t}/comment?type=count&url=${encodeURIComponent(r.join(","))}&lang=${e}`, {
signal: n
}).then(t => t.json()).then(t => Array.isArray(t) ? t : [t]);
})({
serverURL: t(r),
paths: Array.from(c).map(t => (t => {
try {
e = decodeURI(e);
} catch (e) {}
return e;
})(e.dataset.path || e.getAttribute("id") || o)),
lang: c,
t = decodeURI(t);
} catch (t) {}
return t;
})(t.dataset.path || t.getAttribute("id") || n)),
lang: a,
signal: s.signal
}).then(e => {
l.forEach((t, r) => {
t.innerText = e[r].toString();
}).then(t => {
c.forEach((e, r) => {
e.innerText = t[r].toString();
});
}).catch(r), s.abort.bind(s);
}).catch(e), s.abort.bind(s);
},
o = "2.13.1";
_exports.version = o;
_exports.commentCount = n;
n = "2.14.0";
_exports.version = n;
_exports.commentCount = r;
});
//# sourceMappingURL=comment.js.map

@@ -0,1 +1,2 @@

type WalineCommentSorting = 'latest' | 'oldest' | 'hottest';
interface WalineEmojiInfo {

@@ -39,2 +40,3 @@ /**

}
type WalineLoginStatus = 'enable' | 'disable' | 'force';
interface WalineSearchImageData extends Record<string, unknown> {

@@ -97,3 +99,3 @@ /**

*/
more?: (word: string, currectCount: number) => Promise<WalineSearchResult>;
more?: (word: string, currentCount: number) => Promise<WalineSearchResult>;
}

@@ -279,2 +281,10 @@ type WalineMeta = 'nick' | 'mail' | 'link';

/**
* 评论列表排序方式
*
* Sorting method for comment list
*
* @default 'latest'
*/
commentSorting?: WalineCommentSorting;
/**
* 是否启用暗黑模式适配

@@ -336,3 +346,3 @@ *

* - `'enable'`: enable login (default)
* - `'disable'`: Login is disabled, users should fill in infomation to comment
* - `'disable'`: Login is disabled, users should fill in information to comment
* - `'force'`: Forced login, users must login to comment

@@ -342,3 +352,3 @@ *

*/
login?: 'enable' | 'disable' | 'force';
login?: WalineLoginStatus;
/**

@@ -345,0 +355,0 @@ * 是否在页脚展示版权信息

@@ -20,17 +20,12 @@ (function (global, factory) {

_exports.version = _exports.pageviewCount = void 0;
const e = "2.13.1",
const e = "2.14.0",
t = {
"Content-Type": "application/json"
},
n = function (e) {
let t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
if ("object" == typeof e && e.errno) throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);
return e;
},
r = _ref => {
n = _ref => {
let {
serverURL: e,
lang: t,
paths: r,
signal: a
paths: n,
signal: r
} = _ref;

@@ -41,34 +36,34 @@ return (_ref2 => {

lang: t,
paths: r,
type: a,
signal: o
paths: n,
type: r,
signal: a
} = _ref2;
return fetch(`${e}/article?path=${encodeURIComponent(r.join(","))}&type=${encodeURIComponent(a.join(","))}&lang=${t}`, {
signal: o
}).then(e => e.json()).then(e => n(e, "article count"));
return fetch(`${e}/article?path=${encodeURIComponent(n.join(","))}&type=${encodeURIComponent(r.join(","))}&lang=${t}`, {
signal: a
}).then(e => e.json());
})({
serverURL: e,
lang: t,
paths: r,
paths: n,
type: ["time"],
signal: a
signal: r
}).then(e => Array.isArray(e) ? e : [e]);
},
a = e => (_ref3 => {
r = e => (_ref3 => {
let {
serverURL: e,
lang: r,
path: a,
type: o,
action: l
lang: n,
path: r,
type: a,
action: o
} = _ref3;
return fetch(`${e}/article?lang=${r}`, {
return fetch(`${e}/article?lang=${n}`, {
method: "POST",
headers: t,
body: JSON.stringify({
path: a,
type: o,
action: l
path: r,
type: a,
action: o
})
}).then(e => e.json()).then(e => n(e, "article count"));
}).then(e => e.json());
})({

@@ -79,3 +74,3 @@ ...e,

}),
o = e => {
a = e => {
const t = function () {

@@ -87,6 +82,6 @@ let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";

},
l = e => {
o = e => {
"AbortError" !== e.name && console.error(e.message);
},
i = e => e.dataset.path || e.getAttribute("id"),
l = e => e.dataset.path || e.getAttribute("id"),
s = (e, t) => {

@@ -97,36 +92,36 @@ t.forEach((t, n) => {

},
c = _ref4 => {
i = _ref4 => {
let {
serverURL: e,
path: t = window.location.pathname,
selector: n = ".waline-pageview-count",
update: c = !0,
selector: i = ".waline-pageview-count",
update: p = !0,
lang: h = "zh-CN"
} = _ref4;
const p = new AbortController(),
g = Array.from(document.querySelectorAll(n)),
const c = new AbortController(),
g = Array.from(document.querySelectorAll(i)),
y = e => {
const n = i(e);
const n = l(e);
return null !== n && t !== n;
},
u = n => r({
serverURL: o(e),
paths: n.map(e => i(e) || t),
d = r => n({
serverURL: a(e),
paths: r.map(e => l(e) || t),
lang: h,
signal: p.signal
}).then(e => s(e, n)).catch(l);
if (c) {
signal: c.signal
}).then(e => s(e, r)).catch(o);
if (p) {
const n = g.filter(e => !y(e)),
r = g.filter(y);
a({
serverURL: o(e),
o = g.filter(y);
r({
serverURL: a(e),
path: t,
lang: h
}).then(e => s(new Array(n.length).fill(e), n)), r.length && u(r);
} else u(g);
return p.abort.bind(p);
}).then(e => s(new Array(n.length).fill(e), n)), o.length && d(o);
} else d(g);
return c.abort.bind(c);
};
_exports.pageviewCount = c;
_exports.pageviewCount = i;
_exports.version = e;
});
//# sourceMappingURL=pageview.js.map

@@ -0,1 +1,2 @@

type WalineCommentSorting = 'latest' | 'oldest' | 'hottest';
interface WalineEmojiInfo {

@@ -40,2 +41,3 @@ /**

type WalineEmojiMaps = Record<string, string>;
type WalineLoginStatus = 'enable' | 'disable' | 'force';
interface WalineSearchImageData extends Record<string, unknown> {

@@ -98,3 +100,3 @@ /**

*/
more?: (word: string, currectCount: number) => Promise<WalineSearchResult>;
more?: (word: string, currentCount: number) => Promise<WalineSearchResult>;
}

@@ -140,6 +142,2 @@ type WalineMeta = 'nick' | 'mail' | 'link';

/**
* edit comment id
*/
eid?: string;
/**
* Comment link

@@ -357,2 +355,10 @@ */

/**
* 评论列表排序方式
*
* Sorting method for comment list
*
* @default 'latest'
*/
commentSorting?: WalineCommentSorting;
/**
* 是否启用暗黑模式适配

@@ -414,3 +420,3 @@ *

* - `'enable'`: enable login (default)
* - `'disable'`: Login is disabled, users should fill in infomation to comment
* - `'disable'`: Login is disabled, users should fill in information to comment
* - `'force'`: Forced login, users must login to comment

@@ -420,3 +426,3 @@ *

*/
login?: 'enable' | 'disable' | 'force';
login?: WalineLoginStatus;
/**

@@ -495,3 +501,3 @@ * 是否在页脚展示版权信息

*
* Commment count CSS selector
* Comment count CSS selector
*

@@ -702,2 +708,2 @@ * @default '.waline-comment-count'

export { RecentComments, UserList, WalineAbort, WalineComment, WalineCommentCountOptions, WalineCommentData, WalineCommentStatus, WalineDateLocale, WalineEmojiInfo, WalineEmojiMaps, WalineHighlighter, WalineImageUploader, WalineInitOptions, WalineInstance, WalineLevelLocale, WalineLocale, WalineMeta, WalinePageviewCountOptions, WalineProps, WalineReactionLocale, WalineRecentCommentsOptions, WalineRecentCommentsResult, WalineSearchImageData, WalineSearchOptions, WalineSearchResult, WalineTexRenderer, WalineUserListOptions, WalineUserListResult, commentCount, defaultLocales, init, pageviewCount, version };
export { RecentComments, UserList, WalineAbort, WalineComment, WalineCommentCountOptions, WalineCommentData, WalineCommentSorting, WalineCommentStatus, WalineDateLocale, WalineEmojiInfo, WalineEmojiMaps, WalineHighlighter, WalineImageUploader, WalineInitOptions, WalineInstance, WalineLevelLocale, WalineLocale, WalineLoginStatus, WalineMeta, WalinePageviewCountOptions, WalineProps, WalineReactionLocale, WalineRecentCommentsOptions, WalineRecentCommentsResult, WalineSearchImageData, WalineSearchOptions, WalineSearchResult, WalineTexRenderer, WalineUserListOptions, WalineUserListResult, commentCount, defaultLocales, init, pageviewCount, version };
{
"name": "@waline/client",
"version": "2.13.1",
"version": "2.14.0",
"description": "client for waline comment system",

@@ -5,0 +5,0 @@ "keywords": [

@@ -1,2 +0,2 @@

import { JSON_HEADERS, errorCheck } from './utils';
import { JSON_HEADERS } from './utils';
import type { BaseAPIOptions } from './utils';

@@ -45,5 +45,3 @@

{ signal }
)
.then((resp) => <Promise<GetArticleCounterResponse>>resp.json())
.then((data) => errorCheck(data, 'article count'));
).then((resp) => <Promise<GetArticleCounterResponse>>resp.json());

@@ -86,4 +84,2 @@ export interface UpdateArticleCounterOptions extends BaseAPIOptions {

body: JSON.stringify({ path, type, action }),
})
.then((resp) => <Promise<number>>resp.json())
.then((data) => errorCheck(data, 'article count'));
}).then((resp) => <Promise<number>>resp.json());
import { JSON_HEADERS, errorCheck } from './utils';
import type { BaseAPIOptions } from './utils';
import type { BaseAPIOptions, ErrorStatusResponse } from './utils';
import type { WalineComment, WalineCommentData } from '../typings';

@@ -7,3 +7,3 @@

/**
* 待获取评论列hi奥德路径
* 待获取评论列表的 path
*

@@ -17,3 +17,3 @@ * Path of comment list

*
* Comment panination number
* Comment pagination number
*/

@@ -23,3 +23,3 @@ page: number;

/**
* 评论每页个数
* 每页评论个数
*

@@ -52,3 +52,3 @@ * Comment number per page

export interface GetCommentResponse {
export interface GetCommentResponse extends ErrorStatusResponse {
/**

@@ -62,2 +62,16 @@ * 评论数量

/**
* 评论分页数
*
* Comment pagination number
*/
page: number;
/**
* 每页评论个数
*
* Comment number per page
*/
pageSize: number;
/**
* 评论数据

@@ -98,3 +112,3 @@ *

.then((resp) => <Promise<GetCommentResponse>>resp.json())
.then((data) => errorCheck(data, 'comment data'));
.then((data) => errorCheck(data, 'Get comment data'));
};

@@ -118,3 +132,3 @@

export interface AddCommentResponse {
export interface AddCommentResponse extends ErrorStatusResponse {
/**

@@ -126,5 +140,2 @@ * 渲染好的评论数据

data?: WalineComment;
/** 错误原因 */
errmsg?: string;
}

@@ -145,10 +156,7 @@

return fetch(
`${serverURL}/comment${comment.eid ? `/${comment.eid}` : ''}?lang=${lang}`,
{
method: 'PUT',
headers,
body: JSON.stringify(comment),
}
).then((resp) => <Promise<AddCommentResponse>>resp.json());
return fetch(`${serverURL}/comment?lang=${lang}`, {
method: 'POST',
headers,
body: JSON.stringify(comment),
}).then((resp) => <Promise<AddCommentResponse>>resp.json());
};

@@ -161,2 +169,6 @@

export interface DeleteCommentResponse extends ErrorStatusResponse {
data: '';
}
export const deleteComment = ({

@@ -167,3 +179,3 @@ serverURL,

objectId,
}: DeleteCommentOptions): Promise<void> =>
}: DeleteCommentOptions): Promise<DeleteCommentResponse> =>
fetch(`${serverURL}/comment/${objectId}?lang=${lang}`, {

@@ -174,46 +186,34 @@ method: 'DELETE',

},
}).then((resp) => <Promise<void>>resp.json());
})
.then((resp) => <Promise<DeleteCommentResponse>>resp.json())
.then((resp) => errorCheck(resp, 'Delete comment'));
export interface LikeCommentOptions extends BaseAPIOptions {
export interface UpdateCommentOptions extends BaseAPIOptions {
/**
* 评论的 ID
* 用户令牌
*
* Comment ID
* User token
*/
objectId: number | string;
token: string;
/**
* 点赞还是取消点赞
* 评论的 ID
*
* Like or dislike
* Comment ID
*/
like: boolean;
}
objectId: number | string;
export const likeComment = ({
serverURL,
lang,
objectId,
like,
}: LikeCommentOptions): Promise<void> =>
fetch(`${serverURL}/comment/${objectId}?lang=${lang}`, {
method: 'PUT',
headers: JSON_HEADERS,
body: JSON.stringify({ like }),
}).then((resp) => <Promise<void>>resp.json());
export interface UpdateCommentOptions extends BaseAPIOptions {
/**
* 用户令牌
* 评论数据
*
* User token
* Comment data
*/
token: string;
comment?: WalineCommentData;
/**
* 评论的 ID
* 点赞还是取消点赞
*
* Comment ID
* Like or dislike
*/
objectId: number | string;
like?: boolean;

@@ -237,2 +237,11 @@ /**

export interface UpdateCommentResponse extends ErrorStatusResponse {
/**
* 更新后的评论数据
*
* Comment data rendered
*/
data: WalineComment;
}
export const updateComment = ({

@@ -244,3 +253,3 @@ serverURL,

...data
}: UpdateCommentOptions): Promise<void> =>
}: UpdateCommentOptions): Promise<UpdateCommentResponse> =>
fetch(`${serverURL}/comment/${objectId}?lang=${lang}`, {

@@ -253,2 +262,4 @@ method: 'PUT',

body: JSON.stringify(data),
}).then((resp) => <Promise<void>>resp.json());
})
.then((resp) => <Promise<UpdateCommentResponse>>resp.json())
.then((resp) => errorCheck(resp, 'Update comment'));

@@ -1,2 +0,1 @@

import { errorCheck } from './utils';
import type { BaseAPIOptions } from './utils';

@@ -33,4 +32,3 @@

.then((resp) => <Promise<number | number[]>>resp.json())
.then((data) => errorCheck(data, 'comment count'))
// TODO: Improve this API
.then((counts) => (Array.isArray(counts) ? counts : [counts]));

@@ -20,3 +20,3 @@ import { getArticleCounter, updateArticleCounter } from './articleCounter';

export const getPageviews = ({
export const getPageview = ({
serverURL,

@@ -48,3 +48,3 @@ lang,

export const updatePageviews = (
export const updatePageview = (
options: UpdatePageviewOptions

@@ -51,0 +51,0 @@ ): Promise<number> =>

@@ -1,2 +0,1 @@

import { errorCheck } from './utils';
import type { BaseAPIOptions } from './utils';

@@ -9,3 +8,3 @@ import type { WalineComment } from '../typings';

*
* Comment numebr to be fetched
* Comment number to be fetched
*/

@@ -43,5 +42,3 @@ count: number;

headers,
})
.then((resp) => <Promise<WalineComment[]>>resp.json())
.then((data) => errorCheck(data, 'recent comment'));
}).then((resp) => <Promise<WalineComment[]>>resp.json());
};

@@ -1,2 +0,2 @@

import { errorCheck } from './utils';
import { errorCheck, ErrorStatusResponse } from './utils';
import type { BaseAPIOptions } from './utils';

@@ -26,5 +26,3 @@ import type { WalineComment } from '../typings';

export interface GetUserListResponse {
errno: number;
message: string;
export interface GetUserListResponse extends ErrorStatusResponse {
data: WalineUser[];

@@ -31,0 +29,0 @@ }

@@ -17,4 +17,15 @@ export interface BaseAPIOptions {

export interface APIErrorResponse {
export interface ErrorStatusResponse {
/**
* 错误代码
*
* Error number
*/
errno: number;
/**
* 错误消息
*
* Error msg
*/
errmsg: string;

@@ -28,14 +39,10 @@ }

export const errorCheck = <T = unknown>(
data: T | APIErrorResponse,
export const errorCheck = <T extends ErrorStatusResponse>(
data: T,
name = ''
): T => {
if (typeof data === 'object' && (data as APIErrorResponse).errno)
throw new TypeError(
`Fetch ${name} failed with ${(data as APIErrorResponse).errno}: ${
(data as APIErrorResponse).errmsg
}`
);
if (typeof data === 'object' && data.errno)
throw new TypeError(`${name} failed with ${data.errno}: ${data.errmsg}`);
return data as T;
return data;
};

@@ -16,3 +16,3 @@ import { fetchCommentCount } from './api';

*
* Commment count CSS selector
* Comment count CSS selector
*

@@ -19,0 +19,0 @@ * @default '.waline-comment-count'

@@ -47,3 +47,3 @@ import { warning } from './logger';

// error with those which can no longr be handled
// error with those which can no longer be handled
DROPPED_OPTIONS_WHICH_CAN_NOT_BE_POLYFILLED.filter((item) =>

@@ -50,0 +50,0 @@ Object.keys(options).includes(item)

@@ -1,2 +0,2 @@

import { getPageviews, updatePageviews } from './api';
import { getPageview, updatePageview } from './api';
import { errorHandler, getQuery, getServerURL } from './utils';

@@ -81,3 +81,3 @@

const fetch = (elements: HTMLElement[]): Promise<void> =>
getPageviews({
getPageview({
serverURL: getServerURL(serverURL),

@@ -96,3 +96,3 @@ paths: elements.map((element) => getQuery(element) || path),

void updatePageviews({
void updatePageview({
serverURL: getServerURL(serverURL),

@@ -99,0 +99,0 @@ path,

@@ -0,1 +1,3 @@

export type WalineCommentSorting = 'latest' | 'oldest' | 'hottest';
export interface WalineEmojiInfo {

@@ -42,2 +44,4 @@ /**

export type WalineLoginStatus = 'enable' | 'disable' | 'force';
export interface WalineSearchImageData extends Record<string, unknown> {

@@ -106,3 +110,3 @@ /**

*/
more?: (word: string, currectCount: number) => Promise<WalineSearchResult>;
more?: (word: string, currentCount: number) => Promise<WalineSearchResult>;
}

@@ -109,0 +113,0 @@

@@ -44,10 +44,6 @@ export interface WalineCommentData {

/**
* edit comment id
*/
eid?: string;
/**
* Comment link
*/
url: string;
/**

@@ -54,0 +50,0 @@ * Recaptcha Token

import type {
WalineCommentSorting,
WalineHighlighter,
WalineEmojiInfo,
WalineImageUploader,
WalineLoginStatus,
WalineMeta,

@@ -133,2 +135,11 @@ WalineTexRenderer,

/**
* 评论列表排序方式
*
* Sorting method for comment list
*
* @default 'latest'
*/
commentSorting?: WalineCommentSorting;
/**
* 是否启用暗黑模式适配

@@ -198,3 +209,3 @@ *

* - `'enable'`: enable login (default)
* - `'disable'`: Login is disabled, users should fill in infomation to comment
* - `'disable'`: Login is disabled, users should fill in information to comment
* - `'force'`: Forced login, users must login to comment

@@ -204,3 +215,3 @@ *

*/
login?: 'enable' | 'disable' | 'force';
login?: WalineLoginStatus;

@@ -207,0 +218,0 @@ /**

@@ -70,2 +70,3 @@ import {

recaptchaV3Key = '',
commentSorting = 'latest',
...more

@@ -98,3 +99,4 @@ }: WalineProps): WalineConfig => ({

: [],
commentSorting,
...more,
});

@@ -33,5 +33,5 @@ import { WalineDateLocale } from '../typings';

const timepassed = now.getTime() - time.getTime();
const timePassed = now.getTime() - time.getTime();
const days = Math.floor(timepassed / (24 * 3600 * 1000));
const days = Math.floor(timePassed / (24 * 3600 * 1000));

@@ -42,3 +42,3 @@ if (days === 0) {

// 计算天数后剩余的毫秒数
const leave1 = timepassed % (24 * 3600 * 1000);
const leave1 = timePassed % (24 * 3600 * 1000);
const hours = Math.floor(leave1 / (3600 * 1000));

@@ -45,0 +45,0 @@

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

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

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

Sorry, the diff of this file is too big to display

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

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

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

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 too big to display

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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