diff --git a/.vscode/settings.json b/.vscode/settings.json index 0d052137b..13a32ba3c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,5 +13,6 @@ "editor.defaultFormatter": "esbenp.prettier-vscode" }, "cSpell.words": ["huggingface"], - "deno.enablePaths": ["./e2e/deno"] + "deno.enablePaths": ["./e2e/deno"], + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/CODEOWNERS b/CODEOWNERS index 8ea104812..80148fb6c 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -21,3 +21,6 @@ # Ownership for the gguf Package /packages/gguf @mishig25 @julien-c + +# Ownership for the space-header Package +/packages/space-header @enzostvs diff --git a/README.md b/README.md index a74f18bf0..44f6f5a2b 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ This is a collection of JS libraries to interact with the Hugging Face API, with - [@huggingface/agents](packages/agents/README.md): Interact with HF models through a natural language interface - [@huggingface/gguf](packages/gguf/README.md): A GGUF parser that works on remotely hosted files. - [@huggingface/tasks](packages/tasks/README.md): The definition files and source-of-truth for the Hub's main primitives like pipeline tasks, model libraries, etc. +- [@huggingface/space-header](packages/space-header/README.md): Use the Space `mini_header` outside Hugging Face We use modern features to avoid polyfills and dependencies, so the libraries will only work on modern browsers / Node.js >= 18 / Bun / Deno. diff --git a/docs/_toctree.yml b/docs/_toctree.yml index e051e87d6..948c70e79 100644 --- a/docs/_toctree.yml +++ b/docs/_toctree.yml @@ -21,3 +21,13 @@ title: Use Agents to run multi-modal workflows from a natural language API - local: agents/modules title: API Reference +- title: "@huggingface/space-header" + isExpanded: true + sections: + - local: space-header/README + title: Use Space mini_header in your app +- title: "@huggingface/gguf" + isExpanded: true + sections: + - local: gguf/README + title: Parse local and remote GGUF files diff --git a/packages/doc-internal/package.json b/packages/doc-internal/package.json index 0ddba04de..e8fa9ad09 100644 --- a/packages/doc-internal/package.json +++ b/packages/doc-internal/package.json @@ -5,7 +5,7 @@ "description": "Package to generate doc for other @huggingface packages", "private": true, "scripts": { - "start": "pnpm run fix-cdn-versions && pnpm run doc-hub && pnpm run doc-inference && pnpm run doc-agents && cp ../../README.md ../../docs/index.md && pnpm run update-toc && pnpm run fix-md-links && pnpm run fix-md-headinghashlinks", + "start": "pnpm run fix-cdn-versions && pnpm run doc-hub && pnpm run doc-inference && pnpm run doc-agents && pnpm run doc-space-header && pnpm run doc-gguf && cp ../../README.md ../../docs/index.md && pnpm run update-toc && pnpm run fix-md-links && pnpm run fix-md-headinghashlinks", "lint": "eslint --quiet --fix --ext .cjs,.ts .", "lint:check": "eslint --ext .cjs,.ts .", "format": "prettier --write .", @@ -13,6 +13,8 @@ "doc-hub": "typedoc --tsconfig ../hub/tsconfig.json --githubPages false --plugin typedoc-plugin-markdown --out ../../docs/hub --hideBreadcrumbs --hideInPageTOC --sourceLinkTemplate https://github.com/huggingface/huggingface.js/blob/main/{path}#L{line} ../hub/index.ts", "doc-inference": "typedoc --tsconfig ../inference/tsconfig.json --githubPages false --plugin typedoc-plugin-markdown --out ../../docs/inference --hideBreadcrumbs --hideInPageTOC --sourceLinkTemplate https://github.com/huggingface/huggingface.js/blob/main/{path}#L{line} ../inference/src/index.ts", "doc-agents": "typedoc --tsconfig ../agents/tsconfig.json --githubPages false --plugin typedoc-plugin-markdown --out ../../docs/agents --hideBreadcrumbs --hideInPageTOC --sourceLinkTemplate https://github.com/huggingface/huggingface.js/blob/main/{path}#L{line} ../agents/src/index.ts", + "doc-gguf": "mkdir -p ../../docs/gguf && cp ../../packages/gguf/README.md ../../docs/gguf/README.md", + "doc-space-header": "mkdir -p ../../docs/space-header && cp ../../packages/space-header/README.md ../../docs/space-header/README.md", "update-toc": "tsx update-toc.ts", "fix-cdn-versions": "tsx fix-cdn-versions.ts", "fix-md-links": "tsx fix-md-links.ts", diff --git a/packages/space-header/README.md b/packages/space-header/README.md new file mode 100644 index 000000000..4da989f35 --- /dev/null +++ b/packages/space-header/README.md @@ -0,0 +1,59 @@ +# 🤗 Hugging Face Space Header + +A Typescript powered wrapper for the Space `mini_header` feature. + +## Install + +```console +pnpm add @huggingface/space-header + +npm add @huggingface/space-header + +yarn add @huggingface/space-header +``` + +### Deno + +```ts +// esm.sh +import { init } from "https://esm.sh/@huggingface/space-header" +// or npm: +import { init } from "npm:@huggingface/space-header" +``` + +### Initialize +```ts +import { init } from "@huggingface/space-header"; + +// ... + +init(":user/:spaceId"); +// init("enzostvs/lora-studio") for example +``` +❗Important note: The `init` method must be called on the client side. + +## Usage + +Uses the `target` option to inject the space-header into another DOM element + +```ts +const app = document.getElementById("app"); + +// ... + +init(":user/:spaceId", { + target: app +}); +``` + +If you already have the space data, you can also pass it as a parameter to avoid a fetch + +```ts +init(space); + +// space = { +// id: string; +// likes: number; +// author: string; +// } +``` \ No newline at end of file diff --git a/packages/space-header/package.json b/packages/space-header/package.json index 17073b538..242a16ab6 100644 --- a/packages/space-header/package.json +++ b/packages/space-header/package.json @@ -1,6 +1,6 @@ { "name": "@huggingface/space-header", - "version": "1.0.0", + "version": "0.0.0", "description": "", "main": "index.js", "type": "module", @@ -15,7 +15,7 @@ "prepublishOnly": "pnpm run build" }, "keywords": [], - "author": "", + "author": "Hugging Face", "license": "ISC", "devDependencies": { "tsup": "^8.1.0",