Skip to content

Commit

Permalink
fix(refactor): global Redux store persist, per-publication session st…
Browse files Browse the repository at this point in the history
…ate, OPDS catalog last column info, tags editor prevent empty text, mismatched reader settings (PR #930 Fixes #1036 Fixes #1037 Fixes #1035 Fixes #911)
  • Loading branch information
panaC authored May 6, 2020
1 parent 3a235fe commit 321c18b
Show file tree
Hide file tree
Showing 203 changed files with 8,545 additions and 3,011 deletions.
1,592 changes: 1,575 additions & 17 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"start:dev:main:electron": "cross-env DEBUG=r2:*,readium-desktop:* NODE_ENV=development electron .",
"start:dev:main": "npm run build:dev:main && npm run start:dev:main:electron",
"start:devex": "cross-env WEBPACK=bundle-external npm run start:dev",
"start:dev": "cross-env DEBUG_COLORS=true concurrently --kill-others \"npm run start:dev:renderer:library\" \"npm run start:dev:renderer:reader\" \"npm run start:dev:main\"",
"start:dev": "cross-env DEBUG_COLORS=true concurrently --kill-others \"npm run start:dev:renderer:library\" \"npm run start:dev:renderer:reader\" \"npm run start:dev:main\" \"npm run redux-devtools\"",
"vscode:launch:attach:electron": "electron --enable-logging --remote-debugging-port=9223 --inspect=25575 --nolazy .",
"vscode:launch:attach": "cross-env DEBUG=r2:*,readium-desktop:* NODE_ENV=development VSCODE_LAUNCH=true npm run build:dev:main && concurrently --kill-others \"npm run start:dev:renderer:library\" \"npm run start:dev:renderer:reader\" \"npm run vscode:launch:attach:electron\"",
"vscode:launch:hot": "cross-env DEBUG=r2:*,readium-desktop:* NODE_ENV=development VSCODE_LAUNCH=true npm run build:dev:main",
Expand All @@ -56,7 +56,8 @@
"i18n-sort": "node ./scripts/locales-sort.js",
"i18n-scan": "node ./scripts/translate-scan.js \"src/resources/locales/temp.json\" && sync-i18n --files 'src/resources/locales/*.json' --primary temp --languages en fr de en nl --space 4 --finalnewline --newkeysempty && rimraf \"src/resources/locales/temp.json\"",
"i18n-check": "sync-i18n --files 'src/resources/locales/*.json' --primary en --languages fr de en nl --space 4 --finalnewline --newkeysempty",
"i18n-typed": "node ./scripts/locale-wrap.js \"src/resources/locales/en.json\" \"en.json\" && typed_i18n -i \"en.json\" -o src/typings -l typescript && rimraf \"en.json\""
"i18n-typed": "node ./scripts/locale-wrap.js \"src/resources/locales/en.json\" \"en.json\" && typed_i18n -i \"en.json\" -o src/typings -l typescript && rimraf \"en.json\"",
"redux-devtools": "redux-devtools --hostname=localhost --port=7770"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -212,6 +213,7 @@
"r2-shared-js": "^1.0.35",
"r2-streamer-js": "^1.0.27",
"r2-utils-js": "^1.0.20",
"ramda": "^0.27.0",
"react": "^16.13.1",
"react-beautiful-dnd": "^13.0.0",
"react-dom": "^16.13.1",
Expand Down Expand Up @@ -245,13 +247,15 @@
"@types/jest": "^24.9.1",
"@types/node": "^12.12.37",
"@types/pouchdb-core": "^7.0.5",
"@types/ramda": "^0.26.41",
"@types/react": "^16.9.34",
"@types/react-beautiful-dnd": "^12.1.2",
"@types/react-dom": "^16.9.7",
"@types/react-redux": "^7.1.8",
"@types/react-router": "^5.1.7",
"@types/react-router-dom": "^5.1.5",
"@types/redux": "^3.6.31",
"@types/remote-redux-devtools": "^0.5.4",
"@types/request": "^2.48.4",
"@types/tmp": "^0.2.0",
"@types/urijs": "^1.19.8",
Expand Down Expand Up @@ -290,7 +294,9 @@
"pouchdb-adapter-memory": "^7.2.1",
"react-axe": "^3.4.1",
"react-svg-loader": "^3.0.3",
"redux-devtools-cli": "0.0.1-1",
"redux-devtools-extension": "^2.13.8",
"remote-redux-devtools": "^0.5.16",
"rimraf": "^3.0.2",
"style-loader": "^1.2.1",
"svg-sprite-loader": "^4.3.0",
Expand Down
4 changes: 3 additions & 1 deletion src/common/api/api.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import { ILcpModuleApi } from "./interface/lcpApi.interface";
import { IOpdsModuleApi } from "./interface/opdsApi.interface";
import { IPublicationModuleApi } from "./interface/publicationApi.interface";
import { IReaderModuleApi } from "./interface/readerApi.interface";
import { ISessionModuleApi } from "./interface/session.interface";

export type TApiMethod =
ICatalogModuleApi &
ILcpModuleApi &
IOpdsModuleApi &
IKeyboardModuleApi &
IPublicationModuleApi &
IReaderModuleApi;
IReaderModuleApi &
ISessionModuleApi;

export type TApiMethodName = keyof TApiMethod;
14 changes: 7 additions & 7 deletions src/common/api/interface/catalog.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==

import { CatalogEntryView, CatalogView } from "readium-desktop/common/views/catalog";
import { CatalogView } from "readium-desktop/common/views/catalog";

export interface ICatalogApi {
get: () => Promise<CatalogView>;
addEntry: (entryView: CatalogEntryView) => Promise<CatalogEntryView[]>;
getEntries: () => Promise<CatalogEntryView[]>;
updateEntries: (entryView: CatalogEntryView[]) => Promise<CatalogEntryView[]>;
// addEntry: (entryView: CatalogEntryView) => Promise<CatalogEntryView[]>;
// getEntries: () => Promise<CatalogEntryView[]>;
// updateEntries: (entryView: CatalogEntryView[]) => Promise<CatalogEntryView[]>;
}

export interface ICatalogModuleApi {
"catalog/get": ICatalogApi["get"];
"catalog/addEntry": ICatalogApi["addEntry"];
"catalog/getEntries": ICatalogApi["getEntries"];
"catalog/updateEntries": ICatalogApi["updateEntries"];
// "catalog/addEntry": ICatalogApi["addEntry"];
// "catalog/getEntries": ICatalogApi["getEntries"];
// "catalog/updateEntries": ICatalogApi["updateEntries"];
}
3 changes: 2 additions & 1 deletion src/common/api/interface/opdsApi.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
IOpdsFeedView, IOpdsLinkView, THttpGetOpdsResultView,
} from "readium-desktop/common/views/opds";

