@peerboard/core
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -32,2 +32,6 @@ 'use strict'; | ||
var PEERBOARD_EMBED_SDK_URL = 'https://static.peerboard.com/embed/embed.js'; | ||
(function (ExcludeOptions) { | ||
ExcludeOptions["Subdomain"] = "subdomain"; | ||
ExcludeOptions["QueryParams"] = "query"; | ||
})(exports.ExcludeOptions || (exports.ExcludeOptions = {})); | ||
var trimLeftSlash = function (str) { | ||
@@ -104,5 +108,33 @@ return str.startsWith('/') ? str.substr(1) : str; | ||
}; | ||
var createCommentsWidget = function (communityID, container, exclude, spaceID, options) { | ||
if (spaceID === void 0) { spaceID = 0; } | ||
return loadSdk(options.sdkURL).then(function () { | ||
if (!forumSDK) { | ||
throw new Error("Forum should be loaded at the moment."); | ||
} | ||
return new Promise(function (resolve, reject) { | ||
var api = forumSDK.createCommentWidget(communityID, exclude, container, spaceID, __assign(__assign({}, options), { onFail: function () { | ||
if (options.onFail) { | ||
options.onFail(); | ||
} | ||
reject(new Error("failed to initialize PeerBoard iframe internals")); | ||
}, onReady: function () { | ||
if (options.onReady) { | ||
options.onReady(); | ||
} | ||
resolve(api); | ||
} })); | ||
}); | ||
}).catch(function (err) { | ||
console.error("Error creating forum: ", err); | ||
if (options.onFail) { | ||
options.onFail(); | ||
} | ||
throw err; | ||
}); | ||
}; | ||
exports.loadSdk = loadSdk; | ||
exports.createForum = createForum; | ||
exports.createCommentsWidget = createCommentsWidget; | ||
//# sourceMappingURL=peerboard-core.cjs.js.map |
@@ -34,2 +34,6 @@ (function (global, factory) { | ||
var PEERBOARD_EMBED_SDK_URL = 'https://static.peerboard.com/embed/embed.js'; | ||
(function (ExcludeOptions) { | ||
ExcludeOptions["Subdomain"] = "subdomain"; | ||
ExcludeOptions["QueryParams"] = "query"; | ||
})(exports.ExcludeOptions || (exports.ExcludeOptions = {})); | ||
var trimLeftSlash = function (str) { | ||
@@ -106,5 +110,33 @@ return str.startsWith('/') ? str.substr(1) : str; | ||
}; | ||
var createCommentsWidget = function (communityID, container, exclude, spaceID, options) { | ||
if (spaceID === void 0) { spaceID = 0; } | ||
return loadSdk(options.sdkURL).then(function () { | ||
if (!forumSDK) { | ||
throw new Error("Forum should be loaded at the moment."); | ||
} | ||
return new Promise(function (resolve, reject) { | ||
var api = forumSDK.createCommentWidget(communityID, exclude, container, spaceID, __assign(__assign({}, options), { onFail: function () { | ||
if (options.onFail) { | ||
options.onFail(); | ||
} | ||
reject(new Error("failed to initialize PeerBoard iframe internals")); | ||
}, onReady: function () { | ||
if (options.onReady) { | ||
options.onReady(); | ||
} | ||
resolve(api); | ||
} })); | ||
}); | ||
}).catch(function (err) { | ||
console.error("Error creating forum: ", err); | ||
if (options.onFail) { | ||
options.onFail(); | ||
} | ||
throw err; | ||
}); | ||
}; | ||
exports.loadSdk = loadSdk; | ||
exports.createForum = createForum; | ||
exports.createCommentsWidget = createCommentsWidget; | ||
@@ -111,0 +143,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -1,14 +0,32 @@ | ||
interface Options { | ||
export declare enum ExcludeOptions { | ||
Subdomain = "subdomain", | ||
QueryParams = "query" | ||
} | ||
export interface TitleOptions { | ||
onTitleChanged?: (title: string) => void; | ||
} | ||
export interface SdkUrlOptions { | ||
sdkURL?: string; | ||
} | ||
export interface LoginOptions { | ||
/** | ||
* Authentication parameters | ||
*/ | ||
jwtToken?: string; | ||
} | ||
export interface FunctionOptions { | ||
onReady?: () => void; | ||
onFail?: () => void; | ||
onLogout?: () => void; | ||
} | ||
export interface WidgetOptions extends FunctionOptions, LoginOptions, SdkUrlOptions, TitleOptions { | ||
} | ||
interface Options extends FunctionOptions, LoginOptions, SdkUrlOptions, TitleOptions { | ||
prefix?: string; | ||
jwtToken?: string; | ||
anon?: boolean; | ||
minHeight?: number | string; | ||
onPathChanged?: (forumPath: string) => void; | ||
onTitleChanged?: (title: string) => void; | ||
onCustomProfile?: (url: string) => void; | ||
onReady?: () => void; | ||
onFail?: () => void; | ||
path?: string; | ||
baseURL?: string; | ||
sdkURL?: string; | ||
resize?: boolean; | ||
@@ -18,7 +36,6 @@ hideMenu?: boolean; | ||
} | ||
interface InternalSDKOptions { | ||
interface InternalSDKOptions extends FunctionOptions, LoginOptions { | ||
prefix?: string; | ||
prefixProxy?: string; | ||
baseURL?: string; | ||
jwtToken?: string; | ||
anon?: boolean; | ||
@@ -34,4 +51,2 @@ wpPayload?: string; | ||
onCustomProfile?: (url: string) => void; | ||
onReady?: () => void; | ||
onFail?: () => void; | ||
scrollToTopOnNavigationChanged?: boolean; | ||
@@ -46,5 +61,7 @@ sendReferrer?: boolean; | ||
createForum(forumID: number, container: HTMLElement, options: InternalSDKOptions): ForumAPI; | ||
createCommentWidget(communityID: number, exclude: ExcludeOptions[], container: HTMLElement, spaceID: number, options: WidgetOptions): ForumAPI; | ||
} | ||
export declare const loadSdk: (embedSDKURL?: string | undefined) => Promise<void>; | ||
export declare const createForum: (forumID: number, container: HTMLElement, options: Readonly<Options>) => Promise<ForumAPI>; | ||
export declare const createCommentsWidget: (communityID: number, container: HTMLElement, exclude: ExcludeOptions[], spaceID: number | undefined, options: Readonly<WidgetOptions>) => Promise<ForumAPI>; | ||
export {}; |
{ | ||
"name": "@peerboard/core", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "peerboard.com frontend components", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38482
8
331
1