-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add messaging contract for duck player page
- Loading branch information
Shane Osbourne
committed
Jul 31, 2024
1 parent
e4a01f6
commit ce63bd8
Showing
13 changed files
with
275 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
packages/special-pages/messages/duckplayer/getUserValues.request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#" | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/special-pages/messages/duckplayer/getUserValues.response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"allOf": [ | ||
{ | ||
"$ref": "./userValues.shared.json" | ||
} | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/special-pages/messages/duckplayer/initialSetup.request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#" | ||
} |
52 changes: 52 additions & 0 deletions
52
packages/special-pages/messages/duckplayer/initialSetup.response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"required": ["userValues", "settings", "locale", "env", "platform"], | ||
"properties": { | ||
"userValues": { "$ref": "./userValues.shared.json" }, | ||
"settings": { | ||
"type": "object", | ||
"title": "DuckPlayerPageSettings", | ||
"required": ["pip"], | ||
"properties": { | ||
"pip": { | ||
"type": "object", | ||
"required": ["state"], | ||
"properties": { | ||
"state": { | ||
"type": "string", | ||
"enum": ["enabled", "disabled"] | ||
} | ||
} | ||
}, | ||
"autoplay": { | ||
"type": "object", | ||
"required": ["state"], | ||
"properties": { | ||
"state": { | ||
"type": "string", | ||
"enum": ["enabled", "disabled"] | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"locale": { | ||
"type": "string" | ||
}, | ||
"env": { | ||
"type": "string", | ||
"enum": ["development", "production"] | ||
}, | ||
"platform": { | ||
"type": "object", | ||
"required": ["name"], | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"enum": ["macos", "windows", "android", "ios"] | ||
} | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/special-pages/messages/duckplayer/onUserValuesChanged.subscribe.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"allOf": [ | ||
{ | ||
"$ref": "./userValues.shared.json" | ||
} | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
packages/special-pages/messages/duckplayer/openInfo.notify.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
1 change: 1 addition & 0 deletions
1
packages/special-pages/messages/duckplayer/openSettings.notify.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
10 changes: 10 additions & 0 deletions
10
packages/special-pages/messages/duckplayer/reportInitException.notify.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"required": ["message"], | ||
"properties": { | ||
"message": { | ||
"type": "string" | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/special-pages/messages/duckplayer/reportPageException.notify.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"required": ["message"], | ||
"properties": { | ||
"message": { | ||
"type": "string" | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/special-pages/messages/duckplayer/setUserValues.request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"allOf": [ | ||
{ | ||
"$ref": "./userValues.shared.json" | ||
} | ||
] | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/special-pages/messages/duckplayer/setUserValues.response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"allOf": [ | ||
{ | ||
"$ref": "./userValues.shared.json" | ||
} | ||
] | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/special-pages/messages/duckplayer/userValues.shared.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"title": "UserValues", | ||
"additionalProperties": false, | ||
"required": ["overlayInteracted", "privatePlayerMode"], | ||
"properties": { | ||
"overlayInteracted": { | ||
"type": "boolean" | ||
}, | ||
"privatePlayerMode": { | ||
"title": "PrivatePlayerMode", | ||
"oneOf": [ | ||
{ | ||
"type": "object", | ||
"required": ["enabled"], | ||
"additionalProperties": false, | ||
"properties": { | ||
"enabled": {} | ||
} | ||
}, | ||
{ | ||
"type": "object", | ||
"required": ["disabled"], | ||
"additionalProperties": false, | ||
"properties": { | ||
"disabled": {} | ||
} | ||
}, | ||
{ | ||
"type": "object", | ||
"additionalProperties": false, | ||
"required": ["alwaysAsk"], | ||
"properties": { | ||
"alwaysAsk": {} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/** | ||
* @module Duckplayer Messages | ||
* @description | ||
* | ||
* These types are auto-generated from schema files. | ||
* scripts/build-types.mjs is responsible for type generation. | ||
* **DO NOT** edit this file directly as your changes will be lost. | ||
*/ | ||
|
||
export type PrivatePlayerMode = | ||
| { | ||
enabled: unknown; | ||
} | ||
| { | ||
disabled: unknown; | ||
} | ||
| { | ||
alwaysAsk: unknown; | ||
}; | ||
|
||
/** | ||
* Requests, Notifications and Subscriptions from the Duckplayer feature | ||
*/ | ||
export interface DuckplayerMessages { | ||
notifications: | ||
| OpenInfoNotification | ||
| OpenSettingsNotification | ||
| ReportInitExceptionNotification | ||
| ReportPageExceptionNotification; | ||
requests: GetUserValuesRequest | InitialSetupRequest | SetUserValuesRequest; | ||
subscriptions: OnUserValuesChangedSubscription; | ||
} | ||
/** | ||
* Generated from @see "../messages/duckplayer/openInfo.notify.json" | ||
*/ | ||
export interface OpenInfoNotification { | ||
method: "openInfo"; | ||
} | ||
/** | ||
* Generated from @see "../messages/duckplayer/openSettings.notify.json" | ||
*/ | ||
export interface OpenSettingsNotification { | ||
method: "openSettings"; | ||
} | ||
/** | ||
* Generated from @see "../messages/duckplayer/reportInitException.notify.json" | ||
*/ | ||
export interface ReportInitExceptionNotification { | ||
method: "reportInitException"; | ||
params: ReportInitExceptionNotify; | ||
} | ||
export interface ReportInitExceptionNotify { | ||
message: string; | ||
} | ||
/** | ||
* Generated from @see "../messages/duckplayer/reportPageException.notify.json" | ||
*/ | ||
export interface ReportPageExceptionNotification { | ||
method: "reportPageException"; | ||
params: ReportPageExceptionNotify; | ||
} | ||
export interface ReportPageExceptionNotify { | ||
message: string; | ||
} | ||
/** | ||
* Generated from @see "../messages/duckplayer/getUserValues.request.json" | ||
*/ | ||
export interface GetUserValuesRequest { | ||
method: "getUserValues"; | ||
result: UserValues; | ||
} | ||
export interface UserValues { | ||
overlayInteracted: boolean; | ||
privatePlayerMode: PrivatePlayerMode; | ||
} | ||
/** | ||
* Generated from @see "../messages/duckplayer/initialSetup.request.json" | ||
*/ | ||
export interface InitialSetupRequest { | ||
method: "initialSetup"; | ||
result: InitialSetupResponse; | ||
} | ||
export interface InitialSetupResponse { | ||
userValues: UserValues; | ||
settings: DuckPlayerPageSettings; | ||
locale: string; | ||
env: "development" | "production"; | ||
platform: { | ||
name: "macos" | "windows" | "android" | "ios"; | ||
}; | ||
} | ||
export interface DuckPlayerPageSettings { | ||
pip: { | ||
state: "enabled" | "disabled"; | ||
}; | ||
autoplay?: { | ||
state: "enabled" | "disabled"; | ||
}; | ||
} | ||
/** | ||
* Generated from @see "../messages/duckplayer/setUserValues.request.json" | ||
*/ | ||
export interface SetUserValuesRequest { | ||
method: "setUserValues"; | ||
params: UserValues; | ||
result: UserValues; | ||
} | ||
/** | ||
* Generated from @see "../messages/duckplayer/onUserValuesChanged.subscribe.json" | ||
*/ | ||
export interface OnUserValuesChangedSubscription { | ||
subscriptionEvent: "onUserValuesChanged"; | ||
params: UserValues; | ||
} | ||
|
||
declare module "../pages/duckplayer/src/js/index.js" { | ||
export interface DuckplayerPage { | ||
notify: import("@duckduckgo/messaging/lib/shared-types").MessagingBase<DuckplayerMessages>['notify'], | ||
request: import("@duckduckgo/messaging/lib/shared-types").MessagingBase<DuckplayerMessages>['request'], | ||
subscribe: import("@duckduckgo/messaging/lib/shared-types").MessagingBase<DuckplayerMessages>['subscribe'] | ||
} | ||
} |