Skip to content

Commit

Permalink
Initial dig
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianWalkerToretto committed Nov 7, 2019
0 parents commit eea3b7e
Show file tree
Hide file tree
Showing 21 changed files with 754 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// .babelrc
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"browsers": [
">0.2%",
"not dead",
"not op_mini all",
"last 2 versions",
"ie >= 9",
"iOS >= 8",
"Android >= 4"
]
},
"modules": false,
"useBuiltIns": "entry", // usage
"corejs": 3,
"debug": false, // 是否输出启用的plugins列表
"spec": false, // 是否允许more spec compliant,但可能转译出的代码更慢
"loose": true, // 是否允许生成更简单es5的代码,但可能不那么完全符合ES6语义
"include": [], // 总是启用的 plugins
"exclude": [], // 强制不启用的 plugins
"forceAllTransforms": false // 强制使用所有的plugins,用于只能支持ES5的uglify可以正确压缩代码
}
]
],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
[
// @babel/plugin-transform-runtime: 避免 polyfill 污染全局变量,减小打包体积
"@babel/plugin-transform-runtime",
{
// "polyfill": false,
"absoluteRuntime": false,
"corejs": 3, // 对应 @babel/runtime-corejs@3,需要填3
"helpers": false,
"regenerator": true,
"useESModules": false
}
],
["@babel/plugin-syntax-dynamic-import"],
["@babel/plugin-transform-arrow-functions", { "spec": false }],
["@babel/plugin-proposal-class-properties", { "loose": true }]
]
}
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

# starter/.editoorconfig
root = true # 表明是最顶层的配置文件,发现设为 true 时,才会停止查找.editorconfig 文件。

[*]
charset = utf-8
indent_style = space # tab 为 hard-tabs,space 为 soft-tabs。
indent_size = 2 # 规定每级缩进的列数和 soft-tabs 的宽度(空格数)。如果设定为 tab,则会使用 tab_width 的值。
end_of_line = lf # 定义换行符,支持 lf(UNIX/Linux采用换行符 LF 表示下一行)、cr(MAC OS系统)则采用回车符 CR 表示下一行) 和 crlf。
insert_final_newline = true # 设为 true 表明使文件以一个空白行结尾,false 反之
trim_trailing_whitespace = true # 设为 true 表示会除去换行行首的任意空白字符,false 反之。
max_line_length = 80

[*.md] # 校验 markdown 文档
insert_final_newline = false
trim_trailing_whitespace = false
max_line_length = 0
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
44 changes: 44 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"root": true,
"env": {
"es6": true,
"browser": true
},
"extends": [
"eslint:recommended", // 启用推荐的规则
"plugin:react/recommended", // 该插件会导出建议的配置,以强制实施 React 的良好做法。
"plugin:jsx-a11y/recommended",
"plugin:prettier/recommended",
"prettier/react"
],
"parser": "babel-eslint", // 一个对 Babel 解析器的包装,使其能够与 ESLint 兼容
"plugins": [
"react",
"jsx-a11y",
"react-hooks",
"import" // 该插件旨在支持ES2015 +(ES6 +)导入/导出语法的检查,并防止文件路径和导入名称拼写错误的问题。
],
"rules": {
"semi": ["error", "always"],
"quotes": ["error", "single"],
"camelcase": [0, { "properties": "never" }],
"no-console": [2, { "allow": ["warn", "error"] }],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"react/jsx-props-no-spreading": "off",
"jsx-a11y/click-events-have-key-events": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"react/no-unused-prop-types": "off"
},
"settings": {
// "react": {
// "version": "16.10.2"
// },
"import/resolver": "webpack"
},
"globals": {
"process": true,
"module": true
}
}

12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# dependencies
node_modules/
package-lock.json
src/animate/
*.bat
*.map

# misc
.DS_Store

# Editor directories and files
.vscode
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
registry=https://registry.npmjs.org/
disturl=https://registry.npmjs.org/dist/node
sass_binary_site=https://registry.npmjs.org/mirrors/node-sass/
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": true,
"singleQuote": true,
"trailingComma": 'all',
}

