@capytale/iframe-react 1.1.7 → 1.1.9
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 -14
- package/dist/index.d.ts +336 -0
- package/dist/index.es.js +800 -1410
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react");var ae={exports:{}},X={};var Ze;function Bt(){if(Ze)return X;Ze=1;var e=R,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function m(l,d,v){var u,y={},S=null,T=null;v!==void 0&&(S=""+v),d.key!==void 0&&(S=""+d.key),d.ref!==void 0&&(T=d.ref);for(u in d)i.call(d,u)&&!s.hasOwnProperty(u)&&(y[u]=d[u]);if(l&&l.defaultProps)for(u in d=l.defaultProps,d)y[u]===void 0&&(y[u]=d[u]);return{$$typeof:n,type:l,key:S,ref:T,props:y,_owner:a.current}}return X.Fragment=r,X.jsx=m,X.jsxs=m,X}var Z={};var et;function Yt(){return et||(et=1,process.env.NODE_ENV!=="production"&&function(){var e=R,n=Symbol.for("react.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),l=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),T=Symbol.for("react.offscreen"),I=Symbol.iterator,L="@@iterator";function $(t){if(t===null||typeof t!="object")return null;var o=I&&t[I]||t[L];return typeof o=="function"?o:null}var j=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function F(t){{for(var o=arguments.length,g=new Array(o>1?o-1:0),C=1;C<o;C++)g[C-1]=arguments[C];c("error",t,g)}}function c(t,o,g){{var C=j.ReactDebugCurrentFrame,A=C.getStackAddendum();A!==""&&(o+="%s",g=g.concat([A]));var k=g.map(function(w){return String(w)});k.unshift("Warning: "+o),Function.prototype.apply.call(console[t],console,k)}}var p=!1,h=!1,E=!1,_=!1,G=!1,ee;ee=Symbol.for("react.module.reference");function V(t){return!!(typeof t=="string"||typeof t=="function"||t===i||t===s||G||t===a||t===v||t===u||_||t===T||p||h||E||typeof t=="object"&&t!==null&&(t.$$typeof===S||t.$$typeof===y||t.$$typeof===m||t.$$typeof===l||t.$$typeof===d||t.$$typeof===ee||t.getModuleId!==void 0))}function H(t,o,g){var C=t.displayName;if(C)return C;var A=o.displayName||o.name||"";return A!==""?g+"("+A+")":g}function xe(t){return t.displayName||"Context"}function W(t){if(t==null)return null;if(typeof t.tag=="number"&&F("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case i:return"Fragment";case r:return"Portal";case s:return"Profiler";case a:return"StrictMode";case v:return"Suspense";case u:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case l:var o=t;return xe(o)+".Consumer";case m:var g=t;return xe(g._context)+".Provider";case d:return H(t,t.render,"ForwardRef");case y:var C=t.displayName||null;return C!==null?C:W(t.type)||"Memo";case S:{var A=t,k=A._payload,w=A._init;try{return W(w(k))}catch{return null}}}return null}var N=Object.assign,Q=0,_e,Je,Pe,Oe,je,De,Ie;function Le(){}Le.__reactDisabledLog=!0;function St(){{if(Q===0){_e=console.log,Je=console.info,Pe=console.warn,Oe=console.error,je=console.group,De=console.groupCollapsed,Ie=console.groupEnd;var t={configurable:!0,enumerable:!0,value:Le,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}Q++}}function ht(){{if(Q--,Q===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:N({},t,{value:_e}),info:N({},t,{value:Je}),warn:N({},t,{value:Pe}),error:N({},t,{value:Oe}),group:N({},t,{value:je}),groupCollapsed:N({},t,{value:De}),groupEnd:N({},t,{value:Ie})})}Q<0&&F("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var pe=j.ReactCurrentDispatcher,me;function te(t,o,g){{if(me===void 0)try{throw Error()}catch(A){var C=A.stack.trim().match(/\n( *(at )?)/);me=C&&C[1]||""}return`
|
|
2
|
-
`+me+t}}var ye=!1,ne;{var bt=typeof WeakMap=="function"?WeakMap:Map;ne=new bt}function Ve(t,o){if(!t||ye)return"";{var g=ne.get(t);if(g!==void 0)return g}var C;ye=!0;var A=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var k;k=pe.current,pe.current=null,St();try{if(o){var w=function(){throw Error()};if(Object.defineProperty(w.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(w,[])}catch(O){C=O}Reflect.construct(t,[],w)}else{try{w.call()}catch(O){C=O}t.call(w.prototype)}}else{try{throw Error()}catch(O){C=O}t()}}catch(O){if(O&&C&&typeof O.stack=="string"){for(var b=O.stack.split(`
|
|
3
|
-
`),P=C.stack.split(`
|
|
4
|
-
`),x=b.length-1,J=P.length-1;x>=1&&J>=0&&b[x]!==P[J];)J--;for(;x>=1&&J>=0;x--,J--)if(b[x]!==P[J]){if(x!==1||J!==1)do if(x--,J--,J<0||b[x]!==P[J]){var D=`
|
|
5
|
-
`+b[x].replace(" at new "," at ");return t.displayName&&D.includes("<anonymous>")&&(D=D.replace("<anonymous>",t.displayName)),typeof t=="function"&&ne.set(t,D),D}while(x>=1&&J>=0);break}}}finally{ye=!1,pe.current=k,ht(),Error.prepareStackTrace=A}var Y=t?t.displayName||t.name:"",q=Y?te(Y):"";return typeof t=="function"&&ne.set(t,q),q}function wt(t,o,g){return Ve(t,!1)}function Et(t){var o=t.prototype;return!!(o&&o.isReactComponent)}function re(t,o,g){if(t==null)return"";if(typeof t=="function")return Ve(t,Et(t));if(typeof t=="string")return te(t);switch(t){case v:return te("Suspense");case u:return te("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case d:return wt(t.render);case y:return re(t.type,o,g);case S:{var C=t,A=C._payload,k=C._init;try{return re(k(A),o,g)}catch{}}}return""}var K=Object.prototype.hasOwnProperty,Me={},$e=j.ReactDebugCurrentFrame;function oe(t){if(t){var o=t._owner,g=re(t.type,t._source,o?o.type:null);$e.setExtraStackFrame(g)}else $e.setExtraStackFrame(null)}function At(t,o,g,C,A){{var k=Function.call.bind(K);for(var w in t)if(k(t,w)){var b=void 0;try{if(typeof t[w]!="function"){var P=Error((C||"React class")+": "+g+" type `"+w+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[w]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw P.name="Invariant Violation",P}b=t[w](o,w,C,g,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(x){b=x}b&&!(b instanceof Error)&&(oe(A),F("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",C||"React class",g,w,typeof b),oe(null)),b instanceof Error&&!(b.message in Me)&&(Me[b.message]=!0,oe(A),F("Failed %s type: %s",g,b.message),oe(null))}}}var Rt=Array.isArray;function Ce(t){return Rt(t)}function kt(t){{var o=typeof Symbol=="function"&&Symbol.toStringTag,g=o&&t[Symbol.toStringTag]||t.constructor.name||"Object";return g}}function Tt(t){try{return Ge(t),!1}catch{return!0}}function Ge(t){return""+t}function We(t){if(Tt(t))return F("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",kt(t)),Ge(t)}var Ne=j.ReactCurrentOwner,Ft={key:!0,ref:!0,__self:!0,__source:!0},qe,Ue;function xt(t){if(K.call(t,"ref")){var o=Object.getOwnPropertyDescriptor(t,"ref").get;if(o&&o.isReactWarning)return!1}return t.ref!==void 0}function _t(t){if(K.call(t,"key")){var o=Object.getOwnPropertyDescriptor(t,"key").get;if(o&&o.isReactWarning)return!1}return t.key!==void 0}function Jt(t,o){typeof t.ref=="string"&&Ne.current}function Pt(t,o){{var g=function(){qe||(qe=!0,F("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};g.isReactWarning=!0,Object.defineProperty(t,"key",{get:g,configurable:!0})}}function Ot(t,o){{var g=function(){Ue||(Ue=!0,F("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};g.isReactWarning=!0,Object.defineProperty(t,"ref",{get:g,configurable:!0})}}var jt=function(t,o,g,C,A,k,w){var b={$$typeof:n,type:t,key:o,ref:g,props:w,_owner:k};return b._store={},Object.defineProperty(b._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(b,"_self",{configurable:!1,enumerable:!1,writable:!1,value:C}),Object.defineProperty(b,"_source",{configurable:!1,enumerable:!1,writable:!1,value:A}),Object.freeze&&(Object.freeze(b.props),Object.freeze(b)),b};function Dt(t,o,g,C,A){{var k,w={},b=null,P=null;g!==void 0&&(We(g),b=""+g),_t(o)&&(We(o.key),b=""+o.key),xt(o)&&(P=o.ref,Jt(o,A));for(k in o)K.call(o,k)&&!Ft.hasOwnProperty(k)&&(w[k]=o[k]);if(t&&t.defaultProps){var x=t.defaultProps;for(k in x)w[k]===void 0&&(w[k]=x[k])}if(b||P){var J=typeof t=="function"?t.displayName||t.name||"Unknown":t;b&&Pt(w,J),P&&Ot(w,J)}return jt(t,b,P,A,C,Ne.current,w)}}var Se=j.ReactCurrentOwner,Be=j.ReactDebugCurrentFrame;function B(t){if(t){var o=t._owner,g=re(t.type,t._source,o?o.type:null);Be.setExtraStackFrame(g)}else Be.setExtraStackFrame(null)}var he;he=!1;function be(t){return typeof t=="object"&&t!==null&&t.$$typeof===n}function Ye(){{if(Se.current){var t=W(Se.current.type);if(t)return`
|
|
6
|
-
|
|
7
|
-
Check the render method of \``+t+"`."}return""}}function It(t){return""}var ze={};function Lt(t){{var o=Ye();if(!o){var g=typeof t=="string"?t:t.displayName||t.name;g&&(o=`
|
|
8
|
-
|
|
9
|
-
Check the top-level render call using <`+g+">.")}return o}}function He(t,o){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var g=Lt(o);if(ze[g])return;ze[g]=!0;var C="";t&&t._owner&&t._owner!==Se.current&&(C=" It was passed a child from "+W(t._owner.type)+"."),B(t),F('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',g,C),B(null)}}function Qe(t,o){{if(typeof t!="object")return;if(Ce(t))for(var g=0;g<t.length;g++){var C=t[g];be(C)&&He(C,o)}else if(be(t))t._store&&(t._store.validated=!0);else if(t){var A=$(t);if(typeof A=="function"&&A!==t.entries)for(var k=A.call(t),w;!(w=k.next()).done;)be(w.value)&&He(w.value,o)}}}function Vt(t){{var o=t.type;if(o==null||typeof o=="string")return;var g;if(typeof o=="function")g=o.propTypes;else if(typeof o=="object"&&(o.$$typeof===d||o.$$typeof===y))g=o.propTypes;else return;if(g){var C=W(o);At(g,t.props,"prop",C,t)}else if(o.PropTypes!==void 0&&!he){he=!0;var A=W(o);F("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",A||"Unknown")}typeof o.getDefaultProps=="function"&&!o.getDefaultProps.isReactClassApproved&&F("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Mt(t){{for(var o=Object.keys(t.props),g=0;g<o.length;g++){var C=o[g];if(C!=="children"&&C!=="key"){B(t),F("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",C),B(null);break}}t.ref!==null&&(B(t),F("Invalid attribute `ref` supplied to `React.Fragment`."),B(null))}}var Ke={};function Xe(t,o,g,C,A,k){{var w=V(t);if(!w){var b="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(b+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var P=It();P?b+=P:b+=Ye();var x;t===null?x="null":Ce(t)?x="array":t!==void 0&&t.$$typeof===n?(x="<"+(W(t.type)||"Unknown")+" />",b=" Did you accidentally export a JSX literal instead of a component?"):x=typeof t,F("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",x,b)}var J=Dt(t,o,g,A,k);if(J==null)return J;if(w){var D=o.children;if(D!==void 0)if(C)if(Ce(D)){for(var Y=0;Y<D.length;Y++)Qe(D[Y],t);Object.freeze&&Object.freeze(D)}else F("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Qe(D,t)}if(K.call(o,"key")){var q=W(t),O=Object.keys(o).filter(function(Ut){return Ut!=="key"}),we=O.length>0?"{key: someKey, "+O.join(": ..., ")+": ...}":"{key: someKey}";if(!Ke[q+we]){var qt=O.length>0?"{"+O.join(": ..., ")+": ...}":"{}";F(`A props object containing a "key" prop is being spread into JSX:
|
|
10
|
-
let props = %s;
|
|
11
|
-
<%s {...props} />
|
|
12
|
-
React keys must be passed directly to JSX without using spread:
|
|
13
|
-
let props = %s;
|
|
14
|
-
<%s key={someKey} {...props} />`,we,q,qt,q),Ke[q+we]=!0}}return t===i?Mt(J):Vt(J),J}}function $t(t,o,g){return Xe(t,o,g,!0)}function Gt(t,o,g){return Xe(t,o,g,!1)}var Wt=Gt,Nt=$t;Z.Fragment=i,Z.jsx=Wt,Z.jsxs=Nt}()),Z}var tt;function zt(){return tt||(tt=1,process.env.NODE_ENV==="production"?ae.exports=Bt():ae.exports=Yt()),ae.exports}var se=zt();const it=Symbol("Comlink.proxy"),Ht=Symbol("Comlink.endpoint"),Qt=Symbol("Comlink.releaseProxy"),Ee=Symbol("Comlink.finalizer"),fe=Symbol("Comlink.thrown"),ct=e=>typeof e=="object"&&e!==null||typeof e=="function",Kt={canHandle:e=>ct(e)&&e[it],serialize(e){const{port1:n,port2:r}=new MessageChannel;return Fe(e,n),[r,[r]]},deserialize(e){return e.start(),ft(e)}},Xt={canHandle:e=>ct(e)&&fe in e,serialize({value:e}){let n;return e instanceof Error?n={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:n={isError:!1,value:e},[n,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},lt=new Map([["proxy",Kt],["throw",Xt]]);function Zt(e,n){for(const r of e)if(n===r||r==="*"||r instanceof RegExp&&r.test(n))return!0;return!1}function Fe(e,n=globalThis,r=["*"]){n.addEventListener("message",function i(a){if(!a||!a.data)return;if(!Zt(r,a.origin)){console.warn(`Invalid origin '${a.origin}' for comlink proxy`);return}const{id:s,type:m,path:l}=Object.assign({path:[]},a.data),d=(a.data.argumentList||[]).map(U);let v;try{const u=l.slice(0,-1).reduce((S,T)=>S[T],e),y=l.reduce((S,T)=>S[T],e);switch(m){case"GET":v=y;break;case"SET":u[l.slice(-1)[0]]=U(a.data.value),v=!0;break;case"APPLY":v=y.apply(u,d);break;case"CONSTRUCT":{const S=new y(...d);v=vt(S)}break;case"ENDPOINT":{const{port1:S,port2:T}=new MessageChannel;Fe(e,T),v=on(S,[S])}break;case"RELEASE":v=void 0;break;default:return}}catch(u){v={value:u,[fe]:0}}Promise.resolve(v).catch(u=>({value:u,[fe]:0})).then(u=>{const[y,S]=ve(u);n.postMessage(Object.assign(Object.assign({},y),{id:s}),S),m==="RELEASE"&&(n.removeEventListener("message",i),ut(n),Ee in e&&typeof e[Ee]=="function"&&e[Ee]())}).catch(u=>{const[y,S]=ve({value:new TypeError("Unserializable return value"),[fe]:0});n.postMessage(Object.assign(Object.assign({},y),{id:s}),S)})}),n.start&&n.start()}function en(e){return e.constructor.name==="MessagePort"}function ut(e){en(e)&&e.close()}function ft(e,n){const r=new Map;return e.addEventListener("message",function(a){const{data:s}=a;if(!s||!s.id)return;const m=r.get(s.id);if(m)try{m(s)}finally{r.delete(s.id)}}),Te(e,r,[],n)}function ie(e){if(e)throw new Error("Proxy has been released and is not useable")}function dt(e){return z(e,new Map,{type:"RELEASE"}).then(()=>{ut(e)})}const de=new WeakMap,ge="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const n=(de.get(e)||0)-1;de.set(e,n),n===0&&dt(e)});function tn(e,n){const r=(de.get(n)||0)+1;de.set(n,r),ge&&ge.register(e,n,e)}function nn(e){ge&&ge.unregister(e)}function Te(e,n,r=[],i=function(){}){let a=!1;const s=new Proxy(i,{get(m,l){if(ie(a),l===Qt)return()=>{nn(s),dt(e),n.clear(),a=!0};if(l==="then"){if(r.length===0)return{then:()=>s};const d=z(e,n,{type:"GET",path:r.map(v=>v.toString())}).then(U);return d.then.bind(d)}return Te(e,n,[...r,l])},set(m,l,d){ie(a);const[v,u]=ve(d);return z(e,n,{type:"SET",path:[...r,l].map(y=>y.toString()),value:v},u).then(U)},apply(m,l,d){ie(a);const v=r[r.length-1];if(v===Ht)return z(e,n,{type:"ENDPOINT"}).then(U);if(v==="bind")return Te(e,n,r.slice(0,-1));const[u,y]=nt(d);return z(e,n,{type:"APPLY",path:r.map(S=>S.toString()),argumentList:u},y).then(U)},construct(m,l){ie(a);const[d,v]=nt(l);return z(e,n,{type:"CONSTRUCT",path:r.map(u=>u.toString()),argumentList:d},v).then(U)}});return tn(s,e),s}function rn(e){return Array.prototype.concat.apply([],e)}function nt(e){const n=e.map(ve);return[n.map(r=>r[0]),rn(n.map(r=>r[1]))]}const gt=new WeakMap;function on(e,n){return gt.set(e,n),e}function vt(e){return Object.assign(e,{[it]:!0})}function an(e,n=globalThis,r="*"){return{postMessage:(i,a)=>e.postMessage(i,r,a),addEventListener:n.addEventListener.bind(n),removeEventListener:n.removeEventListener.bind(n)}}function ve(e){for(const[n,r]of lt)if(r.canHandle(e)){const[i,a]=r.serialize(e);return[{type:"HANDLER",name:n,value:i},a]}return[{type:"RAW",value:e},gt.get(e)||[]]}function U(e){switch(e.type){case"HANDLER":return lt.get(e.name).deserialize(e.value);case"RAW":return e.value}}function z(e,n,r,i){return new Promise(a=>{const s=sn();n.set(s,a),e.start&&e.start(),e.postMessage(Object.assign({id:s},r),i)})}function sn(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}function cn(e,n){return e.length===0?n:`[${e}] ${n}`}function ln(e,n){let r=!1,i,a,s;function m(u){return cn(e,u)}let l,d=!1;if(window.parent===window)console.warn(m("Contract link is not supported in standalone mode")),l={ready(){return Promise.resolve()},declare(){return Promise.resolve()},done(){return Promise.resolve()},provide(u,y,S){return Promise.resolve()}};else{const u=an(window.parent,void 0,n);Fe({declare(y){if(i==null)throw new Error(m("No handler for declare"));i(y)},done(){if(a==null)throw new Error(m("No handler for done"));a()},provide(y,S,T){if(s==null)throw new Error(m("No handler for provide"));s(y,S,T)}},u),l=ft(u),d=!0}const v=()=>{if(!r){if(i==null||a==null||s==null)return;r=!0,l.ready()}};return{declare:u=>l.declare(u),done:()=>l.done(),provide:(u,y,S)=>l.provide(u,y,vt(S)),get name(){return e},get isReady(){return d},set onDeclare(u){i=u,v()},set onDone(u){a=u,v()},set onProvide(u){s=u,v()}}}function un(e){return function(n){let r,i=!1,a=!1,s,m,l=!1,d=!1,v,u,y,S;function T(){if(s!=null&&s!==0&&m!=null)return m}function I(c){if(s!=null&&m!=null&&!(c>s))return m}function L(){return y??(d?y=Promise.resolve():y=new Promise((c,p)=>{S=c}))}function $(){return v===void 0&&(v={get name(){return n},get version(){return s},get i(){return T()},v:c=>I(c)}),v}function j(){return u===void 0&&(u={get name(){return n},get version(){return d?s:void 0},get i(){return d?T():void 0},v:c=>d?I(c):void 0,get promise(){return s===0?Promise.reject(e("Remote interface not provided")):L().then(()=>{if(s===0)throw new Error(e("Remote interface not provided"));return $()})}}),u}function F(){S!=null&&(S(),S=void 0)}return{get name(){return n},get localVersion(){if(r!=null)return r},set localVersion(c){if(r!=null&&r!==c)throw new Error(e("A different local version is already set"));r=c},get localVersionSent(){return i},set localVersionSent(c){if(!c&&i)throw new Error(e("Local version already notified"));i=c,c&&r===0&&(a=!0)},get localInterfaceSent(){return a},set localInterfaceSent(c){if(r==null)throw new Error(e("Local version not set"));if(!c&&a)throw new Error(e("Local interface already sent."));a=c},get remoteVersion(){if(s!=null)return s},set remoteVersion(c){if(s!=null&&s!==c)throw new Error(e("A different remote version is already set for "+n+`(${s} -> ${c})`));s=c,c===0&&(l=!0)},get remoteVersionReceived(){return s!=null},setRemoteInterface:c=>{if(s==null)throw new Error(e("Remote version not set"));if(s===0){console.warn(e("Remote version is 0, remote interface is ignored."));return}if(l)throw new Error(e("Interface already provided."));m=c,l=!0},get remoteInterfaceReceived(){return l},depGroup:void 0,get isActivable(){return l&&a},get isActivated(){return d},activate(){if(!d){if(!l)throw new Error(e("Remote interface not provided."));if(!a)throw new Error(e("Local interface not sent"));d=!0,F()}},getRemote:()=>$(),getLazyRemote:()=>j(),get activationPromise(){return L()}}}}function fn(e){return function(n,r,i,a){let s=i,m=!1,l=!1;function d(){return n.every(v=>v.remoteVersionReceived&&v.localVersionSent)&&r.every(v=>v.remoteVersionReceived)}return{get isDeclared(){return l},set isDeclared(v){if(!v&&l)throw new Error(e("Factory already declared"));l=v},get isReady(){return d()},get isDone(){return m},get args(){return n},get deps(){return r},invoke(){if(m)throw new Error(e("Factory already invoked"));if(!d())throw new Error(e("Factory is not ready"));let v;a?v=n.map(S=>S.getRemote()):v=n[0].getRemote();let u;const y=r.length>0?r.map(S=>S.getRemote()):null;try{u=y==null?s(v):s(v,y)}catch(S){throw new Error(e("error in factory:"),{cause:S})}if(a||(u=[u]),u.length!=n.length)throw new Error(e("Invalid factory result"));return m=!0,s=null,u}}}}function dn(e){return function(n,r,i,a){let s=r,m=!1;function l(){return n.every(d=>d.isActivated)}return{get isReady(){return l()},get isDone(){return m},get args(){return n},invoke(){if(m||!l()){const u=new Error(e(m?"callback already invoked":"callback parameters are not ready"));throw a?.[1](u),u}const d=i?n.map(u=>u.getRemote()):n[0].getRemote();let v;try{v=s(d)}catch(u){a==null?console.error(e("error in callback:"),u):a[1](u)}finally{m=!0}a?.[0](v)}}}}function pt(e,n){return e==null||e.length===0?n:`[${e}] ${n}`}function gn(e){function n(c){return pt(e.name,c)}const r=dn(n),i=un(n),a=fn(n),s={},m=[];let l=[],d;const v=()=>(d==null?d=0:d++,d);function u(c){let p=s[c];return p==null&&(p=i(c),p.localVersion==null&&(L&&(p.localVersion=0),$&&(p.localVersionSent=!0)),p.remoteVersion==null&&j&&(p.remoteVersion=0),s[c]=p),p}function y(c){return c.map(u)}function S(...c){const p=v(),h=Array(p).fill(!1);c.forEach(E=>{E.forEach(_=>{_.depGroup!=null&&(h[_.depGroup]=!0),_.depGroup=p})}),Object.values(s).forEach(E=>{E.depGroup!=null&&E.depGroup!==p&&h[E.depGroup]&&(E.depGroup=p)})}e.onDeclare=c=>{const p=y(c.map(h=>h.name));for(let h=0;h<c.length;h++)c[h].version!=null&&(p[h].remoteVersion=c[h].version);S(p),F()},e.onDone=()=>{j||(j=!0,Object.values(s).forEach(c=>{c.remoteVersion==null&&(c.remoteVersion=0)}),F())},e.onProvide=(c,p,h)=>{let E=s[c];if(E==null)throw new Error(n(`Contract not declared : ${c}`));if(E.remoteVersion!=p)throw new Error(n(`Remote declared version ${E.remoteVersion} of contract "${c}" but provided version ${p}.`));if(E.remoteInterfaceReceived)throw new Error(n(`Remote contract "${c}" is already provided.`));E.setRemoteInterface(h),F()};let T=!1,I=!1,L=!1,$=!1,j=!1;async function F(){if(I=!0,!T){for(T=!0;I;){if(I=!1,e.isReady){const c=m.filter(p=>!p.isDeclared);if(c.length>0)for(const p of c){const h=Array(p.args.length+p.deps.length);p.args.forEach((E,_)=>h[_]=E),p.deps.forEach((E,_)=>h[_+p.args.length]=E),await e.declare(h.map(E=>({name:E.name,version:E.localVersion}))),h.forEach(E=>{E.localVersion!=null&&(E.localVersionSent=!0)}),p.isDeclared=!0}}if(e.isReady&&L&&m.every(c=>c.isDeclared)){const c=Object.values(s).filter(p=>!p.localVersionSent&&p.localVersion!=null);if(c.length>0)for(const p of c)await e.declare([{name:p.name,version:p.localVersion}]),p.localVersionSent=!0;$||($=!0,await e.done())}if(e.isReady){const c=m.filter(p=>!p.isDone&&p.isReady);if(c.length>0)for(const p of c){const h=p.invoke();for(let E=0;E<p.args.length;E++){const _=p.args[E];await e.provide(_.name,_.localVersion,h[E]),_.localInterfaceSent=!0}}}if(d!=null){const c=Array(d+1).fill(null);for(const p in s){const h=s[p];h.depGroup!=null&&(h.isActivable?c[h.depGroup]==null&&!h.isActivated&&(c[h.depGroup]=!0):c[h.depGroup]=!1)}if(c.some(p=>p===!0))for(const p in s){const h=s[p];h.depGroup!=null&&c[h.depGroup]&&h.activate()}}if(e.isReady){const c=l;l=[];const p=[];for(const h of c)!h.isDone&&h.isReady?h.invoke():p.push(h);p.push(...l),l=p}}T=!1}}return{get(c){return u(c)},declareFactory:(c,p,h,E)=>{if(L)throw new Error(n("Cannot declare a factory after done has been set to true."));const _=y(c.map(V=>V.name));{const V=_.filter(H=>H.localVersion!=null);if(V.length>0)throw new Error(n("Cannot declare a factory for already implemented contracts : "+V.map(H=>H.name).join(", ")))}for(let V=0;V<c.length;V++)_[V].localVersion=c[V].version;const G=y(p);S(_,G);const ee=a(_,G,h,E);m.push(ee),F()},declareCallback(c,p,h,E){const _=y(c),G=r(_,p,h,E);!T&&l.length===0&&G.isReady?G.invoke():(l.push(G),F())},get done(){return L},set done(c){if(L){if(!c)throw new Error(n("Cannot set done to false after it has been set to true."))}else c&&(L=!0,Object.values(s).forEach(p=>{p.localVersion==null&&(p.localVersion=0)}),F())}}}const vn=/^\d+$/;function pn(e){const[n,r,i]=e.split(":",3);if(r==null||i!=null||!vn.test(r))return null;const a=parseInt(r);return isNaN(a)||a===0?null:{name:n,version:a}}function mn(e){const n=gn(e);function r(i){return pt(e.name,i)}return{plug(i,a,s=void 0){if(n.done)throw new Error(r("Cannot plug after plugsDone."));s==null&&(s=a,a=[]);let m=!0;Array.isArray(i)||(i=[i],m=!1);const l=i.map(d=>{const v=pn(d);if(v==null)throw new Error(r("Invalid contract id : "+d));return v});n.declareFactory(l,a,s,m)},plugsDone(){n.done=!0},use(i,a){let s=!0;Array.isArray(i)||(i=[i],s=!1),n.declareCallback(i,a,s)},exec(i,a){let s=!0;return Array.isArray(i)||(i=[i],s=!1),new Promise((...m)=>{n.declareCallback(i,a,s,m)})},get(i){return i.map(a=>n.get(a).getLazyRemote())}}}const mt="app-agent";let Ae;function yn(e){return Ae!=null||(Ae=mn(ln(mt,e))),Ae}console.log(`[${mt}@1.0.12] loaded`);const rt=e=>{let n;const r=new Set,i=(v,u)=>{const y=typeof v=="function"?v(n):v;if(!Object.is(y,n)){const S=n;n=u??(typeof y!="object"||y===null)?y:Object.assign({},n,y),r.forEach(T=>T(n,S))}},a=()=>n,l={setState:i,getState:a,getInitialState:()=>d,subscribe:v=>(r.add(v),()=>r.delete(v))},d=n=e(i,a,l);return l},Cn=e=>e?rt(e):rt,Sn=e=>e;function hn(e,n=Sn){const r=R.useSyncExternalStore(e.subscribe,R.useCallback(()=>n(e.getState()),[e,n]),R.useCallback(()=>n(e.getInitialState()),[e,n]));return R.useDebugValue(r),r}const ot=e=>{const n=Cn(e),r=i=>hn(n,i);return Object.assign(r,n),r},yt=e=>e?ot(e):ot,bn=e=>(n,r,i)=>{const a=i.subscribe;return i.subscribe=(m,l,d)=>{let v=m;if(l){const u=d?.equalityFn||Object.is;let y=m(i.getState());v=S=>{const T=m(S);if(!u(y,T)){const I=y;l(y=T,I)}},d?.fireImmediately&&l(y,y)}return a(v)},e(n,r,i)},wn=bn,f=yt()(wn(e=>({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:n=>{e({getTextContentFunction:n})},setGetJsonContentFunction:n=>{e({getJsonContentFunction:n})},setGetJsonActivityContentFunction:n=>{e({getJsonActivityContentFunction:n})},setGetJsonAssignmentContentFunction:n=>{e({getJsonAssignmentContentFunction:n})},setGetJsonActivitySplitContentFunction:n=>{e({getJsonActivitySplitContentFunction:n})},setGetJsonAssignmentSplitContentFunction:n=>{e({getJsonAssignmentSplitContentFunction:n})},setSidebarActions:n=>{e({sidebarActions:n})},setQuickActions:n=>{e({quickActions:n})},setActivitySettingsCallback:n=>{e({activitySettingsCallback:n})},incSaveCount:()=>e(n=>({saveCount:n.saveCount+1})),incDirtyCount:()=>e(n=>({isDirtyCount:n.isDirtyCount+1}))})));let at=!1;const En=["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"],st={"mode:1":{setMode:e=>{f.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){f.setState({theme:null});return}if(e!=="light"&&e!=="dark"){console.warn(`Invalid theme: ${e}. Expected 'light' or 'dark'.`),f.setState({theme:null});return}f.setState({theme:e})}},"workflow:1":{setWorkflow:e=>{f.setState({workflow:e})}},"simple-content(text):1":{contentSaved:()=>{f.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},getContent:()=>f.getState().getTextContentFunction(),loadContent:e=>{f.setState({loadedTextContent:e})}},"simple-content(json):1":{contentSaved:()=>{f.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},getContent:()=>f.getState().getJsonContentFunction(),loadContent:e=>{f.setState({loadedJsonContent:e})}},"simple-binary-data(text):1":{contentSaved:()=>{f.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},getContent:()=>f.getState().getTextContentFunction(),loadContent:e=>{f.setState({loadedTextContent:e})}},"simple-content-eval(text):1":{contentSaved:()=>{f.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},getContent:()=>f.getState().getTextContentFunction(),loadContent:e=>{f.setState({loadedTextContent:e})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(text)")}},"simple-content-eval(json):1":{contentSaved:()=>{f.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},getContent:()=>f.getState().getJsonContentFunction(),loadContent:e=>{f.setState({loadedJsonContent:e})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(json)")}},"simple-content-eval(json):2":{contentSaved:()=>{f.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},getContent:()=>f.getState().getJsonContentFunction(),loadContent:e=>{f.setState({loadedJsonContent:e})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(json)")}},"simple-content-eval(text):2":{contentSaved:()=>{f.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},getContent:()=>f.getState().getTextContentFunction(),loadContent:e=>{f.setState({loadedTextContent:e})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(text)")}},"separate-contents(json):1":{contentSaved:()=>{f.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},loadContent:(e,n)=>{f.setState({loadedJsonActivityContent:e,loadedJsonAssignmentContent:n})},getActivityContent:()=>f.getState().getJsonActivityContentFunction(),getAssignmentContent:()=>f.getState().getJsonAssignmentContentFunction()},"separate-dual-contents(json):1":{contentSaved:()=>{f.setState(e=>({afterSaveCount:e.afterSaveCount+1}))},loadContent:({activityContent:e,assignmentContent:n,activityBinaryData:r,assignmentBinaryData:i})=>{f.setState({loadedJsonActivityContent:e,loadedJsonAssignmentContent:n,loadedJsonActivityBinaryData:r,loadedJsonAssignmentBinaryData:i})},getActivityContentAndData:()=>f.getState().getJsonActivitySplitContentFunction(),getAssignmentContentAndData:()=>f.getState().getJsonAssignmentSplitContentFunction()},"meta-player-anti-cheat:1":{lock:()=>{},unlock:()=>{}},"meta-player-ui:1":{executeAction(e){if(e.startsWith("qa")){const r=f.getState().quickActions[e];r?r():console.error(`Quick action not found: ${e}`)}else{const r=f.getState().sidebarActions[e];r?r():console.error(`Sidebar action not found: ${e}`)}},executeFileUpload(e,n){if(e.startsWith("qa")){const i=f.getState().quickActions[e];i?i(n):console.error(`Quick action not found: ${e}`)}else{const i=f.getState().sidebarActions[e];i?i(n):console.error(`Sidebar action not found: ${e}`)}},updateSettings(e){const n=f.getState().activitySettingsCallback;n?n(e):console.warn("activitySettingsCallback is not set. Changes:",e)}},"meta-player-events:1":{handleEvent(e){e==="all-loaded"&&f.setState({ready:!0})}}},M=yn();function An(e){if(at){console.warn("Contracts have already been plugged. Skipping.");return}at=!0;for(const n of e){if(!En.includes(n)){console.warn(`Contract ${n} is not implemented in Capytale. Skipping plug.`);continue}if(!(n in st)){console.warn(`Contract handler for ${n} is not defined. Skipping plug.`);continue}const r=st[n];M.plug([n],([])=>[r])}M.plugsDone();for(const n 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 ${n} is being subscribed to content changes.`),e.includes(n)){console.log(`Subscribing to content changes for contract ${n}`);const r=n.split(":")[0];M.use([r],([i])=>{f.subscribe(a=>a.isDirtyCount,()=>{i.i?.contentChanged(),console.log(`Content changed for contract ${r}`)})})}}const Rn=()=>f(e=>{if(e.mode===null)throw new Error("Mode is not set. Have you used contract 'mode'?");return e.mode}),kn=()=>f(e=>{if(e.workflow===null)throw new Error("Workflow is not set. Have you used contract 'workflow'?");return e.workflow}),Tn=()=>f(e=>{if(e.theme===null)throw new Error("Theme is not set. Have you used contract 'theme'?");return e.theme}),Fn=()=>f(e=>e.incSaveCount),xn=()=>f(e=>e.incDirtyCount),_n=()=>f(e=>e.loadedTextContent),Jn=()=>f(e=>e.loadedJsonContent),Pn=()=>f(e=>e.loadedJsonActivityContent),On=()=>f(e=>e.loadedJsonAssignmentContent),jn=()=>f(e=>e.loadedJsonActivityBinaryData),Dn=()=>f(e=>e.loadedJsonAssignmentBinaryData),In=()=>R.useCallback(()=>f.getState().loadedTextContent,[]),Ln=()=>R.useCallback(()=>f.getState().loadedJsonContent,[]),Vn=()=>R.useCallback(()=>f.getState().loadedJsonActivityContent,[]),Mn=()=>R.useCallback(()=>f.getState().loadedJsonAssignmentContent,[]),$n=()=>R.useCallback(()=>({content:f.getState().loadedJsonActivityContent,binaryData:f.getState().loadedJsonActivityBinaryData}),[]),Gn=()=>R.useCallback(()=>({content:f.getState().loadedJsonAssignmentContent,binaryData:f.getState().loadedJsonAssignmentBinaryData}),[]),Wn=e=>{const n=f(r=>r.setGetTextContentFunction);R.useEffect(()=>{n(e)},[e,n])},Nn=e=>{const n=f(r=>r.setGetJsonContentFunction);R.useEffect(()=>{n(e)},[e,n])},qn=e=>{const n=f(r=>r.setGetJsonActivityContentFunction);R.useEffect(()=>{n(e)},[e,n])},Un=e=>{const n=f(r=>r.setGetJsonAssignmentContentFunction);R.useEffect(()=>{n(e)},[e,n])},Bn=e=>{const n=f(r=>r.setGetJsonActivitySplitContentFunction);R.useEffect(()=>{n(e)},[e,n])},Yn=e=>{const n=f(r=>r.setGetJsonAssignmentSplitContentFunction);R.useEffect(()=>{n(e)},[e,n])},zn=e=>{const n=f(r=>r.afterSaveCount);R.useEffect(()=>{n>0&&e()},[n])},Hn=()=>(e,n)=>{M.use(["meta-player-ui"],([r])=>{if(r.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}r.i?.previewTextFile(e,n)})},Qn=()=>(e,n)=>{M.use(["meta-player-ui"],([r])=>{if(r.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}r.i?.previewImageFile(e,n)})};let ce=0,Re=0;const Kn=(e,n)=>{const r=R.useMemo(e,n),i=f(a=>a.setSidebarActions);R.useEffect(()=>(ce++,ce>1&&console.error("Capytale iframe React: Multiple sidebar actions registered: ",ce),()=>{ce--}),[]),R.useEffect(()=>(M.use(["meta-player-ui"],([a])=>{if(a.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}Re++;const s=r.map((l,d)=>({type:l.type,title:l.title,icon:l.icon,id:`sa-${Re}-${d}`,...l.type==="file-upload"?{accept:l.accept}:{}})),m={};r.forEach((l,d)=>{m[`sa-${Re}-${d}`]=l.action}),a.i?.setSidebarActionButtons(s),i(m)}),()=>{i({}),M.use(["meta-player-ui"],([a])=>{if(a.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}a.i?.setSidebarActionButtons([])})}),[r])};let le=0,ke=0;const Xn=(e,n)=>{const r=R.useMemo(e,n),i=f(a=>a.setQuickActions);R.useEffect(()=>(le++,le>1&&console.error("Capytale iframe React: Multiple quick actions registered: ",le),()=>{le--}),[]),R.useEffect(()=>(M.use(["meta-player-ui"],([a])=>{if(a.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}ke++;const s=r.map((l,d)=>({type:l.type,title:l.title,icon:l.icon,id:`qa-${ke}-${d}`,...l.type==="file-upload"?{accept:l.accept}:{}})),m={};r.forEach((l,d)=>{m[`qa-${ke}-${d}`]=l.action}),a.i?.setQuickActionButtons(s),i(m)}),()=>{i({}),M.use(["meta-player-ui"],([a])=>{if(a.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}a.i?.setQuickActionButtons([])})}),[r])};let ue=0;const Ct=(e,n,r)=>{const i=R.useMemo(e,r),a=f(s=>s.setActivitySettingsCallback);R.useEffect(()=>(console.log("Mounting useSettings"),ue++,ue>1&&console.error("Capytale iframe React: Multiple settings registered: ",ue),()=>{console.log("Unmounting useSettings"),ue--}),[]),R.useEffect(()=>(M.use(["meta-player-ui"],([s])=>{if(s.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}console.log("Updating settings UI in MetaPlayer",i),s.i?.setSettingsUI(i)}),a(n),()=>{a(null)}),[i])},Zn=()=>n=>{M.use(["meta-player-ui"],([r])=>{if(r.version===0){console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");return}r.i?.showToast(n)})};function er(e){const n={};for(const r of e.fields)n[r.name]=r.defaultValue;return n}function tr(e){return{[e.name]:e.defaultValues}}function nr(e){return{[e.name]:e.defaultValue}}function rr(e){switch(e.type){case"form":return er(e);case"checkboxes":case"switches":return tr(e);case"radio":return nr(e);default:return{}}}function or(e){const n={};for(const r of e)Object.assign(n,rr(r));return n}function ar(e){const r=yt()(i=>({...or(e)}));return r.activitySettings=e,r}function sr(e){Ct(()=>e.activitySettings,n=>{e.setState(n)},[])}function ir({store:e}){return sr(e),null}const cr=["meta-player-events:1","mode:1","workflow:1"];function lr({children:e,contracts:n,loadOnlyWhenReady:r=!0,activitySettingsStore:i}){const a=f(s=>s.ready);return R.useEffect(()=>{const s=[...n];for(const m of cr)s.includes(m)||s.push(m);An(s)},[]),r&&!a?se.jsx("div",{className:"capy-loading-container",children:"Chargement en cours..."}):se.jsxs(se.Fragment,{children:[i&&se.jsx(ir,{store:i}),e]})}exports.Capytale=lr;exports.createActivitySettingsStore=ar;exports.useAfterSaveAction=zn;exports.useGetLoadedJsonActivityContent=Vn;exports.useGetLoadedJsonActivitySplitContent=$n;exports.useGetLoadedJsonAssignmentContent=Mn;exports.useGetLoadedJsonAssignmentSplitContent=Gn;exports.useGetLoadedJsonContent=Ln;exports.useGetLoadedTextContent=In;exports.useJsonActivityContentSaveFunction=qn;exports.useJsonActivitySplitContentSaveFunction=Bn;exports.useJsonAssignmentContentSaveFunction=Un;exports.useJsonAssignmentSplitContentSaveFunction=Yn;exports.useJsonContentSaveFunction=Nn;exports.useLoadedJsonActivityBinaryData=jn;exports.useLoadedJsonActivityContent=Pn;exports.useLoadedJsonAssignmentBinaryData=Dn;exports.useLoadedJsonAssignmentContent=On;exports.useLoadedJsonContent=Jn;exports.useLoadedTextContent=_n;exports.useMode=Rn;exports.useNotifyIsDirty=xn;exports.usePreviewImageFile=Qn;exports.usePreviewTextFile=Hn;exports.useQuickActions=Xn;exports.useRequestSave=Fn;exports.useSettings=Ct;exports.useShowToast=Zn;exports.useSidebarActions=Kn;exports.useTextContentSaveFunction=Wn;exports.useTheme=Tn;exports.useWorkflow=kn;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),C=require("react");const X=Symbol("Comlink.proxy"),dt=Symbol("Comlink.endpoint"),ft=Symbol("Comlink.releaseProxy"),N=Symbol("Comlink.finalizer"),P=Symbol("Comlink.thrown"),Z=t=>typeof t=="object"&&t!==null||typeof t=="function",gt={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)}},mt={canHandle:t=>Z(t)&&P 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",gt],["throw",mt]]);function pt(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(!pt(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),m=c.reduce((y,S)=>y[S],t);switch(g){case"GET":d=m;break;case"SET":u[c.slice(-1)[0]]=k(o.data.value),d=!0;break;case"APPLY":d=m.apply(u,f);break;case"CONSTRUCT":{const y=new m(...f);d=st(y)}break;case"ENDPOINT":{const{port1:y,port2:S}=new MessageChannel;z(t,S),d=At(y,[y])}break;case"RELEASE":d=void 0;break;default:return}}catch(u){d={value:u,[P]:0}}Promise.resolve(d).catch(u=>({value:u,[P]:0})).then(u=>{const[m,y]=$(u);e.postMessage(Object.assign(Object.assign({},m),{id:r}),y),g==="RELEASE"&&(e.removeEventListener("message",s),et(e),N in t&&typeof t[N]=="function"&&t[N]())}).catch(u=>{const[m,y]=$({value:new TypeError("Unserializable return value"),[P]:0});e.postMessage(Object.assign(Object.assign({},m),{id:r}),y)})}),e.start&&e.start()}function yt(t){return t.constructor.name==="MessagePort"}function et(t){yt(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 V(t){if(t)throw new Error("Proxy has been released and is not useable")}function ot(t){return R(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 vt(t,e){const n=(I.get(e)||0)+1;I.set(e,n),j&&j.register(t,e,t)}function Ct(t){j&&j.unregister(t)}function H(t,e,n=[],s=function(){}){let o=!1;const r=new Proxy(s,{get(g,c){if(V(o),c===ft)return()=>{Ct(r),ot(t),e.clear(),o=!0};if(c==="then"){if(n.length===0)return{then:()=>r};const f=R(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){V(o);const[d,u]=$(f);return R(t,e,{type:"SET",path:[...n,c].map(m=>m.toString()),value:d},u).then(k)},apply(g,c,f){V(o);const d=n[n.length-1];if(d===dt)return R(t,e,{type:"ENDPOINT"}).then(k);if(d==="bind")return H(t,e,n.slice(0,-1));const[u,m]=U(f);return R(t,e,{type:"APPLY",path:n.map(y=>y.toString()),argumentList:u},m).then(k)},construct(g,c){V(o);const[f,d]=U(c);return R(t,e,{type:"CONSTRUCT",path:n.map(u=>u.toString()),argumentList:f},d).then(k)}});return vt(r,t),r}function St(t){return Array.prototype.concat.apply([],t)}function U(t){const e=t.map($);return[e.map(n=>n[0]),St(e.map(n=>n[1]))]}const rt=new WeakMap;function At(t,e){return rt.set(t,e),t}function st(t){return Object.assign(t,{[X]:!0})}function wt(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 R(t,e,n,s){return new Promise(o=>{const r=ht();e.set(r,o),t.start&&t.start(),t.postMessage(Object.assign({id:r},n),s)})}function ht(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}function bt(t,e){return t.length===0?e:`[${t}] ${e}`}function Et(t,e){let n=!1,s,o,r;function g(u){return bt(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,m,y){return Promise.resolve()}};else{const u=wt(window.parent,void 0,e);z({declare(m){if(s==null)throw new Error(g("No handler for declare"));s(m)},done(){if(o==null)throw new Error(g("No handler for done"));o()},provide(m,y,S){if(r==null)throw new Error(g("No handler for provide"));r(m,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,m,y)=>c.provide(u,m,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 Jt(t){return function(e){let n,s=!1,o=!1,r,g,c=!1,f=!1,d,u,m,y;function S(){if(r!=null&&r!==0&&g!=null)return g}function E(i){if(r!=null&&g!=null&&!(i>r))return g}function h(){return m??(f?m=Promise.resolve():m=new Promise((i,l)=>{y=i}))}function F(){return d===void 0&&(d={get name(){return e},get version(){return r},get i(){return S()},v:i=>E(i)}),d}function T(){return u===void 0&&(u={get name(){return e},get version(){return f?r:void 0},get i(){return f?S():void 0},v:i=>f?E(i):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(i){if(n!=null&&n!==i)throw new Error(t("A different local version is already set"));n=i},get localVersionSent(){return s},set localVersionSent(i){if(!i&&s)throw new Error(t("Local version already notified"));s=i,i&&n===0&&(o=!0)},get localInterfaceSent(){return o},set localInterfaceSent(i){if(n==null)throw new Error(t("Local version not set"));if(!i&&o)throw new Error(t("Local interface already sent."));o=i},get remoteVersion(){if(r!=null)return r},set remoteVersion(i){if(r!=null&&r!==i)throw new Error(t("A different remote version is already set for "+e+`(${r} -> ${i})`));r=i,i===0&&(c=!0)},get remoteVersionReceived(){return r!=null},setRemoteInterface:i=>{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=i,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:()=>T(),get activationPromise(){return h()}}}}function kt(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 m=n.length>0?n.map(y=>y.getRemote()):null;try{u=m==null?r(d):r(d,m)}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 Ft(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 it(t,e){return t==null||t.length===0?e:`[${t}] ${e}`}function xt(t){function e(i){return it(t.name,i)}const n=Ft(e),s=Jt(e),o=kt(e),r={},g=[];let c=[],f;const d=()=>(f==null?f=0:f++,f);function u(i){let l=r[i];return l==null&&(l=s(i),l.localVersion==null&&(h&&(l.localVersion=0),F&&(l.localVersionSent=!0)),l.remoteVersion==null&&T&&(l.remoteVersion=0),r[i]=l),l}function m(i){return i.map(u)}function y(...i){const l=d(),p=Array(l).fill(!1);i.forEach(v=>{v.forEach(A=>{A.depGroup!=null&&(p[A.depGroup]=!0),A.depGroup=l})}),Object.values(r).forEach(v=>{v.depGroup!=null&&v.depGroup!==l&&p[v.depGroup]&&(v.depGroup=l)})}t.onDeclare=i=>{const l=m(i.map(p=>p.name));for(let p=0;p<i.length;p++)i[p].version!=null&&(l[p].remoteVersion=i[p].version);y(l),J()},t.onDone=()=>{T||(T=!0,Object.values(r).forEach(i=>{i.remoteVersion==null&&(i.remoteVersion=0)}),J())},t.onProvide=(i,l,p)=>{let v=r[i];if(v==null)throw new Error(e(`Contract not declared : ${i}`));if(v.remoteVersion!=l)throw new Error(e(`Remote declared version ${v.remoteVersion} of contract "${i}" but provided version ${l}.`));if(v.remoteInterfaceReceived)throw new Error(e(`Remote contract "${i}" is already provided.`));v.setRemoteInterface(p),J()};let S=!1,E=!1,h=!1,F=!1,T=!1;async function J(){if(E=!0,!S){for(S=!0;E;){if(E=!1,t.isReady){const i=g.filter(l=>!l.isDeclared);if(i.length>0)for(const l of i){const p=Array(l.args.length+l.deps.length);l.args.forEach((v,A)=>p[A]=v),l.deps.forEach((v,A)=>p[A+l.args.length]=v),await t.declare(p.map(v=>({name:v.name,version:v.localVersion}))),p.forEach(v=>{v.localVersion!=null&&(v.localVersionSent=!0)}),l.isDeclared=!0}}if(t.isReady&&h&&g.every(i=>i.isDeclared)){const i=Object.values(r).filter(l=>!l.localVersionSent&&l.localVersion!=null);if(i.length>0)for(const l of i)await t.declare([{name:l.name,version:l.localVersion}]),l.localVersionSent=!0;F||(F=!0,await t.done())}if(t.isReady){const i=g.filter(l=>!l.isDone&&l.isReady);if(i.length>0)for(const l of i){const p=l.invoke();for(let v=0;v<l.args.length;v++){const A=l.args[v];await t.provide(A.name,A.localVersion,p[v]),A.localInterfaceSent=!0}}}if(f!=null){const i=Array(f+1).fill(null);for(const l in r){const p=r[l];p.depGroup!=null&&(p.isActivable?i[p.depGroup]==null&&!p.isActivated&&(i[p.depGroup]=!0):i[p.depGroup]=!1)}if(i.some(l=>l===!0))for(const l in r){const p=r[l];p.depGroup!=null&&i[p.depGroup]&&p.activate()}}if(t.isReady){const i=c;c=[];const l=[];for(const p of i)!p.isDone&&p.isReady?p.invoke():l.push(p);l.push(...c),c=l}}S=!1}}return{get(i){return u(i)},declareFactory:(i,l,p,v)=>{if(h)throw new Error(e("Cannot declare a factory after done has been set to true."));const A=m(i.map(b=>b.name));{const b=A.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<i.length;b++)A[b].localVersion=i[b].version;const x=m(l);y(A,x);const ut=o(A,x,p,v);g.push(ut),J()},declareCallback(i,l,p,v){const A=m(i),x=n(A,l,p,v);!S&&c.length===0&&x.isReady?x.invoke():(c.push(x),J())},get done(){return h},set done(i){if(h){if(!i)throw new Error(e("Cannot set done to false after it has been set to true."))}else i&&(h=!0,Object.values(r).forEach(l=>{l.localVersion==null&&(l.localVersion=0)}),J())}}}const Rt=/^\d+$/;function Tt(t){const[e,n,s]=t.split(":",3);if(n==null||s!=null||!Rt.test(n))return null;const o=parseInt(n);return isNaN(o)||o===0?null:{name:e,version:o}}function Lt(t){const e=xt(t);function n(s){return it(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=Tt(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 at="app-agent";let q;function Vt(t){return q!=null||(q=Lt(Et(at,t))),q}console.log(`[${at}@1.0.12] loaded`);const Q=t=>{let e;const n=new Set,s=(d,u)=>{const m=typeof d=="function"?d(e):d;if(!Object.is(m,e)){const y=e;e=u??(typeof m!="object"||m===null)?m:Object.assign({},e,m),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 Mt(t,e=Gt){const n=C.useSyncExternalStore(t.subscribe,C.useCallback(()=>e(t.getState()),[t,e]),C.useCallback(()=>e(t.getInitialState()),[t,e]));return C.useDebugValue(n),n}const _=t=>{const e=Dt(t),n=s=>Mt(e,s);return Object.assign(n,e),n},ct=t=>t?_(t):_,Pt=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 m=g(s.getState());d=y=>{const S=g(y);if(!u(m,S)){const E=m;c(m=S,E)}},f?.fireImmediately&&c(m,m)}return o(d)},t(e,n,s)},It=Pt,a=ct()(It(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 jt=["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=>{a.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){a.setState({theme:null});return}if(t!=="light"&&t!=="dark"){console.warn(`Invalid theme: ${t}. Expected 'light' or 'dark'.`),a.setState({theme:null});return}a.setState({theme:t})}},"workflow:1":{setWorkflow:t=>{a.setState({workflow:t})}},"simple-content(text):1":{contentSaved:()=>{a.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>a.getState().getTextContentFunction(),loadContent:t=>{a.setState({loadedTextContent:t})}},"simple-content(json):1":{contentSaved:()=>{a.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>a.getState().getJsonContentFunction(),loadContent:t=>{a.setState({loadedJsonContent:t})}},"simple-binary-data(text):1":{contentSaved:()=>{a.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>a.getState().getTextContentFunction(),loadContent:t=>{a.setState({loadedTextContent:t})}},"simple-content-eval(text):1":{contentSaved:()=>{a.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>a.getState().getTextContentFunction(),loadContent:t=>{a.setState({loadedTextContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(text)")}},"simple-content-eval(json):1":{contentSaved:()=>{a.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>a.getState().getJsonContentFunction(),loadContent:t=>{a.setState({loadedJsonContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(json)")}},"simple-content-eval(json):2":{contentSaved:()=>{a.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>a.getState().getJsonContentFunction(),loadContent:t=>{a.setState({loadedJsonContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(json)")}},"simple-content-eval(text):2":{contentSaved:()=>{a.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},getContent:()=>a.getState().getTextContentFunction(),loadContent:t=>{a.setState({loadedTextContent:t})},getAssignmentContent:()=>{throw new Error("getAssignmentContent is not implemented for simple-content-eval(text)")}},"separate-contents(json):1":{contentSaved:()=>{a.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},loadContent:(t,e)=>{a.setState({loadedJsonActivityContent:t,loadedJsonAssignmentContent:e})},getActivityContent:()=>a.getState().getJsonActivityContentFunction(),getAssignmentContent:()=>a.getState().getJsonAssignmentContentFunction()},"separate-dual-contents(json):1":{contentSaved:()=>{a.setState(t=>({afterSaveCount:t.afterSaveCount+1}))},loadContent:({activityContent:t,assignmentContent:e,activityBinaryData:n,assignmentBinaryData:s})=>{a.setState({loadedJsonActivityContent:t,loadedJsonAssignmentContent:e,loadedJsonActivityBinaryData:n,loadedJsonAssignmentBinaryData:s})},getActivityContentAndData:()=>a.getState().getJsonActivitySplitContentFunction(),getAssignmentContentAndData:()=>a.getState().getJsonAssignmentSplitContentFunction()},"meta-player-anti-cheat:1":{lock:()=>{},unlock:()=>{}},"meta-player-ui:1":{executeAction(t){if(t.startsWith("qa")){const n=a.getState().quickActions[t];n?n():console.error(`Quick action not found: ${t}`)}else{const n=a.getState().sidebarActions[t];n?n():console.error(`Sidebar action not found: ${t}`)}},executeFileUpload(t,e){if(t.startsWith("qa")){const s=a.getState().quickActions[t];s?s(e):console.error(`Quick action not found: ${t}`)}else{const s=a.getState().sidebarActions[t];s?s(e):console.error(`Sidebar action not found: ${t}`)}},updateSettings(t){const e=a.getState().activitySettingsCallback;e?e(t):console.warn("activitySettingsCallback is not set. Changes:",t)}},"meta-player-events:1":{handleEvent(t){t==="all-loaded"&&a.setState({ready:!0})}}},w=Vt();function $t(t){if(Y){console.warn("Contracts have already been plugged. Skipping.");return}Y=!0;for(const e of t){if(!jt.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];w.plug([e],([])=>[n])}w.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];w.use([n],([s])=>{a.subscribe(o=>o.isDirtyCount,()=>{s.i?.contentChanged(),console.log(`Content changed for contract ${n}`)})})}}const Ot=()=>a(t=>{if(t.mode===null)throw new Error("Mode is not set. Have you used contract 'mode'?");return t.mode}),Nt=()=>a(t=>{if(t.workflow===null)throw new Error("Workflow is not set. Have you used contract 'workflow'?");return t.workflow}),qt=()=>a(t=>{if(t.theme===null)throw new Error("Theme is not set. Have you used contract 'theme'?");return t.theme}),Bt=()=>a(t=>t.incSaveCount),Wt=()=>a(t=>t.incDirtyCount),Ht=()=>a(t=>t.loadedTextContent),zt=()=>a(t=>t.loadedJsonContent),Ut=()=>a(t=>t.loadedJsonActivityContent),Qt=()=>a(t=>t.loadedJsonAssignmentContent),_t=()=>a(t=>t.loadedJsonActivityBinaryData),Yt=()=>a(t=>t.loadedJsonAssignmentBinaryData),Kt=()=>C.useCallback(()=>a.getState().loadedTextContent,[]),Xt=()=>C.useCallback(()=>a.getState().loadedJsonContent,[]),Zt=()=>C.useCallback(()=>a.getState().loadedJsonActivityContent,[]),te=()=>C.useCallback(()=>a.getState().loadedJsonAssignmentContent,[]),ee=()=>C.useCallback(()=>({content:a.getState().loadedJsonActivityContent,binaryData:a.getState().loadedJsonActivityBinaryData}),[]),ne=()=>C.useCallback(()=>({content:a.getState().loadedJsonAssignmentContent,binaryData:a.getState().loadedJsonAssignmentBinaryData}),[]),oe=t=>{const e=a(n=>n.setGetTextContentFunction);C.useEffect(()=>{e(t)},[t,e])},re=t=>{const e=a(n=>n.setGetJsonContentFunction);C.useEffect(()=>{e(t)},[t,e])},se=t=>{const e=a(n=>n.setGetJsonActivityContentFunction);C.useEffect(()=>{e(t)},[t,e])},ie=t=>{const e=a(n=>n.setGetJsonAssignmentContentFunction);C.useEffect(()=>{e(t)},[t,e])},ae=t=>{const e=a(n=>n.setGetJsonActivitySplitContentFunction);C.useEffect(()=>{e(t)},[t,e])},ce=t=>{const e=a(n=>n.setGetJsonAssignmentSplitContentFunction);C.useEffect(()=>{e(t)},[t,e])},le=t=>{const e=a(n=>n.afterSaveCount);C.useEffect(()=>{e>0&&t()},[e])},ue=()=>(t,e)=>{w.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)})},de=()=>(t,e)=>{w.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 D=0,B=0;const fe=(t,e)=>{const n=C.useMemo(t,e),s=a(o=>o.setSidebarActions);C.useEffect(()=>(D++,D>1&&console.error("Capytale iframe React: Multiple sidebar actions registered: ",D),()=>{D--}),[]),C.useEffect(()=>(w.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({}),w.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 G=0,W=0;const ge=(t,e)=>{const n=C.useMemo(t,e),s=a(o=>o.setQuickActions);C.useEffect(()=>(G++,G>1&&console.error("Capytale iframe React: Multiple quick actions registered: ",G),()=>{G--}),[]),C.useEffect(()=>(w.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({}),w.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 M=0;const lt=(t,e,n)=>{const s=C.useMemo(t,n),o=a(r=>r.setActivitySettingsCallback);C.useEffect(()=>(console.log("Mounting useSettings"),M++,M>1&&console.error("Capytale iframe React: Multiple settings registered: ",M),()=>{console.log("Unmounting useSettings"),M--}),[]),C.useEffect(()=>(w.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])},me=()=>e=>{w.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?.showToast(e)})};function pe(t){const e={};for(const n of t.fields)e[n.name]=n.defaultValue;return e}function ye(t){return{[t.name]:t.defaultValues}}function ve(t){return{[t.name]:t.defaultValue}}function Ce(t){switch(t.type){case"form":return pe(t);case"checkboxes":case"switches":return ye(t);case"radio":return ve(t);default:return{}}}function Se(t){const e={};for(const n of t)Object.assign(e,Ce(n));return e}function Ae(t){const n=ct()(s=>({...Se(t)}));return n.activitySettings=t,n}function we(t){lt(()=>t.activitySettings,e=>{t.setState(e)},[])}function he({store:t}){return we(t),null}const be=["meta-player-events:1","mode:1","workflow:1"];function Ee({children:t,contracts:e,loadOnlyWhenReady:n=!0,activitySettingsStore:s}){const o=a(r=>r.ready);return C.useEffect(()=>{const r=[...e];for(const g of be)r.includes(g)||r.push(g);$t(r)},[]),n&&!o?L.jsx("div",{className:"capy-loading-container",children:"Chargement en cours..."}):L.jsxs(L.Fragment,{children:[s&&L.jsx(he,{store:s}),t]})}exports.Capytale=Ee;exports.createActivitySettingsStore=Ae;exports.useAfterSaveAction=le;exports.useGetLoadedJsonActivityContent=Zt;exports.useGetLoadedJsonActivitySplitContent=ee;exports.useGetLoadedJsonAssignmentContent=te;exports.useGetLoadedJsonAssignmentSplitContent=ne;exports.useGetLoadedJsonContent=Xt;exports.useGetLoadedTextContent=Kt;exports.useJsonActivityContentSaveFunction=se;exports.useJsonActivitySplitContentSaveFunction=ae;exports.useJsonAssignmentContentSaveFunction=ie;exports.useJsonAssignmentSplitContentSaveFunction=ce;exports.useJsonContentSaveFunction=re;exports.useLoadedJsonActivityBinaryData=_t;exports.useLoadedJsonActivityContent=Ut;exports.useLoadedJsonAssignmentBinaryData=Yt;exports.useLoadedJsonAssignmentContent=Qt;exports.useLoadedJsonContent=zt;exports.useLoadedTextContent=Ht;exports.useMode=Ot;exports.useNotifyIsDirty=Wt;exports.usePreviewImageFile=de;exports.usePreviewTextFile=ue;exports.useQuickActions=ge;exports.useRequestSave=Bt;exports.useSettings=lt;exports.useShowToast=me;exports.useSidebarActions=fe;exports.useTextContentSaveFunction=oe;exports.useTheme=qt;exports.useWorkflow=Nt;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { CapytaleContracts } from '@capytale/contracts';
|
|
2
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
4
|
+
import { StoreApi } from 'zustand';
|
|
5
|
+
|
|
6
|
+
export declare type Action = {
|
|
7
|
+
type: "action";
|
|
8
|
+
title: string;
|
|
9
|
+
icon: string;
|
|
10
|
+
action: () => any;
|
|
11
|
+
} | {
|
|
12
|
+
type: "file-upload";
|
|
13
|
+
accept?: string;
|
|
14
|
+
title: string;
|
|
15
|
+
icon: string;
|
|
16
|
+
action: (file: File) => any;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export declare type ActivitySettings = ActivitySettingsSection[];
|
|
20
|
+
|
|
21
|
+
declare type ActivitySettingsFormSection = {
|
|
22
|
+
type: "form";
|
|
23
|
+
fields: FormField[];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
declare type ActivitySettingsInput = {
|
|
27
|
+
type: "input";
|
|
28
|
+
inputType: "color" | "date" | "datetime-local" | "email" | "month" | "password" | "search" | "tel" | "text" | "time" | "url" | "week";
|
|
29
|
+
defaultValue: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
declare type ActivitySettingsMultipleOptionsSection = {
|
|
33
|
+
name: string;
|
|
34
|
+
type: "checkboxes" | "switches";
|
|
35
|
+
options: {
|
|
36
|
+
label: string;
|
|
37
|
+
value: string;
|
|
38
|
+
}[];
|
|
39
|
+
defaultValues: string[];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
declare type ActivitySettingsNumberInput = {
|
|
43
|
+
type: "input";
|
|
44
|
+
inputType: "number";
|
|
45
|
+
defaultValue: number;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
declare type ActivitySettingsOption = {
|
|
49
|
+
type: "checkbox" | "switch";
|
|
50
|
+
defaultValue: boolean;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
declare type ActivitySettingsRadioOptionsSection = {
|
|
54
|
+
name: string;
|
|
55
|
+
type: "radio";
|
|
56
|
+
options: {
|
|
57
|
+
label: string;
|
|
58
|
+
value: string;
|
|
59
|
+
}[];
|
|
60
|
+
defaultValue: string | null;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
declare type ActivitySettingsRange = {
|
|
64
|
+
type: "range";
|
|
65
|
+
min: number;
|
|
66
|
+
max: number;
|
|
67
|
+
step?: number;
|
|
68
|
+
defaultValue: number;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
declare type ActivitySettingsSection = (ActivitySettingsMultipleOptionsSection | ActivitySettingsRadioOptionsSection | ActivitySettingsFormSection) & {
|
|
72
|
+
title: string;
|
|
73
|
+
modes?: ("assignment" | "create" | "review" | "view")[];
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
declare type ActivitySettingsSelect = {
|
|
77
|
+
type: "select";
|
|
78
|
+
options: {
|
|
79
|
+
label: string;
|
|
80
|
+
value: string;
|
|
81
|
+
}[];
|
|
82
|
+
defaultValue: string;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
declare type ActivitySettingsTextArea = {
|
|
86
|
+
type: "textarea";
|
|
87
|
+
defaultValue: string;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
declare type AddId<C, I extends {
|
|
91
|
+
name: string;
|
|
92
|
+
variant?: string;
|
|
93
|
+
}> = I extends {
|
|
94
|
+
variant: string;
|
|
95
|
+
} ? C & {
|
|
96
|
+
name: `${I['name']}(${I['variant']})`;
|
|
97
|
+
} : C & {
|
|
98
|
+
name: I['name'];
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Un type utilitaire pour ajouter les propriétés d'identifications à un contrat
|
|
103
|
+
* ou à un tuple de contrats.
|
|
104
|
+
*
|
|
105
|
+
* @param C Le type de contrat ou de tuple de contrats.
|
|
106
|
+
* @param I Le nom et éventuellement la variante à ajouter.
|
|
107
|
+
*/
|
|
108
|
+
declare type AddIdData<C, I extends {
|
|
109
|
+
name: string;
|
|
110
|
+
variant?: string;
|
|
111
|
+
}> = C extends {}[] ? {
|
|
112
|
+
[Index in keyof C]: AddId<C[Index], I>;
|
|
113
|
+
} : AddId<C, I>;
|
|
114
|
+
|
|
115
|
+
declare type AllContractNames = keyof AllContracts;
|
|
116
|
+
|
|
117
|
+
declare type AllContracts = CapytaleContracts & CustomContracts;
|
|
118
|
+
|
|
119
|
+
export declare function Capytale<T extends ActivitySettings>({ children, contracts, loadOnlyWhenReady, activitySettingsStore, }: PropsWithChildren<CapytaleProps<T>>): JSX_2.Element;
|
|
120
|
+
|
|
121
|
+
declare type CapytaleProps<T extends ActivitySettings> = {
|
|
122
|
+
contracts: ContractNamesExceptForced[];
|
|
123
|
+
loadOnlyWhenReady?: boolean;
|
|
124
|
+
activitySettingsStore?: ReturnType<typeof createActivitySettingsStore<T>>;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Un type utilitaire pour indexer un ensemble de contrats par leur identifiant complet.
|
|
129
|
+
*
|
|
130
|
+
* @param T Un tuple de contrats.
|
|
131
|
+
*/
|
|
132
|
+
declare type CollectionOf<T extends {
|
|
133
|
+
name: string;
|
|
134
|
+
version: number;
|
|
135
|
+
}[]> = Indexed<IdContractTuple<T>>;
|
|
136
|
+
|
|
137
|
+
declare type ContractNamesExceptForced = Exclude<AllContractNames, ForcedContactNames>;
|
|
138
|
+
|
|
139
|
+
export declare function createActivitySettingsStore<T extends ActivitySettings>(as: T): {
|
|
140
|
+
(): InferValue<T>;
|
|
141
|
+
<U>(selector: (state: InferValue<T>) => U): U;
|
|
142
|
+
} & StoreApi<InferValue<T>> & {
|
|
143
|
+
activitySettings: T;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
declare type CustomContracts = CollectionOf<[
|
|
147
|
+
AddIdData<MetaPlayerAntiCheatV1, {
|
|
148
|
+
name: "meta-player-anti-cheat";
|
|
149
|
+
}>
|
|
150
|
+
]>;
|
|
151
|
+
|
|
152
|
+
declare type ForcedContactNames = "meta-player-events:1" | "mode:1" | "workflow:1";
|
|
153
|
+
|
|
154
|
+
declare type FormField = (ActivitySettingsRange | ActivitySettingsInput | ActivitySettingsNumberInput | ActivitySettingsTextArea | ActivitySettingsOption | ActivitySettingsSelect) & {
|
|
155
|
+
label: string;
|
|
156
|
+
name: string;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
declare type IdContractTuple<T extends {
|
|
160
|
+
name: string;
|
|
161
|
+
version: number;
|
|
162
|
+
}[]> = {
|
|
163
|
+
[Index in keyof T]: [IdOf<T[Index]>, T[Index]];
|
|
164
|
+
}[number];
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Un type qui représente un identifiant de contrat.
|
|
168
|
+
* Il est composé du nom du contrat et de sa version.
|
|
169
|
+
* Exemple: `content:1`
|
|
170
|
+
*
|
|
171
|
+
* @param C Le type de contrat.
|
|
172
|
+
*/
|
|
173
|
+
declare type IdOf<C extends {
|
|
174
|
+
name: string;
|
|
175
|
+
version: number;
|
|
176
|
+
}> = `${C['name']}:${C['version']}`;
|
|
177
|
+
|
|
178
|
+
declare type Indexed<L extends [string, unknown]> = {
|
|
179
|
+
[I in L[0]]: Extract<L, [I, any]>[1];
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
declare type InferFieldType<T> = T extends {
|
|
183
|
+
type: "checkboxes" | "switches";
|
|
184
|
+
options: readonly {
|
|
185
|
+
value: infer V;
|
|
186
|
+
}[];
|
|
187
|
+
} ? V[] : T extends {
|
|
188
|
+
type: "radio";
|
|
189
|
+
options: readonly {
|
|
190
|
+
value: infer V;
|
|
191
|
+
}[];
|
|
192
|
+
} ? V | null : T extends {
|
|
193
|
+
type: "select";
|
|
194
|
+
options: readonly {
|
|
195
|
+
value: infer V;
|
|
196
|
+
}[];
|
|
197
|
+
} ? V : T extends {
|
|
198
|
+
type: "input";
|
|
199
|
+
inputType: "number";
|
|
200
|
+
} ? number : T extends {
|
|
201
|
+
type: "input" | "textarea";
|
|
202
|
+
} ? string : T extends {
|
|
203
|
+
type: "range";
|
|
204
|
+
} ? number : T extends {
|
|
205
|
+
type: "checkbox" | "switch";
|
|
206
|
+
} ? boolean : never;
|
|
207
|
+
|
|
208
|
+
export declare type InferValue<T> = T extends readonly (infer Section)[] ? UnionToIntersection<Section extends {
|
|
209
|
+
type: "form";
|
|
210
|
+
fields: infer F extends readonly any[];
|
|
211
|
+
} ? UnionToIntersection<{
|
|
212
|
+
[K in keyof F]: F[K] extends {
|
|
213
|
+
name: infer N extends string;
|
|
214
|
+
} ? {
|
|
215
|
+
[P in N]: InferFieldType<F[K]>;
|
|
216
|
+
} : never;
|
|
217
|
+
}[number]> : Section extends {
|
|
218
|
+
name: infer N extends string;
|
|
219
|
+
} ? {
|
|
220
|
+
[P in N]: InferFieldType<Section>;
|
|
221
|
+
} : never> : never;
|
|
222
|
+
|
|
223
|
+
declare type MetaPlayerAntiCheatV1 = {
|
|
224
|
+
version: 1;
|
|
225
|
+
/**
|
|
226
|
+
* L'interface qui expose le *MetaPlayer* à l'*Application*.
|
|
227
|
+
*/
|
|
228
|
+
metaplayer: {
|
|
229
|
+
reportGainedFocus(): void;
|
|
230
|
+
reportLostFocus(): void;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* L'interface qui expose l'*Application* au *MetaPlayer*.
|
|
234
|
+
*/
|
|
235
|
+
application: {
|
|
236
|
+
lock(): void;
|
|
237
|
+
unlock(): void;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
declare type MPToastMessage = {
|
|
242
|
+
/**
|
|
243
|
+
* Severity of the message.
|
|
244
|
+
*/
|
|
245
|
+
severity?: "error" | "success" | "info" | "warn" | "secondary" | "contrast";
|
|
246
|
+
/**
|
|
247
|
+
* Summary content of the message.
|
|
248
|
+
*/
|
|
249
|
+
summary?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Detail content of the message.
|
|
252
|
+
*/
|
|
253
|
+
detail?: string;
|
|
254
|
+
/**
|
|
255
|
+
* Whether the message can be closed manually using the close icon.
|
|
256
|
+
*/
|
|
257
|
+
closable?: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* When enabled, message is not removed automatically.
|
|
260
|
+
*/
|
|
261
|
+
sticky?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Delay in milliseconds to close the message automatically.
|
|
264
|
+
*/
|
|
265
|
+
life?: number;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
269
|
+
|
|
270
|
+
export declare const useAfterSaveAction: (fn: () => any) => void;
|
|
271
|
+
|
|
272
|
+
export declare const useGetLoadedJsonActivityContent: () => () => any;
|
|
273
|
+
|
|
274
|
+
export declare const useGetLoadedJsonActivitySplitContent: () => () => {
|
|
275
|
+
content: any;
|
|
276
|
+
binaryData: any;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export declare const useGetLoadedJsonAssignmentContent: () => () => any;
|
|
280
|
+
|
|
281
|
+
export declare const useGetLoadedJsonAssignmentSplitContent: () => () => {
|
|
282
|
+
content: any;
|
|
283
|
+
binaryData: any;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
export declare const useGetLoadedJsonContent: () => () => any;
|
|
287
|
+
|
|
288
|
+
export declare const useGetLoadedTextContent: () => () => string | null;
|
|
289
|
+
|
|
290
|
+
export declare const useJsonActivityContentSaveFunction: (fn: () => any) => void;
|
|
291
|
+
|
|
292
|
+
export declare const useJsonActivitySplitContentSaveFunction: (fn: () => any) => void;
|
|
293
|
+
|
|
294
|
+
export declare const useJsonAssignmentContentSaveFunction: (fn: () => any) => void;
|
|
295
|
+
|
|
296
|
+
export declare const useJsonAssignmentSplitContentSaveFunction: (fn: () => any) => void;
|
|
297
|
+
|
|
298
|
+
export declare const useJsonContentSaveFunction: (fn: () => any) => void;
|
|
299
|
+
|
|
300
|
+
export declare const useLoadedJsonActivityBinaryData: () => any;
|
|
301
|
+
|
|
302
|
+
export declare const useLoadedJsonActivityContent: () => any;
|
|
303
|
+
|
|
304
|
+
export declare const useLoadedJsonAssignmentBinaryData: () => any;
|
|
305
|
+
|
|
306
|
+
export declare const useLoadedJsonAssignmentContent: () => any;
|
|
307
|
+
|
|
308
|
+
export declare const useLoadedJsonContent: () => any;
|
|
309
|
+
|
|
310
|
+
export declare const useLoadedTextContent: () => string | null;
|
|
311
|
+
|
|
312
|
+
export declare const useMode: () => "assignment" | "create" | "review" | "view";
|
|
313
|
+
|
|
314
|
+
export declare const useNotifyIsDirty: () => () => void;
|
|
315
|
+
|
|
316
|
+
export declare const usePreviewImageFile: () => (title: string, url: string) => void;
|
|
317
|
+
|
|
318
|
+
export declare const usePreviewTextFile: () => (title: string, content: string) => void;
|
|
319
|
+
|
|
320
|
+
export declare const useQuickActions: (actionsFn: () => Action[], deps: readonly unknown[]) => void;
|
|
321
|
+
|
|
322
|
+
export declare const useRequestSave: () => () => void;
|
|
323
|
+
|
|
324
|
+
export declare const useSettings: <T extends ActivitySettings>(settingsUiFn: () => T | null, callback: (changes: Partial<InferValue<T>>) => void, deps: readonly unknown[]) => void;
|
|
325
|
+
|
|
326
|
+
export declare const useShowToast: () => (message: MPToastMessage) => void;
|
|
327
|
+
|
|
328
|
+
export declare const useSidebarActions: (actionsFn: () => Action[], deps: readonly unknown[]) => void;
|
|
329
|
+
|
|
330
|
+
export declare const useTextContentSaveFunction: (fn: () => string | null | Promise<string | null>) => void;
|
|
331
|
+
|
|
332
|
+
export declare const useTheme: () => "light" | "dark";
|
|
333
|
+
|
|
334
|
+
export declare const useWorkflow: () => "current" | "finished" | "corrected";
|
|
335
|
+
|
|
336
|
+
export { }
|