Update Kirby to 3.7.4

This commit is contained in:
Lukas Bestle
2022-08-23 21:36:13 +02:00
parent 435b9f4541
commit d89a0a647c
674 changed files with 212 additions and 61 deletions

0
kirby/src/Panel/Dialog.php Executable file → Normal file
View File

4
kirby/src/Panel/Document.php Executable file → Normal file
View File

@@ -72,6 +72,8 @@ class Document
'custom' => static::customAsset('panel.css'),
],
'icons' => static::favicon($url),
// loader for plugins' index.dev.mjs files inlined, so we provide the code instead of the asset URL
'plugin-imports' => $plugins->read('mjs'),
'js' => [
'vendor' => [
'nonce' => $nonce,
@@ -276,7 +278,7 @@ class Document
try {
if (static::link() === true) {
usleep(1);
Response::go($kirby->url('index') . '/' . $kirby->path());
Response::go($kirby->url('base') . '/' . $kirby->path());
}
} catch (Throwable $e) {
die('The Panel assets cannot be installed properly. ' . $e->getMessage());

0
kirby/src/Panel/Dropdown.php Executable file → Normal file
View File

0
kirby/src/Panel/Field.php Executable file → Normal file
View File

0
kirby/src/Panel/File.php Executable file → Normal file
View File

0
kirby/src/Panel/Home.php Executable file → Normal file
View File

0
kirby/src/Panel/Json.php Executable file → Normal file
View File

0
kirby/src/Panel/Model.php Executable file → Normal file
View File

0
kirby/src/Panel/Page.php Executable file → Normal file
View File

0
kirby/src/Panel/Panel.php Executable file → Normal file
View File

62
kirby/src/Panel/Plugins.php Executable file → Normal file
View File

@@ -3,7 +3,9 @@
namespace Kirby\Panel;
use Kirby\Cms\App;
use Kirby\Data\Json;
use Kirby\Filesystem\F;
use Kirby\Toolkit\A;
use Kirby\Toolkit\Str;
/**
@@ -42,6 +44,12 @@ class Plugins
foreach (App::instance()->plugins() as $plugin) {
$this->files[] = $plugin->root() . '/index.css';
$this->files[] = $plugin->root() . '/index.js';
// During plugin development, kirbyup adds an index.dev.mjs as entry point, which
// Kirby will load instead of the regular index.js. Since kirbyup is based on Vite,
// it can't use the standard index.js as entry for its development server:
// Vite requires an entry of type module so it can use JavaScript imports,
// but Kirbyup needs index.js to load as a regular script, synchronously.
$this->files[] = $plugin->root() . '/index.dev.mjs';
}
return $this->files;
@@ -76,20 +84,54 @@ class Plugins
$dist = [];
foreach ($this->files() as $file) {
if (F::extension($file) === $type) {
if ($content = F::read($file)) {
if ($type === 'js') {
$content = trim($content);
// filter out files with a different type
if (F::extension($file) !== $type) {
continue;
}
// make sure that each plugin is ended correctly
if (Str::endsWith($content, ';') === false) {
$content .= ';';
}
}
// filter out empty files and files that don't exist
$content = F::read($file);
if (!$content) {
continue;
}
$dist[] = $content;
if ($type === 'mjs') {
// index.dev.mjs files are turned into data URIs so they
// can be imported without having to copy them to /media
// (avoids having to clean the files from /media again)
$content = F::uri($file);
}
if ($type === 'js') {
// filter out all index.js files that shouldn't be loaded
// because an index.dev.mjs exists
if (F::exists(preg_replace('/\.js$/', '.dev.mjs', $file)) === true) {
continue;
}
$content = trim($content);
// make sure that each plugin is ended correctly
if (Str::endsWith($content, ';') === false) {
$content .= ';';
}
}
$dist[] = $content;
}
if ($type === 'mjs') {
// if no index.dev.mjs modules exist, we MUST return an empty string instead
// of loading an empty array; this is because the module loader code uses
// top level await, which is not compatible with Kirby's minimum browser
// version requirements and therefore must not appear in a default setup
if (empty($dist)) {
return '';
}
$modules = Json::encode($dist);
$modulePromise = "Promise.all($modules.map(url => import(url)))";
return "try { await $modulePromise } catch (e) { console.error(e) }" . PHP_EOL;
}
return implode(PHP_EOL . PHP_EOL, $dist);

0
kirby/src/Panel/Redirect.php Executable file → Normal file
View File

0
kirby/src/Panel/Search.php Executable file → Normal file
View File

0
kirby/src/Panel/Site.php Executable file → Normal file
View File

0
kirby/src/Panel/User.php Executable file → Normal file
View File

0
kirby/src/Panel/View.php Executable file → Normal file
View File