@pitlane/assets 0.0.0-stage → 0.1.0

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,106 @@
1
+ //#region src/types.d.ts
2
+ /**
3
+ * An import map as the HTML standard defines it: specifier mappings, optional
4
+ * scoped mappings, and optional integrity metadata.
5
+ */
6
+ interface ImportMap {
7
+ imports: Record<string, string>;
8
+ scopes?: Record<string, Record<string, string>>;
9
+ integrity?: Record<string, string>;
10
+ }
11
+ /**
12
+ * What a browser needs to load one script entry: its URL, the URLs worth
13
+ * `modulepreload` hints, and the import map its imports resolve through.
14
+ *
15
+ * Structurally the `ScriptEntry` of `remix/assets`.
16
+ */
17
+ interface ScriptEntry {
18
+ /** The public URL of the entry module. */
19
+ href: string;
20
+ /** The entry module's URL followed by its static JavaScript dependencies, shallowest first. */
21
+ preloads: string[];
22
+ /** The complete client import map, or `{ imports: {} }` when chunk import maps are disabled. */
23
+ importMap: ImportMap;
24
+ }
25
+ /** The JavaScript and CSS one source module requires in one environment. */
26
+ interface AssetMetadata {
27
+ /** Public URLs of the chunks holding the module and their static JavaScript dependencies. */
28
+ preloads: string[];
29
+ /** Public URLs of the stylesheets those chunks require. */
30
+ stylesheets: string[];
31
+ }
32
+ /** Every source module observed in one environment's graph, keyed by portable source key. */
33
+ interface AssetEnvironment {
34
+ role: "client" | "server";
35
+ modules: Record<string, AssetMetadata>;
36
+ }
37
+ /** The manifest a production build produces. */
38
+ interface BuildAssetsManifest {
39
+ mode: "build";
40
+ environments: Record<string, AssetEnvironment>;
41
+ /** Browser-entry source keys mapped to public URLs. */
42
+ entries: Record<string, string>;
43
+ /** Non-script asset source keys mapped to public URLs. */
44
+ assets: Record<string, string>;
45
+ importMap: ImportMap;
46
+ /** The server environment this manifest was written for. */
47
+ serverEnvironment?: string;
48
+ }
49
+ /** The manifest a development server supplies, refreshed as the graph changes. */
50
+ interface DevAssetsManifest {
51
+ mode: "dev";
52
+ environments: Record<string, AssetEnvironment>;
53
+ /** Browser-entry source keys mapped to development URLs. */
54
+ entries: Record<string, string>;
55
+ /** Non-script asset source keys mapped to development URLs. */
56
+ assets: Record<string, string>;
57
+ /** The server environment this manifest was written for. */
58
+ serverEnvironment?: string;
59
+ }
60
+ /**
61
+ * Everything `createAssetResolver` accepts. `{ mode: "unavailable" }` is
62
+ * what `@pitlane/assets/manifest` exports when no build integration replaced it.
63
+ */
64
+ type AssetsManifest = BuildAssetsManifest | DevAssetsManifest | {
65
+ mode: "unavailable";
66
+ };
67
+ /**
68
+ * A bundler's output, normalized for `createAssetManifest`.
69
+ *
70
+ * Paths and filenames are already portable: source keys are relative to the
71
+ * project root, and `file`/`stylesheets` are emitted filenames relative to
72
+ * `base` or absolute public URLs.
73
+ */
74
+ interface AssetBuild {
75
+ /** The public base relative emitted filenames resolve against, such as `/` or `https://cdn.example/app/`. */
76
+ base: string;
77
+ /** Every participating environment by name. Exactly one has the client role. */
78
+ environments: Record<string, AssetBuildEnvironment>;
79
+ /** The import map the bundler generated for the client build, when it generated one. */
80
+ importMap?: ImportMap;
81
+ }
82
+ /** One environment's output graph. */
83
+ interface AssetBuildEnvironment {
84
+ role: "client" | "server";
85
+ /** Emitted chunks by opaque, environment-local identity. */
86
+ chunks: Record<string, AssetBuildChunk>;
87
+ /** Browser-entry source keys mapped to chunk identities. Populated only on the client. */
88
+ entries: Record<string, string>;
89
+ /** Source keys mapped to emitted non-script files. */
90
+ assets: Record<string, string>;
91
+ }
92
+ /** One emitted JavaScript chunk. */
93
+ interface AssetBuildChunk {
94
+ /** The emitted filename, or an absolute public URL. */
95
+ file: string;
96
+ /** Source keys of every module the chunk contains. */
97
+ modules: string[];
98
+ /** Chunk identities this chunk imports statically, in import order. */
99
+ imports: string[];
100
+ /** Chunk identities this chunk imports dynamically. */
101
+ dynamicImports: string[];
102
+ /** Emitted stylesheet filenames, or absolute public URLs, the chunk requires. */
103
+ stylesheets: string[];
104
+ }
105
+ //#endregion
106
+ export { AssetMetadata as a, DevAssetsManifest as c, AssetEnvironment as i, ImportMap as l, AssetBuildChunk as n, AssetsManifest as o, AssetBuildEnvironment as r, BuildAssetsManifest as s, AssetBuild as t, ScriptEntry as u };
@@ -0,0 +1,26 @@
1
+ import { PluginOption } from "vite";
2
+ //#region src/vite-plugin.d.ts
3
+ export interface AssetsPluginOptions {
4
+ /** Extra source keys to make available as client entries or assets. */
5
+ include?: string[];
6
+ /** Server environments whose module graphs provide metadata. Defaults to `["ssr"]`. */
7
+ serverEnvironments?: string[];
8
+ /** Override Vite's native setting. With neither setting present, maps are disabled. */
9
+ chunkImportMap?: boolean;
10
+ }
11
+ /** Browser entries declared by one server module's development transform. */
12
+ export interface AssetEntryRegistration {
13
+ /** The server environment that transformed the owner. */
14
+ environment: string;
15
+ /** The resolved server module ID declaring these entries. */
16
+ owner: string;
17
+ /** Resolved browser module IDs; an empty list removes the owner's declarations. */
18
+ entries: string[];
19
+ }
20
+ /** Available on the resolved plugin named `pitlane-assets`. */
21
+ export interface AssetsPluginApi {
22
+ /** Replace an owner's declarations; an empty list removes them. Builds use `emitFile` instead. */
23
+ setBrowserEntries(registration: AssetEntryRegistration): void;
24
+ }
25
+ export declare function assets(options?: AssetsPluginOptions): PluginOption;
26
+ //#endregion