create-prisma-php-app 4.0.0-beta.5 → 4.0.0-rc

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.
@@ -3,7 +3,7 @@ import { writeFileSync, existsSync, mkdirSync } from "fs";
3
3
  import browserSync, { BrowserSyncInstance } from "browser-sync";
4
4
  import prismaPhpConfigJson from "../prisma-php.json";
5
5
  import { generateFileListJson } from "./files-list.js";
6
- import { join, dirname } from "path";
6
+ import { join, dirname, relative } from "path";
7
7
  import { getFileMeta, PUBLIC_DIR, SRC_DIR } from "./utils.js";
8
8
  import { updateAllClassLogs } from "./class-log.js";
9
9
  import {
@@ -15,9 +15,10 @@ import { checkComponentImports } from "./component-import-checker";
15
15
  import { DebouncedWorker, createSrcWatcher, DEFAULT_AWF } from "./utils.js";
16
16
 
17
17
  const { __dirname } = getFileMeta();
18
-
19
18
  const bs: BrowserSyncInstance = browserSync.create();
20
19
 
20
+ const PUBLIC_IGNORE_DIRS = [''];
21
+
21
22
  const pipeline = new DebouncedWorker(
22
23
  async () => {
23
24
  await generateFileListJson();
@@ -68,7 +69,19 @@ createSrcWatcher(join(SRC_DIR, "**", "*"), {
68
69
  });
69
70
 
70
71
  createSrcWatcher(join(PUBLIC_DIR, "**", "*"), {
71
- onEvent: (_ev, _abs, rel) => publicPipeline.schedule(rel),
72
+ onEvent: (_ev, abs, _) => {
73
+ const relFromPublic = relative(PUBLIC_DIR, abs);
74
+ const normalized = relFromPublic.replace(/\\/g, "/");
75
+
76
+ const segments = normalized.split("/").filter(Boolean);
77
+ const firstSegment = segments[0] || "";
78
+
79
+ if (PUBLIC_IGNORE_DIRS.includes(firstSegment)) {
80
+ return;
81
+ }
82
+
83
+ publicPipeline.schedule(relFromPublic);
84
+ },
72
85
  awaitWriteFinish: DEFAULT_AWF,
73
86
  logPrefix: "watch-public",
74
87
  usePolling: true,
@@ -1,7 +1,6 @@
1
1
  <?php
2
2
 
3
3
  use PP\MainLayout;
4
- use PP\Request;
5
4
 
6
5
  MainLayout::$title = !empty(MainLayout::$title) ? MainLayout::$title : 'Create Prisma PHP App';
7
6
  MainLayout::$description = !empty(MainLayout::$description) ? MainLayout::$description : 'Generated by create Prisma PHP App';
@@ -12,11 +11,11 @@ MainLayout::$description = !empty(MainLayout::$description) ? MainLayout::$descr
12
11
 
13
12
  <head>
14
13
  <!-- Dynamic Meta Tags -->
15
- <link rel="icon" href="<?= Request::baseUrl; ?>/favicon.ico" type="image/x-icon" sizes="16x16" />
14
+ <link rel="icon" href="/favicon.ico" type="image/x-icon" sizes="16x16" />
16
15
  <!-- Dynamic Header Scripts -->
17
16
  </head>
18
17
 
19
- <body>
18
+ <body pp-spa="true">
20
19
  <?= MainLayout::$children; ?>
21
20
  <!-- Dynamic Footer Scripts -->
22
21
  </body>
package/dist/ts/main.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import "/js/pp-reactive-v1.js";
2
- import "/js/pp-utilities.js";
3
2
 
4
3
  // The following global names have already been declared elsewhere in the project:
5
4
  // - pp: Used for the Reactive Core functionality.
@@ -10,6 +10,11 @@ const entries = Object.fromEntries(
10
10
  })
11
11
  );
12
12
 
13
+ const VITE_WATCH_EXCLUDE = [
14
+ "public/js/**",
15
+ "node_modules/**",
16
+ ];
17
+
13
18
  function browserSyncNotify(): Plugin {
14
19
  const flagFile = path.resolve(__dirname, ".pp", ".vite-build-complete");
15
20
 
@@ -21,16 +26,17 @@ function browserSyncNotify(): Plugin {
21
26
  };
22
27
  }
23
28
 
24
- export default defineConfig({
29
+ export default defineConfig(({ command, mode }) => ({
25
30
  publicDir: false,
26
31
  build: {
27
32
  outDir: "public/js",
28
33
  emptyOutDir: false,
29
34
  minify: "esbuild",
30
35
  sourcemap: false,
31
- watch: {
32
- exclude: ["public/**", "node_modules/**"],
33
- },
36
+ watch:
37
+ command === "build" && mode === "development"
38
+ ? { exclude: VITE_WATCH_EXCLUDE }
39
+ : undefined,
34
40
  rollupOptions: {
35
41
  input: entries,
36
42
  external: [/^\/js\/.*/],
@@ -41,7 +47,8 @@ export default defineConfig({
41
47
  },
42
48
  },
43
49
  },
44
- plugins: [browserSyncNotify()],
50
+ plugins:
51
+ command === "build" && mode === "development" ? [browserSyncNotify()] : [],
45
52
  esbuild: { legalComments: "none" },
46
53
  define: { "process.env.NODE_ENV": '"production"' },
47
- });
54
+ }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "4.0.0-beta.5",
3
+ "version": "4.0.0-rc",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- import{P as ce}from"./pp-reactive-v1.js";var ee=11;function le(i,e){var t=e.attributes,n,a,r,s,u;if(!(e.nodeType===ee||i.nodeType===ee)){for(var f=t.length-1;f>=0;f--)n=t[f],a=n.name,r=n.namespaceURI,s=n.value,r?(a=n.localName||a,u=i.getAttributeNS(r,a),u!==s&&(n.prefix==="xmlns"&&(a=n.name),i.setAttributeNS(r,a,s))):(u=i.getAttribute(a),u!==s&&i.setAttribute(a,s));for(var b=i.attributes,y=b.length-1;y>=0;y--)n=b[y],a=n.name,r=n.namespaceURI,r?(a=n.localName||a,e.hasAttributeNS(r,a)||i.removeAttributeNS(r,a)):e.hasAttribute(a)||i.removeAttribute(a)}}var D,de="http://www.w3.org/1999/xhtml",v=typeof document>"u"?void 0:document,ue=!!v&&"content"in v.createElement("template"),he=!!v&&v.createRange&&"createContextualFragment"in v.createRange();function fe(i){var e=v.createElement("template");return e.innerHTML=i,e.content.childNodes[0]}function pe(i){D||(D=v.createRange(),D.selectNode(v.body));var e=D.createContextualFragment(i);return e.childNodes[0]}function ve(i){var e=v.createElement("body");return e.innerHTML=i,e.childNodes[0]}function ge(i){return i=i.trim(),ue?fe(i):he?pe(i):ve(i)}function $(i,e){var t=i.nodeName,n=e.nodeName,a,r;return t===n?!0:(a=t.charCodeAt(0),r=n.charCodeAt(0),a<=90&&r>=97?t===n.toUpperCase():r<=90&&a>=97?n===t.toUpperCase():!1)}function ye(i,e){return!e||e===de?v.createElement(i):v.createElementNS(e,i)}function me(i,e){for(var t=i.firstChild;t;){var n=t.nextSibling;e.appendChild(t),t=n}return e}function j(i,e,t){i[t]!==e[t]&&(i[t]=e[t],i[t]?i.setAttribute(t,""):i.removeAttribute(t))}var te={OPTION:function(i,e){var t=i.parentNode;if(t){var n=t.nodeName.toUpperCase();n==="OPTGROUP"&&(t=t.parentNode,n=t&&t.nodeName.toUpperCase()),n==="SELECT"&&!t.hasAttribute("multiple")&&(i.hasAttribute("selected")&&!e.selected&&(i.setAttribute("selected","selected"),i.removeAttribute("selected")),t.selectedIndex=-1)}j(i,e,"selected")},INPUT:function(i,e){j(i,e,"checked"),j(i,e,"disabled"),i.value!==e.value&&(i.value=e.value),e.hasAttribute("value")||i.removeAttribute("value")},TEXTAREA:function(i,e){var t=e.value;i.value!==t&&(i.value=t);var n=i.firstChild;if(n){var a=n.nodeValue;if(a==t||!t&&a==i.placeholder)return;n.nodeValue=t}},SELECT:function(i,e){if(!e.hasAttribute("multiple")){for(var t=-1,n=0,a=i.firstChild,r,s;a;)if(s=a.nodeName&&a.nodeName.toUpperCase(),s==="OPTGROUP")r=a,a=r.firstChild,a||(a=r.nextSibling,r=null);else{if(s==="OPTION"){if(a.hasAttribute("selected")){t=n;break}n++}a=a.nextSibling,!a&&r&&(a=r.nextSibling,r=null)}i.selectedIndex=t}}},R=1,ne=11,ae=3,ie=8;function T(){}function we(i){if(i)return i.getAttribute&&i.getAttribute("id")||i.id}function be(i){return function(t,n,a){if(a||(a={}),typeof n=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var r=n;n=v.createElement("html"),n.innerHTML=r}else n=ge(n);else n.nodeType===ne&&(n=n.firstElementChild);var s=a.getNodeKey||we,u=a.onBeforeNodeAdded||T,f=a.onNodeAdded||T,b=a.onBeforeElUpdated||T,y=a.onElUpdated||T,I=a.onBeforeNodeDiscarded||T,g=a.onNodeDiscarded||T,m=a.onBeforeElChildrenUpdated||T,E=a.skipFromChildren||T,x=a.addChild||function(o,c){return o.appendChild(c)},q=a.childrenOnly===!0,C=Object.create(null),U=[];function _(o){U.push(o)}function X(o,c){if(o.nodeType===R)for(var h=o.firstChild;h;){var l=void 0;c&&(l=s(h))?_(l):(g(h),h.firstChild&&X(h,c)),h=h.nextSibling}}function K(o,c,h){I(o)!==!1&&(c&&c.removeChild(o),g(o),X(o,h))}function G(o){if(o.nodeType===R||o.nodeType===ne)for(var c=o.firstChild;c;){var h=s(c);h&&(C[h]=c),G(c),c=c.nextSibling}}G(t);function M(o){f(o);for(var c=o.firstChild;c;){var h=c.nextSibling,l=s(c);if(l){var d=C[l];d&&$(c,d)?(c.parentNode.replaceChild(d,c),H(d,c)):M(c)}else M(c);c=h}}function re(o,c,h){for(;c;){var l=c.nextSibling;(h=s(c))?_(h):K(c,o,!0),c=l}}function H(o,c,h){var l=s(c);if(l&&delete C[l],!h){var d=b(o,c);if(d===!1||(d instanceof HTMLElement&&(o=d,G(o)),i(o,c),y(o),m(o,c)===!1))return}o.nodeName!=="TEXTAREA"?se(o,c):te.TEXTAREA(o,c)}function se(o,c){var h=E(o,c),l=c.firstChild,d=o.firstChild,N,w,O,B,S;e:for(;l;){for(B=l.nextSibling,N=s(l);!h&&d;){if(O=d.nextSibling,l.isSameNode&&l.isSameNode(d)){l=B,d=O;continue e}w=s(d);var V=d.nodeType,A=void 0;if(V===l.nodeType&&(V===R?(N?N!==w&&((S=C[N])?O===S?A=!1:(o.insertBefore(S,d),w?_(w):K(d,o,!0),d=S,w=s(d)):A=!1):w&&(A=!1),A=A!==!1&&$(d,l),A&&H(d,l)):(V===ae||V==ie)&&(A=!0,d.nodeValue!==l.nodeValue&&(d.nodeValue=l.nodeValue))),A){l=B,d=O;continue e}w?_(w):K(d,o,!0),d=O}if(N&&(S=C[N])&&$(S,l))h||x(o,S),H(S,l);else{var W=u(l);W!==!1&&(W&&(l=W),l.actualize&&(l=l.actualize(o.ownerDocument||v)),x(o,l),M(l))}l=B,d=O}re(o,d,w);var Z=te[o.nodeName];Z&&Z(o,c)}var p=t,F=p.nodeType,Q=n.nodeType;if(!q){if(F===R)Q===R?$(t,n)||(g(t),p=me(t,ye(n.nodeName,n.namespaceURI))):p=n;else if(F===ae||F===ie){if(Q===F)return p.nodeValue!==n.nodeValue&&(p.nodeValue=n.nodeValue),p;p=n}}if(p===n)g(t);else{if(n.isSameNode&&n.isSameNode(p))return;if(H(p,n,q),U)for(var Y=0,oe=U.length;Y<oe;Y++){var J=C[U[Y]];J&&K(J,J.parentNode,!1)}}return!q&&p!==t&&t.parentNode&&(p.actualize&&(p=p.actualize(t.ownerDocument||v)),t.parentNode.replaceChild(p,t)),p}}var Se=be(le);class P extends ce{static instance=null;cryptoKey=null;activeAbortController=null;navigationEnabled=!1;boundHandleLinkClick=null;boundHandlePopState=null;isNavigating=!1;constructor(){super(),this.hydrated().then(()=>{this.isNavigating||(document.body.hidden=!1),this.enableSPANavigation()}).catch(e=>{console.error("PPHPUtilities hydration error:",e),document.body.hidden=!1})}static resetInstance(){this.instance&&(this.instance.navigationEnabled&&this.instance.disableSPANavigation(),this.instance.activeAbortController&&(this.instance.activeAbortController.abort(),this.instance.activeAbortController=null),this.instance.destroy(),this.instance=null)}static getInstance(){return this.instance||(this.instance=new P),this.instance}enableSPANavigation(){this.navigationEnabled||(this.navigationEnabled=!0,this.boundHandleLinkClick=this.handleLinkClick.bind(this),this.boundHandlePopState=this.handlePopState.bind(this),document.addEventListener("click",this.boundHandleLinkClick),window.addEventListener("popstate",this.boundHandlePopState))}disableSPANavigation(){this.navigationEnabled=!1,this.boundHandleLinkClick&&(document.removeEventListener("click",this.boundHandleLinkClick),this.boundHandleLinkClick=null),this.boundHandlePopState&&(window.removeEventListener("popstate",this.boundHandlePopState),this.boundHandlePopState=null)}handleLinkClick(e){if(!this.navigationEnabled)return;const n=e.target.closest("a");if(!(!n||!n.href))try{const a=new URL(n.href),r=a.origin!==window.location.origin,s=a.pathname===window.location.pathname&&a.search===window.location.search;if(r||n.target==="_blank"||n.hasAttribute("download")||n.getAttribute("pp-no-spa")==="true"||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;if(e.preventDefault(),s){const u=a.hash;if(u){const f=document.querySelector(u);f&&f.scrollIntoView({behavior:"smooth"})}else window.scrollTo({top:0,behavior:"smooth"});return}this.navigateTo(a.pathname+a.search+a.hash)}catch(a){console.error("Link click navigation error:",a)}}async handlePopState(){const e=window.location.pathname+window.location.search+window.location.hash;await this.navigateTo(e,!1)}async navigateTo(e,t=!0){this.isNavigating=!0;try{this.dispatchNavigationEvent("start",e),await this.showLoadingTransition();const n=await this.fetchPageContent(e);this.performCleanup(),this.updateBrowserHistory(e,t);const a=document.getElementById("loading-file-1B87E"),r="startViewTransition"in document;!a&&r?await this.updatePageContentWithViewTransition(n):this.updatePageContent(n),await this.reinitializeApp(),await this.handleNavigationCompletion(e),this.dispatchNavigationEvent("complete",e)}catch(n){this.handleNavigationError(e,n)}finally{this.isNavigating=!1}}async updatePageContentWithViewTransition(e){if(this.isNavigating){this.updatePageContent(e);return}const t=document.startViewTransition(()=>{this.updatePageContent(e)});try{await t.finished}catch(n){console.warn("View transition failed, continuing anyway:",n)}}dispatchNavigationEvent(e,t,n){const a=`pp:navigation:${e}`,r=n?{url:t,error:n}:{url:t};document.dispatchEvent(new CustomEvent(a,{detail:r}))}async showLoadingTransition(){const e=document.getElementById("loading-file-1B87E");if(e){const n=this.findLoadingElement(e,window.location.pathname);if(n){await this.updateContentWithTransition(n);return}}const t=document.querySelector("[pp-loading-content='true']")||document.body;t&&!("startViewTransition"in document)&&await this.fadeOut(t,250)}async fetchPageContent(e){const t=await fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest",Accept:"text/html"}});if(!t.ok)throw new Error(`Navigation failed: ${t.status} ${t.statusText}`);const n=await t.text();return new DOMParser().parseFromString(n,"text/html")}performCleanup(){this.cleanup(),this.disableSPANavigation()}updateBrowserHistory(e,t){t&&history.pushState(null,"",e)}updatePageContent(e){e.title&&(document.title=e.title),this.reconcileHead(e);const t=e.body;Se(document.body,t,{childrenOnly:!0,onBeforeElUpdated:(n,a)=>!n.isEqualNode(a)})}async reinitializeApp(){window.pp=null,P.instance=null;const e=window.pp;return await e.hydrated(),e}async handleNavigationCompletion(e){const t=new URL(e,window.location.origin).hash;if(t){const a=document.querySelector(t);a&&a.scrollIntoView({behavior:"smooth"})}else window.scrollTo({top:0,behavior:"instant"});const n=document.querySelector("[pp-loading-content='true']")||document.body;n?requestAnimationFrame(()=>{document.body.hidden=!1,this.fadeIn(n,150)}):document.body.hidden=!1}handleNavigationError(e,t){console.error("Navigation error:",t),document.body.hidden=!1,this.dispatchNavigationEvent("error",e,t),window.location.href=e}findLoadingElement(e,t){let n=t;for(;;){const a=e.querySelector(`div[pp-loading-url='${n}']`);if(a)return a;if(n==="/")break;const r=n.lastIndexOf("/");r<=0?n="/":n=n.substring(0,r)}return e.querySelector("div[pp-loading-url='/' ]")}async updateContentWithTransition(e){const t=document.querySelector("[pp-loading-content='true']")||document.body;if(!t)return;const{fadeIn:n,fadeOut:a}=this.parseTransition(e);await this.fadeOut(t,a),t.innerHTML=e.innerHTML,this.fadeIn(t,n)}parseTransition(e){let t=250,n=250;const r=e.querySelector("[pp-loading-transition]")?.getAttribute("pp-loading-transition");if(r){let s=JSON.parse(r);s&&typeof s=="object"?(t=this.parseTime(s.fadeIn??t),n=this.parseTime(s.fadeOut??n)):console.warn("pp-loading-transition is not valid JSON → default values (250 ms) will be used. String:",r)}return{fadeIn:t,fadeOut:n}}fadeOut(e,t){return new Promise(n=>{e.style.transition=`opacity ${t}ms ease-out`,setTimeout(()=>{e.style.transition="",n()},t)})}fadeIn(e,t){e.style.transition=`opacity ${t}ms ease-in`,setTimeout(()=>{e.style.transition=""},t)}parseTime(e){if(typeof e=="number")return e;const t=e.match(/^(\d+)(ms|s|m)?$/);if(t){const n=parseInt(t[1],10);switch(t[2]||"ms"){case"ms":return n;case"s":return n*1e3;case"m":return n*60*1e3;default:return n}}return 0}reconcileHead(e){const t="pp-dynamic-script",n="pp-dynamic-meta",a="pp-dynamic-link";document.head.querySelectorAll(`[${n}]`).forEach(r=>r.remove()),document.head.querySelectorAll(`[${a}]`).forEach(r=>r.remove()),document.head.querySelectorAll(`[${t}]`).forEach(r=>r.remove()),Array.from(e.head.children).forEach(r=>{switch(r.tagName){case"SCRIPT":if(r.hasAttribute(t)){const s=document.createElement("script");Array.from(r.attributes).forEach(u=>s.setAttribute(u.name,u.value)),s.textContent=r.textContent,document.head.appendChild(s)}break;case"META":{const s=r;if(s.getAttribute("charset")||s.name==="viewport")break;const u=s.name?`meta[name="${s.name}"]`:`meta[property="${s.getAttribute("property")}"]`,f=s.cloneNode(!0),b=document.head.querySelector(u);b?document.head.replaceChild(f,b):document.head.insertBefore(f,document.head.querySelector("title")?.nextSibling||null);break}case"TITLE":{const s=r.cloneNode(!0),u=document.head.querySelector("title");u?document.head.replaceChild(s,u):document.head.appendChild(s);break}case"LINK":{const s=r;if(s.rel==="icon"){const u=s.cloneNode(!0),f=document.head.querySelector('link[rel="icon"]');f?document.head.replaceChild(u,f):document.head.appendChild(u)}else s.hasAttribute(a)&&document.head.appendChild(s.cloneNode(!0));break}}})}async redirect(e){if(e)try{const t=new URL(e,window.location.origin);t.origin!==window.location.origin?window.location.href=e:this.navigationEnabled?await this.navigateTo(t.pathname+t.search+t.hash):window.location.href=e}catch(t){console.error("Redirect error:",t)}}async initCryptoKey(){const e=document.cookie.split("; ").find(u=>u.startsWith("pp_function_call_jwt="))?.split("=",2)[1];if(!e)throw new Error("Missing function-call token");const[,t]=e.split("."),n=atob(t.replace(/-/g,"+").replace(/_/g,"/")),{k:a,exp:r}=JSON.parse(n);if(Date.now()/1e3>r)throw new Error("Function-call token expired");const s=Uint8Array.from(atob(a),u=>u.charCodeAt(0));this.cryptoKey=await crypto.subtle.importKey("raw",s,{name:"AES-CBC"},!1,["encrypt","decrypt"])}async encryptCallbackName(e){await this.initCryptoKey();const t=crypto.getRandomValues(new Uint8Array(16)),n=new TextEncoder().encode(e),a=await crypto.subtle.encrypt({name:"AES-CBC",iv:t},this.cryptoKey,n),r=btoa(String.fromCharCode(...t)),s=btoa(String.fromCharCode(...new Uint8Array(a)));return`${r}:${s}`}createFetchOptions(e){return{method:"POST",headers:{"Content-Type":"application/json",HTTP_PP_WIRE_REQUEST:"true"},body:JSON.stringify(e)}}async fetchFunction(e,t={},n=!1){let a=null;try{n&&this.activeAbortController&&(this.activeAbortController.abort(),this.activeAbortController=null),a=new AbortController,n&&(this.activeAbortController=a);const s={callback:await this.encryptCallbackName(e),...t},u=window.location.href;let f;if(Object.keys(s).some(g=>{const m=s[g];return m instanceof File||m instanceof FileList&&m.length>0})){const g=new FormData;Object.keys(s).forEach(m=>{const E=s[m];E instanceof File?g.append(m,E):E instanceof FileList?Array.from(E).forEach(x=>g.append(m,x)):g.append(m,E)}),f={method:"POST",headers:{HTTP_PP_WIRE_REQUEST:"true"},body:g,signal:a.signal}}else f={signal:a.signal,...this.createFetchOptions(s)};const y=await fetch(u,f);if(!y.ok)throw new Error(`Fetch failed with status: ${y.status} ${y.statusText}`);const I=await y.text();a&&this.activeAbortController===a&&(this.activeAbortController=null);try{return JSON.parse(I)}catch{return I}}catch(r){if(a&&this.activeAbortController===a&&(this.activeAbortController=null),r instanceof Error&&r.name==="AbortError")return console.log("Request was cancelled"),{cancelled:!0};throw console.error("Error in fetchFunction:",r),new Error("Failed to fetch data.")}}}class k{state;static instance=null;listeners;pp;STORAGE_KEY;lastSyncedState=null;constructor(e={}){this.state=e,this.listeners=[],this.pp=P.getInstance(),this.STORAGE_KEY=this.getCookie("pp_local_store_key")||"pp_local_store_59e13",this.lastSyncedState=localStorage.getItem(this.STORAGE_KEY),this.loadState()}static getInstance(e={}){return k.instance||(k.instance=new k(e)),k.instance}getCookie(e){return document.cookie.split("; ").find(t=>t.startsWith(e+"="))?.split("=")[1]||null}setState(e,t=!1){const n={...this.state,...e};if(JSON.stringify(n)!==JSON.stringify(this.state)&&(this.state=n,this.listeners.forEach(a=>a(this.state)),this.saveState(),t)){const a=localStorage.getItem(this.STORAGE_KEY);a&&a!==this.lastSyncedState&&(this.pp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:a}),this.lastSyncedState=a)}}saveState(){localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.state))}loadState(){const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.state=JSON.parse(e),this.listeners.forEach(t=>t(this.state)))}resetState(e,t=!1){if(e?(delete this.state[e],this.saveState()):(this.state={},localStorage.removeItem(this.STORAGE_KEY)),this.listeners.forEach(n=>n(this.state)),t){const n=e?localStorage.getItem(this.STORAGE_KEY):null;this.pp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:n}),this.lastSyncedState=n}}}class L{static instance=null;listeners=[];constructor(){}static getInstance(){return L.instance||(L.instance=new L),L.instance}get params(){return new URLSearchParams(window.location.search)}get(e){return this.params.get(e)}set(e,t){const n=this.params;n.set(e,t),this.updateURL(n)}delete(e){const t=this.params;t.delete(e),this.updateURL(t)}replace(e){const t=new URLSearchParams;for(const n in e){const a=e[n];a!==null&&t.set(n,a)}this.updateURL(t,!0)}updateURL(e,t=!1){const n=`${window.location.pathname}?${e.toString()}`;t?history.replaceState(null,"",n):history.pushState(null,"",n),this.notifyListeners(e)}listen(e){this.listeners.push(e)}notifyListeners(e){for(const t of this.listeners)t(e)}enablePopStateListener(){window.addEventListener("popstate",()=>{this.notifyListeners(this.params)})}}function z(i,e,t=window,n=!0){let a=null;if(Object.defineProperty(t,i,{get(){if(a!==null)return a;if(e&&typeof e=="object"&&!Array.isArray(e)&&"getInstance"in e&&typeof e.getInstance=="function")return a=e.getInstance(),a;if(typeof e=="function")try{return a=e.getInstance(),a}catch{return a=e,a}else return a=e,a},set(r){r===null?a=null:console.warn(`Cannot override global ${i}`)},configurable:!0,enumerable:!0}),n)try{t[i]}catch(r){console.error(`Failed to initialize ${i}:`,r)}}z("pp",P);z("store",k);z("searchParams",L);
File without changes