Skip to content

Commit 3c47407

Browse files
authored
Merge pull request #6 from factman/feature/permissions-api
Improve PermissionsAPI Error Handling and Remove nxCloud Access Token
2 parents e7fc42c + 98d2bf6 commit 3c47407

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

.github/workflows/verify.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
branches:
66
- main
77
pull_request:
8-
98
permissions:
109
actions: read
1110
contents: read
@@ -22,21 +21,16 @@ jobs:
2221
with:
2322
version: 9
2423

25-
# This enables task distribution via Nx Cloud
26-
# Run this command as early as possible, before dependencies are installed
27-
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
28-
- run: pnpm dlx nx-cloud start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="build"
29-
3024
# Cache node_modules
3125
- uses: actions/setup-node@v4
3226
with:
3327
node-version: 20
3428
cache: 'pnpm'
3529

36-
- run: pnpm install --frozen-lockfile
30+
- run: pnpm install --no-frozen-lockfile
3731
- uses: nrwl/nx-set-shas@v4
3832

3933
# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
4034
# - run: pnpm exec nx-cloud record -- echo Hello World
4135
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected
42-
- run: pnpm exec nx affected -t build && pnpm build
36+
- run: pnpx nx affected -t build && pnpm build

eslint.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export default [
2020
'**/.nx',
2121
'**/pnpm-*.yaml',
2222
'**/node_modules',
23-
'**/dist'
23+
'**/dist',
24+
'**/*.html'
2425
]
2526
},
2627
{

nx.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,5 @@
2929
"sharedGlobals"
3030
]
3131
},
32-
"nxCloudId": "681f1bf43845db51336764b6",
33-
"nxCloudAccessToken": "OWM0ZThhYWItODQwYS00ZjgzLWJhMWMtODYyOTgzMDVjMmZhfHJlYWQtd3JpdGU="
32+
"nxCloudId": "681f1bf43845db51336764b6"
3433
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"type": "git",
1010
"url": "https://github.com/ArcStackLab/webapis.git"
1111
},
12-
"packageManager": "pnpm@9.2.0",
12+
"packageManager": "pnpm@9",
1313
"description": "A Comprehensive Integration of All Web Standard APIs",
1414
"scripts": {
1515
"build": "tsup",
@@ -52,8 +52,11 @@
5252
"esbuild": "^0.23.1",
5353
"eslint": "^9.9.1",
5454
"globals": "^15.9.0",
55+
"gulp": "^5.0.0",
56+
"gulp-cli": "^3.0.0",
5557
"husky": "^9.1.5",
5658
"lint-staged": "^15.2.10",
59+
"netlify-cli": "^21.4.2",
5760
"nx": "19.8.0",
5861
"prettier": "^3.3.3",
5962
"tslib": "^2.7.0",

packages/permissions/demo/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function createOptionTag(value) {
1919
}
2020

2121
/**
22-
* @type {ReturnType<PermissionsAPI.getPermissionHandler>}
22+
* @type {ReturnType<getPermissionHandler>}
2323
*/
2424
let permissionHandler
2525
const closeButton = document.querySelector('#close')
@@ -49,7 +49,7 @@ const stateColor = {
4949
}
5050

5151
function handlePermission(option) {
52-
permissionHandler = PermissionsAPI.getPermissionHandler(option, {
52+
permissionHandler = getPermissionHandler(option, {
5353
granted: (permission) => {
5454
console.log('Permission Granted:', permission)
5555
state.replaceChildren(

packages/permissions/src/PermissionsAPI.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ export class PermissionsAPI {
202202
getPermission: () => {
203203
const _events = PermissionsAPI.#events.get(_handler)
204204

205+
if (!_events || _handler === null) throw new Error('Cannot get permission: handler has been closed')
206+
205207
PermissionsAPI.getPermission(permissionOption).then(
206208
({ error, permission }) => {
207209
if (error) {

packages/permissions/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export type PermissionHandler<T = void> = {
150150
/**
151151
* Executes the permission request.
152152
* @returns {T} - The result of the permission request.
153+
* @throws {Error} - Throws if handler is already closed
153154
*/
154155
getPermission: () => T
155156

0 commit comments

Comments
 (0)