export type TOpdsLinkSearch = Required<Pick<IOpdsLinkView, "url" | "type">>;
// quite useless
export type TOpdsLinkSearch = Required<Pick<IOpdsLinkView, "url">>;

export interface IOpdsApi {
getFeed: (
Expand Down
10 changes: 7 additions & 3 deletions src/common/api/interface/readerApi.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==

import { ReaderMode } from "readium-desktop/common/models/reader";
import { LocatorView } from "readium-desktop/common/views/locator";

import { IEventPayload_R2_EVENT_CLIPBOARD_COPY } from "@r2-navigator-js/electron/common/events";
import { LocatorExtended } from "@r2-navigator-js/electron/renderer";
import { Locator as R2Locator } from "@r2-shared-js/models/locator";

export interface IReaderApi {
setLastReadingLocation: (publicationIdentifier: string, locator: R2Locator) => Promise<LocatorView>;
getLastReadingLocation: (publicationIdentifier: string) => Promise<LocatorView>;
// setLastReadingLocation: (publicationIdentifier: string, locator: R2Locator) => Promise<LocatorView>;
getLastReadingLocation: (publicationIdentifier: string) => Promise<LocatorExtended | undefined>;
findBookmarks: (publicationIdentifier: string) => Promise<LocatorView[]>;
updateBookmark: (
identifier: string,
Expand All @@ -29,14 +31,16 @@ export interface IReaderApi {
clipboardCopy: (
publicationIdentifier: string,
clipboardData: IEventPayload_R2_EVENT_CLIPBOARD_COPY) => Promise<boolean>;
getMode: () => Promise<ReaderMode>;
}

export interface IReaderModuleApi {
"reader/setLastReadingLocation": IReaderApi["setLastReadingLocation"];
// "reader/setLastReadingLocation": IReaderApi["setLastReadingLocation"];
"reader/getLastReadingLocation": IReaderApi["getLastReadingLocation"];
"reader/findBookmarks": IReaderApi["findBookmarks"];
"reader/updateBookmark": IReaderApi["updateBookmark"];
"reader/addBookmark": IReaderApi["addBookmark"];
"reader/deleteBookmark": IReaderApi["deleteBookmark"];
"reader/clipboardCopy": IReaderApi["clipboardCopy"];
"reader/getMode": IReaderApi["getMode"];
}
16 changes: 16 additions & 0 deletions src/common/api/interface/session.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// ==LICENSE-BEGIN==
// Copyright 2017 European Digital Reading Lab. All rights reserved.
// Licensed to the Readium Foundation under one or more contributor license agreements.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==

export interface ISessionApi {
enable: (bool: boolean) => Promise<void>;
isEnabled: () => Promise<boolean>;
}

export interface ISessionModuleApi {
"session/enable": ISessionApi["enable"];
"session/isEnabled": ISessionApi["isEnabled"];
}
4 changes: 3 additions & 1 deletion src/common/api/methodApi.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import { ILcpApi } from "./interface/lcpApi.interface";
import { IOpdsApi } from "./interface/opdsApi.interface";
import { IPublicationApi } from "./interface/publicationApi.interface";
import { IReaderApi } from "./interface/readerApi.interface";
import { ISessionApi } from "./interface/session.interface";

export type TMethodApi =
keyof ICatalogApi |
keyof IPublicationApi |
keyof IOpdsApi |
keyof IKeyboardApi |
keyof ILcpApi |
keyof IReaderApi;
keyof IReaderApi |
keyof ISessionApi;
4 changes: 3 additions & 1 deletion src/common/api/moduleApi.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ type TOpdsApi = "opds";
type TKeyboardApi = "keyboardShortcuts";
type TLcpApi = "lcp";
type TReaderApi = "reader";
type TSessionApi = "session";
export type TModuleApi =
TCatalogApi |
TPublicationApi |
TOpdsApi |
TKeyboardApi |
TLcpApi |
TReaderApi;
TReaderApi |
TSessionApi;
File renamed without changes.
74 changes: 74 additions & 0 deletions src/common/computeReadiumCssJsonMessage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// ==LICENSE-BEGIN==
// Copyright 2017 European Digital Reading Lab. All rights reserved.
// Licensed to the Readium Foundation under one or more contributor license agreements.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==

import { ReaderConfig } from "readium-desktop/common/models/reader";

import { IEventPayload_R2_EVENT_READIUMCSS } from "@r2-navigator-js/electron/common/events";
import {
colCountEnum, IReadiumCSS, readiumCSSDefaults, textAlignEnum,
} from "@r2-navigator-js/electron/common/readium-css-settings";

export const computeReadiumCssJsonMessage = (settings: ReaderConfig): IEventPayload_R2_EVENT_READIUMCSS => {

const cssJson: IReadiumCSS = {

a11yNormalize: readiumCSSDefaults.a11yNormalize,

backgroundColor: readiumCSSDefaults.backgroundColor,

bodyHyphens: readiumCSSDefaults.bodyHyphens,

colCount: settings.colCount === "1" ? colCountEnum.one :
(settings.colCount === "2" ? colCountEnum.two : colCountEnum.auto),

darken: settings.darken,

font: settings.font,

fontSize: settings.fontSize,

invert: settings.invert,

letterSpacing: settings.letterSpacing,

ligatures: readiumCSSDefaults.ligatures,

lineHeight: settings.lineHeight,

night: settings.night,

pageMargins: settings.pageMargins,

paged: settings.paged,

paraIndent: readiumCSSDefaults.paraIndent,

paraSpacing: settings.paraSpacing,

sepia: settings.sepia,

noFootnotes: settings.noFootnotes,

textAlign: settings.align === textAlignEnum.left ? textAlignEnum.left :
(settings.align === textAlignEnum.right ? textAlignEnum.right :
(settings.align === textAlignEnum.justify ? textAlignEnum.justify :
(settings.align === textAlignEnum.start ? textAlignEnum.start : undefined))),

textColor: readiumCSSDefaults.textColor,

typeScale: readiumCSSDefaults.typeScale,

wordSpacing: settings.wordSpacing,

mathJax: settings.enableMathJax,

reduceMotion: readiumCSSDefaults.reduceMotion,
};

const jsonMsg: IEventPayload_R2_EVENT_READIUMCSS = { setCSS: cssJson };
return jsonMsg;
};
2 changes: 2 additions & 0 deletions src/common/ipc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==

import * as readerIpc from "./reader";
import * as syncIpc from "./sync";
import * as winIpc from "./win";

export {
readerIpc,
syncIpc,
winIpc,
};
22 changes: 22 additions & 0 deletions src/common/ipc/reader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// ==LICENSE-BEGIN==
// Copyright 2017 European Digital Reading Lab. All rights reserved.
// Licensed to the Readium Foundation under one or more contributor license agreements.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==

import {
IReaderRootState,
} from "readium-desktop/common/redux/states/renderer/readerRootState";

export enum EventType {
request = "REQUEST",
response = "RESPONSE",
}

export const CHANNEL = "READER_INIT";

export interface EventPayload {
type: EventType;
payload: Partial<IReaderRootState>;
}
2 changes: 1 addition & 1 deletion src/common/ipc/win.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export const CHANNEL = "WIN";
export interface EventPayload {
type: EventType;
payload: {
winId: string;
identifier: string;
};
}
8 changes: 1 addition & 7 deletions src/common/models/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==

import { BrowserWindow } from "electron";

import { Identifiable } from "./identifiable";

export enum ReaderMode {
Attached = "attached",
Detached = "detached",
Expand All @@ -17,12 +13,10 @@ export enum ReaderMode {
/**
* A reader
*/
export interface Reader extends Identifiable {
export interface ReaderInfo {
filesystemPath: string;
manifestUrl: string;
publicationIdentifier: string;
browserWindow: BrowserWindow;
browserWindowID: number;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/common/models/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export enum SenderType {

export interface WindowSender {
type: SenderType;
winId: string;
identifier: string;
}

export interface WithSender {
Expand Down
40 changes: 20 additions & 20 deletions src/common/models/win.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// ==LICENSE-BEGIN==
// Copyright 2017 European Digital Reading Lab. All rights reserved.
// Licensed to the Readium Foundation under one or more contributor license agreements.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==
// // ==LICENSE-BEGIN==
// // Copyright 2017 European Digital Reading Lab. All rights reserved.
// // Licensed to the Readium Foundation under one or more contributor license agreements.
// // Use of this source code is governed by a BSD-style license
// // that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// // ==LICENSE-END==

import { BrowserWindow } from "electron";
// import { BrowserWindow } from "electron";

import { IOnWindowMoveResize } from "../rectangle/window";
import { Identifiable } from "./identifiable";
// import { IOnWindowMoveResize } from "../rectangle/window";
// import { Identifiable } from "./identifiable";

export enum AppWindowType {
Library = "library",
Reader = "reader",
}
// export enum AppWindowType {
// Library = "library",
// Reader = "reader",
// }

export interface AppWindow extends Identifiable {
type: AppWindowType;
browserWindow: BrowserWindow;
browserWindowID: number;
onWindowMoveResize: IOnWindowMoveResize;
registerIndex: number;
}
// export interface AppWindow extends Identifiable {
// type: AppWindowType;
// browserWindow: BrowserWindow;
// browserWindowID: number;
// onWindowMoveResize: IOnWindowMoveResize;
// registerIndex: number;
// }
Loading

0 comments on commit 321c18b

Please sign in to comment.