@capytale/iframe-react 1.1.3 → 1.1.4
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 +212 -165
- 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"),c=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,a={setState:s,getState:i,getInitialState:()=>u,subscribe:C=>(o.add(C),()=>o.delete(C))},u=e=t(s,i,a);return a},G=t=>t?b(t):b,D=t=>t;function M(t,e=D){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=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,a,u)=>{let C=l;if(a){const S=u?.equalityFn||Object.is;let d=l(s.getState());C=A=>{const f=l(A);if(!S(d,f)){const E=d;a(d=f,E)}},u?.fireImmediately&&a(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),H=()=>n(t=>t.loadedJsonAssignmentContent),U=()=>n(t=>t.loadedJsonActivityBinaryData),_=()=>n(t=>t.loadedJsonAssignmentBinaryData),z=()=>()=>n.getState().loadedTextContent,K=()=>()=>n.getState().loadedJsonContent,X=()=>()=>n.getState().loadedJsonActivityContent,Y=()=>()=>n.getState().loadedJsonAssignmentContent,Z=()=>()=>({content:n.getState().loadedJsonActivityContent,binaryData:n.getState().loadedJsonActivityBinaryData}),tt=()=>()=>({content:n.getState().loadedJsonAssignmentContent,binaryData:n.getState().loadedJsonAssignmentBinaryData}),et=t=>{const e=n(o=>o.setGetTextContentFunction);c.useEffect(()=>{e(t)},[t,e])},nt=t=>{const e=n(o=>o.setGetJsonContentFunction);c.useEffect(()=>{e(t)},[t,e])},ot=t=>{const e=n(o=>o.setGetJsonActivityContentFunction);c.useEffect(()=>{e(t)},[t,e])},st=t=>{const e=n(o=>o.setGetJsonAssignmentContentFunction);c.useEffect(()=>{e(t)},[t,e])},it=t=>{const e=n(o=>o.setGetJsonActivitySplitContentFunction);c.useEffect(()=>{e(t)},[t,e])},at=t=>{const e=n(o=>o.setGetJsonAssignmentSplitContentFunction);c.useEffect(()=>{e(t)},[t,e])},ct=t=>{const e=n(o=>o.afterSaveCount);c.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=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(()=>(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((a,u)=>({type:a.type,title:a.title,icon:a.icon,id:`sa-${J}-${u}`,...a.type==="file-upload"?{accept:a.accept}:{}})),l={};o.forEach((a,u)=>{l[`sa-${J}-${u}`]=a.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=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(()=>(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((a,u)=>({type:a.type,title:a.title,icon:a.icon,id:`qa-${F}-${u}`,...a.type==="file-upload"?{accept:a.accept}:{}})),l={};o.forEach((a,u)=>{l[`qa-${F}-${u}`]=a.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=c.useMemo(t,o),i=n(r=>r.setActivitySettingsCallback);c.useEffect(()=>(console.log("Mounting useSettings"),m++,m>1&&console.error("Capytale iframe React: Multiple settings registered: ",m),()=>{m--}),[]),c.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 c.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=U;exports.useLoadedJsonActivityContent=N;exports.useLoadedJsonAssignmentBinaryData=_;exports.useLoadedJsonAssignmentContent=H;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,17 +1,17 @@
|
|
|
1
|
-
import { jsx as w, Fragment as
|
|
2
|
-
import m, { useEffect as
|
|
3
|
-
import { getSocket as
|
|
1
|
+
import { jsx as w, jsxs as G, Fragment as j } from "react/jsx-runtime";
|
|
2
|
+
import m, { useEffect as l, useMemo as b } from "react";
|
|
3
|
+
import { getSocket as M } from "@capytale/app-agent";
|
|
4
4
|
const h = (t) => {
|
|
5
5
|
let e;
|
|
6
|
-
const o = /* @__PURE__ */ new Set(), s = (
|
|
7
|
-
const
|
|
8
|
-
if (!Object.is(
|
|
9
|
-
const
|
|
10
|
-
e = S ?? (typeof
|
|
6
|
+
const o = /* @__PURE__ */ new Set(), s = (C, S) => {
|
|
7
|
+
const d = typeof C == "function" ? C(e) : C;
|
|
8
|
+
if (!Object.is(d, e)) {
|
|
9
|
+
const A = e;
|
|
10
|
+
e = S ?? (typeof d != "object" || d === null) ? d : Object.assign({}, e, d), o.forEach((p) => p(e, A));
|
|
11
11
|
}
|
|
12
|
-
}, i = () => e,
|
|
13
|
-
return
|
|
14
|
-
},
|
|
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
|
+
}, I = (t) => t ? h(t) : h, L = (t) => t;
|
|
15
15
|
function $(t, e = L) {
|
|
16
16
|
const o = m.useSyncExternalStore(
|
|
17
17
|
t.subscribe,
|
|
@@ -20,27 +20,27 @@ function $(t, e = L) {
|
|
|
20
20
|
);
|
|
21
21
|
return m.useDebugValue(o), o;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
const e =
|
|
23
|
+
const k = (t) => {
|
|
24
|
+
const e = I(t), o = (s) => $(e, s);
|
|
25
25
|
return Object.assign(o, e), o;
|
|
26
|
-
},
|
|
26
|
+
}, D = (t) => t ? k(t) : k, q = (t) => (e, o, s) => {
|
|
27
27
|
const i = s.subscribe;
|
|
28
|
-
return s.subscribe = (
|
|
29
|
-
let
|
|
30
|
-
if (
|
|
31
|
-
const S =
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
const p =
|
|
35
|
-
if (!S(
|
|
36
|
-
const
|
|
37
|
-
|
|
28
|
+
return s.subscribe = (u, a, r) => {
|
|
29
|
+
let C = u;
|
|
30
|
+
if (a) {
|
|
31
|
+
const S = r?.equalityFn || Object.is;
|
|
32
|
+
let d = u(s.getState());
|
|
33
|
+
C = (A) => {
|
|
34
|
+
const p = u(A);
|
|
35
|
+
if (!S(d, p)) {
|
|
36
|
+
const E = d;
|
|
37
|
+
a(d = p, E);
|
|
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
|
-
}, B =
|
|
43
|
+
}, B = q, n = D()(
|
|
44
44
|
B((t) => ({
|
|
45
45
|
ready: !1,
|
|
46
46
|
workflow: "current",
|
|
@@ -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,7 +109,7 @@ const x = (t) => {
|
|
|
109
109
|
incDirtyCount: () => t((e) => ({ isDirtyCount: e.isDirtyCount + 1 }))
|
|
110
110
|
}))
|
|
111
111
|
);
|
|
112
|
-
let
|
|
112
|
+
let x = !1;
|
|
113
113
|
const P = [
|
|
114
114
|
"meta-player-events:1",
|
|
115
115
|
"meta-player-ui:1",
|
|
@@ -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,13 +325,13 @@ const P = [
|
|
|
321
325
|
t === "all-loaded" && n.setState({ ready: !0 });
|
|
322
326
|
}
|
|
323
327
|
}
|
|
324
|
-
},
|
|
328
|
+
}, g = M();
|
|
325
329
|
function R(t) {
|
|
326
|
-
if (
|
|
330
|
+
if (x) {
|
|
327
331
|
console.warn("Contracts have already been plugged. Skipping.");
|
|
328
332
|
return;
|
|
329
333
|
}
|
|
330
|
-
|
|
334
|
+
x = !0;
|
|
331
335
|
for (const e of t) {
|
|
332
336
|
if (!P.includes(e)) {
|
|
333
337
|
console.warn(
|
|
@@ -342,9 +346,9 @@ function R(t) {
|
|
|
342
346
|
continue;
|
|
343
347
|
}
|
|
344
348
|
const o = T[e];
|
|
345
|
-
|
|
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,277 @@ 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 Z = () => 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
|
+
}), tt = () => n((t) => {
|
|
396
381
|
if (t.workflow === null)
|
|
397
382
|
throw new Error("Workflow is not set. Have you used contract 'workflow'?");
|
|
398
383
|
return t.workflow;
|
|
399
|
-
}),
|
|
384
|
+
}), et = () => n((t) => {
|
|
400
385
|
if (t.theme === null)
|
|
401
386
|
throw new Error("Theme is not set. Have you used contract 'theme'?");
|
|
402
387
|
return t.theme;
|
|
403
|
-
}),
|
|
388
|
+
}), nt = () => n((t) => t.incSaveCount), ot = () => n((t) => t.incDirtyCount), st = () => n((t) => t.loadedTextContent), it = () => n((t) => t.loadedJsonContent), at = () => n((t) => t.loadedJsonActivityContent), ct = () => n((t) => t.loadedJsonAssignmentContent), rt = () => n((t) => t.loadedJsonActivityBinaryData), lt = () => n((t) => t.loadedJsonAssignmentBinaryData), ut = () => () => n.getState().loadedTextContent, dt = () => () => n.getState().loadedJsonContent, gt = () => () => n.getState().loadedJsonActivityContent, Ct = () => () => n.getState().loadedJsonAssignmentContent, St = () => () => ({
|
|
404
389
|
content: n.getState().loadedJsonActivityContent,
|
|
405
390
|
binaryData: n.getState().loadedJsonActivityBinaryData
|
|
406
|
-
}),
|
|
391
|
+
}), pt = () => () => ({
|
|
407
392
|
content: n.getState().loadedJsonAssignmentContent,
|
|
408
393
|
binaryData: n.getState().loadedJsonAssignmentBinaryData
|
|
409
|
-
}),
|
|
394
|
+
}), mt = (t) => {
|
|
410
395
|
const e = n(
|
|
411
396
|
(o) => o.setGetTextContentFunction
|
|
412
397
|
);
|
|
413
|
-
|
|
398
|
+
l(() => {
|
|
414
399
|
e(t);
|
|
415
400
|
}, [t, e]);
|
|
416
|
-
},
|
|
401
|
+
}, vt = (t) => {
|
|
417
402
|
const e = n(
|
|
418
403
|
(o) => o.setGetJsonContentFunction
|
|
419
404
|
);
|
|
420
|
-
|
|
405
|
+
l(() => {
|
|
421
406
|
e(t);
|
|
422
407
|
}, [t, e]);
|
|
423
|
-
},
|
|
408
|
+
}, yt = (t) => {
|
|
424
409
|
const e = n(
|
|
425
410
|
(o) => o.setGetJsonActivityContentFunction
|
|
426
411
|
);
|
|
427
|
-
|
|
412
|
+
l(() => {
|
|
428
413
|
e(t);
|
|
429
414
|
}, [t, e]);
|
|
430
|
-
},
|
|
415
|
+
}, ft = (t) => {
|
|
431
416
|
const e = n(
|
|
432
417
|
(o) => o.setGetJsonAssignmentContentFunction
|
|
433
418
|
);
|
|
434
|
-
|
|
419
|
+
l(() => {
|
|
435
420
|
e(t);
|
|
436
421
|
}, [t, e]);
|
|
437
|
-
},
|
|
422
|
+
}, At = (t) => {
|
|
438
423
|
const e = n(
|
|
439
424
|
(o) => o.setGetJsonActivitySplitContentFunction
|
|
440
425
|
);
|
|
441
|
-
|
|
426
|
+
l(() => {
|
|
442
427
|
e(t);
|
|
443
428
|
}, [t, e]);
|
|
444
|
-
},
|
|
429
|
+
}, Jt = (t) => {
|
|
445
430
|
const e = n(
|
|
446
431
|
(o) => o.setGetJsonAssignmentSplitContentFunction
|
|
447
432
|
);
|
|
448
|
-
|
|
433
|
+
l(() => {
|
|
449
434
|
e(t);
|
|
450
435
|
}, [t, e]);
|
|
451
|
-
},
|
|
436
|
+
}, Ft = (t) => {
|
|
452
437
|
const e = n((o) => o.afterSaveCount);
|
|
453
|
-
|
|
438
|
+
l(() => {
|
|
454
439
|
e > 0 && t();
|
|
455
440
|
}, [e]);
|
|
456
|
-
},
|
|
457
|
-
|
|
458
|
-
var s;
|
|
441
|
+
}, bt = () => (t, e) => {
|
|
442
|
+
g.use(["meta-player-ui"], ([o]) => {
|
|
459
443
|
if (o.version === 0) {
|
|
460
444
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
461
445
|
return;
|
|
462
446
|
}
|
|
463
|
-
|
|
447
|
+
o.i?.previewTextFile(t, e);
|
|
464
448
|
});
|
|
465
|
-
},
|
|
466
|
-
|
|
467
|
-
var s;
|
|
449
|
+
}, wt = () => (t, e) => {
|
|
450
|
+
g.use(["meta-player-ui"], ([o]) => {
|
|
468
451
|
if (o.version === 0) {
|
|
469
452
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
470
453
|
return;
|
|
471
454
|
}
|
|
472
|
-
|
|
455
|
+
o.i?.previewImageFile(t, e);
|
|
473
456
|
});
|
|
474
457
|
};
|
|
475
458
|
let v = 0, J = 0;
|
|
476
|
-
const
|
|
459
|
+
const ht = (t, e) => {
|
|
477
460
|
const o = b(t, e), s = n((i) => i.setSidebarActions);
|
|
478
|
-
|
|
461
|
+
l(() => (v++, v > 1 && console.error("Capytale iframe React: Multiple sidebar actions registered: ", v), () => {
|
|
479
462
|
v--;
|
|
480
|
-
}), []),
|
|
481
|
-
var u;
|
|
463
|
+
}), []), l(() => (g.use(["meta-player-ui"], ([i]) => {
|
|
482
464
|
if (i.version === 0) {
|
|
483
465
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
484
466
|
return;
|
|
485
467
|
}
|
|
486
468
|
J++;
|
|
487
|
-
const c = o.map((a,
|
|
469
|
+
const c = o.map((a, r) => ({
|
|
488
470
|
type: a.type,
|
|
489
471
|
title: a.title,
|
|
490
472
|
icon: a.icon,
|
|
491
|
-
id: `sa-${J}-${
|
|
473
|
+
id: `sa-${J}-${r}`,
|
|
492
474
|
...a.type === "file-upload" ? { accept: a.accept } : {}
|
|
493
|
-
})),
|
|
494
|
-
o.forEach((a,
|
|
495
|
-
|
|
496
|
-
}),
|
|
475
|
+
})), u = {};
|
|
476
|
+
o.forEach((a, r) => {
|
|
477
|
+
u[`sa-${J}-${r}`] = a.action;
|
|
478
|
+
}), i.i?.setSidebarActionButtons(c), s(u);
|
|
497
479
|
}), () => {
|
|
498
|
-
s({}),
|
|
499
|
-
var c;
|
|
480
|
+
s({}), g.use(["meta-player-ui"], ([i]) => {
|
|
500
481
|
if (i.version === 0) {
|
|
501
482
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
502
483
|
return;
|
|
503
484
|
}
|
|
504
|
-
|
|
485
|
+
i.i?.setSidebarActionButtons([]);
|
|
505
486
|
});
|
|
506
487
|
}), [o]);
|
|
507
488
|
};
|
|
508
489
|
let y = 0, F = 0;
|
|
509
|
-
const
|
|
490
|
+
const kt = (t, e) => {
|
|
510
491
|
const o = b(t, e), s = n((i) => i.setQuickActions);
|
|
511
|
-
|
|
492
|
+
l(() => (y++, y > 1 && console.error("Capytale iframe React: Multiple quick actions registered: ", y), () => {
|
|
512
493
|
y--;
|
|
513
|
-
}), []),
|
|
514
|
-
var u;
|
|
494
|
+
}), []), l(() => (g.use(["meta-player-ui"], ([i]) => {
|
|
515
495
|
if (i.version === 0) {
|
|
516
496
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
517
497
|
return;
|
|
518
498
|
}
|
|
519
499
|
F++;
|
|
520
|
-
const c = o.map((a,
|
|
500
|
+
const c = o.map((a, r) => ({
|
|
521
501
|
type: a.type,
|
|
522
502
|
title: a.title,
|
|
523
503
|
icon: a.icon,
|
|
524
|
-
id: `qa-${F}-${
|
|
504
|
+
id: `qa-${F}-${r}`,
|
|
525
505
|
...a.type === "file-upload" ? { accept: a.accept } : {}
|
|
526
|
-
})),
|
|
527
|
-
o.forEach((a,
|
|
528
|
-
|
|
529
|
-
}),
|
|
506
|
+
})), u = {};
|
|
507
|
+
o.forEach((a, r) => {
|
|
508
|
+
u[`qa-${F}-${r}`] = a.action;
|
|
509
|
+
}), i.i?.setQuickActionButtons(c), s(u);
|
|
530
510
|
}), () => {
|
|
531
|
-
s({}),
|
|
532
|
-
var c;
|
|
511
|
+
s({}), g.use(["meta-player-ui"], ([i]) => {
|
|
533
512
|
if (i.version === 0) {
|
|
534
513
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
535
514
|
return;
|
|
536
515
|
}
|
|
537
|
-
|
|
516
|
+
i.i?.setQuickActionButtons([]);
|
|
538
517
|
});
|
|
539
518
|
}), [o]);
|
|
540
519
|
};
|
|
541
|
-
let
|
|
542
|
-
const
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
}), []),
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
return
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
s(null);
|
|
558
|
-
};
|
|
559
|
-
}, [o]), i;
|
|
560
|
-
}, Jt = () => (e) => {
|
|
561
|
-
C.use(["meta-player-ui"], ([o]) => {
|
|
562
|
-
var s;
|
|
520
|
+
let f = 0;
|
|
521
|
+
const O = (t, e, o) => {
|
|
522
|
+
const s = b(t, o), i = n((c) => c.setActivitySettingsCallback);
|
|
523
|
+
l(() => (console.log("Mounting useSettings"), f++, f > 1 && console.error("Capytale iframe React: Multiple settings registered: ", f), () => {
|
|
524
|
+
f--;
|
|
525
|
+
}), []), l(() => (g.use(["meta-player-ui"], ([c]) => {
|
|
526
|
+
if (c.version === 0) {
|
|
527
|
+
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
console.log("Updating settings UI in MetaPlayer", s), c.i?.setSettingsUI(s);
|
|
531
|
+
}), i(e), () => {
|
|
532
|
+
i(null);
|
|
533
|
+
}), [s]);
|
|
534
|
+
}, xt = () => (e) => {
|
|
535
|
+
g.use(["meta-player-ui"], ([o]) => {
|
|
563
536
|
if (o.version === 0) {
|
|
564
537
|
console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
565
538
|
return;
|
|
566
539
|
}
|
|
567
|
-
|
|
540
|
+
o.i?.showToast(e);
|
|
568
541
|
});
|
|
569
542
|
};
|
|
543
|
+
function V(t) {
|
|
544
|
+
const e = {};
|
|
545
|
+
for (const o of t.fields)
|
|
546
|
+
e[o.name] = o.defaultValue;
|
|
547
|
+
return e;
|
|
548
|
+
}
|
|
549
|
+
function W(t) {
|
|
550
|
+
return { [t.name]: t.defaultValues };
|
|
551
|
+
}
|
|
552
|
+
function Q(t) {
|
|
553
|
+
return { [t.name]: t.defaultValue };
|
|
554
|
+
}
|
|
555
|
+
function H(t) {
|
|
556
|
+
switch (t.type) {
|
|
557
|
+
case "form":
|
|
558
|
+
return V(t);
|
|
559
|
+
case "checkboxes":
|
|
560
|
+
case "switches":
|
|
561
|
+
return W(t);
|
|
562
|
+
case "radio":
|
|
563
|
+
return Q(t);
|
|
564
|
+
default:
|
|
565
|
+
return {};
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function N(t) {
|
|
569
|
+
const e = {};
|
|
570
|
+
for (const o of t)
|
|
571
|
+
Object.assign(e, H(o));
|
|
572
|
+
return e;
|
|
573
|
+
}
|
|
574
|
+
function Tt(t) {
|
|
575
|
+
const o = D()((s) => ({
|
|
576
|
+
...N(t)
|
|
577
|
+
}));
|
|
578
|
+
return o.activitySettings = t, o;
|
|
579
|
+
}
|
|
580
|
+
function U(t) {
|
|
581
|
+
O(
|
|
582
|
+
() => t.activitySettings,
|
|
583
|
+
(e) => {
|
|
584
|
+
t.setState(e);
|
|
585
|
+
},
|
|
586
|
+
[]
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
function _({
|
|
590
|
+
store: t
|
|
591
|
+
}) {
|
|
592
|
+
return U(t), null;
|
|
593
|
+
}
|
|
594
|
+
const z = [
|
|
595
|
+
"meta-player-events:1",
|
|
596
|
+
"mode:1",
|
|
597
|
+
"workflow:1"
|
|
598
|
+
];
|
|
599
|
+
function Dt({
|
|
600
|
+
children: t,
|
|
601
|
+
contracts: e,
|
|
602
|
+
loadOnlyWhenReady: o = !0,
|
|
603
|
+
activitySettingsStore: s
|
|
604
|
+
}) {
|
|
605
|
+
const i = n((c) => c.ready);
|
|
606
|
+
return l(() => {
|
|
607
|
+
const c = [...e];
|
|
608
|
+
for (const u of z)
|
|
609
|
+
c.includes(u) || c.push(u);
|
|
610
|
+
R(c);
|
|
611
|
+
}, []), o && !i ? /* @__PURE__ */ w("div", { className: "capy-loading-container", children: "Chargement en cours..." }) : /* @__PURE__ */ G(j, { children: [
|
|
612
|
+
s && /* @__PURE__ */ w(_, { store: s }),
|
|
613
|
+
t
|
|
614
|
+
] });
|
|
615
|
+
}
|
|
570
616
|
export {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
617
|
+
Dt as Capytale,
|
|
618
|
+
Tt as createActivitySettingsStore,
|
|
619
|
+
Ft as useAfterSaveAction,
|
|
620
|
+
gt as useGetLoadedJsonActivityContent,
|
|
621
|
+
St as useGetLoadedJsonActivitySplitContent,
|
|
622
|
+
Ct as useGetLoadedJsonAssignmentContent,
|
|
623
|
+
pt as useGetLoadedJsonAssignmentSplitContent,
|
|
624
|
+
dt as useGetLoadedJsonContent,
|
|
625
|
+
ut as useGetLoadedTextContent,
|
|
626
|
+
yt as useJsonActivityContentSaveFunction,
|
|
627
|
+
At as useJsonActivitySplitContentSaveFunction,
|
|
628
|
+
ft as useJsonAssignmentContentSaveFunction,
|
|
629
|
+
Jt as useJsonAssignmentSplitContentSaveFunction,
|
|
630
|
+
vt as useJsonContentSaveFunction,
|
|
631
|
+
rt as useLoadedJsonActivityBinaryData,
|
|
632
|
+
at as useLoadedJsonActivityContent,
|
|
633
|
+
lt as useLoadedJsonAssignmentBinaryData,
|
|
634
|
+
ct as useLoadedJsonAssignmentContent,
|
|
635
|
+
it as useLoadedJsonContent,
|
|
636
|
+
st as useLoadedTextContent,
|
|
637
|
+
Z as useMode,
|
|
638
|
+
ot as useNotifyIsDirty,
|
|
639
|
+
wt as usePreviewImageFile,
|
|
640
|
+
bt as usePreviewTextFile,
|
|
641
|
+
kt as useQuickActions,
|
|
642
|
+
nt as useRequestSave,
|
|
643
|
+
O as useSettings,
|
|
644
|
+
xt as useShowToast,
|
|
645
|
+
ht as useSidebarActions,
|
|
646
|
+
mt as useTextContentSaveFunction,
|
|
647
|
+
et as useTheme,
|
|
648
|
+
tt as useWorkflow
|
|
602
649
|
};
|
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.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": "^
|
|
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.4",
|
|
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.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": "^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
|
+
}
|