@f5-sales-demo/docs-theme 4.13.9 → 4.13.11

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/config.ts CHANGED
@@ -23,6 +23,7 @@ import { defaultLocale as f5xcDefaultLocale, f5xcDefaultLocales } from './src/i1
23
23
  import { mobileLabels } from './src/i18n/mega-menu-translations.ts';
24
24
  import { sidebarTranslations } from './src/i18n/translations.ts';
25
25
  import remarkMermaid from './src/plugins/remark-mermaid.mjs';
26
+ import { englishSearchEngineIntegration } from './src/search/pagefind-engine.mjs';
26
27
  import { sharedSearchIntegration } from './src/shared/search-integration.mjs';
27
28
  import { sharedMode } from './src/shared/settings.mjs';
28
29
  import canonicalLlms from './src/utils/canonical-llms.mjs';
@@ -474,6 +475,7 @@ export function createF5xcDocsConfig(options: F5xcDocsConfigOptions = {}) {
474
475
  : []),
475
476
  ...(githubRepository === 'f5-sales-demo/statistics' ? [statisticsScriptMarkdown()] : []),
476
477
  ...additionalIntegrations,
478
+ englishSearchEngineIntegration(),
477
479
  ],
478
480
  });
479
481
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@f5-sales-demo/docs-theme",
3
- "version": "4.13.9",
3
+ "version": "4.13.11",
4
4
  "description": "F5 Distributed Cloud branded Starlight documentation theme",
5
5
  "type": "module",
6
6
  "engines": {
@@ -64,7 +64,8 @@
64
64
  "assets/",
65
65
  "components/",
66
66
  "src/",
67
- "canonical-route-middleware.ts"
67
+ "canonical-route-middleware.ts",
68
+ "vendor/pagefind/"
68
69
  ],
