feat: migrate to starlight

This commit is contained in:
DuroCodes
2024-05-06 17:15:30 -04:00
parent 767acedea7
commit bb190f2d81
15140 changed files with 2828326 additions and 35408 deletions

16
node_modules/pagefind/LICENSE/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,16 @@
pagefind
Copyright (c) CloudCannon
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Includes other software related under the MIT license:
- vscode-ripgrep, Copyright Microsoft Corporation. For licensing see /LICENSE/LICENSE-vscode-ripgrep

13
node_modules/pagefind/LICENSE/LICENSE-vscode-ripgrep generated vendored Normal file
View File

@@ -0,0 +1,13 @@
vscode-ripgrep
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

50
node_modules/pagefind/README.md generated vendored Normal file
View File

@@ -0,0 +1,50 @@
# Pagefind Static Search
Pagefind is a fully static search library that aims to perform well on large sites, while using as little of your users bandwidth as possible, and without hosting any infrastructure.
The full documentation on using Pagefind can be found at https://pagefind.app/.
This packages houses a wrapper for running the precompiled Pagefind binary, and also serves as a NodeJS indexing library that can be integrated into existing tools.
## Running Pagefind through NPX
This is the recommended way of running Pagefind on a static site.
```bash
npx pagefind --site "public"
```
For more details on using the Pagefind binary, see [Installing and running Pagefind](https://pagefind.app/docs/installation/#running-via-npx), and the rest of the Pagefind documentation.
## Using Pagefind as a Node library
This package also provides an interface to the Pagefind binary directly as a package you can import.
```js
import * as pagefind from "pagefind";
// Create a Pagefind search index to work with
const { index } = await pagefind.createIndex();
// Index all HTML files in a directory
await index.addDirectory({
path: "public"
});
// Add extra content
await index.addCustomRecord({
url: "/resume.pdf",
content: "Aenean lacinia bibendum nulla sed consectetur",
language: "en",
});
// Get the index files in-memory
const { files } = await index.getFiles();
// Or, write the index to disk
await index.writeFiles({
outputPath: "public/pagefind"
});
```
For more details on using Pagefind as a library, see [Indexing content using the NodeJS API](https://pagefind.app/docs/node-api/).

View File

@@ -0,0 +1 @@
3097b82ac3dc0d7d3d78d242bfd68bc0753ab5432eed6712501b87f9c05c0716 pagefind-v1.1.0-aarch64-apple-darwin.tar.gz

View File

@@ -0,0 +1 @@
fef38491d13817d85a1b05710c1de05840e4568617ca5bf0b0a1637ec2617e02 pagefind-v1.1.0-aarch64-unknown-linux-musl.tar.gz

View File

@@ -0,0 +1 @@
5ffd34d32addc2454b436cfbb4894b6220e60d97f32ed003a95db9b1903ad2a0 pagefind-v1.1.0-x86_64-apple-darwin.tar.gz

View File

@@ -0,0 +1 @@
a04a99318d3604343a3c99c86bcf8c35e829ff7f729a4ec1b6d66adfaaf52e6f *pagefind-v1.1.0-x86_64-pc-windows-msvc.tar.gz

View File

@@ -0,0 +1 @@
b20d0b06b54eb2fba1e290245919376364584a456fb644e66eecdb67549b1cf2 pagefind-v1.1.0-x86_64-unknown-linux-musl.tar.gz

View File

@@ -0,0 +1 @@
e33ee297b885abcce4a674b70779778e354d7ae4eb1a0b7b15dea48852d80cb7 pagefind_extended-v1.1.0-aarch64-apple-darwin.tar.gz

View File

@@ -0,0 +1 @@
b05661d856372beea75468ea683f197b465e019f033259768f65988c9598f390 pagefind_extended-v1.1.0-aarch64-unknown-linux-musl.tar.gz

View File

@@ -0,0 +1 @@
907d526d1d40de7a15060a495a460d00ed461fa6e6963278d90152360ea24346 pagefind_extended-v1.1.0-x86_64-apple-darwin.tar.gz

View File

@@ -0,0 +1 @@
5c534b4d69bcae15e3684e074150eefa1b9b16d5f359e10f349bc5add6af5ea6 *pagefind_extended-v1.1.0-x86_64-pc-windows-msvc.tar.gz

View File

@@ -0,0 +1 @@
583cf2753fb2070448a9c9cf1f31acd1b96af99b9ca0a450faf9bb376420bac4 pagefind_extended-v1.1.0-x86_64-unknown-linux-musl.tar.gz

8
node_modules/pagefind/jsconfig.json generated vendored Normal file
View File

@@ -0,0 +1,8 @@
{
"compilerOptions": {
"resolveJsonModule": true,
"lib": [
"esnext"
]
}
}

27
node_modules/pagefind/lib/encoding.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
/**
*
* @param {string} b64
* @returns {Uint8Array}
*/
export const decode = (b64) => {
let binString;
if (typeof Buffer !== "undefined" && typeof Buffer.from === "function") {
return Buffer.from(b64, "base64");
} else if (
typeof window !== "undefined" &&
typeof window.atob === "function"
) {
binString = window.atob(b64);
} else if (typeof atob === "function") {
binString = atob(b64);
} else {
throw new Error("Unable to decode base64 data");
}
const size = binString.length;
const bytes = new Uint8Array(size);
for (let i = 0; i < size; i++) {
bytes[i] = binString.charCodeAt(i);
}
return bytes;
};

301
node_modules/pagefind/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,301 @@
import { PagefindService } from "./service.js";
import { decode } from "./encoding.js";
/**
* @typedef {import('pagefindInternal').InternalResponseCallback} InternalResponseCallback
* @typedef {import('pagefindInternal').InternalResponsePayload} InternalResponsePayload
*/
/**
* @type {PagefindService?}
*/
let persistentService;
const launch = () => {
if (!persistentService) {
persistentService = new PagefindService();
}
return persistentService;
}
/**
* @template T
* @param {function(any): void} resolve
* @param {function(any): void} reject
* @param {InternalResponseCallback} response_callback
* @param {function(InternalResponsePayload): T} resultFn
*/
const handleApiResponse = (resolve, reject, { exception, err, result }, resultFn) => {
if (exception) {
reject(exception);
} else {
resolve({
errors: err ? [err.message] : [],
...(result ? resultFn(result) : {})
});
}
}
/**
* @typedef {import('pagefindService').NewIndexResponse} NewIndexResponse
*
* @param {import('pagefindService').PagefindServiceConfig=} config
* @type {import('pagefindService').createIndex}
* */
export const createIndex = (config) => new Promise((resolve, reject) => {
// TODO: Validate `config` here, instead of waiting for the backend to throw an error.
// Ideally we create a global Pagefind config JSON schema that (a subset of) can be used here.
const action = 'NewIndex';
launch().sendMessage(
{
type: action,
config: {
root_selector: config?.rootSelector,
exclude_selectors: config?.excludeSelectors,
force_language: config?.forceLanguage,
verbose: config?.verbose,
logfile: config?.logfile,
keep_index_url: config?.keepIndexUrl,
}
}, (response) => {
/** @type {function(InternalResponsePayload): Omit<NewIndexResponse, 'errors'>?} */
const successCallback = (success) => {
if (success.type !== action) {
reject(`Message returned from backend should have been ${action}, but was ${success.type}`);
return null;
}
return {
index: indexFns(success.index_id),
}
};
handleApiResponse(resolve, reject, response, successCallback);
}
);
});
/**
* @type {import('pagefindService').close}
*/
export const close = () => new Promise((resolve, reject) => {
persistentService?.close(null);
persistentService = null;
resolve(null);
});
/**
* @param {number} indexId
* @returns {import ('pagefindService').PagefindIndex}
*/
const indexFns = (indexId) => {
return {
addHTMLFile: (file) => addHTMLFile(indexId, file),
addCustomRecord: (record) => addCustomRecord(indexId, record),
addDirectory: (dir) => addDirectory(indexId, dir),
writeFiles: (options) => writeFiles(indexId, options),
getFiles: () => getFiles(indexId),
deleteIndex: () => deleteIndex(indexId)
}
}
/**
* @typedef {import('pagefindService').NewFileResponse} NewFileResponse
*
* @param {number} indexId
* @param {import('pagefindService').HTMLFile} file
* @returns {Promise<NewFileResponse>}
*/
const addHTMLFile = (indexId, file) => new Promise((resolve, reject) => {
const action = 'AddFile';
const responseAction = 'IndexedFile';
launch().sendMessage(
{
type: action,
index_id: indexId,
file_path: file.sourcePath,
url: file.url,
file_contents: file.content
}, (response) => {
/** @type {function(InternalResponsePayload): Omit<NewFileResponse, 'errors'>?} */
const successCallback = (success) => {
if (success.type !== responseAction) {
reject(`Message returned from backend should have been ${action}, but was ${success.type}`);
return null;
}
return {
file: {
uniqueWords: success.page_word_count,
url: success.page_url,
meta: success.page_meta,
}
}
};
handleApiResponse(resolve, reject, response, successCallback);
}
);
});
/**
* @param {number} indexId
* @param {import('pagefindService').CustomRecord} record
* @returns {Promise<NewFileResponse>}
*/
const addCustomRecord = (indexId, record) => new Promise((resolve, reject) => {
const action = 'AddRecord';
const responseAction = 'IndexedFile';
launch().sendMessage(
{
type: action,
index_id: indexId,
url: record.url,
content: record.content,
language: record.language,
meta: record.meta,
filters: record.filters,
sort: record.sort,
}, (response) => {
/** @type {function(InternalResponsePayload): Omit<NewFileResponse, 'errors'>?} */
const successCallback = (success) => {
if (success.type !== responseAction) {
reject(`Message returned from backend should have been ${action}, but was ${success.type}`);
return null;
}
return {
file: {
uniqueWords: success.page_word_count,
url: success.page_url,
meta: success.page_meta,
}
}
};
handleApiResponse(resolve, reject, response, successCallback);
}
);
});
/**
* @typedef {import('pagefindService').IndexingResponse} IndexingResponse
*
* @param {number} indexId
* @param {import('pagefindService').SiteDirectory} dir
* @returns {Promise<IndexingResponse>}
*/
const addDirectory = (indexId, dir) => new Promise((resolve, reject) => {
const action = 'AddDir';
const responseAction = 'IndexedDir';
launch().sendMessage(
{
type: action,
index_id: indexId,
path: dir.path,
glob: dir.glob
}, (response) => {
/** @type {function(InternalResponsePayload): Omit<IndexingResponse, 'errors'>?} */
const successCallback = (success) => {
if (success.type !== responseAction) {
reject(`Message returned from backend should have been ${action}, but was ${success.type}`);
return null;
}
return {
page_count: success.page_count
}
};
handleApiResponse(resolve, reject, response, successCallback);
}
);
});
/**
* @typedef {import ('pagefindService').WriteFilesResponse} WriteFilesResponse
*
* @param {number} indexId
* @param {import('pagefindService').WriteOptions=} options
* @returns {Promise<WriteFilesResponse>}
*/
const writeFiles = (indexId, options) => new Promise((resolve, reject) => {
const action = 'WriteFiles';
launch().sendMessage(
{
type: action,
index_id: indexId,
output_path: options?.outputPath
}, (response) => {
/** @type {function(InternalResponsePayload): Omit<WriteFilesResponse, 'errors'>?} */
const successCallback = (success) => {
if (success.type !== action) {
reject(`Message returned from backend should have been ${action}, but was ${success.type}`);
return null;
}
return {
outputPath: success.output_path
}
};
handleApiResponse(resolve, reject, response, successCallback);
}
);
});
/**
* @typedef {import ('pagefindService').GetFilesResponse} GetFilesResponse
*
* @param {number} indexId
* @returns {Promise<GetFilesResponse>}
*/
const getFiles = (indexId) => new Promise((resolve, reject) => {
const action = 'GetFiles';
launch().sendMessage(
{
type: action,
index_id: indexId,
}, (response) => {
/** @type {function(InternalResponsePayload): Omit<GetFilesResponse, 'errors'>?} */
const successCallback = (success) => {
if (success.type !== action) {
reject(`Message returned from backend should have been ${action}, but was ${success.type}`);
return null;
}
return {
files: success.files.map(file => {
return {
path: file.path,
content: decode(file.content)
}
})
}
};
handleApiResponse(resolve, reject, response, successCallback);
}
);
});
/**
* @param {number} indexId
* @returns {Promise<null>}
*/
const deleteIndex = (indexId) => new Promise((resolve, reject) => {
const action = 'DeleteIndex';
launch().sendMessage(
{
type: action,
index_id: indexId,
}, (response) => {
/** @type {function(InternalResponsePayload): Omit<GetFilesResponse, 'errors'>?} */
const successCallback = (success) => {
if (success.type !== action) {
reject(`Message returned from backend should have been ${action}, but was ${success.type}`);
return null;
}
return null;
};
handleApiResponse(resolve, reject, response, successCallback);
}
);
});

36
node_modules/pagefind/lib/resolveBinary.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
import os from 'os';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
/**
* @param {string[]} execnames
* @returns {string}
*/
export function resolveBinaryPath(execnames = []) {
for (const execname of execnames) {
const env_var = process.env[`${execname.toUpperCase()}_BINARY_PATH`];
if (env_var) return env_var;
}
const cpu = process.env.npm_config_arch || os.arch();
const platform = process.platform === 'win32' ? 'windows' : process.platform;
for (const execname of execnames) {
const executable = platform === 'windows' ? `${execname}.exe` : execname;
try {
return require.resolve(`@pagefind/${platform}-${cpu}/bin/${executable}`);
} catch (e) { }
}
throw new Error(
[
`Failed to install either of [${execnames.join(', ')}]. Most likely the platform ${platform}-${cpu} is not yet a supported architecture.`,
`Please open an issue at https://github.com/CloudCannon/pagefind and paste this error message in full.`,
`If you believe this package should be compatible with your system,`,
`you can try downloading a release binary directly from https://github.com/CloudCannon/pagefind/releases`
].join('\n')
);
}

29
node_modules/pagefind/lib/runner/bin.cjs generated vendored Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env node
const { spawnSync } = require('child_process');
const execname = 'pagefind';
const execnames = ["pagefind_extended", "pagefind"];
(async () => {
try {
const { resolveBinaryPath } = await import("../resolveBinary.js");
const args = process.argv.slice(2);
const binaryPath = resolveBinaryPath(execnames);
const verbose = args.filter(a => /verbose|-v$/i.test(a)).length;
if (verbose) {
console.log(`${execname} npm wrapper: Running the executable at ${binaryPath}`);
}
const processResult = spawnSync(binaryPath, args, {
windowsHide: true,
stdio: [process.stdin, process.stdout, process.stderr]
});
if (verbose) {
console.log(`${execname} npm wrapper: Process exited with status ${processResult.status}`);
}
process.exit(processResult.status ?? 1);
} catch (err) {
console.error(`Failed to run ${execname} via the npx wrapper: ${err}`);
console.error(`Please open an issue at https://github.com/CloudCannon/${execname} and paste this error message in full.`);
process.exit(1);
}
})();

210
node_modules/pagefind/lib/service.js generated vendored Normal file
View File

@@ -0,0 +1,210 @@
import child_process from 'child_process';
import { resolveBinaryPath } from './resolveBinary.js';
/**
* Requests
* @typedef {import('pagefindInternal').InternalServiceRequest} InternalServiceRequest
* @typedef {import('pagefindInternal').InternalRequestPayload} InternalRequestPayload
*
* Responses
* @typedef {import('pagefindInternal').InternalServiceResponse} InternalServiceResponse
* @typedef {import('pagefindInternal').InternalResponseError} InternalResponseError
* @typedef {import('pagefindInternal').InternalResponsePayload} InternalResponsePayload
*
* @typedef {import('pagefindInternal').InternalResponseCallback} InternalResponseCallback
*/
export class PagefindService {
constructor() {
/**
* @type {child_process.ChildProcessByStdio<import('stream').Writable, import('stream').Readable, null> | null}
*/
this.backend = child_process.spawn(resolveBinaryPath(["pagefind_extended", "pagefind"]), [`--service`], {
windowsHide: true,
stdio: ['pipe', 'pipe', 'inherit'],
cwd: process.cwd(),
});
this.incomingMessageBuffer = "";
/**
* @type {Record<number, function(InternalResponseCallback): void>}
*/
this.callbacks = {};
this.messageId = 0;
(this.backend.stdout).on('data', (data) => this.handleIncomingChunk(data));
(this.backend.stdin).on('error', (err) => this.close(err));
this.backend.on('error', (err) => this.close(err));
this.refCount = 0
this.backend.unref?.();
/** @type {{ unref?(): void }} */
(this.backend.stdout)?.unref?.();
/** @type {{ unref?(): void }} */
(this.backend.stdin)?.unref?.();
}
/**
* @param {Error?} err
*/
close(err) {
if (err) {
console.error("Service stopped", err);
}
this.backend?.unref?.();
this.backend?.stdout?.destroy?.()
this.backend?.stdin?.destroy?.()
this.backend?.kill?.();
this.backend = null;
for (const [, cb] of Object.entries(this.callbacks)) {
cb({
exception: new Error("Pagefind backend closed"),
err: null,
result: null
})
}
}
ref() {
if (++this.refCount === 1) this.backend?.ref?.();
}
unref() {
if (--this.refCount === 0) this.backend?.unref?.();
}
/**
* @param {Buffer} buf
*/
handleIncomingChunk(buf) {
let chunk = buf.toString();
try {
while (chunk.length) {
let delim = chunk.indexOf(',');
if (delim === -1) {
this.incomingMessageBuffer = this.incomingMessageBuffer + chunk;
return;
}
let chunkMessage = chunk.slice(0, delim);
this.handleIncomingMessage(this.incomingMessageBuffer + chunkMessage);
this.incomingMessageBuffer = "";
chunk = chunk.slice(delim + 1);
}
} catch (e) {
/* TODO: Comms error handling */
console.error(e);
this.incomingMessageBuffer = "";
}
}
/**
* @param {string} message
*/
handleIncomingMessage(message) {
let parsed_message = PagefindService.parseMessage(message);
if (parsed_message && typeof parsed_message.message_id !== "number") {
if (parsed_message.payload.type !== "Error") {
// Unreachable (hopefully)
return;
}
if (!parsed_message.payload.original_message) {
throw new Error(`Failed to communicate with the Pagefind service backend: ${parsed_message.payload.message}`);
}
try {
let our_message = JSON.parse(parsed_message.payload.original_message);
if (our_message.message_id && this.callbacks[our_message.message_id]) {
this.returnValue(
our_message.message_id,
{
exception: new Error(`Pagefind service error when parsing a message: ${parsed_message.payload.message}\nMessage being parsed:\n${parsed_message.payload.original_message}`),
err: null,
result: null,
});
}
} catch (e) {
throw new Error(`Failed to communicate with the Pagefind service backend: ${parsed_message.payload.message}`);
}
}
if (parsed_message && this.callbacks[parsed_message.message_id]) {
const isError = parsed_message.payload.type === "Error";
this.returnValue(
parsed_message.message_id,
{
exception: null,
err: isError ? /** @type {InternalResponseError} */ (parsed_message.payload) : null,
result: !isError ? /** @type {InternalResponsePayload} */ (parsed_message.payload) : null,
});
}
}
/**
* @param {InternalRequestPayload} message
* @param {function(InternalResponseCallback): void} callback
* @returns {InternalServiceRequest}
*/
wrapOutgoingMessage(message, callback) {
let output_message = {
message_id: ++this.messageId,
payload: message
};
if (callback) this.callbacks[output_message.message_id] = callback;
return output_message;
}
/**
* @param {InternalRequestPayload} message
* @param {function(InternalResponseCallback): void} callback
*/
sendMessage(message, callback) {
if (this.backend === null) {
throw new Error(`Cannot send message, backend is closed: ${message}`);
}
let wrapped_message = this.wrapOutgoingMessage(message, callback);
this.ref();
let encoded = PagefindService.encodeMessage(wrapped_message);
this.backend.stdin.write(encoded, (err) => {
if (err) {
this.close(err);
}
});
}
/**
* @param {number} message_id
* @param {InternalResponseCallback} response_callback
*/
returnValue(message_id, response_callback) {
try {
this.callbacks[message_id](response_callback);
} finally {
delete this.callbacks[message_id];
this.unref();
}
}
/**
* @param {InternalServiceRequest} message
* @returns {string}
*/
static encodeMessage(message) {
return Buffer.from(JSON.stringify(message)).toString('base64') + ",";
}
/**
*
* @param {string} message
* @returns {InternalServiceResponse?}
*/
static parseMessage(message) {
const data = Buffer.from(message, 'base64');
try {
return JSON.parse(data.toString());
} catch {
throw new Error(`Failed to parse a message from the Pagefind service backend`);
}
}
}

46
node_modules/pagefind/package.json generated vendored Normal file
View File

@@ -0,0 +1,46 @@
{
"name": "pagefind",
"version": "1.1.0",
"type": "module",
"description": "Implement search on any static website.",
"bin": "lib/runner/bin.cjs",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "https://github.com/CloudCannon/pagefind"
},
"exports": {
".": {
"types": "./types/index.d.ts",
"import": "./lib/index.js"
}
},
"types": "types/index.d.ts",
"author": "CloudCannon",
"license": "MIT",
"optionalDependencies": {
"@pagefind/linux-x64": "1.1.0",
"@pagefind/linux-arm64": "1.1.0",
"@pagefind/darwin-x64": "1.1.0",
"@pagefind/darwin-arm64": "1.1.0",
"@pagefind/windows-x64": "1.1.0"
},
"keywords": [
"CloudCannon",
"Cloud",
"Cannon",
"jamstack",
"static",
"search",
"pagefind",
"page",
"find"
],
"bugs": {
"url": "https://github.com/CloudCannon/pagefind/issues"
},
"homepage": "https://github.com/CloudCannon/pagefind#readme",
"devDependencies": {
"@types/node": "^20.4.5"
}
}

25
node_modules/pagefind/tsconfig.json generated vendored Normal file
View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2020",
"module": "es2022",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"paths": {
"pagefindService": [
"./types/index"
],
"pagefindInternal": [
"./types/internal"
],
},
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": [
"lib/**/*"
]
}

