@small-web/kitten-types 1.0.0 → 1.0.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/CHANGELOG.md +9 -2
- package/global.d.ts +795 -27
- package/index.d.ts +9 -13
- package/package.json +2 -2
- package/types.d.ts +195 -87
package/global.d.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
// The `KittenGlobal` interface is the single, hand-written source of truth for
|
|
8
|
-
// the global namespace shape (previously reconstructed from runtime casts in
|
|
9
|
-
// `@small-web/kitten`’s `globals.js`).
|
|
1
|
+
/**
|
|
2
|
+
Kitten Types (@small-web/kitten-types)
|
|
3
|
+
|
|
4
|
+
Type declarations for global `kitten` namespace.
|
|
5
|
+
*/
|
|
10
6
|
|
|
11
7
|
import type { EventEmitter } from 'node:events'
|
|
12
8
|
import type { Server } from 'node:https'
|
|
@@ -27,23 +23,32 @@ import type {
|
|
|
27
23
|
|
|
28
24
|
import type { KittenIcons } from 'kitten-icons/types.d.ts'
|
|
29
25
|
|
|
30
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
Tagged template function (e.g. `kitten.html`, `kitten.css`).
|
|
28
|
+
*/
|
|
31
29
|
export type TaggedTemplate = (
|
|
32
30
|
strings: TemplateStringsArray,
|
|
33
31
|
...properties: any[]
|
|
34
32
|
) => string | Array<string> | Promise<string | Array<string>>
|
|
35
33
|
|
|
36
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
Sanitisation helper (e.g. `kitten.safelyAddHtml`, `kitten.sanitise`).
|
|
36
|
+
*/
|
|
37
37
|
export type SanitisationFunction = (
|
|
38
38
|
untrustedContent: string,
|
|
39
39
|
allowedTags?: Array<string>,
|
|
40
40
|
contact?: boolean
|
|
41
41
|
) => string
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
Record that maps URL fragments to hit counts.
|
|
45
|
+
*/
|
|
43
46
|
type StatsObject = Record<string, number>
|
|
44
47
|
|
|
45
|
-
/**
|
|
46
|
-
|
|
48
|
+
/**
|
|
49
|
+
Internal Kitten database (`kitten._db`).
|
|
50
|
+
*/
|
|
51
|
+
export interface KittenInternalDatabase {
|
|
47
52
|
sessions: Record<string, Session>
|
|
48
53
|
settings: {
|
|
49
54
|
autoUpdate: {
|
|
@@ -77,7 +82,9 @@ export interface KittenInternalDb {
|
|
|
77
82
|
uploads: Record<string, Upload>
|
|
78
83
|
}
|
|
79
84
|
|
|
80
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
The `kitten.uploads` store.
|
|
87
|
+
*/
|
|
81
88
|
export type UploadStore = {
|
|
82
89
|
get(id: string): Upload
|
|
83
90
|
length(): number
|
|
@@ -86,6 +93,9 @@ export type UploadStore = {
|
|
|
86
93
|
delete(id: string): Promise<void>
|
|
87
94
|
} & Record<string, Upload>
|
|
88
95
|
|
|
96
|
+
/**
|
|
97
|
+
Configuration options for the Kitten server.
|
|
98
|
+
*/
|
|
89
99
|
interface ServerOptions {
|
|
90
100
|
domain?: string
|
|
91
101
|
port?: number
|
|
@@ -97,9 +107,12 @@ interface ServerOptions {
|
|
|
97
107
|
}
|
|
98
108
|
|
|
99
109
|
/**
|
|
100
|
-
|
|
110
|
+
Global `kitten` namespace.
|
|
101
111
|
*/
|
|
102
|
-
export interface
|
|
112
|
+
export interface kitten {
|
|
113
|
+
/**
|
|
114
|
+
Kitten’s version number and releated utilities.
|
|
115
|
+
*/
|
|
103
116
|
version: {
|
|
104
117
|
date: Date
|
|
105
118
|
versionStamp: number
|
|
@@ -114,30 +127,90 @@ export interface KittenGlobal {
|
|
|
114
127
|
printToConsole: () => void
|
|
115
128
|
}
|
|
116
129
|
|
|
130
|
+
/**
|
|
131
|
+
The Kitten app.
|
|
132
|
+
|
|
133
|
+
Includes references to the Kitten router (Polka) and server as well as the Kitten package (in deployed servers).
|
|
134
|
+
*/
|
|
117
135
|
app: {
|
|
136
|
+
/** The parsed package.json file for the current Kitten app (if any). */
|
|
118
137
|
package?: any
|
|
119
138
|
router: Polka
|
|
120
139
|
server: Server
|
|
121
140
|
}
|
|
122
141
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
142
|
+
/**
|
|
143
|
+
This is your custom JSDB database.
|
|
144
|
+
|
|
145
|
+
If you want type safety for it, create a database app module in your project and declare the types there.
|
|
146
|
+
|
|
147
|
+
@see https://codeberg.org/kitten/app#database-app-module
|
|
148
|
+
*/
|
|
126
149
|
db: any
|
|
127
150
|
|
|
128
|
-
|
|
151
|
+
/**
|
|
152
|
+
Kitten’s internal database.
|
|
153
|
+
|
|
154
|
+
You should not need to access this directly.
|
|
155
|
+
*/
|
|
156
|
+
_db: KittenInternalDatabase
|
|
129
157
|
|
|
158
|
+
/**
|
|
159
|
+
Represents an uploaded file.
|
|
160
|
+
|
|
161
|
+
@see https://kitten.small-web.org/tutorials/multipart-forms-and-file-uploads/
|
|
162
|
+
*/
|
|
130
163
|
Upload: typeof Upload
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
Uploads sent to `POST` routes via `<input type='file'>` in your pages are automatically saved in your project’s uploads folder. Kitten also automatically assigns them unique IDs, maps to IDs to their locations on disk in its internal database (`kitten._db.uploads`), and serves them from the `/uploads/<unique-id>` route.
|
|
167
|
+
|
|
168
|
+
You can access uploads by ID from this global reference (which, itself, is simply a reference to `kitten._db.uploads`).
|
|
169
|
+
|
|
170
|
+
The Upload objects are also available to your `POST` routes in the `request.uploads` array.
|
|
171
|
+
|
|
172
|
+
@see https://kitten.small-web.org/tutorials/multipart-forms-and-file-uploads/
|
|
173
|
+
*/
|
|
131
174
|
uploads: UploadStore
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
Kitten’s built-in icon set.
|
|
178
|
+
|
|
179
|
+
A subset of the Phosphor icon set by Helena Zhang and Tobias Fried as Kitten components.
|
|
180
|
+
|
|
181
|
+
@example
|
|
182
|
+
export default () => kitten.html`
|
|
183
|
+
<h1>I’m a cat! <${kitten.icons.Cat} /></h1>
|
|
184
|
+
`
|
|
185
|
+
|
|
186
|
+
@see
|
|
187
|
+
https://kitten.small-web.org/reference/#icons
|
|
188
|
+
*/
|
|
132
189
|
icons: KittenIcons
|
|
133
190
|
|
|
191
|
+
/**
|
|
192
|
+
The domain or Web Number (IP Address) Kitten is running at.
|
|
193
|
+
*/
|
|
134
194
|
domain: string
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
The port number Kitten is running at.
|
|
198
|
+
*/
|
|
135
199
|
port: number
|
|
136
200
|
|
|
137
|
-
|
|
201
|
+
/**
|
|
202
|
+
The unique identifier for this Kitten site/app, calculated using the base path of the source code as well as the domain and port the server is running on.
|
|
203
|
+
*/
|
|
138
204
|
projectIdentifier: string
|
|
139
205
|
|
|
140
|
-
|
|
206
|
+
/**
|
|
207
|
+
Represents the git repository of the app that Kitten is currently serving.
|
|
208
|
+
|
|
209
|
+
Available in production mode only (when Kitten is run with PRODUCTION=true).
|
|
210
|
+
|
|
211
|
+
@remarks For internal use only.
|
|
212
|
+
*/
|
|
213
|
+
appRepository?: {
|
|
141
214
|
upgradeAppToLatestCompatibleVersion(): Promise<void>
|
|
142
215
|
upgradeAppToLatestAvailableCommit(): Promise<void>
|
|
143
216
|
updateAppToVersion(versionTag: string): Promise<void>
|
|
@@ -154,7 +227,14 @@ export interface KittenGlobal {
|
|
|
154
227
|
displayAppVersion(): void
|
|
155
228
|
}
|
|
156
229
|
|
|
157
|
-
|
|
230
|
+
/**
|
|
231
|
+
Schedules and runs automatic updates of both Kitten itself and the app that Kitten is running.
|
|
232
|
+
|
|
233
|
+
Available in production mode only (when Kitten is run with PRODUCTION=true).
|
|
234
|
+
|
|
235
|
+
@remarks For internal use only.
|
|
236
|
+
*/
|
|
237
|
+
automaticUpdates?: {
|
|
158
238
|
interval: number
|
|
159
239
|
intervalInHours: number
|
|
160
240
|
timeToNextCheck(): number
|
|
@@ -164,9 +244,15 @@ export interface KittenGlobal {
|
|
|
164
244
|
stop(): void
|
|
165
245
|
}
|
|
166
246
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
247
|
+
/**
|
|
248
|
+
Represents the currently-installed Kitten package.
|
|
249
|
+
|
|
250
|
+
Provides information about and manages updates of the package by communicating with Kitten’s deployment site (https://kittens.small-web.org).
|
|
251
|
+
|
|
252
|
+
_Note that this class does NOT manage automatic updates. For that, please see the {@link AutomaticUpdates} class._
|
|
253
|
+
|
|
254
|
+
@remarks For internal use only.
|
|
255
|
+
*/
|
|
170
256
|
package: {
|
|
171
257
|
hasCompatibleVersion: boolean
|
|
172
258
|
isLatestReleaseVersion: boolean
|
|
@@ -176,36 +262,307 @@ export interface KittenGlobal {
|
|
|
176
262
|
update(): Promise<void>
|
|
177
263
|
}
|
|
178
264
|
|
|
265
|
+
/**
|
|
266
|
+
A truncated log of the last 25 request URLs for debugging purposes.
|
|
267
|
+
*/
|
|
179
268
|
requests: Array<string>
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
Record of all active KittenPage instances, keyed by page ID (UUID).
|
|
272
|
+
*/
|
|
180
273
|
pages: Record<string, KittenPage>
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
Global Kitten event emitter.
|
|
277
|
+
*/
|
|
181
278
|
events: EventEmitter
|
|
182
279
|
|
|
280
|
+
/**
|
|
281
|
+
KittenComponent class.
|
|
282
|
+
|
|
283
|
+
Extend this class to create your own stateful Kitten components.
|
|
284
|
+
|
|
285
|
+
@example
|
|
286
|
+
export default class MyComponent extends kitten.Component {
|
|
287
|
+
override html () {
|
|
288
|
+
return kitten.html`
|
|
289
|
+
What a lovely component I am! :)
|
|
290
|
+
`
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
*/
|
|
183
294
|
Component: typeof KittenComponent
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
KittenPage class.
|
|
298
|
+
|
|
299
|
+
Extend this class to create your custom stateful Kitten pages.
|
|
300
|
+
|
|
301
|
+
@example
|
|
302
|
+
export default class MyPage extends kitten.Page {
|
|
303
|
+
override html () {
|
|
304
|
+
return kitten.html`
|
|
305
|
+
I am a KittenPage, short and sweet!
|
|
306
|
+
`
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
*/
|
|
184
310
|
Page: typeof KittenPage
|
|
185
311
|
|
|
312
|
+
/**
|
|
313
|
+
Kitten HTML tagged template string with support for Kitten components and JavaScript string interpolation.
|
|
314
|
+
|
|
315
|
+
This is the primary means of authoring HTML in Kitten.
|
|
316
|
+
|
|
317
|
+
@example
|
|
318
|
+
// A simple Kitten page (e.g., index.page.js) that says “Happy <month name>!” and uses the built-in kitten.icons.Smiley Kitten component to display a smiley.
|
|
319
|
+
export default function () {
|
|
320
|
+
const currentMonth = new Intl.DateTimeFormat('en-IE', { month: 'long' }).format(new Date())
|
|
321
|
+
return kitten.html`
|
|
322
|
+
<h1>Happy ${currentMonth}! <${kitten.icons.Smiley} /></h1>
|
|
323
|
+
`
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
@see https://kitten.small-web.org/reference/#html
|
|
327
|
+
*/
|
|
186
328
|
html: TaggedTemplate
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
CSS tagged template.
|
|
332
|
+
|
|
333
|
+
Wraps passed string in `<style>…</style>` tags.
|
|
334
|
+
|
|
335
|
+
Useful if you want to use JavaScript variables in your CSS.
|
|
336
|
+
|
|
337
|
+
@example
|
|
338
|
+
const randomColour = ['red', 'green', 'blue'][Math.floor(Math.random()*3)]
|
|
339
|
+
const css = kitten.css`body { background-color: ${randomColour} }`
|
|
340
|
+
|
|
341
|
+
@see To include external static CSS, use CSS fragments (_.fragment.css_ files) instead. https://kitten.small-web.org/tutorials/components-and-fragments/#html-css-and-markdown-fragments
|
|
342
|
+
*/
|
|
187
343
|
css: TaggedTemplate
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
JS tagged template. This is a basic function that simply attaches its input to the page
|
|
347
|
+
without any escaping. It can be used to get language intelligence/syntax highlighting
|
|
348
|
+
for Alpine.js snippets in your editor (if your editor and/or language server understands
|
|
349
|
+
to display kitten.js`` tagged templates as JavaScript).
|
|
350
|
+
|
|
351
|
+
Be careful if using this as you will have to escape backticks in your code and it
|
|
352
|
+
can make your code harder to read and understand for other people.
|
|
353
|
+
|
|
354
|
+
Use for simple things only.
|
|
355
|
+
|
|
356
|
+
@param {string[]} strings - Static strings.
|
|
357
|
+
@param {[]} interpolations - Interpolated values.
|
|
358
|
+
*/
|
|
188
359
|
js: TaggedTemplate
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
Markdown wrapper.
|
|
363
|
+
|
|
364
|
+
Results in exactly the same thing as `` kitten.html`<markdown>…</markdown>` `` but without
|
|
365
|
+
requiring you to add the markdown tags. In a lot of ways more limited than just
|
|
366
|
+
using ``` kitten.html`` ``` with markdown tags inside it but might be nicer semantically in
|
|
367
|
+
certain cases.
|
|
368
|
+
|
|
369
|
+
@see https://kitten.small-web.org/reference/#markdown-support
|
|
370
|
+
*/
|
|
189
371
|
markdown: TaggedTemplate
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
Reference to the MarkdownIt instance used internally by Kitten.
|
|
375
|
+
|
|
376
|
+
Use `kitten.md.render()` and `kitten.md.renderInline()` if you need more flexibility than what the other Markdown features in Kitten allow.
|
|
377
|
+
|
|
378
|
+
@example
|
|
379
|
+
<!-- Safely display comments on a blog that contain Markdown syntax. -->
|
|
380
|
+
<ul>
|
|
381
|
+
${kitten.db.comments.map(comment => kitten.html`
|
|
382
|
+
<li>
|
|
383
|
+
<p>${kitten.safelyAddHtml(kitten.md.render(comment.message))}</p>
|
|
384
|
+
<p class='nameAndDate'>${comment.name} (${new Date(comment.date).toLocaleString()})</p>
|
|
385
|
+
</li>
|
|
386
|
+
`)}
|
|
387
|
+
</ul>
|
|
388
|
+
*/
|
|
190
389
|
md: MarkdownIt
|
|
191
390
|
|
|
391
|
+
/**
|
|
392
|
+
Slugify a string.
|
|
393
|
+
|
|
394
|
+
@example
|
|
395
|
+
kitten.slugify('I ♥ Dogs') // i-love-dogs
|
|
396
|
+
|
|
397
|
+
@see https://github.com/sindresorhus/slugify
|
|
398
|
+
*/
|
|
192
399
|
slugify: typeof Slugify
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
YAML parser and serialiser.
|
|
403
|
+
|
|
404
|
+
Used internally by the Markdown loader for parsing YAML frontmatter but also exposed here for you to use in your own apps.
|
|
405
|
+
|
|
406
|
+
@example
|
|
407
|
+
kitten.yaml.parse(`
|
|
408
|
+
YAML:
|
|
409
|
+
- A human-readable data serialization language
|
|
410
|
+
- https://en.wikipedia.org/wiki/YAML
|
|
411
|
+
`)
|
|
412
|
+
|
|
413
|
+
@see https://github.com/eemeli/yaml
|
|
414
|
+
*/
|
|
193
415
|
yaml: typeof Yaml
|
|
194
416
|
|
|
417
|
+
/**
|
|
418
|
+
Kitten Crypto API
|
|
419
|
+
|
|
420
|
+
Crypographic functions used by Kitten and available for you to use in your own apps.
|
|
421
|
+
|
|
422
|
+
Remember that secrets that belong to people should only be handled on the client. The exact same API is available to use in the browser.
|
|
423
|
+
|
|
424
|
+
@example
|
|
425
|
+
// Client side use
|
|
426
|
+
<script type='module' async>
|
|
427
|
+
import { createKeys } from '/🐱/library/crypto-1.js'
|
|
428
|
+
|
|
429
|
+
async function generateSecret(event, secretView, copySecretButtonPlaceholder) {
|
|
430
|
+
const keys = await createKeys('${domain}')
|
|
431
|
+
const secret = keys.private.ed25519.asString
|
|
432
|
+
}
|
|
433
|
+
</script>
|
|
434
|
+
*/
|
|
195
435
|
crypto: {
|
|
436
|
+
/**
|
|
437
|
+
Converts Uint8Array to hex string.
|
|
438
|
+
|
|
439
|
+
From @noble/hashes.
|
|
440
|
+
|
|
441
|
+
@see https://github.com/paulmillr/noble-hashes#utils
|
|
442
|
+
*/
|
|
196
443
|
bytesToHex: (uint8a: Uint8Array) => string
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
Decrypts passed encoded ciphertext using shared key.
|
|
447
|
+
|
|
448
|
+
From micro-aes-gcm.
|
|
449
|
+
|
|
450
|
+
@see https://www.npmjs.com/package/micro-aes-gcm
|
|
451
|
+
*/
|
|
197
452
|
decrypt: (sharedKey: Uint8Array, encoded: string | Uint8Array) => Uint8Array
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
Convert emoji string to secret bytes.
|
|
456
|
+
|
|
457
|
+
@see https://kitten.small-web.org/reference/#cryptographic-properties
|
|
458
|
+
*/
|
|
198
459
|
emojiStringToSecret: (emojiString: string) => Uint8Array
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
Encrypts passed plain text using the shared key.
|
|
463
|
+
|
|
464
|
+
From micro-aes-gcm.
|
|
465
|
+
|
|
466
|
+
@see https://www.npmjs.com/package/micro-aes-gcm
|
|
467
|
+
*/
|
|
199
468
|
encrypt: (sharedKey: Uint8Array, plaintext: string | Uint8Array) => Uint8Array
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
Encrypts a message for a domain.
|
|
472
|
+
|
|
473
|
+
@param message Message to encrypt
|
|
474
|
+
@param ourPrivateKey Our emoji-encoded private key
|
|
475
|
+
@param domain The domain to encrypt the message for
|
|
476
|
+
@returns Hex-encoded encrypted message.
|
|
477
|
+
|
|
478
|
+
@remarks While this function can be used on the server, all encryption should be carried out on the client as the server should never have person’s secrets.
|
|
479
|
+
*/
|
|
480
|
+
encryptMessageForDomain: (message: string, ourPrivateKey: string, domain: string) => Promise<string>
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
Converts ed25519 private / public keys to Curve25519 and calculates Elliptic Curve Diffie Hellman (ECDH) with X25519. Conforms to RFC7748.
|
|
484
|
+
|
|
485
|
+
From `@noble/ed25519` (v1).
|
|
486
|
+
|
|
487
|
+
@see https://github.com/paulmillr/noble-ed25519/tree/v1#getsharedsecretprivatekey-publickey
|
|
488
|
+
*/
|
|
200
489
|
getSharedSecret: (
|
|
201
490
|
privateKey: Uint8Array | string | bigint | number,
|
|
202
491
|
publicKey: Uint8Array | string
|
|
203
492
|
) => Promise<Uint8Array>
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
Converts hex string to Uint8Array .
|
|
496
|
+
|
|
497
|
+
From `@noble/hashes`.
|
|
498
|
+
|
|
499
|
+
@see https://github.com/paulmillr/noble-hashes#usage
|
|
500
|
+
*/
|
|
204
501
|
hexToBytes: (hex: string) => Uint8Array
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
Produces cryptographically secure random Uint8Array of length bytes.
|
|
505
|
+
|
|
506
|
+
From `@noble/hashes`.
|
|
507
|
+
|
|
508
|
+
@see https://github.com/paulmillr/noble-hashes#utils
|
|
509
|
+
*/
|
|
205
510
|
randomBytes: (bytesLength?: number) => Uint8Array
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
Generates cryptographically random 32-byte token and coverts it to hexadecimal representation.
|
|
514
|
+
|
|
515
|
+
Use anywhere you need a secret token (domain token, webhook secret, etc.)
|
|
516
|
+
*/
|
|
206
517
|
random32ByteTokenInHex: () => string
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
Convert secret bytes to emoji string.
|
|
521
|
+
|
|
522
|
+
@see https://kitten.small-web.org/reference/#cryptographic-properties
|
|
523
|
+
*/
|
|
207
524
|
secretToEmojiString: (secret: Uint8Array) => string
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
Calculates the shared secret for a domain using the domain’s public key and our private key.
|
|
528
|
+
|
|
529
|
+
Part of the Meow Protocol.
|
|
530
|
+
*/
|
|
531
|
+
sharedSecretForDomain: (domain: string, ourPrivateKey: string) => Promise<Uint8Array>
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
Signs message with privatek key and returns EdDSA signature.
|
|
535
|
+
|
|
536
|
+
From `@noble/ed25519` (v1).
|
|
537
|
+
|
|
538
|
+
@param message Message (not message hash) which would be signed
|
|
539
|
+
@param privateKey Private key which will sign the hash
|
|
540
|
+
@returns EdDSA signature. You can consume it with the `Signature.fromHex()` method: `Signature.fromHex(ed25519.sign(hash, privateKey))`
|
|
541
|
+
|
|
542
|
+
@see https://github.com/paulmillr/noble-ed25519/tree/v1#signmessage-privatekey
|
|
543
|
+
*/
|
|
208
544
|
sign: (message: Uint8Array | string, privateKey: Uint8Array | string) => Promise<Uint8Array>
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
Verifies signature.
|
|
548
|
+
|
|
549
|
+
From `@noble/ed25519` (v1).
|
|
550
|
+
|
|
551
|
+
Compatible with [ZIP215](https://zips.z.cash/zip-0215), accepts:
|
|
552
|
+
|
|
553
|
+
```
|
|
554
|
+
0 <= sig.R/publicKey < 2**256 (can be >= curve.P aka non-canonical encoding)
|
|
555
|
+
0 <= sig.s < l
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
@param sig Signature returned by {@link sign} function
|
|
559
|
+
@param message Message to be verified
|
|
560
|
+
@param publicKey Public key (e.g., as generated from privateKey using it’s getPublicKey method)
|
|
561
|
+
|
|
562
|
+
@see https://github.com/paulmillr/noble-ed25519/tree/v1#verifysignature-message-publickey
|
|
563
|
+
|
|
564
|
+
@remarks Not compatible with RFC8032 because rfc encorces canonical encoding of R/publicKey. There is no security risk in ZIP behavior, and there is no effect on honestly generated signatures. For additional info about verification strictness, check out It’s [255:19AM](https://hdevalence.ca/blog/2020-10-04-its-25519am/).
|
|
565
|
+
*/
|
|
209
566
|
verify: (
|
|
210
567
|
sig: Uint8Array | string | Signature,
|
|
211
568
|
message: Uint8Array | string,
|
|
@@ -213,22 +570,123 @@ export interface KittenGlobal {
|
|
|
213
570
|
) => Promise<boolean>
|
|
214
571
|
}
|
|
215
572
|
|
|
573
|
+
/**
|
|
574
|
+
Kitten utility functions and properties.
|
|
575
|
+
*/
|
|
216
576
|
utils: {
|
|
577
|
+
/**
|
|
578
|
+
Currently contains the same extensions as in {@link DYNAMIC_ROUTE_EXTENSIONS}.
|
|
579
|
+
*/
|
|
217
580
|
ALL_ROUTE_EXTENSIONS: Array<string>
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
Extensions that Kitten treats as backend routes.
|
|
584
|
+
|
|
585
|
+
Currently: `socket.js` and `socket.ts`.
|
|
586
|
+
|
|
587
|
+
@see https://kitten.small-web.org/tutorials/htmx-the-htmx-web-socket-extension-and-socket-routes/
|
|
588
|
+
*/
|
|
218
589
|
BACKEND_EXTENSIONS: Array<string>
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
Extensions that don’t map to routes but are elements that can be imported and used in routes.
|
|
593
|
+
|
|
594
|
+
@example
|
|
595
|
+
`component.js`, `component.ts`, `fragment.html`, `fragment.css`, `layout.js`, `layout.ts`
|
|
596
|
+
|
|
597
|
+
@see https://kitten.small-web.org/tutorials/components-and-fragments/
|
|
598
|
+
*/
|
|
219
599
|
DEPENDENCY_EXTENSIONS: Array<string>
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
File extensions Kitten considers to be dynamic (not static) routes.
|
|
603
|
+
|
|
604
|
+
Currently, this includes all extensions in {@link BACKEND_EXTENSIONS} and {@link FRONTEND_EXTENSIONS}.
|
|
605
|
+
*/
|
|
220
606
|
DYNAMIC_ROUTE_EXTENSIONS: Array<string>
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
Extensions for files that hold front-end functionality.
|
|
610
|
+
|
|
611
|
+
Currently: `page.js`, `page.ts`, and `page.md`.
|
|
612
|
+
|
|
613
|
+
@remarks For internal use only.
|
|
614
|
+
*/
|
|
221
615
|
FRONTEND_EXTENSIONS: Array<string>
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
Extensions Kitten maps to standard HTTP routes.
|
|
619
|
+
|
|
620
|
+
@example
|
|
621
|
+
`get.js`, `post.js`, `put.js`, `head.js`, etc.
|
|
622
|
+
|
|
623
|
+
@see https://kitten.small-web.org/reference/#http-routes
|
|
624
|
+
|
|
625
|
+
@remarks For internal use only.
|
|
626
|
+
*/
|
|
222
627
|
HTTP_METHODS: Array<string>
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
File extensions that that Kitten treats as static files.
|
|
631
|
+
|
|
632
|
+
Currently: `html` and `htm`.
|
|
633
|
+
|
|
634
|
+
@see https://kitten.small-web.org/tutorials/static-html/
|
|
635
|
+
|
|
636
|
+
@remarks For internal use only.
|
|
637
|
+
*/
|
|
223
638
|
STATIC_ROUTE_EXTENSIONS: Array<string>
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
Given a file path, derives the unique class name for its route.
|
|
642
|
+
|
|
643
|
+
@remarks For internal use only.
|
|
644
|
+
*/
|
|
224
645
|
classNameFromFilePath: (filePath: string, basePath: string) => string
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
Converts a route in the form of, e.g., `'/some_thing/with/underscores-and-hyphens'` to `'SomeThingWithUnderscoresAndHyphensPage'`.
|
|
649
|
+
|
|
650
|
+
@remarks For internal use only.
|
|
651
|
+
*/
|
|
225
652
|
classNameFromRoutePattern: (pattern: string) => string
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
db namespace for JSDB database-related utility functions.
|
|
656
|
+
*/
|
|
226
657
|
db: {
|
|
658
|
+
/**
|
|
659
|
+
Given a JSDB change string, returns the dot-separated keypath of the changed property.
|
|
660
|
+
*/
|
|
227
661
|
keypathForChange(change: string): string
|
|
228
662
|
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
Inverse of encodeFilePath. Used when we want to avoid double escaping of file paths.
|
|
666
|
+
*/
|
|
229
667
|
decodeFilePath: (filePath: string) => string
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
Since Polka does not handle unicode in paths correctly (see https://github.com/lukeed/polka/issues/187), we have to split the file path and URI encode each component ourselves.
|
|
671
|
+
*/
|
|
230
672
|
encodeFilePath: (filePath: string) => string
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
Display error in console and exit process.
|
|
676
|
+
|
|
677
|
+
@remarks For internal use only.
|
|
678
|
+
*/
|
|
231
679
|
exitWithError: (message: string) => void
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
Routes sorted by category based on their extensions (e.g., .page.js, post.js, etc.)
|
|
683
|
+
|
|
684
|
+
Routes in the different categories are served differently by Kitten.
|
|
685
|
+
|
|
686
|
+
@see https://kitten.small-web.org/reference/#valid-file-types
|
|
687
|
+
|
|
688
|
+
@remarks For internal use only.
|
|
689
|
+
*/
|
|
232
690
|
extensionCategories: {
|
|
233
691
|
backendRoutes: Array<string>
|
|
234
692
|
frontendRoutes: Array<string>
|
|
@@ -237,17 +695,64 @@ export interface KittenGlobal {
|
|
|
237
695
|
staticRoutes: Array<string>
|
|
238
696
|
allRoutes: Array<string>
|
|
239
697
|
}
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
Returns the complete extension (e.g., page.js not just .js) of the passed file path. Works with any number of extensions, returning the last two without a dot at the start.
|
|
701
|
+
*/
|
|
240
702
|
extensionOfFilePath: (filePath: string) => string
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
Determines which places the server should listen at.
|
|
706
|
+
*/
|
|
241
707
|
getDomainsAndPort: (options: ServerOptions) => { domains: string[]; port: number }
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
Returns unique project identifier based on the path of the project. This can be used as the name of a directory that is certain to be unique for this project.
|
|
711
|
+
*/
|
|
242
712
|
getProjectIdentifierForDomain: (domain: string, port: number) => string
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
Kitten app path, formatted in a way that works regardless of whether Kitten was invoked using the `kitten` command from the bundled distribution or via _bin/kitten_ from source.
|
|
716
|
+
*/
|
|
243
717
|
kittenAppPath: string
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
Run passed command (either `'ci'` or `'install'`) on the given module path.
|
|
721
|
+
*/
|
|
244
722
|
npm: (command: 'ci' | 'install', modulePath: string) => boolean
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
Derives the route pattern for the passed file path based on the base path.
|
|
726
|
+
*/
|
|
245
727
|
routePatternFromFilePath: (filePath: string, basePath: string) => string
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
Runs npm ci on the passed module path.
|
|
731
|
+
*/
|
|
246
732
|
runNpmCiOnModulePath: (modulePath: string) => void
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
Calculates the base path used by the Kitten server to find files in the served app.
|
|
736
|
+
*/
|
|
247
737
|
setBasePath: (workingDirectory: string, pathToServe: string) => string
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
A regular expression that matches all extensions supported by Kitten.
|
|
741
|
+
|
|
742
|
+
Currently, this includes all extensions in {@link DYNAMIC_ROUTE_EXTENSIONS} and {@link STATIC_ROUTE_EXTENSIONS}.
|
|
743
|
+
|
|
744
|
+
@remarks For internal use only.
|
|
745
|
+
*/
|
|
248
746
|
supportedExtensionsRegExp: RegExp
|
|
249
747
|
}
|
|
250
748
|
|
|
749
|
+
/**
|
|
750
|
+
Constants for well-known/supported client-side libraries meant to be referenced in page routes.
|
|
751
|
+
|
|
752
|
+
Usually the file names held by these properties will refer to the minified version when `process.env.PRODUCTION` is `true` and non-minified versions otherwise (in development mode, so we can get more meaningful stack traces).
|
|
753
|
+
|
|
754
|
+
@see https://kitten.small-web.org/reference/#kitten-client-side-libraries
|
|
755
|
+
*/
|
|
251
756
|
libraries: {
|
|
252
757
|
htmx: string
|
|
253
758
|
htmxIdiomorph: string
|
|
@@ -256,6 +761,25 @@ export interface KittenGlobal {
|
|
|
256
761
|
water: string
|
|
257
762
|
}
|
|
258
763
|
|
|
764
|
+
/**
|
|
765
|
+
Special page slot names (constants) that can be used as targets of `<content for='…'>` tags.
|
|
766
|
+
|
|
767
|
+
@example
|
|
768
|
+
export default () => kitten.html`
|
|
769
|
+
<markdown>
|
|
770
|
+
# Special page slots
|
|
771
|
+
|
|
772
|
+
This is just regular page content.
|
|
773
|
+
</markdown>
|
|
774
|
+
<!-- Whereas this will be added to the <head>…</head> -->
|
|
775
|
+
<content for='${kitten.page.head}'>
|
|
776
|
+
<title>Special page slots</title>
|
|
777
|
+
<link rel='icon' href='/favicon.ico'>
|
|
778
|
+
</content>
|
|
779
|
+
`
|
|
780
|
+
|
|
781
|
+
@see https://kitten.small-web.org/tutorials/special-page-slots/
|
|
782
|
+
*/
|
|
259
783
|
page: {
|
|
260
784
|
html: 'HTML'
|
|
261
785
|
head: 'HEAD'
|
|
@@ -265,24 +789,268 @@ export interface KittenGlobal {
|
|
|
265
789
|
endOfBody: 'END_OF_BODY'
|
|
266
790
|
}
|
|
267
791
|
|
|
792
|
+
/**
|
|
793
|
+
Use this method to add untrusted markup to your page safely.
|
|
794
|
+
|
|
795
|
+
You can customise the list of allowed tags by providing a list of ones to add to them (e.g., `['img']`) or by replacing it altogether with your own list by passing `false` as the last argument.
|
|
796
|
+
|
|
797
|
+
@example
|
|
798
|
+
<!-- Safely display comments on a blog that contain Markdown syntax. -->
|
|
799
|
+
<ul>
|
|
800
|
+
${kitten.db.comments.map(comment => kitten.html`
|
|
801
|
+
<li>
|
|
802
|
+
<p>${kitten.safelyAddHtml(kitten.md.render(comment.message))}</p>
|
|
803
|
+
<p class='nameAndDate'>${comment.name} (${new Date(comment.date).toLocaleString()})</p>
|
|
804
|
+
</li>
|
|
805
|
+
`)}
|
|
806
|
+
</ul>
|
|
807
|
+
|
|
808
|
+
@remarks
|
|
809
|
+
Kitten escapes interpolated content by default so you’re safe from injection attacks by default. It also does not give you direct access to a `dangerouslySetInnerHTML()` style method on purpose. If you _really, really_ want to dangerously add HTML, you can do so by returning an array from your interpolation. e.g., `` `kitten.html`${[ thisContentWontBeSanitised ]}` ``. Needless to say, only ever do this with trusted content and then only if you absolutely must.
|
|
810
|
+
*/
|
|
268
811
|
safelyAddHtml: SanitisationFunction
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
This is a wrapper around sanitize-html that you can use to only allow whitelisted HTML in strings.
|
|
815
|
+
|
|
816
|
+
@example
|
|
817
|
+
// Kitten’s `kitten.safelyAddHtml()` function uses `sanitise()`.
|
|
818
|
+
kitten.safelyAddHtml = (untrustedContent, allowedTags = [], concat = true) => kitten.html`${[ sanitise(untrustedContent, allowedTags, concat) ]}`
|
|
819
|
+
|
|
820
|
+
@see https://github.com/apostrophecms/apostrophe/tree/main/packages/sanitize-html
|
|
821
|
+
*/
|
|
269
822
|
sanitise: SanitisationFunction
|
|
270
823
|
|
|
824
|
+
/**
|
|
825
|
+
Reference to `WebSocket` class from ws.
|
|
826
|
+
|
|
827
|
+
Use it to create your own server-to-server WebSocket connections.
|
|
828
|
+
|
|
829
|
+
@see https://github.com/websockets/ws
|
|
830
|
+
|
|
831
|
+
@example
|
|
832
|
+
// Detail of _updates.socket.js_ route in Kitten’s Streamiverse example.
|
|
833
|
+
stream = new kitten.WebSocket('wss://streamiverse.small-web.org/stream.socket')
|
|
834
|
+
|
|
835
|
+
stream.addEventListener('message', event => {
|
|
836
|
+
const message = JSON.parse(event.data)
|
|
837
|
+
if (message.event === 'update') {
|
|
838
|
+
const post = JSON.parse(message.payload)
|
|
839
|
+
|
|
840
|
+
console.info(` 🐘 Got an update from ${post.account.username}!`)
|
|
841
|
+
}
|
|
842
|
+
})
|
|
843
|
+
*/
|
|
271
844
|
WebSocket: typeof KittenWebSocket
|
|
272
845
|
|
|
846
|
+
/**
|
|
847
|
+
Kitten is run by default to silence Node’s deprecation warnings (you can turn them on by running `kitten` with `SHOW_DEPRECATION_WARNINGS=true`) as we use experimental features and we don’t what the console output to be noisy.
|
|
848
|
+
|
|
849
|
+
Any deprecation warnings that are encountered are kept here even if they’re not shown in the console.
|
|
850
|
+
|
|
851
|
+
@see https://codeberg.org/kitten/app/src/branch/main/suppress-experimental.cjs
|
|
852
|
+
*/
|
|
273
853
|
deprecationWarnings: Array<string>
|
|
274
854
|
|
|
855
|
+
/**
|
|
856
|
+
File system paths of important Kitten resources.
|
|
857
|
+
*/
|
|
275
858
|
paths: {
|
|
859
|
+
/**
|
|
860
|
+
Absolute local system path for binaries (~/.local/bin)
|
|
861
|
+
*/
|
|
862
|
+
BINARY_HOME: string,
|
|
863
|
+
|
|
864
|
+
/**
|
|
865
|
+
Path to Kitten’s own “binary” (shell script that starts the Node runtime and loads the loader and main process bundles).
|
|
866
|
+
*/
|
|
867
|
+
KITTEN_BINARY_PATH: string,
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
The path where a person’s data files should be stored according to the XDG Base Directory Specification (if the `XDG_DATA_HOME` environment variable is set, otherwise, falls back to _~/.local/share_).
|
|
871
|
+
|
|
872
|
+
@see https://specifications.freedesktop.org/basedir/latest/
|
|
873
|
+
*/
|
|
874
|
+
DATA_HOME: string,
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
The small-tech.org namespace within the person’s data home folder.
|
|
878
|
+
|
|
879
|
+
All Small Technology Foundation tools, including Kitten, live under this namespace.
|
|
880
|
+
*/
|
|
881
|
+
SMALL_TECH_DATA_HOME: string,
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
The home directory of Kitten’s own data.
|
|
885
|
+
|
|
886
|
+
Set to {@link SMALL_TECH_DATA_HOME}/kitten
|
|
887
|
+
*/
|
|
888
|
+
KITTEN_DATA_HOME: string,
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
The directory that hosts the Kitten app itself.
|
|
892
|
+
|
|
893
|
+
Set to {@link KITTEN_DATA_HOME}/app
|
|
894
|
+
*/
|
|
895
|
+
KITTEN_APP_DIRECTORY_PATH: string,
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
The directory containing Kitten’s own web app (settings, initial secret creation, etc.)
|
|
899
|
+
|
|
900
|
+
Set to {@link KITTEN_APP_DIRECTORY_PATH}/web
|
|
901
|
+
*/
|
|
902
|
+
KITTEN_WEB_APP_DIRECTORY_PATH: string,
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
The directory that houses all the TLS certificate information for Kitten servers (both local and globally-accessible ones).
|
|
906
|
+
|
|
907
|
+
Stores certificate data managed by \@small-tech/auto-encrypt (Let’s Encrypt) and \@small-tech/auto-encrypt-localhost, as abstracted by \@small-tech/https.
|
|
908
|
+
|
|
909
|
+
@see https://codeberg.org/small-tech/https
|
|
910
|
+
*/
|
|
911
|
+
KITTEN_TLS_DIRECTORY: string,
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
Contains certificate data for localhost domains.
|
|
915
|
+
|
|
916
|
+
As managed by Auto Encrypt Localhost (\@small-tech/auto-encrypt-localhost).
|
|
917
|
+
|
|
918
|
+
@see https://codeberg.org/small-tech/auto-encrypt-localhost
|
|
919
|
+
*/
|
|
920
|
+
KITTEN_TLS_LOCAL_CERTIFICATE_DIRECTORY: string,
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
Contains certificate data for production domains (and Web Numbers/IP Addresses).
|
|
924
|
+
|
|
925
|
+
As managed by Auto Encrypt (\@small-tech/auto-encrypt).
|
|
926
|
+
|
|
927
|
+
@see https://codeberg.org/small-tech/auto-encrypt
|
|
928
|
+
*/
|
|
929
|
+
KITTEN_TLS_GLOBAL_CERTIFICATE_DIRECTORY: string,
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
Location under /tmp that Kitten stores its temporary files.
|
|
933
|
+
|
|
934
|
+
Currently /tmp/small-tech.org/kitten
|
|
935
|
+
*/
|
|
936
|
+
KITTEN_TEMP_DIRECTORY: string,
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
Location of runtime.tar.xz, the archived version of Kitten’s runtime.
|
|
940
|
+
|
|
941
|
+
(Currently, Node.js).
|
|
942
|
+
*/
|
|
943
|
+
KITTEN_TEMP_RUNTIME_ARCHIVE_PATH: string,
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
The same-device temp directory is guaranteed to be on the same device as the rest of Kitten’s data so you can use, for example, `fs.rename` on it while you may not be able to do so with `KITTEN_TEMP_DIRECTORY`, which might be on a different partition.
|
|
947
|
+
*/
|
|
948
|
+
KITTEN_SAME_DEVICE_TEMP_DIRECTORY: string,
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
This directory holds Kitten’s runtime (currently, Node.js)
|
|
952
|
+
*/
|
|
953
|
+
KITTEN_RUNTIME_DIRECTORY: string,
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
The directory that holds the binary of Kitten’s runtime (currently, Node.js)
|
|
957
|
+
*/
|
|
958
|
+
KITTEN_RUNTIME_BIN_DIRECTORY: string,
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
The directory that holds the data for all projects (sites/apps) that have been served on this device.
|
|
962
|
+
|
|
963
|
+
Subfolders within this directory are named based on {@link utils.getProjectIdentifierForDomain}.
|
|
964
|
+
*/
|
|
965
|
+
KITTEN_DATA_DIRECTORY: string,
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
Kitten has two different types of internal databases: a global one for Kitten itself and separate internal databases for every project.
|
|
969
|
+
|
|
970
|
+
This is path for the global one.
|
|
971
|
+
|
|
972
|
+
@remarks For internal use only.
|
|
973
|
+
*/
|
|
974
|
+
KITTEN_GLOBAL_INTERNAL_DATABASE_DIRECTORY: string,
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
The directory that kitten projects are deployed to when you use the `kitten deploy` command.
|
|
978
|
+
*/
|
|
979
|
+
KITTEN_DEPLOYMENTS_DIRECTORY: string,
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
The directory that the repositories are cloned to when you use the `kitten run` command to clone and run a Kitten project based on the HTTPS git URL of the project’s repository.
|
|
983
|
+
*/
|
|
984
|
+
KITTEN_CLONES_DIRECTORY: string,
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
The path where a person’s configuration files should be stored according to the XDG Base Directory Specification (if the `XDG_CONFIG_HOME` environment variable is set, otherwise, falls back to _~/.config_).
|
|
988
|
+
|
|
989
|
+
@see https://specifications.freedesktop.org/basedir/latest/
|
|
990
|
+
*/
|
|
991
|
+
CONFIG_HOME: string,
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
Path of the systemd “user” (we don’t use that term in Small Tech as it’s an othering) directory.
|
|
995
|
+
|
|
996
|
+
Defaults to _~/.config/systemd/user_.
|
|
997
|
+
*/
|
|
998
|
+
SYSTEMD_USER_DIRECTORY: string,
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
Path to Kitten’s systemd unit.
|
|
1002
|
+
|
|
1003
|
+
Set to {@link SYSTEMD_USER_DIRECTORY}/kitten.service
|
|
1004
|
+
*/
|
|
1005
|
+
KITTEN_SYSTEMD_UNIT_PATH: string
|
|
1006
|
+
|
|
1007
|
+
// From Kitten’s src/lib/globals.ts
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
The app data directory for the current app (site/project).
|
|
1011
|
+
|
|
1012
|
+
Set to the return value of {@link utils.getProjectIdentifierForDomain} in {@link KITTEN_DATA_DIRECTORY}.
|
|
1013
|
+
*/
|
|
276
1014
|
APP_DATA_DIRECTORY: string
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
The location of file uploads for the current app.
|
|
1018
|
+
|
|
1019
|
+
Set to {@link APP_DATA_DIRECTORY}/uploads
|
|
1020
|
+
*/
|
|
277
1021
|
APP_UPLOADS_DIRECTORY: string
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
The location of REPL data (REPL history) for the current app.
|
|
1025
|
+
|
|
1026
|
+
Set to {@link APP_DATA_DIRECTORY}/repl
|
|
1027
|
+
*/
|
|
278
1028
|
APP_REPL_DIRECTORY: string
|
|
279
1029
|
}
|
|
280
1030
|
|
|
1031
|
+
/**
|
|
1032
|
+
For internal use by Kitten’s web app.
|
|
1033
|
+
*/
|
|
281
1034
|
deploy: Function
|
|
282
1035
|
}
|
|
283
1036
|
|
|
284
1037
|
declare global {
|
|
285
|
-
|
|
1038
|
+
/**
|
|
1039
|
+
Kitten’s global `kitten` object.
|
|
1040
|
+
|
|
1041
|
+
The most common properties you’ll be using in daily authoring include:
|
|
1042
|
+
|
|
1043
|
+
- {@link html} - Write HTML with component and string interpolation support.
|
|
1044
|
+
- {@link db} - Reference your site/apps custom JSDB database.
|
|
1045
|
+
- {@link Page} - Extend this class to create your own Kitten pages.
|
|
1046
|
+
- {@link Component} - Extend this class to create your own stateful Kitten components.
|
|
1047
|
+
- {@link safelyAddHtml} - Use when adding untrusted content to your pages.
|
|
1048
|
+
- {@link crypto} - Kitten’s cryptographic library.
|
|
1049
|
+
- {@link icons} - Kitten’s built-in icon library.
|
|
1050
|
+
|
|
1051
|
+
@see https://kitten.small-web.org/tutorials/
|
|
1052
|
+
*/
|
|
1053
|
+
var kitten: kitten
|
|
286
1054
|
}
|
|
287
1055
|
|
|
288
1056
|
export {}
|