Skip to content

Commit

Permalink
type: export plugin types
Browse files Browse the repository at this point in the history
  • Loading branch information
devonik committed Aug 15, 2023
1 parent 60eb33c commit 44db995
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 123 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Changelog


## v1.0.5

[compare changes](https://github.com/devonik/nuxt-3-intercom/compare/v1.0.2...v1.0.5)

## v1.0.4

[compare changes](https://github.com/devonik/nuxt-3-intercom/compare/v1.0.2...v1.0.4)

## v1.0.3

[compare changes](https://github.com/devonik/nuxt-3-intercom/compare/v1.0.2...v1.0.3)

## v1.0.2

[compare changes](https://github.com/devonik/nuxt-3-intercom/compare/v1.0.1...v1.0.2)
Expand Down
5 changes: 0 additions & 5 deletions index.d.ts

This file was deleted.

11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nuxt-3-intercom",
"type": "module",
"version": "1.0.2",
"version": "1.0.5",
"description": "This nuxt 3 module provides a client side plugin that add intercom to window and provides $intercom instance so you can easily access intercom function like update user properties",
"author": {
"name": "devnik",
Expand Down Expand Up @@ -33,6 +33,7 @@
"scripts": {
"prepack": "nuxt-module-build",
"dev": "nuxi dev playground",
"compile": "nuxi typecheck",
"dev:build": "nuxi build playground",
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
Expand All @@ -56,11 +57,5 @@
"nuxt": "^3.6.5",
"simple-git-hooks": "^2.8.1",
"vitest": "^0.34.1"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
},
"lint-staged": {
"*": "eslint --fix"
}
}
}
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 1 addition & 36 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,6 @@
import { addPlugin, createResolver, defineNuxtModule } from '@nuxt/kit'
import { defu } from 'defu'

export interface NuxtIntercomConfig {
/** Intercom ID */
appId?: string
/** Intercom ID getting with promise */
appIdPromise?: Function
/** True to boot messenger widget and show UI on page load, false to allow manually booting later. Default: true */
autoBoot: boolean
/** True to show debug messages in the console, useful for development, false to not show them. Default: false */
debug: boolean
/** Object to specify messenger attributes to configure when booting. see https://developers.intercom.com/installing-intercom/docs/javascript-api-attributes-objects#section-messenger-attributes. Default: {} */
config: any
/** String to identfy the script tag, for vue-meta. Default: "intercom-script" */
scriptId: string
/** True to defer loading intercom widget javascript until page loads, false to async load it in document flow. Default: false */
scriptDefer: boolean
/** True to call intercom's 'update' method on route change, false to not do this. Default: true */
updateOnPageRoute: boolean
/** The CSS selector of an element to trigger Intercom("show") in order to activate the messenger (See https://docs.intercom.com/configure-intercom-for-your-product-or-site/customize-the-intercom-messenger/customize-the-intercom-messenger-technical). To target an element by ID: "#id_of_element". To target elements by class ".classname_of_elements" */
custom_launcher_selector?: string
/** Dictate the alignment of the default launcher icon to be on the left/right. Possible values: "left" or "right" (any other value is treated as right). (See https://docs.intercom.com/configure-intercom-for-your-product-or-site/customize-the-intercom-messenger/customize-the-intercom-messenger-technical) */
alignment?: string
/** Move the default launcher icon vertically. Padding from bottom of screen. Minimum value: 20. Does not work on mobile. (See https://docs.intercom.com/configure-intercom-for-your-product-or-site/customize-the-intercom-messenger/customize-the-intercom-messenger-technical) */
vertical_padding?: number
/** Move the default launcher icon horizontally. Padding from right side of screen Minimum value: 20. Does not work on mobile. (See https://docs.intercom.com/configure-intercom-for-your-product-or-site/customize-the-intercom-messenger/customize-the-intercom-messenger-technical) */
horizontal_padding?: number
/** Hide the default launcher icon. Setting to false will forcefully show the launcher icon (See https://docs.intercom.com/configure-intercom-for-your-product-or-site/customize-the-intercom-messenger/turn-off-show-or-hide-the-intercom-messenger) */
hide_default_launcher?: boolean
/** Time in milliseconds for the Intercom session to be considered active.A value of 5 * 60 * 1000 would set the expiry time to be 5 minutes */
session_duration?: number
/** Used in button links and more to highlight and emphasise. The color string can be any valid CSS (https://www.w3schools.com/cssref/css_colors.asp) Color Name HEX or RGB */
action_color?: string
/** Used behind your team profile and other attributes. The color string can be any valid CSS (https://www.w3schools.com/cssref/css_colors.asp) Color Name HEX or RGB */
background_color?: string
}

export default defineNuxtModule<NuxtIntercomConfig>({
meta: {
name: 'nuxt-3-intercom',
Expand All @@ -51,7 +16,7 @@ export default defineNuxtModule<NuxtIntercomConfig>({
scriptDefer: false,
updateOnPageRoute: true,
},
setup(config, nuxt) {
setup(config: NuxtIntercomConfig, nuxt: any) {
const resolver = createResolver(import.meta.url)

// Async id evaluation
Expand Down
72 changes: 0 additions & 72 deletions src/runtime/Intercom.ts
Original file line number Diff line number Diff line change
@@ -1,75 +1,3 @@
import type { NuxtIntercomConfig } from '../module'

declare global {
interface Window {
Intercom?: any
intercomSettings?: any
}
}
interface IntercomUserAvatar {
/** The value is "avatar" */
type: string
/** An avatar image URL. Note: needs to be https. */
image_url: string
}
interface IntercomUserCompany {
/** The company ID of the company */
company_id: string
/** The name of the company */
name: string
/** The time the company was created in your system */
remote_created_at: number
/** The name of the plan the company is on */
plan: string
/** How much revenue the company generates for your business */
monthly_spend: number
/** Indicates the number of users in Intercom associated to the companyDoes not actually update the value but is a reserved keyword */
user_count: number
/** The number of employees in the company */
size: number
/** The URL for the company website */
website: string
/** The industry of the company */
industry: string
}
export interface IntercomUserData {
[key: string]: any
/** The email address of the currently logged in user (Only applicable to users) */
email?: string
/** The user_id address of the currently logged in user (Only applicable to users) */
user_id?: string
/** The Unix timestamp (in seconds) when the user signed up to your app (Only applicable to users) */
created_at?: number
/** Name of the current user/lead */
name?: string
/** Phone number of the current user/lead */
phone?: string
/** This value can't actually be set by the Javascript API (it automatically uses the time of the last request but is a this is a reserved attribute) */
last_request_at?: number
/** Sets the [unsubscribe status]((https://docs.intercom.com/faqs-and-troubleshooting/unsubscribing-users/how-do-i-unsubscribe-users-from-receiving-emails) of the record */
unsubscribed_from_emails?: boolean
/** Set the messenger language programmatically (instead of relying on browser language settings) */
language_override?: string
/** UTM Campaign valueNote: All UTM parameters are updated automatically and can not be manually overidden (See https://docs.intercom.com/the-intercom-platform/track-conversions-and-clicks-with-utm-parameters for more) */
utm_campaign?: string
/** https://docs.intercom.com/the-intercom-platform/track-conversions-and-clicks-with-utm-parameters */
utm_content?: string
/** https://docs.intercom.com/the-intercom-platform/track-conversions-and-clicks-with-utm-parameters */
utm_medium?: string
/** https://docs.intercom.com/the-intercom-platform/track-conversions-and-clicks-with-utm-parameters */
utm_source?: string
/** https://docs.intercom.com/the-intercom-platform/track-conversions-and-clicks-with-utm-parameters */
utm_term?: string
/** Set the avatar/profile image associated to the current record (typically gathered via social profiles via email address https://docs.intercom.com/faqs-and-troubleshooting/your-users-and-leads-data-in-intercom/where-do-the-social-profiles-come-from) */
avatar?: IntercomUserAvatar
/** Used for identity verification (Only applicable to users) */
user_hash?: string
/** Current user's company (Only applicable to users)For field definitions see Company Object in the section belowNote: Company ID and company name are the minimum requirements to pass a company into Intercom. */
company?: IntercomUserCompany
/** An array of companies the user is associated to (Only applicable to users) */
companies?: Array<IntercomUserCompany>
app_id?: string | undefined
}
export default class Intercom {
/** Intercom ID */
appId?: string
Expand Down
7 changes: 6 additions & 1 deletion src/runtime/plugin.client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { NuxtIntercomConfig } from '../module'
import Intercom from './Intercom'
import { defineNuxtPlugin, useRuntimeConfig } from '#app'

Expand Down Expand Up @@ -71,3 +70,9 @@ export default defineNuxtPlugin((nuxtApp) => {
},
}
})

declare module '#app' {
interface NuxtApp {
$intercom: Intercom
}
}
99 changes: 99 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
interface NuxtIntercomConfig {
/** Intercom ID */
appId?: string
/** Intercom ID getting with promise */
appIdPromise?: Function
/** True to boot messenger widget and show UI on page load, false to allow manually booting later. Default: true */
autoBoot: boolean
/** True to show debug messages in the console, useful for development, false to not show them. Default: false */
debug: boolean
/** Object to specify messenger attributes to configure when booting. see https://developers.intercom.com/installing-intercom/docs/javascript-api-attributes-objects#section-messenger-attributes. Default: {} */
config: any
/** String to identfy the script tag, for vue-meta. Default: "intercom-script" */
scriptId: string
/** True to defer loading intercom widget javascript until page loads, false to async load it in document flow. Default: false */
scriptDefer: boolean
/** True to call intercom's 'update' method on route change, false to not do this. Default: true */
updateOnPageRoute: boolean
/** The CSS selector of an element to trigger Intercom("show") in order to activate the messenger (See https://docs.intercom.com/configure-intercom-for-your-product-or-site/customize-the-intercom-messenger/customize-the-intercom-messenger-technical). To target an element by ID: "#id_of_element". To target elements by class ".classname_of_elements" */
custom_launcher_selector?: string
/** Dictate the alignment of the default launcher icon to be on the left/right. Possible values: "left" or "right" (any other value is treated as right). (See https://docs.intercom.com/configure-intercom-for-your-product-or-site/customize-the-intercom-messenger/customize-the-intercom-messenger-technical) */
alignment?: string
/** Move the default launcher icon vertically. Padding from bottom of screen. Minimum value: 20. Does not work on mobile. (See https://docs.intercom.com/configure-intercom-for-your-product-or-site/customize-the-intercom-messenger/customize-the-intercom-messenger-technical) */
vertical_padding?: number
/** Move the default launcher icon horizontally. Padding from right side of screen Minimum value: 20. Does not work on mobile. (See https://docs.intercom.com/configure-intercom-for-your-product-or-site/customize-the-intercom-messenger/customize-the-intercom-messenger-technical) */
horizontal_padding?: number
/** Hide the default launcher icon. Setting to false will forcefully show the launcher icon (See https://docs.intercom.com/configure-intercom-for-your-product-or-site/customize-the-intercom-messenger/turn-off-show-or-hide-the-intercom-messenger) */
hide_default_launcher?: boolean
/** Time in milliseconds for the Intercom session to be considered active.A value of 5 * 60 * 1000 would set the expiry time to be 5 minutes */
session_duration?: number
/** Used in button links and more to highlight and emphasise. The color string can be any valid CSS (https://www.w3schools.com/cssref/css_colors.asp) Color Name HEX or RGB */
action_color?: string
/** Used behind your team profile and other attributes. The color string can be any valid CSS (https://www.w3schools.com/cssref/css_colors.asp) Color Name HEX or RGB */
background_color?: string
}

interface IntercomUserAvatar {
/** The value is "avatar" */
type: string
/** An avatar image URL. Note: needs to be https. */
image_url: string
}
interface IntercomUserCompany {
/** The company ID of the company */
company_id: string
/** The name of the company */
name: string
/** The time the company was created in your system */
remote_created_at: number
/** The name of the plan the company is on */
plan: string
/** How much revenue the company generates for your business */
monthly_spend: number
/** Indicates the number of users in Intercom associated to the companyDoes not actually update the value but is a reserved keyword */
user_count: number
/** The number of employees in the company */
size: number
/** The URL for the company website */
website: string
/** The industry of the company */
industry: string
}
interface IntercomUserData {
[key: string]: any
/** The email address of the currently logged in user (Only applicable to users) */
email?: string
/** The user_id address of the currently logged in user (Only applicable to users) */
user_id?: string
/** The Unix timestamp (in seconds) when the user signed up to your app (Only applicable to users) */
created_at?: number
/** Name of the current user/lead */
name?: string
/** Phone number of the current user/lead */
phone?: string
/** This value can't actually be set by the Javascript API (it automatically uses the time of the last request but is a this is a reserved attribute) */
last_request_at?: number
/** Sets the [unsubscribe status]((https://docs.intercom.com/faqs-and-troubleshooting/unsubscribing-users/how-do-i-unsubscribe-users-from-receiving-emails) of the record */
unsubscribed_from_emails?: boolean
/** Set the messenger language programmatically (instead of relying on browser language settings) */
language_override?: string
/** UTM Campaign valueNote: All UTM parameters are updated automatically and can not be manually overidden (See https://docs.intercom.com/the-intercom-platform/track-conversions-and-clicks-with-utm-parameters for more) */
utm_campaign?: string
/** https://docs.intercom.com/the-intercom-platform/track-conversions-and-clicks-with-utm-parameters */
utm_content?: string
/** https://docs.intercom.com/the-intercom-platform/track-conversions-and-clicks-with-utm-parameters */
utm_medium?: string
/** https://docs.intercom.com/the-intercom-platform/track-conversions-and-clicks-with-utm-parameters */
utm_source?: string
/** https://docs.intercom.com/the-intercom-platform/track-conversions-and-clicks-with-utm-parameters */
utm_term?: string
/** Set the avatar/profile image associated to the current record (typically gathered via social profiles via email address https://docs.intercom.com/faqs-and-troubleshooting/your-users-and-leads-data-in-intercom/where-do-the-social-profiles-come-from) */
avatar?: IntercomUserAvatar
/** Used for identity verification (Only applicable to users) */
user_hash?: string
/** Current user's company (Only applicable to users)For field definitions see Company Object in the section belowNote: Company ID and company name are the minimum requirements to pass a company into Intercom. */
company?: IntercomUserCompany
/** An array of companies the user is associated to (Only applicable to users) */
companies?: Array<IntercomUserCompany>
app_id?: string | undefined
}

0 comments on commit 44db995

Please sign in to comment.