@panomc/widget-host 1.1.0-dev.1 → 1.1.0
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/runtime/chunks/chunk-B64dhCzK.js +1 -0
- package/dist/runtime/chunks/{chunk-uTSPLXJn.js → chunk-B8GDD4Jh.js} +1 -1
- package/dist/runtime/chunks/{chunk-DDDEBZES.js → chunk-CxieYCZG.js} +1 -1
- package/dist/runtime/host/components-panel.js +1 -1
- package/dist/runtime/host/components-theme.js +1 -1
- package/dist/runtime/host/controllers.js +1 -1
- package/dist/runtime/host/index.js +1 -1
- package/dist/runtime/host/internal.js +1 -1
- package/dist/runtime/host/svelte.js +1 -1
- package/dist/runtime/host/utils-api.js +1 -1
- package/dist/runtime/host/utils-language.js +1 -1
- package/dist/runtime/host/variables.js +1 -1
- package/dist/runtime/loader.js +1 -1
- package/dist/runtime/runtime.json +4 -4
- package/dist/widget-runtime.zip +0 -0
- package/package.json +5 -5
- package/scripts/loader.js +7 -2
- package/src/__tests__/controllers.test.js +15 -0
- package/src/controllers.js +3 -2
- package/dist/runtime/chunks/chunk-Cmbb89rp.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t,n={}){return{ok:!1,status:e,error:{...n,code:t}}}function t(t,n){const o=n&&"object"==typeof n?n.error:void 0;if(o&&"object"==typeof o&&"string"==typeof o.code){const e={code:o.code};return"string"==typeof o.message&&(e.message=o.message),o.details&&"object"==typeof o.details&&(e.details=o.details),o.fields&&"object"==typeof o.fields&&(e.fields=o.fields),{ok:!1,status:t,error:e}}const r=e(t,`HTTP_${t}`);return"string"==typeof n&&n&&(r.error.message=n.slice(0,500)),r}const n="/api/v1/auth/csrf",o=new Set(["GET","HEAD","OPTIONS"]);function r(r){if(!r||"string"!=typeof r.baseUrl)throw new TypeError('createClient: options.baseUrl is required (Pano origin or proxy prefix, e.g. "/pano")');const s=r.baseUrl.replace(/\/+$/,""),a="undefined"!=typeof window&&"undefined"!=typeof document,i=r.credentials??(a?"include":"omit"),c=r.csrf??("include"!==i||r.sessionToken?"off":"auto");let f,l=null;async function u(e){const t={Accept:"application/json"};r.locale&&(t["Accept-Language"]=r.locale),r.frontendKey&&(t["X-Pano-Frontend-Key"]=r.frontendKey,r.clientIp&&(t["X-Pano-Client-Ip"]=r.clientIp));const n="function"==typeof r.sessionToken?await r.sessionToken():r.sessionToken;if(n&&(t.Authorization=`Bearer ${n}`),e)for(const[n,o]of Object.entries(e)){if(null==o)continue;const e=n.toLowerCase();"x-pano-frontend-key"!==e&&"x-pano-client-ip"!==e&&(t[n]=o)}return t}async function d(n,o,a,c,f,l){const u=r.fetch??globalThis.fetch;if("function"!=typeof u)return{result:e(0,"NETWORK_ERROR",{message:"No fetch implementation available"})};const d={method:n,headers:c,credentials:i};void 0!==f&&(d.body=f),l&&(d.signal=l);try{const e=await u(`${s}${o}${a}`,d),n=await async function(e){if(204===e.status||205===e.status)return;const t=await e.text();if(!t)return;if((e.headers.get("content-type")||"").includes("json")||/^\s*[[{]/.test(t))try{return JSON.parse(t)}catch{return t}return t}(e);return e.ok?{result:{ok:!0,status:e.status,data:n}}:{result:t(e.status,n)}}catch(t){const n="AbortError"===t?.name;return{result:e(0,"NETWORK_ERROR",{message:t instanceof Error?t.message:"Network request failed",...n?{details:{aborted:!0}}:{}})}}}function p(){return l||(l=(async()=>{try{const e=await u(void 0),{result:t}=await d("GET",n,"",e,void 0,void 0);if(t.ok){const e=t.data?.csrfToken;f="string"==typeof e?e:null}else 401===t.status&&(f=null)}finally{l=null}})()),l}return{request:async function(t,s={}){try{const i=String(t.method).toUpperCase(),l=function(e,t){let n=null;const o=e.replace(/\{([^}]+)\}/g,(e,o)=>{const r=t?.[o],s=null==r?"":String(r);return""===s||"."===s||".."===s?(n??=o,e):encodeURIComponent(s)});return null===n?{path:o}:{missing:n}}(t.path,s.path);if("missing"in l)return e(0,"INVALID_PATH_PARAM",{message:`Path parameter "${l.missing}" is missing, empty, "." or ".."`});const y=l.path,g=function(e){if(!e)return"";const t=new URLSearchParams;for(const[n,o]of Object.entries(e))if(null!=o)for(const e of Array.isArray(o)?o:[o])null!=e&&t.append(n,e instanceof Date?e.toISOString():String(e));const n=t.toString();return n?`?${n}`:""}(s.query),h=!o.has(i),m="auto"===c&&h&&y!==n;let v=s.body,b=!1;null==v||function(e){return"string"==typeof e||"undefined"!=typeof FormData&&e instanceof FormData||"undefined"!=typeof Blob&&e instanceof Blob||"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams||"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||"undefined"!=typeof ReadableStream&&e instanceof ReadableStream}(v)?null===v&&(v=void 0):(v=JSON.stringify(v),b=!0);const w=async e=>{const t=await u(s.headers);return b&&!Object.keys(t).some(e=>"content-type"===e.toLowerCase())&&(t["Content-Type"]="application/json"),e&&(t["X-CSRF-Token"]=e),d(i,y,g,t,v,s.signal)};m&&void 0===f&&await p();let{result:R}=await w(m?f:void 0);if(m&&!R.ok&&"INVALID_CSRF_TOKEN"===R.error.code&&(f=void 0,await p(),f&&({result:R}=await w(f))),R.ok)h&&y.startsWith("/api/v1/auth/")&&(f=void 0),(a=R.data)&&"object"==typeof a&&"string"==typeof a.csrfToken&&(f=a.csrfToken);else if(401===R.status&&r.onUnauthorized)try{r.onUnauthorized(R)}catch{}return R}catch(t){return e(0,"NETWORK_ERROR",{message:t instanceof Error?t.message:"Request failed before it was sent"})}var a},options:Object.freeze({...r})}}const s={apiBase:"",locale:void 0,urls:{},siteUrl:"",fetch:void 0,navigate:void 0,csrf:void 0};let a=null;const i=new Set;function c(e={}){void 0!==e.apiBase&&(s.apiBase=String(e.apiBase||"").replace(/\/+$/,"")),void 0!==e.locale&&(s.locale=e.locale||void 0),void 0!==e.urls&&(s.urls={...e.urls}),void 0!==e.siteUrl&&(s.siteUrl=String(e.siteUrl||"").replace(/\/+$/,"")),void 0!==e.fetch&&(s.fetch=e.fetch),void 0!==e.navigate&&(s.navigate=e.navigate),void 0!==e.csrf&&(s.csrf=e.csrf),a=null;for(const e of[...i])e(s);return f()}function f(){return{...s,csrf:s.csrf??(e=s.apiBase,e&&!/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?"off":"auto")};var e}function l(e){return i.add(e),()=>i.delete(e)}function u(...e){return(s.fetch??globalThis.fetch)(...e)}function d(){if(!a){const e=f();a=r({baseUrl:e.apiBase,fetch:(...e)=>u(...e),locale:e.locale,credentials:"include",csrf:e.csrf})}return a}function p(e,t){let n=s.urls[e]??e;return t&&(n=n.replace(/\{([^}]+)\}/g,(e,n)=>void 0===t[n]||null===t[n]?e:encodeURIComponent(String(t[n])))),/^[a-z][a-z0-9+.-]*:/i.test(n)||n.startsWith("//")?n:n.startsWith("/")&&s.siteUrl?`${s.siteUrl}${n}`:n}export{d as a,c,f as g,l as o,u as p,p as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{onMount as e}from"../svelte/index.js";import{c as n}from"./chunk-s84dpggu.js";import{g as t}from"./chunk-DLMzDTGN.js";import"./chunk-B5CK1uiS.js";import{_ as r,locale as o}from"../svelte-i18n.js";import{a as s,g as a,r as i}from"./chunk-Cmbb89rp.js";import{hostRequest as c}from"../host/utils-api.js";import{goto as l}from"../host/svelte.js";import{showToast as u}from"../host/toasts.js";const f=/^\/(?:api\/)?plugins\/[^/?#]+\/(?!_(?:[/?#]|$))[^?#]/,d=()=>{};function p(e,n){return n?`${e}?redirect=${encodeURIComponent(n)}`:e}function g(e={}){const n=e||{},t=String(n.baseUrl??"").replace(/\/+$/,""),r="boolean"==typeof n.browser?n.browser:"undefined"!=typeof window,o=(e,t)=>function(e,n){return n?e.replace(/\{\s*([\w.-]+)\s*\}/g,(e,t)=>t in n&&null!=n[t]?String(n[t]):e):e}(n.messages&&"string"==typeof n.messages[e]?n.messages[e]:e,t);return{baseUrl:t,browser:r,request:async function(e){try{const{method:r="GET",path:o="",query:s,body:a,headers:i,blob:c}=e||{},l=String(r).toUpperCase(),u=o.startsWith("/")||""===o?o:`/${o}`,d=f.test(u)?"/api":"/api/v1",p=`${t}${d}${u.replace(/^\/api(?=\/plugins\/)/,"")}${function(e){if(!e||"object"!=typeof e)return"";const n=new URLSearchParams;for(const[t,r]of Object.entries(e))if(null!=r)if(Array.isArray(r))for(const e of r)null!=e&&n.append(t,String(e));else n.append(t,String(r));const t=n.toString();return t?`?${t}`:""}(s)}`,g={Accept:"application/json"},h={method:l,headers:g},m=n.getToken?n.getToken():null;m?g.Authorization=`Bearer ${m}`:h.credentials="include";const y=n.getCsrf?n.getCsrf():null;y&&"GET"!==l&&"HEAD"!==l&&(g["X-CSRF-Token"]=y),null!=a&&"GET"!==l&&"HEAD"!==l&&(!function(e){return"string"==typeof e||"undefined"!=typeof FormData&&e instanceof FormData||"undefined"!=typeof Blob&&e instanceof Blob||"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams||"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))}(a)?(g["Content-Type"]="application/json",h.body=JSON.stringify(a)):h.body=a),i&&Object.assign(g,i);const b=await((...e)=>(n.fetch||globalThis.fetch)(...e))(p,h);if(c&&b.ok)return await b.blob();const w=await b.text();let v,$=!1;if(w)try{v=JSON.parse(w)}catch(e){$=!0}return b.ok?w?$?{error:{code:"INVALID_RESPONSE"}}:v:{}:!$&&v&&"object"==typeof v&&v.error?v:{error:{code:"UNKNOWN_ERROR",details:{status:b.status}}}}catch(e){return{error:{code:"NETWORK_ERROR"}}}},session(){let e=null;try{e=n.getSession&&n.getSession()?.user||null}catch(n){e=null}return{user:e,csrfToken:n.getCsrf&&n.getCsrf()||null}},locale:()=>"function"==typeof n.locale?n.locale():n.locale,onSession:e=>"function"==typeof n.onSession&&n.onSession(e)||d,t:o,toast(e,t){if(!n.onToast)return;const r=t&&t.values;n.onToast(e,{...t||{},message:o(e,r)})},storage:function(e){try{return"function"==typeof n.storage?n.storage(e)||null:n.storage&&"object"==typeof n.storage?n.storage[e]||null:r&&("session"===e?globalThis.sessionStorage:globalThis.localStorage)||null}catch(e){return null}},now:()=>n.now?n.now():Date.now(),navigate(e,t){if(n.onNavigate)return n.onNavigate(e,t);r&&"undefined"!=typeof location&&(t&&t.replace?location.replace(e):location.assign(e))},feature:e=>{const t=n.features;return!!t&&("function"==typeof t?!!t(e):Array.isArray(t)?t.includes(e):"function"==typeof t.has?!!t.has(e):!0===t[e])},loginUrl:e=>n.loginUrl?n.loginUrl(e):p("/login",e),registerUrl:e=>n.registerUrl?n.registerUrl(e):p("/register",e)}}const h="__PANO_CONTROLLERS__";function m(){let e=globalThis[h];return e||(e={defs:new Map,plugins:new Map,cache:new Map,pendingEager:[],pins:{},samples:null,sampleCache:new Map,hostFactory:null,browserHost:null,mismatch:[],warned:new Set},globalThis[h]=e),e}function y(){return"undefined"!=typeof window&&"undefined"!=typeof document}function b(e,n){const t=m();t.warned.has(e)||(t.warned.add(e),console.warn(n))}function w(e){return"instance"===e.scope?"instance":"app"}function v(e){try{e?.destroy?.()}catch(e){console.error("[PanoSDK] controller destroy failed",e)}}function $(e){const n=m();return n.hostFactory?y()?(n.browserHost||(n.browserHost=n.hostFactory(e)),n.browserHost):n.hostFactory(e):null}function S(e,n){const t=m(),r=t.defs.get(e);if(!r)return b(`missing:${e}`,`controller '${e}' is not registered - is ${function(e){const n=String(e).split("/")[0],t=m();return t.plugins.get(n)??`pano-plugin-${n}`}(e)} installed and enabled?`),null;const o=n?.version??t.pins[e];return null!=o&&o!==r.def.version?(b(`mismatch:${e}:${o}:${r.def.version}`,`'${e}' is at version ${r.def.version}, this theme was written for ${o} - run theme-core check`),function(e){const n=m();for(const t of[...n.mismatch])try{t(e)}catch(e){console.error("[PanoSDK] onMismatch listener failed",e)}}({kind:"controller",name:e,wanted:o,available:r.def.version}),null):r}function T(e,n,t,r,o){const s=m(),a=e.def,i=y()&&"app"===w(a);if(i&&s.cache.has(n))return s.cache.get(n);const c=a.create(r,t?.params??{},t?.initial,function(e,n){return{use(t){const r=`${e.namespace}/${t}`,o=m().defs.get(r);return o?T(o,r,{},n):null}}}(e,r));return i&&s.cache.set(n,c),c}function j(e){const n=m(),t=n.defs.get(e);if(!t||!t.def.eager||"app"!==w(t.def))return;const r=$();if(r)try{T(t,e,{},r)}catch(n){console.error(`[PanoSDK] eager controller '${e}' failed to start`,n)}else n.pendingEager.includes(e)||n.pendingEager.push(e)}function k(e,n,t){const r=m();r.plugins.set(n,e);const o=Array.isArray(t)?t.map(e=>[e?.name,e]):Object.entries(t??{}).map(([e,n])=>[n?.name??e,n]);for(const[t,s]of o){if(!s||"function"!=typeof s.create||!t){console.warn(`[PanoSDK] ${e}: skipped a controller definition without name or create()`);continue}const o=`${n}/${t}`;r.cache.has(o)&&(v(r.cache.get(o)),r.cache.delete(o)),r.defs.set(o,{def:s,pluginId:e,namespace:n,key:t}),r.warned.delete(`missing:${o}`),y()&&j(o)}}function O(){const e=m();for(const n of e.cache.values())v(n);e.cache.clear(),e.sampleCache.clear(),e.defs.clear(),e.plugins.clear(),e.pendingEager=[],e.warned.clear()}function U(e,n){const t=m(),r=S(e,n);if(!r)return null;if(t.samples)return t.sampleCache.has(e)||t.sampleCache.set(e,function(e,n,t){const r=e.def;if("function"==typeof r.createSample)return r.createSample(t??{});const o={baseUrl:"",browser:!1,request:async()=>({error:{code:"NULL_HOST"}}),session:()=>({user:null,csrfToken:null}),locale:()=>{},onSession:()=>()=>{},t:e=>e,toast:()=>{},storage:()=>null,now:()=>Date.now(),navigate:()=>{},feature:()=>!1,loginUrl:()=>"/login",registerUrl:()=>"/register"};let s=null,a={},i=[];try{s=r.create(o,{},void 0,{use:()=>null}),a=s.get()??{},i=Object.keys(s.actions??{})}catch(e){console.warn(`[PanoSDK] sample state of '${n}' could not read the initial state`,e)}finally{v(s)}const c={...a,...t??{}},l=[],u={};for(const e of i)u[e]=(...n)=>(l.push({name:e,args:n}),{ok:!0});return{name:n,version:r.version,get:()=>c,subscribe:e=>(e(c),()=>{}),actions:u,calls:l,destroy(){}}}(r,e,t.samples[e])),t.sampleCache.get(e);const o=$(n?.event);return o?T(r,e,n,o):(b("nohost","[PanoSDK] controllers.use() called before a host factory was set"),null)}async function A(e,n){const t=S(e,n);if(!t)return null;if("function"!=typeof t.def.load)return{};const r=$(n?.event);return r?t.def.load({host:r,params:n?.params??{}}):(b("nohost","[PanoSDK] controllers.load() called before a host factory was set"),null)}function E(e,n){const t=m().defs.get(e);return!!t&&(null==n||t.def.version===n)}function P(){return[...m().defs.entries()].map(([e,n])=>({name:e,version:n.def.version,pluginId:n.pluginId,scope:w(n.def)}))}function C(e){return m().plugins.get(e)}function R(e){const n=m();if(n.hostFactory="function"==typeof e?e:null,n.browserHost=null,n.hostFactory&&y()){const e=n.pendingEager;n.pendingEager=[];for(const n of e)j(n)}}function _(e){m().pins={...e??{}}}function D(e){const n=m();n.samples=e?{...e}:null,n.sampleCache.clear()}function N(e){const n=m();return n.mismatch.push(e),()=>{n.mismatch=n.mismatch.filter(n=>n!==e)}}const F={register:k,reset:O,use:U,load:A,has:E,list:P,pluginIdOf:C,setHostFactory:R,setThemePins:_,setSamples:D,onMismatch:N},H=Object.freeze(Object.defineProperty({__proto__:null,controllers:F,default:F,has:E,list:P,load:A,onMismatch:N,pluginIdOf:C,register:k,reset:O,setHostFactory:R,setSamples:D,setThemePins:_,use:U},Symbol.toStringTag,{value:"Module"})),I=Object.freeze({user:null,csrfToken:null});let M=I,K=null,L=!1;const B=new Set;function q(){return M}function z(e){L=!0,function(e){M=e;for(const e of[...B])try{e(M)}catch(e){console.error("[pano-widgets] session listener failed",e)}}({user:e?.user??null,csrfToken:e?.csrfToken??null})}function G(e=!1){return L&&!e?Promise.resolve(M):K||(K=(async()=>{try{const e=await s().request({method:"GET",path:"/api/v1/auth/credentials",auth:"none"});if(e.ok&&e.data&&"object"==typeof e.data){const{csrfToken:n,result:t,...r}=e.data;z({user:r,csrfToken:"string"==typeof n?n:null})}else z(I)}catch{z(I)}finally{K=null}return M})(),K)}const J=5e3;function x(e){return Array.isArray(e)?`[${e.map(x).join(",")}]`:e&&"object"==typeof e?`{${Object.keys(e).sort().map(n=>`${JSON.stringify(n)}:${x(e[n])}`).join(",")}}`:JSON.stringify(e)??"undefined"}function W({ttl:e=5e3,now:n=()=>Date.now()}={}){const t=new Map;return{run(r,o,s){const a=`${r}\0${x(o??{})}`,i=t.get(a);if(i&&(i.pending||n()-i.settledAt<e))return i.promise;let c;t.delete(a);try{c=Promise.resolve(s())}catch(e){c=Promise.reject(e)}const l={promise:c,pending:!0,settledAt:0};return t.set(a,l),c.then(e=>{null!=e?(l.pending=!1,l.settledAt=n()):t.get(a)===l&&t.delete(a)},()=>{t.get(a)===l&&t.delete(a)}),c},clear(){t.clear()},get size(){return t.size}}}const V=W();function X(){V.clear()}function Q(e){try{return("session"===e?globalThis.sessionStorage:globalThis.localStorage)||null}catch{return null}}function Y(){try{return t(o)||a().locale||void 0}catch{return a().locale||void 0}}function Z(e,n){try{return t(r)(e,{values:n})}catch{return e}}function ee(e,n){return a().urls[e]?i(e):i(n)}function ne(e,n){return n?`${e}${e.includes("?")?"&":"?"}redirect=${encodeURIComponent(n)}`:e}function te(e={}){const n={...g({baseUrl:a().apiBase,browser:!0}),request:e=>c(e),session:()=>q(),onSession:e=>function(e){return B.add(e),()=>B.delete(e)}(e),locale:Y,t:Z,toast:(e,n)=>{u(e,n?.values??{},void 0,n?.variant?{variant:n.variant}:void 0)},navigate:(e,n)=>{l(e,{replace:!!n?.replace})},storage:Q,feature:()=>!1,loginUrl:e=>ne(ee("auth.login","/login"),e),registerUrl:e=>ne(ee("auth.register","/register"),e),...e};return Object.defineProperty(n,"baseUrl",{get:()=>a().apiBase,enumerable:!0,configurable:!0}),n}let re=!1;function oe(){if(re)return;re=!0;const e=te();R(()=>e)}const se=new Map;function ae({pluginId:e,ns:n,url:t,module:r}){return se.has(e)||se.set(e,(async()=>{try{const o=r??await(import(t));return!!o?.controllers&&(oe(),k(e,n,o.controllers),!0)}catch(n){return console.warn(`[pano-widgets] controllers of ${e} could not be loaded`,n),!1}})()),se.get(e)}function ie(e){const t=n(n=>{let t=!1;const r=e.subscribe(()=>{t&&n()});return t=!0,r});return{controller:e,actions:e.actions,get state(){return t(),e.get()}}}function ce(n,t){oe();const r=U(n,t);if(!r)return null;if("instance"===P().find(e=>e.name===n)?.scope&&"undefined"!=typeof window)try{e(()=>()=>r.destroy())}catch{}return ie(r)}function le(e){const n=()=>C(e)??`pano-plugin-${e}`,t=()=>`plugins.${n()}.`,o=n=>`${e}/${n}`,s={subscribe(e){const n=t();return r.subscribe(t=>{e((e,r)=>t(`${n}${e}`,function(e){if(e&&"object"==typeof e)return"values"in e||"default"in e||"locale"in e||"format"in e?e:{values:e}}(r)))})}};return{get id(){return n()},namespace:e,get installed(){return void 0!==C(e)},_:s,toast:(e,n)=>u(`${t()}${e}`,n?.values??{},void 0,n?.variant?{variant:n.variant}:void 0),use:(e,n)=>ce(o(e),n),require(e,n){const t=ce(o(e),n);if(!t)throw new Error(`${o(e)} is not available`);return t},load(e,n){oe();const t=o(e);return V.run(t,n?.params,()=>A(t,n))}}}export{H as C,J as L,W as a,te as b,X as c,oe as d,G as e,q as g,ae as l,le as p,ie as r,z as s,ce as u};
|
|
1
|
+
import{onMount as e}from"../svelte/index.js";import{c as n}from"./chunk-s84dpggu.js";import{g as t}from"./chunk-DLMzDTGN.js";import"./chunk-B5CK1uiS.js";import{_ as r,locale as o}from"../svelte-i18n.js";import{a as s,g as a,r as i}from"./chunk-B64dhCzK.js";import{hostRequest as c}from"../host/utils-api.js";import{goto as l}from"../host/svelte.js";import{showToast as u}from"../host/toasts.js";const f=/^\/(?:api\/)?plugins\/[^/?#]+\/(?!_(?:[/?#]|$))[^?#]/,p=()=>{};function d(e,n){return n?`${e}?redirect=${encodeURIComponent(n)}`:e}function g(e={}){const n=e||{},t=String(n.baseUrl??"").replace(/\/+$/,""),r="boolean"==typeof n.browser?n.browser:"undefined"!=typeof window,o=(e,t)=>function(e,n){return n?e.replace(/\{\s*([\w.-]+)\s*\}/g,(e,t)=>t in n&&null!=n[t]?String(n[t]):e):e}(n.messages&&"string"==typeof n.messages[e]?n.messages[e]:e,t);return{baseUrl:t,browser:r,request:async function(e){try{const{method:r="GET",path:o="",query:s,body:a,headers:i,blob:c}=e||{},l=String(r).toUpperCase(),u=o.startsWith("/")||""===o?o:`/${o}`,p=f.test(u)?"/api":"/api/v1",d=`${t}${p}${u.replace(/^\/api(?=\/plugins\/)/,"")}${function(e){if(!e||"object"!=typeof e)return"";const n=new URLSearchParams;for(const[t,r]of Object.entries(e))if(null!=r)if(Array.isArray(r))for(const e of r)null!=e&&n.append(t,String(e));else n.append(t,String(r));const t=n.toString();return t?`?${t}`:""}(s)}`,g={Accept:"application/json"},h={method:l,headers:g},m=n.getToken?n.getToken():null;m?g.Authorization=`Bearer ${m}`:h.credentials="include";const y=n.getCsrf?n.getCsrf():null;y&&"GET"!==l&&"HEAD"!==l&&(g["X-CSRF-Token"]=y),null!=a&&"GET"!==l&&"HEAD"!==l&&(!function(e){return"string"==typeof e||"undefined"!=typeof FormData&&e instanceof FormData||"undefined"!=typeof Blob&&e instanceof Blob||"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams||"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))}(a)?(g["Content-Type"]="application/json",h.body=JSON.stringify(a)):h.body=a),i&&Object.assign(g,i);const b=await((...e)=>(n.fetch||globalThis.fetch)(...e))(d,h);if(c&&b.ok)return await b.blob();const w=await b.text();let v,$=!1;if(w)try{v=JSON.parse(w)}catch(e){$=!0}return b.ok?w?$?{error:{code:"INVALID_RESPONSE"}}:v:{}:!$&&v&&"object"==typeof v&&v.error?v:{error:{code:"UNKNOWN_ERROR",details:{status:b.status}}}}catch(e){return{error:{code:"NETWORK_ERROR"}}}},session(){let e=null;try{e=n.getSession&&n.getSession()?.user||null}catch(n){e=null}return{user:e,csrfToken:n.getCsrf&&n.getCsrf()||null}},locale:()=>"function"==typeof n.locale?n.locale():n.locale,onSession:e=>"function"==typeof n.onSession&&n.onSession(e)||p,t:o,toast(e,t){if(!n.onToast)return;const r=t&&t.values;n.onToast(e,{...t||{},message:o(e,r)})},storage:function(e){try{return"function"==typeof n.storage?n.storage(e)||null:n.storage&&"object"==typeof n.storage?n.storage[e]||null:r&&("session"===e?globalThis.sessionStorage:globalThis.localStorage)||null}catch(e){return null}},now:()=>n.now?n.now():Date.now(),navigate(e,t){if(n.onNavigate)return n.onNavigate(e,t);r&&"undefined"!=typeof location&&(t&&t.replace?location.replace(e):location.assign(e))},feature:e=>{const t=n.features;return!!t&&("function"==typeof t?!!t(e):Array.isArray(t)?t.includes(e):"function"==typeof t.has?!!t.has(e):!0===t[e])},loginUrl:e=>n.loginUrl?n.loginUrl(e):d("/login",e),registerUrl:e=>n.registerUrl?n.registerUrl(e):d("/register",e)}}const h="__PANO_CONTROLLERS__";function m(){let e=globalThis[h];return e||(e={defs:new Map,plugins:new Map,cache:new Map,pendingEager:[],pins:{},samples:null,sampleCache:new Map,hostFactory:null,browserHost:null,mismatch:[],warned:new Set},globalThis[h]=e),e}function y(){return"undefined"!=typeof window&&"undefined"!=typeof document}function b(e,n){const t=m();t.warned.has(e)||(t.warned.add(e),console.warn(n))}function w(e){return"instance"===e.scope?"instance":"app"}function v(e){try{e?.destroy?.()}catch(e){console.error("[PanoSDK] controller destroy failed",e)}}function $(e){const n=m();return n.hostFactory?y()?(n.browserHost||(n.browserHost=n.hostFactory(e)),n.browserHost):n.hostFactory(e):null}function S(e,n){const t=m(),r=t.defs.get(e);if(!r)return b(`missing:${e}`,`controller '${e}' is not registered - is ${function(e){const n=String(e).split("/")[0],t=m();return t.plugins.get(n)??`pano-plugin-${n}`}(e)} installed and enabled?`),null;const o=n?.version??t.pins[e];return null!=o&&o!==r.def.version?(b(`mismatch:${e}:${o}:${r.def.version}`,`'${e}' is at version ${r.def.version}, this theme was written for ${o} - run theme-core check`),function(e){const n=m();for(const t of[...n.mismatch])try{t(e)}catch(e){console.error("[PanoSDK] onMismatch listener failed",e)}}({kind:"controller",name:e,wanted:o,available:r.def.version}),null):r}function T(e,n,t,r,o){const s=m(),a=e.def,i=y()&&"app"===w(a);if(i&&s.cache.has(n))return s.cache.get(n);const c=a.create(r,t?.params??{},t?.initial,function(e,n){return{use(t){const r=`${e.namespace}/${t}`,o=m().defs.get(r);return o?T(o,r,{},n):null}}}(e,r));return i&&s.cache.set(n,c),c}function j(e){const n=m(),t=n.defs.get(e);if(!t||!t.def.eager||"app"!==w(t.def))return;const r=$();if(r)try{T(t,e,{},r)}catch(n){console.error(`[PanoSDK] eager controller '${e}' failed to start`,n)}else n.pendingEager.includes(e)||n.pendingEager.push(e)}function k(e,n,t){const r=m();r.plugins.set(n,e);const o=Array.isArray(t)?t.map(e=>[e?.name,e]):Object.entries(t??{}).map(([e,n])=>[n?.name??e,n]);for(const[t,s]of o){if(!s||"function"!=typeof s.create||!t){console.warn(`[PanoSDK] ${e}: skipped a controller definition without name or create()`);continue}const o=`${n}/${t}`;r.cache.has(o)&&(v(r.cache.get(o)),r.cache.delete(o)),r.defs.set(o,{def:s,pluginId:e,namespace:n,key:t}),r.warned.delete(`missing:${o}`),y()&&j(o)}}function O(){const e=m();for(const n of e.cache.values())v(n);e.cache.clear(),e.sampleCache.clear(),e.defs.clear(),e.plugins.clear(),e.pendingEager=[],e.warned.clear()}function U(e,n){const t=m(),r=S(e,n);if(!r)return null;if(t.samples)return t.sampleCache.has(e)||t.sampleCache.set(e,function(e,n,t){const r=e.def;if("function"==typeof r.createSample)return r.createSample(t??{});const o={baseUrl:"",browser:!1,request:async()=>({error:{code:"NULL_HOST"}}),session:()=>({user:null,csrfToken:null}),locale:()=>{},onSession:()=>()=>{},t:e=>e,toast:()=>{},storage:()=>null,now:()=>Date.now(),navigate:()=>{},feature:()=>!1,loginUrl:()=>"/login",registerUrl:()=>"/register"};let s=null,a={},i=[];try{s=r.create(o,{},void 0,{use:()=>null}),a=s.get()??{},i=Object.keys(s.actions??{})}catch(e){console.warn(`[PanoSDK] sample state of '${n}' could not read the initial state`,e)}finally{v(s)}const c={...a,...t??{}},l=[],u={};for(const e of i)u[e]=(...n)=>(l.push({name:e,args:n}),{ok:!0});return{name:n,version:r.version,get:()=>c,subscribe:e=>(e(c),()=>{}),actions:u,calls:l,destroy(){}}}(r,e,t.samples[e])),t.sampleCache.get(e);const o=$(n?.event);return o?T(r,e,n,o):(b("nohost","[PanoSDK] controllers.use() called before a host factory was set"),null)}async function A(e,n){const t=S(e,n);if(!t)return null;if("function"!=typeof t.def.load)return{};const r=$(n?.event);return r?t.def.load({host:r,params:n?.params??{}}):(b("nohost","[PanoSDK] controllers.load() called before a host factory was set"),null)}function E(e,n){const t=m().defs.get(e);return!!t&&(null==n||t.def.version===n)}function P(){return[...m().defs.entries()].map(([e,n])=>({name:e,version:n.def.version,pluginId:n.pluginId,scope:w(n.def)}))}function C(e){return m().plugins.get(e)}function R(e){const n=m();if(n.hostFactory="function"==typeof e?e:null,n.browserHost=null,n.hostFactory&&y()){const e=n.pendingEager;n.pendingEager=[];for(const n of e)j(n)}}function _(e){m().pins={...e??{}}}function D(e){const n=m();n.samples=e?{...e}:null,n.sampleCache.clear()}function N(e){const n=m();return n.mismatch.push(e),()=>{n.mismatch=n.mismatch.filter(n=>n!==e)}}const F={register:k,reset:O,use:U,load:A,has:E,list:P,pluginIdOf:C,setHostFactory:R,setThemePins:_,setSamples:D,onMismatch:N},H=Object.freeze(Object.defineProperty({__proto__:null,controllers:F,default:F,has:E,list:P,load:A,onMismatch:N,pluginIdOf:C,register:k,reset:O,setHostFactory:R,setSamples:D,setThemePins:_,use:U},Symbol.toStringTag,{value:"Module"})),I=Object.freeze({user:null,csrfToken:null});let M=I,K=null,L=!1;const B=new Set;function q(){return M}function z(e){L=!0,function(e){M=e;for(const e of[...B])try{e(M)}catch(e){console.error("[pano-widgets] session listener failed",e)}}({user:e?.user??null,csrfToken:e?.csrfToken??null})}function G(e=!1){return L&&!e?Promise.resolve(M):K||(K=(async()=>{try{const e=await s().request({method:"GET",path:"/api/v1/auth/credentials",auth:"none"});if(e.ok&&e.data&&"object"==typeof e.data){const{csrfToken:n,result:t,...r}=e.data;z({user:r,csrfToken:"string"==typeof n?n:null})}else z(I)}catch{z(I)}finally{K=null}return M})(),K)}const J=5e3;function x(e){return Array.isArray(e)?`[${e.map(x).join(",")}]`:e&&"object"==typeof e?`{${Object.keys(e).sort().map(n=>`${JSON.stringify(n)}:${x(e[n])}`).join(",")}}`:JSON.stringify(e)??"undefined"}function W({ttl:e=5e3,now:n=()=>Date.now()}={}){const t=new Map;return{run(r,o,s){const a=`${r}\0${x(o??{})}`,i=t.get(a);if(i&&(i.pending||n()-i.settledAt<e))return i.promise;let c;t.delete(a);try{c=Promise.resolve(s())}catch(e){c=Promise.reject(e)}const l={promise:c,pending:!0,settledAt:0};return t.set(a,l),c.then(e=>{null!=e?(l.pending=!1,l.settledAt=n()):t.get(a)===l&&t.delete(a)},()=>{t.get(a)===l&&t.delete(a)}),c},clear(){t.clear()},get size(){return t.size}}}const V=W();function X(){V.clear()}function Q(e){try{return("session"===e?globalThis.sessionStorage:globalThis.localStorage)||null}catch{return null}}function Y(){try{return t(o)||a().locale||void 0}catch{return a().locale||void 0}}function Z(e,n){try{return t(r)(e,{values:n})}catch{return e}}function ee(e,n){return a().urls[e]?i(e):i(n)}function ne(e,n){return n?`${e}${e.includes("?")?"&":"?"}redirect=${encodeURIComponent(n)}`:e}function te(e={}){const n={...g({baseUrl:a().apiBase,browser:!0}),request:e=>c(e),session:()=>q(),onSession:e=>function(e){return B.add(e),()=>B.delete(e)}(e),locale:Y,t:Z,toast:(e,n)=>{u(e,n?.values??{},void 0,n?.variant?{variant:n.variant}:void 0)},navigate:(e,n)=>{l(e,{replace:!!n?.replace})},storage:Q,feature:()=>!1,loginUrl:e=>ne(ee("auth.login","/login"),e),registerUrl:e=>ne(ee("auth.register","/register"),e),...e};return Object.defineProperty(n,"baseUrl",{get:()=>a().apiBase,enumerable:!0,configurable:!0}),n}let re=!1;function oe(){if(re)return;re=!0;const e=te();R(()=>e)}const se=new Map;function ae({pluginId:e,ns:n,url:t,module:r}){return se.has(e)||se.set(e,(async()=>{try{const o=r??await(import(t));return!!o?.controllers&&(oe(),k(e,n,o.controllers),!0)}catch(n){return console.warn(`[pano-widgets] controllers of ${e} could not be loaded`,n),!1}})()),se.get(e)}function ie(e){const t=n(n=>{let t=!1;const r=e.subscribe(()=>{t&&n()});return t=!0,r});return{controller:e,actions:e.actions,get state(){return t(),e.get()}}}function ce(n,t){oe();const r=U(n,t);if(!r)return null;if("instance"===P().find(e=>e.name===n)?.scope&&"undefined"!=typeof window)try{e(()=>()=>r.destroy())}catch{}return ie(r)}function le(e){const n=()=>C(e)??`pano-plugin-${e}`,t=()=>`plugins.${n()}.`,o=n=>`${e}/${n}`,s={subscribe(e){const n=t();return r.subscribe(t=>{e((e,r)=>t(`${n}${e}`,function(e){if(e&&"object"==typeof e)return"values"in e||"default"in e||"locale"in e||"format"in e?e:{values:e}}(r)))})}};return{get id(){return n()},namespace:e,get installed(){return void 0!==C(e)},_:s,toast:(e,n)=>u(`${t()}${e}`,n?.values??{},void 0,n?.variant?{variant:n.variant}:void 0),use:(e,n)=>ce(o(e),n),require(e,n){const t=ce(o(e),n);if(!t)throw new Error(`${o(e)} is not available`);return t},load(e,n){oe();const t=o(e);return V.run(t,{params:n?.params??{},version:n?.version??null},()=>A(t,n))}}}export{H as C,J as L,W as a,te as b,X as c,oe as d,G as e,q as g,ae as l,le as p,ie as r,z as s,ce as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../svelte/internal-disclose-version.js";import{k as a,$ as t,a0 as e,a2 as s,a4 as i,an as n,a3 as o,n as r,g as l,a1 as c,_ as d}from"./chunk-DQhQpYBr.js";import{b as u,f as v,s as m,d as g,t as p}from"./chunk-dcWYlI_G.js";import{s as f}from"./chunk-Bkf3iLx0.js";import{p as h,b,d as y,s as k,i as x,a as j,c as w,e as $}from"./chunk-BwMumrfI.js";import"./chunk-B5CK1uiS.js";import{translate as C,currentLanguage as T}from"../host/utils-language.js";import{g as D}from"./chunk-
|
|
1
|
+
import"../svelte/internal-disclose-version.js";import{k as a,$ as t,a0 as e,a2 as s,a4 as i,an as n,a3 as o,n as r,g as l,a1 as c,_ as d}from"./chunk-DQhQpYBr.js";import{b as u,f as v,s as m,d as g,t as p}from"./chunk-dcWYlI_G.js";import{s as f}from"./chunk-Bkf3iLx0.js";import{p as h,b,d as y,s as k,i as x,a as j,c as w,e as $}from"./chunk-BwMumrfI.js";import"./chunk-B5CK1uiS.js";import{translate as C,currentLanguage as T}from"../host/utils-language.js";import{g as D}from"./chunk-B64dhCzK.js";import{createEventDispatcher as I}from"../svelte/index.js";import{d as P,a as F}from"./chunk-C8W1Nv_i.js";function M(){}var N=v('<div class="card opacity-50 bg-transparent border-none"><div class="card-body vstack gap-3 text-center"><span></span> <p class="mb-0"> </p> <!></div></div>');function L(l,c){e(c,!0);let d=h(c,"icon",3,"fa-solid fa-square fa-3x"),v=h(c,"text",19,()=>C("components.no-content.text","No content"));var g=N(),p=s(g),k=s(p),x=i(k,2),j=n(x,!0),w=i(x,2);f(w,()=>c.children??r),o(p),o(g),a(()=>{b(k,1,y(d())),m(j,v())}),u(l,g),t()}var S=v("<span><!></span>");function q(i,n){e(n,!0);const[r,v]=k();let b=h(n,"relativeFormat",3,!1);const y=c(()=>w(T,"$currentLanguage",r)?.code??D().locale??void 0),$=c(()=>new Date(parseInt(n.time))),C=c(()=>new Intl.DateTimeFormat(l(y),{dateStyle:"short",timeStyle:"short"}).format(l($))),I=c(()=>{if(!b())return new Intl.DateTimeFormat(l(y),{day:"2-digit",month:"long",year:"numeric"}).format(l($));const a=Math.round((l($).getTime()-Date.now())/1e3),t=[["year",31536e3],["month",2592e3],["day",86400],["hour",3600],["minute",60]],e=new Intl.RelativeTimeFormat(l(y),{numeric:"auto"});for(const[s,i]of t)if(Math.abs(a)>=i)return e.format(Math.round(a/i),s);return e.format(a,"second")});var P=S(),F=s(P),M=a=>{var t=g(),e=d(t);f(e,()=>n.children),u(a,t)},N=t=>{var e=p();a(()=>m(e,l(I))),u(t,e)};x(F,a=>{n.children?a(M):a(N,-1)}),o(P),a(()=>j(P,"title",l(C))),u(i,P),t(),v()}var A=v('<div role="alert" aria-live="assertive" aria-atomic="true"><div class="toast-body"><!></div></div>');function E(t,e){let i=h(e,"variant",3,null);const n={success:"text-success",danger:"text-danger"},d=c(()=>n[i()]??"");var v=A(),m=s(v),g=s(m);f(g,()=>e.children??r),o(m),o(v),a(()=>{j(v,"id",`appToast${e.id??""}`),b(v,1,`toast show align-items-center shadow-lg text-bg-tertiary opacity-100 ${l(d)??""}`)}),u(t,v)}var R=v("<div><!></div>"),_=v('<div class="row d-flex align-items-center gy-3 justify-content-lg-between justify-content-center"><!> <!> <!></div>');function z(t,e){let n=h(e,"leftClasses",3,void 0),l=h(e,"middleClasses",3,void 0),c=h(e,"rightClasses",3,void 0);var d=_(),v=s(d),m=t=>{var i=R(),l=s(i);f(l,()=>e.left??r),o(i),a(()=>b(i,1,`col-lg-auto col-12 d-flex justify-content-lg-start overflow-x-auto ${(n()||"")??""}`)),u(t,i)};x(v,a=>{null===n()||!e.left&&void 0===n()||a(m)});var g=i(v,2),p=t=>{var i=R(),n=s(i);f(n,()=>e.middle??r),o(i),a(()=>b(i,1,`col-lg-auto col-12 order-lg-2 order-last d-flex justify-content-center overflow-x-auto ${(l()||"")??""}`)),u(t,i)};x(g,a=>{null===l()||!e.middle&&void 0===l()||a(p)});var y=i(g,2),k=t=>{var i=R(),n=s(i);f(n,()=>e.right??r),o(i),a(()=>b(i,1,`col-lg-auto col-12 order-3 d-flex justify-content-lg-end overflow-x-auto ${(c()||"")??""}`)),u(t,i)};x(y,a=>{null===c()||!e.right&&void 0===c()||a(k)}),o(d),u(t,d)}var B=v('<li><button type="button" class="page-link"> </button></li>'),G=v('<nav><ul class="pagination pagination-sm mb-0 justify-content-start flex-wrap"><li><button type="button" class="page-link"><i class="fa-solid fa-caret-left"></i></button></li> <!> <li><button type="button" class="page-link"><i class="fa-solid fa-caret-right"></i></button></li></ul></nav>');function H(r,d){e(d,!0);const v=I();let g=h(d,"page",3,1),p=h(d,"totalPage",3,1);const f=c(()=>Array.from({length:p()},(a,t)=>t+1)),y=c(()=>parseInt(g()));var k=G(),x=s(k),w=s(x);let T;var D=n(w),P=i(w,2);$(P,16,()=>l(f),a=>a,(t,e)=>{var i=B();let r;var c=s(i),d=n(c,!0);o(i),a(()=>{r=b(i,1,"page-item",null,r,{active:l(y)===e}),j(i,"aria-current",l(y)===e?"page":void 0),j(c,"aria-hidden",l(y)===e),m(d,e)}),F("click",c,()=>v("pageLinkClick",{page:e})),u(t,i)});var M=i(P,2);let N;var L=n(M);o(x),o(k),a((a,t)=>{T=b(w,1,"page-item",null,T,{disabled:1===l(y)}),j(D,"title",a),j(D,"aria-hidden",1===l(y)),N=b(M,1,"page-item",null,N,{disabled:l(y)===p()}),j(L,"title",t),j(L,"aria-hidden",l(y)===p())},[()=>C("components.pagination.previous-page","Previous page"),()=>C("components.pagination.next-page","Next page")]),F("click",D,()=>v("firstPageClick",{})),F("click",L,()=>v("lastPageClick",{})),u(r,k),t()}P(["click"]);export{q as D,M as E,L as N,z as P,E as T,H as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as s}from"../chunks/chunk-
|
|
1
|
+
import{E as s}from"../chunks/chunk-CxieYCZG.js";export{D as Date,N as NoContent,P as PageActions,a as Pagination,T as Toast}from"../chunks/chunk-CxieYCZG.js";const o=s,n=s,t=s,c=s,e=s,r=s,h=s,i=s,k=s,u=s;export{h as CardFilters,i as CardFiltersItem,k as CardHeader,n as DragAndDropZone,o as Editor,c as PageLoader,t as PageLoading,r as PageNav,e as PageNavItem,u as SearchInput};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as e}from"../chunks/chunk-
|
|
1
|
+
import{E as e}from"../chunks/chunk-CxieYCZG.js";export{D as Date,N as NoContent,P as PageActions,a as Pagination,T as Toast}from"../chunks/chunk-CxieYCZG.js";import"../svelte/internal-disclose-version.js";import{_ as t,$ as s,a0 as n,k as r,g as o,a1 as i,a2 as c,a3 as m,a4 as u,n as d}from"../chunks/chunk-DQhQpYBr.js";import{d as l,b as h,f as b,t as p,s as v}from"../chunks/chunk-dcWYlI_G.js";import{s as k,p as f,i as g,a as j,b as w,c as y}from"../chunks/chunk-BwMumrfI.js";import"../chunks/chunk-B5CK1uiS.js";import{g as x}from"../chunks/chunk-B64dhCzK.js";import{translate as A,currentLanguage as I}from"./utils-language.js";import{s as $}from"../chunks/chunk-Bkf3iLx0.js";import{h as C}from"../chunks/chunk-BfcUislW.js";var S=b("<img/>");function B(a,e){n(e,!0);const[c,m]=k();let u=f(e,"width",3,64),d=f(e,"height",3,64),b=f(e,"inGame",3,!1);const p=i(()=>e.lastActivityTime>Date.now()-3e5||b()),v=i(()=>`${x().apiBase}/api/profile/picture/${encodeURIComponent(e.username)}`),T=i(()=>{if(e.banned)return;if(o(p))return A("components.player-head."+(b()?"in-game":"in-website"),b()?"In game":"On the website");const a=y(I,"$currentLanguage",c)?.code??x().locale??void 0;return new Intl.DateTimeFormat(a,{dateStyle:"medium",timeStyle:"short"}).format(new Date(parseInt(e.lastActivityTime)))});var D=l(),$=t(D),P=a=>{var t=S();let s;r(()=>{j(t,"src",o(v)),s=w(t,1,"img-thumbnail rounded d-block m-auto",null,s,{border:e.banned||o(p),"border-3":e.banned||o(p),"border-success":!e.banned&&o(p),"border-danger":e.banned}),j(t,"width",u()),j(t,"height",d()),j(t,"alt",e.username),j(t,"title",o(T))}),h(a,t)},C=a=>{var t=S();let s;r(()=>{j(t,"src",o(v)),s=w(t,1,"rounded d-block m-auto",null,s,{border:e.banned,"border-3":e.banned,"border-danger":e.banned}),j(t,"width",u()),j(t,"height",d()),j(t,"alt",e.username)}),h(a,t)};g($,a=>{e.lastActivityTime?a(P):a(C,-1)}),h(a,D),s(),m()}var E=b('<p class="mb-0 mt-2 opacity-75"><!></p>'),F=b('<div class="text-center"><h1 class="fs-3 mb-0 text-break word-break"><!></h1> <!> <!></div>');function G(a,e){let s=f(e,"title",3,""),n=f(e,"subtitle",3,""),b=f(e,"subtitleHtml",3,!1);const k=i(()=>"function"==typeof s());var j=l(),w=t(j),y=a=>{var i=F(),f=c(i),j=c(f),w=a=>{var e=l(),n=t(e);$(n,s),h(a,e)},y=a=>{var n=l(),o=t(n),i=a=>{var e=l(),n=t(e);C(n,s),h(a,e)},c=a=>{var e=p();r(()=>v(e,s())),h(a,e)};g(o,a=>{e.html?a(i):a(c,-1)}),h(a,n)};g(j,a=>{o(k)?a(w):s()&&a(y,1)}),m(f);var T=u(f,2),D=a=>{var e=E(),s=c(e),o=a=>{var e=l(),s=t(e);C(s,n),h(a,e)},i=a=>{var e=p();r(()=>v(e,n())),h(a,e)};g(s,a=>{b()?a(o):a(i,-1)}),m(e),h(a,e)};g(T,a=>{n()&&a(D)});var x=u(T,2);$(x,()=>e.children??d),m(i),h(a,i)};g(w,a=>{(s()||n())&&a(y)}),h(a,j)}const H=e,L=e;export{G as PageTitle,B as PlayerHead,H as PluginBlock,L as PluginSlot};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../svelte/index.js";import"../chunks/chunk-s84dpggu.js";import"../chunks/chunk-DLMzDTGN.js";import"../chunks/chunk-B5CK1uiS.js";import"../svelte-i18n.js";export{L as LOAD_MEMO_MS,c as clearLoadMemo,a as createLoadMemo,b as createWidgetHost,d as ensureControllerHost,l as loadPluginControllers,p as plugin,r as reactive,C as registry,u as useController}from"../chunks/chunk-
|
|
1
|
+
import"../svelte/index.js";import"../chunks/chunk-s84dpggu.js";import"../chunks/chunk-DLMzDTGN.js";import"../chunks/chunk-B5CK1uiS.js";import"../svelte-i18n.js";export{L as LOAD_MEMO_MS,c as clearLoadMemo,a as createLoadMemo,b as createWidgetHost,d as ensureControllerHost,l as loadPluginControllers,p as plugin,r as reactive,C as registry,u as useController}from"../chunks/chunk-B8GDD4Jh.js";import"../chunks/chunk-B64dhCzK.js";import"./utils-api.js";import"./svelte.js";import"./toasts.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{createViewProxy}from"./views.js";export{getPanoContext,setPanoContext}from"./internal.js";export{viewComponent}from"./utils-component.js";import{u as t,m as e}from"../chunks/chunk-dcWYlI_G.js";import{c as n}from"../chunks/chunk-s84dpggu.js";import"../chunks/chunk-B5CK1uiS.js";import{r as o,g as r,p as i}from"../chunks/chunk-
|
|
1
|
+
export{createViewProxy}from"./views.js";export{getPanoContext,setPanoContext}from"./internal.js";export{viewComponent}from"./utils-component.js";import{u as t,m as e}from"../chunks/chunk-dcWYlI_G.js";import{c as n}from"../chunks/chunk-s84dpggu.js";import"../chunks/chunk-B5CK1uiS.js";import{r as o,g as r,p as i}from"../chunks/chunk-B64dhCzK.js";export{c as configure}from"../chunks/chunk-B64dhCzK.js";import{e as u,g as h,l}from"../chunks/chunk-B8GDD4Jh.js";export{L as LOAD_MEMO_MS,c as clearLoadMemo,a as createLoadMemo,b as createWidgetHost,s as setSession}from"../chunks/chunk-B8GDD4Jh.js";import{translate as p,ensureLanguage as d,loadPluginTranslations as _}from"./utils-language.js";import{r as m,u as g,e as f}from"../chunks/chunk-D7Jd5Dpn.js";export{W as WidgetError}from"../chunks/chunk-D7Jd5Dpn.js";class k{static isPanoPlugin=!0;pano;contextApi;context;constructor({pluginId:t}={}){if(!t)throw new Error("[PanoPlugin] pluginId is required");this.contextApi={context:{},set(){},subscribe:()=>()=>{},destroy(){}},this.context=this.contextApi.context,this._unsubscribers=[]}onLoad(t){}onUnload(){}setContext(t){}__destroy(){}}const j=new Set(["PLUGIN_INACTIVE","PLUGIN_NOT_FOUND"]),w=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),v=t=>t.replace(/-([a-z0-9])/g,(t,e)=>e.toUpperCase());function y(t,e){if(null===e)return"boolean"!==t&&void 0;if("number"===t){const t=Number(e);return Number.isNaN(t)?void 0:t}return"boolean"===t?"false"!==e:e}function P(t){const e=document.createElement("link");return e.rel="stylesheet",e.href=t,e}function x(t){if(!t)return;[...document.head.querySelectorAll('link[rel="stylesheet"]')].some(e=>e.getAttribute("href")===t)||document.head.append(P(t))}function E(s,a,c={}){const k=customElements.get(s);if(k)return k;const b=function(t){return(t??[]).map(t=>{const e="string"==typeof t?t:t.name;return{attr:w(e),prop:v(e),type:"string"==typeof t?"string":t.type??"string"}})}(a.attrs),E=new Map(b.map(t=>[t.attr,t])),A=c.session??a.session??"none";class C extends HTMLElement{static get observedAttributes(){return b.map(t=>t.attr)}constructor(){super(),this._gen=0,this._instance=null,this._reactive=null,this._loaded={},this._jsProps={},this._root=null,this._container=null}connectedCallback(){m(this),this._ensureStructure(),this._start(!1)}disconnectedCallback(){this._gen+=1,this._unmount(),g(this)}attributeChangedCallback(){this._instance&&this._reactive?.set(this._currentProps())}reload(){return this._start(!0)}get props(){return{...this._jsProps}}set props(t){Object.assign(this._jsProps,t??{}),this._instance&&this._reactive?.set(this._currentProps())}_ensureStructure(){if(this._container)return;const t=!this.hasAttribute("no-shadow"),e=c.styles??{},s=function(t){const e=t?.fallback;return e?t.hash&&!e.includes("?")?`${e}?v=${t.hash}`:e:null}(e),n=document.createElement("div");if(n.className="pano-fb",n.dataset.panoFb=c.ns??"",t){const t=this.shadowRoot??this.attachShadow({mode:"open"});s&&t.append(P(s)),e.icons&&t.append(P(e.icons)),t.append(n),this._root=t}else x(s),x(e.icons),this.append(n),this._root=this;this._container=n}_attrProps(){const t={};for(const{attr:e,prop:s,type:n}of b){const o=y(n,this.getAttribute(e));void 0!==o&&(t[s]=o)}return t}_currentProps(){return{...this._loaded,...this._attrProps(),...this._jsProps}}_setState(t){this.dataset.panoState=t}_unmount(){if(this._instance)try{t(this._instance)}catch(t){console.warn(`[pano-widgets] ${s} unmount failed`,t)}this._instance=null,this._reactive=null,this._container&&this._container.replaceChildren()}_show(t,e){this._unmount(),this._setState(t),e&&this._container.append(e)}_stateNode(t,e){const s=document.createElement("div");return s.className="pano-widget__state",s.dataset.panoStateView=t,e&&s.setAttribute("role",e),s}_showError(t){const e=t?.code??t?.error?.code??"LOAD_FAILED";if(j.has(e))return void this._show("inactive");const s=this._stateNode("error","alert"),n=document.createElement("span");n.textContent=p("widgets.error","This content could not be loaded.");const o=document.createElement("button");o.type="button",o.dataset.panoRetry="",o.textContent=p("widgets.retry","Retry"),o.addEventListener("click",()=>{this.reload()}),s.append(n," ",o),this._show("error",s),f(this,"pano:error",{code:e})}_showSignIn(){const t=this._stateNode("signin"),e=document.createElement("a");e.href=o(r().urls["auth.login"]?"auth.login":"/login"),e.textContent=p("widgets.sign-in","Sign in"),t.append(e),this._show("signin",t)}async _start(t){const o=this._gen+=1,r=()=>o!==this._gen;if(!1!==c.active){t&&this._instance||(this._show("loading",this._stateNode("loading")),this._container.firstChild?.setAttribute("aria-busy","true"));try{if("none"!==A){if(await u(),r())return;if("required"===A&&!h().user)return void this._showSignIn()}if(await Promise.all([c.pluginId&&c.controllers?l({pluginId:c.pluginId,ns:c.ns??"",url:c.controllers}):null,d().then(()=>c.pluginId?_(c.pluginId):null)]),r())return;const t=this._attrProps(),o="function"==typeof a.load?await a.load({fetch:(...t)=>i(...t),params:t,url:new URL(globalThis.location.href),widget:!0},t):{};if(r())return;if(this._loaded=o&&"object"==typeof o?o:{},this._instance)return void this._reactive?.set(this._currentProps());this._unmount(),this._reactive=function(t){let e={...t},s=null;const o=n(t=>(s=t,()=>{s=null}));return{props:new Proxy({},{get:(t,s)=>(o(),e[s]),has:(t,s)=>(o(),s in e),ownKeys:()=>(o(),Reflect.ownKeys(e)),getOwnPropertyDescriptor:(t,s)=>(o(),s in e?{enumerable:!0,configurable:!0,writable:!0,value:e[s]}:void 0)}),set(t){e={...t},s?.()}}}(this._currentProps()),this._instance=e(a.component,{target:this._container,props:this._reactive.props}),this._setState("ready"),f(this,"pano:ready",{tag:s})}catch(t){if(r())return;this._showError(t)}}else this._show("inactive")}}for(const{attr:t,prop:e}of b)Object.defineProperty(C.prototype,e,{configurable:!0,get(){return e in this._jsProps?this._jsProps[e]:y(E.get(t).type,this.getAttribute(t))},set(t){this._jsProps[e]=t,this._instance&&this._reactive?.set(this._currentProps())}});return customElements.define(s,C),C}const A=Object.freeze({"@panomc/sdk":"index.js","@panomc/sdk/svelte":"svelte.js","@panomc/sdk/views":"views.js","@panomc/sdk/controllers":"controllers.js","@panomc/sdk/toasts":"toasts.js","@panomc/sdk/internal":"internal.js","@panomc/sdk/variables":"variables.js","@panomc/sdk/components/theme":"components/index.js","@panomc/sdk/components/panel":"components/panel.js","@panomc/sdk/utils/api":"api.js","@panomc/sdk/utils/auth":"auth.js","@panomc/sdk/utils/tooltip":"tooltip.js","@panomc/sdk/utils/language":"language.js","@panomc/sdk/utils/component":"component.js","@panomc/sdk/utils/text":"text.js","@panomc/sdk/utils/route":"route.js"});export{k as PanoPlugin,A as SPECIFIER_MODULES,E as defineWidget,d as ensureLanguage,u as ensureSession,r as getConfig,h as getSession,l as loadPluginControllers,_ as loadPluginTranslations,o as resolveUrl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as t,g as e}from"../chunks/chunk-
|
|
1
|
+
import{o as t,g as e}from"../chunks/chunk-B64dhCzK.js";const n={context:{isPanel:!1,browser:!0},listeners:[]};function s(){for(const t of[...n.listeners])try{t(n.context)}catch(t){console.error("[pano-widgets] context listener failed",t)}}function o(t){"object"==typeof t&&null!==t?(Object.assign(n.context,t),s()):console.warn("[PanoSDK] setPanoContext expects an object")}function c(){return{context:n.context,subscribe:t=>(n.listeners.push(t),()=>{n.listeners=n.listeners.filter(e=>e!==t)})}}t(t=>{n.context.base=t.siteUrl,n.context.urls={...t.urls},s()}),n.context.base=e().siteUrl,n.context.urls=e().urls;export{c as getPanoContext,o as setPanoContext};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n}from"../chunks/chunk-DLMzDTGN.js";import{o as t,g as e,r as a}from"../chunks/chunk-
|
|
1
|
+
import{r as n}from"../chunks/chunk-DLMzDTGN.js";import{o as t,g as e,r as a}from"../chunks/chunk-B64dhCzK.js";import{W as o,e as r,a as s,b as c}from"../chunks/chunk-D7Jd5Dpn.js";const i=!0;let l=e().siteUrl;t(n=>{l=n.siteUrl});const u=n({url:f(),params:{}},n=>{const t=()=>n({url:f(),params:{}});if(t(),"undefined"!=typeof window)return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)}),p=n(null);function f(){try{return new URL(globalThis.location.href)}catch{return new URL("about:blank")}}async function m(n,t){const o=a(String(n));if(!r(c(),"pano:navigate",{url:o},!0))return;const s=e().navigate;"function"!=typeof s?"undefined"!=typeof location&&(t?.replace??t?.replaceState?location.replace(o):location.assign(o)):s(o,{replace:!!(t?.replace??t?.replaceState)})}function d(n,t){return m(String(t))}function w(n,t){throw new o(Number(n)||500,"string"==typeof t?t:t?.message)}async function h(){const{clearLoadMemo:n}=await(import("./controllers.js"));n(),await Promise.all(s().map(n=>n.reload?.()))}function g(n){return h()}export{l as base,i as browser,w as error,m as goto,g as invalidate,h as invalidateAll,p as navigating,u as page,d as redirect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,p as t,a as r}from"../chunks/chunk-
|
|
1
|
+
import{g as e,p as t,a as r}from"../chunks/chunk-B64dhCzK.js";const o="NETWORK_ERROR",a=Object.freeze({error:Object.freeze({code:o})});function n(e){const t=Object.keys(e??{}).filter(t=>e[t]).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`).join("&");return""===t?"":`?${t}`}async function s(a){const s=String(a?.method??"GET").toUpperCase(),h=function(e){const t=String(e??"");if(/^\/api\/plugins\/[^/?#]+\/(?!_(?:[/?#]|$))[^?#]/.test(t))return t;if(/^\/plugins\/[^/?#]+\/(?!_(?:[/?#]|$))[^?#]/.test(t))return`/api${t}`;const r=String(e??"").replace(/^\/?api(\/v1)?(?=\/|$)/,"");return`/api/v1${r.startsWith("/")||""===r?"":"/"}${r}`}(a?.path);if(a?.blob&&"GET"===s)try{const r=`${e().apiBase}${h}${n(a.query??{})}`,o=await t(r,{method:s,credentials:"include",headers:a.headers,signal:a.signal});return o.ok?await o.blob():{error:{code:"UNKNOWN_ERROR",details:{status:o.status}}}}catch{return{error:{code:o}}}const d=await r().request({method:s,path:h},{query:a?.query,body:a?.body,headers:a?.headers,signal:a?.signal});return d.ok?void 0===d.data||null===d.data?{}:d.data:d.error?.code===o?{error:{code:o}}:{error:d.error}}function h({headers:e,token:t,csrfToken:r}){const o={...e??{}};return t&&(o.Authorization=`Bearer ${t}`),r&&(o["X-CSRF-Token"]=r),o}const d={interceptors:{},get({path:e,query:t,headers:r,csrfToken:o,token:a,blob:n,handler:s}){return this.customRequest({path:e,data:{method:"GET",query:t,headers:r},csrfToken:o,token:a,blob:n,handler:s})},post({path:e,body:t,headers:r,csrfToken:o,token:a,blob:n,handler:s}){return this.customRequest({path:e,data:{method:"POST",body:t,headers:r},csrfToken:o,token:a,blob:n,handler:s})},put({path:e,body:t,headers:r,csrfToken:o,token:a,blob:n,handler:s}){return this.customRequest({path:e,data:{method:"PUT",body:t,headers:r},csrfToken:o,token:a,blob:n,handler:s})},delete({path:e,headers:t,csrfToken:r,token:o,blob:a,handler:n}){return this.customRequest({path:e,data:{method:"DELETE",headers:t},csrfToken:r,token:o,blob:a,handler:n})},customRequest:async({path:e,data:t={},csrfToken:r,token:o,blob:a,handler:n})=>async function(e,t){return t?t(e):e}(await s({method:t.method??"GET",path:e,query:t.query,body:t.body,headers:h({headers:t.headers,token:o,csrfToken:r}),blob:a}),n)},i=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function u(e){if("string"!=typeof e||!i.test(e))throw new Error(`[pano] createPluginApi needs the full plugin id, got ${JSON.stringify(e)}`);const t=e=>{const t=t=>async(r={})=>{if("string"!=typeof r.path)throw new TypeError("[pano] api path must be a string");const o=r.path.startsWith("/")?r.path:`/${r.path}`;if(!import.meta.env?.PROD&&/^\/api(?:[/?#]|$)/.test(o))throw new Error(`[pano] path must not start with /api: write '${o.replace(/^\/api/,"")||"/"}'`);return d[t]({...r,path:`${e}${o}`})};return{get:t("get"),post:t("post"),put:t("put"),delete:t("delete"),customRequest:t("customRequest")}};return{...t(`/api/plugins/${e}`),panel:t(`/api/plugins/${e}/panel`)}}export{d as ApiUtil,o as NETWORK_ERROR,n as buildQueryParams,u as createPluginApi,d as default,s as hostRequest,a as networkErrorBody};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{init as t,addMessages as n,locale as e,getLocaleFromNavigator as a,_ as o}from"../svelte-i18n.js";import{g as c,w as s}from"../chunks/chunk-DLMzDTGN.js";import{g as r,a as l}from"../chunks/chunk-
|
|
1
|
+
import{init as t,addMessages as n,locale as e,getLocaleFromNavigator as a,_ as o}from"../svelte-i18n.js";import{g as c,w as s}from"../chunks/chunk-DLMzDTGN.js";import{g as r,a as l}from"../chunks/chunk-B64dhCzK.js";const i=s(!1),u=s(null),f=s({}),p="en-US",y=new Map,d=new Map;let m=null,h=!1;function g(t,n="",e={}){for(const a of Object.keys(t??{})){const o=t[a],c=n?`${n}.${a}`:a;o&&"object"==typeof o&&!Array.isArray(o)?g(o,c,e):e[c]=o}return e}async function j(t){const n=await l().request({method:"GET",path:`/api/v1${t}`});return n.ok?n.data:null}async function b(){const t=(n=await j("/locales"),Array.isArray(n)?n:Array.isArray(n?.items)?n.items:Array.isArray(n?.data)?n.data:[]);var n;f.set(Object.fromEntries(t.filter(t=>t?.code).map(t=>[t.code,t])))}function w(t){return Object.values(c(f)).find(n=>n.code===t)??null}function k(t){const n=t?.get?.("accept-language");return n?n.split(",")[0]:""}function A(t){const e=t.code;return y.has(e)||y.set(e,(async()=>{const a=await j(`/locales/${encodeURIComponent(e)}/translations/types/THEME`),o=a&&"object"==typeof a?a.data??a.translations??a:{},{result:c,...s}=o,r=function(t){const n={};for(const[e,a]of Object.entries(t)){const t=e.split(".");t.reduce((n,e,o)=>(o===t.length-1?n[e]=a:n[e]=n[e]&&"object"==typeof n[e]?n[e]:{},n[e]),n)}return n}(g(s));n(e,r);for(const e of t.derivatives??[])n(e,r);return r})().catch(()=>({}))),y.get(e)}function $(t,a=c(e)||r().locale||p){const o=`${t}:${a}`;return d.has(o)||d.set(o,(async()=>{const e=await j(`/plugins/${encodeURIComponent(t)}/_/translations/${encodeURIComponent(a)}`),o=e?.translations;if(!o||"object"!=typeof o)return{};const c=o.plugins?o:{plugins:{[t]:o}};return n(a,c),c})().catch(()=>({}))),d.get(o)}async function v(n){await b();const o=n||r().locale||c(e)||a()||p,s=c(f),l=w(o)??s[p]??{code:o},i=s[p]??{code:p};return await Promise.all([A(i),l.code===i.code?null:A(l)]),u.set(l),t({fallbackLocale:p,initialLocale:l.code}),h=!0,l}function E(){return m||(m=v().catch(()=>(h||(t({fallbackLocale:p,initialLocale:r().locale||p}),h=!0),null))),m}async function L(t){if(c(u)!==t){i.set(!0);try{await A(t),e.set(t.code),u.set(t)}finally{i.set(!1)}}}function O(t,n,e){try{return c(o)(t,{default:n,values:e})}catch{return n}}function U(){y.clear(),d.clear(),m=null,h=!1,u.set(null),f.set({})}export{f as Languages,o as _,L as changeLanguage,u as currentLanguage,E as ensureLanguage,k as getAcceptedLanguage,w as getLanguageByLocale,v as init,i as languageLoading,A as loadLanguage,$ as loadPluginTranslations,U as resetLanguage,O as translate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as s,g as a}from"../chunks/chunk-
|
|
1
|
+
import{o as s,g as a}from"../chunks/chunk-B64dhCzK.js";let o=`${a().apiBase}/api`,p=a().siteUrl,t="",c="",i="https://panomc.com",e="https://api.panomc.com";const n=!1,m="",r="",h="",k="X-CSRF-Token";s(s=>{o=`${s.apiBase}/api`,p=s.siteUrl});const l=s=>{o=s},u=s=>{i=s},B=s=>{e=s};export{o as API_URL,m as COOKIE_PREFIX,k as CSRF_HEADER,r as CSRF_TOKEN_COOKIE_NAME,h as JWT_COOKIE_NAME,t as PANEL_URL,e as PANO_WEBSITE_API_URL,i as PANO_WEBSITE_URL,n as PRERELEASE,c as SETUP_URL,p as UI_URL,l as updateApiUrl,B as updatePanoWebsiteApiUrl,u as updatePanoWebsiteUrl};
|
package/dist/runtime/loader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="pano-",t=window,n=import.meta.url,o=/^(.*?)\/api\/v1\/(?:widgets\/)?(?:runtime\/)?[^/]*$/.exec(n),s=new URL(n),i=s.origin===location.origin,a=o?o[1]:null,l={apiBase:null===a?"":i?a.slice(s.origin.length):a,locale:void 0,urls:void 0,navigate:void 0,fetch:void 0,csrf:void 0},c=e=>new URL(e||"/",location.href).href.replace(/\/$/,""),r=()=>`${c(l.apiBase)}/api/v1/`,d=e=>(null===a?n.replace(/[^/?#]*([?#].*)?$/,""):`${r()}widgets/runtime/`)+e,u=[...document.querySelectorAll("script[src]")].find(e=>e.src===n),f=u?.dataset.palette||"light";l.locale=u?.dataset.locale||void 0;let h=null,
|
|
1
|
+
const e="pano-",t=window,n=import.meta.url,o=/^(.*?)\/api\/v1\/(?:widgets\/)?(?:runtime\/)?[^/]*$/.exec(n),s=new URL(n),i=s.origin===location.origin,a=o?o[1]:null,l={apiBase:null===a?"":i?a.slice(s.origin.length):a,locale:void 0,urls:void 0,navigate:void 0,fetch:void 0,csrf:void 0},c=e=>new URL(e||"/",location.href).href.replace(/\/$/,""),r=()=>`${c(l.apiBase)}/api/v1/`,d=e=>(null===a?n.replace(/[^/?#]*([?#].*)?$/,""):`${r()}widgets/runtime/`)+e,u=[...document.querySelectorAll("script[src]")].find(e=>e.src===n),f=u?.dataset.palette||"light";l.locale=u?.dataset.locale||void 0;let h=null,g=null,p=!1,m=0;const w=new Set,v=new Set;function y(e){if(!e||v.has(e))return;v.add(e);const t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.append(t)}function $(e,t,n){if(t)return/^[a-z][a-z0-9+.-]*:|^\/\//i.test(t)?t:t.startsWith("/")?new URL(t,c(l.apiBase)+"/").href:`${r()}plugins/${e}/_/ui/${n}${t}`}function b(){return g??=import(d("host/index.js")).then(e=>(B(e),e)),g}function B(e){const{apiBase:t,locale:n,urls:o,navigate:s,fetch:i,csrf:a}=l;e.configure({apiBase:t,siteUrl:h?.site?.url,...n||h?.site?.locale?{locale:n||h.site.locale}:{},...o?{urls:o}:{},...s?{navigate:s}:{},...i?{fetch:i}:{},...a?{csrf:a}:{}})}async function I(e){const t=h.widgets[e],[n,o]=await Promise.all([b(),import($(t.pluginId,t.module,"widgets/"))]),s=t.styles??{};n.defineWidget(e,o,{ns:t.ns,pluginId:t.pluginId,session:t.session,controllers:t.controllers?$(t.pluginId,"controllers.mjs","controllers/"):void 0,styles:{hash:s.hash,fallback:$(t.pluginId,s.fallback,""),icons:$(t.pluginId,s.icons,"")}})}function k(e){e.hasAttribute("data-bs-theme")||e.setAttribute("data-bs-theme",f)}function L(t){if(!h?.widgets)return;const n=m,o=1===t.nodeType&&t.localName.startsWith(e)?[t]:[];t.querySelectorAll&&o.push(...t.querySelectorAll("*"));for(const t of o){const o=t.localName;if(!o.startsWith(e)||!h.widgets[o])continue;if(k(t),w.has(o))continue;w.add(o),y(d("css/pano-tokens.css"));const s=h.widgets[o].styles?.icons;s&&y($(h.widgets[o].pluginId,s,"")),I(o).catch(e=>{n===m&&w.delete(o),console.warn(`[pano-widgets] ${o} failed to load`,e)})}}async function S(){const e=++m;try{const t=await(l.fetch??fetch)(`${r()}widgets/index.json`,{credentials:"omit"});if(!t.ok)throw new Error(`HTTP ${t.status}`);const n=await t.json();if(e!==m)return;h=n}catch(e){return void console.warn("[pano-widgets] could not read the widget index",e)}g&&g.then(B),p||(p=!0,new MutationObserver(e=>{for(const t of e)for(const e of t.addedNodes)1===e.nodeType&&L(e)}).observe(document.documentElement,{childList:!0,subtree:!0}));for(const e of[...w])customElements.get(e)||w.delete(e);L(document)}t.PanoWidgets={configure(e={}){const t=void 0!==e.apiBase&&e.apiBase!==l.apiBase;for(const t of Object.keys(l))void 0!==e[t]&&(l[t]=e[t]);return g&&g.then(B),t&&h&&(h=null,S()),{...l}},host:()=>b()};const j=()=>setTimeout(S,0);"loading"===document.readyState?document.addEventListener("DOMContentLoaded",j,{once:!0}):j();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"format": 1,
|
|
3
3
|
"svelte": "5.57.2",
|
|
4
|
-
"hash": "
|
|
4
|
+
"hash": "76b21490f5375e70",
|
|
5
5
|
"specifiers": {
|
|
6
6
|
"svelte": "svelte/index.js",
|
|
7
7
|
"svelte/animate": "svelte/animate.js",
|
|
@@ -40,13 +40,14 @@
|
|
|
40
40
|
},
|
|
41
41
|
"files": [
|
|
42
42
|
"chunks/chunk-B5CK1uiS.js",
|
|
43
|
+
"chunks/chunk-B64dhCzK.js",
|
|
44
|
+
"chunks/chunk-B8GDD4Jh.js",
|
|
43
45
|
"chunks/chunk-BfcUislW.js",
|
|
44
46
|
"chunks/chunk-Bkf3iLx0.js",
|
|
45
47
|
"chunks/chunk-BwMumrfI.js",
|
|
46
48
|
"chunks/chunk-C8W1Nv_i.js",
|
|
47
|
-
"chunks/chunk-
|
|
49
|
+
"chunks/chunk-CxieYCZG.js",
|
|
48
50
|
"chunks/chunk-D7Jd5Dpn.js",
|
|
49
|
-
"chunks/chunk-DDDEBZES.js",
|
|
50
51
|
"chunks/chunk-DE7YsbjM.js",
|
|
51
52
|
"chunks/chunk-DLMzDTGN.js",
|
|
52
53
|
"chunks/chunk-DNUkGPCL.js",
|
|
@@ -55,7 +56,6 @@
|
|
|
55
56
|
"chunks/chunk-DptTvy3T.js",
|
|
56
57
|
"chunks/chunk-dcWYlI_G.js",
|
|
57
58
|
"chunks/chunk-s84dpggu.js",
|
|
58
|
-
"chunks/chunk-uTSPLXJn.js",
|
|
59
59
|
"css/pano-fallback-icons.css",
|
|
60
60
|
"css/pano-tokens.css",
|
|
61
61
|
"host/components-panel.js",
|
package/dist/widget-runtime.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panomc/widget-host",
|
|
3
|
-
"version": "1.1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Host modules and runtime that let Pano plugin views run as web-component widgets outside a theme.",
|
|
5
5
|
"author": "PanoMC",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,16 +46,16 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@panomc/client": "1.1.0
|
|
50
|
-
"@panomc/plugin-kit": "1.1.0
|
|
49
|
+
"@panomc/client": "1.1.0",
|
|
50
|
+
"@panomc/plugin-kit": "1.1.0",
|
|
51
51
|
"svelte-i18n": "^4.0.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@panomc/sdk": "^2.0.0
|
|
54
|
+
"@panomc/sdk": "^2.0.0",
|
|
55
55
|
"svelte": "*"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@panomc/sdk": "2.0.0
|
|
58
|
+
"@panomc/sdk": "2.0.0",
|
|
59
59
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
60
60
|
"@rollup/plugin-terser": "^1.0.0",
|
|
61
61
|
"happy-dom": "^21.0.1",
|
package/scripts/loader.js
CHANGED
|
@@ -104,6 +104,8 @@ function tidy(el) {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
function scan(root) {
|
|
107
|
+
// no index yet (the first or a new one is in flight, or it failed): nothing to define
|
|
108
|
+
if (!index?.widgets) return;
|
|
107
109
|
const gen = generation;
|
|
108
110
|
const nodes = root.nodeType === 1 && root.localName.startsWith(PREFIX) ? [root] : [];
|
|
109
111
|
if (root.querySelectorAll) nodes.push(...root.querySelectorAll('*'));
|
|
@@ -142,7 +144,9 @@ async function start() {
|
|
|
142
144
|
for (const r of records) for (const n of r.addedNodes) if (n.nodeType === 1) scan(n);
|
|
143
145
|
}).observe(document.documentElement, { childList: true, subtree: true });
|
|
144
146
|
}
|
|
145
|
-
|
|
147
|
+
// a tag that is already a custom element stays defined (customElements cannot redefine it); the others get
|
|
148
|
+
// another try with the new index
|
|
149
|
+
for (const tag of [...seen]) if (!customElements.get(tag)) seen.delete(tag);
|
|
146
150
|
scan(document);
|
|
147
151
|
}
|
|
148
152
|
|
|
@@ -152,9 +156,10 @@ w.PanoWidgets = {
|
|
|
152
156
|
const apiChanged = options.apiBase !== undefined && options.apiBase !== state.apiBase;
|
|
153
157
|
for (const key of Object.keys(state)) if (options[key] !== undefined) state[key] = options[key];
|
|
154
158
|
if (hostReady) hostReady.then(push);
|
|
159
|
+
// a new apiBase reads its own index; the loaded host stays (push above handed it the new apiBase), so no
|
|
160
|
+
// second runtime is imported
|
|
155
161
|
if (apiChanged && index) {
|
|
156
162
|
index = null;
|
|
157
|
-
hostReady = null;
|
|
158
163
|
start();
|
|
159
164
|
}
|
|
160
165
|
return { ...state };
|
|
@@ -143,6 +143,21 @@ describe('plugin(ns).load', () => {
|
|
|
143
143
|
expect(requests).toBe(3);
|
|
144
144
|
});
|
|
145
145
|
|
|
146
|
+
test('a load pinned to another version gets null, not the cached data of the registered version', async () => {
|
|
147
|
+
clearLoadMemo();
|
|
148
|
+
const definition = {
|
|
149
|
+
name: 'pinned',
|
|
150
|
+
version: 1,
|
|
151
|
+
load: async () => ({ goal: 1 }),
|
|
152
|
+
create: () => ({ get: () => ({}), subscribe: (run) => (run({}), () => {}), actions: {}, destroy() {} }),
|
|
153
|
+
};
|
|
154
|
+
registry.register('pano-plugin-pin', 'pin', [definition]);
|
|
155
|
+
|
|
156
|
+
expect(await plugin('pin').load('pinned')).toEqual({ goal: 1 });
|
|
157
|
+
expect(await plugin('pin').load('pinned', { version: 2 })).toBeNull();
|
|
158
|
+
expect(await plugin('pin').load('pinned', { version: 1 })).toEqual({ goal: 1 });
|
|
159
|
+
});
|
|
160
|
+
|
|
146
161
|
test('an unknown controller resolves null and is not remembered', async () => {
|
|
147
162
|
expect(await plugin('missing').load('nothing')).toBeNull();
|
|
148
163
|
});
|
package/src/controllers.js
CHANGED
|
@@ -303,11 +303,12 @@ export function plugin(namespace) {
|
|
|
303
303
|
if (!c) throw new Error(`${fullName(name)} is not available`);
|
|
304
304
|
return c;
|
|
305
305
|
},
|
|
306
|
-
/** Memoised per page: shared while in flight and for 5 s (`LOAD_MEMO_MS`). */
|
|
306
|
+
/** Memoised per page by name, params and version pin: shared while in flight and for 5 s (`LOAD_MEMO_MS`). */
|
|
307
307
|
load(name, opts) {
|
|
308
308
|
ensureControllerHost();
|
|
309
309
|
const full = fullName(name);
|
|
310
|
-
|
|
310
|
+
// the version pin is part of the key: a pinned load that does not match the registered controller gets null
|
|
311
|
+
return memo.run(full, { params: opts?.params ?? {}, version: opts?.version ?? null }, () => registry.load(full, opts));
|
|
311
312
|
},
|
|
312
313
|
};
|
|
313
314
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,t,n={}){return{ok:!1,status:e,error:{...n,code:t}}}function t(t,n){const o=n&&"object"==typeof n?n.error:void 0;if(o&&"object"==typeof o&&"string"==typeof o.code){const e={code:o.code};return"string"==typeof o.message&&(e.message=o.message),o.details&&"object"==typeof o.details&&(e.details=o.details),o.fields&&"object"==typeof o.fields&&(e.fields=o.fields),{ok:!1,status:t,error:e}}const r=e(t,`HTTP_${t}`);return"string"==typeof n&&n&&(r.error.message=n.slice(0,500)),r}const n="/api/v1/auth/csrf",o=new Set(["GET","HEAD","OPTIONS"]);function r(r){if(!r||"string"!=typeof r.baseUrl)throw new TypeError('createClient: options.baseUrl is required (Pano origin or proxy prefix, e.g. "/pano")');const s=r.baseUrl.replace(/\/+$/,""),a="undefined"!=typeof window&&"undefined"!=typeof document,i=r.credentials??(a?"include":"omit"),c=r.csrf??("include"!==i||r.sessionToken?"off":"auto");let f,l=null;async function u(e){const t={Accept:"application/json"};r.locale&&(t["Accept-Language"]=r.locale),r.frontendKey&&(t["X-Pano-Frontend-Key"]=r.frontendKey,r.clientIp&&(t["X-Pano-Client-Ip"]=r.clientIp));const n="function"==typeof r.sessionToken?await r.sessionToken():r.sessionToken;if(n&&(t.Authorization=`Bearer ${n}`),e)for(const[n,o]of Object.entries(e)){if(null==o)continue;const e=n.toLowerCase();"x-pano-frontend-key"!==e&&"x-pano-client-ip"!==e&&(t[n]=o)}return t}async function d(n,o,a,c,f,l){const u=r.fetch??globalThis.fetch;if("function"!=typeof u)return{result:e(0,"NETWORK_ERROR",{message:"No fetch implementation available"})};const d={method:n,headers:c,credentials:i};void 0!==f&&(d.body=f),l&&(d.signal=l);try{const e=await u(`${s}${o}${a}`,d),n=await async function(e){if(204===e.status||205===e.status)return;const t=await e.text();if(!t)return;if((e.headers.get("content-type")||"").includes("json")||/^\s*[[{]/.test(t))try{return JSON.parse(t)}catch{return t}return t}(e);return e.ok?{result:{ok:!0,status:e.status,data:n}}:{result:t(e.status,n)}}catch(t){const n="AbortError"===t?.name;return{result:e(0,"NETWORK_ERROR",{message:t instanceof Error?t.message:"Network request failed",...n?{details:{aborted:!0}}:{}})}}}function p(){return l||(l=(async()=>{try{const e=await u(void 0),{result:t}=await d("GET",n,"",e,void 0,void 0);if(t.ok){const e=t.data?.csrfToken;f="string"==typeof e?e:null}else 401===t.status&&(f=null)}finally{l=null}})()),l}return{request:async function(t,s={}){try{const e=String(t.method).toUpperCase(),i=function(e,t){return e.replace(/\{([^}]+)\}/g,(e,n)=>{const o=t?.[n];return null==o?e:encodeURIComponent(String(o))})}(t.path,s.path),l=function(e){if(!e)return"";const t=new URLSearchParams;for(const[n,o]of Object.entries(e))if(null!=o)for(const e of Array.isArray(o)?o:[o])null!=e&&t.append(n,e instanceof Date?e.toISOString():String(e));const n=t.toString();return n?`?${n}`:""}(s.query),y=!o.has(e),g="auto"===c&&y&&i!==n;let h=s.body,v=!1;null==h||function(e){return"string"==typeof e||"undefined"!=typeof FormData&&e instanceof FormData||"undefined"!=typeof Blob&&e instanceof Blob||"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams||"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||"undefined"!=typeof ReadableStream&&e instanceof ReadableStream}(h)?null===h&&(h=void 0):(h=JSON.stringify(h),v=!0);const m=async t=>{const n=await u(s.headers);return v&&!Object.keys(n).some(e=>"content-type"===e.toLowerCase())&&(n["Content-Type"]="application/json"),t&&(n["X-CSRF-Token"]=t),d(e,i,l,n,h,s.signal)};g&&void 0===f&&await p();let{result:b}=await m(g?f:void 0);if(g&&!b.ok&&"INVALID_CSRF_TOKEN"===b.error.code&&(f=void 0,await p(),f&&({result:b}=await m(f))),b.ok)y&&i.startsWith("/api/v1/auth/")&&(f=void 0),(a=b.data)&&"object"==typeof a&&"string"==typeof a.csrfToken&&(f=a.csrfToken);else if(401===b.status&&r.onUnauthorized)try{r.onUnauthorized(b)}catch{}return b}catch(t){return e(0,"NETWORK_ERROR",{message:t instanceof Error?t.message:"Request failed before it was sent"})}var a},options:Object.freeze({...r})}}const s={apiBase:"",locale:void 0,urls:{},siteUrl:"",fetch:void 0,navigate:void 0,csrf:void 0};let a=null;const i=new Set;function c(e={}){void 0!==e.apiBase&&(s.apiBase=String(e.apiBase||"").replace(/\/+$/,"")),void 0!==e.locale&&(s.locale=e.locale||void 0),void 0!==e.urls&&(s.urls={...e.urls}),void 0!==e.siteUrl&&(s.siteUrl=String(e.siteUrl||"").replace(/\/+$/,"")),void 0!==e.fetch&&(s.fetch=e.fetch),void 0!==e.navigate&&(s.navigate=e.navigate),void 0!==e.csrf&&(s.csrf=e.csrf),a=null;for(const e of[...i])e(s);return f()}function f(){return{...s,csrf:s.csrf??(e=s.apiBase,e&&!/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?"off":"auto")};var e}function l(e){return i.add(e),()=>i.delete(e)}function u(...e){return(s.fetch??globalThis.fetch)(...e)}function d(){if(!a){const e=f();a=r({baseUrl:e.apiBase,fetch:(...e)=>u(...e),locale:e.locale,credentials:"include",csrf:e.csrf})}return a}function p(e,t){let n=s.urls[e]??e;return t&&(n=n.replace(/\{([^}]+)\}/g,(e,n)=>void 0===t[n]||null===t[n]?e:encodeURIComponent(String(t[n])))),/^[a-z][a-z0-9+.-]*:/i.test(n)||n.startsWith("//")?n:n.startsWith("/")&&s.siteUrl?`${s.siteUrl}${n}`:n}export{d as a,c,f as g,l as o,u as p,p as r};
|