-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
580 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"version":1,"defects":[],"times":{"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testRenderTagBasic":1.815}} | ||
{"version":1,"defects":{"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testRenderTag":3,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateTagWithCustomAttributes":3,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateTagWithCustomAttributes with data set #0":3,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateTagWithCustomAttributes with data set #5":3,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateScript with data set #0":3,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateScript with data set #1":3,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateLinkStylesheet with data set #0":3,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateLinkStylesheet with data set #1":3,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testSpecialTag":3,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateLinkPreload with data set #0":3,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateLinkPreload with data set #1":3},"times":{"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testRenderTagBasic":2.477,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testRenderTagBasic1":0,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testRenderTag":0.004,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateTagWithCustomAttributes":0.004,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateTagWithCustomAttributes with data set #0":0.003,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateTagWithCustomAttributes with data set #1":0,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateTagWithCustomAttributes with data set #2":0,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateTagWithCustomAttributes with data set #3":0,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateTagWithCustomAttributes with data set #4":0,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateTagWithCustomAttributes with data set #5":0,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateTagWithGlobalAttributes with data set #0":0,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateScript with data set #0":0,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateScript with data set #1":0,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateScript with data set #2":0,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateLinkStylesheet with data set #0":0,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateLinkStylesheet with data set #1":0,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testSpecialTag":0,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateLinkPreload with data set #0":0,"Pentatrion\\ViteBundle\\Tests\\Asset\\TagRendererTest::testGenerateLinkPreload with data set #1":0}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace Pentatrion\ViteBundle\Asset; | ||
|
||
class InlineContent | ||
{ | ||
/* Safari 10.1 supports modules, but does not support the `nomodule` attribute | ||
* it will load <script nomodule> anyway | ||
* https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc | ||
*/ | ||
public const SAFARI10_NO_MODULE_FIX_INLINE_CODE = '!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();'; | ||
|
||
/* set or not the __vite_is_modern_browser variable */ | ||
public const DETECT_MODERN_BROWSER_INLINE_CODE = 'try{import.meta.url;import("_").catch(()=>1);}catch(e){}window.__vite_is_modern_browser=true;'; | ||
|
||
/* if your browser understands the modules but not dynamic import, | ||
* load the legacy entrypoints | ||
* | ||
* load the <script nomodule crossorigin id="vite-legacy-polyfill" src="..."></script> | ||
* and the <script nomodule crossorigin id="vite-legacy-entry" data-src="..."></script> | ||
* if browser accept modules but don't dynamic import or import.meta | ||
*/ | ||
public const DYNAMIC_FALLBACK_INLINE_CODE = <<<INLINE | ||
\n (function() { | ||
if (window.__vite_is_modern_browser) return; | ||
console.warn("vite: loading legacy build because dynamic import or import.meta.url is unsupported, syntax error above should be ignored"); | ||
var legacyPolyfill = document.getElementById("vite-legacy-polyfill") | ||
var script = document.createElement("script"); | ||
script.src = legacyPolyfill.src; | ||
script.onload = function() { | ||
document.querySelectorAll("script.vite-legacy-entry").forEach(function(elt) { | ||
System.import(elt.getAttribute("data-src")); | ||
}); | ||
}; | ||
document.body.appendChild(script); | ||
})();\n | ||
INLINE; | ||
|
||
public static function getSystemJSInlineCode($id): string | ||
{ | ||
$content = 'System.import(document.getElementById("__ID__").getAttribute("data-src"))'; | ||
|
||
return str_replace('__ID__', $id, $content); | ||
} | ||
|
||
public static function getReactRefreshInlineCode(string $devServerUrl) | ||
{ | ||
return <<<INLINE | ||
\n import RefreshRuntime from "$devServerUrl@react-refresh" | ||
RefreshRuntime.injectIntoGlobalHook(window) | ||
window.\$RefreshReg$ = () => {} | ||
window.\$RefreshSig$ = () => (type) => type | ||
window.__vite_plugin_react_preamble_installed__ = true\n | ||
INLINE; | ||
} | ||
} |
Oops, something went wrong.