From 4d1199f18aaf2c5141afcd4cbf845a92dc329cfb Mon Sep 17 00:00:00 2001 From: kiosion Date: Wed, 14 Feb 2024 16:42:05 -0500 Subject: [PATCH] fix: Patch portabletext, svelte-highlight --- svelte-app/package.json | 8 +- .../patches/@portabletext__svelte@2.1.5.patch | 129 +++++++++ .../patches/svelte-highlight@7.6.0.patch | 273 ++++++++++++++++++ svelte-app/pnpm-lock.yaml | 18 +- svelte-app/src/components/code-block.svelte | 14 +- .../serializers/code-block.svelte | 13 +- .../serializers/custom-code.svelte | 12 +- .../serializers/custom-heading.svelte | 13 +- .../serializers/custom-highlight.svelte | 10 +- .../serializers/custom-link.svelte | 10 +- .../serializers/custom-paragraph.svelte | 10 +- .../portable-text/serializers/image.svelte | 14 +- .../serializers/list-item.svelte | 10 +- .../serializers/null-mark.svelte | 10 +- .../portable-text/serializers/ol-item.svelte | 10 +- .../serializers/ol-wrapper.svelte | 10 +- .../serializers/ul-wrapper.svelte | 10 +- svelte-app/src/components/tooltip.svelte | 106 +++---- .../routes/[[lang=lang]]/blog/+page.svelte | 2 +- 19 files changed, 588 insertions(+), 94 deletions(-) create mode 100644 svelte-app/patches/@portabletext__svelte@2.1.5.patch create mode 100644 svelte-app/patches/svelte-highlight@7.6.0.patch diff --git a/svelte-app/package.json b/svelte-app/package.json index bc0629125..19aca65ed 100644 --- a/svelte-app/package.json +++ b/svelte-app/package.json @@ -67,5 +67,11 @@ "resolutions": { "svelte": "5.0.0-next.51" }, - "type": "module" + "type": "module", + "pnpm": { + "patchedDependencies": { + "@portabletext/svelte@2.1.5": "patches/@portabletext__svelte@2.1.5.patch", + "svelte-highlight@7.6.0": "patches/svelte-highlight@7.6.0.patch" + } + } } diff --git a/svelte-app/patches/@portabletext__svelte@2.1.5.patch b/svelte-app/patches/@portabletext__svelte@2.1.5.patch new file mode 100644 index 000000000..6303c8198 --- /dev/null +++ b/svelte-app/patches/@portabletext__svelte@2.1.5.patch @@ -0,0 +1,129 @@ +diff --git a/dist/PortableText.svelte b/dist/PortableText.svelte +index 0859389183d8d84889b90255ba3d59d35c9f8b8f..d51cae17ceb7591c25c2d20bc5d3d3d12b3bd3f4 100644 +--- a/dist/PortableText.svelte ++++ b/dist/PortableText.svelte +@@ -1,3 +1,4 @@ ++ + +diff --git a/dist/defaultComponents/UnknownType.svelte b/dist/defaultComponents/UnknownType.svelte +index 4fa864ce7aa9d8b620269649779b40fda753c36f..22634eb158cb10c3b74d2d1c29fa6dac0d54dc6d 100644 +--- a/dist/defaultComponents/UnknownType.svelte ++++ b/dist/defaultComponents/UnknownType.svelte +@@ -1 +1,2 @@ ++ + +diff --git a/dist/renderers/RenderBlock.svelte b/dist/renderers/RenderBlock.svelte +index 9a49ca1766f60af123b1d82846b38a9a7f9277c5..9f16ce8ee78788fc45f8b082cb8dcbf2f0a11e73 100644 +--- a/dist/renderers/RenderBlock.svelte ++++ b/dist/renderers/RenderBlock.svelte +@@ -1,3 +1,4 @@ ++ + + + + + + + + + + + + + + +-
{#if highlighted}{@html highlighted}{:else}{code}{/if}
+diff --git a/LineNumbers.svelte b/LineNumbers.svelte +index 704976d98f45c0a472355927aed541adc0934806..a43ce7f24b77edb95611d7c71f973b91a9d39b21 100644 +--- a/LineNumbers.svelte ++++ b/LineNumbers.svelte +@@ -1,32 +1,41 @@ ++ + + +-
++
+ + + {#each lines as line, i} diff --git a/svelte-app/pnpm-lock.yaml b/svelte-app/pnpm-lock.yaml index d2112f5e2..15b182b5e 100644 --- a/svelte-app/pnpm-lock.yaml +++ b/svelte-app/pnpm-lock.yaml @@ -7,13 +7,21 @@ settings: overrides: svelte: 5.0.0-next.51 +patchedDependencies: + '@portabletext/svelte@2.1.5': + hash: d55qls7dpjc43722a7i42rbfcq + path: patches/@portabletext__svelte@2.1.5.patch + svelte-highlight@7.6.0: + hash: laj6iln5v7g2a6rps4ze5fqq4e + path: patches/svelte-highlight@7.6.0.patch + devDependencies: '@playwright/test': specifier: 1.41.2 version: 1.41.2 '@portabletext/svelte': specifier: 2.1.5 - version: 2.1.5(svelte@5.0.0-next.51) + version: 2.1.5(patch_hash=d55qls7dpjc43722a7i42rbfcq)(svelte@5.0.0-next.51) '@portabletext/types': specifier: 2.0.8 version: 2.0.8 @@ -112,7 +120,7 @@ devDependencies: version: 0.33.1(svelte@5.0.0-next.51) svelte-highlight: specifier: 7.6.0 - version: 7.6.0 + version: 7.6.0(patch_hash=laj6iln5v7g2a6rps4ze5fqq4e) tailwindcss: specifier: 3.4.1 version: 3.4.1 @@ -1451,7 +1459,7 @@ packages: resolution: {integrity: sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==} dev: true - /@portabletext/svelte@2.1.5(svelte@5.0.0-next.51): + /@portabletext/svelte@2.1.5(patch_hash=d55qls7dpjc43722a7i42rbfcq)(svelte@5.0.0-next.51): resolution: {integrity: sha512-NDHIT6TRPnWCGnr0VjwsmYtuhZRVkD41aexajtElwsVLSoYUf/mxXd6PVxjg1e12DfubQo4aQv6lpRthIVbIIA==} peerDependencies: svelte: 5.0.0-next.51 @@ -1459,6 +1467,7 @@ packages: '@portabletext/toolkit': 2.0.10 svelte: 5.0.0-next.51 dev: true + patched: true /@portabletext/toolkit@2.0.10: resolution: {integrity: sha512-d+F9JvpnMEx7kd6saZ9OWA4U1Iwuokh6TOht7iqkfWU+0ivh9yM4v+b0Kpu+iiPcElicoabhtXol+yTvWJ1jDw==} @@ -9566,11 +9575,12 @@ packages: svelte: 5.0.0-next.51 dev: true - /svelte-highlight@7.6.0: + /svelte-highlight@7.6.0(patch_hash=laj6iln5v7g2a6rps4ze5fqq4e): resolution: {integrity: sha512-J9X1d07iMIKZMAqNAhlkjLX/FS+7R2lPrqVul7i+EleVZIOYvBhtx7ES62bc661a70nKNOS05yr9JAvyQPPOIA==} dependencies: highlight.js: 11.9.0 dev: true + patched: true /svelte-hmr@0.15.3(svelte@5.0.0-next.51): resolution: {integrity: sha512-41snaPswvSf8TJUhlkoJBekRrABDXDMdpNpT2tfHIv4JuhgvHqLMhEPGtaQn0BmbNSTkuz2Ed20DF2eHw0SmBQ==} diff --git a/svelte-app/src/components/code-block.svelte b/svelte-app/src/components/code-block.svelte index 0f36dd3a6..4cef43c2e 100644 --- a/svelte-app/src/components/code-block.svelte +++ b/svelte-app/src/components/code-block.svelte @@ -13,14 +13,16 @@ import type { ResolvedComponentType } from '$components/code-block/imports'; import type { Unsubscriber } from 'svelte/store'; - import type { LanguageType as _LanguageType } from 'svelte-highlight/languages'; export let content: string, filename: string | undefined, showLineNumbers = true, lang: string | undefined; - let LanguageType: Promise<_LanguageType>, + let LanguageType: Promise<{ + name: string; + register: (hljsApi: any) => any; + }>, HighlightSvelte: Promise | undefined>, LineNumbers: Promise | undefined>, Highlight: Promise | undefined>, @@ -52,14 +54,14 @@ LineNumbers = showLineNumbers ? genericAsyncImport('LineNumbers').then((res) => - res instanceof Error ? ((loadError = res), undefined) : res + res instanceof Error ? ((loadError = res), undefined) : res ) : Promise.resolve(undefined); HighlightSvelte = lang === 'svelte' ? genericAsyncImport('HighlightSvelte').then((res) => res instanceof Error ? ((loadError = res), undefined) : res - ) + ) : Promise.resolve(undefined); Highlight = genericAsyncImport('Highlight').then((res) => res instanceof Error ? ((loadError = res), undefined) : res @@ -148,14 +150,14 @@ language={resolvedLang} let:highlighted > - {#if showLineNumbers === true} + {:catch error}
Error loading: {error.message}
diff --git a/svelte-app/src/components/portable-text/serializers/code-block.svelte b/svelte-app/src/components/portable-text/serializers/code-block.svelte index b8277002e..2c3b14cae 100644 --- a/svelte-app/src/components/portable-text/serializers/code-block.svelte +++ b/svelte-app/src/components/portable-text/serializers/code-block.svelte @@ -1,12 +1,19 @@ + diff --git a/svelte-app/src/components/portable-text/serializers/custom-code.svelte b/svelte-app/src/components/portable-text/serializers/custom-code.svelte index e3df433c7..8a74cf128 100644 --- a/svelte-app/src/components/portable-text/serializers/custom-code.svelte +++ b/svelte-app/src/components/portable-text/serializers/custom-code.svelte @@ -1,10 +1,16 @@ + {#if markType === 'code'} diff --git a/svelte-app/src/components/portable-text/serializers/custom-heading.svelte b/svelte-app/src/components/portable-text/serializers/custom-heading.svelte index 1365799be..fb5d0e32a 100644 --- a/svelte-app/src/components/portable-text/serializers/custom-heading.svelte +++ b/svelte-app/src/components/portable-text/serializers/custom-heading.svelte @@ -1,12 +1,19 @@ + diff --git a/svelte-app/src/components/portable-text/serializers/custom-link.svelte b/svelte-app/src/components/portable-text/serializers/custom-link.svelte index 31b956199..93d659f22 100644 --- a/svelte-app/src/components/portable-text/serializers/custom-link.svelte +++ b/svelte-app/src/components/portable-text/serializers/custom-link.svelte @@ -1,11 +1,17 @@ + {plainTextContent} diff --git a/svelte-app/src/components/portable-text/serializers/custom-paragraph.svelte b/svelte-app/src/components/portable-text/serializers/custom-paragraph.svelte index 328f49e03..385722a9f 100644 --- a/svelte-app/src/components/portable-text/serializers/custom-paragraph.svelte +++ b/svelte-app/src/components/portable-text/serializers/custom-paragraph.svelte @@ -1,9 +1,15 @@ +

diff --git a/svelte-app/src/components/portable-text/serializers/image.svelte b/svelte-app/src/components/portable-text/serializers/image.svelte index 5b5d08737..162fe3847 100644 --- a/svelte-app/src/components/portable-text/serializers/image.svelte +++ b/svelte-app/src/components/portable-text/serializers/image.svelte @@ -1,14 +1,20 @@ + diff --git a/svelte-app/src/components/portable-text/serializers/list-item.svelte b/svelte-app/src/components/portable-text/serializers/list-item.svelte index 7fcf1dadd..5606480eb 100644 --- a/svelte-app/src/components/portable-text/serializers/list-item.svelte +++ b/svelte-app/src/components/portable-text/serializers/list-item.svelte @@ -1,9 +1,15 @@ +
  • diff --git a/svelte-app/src/components/portable-text/serializers/null-mark.svelte b/svelte-app/src/components/portable-text/serializers/null-mark.svelte index 4c802f12d..c49379943 100644 --- a/svelte-app/src/components/portable-text/serializers/null-mark.svelte +++ b/svelte-app/src/components/portable-text/serializers/null-mark.svelte @@ -1,9 +1,15 @@ + diff --git a/svelte-app/src/components/portable-text/serializers/ol-item.svelte b/svelte-app/src/components/portable-text/serializers/ol-item.svelte index 7fcf1dadd..5606480eb 100644 --- a/svelte-app/src/components/portable-text/serializers/ol-item.svelte +++ b/svelte-app/src/components/portable-text/serializers/ol-item.svelte @@ -1,9 +1,15 @@ +
  • diff --git a/svelte-app/src/components/portable-text/serializers/ol-wrapper.svelte b/svelte-app/src/components/portable-text/serializers/ol-wrapper.svelte index 108b47508..1743ae9cb 100644 --- a/svelte-app/src/components/portable-text/serializers/ol-wrapper.svelte +++ b/svelte-app/src/components/portable-text/serializers/ol-wrapper.svelte @@ -1,9 +1,15 @@ +
    diff --git a/svelte-app/src/components/portable-text/serializers/ul-wrapper.svelte b/svelte-app/src/components/portable-text/serializers/ul-wrapper.svelte index ea3601b3a..894a6859c 100644 --- a/svelte-app/src/components/portable-text/serializers/ul-wrapper.svelte +++ b/svelte-app/src/components/portable-text/serializers/ul-wrapper.svelte @@ -1,9 +1,15 @@ +
    diff --git a/svelte-app/src/components/tooltip.svelte b/svelte-app/src/components/tooltip.svelte index 1d6aad287..75a2d379a 100644 --- a/svelte-app/src/components/tooltip.svelte +++ b/svelte-app/src/components/tooltip.svelte @@ -17,64 +17,64 @@ let container: HTMLSpanElement, instance: Instance; - onMount(() => { - let target = container?.firstChild as HTMLElement | null; + // onMount(() => { + // let target = container?.firstChild as HTMLElement | null; - if ( - target instanceof Element && - window?.getComputedStyle(target).display === 'contents' - ) { - target = target?.firstChild as HTMLElement | null; - } + // if ( + // target instanceof Element && + // window?.getComputedStyle(target).display === 'contents' + // ) { + // target = target?.firstChild as HTMLElement | null; + // } - if (target) { - if (!disable) { - instance = tippy(target, { - content: createContent(text), - allowHTML: true, - duration: transitionDuration, - delay: [delay, 0], - touch: ['hold', 500], - offset: fixed ? offset : [6, 24], - animation: 'fade', - placement: position, - followCursor: !fixed, - plugins: [followCursor] - }); - } - } else { - Logger.error('Tooltip target not found!'); - } - }); + // if (target) { + // if (!disable) { + // instance = tippy(target, { + // content: createContent(text), + // allowHTML: true, + // duration: transitionDuration, + // delay: [delay, 0], + // touch: ['hold', 500], + // offset: fixed ? offset : [6, 24], + // animation: 'fade', + // placement: position, + // followCursor: !fixed, + // plugins: [followCursor] + // }); + // } + // } else { + // Logger.error('Tooltip target not found!'); + // } + // }); - onDestroy(() => instance?.destroy?.()); + // onDestroy(() => instance?.destroy?.()); - const createContent = (content: string) => { - const div = document.createElement('div'); - div.innerText = content; - div.classList.add( - 'tooltip', - 'rounded-sm', - 'py-1', - 'px-2', - 'bg-black', - 'text-light', - 'dark:bg-light', - 'dark:text-dark', - 'font-code', - 'text-sm' - ); - return div; - }; + // const createContent = (content: string) => { + // const div = document.createElement('div'); + // div.innerText = content; + // div.classList.add( + // 'tooltip', + // 'rounded-sm', + // 'py-1', + // 'px-2', + // 'bg-black', + // 'text-light', + // 'dark:bg-light', + // 'dark:text-dark', + // 'font-code', + // 'text-sm' + // ); + // return div; + // }; - $: if (text !== (instance?.props.content as Element | undefined)?.textContent) { - instance?.setContent(createContent(text)); - } - $: if (!disable) { - instance?.enable(); - } else { - instance?.disable(); - } + // $: if (text !== (instance?.props.content as Element | undefined)?.textContent) { + // instance?.setContent(createContent(text)); + // } + // $: if (!disable) { + // instance?.enable(); + // } else { + // instance?.disable(); + // } diff --git a/svelte-app/src/routes/[[lang=lang]]/blog/+page.svelte b/svelte-app/src/routes/[[lang=lang]]/blog/+page.svelte index c0eea9e60..265b2b435 100644 --- a/svelte-app/src/routes/[[lang=lang]]/blog/+page.svelte +++ b/svelte-app/src/routes/[[lang=lang]]/blog/+page.svelte @@ -25,7 +25,7 @@ - {#if data.posts.length} + {#if data.posts?.length} {:else}