Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

msc-ai-assistant

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

msc-ai-assistant - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

121

mjs/wc-msc-ai-assistant.js

@@ -6,3 +6,3 @@ import { _wcl } from './common-lib.js';

import 'https://unpkg.com/dompurify/dist/purify.min.js';
import 'https://unpkg.com/msc-circle-progress/mjs/wc-msc-circle-progress.js';
/*

@@ -140,6 +140,2 @@ reference:

&:popover-open {
@starting-style {
opacity: 0;
}
opacity: 1;

@@ -160,2 +156,8 @@ }

@starting-style {
&:popover-open {
opacity: 0;
}
}
.ai-assistant__head {

@@ -690,2 +692,3 @@ display: flex;

let available = 'no';
/*
if (window.ai?.[NS]) {

@@ -705,3 +708,111 @@ const {

}
*/
const templateProgressSet = `
<style>
#built-in-ai-loading-progress {
--size: 50px;
inset-inline-start: calc(100dvi - var(--size) - 8px);
inset-block-start: calc(100dvb - var(--size) - 8px);
inline-size: var(--size);
aspect-ratio: 1/1;
border-radius: var(--size);
background-color: rgba(0 0 0/.8);
padding: 5px;
box-sizing: border-box;
&::after {
position: absolute;
inset-inline-start: 50%;
inset-block-start: 50%;
content: 'AI';
color: rgba(255 255 255);
font-size: 16px;
transform: translate(-50%, -50%);
}
msc-circle-progress {
--msc-circle-progress-font-size: 0px;
--msc-circle-progress-font-color: rgba(255 255 255);
--msc-circle-progress-color: rgba(84 129 236);
}
&:popover-open {
opacity: 1;
scale: 1;
}
opacity: 0;
scale: .001;
transition-property: opacity,scale,display;
transition-duration: 250ms;
transition-behavior: allow-discrete;
@starting-style {
&:popover-open {
opacity: 0;
scale: .001;
}
}
}
</style>
<div id="built-in-ai-loading-progress" popover>
<msc-circle-progress size="5" value="0" max="100" round></msc-circle-progress>
</div>
`;
if (window.ai?.[NS]) {
const updateConfig = async() => {
const {
available: A,
defaultTemperature,
defaultTopK
} = await window.ai[NS].capabilities();
available = A;
defaults.config = {
systemPrompt: '',
temperature: defaultTemperature,
topK: defaultTopK
};
};
const { available: A } = await window.ai[NS].capabilities();
if (A === 'after-download') {
// setup download progress
document.body.insertAdjacentHTML('beforeend', templateProgressSet);
const popover = document.querySelector('#built-in-ai-loading-progress');
const progress = document.querySelector('#built-in-ai-loading-progress msc-circle-progress');
popover.showPopover();
requestAnimationFrame(() => progress.refresh());
await window.ai[NS].create({
monitor(m) {
m.addEventListener('downloadprogress',
async (e) => {
const { loaded, total } = e;
const value = Math.floor((loaded / total) * 100);
progress.value = value;
// complete loading
if (loaded >= total) {
popover.hidePopover();
await updateConfig();
}
}
);
}
});
} else {
await updateConfig();
}
}
export class MscAiAssistant extends HTMLElement {

@@ -708,0 +819,0 @@ #data;

2

package.json
{
"name": "msc-ai-assistant",
"version": "1.0.3",
"version": "1.0.4",
"description": "<msc-ai-assistant /> is a web component based on Chrome Built-in AI Prompt API. Web developers could use <msc-ai-assistant /> to help user consult anything they like to know.",

@@ -5,0 +5,0 @@ "main": "index.html",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc