watermark-js-plus 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +88 -1
  2. package/dist/index.js +400 -0
  3. package/dist/index.min.js +1 -0
  4. package/package.json +22 -10
  5. package/.editorconfig +0 -16
  6. package/.eslintignore +0 -7
  7. package/.eslintrc.cjs +0 -46
  8. package/.github/workflows/deploy.yml +0 -29
  9. package/.github/workflows/npm-publish.yml +0 -32
  10. package/.husky/commit-msg +0 -4
  11. package/.husky/pre-commit +0 -4
  12. package/.prettierrc +0 -10
  13. package/CHANGELOG.md +0 -18
  14. package/babel.config.cjs +0 -23
  15. package/changelog-option.cjs +0 -87
  16. package/commitlint.config.cjs +0 -26
  17. package/docs/.vitepress/config.ts +0 -103
  18. package/docs/.vitepress/locales/zh-CN.ts +0 -51
  19. package/docs/.vitepress/theme/index.ts +0 -12
  20. package/docs/config/blind-decode.md +0 -33
  21. package/docs/config/blind.md +0 -19
  22. package/docs/config/index.md +0 -178
  23. package/docs/guide/blind-watermark.md +0 -267
  24. package/docs/guide/getting-started.md +0 -73
  25. package/docs/guide/watermark.md +0 -213
  26. package/docs/guide/what-is-this.md +0 -19
  27. package/docs/index.md +0 -33
  28. package/docs/public/favicons/apple-touch-icon.png +0 -0
  29. package/docs/public/favicons/favicon-64x64.png +0 -0
  30. package/docs/public/hero-image.png +0 -0
  31. package/docs/public/logo.png +0 -0
  32. package/docs/zh/config/blind-decode.md +0 -33
  33. package/docs/zh/config/blind.md +0 -19
  34. package/docs/zh/config/index.md +0 -178
  35. package/docs/zh/guide/blink-watermark.md +0 -288
  36. package/docs/zh/guide/getting-started.md +0 -48
  37. package/docs/zh/guide/watermark.md +0 -213
  38. package/docs/zh/guide/what-is-this.md +0 -19
  39. package/docs/zh/index.md +0 -33
  40. package/rollup.config.mjs +0 -40
  41. package/src/blind.ts +0 -43
  42. package/src/index.ts +0 -7
  43. package/src/types/index.ts +0 -69
  44. package/src/utils/index.ts +0 -63
  45. package/src/watermark.ts +0 -300
  46. package/tools/terser.js +0 -19
  47. package/tsconfig.json +0 -15
