Skip to content

Commit

Permalink
Merge pull request #1498 from privy-open-source/feat/pspdfkit-selfhost
Browse files Browse the repository at this point in the history
feat(pspdfkit): add selfhost worker
  • Loading branch information
adenvt authored Oct 22, 2024
2 parents 08333f4 + f518002 commit ff8321c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:
pull-requests: write

env:
NODE_VERSION: 18
NODE_VERSION: 20

jobs:
sync:
Expand Down
1 change: 1 addition & 0 deletions packages/persona/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"nanodelay": "2.0.2",
"pathe": "^1.1.2",
"pdfjs-dist": "4.7.76",
"pspdfkit": "^2024.6.0",
"scroll-into-view": "1.16.2",
"tabbable": "6.2.0",
"tiptap-extension-font-size": "^1.2.0",
Expand Down
15 changes: 13 additions & 2 deletions packages/persona/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { join as joinPath } from 'pathe'
import { defu } from 'defu'
import { joinURL } from 'ufo'
import { version as PDFJS_VERSION } from 'pdfjs-dist/legacy/build/pdf.mjs'
import { version as PSPDFKIT_VERSION } from 'pspdfkit/package.json'

export interface ModuleOptions {
/**
Expand Down Expand Up @@ -99,13 +100,18 @@ export default defineNuxtModule<ModuleOptions>({
// eslint-disable-next-line align-assignments/align-assignments
nitroConfig.publicAssets ||= []

const baseURL = '_persona'
const pdfjsDir = joinPath(await resolvePath('pdfjs-dist'), '../../')
const pdfjsBaseURL = `_persona/pdfjs-dist@${PDFJS_VERSION}`
const pdfjsBaseURL = joinURL(baseURL, `pdfjs-dist@${PDFJS_VERSION}`)

const pspdfDir = joinPath(await resolvePath('pspdfkit'), '../../')
const pspdfBaseURL = joinURL(baseURL, `pspdfkit@${PSPDFKIT_VERSION}`)

const assetsMaxAge = 60 * 60 * 24 * 30 // 1 month

nitroConfig.publicAssets.push(
{
baseURL: joinURL(pdfjsDir, 'build'),
baseURL: joinURL(pdfjsBaseURL, 'build'),
dir : joinPath(pdfjsDir, 'build'),
maxAge : assetsMaxAge,
},
Expand All @@ -119,6 +125,11 @@ export default defineNuxtModule<ModuleOptions>({
dir : joinPath(pdfjsDir, 'cmaps'),
maxAge : assetsMaxAge,
},
{
baseURL: joinURL(pspdfBaseURL, 'dist'),
dir : joinPath(pspdfDir, 'dist'),
maxAge : assetsMaxAge,
},
)
})
}
Expand Down
53 changes: 14 additions & 39 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3984,6 +3984,7 @@ __metadata:
postcss-custom-properties: "npm:14.0.1"
postcss-hexrgba: "npm:2.1.0"
postcss-lighten-darken: "npm:0.9.0"
pspdfkit: "npm:^2024.6.0"
scroll-into-view: "npm:1.16.2"
tabbable: "npm:6.2.0"
tailwind: "npm:4.0.0"
Expand Down Expand Up @@ -8018,45 +8019,10 @@ __metadata:
languageName: node
linkType: hard

"caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30001370":
version: 1.0.30001538
resolution: "caniuse-lite@npm:1.0.30001538"
checksum: 10/c37f3cc5f8f6a1beff714c641a437f9f2593fe319aec1848ccbbbba4a7cc875886fc07f903a490254bba7d294a8aaa2ee0fc87a71b8d61de35fafb7514a194ef
languageName: node
linkType: hard

"caniuse-lite@npm:^1.0.30001565":
version: 1.0.30001568
resolution: "caniuse-lite@npm:1.0.30001568"
checksum: 10/27aa9697e8fccf61702962a3cc48ec2355940e94872e4f0dab108d8a88adb0250e5b96572bef08b90a67a8183d1c704448b2fc69d600d7b6405b3f74dc5dbcb6
languageName: node
linkType: hard

"caniuse-lite@npm:^1.0.30001587":
version: 1.0.30001593
resolution: "caniuse-lite@npm:1.0.30001593"
checksum: 10/c179af389ca40b254939308099b9e8681d1ca1ad535e48a3e3035880e97fe2cca147e3481ca821112c11a8cde534d090daf5a3b072d73db9e9360c136bf84e55
languageName: node
linkType: hard

"caniuse-lite@npm:^1.0.30001599":
version: 1.0.30001599
resolution: "caniuse-lite@npm:1.0.30001599"
checksum: 10/c9a5ad806fc0d446e4f995d551b840d8fdcbe97958b7f83ff7a255a8ef5e40ca12ca1a508c66b3ab147e19eef932d28772d205c046500dd0740ea9dfb602e2e1
languageName: node
linkType: hard

"caniuse-lite@npm:^1.0.30001640":
version: 1.0.30001643
resolution: "caniuse-lite@npm:1.0.30001643"
checksum: 10/dddbda29fa24fbc435873309c71070461cbfc915d9bce3216180524c20c5637b2bee1a14b45972e9ac19e1fdf63fba3f63608b9e7d68de32f5ee1953c8c69e05
languageName: node
linkType: hard

"caniuse-lite@npm:^1.0.30001646":
version: 1.0.30001646
resolution: "caniuse-lite@npm:1.0.30001646"
checksum: 10/6c66a5677b58988c2ee86905b05705b00be552a3e4f768bd0d9a10098cc4ec471de5b204e2c2ab534f34b5f216c059321a9e5cb1395928cf29ded0a4aae4535f
"caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30001370, caniuse-lite@npm:^1.0.30001565, caniuse-lite@npm:^1.0.30001587, caniuse-lite@npm:^1.0.30001599, caniuse-lite@npm:^1.0.30001640, caniuse-lite@npm:^1.0.30001646":
version: 1.0.30001669
resolution: "caniuse-lite@npm:1.0.30001669"
checksum: 10/cd0b481bb997703cb7651e55666b4aa4e7b4ecf9784796e2393179a15e55c71a6abc6ff865c922bbd3bbfa4a4bf0530d8da13989b97ff8c7850c8a5bd4e00491
languageName: node
linkType: hard

Expand Down Expand Up @@ -17233,6 +17199,15 @@ __metadata:
languageName: node
linkType: hard

"pspdfkit@npm:^2024.6.0":
version: 2024.6.0
resolution: "pspdfkit@npm:2024.6.0"
dependencies:
"@types/react": "npm:^17.0.39"
checksum: 10/41e0bbcb2727ba3010e1b6bd97a1abccc5bfdf6477f0aafc7032a2c074e654e02299baa84d12e2e4507678a7329897468af7e08b073dc46ccc4eae11505ad7be
languageName: node
linkType: hard

"punycode.js@npm:^2.3.1":
version: 2.3.1
resolution: "punycode.js@npm:2.3.1"
Expand Down

0 comments on commit ff8321c

Please sign in to comment.