@cuemath/leap 3.1.1-aa0 → 3.1.1-aa2
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,95 +1,88 @@
|
|
1
|
-
import { jsx as
|
2
|
-
import { memo as
|
3
|
-
import
|
4
|
-
import { CueCanvasCore as
|
5
|
-
import { getCanvasConfig as
|
6
|
-
import { CueCanvasWrapper as
|
7
|
-
import
|
8
|
-
import
|
9
|
-
import
|
10
|
-
|
1
|
+
import { jsx as j } from "react/jsx-runtime";
|
2
|
+
import { memo as k, useRef as x, useCallback as A, useEffect as n } from "react";
|
3
|
+
import I from "../worksheet/learnosity-preloader/use-is-learnosity-loaded.js";
|
4
|
+
import { CueCanvasCore as P } from "./cue-canvas-core.js";
|
5
|
+
import { getCanvasConfig as W, getCanvasSettings as q } from "./cue-canvas-helpers.js";
|
6
|
+
import { CueCanvasWrapper as y } from "./cue-cavas-styled.js";
|
7
|
+
import z from "./hooks/use-config-updater.js";
|
8
|
+
import { useCueCanvasActions as B } from "./hooks/use-cue-canvas-actions.js";
|
9
|
+
import F from "./hooks/use-height-extender.js";
|
10
|
+
import G from "./hooks/use-upload-helper.js";
|
11
|
+
const J = k(
|
11
12
|
({
|
12
|
-
canvasId:
|
13
|
-
width:
|
14
|
-
height:
|
15
|
-
canRender:
|
16
|
-
onUpdateHeight:
|
17
|
-
initialData:
|
18
|
-
onPublish:
|
19
|
-
onSubscribe:
|
20
|
-
userId:
|
21
|
-
appended:
|
22
|
-
canScribble:
|
23
|
-
userType:
|
24
|
-
renderAs:
|
25
|
-
canvasConfig:
|
26
|
-
updateCanvasConfig:
|
13
|
+
canvasId: i,
|
14
|
+
width: u,
|
15
|
+
height: o,
|
16
|
+
canRender: C,
|
17
|
+
onUpdateHeight: E,
|
18
|
+
initialData: a,
|
19
|
+
onPublish: p,
|
20
|
+
onSubscribe: l,
|
21
|
+
userId: g,
|
22
|
+
appended: $,
|
23
|
+
canScribble: r,
|
24
|
+
userType: s,
|
25
|
+
renderAs: e = "canvas",
|
26
|
+
canvasConfig: U,
|
27
|
+
updateCanvasConfig: H
|
27
28
|
}) => {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
R(x);
|
29
|
+
const f = x(null), { setActiveInstance: c, setActiveTool: d } = B(), L = G({ userId: g, renderAs: e, userType: s }), { scriptStatus: w } = I(), t = x(null), R = A(
|
30
|
+
(m) => {
|
31
|
+
d(m);
|
32
32
|
},
|
33
|
-
[
|
33
|
+
[d]
|
34
34
|
);
|
35
|
-
return
|
36
|
-
canvasElementRef:
|
35
|
+
return F({
|
36
|
+
canvasElementRef: f,
|
37
37
|
cueCanvasRef: t,
|
38
|
-
canScribble:
|
39
|
-
}),
|
40
|
-
t.current && (
|
41
|
-
}, [
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
uploadImageToS3: W,
|
60
|
-
height: m,
|
61
|
-
userId: H,
|
62
|
-
canvasId: E,
|
63
|
-
userType: l,
|
64
|
-
renderAs: r,
|
65
|
-
updateCanvasConfig: I
|
38
|
+
canScribble: r
|
39
|
+
}), z(U), n(() => {
|
40
|
+
r && t.current && (t.current.resetViewPort(), c(t.current));
|
41
|
+
}, [r, c]), n(() => {
|
42
|
+
a && t.current && t.current.update(a);
|
43
|
+
}, [a]), n(() => {
|
44
|
+
o && t.current && t.current.resetViewPort();
|
45
|
+
}, [o, u]), n(() => {
|
46
|
+
if (C && $ && !t.current && w === "loaded") {
|
47
|
+
const m = W(u, o, e, s), V = q(e, s), v = new P({
|
48
|
+
onPublish: p,
|
49
|
+
onSubscribe: l,
|
50
|
+
onUpdateActiveTool: R,
|
51
|
+
onUpdateHeight: E,
|
52
|
+
uploadImageToS3: L,
|
53
|
+
height: o,
|
54
|
+
userId: g,
|
55
|
+
canvasId: i,
|
56
|
+
userType: s,
|
57
|
+
renderAs: e,
|
58
|
+
updateCanvasConfig: H
|
66
59
|
});
|
67
60
|
(async () => {
|
68
|
-
await
|
69
|
-
canvasElementRef:
|
70
|
-
canvasConfig:
|
71
|
-
canvasSetting:
|
72
|
-
initialData:
|
73
|
-
}), t.current =
|
61
|
+
await v.create({
|
62
|
+
canvasElementRef: f,
|
63
|
+
canvasConfig: m,
|
64
|
+
canvasSetting: V,
|
65
|
+
initialData: a
|
66
|
+
}), t.current = v, r && c(v);
|
74
67
|
})();
|
75
68
|
}
|
76
|
-
}, [
|
69
|
+
}, [p, l, c, C, $, w]), n(() => () => {
|
77
70
|
t.current && (t.current.destroy(), t.current = null);
|
78
|
-
}, []), /* @__PURE__ */
|
79
|
-
|
71
|
+
}, []), /* @__PURE__ */ j(
|
72
|
+
y,
|
80
73
|
{
|
81
|
-
id:
|
82
|
-
ref:
|
83
|
-
$width:
|
84
|
-
$height:
|
85
|
-
$canScribble:
|
86
|
-
$canRender:
|
87
|
-
$renderAs:
|
74
|
+
id: e === "whiteboard" ? "canvasContainer" : i,
|
75
|
+
ref: f,
|
76
|
+
$width: u,
|
77
|
+
$height: o,
|
78
|
+
$canScribble: r,
|
79
|
+
$canRender: C,
|
80
|
+
$renderAs: e
|
88
81
|
}
|
89
82
|
);
|
90
83
|
}
|
91
|
-
),
|
84
|
+
), D = J;
|
92
85
|
export {
|
93
|
-
|
86
|
+
D as default
|
94
87
|
};
|
95
88
|
//# sourceMappingURL=cue-canvas.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cue-canvas.js","sources":["../../../src/features/cue-canvas/cue-canvas.tsx"],"sourcesContent":["import type { ICueCanvas, TCueCanvasTool } from './types/cue-canvas';\n\nimport { memo, useCallback, useEffect, useRef } from 'react';\n\nimport useIsLearnosityLoaded from '../worksheet/learnosity-preloader/use-is-learnosity-loaded';\nimport { CueCanvasCore } from './cue-canvas-core';\nimport { getCanvasConfig, getCanvasSettings } from './cue-canvas-helpers';\nimport { CueCanvasWrapper } from './cue-cavas-styled';\nimport { useCueCanvasActions } from './hooks/use-cue-canvas-actions';\nimport useHeightExtender from './hooks/use-height-extender';\nimport useUploadHelper from './hooks/use-upload-helper';\n\nconst CueCanvas: React.FC<ICueCanvas> = memo(\n ({\n canvasId,\n width,\n height,\n canRender,\n onUpdateHeight,\n initialData,\n onPublish,\n onSubscribe,\n userId,\n appended,\n canScribble,\n userType,\n renderAs = 'canvas',\n canvasConfig,\n updateCanvasConfig,\n }) => {\n const canvasElementRef = useRef<HTMLDivElement>(null);\n const { setActiveInstance: setActiveCueCanvas, setActiveTool } = useCueCanvasActions();\n const uploadImageToS3 = useUploadHelper({ userId, renderAs, userType });\n const { scriptStatus } = useIsLearnosityLoaded(); // This hook checks if the Polypad script is loaded + (additional scripts)\n\n const cueCanvasRef = useRef<CueCanvasCore | null>(null);\n\n const onUpdateActiveTool = useCallback(\n (tool: TCueCanvasTool) => {\n setActiveTool(tool);\n },\n [setActiveTool],\n );\n\n useHeightExtender({\n canvasElementRef,\n cueCanvasRef,\n canScribble,\n });\n
|
1
|
+
{"version":3,"file":"cue-canvas.js","sources":["../../../src/features/cue-canvas/cue-canvas.tsx"],"sourcesContent":["import type { ICueCanvas, TCueCanvasTool } from './types/cue-canvas';\n\nimport { memo, useCallback, useEffect, useRef } from 'react';\n\nimport useIsLearnosityLoaded from '../worksheet/learnosity-preloader/use-is-learnosity-loaded';\nimport { CueCanvasCore } from './cue-canvas-core';\nimport { getCanvasConfig, getCanvasSettings } from './cue-canvas-helpers';\nimport { CueCanvasWrapper } from './cue-cavas-styled';\nimport useConfigUpdater from './hooks/use-config-updater';\nimport { useCueCanvasActions } from './hooks/use-cue-canvas-actions';\nimport useHeightExtender from './hooks/use-height-extender';\nimport useUploadHelper from './hooks/use-upload-helper';\n\nconst CueCanvas: React.FC<ICueCanvas> = memo(\n ({\n canvasId,\n width,\n height,\n canRender,\n onUpdateHeight,\n initialData,\n onPublish,\n onSubscribe,\n userId,\n appended,\n canScribble,\n userType,\n renderAs = 'canvas',\n canvasConfig,\n updateCanvasConfig,\n }) => {\n const canvasElementRef = useRef<HTMLDivElement>(null);\n const { setActiveInstance: setActiveCueCanvas, setActiveTool } = useCueCanvasActions();\n const uploadImageToS3 = useUploadHelper({ userId, renderAs, userType });\n const { scriptStatus } = useIsLearnosityLoaded(); // This hook checks if the Polypad script is loaded + (additional scripts)\n\n const cueCanvasRef = useRef<CueCanvasCore | null>(null);\n\n const onUpdateActiveTool = useCallback(\n (tool: TCueCanvasTool) => {\n setActiveTool(tool);\n },\n [setActiveTool],\n );\n\n useHeightExtender({\n canvasElementRef,\n cueCanvasRef,\n canScribble,\n });\n useConfigUpdater(canvasConfig);\n\n useEffect(() => {\n if (canScribble && cueCanvasRef.current) {\n cueCanvasRef.current.resetViewPort();\n\n setActiveCueCanvas(cueCanvasRef.current);\n }\n }, [canScribble, setActiveCueCanvas]);\n\n useEffect(() => {\n if (initialData && cueCanvasRef.current) {\n cueCanvasRef.current.update(initialData);\n }\n }, [initialData]);\n\n useEffect(() => {\n if (height && cueCanvasRef.current) {\n cueCanvasRef.current.resetViewPort();\n }\n }, [height, width]);\n\n useEffect(() => {\n if (canRender && appended && !cueCanvasRef.current && scriptStatus === 'loaded') {\n const canvasCreateConfig = getCanvasConfig(width, height, renderAs, userType);\n const canvasSetting = getCanvasSettings(renderAs, userType);\n const cueCanvasCore = new CueCanvasCore({\n onPublish,\n onSubscribe,\n onUpdateActiveTool,\n onUpdateHeight,\n uploadImageToS3,\n height,\n userId,\n canvasId,\n userType,\n renderAs,\n updateCanvasConfig,\n });\n\n const createCueCanvas = async () => {\n await cueCanvasCore.create({\n canvasElementRef,\n canvasConfig: canvasCreateConfig,\n canvasSetting,\n initialData,\n });\n cueCanvasRef.current = cueCanvasCore;\n\n if (canScribble) {\n setActiveCueCanvas(cueCanvasCore);\n }\n };\n\n createCueCanvas();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [onPublish, onSubscribe, setActiveCueCanvas, canRender, appended, scriptStatus]);\n\n useEffect(() => {\n return () => {\n if (cueCanvasRef.current) {\n cueCanvasRef.current.destroy();\n cueCanvasRef.current = null;\n }\n };\n }, []);\n\n return (\n <CueCanvasWrapper\n id={renderAs === 'whiteboard' ? 'canvasContainer' : canvasId}\n ref={canvasElementRef}\n $width={width}\n $height={height}\n $canScribble={canScribble}\n $canRender={canRender}\n $renderAs={renderAs}\n />\n );\n },\n);\n\nexport default CueCanvas;\n"],"names":["CueCanvas","memo","canvasId","width","height","canRender","onUpdateHeight","initialData","onPublish","onSubscribe","userId","appended","canScribble","userType","renderAs","canvasConfig","updateCanvasConfig","canvasElementRef","useRef","setActiveCueCanvas","setActiveTool","useCueCanvasActions","uploadImageToS3","useUploadHelper","scriptStatus","useIsLearnosityLoaded","cueCanvasRef","onUpdateActiveTool","useCallback","tool","useHeightExtender","useConfigUpdater","useEffect","canvasCreateConfig","getCanvasConfig","canvasSetting","getCanvasSettings","cueCanvasCore","CueCanvasCore","jsx","CueCanvasWrapper","CueCanvas$1"],"mappings":";;;;;;;;;;AAaA,MAAMA,IAAkCC;AAAA,EACtC,CAAC;AAAA,IACC,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,aAAAC;AAAA,IACA,WAAAC;AAAA,IACA,aAAAC;AAAA,IACA,QAAAC;AAAA,IACA,UAAAC;AAAA,IACA,aAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,cAAAC;AAAA,IACA,oBAAAC;AAAA,EAAA,MACI;AACE,UAAAC,IAAmBC,EAAuB,IAAI,GAC9C,EAAE,mBAAmBC,GAAoB,eAAAC,MAAkBC,EAAoB,GAC/EC,IAAkBC,EAAgB,EAAE,QAAAb,GAAQ,UAAAI,GAAU,UAAAD,GAAU,GAChE,EAAE,cAAAW,MAAiBC,KAEnBC,IAAe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,CAAa;AAAA,QAClC;MAIJ;AAAA,IAAA,GAEC,CAAC7B,GAAWC,GAAaU,GAAoBd,GAAWM,GAAUa,CAAY,CAAC,GAElFQ,EAAU,MACD,MAAM;AACX,MAAIN,EAAa,YACfA,EAAa,QAAQ,WACrBA,EAAa,UAAU;AAAA,IACzB,GAED,CAAE,CAAA,GAGH,gBAAAa;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,IAAI1B,MAAa,eAAe,oBAAoBZ;AAAA,QACpD,KAAKe;AAAA,QACL,QAAQd;AAAA,QACR,SAASC;AAAA,QACT,cAAcQ;AAAA,QACd,YAAYP;AAAA,QACZ,WAAWS;AAAA,MAAA;AAAA,IAAA;AAAA,EAGjB;AACF,GAEA2B,IAAezC;"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { useEffect as r } from "react";
|
2
|
+
import { useCueCanvasActions as m } from "./use-cue-canvas-actions.js";
|
3
|
+
const p = (e) => {
|
4
|
+
const { activeInstance: t } = m();
|
5
|
+
r(() => {
|
6
|
+
t && (e != null && e.gridName && t.changeGrid(e == null ? void 0 : e.gridName), e != null && e.dimesion && t.setViewPort(e == null ? void 0 : e.dimesion));
|
7
|
+
}, [e, t]);
|
8
|
+
};
|
9
|
+
export {
|
10
|
+
p as default
|
11
|
+
};
|
12
|
+
//# sourceMappingURL=use-config-updater.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-config-updater.js","sources":["../../../../src/features/cue-canvas/hooks/use-config-updater.ts"],"sourcesContent":["import type { ICanvasUpdateConfig } from '../types/cue-canvas';\n\nimport { useEffect } from 'react';\n\nimport { useCueCanvasActions } from './use-cue-canvas-actions';\n\nconst useConfigUpdater = (canvasConfig?: ICanvasUpdateConfig | null) => {\n const { activeInstance: cueCanvas } = useCueCanvasActions();\n\n useEffect(() => {\n if (!cueCanvas) {\n return;\n }\n\n if (canvasConfig?.gridName) {\n cueCanvas.changeGrid(canvasConfig?.gridName);\n }\n\n if (canvasConfig?.dimesion) {\n cueCanvas.setViewPort(canvasConfig?.dimesion);\n }\n }, [canvasConfig, cueCanvas]);\n};\n\nexport default useConfigUpdater;\n"],"names":["useConfigUpdater","canvasConfig","cueCanvas","useCueCanvasActions","useEffect"],"mappings":";;AAMM,MAAAA,IAAmB,CAACC,MAA8C;AACtE,QAAM,EAAE,gBAAgBC,EAAU,IAAIC,EAAoB;AAE1D,EAAAC,EAAU,MAAM;AACd,IAAKF,MAIDD,KAAA,QAAAA,EAAc,YACNC,EAAA,WAAWD,KAAA,gBAAAA,EAAc,QAAQ,GAGzCA,KAAA,QAAAA,EAAc,YACNC,EAAA,YAAYD,KAAA,gBAAAA,EAAc,QAAQ;AAAA,EAC9C,GACC,CAACA,GAAcC,CAAS,CAAC;AAC9B;"}
|