From 245ff9adb07f80b9f7ef97c6a72fabab1dfc2fe0 Mon Sep 17 00:00:00 2001 From: Brandon Nifong Date: Fri, 8 Jul 2022 09:35:39 -0500 Subject: [PATCH 1/4] fix(bundle): Fix javascript enqueue handle (Fixes #238) chore(bundle): Add missing docblocks --- src/Roots/Acorn/Assets/Bundle.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Roots/Acorn/Assets/Bundle.php b/src/Roots/Acorn/Assets/Bundle.php index 29bf00ec..d9e40b62 100644 --- a/src/Roots/Acorn/Assets/Bundle.php +++ b/src/Roots/Acorn/Assets/Bundle.php @@ -67,12 +67,12 @@ public function css(?callable $callable = null) * * Optionally pass a function to execute on each JS file. * - * @param callable $callable + * @param callable $callable * @return Collection|$this */ public function js(?callable $callable = null) { - $scripts = $this->conditional ? array_merge($this->bundle['js'], $this->bundle['mjs']) : []; + $scripts = $this->conditional ? ($this->bundle['js'] + $this->bundle['mjs']) : []; if (! $callable) { return collect($scripts); @@ -88,7 +88,7 @@ public function js(?callable $callable = null) } /** - * Get depdencies. + * Get the bundle dependencies. * * @return array */ @@ -98,7 +98,7 @@ public function dependencies() } /** - * Get bundle runtime. + * Get the bundle runtime. * * @return string|null */ @@ -125,6 +125,12 @@ public function runtimeSource() return self::$runtimes[$runtime] = file_get_contents("{$this->path}/{$runtime}"); } + /** + * Get the bundle URL. + * + * @param mixed $path + * @return mixed + */ protected function getUrl($path) { if (parse_url($path, PHP_URL_HOST)) { @@ -137,6 +143,11 @@ protected function getUrl($path) return "{$uri}/{$path}"; } + /** + * Set the bundle runtime. + * + * @return void + */ protected function setRuntime() { if (Arr::isAssoc($this->bundle['js'])) { From e232c9479e6427be01d4b2225b501d3b0a0385f7 Mon Sep 17 00:00:00 2001 From: Brandon Nifong Date: Sun, 10 Jul 2022 01:54:41 -0500 Subject: [PATCH 2/4] fix(bundle): Fix out of order bundle array during script inline --- src/Roots/Acorn/Assets/Bundle.php | 2 +- src/Roots/Acorn/Assets/Concerns/Enqueuable.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Roots/Acorn/Assets/Bundle.php b/src/Roots/Acorn/Assets/Bundle.php index d9e40b62..980e8cea 100644 --- a/src/Roots/Acorn/Assets/Bundle.php +++ b/src/Roots/Acorn/Assets/Bundle.php @@ -72,7 +72,7 @@ public function css(?callable $callable = null) */ public function js(?callable $callable = null) { - $scripts = $this->conditional ? ($this->bundle['js'] + $this->bundle['mjs']) : []; + $scripts = $this->conditional ? array_merge($this->bundle['js'], $this->bundle['mjs']) : []; if (! $callable) { return collect($scripts); diff --git a/src/Roots/Acorn/Assets/Concerns/Enqueuable.php b/src/Roots/Acorn/Assets/Concerns/Enqueuable.php index 7f431740..534c88d6 100644 --- a/src/Roots/Acorn/Assets/Concerns/Enqueuable.php +++ b/src/Roots/Acorn/Assets/Concerns/Enqueuable.php @@ -155,7 +155,9 @@ public function inlineRuntime() */ public function inline($contents, $position = 'after') { - if (! $handles = array_keys($this->bundle['js'] ?? [])) { + $bundle = array_merge($this->bundle['js'], $this->bundle['mjs']) ?? []; + + if (! $handles = array_keys($bundle)) { return $this; } From 2506fcc86a987789b8d517bdc3535495d3d23bcf Mon Sep 17 00:00:00 2001 From: Brandon Nifong Date: Sun, 10 Jul 2022 02:02:28 -0500 Subject: [PATCH 3/4] chore(bundle): Fix incorrect docblock return type --- src/Roots/Acorn/Assets/Bundle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Roots/Acorn/Assets/Bundle.php b/src/Roots/Acorn/Assets/Bundle.php index 980e8cea..a0daafe8 100644 --- a/src/Roots/Acorn/Assets/Bundle.php +++ b/src/Roots/Acorn/Assets/Bundle.php @@ -129,7 +129,7 @@ public function runtimeSource() * Get the bundle URL. * * @param mixed $path - * @return mixed + * @return string */ protected function getUrl($path) { From d61671c41a9f7fdb02524073dab619e11c894703 Mon Sep 17 00:00:00 2001 From: Brandon Nifong Date: Sun, 10 Jul 2022 02:03:33 -0500 Subject: [PATCH 4/4] chore(bundle): Fix incorrect docblock param type --- src/Roots/Acorn/Assets/Bundle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Roots/Acorn/Assets/Bundle.php b/src/Roots/Acorn/Assets/Bundle.php index a0daafe8..f893beed 100644 --- a/src/Roots/Acorn/Assets/Bundle.php +++ b/src/Roots/Acorn/Assets/Bundle.php @@ -128,7 +128,7 @@ public function runtimeSource() /** * Get the bundle URL. * - * @param mixed $path + * @param string $path * @return string */ protected function getUrl($path)