Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ typings/

# project specific
dist
.output

release/
88 changes: 88 additions & 0 deletions .wxt/eslint-auto-imports.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
const globals = {
"AutoMount": true,
"AutoMountOptions": true,
"Book": true,
"BookWasUpdated": true,
"Browser": true,
"ClearBook": true,
"ContentScriptAnchoredOptions": true,
"ContentScriptAppendMode": true,
"ContentScriptContext": true,
"ContentScriptInlinePositioningOptions": true,
"ContentScriptModalPositioningOptions": true,
"ContentScriptOverlayAlignment": true,
"ContentScriptOverlayPositioningOptions": true,
"ContentScriptPositioningOptions": true,
"ContentScriptUi": true,
"ContentScriptUiOptions": true,
"IframeContentScriptUi": true,
"IframeContentScriptUiOptions": true,
"InjectScriptOptions": true,
"IntegratedContentScriptUi": true,
"IntegratedContentScriptUiOptions": true,
"InvalidMatchPattern": true,
"LocalStorageData": true,
"MatchPattern": true,
"MessageResponse": true,
"MigrationError": true,
"Page": true,
"SaveBook": true,
"ScraperMessage": true,
"ScriptPublicPath": true,
"ShadowRootContentScriptUi": true,
"ShadowRootContentScriptUiOptions": true,
"StopAutoMount": true,
"StorageArea": true,
"StorageAreaChanges": true,
"StorageItemKey": true,
"UpdatePageOrder": true,
"WxtAppConfig": true,
"WxtStorage": true,
"WxtStorageItem": true,
"WxtWindowEventMap": true,
"asyncUpdatePageOrder": true,
"browser": true,
"createIframeUi": true,
"createIntegratedUi": true,
"createPDF": true,
"createShadowRootUi": true,
"defineAppConfig": true,
"defineBackground": true,
"defineContentScript": true,
"defineUnlistedScript": true,
"defineWxtPlugin": true,
"deleteBook": true,
"extractPageImageURL": true,
"fakeBrowser": true,
"fetchAsBlob": true,
"getActiveTab": true,
"getBook": true,
"getBookURL": true,
"getURL": true,
"injectScript": true,
"move": true,
"postBookUpdate": true,
"saveBook": true,
"savePage": true,
"sites": true,
"storage": true,
"stripCdnPlugin": true,
"updatePageAction": true,
"useAppConfig": true,
"useCallback": true,
"useContext": true,
"useEffect": true,
"useMemo": true,
"useReducer": true,
"useRef": true,
"useState": true
}

export default {
name: "wxt/auto-imports",
languageOptions: {
globals,
/** @type {import('eslint').Linter.SourceType} */
sourceType: "module",
},
};
28 changes: 28 additions & 0 deletions .wxt/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"noEmit": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"strict": true,
"skipLibCheck": true,
"paths": {
"@": [".."],
"@/*": ["../*"],
"~": [".."],
"~/*": ["../*"],
"@@": [".."],
"@@/*": ["../*"],
"~~": [".."],
"~~/*": ["../*"]
}
},
"include": [
"../**/*",
"./wxt.d.ts"
],
"exclude": ["../.output"]
}
15 changes: 15 additions & 0 deletions .wxt/types/globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Generated by wxt
interface ImportMetaEnv {
readonly MANIFEST_VERSION: 2 | 3;
readonly BROWSER: string;
readonly CHROME: boolean;
readonly FIREFOX: boolean;
readonly SAFARI: boolean;
readonly EDGE: boolean;
readonly OPERA: boolean;
readonly COMMAND: "build" | "serve";
readonly ENTRYPOINT: string;
}
interface ImportMeta {
readonly env: ImportMetaEnv
}
81 changes: 81 additions & 0 deletions .wxt/types/i18n.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Generated by wxt
import "wxt/browser";

