npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

msc-built-in-ai-embedding

v1.0.1

Published

<msc-built-in-ai-embedding /> is a web component based on Chrome Built-in AI Semantic Embedder API. Web developers could use <msc-built-in-ai-embedding /> to generate vector embeddings with EmbeddingGemma and provide vivid features like semantic search or

Readme

msc-built-in-ai-embedding

Published on webcomponents.org DeepScan grade

<msc-built-in-ai-embedding /> is a web component based on Chrome Built-in AI Semantic Embedder API. Web developers could use <msc-built-in-ai-embedding /> to generate vector embeddings with EmbeddingGemma and provide vivid features like semantic search or text similarity comparison.

<msc-built-in-ai-embedding /> is a non-UI component. But it will provide current status in data-status. That means web developers have maximum creation to build UI through this information.

<msc-built-in-ai-embedding />

Basic Usage

<msc-built-in-ai-embedding /> is a web component. All we need to do is put the required script into your HTML document. Then follow <msc-built-in-ai-embedding />'s html structure and everything will be all set.

  • Required Script

    <script
      type="module"
      src="https://unpkg.com/msc-built-in-ai-embedding/mjs/wc-msc-built-in-ai-embedding.js">        
    </script>
  • Structure

    Put <msc-built-in-ai-embedding /> into HTML document. It will have different functions and looks with attribute mutation.

    <msc-built-in-ai-embedding>
      <!-- style by yourself -->
      <button type="button">
        Try AI features
      </button>
    </msc-built-in-ai-embedding>

There will be serverial status to indicate Built-in AI status. Check msc-built-in-ai-embedding[data-status] out.

  • available:AI ready to use.
  • downloadable:Need to download LLM first (browser supported).
  • downloading:LLM downloading (browser supported).
  • unsupported:current browser doesn't support Built-in AI Semantic Embedder API.
  • unavailable:current browser doesn't support Built-in AI Semantic Embedder API.

Once <msc-built-in-ai-embedding /> in status: downloading, <msc-built-in-ai-embedding /> will show download progress in attribute data-progress.

Such as:

<msc-built-in-ai-embedding
  data-status="downloading"
  data-progress="45"
>
  <button type="button">
    Try AI features
  </button>
</msc-built-in-ai-embedding>

JavaScript Instantiation

<msc-built-in-ai-embedding /> could also use JavaScript to create DOM element. Here comes some examples.

<script type="module">
import { MscBuiltInAiEmbedding } from 'https://unpkg.com/msc-built-in-ai-embedding/mjs/wc-msc-built-in-ai-embedding.js';

const buttonTemplate = document.querySelector('.my-button-template');

// use DOM api
const nodeA = document.createElement('msc-built-in-ai-embedding');
document.body.appendChild(nodeA);
nodeA.appendChild(buttonTemplate.content.cloneNode(true));

// new instance with Class
const nodeB = new MscBuiltInAiEmbedding();
document.body.appendChild(nodeB);
nodeB.appendChild(buttonTemplate.content.cloneNode(true));
</script>

Use <msc-built-in-ai-embedding />

<msc-built-in-ai-embedding /> provide same method as Chrome Built-in AI Semantic Embedder API. That means web developers need to create() embedder before embed().

  • Embed a single string
<script type="module">
const ai = document.querySelector('msc-built-in-ai-embedding');

if (['unavailable', 'unsupported'].includes(ai.status)) {
  console.log('The current browser does not support the Built-in AI Semantic Embedder API.');
} else {
  try {
    await ai.create();
    const result = await ai.embed(
      "The quick brown fox jumps over the lazy dog.",
      { taskType: "semantic-similarity" }
    );
    ai.destroy();

    console.log(result);
  } catch(err) {
    console.log(err);
  }
}
</script>
  • Embed a batch of strings
<script type="module">
const ai = document.querySelector('msc-built-in-ai-embedding');

if (['unavailable', 'unsupported'].includes(ai.status)) {
  console.log('The current browser does not support the Built-in AI Semantic Embedder API.');
} else {
  try {
    await ai.create();
    const result = await ai.embed(
      [
        "Built-in AI APIs use on-device models.",
        "Embeddings are high-dimensional vectors representing semantic meaning.",
      ],
      { taskType: "semantic-similarity" }
    );
    ai.destroy();

    console.log(result);
  } catch(err) {
    console.log(err);
  }
}
</script>

Property

| Property Name | Type | Description | | ----------- | ----------- | ----------- | | status | String | Getter current status. (availabledownloadabledownloadingunsupportedunavailable) |

Mathods

| Mathod Signature | Description | | ----------- | ----------- | | create() | Create the embedder instance. | | embed(string = '' [, options = {}]) | Embed a single string or batch of strings. The embed function takes an optional parameter called taskType which allows you to optimize the embedding quality for specific use cases. | | destroy() | Destroy current embedder instance. |

※ Note: Except for destroy(), all the above methods are async.

Events

| Event Signature | Description | | ----------- | ----------- | | msc-built-in-ai-embedding-ready | Fired when LLM download done. | | msc-built-in-ai-embedding-download-progress | Fired when LLM downloading. Developers could gather result information through event.detail. |

Reference