@addfox/core 0.1.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,186 @@
1
+ import type { RsbuildConfig } from "@rsbuild/core";
2
+ import type { EntryRowBase } from "@addfox/common";
3
+ /** Browser executable paths for dev mode (addfox.config browserPath option) */
4
+ export interface BrowserPathConfig {
5
+ chrome?: string;
6
+ chromium?: string;
7
+ edge?: string;
8
+ brave?: string;
9
+ vivaldi?: string;
10
+ opera?: string;
11
+ santa?: string;
12
+ arc?: string;
13
+ yandex?: string;
14
+ browseros?: string;
15
+ /** Required when launch target is "custom" */
16
+ custom?: string;
17
+ firefox?: string;
18
+ }
19
+ /** Single manifest as JSON object (nested unknown allowed) */
20
+ export type ManifestRecord = Record<string, unknown>;
21
+ /** Manifest config with chromium/firefox branches */
22
+ export interface ChromiumFirefoxManifest {
23
+ chromium?: ManifestRecord;
24
+ firefox?: ManifestRecord;
25
+ }
26
+ /** Manifest config: single object or per-browser branches */
27
+ export type ManifestConfig = ManifestRecord | ChromiumFirefoxManifest;
28
+ /**
29
+ * Manifest path config: addfox.config can set chromium/firefox to manifest file paths,
30
+ * relative to appDir. E.g. chromium: 'app/manifest/manifest.json'
31
+ */
32
+ export type ManifestPathConfig = {
33
+ chromium?: string;
34
+ firefox?: string;
35
+ };
36
+ /**
37
+ * Helpers passed to rsbuild when it is a function.
38
+ * Use merge(base, overrides) for the same deep-merge effect as object form.
39
+ */
40
+ export interface RsbuildConfigHelpers {
41
+ merge: (base: RsbuildConfig, user: RsbuildConfig) => RsbuildConfig;
42
+ }
43
+ /** User ext config */
44
+ export interface AddfoxUserConfig {
45
+ /**
46
+ * Extension manifest: object config, path config (relative to appDir), or omit to auto-read
47
+ * manifest.json / manifest.chromium.json / manifest.firefox.json from appDir.
48
+ */
49
+ manifest?: ManifestConfig | ManifestPathConfig;
50
+ /** Rsbuild plugins array; use function calls like Vite, e.g. plugins: [vue()] */
51
+ plugins?: RsbuildConfig["plugins"];
52
+ /**
53
+ * Override/extend Rsbuild config (like Vite's build.rollupOptions / esbuild).
54
+ * Object: deep-merge with base.
55
+ * Function: (base, helpers) => config; use helpers.merge(base, overrides) for deep-merge effect.
56
+ */
57
+ rsbuild?: RsbuildConfig | ((base: RsbuildConfig, helpers?: RsbuildConfigHelpers) => RsbuildConfig | Promise<RsbuildConfig>);
58
+ /**
59
+ * Custom entries: key = entry name (reserved: popup/options/sidepanel/background/devtools/content; others custom),
60
+ * value = path relative to baseDir (baseDir = app/ when appDir unset, else baseDir = appDir).
61
+ * Omit to discover background/content/popup/options/sidepanel/devtools from baseDir.
62
+ * Set to **false** to disable framework entry handling: no discovery, no plugin-extension-entry;
63
+ * only debug, hotReload, manifest, plugins, appDir, outDir are used; configure entry in rsbuild.
64
+ */
65
+ entry?: Record<string, EntryConfigValue> | false;
66
+ /** App directory; default app/. Also the lookup base for entry paths (app/ or appDir). */
67
+ appDir?: string;
68
+ /**
69
+ * Output directory name under .addfox (e.g. "extension" �?output at .addfox/extension). Default "extension".
70
+ */
71
+ outDir?: string;
72
+ /**
73
+ * When true or omitted, `addfox build` packs the output directory into a zip file at `.addfox/<outDir>.zip`.
74
+ * Set to false to disable zip output.
75
+ */
76
+ zip?: boolean;
77
+ /**
78
+ * Prefixes for env vars loaded from .env to inject into client (e.g. background/content).
79
+ * Passed to Rsbuild loadEnv; default `['ADDFOX_PUBLIC_']` only exposes ADDFOX_PUBLIC_* vars.
80
+ * Non-public vars like ADDFOX_SECRET are not injected into runtime bundles.
81
+ */
82
+ envPrefix?: string[];
83
+ /**
84
+ * Browser executable paths for dev mode. Framework uses these to start Chrome/Firefox when running `addfox dev`.
85
+ * If unset, dev mode uses default OS paths (see plugin-extension-hmr). Chrome is launched via chrome-launcher.
86
+ */
87
+ browserPath?: BrowserPathConfig;
88
+ /**
89
+ * Cache chromium-based user data dir between dev runs.
90
+ * Default true; CLI -c/--cache has higher priority.
91
+ */
92
+ cache?: boolean;
93
+ /**
94
+ * Hot-reload (WebSocket) options for dev. Port defaults to 23333.
95
+ * Set to false to disable; true or object to enable (object allows port/autoRefreshContentPage).
96
+ */
97
+ hotReload?: {
98
+ /** HMR WebSocket server port; default 23333 */
99
+ port?: number;
100
+ /** When true, content entry change triggers reload manager to refresh the active tab. Default is false. */
101
+ autoRefreshContentPage?: boolean;
102
+ } | boolean;
103
+ /**
104
+ * When true and running in dev (`addfox dev`), enables the error monitor (plugin-extension-monitor).
105
+ * Default false. Only has effect in dev; build ignores this.
106
+ */
107
+ debug?: boolean;
108
+ /**
109
+ * When true, enables Rsdoctor build report (RSDOCTOR=true). Build/dev will open analysis page after build.
110
+ * When object, passes options to RsdoctorRspackPlugin (see https://rsdoctor.rs/config/options/options).
111
+ * Default false. CLI -r/--report overrides to true when enabled.
112
+ */
113
+ report?: boolean | RsdoctorReportOptions;
114
+ }
115
+ /** Resolved config with root, appDir, outDir; manifest is resolved to object form */
116
+ export interface AddfoxResolvedConfig extends Omit<AddfoxUserConfig, "manifest"> {
117
+ manifest: ManifestConfig;
118
+ appDir: string;
119
+ outDir: string;
120
+ /** Parent folder for build output (always ".addfox"). */
121
+ outputRoot: string;
122
+ root: string;
123
+ /** When false, framework does not add plugin-extension-entry; user configures entry in rsbuild */
124
+ entry?: Record<string, EntryConfigValue> | false;
125
+ /** Passed to Rsbuild loadEnv; default `['ADDFOX_PUBLIC_']` only exposes ADDFOX_PUBLIC_* */
126
+ envPrefix?: string[];
127
+ /** Hot-reload options for dev; port defaults to 23333. false = disabled, true or object = enabled. */
128
+ hotReload?: {
129
+ port?: number;
130
+ autoRefreshContentPage?: boolean;
131
+ } | boolean;
132
+ }
133
+ /** Entry config value: string path or structured { src, html } */
134
+ export type EntryConfigValue = string | {
135
+ /** JS/TS entry path (relative to baseDir) */
136
+ src: string;
137
+ /**
138
+ * HTML generation toggle or template path.
139
+ * - true: generate HTML without a template
140
+ * - false: script-only entry
141
+ * - string: HTML template path (relative to baseDir)
142
+ */
143
+ html?: boolean | string;
144
+ };
145
+ /** Where to inject the entry script in HTML (for entries discovered via data-addfox-entry). */
146
+ export type ScriptInjectPosition = "head" | "body";
147
+ /**
148
+ * Options for RsdoctorRspackPlugin when report is object.
149
+ * @see https://rsdoctor.rs/config/options/options
150
+ */
151
+ export interface RsdoctorReportOptions {
152
+ mode?: "brief" | "normal" | "lite";
153
+ output?: {
154
+ reportDir?: string;
155
+ mode?: "brief" | "normal";
156
+ options?: Record<string, unknown>;
157
+ reportCodeType?: string | Record<string, boolean>;
158
+ [key: string]: unknown;
159
+ };
160
+ disableClientServer?: boolean;
161
+ port?: number;
162
+ features?: unknown;
163
+ linter?: unknown;
164
+ supports?: unknown;
165
+ brief?: unknown;
166
+ experiments?: {
167
+ enableNativePlugin?: boolean;
168
+ [key: string]: unknown;
169
+ };
170
+ [key: string]: unknown;
171
+ }
172
+ /** Discovered entry info */
173
+ export interface EntryInfo extends EntryRowBase {
174
+ htmlPath?: string;
175
+ /** Whether this entry should generate an HTML page (template optional). */
176
+ html?: boolean;
177
+ /** When set, template must omit the data-addfox-entry script and rsbuild html.inject should use this. */
178
+ scriptInject?: ScriptInjectPosition;
179
+ /** When true, output path follows script/html path (e.g. main.ts �?main.js, scripts/main.ts �?scripts/main.js). */
180
+ outputFollowsScriptPath?: boolean;
181
+ }
182
+ /** Entry with name + absolute path for HMR reload manager */
183
+ export type ReloadManagerEntry = {
184
+ name: string;
185
+ path: string;
186
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Current addfox (core) version, e.g. for extension error reports.
3
+ */
4
+ export declare function getAddfoxVersion(): string;
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@addfox/core",
3
+ "version": "0.1.1-beta.2",
4
+ "description": "addfox core: types, config loading, entry discovery/resolution, manifest building",
5
+ "type": "module",
6
+ "main": "./dist/cjs/index.cjs",
7
+ "module": "./dist/esm/index.js",
8
+ "types": "./dist/esm/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/esm/index.d.ts",
12
+ "import": "./dist/esm/index.js",
13
+ "require": "./dist/cjs/index.cjs",
14
+ "default": "./dist/esm/index.js"
15
+ },
16
+ "./pipeline": {
17
+ "types": "./dist/esm/pipeline/index.d.ts",
18
+ "import": "./dist/esm/pipeline/index.js",
19
+ "require": "./dist/cjs/pipeline/index.cjs",
20
+ "default": "./dist/esm/pipeline/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "dependencies": {
27
+ "@rsbuild/core": "^1.7.3",
28
+ "cli-table3": "^0.6.5",
29
+ "jiti": "^2.0.0",
30
+ "@addfox/common": "0.1.1-beta.2"
31
+ },
32
+ "devDependencies": {
33
+ "@rslib/core": "^0.20.0",
34
+ "@rstest/core": "^0.9.2",
35
+ "@rstest/coverage-istanbul": "^0.3.0",
36
+ "@types/node": "^20.0.0",
37
+ "typescript": "^5.0.0"
38
+ },
39
+ "peerDependencies": {
40
+ "@rsbuild/core": ">=1.0.0"
41
+ },
42
+ "scripts": {
43
+ "build": "rslib build",
44
+ "dev": "rslib build --watch",
45
+ "test": "rstest run",
46
+ "test:coverage": "rstest run --coverage"
47
+ }
48
+ }