@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,35 @@
1
+ import type { ScriptInjectPosition } from "../types.ts";
2
+ export type { ScriptInjectPosition };
3
+ export interface AddfoxEntryScriptResult {
4
+ /** Resolved src attribute value (relative path) */
5
+ src: string;
6
+ /** Where the script tag sits: head or body */
7
+ inject: ScriptInjectPosition;
8
+ /** HTML content with the data-addfox-entry script tag removed */
9
+ strippedHtml: string;
10
+ }
11
+ /** True if src is a relative path (no leading / or \, no protocol). */
12
+ export declare function isScriptSrcRelative(src: string): boolean;
13
+ /**
14
+ * Parses HTML at htmlPath for the entry script.
15
+ * Entry is either: (1) script with data-addfox-entry and protocol-less src, or
16
+ * (2) if none found, the first script in HTML (head or body) with protocol-less src.
17
+ * Returns src, inject position (head vs body), and HTML with that script tag removed.
18
+ * If no such tag is found or it has no valid src, returns undefined.
19
+ */
20
+ export declare function parseAddfoxEntryFromHtml(htmlPath: string): AddfoxEntryScriptResult | undefined;
21
+ /**
22
+ * If html has data-addfox-entry and its script src resolves to the same path as scriptPath,
23
+ * returns the inject position so the entry can use stripped template and html.inject.
24
+ */
25
+ export declare function getScriptInjectIfMatches(htmlPath: string, scriptPath: string): ScriptInjectPosition | undefined;
26
+ /**
27
+ * Resolve script path from HTML that has data-addfox-entry with src.
28
+ * - src must be relative; throws if absolute.
29
+ * - Resolved file must exist; throws if not found.
30
+ * Use this when the entry is driven by HTML so invalid config fails fast.
31
+ */
32
+ export declare function resolveScriptFromHtmlStrict(htmlPath: string): {
33
+ scriptPath: string;
34
+ inject: ScriptInjectPosition;
35
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @addfox/core/entry
3
+ *
4
+ * Entry discovery and resolution
5
+ */
6
+ export { discoverEntries, getHtmlEntryNames, getScriptOnlyEntryNames, getAllEntryNames, } from "./discoverer.ts";
7
+ export type { EntryDiscovererOptions } from "./discoverer.ts";
8
+ export { resolveEntries, resolveEntriesLegacy, extractEntriesFromManifest } from "./resolver.ts";
9
+ export type { EntryResolverOptions, EntryResolutionResult } from "./resolver.ts";
10
+ export type { ParsedEntryFromManifest, ExtractedEntry } from "./manifestParser.ts";
11
+ export { parseAddfoxEntryFromHtml, getScriptInjectIfMatches, resolveScriptFromHtmlStrict, isScriptSrcRelative, } from "./html.ts";
12
+ export type { AddfoxEntryScriptResult } from "./html.ts";
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Manifest entry parser - extracts entry paths from manifest.json
3
+ * Allows users to specify source file paths directly in manifest fields
4
+ */
5
+ import type { ManifestRecord, EntryConfigValue } from "../types.ts";
6
+ import type { BrowserTarget } from "../constants.ts";
7
+ interface ExtractedEntry {
8
+ name: string;
9
+ value: EntryConfigValue;
10
+ /** Original manifest field path, used for later replacement */
11
+ manifestPath: string;
12
+ }
13
+ interface ParsedEntryFromManifest {
14
+ entries: Record<string, EntryConfigValue>;
15
+ /** Maps manifest field paths to entry names for replacement */
16
+ replacementMap: Map<string, string>;
17
+ }
18
+ /**
19
+ * Extract all entry config from manifest.
20
+ * Only extracts fields that specify source file paths (.ts/.tsx/.js/.jsx).
21
+ */
22
+ export declare function extractEntriesFromManifest(manifest: ManifestRecord, browser: BrowserTarget): ParsedEntryFromManifest;
23
+ /**
24
+ * Check whether the manifest contains any source file paths.
25
+ */
26
+ export declare function hasManifestSourcePaths(manifest: ManifestRecord): boolean;
27
+ export type { ParsedEntryFromManifest, ExtractedEntry };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Entry resolution - resolves entry configuration
3
+ * Priority: 1. config.entry > 2. manifest entries > 3. auto-discovery
4
+ */
5
+ import type { AddfoxUserConfig, EntryInfo, ManifestRecord } from "../types.ts";
6
+ import type { BrowserTarget } from "../constants.ts";
7
+ import { type EntryDiscovererOptions } from "./discoverer.ts";
8
+ import { extractEntriesFromManifest, type ParsedEntryFromManifest } from "./manifestParser.ts";
9
+ export interface EntryResolverOptions {
10
+ entryDiscovererOptions?: EntryDiscovererOptions;
11
+ /** Target browser for manifest entry extraction */
12
+ browser?: BrowserTarget;
13
+ }
14
+ export interface EntryResolutionResult {
15
+ entries: EntryInfo[];
16
+ /** Map of manifest field paths to entry names for output path replacement */
17
+ manifestReplacementMap?: Map<string, string>;
18
+ }
19
+ /**
20
+ * Resolve entries with priority:
21
+ * 1. config.entry (highest priority)
22
+ * 2. manifest entries (if config.entry doesn't specify)
23
+ * 3. auto-discovery (lowest priority)
24
+ */
25
+ export declare function resolveEntries(config: Pick<AddfoxUserConfig, "entry" | "appDir">, _root: string, baseDir: string, manifest?: ManifestRecord, options?: EntryResolverOptions): EntryResolutionResult;
26
+ /**
27
+ * Legacy API - returns just the entries array for backward compatibility
28
+ */
29
+ export declare function resolveEntriesLegacy(config: Pick<AddfoxUserConfig, "entry" | "appDir">, _root: string, baseDir: string, options?: EntryResolverOptions): EntryInfo[];
30
+ export { extractEntriesFromManifest, type ParsedEntryFromManifest };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Detect front-end framework from project package.json (dependencies / devDependencies).
3
+ * Used for debug error output; falls back to Vanilla when none detected.
4
+ */
5
+ export type FrontendFramework = "Vanilla" | "React" | "Vue" | "Preact" | "Svelte" | "Solid";
6
+ /**
7
+ * Detect front-end framework from project root package.json.
8
+ * Checks dependencies/devDependencies for solid-js, svelte, vue, preact, react (first match wins).
9
+ * Returns "Vanilla" when root is empty, package.json missing, or no framework detected.
10
+ */
11
+ export declare function detectFrontendFramework(root: string): FrontendFramework;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @addfox/core - Core build logic for Addfox
3
+ *
4
+ * Responsibilities:
5
+ * - Build orchestration (Pipeline)
6
+ * - Config loading and resolution
7
+ * - Entry discovery and resolution
8
+ * - Manifest building and loading
9
+ * - Type definitions and constants
10
+ */
11
+ export { defineConfig } from "./config/defineConfig.js";
12
+ export { resolveAddfoxConfig, loadConfigFile, getResolvedConfigFilePath, getResolvedRstestConfigFilePath, clearConfigCache, } from "./config/loader.js";
13
+ export type { ConfigResolutionResult, ConfigLoaderOptions, } from "./config/loader.js";
14
+ export { Pipeline } from "./pipeline/Pipeline.js";
15
+ export type { PipelineContext, PipelineStage, PipelineHook } from "./pipeline/types.js";
16
+ export { discoverEntries, getHtmlEntryNames, getScriptOnlyEntryNames, getAllEntryNames, } from "./entry/discoverer.js";
17
+ export type { EntryDiscovererOptions } from "./entry/discoverer.js";
18
+ export { resolveEntries, extractEntriesFromManifest } from "./entry/resolver.js";
19
+ export type { EntryResolverOptions, EntryResolutionResult } from "./entry/resolver.js";
20
+ export type { ParsedEntryFromManifest, ExtractedEntry } from "./entry/manifestParser.js";
21
+ export { parseAddfoxEntryFromHtml, getScriptInjectIfMatches, resolveScriptFromHtmlStrict, isScriptSrcRelative, } from "./entry/html.js";
22
+ export type { AddfoxEntryScriptResult } from "./entry/html.js";
23
+ export { buildForBrowser, resolveManifestChromium, resolveManifestFirefox, resolveManifestForTarget, getManifestRecordForTarget, } from "./manifest/builder.js";
24
+ export type { ContentScriptOutput } from "./manifest/builder.js";
25
+ export { resolveManifestInput, ManifestLoader, } from "./manifest/loader.js";
26
+ export type { ManifestValidationTarget } from "./manifest/loader.js";
27
+ export { DEFAULT_OUT_DIR, DEFAULT_APP_DIR, DEFAULT_ENV_PREFIXES, ADDFOX_OUTPUT_ROOT, HMR_WS_PORT, DEFAULT_BROWSER, SUPPORTED_BROWSERS, SUPPORTED_LAUNCH_TARGETS, CLI_COMMANDS, RSTEST_CONFIG_FILES, MANIFEST_ENTRY_PATHS, MANIFEST_ENTRY_KEYS, MANIFEST_DIR, MANIFEST_FILE_NAMES, CONFIG_FILES, SCRIPT_EXTS, HTML_ENTRY_NAMES, SCRIPT_ONLY_ENTRY_NAMES, RELOAD_MANAGER_ENTRY_NAMES, RESERVED_ENTRY_NAMES, BROWSER_OUTPUT_PREFIX, getBrowserOutputDir, } from "./constants.js";
28
+ export { toReloadManagerEntries } from "./reloadManager.js";
29
+ export { getAddfoxVersion } from "./version.js";
30
+ export { detectFrontendFramework, type FrontendFramework, } from "./frameworkDetect.js";
31
+ export type { AddfoxUserConfig, AddfoxResolvedConfig, ManifestConfig, ManifestRecord, ChromiumFirefoxManifest, ManifestPathConfig, BrowserPathConfig, RsbuildConfigHelpers, EntryInfo, ReloadManagerEntry, ScriptInjectPosition, RsdoctorReportOptions, } from "./types.js";
32
+ export type { BrowserTarget, CliCommand, LaunchTarget, EntryKey, ChromiumLaunchTarget, } from "./constants.js";