@enspiredigital/xlms-headless 0.0.26 → 0.0.27

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,6 +1,5 @@
1
1
  import { SpeakingQuestionType } from '../types/speaking';
2
2
  export type SpeakingSubmitPayload = {
3
- questionId: string | number;
4
3
  type: 'speaking';
5
4
  audioUrl?: string;
6
5
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useSpeaking.d.ts","sourceRoot":"","sources":["../../src/hooks/useSpeaking.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEzE,MAAM,MAAM,qBAAqB,GAAG,CAClC,SAAS,EAAE,IAAI,EACf,QAAQ,CAAC,EAAE,MAAM,KACd,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEjE,wBAAgB,WAAW,CACzB,QAAQ,EAAE,oBAAoB,EAC9B,aAAa,CAAC,EAAE,qBAAqB;;;;;;;;;;;;;;;;;;;uBAiItB,IAAI;;;EAmFpB"}
1
+ {"version":3,"file":"useSpeaking.d.ts","sourceRoot":"","sources":["../../src/hooks/useSpeaking.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEzE,MAAM,MAAM,qBAAqB,GAAG,CAClC,SAAS,EAAE,IAAI,EACf,QAAQ,CAAC,EAAE,MAAM,KACd,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEjE,wBAAgB,WAAW,CACzB,QAAQ,EAAE,oBAAoB,EAC9B,aAAa,CAAC,EAAE,qBAAqB;;;;;;;;;;;;;;;;;;;uBAiItB,IAAI;;;EAkFpB"}
@@ -1,6 +1,5 @@
1
1
  import { WritingQuestionType } from '../types/writing';
2
2
  export type WritingSubmitPayload = {
3
- questionId: string | number;
4
3
  type: 'writing';
5
4
  text: string;
6
5
  fileUrl?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"useWriting.d.ts","sourceRoot":"","sources":["../../src/hooks/useWriting.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,CACjC,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,QAAQ,CAAC,EAAE,MAAM,KACd,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEjE,wBAAgB,UAAU,CACxB,QAAQ,EAAE,mBAAmB,EAC7B,aAAa,CAAC,EAAE,oBAAoB;;;;;;;;;;;uBAWrB,IAAI;;;;;EAgGpB"}
1
+ {"version":3,"file":"useWriting.d.ts","sourceRoot":"","sources":["../../src/hooks/useWriting.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,CACjC,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,QAAQ,CAAC,EAAE,MAAM,KACd,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEjE,wBAAgB,UAAU,CACxB,QAAQ,EAAE,mBAAmB,EAC7B,aAAa,CAAC,EAAE,oBAAoB;;;;;;;;;;;uBAWrB,IAAI;;;;;EA+FpB"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useState as A, useRef as _, useEffect as V, useMemo as T, useCallback as R } from "react";
2
- import { jsx as W, Fragment as $ } from "react/jsx-runtime";
2
+ import { jsx as W, Fragment as z } from "react/jsx-runtime";
3
3
  function E() {
4
4
  const [t, n] = A(null), [u, f] = A(null), [b, C] = A(0);
5
5
  function S(d) {
@@ -28,7 +28,7 @@ function J(t, n) {
28
28
  if (!f.has(b)) return !1;
29
29
  return !0;
30
30
  }
31
- function z(t) {
31
+ function G(t) {
32
32
  const n = [...t];
33
33
  for (let u = n.length - 1; u > 0; u--) {
34
34
  const f = Math.floor(Math.random() * (u + 1));
@@ -137,7 +137,7 @@ function Y(t) {
137
137
  );
138
138
  w(e);
139
139
  }, [o]), V(() => {
140
- m.current = z(t.options.targets);
140
+ m.current = G(t.options.targets);
141
141
  }, [t.options.targets]), {
142
142
  // data
143
143
  sources: t.options.sources,
@@ -281,7 +281,7 @@ function H(t) {
281
281
  attempts: b,
282
282
  submitQuestion: C,
283
283
  resetQuestion: S
284
- } = E(), [o, d] = A(() => z(
284
+ } = E(), [o, d] = A(() => G(
285
285
  t.options.answers.map((c) => String(c.id))
286
286
  )), h = T(() => o.map(
287
287
  (c) => t.options.answers.find((i) => String(i.id) === c)
@@ -629,7 +629,7 @@ function nt(t, n) {
629
629
  if (!(!n || !o)) {
630
630
  w(!0), p(void 0);
631
631
  try {
632
- const e = new Blob([o], { type: "text/plain; charset=utf-8" }), s = `writing-${t.id}-${Date.now()}.txt`, l = await n(e, s);
632
+ const e = new Blob([o], { type: "text/plain; charset=utf-8" }), s = `writing-${Date.now()}.txt`, l = await n(e, s);
633
633
  l.success && l.url ? I(l.url) : p(l.error || "Upload failed");
634
634
  } catch (e) {
635
635
  console.error("Text upload failed:", e), p(
@@ -639,14 +639,13 @@ function nt(t, n) {
639
639
  w(!1);
640
640
  }
641
641
  }
642
- }, [o, t.id, n]), c = T(
642
+ }, [o, n]), c = T(
643
643
  () => ({
644
- questionId: t.id || "",
645
644
  type: "writing",
646
645
  text: o,
647
646
  fileUrl: h
648
647
  }),
649
- [t.id, o, h]
648
+ [o, h]
650
649
  ), i = R(() => (C(), c), [C, c]), r = R(() => {
651
650
  d(""), I(void 0), p(void 0), S();
652
651
  }, [S]);
@@ -698,13 +697,13 @@ function st(t, n) {
698
697
  }, 1e3));
699
698
  }, [h]), B = R(() => {
700
699
  r.current && h !== "idle" && (r.current.stop(), I("stopped"), s.current && clearInterval(s.current), l.current && l.current.getTracks().forEach((Q) => Q.stop()), i(!1));
701
- }, [h]), L = R(() => c ? B() : g(), []), M = R(async () => {
700
+ }, [h]), L = R(() => c ? B() : g(), [c]), M = R(async () => {
702
701
  if (!(!e.current.length || !n)) {
703
702
  p(!0), a(void 0);
704
703
  try {
705
704
  const Q = new Blob(e.current, {
706
705
  type: "audio/webm"
707
- }), k = `speaking-${t.id}-${Date.now()}.webm`, O = await n(Q, k);
706
+ }), k = `speaking-${Date.now()}.webm`, O = await n(Q, k);
708
707
  O.success && O.url ? d(O.url) : a(O.error || "Upload failed");
709
708
  } catch (Q) {
710
709
  console.error("Upload failed:", Q), a(Q instanceof Error ? Q.message : "Upload failed");
@@ -712,7 +711,7 @@ function st(t, n) {
712
711
  p(!1);
713
712
  }
714
713
  }
715
- }, [t.id, n]), D = R(
714
+ }, [t, n]), D = R(
716
715
  async (Q) => {
717
716
  if (n) {
718
717
  p(!0), a(void 0);
@@ -731,12 +730,11 @@ function st(t, n) {
731
730
  [n]
732
731
  ), j = T(
733
732
  () => ({
734
- questionId: t.id || "",
735
733
  type: "speaking",
736
734
  audioUrl: o
737
735
  }),
738
- [t.id, o]
739
- ), G = R(() => (C(), j), [C, j]), N = R(() => {
736
+ [t, o]
737
+ ), $ = R(() => (C(), j), [C, j]), N = R(() => {
740
738
  d(void 0), I("idle"), w(0), a(void 0), e.current = [], s.current && clearInterval(s.current), l.current && l.current.getTracks().forEach((Q) => Q.stop()), S();
741
739
  }, [S]);
742
740
  return {
@@ -759,7 +757,7 @@ function st(t, n) {
759
757
  toggleRecording: L,
760
758
  uploadAudio: M,
761
759
  uploadFile: D,
762
- submit: G,
760
+ submit: $,
763
761
  reset: N
764
762
  };
765
763
  }
@@ -832,7 +830,7 @@ function bt({
832
830
  uploadHandler: u
833
831
  }) {
834
832
  const f = t(), b = nt(f, u);
835
- return /* @__PURE__ */ W($, { children: n(b) });
833
+ return /* @__PURE__ */ W(z, { children: n(b) });
836
834
  }
837
835
  function wt({
838
836
  getData: t,
@@ -840,7 +838,7 @@ function wt({
840
838
  uploadHandler: u
841
839
  }) {
842
840
  const f = t(), b = st(f, u);
843
- return /* @__PURE__ */ W($, { children: n(b) });
841
+ return /* @__PURE__ */ W(z, { children: n(b) });
844
842
  }
845
843
  export {
846
844
  lt as DragDropQuestion,
@@ -855,7 +853,7 @@ export {
855
853
  at as VideoQuestion,
856
854
  bt as WritingQuestion,
857
855
  J as isSameSet,
858
- z as shuffleArray,
856
+ G as shuffleArray,
859
857
  E as useBaseQuestion,
860
858
  K as useDragDrop,
861
859
  tt as useFillInBlank,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enspiredigital/xlms-headless",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",