@gui-chat-plugin/template 0.1.1
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/README.ja.md +258 -0
- package/README.md +248 -0
- package/README.npm.md +93 -0
- package/dist/core/definition.d.ts +6 -0
- package/dist/core/index.d.ts +10 -0
- package/dist/core/plugin.d.ts +10 -0
- package/dist/core/samples.d.ts +5 -0
- package/dist/core/types.d.ts +23 -0
- package/dist/core.cjs +1 -0
- package/dist/core.js +146 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +9 -0
- package/dist/react/Preview.d.ts +8 -0
- package/dist/react/View.d.ts +8 -0
- package/dist/react/index.d.ts +24 -0
- package/dist/react.cjs +8 -0
- package/dist/react.js +398 -0
- package/dist/style.css +1 -0
- package/dist/vue/Preview.vue.d.ts +7 -0
- package/dist/vue/View.vue.d.ts +12 -0
- package/dist/vue/index.d.ts +24 -0
- package/dist/vue.cjs +3 -0
- package/dist/vue.js +146 -0
- package/package.json +92 -0
package/dist/core.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
const a = "putQuestions", o = {
|
|
2
|
+
type: "function",
|
|
3
|
+
name: a,
|
|
4
|
+
description: "Present a set of multiple choice questions to test the user's knowledge or abilities. Each question should have 2-6 answer choices.",
|
|
5
|
+
parameters: {
|
|
6
|
+
type: "object",
|
|
7
|
+
properties: {
|
|
8
|
+
title: {
|
|
9
|
+
type: "string",
|
|
10
|
+
description: "Optional title for the quiz (e.g., 'JavaScript Basics Quiz')"
|
|
11
|
+
},
|
|
12
|
+
questions: {
|
|
13
|
+
type: "array",
|
|
14
|
+
description: "Array of multiple choice questions",
|
|
15
|
+
items: {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
question: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "The question text"
|
|
21
|
+
},
|
|
22
|
+
choices: {
|
|
23
|
+
type: "array",
|
|
24
|
+
description: "Array of answer choices (2-6 choices)",
|
|
25
|
+
items: {
|
|
26
|
+
type: "string"
|
|
27
|
+
},
|
|
28
|
+
minItems: 2,
|
|
29
|
+
maxItems: 6
|
|
30
|
+
},
|
|
31
|
+
correctAnswer: {
|
|
32
|
+
type: "number",
|
|
33
|
+
description: "Optional: The index of the correct answer (0-based). Include this if you want to track correct answers."
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
required: ["question", "choices"]
|
|
37
|
+
},
|
|
38
|
+
minItems: 1
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
required: ["questions"]
|
|
42
|
+
}
|
|
43
|
+
}, c = [
|
|
44
|
+
{
|
|
45
|
+
name: "JavaScript Quiz",
|
|
46
|
+
args: {
|
|
47
|
+
title: "JavaScript Basics",
|
|
48
|
+
questions: [
|
|
49
|
+
{
|
|
50
|
+
question: "What does 'const' do in JavaScript?",
|
|
51
|
+
choices: [
|
|
52
|
+
"Declares a constant variable",
|
|
53
|
+
"Declares a mutable variable",
|
|
54
|
+
"Creates a function",
|
|
55
|
+
"Imports a module"
|
|
56
|
+
],
|
|
57
|
+
correctAnswer: 0
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
question: "Which method adds an element to the end of an array?",
|
|
61
|
+
choices: ["pop()", "shift()", "push()", "unshift()"],
|
|
62
|
+
correctAnswer: 2
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
question: "What is the output of: typeof null?",
|
|
66
|
+
choices: ['"null"', '"undefined"', '"object"', '"boolean"'],
|
|
67
|
+
correctAnswer: 2
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "World Capitals",
|
|
74
|
+
args: {
|
|
75
|
+
title: "World Capitals Quiz",
|
|
76
|
+
questions: [
|
|
77
|
+
{
|
|
78
|
+
question: "What is the capital of Japan?",
|
|
79
|
+
choices: ["Osaka", "Kyoto", "Tokyo", "Hiroshima"],
|
|
80
|
+
correctAnswer: 2
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
question: "What is the capital of Australia?",
|
|
84
|
+
choices: ["Sydney", "Melbourne", "Canberra", "Brisbane"],
|
|
85
|
+
correctAnswer: 2
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "Simple Yes/No",
|
|
92
|
+
args: {
|
|
93
|
+
questions: [
|
|
94
|
+
{
|
|
95
|
+
question: "Is the Earth round?",
|
|
96
|
+
choices: ["Yes", "No"],
|
|
97
|
+
correctAnswer: 0
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
], u = async (h, i) => {
|
|
103
|
+
try {
|
|
104
|
+
const { title: s, questions: e } = i;
|
|
105
|
+
if (!e || !Array.isArray(e) || e.length === 0)
|
|
106
|
+
throw new Error("At least one question is required");
|
|
107
|
+
for (let t = 0; t < e.length; t++) {
|
|
108
|
+
const r = e[t];
|
|
109
|
+
if (!r.question || typeof r.question != "string")
|
|
110
|
+
throw new Error(`Question ${t + 1} must have a question text`);
|
|
111
|
+
if (!Array.isArray(r.choices) || r.choices.length < 2)
|
|
112
|
+
throw new Error(`Question ${t + 1} must have at least 2 choices`);
|
|
113
|
+
if (r.choices.length > 6)
|
|
114
|
+
throw new Error(`Question ${t + 1} cannot have more than 6 choices`);
|
|
115
|
+
}
|
|
116
|
+
const n = {
|
|
117
|
+
title: s,
|
|
118
|
+
questions: e
|
|
119
|
+
};
|
|
120
|
+
return {
|
|
121
|
+
toolName: o.name,
|
|
122
|
+
message: `Quiz presented with ${e.length} question${e.length > 1 ? "s" : ""}`,
|
|
123
|
+
jsonData: n,
|
|
124
|
+
instructions: "The quiz has been presented to the user. Wait for the user to submit their answers. They will tell you their answers in text format."
|
|
125
|
+
};
|
|
126
|
+
} catch (s) {
|
|
127
|
+
return console.error("Quiz creation error", s), {
|
|
128
|
+
toolName: o.name,
|
|
129
|
+
message: `Quiz error: ${s instanceof Error ? s.message : "Unknown error"}`,
|
|
130
|
+
instructions: "Acknowledge that there was an error creating the quiz and suggest trying again."
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}, l = {
|
|
134
|
+
toolDefinition: o,
|
|
135
|
+
execute: u,
|
|
136
|
+
generatingMessage: "Preparing quiz...",
|
|
137
|
+
isEnabled: () => !0,
|
|
138
|
+
samples: c
|
|
139
|
+
};
|
|
140
|
+
export {
|
|
141
|
+
c as SAMPLES,
|
|
142
|
+
o as TOOL_DEFINITION,
|
|
143
|
+
a as TOOL_NAME,
|
|
144
|
+
u as executeQuiz,
|
|
145
|
+
l as pluginCore
|
|
146
|
+
};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./core.cjs");exports.SAMPLES=e.SAMPLES;exports.TOOL_DEFINITION=e.TOOL_DEFINITION;exports.TOOL_NAME=e.TOOL_NAME;exports.default=e.pluginCore;exports.executeQuiz=e.executeQuiz;exports.pluginCore=e.pluginCore;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MulmoChat Quiz Plugin
|
|
3
|
+
*
|
|
4
|
+
* Default export is the framework-agnostic core.
|
|
5
|
+
* For Vue implementation, import from "@mulmochat-plugin/quiz/vue"
|
|
6
|
+
*
|
|
7
|
+
* @example Default (Core - framework-agnostic)
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { pluginCore, TOOL_NAME, QuizData } from "@mulmochat-plugin/quiz";
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @example Vue implementation
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import QuizPlugin from "@mulmochat-plugin/quiz/vue";
|
|
15
|
+
* import "@mulmochat-plugin/quiz/style.css";
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export * from "./core";
|
|
19
|
+
export { pluginCore as default } from "./core";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quiz Preview Component (React)
|
|
3
|
+
*/
|
|
4
|
+
import type { PreviewComponentProps } from "gui-chat-protocol";
|
|
5
|
+
import type { QuizData } from "../core/types";
|
|
6
|
+
type PreviewProps = PreviewComponentProps<never, QuizData>;
|
|
7
|
+
export declare function Preview({ result }: PreviewProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export default Preview;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quiz View Component (React)
|
|
3
|
+
*/
|
|
4
|
+
import type { ViewComponentProps } from "gui-chat-protocol";
|
|
5
|
+
import type { QuizData } from "../core/types";
|
|
6
|
+
type ViewProps = ViewComponentProps<never, QuizData>;
|
|
7
|
+
export declare function View({ selectedResult, sendTextMessage, onUpdateResult }: ViewProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export default View;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MulmoChat Quiz Plugin - React Implementation
|
|
3
|
+
*
|
|
4
|
+
* Full React plugin with UI components.
|
|
5
|
+
* Import from "@mulmochat-plugin/quiz/react"
|
|
6
|
+
*/
|
|
7
|
+
import "../style.css";
|
|
8
|
+
import type { ToolPluginReact } from "gui-chat-protocol/react";
|
|
9
|
+
import type { QuizData, QuizArgs } from "../core/types";
|
|
10
|
+
import { View } from "./View";
|
|
11
|
+
import { Preview } from "./Preview";
|
|
12
|
+
/**
|
|
13
|
+
* Quiz plugin instance with React components
|
|
14
|
+
*/
|
|
15
|
+
export declare const plugin: ToolPluginReact<never, QuizData, QuizArgs>;
|
|
16
|
+
export type { QuizQuestion, QuizData, QuizArgs } from "../core/types";
|
|
17
|
+
export { pluginCore, executeQuiz } from "../core/plugin";
|
|
18
|
+
export { TOOL_NAME, TOOL_DEFINITION } from "../core/definition";
|
|
19
|
+
export { SAMPLES } from "../core/samples";
|
|
20
|
+
export { View, Preview };
|
|
21
|
+
declare const _default: {
|
|
22
|
+
plugin: ToolPluginReact<never, QuizData, QuizArgs, import("gui-chat-protocol/react").InputHandler, Record<string, unknown>>;
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});;/* empty css */const h=require("./core.cjs"),w=require("react");var S={exports:{}},g={};var W;function ae(){if(W)return g;W=1;var i=Symbol.for("react.transitional.element"),c=Symbol.for("react.fragment");function x(l,d,u){var p=null;if(u!==void 0&&(p=""+u),d.key!==void 0&&(p=""+d.key),"key"in d){u={};for(var v in d)v!=="key"&&(u[v]=d[v])}else u=d;return d=u.ref,{$$typeof:i,type:l,key:p,ref:d!==void 0?d:null,props:u}}return g.Fragment=c,g.jsx=x,g.jsxs=x,g}var T={};var Q;function oe(){return Q||(Q=1,process.env.NODE_ENV!=="production"&&(function(){function i(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===te?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case b:return"Fragment";case k:return"Profiler";case y:return"StrictMode";case Z:return"Suspense";case K:return"SuspenseList";case re:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case m:return"Portal";case H:return e.displayName||"Context";case P:return(e._context.displayName||"Context")+".Consumer";case B:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ee:return r=e.displayName||null,r!==null?r:i(e.type)||"Memo";case C:r=e._payload,e=e._init;try{return i(e(r))}catch{}}return null}function c(e){return""+e}function x(e){try{c(e);var r=!1}catch{r=!0}if(r){r=console;var n=r.error,a=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",a),c(e)}}function l(e){if(e===b)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===C)return"<...>";try{var r=i(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function d(){var e=$.A;return e===null?null:e.getOwner()}function u(){return Error("react-stack-top-frame")}function p(e){if(L.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function v(e,r){function n(){M||(M=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}function O(){var e=i(this.type);return F[e]||(F[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function j(e,r,n,a,A,D){var o=n.ref;return e={$$typeof:f,type:e,key:r,props:n,_owner:a},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:O}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:D}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function _(e,r,n,a,A,D){var o=r.children;if(o!==void 0)if(a)if(ne(o)){for(a=0;a<o.length;a++)N(o[a]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else N(o);if(L.call(r,"key")){o=i(e);var E=Object.keys(r).filter(function(se){return se!=="key"});a=0<E.length?"{key: someKey, "+E.join(": ..., ")+": ...}":"{key: someKey}",V[o+a]||(E=0<E.length?"{"+E.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
+
let props = %s;
|
|
3
|
+
<%s {...props} />
|
|
4
|
+
React keys must be passed directly to JSX without using spread:
|
|
5
|
+
let props = %s;
|
|
6
|
+
<%s key={someKey} {...props} />`,a,o,E,o),V[o+a]=!0)}if(o=null,n!==void 0&&(x(n),o=""+n),p(r)&&(x(r.key),o=""+r.key),"key"in r){n={};for(var Y in r)Y!=="key"&&(n[Y]=r[Y])}else n=r;return o&&v(n,typeof e=="function"?e.displayName||e.name||"Unknown":e),j(e,o,n,d(),A,D)}function N(e){R(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===C&&(e._payload.status==="fulfilled"?R(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function R(e){return typeof e=="object"&&e!==null&&e.$$typeof===f}var s=w,f=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),H=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),Z=Symbol.for("react.suspense"),K=Symbol.for("react.suspense_list"),ee=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),re=Symbol.for("react.activity"),te=Symbol.for("react.client.reference"),$=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=Object.prototype.hasOwnProperty,ne=Array.isArray,q=console.createTask?console.createTask:function(){return null};s={react_stack_bottom_frame:function(e){return e()}};var M,F={},z=s.react_stack_bottom_frame.bind(s,u)(),I=q(l(u)),V={};T.Fragment=b,T.jsx=function(e,r,n){var a=1e4>$.recentlyCreatedOwnerStacks++;return _(e,r,n,!1,a?Error("react-stack-top-frame"):z,a?q(l(e)):I)},T.jsxs=function(e,r,n){var a=1e4>$.recentlyCreatedOwnerStacks++;return _(e,r,n,!0,a?Error("react-stack-top-frame"):z,a?q(l(e)):I)}})()),T}var U;function le(){return U||(U=1,process.env.NODE_ENV==="production"?S.exports=ae():S.exports=oe()),S.exports}var t=le();function J({selectedResult:i,sendTextMessage:c,onUpdateResult:x}){const[l,d]=w.useState(null),[u,p]=w.useState([]);w.useEffect(()=>{if(i?.toolName===h.TOOL_NAME&&i.jsonData){const s=i.jsonData;d(s),i.viewState?.userAnswers?p(i.viewState.userAnswers):p(new Array(s.questions.length).fill(null))}},[i]);const v=w.useCallback(s=>{p(s),x&&x({viewState:{userAnswers:s}})},[x]),O=(s,f)=>{const m=[...u];m[s]=f,v(m)},j=u.filter(s=>s!==null).length,_=l&&j===l.questions.length,N=(s,f)=>u[s]===f?"border-blue-500 bg-blue-500/20":"border-[#4b4b6b] hover:border-[#6b6b8b] hover:bg-[#6b6b8b]/20",R=()=>{if(!l||!_)return;const f=`Here are my answers:
|
|
7
|
+
${u.map((m,b)=>{if(m===null)return null;const y=b+1,k=String.fromCharCode(65+m),P=l.questions[b].choices[m];return`Q${y}: ${k} - ${P}`}).filter(m=>m!==null).join(`
|
|
8
|
+
`)}`;c(f)};return l?t.jsx("div",{className:"w-full min-h-[400px] overflow-y-auto p-8 bg-[#1a1a2e] rounded-lg",children:t.jsxs("div",{className:"max-w-3xl mx-auto",children:[l.title&&t.jsx("h2",{className:"text-[#f0f0f0] text-3xl font-bold mb-8 text-center",children:l.title}),t.jsx("div",{className:"flex flex-col gap-6",children:l.questions.map((s,f)=>t.jsxs("div",{className:"bg-[#2d2d44] rounded-lg p-6 border-2 border-[#3d3d5c]",children:[t.jsxs("div",{className:"text-white text-lg font-semibold mb-4",children:[t.jsxs("span",{className:"text-blue-400 mr-2",children:[f+1,"."]}),s.question]}),t.jsx("div",{className:"flex flex-col gap-3",children:s.choices.map((m,b)=>t.jsxs("label",{className:`flex items-start p-4 rounded-lg cursor-pointer transition-all duration-200 border-2 ${N(f,b)}`,children:[t.jsx("input",{type:"radio",name:`question-${f}`,value:b,checked:u[f]===b,onChange:()=>O(f,b),className:"mt-1 mr-3 size-4 shrink-0"}),t.jsxs("span",{className:"text-white flex-1",children:[t.jsxs("span",{className:"font-semibold mr-2",children:[String.fromCharCode(65+b),"."]}),m]})]},b))})]},f))}),t.jsx("div",{className:"mt-8 flex justify-center",children:t.jsx("button",{onClick:R,disabled:!_,className:`py-3 px-8 rounded-lg text-white font-semibold text-lg transition-colors border-none cursor-pointer ${_?"bg-blue-600 hover:bg-blue-700":"bg-gray-600 cursor-not-allowed opacity-50"}`,children:"Submit Answers"})}),t.jsxs("div",{className:"mt-4 text-center text-gray-400 text-sm",children:[j," / ",l.questions.length," questions answered"]})]})}):null}function G({result:i}){const c=i.jsonData;return c?t.jsx("div",{className:"p-3 bg-blue-50 rounded-md",children:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("div",{className:"text-sm font-semibold text-gray-800 text-center",children:c.title||"Quiz"}),t.jsx("div",{className:"text-center",children:t.jsxs("span",{className:"inline-block bg-blue-600 text-white text-xs font-bold py-1 px-3 rounded-full",children:[c.questions.length," ",c.questions.length===1?"Question":"Questions"]})}),t.jsx("div",{className:"text-xs text-gray-600 overflow-hidden line-clamp-2",children:c.questions[0]?.question}),t.jsxs("div",{className:"flex justify-center gap-1",children:[Array.from({length:Math.min(c.questions[0]?.choices.length||0,4)}).map((x,l)=>t.jsx("div",{className:"size-2 bg-gray-400 rounded-full"},l)),(c.questions[0]?.choices.length||0)>4&&t.jsxs("span",{className:"text-xs text-gray-500",children:["+",c.questions[0].choices.length-4]})]})]})}):null}const X={...h.pluginCore,ViewComponent:J,PreviewComponent:G},ie={plugin:X};exports.SAMPLES=h.SAMPLES;exports.TOOL_DEFINITION=h.TOOL_DEFINITION;exports.TOOL_NAME=h.TOOL_NAME;exports.executeQuiz=h.executeQuiz;exports.pluginCore=h.pluginCore;exports.Preview=G;exports.View=J;exports.default=ie;exports.plugin=X;
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
import { TOOL_NAME as re, pluginCore as te } from "./core.js";
|
|
3
|
+
import { SAMPLES as ve, TOOL_DEFINITION as Ee, executeQuiz as _e } from "./core.js";
|
|
4
|
+
import ne, { useState as W, useEffect as se, useCallback as ae } from "react";
|
|
5
|
+
var N = { exports: {} }, _ = {};
|
|
6
|
+
var V;
|
|
7
|
+
function oe() {
|
|
8
|
+
if (V) return _;
|
|
9
|
+
V = 1;
|
|
10
|
+
var i = /* @__PURE__ */ Symbol.for("react.transitional.element"), u = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
11
|
+
function x(l, d, c) {
|
|
12
|
+
var p = null;
|
|
13
|
+
if (c !== void 0 && (p = "" + c), d.key !== void 0 && (p = "" + d.key), "key" in d) {
|
|
14
|
+
c = {};
|
|
15
|
+
for (var h in d)
|
|
16
|
+
h !== "key" && (c[h] = d[h]);
|
|
17
|
+
} else c = d;
|
|
18
|
+
return d = c.ref, {
|
|
19
|
+
$$typeof: i,
|
|
20
|
+
type: l,
|
|
21
|
+
key: p,
|
|
22
|
+
ref: d !== void 0 ? d : null,
|
|
23
|
+
props: c
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return _.Fragment = u, _.jsx = x, _.jsxs = x, _;
|
|
27
|
+
}
|
|
28
|
+
var g = {};
|
|
29
|
+
var U;
|
|
30
|
+
function le() {
|
|
31
|
+
return U || (U = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
32
|
+
function i(e) {
|
|
33
|
+
if (e == null) return null;
|
|
34
|
+
if (typeof e == "function")
|
|
35
|
+
return e.$$typeof === Z ? null : e.displayName || e.name || null;
|
|
36
|
+
if (typeof e == "string") return e;
|
|
37
|
+
switch (e) {
|
|
38
|
+
case b:
|
|
39
|
+
return "Fragment";
|
|
40
|
+
case k:
|
|
41
|
+
return "Profiler";
|
|
42
|
+
case y:
|
|
43
|
+
return "StrictMode";
|
|
44
|
+
case G:
|
|
45
|
+
return "Suspense";
|
|
46
|
+
case X:
|
|
47
|
+
return "SuspenseList";
|
|
48
|
+
case B:
|
|
49
|
+
return "Activity";
|
|
50
|
+
}
|
|
51
|
+
if (typeof e == "object")
|
|
52
|
+
switch (typeof e.tag == "number" && console.error(
|
|
53
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
54
|
+
), e.$$typeof) {
|
|
55
|
+
case m:
|
|
56
|
+
return "Portal";
|
|
57
|
+
case J:
|
|
58
|
+
return e.displayName || "Context";
|
|
59
|
+
case S:
|
|
60
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
61
|
+
case Q:
|
|
62
|
+
var r = e.render;
|
|
63
|
+
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
64
|
+
case H:
|
|
65
|
+
return r = e.displayName || null, r !== null ? r : i(e.type) || "Memo";
|
|
66
|
+
case O:
|
|
67
|
+
r = e._payload, e = e._init;
|
|
68
|
+
try {
|
|
69
|
+
return i(e(r));
|
|
70
|
+
} catch {
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
function u(e) {
|
|
76
|
+
return "" + e;
|
|
77
|
+
}
|
|
78
|
+
function x(e) {
|
|
79
|
+
try {
|
|
80
|
+
u(e);
|
|
81
|
+
var r = !1;
|
|
82
|
+
} catch {
|
|
83
|
+
r = !0;
|
|
84
|
+
}
|
|
85
|
+
if (r) {
|
|
86
|
+
r = console;
|
|
87
|
+
var n = r.error, a = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
88
|
+
return n.call(
|
|
89
|
+
r,
|
|
90
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
91
|
+
a
|
|
92
|
+
), u(e);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function l(e) {
|
|
96
|
+
if (e === b) return "<>";
|
|
97
|
+
if (typeof e == "object" && e !== null && e.$$typeof === O)
|
|
98
|
+
return "<...>";
|
|
99
|
+
try {
|
|
100
|
+
var r = i(e);
|
|
101
|
+
return r ? "<" + r + ">" : "<...>";
|
|
102
|
+
} catch {
|
|
103
|
+
return "<...>";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function d() {
|
|
107
|
+
var e = P.A;
|
|
108
|
+
return e === null ? null : e.getOwner();
|
|
109
|
+
}
|
|
110
|
+
function c() {
|
|
111
|
+
return Error("react-stack-top-frame");
|
|
112
|
+
}
|
|
113
|
+
function p(e) {
|
|
114
|
+
if (D.call(e, "key")) {
|
|
115
|
+
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
116
|
+
if (r && r.isReactWarning) return !1;
|
|
117
|
+
}
|
|
118
|
+
return e.key !== void 0;
|
|
119
|
+
}
|
|
120
|
+
function h(e, r) {
|
|
121
|
+
function n() {
|
|
122
|
+
Y || (Y = !0, console.error(
|
|
123
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
124
|
+
r
|
|
125
|
+
));
|
|
126
|
+
}
|
|
127
|
+
n.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
128
|
+
get: n,
|
|
129
|
+
configurable: !0
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function A() {
|
|
133
|
+
var e = i(this.type);
|
|
134
|
+
return F[e] || (F[e] = !0, console.error(
|
|
135
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
136
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
137
|
+
}
|
|
138
|
+
function w(e, r, n, a, R, $) {
|
|
139
|
+
var o = n.ref;
|
|
140
|
+
return e = {
|
|
141
|
+
$$typeof: f,
|
|
142
|
+
type: e,
|
|
143
|
+
key: r,
|
|
144
|
+
props: n,
|
|
145
|
+
_owner: a
|
|
146
|
+
}, (o !== void 0 ? o : null) !== null ? Object.defineProperty(e, "ref", {
|
|
147
|
+
enumerable: !1,
|
|
148
|
+
get: A
|
|
149
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
150
|
+
configurable: !1,
|
|
151
|
+
enumerable: !1,
|
|
152
|
+
writable: !0,
|
|
153
|
+
value: 0
|
|
154
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
155
|
+
configurable: !1,
|
|
156
|
+
enumerable: !1,
|
|
157
|
+
writable: !0,
|
|
158
|
+
value: null
|
|
159
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
160
|
+
configurable: !1,
|
|
161
|
+
enumerable: !1,
|
|
162
|
+
writable: !0,
|
|
163
|
+
value: R
|
|
164
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
165
|
+
configurable: !1,
|
|
166
|
+
enumerable: !1,
|
|
167
|
+
writable: !0,
|
|
168
|
+
value: $
|
|
169
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
170
|
+
}
|
|
171
|
+
function v(e, r, n, a, R, $) {
|
|
172
|
+
var o = r.children;
|
|
173
|
+
if (o !== void 0)
|
|
174
|
+
if (a)
|
|
175
|
+
if (K(o)) {
|
|
176
|
+
for (a = 0; a < o.length; a++)
|
|
177
|
+
j(o[a]);
|
|
178
|
+
Object.freeze && Object.freeze(o);
|
|
179
|
+
} else
|
|
180
|
+
console.error(
|
|
181
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
182
|
+
);
|
|
183
|
+
else j(o);
|
|
184
|
+
if (D.call(r, "key")) {
|
|
185
|
+
o = i(e);
|
|
186
|
+
var E = Object.keys(r).filter(function(ee) {
|
|
187
|
+
return ee !== "key";
|
|
188
|
+
});
|
|
189
|
+
a = 0 < E.length ? "{key: someKey, " + E.join(": ..., ") + ": ...}" : "{key: someKey}", M[o + a] || (E = 0 < E.length ? "{" + E.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
190
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
191
|
+
let props = %s;
|
|
192
|
+
<%s {...props} />
|
|
193
|
+
React keys must be passed directly to JSX without using spread:
|
|
194
|
+
let props = %s;
|
|
195
|
+
<%s key={someKey} {...props} />`,
|
|
196
|
+
a,
|
|
197
|
+
o,
|
|
198
|
+
E,
|
|
199
|
+
o
|
|
200
|
+
), M[o + a] = !0);
|
|
201
|
+
}
|
|
202
|
+
if (o = null, n !== void 0 && (x(n), o = "" + n), p(r) && (x(r.key), o = "" + r.key), "key" in r) {
|
|
203
|
+
n = {};
|
|
204
|
+
for (var q in r)
|
|
205
|
+
q !== "key" && (n[q] = r[q]);
|
|
206
|
+
} else n = r;
|
|
207
|
+
return o && h(
|
|
208
|
+
n,
|
|
209
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
210
|
+
), w(
|
|
211
|
+
e,
|
|
212
|
+
o,
|
|
213
|
+
n,
|
|
214
|
+
d(),
|
|
215
|
+
R,
|
|
216
|
+
$
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
function j(e) {
|
|
220
|
+
T(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === O && (e._payload.status === "fulfilled" ? T(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
221
|
+
}
|
|
222
|
+
function T(e) {
|
|
223
|
+
return typeof e == "object" && e !== null && e.$$typeof === f;
|
|
224
|
+
}
|
|
225
|
+
var s = ne, f = /* @__PURE__ */ Symbol.for("react.transitional.element"), m = /* @__PURE__ */ Symbol.for("react.portal"), b = /* @__PURE__ */ Symbol.for("react.fragment"), y = /* @__PURE__ */ Symbol.for("react.strict_mode"), k = /* @__PURE__ */ Symbol.for("react.profiler"), S = /* @__PURE__ */ Symbol.for("react.consumer"), J = /* @__PURE__ */ Symbol.for("react.context"), Q = /* @__PURE__ */ Symbol.for("react.forward_ref"), G = /* @__PURE__ */ Symbol.for("react.suspense"), X = /* @__PURE__ */ Symbol.for("react.suspense_list"), H = /* @__PURE__ */ Symbol.for("react.memo"), O = /* @__PURE__ */ Symbol.for("react.lazy"), B = /* @__PURE__ */ Symbol.for("react.activity"), Z = /* @__PURE__ */ Symbol.for("react.client.reference"), P = s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, D = Object.prototype.hasOwnProperty, K = Array.isArray, C = console.createTask ? console.createTask : function() {
|
|
226
|
+
return null;
|
|
227
|
+
};
|
|
228
|
+
s = {
|
|
229
|
+
react_stack_bottom_frame: function(e) {
|
|
230
|
+
return e();
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
var Y, F = {}, L = s.react_stack_bottom_frame.bind(
|
|
234
|
+
s,
|
|
235
|
+
c
|
|
236
|
+
)(), z = C(l(c)), M = {};
|
|
237
|
+
g.Fragment = b, g.jsx = function(e, r, n) {
|
|
238
|
+
var a = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
239
|
+
return v(
|
|
240
|
+
e,
|
|
241
|
+
r,
|
|
242
|
+
n,
|
|
243
|
+
!1,
|
|
244
|
+
a ? Error("react-stack-top-frame") : L,
|
|
245
|
+
a ? C(l(e)) : z
|
|
246
|
+
);
|
|
247
|
+
}, g.jsxs = function(e, r, n) {
|
|
248
|
+
var a = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
249
|
+
return v(
|
|
250
|
+
e,
|
|
251
|
+
r,
|
|
252
|
+
n,
|
|
253
|
+
!0,
|
|
254
|
+
a ? Error("react-stack-top-frame") : L,
|
|
255
|
+
a ? C(l(e)) : z
|
|
256
|
+
);
|
|
257
|
+
};
|
|
258
|
+
})()), g;
|
|
259
|
+
}
|
|
260
|
+
var I;
|
|
261
|
+
function ie() {
|
|
262
|
+
return I || (I = 1, process.env.NODE_ENV === "production" ? N.exports = oe() : N.exports = le()), N.exports;
|
|
263
|
+
}
|
|
264
|
+
var t = ie();
|
|
265
|
+
function ce({ selectedResult: i, sendTextMessage: u, onUpdateResult: x }) {
|
|
266
|
+
const [l, d] = W(null), [c, p] = W([]);
|
|
267
|
+
se(() => {
|
|
268
|
+
if (i?.toolName === re && i.jsonData) {
|
|
269
|
+
const s = i.jsonData;
|
|
270
|
+
d(s), i.viewState?.userAnswers ? p(i.viewState.userAnswers) : p(new Array(s.questions.length).fill(null));
|
|
271
|
+
}
|
|
272
|
+
}, [i]);
|
|
273
|
+
const h = ae(
|
|
274
|
+
(s) => {
|
|
275
|
+
p(s), x && x({
|
|
276
|
+
viewState: { userAnswers: s }
|
|
277
|
+
});
|
|
278
|
+
},
|
|
279
|
+
[x]
|
|
280
|
+
), A = (s, f) => {
|
|
281
|
+
const m = [...c];
|
|
282
|
+
m[s] = f, h(m);
|
|
283
|
+
}, w = c.filter((s) => s !== null).length, v = l && w === l.questions.length, j = (s, f) => c[s] === f ? "border-blue-500 bg-blue-500/20" : "border-[#4b4b6b] hover:border-[#6b6b8b] hover:bg-[#6b6b8b]/20", T = () => {
|
|
284
|
+
if (!l || !v) return;
|
|
285
|
+
const f = `Here are my answers:
|
|
286
|
+
${c.map((m, b) => {
|
|
287
|
+
if (m === null) return null;
|
|
288
|
+
const y = b + 1, k = String.fromCharCode(65 + m), S = l.questions[b].choices[m];
|
|
289
|
+
return `Q${y}: ${k} - ${S}`;
|
|
290
|
+
}).filter((m) => m !== null).join(`
|
|
291
|
+
`)}`;
|
|
292
|
+
u(f);
|
|
293
|
+
};
|
|
294
|
+
return l ? /* @__PURE__ */ t.jsx("div", { className: "w-full min-h-[400px] overflow-y-auto p-8 bg-[#1a1a2e] rounded-lg", children: /* @__PURE__ */ t.jsxs("div", { className: "max-w-3xl mx-auto", children: [
|
|
295
|
+
l.title && /* @__PURE__ */ t.jsx("h2", { className: "text-[#f0f0f0] text-3xl font-bold mb-8 text-center", children: l.title }),
|
|
296
|
+
/* @__PURE__ */ t.jsx("div", { className: "flex flex-col gap-6", children: l.questions.map((s, f) => /* @__PURE__ */ t.jsxs(
|
|
297
|
+
"div",
|
|
298
|
+
{
|
|
299
|
+
className: "bg-[#2d2d44] rounded-lg p-6 border-2 border-[#3d3d5c]",
|
|
300
|
+
children: [
|
|
301
|
+
/* @__PURE__ */ t.jsxs("div", { className: "text-white text-lg font-semibold mb-4", children: [
|
|
302
|
+
/* @__PURE__ */ t.jsxs("span", { className: "text-blue-400 mr-2", children: [
|
|
303
|
+
f + 1,
|
|
304
|
+
"."
|
|
305
|
+
] }),
|
|
306
|
+
s.question
|
|
307
|
+
] }),
|
|
308
|
+
/* @__PURE__ */ t.jsx("div", { className: "flex flex-col gap-3", children: s.choices.map((m, b) => /* @__PURE__ */ t.jsxs(
|
|
309
|
+
"label",
|
|
310
|
+
{
|
|
311
|
+
className: `flex items-start p-4 rounded-lg cursor-pointer transition-all duration-200 border-2 ${j(f, b)}`,
|
|
312
|
+
children: [
|
|
313
|
+
/* @__PURE__ */ t.jsx(
|
|
314
|
+
"input",
|
|
315
|
+
{
|
|
316
|
+
type: "radio",
|
|
317
|
+
name: `question-${f}`,
|
|
318
|
+
value: b,
|
|
319
|
+
checked: c[f] === b,
|
|
320
|
+
onChange: () => A(f, b),
|
|
321
|
+
className: "mt-1 mr-3 size-4 shrink-0"
|
|
322
|
+
}
|
|
323
|
+
),
|
|
324
|
+
/* @__PURE__ */ t.jsxs("span", { className: "text-white flex-1", children: [
|
|
325
|
+
/* @__PURE__ */ t.jsxs("span", { className: "font-semibold mr-2", children: [
|
|
326
|
+
String.fromCharCode(65 + b),
|
|
327
|
+
"."
|
|
328
|
+
] }),
|
|
329
|
+
m
|
|
330
|
+
] })
|
|
331
|
+
]
|
|
332
|
+
},
|
|
333
|
+
b
|
|
334
|
+
)) })
|
|
335
|
+
]
|
|
336
|
+
},
|
|
337
|
+
f
|
|
338
|
+
)) }),
|
|
339
|
+
/* @__PURE__ */ t.jsx("div", { className: "mt-8 flex justify-center", children: /* @__PURE__ */ t.jsx(
|
|
340
|
+
"button",
|
|
341
|
+
{
|
|
342
|
+
onClick: T,
|
|
343
|
+
disabled: !v,
|
|
344
|
+
className: `py-3 px-8 rounded-lg text-white font-semibold text-lg transition-colors border-none cursor-pointer ${v ? "bg-blue-600 hover:bg-blue-700" : "bg-gray-600 cursor-not-allowed opacity-50"}`,
|
|
345
|
+
children: "Submit Answers"
|
|
346
|
+
}
|
|
347
|
+
) }),
|
|
348
|
+
/* @__PURE__ */ t.jsxs("div", { className: "mt-4 text-center text-gray-400 text-sm", children: [
|
|
349
|
+
w,
|
|
350
|
+
" / ",
|
|
351
|
+
l.questions.length,
|
|
352
|
+
" questions answered"
|
|
353
|
+
] })
|
|
354
|
+
] }) }) : null;
|
|
355
|
+
}
|
|
356
|
+
function ue({ result: i }) {
|
|
357
|
+
const u = i.jsonData;
|
|
358
|
+
return u ? /* @__PURE__ */ t.jsx("div", { className: "p-3 bg-blue-50 rounded-md", children: /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
359
|
+
/* @__PURE__ */ t.jsx("div", { className: "text-sm font-semibold text-gray-800 text-center", children: u.title || "Quiz" }),
|
|
360
|
+
/* @__PURE__ */ t.jsx("div", { className: "text-center", children: /* @__PURE__ */ t.jsxs("span", { className: "inline-block bg-blue-600 text-white text-xs font-bold py-1 px-3 rounded-full", children: [
|
|
361
|
+
u.questions.length,
|
|
362
|
+
" ",
|
|
363
|
+
u.questions.length === 1 ? "Question" : "Questions"
|
|
364
|
+
] }) }),
|
|
365
|
+
/* @__PURE__ */ t.jsx("div", { className: "text-xs text-gray-600 overflow-hidden line-clamp-2", children: u.questions[0]?.question }),
|
|
366
|
+
/* @__PURE__ */ t.jsxs("div", { className: "flex justify-center gap-1", children: [
|
|
367
|
+
Array.from({
|
|
368
|
+
length: Math.min(u.questions[0]?.choices.length || 0, 4)
|
|
369
|
+
}).map((x, l) => /* @__PURE__ */ t.jsx(
|
|
370
|
+
"div",
|
|
371
|
+
{
|
|
372
|
+
className: "size-2 bg-gray-400 rounded-full"
|
|
373
|
+
},
|
|
374
|
+
l
|
|
375
|
+
)),
|
|
376
|
+
(u.questions[0]?.choices.length || 0) > 4 && /* @__PURE__ */ t.jsxs("span", { className: "text-xs text-gray-500", children: [
|
|
377
|
+
"+",
|
|
378
|
+
u.questions[0].choices.length - 4
|
|
379
|
+
] })
|
|
380
|
+
] })
|
|
381
|
+
] }) }) : null;
|
|
382
|
+
}
|
|
383
|
+
const fe = {
|
|
384
|
+
...te,
|
|
385
|
+
ViewComponent: ce,
|
|
386
|
+
PreviewComponent: ue
|
|
387
|
+
}, xe = { plugin: fe };
|
|
388
|
+
export {
|
|
389
|
+
ue as Preview,
|
|
390
|
+
ve as SAMPLES,
|
|
391
|
+
Ee as TOOL_DEFINITION,
|
|
392
|
+
re as TOOL_NAME,
|
|
393
|
+
ce as View,
|
|
394
|
+
xe as default,
|
|
395
|
+
_e as executeQuiz,
|
|
396
|
+
fe as plugin,
|
|
397
|
+
te as pluginCore
|
|
398
|
+
};
|