216
node_modules/pagefind/types/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,216 @@
/**
* Create a new Pagefind index that files can be added to
*/
export function createIndex(config: PagefindServiceConfig): Promise<NewIndexResponse>;
/**
* Close the Pagefind service and clean up, stopping the binary altogether.
*
* Service _will_ be restarted if any new calls are made to any other function.
*
* Calling functions on an existing index after calling close() is undefined behavior,
* as that index may map to a new index after the service has restarted.
*/
export function close(): Promise<null>;
export interface PagefindServiceConfig {
/**
* The element Pagefind should treat as the root of the document, defaults to `html`.
* Usually you will want to use the data-pagefind-body attribute instead.
* @example ".my-html-outer"
*/
rootSelector?: string,
/**
* Custom selectors that Pagefind should ignore when indexing.
* Usually you will want to use the data-pagefind-ignore attribute instead.
* @example ["svg", ".my-code-blocks"]
*/
excludeSelectors?: string[],
/**
* Ignore any detected languages and index the whole site as a single language.
* Expects an ISO 639-1 code.
*/
forceLanguage?: string,
/**
* Print verbose logging while indexing the site. Does not impact the web-facing search.
* When running as a service, only impacts the logfile (if present).
*/
verbose?: boolean,
/**
* Path to a logfile to write to. Will replace the file on each run.
*/
logfile?: string,
/**
* Keep `index.html` at the end of search result paths.
* Defaults to false, stripping `index.html`.
*/
keepIndexUrl?: boolean,
}
export interface NewIndexResponse {
errors: string[],
index?: PagefindIndex
}
/**
* A Pagefind index that exists in the backend service before being built
*/
export interface PagefindIndex {
addHTMLFile: typeof addHTMLFile,
addCustomRecord: typeof addCustomRecord,
addDirectory: typeof addDirectory,
writeFiles: typeof writeFiles,
getFiles: typeof getFiles,
deleteIndex: typeof deleteIndex,
}
/**
* Index an HTML file that isn't on disk
*/
declare function addHTMLFile(file: HTMLFile): Promise<NewFileResponse>;
/**
* Index a custom record that isn't backed by an HTML file
*/
declare function addCustomRecord(record: CustomRecord): Promise<NewFileResponse>;
/**
* Index a directory of HTML files from disk
*/
declare function addDirectory(path: SiteDirectory): Promise<IndexingResponse>;
/**
* The data required for Pagefind to index an HTML file that isn't on disk
* @example
* {
* path: "about/index.html",
* content: "<html lang='en'><body><h1>Meet the team</h1></body></html>"
* }
*/
export interface HTMLFile {
/**
* The source path of the HTML file if it were to exist on disk.
* Must be a relative path, or an absolute path within the current working directory.
* Pagefind will compute the result URL from this path.
*
* If not supplied, url must be supplied.
*
* @example "about/index.html"
* @example "/Users/user/Documents/site/about/index.html"
*/
sourcePath?: string,
/**
* An explicit URL to use, instead of having Pagefind
* compute the URL based on the sourcePath.
*
* If not supplied, sourcePath must be supplied.
*
* @example "/about/"
*/
url?: string,
/** The source HTML content of the file to be parsed */
content: string
}
/**
* The data required for Pagefind to index a custom record that isn't backed by an HTML file
* @example
* {
* url: "/about/",
* content: "Meet the team",
* language: "en"
* }
*/
export interface CustomRecord {
/** The output URL of this record. Pagefind will not alter this */
url: string,
/** The raw content of this record */
content: string,
/** What language is this record written in. Multiple languages will be split into separate indexes. Expects an ISO 639-1 code. */
language: string,
/** The metadata to attach to this record. Supplying a `title` is highly recommended */
meta?: Record<string, string>,
/** The filters to attach to this record */
filters?: Record<string, string[]>,
/** The sort keys to attach to this record */
sort?: Record<string, string>
}
/**
* The data required for Pagefind to index the files in a directory
* @example
* {
* path: "public",
* glob: "**\/*.{html}"
* }
*/
export interface SiteDirectory {
/**
* The path to the directory to index.
* If relative, is relative to the cwd.
*/
path: string,
/** Optionally, a custom glob to evaluate for finding files. Default to all HTML files. */
glob?: string
}
export interface IndexingResponse {
errors: string[],
page_count: number
}
export interface NewFileResponse {
errors: string[],
file: NewFile
}
/**
* Details about a new file that has been successfully added to the Pagefind index
*/
export interface NewFile {
uniqueWords: number,
url: string,
meta: Record<string, string>
}
/**
* Write the index files to disk
*/
declare function writeFiles(options?: WriteOptions): Promise<WriteFilesResponse>;
/**
* Options for writing a Pagefind index to disk
*/
export interface WriteOptions {
/**
* The path of the pagefind bundle directory to write to disk.
* If relative, is relative to the cwd.
* @example "./public/pagefind"
*/
outputPath: string
}
export interface WriteFilesResponse {
errors: string[],
outputPath: string
}
/**
* Get an in-memory copy of the built index files
*/
declare function getFiles(): Promise<GetFilesResponse>;
export interface GetFilesResponse {
errors: string[],
files: IndexFile[]
}
export interface IndexFile {
path: string,
content: Uint8Array
}
/**
* Delete this index and clear it from memory
*/
declare function deleteIndex(): Promise<null>;

