@inglorious/ssx 1.3.4 → 1.3.5

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.
Files changed (2) hide show
  1. package/package.json +3 -2
  2. package/types/index.d.ts +280 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/ssx",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Server-Side-X. Xecution? Xperience? Who knows.",
5
5
  "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -26,11 +26,12 @@
26
26
  "ssx": "./bin/ssx.js"
27
27
  },
28
28
  "exports": {
29
- "./site.config": "./types/site.config.d.ts"
29
+ ".": "./types/site.config.d.ts"
30
30
  },
31
31
  "files": [
32
32
  "bin",
33
33
  "src",
34
+ "types",
34
35
  "!src/**/__fixtures__",
35
36
  "!src/**/__snapshots__"
36
37
  ],
@@ -0,0 +1,280 @@
1
+ /**
2
+ * Represents a page being built or processed.
3
+ */
4
+ export interface Page {
5
+ /**
6
+ * The final URL path for the page (e.g., "/about").
7
+ */
8
+ path: string
9
+ /**
10
+ * The route pattern that matched this page (e.g., "/posts/:id").
11
+ */
12
+ pattern: string
13
+ /**
14
+ * The absolute file path to the source component.
15
+ */
16
+ filePath: string
17
+ [key: string]: any
18
+ }
19
+
20
+ /**
21
+ * Options passed to the layout function.
22
+ */
23
+ export interface LayoutOptions {
24
+ /**
25
+ * The language attribute for the <html> tag.
26
+ */
27
+ lang?: string
28
+ /**
29
+ * The character encoding.
30
+ */
31
+ charset?: string
32
+ /**
33
+ * The page title.
34
+ */
35
+ title?: string
36
+ /**
37
+ * Meta tags to include in <head>.
38
+ */
39
+ meta?: Record<string, string>
40
+ /**
41
+ * Stylesheets to include.
42
+ */
43
+ styles?: string[]
44
+ /**
45
+ * Additional HTML to inject into <head>.
46
+ */
47
+ head?: string
48
+ /**
49
+ * Scripts to include.
50
+ */
51
+ scripts?: string[]
52
+ /**
53
+ * Whether the build is running in development mode.
54
+ */
55
+ isDev?: boolean
56
+ [key: string]: any
57
+ }
58
+
59
+ /**
60
+ * Configuration for the sitemap generation.
61
+ */
62
+ export interface SitemapConfig {
63
+ /**
64
+ * The base hostname for the sitemap URLs (e.g., "https://example.com").
65
+ */
66
+ hostname: string
67
+ /**
68
+ * A function to filter which pages are included in the sitemap.
69
+ */
70
+ filter?: (page: Page) => boolean
71
+ /**
72
+ * Default values for sitemap entries.
73
+ */
74
+ defaults?: {
75
+ /**
76
+ * How frequently the page is likely to change.
77
+ */
78
+ changefreq?: string
79
+ /**
80
+ * The priority of this URL relative to other URLs on your site.
81
+ */
82
+ priority?: number
83
+ /**
84
+ * The date of last modification.
85
+ */
86
+ lastmod?: string | Date
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Configuration for the RSS feed generation.
92
+ */
93
+ export interface RssConfig {
94
+ /**
95
+ * The title of the RSS feed.
96
+ */
97
+ title: string
98
+ /**
99
+ * The description of the RSS feed.
100
+ */
101
+ description: string
102
+ /**
103
+ * The link to the site associated with the feed.
104
+ */
105
+ link: string
106
+ /**
107
+ * The output path for the RSS feed file.
108
+ * @default "/feed.xml"
109
+ */
110
+ feedPath?: string
111
+ /**
112
+ * The language of the feed.
113
+ */
114
+ language?: string
115
+ /**
116
+ * Copyright notice for content in the feed.
117
+ */
118
+ copyright?: string
119
+ /**
120
+ * Maximum number of items to include in the feed.
121
+ */
122
+ maxItems?: number
123
+ /**
124
+ * A function to filter which pages are included in the feed.
125
+ */
126
+ filter?: (page: Page) => boolean
127
+ }
128
+
129
+ /**
130
+ * Configuration for a URL redirect.
131
+ */
132
+ export interface RedirectConfig {
133
+ /**
134
+ * The source path or pattern to redirect from.
135
+ */
136
+ from: string
137
+ /**
138
+ * The destination path to redirect to.
139
+ */
140
+ to: string
141
+ /**
142
+ * The HTTP status code for the redirect.
143
+ * @default 301
144
+ */
145
+ status?: number
146
+ }
147
+
148
+ /**
149
+ * Configuration for the client-side router.
150
+ */
151
+ export interface RouterConfig {
152
+ /**
153
+ * Whether to enforce trailing slashes on URLs.
154
+ */
155
+ trailingSlash?: boolean
156
+ /**
157
+ * The scroll behavior when navigating between pages.
158
+ */
159
+ scrollBehavior?: "auto" | "smooth"
160
+ }
161
+
162
+ /**
163
+ * Result object passed to the afterBuild hook.
164
+ */
165
+ export interface BuildResult {
166
+ /**
167
+ * The total number of pages generated.
168
+ */
169
+ pages: number
170
+ [key: string]: any
171
+ }
172
+
173
+ /**
174
+ * Lifecycle hooks for the build process.
175
+ */
176
+ export interface SSXHooks {
177
+ /**
178
+ * Called before the build process starts.
179
+ */
180
+ beforeBuild?: (config: SiteConfig) => Promise<void> | void
181
+ /**
182
+ * Called after the build process completes.
183
+ */
184
+ afterBuild?: (result: BuildResult) => Promise<void> | void
185
+ /**
186
+ * Called after an individual page is built.
187
+ */
188
+ onPageBuild?: (page: Page) => Promise<void> | void
189
+ }
190
+
191
+ /**
192
+ * Main configuration object for SSX.
193
+ */
194
+ export interface SiteConfig {
195
+ /**
196
+ * The language attribute for the <html> tag.
197
+ * @default "en"
198
+ */
199
+ lang?: string
200
+ /**
201
+ * The character encoding for the site.
202
+ * @default "UTF-8"
203
+ */
204
+ charset?: string
205
+ /**
206
+ * The default title for pages.
207
+ */
208
+ title?: string
209
+ /**
210
+ * Default meta tags to be applied to all pages.
211
+ * Keys are meta names/properties, values are content.
212
+ */
213
+ meta?: Record<string, string>
214
+ /**
215
+ * List of CSS file paths or URLs to include globally.
216
+ */
217
+ styles?: string[]
218
+ /**
219
+ * List of JavaScript file paths or URLs to include globally.
220
+ */
221
+ scripts?: string[]
222
+ /**
223
+ * A function that renders the full HTML document structure.
224
+ * Receives the page body and options.
225
+ */
226
+ layout?: (body: string, options: LayoutOptions) => string
227
+ /**
228
+ * A function to wrap the page content before layout.
229
+ * Useful for adding common UI elements like headers/footers around the content.
230
+ */
231
+ wrapper?: (body: any) => any
232
+ /**
233
+ * The base URL path for the application.
234
+ * @default "/"
235
+ */
236
+ basePath?: string
237
+ /**
238
+ * The directory containing source files.
239
+ * @default "src"
240
+ */
241
+ rootDir?: string
242
+ /**
243
+ * The directory where build artifacts will be output.
244
+ * @default "dist"
245
+ */
246
+ outDir?: string
247
+ /**
248
+ * The directory containing static assets to be copied to the output.
249
+ * @default "public"
250
+ */
251
+ publicDir?: string
252
+ /**
253
+ * Path to the favicon file.
254
+ */
255
+ favicon?: string
256
+ /**
257
+ * Configuration for generating a sitemap.xml.
258
+ */
259
+ sitemap?: SitemapConfig
260
+ /**
261
+ * Configuration for generating an RSS feed.
262
+ */
263
+ rss?: RssConfig
264
+ /**
265
+ * List of redirect rules.
266
+ */
267
+ redirects?: RedirectConfig[]
268
+ /**
269
+ * Configuration for the client-side router.
270
+ */
271
+ router?: RouterConfig
272
+ /**
273
+ * Configuration options passed directly to Vite.
274
+ */
275
+ vite?: Record<string, any>
276
+ /**
277
+ * Lifecycle hooks for the build process.
278
+ */
279
+ hooks?: SSXHooks
280
+ }