react-onesignal 3.2.2 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +6 -5
- package/dist/index.d.ts +7 -2
- package/dist/index.es.js +166 -163
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -1
- package/.editorconfig +0 -9
- package/.eslintignore +0 -2
- package/.eslintrc.cjs +0 -45
- package/.github/ISSUE_TEMPLATE/ask-question.yml +0 -19
- package/.github/ISSUE_TEMPLATE/bug-report.yml +0 -70
- package/.github/ISSUE_TEMPLATE/general-feedback.yml +0 -19
- package/.github/ISSUE_TEMPLATE/workflows/Zapier.yml +0 -34
- package/.github/ISSUE_TEMPLATE/workflows/release-drafter.yml +0 -41
- package/.github/release-drafter.yml +0 -27
- package/.github/workflows/release.yml +0 -40
- package/.releaserc.json +0 -133
- package/.travis.yml +0 -3
- package/.vscode/settings.json +0 -3
- package/index.test.ts +0 -50
- package/index.ts +0 -1039
- package/rollup.config.js +0 -37
- package/tsconfig.json +0 -25
- package/vite.config.ts +0 -20
- package/vitest.config.ts +0 -8
package/.eslintrc.cjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
env: {
|
|
4
|
-
browser: true,
|
|
5
|
-
es6: true,
|
|
6
|
-
node: true,
|
|
7
|
-
},
|
|
8
|
-
settings: {
|
|
9
|
-
'import/resolver': {
|
|
10
|
-
node: {
|
|
11
|
-
paths: ['src'],
|
|
12
|
-
extensions: ['.js', '.ts', '.jsx', '.tsx'],
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
extends: [
|
|
17
|
-
'plugin:react/recommended',
|
|
18
|
-
'plugin:@typescript-eslint/recommended',
|
|
19
|
-
],
|
|
20
|
-
parser: '@typescript-eslint/parser',
|
|
21
|
-
parserOptions: {
|
|
22
|
-
ecmaFeatures: {
|
|
23
|
-
jsx: true,
|
|
24
|
-
},
|
|
25
|
-
ecmaVersion: 2018,
|
|
26
|
-
sourceType: 'module',
|
|
27
|
-
},
|
|
28
|
-
plugins: ['react', '@typescript-eslint'],
|
|
29
|
-
rules: {
|
|
30
|
-
'react/jsx-filename-extension': [1, { extensions: ['.tsx', '.jsx'] }],
|
|
31
|
-
'react/jsx-props-no-spreading': 0,
|
|
32
|
-
'@typescript-eslint/no-unused-vars': ['error'],
|
|
33
|
-
'@typescript-eslint/no-explicit-any': 'warn',
|
|
34
|
-
'prefer-destructuring': 0,
|
|
35
|
-
'no-param-reassign': 0,
|
|
36
|
-
'import/extensions': 0,
|
|
37
|
-
'dot-notation': 0,
|
|
38
|
-
'no-continue': 0,
|
|
39
|
-
'no-unused-vars': 'off',
|
|
40
|
-
'no-unused-expressions': [
|
|
41
|
-
'error',
|
|
42
|
-
{ allowShortCircuit: true, allowTernary: true },
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
name: 🙋♂️ Ask a question
|
|
2
|
-
description: Tell us what's on your mind
|
|
3
|
-
title: "[Question]: "
|
|
4
|
-
labels: ["triage"]
|
|
5
|
-
assignees:
|
|
6
|
-
- OneSignal/eng-developer-sdk
|
|
7
|
-
body:
|
|
8
|
-
- type: markdown
|
|
9
|
-
attributes:
|
|
10
|
-
value: |
|
|
11
|
-
Having issues integrating this SDK?
|
|
12
|
-
- type: textarea
|
|
13
|
-
id: question
|
|
14
|
-
attributes:
|
|
15
|
-
label: How can we help?
|
|
16
|
-
description: Specific question regarding integrating this SDK.
|
|
17
|
-
placeholder: How do I...?
|
|
18
|
-
validations:
|
|
19
|
-
required: true
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
name: 🪳 Bug report
|
|
2
|
-
description: File a bug report
|
|
3
|
-
title: "[Bug]: "
|
|
4
|
-
labels: ["bug", "triage"]
|
|
5
|
-
assignees:
|
|
6
|
-
- OneSignal/eng-developer-sdk
|
|
7
|
-
body:
|
|
8
|
-
- type: markdown
|
|
9
|
-
attributes:
|
|
10
|
-
value: |
|
|
11
|
-
Thanks for taking the time to fill out this bug report!
|
|
12
|
-
- type: textarea
|
|
13
|
-
id: what-happened
|
|
14
|
-
attributes:
|
|
15
|
-
label: What happened?
|
|
16
|
-
description: Provide a thorough description of whats going on.
|
|
17
|
-
placeholder: The latest version of the SDK causes a runtime error.
|
|
18
|
-
validations:
|
|
19
|
-
required: true
|
|
20
|
-
- type: dropdown
|
|
21
|
-
id: browsers
|
|
22
|
-
attributes:
|
|
23
|
-
label: What browsers are you seeing the problem on?
|
|
24
|
-
multiple: true
|
|
25
|
-
options:
|
|
26
|
-
- Firefox
|
|
27
|
-
- Chrome (Chromium)
|
|
28
|
-
- Safari
|
|
29
|
-
- Microsoft Edge
|
|
30
|
-
- Opera
|
|
31
|
-
- Brave
|
|
32
|
-
- Other
|
|
33
|
-
validations:
|
|
34
|
-
required: true
|
|
35
|
-
- type: input
|
|
36
|
-
id: operating-system
|
|
37
|
-
attributes:
|
|
38
|
-
label: What operating system are you running?
|
|
39
|
-
description: Make sure to include the version.
|
|
40
|
-
placeholder: macOS Monterey 12.3.1
|
|
41
|
-
validations:
|
|
42
|
-
required: true
|
|
43
|
-
- type: textarea
|
|
44
|
-
id: reproduction-steps
|
|
45
|
-
attributes:
|
|
46
|
-
label: Steps to reproduce?
|
|
47
|
-
description: Provide as much detail as posible to reproduce the issue.
|
|
48
|
-
placeholder: |
|
|
49
|
-
1. Install dependencies: vX.Y.Z, etc...
|
|
50
|
-
2. Run the app
|
|
51
|
-
3. Click on the notification prompt
|
|
52
|
-
4. Note that this causes a runtime error and a failed subscription.
|
|
53
|
-
render: Markdown
|
|
54
|
-
validations:
|
|
55
|
-
required: true
|
|
56
|
-
- type: textarea
|
|
57
|
-
id: what-are-expectations
|
|
58
|
-
attributes:
|
|
59
|
-
label: What did you expect to happen?
|
|
60
|
-
description: Also tell us, what did you expect to happen?
|
|
61
|
-
placeholder: I expected the notification prompt to cause a native permission change in the browser.
|
|
62
|
-
validations:
|
|
63
|
-
required: true
|
|
64
|
-
- type: textarea
|
|
65
|
-
id: logs
|
|
66
|
-
attributes:
|
|
67
|
-
label: Relevant log output
|
|
68
|
-
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
|
|
69
|
-
render: Shell
|
|
70
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
name: 📣 General feedback
|
|
2
|
-
description: Tell us what's on your mind
|
|
3
|
-
title: "[Feedback]: "
|
|
4
|
-
labels: ["triage"]
|
|
5
|
-
assignees:
|
|
6
|
-
- OneSignal/eng-developer-sdk
|
|
7
|
-
body:
|
|
8
|
-
- type: markdown
|
|
9
|
-
attributes:
|
|
10
|
-
value: |
|
|
11
|
-
Thanks for sharing your valuable feedback!
|
|
12
|
-
- type: textarea
|
|
13
|
-
id: feedback
|
|
14
|
-
attributes:
|
|
15
|
-
label: What's on your mind?
|
|
16
|
-
description: Feedback regarding this SDK.
|
|
17
|
-
placeholder: Share your feedback...
|
|
18
|
-
validations:
|
|
19
|
-
required: true
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# This is an action to close asana tasks that were generated by Github issues
|
|
2
|
-
|
|
3
|
-
name: Zapier web hook
|
|
4
|
-
|
|
5
|
-
# Controls when the workflow will run
|
|
6
|
-
on:
|
|
7
|
-
# Triggers the workflow on push or pull request events but only for the "main" branch
|
|
8
|
-
issues:
|
|
9
|
-
types: [closed]
|
|
10
|
-
|
|
11
|
-
permissions:
|
|
12
|
-
issues: read
|
|
13
|
-
|
|
14
|
-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
|
15
|
-
jobs:
|
|
16
|
-
# This workflow contains a single job called "build"
|
|
17
|
-
build:
|
|
18
|
-
# The type of runner that the job will run on
|
|
19
|
-
runs-on: ubuntu-latest
|
|
20
|
-
|
|
21
|
-
# Steps represent a sequence of tasks that will be executed as part of the job
|
|
22
|
-
steps:
|
|
23
|
-
# Runs a set of commands using the runners shell
|
|
24
|
-
- name: Call Zapier web hook to close Asana task
|
|
25
|
-
if: ${{ !github.event.issue.pull_request }}
|
|
26
|
-
env:
|
|
27
|
-
ISSUE_TITLE: ${{ github.event.issue.title }}
|
|
28
|
-
run: |
|
|
29
|
-
curl --location --request POST 'https://hooks.zapier.com/hooks/catch/12728683/b7009qc/' \
|
|
30
|
-
--header 'Content-Type: application/json' \
|
|
31
|
-
--header 'Accept: application/json' \
|
|
32
|
-
--data-raw '{
|
|
33
|
-
"task_name" : "$ISSUE_TITLE"
|
|
34
|
-
}'
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
name: Release Drafter
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
# branches to consider in the event; optional, defaults to all
|
|
6
|
-
branches:
|
|
7
|
-
- main
|
|
8
|
-
# pull_request event is required only for autolabeler
|
|
9
|
-
pull_request:
|
|
10
|
-
# Only following types are handled by the action, but one can default to all as well
|
|
11
|
-
types: [opened, reopened, synchronize]
|
|
12
|
-
# pull_request_target event is required for autolabeler to support PRs from forks
|
|
13
|
-
# pull_request_target:
|
|
14
|
-
# types: [opened, reopened, synchronize]
|
|
15
|
-
|
|
16
|
-
permissions:
|
|
17
|
-
contents: read
|
|
18
|
-
|
|
19
|
-
jobs:
|
|
20
|
-
update_release_draft:
|
|
21
|
-
permissions:
|
|
22
|
-
# write permission is required to create a github release
|
|
23
|
-
contents: write
|
|
24
|
-
# write permission is required for autolabeler
|
|
25
|
-
# otherwise, read permission is required at least
|
|
26
|
-
pull-requests: write
|
|
27
|
-
runs-on: ubuntu-latest
|
|
28
|
-
steps:
|
|
29
|
-
# (Optional) GitHub Enterprise requires GHE_HOST variable set
|
|
30
|
-
#- name: Set GHE_HOST
|
|
31
|
-
# run: |
|
|
32
|
-
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV
|
|
33
|
-
|
|
34
|
-
# Drafts your next Release notes as Pull Requests are merged into "master"
|
|
35
|
-
- uses: release-drafter/release-drafter@v5
|
|
36
|
-
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
|
|
37
|
-
# with:
|
|
38
|
-
# config-name: my-config.yml
|
|
39
|
-
# disable-autolabeler: true
|
|
40
|
-
env:
|
|
41
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
name-template: $RESOLVED_VERSION
|
|
2
|
-
tag-template: $RESOLVED_VERSION
|
|
3
|
-
categories:
|
|
4
|
-
- title: 🚀 Features
|
|
5
|
-
label: Enhancement / Feature
|
|
6
|
-
- title: 🐛 Bug Fixes
|
|
7
|
-
label: Bug
|
|
8
|
-
- title: 🧰 Improvements
|
|
9
|
-
label: Improvement
|
|
10
|
-
- title: down arrow Dependency Updates
|
|
11
|
-
label: Dependencies
|
|
12
|
-
change-template: '- $TITLE (#$NUMBER)'
|
|
13
|
-
version-resolver:
|
|
14
|
-
major:
|
|
15
|
-
labels:
|
|
16
|
-
- 'major'
|
|
17
|
-
minor:
|
|
18
|
-
labels:
|
|
19
|
-
- 'minor'
|
|
20
|
-
patch:
|
|
21
|
-
labels:
|
|
22
|
-
- 'patch'
|
|
23
|
-
default: patch
|
|
24
|
-
template: |
|
|
25
|
-
## Other Changes
|
|
26
|
-
|
|
27
|
-
$CHANGES
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
name: Release
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches:
|
|
5
|
-
- main
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
release:
|
|
9
|
-
name: Release
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
permissions:
|
|
12
|
-
contents: write
|
|
13
|
-
issues: write
|
|
14
|
-
pull-requests: write
|
|
15
|
-
steps:
|
|
16
|
-
- name: Checkout
|
|
17
|
-
uses: actions/checkout@v4
|
|
18
|
-
with:
|
|
19
|
-
fetch-depth: 0
|
|
20
|
-
token: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
|
|
21
|
-
- name: Setup Node.js
|
|
22
|
-
uses: actions/setup-node@v4
|
|
23
|
-
with:
|
|
24
|
-
node-version: 'lts/*'
|
|
25
|
-
registry-url: 'https://registry.npmjs.org'
|
|
26
|
-
- name: Install dependencies
|
|
27
|
-
run: npm ci
|
|
28
|
-
- name: Release
|
|
29
|
-
env:
|
|
30
|
-
GITHUB_TOKEN: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
|
|
31
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_WEB_SHIM_PUSH_TOKEN }}
|
|
32
|
-
NPM_TOKEN: ${{ secrets.NPM_WEB_SHIM_PUSH_TOKEN }}
|
|
33
|
-
run: |
|
|
34
|
-
npx -p semantic-release \
|
|
35
|
-
-p @semantic-release/changelog \
|
|
36
|
-
-p @semantic-release/git \
|
|
37
|
-
-p @semantic-release/github \
|
|
38
|
-
-p @semantic-release/npm \
|
|
39
|
-
-p conventional-changelog-conventionalcommits \
|
|
40
|
-
semantic-release
|
package/.releaserc.json
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"branches": [
|
|
3
|
-
"main"
|
|
4
|
-
],
|
|
5
|
-
"tagFormat": "${version}",
|
|
6
|
-
"plugins": [
|
|
7
|
-
[
|
|
8
|
-
"@semantic-release/commit-analyzer",
|
|
9
|
-
{
|
|
10
|
-
"releaseRules": [
|
|
11
|
-
{
|
|
12
|
-
"breaking": true,
|
|
13
|
-
"release": "minor"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"type": "feat",
|
|
17
|
-
"release": "minor"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"type": "fix",
|
|
21
|
-
"release": "patch"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"type": "docs",
|
|
25
|
-
"release": "patch"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"type": "perf",
|
|
29
|
-
"release": "patch"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"type": "refactor",
|
|
33
|
-
"release": "patch"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"type": "style",
|
|
37
|
-
"release": "patch"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"type": "test",
|
|
41
|
-
"release": "patch"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"type": "build",
|
|
45
|
-
"release": "patch"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"type": "ci",
|
|
49
|
-
"release": "patch"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"type": "chore",
|
|
53
|
-
"scope": "deps",
|
|
54
|
-
"release": "patch"
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
}
|
|
58
|
-
],
|
|
59
|
-
[
|
|
60
|
-
"@semantic-release/release-notes-generator",
|
|
61
|
-
{
|
|
62
|
-
"preset": "conventionalcommits",
|
|
63
|
-
"writerOpts": {
|
|
64
|
-
"types": [
|
|
65
|
-
{
|
|
66
|
-
"type": "feat",
|
|
67
|
-
"section": "Features"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
"type": "fix",
|
|
71
|
-
"section": "Bug Fixes"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
"type": "docs",
|
|
75
|
-
"section": "Documentation",
|
|
76
|
-
"hidden": false
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
"type": "deps",
|
|
80
|
-
"section": "Dependency Updates",
|
|
81
|
-
"hidden": false
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"type": "chore",
|
|
85
|
-
"hidden": true
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"type": "style",
|
|
89
|
-
"hidden": true
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"type": "refactor",
|
|
93
|
-
"hidden": true
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
"type": "perf",
|
|
97
|
-
"hidden": true
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
"type": "test",
|
|
101
|
-
"hidden": true
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
],
|
|
107
|
-
[
|
|
108
|
-
"@semantic-release/changelog",
|
|
109
|
-
{
|
|
110
|
-
"changelogFile": "CHANGELOG.md",
|
|
111
|
-
"changelogTitle": "# Changelog"
|
|
112
|
-
}
|
|
113
|
-
],
|
|
114
|
-
[
|
|
115
|
-
"@semantic-release/npm",
|
|
116
|
-
{
|
|
117
|
-
"pkgRoot": "."
|
|
118
|
-
}
|
|
119
|
-
],
|
|
120
|
-
[
|
|
121
|
-
"@semantic-release/git",
|
|
122
|
-
{
|
|
123
|
-
"assets": [
|
|
124
|
-
"dist/**",
|
|
125
|
-
"package.json",
|
|
126
|
-
"CHANGELOG.md"
|
|
127
|
-
],
|
|
128
|
-
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes} [skip ci]"
|
|
129
|
-
}
|
|
130
|
-
],
|
|
131
|
-
"@semantic-release/github"
|
|
132
|
-
]
|
|
133
|
-
}
|
package/.travis.yml
DELETED
package/.vscode/settings.json
DELETED
package/index.test.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import OneSignal from './index';
|
|
2
|
-
|
|
3
|
-
const originalDocument = global.document;
|
|
4
|
-
const documentSpy = vi.spyOn(global, 'document', 'get');
|
|
5
|
-
|
|
6
|
-
const APP_ID = '123456';
|
|
7
|
-
|
|
8
|
-
const init = vi.fn();
|
|
9
|
-
// @ts-expect-error - mocking OneSignal class that comes from the cdn
|
|
10
|
-
window.OneSignal = {
|
|
11
|
-
init,
|
|
12
|
-
};
|
|
13
|
-
window.OneSignalDeferred = [];
|
|
14
|
-
Object.defineProperty(window.OneSignalDeferred, 'push', {
|
|
15
|
-
value: (cb: (OneSignal: typeof window.OneSignal) => void) => {
|
|
16
|
-
cb(window.OneSignal);
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('React OneSignal', () => {
|
|
21
|
-
test('init method', async () => {
|
|
22
|
-
// no document error
|
|
23
|
-
documentSpy.mockReturnValue(undefined);
|
|
24
|
-
await expect(OneSignal.init({ appId: APP_ID })).rejects.toThrow(
|
|
25
|
-
'Document is not defined.',
|
|
26
|
-
);
|
|
27
|
-
documentSpy.mockImplementation(() => originalDocument);
|
|
28
|
-
|
|
29
|
-
// no appId error
|
|
30
|
-
// @ts-expect-error - appId is required but purposely not provided for this test
|
|
31
|
-
await expect(OneSignal.init({})).rejects.toThrow(
|
|
32
|
-
'You need to provide your OneSignal appId.',
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
// init error
|
|
36
|
-
init.mockRejectedValue(new Error('init error'));
|
|
37
|
-
await expect(OneSignal.init({ appId: APP_ID })).rejects.toThrow(
|
|
38
|
-
'init error',
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
// init success
|
|
42
|
-
init.mockResolvedValue(undefined);
|
|
43
|
-
await expect(OneSignal.init({ appId: APP_ID })).resolves.not.toThrow();
|
|
44
|
-
|
|
45
|
-
// already initialized error
|
|
46
|
-
await expect(OneSignal.init({ appId: APP_ID })).rejects.toThrow(
|
|
47
|
-
'OneSignal is already initialized.',
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
});
|