diff --git a/resources/js/polyfills.ts b/resources/js/polyfills.ts new file mode 100644 index 000000000..8c976c1b8 --- /dev/null +++ b/resources/js/polyfills.ts @@ -0,0 +1,16 @@ + +if(!window.crypto) { + // @ts-ignore + window.crypto = {}; +} + +// polyfill for non-HTTPS environment (e.g. local dev). tiptap-footnotes uses it. +if (!window.crypto.randomUUID) { + window.crypto.randomUUID = function () { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + const r = Math.random() * 16 | 0; + const v = c === 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + }) as `${string}-${string}-${string}-${string}-${string}`; + }; +} diff --git a/resources/js/sharp.ts b/resources/js/sharp.ts index a57232811..f3e036775 100644 --- a/resources/js/sharp.ts +++ b/resources/js/sharp.ts @@ -1,6 +1,7 @@ import '../css/vendors.css'; import '../css/app.css'; +import './polyfills'; import { createApp, DefineComponent, h, nextTick } from 'vue'; import { createInertiaApp } from '@inertiajs/vue3'; import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';