@capytale/iframe-react 1.0.5 → 1.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.md +5 -5
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +48 -88
- package/dist/index.es.js +334 -199
- package/package.json +51 -51
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# Capytale iframe React
|
|
2
|
-
|
|
3
|
-
Une bibliothèque React pour intégrer une application React à la plateforme Capytale.
|
|
4
|
-
|
|
5
|
-
Elle gère la communication entre l'application React et le conteneur Capytale, en utilisant des contrats metaplayer-rpc.
|
|
1
|
+
# Capytale iframe React
|
|
2
|
+
|
|
3
|
+
Une bibliothèque React pour intégrer une application React à la plateforme Capytale.
|
|
4
|
+
|
|
5
|
+
Elle gère la communication entre l'application React et le conteneur Capytale, en utilisant des contrats metaplayer-rpc.
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react/jsx-runtime"),u=require("react"),E=require("@capytale/app-agent"),x=t=>{let e;const n=new Set,s=(c,p)=>{const S=typeof c=="function"?c(e):c;if(!Object.is(S,e)){const y=e;e=p??(typeof S!="object"||S===null)?S:Object.assign({},e,S),n.forEach(g=>g(e,y))}},i=()=>e,l={setState:s,getState:i,getInitialState:()=>a,subscribe:c=>(n.add(c),()=>n.delete(c))},a=e=t(s,i,l);return l},M=t=>t?x(t):x,q=t=>t;function j(t,e=q){const n=u.useSyncExternalStore(t.subscribe,()=>e(t.getState()),()=>e(t.getInitialState()));return u.useDebugValue(n),n}const h=t=>{const e=M(t),n=s=>j(e,s);return Object.assign(n,e),n},J=t=>t?h(t):h,I=t=>(e,n,s)=>{const i=s.subscribe;return s.subscribe=(r,l,a)=>{let c=r;if(l){const p=(a==null?void 0:a.equalityFn)||Object.is;let S=r(s.getState());c=y=>{const g=r(y);if(!p(S,g)){const F=S;l(S=g,F)}},a!=null&&a.fireImmediately&&l(S,S)}return i(c)},t(e,n,s)},$=I,o=J()($(t=>({ready:!1,workflow:"current",mode:"assignment",theme:"light",saveCount:0,afterSaveCount:0,isDirtyCount:0,loadedTextContent:null,loadedJsonContent:null,getTextContentFunction:()=>(console.error("getTextContentFunction is not set"),null),getJsonContentFunction:()=>(console.error("getJsonContentFunction is not set"),null),sidebarActions:{},quickActions:{},activitySettings:null,setGetTextContentFunction:e=>{t({getTextContentFunction:e})},setGetJsonContentFunction:e=>{t({getJsonContentFunction:e})},setSidebarActions:e=>{t({sidebarActions:e})},setQuickActions:e=>{t({quickActions:e})},setActivitySettings:e=>{t({activitySettings:e})},incSaveCount:()=>t(e=>({saveCount:e.saveCount+1})),incDirtyCount:()=>t(e=>({isDirtyCount:e.isDirtyCount+1}))})));let k=!1;const P=["meta-player-events:1","meta-player-ui:1","mode:1","reload:1","theme:1","workflow:1","simple-content(text):1","simple-content(json):1","simple-binary-data(text):1","simple-content-eval(text):1","simple-content-eval(json):1"],T={"mode:1":{setMode:t=>{o.setState({mode:t})}},"reload:1":{reloaded:t=>{console.log("Reloaded with state:",t),console.error("Not implemented yet")}},"theme:1":{setTheme:t=>{if(t===null){o.setState({theme:null});return}if(t!=="light"&&t!=="dark"){console.warn(`Invalid theme: ${t}. Expected 'light' or 'dark'.`),o.setState({theme:null});return}o.setState({theme:t})}},"workflow:1":{setWorkflow:t=>{o.setState({workflow:t})}},"simple-content(text):1":{contentSaved:()=>{o.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>o.getState().getTextContentFunction(),loadContent:t=>{o.setState({loadedTextContent:t})}},"simple-content(json):1":{contentSaved:()=>{o.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>o.getState().getJsonContentFunction(),loadContent:t=>{o.setState({loadedJsonContent:t})}},"simple-binary-data(text):1":{contentSaved:()=>{o.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>o.getState().getTextContentFunction(),loadContent:t=>{o.setState({loadedTextContent:t})}},"simple-content-eval(text):1":{contentSaved:()=>{o.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>o.getState().getTextContentFunction(),loadContent:t=>{o.setState({loadedTextContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(text)")}},"simple-content-eval(json):1":{contentSaved:()=>{o.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>o.getState().getJsonContentFunction(),loadContent:t=>{o.setState({loadedJsonContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(json)")}},"simple-content-eval(json):2":{contentSaved:()=>{o.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>o.getState().getJsonContentFunction(),loadContent:t=>{o.setState({loadedJsonContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(json)")}},"simple-content-eval(text):2":{contentSaved:()=>{o.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>o.getState().getTextContentFunction(),loadContent:t=>{o.setState({loadedTextContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(text)")}},"meta-player-ui:1":{executeAction(t){if(t.startsWith("qa")){const n=o.getState().quickActions[t];n?n():console.error(`Quick action not found: ${t}`)}else{const n=o.getState().sidebarActions[t];n?n():console.error(`Sidebar action not found: ${t}`)}},executeFileUpload(t,e){if(t.startsWith("qa")){const s=o.getState().quickActions[t];s?s(e):console.error(`Quick action not found: ${t}`)}else{const s=o.getState().sidebarActions[t];s?s(e):console.error(`Sidebar action not found: ${t}`)}},updateSettings(t){o.setState({activitySettings:t})}},"meta-player-events:1":{handleEvent(t){t==="all-loaded"&&o.setState({ready:!0})}}},f=E.getSocket();function L(t){if(k){console.warn("Contracts have already been plugged. Skipping.");return}k=!0;for(const e of t){if(!P.includes(e)){console.warn(`Contract ${e} is not implemented in Capytale. Skipping plug.`);continue}if(!(e in T)){console.warn(`Contract handler for ${e} is not defined. Skipping plug.`);continue}const n=T[e];f.plug([e],([])=>[n])}f.plugsDone();for(const e of["simple-content(text):1","simple-content(json):1","simple-binary-data(text):1","simple-content-eval(text):1","simple-content-eval(json):1","simple-content-eval(json):2","simple-content-eval(text):2"])if(console.log(`Contract ${e} is being subscribed to content changes.`),t.includes(e)){console.log(`Subscribing to content changes for contract ${e}`);const n=e.split(":")[0];f.use([n],([s])=>{o.subscribe(i=>i.isDirtyCount,()=>{var i;(i=s.i)==null||i.contentChanged(),console.log(`Content changed for contract ${n}`)})})}}function R({children:t,contracts:e,loadOnlyWhenReady:n=!0}){const s=o(i=>i.ready);return u.useEffect(()=>{const i=e.includes("meta-player-events:1")?e:[...e,"meta-player-events:1"];L(i)},[]),n&&!s?w.jsx("div",{className:"container",children:"Chargement en cours..."}):w.jsx("div",{className:"container",children:t})}const D=()=>o(t=>{if(t.mode===null)throw new Error("Mode is not set. Have you used contract 'mode'?");return t.mode}),Q=()=>o(t=>{if(t.workflow===null)throw new Error("Workflow is not set. Have you used contract 'workflow'?");return t.workflow}),W=()=>o(t=>{if(t.theme===null)throw new Error("Theme is not set. Have you used contract 'theme'?");return t.theme}),N=()=>o(t=>t.incSaveCount),O=()=>o(t=>t.incDirtyCount),G=()=>o(t=>t.loadedTextContent),H=()=>o(t=>t.loadedJsonContent),U=t=>{const e=o(n=>n.setGetTextContentFunction);u.useEffect(()=>{e(t)},[t,e])},B=t=>{const e=o(n=>n.setGetJsonContentFunction);u.useEffect(()=>{e(t)},[t,e])},V=t=>{const e=o(n=>n.afterSaveCount);u.useEffect(()=>{e>0&&t()},[e])},_=()=>(t,e)=>{f.use(["meta-player-ui"],([n])=>{var s;if(n.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}(s=n.i)==null||s.previewTextFile(t,e)})},z=()=>(t,e)=>{f.use(["meta-player-ui"],([n])=>{var s;if(n.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}(s=n.i)==null||s.previewImageFile(t,e)})};let C=0,b=0;const K=(t,e)=>{const n=u.useMemo(t,e),s=o(i=>i.setSidebarActions);u.useEffect(()=>(C++,C>1&&console.error("Capytale iframe React: Multiple sidebar actions registered: ",C),()=>{C--}),[]),u.useEffect(()=>(f.use(["meta-player-ui"],([i])=>{var l;if(i.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}b++;const d=n.map((a,c)=>({type:a.type,title:a.title,icon:a.icon,id:`sa-${b}-${c}`,...a.type==="file-upload"?{accept:a.accept}:{}})),r={};n.forEach((a,c)=>{r[`sa-${b}-${c}`]=a.action}),(l=i.i)==null||l.setSidebarActionButtons(d),s(r)}),()=>{s({}),f.use(["meta-player-ui"],([i])=>{var d;if(i.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}(d=i.i)==null||d.setSidebarActionButtons([])})}),[n])};let m=0,A=0;const X=(t,e)=>{const n=u.useMemo(t,e),s=o(i=>i.setQuickActions);u.useEffect(()=>(m++,m>1&&console.error("Capytale iframe React: Multiple quick actions registered: ",m),()=>{m--}),[]),u.useEffect(()=>(f.use(["meta-player-ui"],([i])=>{var l;if(i.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}A++;const d=n.map((a,c)=>({type:a.type,title:a.title,icon:a.icon,id:`qa-${A}-${c}`,...a.type==="file-upload"?{accept:a.accept}:{}})),r={};n.forEach((a,c)=>{r[`qa-${A}-${c}`]=a.action}),(l=i.i)==null||l.setQuickActionButtons(d),s(r)}),()=>{s({}),f.use(["meta-player-ui"],([i])=>{var d;if(i.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}(d=i.i)==null||d.setQuickActionButtons([])})}),[n])};let v=0;const Y=(t,e)=>{const n=u.useMemo(t,e),s=o(r=>r.setActivitySettings),i=o(r=>r.activitySettings),d=u.useRef("");return u.useEffect(()=>(console.log("Mounting useSettings"),v++,v>1&&console.error("Capytale iframe React: Multiple settings registered: ",v),()=>{v--}),[]),u.useEffect(()=>{const r=JSON.stringify(n);if(r!==d.current)return d.current=r,f.use(["meta-player-ui"],([l])=>{var a;if(l.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}console.log("Updating settings UI in MetaPlayer",n),(a=l.i)==null||a.setSettingsUI(n)}),()=>{s(null)}},[n]),i},Z=()=>e=>{f.use(["meta-player-ui"],([n])=>{var s;if(n.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}(s=n.i)==null||s.showToast(e)})};exports.Capytale=R;exports.useAfterSaveAction=V;exports.useJsonContentSaveFunction=B;exports.useLoadedJsonContent=H;exports.useLoadedTextContent=G;exports.useMode=D;exports.useNotifyIsDirty=O;exports.usePreviewImageFile=z;exports.usePreviewTextFile=_;exports.useQuickActions=X;exports.useRequestSave=N;exports.useSettings=Y;exports.useShowToast=Z;exports.useSidebarActions=K;exports.useTextContentSaveFunction=U;exports.useTheme=W;exports.useWorkflow=Q;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("react/jsx-runtime"),c=require("react"),T=require("@capytale/app-agent"),b=t=>{let e;const o=new Set,s=(l,S)=>{const g=typeof l=="function"?l(e):l;if(!Object.is(g,e)){const A=e;e=S??(typeof g!="object"||g===null)?g:Object.assign({},e,g),o.forEach(p=>p(e,A))}},i=()=>e,d={setState:s,getState:i,getInitialState:()=>a,subscribe:l=>(o.add(l),()=>o.delete(l))},a=e=t(s,i,d);return d},E=t=>t?b(t):b,L=t=>t;function G(t,e=L){const o=c.useSyncExternalStore(t.subscribe,c.useCallback(()=>e(t.getState()),[t,e]),c.useCallback(()=>e(t.getInitialState()),[t,e]));return c.useDebugValue(o),o}const w=t=>{const e=E(t),o=s=>G(e,s);return Object.assign(o,e),o},D=t=>t?w(t):w,M=t=>(e,o,s)=>{const i=s.subscribe;return s.subscribe=(u,d,a)=>{let l=u;if(d){const S=(a==null?void 0:a.equalityFn)||Object.is;let g=u(s.getState());l=A=>{const p=u(A);if(!S(g,p)){const k=g;d(g=p,k)}},a!=null&&a.fireImmediately&&d(g,g)}return i(l)},t(e,o,s)},j=M,n=D()(j(t=>({ready:!1,workflow:"current",mode:"assignment",theme:"light",saveCount:0,afterSaveCount:0,isDirtyCount:0,loadedTextContent:null,loadedJsonContent:null,loadedJsonActivityContent:null,loadedJsonAssignmentContent:null,loadedJsonActivityBinaryData:null,loadedJsonAssignmentBinaryData:null,getTextContentFunction:()=>{throw console.error("getTextContentFunction is not set"),new Error("getTextContentFunction is not set")},getJsonContentFunction:()=>{throw console.error("getJsonContentFunction is not set"),new Error("getJsonContentFunction is not set")},getJsonActivityContentFunction:()=>{throw console.error("getJsonActivityContentFunction is not set"),new Error("getJsonActivityContentFunction is not set")},getJsonAssignmentContentFunction:()=>{throw console.error("getJsonAssignmentContentFunction is not set"),new Error("getJsonAssignmentContentFunction is not set")},getJsonActivitySplitContentFunction:()=>{throw console.error("getJsonActivitySplitContentFunction is not set"),new Error("getJsonActivitySplitContentFunction is not set")},getJsonAssignmentSplitContentFunction:()=>{throw console.error("getJsonAssignmentSplitContentFunction is not set"),new Error("getJsonAssignmentSplitContentFunction is not set")},sidebarActions:{},quickActions:{},activitySettings:null,setGetTextContentFunction:e=>{t({getTextContentFunction:e})},setGetJsonContentFunction:e=>{t({getJsonContentFunction:e})},setGetJsonActivityContentFunction:e=>{t({getJsonActivityContentFunction:e})},setGetJsonAssignmentContentFunction:e=>{t({getJsonAssignmentContentFunction:e})},setGetJsonActivitySplitContentFunction:e=>{t({getJsonActivitySplitContentFunction:e})},setGetJsonAssignmentSplitContentFunction:e=>{t({getJsonAssignmentSplitContentFunction:e})},setSidebarActions:e=>{t({sidebarActions:e})},setQuickActions:e=>{t({quickActions:e})},setActivitySettings:e=>{t({activitySettings:e})},incSaveCount:()=>t(e=>({saveCount:e.saveCount+1})),incDirtyCount:()=>t(e=>({isDirtyCount:e.isDirtyCount+1}))})));let h=!1;const q=["meta-player-events:1","meta-player-ui:1","mode:1","reload:1","theme:1","workflow:1","simple-content(text):1","simple-content(json):1","simple-binary-data(text):1","simple-content-eval(text):1","simple-content-eval(json):1","separate-contents(json):1","separate-dual-contents(json):1"],x={"mode:1":{setMode:t=>{n.setState({mode:t})}},"reload:1":{reloaded:t=>{console.log("Reloaded with state:",t),console.error("Not implemented yet")}},"theme:1":{setTheme:t=>{if(t===null){n.setState({theme:null});return}if(t!=="light"&&t!=="dark"){console.warn(`Invalid theme: ${t}. Expected 'light' or 'dark'.`),n.setState({theme:null});return}n.setState({theme:t})}},"workflow:1":{setWorkflow:t=>{n.setState({workflow:t})}},"simple-content(text):1":{contentSaved:()=>{n.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>n.getState().getTextContentFunction(),loadContent:t=>{n.setState({loadedTextContent:t})}},"simple-content(json):1":{contentSaved:()=>{n.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>n.getState().getJsonContentFunction(),loadContent:t=>{n.setState({loadedJsonContent:t})}},"simple-binary-data(text):1":{contentSaved:()=>{n.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>n.getState().getTextContentFunction(),loadContent:t=>{n.setState({loadedTextContent:t})}},"simple-content-eval(text):1":{contentSaved:()=>{n.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>n.getState().getTextContentFunction(),loadContent:t=>{n.setState({loadedTextContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(text)")}},"simple-content-eval(json):1":{contentSaved:()=>{n.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>n.getState().getJsonContentFunction(),loadContent:t=>{n.setState({loadedJsonContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(json)")}},"simple-content-eval(json):2":{contentSaved:()=>{n.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>n.getState().getJsonContentFunction(),loadContent:t=>{n.setState({loadedJsonContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(json)")}},"simple-content-eval(text):2":{contentSaved:()=>{n.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>n.getState().getTextContentFunction(),loadContent:t=>{n.setState({loadedTextContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(text)")}},"separate-contents(json):1":{contentSaved:()=>{n.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},loadContent:(t,e)=>{n.setState({loadedJsonActivityContent:t,loadedJsonAssignmentContent:e})},getActivityContent:()=>n.getState().getJsonActivityContentFunction(),getAssignmentContent:()=>n.getState().getJsonAssignmentContentFunction()},"separate-dual-contents(json):1":{contentSaved:()=>{n.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},loadContent:({activityContent:t,assignmentContent:e,activityBinaryData:o,assignmentBinaryData:s})=>{n.setState({loadedJsonActivityContent:t,loadedJsonAssignmentContent:e,loadedJsonActivityBinaryData:o,loadedJsonAssignmentBinaryData:s})},getActivityContentAndData:()=>n.getState().getJsonActivitySplitContentFunction(),getAssignmentContentAndData:()=>n.getState().getJsonAssignmentSplitContentFunction()},"meta-player-anti-cheat:1":{lock:()=>{},unlock:()=>{}},"meta-player-ui:1":{executeAction(t){if(t.startsWith("qa")){const o=n.getState().quickActions[t];o?o():console.error(`Quick action not found: ${t}`)}else{const o=n.getState().sidebarActions[t];o?o():console.error(`Sidebar action not found: ${t}`)}},executeFileUpload(t,e){if(t.startsWith("qa")){const s=n.getState().quickActions[t];s?s(e):console.error(`Quick action not found: ${t}`)}else{const s=n.getState().sidebarActions[t];s?s(e):console.error(`Sidebar action not found: ${t}`)}},updateSettings(t){n.setState({activitySettings:t})}},"meta-player-events:1":{handleEvent(t){t==="all-loaded"&&n.setState({ready:!0})}}},C=T.getSocket();function I(t){if(h){console.warn("Contracts have already been plugged. Skipping.");return}h=!0;for(const e of t){if(!q.includes(e)){console.warn(`Contract ${e} is not implemented in Capytale. Skipping plug.`);continue}if(!(e in x)){console.warn(`Contract handler for ${e} is not defined. Skipping plug.`);continue}const o=x[e];C.plug([e],([])=>[o])}C.plugsDone();for(const e of["simple-content(text):1","simple-content(json):1","simple-binary-data(text):1","simple-content-eval(text):1","simple-content-eval(json):1","simple-content-eval(json):2","simple-content-eval(text):2"])if(console.log(`Contract ${e} is being subscribed to content changes.`),t.includes(e)){console.log(`Subscribing to content changes for contract ${e}`);const o=e.split(":")[0];C.use([o],([s])=>{n.subscribe(i=>i.isDirtyCount,()=>{var i;(i=s.i)==null||i.contentChanged(),console.log(`Content changed for contract ${o}`)})})}}const $=["meta-player-events:1","mode:1","workflow:1"];function B({children:t,contracts:e,loadOnlyWhenReady:o=!0}){const s=n(i=>i.ready);return c.useEffect(()=>{const i=[...e];for(const r of $)i.includes(r)||i.push(r);I(i)},[]),o&&!s?F.jsx("div",{className:"container",children:"Chargement en cours..."}):F.jsx("div",{className:"container",children:t})}const P=()=>n(t=>{if(t.mode===null)throw new Error("Mode is not set. Have you used contract 'mode'?");return t.mode}),R=()=>n(t=>{if(t.workflow===null)throw new Error("Workflow is not set. Have you used contract 'workflow'?");return t.workflow}),Q=()=>n(t=>{if(t.theme===null)throw new Error("Theme is not set. Have you used contract 'theme'?");return t.theme}),W=()=>n(t=>t.incSaveCount),N=()=>n(t=>t.incDirtyCount),O=()=>n(t=>t.loadedTextContent),H=()=>n(t=>t.loadedJsonContent),U=()=>n(t=>t.loadedJsonActivityContent),V=()=>n(t=>t.loadedJsonAssignmentContent),_=()=>n(t=>t.loadedJsonActivityBinaryData),z=()=>n(t=>t.loadedJsonAssignmentBinaryData),K=()=>n.getState().loadedTextContent,X=()=>n.getState().loadedJsonContent,Y=()=>n.getState().loadedJsonActivityContent,Z=()=>n.getState().loadedJsonAssignmentContent,tt=()=>({content:n.getState().loadedJsonActivityContent,binaryData:n.getState().loadedJsonActivityBinaryData}),et=()=>({content:n.getState().loadedJsonAssignmentContent,binaryData:n.getState().loadedJsonAssignmentBinaryData}),nt=t=>{const e=n(o=>o.setGetTextContentFunction);c.useEffect(()=>{e(t)},[t,e])},ot=t=>{const e=n(o=>o.setGetJsonContentFunction);c.useEffect(()=>{e(t)},[t,e])},st=t=>{const e=n(o=>o.setGetJsonActivityContentFunction);c.useEffect(()=>{e(t)},[t,e])},it=t=>{const e=n(o=>o.setGetJsonAssignmentContentFunction);c.useEffect(()=>{e(t)},[t,e])},at=t=>{const e=n(o=>o.setGetJsonActivitySplitContentFunction);c.useEffect(()=>{e(t)},[t,e])},ct=t=>{const e=n(o=>o.setGetJsonAssignmentSplitContentFunction);c.useEffect(()=>{e(t)},[t,e])},rt=t=>{const e=n(o=>o.afterSaveCount);c.useEffect(()=>{e>0&&t()},[e])},ut=()=>(t,e)=>{C.use(["meta-player-ui"],([o])=>{var s;if(o.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}(s=o.i)==null||s.previewTextFile(t,e)})},lt=()=>(t,e)=>{C.use(["meta-player-ui"],([o])=>{var s;if(o.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}(s=o.i)==null||s.previewImageFile(t,e)})};let v=0,f=0;const dt=(t,e)=>{const o=c.useMemo(t,e),s=n(i=>i.setSidebarActions);c.useEffect(()=>(v++,v>1&&console.error("Capytale iframe React: Multiple sidebar actions registered: ",v),()=>{v--}),[]),c.useEffect(()=>(C.use(["meta-player-ui"],([i])=>{var d;if(i.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}f++;const r=o.map((a,l)=>({type:a.type,title:a.title,icon:a.icon,id:`sa-${f}-${l}`,...a.type==="file-upload"?{accept:a.accept}:{}})),u={};o.forEach((a,l)=>{u[`sa-${f}-${l}`]=a.action}),(d=i.i)==null||d.setSidebarActionButtons(r),s(u)}),()=>{s({}),C.use(["meta-player-ui"],([i])=>{var r;if(i.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}(r=i.i)==null||r.setSidebarActionButtons([])})}),[o])};let y=0,J=0;const gt=(t,e)=>{const o=c.useMemo(t,e),s=n(i=>i.setQuickActions);c.useEffect(()=>(y++,y>1&&console.error("Capytale iframe React: Multiple quick actions registered: ",y),()=>{y--}),[]),c.useEffect(()=>(C.use(["meta-player-ui"],([i])=>{var d;if(i.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}J++;const r=o.map((a,l)=>({type:a.type,title:a.title,icon:a.icon,id:`qa-${J}-${l}`,...a.type==="file-upload"?{accept:a.accept}:{}})),u={};o.forEach((a,l)=>{u[`qa-${J}-${l}`]=a.action}),(d=i.i)==null||d.setQuickActionButtons(r),s(u)}),()=>{s({}),C.use(["meta-player-ui"],([i])=>{var r;if(i.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}(r=i.i)==null||r.setQuickActionButtons([])})}),[o])};let m=0;const Ct=(t,e)=>{const o=c.useMemo(t,e),s=n(u=>u.setActivitySettings),i=n(u=>u.activitySettings),r=c.useRef("");return c.useEffect(()=>(console.log("Mounting useSettings"),m++,m>1&&console.error("Capytale iframe React: Multiple settings registered: ",m),()=>{m--}),[]),c.useEffect(()=>{const u=JSON.stringify(o);if(u!==r.current)return r.current=u,C.use(["meta-player-ui"],([d])=>{var a;if(d.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}console.log("Updating settings UI in MetaPlayer",o),(a=d.i)==null||a.setSettingsUI(o)}),()=>{s(null)}},[o]),i},St=()=>e=>{C.use(["meta-player-ui"],([o])=>{var s;if(o.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}(s=o.i)==null||s.showToast(e)})};exports.Capytale=B;exports.useAfterSaveAction=rt;exports.useGetLoadedJsonActivityContent=Y;exports.useGetLoadedJsonActivitySplitContent=tt;exports.useGetLoadedJsonAssignmentContent=Z;exports.useGetLoadedJsonAssignmentSplitContent=et;exports.useGetLoadedJsonContent=X;exports.useGetLoadedTextContent=K;exports.useJsonActivityContentSaveFunction=st;exports.useJsonActivitySplitContentSaveFunction=at;exports.useJsonAssignmentContentSaveFunction=it;exports.useJsonAssignmentSplitContentSaveFunction=ct;exports.useJsonContentSaveFunction=ot;exports.useLoadedJsonActivityBinaryData=_;exports.useLoadedJsonActivityContent=U;exports.useLoadedJsonAssignmentBinaryData=z;exports.useLoadedJsonAssignmentContent=V;exports.useLoadedJsonContent=H;exports.useLoadedTextContent=O;exports.useMode=P;exports.useNotifyIsDirty=N;exports.usePreviewImageFile=lt;exports.usePreviewTextFile=ut;exports.useQuickActions=gt;exports.useRequestSave=W;exports.useSettings=Ct;exports.useShowToast=St;exports.useSidebarActions=dt;exports.useTextContentSaveFunction=nt;exports.useTheme=Q;exports.useWorkflow=R;
|
package/dist/index.d.ts
CHANGED
|
@@ -108,12 +108,14 @@ declare type AddIdData<C, I extends {
|
|
|
108
108
|
[Index in keyof C]: AddId<C[Index], I>;
|
|
109
109
|
} : AddId<C, I>;
|
|
110
110
|
|
|
111
|
+
declare type AllContractNames = keyof AllContracts;
|
|
112
|
+
|
|
111
113
|
declare type AllContracts = CapytaleContracts & CustomContracts;
|
|
112
114
|
|
|
113
115
|
export declare function Capytale({ children, contracts, loadOnlyWhenReady, }: PropsWithChildren<CapytaleProps>): JSX_2.Element;
|
|
114
116
|
|
|
115
117
|
declare type CapytaleProps = {
|
|
116
|
-
contracts:
|
|
118
|
+
contracts: ContractNamesExceptForced[];
|
|
117
119
|
loadOnlyWhenReady?: boolean;
|
|
118
120
|
};
|
|
119
121
|
|
|
@@ -127,15 +129,16 @@ declare type CollectionOf<T extends {
|
|
|
127
129
|
version: number;
|
|
128
130
|
}[]> = Indexed<IdContractTuple<T>>;
|
|
129
131
|
|
|
132
|
+
declare type ContractNamesExceptForced = Exclude<AllContractNames, ForcedContactNames>;
|
|
133
|
+
|
|
130
134
|
declare type CustomContracts = CollectionOf<[
|
|
131
|
-
AddIdData<
|
|
132
|
-
name: "meta-player-
|
|
133
|
-
}>,
|
|
134
|
-
AddIdData<MetaPlayerEventsV1, {
|
|
135
|
-
name: "meta-player-events";
|
|
135
|
+
AddIdData<MetaPlayerAntiCheatV1, {
|
|
136
|
+
name: "meta-player-anti-cheat";
|
|
136
137
|
}>
|
|
137
138
|
]>;
|
|
138
139
|
|
|
140
|
+
declare type ForcedContactNames = "meta-player-events:1" | "mode:1" | "workflow:1";
|
|
141
|
+
|
|
139
142
|
declare type IdContractTuple<T extends {
|
|
140
143
|
name: string;
|
|
141
144
|
version: number;
|
|
@@ -159,87 +162,21 @@ declare type Indexed<L extends [string, unknown]> = {
|
|
|
159
162
|
[I in L[0]]: Extract<L, [I, any]>[1];
|
|
160
163
|
};
|
|
161
164
|
|
|
162
|
-
declare type
|
|
163
|
-
version: 1;
|
|
164
|
-
/**
|
|
165
|
-
* L'interface qui expose le *MetaPlayer* à l'*Application*.
|
|
166
|
-
*/
|
|
167
|
-
metaplayer: {};
|
|
168
|
-
/**
|
|
169
|
-
* L'interface qui expose l'*Application* au *MetaPlayer*.
|
|
170
|
-
*/
|
|
171
|
-
application: {
|
|
172
|
-
/**
|
|
173
|
-
* Le *MetaPlayer* appelle cette méthode pour indiquer à l'*Application* qu'un événement a eu lieu.
|
|
174
|
-
*
|
|
175
|
-
* @param event l'identifiant de l'événement qui a eu lieu (pour l'instant seulement "all-loaded", qui indique que tous les contrats liés au chargement initial de l'activité ont été appelés par le *MetaPlayer*).
|
|
176
|
-
*/
|
|
177
|
-
handleEvent(event: "all-loaded" | (string & {})): void;
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
declare type MetaPlayerUIV1 = {
|
|
165
|
+
declare type MetaPlayerAntiCheatV1 = {
|
|
182
166
|
version: 1;
|
|
183
167
|
/**
|
|
184
168
|
* L'interface qui expose le *MetaPlayer* à l'*Application*.
|
|
185
169
|
*/
|
|
186
170
|
metaplayer: {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
* @param actions Un tableau d'objets décrivant les boutons d'action rapide.
|
|
190
|
-
*/
|
|
191
|
-
setQuickActionButtons(actions: QuickActionInfo[]): void;
|
|
192
|
-
/**
|
|
193
|
-
* L'*Application* peut appeler cette méthode pour définir les boutons d'action dans la barre latérale.
|
|
194
|
-
* @param actions Un tableau d'objets décrivant les boutons d'action dans la barre latérale.
|
|
195
|
-
*/
|
|
196
|
-
setSidebarActionButtons(actions: QuickActionInfo[]): void;
|
|
197
|
-
/**
|
|
198
|
-
* L'*Application* peut appeler cette méthode pour définir l'interface utilisateur des paramètres de l'activité.
|
|
199
|
-
* @param settingsUI Un objet décrivant l'interface utilisateur des paramètres de l'activité.
|
|
200
|
-
*/
|
|
201
|
-
setSettingsUI(settingsUI: ActivitySettings | null): void;
|
|
202
|
-
/**
|
|
203
|
-
* L'*Application* peut appeler cette méthode pour demander au *MetaPlayer* de prévisualiser un fichier texte.
|
|
204
|
-
* @param title le titre du fichier texte à prévisualiser.
|
|
205
|
-
* @param content le contenu du fichier texte à prévisualiser.
|
|
206
|
-
*/
|
|
207
|
-
previewTextFile(title: string, content: string): void;
|
|
208
|
-
/**
|
|
209
|
-
* L'*Application* peut appeler cette méthode pour demander au *MetaPlayer* de prévisualiser un fichier image.
|
|
210
|
-
* @param title le titre du fichier image à prévisualiser.
|
|
211
|
-
* @param url l'URL du fichier image à prévisualiser.
|
|
212
|
-
*/
|
|
213
|
-
previewImageFile(title: string, url: string): void;
|
|
214
|
-
/**
|
|
215
|
-
* L'*Application* peut appeler cette méthode pour afficher une notification.
|
|
216
|
-
* @param message Un objet décrivant le message à afficher.
|
|
217
|
-
*/
|
|
218
|
-
showToast(message: MPToastMessage): void;
|
|
171
|
+
reportGainedFocus(): void;
|
|
172
|
+
reportLostFocus(): void;
|
|
219
173
|
};
|
|
220
174
|
/**
|
|
221
175
|
* L'interface qui expose l'*Application* au *MetaPlayer*.
|
|
222
176
|
*/
|
|
223
177
|
application: {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
*
|
|
227
|
-
* @param id l'identifiant de l'action associée au bouton cliqué.
|
|
228
|
-
*/
|
|
229
|
-
executeAction(id: string): void;
|
|
230
|
-
/**
|
|
231
|
-
* Le *MetaPlayer* appelle cette méthode pour indiquer à l'*Application* que l'utilisateur a cliqué sur un bouton de type file-upload.
|
|
232
|
-
*
|
|
233
|
-
* @param id l'identifiant de l'action associée au bouton cliqué.
|
|
234
|
-
* @param file le fichier chargé par l'utilisateur.
|
|
235
|
-
*/
|
|
236
|
-
executeFileUpload(id: string, file: File): void;
|
|
237
|
-
/**
|
|
238
|
-
* Le *MetaPlayer* appelle cette méthode pour indiquer à l'*Application* que l'utilisateur a modifié les paramètres de l'activité.
|
|
239
|
-
*
|
|
240
|
-
* @param settingsUI Un objet décrivant l'interface utilisateur des paramètres de l'activité.
|
|
241
|
-
*/
|
|
242
|
-
updateSettings(settingsUI: ActivitySettings | null): void;
|
|
178
|
+
lock(): void;
|
|
179
|
+
unlock(): void;
|
|
243
180
|
};
|
|
244
181
|
};
|
|
245
182
|
|
|
@@ -270,21 +207,44 @@ declare type MPToastMessage = {
|
|
|
270
207
|
life?: number;
|
|
271
208
|
};
|
|
272
209
|
|
|
273
|
-
declare type QuickActionInfo = {
|
|
274
|
-
title: string;
|
|
275
|
-
icon: string;
|
|
276
|
-
id: string;
|
|
277
|
-
} & ({
|
|
278
|
-
type: "action";
|
|
279
|
-
} | {
|
|
280
|
-
type: "file-upload";
|
|
281
|
-
accept?: string;
|
|
282
|
-
});
|
|
283
|
-
|
|
284
210
|
export declare const useAfterSaveAction: (fn: () => any) => void;
|
|
285
211
|
|
|
212
|
+
export declare const useGetLoadedJsonActivityContent: () => any;
|
|
213
|
+
|
|
214
|
+
export declare const useGetLoadedJsonActivitySplitContent: () => {
|
|
215
|
+
content: any;
|
|
216
|
+
binaryData: any;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export declare const useGetLoadedJsonAssignmentContent: () => any;
|
|
220
|
+
|
|
221
|
+
export declare const useGetLoadedJsonAssignmentSplitContent: () => {
|
|
222
|
+
content: any;
|
|
223
|
+
binaryData: any;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export declare const useGetLoadedJsonContent: () => any;
|
|
227
|
+
|
|
228
|
+
export declare const useGetLoadedTextContent: () => string | null;
|
|
229
|
+
|
|
230
|
+
export declare const useJsonActivityContentSaveFunction: (fn: () => any) => void;
|
|
231
|
+
|
|
232
|
+
export declare const useJsonActivitySplitContentSaveFunction: (fn: () => any) => void;
|
|
233
|
+
|
|
234
|
+
export declare const useJsonAssignmentContentSaveFunction: (fn: () => any) => void;
|
|
235
|
+
|
|
236
|
+
export declare const useJsonAssignmentSplitContentSaveFunction: (fn: () => any) => void;
|
|
237
|
+
|
|
286
238
|
export declare const useJsonContentSaveFunction: (fn: () => any) => void;
|
|
287
239
|
|
|
240
|
+
export declare const useLoadedJsonActivityBinaryData: () => any;
|
|
241
|
+
|
|
242
|
+
export declare const useLoadedJsonActivityContent: () => any;
|
|
243
|
+
|
|
244
|
+
export declare const useLoadedJsonAssignmentBinaryData: () => any;
|
|
245
|
+
|
|
246
|
+
export declare const useLoadedJsonAssignmentContent: () => any;
|
|
247
|
+
|
|
288
248
|
export declare const useLoadedJsonContent: () => any;
|
|
289
249
|
|
|
290
250
|
export declare const useLoadedTextContent: () => string | null;
|
package/dist/index.es.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { getSocket as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as w } from "react/jsx-runtime";
|
|
2
|
+
import m, { useEffect as d, useMemo as b, useRef as E } from "react";
|
|
3
|
+
import { getSocket as G } from "@capytale/app-agent";
|
|
4
|
+
const h = (t) => {
|
|
5
5
|
let e;
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
if (!Object.is(
|
|
9
|
-
const
|
|
10
|
-
e =
|
|
6
|
+
const o = /* @__PURE__ */ new Set(), s = (l, S) => {
|
|
7
|
+
const g = typeof l == "function" ? l(e) : l;
|
|
8
|
+
if (!Object.is(g, e)) {
|
|
9
|
+
const f = e;
|
|
10
|
+
e = S ?? (typeof g != "object" || g === null) ? g : Object.assign({}, e, g), o.forEach((p) => p(e, f));
|
|
11
11
|
}
|
|
12
|
-
}, i = () => e,
|
|
13
|
-
return
|
|
14
|
-
}, j = (t) => t ?
|
|
15
|
-
function
|
|
16
|
-
const
|
|
12
|
+
}, i = () => e, u = { setState: s, getState: i, getInitialState: () => a, subscribe: (l) => (o.add(l), () => o.delete(l)) }, a = e = t(s, i, u);
|
|
13
|
+
return u;
|
|
14
|
+
}, j = (t) => t ? h(t) : h, M = (t) => t;
|
|
15
|
+
function L(t, e = M) {
|
|
16
|
+
const o = m.useSyncExternalStore(
|
|
17
17
|
t.subscribe,
|
|
18
|
-
() => e(t.getState()),
|
|
19
|
-
() => e(t.getInitialState())
|
|
18
|
+
m.useCallback(() => e(t.getState()), [t, e]),
|
|
19
|
+
m.useCallback(() => e(t.getInitialState()), [t, e])
|
|
20
20
|
);
|
|
21
|
-
return
|
|
21
|
+
return m.useDebugValue(o), o;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
const e = j(t),
|
|
25
|
-
return Object.assign(
|
|
26
|
-
},
|
|
23
|
+
const x = (t) => {
|
|
24
|
+
const e = j(t), o = (s) => L(e, s);
|
|
25
|
+
return Object.assign(o, e), o;
|
|
26
|
+
}, $ = (t) => t ? x(t) : x, q = (t) => (e, o, s) => {
|
|
27
27
|
const i = s.subscribe;
|
|
28
|
-
return s.subscribe = (
|
|
29
|
-
let
|
|
30
|
-
if (
|
|
31
|
-
const
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
if (!g
|
|
36
|
-
const
|
|
37
|
-
|
|
28
|
+
return s.subscribe = (r, u, a) => {
|
|
29
|
+
let l = r;
|
|
30
|
+
if (u) {
|
|
31
|
+
const S = (a == null ? void 0 : a.equalityFn) || Object.is;
|
|
32
|
+
let g = r(s.getState());
|
|
33
|
+
l = (f) => {
|
|
34
|
+
const p = r(f);
|
|
35
|
+
if (!S(g, p)) {
|
|
36
|
+
const D = g;
|
|
37
|
+
u(g = p, D);
|
|
38
38
|
}
|
|
39
|
-
},
|
|
39
|
+
}, a != null && a.fireImmediately && u(g, g);
|
|
40
40
|
}
|
|
41
|
-
return i(
|
|
42
|
-
}, t(e,
|
|
43
|
-
},
|
|
44
|
-
|
|
41
|
+
return i(l);
|
|
42
|
+
}, t(e, o, s);
|
|
43
|
+
}, I = q, n = $()(
|
|
44
|
+
I((t) => ({
|
|
45
45
|
ready: !1,
|
|
46
46
|
workflow: "current",
|
|
47
47
|
mode: "assignment",
|
|
@@ -51,8 +51,28 @@ const T = (t) => {
|
|
|
51
51
|
isDirtyCount: 0,
|
|
52
52
|
loadedTextContent: null,
|
|
53
53
|
loadedJsonContent: null,
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
loadedJsonActivityContent: null,
|
|
55
|
+
loadedJsonAssignmentContent: null,
|
|
56
|
+
loadedJsonActivityBinaryData: null,
|
|
57
|
+
loadedJsonAssignmentBinaryData: null,
|
|
58
|
+
getTextContentFunction: () => {
|
|
59
|
+
throw console.error("getTextContentFunction is not set"), new Error("getTextContentFunction is not set");
|
|
60
|
+
},
|
|
61
|
+
getJsonContentFunction: () => {
|
|
62
|
+
throw console.error("getJsonContentFunction is not set"), new Error("getJsonContentFunction is not set");
|
|
63
|
+
},
|
|
64
|
+
getJsonActivityContentFunction: () => {
|
|
65
|
+
throw console.error("getJsonActivityContentFunction is not set"), new Error("getJsonActivityContentFunction is not set");
|
|
66
|
+
},
|
|
67
|
+
getJsonAssignmentContentFunction: () => {
|
|
68
|
+
throw console.error("getJsonAssignmentContentFunction is not set"), new Error("getJsonAssignmentContentFunction is not set");
|
|
69
|
+
},
|
|
70
|
+
getJsonActivitySplitContentFunction: () => {
|
|
71
|
+
throw console.error("getJsonActivitySplitContentFunction is not set"), new Error("getJsonActivitySplitContentFunction is not set");
|
|
72
|
+
},
|
|
73
|
+
getJsonAssignmentSplitContentFunction: () => {
|
|
74
|
+
throw console.error("getJsonAssignmentSplitContentFunction is not set"), new Error("getJsonAssignmentSplitContentFunction is not set");
|
|
75
|
+
},
|
|
56
76
|
sidebarActions: {},
|
|
57
77
|
quickActions: {},
|
|
58
78
|
activitySettings: null,
|
|
@@ -62,6 +82,18 @@ const T = (t) => {
|
|
|
62
82
|
setGetJsonContentFunction: (e) => {
|
|
63
83
|
t({ getJsonContentFunction: e });
|
|
64
84
|
},
|
|
85
|
+
setGetJsonActivityContentFunction: (e) => {
|
|
86
|
+
t({ getJsonActivityContentFunction: e });
|
|
87
|
+
},
|
|
88
|
+
setGetJsonAssignmentContentFunction: (e) => {
|
|
89
|
+
t({ getJsonAssignmentContentFunction: e });
|
|
90
|
+
},
|
|
91
|
+
setGetJsonActivitySplitContentFunction: (e) => {
|
|
92
|
+
t({ getJsonActivitySplitContentFunction: e });
|
|
93
|
+
},
|
|
94
|
+
setGetJsonAssignmentSplitContentFunction: (e) => {
|
|
95
|
+
t({ getJsonAssignmentSplitContentFunction: e });
|
|
96
|
+
},
|
|
65
97
|
setSidebarActions: (e) => {
|
|
66
98
|
t({ sidebarActions: e });
|
|
67
99
|
},
|
|
@@ -77,8 +109,8 @@ const T = (t) => {
|
|
|
77
109
|
incDirtyCount: () => t((e) => ({ isDirtyCount: e.isDirtyCount + 1 }))
|
|
78
110
|
}))
|
|
79
111
|
);
|
|
80
|
-
let
|
|
81
|
-
const
|
|
112
|
+
let k = !1;
|
|
113
|
+
const B = [
|
|
82
114
|
"meta-player-events:1",
|
|
83
115
|
"meta-player-ui:1",
|
|
84
116
|
"mode:1",
|
|
@@ -89,11 +121,13 @@ const R = [
|
|
|
89
121
|
"simple-content(json):1",
|
|
90
122
|
"simple-binary-data(text):1",
|
|
91
123
|
"simple-content-eval(text):1",
|
|
92
|
-
"simple-content-eval(json):1"
|
|
93
|
-
|
|
124
|
+
"simple-content-eval(json):1",
|
|
125
|
+
"separate-contents(json):1",
|
|
126
|
+
"separate-dual-contents(json):1"
|
|
127
|
+
], T = {
|
|
94
128
|
"mode:1": {
|
|
95
129
|
setMode: (t) => {
|
|
96
|
-
|
|
130
|
+
n.setState({ mode: t });
|
|
97
131
|
}
|
|
98
132
|
},
|
|
99
133
|
"reload:1": {
|
|
@@ -104,65 +138,63 @@ const R = [
|
|
|
104
138
|
"theme:1": {
|
|
105
139
|
setTheme: (t) => {
|
|
106
140
|
if (t === null) {
|
|
107
|
-
|
|
141
|
+
n.setState({ theme: null });
|
|
108
142
|
return;
|
|
109
143
|
}
|
|
110
144
|
if (t !== "light" && t !== "dark") {
|
|
111
|
-
console.warn(
|
|
112
|
-
`Invalid theme: ${t}. Expected 'light' or 'dark'.`
|
|
113
|
-
), o.setState({ theme: null });
|
|
145
|
+
console.warn(`Invalid theme: ${t}. Expected 'light' or 'dark'.`), n.setState({ theme: null });
|
|
114
146
|
return;
|
|
115
147
|
}
|
|
116
|
-
|
|
148
|
+
n.setState({ theme: t });
|
|
117
149
|
}
|
|
118
150
|
},
|
|
119
151
|
"workflow:1": {
|
|
120
152
|
setWorkflow: (t) => {
|
|
121
|
-
|
|
153
|
+
n.setState({ workflow: t });
|
|
122
154
|
}
|
|
123
155
|
},
|
|
124
156
|
"simple-content(text):1": {
|
|
125
157
|
contentSaved: () => {
|
|
126
|
-
|
|
158
|
+
n.setState((t) => ({
|
|
127
159
|
afterSaveCount: t.afterSaveCount + 1
|
|
128
160
|
}));
|
|
129
161
|
},
|
|
130
|
-
getContent: () =>
|
|
162
|
+
getContent: () => n.getState().getTextContentFunction(),
|
|
131
163
|
loadContent: (t) => {
|
|
132
|
-
|
|
164
|
+
n.setState({ loadedTextContent: t });
|
|
133
165
|
}
|
|
134
166
|
},
|
|
135
167
|
"simple-content(json):1": {
|
|
136
168
|
contentSaved: () => {
|
|
137
|
-
|
|
169
|
+
n.setState((t) => ({
|
|
138
170
|
afterSaveCount: t.afterSaveCount + 1
|
|
139
171
|
}));
|
|
140
172
|
},
|
|
141
|
-
getContent: () =>
|
|
173
|
+
getContent: () => n.getState().getJsonContentFunction(),
|
|
142
174
|
loadContent: (t) => {
|
|
143
|
-
|
|
175
|
+
n.setState({ loadedJsonContent: t });
|
|
144
176
|
}
|
|
145
177
|
},
|
|
146
178
|
"simple-binary-data(text):1": {
|
|
147
179
|
contentSaved: () => {
|
|
148
|
-
|
|
180
|
+
n.setState((t) => ({
|
|
149
181
|
afterSaveCount: t.afterSaveCount + 1
|
|
150
182
|
}));
|
|
151
183
|
},
|
|
152
|
-
getContent: () =>
|
|
184
|
+
getContent: () => n.getState().getTextContentFunction(),
|
|
153
185
|
loadContent: (t) => {
|
|
154
|
-
|
|
186
|
+
n.setState({ loadedTextContent: t });
|
|
155
187
|
}
|
|
156
188
|
},
|
|
157
189
|
"simple-content-eval(text):1": {
|
|
158
190
|
contentSaved: () => {
|
|
159
|
-
|
|
191
|
+
n.setState((t) => ({
|
|
160
192
|
afterSaveCount: t.afterSaveCount + 1
|
|
161
193
|
}));
|
|
162
194
|
},
|
|
163
|
-
getContent: () =>
|
|
195
|
+
getContent: () => n.getState().getTextContentFunction(),
|
|
164
196
|
loadContent: (t) => {
|
|
165
|
-
|
|
197
|
+
n.setState({ loadedTextContent: t });
|
|
166
198
|
},
|
|
167
199
|
getAssignmentContent: () => {
|
|
168
200
|
throw new Error(
|
|
@@ -172,13 +204,13 @@ const R = [
|
|
|
172
204
|
},
|
|
173
205
|
"simple-content-eval(json):1": {
|
|
174
206
|
contentSaved: () => {
|
|
175
|
-
|
|
207
|
+
n.setState((t) => ({
|
|
176
208
|
afterSaveCount: t.afterSaveCount + 1
|
|
177
209
|
}));
|
|
178
210
|
},
|
|
179
|
-
getContent: () =>
|
|
211
|
+
getContent: () => n.getState().getJsonContentFunction(),
|
|
180
212
|
loadContent: (t) => {
|
|
181
|
-
|
|
213
|
+
n.setState({ loadedJsonContent: t });
|
|
182
214
|
},
|
|
183
215
|
getAssignmentContent: () => {
|
|
184
216
|
throw new Error(
|
|
@@ -188,13 +220,13 @@ const R = [
|
|
|
188
220
|
},
|
|
189
221
|
"simple-content-eval(json):2": {
|
|
190
222
|
contentSaved: () => {
|
|
191
|
-
|
|
223
|
+
n.setState((t) => ({
|
|
192
224
|
afterSaveCount: t.afterSaveCount + 1
|
|
193
225
|
}));
|
|
194
226
|
},
|
|
195
|
-
getContent: () =>
|
|
227
|
+
getContent: () => n.getState().getJsonContentFunction(),
|
|
196
228
|
loadContent: (t) => {
|
|
197
|
-
|
|
229
|
+
n.setState({ loadedJsonContent: t });
|
|
198
230
|
},
|
|
199
231
|
getAssignmentContent: () => {
|
|
200
232
|
throw new Error(
|
|
@@ -204,13 +236,13 @@ const R = [
|
|
|
204
236
|
},
|
|
205
237
|
"simple-content-eval(text):2": {
|
|
206
238
|
contentSaved: () => {
|
|
207
|
-
|
|
239
|
+
n.setState((t) => ({
|
|
208
240
|
afterSaveCount: t.afterSaveCount + 1
|
|
209
241
|
}));
|
|
210
242
|
},
|
|
211
|
-
getContent: () =>
|
|
243
|
+
getContent: () => n.getState().getTextContentFunction(),
|
|
212
244
|
loadContent: (t) => {
|
|
213
|
-
|
|
245
|
+
n.setState({ loadedTextContent: t });
|
|
214
246
|
},
|
|
215
247
|
getAssignmentContent: () => {
|
|
216
248
|
throw new Error(
|
|
@@ -218,58 +250,101 @@ const R = [
|
|
|
218
250
|
);
|
|
219
251
|
}
|
|
220
252
|
},
|
|
253
|
+
"separate-contents(json):1": {
|
|
254
|
+
contentSaved: () => {
|
|
255
|
+
n.setState((t) => ({
|
|
256
|
+
afterSaveCount: t.afterSaveCount + 1
|
|
257
|
+
}));
|
|
258
|
+
},
|
|
259
|
+
loadContent: (t, e) => {
|
|
260
|
+
n.setState({
|
|
261
|
+
loadedJsonActivityContent: t,
|
|
262
|
+
loadedJsonAssignmentContent: e
|
|
263
|
+
});
|
|
264
|
+
},
|
|
265
|
+
getActivityContent: () => n.getState().getJsonActivityContentFunction(),
|
|
266
|
+
getAssignmentContent: () => n.getState().getJsonAssignmentContentFunction()
|
|
267
|
+
},
|
|
268
|
+
"separate-dual-contents(json):1": {
|
|
269
|
+
contentSaved: () => {
|
|
270
|
+
n.setState((t) => ({
|
|
271
|
+
afterSaveCount: t.afterSaveCount + 1
|
|
272
|
+
}));
|
|
273
|
+
},
|
|
274
|
+
loadContent: ({
|
|
275
|
+
activityContent: t,
|
|
276
|
+
assignmentContent: e,
|
|
277
|
+
activityBinaryData: o,
|
|
278
|
+
assignmentBinaryData: s
|
|
279
|
+
}) => {
|
|
280
|
+
n.setState({
|
|
281
|
+
loadedJsonActivityContent: t,
|
|
282
|
+
loadedJsonAssignmentContent: e,
|
|
283
|
+
loadedJsonActivityBinaryData: o,
|
|
284
|
+
loadedJsonAssignmentBinaryData: s
|
|
285
|
+
});
|
|
286
|
+
},
|
|
287
|
+
getActivityContentAndData: () => n.getState().getJsonActivitySplitContentFunction(),
|
|
288
|
+
getAssignmentContentAndData: () => n.getState().getJsonAssignmentSplitContentFunction()
|
|
289
|
+
},
|
|
290
|
+
"meta-player-anti-cheat:1": {
|
|
291
|
+
lock: () => {
|
|
292
|
+
},
|
|
293
|
+
unlock: () => {
|
|
294
|
+
}
|
|
295
|
+
},
|
|
221
296
|
"meta-player-ui:1": {
|
|
222
297
|
executeAction(t) {
|
|
223
298
|
if (t.startsWith("qa")) {
|
|
224
|
-
const
|
|
225
|
-
|
|
299
|
+
const o = n.getState().quickActions[t];
|
|
300
|
+
o ? o() : console.error(`Quick action not found: ${t}`);
|
|
226
301
|
} else {
|
|
227
|
-
const
|
|
228
|
-
|
|
302
|
+
const o = n.getState().sidebarActions[t];
|
|
303
|
+
o ? o() : console.error(`Sidebar action not found: ${t}`);
|
|
229
304
|
}
|
|
230
305
|
},
|
|
231
306
|
executeFileUpload(t, e) {
|
|
232
307
|
if (t.startsWith("qa")) {
|
|
233
|
-
const s =
|
|
308
|
+
const s = n.getState().quickActions[t];
|
|
234
309
|
s ? s(e) : console.error(`Quick action not found: ${t}`);
|
|
235
310
|
} else {
|
|
236
|
-
const s =
|
|
311
|
+
const s = n.getState().sidebarActions[t];
|
|
237
312
|
s ? s(e) : console.error(`Sidebar action not found: ${t}`);
|
|
238
313
|
}
|
|
239
314
|
},
|
|
240
315
|
updateSettings(t) {
|
|
241
|
-
|
|
316
|
+
n.setState({ activitySettings: t });
|
|
242
317
|
}
|
|
243
318
|
},
|
|
244
319
|
"meta-player-events:1": {
|
|
245
320
|
handleEvent(t) {
|
|
246
|
-
t === "all-loaded" &&
|
|
321
|
+
t === "all-loaded" && n.setState({ ready: !0 });
|
|
247
322
|
}
|
|
248
323
|
}
|
|
249
|
-
},
|
|
250
|
-
function
|
|
251
|
-
if (
|
|
324
|
+
}, C = G();
|
|
325
|
+
function P(t) {
|
|
326
|
+
if (k) {
|
|
252
327
|
console.warn("Contracts have already been plugged. Skipping.");
|
|
253
328
|
return;
|
|
254
329
|
}
|
|
255
|
-
|
|
330
|
+
k = !0;
|
|
256
331
|
for (const e of t) {
|
|
257
|
-
if (!
|
|
332
|
+
if (!B.includes(e)) {
|
|
258
333
|
console.warn(
|
|
259
334
|
`Contract ${e} is not implemented in Capytale. Skipping plug.`
|
|
260
335
|
);
|
|
261
336
|
continue;
|
|
262
337
|
}
|
|
263
|
-
if (!(e in
|
|
338
|
+
if (!(e in T)) {
|
|
264
339
|
console.warn(
|
|
265
340
|
`Contract handler for ${e} is not defined. Skipping plug.`
|
|
266
341
|
);
|
|
267
342
|
continue;
|
|
268
343
|
}
|
|
269
|
-
const
|
|
270
|
-
|
|
344
|
+
const o = T[e];
|
|
345
|
+
C.plug([e], ([]) => [o]);
|
|
271
346
|
}
|
|
272
|
-
|
|
347
|
+
C.plugsDone();
|
|
273
348
|
for (const e of [
|
|
274
349
|
"simple-content(text):1",
|
|
275
350
|
"simple-content(json):1",
|
|
@@ -281,187 +356,247 @@ function Q(t) {
|
|
|
281
356
|
])
|
|
282
357
|
if (console.log(`Contract ${e} is being subscribed to content changes.`), t.includes(e)) {
|
|
283
358
|
console.log(`Subscribing to content changes for contract ${e}`);
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
(
|
|
289
|
-
|
|
359
|
+
const o = e.split(":")[0];
|
|
360
|
+
C.use([o], ([s]) => {
|
|
361
|
+
n.subscribe(
|
|
362
|
+
(i) => i.isDirtyCount,
|
|
363
|
+
() => {
|
|
364
|
+
var i;
|
|
365
|
+
(i = s.i) == null || i.contentChanged(), console.log(
|
|
366
|
+
`Content changed for contract ${o}`
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
);
|
|
290
370
|
});
|
|
291
371
|
}
|
|
292
372
|
}
|
|
293
|
-
|
|
373
|
+
const R = [
|
|
374
|
+
"meta-player-events:1",
|
|
375
|
+
"mode:1",
|
|
376
|
+
"workflow:1"
|
|
377
|
+
];
|
|
378
|
+
function O({
|
|
294
379
|
children: t,
|
|
295
380
|
contracts: e,
|
|
296
|
-
loadOnlyWhenReady:
|
|
381
|
+
loadOnlyWhenReady: o = !0
|
|
297
382
|
}) {
|
|
298
|
-
const s =
|
|
299
|
-
return
|
|
300
|
-
const i =
|
|
301
|
-
|
|
302
|
-
|
|
383
|
+
const s = n((i) => i.ready);
|
|
384
|
+
return d(() => {
|
|
385
|
+
const i = [...e];
|
|
386
|
+
for (const c of R)
|
|
387
|
+
i.includes(c) || i.push(c);
|
|
388
|
+
P(i);
|
|
389
|
+
}, []), o && !s ? /* @__PURE__ */ w("div", { className: "container", children: "Chargement en cours..." }) : /* @__PURE__ */ w("div", { className: "container", children: t });
|
|
303
390
|
}
|
|
304
|
-
const
|
|
391
|
+
const H = () => n((t) => {
|
|
305
392
|
if (t.mode === null)
|
|
306
393
|
throw new Error("Mode is not set. Have you used contract 'mode'?");
|
|
307
394
|
return t.mode;
|
|
308
|
-
}), U = () =>
|
|
395
|
+
}), U = () => n((t) => {
|
|
309
396
|
if (t.workflow === null)
|
|
310
397
|
throw new Error("Workflow is not set. Have you used contract 'workflow'?");
|
|
311
398
|
return t.workflow;
|
|
312
|
-
}),
|
|
399
|
+
}), V = () => n((t) => {
|
|
313
400
|
if (t.theme === null)
|
|
314
401
|
throw new Error("Theme is not set. Have you used contract 'theme'?");
|
|
315
402
|
return t.theme;
|
|
316
|
-
}),
|
|
317
|
-
|
|
318
|
-
|
|
403
|
+
}), _ = () => n((t) => t.incSaveCount), z = () => n((t) => t.incDirtyCount), K = () => n((t) => t.loadedTextContent), X = () => n((t) => t.loadedJsonContent), Y = () => n((t) => t.loadedJsonActivityContent), Z = () => n((t) => t.loadedJsonAssignmentContent), tt = () => n((t) => t.loadedJsonActivityBinaryData), et = () => n((t) => t.loadedJsonAssignmentBinaryData), nt = () => n.getState().loadedTextContent, ot = () => n.getState().loadedJsonContent, st = () => n.getState().loadedJsonActivityContent, it = () => n.getState().loadedJsonAssignmentContent, at = () => ({
|
|
404
|
+
content: n.getState().loadedJsonActivityContent,
|
|
405
|
+
binaryData: n.getState().loadedJsonActivityBinaryData
|
|
406
|
+
}), ct = () => ({
|
|
407
|
+
content: n.getState().loadedJsonAssignmentContent,
|
|
408
|
+
binaryData: n.getState().loadedJsonAssignmentBinaryData
|
|
409
|
+
}), rt = (t) => {
|
|
410
|
+
const e = n(
|
|
411
|
+
(o) => o.setGetTextContentFunction
|
|
412
|
+
);
|
|
413
|
+
d(() => {
|
|
414
|
+
e(t);
|
|
415
|
+
}, [t, e]);
|
|
416
|
+
}, lt = (t) => {
|
|
417
|
+
const e = n(
|
|
418
|
+
(o) => o.setGetJsonContentFunction
|
|
319
419
|
);
|
|
320
|
-
|
|
420
|
+
d(() => {
|
|
321
421
|
e(t);
|
|
322
422
|
}, [t, e]);
|
|
323
|
-
},
|
|
324
|
-
const e =
|
|
325
|
-
(
|
|
423
|
+
}, ut = (t) => {
|
|
424
|
+
const e = n(
|
|
425
|
+
(o) => o.setGetJsonActivityContentFunction
|
|
326
426
|
);
|
|
327
|
-
|
|
427
|
+
d(() => {
|
|
328
428
|
e(t);
|
|
329
429
|
}, [t, e]);
|
|
330
|
-
},
|
|
331
|
-
const e =
|
|
332
|
-
|
|
430
|
+
}, dt = (t) => {
|
|
431
|
+
const e = n(
|
|
432
|
+
(o) => o.setGetJsonAssignmentContentFunction
|
|
433
|
+
);
|
|
434
|
+
d(() => {
|
|
435
|
+
e(t);
|
|
436
|
+
}, [t, e]);
|
|
437
|
+
}, gt = (t) => {
|
|
438
|
+
const e = n(
|
|
439
|
+
(o) => o.setGetJsonActivitySplitContentFunction
|
|
440
|
+
);
|
|
441
|
+
d(() => {
|
|
442
|
+
e(t);
|
|
443
|
+
}, [t, e]);
|
|
444
|
+
}, Ct = (t) => {
|
|
445
|
+
const e = n(
|
|
446
|
+
(o) => o.setGetJsonAssignmentSplitContentFunction
|
|
447
|
+
);
|
|
448
|
+
d(() => {
|
|
449
|
+
e(t);
|
|
450
|
+
}, [t, e]);
|
|
451
|
+
}, St = (t) => {
|
|
452
|
+
const e = n((o) => o.afterSaveCount);
|
|
453
|
+
d(() => {
|
|
333
454
|
e > 0 && t();
|
|
334
455
|
}, [e]);
|
|
335
|
-
},
|
|
336
|
-
|
|
456
|
+
}, pt = () => (t, e) => {
|
|
457
|
+
C.use(["meta-player-ui"], ([o]) => {
|
|
337
458
|
var s;
|
|
338
|
-
if (
|
|
459
|
+
if (o.version === 0) {
|
|
339
460
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
340
461
|
return;
|
|
341
462
|
}
|
|
342
|
-
(s =
|
|
463
|
+
(s = o.i) == null || s.previewTextFile(t, e);
|
|
343
464
|
});
|
|
344
|
-
},
|
|
345
|
-
|
|
465
|
+
}, mt = () => (t, e) => {
|
|
466
|
+
C.use(["meta-player-ui"], ([o]) => {
|
|
346
467
|
var s;
|
|
347
|
-
if (
|
|
468
|
+
if (o.version === 0) {
|
|
348
469
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
349
470
|
return;
|
|
350
471
|
}
|
|
351
|
-
(s =
|
|
472
|
+
(s = o.i) == null || s.previewImageFile(t, e);
|
|
352
473
|
});
|
|
353
474
|
};
|
|
354
|
-
let
|
|
355
|
-
const
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}), []),
|
|
360
|
-
var
|
|
475
|
+
let v = 0, J = 0;
|
|
476
|
+
const vt = (t, e) => {
|
|
477
|
+
const o = b(t, e), s = n((i) => i.setSidebarActions);
|
|
478
|
+
d(() => (v++, v > 1 && console.error("Capytale iframe React: Multiple sidebar actions registered: ", v), () => {
|
|
479
|
+
v--;
|
|
480
|
+
}), []), d(() => (C.use(["meta-player-ui"], ([i]) => {
|
|
481
|
+
var u;
|
|
361
482
|
if (i.version === 0) {
|
|
362
483
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
363
484
|
return;
|
|
364
485
|
}
|
|
365
|
-
|
|
366
|
-
const
|
|
367
|
-
type:
|
|
368
|
-
title:
|
|
369
|
-
icon:
|
|
370
|
-
id: `sa-${
|
|
371
|
-
...
|
|
372
|
-
})),
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
}), (
|
|
486
|
+
J++;
|
|
487
|
+
const c = o.map((a, l) => ({
|
|
488
|
+
type: a.type,
|
|
489
|
+
title: a.title,
|
|
490
|
+
icon: a.icon,
|
|
491
|
+
id: `sa-${J}-${l}`,
|
|
492
|
+
...a.type === "file-upload" ? { accept: a.accept } : {}
|
|
493
|
+
})), r = {};
|
|
494
|
+
o.forEach((a, l) => {
|
|
495
|
+
r[`sa-${J}-${l}`] = a.action;
|
|
496
|
+
}), (u = i.i) == null || u.setSidebarActionButtons(c), s(r);
|
|
376
497
|
}), () => {
|
|
377
|
-
s({}),
|
|
378
|
-
var
|
|
498
|
+
s({}), C.use(["meta-player-ui"], ([i]) => {
|
|
499
|
+
var c;
|
|
379
500
|
if (i.version === 0) {
|
|
380
501
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
381
502
|
return;
|
|
382
503
|
}
|
|
383
|
-
(
|
|
504
|
+
(c = i.i) == null || c.setSidebarActionButtons([]);
|
|
384
505
|
});
|
|
385
|
-
}), [
|
|
506
|
+
}), [o]);
|
|
386
507
|
};
|
|
387
|
-
let
|
|
388
|
-
const
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}), []),
|
|
393
|
-
var
|
|
508
|
+
let y = 0, F = 0;
|
|
509
|
+
const yt = (t, e) => {
|
|
510
|
+
const o = b(t, e), s = n((i) => i.setQuickActions);
|
|
511
|
+
d(() => (y++, y > 1 && console.error("Capytale iframe React: Multiple quick actions registered: ", y), () => {
|
|
512
|
+
y--;
|
|
513
|
+
}), []), d(() => (C.use(["meta-player-ui"], ([i]) => {
|
|
514
|
+
var u;
|
|
394
515
|
if (i.version === 0) {
|
|
395
516
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
396
517
|
return;
|
|
397
518
|
}
|
|
398
|
-
|
|
399
|
-
const
|
|
400
|
-
type:
|
|
401
|
-
title:
|
|
402
|
-
icon:
|
|
403
|
-
id: `qa-${
|
|
404
|
-
...
|
|
405
|
-
})),
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}), (
|
|
519
|
+
F++;
|
|
520
|
+
const c = o.map((a, l) => ({
|
|
521
|
+
type: a.type,
|
|
522
|
+
title: a.title,
|
|
523
|
+
icon: a.icon,
|
|
524
|
+
id: `qa-${F}-${l}`,
|
|
525
|
+
...a.type === "file-upload" ? { accept: a.accept } : {}
|
|
526
|
+
})), r = {};
|
|
527
|
+
o.forEach((a, l) => {
|
|
528
|
+
r[`qa-${F}-${l}`] = a.action;
|
|
529
|
+
}), (u = i.i) == null || u.setQuickActionButtons(c), s(r);
|
|
409
530
|
}), () => {
|
|
410
|
-
s({}),
|
|
411
|
-
var
|
|
531
|
+
s({}), C.use(["meta-player-ui"], ([i]) => {
|
|
532
|
+
var c;
|
|
412
533
|
if (i.version === 0) {
|
|
413
534
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
414
535
|
return;
|
|
415
536
|
}
|
|
416
|
-
(
|
|
537
|
+
(c = i.i) == null || c.setQuickActionButtons([]);
|
|
417
538
|
});
|
|
418
|
-
}), [
|
|
539
|
+
}), [o]);
|
|
419
540
|
};
|
|
420
|
-
let
|
|
421
|
-
const
|
|
422
|
-
const
|
|
423
|
-
return
|
|
424
|
-
|
|
425
|
-
}), []),
|
|
426
|
-
const
|
|
427
|
-
if (
|
|
428
|
-
return
|
|
429
|
-
var
|
|
430
|
-
if (
|
|
541
|
+
let A = 0;
|
|
542
|
+
const At = (t, e) => {
|
|
543
|
+
const o = b(t, e), s = n((r) => r.setActivitySettings), i = n((r) => r.activitySettings), c = E("");
|
|
544
|
+
return d(() => (console.log("Mounting useSettings"), A++, A > 1 && console.error("Capytale iframe React: Multiple settings registered: ", A), () => {
|
|
545
|
+
A--;
|
|
546
|
+
}), []), d(() => {
|
|
547
|
+
const r = JSON.stringify(o);
|
|
548
|
+
if (r !== c.current)
|
|
549
|
+
return c.current = r, C.use(["meta-player-ui"], ([u]) => {
|
|
550
|
+
var a;
|
|
551
|
+
if (u.version === 0) {
|
|
431
552
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
432
553
|
return;
|
|
433
554
|
}
|
|
434
|
-
console.log("Updating settings UI in MetaPlayer",
|
|
555
|
+
console.log("Updating settings UI in MetaPlayer", o), (a = u.i) == null || a.setSettingsUI(o);
|
|
435
556
|
}), () => {
|
|
436
557
|
s(null);
|
|
437
558
|
};
|
|
438
|
-
}, [
|
|
439
|
-
},
|
|
440
|
-
|
|
559
|
+
}, [o]), i;
|
|
560
|
+
}, ft = () => (e) => {
|
|
561
|
+
C.use(["meta-player-ui"], ([o]) => {
|
|
441
562
|
var s;
|
|
442
|
-
if (
|
|
563
|
+
if (o.version === 0) {
|
|
443
564
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
444
565
|
return;
|
|
445
566
|
}
|
|
446
|
-
(s =
|
|
567
|
+
(s = o.i) == null || s.showToast(e);
|
|
447
568
|
});
|
|
448
569
|
};
|
|
449
570
|
export {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
571
|
+
O as Capytale,
|
|
572
|
+
St as useAfterSaveAction,
|
|
573
|
+
st as useGetLoadedJsonActivityContent,
|
|
574
|
+
at as useGetLoadedJsonActivitySplitContent,
|
|
575
|
+
it as useGetLoadedJsonAssignmentContent,
|
|
576
|
+
ct as useGetLoadedJsonAssignmentSplitContent,
|
|
577
|
+
ot as useGetLoadedJsonContent,
|
|
578
|
+
nt as useGetLoadedTextContent,
|
|
579
|
+
ut as useJsonActivityContentSaveFunction,
|
|
580
|
+
gt as useJsonActivitySplitContentSaveFunction,
|
|
581
|
+
dt as useJsonAssignmentContentSaveFunction,
|
|
582
|
+
Ct as useJsonAssignmentSplitContentSaveFunction,
|
|
583
|
+
lt as useJsonContentSaveFunction,
|
|
584
|
+
tt as useLoadedJsonActivityBinaryData,
|
|
585
|
+
Y as useLoadedJsonActivityContent,
|
|
586
|
+
et as useLoadedJsonAssignmentBinaryData,
|
|
587
|
+
Z as useLoadedJsonAssignmentContent,
|
|
588
|
+
X as useLoadedJsonContent,
|
|
589
|
+
K as useLoadedTextContent,
|
|
590
|
+
H as useMode,
|
|
591
|
+
z as useNotifyIsDirty,
|
|
592
|
+
mt as usePreviewImageFile,
|
|
593
|
+
pt as usePreviewTextFile,
|
|
594
|
+
yt as useQuickActions,
|
|
595
|
+
_ as useRequestSave,
|
|
596
|
+
At as useSettings,
|
|
597
|
+
ft as useShowToast,
|
|
598
|
+
vt as useSidebarActions,
|
|
599
|
+
rt as useTextContentSaveFunction,
|
|
600
|
+
V as useTheme,
|
|
466
601
|
U as useWorkflow
|
|
467
602
|
};
|
package/package.json
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@capytale/iframe-react",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "vite",
|
|
7
|
-
"build": "vite build",
|
|
8
|
-
"clean": "",
|
|
9
|
-
"builddev": "vite build -m development",
|
|
10
|
-
"preview": "vite preview",
|
|
11
|
-
"prepublishOnly": "npm run clean && npm run build"
|
|
12
|
-
},
|
|
13
|
-
"main": "dist/index.cjs.js",
|
|
14
|
-
"module": "dist/index.es.js",
|
|
15
|
-
"types": "dist/index.d.ts",
|
|
16
|
-
"exports": {
|
|
17
|
-
".": {
|
|
18
|
-
"types": "./dist/index.d.ts",
|
|
19
|
-
"import": "./dist/index.es.js",
|
|
20
|
-
"require": "./dist/index.cjs.js",
|
|
21
|
-
"default": "./dist/index.es.js"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"files": [
|
|
25
|
-
"dist"
|
|
26
|
-
],
|
|
27
|
-
"sideEffects": false,
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"@capytale/app-agent": "^1.0.
|
|
30
|
-
"@capytale/contracts": "^1.0.
|
|
31
|
-
"zustand": "^5.0.
|
|
32
|
-
},
|
|
33
|
-
"peerDependencies": {
|
|
34
|
-
"react": ">=17.0.0 <20",
|
|
35
|
-
"react-dom": ">=17.0.0 <20"
|
|
36
|
-
},
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"@types/node": "^22.13.1",
|
|
39
|
-
"@types/react": "^18.3.18",
|
|
40
|
-
"@types/react-dom": "^18.3.5",
|
|
41
|
-
"@vitejs/plugin-react": "^4.4.1",
|
|
42
|
-
"react": "^18.3.1",
|
|
43
|
-
"react-dom": "^18.3.1",
|
|
44
|
-
"typescript": "^5.8.3",
|
|
45
|
-
"vite": "^6.3.5",
|
|
46
|
-
"vite-plugin-dts": "^4.5.4"
|
|
47
|
-
},
|
|
48
|
-
"publishConfig": {
|
|
49
|
-
"access": "public"
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@capytale/iframe-react",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"clean": "rm -rf dist",
|
|
9
|
+
"builddev": "vite build -m development",
|
|
10
|
+
"preview": "vite preview",
|
|
11
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
12
|
+
},
|
|
13
|
+
"main": "dist/index.cjs.js",
|
|
14
|
+
"module": "dist/index.es.js",
|
|
15
|
+
"types": "dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.es.js",
|
|
20
|
+
"require": "./dist/index.cjs.js",
|
|
21
|
+
"default": "./dist/index.es.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@capytale/app-agent": "^1.0.12",
|
|
30
|
+
"@capytale/contracts": "^1.0.8",
|
|
31
|
+
"zustand": "^5.0.8"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": ">=17.0.0 <20",
|
|
35
|
+
"react-dom": ">=17.0.0 <20"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^22.13.1",
|
|
39
|
+
"@types/react": "^18.3.18",
|
|
40
|
+
"@types/react-dom": "^18.3.5",
|
|
41
|
+
"@vitejs/plugin-react": "^4.4.1",
|
|
42
|
+
"react": "^18.3.1",
|
|
43
|
+
"react-dom": "^18.3.1",
|
|
44
|
+
"typescript": "^5.8.3",
|
|
45
|
+
"vite": "^6.3.5",
|
|
46
|
+
"vite-plugin-dts": "^4.5.4"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
}
|
|
51
|
+
}
|