@onesignal/onesignal-vue3
Advanced tools
Comparing version 1.0.2 to 2.0.0-beta.1
@@ -14,3 +14,2 @@ module.exports = { | ||
".ts", | ||
".tsx", | ||
], | ||
@@ -32,2 +31,5 @@ }, | ||
], | ||
extends: [ | ||
'plugin:@typescript-eslint/recommended', | ||
], | ||
rules: { | ||
@@ -40,4 +42,5 @@ "prefer-destructuring": 0, | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/no-unused-vars": ["error"] | ||
"@typescript-eslint/no-unused-vars": ["error"], | ||
"no-prototype-builtins": "warn", | ||
}, | ||
}; |
import { App } from 'vue'; | ||
declare module '@vue/runtime-core' { | ||
interface ComponentCustomProperties { | ||
$OneSignal: IOneSignal; | ||
$OneSignal: IOneSignalOneSignal; | ||
} | ||
@@ -9,3 +9,6 @@ } | ||
interface Window { | ||
OneSignal: any; | ||
OneSignalDeferred?: OneSignalDeferredLoadedCallback[]; | ||
safari?: { | ||
pushNotification: any; | ||
}; | ||
} | ||
@@ -19,18 +22,2 @@ } | ||
} | ||
interface RegisterOptions { | ||
modalPrompt?: boolean; | ||
httpPermissionRequest?: boolean; | ||
slidedown?: boolean; | ||
autoAccept?: boolean; | ||
} | ||
interface SetSMSOptions { | ||
identifierAuthHash?: string; | ||
} | ||
interface SetEmailOptions { | ||
identifierAuthHash?: string; | ||
emailAuthHash?: string; | ||
} | ||
interface TagsObject<T> { | ||
[key: string]: T; | ||
} | ||
interface IOneSignalAutoPromptOptions { | ||
@@ -55,2 +42,14 @@ force?: boolean; | ||
} | ||
declare type PushSubscriptionNamespaceProperties = { | ||
id: string | null | undefined; | ||
token: string | null | undefined; | ||
optedIn: boolean; | ||
}; | ||
declare type SubscriptionChangeEvent = { | ||
previous: PushSubscriptionNamespaceProperties; | ||
current: PushSubscriptionNamespaceProperties; | ||
}; | ||
declare type NotificationEventName = 'click' | 'willDisplay' | 'dismiss' | 'permissionChange' | 'permissionPromptDisplay'; | ||
declare type SlidedownEventName = 'slidedownShown'; | ||
declare type OneSignalDeferredLoadedCallback = (onesignal: IOneSignalOneSignal) => void; | ||
interface IInitObject { | ||
@@ -78,43 +77,66 @@ appId: string; | ||
} | ||
interface IOneSignal { | ||
interface IOneSignalOneSignal { | ||
login(externalId: string, jwtToken?: string): Promise<void>; | ||
logout(): Promise<void>; | ||
init(options: IInitObject): Promise<void>; | ||
on(event: string, listener: (eventData?: any) => void): void; | ||
off(event: string, listener: (eventData?: any) => void): void; | ||
once(event: string, listener: (eventData?: any) => void): void; | ||
isPushNotificationsEnabled(callback?: Action<boolean>): Promise<boolean>; | ||
showHttpPrompt(options?: AutoPromptOptions): Promise<void>; | ||
registerForPushNotifications(options?: RegisterOptions): Promise<void>; | ||
setDefaultNotificationUrl(url: string): Promise<void>; | ||
setConsentGiven(consent: boolean): Promise<void>; | ||
setConsentRequired(requiresConsent: boolean): Promise<void>; | ||
Slidedown: IOneSignalSlidedown; | ||
Notifications: IOneSignalNotifications; | ||
Session: IOneSignalSession; | ||
User: IOneSignalUser; | ||
Debug: IOneSignalDebug; | ||
[index: string]: any; | ||
} | ||
interface IOneSignalNotifications { | ||
setDefaultUrl(url: string): Promise<void>; | ||
setDefaultTitle(title: string): Promise<void>; | ||
getTags(callback?: Action<any>): Promise<void>; | ||
sendTag(key: string, value: any, callback?: Action<Object>): Promise<Object | null>; | ||
sendTags(tags: TagsObject<any>, callback?: Action<Object>): Promise<Object | null>; | ||
deleteTag(tag: string): Promise<Array<string>>; | ||
deleteTags(tags: Array<string>, callback?: Action<Array<string>>): Promise<Array<string>>; | ||
addListenerForNotificationOpened(callback?: Action<Notification>): Promise<void>; | ||
setSubscription(newSubscription: boolean): Promise<void>; | ||
showHttpPermissionRequest(options?: AutoPromptOptions): Promise<any>; | ||
showNativePrompt(): Promise<void>; | ||
showSlidedownPrompt(options?: AutoPromptOptions): Promise<void>; | ||
showCategorySlidedown(options?: AutoPromptOptions): Promise<void>; | ||
showSmsSlidedown(options?: AutoPromptOptions): Promise<void>; | ||
showEmailSlidedown(options?: AutoPromptOptions): Promise<void>; | ||
showSmsAndEmailSlidedown(options?: AutoPromptOptions): Promise<void>; | ||
getNotificationPermission(onComplete?: Action<NotificationPermission>): Promise<NotificationPermission>; | ||
getUserId(callback?: Action<string | undefined | null>): Promise<string | undefined | null>; | ||
getSubscription(callback?: Action<boolean>): Promise<boolean>; | ||
setEmail(email: string, options?: SetEmailOptions): Promise<string | null>; | ||
setSMSNumber(smsNumber: string, options?: SetSMSOptions): Promise<string | null>; | ||
logoutEmail(): Promise<void>; | ||
logoutSMS(): Promise<void>; | ||
setExternalUserId(externalUserId: string | undefined | null, authHash?: string): Promise<void>; | ||
removeExternalUserId(): Promise<void>; | ||
getExternalUserId(): Promise<string | undefined | null>; | ||
provideUserConsent(consent: boolean): Promise<void>; | ||
getEmailId(callback?: Action<string | undefined>): Promise<string | null | undefined>; | ||
getSMSId(callback?: Action<string | undefined>): Promise<string | null | undefined>; | ||
sendOutcome(outcomeName: string, outcomeWeight?: number | undefined): Promise<void>; | ||
[index: string]: Function; | ||
isPushSupported(): boolean; | ||
getPermissionStatus(onComplete: Action<NotificationPermission>): Promise<NotificationPermission>; | ||
requestPermission(): Promise<void>; | ||
addEventListener(event: NotificationEventName, listener: (obj: any) => void): void; | ||
removeEventListener(event: NotificationEventName, listener: (obj: any) => void): void; | ||
[index: string]: any; | ||
} | ||
export declare const useOneSignal: () => IOneSignal; | ||
interface IOneSignalSlidedown { | ||
promptPush(options?: AutoPromptOptions): Promise<void>; | ||
promptPushCategories(options?: AutoPromptOptions): Promise<void>; | ||
promptSms(options?: AutoPromptOptions): Promise<void>; | ||
promptEmail(options?: AutoPromptOptions): Promise<void>; | ||
promptSmsAndEmail(options?: AutoPromptOptions): Promise<void>; | ||
addEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void; | ||
removeEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void; | ||
[index: string]: any; | ||
} | ||
interface IOneSignalDebug { | ||
setLogLevel(logLevel: string): void; | ||
[index: string]: any; | ||
} | ||
interface IOneSignalSession { | ||
sendOutcome(outcomeName: string, outcomeWeight?: number): Promise<void>; | ||
sendUniqueOutcome(outcomeName: string): Promise<void>; | ||
[index: string]: any; | ||
} | ||
interface IOneSignalUser { | ||
addAlias(label: string, id: string): void; | ||
addAliases(aliases: { | ||
[key: string]: string; | ||
}): void; | ||
removeAlias(label: string): void; | ||
removeAliases(labels: string[]): void; | ||
addEmail(email: string): void; | ||
removeEmail(email: string): void; | ||
addSms(smsNumber: string): void; | ||
removeSms(smsNumber: string): void; | ||
PushSubscription: IOneSignalPushSubscription; | ||
[index: string]: any; | ||
} | ||
interface IOneSignalPushSubscription { | ||
optIn(): Promise<void>; | ||
optOut(): Promise<void>; | ||
addEventListener(event: 'subscriptionChange', listener: (change: SubscriptionChangeEvent) => void): void; | ||
removeEventListener(event: 'subscriptionChange', listener: (change: SubscriptionChangeEvent) => void): void; | ||
[index: string]: any; | ||
} | ||
export declare const useOneSignal: () => IOneSignalOneSignal; | ||
declare const OneSignalVuePlugin: { | ||
@@ -121,0 +143,0 @@ install(app: App, options: IInitObject): void; |
const ONESIGNAL_SDK_ID = 'onesignal-sdk'; | ||
const ONE_SIGNAL_SCRIPT_SRC = 'https://cdn.onesignal.com/sdks/OneSignalSDK.js'; | ||
const ONESIGNAL_NOT_SETUP_ERROR = 'OneSignal is not setup correctly.'; | ||
const MAX_TIMEOUT = 30; | ||
const ONE_SIGNAL_SCRIPT_SRC = "https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.js"; | ||
// true if the script is successfully loaded from CDN. | ||
let isOneSignalInitialized = false; | ||
const vueOneSignalFunctionQueue = []; | ||
// true if the script fails to load from CDN. A separate flag is necessary | ||
// to disambiguate between a CDN load failure and a delayed call to | ||
// OneSignal#init. | ||
let isOneSignalScriptFailed = false; | ||
window.OneSignalDeferred = window.OneSignalDeferred || []; | ||
addSDKScript(); | ||
/* H E L P E R S */ | ||
const injectScript = () => { | ||
function handleOnError() { | ||
isOneSignalScriptFailed = true; | ||
} | ||
function addSDKScript() { | ||
const script = document.createElement('script'); | ||
script.id = ONESIGNAL_SDK_ID; | ||
script.defer = true; | ||
script.src = ONE_SIGNAL_SCRIPT_SRC; | ||
script.async = true; | ||
// Always resolve whether or not the script is successfully initialized. | ||
// This is important for users who may block cdn.onesignal.com w/ adblock. | ||
script.onerror = () => { | ||
handleOnError(); | ||
}; | ||
document.head.appendChild(script); | ||
}; | ||
const doesOneSignalExist = () => { | ||
if (window.OneSignal) { | ||
return true; | ||
} | ||
/* O N E S I G N A L A P I */ | ||
/** | ||
* @PublicApi | ||
*/ | ||
const init = (options) => { | ||
if (isOneSignalInitialized) { | ||
return Promise.reject(`OneSignal is already initialized.`); | ||
} | ||
return false; | ||
}; | ||
const processQueuedOneSignalFunctions = () => { | ||
vueOneSignalFunctionQueue.forEach(element => { | ||
const { name, args, promiseResolver } = element; | ||
if (!!promiseResolver) { | ||
OneSignalVue[name](...args).then((result) => { | ||
promiseResolver(result); | ||
if (!options || !options.appId) { | ||
throw new Error('You need to provide your OneSignal appId.'); | ||
} | ||
if (!document) { | ||
return Promise.reject(`Document is not defined.`); | ||
} | ||
return new Promise((resolve) => { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.init(options).then(() => { | ||
isOneSignalInitialized = true; | ||
resolve(); | ||
}); | ||
} | ||
else { | ||
window.OneSignal[name](...args); | ||
} | ||
}); | ||
}); | ||
}; | ||
const setupOneSignalIfMissing = () => { | ||
if (!doesOneSignalExist()) { | ||
window.OneSignal = window.OneSignal || []; | ||
} | ||
}; | ||
/* O N E S I G N A L A P I */ | ||
function init(options) { | ||
return new Promise(resolve => { | ||
if (isOneSignalInitialized) { | ||
return; | ||
} | ||
injectScript(); | ||
setupOneSignalIfMissing(); | ||
window.OneSignal.push(() => { | ||
window.OneSignal.init(options); | ||
}); | ||
const timeout = setTimeout(() => { | ||
console.error(ONESIGNAL_NOT_SETUP_ERROR); | ||
}, MAX_TIMEOUT * 1000); | ||
window.OneSignal.push(() => { | ||
clearTimeout(timeout); | ||
isOneSignalInitialized = true; | ||
processQueuedOneSignalFunctions(); | ||
resolve(); | ||
}); | ||
}); | ||
/** | ||
* The following code is copied directly from the native SDK source file BrowserSupportsPush.ts | ||
* S T A R T | ||
*/ | ||
// Checks if the browser supports push notifications by checking if specific | ||
// classes and properties on them exist | ||
function isPushNotificationsSupported() { | ||
return supportsVapidPush() || supportsSafariPush(); | ||
} | ||
function on(event, listener) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'on', | ||
args: arguments, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.on(event, listener); | ||
}); | ||
function isMacOSSafariInIframe() { | ||
// Fallback detection for Safari on macOS in an iframe context | ||
return window.top !== window && // isContextIframe | ||
navigator.vendor === "Apple Computer, Inc." && // isSafari | ||
navigator.platform === "MacIntel"; // isMacOS | ||
} | ||
function off(event, listener) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'off', | ||
args: arguments, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.off(event, listener); | ||
}); | ||
function supportsSafariPush() { | ||
return (window.safari && typeof window.safari.pushNotification !== "undefined") || | ||
isMacOSSafariInIframe(); | ||
} | ||
function once(event, listener) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'once', | ||
args: arguments, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.once(event, listener); | ||
}); | ||
// Does the browser support the standard Push API | ||
function supportsVapidPush() { | ||
return typeof PushSubscriptionOptions !== "undefined" && | ||
PushSubscriptionOptions.prototype.hasOwnProperty("applicationServerKey"); | ||
} | ||
function isPushNotificationsEnabled(callback) { | ||
/* E N D */ | ||
/** | ||
* @PublicApi | ||
*/ | ||
const isPushSupported = () => { | ||
return isPushNotificationsSupported(); | ||
}; | ||
function oneSignalLogin(externalId, jwtToken) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'isPushNotificationsEnabled', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.login(externalId, jwtToken) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.isPushNotificationsEnabled(callback) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showHttpPrompt(options) { | ||
function oneSignalLogout() { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showHttpPrompt', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.logout() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showHttpPrompt(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function registerForPushNotifications(options) { | ||
function oneSignalSetConsentGiven(consent) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'registerForPushNotifications', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.setConsentGiven(consent) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.registerForPushNotifications(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setDefaultNotificationUrl(url) { | ||
function oneSignalSetConsentRequired(requiresConsent) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'setDefaultNotificationUrl', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.setConsentRequired(requiresConsent) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.setDefaultNotificationUrl(url) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setDefaultTitle(title) { | ||
function slidedownPromptPush(options) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'setDefaultTitle', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Slidedown.promptPush(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.setDefaultTitle(title) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getTags(callback) { | ||
function slidedownPromptPushCategories(options) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'getTags', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Slidedown.promptPushCategories(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.getTags(callback) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function sendTag(key, value, callback) { | ||
function slidedownPromptSms(options) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'sendTag', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Slidedown.promptSms(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.sendTag(key, value, callback) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function sendTags(tags, callback) { | ||
function slidedownPromptEmail(options) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'sendTags', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Slidedown.promptEmail(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.sendTags(tags, callback) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function deleteTag(tag) { | ||
function slidedownPromptSmsAndEmail(options) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'deleteTag', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Slidedown.promptSmsAndEmail(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.deleteTag(tag) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function deleteTags(tags, callback) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'deleteTags', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.deleteTags(tags, callback) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function slidedownAddEventListener(event, listener) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Slidedown.addEventListener(event, listener); | ||
}); | ||
} | ||
function addListenerForNotificationOpened(callback) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'addListenerForNotificationOpened', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.addListenerForNotificationOpened(callback) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function slidedownRemoveEventListener(event, listener) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Slidedown.removeEventListener(event, listener); | ||
}); | ||
} | ||
function setSubscription(newSubscription) { | ||
function notificationsSetDefaultUrl(url) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'setSubscription', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Notifications.setDefaultUrl(url) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.setSubscription(newSubscription) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showHttpPermissionRequest(options) { | ||
function notificationsSetDefaultTitle(title) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showHttpPermissionRequest', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Notifications.setDefaultTitle(title) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showHttpPermissionRequest(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showNativePrompt() { | ||
function notificationsGetPermissionStatus(onComplete) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showNativePrompt', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Notifications.getPermissionStatus(onComplete) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showNativePrompt() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showSlidedownPrompt(options) { | ||
function notificationsRequestPermission() { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showSlidedownPrompt', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Notifications.requestPermission() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showSlidedownPrompt(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showCategorySlidedown(options) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showCategorySlidedown', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showCategorySlidedown(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function notificationsAddEventListener(event, listener) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Notifications.addEventListener(event, listener); | ||
}); | ||
} | ||
function showSmsSlidedown(options) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showSmsSlidedown', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showSmsSlidedown(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function notificationsRemoveEventListener(event, listener) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Notifications.removeEventListener(event, listener); | ||
}); | ||
} | ||
function showEmailSlidedown(options) { | ||
function sessionSendOutcome(outcomeName, outcomeWeight) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showEmailSlidedown', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Session.sendOutcome(outcomeName, outcomeWeight) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showEmailSlidedown(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showSmsAndEmailSlidedown(options) { | ||
function sessionSendUniqueOutcome(outcomeName) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showSmsAndEmailSlidedown', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Session.sendUniqueOutcome(outcomeName) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showSmsAndEmailSlidedown(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getNotificationPermission(onComplete) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'getNotificationPermission', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.getNotificationPermission(onComplete) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function userAddAlias(label, id) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.User.addAlias(label, id); | ||
}); | ||
} | ||
function getUserId(callback) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'getUserId', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.getUserId(callback) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function userAddAliases(aliases) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.User.addAliases(aliases); | ||
}); | ||
} | ||
function getSubscription(callback) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'getSubscription', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.getSubscription(callback) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function userRemoveAlias(label) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.User.removeAlias(label); | ||
}); | ||
} | ||
function setEmail(email, options) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'setEmail', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.setEmail(email, options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function userRemoveAliases(labels) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.User.removeAliases(labels); | ||
}); | ||
} | ||
function setSMSNumber(smsNumber, options) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'setSMSNumber', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.setSMSNumber(smsNumber, options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function userAddEmail(email) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.User.addEmail(email); | ||
}); | ||
} | ||
function logoutEmail() { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'logoutEmail', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.logoutEmail() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function userRemoveEmail(email) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.User.removeEmail(email); | ||
}); | ||
} | ||
function logoutSMS() { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'logoutSMS', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.logoutSMS() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function userAddSms(smsNumber) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.User.addSms(smsNumber); | ||
}); | ||
} | ||
function setExternalUserId(externalUserId, authHash) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'setExternalUserId', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.setExternalUserId(externalUserId, authHash) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function userRemoveSms(smsNumber) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.User.removeSms(smsNumber); | ||
}); | ||
} | ||
function removeExternalUserId() { | ||
function pushSubscriptionOptIn() { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'removeExternalUserId', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.User.PushSubscription.optIn() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.removeExternalUserId() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getExternalUserId() { | ||
function pushSubscriptionOptOut() { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'getExternalUserId', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
var _a; | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.getExternalUserId() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
function provideUserConsent(consent) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'provideUserConsent', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
try { | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.User.PushSubscription.optOut() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.provideUserConsent(consent) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getEmailId(callback) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'getEmailId', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.getEmailId(callback) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function pushSubscriptionAddEventListener(event, listener) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.User.PushSubscription.addEventListener(event, listener); | ||
}); | ||
} | ||
function getSMSId(callback) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'getSMSId', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.getSMSId(callback) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function pushSubscriptionRemoveEventListener(event, listener) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.User.PushSubscription.removeEventListener(event, listener); | ||
}); | ||
} | ||
function sendOutcome(outcomeName, outcomeWeight) { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'sendOutcome', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.sendOutcome(outcomeName, outcomeWeight) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
function debugSetLogLevel(logLevel) { | ||
var _a; | ||
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => { | ||
OneSignal.Debug.setLogLevel(logLevel); | ||
}); | ||
} | ||
const OneSignalVue = { | ||
const PushSubscriptionNamespace = { | ||
optIn: pushSubscriptionOptIn, | ||
optOut: pushSubscriptionOptOut, | ||
addEventListener: pushSubscriptionAddEventListener, | ||
removeEventListener: pushSubscriptionRemoveEventListener, | ||
}; | ||
const UserNamespace = { | ||
addAlias: userAddAlias, | ||
addAliases: userAddAliases, | ||
removeAlias: userRemoveAlias, | ||
removeAliases: userRemoveAliases, | ||
addEmail: userAddEmail, | ||
removeEmail: userRemoveEmail, | ||
addSms: userAddSms, | ||
removeSms: userRemoveSms, | ||
PushSubscription: PushSubscriptionNamespace, | ||
}; | ||
const SessionNamespace = { | ||
sendOutcome: sessionSendOutcome, | ||
sendUniqueOutcome: sessionSendUniqueOutcome, | ||
}; | ||
const DebugNamespace = { | ||
setLogLevel: debugSetLogLevel, | ||
}; | ||
const SlidedownNamespace = { | ||
promptPush: slidedownPromptPush, | ||
promptPushCategories: slidedownPromptPushCategories, | ||
promptSms: slidedownPromptSms, | ||
promptEmail: slidedownPromptEmail, | ||
promptSmsAndEmail: slidedownPromptSmsAndEmail, | ||
addEventListener: slidedownAddEventListener, | ||
removeEventListener: slidedownRemoveEventListener, | ||
}; | ||
const NotificationsNamespace = { | ||
setDefaultUrl: notificationsSetDefaultUrl, | ||
setDefaultTitle: notificationsSetDefaultTitle, | ||
isPushSupported, | ||
getPermissionStatus: notificationsGetPermissionStatus, | ||
requestPermission: notificationsRequestPermission, | ||
addEventListener: notificationsAddEventListener, | ||
removeEventListener: notificationsRemoveEventListener, | ||
}; | ||
const OneSignalNamespace = { | ||
login: oneSignalLogin, | ||
logout: oneSignalLogout, | ||
init, | ||
on, | ||
off, | ||
once, | ||
isPushNotificationsEnabled, | ||
showHttpPrompt, | ||
registerForPushNotifications, | ||
setDefaultNotificationUrl, | ||
setDefaultTitle, | ||
getTags, | ||
sendTag, | ||
sendTags, | ||
deleteTag, | ||
deleteTags, | ||
addListenerForNotificationOpened, | ||
setSubscription, | ||
showHttpPermissionRequest, | ||
showNativePrompt, | ||
showSlidedownPrompt, | ||
showCategorySlidedown, | ||
showSmsSlidedown, | ||
showEmailSlidedown, | ||
showSmsAndEmailSlidedown, | ||
getNotificationPermission, | ||
getUserId, | ||
getSubscription, | ||
setEmail, | ||
setSMSNumber, | ||
logoutEmail, | ||
logoutSMS, | ||
setExternalUserId, | ||
removeExternalUserId, | ||
getExternalUserId, | ||
provideUserConsent, | ||
getEmailId, | ||
getSMSId, | ||
sendOutcome, | ||
setConsentGiven: oneSignalSetConsentGiven, | ||
setConsentRequired: oneSignalSetConsentRequired, | ||
Slidedown: SlidedownNamespace, | ||
Notifications: NotificationsNamespace, | ||
Session: SessionNamespace, | ||
User: UserNamespace, | ||
Debug: DebugNamespace, | ||
}; | ||
export const useOneSignal = () => { | ||
return OneSignalVue; | ||
return OneSignalNamespace; | ||
}; | ||
const OneSignalVuePlugin = { | ||
install(app, options) { | ||
app.config.globalProperties.$OneSignal = OneSignalVue; | ||
app.config.globalProperties.$OneSignal = OneSignalNamespace; | ||
app.config.globalProperties.$OneSignal.init(options); | ||
@@ -704,0 +539,0 @@ } |
1214
index.ts
import { App } from 'vue'; | ||
const ONESIGNAL_SDK_ID = 'onesignal-sdk'; | ||
const ONE_SIGNAL_SCRIPT_SRC = 'https://cdn.onesignal.com/sdks/OneSignalSDK.js'; | ||
const ONESIGNAL_NOT_SETUP_ERROR = 'OneSignal is not setup correctly.'; | ||
const MAX_TIMEOUT = 30; | ||
const ONE_SIGNAL_SCRIPT_SRC = "https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.js"; | ||
// true if the script is successfully loaded from CDN. | ||
let isOneSignalInitialized = false; | ||
const vueOneSignalFunctionQueue: IOneSignalFunctionCall[] = []; | ||
// true if the script fails to load from CDN. A separate flag is necessary | ||
// to disambiguate between a CDN load failure and a delayed call to | ||
// OneSignal#init. | ||
let isOneSignalScriptFailed = false; | ||
window.OneSignalDeferred = window.OneSignalDeferred || []; | ||
addSDKScript(); | ||
/* H E L P E R S */ | ||
const injectScript = () => { | ||
function handleOnError() { | ||
isOneSignalScriptFailed = true; | ||
} | ||
function addSDKScript() { | ||
const script = document.createElement('script'); | ||
script.id = ONESIGNAL_SDK_ID; | ||
script.defer = true; | ||
script.src = ONE_SIGNAL_SCRIPT_SRC; | ||
script.async = true; | ||
// Always resolve whether or not the script is successfully initialized. | ||
// This is important for users who may block cdn.onesignal.com w/ adblock. | ||
script.onerror = () => { | ||
handleOnError(); | ||
} | ||
document.head.appendChild(script); | ||
} | ||
/* T Y P E D E C L A R A T I O N S */ | ||
const doesOneSignalExist = () => { | ||
if (window.OneSignal) { | ||
return true; | ||
declare module '@vue/runtime-core' { | ||
export interface ComponentCustomProperties { | ||
$OneSignal: IOneSignalOneSignal; | ||
} | ||
return false; | ||
} | ||
const processQueuedOneSignalFunctions = () => { | ||
vueOneSignalFunctionQueue.forEach(element => { | ||
const { name, args, promiseResolver } = element; | ||
declare global { | ||
interface Window { | ||
OneSignalDeferred?: OneSignalDeferredLoadedCallback[]; | ||
safari?: { | ||
pushNotification: any; | ||
}; | ||
} | ||
} | ||
if (!!promiseResolver) { | ||
OneSignalVue[name](...args).then((result: any) => { | ||
promiseResolver(result); | ||
/* O N E S I G N A L A P I */ | ||
/** | ||
* @PublicApi | ||
*/ | ||
const init = (options: IInitObject): Promise<void> => { | ||
if (isOneSignalInitialized) { | ||
return Promise.reject(`OneSignal is already initialized.`); | ||
} | ||
if (!options || !options.appId) { | ||
throw new Error('You need to provide your OneSignal appId.'); | ||
} | ||
if (!document) { | ||
return Promise.reject(`Document is not defined.`); | ||
} | ||
return new Promise<void>((resolve) => { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.init(options).then(() => { | ||
isOneSignalInitialized = true; | ||
resolve(); | ||
}); | ||
} else { | ||
window.OneSignal[name](...args); | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* The following code is copied directly from the native SDK source file BrowserSupportsPush.ts | ||
* S T A R T | ||
*/ | ||
// Checks if the browser supports push notifications by checking if specific | ||
// classes and properties on them exist | ||
function isPushNotificationsSupported() { | ||
return supportsVapidPush() || supportsSafariPush(); | ||
} | ||
const setupOneSignalIfMissing = () => { | ||
if (!doesOneSignalExist()) { | ||
window.OneSignal = window.OneSignal || []; | ||
} | ||
function isMacOSSafariInIframe(): boolean { | ||
// Fallback detection for Safari on macOS in an iframe context | ||
return window.top !== window && // isContextIframe | ||
navigator.vendor === "Apple Computer, Inc." && // isSafari | ||
navigator.platform === "MacIntel"; // isMacOS | ||
} | ||
/* T Y P E D E C L A R A T I O N S */ | ||
declare module '@vue/runtime-core' { | ||
export interface ComponentCustomProperties { | ||
$OneSignal: IOneSignal; | ||
} | ||
function supportsSafariPush(): boolean { | ||
return (window.safari && typeof window.safari.pushNotification !== "undefined") || | ||
isMacOSSafariInIframe(); | ||
} | ||
declare global { | ||
interface Window { | ||
OneSignal: any; | ||
} | ||
// Does the browser support the standard Push API | ||
function supportsVapidPush(): boolean { | ||
return typeof PushSubscriptionOptions !== "undefined" && | ||
PushSubscriptionOptions.prototype.hasOwnProperty("applicationServerKey"); | ||
} | ||
/* E N D */ | ||
interface IOneSignalFunctionCall { | ||
name: string; | ||
args: IArguments; | ||
promiseResolver?: Function; | ||
/** | ||
* @PublicApi | ||
*/ | ||
const isPushSupported = (): boolean => { | ||
return isPushNotificationsSupported(); | ||
} | ||
@@ -70,9 +123,12 @@ | ||
interface AutoPromptOptions { force?: boolean; forceSlidedownOverNative?: boolean; slidedownPromptOptions?: IOneSignalAutoPromptOptions; } | ||
interface RegisterOptions { modalPrompt?: boolean; httpPermissionRequest?: boolean; slidedown?: boolean; autoAccept?: boolean } | ||
interface SetSMSOptions { identifierAuthHash?: string; } | ||
interface SetEmailOptions { identifierAuthHash?: string; emailAuthHash?: string; } | ||
interface TagsObject<T> { [key: string]: T; } | ||
interface IOneSignalAutoPromptOptions { force?: boolean; forceSlidedownOverNative?: boolean; isInUpdateMode?: boolean; categoryOptions?: IOneSignalCategories; } | ||
interface IOneSignalCategories { positiveUpdateButton: string; negativeUpdateButton: string; savingButtonText: string; errorButtonText: string; updateMessage: string; tags: IOneSignalTagCategory[]; } | ||
interface IOneSignalTagCategory { tag: string; label: string; checked?: boolean; } | ||
type PushSubscriptionNamespaceProperties = { id: string | null | undefined; token: string | null | undefined; optedIn: boolean; }; | ||
type SubscriptionChangeEvent = { previous: PushSubscriptionNamespaceProperties; current: PushSubscriptionNamespaceProperties; }; | ||
type NotificationEventName = 'click' | 'willDisplay' | 'dismiss' | 'permissionChange' | 'permissionPromptDisplay'; | ||
interface NotificationButtonData { action?: string; title?: string; icon?: string; url?: string; } | ||
interface StructuredNotification { id: string; content: string; heading?: string; url?: string; data?: object; rr?: string; icon?: string; image?: string; tag?: string; badge?: string; vibrate?: string; buttons?: NotificationButtonData[]; } | ||
type SlidedownEventName = 'slidedownShown'; | ||
type OneSignalDeferredLoadedCallback = (onesignal: IOneSignalOneSignal) => void; | ||
@@ -100,782 +156,530 @@ interface IInitObject { | ||
interface IOneSignal { | ||
interface IOneSignalOneSignal { | ||
login(externalId: string, jwtToken?: string): Promise<void> | ||
logout(): Promise<void> | ||
init(options: IInitObject): Promise<void> | ||
on(event: string, listener: (eventData?: any) => void): void | ||
off(event: string, listener: (eventData?: any) => void): void | ||
once(event: string, listener: (eventData?: any) => void): void | ||
isPushNotificationsEnabled(callback?: Action<boolean>): Promise<boolean> | ||
showHttpPrompt(options?: AutoPromptOptions): Promise<void> | ||
registerForPushNotifications(options?: RegisterOptions): Promise<void> | ||
setDefaultNotificationUrl(url: string): Promise<void> | ||
setConsentGiven(consent: boolean): Promise<void> | ||
setConsentRequired(requiresConsent: boolean): Promise<void> | ||
Slidedown: IOneSignalSlidedown; | ||
Notifications: IOneSignalNotifications; | ||
Session: IOneSignalSession; | ||
User: IOneSignalUser; | ||
Debug: IOneSignalDebug; | ||
[index: string]: any; | ||
} | ||
interface IOneSignalNotifications { | ||
setDefaultUrl(url: string): Promise<void> | ||
setDefaultTitle(title: string): Promise<void> | ||
getTags(callback?: Action<any>): Promise<void> | ||
sendTag(key: string, value: any, callback?: Action<Object>): Promise<Object | null> | ||
sendTags(tags: TagsObject<any>, callback?: Action<Object>): Promise<Object | null> | ||
deleteTag(tag: string): Promise<Array<string>> | ||
deleteTags(tags: Array<string>, callback?: Action<Array<string>>): Promise<Array<string>> | ||
addListenerForNotificationOpened(callback?: Action<Notification>): Promise<void> | ||
setSubscription(newSubscription: boolean): Promise<void> | ||
showHttpPermissionRequest(options?: AutoPromptOptions): Promise<any> | ||
showNativePrompt(): Promise<void> | ||
showSlidedownPrompt(options?: AutoPromptOptions): Promise<void> | ||
showCategorySlidedown(options?: AutoPromptOptions): Promise<void> | ||
showSmsSlidedown(options?: AutoPromptOptions): Promise<void> | ||
showEmailSlidedown(options?: AutoPromptOptions): Promise<void> | ||
showSmsAndEmailSlidedown(options?: AutoPromptOptions): Promise<void> | ||
getNotificationPermission(onComplete?: Action<NotificationPermission>): Promise<NotificationPermission> | ||
getUserId(callback?: Action<string | undefined | null>): Promise<string | undefined | null> | ||
getSubscription(callback?: Action<boolean>): Promise<boolean> | ||
setEmail(email: string, options?: SetEmailOptions): Promise<string|null> | ||
setSMSNumber(smsNumber: string, options?: SetSMSOptions): Promise<string | null> | ||
logoutEmail(): Promise<void> | ||
logoutSMS(): Promise<void> | ||
setExternalUserId(externalUserId: string | undefined | null, authHash?: string): Promise<void> | ||
removeExternalUserId(): Promise<void> | ||
getExternalUserId(): Promise<string | undefined | null> | ||
provideUserConsent(consent: boolean): Promise<void> | ||
getEmailId(callback?: Action<string | undefined>): Promise<string | null | undefined> | ||
getSMSId(callback?: Action<string | undefined>): Promise<string | null | undefined> | ||
sendOutcome(outcomeName: string, outcomeWeight?: number | undefined): Promise<void> | ||
[index: string]: Function; | ||
isPushSupported(): boolean | ||
getPermissionStatus(onComplete: Action<NotificationPermission>): Promise<NotificationPermission> | ||
requestPermission(): Promise<void> | ||
addEventListener(event: NotificationEventName, listener: (obj: any) => void): void | ||
removeEventListener(event: NotificationEventName, listener: (obj: any) => void): void | ||
[index: string]: any; | ||
} | ||
/* O N E S I G N A L A P I */ | ||
function init(options: IInitObject) { | ||
return new Promise<void>(resolve => { | ||
if (isOneSignalInitialized) { | ||
return; | ||
} | ||
injectScript(); | ||
setupOneSignalIfMissing(); | ||
window.OneSignal.push(() => { | ||
window.OneSignal.init(options); | ||
}) | ||
const timeout = setTimeout(() => { | ||
console.error(ONESIGNAL_NOT_SETUP_ERROR); | ||
}, MAX_TIMEOUT * 1_000); | ||
window.OneSignal.push(() => { | ||
clearTimeout(timeout); | ||
isOneSignalInitialized = true; | ||
processQueuedOneSignalFunctions(); | ||
resolve(); | ||
}); | ||
}); | ||
interface IOneSignalSlidedown { | ||
promptPush(options?: AutoPromptOptions): Promise<void> | ||
promptPushCategories(options?: AutoPromptOptions): Promise<void> | ||
promptSms(options?: AutoPromptOptions): Promise<void> | ||
promptEmail(options?: AutoPromptOptions): Promise<void> | ||
promptSmsAndEmail(options?: AutoPromptOptions): Promise<void> | ||
addEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void | ||
removeEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void | ||
[index: string]: any; | ||
} | ||
interface IOneSignalDebug { | ||
setLogLevel(logLevel: string): void | ||
[index: string]: any; | ||
} | ||
interface IOneSignalSession { | ||
sendOutcome(outcomeName: string, outcomeWeight?: number): Promise<void> | ||
sendUniqueOutcome(outcomeName: string): Promise<void> | ||
[index: string]: any; | ||
} | ||
interface IOneSignalUser { | ||
addAlias(label: string, id: string): void | ||
addAliases(aliases: { [key: string]: string }): void | ||
removeAlias(label: string): void | ||
removeAliases(labels: string[]): void | ||
addEmail(email: string): void | ||
removeEmail(email: string): void | ||
addSms(smsNumber: string): void | ||
removeSms(smsNumber: string): void | ||
PushSubscription: IOneSignalPushSubscription; | ||
[index: string]: any; | ||
} | ||
interface IOneSignalPushSubscription { | ||
optIn(): Promise<void> | ||
optOut(): Promise<void> | ||
addEventListener(event: 'subscriptionChange', listener: (change: SubscriptionChangeEvent) => void): void | ||
removeEventListener(event: 'subscriptionChange', listener: (change: SubscriptionChangeEvent) => void): void | ||
[index: string]: any; | ||
} | ||
function on(event: string, listener: (eventData?: any) => void): void { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'on', | ||
args: arguments, | ||
}); | ||
return; | ||
function oneSignalLogin(externalId: string, jwtToken?: string): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.on(event, listener) | ||
}); | ||
} | ||
function off(event: string, listener: (eventData?: any) => void): void { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'off', | ||
args: arguments, | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.login(externalId, jwtToken) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
return; | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.off(event, listener) | ||
}); | ||
} | ||
function once(event: string, listener: (eventData?: any) => void): void { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'once', | ||
args: arguments, | ||
}); | ||
return; | ||
function oneSignalLogout(): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.once(event, listener) | ||
}); | ||
} | ||
function isPushNotificationsEnabled(callback?: Action<boolean>): Promise<boolean> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'isPushNotificationsEnabled', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.isPushNotificationsEnabled(callback) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.logout() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showHttpPrompt(options?: AutoPromptOptions): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showHttpPrompt', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function oneSignalSetConsentGiven(consent: boolean): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showHttpPrompt(options) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.setConsentGiven(consent) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function registerForPushNotifications(options?: RegisterOptions): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'registerForPushNotifications', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function oneSignalSetConsentRequired(requiresConsent: boolean): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.registerForPushNotifications(options) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.setConsentRequired(requiresConsent) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setDefaultNotificationUrl(url: string): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'setDefaultNotificationUrl', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function slidedownPromptPush(options?: AutoPromptOptions): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.setDefaultNotificationUrl(url) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Slidedown.promptPush(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setDefaultTitle(title: string): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'setDefaultTitle', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function slidedownPromptPushCategories(options?: AutoPromptOptions): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.setDefaultTitle(title) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Slidedown.promptPushCategories(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getTags(callback?: Action<any>): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'getTags', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function slidedownPromptSms(options?: AutoPromptOptions): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.getTags(callback) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Slidedown.promptSms(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function sendTag(key: string, value: any, callback?: Action<Object>): Promise<Object | null> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'sendTag', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function slidedownPromptEmail(options?: AutoPromptOptions): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.sendTag(key, value, callback) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Slidedown.promptEmail(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function sendTags(tags: TagsObject<any>, callback?: Action<Object>): Promise<Object | null> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'sendTags', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function slidedownPromptSmsAndEmail(options?: AutoPromptOptions): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.sendTags(tags, callback) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Slidedown.promptSmsAndEmail(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function deleteTag(tag: string): Promise<Array<string>> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'deleteTag', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function slidedownAddEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Slidedown.addEventListener(event, listener) | ||
}); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.deleteTag(tag) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
function slidedownRemoveEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Slidedown.removeEventListener(event, listener) | ||
}); | ||
} | ||
function deleteTags(tags: Array<string>, callback?: Action<Array<string>>): Promise<Array<string>> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'deleteTags', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function notificationsSetDefaultUrl(url: string): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.deleteTags(tags, callback) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Notifications.setDefaultUrl(url) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function addListenerForNotificationOpened(callback?: Action<Notification>): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'addListenerForNotificationOpened', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function notificationsSetDefaultTitle(title: string): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.addListenerForNotificationOpened(callback) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Notifications.setDefaultTitle(title) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setSubscription(newSubscription: boolean): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'setSubscription', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function notificationsGetPermissionStatus(onComplete: Action<NotificationPermission>): Promise<NotificationPermission> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.setSubscription(newSubscription) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Notifications.getPermissionStatus(onComplete) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showHttpPermissionRequest(options?: AutoPromptOptions): Promise<any> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showHttpPermissionRequest', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function notificationsRequestPermission(): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showHttpPermissionRequest(options) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Notifications.requestPermission() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showNativePrompt(): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showNativePrompt', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function notificationsAddEventListener(event: 'click' | 'willDisplay' | 'dismiss', listener: (obj: StructuredNotification) => void): void; | ||
function notificationsAddEventListener(event: 'permissionChange', listener: (obj: { to: NotificationPermission }) => void): void; | ||
function notificationsAddEventListener(event: 'permissionPromptDisplay', listener: () => void): void; | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showNativePrompt() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
function notificationsAddEventListener(event: NotificationEventName, listener: (obj: any) => void): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Notifications.addEventListener(event, listener) | ||
}); | ||
} | ||
function showSlidedownPrompt(options?: AutoPromptOptions): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showSlidedownPrompt', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function notificationsRemoveEventListener(event: 'click' | 'willDisplay' | 'dismiss', listener: (obj: StructuredNotification) => void): void; | ||
function notificationsRemoveEventListener(event: 'permissionChange', listener: (obj: { to: NotificationPermission }) => void): void; | ||
function notificationsRemoveEventListener(event: 'permissionPromptDisplay', listener: () => void): void; | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showSlidedownPrompt(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
function notificationsRemoveEventListener(event: NotificationEventName, listener: (obj: any) => void): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Notifications.removeEventListener(event, listener) | ||
}); | ||
} | ||
function showCategorySlidedown(options?: AutoPromptOptions): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showCategorySlidedown', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function sessionSendOutcome(outcomeName: string, outcomeWeight?: number): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showCategorySlidedown(options) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Session.sendOutcome(outcomeName, outcomeWeight) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showSmsSlidedown(options?: AutoPromptOptions): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showSmsSlidedown', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function sessionSendUniqueOutcome(outcomeName: string): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showSmsSlidedown(options) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Session.sendUniqueOutcome(outcomeName) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showEmailSlidedown(options?: AutoPromptOptions): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showEmailSlidedown', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function userAddAlias(label: string, id: string): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.User.addAlias(label, id) | ||
}); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showEmailSlidedown(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
function userAddAliases(aliases: { [key: string]: string }): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.User.addAliases(aliases) | ||
}); | ||
} | ||
function showSmsAndEmailSlidedown(options?: AutoPromptOptions): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'showSmsAndEmailSlidedown', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function userRemoveAlias(label: string): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.User.removeAlias(label) | ||
}); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.showSmsAndEmailSlidedown(options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
function userRemoveAliases(labels: string[]): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.User.removeAliases(labels) | ||
}); | ||
} | ||
function getNotificationPermission(onComplete?: Action<NotificationPermission>): Promise<NotificationPermission> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'getNotificationPermission', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function userAddEmail(email: string): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.User.addEmail(email) | ||
}); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.getNotificationPermission(onComplete) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
function userRemoveEmail(email: string): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.User.removeEmail(email) | ||
}); | ||
} | ||
function getUserId(callback?: Action<string | undefined | null>): Promise<string | undefined | null> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'getUserId', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function userAddSms(smsNumber: string): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.User.addSms(smsNumber) | ||
}); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.getUserId(callback) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
function userRemoveSms(smsNumber: string): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.User.removeSms(smsNumber) | ||
}); | ||
} | ||
function getSubscription(callback?: Action<boolean>): Promise<boolean> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'getSubscription', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function pushSubscriptionOptIn(): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.getSubscription(callback) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.User.PushSubscription.optIn() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setEmail(email: string, options?: SetEmailOptions): Promise<string|null> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'setEmail', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function pushSubscriptionOptOut(): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (isOneSignalScriptFailed) { | ||
reject(); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.setEmail(email, options) | ||
try { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.User.PushSubscription.optOut() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setSMSNumber(smsNumber: string, options?: SetSMSOptions): Promise<string | null> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'setSMSNumber', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function pushSubscriptionAddEventListener(event: 'subscriptionChange', listener: (change: SubscriptionChangeEvent) => void): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.User.PushSubscription.addEventListener(event, listener) | ||
}); | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.setSMSNumber(smsNumber, options) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
function pushSubscriptionRemoveEventListener(event: 'subscriptionChange', listener: (change: SubscriptionChangeEvent) => void): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.User.PushSubscription.removeEventListener(event, listener) | ||
}); | ||
} | ||
function logoutEmail(): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'logoutEmail', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
function debugSetLogLevel(logLevel: string): void { | ||
window.OneSignalDeferred?.push((OneSignal) => { | ||
OneSignal.Debug.setLogLevel(logLevel) | ||
}); | ||
} | ||
const PushSubscriptionNamespace: IOneSignalPushSubscription = { | ||
optIn: pushSubscriptionOptIn, | ||
optOut: pushSubscriptionOptOut, | ||
addEventListener: pushSubscriptionAddEventListener, | ||
removeEventListener: pushSubscriptionRemoveEventListener, | ||
}; | ||
window.OneSignal.push(() => { | ||
window.OneSignal.logoutEmail() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
const UserNamespace: IOneSignalUser = { | ||
addAlias: userAddAlias, | ||
addAliases: userAddAliases, | ||
removeAlias: userRemoveAlias, | ||
removeAliases: userRemoveAliases, | ||
addEmail: userAddEmail, | ||
removeEmail: userRemoveEmail, | ||
addSms: userAddSms, | ||
removeSms: userRemoveSms, | ||
PushSubscription: PushSubscriptionNamespace, | ||
}; | ||
function logoutSMS(): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'logoutSMS', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
const SessionNamespace: IOneSignalSession = { | ||
sendOutcome: sessionSendOutcome, | ||
sendUniqueOutcome: sessionSendUniqueOutcome, | ||
}; | ||
window.OneSignal.push(() => { | ||
window.OneSignal.logoutSMS() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
const DebugNamespace: IOneSignalDebug = { | ||
setLogLevel: debugSetLogLevel, | ||
}; | ||
function setExternalUserId(externalUserId: string | undefined | null, authHash?: string): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'setExternalUserId', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
const SlidedownNamespace: IOneSignalSlidedown = { | ||
promptPush: slidedownPromptPush, | ||
promptPushCategories: slidedownPromptPushCategories, | ||
promptSms: slidedownPromptSms, | ||
promptEmail: slidedownPromptEmail, | ||
promptSmsAndEmail: slidedownPromptSmsAndEmail, | ||
addEventListener: slidedownAddEventListener, | ||
removeEventListener: slidedownRemoveEventListener, | ||
}; | ||
window.OneSignal.push(() => { | ||
window.OneSignal.setExternalUserId(externalUserId, authHash) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
const NotificationsNamespace: IOneSignalNotifications = { | ||
setDefaultUrl: notificationsSetDefaultUrl, | ||
setDefaultTitle: notificationsSetDefaultTitle, | ||
isPushSupported, | ||
getPermissionStatus: notificationsGetPermissionStatus, | ||
requestPermission: notificationsRequestPermission, | ||
addEventListener: notificationsAddEventListener, | ||
removeEventListener: notificationsRemoveEventListener, | ||
}; | ||
function removeExternalUserId(): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'removeExternalUserId', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.removeExternalUserId() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
function getExternalUserId(): Promise<string | undefined | null> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'getExternalUserId', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.getExternalUserId() | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
function provideUserConsent(consent: boolean): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'provideUserConsent', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.provideUserConsent(consent) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
function getEmailId(callback?: Action<string | undefined>): Promise<string | null | undefined> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'getEmailId', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.getEmailId(callback) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
function getSMSId(callback?: Action<string | undefined>): Promise<string | null | undefined> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'getSMSId', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.getSMSId(callback) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
function sendOutcome(outcomeName: string, outcomeWeight?: number | undefined): Promise<void> { | ||
return new Promise(function (resolve, reject) { | ||
if (!doesOneSignalExist()) { | ||
vueOneSignalFunctionQueue.push({ | ||
name: 'sendOutcome', | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
window.OneSignal.push(() => { | ||
window.OneSignal.sendOutcome(outcomeName, outcomeWeight) | ||
.then(value => resolve(value)) | ||
.catch(error => reject(error)); | ||
}); | ||
}); | ||
} | ||
const OneSignalVue: IOneSignal = { | ||
const OneSignalNamespace: IOneSignalOneSignal = { | ||
login: oneSignalLogin, | ||
logout: oneSignalLogout, | ||
init, | ||
on, | ||
off, | ||
once, | ||
isPushNotificationsEnabled, | ||
showHttpPrompt, | ||
registerForPushNotifications, | ||
setDefaultNotificationUrl, | ||
setDefaultTitle, | ||
getTags, | ||
sendTag, | ||
sendTags, | ||
deleteTag, | ||
deleteTags, | ||
addListenerForNotificationOpened, | ||
setSubscription, | ||
showHttpPermissionRequest, | ||
showNativePrompt, | ||
showSlidedownPrompt, | ||
showCategorySlidedown, | ||
showSmsSlidedown, | ||
showEmailSlidedown, | ||
showSmsAndEmailSlidedown, | ||
getNotificationPermission, | ||
getUserId, | ||
getSubscription, | ||
setEmail, | ||
setSMSNumber, | ||
logoutEmail, | ||
logoutSMS, | ||
setExternalUserId, | ||
removeExternalUserId, | ||
getExternalUserId, | ||
provideUserConsent, | ||
getEmailId, | ||
getSMSId, | ||
sendOutcome, | ||
setConsentGiven: oneSignalSetConsentGiven, | ||
setConsentRequired: oneSignalSetConsentRequired, | ||
Slidedown: SlidedownNamespace, | ||
Notifications: NotificationsNamespace, | ||
Session: SessionNamespace, | ||
User: UserNamespace, | ||
Debug: DebugNamespace, | ||
}; | ||
export const useOneSignal = () => { | ||
return OneSignalVue; | ||
return OneSignalNamespace; | ||
} | ||
@@ -885,3 +689,3 @@ | ||
install(app: App, options: IInitObject) { | ||
app.config.globalProperties.$OneSignal = OneSignalVue as IOneSignal; | ||
app.config.globalProperties.$OneSignal = OneSignalNamespace as IOneSignalOneSignal; | ||
app.config.globalProperties.$OneSignal.init(options); | ||
@@ -888,0 +692,0 @@ } |
{ | ||
"name": "@onesignal/onesignal-vue3", | ||
"version": "1.0.2", | ||
"version": "2.0.0-beta.1", | ||
"description": "Vue 3 OneSignal Plugin: Make it easy to integrate OneSignal with your Vue App!", | ||
@@ -5,0 +5,0 @@ "author": "rgomezp", |
@@ -16,2 +16,5 @@ <h1 align="center">welcome to onesignal-vue3 👋</h1> | ||
> 🚧 Version 2 now in Beta! | ||
See our [migration guide](./MigrationGuide.md) to get started. | ||
## Contents | ||
@@ -18,0 +21,0 @@ - [Install](#install) |
@@ -24,3 +24,3 @@ { | ||
"include": ["index.ts"], | ||
"exclude": ["node_modules", "build", "dist", "example", "rollup.config.js"] | ||
"exclude": ["node_modules", "build", "dist", "example"] | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
94553
18
231
1355
2
1