create-prisma-php-app 4.1.0-alpha.2 → 4.1.0-alpha.4
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as w}from"./reactive-v1.js";class f extends w{cryptoKey=null;activeAbortController=null;static instance=null;constructor(){super(),this.hydrated().then(()=>{document.body.hidden=!1}).catch(t=>{console.error("PPHPUtilities hydration error:",t),document.body.hidden=!1})}static getInstance(){return this.instance||(this.instance=new f),this.instance}async redirect(t){if(t)try{new URL(t,window.location.origin).origin!==window.location.origin?window.location.href=t:history.pushState(null,"",t)}catch(r){console.error("Redirect error:",r)}}async initCryptoKey(){const t=document.cookie.split("; ").find(s=>s.startsWith("pp_function_call_jwt="))?.split("=",2)[1];if(!t)throw new Error("Missing function-call token");const[,r]=t.split("."),a=atob(r.replace(/-/g,"+").replace(/_/g,"/")),{k:e,exp:o}=JSON.parse(a);if(Date.now()/1e3>o)throw new Error("Function-call token expired");const n=Uint8Array.from(atob(e),s=>s.charCodeAt(0));this.cryptoKey=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt","decrypt"])}async encryptCallbackName(t){await this.initCryptoKey();const r=crypto.getRandomValues(new Uint8Array(16)),a=new TextEncoder().encode(t),e=await crypto.subtle.encrypt({name:"AES-CBC",iv:r},this.cryptoKey,a),o=btoa(String.fromCharCode(...r)),n=btoa(String.fromCharCode(...new Uint8Array(e)));return`${o}:${n}`}createFetchOptions(t){return{method:"POST",headers:{"Content-Type":"application/json",HTTP_PP_WIRE_REQUEST:"true"},body:JSON.stringify(t)}}async fetchFunction(t,r={},a=!1){let e=null;try{a&&this.activeAbortController&&(this.activeAbortController.abort(),this.activeAbortController=null),e=new AbortController,a&&(this.activeAbortController=e);const n={callback:await this.encryptCallbackName(t),...r},s=window.location.href;let d;if(Object.keys(n).some(c=>{const i=n[c];return i instanceof File||i instanceof FileList&&i.length>0})){const c=new FormData;Object.keys(n).forEach(i=>{const l=n[i];l instanceof File?c.append(i,l):l instanceof FileList?Array.from(l).forEach(u=>c.append(i,u)):c.append(i,l)}),d={method:"POST",headers:{HTTP_PP_WIRE_REQUEST:"true"},body:c,signal:e.signal}}else d={signal:e.signal,...this.createFetchOptions(n)};const h=await fetch(s,d);if(!h.ok)throw new Error(`Fetch failed with status: ${h.status} ${h.statusText}`);const y=await h.text();e&&this.activeAbortController===e&&(this.activeAbortController=null);try{return JSON.parse(y)}catch{return y}}catch(o){if(e&&this.activeAbortController===e&&(this.activeAbortController=null),o instanceof Error&&o.name==="AbortError")return console.log("Request was cancelled"),{cancelled:!0};throw console.error("Error in fetchFunction:",o),new Error("Failed to fetch data.")}}}Object.defineProperty(window,"pp",{get:()=>f.getInstance(),set(p){console.warn("[pp] Attempted to override global pp; ignoring.",p)},configurable:!1,enumerable:!0});try{window.pp}catch(p){console.error("PPHPUtilities singleton initialization failed:",p)}
|
|
1
|
+
import{P as w}from"./pp-reactive-v1.js";class f extends w{cryptoKey=null;activeAbortController=null;static instance=null;constructor(){super(),this.hydrated().then(()=>{document.body.hidden=!1}).catch(t=>{console.error("PPHPUtilities hydration error:",t),document.body.hidden=!1})}static getInstance(){return this.instance||(this.instance=new f),this.instance}async redirect(t){if(t)try{new URL(t,window.location.origin).origin!==window.location.origin?window.location.href=t:history.pushState(null,"",t)}catch(r){console.error("Redirect error:",r)}}async initCryptoKey(){const t=document.cookie.split("; ").find(s=>s.startsWith("pp_function_call_jwt="))?.split("=",2)[1];if(!t)throw new Error("Missing function-call token");const[,r]=t.split("."),a=atob(r.replace(/-/g,"+").replace(/_/g,"/")),{k:e,exp:o}=JSON.parse(a);if(Date.now()/1e3>o)throw new Error("Function-call token expired");const n=Uint8Array.from(atob(e),s=>s.charCodeAt(0));this.cryptoKey=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt","decrypt"])}async encryptCallbackName(t){await this.initCryptoKey();const r=crypto.getRandomValues(new Uint8Array(16)),a=new TextEncoder().encode(t),e=await crypto.subtle.encrypt({name:"AES-CBC",iv:r},this.cryptoKey,a),o=btoa(String.fromCharCode(...r)),n=btoa(String.fromCharCode(...new Uint8Array(e)));return`${o}:${n}`}createFetchOptions(t){return{method:"POST",headers:{"Content-Type":"application/json",HTTP_PP_WIRE_REQUEST:"true"},body:JSON.stringify(t)}}async fetchFunction(t,r={},a=!1){let e=null;try{a&&this.activeAbortController&&(this.activeAbortController.abort(),this.activeAbortController=null),e=new AbortController,a&&(this.activeAbortController=e);const n={callback:await this.encryptCallbackName(t),...r},s=window.location.href;let d;if(Object.keys(n).some(c=>{const i=n[c];return i instanceof File||i instanceof FileList&&i.length>0})){const c=new FormData;Object.keys(n).forEach(i=>{const l=n[i];l instanceof File?c.append(i,l):l instanceof FileList?Array.from(l).forEach(u=>c.append(i,u)):c.append(i,l)}),d={method:"POST",headers:{HTTP_PP_WIRE_REQUEST:"true"},body:c,signal:e.signal}}else d={signal:e.signal,...this.createFetchOptions(n)};const h=await fetch(s,d);if(!h.ok)throw new Error(`Fetch failed with status: ${h.status} ${h.statusText}`);const y=await h.text();e&&this.activeAbortController===e&&(this.activeAbortController=null);try{return JSON.parse(y)}catch{return y}}catch(o){if(e&&this.activeAbortController===e&&(this.activeAbortController=null),o instanceof Error&&o.name==="AbortError")return console.log("Request was cancelled"),{cancelled:!0};throw console.error("Error in fetchFunction:",o),new Error("Failed to fetch data.")}}}Object.defineProperty(window,"pp",{get:()=>f.getInstance(),set(p){console.warn("[pp] Attempted to override global pp; ignoring.",p)},configurable:!1,enumerable:!0});try{window.pp}catch(p){console.error("PPHPUtilities singleton initialization failed:",p)}
|
package/dist/ts/main.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import "../public/js/reactive-v1.js";
|
|
1
|
+
import "../public/js/pp-reactive-v1.js";
|
|
2
2
|
import "../public/js/pp-utilities.js";
|