@plitzi/plitzi-sdk 0.38.15 → 0.38.16
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/CHANGELOG.md +74 -0
- package/dist/plitzi-sdk.js +2 -2
- package/dist/plitzi-sdk.js.gz +0 -0
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
1
|
# @plitzi/plitzi-sdk
|
|
2
2
|
|
|
3
|
+
## 0.38.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9cfdccb: ## Security
|
|
8
|
+
|
|
9
|
+
- **A site's credential reads nothing of the space over MCP** (`@plitzi/sdk-mcp`): the `render` token every published
|
|
10
|
+
page embeds — and a self-hosting `host` key — resolved to a grant naming the space, and the MCP served every read
|
|
11
|
+
under it: the unpublished draft, the change history with who made each change and every value before and after, the
|
|
12
|
+
functions' source, the space's private data, its action documents and connectors. Only an `agent` grant attaches a
|
|
13
|
+
space now; any other is a connection with no space (`plitzi_render` and the public guides), told so in the words
|
|
14
|
+
`NO_SPACE_ATTACHED` already uses. A deployment whose `getGrant` answered other scopes for reading must issue agent
|
|
15
|
+
grants for them.
|
|
16
|
+
|
|
17
|
+
## Agents
|
|
18
|
+
- **`plitzi space watch`** (`@plitzi/cli`): the space read again on every save of `src/space/`, `src/plugins/`,
|
|
19
|
+
`src/data/` or `public/data/`, and only what changed said — what the save did to the space element by element, the
|
|
20
|
+
findings and warnings it brought and fixed (one that only moved down its file is the same one), a save that changed
|
|
21
|
+
nothing, or that the space stopped authoring and why. `--json` is one event a line (`ready`, `pass`, `refused`,
|
|
22
|
+
`error`), for an agent to run in the background instead of `author` and `space lint` after every edit. Each pass reads
|
|
23
|
+
the space in a process of its own (`space watch-pass`, hidden). `space lint`'s reading is `spaceFindings`, shared.
|
|
24
|
+
- **A space's activity, followed** (`@plitzi/sdk-shared`, `@plitzi/sdk-mcp`, `@plitzi/cli`): what happened on a space
|
|
25
|
+
after a cursor — its draft changed (a person in the builder, an agent, the autofix), a version went out, a server
|
|
26
|
+
action failed or was refused — and, with nothing yet, waited for, up to 50 s. One vocabulary,
|
|
27
|
+
`@plitzi/sdk-shared/activity` (`SpaceActivity`, `SpaceActivityPage`, `activityLine`, `isSpaceActivityPage`, the
|
|
28
|
+
limits); the reader's own writes left out and counted (`skippedMine`), `mine` keeps them.
|
|
29
|
+
- **`plitzi_activity { after, wait, limit, mine }`** (`@plitzi/sdk-mcp`), on the new `getActivity` adapter
|
|
30
|
+
(`SSRAdapters`). The listing budget is 78k (was 77k) for it.
|
|
31
|
+
- **`plitzi space activity [--follow] [--after <cursor>] [--mine] [--limit <n>] [--json]`** (`@plitzi/cli`), over
|
|
32
|
+
the platform's `GET /spaces/:spaceId/activity`; `--follow` stays, one page a line with `--json`, and asks again
|
|
33
|
+
when the platform does not answer.
|
|
34
|
+
- **The people in the builder see the agent work** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`, `@plitzi/sdk-mcp`,
|
|
35
|
+
`@plitzi/plitzi-builder`): an agent grant carries the application the member connected (`Grant.client`,
|
|
36
|
+
`StoredSpaceToken.client`, `SSRGrant.client`), and every MCP write `SSRWriteContext.client` — the history's
|
|
37
|
+
`client` for an agent, which was never set. A collaborator may be an agent (`SubscriptionCollaborator.agent`): the
|
|
38
|
+
builder draws it as a robot, names it `Claude · for ana` (`collaboratorTitle`) in the header, on the canvas and in
|
|
39
|
+
its notices. The deployment announces it — Plitzi's joins it on a write, selects what it changed, and lets it go
|
|
40
|
+
after a minute of nothing. `activityLine` names it the same way (`Claude for ana over the MCP, …`), so
|
|
41
|
+
`plitzi space activity` says which application wrote.
|
|
42
|
+
- A tool may declare `documents: false` (`ToolSpec`): the host loads none of the space for it, and passes the call's
|
|
43
|
+
abort signal through `ToolContext.activity`.
|
|
44
|
+
|
|
45
|
+
## Authoring
|
|
46
|
+
- **A file that does not parse is said at its line under any loader** (`@plitzi/sdk-authoring`): `moduleProblem` read
|
|
47
|
+
the first line of the error, and an esbuild transform (tsx, vitest) puts only `Transform failed with 1 error:` there
|
|
48
|
+
— the file, line and what is wrong are on the next. A line of the message that points at a file of the project is
|
|
49
|
+
now the problem (`src/space/hero.ts:139: Expected "}" but found ";"`), the project's root matched as given and as it
|
|
50
|
+
is on disk (`/var/…` and `/private/var/…` on macOS).
|
|
51
|
+
|
|
52
|
+
## Testing
|
|
53
|
+
- **`unusedPort` is chosen where the system never hands one out** (`@plitzi/sdk-server`): it answered a port the system
|
|
54
|
+
had just handed out (`listen(0)`), from the ephemeral range every outgoing connection takes its local port from — so
|
|
55
|
+
another worker's request could take it before the test listened, and CI failed `runtime.test.ts` with `EADDRINUSE`
|
|
56
|
+
(the page server then ends the process). It is a free port below that range now, at random, checked first.
|
|
57
|
+
|
|
58
|
+
## Docs
|
|
59
|
+
- **A self-hosted runtime's endpoints go in `data`**, as 0.38.15 moved them: `docs/en/runtimes.md`, the
|
|
60
|
+
`10-runtime` example and the website still put `served.stage` in `preAuth`, before the cross-site guard.
|
|
61
|
+
- New: `docs/en/activity.md`; `space watch` in `docs/en/agent-tooling.md`'s loop; the CLI README, the CLI skill, the
|
|
62
|
+
generated project's `AGENTS.md`, the MCP guide and README.
|
|
63
|
+
|
|
64
|
+
- Updated dependencies [9cfdccb]
|
|
65
|
+
- @plitzi/sdk-auth@0.38.16
|
|
66
|
+
- @plitzi/sdk-dev-tools@0.38.16
|
|
67
|
+
- @plitzi/sdk-elements@0.38.16
|
|
68
|
+
- @plitzi/sdk-event-bridge@0.38.16
|
|
69
|
+
- @plitzi/sdk-interactions@0.38.16
|
|
70
|
+
- @plitzi/sdk-navigation@0.38.16
|
|
71
|
+
- @plitzi/sdk-plugins@0.38.16
|
|
72
|
+
- @plitzi/sdk-schema@0.38.16
|
|
73
|
+
- @plitzi/sdk-shared@0.38.16
|
|
74
|
+
- @plitzi/sdk-style@0.38.16
|
|
75
|
+
- @plitzi/sdk-variables@0.38.16
|
|
76
|
+
|
|
3
77
|
## 0.38.15
|
|
4
78
|
|
|
5
79
|
### Patch Changes
|
package/dist/plitzi-sdk.js
CHANGED
|
@@ -40,7 +40,7 @@ return e.createElement(e.Fragment,null,h.map(t=>/* @__PURE__ */e.createElement("
|
|
|
40
40
|
return e.createElement(Gf,{...c,"aria-current":C,className:k,ref:u,style:E,to:a,viewTransition:s},"function"==typeof l?l(T):l)});Kf.displayName="NavLink";var Yf=e.forwardRef(({discover:t="render",fetcherKey:n,navigate:r,reloadDocument:i,replace:o,state:a,method:s=Cf,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:p,defaultShouldRevalidate:h,...f},m)=>{let{useTransitions:g}=e.useContext(ef),y=function(){let{router:t}=Jf("useSubmit"),{basename:n}=e.useContext(ef),r=vf("useRouteId"),i=t.fetch,o=t.navigate;return e.useCallback(async(e,t={})=>{let{action:a,method:s,encType:l,formData:c,body:u}=function(e,t){let n,r,i,o,a;if(Af(s=e)&&"form"===s.tagName.toLowerCase()){let a=e.getAttribute("action");r=a?Eh(a,t):null,n=e.getAttribute("method")||Cf,i=_f(e.getAttribute("enctype"))||Ef,o=new FormData(e)}else if(function(e){return Af(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return Af(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let a=e.form;if(null==a)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let s=e.getAttribute("formaction")||a.getAttribute("action");if(r=s?Eh(s,t):null,n=e.getAttribute("formmethod")||a.getAttribute("method")||Cf,i=_f(e.getAttribute("formenctype"))||_f(a.getAttribute("enctype"))||Ef,o=new FormData(a,e),!function(){if(null===If)try{new FormData(document.createElement("form"),0),If=!1}catch(aM){If=!0}return If}()){let{name:t,type:n,value:r}=e;if("image"===n){let e=t?`${t}.`:"";o.append(`${e}x`,"0"),o.append(`${e}y`,"0")}else t&&o.append(t,r)}}else{if(Af(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Cf,r=null,i=Ef,a=e}var s;return o&&"text/plain"===i&&(a=o,o=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:o,body:a}}(e,n);if(!1===t.navigate){let e=t.fetcherKey||Zf();await i(e,r,t.action||a,{defaultShouldRevalidate:t.defaultShouldRevalidate,preventScrollReset:t.preventScrollReset,formData:c,body:u,formMethod:t.method||s,formEncType:t.encType||l,flushSync:t.flushSync})}else await o(t.action||a,{defaultShouldRevalidate:t.defaultShouldRevalidate,preventScrollReset:t.preventScrollReset,formData:c,body:u,formMethod:t.method||s,formEncType:t.encType||l,replace:t.replace,state:t.state,fromRouteId:r,flushSync:t.flushSync,viewTransition:t.viewTransition})},[i,o,n,r])}(),b=function(t,{relative:n}={}){let{basename:r}=e.useContext(ef),i=e.useContext(nf);ih(i,"useFormAction must be used inside a RouteContext");let[o]=i.matches.slice(-1),a={...df(t||".",{relative:n})},s=sf();if(null==t){a.search=s.search;let e=new URLSearchParams(a.search),t=e.getAll("index");if(t.some(e=>""===e)){e.delete("index"),t.filter(e=>e).forEach(t=>e.append("index",t));let n=e.toString();a.search=n?`?${n}`:""}}return t&&"."!==t||!o.route.index||(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),"/"!==r&&(a.pathname="/"===a.pathname?r:Mh([r,a.pathname])),lh(a)}(l,{relative:u}),v="get"===s.toLowerCase()?"get":"post",w="string"==typeof l&&eh.test(l);/* @__PURE__ */
|
|
41
41
|
return e.createElement("form",{ref:m,method:v,action:b,onSubmit:i?c:t=>{if(c&&c(t),t.defaultPrevented)return;t.preventDefault();let i=t.nativeEvent.submitter,l=i?.getAttribute("formmethod")||s,f=()=>y(i||t.currentTarget,{fetcherKey:n,method:l,navigate:r,replace:o,state:a,relative:u,preventScrollReset:d,viewTransition:p,defaultShouldRevalidate:h});g&&!1!==r?e.startTransition(()=>f()):f()},...f,"data-discover":w||"render"!==t?void 0:"true"})});function Jf(t){let n=e.useContext(Yh);return ih(n,function(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}(t)),n}Yf.displayName="Form";var Xf=0,Zf=()=>`__${String(++Xf)}__`;function Qf({basename:t,children:n,location:r="/"}){"string"==typeof r&&(r=ch(r));let i={pathname:r.pathname||"/",search:r.search||"",hash:r.hash||"",state:null!=r.state?r.state:null,key:r.key||"default",mask:void 0},o={createHref:em,encodeLocation:tm,push(e){throw new Error(`You cannot use navigator.push() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(e)})\` somewhere in your app.`)},replace(e){throw new Error(`You cannot use navigator.replace() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(e)}, { replace: true })\` somewhere in your app.`)},go(e){throw new Error(`You cannot use navigator.go() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${e})\` somewhere in your app.`)},back(){throw new Error("You cannot use navigator.back() on the server because it is a stateless environment.")},forward(){throw new Error("You cannot use navigator.forward() on the server because it is a stateless environment.")}};/* @__PURE__ */
|
|
42
42
|
return e.createElement(Tf,{basename:t,children:n,location:i,navigationType:"POP",navigator:o,static:!0,useTransitions:!1})}function em(e){return"string"==typeof e?e:lh(e)}function tm(e){let t="string"==typeof e?e:lh(e);t=t.replace(/ $/,"%20");let n=eh.test(t)?new URL(t):new URL(t,"http://localhost");return{pathname:n.pathname,search:n.search,hash:n.hash}}var nm,rm=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],im=()=>{const e=new URLSearchParams(window.location.search),t={};for(const n of rm){const r=e.get(n);r&&(t[n.slice(4)]=r)}return Object.keys(t).length>0?t:void 0},om=()=>"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,am=e=>{nm=e},sm=(e,t)=>{nm?.track(e,t)},lm=({analytics:e})=>{const t=sf(),n=x(!0===e?.firstViewCounted);return g(()=>{if(!e?.endpoint||!e.key)return;const t=((e,t=20,n=5e3)=>{const r=[],i=`${e.endpoint.replace(/\/+$/,"")}/batch?k=${encodeURIComponent(e.key)}`;let o;const a=()=>{0!==r.length&&(e=>{const t=JSON.stringify({events:e});"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(i,t)||fetch(i,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},body:t,keepalive:!0,mode:"no-cors"}).catch(()=>{})})(r.splice(0,r.length))},s=e=>{r.push(e),r.length>=t&&a()},l=()=>({path:window.location.pathname,title:document.title||void 0});return"undefined"!=typeof window&&(o=setInterval(a,n),document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&a()}),window.addEventListener("pagehide",a)),{trackRender:()=>{s({id:om(),type:"render",ts:Date.now(),page:l(),ref:{referrer:document.referrer||void 0,utm:im()}})},track:(e,t)=>{s({id:om(),type:"interaction",ts:Date.now(),page:l(),name:e,props:t})},flush:a,stop:()=>{o&&(clearInterval(o),o=void 0),a()}}})(e);return am(t),()=>{am(void 0),t.stop()}},[e]),g(()=>{n.current?n.current=!1:nm?.trackRender()},[t.pathname,t.search]),null},cm=K("AuthContext",{}),um=({server:e,routerLocation:t})=>{let n=k(()=>typeof window<"u"?window.location:pr(e,"location",{pathname:"/"}),[e]),r=k(()=>{if(!t)return n;let{origin:e,host:r,hostname:i,protocol:o,href:a}=n,{pathname:s,search:l}=t;return{origin:e,host:r,hostname:i,protocol:o,pathname:s,search:l,hash:"",href:e?`${e}${s}${l}`:a}},[n,t]),i=k(()=>function(e){!e&&typeof window<"u"&&(e=window.location.search);let t={};if(!e||0===e.length)return t;let n=e.replace("?","").split("&");for(let r=0;r<n.length;r++){let e=n[r].split("="),i=decodeURIComponent(e[0]),o=decodeURIComponent(e[1]);void 0===t[i]?t[i]=decodeURIComponent(o):"string"==typeof t[i]?t[i]=[t[i],decodeURIComponent(o)]:t[i].push(decodeURIComponent(o))}return t}(r.search),[r.search]),o=k(()=>r.hostname?r.hostname:"localhost",[r.hostname]),a=r.origin||"";return k(()=>({queryParams:i,hostname:o,origin:a,location:r}),[i,o,a,r])},dm=(e,t)=>{let n="string"==typeof e?{path:e,caseSensitive:!1,end:!0}:{path:e.path,caseSensitive:e.caseSensitive??!1,end:e.end??!0},[r,i]=((e,t,n)=>{let r=[],i=`^${e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,o)=>{if(r.push({paramName:t,isOptional:void 0!==n}),void 0===n)return"/([^\\/]+)";let a=o.charAt(i+e.length);return a&&"/"!==a?"/([^\\/]*)":"(?:/([^\\/]*))?"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2")}`;return e.endsWith("*")?(r.push({paramName:"*",isOptional:!1}),i+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":""!==e&&"/"!==e&&(i+="(?:(?=\\/|$))"),[new RegExp(i,t?void 0:"i"),r]})(n.path,n.caseSensitive,n.end),o=t.match(r);if(!o)return null;let a=o[0],s=o.slice(1),l=a.replace(/(.)\/+$/,"$1");return{params:i.reduce((e,{paramName:t,isOptional:n},r)=>{let i=s[r];if("*"===t){let e=i??"";l=a.slice(0,a.length-e.length).replace(/(.)\/+$/,"$1")}return n&&!i?(e[t]=void 0,e):(e[t]=(i??"").replace(/%2F/g,"/"),e)},{}),pathname:a,pathnameBase:l,pattern:n}},pm=e=>/^https?:\/\//i.test(e),hm=e=>e.replaceAll(/\/+/g,"/"),fm=e=>hm(e.replace(/{{([a-zA-Z0-9-_:*/]+)}}/gi,":$1")),mm=(e,t)=>{if(!t||!e[t])return"";let{slug:n,parentId:r}=e[t];return r?`${mm(e,r)}/${n}`:n};function gm(e,t,n,r=!1){let i=n.replace(/^\/+/,""),{slug:o="",folder:a,default:s}=e[i]?.attributes??{slug:i,folder:"",default:!1};if(s&&!r)return{"/":n,[`/${n}`]:n};if(s&&r)return"/";if(!a&&!r)return{[fm(`/${o}`)]:n,[fm(`/${n}`)]:n};if(!a&&r)return hm(`/${o}`);if(!t.find(e=>e.id===a))return r?hm(`/${o}`):{[fm(`/${o}`)]:n,[fm(`/${n}`)]:n};let l=[mm(t.reduce((e,t)=>({...e,[t.id]:t}),{}),a),o].filter(Boolean).join("/");return r?hm(`/${l}`):{[fm(`/${l}`)]:n,[fm(`/${n}`)]:n}}var ym=(e,t,n)=>{let r=n.indexOf("#");if(r>0)return`${ym(e,t,n.slice(0,r))}${n.slice(r)}`;let i=e[n];if(!i)return n;let{slug:o,default:a}=i.attributes;return"string"==typeof o?gm(e,t,n,!0):a?"/":`/${n}`},bm=(e,t,n=!0)=>!(e&&n&&void 0!==t&&(!t||"authenticated"!==e)&&(t||"public"!==e)&&(t&&"public"===e||e)),vm=(e={},t=[],n,r="",i=!0)=>Object.keys(e).reduce((o,a)=>{let{attributes:{accessLevel:s,enabled:l=!0,unauthorizedBehaviour:c}}=e[a],u=e[a].attributes.unauthorizedPageRedirect;if(!l&&i)return o;u&&=(e=>pm(e)||e.includes("{{"))(u)?u:gm(e,t,u,!0);let d=gm(e,t,a),p="*"===e[a].attributes.slug,h=Object.keys(d).map(e=>({pageId:a,path:`${r}${e}`.replaceAll("//","/"),accessLevel:s,enabled:l,isRaw:`/${a}`===e,unauthorizedBehaviour:c,unauthorizedPageRedirect:u,hasAccess:bm(s,n,i),...p?{notFound:!0}:{}}));return[...o,...h]},[]).sort((e,t)=>!!e.notFound==!!t.notFound?e.path===t.path?"authenticated"===e.accessLevel?-1:1:e.path>t.path?-1:1:e.notFound?1:-1),wm=(e,t,n)=>{if(!t)return{action:{type:"accessDenied",path:void 0},pathMatch:void 0};let r=[];e.forEach(e=>{let n=dm({path:e.path,end:"*"!==e.path},t);n&&r.push({matchResult:n,path:e,pageId:e.pageId})});let i=e=>e.find(({path:{accessLevel:e}})=>"authenticated"===e&&n||"public"===e&&!n||!e)??e.find(({path:{accessLevel:e}})=>"authenticated"===e&&!n||"public"===e&&n),o=i(r.filter(({path:e})=>!e.notFound))??i(r.filter(({path:e})=>e.notFound));if(!o)return{action:{type:"notFound",path:void 0},pathMatch:void 0};let{pageId:a,matchResult:s,path:{hasAccess:l,unauthorizedBehaviour:c,unauthorizedPageRedirect:u,notFound:d}}=o;return!l&&"redirect"===c&&u?{action:{type:"redirect",path:u},pathMatch:void 0}:l?{action:{type:d?"notFound":"normal",path:void 0},pathMatch:s,pageId:a}:{action:{type:"accessDenied",path:void 0},pathMatch:void 0}},km=e=>e&&"string"==typeof e?(e.match(/:[a-zA-Z0-9-_:*]+/gim)||[]).map(e=>e.replace(":","")):[],xm=({authenticated:e,user:t})=>{let n=t?.details,r={authenticated:!0===e};return n?{...r,email:n.email,username:n.username,roles:n.roles}:r},Sm=/* @__PURE__ */new Set,Tm=async e=>(await Promise.all([...Sm].map(async t=>t(e)))).some(e=>!0===e),Cm=["missing","expired","revoked","inactive","unverified","malformed","outdated","network"],Em=(e,t)=>{if(401!==e)return;let n=t?.reason;return"string"==typeof n&&Cm.includes(n)?n:"expired"},Am=e=>/([^.]+\.[^.]+)$/.exec(e)?.[1]??e,Im=(e,t)=>{let n=e?.attributes[t];return"string"==typeof n?n:""},Om=(e,t,n)=>{let r=[],i=/* @__PURE__ */new Set,o=t,a=n;for(;o&&!i.has(o)&&r.length<16;){let t=e(o);if("layoutContainer"!==t?.definition.type)break;i.add(o),r.push({layout:o,slot:a||o}),o=Im(t,"layout"),a=Im(t,"layoutContainer")}return r},_m=(e,t,n,r)=>{if(void 0===t)return[];let i=n?new Set(n):void 0,o=[],a=/* @__PURE__ */new Set,s=e.flat[t],l=e=>"string"==typeof e?e:"",c=[t,...s?Om(t=>e.flat[t],l(s.attributes.layout),l(s.attributes.layoutContainer)).map(e=>e.layout):[]];for(;c.length>0;){let t=c.pop();if(void 0===t||a.has(t))continue;a.add(t);let n=e.flat[t];if(!n||r&&!Pi(n.definition.flag,r))continue;"server"===n.definition.runtime&&(!i||i.has(n.id))&&o.push(n);let{items:s}=n.definition;s&&c.push(...s)}return o},Nm=/\{[{%]/,Mm=(e,t)=>{if("string"!=typeof e)return;let n=Nm.test(e)?Yn(e,t):e,r="string"==typeof n||"number"==typeof n?String(n).trim():"";return""===r||Nm.test(r)?void 0:r},Pm=e=>`rsc.data.${e}`,Lm=()=>typeof window>"u"?"":`${window.location.pathname}${window.location.search}`,Rm="*",jm=/* @__PURE__ */new Map,zm=/* @__PURE__ */new WeakMap,Dm=()=>({seq:0,inFlight:/* @__PURE__ */new Set,asked:/* @__PURE__ */new Map}),$m=e=>{let t=e.get("rsc.instance");if("string"==typeof t&&t){let e=jm.get(t);if(e)return e;let n=Dm();return jm.set(t,n),n}let n=zm.get(e);if(n)return n;let r=Dm();return zm.set(e,r),r},Fm=(e,t)=>{let n={};t.inFlight.forEach(e=>{e.here&&(e.ids??[Rm]).forEach(e=>{n[e]=!0})}),e.set("rsc.refreshing",n)},qm=async(e,t,n,{location:r,fresh:i=!1}={})=>{let{enabled:o,endpoint:a}=e.get("rsc")??{};if(!o||!a||typeof window>"u")return;let s=r??Lm(),l=e.get("schema"),c=e.get("runtime.sources.auth"),u=r?((e,t,n)=>{if(!e)return;let r=e.pages.reduce((t,n)=>(n in e.flat&&(t[n]=e.flat[n]),t),{});return wm(vm(r,e.pageFolders,n),t.split("?")[0],n).pageId})(l,r,!!c?.details):e.get("navigation.currentPageId"),d=r?void 0:e.get("runtime.sources.flags");if(!l)return;let p=t?.length?((e,t,n,r)=>{let i=new Set(_m(e,t,[...n],r).map(({id:e})=>e));return n.filter(e=>i.has(e))})(l,u,t,d):void 0;if(p?!p.length:!((e,t,n)=>_m(e,t,void 0,n).length>0)(l,u,d))return;let h=new URLSearchParams({location:s});p?.length&&h.set("ids",p.join(",")),Object.entries(n??{}).forEach(([e,t])=>h.set(e,t));let f=`${a}?${h.toString()}`,m=$m(e),g=[...m.inFlight].find(e=>e.url===f&&(e.fresh||!i));if(g)return g.promise;m.inFlight.forEach(e=>{((e,t)=>!e||!!t&&t.every(t=>e.includes(t)))(p,e.ids)&&e.controller.abort()});let y=++m.seq;p?.length?p.forEach(e=>m.asked.set(e,y)):(m.asked.clear(),m.asked.set(Rm,y));let b=new AbortController,v={url:f,...p?.length?{ids:p}:{},here:s===Lm(),fresh:i,seq:y,controller:b,promise:Promise.resolve()},w=async t=>{let n=await fetch(f,{...i?{cache:"no-cache",headers:{Accept:"application/json","Cache-Control":"no-cache"}}:{headers:{Accept:"application/json"}},signal:b.signal});if(!n.ok){let r=Em(n.status,await n.json().catch(()=>{}));return r&&await Tm({reason:r,url:a})&&!t?w(!0):void e.set("rsc.stale",!0)}let{serverData:r,actionRuns:o}=await n.json();o?.length&&ft(o),((e,t,n,r,i)=>{let{ids:o,seq:a}=n;e.batch(()=>{if(o?.length)Object.entries(r).forEach(([n,r])=>{(t.asked.get(n)??0)<=a&&(t.asked.get(Rm)??0)<=a&&e.set(Pm(n),r)});else{let n=e.get("rsc.data")??{},i=e=>e!==Rm&&(t.asked.get(e)??0)>a,o=Object.fromEntries([...Object.entries(r).filter(([e])=>!i(e)),...Object.entries(n).filter(([e])=>i(e))]);e.set("rsc.data",o)}e.set("rsc.loaded",!0),e.set("rsc.stale",!1),e.set("rsc.location",i)})})(e,m,v,r??{},s)};return v.promise=w(!1).catch(()=>{b.signal.aborted||e.set("rsc.stale",!0)}).finally(()=>{m.inFlight.delete(v),Fm(e,m)}),m.inFlight.add(v),Fm(e,m),v.promise},Bm=["wheel","touchmove","keydown","pointerdown"],Um=e=>{const t=document.getElementById(e);return t?.scrollIntoView({block:"start"}),null!==t},Hm=({children:e,currentPageId:t})=>{const{server:n}=h(Kd),r=zt(),{renderMode:i,previewMode:o,environment:a}=re(),[[s,l,c,u,d]]=Bt(["schema.pageFolders","pageDefinitions","schema.variables","schema.flags","flags.overrides"]),p=n.ssr?.renderResult,m="widget"!==i?sf():void 0,{queryParams:y,hostname:b,origin:v,location:w}=um({server:n,routerLocation:m}),S=x(l);S.current=l;const T=x(s);T.current=s;const{authenticated:C,user:E}=h(cm),A="widget"!==i?uf():void 0,_=x(A);g(()=>{_.current=A},[A]);const N=k(()=>vm(l,s,C,n.basePath,o),[l,s,C,n.basePath,o]),{action:M,pageId:P="",pathMatch:L}=k(()=>"widget"===i?{action:{type:"normal",path:""},pageId:t||wm(N,"/",C).pageId}:wm(N,w.pathname,C),[N,w.pathname,C,i,t]),R=t||P;(({hash:e,navigationKey:t,enabled:n})=>{g(()=>{const t=(e=>{const t=e.replace(/^#/,"");try{return decodeURIComponent(t)}catch{return t}})(e);if(!n||!t||"undefined"==typeof document||Um(t))return;const r=new AbortController,i=new MutationObserver(()=>{Um(t)&&r.abort()}),o=setTimeout(()=>r.abort(),3e3);return r.signal.addEventListener("abort",()=>{i.disconnect(),clearTimeout(o)}),i.observe(document.body,{childList:!0,subtree:!0}),Bm.forEach(e=>window.addEventListener(e,()=>r.abort(),{once:!0,passive:!0,signal:r.signal})),()=>r.abort()},[e,t,n])})({hash:m?.hash??"",navigationKey:m?.key,enabled:o&&"widget"!==i}),g(()=>{$d.info("navigation",/* @__PURE__ */O("span",{children:["Navigated to page"," ",
|
|
43
|
-
/* @__PURE__ */I("b",{children:pr(l,`${R}.attributes.name`,R||"Unknown")})]}),{status:M.type,elementId:R})},[M.type,R,l]);const j=f(e=>ym(S.current,T.current,e),[]),z=x(0),D=f((e,t=!1)=>{if(t&&"undefined"!=typeof window)return void(window.location.href=e);const n=j(e),i=++z.current;if(!r.get("rsc.enabled"))return r.set("navigation.pendingLocation",""),void _.current?.(n);r.set("navigation.pendingLocation",n);const o=qm(r,void 0,void 0,{location:n}).finally(()=>{z.current===i&&r.set("navigation.pendingLocation","")}),a=()=>{z.current===i&&_.current?.(n)};Promise.race([o,new Promise(e=>setTimeout(e,1500))]).then(a,a)},[j,r]),$=k(()=>{const e=N.find(e=>e.pageId===R&&!e.isRaw);return e?{...km(e.path).reduce((e,t)=>({...e,[t]:""}),{}),...pr(L,"params",{})}:pr(L,"params",{})},[N,L,R]),F=Rd($),q=Rd(y),B=k(()=>new URLSearchParams(w.search),[w.search]),U=v?`${v}${w.pathname}${w.search}`:"",H=Object.hasOwn(l,R)?l[R].definition.flag:void 0,W=void 0!==H&&!Pi(H,Mi(Ni(u,{environment:a,hostname:b,routeParams:F,queryParams:q,user:xm({authenticated:C,user:E})},d))),V=W?((e,t)=>e.find(e=>e.hasAccess&&e.notFound&&dm({path:e.path,end:!0},t))?.pageId)(N,w.pathname)??"":R;if(Ut(["navigation.urlSearchParams","navigation.routeParams","navigation.queryParams","navigation.hostname","navigation.origin","navigation.href","navigation.currentPageId","navigation.navigate"],[B,F,q,b,v,U,V,D],{raw:!0}),"notFound"===M.type||W)return p&&(p.status=404),V?e:"Not Found";if("accessDenied"===M.type)return p&&(p.status=403),"Access Denied";if("redirect"===M.type){const e=Ld(c,{queryParams:y,routeParams:F,hostname:b,environment:a}),t=M.path?String(Vn(M.path,{variables:e},!1,!0)):"";if(t&&pm(t)){const e=new URL(t);return e.searchParams.has("redirect")||e.searchParams.set("redirect",(e=>e.href?e.href:`${e.protocol||"https:"}//${e.host||e.hostname}${e.pathname}${e.search}`)(w)),p?(p.redirect=e.toString(),null):(window.location.assign(e.toString()),null)}return p?(p.redirect=M.path??"",null):/* @__PURE__ */I(Sf,{to:M.path??"",replace:!0})}return e},Wm=(e,{src:t,type:n,isMain:r},i=!1)=>{let o,a=`${e}/${t}`,s=btoa(a);return o="style"===n&&a.endsWith(".css")?{type:"link",id:s,params:{href:a,rel:"stylesheet",type:"text/css"},isMain:r}:{type:"script",id:s,params:{src:a,type:"text/javascript"},isMain:r},i&&delete o.isMain,o},Vm=(e,t)=>{try{let{resource:n,settings:r,type:i}=e,{definition:{name:o="Plitzi's Demo Plugin",owner:a="Plitzi",verified:s=!1,license:l="MIT",website:c="https://plitzi.com",backgroundColor:u="#4422ee",icon:d="https://cdn.plitzi.com/resources/img/favicon.svg"},assets:p,assetsSettings:h,pluginSchema:f}=t;return Object.values(pr(t,"pluginSchema",{})).reduce((e,m)=>{let{definition:g,builder:y,defaultStyle:b,attributes:v}=m,w=[];return g.type===i&&(w=Object.keys(vr(f,[i]))),{...e,[g.type]:{attributes:v,builder:y,defaultStyle:b,definition:g,market:{owner:a,verified:s,license:l,website:c,backgroundColor:u,icon:d,category:o},resource:n,isMain:g.type===i,manifest:t,type:i,settings:r,assetsSettings:Object.values(h).filter(({src:e})=>!!e&&[".css",".js",".mjs",".cjs"].some(t=>e.endsWith(t))).map(e=>Wm(n,e,!0)),assets:Object.values(p).filter(({src:e})=>!!e&&[".css",".js",".mjs",".cjs"].some(t=>e.endsWith(t))).map(e=>Wm(n,e)),subPlugins:w}}},{})}catch{return{}}},Gm=async(e=[])=>{let t={};if(!Array.isArray(e))return t;let n=await(async e=>{if(!Array.isArray(e)||0===e.length)return{};let t=e.map(e=>(async e=>{try{let t=await fetch(e,{headers:{Accept:"application/json"}});return t.ok?await t.json():void 0}catch{return}})(e));return(await Promise.allSettled(t)).reduce((e,t)=>"fulfilled"===t.status&&t.value?{...e,[pr(t.value,"root","")]:t.value}:e,{})})(e.filter(e=>e.resource).reduce((e,t)=>[...e,`${t.resource}/plugin-manifest.json`],[]));return e.forEach(e=>{let{type:r}=e,i=pr(n,r);t={...t,...Vm(e,i)}}),t},Km={},Ym={Init:"\n query InitQuery($environment: String!, $revision: Int) {\n Space(environment: $environment, revision: $revision) {\n schema {\n settings\n rsc\n flat {\n id\n definition {\n label\n type\n initialState\n styleSelectors\n bindings\n interactions\n parentId\n rootId\n items\n runtime\n loadStrategy\n flag {\n name\n is\n }\n anchor\n motion {\n enter\n on\n duration\n delay\n stagger\n loop\n }\n }\n attributes\n }\n pages\n components\n flags\n pageFolders {\n id\n name\n slug\n parentId\n }\n variables {\n name\n type\n value\n subValues {\n when\n value\n }\n }\n }\n plugins {\n type\n resource\n settings\n }\n style {\n variables\n cache\n }\n # The schema fetch is the one moment a client-side render hears from the server at all, so the decision it\n # would have been handed in an SSR bootstrap travels here instead.\n render {\n overQuota\n }\n }\n }\n"},Jm=K("NetworkInternalContext",{}),Xm=e=>({...e.enter?{enter:e.enter}:{},...e.on?{on:e.on}:{},..."number"==typeof e.duration?{duration:e.duration}:{},..."number"==typeof e.delay?{delay:e.delay}:{},..."number"==typeof e.stagger?{stagger:e.stagger}:{},...e.loop?{loop:e.loop}:{}}),Zm=({definition:e,...t})=>{let{parentId:n,items:r,bindings:i,interactions:o,initialState:a,runtime:s,loadStrategy:l,flag:c,anchor:u,motion:d,quiet:p,...h}=e;return{...t,definition:{...h,...null==n?{}:{parentId:n},...null==r?{}:{items:r},...null==i?{}:{bindings:i},...null==o?{}:{interactions:o},...null==a?{}:{initialState:a},...null==s?{}:{runtime:s},...null==l?{}:{loadStrategy:l},...null==c?{}:{flag:c},...null==u?{}:{anchor:u},...null==d?{}:{motion:Xm(d)},...null==p?{}:{quiet:p}}}},Qm=e=>({...e,flat:Object.fromEntries(e.flat.map(e=>[e.id,Zm(e)]))}),eg=class extends Error{failure;statusCode;constructor(e,t,n){super(e),this.name="GraphqlRequestError",this.failure=t,this.statusCode=n}},tg=({children:e,server:t,revision:n,webKey:r="",webId:i,userKey:o="",instanceId:a,offlineMode:s=!1,offlineData:l,offlineDataType:c="json"})=>{const{environment:u,debugMode:d}=re(),p=Wt(),m=s&&!!l&&!!l.schema,y=k(()=>((e,t)=>({request:async(n,r)=>{let i;try{i=await fetch(e,{method:"POST",headers:{accept:"application/graphql-response+json, application/json;q=0.9","content-type":"application/json","sdk-version":"0.38.
|
|
43
|
+
/* @__PURE__ */I("b",{children:pr(l,`${R}.attributes.name`,R||"Unknown")})]}),{status:M.type,elementId:R})},[M.type,R,l]);const j=f(e=>ym(S.current,T.current,e),[]),z=x(0),D=f((e,t=!1)=>{if(t&&"undefined"!=typeof window)return void(window.location.href=e);const n=j(e),i=++z.current;if(!r.get("rsc.enabled"))return r.set("navigation.pendingLocation",""),void _.current?.(n);r.set("navigation.pendingLocation",n);const o=qm(r,void 0,void 0,{location:n}).finally(()=>{z.current===i&&r.set("navigation.pendingLocation","")}),a=()=>{z.current===i&&_.current?.(n)};Promise.race([o,new Promise(e=>setTimeout(e,1500))]).then(a,a)},[j,r]),$=k(()=>{const e=N.find(e=>e.pageId===R&&!e.isRaw);return e?{...km(e.path).reduce((e,t)=>({...e,[t]:""}),{}),...pr(L,"params",{})}:pr(L,"params",{})},[N,L,R]),F=Rd($),q=Rd(y),B=k(()=>new URLSearchParams(w.search),[w.search]),U=v?`${v}${w.pathname}${w.search}`:"",H=Object.hasOwn(l,R)?l[R].definition.flag:void 0,W=void 0!==H&&!Pi(H,Mi(Ni(u,{environment:a,hostname:b,routeParams:F,queryParams:q,user:xm({authenticated:C,user:E})},d))),V=W?((e,t)=>e.find(e=>e.hasAccess&&e.notFound&&dm({path:e.path,end:!0},t))?.pageId)(N,w.pathname)??"":R;if(Ut(["navigation.urlSearchParams","navigation.routeParams","navigation.queryParams","navigation.hostname","navigation.origin","navigation.href","navigation.currentPageId","navigation.navigate"],[B,F,q,b,v,U,V,D],{raw:!0}),"notFound"===M.type||W)return p&&(p.status=404),V?e:"Not Found";if("accessDenied"===M.type)return p&&(p.status=403),"Access Denied";if("redirect"===M.type){const e=Ld(c,{queryParams:y,routeParams:F,hostname:b,environment:a}),t=M.path?String(Vn(M.path,{variables:e},!1,!0)):"";if(t&&pm(t)){const e=new URL(t);return e.searchParams.has("redirect")||e.searchParams.set("redirect",(e=>e.href?e.href:`${e.protocol||"https:"}//${e.host||e.hostname}${e.pathname}${e.search}`)(w)),p?(p.redirect=e.toString(),null):(window.location.assign(e.toString()),null)}return p?(p.redirect=M.path??"",null):/* @__PURE__ */I(Sf,{to:M.path??"",replace:!0})}return e},Wm=(e,{src:t,type:n,isMain:r},i=!1)=>{let o,a=`${e}/${t}`,s=btoa(a);return o="style"===n&&a.endsWith(".css")?{type:"link",id:s,params:{href:a,rel:"stylesheet",type:"text/css"},isMain:r}:{type:"script",id:s,params:{src:a,type:"text/javascript"},isMain:r},i&&delete o.isMain,o},Vm=(e,t)=>{try{let{resource:n,settings:r,type:i}=e,{definition:{name:o="Plitzi's Demo Plugin",owner:a="Plitzi",verified:s=!1,license:l="MIT",website:c="https://plitzi.com",backgroundColor:u="#4422ee",icon:d="https://cdn.plitzi.com/resources/img/favicon.svg"},assets:p,assetsSettings:h,pluginSchema:f}=t;return Object.values(pr(t,"pluginSchema",{})).reduce((e,m)=>{let{definition:g,builder:y,defaultStyle:b,attributes:v}=m,w=[];return g.type===i&&(w=Object.keys(vr(f,[i]))),{...e,[g.type]:{attributes:v,builder:y,defaultStyle:b,definition:g,market:{owner:a,verified:s,license:l,website:c,backgroundColor:u,icon:d,category:o},resource:n,isMain:g.type===i,manifest:t,type:i,settings:r,assetsSettings:Object.values(h).filter(({src:e})=>!!e&&[".css",".js",".mjs",".cjs"].some(t=>e.endsWith(t))).map(e=>Wm(n,e,!0)),assets:Object.values(p).filter(({src:e})=>!!e&&[".css",".js",".mjs",".cjs"].some(t=>e.endsWith(t))).map(e=>Wm(n,e)),subPlugins:w}}},{})}catch{return{}}},Gm=async(e=[])=>{let t={};if(!Array.isArray(e))return t;let n=await(async e=>{if(!Array.isArray(e)||0===e.length)return{};let t=e.map(e=>(async e=>{try{let t=await fetch(e,{headers:{Accept:"application/json"}});return t.ok?await t.json():void 0}catch{return}})(e));return(await Promise.allSettled(t)).reduce((e,t)=>"fulfilled"===t.status&&t.value?{...e,[pr(t.value,"root","")]:t.value}:e,{})})(e.filter(e=>e.resource).reduce((e,t)=>[...e,`${t.resource}/plugin-manifest.json`],[]));return e.forEach(e=>{let{type:r}=e,i=pr(n,r);t={...t,...Vm(e,i)}}),t},Km={},Ym={Init:"\n query InitQuery($environment: String!, $revision: Int) {\n Space(environment: $environment, revision: $revision) {\n schema {\n settings\n rsc\n flat {\n id\n definition {\n label\n type\n initialState\n styleSelectors\n bindings\n interactions\n parentId\n rootId\n items\n runtime\n loadStrategy\n flag {\n name\n is\n }\n anchor\n motion {\n enter\n on\n duration\n delay\n stagger\n loop\n }\n }\n attributes\n }\n pages\n components\n flags\n pageFolders {\n id\n name\n slug\n parentId\n }\n variables {\n name\n type\n value\n subValues {\n when\n value\n }\n }\n }\n plugins {\n type\n resource\n settings\n }\n style {\n variables\n cache\n }\n # The schema fetch is the one moment a client-side render hears from the server at all, so the decision it\n # would have been handed in an SSR bootstrap travels here instead.\n render {\n overQuota\n }\n }\n }\n"},Jm=K("NetworkInternalContext",{}),Xm=e=>({...e.enter?{enter:e.enter}:{},...e.on?{on:e.on}:{},..."number"==typeof e.duration?{duration:e.duration}:{},..."number"==typeof e.delay?{delay:e.delay}:{},..."number"==typeof e.stagger?{stagger:e.stagger}:{},...e.loop?{loop:e.loop}:{}}),Zm=({definition:e,...t})=>{let{parentId:n,items:r,bindings:i,interactions:o,initialState:a,runtime:s,loadStrategy:l,flag:c,anchor:u,motion:d,quiet:p,...h}=e;return{...t,definition:{...h,...null==n?{}:{parentId:n},...null==r?{}:{items:r},...null==i?{}:{bindings:i},...null==o?{}:{interactions:o},...null==a?{}:{initialState:a},...null==s?{}:{runtime:s},...null==l?{}:{loadStrategy:l},...null==c?{}:{flag:c},...null==u?{}:{anchor:u},...null==d?{}:{motion:Xm(d)},...null==p?{}:{quiet:p}}}},Qm=e=>({...e,flat:Object.fromEntries(e.flat.map(e=>[e.id,Zm(e)]))}),eg=class extends Error{failure;statusCode;constructor(e,t,n){super(e),this.name="GraphqlRequestError",this.failure=t,this.statusCode=n}},tg=({children:e,server:t,revision:n,webKey:r="",webId:i,userKey:o="",instanceId:a,offlineMode:s=!1,offlineData:l,offlineDataType:c="json"})=>{const{environment:u,debugMode:d}=re(),p=Wt(),m=s&&!!l&&!!l.schema,y=k(()=>((e,t)=>({request:async(n,r)=>{let i;try{i=await fetch(e,{method:"POST",headers:{accept:"application/graphql-response+json, application/json;q=0.9","content-type":"application/json","sdk-version":"0.38.16",authorization:t?`Bearer ${t}`:""},body:JSON.stringify({query:n,variables:r})})}catch(aM){throw new eg(aM instanceof Error?aM.message:"Network request failed","network")}const o=(e=>{try{return JSON.parse(e)}catch{return}})(await i.text());if(!i.ok){const t=Em(i.status,o);throw t&&Tm({reason:t,url:e}),new eg(`Response not successful: Received status code ${i.status}`,"http",i.status)}const a=(e=>{const t=X(e)?e.errors:void 0;return Array.isArray(t)?t.map(e=>X(e)&&"string"==typeof e.message?e.message:"Unknown error"):[]})(o);if(a.length)throw new eg(a.join("\n"),"graphql",i.status);if(!X(o)||!X(o.data))throw new eg("The server answered without data","graphql",i.status);return o.data}}))(t.serverUrl,r),[t.serverUrl,r]),[b,v]=S(!(s&&l)),[w,x]=S(void 0),{components:T}=h(Wr),[C,E]=S(()=>m&&"json"===c?{...l,plugins:{}}:{plugins:{}}),A=f(async(e,t)=>{try{return{success:!0,result:await y.request(Ym[e],{environment:u,...t})}}catch(aM){return{success:!1,result:void 0,error:aM instanceof Error?aM:String(aM)}}},[y,u]),_=f(async(e,t,n=!0)=>{const r=Km[e];if(!r)return{success:!1,result:void 0,error:"Mutation Not Found"};try{return{success:!0,result:await y.request(r,n?{environment:u,...t}:t)}}catch(aM){return{success:!1,result:void 0,error:aM instanceof Error?aM:String(aM)}}},[y,u]),N=async()=>{let e=n;"number"==typeof n&&0!==n||(e=void 0);const t=await A("Init",{environment:u,revision:e});if(t.error)return v(!1),void x((e=>e instanceof eg?401===e.statusCode?"Access not authorized":"network"===e.failure?"Service not available":e.message:"string"==typeof e?e:e.message)(t.error));if(t.success&&t.result){const{Space:e}=mr(t.result);if(!e)return x(/* @__PURE__ */O("span",{children:["Space not found, publish to ",
|
|
44
44
|
/* @__PURE__ */I("b",{children:u})," environment"]})),void v(!1);let n={};e.plugins.length>0&&(n=await Gm(e.plugins.filter(e=>!T.current[e.type]))),p("render.overQuota",e.render?.overQuota??!1),E({schema:{...cu,...Qm(e.schema)},plugins:n,style:e.style})}v(!1)};g(()=>{s&&l?m&&(async()=>{let e={};l?.plugins&&l.plugins.length>0&&(e=await Gm(l.plugins.filter(e=>!T.current[e.type]))),E(t=>({...t,plugins:e})),v(!1)})():(v(e=>e||!0),N())},[m,s&&c,r,u,d]);const M=k(()=>({query:A,mutate:_,webKey:r,webId:i,server:t,environment:u,instanceId:a,userKey:o}),[A,_,r,i,t,u,a,o]);return w?/* @__PURE__ */I("div",{children:w}):b?null:/* @__PURE__ */I(Kd,{value:M,children:/* @__PURE__ */I(Jm,{value:C,children:e})})},ng=({children:e,plugins:t,sdkStylePath:n="./plitzi-sdk.css",sdkIconsPath:r="./plitzi-sdk-icons.css"})=>{const{renderMode:i}=re(),[o,a]=S({}),s=h(Jm),l=k(()=>t||s.plugins,[t,s]),{components:c}=h(Wr),u=f((e,t,n="")=>t?pr(l,`${e}.settings.${t}`,n):pr(l,`${e}.settings`,{}),[l]),d=f((e=[])=>{const t=e.reduce((e,t)=>{let n="";return n="script"===t.type?t.params.src:t.params.href,n?(n=btoa(n),{...e,[n]:{...t,key:n}}):e},{});0!==Object.keys(t).length&&a(e=>({...e,...t}))},[]),p=f((e=[])=>{const t=e.filter(e=>!function(e){return null==e||"number"!=typeof e&&"boolean"!=typeof e&&"function"!=typeof e&&"symbol"!=typeof e&&("string"==typeof e||Array.isArray(e)?0===e.length:e instanceof Map||e instanceof Set?0===e.size:"object"==typeof e&&0===Object.keys(e).length)}(e)).map(e=>btoa(e));a(e=>vr(e,t))},[]),m=k(()=>(e=>Object.values(e).reduce((e,t)=>({...e,...pr(t,"assets",[]).filter(e=>"link"===e.type).reduce((e,t)=>({...e,[btoa(t.id)]:t}),{})}),{}))(l),[l]),g=k(()=>Object.keys(c.current).filter(e=>"local-custom"===c.current[e].origin).reduce((e,t)=>({...e,...pr(c,`${t}.assets`,[]).reduce((e,n,r)=>({...e,[`${t}-${r}`]:{type:"link",id:`${t}-${r}`,params:n}}),{})}),{}),[c.current]),y=k(()=>{const e={};return"iframe"!==i&&"shadow"!==i||(e["static-99"]={type:"link",id:"static-99",params:{type:"text/css",href:n,rel:"stylesheet"}},e["static-100"]={type:"link",id:"static-100",params:{type:"text/css",href:r,rel:"stylesheet"}}),{...e,...g,...m,...o}},[g,m,o,i,n,r]),b=k(()=>({assets:y,getSettings:u,plugins:l,registerCustomAssets:d,unregisterCustomAssets:p}),[y,u,l,d,p]),v=k(()=>Object.values({...m,...o}).map((e,t)=>/* @__PURE__ */I(e.type,{...e.params},t)),[m,o]);/* @__PURE__ */
|
|
45
45
|
return O(A,{children:[/* @__PURE__ */I(Np,{children:("raw"===i||"widget"===i)&&v}),/* @__PURE__ */I(Li,{value:b,children:e})]})},rg=({children:e,schema:t})=>{const n=h(Jm),r=k(()=>({...cu,...t||n.schema}),[t,n.schema]);Ut("schema",r);const{flat:i,pages:o}=r,a=Rd(k(()=>fr(i,o),[i,o]));return Ut("pageDefinitions",a),e},ig=l({});ig.displayName="ContainerRootContext";var og=({className:e="",children:t,...n})=>{let r=x(null),i=f(()=>r.current instanceof HTMLElement?r.current.getRootNode():void 0,[r]),o=f(()=>i()instanceof ShadowRoot,[i]),a=k(()=>({getHost:i,rootRef:r,isRootShadow:o}),[i,r,o]);/* @__PURE__ */
|
|
46
46
|
return I("div",{...n,ref:r,className:e,children:/* @__PURE__ */I(ig,{value:a,children:t})})},ag={desktop:1024,tablet:768,mobile:0},sg=e=>0===ag[e]?"0":`${String(ag[e]/16)}rem`,lg=e=>e<=ag.tablet?"mobile":e<=ag.desktop?"tablet":"desktop",cg="plitzi-sdk-runtime",ug=e=>e.links.filter(e=>"stylesheet"===e.rel).reduce((e,t,n)=>{let r=`font-${n}`;return{...e,[r]:{type:"link",id:r,params:{href:t.href,type:"text/css",rel:"stylesheet"}}}},{}),dg="https://fonts.googleapis.com",pg={woff2:"font/woff2",woff:"font/woff"},hg=e=>{try{let t=new URL(e);return"https:"===t.protocol&&!t.username&&!t.password}catch{return!1}},fg=e=>{try{return new URL(e).origin}catch{return}},mg={"<":"\\3c ",">":"\\3e "},gg=e=>`"${e.replace(/[\\"<>]/g,e=>mg[e]??`\\${e}`)}"`,yg=/^U\+[0-9A-Fa-f?]{1,6}(-[0-9A-Fa-f]{1,6})?(\s*,\s*U\+[0-9A-Fa-f?]{1,6}(-[0-9A-Fa-f]{1,6})?)*$/,bg=e=>encodeURIComponent(e).replace(/%20/g,"+"),vg=(e,t)=>["@font-face{",`font-family:${gg(e.family)};`,`font-style:${"italic"===t.style?"italic":"normal"};`,`font-weight:${Number.parseInt(String(t.weight),10)||400};`,`font-display:${e.display??"swap"};`,`src:url(${gg(t.url)}) format(${gg(t.format)});`,t.unicodeRange&&yg.test(t.unicodeRange)?`unicode-range:${t.unicodeRange};`:"","}"].join(""),wg="/*plitzi:style-cache*/",kg="/*plitzi:style-cache-end*/",xg=(e="theme")=>Xe({mode:"system",scheme:"light",areas:{}},{id:e}),Sg=xg(),Tg=(e,t)=>"system"===e?t:e,Cg=(e,t=Sg)=>{t.batch(()=>{t.setState("mode",e),t.setState("areas",{})})},Eg=(e,t=Sg)=>{t.setState("scheme",e)},Ag=K("ThemeScopeContext",void 0),Ig=K("ThemeStartContext",void 0),Og=e=>{let t=h(Ig),n=k(()=>void 0===t?void 0:(e=>({mode:"system",scheme:"light",areas:{},mode:e}))(t),[t]);return T(e.subscribe,e.getState,()=>n??e.getState())},_g="canvas",Ng=e=>{let t=h(Ag)??Sg,n=Og(t),r=((e,t)=>(t?e.areas[t]:void 0)??e.mode)(n,e),i=Tg(r,n.scheme),o=f(n=>e?((e,t,n=Sg)=>{n.setState(`areas.${e}`,t)})(e,n,t):Cg(n,t),[e,t]),a=f(()=>o("dark"===i?"light":"dark"),[i,o]);return k(()=>({theme:r,resolvedTheme:i,setTheme:o,toggleTheme:a}),[r,i,o,a])},Mg=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/,Pg=/^rgba?\(\s*(\d{1,3}%?\s*,\s*){2,3}\d{1,3}%?\s*\)$/,Lg=/^hsla?\(\s*\d{1,3}(deg|rad|turn)?\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%(\s*,\s*(0|0?\.\d+|1))?\s*\)$/,Rg=/* @__PURE__ */new Set(["black","white","red","green","blue","yellow","cyan","magenta","orange","purple","brown","pink","gray","lime","teal","navy","silver","maroon","olive","aqua","fuchsia"]),jg=({children:e,contentDidMount:t,contentDidDismount:n})=>(g(()=>(t?.(),()=>{n?.()}),[]),e),zg=({ref:e,className:t="",ssrMode:r=!1,id:i="",css:o="",style:a,zoom:s=1,assets:l,viewport:c="width=device-width, initial-scale=1",children:u,contentDidMount:d,contentDidDismount:p,contentDidUpdate:h,onLoad:m})=>{t=Ll("ContainerFrame",{className:t,componentKey:"root"});let y=x(null);v(e,()=>y.current,[y]);let[b,w]=S(!1),[k,T]=S(null),C=f((e,t,n)=>{let r=[...t.childNodes],i=n.getElementById("customStyle");Object.values(e).forEach(e=>{let o=n.createElement(e.type);e.id&&o.setAttribute("data-id",e.id),Object.keys(e.params).forEach(t=>{("link"===e.type||"script"===e.type)&&o.setAttribute(t,e.params[t])}),r.find(t=>"link"===e.type&&t.href===o.href||"script"===e.type&&t.src===o.src)||(t.insertBefore(o,i),r.push(o))})},[]),E=f((e,t)=>{let{head:n}=e,r=n.querySelectorAll('*:not([asset-static="true"])');Object.values(r).forEach(e=>{n.removeChild(e)}),t&&C(t,n,e)},[C]),[N]=S(()=>(e=>{if(!e)return"";let t=[];return Object.values(e).forEach(e=>{t.push(`<${e.type} ${Object.keys(e.params).map(t=>`${t}="${e.params[t]}"`).join(" ")}>`)}),t.join("")})(l)),M=f(()=>d?.(),[d]);g(()=>{b&&k&&E(k,l)},[b,l,k,E]);let P=f(()=>{let e=y.current&&k,t=y.current?.contentDocument===k;!e||t?b||(m?.(y.current),w(!0),T(y.current?.contentDocument)):T(y.current?.contentDocument)},[b,k,m]);return g(()=>{k&&(k.body.style.zoom=1===s?"":`${s}`)},[k,s]),/* @__PURE__ */O("iframe",{ref:y,className:t,title:"#",srcDoc:`<!DOCTYPE html><html><head>${N}</head><body></body></html>`,id:i,onLoad:P,style:a,children:[b&&k&&_(/* @__PURE__ */O(A,{children:[
|
|
@@ -155,4 +155,4 @@ return O(og,{className:V(e,t&&"system"!==r&&r),"data-hydrated":i?"":void 0,child
|
|
|
155
155
|
return I(Wr,{value:p,children:n})},eM=K("EnclosingSpaceContext",!1),tM=e=>({apiServer:"https://api.plitzi.com",ssrServer:"https://ssr.plitzi.com",serverUrl:"https://server.plitzi.com",websocketServer:"wss://server.plitzi.com",subscriptionServer:"wss://server.plitzi.com/subscriptions",...e}),nM={Button:$l,ContentEditable:Kp,Input:Gl,Heading:Jp,ContainerResizable:$p,ContainerCollapsable:zp,Text:Qp,ContainerTabs:Vp},rM=({className:e,children:t,webKey:r="",server:o,renderMode:a=ne.renderMode,routing:s="browser",debugMode:l=!1,themeScope:c,theme:d,state:p,forcedFlags:m,...y})=>{const b=k(()=>function(e){if(!e)return 0;let t={};try{let n=e.split(".")[1],r=typeof window<"u"?window.atob(n):Buffer.from(n,"base64").toString();t=JSON.parse(r)}catch{return 0}let n=Number(pr(t,"sub",0));return Number.isInteger(n)&&n>0?n:0}(r),[r]),v=h(eM),w=c??(v?"container":"document"),T=v&&"raw"===a?"widget":a,C=e??(v?void 0:"min-h-screen"),E=x(p).current,A=k(()=>({runtime:{sources:{},state:E??{}},render:{...ne,ownsHead:!v,enclosed:v}}),[E,v]),O=k(()=>(e=>{let t=e?.split(":")[1];return t?`plitzi_debug_${t}`:"plitzi_debug"})("undefined"==typeof window?void 0:window.location.host),[]),[_,N]=S(()=>(e=>{if("undefined"==typeof document)return!0;for(const t of document.cookie.split(";")){const n=t.indexOf("=");if(-1!==n&&t.slice(0,n).trim()===e)return"false"!==decodeURIComponent(t.slice(n+1).trim())}return!0})(O)),M=l&&_,[P]=S(()=>m||!l||"undefined"==typeof window?m:((e,t)=>(e=>e?Object.fromEntries(e.split(",").map(e=>e.split(":")).filter(([e,t])=>oi(e)&&("1"===t||"0"===t)).map(([e,t])=>[e,"1"===t])):{})(ai(e,li(t))))(si(),window.location.host)),L=k(()=>tM(o),[o]);g(()=>{},[]);const R=f(()=>{const e=!_;((e,t)=>{"undefined"!=typeof document&&(document.cookie=`${e}=${JSON.stringify(t)}; path=/; max-age=31536000; samesite=lax`)})(O,e),N(e)},[O,_]);(({authorized:e,onToggle:t})=>{const n=f(e=>{var n;e.shiftKey&&"F12"===e.key?t():!e.shiftKey||!e.altKey||"KeyD"!==e.code||(n=e.target)instanceof HTMLElement&&(n.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(n.tagName))||(e.preventDefault(),t())},[t]);g(()=>{if(e)return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,n])})({authorized:l,onToggle:R}),g(()=>{},[l,_,O]),g(()=>{if(M)return window.plitziTracing={lastCommitId:Vu.lastCommitId,commitsSince:Vu.commitsSince},()=>{delete window.plitziTracing}},[M]),g(()=>{y.isHydrating&&Vu.setHydrated()},[y.isHydrating]);const j=k(()=>{const e={};return n.forEach(t,t=>{if(!u(t))return;if(t.type!==uO)return;const{renderType:n,component:r,assets:i=[],...o}=t.props;if(!n||!r)return;const a=r;a.type=n,a.assets=i,a.extraProps=o,e[n]=a}),e},[t]);"undefined"==typeof window&&L.requestUrl;const z="widget"===T?i:"undefined"==typeof window?Qf:"memory"===s?xf:Vf,D="widget"===T?{}:{..."memory"===s&&"undefined"!=typeof window?{}:{basename:pr(L,"basePath","/"),location:"undefined"==typeof window?L.requestUrl??"":void 0}};/* @__PURE__ */
|
|
156
156
|
return I(eM,{value:!0,children:/* @__PURE__ */I(Mt,{value:A,middlewares:[ke(Fd("sdk")),zN(b),...M?[()=>({onChange:e=>Vu.recordStoreChange(e)}),be({shouldRecord:e=>!(e?.startsWith("runtime.elements")||e?.startsWith("rsc")||e?.startsWith("theme")||e?.startsWith("flags"))})]:[]],children:/* @__PURE__ */I(DN,{scope:w,theme:d,children:/* @__PURE__ */I(Zp,{components:nM,applyColorModeClass:!1,children:/* @__PURE__ */I(qN,{scoped:"container"===w,className:V("plitzi-sdk","flex",C,{"sdk-debug-mode":M}),children:/* @__PURE__ */I(Ip,{children:/* @__PURE__ */I(z,{...D,children:/* @__PURE__ */I(QN,{localCustomComponents:j,localComponents:oM,children:/* @__PURE__ */I(vN,{server:L,webKey:r,renderMode:T,debugMode:M,webId:b,forcedFlags:P,...y})})})})})})})})})},iM=Ku(({ref:e,className:t,spaceKey:n,environment:r="main",offlineData:i})=>{const{settings:{previewMode:o}}=vu(),{server:a}=h(Kd),s=k(()=>void 0===i?void 0:(e=>{if(!X(e))return{problem:"The documents cannot be drawn: they are not an object with `schema` and `style`."};const t=["schema","style"].filter(t=>void 0===e[t]);return t.length>0?{waiting:t}:(e=>void 0===Yd(e.schema,e.style))(e)?{documents:e}:{problem:`The documents cannot be drawn: ${Yd(e.schema,e.style)??"their shape is unknown"}.`}})(i),[i]),l=s&&"problem"in s?s.problem:void 0,c=s&&"waiting"in s?s.waiting:void 0,u=s&&"documents"in s?s.documents:void 0,d=void 0!==s&&!!n;return g(()=>{l&&console.error(`[plitziSdk] ${l}`)},[l]),g(()=>{d&&console.warn("[plitziSdk] Both `offlineData` and `spaceKey` are set: the documents are drawn, the key is not.")},[d]),/* @__PURE__ */O(Gd,{ref:e,className:V("plitzi-component__plitzi-sdk",t,{"with__plitzi-sdk":!o}),children:[u&&/* @__PURE__ */I(rM,{offlineMode:!0,offlineData:u,environment:r,renderMode:"widget",className:"h-full w-full"}),!s&&n&&/* @__PURE__ */I(rM,{webKey:n,environment:r,server:a,renderMode:"widget",className:"h-full w-full"}),l&&!o&&/* @__PURE__ */I("p",{className:"plitzi-sdk__problem",children:l}),c&&!o&&/* @__PURE__ */O("p",{className:"plitzi-sdk__waiting",children:["Waiting for ",c.map(e=>`\`${e}\``).join(" and ")," to be bound."]})]})}),oM={plitziSdk:Object.assign(iM,{...H,content:{...H.content,market:{...H.content.market,icon:/* @__PURE__ */I(q,{})}}})},aM=class extends Error{stage;log;constructor(e,t){super(`${"link"===e?"program failed to link":`${e} shader failed`}: ${t.trim()||"no log given"}`),this.name="ShaderError",this.stage=e,this.log=t}},sM=(e,t,n)=>{let r=e.createShader("vertex"===t?e.VERTEX_SHADER:e.FRAGMENT_SHADER);if(!r)throw new aM(t,"the context made no shader (it is lost)");if(e.shaderSource(r,n),e.compileShader(r),!0!==e.getShaderParameter(r,e.COMPILE_STATUS)){let n=e.getShaderInfoLog(r)??"";throw e.deleteShader(r),new aM(t,n)}return r},lM=(e,{vertex:t,fragment:n})=>{let r=sM(e,"vertex",t),i=sM(e,"fragment",n),o=e.createProgram();if(e.attachShader(o,r),e.attachShader(o,i),e.linkProgram(o),e.deleteShader(r),e.deleteShader(i),!0!==e.getProgramParameter(o,e.LINK_STATUS)){let t=e.getProgramInfoLog(o)??"";throw e.deleteProgram(o),new aM("link",t)}return o},cM="(prefers-reduced-motion: reduce)",uM=()=>"function"==typeof window.matchMedia&&window.matchMedia(cM).matches||document.documentElement.classList.contains("plitzi-reduced-motion"),dM=e=>{let t="function"==typeof window.matchMedia?window.matchMedia(cM):void 0;t?.addEventListener("change",e);let n=new MutationObserver(e);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{t?.removeEventListener("change",e),n.disconnect()}},pM=()=>T(dM,uM,()=>!1),hM=e=>(document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)),fM=()=>"hidden"!==document.visibilityState,mM=(e,{paused:t=!1,fps:n,target:r}={})=>{let i=vu().settings.previewMode??!0,o=pM(),a=T(hM,fM,()=>!1),s=(e=>{let[t,n]=S(!0);return g(()=>{let t=e?.current;if(!t||typeof IntersectionObserver>"u")return;let r=new IntersectionObserver(e=>n(e.some(e=>e.isIntersecting)));return r.observe(t),()=>r.disconnect()},[e]),t})(r),l=i&&!o&&!t&&a&&s,c=x(e);g(()=>{c.current=e},[e]);let u=x({time:0,frame:0});return g(()=>{if(!l)return;let e,t=n&&n>0?1e3/n:0,r=0,i=0,o=n=>{let a=void 0===e?0:n-e;if(e=n,i+=a,i>=t){let e=t>0?i:a;i=t>0?i%t:0,u.current={time:u.current.time+e,frame:u.current.frame+1},c.current({...u.current,delta:e})}r=requestAnimationFrame(o)};return r=requestAnimationFrame(o),()=>cancelAnimationFrame(r)},[l,n]),{running:l}},gM=(e,{setup:t,draw:n,maxPixelRatio:r=2,paused:i,fps:o})=>{let a=(e=>`[plugin ${e?.definition?.type??"canvas"}${e?.id?` "${e.id}"`:""}]`)(h(Y)),s=x(null),[l,c]=S(null),[u,d]=S({width:0,height:0,pixelRatio:1}),[p,m]=S(),[y,b]=S(!1),[v,w]=S(0),k=x(null),T=x({acquire:e,setup:t,draw:n});g(()=>{T.current={acquire:e,setup:t,draw:n}},[e,t,n]);let C=f(e=>{let t=e instanceof Error?e.message:String(e);console.error(`${a} ${t}`),m(t)},[a]),E=f(e=>{s.current=e,c(e)},[]);g(()=>{if(!l)return;let e=()=>{let e=l.getBoundingClientRect(),t=Math.min(window.devicePixelRatio||1,r);l.width=Math.max(1,Math.round(e.width*t)),l.height=Math.max(1,Math.round(e.height*t)),d({width:e.width,height:e.height,pixelRatio:t})};if(e(),typeof ResizeObserver>"u")return;let t=new ResizeObserver(e);return t.observe(l),()=>t.disconnect()},[l,r]),g(()=>{if(!l)return;let e=e=>{e.preventDefault(),k.current=null,b(!1)},t=()=>w(e=>e+1);return l.addEventListener("webglcontextlost",e),l.addEventListener("webglcontextrestored",t),()=>{l.removeEventListener("webglcontextlost",e),l.removeEventListener("webglcontextrestored",t)}},[l]),g(()=>{if(l&&0!==u.width&&void 0===p)try{let e=T.current.acquire(l);if(!e)return void C(/* @__PURE__ */Error("the browser gave no drawing context (WebGL may be off)"));e.prepare(u);let t=T.current.setup?T.current.setup(e.context,u):void 0;k.current={handle:e,state:t}}catch(aM){C(aM)}},[l,u,v,p,C]);let A=f(e=>{let t=k.current;if(t&&void 0===p)try{t.handle.prepare(u),T.current.draw(t.handle.context,{...e,...u,state:t.state}),b(!0)}catch(e){k.current=null,C(e)}},[u,p,C]),{running:I}=mM(A,{paused:i||void 0!==p,fps:o,target:s});return g(()=>{!I&&u.width>0&&A({time:0,delta:0,frame:0})},[I,u,v,A]),{ref:E,ready:y,error:p,running:I}},yM=({attributes:e,...t})=>gM(f(t=>{let n=t.getContext("2d",e);return n&&{context:n,prepare:({pixelRatio:e})=>n.setTransform(e,0,0,e,0,0)}},[e]),t),bM=({attributes:e,...t})=>gM(f(t=>{let n=t.getContext("webgl",e);return n&&{context:n,prepare:()=>n.viewport(0,0,t.width,t.height)}},[e]),t),vM=({attributes:e,...t})=>gM(f(t=>{let n=t.getContext("webgl2",e);return n&&{context:n,prepare:()=>n.viewport(0,0,t.width,t.height)}},[e]),t),wM=e=>"string"==typeof e&&e?e:void 0,kM=e=>n.toArray(e).flatMap(e=>{if(!u(e))return[];let t=(e=>{let t=e.props;return e.type===ti?wM(t.id):wM(t.internalProps?.id)})(e);return void 0===t?[]:[{id:t,node:e}]}),xM=e=>"function"==typeof e.checkVisibility?e.checkVisibility():e.getClientRects().length>0,SM=e=>{let{utils:{rootRef:t}}=vu(),[n,r]=S(void 0);return g(()=>{let n=t.current,i=n?.ownerDocument.defaultView;if(!n||!i||!e)return;let o=`[data-plitzi-el="${i.CSS.escape(e)}"]`,a=()=>r([...n.querySelectorAll(o)].some(xM)),s=0,l=new i.MutationObserver(()=>{s||=i.requestAnimationFrame(()=>{s=0,a()})});return l.observe(n,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class","style"]}),i.addEventListener("resize",a),a(),()=>{l.disconnect(),i.removeEventListener("resize",a),i.cancelAnimationFrame(s)}},[e,t]),n},TM=e=>{let{id:t}=Yu(),{settings:{previewMode:n=!0}}=vu(),{interactionsManager:r}=h(Id);return f((i,o)=>{n&&r.interactionTrigger(t,e.triggers[i].action,o)},[e,t,r,n])},CM=e=>{let[t]=Dt("actions.endpoint");return f((n="/")=>{if(!t)return;let r=((e,t="/")=>`/fn/plugins/${encodeURIComponent(e)}${t.startsWith("/")?t:`/${t}`}`)(e,n);return typeof window>"u"?r:new URL(r,new URL(t,window.location.href)).href},[t,e])},EM={mobile:`(max-width: ${sg("tablet")})`,tablet:`(max-width: ${sg("desktop")})`},AM=e=>typeof window>"u"||"function"!=typeof window.matchMedia?void 0:window.matchMedia(e),IM=()=>AM(EM.mobile)?.matches?"mobile":AM(EM.tablet)?.matches?"tablet":"desktop",OM=e=>{let t=[AM(EM.mobile),AM(EM.tablet)].filter(e=>void 0!==e);return t.forEach(t=>{t.addEventListener("change",e)}),()=>{t.forEach(t=>{t.removeEventListener("change",e)})}},_M=()=>"desktop",NM=()=>T(OM,IM,_M),MM=e=>{let[t,n]=S(void 0);return g(()=>{let t=e.current;if(!t||typeof ResizeObserver>"u")return;let r=(e,t)=>n(n=>n?.width===e&&n.height===t?n:{width:e,height:t}),i=t.getBoundingClientRect();r(i.width,i.height);let o=new ResizeObserver(e=>{e.slice(-1).forEach(e=>r(e.contentRect.width,e.contentRect.height))});return o.observe(t),()=>o.disconnect()},[e]),t},PM=e=>{const t=h(J_);return f(async(n,r={})=>{if(!t)return console.warn(`[plitzi] useServerAction: nothing on this page runs server actions, so "${e}" was skipped`),{ok:!1,runId:"",reason:"skipped"};const i=await t({actionId:e,input:n,...r});return"completed"!==i.status?{ok:!1,runId:i.runId,reason:i.reason??i.status,...i.error?{error:i.error}:{}}:{ok:!0,runId:i.runId,output:i.output}},[e,t])},LM=(e,t)=>new Promise(n=>{const r=document.createElement("link");r.rel="stylesheet",r.href=e,r.dataset.plitziPlugin=t,r.onload=()=>n(),r.onerror=()=>n(),document.head.append(r)}),RM=(e,{load:t,css:n,declaration:r})=>{let i;const o=(r,{content:s,version:l,initialItems:c,plugins:u})=>{const p=d(async()=>({default:r.reduce((t,n)=>{const r=t.plugins?.[n];if(!r)throw new Error(`[plitzi] plugin "${e}" was loaded without the "${n}" it declared`);return r},await(i??=Promise.all([t(),n?LM(n,e):void 0]).then(([e])=>e.default)))})),h=e=>/* @__PURE__ */I(a,{fallback:null,children:/* @__PURE__ */I(p,{...e})});return h.displayName=`Deferred(${r.at(-1)??e})`,Object.assign(h,{content:s,version:l,initialItems:c,plugins:u?Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o([...r,e],t)])):void 0})};return o([],r)},jM=e=>{try{return JSON.stringify({...e},(e,t)=>"function"==typeof t?void 0:t)}catch{return}},zM=e=>{const t=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;return{plugins:Object.fromEntries(Object.entries(e).map(([e,i])=>{t.set(e,i.component);const o=((e,r)=>{const i=(e=>t=>{const r=n.get(e)??/* @__PURE__ */new Set;return r.add(t),n.set(e,r),()=>{r.delete(t)}})(e),o=()=>t.get(e)??r,a=e=>{const t=T(i,o,o);/* @__PURE__ */
|
|
157
157
|
return I(t,{...e})};return a.displayName=`Hot(${r.displayName??r.name})`,Object.assign(a,r)})(e,i.component);return r.set(e,o),[e,{...i,component:o}]})),replace:(e,i)=>{const o=t.get(e),a=r.get(e);return!(!o||!a||jM(o)!==jM(i)||(t.set(e,i),n.get(e)?.forEach(e=>{e()}),0))}}};Promise.resolve({ });function DM(e,t={},n={},r=!1,i=!1,{hotPlugins:o=!1}={}){const a=Object.fromEntries(Object.entries(n).map(([e,t])=>{if("component"in t)return[e,t];const{load:n,css:r,declaration:i,...o}=t;return[e,{...o,component:RM(e,{load:n,css:r,declaration:i})}]})),s=o?zM(a):void 0,l=s?.plugins??a,{actionRuns:c,styleCacheInDocument:u,...d}=(e=>{if(e.analytics||e.offlineMode||!e.webKey)return e;const{apiServer:t}=tM(e.server);return t?{...e,analytics:{endpoint:`${t.replace(/\/+$/,"")}/v1/collect`,key:e.webKey}}:e})(t),p="undefined"!=typeof document?document.getElementById(e):void 0,h=u?((e,t)=>{const{offlineData:n}=e;if(!n||!t)return e;const r=(e=>{let t=e.querySelector('style[data-id="plitzi-runtime-style"]')?.textContent??"",n=t.indexOf(wg),r=t.indexOf(kg,n);if(!(n<0||r<0))return t.slice(n+22,r)})(t);return void 0===r?(console.error("[plitzi] The server-rendered stylesheet is missing from the page: it renders without its styles."),e):{...e,offlineData:{...n,style:{...n.style,cache:r}}}})(d,p):d,m=h.debugMode??r;m&&c?.length&&ft(c);const y=({isHydrating:e=!1})=>{const[t,n]=S(!e);g(()=>n(!0),[]);const r=Object.keys(l).filter(e=>t||!l[e].clientOnly);m||(()=>{if(typeof window>"u")return;let e=()=>{},t=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;"object"==typeof t&&Object.keys(t).forEach(n=>{let r=t[n];t[n]="function"==typeof r?e:null})})();const i=f(e=>{gO=e},[]),o=f(e=>{yO=e},[]);/* @__PURE__ */
|
|
158
|
-
return I(rM,{...h,debugMode:m,isHydrating:e,onInitStateManager:i,onInitEventBridge:o,children:r.filter(e=>!!l[e].component).map(e=>/* @__PURE__ */I(bO.Plugin,{renderType:e,component:l[e].component,...l[e].props},e))})};if(!p)return;const b=i?E(p,/* @__PURE__ */I(y,{isHydrating:!0})):C(p);return i||b.render(/* @__PURE__ */I(y,{})),{unmount:()=>b.unmount(),replacePlugin:(e,t)=>s?.replace(e,t)??!1}}var $M=({debugMode:e=!1,isHydrating:t=!1,children:n,webKey:r="",environment:i="main",renderMode:o=ne.renderMode,...a})=>/* @__PURE__ */I(rM,{...a,isHydrating:t,renderMode:o,debugMode:e,webKey:r,environment:i,children:n});$M.Plugin=bO.Plugin;var FM="0.38.
|
|
158
|
+
return I(rM,{...h,debugMode:m,isHydrating:e,onInitStateManager:i,onInitEventBridge:o,children:r.filter(e=>!!l[e].component).map(e=>/* @__PURE__ */I(bO.Plugin,{renderType:e,component:l[e].component,...l[e].props},e))})};if(!p)return;const b=i?E(p,/* @__PURE__ */I(y,{isHydrating:!0})):C(p);return i||b.render(/* @__PURE__ */I(y,{})),{unmount:()=>b.unmount(),replacePlugin:(e,t)=>s?.replace(e,t)??!1}}var $M=({debugMode:e=!1,isHydrating:t=!1,children:n,webKey:r="",environment:i="main",renderMode:o=ne.renderMode,...a})=>/* @__PURE__ */I(rM,{...a,isHydrating:t,renderMode:o,debugMode:e,webKey:r,environment:i,children:n});$M.Plugin=bO.Plugin;var FM="0.38.16",qM=()=>gO,BM=()=>yO;export{Br as A,je as B,ts as C,Wr as ComponentContext,QN as ComponentProvider,ci as D,di as E,kt as F,V as H,yt as I,JN as JsxManager,pt as L,pr as M,Dt as N,ui as O,Ct as P,wu as PlitziProvider,Kg as PluginManager,Kr as PluginRemote,Li as PluginsContext,at as R,Yg as ReplicaProvider,Gd as RootElement,Fl as S,aM as ShaderError,Ii as T,ge as V,Dp as _,UO as a,Tu as b,uv as c,lM as createShaderProgram,xy as d,$M as default,kM as elementChildren,Ng as f,qp as g,BM as getEventBridge,qM as getStateManager,Gp as h,HO as i,kr as j,Vr as k,cv as l,Om as m,n_ as n,qO as o,lg as p,r_ as r,DM as render,qE as s,oM as sdkComponents,c_ as t,sm as track,Ay as u,mM as useAnimationFrame,yM as useCanvas2d,mA as useChannel,NM as useDisplayMode,Yu as useElement,MM as useElementSize,SM as useElementVisible,XN as useFlag,JI as useNotify,vu as usePlitzi,CM as usePluginRoute,TM as usePluginTrigger,pM as useReducedMotion,RE as useRscData,LE as useRscRefresh,PM as useServerAction,Bt as useStore,bM as useWebGL,vM as useWebGL2,Vd as v,FM as version,es as w,Ku as withElement,Kl as x,Vu as y,st as z};
|
package/dist/plitzi-sdk.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/plitzi-sdk",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.16",
|
|
4
4
|
"homepage": "./",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"files": [
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"@fortawesome/fontawesome-free": "^7.3.1",
|
|
34
34
|
"@plitzi/nexus": "^1.4.0",
|
|
35
35
|
"@plitzi/plitzi-ui": "^1.6.33",
|
|
36
|
-
"@plitzi/sdk-auth": "0.38.
|
|
37
|
-
"@plitzi/sdk-dev-tools": "0.38.
|
|
38
|
-
"@plitzi/sdk-elements": "0.38.
|
|
39
|
-
"@plitzi/sdk-event-bridge": "0.38.
|
|
40
|
-
"@plitzi/sdk-interactions": "0.38.
|
|
41
|
-
"@plitzi/sdk-navigation": "0.38.
|
|
42
|
-
"@plitzi/sdk-plugins": "0.38.
|
|
43
|
-
"@plitzi/sdk-schema": "0.38.
|
|
44
|
-
"@plitzi/sdk-shared": "0.38.
|
|
45
|
-
"@plitzi/sdk-style": "0.38.
|
|
46
|
-
"@plitzi/sdk-variables": "0.38.
|
|
36
|
+
"@plitzi/sdk-auth": "0.38.16",
|
|
37
|
+
"@plitzi/sdk-dev-tools": "0.38.16",
|
|
38
|
+
"@plitzi/sdk-elements": "0.38.16",
|
|
39
|
+
"@plitzi/sdk-event-bridge": "0.38.16",
|
|
40
|
+
"@plitzi/sdk-interactions": "0.38.16",
|
|
41
|
+
"@plitzi/sdk-navigation": "0.38.16",
|
|
42
|
+
"@plitzi/sdk-plugins": "0.38.16",
|
|
43
|
+
"@plitzi/sdk-schema": "0.38.16",
|
|
44
|
+
"@plitzi/sdk-shared": "0.38.16",
|
|
45
|
+
"@plitzi/sdk-style": "0.38.16",
|
|
46
|
+
"@plitzi/sdk-variables": "0.38.16",
|
|
47
47
|
"clsx": "^2.1.1",
|
|
48
48
|
"react-router-dom": "^7.18.4"
|
|
49
49
|
},
|