watermark-js-plus 0.0.1

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 (43) hide show
  1. package/.editorconfig +16 -0
  2. package/.eslintignore +7 -0
  3. package/.eslintrc.cjs +46 -0
  4. package/.github/workflows/deploy.yml +29 -0
  5. package/.github/workflows/npm-publish.yml +32 -0
  6. package/.husky/commit-msg +4 -0
  7. package/.husky/pre-commit +4 -0
  8. package/.prettierrc +10 -0
  9. package/CHANGELOG.md +9 -0
  10. package/LICENSE +21 -0
  11. package/README.md +1 -0
  12. package/babel.config.cjs +23 -0
  13. package/changelog-option.cjs +87 -0
  14. package/commitlint.config.cjs +26 -0
  15. package/docs/.vitepress/config.ts +91 -0
  16. package/docs/.vitepress/locales/zh-CN.ts +49 -0
  17. package/docs/.vitepress/theme/index.ts +12 -0
  18. package/docs/config/blind-decode.md +33 -0
  19. package/docs/config/blind.md +19 -0
  20. package/docs/config/index.md +178 -0
  21. package/docs/guide/blind-watermark.md +267 -0
  22. package/docs/guide/getting-started.md +73 -0
  23. package/docs/guide/watermark.md +213 -0
  24. package/docs/guide/what-is-this.md +19 -0
  25. package/docs/index.md +33 -0
  26. package/docs/public/logo.png +0 -0
  27. package/docs/zh/config/blind-decode.md +33 -0
  28. package/docs/zh/config/blind.md +19 -0
  29. package/docs/zh/config/index.md +178 -0
  30. package/docs/zh/guide/blink-watermark.md +288 -0
  31. package/docs/zh/guide/getting-started.md +48 -0
  32. package/docs/zh/guide/watermark.md +213 -0
  33. package/docs/zh/guide/what-is-this.md +19 -0
  34. package/docs/zh/index.md +33 -0
  35. package/package.json +78 -0
  36. package/rollup.config.mjs +40 -0
  37. package/src/blind.ts +43 -0
  38. package/src/index.ts +7 -0
  39. package/src/types/index.ts +69 -0
  40. package/src/utils/index.ts +63 -0
  41. package/src/watermark.ts +288 -0
  42. package/tools/terser.js +19 -0
  43. package/tsconfig.json +15 -0
