@ogygia/compiler 0.0.0-stage → 0.14.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.
- package/LICENSE +21 -0
- package/README.md +63 -2
- package/dist/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/taggedTemplateLiteral.js +5 -0
- package/dist/app-spec.d.ts +18 -0
- package/dist/app-spec.js +22 -0
- package/dist/blank-styles.d.ts +1 -0
- package/dist/blank-styles.js +24 -0
- package/dist/bom.d.ts +2 -0
- package/dist/bom.js +7 -0
- package/dist/build-cache.d.ts +13 -0
- package/dist/build-cache.js +65 -0
- package/dist/ctx.d.ts +238 -0
- package/dist/ctx.js +221 -0
- package/dist/dev/css-scope.d.ts +16 -0
- package/dist/dev/css-scope.js +32 -0
- package/dist/dev/dev-hmr.d.ts +24 -0
- package/dist/dev/dev-hmr.js +51 -0
- package/dist/dev/hmr.d.ts +34 -0
- package/dist/dev/hmr.js +52 -0
- package/dist/driver.d.ts +349 -0
- package/dist/driver.js +1401 -0
- package/dist/exports/index.d.ts +77 -0
- package/dist/exports/index.js +349 -0
- package/dist/exports/parse.d.ts +65 -0
- package/dist/exports/parse.js +251 -0
- package/dist/fouc-css.d.ts +102 -0
- package/dist/fouc-css.js +304 -0
- package/dist/free-vars.d.ts +32 -0
- package/dist/free-vars.js +454 -0
- package/dist/fs.d.ts +31 -0
- package/dist/fs.js +82 -0
- package/dist/ids.d.ts +49 -0
- package/dist/ids.js +52 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +23 -0
- package/dist/kit.d.ts +204 -0
- package/dist/kit.js +554 -0
- package/dist/leg.d.ts +34 -0
- package/dist/leg.js +26 -0
- package/dist/link/analyses.d.ts +26 -0
- package/dist/link/analyses.js +237 -0
- package/dist/link/build-output.d.ts +47 -0
- package/dist/link/build-output.js +168 -0
- package/dist/link/caps.d.ts +32 -0
- package/dist/link/caps.js +39 -0
- package/dist/link/context-detect.d.ts +28 -0
- package/dist/link/context-detect.js +143 -0
- package/dist/link/emit-gate.d.ts +43 -0
- package/dist/link/emit-gate.js +55 -0
- package/dist/link/file-token.d.ts +11 -0
- package/dist/link/file-token.js +15 -0
- package/dist/link/island-deps.d.ts +183 -0
- package/dist/link/island-deps.js +802 -0
- package/dist/link/location-map.d.ts +24 -0
- package/dist/link/location-map.js +51 -0
- package/dist/link/own-reach.d.ts +15 -0
- package/dist/link/own-reach.js +188 -0
- package/dist/link/registry-stub.d.ts +50 -0
- package/dist/link/registry-stub.js +163 -0
- package/dist/link/relocations.d.ts +79 -0
- package/dist/link/relocations.js +198 -0
- package/dist/link/router-css.d.ts +38 -0
- package/dist/link/router-css.js +124 -0
- package/dist/link/runtime-entry.d.ts +103 -0
- package/dist/link/runtime-entry.js +183 -0
- package/dist/link/server-manifest.d.ts +25 -0
- package/dist/link/server-manifest.js +102 -0
- package/dist/link/transport.d.ts +42 -0
- package/dist/link/transport.js +91 -0
- package/dist/macros/dollar.d.ts +24 -0
- package/dist/macros/dollar.js +397 -0
- package/dist/macros/pipeline.d.ts +50 -0
- package/dist/macros/pipeline.js +133 -0
- package/dist/macros/source.d.ts +9 -0
- package/dist/macros/source.js +115 -0
- package/dist/macros/store.d.ts +22 -0
- package/dist/macros/store.js +217 -0
- package/dist/macros/wire.d.ts +17 -0
- package/dist/macros/wire.js +116 -0
- package/dist/map-chain.d.ts +18 -0
- package/dist/map-chain.js +42 -0
- package/dist/messages.d.ts +672 -0
- package/dist/messages.js +938 -0
- package/dist/ownership-stamps.d.ts +9 -0
- package/dist/ownership-stamps.js +101 -0
- package/dist/parse/oxc.d.ts +36 -0
- package/dist/parse/oxc.js +35 -0
- package/dist/parse/roots.d.ts +4 -0
- package/dist/parse/roots.js +27 -0
- package/dist/parse/scan.d.ts +65 -0
- package/dist/parse/scan.js +297 -0
- package/dist/parse/svelte-ast.d.ts +7 -0
- package/dist/parse/svelte-ast.js +99 -0
- package/dist/program.d.ts +140 -0
- package/dist/program.js +304 -0
- package/dist/queries.d.ts +105 -0
- package/dist/queries.js +326 -0
- package/dist/region/emit.d.ts +168 -0
- package/dist/region/emit.js +292 -0
- package/dist/region/identity.d.ts +32 -0
- package/dist/region/identity.js +46 -0
- package/dist/region/ir.d.ts +56 -0
- package/dist/region/ir.js +0 -0
- package/dist/region/marked-imports.d.ts +27 -0
- package/dist/region/marked-imports.js +265 -0
- package/dist/region/transform.d.ts +189 -0
- package/dist/region/transform.js +1565 -0
- package/dist/scan-facts.d.ts +36 -0
- package/dist/scan-facts.js +54 -0
- package/dist/script-request.d.ts +1 -0
- package/dist/script-request.js +33 -0
- package/dist/splice.d.ts +11 -0
- package/dist/splice.js +33 -0
- package/dist/transportables.d.ts +23 -0
- package/dist/transportables.js +144 -0
- package/dist/virtual/core.d.ts +158 -0
- package/dist/virtual/core.js +588 -0
- package/dist/virtual/resolver.d.ts +56 -0
- package/dist/virtual/resolver.js +249 -0
- package/dist/virtual/specifier.d.ts +10 -0
- package/dist/virtual/specifier.js +6 -0
- package/dist/virtual/table.d.ts +118 -0
- package/dist/virtual/table.js +54 -0
- package/dist/virtual/types.d.ts +17 -0
- package/dist/virtual/types.js +100 -0
- package/dist/virtual/value-names.d.ts +2 -0
- package/dist/virtual/value-names.js +18 -0
- package/dist/vite/definers.d.ts +16 -0
- package/dist/vite/definers.js +69 -0
- package/dist/vite/dev-maps.d.ts +34 -0
- package/dist/vite/dev-maps.js +91 -0
- package/dist/vite/index.d.ts +21 -0
- package/dist/vite/index.js +874 -0
- package/dist/vite/kit-dirs.d.ts +6 -0
- package/dist/vite/kit-dirs.js +53 -0
- package/dist/vite/late-island.d.ts +11 -0
- package/dist/vite/late-island.js +19 -0
- package/dist/vite/lazy-files.d.ts +2 -0
- package/dist/vite/lazy-files.js +72 -0
- package/dist/vite/options.d.ts +195 -0
- package/dist/vite/options.js +72 -0
- package/dist/vite/package-files.d.ts +3 -0
- package/dist/vite/package-files.js +88 -0
- package/dist/vite/paths.d.ts +14 -0
- package/dist/vite/paths.js +37 -0
- package/dist/vite/plugin-api.d.ts +316 -0
- package/dist/vite/plugin-api.js +328 -0
- package/dist/vite/session.d.ts +28 -0
- package/dist/vite/session.js +43 -0
- package/dist/vite/sourcemaps.d.ts +19 -0
- package/dist/vite/sourcemaps.js +75 -0
- package/dist/vite/style-preprocess.d.ts +2 -0
- package/dist/vite/style-preprocess.js +84 -0
- package/dist/vite/svelte-entries.d.ts +4 -0
- package/dist/vite/svelte-entries.js +10 -0
- package/package.json +85 -3
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { ExportMap, Policy } from "../exports/index.js";
|
|
2
|
+
import { ClientRealmFile, ServerRealm } from "../link/caps.js";
|
|
3
|
+
import { Definers } from "./definers.js";
|
|
4
|
+
import { MacroContext } from "../macros/pipeline.js";
|
|
5
|
+
import { PrescanHook } from "../ctx.js";
|
|
6
|
+
import { BarrelLeftReason, RuntimeHookName } from "@ogygia/core/contract";
|
|
7
|
+
import MagicString from "magic-string";
|
|
8
|
+
import { Plugin } from "vite";
|
|
9
|
+
/** Where `definePlugin` puts the definition on the Vite plugin it returns. A registered symbol, so a
|
|
10
|
+
* second copy of ogygia in one app still recognizes the first's plugins. */
|
|
11
|
+
export declare const PLUGIN: unique symbol;
|
|
12
|
+
/** The value a plugin's factory returns: a Vite plugin carrying its definition. */
|
|
13
|
+
export interface OgygiaPlugin<Options = unknown> extends Plugin {
|
|
14
|
+
readonly [PLUGIN]: PluginDefinition<Options>;
|
|
15
|
+
}
|
|
16
|
+
/** What a plugin is: the argument to `definePlugin`. */
|
|
17
|
+
export interface PluginDefinition<Options = unknown> {
|
|
18
|
+
/** The plugin's package name (`'@ogygia/postrender'`): its identity. */
|
|
19
|
+
name: string;
|
|
20
|
+
/** The SERVER realm: a module whose default export is `defineServer({…})` (`ogygia/plugin`), as a
|
|
21
|
+
* `file:` URL or an absolute path — `import.meta.resolve('./server.ts')`. */
|
|
22
|
+
server?: string;
|
|
23
|
+
/** The BROWSER realm: a module whose default export is `defineClient({…})` (`ogygia/plugin/client`),
|
|
24
|
+
* booted on every page — same form as `server`. */
|
|
25
|
+
client?: string;
|
|
26
|
+
/** Settings for every realm (JSON: no functions, no clients — live objects are configured at
|
|
27
|
+
* runtime, in hooks.server.ts). */
|
|
28
|
+
options?: Options;
|
|
29
|
+
/** Run before (`'pre'`) or after (`'post'`) the other plugins, in every realm. */
|
|
30
|
+
enforce?: "pre" | "post";
|
|
31
|
+
/** The plugins this one needs listed beside it: each one's package name, its call and the
|
|
32
|
+
* package to import it from. One the app does not list fails the build
|
|
33
|
+
* (`plugin_needs_plugin`), naming the line to add. */
|
|
34
|
+
needs?: readonly {
|
|
35
|
+
name: string;
|
|
36
|
+
call: string;
|
|
37
|
+
from: string;
|
|
38
|
+
}[];
|
|
39
|
+
/** Build-time contributions, with the build context. */
|
|
40
|
+
build?(b: BuildContext): void;
|
|
41
|
+
}
|
|
42
|
+
/** A `import.meta.og.<name>` macro: rewrites a module that contains the marker (it is called only
|
|
43
|
+
* then), before the island transform or region minting see it. Returns the new code (the same
|
|
44
|
+
* string when nothing changed). */
|
|
45
|
+
export type MacroHandler = (code: string, m: MacroContext) => string | Promise<string>;
|
|
46
|
+
/** A source format that becomes Svelte only through a preprocessor (markdown → Svelte): how its
|
|
47
|
+
* islands and its modules' CSS reach the build. */
|
|
48
|
+
export interface MarkupSource {
|
|
49
|
+
/** The format's file extensions (`['.svx', '.md']`). */
|
|
50
|
+
extensions: readonly string[];
|
|
51
|
+
/** Discover the format's islands up front (build start, dev included): read each file, turn it
|
|
52
|
+
* into Svelte, and hand that to `transform` so its islands are registered before chunks emit. */
|
|
53
|
+
scan?(ctx: {
|
|
54
|
+
root: string;
|
|
55
|
+
readFile: (abs: string) => string | null;
|
|
56
|
+
}): void | Promise<void>;
|
|
57
|
+
/** The format's modules, absolute path → their post-preprocess Svelte source. A module only ever
|
|
58
|
+
* renders on the server, so no client chunk carries its CSS: the build ships, as one client asset
|
|
59
|
+
* per module, the scoped CSS of its own `<style>` and of every component it imports (and plain
|
|
60
|
+
* style imports). The plugin keeps filling it ([path, source] pairs); the build reads it late. */
|
|
61
|
+
modules?: Iterable<readonly [string, string]>;
|
|
62
|
+
}
|
|
63
|
+
/** What the build hands back for a markup source: run the region transform on preprocessed Svelte. */
|
|
64
|
+
export interface MarkupRegions {
|
|
65
|
+
/** Rewrite the marked imports in already-preprocessed Svelte and register its regions. The code,
|
|
66
|
+
* or null when nothing changed. */
|
|
67
|
+
transform: (source: string, filename: string) => string | null;
|
|
68
|
+
}
|
|
69
|
+
/** Where a plugin's transform runs: on the module as written, before the region transform
|
|
70
|
+
* (`'source'`), or on what the region transform made of it (`'post'`). */
|
|
71
|
+
export type TransformStage = "source" | "post";
|
|
72
|
+
/** One module, as a stage transform sees it. */
|
|
73
|
+
export interface TransformContext {
|
|
74
|
+
/** The module id, query included. */
|
|
75
|
+
readonly id: string;
|
|
76
|
+
/** The module's code as the stage received it (no byte-order mark). */
|
|
77
|
+
readonly code: string;
|
|
78
|
+
/** The stage's edits, by offsets into `code`: every transform of a stage edits the code it
|
|
79
|
+
* received, and the stage emits one result and one source map. */
|
|
80
|
+
readonly edit: MagicString;
|
|
81
|
+
/** The bundler's environment (`client`, `ssr`). */
|
|
82
|
+
readonly environment: string;
|
|
83
|
+
/** A specifier resolved from `importer` as the bundler resolves it now; null when it cannot be
|
|
84
|
+
* (unresolvable, or external). */
|
|
85
|
+
resolve(spec: string, importer: string): Promise<string | null>;
|
|
86
|
+
/** Re-transform this module when `file` changes (dev). */
|
|
87
|
+
watch: (file: string) => void;
|
|
88
|
+
}
|
|
89
|
+
/** Why imports of the module at `file` stayed as written in these importers (ids, queries allowed),
|
|
90
|
+
* in the bundler environment `environment`; none when this plugin left none of them. */
|
|
91
|
+
export type StayedAnswer = (file: string, importers: readonly string[], environment: string) => readonly BarrelLeftReason[];
|
|
92
|
+
/** A transform at a stage around the region transform: ordering is the stage, not list position. */
|
|
93
|
+
export interface StageTransform {
|
|
94
|
+
stage: TransformStage;
|
|
95
|
+
/** Which modules (by full id); every module when absent. */
|
|
96
|
+
filter?(id: string): boolean;
|
|
97
|
+
transform(t: TransformContext): void | Promise<void>;
|
|
98
|
+
}
|
|
99
|
+
/** The app's export index: each barrel's names to the modules that define them, over one parse of
|
|
100
|
+
* each module for the whole app, resolved as the module being transformed resolves. */
|
|
101
|
+
export interface ExportsSeam {
|
|
102
|
+
/** The map of the barrel at `file` (as `spec` named it), or null when `policy` does not go
|
|
103
|
+
* through it. */
|
|
104
|
+
map(file: string, spec: string, policy: Policy, t: TransformContext): Promise<ExportMap | null>;
|
|
105
|
+
}
|
|
106
|
+
/** An import declaration, as {@link BuildContext.pinnedImports} reads it. */
|
|
107
|
+
export interface PinnedDecl {
|
|
108
|
+
readonly attribute_keys: readonly string[];
|
|
109
|
+
readonly specs: readonly {
|
|
110
|
+
readonly local: string;
|
|
111
|
+
}[];
|
|
112
|
+
}
|
|
113
|
+
/** The build, as one plugin sees it (handed to `build`). */
|
|
114
|
+
export interface BuildContext {
|
|
115
|
+
/** Run `transform` on every module (that `filter` takes) at its `stage`. */
|
|
116
|
+
transform(transform: StageTransform): void;
|
|
117
|
+
/** Answer why a transform of this plugin left imports of a module as written: the findings that
|
|
118
|
+
* weigh a module an island still imports whole ask every plugin's answer
|
|
119
|
+
* ({@link RegionsSeam.whyStayed}). */
|
|
120
|
+
stayed(answer: StayedAnswer): void;
|
|
121
|
+
/** The app's export index (`compiler/exports/`), for a transform that follows names through
|
|
122
|
+
* barrels. */
|
|
123
|
+
readonly exports: ExportsSeam;
|
|
124
|
+
/** For a module's code: the imports that carry a region's identity (a region mark, on a default
|
|
125
|
+
* or a named import). A transform that rewrites imports leaves them as written, so the region
|
|
126
|
+
* the prescan keys on the raw import is the region the transform sees. */
|
|
127
|
+
readonly pinnedImports: (code: string) => (decl: PinnedDecl) => boolean;
|
|
128
|
+
/** The app's regions as the build knows them now, for a tool that names or weighs them. */
|
|
129
|
+
readonly regions: RegionsSeam;
|
|
130
|
+
/** The app's root directory. */
|
|
131
|
+
readonly root: string;
|
|
132
|
+
/** `vite dev` (true) or `vite build` (false). */
|
|
133
|
+
readonly dev: boolean;
|
|
134
|
+
/** A key this plugin reads inside Kit's own `config` page option (`export const config = { <key>:
|
|
135
|
+
* false }` in a `+page` / `+layout` module, `.server` included). Read at build time, merged the
|
|
136
|
+
* way Kit merges `config` (layouts, then the page; later wins), and answered on the server by
|
|
137
|
+
* `ctx.routeConfig(key)`. Literal values only (a boolean, number, string or null); nothing is
|
|
138
|
+
* stripped, because Kit accepts any key inside `config`. */
|
|
139
|
+
routeConfig(key: string): void;
|
|
140
|
+
/** Keep the foreign-hydrate exports on this app's island entries: another app's page may host
|
|
141
|
+
* them and wake them through its own runtime (fragment federation). Off by default — they cost
|
|
142
|
+
* every island ~185 B gz and a preload. It also says this app's pages carry other apps'
|
|
143
|
+
* regions, so its runtime ships every feature a region in the HTML can need. */
|
|
144
|
+
foreignHydrate(): void;
|
|
145
|
+
/** An `import.meta.og.<name>(…)` construct this plugin compiles (`'code'`, `'loader'`). Plugin
|
|
146
|
+
* macros run after core's own (`wire`, `$`, `source`, `store`), in plugin order; `last`: after
|
|
147
|
+
* every other plugin's (`bake`: it runs code the others may still rewrite). They
|
|
148
|
+
* run on the app's own source only: elsewhere a call fails the build (`macro_outside_app`). */
|
|
149
|
+
macro(name: string, handler: MacroHandler, options?: {
|
|
150
|
+
last?: boolean;
|
|
151
|
+
}): void;
|
|
152
|
+
/** Read the modules the build's prescan reads (the app's source and the files packages declare,
|
|
153
|
+
* every one, used or not) that import one of `hook.imports`; `hook.written()` after a
|
|
154
|
+
* `vite build` wrote its client output. An inventory (`flags()`'s flag sites) is built here. */
|
|
155
|
+
prescan(hook: PrescanHook): void;
|
|
156
|
+
/** A source format that becomes Svelte through a preprocessor (markdown): register it, get the
|
|
157
|
+
* island transform to call from that preprocessor. */
|
|
158
|
+
markup(source: MarkupSource): MarkupRegions;
|
|
159
|
+
/** Calls that define things for the life of the module making them (`content`, `flag`): exported
|
|
160
|
+
* as `names` from `module`. In dev each such call in a server module is marked with its module's
|
|
161
|
+
* run (./definers.ts), so a definition deleted from the code leaves when the module reloads; the
|
|
162
|
+
* definer reads the run with `defining()` from @ogygia/machine. */
|
|
163
|
+
definers(module: string, names: readonly string[]): void;
|
|
164
|
+
/** Compile core's EVENT emits in, browser and server (`ogygia/events`: island wakes, server renders,
|
|
165
|
+
* hub mints, navigations) — off, every emit folds away. `lazy`: measure only once a viewer opens a
|
|
166
|
+
* tool (the page carries a launcher; a preview build). */
|
|
167
|
+
events(options?: {
|
|
168
|
+
lazy?: boolean;
|
|
169
|
+
}): void;
|
|
170
|
+
/** Record the build's MEASUREMENT data: per-island detail, chunk contents, server source maps, the
|
|
171
|
+
* module map, the embedded maps, the request stats' detail — what a profiler reads. */
|
|
172
|
+
measure(): void;
|
|
173
|
+
/** Compile a package's files as app source (their islands, router-css roots): `dirs` / `files`
|
|
174
|
+
* absolute, under `root` (the package's directory). For a plugin's own pages (a UI it serves). */
|
|
175
|
+
files(scan: {
|
|
176
|
+
root: string;
|
|
177
|
+
dirs?: string[];
|
|
178
|
+
files?: string[];
|
|
179
|
+
}): void;
|
|
180
|
+
/** Modules that render pages outside Kit's routes (a programmatic router): every component they
|
|
181
|
+
* import gets its whole-tree CSS linked when it renders (`componentCssHead()` from
|
|
182
|
+
* `ogygia/plugin/css`). `importers`: any compiled module importing one of these specifiers is a
|
|
183
|
+
* page module; `files`: absolute paths that are page modules themselves (compiled ones: app source,
|
|
184
|
+
* or a `files()` / `ogygia.files` surface). */
|
|
185
|
+
pageModules(modules: {
|
|
186
|
+
importers?: string[];
|
|
187
|
+
files?: string[];
|
|
188
|
+
}): void;
|
|
189
|
+
/** SEED SHAPING: this plugin answers which top-level `page.data` keys a module reads
|
|
190
|
+
* (`@ogygia/data-shake`). One plugin at most. Without one, every region that reads the page gets
|
|
191
|
+
* all of `page.data`, and every server hole looks it up. */
|
|
192
|
+
pageReads(reads: PageReads): void;
|
|
193
|
+
}
|
|
194
|
+
/** A specifier resolved from an importer, as the bundler resolves it (null: it does not). */
|
|
195
|
+
export type PageReadsResolve = (specifier: string, importer: string) => Promise<{
|
|
196
|
+
id: string;
|
|
197
|
+
} | null | undefined>;
|
|
198
|
+
/** Why a module answers `'unknown'`: the construct, and its line. */
|
|
199
|
+
export interface PageReadWhy {
|
|
200
|
+
readonly why: string;
|
|
201
|
+
readonly line: number | null;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* What a seed-shaping plugin answers (handed to {@link BuildContext.pageReads}). Module ids are
|
|
205
|
+
* query-less, with forward slashes. Core unions the answers over each island's closure and walks
|
|
206
|
+
* each server hole's graph; `'unknown'` anywhere ships (or looks up) all of `page.data`.
|
|
207
|
+
*/
|
|
208
|
+
export interface PageReads {
|
|
209
|
+
/** A module the build compiles, in its source form (before ogygia's own rewrites). Build only. */
|
|
210
|
+
module(id: string, code: string): void;
|
|
211
|
+
/** Once in the client leg, before core asks `keys`: settle what needs the bundler (a helper in
|
|
212
|
+
* another module that the page is handed to). */
|
|
213
|
+
settle(resolve: PageReadsResolve): Promise<void>;
|
|
214
|
+
/** The keys a module reads, `'unknown'`, or null (it was never seen reading the page). */
|
|
215
|
+
keys(id: string): ReadonlySet<string> | "unknown" | null;
|
|
216
|
+
/** Why a module answers `'unknown'` (the build's seed report, the profiler). */
|
|
217
|
+
why(id: string): PageReadWhy | null;
|
|
218
|
+
/** Dev, for the profiler: what these files read together (an island's component and the app
|
|
219
|
+
* modules below it), as the build would answer; null when none reads the page. */
|
|
220
|
+
dev(files: readonly string[], resolve: PageReadsResolve): Promise<{
|
|
221
|
+
keys: string[] | "unknown" | null;
|
|
222
|
+
why: {
|
|
223
|
+
file: string;
|
|
224
|
+
line: number | null;
|
|
225
|
+
why: string;
|
|
226
|
+
}[];
|
|
227
|
+
}>;
|
|
228
|
+
}
|
|
229
|
+
/** A plugin, as the Vite plugin the app lists beside `ogygia()`. */
|
|
230
|
+
export declare function definePlugin<Options = undefined>(definition: PluginDefinition<Options>): OgygiaPlugin<Options>;
|
|
231
|
+
/** The plugin definitions in the app's Vite plugin list (nested arrays and promises included), in
|
|
232
|
+
* list order, shape-checked. `ogygia()` and its plugins come before `sveltekit()`: Vite runs
|
|
233
|
+
* same-stage hooks in list order, and theirs (the content pre-transforms, the config ogygia hands
|
|
234
|
+
* Kit) must see a module before Kit's do. */
|
|
235
|
+
export declare function find_plugins(list: unknown): Promise<PluginDefinition[]>;
|
|
236
|
+
/** What the build takes from the app's plugins. */
|
|
237
|
+
export interface ResolvedPlugins {
|
|
238
|
+
/** each server realm, in plugin order (`enforce` applied) */
|
|
239
|
+
servers: ServerRealm[];
|
|
240
|
+
/** each browser realm (its plugin's name, its absolute path), in plugin order */
|
|
241
|
+
clients: ClientRealmFile[];
|
|
242
|
+
/** every runtime hook some browser realm subscribes to */
|
|
243
|
+
client_hooks: RuntimeHookName[];
|
|
244
|
+
/** every key any plugin claims inside Kit's `config` page option */
|
|
245
|
+
route_config: string[];
|
|
246
|
+
/** a plugin asked for island entries' foreign-hydrate exports */
|
|
247
|
+
foreign_hydrate: boolean;
|
|
248
|
+
/** plugin macros, in plugin order */
|
|
249
|
+
macros: {
|
|
250
|
+
name: string;
|
|
251
|
+
handler: MacroHandler;
|
|
252
|
+
}[];
|
|
253
|
+
/** prescan readers (`b.prescan()`), in plugin order */
|
|
254
|
+
prescans: PrescanHook[];
|
|
255
|
+
/** markup sources (a preprocessor format with islands) */
|
|
256
|
+
markup: MarkupSource[];
|
|
257
|
+
/** the definer calls plugins named (`b.definers()`): marked in dev with their module's run */
|
|
258
|
+
definers: Definers[];
|
|
259
|
+
/** a plugin asked for core's events (`lazy`: measure once a tool opens), or false */
|
|
260
|
+
events: false | {
|
|
261
|
+
lazy: boolean;
|
|
262
|
+
};
|
|
263
|
+
/** a plugin asked for the build's measurement data */
|
|
264
|
+
measure: boolean;
|
|
265
|
+
/** package files compiled as app source, per plugin */
|
|
266
|
+
files: {
|
|
267
|
+
name: string;
|
|
268
|
+
root: string;
|
|
269
|
+
dirs: string[];
|
|
270
|
+
files: string[];
|
|
271
|
+
}[];
|
|
272
|
+
/** page modules (`b.pageModules()`): the specifiers whose importers are page modules, and files
|
|
273
|
+
* that are page modules themselves */
|
|
274
|
+
page_modules: {
|
|
275
|
+
importers: string[];
|
|
276
|
+
files: string[];
|
|
277
|
+
};
|
|
278
|
+
/** stage transforms (`b.transform()`), in plugin order */
|
|
279
|
+
transforms: StageTransform[];
|
|
280
|
+
/** why-stayed answers (`b.stayed()`), in plugin order */
|
|
281
|
+
stayed: StayedAnswer[];
|
|
282
|
+
/** the plugin that answers seed shaping (`b.pageReads()`), or null: every region gets all */
|
|
283
|
+
page_reads: PageReads | null;
|
|
284
|
+
}
|
|
285
|
+
/** The live region table (read at call time, so it is complete once the app's islands are known). */
|
|
286
|
+
export interface RegionsSeam {
|
|
287
|
+
/** island id → its component's name */
|
|
288
|
+
names(): Record<string, string>;
|
|
289
|
+
/** Each module that marks region imports (a host, by its absolute path) → the module ids its
|
|
290
|
+
* regions are built from: their components and the modules ogygia mints for them. */
|
|
291
|
+
hosts(): ReadonlyMap<string, ReadonlySet<string>>;
|
|
292
|
+
/** Why the module at `file` stayed as these modules import it, in the browser's leg: every
|
|
293
|
+
* plugin's answer ({@link BuildContext.stayed}), in `BARREL_LEFT_REASONS` order (none: no plugin
|
|
294
|
+
* left it). */
|
|
295
|
+
whyStayed(file: string, importers: Iterable<string>): BarrelLeftReason[];
|
|
296
|
+
}
|
|
297
|
+
export interface BuildSeams {
|
|
298
|
+
exports: ExportsSeam;
|
|
299
|
+
pinned_imports: (code: string) => (decl: PinnedDecl) => boolean;
|
|
300
|
+
regions: RegionsSeam;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Config-time shape check of the definitions found: each named once, its realms locations, its
|
|
304
|
+
* options JSON.
|
|
305
|
+
*/
|
|
306
|
+
export declare function check_plugins(plugins: readonly unknown[]): PluginDefinition[];
|
|
307
|
+
/** The runtime hooks a client realm subscribes to: the keys of the `hooks` object literal in its
|
|
308
|
+
* default `defineClient({ … })`, read from the file. */
|
|
309
|
+
export declare function client_hook_names(plugin: string, file: string): RuntimeHookName[];
|
|
310
|
+
/**
|
|
311
|
+
* When the app's root and mode are known (the `config` hook): order the plugins (`enforce`), check their
|
|
312
|
+
* realms, run their `build` hooks. `markup_transform` is the configured compiler's island
|
|
313
|
+
* transform for preprocessed markup (what `b.markup()` hands back).
|
|
314
|
+
*/
|
|
315
|
+
export declare function resolve_plugins(plugins: readonly PluginDefinition[], root: string, dev: boolean, markup_transform?: MarkupRegions["transform"], seams?: BuildSeams): ResolvedPlugins;
|
|
316
|
+
export type { MacroContext, PrescanHook };
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { OgygiaError } from "../messages.js";
|
|
2
|
+
import { parse_module } from "../parse/oxc.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { RUNTIME_HOOK_CONSTANTS } from "@ogygia/core/contract";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
// src/vite/plugin-api.ts
|
|
9
|
+
/** Where `definePlugin` puts the definition on the Vite plugin it returns. A registered symbol, so a
|
|
10
|
+
* second copy of ogygia in one app still recognizes the first's plugins. */
|
|
11
|
+
const PLUGIN = Symbol.for("ogygia.plugin");
|
|
12
|
+
const OGYGIA_VITE_PLUGIN = "ogygia";
|
|
13
|
+
/** A plugin, as the Vite plugin the app lists beside `ogygia()`. */
|
|
14
|
+
function definePlugin(definition) {
|
|
15
|
+
return {
|
|
16
|
+
name: definition.name,
|
|
17
|
+
[PLUGIN]: definition,
|
|
18
|
+
configResolved(config) {
|
|
19
|
+
if (!config.plugins.some((p) => p.name === OGYGIA_VITE_PLUGIN)) throw new OgygiaError("plugin_without_ogygia", { plugin: definition.name });
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const KIT_VITE_PLUGIN_PREFIX = "vite-plugin-sveltekit";
|
|
24
|
+
/** The plugin definitions in the app's Vite plugin list (nested arrays and promises included), in
|
|
25
|
+
* list order, shape-checked. `ogygia()` and its plugins come before `sveltekit()`: Vite runs
|
|
26
|
+
* same-stage hooks in list order, and theirs (the content pre-transforms, the config ogygia hands
|
|
27
|
+
* Kit) must see a module before Kit's do. */
|
|
28
|
+
async function find_plugins(list) {
|
|
29
|
+
const found = [];
|
|
30
|
+
let kit_seen = false;
|
|
31
|
+
const walk = async (entry) => {
|
|
32
|
+
const value = await entry;
|
|
33
|
+
if (Array.isArray(value)) {
|
|
34
|
+
for (const item of value) await walk(item);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (typeof value === "function") throw new OgygiaError("plugin_factory_not_called");
|
|
38
|
+
const plugin = value;
|
|
39
|
+
const name = typeof plugin?.name === "string" ? plugin.name : "";
|
|
40
|
+
const definition = plugin?.[PLUGIN];
|
|
41
|
+
if (name.startsWith(KIT_VITE_PLUGIN_PREFIX)) kit_seen = true;
|
|
42
|
+
const own = name === OGYGIA_VITE_PLUGIN;
|
|
43
|
+
if ((own || definition) && kit_seen) throw new OgygiaError("plugin_after_sveltekit", { plugin: own ? "ogygia()" : String(definition?.name) });
|
|
44
|
+
if (definition) found.push(definition);
|
|
45
|
+
};
|
|
46
|
+
await walk(list);
|
|
47
|
+
return check_plugins(found);
|
|
48
|
+
}
|
|
49
|
+
const MACRO_NAME_RE = /^[a-z][A-Za-z0-9]*$/;
|
|
50
|
+
const CORE_MACROS = /* @__PURE__ */ new Set([
|
|
51
|
+
"wire",
|
|
52
|
+
"$",
|
|
53
|
+
"source",
|
|
54
|
+
"store"
|
|
55
|
+
]);
|
|
56
|
+
function order(plugins) {
|
|
57
|
+
return [
|
|
58
|
+
...plugins.filter((p) => p.enforce === "pre"),
|
|
59
|
+
...plugins.filter((p) => p.enforce !== "pre" && p.enforce !== "post"),
|
|
60
|
+
...plugins.filter((p) => p.enforce === "post")
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
const ROUTE_CONFIG_KEY_RE = /^[a-z][A-Za-z0-9]*$/;
|
|
64
|
+
const NO_SEAMS = {
|
|
65
|
+
exports: { map: () => Promise.reject(/* @__PURE__ */ new Error("resolve_plugins: no export index without ogygia()")) },
|
|
66
|
+
pinned_imports: () => {
|
|
67
|
+
throw new Error("resolve_plugins: no pinned imports without ogygia()");
|
|
68
|
+
},
|
|
69
|
+
regions: {
|
|
70
|
+
names: () => {
|
|
71
|
+
throw new Error("resolve_plugins: no region table without ogygia()");
|
|
72
|
+
},
|
|
73
|
+
hosts: () => {
|
|
74
|
+
throw new Error("resolve_plugins: no region table without ogygia()");
|
|
75
|
+
},
|
|
76
|
+
whyStayed: () => {
|
|
77
|
+
throw new Error("resolve_plugins: no region table without ogygia()");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Config-time shape check of the definitions found: each named once, its realms locations, its
|
|
83
|
+
* options JSON.
|
|
84
|
+
*/
|
|
85
|
+
function check_plugins(plugins) {
|
|
86
|
+
const seen = /* @__PURE__ */ new Set();
|
|
87
|
+
for (const p of plugins) {
|
|
88
|
+
const plugin = p;
|
|
89
|
+
if (!plugin || typeof plugin !== "object" || typeof plugin.name !== "string" || plugin.name === "") throw new OgygiaError("plugin_name_missing");
|
|
90
|
+
if (seen.has(plugin.name)) throw new OgygiaError("plugin_listed_twice", { plugin: plugin.name });
|
|
91
|
+
seen.add(plugin.name);
|
|
92
|
+
for (const realm of ["server", "client"]) if (plugin[realm] !== void 0 && typeof plugin[realm] !== "string") throw new OgygiaError("plugin_realm_not_location", {
|
|
93
|
+
plugin: plugin.name,
|
|
94
|
+
realm
|
|
95
|
+
});
|
|
96
|
+
if (plugin.options !== void 0) try {
|
|
97
|
+
JSON.stringify(plugin.options);
|
|
98
|
+
} catch {
|
|
99
|
+
throw new OgygiaError("plugin_options_not_json", { plugin: plugin.name });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
for (const plugin of plugins) for (const need of plugin.needs ?? []) if (!seen.has(need.name)) throw new OgygiaError("plugin_needs_plugin", {
|
|
103
|
+
plugin: plugin.name,
|
|
104
|
+
needs: need.call,
|
|
105
|
+
from: need.from
|
|
106
|
+
});
|
|
107
|
+
return plugins;
|
|
108
|
+
}
|
|
109
|
+
function realm_path(plugin, realm) {
|
|
110
|
+
const where = plugin[realm];
|
|
111
|
+
if (where === void 0) return null;
|
|
112
|
+
const abs = where.startsWith("file:") ? fileURLToPath(where) : where;
|
|
113
|
+
if (!path.isAbsolute(abs) || !fs.existsSync(abs)) throw new OgygiaError("plugin_realm_not_file", {
|
|
114
|
+
plugin: plugin.name,
|
|
115
|
+
realm,
|
|
116
|
+
location: where
|
|
117
|
+
});
|
|
118
|
+
return abs.split(path.sep).join("/");
|
|
119
|
+
}
|
|
120
|
+
/** The runtime hooks a client realm subscribes to: the keys of the `hooks` object literal in its
|
|
121
|
+
* default `defineClient({ … })`, read from the file. */
|
|
122
|
+
function client_hook_names(plugin, file) {
|
|
123
|
+
const unread = () => new OgygiaError("plugin_client_hooks_unread", {
|
|
124
|
+
plugin,
|
|
125
|
+
location: file
|
|
126
|
+
});
|
|
127
|
+
const { program } = parse_module(fs.readFileSync(file, "utf8"), file);
|
|
128
|
+
if (!program) throw unread();
|
|
129
|
+
const body = program.body;
|
|
130
|
+
const consts = /* @__PURE__ */ new Map();
|
|
131
|
+
for (const s of body) if (s.type === "VariableDeclaration" && s.kind === "const") {
|
|
132
|
+
for (const d of s.declarations) if (d.id?.type === "Identifier" && d.init) consts.set(d.id.name, d.init);
|
|
133
|
+
}
|
|
134
|
+
const unwrap = (n) => {
|
|
135
|
+
const seen = /* @__PURE__ */ new Set();
|
|
136
|
+
while (n) if (n.type === "TSAsExpression" || n.type === "TSSatisfiesExpression" || n.type === "ParenthesizedExpression") n = n.expression;
|
|
137
|
+
else if (n.type === "Identifier" && consts.has(n.name) && !seen.has(n.name)) {
|
|
138
|
+
seen.add(n.name);
|
|
139
|
+
n = consts.get(n.name);
|
|
140
|
+
} else break;
|
|
141
|
+
return n;
|
|
142
|
+
};
|
|
143
|
+
const default_local = body.filter((s) => s.type === "ExportNamedDeclaration" && !s.source).flatMap((s) => s.specifiers).find((sp) => (sp.exported?.name ?? sp.exported?.value) === "default")?.local;
|
|
144
|
+
let value = unwrap(body.find((s) => s.type === "ExportDefaultDeclaration")?.declaration ?? default_local);
|
|
145
|
+
if (value?.type === "CallExpression") value = unwrap(value.arguments?.[0]);
|
|
146
|
+
if (value?.type !== "ObjectExpression") throw unread();
|
|
147
|
+
const key_of = (p) => {
|
|
148
|
+
if (p.type !== "Property" || p.computed) return null;
|
|
149
|
+
if (p.key.type === "Identifier") return p.key.name;
|
|
150
|
+
return p.key.type === "Literal" && typeof p.key.value === "string" ? p.key.value : null;
|
|
151
|
+
};
|
|
152
|
+
const props = value.properties;
|
|
153
|
+
if (props.some((p) => key_of(p) === null)) throw unread();
|
|
154
|
+
const hooks = unwrap(props.find((p) => key_of(p) === "hooks")?.value);
|
|
155
|
+
if (!hooks) return [];
|
|
156
|
+
if (hooks.type !== "ObjectExpression") throw unread();
|
|
157
|
+
const names = [];
|
|
158
|
+
for (const p of hooks.properties) {
|
|
159
|
+
const key = key_of(p);
|
|
160
|
+
if (key === null) throw unread();
|
|
161
|
+
if (!Object.hasOwn(RUNTIME_HOOK_CONSTANTS, key)) throw new OgygiaError("plugin_client_hook_unknown", {
|
|
162
|
+
plugin,
|
|
163
|
+
hook: key
|
|
164
|
+
});
|
|
165
|
+
names.push(key);
|
|
166
|
+
}
|
|
167
|
+
return names;
|
|
168
|
+
}
|
|
169
|
+
function package_resolves(req, name) {
|
|
170
|
+
try {
|
|
171
|
+
req.resolve(`${name}/package.json`);
|
|
172
|
+
return true;
|
|
173
|
+
} catch (e) {
|
|
174
|
+
return e.code === "ERR_PACKAGE_PATH_NOT_EXPORTED";
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* When the app's root and mode are known (the `config` hook): order the plugins (`enforce`), check their
|
|
179
|
+
* realms, run their `build` hooks. `markup_transform` is the configured compiler's island
|
|
180
|
+
* transform for preprocessed markup (what `b.markup()` hands back).
|
|
181
|
+
*/
|
|
182
|
+
function resolve_plugins(plugins, root, dev, markup_transform = () => null, seams = NO_SEAMS) {
|
|
183
|
+
const ordered = order(plugins);
|
|
184
|
+
const req = createRequire(path.join(root, "package.json"));
|
|
185
|
+
const out = {
|
|
186
|
+
servers: [],
|
|
187
|
+
clients: [],
|
|
188
|
+
client_hooks: [],
|
|
189
|
+
route_config: [],
|
|
190
|
+
foreign_hydrate: false,
|
|
191
|
+
macros: [],
|
|
192
|
+
prescans: [],
|
|
193
|
+
markup: [],
|
|
194
|
+
definers: [],
|
|
195
|
+
events: false,
|
|
196
|
+
measure: false,
|
|
197
|
+
files: [],
|
|
198
|
+
page_modules: {
|
|
199
|
+
importers: [],
|
|
200
|
+
files: []
|
|
201
|
+
},
|
|
202
|
+
transforms: [],
|
|
203
|
+
stayed: [],
|
|
204
|
+
page_reads: null
|
|
205
|
+
};
|
|
206
|
+
let page_reads_owner = null;
|
|
207
|
+
const config_owner = /* @__PURE__ */ new Map();
|
|
208
|
+
const macro_owner = /* @__PURE__ */ new Map();
|
|
209
|
+
const last_macros = [];
|
|
210
|
+
for (const plugin of ordered) {
|
|
211
|
+
if (!package_resolves(req, plugin.name)) throw new OgygiaError("plugin_package_unresolved", {
|
|
212
|
+
plugin: plugin.name,
|
|
213
|
+
root
|
|
214
|
+
});
|
|
215
|
+
const server = realm_path(plugin, "server");
|
|
216
|
+
if (server) out.servers.push({
|
|
217
|
+
name: plugin.name,
|
|
218
|
+
module: server,
|
|
219
|
+
options: plugin.options ?? {}
|
|
220
|
+
});
|
|
221
|
+
const client = realm_path(plugin, "client");
|
|
222
|
+
if (client) {
|
|
223
|
+
out.clients.push({
|
|
224
|
+
name: plugin.name,
|
|
225
|
+
module: client
|
|
226
|
+
});
|
|
227
|
+
for (const name of client_hook_names(plugin.name, client)) if (!out.client_hooks.includes(name)) out.client_hooks.push(name);
|
|
228
|
+
}
|
|
229
|
+
plugin.build?.({
|
|
230
|
+
root,
|
|
231
|
+
dev,
|
|
232
|
+
exports: seams.exports,
|
|
233
|
+
pinnedImports: seams.pinned_imports,
|
|
234
|
+
regions: seams.regions,
|
|
235
|
+
transform(t) {
|
|
236
|
+
out.transforms.push(t);
|
|
237
|
+
},
|
|
238
|
+
stayed(answer) {
|
|
239
|
+
out.stayed.push(answer);
|
|
240
|
+
},
|
|
241
|
+
routeConfig(key) {
|
|
242
|
+
if (!ROUTE_CONFIG_KEY_RE.test(key)) throw new OgygiaError("route_config_key_invalid", {
|
|
243
|
+
plugin: plugin.name,
|
|
244
|
+
key
|
|
245
|
+
});
|
|
246
|
+
const owner = config_owner.get(key);
|
|
247
|
+
if (owner && owner !== plugin.name) throw new OgygiaError("route_config_key_claimed", {
|
|
248
|
+
key,
|
|
249
|
+
owner,
|
|
250
|
+
plugin: plugin.name
|
|
251
|
+
});
|
|
252
|
+
if (!owner) {
|
|
253
|
+
config_owner.set(key, plugin.name);
|
|
254
|
+
out.route_config.push(key);
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
foreignHydrate() {
|
|
258
|
+
out.foreign_hydrate = true;
|
|
259
|
+
},
|
|
260
|
+
macro(name, handler, options) {
|
|
261
|
+
if (!MACRO_NAME_RE.test(name) || CORE_MACROS.has(name)) throw new OgygiaError("plugin_macro_name_invalid", {
|
|
262
|
+
plugin: plugin.name,
|
|
263
|
+
name
|
|
264
|
+
});
|
|
265
|
+
const owner = macro_owner.get(name);
|
|
266
|
+
if (owner) throw new OgygiaError("plugin_macro_claimed", {
|
|
267
|
+
name,
|
|
268
|
+
owner,
|
|
269
|
+
plugin: plugin.name
|
|
270
|
+
});
|
|
271
|
+
macro_owner.set(name, plugin.name);
|
|
272
|
+
(options?.last ? last_macros : out.macros).push({
|
|
273
|
+
name,
|
|
274
|
+
handler
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
prescan(hook) {
|
|
278
|
+
out.prescans.push(hook);
|
|
279
|
+
},
|
|
280
|
+
markup(source) {
|
|
281
|
+
out.markup.push(source);
|
|
282
|
+
return { transform: markup_transform };
|
|
283
|
+
},
|
|
284
|
+
definers(module, names) {
|
|
285
|
+
out.definers.push({
|
|
286
|
+
module,
|
|
287
|
+
names: [...names]
|
|
288
|
+
});
|
|
289
|
+
},
|
|
290
|
+
events(options) {
|
|
291
|
+
const lazy = options?.lazy === true;
|
|
292
|
+
out.events = out.events ? { lazy: out.events.lazy && lazy } : { lazy };
|
|
293
|
+
},
|
|
294
|
+
measure() {
|
|
295
|
+
out.measure = true;
|
|
296
|
+
},
|
|
297
|
+
files(scan) {
|
|
298
|
+
out.files.push({
|
|
299
|
+
name: plugin.name,
|
|
300
|
+
root: scan.root,
|
|
301
|
+
dirs: scan.dirs ?? [],
|
|
302
|
+
files: scan.files ?? []
|
|
303
|
+
});
|
|
304
|
+
},
|
|
305
|
+
pageModules(modules) {
|
|
306
|
+
for (const spec of modules.importers ?? []) if (!out.page_modules.importers.includes(spec)) out.page_modules.importers.push(spec);
|
|
307
|
+
for (const file of modules.files ?? []) {
|
|
308
|
+
if (!path.isAbsolute(file)) throw new OgygiaError("page_modules_not_absolute", {
|
|
309
|
+
plugin: plugin.name,
|
|
310
|
+
file
|
|
311
|
+
});
|
|
312
|
+
if (!out.page_modules.files.includes(file)) out.page_modules.files.push(file);
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
pageReads(reads) {
|
|
316
|
+
if (page_reads_owner !== null) throw new OgygiaError("page_reads_claimed", {
|
|
317
|
+
owner: page_reads_owner,
|
|
318
|
+
plugin: plugin.name
|
|
319
|
+
});
|
|
320
|
+
page_reads_owner = plugin.name;
|
|
321
|
+
out.page_reads = reads;
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
out.macros.push(...last_macros);
|
|
326
|
+
return out;
|
|
327
|
+
}
|
|
328
|
+
export { PLUGIN, check_plugins, client_hook_names, definePlugin, find_plugins, resolve_plugins };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Compiler } from "../driver.js";
|
|
2
|
+
import { Machine } from "@ogygia/machine";
|
|
3
|
+
type SessionStates = {
|
|
4
|
+
created: {};
|
|
5
|
+
configured: {};
|
|
6
|
+
resolved: {
|
|
7
|
+
compiler: Compiler;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
declare const SESSION_STEPS: {
|
|
11
|
+
readonly created: readonly ["configured", "resolved"];
|
|
12
|
+
readonly configured: readonly ["configured", "resolved"];
|
|
13
|
+
readonly resolved: readonly ["configured", "resolved"];
|
|
14
|
+
};
|
|
15
|
+
export type Session = Machine<SessionStates, typeof SESSION_STEPS>;
|
|
16
|
+
export declare function new_session(): Session;
|
|
17
|
+
/** The `config` hook ran (again). */
|
|
18
|
+
export declare function configured(session: Session): void;
|
|
19
|
+
/**
|
|
20
|
+
* The bundler resolved the build: the session's compiler, made with that build's context. `prev` is
|
|
21
|
+
* the compiler a resolve with no `config` since made (a plugin shared across a builder's
|
|
22
|
+
* environments): the new one keeps its build (`Compiler.with_ctx`), else the next leg would start
|
|
23
|
+
* from nothing.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolve(session: Session, make: (prev: Compiler | null) => Compiler): Compiler;
|
|
26
|
+
/** The session's compiler, for `hook`: refused before the build is resolved. */
|
|
27
|
+
export declare function compiler_of(session: Session, hook: string): Compiler;
|
|
28
|
+
export {};
|