@@ -1,32 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: npm-publish
5
-
6
- on:
7
- release:
8
- types: [created]
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: actions/setup-node@v3
16
- with:
17
- node-version: 16
18
- - run: npm ci
19
-
20
- publish-npm:
21
- needs: build
22
- runs-on: ubuntu-latest
23
- steps:
24
- - uses: actions/checkout@v3
25
- - uses: actions/setup-node@v3
26
- with:
27
- node-version: 16
28
- registry-url: https://registry.npmjs.org/
29
- - run: npm ci
30
- - run: npm publish
31
- env:
32
- NODE_AUTH_TOKEN: ${{secrets.npm_token}}
package/.husky/commit-msg DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname -- "$0")/_/husky.sh"
3
-
4
- npx --no-install commitlint --edit ""
package/.husky/pre-commit DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname -- "$0")/_/husky.sh"
3
-
4
- npm run lint-changelog
package/.prettierrc DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "tabWidth": 2,
3
- "useTabs": false,
4
- "semi": false,
5
- "singleQuote": true,
6
- "TrailingComma": "all",
7
- "bracketSpacing": true,
8
- "jsxBracketSameLine": false,
9
- "arrowParens": "avoid"
10
- }
package/CHANGELOG.md DELETED
@@ -1,18 +0,0 @@
1
- ## [0.0.2](https://github.com/zhensherlock/watermark-js-plus/compare/v0.0.1...v0.0.2) (2022-12-07)
2
-
3
-
4
- ### ✨ Features | 新功能
5
-
6
- * optimize parent element logic ([836a1ee](https://github.com/zhensherlock/watermark-js-plus/commit/836a1eed2319c42444bdb6362dbf8114ab9bcf0e))
7
-
8
-
9
-
10
- ## [0.0.1](https://github.com/zhensherlock/watermark-js-plus/compare/fb530a78a35020947fec230142a131b56b3588b4...v0.0.1) (2022-12-05)
11
-
12
-
13
- ### ✨ Features | 新功能
14
-
15
- * add initial version ([fb530a7](https://github.com/zhensherlock/watermark-js-plus/commit/fb530a78a35020947fec230142a131b56b3588b4))
16
-
17
-
18
-
package/babel.config.cjs DELETED
@@ -1,23 +0,0 @@
1
- const presets = [
2
- [
3
- '@babel/preset-env',
4
- {
5
- useBuiltIns: 'usage',
6
- corejs: { version: 3 },
7
- targets: [
8
- '> 1%',
9
- 'Firefox ESR',
10
- 'last 4 versions',
11
- 'maintained node versions',
12
- 'not dead',
13
- 'safari >= 7'
14
- ],
15
- },
16
- ],
17
- ]
18
-
19
- const plugins = [
20
- '@babel/plugin-transform-runtime'
21
- ]
22
-
23
- module.exports = { presets, plugins }
@@ -1,87 +0,0 @@
1
- const compareFunc = require('compare-func')
2
-
3
- module.exports = {
4
- writerOpts: {
5
- transform: (commit, context) => {
6
- let discard = true
7
- const issues = []
8
-
9
- commit.notes.forEach(note => {
10
- note.title = 'BREAKING CHANGES'
11
- discard = false
12
- })
13
- if (commit.type === 'feat') {
14
- commit.type = '✨ Features | 新功能'
15
- } else if (commit.type === 'fix') {
16
- commit.type = '🐛 Bug Fixes | Bug 修复'
17
- } else if (commit.type === 'perf') {
18
- commit.type = '⚡ Performance Improvements | 性能优化'
19
- } else if (commit.type === 'revert' || commit.revert) {
20
- commit.type = '⏪ Reverts | 回退'
21
- } else if (discard) {
22
- return
23
- } else if (commit.type === 'refactor') {
24
- commit.type = '♻ Code Refactoring | 代码重构'
25
- } else if (commit.type === 'test') {
26
- commit.type = '✅ Tests | 测试'
27
- } else if (commit.type === 'build') {
28
- commit.type = '👷‍ Build System | 构建'
29
- } else if (commit.type === 'ci') {
30
- commit.type = '🔧 Continuous Integration | CI 配置'
31
- } else if (commit.type === 'chore') {
32
- commit.type = '🎫 Chores | 其他更新'
33
- } else if (commit.type === 'style') {
34
- commit.type = '💄 Styles | 风格'
35
- } else if (commit.type === 'docs') {
36
- commit.type = '📝 Documentation | 文档'
37
- }
38
-
39
- if (commit.scope === '*') {
40
- commit.scope = ''
41
- }
42
-
43
- if (typeof commit.hash === 'string') {
44
- commit.shortHash = commit.hash.substring(0, 7)
45
- }
46
-
47
- if (typeof commit.subject === 'string') {
48
- let url = context.repository
49
- ? `${context.host}/${context.owner}/${context.repository}`
50
- : context.repoUrl
51
-
52
- if (url) {
53
- url = `${url}/issues/`
54
- // Issue URLs.
55
- commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
56
- issues.push(issue)
57
- return `[#${issue}](${url}${issue})`
58
- })
59
- }
60
-
61
- if (context.host) {
62
- // User URLs.
63
- commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
64
- if (username.includes('/')) {
65
- return `@${username}`
66
- }
67
- return `[@${username}](${context.host}/${username})`
68
- })
69
- }
70
- }
71
-
72
- // remove references that already appear in the subject
73
- commit.references = commit.references.filter(reference => {
74
- if (issues.indexOf(reference.issue) === -1) {
75
- return true
76
- }
77
- return false
78
- })
79
- return commit
80
- },
81
- groupBy: 'type',
82
- commitGroupsSort: 'title',
83
- commitsSort: ['scope', 'subject'],
84
- noteGroupsSort: 'title',
85
- notesSort: compareFunc
86
- }
87
- }
@@ -1,26 +0,0 @@
1
- module.exports = {
2
- extends: ['@commitlint/config-conventional'],
3
- rules: {
4
- // type 类型定义,表示 git 提交的 type 必须在以下类型范围内
5
- 'type-enum': [
6
- 2,
7
- 'always',
8
- [
9
- 'feat', // 新功能
10
- 'fix', // 修复
11
- 'docs', // 文档变更
12
- 'style', // 代码格式
13
- 'refactor', // 重构
14
- 'pref', // 性能优化
15
- 'test', // 增加测试
16
- 'build', // 构建
17
- 'ci', // CI配置
18
- 'chore', // 构建过程或辅助工具的变动
19
- 'revert', // 回退
20
- 'build' // 打包
21
- ]
22
- ],
23
- // subject 大小写不做校验
24
- 'subject-case': [0]
25
- }
26
- };
@@ -1,103 +0,0 @@
1
- import { version } from '../../package.json'
2
- import zh_CN from './locales/zh-CN'
3
-
4
- export default {
5
- title: 'watermark-js-plus',
6
- description: 'A watermark plugin',
7
- base: '/watermark-js-plus',
8
- head: [
9
- ['link', { rel: 'shortcut icon', href: '/watermark-js-plus/favicons/favicon-64x64.png' }],
10
- ['link', { rel: 'apple-touch-icon', sizes: '180x180', href: '/watermark-js-plus/favicons/apple-touch-icon.png' }],
11
- // ['link', { rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicons/favicon-32x32.png' }],
12
- // ['link', { rel: 'icon', type: 'image/png', sizes: '16x16', href: '/favicons/favicon-16x16.png' }],
13
- // ['link', { rel: "manifest", href: "/assets/favicons/site.webmanifest"}],
14
- // ['link', { rel: "mask-icon", href: "/assets/favicons/safari-pinned-tab.svg", color: "#3a0839"}],
15
- // ['meta', { name: "msapplication-TileColor", content: "#3a0839"}],
16
- // ['meta', { name: "msapplication-config", content: "/assets/favicons/browserconfig.xml"}],
17
- // ['meta', { name: "theme-color", content: "#ffffff"}],
18
- ],
19
- themeConfig: {
20
- logo: '/logo.png',
21
- nav: [
22
- { text: 'Guide', link: '/guide/what-is-this', activeMatch: '/guide/' },
23
- { text: 'Configs', link: '/config/', activeMatch: '/config/' },
24
- {
25
- text: version,
26
- items: [
27
- {
28
- text: 'Changelog',
29
- link: 'https://github.com/zhensherlock/watermark-js-plus/blob/main/CHANGELOG.md'
30
- },
31
- // {
32
- // text: 'Contributing',
33
- // link: 'https://github.com/zhensherlock/watermark-js-plus/blob/main/.github/contributing.md'
34
- // }
35
- ]
36
- }
37
- ],
38
- socialLinks: [
39
- { icon: 'github', link: 'https://github.com/zhensherlock/watermark-js-plus' },
40
- ],
41
- sidebar: {
42
- '/guide': [
43
- {
44
- text: 'Guide',
45
- // collapsible: true,
46
- items: [
47
- { text: 'Introduce', link: '/guide/what-is-this' },
48
- { text: 'Getting Started', link: '/guide/getting-started' },
49
- { text: 'Watermark', link: '/guide/watermark' },
50
- { text: 'Blind Watermark', link: '/guide/blind-watermark' },
51
- ]
52
- }
53
- ],
54
- '/config': [
55
- {
56
- text: 'Config',
57
- // collapsible: true,
58
- items: [
59
- { text: 'Basic Config', link: '/config/' },
60
- { text: 'Blind Watermark Config', link: '/config/blind' },
61
- { text: 'Blind Watermark Decode', link: '/config/blind-decode' },
62
- ]
63
- }
64
- ]
65
- },
66
- algolia: {
67
- appId: 'V6CF28P0PS',
68
- apiKey: '692752b7b3c6f794997d8ae22aed79fa',
69
- indexName: 'dev_docs'
70
- },
71
- footer: {
72
- message: 'Released under the MIT License.',
73
- copyright: 'Copyright © 2021-present Michael Sun'
74
- },
75
- locales: {
76
- '/zh/': zh_CN
77
- },
78
- localeLinks: {
79
- // text: 'English',
80
- items: [
81
- { text: 'English', link: '/' },
82
- { text: '简体中文', link: '/zh/' },
83
- ]
84
- },
85
- },
86
- markdown: {
87
- lineNumbers: true
88
- },
89
- locales: {
90
- '/': {
91
- lang: 'en-US',
92
- title: 'watermark-js-plus',
93
- description: 'A watermark plugin',
94
- },
95
- '/zh/': {
96
- lang: 'zh-CN',
97
- description: '一个水印插件',
98
- outlineTitle: '本页目录',
99
- lastUpdatedText: '上次更新',
100
- base: '/zh/',
101
- }
102
- }
103
- }
@@ -1,51 +0,0 @@
1
- import { version } from '../../../package.json'
2
-
3
- export default {
4
- outlineTitle: '本页目录',
5
- lastUpdatedText: '上次更新',
6
- nav: [
7
- { text: '指南', link: '/zh/guide/what-is-this', activeMatch: '/guide/' },
8
- { text: '配置项', link: '/zh/config/', activeMatch: '/config/' },
9
- {
10
- text: version,
11
- items: [
12
- {
13
- text: '更新日志',
14
- link: 'https://github.com/zhensherlock/watermark-js-plus/blob/main/CHANGELOG.md'
15
- },
16
- // {
17
- // text: '贡献',
18
- // link: 'https://github.com/vuejs/vitepress/blob/main/.github/contributing.md'
19
- // }
20
- ]
21
- }
22
- ],
23
- sidebar: {
24
- '/zh/guide': [
25
- {
26
- text: '向导',
27
- // collapsible: true,
28
- items: [
29
- { text: '介绍', link: '/zh/guide/what-is-this' },
30
- { text: '开始使用', link: '/zh/guide/getting-started' },
31
- { text: '水印', link: '/zh/guide/watermark' },
32
- { text: '暗水印', link: '/zh/guide/blink-watermark' },
33
- ]
34
- }
35
- ],
36
- '/zh/config': [
37
- {
38
- text: '配置',
39
- // collapsible: true,
40
- items: [
41
- { text: '基础配置项', link: '/zh/config/' },
42
- { text: '暗水印配置项', link: '/zh/config/blind' },
43
- { text: '暗水印解码配置项', link: '/zh/config/blind-decode' },
44
- ]
45
- }
46
- ]
47
- },
48
- footer: {
49
- message: '本中文文档内容版权为 Michael Sun 所有,保留所有权利。'
50
- },
51
- }
@@ -1,12 +0,0 @@
1
- import DefaultTheme from 'vitepress/theme'
2
- import 'element-plus/dist/index.css'
3
- export default {
4
- ...DefaultTheme,
5
- enhanceApp: async ({ app, router, siteData, isServer }: any) => {
6
- // app is the Vue 3 app instance from `createApp()`. router is VitePress'
7
- // custom router. `siteData`` is a `ref`` of current site-level metadata.
8
- import('element-plus').then((module) => {
9
- app.use(module)
10
- })
11
- }
12
- }
@@ -1,33 +0,0 @@
1
- ---
2
- layout: doc
3
- ---
4
- # Blind Watermark Decode
5
-
6
- ## url
7
-
8
- - **Type:** `string`
9
- - **Default:** `''`
10
-
11
- Decoding picture path.
12
-
13
- ## mode
14
-
15
- - **Type:** `string`
16
- - **Default:** `'canvas'`
17
- - **available values**: `'canvas'`
18
-
19
- Mode of decoding.
20
-
21
- ## fillColor
22
-
23
- - **Type:** `string`
24
- - **Default:** `'#000'`
25
-
26
- fill color.
27
-
28
- ## compositeOperation
29
-
30
- - **Type:** `string`
31
- - **Default:** `'color-burn'`
32
-
33
- composite operation.
@@ -1,19 +0,0 @@
1
- ---
2
- layout: doc
3
- ---
4
- # Blind Watermark Config
5
-
6
- ## globalAlpha
7
-
8
- - **Type:** `number`
9
- - **Default:** `0.005`
10
-
11
- Transparency of watermark.
12
-
13
- ## mode
14
-
15
- - **Type:** `string`
16
- - **Default:** `'blind'`
17
- - **available values**: `'default' | 'blind'`
18
-
19
- Watermark mode
@@ -1,178 +0,0 @@
1
- ---
2
- layout: doc
3
- ---
4
- # Basic Config
5
-
6
- ## width
7
-
8
- - **Type:** `number`
9
- - **Default:** `300`
10
-
11
- A unit of width for a single watermark.
12
-
13
- ## height
14
-
15
- - **Type:** `number`
16
- - **Default:** `300`
17
-
18
- A unit of height for a single watermark.
19
-
20
- ## rotate
21
-
22
- - **Type:** `number`
23
- - **Default:** `45`
24
-
25
- Watermark rotation Angle.
26
-
27
- Rotate with the center of the text as the origin.
28
-
29
- ## contentType
30
-
31
- - **Type:** `string`
32
- - **Default:** `'text'`
33
- - **available values**: `'text' | 'image' | 'multi-line-text' | 'rich-text'`
34
-
35
- Type of watermark content.
36
-
37
- ## content
38
-
39
- - **Type:** `string`
40
- - **Default:** `'hello watermark-js-plus'`
41
-
42
- Watermark content.
43
-
44
- ## imageWidth
45
-
46
- - **Type:** `number`
47
- - **Default:** `0`
48
-
49
- Watermark image width.
50
-
51
- ## imageHeight
52
-
53
- - **Type:** `number`
54
- - **Default:** `0`
55
-
56
- Watermark image height.
57
-
58
- ## lineHeight
59
-
60
- - **Type:** `number`
61
- - **Default:** `30`
62
-
63
- Watermark content line high.
64
-
65
- ## zIndex
66
-
67
- - **Type:** `number`
68
- - **Default:** `10000`
69
-
70
- z-index
71
-
72
- ## backgroundPosition
73
-
74
- - **Type:** `string`
75
- - **Default:** `'0 0, 0 0'`
76
-
77
- background-position
78
-
79
- ## fontSize
80
-
81
- - **Type:** `number`
82
- - **Default:** `20`
83
-
84
- The font size of the watermark content.
85
-
86
- ## fontFamily
87
-
88
- - **Type:** `string`
89
- - **Default:** `'sans-serif'`
90
-
91
- The font family of the watermark content.
92
-
93
- ## textAlign
94
-
95
- - **Type:** `string`
96
- - **Default:** `'center'`
97
- - **available values**: `'center' | 'left' | 'right'`
98
-
99
- Watermark content horizontal alignment.
100
-
101
- ## textBaseline
102
-
103
- - **Type:** `string`
104
- - **Default:** `'middle'`
105
- - **available values**: `'top' | 'bottom' | 'middle'`
106
-
107
- Watermark content baseline.
108
-
109
- ## fontColor
110
-
111
- - **Type:** `string`
112
- - **Default:** `'#000'`
113
-
114
- Watermark content font color.
115
-
116
- ## globalAlpha
117
-
118
- - **Type:** `number`
119
- - **Default:** `0.5`
120
-
121
- Transparency of watermark.
122
-
123
- ## fontWeight
124
-
125
- - **Type:** `string`
126
- - **Default:** `'normal'`
127
-
128
- Watermark content font weight.
129
-
130
- ## mode
131
-
132
- - **Type:** `string`
133
- - **Default:** `'default'`
134
- - **available values**: `'default' | 'blind'`
135
-
136
- Watermark mode
137
-
138
- ## mutationObserve
139
-
140
- - **Type:** `boolean`
141
- - **Default:** `true`
142
-
143
- Enable listening for watermark dom changes.
144
-
145
- ## unique
146
-
147
- - **Type:** `boolean`
148
- - **Default:** `true`
149
-
150
- The watermark cannot be added repeatedly.
151
-
152
- ## parent
153
-
154
- - **Type:** `Element | string`
155
- - **Default:** `'body'`
156
-
157
- Watermarking container.
158
-
159
- ## onSuccess
160
-
161
- - **Type:** `Function`
162
- - **Default:** `() => {}`
163
-
164
- Watermark added successful callback event.
165
-
166
- ## onBeforeDestroy
167
-
168
- - **Type:** `Function`
169
- - **Default:** `() => {}`
170
-
171
- Watermark delete before callback event.
172
-
173
- ## onDestroyed
174
-
175
- - **Type:** `Function`
176
- - **Default:** `() => {}`
177
-
178
- Watermark deleted after callback event.