package/.editorconfig ADDED
@@ -0,0 +1,16 @@
1
+ # http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+
12
+ [*.md]
13
+ trim_trailing_whitespace = false
14
+
15
+ [Makefile]
16
+ indent_style = tab
package/.eslintignore ADDED
@@ -0,0 +1,7 @@
1
+ */build/*.js
2
+ */public
3
+ dist
4
+ .husky/
5
+ lib
6
+ */node_modules
7
+ package-lock.json
package/.eslintrc.cjs ADDED
@@ -0,0 +1,46 @@
1
+ module.exports = {
2
+ parser: '@typescript-eslint/parser', // 解析器,默认使用Espree
3
+ env: { // 指定脚本的运行环境。每种环境都有一组特定的预定义全局变量。
4
+ browser: true, // 运行在浏览器
5
+ es2021: true, // 支持es2021
6
+ es6: true,
7
+ },
8
+ extends: [ // 使用的外部代码格式化配置文件
9
+ 'semistandard',
10
+ 'plugin:import/recommended'
11
+ ],
12
+ plugins: [
13
+ 'import'
14
+ ],
15
+ parserOptions: {
16
+ ecmaVersion: 12, // ecmaVersion 用来指定支持的 ECMAScript 版本 。默认为 5,即仅支持es5
17
+ sourceType: 'module',
18
+ },
19
+ globals: { // 脚本在执行期间访问的额外的全局变量
20
+ describe: true,
21
+ it: true,
22
+ after: true,
23
+ before: true,
24
+ afterEach: true,
25
+ beforeEach: true,
26
+ __BUILD__: true,
27
+ __DEV__: true,
28
+ __SIT__: true,
29
+ __UAT__: true,
30
+ __PROD__: true
31
+ },
32
+ rules: {
33
+ // 启用的规则及其各自的错误级别。0(off) 1(warning) 2(error)
34
+ 'no-console': 0,
35
+ semi: [1, 'never'],
36
+ quotes: [1, 'single'],
37
+ 'no-unused-vars': 0,
38
+ },
39
+ settings: {
40
+ 'import/resolver': {
41
+ node: {
42
+ extensions: ['.js', '.jsx', '.ts', '.tsx']
43
+ }
44
+ }
45
+ },
46
+ };
@@ -0,0 +1,29 @@
1
+ name: Deploy
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ deploy:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v3
13
+ with:
14
+ fetch-depth: 0
15
+ - uses: actions/setup-node@v3
16
+ with:
17
+ node-version: 16
18
+ cache: npm
19
+ - run: npm ci
20
+
21
+ - name: Build
22
+ run: yarn docs:build
23
+
24
+ - name: Deploy
25
+ uses: peaceiris/actions-gh-pages@v3
26
+ with:
27
+ github_token: ${{ secrets.GITHUB_TOKEN }}
28
+ publish_dir: docs/.vitepress/dist
29
+ # cname: example.com # if wanna deploy to custom domain
@@ -0,0 +1,32 @@
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: 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}}
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx --no-install commitlint --edit ""
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npm run lint-changelog
package/.prettierrc ADDED
@@ -0,0 +1,10 @@
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 ADDED
@@ -0,0 +1,9 @@
1
+ ## 0.0.1 (2022-12-05)
2
+
3
+
4
+ ### ✨ Features | 新功能
5
+
6
+ * add initial version ([fb530a7](https://github.com/zhensherlock/watermark-js-plus/commit/fb530a78a35020947fec230142a131b56b3588b4))
7
+
8
+
9
+
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 sunzhenxuan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # watermark-js-plus
@@ -0,0 +1,23 @@
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 }
@@ -0,0 +1,87 @@
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
+ }
@@ -0,0 +1,26 @@
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
+ };
@@ -0,0 +1,91 @@
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
+ themeConfig: {
9
+ // siteTitle: "Kitty",
10
+ // logo: "/logo.png",
11
+ nav: [
12
+ { text: 'Guide', link: '/guide/what-is-this', activeMatch: '/guide/' },
13
+ { text: 'Configs', link: '/config/', activeMatch: '/config/' },
14
+ {
15
+ text: version,
16
+ items: [
17
+ {
18
+ text: 'Changelog',
19
+ link: 'https://github.com/zhensherlock/watermark-js-plus/blob/main/CHANGELOG.md'
20
+ },
21
+ // {
22
+ // text: 'Contributing',
23
+ // link: 'https://github.com/vuejs/vitepress/blob/main/.github/contributing.md'
24
+ // }
25
+ ]
26
+ }
27
+ ],
28
+ socialLinks: [
29
+ { icon: 'github', link: 'https://github.com/zhensherlock/watermark-js-plus' },
30
+ ],
31
+ sidebar: {
32
+ '/guide': [
33
+ {
34
+ text: 'Guide',
35
+ items: [
36
+ { text: 'Introduce', link: '/guide/what-is-this' },
37
+ { text: 'Getting Started', link: '/guide/getting-started' },
38
+ { text: 'Watermark', link: '/guide/watermark' },
39
+ { text: 'Blind Watermark', link: '/guide/blind-watermark' },
40
+ ]
41
+ }
42
+ ],
43
+ '/config': [
44
+ {
45
+ text: 'Config',
46
+ items: [
47
+ { text: 'Basic Config', link: '/config/' },
48
+ { text: 'Blind Watermark Config', link: '/config/blind' },
49
+ { text: 'Blind Watermark Decode', link: '/config/blind-decode' },
50
+ ]
51
+ }
52
+ ]
53
+ },
54
+ algolia: {
55
+ appId: 'V6CF28P0PS',
56
+ apiKey: '692752b7b3c6f794997d8ae22aed79fa',
57
+ indexName: 'dev_docs'
58
+ },
59
+ footer: {
60
+ message: 'Released under the MIT License.',
61
+ copyright: 'Copyright © 2021-present Michael Sun'
62
+ },
63
+ locales: {
64
+ '/zh/': zh_CN
65
+ },
66
+ localeLinks: {
67
+ // text: 'English',
68
+ items: [
69
+ { text: 'English', link: '/' },
70
+ { text: '简体中文', link: '/zh/' },
71
+ ]
72
+ },
73
+ },
74
+ markdown: {
75
+ lineNumbers: true
76
+ },
77
+ locales: {
78
+ '/': {
79
+ lang: 'en-US',
80
+ title: 'watermark-js-plus',
81
+ description: 'A watermark plugin',
82
+ },
83
+ '/zh/': {
84
+ lang: 'zh-CN',
85
+ description: '一个水印插件',
86
+ outlineTitle: '本页目录',
87
+ lastUpdatedText: '上次更新',
88
+ base: '/zh/',
89
+ }
90
+ }
91
+ }
@@ -0,0 +1,49 @@
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
+ items: [
28
+ { text: '介绍', link: '/zh/guide/what-is-this' },
29
+ { text: '开始使用', link: '/zh/guide/getting-started' },
30
+ { text: '水印', link: '/zh/guide/watermark' },
31
+ { text: '暗水印', link: '/zh/guide/blink-watermark' },
32
+ ]
33
+ }
34
+ ],
35
+ '/zh/config': [
36
+ {
37
+ text: '配置',
38
+ items: [
39
+ { text: '基础配置项', link: '/zh/config/' },
40
+ { text: '暗水印配置项', link: '/zh/config/blind' },
41
+ { text: '暗水印解码配置项', link: '/zh/config/blind-decode' },
42
+ ]
43
+ }
44
+ ]
45
+ },
46
+ footer: {
47
+ message: '本中文文档内容版权为 Michael Sun 所有,保留所有权利。'
48
+ },
49
+ }
@@ -0,0 +1,12 @@
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
+ }
@@ -0,0 +1,33 @@
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.
@@ -0,0 +1,19 @@
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