69
70
  "keywords": [
70
71
  "starlight",
@@ -95,6 +96,7 @@
95
96
  "@types/react": "^19.2.18",
96
97
  "@types/react-dom": "^19.2.7",
97
98
  "astro": "7.2.8",
99
+ "pagefind": "1.5.2",
98
100
  "react": "^19.2.8",
99
101
  "react-dom": "^19.2.8",
100
102
  "vitest": "^4.1.11"
@@ -0,0 +1,17 @@
1
+ # English Pagefind matching
2
+
3
+ The engine uses indexed words beginning with the query term and retains Pagefind's English stemming. It rejects inverse-prefix matches and requires every word in a multiword query to match. Unknown tokens therefore produce no results without disabling autocomplete, ranking, filters, or quoted searches.
4
+
5
+ The build integration replaces only the English WebAssembly engine after Starlight generates its index. It verifies the Pagefind version, sealed artifact checksum, and the generated module's import/export interface before replacing the file. Other language engines remain untouched.
6
+
7
+ The artifact uses Pagefind 1.5.2 at the immutable upstream commit recorded in `../../vendor/pagefind/manifest.json`. `../../vendor/pagefind/pagefind-1.5.2.patch` contains both corrections and their Rust regression tests; the upstream license is retained. The adjacent generated bindings exercise the actual WebAssembly module in Node tests against a real Pagefind index.
8
+
9
+ To reproduce the artifact, use the recorded Rust compiler, the `wasm32-unknown-unknown` target, Python 3.15, and the matching wasm-bindgen CLI:
10
+
11
+ ```sh
12
+ WASM_BINDGEN_BIN=/path/to/wasm-bindgen node src/search/rebuild-engine.mjs
13
+ ```
14
+
15
+ Build paths are remapped to synthetic source and dependency roots before sealing the artifact.
16
+
17
+ The rebuild verifies the pinned source patch and Cargo lock, runs the native regressions, and requires the resulting artifact to match its recorded checksum. The published package includes the sealed engine; ordinary documentation builds require no Rust toolchain.
@@ -0,0 +1,52 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { readFile, writeFile } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { gunzipSync } from 'node:zlib';
6
+
7
+ const vendor = new URL('../../vendor/pagefind/', import.meta.url);
8
+ const sha256 = (bytes) => createHash('sha256').update(bytes).digest('hex');
9
+ const magic = Buffer.from('pagefind_dcd');
10
+
11
+ function moduleInterface(bytes) {
12
+ const unpacked = gunzipSync(bytes);
13
+ if (!unpacked.subarray(0, magic.length).equals(magic)) throw new Error('Invalid Pagefind WASM envelope');
14
+ const module = new WebAssembly.Module(unpacked.subarray(magic.length));
15
+ return JSON.stringify({ imports: WebAssembly.Module.imports(module), exports: WebAssembly.Module.exports(module) });
16
+ }
17
+
18
+ export async function installEnglishSearchEngine(directory) {
19
+ const root = directory instanceof URL ? fileURLToPath(directory) : directory;
20
+ const pagefind = path.join(root, 'pagefind');
21
+ let entry;
22
+ try {
23
+ entry = JSON.parse(await readFile(path.join(pagefind, 'pagefind-entry.json'), 'utf8'));
24
+ } catch (error) {
25
+ if (error.code === 'ENOENT') return { applied: false };
26
+ throw error;
27
+ }
28
+ if (entry.languages?.en?.wasm !== 'en') return { applied: false };
29
+ const manifest = JSON.parse(await readFile(new URL('manifest.json', vendor), 'utf8'));
30
+ if (entry.version !== manifest.pagefindVersion) throw new Error(`Unsupported Pagefind version ${entry.version}`);
31
+ const replacement = await readFile(new URL('wasm.en.pagefind', vendor));
32
+ if (sha256(replacement) !== manifest.sha256) throw new Error('Pagefind search engine integrity mismatch');
33
+ const destination = path.join(pagefind, 'wasm.en.pagefind');
34
+ const original = await readFile(destination);
35
+ if (moduleInterface(original) !== moduleInterface(replacement))
36
+ throw new Error('Pagefind search engine ABI mismatch');
37
+ if (sha256(original) !== manifest.sha256) await writeFile(destination, replacement);
38
+ return { applied: true, sha256: manifest.sha256, pagefindVersion: manifest.pagefindVersion };
39
+ }
40
+
41
+ export function englishSearchEngineIntegration() {
42
+ return {
43
+ name: 'f5-pagefind-search-matching',
44
+ hooks: {
45
+ 'astro:build:done': async ({ dir, logger }) => {
46
+ const result = await installEnglishSearchEngine(dir);
47
+ if (result.applied)
48
+ logger.info(`English Pagefind matching engine ${result.pagefindVersion} sha256:${result.sha256}`);
49
+ },
50
+ },
51
+ };
52
+ }
@@ -0,0 +1,88 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
3
+ import { createRequire } from 'node:module';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ import { gunzipSync } from 'node:zlib';
7
+ import * as pagefind from 'pagefind';
8
+ import { afterAll, beforeAll, expect, it } from 'vitest';
9
+ import { installEnglishSearchEngine } from './pagefind-engine.mjs';
10
+
11
+ let directory: string;
12
+ const require = createRequire(import.meta.url);
13
+ const checksum = (bytes: Buffer) => createHash('sha256').update(bytes).digest('hex');
14
+ const unpack = (bytes: Buffer) => gunzipSync(bytes).subarray(12);
15
+
16
+ beforeAll(async () => {
17
+ directory = await mkdtemp(path.join(os.tmpdir(), 'pagefind-matching-'));
18
+ const { index, errors } = await pagefind.createIndex();
19
+ expect(errors).toEqual([]);
20
+ if (!index) throw new Error('Missing Pagefind index');
21
+ for (const [slug, title, body] of [
22
+ ['alias', 'Command alias', 'Search also answers to q.'],
23
+ ['manifest', 'Manifest guide', 'Create and apply manifests with xcsh.'],
24
+ ]) {
25
+ const result = await index.addHTMLFile({
26
+ sourcePath: `${slug}/index.html`,
27
+ content: `<html lang="en"><body><main data-pagefind-body><h1>${title}</h1><p>${body}</p></main></body></html>`,
28
+ });
29
+ expect(result.errors).toEqual([]);
30
+ }
31
+ const output = await index.writeFiles({ outputPath: path.join(directory, 'pagefind') });
32
+ expect(output.errors).toEqual([]);
33
+ await pagefind.close();
34
+ }, 30000);
35
+
36
+ afterAll(async () => {
37
+ await rm(directory, { recursive: true, force: true });
38
+ });
39
+
40
+ it('rejects unsupported engines before modifying their output', async () => {
41
+ const file = path.join(directory, 'pagefind/pagefind-entry.json');
42
+ const original = await readFile(file, 'utf8');
43
+ const engine = await readFile(path.join(directory, 'pagefind/wasm.en.pagefind'));
44
+ const entry = JSON.parse(original);
45
+ entry.version = '999.0.0';
46
+ await writeFile(file, JSON.stringify(entry));
47
+ await expect(installEnglishSearchEngine(directory)).rejects.toThrow('Unsupported Pagefind version');
48
+ expect(await readFile(path.join(directory, 'pagefind/wasm.en.pagefind'))).toEqual(engine);
49
+ await writeFile(file, original);
50
+ });
51
+
52
+ it('installs the sealed compatible engine and is idempotent', async () => {
53
+ const installed = await installEnglishSearchEngine(directory);
54
+ expect(installed.applied).toBe(true);
55
+ const file = path.join(directory, 'pagefind/wasm.en.pagefind');
56
+ const first = await readFile(file);
57
+ expect(checksum(first)).toBe(installed.sha256);
58
+ expect(await installEnglishSearchEngine(directory)).toEqual(installed);
59
+ expect(await readFile(file)).toEqual(first);
60
+ });
61
+
62
+ it('runs the actual WASM against a real index with strict word and forward-prefix matching', async () => {
63
+ await installEnglishSearchEngine(directory);
64
+ const backend = require('../../vendor/pagefind/pagefind-bindings.cjs');
65
+ const bytes = unpack(await readFile(path.join(directory, 'pagefind/wasm.en.pagefind')));
66
+ await backend({ module_or_path: bytes });
67
+ const entry = JSON.parse(await readFile(path.join(directory, 'pagefind/pagefind-entry.json'), 'utf8'));
68
+ const metadata = unpack(await readFile(path.join(directory, `pagefind/pagefind.${entry.languages.en.hash}.pf_meta`)));
69
+ const pointer = backend.init_pagefind(metadata);
70
+ expect(pointer).not.toBe(0);
71
+ for (const [query, expected] of [
72
+ ['qzxwvjknypvzrltg', 0],
73
+ ['qzxwvjknypvzrltg manifest', 0],
74
+ ['manifestunknownsuffix', 0],
75
+ ['manifest', 1],
76
+ ['manif', 1],
77
+ ['manifests', 1],
78
+ ['q', 1],
79
+ ] as const) {
80
+ for (const hash of JSON.parse(backend.request_indexes(pointer, query))) {
81
+ const chunk = unpack(await readFile(path.join(directory, `pagefind/index/${hash}.pf_index`)));
82
+ backend.load_index_chunk(pointer, chunk);
83
+ }
84
+ const result = JSON.parse(backend.search(pointer, query, query, '', '', false, false));
85
+ expect(result.results.length, query).toBe(expected);
86
+ expect(result.unfiltered_total, query).toBe(expected);
87
+ }
88
+ });
@@ -0,0 +1,78 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { createHash } from 'node:crypto';
3
+ import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+
8
+ const vendor = new URL('../../vendor/pagefind/', import.meta.url);
9
+ const manifest = JSON.parse(await readFile(new URL('manifest.json', vendor), 'utf8'));
10
+ const checksum = (bytes) => createHash('sha256').update(bytes).digest('hex');
11
+ const run = (command, args, options = {}) => {
12
+ const result = spawnSync(command, args, { encoding: 'utf8', stdio: 'pipe', ...options });
13
+ if (result.error || result.status !== 0) throw result.error || new Error(`${command} failed: ${result.stderr}`);
14
+ return result.stdout;
15
+ };
16
+ const wasmBindgen = process.env.WASM_BINDGEN_BIN || 'wasm-bindgen';
17
+ if (run('rustc', ['--version']).trim() !== manifest.rustCompiler) throw new Error('Use the recorded Rust compiler');
18
+ if (run(wasmBindgen, ['--version']).trim() !== `wasm-bindgen ${manifest.wasmBindgenVersion}`)
19
+ throw new Error('Use the recorded wasm-bindgen version');
20
+ const patch = await readFile(new URL('pagefind-1.5.2.patch', vendor));
21
+ if (checksum(patch) !== manifest.patchSha256) throw new Error('Source patch integrity mismatch');
22
+ const workspace = await mkdtemp(path.join(os.tmpdir(), 'pagefind-engine-source-'));
23
+ try {
24
+ const source = path.join(workspace, 'source');
25
+ run('git', ['clone', '--quiet', '--no-checkout', 'https://github.com/Pagefind/pagefind.git', source]);
26
+ run('git', ['checkout', '--detach', manifest.upstreamCommit], { cwd: source });
27
+ run('git', ['apply', '--unidiff-zero', fileURLToPath(new URL('pagefind-1.5.2.patch', vendor))], { cwd: source });
28
+ const cargoFile = path.join(source, 'pagefind_web/Cargo.toml');
29
+ const cargoHome = process.env.CARGO_HOME || path.join(os.homedir(), '.cargo');
30
+ const remap = [`--remap-path-prefix=${source}=/pagefind`, `--remap-path-prefix=${cargoHome}=/cargo`];
31
+ const cargoEnvironment = { ...process.env, CARGO_ENCODED_RUSTFLAGS: remap.join('\u001f') };
32
+
33
+ if (checksum(await readFile(path.join(source, 'pagefind_web/Cargo.lock'))) !== manifest.cargoLockSha256)
34
+ throw new Error('Cargo lock integrity mismatch');
35
+ run(
36
+ 'cargo',
37
+ ['test', '--manifest-path', cargoFile, '--locked', '--release', '--features', 'en', 'forward_prefix_tests'],
38
+ { env: cargoEnvironment },
39
+ );
40
+ run(
41
+ 'cargo',
42
+ [
43
+ 'build',
44
+ '--manifest-path',
45
+ cargoFile,
46
+ '--locked',
47
+ '--release',
48
+ '--features',
49
+ 'en',
50
+ '--target',
51
+ 'wasm32-unknown-unknown',
52
+ ],
53
+ { env: cargoEnvironment },
54
+ );
55
+ const output = path.join(workspace, 'bindings');
56
+ run(wasmBindgen, [
57
+ path.join(source, 'pagefind_web/target/wasm32-unknown-unknown/release/pagefind_web.wasm'),
58
+ '--target',
59
+ 'no-modules',
60
+ '--out-dir',
61
+ output,
62
+ ]);
63
+ const packet = path.join(workspace, 'wasm.en.pagefind');
64
+ run('python3', [
65
+ '-c',
66
+ 'import gzip,pathlib,sys; pathlib.Path(sys.argv[2]).write_bytes(gzip.compress(b"pagefind_dcd"+pathlib.Path(sys.argv[1]).read_bytes(),compresslevel=9,mtime=0))',
67
+ path.join(output, 'pagefind_web_bg.wasm'),
68
+ packet,
69
+ ]);
70
+ const bytes = await readFile(packet);
71
+ if (checksum(bytes) !== manifest.sha256) throw new Error(`Rebuilt engine differs: ${checksum(bytes)}`);
72
+ await writeFile(new URL('wasm.en.pagefind', vendor), bytes);
73
+ const bindings = await readFile(path.join(output, 'pagefind_web.js'), 'utf8');
74
+ await writeFile(new URL('pagefind-bindings.cjs', vendor), `${bindings}\nmodule.exports = wasm_bindgen;\n`);
75
+ console.log(`Reproduced Pagefind ${manifest.pagefindVersion} engine sha256:${manifest.sha256}`);
76
+ } finally {
77
+ await rm(workspace, { recursive: true, force: true });
78
+ }
@@ -0,0 +1,7 @@
1
+ Copyright 2022 Pagefind
2
+
3
+ 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:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ 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.
@@ -0,0 +1,13 @@
1
+ {
2
+ "pagefindVersion": "1.5.2",
3
+ "upstreamCommit": "bf17396721be637cc67c8ed7ead1dc7b8ac43d96",
4
+ "sha256": "bb201cd6460bacb5399d77ef12f076413655122dd54a529314ffa96bcace5d5d",
5
+ "patchSha256": "73db39627af42174a3a0732c8450f469d350ccbd4d715872eed9ae77a6c6fb96",
6
+ "wasmBindgenVersion": "0.2.117",
7
+ "rustCompiler": "rustc 1.99.0 (b940084d7 2026-09-28)",
8
+ "cargoLockSha256": "bd45029efb862c7aef38ccb524194eb8d36b0eb28ac7cc22467474d27d6556dd",
9
+ "pathRemapping": {
10
+ "source": "/pagefind",
11
+ "dependencies": "/cargo"
12
+ }
13
+ }
@@ -0,0 +1,91 @@
1
+ diff --git a/pagefind_web/Cargo.lock b/pagefind_web/Cargo.lock
2
+ index 1c15fdf..0ec7782 100644
3
+ --- a/pagefind_web/Cargo.lock
4
+ +++ b/pagefind_web/Cargo.lock
5
+ @@ -61 +61 @@ name = "pagefind_web"
6
+ -version = "0.0.0"
7
+ +version = "1.5.2"
8
+ diff --git a/pagefind_web/Cargo.toml b/pagefind_web/Cargo.toml
9
+ index de44fac..90669d5 100644
10
+ --- a/pagefind_web/Cargo.toml
11
+ +++ b/pagefind_web/Cargo.toml
12
+ @@ -3 +3 @@ name = "pagefind_web"
13
+ -version = "0.0.0"
14
+ +version = "1.5.2"
15
+ diff --git a/pagefind_web/src/search.rs b/pagefind_web/src/search.rs
16
+ index 24a75b2..61210ca 100644
17
+ --- a/pagefind_web/src/search.rs
18
+ +++ b/pagefind_web/src/search.rs
19
+ @@ -504,0 +505 @@ impl SearchIndex {
20
+ + maps.push(BitSet::new());
21
+ @@ -812,26 +813 @@ impl SearchIndex {
22
+ - let mut extensions = vec![];
23
+ - let mut longest_prefix = None;
24
+ - for (key, results) in self.words.iter() {
25
+ - if key.starts_with(term) {
26
+ - debug!({
27
+ - format! {"Adding {:#?} to the query", key}
28
+ - });
29
+ - extensions.push((key, results));
30
+ - } else if term.starts_with(key)
31
+ - && key.len() > longest_prefix.map(String::len).unwrap_or_default()
32
+ - {
33
+ - longest_prefix = Some(key);
34
+ - }
35
+ - }
36
+ - if extensions.is_empty() {
37
+ - debug!({ "No word extensions found, checking the inverse" });
38
+ - if let Some(longest_prefix) = longest_prefix {
39
+ - if let Some(results) = self.words.get(longest_prefix) {
40
+ - debug!({
41
+ - format! {"Adding the prefix {:#?} to the query", longest_prefix}
42
+ - });
43
+ - extensions.push((longest_prefix, results));
44
+ - }
45
+ - }
46
+ - }
47
+ - extensions
48
+ + self.words.iter().filter(|(word, _)| word.starts_with(term)).collect()
49
+ @@ -838,0 +815 @@ impl SearchIndex {
50
+ +
51
+ @@ -878,0 +856,40 @@ fn union_maps(mut maps: Vec<BitSet>) -> Option<BitSet> {
52
+ +
53
+ +#[cfg(test)]
54
+ +mod forward_prefix_tests {
55
+ + use super::*;
56
+ + use crate::{RankingWeights, WordData, Page, PageWord};
57
+ + use std::collections::BTreeMap;
58
+ + fn fixture() -> SearchIndex {
59
+ + SearchIndex {
60
+ + web_version: "1.5.2", playground_mode: false, generator_version: None,
61
+ + pages: vec![Page { hash: "fixture".into(), word_count: 2 }], average_page_length: 2.0, chunks: vec![], filter_chunks: BTreeMap::new(),
62
+ + words: ["q", "manifest"].into_iter().map(|word| (word.to_string(), WordData { pages: vec![PageWord { page: 0, locs: vec![(24, 0)], meta_locs: vec![] }], additional_variants: vec![] })).collect(),
63
+ + filters: BTreeMap::new(), sorts: BTreeMap::new(), meta_fields: vec![], ranking_weights: RankingWeights::default(),
64
+ + }
65
+ + }
66
+ + #[test]
67
+ + fn unknown_query_cannot_match_a_short_indexed_prefix() {
68
+ + let index = fixture();
69
+ + assert!(index.find_word_extensions("qzxwvjknypvzrltg").is_empty());
70
+ + assert!(index.find_word_extensions("manifestunknownsuffix").is_empty());
71
+ + }
72
+ + #[test]
73
+ + fn autocomplete_and_explicit_short_terms_still_match() {
74
+ + let index = fixture();
75
+ + for (query, expected) in [("manif", "manifest"), ("manifest", "manifest"), ("q", "q")] {
76
+ + let found = index.find_word_extensions(query);
77
+ + assert_eq!(found.len(), 1);
78
+ + assert_eq!(found[0].0, expected);
79
+ + }
80
+ + }
81
+ + #[test]
82
+ + fn english_inflections_are_stemmed_before_prefix_matching() {
83
+ + assert_eq!(stems_from_term("manifests")[0].as_ref(), "manifest");
84
+ + } #[test]
85
+ + fn every_word_in_a_multiword_query_must_match() {
86
+ + let index = fixture();
87
+ + assert!(index.search_term("qzxwvjknypvzrltg manifest", "qzxwvjknypvzrltg manifest", None, false).1.is_empty());
88
+ + assert_eq!(index.search_term("manifest", "manifest", None, false).1.len(), 1);
89
+ + }
90
+ +
91
+ +}
@@ -0,0 +1,381 @@
1
+ let wasm_bindgen = (function(exports) {
2
+ let script_src;
3
+ if (typeof document !== 'undefined' && document.currentScript !== null) {
4
+ script_src = new URL(document.currentScript.src, location.href).toString();
5
+ }
6
+
7
+ /**
8
+ * @param {number} ptr
9
+ * @param {string} filter
10
+ * @returns {number}
11
+ */
12
+ function add_synthetic_filter(ptr, filter) {
13
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
14
+ const len0 = WASM_VECTOR_LEN;
15
+ const ret = wasm.add_synthetic_filter(ptr, ptr0, len0);
16
+ return ret >>> 0;
17
+ }
18
+ exports.add_synthetic_filter = add_synthetic_filter;
19
+
20
+ /**
21
+ * @param {number} ptr
22
+ * @returns {number}
23
+ */
24
+ function enter_playground_mode(ptr) {
25
+ const ret = wasm.enter_playground_mode(ptr);
26
+ return ret >>> 0;
27
+ }
28
+ exports.enter_playground_mode = enter_playground_mode;
29
+
30
+ /**
31
+ * @param {number} ptr
32
+ * @returns {string}
33
+ */
34
+ function filters(ptr) {
35
+ let deferred1_0;
36
+ let deferred1_1;
37
+ try {
38
+ const ret = wasm.filters(ptr);
39
+ deferred1_0 = ret[0];
40
+ deferred1_1 = ret[1];
41
+ return getStringFromWasm0(ret[0], ret[1]);
42
+ } finally {
43
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
44
+ }
45
+ }
46
+ exports.filters = filters;
47
+
48
+ /**
49
+ * @param {Uint8Array} metadata_bytes
50
+ * @returns {number}
51
+ */
52
+ function init_pagefind(metadata_bytes) {
53
+ const ptr0 = passArray8ToWasm0(metadata_bytes, wasm.__wbindgen_malloc);
54
+ const len0 = WASM_VECTOR_LEN;
55
+ const ret = wasm.init_pagefind(ptr0, len0);
56
+ return ret >>> 0;
57
+ }
58
+ exports.init_pagefind = init_pagefind;
59
+
60
+ /**
61
+ * @param {number} ptr
62
+ * @param {Uint8Array} chunk_bytes
63
+ * @returns {number}
64
+ */
65
+ function load_filter_chunk(ptr, chunk_bytes) {
66
+ const ptr0 = passArray8ToWasm0(chunk_bytes, wasm.__wbindgen_malloc);
67
+ const len0 = WASM_VECTOR_LEN;
68
+ const ret = wasm.load_filter_chunk(ptr, ptr0, len0);
69
+ return ret >>> 0;
70
+ }
71
+ exports.load_filter_chunk = load_filter_chunk;
72
+
73
+ /**
74
+ * @param {number} ptr
75
+ * @param {Uint8Array} chunk_bytes
76
+ * @returns {number}
77
+ */
78
+ function load_index_chunk(ptr, chunk_bytes) {
79
+ const ptr0 = passArray8ToWasm0(chunk_bytes, wasm.__wbindgen_malloc);
80
+ const len0 = WASM_VECTOR_LEN;
81
+ const ret = wasm.load_index_chunk(ptr, ptr0, len0);
82
+ return ret >>> 0;
83
+ }
84
+ exports.load_index_chunk = load_index_chunk;
85
+
86
+ /**
87
+ * @param {number} ptr
88
+ * @returns {string}
89
+ */
90
+ function request_all_filter_indexes(ptr) {
91
+ let deferred1_0;
92
+ let deferred1_1;
93
+ try {
94
+ const ret = wasm.request_all_filter_indexes(ptr);
95
+ deferred1_0 = ret[0];
96
+ deferred1_1 = ret[1];
97
+ return getStringFromWasm0(ret[0], ret[1]);
98
+ } finally {
99
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
100
+ }
101
+ }
102
+ exports.request_all_filter_indexes = request_all_filter_indexes;
103
+
104
+ /**
105
+ * @param {number} ptr
106
+ * @param {string} filters
107
+ * @returns {string}
108
+ */
109
+ function request_filter_indexes(ptr, filters) {
110
+ let deferred2_0;
111
+ let deferred2_1;
112
+ try {
113
+ const ptr0 = passStringToWasm0(filters, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
114
+ const len0 = WASM_VECTOR_LEN;
115
+ const ret = wasm.request_filter_indexes(ptr, ptr0, len0);
116
+ deferred2_0 = ret[0];
117
+ deferred2_1 = ret[1];
118
+ return getStringFromWasm0(ret[0], ret[1]);
119
+ } finally {
120
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
121
+ }
122
+ }
123
+ exports.request_filter_indexes = request_filter_indexes;
124
+
125
+ /**
126
+ * @param {number} ptr
127
+ * @param {string} query
128
+ * @returns {string}
129
+ */
130
+ function request_indexes(ptr, query) {
131
+ let deferred2_0;
132
+ let deferred2_1;
133
+ try {
134
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
135
+ const len0 = WASM_VECTOR_LEN;
136
+ const ret = wasm.request_indexes(ptr, ptr0, len0);
137
+ deferred2_0 = ret[0];
138
+ deferred2_1 = ret[1];
139
+ return getStringFromWasm0(ret[0], ret[1]);
140
+ } finally {
141
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
142
+ }
143
+ }
144
+ exports.request_indexes = request_indexes;
145
+
146
+ /**
147
+ * @param {number} ptr
148
+ * @param {string} query
149
+ * @param {string} original_query
150
+ * @param {string} filter
151
+ * @param {string} sort
152
+ * @param {boolean} exact
153
+ * @param {boolean} exact_diacritics
154
+ * @returns {string}
155
+ */
156
+ function search(ptr, query, original_query, filter, sort, exact, exact_diacritics) {
157
+ let deferred5_0;
158
+ let deferred5_1;
159
+ try {
160
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
161
+ const len0 = WASM_VECTOR_LEN;
162
+ const ptr1 = passStringToWasm0(original_query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
163
+ const len1 = WASM_VECTOR_LEN;
164
+ const ptr2 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
165
+ const len2 = WASM_VECTOR_LEN;
166
+ const ptr3 = passStringToWasm0(sort, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
167
+ const len3 = WASM_VECTOR_LEN;
168
+ const ret = wasm.search(ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, exact, exact_diacritics);
169
+ deferred5_0 = ret[0];
170
+ deferred5_1 = ret[1];
171
+ return getStringFromWasm0(ret[0], ret[1]);
172
+ } finally {
173
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
174
+ }
175
+ }
176
+ exports.search = search;
177
+
178
+ /**
179
+ * @param {number} ptr
180
+ * @param {string} weights
181
+ * @returns {number}
182
+ */
183
+ function set_ranking_weights(ptr, weights) {
184
+ const ptr0 = passStringToWasm0(weights, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
185
+ const len0 = WASM_VECTOR_LEN;
186
+ const ret = wasm.set_ranking_weights(ptr, ptr0, len0);
187
+ return ret >>> 0;
188
+ }
189
+ exports.set_ranking_weights = set_ranking_weights;
190
+
191
+ function __wbg_get_imports() {
192
+ const import0 = {
193
+ __proto__: null,
194
+ __wbindgen_init_externref_table: function() {
195
+ const table = wasm.__wbindgen_externrefs;
196
+ const offset = table.grow(4);
197
+ table.set(0, undefined);
198
+ table.set(offset + 0, undefined);
199
+ table.set(offset + 1, null);
200
+ table.set(offset + 2, true);
201
+ table.set(offset + 3, false);
202
+ },
203
+ };
204
+ return {
205
+ __proto__: null,
206
+ "./pagefind_web_bg.js": import0,
207
+ };
208
+ }
209
+
210
+ function getStringFromWasm0(ptr, len) {
211
+ ptr = ptr >>> 0;
212
+ return decodeText(ptr, len);
213
+ }
214
+
215
+ let cachedUint8ArrayMemory0 = null;
216
+ function getUint8ArrayMemory0() {
217
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
218
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
219
+ }
220
+ return cachedUint8ArrayMemory0;
221
+ }
222
+
223
+ function passArray8ToWasm0(arg, malloc) {
224
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
225
+ getUint8ArrayMemory0().set(arg, ptr / 1);
226
+ WASM_VECTOR_LEN = arg.length;
227
+ return ptr;
228
+ }
229
+
230
+ function passStringToWasm0(arg, malloc, realloc) {
231
+ if (realloc === undefined) {
232
+ const buf = cachedTextEncoder.encode(arg);
233
+ const ptr = malloc(buf.length, 1) >>> 0;
234
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
235
+ WASM_VECTOR_LEN = buf.length;
236
+ return ptr;
237
+ }
238
+
239
+ let len = arg.length;
240
+ let ptr = malloc(len, 1) >>> 0;
241
+
242
+ const mem = getUint8ArrayMemory0();
243
+
244
+ let offset = 0;
245
+
246
+ for (; offset < len; offset++) {
247
+ const code = arg.charCodeAt(offset);
248
+ if (code > 0x7F) break;
249
+ mem[ptr + offset] = code;
250
+ }
251
+ if (offset !== len) {
252
+ if (offset !== 0) {
253
+ arg = arg.slice(offset);
254
+ }
255
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
256
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
257
+ const ret = cachedTextEncoder.encodeInto(arg, view);
258
+
259
+ offset += ret.written;
260
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
261
+ }
262
+
263
+ WASM_VECTOR_LEN = offset;
264
+ return ptr;
265
+ }
266
+
267
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
268
+ cachedTextDecoder.decode();
269
+ function decodeText(ptr, len) {
270
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
271
+ }
272
+
273
+ const cachedTextEncoder = new TextEncoder();
274
+
275
+ if (!('encodeInto' in cachedTextEncoder)) {
276
+ cachedTextEncoder.encodeInto = function (arg, view) {
277
+ const buf = cachedTextEncoder.encode(arg);
278
+ view.set(buf);
279
+ return {
280
+ read: arg.length,
281
+ written: buf.length
282
+ };
283
+ };
284
+ }
285
+
286
+ let WASM_VECTOR_LEN = 0;
287
+
288
+ let wasmModule, wasm;
289
+ function __wbg_finalize_init(instance, module) {
290
+ wasm = instance.exports;
291
+ wasmModule = module;
292
+ cachedUint8ArrayMemory0 = null;
293
+ wasm.__wbindgen_start();
294
+ return wasm;
295
+ }
296
+
297
+ async function __wbg_load(module, imports) {
298
+ if (typeof Response === 'function' && module instanceof Response) {
299
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
300
+ try {
301
+ return await WebAssembly.instantiateStreaming(module, imports);
302
+ } catch (e) {
303
+ const validResponse = module.ok && expectedResponseType(module.type);
304
+
305
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
306
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
307
+
308
+ } else { throw e; }
309
+ }
310
+ }
311
+
312
+ const bytes = await module.arrayBuffer();
313
+ return await WebAssembly.instantiate(bytes, imports);
314
+ } else {
315
+ const instance = await WebAssembly.instantiate(module, imports);
316
+
317
+ if (instance instanceof WebAssembly.Instance) {
318
+ return { instance, module };
319
+ } else {
320
+ return instance;
321
+ }
322
+ }
323
+
324
+ function expectedResponseType(type) {
325
+ switch (type) {
326
+ case 'basic': case 'cors': case 'default': return true;
327
+ }
328
+ return false;
329
+ }
330
+ }
331
+
332
+ function initSync(module) {
333
+ if (wasm !== undefined) return wasm;
334
+
335
+
336
+ if (module !== undefined) {
337
+ if (Object.getPrototypeOf(module) === Object.prototype) {
338
+ ({module} = module)
339
+ } else {
340
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
341
+ }
342
+ }
343
+
344
+ const imports = __wbg_get_imports();
345
+ if (!(module instanceof WebAssembly.Module)) {
346
+ module = new WebAssembly.Module(module);
347
+ }
348
+ const instance = new WebAssembly.Instance(module, imports);
349
+ return __wbg_finalize_init(instance, module);
350
+ }
351
+
352
+ async function __wbg_init(module_or_path) {
353
+ if (wasm !== undefined) return wasm;
354
+
355
+
356
+ if (module_or_path !== undefined) {
357
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
358
+ ({module_or_path} = module_or_path)
359
+ } else {
360
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
361
+ }
362
+ }
363
+
364
+ if (module_or_path === undefined && script_src !== undefined) {
365
+ module_or_path = script_src.replace(/\.js$/, "_bg.wasm");
366
+ }
367
+ const imports = __wbg_get_imports();
368
+
369
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
370
+ module_or_path = fetch(module_or_path);
371
+ }
372
+
373
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
374
+
375
+ return __wbg_finalize_init(instance, module);
376
+ }
377
+
378
+ return Object.assign(__wbg_init, { initSync }, exports);
379
+ })({ __proto__: null });
380
+
381
+ module.exports = wasm_bindgen;
Binary file