Skip to content

Commit a7ea2b8

Browse files
authored
Merge pull request #31 from LibreSign/chore/vue3-vite-refactor
chore: vue3 vite refactor
2 parents 780d9ae + 2679087 commit a7ea2b8

45 files changed

Lines changed: 2003 additions & 365 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,23 @@ module.exports = {
1111
extends: [
1212
'plugin:vue/essential',
1313
'eslint:recommended',
14+
'plugin:@typescript-eslint/recommended',
1415
],
1516
parserOptions: {
16-
parser: '@babel/eslint-parser',
17-
requireConfigFile: false,
17+
parser: '@typescript-eslint/parser',
18+
ecmaVersion: 2021,
19+
sourceType: 'module',
1820
},
21+
parser: 'vue-eslint-parser',
22+
overrides: [
23+
{
24+
files: ['tests/**/*.ts'],
25+
env: {
26+
'vitest/globals': true,
27+
},
28+
plugins: ['vitest'],
29+
},
30+
],
1931
rules: {
2032
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
2133
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',

.github/workflows/node.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
run: npm run lint
5353

5454
- name: Build library
55-
run: npm run build:lib
55+
run: npm run build
5656

5757
- name: Check build changes
5858
run: |

.github/workflows/npm-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
CYPRESS_INSTALL_BINARY: 0
4848
run: |
4949
npm i
50-
npm run build:lib
50+
npm run build
5151
5252
- name: Publish to npm
5353
run: npm publish --provenance --access public

.github/workflows/pages.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
22
# SPDX-License-Identifier: AGPL-3.0-or-later
33

4-
name: Deploy A DEMO
4+
name: Deploy Demo
55

66
on:
77
workflow_dispatch:
@@ -16,17 +16,28 @@ jobs:
1616
- name: Checkout repository
1717
uses: actions/checkout@v4
1818

19-
- name: Set up Node.js
19+
- name: Read package.json node and npm engines version
20+
uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
21+
id: versions
22+
with:
23+
fallbackNode: '^20'
24+
fallbackNpm: '^10'
25+
26+
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
2027
uses: actions/setup-node@v4
28+
with:
29+
node-version: ${{ steps.versions.outputs.nodeVersion }}
30+
31+
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
32+
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
2133

2234
- name: Install & Build
2335
run: |
2436
npm i
25-
npm install -g cross-env
26-
cross-env PUBLIC_PATH=/pdf-elements/ npm run build
37+
npm run build:demo
2738
2839
- name: Deploy
2940
uses: JamesIves/github-pages-deploy-action@v4
3041
with:
3142
branch: gh-pages
32-
folder: dist
43+
folder: dist-demo

.github/workflows/tests.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
name: Tests
5+
6+
on:
7+
pull_request:
8+
push:
9+
branches:
10+
- main
11+
12+
permissions:
13+
contents: read
14+
15+
concurrency:
16+
group: tests-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
test:
21+
runs-on: ubuntu-latest
22+
23+
name: NPM test
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
with:
28+
persist-credentials: false
29+
30+
- name: Read package.json node and npm engines version
31+
uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
32+
id: versions
33+
with:
34+
fallbackNode: '^20'
35+
fallbackNpm: '^10'
36+
37+
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: ${{ steps.versions.outputs.nodeVersion }}
41+
42+
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
43+
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
44+
45+
- name: Install dependencies
46+
env:
47+
CYPRESS_INSTALL_BINARY: 0
48+
PUPPETEER_SKIP_DOWNLOAD: true
49+
run: npm i
50+
51+
- name: Test
52+
run: npm run test

.npmignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
# Source files
55
src/
66
examples/
7+
tests/
78

89
# Config files
910
.babelrc
1011
.eslintrc.js
11-
vue.config.js
12+
env.d.ts
1213
postcss.config.js
14+
tsconfig.json
15+
vite.config.ts
16+
vitest.config.ts
1317
REUSE.toml
1418
LICENSES/
1519
CONTRIBUTING.md

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ SPDX-License-Identifier: AGPL-3.0-or-later
55

66
# PDF Elements
77

8-
A Vue 2 component for rendering PDFs with draggable and resizable element overlays.
8+
A Vue 3 component for rendering PDFs with draggable and resizable element overlays.
99

1010
**[Demo](https://libresign.github.io/pdf-elements/)** · [Examples](examples/)
1111

12+
## Development
13+
14+
- `npm run dev` - Run the demo with Vite
15+
- `npm run build` - Build the library (ESM + types)
16+
- `npm run build:demo` - Build the demo to `dist-demo`
17+
1218
## API
1319

1420
### Props
@@ -28,6 +34,23 @@ A Vue 2 component for rendering PDFs with draggable and resizable element overla
2834
| `ignoreClickOutsideSelectors` | Array | `[]` | CSS selectors that keep the selection active when clicking outside the element |
2935
| `pageCountFormat` | String | `'{currentPage} of {totalPages}'` | Format string for page counter |
3036
| `autoFitZoom` | Boolean | `false` | Automatically adjust zoom to fit viewport on window resize |
37+
| `pdfjsOptions` | Object | `{}` | Options passed to PDF.js `getDocument` (advanced) |
38+
39+
### PDF.js options
40+
41+
`pdfjsOptions` is forwarded to PDF.js `getDocument(...)` and can be used to tune performance.
42+
43+
Example:
44+
45+
```ts
46+
<PDFElements
47+
:pdfjs-options="{
48+
disableFontFace: true,
49+
disableRange: true,
50+
disableStream: true,
51+
}"
52+
/>
53+
```
3154

3255
### Events
3356

REUSE.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ default-copyright = "2025 LibreCode coop and contributors"
1212
path = [
1313
".babelrc",
1414
".eslintrc.js",
15+
"env.d.ts",
1516
"package.json",
1617
"package-lock.json",
1718
"postcss.config.js",
18-
"vue.config.js",
19+
"tsconfig.json",
20+
"vite.config.ts",
21+
"vitest.config.ts",
1922
"examples/**",
23+
"tests/**",
2024
"dist/**",
2125
]
2226
precedence = "aggregate"

env.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference types="vite/client" />
2+
3+
declare module '*.vue' {
4+
import type { DefineComponent } from 'vue'
5+
const component: DefineComponent<Record<string, never>, Record<string, never>, unknown>
6+
export default component
7+
}

eslint.config.js

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
2+
// SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
const js = require('@eslint/js')
5+
const globals = require('globals')
6+
const vue = require('eslint-plugin-vue')
7+
const tsPlugin = require('@typescript-eslint/eslint-plugin')
8+
const tsParser = require('@typescript-eslint/parser')
9+
const vueParser = require('vue-eslint-parser')
10+
const vitest = require('eslint-plugin-vitest')
11+
12+
const vitestGlobals = {
13+
afterAll: 'readonly',
14+
afterEach: 'readonly',
15+
beforeAll: 'readonly',
16+
beforeEach: 'readonly',
17+
describe: 'readonly',
18+
expect: 'readonly',
19+
it: 'readonly',
20+
test: 'readonly',
21+
vi: 'readonly',
22+
}
23+
24+
module.exports = [
25+
{
26+
ignores: ['dist/**', 'dist-demo/**', 'node_modules/**', '.eslintrc.js'],
27+
},
28+
js.configs.recommended,
29+
{
30+
files: ['**/*.{ts,vue}'],
31+
languageOptions: {
32+
parser: vueParser,
33+
parserOptions: {
34+
parser: tsParser,
35+
ecmaVersion: 2021,
36+
sourceType: 'module',
37+
},
38+
globals: {
39+
...globals.browser,
40+
...globals.es2021,
41+
},
42+
},
43+
plugins: {
44+
vue,
45+
'@typescript-eslint': tsPlugin,
46+
},
47+
rules: {
48+
...vue.configs['flat/essential'].rules,
49+
...tsPlugin.configs.recommended.rules,
50+
'no-undef': 'off',
51+
'@typescript-eslint/no-explicit-any': 'off',
52+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
53+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
54+
},
55+
},
56+
{
57+
files: ['eslint.config.js', '**/*.config.js', '**/*.config.cjs', 'postcss.config.js'],
58+
languageOptions: {
59+
globals: {
60+
...globals.node,
61+
...globals.es2021,
62+
},
63+
sourceType: 'script',
64+
},
65+
rules: {
66+
'no-undef': 'off',
67+
},
68+
},
69+
{
70+
files: ['vite.config.ts', 'vitest.config.ts'],
71+
languageOptions: {
72+
globals: {
73+
...globals.node,
74+
...globals.es2021,
75+
},
76+
},
77+
},
78+
{
79+
files: ['tests/**/*.ts'],
80+
plugins: {
81+
vitest,
82+
},
83+
languageOptions: {
84+
globals: {
85+
...globals.browser,
86+
...globals.es2021,
87+
...vitestGlobals,
88+
},
89+
},
90+
rules: {
91+
...(vitest.configs?.recommended?.rules || {}),
92+
},
93+
},
94+
]

0 commit comments

Comments
 (0)