create-prisma-php-app 1.13.501 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bootstrap.php
CHANGED
|
@@ -405,11 +405,10 @@ function modifyOutputLayoutForError($contentToAdd)
|
|
|
405
405
|
|
|
406
406
|
function wireCallback($content)
|
|
407
407
|
{
|
|
408
|
-
$
|
|
409
|
-
|
|
410
|
-
|
|
408
|
+
global $isWire;
|
|
409
|
+
|
|
410
|
+
if ($isWire) {
|
|
411
411
|
|
|
412
|
-
if ($wireRequest === 'true') {
|
|
413
412
|
// Read input data
|
|
414
413
|
$input = file_get_contents('php://input');
|
|
415
414
|
$data = json_decode($input, true);
|
|
@@ -444,14 +443,7 @@ function wireCallback($content)
|
|
|
444
443
|
}
|
|
445
444
|
}
|
|
446
445
|
|
|
447
|
-
if (!empty($response['response']))
|
|
448
|
-
if ($wireJsonRequest === 'true') {
|
|
449
|
-
header('Content-Type: application/json');
|
|
450
|
-
echo json_encode($response);
|
|
451
|
-
exit;
|
|
452
|
-
}
|
|
453
|
-
echo json_encode($response);
|
|
454
|
-
}
|
|
446
|
+
if (!empty($response['response'])) echo json_encode($response);
|
|
455
447
|
|
|
456
448
|
echo $content;
|
|
457
449
|
exit;
|
|
@@ -23,6 +23,7 @@ $isPatch = $requestMethod === 'PATCH';
|
|
|
23
23
|
$isHead = $requestMethod === 'HEAD';
|
|
24
24
|
$isOptions = $requestMethod === 'OPTIONS';
|
|
25
25
|
$isAjax = isAjaxRequest();
|
|
26
|
+
$isWire = isWireRequest();
|
|
26
27
|
$contentType = $_SERVER['CONTENT_TYPE'] ?? '';
|
|
27
28
|
$requestedWith = $_SERVER['HTTP_X_REQUESTED_WITH'] ?? '';
|
|
28
29
|
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
|
|
@@ -19,13 +19,13 @@ class StateManager
|
|
|
19
19
|
*/
|
|
20
20
|
public function __construct($initialState = [], $keepState = null)
|
|
21
21
|
{
|
|
22
|
-
global $
|
|
22
|
+
global $isWire;
|
|
23
23
|
|
|
24
24
|
$this->state = $initialState;
|
|
25
25
|
$this->listeners = [];
|
|
26
26
|
$this->loadState();
|
|
27
27
|
|
|
28
|
-
if (!$
|
|
28
|
+
if (!$isWire) $this->resetState($keepState);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -51,10 +51,11 @@ class StateManager
|
|
|
51
51
|
/**
|
|
52
52
|
* Updates the application state with the given update.
|
|
53
53
|
*
|
|
54
|
-
* @param array $
|
|
54
|
+
* @param string|array $key The key of the state value to update, or an array of key-value pairs to update multiple values.
|
|
55
55
|
*/
|
|
56
|
-
public function setState($
|
|
56
|
+
public function setState($key, $value = null)
|
|
57
57
|
{
|
|
58
|
+
$update = is_array($key) ? $key : [$key => $value];
|
|
58
59
|
$this->state = array_merge($this->state, $update);
|
|
59
60
|
foreach ($this->listeners as $listener) {
|
|
60
61
|
call_user_func($listener, $this->state);
|
package/dist/src/app/js/index.js
CHANGED
|
@@ -339,4 +339,4 @@ if (
|
|
|
339
339
|
});
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
-
"use strict";var eventAttributes=["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmousemove","onmouseout","onwheel","onkeypress","onkeydown","onkeyup","onfocus","onblur","onchange","oninput","onselect","onsubmit","onreset","onresize","onscroll","onload","onunload","onabort","onerror","onbeforeunload","oncopy","oncut","onpaste","ondrag","ondragstart","ondragend","ondragover","ondragenter","ondragleave","ondrop","oncontextmenu","ontouchstart","ontouchmove","ontouchend","ontouchcancel","onpointerdown","onpointerup","onpointermove","onpointerover","onpointerout","onpointerenter","onpointerleave","onpointercancel"];function attachWireFunctionEvents(){document.querySelectorAll("button, input, select, textarea, a, form, label, div, span").forEach((t=>{t instanceof HTMLAnchorElement&&t.addEventListener("click",handleAnchorTag),eventAttributes.forEach((e=>{const n=t.getAttribute(e),o=e.slice(2);n&&(t.removeAttribute(e),t.addEventListener(o,(e=>{e.preventDefault();const{funcName:o,data:r}=parseCallback(t,n);if(o){const t=window[o];if("function"==typeof t)try{t(...r)}catch(t){}else handleUndefinedFunction(o,r)}})))}))}))}async function handleAnchorTag(t){const e=t.currentTarget,n=e.getAttribute("href"),o=e.getAttribute("target");if(!n||"_blank"===o||t.metaKey||t.ctrlKey)return;t.preventDefault();if(/^(https?:)?\/\//i.test(n)&&!n.startsWith(window.location.origin))window.location.href=n;else try{history.pushState(null,"",n),window.dispatchEvent(new PopStateEvent("popstate",{state:null}))}catch(t){}}function updateDocumentContent(t){t.includes("<!DOCTYPE html>")?document.documentElement.innerHTML=t:document.body.innerHTML=t,attachWireFunctionEvents()}function parseCallback(t,e){let n={};if(t instanceof HTMLFormElement){const e=new FormData(t);n=Object.fromEntries(e.entries())}else t instanceof HTMLInputElement&&(t.name?"checkbox"===t.type||"radio"===t.type?n[t.name]=t.checked:n[t.name]=t.value:"checkbox"===t.type||"radio"===t.type?n.value=t.checked:n.value=t.value);const o=e.match(/(\w+)\(([^)]*)\)/);if(o){const t=o[1];let e=[];return o[2]&&(e=o[2].split(/,(?=(?:[^'"]*['"][^'"]*['"])*[^'"]*$)/).map((t=>t.trim())),e=e.map((t=>{try{const e=t.replace(/'/g,'"');return JSON.parse(e)}catch{return t}}))),e.forEach((t=>{n="object"==typeof t&&null!==t?{...n,...t}:{...n,args:e}})),{funcName:t,data:n}}return{funcName:e,data:n}}function handleUndefinedFunction(t,e){const n={callback:t,...e},o={method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest",HTTP_PPHP_WIRE_REQUEST:"true"},body:JSON.stringify(n)},r={method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest",HTTP_PPHP_WIRE_REQUEST:"true"}},c=async t=>{const e=await fetch(window.location.pathname,t);return await e.text()};let a="";c(o).then((t=>(""===a&&(a=t),c(r)))).then((t=>{updateDocumentContent(mergeAndReplaceDuplicates(a,t))})).catch((t=>{}))}function mergeAndReplaceDuplicates(t,e){const{html:n,scripts:o}=extractScripts(t),{html:r,scripts:c}=extractScripts(e),a=new DOMParser
|
|
342
|
+
"use strict";var eventAttributes=["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmousemove","onmouseout","onwheel","onkeypress","onkeydown","onkeyup","onfocus","onblur","onchange","oninput","onselect","onsubmit","onreset","onresize","onscroll","onload","onunload","onabort","onerror","onbeforeunload","oncopy","oncut","onpaste","ondrag","ondragstart","ondragend","ondragover","ondragenter","ondragleave","ondrop","oncontextmenu","ontouchstart","ontouchmove","ontouchend","ontouchcancel","onpointerdown","onpointerup","onpointermove","onpointerover","onpointerout","onpointerenter","onpointerleave","onpointercancel"];function attachWireFunctionEvents(){document.querySelectorAll("button, input, select, textarea, a, form, label, div, span").forEach((t=>{t instanceof HTMLAnchorElement&&t.addEventListener("click",handleAnchorTag),eventAttributes.forEach((e=>{const n=t.getAttribute(e),o=e.slice(2);n&&(t.removeAttribute(e),t.addEventListener(o,(e=>{e.preventDefault();const{funcName:o,data:r}=parseCallback(t,n);if(o){const t=window[o];if("function"==typeof t)try{t(...r)}catch(t){}else handleUndefinedFunction(o,r)}})))}))}))}async function handleAnchorTag(t){const e=t.currentTarget,n=e.getAttribute("href"),o=e.getAttribute("target");if(!n||"_blank"===o||t.metaKey||t.ctrlKey)return;t.preventDefault();if(/^(https?:)?\/\//i.test(n)&&!n.startsWith(window.location.origin))window.location.href=n;else try{history.pushState(null,"",n),window.dispatchEvent(new PopStateEvent("popstate",{state:null}))}catch(t){}}function updateDocumentContent(t){t.includes("<!DOCTYPE html>")?document.documentElement.innerHTML=t:document.body.innerHTML=t,attachWireFunctionEvents()}function parseCallback(t,e){let n={};if(t instanceof HTMLFormElement){const e=new FormData(t);n=Object.fromEntries(e.entries())}else t instanceof HTMLInputElement&&(t.name?"checkbox"===t.type||"radio"===t.type?n[t.name]=t.checked:n[t.name]=t.value:"checkbox"===t.type||"radio"===t.type?n.value=t.checked:n.value=t.value);const o=e.match(/(\w+)\(([^)]*)\)/);if(o){const t=o[1];let e=[];return o[2]&&(e=o[2].split(/,(?=(?:[^'"]*['"][^'"]*['"])*[^'"]*$)/).map((t=>t.trim())),e=e.map((t=>{try{const e=t.replace(/'/g,'"');return JSON.parse(e)}catch{return t}}))),e.forEach((t=>{n="object"==typeof t&&null!==t?{...n,...t}:{...n,args:e}})),{funcName:t,data:n}}return{funcName:e,data:n}}function handleUndefinedFunction(t,e){const n={callback:t,...e},o={method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest",HTTP_PPHP_WIRE_REQUEST:"true"},body:JSON.stringify(n)},r={method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest",HTTP_PPHP_WIRE_REQUEST:"true"}},c=async t=>{const e=await fetch(window.location.pathname,t);return await e.text()};let a="";c(o).then((t=>(""===a&&(a=t),c(r)))).then((t=>{updateDocumentContent(mergeAndReplaceDuplicates(a,t))})).catch((t=>{}))}function mergeAndReplaceDuplicates(t,e){const{html:n,scripts:o}=extractScripts(t),{html:r,scripts:c}=extractScripts(e),a=(new DOMParser).parseFromString(r,"text/html"),i=document.createElement("div");i.innerHTML=n,mergeElements(i,a.body);const s=i.innerHTML;return mergeScripts(o,c)+s}function mergeElements(t,e){for(const n of e.attributes)t.setAttribute(n.name,n.value);e.textContent&&!e.children.length&&(t.textContent=e.textContent);const n=Array.from(t.children),o=Array.from(e.children);for(let e=0;e<o.length;e++)n[e]?mergeElements(n[e],o[e]):t.appendChild(o[e].cloneNode(!0));for(;n.length>o.length;)t.removeChild(n.pop())}function extractScripts(t){let e="",n=t;return n=n.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,(t=>(e+=t,""))),{html:n,scripts:e}}function mergeScripts(t,e){const n=new Set([...t.match(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi)||[],...e.match(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi)||[]]);return Array.from(n).join("\n")}document.addEventListener("DOMContentLoaded",(()=>{attachWireFunctionEvents()})),window.addEventListener("popstate",(async()=>{try{const t=await fetch(window.location.href,{headers:{"X-Requested-With":"XMLHttpRequest"}});updateDocumentContent(await t.text())}catch(t){}}));
|