152
node_modules/pagefind/types/internal.d.ts generated vendored Normal file
View File

@@ -0,0 +1,152 @@
// Requests to the backend.
/**
* The raw object passed to the backend binary
*/
export interface InternalServiceRequest {
message_id?: number,
payload: InternalRequestPayload
}
/**
* The payload describing an action to the backend binary
*/
export type InternalRequestPayload =
| InternalNewIndexRequest
| InternalAddFileRequest
| InternalAddRecordRequest
| InternalAddDirRequest
| InternalWriteFilesRequest
| InternalGetFilesRequest
| InternalDeleteIndexRequest;
export interface InternalNewIndexRequest {
type: 'NewIndex',
config?: InternalPagefindServiceConfig
}
export interface InternalPagefindServiceConfig {
root_selector?: string,
exclude_selectors?: string[],
force_language?: string,
verbose?: boolean,
logfile?: string,
keep_index_url?: boolean,
}
export interface InternalAddFileRequest {
type: 'AddFile',
index_id: number,
file_path?: string,
url?: string,
file_contents: string
}
export interface InternalAddRecordRequest {
type: 'AddRecord',
index_id: number,
url: string,
content: string,
language: string,
meta?: Record<string, string>,
filters?: Record<string, string[]>,
sort?: Record<string, string>
}
export interface InternalAddDirRequest {
type: 'AddDir',
index_id: number,
path: string,
glob?: string
}
export interface InternalWriteFilesRequest {
type: 'WriteFiles',
index_id: number,
output_path?: string
}
export interface InternalGetFilesRequest {
type: 'GetFiles',
index_id: number
}
export interface InternalDeleteIndexRequest {
type: 'DeleteIndex',
index_id: number
}
// Responses from the backend.
/**
* The raw object returned from the backend binary
*/
export interface InternalServiceResponse {
message_id: number,
payload: InternalResponsePayload | InternalResponseError
}
/**
* The response payload in the case of an error
*/
export interface InternalResponseError {
type: 'Error',
original_message?: string,
message: string
}
/**
* The response payload in the case of a success
*/
export type InternalResponsePayload =
| InternalNewIndexResponse
| InternalIndexedFileResponse
| InternalIndexedDirResponse
| InternalWriteFilesResponse
| InternalGetFilesResponse
| InternalDeleteIndexResponse;
export interface InternalNewIndexResponse {
type: 'NewIndex',
index_id: number
}
export interface InternalIndexedFileResponse {
type: 'IndexedFile',
page_word_count: number,
page_url: string,
page_meta: Record<string, string>
}
export interface InternalIndexedDirResponse {
type: 'IndexedDir',
page_count: number
}
export interface InternalWriteFilesResponse {
type: 'WriteFiles',
output_path: string,
}
export interface InternalGetFilesResponse {
type: 'GetFiles',
files: InternalSyntheticFile[],
}
export interface InternalSyntheticFile {
path: string,
content: string
}
export interface InternalDeleteIndexResponse {
type: 'DeleteIndex'
}
/**
* What the service returns to the wrapping javascript detailing a response
*/
export interface InternalResponseCallback {
exception: Error | null,
err: InternalResponseError | null,
result: InternalResponsePayload | null
}