Skip to content

Commit

Permalink
feat(hooks): GlobalPreloadHookContext
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Mar 4, 2023
1 parent 21c7198 commit e50a12d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"@types/eslint": "8.21.1",
"@types/git-raw-commits": "2.0.1",
"@types/is-ci": "3.0.0",
"@types/node": "18.14.6",
"@types/node-notifier": "8.0.2",
"@types/prettier": "2.7.2",
"@types/semver": "7.3.13",
Expand Down
15 changes: 15 additions & 0 deletions src/hooks/__tests__/global-preload-context.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @file Type Tests - GlobalPreloadHookContext
* @module esm-types/hooks/tests/unit-d/GlobalPreloadHookContext
*/

import type { MessagePort } from 'node:worker_threads'
import type TestSubject from '../global-preload-context'

describe('unit-d:hooks/GlobalPreloadHookContext', () => {
it('should match [port: MessagePort]', () => {
expectTypeOf<TestSubject>()
.toHaveProperty('port')
.toEqualTypeOf<MessagePort>()
})
})
21 changes: 21 additions & 0 deletions src/hooks/global-preload-context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @file Hooks - GlobalPreloadHookContext
* @module esm-types/hooks/GlobalPreloadHookContext
*/

import type { MessagePort } from 'node:worker_threads'

/**
* [`globalPreload`][1] hook context.
*
* [1]: https://nodejs.org/api/esm.html#globalpreload
*/
interface GlobalPreloadHookContext {
/**
* {@linkcode MessagePort} to allow communication between the application and
* the loader.
*/
port: MessagePort
}

export type { GlobalPreloadHookContext as default }
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export type { default as GetFormatHookContext } from './get-format-context'
export type { default as GetFormatHookResult } from './get-format-result'
export type { default as GetSourceHook } from './get-source'
export type { default as GetSourceHookContext } from './get-source-context'
export type { default as GlobalPreloadHookContext } from './global-preload-context'
export type { default as SourceHookResult } from './source-result'
2 changes: 1 addition & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const config: UserConfigExport = defineConfig((): UserConfig => {
'**/__tests__/**',
'**/index.ts',
'src/enums/',
'src/hooks/',
'src/interfaces/',
'src/nodes/',
'src/types/'
],
extension: ['.ts'],
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,7 @@ __metadata:
"@types/eslint": "npm:8.21.1"
"@types/git-raw-commits": "npm:2.0.1"
"@types/is-ci": "npm:3.0.0"
"@types/node": "npm:18.14.6"
"@types/node-notifier": "npm:8.0.2"
"@types/prettier": "npm:2.7.2"
"@types/semver": "npm:7.3.13"
Expand Down Expand Up @@ -2218,7 +2219,7 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:*":
"@types/node@npm:*, @types/node@npm:18.14.6":
version: 18.14.6
resolution: "@types/node@npm:18.14.6"
checksum: 4bbd9fe4cb1b31afe4f76b0b37fe51e46199dc57ab519811f61456cb267d7590323e6c687041f5a73872858d9eb64fdd158e9f669bbb36979d59ec7a91396dfa
Expand Down

0 comments on commit e50a12d

Please sign in to comment.