From 775365ad3f6007b36a1db4d11cca35fb92ea364c Mon Sep 17 00:00:00 2001 From: Fadi George Date: Wed, 23 Jul 2025 16:54:54 -0700 Subject: [PATCH 1/4] update packages --- __test__/support/mocks/notifcations.ts | 4 +- package-lock.json | 1039 +++++++---------- package.json | 22 +- src/core/types/api.ts | 9 +- src/page/models/OutcomeRequestData.ts | 2 +- src/page/slidedown/ChannelCaptureContainer.ts | 19 +- .../userModel/FuturePushSubscriptionRecord.ts | 8 +- tsconfig.json | 8 +- 8 files changed, 466 insertions(+), 645 deletions(-) diff --git a/__test__/support/mocks/notifcations.ts b/__test__/support/mocks/notifcations.ts index 30a817dd8..e0128791d 100644 --- a/__test__/support/mocks/notifcations.ts +++ b/__test__/support/mocks/notifcations.ts @@ -1,6 +1,6 @@ -import { OSMinifiedNotificationPayload } from 'src/sw/models/OSMinifiedNotificationPayload'; -import { PartialDeep } from 'type-fest'; import deepmerge from 'deepmerge'; +import type { OSMinifiedNotificationPayload } from 'src/sw/models/OSMinifiedNotificationPayload'; +import type { PartialDeep } from 'type-fest'; export const mockOSMinifiedNotificationPayload = ( data: PartialDeep = {}, diff --git a/package-lock.json b/package-lock.json index 1a7e31649..1c50f82ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,30 +15,30 @@ }, "devDependencies": { "@size-limit/file": "^11.2.0", - "@types/body-parser": "*", + "@types/body-parser": "latest", "@types/express": "^4.17.17", "@types/intl-tel-input": "^18.1.4", "@types/jsdom": "^21.1.7", - "@types/node": "^18.18.0", + "@types/node": "^24.1.0", "@types/uuid": "^10.0.0", "@typescript-eslint/eslint-plugin": "^5.36.1", "@typescript-eslint/parser": "^5.36.1", - "@vitest/coverage-v8": "3.1.4", + "@vitest/coverage-v8": "3.2.4", "deepmerge": "^4.2.2", "eslint": "^8.23.0", "eslint-config-prettier": "9.0.0", "fake-indexeddb": "5.0.2", - "jsdom": "^26.0.0", - "msw": "^2.7.4", - "prettier": "3.0.2", + "jsdom": "^26.1.0", + "msw": "^2.10.4", + "prettier": "3.6.2", "prettylint": "^2.0.0", - "type-fest": "^4.33.0", - "typescript": "^4.9.5", - "vite": "^6.2.0", - "vite-bundle-analyzer": "^0.17.1", - "vite-plugin-mkcert": "^1.17.6", + "type-fest": "^4.41.0", + "typescript": "^5.8.3", + "vite": "^7.0.5", + "vite-bundle-analyzer": "^1.1.0", + "vite-plugin-mkcert": "^1.17.8", "vite-tsconfig-paths": "^5.1.4", - "vitest": "3.1.4" + "vitest": "3.2.4" } }, "node_modules/@ampproject/remapping": { @@ -56,14 +56,14 @@ } }, "node_modules/@asamuzakjp/css-color": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-2.8.3.tgz", - "integrity": "sha512-GIc76d9UI1hCvOATjZPyHFmE5qhRccp3/zGfMPapK3jBi+yocEzp6BBB0UnfRYP9NP4FANqUZYb0hnfs3TM3hw==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-3.2.0.tgz", + "integrity": "sha512-K1A6z8tS3XsmCMM86xoWdn7Fkdn9m6RSVtocUrJYIwZnFVkng/PvkEoWtOWmP+Scc6saYWHWZYbndEEXxl24jw==", "dev": true, "license": "MIT", "dependencies": { - "@csstools/css-calc": "^2.1.1", - "@csstools/css-color-parser": "^3.0.7", + "@csstools/css-calc": "^2.1.3", + "@csstools/css-color-parser": "^3.0.9", "@csstools/css-parser-algorithms": "^3.0.4", "@csstools/css-tokenizer": "^3.0.3", "lru-cache": "^10.4.3" @@ -177,9 +177,9 @@ } }, "node_modules/@csstools/color-helpers": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.0.1.tgz", - "integrity": "sha512-MKtmkA0BX87PKaO1NFRTFH+UnkgnmySQOvNxJubsadusqPEC2aJ9MOQiMceZJJ6oitUl/i0L6u0M1IrmAOmgBA==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.0.2.tgz", + "integrity": "sha512-JqWH1vsgdGcw2RR6VliXXdA0/59LttzlU8UlRT/iUUsEeWfYq8I+K0yhihEUTTHLRm1EXvpsCx3083EU15ecsA==", "dev": true, "funding": [ { @@ -197,9 +197,9 @@ } }, "node_modules/@csstools/css-calc": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-2.1.1.tgz", - "integrity": "sha512-rL7kaUnTkL9K+Cvo2pnCieqNpTKgQzy5f+N+5Iuko9HAoasP+xgprVh7KN/MaJVvVL1l0EzQq2MoqBHKSrDrag==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-2.1.4.tgz", + "integrity": "sha512-3N8oaj+0juUw/1H3YwmDDJXCgTB1gKU6Hc/bB502u9zR0q2vd786XJH9QfrKIEgFlZmhZiq6epXl4rHqhzsIgQ==", "dev": true, "funding": [ { @@ -216,14 +216,14 @@ "node": ">=18" }, "peerDependencies": { - "@csstools/css-parser-algorithms": "^3.0.4", - "@csstools/css-tokenizer": "^3.0.3" + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" } }, "node_modules/@csstools/css-color-parser": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-3.0.7.tgz", - "integrity": "sha512-nkMp2mTICw32uE5NN+EsJ4f5N+IGFeCFu4bGpiKgb2Pq/7J/MpyLBeQ5ry4KKtRFZaYs6sTmcMYrSRIyj5DFKA==", + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-3.0.10.tgz", + "integrity": "sha512-TiJ5Ajr6WRd1r8HSiwJvZBiJOqtH86aHpUjq5aEKWHiII2Qfjqd/HCWKPOW8EP4vcspXbHnXrwIDlu5savQipg==", "dev": true, "funding": [ { @@ -237,21 +237,21 @@ ], "license": "MIT", "dependencies": { - "@csstools/color-helpers": "^5.0.1", - "@csstools/css-calc": "^2.1.1" + "@csstools/color-helpers": "^5.0.2", + "@csstools/css-calc": "^2.1.4" }, "engines": { "node": ">=18" }, "peerDependencies": { - "@csstools/css-parser-algorithms": "^3.0.4", - "@csstools/css-tokenizer": "^3.0.3" + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" } }, "node_modules/@csstools/css-parser-algorithms": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-3.0.4.tgz", - "integrity": "sha512-Up7rBoV77rv29d3uKHUIVubz1BTcgyUK72IvCQAbfbMv584xHcGKCKbWh7i8hPrRJ7qU4Y8IO3IY9m+iTB7P3A==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-3.0.5.tgz", + "integrity": "sha512-DaDeUkXZKjdGhgYaHNJTV9pV7Y9B3b644jCLs9Upc3VeNGg6LWARAT6O+Q+/COo+2gg/bM5rhpMAtf70WqfBdQ==", "dev": true, "funding": [ { @@ -268,13 +268,13 @@ "node": ">=18" }, "peerDependencies": { - "@csstools/css-tokenizer": "^3.0.3" + "@csstools/css-tokenizer": "^3.0.4" } }, "node_modules/@csstools/css-tokenizer": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-3.0.3.tgz", - "integrity": "sha512-UJnjoFsmxfKUdNYdWgOB0mWUypuLvAfQPH1+pyvRJs6euowbFkFC6P13w1l8mJyi3vxYMxc9kld5jZEGRQs6bw==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-3.0.4.tgz", + "integrity": "sha512-Vd/9EVDiu6PPJt9yAh6roZP6El1xHrdvIVGjyBsHR0RYwNHgL7FJPyIIW4fANJNG6FtyZfvlRPpFI4ZM/lubvw==", "dev": true, "funding": [ { @@ -865,14 +865,14 @@ "license": "BSD-3-Clause" }, "node_modules/@inquirer/confirm": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-5.1.6.tgz", - "integrity": "sha512-6ZXYK3M1XmaVBZX6FCfChgtponnL0R6I7k8Nu+kaoNkT828FVZTcca1MqmWQipaW2oNREQl5AaPCUOOCVNdRMw==", + "version": "5.1.14", + "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-5.1.14.tgz", + "integrity": "sha512-5yR4IBfe0kXe59r1YCTG8WXkUbl7Z35HK87Sw+WUyGD8wNUx7JvY7laahzeytyE1oLn74bQnL7hstctQxisQ8Q==", "dev": true, "license": "MIT", "dependencies": { - "@inquirer/core": "^10.1.7", - "@inquirer/type": "^3.0.4" + "@inquirer/core": "^10.1.15", + "@inquirer/type": "^3.0.8" }, "engines": { "node": ">=18" @@ -887,14 +887,14 @@ } }, "node_modules/@inquirer/core": { - "version": "10.1.7", - "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-10.1.7.tgz", - "integrity": "sha512-AA9CQhlrt6ZgiSy6qoAigiA1izOa751ugX6ioSjqgJ+/Gd+tEN/TORk5sUYNjXuHWfW0r1n/a6ak4u/NqHHrtA==", + "version": "10.1.15", + "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-10.1.15.tgz", + "integrity": "sha512-8xrp836RZvKkpNbVvgWUlxjT4CraKk2q+I3Ksy+seI2zkcE+y6wNs1BVhgcv8VyImFecUhdQrYLdW32pAjwBdA==", "dev": true, "license": "MIT", "dependencies": { - "@inquirer/figures": "^1.0.10", - "@inquirer/type": "^3.0.4", + "@inquirer/figures": "^1.0.13", + "@inquirer/type": "^3.0.8", "ansi-escapes": "^4.3.2", "cli-width": "^4.1.0", "mute-stream": "^2.0.0", @@ -914,22 +914,6 @@ } } }, - "node_modules/@inquirer/core/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, "node_modules/@inquirer/core/node_modules/wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", @@ -946,9 +930,9 @@ } }, "node_modules/@inquirer/figures": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-1.0.10.tgz", - "integrity": "sha512-Ey6176gZmeqZuY/W/nZiUyvmb1/qInjcpiZjXWi6nON+nxJpD1bxtSoBxNliGISae32n6OwbY+TSXPZ1CfS4bw==", + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-1.0.13.tgz", + "integrity": "sha512-lGPVU3yO9ZNqA7vTYz26jny41lE7yoQansmqdMLBEfqaGsmdg7V3W9mK9Pvb5IL4EVZ9GnSDGMO/cJXud5dMaw==", "dev": true, "license": "MIT", "engines": { @@ -956,9 +940,9 @@ } }, "node_modules/@inquirer/type": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-3.0.4.tgz", - "integrity": "sha512-2MNFrDY8jkFYc9Il9DgLsHhMzuHnOYM1+CUYVWbzu9oT0hC7V7EcYvdCKeoll/Fcci04A+ERZ9wcc7cQ8lTkIA==", + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-3.0.8.tgz", + "integrity": "sha512-lg9Whz8onIHRthWaN1Q9EGLa/0LFJjyM8mEUbL1eTi6yMGvBf8gvyDLtxSXztQsxMvhxxNpJYrwa1YHdq+w4Jw==", "dev": true, "license": "MIT", "engines": { @@ -1122,9 +1106,9 @@ } }, "node_modules/@mswjs/interceptors": { - "version": "0.37.6", - "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.37.6.tgz", - "integrity": "sha512-wK+5pLK5XFmgtH3aQ2YVvA3HohS3xqV/OxuVOdNx9Wpnz7VE/fnC+e1A7ln6LFYeck7gOJ/dsZV6OLplOtAJ2w==", + "version": "0.39.3", + "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.39.3.tgz", + "integrity": "sha512-9bw/wBL7pblsnOCIqvn1788S9o4h+cC5HWXg0Xhh0dOzsZ53IyfmBM+FYqpDDPbm0xjCqEqvCITloF3Dm4TXRQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1177,173 +1161,6 @@ "node": ">= 8" } }, - "node_modules/@octokit/auth-token": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz", - "integrity": "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/core": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.0.tgz", - "integrity": "sha512-1LFfa/qnMQvEOAdzlQymH0ulepxbxnCYAKJZfMci/5XJyIHWgEYnDmgnKakbTh7CH2tFQ5O60oYDvns4i9RAIg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@octokit/auth-token": "^4.0.0", - "@octokit/graphql": "^7.1.0", - "@octokit/request": "^8.3.1", - "@octokit/request-error": "^5.1.0", - "@octokit/types": "^13.0.0", - "before-after-hook": "^2.2.0", - "universal-user-agent": "^6.0.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/endpoint": { - "version": "9.0.6", - "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.6.tgz", - "integrity": "sha512-H1fNTMA57HbkFESSt3Y9+FBICv+0jFceJFPWDePYlR/iMGrwM5ph+Dd4XRQs+8X+PUFURLQgX9ChPfhJ/1uNQw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@octokit/types": "^13.1.0", - "universal-user-agent": "^6.0.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/graphql": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.1.1.tgz", - "integrity": "sha512-3mkDltSfcDUoa176nlGoA32RGjeWjl3K7F/BwHwRMJUW/IteSa4bnSV8p2ThNkcIcZU2umkZWxwETSSCJf2Q7g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@octokit/request": "^8.4.1", - "@octokit/types": "^13.0.0", - "universal-user-agent": "^6.0.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/openapi-types": { - "version": "23.0.1", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-23.0.1.tgz", - "integrity": "sha512-izFjMJ1sir0jn0ldEKhZ7xegCTj/ObmEDlEfpFrx4k/JyZSMRHbO3/rBwgE7f3m2DHt+RrNGIVw4wSmwnm3t/g==", - "dev": true, - "license": "MIT" - }, - "node_modules/@octokit/plugin-paginate-rest": { - "version": "11.4.4-cjs.2", - "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-11.4.4-cjs.2.tgz", - "integrity": "sha512-2dK6z8fhs8lla5PaOTgqfCGBxgAv/le+EhPs27KklPhm1bKObpu6lXzwfUEQ16ajXzqNrKMujsFyo9K2eaoISw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@octokit/types": "^13.7.0" - }, - "engines": { - "node": ">= 18" - }, - "peerDependencies": { - "@octokit/core": "5" - } - }, - "node_modules/@octokit/plugin-request-log": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-4.0.1.tgz", - "integrity": "sha512-GihNqNpGHorUrO7Qa9JbAl0dbLnqJVrV8OXe2Zm5/Y4wFkZQDfTreBzVmiRfJVfE4mClXdihHnbpyyO9FSX4HA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 18" - }, - "peerDependencies": { - "@octokit/core": "5" - } - }, - "node_modules/@octokit/plugin-rest-endpoint-methods": { - "version": "13.3.2-cjs.1", - "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-13.3.2-cjs.1.tgz", - "integrity": "sha512-VUjIjOOvF2oELQmiFpWA1aOPdawpyaCUqcEBc/UOUnj3Xp6DJGrJ1+bjUIIDzdHjnFNO6q57ODMfdEZnoBkCwQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@octokit/types": "^13.8.0" - }, - "engines": { - "node": ">= 18" - }, - "peerDependencies": { - "@octokit/core": "^5" - } - }, - "node_modules/@octokit/request": { - "version": "8.4.1", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.4.1.tgz", - "integrity": "sha512-qnB2+SY3hkCmBxZsR/MPCybNmbJe4KAlfWErXq+rBKkQJlbjdJeS85VI9r8UqeLYLvnAenU8Q1okM/0MBsAGXw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@octokit/endpoint": "^9.0.6", - "@octokit/request-error": "^5.1.1", - "@octokit/types": "^13.1.0", - "universal-user-agent": "^6.0.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/request-error": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.1.1.tgz", - "integrity": "sha512-v9iyEQJH6ZntoENr9/yXxjuezh4My67CBSu9r6Ve/05Iu5gNgnisNWOsoJHTP6k0Rr0+HQIpnH+kyammu90q/g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@octokit/types": "^13.1.0", - "deprecation": "^2.0.0", - "once": "^1.4.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/rest": { - "version": "20.1.2", - "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-20.1.2.tgz", - "integrity": "sha512-GmYiltypkHHtihFwPRxlaorG5R9VAHuk/vbszVoRTGXnAsY60wYLkh/E2XiFmdZmqrisw+9FaazS1i5SbdWYgA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@octokit/core": "^5.0.2", - "@octokit/plugin-paginate-rest": "11.4.4-cjs.2", - "@octokit/plugin-request-log": "^4.0.0", - "@octokit/plugin-rest-endpoint-methods": "13.3.2-cjs.1" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/types": { - "version": "13.8.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.8.0.tgz", - "integrity": "sha512-x7DjTIbEpEWXK99DMd01QfWy0hd5h4EN+Q7shkdKds3otGQP+oWE/y0A76i1OvH9fygo4ddvNf7ZvF0t78P98A==", - "dev": true, - "license": "MIT", - "dependencies": { - "@octokit/openapi-types": "^23.0.1" - } - }, "node_modules/@open-draft/deferred-promise": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz", @@ -2008,6 +1825,16 @@ "@types/node": "*" } }, + "node_modules/@types/chai": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.2.tgz", + "integrity": "sha512-8kB30R7Hwqf40JPiKhVzodJs2Qc1ZJ5zuT3uzw5Hq/dhNCl3G3l83jfpdI1e20BP348+fV7VIL/+FxaXkqBmWg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*" + } + }, "node_modules/@types/connect": { "version": "3.4.38", "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", @@ -2025,6 +1852,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/eslint": { "version": "8.56.12", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.12.tgz", @@ -2123,13 +1957,13 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "18.19.76", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.76.tgz", - "integrity": "sha512-yvR7Q9LdPz2vGpmpJX5LolrgRdWvB67MJKDPSgIIzpFbaf9a1j/f5DnLp5VDyHGMR0QZHlTr1afsD87QCXFHKw==", + "version": "24.1.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.1.0.tgz", + "integrity": "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~7.8.0" } }, "node_modules/@types/qs": { @@ -2184,9 +2018,9 @@ "license": "MIT" }, "node_modules/@types/statuses": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@types/statuses/-/statuses-2.0.5.tgz", - "integrity": "sha512-jmIUGWrAiwu3dZpxntxieC+1n/5c3mjrImkmOSQ2NC5uP6cYO4aAZDdSmRcI5C1oiTmqlZGHC+/NmJrKogbP5A==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/statuses/-/statuses-2.0.6.tgz", + "integrity": "sha512-xMAgYwceFhRA2zY+XbEA7mxYbA093wdiW8Vu6gZPGWy9cmOyU9XesH1tNcEWsKFd5Vzrqx5T3D38PWx1FIIXkA==", "dev": true, "license": "MIT" }, @@ -2408,15 +2242,16 @@ "license": "ISC" }, "node_modules/@vitest/coverage-v8": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-3.1.4.tgz", - "integrity": "sha512-G4p6OtioySL+hPV7Y6JHlhpsODbJzt1ndwHAFkyk6vVjpK03PFsKnauZIzcd0PrK4zAbc5lc+jeZ+eNGiMA+iw==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-3.2.4.tgz", + "integrity": "sha512-EyF9SXU6kS5Ku/U82E259WSnvg6c8KTjppUncuNdm5QHpe17mwREHnjDzozC8x9MZ0xfBUFSaLkRv4TMA75ALQ==", "dev": true, "license": "MIT", "dependencies": { "@ampproject/remapping": "^2.3.0", "@bcoe/v8-coverage": "^1.0.2", - "debug": "^4.4.0", + "ast-v8-to-istanbul": "^0.3.3", + "debug": "^4.4.1", "istanbul-lib-coverage": "^3.2.2", "istanbul-lib-report": "^3.0.1", "istanbul-lib-source-maps": "^5.0.6", @@ -2431,8 +2266,8 @@ "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "@vitest/browser": "3.1.4", - "vitest": "3.1.4" + "@vitest/browser": "3.2.4", + "vitest": "3.2.4" }, "peerDependenciesMeta": { "@vitest/browser": { @@ -2441,14 +2276,15 @@ } }, "node_modules/@vitest/expect": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.1.4.tgz", - "integrity": "sha512-xkD/ljeliyaClDYqHPNCiJ0plY5YIcM0OlRiZizLhlPmpXWpxnGMyTZXOHFhFeG7w9P5PBeL4IdtJ/HeQwTbQA==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.4.tgz", + "integrity": "sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/spy": "3.1.4", - "@vitest/utils": "3.1.4", + "@types/chai": "^5.2.2", + "@vitest/spy": "3.2.4", + "@vitest/utils": "3.2.4", "chai": "^5.2.0", "tinyrainbow": "^2.0.0" }, @@ -2457,13 +2293,13 @@ } }, "node_modules/@vitest/mocker": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.1.4.tgz", - "integrity": "sha512-8IJ3CvwtSw/EFXqWFL8aCMu+YyYXG2WUSrQbViOZkWTKTVicVwZ/YiEZDSqD00kX+v/+W+OnxhNWoeVKorHygA==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.2.4.tgz", + "integrity": "sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/spy": "3.1.4", + "@vitest/spy": "3.2.4", "estree-walker": "^3.0.3", "magic-string": "^0.30.17" }, @@ -2472,7 +2308,7 @@ }, "peerDependencies": { "msw": "^2.4.9", - "vite": "^5.0.0 || ^6.0.0" + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" }, "peerDependenciesMeta": { "msw": { @@ -2484,9 +2320,9 @@ } }, "node_modules/@vitest/pretty-format": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.1.4.tgz", - "integrity": "sha512-cqv9H9GvAEoTaoq+cYqUTCGscUjKqlJZC7PRwY5FMySVj5J+xOm1KQcCiYHJOEzOKRUhLH4R2pTwvFlWCEScsg==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.4.tgz", + "integrity": "sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==", "dev": true, "license": "MIT", "dependencies": { @@ -2497,27 +2333,28 @@ } }, "node_modules/@vitest/runner": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.1.4.tgz", - "integrity": "sha512-djTeF1/vt985I/wpKVFBMWUlk/I7mb5hmD5oP8K9ACRmVXgKTae3TUOtXAEBfslNKPzUQvnKhNd34nnRSYgLNQ==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.2.4.tgz", + "integrity": "sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/utils": "3.1.4", - "pathe": "^2.0.3" + "@vitest/utils": "3.2.4", + "pathe": "^2.0.3", + "strip-literal": "^3.0.0" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/snapshot": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.1.4.tgz", - "integrity": "sha512-JPHf68DvuO7vilmvwdPr9TS0SuuIzHvxeaCkxYcCD4jTk67XwL45ZhEHFKIuCm8CYstgI6LZ4XbwD6ANrwMpFg==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.2.4.tgz", + "integrity": "sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "3.1.4", + "@vitest/pretty-format": "3.2.4", "magic-string": "^0.30.17", "pathe": "^2.0.3" }, @@ -2526,27 +2363,27 @@ } }, "node_modules/@vitest/spy": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.1.4.tgz", - "integrity": "sha512-Xg1bXhu+vtPXIodYN369M86K8shGLouNjoVI78g8iAq2rFoHFdajNvJJ5A/9bPMFcfQqdaCpOgWKEoMQg/s0Yg==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.2.4.tgz", + "integrity": "sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==", "dev": true, "license": "MIT", "dependencies": { - "tinyspy": "^3.0.2" + "tinyspy": "^4.0.3" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/utils": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.1.4.tgz", - "integrity": "sha512-yriMuO1cfFhmiGc8ataN51+9ooHRuURdfAZfwFd3usWynjzpLslZdYnRegTv32qdgtJTsj15FoeZe2g15fY1gg==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.2.4.tgz", + "integrity": "sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "3.1.4", - "loupe": "^3.1.3", + "@vitest/pretty-format": "3.2.4", + "loupe": "^3.1.4", "tinyrainbow": "^2.0.0" }, "funding": { @@ -2577,9 +2414,9 @@ } }, "node_modules/agent-base": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", - "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", "dev": true, "license": "MIT", "engines": { @@ -2642,6 +2479,22 @@ "node": ">=8" } }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", @@ -2662,6 +2515,18 @@ "node": ">=12" } }, + "node_modules/ast-v8-to-istanbul": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-0.3.3.tgz", + "integrity": "sha512-MuXMrSLVVoA6sYN/6Hke18vMzrT4TZNbZIj/hvh0fnYFpO+/kFXcLIaiPwXXWaQUPg4yJD8fj+lfJ7/1EBconw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.25", + "estree-walker": "^3.0.3", + "js-tokens": "^9.0.1" + } + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -2688,13 +2553,6 @@ "dev": true, "license": "MIT" }, - "node_modules/before-after-hook": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", - "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==", - "dev": true, - "license": "Apache-2.0" - }, "node_modules/bowser": { "version": "1.7.2", "resolved": "git+ssh://git@github.com/OneSignal/bowser.git#acdbf27b721d27e7abdb559be1e20773f21d1da5", @@ -2779,9 +2637,9 @@ } }, "node_modules/chai": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-5.2.0.tgz", - "integrity": "sha512-mCuXncKXk5iCLhfhwTc0izo0gtEmpz5CtG2y8GiOINBlMVS6v8TMRc5TaLWKS6692m9+dVVfzgeVxR5UxWHTYw==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.2.1.tgz", + "integrity": "sha512-5nFxhUrX0PqtyogoYOA8IPswy5sZFTOsBFl/9bNsmDLgsxYTzSZQJDPppDnZPTQbzSEm0hqGjWPzRemQCYbD6A==", "dev": true, "license": "MIT", "dependencies": { @@ -2792,7 +2650,7 @@ "pathval": "^2.0.0" }, "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/chalk": { @@ -2812,22 +2670,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/chalk/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, "node_modules/check-error": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", @@ -2865,6 +2707,39 @@ "node": ">= 12" } }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/cliui/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -2931,13 +2806,13 @@ } }, "node_modules/cssstyle": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.2.1.tgz", - "integrity": "sha512-9+vem03dMXG7gDmZ62uqmRiMRNtinIZ9ZyuF6BdxzfOD+FdN5hretzynkn0ReS2DO2GSw76RWHs0UmJPI2zUjw==", + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.6.0.tgz", + "integrity": "sha512-2z+rWdzbbSZv6/rhtvzvqeZQHrBaqgogqt85sqFNbabZOuFbCVFb8kPeEtZjiKkbrm395irpNKiYeFeLiQnFPg==", "dev": true, "license": "MIT", "dependencies": { - "@asamuzakjp/css-color": "^2.8.2", + "@asamuzakjp/css-color": "^3.2.0", "rrweb-cssom": "^0.8.0" }, "engines": { @@ -2950,14 +2825,18 @@ "integrity": "sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==", "dev": true, "license": "MIT", + "dependencies": { + "whatwg-mimetype": "^4.0.0", + "whatwg-url": "^14.0.0" + }, "engines": { "node": ">=18" } }, "node_modules/debug": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", "dev": true, "license": "MIT", "dependencies": { @@ -2973,9 +2852,9 @@ } }, "node_modules/decimal.js": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.5.0.tgz", - "integrity": "sha512-8vDa8Qxvr/+d94hSh5P3IJwI5t8/c0KsMp+g8bNw9cY2icONa5aPfvKeieW1WlG0WQYwwhJ7mjui2xtiePQSXw==", + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", "dev": true, "license": "MIT" }, @@ -3016,13 +2895,6 @@ "node": ">=0.4.0" } }, - "node_modules/deprecation": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", - "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==", - "dev": true, - "license": "ISC" - }, "node_modules/detect-libc": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", @@ -3508,9 +3380,9 @@ } }, "node_modules/expect-type": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.2.1.tgz", - "integrity": "sha512-/kP8CAwxzLVEeFrMm4kMmy4CCDlpipyA7MYLVrdJIkV0fYF0UaigQHRsxHiuY/GEea+bh4KSv3TIlgr+2UL6bw==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.2.2.tgz", + "integrity": "sha512-JhFGDVJ7tmDJItKhYgJCGLOWjuK9vPxiXoUFLwLDc99NlmklilbiQJwoctZtt13+xMw91MCk/REan6MWHqDjyA==", "dev": true, "license": "Apache-2.0", "engines": { @@ -3921,9 +3793,9 @@ "license": "MIT" }, "node_modules/graphql": { - "version": "16.10.0", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.10.0.tgz", - "integrity": "sha512-AjqGKbDGUFRKIRCP9tCKiIGHyriz2oHEbPIbEtcSLSs4YjReZOIPQQWek4+6hjw62H9QShXHyaGivGiYVLeYFQ==", + "version": "16.11.0", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.11.0.tgz", + "integrity": "sha512-mS1lbMsxgQj6hge1XZ6p7GPhbrtFwUFYi3wRzXAC/FmYnyXMTvvI3td3rjmQ2u8ewXueaSvRPWaEcgVVOT9Jnw==", "dev": true, "license": "MIT", "engines": { @@ -4037,6 +3909,19 @@ "node": ">= 14" } }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -4263,17 +4148,23 @@ "jiti": "lib/jiti-cli.mjs" } }, + "node_modules/js-tokens": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", + "integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==", + "dev": true, + "license": "MIT" + }, "node_modules/jsdom": { - "version": "26.0.0", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-26.0.0.tgz", - "integrity": "sha512-BZYDGVAIriBWTpIxYzrXjv3E/4u8+/pSG5bQdIYCbNCGOvsPkDQfTVLAIXAf9ETdCpduCVTkDe2NNZ8NIwUVzw==", + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-26.1.0.tgz", + "integrity": "sha512-Cvc9WUhxSMEo4McES3P7oK3QaXldCfNWp7pl2NNeiIFlCoLr3kfq9kb1fxftiwk1FLV7CvpvDfonxtzUDeSOPg==", "dev": true, "license": "MIT", "dependencies": { "cssstyle": "^4.2.1", "data-urls": "^5.0.0", - "decimal.js": "^10.4.3", - "form-data": "^4.0.1", + "decimal.js": "^10.5.0", "html-encoding-sniffer": "^4.0.0", "http-proxy-agent": "^7.0.2", "https-proxy-agent": "^7.0.6", @@ -4283,12 +4174,12 @@ "rrweb-cssom": "^0.8.0", "saxes": "^6.0.0", "symbol-tree": "^3.2.4", - "tough-cookie": "^5.0.0", + "tough-cookie": "^5.1.1", "w3c-xmlserializer": "^5.0.0", "webidl-conversions": "^7.0.0", "whatwg-encoding": "^3.1.1", "whatwg-mimetype": "^4.0.0", - "whatwg-url": "^14.1.0", + "whatwg-url": "^14.1.1", "ws": "^8.18.0", "xml-name-validator": "^5.0.0" }, @@ -4304,28 +4195,6 @@ } } }, - "node_modules/jsdom/node_modules/ws": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", - "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", @@ -4458,9 +4327,9 @@ } }, "node_modules/loupe": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.3.tgz", - "integrity": "sha512-kkIp7XSkP78ZxJEsSxW3712C6teJVoeHHwgo9zJ380de7IYyJ2ISlxojcH2pC5OFLewESmnRi/+XCDIEEVyoug==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.0.tgz", + "integrity": "sha512-2NCfZcT5VGVNX9mSZIxLRkEAegDGBpuQZBy13desuHeVORmBDyAET4TkJr4SjqQy3A8JDofMN6LpkK8Xcm/dlw==", "dev": true, "license": "MIT" }, @@ -4610,9 +4479,9 @@ "license": "MIT" }, "node_modules/msw": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/msw/-/msw-2.7.4.tgz", - "integrity": "sha512-A2kuMopOjAjNEYkn0AnB1uj+x7oBjLIunFk7Ud4icEnVWFf6iBekn8oXW4zIwcpfEdWP9sLqyVaHVzneWoGEww==", + "version": "2.10.4", + "resolved": "https://registry.npmjs.org/msw/-/msw-2.10.4.tgz", + "integrity": "sha512-6R1or/qyele7q3RyPwNuvc0IxO8L8/Aim6Sz5ncXEgcWUNxSKE+udriTOWHtpMwmfkLYlacA2y7TIx4cL5lgHA==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -4621,7 +4490,7 @@ "@bundled-es-modules/statuses": "^1.0.1", "@bundled-es-modules/tough-cookie": "^0.1.6", "@inquirer/confirm": "^5.0.0", - "@mswjs/interceptors": "^0.37.0", + "@mswjs/interceptors": "^0.39.1", "@open-draft/deferred-promise": "^2.2.0", "@open-draft/until": "^2.1.0", "@types/cookie": "^0.6.0", @@ -4654,84 +4523,6 @@ } } }, - "node_modules/msw/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/msw/node_modules/cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/msw/node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/msw/node_modules/yargs": { - "version": "17.7.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", - "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/msw/node_modules/yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, "node_modules/mute-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-2.0.0.tgz", @@ -4743,9 +4534,9 @@ } }, "node_modules/nanoid": { - "version": "3.3.8", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", - "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", "dev": true, "funding": [ { @@ -4796,9 +4587,9 @@ "peer": true }, "node_modules/nwsapi": { - "version": "2.2.16", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.16.tgz", - "integrity": "sha512-F1I/bimDpj3ncaNDhfyMWuFqmQDBwDB0Fogc2qpL3BWvkQteFD/8BzWuIRl83rq0DXfm8SGt/HFhLXZyljTXcQ==", + "version": "2.2.20", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.20.tgz", + "integrity": "sha512-/ieB+mDe4MrrKMT8z+mQL8klXydZWGR5Dowt4RAGKbJ3kIGEx3X4ljUo+6V73IXtUPWgfOlU5B9MlGxFO5T+cA==", "dev": true, "license": "MIT" }, @@ -4974,9 +4765,9 @@ "license": "MIT" }, "node_modules/pathval": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", - "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz", + "integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==", "dev": true, "license": "MIT", "engines": { @@ -5020,9 +4811,9 @@ } }, "node_modules/postcss": { - "version": "8.5.3", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz", - "integrity": "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==", + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", "dev": true, "funding": [ { @@ -5040,7 +4831,7 @@ ], "license": "MIT", "dependencies": { - "nanoid": "^3.3.8", + "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" }, @@ -5059,9 +4850,9 @@ } }, "node_modules/prettier": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.2.tgz", - "integrity": "sha512-o2YR9qtniXvwEZlOKbveKfDQVyqxbEIWn48Z8m3ZJjBjcCmUy3xZGIv+7AkaeuaTr6yPXJjwv07ZWlsWbEy1rQ==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", "dev": true, "license": "MIT", "bin": { @@ -5497,9 +5288,9 @@ "license": "MIT" }, "node_modules/statuses": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", - "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", "dev": true, "license": "MIT", "engines": { @@ -5591,6 +5382,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/strip-literal": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.0.0.tgz", + "integrity": "sha512-TcccoMhJOM3OebGhSBEmp3UZ2SfDMZUEBdRA/9ynfLi8yYajyWX3JiXArcJt4Umh4vISpspkQIY8ZZoCqjbviA==", + "dev": true, + "license": "MIT", + "dependencies": { + "js-tokens": "^9.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -5718,9 +5522,9 @@ "license": "MIT" }, "node_modules/tinyglobby": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.13.tgz", - "integrity": "sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw==", + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz", + "integrity": "sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==", "dev": true, "license": "MIT", "dependencies": { @@ -5763,9 +5567,9 @@ } }, "node_modules/tinypool": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.0.2.tgz", - "integrity": "sha512-al6n+QEANGFOMf/dmUMsuS5/r9B06uwlyNjZZql/zv8J7ybHCgoihBNORZCY2mzUuAnomQa2JdhyHKzZxPCrFA==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz", + "integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==", "dev": true, "license": "MIT", "engines": { @@ -5783,9 +5587,9 @@ } }, "node_modules/tinyspy": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz", - "integrity": "sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-4.0.3.tgz", + "integrity": "sha512-t2T/WLB2WRgZ9EpE4jgPJ9w+i66UZfDc8wHh0xrwiRNN+UwH98GIJkTeZqX9rg0i0ptwzqW+uYeIF0T4F8LR7A==", "dev": true, "license": "MIT", "engines": { @@ -5793,22 +5597,22 @@ } }, "node_modules/tldts": { - "version": "6.1.77", - "resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.77.tgz", - "integrity": "sha512-lBpoWgy+kYmuXWQ83+R7LlJCnsd9YW8DGpZSHhrMl4b8Ly/1vzOie3OdtmUJDkKxcgRGOehDu5btKkty+JEe+g==", + "version": "6.1.86", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.86.tgz", + "integrity": "sha512-WMi/OQ2axVTf/ykqCQgXiIct+mSQDFdH2fkwhPwgEwvJ1kSzZRiinb0zF2Xb8u4+OqPChmyI6MEu4EezNJz+FQ==", "dev": true, "license": "MIT", "dependencies": { - "tldts-core": "^6.1.77" + "tldts-core": "^6.1.86" }, "bin": { "tldts": "bin/cli.js" } }, "node_modules/tldts-core": { - "version": "6.1.77", - "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.77.tgz", - "integrity": "sha512-bCaqm24FPk8OgBkM0u/SrEWJgHnhBWYqeBo6yUmcZJDCHt/IfyWBb+14CXdGi4RInMv4v7eUAin15W0DoA+Ytg==", + "version": "6.1.86", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.86.tgz", + "integrity": "sha512-Je6p7pkk+KMzMv2XXKmAE3McmolOQFdxkKw0R8EYNr7sELW46JqnNeTX8ybPiQgvg1ymCoF8LXs5fzFaZvJPTA==", "dev": true, "license": "MIT" }, @@ -5826,9 +5630,9 @@ } }, "node_modules/tough-cookie": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-5.1.1.tgz", - "integrity": "sha512-Ek7HndSVkp10hmHP9V4qZO1u+pn1RU5sI0Fw+jCU3lyvuMZcgqsNgc6CmJJZyByK4Vm/qotGRJlfgAX8q+4JiA==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-5.1.2.tgz", + "integrity": "sha512-FVDYdxtnj0G6Qm/DhNPSb8Ju59ULcup3tuJxkFb5K8Bv2pUXILbf0xZWU8PX8Ov19OXljbUyveOFwRMwkXzO+A==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -5839,9 +5643,9 @@ } }, "node_modules/tr46": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.0.0.tgz", - "integrity": "sha512-tk2G5R2KRwBd+ZN0zaEXpmzdKyOYksXwywulIX95MBODjSzMIuQnQ3m8JxgbhnL1LeVo7lqQKsYa1O3Htl7K5g==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz", + "integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==", "dev": true, "license": "MIT", "dependencies": { @@ -5888,9 +5692,9 @@ } }, "node_modules/type-fest": { - "version": "4.34.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.34.1.tgz", - "integrity": "sha512-6kSc32kT0rbwxD6QL1CYe8IqdzN/J/ILMrNK+HMQCKH3insCDRY/3ITb0vcBss0a3t72fzh2YSzj8ko1HgwT3g==", + "version": "4.41.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz", + "integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==", "dev": true, "license": "(MIT OR CC0-1.0)", "engines": { @@ -5901,9 +5705,9 @@ } }, "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "dev": true, "license": "Apache-2.0", "bin": { @@ -5911,23 +5715,16 @@ "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz", + "integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==", "dev": true, "license": "MIT" }, - "node_modules/universal-user-agent": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz", - "integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==", - "dev": true, - "license": "ISC" - }, "node_modules/universalify": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", @@ -5973,24 +5770,24 @@ } }, "node_modules/vite": { - "version": "6.3.4", - "resolved": "https://registry.npmjs.org/vite/-/vite-6.3.4.tgz", - "integrity": "sha512-BiReIiMS2fyFqbqNT/Qqt4CVITDU9M9vE+DKcVAsB+ZV0wvTKd+3hMbkpxz1b+NmEDMegpVbisKiAZOnvO92Sw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.0.5.tgz", + "integrity": "sha512-1mncVwJxy2C9ThLwz0+2GKZyEXuC3MyWtAAlNftlZZXZDP3AJt5FmwcMit/IGGaNZ8ZOB2BNO/HFUB+CpN0NQw==", "dev": true, "license": "MIT", "dependencies": { "esbuild": "^0.25.0", - "fdir": "^6.4.4", + "fdir": "^6.4.6", "picomatch": "^4.0.2", - "postcss": "^8.5.3", - "rollup": "^4.34.9", - "tinyglobby": "^0.2.13" + "postcss": "^8.5.6", + "rollup": "^4.40.0", + "tinyglobby": "^0.2.14" }, "bin": { "vite": "bin/vite.js" }, "engines": { - "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + "node": "^20.19.0 || >=22.12.0" }, "funding": { "url": "https://github.com/vitejs/vite?sponsor=1" @@ -5999,14 +5796,14 @@ "fsevents": "~2.3.3" }, "peerDependencies": { - "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", - "less": "*", + "less": "^4.0.0", "lightningcss": "^1.21.0", - "sass": "*", - "sass-embedded": "*", - "stylus": "*", - "sugarss": "*", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" @@ -6048,9 +5845,9 @@ } }, "node_modules/vite-bundle-analyzer": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/vite-bundle-analyzer/-/vite-bundle-analyzer-0.17.1.tgz", - "integrity": "sha512-ubjLhkuRgOSBNck+6xBbQmjmh8SeLTG4alEM5PX2TNzyGhKLwWlyCz1YG0an3RQnscbhVzSb6kYteoHXhP///A==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/vite-bundle-analyzer/-/vite-bundle-analyzer-1.1.0.tgz", + "integrity": "sha512-f/9m+6S5yPOHf/QS00rLOkyQ0icZeF67roM3O5LZZMPTOZFU1bHJTptNHCKMJc2yxXzj0Hunwcetrc+vM2LEQQ==", "dev": true, "license": "MIT", "bin": { @@ -6058,17 +5855,17 @@ } }, "node_modules/vite-node": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.1.4.tgz", - "integrity": "sha512-6enNwYnpyDo4hEgytbmc6mYWHXDHYEn0D1/rw4Q+tnHUGtKTJsn8T1YkX6Q18wI5LCrS8CTYlBaiCqxOy2kvUA==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.2.4.tgz", + "integrity": "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==", "dev": true, "license": "MIT", "dependencies": { "cac": "^6.7.14", - "debug": "^4.4.0", + "debug": "^4.4.1", "es-module-lexer": "^1.7.0", "pathe": "^2.0.3", - "vite": "^5.0.0 || ^6.0.0" + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" }, "bin": { "vite-node": "vite-node.mjs" @@ -6081,16 +5878,15 @@ } }, "node_modules/vite-plugin-mkcert": { - "version": "1.17.6", - "resolved": "https://registry.npmjs.org/vite-plugin-mkcert/-/vite-plugin-mkcert-1.17.6.tgz", - "integrity": "sha512-4JR1RN0HEg/w17eRQJ/Ve2pSa6KCVQcQO6yKtIaKQCFDyd63zGfXHWpygBkvvRSpqa0GcqNKf0fjUJ0HiJQXVQ==", + "version": "1.17.8", + "resolved": "https://registry.npmjs.org/vite-plugin-mkcert/-/vite-plugin-mkcert-1.17.8.tgz", + "integrity": "sha512-S+4tNEyGqdZQ3RLAG54ETeO2qyURHWrVjUWKYikLAbmhh/iJ+36gDEja4OWwFyXNuvyXcZwNt5TZZR9itPeG5Q==", "dev": true, "license": "MIT", "dependencies": { - "@octokit/rest": "^20.1.1", - "axios": "^1.7.4", - "debug": "^4.3.6", - "picocolors": "^1.0.1" + "axios": "^1.8.3", + "debug": "^4.4.0", + "picocolors": "^1.1.1" }, "engines": { "node": ">=v16.7.0" @@ -6140,26 +5936,10 @@ } } }, - "node_modules/vite-tsconfig-paths/node_modules/typescript": { - "version": "5.7.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", - "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", - "dev": true, - "license": "Apache-2.0", - "optional": true, - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, "node_modules/vite/node_modules/fdir": { - "version": "6.4.4", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.4.tgz", - "integrity": "sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg==", + "version": "6.4.6", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz", + "integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==", "dev": true, "license": "MIT", "peerDependencies": { @@ -6172,9 +5952,9 @@ } }, "node_modules/vite/node_modules/picomatch": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", - "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", "engines": { @@ -6185,32 +5965,34 @@ } }, "node_modules/vitest": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-3.1.4.tgz", - "integrity": "sha512-Ta56rT7uWxCSJXlBtKgIlApJnT6e6IGmTYxYcmxjJ4ujuZDI59GUQgVDObXXJujOmPDBYXHK1qmaGtneu6TNIQ==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.4.tgz", + "integrity": "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/expect": "3.1.4", - "@vitest/mocker": "3.1.4", - "@vitest/pretty-format": "^3.1.4", - "@vitest/runner": "3.1.4", - "@vitest/snapshot": "3.1.4", - "@vitest/spy": "3.1.4", - "@vitest/utils": "3.1.4", + "@types/chai": "^5.2.2", + "@vitest/expect": "3.2.4", + "@vitest/mocker": "3.2.4", + "@vitest/pretty-format": "^3.2.4", + "@vitest/runner": "3.2.4", + "@vitest/snapshot": "3.2.4", + "@vitest/spy": "3.2.4", + "@vitest/utils": "3.2.4", "chai": "^5.2.0", - "debug": "^4.4.0", + "debug": "^4.4.1", "expect-type": "^1.2.1", "magic-string": "^0.30.17", "pathe": "^2.0.3", + "picomatch": "^4.0.2", "std-env": "^3.9.0", "tinybench": "^2.9.0", "tinyexec": "^0.3.2", - "tinyglobby": "^0.2.13", - "tinypool": "^1.0.2", + "tinyglobby": "^0.2.14", + "tinypool": "^1.1.1", "tinyrainbow": "^2.0.0", - "vite": "^5.0.0 || ^6.0.0", - "vite-node": "3.1.4", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0", + "vite-node": "3.2.4", "why-is-node-running": "^2.3.0" }, "bin": { @@ -6226,8 +6008,8 @@ "@edge-runtime/vm": "*", "@types/debug": "^4.1.12", "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", - "@vitest/browser": "3.1.4", - "@vitest/ui": "3.1.4", + "@vitest/browser": "3.2.4", + "@vitest/ui": "3.2.4", "happy-dom": "*", "jsdom": "*" }, @@ -6255,6 +6037,19 @@ } } }, + "node_modules/vitest/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/w3c-xmlserializer": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", @@ -6291,19 +6086,6 @@ "node": ">=18" } }, - "node_modules/whatwg-encoding/node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dev": true, - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/whatwg-mimetype": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz", @@ -6315,13 +6097,13 @@ } }, "node_modules/whatwg-url": { - "version": "14.1.1", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.1.1.tgz", - "integrity": "sha512-mDGf9diDad/giZ/Sm9Xi2YcyzaFpbdLpJPr+E9fSkyQ7KpQD4SdFcugkRQYzhmfI4KeV4Qpnn2sKPdo+kmsgRQ==", + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz", + "integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==", "dev": true, "license": "MIT", "dependencies": { - "tr46": "^5.0.0", + "tr46": "^5.1.0", "webidl-conversions": "^7.0.0" }, "engines": { @@ -6408,22 +6190,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, "node_modules/wrap-ansi/node_modules/ansi-regex": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", @@ -6498,6 +6264,28 @@ "dev": true, "license": "ISC" }, + "node_modules/ws": { + "version": "8.18.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", + "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/xml-name-validator": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", @@ -6525,6 +6313,35 @@ "node": ">=10" } }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 397b825f8..acf2328ad 100644 --- a/package.json +++ b/package.json @@ -41,26 +41,26 @@ "@types/express": "^4.17.17", "@types/intl-tel-input": "^18.1.4", "@types/jsdom": "^21.1.7", - "@types/node": "^18.18.0", + "@types/node": "^24.1.0", "@types/uuid": "^10.0.0", "@typescript-eslint/eslint-plugin": "^5.36.1", "@typescript-eslint/parser": "^5.36.1", - "@vitest/coverage-v8": "3.1.4", + "@vitest/coverage-v8": "3.2.4", "deepmerge": "^4.2.2", "eslint": "^8.23.0", "eslint-config-prettier": "9.0.0", "fake-indexeddb": "5.0.2", - "jsdom": "^26.0.0", - "msw": "^2.7.4", - "prettier": "3.0.2", + "jsdom": "^26.1.0", + "msw": "^2.10.4", + "prettier": "3.6.2", "prettylint": "^2.0.0", - "type-fest": "^4.33.0", - "typescript": "^4.9.5", - "vite": "^6.2.0", - "vite-bundle-analyzer": "^0.17.1", - "vite-plugin-mkcert": "^1.17.6", + "type-fest": "^4.41.0", + "typescript": "^5.8.3", + "vite": "^7.0.5", + "vite-bundle-analyzer": "^1.1.0", + "vite-plugin-mkcert": "^1.17.8", "vite-tsconfig-paths": "^5.1.4", - "vitest": "3.1.4" + "vitest": "3.2.4" }, "size-limit": [ { diff --git a/src/core/types/api.ts b/src/core/types/api.ts index 59344e0b6..8520c1f54 100644 --- a/src/core/types/api.ts +++ b/src/core/types/api.ts @@ -1,7 +1,10 @@ -import { SetRequired } from 'type-fest'; +import type { SetRequired } from 'type-fest'; -import { APIHeaders } from '../../shared/models/APIHeaders'; -import { NotificationTypeValue, SubscriptionTypeValue } from './subscription'; +import type { APIHeaders } from 'src/shared/models/APIHeaders'; +import type { + NotificationTypeValue, + SubscriptionTypeValue, +} from './subscription'; export interface RequestMetadata { appId: string; diff --git a/src/page/models/OutcomeRequestData.ts b/src/page/models/OutcomeRequestData.ts index 9b71cdf2e..9b7fb4aa2 100644 --- a/src/page/models/OutcomeRequestData.ts +++ b/src/page/models/OutcomeRequestData.ts @@ -1,4 +1,4 @@ -import { SubscriptionModel } from '../../core/models/SubscriptionModels'; +import type { SubscriptionModel } from 'src/core/models/SubscriptionModel'; export interface OutcomeRequestData { app_id: string; diff --git a/src/page/slidedown/ChannelCaptureContainer.ts b/src/page/slidedown/ChannelCaptureContainer.ts index 8e471b4d9..664d5b421 100644 --- a/src/page/slidedown/ChannelCaptureContainer.ts +++ b/src/page/slidedown/ChannelCaptureContainer.ts @@ -1,24 +1,23 @@ +import Log from '../../shared/libraries/Log'; import { - addCssClass, - getDomElementOrStub, - removeCssClass, -} from '../../shared/utils/utils'; + type SlidedownPromptOptions, + DelayedPromptType, +} from '../../shared/models/Prompts'; import { CHANNEL_CAPTURE_CONTAINER_CSS_CLASSES, CHANNEL_CAPTURE_CONTAINER_CSS_IDS, DANGER_ICON, SLIDEDOWN_CSS_IDS, } from '../../shared/slidedown/constants'; +import { + addCssClass, + getDomElementOrStub, + removeCssClass, +} from '../../shared/utils/utils'; import { ItiScriptURLHashes, ItiScriptURLs, } from './InternationalTelephoneInput'; -import {} from 'intl-tel-input'; // typings -import Log from '../../shared/libraries/Log'; -import { - SlidedownPromptOptions, - DelayedPromptType, -} from '../../shared/models/Prompts'; interface TypeSpecificVariablePayload { message: string; diff --git a/src/page/userModel/FuturePushSubscriptionRecord.ts b/src/page/userModel/FuturePushSubscriptionRecord.ts index 04ee1ec00..b44bbce49 100644 --- a/src/page/userModel/FuturePushSubscriptionRecord.ts +++ b/src/page/userModel/FuturePushSubscriptionRecord.ts @@ -1,8 +1,10 @@ +import type { + NotificationTypeValue, + SubscriptionTypeValue, +} from 'src/core/types/subscription'; import { NotificationType, - NotificationTypeValue, SubscriptionType, - SubscriptionTypeValue, } from 'src/core/types/subscription'; import { RawPushSubscription } from 'src/shared/models/RawPushSubscription'; import { VERSION } from 'src/shared/utils/EnvVariables'; @@ -10,7 +12,7 @@ import Environment from '../../shared/helpers/Environment'; import { DeliveryPlatformKind } from '../../shared/models/DeliveryPlatformKind'; import OneSignalUtils from '../../shared/utils/OneSignalUtils'; import { EnvironmentInfoHelper } from '../helpers/EnvironmentInfoHelper'; -import { Serializable } from '../models/Serializable'; +import type { Serializable } from '../models/Serializable'; export default class FuturePushSubscriptionRecord implements Serializable { readonly type: SubscriptionTypeValue; diff --git a/tsconfig.json b/tsconfig.json index 28923f2a6..c9ee52d1e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,23 +1,23 @@ { "compilerOptions": { - "target": "ES2020", + "target": "ES2022", "useDefineForClassFields": true, - "lib": ["ESNext", "DOM", "DOM.Iterable", "WebWorker"], "module": "ESNext", + "lib": ["ES2022", "DOM", "DOM.Iterable"], "skipLibCheck": true, /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, - "isolatedModules": true, + "verbatimModuleSyntax": true, "moduleDetection": "force", "noEmit": true, - "jsx": "react-jsx", /* Linting */ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, + "erasableSyntaxOnly": true, "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true, From 451939603f1fb8c5b8f0cf8b52a70ee936ab44c7 Mon Sep 17 00:00:00 2001 From: Fadi George Date: Wed, 23 Jul 2025 17:11:08 -0700 Subject: [PATCH 2/4] fix import types usage --- .gitignore | 1 + .vscode/settings.json | 6 ++ package-lock.json | 8 +++ package.json | 5 +- src/core/CoreModuleDirector.ts | 7 +- .../executors/IdentityOperationExecutor.ts | 7 +- .../executors/LoginUserOperationExecutor.ts | 29 ++++++--- .../executors/RefreshUserOperationExecutor.ts | 26 ++++++-- .../SubscriptionOperationExecutor.ts | 23 +++++-- .../executors/UpdateUserOperationExecutor.ts | 24 +++++-- src/core/listeners/ModelStoreListener.ts | 4 +- .../listeners/SingletonModelStoreListener.ts | 8 +-- .../SubscriptionModelStoreListener.ts | 7 +- src/core/modelRepo/ModelStore.ts | 13 ++-- src/core/modelRepo/RebuildUserService.ts | 18 +++-- src/core/modelStores/SimpleModelStore.ts | 2 +- src/core/modelStores/SingletonModelStore.ts | 8 +-- .../modelStores/SubscriptionModelStore.ts | 2 +- src/core/models/Model.ts | 2 +- src/core/models/PropertiesModel.ts | 2 +- src/core/models/SubscriptionModel.ts | 6 +- src/core/operationRepo/OperationRepo.ts | 15 +++-- .../BaseFullSubscriptionOperation.ts | 6 +- .../operations/CreateSubscriptionOperation.ts | 2 +- src/core/operations/DeleteAliasOperation.ts | 2 +- .../operations/DeleteSubscriptionOperation.ts | 2 +- src/core/operations/ExecutionResponse.ts | 4 +- src/core/operations/LoginUserOperation.ts | 2 +- src/core/operations/RefreshUserOperation.ts | 2 +- .../TransferSubscriptionOperation.ts | 2 +- .../operations/UpdateSubscriptionOperation.ts | 2 +- src/core/requestService/RequestService.ts | 20 +++--- src/entries/pageSdkInit.ts | 2 +- src/onesignal/NotificationsNamespace.ts | 10 +-- src/onesignal/OneSignal.ts | 10 +-- src/onesignal/PushSubscriptionNamespace.ts | 2 +- src/onesignal/SlidedownNamespace.ts | 4 +- src/onesignal/User.ts | 2 +- src/onesignal/UserNamespace.ts | 2 +- src/page/bell/Bell.ts | 55 +++++++--------- src/page/bell/Dialog.ts | 5 +- src/page/bell/Launcher.ts | 20 +++--- src/page/helpers/EnvironmentInfoHelper.ts | 2 +- src/page/managers/ConfigManager.ts | 4 +- src/page/managers/PromptsManager.ts | 32 ++++----- .../slidedownManager/SlidedownManager.ts | 20 ++++-- src/page/managers/tagManager/TagManager.ts | 16 +++-- src/page/managers/tagManager/types.ts | 7 +- src/page/models/Context.ts | 12 ++-- src/page/models/NotificationEventTypeMap.ts | 8 +-- src/page/models/NotificationIcons.ts | 8 +-- src/page/models/OutcomeRequestData.ts | 7 +- src/page/models/SubscriptionChangeEvent.ts | 10 ++- src/page/slidedown/Slidedown.ts | 49 +++++++------- src/page/slidedown/SlidedownElement.ts | 6 +- src/page/slidedown/TaggingContainer.ts | 22 +++---- src/page/utils/ProcessOneSignalPushCalls.ts | 6 +- src/page/utils/ReplayCallsOnOneSignal.ts | 2 +- src/shared/api/OneSignalApi.ts | 8 +-- src/shared/api/OneSignalApiBase.ts | 4 +- src/shared/api/OneSignalApiSW.ts | 11 ++-- src/shared/api/OneSignalApiShared.ts | 2 +- src/shared/config/constants.ts | 5 +- src/shared/helpers/ConfigHelper.ts | 37 ++++++----- src/shared/helpers/ContextHelper.ts | 6 +- src/shared/helpers/ConverterHelper.ts | 9 ++- src/shared/helpers/EventHelper.ts | 30 +++++---- src/shared/helpers/EventProducer.ts | 2 +- src/shared/helpers/InitHelper.ts | 37 ++++++----- src/shared/helpers/MainHelper.ts | 31 +++++---- .../OSNotificationDatabaseSerializer.ts | 8 +-- src/shared/helpers/OutcomesHelper.ts | 16 ++--- src/shared/helpers/PromptsHelper.ts | 14 ++-- src/shared/helpers/ServiceWorkerHelper.ts | 29 +++++---- src/shared/helpers/SubscriptionHelper.ts | 4 +- src/shared/libraries/WorkerMessenger.ts | 61 ++++++++--------- src/shared/managers/CustomLinkManager.ts | 4 +- src/shared/managers/ServiceWorkerManager.ts | 16 ++--- .../managers/SubscriptionManager.test.ts | 2 +- src/shared/managers/SubscriptionManager.ts | 12 ++-- src/shared/managers/UpdateManager.ts | 8 +-- .../managers/sessionManager/SessionManager.ts | 13 ++-- src/shared/managers/sessionManager/types.ts | 6 +- src/shared/models/APIHeaders.ts | 4 +- src/shared/models/Action.ts | 3 - src/shared/models/AppConfig.ts | 65 ++++++++++--------- src/shared/models/AppState.ts | 2 +- src/shared/models/ContextSW.ts | 12 ++-- src/shared/models/NotificationEvent.ts | 2 +- src/shared/models/OSNotification.ts | 6 ++ src/shared/models/OutcomeProps.ts | 6 +- src/shared/models/Outcomes.ts | 17 +++-- src/shared/models/Prompts.ts | 23 ++++--- src/shared/models/RawPushSubscription.ts | 6 +- src/shared/models/Session.ts | 40 +++++++----- src/shared/models/Subscription.ts | 2 +- src/shared/services/Database.ts | 47 +++++++------- src/shared/utils/TagUtils.ts | 4 +- src/sw/libraries/Log.ts | 2 +- .../managers/sessionManager/SessionManager.ts | 4 +- .../models/OSMinifiedNotificationPayload.ts | 4 +- .../models/OSNotificationButtonsConverter.ts | 5 +- src/sw/serviceWorker/ServiceWorker.test.ts | 17 +++-- src/sw/serviceWorker/ServiceWorker.ts | 33 +++++----- src/sw/webhooks/OSWebhookSender.ts | 2 +- .../OSWebhookNotificationEventSender.ts | 15 +++-- .../OSWebhookPayloadNotificationClick.ts | 4 +- .../OSWebhookPayloadNotificationDismiss.ts | 4 +- ...OSWebhookPayloadNotificationWillDisplay.ts | 4 +- tsconfig.json | 2 +- 110 files changed, 731 insertions(+), 569 deletions(-) create mode 100644 .vscode/settings.json delete mode 100755 src/shared/models/Action.ts diff --git a/.gitignore b/.gitignore index 201947b5e..ab2790e9c 100755 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ ngrok.log *.crt .vscode/** !.vscode/launch.json +!.vscode/settings.json .cursor/ coverage diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..33f489961 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit", + "source.organizeImports": "always" + } +} diff --git a/package-lock.json b/package-lock.json index 1c50f82ac..3c6f0a003 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "@types/express": "^4.17.17", "@types/intl-tel-input": "^18.1.4", "@types/jsdom": "^21.1.7", + "@types/jsonp": "^0.2.3", "@types/node": "^24.1.0", "@types/uuid": "^10.0.0", "@typescript-eslint/eslint-plugin": "^5.36.1", @@ -1949,6 +1950,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/jsonp": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@types/jsonp/-/jsonp-0.2.3.tgz", + "integrity": "sha512-+bbowFC2n6TkpbQ369/tqL8pRPF4JRfRNf7Z6cpnAlLlEdy6YxG4HYZE7Qkeg2otcDbwNPIuSMux+P3pE4viFA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/mime": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", diff --git a/package.json b/package.json index acf2328ad..4f0afcaf4 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "@types/express": "^4.17.17", "@types/intl-tel-input": "^18.1.4", "@types/jsdom": "^21.1.7", + "@types/jsonp": "^0.2.3", "@types/node": "^24.1.0", "@types/uuid": "^10.0.0", "@typescript-eslint/eslint-plugin": "^5.36.1", @@ -70,7 +71,7 @@ }, { "path": "./build/releases/OneSignalSDK.page.es6.js", - "limit": "65.5 kB", + "limit": "65.2 kB", "gzip": true }, { @@ -80,7 +81,7 @@ }, { "path": "./build/releases/OneSignalSDK.page.styles.css", - "limit": "8.9 kB", + "limit": "8.81 kB", "gzip": true } ] diff --git a/src/core/CoreModuleDirector.ts b/src/core/CoreModuleDirector.ts index 3b404a360..387277a5c 100644 --- a/src/core/CoreModuleDirector.ts +++ b/src/core/CoreModuleDirector.ts @@ -17,14 +17,17 @@ import { type OperationRepo } from './operationRepo/OperationRepo'; import { ModelChangeTags } from './types/models'; import { SubscriptionChannel, - SubscriptionChannelValue, + type SubscriptionChannelValue, SubscriptionType, } from './types/subscription'; /* Contains OneSignal User-Model-specific logic*/ export class CoreModuleDirector { - constructor(private core: CoreModule) {} + private core: CoreModule; + constructor(core: CoreModule) { + this.core = core; + } get operationRepo(): OperationRepo { return this.core.operationRepo; diff --git a/src/core/executors/IdentityOperationExecutor.ts b/src/core/executors/IdentityOperationExecutor.ts index d1fa19aff..8487ad4ab 100644 --- a/src/core/executors/IdentityOperationExecutor.ts +++ b/src/core/executors/IdentityOperationExecutor.ts @@ -1,6 +1,9 @@ import { ModelChangeTags } from 'src/core/types/models'; -import { ExecutionResult, IOperationExecutor } from 'src/core/types/operation'; -import { IRebuildUserService } from 'src/core/types/user'; +import { + ExecutionResult, + type IOperationExecutor, +} from 'src/core/types/operation'; +import type { IRebuildUserService } from 'src/core/types/user'; import { getResponseStatusType, ResponseStatusType, diff --git a/src/core/executors/LoginUserOperationExecutor.ts b/src/core/executors/LoginUserOperationExecutor.ts index 9e6355b1f..d04be3120 100644 --- a/src/core/executors/LoginUserOperationExecutor.ts +++ b/src/core/executors/LoginUserOperationExecutor.ts @@ -1,5 +1,8 @@ import { ModelChangeTags } from 'src/core/types/models'; -import { ExecutionResult, IOperationExecutor } from 'src/core/types/operation'; +import { + ExecutionResult, + type IOperationExecutor, +} from 'src/core/types/operation'; import OneSignalError from 'src/shared/errors/OneSignalError'; import Environment from 'src/shared/helpers/Environment'; import EventHelper from 'src/shared/helpers/EventHelper'; @@ -12,7 +15,7 @@ import Database from 'src/shared/services/Database'; import LocalStorage from 'src/shared/utils/LocalStorage'; import { getTimeZoneId } from 'src/shared/utils/utils'; import { IdentityConstants, OPERATION_NAME } from '../constants'; -import { IPropertiesModelKeys } from '../models/PropertiesModel'; +import { type IPropertiesModelKeys } from '../models/PropertiesModel'; import { type IdentityModelStore } from '../modelStores/IdentityModelStore'; import { PropertiesModelStore } from '../modelStores/PropertiesModelStore'; import { type SubscriptionModelStore } from '../modelStores/SubscriptionModelStore'; @@ -26,7 +29,7 @@ import { SetAliasOperation } from '../operations/SetAliasOperation'; import { TransferSubscriptionOperation } from '../operations/TransferSubscriptionOperation'; import { UpdateSubscriptionOperation } from '../operations/UpdateSubscriptionOperation'; import { RequestService } from '../requestService/RequestService'; -import { +import type { ICreateUserIdentity, ICreateUserSubscription, IUserProperties, @@ -41,12 +44,22 @@ type SubscriptionMap = Record< // Implements logic similar to Android's SDK's LoginUserOperationExecutor // Reference: https://github.com/OneSignal/OneSignal-Android-SDK/blob/5.1.31/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/operations/impl/executors/LoginUserOperationExecutor.kt export class LoginUserOperationExecutor implements IOperationExecutor { + private _identityOperationExecutor: IdentityOperationExecutor; + private _identityModelStore: IdentityModelStore; + private _propertiesModelStore: PropertiesModelStore; + private _subscriptionsModelStore: SubscriptionModelStore; + constructor( - private _identityOperationExecutor: IdentityOperationExecutor, - private _identityModelStore: IdentityModelStore, - private _propertiesModelStore: PropertiesModelStore, - private _subscriptionsModelStore: SubscriptionModelStore, - ) {} + _identityOperationExecutor: IdentityOperationExecutor, + _identityModelStore: IdentityModelStore, + _propertiesModelStore: PropertiesModelStore, + _subscriptionsModelStore: SubscriptionModelStore, + ) { + this._identityOperationExecutor = _identityOperationExecutor; + this._identityModelStore = _identityModelStore; + this._propertiesModelStore = _propertiesModelStore; + this._subscriptionsModelStore = _subscriptionsModelStore; + } get operations(): string[] { return [OPERATION_NAME.LOGIN_USER]; diff --git a/src/core/executors/RefreshUserOperationExecutor.ts b/src/core/executors/RefreshUserOperationExecutor.ts index 6cee59433..c7bf3403a 100644 --- a/src/core/executors/RefreshUserOperationExecutor.ts +++ b/src/core/executors/RefreshUserOperationExecutor.ts @@ -8,7 +8,7 @@ import Database from 'src/shared/services/Database'; import { IdentityConstants, OPERATION_NAME } from '../constants'; import { IdentityModel } from '../models/IdentityModel'; import { - IPropertiesModelKeys, + type IPropertiesModelKeys, PropertiesModel, } from '../models/PropertiesModel'; import { SubscriptionModel } from '../models/SubscriptionModel'; @@ -29,13 +29,25 @@ import { type IRebuildUserService } from '../types/user'; // Implements logic similar to Android SDK's RefreshUserOperationExecutor // Reference: https://github.com/OneSignal/OneSignal-Android-SDK/blob/5.1.31/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/operations/impl/executors/RefreshUserOperationExecutor.kt export class RefreshUserOperationExecutor implements IOperationExecutor { + private _identityModelStore: IdentityModelStore; + private _propertiesModelStore: PropertiesModelStore; + private _subscriptionsModelStore: SubscriptionModelStore; + private _buildUserService: IRebuildUserService; + private _newRecordState: NewRecordsState; + constructor( - private _identityModelStore: IdentityModelStore, - private _propertiesModelStore: PropertiesModelStore, - private _subscriptionsModelStore: SubscriptionModelStore, - private _buildUserService: IRebuildUserService, - private _newRecordState: NewRecordsState, - ) {} + _identityModelStore: IdentityModelStore, + _propertiesModelStore: PropertiesModelStore, + _subscriptionsModelStore: SubscriptionModelStore, + _buildUserService: IRebuildUserService, + _newRecordState: NewRecordsState, + ) { + this._identityModelStore = _identityModelStore; + this._propertiesModelStore = _propertiesModelStore; + this._subscriptionsModelStore = _subscriptionsModelStore; + this._buildUserService = _buildUserService; + this._newRecordState = _newRecordState; + } get operations(): string[] { return [OPERATION_NAME.REFRESH_USER]; diff --git a/src/core/executors/SubscriptionOperationExecutor.ts b/src/core/executors/SubscriptionOperationExecutor.ts index f521c774f..0a51901ad 100644 --- a/src/core/executors/SubscriptionOperationExecutor.ts +++ b/src/core/executors/SubscriptionOperationExecutor.ts @@ -1,5 +1,8 @@ -import { ExecutionResult, IOperationExecutor } from 'src/core/types/operation'; -import { IRebuildUserService } from 'src/core/types/user'; +import { + ExecutionResult, + type IOperationExecutor, +} from 'src/core/types/operation'; +import type { IRebuildUserService } from 'src/core/types/user'; import { getResponseStatusType, ResponseStatusType, @@ -23,11 +26,19 @@ import { ModelChangeTags } from '../types/models'; // Implements logic similar to Android SDK's SubscriptionOperationExecutor // Reference: https://github.com/OneSignal/OneSignal-Android-SDK/blob/5.1.31/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/operations/impl/executors/SubscriptionOperationExecutor.kt export class SubscriptionOperationExecutor implements IOperationExecutor { + private _subscriptionModelStore: SubscriptionModelStore; + private _buildUserService: IRebuildUserService; + private _newRecordState: NewRecordsState; + constructor( - private _subscriptionModelStore: SubscriptionModelStore, - private _buildUserService: IRebuildUserService, - private _newRecordState: NewRecordsState, - ) {} + _subscriptionModelStore: SubscriptionModelStore, + _buildUserService: IRebuildUserService, + _newRecordState: NewRecordsState, + ) { + this._subscriptionModelStore = _subscriptionModelStore; + this._buildUserService = _buildUserService; + this._newRecordState = _newRecordState; + } get operations(): string[] { return [ diff --git a/src/core/executors/UpdateUserOperationExecutor.ts b/src/core/executors/UpdateUserOperationExecutor.ts index 78e7928ea..dd4bcde3f 100644 --- a/src/core/executors/UpdateUserOperationExecutor.ts +++ b/src/core/executors/UpdateUserOperationExecutor.ts @@ -5,7 +5,7 @@ import { import { PropertyOperationHelper } from 'src/shared/helpers/PropertyOperationHelper'; import Log from 'src/shared/libraries/Log'; import { OPERATION_NAME } from '../constants'; -import { IPropertiesModelKeys } from '../models/PropertiesModel'; +import { type IPropertiesModelKeys } from '../models/PropertiesModel'; import { type IdentityModelStore } from '../modelStores/IdentityModelStore'; import { PropertiesModelStore } from '../modelStores/PropertiesModelStore'; import { PropertiesObject } from '../objects/PropertiesObject'; @@ -16,18 +16,28 @@ import { SetPropertyOperation } from '../operations/SetPropertyOperation'; import AliasPair from '../requestService/AliasPair'; import { RequestService } from '../requestService/RequestService'; import { ModelChangeTags } from '../types/models'; -import { ExecutionResult, IOperationExecutor } from '../types/operation'; +import { ExecutionResult, type IOperationExecutor } from '../types/operation'; import { type IRebuildUserService } from '../types/user'; // Implements logic similar to Android's SDK's UpdateUserOperationExecutor // Reference: https://github.com/OneSignal/OneSignal-Android-SDK/blob/5.1.31/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/operations/impl/executors/UpdateUserOperationExecutor.kt export class UpdateUserOperationExecutor implements IOperationExecutor { + private _identityModelStore: IdentityModelStore; + private _propertiesModelStore: PropertiesModelStore; + private _buildUserService: IRebuildUserService; + private _newRecordState: NewRecordsState; + constructor( - private _identityModelStore: IdentityModelStore, - private _propertiesModelStore: PropertiesModelStore, - private _buildUserService: IRebuildUserService, - private _newRecordState: NewRecordsState, - ) {} + _identityModelStore: IdentityModelStore, + _propertiesModelStore: PropertiesModelStore, + _buildUserService: IRebuildUserService, + _newRecordState: NewRecordsState, + ) { + this._identityModelStore = _identityModelStore; + this._propertiesModelStore = _propertiesModelStore; + this._buildUserService = _buildUserService; + this._newRecordState = _newRecordState; + } get operations(): string[] { return [OPERATION_NAME.SET_PROPERTY]; diff --git a/src/core/listeners/ModelStoreListener.ts b/src/core/listeners/ModelStoreListener.ts index 84c0b62a7..481fd90b7 100644 --- a/src/core/listeners/ModelStoreListener.ts +++ b/src/core/listeners/ModelStoreListener.ts @@ -1,7 +1,7 @@ -import { ModelChangedArgs, type Model } from '../models/Model'; +import type { Model, ModelChangedArgs } from '../models/Model'; import { Operation } from '../operations/Operation'; import { ModelChangeTags, type IModelStore } from '../types/models'; -import { type IOperationRepo } from '../types/operation'; +import type { IOperationRepo } from '../types/operation'; // Implements logic similar to Android SDK's ModelStoreListener // Reference: https://github.com/OneSignal/OneSignal-Android-SDK/blob/5.1.31/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/operations/listeners/ModelStoreListener.kt diff --git a/src/core/listeners/SingletonModelStoreListener.ts b/src/core/listeners/SingletonModelStoreListener.ts index 20cdf9eb9..3259bd134 100644 --- a/src/core/listeners/SingletonModelStoreListener.ts +++ b/src/core/listeners/SingletonModelStoreListener.ts @@ -1,11 +1,11 @@ -import { type Model, ModelChangedArgs } from '../models/Model'; +import type { Model, ModelChangedArgs } from '../models/Model'; import { type Operation } from '../operations/Operation'; import { - ISingletonModelStoreChangeHandler, + type ISingletonModelStoreChangeHandler, ModelChangeTags, } from '../types/models'; -import { IOperationRepo } from '../types/operation'; -import { ISingletonModelStore } from './types'; +import type { IOperationRepo } from '../types/operation'; +import type { ISingletonModelStore } from './types'; // Implements logic similar to Android SDK's SingletonModelStore // Reference: https://github.com/OneSignal/OneSignal-Android-SDK/blob/5.1.31/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/operations/listeners/SingletonModelStoreListener.kt diff --git a/src/core/listeners/SubscriptionModelStoreListener.ts b/src/core/listeners/SubscriptionModelStoreListener.ts index 71418d5d6..f65edf94c 100644 --- a/src/core/listeners/SubscriptionModelStoreListener.ts +++ b/src/core/listeners/SubscriptionModelStoreListener.ts @@ -6,8 +6,11 @@ import { CreateSubscriptionOperation } from '../operations/CreateSubscriptionOpe import { DeleteSubscriptionOperation } from '../operations/DeleteSubscriptionOperation'; import { type Operation } from '../operations/Operation'; import { UpdateSubscriptionOperation } from '../operations/UpdateSubscriptionOperation'; -import { IOperationRepo } from '../types/operation'; -import { NotificationType, NotificationTypeValue } from '../types/subscription'; +import type { IOperationRepo } from '../types/operation'; +import { + NotificationType, + type NotificationTypeValue, +} from '../types/subscription'; import { ModelStoreListener } from './ModelStoreListener'; // Implements logic similar to Android SDK's SubscriptionModelStoreListener diff --git a/src/core/modelRepo/ModelStore.ts b/src/core/modelRepo/ModelStore.ts index 8c56fae44..400900660 100644 --- a/src/core/modelRepo/ModelStore.ts +++ b/src/core/modelRepo/ModelStore.ts @@ -2,12 +2,12 @@ // Reference: https://github.com/OneSignal/OneSignal-Android-SDK/blob/5.1.31/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/common/modeling/ModelStore.kt import type { IEventNotifier } from 'src/core/types/events'; import { - DatabaseModel, - ModelChangeTags, - ModelChangeTagValue, - ModelNameType, + type DatabaseModel, type IModelStore, type IModelStoreChangeHandler, + ModelChangeTags, + type ModelChangeTagValue, + type ModelNameType, } from 'src/core/types/models'; import { EventProducer } from 'src/shared/helpers/EventProducer'; import Database from 'src/shared/services/Database'; @@ -43,6 +43,7 @@ export abstract class ModelStore< IModelStore, IModelChangedHandler { + public readonly modelName: ModelNameType; private changeSubscription: EventProducer> = new EventProducer(); private models: TModel[] = []; @@ -51,7 +52,9 @@ export abstract class ModelStore< /** * @param modelName The persistable name of the model store. If not specified no persisting will occur. */ - constructor(public readonly modelName: ModelNameType) {} + constructor(modelName: ModelNameType) { + this.modelName = modelName; + } /** * Create a model from JSON data diff --git a/src/core/modelRepo/RebuildUserService.ts b/src/core/modelRepo/RebuildUserService.ts index 41158cf71..171dc2dfc 100644 --- a/src/core/modelRepo/RebuildUserService.ts +++ b/src/core/modelRepo/RebuildUserService.ts @@ -9,16 +9,24 @@ import { CreateSubscriptionOperation } from '../operations/CreateSubscriptionOpe import { LoginUserOperation } from '../operations/LoginUserOperation'; import { Operation } from '../operations/Operation'; import { RefreshUserOperation } from '../operations/RefreshUserOperation'; -import { IRebuildUserService } from '../types/user'; +import type { IRebuildUserService } from '../types/user'; // Implements logic similar to Android SDK's RebuildUserService // Reference: https://github.com/OneSignal/OneSignal-Android-SDK/blob/5.1.31/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/builduser/impl/RebuildUserService.kt export class RebuildUserService implements IRebuildUserService { + private _identityModelStore: IdentityModelStore; + private _propertiesModelStore: PropertiesModelStore; + private _subscriptionsModelStore: SubscriptionModelStore; + constructor( - private _identityModelStore: IdentityModelStore, - private _propertiesModelStore: PropertiesModelStore, - private _subscriptionsModelStore: SubscriptionModelStore, - ) {} + _identityModelStore: IdentityModelStore, + _propertiesModelStore: PropertiesModelStore, + _subscriptionsModelStore: SubscriptionModelStore, + ) { + this._identityModelStore = _identityModelStore; + this._propertiesModelStore = _propertiesModelStore; + this._subscriptionsModelStore = _subscriptionsModelStore; + } async getRebuildOperationsIfCurrentUser( appId: string, diff --git a/src/core/modelStores/SimpleModelStore.ts b/src/core/modelStores/SimpleModelStore.ts index dae409d9d..7ec113bc9 100644 --- a/src/core/modelStores/SimpleModelStore.ts +++ b/src/core/modelStores/SimpleModelStore.ts @@ -1,6 +1,6 @@ import { ModelStore } from 'src/core/modelRepo/ModelStore'; import { Model } from 'src/core/models/Model'; -import { DatabaseModel, ModelNameType } from 'src/core/types/models'; +import type { DatabaseModel, ModelNameType } from 'src/core/types/models'; // Implements logic similar to Android SDK's SimpleModelStore // Reference: https://github.com/OneSignal/OneSignal-Android-SDK/blob/5.1.31/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/common/modeling/SimpleModelStore.kt diff --git a/src/core/modelStores/SingletonModelStore.ts b/src/core/modelStores/SingletonModelStore.ts index 22bde298a..5a52f0969 100644 --- a/src/core/modelStores/SingletonModelStore.ts +++ b/src/core/modelStores/SingletonModelStore.ts @@ -1,9 +1,9 @@ import { ModelStore } from 'src/core/modelRepo/ModelStore'; -import { Model, ModelChangedArgs } from 'src/core/models/Model'; +import { Model, type ModelChangedArgs } from 'src/core/models/Model'; import { - IModelStoreChangeHandler, - ISingletonModelStore, - ISingletonModelStoreChangeHandler, + type IModelStoreChangeHandler, + type ISingletonModelStore, + type ISingletonModelStoreChangeHandler, type ModelChangeTagValue, } from 'src/core/types/models'; import { EventProducer } from '../../shared/helpers/EventProducer'; diff --git a/src/core/modelStores/SubscriptionModelStore.ts b/src/core/modelStores/SubscriptionModelStore.ts index aa76f4d45..cba519716 100644 --- a/src/core/modelStores/SubscriptionModelStore.ts +++ b/src/core/modelStores/SubscriptionModelStore.ts @@ -1,7 +1,7 @@ import { SimpleModelStore } from 'src/core/modelStores/SimpleModelStore'; import { ModelChangeTags, - ModelChangeTagValue, + type ModelChangeTagValue, ModelName, } from 'src/core/types/models'; import SubscriptionHelper from 'src/shared/helpers/SubscriptionHelper'; diff --git a/src/core/models/Model.ts b/src/core/models/Model.ts index e96d29bc3..69fc7004f 100644 --- a/src/core/models/Model.ts +++ b/src/core/models/Model.ts @@ -1,4 +1,4 @@ -import { IEventNotifier } from 'src/core/types/events'; +import type { IEventNotifier } from 'src/core/types/events'; import { ModelChangeTags } from 'src/core/types/models'; import { EventProducer } from 'src/shared/helpers/EventProducer'; diff --git a/src/core/models/PropertiesModel.ts b/src/core/models/PropertiesModel.ts index b39f6fa36..2ea2305fe 100644 --- a/src/core/models/PropertiesModel.ts +++ b/src/core/models/PropertiesModel.ts @@ -1,4 +1,4 @@ -import { IUserProperties } from '../types/api'; +import type { IUserProperties } from '../types/api'; import { Model } from './Model'; type IPropertiesModel = { diff --git a/src/core/models/SubscriptionModel.ts b/src/core/models/SubscriptionModel.ts index d1cd2cd64..4227b39b5 100644 --- a/src/core/models/SubscriptionModel.ts +++ b/src/core/models/SubscriptionModel.ts @@ -1,8 +1,8 @@ import FuturePushSubscriptionRecord from 'src/page/userModel/FuturePushSubscriptionRecord'; -import { ISubscription } from '../types/api'; +import type { ISubscription } from '../types/api'; import { - NotificationTypeValue, - SubscriptionTypeValue, + type NotificationTypeValue, + type SubscriptionTypeValue, } from '../types/subscription'; import { Model } from './Model'; diff --git a/src/core/operationRepo/OperationRepo.ts b/src/core/operationRepo/OperationRepo.ts index 7cb1d12bc..248bf172a 100644 --- a/src/core/operationRepo/OperationRepo.ts +++ b/src/core/operationRepo/OperationRepo.ts @@ -1,8 +1,8 @@ import { ExecutionResult, - IOperationExecutor, - IOperationRepo, - IStartableService, + type IOperationExecutor, + type IOperationRepo, + type IStartableService, } from 'src/core/types/operation'; import Log from 'src/shared/libraries/Log'; import Database from 'src/shared/services/Database'; @@ -52,12 +52,17 @@ export class OperationRepo implements IOperationRepo, IStartableService { public queue: OperationQueueItem[] = []; private paused = true; private enqueueIntoBucket = 0; + private operationModelStore: OperationModelStore; + private newRecordState: NewRecordsState; constructor( executors: IOperationExecutor[], - private operationModelStore: OperationModelStore, - private newRecordState: NewRecordsState, + operationModelStore: OperationModelStore, + newRecordState: NewRecordsState, ) { + this.operationModelStore = operationModelStore; + this.newRecordState = newRecordState; + this.executorsMap = new Map(); for (const executor of executors) { for (const operation of executor.operations) { diff --git a/src/core/operations/BaseFullSubscriptionOperation.ts b/src/core/operations/BaseFullSubscriptionOperation.ts index b70dcbc5f..35813928d 100644 --- a/src/core/operations/BaseFullSubscriptionOperation.ts +++ b/src/core/operations/BaseFullSubscriptionOperation.ts @@ -1,8 +1,8 @@ import FuturePushSubscriptionRecord from 'src/page/userModel/FuturePushSubscriptionRecord'; -import { ICreateUserSubscription } from '../types/api'; +import type { ICreateUserSubscription } from '../types/api'; import { - NotificationTypeValue, - SubscriptionTypeValue, + type NotificationTypeValue, + type SubscriptionTypeValue, } from '../types/subscription'; import { BaseSubscriptionOperation } from './BaseSubscriptionOperation'; diff --git a/src/core/operations/CreateSubscriptionOperation.ts b/src/core/operations/CreateSubscriptionOperation.ts index b1a12cb5e..75dc69c36 100644 --- a/src/core/operations/CreateSubscriptionOperation.ts +++ b/src/core/operations/CreateSubscriptionOperation.ts @@ -2,7 +2,7 @@ import { IDManager } from 'src/shared/managers/IDManager'; import { OPERATION_NAME } from '../constants'; import { BaseFullSubscriptionOperation, - SubscriptionWithAppId, + type SubscriptionWithAppId, } from './BaseFullSubscriptionOperation'; /** diff --git a/src/core/operations/DeleteAliasOperation.ts b/src/core/operations/DeleteAliasOperation.ts index 413d8a434..9f36a25d9 100644 --- a/src/core/operations/DeleteAliasOperation.ts +++ b/src/core/operations/DeleteAliasOperation.ts @@ -1,6 +1,6 @@ import { OPERATION_NAME } from '../constants'; import { BaseAliasOperation } from './BaseAliasOperation'; -import { GroupComparisonType, GroupComparisonValue } from './Operation'; +import { GroupComparisonType, type GroupComparisonValue } from './Operation'; // Implements logic similar to Android SDK's DeleteAliasOperation // Reference: https://github.com/OneSignal/OneSignal-Android-SDK/blob/5.1.31/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/operations/DeleteAliasOperation.kt diff --git a/src/core/operations/DeleteSubscriptionOperation.ts b/src/core/operations/DeleteSubscriptionOperation.ts index af2660e48..09b9abbfd 100644 --- a/src/core/operations/DeleteSubscriptionOperation.ts +++ b/src/core/operations/DeleteSubscriptionOperation.ts @@ -1,6 +1,6 @@ import { OPERATION_NAME } from '../constants'; import { BaseSubscriptionOperation } from './BaseSubscriptionOperation'; -import { GroupComparisonType, GroupComparisonValue } from './Operation'; +import { GroupComparisonType, type GroupComparisonValue } from './Operation'; /** * An Operation to delete a subscription from the OneSignal backend. diff --git a/src/core/operations/ExecutionResponse.ts b/src/core/operations/ExecutionResponse.ts index 66e0719f2..06832a00c 100644 --- a/src/core/operations/ExecutionResponse.ts +++ b/src/core/operations/ExecutionResponse.ts @@ -1,5 +1,5 @@ -import { ExecutionResultValue } from 'src/core/types/operation'; -import { type Operation } from './Operation'; +import type { ExecutionResultValue } from 'src/core/types/operation'; +import type { Operation } from './Operation'; export class ExecutionResponse { /** diff --git a/src/core/operations/LoginUserOperation.ts b/src/core/operations/LoginUserOperation.ts index 1c4fad535..d4818afb9 100644 --- a/src/core/operations/LoginUserOperation.ts +++ b/src/core/operations/LoginUserOperation.ts @@ -2,7 +2,7 @@ import { IDManager } from 'src/shared/managers/IDManager'; import { OPERATION_NAME } from '../constants'; import { GroupComparisonType, - GroupComparisonValue, + type GroupComparisonValue, Operation, } from './Operation'; diff --git a/src/core/operations/RefreshUserOperation.ts b/src/core/operations/RefreshUserOperation.ts index 03d104d61..c507cce02 100644 --- a/src/core/operations/RefreshUserOperation.ts +++ b/src/core/operations/RefreshUserOperation.ts @@ -2,7 +2,7 @@ import { OPERATION_NAME } from '../constants'; import { GroupComparisonType, - GroupComparisonValue, + type GroupComparisonValue, Operation, } from './Operation'; diff --git a/src/core/operations/TransferSubscriptionOperation.ts b/src/core/operations/TransferSubscriptionOperation.ts index cb4998ad0..5a42f32c0 100644 --- a/src/core/operations/TransferSubscriptionOperation.ts +++ b/src/core/operations/TransferSubscriptionOperation.ts @@ -1,6 +1,6 @@ import { OPERATION_NAME } from '../constants'; import { BaseSubscriptionOperation } from './BaseSubscriptionOperation'; -import { GroupComparisonType, GroupComparisonValue } from './Operation'; +import { GroupComparisonType, type GroupComparisonValue } from './Operation'; /** * An Operation to transfer a subscription to a new owner on the OneSignal backend. diff --git a/src/core/operations/UpdateSubscriptionOperation.ts b/src/core/operations/UpdateSubscriptionOperation.ts index b57a4ef71..e8ee8e796 100644 --- a/src/core/operations/UpdateSubscriptionOperation.ts +++ b/src/core/operations/UpdateSubscriptionOperation.ts @@ -1,7 +1,7 @@ import { OPERATION_NAME } from '../constants'; import { BaseFullSubscriptionOperation, - SubscriptionWithAppId, + type SubscriptionWithAppId, } from './BaseFullSubscriptionOperation'; /** diff --git a/src/core/requestService/RequestService.ts b/src/core/requestService/RequestService.ts index 8f6d088b9..29e241fff 100644 --- a/src/core/requestService/RequestService.ts +++ b/src/core/requestService/RequestService.ts @@ -1,5 +1,5 @@ import OneSignalApiBase from '../../shared/api/OneSignalApiBase'; -import OneSignalApiBaseResponse from '../../shared/api/OneSignalApiBaseResponse'; +import type OneSignalApiBaseResponse from '../../shared/api/OneSignalApiBaseResponse'; import { SdkInitError, SdkInitErrorKind, @@ -8,15 +8,15 @@ import { encodeRFC3986URIComponent } from '../../shared/utils/Encoding'; import OneSignalUtils from '../../shared/utils/OneSignalUtils'; import { IdentityModel } from '../models/IdentityModel'; import { - ICreateUser, - ICreateUserIdentity, - ICreateUserSubscription, - ISubscription, - IUpdateUser, - IUserIdentity, - IUserProperties, - RequestMetadata, - UserData, + type ICreateUser, + type ICreateUserIdentity, + type ICreateUserSubscription, + type ISubscription, + type IUpdateUser, + type IUserIdentity, + type IUserProperties, + type RequestMetadata, + type UserData, } from '../types/api'; import AliasPair from './AliasPair'; diff --git a/src/entries/pageSdkInit.ts b/src/entries/pageSdkInit.ts index 163ddbbc1..0b78c83a3 100644 --- a/src/entries/pageSdkInit.ts +++ b/src/entries/pageSdkInit.ts @@ -2,7 +2,7 @@ * This is OneSignalSDK.page.es6.js(ES6) * Loaded from OneSignalSDK.page.js only if the browser supports push. */ -import { OneSignalDeferredLoadedCallback } from 'src/page/models/OneSignalDeferredLoadedCallback'; +import type { OneSignalDeferredLoadedCallback } from 'src/page/models/OneSignalDeferredLoadedCallback'; import OneSignal from '../onesignal/OneSignal'; import { ReplayCallsOnOneSignal } from '../page/utils/ReplayCallsOnOneSignal'; import Log from '../shared/libraries/Log'; diff --git a/src/onesignal/NotificationsNamespace.ts b/src/onesignal/NotificationsNamespace.ts index f300ab093..949e04ffd 100644 --- a/src/onesignal/NotificationsNamespace.ts +++ b/src/onesignal/NotificationsNamespace.ts @@ -1,5 +1,5 @@ -import { NotificationEventName } from '../page/models/NotificationEventName'; -import NotificationEventTypeMap from '../page/models/NotificationEventTypeMap'; +import type { NotificationEventName } from '../page/models/NotificationEventName'; +import type { NotificationEventTypeMap } from '../page/models/NotificationEventTypeMap'; import { EventListenerBase } from '../page/userModel/EventListenerBase'; import { ValidatorUtils } from '../page/utils/ValidatorUtils'; import { @@ -17,11 +17,13 @@ import OneSignal from './OneSignal'; export default class NotificationsNamespace extends EventListenerBase { private _permission: boolean; + private _permissionNative?: NotificationPermission; - constructor(private _permissionNative?: NotificationPermission) { + constructor(permissionNative?: NotificationPermission) { super(); - this._permission = _permissionNative === NotificationPermission.Granted; + this._permissionNative = permissionNative; + this._permission = permissionNative === NotificationPermission.Granted; OneSignal.emitter.on( OneSignal.EVENTS.NOTIFICATION_PERMISSION_CHANGED_AS_STRING, diff --git a/src/onesignal/OneSignal.ts b/src/onesignal/OneSignal.ts index 4f634bbea..cee6d4805 100644 --- a/src/onesignal/OneSignal.ts +++ b/src/onesignal/OneSignal.ts @@ -1,11 +1,12 @@ +import type Bell from 'src/page/bell/Bell'; import CoreModule from '../core/CoreModule'; import { CoreModuleDirector } from '../core/CoreModuleDirector'; import { EnvironmentInfoHelper } from '../page/helpers/EnvironmentInfoHelper'; import ConfigManager from '../page/managers/ConfigManager'; import LoginManager from '../page/managers/LoginManager'; import Context from '../page/models/Context'; -import { EnvironmentInfo } from '../page/models/EnvironmentInfo'; -import { OneSignalDeferredLoadedCallback } from '../page/models/OneSignalDeferredLoadedCallback'; +import type { EnvironmentInfo } from '../page/models/EnvironmentInfo'; +import type { OneSignalDeferredLoadedCallback } from '../page/models/OneSignalDeferredLoadedCallback'; import TimedLocalStorage from '../page/modules/TimedLocalStorage'; import { ProcessOneSignalPushCalls } from '../page/utils/ProcessOneSignalPushCalls'; import { @@ -20,8 +21,7 @@ import MainHelper from '../shared/helpers/MainHelper'; import Emitter from '../shared/libraries/Emitter'; import Log from '../shared/libraries/Log'; import SdkEnvironment from '../shared/managers/SdkEnvironment'; -import { AppConfig, AppUserConfig } from '../shared/models/AppConfig'; -import { AppUserConfigNotifyButton } from '../shared/models/Prompts'; +import type { AppConfig, AppUserConfig } from '../shared/models/AppConfig'; import Database from '../shared/services/Database'; import OneSignalEvent from '../shared/services/OneSignalEvent'; import { bowserCastle } from '../shared/utils/bowserCastle'; @@ -277,7 +277,7 @@ export default class OneSignal { static timedLocalStorage = TimedLocalStorage; static initialized = false; static _didLoadITILibrary = false; - static notifyButton: AppUserConfigNotifyButton | null = null; + static notifyButton: Bell | null = null; static environment = Environment; static database = Database; static event = OneSignalEvent; diff --git a/src/onesignal/PushSubscriptionNamespace.ts b/src/onesignal/PushSubscriptionNamespace.ts index 44204b3bc..31ceef15a 100644 --- a/src/onesignal/PushSubscriptionNamespace.ts +++ b/src/onesignal/PushSubscriptionNamespace.ts @@ -1,5 +1,5 @@ import { isCompleteSubscriptionObject } from '../core/utils/typePredicates'; -import SubscriptionChangeEvent from '../page/models/SubscriptionChangeEvent'; +import type SubscriptionChangeEvent from '../page/models/SubscriptionChangeEvent'; import { EventListenerBase } from '../page/userModel/EventListenerBase'; import { ValidatorUtils } from '../page/utils/ValidatorUtils'; import { diff --git a/src/onesignal/SlidedownNamespace.ts b/src/onesignal/SlidedownNamespace.ts index 91361a29b..ff6ccbf4a 100644 --- a/src/onesignal/SlidedownNamespace.ts +++ b/src/onesignal/SlidedownNamespace.ts @@ -1,8 +1,8 @@ -import { AutoPromptOptions } from '../page/managers/PromptsManager'; +import type { AutoPromptOptions } from '../page/managers/PromptsManager'; +import { EventListenerBase } from '../page/userModel/EventListenerBase'; import { DelayedPromptType } from '../shared/models/Prompts'; import { awaitOneSignalInitAndSupported } from '../shared/utils/utils'; import OneSignal from './OneSignal'; -import { EventListenerBase } from '../page/userModel/EventListenerBase'; export default class SlidedownNamespace extends EventListenerBase { constructor() { diff --git a/src/onesignal/User.ts b/src/onesignal/User.ts index ea4ba7bfe..d836559e6 100644 --- a/src/onesignal/User.ts +++ b/src/onesignal/User.ts @@ -2,7 +2,7 @@ import { SubscriptionModel } from 'src/core/models/SubscriptionModel'; import { NotificationType, SubscriptionType, - SubscriptionTypeValue, + type SubscriptionTypeValue, } from 'src/core/types/subscription'; import Log from 'src/shared/libraries/Log'; import { IDManager } from 'src/shared/managers/IDManager'; diff --git a/src/onesignal/UserNamespace.ts b/src/onesignal/UserNamespace.ts index 7679d5606..ac0ab9300 100644 --- a/src/onesignal/UserNamespace.ts +++ b/src/onesignal/UserNamespace.ts @@ -1,4 +1,4 @@ -import UserChangeEvent from '../page/models/UserChangeEvent'; +import type UserChangeEvent from '../page/models/UserChangeEvent'; import { EventListenerBase } from '../page/userModel/EventListenerBase'; import Emitter from '../shared/libraries/Emitter'; import { Subscription } from '../shared/models/Subscription'; diff --git a/src/page/bell/Bell.ts b/src/page/bell/Bell.ts index 5c9ed3cb2..64b64dc0d 100755 --- a/src/page/bell/Bell.ts +++ b/src/page/bell/Bell.ts @@ -1,6 +1,17 @@ +import OneSignal from '../../onesignal/OneSignal'; +import { DismissHelper } from '../../shared/helpers/DismissHelper'; +import MainHelper from '../../shared/helpers/MainHelper'; +import Log from '../../shared/libraries/Log'; import { NotificationPermission } from '../../shared/models/NotificationPermission'; +import type { + AppUserConfigNotifyButton, + BellPosition, + BellSize, + BellText, +} from '../../shared/models/Prompts'; import OneSignalEvent from '../../shared/services/OneSignalEvent'; -import { ResourceLoadState } from '../services/DynamicResourceLoader'; +import { bowserCastle } from '../../shared/utils/bowserCastle'; +import BrowserUtils from '../../shared/utils/BrowserUtils'; import { addCssClass, addDomElement, @@ -10,25 +21,14 @@ import { once, removeDomElement, } from '../../shared/utils/utils'; +import { DismissPrompt } from '../models/Dismiss'; +import type { SubscriptionChangeEvent } from '../models/SubscriptionChangeEvent'; +import { ResourceLoadState } from '../services/DynamicResourceLoader'; import Badge from './Badge'; import Button from './Button'; import Dialog from './Dialog'; import Launcher from './Launcher'; import Message from './Message'; -import { DismissPrompt } from '../models/Dismiss'; -import { DismissHelper } from '../../shared/helpers/DismissHelper'; -import MainHelper from '../../shared/helpers/MainHelper'; -import Log from '../../shared/libraries/Log'; -import { - AppUserConfigNotifyButton, - BellSize, - BellPosition, - BellText, -} from '../../shared/models/Prompts'; -import SubscriptionChangeEvent from '../models/SubscriptionChangeEvent'; -import { bowserCastle } from '../../shared/utils/bowserCastle'; -import OneSignal from '../../onesignal/OneSignal'; -import BrowserUtils from '../../shared/utils/BrowserUtils'; const logoSvg = ``; @@ -620,9 +620,8 @@ export default class Bell { if (this.options.colors) { const colors = this.options.colors; if (colors['circle.background']) { - this.graphic.querySelector( - '.background', - ).style.cssText += `fill: ${colors['circle.background']}`; + this.graphic.querySelector('.background').style.cssText += + `fill: ${colors['circle.background']}`; } if (colors['circle.foreground']) { const foregroundElements = this.graphic.querySelectorAll('.foreground'); @@ -630,9 +629,8 @@ export default class Bell { const element = foregroundElements[i]; element.style.cssText += `fill: ${colors['circle.foreground']}`; } - this.graphic.querySelector( - '.stroke', - ).style.cssText += `stroke: ${colors['circle.foreground']}`; + this.graphic.querySelector('.stroke').style.cssText += + `stroke: ${colors['circle.foreground']}`; } if (colors['badge.background']) { this.badge.element.style.cssText += `background: ${colors['badge.background']}`; @@ -645,14 +643,12 @@ export default class Bell { } if (dialogButton) { if (colors['dialog.button.background']) { - this.dialog.element.querySelector( - 'button.action', - ).style.cssText += `background: ${colors['dialog.button.background']}`; + this.dialog.element.querySelector('button.action').style.cssText += + `background: ${colors['dialog.button.background']}`; } if (colors['dialog.button.foreground']) { - this.dialog.element.querySelector( - 'button.action', - ).style.cssText += `color: ${colors['dialog.button.foreground']}`; + this.dialog.element.querySelector('button.action').style.cssText += + `color: ${colors['dialog.button.foreground']}`; } if (colors['dialog.button.background.hovering']) { this.addCssToHead( @@ -669,9 +665,8 @@ export default class Bell { } if (pulseRing) { if (colors['pulse.color']) { - this.button.element.querySelector( - '.pulse-ring', - ).style.cssText = `border-color: ${colors['pulse.color']}`; + this.button.element.querySelector('.pulse-ring').style.cssText = + `border-color: ${colors['pulse.color']}`; } } } diff --git a/src/page/bell/Dialog.ts b/src/page/bell/Dialog.ts index 4b50099aa..fc243b47f 100755 --- a/src/page/bell/Dialog.ts +++ b/src/page/bell/Dialog.ts @@ -1,13 +1,14 @@ -import OneSignalEvent from '../../shared/services/OneSignalEvent'; import SdkEnvironment from '../../shared/managers/SdkEnvironment'; +import OneSignalEvent from '../../shared/services/OneSignalEvent'; +import { bowserCastle } from '../../shared/utils/bowserCastle'; import { addDomElement, clearDomElementChildren, getPlatformNotificationIcon, } from '../../shared/utils/utils'; +import type { NotificationIcons } from '../models/NotificationIcons'; import AnimatedElement from './AnimatedElement'; import Bell from './Bell'; -import { bowserCastle } from '../../shared/utils/bowserCastle'; export default class Dialog extends AnimatedElement { public bell: Bell; diff --git a/src/page/bell/Launcher.ts b/src/page/bell/Launcher.ts index bc0624cec..f27f41a1c 100755 --- a/src/page/bell/Launcher.ts +++ b/src/page/bell/Launcher.ts @@ -1,3 +1,9 @@ +import { + InvalidStateError, + InvalidStateReason, +} from '../../shared/errors/InvalidStateError'; +import Log from '../../shared/libraries/Log'; +import type { BellSize } from '../../shared/models/Prompts'; import { addCssClass, contains, @@ -8,15 +14,9 @@ import { } from '../../shared/utils/utils'; import ActiveAnimatedElement from './ActiveAnimatedElement'; import Bell from './Bell'; -import { - InvalidStateError, - InvalidStateReason, -} from '../../shared/errors/InvalidStateError'; -import { BellSize } from '../../shared/models/Prompts'; -import Log from '../../shared/libraries/Log'; export default class Launcher extends ActiveAnimatedElement { - public bell: any; + public bell: Bell; public wasInactive: boolean; constructor(bell: Bell) { @@ -77,7 +77,7 @@ export default class Launcher extends ActiveAnimatedElement { ); }, this.transitionCheckTimeout); once( - this.element, + this.element!, 'transitionend', (event: Event, destroyListenerFn: () => void) => { if ( @@ -136,12 +136,12 @@ export default class Launcher extends ActiveAnimatedElement { return this.bell.badge .hide() .then(() => - Promise.all([super.activate(), this.resize(this.bell.options.size)]), + Promise.all([super.activate(), this.resize(this.bell.options.size!)]), ); } else { return Promise.all([ super.activate(), - this.resize(this.bell.options.size), + this.resize(this.bell.options.size!), ]); } } diff --git a/src/page/helpers/EnvironmentInfoHelper.ts b/src/page/helpers/EnvironmentInfoHelper.ts index 7bbba4a2e..14f13d109 100644 --- a/src/page/helpers/EnvironmentInfoHelper.ts +++ b/src/page/helpers/EnvironmentInfoHelper.ts @@ -2,7 +2,7 @@ import bowser from 'bowser'; import Utils from '../../shared/context/Utils'; import { Browser } from '../../shared/models/Browser'; import { bowserCastle } from '../../shared/utils/bowserCastle'; -import { EnvironmentInfo } from '../models/EnvironmentInfo'; +import type { EnvironmentInfo } from '../models/EnvironmentInfo'; /** * EnvironmentInfoHelper is used to save page ("browser") context environment information to diff --git a/src/page/managers/ConfigManager.ts b/src/page/managers/ConfigManager.ts index e7fc45022..d37f125a4 100644 --- a/src/page/managers/ConfigManager.ts +++ b/src/page/managers/ConfigManager.ts @@ -1,8 +1,8 @@ import OneSignalApi from '../../shared/api/OneSignalApi'; import { ConfigHelper } from '../../shared/helpers/ConfigHelper'; -import { - AppUserConfig, +import type { AppConfig, + AppUserConfig, ServerAppConfig, } from '../../shared/models/AppConfig'; diff --git a/src/page/managers/PromptsManager.ts b/src/page/managers/PromptsManager.ts index 3fdc8f290..32cf28619 100644 --- a/src/page/managers/PromptsManager.ts +++ b/src/page/managers/PromptsManager.ts @@ -1,5 +1,3 @@ -import OneSignalEvent from '../../shared/services/OneSignalEvent'; -import { ResourceLoadState } from '../services/DynamicResourceLoader'; import { CONFIG_DEFAULTS_SLIDEDOWN_OPTIONS, SERVER_CONFIG_DEFAULTS_PROMPT_DELAYS, @@ -9,18 +7,21 @@ import InitHelper from '../../shared/helpers/InitHelper'; import PromptsHelper from '../../shared/helpers/PromptsHelper'; import Log from '../../shared/libraries/Log'; import { - SlidedownPromptOptions, - AppUserConfigPromptOptions, DelayedPromptType, - DelayedPromptOptions, + type AppUserConfigPromptOptions, + type DelayedPromptOptions, + type DelayedPromptTypeValue, + type SlidedownPromptOptions, } from '../../shared/models/Prompts'; +import OneSignalEvent from '../../shared/services/OneSignalEvent'; import { awaitableTimeout } from '../../shared/utils/AwaitableTimeout'; +import { bowserCastle } from '../../shared/utils/bowserCastle'; import OneSignalUtils from '../../shared/utils/OneSignalUtils'; import { EnvironmentInfoHelper } from '../helpers/EnvironmentInfoHelper'; -import { ContextInterface } from '../models/Context'; +import type { ContextInterface } from '../models/Context'; import { DismissPrompt } from '../models/Dismiss'; +import { ResourceLoadState } from '../services/DynamicResourceLoader'; import Slidedown from '../slidedown/Slidedown'; -import { bowserCastle } from '../../shared/utils/bowserCastle'; export interface AutoPromptOptions { force?: boolean; @@ -43,7 +44,7 @@ export class PromptsManager { private shouldForceSlidedownOverNative(): boolean { const { environmentInfo } = OneSignal; const { browserType, browserVersion, requiresUserInteraction } = - environmentInfo; + environmentInfo!; return ( (browserType === 'chrome' && @@ -55,8 +56,7 @@ export class PromptsManager { public async spawnAutoPrompts() { // user config prompt options - const userPromptOptions: AppUserConfigPromptOptions = - OneSignal.config.userConfig.promptOptions; + const userPromptOptions = OneSignal.config?.userConfig.promptOptions; /* * Chrome 63 on Android permission prompts are permanent without a dismiss option. To avoid @@ -90,7 +90,7 @@ export class PromptsManager { // if slidedown not configured, condition met with native options, & should force slidedown over native: const isPushSlidedownConfigured = !!PromptsHelper.getFirstSlidedownPromptOptionsWithType( - userPromptOptions.slidedown?.prompts, + userPromptOptions?.slidedown?.prompts, DelayedPromptType.Push, ); @@ -102,7 +102,7 @@ export class PromptsManager { } // spawn slidedown prompts - const prompts = userPromptOptions.slidedown?.prompts; + const prompts = userPromptOptions?.slidedown?.prompts; if (!!prompts && prompts?.length > 0) { for (let i = 0; i < prompts.length; i++) { const promptOptions = prompts[i]; @@ -132,7 +132,7 @@ export class PromptsManager { } public async internalShowDelayedPrompt( - type: DelayedPromptType, + type: DelayedPromptTypeValue, timeDelaySeconds: number, options?: AutoPromptOptions, ): Promise { @@ -260,7 +260,7 @@ export class PromptsManager { * If present, `options.slidedownPromptOptions` overrides `typeToPullFromConfig` */ public async internalShowParticularSlidedown( - typeToPullFromConfig: DelayedPromptType, + typeToPullFromConfig: DelayedPromptTypeValue, options?: AutoPromptOptions, ): Promise { const prompts = @@ -347,8 +347,8 @@ export class PromptsManager { } private getDelayedPromptOptions( - promptOptions: AppUserConfigPromptOptions, - type: DelayedPromptType, + promptOptions: AppUserConfigPromptOptions | undefined, + type: DelayedPromptTypeValue, ): DelayedPromptOptions { const defaultOptions = { enabled: false, diff --git a/src/page/managers/slidedownManager/SlidedownManager.ts b/src/page/managers/slidedownManager/SlidedownManager.ts index d344f178c..f68635335 100644 --- a/src/page/managers/slidedownManager/SlidedownManager.ts +++ b/src/page/managers/slidedownManager/SlidedownManager.ts @@ -18,23 +18,29 @@ import InitHelper from '../../../shared/helpers/InitHelper'; import PromptsHelper from '../../../shared/helpers/PromptsHelper'; import Log from '../../../shared/libraries/Log'; import { NotificationPermission } from '../../../shared/models/NotificationPermission'; -import { DelayedPromptType } from '../../../shared/models/Prompts'; -import { PushSubscriptionState } from '../../../shared/models/PushSubscriptionState'; +import { + DelayedPromptType, + type DelayedPromptTypeValue, +} from '../../../shared/models/Prompts'; +import type { PushSubscriptionState } from '../../../shared/models/PushSubscriptionState'; import { awaitableTimeout } from '../../../shared/utils/AwaitableTimeout'; import { OneSignalUtils } from '../../../shared/utils/OneSignalUtils'; import TagUtils from '../../../shared/utils/TagUtils'; import AlreadySubscribedError from '../../errors/AlreadySubscribedError'; import PermissionMessageDismissedError from '../../errors/PermissionMessageDismissedError'; -import { ContextInterface } from '../../models/Context'; +import type { ContextInterface } from '../../models/Context'; import { DismissPrompt } from '../../models/Dismiss'; -import { TagsObjectForApi, TagsObjectWithBoolean } from '../../models/Tags'; +import type { + TagsObjectForApi, + TagsObjectWithBoolean, +} from '../../models/Tags'; import ChannelCaptureContainer from '../../slidedown/ChannelCaptureContainer'; import ConfirmationToast from '../../slidedown/ConfirmationToast'; import Slidedown, { manageNotifyButtonStateWhileSlidedownShows, } from '../../slidedown/Slidedown'; import TaggingContainer from '../../slidedown/TaggingContainer'; -import { AutoPromptOptions } from '../PromptsManager'; +import type { AutoPromptOptions } from '../PromptsManager'; export class SlidedownManager { private context: ContextInterface; @@ -370,7 +376,7 @@ export class SlidedownManager { `SlidedownManager: handleAllowClick: this.slidedown is undefined`, ); } - const slidedownType: DelayedPromptType = this.slidedown.options.type; + const slidedownType: DelayedPromptTypeValue = this.slidedown.options.type; if (this.slidedown.isShowingFailureState) { this.slidedown.removeFailureState(); @@ -402,7 +408,7 @@ export class SlidedownManager { this.slidedown.removeSaveState(); this.slidedown.setFailureState(); - if (e.reason !== undefined) { + if (e instanceof ChannelCaptureError) { this.slidedown.setFailureStateForInvalidChannelInput(e.reason); } return; diff --git a/src/page/managers/tagManager/TagManager.ts b/src/page/managers/tagManager/TagManager.ts index b1116b2a6..4e4b7ddb4 100644 --- a/src/page/managers/tagManager/TagManager.ts +++ b/src/page/managers/tagManager/TagManager.ts @@ -1,8 +1,11 @@ -import { TagsObjectForApi, TagsObjectWithBoolean } from '../../models/Tags'; -import TagUtils from '../../../shared/utils/TagUtils'; -import { ContextInterface } from '../../models/Context'; -import { ITagManager } from './types'; import Log from '../../../shared/libraries/Log'; +import TagUtils from '../../../shared/utils/TagUtils'; +import type { ContextInterface } from '../../models/Context'; +import type { + TagsObjectForApi, + TagsObjectWithBoolean, +} from '../../models/Tags'; +import type { ITagManager } from './types'; /** * Manages tags for the TaggingContainer @@ -33,9 +36,8 @@ export default class TagManager implements ITagManager { const shouldSendUpdate = !TagUtils.isTagObjectEmpty(finalTagsObject); if (shouldSendUpdate) { - return (await OneSignal.User.addTags( - finalTagsObject, - )) as TagsObjectForApi; + await OneSignal.User.addTags(finalTagsObject); + return finalTagsObject; } Log.warn( 'OneSignal: no change detected in Category preferences. Skipping tag update.', diff --git a/src/page/managers/tagManager/types.ts b/src/page/managers/tagManager/types.ts index b4f440507..5afc70b10 100644 --- a/src/page/managers/tagManager/types.ts +++ b/src/page/managers/tagManager/types.ts @@ -1,7 +1,10 @@ -import { TagsObjectForApi, TagsObjectWithBoolean } from '../../models/Tags'; +import type { + TagsObjectForApi, + TagsObjectWithBoolean, +} from '../../models/Tags'; export interface ITagManager { - sendTags: (isInUpdateMode: boolean) => Promise; + sendTags: (isInUpdateMode?: boolean) => Promise; storeTagValuesToUpdate: (tags: TagsObjectWithBoolean) => void; storeRemotePlayerTags: (tags: TagsObjectForApi) => void; remoteTags: TagsObjectForApi; diff --git a/src/page/models/Context.ts b/src/page/models/Context.ts index 43e6dcc82..3bdfc4411 100644 --- a/src/page/models/Context.ts +++ b/src/page/models/Context.ts @@ -6,16 +6,16 @@ import { ServiceWorkerManager } from '../../shared/managers/ServiceWorkerManager import { SubscriptionManager } from '../../shared/managers/SubscriptionManager'; import { UpdateManager } from '../../shared/managers/UpdateManager'; import { SessionManager } from '../../shared/managers/sessionManager/SessionManager'; -import { ISessionManager } from '../../shared/managers/sessionManager/types'; -import { AppConfig } from '../../shared/models/AppConfig'; -import { ContextSWInterface } from '../../shared/models/ContextSW'; +import type { ISessionManager } from '../../shared/managers/sessionManager/types'; +import type { AppConfig } from '../../shared/models/AppConfig'; +import type { ContextSWInterface } from '../../shared/models/ContextSW'; import { PromptsManager } from '../managers/PromptsManager'; import { SlidedownManager } from '../managers/slidedownManager/SlidedownManager'; -import { ISlidedownManager } from '../managers/slidedownManager/types'; +import type { ISlidedownManager } from '../managers/slidedownManager/types'; import TagManager from '../managers/tagManager/TagManager'; -import { ITagManager } from '../managers/tagManager/types'; +import type { ITagManager } from '../managers/tagManager/types'; import { DynamicResourceLoader } from '../services/DynamicResourceLoader'; -import { EnvironmentInfo } from './EnvironmentInfo'; +import type { EnvironmentInfo } from './EnvironmentInfo'; export interface ContextInterface extends ContextSWInterface { dynamicResourceLoader: DynamicResourceLoader; diff --git a/src/page/models/NotificationEventTypeMap.ts b/src/page/models/NotificationEventTypeMap.ts index 0916b8aa7..d46c49675 100644 --- a/src/page/models/NotificationEventTypeMap.ts +++ b/src/page/models/NotificationEventTypeMap.ts @@ -1,15 +1,13 @@ -import { +import type { NotificationClickEvent, - NotificationForegroundWillDisplayEvent, NotificationDismissEvent, + NotificationForegroundWillDisplayEvent, } from '../../shared/models/NotificationEvent'; -type NotificationEventTypeMap = { +export type NotificationEventTypeMap = { click: NotificationClickEvent; foregroundWillDisplay: NotificationForegroundWillDisplayEvent; dismiss: NotificationDismissEvent; permissionChange: boolean; permissionPromptDisplay: void; }; - -export default NotificationEventTypeMap; diff --git a/src/page/models/NotificationIcons.ts b/src/page/models/NotificationIcons.ts index a4bf59a30..6027c760f 100644 --- a/src/page/models/NotificationIcons.ts +++ b/src/page/models/NotificationIcons.ts @@ -1,5 +1,5 @@ -interface NotificationIcons { - chrome?: string; - firefox?: string; - safari?: string; +export interface NotificationIcons { + chrome: string | null; + firefox: string | null; + safari: string | null; } diff --git a/src/page/models/OutcomeRequestData.ts b/src/page/models/OutcomeRequestData.ts index 9b7fb4aa2..97dacd83d 100644 --- a/src/page/models/OutcomeRequestData.ts +++ b/src/page/models/OutcomeRequestData.ts @@ -1,4 +1,4 @@ -import type { SubscriptionModel } from 'src/core/models/SubscriptionModel'; +import type { SubscriptionTypeValue } from 'src/core/types/subscription'; export interface OutcomeRequestData { app_id: string; @@ -7,6 +7,9 @@ export interface OutcomeRequestData { notification_ids?: string[]; weight?: number; session_time?: number; - subscription?: SubscriptionModel; + subscription?: { + id: string; + type: SubscriptionTypeValue; + }; onesignal_id?: string; } diff --git a/src/page/models/SubscriptionChangeEvent.ts b/src/page/models/SubscriptionChangeEvent.ts index 1633aab34..9e0e49409 100644 --- a/src/page/models/SubscriptionChangeEvent.ts +++ b/src/page/models/SubscriptionChangeEvent.ts @@ -1,12 +1,10 @@ -type PushSubscriptionNamespaceProperties = { +interface PushSubscriptionNamespaceProperties { id: string | null | undefined; token: string | null | undefined; optedIn: boolean; -}; +} -type SubscriptionChangeEvent = { +export interface SubscriptionChangeEvent { previous: PushSubscriptionNamespaceProperties; current: PushSubscriptionNamespaceProperties; -}; - -export default SubscriptionChangeEvent; +} diff --git a/src/page/slidedown/Slidedown.ts b/src/page/slidedown/Slidedown.ts index 7509c018a..9c47dadb9 100755 --- a/src/page/slidedown/Slidedown.ts +++ b/src/page/slidedown/Slidedown.ts @@ -1,33 +1,34 @@ -import OneSignalEvent from '../../shared/services/OneSignalEvent'; +import { SERVER_CONFIG_DEFAULTS_SLIDEDOWN } from '../../shared/config/constants'; +import { Utils } from '../../shared/context/Utils'; import MainHelper from '../../shared/helpers/MainHelper'; +import PromptsHelper from '../../shared/helpers/PromptsHelper'; +import { + type SlidedownPromptOptions, + DelayedPromptType, +} from '../../shared/models/Prompts'; +import OneSignalEvent from '../../shared/services/OneSignalEvent'; +import { + COLORS, + SLIDEDOWN_CSS_CLASSES, + SLIDEDOWN_CSS_IDS, +} from '../../shared/slidedown/constants'; +import { bowserCastle } from '../../shared/utils/bowserCastle'; import { addCssClass, addDomElement, + getDomElementOrStub, getPlatformNotificationIcon, once, - removeDomElement, removeCssClass, - getDomElementOrStub, + removeDomElement, } from '../../shared/utils/utils'; -import { SERVER_CONFIG_DEFAULTS_SLIDEDOWN } from '../../shared/config/constants'; +import { InvalidChannelInputField } from '../errors/ChannelCaptureError'; +import type { NotificationIcons } from '../models/NotificationIcons'; +import type { TagCategory } from '../models/Tags'; +import ChannelCaptureContainer from './ChannelCaptureContainer'; import { getLoadingIndicatorWithColor } from './LoadingIndicator'; import { getRetryIndicator } from './RetryIndicator'; -import { - SLIDEDOWN_CSS_CLASSES, - SLIDEDOWN_CSS_IDS, - COLORS, -} from '../../shared/slidedown/constants'; -import { TagCategory } from '../models/Tags'; import { getSlidedownElement } from './SlidedownElement'; -import { Utils } from '../../shared/context/Utils'; -import ChannelCaptureContainer from './ChannelCaptureContainer'; -import PromptsHelper from '../../shared/helpers/PromptsHelper'; -import { - SlidedownPromptOptions, - DelayedPromptType, -} from '../../shared/models/Prompts'; -import { InvalidChannelInputField } from '../errors/ChannelCaptureError'; -import { bowserCastle } from '../../shared/utils/bowserCastle'; export default class Slidedown { public options: SlidedownPromptOptions; @@ -218,7 +219,7 @@ export default class Slidedown { * To be used with slidedown types other than `push` type */ removeSaveState(): void { - this.allowButton.textContent = this.positiveUpdateButton; + this.allowButton.textContent = this.positiveUpdateButton ?? ''; removeDomElement(`#${SLIDEDOWN_CSS_CLASSES.buttonIndicatorHolder}`); this.allowButton.disabled = false; removeCssClass(this.allowButton, 'disabled'); @@ -343,11 +344,11 @@ export function manageNotifyButtonStateWhileSlidedownShows(): void { const notifyButton = OneSignal.notifyButton; if ( notifyButton && - notifyButton.options.enable && - OneSignal.notifyButton.launcher.state !== 'hidden' + notifyButton.options?.enable && + OneSignal.notifyButton?.launcher?.state !== 'hidden' ) { - OneSignal.notifyButton.launcher.waitUntilShown().then(() => { - OneSignal.notifyButton.launcher.hide(); + OneSignal.notifyButton?.launcher?.waitUntilShown().then(() => { + OneSignal.notifyButton?.launcher?.hide(); }); } OneSignal.emitter.once(Slidedown.EVENTS.CLOSED, () => { diff --git a/src/page/slidedown/SlidedownElement.ts b/src/page/slidedown/SlidedownElement.ts index 98efd3eda..ec8ef2ef8 100644 --- a/src/page/slidedown/SlidedownElement.ts +++ b/src/page/slidedown/SlidedownElement.ts @@ -1,11 +1,11 @@ -import { SlidedownHtmlProps } from './types'; import { DEFAULT_ICON, - SLIDEDOWN_CSS_IDS, - SLIDEDOWN_CSS_CLASSES, SLIDEDOWN_BUTTON_CLASSES, + SLIDEDOWN_CSS_CLASSES, + SLIDEDOWN_CSS_IDS, } from '../../shared/slidedown/constants'; import { addCssClass } from '../../shared/utils/utils'; +import type { SlidedownHtmlProps } from './types'; export function getSlidedownElement(dialogProps: SlidedownHtmlProps): Element { const { icon, messageText, positiveButtonText, negativeButtonText } = diff --git a/src/page/slidedown/TaggingContainer.ts b/src/page/slidedown/TaggingContainer.ts index 2ca90a193..383cbf393 100644 --- a/src/page/slidedown/TaggingContainer.ts +++ b/src/page/slidedown/TaggingContainer.ts @@ -1,21 +1,21 @@ -import { TagCategory, TagsObjectWithBoolean } from '../models/Tags'; -import { - addDomElement, - removeDomElement, - addCssClass, - removeCssClass, - getDomElementOrStub, -} from '../../shared/utils/utils'; -import { getLoadingIndicatorWithColor } from './LoadingIndicator'; import { + COLORS, + SLIDEDOWN_CSS_CLASSES, SLIDEDOWN_CSS_IDS, TAGGING_CONTAINER_CSS_CLASSES, TAGGING_CONTAINER_CSS_IDS, TAGGING_CONTAINER_STRINGS, - COLORS, - SLIDEDOWN_CSS_CLASSES, } from '../../shared/slidedown/constants'; import TagUtils from '../../shared/utils/TagUtils'; +import { + addCssClass, + addDomElement, + getDomElementOrStub, + removeCssClass, + removeDomElement, +} from '../../shared/utils/utils'; +import type { TagCategory, TagsObjectWithBoolean } from '../models/Tags'; +import { getLoadingIndicatorWithColor } from './LoadingIndicator'; export default class TaggingContainer { public mount( diff --git a/src/page/utils/ProcessOneSignalPushCalls.ts b/src/page/utils/ProcessOneSignalPushCalls.ts index 97779a8cf..f18f1406e 100644 --- a/src/page/utils/ProcessOneSignalPushCalls.ts +++ b/src/page/utils/ProcessOneSignalPushCalls.ts @@ -1,9 +1,9 @@ -import { OneSignalDeferredLoadedCallback } from '../../page/models/OneSignalDeferredLoadedCallback'; -import OneSignalError from '../../shared/errors/OneSignalError'; +import OneSignalError from 'src/shared/errors/OneSignalError'; +import type { OneSignalDeferredLoadedCallback } from '../../page/models/OneSignalDeferredLoadedCallback'; export class ProcessOneSignalPushCalls { public static processItem( - oneSignalInstance: IOneSignal, + oneSignalInstance: typeof OneSignal, item: OneSignalDeferredLoadedCallback, ) { if (typeof item === 'function') return item(oneSignalInstance); diff --git a/src/page/utils/ReplayCallsOnOneSignal.ts b/src/page/utils/ReplayCallsOnOneSignal.ts index 561ad4bc1..54f181ce5 100644 --- a/src/page/utils/ReplayCallsOnOneSignal.ts +++ b/src/page/utils/ReplayCallsOnOneSignal.ts @@ -1,6 +1,6 @@ import OneSignal from '../../onesignal/OneSignal'; import Log from '../../shared/libraries/Log'; -import { OneSignalDeferredLoadedCallback } from '../models/OneSignalDeferredLoadedCallback'; +import type { OneSignalDeferredLoadedCallback } from '../models/OneSignalDeferredLoadedCallback'; // TODO: Renaming ReplayCallsOnOneSignal in a future commit export class ReplayCallsOnOneSignal { diff --git a/src/shared/api/OneSignalApi.ts b/src/shared/api/OneSignalApi.ts index 633d9d236..8cb6570a7 100755 --- a/src/shared/api/OneSignalApi.ts +++ b/src/shared/api/OneSignalApi.ts @@ -1,15 +1,15 @@ import JSONP from 'jsonp'; import SdkEnvironment from '../managers/SdkEnvironment'; -import { ServerAppConfig } from '../models/AppConfig'; +import type { ServerAppConfig } from '../models/AppConfig'; import { WindowEnvironmentKind } from '../models/WindowEnvironmentKind'; import OneSignalApiSW from './OneSignalApiSW'; export default class OneSignalApi { static jsonpLib( url: string, - fn: (err: Error, data: ServerAppConfig) => void, + fn: (err: Error | null, data: ServerAppConfig) => void, ) { - JSONP(url, null, fn); + JSONP(url, undefined, fn); } static async downloadServerAppConfig( @@ -20,7 +20,7 @@ export default class OneSignalApi { // Due to CloudFlare's algorithms, the .js extension is required for proper caching. Don't remove it! OneSignalApi.jsonpLib( `${SdkEnvironment.getOneSignalApiUrl().toString()}sync/${appId}/web`, - (err: Error, data: ServerAppConfig) => { + (err: Error | null, data: ServerAppConfig) => { if (err) reject(err); else { if (data.success) resolve(data); diff --git a/src/shared/api/OneSignalApiBase.ts b/src/shared/api/OneSignalApiBase.ts index df938d1ce..db0608cdb 100644 --- a/src/shared/api/OneSignalApiBase.ts +++ b/src/shared/api/OneSignalApiBase.ts @@ -6,10 +6,10 @@ import OneSignalError from '../errors/OneSignalError'; import Environment from '../helpers/Environment'; import Log from '../libraries/Log'; import SdkEnvironment from '../managers/SdkEnvironment'; -import { APIHeaders } from '../models/APIHeaders'; +import type { APIHeaders } from '../models/APIHeaders'; import { awaitableTimeout } from '../utils/AwaitableTimeout'; import { isValidUuid } from '../utils/utils'; -import OneSignalApiBaseResponse from './OneSignalApiBaseResponse'; +import type OneSignalApiBaseResponse from './OneSignalApiBaseResponse'; import { RETRY_BACKOFF } from './RetryBackoff'; type SupportedMethods = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; diff --git a/src/shared/api/OneSignalApiSW.ts b/src/shared/api/OneSignalApiSW.ts index 56bbd34f3..bb7588bc3 100644 --- a/src/shared/api/OneSignalApiSW.ts +++ b/src/shared/api/OneSignalApiSW.ts @@ -1,14 +1,17 @@ -import { IUpdateUser } from 'src/core/types/api'; +import type { IUpdateUser } from 'src/core/types/api'; import { NotificationType } from 'src/core/types/subscription'; import AliasPair from '../../core/requestService/AliasPair'; import { RequestService } from '../../core/requestService/RequestService'; -import { OutcomeRequestData } from '../../page/models/OutcomeRequestData'; +import type { OutcomeRequestData } from '../../page/models/OutcomeRequestData'; import FuturePushSubscriptionRecord from '../../page/userModel/FuturePushSubscriptionRecord'; import Utils from '../context/Utils'; import Log from '../libraries/Log'; -import { ServerAppConfig } from '../models/AppConfig'; +import type { ServerAppConfig } from '../models/AppConfig'; import { DeliveryPlatformKind } from '../models/DeliveryPlatformKind'; -import { OutcomeAttribution, OutcomeAttributionType } from '../models/Outcomes'; +import { + OutcomeAttributionType, + type OutcomeAttribution, +} from '../models/Outcomes'; import { OneSignalApiBase } from './OneSignalApiBase'; import OneSignalApiShared from './OneSignalApiShared'; diff --git a/src/shared/api/OneSignalApiShared.ts b/src/shared/api/OneSignalApiShared.ts index 9531397f9..f24484fd8 100644 --- a/src/shared/api/OneSignalApiShared.ts +++ b/src/shared/api/OneSignalApiShared.ts @@ -1,4 +1,4 @@ -import { OutcomeRequestData } from '../../page/models/OutcomeRequestData'; +import type { OutcomeRequestData } from '../../page/models/OutcomeRequestData'; import Log from '../libraries/Log'; import OneSignalApiBase from './OneSignalApiBase'; diff --git a/src/shared/config/constants.ts b/src/shared/config/constants.ts index ffd6674ca..0f989ba7f 100644 --- a/src/shared/config/constants.ts +++ b/src/shared/config/constants.ts @@ -1,4 +1,7 @@ -import { DelayedPromptType, SlidedownPromptOptions } from '../models/Prompts'; +import { + DelayedPromptType, + type SlidedownPromptOptions, +} from '../models/Prompts'; export const SERVER_CONFIG_DEFAULTS_SESSION = { reportingThreshold: 30, diff --git a/src/shared/helpers/ConfigHelper.ts b/src/shared/helpers/ConfigHelper.ts index 54d2effaf..7550fd73b 100644 --- a/src/shared/helpers/ConfigHelper.ts +++ b/src/shared/helpers/ConfigHelper.ts @@ -8,16 +8,17 @@ import Utils from '../context/Utils'; import { SdkInitError, SdkInitErrorKind } from '../errors/SdkInitError'; import SdkEnvironment from '../managers/SdkEnvironment'; import { - AppConfig, - AppUserConfig, + type AppConfig, + type AppUserConfig, ConfigIntegrationKind, - ServerAppConfig, - ServerAppPromptConfig, - ServiceWorkerConfigParams, + type ConfigIntegrationKindValue, + type ServerAppConfig, + type ServerAppPromptConfig, + type ServiceWorkerConfigParams, } from '../models/AppConfig'; import { - AppUserConfigCustomLinkOptions, - AppUserConfigPromptOptions, + type AppUserConfigCustomLinkOptions, + type AppUserConfigPromptOptions, DelayedPromptType, } from '../models/Prompts'; import { WindowEnvironmentKind } from '../models/WindowEnvironmentKind'; @@ -26,19 +27,21 @@ import TagUtils from '../utils/TagUtils'; import { ConverterHelper } from './ConverterHelper'; import PromptsHelper from './PromptsHelper'; -export enum IntegrationConfigurationKind { +export const IntegrationConfigurationKind = { /** * Configuration comes from the dashboard only. */ - Dashboard, + Dashboard: 0, /** * Configuration comes from user-provided JavaScript code only. */ - JavaScript, -} + JavaScript: 1, +} as const; +type IntegrationConfigurationKindValue = + (typeof IntegrationConfigurationKind)[keyof typeof IntegrationConfigurationKind]; export interface IntegrationCapabilities { - configuration: IntegrationConfigurationKind; + configuration: IntegrationConfigurationKindValue; } const MAX_CATEGORIES = 10; @@ -64,7 +67,7 @@ export class ConfigHelper { this.checkRestrictedOrigin(appConfig); return appConfig; } catch (e) { - if (e) { + if (e instanceof Object && 'code' in e) { if (e.code === 1) throw new SdkInitError(SdkInitErrorKind.InvalidAppId); else if (e.code === 2) throw new SdkInitError(SdkInitErrorKind.AppNotConfiguredForWebPush); @@ -119,7 +122,7 @@ export class ConfigHelper { } public static getIntegrationCapabilities( - integration: ConfigIntegrationKind, + integration: ConfigIntegrationKindValue, ): IntegrationCapabilities { switch (integration) { case ConfigIntegrationKind.Custom: @@ -178,7 +181,7 @@ export class ConfigHelper { public static getConfigIntegrationKind( serverConfig: ServerAppConfig, - ): ConfigIntegrationKind { + ): ConfigIntegrationKindValue { if (serverConfig.config.integration) return serverConfig.config.integration.kind; return ConfigIntegrationKind.Custom; @@ -517,7 +520,7 @@ export class ConfigHelper { } public static getUserConfigForConfigIntegrationKind( - configIntegrationKind: ConfigIntegrationKind, + configIntegrationKind: ConfigIntegrationKindValue, userConfig: AppUserConfig, serverConfig: ServerAppConfig, ): AppUserConfig { @@ -704,7 +707,7 @@ export class ConfigHelper { * Describes how to merge a dashboard-set subdomain with a/lack of user-supplied subdomain. */ public static hasUnsupportedSubdomainForConfigIntegrationKind( - configIntegrationKind: ConfigIntegrationKind, + configIntegrationKind: ConfigIntegrationKindValue, userConfig: AppUserConfig, serverConfig: ServerAppConfig, ): boolean { diff --git a/src/shared/helpers/ContextHelper.ts b/src/shared/helpers/ContextHelper.ts index c5d5754ad..c574d14c5 100644 --- a/src/shared/helpers/ContextHelper.ts +++ b/src/shared/helpers/ContextHelper.ts @@ -1,10 +1,10 @@ import { ServiceWorkerManager } from '../managers/ServiceWorkerManager'; import { SubscriptionManager, - SubscriptionManagerConfig, + type SubscriptionManagerConfig, } from '../managers/SubscriptionManager'; -import { AppConfig } from '../models/AppConfig'; -import { ContextSWInterface } from '../models/ContextSW'; +import type { AppConfig } from '../models/AppConfig'; +import type { ContextSWInterface } from '../models/ContextSW'; import Path from '../models/Path'; export class ContextHelper { diff --git a/src/shared/helpers/ConverterHelper.ts b/src/shared/helpers/ConverterHelper.ts index b34926bab..06c52a975 100644 --- a/src/shared/helpers/ConverterHelper.ts +++ b/src/shared/helpers/ConverterHelper.ts @@ -1,7 +1,10 @@ -import { AppUserConfig, SlidedownOptionsVersion1 } from '../models/AppConfig'; +import type { + AppUserConfig, + SlidedownOptionsVersion1, +} from '../models/AppConfig'; import { - AppUserConfigPromptOptions, - SlidedownOptions, + type AppUserConfigPromptOptions, + type SlidedownOptions, DelayedPromptType, } from '../models/Prompts'; import PromptsHelper from './PromptsHelper'; diff --git a/src/shared/helpers/EventHelper.ts b/src/shared/helpers/EventHelper.ts index 2ea404105..45dbd01b1 100755 --- a/src/shared/helpers/EventHelper.ts +++ b/src/shared/helpers/EventHelper.ts @@ -1,10 +1,10 @@ import UserNamespace from '../../onesignal/UserNamespace'; -import SubscriptionChangeEvent from '../../page/models/SubscriptionChangeEvent'; -import UserChangeEvent from '../../page/models/UserChangeEvent'; +import type SubscriptionChangeEvent from '../../page/models/SubscriptionChangeEvent'; +import type UserChangeEvent from '../../page/models/UserChangeEvent'; import Log from '../libraries/Log'; import { CustomLinkManager } from '../managers/CustomLinkManager'; -import { ContextSWInterface } from '../models/ContextSW'; -import { +import type { ContextSWInterface } from '../models/ContextSW'; +import type { NotificationClickEvent, NotificationClickEventInternal, } from '../models/NotificationEvent'; @@ -187,7 +187,7 @@ export default class EventHelper { } private static async onSubscriptionChanged_evaluateNotifyButtonDisplayPredicate() { - if (!OneSignal.config.userConfig.notifyButton) return; + if (!OneSignal.config?.userConfig.notifyButton) return; const displayPredicate = OneSignal.config.userConfig.notifyButton.displayPredicate; @@ -212,9 +212,9 @@ export default class EventHelper { } private static async onSubscriptionChanged_updateCustomLink() { - if (OneSignal.config.userConfig.promptOptions) { + if (OneSignal.config?.userConfig.promptOptions) { new CustomLinkManager( - OneSignal.config.userConfig.promptOptions.customlink, + OneSignal.config?.userConfig.promptOptions.customlink, ).initialize(); } } @@ -251,8 +251,8 @@ export default class EventHelper { static async fireStoredNotificationClicks() { await awaitOneSignalInitAndSupported(); const url = - OneSignal.config.pageUrl || - OneSignal.config.userConfig.pageUrl || + OneSignal.config?.pageUrl || + OneSignal.config?.userConfig.pageUrl || document.URL; async function fireEventWithNotification( @@ -261,7 +261,9 @@ export default class EventHelper { // Remove the notification from the recently clicked list // Once this page processes this retroactively provided clicked event, nothing should get the same event const appState = await Database.getAppState(); - appState.pendingNotificationClickEvents[selectedEvent.result.url] = null; + // @ts-expect-error - TODO: address this is a workaround to fix the type error + appState.pendingNotificationClickEvents![selectedEvent.result.url!] = + null; await Database.setAppState(appState); const timestamp = selectedEvent.timestamp; @@ -290,13 +292,13 @@ export default class EventHelper { ); if (notificationClickHandlerMatch === 'origin') { for (const clickedNotificationUrl of Object.keys( - appState.pendingNotificationClickEvents, + appState.pendingNotificationClickEvents!, )) { // Using notificationClickHandlerMatch: 'origin', as long as the notification's URL's origin matches our current tab's origin, // fire the clicked event if (new URL(clickedNotificationUrl).origin === location.origin) { const clickedNotification = - appState.pendingNotificationClickEvents[clickedNotificationUrl]; + appState.pendingNotificationClickEvents![clickedNotificationUrl]; await fireEventWithNotification(clickedNotification); } } @@ -309,13 +311,13 @@ export default class EventHelper { As a workaround, if there are no notifications for https://site.com/, we'll do a check for https://site.com. */ let pageClickedNotifications = - appState.pendingNotificationClickEvents[url]; + appState.pendingNotificationClickEvents?.[url]; if (pageClickedNotifications) { await fireEventWithNotification(pageClickedNotifications); } else if (!pageClickedNotifications && url.endsWith('/')) { const urlWithoutTrailingSlash = url.substring(0, url.length - 1); pageClickedNotifications = - appState.pendingNotificationClickEvents[urlWithoutTrailingSlash]; + appState.pendingNotificationClickEvents?.[urlWithoutTrailingSlash]; if (pageClickedNotifications) { await fireEventWithNotification(pageClickedNotifications); } diff --git a/src/shared/helpers/EventProducer.ts b/src/shared/helpers/EventProducer.ts index 50cff777f..4da288103 100644 --- a/src/shared/helpers/EventProducer.ts +++ b/src/shared/helpers/EventProducer.ts @@ -1,4 +1,4 @@ -import { IEventNotifier } from 'src/core/types/events'; +import type { IEventNotifier } from 'src/core/types/events'; export class EventProducer implements IEventNotifier { private subscribers: THandler[] = []; diff --git a/src/shared/helpers/InitHelper.ts b/src/shared/helpers/InitHelper.ts index 588fd78b7..71791e25e 100755 --- a/src/shared/helpers/InitHelper.ts +++ b/src/shared/helpers/InitHelper.ts @@ -1,9 +1,9 @@ import Bell from '../../page/bell/Bell'; -import { ContextInterface } from '../../page/models/Context'; +import type { ContextInterface } from '../../page/models/Context'; import { SdkInitError, SdkInitErrorKind } from '../errors/SdkInitError'; import Log from '../libraries/Log'; import { CustomLinkManager } from '../managers/CustomLinkManager'; -import { AppConfig } from '../models/AppConfig'; +import type { AppConfig } from '../models/AppConfig'; import { NotificationPermission } from '../models/NotificationPermission'; import { SubscriptionStrategyKind } from '../models/SubscriptionStrategyKind'; import Database from '../services/Database'; @@ -76,7 +76,8 @@ export default class InitHelper { * We don't want to resubscribe if the user is opted out, and we can't check on HTTP, because the promise will * prevent the popup from opening. */ - const isOptedOut = await OneSignal.context.subscriptionManager.isOptedOut(); + const isOptedOut = + (await OneSignal.context.subscriptionManager.isOptedOut()) ?? false; // saves isOptedOut to localStorage. used for require user interaction functionality const subscription = await Database.getSubscription(); subscription.optedOut = isOptedOut; @@ -89,7 +90,7 @@ export default class InitHelper { // saves isSubscribed to IndexedDb. used for require user interaction functionality await Database.setIsPushEnabled(!!isSubscribed); - if (OneSignal.config.userConfig.promptOptions.autoPrompt && !isOptedOut) { + if (OneSignal.config?.userConfig.promptOptions?.autoPrompt && !isOptedOut) { OneSignal.context.promptsManager.spawnAutoPrompts(); } @@ -125,8 +126,8 @@ export default class InitHelper { await OneSignal.context.updateManager.sendOnSessionUpdate(); } } else if ( - !OneSignal.config.userConfig.promptOptions.autoPrompt && - !OneSignal.config.userConfig.autoResubscribe + !OneSignal.config?.userConfig.promptOptions?.autoPrompt && + !OneSignal.config?.userConfig.autoResubscribe ) { await OneSignal.context.updateManager.sendOnSessionUpdate(); } @@ -262,7 +263,7 @@ export default class InitHelper { } protected static async showPromptsFromWebConfigEditor() { - const config: AppConfig = OneSignal.config; + const config: AppConfig = OneSignal.config!; if (config.userConfig.promptOptions) { await new CustomLinkManager( config.userConfig.promptOptions.customlink, @@ -293,7 +294,8 @@ export default class InitHelper { public static async saveInitOptions() { const opPromises: Promise[] = []; - const persistNotification = OneSignal.config.userConfig.persistNotification; + const persistNotification = + OneSignal.config?.userConfig.persistNotification; opPromises.push( Database.put('Options', { key: 'persistNotification', @@ -301,17 +303,20 @@ export default class InitHelper { }), ); - const webhookOptions = OneSignal.config.userConfig.webhooks; + const webhookOptions = OneSignal.config?.userConfig.webhooks; [ 'notification.willDisplay', 'notification.clicked', 'notification.dismissed', ].forEach((event) => { - if (webhookOptions && webhookOptions[event]) { + if ( + webhookOptions && + webhookOptions[event as keyof typeof webhookOptions] + ) { opPromises.push( Database.put('Options', { key: `webhooks.${event}`, - value: webhookOptions[event], + value: webhookOptions[event as keyof typeof webhookOptions], }), ); } else { @@ -330,7 +335,7 @@ export default class InitHelper { ); } - if (OneSignal.config.userConfig.notificationClickHandlerMatch) { + if (OneSignal.config?.userConfig.notificationClickHandlerMatch) { opPromises.push( Database.put('Options', { key: 'notificationClickHandlerMatch', @@ -346,7 +351,7 @@ export default class InitHelper { ); } - if (OneSignal.config.userConfig.notificationClickHandlerAction) { + if (OneSignal.config?.userConfig.notificationClickHandlerAction) { opPromises.push( Database.put('Options', { key: 'notificationClickHandlerAction', @@ -366,7 +371,7 @@ export default class InitHelper { public static async initSaveState(overridingPageTitle?: string) { const appId = MainHelper.getAppId(); - const config: AppConfig = OneSignal.config; + const config: AppConfig = OneSignal.config!; await Database.put('Ids', { type: 'appId', id: appId }); const pageTitle: string = overridingPageTitle || @@ -379,10 +384,10 @@ export default class InitHelper { public static async handleAutoResubscribe(isOptedOut: boolean) { Log.info('handleAutoResubscribe', { - autoResubscribe: OneSignal.config.userConfig.autoResubscribe, + autoResubscribe: OneSignal.config?.userConfig.autoResubscribe, isOptedOut, }); - if (OneSignal.config.userConfig.autoResubscribe && !isOptedOut) { + if (OneSignal.config?.userConfig.autoResubscribe && !isOptedOut) { const currentPermission: NotificationPermission = await OneSignal.context.permissionManager.getNotificationPermission( OneSignal.context.appConfig.safariWebId, diff --git a/src/shared/helpers/MainHelper.ts b/src/shared/helpers/MainHelper.ts index ddcadf283..89b4ad9f6 100755 --- a/src/shared/helpers/MainHelper.ts +++ b/src/shared/helpers/MainHelper.ts @@ -1,3 +1,4 @@ +import type { NotificationIcons } from 'src/page/models/NotificationIcons'; import { ValidatorUtils } from '../../page/utils/ValidatorUtils'; import Utils from '../context/Utils'; import { @@ -15,8 +16,8 @@ import { import Log from '../libraries/Log'; import SdkEnvironment from '../managers/SdkEnvironment'; import { - AppUserConfigPromptOptions, - SlidedownOptions, + type AppUserConfigPromptOptions, + type SlidedownOptions, } from '../models/Prompts'; import Database from '../services/Database'; import { PermissionUtils } from '../utils/PermissionUtils'; @@ -132,7 +133,7 @@ export default class MainHelper { Log.error(`API call ${url}`, 'failed with:', data.errors); throw new Error('Failed to get notification icons.'); } - return data; + return data as NotificationIcons; } public static getSlidedownOptions( @@ -142,7 +143,7 @@ export default class MainHelper { } static getFullscreenPermissionMessageOptions( - promptOptions: AppUserConfigPromptOptions, + promptOptions: AppUserConfigPromptOptions | undefined, ): AppUserConfigPromptOptions | null { if (!promptOptions) { return null; @@ -166,13 +167,13 @@ export default class MainHelper { static getPromptOptionsQueryString() { const promptOptions = MainHelper.getFullscreenPermissionMessageOptions( - OneSignal.config.userConfig.promptOptions, + OneSignal.config?.userConfig.promptOptions, ); let promptOptionsStr = ''; if (promptOptions) { const hash = MainHelper.getPromptOptionsPostHash(); for (const key of Object.keys(hash)) { - const value = hash[key]; + const value = hash[key as keyof typeof hash]; promptOptionsStr += '&' + key + '=' + value; } } @@ -181,9 +182,9 @@ export default class MainHelper { static getPromptOptionsPostHash() { const promptOptions = MainHelper.getFullscreenPermissionMessageOptions( - OneSignal.config.userConfig.promptOptions, + OneSignal.config?.userConfig.promptOptions, ); - const hash = {}; + const hash: Record = {}; if (promptOptions) { const legacyParams = { exampleNotificationTitleDesktop: 'exampleNotificationTitle', @@ -192,8 +193,10 @@ export default class MainHelper { exampleNotificationMessageMobile: 'exampleNotificationMessage', }; for (const legacyParamKey of Object.keys(legacyParams)) { - const legacyParamValue = legacyParams[legacyParamKey]; - if (promptOptions[legacyParamKey]) { + const legacyParamValue = + legacyParams[legacyParamKey as keyof typeof legacyParams]; + if (promptOptions[legacyParamKey as keyof AppUserConfigPromptOptions]) { + // @ts-expect-error - TODO: look into better typing for this promptOptions[legacyParamValue] = promptOptions[legacyParamKey]; } } @@ -213,10 +216,10 @@ export default class MainHelper { ]; for (let i = 0; i < allowedPromptOptions.length; i++) { const key = allowedPromptOptions[i]; - const value = promptOptions[key]; - const encoded_value = encodeURIComponent(value); + const value = promptOptions[key as keyof AppUserConfigPromptOptions]; + const encoded_value = encodeURIComponent(value as string); if (value || value === false || value === '') { - hash[key] = encoded_value; + hash[key as keyof typeof hash] = encoded_value; } } } @@ -236,7 +239,7 @@ export default class MainHelper { static async getCurrentPushToken(): Promise { if (Environment.useSafariLegacyPush()) { const safariToken = window.safari?.pushNotification?.permission( - OneSignal.config.safariWebId, + OneSignal.config?.safariWebId, ).deviceToken; return safariToken?.toLowerCase() || undefined; } diff --git a/src/shared/helpers/OSNotificationDatabaseSerializer.ts b/src/shared/helpers/OSNotificationDatabaseSerializer.ts index 5c3acd8cc..bb0801d41 100644 --- a/src/shared/helpers/OSNotificationDatabaseSerializer.ts +++ b/src/shared/helpers/OSNotificationDatabaseSerializer.ts @@ -1,9 +1,9 @@ -import { NotificationClickEventInternal } from '../models/NotificationEvent'; -import { +import type { IOSNotification, IOSNotificationActionButton, -} from '../models/OSNotification'; -import { +} from 'src/shared/models/OSNotification'; +import type { NotificationClickEventInternal } from '../models/NotificationEvent'; +import type { OutcomesNotificationClicked, OutcomesNotificationReceived, } from '../models/OutcomesNotificationEvents'; diff --git a/src/shared/helpers/OutcomesHelper.ts b/src/shared/helpers/OutcomesHelper.ts index af81206c0..5192388c9 100644 --- a/src/shared/helpers/OutcomesHelper.ts +++ b/src/shared/helpers/OutcomesHelper.ts @@ -1,17 +1,17 @@ +import { Utils } from '../../shared/context/Utils'; +import Log from '../libraries/Log'; +import type { OutcomeProps } from '../models/OutcomeProps'; import { - OutcomesConfig, - OutcomeAttribution, + type OutcomeAttribution, OutcomeAttributionType, - SentUniqueOutcome, + type OutcomesConfig, + type SentUniqueOutcome, } from '../models/Outcomes'; -import { OutcomesNotificationReceived } from '../models/OutcomesNotificationEvents'; +import type { OutcomesNotificationReceived } from '../models/OutcomesNotificationEvents'; import Database, { TABLE_OUTCOMES_NOTIFICATION_RECEIVED, } from '../services/Database'; -import Log from '../libraries/Log'; -import { Utils } from '../../shared/context/Utils'; -import { logMethodCall, awaitOneSignalInitAndSupported } from '../utils/utils'; -import OutcomeProps from '../models/OutcomeProps'; +import { awaitOneSignalInitAndSupported, logMethodCall } from '../utils/utils'; const SEND_OUTCOME = 'sendOutcome'; const SEND_UNIQUE_OUTCOME = 'sendUniqueOutcome'; diff --git a/src/shared/helpers/PromptsHelper.ts b/src/shared/helpers/PromptsHelper.ts index 677a5fab1..6d558585b 100644 --- a/src/shared/helpers/PromptsHelper.ts +++ b/src/shared/helpers/PromptsHelper.ts @@ -1,5 +1,9 @@ -import { SlidedownOptionsVersion1 } from '../models/AppConfig'; -import { SlidedownPromptOptions, DelayedPromptType } from '../models/Prompts'; +import type { SlidedownOptionsVersion1 } from '../models/AppConfig'; +import { + DelayedPromptType, + type DelayedPromptTypeValue, + type SlidedownPromptOptions, +} from '../models/Prompts'; export default class PromptsHelper { static isCategorySlidedownConfigured( @@ -29,7 +33,7 @@ export default class PromptsHelper { static getFirstSlidedownPromptOptionsWithType( prompts: SlidedownPromptOptions[] | undefined, - type: DelayedPromptType, + type: DelayedPromptTypeValue, ): SlidedownPromptOptions | undefined { return prompts ? prompts.filter((options) => options.type === type)[0] @@ -49,7 +53,9 @@ export default class PromptsHelper { return false; } - static isSlidedownPushDependent(slidedownType: DelayedPromptType): boolean { + static isSlidedownPushDependent( + slidedownType: DelayedPromptTypeValue, + ): boolean { return ( slidedownType === DelayedPromptType.Push || slidedownType === DelayedPromptType.Category diff --git a/src/shared/helpers/ServiceWorkerHelper.ts b/src/shared/helpers/ServiceWorkerHelper.ts index d30fb3d46..f98444c9a 100755 --- a/src/shared/helpers/ServiceWorkerHelper.ts +++ b/src/shared/helpers/ServiceWorkerHelper.ts @@ -1,18 +1,19 @@ import { cancelableTimeout, - CancelableTimeoutPromise, + type CancelableTimeoutPromise, } from '../../sw/helpers/CancelableTimeout'; import Log from '../../sw/libraries/Log'; -import { OSServiceWorkerFields } from '../../sw/serviceWorker/types'; +import type { OSServiceWorkerFields } from '../../sw/serviceWorker/types'; import OneSignalApiSW from '../api/OneSignalApiSW'; import Utils from '../context/Utils'; -import { OutcomesConfig } from '../models/Outcomes'; -import { OutcomesNotificationClicked } from '../models/OutcomesNotificationEvents'; +import type { OutcomesConfig } from '../models/Outcomes'; +import type { OutcomesNotificationClicked } from '../models/OutcomesNotificationEvents'; import Path from '../models/Path'; import { initializeNewSession, - Session, + type Session, SessionOrigin, + type SessionOriginValue, SessionStatus, } from '../models/Session'; import Database from '../services/Database'; @@ -25,7 +26,7 @@ export default class ServiceWorkerHelper { public static getServiceWorkerHref( config: ServiceWorkerManagerConfig, appId: string, - sdkVersion: number, + sdkVersion: string, ): string { return ServiceWorkerHelper.appendServiceWorkerParams( config.workerPath.getFullPath(), @@ -37,7 +38,7 @@ export default class ServiceWorkerHelper { private static appendServiceWorkerParams( workerFullPath: string, appId: string, - sdkVersion: number, + sdkVersion: string, ): string { const fullPath = new URL(workerFullPath, OneSignalUtils.getBaseUrl()).href; const appIdAsQueryParam = Utils.encodeHashAsUriComponent({ appId }); @@ -53,7 +54,7 @@ export default class ServiceWorkerHelper { subscriptionId: string, sessionThresholdInSeconds: number, sendOnFocusEnabled: boolean, - sessionOrigin: SessionOrigin, + sessionOrigin: SessionOriginValue, outcomesConfig: OutcomesConfig, ): Promise { const existingSession = await Database.getCurrentSession(); @@ -201,7 +202,7 @@ export default class ServiceWorkerHelper { appId: string, onesignalId: string, subscriptionId: string, - sessionOrigin: SessionOrigin, + sessionOrigin: SessionOriginValue, session: Session, ) { if (sessionOrigin === SessionOrigin.UserCreate) { @@ -264,21 +265,21 @@ export default class ServiceWorkerHelper { } } -export enum ServiceWorkerActiveState { +export const ServiceWorkerActiveState = { /** * OneSignalSDKWorker.js, or the equivalent custom file name, is active. */ - OneSignalWorker = 'OneSignal Worker', + OneSignalWorker: 'OneSignal Worker', /** * A service worker is active, but it is not OneSignalSDKWorker.js * (or the equivalent custom file names as provided by user config). */ - ThirdParty = '3rd Party', + ThirdParty: '3rd Party', /** * No service worker is installed. */ - None = 'None', -} + None: 'None', +} as const; export interface ServiceWorkerManagerConfig { /** diff --git a/src/shared/helpers/SubscriptionHelper.ts b/src/shared/helpers/SubscriptionHelper.ts index eeb561695..bceac8c16 100755 --- a/src/shared/helpers/SubscriptionHelper.ts +++ b/src/shared/helpers/SubscriptionHelper.ts @@ -1,8 +1,8 @@ import { SubscriptionChannel, - SubscriptionChannelValue, + type SubscriptionChannelValue, SubscriptionType, - SubscriptionTypeValue, + type SubscriptionTypeValue, } from 'src/core/types/subscription'; import { InvalidStateError, diff --git a/src/shared/libraries/WorkerMessenger.ts b/src/shared/libraries/WorkerMessenger.ts index 5e0bdff8c..3acd15bfd 100644 --- a/src/shared/libraries/WorkerMessenger.ts +++ b/src/shared/libraries/WorkerMessenger.ts @@ -5,33 +5,36 @@ import { import SdkEnvironment from '../managers/SdkEnvironment'; import { WindowEnvironmentKind } from '../models/WindowEnvironmentKind'; -import { Serializable } from '../../page/models/Serializable'; +import type { Serializable } from '../../page/models/Serializable'; import ServiceWorkerUtilHelper from '../../sw/helpers/ServiceWorkerUtilHelper'; import Environment from '../helpers/Environment'; -import { ContextSWInterface } from '../models/ContextSW'; +import type { ContextSWInterface } from '../models/ContextSW'; import Log from './Log'; /** * NOTE: This file contains a mix of code that runs in ServiceWorker and Page contexts */ -export enum WorkerMessengerCommand { - WorkerVersion = 'GetWorkerVersion', - Subscribe = 'Subscribe', - SubscribeNew = 'SubscribeNew', - NotificationWillDisplay = 'notification.willDisplay', - NotificationClicked = 'notification.clicked', - NotificationDismissed = 'notification.dismissed', - RedirectPage = 'command.redirect', - SessionUpsert = 'os.session.upsert', - SessionDeactivate = 'os.session.deactivate', - AreYouVisible = 'os.page_focused_request', - AreYouVisibleResponse = 'os.page_focused_response', - SetLogging = 'os.set_sw_logging', -} +export const WorkerMessengerCommand = { + WorkerVersion: 'GetWorkerVersion', + Subscribe: 'Subscribe', + SubscribeNew: 'SubscribeNew', + NotificationWillDisplay: 'notification.willDisplay', + NotificationClicked: 'notification.clicked', + NotificationDismissed: 'notification.dismissed', + RedirectPage: 'command.redirect', + SessionUpsert: 'os.session.upsert', + SessionDeactivate: 'os.session.deactivate', + AreYouVisible: 'os.page_focused_request', + AreYouVisibleResponse: 'os.page_focused_response', + SetLogging: 'os.set_sw_logging', +} as const; + +export type WorkerMessengerCommandValue = + (typeof WorkerMessengerCommand)[keyof typeof WorkerMessengerCommand]; export interface WorkerMessengerMessage { - command: WorkerMessengerCommand; + command: WorkerMessengerCommandValue; payload: WorkerMessengerPayload; } @@ -50,7 +53,7 @@ export class WorkerMessengerReplyBuffer { } public addListener( - command: WorkerMessengerCommand, + command: WorkerMessengerCommandValue, callback: (param: unknown) => void, onceListenerOnly: boolean, ) { @@ -65,12 +68,12 @@ export class WorkerMessengerReplyBuffer { } public findListenersForMessage( - command: WorkerMessengerCommand, + command: WorkerMessengerCommandValue, ): WorkerMessengerReplyBufferRecord[] { return this.replies[command.toString()] || []; } - public deleteListenerRecords(command: WorkerMessengerCommand) { + public deleteListenerRecords(command: WorkerMessengerCommandValue) { this.replies[command.toString()] = null; } @@ -79,7 +82,7 @@ export class WorkerMessengerReplyBuffer { } public deleteListenerRecord( - command: WorkerMessengerCommand, + command: WorkerMessengerCommandValue, targetRecord: object, ) { const listenersForCommand = this.replies[command.toString()]; @@ -127,7 +130,7 @@ export class WorkerMessenger { * Broadcasts a message from a service worker to all clients, including uncontrolled clients. */ async broadcast( - command: WorkerMessengerCommand, + command: WorkerMessengerCommandValue, payload: WorkerMessengerPayload, ) { if (SdkEnvironment.getWindowEnv() !== WindowEnvironmentKind.ServiceWorker) @@ -156,7 +159,7 @@ export class WorkerMessenger { Sends a postMessage() to the supplied windowClient */ async unicast( - command: WorkerMessengerCommand, + command: WorkerMessengerCommandValue, payload?: WorkerMessengerPayload, windowClient?: Client, ) { @@ -188,7 +191,7 @@ export class WorkerMessenger { } public async directPostMessageToSW( - command: WorkerMessengerCommand, + command: WorkerMessengerCommandValue, payload?: WorkerMessengerPayload, ): Promise { Log.debug( @@ -254,7 +257,7 @@ export class WorkerMessenger { ); } - onWorkerMessageReceivedFromPage(event: ExtendableMessageEvent) { + onWorkerMessageReceivedFromPage(event: MessageEvent) { const data: WorkerMessengerMessage = event.data; /* If this message doesn't contain our expected fields, discard the message */ @@ -295,7 +298,7 @@ export class WorkerMessenger { message topic. If no one is listening to the message, it is discarded; otherwise, the listener callback is executed. */ - onPageMessageReceivedFromServiceWorker(event: ExtendableMessageEvent) { + onPageMessageReceivedFromServiceWorker(event: MessageEvent) { const data: WorkerMessengerMessage = event.data; /* If this message doesn't contain our expected fields, discard the message */ @@ -329,7 +332,7 @@ export class WorkerMessenger { message to the window frame with the specific command. */ on( - command: WorkerMessengerCommand, + command: WorkerMessengerCommandValue, callback: (WorkerMessengerPayload: any) => void, ): void { this.replies.addListener(command, callback, false); @@ -342,7 +345,7 @@ export class WorkerMessenger { The callback is executed once at most. */ once( - command: WorkerMessengerCommand, + command: WorkerMessengerCommandValue, callback: (WorkerMessengerPayload: any) => void, ): void { this.replies.addListener(command, callback, true); @@ -352,7 +355,7 @@ export class WorkerMessenger { Unsubscribe a callback from being notified about service worker messages with the specified command. */ - off(command?: WorkerMessengerCommand): void { + off(command?: WorkerMessengerCommandValue): void { if (command) { this.replies.deleteListenerRecords(command); } else { diff --git a/src/shared/managers/CustomLinkManager.ts b/src/shared/managers/CustomLinkManager.ts index fa900c286..ad7cc0efc 100644 --- a/src/shared/managers/CustomLinkManager.ts +++ b/src/shared/managers/CustomLinkManager.ts @@ -1,11 +1,11 @@ import { ResourceLoadState } from '../../page/services/DynamicResourceLoader'; +import Log from '../libraries/Log'; +import type { AppUserConfigCustomLinkOptions } from '../models/Prompts'; import { CUSTOM_LINK_CSS_CLASSES, CUSTOM_LINK_CSS_SELECTORS, } from '../slidedown/constants'; import { addCssClass } from '../utils/utils'; -import Log from '../libraries/Log'; -import { AppUserConfigCustomLinkOptions } from '../models/Prompts'; export class CustomLinkManager { private config: AppUserConfigCustomLinkOptions | undefined; diff --git a/src/shared/managers/ServiceWorkerManager.ts b/src/shared/managers/ServiceWorkerManager.ts index 29a544f91..96857974a 100644 --- a/src/shared/managers/ServiceWorkerManager.ts +++ b/src/shared/managers/ServiceWorkerManager.ts @@ -5,20 +5,20 @@ import Environment from '../helpers/Environment'; import EventHelper from '../helpers/EventHelper'; import ServiceWorkerHelper, { ServiceWorkerActiveState, - ServiceWorkerManagerConfig, + type ServiceWorkerManagerConfig, } from '../helpers/ServiceWorkerHelper'; import Log from '../libraries/Log'; import { WorkerMessengerCommand } from '../libraries/WorkerMessenger'; -import { ContextSWInterface } from '../models/ContextSW'; +import type { ContextSWInterface } from '../models/ContextSW'; import { - NotificationClickEventInternal, - NotificationForegroundWillDisplayEvent, - NotificationForegroundWillDisplayEventSerializable, + type NotificationClickEventInternal, + type NotificationForegroundWillDisplayEvent, + type NotificationForegroundWillDisplayEventSerializable, } from '../models/NotificationEvent'; import Path from '../models/Path'; import { - PageVisibilityRequest, - PageVisibilityResponse, + type PageVisibilityRequest, + type PageVisibilityResponse, } from '../models/Session'; import Database from '../services/Database'; import OneSignalEvent from '../services/OneSignalEvent'; @@ -39,7 +39,7 @@ export class ServiceWorkerManager { * WARNING: This might be a non-OneSignal service worker, use * getOneSignalRegistration() instead if you need this guarantee. */ - private async getRegistration(): Promise< + public async getRegistration(): Promise< ServiceWorkerRegistration | undefined > { return ServiceWorkerUtilHelper.getRegistration( diff --git a/src/shared/managers/SubscriptionManager.test.ts b/src/shared/managers/SubscriptionManager.test.ts index dc2e793f3..25873cc32 100644 --- a/src/shared/managers/SubscriptionManager.test.ts +++ b/src/shared/managers/SubscriptionManager.test.ts @@ -15,7 +15,7 @@ import { RawPushSubscription } from '../models/RawPushSubscription'; import { IDManager } from './IDManager'; import { SubscriptionManager, - SubscriptionManagerConfig, + type SubscriptionManagerConfig, } from './SubscriptionManager'; const subConfig: SubscriptionManagerConfig = { diff --git a/src/shared/managers/SubscriptionManager.ts b/src/shared/managers/SubscriptionManager.ts index 635581b5f..acb0aea0b 100644 --- a/src/shared/managers/SubscriptionManager.ts +++ b/src/shared/managers/SubscriptionManager.ts @@ -1,6 +1,6 @@ import { NotificationType, - NotificationTypeValue, + type NotificationTypeValue, } from 'src/core/types/subscription'; import UserDirector from 'src/onesignal/UserDirector'; import LoginManager from 'src/page/managers/LoginManager'; @@ -22,9 +22,9 @@ import SubscriptionError, { import Environment from '../helpers/Environment'; import { ServiceWorkerActiveState } from '../helpers/ServiceWorkerHelper'; import Log from '../libraries/Log'; -import { ContextSWInterface } from '../models/ContextSW'; +import type { ContextSWInterface } from '../models/ContextSW'; import { NotificationPermission } from '../models/NotificationPermission'; -import { PushSubscriptionState } from '../models/PushSubscriptionState'; +import type { PushSubscriptionState } from '../models/PushSubscriptionState'; import { RawPushSubscription } from '../models/RawPushSubscription'; import { SessionOrigin } from '../models/Session'; import { Subscription } from '../models/Subscription'; @@ -47,12 +47,12 @@ export interface SubscriptionManagerConfig { /** * The VAPID public key to use for Chrome-like browsers, including Opera and Yandex browser. */ - vapidPublicKey: string; + vapidPublicKey?: string; /** * A globally shared VAPID public key to use for the Firefox browser, which does not use * VAPID for authentication but for application identification and uses a single */ - onesignalVapidPublicKey: string; + onesignalVapidPublicKey?: string; } export type SubscriptionStateServiceWorkerNotIntalled = Exclude< @@ -253,7 +253,7 @@ export class SubscriptionManager { * records are marked with a special subscription state for tracking purposes. */ public async registerSubscription( - pushSubscription: RawPushSubscription, + pushSubscription: RawPushSubscription | undefined, // eslint-disable-next-line @typescript-eslint/no-unused-vars _subscriptionState?: NotificationTypeValue | null, ): Promise { diff --git a/src/shared/managers/UpdateManager.ts b/src/shared/managers/UpdateManager.ts index 09a51980f..c7e9b9f57 100644 --- a/src/shared/managers/UpdateManager.ts +++ b/src/shared/managers/UpdateManager.ts @@ -1,13 +1,11 @@ -import Log from '../libraries/Log'; -import { ContextSWInterface } from '../models/ContextSW'; - -import { OutcomeRequestData } from '../../page/models/OutcomeRequestData'; - import { NotificationType } from 'src/core/types/subscription'; import { isCompleteSubscriptionObject } from '../../core/utils/typePredicates'; import User from '../../onesignal/User'; +import type { OutcomeRequestData } from '../../page/models/OutcomeRequestData'; import FuturePushSubscriptionRecord from '../../page/userModel/FuturePushSubscriptionRecord'; import OneSignalApiShared from '../api/OneSignalApiShared'; +import Log from '../libraries/Log'; +import type { ContextSWInterface } from '../models/ContextSW'; import { SessionOrigin } from '../models/Session'; import { logMethodCall } from '../utils/utils'; diff --git a/src/shared/managers/sessionManager/SessionManager.ts b/src/shared/managers/sessionManager/SessionManager.ts index d2701b83a..e0ada5feb 100644 --- a/src/shared/managers/sessionManager/SessionManager.ts +++ b/src/shared/managers/sessionManager/SessionManager.ts @@ -1,11 +1,11 @@ -import { IUpdateUser } from 'src/core/types/api'; +import type { IUpdateUser } from 'src/core/types/api'; import { NotificationType } from 'src/core/types/subscription'; import AliasPair from '../../../core/requestService/AliasPair'; import { RequestService } from '../../../core/requestService/RequestService'; import { isCompleteSubscriptionObject } from '../../../core/utils/typePredicates'; import User from '../../../onesignal/User'; import LoginManager from '../../../page/managers/LoginManager'; -import { ContextInterface } from '../../../page/models/Context'; +import type { ContextInterface } from '../../../page/models/Context'; import Utils from '../../../shared/context/Utils'; import OneSignalError from '../../../shared/errors/OneSignalError'; import MainHelper from '../../helpers/MainHelper'; @@ -13,10 +13,11 @@ import Log from '../../libraries/Log'; import { WorkerMessengerCommand } from '../../libraries/WorkerMessenger'; import { SessionOrigin, - UpsertOrDeactivateSessionPayload, + type SessionOriginValue, + type UpsertOrDeactivateSessionPayload, } from '../../models/Session'; import { OneSignalUtils } from '../../utils/OneSignalUtils'; -import { ISessionManager } from './types'; +import type { ISessionManager } from './types'; export class SessionManager implements ISessionManager { private context: ContextInterface; @@ -29,7 +30,7 @@ export class SessionManager implements ISessionManager { async notifySWToUpsertSession( onesignalId: string, subscriptionId: string, - sessionOrigin: SessionOrigin, + sessionOrigin: SessionOriginValue, ): Promise { const payload: UpsertOrDeactivateSessionPayload = { onesignalId, @@ -57,7 +58,7 @@ export class SessionManager implements ISessionManager { async notifySWToDeactivateSession( onesignalId: string, subscriptionId: string, - sessionOrigin: SessionOrigin, + sessionOrigin: SessionOriginValue, ): Promise { const payload: UpsertOrDeactivateSessionPayload = { appId: this.context.appConfig.appId, diff --git a/src/shared/managers/sessionManager/types.ts b/src/shared/managers/sessionManager/types.ts index c67058c39..a23bbb588 100644 --- a/src/shared/managers/sessionManager/types.ts +++ b/src/shared/managers/sessionManager/types.ts @@ -1,7 +1,7 @@ -import { SessionOrigin } from '../../models/Session'; +import type { SessionOriginValue } from '../../models/Session'; export interface ISessionManager { - sendOnSessionUpdateFromPage: () => Promise; setupSessionEventListeners(): void; - upsertSession: (sessionOrigin: SessionOrigin) => Promise; + upsertSession: (sessionOrigin: SessionOriginValue) => Promise; + sendOnSessionUpdateFromPage: () => Promise; } diff --git a/src/shared/models/APIHeaders.ts b/src/shared/models/APIHeaders.ts index ab97bdcc5..64b47971c 100644 --- a/src/shared/models/APIHeaders.ts +++ b/src/shared/models/APIHeaders.ts @@ -1,4 +1,4 @@ -export type APIHeaders = { +export interface APIHeaders { Authorization?: string; [key: string]: any; -}; +} diff --git a/src/shared/models/Action.ts b/src/shared/models/Action.ts deleted file mode 100755 index 014864d6c..000000000 --- a/src/shared/models/Action.ts +++ /dev/null @@ -1,3 +0,0 @@ -interface Action { - (item: T): void; -} diff --git a/src/shared/models/AppConfig.ts b/src/shared/models/AppConfig.ts index 7931eab69..bdcc8997d 100755 --- a/src/shared/models/AppConfig.ts +++ b/src/shared/models/AppConfig.ts @@ -1,6 +1,6 @@ -import { Categories } from '../../page/models/Tags'; -import { OutcomesConfig, OutcomesServerConfig } from './Outcomes'; -import { +import type { Categories } from '../../page/models/Tags'; +import type { OutcomesConfig, OutcomesServerConfig } from './Outcomes'; +import type { AppUserConfigNotifyButton, AppUserConfigPromptOptions, CustomLinkSize, @@ -51,29 +51,36 @@ export interface AppConfig { siteName: string; } -export enum ConfigIntegrationKind { - TypicalSite = 'typical', - WordPress = 'wordpress', - Shopify = 'shopify', - Blogger = 'blogger', - Magento = 'magento', - Drupal = 'drupal', - SquareSpace = 'squarespace', - Joomla = 'joomla', - Weebly = 'weebly', - Wix = 'wix', - Custom = 'custom', -} +export const ConfigIntegrationKind = { + TypicalSite: 'typical', + WordPress: 'wordpress', + Shopify: 'shopify', + Blogger: 'blogger', + Magento: 'magento', + Drupal: 'drupal', + SquareSpace: 'squarespace', + Joomla: 'joomla', + Weebly: 'weebly', + Wix: 'wix', + Custom: 'custom', +} as const; -export enum NotificationClickMatchBehavior { - Exact = 'exact', - Origin = 'origin', -} +export type ConfigIntegrationKindValue = + (typeof ConfigIntegrationKind)[keyof typeof ConfigIntegrationKind]; -export enum NotificationClickActionBehavior { - Navigate = 'navigate', - Focus = 'focus', -} +export const NotificationClickMatchBehavior = { + Exact: 'exact', + Origin: 'origin', +} as const; +type NotificationClickMatchBehaviorValue = + (typeof NotificationClickMatchBehavior)[keyof typeof NotificationClickMatchBehavior]; + +export const NotificationClickActionBehavior = { + Navigate: 'navigate', + Focus: 'focus', +} as const; +type NotificationClickActionBehaviorValue = + (typeof NotificationClickActionBehavior)[keyof typeof NotificationClickActionBehavior]; export interface AppUserConfig { [key: string]: any; @@ -89,8 +96,8 @@ export interface AppUserConfig { notifyButton?: Partial; persistNotification?: boolean; webhooks?: AppUserConfigWebhooks; - notificationClickHandlerMatch?: NotificationClickMatchBehavior; - notificationClickHandlerAction?: NotificationClickActionBehavior; + notificationClickHandlerMatch?: NotificationClickMatchBehaviorValue; + notificationClickHandlerAction?: NotificationClickActionBehaviorValue; pageUrl?: string; outcomes?: OutcomesConfig; serviceWorkerOverrideForTypical?: boolean; @@ -237,7 +244,7 @@ export interface ServerAppConfig { notificationDisplayedHook?: string; }; integration: { - kind: ConfigIntegrationKind; + kind: ConfigIntegrationKindValue; }; serviceWorker: { path?: string; @@ -254,8 +261,8 @@ export interface ServerAppConfig { }; notificationBehavior?: { click: { - match: NotificationClickMatchBehavior; - action: NotificationClickActionBehavior; + match: NotificationClickMatchBehaviorValue; + action: NotificationClickActionBehaviorValue; }; display: { persist: boolean; diff --git a/src/shared/models/AppState.ts b/src/shared/models/AppState.ts index 0d65a3764..a22382f5c 100755 --- a/src/shared/models/AppState.ts +++ b/src/shared/models/AppState.ts @@ -1,4 +1,4 @@ -import { NotificationClickEventInternal } from './NotificationEvent'; +import type { NotificationClickEventInternal } from './NotificationEvent'; // NotificationsClickEvents that are waiting to fire until these conditions are meet: // 1. Page is opened to the result.url; that is once a page is open to the intended URL diff --git a/src/shared/models/ContextSW.ts b/src/shared/models/ContextSW.ts index ac476a4ae..22e15b717 100644 --- a/src/shared/models/ContextSW.ts +++ b/src/shared/models/ContextSW.ts @@ -1,13 +1,13 @@ +import { SessionManager } from '../../sw/managers/sessionManager/SessionManager'; +import ContextHelper from '../helpers/ContextHelper'; import { WorkerMessenger } from '../libraries/WorkerMessenger'; -import { ServiceWorkerManager } from '../managers/ServiceWorkerManager'; -import { SubscriptionManager } from '../managers/SubscriptionManager'; -import { AppConfig } from './AppConfig'; import { PageViewManager } from '../managers/PageViewManager'; import PermissionManager from '../managers/PermissionManager'; -import ContextHelper from '../helpers/ContextHelper'; +import { ServiceWorkerManager } from '../managers/ServiceWorkerManager'; +import { SubscriptionManager } from '../managers/SubscriptionManager'; import { UpdateManager } from '../managers/UpdateManager'; -import { ISessionManager } from '../managers/sessionManager/types'; -import { SessionManager } from '../../sw/managers/sessionManager/SessionManager'; +import type { ISessionManager } from '../managers/sessionManager/types'; +import type { AppConfig } from './AppConfig'; // TODO: Ideally this file should only import classes used by ServiceWorker.ts. // Example, ServiceWorkerManager should be remove as it is used by the page / browser, diff --git a/src/shared/models/NotificationEvent.ts b/src/shared/models/NotificationEvent.ts index 0d3841d05..185b21bb3 100644 --- a/src/shared/models/NotificationEvent.ts +++ b/src/shared/models/NotificationEvent.ts @@ -1,4 +1,4 @@ -import { IOSNotification } from './OSNotification'; +import type { IOSNotification } from './OSNotification'; export interface NotificationClickEvent { readonly notification: IOSNotification; diff --git a/src/shared/models/OSNotification.ts b/src/shared/models/OSNotification.ts index 0fe49a931..2d045c38c 100755 --- a/src/shared/models/OSNotification.ts +++ b/src/shared/models/OSNotification.ts @@ -102,3 +102,9 @@ export interface IMutableOSNotificationActionButton icon?: string; launchURL?: string; } + +export interface NotificationAction { + action: string; + title: string; + icon?: string; +} diff --git a/src/shared/models/OutcomeProps.ts b/src/shared/models/OutcomeProps.ts index e41734159..c6152a512 100644 --- a/src/shared/models/OutcomeProps.ts +++ b/src/shared/models/OutcomeProps.ts @@ -1,7 +1,7 @@ -import { OutcomeAttributionType } from './Outcomes'; +import type { OutcomeAttributionTypeValue } from './Outcomes'; -export default interface OutcomeProps { - type: OutcomeAttributionType; +export interface OutcomeProps { + type: OutcomeAttributionTypeValue; notificationIds: string[]; weight?: number | undefined; } diff --git a/src/shared/models/Outcomes.ts b/src/shared/models/Outcomes.ts index 8ad8db4f1..e8a47b5cb 100644 --- a/src/shared/models/Outcomes.ts +++ b/src/shared/models/Outcomes.ts @@ -28,15 +28,18 @@ export interface OutcomesConfig { }; } -export enum OutcomeAttributionType { - Direct = 1, - Indirect = 2, - Unattributed = 3, - NotSupported = 4, -} +export const OutcomeAttributionType = { + Direct: 1, + Indirect: 2, + Unattributed: 3, + NotSupported: 4, +} as const; + +export type OutcomeAttributionTypeValue = + (typeof OutcomeAttributionType)[keyof typeof OutcomeAttributionType]; export interface OutcomeAttribution { - type: OutcomeAttributionType; + type: OutcomeAttributionTypeValue; notificationIds: string[]; } diff --git a/src/shared/models/Prompts.ts b/src/shared/models/Prompts.ts index 59d50fa49..92a0f495e 100644 --- a/src/shared/models/Prompts.ts +++ b/src/shared/models/Prompts.ts @@ -1,13 +1,16 @@ -import { TagCategory } from '../../page/models/Tags'; +import type { TagCategory } from '../../page/models/Tags'; -export enum DelayedPromptType { - Native = 'native', // native push - Push = 'push', // slidedown w/ push only - Category = 'category', // slidedown w/ push + categories - Sms = 'sms', // sms only - Email = 'email', // email only - SmsAndEmail = 'smsAndEmail', // sms and email only -} +export const DelayedPromptType = { + Native: 'native', // native push + Push: 'push', // slidedown w/ push only + Category: 'category', // slidedown w/ push + categories + Sms: 'sms', // sms only + Email: 'email', // email only + SmsAndEmail: 'smsAndEmail', // sms and email only +}; + +export type DelayedPromptTypeValue = + (typeof DelayedPromptType)[keyof typeof DelayedPromptType]; interface BasePromptOptions { enabled: boolean; @@ -24,7 +27,7 @@ export interface SlidedownOptions { } export interface SlidedownPromptOptions { - type: DelayedPromptType; + type: DelayedPromptTypeValue; text: SlidedownTextOptions; autoPrompt: boolean; icon?: string | null; // url diff --git a/src/shared/models/RawPushSubscription.ts b/src/shared/models/RawPushSubscription.ts index 4905ac376..ff1a7ffd4 100644 --- a/src/shared/models/RawPushSubscription.ts +++ b/src/shared/models/RawPushSubscription.ts @@ -1,4 +1,4 @@ -import { Serializable } from '../../page/models/Serializable'; +import type { Serializable } from '../../page/models/Serializable'; export class RawPushSubscription implements Serializable { /** @@ -45,14 +45,14 @@ export class RawPushSubscription implements Serializable { if (p256dh) { // Base64 encode the ArrayBuffer (not URL-Safe, using standard Base64) const p256dh_base64encoded = btoa( - String.fromCharCode.apply(null, new Uint8Array(p256dh)), + String.fromCharCode(...new Uint8Array(p256dh)), ); rawPushSubscription.w3cP256dh = p256dh_base64encoded; } if (auth) { // Base64 encode the ArrayBuffer (not URL-Safe, using standard Base64) const auth_base64encoded = btoa( - String.fromCharCode.apply(null, new Uint8Array(auth)), + String.fromCharCode(...new Uint8Array(auth)), ); rawPushSubscription.w3cAuth = auth_base64encoded; } diff --git a/src/shared/models/Session.ts b/src/shared/models/Session.ts index 3755164bd..332d64423 100644 --- a/src/shared/models/Session.ts +++ b/src/shared/models/Session.ts @@ -1,20 +1,26 @@ -import { OutcomesConfig } from './Outcomes'; +import type { OutcomesConfig } from './Outcomes'; -export enum SessionStatus { - Active = 'active', - Inactive = 'inactive', -} +export const SessionStatus = { + Active: 'active', + Inactive: 'inactive', +} as const; -export enum SessionOrigin { - UserCreate = 1, - UserNewSession = 2, - VisibilityVisible = 3, - VisibilityHidden = 4, - BeforeUnload = 5, - PageRefresh = 6, - Focus = 7, - Blur = 8, -} +export type SessionStatusValue = + (typeof SessionStatus)[keyof typeof SessionStatus]; + +export const SessionOrigin = { + UserCreate: 1, + UserNewSession: 2, + VisibilityVisible: 3, + VisibilityHidden: 4, + BeforeUnload: 5, + PageRefresh: 6, + Focus: 7, + Blur: 8, +} as const; + +export type SessionOriginValue = + (typeof SessionOrigin)[keyof typeof SessionOrigin]; export interface Session { sessionKey: string; // indexDb keyPath, always ONESIGNAL_SESSION_KEY @@ -22,7 +28,7 @@ export interface Session { startTimestamp: number; accumulatedDuration: number; notificationId: string | null; // for direct clicks - status: SessionStatus; + status: SessionStatusValue; lastDeactivatedTimestamp: number | null; lastActivatedTimestamp: number; } @@ -32,7 +38,7 @@ type NewSessionOptions = Partial & { appId: string }; interface BaseSessionPayload { sessionThreshold: number; enableSessionDuration: boolean; - sessionOrigin: SessionOrigin; + sessionOrigin: SessionOriginValue; isSafari: boolean; outcomesConfig: OutcomesConfig; } diff --git a/src/shared/models/Subscription.ts b/src/shared/models/Subscription.ts index 8c5381da2..ec5c60d61 100755 --- a/src/shared/models/Subscription.ts +++ b/src/shared/models/Subscription.ts @@ -1,4 +1,4 @@ -import { Serializable } from '../../page/models/Serializable'; +import type { Serializable } from '../../page/models/Serializable'; export class Subscription implements Serializable { /** diff --git a/src/shared/services/Database.ts b/src/shared/services/Database.ts index 3a33513ec..5b198f0ee 100644 --- a/src/shared/services/Database.ts +++ b/src/shared/services/Database.ts @@ -1,32 +1,40 @@ import Emitter from '../libraries/Emitter'; import IndexedDb from './IndexedDb'; -import { ICreateUserSubscription, IUserProperties } from 'src/core/types/api'; -import { ModelNameType } from 'src/core/types/models'; +import type { + ICreateUserSubscription, + IUserProperties, +} from 'src/core/types/api'; +import type { ModelNameType } from 'src/core/types/models'; import { - NotificationClickForOpenHandlingSchema, + type NotificationClickForOpenHandlingSchema, NotificationClickForOpenHandlingSerializer, NotificationClickedForOutcomesSerializer, - NotificationReceivedForOutcomesSchema, + type NotificationReceivedForOutcomesSchema, NotificationReceivedForOutcomesSerializer, } from '../helpers/OSNotificationDatabaseSerializer'; import Log from '../libraries/Log'; -import { AppConfig } from '../models/AppConfig'; -import { AppState, PendingNotificationClickEvents } from '../models/AppState'; -import { NotificationClickEventInternal } from '../models/NotificationEvent'; -import { IOSNotification } from '../models/OSNotification'; -import { SentUniqueOutcome } from '../models/Outcomes'; +import type { AppConfig } from '../models/AppConfig'; import { + AppState, + type PendingNotificationClickEvents, +} from '../models/AppState'; +import type { NotificationClickEventInternal } from '../models/NotificationEvent'; +import type { IOSNotification } from '../models/OSNotification'; +import type { SentUniqueOutcome } from '../models/Outcomes'; +import type { OutcomesNotificationClicked, OutcomesNotificationReceived, } from '../models/OutcomesNotificationEvents'; -import { ONESIGNAL_SESSION_KEY, Session } from '../models/Session'; +import { ONESIGNAL_SESSION_KEY, type Session } from '../models/Session'; import { Subscription } from '../models/Subscription'; import { UserState } from '../models/UserState'; -enum DatabaseEventName { - SET, -} +const DatabaseEventName = { + SET: 0, +} as const; +type DatabaseEventNameValue = + (typeof DatabaseEventName)[keyof typeof DatabaseEventName]; interface DatabaseResult { id: any; @@ -83,6 +91,7 @@ export interface OperationItem extends ModelItem { export default class Database { public emitter: Emitter; private database: IndexedDb; + private databaseName: string; /* Temp Database Proxy */ public static databaseInstanceName: string; @@ -91,7 +100,8 @@ export default class Database { public static EVENTS = DatabaseEventName; - constructor(private databaseName: string) { + constructor(databaseName: string) { + this.databaseName = databaseName; this.emitter = new Emitter(); this.database = new IndexedDb(this.databaseName); } @@ -514,15 +524,6 @@ export default class Database { } } - // START: Static mappings to instance methods - static async on(...args: any[]) { - // eslint-disable-next-line prefer-spread - return Database.singletonInstance.emitter.on.apply( - Database.singletonInstance.emitter, - args, - ); - } - static async getPushId(): Promise { return this.get('Options', 'lastPushId'); } diff --git a/src/shared/utils/TagUtils.ts b/src/shared/utils/TagUtils.ts index 329725bee..297de4a1f 100644 --- a/src/shared/utils/TagUtils.ts +++ b/src/shared/utils/TagUtils.ts @@ -1,7 +1,7 @@ -import { +import type { + TagCategory, TagsObjectForApi, TagsObjectWithBoolean, - TagCategory, } from '../../page/models/Tags'; import { deepCopy } from './utils'; diff --git a/src/sw/libraries/Log.ts b/src/sw/libraries/Log.ts index 46cbec771..4f0a2e772 100644 --- a/src/sw/libraries/Log.ts +++ b/src/sw/libraries/Log.ts @@ -1,4 +1,4 @@ -import { OSServiceWorkerFields } from '../serviceWorker/types'; +import type { OSServiceWorkerFields } from '../serviceWorker/types'; declare let self: ServiceWorkerGlobalScope & OSServiceWorkerFields; diff --git a/src/sw/managers/sessionManager/SessionManager.ts b/src/sw/managers/sessionManager/SessionManager.ts index d6920f959..e2e4660b8 100644 --- a/src/sw/managers/sessionManager/SessionManager.ts +++ b/src/sw/managers/sessionManager/SessionManager.ts @@ -1,5 +1,5 @@ -import { ISessionManager } from '../../../shared/managers/sessionManager/types'; -import { SessionOrigin } from '../../../shared/models/Session'; +import type { ISessionManager } from '../../../shared/managers/sessionManager/types'; +import type { SessionOrigin } from '../../../shared/models/Session'; export class SessionManager implements ISessionManager { async upsertSession(_sessionOrigin: SessionOrigin): Promise { diff --git a/src/sw/models/OSMinifiedNotificationPayload.ts b/src/sw/models/OSMinifiedNotificationPayload.ts index 8f10f821c..995c72fd1 100644 --- a/src/sw/models/OSMinifiedNotificationPayload.ts +++ b/src/sw/models/OSMinifiedNotificationPayload.ts @@ -1,7 +1,7 @@ -import { +import type { IOSNotification, IOSNotificationActionButton, -} from '../../shared/models/OSNotification'; +} from 'src/shared/models/OSNotification'; // This is the raw payload that OneSignal sends export interface OSMinifiedNotificationPayload { diff --git a/src/sw/models/OSNotificationButtonsConverter.ts b/src/sw/models/OSNotificationButtonsConverter.ts index 56b187696..0b09a83f1 100644 --- a/src/sw/models/OSNotificationButtonsConverter.ts +++ b/src/sw/models/OSNotificationButtonsConverter.ts @@ -1,4 +1,7 @@ -import { IOSNotificationActionButton } from '../../shared/models/OSNotification'; +import type { + IOSNotificationActionButton, + NotificationAction, +} from '../../shared/models/OSNotification'; export class OSNotificationButtonsConverter { static toNative( diff --git a/src/sw/serviceWorker/ServiceWorker.test.ts b/src/sw/serviceWorker/ServiceWorker.test.ts index 088817136..955b28eb7 100644 --- a/src/sw/serviceWorker/ServiceWorker.test.ts +++ b/src/sw/serviceWorker/ServiceWorker.test.ts @@ -17,15 +17,18 @@ import { DEFAULT_DEVICE_ID, SubscriptionManager, } from 'src/shared/managers/SubscriptionManager'; -import { AppConfig, ConfigIntegrationKind } from 'src/shared/models/AppConfig'; +import { + type AppConfig, + ConfigIntegrationKind, +} from 'src/shared/models/AppConfig'; import { DeliveryPlatformKind } from 'src/shared/models/DeliveryPlatformKind'; import { RawPushSubscription } from 'src/shared/models/RawPushSubscription'; import { ONESIGNAL_SESSION_KEY, - Session, + type Session, SessionOrigin, SessionStatus, - UpsertOrDeactivateSessionPayload, + type UpsertOrDeactivateSessionPayload, } from 'src/shared/models/Session'; import { SubscriptionStrategyKind } from 'src/shared/models/SubscriptionStrategyKind'; import Database, { @@ -328,6 +331,7 @@ describe('ServiceWorker', () => { http.post(`**/players`, () => HttpResponse.json({ id: someDeviceId })), ); + // @ts-expect-error - for setting sdk env global.ServiceWorkerGlobalScope = undefined; }); @@ -402,8 +406,8 @@ describe('ServiceWorker', () => { const [rawSubscription, subscriptionState] = registerSubscriptionCall.mock.calls[0]; expect(rawSubscription).toBeInstanceOf(RawPushSubscription); - expect(rawSubscription.w3cEndpoint?.href).toBe('https://example.com/'); - expect(rawSubscription.safariDeviceToken).toBeUndefined(); + expect(rawSubscription?.w3cEndpoint?.href).toBe('https://example.com/'); + expect(rawSubscription?.safariDeviceToken).toBeUndefined(); expect(subscriptionState).toBe(NotificationType.PermissionRevoked); }); }); @@ -578,7 +582,6 @@ describe('ServiceWorker', () => { }); describe('worker messenger', () => { - const newAppID = '32f13333-a0d2-4ce8-bcd9-b1754e242756'; const appConfig: AppConfig = { appId, hasUnsupportedSubdomain: false, @@ -689,6 +692,8 @@ describe('ServiceWorker', () => { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const logDebugSpy = vi.spyOn(Log, 'debug'); // -- one signal api base mock + +// @ts-expect-error - for mocking const apiPutSpy = vi.spyOn(OneSignalApiBase, 'put').mockResolvedValue({ result: {}, status: 200, diff --git a/src/sw/serviceWorker/ServiceWorker.ts b/src/sw/serviceWorker/ServiceWorker.ts index 235e908a5..15aab84f4 100755 --- a/src/sw/serviceWorker/ServiceWorker.ts +++ b/src/sw/serviceWorker/ServiceWorker.ts @@ -7,7 +7,7 @@ import OneSignalApiSW from '../../../src/shared/api/OneSignalApiSW'; import { WorkerMessenger, WorkerMessengerCommand, - WorkerMessengerMessage, + type WorkerMessengerMessage, } from '../../../src/shared/libraries/WorkerMessenger'; import { RawPushSubscription } from '../../../src/shared/models/RawPushSubscription'; import FuturePushSubscriptionRecord from '../../page/userModel/FuturePushSubscriptionRecord'; @@ -16,34 +16,37 @@ import { ConfigHelper } from '../../shared/helpers/ConfigHelper'; import ServiceWorkerHelper from '../../shared/helpers/ServiceWorkerHelper'; import { DeliveryPlatformKind } from '../../shared/models/DeliveryPlatformKind'; import { - NotificationClickEventInternal, - NotificationForegroundWillDisplayEventSerializable, + type NotificationClickEventInternal, + type NotificationForegroundWillDisplayEventSerializable, } from '../../shared/models/NotificationEvent'; import { - IMutableOSNotification, - IOSNotification, + type IMutableOSNotification, + type IOSNotification, } from '../../shared/models/OSNotification'; import { - PageVisibilityRequest, - PageVisibilityResponse, + type PageVisibilityRequest, + type PageVisibilityResponse, SessionStatus, - UpsertOrDeactivateSessionPayload, + type UpsertOrDeactivateSessionPayload, } from '../../shared/models/Session'; import { SubscriptionStrategyKind } from '../../shared/models/SubscriptionStrategyKind'; import { awaitableTimeout } from '../../shared/utils/AwaitableTimeout'; import { cancelableTimeout } from '../helpers/CancelableTimeout'; import Log from '../libraries/Log'; import { - OSMinifiedNotificationPayload, + type OSMinifiedNotificationPayload, OSMinifiedNotificationPayloadHelper, } from '../models/OSMinifiedNotificationPayload'; -import { OSServiceWorkerFields, SubscriptionChangeEvent } from './types'; +import { + type OSServiceWorkerFields, + type SubscriptionChangeEvent, +} from './types'; import { NotificationType, - NotificationTypeValue, + type NotificationTypeValue, } from 'src/core/types/subscription'; -import { AppConfig } from 'src/shared/models/AppConfig'; +import type { AppConfig } from 'src/shared/models/AppConfig'; import { bowserCastle } from '../../shared/utils/bowserCastle'; import { ModelCacheDirectAccess } from '../helpers/ModelCacheDirectAccess'; import { OSNotificationButtonsConverter } from '../models/OSNotificationButtonsConverter'; @@ -626,8 +629,8 @@ export class ServiceWorker { notification.icon = notification.icon ? notification.icon : defaultIcon - ? defaultIcon - : undefined; + ? defaultIcon + : undefined; ServiceWorker.ensureNotificationResourcesHttps(notification); @@ -1081,7 +1084,7 @@ export class ServiceWorker { } // Get our new push subscription - let rawPushSubscription: RawPushSubscription; + let rawPushSubscription: RawPushSubscription | undefined; // Set it initially by the provided new push subscription const providedNewSubscription = event.newSubscription; diff --git a/src/sw/webhooks/OSWebhookSender.ts b/src/sw/webhooks/OSWebhookSender.ts index df4754692..5add0fad7 100644 --- a/src/sw/webhooks/OSWebhookSender.ts +++ b/src/sw/webhooks/OSWebhookSender.ts @@ -1,6 +1,6 @@ import Database from '../../shared/services/Database'; import Log from '../libraries/Log'; -import { IOSWebhookEventPayload } from './IOSWebhookEventPayload'; +import type { IOSWebhookEventPayload } from './IOSWebhookEventPayload'; export class OSWebhookSender { async send(payload: IOSWebhookEventPayload): Promise { diff --git a/src/sw/webhooks/notifications/OSWebhookNotificationEventSender.ts b/src/sw/webhooks/notifications/OSWebhookNotificationEventSender.ts index c243542fd..9a94f4f08 100644 --- a/src/sw/webhooks/notifications/OSWebhookNotificationEventSender.ts +++ b/src/sw/webhooks/notifications/OSWebhookNotificationEventSender.ts @@ -1,15 +1,16 @@ -import { NotificationClickEvent } from '../../../shared/models/NotificationEvent'; +import type { NotificationClickEvent } from '../../../shared/models/NotificationEvent'; +import type { IOSNotification } from '../../../shared/models/OSNotification'; import { OSWebhookSender } from './../OSWebhookSender'; - import { OSWebhookPayloadNotificationClick } from './payloads/OSWebhookPayloadNotificationClick'; -import { OSWebhookPayloadNotificationWillDisplay } from './payloads/OSWebhookPayloadNotificationWillDisplay'; import { OSWebhookPayloadNotificationDismiss } from './payloads/OSWebhookPayloadNotificationDismiss'; -import { IOSNotification } from '../../../shared/models/OSNotification'; +import { OSWebhookPayloadNotificationWillDisplay } from './payloads/OSWebhookPayloadNotificationWillDisplay'; export class OSWebhookNotificationEventSender { - constructor( - private readonly sender: OSWebhookSender = new OSWebhookSender(), - ) {} + private readonly sender: OSWebhookSender; + + constructor(sender: OSWebhookSender = new OSWebhookSender()) { + this.sender = sender; + } async click( event: NotificationClickEvent, diff --git a/src/sw/webhooks/notifications/payloads/OSWebhookPayloadNotificationClick.ts b/src/sw/webhooks/notifications/payloads/OSWebhookPayloadNotificationClick.ts index 40a848261..07fdfb8c1 100644 --- a/src/sw/webhooks/notifications/payloads/OSWebhookPayloadNotificationClick.ts +++ b/src/sw/webhooks/notifications/payloads/OSWebhookPayloadNotificationClick.ts @@ -1,5 +1,5 @@ -import { NotificationClickEvent } from '../../../../shared/models/NotificationEvent'; -import { IOSWebhookEventPayload } from '../../IOSWebhookEventPayload'; +import type { NotificationClickEvent } from '../../../../shared/models/NotificationEvent'; +import type { IOSWebhookEventPayload } from '../../IOSWebhookEventPayload'; export class OSWebhookPayloadNotificationClick implements IOSWebhookEventPayload diff --git a/src/sw/webhooks/notifications/payloads/OSWebhookPayloadNotificationDismiss.ts b/src/sw/webhooks/notifications/payloads/OSWebhookPayloadNotificationDismiss.ts index 5ff13c6bd..846d107d9 100644 --- a/src/sw/webhooks/notifications/payloads/OSWebhookPayloadNotificationDismiss.ts +++ b/src/sw/webhooks/notifications/payloads/OSWebhookPayloadNotificationDismiss.ts @@ -1,5 +1,5 @@ -import { IOSWebhookEventPayload } from '../../IOSWebhookEventPayload'; -import { IOSNotification } from '../../../../shared/models/OSNotification'; +import type { IOSNotification } from '../../../../shared/models/OSNotification'; +import type { IOSWebhookEventPayload } from '../../IOSWebhookEventPayload'; export class OSWebhookPayloadNotificationDismiss implements IOSWebhookEventPayload diff --git a/src/sw/webhooks/notifications/payloads/OSWebhookPayloadNotificationWillDisplay.ts b/src/sw/webhooks/notifications/payloads/OSWebhookPayloadNotificationWillDisplay.ts index 3aeb7f2a9..0f81ae6db 100644 --- a/src/sw/webhooks/notifications/payloads/OSWebhookPayloadNotificationWillDisplay.ts +++ b/src/sw/webhooks/notifications/payloads/OSWebhookPayloadNotificationWillDisplay.ts @@ -1,5 +1,5 @@ -import { IOSWebhookEventPayload } from '../../IOSWebhookEventPayload'; -import { IOSNotification } from '../../../../shared/models/OSNotification'; +import type { IOSNotification } from '../../../../shared/models/OSNotification'; +import type { IOSWebhookEventPayload } from '../../IOSWebhookEventPayload'; export class OSWebhookPayloadNotificationWillDisplay implements IOSWebhookEventPayload diff --git a/tsconfig.json b/tsconfig.json index c9ee52d1e..31a9e2c56 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "target": "ES2022", "useDefineForClassFields": true, "module": "ESNext", - "lib": ["ES2022", "DOM", "DOM.Iterable"], + "lib": ["ESNext", "DOM", "DOM.Iterable", "WebWorker"], "skipLibCheck": true, /* Bundler mode */ From a2b15d3a7babef4b23ea203ca7ca9fffc7b704ac Mon Sep 17 00:00:00 2001 From: Fadi George Date: Thu, 24 Jul 2025 14:26:55 -0700 Subject: [PATCH 3/4] prettier fixes --- src/page/stylesheets/customlink.scss | 16 ++++++++-------- src/page/stylesheets/reset.scss | 3 ++- src/page/stylesheets/slidedown.scss | 11 ++++++----- src/shared/models/AppConfig.ts | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/page/stylesheets/customlink.scss b/src/page/stylesheets/customlink.scss index bf84694f6..3f750a26b 100644 --- a/src/page/stylesheets/customlink.scss +++ b/src/page/stylesheets/customlink.scss @@ -20,8 +20,8 @@ $customlink-base-padding-vertical: 8px; .onesignal-customlink-subscribe { display: inline-block; transition: all 0.1s; - font-family: -apple-system, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, - sans-serif; + font-family: + -apple-system, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; &:hover { filter: brightness(0.9); @@ -32,8 +32,8 @@ $customlink-base-padding-vertical: 8px; } &.onesignal-reset { - font-family: -apple-system, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, - sans-serif; + font-family: + -apple-system, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; display: inline-block; transition: all 0.1s; } @@ -99,15 +99,15 @@ $customlink-base-padding-vertical: 8px; .onesignal-customlink-explanation { color: rgba(0, 0, 0, 0.64); transition: all 0.1s; - font-family: 'Proxima-Nova', 'Proxima Nova', 'Open Sans', Arial, Helvetica, - sans-serif; + font-family: + 'Proxima-Nova', 'Proxima Nova', 'Open Sans', Arial, Helvetica, sans-serif; margin-bottom: 12px; &.onesignal-reset { color: rgba(0, 0, 0, 0.64); transition: all 0.1s; - font-family: 'Proxima-Nova', 'Proxima Nova', 'Open Sans', Arial, Helvetica, - sans-serif; + font-family: + 'Proxima-Nova', 'Proxima Nova', 'Open Sans', Arial, Helvetica, sans-serif; margin-bottom: 12px; } diff --git a/src/page/stylesheets/reset.scss b/src/page/stylesheets/reset.scss index 81c8188ab..e95e45d49 100755 --- a/src/page/stylesheets/reset.scss +++ b/src/page/stylesheets/reset.scss @@ -772,7 +772,8 @@ direction: ltr; text-align: left; /* for IE, Opera */ text-align: start; /* recommended W3C Spec */ - font-family: 'Times New Roman', Times, serif; /* Override this with whatever font-family is required */ + font-family: + 'Times New Roman', Times, serif; /* Override this with whatever font-family is required */ color: black; font-style: normal; font-weight: normal; diff --git a/src/page/stylesheets/slidedown.scss b/src/page/stylesheets/slidedown.scss index 34e28926d..d81dd9238 100755 --- a/src/page/stylesheets/slidedown.scss +++ b/src/page/stylesheets/slidedown.scss @@ -19,8 +19,9 @@ $desktop-width: 1024px; } .iti--container { - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, - Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; + font-family: + -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, + Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; @include mobile { z-index: 2258594001 !important; @@ -411,9 +412,9 @@ $desktop-width: 1024px; padding: 1.5em 1.5em; border-bottom-left-radius: $border-radius; border-bottom-right-radius: $border-radius; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, - Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', - 'Seoe UI Symbol'; + font-family: + -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, + sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Seoe UI Symbol'; .slidedown-body, .popover-body { diff --git a/src/shared/models/AppConfig.ts b/src/shared/models/AppConfig.ts index bdcc8997d..148d19407 100755 --- a/src/shared/models/AppConfig.ts +++ b/src/shared/models/AppConfig.ts @@ -251,7 +251,7 @@ export interface ServerAppConfig { workerName?: string; registrationScope?: string; }; - setupBehavior?: {}; + setupBehavior?: Record; welcomeNotification: { url: string | undefined; title: string | undefined; From e78fe319f05759e0156434413b241e17032e3a42 Mon Sep 17 00:00:00 2001 From: Fadi George Date: Thu, 24 Jul 2025 17:20:41 -0700 Subject: [PATCH 4/4] address pr comments and clean up more enum clean up --- __test__/support/models/BrowserUserAgent.ts | 145 ++++++++++++------ src/page/errors/ChannelCaptureError.ts | 23 ++- src/page/models/Dismiss.ts | 24 +-- src/page/services/DynamicResourceLoader.ts | 36 +++-- .../slidedown/InternationalTelephoneInput.ts | 24 +-- src/shared/errors/InvalidArgumentError.ts | 29 ++-- src/shared/errors/InvalidStateError.ts | 29 ++-- src/shared/errors/NotSubscribedError.ts | 25 +-- src/shared/errors/OneSignalApiError.ts | 13 +- .../errors/PushPermissionNotGrantedError.ts | 17 +- src/shared/errors/SdkInitError.ts | 27 ++-- src/shared/errors/SubscriptionError.ts | 15 +- src/shared/managers/SubscriptionManager.ts | 22 ++- src/shared/models/Browser.ts | 18 ++- src/shared/models/DeliveryPlatformKind.ts | 21 +-- src/shared/models/NotificationPermission.ts | 13 +- src/shared/models/PermissionPromptType.ts | 13 +- src/shared/models/SubscriptionStrategyKind.ts | 11 +- src/shared/models/UnsubscriptionStrategy.ts | 11 +- src/shared/models/WindowEnvironmentKind.ts | 11 +- tsconfig.json | 11 +- 21 files changed, 341 insertions(+), 197 deletions(-) diff --git a/__test__/support/models/BrowserUserAgent.ts b/__test__/support/models/BrowserUserAgent.ts index f1e3d9ce1..7789fc29c 100644 --- a/__test__/support/models/BrowserUserAgent.ts +++ b/__test__/support/models/BrowserUserAgent.ts @@ -1,52 +1,97 @@ -enum BrowserUserAgent { - Default = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', - iPad = 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10', - iPhone = 'Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25', - iPod = 'Mozilla/5.0 (iPod touch; CPU iPhone OS 7_0_3 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B511 Safari/9537.53', - EdgeUnsupported = 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10136', - EdgeUnsupported2 = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/17.17062', - EdgeSupported = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/17.17074', - IE11 = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko', - FirefoxMobileUnsupported = 'Mozilla/5.0 (Android 4.4; Mobile; rv:47.0) Gecko/47.0 Firefox/47.0', - FirefoxTabletUnsupported = 'Mozilla/5.0 (Android 4.4; Mobile ; rv:47.0) Gecko/47.0 Firefox/47.0', - FirefoxMobileSupported = 'Mozilla/5.0 (Android 4.4; Mobile; rv:44.0) Gecko/48.0 Firefox/48.0', - FirefoxTabletSupported = 'Mozilla/5.0 (Android 4.4; Mobile ; rv:44.0) Gecko/48.0 Firefox/48.0', - FirefoxWindowsUnSupported = 'Mozilla/5.0 (Windows NT x.y; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0', - FirefoxWindowsSupported = 'Mozilla/5.0 (Windows NT x.y; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0', - FirefoxMacSupported = 'Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:47.0) Gecko/20100101 Firefox/47.0', - FirefoxLinuxSupported = 'Mozilla/5.0 (X11; Linux i686 on x86_64; rv:47.0) Gecko/20100101 Firefox/47.0', - SafariUnsupportedMac = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/538.32 (KHTML, like Gecko) Version/7.0 Safari/538.4', - SafariSupportedMac = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/538.32 (KHTML, like Gecko) Version/7.1 Safari/538.4', - SafariSupportedMac121 = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15', - FacebookBrowseriOS = 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12D508 [FBAN/FBIOS;FBAV/27.0.0.10.12;FBBV/8291884;FBDV/iPhone7,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/8.2;FBSS/3;]', - FacebookBrowserAndroid = 'Mozilla/5.0 (Linux; Android 5.1; Archos Diamond S Build/LMY47D; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/51.0.2704.81 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/87.0.0.17.79;]', - ChromeAndroidSupported = 'Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/54 Mobile Safari/535.19', - ChromeWindowsSupported = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2228.0 Safari/537.36', - ChromeMacSupported = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.1636.0 Safari/537.36', - ChromeMac10_15 = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36', - ChromeMacSupported69 = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36', - ChromeLinuxSupported = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.1636.0 Safari/537.36', - ChromeTabletSupported = 'Mozilla/5.0 (Linux; Android 4.3; Nexus 10 Build/JWR66Y) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.1547.72 Safari/537.36', - ChromeAndroidUnsupported = 'Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/41 Mobile Safari/535.19', - ChromeWindowsUnsupported = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2228.0 Safari/537.36', - ChromeMacUnsupported = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.1636.0 Safari/537.36', - ChromeLinuxUnsupported = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.1636.0 Safari/537.36', - ChromeTabletUnsupported = 'Mozilla/5.0 (Linux; Android 4.3; Nexus 10 Build/JWR66Y) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.1547.72 Safari/537.36', - YandexDesktopSupportedHigh = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.12785 YaBrowser/17.1.0.2036 Safari/537.36', - YandexDesktopSupportedLow = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.12785 YaBrowser/15.12.1.6475 Safari/537.36', - YandexMobileSupported = 'Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6P Build/N4F26T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 YaBrowser/17.1.2.339.00 Mobile Safari/537.36', - OperaDesktopSupported = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36 OPR/42.0.2442.806', - OperaMac10_14 = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36 OPR/42.0.2442.806', - OperaAndroidSupported = 'Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6P Build/N4F26T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.91 Mobile Safari/537.36 OPR/37.5.2246.114172', - OperaTabletSupported = 'Mozilla/5.0 (Linux; Android 4.1.2; GT-N8000 Build/JZO54K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.166 Safari/537.36 OPR/37.0.1396.73172', - OperaMiniUnsupported = 'Mozilla/5.0 (Linux; U; Android 7.1.2; Nexus 6P Build/N2G47H; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 Mobile Safari/537.36 OPR/24.0.2254.115784', - VivaldiWindowsSupported = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.89 Vivaldi/1.0.94.2 Safari/537.36', - VivaldiLinuxSupported = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.105 Safari/537.36 Vivaldi/1.0.162.2', - VivaldiMacSupported = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36 Vivaldi/1.0.303.52', - SamsungBrowserSupported = 'Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG SM-N910F Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile Safari/537.36', - SamsungBrowserUnsupported = 'Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG SM-N910F Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/3.0 Chrome/44.0.2403.133 Mobile Safari/537.36', - UcBrowserSupported = 'Mozilla/5.0 (Linux; U; Android 9; en-US; LM-G710 Build/PKQ1.181105.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.9.10.1159 Mobile Safari/537.36', - UcBrowserUnsupported = 'Mozilla/5.0 (Linux; U; Android 6.0.1; zh-CN; F5121 Build/34.0.A.1.247) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/40.0.2214.89 UCBrowser/11.5.1.944 Mobile Safari/537.36', -} +const BrowserUserAgent = { + Default: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', + iPad: 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10', + iPhone: + 'Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25', + iPod: 'Mozilla/5.0 (iPod touch; CPU iPhone OS 7_0_3 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B511 Safari/9537.53', + EdgeUnsupported: + 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10136', + EdgeUnsupported2: + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/17.17062', + EdgeSupported: + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/17.17074', + IE11: 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko', + FirefoxMobileUnsupported: + 'Mozilla/5.0 (Android 4.4; Mobile; rv:47.0) Gecko/47.0 Firefox/47.0', + FirefoxTabletUnsupported: + 'Mozilla/5.0 (Android 4.4; Mobile ; rv:47.0) Gecko/47.0 Firefox/47.0', + FirefoxMobileSupported: + 'Mozilla/5.0 (Android 4.4; Mobile; rv:44.0) Gecko/48.0 Firefox/48.0', + FirefoxTabletSupported: + 'Mozilla/5.0 (Android 4.4; Mobile ; rv:44.0) Gecko/48.0 Firefox/48.0', + FirefoxWindowsUnSupported: + 'Mozilla/5.0 (Windows NT x.y; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0', + FirefoxWindowsSupported: + 'Mozilla/5.0 (Windows NT x.y; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0', + FirefoxMacSupported: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:47.0) Gecko/20100101 Firefox/47.0', + FirefoxLinuxSupported: + 'Mozilla/5.0 (X11; Linux i686 on x86_64; rv:47.0) Gecko/20100101 Firefox/47.0', + SafariUnsupportedMac: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/538.32 (KHTML, like Gecko) Version/7.0 Safari/538.4', + SafariSupportedMac: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/538.32 (KHTML, like Gecko) Version/7.1 Safari/538.4', + SafariSupportedMac121: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15', + FacebookBrowseriOS: + 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12D508 [FBAN/FBIOS;FBAV/27.0.0.10.12;FBBV/8291884;FBDV/iPhone7,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/8.2;FBSS/3;]', + FacebookBrowserAndroid: + 'Mozilla/5.0 (Linux; Android 5.1; Archos Diamond S Build/LMY47D; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/51.0.2704.81 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/87.0.0.17.79;]', + ChromeAndroidSupported: + 'Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/54 Mobile Safari/535.19', + ChromeWindowsSupported: + 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2228.0 Safari/537.36', + ChromeMacSupported: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.1636.0 Safari/537.36', + ChromeMac10_15: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36', + ChromeMacSupported69: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36', + ChromeLinuxSupported: + 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.1636.0 Safari/537.36', + ChromeTabletSupported: + 'Mozilla/5.0 (Linux; Android 4.3; Nexus 10 Build/JWR66Y) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.1547.72 Safari/537.36', + ChromeAndroidUnsupported: + 'Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/41 Mobile Safari/535.19', + ChromeWindowsUnsupported: + 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2228.0 Safari/537.36', + ChromeMacUnsupported: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.1636.0 Safari/537.36', + ChromeLinuxUnsupported: + 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.1636.0 Safari/537.36', + ChromeTabletUnsupported: + 'Mozilla/5.0 (Linux; Android 4.3; Nexus 10 Build/JWR66Y) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.1547.72 Safari/537.36', + YandexDesktopSupportedHigh: + 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.12785 YaBrowser/17.1.0.2036 Safari/537.36', + YandexDesktopSupportedLow: + 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.12785 YaBrowser/15.12.1.6475 Safari/537.36', + YandexMobileSupported: + 'Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6P Build/N4F26T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 YaBrowser/17.1.2.339.00 Mobile Safari/537.36', + OperaDesktopSupported: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36 OPR/42.0.2442.806', + OperaMac10_14: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36 OPR/42.0.2442.806', + OperaAndroidSupported: + 'Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6P Build/N4F26T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.91 Mobile Safari/537.36 OPR/37.5.2246.114172', + OperaTabletSupported: + 'Mozilla/5.0 (Linux; Android 4.1.2; GT-N8000 Build/JZO54K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.166 Safari/537.36 OPR/37.0.1396.73172', + OperaMiniUnsupported: + 'Mozilla/5.0 (Linux; U; Android 7.1.2; Nexus 6P Build/N2G47H; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 Mobile Safari/537.36 OPR/24.0.2254.115784', + VivaldiWindowsSupported: + 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.89 Vivaldi/1.0.94.2 Safari/537.36', + VivaldiLinuxSupported: + 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.105 Safari/537.36 Vivaldi/1.0.162.2', + VivaldiMacSupported: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36 Vivaldi/1.0.303.52', + SamsungBrowserSupported: + 'Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG SM-N910F Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile Safari/537.36', + SamsungBrowserUnsupported: + 'Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG SM-N910F Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/3.0 Chrome/44.0.2403.133 Mobile Safari/537.36', + UcBrowserSupported: + 'Mozilla/5.0 (Linux; U; Android 9; en-US; LM-G710 Build/PKQ1.181105.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.9.10.1159 Mobile Safari/537.36', + UcBrowserUnsupported: + 'Mozilla/5.0 (Linux; U; Android 6.0.1; zh-CN; F5121 Build/34.0.A.1.247) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/40.0.2214.89 UCBrowser/11.5.1.944 Mobile Safari/537.36', +}; export default BrowserUserAgent; diff --git a/src/page/errors/ChannelCaptureError.ts b/src/page/errors/ChannelCaptureError.ts index fda690065..6fa1ff286 100644 --- a/src/page/errors/ChannelCaptureError.ts +++ b/src/page/errors/ChannelCaptureError.ts @@ -1,16 +1,23 @@ import OneSignalError from '../../shared/errors/OneSignalError'; -export enum InvalidChannelInputField { - InvalidSms, - InvalidEmail, - InvalidEmailAndSms, -} +export const InvalidChannelInputField = { + InvalidSms: 0, + InvalidEmail: 1, + InvalidEmailAndSms: 2, +} as const; + +const reverseInvalidChannelInputField = Object.fromEntries( + Object.entries(InvalidChannelInputField).map(([key, value]) => [value, key]), +); + +export type InvalidChannelInputFieldValue = + (typeof InvalidChannelInputField)[keyof typeof InvalidChannelInputField]; export class ChannelCaptureError extends OneSignalError { description: string; - reason: InvalidChannelInputField; + reason: InvalidChannelInputFieldValue; - constructor(reason: InvalidChannelInputField) { + constructor(reason: InvalidChannelInputFieldValue) { let errorMessage; switch (reason) { case InvalidChannelInputField.InvalidEmail: @@ -27,7 +34,7 @@ export class ChannelCaptureError extends OneSignalError { } super(errorMessage); - this.description = InvalidChannelInputField[reason]; + this.description = reverseInvalidChannelInputField[reason]; this.reason = reason; /** diff --git a/src/page/models/Dismiss.ts b/src/page/models/Dismiss.ts index fa629e12c..fee871f26 100644 --- a/src/page/models/Dismiss.ts +++ b/src/page/models/Dismiss.ts @@ -1,16 +1,16 @@ -export enum DismissPrompt { - Push = 'push', - NonPush = 'nonPush', -} +export const DismissPrompt = { + Push: 'push', + NonPush: 'nonPush', +} as const; -export enum DismissCountKey { - PromptDismissCount = 'promptDismissCount', // legacy. applies to 'push' and 'category' slidedown types + native - NonPushPromptsDismissCount = 'nonPushPromptsDismissCount', // applies to all new slidedown types (e.g: smsAndEmail) -} +export const DismissCountKey = { + PromptDismissCount: 'promptDismissCount', // legacy. applies to 'push' and 'category' slidedown types + native + NonPushPromptsDismissCount: 'nonPushPromptsDismissCount', // applies to all new slidedown types (e.g: smsAndEmail) +} as const; -export enum DismissTimeKey { +export const DismissTimeKey = { // legacy. applies to 'push' and 'category' slidedown types + native prompt - OneSignalNotificationPrompt = 'onesignal-notification-prompt', + OneSignalNotificationPrompt: 'onesignal-notification-prompt', // applies to all new slidedown types (e.g: smsAndEmail) - OneSignalNonPushPrompt = 'onesignal-non-push-prompt', -} + OneSignalNonPushPrompt: 'onesignal-non-push-prompt', +} as const; diff --git a/src/page/services/DynamicResourceLoader.ts b/src/page/services/DynamicResourceLoader.ts index 06db5a3a1..202c5b7d0 100644 --- a/src/page/services/DynamicResourceLoader.ts +++ b/src/page/services/DynamicResourceLoader.ts @@ -1,24 +1,30 @@ import { VERSION } from 'src/shared/utils/EnvVariables'; import SdkEnvironment from '../../shared/managers/SdkEnvironment'; -export const enum ResourceType { - Stylesheet, - Script, -} +export const ResourceType = { + Stylesheet: 0, + Script: 1, +} as const; + +export type ResourceTypeValue = + (typeof ResourceType)[keyof typeof ResourceType]; -export const enum ResourceLoadState { +export const ResourceLoadState = { /** * The remote resource was fetched and loaded successfully. */ - Loaded, + Loaded: 0, /** * The remote resource failed to be loaded (e.g. not found or network offline). */ - Failed, -} + Failed: 1, +} as const; + +export type ResourceLoadStateValue = + (typeof ResourceLoadState)[keyof typeof ResourceLoadState]; interface DynamicResourceLoaderCache { - [key: string]: Promise; + [key: string]: Promise; } export class DynamicResourceLoader { @@ -33,7 +39,7 @@ export class DynamicResourceLoader { return { ...this.cache }; } - async loadSdkStylesheet(): Promise { + async loadSdkStylesheet(): Promise { const pathForEnv = SdkEnvironment.getOneSignalResourceUrlPath(); const cssFileForEnv = SdkEnvironment.getOneSignalCssFileName(); return this.loadIfNew( @@ -46,7 +52,10 @@ export class DynamicResourceLoader { * Attempts to load a resource by adding it to the document's . * Caches any previous load attempt's result and does not retry loading a previous resource. */ - async loadIfNew(type: ResourceType, url: URL): Promise { + async loadIfNew( + type: ResourceTypeValue, + url: URL, + ): Promise { // Load for first time if (!this.cache[url.toString()]) { this.cache[url.toString()] = DynamicResourceLoader.load(type, url); @@ -60,7 +69,10 @@ export class DynamicResourceLoader { * Attempts to load a resource by adding it to the document's . * Each call creates a new DOM element and fetch attempt. */ - static async load(type: ResourceType, url: URL): Promise { + static async load( + type: ResourceTypeValue, + url: URL, + ): Promise { try { let domElement: HTMLElement; await new Promise((resolve, reject) => { diff --git a/src/page/slidedown/InternationalTelephoneInput.ts b/src/page/slidedown/InternationalTelephoneInput.ts index 0d2c9aec5..7a890c5a8 100644 --- a/src/page/slidedown/InternationalTelephoneInput.ts +++ b/src/page/slidedown/InternationalTelephoneInput.ts @@ -1,11 +1,15 @@ -export enum ItiScriptURLs { - Stylesheet = 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/css/intlTelInput.min.css', - Main = 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/js/intlTelInput.min.js', - Utils = 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/js/utils.js', -} +export const ItiScriptURLs = { + Stylesheet: + 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/css/intlTelInput.min.css', + Main: 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/js/intlTelInput.min.js', + Utils: + 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/js/utils.js', +} as const; -export enum ItiScriptURLHashes { - Stylesheet = 'sha512-yye/u0ehQsrVrfSd6biT17t39Rg9kNc+vENcCXZuMz2a+LWFGvXUnYuWUW6pbfYj1jcBb/C39UZw2ciQvwDDvg==', - Main = 'sha512-OnkjbJ4TwPpgSmjXACCb5J4cJwi880VRe+vWpPDlr8M38/L3slN5uUAeOeWU2jN+4vN0gImCXFGdJmc0wO4Mig==', - Utils = 'sha512-bUcJxlqkiGA3cmoYPuZaLRsyc5ChG9APG4ajom2AXKSlBtOmx4kLV3c8uv/6uSz43FMjI4Q2QI21+D223rT76w==', -} +export const ItiScriptURLHashes = { + Stylesheet: + 'sha512-yye/u0ehQsrVrfSd6biT17t39Rg9kNc+vENcCXZuMz2a+LWFGvXUnYuWUW6pbfYj1jcBb/C39UZw2ciQvwDDvg==', + Main: 'sha512-OnkjbJ4TwPpgSmjXACCb5J4cJwi880VRe+vWpPDlr8M38/L3slN5uUAeOeWU2jN+4vN0gImCXFGdJmc0wO4Mig==', + Utils: + 'sha512-bUcJxlqkiGA3cmoYPuZaLRsyc5ChG9APG4ajom2AXKSlBtOmx4kLV3c8uv/6uSz43FMjI4Q2QI21+D223rT76w==', +} as const; diff --git a/src/shared/errors/InvalidArgumentError.ts b/src/shared/errors/InvalidArgumentError.ts index 02ba5e2a2..8146b5d6e 100755 --- a/src/shared/errors/InvalidArgumentError.ts +++ b/src/shared/errors/InvalidArgumentError.ts @@ -1,18 +1,29 @@ import OneSignalError from './OneSignalError'; -export enum InvalidArgumentReason { - Empty, - Malformed, - EnumOutOfRange, - WrongType, - Reserved, -} +export const InvalidArgumentReason = { + Empty: 0, + Malformed: 1, + EnumOutOfRange: 2, + WrongType: 3, + Reserved: 4, +} as const; + +const reverseInvalidArgumentReason = Object.fromEntries( + Object.entries(InvalidArgumentReason).map(([key, value]) => [value, key]), +); + +export type InvalidArgumentReasonValue = + (typeof InvalidArgumentReason)[keyof typeof InvalidArgumentReason]; export class InvalidArgumentError extends OneSignalError { argument: string; reason: string; - constructor(argName: string, reason: InvalidArgumentReason, message = '') { + constructor( + argName: string, + reason: InvalidArgumentReasonValue, + message = '', + ) { let errorMessage; switch (reason) { case InvalidArgumentReason.Empty: @@ -36,7 +47,7 @@ export class InvalidArgumentError extends OneSignalError { super(errorMessage); this.argument = argName; - this.reason = InvalidArgumentReason[reason]; + this.reason = reverseInvalidArgumentReason[reason]; /** * Important! Required to make sure the correct error type is detected during instanceof checks. diff --git a/src/shared/errors/InvalidStateError.ts b/src/shared/errors/InvalidStateError.ts index 300917dc6..63b446d3d 100755 --- a/src/shared/errors/InvalidStateError.ts +++ b/src/shared/errors/InvalidStateError.ts @@ -1,21 +1,28 @@ import { PermissionPromptType } from '../models/PermissionPromptType'; import OneSignalError from './OneSignalError'; -export enum InvalidStateReason { - MissingAppId, - RedundantPermissionMessage, - PushPermissionAlreadyGranted, - UnsupportedEnvironment, - MissingDomElement, - ServiceWorkerNotActivated, -} +export const InvalidStateReason = { + MissingAppId: 0, + RedundantPermissionMessage: 1, + PushPermissionAlreadyGranted: 2, + UnsupportedEnvironment: 3, + MissingDomElement: 4, + ServiceWorkerNotActivated: 5, +} as const; + +export type InvalidStateReasonValue = + (typeof InvalidStateReason)[keyof typeof InvalidStateReason]; + +const reverseInvalidStateReason = Object.fromEntries( + Object.entries(InvalidStateReason).map(([key, value]) => [value, key]), +); export class InvalidStateError extends OneSignalError { description: string; - reason: InvalidStateReason; + reason: InvalidStateReasonValue; constructor( - reason: InvalidStateReason, + reason: InvalidStateReasonValue, extra?: { permissionPromptType: PermissionPromptType; }, @@ -44,7 +51,7 @@ export class InvalidStateError extends OneSignalError { } super(errorMessage); - this.description = InvalidStateReason[reason]; + this.description = reverseInvalidStateReason[reason]; this.reason = reason; /** diff --git a/src/shared/errors/NotSubscribedError.ts b/src/shared/errors/NotSubscribedError.ts index 5be759e39..cf6df8313 100755 --- a/src/shared/errors/NotSubscribedError.ts +++ b/src/shared/errors/NotSubscribedError.ts @@ -1,17 +1,24 @@ import OneSignalError from './OneSignalError'; -export enum NotSubscribedReason { - Unknown, - NoDeviceId, - NoEmailSet, - NoSMSSet, - OptedOut, -} +export const NotSubscribedReason = { + Unknown: 0, + NoDeviceId: 1, + NoEmailSet: 2, + NoSMSSet: 3, + OptedOut: 4, +} as const; + +export type NotSubscribedReasonValue = + (typeof NotSubscribedReason)[keyof typeof NotSubscribedReason]; + +const reverseNotSubscribedReason = Object.fromEntries( + Object.entries(NotSubscribedReason).map(([key, value]) => [value, key]), +); export class NotSubscribedError extends OneSignalError { reason: string; - constructor(reason: NotSubscribedReason) { + constructor(reason: NotSubscribedReasonValue) { let errorMessage; switch (reason) { case NotSubscribedReason.Unknown || NotSubscribedReason.NoDeviceId: @@ -31,7 +38,7 @@ export class NotSubscribedError extends OneSignalError { break; } super(errorMessage); - this.reason = NotSubscribedReason[reason]; + this.reason = reverseNotSubscribedReason[reason]; /** * Important! Required to make sure the correct error type is detected during instanceof checks. diff --git a/src/shared/errors/OneSignalApiError.ts b/src/shared/errors/OneSignalApiError.ts index 077a892f2..f69920248 100644 --- a/src/shared/errors/OneSignalApiError.ts +++ b/src/shared/errors/OneSignalApiError.ts @@ -1,14 +1,17 @@ import OneSignalError from './OneSignalError'; -export enum OneSignalApiErrorKind { - MissingAppId, - RetryLimitReached, -} +export const OneSignalApiErrorKind = { + MissingAppId: 0, + RetryLimitReached: 1, +} as const; + +export type OneSignalApiErrorKindValue = + (typeof OneSignalApiErrorKind)[keyof typeof OneSignalApiErrorKind]; export class OneSignalApiError extends OneSignalError { reason!: string; - constructor(reason: OneSignalApiErrorKind) { + constructor(reason: OneSignalApiErrorKindValue) { let errorMessage; switch (reason) { case OneSignalApiErrorKind.MissingAppId: diff --git a/src/shared/errors/PushPermissionNotGrantedError.ts b/src/shared/errors/PushPermissionNotGrantedError.ts index cca55d483..74ab2bdaa 100755 --- a/src/shared/errors/PushPermissionNotGrantedError.ts +++ b/src/shared/errors/PushPermissionNotGrantedError.ts @@ -1,15 +1,18 @@ import OneSignalError from './OneSignalError'; -export enum PushPermissionNotGrantedErrorReason { - Blocked, - Dismissed, - Default, -} +export const PushPermissionNotGrantedErrorReason = { + Blocked: 0, + Dismissed: 1, + Default: 2, +} as const; + +export type PushPermissionNotGrantedErrorReasonValue = + (typeof PushPermissionNotGrantedErrorReason)[keyof typeof PushPermissionNotGrantedErrorReason]; export default class PushPermissionNotGrantedError extends OneSignalError { - reason!: PushPermissionNotGrantedErrorReason; + reason!: PushPermissionNotGrantedErrorReasonValue; - constructor(reason: PushPermissionNotGrantedErrorReason) { + constructor(reason: PushPermissionNotGrantedErrorReasonValue) { let errorMessage; switch (reason) { case PushPermissionNotGrantedErrorReason.Dismissed: diff --git a/src/shared/errors/SdkInitError.ts b/src/shared/errors/SdkInitError.ts index beca48063..5f613cddd 100755 --- a/src/shared/errors/SdkInitError.ts +++ b/src/shared/errors/SdkInitError.ts @@ -1,19 +1,26 @@ import OneSignalError from './OneSignalError'; -export enum SdkInitErrorKind { - InvalidAppId, - AppNotConfiguredForWebPush, - WrongSiteUrl, - MultipleInitialization, - MissingSafariWebId, - Unknown, -} +export const SdkInitErrorKind = { + InvalidAppId: 0, + AppNotConfiguredForWebPush: 1, + WrongSiteUrl: 2, + MultipleInitialization: 3, + MissingSafariWebId: 4, + Unknown: 5, +} as const; + +const reverseSdkInitErrorKind = Object.fromEntries( + Object.entries(SdkInitErrorKind).map(([key, value]) => [value, key]), +); + +export type SdkInitErrorKindValue = + (typeof SdkInitErrorKind)[keyof typeof SdkInitErrorKind]; export class SdkInitError extends OneSignalError { reason!: string; constructor( - reason: SdkInitErrorKind, + reason: SdkInitErrorKindValue, extra?: { siteUrl: string; }, @@ -56,7 +63,7 @@ export class SdkInitError extends OneSignalError { } super(errorMessage); - this.reason = SdkInitErrorKind[reason]; + this.reason = reverseSdkInitErrorKind[reason]; /** * Important! Required to make sure the correct error type is detected during instanceof checks. diff --git a/src/shared/errors/SubscriptionError.ts b/src/shared/errors/SubscriptionError.ts index d16ab9737..d5a0b9605 100755 --- a/src/shared/errors/SubscriptionError.ts +++ b/src/shared/errors/SubscriptionError.ts @@ -1,13 +1,16 @@ import OneSignalError from './OneSignalError'; -export enum SubscriptionErrorReason { - InvalidSafariSetup, - Blocked, - Dismissed, -} +export const SubscriptionErrorReason = { + InvalidSafariSetup: 0, + Blocked: 1, + Dismissed: 2, +} as const; + +export type SubscriptionErrorReasonValue = + (typeof SubscriptionErrorReason)[keyof typeof SubscriptionErrorReason]; export default class SubscriptionError extends OneSignalError { - constructor(reason: SubscriptionErrorReason) { + constructor(reason: SubscriptionErrorReasonValue) { let errorMessage; switch (reason) { case SubscriptionErrorReason.InvalidSafariSetup: diff --git a/src/shared/managers/SubscriptionManager.ts b/src/shared/managers/SubscriptionManager.ts index acb0aea0b..43ee7821a 100644 --- a/src/shared/managers/SubscriptionManager.ts +++ b/src/shared/managers/SubscriptionManager.ts @@ -28,8 +28,14 @@ import type { PushSubscriptionState } from '../models/PushSubscriptionState'; import { RawPushSubscription } from '../models/RawPushSubscription'; import { SessionOrigin } from '../models/Session'; import { Subscription } from '../models/Subscription'; -import { SubscriptionStrategyKind } from '../models/SubscriptionStrategyKind'; -import { UnsubscriptionStrategy } from '../models/UnsubscriptionStrategy'; +import { + SubscriptionStrategyKind, + type SubscriptionStrategyKindValue, +} from '../models/SubscriptionStrategyKind'; +import { + UnsubscriptionStrategy, + type UnsubscriptionStrategyValue, +} from '../models/UnsubscriptionStrategy'; import { WindowEnvironmentKind } from '../models/WindowEnvironmentKind'; import Database from '../services/Database'; import OneSignalEvent from '../services/OneSignalEvent'; @@ -113,7 +119,7 @@ export class SubscriptionManager { * and will select the correct method. */ public async subscribe( - subscriptionStrategy: SubscriptionStrategyKind, + subscriptionStrategy: SubscriptionStrategyKindValue, ): Promise { const env = SdkEnvironment.getWindowEnv(); @@ -311,7 +317,7 @@ export class SubscriptionManager { return await SubscriptionManager.requestNotificationPermission(); } - public async unsubscribe(strategy: UnsubscriptionStrategy) { + public async unsubscribe(strategy: UnsubscriptionStrategyValue) { if (strategy === UnsubscriptionStrategy.DestroySubscription) { throw new NotImplementedError(); } else if (strategy === UnsubscriptionStrategy.MarkUnsubscribed) { @@ -335,7 +341,7 @@ export class SubscriptionManager { */ public static async requestNotificationPermission(): Promise { const results = await window.Notification.requestPermission(); - // TODO: Clean up our custom NotificationPermission enum + // TODO: Clean up our custom NotificationPermission // in favor of TS union type NotificationPermission instead of converting return results as NotificationPermission; } @@ -423,7 +429,7 @@ export class SubscriptionManager { } private async subscribeFcmFromPage( - subscriptionStrategy: SubscriptionStrategyKind, + subscriptionStrategy: SubscriptionStrategyKindValue, ): Promise { /* Before installing the service worker, request notification permissions. If @@ -517,7 +523,7 @@ export class SubscriptionManager { } public async subscribeFcmFromWorker( - subscriptionStrategy: SubscriptionStrategyKind, + subscriptionStrategy: SubscriptionStrategyKindValue, ): Promise { /* We're running inside of the service worker. @@ -608,7 +614,7 @@ export class SubscriptionManager { */ public async subscribeWithVapidKey( pushManager: PushManager, - subscriptionStrategy: SubscriptionStrategyKind, + subscriptionStrategy: SubscriptionStrategyKindValue, ): Promise { /* Always try subscribing using VAPID by providing an applicationServerKey, except for cases diff --git a/src/shared/models/Browser.ts b/src/shared/models/Browser.ts index 94ff08a4e..01da905fa 100644 --- a/src/shared/models/Browser.ts +++ b/src/shared/models/Browser.ts @@ -1,8 +1,10 @@ -export enum Browser { - Safari = 'safari', - Firefox = 'firefox', - Chrome = 'chrome', - Opera = 'opera', - Edge = 'edge', - Other = 'other', -} +export const Browser = { + Safari: 'safari', + Firefox: 'firefox', + Chrome: 'chrome', + Opera: 'opera', + Edge: 'edge', + Other: 'other', +} as const; + +export type BrowserValue = (typeof Browser)[keyof typeof Browser]; diff --git a/src/shared/models/DeliveryPlatformKind.ts b/src/shared/models/DeliveryPlatformKind.ts index 86d4a3876..9b6172d63 100644 --- a/src/shared/models/DeliveryPlatformKind.ts +++ b/src/shared/models/DeliveryPlatformKind.ts @@ -1,9 +1,12 @@ -export enum DeliveryPlatformKind { - ChromeLike = 5, - SafariLegacy = 7, - Firefox = 8, - Email = 11, - Edge = 12, - SMS = 14, - SafariVapid = 17, -} +export const DeliveryPlatformKind = { + ChromeLike: 5, + SafariLegacy: 7, + Firefox: 8, + Email: 11, + Edge: 12, + SMS: 14, + SafariVapid: 17, +} as const; + +export type DeliveryPlatformKindValue = + (typeof DeliveryPlatformKind)[keyof typeof DeliveryPlatformKind]; diff --git a/src/shared/models/NotificationPermission.ts b/src/shared/models/NotificationPermission.ts index 4de244678..82ba3fcde 100755 --- a/src/shared/models/NotificationPermission.ts +++ b/src/shared/models/NotificationPermission.ts @@ -1,14 +1,17 @@ -export enum NotificationPermission { +export const NotificationPermission = { /** * The user has not granted notification permissions and may have just dismissed the notification permission prompt. */ - Default = 'default', + Default: 'default', /** * The user has granted notification permissions. */ - Granted = 'granted', + Granted: 'granted', /** * The user has blocked notifications. */ - Denied = 'denied', -} + Denied: 'denied', +} as const; + +export type NotificationPermissionValue = + (typeof NotificationPermission)[keyof typeof NotificationPermission]; diff --git a/src/shared/models/PermissionPromptType.ts b/src/shared/models/PermissionPromptType.ts index cacb438ab..9528f44e1 100644 --- a/src/shared/models/PermissionPromptType.ts +++ b/src/shared/models/PermissionPromptType.ts @@ -1,14 +1,17 @@ -export enum PermissionPromptType { +export const PermissionPromptType = { /** * The "main" browser native permission request dialog when prompting for local or push notification permissions. */ - HttpsPermissionRequest = 'HTTPS permission request', + HttpsPermissionRequest: 'HTTPS permission request', /** * The "sliding down" prompt. */ - SlidedownPermissionMessage = 'slidedown permission message', + SlidedownPermissionMessage: 'slidedown permission message', /** * The "notify button". */ - SubscriptionBell = 'subscription bell', -} + SubscriptionBell: 'subscription bell', +} as const; + +export type PermissionPromptTypeValue = + (typeof PermissionPromptType)[keyof typeof PermissionPromptType]; diff --git a/src/shared/models/SubscriptionStrategyKind.ts b/src/shared/models/SubscriptionStrategyKind.ts index 1a0f3b2bb..f18b30481 100644 --- a/src/shared/models/SubscriptionStrategyKind.ts +++ b/src/shared/models/SubscriptionStrategyKind.ts @@ -2,7 +2,7 @@ * When subscribing for a web push subscription, describes whether an existing subscription is first * unsubscribed or is left intact. */ -export const enum SubscriptionStrategyKind { +export const SubscriptionStrategyKind = { /** * Creates a new push subscription or resubscribes an existing push subscription. * @@ -25,7 +25,7 @@ export const enum SubscriptionStrategyKind { * unchanged still as legacy GCM). Migrating the subscription to VAPID would require first * unsubscribing, which this strategy does not attempt. */ - ResubscribeExisting, + ResubscribeExisting: 0, /** * Unsubscribes an existing push subscription if one exists, and creates a new push subscription * with a new endpoint and crypto keys. @@ -34,5 +34,8 @@ export const enum SubscriptionStrategyKind { * strategy is used to "refresh" Microsoft Edge's expiring push subscriptions by obtaining a new * subscription with a newly long duration expiration time. */ - SubscribeNew, -} + SubscribeNew: 1, +} as const; + +export type SubscriptionStrategyKindValue = + (typeof SubscriptionStrategyKind)[keyof typeof SubscriptionStrategyKind]; diff --git a/src/shared/models/UnsubscriptionStrategy.ts b/src/shared/models/UnsubscriptionStrategy.ts index f0719413f..6e4a3f916 100644 --- a/src/shared/models/UnsubscriptionStrategy.ts +++ b/src/shared/models/UnsubscriptionStrategy.ts @@ -1,10 +1,13 @@ -export const enum UnsubscriptionStrategy { +export const UnsubscriptionStrategy = { /** * Actually unsubscribe the user by removing the push subscription. */ - DestroySubscription, + DestroySubscription: 0, /** * Mute the user from receiving notifications by marking a flag in our database. */ - MarkUnsubscribed, -} + MarkUnsubscribed: 1, +} as const; + +export type UnsubscriptionStrategyValue = + (typeof UnsubscriptionStrategy)[keyof typeof UnsubscriptionStrategy]; diff --git a/src/shared/models/WindowEnvironmentKind.ts b/src/shared/models/WindowEnvironmentKind.ts index dffad8838..51a007254 100644 --- a/src/shared/models/WindowEnvironmentKind.ts +++ b/src/shared/models/WindowEnvironmentKind.ts @@ -1,11 +1,14 @@ -export enum WindowEnvironmentKind { +export const WindowEnvironmentKind = { /** * A service worker environment. */ - ServiceWorker = 'ServiceWorker', + ServiceWorker: 'ServiceWorker', /** * The top-level frame to the "main" client's site. */ - Host = 'Host', -} + Host: 'Host', +} as const; + +export type WindowEnvironmentKindValue = + (typeof WindowEnvironmentKind)[keyof typeof WindowEnvironmentKind]; diff --git a/tsconfig.json b/tsconfig.json index 31a9e2c56..6b211f31b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "ES2022", + "target": "ES2020", "useDefineForClassFields": true, "module": "ESNext", "lib": ["ESNext", "DOM", "DOM.Iterable", "WebWorker"], @@ -9,7 +9,12 @@ /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, + + /** + * Should use import type syntax instead of regular import when getting types/interfaces from a module + */ "verbatimModuleSyntax": true, + "moduleDetection": "force", "noEmit": true, @@ -17,6 +22,10 @@ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, + + /** + * Warn against using enums, parameter properties e.g. private readonly variable in constructor, etc. + */ "erasableSyntaxOnly": true, "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true,