Skip to content

Commit ca2daf7

Browse files
committed
chore: use class-style
1 parent 7ecdfef commit ca2daf7

8 files changed

Lines changed: 21 additions & 21 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ npm i pdfeasy
3030
```
3131

3232
```ts
33-
import pdfeasy from 'pdfeasy'
33+
import { PDFEasy } from 'pdfeasy'
34+
35+
const pdfeasy = new PDFEasy()
3436

3537
pdfeasy.new()
3638

demo/src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pdfeasy, { Utils } from 'pdfeasy'
1+
import { PDFEasy, Utils } from 'pdfeasy'
22
import './style.css'
33

44
const app = document.querySelector<HTMLDivElement>('#app')!
@@ -7,6 +7,8 @@ app.innerHTML = `
77
<iframe id="pdf">
88
`
99

10+
const pdfeasy = new PDFEasy()
11+
1012
pdfeasy.new({
1113
document: {
1214
margins: {

packages/nuxt/src/module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fileURLToPath } from 'url'
22
import { defineNuxtModule, addPlugin, createResolver } from '@nuxt/kit'
3-
import PDFEASY from 'pdfeasy'
3+
import { PDFEasy } from 'pdfeasy'
44

55
export interface ModuleOptions {}
66

@@ -24,12 +24,12 @@ export default defineNuxtModule<ModuleOptions>({
2424

2525
declare module '#app' {
2626
interface NuxtApp {
27-
$pdf: typeof PDFEASY
27+
$pdf: PDFEasy
2828
}
2929
}
3030

3131
declare module 'vue' {
3232
interface ComponentCustomProperties {
33-
$pdf: typeof PDFEASY
33+
$pdf: PDFEasy
3434
}
3535
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { defineNuxtPlugin } from '#app'
2-
import PDFEASY from 'pdfeasy'
2+
import { PDFEasy } from 'pdfeasy'
33

44
export default defineNuxtPlugin(({ provide }) => {
5-
// @ts-expect-error
6-
provide('pdf', PDFEASY.default as typeof PDFEASY)
5+
provide('pdf', new PDFEasy())
76
})

packages/pdfeasy/src/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import PDFEasy from './runner/pdfeasy'
2-
3-
export default new PDFEasy()
4-
5-
export * as Utils from './utils'
6-
export * as Types from './types'
1+
export * from './runner/pdfeasy'
2+
3+
export * as Utils from './utils'
4+
export * as Types from './types'

packages/pdfeasy/src/runner/pdfeasy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { runPluginBackground } from '../plugins/background'
2727
/**
2828
* A Base PDFEasy Runner
2929
*/
30-
export default class {
30+
export class PDFEasy {
3131
/**
3232
* A internal emitter.
3333
*

packages/vue/src/plugin.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import { App, Plugin } from 'vue-demi';
2-
import pdfeasy from 'pdfeasy'
2+
import { PDFEasy } from 'pdfeasy'
33

44
interface PluginOptions {}
55

66
export const PDFPlugin: Plugin = {
77
install: (app: App, options: PluginOptions = {}) => {
8-
// @ts-expect-error
9-
app.config.globalProperties.$pdf = pdfeasy.default;
8+
app.config.globalProperties.$pdf = new PDFEasy();
109
},
1110
};
1211

1312
declare module "@vue/runtime-core" {
1413
interface ComponentCustomProperties {
15-
$pdf: typeof pdfeasy;
14+
$pdf: PDFEasy;
1615
}
1716
}

packages/vue/src/use.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import pdfeasy from 'pdfeasy';
1+
import { PDFEasy } from 'pdfeasy';
22
import { getCurrentInstance, ComponentInternalInstance } from 'vue-demi';
33

4-
export const usePDF = (): typeof pdfeasy => {
4+
export const usePDF = (): PDFEasy => {
55
const instance = getCurrentInstance();
66

77
if (!instance) {

0 commit comments

Comments
 (0)