@capytale/iframe-react 1.1.3 → 1.1.5
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 +81 -22
- package/dist/index.es.js +280 -196
- package/package.json +52 -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 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:"capy-loading-container",children:"Chargement en cours..."}):f.jsx(f.Fragment,{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),O=()=>n(t=>t.incDirtyCount),N=()=>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,J=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}J++;const r=o.map((a,l)=>({type:a.type,title:a.title,icon:a.icon,id:`sa-${J}-${l}`,...a.type==="file-upload"?{accept:a.accept}:{}})),u={};o.forEach((a,l)=>{u[`sa-${J}-${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,F=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}F++;const r=o.map((a,l)=>({type:a.type,title:a.title,icon:a.icon,id:`qa-${F}-${l}`,...a.type==="file-upload"?{accept:a.accept}:{}})),u={};o.forEach((a,l)=>{u[`qa-${F}-${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=N;exports.useMode=P;exports.useNotifyIsDirty=O;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;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),a=require("react"),L=require("@capytale/app-agent"),b=t=>{let e;const o=new Set,s=(C,S)=>{const d=typeof C=="function"?C(e):C;if(!Object.is(d,e)){const A=e;e=S??(typeof d!="object"||d===null)?d:Object.assign({},e,d),o.forEach(f=>f(e,A))}},i=()=>e,c={setState:s,getState:i,getInitialState:()=>u,subscribe:C=>(o.add(C),()=>o.delete(C))},u=e=t(s,i,c);return c},G=t=>t?b(t):b,D=t=>t;function M(t,e=D){const o=a.useSyncExternalStore(t.subscribe,a.useCallback(()=>e(t.getState()),[t,e]),a.useCallback(()=>e(t.getInitialState()),[t,e]));return a.useDebugValue(o),o}const w=t=>{const e=G(t),o=s=>M(e,s);return Object.assign(o,e),o},x=t=>t?w(t):w,j=t=>(e,o,s)=>{const i=s.subscribe;return s.subscribe=(l,c,u)=>{let C=l;if(c){const S=u?.equalityFn||Object.is;let d=l(s.getState());C=A=>{const f=l(A);if(!S(d,f)){const E=d;c(d=f,E)}},u?.fireImmediately&&c(d,d)}return i(C)},t(e,o,s)},I=j,n=x()(I(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:{},activitySettingsCallback: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})},setActivitySettingsCallback:e=>{t({activitySettingsCallback: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"],k={"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){const e=n.getState().activitySettingsCallback;e?e(t):console.warn("activitySettingsCallback is not set. Changes:",t)}},"meta-player-events:1":{handleEvent(t){t==="all-loaded"&&n.setState({ready:!0})}}},g=L.getSocket();function $(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 k)){console.warn(`Contract handler for ${e} is not defined. Skipping plug.`);continue}const o=k[e];g.plug([e],([])=>[o])}g.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];g.use([o],([s])=>{n.subscribe(i=>i.isDirtyCount,()=>{s.i?.contentChanged(),console.log(`Content changed for contract ${o}`)})})}}const B=()=>n(t=>{if(t.mode===null)throw new Error("Mode is not set. Have you used contract 'mode'?");return t.mode}),P=()=>n(t=>{if(t.workflow===null)throw new Error("Workflow is not set. Have you used contract 'workflow'?");return t.workflow}),R=()=>n(t=>{if(t.theme===null)throw new Error("Theme is not set. Have you used contract 'theme'?");return t.theme}),O=()=>n(t=>t.incSaveCount),W=()=>n(t=>t.incDirtyCount),Q=()=>n(t=>t.loadedTextContent),V=()=>n(t=>t.loadedJsonContent),N=()=>n(t=>t.loadedJsonActivityContent),U=()=>n(t=>t.loadedJsonAssignmentContent),H=()=>n(t=>t.loadedJsonActivityBinaryData),_=()=>n(t=>t.loadedJsonAssignmentBinaryData),z=()=>a.useCallback(()=>n.getState().loadedTextContent,[]),K=()=>a.useCallback(()=>n.getState().loadedJsonContent,[]),X=()=>a.useCallback(()=>n.getState().loadedJsonActivityContent,[]),Y=()=>a.useCallback(()=>n.getState().loadedJsonAssignmentContent,[]),Z=()=>a.useCallback(()=>({content:n.getState().loadedJsonActivityContent,binaryData:n.getState().loadedJsonActivityBinaryData}),[]),tt=()=>a.useCallback(()=>({content:n.getState().loadedJsonAssignmentContent,binaryData:n.getState().loadedJsonAssignmentBinaryData}),[]),et=t=>{const e=n(o=>o.setGetTextContentFunction);a.useEffect(()=>{e(t)},[t,e])},nt=t=>{const e=n(o=>o.setGetJsonContentFunction);a.useEffect(()=>{e(t)},[t,e])},ot=t=>{const e=n(o=>o.setGetJsonActivityContentFunction);a.useEffect(()=>{e(t)},[t,e])},st=t=>{const e=n(o=>o.setGetJsonAssignmentContentFunction);a.useEffect(()=>{e(t)},[t,e])},it=t=>{const e=n(o=>o.setGetJsonActivitySplitContentFunction);a.useEffect(()=>{e(t)},[t,e])},at=t=>{const e=n(o=>o.setGetJsonAssignmentSplitContentFunction);a.useEffect(()=>{e(t)},[t,e])},ct=t=>{const e=n(o=>o.afterSaveCount);a.useEffect(()=>{e>0&&t()},[e])},rt=()=>(t,e)=>{g.use(["meta-player-ui"],([o])=>{if(o.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}o.i?.previewTextFile(t,e)})},ut=()=>(t,e)=>{g.use(["meta-player-ui"],([o])=>{if(o.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}o.i?.previewImageFile(t,e)})};let v=0,J=0;const lt=(t,e)=>{const o=a.useMemo(t,e),s=n(i=>i.setSidebarActions);a.useEffect(()=>(v++,v>1&&console.error("Capytale iframe React: Multiple sidebar actions registered: ",v),()=>{v--}),[]),a.useEffect(()=>(g.use(["meta-player-ui"],([i])=>{if(i.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}J++;const r=o.map((c,u)=>({type:c.type,title:c.title,icon:c.icon,id:`sa-${J}-${u}`,...c.type==="file-upload"?{accept:c.accept}:{}})),l={};o.forEach((c,u)=>{l[`sa-${J}-${u}`]=c.action}),i.i?.setSidebarActionButtons(r),s(l)}),()=>{s({}),g.use(["meta-player-ui"],([i])=>{if(i.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}i.i?.setSidebarActionButtons([])})}),[o])};let y=0,F=0;const dt=(t,e)=>{const o=a.useMemo(t,e),s=n(i=>i.setQuickActions);a.useEffect(()=>(y++,y>1&&console.error("Capytale iframe React: Multiple quick actions registered: ",y),()=>{y--}),[]),a.useEffect(()=>(g.use(["meta-player-ui"],([i])=>{if(i.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}F++;const r=o.map((c,u)=>({type:c.type,title:c.title,icon:c.icon,id:`qa-${F}-${u}`,...c.type==="file-upload"?{accept:c.accept}:{}})),l={};o.forEach((c,u)=>{l[`qa-${F}-${u}`]=c.action}),i.i?.setQuickActionButtons(r),s(l)}),()=>{s({}),g.use(["meta-player-ui"],([i])=>{if(i.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}i.i?.setQuickActionButtons([])})}),[o])};let m=0;const T=(t,e,o)=>{const s=a.useMemo(t,o),i=n(r=>r.setActivitySettingsCallback);a.useEffect(()=>(console.log("Mounting useSettings"),m++,m>1&&console.error("Capytale iframe React: Multiple settings registered: ",m),()=>{console.log("Unmounting useSettings"),m--}),[]),a.useEffect(()=>(g.use(["meta-player-ui"],([r])=>{if(r.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}console.log("Updating settings UI in MetaPlayer",s),r.i?.setSettingsUI(s)}),i(e),()=>{i(null)}),[s])},gt=()=>e=>{g.use(["meta-player-ui"],([o])=>{if(o.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}o.i?.showToast(e)})};function Ct(t){const e={};for(const o of t.fields)e[o.name]=o.defaultValue;return e}function St(t){return{[t.name]:t.defaultValues}}function ft(t){return{[t.name]:t.defaultValue}}function pt(t){switch(t.type){case"form":return Ct(t);case"checkboxes":case"switches":return St(t);case"radio":return ft(t);default:return{}}}function vt(t){const e={};for(const o of t)Object.assign(e,pt(o));return e}function yt(t){const o=x()(s=>({...vt(t)}));return o.activitySettings=t,o}function mt(t){T(()=>t.activitySettings,e=>{t.setState(e)},[])}function At({store:t}){return mt(t),null}const Jt=["meta-player-events:1","mode:1","workflow:1"];function Ft({children:t,contracts:e,loadOnlyWhenReady:o=!0,activitySettingsStore:s}){const i=n(r=>r.ready);return a.useEffect(()=>{const r=[...e];for(const l of Jt)r.includes(l)||r.push(l);$(r)},[]),o&&!i?p.jsx("div",{className:"capy-loading-container",children:"Chargement en cours..."}):p.jsxs(p.Fragment,{children:[s&&p.jsx(At,{store:s}),t]})}exports.Capytale=Ft;exports.createActivitySettingsStore=yt;exports.useAfterSaveAction=ct;exports.useGetLoadedJsonActivityContent=X;exports.useGetLoadedJsonActivitySplitContent=Z;exports.useGetLoadedJsonAssignmentContent=Y;exports.useGetLoadedJsonAssignmentSplitContent=tt;exports.useGetLoadedJsonContent=K;exports.useGetLoadedTextContent=z;exports.useJsonActivityContentSaveFunction=ot;exports.useJsonActivitySplitContentSaveFunction=it;exports.useJsonAssignmentContentSaveFunction=st;exports.useJsonAssignmentSplitContentSaveFunction=at;exports.useJsonContentSaveFunction=nt;exports.useLoadedJsonActivityBinaryData=H;exports.useLoadedJsonActivityContent=N;exports.useLoadedJsonAssignmentBinaryData=_;exports.useLoadedJsonAssignmentContent=U;exports.useLoadedJsonContent=V;exports.useLoadedTextContent=Q;exports.useMode=B;exports.useNotifyIsDirty=W;exports.usePreviewImageFile=ut;exports.usePreviewTextFile=rt;exports.useQuickActions=dt;exports.useRequestSave=O;exports.useSettings=T;exports.useShowToast=gt;exports.useSidebarActions=lt;exports.useTextContentSaveFunction=et;exports.useTheme=R;exports.useWorkflow=P;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CapytaleContracts } from '@capytale/contracts';
|
|
2
2
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
3
3
|
import { PropsWithChildren } from 'react';
|
|
4
|
+
import { StoreApi } from 'zustand';
|
|
4
5
|
|
|
5
6
|
export declare type Action = {
|
|
6
7
|
type: "action";
|
|
@@ -15,46 +16,48 @@ export declare type Action = {
|
|
|
15
16
|
action: (file: File) => any;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
declare type ActivitySettings =
|
|
19
|
-
[id: string]: ActivitySettingsSection;
|
|
20
|
-
};
|
|
19
|
+
export declare type ActivitySettings = ActivitySettingsSection[];
|
|
21
20
|
|
|
22
21
|
declare type ActivitySettingsFormSection = {
|
|
23
22
|
type: "form";
|
|
24
|
-
fields:
|
|
25
|
-
[name: string]: (ActivitySettingsRange | ActivitySettingsInput | ActivitySettingsTextArea | ActivitySettingsOption | ActivitySettingsSelect) & {
|
|
26
|
-
label: string;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
23
|
+
fields: FormField[];
|
|
29
24
|
};
|
|
30
25
|
|
|
31
26
|
declare type ActivitySettingsInput = {
|
|
32
27
|
type: "input";
|
|
33
|
-
inputType: "color" | "date" | "datetime-local" | "email" | "month" | "
|
|
34
|
-
|
|
28
|
+
inputType: "color" | "date" | "datetime-local" | "email" | "month" | "password" | "search" | "tel" | "text" | "time" | "url" | "week";
|
|
29
|
+
defaultValue: string;
|
|
35
30
|
};
|
|
36
31
|
|
|
37
32
|
declare type ActivitySettingsMultipleOptionsSection = {
|
|
33
|
+
name: string;
|
|
38
34
|
type: "checkboxes" | "switches";
|
|
39
35
|
options: {
|
|
40
36
|
label: string;
|
|
41
|
-
|
|
37
|
+
value: string;
|
|
42
38
|
}[];
|
|
43
|
-
|
|
39
|
+
defaultValues: string[];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
declare type ActivitySettingsNumberInput = {
|
|
43
|
+
type: "input";
|
|
44
|
+
inputType: "number";
|
|
45
|
+
defaultValue: number;
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
declare type ActivitySettingsOption = {
|
|
47
49
|
type: "checkbox" | "switch";
|
|
48
|
-
|
|
50
|
+
defaultValue: boolean;
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
declare type ActivitySettingsRadioOptionsSection = {
|
|
54
|
+
name: string;
|
|
52
55
|
type: "radio";
|
|
53
56
|
options: {
|
|
54
57
|
label: string;
|
|
55
|
-
|
|
58
|
+
value: string;
|
|
56
59
|
}[];
|
|
57
|
-
|
|
60
|
+
defaultValue: string | null;
|
|
58
61
|
};
|
|
59
62
|
|
|
60
63
|
declare type ActivitySettingsRange = {
|
|
@@ -62,7 +65,7 @@ declare type ActivitySettingsRange = {
|
|
|
62
65
|
min: number;
|
|
63
66
|
max: number;
|
|
64
67
|
step?: number;
|
|
65
|
-
|
|
68
|
+
defaultValue: number;
|
|
66
69
|
};
|
|
67
70
|
|
|
68
71
|
declare type ActivitySettingsSection = (ActivitySettingsMultipleOptionsSection | ActivitySettingsRadioOptionsSection | ActivitySettingsFormSection) & {
|
|
@@ -73,14 +76,14 @@ declare type ActivitySettingsSelect = {
|
|
|
73
76
|
type: "select";
|
|
74
77
|
options: {
|
|
75
78
|
label: string;
|
|
76
|
-
|
|
79
|
+
value: string;
|
|
77
80
|
}[];
|
|
78
|
-
|
|
81
|
+
defaultValue: string;
|
|
79
82
|
};
|
|
80
83
|
|
|
81
84
|
declare type ActivitySettingsTextArea = {
|
|
82
85
|
type: "textarea";
|
|
83
|
-
|
|
86
|
+
defaultValue: string;
|
|
84
87
|
};
|
|
85
88
|
|
|
86
89
|
declare type AddId<C, I extends {
|
|
@@ -112,11 +115,12 @@ declare type AllContractNames = keyof AllContracts;
|
|
|
112
115
|
|
|
113
116
|
declare type AllContracts = CapytaleContracts & CustomContracts;
|
|
114
117
|
|
|
115
|
-
export declare function Capytale({ children, contracts, loadOnlyWhenReady, }: PropsWithChildren<CapytaleProps
|
|
118
|
+
export declare function Capytale<T extends ActivitySettings>({ children, contracts, loadOnlyWhenReady, activitySettingsStore, }: PropsWithChildren<CapytaleProps<T>>): JSX_2.Element;
|
|
116
119
|
|
|
117
|
-
declare type CapytaleProps = {
|
|
120
|
+
declare type CapytaleProps<T extends ActivitySettings> = {
|
|
118
121
|
contracts: ContractNamesExceptForced[];
|
|
119
122
|
loadOnlyWhenReady?: boolean;
|
|
123
|
+
activitySettingsStore?: ReturnType<typeof createActivitySettingsStore<T>>;
|
|
120
124
|
};
|
|
121
125
|
|
|
122
126
|
/**
|
|
@@ -131,6 +135,13 @@ declare type CollectionOf<T extends {
|
|
|
131
135
|
|
|
132
136
|
declare type ContractNamesExceptForced = Exclude<AllContractNames, ForcedContactNames>;
|
|
133
137
|
|
|
138
|
+
export declare function createActivitySettingsStore<T extends ActivitySettings>(as: T): {
|
|
139
|
+
(): InferValue<T>;
|
|
140
|
+
<U>(selector: (state: InferValue<T>) => U): U;
|
|
141
|
+
} & StoreApi<InferValue<T>> & {
|
|
142
|
+
activitySettings: T;
|
|
143
|
+
};
|
|
144
|
+
|
|
134
145
|
declare type CustomContracts = CollectionOf<[
|
|
135
146
|
AddIdData<MetaPlayerAntiCheatV1, {
|
|
136
147
|
name: "meta-player-anti-cheat";
|
|
@@ -139,6 +150,11 @@ AddIdData<MetaPlayerAntiCheatV1, {
|
|
|
139
150
|
|
|
140
151
|
declare type ForcedContactNames = "meta-player-events:1" | "mode:1" | "workflow:1";
|
|
141
152
|
|
|
153
|
+
declare type FormField = (ActivitySettingsRange | ActivitySettingsInput | ActivitySettingsNumberInput | ActivitySettingsTextArea | ActivitySettingsOption | ActivitySettingsSelect) & {
|
|
154
|
+
label: string;
|
|
155
|
+
name: string;
|
|
156
|
+
};
|
|
157
|
+
|
|
142
158
|
declare type IdContractTuple<T extends {
|
|
143
159
|
name: string;
|
|
144
160
|
version: number;
|
|
@@ -162,6 +178,47 @@ declare type Indexed<L extends [string, unknown]> = {
|
|
|
162
178
|
[I in L[0]]: Extract<L, [I, any]>[1];
|
|
163
179
|
};
|
|
164
180
|
|
|
181
|
+
declare type InferFieldType<T> = T extends {
|
|
182
|
+
type: "checkboxes" | "switches";
|
|
183
|
+
options: readonly {
|
|
184
|
+
value: infer V;
|
|
185
|
+
}[];
|
|
186
|
+
} ? V[] : T extends {
|
|
187
|
+
type: "radio";
|
|
188
|
+
options: readonly {
|
|
189
|
+
value: infer V;
|
|
190
|
+
}[];
|
|
191
|
+
} ? V | null : T extends {
|
|
192
|
+
type: "select";
|
|
193
|
+
options: readonly {
|
|
194
|
+
value: infer V;
|
|
195
|
+
}[];
|
|
196
|
+
} ? V : T extends {
|
|
197
|
+
type: "input";
|
|
198
|
+
inputType: "number";
|
|
199
|
+
} ? number : T extends {
|
|
200
|
+
type: "input" | "textarea";
|
|
201
|
+
} ? string : T extends {
|
|
202
|
+
type: "range";
|
|
203
|
+
} ? number : T extends {
|
|
204
|
+
type: "checkbox" | "switch";
|
|
205
|
+
} ? boolean : never;
|
|
206
|
+
|
|
207
|
+
export declare type InferValue<T> = T extends readonly (infer Section)[] ? UnionToIntersection<Section extends {
|
|
208
|
+
type: "form";
|
|
209
|
+
fields: infer F extends readonly any[];
|
|
210
|
+
} ? UnionToIntersection<{
|
|
211
|
+
[K in keyof F]: F[K] extends {
|
|
212
|
+
name: infer N extends string;
|
|
213
|
+
} ? {
|
|
214
|
+
[P in N]: InferFieldType<F[K]>;
|
|
215
|
+
} : never;
|
|
216
|
+
}[number]> : Section extends {
|
|
217
|
+
name: infer N extends string;
|
|
218
|
+
} ? {
|
|
219
|
+
[P in N]: InferFieldType<Section>;
|
|
220
|
+
} : never> : never;
|
|
221
|
+
|
|
165
222
|
declare type MetaPlayerAntiCheatV1 = {
|
|
166
223
|
version: 1;
|
|
167
224
|
/**
|
|
@@ -207,6 +264,8 @@ declare type MPToastMessage = {
|
|
|
207
264
|
life?: number;
|
|
208
265
|
};
|
|
209
266
|
|
|
267
|
+
declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
268
|
+
|
|
210
269
|
export declare const useAfterSaveAction: (fn: () => any) => void;
|
|
211
270
|
|
|
212
271
|
export declare const useGetLoadedJsonActivityContent: () => () => any;
|
|
@@ -261,7 +320,7 @@ export declare const useQuickActions: (actionsFn: () => Action[], deps: readonly
|
|
|
261
320
|
|
|
262
321
|
export declare const useRequestSave: () => () => void;
|
|
263
322
|
|
|
264
|
-
export declare const useSettings: (settingsUiFn: () =>
|
|
323
|
+
export declare const useSettings: <T extends ActivitySettings>(settingsUiFn: () => T | null, callback: (changes: Partial<InferValue<T>>) => void, deps: readonly unknown[]) => void;
|
|
265
324
|
|
|
266
325
|
export declare const useShowToast: () => (message: MPToastMessage) => void;
|
|
267
326
|
|
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 h, jsxs as j, Fragment as M } from "react/jsx-runtime";
|
|
2
|
+
import v, { useCallback as S, useEffect as l, useMemo as w } from "react";
|
|
3
|
+
import { getSocket as I } from "@capytale/app-agent";
|
|
4
|
+
const k = (t) => {
|
|
5
5
|
let e;
|
|
6
|
-
const o = /* @__PURE__ */ new Set(), s = (
|
|
7
|
-
const
|
|
8
|
-
if (!Object.is(
|
|
9
|
-
const
|
|
10
|
-
e =
|
|
6
|
+
const o = /* @__PURE__ */ new Set(), s = (C, p) => {
|
|
7
|
+
const d = typeof C == "function" ? C(e) : C;
|
|
8
|
+
if (!Object.is(d, e)) {
|
|
9
|
+
const J = e;
|
|
10
|
+
e = p ?? (typeof d != "object" || d === null) ? d : Object.assign({}, e, d), o.forEach((m) => m(e, J));
|
|
11
11
|
}
|
|
12
|
-
}, i = () => e,
|
|
13
|
-
return
|
|
14
|
-
},
|
|
15
|
-
function
|
|
16
|
-
const o =
|
|
12
|
+
}, i = () => e, a = { setState: s, getState: i, getInitialState: () => r, subscribe: (C) => (o.add(C), () => o.delete(C)) }, r = e = t(s, i, a);
|
|
13
|
+
return a;
|
|
14
|
+
}, L = (t) => t ? k(t) : k, $ = (t) => t;
|
|
15
|
+
function q(t, e = $) {
|
|
16
|
+
const o = v.useSyncExternalStore(
|
|
17
17
|
t.subscribe,
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
v.useCallback(() => e(t.getState()), [t, e]),
|
|
19
|
+
v.useCallback(() => e(t.getInitialState()), [t, e])
|
|
20
20
|
);
|
|
21
|
-
return
|
|
21
|
+
return v.useDebugValue(o), o;
|
|
22
22
|
}
|
|
23
23
|
const x = (t) => {
|
|
24
|
-
const e =
|
|
24
|
+
const e = L(t), o = (s) => q(e, s);
|
|
25
25
|
return Object.assign(o, e), o;
|
|
26
|
-
},
|
|
26
|
+
}, E = (t) => t ? x(t) : x, B = (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 (!
|
|
36
|
-
const
|
|
37
|
-
|
|
28
|
+
return s.subscribe = (u, a, r) => {
|
|
29
|
+
let C = u;
|
|
30
|
+
if (a) {
|
|
31
|
+
const p = r?.equalityFn || Object.is;
|
|
32
|
+
let d = u(s.getState());
|
|
33
|
+
C = (J) => {
|
|
34
|
+
const m = u(J);
|
|
35
|
+
if (!p(d, m)) {
|
|
36
|
+
const G = d;
|
|
37
|
+
a(d = m, G);
|
|
38
38
|
}
|
|
39
|
-
},
|
|
39
|
+
}, r?.fireImmediately && a(d, d);
|
|
40
40
|
}
|
|
41
|
-
return i(
|
|
41
|
+
return i(C);
|
|
42
42
|
}, t(e, o, s);
|
|
43
|
-
},
|
|
44
|
-
|
|
43
|
+
}, P = B, n = E()(
|
|
44
|
+
P((t) => ({
|
|
45
45
|
ready: !1,
|
|
46
46
|
workflow: "current",
|
|
47
47
|
mode: "assignment",
|
|
@@ -75,7 +75,7 @@ const x = (t) => {
|
|
|
75
75
|
},
|
|
76
76
|
sidebarActions: {},
|
|
77
77
|
quickActions: {},
|
|
78
|
-
|
|
78
|
+
activitySettingsCallback: null,
|
|
79
79
|
setGetTextContentFunction: (e) => {
|
|
80
80
|
t({ getTextContentFunction: e });
|
|
81
81
|
},
|
|
@@ -100,8 +100,8 @@ const x = (t) => {
|
|
|
100
100
|
setQuickActions: (e) => {
|
|
101
101
|
t({ quickActions: e });
|
|
102
102
|
},
|
|
103
|
-
|
|
104
|
-
t({
|
|
103
|
+
setActivitySettingsCallback: (e) => {
|
|
104
|
+
t({ activitySettingsCallback: e });
|
|
105
105
|
},
|
|
106
106
|
incSaveCount: () => t((e) => ({
|
|
107
107
|
saveCount: e.saveCount + 1
|
|
@@ -109,8 +109,8 @@ const x = (t) => {
|
|
|
109
109
|
incDirtyCount: () => t((e) => ({ isDirtyCount: e.isDirtyCount + 1 }))
|
|
110
110
|
}))
|
|
111
111
|
);
|
|
112
|
-
let
|
|
113
|
-
const
|
|
112
|
+
let T = !1;
|
|
113
|
+
const R = [
|
|
114
114
|
"meta-player-events:1",
|
|
115
115
|
"meta-player-ui:1",
|
|
116
116
|
"mode:1",
|
|
@@ -124,7 +124,7 @@ const P = [
|
|
|
124
124
|
"simple-content-eval(json):1",
|
|
125
125
|
"separate-contents(json):1",
|
|
126
126
|
"separate-dual-contents(json):1"
|
|
127
|
-
],
|
|
127
|
+
], D = {
|
|
128
128
|
"mode:1": {
|
|
129
129
|
setMode: (t) => {
|
|
130
130
|
n.setState({ mode: t });
|
|
@@ -313,7 +313,11 @@ const P = [
|
|
|
313
313
|
}
|
|
314
314
|
},
|
|
315
315
|
updateSettings(t) {
|
|
316
|
-
n.
|
|
316
|
+
const e = n.getState().activitySettingsCallback;
|
|
317
|
+
e ? e(t) : console.warn(
|
|
318
|
+
"activitySettingsCallback is not set. Changes:",
|
|
319
|
+
t
|
|
320
|
+
);
|
|
317
321
|
}
|
|
318
322
|
},
|
|
319
323
|
"meta-player-events:1": {
|
|
@@ -321,30 +325,30 @@ const P = [
|
|
|
321
325
|
t === "all-loaded" && n.setState({ ready: !0 });
|
|
322
326
|
}
|
|
323
327
|
}
|
|
324
|
-
},
|
|
325
|
-
function
|
|
326
|
-
if (
|
|
328
|
+
}, g = I();
|
|
329
|
+
function O(t) {
|
|
330
|
+
if (T) {
|
|
327
331
|
console.warn("Contracts have already been plugged. Skipping.");
|
|
328
332
|
return;
|
|
329
333
|
}
|
|
330
|
-
|
|
334
|
+
T = !0;
|
|
331
335
|
for (const e of t) {
|
|
332
|
-
if (!
|
|
336
|
+
if (!R.includes(e)) {
|
|
333
337
|
console.warn(
|
|
334
338
|
`Contract ${e} is not implemented in Capytale. Skipping plug.`
|
|
335
339
|
);
|
|
336
340
|
continue;
|
|
337
341
|
}
|
|
338
|
-
if (!(e in
|
|
342
|
+
if (!(e in D)) {
|
|
339
343
|
console.warn(
|
|
340
344
|
`Contract handler for ${e} is not defined. Skipping plug.`
|
|
341
345
|
);
|
|
342
346
|
continue;
|
|
343
347
|
}
|
|
344
|
-
const o =
|
|
345
|
-
|
|
348
|
+
const o = D[e];
|
|
349
|
+
g.plug([e], ([]) => [o]);
|
|
346
350
|
}
|
|
347
|
-
|
|
351
|
+
g.plugsDone();
|
|
348
352
|
for (const e of [
|
|
349
353
|
"simple-content(text):1",
|
|
350
354
|
"simple-content(json):1",
|
|
@@ -357,12 +361,11 @@ function R(t) {
|
|
|
357
361
|
if (console.log(`Contract ${e} is being subscribed to content changes.`), t.includes(e)) {
|
|
358
362
|
console.log(`Subscribing to content changes for contract ${e}`);
|
|
359
363
|
const o = e.split(":")[0];
|
|
360
|
-
|
|
364
|
+
g.use([o], ([s]) => {
|
|
361
365
|
n.subscribe(
|
|
362
366
|
(i) => i.isDirtyCount,
|
|
363
367
|
() => {
|
|
364
|
-
|
|
365
|
-
(i = s.i) == null || i.contentChanged(), console.log(
|
|
368
|
+
s.i?.contentChanged(), console.log(
|
|
366
369
|
`Content changed for contract ${o}`
|
|
367
370
|
);
|
|
368
371
|
}
|
|
@@ -370,233 +373,314 @@ function R(t) {
|
|
|
370
373
|
});
|
|
371
374
|
}
|
|
372
375
|
}
|
|
373
|
-
const
|
|
374
|
-
"meta-player-events:1",
|
|
375
|
-
"mode:1",
|
|
376
|
-
"workflow:1"
|
|
377
|
-
];
|
|
378
|
-
function H({
|
|
379
|
-
children: t,
|
|
380
|
-
contracts: e,
|
|
381
|
-
loadOnlyWhenReady: o = !0
|
|
382
|
-
}) {
|
|
383
|
-
const s = n((i) => i.ready);
|
|
384
|
-
return d(() => {
|
|
385
|
-
const i = [...e];
|
|
386
|
-
for (const c of Q)
|
|
387
|
-
i.includes(c) || i.push(c);
|
|
388
|
-
R(i);
|
|
389
|
-
}, []), o && !s ? /* @__PURE__ */ w("div", { className: "capy-loading-container", children: "Chargement en cours..." }) : /* @__PURE__ */ w(E, { children: t });
|
|
390
|
-
}
|
|
391
|
-
const U = () => n((t) => {
|
|
376
|
+
const tt = () => n((t) => {
|
|
392
377
|
if (t.mode === null)
|
|
393
378
|
throw new Error("Mode is not set. Have you used contract 'mode'?");
|
|
394
379
|
return t.mode;
|
|
395
|
-
}),
|
|
380
|
+
}), et = () => n((t) => {
|
|
396
381
|
if (t.workflow === null)
|
|
397
|
-
throw new Error(
|
|
382
|
+
throw new Error(
|
|
383
|
+
"Workflow is not set. Have you used contract 'workflow'?"
|
|
384
|
+
);
|
|
398
385
|
return t.workflow;
|
|
399
|
-
}),
|
|
386
|
+
}), nt = () => n((t) => {
|
|
400
387
|
if (t.theme === null)
|
|
401
388
|
throw new Error("Theme is not set. Have you used contract 'theme'?");
|
|
402
389
|
return t.theme;
|
|
403
|
-
}),
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
390
|
+
}), ot = () => n((t) => t.incSaveCount), st = () => n((t) => t.incDirtyCount), it = () => n((t) => t.loadedTextContent), at = () => n((t) => t.loadedJsonContent), ct = () => n((t) => t.loadedJsonActivityContent), rt = () => n((t) => t.loadedJsonAssignmentContent), lt = () => n((t) => t.loadedJsonActivityBinaryData), ut = () => n((t) => t.loadedJsonAssignmentBinaryData), dt = () => S(() => n.getState().loadedTextContent, []), gt = () => S(() => n.getState().loadedJsonContent, []), Ct = () => S(() => n.getState().loadedJsonActivityContent, []), St = () => S(() => n.getState().loadedJsonAssignmentContent, []), pt = () => S(
|
|
391
|
+
() => ({
|
|
392
|
+
content: n.getState().loadedJsonActivityContent,
|
|
393
|
+
binaryData: n.getState().loadedJsonActivityBinaryData
|
|
394
|
+
}),
|
|
395
|
+
[]
|
|
396
|
+
), mt = () => S(
|
|
397
|
+
() => ({
|
|
398
|
+
content: n.getState().loadedJsonAssignmentContent,
|
|
399
|
+
binaryData: n.getState().loadedJsonAssignmentBinaryData
|
|
400
|
+
}),
|
|
401
|
+
[]
|
|
402
|
+
), vt = (t) => {
|
|
410
403
|
const e = n(
|
|
411
404
|
(o) => o.setGetTextContentFunction
|
|
412
405
|
);
|
|
413
|
-
|
|
406
|
+
l(() => {
|
|
414
407
|
e(t);
|
|
415
408
|
}, [t, e]);
|
|
416
|
-
},
|
|
409
|
+
}, yt = (t) => {
|
|
417
410
|
const e = n(
|
|
418
411
|
(o) => o.setGetJsonContentFunction
|
|
419
412
|
);
|
|
420
|
-
|
|
413
|
+
l(() => {
|
|
421
414
|
e(t);
|
|
422
415
|
}, [t, e]);
|
|
423
|
-
},
|
|
416
|
+
}, ft = (t) => {
|
|
424
417
|
const e = n(
|
|
425
418
|
(o) => o.setGetJsonActivityContentFunction
|
|
426
419
|
);
|
|
427
|
-
|
|
420
|
+
l(() => {
|
|
428
421
|
e(t);
|
|
429
422
|
}, [t, e]);
|
|
430
|
-
},
|
|
423
|
+
}, At = (t) => {
|
|
431
424
|
const e = n(
|
|
432
425
|
(o) => o.setGetJsonAssignmentContentFunction
|
|
433
426
|
);
|
|
434
|
-
|
|
427
|
+
l(() => {
|
|
435
428
|
e(t);
|
|
436
429
|
}, [t, e]);
|
|
437
|
-
},
|
|
430
|
+
}, Jt = (t) => {
|
|
438
431
|
const e = n(
|
|
439
432
|
(o) => o.setGetJsonActivitySplitContentFunction
|
|
440
433
|
);
|
|
441
|
-
|
|
434
|
+
l(() => {
|
|
442
435
|
e(t);
|
|
443
436
|
}, [t, e]);
|
|
444
|
-
},
|
|
437
|
+
}, Ft = (t) => {
|
|
445
438
|
const e = n(
|
|
446
439
|
(o) => o.setGetJsonAssignmentSplitContentFunction
|
|
447
440
|
);
|
|
448
|
-
|
|
441
|
+
l(() => {
|
|
449
442
|
e(t);
|
|
450
443
|
}, [t, e]);
|
|
451
|
-
},
|
|
444
|
+
}, bt = (t) => {
|
|
452
445
|
const e = n((o) => o.afterSaveCount);
|
|
453
|
-
|
|
446
|
+
l(() => {
|
|
454
447
|
e > 0 && t();
|
|
455
448
|
}, [e]);
|
|
456
|
-
},
|
|
457
|
-
|
|
458
|
-
var s;
|
|
449
|
+
}, wt = () => (t, e) => {
|
|
450
|
+
g.use(["meta-player-ui"], ([o]) => {
|
|
459
451
|
if (o.version === 0) {
|
|
460
|
-
console.error(
|
|
452
|
+
console.error(
|
|
453
|
+
"Le MétaPlayer ne supporte pas le contrat meta-player-ui"
|
|
454
|
+
);
|
|
461
455
|
return;
|
|
462
456
|
}
|
|
463
|
-
|
|
457
|
+
o.i?.previewTextFile(t, e);
|
|
464
458
|
});
|
|
465
|
-
},
|
|
466
|
-
|
|
467
|
-
var s;
|
|
459
|
+
}, ht = () => (t, e) => {
|
|
460
|
+
g.use(["meta-player-ui"], ([o]) => {
|
|
468
461
|
if (o.version === 0) {
|
|
469
|
-
console.error(
|
|
462
|
+
console.error(
|
|
463
|
+
"Le MétaPlayer ne supporte pas le contrat meta-player-ui"
|
|
464
|
+
);
|
|
470
465
|
return;
|
|
471
466
|
}
|
|
472
|
-
|
|
467
|
+
o.i?.previewImageFile(t, e);
|
|
473
468
|
});
|
|
474
469
|
};
|
|
475
|
-
let
|
|
476
|
-
const
|
|
477
|
-
const o =
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
470
|
+
let y = 0, F = 0;
|
|
471
|
+
const kt = (t, e) => {
|
|
472
|
+
const o = w(t, e), s = n((i) => i.setSidebarActions);
|
|
473
|
+
l(() => (y++, y > 1 && console.error(
|
|
474
|
+
"Capytale iframe React: Multiple sidebar actions registered: ",
|
|
475
|
+
y
|
|
476
|
+
), () => {
|
|
477
|
+
y--;
|
|
478
|
+
}), []), l(() => (g.use(["meta-player-ui"], ([i]) => {
|
|
482
479
|
if (i.version === 0) {
|
|
483
|
-
console.error(
|
|
480
|
+
console.error(
|
|
481
|
+
"Le MétaPlayer ne supporte pas le contrat meta-player-ui"
|
|
482
|
+
);
|
|
484
483
|
return;
|
|
485
484
|
}
|
|
486
|
-
|
|
487
|
-
const c = o.map((a,
|
|
485
|
+
F++;
|
|
486
|
+
const c = o.map((a, r) => ({
|
|
488
487
|
type: a.type,
|
|
489
488
|
title: a.title,
|
|
490
489
|
icon: a.icon,
|
|
491
|
-
id: `sa-${
|
|
490
|
+
id: `sa-${F}-${r}`,
|
|
492
491
|
...a.type === "file-upload" ? { accept: a.accept } : {}
|
|
493
|
-
})),
|
|
494
|
-
o.forEach((a,
|
|
495
|
-
|
|
496
|
-
}),
|
|
492
|
+
})), u = {};
|
|
493
|
+
o.forEach((a, r) => {
|
|
494
|
+
u[`sa-${F}-${r}`] = a.action;
|
|
495
|
+
}), i.i?.setSidebarActionButtons(c), s(u);
|
|
497
496
|
}), () => {
|
|
498
|
-
s({}),
|
|
499
|
-
var c;
|
|
497
|
+
s({}), g.use(["meta-player-ui"], ([i]) => {
|
|
500
498
|
if (i.version === 0) {
|
|
501
|
-
console.error(
|
|
499
|
+
console.error(
|
|
500
|
+
"Le MétaPlayer ne supporte pas le contrat meta-player-ui"
|
|
501
|
+
);
|
|
502
502
|
return;
|
|
503
503
|
}
|
|
504
|
-
|
|
504
|
+
i.i?.setSidebarActionButtons([]);
|
|
505
505
|
});
|
|
506
506
|
}), [o]);
|
|
507
507
|
};
|
|
508
|
-
let
|
|
509
|
-
const
|
|
510
|
-
const o =
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
508
|
+
let f = 0, b = 0;
|
|
509
|
+
const xt = (t, e) => {
|
|
510
|
+
const o = w(t, e), s = n((i) => i.setQuickActions);
|
|
511
|
+
l(() => (f++, f > 1 && console.error(
|
|
512
|
+
"Capytale iframe React: Multiple quick actions registered: ",
|
|
513
|
+
f
|
|
514
|
+
), () => {
|
|
515
|
+
f--;
|
|
516
|
+
}), []), l(() => (g.use(["meta-player-ui"], ([i]) => {
|
|
515
517
|
if (i.version === 0) {
|
|
516
|
-
console.error(
|
|
518
|
+
console.error(
|
|
519
|
+
"Le MétaPlayer ne supporte pas le contrat meta-player-ui"
|
|
520
|
+
);
|
|
517
521
|
return;
|
|
518
522
|
}
|
|
519
|
-
|
|
520
|
-
const c = o.map((a,
|
|
523
|
+
b++;
|
|
524
|
+
const c = o.map((a, r) => ({
|
|
521
525
|
type: a.type,
|
|
522
526
|
title: a.title,
|
|
523
527
|
icon: a.icon,
|
|
524
|
-
id: `qa-${
|
|
528
|
+
id: `qa-${b}-${r}`,
|
|
525
529
|
...a.type === "file-upload" ? { accept: a.accept } : {}
|
|
526
|
-
})),
|
|
527
|
-
o.forEach((a,
|
|
528
|
-
|
|
529
|
-
}),
|
|
530
|
+
})), u = {};
|
|
531
|
+
o.forEach((a, r) => {
|
|
532
|
+
u[`qa-${b}-${r}`] = a.action;
|
|
533
|
+
}), i.i?.setQuickActionButtons(c), s(u);
|
|
530
534
|
}), () => {
|
|
531
|
-
s({}),
|
|
532
|
-
var c;
|
|
535
|
+
s({}), g.use(["meta-player-ui"], ([i]) => {
|
|
533
536
|
if (i.version === 0) {
|
|
534
|
-
console.error(
|
|
537
|
+
console.error(
|
|
538
|
+
"Le MétaPlayer ne supporte pas le contrat meta-player-ui"
|
|
539
|
+
);
|
|
535
540
|
return;
|
|
536
541
|
}
|
|
537
|
-
|
|
542
|
+
i.i?.setQuickActionButtons([]);
|
|
538
543
|
});
|
|
539
544
|
}), [o]);
|
|
540
545
|
};
|
|
541
546
|
let A = 0;
|
|
542
|
-
const
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
547
|
+
const V = (t, e, o) => {
|
|
548
|
+
const s = w(t, o), i = n(
|
|
549
|
+
(c) => c.setActivitySettingsCallback
|
|
550
|
+
);
|
|
551
|
+
l(() => (console.log("Mounting useSettings"), A++, A > 1 && console.error(
|
|
552
|
+
"Capytale iframe React: Multiple settings registered: ",
|
|
553
|
+
A
|
|
554
|
+
), () => {
|
|
555
|
+
console.log("Unmounting useSettings"), A--;
|
|
556
|
+
}), []), l(() => (g.use(["meta-player-ui"], ([c]) => {
|
|
557
|
+
if (c.version === 0) {
|
|
558
|
+
console.error(
|
|
559
|
+
"Le MétaPlayer ne supporte pas le contrat meta-player-ui"
|
|
560
|
+
);
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
console.log("Updating settings UI in MetaPlayer", s), c.i?.setSettingsUI(s);
|
|
564
|
+
}), i(
|
|
565
|
+
e
|
|
566
|
+
), () => {
|
|
567
|
+
i(null);
|
|
568
|
+
}), [s]);
|
|
569
|
+
}, Tt = () => (e) => {
|
|
570
|
+
g.use(["meta-player-ui"], ([o]) => {
|
|
563
571
|
if (o.version === 0) {
|
|
564
|
-
console.error(
|
|
572
|
+
console.error(
|
|
573
|
+
"Le MétaPlayer ne supporte pas le contrat meta-player-ui"
|
|
574
|
+
);
|
|
565
575
|
return;
|
|
566
576
|
}
|
|
567
|
-
|
|
577
|
+
o.i?.showToast(e);
|
|
568
578
|
});
|
|
569
579
|
};
|
|
580
|
+
function W(t) {
|
|
581
|
+
const e = {};
|
|
582
|
+
for (const o of t.fields)
|
|
583
|
+
e[o.name] = o.defaultValue;
|
|
584
|
+
return e;
|
|
585
|
+
}
|
|
586
|
+
function Q(t) {
|
|
587
|
+
return { [t.name]: t.defaultValues };
|
|
588
|
+
}
|
|
589
|
+
function U(t) {
|
|
590
|
+
return { [t.name]: t.defaultValue };
|
|
591
|
+
}
|
|
592
|
+
function H(t) {
|
|
593
|
+
switch (t.type) {
|
|
594
|
+
case "form":
|
|
595
|
+
return W(t);
|
|
596
|
+
case "checkboxes":
|
|
597
|
+
case "switches":
|
|
598
|
+
return Q(t);
|
|
599
|
+
case "radio":
|
|
600
|
+
return U(t);
|
|
601
|
+
default:
|
|
602
|
+
return {};
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
function N(t) {
|
|
606
|
+
const e = {};
|
|
607
|
+
for (const o of t)
|
|
608
|
+
Object.assign(e, H(o));
|
|
609
|
+
return e;
|
|
610
|
+
}
|
|
611
|
+
function Dt(t) {
|
|
612
|
+
const o = E()((s) => ({
|
|
613
|
+
...N(t)
|
|
614
|
+
}));
|
|
615
|
+
return o.activitySettings = t, o;
|
|
616
|
+
}
|
|
617
|
+
function _(t) {
|
|
618
|
+
V(
|
|
619
|
+
() => t.activitySettings,
|
|
620
|
+
(e) => {
|
|
621
|
+
t.setState(e);
|
|
622
|
+
},
|
|
623
|
+
[]
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
function z({
|
|
627
|
+
store: t
|
|
628
|
+
}) {
|
|
629
|
+
return _(t), null;
|
|
630
|
+
}
|
|
631
|
+
const K = [
|
|
632
|
+
"meta-player-events:1",
|
|
633
|
+
"mode:1",
|
|
634
|
+
"workflow:1"
|
|
635
|
+
];
|
|
636
|
+
function Et({
|
|
637
|
+
children: t,
|
|
638
|
+
contracts: e,
|
|
639
|
+
loadOnlyWhenReady: o = !0,
|
|
640
|
+
activitySettingsStore: s
|
|
641
|
+
}) {
|
|
642
|
+
const i = n((c) => c.ready);
|
|
643
|
+
return l(() => {
|
|
644
|
+
const c = [...e];
|
|
645
|
+
for (const u of K)
|
|
646
|
+
c.includes(u) || c.push(u);
|
|
647
|
+
O(c);
|
|
648
|
+
}, []), o && !i ? /* @__PURE__ */ h("div", { className: "capy-loading-container", children: "Chargement en cours..." }) : /* @__PURE__ */ j(M, { children: [
|
|
649
|
+
s && /* @__PURE__ */ h(z, { store: s }),
|
|
650
|
+
t
|
|
651
|
+
] });
|
|
652
|
+
}
|
|
570
653
|
export {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
dt as
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
654
|
+
Et as Capytale,
|
|
655
|
+
Dt as createActivitySettingsStore,
|
|
656
|
+
bt as useAfterSaveAction,
|
|
657
|
+
Ct as useGetLoadedJsonActivityContent,
|
|
658
|
+
pt as useGetLoadedJsonActivitySplitContent,
|
|
659
|
+
St as useGetLoadedJsonAssignmentContent,
|
|
660
|
+
mt as useGetLoadedJsonAssignmentSplitContent,
|
|
661
|
+
gt as useGetLoadedJsonContent,
|
|
662
|
+
dt as useGetLoadedTextContent,
|
|
663
|
+
ft as useJsonActivityContentSaveFunction,
|
|
664
|
+
Jt as useJsonActivitySplitContentSaveFunction,
|
|
665
|
+
At as useJsonAssignmentContentSaveFunction,
|
|
666
|
+
Ft as useJsonAssignmentSplitContentSaveFunction,
|
|
667
|
+
yt as useJsonContentSaveFunction,
|
|
668
|
+
lt as useLoadedJsonActivityBinaryData,
|
|
669
|
+
ct as useLoadedJsonActivityContent,
|
|
670
|
+
ut as useLoadedJsonAssignmentBinaryData,
|
|
671
|
+
rt as useLoadedJsonAssignmentContent,
|
|
672
|
+
at as useLoadedJsonContent,
|
|
673
|
+
it as useLoadedTextContent,
|
|
674
|
+
tt as useMode,
|
|
675
|
+
st as useNotifyIsDirty,
|
|
676
|
+
ht as usePreviewImageFile,
|
|
677
|
+
wt as usePreviewTextFile,
|
|
678
|
+
xt as useQuickActions,
|
|
679
|
+
ot as useRequestSave,
|
|
680
|
+
V as useSettings,
|
|
681
|
+
Tt as useShowToast,
|
|
682
|
+
kt as useSidebarActions,
|
|
683
|
+
vt as useTextContentSaveFunction,
|
|
684
|
+
nt as useTheme,
|
|
685
|
+
et as useWorkflow
|
|
602
686
|
};
|
package/package.json
CHANGED
|
@@ -1,51 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@capytale/iframe-react",
|
|
3
|
-
"version": "1.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.12",
|
|
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": "^
|
|
42
|
-
"react": "^18.3.1",
|
|
43
|
-
"react-dom": "^18.3.1",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"vite
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@capytale/iframe-react",
|
|
3
|
+
"version": "1.1.5",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"clean": "rimraf 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.1.0",
|
|
31
|
+
"zustand": "^5.0.9"
|
|
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": "^5.1.1",
|
|
42
|
+
"react": "^18.3.1",
|
|
43
|
+
"react-dom": "^18.3.1",
|
|
44
|
+
"rimraf": "^6.1.2",
|
|
45
|
+
"typescript": "^5.9.3",
|
|
46
|
+
"vite": "^7.2.6",
|
|
47
|
+
"vite-plugin-dts": "^4.5.4"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
}
|
|
52
|
+
}
|