22 changes: 22 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": [
"stylelint-config-recommended",
"stylelint-config-prettier"
],
"rules": {
"indentation": 2,
"declaration-colon-space-after": "always",
"declaration-colon-space-before": "never",
"function-comma-space-after": "always",
"function-url-quotes": "always",
"media-feature-colon-space-before": "never",
"media-feature-name-no-vendor-prefix": true,
"max-empty-lines": 5,
"number-leading-zero": "never",
"number-no-trailing-zeros": true,
"at-rule-semicolon-newline-after": "always",
"selector-list-comma-space-before": "never",
"selector-list-comma-newline-after": "always",
"string-quotes": "single",
}
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 BrianWalkerToretto

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# watermark
canvas/svg水印:可用于 react,vue 和其他小程序(更多小程序平台正在开发)的水印组件

### 使用
##### 1. 安装依赖
```
npm install @brian-walker-toretto/watermark
```

### Todo

- [ ] 实现 react hooks 版本
- [ ] 拓展更多小程序平台
- [ ] api 拓展

### 工程TODO
- [] 引入typescript/tslint
- [] 打包使用rollup
- [] 单元测试jest

### 任务 TODO
- [] 防删除
- [] react/vue/js
- [] 暗水印
- [] 性能优化
2 changes: 2 additions & 0 deletions dist/dig.js

Large diffs are not rendered by default.

93 changes: 93 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"name": "@brian-walker-toretto/dig",
"version": "0.01.1",
"description": "canvas/svg watermark",
"main": "/dist/dig.js",
"keywords": [
"dig",
"埋点"
],
"scripts": {
"build": "npm run clear && cross-env NODE_ENV=production webpack --config ./webpack.config.js --color --progress --hide-modules",
"dev": "npm run clear && cross-env NODE_ENV=development webpack-dev-server --config ./webpack.config.js",
"clear": "rimraf ./dist",
"prettier": "prettier --check --write './**/*.{js,jsx,scss,css}' --config ./.prettierrc",
"eslint": "npm run eslint:style && npm run eslint:script",
"eslint:script": "eslint --fix --ext .ts,.tsx,.js,.jsx ./",
"eslint:style": "stylelint --fix 'src/**/*.css' 'src/**/*.less' --syntax less",
"release": "npm run build && npm publish"
},
"repository": {
"type": "git",
"url": "githttps://github.com/BrianWalkerToretto/watermark.git"
},
"author": "https://github.com/BrianWalkerToretto",
"license": "MIT",
"bugs": {
"url": "https://github.com/BrianWalkerToretto/watermark/issues"
},
"homepage": "https://github.com/BrianWalkerToretto/watermark#readme",
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.6.4",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-decorators": "^7.6.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-arrow-functions": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.6.2",
"@babel/polyfill": "^7.6.0",
"@babel/preset-env": "^7.6.3",
"@babel/register": "^7.6.2",
"@babel/runtime-corejs3": "^7.6.3",
"autoprefixer": "^9.7.0",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"core-js": "^3.3.5",
"cross-env": "^6.0.3",
"css-loader": "^3.2.0",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.5.0",
"eslint-import-resolver-webpack": "^0.11.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^2.2.0",
"html-webpack-plugin": "^3.2.0",
"husky": "^3.0.9",
"less": "^3.10.3",
"less-loader": "^5.0.0",
"lint-staged": "^9.4.2",
"lodash-webpack-plugin": "^0.11.5",
"postcss-loader": "^3.0.0",
"postcss-reporter": "^6.0.1",
"prettier": "^1.18.2",
"rimraf": "^3.0.0",
"style-loader": "^1.0.0",
"stylelint": "^11.1.1",
"stylelint-config-prettier": "^6.0.0",
"stylelint-config-recommended": "^3.0.0",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.9",
"webpack-dev-server": "^3.9.0",
"webpack-merge": "^4.2.2",
"webpack-node-externals": "^1.7.2"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all",
"last 2 versions",
"ie >= 8",
"iOS >= 8",
"Android >= 4"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
12 changes: 12 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const autoprefixer = require('autoprefixer');
const postcssReporter = require('postcss-reporter');

module.exports = () => ({
plugins: [
autoprefixer(),
postcssReporter({
clearReportedMessages: true, // 插件将在记录结果消息后清除它们。这样可以防止其他插件或您使用的任何运行程序再次记录相同的信息并引起混乱。
throwError: true // 在插件记录您的消息后,如果发现任何警告,它将引发错误。
})
]
});
15 changes: 15 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

import Dig from './dig';

const dig = Dig(
'/operation/statistics/record.gif',
{
mis: 'testUserName',
uid: '123123123',
un: '十点多'
});

// dig.send({
// ty: 'event',
// ev: 'click'
// })
Loading

0 comments on commit eea3b7e

Please sign in to comment.