@capytale/iframe-react 1.1.12 → 1.1.14
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/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.es.js +256 -233
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),v=require("react");const X=Symbol("Comlink.proxy"),gt=Symbol("Comlink.endpoint"),pt=Symbol("Comlink.releaseProxy"),N=Symbol("Comlink.finalizer"),G=Symbol("Comlink.thrown"),Z=t=>typeof t=="object"&&t!==null||typeof t=="function",mt={canHandle:t=>Z(t)&&t[X],serialize(t){const{port1:e,port2:n}=new MessageChannel;return z(t,e),[n,[n]]},deserialize(t){return t.start(),nt(t)}},yt={canHandle:t=>Z(t)&&G in t,serialize({value:t}){let e;return t instanceof Error?e={isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:e={isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}},tt=new Map([["proxy",mt],["throw",yt]]);function Ct(t,e){for(const n of t)if(e===n||n==="*"||n instanceof RegExp&&n.test(e))return!0;return!1}function z(t,e=globalThis,n=["*"]){e.addEventListener("message",function s(o){if(!o||!o.data)return;if(!Ct(n,o.origin)){console.warn(`Invalid origin '${o.origin}' for comlink proxy`);return}const{id:r,type:g,path:c}=Object.assign({path:[]},o.data),f=(o.data.argumentList||[]).map(k);let d;try{const u=c.slice(0,-1).reduce((y,S)=>y[S],t),p=c.reduce((y,S)=>y[S],t);switch(g){case"GET":d=p;break;case"SET":u[c.slice(-1)[0]]=k(o.data.value),d=!0;break;case"APPLY":d=p.apply(u,f);break;case"CONSTRUCT":{const y=new p(...f);d=st(y)}break;case"ENDPOINT":{const{port1:y,port2:S}=new MessageChannel;z(t,S),d=ht(y,[y])}break;case"RELEASE":d=void 0;break;default:return}}catch(u){d={value:u,[G]:0}}Promise.resolve(d).catch(u=>({value:u,[G]:0})).then(u=>{const[p,y]=$(u);e.postMessage(Object.assign(Object.assign({},p),{id:r}),y),g==="RELEASE"&&(e.removeEventListener("message",s),et(e),N in t&&typeof t[N]=="function"&&t[N]())}).catch(u=>{const[p,y]=$({value:new TypeError("Unserializable return value"),[G]:0});e.postMessage(Object.assign(Object.assign({},p),{id:r}),y)})}),e.start&&e.start()}function vt(t){return t.constructor.name==="MessagePort"}function et(t){vt(t)&&t.close()}function nt(t,e){const n=new Map;return t.addEventListener("message",function(o){const{data:r}=o;if(!r||!r.id)return;const g=n.get(r.id);if(g)try{g(r)}finally{n.delete(r.id)}}),H(t,n,[],e)}function P(t){if(t)throw new Error("Proxy has been released and is not useable")}function ot(t){return x(t,new Map,{type:"RELEASE"}).then(()=>{et(t)})}const I=new WeakMap,j="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(I.get(t)||0)-1;I.set(t,e),e===0&&ot(t)});function St(t,e){const n=(I.get(e)||0)+1;I.set(e,n),j&&j.register(t,e,t)}function wt(t){j&&j.unregister(t)}function H(t,e,n=[],s=function(){}){let o=!1;const r=new Proxy(s,{get(g,c){if(P(o),c===pt)return()=>{wt(r),ot(t),e.clear(),o=!0};if(c==="then"){if(n.length===0)return{then:()=>r};const f=x(t,e,{type:"GET",path:n.map(d=>d.toString())}).then(k);return f.then.bind(f)}return H(t,e,[...n,c])},set(g,c,f){P(o);const[d,u]=$(f);return x(t,e,{type:"SET",path:[...n,c].map(p=>p.toString()),value:d},u).then(k)},apply(g,c,f){P(o);const d=n[n.length-1];if(d===gt)return x(t,e,{type:"ENDPOINT"}).then(k);if(d==="bind")return H(t,e,n.slice(0,-1));const[u,p]=U(f);return x(t,e,{type:"APPLY",path:n.map(y=>y.toString()),argumentList:u},p).then(k)},construct(g,c){P(o);const[f,d]=U(c);return x(t,e,{type:"CONSTRUCT",path:n.map(u=>u.toString()),argumentList:f},d).then(k)}});return St(r,t),r}function At(t){return Array.prototype.concat.apply([],t)}function U(t){const e=t.map($);return[e.map(n=>n[0]),At(e.map(n=>n[1]))]}const rt=new WeakMap;function ht(t,e){return rt.set(t,e),t}function st(t){return Object.assign(t,{[X]:!0})}function bt(t,e=globalThis,n="*"){return{postMessage:(s,o)=>t.postMessage(s,n,o),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function $(t){for(const[e,n]of tt)if(n.canHandle(t)){const[s,o]=n.serialize(t);return[{type:"HANDLER",name:e,value:s},o]}return[{type:"RAW",value:t},rt.get(t)||[]]}function k(t){switch(t.type){case"HANDLER":return tt.get(t.name).deserialize(t.value);case"RAW":return t.value}}function x(t,e,n,s){return new Promise(o=>{const r=Et();e.set(r,o),t.start&&t.start(),t.postMessage(Object.assign({id:r},n),s)})}function Et(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}function Jt(t,e){return t.length===0?e:`[${t}] ${e}`}function kt(t,e){let n=!1,s,o,r;function g(u){return Jt(t,u)}let c,f=!1;if(window.parent===window)console.warn(g("Contract link is not supported in standalone mode")),c={ready(){return Promise.resolve()},declare(){return Promise.resolve()},done(){return Promise.resolve()},provide(u,p,y){return Promise.resolve()}};else{const u=bt(window.parent,void 0,e);z({declare(p){if(s==null)throw new Error(g("No handler for declare"));s(p)},done(){if(o==null)throw new Error(g("No handler for done"));o()},provide(p,y,S){if(r==null)throw new Error(g("No handler for provide"));r(p,y,S)}},u),c=nt(u),f=!0}const d=()=>{if(!n){if(s==null||o==null||r==null)return;n=!0,c.ready()}};return{declare:u=>c.declare(u),done:()=>c.done(),provide:(u,p,y)=>c.provide(u,p,st(y)),get name(){return t},get isReady(){return f},set onDeclare(u){s=u,d()},set onDone(u){o=u,d()},set onProvide(u){r=u,d()}}}function Ft(t){return function(e){let n,s=!1,o=!1,r,g,c=!1,f=!1,d,u,p,y;function S(){if(r!=null&&r!==0&&g!=null)return g}function E(a){if(r!=null&&g!=null&&!(a>r))return g}function h(){return p??(f?p=Promise.resolve():p=new Promise((a,l)=>{y=a}))}function F(){return d===void 0&&(d={get name(){return e},get version(){return r},get i(){return S()},v:a=>E(a)}),d}function R(){return u===void 0&&(u={get name(){return e},get version(){return f?r:void 0},get i(){return f?S():void 0},v:a=>f?E(a):void 0,get promise(){return r===0?Promise.reject(t("Remote interface not provided")):h().then(()=>{if(r===0)throw new Error(t("Remote interface not provided"));return F()})}}),u}function J(){y!=null&&(y(),y=void 0)}return{get name(){return e},get localVersion(){if(n!=null)return n},set localVersion(a){if(n!=null&&n!==a)throw new Error(t("A different local version is already set"));n=a},get localVersionSent(){return s},set localVersionSent(a){if(!a&&s)throw new Error(t("Local version already notified"));s=a,a&&n===0&&(o=!0)},get localInterfaceSent(){return o},set localInterfaceSent(a){if(n==null)throw new Error(t("Local version not set"));if(!a&&o)throw new Error(t("Local interface already sent."));o=a},get remoteVersion(){if(r!=null)return r},set remoteVersion(a){if(r!=null&&r!==a)throw new Error(t("A different remote version is already set for "+e+`(${r} -> ${a})`));r=a,a===0&&(c=!0)},get remoteVersionReceived(){return r!=null},setRemoteInterface:a=>{if(r==null)throw new Error(t("Remote version not set"));if(r===0){console.warn(t("Remote version is 0, remote interface is ignored."));return}if(c)throw new Error(t("Interface already provided."));g=a,c=!0},get remoteInterfaceReceived(){return c},depGroup:void 0,get isActivable(){return c&&o},get isActivated(){return f},activate(){if(!f){if(!c)throw new Error(t("Remote interface not provided."));if(!o)throw new Error(t("Local interface not sent"));f=!0,J()}},getRemote:()=>F(),getLazyRemote:()=>R(),get activationPromise(){return h()}}}}function Tt(t){return function(e,n,s,o){let r=s,g=!1,c=!1;function f(){return e.every(d=>d.remoteVersionReceived&&d.localVersionSent)&&n.every(d=>d.remoteVersionReceived)}return{get isDeclared(){return c},set isDeclared(d){if(!d&&c)throw new Error(t("Factory already declared"));c=d},get isReady(){return f()},get isDone(){return g},get args(){return e},get deps(){return n},invoke(){if(g)throw new Error(t("Factory already invoked"));if(!f())throw new Error(t("Factory is not ready"));let d;o?d=e.map(y=>y.getRemote()):d=e[0].getRemote();let u;const p=n.length>0?n.map(y=>y.getRemote()):null;try{u=p==null?r(d):r(d,p)}catch(y){throw new Error(t("error in factory:"),{cause:y})}if(o||(u=[u]),u.length!=e.length)throw new Error(t("Invalid factory result"));return g=!0,r=null,u}}}}function xt(t){return function(e,n,s,o){let r=n,g=!1;function c(){return e.every(f=>f.isActivated)}return{get isReady(){return c()},get isDone(){return g},get args(){return e},invoke(){if(g||!c()){const u=new Error(t(g?"callback already invoked":"callback parameters are not ready"));throw o?.[1](u),u}const f=s?e.map(u=>u.getRemote()):e[0].getRemote();let d;try{d=r(f)}catch(u){o==null?console.error(t("error in callback:"),u):o[1](u)}finally{g=!0}o?.[0](d)}}}}function at(t,e){return t==null||t.length===0?e:`[${t}] ${e}`}function Rt(t){function e(a){return at(t.name,a)}const n=xt(e),s=Ft(e),o=Tt(e),r={},g=[];let c=[],f;const d=()=>(f==null?f=0:f++,f);function u(a){let l=r[a];return l==null&&(l=s(a),l.localVersion==null&&(h&&(l.localVersion=0),F&&(l.localVersionSent=!0)),l.remoteVersion==null&&R&&(l.remoteVersion=0),r[a]=l),l}function p(a){return a.map(u)}function y(...a){const l=d(),m=Array(l).fill(!1);a.forEach(C=>{C.forEach(w=>{w.depGroup!=null&&(m[w.depGroup]=!0),w.depGroup=l})}),Object.values(r).forEach(C=>{C.depGroup!=null&&C.depGroup!==l&&m[C.depGroup]&&(C.depGroup=l)})}t.onDeclare=a=>{const l=p(a.map(m=>m.name));for(let m=0;m<a.length;m++)a[m].version!=null&&(l[m].remoteVersion=a[m].version);y(l),J()},t.onDone=()=>{R||(R=!0,Object.values(r).forEach(a=>{a.remoteVersion==null&&(a.remoteVersion=0)}),J())},t.onProvide=(a,l,m)=>{let C=r[a];if(C==null)throw new Error(e(`Contract not declared : ${a}`));if(C.remoteVersion!=l)throw new Error(e(`Remote declared version ${C.remoteVersion} of contract "${a}" but provided version ${l}.`));if(C.remoteInterfaceReceived)throw new Error(e(`Remote contract "${a}" is already provided.`));C.setRemoteInterface(m),J()};let S=!1,E=!1,h=!1,F=!1,R=!1;async function J(){if(E=!0,!S){for(S=!0;E;){if(E=!1,t.isReady){const a=g.filter(l=>!l.isDeclared);if(a.length>0)for(const l of a){const m=Array(l.args.length+l.deps.length);l.args.forEach((C,w)=>m[w]=C),l.deps.forEach((C,w)=>m[w+l.args.length]=C),await t.declare(m.map(C=>({name:C.name,version:C.localVersion}))),m.forEach(C=>{C.localVersion!=null&&(C.localVersionSent=!0)}),l.isDeclared=!0}}if(t.isReady&&h&&g.every(a=>a.isDeclared)){const a=Object.values(r).filter(l=>!l.localVersionSent&&l.localVersion!=null);if(a.length>0)for(const l of a)await t.declare([{name:l.name,version:l.localVersion}]),l.localVersionSent=!0;F||(F=!0,await t.done())}if(t.isReady){const a=g.filter(l=>!l.isDone&&l.isReady);if(a.length>0)for(const l of a){const m=l.invoke();for(let C=0;C<l.args.length;C++){const w=l.args[C];await t.provide(w.name,w.localVersion,m[C]),w.localInterfaceSent=!0}}}if(f!=null){const a=Array(f+1).fill(null);for(const l in r){const m=r[l];m.depGroup!=null&&(m.isActivable?a[m.depGroup]==null&&!m.isActivated&&(a[m.depGroup]=!0):a[m.depGroup]=!1)}if(a.some(l=>l===!0))for(const l in r){const m=r[l];m.depGroup!=null&&a[m.depGroup]&&m.activate()}}if(t.isReady){const a=c;c=[];const l=[];for(const m of a)!m.isDone&&m.isReady?m.invoke():l.push(m);l.push(...c),c=l}}S=!1}}return{get(a){return u(a)},declareFactory:(a,l,m,C)=>{if(h)throw new Error(e("Cannot declare a factory after done has been set to true."));const w=p(a.map(b=>b.name));{const b=w.filter(O=>O.localVersion!=null);if(b.length>0)throw new Error(e("Cannot declare a factory for already implemented contracts : "+b.map(O=>O.name).join(", ")))}for(let b=0;b<a.length;b++)w[b].localVersion=a[b].version;const T=p(l);y(w,T);const ft=o(w,T,m,C);g.push(ft),J()},declareCallback(a,l,m,C){const w=p(a),T=n(w,l,m,C);!S&&c.length===0&&T.isReady?T.invoke():(c.push(T),J())},get done(){return h},set done(a){if(h){if(!a)throw new Error(e("Cannot set done to false after it has been set to true."))}else a&&(h=!0,Object.values(r).forEach(l=>{l.localVersion==null&&(l.localVersion=0)}),J())}}}const Lt=/^\d+$/;function Pt(t){const[e,n,s]=t.split(":",3);if(n==null||s!=null||!Lt.test(n))return null;const o=parseInt(n);return isNaN(o)||o===0?null:{name:e,version:o}}function Mt(t){const e=Rt(t);function n(s){return at(t.name,s)}return{plug(s,o,r=void 0){if(e.done)throw new Error(n("Cannot plug after plugsDone."));r==null&&(r=o,o=[]);let g=!0;Array.isArray(s)||(s=[s],g=!1);const c=s.map(f=>{const d=Pt(f);if(d==null)throw new Error(n("Invalid contract id : "+f));return d});e.declareFactory(c,o,r,g)},plugsDone(){e.done=!0},use(s,o){let r=!0;Array.isArray(s)||(s=[s],r=!1),e.declareCallback(s,o,r)},exec(s,o){let r=!0;return Array.isArray(s)||(s=[s],r=!1),new Promise((...g)=>{e.declareCallback(s,o,r,g)})},get(s){return s.map(o=>e.get(o).getLazyRemote())}}}const it="app-agent";let q;function Vt(t){return q!=null||(q=Mt(kt(it,t))),q}console.log(`[${it}@1.0.12] loaded`);const Q=t=>{let e;const n=new Set,s=(d,u)=>{const p=typeof d=="function"?d(e):d;if(!Object.is(p,e)){const y=e;e=u??(typeof p!="object"||p===null)?p:Object.assign({},e,p),n.forEach(S=>S(e,y))}},o=()=>e,c={setState:s,getState:o,getInitialState:()=>f,subscribe:d=>(n.add(d),()=>n.delete(d))},f=e=t(s,o,c);return c},Dt=t=>t?Q(t):Q,Gt=t=>t;function It(t,e=Gt){const n=v.useSyncExternalStore(t.subscribe,v.useCallback(()=>e(t.getState()),[t,e]),v.useCallback(()=>e(t.getInitialState()),[t,e]));return v.useDebugValue(n),n}const _=t=>{const e=Dt(t),n=s=>It(e,s);return Object.assign(n,e),n},ct=t=>t?_(t):_,jt=t=>(e,n,s)=>{const o=s.subscribe;return s.subscribe=(g,c,f)=>{let d=g;if(c){const u=f?.equalityFn||Object.is;let p=g(s.getState());d=y=>{const S=g(y);if(!u(p,S)){const E=p;c(p=S,E)}},f?.fireImmediately&&c(p,p)}return o(d)},t(e,n,s)},$t=jt,i=ct()($t(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 Y=!1;const Ot=["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=>{i.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){i.setState({theme:null});return}if(t!=="light"&&t!=="dark"){console.warn(`Invalid theme: ${t}. Expected 'light' or 'dark'.`),i.setState({theme:null});return}i.setState({theme:t})}},"workflow:1":{setWorkflow:t=>{i.setState({workflow:t})}},"simple-content(text):1":{contentSaved:()=>{i.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>i.getState().getTextContentFunction(),loadContent:t=>{i.setState({loadedTextContent:t})}},"simple-content(json):1":{contentSaved:()=>{i.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>i.getState().getJsonContentFunction(),loadContent:t=>{i.setState({loadedJsonContent:t})}},"simple-binary-data(text):1":{contentSaved:()=>{i.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>i.getState().getTextContentFunction(),loadContent:t=>{i.setState({loadedTextContent:t})}},"simple-content-eval(text):1":{contentSaved:()=>{i.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>i.getState().getTextContentFunction(),loadContent:t=>{i.setState({loadedTextContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(text)")}},"simple-content-eval(json):1":{contentSaved:()=>{i.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>i.getState().getJsonContentFunction(),loadContent:t=>{i.setState({loadedJsonContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(json)")}},"simple-content-eval(json):2":{contentSaved:()=>{i.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>i.getState().getJsonContentFunction(),loadContent:t=>{i.setState({loadedJsonContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(json)")}},"simple-content-eval(text):2":{contentSaved:()=>{i.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>i.getState().getTextContentFunction(),loadContent:t=>{i.setState({loadedTextContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(text)")}},"separate-contents(json):1":{contentSaved:()=>{i.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},loadContent:(t,e)=>{i.setState({loadedJsonActivityContent:t,loadedJsonAssignmentContent:e})},getActivityContent:()=>i.getState().getJsonActivityContentFunction(),getAssignmentContent:()=>i.getState().getJsonAssignmentContentFunction()},"separate-dual-contents(json):1":{contentSaved:()=>{i.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},loadContent:({activityContent:t,assignmentContent:e,activityBinaryData:n,assignmentBinaryData:s})=>{i.setState({loadedJsonActivityContent:t,loadedJsonAssignmentContent:e,loadedJsonActivityBinaryData:n,loadedJsonAssignmentBinaryData:s})},getActivityContentAndData:()=>i.getState().getJsonActivitySplitContentFunction(),getAssignmentContentAndData:()=>i.getState().getJsonAssignmentSplitContentFunction()},"meta-player-anti-cheat:1":{lock:()=>{},unlock:()=>{}},"meta-player-ui:1":{executeAction(t){if(t.startsWith("qa")){const n=i.getState().quickActions[t];n?n():console.error(`Quick action not found: ${t}`)}else{const n=i.getState().sidebarActions[t];n?n():console.error(`Sidebar action not found: ${t}`)}},executeFileUpload(t,e){if(t.startsWith("qa")){const s=i.getState().quickActions[t];s?s(e):console.error(`Quick action not found: ${t}`)}else{const s=i.getState().sidebarActions[t];s?s(e):console.error(`Sidebar action not found: ${t}`)}},updateSettings(t){const e=i.getState().activitySettingsCallback;e?e(t):console.warn("activitySettingsCallback is not set. Changes:",t)}},"meta-player-events:1":{handleEvent(t){t==="all-loaded"&&i.setState({ready:!0})}}},A=Vt();function Nt(t){if(Y){console.warn("Contracts have already been plugged. Skipping.");return}Y=!0;for(const e of t){if(!Ot.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 n=K[e];A.plug([e],([])=>[n])}A.plugsDone();for(const e of["simple-content(text):1","simple-content(json):1","simple-binary-data(text):1","simple-content-eval(text):1","simple-content-eval(json):1","simple-content-eval(json):2","simple-content-eval(text):2"])if(console.log(`Contract ${e} is being subscribed to content changes.`),t.includes(e)){console.log(`Subscribing to content changes for contract ${e}`);const n=e.split(":")[0];A.use([n],([s])=>{i.subscribe(o=>o.isDirtyCount,()=>{s.i?.contentChanged(),console.log(`Content changed for contract ${n}`)})})}}const qt=()=>i(t=>{if(t.mode===null)throw new Error("Mode is not set. Have you used contract 'mode'?");return t.mode}),Bt=()=>i(t=>{if(t.workflow===null)throw new Error("Workflow is not set. Have you used contract 'workflow'?");return t.workflow}),Wt=()=>i(t=>{if(t.theme===null)throw new Error("Theme is not set. Have you used contract 'theme'?");return t.theme}),Ht=()=>i(t=>t.incSaveCount),zt=()=>i(t=>t.incDirtyCount),Ut=()=>i(t=>t.loadedTextContent),Qt=()=>i(t=>t.loadedJsonContent),_t=()=>i(t=>t.loadedJsonActivityContent),Yt=()=>i(t=>t.loadedJsonAssignmentContent),Kt=()=>i(t=>t.loadedJsonActivityBinaryData),Xt=()=>i(t=>t.loadedJsonAssignmentBinaryData),Zt=()=>v.useCallback(()=>i.getState().loadedTextContent,[]),te=()=>v.useCallback(()=>i.getState().loadedJsonContent,[]),ee=()=>v.useCallback(()=>i.getState().loadedJsonActivityContent,[]),ne=()=>v.useCallback(()=>i.getState().loadedJsonAssignmentContent,[]),oe=()=>v.useCallback(()=>({content:i.getState().loadedJsonActivityContent,binaryData:i.getState().loadedJsonActivityBinaryData}),[]),re=()=>v.useCallback(()=>({content:i.getState().loadedJsonAssignmentContent,binaryData:i.getState().loadedJsonAssignmentBinaryData}),[]),se=t=>{const e=i(n=>n.setGetTextContentFunction);v.useEffect(()=>{e(t)},[t,e])},ae=t=>{const e=i(n=>n.setGetJsonContentFunction);v.useEffect(()=>{e(t)},[t,e])},ie=t=>{const e=i(n=>n.setGetJsonActivityContentFunction);v.useEffect(()=>{e(t)},[t,e])},ce=t=>{const e=i(n=>n.setGetJsonAssignmentContentFunction);v.useEffect(()=>{e(t)},[t,e])},le=t=>{const e=i(n=>n.setGetJsonActivitySplitContentFunction);v.useEffect(()=>{e(t)},[t,e])},ue=t=>{const e=i(n=>n.setGetJsonAssignmentSplitContentFunction);v.useEffect(()=>{e(t)},[t,e])},de=t=>{const e=i(n=>n.afterSaveCount);v.useEffect(()=>{e>0&&t()},[e])},fe=()=>(t,e)=>{A.use(["meta-player-ui"],([n])=>{if(n.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}n.i?.previewTextFile(t,e)})},ge=()=>(t,e)=>{A.use(["meta-player-ui"],([n])=>{if(n.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}n.i?.previewImageFile(t,e)})};let M=0,B=0;const pe=(t,e)=>{const n=v.useMemo(t,e),s=i(o=>o.setSidebarActions);v.useEffect(()=>(M++,M>1&&console.error("Capytale iframe React: Multiple sidebar actions registered: ",M),()=>{M--}),[]),v.useEffect(()=>(A.use(["meta-player-ui"],([o])=>{if(o.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}B++;const r=n.map((c,f)=>({type:c.type,title:c.title,icon:c.icon,id:`sa-${B}-${f}`,...c.type==="file-upload"?{accept:c.accept}:{}})),g={};n.forEach((c,f)=>{g[`sa-${B}-${f}`]=c.action}),o.i?.setSidebarActionButtons(r),s(g)}),()=>{s({}),A.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?.setSidebarActionButtons([])})}),[n])};let V=0,W=0;const me=(t,e)=>{const n=v.useMemo(t,e),s=i(o=>o.setQuickActions);v.useEffect(()=>(V++,V>1&&console.error("Capytale iframe React: Multiple quick actions registered: ",V),()=>{V--}),[]),v.useEffect(()=>(A.use(["meta-player-ui"],([o])=>{if(o.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}W++;const r=n.map((c,f)=>({type:c.type,title:c.title,icon:c.icon,id:`qa-${W}-${f}`,...c.type==="file-upload"?{accept:c.accept}:{}})),g={};n.forEach((c,f)=>{g[`qa-${W}-${f}`]=c.action}),o.i?.setQuickActionButtons(r),s(g)}),()=>{s({}),A.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?.setQuickActionButtons([])})}),[n])};let D=0;const lt=(t,e,n)=>{const s=v.useMemo(t,n),o=i(r=>r.setActivitySettingsCallback);v.useEffect(()=>(console.log("Mounting useSettings"),D++,D>1&&console.error("Capytale iframe React: Multiple settings registered: ",D),()=>{console.log("Unmounting useSettings"),D--}),[]),v.useEffect(()=>(A.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)}),o(e),()=>{o(null)}),[s])},ut=()=>v.useCallback(e=>A.exec(["meta-player-ui"],([n])=>{if(n.version===0)throw console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui"),new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return n.i?.showToast(e)}),[]),dt=()=>v.useCallback(e=>A.exec(["meta-player-ui"],([n])=>{if(n.version===0)throw console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui"),new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return n.i?.clearToast(e)}),[]),ye=()=>v.useCallback(()=>A.exec(["meta-player-ui"],([e])=>{if(e.version===0)throw console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui"),new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return e.i?.clearToasts()}),[]);function Ce(t){const e={};for(const n of t.fields)e[n.name]=n.defaultValue;return e}function ve(t){return{[t.name]:t.defaultValues}}function Se(t){return{[t.name]:t.defaultValue}}function we(t){switch(t.type){case"form":return Ce(t);case"checkboxes":case"switches":return ve(t);case"radio":return Se(t);default:return{}}}function Ae(t){const e={};for(const n of t)Object.assign(e,we(n));return e}function he(t){const n=ct()(s=>({...Ae(t)}));return n.activitySettings=t,n}function be(t){lt(()=>t.activitySettings,e=>{t.setState(e)},[])}function Ee({store:t}){return be(t),null}const Je=["meta-player-events:1","mode:1","workflow:1"];function ke({children:t,contracts:e,loadOnlyWhenReady:n=!0,activitySettingsStore:s}){const o=i(r=>r.ready);return v.useEffect(()=>{const r=[...e];for(const g of Je)r.includes(g)||r.push(g);Nt(r)},[]),n&&!o?L.jsx("div",{className:"capy-loading-container",children:"Chargement en cours..."}):L.jsxs(L.Fragment,{children:[s&&L.jsx(Ee,{store:s}),t]})}function Fe({message:t}){const e=ut(),n=dt();return v.useEffect(()=>{const s=e(t);return()=>{s.then(o=>{o!=null&&n(o)})}},[t,e,n]),null}exports.Capytale=ke;exports.TemporaryToast=Fe;exports.createActivitySettingsStore=he;exports.useAfterSaveAction=de;exports.useClearToast=dt;exports.useClearToasts=ye;exports.useGetLoadedJsonActivityContent=ee;exports.useGetLoadedJsonActivitySplitContent=oe;exports.useGetLoadedJsonAssignmentContent=ne;exports.useGetLoadedJsonAssignmentSplitContent=re;exports.useGetLoadedJsonContent=te;exports.useGetLoadedTextContent=Zt;exports.useJsonActivityContentSaveFunction=ie;exports.useJsonActivitySplitContentSaveFunction=le;exports.useJsonAssignmentContentSaveFunction=ce;exports.useJsonAssignmentSplitContentSaveFunction=ue;exports.useJsonContentSaveFunction=ae;exports.useLoadedJsonActivityBinaryData=Kt;exports.useLoadedJsonActivityContent=_t;exports.useLoadedJsonAssignmentBinaryData=Xt;exports.useLoadedJsonAssignmentContent=Yt;exports.useLoadedJsonContent=Qt;exports.useLoadedTextContent=Ut;exports.useMode=qt;exports.useNotifyIsDirty=zt;exports.usePreviewImageFile=ge;exports.usePreviewTextFile=fe;exports.useQuickActions=me;exports.useRequestSave=Ht;exports.useSettings=lt;exports.useShowToast=ut;exports.useSidebarActions=pe;exports.useTextContentSaveFunction=se;exports.useTheme=Wt;exports.useWorkflow=Bt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),v=require("react");const X=Symbol("Comlink.proxy"),pe=Symbol("Comlink.endpoint"),me=Symbol("Comlink.releaseProxy"),N=Symbol("Comlink.finalizer"),D=Symbol("Comlink.thrown"),Z=e=>typeof e=="object"&&e!==null||typeof e=="function",ye={canHandle:e=>Z(e)&&e[X],serialize(e){const{port1:t,port2:n}=new MessageChannel;return z(e,t),[n,[n]]},deserialize(e){return e.start(),ne(e)}},ve={canHandle:e=>Z(e)&&D in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},ee=new Map([["proxy",ye],["throw",ve]]);function Ce(e,t){for(const n of e)if(t===n||n==="*"||n instanceof RegExp&&n.test(t))return!0;return!1}function z(e,t=globalThis,n=["*"]){t.addEventListener("message",function s(o){if(!o||!o.data)return;if(!Ce(n,o.origin)){console.warn(`Invalid origin '${o.origin}' for comlink proxy`);return}const{id:r,type:g,path:c}=Object.assign({path:[]},o.data),f=(o.data.argumentList||[]).map(k);let d;try{const u=c.slice(0,-1).reduce((y,S)=>y[S],e),p=c.reduce((y,S)=>y[S],e);switch(g){case"GET":d=p;break;case"SET":u[c.slice(-1)[0]]=k(o.data.value),d=!0;break;case"APPLY":d=p.apply(u,f);break;case"CONSTRUCT":{const y=new p(...f);d=se(y)}break;case"ENDPOINT":{const{port1:y,port2:S}=new MessageChannel;z(e,S),d=be(y,[y])}break;case"RELEASE":d=void 0;break;default:return}}catch(u){d={value:u,[D]:0}}Promise.resolve(d).catch(u=>({value:u,[D]:0})).then(u=>{const[p,y]=$(u);t.postMessage(Object.assign(Object.assign({},p),{id:r}),y),g==="RELEASE"&&(t.removeEventListener("message",s),te(t),N in e&&typeof e[N]=="function"&&e[N]())}).catch(u=>{const[p,y]=$({value:new TypeError("Unserializable return value"),[D]:0});t.postMessage(Object.assign(Object.assign({},p),{id:r}),y)})}),t.start&&t.start()}function Se(e){return e.constructor.name==="MessagePort"}function te(e){Se(e)&&e.close()}function ne(e,t){const n=new Map;return e.addEventListener("message",function(o){const{data:r}=o;if(!r||!r.id)return;const g=n.get(r.id);if(g)try{g(r)}finally{n.delete(r.id)}}),H(e,n,[],t)}function P(e){if(e)throw new Error("Proxy has been released and is not useable")}function oe(e){return x(e,new Map,{type:"RELEASE"}).then(()=>{te(e)})}const I=new WeakMap,j="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(I.get(e)||0)-1;I.set(e,t),t===0&&oe(e)});function we(e,t){const n=(I.get(t)||0)+1;I.set(t,n),j&&j.register(e,t,e)}function Ae(e){j&&j.unregister(e)}function H(e,t,n=[],s=function(){}){let o=!1;const r=new Proxy(s,{get(g,c){if(P(o),c===me)return()=>{Ae(r),oe(e),t.clear(),o=!0};if(c==="then"){if(n.length===0)return{then:()=>r};const f=x(e,t,{type:"GET",path:n.map(d=>d.toString())}).then(k);return f.then.bind(f)}return H(e,t,[...n,c])},set(g,c,f){P(o);const[d,u]=$(f);return x(e,t,{type:"SET",path:[...n,c].map(p=>p.toString()),value:d},u).then(k)},apply(g,c,f){P(o);const d=n[n.length-1];if(d===pe)return x(e,t,{type:"ENDPOINT"}).then(k);if(d==="bind")return H(e,t,n.slice(0,-1));const[u,p]=U(f);return x(e,t,{type:"APPLY",path:n.map(y=>y.toString()),argumentList:u},p).then(k)},construct(g,c){P(o);const[f,d]=U(c);return x(e,t,{type:"CONSTRUCT",path:n.map(u=>u.toString()),argumentList:f},d).then(k)}});return we(r,e),r}function he(e){return Array.prototype.concat.apply([],e)}function U(e){const t=e.map($);return[t.map(n=>n[0]),he(t.map(n=>n[1]))]}const re=new WeakMap;function be(e,t){return re.set(e,t),e}function se(e){return Object.assign(e,{[X]:!0})}function Ee(e,t=globalThis,n="*"){return{postMessage:(s,o)=>e.postMessage(s,n,o),addEventListener:t.addEventListener.bind(t),removeEventListener:t.removeEventListener.bind(t)}}function $(e){for(const[t,n]of ee)if(n.canHandle(e)){const[s,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:s},o]}return[{type:"RAW",value:e},re.get(e)||[]]}function k(e){switch(e.type){case"HANDLER":return ee.get(e.name).deserialize(e.value);case"RAW":return e.value}}function x(e,t,n,s){return new Promise(o=>{const r=Je();t.set(r,o),e.start&&e.start(),e.postMessage(Object.assign({id:r},n),s)})}function Je(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}function ke(e,t){return e.length===0?t:`[${e}] ${t}`}function Fe(e,t){let n=!1,s,o,r;function g(u){return ke(e,u)}let c,f=!1;if(window.parent===window)console.warn(g("Contract link is not supported in standalone mode")),c={ready(){return Promise.resolve()},declare(){return Promise.resolve()},done(){return Promise.resolve()},provide(u,p,y){return Promise.resolve()}};else{const u=Ee(window.parent,void 0,t);z({declare(p){if(s==null)throw new Error(g("No handler for declare"));s(p)},done(){if(o==null)throw new Error(g("No handler for done"));o()},provide(p,y,S){if(r==null)throw new Error(g("No handler for provide"));r(p,y,S)}},u),c=ne(u),f=!0}const d=()=>{if(!n){if(s==null||o==null||r==null)return;n=!0,c.ready()}};return{declare:u=>c.declare(u),done:()=>c.done(),provide:(u,p,y)=>c.provide(u,p,se(y)),get name(){return e},get isReady(){return f},set onDeclare(u){s=u,d()},set onDone(u){o=u,d()},set onProvide(u){r=u,d()}}}function Te(e){return function(t){let n,s=!1,o=!1,r,g,c=!1,f=!1,d,u,p,y;function S(){if(r!=null&&r!==0&&g!=null)return g}function E(a){if(r!=null&&g!=null&&!(a>r))return g}function h(){return p??(f?p=Promise.resolve():p=new Promise((a,l)=>{y=a}))}function F(){return d===void 0&&(d={get name(){return t},get version(){return r},get i(){return S()},v:a=>E(a)}),d}function R(){return u===void 0&&(u={get name(){return t},get version(){return f?r:void 0},get i(){return f?S():void 0},v:a=>f?E(a):void 0,get promise(){return r===0?Promise.reject(e("Remote interface not provided")):h().then(()=>{if(r===0)throw new Error(e("Remote interface not provided"));return F()})}}),u}function J(){y!=null&&(y(),y=void 0)}return{get name(){return t},get localVersion(){if(n!=null)return n},set localVersion(a){if(n!=null&&n!==a)throw new Error(e("A different local version is already set"));n=a},get localVersionSent(){return s},set localVersionSent(a){if(!a&&s)throw new Error(e("Local version already notified"));s=a,a&&n===0&&(o=!0)},get localInterfaceSent(){return o},set localInterfaceSent(a){if(n==null)throw new Error(e("Local version not set"));if(!a&&o)throw new Error(e("Local interface already sent."));o=a},get remoteVersion(){if(r!=null)return r},set remoteVersion(a){if(r!=null&&r!==a)throw new Error(e("A different remote version is already set for "+t+`(${r} -> ${a})`));r=a,a===0&&(c=!0)},get remoteVersionReceived(){return r!=null},setRemoteInterface:a=>{if(r==null)throw new Error(e("Remote version not set"));if(r===0){console.warn(e("Remote version is 0, remote interface is ignored."));return}if(c)throw new Error(e("Interface already provided."));g=a,c=!0},get remoteInterfaceReceived(){return c},depGroup:void 0,get isActivable(){return c&&o},get isActivated(){return f},activate(){if(!f){if(!c)throw new Error(e("Remote interface not provided."));if(!o)throw new Error(e("Local interface not sent"));f=!0,J()}},getRemote:()=>F(),getLazyRemote:()=>R(),get activationPromise(){return h()}}}}function xe(e){return function(t,n,s,o){let r=s,g=!1,c=!1;function f(){return t.every(d=>d.remoteVersionReceived&&d.localVersionSent)&&n.every(d=>d.remoteVersionReceived)}return{get isDeclared(){return c},set isDeclared(d){if(!d&&c)throw new Error(e("Factory already declared"));c=d},get isReady(){return f()},get isDone(){return g},get args(){return t},get deps(){return n},invoke(){if(g)throw new Error(e("Factory already invoked"));if(!f())throw new Error(e("Factory is not ready"));let d;o?d=t.map(y=>y.getRemote()):d=t[0].getRemote();let u;const p=n.length>0?n.map(y=>y.getRemote()):null;try{u=p==null?r(d):r(d,p)}catch(y){throw new Error(e("error in factory:"),{cause:y})}if(o||(u=[u]),u.length!=t.length)throw new Error(e("Invalid factory result"));return g=!0,r=null,u}}}}function Re(e){return function(t,n,s,o){let r=n,g=!1;function c(){return t.every(f=>f.isActivated)}return{get isReady(){return c()},get isDone(){return g},get args(){return t},invoke(){if(g||!c()){const u=new Error(e(g?"callback already invoked":"callback parameters are not ready"));throw o?.[1](u),u}const f=s?t.map(u=>u.getRemote()):t[0].getRemote();let d;try{d=r(f)}catch(u){o==null?console.error(e("error in callback:"),u):o[1](u)}finally{g=!0}o?.[0](d)}}}}function ae(e,t){return e==null||e.length===0?t:`[${e}] ${t}`}function Le(e){function t(a){return ae(e.name,a)}const n=Re(t),s=Te(t),o=xe(t),r={},g=[];let c=[],f;const d=()=>(f==null?f=0:f++,f);function u(a){let l=r[a];return l==null&&(l=s(a),l.localVersion==null&&(h&&(l.localVersion=0),F&&(l.localVersionSent=!0)),l.remoteVersion==null&&R&&(l.remoteVersion=0),r[a]=l),l}function p(a){return a.map(u)}function y(...a){const l=d(),m=Array(l).fill(!1);a.forEach(C=>{C.forEach(w=>{w.depGroup!=null&&(m[w.depGroup]=!0),w.depGroup=l})}),Object.values(r).forEach(C=>{C.depGroup!=null&&C.depGroup!==l&&m[C.depGroup]&&(C.depGroup=l)})}e.onDeclare=a=>{const l=p(a.map(m=>m.name));for(let m=0;m<a.length;m++)a[m].version!=null&&(l[m].remoteVersion=a[m].version);y(l),J()},e.onDone=()=>{R||(R=!0,Object.values(r).forEach(a=>{a.remoteVersion==null&&(a.remoteVersion=0)}),J())},e.onProvide=(a,l,m)=>{let C=r[a];if(C==null)throw new Error(t(`Contract not declared : ${a}`));if(C.remoteVersion!=l)throw new Error(t(`Remote declared version ${C.remoteVersion} of contract "${a}" but provided version ${l}.`));if(C.remoteInterfaceReceived)throw new Error(t(`Remote contract "${a}" is already provided.`));C.setRemoteInterface(m),J()};let S=!1,E=!1,h=!1,F=!1,R=!1;async function J(){if(E=!0,!S){for(S=!0;E;){if(E=!1,e.isReady){const a=g.filter(l=>!l.isDeclared);if(a.length>0)for(const l of a){const m=Array(l.args.length+l.deps.length);l.args.forEach((C,w)=>m[w]=C),l.deps.forEach((C,w)=>m[w+l.args.length]=C),await e.declare(m.map(C=>({name:C.name,version:C.localVersion}))),m.forEach(C=>{C.localVersion!=null&&(C.localVersionSent=!0)}),l.isDeclared=!0}}if(e.isReady&&h&&g.every(a=>a.isDeclared)){const a=Object.values(r).filter(l=>!l.localVersionSent&&l.localVersion!=null);if(a.length>0)for(const l of a)await e.declare([{name:l.name,version:l.localVersion}]),l.localVersionSent=!0;F||(F=!0,await e.done())}if(e.isReady){const a=g.filter(l=>!l.isDone&&l.isReady);if(a.length>0)for(const l of a){const m=l.invoke();for(let C=0;C<l.args.length;C++){const w=l.args[C];await e.provide(w.name,w.localVersion,m[C]),w.localInterfaceSent=!0}}}if(f!=null){const a=Array(f+1).fill(null);for(const l in r){const m=r[l];m.depGroup!=null&&(m.isActivable?a[m.depGroup]==null&&!m.isActivated&&(a[m.depGroup]=!0):a[m.depGroup]=!1)}if(a.some(l=>l===!0))for(const l in r){const m=r[l];m.depGroup!=null&&a[m.depGroup]&&m.activate()}}if(e.isReady){const a=c;c=[];const l=[];for(const m of a)!m.isDone&&m.isReady?m.invoke():l.push(m);l.push(...c),c=l}}S=!1}}return{get(a){return u(a)},declareFactory:(a,l,m,C)=>{if(h)throw new Error(t("Cannot declare a factory after done has been set to true."));const w=p(a.map(b=>b.name));{const b=w.filter(O=>O.localVersion!=null);if(b.length>0)throw new Error(t("Cannot declare a factory for already implemented contracts : "+b.map(O=>O.name).join(", ")))}for(let b=0;b<a.length;b++)w[b].localVersion=a[b].version;const T=p(l);y(w,T);const ge=o(w,T,m,C);g.push(ge),J()},declareCallback(a,l,m,C){const w=p(a),T=n(w,l,m,C);!S&&c.length===0&&T.isReady?T.invoke():(c.push(T),J())},get done(){return h},set done(a){if(h){if(!a)throw new Error(t("Cannot set done to false after it has been set to true."))}else a&&(h=!0,Object.values(r).forEach(l=>{l.localVersion==null&&(l.localVersion=0)}),J())}}}const Pe=/^\d+$/;function Me(e){const[t,n,s]=e.split(":",3);if(n==null||s!=null||!Pe.test(n))return null;const o=parseInt(n);return isNaN(o)||o===0?null:{name:t,version:o}}function Ve(e){const t=Le(e);function n(s){return ae(e.name,s)}return{plug(s,o,r=void 0){if(t.done)throw new Error(n("Cannot plug after plugsDone."));r==null&&(r=o,o=[]);let g=!0;Array.isArray(s)||(s=[s],g=!1);const c=s.map(f=>{const d=Me(f);if(d==null)throw new Error(n("Invalid contract id : "+f));return d});t.declareFactory(c,o,r,g)},plugsDone(){t.done=!0},use(s,o){let r=!0;Array.isArray(s)||(s=[s],r=!1),t.declareCallback(s,o,r)},exec(s,o){let r=!0;return Array.isArray(s)||(s=[s],r=!1),new Promise((...g)=>{t.declareCallback(s,o,r,g)})},get(s){return s.map(o=>t.get(o).getLazyRemote())}}}const ie="app-agent";let q;function Ge(e){return q!=null||(q=Ve(Fe(ie,e))),q}console.log(`[${ie}@1.0.12] loaded`);const Q=e=>{let t;const n=new Set,s=(d,u)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const y=t;t=u??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(S=>S(t,y))}},o=()=>t,c={setState:s,getState:o,getInitialState:()=>f,subscribe:d=>(n.add(d),()=>n.delete(d))},f=t=e(s,o,c);return c},De=e=>e?Q(e):Q,Ie=e=>e;function je(e,t=Ie){const n=v.useSyncExternalStore(e.subscribe,v.useCallback(()=>t(e.getState()),[e,t]),v.useCallback(()=>t(e.getInitialState()),[e,t]));return v.useDebugValue(n),n}const _=e=>{const t=De(e),n=s=>je(t,s);return Object.assign(n,t),n},ce=e=>e?_(e):_,$e=e=>(t,n,s)=>{const o=s.subscribe;return s.subscribe=(g,c,f)=>{let d=g;if(c){const u=f?.equalityFn||Object.is;let p=g(s.getState());d=y=>{const S=g(y);if(!u(p,S)){const E=p;c(p=S,E)}},f?.fireImmediately&&c(p,p)}return o(d)},e(t,n,s)},Oe=$e,i=ce()(Oe(e=>({ready:!1,workflow:"current",mode:"assignment",theme:"light",saveCount:0,canSave:!1,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:t=>{e({getTextContentFunction:t})},setGetJsonContentFunction:t=>{e({getJsonContentFunction:t})},setGetJsonActivityContentFunction:t=>{e({getJsonActivityContentFunction:t})},setGetJsonAssignmentContentFunction:t=>{e({getJsonAssignmentContentFunction:t})},setGetJsonActivitySplitContentFunction:t=>{e({getJsonActivitySplitContentFunction:t})},setGetJsonAssignmentSplitContentFunction:t=>{e({getJsonAssignmentSplitContentFunction:t})},setSidebarActions:t=>{e({sidebarActions:t})},setQuickActions:t=>{e({quickActions:t})},setActivitySettingsCallback:t=>{e({activitySettingsCallback:t})},incSaveCount:()=>e(t=>({saveCount:t.saveCount+1})),incDirtyCount:()=>e(t=>({isDirtyCount:t.isDirtyCount+1}))})));let Y=!1;const Ne=["meta-player-events:1","meta-player-ui:1","mode:1","reload:1","theme:1","workflow:1","trigger-save: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:e=>{i.setState({mode:e})}},"reload:1":{reloaded:e=>{console.log("Reloaded with state:",e),console.error("Not implemented yet")}},"theme:1":{setTheme:e=>{if(e===null){i.setState({theme:null});return}if(e!=="light"&&e!=="dark"){console.warn(`Invalid theme: ${e}. Expected 'light' or 'dark'.`),i.setState({theme:null});return}i.setState({theme:e})}},"workflow:1":{setWorkflow:e=>{i.setState({workflow:e})}},"trigger-save:1":{setCanSave(e){i.setState({canSave:e})}},"simple-content(text):1":{contentSaved:()=>{i.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},getContent:()=>i.getState().getTextContentFunction(),loadContent:e=>{i.setState({loadedTextContent:e})}},"simple-content(json):1":{contentSaved:()=>{i.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},getContent:()=>i.getState().getJsonContentFunction(),loadContent:e=>{i.setState({loadedJsonContent:e})}},"simple-binary-data(text):1":{contentSaved:()=>{i.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},getContent:()=>i.getState().getTextContentFunction(),loadContent:e=>{i.setState({loadedTextContent:e})}},"simple-content-eval(text):1":{contentSaved:()=>{i.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},getContent:()=>i.getState().getTextContentFunction(),loadContent:e=>{i.setState({loadedTextContent:e})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(text)")}},"simple-content-eval(json):1":{contentSaved:()=>{i.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},getContent:()=>i.getState().getJsonContentFunction(),loadContent:e=>{i.setState({loadedJsonContent:e})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(json)")}},"simple-content-eval(json):2":{contentSaved:()=>{i.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},getContent:()=>i.getState().getJsonContentFunction(),loadContent:e=>{i.setState({loadedJsonContent:e})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(json)")}},"simple-content-eval(text):2":{contentSaved:()=>{i.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},getContent:()=>i.getState().getTextContentFunction(),loadContent:e=>{i.setState({loadedTextContent:e})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(text)")}},"separate-contents(json):1":{contentSaved:()=>{i.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},loadContent:(e,t)=>{i.setState({loadedJsonActivityContent:e,loadedJsonAssignmentContent:t})},getActivityContent:()=>i.getState().getJsonActivityContentFunction(),getAssignmentContent:()=>i.getState().getJsonAssignmentContentFunction()},"separate-dual-contents(json):1":{contentSaved:()=>{i.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},loadContent:({activityContent:e,assignmentContent:t,activityBinaryData:n,assignmentBinaryData:s})=>{i.setState({loadedJsonActivityContent:e,loadedJsonAssignmentContent:t,loadedJsonActivityBinaryData:n,loadedJsonAssignmentBinaryData:s})},getActivityContentAndData:()=>(console.log("Getting activity content and data"),i.getState().getJsonActivitySplitContentFunction()),getAssignmentContentAndData:()=>(console.log("Getting assignment content and data"),i.getState().getJsonAssignmentSplitContentFunction())},"meta-player-anti-cheat:1":{lock:()=>{},unlock:()=>{}},"meta-player-ui:1":{executeAction(e){if(console.log("Executing action:",e),e.startsWith("qa")){const n=i.getState().quickActions[e];n?n():console.error(`Quick action not found: ${e}`)}else{const n=i.getState().sidebarActions[e];n?n():console.error(`Sidebar action not found: ${e}`)}},executeFileUpload(e,t){if(e.startsWith("qa")){const s=i.getState().quickActions[e];s?s(t):console.error(`Quick action not found: ${e}`)}else{const s=i.getState().sidebarActions[e];s?s(t):console.error(`Sidebar action not found: ${e}`)}},updateSettings(e){const t=i.getState().activitySettingsCallback;t?t(e):console.warn("activitySettingsCallback is not set. Changes:",e)}},"meta-player-events:1":{handleEvent(e){e==="all-loaded"&&i.setState({ready:!0})}}},A=Ge();function qe(e){if(console.log("Contracts to plug:",e),Y){console.warn("Contracts have already been plugged. Skipping.");return}Y=!0;for(const t of e){if(!Ne.includes(t)){console.warn(`Contract ${t} is not implemented in Capytale. Skipping plug.`);continue}if(!(t in K)){console.warn(`Contract handler for ${t} is not defined. Skipping plug.`);continue}const n=K[t];A.plug([t],([])=>(console.log(`Contract ${t} plugged.`),[n]))}A.plugsDone();for(const t 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","separate-contents(json):1","separate-dual-contents(json):1"])if(console.log(`Contract ${t} is being subscribed to content changes.`),e.includes(t)){console.log(`Subscribing to content changes for contract ${t}`);const n=t.split(":")[0];A.use([n],([s])=>{i.subscribe(o=>o.isDirtyCount,()=>{s.i?.contentChanged(),console.log(`Content changed for contract ${n}`)})})}}const Be=()=>i(e=>{if(e.mode===null)throw new Error("Mode is not set. Have you used contract 'mode'?");return e.mode}),We=()=>i(e=>{if(e.workflow===null)throw new Error("Workflow is not set. Have you used contract 'workflow'?");return e.workflow}),He=()=>i(e=>{if(e.theme===null)throw new Error("Theme is not set. Have you used contract 'theme'?");return e.theme}),ze=()=>i(e=>e.incSaveCount),Ue=()=>i(e=>e.incDirtyCount),Qe=()=>i(e=>e.loadedTextContent),_e=()=>i(e=>e.loadedJsonContent),Ye=()=>i(e=>e.loadedJsonActivityContent),Ke=()=>i(e=>e.loadedJsonAssignmentContent),Xe=()=>i(e=>e.loadedJsonActivityBinaryData),Ze=()=>i(e=>e.loadedJsonAssignmentBinaryData),et=()=>v.useCallback(()=>i.getState().loadedTextContent,[]),tt=()=>v.useCallback(()=>i.getState().loadedJsonContent,[]),nt=()=>v.useCallback(()=>i.getState().loadedJsonActivityContent,[]),ot=()=>v.useCallback(()=>i.getState().loadedJsonAssignmentContent,[]),rt=()=>v.useCallback(()=>({content:i.getState().loadedJsonActivityContent,binaryData:i.getState().loadedJsonActivityBinaryData}),[]),st=()=>v.useCallback(()=>({content:i.getState().loadedJsonAssignmentContent,binaryData:i.getState().loadedJsonAssignmentBinaryData}),[]),at=e=>{const t=i(n=>n.setGetTextContentFunction);v.useEffect(()=>{t(e)},[e,t])},it=e=>{const t=i(n=>n.setGetJsonContentFunction);v.useEffect(()=>{t(e)},[e,t])},ct=e=>{const t=i(n=>n.setGetJsonActivityContentFunction);v.useEffect(()=>{t(e)},[e,t])},lt=e=>{const t=i(n=>n.setGetJsonAssignmentContentFunction);v.useEffect(()=>{t(e)},[e,t])},ut=e=>{const t=i(n=>n.setGetJsonActivitySplitContentFunction);v.useEffect(()=>{t(e)},[e,t])},dt=e=>{const t=i(n=>n.setGetJsonAssignmentSplitContentFunction);v.useEffect(()=>{t(e)},[e,t])},ft=e=>{const t=i(n=>n.afterSaveCount);v.useEffect(()=>{t>0&&e()},[t])},gt=()=>(e,t)=>{A.use(["meta-player-ui"],([n])=>{if(n.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}n.i?.previewTextFile(e,t)})},pt=()=>(e,t)=>{A.use(["meta-player-ui"],([n])=>{if(n.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}n.i?.previewImageFile(e,t)})};let M=0,B=0;const mt=(e,t)=>{const n=v.useMemo(e,t),s=i(o=>o.setSidebarActions);v.useEffect(()=>(M++,M>1&&console.error("Capytale iframe React: Multiple sidebar actions registered: ",M),()=>{M--}),[]),v.useEffect(()=>(A.use(["meta-player-ui"],([o])=>{if(o.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}B++;const r=n.map((c,f)=>({type:c.type,title:c.title,icon:c.icon,id:`sa-${B}-${f}`,...c.type==="file-upload"?{accept:c.accept}:{}})),g={};n.forEach((c,f)=>{g[`sa-${B}-${f}`]=c.action}),o.i?.setSidebarActionButtons(r),s(g)}),()=>{s({}),A.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?.setSidebarActionButtons([])})}),[n])};let V=0,W=0;const yt=(e,t)=>{const n=v.useMemo(e,t),s=i(o=>o.setQuickActions);v.useEffect(()=>(V++,V>1&&console.error("Capytale iframe React: Multiple quick actions registered: ",V),()=>{V--}),[]),v.useEffect(()=>(A.use(["meta-player-ui"],([o])=>{if(o.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}W++;const r=n.map((c,f)=>({type:c.type,title:c.title,icon:c.icon,id:`qa-${W}-${f}`,...c.type==="file-upload"?{accept:c.accept}:{}})),g={};n.forEach((c,f)=>{g[`qa-${W}-${f}`]=c.action}),o.i?.setQuickActionButtons(r),s(g)}),()=>{s({}),A.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?.setQuickActionButtons([])})}),[n])};let G=0;const le=(e,t,n)=>{const s=v.useMemo(e,n),o=i(r=>r.setActivitySettingsCallback);v.useEffect(()=>(console.log("Mounting useSettings"),G++,G>1&&console.error("Capytale iframe React: Multiple settings registered: ",G),()=>{console.log("Unmounting useSettings"),G--}),[]),v.useEffect(()=>(A.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)}),o(t),()=>{o(null)}),[s])},ue=()=>v.useCallback(t=>A.exec(["meta-player-ui"],([n])=>{if(n.version===0)throw console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui"),new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return n.i?.showToast(t)}),[]),de=()=>v.useCallback(t=>A.exec(["meta-player-ui"],([n])=>{if(n.version===0)throw console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui"),new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return n.i?.clearToast(t)}),[]),vt=()=>v.useCallback(()=>A.exec(["meta-player-ui"],([t])=>{if(t.version===0)throw console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui"),new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return t.i?.clearToasts()}),[]),fe=(e,t)=>{const n=ue(),s=de();return v.useEffect(()=>{if(e==null)return;const o=n(e);return()=>{o.then(r=>{r!=null&&s(r)})}},[n,s,...t]),null},Ct=()=>v.useCallback(()=>A.exec(["trigger-save"],([t])=>{if(t.version===0)throw console.error("Le MétaPlayer ne supporte pas le contrat trigger-save"),new Error("Le MétaPlayer ne supporte pas le contrat trigger-save");return t.i?.triggerSave()}),[]),St=()=>i(e=>e.canSave);function wt(e){const t={};for(const n of e.fields)t[n.name]=n.defaultValue;return t}function At(e){return{[e.name]:e.defaultValues}}function ht(e){return{[e.name]:e.defaultValue}}function bt(e){switch(e.type){case"form":return wt(e);case"checkboxes":case"switches":return At(e);case"radio":return ht(e);default:return{}}}function Et(e){const t={};for(const n of e)Object.assign(t,bt(n));return t}function Jt(e){const n=ce()(s=>({...Et(e)}));return n.activitySettings=e,n}function kt(e){le(()=>e.activitySettings,t=>{e.setState(t)},[])}function Ft({store:e}){return kt(e),null}const Tt=["meta-player-events:1","meta-player-ui:1","mode:1","workflow:1"];function xt({children:e,contracts:t,loadOnlyWhenReady:n=!0,activitySettingsStore:s}){const o=i(r=>r.ready);return v.useEffect(()=>{const r=[...t];for(const g of Tt)r.includes(g)||r.push(g);qe(r)},[]),n&&!o?L.jsx("div",{className:"capy-loading-container",children:"Chargement en cours..."}):L.jsxs(L.Fragment,{children:[s&&L.jsx(Ft,{store:s}),e]})}function Rt({message:e}){return fe(e,[e]),null}exports.Capytale=xt;exports.TemporaryToast=Rt;exports.createActivitySettingsStore=Jt;exports.useAfterSaveAction=ft;exports.useCanSave=St;exports.useClearToast=de;exports.useClearToasts=vt;exports.useGetLoadedJsonActivityContent=nt;exports.useGetLoadedJsonActivitySplitContent=rt;exports.useGetLoadedJsonAssignmentContent=ot;exports.useGetLoadedJsonAssignmentSplitContent=st;exports.useGetLoadedJsonContent=tt;exports.useGetLoadedTextContent=et;exports.useJsonActivityContentSaveFunction=ct;exports.useJsonActivitySplitContentSaveFunction=ut;exports.useJsonAssignmentContentSaveFunction=lt;exports.useJsonAssignmentSplitContentSaveFunction=dt;exports.useJsonContentSaveFunction=it;exports.useLoadedJsonActivityBinaryData=Xe;exports.useLoadedJsonActivityContent=Ye;exports.useLoadedJsonAssignmentBinaryData=Ze;exports.useLoadedJsonAssignmentContent=Ke;exports.useLoadedJsonContent=_e;exports.useLoadedTextContent=Qe;exports.useMode=Be;exports.useNotifyIsDirty=Ue;exports.usePreviewImageFile=pt;exports.usePreviewTextFile=gt;exports.useQuickActions=yt;exports.useRequestSave=ze;exports.useSettings=le;exports.useShowToast=ue;exports.useSidebarActions=mt;exports.useTextContentSaveFunction=at;exports.useTheme=He;exports.useToast=fe;exports.useTriggerSave=Ct;exports.useWorkflow=We;
|
package/dist/index.d.ts
CHANGED
|
@@ -149,7 +149,7 @@ AddIdData<MetaPlayerAntiCheatV1, {
|
|
|
149
149
|
}>
|
|
150
150
|
]>;
|
|
151
151
|
|
|
152
|
-
declare type ForcedContactNames = "meta-player-events:1" | "mode:1" | "workflow:1";
|
|
152
|
+
declare type ForcedContactNames = "meta-player-events:1" | "mode:1" | "workflow:1" | "meta-player-ui:1";
|
|
153
153
|
|
|
154
154
|
declare type FormField = (ActivitySettingsRange | ActivitySettingsInput | ActivitySettingsNumberInput | ActivitySettingsTextArea | ActivitySettingsOption | ActivitySettingsSelect) & {
|
|
155
155
|
label: string;
|
|
@@ -274,6 +274,8 @@ declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) e
|
|
|
274
274
|
|
|
275
275
|
export declare const useAfterSaveAction: (fn: () => any) => void;
|
|
276
276
|
|
|
277
|
+
export declare const useCanSave: () => boolean;
|
|
278
|
+
|
|
277
279
|
export declare const useClearToast: () => (id: Awaited<ReturnType<ReturnType<typeof useShowToast>>>) => Promise<void>;
|
|
278
280
|
|
|
279
281
|
export declare const useClearToasts: () => () => Promise<void>;
|
|
@@ -340,6 +342,10 @@ export declare const useTextContentSaveFunction: (fn: () => string | null | Prom
|
|
|
340
342
|
|
|
341
343
|
export declare const useTheme: () => "light" | "dark";
|
|
342
344
|
|
|
345
|
+
export declare const useToast: (message: MPToastMessage | null, deps: readonly unknown[]) => null;
|
|
346
|
+
|
|
347
|
+
export declare const useTriggerSave: () => () => Promise<boolean>;
|
|
348
|
+
|
|
343
349
|
export declare const useWorkflow: () => "current" | "finished" | "corrected";
|
|
344
350
|
|
|
345
351
|
export { }
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as Q, jsxs as gt, Fragment as pt } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import V, { useCallback as A, useEffect as w, useMemo as U } from "react";
|
|
3
3
|
const et = Symbol("Comlink.proxy"), mt = Symbol("Comlink.endpoint"), yt = Symbol("Comlink.releaseProxy"), q = Symbol("Comlink.finalizer"), I = Symbol("Comlink.thrown"), nt = (t) => typeof t == "object" && t !== null || typeof t == "function", vt = {
|
|
4
4
|
canHandle: (t) => nt(t) && t[et],
|
|
5
5
|
serialize(t) {
|
|
@@ -115,7 +115,7 @@ function M(t) {
|
|
|
115
115
|
if (t)
|
|
116
116
|
throw new Error("Proxy has been released and is not useable");
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function at(t) {
|
|
119
119
|
return R(t, /* @__PURE__ */ new Map(), {
|
|
120
120
|
type: "RELEASE"
|
|
121
121
|
}).then(() => {
|
|
@@ -124,7 +124,7 @@ function it(t) {
|
|
|
124
124
|
}
|
|
125
125
|
const j = /* @__PURE__ */ new WeakMap(), $ = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
|
|
126
126
|
const e = (j.get(t) || 0) - 1;
|
|
127
|
-
j.set(t, e), e === 0 &&
|
|
127
|
+
j.set(t, e), e === 0 && at(t);
|
|
128
128
|
});
|
|
129
129
|
function ht(t, e) {
|
|
130
130
|
const n = (j.get(e) || 0) + 1;
|
|
@@ -140,7 +140,7 @@ function z(t, e, n = [], s = function() {
|
|
|
140
140
|
get(g, c) {
|
|
141
141
|
if (M(o), c === yt)
|
|
142
142
|
return () => {
|
|
143
|
-
At(r),
|
|
143
|
+
At(r), at(t), e.clear(), o = !0;
|
|
144
144
|
};
|
|
145
145
|
if (c === "then") {
|
|
146
146
|
if (n.length === 0)
|
|
@@ -197,9 +197,9 @@ function Y(t) {
|
|
|
197
197
|
const e = t.map(O);
|
|
198
198
|
return [e.map((n) => n[0]), bt(e.map((n) => n[1]))];
|
|
199
199
|
}
|
|
200
|
-
const
|
|
200
|
+
const it = /* @__PURE__ */ new WeakMap();
|
|
201
201
|
function Et(t, e) {
|
|
202
|
-
return
|
|
202
|
+
return it.set(t, e), t;
|
|
203
203
|
}
|
|
204
204
|
function ct(t) {
|
|
205
205
|
return Object.assign(t, { [et]: !0 });
|
|
@@ -229,7 +229,7 @@ function O(t) {
|
|
|
229
229
|
type: "RAW",
|
|
230
230
|
value: t
|
|
231
231
|
},
|
|
232
|
-
|
|
232
|
+
it.get(t) || []
|
|
233
233
|
];
|
|
234
234
|
}
|
|
235
235
|
function F(t) {
|
|
@@ -324,13 +324,13 @@ function Tt(t) {
|
|
|
324
324
|
if (r != null && r !== 0 && g != null)
|
|
325
325
|
return g;
|
|
326
326
|
}
|
|
327
|
-
function k(
|
|
328
|
-
if (r != null && g != null && !(
|
|
327
|
+
function k(a) {
|
|
328
|
+
if (r != null && g != null && !(a > r))
|
|
329
329
|
return g;
|
|
330
330
|
}
|
|
331
|
-
function
|
|
332
|
-
return p ?? (f ? p = Promise.resolve() : p = new Promise((
|
|
333
|
-
y =
|
|
331
|
+
function b() {
|
|
332
|
+
return p ?? (f ? p = Promise.resolve() : p = new Promise((a, l) => {
|
|
333
|
+
y = a;
|
|
334
334
|
}));
|
|
335
335
|
}
|
|
336
336
|
function x() {
|
|
@@ -344,10 +344,10 @@ function Tt(t) {
|
|
|
344
344
|
get i() {
|
|
345
345
|
return C();
|
|
346
346
|
},
|
|
347
|
-
v: (
|
|
347
|
+
v: (a) => k(a)
|
|
348
348
|
}), d;
|
|
349
349
|
}
|
|
350
|
-
function
|
|
350
|
+
function P() {
|
|
351
351
|
return u === void 0 && (u = {
|
|
352
352
|
get name() {
|
|
353
353
|
return e;
|
|
@@ -358,9 +358,9 @@ function Tt(t) {
|
|
|
358
358
|
get i() {
|
|
359
359
|
return f ? C() : void 0;
|
|
360
360
|
},
|
|
361
|
-
v: (
|
|
361
|
+
v: (a) => f ? k(a) : void 0,
|
|
362
362
|
get promise() {
|
|
363
|
-
return r === 0 ? Promise.reject(t("Remote interface not provided")) :
|
|
363
|
+
return r === 0 ? Promise.reject(t("Remote interface not provided")) : b().then(() => {
|
|
364
364
|
if (r === 0) throw new Error(t("Remote interface not provided"));
|
|
365
365
|
return x();
|
|
366
366
|
});
|
|
@@ -378,44 +378,44 @@ function Tt(t) {
|
|
|
378
378
|
if (n != null)
|
|
379
379
|
return n;
|
|
380
380
|
},
|
|
381
|
-
set localVersion(
|
|
382
|
-
if (n != null && n !==
|
|
383
|
-
n =
|
|
381
|
+
set localVersion(a) {
|
|
382
|
+
if (n != null && n !== a) throw new Error(t("A different local version is already set"));
|
|
383
|
+
n = a;
|
|
384
384
|
},
|
|
385
385
|
get localVersionSent() {
|
|
386
386
|
return s;
|
|
387
387
|
},
|
|
388
|
-
set localVersionSent(
|
|
389
|
-
if (!
|
|
390
|
-
s =
|
|
388
|
+
set localVersionSent(a) {
|
|
389
|
+
if (!a && s) throw new Error(t("Local version already notified"));
|
|
390
|
+
s = a, a && n === 0 && (o = !0);
|
|
391
391
|
},
|
|
392
392
|
get localInterfaceSent() {
|
|
393
393
|
return o;
|
|
394
394
|
},
|
|
395
|
-
set localInterfaceSent(
|
|
395
|
+
set localInterfaceSent(a) {
|
|
396
396
|
if (n == null) throw new Error(t("Local version not set"));
|
|
397
|
-
if (!
|
|
398
|
-
o =
|
|
397
|
+
if (!a && o) throw new Error(t("Local interface already sent."));
|
|
398
|
+
o = a;
|
|
399
399
|
},
|
|
400
400
|
get remoteVersion() {
|
|
401
401
|
if (r != null)
|
|
402
402
|
return r;
|
|
403
403
|
},
|
|
404
|
-
set remoteVersion(
|
|
405
|
-
if (r != null && r !==
|
|
406
|
-
r =
|
|
404
|
+
set remoteVersion(a) {
|
|
405
|
+
if (r != null && r !== a) throw new Error(t("A different remote version is already set for " + e + `(${r} -> ${a})`));
|
|
406
|
+
r = a, a === 0 && (c = !0);
|
|
407
407
|
},
|
|
408
408
|
get remoteVersionReceived() {
|
|
409
409
|
return r != null;
|
|
410
410
|
},
|
|
411
|
-
setRemoteInterface: (
|
|
411
|
+
setRemoteInterface: (a) => {
|
|
412
412
|
if (r == null) throw new Error(t("Remote version not set"));
|
|
413
413
|
if (r === 0) {
|
|
414
414
|
console.warn(t("Remote version is 0, remote interface is ignored."));
|
|
415
415
|
return;
|
|
416
416
|
}
|
|
417
417
|
if (c) throw new Error(t("Interface already provided."));
|
|
418
|
-
g =
|
|
418
|
+
g = a, c = !0;
|
|
419
419
|
},
|
|
420
420
|
get remoteInterfaceReceived() {
|
|
421
421
|
return c;
|
|
@@ -435,9 +435,9 @@ function Tt(t) {
|
|
|
435
435
|
}
|
|
436
436
|
},
|
|
437
437
|
getRemote: () => x(),
|
|
438
|
-
getLazyRemote: () =>
|
|
438
|
+
getLazyRemote: () => P(),
|
|
439
439
|
get activationPromise() {
|
|
440
|
-
return
|
|
440
|
+
return b();
|
|
441
441
|
}
|
|
442
442
|
};
|
|
443
443
|
};
|
|
@@ -490,7 +490,7 @@ function Rt(t) {
|
|
|
490
490
|
};
|
|
491
491
|
};
|
|
492
492
|
}
|
|
493
|
-
function
|
|
493
|
+
function Pt(t) {
|
|
494
494
|
return function(e, n, s, o) {
|
|
495
495
|
let r = n, g = !1;
|
|
496
496
|
function c() {
|
|
@@ -528,23 +528,23 @@ function Vt(t) {
|
|
|
528
528
|
function lt(t, e) {
|
|
529
529
|
return t == null || t.length === 0 ? e : `[${t}] ${e}`;
|
|
530
530
|
}
|
|
531
|
-
function
|
|
532
|
-
function e(
|
|
533
|
-
return lt(t.name,
|
|
531
|
+
function Vt(t) {
|
|
532
|
+
function e(a) {
|
|
533
|
+
return lt(t.name, a);
|
|
534
534
|
}
|
|
535
|
-
const n =
|
|
535
|
+
const n = Pt(e), s = Tt(e), o = Rt(e), r = {}, g = [];
|
|
536
536
|
let c = [], f;
|
|
537
537
|
const d = () => (f == null ? f = 0 : f++, f);
|
|
538
|
-
function u(
|
|
539
|
-
let l = r[
|
|
540
|
-
return l == null && (l = s(
|
|
538
|
+
function u(a) {
|
|
539
|
+
let l = r[a];
|
|
540
|
+
return l == null && (l = s(a), l.localVersion == null && (b && (l.localVersion = 0), x && (l.localVersionSent = !0)), l.remoteVersion == null && P && (l.remoteVersion = 0), r[a] = l), l;
|
|
541
541
|
}
|
|
542
|
-
function p(
|
|
543
|
-
return
|
|
542
|
+
function p(a) {
|
|
543
|
+
return a.map(u);
|
|
544
544
|
}
|
|
545
|
-
function y(...
|
|
545
|
+
function y(...a) {
|
|
546
546
|
const l = d(), m = Array(l).fill(!1);
|
|
547
|
-
|
|
547
|
+
a.forEach((v) => {
|
|
548
548
|
v.forEach((S) => {
|
|
549
549
|
S.depGroup != null && (m[S.depGroup] = !0), S.depGroup = l;
|
|
550
550
|
});
|
|
@@ -552,50 +552,50 @@ function Pt(t) {
|
|
|
552
552
|
v.depGroup != null && v.depGroup !== l && m[v.depGroup] && (v.depGroup = l);
|
|
553
553
|
});
|
|
554
554
|
}
|
|
555
|
-
t.onDeclare = (
|
|
556
|
-
const l = p(
|
|
557
|
-
for (let m = 0; m <
|
|
558
|
-
|
|
555
|
+
t.onDeclare = (a) => {
|
|
556
|
+
const l = p(a.map((m) => m.name));
|
|
557
|
+
for (let m = 0; m < a.length; m++)
|
|
558
|
+
a[m].version != null && (l[m].remoteVersion = a[m].version);
|
|
559
559
|
y(l), J();
|
|
560
560
|
}, t.onDone = () => {
|
|
561
|
-
|
|
562
|
-
|
|
561
|
+
P || (P = !0, Object.values(r).forEach((a) => {
|
|
562
|
+
a.remoteVersion == null && (a.remoteVersion = 0);
|
|
563
563
|
}), J());
|
|
564
|
-
}, t.onProvide = (
|
|
565
|
-
let v = r[
|
|
564
|
+
}, t.onProvide = (a, l, m) => {
|
|
565
|
+
let v = r[a];
|
|
566
566
|
if (v == null)
|
|
567
|
-
throw new Error(e(`Contract not declared : ${
|
|
567
|
+
throw new Error(e(`Contract not declared : ${a}`));
|
|
568
568
|
if (v.remoteVersion != l)
|
|
569
|
-
throw new Error(e(`Remote declared version ${v.remoteVersion} of contract "${
|
|
569
|
+
throw new Error(e(`Remote declared version ${v.remoteVersion} of contract "${a}" but provided version ${l}.`));
|
|
570
570
|
if (v.remoteInterfaceReceived)
|
|
571
|
-
throw new Error(e(`Remote contract "${
|
|
571
|
+
throw new Error(e(`Remote contract "${a}" is already provided.`));
|
|
572
572
|
v.setRemoteInterface(m), J();
|
|
573
573
|
};
|
|
574
|
-
let C = !1, k = !1,
|
|
574
|
+
let C = !1, k = !1, b = !1, x = !1, P = !1;
|
|
575
575
|
async function J() {
|
|
576
576
|
if (k = !0, !C) {
|
|
577
577
|
for (C = !0; k; ) {
|
|
578
578
|
if (k = !1, t.isReady) {
|
|
579
|
-
const
|
|
580
|
-
if (
|
|
581
|
-
for (const l of
|
|
579
|
+
const a = g.filter((l) => !l.isDeclared);
|
|
580
|
+
if (a.length > 0)
|
|
581
|
+
for (const l of a) {
|
|
582
582
|
const m = Array(l.args.length + l.deps.length);
|
|
583
583
|
l.args.forEach((v, S) => m[S] = v), l.deps.forEach((v, S) => m[S + l.args.length] = v), await t.declare(m.map((v) => ({ name: v.name, version: v.localVersion }))), m.forEach((v) => {
|
|
584
584
|
v.localVersion != null && (v.localVersionSent = !0);
|
|
585
585
|
}), l.isDeclared = !0;
|
|
586
586
|
}
|
|
587
587
|
}
|
|
588
|
-
if (t.isReady &&
|
|
589
|
-
const
|
|
590
|
-
if (
|
|
591
|
-
for (const l of
|
|
588
|
+
if (t.isReady && b && g.every((a) => a.isDeclared)) {
|
|
589
|
+
const a = Object.values(r).filter((l) => !l.localVersionSent && l.localVersion != null);
|
|
590
|
+
if (a.length > 0)
|
|
591
|
+
for (const l of a)
|
|
592
592
|
await t.declare([{ name: l.name, version: l.localVersion }]), l.localVersionSent = !0;
|
|
593
593
|
x || (x = !0, await t.done());
|
|
594
594
|
}
|
|
595
595
|
if (t.isReady) {
|
|
596
|
-
const
|
|
597
|
-
if (
|
|
598
|
-
for (const l of
|
|
596
|
+
const a = g.filter((l) => !l.isDone && l.isReady);
|
|
597
|
+
if (a.length > 0)
|
|
598
|
+
for (const l of a) {
|
|
599
599
|
const m = l.invoke();
|
|
600
600
|
for (let v = 0; v < l.args.length; v++) {
|
|
601
601
|
const S = l.args[v];
|
|
@@ -604,22 +604,22 @@ function Pt(t) {
|
|
|
604
604
|
}
|
|
605
605
|
}
|
|
606
606
|
if (f != null) {
|
|
607
|
-
const
|
|
607
|
+
const a = Array(f + 1).fill(null);
|
|
608
608
|
for (const l in r) {
|
|
609
609
|
const m = r[l];
|
|
610
|
-
m.depGroup != null && (m.isActivable ?
|
|
610
|
+
m.depGroup != null && (m.isActivable ? a[m.depGroup] == null && !m.isActivated && (a[m.depGroup] = !0) : a[m.depGroup] = !1);
|
|
611
611
|
}
|
|
612
|
-
if (
|
|
612
|
+
if (a.some((l) => l === !0))
|
|
613
613
|
for (const l in r) {
|
|
614
614
|
const m = r[l];
|
|
615
|
-
m.depGroup != null &&
|
|
615
|
+
m.depGroup != null && a[m.depGroup] && m.activate();
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
618
|
if (t.isReady) {
|
|
619
|
-
const
|
|
619
|
+
const a = c;
|
|
620
620
|
c = [];
|
|
621
621
|
const l = [];
|
|
622
|
-
for (const m of
|
|
622
|
+
for (const m of a)
|
|
623
623
|
!m.isDone && m.isReady ? m.invoke() : l.push(m);
|
|
624
624
|
l.push(...c), c = l;
|
|
625
625
|
}
|
|
@@ -628,36 +628,36 @@ function Pt(t) {
|
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
return {
|
|
631
|
-
get(
|
|
632
|
-
return u(
|
|
631
|
+
get(a) {
|
|
632
|
+
return u(a);
|
|
633
633
|
},
|
|
634
|
-
declareFactory: (
|
|
635
|
-
if (
|
|
636
|
-
const S = p(
|
|
634
|
+
declareFactory: (a, l, m, v) => {
|
|
635
|
+
if (b) throw new Error(e("Cannot declare a factory after done has been set to true."));
|
|
636
|
+
const S = p(a.map((E) => E.name));
|
|
637
637
|
{
|
|
638
|
-
const
|
|
639
|
-
if (
|
|
640
|
-
throw new Error(e("Cannot declare a factory for already implemented contracts : " +
|
|
638
|
+
const E = S.filter((N) => N.localVersion != null);
|
|
639
|
+
if (E.length > 0)
|
|
640
|
+
throw new Error(e("Cannot declare a factory for already implemented contracts : " + E.map((N) => N.name).join(", ")));
|
|
641
641
|
}
|
|
642
|
-
for (let
|
|
643
|
-
S[
|
|
642
|
+
for (let E = 0; E < a.length; E++)
|
|
643
|
+
S[E].localVersion = a[E].version;
|
|
644
644
|
const T = p(l);
|
|
645
645
|
y(S, T);
|
|
646
646
|
const ft = o(S, T, m, v);
|
|
647
647
|
g.push(ft), J();
|
|
648
648
|
},
|
|
649
|
-
declareCallback(
|
|
650
|
-
const S = p(
|
|
649
|
+
declareCallback(a, l, m, v) {
|
|
650
|
+
const S = p(a), T = n(S, l, m, v);
|
|
651
651
|
!C && c.length === 0 && T.isReady ? T.invoke() : (c.push(T), J());
|
|
652
652
|
},
|
|
653
653
|
get done() {
|
|
654
|
-
return
|
|
654
|
+
return b;
|
|
655
655
|
},
|
|
656
|
-
set done(
|
|
657
|
-
if (
|
|
658
|
-
if (!
|
|
656
|
+
set done(a) {
|
|
657
|
+
if (b) {
|
|
658
|
+
if (!a) throw new Error(e("Cannot set done to false after it has been set to true."));
|
|
659
659
|
} else
|
|
660
|
-
|
|
660
|
+
a && (b = !0, Object.values(r).forEach((l) => {
|
|
661
661
|
l.localVersion == null && (l.localVersion = 0);
|
|
662
662
|
}), J());
|
|
663
663
|
}
|
|
@@ -671,7 +671,7 @@ function Dt(t) {
|
|
|
671
671
|
return isNaN(o) || o === 0 ? null : { name: e, version: o };
|
|
672
672
|
}
|
|
673
673
|
function Lt(t) {
|
|
674
|
-
const e =
|
|
674
|
+
const e = Vt(t);
|
|
675
675
|
function n(s) {
|
|
676
676
|
return lt(t.name, s);
|
|
677
677
|
}
|
|
@@ -725,12 +725,12 @@ const K = (t) => {
|
|
|
725
725
|
return c;
|
|
726
726
|
}, It = (t) => t ? K(t) : K, jt = (t) => t;
|
|
727
727
|
function $t(t, e = jt) {
|
|
728
|
-
const n =
|
|
728
|
+
const n = V.useSyncExternalStore(
|
|
729
729
|
t.subscribe,
|
|
730
|
-
|
|
731
|
-
|
|
730
|
+
V.useCallback(() => e(t.getState()), [t, e]),
|
|
731
|
+
V.useCallback(() => e(t.getInitialState()), [t, e])
|
|
732
732
|
);
|
|
733
|
-
return
|
|
733
|
+
return V.useDebugValue(n), n;
|
|
734
734
|
}
|
|
735
735
|
const X = (t) => {
|
|
736
736
|
const e = It(t), n = (s) => $t(e, s);
|
|
@@ -752,13 +752,14 @@ const X = (t) => {
|
|
|
752
752
|
}
|
|
753
753
|
return o(d);
|
|
754
754
|
}, t(e, n, s);
|
|
755
|
-
}, Nt = Ot,
|
|
755
|
+
}, Nt = Ot, i = dt()(
|
|
756
756
|
Nt((t) => ({
|
|
757
757
|
ready: !1,
|
|
758
758
|
workflow: "current",
|
|
759
759
|
mode: "assignment",
|
|
760
760
|
theme: "light",
|
|
761
761
|
saveCount: 0,
|
|
762
|
+
canSave: !1,
|
|
762
763
|
afterSaveCount: 0,
|
|
763
764
|
isDirtyCount: 0,
|
|
764
765
|
loadedTextContent: null,
|
|
@@ -829,6 +830,7 @@ const qt = [
|
|
|
829
830
|
"reload:1",
|
|
830
831
|
"theme:1",
|
|
831
832
|
"workflow:1",
|
|
833
|
+
"trigger-save:1",
|
|
832
834
|
"simple-content(text):1",
|
|
833
835
|
"simple-content(json):1",
|
|
834
836
|
"simple-binary-data(text):1",
|
|
@@ -839,7 +841,7 @@ const qt = [
|
|
|
839
841
|
], tt = {
|
|
840
842
|
"mode:1": {
|
|
841
843
|
setMode: (t) => {
|
|
842
|
-
|
|
844
|
+
i.setState({ mode: t });
|
|
843
845
|
}
|
|
844
846
|
},
|
|
845
847
|
"reload:1": {
|
|
@@ -850,63 +852,68 @@ const qt = [
|
|
|
850
852
|
"theme:1": {
|
|
851
853
|
setTheme: (t) => {
|
|
852
854
|
if (t === null) {
|
|
853
|
-
|
|
855
|
+
i.setState({ theme: null });
|
|
854
856
|
return;
|
|
855
857
|
}
|
|
856
858
|
if (t !== "light" && t !== "dark") {
|
|
857
|
-
console.warn(`Invalid theme: ${t}. Expected 'light' or 'dark'.`),
|
|
859
|
+
console.warn(`Invalid theme: ${t}. Expected 'light' or 'dark'.`), i.setState({ theme: null });
|
|
858
860
|
return;
|
|
859
861
|
}
|
|
860
|
-
|
|
862
|
+
i.setState({ theme: t });
|
|
861
863
|
}
|
|
862
864
|
},
|
|
863
865
|
"workflow:1": {
|
|
864
866
|
setWorkflow: (t) => {
|
|
865
|
-
|
|
867
|
+
i.setState({ workflow: t });
|
|
868
|
+
}
|
|
869
|
+
},
|
|
870
|
+
"trigger-save:1": {
|
|
871
|
+
setCanSave(t) {
|
|
872
|
+
i.setState({ canSave: t });
|
|
866
873
|
}
|
|
867
874
|
},
|
|
868
875
|
"simple-content(text):1": {
|
|
869
876
|
contentSaved: () => {
|
|
870
|
-
|
|
877
|
+
i.setState((t) => ({
|
|
871
878
|
afterSaveCount: t.afterSaveCount + 1
|
|
872
879
|
}));
|
|
873
880
|
},
|
|
874
|
-
getContent: () =>
|
|
881
|
+
getContent: () => i.getState().getTextContentFunction(),
|
|
875
882
|
loadContent: (t) => {
|
|
876
|
-
|
|
883
|
+
i.setState({ loadedTextContent: t });
|
|
877
884
|
}
|
|
878
885
|
},
|
|
879
886
|
"simple-content(json):1": {
|
|
880
887
|
contentSaved: () => {
|
|
881
|
-
|
|
888
|
+
i.setState((t) => ({
|
|
882
889
|
afterSaveCount: t.afterSaveCount + 1
|
|
883
890
|
}));
|
|
884
891
|
},
|
|
885
|
-
getContent: () =>
|
|
892
|
+
getContent: () => i.getState().getJsonContentFunction(),
|
|
886
893
|
loadContent: (t) => {
|
|
887
|
-
|
|
894
|
+
i.setState({ loadedJsonContent: t });
|
|
888
895
|
}
|
|
889
896
|
},
|
|
890
897
|
"simple-binary-data(text):1": {
|
|
891
898
|
contentSaved: () => {
|
|
892
|
-
|
|
899
|
+
i.setState((t) => ({
|
|
893
900
|
afterSaveCount: t.afterSaveCount + 1
|
|
894
901
|
}));
|
|
895
902
|
},
|
|
896
|
-
getContent: () =>
|
|
903
|
+
getContent: () => i.getState().getTextContentFunction(),
|
|
897
904
|
loadContent: (t) => {
|
|
898
|
-
|
|
905
|
+
i.setState({ loadedTextContent: t });
|
|
899
906
|
}
|
|
900
907
|
},
|
|
901
908
|
"simple-content-eval(text):1": {
|
|
902
909
|
contentSaved: () => {
|
|
903
|
-
|
|
910
|
+
i.setState((t) => ({
|
|
904
911
|
afterSaveCount: t.afterSaveCount + 1
|
|
905
912
|
}));
|
|
906
913
|
},
|
|
907
|
-
getContent: () =>
|
|
914
|
+
getContent: () => i.getState().getTextContentFunction(),
|
|
908
915
|
loadContent: (t) => {
|
|
909
|
-
|
|
916
|
+
i.setState({ loadedTextContent: t });
|
|
910
917
|
},
|
|
911
918
|
getAssignmentContent: () => {
|
|
912
919
|
throw new Error(
|
|
@@ -916,13 +923,13 @@ const qt = [
|
|
|
916
923
|
},
|
|
917
924
|
"simple-content-eval(json):1": {
|
|
918
925
|
contentSaved: () => {
|
|
919
|
-
|
|
926
|
+
i.setState((t) => ({
|
|
920
927
|
afterSaveCount: t.afterSaveCount + 1
|
|
921
928
|
}));
|
|
922
929
|
},
|
|
923
|
-
getContent: () =>
|
|
930
|
+
getContent: () => i.getState().getJsonContentFunction(),
|
|
924
931
|
loadContent: (t) => {
|
|
925
|
-
|
|
932
|
+
i.setState({ loadedJsonContent: t });
|
|
926
933
|
},
|
|
927
934
|
getAssignmentContent: () => {
|
|
928
935
|
throw new Error(
|
|
@@ -932,13 +939,13 @@ const qt = [
|
|
|
932
939
|
},
|
|
933
940
|
"simple-content-eval(json):2": {
|
|
934
941
|
contentSaved: () => {
|
|
935
|
-
|
|
942
|
+
i.setState((t) => ({
|
|
936
943
|
afterSaveCount: t.afterSaveCount + 1
|
|
937
944
|
}));
|
|
938
945
|
},
|
|
939
|
-
getContent: () =>
|
|
946
|
+
getContent: () => i.getState().getJsonContentFunction(),
|
|
940
947
|
loadContent: (t) => {
|
|
941
|
-
|
|
948
|
+
i.setState({ loadedJsonContent: t });
|
|
942
949
|
},
|
|
943
950
|
getAssignmentContent: () => {
|
|
944
951
|
throw new Error(
|
|
@@ -948,13 +955,13 @@ const qt = [
|
|
|
948
955
|
},
|
|
949
956
|
"simple-content-eval(text):2": {
|
|
950
957
|
contentSaved: () => {
|
|
951
|
-
|
|
958
|
+
i.setState((t) => ({
|
|
952
959
|
afterSaveCount: t.afterSaveCount + 1
|
|
953
960
|
}));
|
|
954
961
|
},
|
|
955
|
-
getContent: () =>
|
|
962
|
+
getContent: () => i.getState().getTextContentFunction(),
|
|
956
963
|
loadContent: (t) => {
|
|
957
|
-
|
|
964
|
+
i.setState({ loadedTextContent: t });
|
|
958
965
|
},
|
|
959
966
|
getAssignmentContent: () => {
|
|
960
967
|
throw new Error(
|
|
@@ -964,22 +971,22 @@ const qt = [
|
|
|
964
971
|
},
|
|
965
972
|
"separate-contents(json):1": {
|
|
966
973
|
contentSaved: () => {
|
|
967
|
-
|
|
974
|
+
i.setState((t) => ({
|
|
968
975
|
afterSaveCount: t.afterSaveCount + 1
|
|
969
976
|
}));
|
|
970
977
|
},
|
|
971
978
|
loadContent: (t, e) => {
|
|
972
|
-
|
|
979
|
+
i.setState({
|
|
973
980
|
loadedJsonActivityContent: t,
|
|
974
981
|
loadedJsonAssignmentContent: e
|
|
975
982
|
});
|
|
976
983
|
},
|
|
977
|
-
getActivityContent: () =>
|
|
978
|
-
getAssignmentContent: () =>
|
|
984
|
+
getActivityContent: () => i.getState().getJsonActivityContentFunction(),
|
|
985
|
+
getAssignmentContent: () => i.getState().getJsonAssignmentContentFunction()
|
|
979
986
|
},
|
|
980
987
|
"separate-dual-contents(json):1": {
|
|
981
988
|
contentSaved: () => {
|
|
982
|
-
|
|
989
|
+
i.setState((t) => ({
|
|
983
990
|
afterSaveCount: t.afterSaveCount + 1
|
|
984
991
|
}));
|
|
985
992
|
},
|
|
@@ -989,15 +996,15 @@ const qt = [
|
|
|
989
996
|
activityBinaryData: n,
|
|
990
997
|
assignmentBinaryData: s
|
|
991
998
|
}) => {
|
|
992
|
-
|
|
999
|
+
i.setState({
|
|
993
1000
|
loadedJsonActivityContent: t,
|
|
994
1001
|
loadedJsonAssignmentContent: e,
|
|
995
1002
|
loadedJsonActivityBinaryData: n,
|
|
996
1003
|
loadedJsonAssignmentBinaryData: s
|
|
997
1004
|
});
|
|
998
1005
|
},
|
|
999
|
-
getActivityContentAndData: () =>
|
|
1000
|
-
getAssignmentContentAndData: () =>
|
|
1006
|
+
getActivityContentAndData: () => (console.log("Getting activity content and data"), i.getState().getJsonActivitySplitContentFunction()),
|
|
1007
|
+
getAssignmentContentAndData: () => (console.log("Getting assignment content and data"), i.getState().getJsonAssignmentSplitContentFunction())
|
|
1001
1008
|
},
|
|
1002
1009
|
"meta-player-anti-cheat:1": {
|
|
1003
1010
|
lock: () => {
|
|
@@ -1007,25 +1014,25 @@ const qt = [
|
|
|
1007
1014
|
},
|
|
1008
1015
|
"meta-player-ui:1": {
|
|
1009
1016
|
executeAction(t) {
|
|
1010
|
-
if (t.startsWith("qa")) {
|
|
1011
|
-
const n =
|
|
1017
|
+
if (console.log("Executing action:", t), t.startsWith("qa")) {
|
|
1018
|
+
const n = i.getState().quickActions[t];
|
|
1012
1019
|
n ? n() : console.error(`Quick action not found: ${t}`);
|
|
1013
1020
|
} else {
|
|
1014
|
-
const n =
|
|
1021
|
+
const n = i.getState().sidebarActions[t];
|
|
1015
1022
|
n ? n() : console.error(`Sidebar action not found: ${t}`);
|
|
1016
1023
|
}
|
|
1017
1024
|
},
|
|
1018
1025
|
executeFileUpload(t, e) {
|
|
1019
1026
|
if (t.startsWith("qa")) {
|
|
1020
|
-
const s =
|
|
1027
|
+
const s = i.getState().quickActions[t];
|
|
1021
1028
|
s ? s(e) : console.error(`Quick action not found: ${t}`);
|
|
1022
1029
|
} else {
|
|
1023
|
-
const s =
|
|
1030
|
+
const s = i.getState().sidebarActions[t];
|
|
1024
1031
|
s ? s(e) : console.error(`Sidebar action not found: ${t}`);
|
|
1025
1032
|
}
|
|
1026
1033
|
},
|
|
1027
1034
|
updateSettings(t) {
|
|
1028
|
-
const e =
|
|
1035
|
+
const e = i.getState().activitySettingsCallback;
|
|
1029
1036
|
e ? e(t) : console.warn(
|
|
1030
1037
|
"activitySettingsCallback is not set. Changes:",
|
|
1031
1038
|
t
|
|
@@ -1034,12 +1041,12 @@ const qt = [
|
|
|
1034
1041
|
},
|
|
1035
1042
|
"meta-player-events:1": {
|
|
1036
1043
|
handleEvent(t) {
|
|
1037
|
-
t === "all-loaded" &&
|
|
1044
|
+
t === "all-loaded" && i.setState({ ready: !0 });
|
|
1038
1045
|
}
|
|
1039
1046
|
}
|
|
1040
1047
|
}, h = Gt();
|
|
1041
1048
|
function Bt(t) {
|
|
1042
|
-
if (Z) {
|
|
1049
|
+
if (console.log("Contracts to plug:", t), Z) {
|
|
1043
1050
|
console.warn("Contracts have already been plugged. Skipping.");
|
|
1044
1051
|
return;
|
|
1045
1052
|
}
|
|
@@ -1058,7 +1065,7 @@ function Bt(t) {
|
|
|
1058
1065
|
continue;
|
|
1059
1066
|
}
|
|
1060
1067
|
const n = tt[e];
|
|
1061
|
-
h.plug([e], ([]) => [n]);
|
|
1068
|
+
h.plug([e], ([]) => (console.log(`Contract ${e} plugged.`), [n]));
|
|
1062
1069
|
}
|
|
1063
1070
|
h.plugsDone();
|
|
1064
1071
|
for (const e of [
|
|
@@ -1068,13 +1075,15 @@ function Bt(t) {
|
|
|
1068
1075
|
"simple-content-eval(text):1",
|
|
1069
1076
|
"simple-content-eval(json):1",
|
|
1070
1077
|
"simple-content-eval(json):2",
|
|
1071
|
-
"simple-content-eval(text):2"
|
|
1078
|
+
"simple-content-eval(text):2",
|
|
1079
|
+
"separate-contents(json):1",
|
|
1080
|
+
"separate-dual-contents(json):1"
|
|
1072
1081
|
])
|
|
1073
1082
|
if (console.log(`Contract ${e} is being subscribed to content changes.`), t.includes(e)) {
|
|
1074
1083
|
console.log(`Subscribing to content changes for contract ${e}`);
|
|
1075
1084
|
const n = e.split(":")[0];
|
|
1076
1085
|
h.use([n], ([s]) => {
|
|
1077
|
-
|
|
1086
|
+
i.subscribe(
|
|
1078
1087
|
(o) => o.isDirtyCount,
|
|
1079
1088
|
() => {
|
|
1080
1089
|
s.i?.contentChanged(), console.log(
|
|
@@ -1085,80 +1094,80 @@ function Bt(t) {
|
|
|
1085
1094
|
});
|
|
1086
1095
|
}
|
|
1087
1096
|
}
|
|
1088
|
-
const
|
|
1097
|
+
const re = () => i((t) => {
|
|
1089
1098
|
if (t.mode === null)
|
|
1090
1099
|
throw new Error("Mode is not set. Have you used contract 'mode'?");
|
|
1091
1100
|
return t.mode;
|
|
1092
|
-
}),
|
|
1101
|
+
}), se = () => i((t) => {
|
|
1093
1102
|
if (t.workflow === null)
|
|
1094
1103
|
throw new Error(
|
|
1095
1104
|
"Workflow is not set. Have you used contract 'workflow'?"
|
|
1096
1105
|
);
|
|
1097
1106
|
return t.workflow;
|
|
1098
|
-
}),
|
|
1107
|
+
}), ae = () => i((t) => {
|
|
1099
1108
|
if (t.theme === null)
|
|
1100
1109
|
throw new Error("Theme is not set. Have you used contract 'theme'?");
|
|
1101
1110
|
return t.theme;
|
|
1102
|
-
}), ie = () =>
|
|
1111
|
+
}), ie = () => i((t) => t.incSaveCount), ce = () => i((t) => t.incDirtyCount), le = () => i((t) => t.loadedTextContent), ue = () => i((t) => t.loadedJsonContent), de = () => i((t) => t.loadedJsonActivityContent), fe = () => i((t) => t.loadedJsonAssignmentContent), ge = () => i((t) => t.loadedJsonActivityBinaryData), pe = () => i((t) => t.loadedJsonAssignmentBinaryData), me = () => A(() => i.getState().loadedTextContent, []), ye = () => A(() => i.getState().loadedJsonContent, []), ve = () => A(() => i.getState().loadedJsonActivityContent, []), Ce = () => A(() => i.getState().loadedJsonAssignmentContent, []), Se = () => A(
|
|
1103
1112
|
() => ({
|
|
1104
|
-
content:
|
|
1105
|
-
binaryData:
|
|
1113
|
+
content: i.getState().loadedJsonActivityContent,
|
|
1114
|
+
binaryData: i.getState().loadedJsonActivityBinaryData
|
|
1106
1115
|
}),
|
|
1107
1116
|
[]
|
|
1108
|
-
),
|
|
1117
|
+
), we = () => A(
|
|
1109
1118
|
() => ({
|
|
1110
|
-
content:
|
|
1111
|
-
binaryData:
|
|
1119
|
+
content: i.getState().loadedJsonAssignmentContent,
|
|
1120
|
+
binaryData: i.getState().loadedJsonAssignmentBinaryData
|
|
1112
1121
|
}),
|
|
1113
1122
|
[]
|
|
1114
|
-
),
|
|
1115
|
-
const e =
|
|
1123
|
+
), he = (t) => {
|
|
1124
|
+
const e = i(
|
|
1116
1125
|
(n) => n.setGetTextContentFunction
|
|
1117
1126
|
);
|
|
1118
1127
|
w(() => {
|
|
1119
1128
|
e(t);
|
|
1120
1129
|
}, [t, e]);
|
|
1121
|
-
},
|
|
1122
|
-
const e =
|
|
1130
|
+
}, Ae = (t) => {
|
|
1131
|
+
const e = i(
|
|
1123
1132
|
(n) => n.setGetJsonContentFunction
|
|
1124
1133
|
);
|
|
1125
1134
|
w(() => {
|
|
1126
1135
|
e(t);
|
|
1127
1136
|
}, [t, e]);
|
|
1128
|
-
},
|
|
1129
|
-
const e =
|
|
1137
|
+
}, be = (t) => {
|
|
1138
|
+
const e = i(
|
|
1130
1139
|
(n) => n.setGetJsonActivityContentFunction
|
|
1131
1140
|
);
|
|
1132
1141
|
w(() => {
|
|
1133
1142
|
e(t);
|
|
1134
1143
|
}, [t, e]);
|
|
1135
|
-
},
|
|
1136
|
-
const e =
|
|
1144
|
+
}, Ee = (t) => {
|
|
1145
|
+
const e = i(
|
|
1137
1146
|
(n) => n.setGetJsonAssignmentContentFunction
|
|
1138
1147
|
);
|
|
1139
1148
|
w(() => {
|
|
1140
1149
|
e(t);
|
|
1141
1150
|
}, [t, e]);
|
|
1142
|
-
},
|
|
1143
|
-
const e =
|
|
1151
|
+
}, ke = (t) => {
|
|
1152
|
+
const e = i(
|
|
1144
1153
|
(n) => n.setGetJsonActivitySplitContentFunction
|
|
1145
1154
|
);
|
|
1146
1155
|
w(() => {
|
|
1147
1156
|
e(t);
|
|
1148
1157
|
}, [t, e]);
|
|
1149
|
-
},
|
|
1150
|
-
const e =
|
|
1158
|
+
}, Je = (t) => {
|
|
1159
|
+
const e = i(
|
|
1151
1160
|
(n) => n.setGetJsonAssignmentSplitContentFunction
|
|
1152
1161
|
);
|
|
1153
1162
|
w(() => {
|
|
1154
1163
|
e(t);
|
|
1155
1164
|
}, [t, e]);
|
|
1156
|
-
},
|
|
1157
|
-
const e =
|
|
1165
|
+
}, Fe = (t) => {
|
|
1166
|
+
const e = i((n) => n.afterSaveCount);
|
|
1158
1167
|
w(() => {
|
|
1159
1168
|
e > 0 && t();
|
|
1160
1169
|
}, [e]);
|
|
1161
|
-
},
|
|
1170
|
+
}, xe = () => (t, e) => {
|
|
1162
1171
|
h.use(["meta-player-ui"], ([n]) => {
|
|
1163
1172
|
if (n.version === 0) {
|
|
1164
1173
|
console.error(
|
|
@@ -1168,7 +1177,7 @@ const oe = () => a((t) => {
|
|
|
1168
1177
|
}
|
|
1169
1178
|
n.i?.previewTextFile(t, e);
|
|
1170
1179
|
});
|
|
1171
|
-
},
|
|
1180
|
+
}, Te = () => (t, e) => {
|
|
1172
1181
|
h.use(["meta-player-ui"], ([n]) => {
|
|
1173
1182
|
if (n.version === 0) {
|
|
1174
1183
|
console.error(
|
|
@@ -1180,8 +1189,8 @@ const oe = () => a((t) => {
|
|
|
1180
1189
|
});
|
|
1181
1190
|
};
|
|
1182
1191
|
let D = 0, W = 0;
|
|
1183
|
-
const
|
|
1184
|
-
const n = U(t, e), s =
|
|
1192
|
+
const Re = (t, e) => {
|
|
1193
|
+
const n = U(t, e), s = i((o) => o.setSidebarActions);
|
|
1185
1194
|
w(() => (D++, D > 1 && console.error(
|
|
1186
1195
|
"Capytale iframe React: Multiple sidebar actions registered: ",
|
|
1187
1196
|
D
|
|
@@ -1218,8 +1227,8 @@ const Te = (t, e) => {
|
|
|
1218
1227
|
}), [n]);
|
|
1219
1228
|
};
|
|
1220
1229
|
let L = 0, H = 0;
|
|
1221
|
-
const
|
|
1222
|
-
const n = U(t, e), s =
|
|
1230
|
+
const Pe = (t, e) => {
|
|
1231
|
+
const n = U(t, e), s = i((o) => o.setQuickActions);
|
|
1223
1232
|
w(() => (L++, L > 1 && console.error(
|
|
1224
1233
|
"Capytale iframe React: Multiple quick actions registered: ",
|
|
1225
1234
|
L
|
|
@@ -1257,7 +1266,7 @@ const Re = (t, e) => {
|
|
|
1257
1266
|
};
|
|
1258
1267
|
let G = 0;
|
|
1259
1268
|
const Wt = (t, e, n) => {
|
|
1260
|
-
const s = U(t, n), o =
|
|
1269
|
+
const s = U(t, n), o = i(
|
|
1261
1270
|
(r) => r.setActivitySettingsCallback
|
|
1262
1271
|
);
|
|
1263
1272
|
w(() => (console.log("Mounting useSettings"), G++, G > 1 && console.error(
|
|
@@ -1278,63 +1287,81 @@ const Wt = (t, e, n) => {
|
|
|
1278
1287
|
), () => {
|
|
1279
1288
|
o(null);
|
|
1280
1289
|
}), [s]);
|
|
1281
|
-
}, Ht = () =>
|
|
1290
|
+
}, Ht = () => A((e) => h.exec(["meta-player-ui"], ([n]) => {
|
|
1282
1291
|
if (n.version === 0)
|
|
1283
1292
|
throw console.error(
|
|
1284
1293
|
"Le MétaPlayer ne supporte pas le contrat meta-player-ui"
|
|
1285
1294
|
), new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
1286
1295
|
return n.i?.showToast(e);
|
|
1287
|
-
}), []), zt = () =>
|
|
1296
|
+
}), []), zt = () => A((e) => h.exec(["meta-player-ui"], ([n]) => {
|
|
1288
1297
|
if (n.version === 0)
|
|
1289
1298
|
throw console.error(
|
|
1290
1299
|
"Le MétaPlayer ne supporte pas le contrat meta-player-ui"
|
|
1291
1300
|
), new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
1292
1301
|
return n.i?.clearToast(e);
|
|
1293
|
-
}), []), Ve = () =>
|
|
1302
|
+
}), []), Ve = () => A(() => h.exec(["meta-player-ui"], ([e]) => {
|
|
1294
1303
|
if (e.version === 0)
|
|
1295
1304
|
throw console.error(
|
|
1296
1305
|
"Le MétaPlayer ne supporte pas le contrat meta-player-ui"
|
|
1297
1306
|
), new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
|
|
1298
1307
|
return e.i?.clearToasts();
|
|
1299
|
-
}), [])
|
|
1300
|
-
|
|
1308
|
+
}), []), Ut = (t, e) => {
|
|
1309
|
+
const n = Ht(), s = zt();
|
|
1310
|
+
return w(() => {
|
|
1311
|
+
if (t == null)
|
|
1312
|
+
return;
|
|
1313
|
+
const o = n(t);
|
|
1314
|
+
return () => {
|
|
1315
|
+
o.then((r) => {
|
|
1316
|
+
r != null && s(r);
|
|
1317
|
+
});
|
|
1318
|
+
};
|
|
1319
|
+
}, [n, s, ...e]), null;
|
|
1320
|
+
}, Me = () => A(() => h.exec(["trigger-save"], ([e]) => {
|
|
1321
|
+
if (e.version === 0)
|
|
1322
|
+
throw console.error(
|
|
1323
|
+
"Le MétaPlayer ne supporte pas le contrat trigger-save"
|
|
1324
|
+
), new Error("Le MétaPlayer ne supporte pas le contrat trigger-save");
|
|
1325
|
+
return e.i?.triggerSave();
|
|
1326
|
+
}), []), De = () => i((t) => t.canSave);
|
|
1327
|
+
function _t(t) {
|
|
1301
1328
|
const e = {};
|
|
1302
1329
|
for (const n of t.fields)
|
|
1303
1330
|
e[n.name] = n.defaultValue;
|
|
1304
1331
|
return e;
|
|
1305
1332
|
}
|
|
1306
|
-
function
|
|
1333
|
+
function Qt(t) {
|
|
1307
1334
|
return { [t.name]: t.defaultValues };
|
|
1308
1335
|
}
|
|
1309
|
-
function
|
|
1336
|
+
function Yt(t) {
|
|
1310
1337
|
return { [t.name]: t.defaultValue };
|
|
1311
1338
|
}
|
|
1312
|
-
function
|
|
1339
|
+
function Kt(t) {
|
|
1313
1340
|
switch (t.type) {
|
|
1314
1341
|
case "form":
|
|
1315
|
-
return
|
|
1342
|
+
return _t(t);
|
|
1316
1343
|
case "checkboxes":
|
|
1317
1344
|
case "switches":
|
|
1318
|
-
return _t(t);
|
|
1319
|
-
case "radio":
|
|
1320
1345
|
return Qt(t);
|
|
1346
|
+
case "radio":
|
|
1347
|
+
return Yt(t);
|
|
1321
1348
|
default:
|
|
1322
1349
|
return {};
|
|
1323
1350
|
}
|
|
1324
1351
|
}
|
|
1325
|
-
function
|
|
1352
|
+
function Xt(t) {
|
|
1326
1353
|
const e = {};
|
|
1327
1354
|
for (const n of t)
|
|
1328
|
-
Object.assign(e,
|
|
1355
|
+
Object.assign(e, Kt(n));
|
|
1329
1356
|
return e;
|
|
1330
1357
|
}
|
|
1331
|
-
function
|
|
1358
|
+
function Le(t) {
|
|
1332
1359
|
const n = dt()((s) => ({
|
|
1333
|
-
...
|
|
1360
|
+
...Xt(t)
|
|
1334
1361
|
}));
|
|
1335
1362
|
return n.activitySettings = t, n;
|
|
1336
1363
|
}
|
|
1337
|
-
function
|
|
1364
|
+
function Zt(t) {
|
|
1338
1365
|
Wt(
|
|
1339
1366
|
() => t.activitySettings,
|
|
1340
1367
|
(e) => {
|
|
@@ -1343,78 +1370,74 @@ function Xt(t) {
|
|
|
1343
1370
|
[]
|
|
1344
1371
|
);
|
|
1345
1372
|
}
|
|
1346
|
-
function
|
|
1373
|
+
function te({
|
|
1347
1374
|
store: t
|
|
1348
1375
|
}) {
|
|
1349
|
-
return
|
|
1376
|
+
return Zt(t), null;
|
|
1350
1377
|
}
|
|
1351
|
-
const
|
|
1378
|
+
const ee = [
|
|
1352
1379
|
"meta-player-events:1",
|
|
1380
|
+
"meta-player-ui:1",
|
|
1353
1381
|
"mode:1",
|
|
1354
1382
|
"workflow:1"
|
|
1355
1383
|
];
|
|
1356
|
-
function
|
|
1384
|
+
function Ge({
|
|
1357
1385
|
children: t,
|
|
1358
1386
|
contracts: e,
|
|
1359
1387
|
loadOnlyWhenReady: n = !0,
|
|
1360
1388
|
activitySettingsStore: s
|
|
1361
1389
|
}) {
|
|
1362
|
-
const o =
|
|
1390
|
+
const o = i((r) => r.ready);
|
|
1363
1391
|
return w(() => {
|
|
1364
1392
|
const r = [...e];
|
|
1365
|
-
for (const g of
|
|
1393
|
+
for (const g of ee)
|
|
1366
1394
|
r.includes(g) || r.push(g);
|
|
1367
1395
|
Bt(r);
|
|
1368
1396
|
}, []), n && !o ? /* @__PURE__ */ Q("div", { className: "capy-loading-container", children: "Chargement en cours..." }) : /* @__PURE__ */ gt(pt, { children: [
|
|
1369
|
-
s && /* @__PURE__ */ Q(
|
|
1397
|
+
s && /* @__PURE__ */ Q(te, { store: s }),
|
|
1370
1398
|
t
|
|
1371
1399
|
] });
|
|
1372
1400
|
}
|
|
1373
|
-
function
|
|
1374
|
-
|
|
1375
|
-
return w(() => {
|
|
1376
|
-
const s = e(t);
|
|
1377
|
-
return () => {
|
|
1378
|
-
s.then((o) => {
|
|
1379
|
-
o != null && n(o);
|
|
1380
|
-
});
|
|
1381
|
-
};
|
|
1382
|
-
}, [t, e, n]), null;
|
|
1401
|
+
function Ie({ message: t }) {
|
|
1402
|
+
return Ut(t, [t]), null;
|
|
1383
1403
|
}
|
|
1384
1404
|
export {
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1405
|
+
Ge as Capytale,
|
|
1406
|
+
Ie as TemporaryToast,
|
|
1407
|
+
Le as createActivitySettingsStore,
|
|
1408
|
+
Fe as useAfterSaveAction,
|
|
1409
|
+
De as useCanSave,
|
|
1389
1410
|
zt as useClearToast,
|
|
1390
1411
|
Ve as useClearToasts,
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1412
|
+
ve as useGetLoadedJsonActivityContent,
|
|
1413
|
+
Se as useGetLoadedJsonActivitySplitContent,
|
|
1414
|
+
Ce as useGetLoadedJsonAssignmentContent,
|
|
1415
|
+
we as useGetLoadedJsonAssignmentSplitContent,
|
|
1416
|
+
ye as useGetLoadedJsonContent,
|
|
1417
|
+
me as useGetLoadedTextContent,
|
|
1418
|
+
be as useJsonActivityContentSaveFunction,
|
|
1419
|
+
ke as useJsonActivitySplitContentSaveFunction,
|
|
1420
|
+
Ee as useJsonAssignmentContentSaveFunction,
|
|
1421
|
+
Je as useJsonAssignmentSplitContentSaveFunction,
|
|
1422
|
+
Ae as useJsonContentSaveFunction,
|
|
1423
|
+
ge as useLoadedJsonActivityBinaryData,
|
|
1424
|
+
de as useLoadedJsonActivityContent,
|
|
1425
|
+
pe as useLoadedJsonAssignmentBinaryData,
|
|
1426
|
+
fe as useLoadedJsonAssignmentContent,
|
|
1427
|
+
ue as useLoadedJsonContent,
|
|
1428
|
+
le as useLoadedTextContent,
|
|
1429
|
+
re as useMode,
|
|
1430
|
+
ce as useNotifyIsDirty,
|
|
1431
|
+
Te as usePreviewImageFile,
|
|
1432
|
+
xe as usePreviewTextFile,
|
|
1433
|
+
Pe as useQuickActions,
|
|
1413
1434
|
ie as useRequestSave,
|
|
1414
1435
|
Wt as useSettings,
|
|
1415
1436
|
Ht as useShowToast,
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1437
|
+
Re as useSidebarActions,
|
|
1438
|
+
he as useTextContentSaveFunction,
|
|
1439
|
+
ae as useTheme,
|
|
1440
|
+
Ut as useToast,
|
|
1441
|
+
Me as useTriggerSave,
|
|
1442
|
+
se as useWorkflow
|
|
1420
1443
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capytale/iframe-react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"react-dom": ">=17.0.0 <20"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@capytale/contracts": "^1.1.
|
|
37
|
+
"@capytale/contracts": "^1.1.3",
|
|
38
38
|
"@types/node": "^22.13.1",
|
|
39
39
|
"@types/react": "^18.3.18",
|
|
40
40
|
"@types/react-dom": "^18.3.5",
|