declare module "wxt/browser" {
/**
* See https://developer.chrome.com/docs/extensions/reference/i18n/#method-getMessage
*/
interface GetMessageOptions {
/**
* See https://developer.chrome.com/docs/extensions/reference/i18n/#method-getMessage
*/
escapeLt?: boolean
}

export interface WxtI18n extends I18n.Static {
/**
* The extension or app ID; you might use this string to construct URLs for resources inside the extension. Even unlocalized extensions can use this message.
* Note: You can't use this message in a manifest file.
*
* "<browser.runtime.id>"
*/
getMessage(
messageName: "@@extension_id",
substitutions?: string | string[],
options?: GetMessageOptions,
): string;
/**
* "<browser.i18n.getUiLocale()>"
*/
getMessage(
messageName: "@@ui_locale",
substitutions?: string | string[],
options?: GetMessageOptions,
): string;
/**
* The text direction for the current locale, either "ltr" for left-to-right languages such as English or "rtl" for right-to-left languages such as Japanese.
*
* "<ltr|rtl>"
*/
getMessage(
messageName: "@@bidi_dir",
substitutions?: string | string[],
options?: GetMessageOptions,
): string;
/**
* If the @@bidi_dir is "ltr", then this is "rtl"; otherwise, it's "ltr".
*
* "<rtl|ltr>"
*/
getMessage(
messageName: "@@bidi_reversed_dir",
substitutions?: string | string[],
options?: GetMessageOptions,
): string;
/**
* If the @@bidi_dir is "ltr", then this is "left"; otherwise, it's "right".
*
* "<left|right>"
*/
getMessage(
messageName: "@@bidi_start_edge",
substitutions?: string | string[],
options?: GetMessageOptions,
): string;
/**
* If the @@bidi_dir is "ltr", then this is "right"; otherwise, it's "left".
*
* "<right|left>"
*/
getMessage(
messageName: "@@bidi_end_edge",
substitutions?: string | string[],
options?: GetMessageOptions,
): string;
getMessage(
messageName: "@@extension_id" | "@@ui_locale" | "@@bidi_dir" | "@@bidi_reversed_dir" | "@@bidi_start_edge" | "@@bidi_end_edge",
substitutions?: string | string[],
options?: GetMessageOptions,
): string;
}
}
27 changes: 27 additions & 0 deletions .wxt/types/imports-module.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Generated by wxt
// Types for the #import virtual module
declare module '#imports' {
export { browser, Browser } from 'wxt/browser';
export { storage, StorageArea, WxtStorage, WxtStorageItem, StorageItemKey, StorageAreaChanges, MigrationError } from 'wxt/utils/storage';
export { useAppConfig } from 'wxt/utils/app-config';
export { ContentScriptContext, WxtWindowEventMap } from 'wxt/utils/content-script-context';
export { createIframeUi, IframeContentScriptUi, IframeContentScriptUiOptions } from 'wxt/utils/content-script-ui/iframe';
export { createIntegratedUi, IntegratedContentScriptUi, IntegratedContentScriptUiOptions } from 'wxt/utils/content-script-ui/integrated';
export { createShadowRootUi, ShadowRootContentScriptUi, ShadowRootContentScriptUiOptions } from 'wxt/utils/content-script-ui/shadow-root';
export { ContentScriptUi, ContentScriptUiOptions, ContentScriptOverlayAlignment, ContentScriptAppendMode, ContentScriptInlinePositioningOptions, ContentScriptOverlayPositioningOptions, ContentScriptModalPositioningOptions, ContentScriptPositioningOptions, ContentScriptAnchoredOptions, AutoMountOptions, StopAutoMount, AutoMount } from 'wxt/utils/content-script-ui/types';
export { defineAppConfig, WxtAppConfig } from 'wxt/utils/define-app-config';
export { defineBackground } from 'wxt/utils/define-background';
export { defineContentScript } from 'wxt/utils/define-content-script';
export { defineUnlistedScript } from 'wxt/utils/define-unlisted-script';
export { defineWxtPlugin } from 'wxt/utils/define-wxt-plugin';
export { injectScript, ScriptPublicPath, InjectScriptOptions } from 'wxt/utils/inject-script';
export { InvalidMatchPattern, MatchPattern } from 'wxt/utils/match-patterns';
export { useState, useCallback, useMemo, useEffect, useRef, useContext, useReducer } from 'react';
export { fakeBrowser } from 'wxt/testing';
export { updatePageAction, asyncUpdatePageOrder, savePage, saveBook, deleteBook, postBookUpdate } from '../components/actions';
export { createPDF } from '../components/pdf';
export { default as sites } from '../components/sites';
export { stripCdnPlugin } from '../components/stripCdnPlugin';
export { Page, Book, SaveBook, BookWasUpdated, ClearBook, UpdatePageOrder, ScraperMessage, MessageResponse, LocalStorageData } from '../components/types';
export { getActiveTab, getURL, getBookURL, extractPageImageURL, getBook, fetchAsBlob, move } from '../components/utils';
}
76 changes: 76 additions & 0 deletions .wxt/types/imports.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Generated by wxt
export {}
declare global {
const ContentScriptContext: typeof import('wxt/utils/content-script-context')['ContentScriptContext']
const InvalidMatchPattern: typeof import('wxt/utils/match-patterns')['InvalidMatchPattern']
const MatchPattern: typeof import('wxt/utils/match-patterns')['MatchPattern']
const asyncUpdatePageOrder: typeof import('/Users/dan/Projects/ebook-scraper/components/actions')['asyncUpdatePageOrder']
const browser: typeof import('wxt/browser')['browser']
const createIframeUi: typeof import('wxt/utils/content-script-ui/iframe')['createIframeUi']
const createIntegratedUi: typeof import('wxt/utils/content-script-ui/integrated')['createIntegratedUi']
const createPDF: typeof import('/Users/dan/Projects/ebook-scraper/components/pdf')['createPDF']
const createShadowRootUi: typeof import('wxt/utils/content-script-ui/shadow-root')['createShadowRootUi']
const defineAppConfig: typeof import('wxt/utils/define-app-config')['defineAppConfig']
const defineBackground: typeof import('wxt/utils/define-background')['defineBackground']
const defineContentScript: typeof import('wxt/utils/define-content-script')['defineContentScript']
const defineUnlistedScript: typeof import('wxt/utils/define-unlisted-script')['defineUnlistedScript']
const defineWxtPlugin: typeof import('wxt/utils/define-wxt-plugin')['defineWxtPlugin']
const deleteBook: typeof import('/Users/dan/Projects/ebook-scraper/components/actions')['deleteBook']
const extractPageImageURL: typeof import('/Users/dan/Projects/ebook-scraper/components/utils')['extractPageImageURL']
const fakeBrowser: typeof import('wxt/testing')['fakeBrowser']
const fetchAsBlob: typeof import('/Users/dan/Projects/ebook-scraper/components/utils')['fetchAsBlob']
const getActiveTab: typeof import('/Users/dan/Projects/ebook-scraper/components/utils')['getActiveTab']
const getBook: typeof import('/Users/dan/Projects/ebook-scraper/components/utils')['getBook']
const getBookURL: typeof import('/Users/dan/Projects/ebook-scraper/components/utils')['getBookURL']
const getURL: typeof import('/Users/dan/Projects/ebook-scraper/components/utils')['getURL']
const injectScript: typeof import('wxt/utils/inject-script')['injectScript']
const move: typeof import('/Users/dan/Projects/ebook-scraper/components/utils')['move']
const postBookUpdate: typeof import('/Users/dan/Projects/ebook-scraper/components/actions')['postBookUpdate']
const saveBook: typeof import('/Users/dan/Projects/ebook-scraper/components/actions')['saveBook']
const savePage: typeof import('/Users/dan/Projects/ebook-scraper/components/actions')['savePage']
const sites: typeof import('/Users/dan/Projects/ebook-scraper/components/sites')['default']
const storage: typeof import('wxt/utils/storage')['storage']
const stripCdnPlugin: typeof import('/Users/dan/Projects/ebook-scraper/components/stripCdnPlugin')['stripCdnPlugin']
const updatePageAction: typeof import('/Users/dan/Projects/ebook-scraper/components/actions')['updatePageAction']
const useAppConfig: typeof import('wxt/utils/app-config')['useAppConfig']
const useCallback: typeof import('react')['useCallback']
const useContext: typeof import('react')['useContext']
const useEffect: typeof import('react')['useEffect']
const useMemo: typeof import('react')['useMemo']
const useReducer: typeof import('react')['useReducer']
const useRef: typeof import('react')['useRef']
const useState: typeof import('react')['useState']
}
// for type re-export
declare global {
// @ts-ignore
export type { Browser } from 'wxt/browser'
import('wxt/browser')
// @ts-ignore
export type { StorageArea, WxtStorage, WxtStorageItem, StorageItemKey, StorageAreaChanges, MigrationError } from 'wxt/utils/storage'
import('wxt/utils/storage')
// @ts-ignore
export type { WxtWindowEventMap } from 'wxt/utils/content-script-context'
import('wxt/utils/content-script-context')
// @ts-ignore
export type { IframeContentScriptUi, IframeContentScriptUiOptions } from 'wxt/utils/content-script-ui/iframe'
import('wxt/utils/content-script-ui/iframe')
// @ts-ignore
export type { IntegratedContentScriptUi, IntegratedContentScriptUiOptions } from 'wxt/utils/content-script-ui/integrated'
import('wxt/utils/content-script-ui/integrated')
// @ts-ignore
export type { ShadowRootContentScriptUi, ShadowRootContentScriptUiOptions } from 'wxt/utils/content-script-ui/shadow-root'
import('wxt/utils/content-script-ui/shadow-root')
// @ts-ignore
export type { ContentScriptUi, ContentScriptUiOptions, ContentScriptOverlayAlignment, ContentScriptAppendMode, ContentScriptInlinePositioningOptions, ContentScriptOverlayPositioningOptions, ContentScriptModalPositioningOptions, ContentScriptPositioningOptions, ContentScriptAnchoredOptions, AutoMountOptions, StopAutoMount, AutoMount } from 'wxt/utils/content-script-ui/types'
import('wxt/utils/content-script-ui/types')
// @ts-ignore
export type { WxtAppConfig } from 'wxt/utils/define-app-config'
import('wxt/utils/define-app-config')
// @ts-ignore
export type { ScriptPublicPath, InjectScriptOptions } from 'wxt/utils/inject-script'
import('wxt/utils/inject-script')
// @ts-ignore
export type { Page, Book, SaveBook, BookWasUpdated, ClearBook, UpdatePageOrder, ScraperMessage, MessageResponse, LocalStorageData } from '/Users/dan/Projects/ebook-scraper/components/types'
import('/Users/dan/Projects/ebook-scraper/components/types')
}
22 changes: 22 additions & 0 deletions .wxt/types/paths.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Generated by wxt
import "wxt/browser";

