diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/SettingData.ts | 1 | ||||
-rw-r--r-- | src/shared/Settings.ts | 1 | ||||
-rw-r--r-- | src/shared/messages.ts | 31 | ||||
-rw-r--r-- | src/shared/operations.ts | 42 |
4 files changed, 73 insertions, 2 deletions
diff --git a/src/shared/SettingData.ts b/src/shared/SettingData.ts index 05e21fa..1c085cf 100644 --- a/src/shared/SettingData.ts +++ b/src/shared/SettingData.ts @@ -390,6 +390,7 @@ export const DefaultSettingData: SettingData = SettingData.valueOf({ "/": { "type": "find.start" }, "n": { "type": "find.next" }, "N": { "type": "find.prev" }, + ".": { "type": "repeat.last" }, "<S-Esc>": { "type": "addon.toggle.enabled" } }, "search": { diff --git a/src/shared/Settings.ts b/src/shared/Settings.ts index c1b5a51..e1e2046 100644 --- a/src/shared/Settings.ts +++ b/src/shared/Settings.ts @@ -177,6 +177,7 @@ export const DefaultSetting: Settings = { '/': { 'type': 'find.start' }, 'n': { 'type': 'find.next' }, 'N': { 'type': 'find.prev' }, + '.': { 'type': 'repeat.last' }, '<S-Esc>': { 'type': 'addon.toggle.enabled' } }, search: { diff --git a/src/shared/messages.ts b/src/shared/messages.ts index fbd3478..36a23d8 100644 --- a/src/shared/messages.ts +++ b/src/shared/messages.ts @@ -42,6 +42,11 @@ export const SETTINGS_QUERY = 'settings.query'; export const CONSOLE_FRAME_MESSAGE = 'console.frame.message'; +export const NAVIGATE_HISTORY_NEXT = 'navigate.history.next'; +export const NAVIGATE_HISTORY_PREV = 'navigate.history.prev'; +export const NAVIGATE_LINK_NEXT = 'navigate.link.next'; +export const NAVIGATE_LINK_PREV = 'navigate.link.prev'; + export interface BackgroundOperationMessage { type: typeof BACKGROUND_OPERATION; operation: operations.Operation; @@ -204,6 +209,22 @@ export interface ConsoleFrameMessageMessage { message: any; } +export interface NavigateHistoryNextMessage { + type: typeof NAVIGATE_HISTORY_NEXT; +} + +export interface NavigateHistoryPrevMessage { + type: typeof NAVIGATE_HISTORY_PREV; +} + +export interface NavigateLinkNext { + type: typeof NAVIGATE_LINK_NEXT; +} + +export interface NavigateLinkPrev { + type: typeof NAVIGATE_LINK_PREV; +} + export type Message = BackgroundOperationMessage | ConsoleUnfocusMessage | @@ -236,7 +257,11 @@ export type Message = OpenUrlMessage | SettingsChangedMessage | SettingsQueryMessage | - ConsoleFrameMessageMessage; + ConsoleFrameMessageMessage | + NavigateHistoryNextMessage | + NavigateHistoryPrevMessage | + NavigateLinkNext | + NavigateLinkPrev; // eslint-disable-next-line complexity export const valueOf = (o: any): Message => { @@ -272,6 +297,10 @@ export const valueOf = (o: any): Message => { case SETTINGS_CHANGED: case SETTINGS_QUERY: case CONSOLE_FRAME_MESSAGE: + case NAVIGATE_HISTORY_NEXT: + case NAVIGATE_HISTORY_PREV: + case NAVIGATE_LINK_NEXT: + case NAVIGATE_LINK_PREV: return o; } throw new Error('unknown operation type: ' + o.type); diff --git a/src/shared/operations.ts b/src/shared/operations.ts index 688c240..2b03d9d 100644 --- a/src/shared/operations.ts +++ b/src/shared/operations.ts @@ -75,6 +75,12 @@ export const FIND_PREV = 'find.prev'; export const MARK_SET_PREFIX = 'mark.set.prefix'; export const MARK_JUMP_PREFIX = 'mark.jump.prefix'; +// Repeat +export const REPEAT_LAST = 'repeat.last'; + +// Internal +export const INTERNAL_OPEN_URL = 'internal.open.url'; + export interface CancelOperation { type: typeof CANCEL; } @@ -291,6 +297,18 @@ export interface MarkJumpPrefixOperation { type: typeof MARK_JUMP_PREFIX; } +export interface RepeatLastOperation { + type: typeof REPEAT_LAST; +} + +export interface InternalOpenUrl { + type: typeof INTERNAL_OPEN_URL; + url: string; + newTab?: boolean; + newWindow?: boolean; + background?: boolean; +} + export type Operation = CancelOperation | AddonEnableOperation | @@ -342,7 +360,9 @@ export type Operation = FindNextOperation | FindPrevOperation | MarkSetPrefixOperation | - MarkJumpPrefixOperation; + MarkJumpPrefixOperation | + RepeatLastOperation | + InternalOpenUrl; const assertOptionalBoolean = (obj: any, name: string) => { if (Object.prototype.hasOwnProperty.call(obj, name) && @@ -358,6 +378,13 @@ const assertRequiredNumber = (obj: any, name: string) => { } }; +const assertRequiredString = (obj: any, name: string) => { + if (!Object.prototype.hasOwnProperty.call(obj, name) || + typeof obj[name] !== 'string') { + throw new TypeError(`Missing string parameter '${name}`); + } +}; + // eslint-disable-next-line complexity, max-lines-per-function export const valueOf = (o: any): Operation => { if (!Object.prototype.hasOwnProperty.call(o, 'type')) { @@ -401,6 +428,18 @@ export const valueOf = (o: any): Operation => { type: URLS_PASTE, newTab: Boolean(typeof o.newTab === undefined ? false : o.newTab), }; + case INTERNAL_OPEN_URL: + assertOptionalBoolean(o, 'newTab'); + assertOptionalBoolean(o, 'newWindow'); + assertOptionalBoolean(o, 'background'); + assertRequiredString(o, 'url'); + return { + type: INTERNAL_OPEN_URL, + url: o.url, + newTab: Boolean(typeof o.newTab === undefined ? false : o.newTab), + newWindow: Boolean(typeof o.newWindow === undefined ? false : o.newWindow), // eslint-disable-line max-len + background: Boolean(typeof o.background === undefined ? true : o.background), // eslint-disable-line max-len + }; case CANCEL: case ADDON_ENABLE: case ADDON_DISABLE: @@ -441,6 +480,7 @@ export const valueOf = (o: any): Operation => { case FIND_PREV: case MARK_SET_PREFIX: case MARK_JUMP_PREFIX: + case REPEAT_LAST: return { type: o.type }; } throw new TypeError('unknown operation type: ' + o.type); |