Skip to content

Commit

Permalink
starting docs
Browse files Browse the repository at this point in the history
  • Loading branch information
booploops committed Oct 4, 2024
1 parent 5148a4d commit 2f37c6c
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dist
.eslintcache
*.log*
*.env*
.obsidian
2 changes: 1 addition & 1 deletion build/index.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ declare function createModal(opts: CreateModalOptions): {
*
* Learn more at https://developer.apple.com/documentation/musickitjs
*/
declare function useMusicKit(): any;
declare function useMusicKit(): MusicKit.MusicKitInstance;

declare function useRouter(): any;
declare function getURLParam(name: string): string | null;
Expand Down
2 changes: 1 addition & 1 deletion build/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ declare function createModal(opts: CreateModalOptions): {
*
* Learn more at https://developer.apple.com/documentation/musickitjs
*/
declare function useMusicKit(): any;
declare function useMusicKit(): MusicKit.MusicKitInstance;

declare function useRouter(): any;
declare function getURLParam(name: string): string | null;
Expand Down
106 changes: 106 additions & 0 deletions docs/API Documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
## Functions

### `useMessageListener`

Registers a callback function to be called when a specified event occurs.

```typescript
useMessageListener(eventName: string, callback: (e: any) => void, opts?: Partial<{
once: boolean;
passive: boolean;
capture: boolean;
}>): () => void;
```

- **eventName**: The name of the event to listen for.
- **callback**: The function to call when the event occurs.
- **opts**: Optional settings for the event listener.
- **once**: If true, the listener will be removed after the first call.
- **passive**: If true, indicates that the function will never call `preventDefault()`.
- **capture**: If true, the event will be captured in the capturing phase.

### `createModal`

Creates a modal dialog with specified options.

```typescript
createModal(opts: CreateModalOptions): {
openDialog: () => void;
closeDialog: () => void;
dialogElement: HTMLDialogElement;
addClass: (className: BuiltInClasses) => void;
};
```

- **opts**: Options for creating the modal.
- **escClose**: If true, the modal can be closed with the Escape key.
- **className**: An array of classes to add to the modal.
- **noDefaultClass**: If true, the default class will not be added.
- **element**: The HTML element to use for the modal.

### `useMusicKit`

Provides access to the MusicKit JS API.

Learn more at https://developer.apple.com/documentation/musickitjs

```typescript
useMusicKit(): MusicKit.MusicKitInstance;
```

### `useRouter`

Provides access to the router.

```typescript
useRouter(): any;
```

### `getURLParam`

Gets the value of a URL parameter by name.

```typescript
getURLParam(name: string): string | null;
```

- **name**: The name of the URL parameter.

### `useCider`

Provides access to the CiderApp.

```typescript
useCider(): typeof CiderApp;
```

## Exports

The following symbols are exported:

- `ComponentNames`
- `CustomButtonOptions`
- `CustomImmersiveLayout`
- `ExternalMessages`
- `MenuItem`
- `PluginAPI`
- `addCustomButton`
- `addImmersiveLayout`
- `addImmersiveMenuEntry`
- `addMainMenuEntry`
- `addMediaItemContextMenuEntry`
- `createModal`
- `definePluginContext`
- `getURLParam`
- `removeImmersiveLayout`
- `removeImmersiveLayoutById`
- `saveConfig`
- `subscribeEvent`
- `subscribeEventOnce`
- `unsubscribeEvent`
- `useCider`
- `useCiderAudio`
- `useMessageListener`
- `useMusicKit`
- `useRouter`

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"test:types": "tsc --noEmit --skipLibCheck"
},
"devDependencies": {
"@types/musickit": "ciderapp/musickit-types",
"@types/lodash": "^4.17.9",
"@types/node": "^22.1.0",
"@vitest/coverage-v8": "^2.0.5",
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

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

6 changes: 3 additions & 3 deletions src/api/MusicKit.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* MusicKit JS API
*
*
* Learn more at https://developer.apple.com/documentation/musickitjs
*/
export function useMusicKit() {
return window.MusicKit.getInstance();
}
return window.MusicKit.getInstance() as MusicKit.MusicKitInstance;
}

0 comments on commit 2f37c6c

Please sign in to comment.