@priscilla-ai/vue 1.0.5 → 1.0.6

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.
package/dist/index.cjs CHANGED
@@ -1 +1,2 @@
1
- (function(r,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("axios")):typeof define=="function"&&define.amd?define(["exports","vue","axios"],t):(r=typeof globalThis<"u"?globalThis:r||self,t(r.PriscillaAI={},r.Vue,r.axios))})(this,(function(r,t,s){"use strict";const p=t.defineComponent({name:"PriscillaAI",props:{xpath:{type:String,required:!0,validator:e=>e.trim().length>0},chapterId:{type:Number,required:!0,validator:e=>Number.isInteger(e)&&e>0},programId:{type:Number,required:!0,validator:e=>Number.isInteger(e)&&e>0}},data(){return{isOpen:!1,loading:!1,hint:"",error:"",extractedContent:"",cancelSource:null}},computed:{hasResult(){return!!(this.hint||this.extractedContent)},buttonLabel(){return this.loading?"Fetching…":"Get Hint"}},beforeUnmount(){this.cancelSource?.cancel("Component unmounted")},methods:{toggle(){this.isOpen=!this.isOpen},extractCodeFromXPath(){let e;try{e=document.evaluate(this.xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}catch{throw new Error(`Invalid XPath expression: "${this.xpath}"`)}if(!e)throw new Error("No element matched the provided XPath.");const n=e instanceof HTMLTextAreaElement?e.value:e.textContent;if(!n?.trim())throw new Error("Matched element contains no extractable text.");return n.trim()},async fetchHint(){this.cancelSource?.cancel("Superseded by newer request"),this.loading=!0,this.error="",this.hint="",this.extractedContent="";try{const e=this.extractCodeFromXPath();this.extractedContent=e;const n=l();if(!n)throw new Error("API endpoint not configured. Please initialise the plugin.");this.cancelSource=s.CancelToken.source();const{data:o}=await s.post(n,{content:e,chapterId:this.chapterId,programId:this.programId},{cancelToken:this.cancelSource.token});this.hint=o.hint?.trim()||"No hint available for this submission."}catch(e){if(s.isCancel(e))return;e instanceof Error?this.error=e.message:s.isAxiosError(e)?this.error=`API ${e.response?.status??"Error"}: ${e.message}`:this.error="An unexpected error occurred."}finally{this.loading=!1}},clearHint(){this.hint="",this.extractedContent="",this.error="",this.cancelSource?.cancel("Cleared by user")}}}),h=(e,n)=>{const o=e.__vccOpts||e;for(const[c,d]of n)o[c]=d;return o},m={class:"priscilla-ai"},g=["aria-expanded","aria-label"],u={"aria-hidden":"true"},f={key:0,class:"assistant-window",role:"dialog","aria-label":"Priscilla AI Code Hint Assistant"},E={class:"assistant-body"},y={class:"code-block"},C={class:"hint-text"},b={key:2,class:"error-message",role:"alert"},k={key:3,class:"loading-spinner","aria-live":"polite"},N={class:"metadata"},I={class:"assistant-footer"},P=["disabled"];function V(e,n,o,c,d,B){return t.openBlock(),t.createElementBlock("div",m,[t.createElementVNode("button",{class:"assistant-button","aria-expanded":e.isOpen,"aria-label":e.isOpen?"Close hint assistant":"Open hint assistant",onClick:n[0]||(n[0]=(...i)=>e.toggle&&e.toggle(...i))},[t.createElementVNode("span",u,t.toDisplayString(e.isOpen?"✖️":"🤖"),1)],8,g),e.isOpen?(t.openBlock(),t.createElementBlock("div",f,[n[5]||(n[5]=t.createElementVNode("header",{class:"assistant-header"},"Priscilla AI Code Hint Assistant",-1)),t.createElementVNode("div",E,[e.extractedContent?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[n[3]||(n[3]=t.createElementVNode("p",null,[t.createElementVNode("strong",null,"Extracted Code:")],-1)),t.createElementVNode("pre",y,t.toDisplayString(e.extractedContent),1)],64)):t.createCommentVNode("",!0),e.hint?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[n[4]||(n[4]=t.createElementVNode("p",null,[t.createElementVNode("strong",null,"💡 Hint:")],-1)),t.createElementVNode("p",C,t.toDisplayString(e.hint),1)],64)):t.createCommentVNode("",!0),e.error?(t.openBlock(),t.createElementBlock("p",b,"❌ "+t.toDisplayString(e.error),1)):t.createCommentVNode("",!0),e.loading?(t.openBlock(),t.createElementBlock("p",k,"⏳ Fetching hint…")):t.createCommentVNode("",!0),t.createElementVNode("p",N,[t.createElementVNode("small",null,"Chapter "+t.toDisplayString(e.chapterId)+" · Program "+t.toDisplayString(e.programId),1)])]),t.createElementVNode("footer",I,[t.createElementVNode("button",{class:"primary-button",disabled:e.loading,onClick:n[1]||(n[1]=(...i)=>e.fetchHint&&e.fetchHint(...i))},t.toDisplayString(e.buttonLabel),9,P),e.hasResult?(t.openBlock(),t.createElementBlock("button",{key:0,class:"secondary-button",onClick:n[2]||(n[2]=(...i)=>e.clearHint&&e.clearHint(...i))},"Clear")):t.createCommentVNode("",!0)])])):t.createCommentVNode("",!0)])}const A=h(p,[["render",V]]);let a="";function S(e){return{install(n){a=e,n.config.globalProperties.$priscillaAIEndpoint=a,n.component("PriscillaAI",A)}}}function l(){return a}r.createPriscillaAI=S,r.getPriscillaAIEndpoint=l,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(n,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("axios")):typeof define=="function"&&define.amd?define(["exports","vue","axios"],t):(n=typeof globalThis<"u"?globalThis:n||self,t(n.PriscillaAI={},n.Vue,n.axios))})(this,(function(n,t,a){"use strict";var d=document.createElement("style");d.textContent=`@font-face{font-family:Roboto;font-style:normal;font-weight:100;font-stretch:100%;src:url(https://fonts.gstatic.com/s/roboto/v51/KFO7CnqEu92Fr1ME7kSn66aGLdTylUAMa3GUBGEe.woff2) format("woff2");unicode-range:U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}.app-container{display:flex;flex-direction:column;height:100vh}.navbar{display:flex;align-items:center;justify-content:center;background:#fff;border-bottom:1px solid #ddd;padding:10px 0;gap:20px}.nav-items{display:flex;gap:16px}.nav-item{background:#e5e5e5;width:40px;height:40px;border-radius:6px;display:flex;align-items:center;justify-content:center;cursor:pointer;position:relative}.main-content{flex:1;display:flex;flex-direction:column;justify-content:center;align-items:center;padding:40px}.code-section{background:#f5f5f5;padding:20px;border-radius:8px;max-width:600px;margin-top:30px}.code-section pre{background:#2d2d2d;color:#f8f8f2;padding:15px;border-radius:6px;overflow-x:auto;font-family:Courier New,monospace;font-size:14px;line-height:1.5}.priscilla-ai{position:relative;font-family:Roboto,sans-serif}.assistant-button{background:#e5e5e5;border:none;width:40px;height:40px;border-radius:6px;font-size:18px;cursor:pointer;transition:background-color .2s}.assistant-button:hover{background:#d0d0d0}.assistant-button:disabled{opacity:.6;cursor:not-allowed}.assistant-window{position:absolute;top:50px;right:0;width:350px;height:auto;max-height:500px;background:#f8f8f8;box-shadow:0 4px 12px #00000026;border-radius:8px;display:flex;flex-direction:column;z-index:1000}.assistant-header{background:#464767;color:#fff;padding:12px;font-weight:700;text-align:center;border-radius:8px 8px 0 0}.assistant-body{flex:1;padding:12px;overflow-y:auto;max-height:350px}.extracted-content{margin-bottom:12px}.code-block{background:#2d2d2d;color:#f8f8f2;padding:8px;border-radius:4px;font-family:Courier New,monospace;font-size:12px;overflow-x:auto;margin:8px 0;max-height:150px;overflow-y:auto}.hint-section{background:#e8f5e9;padding:10px;border-left:3px solid #4caf50;border-radius:4px;margin:10px 0}.hint-text{color:#2e7d32;margin:5px 0;font-size:14px}.error-message{background:#ffebee;color:#c62828;padding:10px;border-radius:4px;margin:10px 0;border-left:3px solid #f44336}.loading-spinner{text-align:center;padding:10px;color:#666}.metadata{font-size:12px;color:#999;margin-top:10px;padding-top:10px;border-top:1px solid #ddd}.assistant-footer{border-top:1px solid #ccc;padding:8px;display:flex;gap:8px;background:#fafafa;border-radius:0 0 8px 8px}.primary-button{flex:1;padding:8px 12px;border:none;background:#464767;color:#fff;border-radius:4px;cursor:pointer;white-space:nowrap;font-weight:500;transition:background-color .2s}.primary-button:hover:not(:disabled){background:#323549}.primary-button:disabled{opacity:.6;cursor:not-allowed}.secondary-button{padding:8px 12px;border:1px solid #ddd;background:#fff;color:#464767;border-radius:4px;cursor:pointer;white-space:nowrap;font-weight:500;transition:all .2s}.secondary-button:hover{background:#f5f5f5;border-color:#464767}.code-assistant{position:relative}.source-block{background:#efefef;padding:6px;margin-top:10px;font-family:monospace;font-size:12px}.mock-response{background:#e8f4f8;padding:8px;border-radius:4px;color:#333}.code-editor{width:100%;min-height:200px;font-family:monospace;font-size:14px;padding:12px;border-radius:6px;border:1px solid #ccc;background:#1e1e1e;color:#eaeaea;resize:vertical}
2
+ /*$vite$:1*/`,document.head.appendChild(d);const f=t.defineComponent({name:"PriscillaAI",props:{xpath:{type:String,required:!0,validator:e=>e.trim().length>0},chapterId:{type:Number,required:!0,validator:e=>Number.isInteger(e)&&e>0},programId:{type:Number,required:!0,validator:e=>Number.isInteger(e)&&e>0}},data(){return{isOpen:!1,loading:!1,hint:"",error:"",extractedContent:"",cancelSource:null}},computed:{hasResult(){return!!(this.hint||this.extractedContent)},buttonLabel(){return this.loading?"Fetching…":"Get Hint"}},beforeUnmount(){this.cancelSource?.cancel("Component unmounted")},methods:{toggle(){this.isOpen=!this.isOpen},extractCodeFromXPath(){let e;try{e=document.evaluate(this.xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}catch{throw new Error(`Invalid XPath expression: "${this.xpath}"`)}if(!e)throw new Error("No element matched the provided XPath.");const o=e instanceof HTMLTextAreaElement?e.value:e.textContent;if(!o?.trim())throw new Error("Matched element contains no extractable text.");return o.trim()},async fetchHint(){this.cancelSource?.cancel("Superseded by newer request"),this.loading=!0,this.error="",this.hint="",this.extractedContent="";try{const e=this.extractCodeFromXPath();this.extractedContent=e;const o=l();if(!o)throw new Error("API endpoint not configured. Please initialise the plugin.");this.cancelSource=a.CancelToken.source();const{data:r}=await a.post(o,{content:e,chapterId:this.chapterId,programId:this.programId},{cancelToken:this.cancelSource.token});this.hint=r.hint?.trim()||"No hint available for this submission."}catch(e){if(a.isCancel(e))return;e instanceof Error?this.error=e.message:a.isAxiosError(e)?this.error=`API ${e.response?.status??"Error"}: ${e.message}`:this.error="An unexpected error occurred."}finally{this.loading=!1}},clearHint(){this.hint="",this.extractedContent="",this.error="",this.cancelSource?.cancel("Cleared by user")}}}),h=(e,o)=>{const r=e.__vccOpts||e;for(const[c,p]of o)r[c]=p;return r},m={class:"priscilla-ai"},g=["aria-expanded","aria-label"],u={"aria-hidden":"true"},x={key:0,class:"assistant-window",role:"dialog","aria-label":"Priscilla AI – Code Hint Assistant"},b={class:"assistant-body"},y={class:"code-block"},k={class:"hint-text"},E={key:2,class:"error-message",role:"alert"},w={key:3,class:"loading-spinner","aria-live":"polite"},C={class:"metadata"},N={class:"assistant-footer"},I=["disabled"];function A(e,o,r,c,p,S){return t.openBlock(),t.createElementBlock("div",m,[t.createElementVNode("button",{class:"assistant-button","aria-expanded":e.isOpen,"aria-label":e.isOpen?"Close hint assistant":"Open hint assistant",onClick:o[0]||(o[0]=(...i)=>e.toggle&&e.toggle(...i))},[t.createElementVNode("span",u,t.toDisplayString(e.isOpen?"✖️":"🤖"),1)],8,g),e.isOpen?(t.openBlock(),t.createElementBlock("div",x,[o[5]||(o[5]=t.createElementVNode("header",{class:"assistant-header"},"Priscilla AI — Code Hint Assistant",-1)),t.createElementVNode("div",b,[e.extractedContent?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[o[3]||(o[3]=t.createElementVNode("p",null,[t.createElementVNode("strong",null,"Extracted Code:")],-1)),t.createElementVNode("pre",y,t.toDisplayString(e.extractedContent),1)],64)):t.createCommentVNode("",!0),e.hint?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[o[4]||(o[4]=t.createElementVNode("p",null,[t.createElementVNode("strong",null,"💡 Hint:")],-1)),t.createElementVNode("p",k,t.toDisplayString(e.hint),1)],64)):t.createCommentVNode("",!0),e.error?(t.openBlock(),t.createElementBlock("p",E,"❌ "+t.toDisplayString(e.error),1)):t.createCommentVNode("",!0),e.loading?(t.openBlock(),t.createElementBlock("p",w,"⏳ Fetching hint…")):t.createCommentVNode("",!0),t.createElementVNode("p",C,[t.createElementVNode("small",null,"Chapter "+t.toDisplayString(e.chapterId)+" · Program "+t.toDisplayString(e.programId),1)])]),t.createElementVNode("footer",N,[t.createElementVNode("button",{class:"primary-button",disabled:e.loading,onClick:o[1]||(o[1]=(...i)=>e.fetchHint&&e.fetchHint(...i))},t.toDisplayString(e.buttonLabel),9,I),e.hasResult?(t.openBlock(),t.createElementBlock("button",{key:0,class:"secondary-button",onClick:o[2]||(o[2]=(...i)=>e.clearHint&&e.clearHint(...i))},"Clear")):t.createCommentVNode("",!0)])])):t.createCommentVNode("",!0)])}const P=h(f,[["render",A]]);let s="";function V(e){return{install(o){s=e,o.config.globalProperties.$priscillaAIEndpoint=s,o.component("PriscillaAI",P)}}}function l(){return s}n.createPriscillaAI=V,n.getPriscillaAIEndpoint=l,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@priscilla-ai/vue",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Vue 3 Plugin in Options Api for Priscilla learning portal",
5
5
  "private": false,
6
6
  "license": "MIT",
File without changes