@xyd-js/ask-ai 0.0.0-build-1760f84-20251129221538 → 0.0.0-build-aebf977-20251203155725

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.
@@ -1,2 +1,2 @@
1
- import e,{useState as t}from"react";import{createComponent as o}from"@lit/react";import{A as r,a as s}from"../index-jph6adaq.js";import"lit";import"../_rollupPluginBabelHelpers-B0vHBMb8.js";const a=o({tagName:"ask-ai",elementClass:r,react:e,events:{onSubmit:"submit"}});function n(e){const[o,r]=t([]),[s,a]=t(!1),[n,i]=t(!1);return{messages:o,submit:async t=>{const o={id:Date.now().toString(),content:t.detail.message,type:"user"};r(e=>[...e,o]);const s=(Date.now()+1).toString(),c={id:s,content:"",type:"assistant",showActions:!1};a(!0),i(!0),r(e=>[...e,c]);try{const o=await fetch(e||"/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:t.detail.message})});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);const a=o.body?.getReader();if(!a)throw new Error("No response body");const c=new TextDecoder;let m="";const d=async()=>{try{for(;;){const{done:e,value:t}=await a.read();if(e)break;const o=c.decode(t,{stream:!0});m+=o,m&&n&&i(!1),r(e=>e.map(e=>e.id===s?{...e,content:m}:e))}}catch(e){throw console.error("Stream processing error:",e),e}};await d(),r(e=>e.map(e=>e.id===s?{...e,showActions:!0}:e))}catch(e){console.error("Error making request:",e),r(t=>t.map(t=>t.id===s?{...t,content:`Error: ${e instanceof Error?e.message:"Unknown error occurred"}`}:t))}finally{a(!1),i(!1)}},disabled:s,loading:n}}a.Message=o({tagName:"ask-ai-message",elementClass:s,react:e});export{a as AskAI,n as useAskAI};
1
+ import e,{useState as t}from"react";import{createComponent as o}from"@lit/react";import{A as r,a as s}from"../index-fwPxyHjz.js";import"lit";import"../_rollupPluginBabelHelpers-DdRaffu0.js";const a=o({tagName:"ask-ai",elementClass:r,react:e,events:{onSubmit:"submit"}});function n(e){const[o,r]=t([]),[s,a]=t(!1),[n,i]=t(!1);return{messages:o,submit:async t=>{const o={id:Date.now().toString(),content:t.detail.message,type:"user"};r(e=>[...e,o]);const s=(Date.now()+1).toString(),c={id:s,content:"",type:"assistant",showActions:!1};a(!0),i(!0),r(e=>[...e,c]);try{const o=await fetch(e||"/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:t.detail.message})});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);const a=o.body?.getReader();if(!a)throw new Error("No response body");const c=new TextDecoder;let m="";const d=async()=>{try{for(;;){const{done:e,value:t}=await a.read();if(e)break;const o=c.decode(t,{stream:!0});m+=o,m&&n&&i(!1),r(e=>e.map(e=>e.id===s?{...e,content:m}:e))}}catch(e){throw console.error("Stream processing error:",e),e}};await d(),r(e=>e.map(e=>e.id===s?{...e,showActions:!0}:e))}catch(e){console.error("Error making request:",e),r(t=>t.map(t=>t.id===s?{...t,content:`Error: ${e instanceof Error?e.message:"Unknown error occurred"}`}:t))}finally{a(!1),i(!1)}},disabled:s,loading:n}}a.Message=o({tagName:"ask-ai-message",elementClass:s,react:e});export{a as AskAI,n as useAskAI};
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyd-js/ask-ai",
3
- "version": "0.0.0-build-1760f84-20251129221538",
3
+ "version": "0.0.0-build-aebf977-20251203155725",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -1,4 +0,0 @@
1
- function t(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function r(t,r,e,n,o,i,u){try{var c=t[i](u),a=c.value}catch(t){return void e(t)}c.done?r(a):Promise.resolve(a).then(n,o)}function e(t){return function(){var e=this,n=arguments;return new Promise(function(o,i){var u=t.apply(e,n);function c(t){r(u,o,i,c,a,"next",t)}function a(t){r(u,o,i,c,a,"throw",t)}c(void 0)})}}function n(t,r,e){return r=f(r),function(t,r){if(r&&("object"==typeof r||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,y()?Reflect.construct(r,e||[],f(t).constructor):r.apply(t,e))}function o(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function i(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,O(n.key),n)}}function u(t,r,e){return r&&i(t.prototype,r),e&&i(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function c(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=j(t))||r){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,c=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return u=t.done,t},e:function(t){c=!0,i=t},f:function(){try{u||null==e.return||e.return()}finally{if(c)throw i}}}}function a(t,r,e){return(r=O(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function l(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&d(t,r)}function y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(y=function(){return!!t})()}function p(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function s(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?p(Object(e),!0).forEach(function(r){a(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):p(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function b(){
2
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
3
- var t,r,e="function"==typeof Symbol?Symbol:{},n=e.iterator||"@@iterator",o=e.toStringTag||"@@toStringTag";function i(e,n,o,i){var a=n&&n.prototype instanceof c?n:c,f=Object.create(a.prototype);return v(f,"_invoke",function(e,n,o){var i,c,a,f=0,l=o||[],y=!1,p={p:0,n:0,v:t,a:s,f:s.bind(t,4),d:function(r,e){return i=r,c=0,a=t,p.n=e,u}};function s(e,n){for(c=e,a=n,r=0;!y&&f&&!o&&r<l.length;r++){var o,i=l[r],s=p.p,b=i[2];e>3?(o=b===n)&&(a=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=t):i[0]<=s&&((o=e<2&&s<i[1])?(c=0,p.v=n,p.n=i[1]):s<b&&(o=e<3||i[0]>n||n>b)&&(i[4]=e,i[5]=n,p.n=b,c=0))}if(o||e>1)return u;throw y=!0,n}return function(o,l,b){if(f>1)throw TypeError("Generator is already running");for(y&&1===l&&s(l,b),c=l,a=b;(r=c<2?t:a)||!y;){i||(c?c<3?(c>1&&(p.n=-1),s(c,a)):p.n=a:p.v=a);try{if(f=2,i){if(c||(o="next"),r=i[o]){if(!(r=r.call(i,a)))throw TypeError("iterator result is not an object");if(!r.done)return r;a=r.value,c<2&&(c=0)}else 1===c&&(r=i.return)&&r.call(i),c<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=t}else if((r=(y=p.n<0)?a:e.call(n,p))!==u)break}catch(r){i=t,c=1,a=r}finally{f=1}}return{value:r,done:y}}}(e,o,i),!0),f}var u={};function c(){}function a(){}function f(){}r=Object.getPrototypeOf;var l=[][n]?r(r([][n]())):(v(r={},n,function(){return this}),r),y=f.prototype=c.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,v(t,o,"GeneratorFunction")),t.prototype=Object.create(y),t}return a.prototype=f,v(y,"constructor",f),v(f,"constructor",a),a.displayName="GeneratorFunction",v(f,o,"GeneratorFunction"),v(y),v(y,o,"Generator"),v(y,n,function(){return this}),v(y,"toString",function(){return"[object Generator]"}),(b=function(){return{w:i,m:p}})()}function v(t,r,e,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}v=function(t,r,e,n){function i(r,e){v(t,r,function(t){return this._invoke(r,e,t)})}r?o?o(t,r,{value:e,enumerable:!n,configurable:!n,writable:!n}):t[r]=e:(i("next",0),i("throw",1),i("return",2))},v(t,r,e,n)}function d(t,r){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},d(t,r)}function h(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,u,c=[],a=!0,f=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;a=!1}else for(;!(a=(n=i.call(e)).done)&&(c.push(n.value),c.length!==r);a=!0);}catch(t){f=!0,o=t}finally{try{if(!a&&null!=e.return&&(u=e.return(),Object(u)!==u))return}finally{if(f)throw o}}return c}}(t,r)||j(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(r){return function(r){if(Array.isArray(r))return t(r)}(r)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||j(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(t){var r=function(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,r);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof r?r:r+""}function w(t){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(t)}function j(r,e){if(r){if("string"==typeof r)return t(r,e);var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(r,e):void 0}}function g(t){var r="function"==typeof Map?new Map:void 0;return g=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(r){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return function(t,r,e){if(y())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,r);var o=new(t.bind.apply(t,n));return e&&d(o,e.prototype),o}(t,arguments,f(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),d(e,t)},g(t)}export{w as _,c as a,s as b,l as c,u as d,g as e,o as f,n as g,m as h,e as i,b as j,a as k,h as l};
4
- //# sourceMappingURL=_rollupPluginBabelHelpers-B0vHBMb8.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_rollupPluginBabelHelpers-B0vHBMb8.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}