goatly 0.1.0 → 0.1.1
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/README.md +853 -1
- package/bin/goatly.js +91 -0
- package/dist/cli/index.js +234 -0
- package/dist/compat/gatsby-node-entry.js +16 -0
- package/dist/compat/gatsby-package.json +6 -0
- package/dist/compat/md5-file.js +47 -0
- package/dist/compat-apis.json +72 -0
- package/dist/compat-apis.json.js +62 -0
- package/dist/graphql.js +3 -0
- package/dist/node/actions/index.js +619 -0
- package/dist/node/actions/job-store.js +180 -0
- package/dist/node/actions/jobs.js +174 -0
- package/dist/node/api-runner.js +258 -0
- package/dist/node/bootstrap.js +539 -0
- package/dist/node/build/assets.js +110 -0
- package/dist/node/build/incremental.js +208 -0
- package/dist/node/build/index.js +752 -0
- package/dist/node/build/memory-governor.js +448 -0
- package/dist/node/build/output-dirs.js +70 -0
- package/dist/node/build/page-data.js +40 -0
- package/dist/node/build/page-files.js +54 -0
- package/dist/node/build/partitioned-state.js +258 -0
- package/dist/node/build/query-worker.js +536 -0
- package/dist/node/build/query-workers.js +832 -0
- package/dist/node/build/render-worker.js +131 -0
- package/dist/node/build/state.js +24 -0
- package/dist/node/build/timing-breakdown.js +155 -0
- package/dist/node/build/worker-pool.js +236 -0
- package/dist/node/cache-layout.js +99 -0
- package/dist/node/cache.js +1430 -0
- package/dist/node/compat/chokidar-shim.js +148 -0
- package/dist/node/compat/core-utils-lmdb.js +145 -0
- package/dist/node/compat/create-node-id-shim.js +1 -0
- package/dist/node/compat/module-hooks.js +245 -0
- package/dist/node/compat/redux-shim.js +1 -0
- package/dist/node/config/index.js +162 -0
- package/dist/node/config/not-found-pages.js +95 -0
- package/dist/node/datastore/codec.js +144 -0
- package/dist/node/datastore/index.js +127 -0
- package/dist/node/datastore/logfile/cache.js +89 -0
- package/dist/node/datastore/logfile/index.js +1329 -0
- package/dist/node/datastore/logfile/record.js +71 -0
- package/dist/node/datastore/types.js +1 -0
- package/dist/node/develop/express-compat.js +207 -0
- package/dist/node/develop/graphiql.js +22 -0
- package/dist/node/develop/hydration-report.js +41 -0
- package/dist/node/develop/index.js +618 -0
- package/dist/node/develop/local-url.js +10 -0
- package/dist/node/develop/ssr-runner.js +66 -0
- package/dist/node/gql.js +5 -0
- package/dist/node/index.js +15 -0
- package/dist/node/info.js +270 -0
- package/dist/node/internal-plugins/data-bridge.js +196 -0
- package/dist/node/internal-plugins/page-creator.js +318 -0
- package/dist/node/loader/import-module.js +160 -0
- package/dist/node/node-helpers.js +66 -0
- package/dist/node/not-found-pages.js +220 -0
- package/dist/node/plugins/api-list.js +12 -0
- package/dist/node/plugins/load-plugins.js +427 -0
- package/dist/node/plugins/resolve-plugin.js +79 -0
- package/dist/node/plugins/static-exports.js +64 -0
- package/dist/node/query/compile.js +326 -0
- package/dist/node/query/dependencies.js +45 -0
- package/dist/node/query/execute.js +417 -0
- package/dist/node/query/extract.js +372 -0
- package/dist/node/query/gql-tada-introspection.js +124 -0
- package/dist/node/query/graphql-env.js +231 -0
- package/dist/node/query/graphql-runner.js +79 -0
- package/dist/node/redux/actions.js +1 -0
- package/dist/node/redux/index.js +133 -0
- package/dist/node/redux/node-changes.js +128 -0
- package/dist/node/redux/reducers.js +193 -0
- package/dist/node/redux/state.js +71 -0
- package/dist/node/renderer.js +124 -0
- package/dist/node/reporter-transports.js +259 -0
- package/dist/node/reporter.js +497 -0
- package/dist/node/schema/date.js +539 -0
- package/dist/node/schema/extensions.js +315 -0
- package/dist/node/schema/index.js +542 -0
- package/dist/node/schema/infer.js +388 -0
- package/dist/node/schema/inline-objects.js +128 -0
- package/dist/node/schema/naming.js +20 -0
- package/dist/node/schema/node-model.js +207 -0
- package/dist/node/schema/query-engine.js +1808 -0
- package/dist/node/schema/resolver-kinds.js +7 -0
- package/dist/node/schema/resolvers.js +273 -0
- package/dist/node/schema/type-builders.js +45 -0
- package/dist/node/schema/types.js +241 -0
- package/dist/node/serve.js +90 -0
- package/dist/node/site-page-nodes.js +277 -0
- package/dist/node/types.js +1 -0
- package/dist/node/utils/content-digest.js +107 -0
- package/dist/node/utils/create-node-id.js +51 -0
- package/dist/node/utils/env.js +24 -0
- package/dist/node/utils/fs-retry.js +74 -0
- package/dist/node/utils/memory-signals.js +410 -0
- package/dist/node/utils/memory.js +400 -0
- package/dist/node/utils/murmurhash.js +32 -0
- package/dist/node/utils/parser.js +33 -0
- package/dist/node/utils/partition-hash.js +19 -0
- package/dist/node/utils/paths.js +122 -0
- package/dist/node/utils/resolver.js +48 -0
- package/dist/node/utils/runtime.js +5 -0
- package/dist/node/utils/serializable.js +41 -0
- package/dist/node/utils/strings.js +41 -0
- package/dist/node/vite/config.js +289 -0
- package/dist/node/vite/paths.js +12 -0
- package/dist/node/vite/plugin-deps.js +232 -0
- package/dist/node/vite/plugin.js +281 -0
- package/dist/node/vite/react-compiler.js +362 -0
- package/dist/node/vite/source-files.js +83 -0
- package/dist/node/vite/static-image.js +136 -0
- package/dist/node/vite/styled-components.js +73 -0
- package/dist/node/vite/transforms.js +299 -0
- package/dist/node/wasm-data/host.js +406 -0
- package/dist/node/wasm-data/lower.js +406 -0
- package/dist/node/wasm-data/runner.js +79 -0
- package/dist/node/wasm-data/worker.js +95 -0
- package/dist/reporter.js +5 -0
- package/dist/runtime/api-runner.js +81 -0
- package/dist/runtime/app.js +256 -0
- package/dist/runtime/client-entry.js +4 -0
- package/dist/runtime/client.js +383 -0
- package/dist/runtime/default-html.js +31 -0
- package/dist/runtime/head-markup.js +100 -0
- package/dist/runtime/head-sync.js +101 -0
- package/dist/runtime/head-tags.js +45 -0
- package/dist/runtime/hydration-report.js +111 -0
- package/dist/runtime/index.js +12 -0
- package/dist/runtime/link.js +293 -0
- package/dist/runtime/loader.js +449 -0
- package/dist/runtime/not-found.js +61 -0
- package/dist/runtime/page-renderer.js +35 -0
- package/dist/runtime/preamble.js +47 -0
- package/dist/runtime/react-compat.js +14 -0
- package/dist/runtime/renderer-shared.js +10 -0
- package/dist/runtime/renderers/react-client.js +14 -0
- package/dist/runtime/renderers/react-server.js +99 -0
- package/dist/runtime/renderers/react.js +17 -0
- package/dist/runtime/renderers/types.js +1 -0
- package/dist/runtime/root-error-handlers.js +29 -0
- package/dist/runtime/router/history.js +132 -0
- package/dist/runtime/router/index.js +240 -0
- package/dist/runtime/router/utils.js +118 -0
- package/dist/runtime/script.js +110 -0
- package/dist/runtime/scroll.js +40 -0
- package/dist/runtime/slice.js +11 -0
- package/dist/runtime/ssr.js +240 -0
- package/dist/runtime/static-query.js +47 -0
- package/dist/utils.js +4 -0
- package/package.json +105 -3
- package/types/graphql-tada.d.ts +223 -0
- package/types/graphql.d.ts +2 -0
- package/types/index.d.ts +2287 -0
- package/types/node.d.ts +380 -0
- package/types/reporter.d.ts +187 -0
- package/types/router.d.ts +102 -0
- package/types/vendor/gql-tada.d.ts +2529 -0
package/types/node.d.ts
ADDED
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import type { DataStore, GatsbyConfig, Node, Page } from "./index.js"
|
|
2
|
+
export type { DataStore, Node }
|
|
3
|
+
|
|
4
|
+
export interface BuildOptions {
|
|
5
|
+
directory: string
|
|
6
|
+
prefixPaths?: boolean
|
|
7
|
+
verbose?: boolean
|
|
8
|
+
/** reporter transports (override `reporter` in gatsby-config) */
|
|
9
|
+
reporter?:
|
|
10
|
+
| import("./reporter.js").ReporterTransport
|
|
11
|
+
| Array<import("./reporter.js").ReporterTransport>
|
|
12
|
+
}
|
|
13
|
+
export interface BuildResult {
|
|
14
|
+
pages: number
|
|
15
|
+
/** page queries that ran (the others were unchanged – incremental query running) */
|
|
16
|
+
queries: number
|
|
17
|
+
rendered: number
|
|
18
|
+
skipped: number
|
|
19
|
+
parallelQueries: boolean
|
|
20
|
+
timings: Record<string, number>
|
|
21
|
+
/**
|
|
22
|
+
* wall-clock milliseconds of the predefined build segments (they add up to `timings.total`):
|
|
23
|
+
* bootstrap, staticQueries, queryWorkers, pageQueries, bundle (time waited for it), render,
|
|
24
|
+
* postBuild, finalize
|
|
25
|
+
*/
|
|
26
|
+
breakdown: Record<
|
|
27
|
+
| "bootstrap"
|
|
28
|
+
| "staticQueries"
|
|
29
|
+
| "queryWorkers"
|
|
30
|
+
| "pageQueries"
|
|
31
|
+
| "bundle"
|
|
32
|
+
| "render"
|
|
33
|
+
| "postBuild"
|
|
34
|
+
| "finalize",
|
|
35
|
+
number
|
|
36
|
+
>
|
|
37
|
+
}
|
|
38
|
+
export declare function build(options: BuildOptions): Promise<BuildResult>
|
|
39
|
+
|
|
40
|
+
export interface DevelopOptions {
|
|
41
|
+
directory: string
|
|
42
|
+
host?: string
|
|
43
|
+
port?: number
|
|
44
|
+
verbose?: boolean
|
|
45
|
+
open?: boolean
|
|
46
|
+
prefixPaths?: boolean
|
|
47
|
+
/** reporter transports (override `reporter` in gatsby-config) */
|
|
48
|
+
reporter?:
|
|
49
|
+
| import("./reporter.js").ReporterTransport
|
|
50
|
+
| Array<import("./reporter.js").ReporterTransport>
|
|
51
|
+
}
|
|
52
|
+
export declare function develop(
|
|
53
|
+
options: DevelopOptions,
|
|
54
|
+
): Promise<{ port: number; close(): Promise<void> }>
|
|
55
|
+
export declare function serve(options: {
|
|
56
|
+
directory: string
|
|
57
|
+
host: string
|
|
58
|
+
port: number
|
|
59
|
+
prefixPaths?: boolean
|
|
60
|
+
open?: boolean
|
|
61
|
+
}): Promise<unknown>
|
|
62
|
+
|
|
63
|
+
export interface LogFileDataStoreOptions {
|
|
64
|
+
/** directory of the segment and index files (default: `<cacheDir>/data/logfile`) */
|
|
65
|
+
dir?: string
|
|
66
|
+
/** decoded nodes kept in memory per thread (default: 10,000; 2,000 in query workers) */
|
|
67
|
+
cacheSize?: number
|
|
68
|
+
/**
|
|
69
|
+
* about the most bytes of nodes kept decoded per thread, counted as their encoded size (default:
|
|
70
|
+
* 256 MB; 64 MB in query workers): with large nodes (e.g. rich text) `cacheSize` nodes could take
|
|
71
|
+
* gigabytes per thread
|
|
72
|
+
*/
|
|
73
|
+
cacheBytes?: number
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The default datastore: nodes are msgpack-encoded and appended to segment files in `.cache`, read
|
|
77
|
+
* back with positional reads (through the OS page cache, outside the process's memory), with a
|
|
78
|
+
* compact index per thread. Query workers read the same files. Each run writes new segment files
|
|
79
|
+
* and index log files; files of earlier builds are never modified, so a layer diff of `.cache`
|
|
80
|
+
* holds only what changed.
|
|
81
|
+
*/
|
|
82
|
+
export declare class LogFileDataStore implements DataStore {
|
|
83
|
+
constructor(
|
|
84
|
+
options?: LogFileDataStoreOptions & {
|
|
85
|
+
cacheDir?: string
|
|
86
|
+
/**
|
|
87
|
+
* Open the store without changing its files (inspection tools): load() restores the persisted
|
|
88
|
+
* state without removing unread index log files or unlisted segments, writes throw, persist()
|
|
89
|
+
* and close() write nothing, and a missing directory is not created. Query workers are always
|
|
90
|
+
* read-only. Experimental (not covered by semver).
|
|
91
|
+
*/
|
|
92
|
+
readonly?: boolean
|
|
93
|
+
},
|
|
94
|
+
)
|
|
95
|
+
readonly name: "logfile"
|
|
96
|
+
readonly sharedAcrossThreads: true
|
|
97
|
+
readonly lazy: true
|
|
98
|
+
getNode(id: string): Node | undefined
|
|
99
|
+
getNodesByIds(ids: readonly string[], options?: { cache?: boolean }): Array<Node | undefined>
|
|
100
|
+
getNodeIdsByType(typeName: string): string[]
|
|
101
|
+
getNodeType(id: string): string | undefined
|
|
102
|
+
getNodeParent(id: string): string | null | undefined
|
|
103
|
+
getMaxNodeCounter(): number
|
|
104
|
+
getNodeDigest(id: string): string | undefined
|
|
105
|
+
getTypes(): string[]
|
|
106
|
+
countNodes(typeName?: string): number
|
|
107
|
+
getNodes(): Node[]
|
|
108
|
+
getNodesByType(typeName: string): Node[]
|
|
109
|
+
iterateNodes(): Iterable<Node>
|
|
110
|
+
iterateNodesByType(typeName: string): Iterable<Node>
|
|
111
|
+
setNode(node: Node, oldNode?: Node): void
|
|
112
|
+
deleteNode(node: Node): void
|
|
113
|
+
ready(): Promise<void>
|
|
114
|
+
trimCache(): void
|
|
115
|
+
clear(): void
|
|
116
|
+
load(): Promise<boolean>
|
|
117
|
+
persist(): Promise<void>
|
|
118
|
+
close(): void
|
|
119
|
+
/**
|
|
120
|
+
* A read-only view of the store's internal state, for inspection tools (e.g. a devtools panel).
|
|
121
|
+
* Experimental: not covered by semver. Reading it changes nothing: it does not flush, encode or
|
|
122
|
+
* use the node cache (`value()` reads a node without keeping it).
|
|
123
|
+
*/
|
|
124
|
+
inspect(): LogFileInspection
|
|
125
|
+
}
|
|
126
|
+
/** A record header in the logfile store's segment files (see `LogFileDataStore.inspect()`) */
|
|
127
|
+
export interface LogFileRecordHeader {
|
|
128
|
+
dataLength: number
|
|
129
|
+
typeIndex: number
|
|
130
|
+
idLength: number
|
|
131
|
+
parentLength: number
|
|
132
|
+
digestLength: number
|
|
133
|
+
}
|
|
134
|
+
/** see `LogFileDataStore.inspect()` */
|
|
135
|
+
export interface LogFileRecordInfo {
|
|
136
|
+
/**
|
|
137
|
+
* offset of the node's latest record (in the virtual address space of the segments); null: not
|
|
138
|
+
* written yet (pending)
|
|
139
|
+
*/
|
|
140
|
+
offset: number | null
|
|
141
|
+
/** index into `types` of the record (or of the pending write) */
|
|
142
|
+
typeIndex: number | null
|
|
143
|
+
/**
|
|
144
|
+
* the file that holds the record (`segment-<id>`) and where in it; null: not written, or outside
|
|
145
|
+
* the files the index lists
|
|
146
|
+
*/
|
|
147
|
+
file: string | null
|
|
148
|
+
fileOffset: number | null
|
|
149
|
+
/** record size in bytes, header included; null: not written, or not readable */
|
|
150
|
+
size: number | null
|
|
151
|
+
header: LogFileRecordHeader | null
|
|
152
|
+
/** a newer version of the node waits in memory (not in a segment yet) */
|
|
153
|
+
pending: boolean
|
|
154
|
+
}
|
|
155
|
+
/** see `LogFileDataStore.inspect()`: a segment file */
|
|
156
|
+
export interface LogFileSegmentInfo {
|
|
157
|
+
/** the file is `segment-<id>` */
|
|
158
|
+
id: string
|
|
159
|
+
/** its first offset in the virtual address space */
|
|
160
|
+
base: number
|
|
161
|
+
/** bytes of it the persisted index covers (the segment this run appends to: bytes written) */
|
|
162
|
+
length: number
|
|
163
|
+
/** bytes of the file (a run that did not persist may have written more than `length`) */
|
|
164
|
+
size: number
|
|
165
|
+
/** bytes of live records */
|
|
166
|
+
live: number
|
|
167
|
+
/** this run appends to it */
|
|
168
|
+
current: boolean
|
|
169
|
+
}
|
|
170
|
+
/** Experimental (not covered by semver): see `LogFileDataStore.inspect()` */
|
|
171
|
+
export interface LogFileInspection {
|
|
172
|
+
dir: string
|
|
173
|
+
readonly: boolean
|
|
174
|
+
/** the on-disk format version this store reads (an index of another version is not restored) */
|
|
175
|
+
formatVersion: number
|
|
176
|
+
/**
|
|
177
|
+
* changes whenever the store's data or files change (writes, flushes, persist, load, compaction,
|
|
178
|
+
* new record structures); not when reads fill or use the node cache
|
|
179
|
+
*/
|
|
180
|
+
version: number
|
|
181
|
+
/** the persisted index snapshot */
|
|
182
|
+
snapshotId: string | null
|
|
183
|
+
/** bytes of the segment files */
|
|
184
|
+
fileEnd: number
|
|
185
|
+
/**
|
|
186
|
+
* bytes of superseded and deleted records in the segments, and the bytes of segments past what
|
|
187
|
+
* the index covers
|
|
188
|
+
*/
|
|
189
|
+
garbage: number
|
|
190
|
+
/** the segments by base */
|
|
191
|
+
segments: LogFileSegmentInfo[]
|
|
192
|
+
/** writes buffered in memory, not in a segment yet */
|
|
193
|
+
pendingWrites: number
|
|
194
|
+
/** ids set or deleted since the last persist() */
|
|
195
|
+
changed: number
|
|
196
|
+
/** changed since the last persist() or load() */
|
|
197
|
+
dirty: boolean
|
|
198
|
+
/** entries in the index log files after the last snapshot */
|
|
199
|
+
logEntries: number
|
|
200
|
+
/**
|
|
201
|
+
* the index log files of the snapshot that were replayed or written
|
|
202
|
+
* (`index-log-000001-<snapshotId>` up to this number; later ones are not read)
|
|
203
|
+
*/
|
|
204
|
+
logFiles: number
|
|
205
|
+
/** msgpackr shared record structures */
|
|
206
|
+
structures: number
|
|
207
|
+
/** the type table: `typeIndex` of records and addresses indexes it */
|
|
208
|
+
types: string[]
|
|
209
|
+
/** the node cache when inspect() was called (reads change `size` without changing `version`) */
|
|
210
|
+
cache: { size: number; max: number }
|
|
211
|
+
/** all node ids in insertion order (a live iterator: consume it before the store changes) */
|
|
212
|
+
ids(): IterableIterator<string>
|
|
213
|
+
record(id: string): LogFileRecordInfo | undefined
|
|
214
|
+
/**
|
|
215
|
+
* The node's latest value, read without changing the store: no encode, no cache fill, nothing
|
|
216
|
+
* kept. Can be the store's own objects: a cached or pending node, or the working copy of
|
|
217
|
+
* `getNodeForUpdate()` (what the next flush encodes): read only, do not modify.
|
|
218
|
+
*/
|
|
219
|
+
value(id: string): Node | undefined
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* `api` of the `goatly` Vite plugin (in develop and build): other Vite plugins of the same
|
|
223
|
+
* server reach the running instance through it, e.g.
|
|
224
|
+
* `config.plugins.find((p) => p.name === "goatly")?.api`.
|
|
225
|
+
*/
|
|
226
|
+
export interface GoatlyVitePluginApi {
|
|
227
|
+
/** increases when a member is added */
|
|
228
|
+
apiVersion: 1
|
|
229
|
+
/** the datastore of this process (the configured one once bootstrap ran) */
|
|
230
|
+
getDataStore(): DataStore
|
|
231
|
+
}
|
|
232
|
+
/** The logfile datastore (the default) with options: `datastore: logFileDataStore({ cacheSize })` */
|
|
233
|
+
export declare function logFileDataStore(
|
|
234
|
+
options?: LogFileDataStoreOptions,
|
|
235
|
+
): (ctx: { cacheDir: string }) => LogFileDataStore
|
|
236
|
+
export declare function createContentDigest(input: string | object): string
|
|
237
|
+
export declare function createNodeId(id: string, namespace?: string): string
|
|
238
|
+
/** Identity helper for typed gatsby-config files */
|
|
239
|
+
export declare function defineConfig<T extends GatsbyConfig>(config: T): T
|
|
240
|
+
export type { Page }
|
|
241
|
+
|
|
242
|
+
// ---- renderers (gatsby-config `renderer`) – experimental, the interface may change ------------
|
|
243
|
+
|
|
244
|
+
export type { RendererDescriptor } from "./index.js"
|
|
245
|
+
|
|
246
|
+
/** The default export of a renderer module (`RendererDescriptor.module`). */
|
|
247
|
+
export type RendererFactory = (
|
|
248
|
+
options: any,
|
|
249
|
+
context: RendererContext,
|
|
250
|
+
) => Renderer | Promise<Renderer>
|
|
251
|
+
|
|
252
|
+
export interface RendererContext {
|
|
253
|
+
/** the site directory */
|
|
254
|
+
root: string
|
|
255
|
+
/** goatly's reporter; the methods can be called detached */
|
|
256
|
+
reporter: {
|
|
257
|
+
info(message: string): void
|
|
258
|
+
warn(message: string): void
|
|
259
|
+
error(message: string, error?: unknown): void
|
|
260
|
+
verbose(message: string): void
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface Renderer {
|
|
265
|
+
name: string
|
|
266
|
+
/** Absolute paths of the runtime modules: `RendererShared`, `RendererServer`, `RendererClient`. */
|
|
267
|
+
runtime: { shared: string; server: string; client: string }
|
|
268
|
+
/** Additions to the Vite config of every stage. */
|
|
269
|
+
vite?(context: RendererViteContext): RendererViteConfig | Promise<RendererViteConfig>
|
|
270
|
+
/** For modules Node (or Bun) loads itself: gatsby-node files, externals of the SSR bundle. */
|
|
271
|
+
nodeHooks?: RendererNodeHooks
|
|
272
|
+
/** Changes whenever the HTML can change while the bundles stay the same (part of the HTML cache key). */
|
|
273
|
+
cacheKey?: string
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export interface RendererViteContext {
|
|
277
|
+
stage: "develop" | "develop-html" | "build-javascript" | "build-html"
|
|
278
|
+
isBuild: boolean
|
|
279
|
+
root: string
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export interface RendererViteConfig {
|
|
283
|
+
/** Added after goatly's own plugins. */
|
|
284
|
+
plugins?: any[]
|
|
285
|
+
/** Packages that must resolve to one copy (`resolve.dedupe`). */
|
|
286
|
+
dedupe?: string[]
|
|
287
|
+
/** Specifiers the SSR bundle of a build leaves to the runtime (`ssr.external`). */
|
|
288
|
+
ssrExternal?: string[]
|
|
289
|
+
/** Bare specifiers the renderer provides: `onCreateWebpackConfig` aliases for them are ignored. */
|
|
290
|
+
ownedSpecifiers?: string[]
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export interface RendererNodeHooks {
|
|
294
|
+
/** Maps a bare specifier to an absolute file, or returns undefined to leave it alone. */
|
|
295
|
+
resolve?(specifier: string): string | undefined
|
|
296
|
+
/** The bare specifiers `resolve` maps (needed on Bun, which has no resolve hook for ESM imports). */
|
|
297
|
+
specifiers?: string[]
|
|
298
|
+
/**
|
|
299
|
+
* Rewrites the source of the files matching `filter` (on Node tested against the absolute path
|
|
300
|
+
* with forward slashes, on Bun it is the `onLoad` filter). `undefined` leaves a file unchanged.
|
|
301
|
+
*/
|
|
302
|
+
load?: { filter: RegExp; transform(file: string, code: string): string | undefined }
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** How the page's `Head` export gets into `<head>` (see the built-in renderer). */
|
|
306
|
+
export type HeadMode = "hoist" | "portal"
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* The runtime modules (`runtime.shared`, `runtime.server`, `runtime.client`) are bundled by Vite.
|
|
310
|
+
* They can import core's runtime as `goatly/runtime/<module>` or `gatsby/runtime/<module>`
|
|
311
|
+
* (an alias, whatever name the site installed goatly under).
|
|
312
|
+
*/
|
|
313
|
+
|
|
314
|
+
/** Exports of `runtime.shared` (bundled into the browser and the SSR bundle). */
|
|
315
|
+
export interface RendererShared {
|
|
316
|
+
headMode: HeadMode
|
|
317
|
+
/**
|
|
318
|
+
* Portal head mode: the text of a `<script>`/`<style>` of the `Head` export as the renderer's
|
|
319
|
+
* server writes it; the browser head sync compares the client's text in this form. Default:
|
|
320
|
+
* `</script` / `</style` escaped.
|
|
321
|
+
*/
|
|
322
|
+
escapeRawText?: (text: string, tag: "script" | "style") => string
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export interface RenderedMarkup {
|
|
326
|
+
html: string
|
|
327
|
+
/**
|
|
328
|
+
* Markup the renderer hoisted out of `html`, for `<head>`. Written as it is, without
|
|
329
|
+
* `data-gatsby-head` markers: the browser head sync never touches it.
|
|
330
|
+
*/
|
|
331
|
+
head: string
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** Exports of `runtime.server`. */
|
|
335
|
+
export interface RendererServer {
|
|
336
|
+
renderBody(
|
|
337
|
+
element: import("react").ReactNode,
|
|
338
|
+
options: { ignoreError(error: unknown): boolean },
|
|
339
|
+
): Promise<RenderedMarkup>
|
|
340
|
+
splitBody(html: string): RenderedMarkup
|
|
341
|
+
/**
|
|
342
|
+
* Portal head mode: the `Head` export. Core marks the head elements of `html` with
|
|
343
|
+
* `data-gatsby-head` (the head sync replaces them on navigation); `head` is for what the renderer
|
|
344
|
+
* keeps in `<head>` itself, e.g. stylesheets with a precedence.
|
|
345
|
+
*/
|
|
346
|
+
renderHead(element: import("react").ReactElement): RenderedMarkup
|
|
347
|
+
/**
|
|
348
|
+
* The document (`html.js`) as static markup. `element.props.body` is the page markup, which must
|
|
349
|
+
* appear in the output unchanged; the head placeholders core puts into `headComponents` must keep
|
|
350
|
+
* their exact markup. The result may start with a doctype.
|
|
351
|
+
*/
|
|
352
|
+
renderDocument(element: import("react").ReactElement): string
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** React 19's `onCaughtError` / `onUncaughtError` root option (`errorBoundary`: caught errors only). */
|
|
356
|
+
export type RootErrorHandler = (
|
|
357
|
+
error: unknown,
|
|
358
|
+
errorInfo: { componentStack?: string | null; errorBoundary?: unknown },
|
|
359
|
+
) => void
|
|
360
|
+
|
|
361
|
+
/** Exports of `runtime.client`. */
|
|
362
|
+
export interface RendererClient {
|
|
363
|
+
mount(
|
|
364
|
+
element: import("react").ReactElement,
|
|
365
|
+
container: Element,
|
|
366
|
+
options: {
|
|
367
|
+
/** `kind: "warning"` shows the issue as a warning in the develop hydration report */
|
|
368
|
+
onRecoverableError(
|
|
369
|
+
error: unknown,
|
|
370
|
+
info?: { componentStack?: string; kind?: "error" | "warning" },
|
|
371
|
+
): void
|
|
372
|
+
/**
|
|
373
|
+
* Root options for the `onCaughtError` / `onUncaughtError` browser APIs (hydration and an
|
|
374
|
+
* empty container). `undefined` when no plugin implements the API: keep the default reporting.
|
|
375
|
+
*/
|
|
376
|
+
onCaughtError?: RootErrorHandler
|
|
377
|
+
onUncaughtError?: RootErrorHandler
|
|
378
|
+
},
|
|
379
|
+
): void
|
|
380
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
export interface ActivityTracker {
|
|
2
|
+
start(): void
|
|
3
|
+
end(): void
|
|
4
|
+
done(): void
|
|
5
|
+
span: Record<string, unknown>
|
|
6
|
+
setStatus(status: string): void
|
|
7
|
+
panic(errorMeta: string | object, error?: object): never
|
|
8
|
+
panicOnBuild(errorMeta: string | object, error?: object): void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ProgressActivityTracker extends ActivityTracker {
|
|
12
|
+
tick(increment?: number): void
|
|
13
|
+
total: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ActivityArgs {
|
|
17
|
+
parentSpan?: object
|
|
18
|
+
id?: string
|
|
19
|
+
tags?: Record<string, unknown>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface Reporter {
|
|
23
|
+
stripIndent(strings: TemplateStringsArray | string, ...values: unknown[]): string
|
|
24
|
+
format: Record<string, (text: string) => string>
|
|
25
|
+
setVerbose(isVerbose?: boolean): void
|
|
26
|
+
setNoColor(noColor?: boolean): void
|
|
27
|
+
setErrorMap(
|
|
28
|
+
map: Record<
|
|
29
|
+
string,
|
|
30
|
+
{ text: (context: any) => string; level?: string; type?: string; category?: string }
|
|
31
|
+
>,
|
|
32
|
+
): void
|
|
33
|
+
panic(errorMeta: unknown, error?: unknown): never
|
|
34
|
+
panicOnBuild(errorMeta: unknown, error?: unknown): void
|
|
35
|
+
error(errorMeta: unknown, error?: unknown): void
|
|
36
|
+
uptime(prefix: string): void
|
|
37
|
+
verbose(text: string): void
|
|
38
|
+
success(text: string): void
|
|
39
|
+
info(text: string): void
|
|
40
|
+
warn(text: string): void
|
|
41
|
+
log(text?: string): void
|
|
42
|
+
/** a line with the breakdown of its time below it: a Gantt chart of the segments */
|
|
43
|
+
timingBreakdown(title: string, segments: TimingSegment[], level?: "info" | "success"): void
|
|
44
|
+
activityTimer(text: string, activityArgs?: ActivityArgs, pluginName?: string): ActivityTracker
|
|
45
|
+
phantomActivity(text: string, activityArgs?: ActivityArgs): ActivityTracker
|
|
46
|
+
createProgress(
|
|
47
|
+
text: string,
|
|
48
|
+
total?: number,
|
|
49
|
+
start?: number,
|
|
50
|
+
activityArgs?: ActivityArgs,
|
|
51
|
+
): ProgressActivityTracker
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type LogLevel = "error" | "warn" | "info" | "success" | "verbose" | "log"
|
|
55
|
+
|
|
56
|
+
/** Gatsby structured error details (see `reporter.error(errorMeta, error)`) */
|
|
57
|
+
export interface LogEntryError {
|
|
58
|
+
id?: string
|
|
59
|
+
category?: string
|
|
60
|
+
type?: string
|
|
61
|
+
level?: string
|
|
62
|
+
context?: Record<string, unknown>
|
|
63
|
+
filePath?: string
|
|
64
|
+
location?: unknown
|
|
65
|
+
pluginName?: string
|
|
66
|
+
message?: string
|
|
67
|
+
stack?: string
|
|
68
|
+
name?: string
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface ActivityInfo {
|
|
72
|
+
id: string
|
|
73
|
+
text: string
|
|
74
|
+
type: "spinner" | "progress"
|
|
75
|
+
status?: string
|
|
76
|
+
current?: number
|
|
77
|
+
total?: number
|
|
78
|
+
/** seconds since the activity started */
|
|
79
|
+
elapsed: number
|
|
80
|
+
outcome?: "success" | "failed"
|
|
81
|
+
/**
|
|
82
|
+
* the activity this one is a part of: a breakdown of the parent's time, reported after the parent
|
|
83
|
+
* ended (e.g. page queries and HTML rendering of the pipelined worker step)
|
|
84
|
+
*/
|
|
85
|
+
parentId?: string
|
|
86
|
+
/** parts: the fraction of the parent's time (0–1) */
|
|
87
|
+
share?: number
|
|
88
|
+
/** parts: the last part of the parent */
|
|
89
|
+
lastPart?: boolean
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface LogEntry {
|
|
93
|
+
level: LogLevel
|
|
94
|
+
/** the message without ANSI colors */
|
|
95
|
+
text: string
|
|
96
|
+
/** milliseconds since the epoch */
|
|
97
|
+
timestamp: number
|
|
98
|
+
error?: LogEntryError
|
|
99
|
+
/** success lines of finished activities */
|
|
100
|
+
activity?: ActivityInfo
|
|
101
|
+
/** worker thread id for entries logged in a worker thread */
|
|
102
|
+
threadId?: number
|
|
103
|
+
/** timing breakdowns (e.g. at the end of a build): the segments of the total time, in order */
|
|
104
|
+
breakdown?: { title: string; segments: TimingSegment[] }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** a segment of a timing breakdown */
|
|
108
|
+
export interface TimingSegment {
|
|
109
|
+
key: string
|
|
110
|
+
label: string
|
|
111
|
+
/** milliseconds */
|
|
112
|
+
ms: number
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface TimingBreakdownFormatOptions {
|
|
116
|
+
/** characters of the timeline (default: 40) */
|
|
117
|
+
width?: number
|
|
118
|
+
/** default: no colors */
|
|
119
|
+
colors?: boolean
|
|
120
|
+
/** the line the breakdown belongs to (default: "timing breakdown") */
|
|
121
|
+
title?: string
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Where reporter output goes. All methods but `log` are optional. */
|
|
125
|
+
export interface ReporterTransport {
|
|
126
|
+
log(entry: LogEntry): void
|
|
127
|
+
activityStart?(activity: ActivityInfo): void
|
|
128
|
+
activityUpdate?(activity: ActivityInfo): void
|
|
129
|
+
/** transports without it receive a `success` log entry with `activity` set */
|
|
130
|
+
activityEnd?(activity: ActivityInfo): void
|
|
131
|
+
flush?(): void | Promise<void>
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface ConsoleTransportOptions {
|
|
135
|
+
stdout?: NodeJS.WritableStream
|
|
136
|
+
stderr?: NodeJS.WritableStream
|
|
137
|
+
colors?: boolean
|
|
138
|
+
silent?: boolean
|
|
139
|
+
}
|
|
140
|
+
export interface JsonTransportOptions {
|
|
141
|
+
stream?: NodeJS.WritableStream
|
|
142
|
+
activityEvents?: boolean
|
|
143
|
+
}
|
|
144
|
+
export interface LoggerLike {
|
|
145
|
+
error: (...args: any[]) => unknown
|
|
146
|
+
warn: (...args: any[]) => unknown
|
|
147
|
+
info: (...args: any[]) => unknown
|
|
148
|
+
debug?: (...args: any[]) => unknown
|
|
149
|
+
verbose?: (...args: any[]) => unknown
|
|
150
|
+
[key: string]: unknown
|
|
151
|
+
}
|
|
152
|
+
export interface LoggerTransportOptions {
|
|
153
|
+
/** `logger.info(message, meta)` (winston, consola, console) or `logger.info(meta, message)` (pino, bunyan); detected by default */
|
|
154
|
+
style?: "message-first" | "object-first"
|
|
155
|
+
verboseLevel?: string
|
|
156
|
+
successLevel?: string
|
|
157
|
+
activityStarts?: boolean
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** Gatsby style console output (the default) */
|
|
161
|
+
export declare function consoleTransport(options?: ConsoleTransportOptions): ReporterTransport
|
|
162
|
+
/** one JSON object per line */
|
|
163
|
+
export declare function jsonTransport(options?: JsonTransportOptions): ReporterTransport
|
|
164
|
+
/** all output to an existing logger: winston, pino, bunyan, consola, console, … */
|
|
165
|
+
export declare function loggerTransport(
|
|
166
|
+
logger: LoggerLike,
|
|
167
|
+
options?: LoggerTransportOptions,
|
|
168
|
+
): ReporterTransport
|
|
169
|
+
export declare function activityEndText(activity: ActivityInfo): string
|
|
170
|
+
/** the segments as a Gantt chart: a row per segment with its time, share and bar on a timeline */
|
|
171
|
+
export declare function formatTimingBreakdown(
|
|
172
|
+
segments: TimingSegment[],
|
|
173
|
+
options?: TimingBreakdownFormatOptions,
|
|
174
|
+
): string
|
|
175
|
+
|
|
176
|
+
export interface ReporterControl {
|
|
177
|
+
/** replaces the transports (overrides `reporter` in gatsby-config) */
|
|
178
|
+
setTransports(transports: ReporterTransport | ReporterTransport[]): void
|
|
179
|
+
addTransport(transport: ReporterTransport): void
|
|
180
|
+
getTransports(): ReporterTransport[]
|
|
181
|
+
/** resolves when asynchronous transports wrote their output */
|
|
182
|
+
flush(): Promise<void>
|
|
183
|
+
isVerbose: boolean
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export declare const reporter: Reporter & ReporterControl
|
|
187
|
+
export default reporter
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type * as React from "react"
|
|
2
|
+
|
|
3
|
+
export interface HistoryLocation {
|
|
4
|
+
pathname: string
|
|
5
|
+
search: string
|
|
6
|
+
hash: string
|
|
7
|
+
href: string
|
|
8
|
+
origin: string
|
|
9
|
+
protocol: string
|
|
10
|
+
host: string
|
|
11
|
+
hostname: string
|
|
12
|
+
port: string
|
|
13
|
+
state: unknown
|
|
14
|
+
key: string
|
|
15
|
+
}
|
|
16
|
+
export type WindowLocation<S = unknown> = HistoryLocation & { state: S }
|
|
17
|
+
export interface NavigateOptions<TState = unknown> {
|
|
18
|
+
state?: TState
|
|
19
|
+
replace?: boolean
|
|
20
|
+
}
|
|
21
|
+
export type NavigateFn = (to: string | number, options?: NavigateOptions) => Promise<void>
|
|
22
|
+
|
|
23
|
+
export interface RouteComponentProps<TParams = {}> {
|
|
24
|
+
path?: string
|
|
25
|
+
default?: boolean
|
|
26
|
+
location?: WindowLocation
|
|
27
|
+
navigate?: NavigateFn
|
|
28
|
+
uri?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export declare function Router(
|
|
32
|
+
props: React.PropsWithChildren<{
|
|
33
|
+
basepath?: string
|
|
34
|
+
primary?: boolean
|
|
35
|
+
location?: WindowLocation
|
|
36
|
+
component?: any
|
|
37
|
+
[key: string]: unknown
|
|
38
|
+
}>,
|
|
39
|
+
): React.ReactElement | null
|
|
40
|
+
export declare function Link<TState = unknown>(
|
|
41
|
+
props: React.AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
42
|
+
to: string
|
|
43
|
+
state?: TState
|
|
44
|
+
replace?: boolean
|
|
45
|
+
getProps?: (props: {
|
|
46
|
+
isCurrent: boolean
|
|
47
|
+
isPartiallyCurrent: boolean
|
|
48
|
+
href: string
|
|
49
|
+
location: WindowLocation
|
|
50
|
+
}) => object | undefined
|
|
51
|
+
innerRef?: React.Ref<HTMLAnchorElement>
|
|
52
|
+
},
|
|
53
|
+
): React.ReactElement
|
|
54
|
+
export declare function Location(props: {
|
|
55
|
+
children: (ctx: { location: WindowLocation; navigate: NavigateFn }) => React.ReactNode
|
|
56
|
+
}): React.ReactElement
|
|
57
|
+
export declare function LocationProvider(
|
|
58
|
+
props: React.PropsWithChildren<{ history?: unknown }>,
|
|
59
|
+
): React.ReactElement
|
|
60
|
+
export declare function ServerLocation(
|
|
61
|
+
props: React.PropsWithChildren<{ url: string }>,
|
|
62
|
+
): React.ReactElement
|
|
63
|
+
export declare function Redirect(props: {
|
|
64
|
+
from?: string
|
|
65
|
+
to: string
|
|
66
|
+
noThrow?: boolean
|
|
67
|
+
state?: unknown
|
|
68
|
+
replace?: boolean
|
|
69
|
+
}): null
|
|
70
|
+
export declare function Match(props: {
|
|
71
|
+
path: string
|
|
72
|
+
children: (props: {
|
|
73
|
+
navigate: NavigateFn
|
|
74
|
+
location: WindowLocation
|
|
75
|
+
match: (Record<string, string> & { uri: string; path: string }) | null
|
|
76
|
+
}) => React.ReactNode
|
|
77
|
+
}): React.ReactElement
|
|
78
|
+
export declare const navigate: NavigateFn
|
|
79
|
+
export declare function useLocation(): WindowLocation
|
|
80
|
+
export declare function useNavigate(): NavigateFn
|
|
81
|
+
export declare function useParams(): Record<string, string> | null
|
|
82
|
+
export declare function useMatch(
|
|
83
|
+
path: string,
|
|
84
|
+
): (Record<string, string> & { uri: string; path: string }) | null
|
|
85
|
+
export declare function isRedirect(o: unknown): boolean
|
|
86
|
+
export declare function redirectTo(to: string): never
|
|
87
|
+
export declare const globalHistory: {
|
|
88
|
+
location: WindowLocation
|
|
89
|
+
navigate: NavigateFn
|
|
90
|
+
listen(listener: (e: { location: WindowLocation; action: string }) => void): () => void
|
|
91
|
+
}
|
|
92
|
+
export declare function createHistory(source: unknown): typeof globalHistory
|
|
93
|
+
export declare function createMemorySource(initialPath?: string): unknown
|
|
94
|
+
export declare function match(
|
|
95
|
+
path: string,
|
|
96
|
+
uri: string,
|
|
97
|
+
): { route: { path: string }; params: Record<string, string>; uri: string } | null
|
|
98
|
+
export declare const LocationContext: React.Context<{
|
|
99
|
+
location: WindowLocation
|
|
100
|
+
navigate: NavigateFn
|
|
101
|
+
}>
|
|
102
|
+
export declare const BaseContext: React.Context<{ baseuri: string; basepath: string }>
|