declare module "wxt/browser" {
export type PublicPath =
| ""
| "/"
| "/background.js"
| "/content-scripts/content.js"
| "/icon/128.png"
| "/icon/16.png"
| "/icon/32.png"
| "/icon/48.png"
| "/icon/512.png"
| "/icon/96.png"
| "/popup.html"
type HtmlPublicPath = Extract<PublicPath, `${string}.html`>
export interface WxtRuntime {
getURL(path: PublicPath): string;
getURL(path: `${HtmlPublicPath}${string}`): string;
}
}
8 changes: 8 additions & 0 deletions .wxt/wxt.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Generated by wxt
/// <reference types="wxt/vite-builder-env" />
/// <reference types="@wxt-dev/module-react" />
/// <reference path="./types/paths.d.ts" />
/// <reference path="./types/i18n.d.ts" />
/// <reference path="./types/globals.d.ts" />
/// <reference path="./types/imports-module.d.ts" />
/// <reference path="./types/imports.d.ts" />
4 changes: 2 additions & 2 deletions src/js/eventPage/actions.ts → components/actions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getBookURL, getURL, getBook, move, getActiveTab } from '../common/utils';
import type { Book, BookWasUpdated, UpdatePageOrder } from '../types';
import type { Book, BookWasUpdated, UpdatePageOrder } from './types';
import { getBookURL, getURL, getBook, move, getActiveTab } from './utils';

export const updatePageAction = async () => {
const tab = await getActiveTab();
Expand Down
4 changes: 2 additions & 2 deletions src/js/popup/pdf.ts → components/pdf.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { jsPDF } from 'jspdf';

import { fetchAsBlob, getActiveTab } from '../common/utils';
import type { Book } from '../types';
import type { Book } from './types';
import { fetchAsBlob, getActiveTab } from './utils';

export async function createPDF(
book: Book,
Expand Down
File renamed without changes.
Loading