Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pattern: detect wasm availability #692

Open
1 task
irthomasthomas opened this issue Mar 5, 2024 · 1 comment
Open
1 task

pattern: detect wasm availability #692

irthomasthomas opened this issue Mar 5, 2024 · 1 comment
Labels
code-generation code generation models and tools like copilot and aider data-validation Validating data structures and formats New-Label Choose this option if the existing labels are insufficient to describe the content accurately openai OpenAI APIs, LLMs, Recipes and Evals programming-languages Topics related to programming languages and their features. source-code Code snippets Sqlite Sqlite DB and tools

Comments

@irthomasthomas
Copy link
Owner

TITLE: static-wiki/src/sqlite.js at b0ae18ed02ca64263075c3516c38a504f46e10c4 · segfall/static-wiki

DESCRIPTION:

import { createDbWorker } from "sql.js-httpvfs"
import db from "../db.js";

export default async function (key='en') {
    // sadly there's no good way to package workers and wasm directly so you need a way to get these two URLs from your bundler.
    // This is the webpack5 way to create a asset bundle of the worker and wasm:
    const workerUrl = new URL(
        "/sqlite.worker.js",
        window.location.origin,
    );
    const wasmUrl = new URL(
        "/sql-wasm.wasm",
        window.location.origin,
    );
    // the legacy webpack4 way is something like `import wasmUrl from "file-loader!sql.js-httpvfs/dist/sql-wasm.wasm"`.
    // the config is either the url to the create_db script, or a inline configuration:
    const config = {
        from: "inline",
        config: {
            serverMode: "full", // file is just a plain old full sqlite database
            requestChunkSize: 8192, // the page size of the  sqlite database (by default 4096)
            url: window.location.origin.includes("localhost") ? db[key].dev : db[key].production // url to the database (relative or full)
        }
    }

    const worker = await createDbWorker(
        [config],
        workerUrl.toString(), wasmUrl.toString()
    );
    // you can also pass multiple config objects which can then be used as separate database schemas with `ATTACH virtualFilename as schemaname`, where virtualFilename is also set in the config object.
    // worker.db is a now SQL.js instance except that all functions return Promises.

    return worker;
}

URL: Link to the code

Suggested labels

{'label-name': 'web-development', 'label-description': 'Includes code libraries and tools for developing web applications.', 'confidence': 77.7}

@irthomasthomas irthomasthomas added code-generation code generation models and tools like copilot and aider data-validation Validating data structures and formats New-Label Choose this option if the existing labels are insufficient to describe the content accurately openai OpenAI APIs, LLMs, Recipes and Evals programming-languages Topics related to programming languages and their features. source-code Code snippets Sqlite Sqlite DB and tools labels Mar 5, 2024
@irthomasthomas
Copy link
Owner Author

irthomasthomas commented Mar 5, 2024

Related content

#692 - Similarity score: 0.98

#74 - Similarity score: 0.91

#691 - Similarity score: 0.91

#695 - Similarity score: 0.88

#678 - Similarity score: 0.84

#325 - Similarity score: 0.84

@irthomasthomas irthomasthomas changed the title static-wiki/src/sqlite.js at b0ae18ed02ca64263075c3516c38a504f46e10c4 · segfall/static-wiki pattern: detect wasm availability Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-generation code generation models and tools like copilot and aider data-validation Validating data structures and formats New-Label Choose this option if the existing labels are insufficient to describe the content accurately openai OpenAI APIs, LLMs, Recipes and Evals programming-languages Topics related to programming languages and their features. source-code Code snippets Sqlite Sqlite DB and tools
Projects
None yet
Development

No branches or pull requests

1 participant