@capytale/meta-player 0.6.13 → 0.6.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capytale/meta-player",
3
- "version": "0.6.13",
3
+ "version": "0.6.15",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -45,11 +45,11 @@ const MetaPlayer: FC<MetaPlayerProps> = (props) => {
45
45
  const primeSettings: Partial<APIOptions> = {
46
46
  ripple: true,
47
47
  };
48
- const antiCheatOptions: AntiCheatOptions = {
48
+ const antiCheatOptions: AntiCheatOptions = useMemo(() => ({
49
49
  preserveDom: true,
50
50
  hasIframes: false,
51
51
  ...props.antiCheatOptions,
52
- };
52
+ }), [props.antiCheatOptions]);
53
53
  const uiOptions: UIOptions = {
54
54
  closePedagoByDefault: false,
55
55
  noWorkflow: false,
@@ -24,6 +24,13 @@ const ActivityJSContext = createContext<ActivitySessionLoaderReturnValue>({
24
24
  state: "initial",
25
25
  });
26
26
 
27
+ export type BinaryDataMode =
28
+ | "json"
29
+ | "text"
30
+ | "blob"
31
+ | "arrayBuffer"
32
+ | "stream";
33
+
27
34
  type ActivityJSProviderProps = PropsWithChildren<{
28
35
  options?: LoadOptions;
29
36
  loadingFallback?: ReactNode;
@@ -217,6 +224,29 @@ export const useActivityJsEssentials = () => {
217
224
  }
218
225
  return getActivityBinaryData();
219
226
  };
227
+
228
+ const retrieveAndGetActivityBinaryData = async (mode: BinaryDataMode) => {
229
+ await ab.activityNode.binaryData.loadAsync(mode);
230
+ return ab.activityNode.binaryData.value as any;
231
+ };
232
+ const retrieveAndGetAssignmentBinaryData = async (mode: BinaryDataMode) => {
233
+ if (!ab.assignmentNode) {
234
+ throw new Error("No assignment node");
235
+ }
236
+ await ab.assignmentNode.binaryData.loadAsync(mode);
237
+ return ab.assignmentNode.binaryData.value as any;
238
+ };
239
+ const retrieveAndGetBinaryData = async (mode: BinaryDataMode) => {
240
+ if (!hasAssignment) {
241
+ return await retrieveAndGetActivityBinaryData(mode);
242
+ }
243
+ const assignmentBinaryData = await retrieveAndGetAssignmentBinaryData(mode);
244
+ if (assignmentBinaryData != null) {
245
+ return assignmentBinaryData;
246
+ }
247
+ return await retrieveAndGetActivityBinaryData(mode);
248
+ }
249
+
220
250
  const setActivityContent = (content: string | null) => {
221
251
  ab.activityNode.content.value = content;
222
252
  };
@@ -262,6 +292,9 @@ export const useActivityJsEssentials = () => {
262
292
  getActivityBinaryData,
263
293
  getAssignmentBinaryData,
264
294
  getBinaryData,
295
+ retrieveAndGetActivityBinaryData,
296
+ retrieveAndGetAssignmentBinaryData,
297
+ retrieveAndGetBinaryData,
265
298
  setActivityContent,
266
299
  setAssignmentContent,
267
300
  setContent,
@@ -6,6 +6,7 @@ import {
6
6
  setPreviewFile,
7
7
  } from "./functionalitiesSlice";
8
8
  import { Dialog } from "primereact/dialog";
9
+ import { useThemeType } from "../theming/hooks";
9
10
 
10
11
  const HighlightedCode = memo(({ code }: { code: string }) => {
11
12
  const codeRef = useRef<HTMLDivElement>(null);
@@ -19,11 +20,17 @@ const HighlightedCode = memo(({ code }: { code: string }) => {
19
20
  }
20
21
  }, [code]);
21
22
 
23
+ const theme = useThemeType();
24
+
22
25
  return (
23
26
  <pre>
24
27
  <code
25
28
  ref={codeRef}
26
- style={{ padding: 0, background: "white", maxWidth: "100%" }}
29
+ style={{
30
+ padding: 0,
31
+ background: theme === "light" ? "white" : "#1f2937",
32
+ maxWidth: "100%",
33
+ }}
27
34
  >
28
35
  {code}
29
36
  </code>
package/src/index.ts CHANGED
@@ -41,6 +41,7 @@ import type {
41
41
 
42
42
  import type { ActivityMode } from "@capytale/activity.js/activity/activitySession";
43
43
  import type { Workflow } from "./features/activityData/activityJsData";
44
+ import type { BinaryDataMode } from "./features/activityJS/ActivityJSProvider";
44
45
 
45
46
  export {
46
47
  MetaPlayer,
@@ -74,7 +75,8 @@ export {
74
75
  export type {
75
76
  ActivityMode,
76
77
  AttachedFileData,
77
- UploadedFileInfo,
78
+ BinaryDataMode,
78
79
  ToastMessage,
80
+ UploadedFileInfo,
79
81
  Workflow,
80
82
  };