create-prisma-php-app 1.26.534 → 1.26.536
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/composer.json +1 -1
- package/dist/index.js +1 -0
- package/dist/settings/bs-config.ts +12 -9
- package/dist/settings/class-imports.ts +165 -0
- package/dist/settings/class-log.ts +149 -0
- package/dist/settings/project-name.ts +6 -1
- package/dist/src/Lib/Auth/Auth.php +7 -7
- package/dist/src/Lib/PHPMailer/Mailer.php +1 -0
- package/dist/src/Lib/PHPX/TemplateCompiler.php +4 -11
- package/dist/src/Lib/Validator.php +11 -0
- package/dist/src/app/js/index.js +1 -1
- package/package.json +1 -1
- package/vendor/composer/autoload_psr4.php +1 -2
- package/vendor/composer/autoload_static.php +3 -22
- package/vendor/composer/platform_check.php +2 -2
package/composer.json
CHANGED
package/dist/index.js
CHANGED
|
@@ -6,6 +6,8 @@ import prismaPhpConfigJson from "../prisma-php.json";
|
|
|
6
6
|
import { generateFileListJson } from "./files-list.js";
|
|
7
7
|
import { join } from "path";
|
|
8
8
|
import { getFileMeta } from "./utils.js";
|
|
9
|
+
import { updateAllClassLogs } from "./class-log.js";
|
|
10
|
+
import { updateComponentImports } from "./class-imports";
|
|
9
11
|
|
|
10
12
|
const { __dirname } = getFileMeta();
|
|
11
13
|
|
|
@@ -19,17 +21,18 @@ const watcher = chokidar.watch("src/app/**/*", {
|
|
|
19
21
|
interval: 1000,
|
|
20
22
|
});
|
|
21
23
|
|
|
24
|
+
// On changes, generate file list and also update the class log
|
|
25
|
+
const handleFileChange = async () => {
|
|
26
|
+
generateFileListJson();
|
|
27
|
+
await updateAllClassLogs();
|
|
28
|
+
await updateComponentImports();
|
|
29
|
+
};
|
|
30
|
+
|
|
22
31
|
// Perform specific actions for file events
|
|
23
32
|
watcher
|
|
24
|
-
.on("add",
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.on("change", () => {
|
|
28
|
-
generateFileListJson();
|
|
29
|
-
})
|
|
30
|
-
.on("unlink", () => {
|
|
31
|
-
generateFileListJson();
|
|
32
|
-
});
|
|
33
|
+
.on("add", handleFileChange)
|
|
34
|
+
.on("change", handleFileChange)
|
|
35
|
+
.on("unlink", handleFileChange);
|
|
33
36
|
|
|
34
37
|
// BrowserSync initialization
|
|
35
38
|
bs.init(
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { promises as fs } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { Engine } from "php-parser";
|
|
4
|
+
import { getFileMeta } from "./utils";
|
|
5
|
+
|
|
6
|
+
const { __dirname } = getFileMeta();
|
|
7
|
+
|
|
8
|
+
const parser = new Engine({
|
|
9
|
+
parser: {
|
|
10
|
+
php7: true,
|
|
11
|
+
extractDoc: true,
|
|
12
|
+
},
|
|
13
|
+
ast: {
|
|
14
|
+
withPositions: true,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const PROJECT_ROOT = path.join(__dirname, "..");
|
|
19
|
+
const SRC_DIR = path.join(PROJECT_ROOT, "src");
|
|
20
|
+
const IMPORTS_FILE = path.join(PROJECT_ROOT, "settings/class-imports.json");
|
|
21
|
+
const CLASS_LOG_FILE = path.join(PROJECT_ROOT, "settings/class-log.json");
|
|
22
|
+
|
|
23
|
+
async function loadImportsData(): Promise<Record<string, string>> {
|
|
24
|
+
try {
|
|
25
|
+
const content = await fs.readFile(IMPORTS_FILE, "utf-8");
|
|
26
|
+
return JSON.parse(content);
|
|
27
|
+
} catch {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function saveImportsData(data: Record<string, string>) {
|
|
33
|
+
await fs.writeFile(IMPORTS_FILE, JSON.stringify(data, null, 2), "utf-8");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function loadClassLogData(): Promise<Record<string, any>> {
|
|
37
|
+
try {
|
|
38
|
+
const content = await fs.readFile(CLASS_LOG_FILE, "utf-8");
|
|
39
|
+
return JSON.parse(content);
|
|
40
|
+
} catch {
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function getAllPhpFiles(dir: string): Promise<string[]> {
|
|
46
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
47
|
+
const files: string[] = [];
|
|
48
|
+
for (const entry of entries) {
|
|
49
|
+
const fullPath = path.join(dir, entry.name);
|
|
50
|
+
if (entry.isDirectory()) {
|
|
51
|
+
files.push(...(await getAllPhpFiles(fullPath)));
|
|
52
|
+
} else if (entry.isFile() && fullPath.endsWith(".php")) {
|
|
53
|
+
files.push(fullPath);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return files;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function preprocessPhpCode(code: string): string {
|
|
60
|
+
return code.replace(/<<<['"]?[A-Z_]+['"]?[\s\S]*?[A-Z_]+\s*;/g, "'';");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function combineNamespaces(
|
|
64
|
+
baseNamespace: string,
|
|
65
|
+
subNamespace: string
|
|
66
|
+
): string {
|
|
67
|
+
return (
|
|
68
|
+
baseNamespace.replace(/\\$/, "") + "\\" + subNamespace.replace(/^\\/, "")
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function analyzeImportsInFile(
|
|
73
|
+
filePath: string
|
|
74
|
+
): Promise<Record<string, string>> {
|
|
75
|
+
let code = await fs.readFile(filePath, "utf-8");
|
|
76
|
+
|
|
77
|
+
// Preprocess the PHP code
|
|
78
|
+
code = preprocessPhpCode(code);
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
// Parse the PHP file to AST
|
|
82
|
+
const ast = parser.parseCode(code, filePath);
|
|
83
|
+
|
|
84
|
+
const imports: Record<string, string> = {};
|
|
85
|
+
|
|
86
|
+
function traverse(node: any, baseNamespace = "") {
|
|
87
|
+
if (!node || typeof node !== "object") return;
|
|
88
|
+
|
|
89
|
+
if (Array.isArray(node)) {
|
|
90
|
+
node.forEach((childNode) => traverse(childNode, baseNamespace));
|
|
91
|
+
} else {
|
|
92
|
+
// Handle grouped `use` statements
|
|
93
|
+
if (node.kind === "usegroup" && node.name) {
|
|
94
|
+
baseNamespace = node.name.name || node.name; // Set base namespace
|
|
95
|
+
for (const useItem of node.items || []) {
|
|
96
|
+
if (useItem.kind === "useitem" && useItem.name) {
|
|
97
|
+
const subNamespace = useItem.name.name || useItem.name; // Sub-namespace
|
|
98
|
+
const fqn = combineNamespaces(baseNamespace, subNamespace); // Fully Qualified Namespace
|
|
99
|
+
const alias = useItem.alias ? useItem.alias.name : subNamespace; // Alias or default to subNamespace
|
|
100
|
+
if (!imports[alias]) {
|
|
101
|
+
// Prevent overwriting
|
|
102
|
+
imports[alias] = fqn; // Map alias to FQN
|
|
103
|
+
// console.log(`🚀 Adding import: ${alias} -> ${fqn}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Handle non-grouped `use` statements
|
|
110
|
+
if (node.kind === "useitem" && node.name) {
|
|
111
|
+
const fqn = node.name.name || node.name; // Fully Qualified Namespace
|
|
112
|
+
const alias = node.alias
|
|
113
|
+
? node.alias.name
|
|
114
|
+
: path.basename(fqn.replace(/\\/g, "/"));
|
|
115
|
+
if (!imports[alias]) {
|
|
116
|
+
// Prevent overwriting
|
|
117
|
+
imports[alias] = fqn;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Traverse child nodes
|
|
122
|
+
for (const key in node) {
|
|
123
|
+
traverse(node[key], baseNamespace);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
traverse(ast);
|
|
129
|
+
return imports;
|
|
130
|
+
} catch (error) {
|
|
131
|
+
console.error(`Error parsing file: ${filePath}`, error);
|
|
132
|
+
return {};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export async function updateComponentImports() {
|
|
137
|
+
// Load existing imports (if any)
|
|
138
|
+
const allImports = await loadImportsData();
|
|
139
|
+
|
|
140
|
+
// Analyze all PHP files for use statements
|
|
141
|
+
const phpFiles = await getAllPhpFiles(SRC_DIR);
|
|
142
|
+
for (const file of phpFiles) {
|
|
143
|
+
const fileImports = await analyzeImportsInFile(file);
|
|
144
|
+
// Merge fileImports into allImports
|
|
145
|
+
Object.assign(allImports, fileImports);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Now filter using class-log.json
|
|
149
|
+
const classLog = await loadClassLogData();
|
|
150
|
+
|
|
151
|
+
const filteredImports: Record<string, string> = {};
|
|
152
|
+
for (const [alias, fqn] of Object.entries(allImports)) {
|
|
153
|
+
if (classLog[fqn]) {
|
|
154
|
+
// console.log(`Including: ${alias} -> ${fqn}`);
|
|
155
|
+
filteredImports[alias] = fqn;
|
|
156
|
+
} else {
|
|
157
|
+
// console.log(`Excluding: ${alias} -> ${fqn}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
await saveImportsData(filteredImports);
|
|
162
|
+
// console.log(
|
|
163
|
+
// "component_imports.json updated with IPHPX/PHPX components only."
|
|
164
|
+
// );
|
|
165
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { promises as fs } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { Engine } from "php-parser";
|
|
4
|
+
import { getFileMeta } from "./utils.js";
|
|
5
|
+
|
|
6
|
+
const { __dirname } = getFileMeta();
|
|
7
|
+
|
|
8
|
+
const SRC_DIR = path.join(__dirname, "..", "src");
|
|
9
|
+
const LOG_FILE = path.join(__dirname, "class-log.json");
|
|
10
|
+
const IPHPX_INTERFACE = "IPHPX";
|
|
11
|
+
const PHPX_BASE_CLASS = "PHPX";
|
|
12
|
+
|
|
13
|
+
const parser = new Engine({
|
|
14
|
+
parser: {
|
|
15
|
+
php7: true,
|
|
16
|
+
extractDoc: true,
|
|
17
|
+
},
|
|
18
|
+
ast: {
|
|
19
|
+
withPositions: true,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
async function loadLogData(): Promise<Record<string, any>> {
|
|
24
|
+
try {
|
|
25
|
+
const content = await fs.readFile(LOG_FILE, "utf-8");
|
|
26
|
+
return JSON.parse(content);
|
|
27
|
+
} catch {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function saveLogData(logData: Record<string, any>) {
|
|
33
|
+
await fs.writeFile(LOG_FILE, JSON.stringify(logData, null, 2));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function preprocessPhpCode(code: string): string {
|
|
37
|
+
// Match heredocs and nowdocs and replace them with placeholders
|
|
38
|
+
return code.replace(/<<<['"]?[A-Z_]+['"]?[\s\S]*?[A-Z_]+\s*;/g, "'';");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function analyzePhpFile(filePath: string) {
|
|
42
|
+
let code = await fs.readFile(filePath, "utf-8");
|
|
43
|
+
|
|
44
|
+
// Preprocess the PHP code
|
|
45
|
+
code = preprocessPhpCode(code);
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
// Parse the PHP file to AST
|
|
49
|
+
const ast = parser.parseCode(code, filePath);
|
|
50
|
+
|
|
51
|
+
const classesFound: {
|
|
52
|
+
name: string;
|
|
53
|
+
implementsIPHPX: boolean;
|
|
54
|
+
extendsPHPX: boolean;
|
|
55
|
+
}[] = [];
|
|
56
|
+
|
|
57
|
+
function traverse(node: any) {
|
|
58
|
+
if (Array.isArray(node)) {
|
|
59
|
+
node.forEach(traverse);
|
|
60
|
+
} else if (node && typeof node === "object") {
|
|
61
|
+
if (node.kind === "class" && node.name?.name) {
|
|
62
|
+
const className = node.name.name;
|
|
63
|
+
|
|
64
|
+
let implementsIPHPX = false;
|
|
65
|
+
let extendsPHPX = false;
|
|
66
|
+
|
|
67
|
+
if (node.implements && Array.isArray(node.implements)) {
|
|
68
|
+
implementsIPHPX = node.implements.some(
|
|
69
|
+
(iface: any) => iface.name === IPHPX_INTERFACE
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (node.extends && node.extends.name === PHPX_BASE_CLASS) {
|
|
74
|
+
extendsPHPX = true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
classesFound.push({ name: className, implementsIPHPX, extendsPHPX });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
for (const key in node) {
|
|
81
|
+
if (node[key]) {
|
|
82
|
+
traverse(node[key]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
traverse(ast);
|
|
89
|
+
|
|
90
|
+
return classesFound;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.error(`Error parsing file: ${filePath}`, error);
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function guessFullClassName(filePath: string, className: string) {
|
|
98
|
+
const srcDir = path.join(__dirname, "..", "src");
|
|
99
|
+
const relativeFromSrc = path.relative(srcDir, filePath);
|
|
100
|
+
const withoutExtension = relativeFromSrc.replace(/\.php$/, "");
|
|
101
|
+
const parts = withoutExtension.split(path.sep);
|
|
102
|
+
parts.pop();
|
|
103
|
+
const namespace = parts.join("\\");
|
|
104
|
+
|
|
105
|
+
return `${namespace}\\${className}`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function updateClassLogForFile(
|
|
109
|
+
filePath: string,
|
|
110
|
+
logData: Record<string, any>
|
|
111
|
+
) {
|
|
112
|
+
const classes = await analyzePhpFile(filePath);
|
|
113
|
+
for (const cls of classes) {
|
|
114
|
+
if (cls.implementsIPHPX || cls.extendsPHPX) {
|
|
115
|
+
const classFullName = await guessFullClassName(filePath, cls.name);
|
|
116
|
+
// Store only the class as a key and a null value
|
|
117
|
+
logData[classFullName] = {};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export async function updateAllClassLogs() {
|
|
123
|
+
const logData = await loadLogData();
|
|
124
|
+
|
|
125
|
+
// Get all PHP files in src
|
|
126
|
+
async function getAllPhpFiles(dir: string): Promise<string[]> {
|
|
127
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
128
|
+
const files: string[] = [];
|
|
129
|
+
for (const entry of entries) {
|
|
130
|
+
const fullPath = path.join(dir, entry.name);
|
|
131
|
+
if (entry.isDirectory()) {
|
|
132
|
+
files.push(...(await getAllPhpFiles(fullPath)));
|
|
133
|
+
} else if (entry.isFile() && fullPath.endsWith(".php")) {
|
|
134
|
+
files.push(fullPath);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return files;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const phpFiles = await getAllPhpFiles(SRC_DIR);
|
|
141
|
+
|
|
142
|
+
// Clear the log to rebuild it fresh each time (optional)
|
|
143
|
+
for (const file of phpFiles) {
|
|
144
|
+
await updateClassLogForFile(file, logData);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
await saveLogData(logData);
|
|
148
|
+
// console.log("class-log.json updated with all PHP files.");
|
|
149
|
+
}
|
|
@@ -3,6 +3,8 @@ import { join, basename, dirname, normalize, sep } from "path";
|
|
|
3
3
|
import prismaPhpConfigJson from "../prisma-php.json";
|
|
4
4
|
import { getFileMeta } from "./utils.js";
|
|
5
5
|
import { promises as fsPromises } from "fs";
|
|
6
|
+
import { updateAllClassLogs } from "./class-log";
|
|
7
|
+
import { updateComponentImports } from "./class-imports";
|
|
6
8
|
|
|
7
9
|
const { __dirname } = getFileMeta();
|
|
8
10
|
|
|
@@ -106,6 +108,9 @@ const deleteFilesIfExist = async (filePaths: string[]): Promise<void> => {
|
|
|
106
108
|
const filePaths = [
|
|
107
109
|
join(__dirname, "request-data.json"),
|
|
108
110
|
join(__dirname, "class-log.json"),
|
|
111
|
+
join(__dirname, "class-imports.json"),
|
|
109
112
|
];
|
|
110
113
|
|
|
111
|
-
deleteFilesIfExist(filePaths);
|
|
114
|
+
await deleteFilesIfExist(filePaths);
|
|
115
|
+
await updateAllClassLogs();
|
|
116
|
+
await updateComponentImports();
|
|
@@ -338,14 +338,14 @@ class Auth
|
|
|
338
338
|
*/
|
|
339
339
|
public function authProviders(...$providers)
|
|
340
340
|
{
|
|
341
|
-
$dynamicRouteParams = Request::$dynamicParams;
|
|
341
|
+
$dynamicRouteParams = Request::$dynamicParams[self::PPHPAUTH] ?? [];
|
|
342
342
|
|
|
343
|
-
if (Request::$isGet && in_array('signin', $dynamicRouteParams
|
|
343
|
+
if (Request::$isGet && in_array('signin', $dynamicRouteParams)) {
|
|
344
344
|
foreach ($providers as $provider) {
|
|
345
|
-
if ($provider instanceof GithubProvider && in_array('github', $dynamicRouteParams
|
|
345
|
+
if ($provider instanceof GithubProvider && in_array('github', $dynamicRouteParams)) {
|
|
346
346
|
$githubAuthUrl = "https://github.com/login/oauth/authorize?scope=user:email%20read:user&client_id={$provider->clientId}";
|
|
347
347
|
Request::redirect($githubAuthUrl);
|
|
348
|
-
} elseif ($provider instanceof GoogleProvider && in_array('google', $dynamicRouteParams
|
|
348
|
+
} elseif ($provider instanceof GoogleProvider && in_array('google', $dynamicRouteParams)) {
|
|
349
349
|
$googleAuthUrl = "https://accounts.google.com/o/oauth2/v2/auth?"
|
|
350
350
|
. "scope=" . urlencode('email profile') . "&"
|
|
351
351
|
. "response_type=code&"
|
|
@@ -358,8 +358,8 @@ class Auth
|
|
|
358
358
|
|
|
359
359
|
$authCode = Validator::string($_GET['code'] ?? '');
|
|
360
360
|
|
|
361
|
-
if (Request::$isGet && in_array('callback', $dynamicRouteParams
|
|
362
|
-
if (in_array('github', $dynamicRouteParams
|
|
361
|
+
if (Request::$isGet && in_array('callback', $dynamicRouteParams) && isset($authCode)) {
|
|
362
|
+
if (in_array('github', $dynamicRouteParams)) {
|
|
363
363
|
$provider = $this->findProvider($providers, GithubProvider::class);
|
|
364
364
|
|
|
365
365
|
if (!$provider) {
|
|
@@ -367,7 +367,7 @@ class Auth
|
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
return $this->githubProvider($provider, $authCode);
|
|
370
|
-
} elseif (in_array('google', $dynamicRouteParams
|
|
370
|
+
} elseif (in_array('google', $dynamicRouteParams)) {
|
|
371
371
|
$provider = $this->findProvider($providers, GoogleProvider::class);
|
|
372
372
|
|
|
373
373
|
if (!$provider) {
|
|
@@ -131,10 +131,8 @@ class TemplateCompiler
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
// Include inner content as 'children'
|
|
135
|
-
|
|
136
|
-
$attributes["children"] = $innerContent;
|
|
137
|
-
}
|
|
134
|
+
// Include inner content as 'children'
|
|
135
|
+
$attributes["children"] = $innerContent;
|
|
138
136
|
|
|
139
137
|
$output .= self::processComponent(
|
|
140
138
|
$componentName,
|
|
@@ -153,13 +151,8 @@ class TemplateCompiler
|
|
|
153
151
|
|
|
154
152
|
protected static function initializeClassMappings(): void
|
|
155
153
|
{
|
|
156
|
-
foreach (
|
|
157
|
-
|
|
158
|
-
as $classPath => $classInfo
|
|
159
|
-
) {
|
|
160
|
-
$normalizedClassPath = str_replace("\\", "/", $classPath);
|
|
161
|
-
$className = pathinfo($normalizedClassPath, PATHINFO_FILENAME);
|
|
162
|
-
self::$classMappings[$className] = $classPath;
|
|
154
|
+
foreach (PrismaPHPSettings::$classLogFiles as $tagName => $fullyQualifiedClassName) {
|
|
155
|
+
self::$classMappings[$tagName] = $fullyQualifiedClassName;
|
|
163
156
|
}
|
|
164
157
|
}
|
|
165
158
|
|
|
@@ -84,6 +84,17 @@ final class Validator
|
|
|
84
84
|
return preg_match('/^c[0-9a-z]{8,}$/', $value) ? $value : null;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Validate a CUID2.
|
|
89
|
+
*
|
|
90
|
+
* @param mixed $value The value to validate.
|
|
91
|
+
* @return string|null The valid CUID2 or null if invalid.
|
|
92
|
+
*/
|
|
93
|
+
public static function cuid2($value): ?string
|
|
94
|
+
{
|
|
95
|
+
return preg_match('/^[0-9a-zA-Z_-]{21,}$/', $value) ? $value : null;
|
|
96
|
+
}
|
|
97
|
+
|
|
87
98
|
/**
|
|
88
99
|
* Validate a size string (e.g., "10MB").
|
|
89
100
|
*
|
package/dist/src/app/js/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const eventAttributesB6B56=new Set(["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"]);(()=>{const e=EventTarget.prototype.addEventListener,t=EventTarget.prototype.removeEventListener,n=new Map;EventTarget.prototype.addEventListener=function(t,o,s){n.has(this)||n.set(this,new Map);const a=n.get(this).get(t)||new Set;a.add(o),n.get(this).set(t,a),e.call(this,t,o,s)},EventTarget.prototype.removeEventListener=function(e,o,s){if(n.has(this)&&n.get(this).has(e)){const t=n.get(this).get(e);t&&(t.delete(o),0===t.size&&n.get(this).delete(e))}t.call(this,e,o,s)},EventTarget.prototype.removeAllEventListeners=function(e){if(n.has(this)&&n.get(this).has(e)){const o=n.get(this).get(e);o&&(o.forEach((n=>{t.call(this,e,n)})),n.get(this).delete(e))}}})();const stateA129A={checkedElements:new Set};let responseDataDEAC2=null;var store=null;let isNavigatingA12E1=!1;const redirectRegex3AE99=/redirect_7F834\s*=\s*(\/[^\s]*)/;function observeDOMChanges(){new MutationObserver((e=>{for(const t of e)"childList"===t.type&&t.addedNodes.length>0&&attachWireFunctionEvents()})).observe(document.body,{childList:!0,subtree:!0})}function attachWireFunctionEvents(){handleHiddenAttribute();document.querySelectorAll("button, input, select, textarea, a, form, label, div, span").forEach((e=>{if(handleAnchorTag(e),Array.from(e.attributes).filter((e=>eventAttributesB6B56.has(e.name))).forEach((t=>{const n=t.name.slice(2),o=t.value;o&&(e.removeAttribute(t.name),handleDebounce(e,n,o))})),e instanceof HTMLFormElement){const t=e.getAttribute("onsubmit");t&&(e.removeAttribute("onsubmit"),handleDebounce(e,"submit",t))}}))}function handleHiddenAttribute(){const e=document.querySelectorAll("[pp-visibility]"),t=document.querySelectorAll("[pp-display]");e.forEach((e=>handleVisibilityElementAttribute(e,"pp-visibility",handleElementVisibility))),t.forEach((e=>handleVisibilityElementAttribute(e,"pp-display",handleElementDisplay)))}function handleVisibilityElementAttribute(e,t,n){const o=e.getAttribute(t);if(o)if(isJsonLike(o)){n(e,parseJson(o))}else{const n=parseTime(o);if(n>0){const o="pp-visibility"===t?"visibility":"display";scheduleChange(e,n,o,"visibility"===o?"hidden":"none")}}}function isJsonLike(e){return"string"==typeof e&&((e=e.trim()).startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))}function handleElementVisibility(e,t){handleElementChange(e,t,"visibility","hidden","visible")}function handleElementDisplay(e,t){handleElementChange(e,t,"display","none","block")}function handleElementChange(e,t,n,o,s){const a=t.start?parseTime(t.start):0,i=t.end?parseTime(t.end):0;a>0?(e.style[n]=o,scheduleChange(e,a,n,s),i>0&&scheduleChange(e,a+i,n,o)):i>0&&scheduleChange(e,i,n,o)}function scheduleChange(e,t,n,o){setTimeout((()=>{requestAnimationFrame((()=>{e.style[n]=o}))}),t)}function parseTime(e){if("number"==typeof e)return e;const t=e.match(/^(\d+)(ms|s|m)?$/);if(t){const e=parseInt(t[1],10);switch(t[2]||"ms"){case"ms":return e;case"s":return 1e3*e;case"m":return 60*e*1e3;default:return e}}return 0}async function handleDebounce(e,t,n){e.removeEventListener(t,(()=>{}));const o=e.getAttribute("pp-debounce")||"",s=e.getAttribute("pp-before-request")||"",a=e.getAttribute("pp-after-request")||"",i=async t=>{t.preventDefault();try{s&&await invokeHandler(e,s,t),await invokeHandler(e,n,t),a&&"@close"!==a&&await invokeHandler(e,a,t),handlerAutofocusAttribute()}catch(e){}};if(o){const n=debounce(i,parseTime(o));e instanceof HTMLFormElement&&"submit"===t?e.addEventListener(t,(e=>{e.preventDefault(),n(e)})):e.addEventListener(t,n)}else e.addEventListener(t,i)}function handlerAutofocusAttribute(){const e=document.querySelectorAll("[pp-autofocus]");let t=!1;e.forEach((e=>{if(t)return;const n=e.getAttribute("pp-autofocus");if(!n||!isJsonLike(n))return;const o=parseJson(n);if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=["text","search","tel","url","password"];if(e instanceof HTMLInputElement)if(t.includes(e.type))if("number"===e.type){e.type="text";const t=e.value.length||0;e.setSelectionRange(t,t),e.type="number"}else setCursorPosition(e,o);else;else e instanceof HTMLTextAreaElement&&setCursorPosition(e,o)}e.focus(),t=!0}))}function setCursorPosition(e,t){if(t.start)e.setSelectionRange(0,0);else if(t.end){const t=e.value.length||0;e.setSelectionRange(t,t)}else if(t.length){const n=parseInt(t.length,10)||0;e.setSelectionRange(n,n)}}async function invokeHandler(e,t,n){try{const o=t.match(/^(\w+(\.\w+)*)\((.*)\)$/);if(o){const s=o[1].split("."),{context:a,methodName:i}=resolveContext(s);"function"==typeof a[i]?new Function("event",t).call(e,n):await handleParsedCallback(e,t)}else await handleParsedCallback(e,t)}catch(e){}}function resolveContext(e){let t=window;for(let n=0;n<e.length-1;n++)if(t=t[e[n]],!t)throw new Error(`Cannot find object ${e[n]} in the context.`);return{context:t,methodName:e[e.length-1]}}async function handleParsedCallback(e,t){const{funcName:n,data:o}=parseCallback(e,t);if(!n)return;const s=window[n];if("function"==typeof s){const t=e.hasAttribute("pp-after-request"),n=Array.isArray(o.args)?o.args:[],a=responseDataDEAC2?parseJson(responseDataDEAC2):{response:responseDataDEAC2};let i={args:n,element:e,data:o};t&&(i={...i,...a}),await s(i)}else responseDataDEAC2=null,responseDataDEAC2=await handleUndefinedFunction(e,n,o)}function handleAnchorTag(e){e instanceof HTMLAnchorElement&&e.addEventListener("click",(async e=>{const t=e.currentTarget,n=t.getAttribute("href"),o=t.getAttribute("target");if(n&&"_blank"!==o&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),!isNavigatingA12E1)){isNavigatingA12E1=!0;try{if(/^(https?:)?\/\//i.test(n)&&!n.startsWith(window.location.origin))window.location.href=n;else{const e=t.getAttribute("pp-append-params");if(n.startsWith("?")&&"true"===e){const e=new URL(window.location.href),t=new URLSearchParams(e.search);let o="";const[s,a]=n.split("#");a&&(o=`#${a}`);new URLSearchParams(s.split("?")[1]).forEach(((e,n)=>{t.set(n,e)}));const i=`${e.pathname}?${t.toString()}${o}`;history.pushState(null,"",i)}else{const[e,t]=n.split("#"),o=`${e}${t?`#${t}`:""}`;history.pushState(null,"",o)}const o=n.indexOf("#");if(-1!==o){const e=n.slice(o+1),t=document.getElementById(e);if(t)t.scrollIntoView({behavior:"smooth"});else{await handleNavigation();const t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth"})}}else await handleNavigation()}}catch(e){}finally{isNavigatingA12E1=!1}}}))}async function handleNavigation(){try{const e=e=>{const t=e.querySelector("[pp-loading-transition]")?.getAttribute("pp-loading-transition");let n=250,o=250;if(t)try{const e=parseJson(t);n=parseTime(e.fadeIn||n),o=parseTime(e.fadeOut||o)}catch(e){}return{fadeIn:n,fadeOut:o}},t=(e,t)=>new Promise((n=>{e.style.transition=`opacity ${t}ms ease-out`,e.style.opacity="0",setTimeout((()=>{e.style.transition="",n()}),t)})),n=(e,t)=>{e.style.transition=`opacity ${t}ms ease-in`,e.style.opacity="1",setTimeout((()=>{e.style.transition=""}),t)},o=async o=>{const s=document.querySelector("[pp-loading-content='true']")||document.body;if(s){const{fadeIn:a,fadeOut:i}=e(o);await t(s,i),s.innerHTML=o.innerHTML,n(s,a)}},s=window.location.pathname,a=document.getElementById("loading-file-1B87E");if(a){let e=a.querySelector(`div[pp-loading-url='${s}']`);e||(e=a.querySelector("div[pp-loading-url='/']")),e&&await o(e)}const i=await pphpFetch(window.location.href),r=i.match(redirectRegex3AE99);if(r&&r[1]){const e=r[1];await handleRedirect(e)}else updateDocumentContent(i)}catch(e){}}function onUrlChange(){}async function updateBodyContent(e){const t=saveScrollPositions();saveState();const n=(new DOMParser).parseFromString(e,"text/html");document.removeAllEventListeners("PPBodyLoaded"),await appendCallbackResponse(n),restoreState(),restoreScrollPositions(t),attachWireFunctionEvents(),document.dispatchEvent(new Event("PPBodyLoaded"))}async function appendCallbackResponse(e){const t=e.getElementById("afterbegin-8D95D");if(t){const e=document.getElementById("afterbegin-8D95D");e?e.innerHTML=t.innerHTML:document.body.insertAdjacentHTML("afterbegin",t.outerHTML)}await populateDocumentBody(e)}async function updateDocumentContent(e){const t=saveScrollPositions(),n=(new DOMParser).parseFromString(e,"text/html"),o="pp-dynamic-script",s="pp-dynamic-link";document.head.querySelectorAll("[pp-dynamic-meta]").forEach((e=>e.remove()));document.head.querySelectorAll("[pp-dynamic-link]").forEach((e=>e.remove()));document.head.querySelectorAll("[pp-dynamic-script]").forEach((e=>e.remove()));document.removeAllEventListeners("PPBodyLoaded"),await(async e=>{Array.from(e.head.children).forEach((e=>{const t=e.tagName;if("SCRIPT"===t&&e.hasAttribute(o)){const t=document.createElement("script");Array.from(e.attributes).forEach((e=>t.setAttribute(e.name,e.value))),e.textContent&&(t.textContent=e.textContent),document.head.appendChild(t)}else if("META"===t){if(e.getAttribute("charset")||"viewport"===e.getAttribute("name"))return;const t=e.name,n=e.getAttribute("property"),o=document.head.querySelector(t?`meta[name="${t}"]`:`meta[property="${n}"]`);o?document.head.replaceChild(e.cloneNode(!0),o):document.head.appendChild(e.cloneNode(!0))}else if("TITLE"===t){const t=document.head.querySelector("title");t?document.head.replaceChild(e.cloneNode(!0),t):document.head.appendChild(e.cloneNode(!0))}else if("LINK"===t){const t=t=>{const n=document.head.querySelector('link[rel="icon"]');if(n)document.head.replaceChild(e.cloneNode(!0),n);else{const e=document.createElement("link");e.rel="icon",e.href=t,document.head.appendChild(e)}};if("icon"===e.getAttribute("rel")){t(e.href)}else if(e.hasAttribute(s)){const t=e.cloneNode(!0);document.head.appendChild(t)}}})),await populateDocumentBody(e)})(n),restoreScrollPositions(t),attachWireFunctionEvents(),document.dispatchEvent(new Event("PPBodyLoaded"))}async function populateDocumentBody(e){try{const t=e.body.cloneNode(!0);t.querySelectorAll("script").forEach((e=>{const t=document.createElement("script");Array.from(e.attributes).forEach((e=>{t.setAttribute(e.name,e.value)})),e.hasAttribute("src")||(t.textContent=e.textContent),e.parentNode?.replaceChild(t,e)})),document.body.replaceWith(t)}catch(e){}}function saveState(){const e=document.activeElement;stateA129A.focusId=e?.id||e?.name,stateA129A.focusValue=e?.value,stateA129A.focusChecked=e?.checked,stateA129A.focusType=e?.type,stateA129A.focusSelectionStart=e?.selectionStart,stateA129A.focusSelectionEnd=e?.selectionEnd,stateA129A.isSuspense=e.hasAttribute("pp-suspense"),stateA129A.checkedElements.clear(),document.querySelectorAll('input[type="checkbox"]:checked').forEach((e=>{stateA129A.checkedElements.add(e.id||e.name)})),document.querySelectorAll('input[type="radio"]:checked').forEach((e=>{stateA129A.checkedElements.add(e.id||e.name)}))}function restoreState(){if(stateA129A.focusId){const e=document.getElementById(stateA129A.focusId)||document.querySelector(`[name="${stateA129A.focusId}"]`);if(e instanceof HTMLInputElement){const t=e.value.length||0;void 0!==stateA129A.focusSelectionStart&&null!==stateA129A.focusSelectionEnd&&e.setSelectionRange(t,t),stateA129A.focusValue&&("checkbox"===e.type||"radio"===e.type?e.checked=!!stateA129A.focusChecked:"number"===e.type||"email"===e.type?(e.type="text",e.setSelectionRange(t,t),e.type="number"===e.type?"number":"email"):"date"===e.type||"month"===e.type||"week"===e.type||"time"===e.type||"datetime-local"===e.type||"color"===e.type||"file"===e.type||""!==e.value&&(e.value=stateA129A.focusValue)),e.focus()}else if(e instanceof HTMLTextAreaElement){const t=e.value.length||0;void 0!==stateA129A.focusSelectionStart&&null!==stateA129A.focusSelectionEnd&&e.setSelectionRange(t,t),stateA129A.focusValue&&""!==e.value&&(e.value=stateA129A.focusValue),e.focus()}else e instanceof HTMLSelectElement&&(stateA129A.focusValue&&""!==e.value&&(e.value=stateA129A.focusValue),e.focus())}stateA129A.checkedElements.forEach((e=>{const t=document.getElementById(e);t&&(t.checked=!0)}))}function saveScrollPositions(){const e={window:{scrollTop:window.scrollY||document.documentElement.scrollTop,scrollLeft:window.scrollX||document.documentElement.scrollLeft}};return document.querySelectorAll("*").forEach((t=>{(t.scrollTop||t.scrollLeft)&&(e[getElementKey(t)]={scrollTop:t.scrollTop,scrollLeft:t.scrollLeft})})),e}function restoreScrollPositions(e){requestAnimationFrame((()=>{const t=e.window;t&&window.scrollTo(t.scrollLeft,t.scrollTop),document.querySelectorAll("*").forEach((t=>{const n=getElementKey(t);e[n]&&(t.scrollTop=e[n].scrollTop,t.scrollLeft=e[n].scrollLeft)}))}))}function getElementKey(e){return e.id||e.className||e.tagName}async function pphpFetch(e,t){const n=await fetch(e,{...t,headers:{...t?.headers,"X-Requested-With":"XMLHttpRequest"}});return await n.text()}function parseCallback(e,t){let n={};const o=e.closest("form");if(o){new FormData(o).forEach(((e,t)=>{n[t]?Array.isArray(n[t])?n[t].push(e):n[t]=[n[t],e]:n[t]=e}))}else e instanceof HTMLInputElement?n=handleInputElement(e):(e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&(n[e.name]=e.value);const s=t.match(/(\w+)\((.*)\)/);if(s){const e=s[1];let t=s[2].trim();if(t.startsWith("{")&&t.endsWith("}"))try{const e=parseJson(t);"object"==typeof e&&null!==e&&(n={...n,...e})}catch(e){}else{const e=t.split(/,(?=(?:[^'"]*['"][^'"]*['"])*[^'"]*$)/).map((e=>e.trim().replace(/^['"]|['"]$/g,"")));n.args=e}return{funcName:e,data:n}}return{funcName:t,data:n}}function handleInputElement(e){let t={};if(e.name)if("checkbox"===e.type)t[e.name]={value:e.value,checked:e.checked};else if("radio"===e.type){const n=document.querySelector(`input[name="${e.name}"]:checked`);t[e.name]=n?n.value:null}else t[e.name]=e.value;else"checkbox"===e.type||"radio"===e.type?t.value=e.checked:t.value=e.value;return t}function updateElementAttributes(e,t){for(const n in t)if(t.hasOwnProperty(n))switch(n){case"innerHTML":case"outerHTML":case"textContent":case"innerText":e[n]=decodeHTML(t[n]);break;case"insertAdjacentHTML":e.insertAdjacentHTML(t.position||"beforeend",decodeHTML(t[n].html));break;case"insertAdjacentText":e.insertAdjacentText(t.position||"beforeend",decodeHTML(t[n].text));break;case"setAttribute":e.setAttribute(t.attrName,decodeHTML(t[n]));break;case"removeAttribute":e.removeAttribute(t[n]);break;case"className":e.className=decodeHTML(t[n]);break;case"classList.add":e.classList.add(...decodeHTML(t[n]).split(","));break;case"classList.remove":e.classList.remove(...decodeHTML(t[n]).split(","));break;case"classList.toggle":e.classList.toggle(decodeHTML(t[n]));break;case"classList.replace":const[o,s]=decodeHTML(t[n]).split(",");e.classList.replace(o,s);break;case"dataset":e.dataset[t.attrName]=decodeHTML(t[n]);break;case"style":Object.assign(e.style,t[n]);break;case"value":e.value=decodeHTML(t[n]);break;case"checked":e.checked=t[n];break;default:e.setAttribute(n,decodeHTML(t[n]))}}function decodeHTML(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}function saveElementOriginalState(e){if(e.hasAttribute("pp-suspense")&&!e.hasAttribute("pp-original-state")){const t={};e.textContent&&(t.textContent=e.textContent.trim()),e.innerHTML&&(t.innerHTML=e.innerHTML.trim()),(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(t.value=e.value);for(let n=0;n<e.attributes.length;n++){const o=e.attributes[n];t[o.name]=o.value}e.setAttribute("pp-original-state",JSON.stringify(t))}if(e instanceof HTMLFormElement){let t=null;const n=e.id;n&&(t=document.querySelector(`[form="${n}"]`)),n&&t||(t=Array.from(e.elements).find((e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement))),t&&(t.hasAttribute("pp-original-state")||saveElementOriginalState(t))}e.querySelectorAll("[pp-suspense]").forEach((e=>saveElementOriginalState(e)))}async function handleSuspenseElement(e){let t=e.getAttribute("pp-suspense")||"";const n=(e,t)=>{for(const n in t)if(t.hasOwnProperty(n))for(const t of e.elements)if(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){const e=t.getAttribute("pp-suspense")||"";if(e)if(isJsonLike(e)){const n=parseJson(e);"disabled"!==n.onsubmit&&updateElementAttributes(t,n),n.targets&&n.targets.forEach((e=>{const{id:t,...n}=e,o=document.querySelector(t);o&&s(o,n)}))}else o(t,e)}},o=(e,t)=>{e instanceof HTMLInputElement?e.value=t:e.textContent=t},s=(e,t)=>{e instanceof HTMLFormElement?n(e,t):updateElementAttributes(e,t)};try{if(t&&isJsonLike(t)){const o=parseJson(t);if(o)if(e instanceof HTMLFormElement){const t=new FormData(e),s={};t.forEach(((e,t)=>{s[t]=e})),o.disabled&&toggleFormElements(e,!0);const{disabled:a,...i}=o;updateElementAttributes(e,i),n(e,s)}else if(o.targets){o.targets.forEach((e=>{const{id:t,...n}=e,o=document.querySelector(t);o&&s(o,n)}));const{targets:t,...n}=o;updateElementAttributes(e,n)}else{if("disabled"===o.empty&&""===e.value)return;const{empty:t,...n}=o;updateElementAttributes(e,n)}}else if(t)o(e,t);else if(e instanceof HTMLFormElement){const t=new FormData(e),o={};t.forEach(((e,t)=>{o[t]=e})),n(e,o)}}catch(e){}}function restoreSuspenseElement(e){const t=e.getAttribute("pp-original-state");if(e.hasAttribute("pp-suspense")&&t){const n=(e,t)=>{for(const n in t)t.hasOwnProperty(n)&&("textContent"===n?e.textContent=t[n]:"innerHTML"===n?e.innerHTML=t[n]:"disabled"===n?!0===t[n]?e.setAttribute("disabled","true"):e.removeAttribute("disabled"):e.setAttribute(n,t[n]));for(const n of Array.from(e.attributes))t.hasOwnProperty(n.name)||e.removeAttribute(n.name)},o=(e,t)=>{for(const o in t)if(t.hasOwnProperty(o))for(const t of Array.from(e.elements))if(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){const e=t.getAttribute("pp-original-state")||"";if(e){if(isJsonLike(e)){const o=parseJson(e);n(t,o)}else s(t,e);t.removeAttribute("pp-original-state")}}},s=(e,t)=>{e instanceof HTMLInputElement?e.value=t:e.textContent=t},a=(e,t)=>{e instanceof HTMLFormElement?o(e,t):n(e,t)};try{const s=parseJson(t);if(s)if(e instanceof HTMLFormElement){const t=e.id;if(t){const e=document.querySelector(`[form="${t}"]`);if(e){const t=e.getAttribute("pp-original-state");if(t&&isJsonLike(t)){const o=parseJson(t);n(e,o)}}}const s=new FormData(e),a={};if(s.forEach(((e,t)=>{a[t]=e})),o(e,a),e.hasAttribute("pp-suspense")){const t=e.getAttribute("pp-suspense")||"";if(parseJson(t).disabled)for(const t of Array.from(e.elements))(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.removeAttribute("disabled")}}else if(s.targets){s.targets.forEach((e=>{const{id:t,...n}=e,o=document.querySelector(t);o&&a(o,n)}));const{targets:t,...o}=s;n(e,o)}else{const{empty:t,...o}=s;n(e,o)}}catch(e){}}e.querySelectorAll("[pp-suspense]").forEach((e=>restoreSuspenseElement(e))),e.removeAttribute("pp-original-state")}function parseJson(e){try{return JSON5.parse(e)}catch(e){return null}}function toggleFormElements(e,t){Array.from(e.elements).forEach((e=>{(e instanceof HTMLInputElement||e instanceof HTMLButtonElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&(e.disabled=t)}))}async function pphpFetchFile(e,t,n){const o=new FormData,s=n.files;if(s)for(let e=0;e<s.length;e++)o.append("file[]",s[e]);o.append("callback",t);const a=await fetch(e,{method:"POST",headers:{HTTP_PPHP_WIRE_REQUEST:"true"},body:o});return await a.text()}function getUrlParams(){const e={};return new URLSearchParams(window.location.search).forEach(((t,n)=>{e[n]=t})),e}async function handleUndefinedFunction(e,t,n){const o=createFetchOptions({callback:t,...n}),s=createFetchOptions({secondRequestC69CD:!0,...getUrlParams()});try{saveElementOriginalState(e),handleSuspenseElement(e);const n=new URL(window.location.href);let a="",i="",r={success:!1};const c=e.querySelector("input[type='file']");if(c){if(a=await pphpFetchFile(n.href,t,c),i=extractJson(a)||"",i)try{r=parseJson(i)}catch(e){}}else if(a=await pphpFetch(n.href,o),i=extractJson(a)||"",i)try{r=parseJson(i)}catch(e){}const l=e.getAttribute("pp-before-request")||"",u=e.getAttribute("pp-after-request")||"";if((l||u&&r.success)&&restoreSuspenseElement(e),l||u){let e="";if(r.success){e=a.replace(i,"")}else e=a;if(appendAfterbegin(e),!u&&!r.success)return}if(u&&r.success){handleAfterRequest(u,i);return appendAfterbegin(a.replace(i,"")),i}if("@close"===u)return r.success?i:void 0;const d=await pphpFetch(n.href,s);await handleResponseRedirectOrUpdate(a,d,i,r)}catch(e){}}function createFetchOptions(e){return{method:"POST",headers:{"Content-Type":"application/json",HTTP_PPHP_WIRE_REQUEST:"true"},body:JSON.stringify(e)}}function getRedirectUrl(e){const t=e.match(redirectRegex3AE99);return t?t[1]:null}function getUpdatedHTMLContent(e,t,n){const o=document.createElement("div");if(o.id="afterbegin-8D95D",n&&t?.success){const t=e.replace(n,"");o.innerHTML=t}else o.innerHTML=e;return o.innerHTML?o:null}async function handleResponseRedirectOrUpdate(e,t,n,o){const s=getRedirectUrl(e);if(s)await handleRedirect(s);else{const s=getUpdatedHTMLContent(e,n,o),a=(new DOMParser).parseFromString(t,"text/html");s&&a.body.insertAdjacentElement("afterbegin",s),updateBodyContent(a.body.outerHTML)}}function appendAfterbegin(e){if(!e)return;const t="afterbegin-8D95D";let n=document.getElementById(t);n?(n.innerHTML=e,document.body.insertAdjacentElement("afterbegin",n)):(n=document.createElement("div"),n.id=t,n.innerHTML=e,document.body.insertAdjacentElement("afterbegin",n))}function extractJson(e){const t=e?.match(/\{[\s\S]*\}/);return t?t[0]:null}function handleAfterRequest(e,t){if(!isJsonLike(e))return;const n=parseJson(e),o=t?parseJson(t):null,s=n.targets;Array.isArray(s)&&s.forEach((e=>{const{id:t,...n}=e,s=document.querySelector(t);let a={};if(o){for(const t in n)if(n.hasOwnProperty(t))switch(t){case"innerHTML":case"outerHTML":case"textContent":case"innerText":"response"===n[t]&&(a[t]=e.responseKey?o[e.responseKey]:o.response);break;default:a[t]=n[t];break}}else a=n;s&&updateElementAttributes(s,a)}))}async function handleRedirect(e){if(e)try{const t=new URL(e,window.location.origin);t.origin!==window.location.origin?window.location.href=e:(history.pushState(null,"",e),await handleNavigation())}catch(e){}}function debounce(e,t=300,n=!1){let o;return function(...s){const a=this;o&&clearTimeout(o),o=setTimeout((()=>{o=null,n||e.apply(a,s)}),t),n&&!o&&e.apply(a,s)}}function copyCode(e,t,n,o,s="img",a=2e3){if(!(e instanceof HTMLElement))return;const i=e.closest(`.${t}`)?.querySelector("pre code"),r=i?.textContent?.trim()||"";r?navigator.clipboard.writeText(r).then((()=>{const t=e.querySelector(s);if(t)for(const[e,n]of Object.entries(o))e in t?t[e]=n:t.setAttribute(e,n);setTimeout((()=>{if(t)for(const[e,o]of Object.entries(n))e in t?t[e]=o:t.setAttribute(e,o)}),a)}),(()=>{alert("Failed to copy command to clipboard")})):alert("Failed to find the code block to copy")}if((e=>{const t=e.pushState,n=e.replaceState;e.pushState=function(n,o,s){const a=t.apply(e,arguments);return window.dispatchEvent(new Event("urlchange")),a},e.replaceState=function(t,o,s){const a=n.apply(e,arguments);return window.dispatchEvent(new Event("urlchange")),a}})(window.history),document.addEventListener("PPBodyLoaded",(()=>{attachWireFunctionEvents(),observeDOMChanges()})),document.addEventListener("DOMContentLoaded",(()=>{document.dispatchEvent(new Event("PPBodyLoaded"))})),window.addEventListener("popstate",(async()=>{await handleNavigation()})),window.addEventListener("urlchange",(()=>{})),null===store){class e{static instance=null;state;listeners;constructor(e={}){this.state=e,this.listeners=[]}static getInstance(t={}){return e.instance||(e.instance=new e(t),e.instance.loadState()),e.instance}setState(e){this.state={...this.state,...e},this.listeners.forEach((e=>e(this.state))),this.saveState()}subscribe(e){return this.listeners.push(e),e(this.state),()=>{this.listeners=this.listeners.filter((t=>t!==e))}}saveState(){localStorage.setItem("appState_59E13",JSON.stringify(this.state))}loadState(){const e=localStorage.getItem("appState_59E13");e&&(this.state=parseJson(e),this.listeners.forEach((e=>e(this.state))))}resetState(e){e?(delete this.state[e],this.saveState()):(this.state={},localStorage.removeItem("appState_59E13")),this.listeners.forEach((e=>e(this.state)))}}store=e.getInstance()}
|
|
1
|
+
const eventAttributesB6B56=new Set(["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"]);(()=>{const e=EventTarget.prototype.addEventListener,t=EventTarget.prototype.removeEventListener,n=new Map;EventTarget.prototype.addEventListener=function(t,o,s){n.has(this)||n.set(this,new Map);const a=n.get(this).get(t)||new Set;a.add(o),n.get(this).set(t,a),e.call(this,t,o,s)},EventTarget.prototype.removeEventListener=function(e,o,s){if(n.has(this)&&n.get(this).has(e)){const t=n.get(this).get(e);t&&(t.delete(o),0===t.size&&n.get(this).delete(e))}t.call(this,e,o,s)},EventTarget.prototype.removeAllEventListeners=function(e){if(n.has(this)&&n.get(this).has(e)){const o=n.get(this).get(e);o&&(o.forEach((n=>{t.call(this,e,n)})),n.get(this).delete(e))}}})();const stateA129A={checkedElements:new Set};let responseDataDEAC2=null;var store=null;let isNavigatingA12E1=!1;const redirectRegex3AE99=/redirect_7F834\s*=\s*(\/[^\s]*)/;function observeDOMChanges(){new MutationObserver((e=>{for(const t of e)"childList"===t.type&&t.addedNodes.length>0&&attachWireFunctionEvents()})).observe(document.body,{childList:!0,subtree:!0})}function attachWireFunctionEvents(){handleHiddenAttribute();document.querySelectorAll("button, input, select, textarea, a, form, label, div, span").forEach((e=>{if(handleAnchorTag(e),Array.from(e.attributes).filter((e=>eventAttributesB6B56.has(e.name))).forEach((t=>{const n=t.name.slice(2),o=t.value;o&&(e.removeAttribute(t.name),handleDebounce(e,n,o))})),e instanceof HTMLFormElement){const t=e.getAttribute("onsubmit");t&&(e.removeAttribute("onsubmit"),handleDebounce(e,"submit",t))}}))}function handleHiddenAttribute(){const e=document.querySelectorAll("[pp-visibility]"),t=document.querySelectorAll("[pp-display]");e.forEach((e=>handleVisibilityElementAttribute(e,"pp-visibility",handleElementVisibility))),t.forEach((e=>handleVisibilityElementAttribute(e,"pp-display",handleElementDisplay)))}function handleVisibilityElementAttribute(e,t,n){const o=e.getAttribute(t);if(o)if(isJsonLike(o)){n(e,parseJson(o))}else{const n=parseTime(o);if(n>0){const o="pp-visibility"===t?"visibility":"display";scheduleChange(e,n,o,"visibility"===o?"hidden":"none")}}}function isJsonLike(e){return"string"==typeof e&&((e=e.trim()).startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))}function handleElementVisibility(e,t){handleElementChange(e,t,"visibility","hidden","visible")}function handleElementDisplay(e,t){handleElementChange(e,t,"display","none","block")}function handleElementChange(e,t,n,o,s){const a=t.start?parseTime(t.start):0,r=t.end?parseTime(t.end):0;a>0?(e.style[n]=o,scheduleChange(e,a,n,s),r>0&&scheduleChange(e,a+r,n,o)):r>0&&scheduleChange(e,r,n,o)}function scheduleChange(e,t,n,o){setTimeout((()=>{requestAnimationFrame((()=>{e.style[n]=o}))}),t)}function parseTime(e){if("number"==typeof e)return e;const t=e.match(/^(\d+)(ms|s|m)?$/);if(t){const e=parseInt(t[1],10);switch(t[2]||"ms"){case"ms":return e;case"s":return 1e3*e;case"m":return 60*e*1e3;default:return e}}return 0}async function handleDebounce(e,t,n){e.removeEventListener(t,(()=>{}));const o=e.getAttribute("pp-debounce")||"",s=e.getAttribute("pp-before-request")||"",a=e.getAttribute("pp-after-request")||"",r=async t=>{t.preventDefault();try{s&&await invokeHandler(e,s,t),await invokeHandler(e,n,t),a&&"@close"!==a&&await invokeHandler(e,a,t),handlerAutofocusAttribute()}catch(e){}};if(o){const n=debounce(r,parseTime(o));e instanceof HTMLFormElement&&"submit"===t?e.addEventListener(t,(e=>{e.preventDefault(),n(e)})):e.addEventListener(t,n)}else e.addEventListener(t,r)}function handlerAutofocusAttribute(){const e=document.querySelectorAll("[pp-autofocus]");let t=!1;e.forEach((e=>{if(t)return;const n=e.getAttribute("pp-autofocus");if(!n||!isJsonLike(n))return;const o=parseJson(n);if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=["text","search","tel","url","password"];if(e instanceof HTMLInputElement)if(t.includes(e.type))if("number"===e.type){e.type="text";const t=e.value.length||0;e.setSelectionRange(t,t),e.type="number"}else setCursorPosition(e,o);else;else e instanceof HTMLTextAreaElement&&setCursorPosition(e,o)}e.focus(),t=!0}))}function setCursorPosition(e,t){if(t.start)e.setSelectionRange(0,0);else if(t.end){const t=e.value.length||0;e.setSelectionRange(t,t)}else if(t.length){const n=parseInt(t.length,10)||0;e.setSelectionRange(n,n)}}async function invokeHandler(e,t,n){try{const o=t.match(/^(\w+(\.\w+)*)\((.*)\)$/);if(o){const s=o[1].split("."),{context:a,methodName:r}=resolveContext(s);"function"==typeof a[r]?new Function("event",t).call(e,n):await handleParsedCallback(e,t)}else await handleParsedCallback(e,t)}catch(e){}}function resolveContext(e){let t=window;for(let n=0;n<e.length-1;n++)if(t=t[e[n]],!t)throw new Error(`Cannot find object ${e[n]} in the context.`);return{context:t,methodName:e[e.length-1]}}async function handleParsedCallback(e,t){const{funcName:n,data:o}=parseCallback(e,t);if(!n)return;const s=window[n];if("function"==typeof s){const t=e.hasAttribute("pp-after-request"),n=Array.isArray(o.args)?o.args:[],a=responseDataDEAC2?parseJson(responseDataDEAC2):{response:responseDataDEAC2};let r={args:n,element:e,data:o};t&&(r={...r,...a}),await s(r)}else responseDataDEAC2=null,responseDataDEAC2=await handleUndefinedFunction(e,n,o)}function handleAnchorTag(e){e instanceof HTMLAnchorElement&&e.addEventListener("click",(async e=>{const t=e.currentTarget,n=t.getAttribute("href"),o=t.getAttribute("target");if(n&&"_blank"!==o&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),!isNavigatingA12E1)){isNavigatingA12E1=!0;try{if(/^(https?:)?\/\//i.test(n)&&!n.startsWith(window.location.origin))window.location.href=n;else{const e=t.getAttribute("pp-append-params");if(n.startsWith("?")&&"true"===e){const e=new URL(window.location.href),t=new URLSearchParams(e.search);let o="";const[s,a]=n.split("#");a&&(o=`#${a}`);new URLSearchParams(s.split("?")[1]).forEach(((e,n)=>{t.set(n,e)}));const r=`${e.pathname}?${t.toString()}${o}`;history.pushState(null,"",r)}else{const[e,t]=n.split("#"),o=`${e}${t?`#${t}`:""}`;history.pushState(null,"",o)}const o=n.indexOf("#");if(-1!==o){const e=n.slice(o+1),t=document.getElementById(e);if(t)t.scrollIntoView({behavior:"smooth"});else{await handleNavigation();const t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth"})}}else await handleNavigation()}}catch(e){}finally{isNavigatingA12E1=!1}}}))}async function handleNavigation(){try{const e=e=>{const t=e.querySelector("[pp-loading-transition]")?.getAttribute("pp-loading-transition");let n=250,o=250;if(t)try{const e=parseJson(t);n=parseTime(e.fadeIn||n),o=parseTime(e.fadeOut||o)}catch(e){}return{fadeIn:n,fadeOut:o}},t=(e,t)=>new Promise((n=>{e.style.transition=`opacity ${t}ms ease-out`,e.style.opacity="0",setTimeout((()=>{e.style.transition="",n()}),t)})),n=(e,t)=>{e.style.transition=`opacity ${t}ms ease-in`,e.style.opacity="1",setTimeout((()=>{e.style.transition=""}),t)},o=async o=>{const s=document.querySelector("[pp-loading-content='true']")||document.body;if(s){const{fadeIn:a,fadeOut:r}=e(o);await t(s,r),s.innerHTML=o.innerHTML,n(s,a)}},s=window.location.pathname,a=document.getElementById("loading-file-1B87E");if(a){let e=null,t=s;for(;t&&(e=a.querySelector(`div[pp-loading-url='${t}']`),!e);){const e=t.lastIndexOf("/");t=e>0?t.substring(0,e):"/"}e||(e=a.querySelector("div[pp-loading-url='/']")),e&&await o(e)}const r=await pphpFetch(window.location.href),i=r.match(redirectRegex3AE99);if(i&&i[1]){const e=i[1];await handleRedirect(e)}else updateDocumentContent(r)}catch(e){}}function onUrlChange(){}async function updateBodyContent(e){const t=saveScrollPositions();saveState();const n=(new DOMParser).parseFromString(e,"text/html");document.removeAllEventListeners("PPBodyLoaded"),await appendCallbackResponse(n),restoreState(),restoreScrollPositions(t),attachWireFunctionEvents(),document.dispatchEvent(new Event("PPBodyLoaded"))}async function appendCallbackResponse(e){const t=e.getElementById("afterbegin-8D95D");if(t){const e=document.getElementById("afterbegin-8D95D");e?e.innerHTML=t.innerHTML:document.body.insertAdjacentHTML("afterbegin",t.outerHTML)}await populateDocumentBody(e)}async function updateDocumentContent(e){const t=saveScrollPositions(),n=(new DOMParser).parseFromString(e,"text/html"),o="pp-dynamic-script",s="pp-dynamic-link";document.head.querySelectorAll("[pp-dynamic-meta]").forEach((e=>e.remove()));document.head.querySelectorAll("[pp-dynamic-link]").forEach((e=>e.remove()));document.head.querySelectorAll("[pp-dynamic-script]").forEach((e=>e.remove()));document.removeAllEventListeners("PPBodyLoaded"),await(async e=>{Array.from(e.head.children).forEach((e=>{const t=e.tagName;if("SCRIPT"===t&&e.hasAttribute(o)){const t=document.createElement("script");Array.from(e.attributes).forEach((e=>t.setAttribute(e.name,e.value))),e.textContent&&(t.textContent=e.textContent),document.head.appendChild(t)}else if("META"===t){if(e.getAttribute("charset")||"viewport"===e.getAttribute("name"))return;const t=e.name,n=e.getAttribute("property"),o=document.head.querySelector(t?`meta[name="${t}"]`:`meta[property="${n}"]`);o?document.head.replaceChild(e.cloneNode(!0),o):document.head.appendChild(e.cloneNode(!0))}else if("TITLE"===t){const t=document.head.querySelector("title");t?document.head.replaceChild(e.cloneNode(!0),t):document.head.appendChild(e.cloneNode(!0))}else if("LINK"===t){const t=t=>{const n=document.head.querySelector('link[rel="icon"]');if(n)document.head.replaceChild(e.cloneNode(!0),n);else{const e=document.createElement("link");e.rel="icon",e.href=t,document.head.appendChild(e)}};if("icon"===e.getAttribute("rel")){t(e.href)}else if(e.hasAttribute(s)){const t=e.cloneNode(!0);document.head.appendChild(t)}}})),await populateDocumentBody(e)})(n),restoreScrollPositions(t),attachWireFunctionEvents(),document.dispatchEvent(new Event("PPBodyLoaded"))}function manageScriptTags(e,t){const n=e.querySelectorAll("script"),o=t?.querySelectorAll("script")||n;n.forEach(((e,t)=>{const n=document.createElement("script"),s=o[t]||e;Array.from(s.attributes).forEach((e=>{n.setAttribute(e.name,e.value)})),s.hasAttribute("src")||(n.textContent=s.textContent),e.parentNode?.replaceChild(n,e)}))}async function populateDocumentBody(e){try{const t=e.body.cloneNode(!0);manageScriptTags(t),document.body.replaceWith(t)}catch(e){}}function saveState(){const e=document.activeElement;stateA129A.focusId=e?.id||e?.name,stateA129A.focusValue=e?.value,stateA129A.focusChecked=e?.checked,stateA129A.focusType=e?.type,stateA129A.focusSelectionStart=e?.selectionStart,stateA129A.focusSelectionEnd=e?.selectionEnd,stateA129A.isSuspense=e.hasAttribute("pp-suspense"),stateA129A.checkedElements.clear(),document.querySelectorAll('input[type="checkbox"]:checked').forEach((e=>{stateA129A.checkedElements.add(e.id||e.name)})),document.querySelectorAll('input[type="radio"]:checked').forEach((e=>{stateA129A.checkedElements.add(e.id||e.name)}))}function restoreState(){if(stateA129A.focusId){const e=document.getElementById(stateA129A.focusId)||document.querySelector(`[name="${stateA129A.focusId}"]`);if(e instanceof HTMLInputElement){const t=e.value.length||0;void 0!==stateA129A.focusSelectionStart&&null!==stateA129A.focusSelectionEnd&&e.setSelectionRange(t,t),stateA129A.focusValue&&("checkbox"===e.type||"radio"===e.type?e.checked=!!stateA129A.focusChecked:"number"===e.type||"email"===e.type?(e.type="text",e.setSelectionRange(t,t),e.type="number"===e.type?"number":"email"):"date"===e.type||"month"===e.type||"week"===e.type||"time"===e.type||"datetime-local"===e.type||"color"===e.type||"file"===e.type||""!==e.value&&(e.value=stateA129A.focusValue)),e.focus()}else if(e instanceof HTMLTextAreaElement){const t=e.value.length||0;void 0!==stateA129A.focusSelectionStart&&null!==stateA129A.focusSelectionEnd&&e.setSelectionRange(t,t),stateA129A.focusValue&&""!==e.value&&(e.value=stateA129A.focusValue),e.focus()}else e instanceof HTMLSelectElement&&(stateA129A.focusValue&&""!==e.value&&(e.value=stateA129A.focusValue),e.focus())}stateA129A.checkedElements.forEach((e=>{const t=document.getElementById(e);t&&(t.checked=!0)}))}function saveScrollPositions(){const e={window:{scrollTop:window.scrollY||document.documentElement.scrollTop,scrollLeft:window.scrollX||document.documentElement.scrollLeft}};return document.querySelectorAll("*").forEach((t=>{(t.scrollTop||t.scrollLeft)&&(e[getElementKey(t)]={scrollTop:t.scrollTop,scrollLeft:t.scrollLeft})})),e}function restoreScrollPositions(e){requestAnimationFrame((()=>{const t=e.window;t&&window.scrollTo(t.scrollLeft,t.scrollTop),document.querySelectorAll("*").forEach((t=>{const n=getElementKey(t);e[n]&&(t.scrollTop=e[n].scrollTop,t.scrollLeft=e[n].scrollLeft)}))}))}function getElementKey(e){return e.id||e.className||e.tagName}async function pphpFetch(e,t){const n=await fetch(e,{...t,headers:{...t?.headers,"X-Requested-With":"XMLHttpRequest"}});return await n.text()}async function pphpFetchFunction(e,t){const n=createFetchOptions({callback:e,...t});return await pphpFetch(window.location.href,n)}async function pphpSync(...e){try{const t=e.length>0?e.map((e=>`pp-sync="${e}"`)):['pp-sync="true"'],n=createFetchOptions({secondRequestC69CD:!0,...getUrlParams()}),o=await pphpFetch(window.location.href,n),s=(new DOMParser).parseFromString(o,"text/html");t.forEach((e=>{const t=document.querySelectorAll(`[${e}]`),n=s.body.querySelectorAll(`[${e}]`);t.forEach(((e,t)=>{const o=n[t];o&&(e.innerHTML=o.innerHTML)}))})),manageScriptTags(document.body,s.body),attachWireFunctionEvents(),document.dispatchEvent(new Event("PPBodyLoaded"))}catch(e){}}function parseCallback(e,t){let n={};const o=e.closest("form");if(o){new FormData(o).forEach(((e,t)=>{n[t]?Array.isArray(n[t])?n[t].push(e):n[t]=[n[t],e]:n[t]=e}))}else e instanceof HTMLInputElement?n=handleInputElement(e):(e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&(n[e.name]=e.value);const s=t.match(/(\w+)\((.*)\)/);if(s){const e=s[1];let t=s[2].trim();if(t.startsWith("{")&&t.endsWith("}"))try{const e=parseJson(t);"object"==typeof e&&null!==e&&(n={...n,...e})}catch(e){}else{const e=t.split(/,(?=(?:[^'"]*['"][^'"]*['"])*[^'"]*$)/).map((e=>e.trim().replace(/^['"]|['"]$/g,"")));n.args=e}return{funcName:e,data:n}}return{funcName:t,data:n}}function handleInputElement(e){let t={};if(e.name)if("checkbox"===e.type)t[e.name]={value:e.value,checked:e.checked};else if("radio"===e.type){const n=document.querySelector(`input[name="${e.name}"]:checked`);t[e.name]=n?n.value:null}else t[e.name]=e.value;else"checkbox"===e.type||"radio"===e.type?t.value=e.checked:t.value=e.value;return t}function updateElementAttributes(e,t){for(const n in t)if(t.hasOwnProperty(n))switch(n){case"innerHTML":case"outerHTML":case"textContent":case"innerText":e[n]=decodeHTML(t[n]);break;case"insertAdjacentHTML":e.insertAdjacentHTML(t.position||"beforeend",decodeHTML(t[n].html));break;case"insertAdjacentText":e.insertAdjacentText(t.position||"beforeend",decodeHTML(t[n].text));break;case"setAttribute":e.setAttribute(t.attrName,decodeHTML(t[n]));break;case"removeAttribute":e.removeAttribute(t[n]);break;case"className":e.className=decodeHTML(t[n]);break;case"classList.add":e.classList.add(...decodeHTML(t[n]).split(","));break;case"classList.remove":e.classList.remove(...decodeHTML(t[n]).split(","));break;case"classList.toggle":e.classList.toggle(decodeHTML(t[n]));break;case"classList.replace":const[o,s]=decodeHTML(t[n]).split(",");e.classList.replace(o,s);break;case"dataset":e.dataset[t.attrName]=decodeHTML(t[n]);break;case"style":Object.assign(e.style,t[n]);break;case"value":e.value=decodeHTML(t[n]);break;case"checked":e.checked=t[n];break;default:e.setAttribute(n,decodeHTML(t[n]))}}function decodeHTML(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}function saveElementOriginalState(e){if(e.hasAttribute("pp-suspense")&&!e.hasAttribute("pp-original-state")){const t={};e.textContent&&(t.textContent=e.textContent.trim()),e.innerHTML&&(t.innerHTML=e.innerHTML.trim()),(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(t.value=e.value);for(let n=0;n<e.attributes.length;n++){const o=e.attributes[n];t[o.name]=o.value}e.setAttribute("pp-original-state",JSON.stringify(t))}if(e instanceof HTMLFormElement){let t=null;const n=e.id;n&&(t=document.querySelector(`[form="${n}"]`)),n&&t||(t=Array.from(e.elements).find((e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement))),t&&(t.hasAttribute("pp-original-state")||saveElementOriginalState(t))}e.querySelectorAll("[pp-suspense]").forEach((e=>saveElementOriginalState(e)))}async function handleSuspenseElement(e){let t=e.getAttribute("pp-suspense")||"";const n=(e,t)=>{for(const n in t)if(t.hasOwnProperty(n))for(const t of e.elements)if(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){const e=t.getAttribute("pp-suspense")||"";if(e)if(isJsonLike(e)){const n=parseJson(e);"disabled"!==n.onsubmit&&updateElementAttributes(t,n),n.targets&&n.targets.forEach((e=>{const{id:t,...n}=e,o=document.querySelector(t);o&&s(o,n)}))}else o(t,e)}},o=(e,t)=>{e instanceof HTMLInputElement?e.value=t:e.textContent=t},s=(e,t)=>{e instanceof HTMLFormElement?n(e,t):updateElementAttributes(e,t)};try{if(t&&isJsonLike(t)){const o=parseJson(t);if(o)if(e instanceof HTMLFormElement){const t=new FormData(e),s={};t.forEach(((e,t)=>{s[t]=e})),o.disabled&&toggleFormElements(e,!0);const{disabled:a,...r}=o;updateElementAttributes(e,r),n(e,s)}else if(o.targets){o.targets.forEach((e=>{const{id:t,...n}=e,o=document.querySelector(t);o&&s(o,n)}));const{targets:t,...n}=o;updateElementAttributes(e,n)}else{if("disabled"===o.empty&&""===e.value)return;const{empty:t,...n}=o;updateElementAttributes(e,n)}}else if(t)o(e,t);else if(e instanceof HTMLFormElement){const t=new FormData(e),o={};t.forEach(((e,t)=>{o[t]=e})),n(e,o)}}catch(e){}}function restoreSuspenseElement(e){const t=e.getAttribute("pp-original-state");if(e.hasAttribute("pp-suspense")&&t){const n=(e,t)=>{for(const n in t)t.hasOwnProperty(n)&&("textContent"===n?e.textContent=t[n]:"innerHTML"===n?e.innerHTML=t[n]:"disabled"===n?!0===t[n]?e.setAttribute("disabled","true"):e.removeAttribute("disabled"):e.setAttribute(n,t[n]));for(const n of Array.from(e.attributes))t.hasOwnProperty(n.name)||e.removeAttribute(n.name)},o=(e,t)=>{for(const o in t)if(t.hasOwnProperty(o))for(const t of Array.from(e.elements))if(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){const e=t.getAttribute("pp-original-state")||"";if(e){if(isJsonLike(e)){const o=parseJson(e);n(t,o)}else s(t,e);t.removeAttribute("pp-original-state")}}},s=(e,t)=>{e instanceof HTMLInputElement?e.value=t:e.textContent=t},a=(e,t)=>{e instanceof HTMLFormElement?o(e,t):n(e,t)};try{const s=parseJson(t);if(s)if(e instanceof HTMLFormElement){const t=e.id;if(t){const e=document.querySelector(`[form="${t}"]`);if(e){const t=e.getAttribute("pp-original-state");if(t&&isJsonLike(t)){const o=parseJson(t);n(e,o)}}}const s=new FormData(e),a={};if(s.forEach(((e,t)=>{a[t]=e})),o(e,a),e.hasAttribute("pp-suspense")){const t=e.getAttribute("pp-suspense")||"";if(parseJson(t).disabled)for(const t of Array.from(e.elements))(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.removeAttribute("disabled")}}else if(s.targets){s.targets.forEach((e=>{const{id:t,...n}=e,o=document.querySelector(t);o&&a(o,n)}));const{targets:t,...o}=s;n(e,o)}else{const{empty:t,...o}=s;n(e,o)}}catch(e){}}e.querySelectorAll("[pp-suspense]").forEach((e=>restoreSuspenseElement(e))),e.removeAttribute("pp-original-state")}function parseJson(e){try{return JSON5.parse(e)}catch(e){return null}}function toggleFormElements(e,t){Array.from(e.elements).forEach((e=>{(e instanceof HTMLInputElement||e instanceof HTMLButtonElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&(e.disabled=t)}))}async function pphpFetchFile(e,t,n){const o=new FormData,s=n.files;if(s)for(let e=0;e<s.length;e++)o.append("file[]",s[e]);o.append("callback",t);const a=await fetch(e,{method:"POST",headers:{HTTP_PPHP_WIRE_REQUEST:"true"},body:o});return await a.text()}function getUrlParams(){const e={};return new URLSearchParams(window.location.search).forEach(((t,n)=>{e[n]=t})),e}async function handleUndefinedFunction(e,t,n){const o=createFetchOptions({callback:t,...n}),s=createFetchOptions({secondRequestC69CD:!0,...getUrlParams()});try{saveElementOriginalState(e),handleSuspenseElement(e);const n=new URL(window.location.href);let a="",r="",i={success:!1};const c=e.querySelector("input[type='file']");if(c){if(a=await pphpFetchFile(n.href,t,c),r=extractJson(a)||"",r)try{i=parseJson(r)}catch(e){}}else if(a=await pphpFetch(n.href,o),r=extractJson(a)||"",r)try{i=parseJson(r)}catch(e){}const l=e.getAttribute("pp-before-request")||"",u=e.getAttribute("pp-after-request")||"";if((l||u&&i.success)&&restoreSuspenseElement(e),l||u){let e="";if(i.success){e=a.replace(r,"")}else e=a;if(appendAfterbegin(e),!u&&!i.success)return}if(u&&i.success){handleAfterRequest(u,r);return appendAfterbegin(a.replace(r,"")),r}if("@close"===u)return i.success?r:void 0;const d=await pphpFetch(n.href,s);await handleResponseRedirectOrUpdate(a,d,r,i)}catch(e){}}function createFetchOptions(e){return{method:"POST",headers:{"Content-Type":"application/json",HTTP_PPHP_WIRE_REQUEST:"true"},body:JSON.stringify(e)}}function getRedirectUrl(e){const t=e.match(redirectRegex3AE99);return t?t[1]:null}function getUpdatedHTMLContent(e,t,n){const o=document.createElement("div");if(o.id="afterbegin-8D95D",n&&t?.success){const t=e.replace(n,"");o.innerHTML=t}else o.innerHTML=e;return o.innerHTML?o:null}async function handleResponseRedirectOrUpdate(e,t,n,o){const s=getRedirectUrl(e);if(s)await handleRedirect(s);else{const s=getUpdatedHTMLContent(e,n,o),a=(new DOMParser).parseFromString(t,"text/html");s&&a.body.insertAdjacentElement("afterbegin",s),updateBodyContent(a.body.outerHTML)}}function appendAfterbegin(e){if(!e)return;const t="afterbegin-8D95D";let n=document.getElementById(t);n?(n.innerHTML=e,document.body.insertAdjacentElement("afterbegin",n)):(n=document.createElement("div"),n.id=t,n.innerHTML=e,document.body.insertAdjacentElement("afterbegin",n))}function extractJson(e){const t=e?.match(/\{[\s\S]*\}/);return t?t[0]:null}function handleAfterRequest(e,t){if(!isJsonLike(e))return;const n=parseJson(e),o=t?parseJson(t):null,s=n.targets;Array.isArray(s)&&s.forEach((e=>{const{id:t,...n}=e,s=document.querySelector(t);let a={};if(o){for(const t in n)if(n.hasOwnProperty(t))switch(t){case"innerHTML":case"outerHTML":case"textContent":case"innerText":"response"===n[t]&&(a[t]=e.responseKey?o[e.responseKey]:o.response);break;default:a[t]=n[t];break}}else a=n;s&&updateElementAttributes(s,a)}))}async function handleRedirect(e){if(e)try{const t=new URL(e,window.location.origin);t.origin!==window.location.origin?window.location.href=e:(history.pushState(null,"",e),await handleNavigation())}catch(e){}}function debounce(e,t=300,n=!1){let o;return function(...s){const a=this;o&&clearTimeout(o),o=setTimeout((()=>{o=null,n||e.apply(a,s)}),t),n&&!o&&e.apply(a,s)}}function copyCode(e,t,n,o,s="img",a=2e3){if(!(e instanceof HTMLElement))return;const r=e.closest(`.${t}`)?.querySelector("pre code"),i=r?.textContent?.trim()||"";i?navigator.clipboard.writeText(i).then((()=>{const t=e.querySelector(s);if(t)for(const[e,n]of Object.entries(o))e in t?t[e]=n:t.setAttribute(e,n);setTimeout((()=>{if(t)for(const[e,o]of Object.entries(n))e in t?t[e]=o:t.setAttribute(e,o)}),a)}),(()=>{alert("Failed to copy command to clipboard")})):alert("Failed to find the code block to copy")}if((e=>{const t=e.pushState,n=e.replaceState;e.pushState=function(n,o,s){const a=t.apply(e,arguments);return window.dispatchEvent(new Event("urlchange")),a},e.replaceState=function(t,o,s){const a=n.apply(e,arguments);return window.dispatchEvent(new Event("urlchange")),a}})(window.history),document.addEventListener("PPBodyLoaded",(()=>{attachWireFunctionEvents(),observeDOMChanges()})),document.addEventListener("DOMContentLoaded",(()=>{document.dispatchEvent(new Event("PPBodyLoaded"))})),window.addEventListener("popstate",(async()=>{await handleNavigation()})),window.addEventListener("urlchange",(()=>{})),null===store){class e{static instance=null;state;listeners;constructor(e={}){this.state=e,this.listeners=[]}static getInstance(t={}){return e.instance||(e.instance=new e(t),e.instance.loadState()),e.instance}setState(e){this.state={...this.state,...e},this.listeners.forEach((e=>e(this.state))),this.saveState()}subscribe(e){return this.listeners.push(e),e(this.state),()=>{this.listeners=this.listeners.filter((t=>t!==e))}}saveState(){localStorage.setItem("appState_59E13",JSON.stringify(this.state))}loadState(){const e=localStorage.getItem("appState_59E13");e&&(this.state=parseJson(e),this.listeners.forEach((e=>e(this.state))))}resetState(e){e?(delete this.state[e],this.saveState()):(this.state={},localStorage.removeItem("appState_59E13")),this.listeners.forEach((e=>e(this.state)))}}store=e.getInstance()}
|
package/package.json
CHANGED
|
@@ -6,26 +6,8 @@ namespace Composer\Autoload;
|
|
|
6
6
|
|
|
7
7
|
class ComposerStaticInit47138f7a82a187607bb66e41f7465a9c
|
|
8
8
|
{
|
|
9
|
-
public static $
|
|
10
|
-
'
|
|
11
|
-
array (
|
|
12
|
-
'Lib\\' => 4,
|
|
13
|
-
),
|
|
14
|
-
'A' =>
|
|
15
|
-
array (
|
|
16
|
-
'App\\' => 4,
|
|
17
|
-
),
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
public static $prefixDirsPsr4 = array (
|
|
21
|
-
'Lib\\' =>
|
|
22
|
-
array (
|
|
23
|
-
0 => __DIR__ . '/../..' . '/src/lib',
|
|
24
|
-
),
|
|
25
|
-
'App\\' =>
|
|
26
|
-
array (
|
|
27
|
-
0 => __DIR__ . '/../..' . '/src/app',
|
|
28
|
-
),
|
|
9
|
+
public static $fallbackDirsPsr4 = array (
|
|
10
|
+
0 => __DIR__ . '/../..' . '/src',
|
|
29
11
|
);
|
|
30
12
|
|
|
31
13
|
public static $classMap = array (
|
|
@@ -35,8 +17,7 @@ class ComposerStaticInit47138f7a82a187607bb66e41f7465a9c
|
|
|
35
17
|
public static function getInitializer(ClassLoader $loader)
|
|
36
18
|
{
|
|
37
19
|
return \Closure::bind(function () use ($loader) {
|
|
38
|
-
$loader->
|
|
39
|
-
$loader->prefixDirsPsr4 = ComposerStaticInit47138f7a82a187607bb66e41f7465a9c::$prefixDirsPsr4;
|
|
20
|
+
$loader->fallbackDirsPsr4 = ComposerStaticInit47138f7a82a187607bb66e41f7465a9c::$fallbackDirsPsr4;
|
|
40
21
|
$loader->classMap = ComposerStaticInit47138f7a82a187607bb66e41f7465a9c::$classMap;
|
|
41
22
|
|
|
42
23
|
}, null, ClassLoader::class);
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
$issues = array();
|
|
6
6
|
|
|
7
|
-
if (!(PHP_VERSION_ID >=
|
|
8
|
-
$issues[] = 'Your Composer dependencies require a PHP version ">=
|
|
7
|
+
if (!(PHP_VERSION_ID >= 80100)) {
|
|
8
|
+
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.';
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
if ($issues) {
|