├── .eslintignore ├── demo ├── index.md ├── gallery.md ├── assets │ ├── css │ │ └── demo.css │ ├── js │ │ └── demo.js │ └── html │ │ └── demo.html ├── _config.yml ├── _includes │ ├── header.html │ ├── facebook.html │ ├── promo.html │ ├── head.html │ └── footer.html ├── _data │ └── egjs.yml ├── common │ ├── css │ │ ├── gallery.css │ │ ├── monokai.css │ │ ├── page.css │ │ └── font-awesome.min.css │ ├── image │ │ ├── logo_mono.svg │ │ ├── type_white.svg │ │ ├── logo_mono_black.svg │ │ ├── type_black.svg │ │ ├── cp-arrow-right.svg │ │ └── logo.svg │ └── js │ │ ├── app.js │ │ └── bootstrap.min.js ├── demo.md ├── _layouts │ ├── gallery.html │ └── page.html └── started.md ├── test ├── node │ └── node.js ├── manual │ └── index.html └── unit │ ├── userAgentData.spec.ts │ ├── userAgent.spec.ts │ └── userAgentDataConsts.ts ├── global.d.ts ├── .github ├── PULL_REQUEST_TEMPLATE.md ├── ISSUE_TEMPLATE.md └── stale.yml ├── src ├── index.umd.ts ├── userAgent.ts ├── agent.ts ├── types.ts ├── userAgentData.ts ├── presets.ts └── utils.ts ├── tsconfig.declaration.json ├── .travis.yml ├── .editorconfig ├── .npmignore ├── jest.config.js ├── tsconfig.json ├── .eslintrc ├── rollup.config.js ├── config ├── commit.template └── validate-commit-msg.js ├── LICENSE ├── NOTICE ├── jsdoc.json ├── package.json ├── CONTRIBUTING.md ├── .gitignore └── README.md /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | *.js 4 | -------------------------------------------------------------------------------- /demo/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | --- 4 | -------------------------------------------------------------------------------- /demo/gallery.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: gallery 3 | --- 4 | -------------------------------------------------------------------------------- /demo/assets/css/demo.css: -------------------------------------------------------------------------------- 1 | /** css **/ 2 | .useragent-input { 3 | width: 100%; 4 | } 5 | -------------------------------------------------------------------------------- /test/node/node.js: -------------------------------------------------------------------------------- 1 | const cjs = require("../../dist/agent.cjs"); 2 | 3 | console.log("success", cjs()); 4 | -------------------------------------------------------------------------------- /demo/_config.yml: -------------------------------------------------------------------------------- 1 | # Build settings 2 | source: demo 3 | destination: demo/_site 4 | exclude: [started.md, demo.md] 5 | markdown: kramdown -------------------------------------------------------------------------------- /global.d.ts: -------------------------------------------------------------------------------- 1 | import { NavigatorUAData } from "./src/types"; 2 | 3 | declare global { 4 | interface Navigator { 5 | userAgentData: NavigatorUAData; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Issue 2 | 3 | 4 | ## Details 5 | 6 | -------------------------------------------------------------------------------- /src/index.umd.ts: -------------------------------------------------------------------------------- 1 | import agent, * as modules from "./agent"; 2 | 3 | for (const name in modules) { 4 | (agent as any)[name] = (modules as any)[name]; 5 | } 6 | 7 | export default agent; 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | 4 | ## Steps to check or reproduce 5 | 6 | -------------------------------------------------------------------------------- /tsconfig.declaration.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "removeComments": true, 5 | "declaration": true, 6 | "emitDeclarationOnly": true, 7 | "declarationDir": "declaration" 8 | }, 9 | "include": [ 10 | "./src/**/*.ts", 11 | "./global.d.ts", 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "12" 4 | dist: trusty 5 | sudo: required 6 | install: 7 | - npm install 8 | addons: 9 | chrome: stable 10 | cache: 11 | directories: 12 | - "node_modules" 13 | before_script: 14 | - npm run lint 15 | script: 16 | - npm run coverage 17 | after_success: 18 | - npm run coveralls 19 | -------------------------------------------------------------------------------- /demo/_includes/header.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /demo/_includes/facebook.html: -------------------------------------------------------------------------------- 1 |
2 | 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [{*.js,*.ts}] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_style = space 8 | indent_size = 4 9 | insert_final_newline = true 10 | max_line_length = 80 11 | trim_trailing_whitespace = true 12 | 13 | [{package.json,.travis.yml}] 14 | indent_style = space 15 | indent_size = 4 16 | 17 | [*] 18 | insert_final_newline = true 19 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | #configs 2 | config 3 | bower.json 4 | 5 | #tests 6 | test 7 | karma.conf.js 8 | 9 | #build tools 10 | webpack.*.js 11 | .travis.yml 12 | .codeclimate.yml 13 | 14 | #linters 15 | .eslintrc* 16 | 17 | #docs 18 | doc 19 | demo 20 | jsdoc.json 21 | README.md 22 | 23 | #editor settings 24 | .idea 25 | .editorconfig 26 | _site 27 | coverage/ 28 | node_modules/ 29 | .github 30 | .babelrc 31 | mocha.opts 32 | demo/ 33 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "roots": [ 3 | "", 4 | ], 5 | "transform": { 6 | "^.+\\.tsx?$": "ts-jest", 7 | }, 8 | "testMatch": ["/test/**/*.spec.ts"], 9 | // "testRegex": "spec\\.ts$", 10 | "moduleFileExtensions": [ 11 | "ts", 12 | "tsx", 13 | "js", 14 | "jsx", 15 | "json", 16 | "node", 17 | ], 18 | }; 19 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./outjs/", 4 | "esModuleInterop": false, 5 | "sourceMap": true, 6 | "module": "es2015", 7 | "target": "es5", 8 | "experimentalDecorators": true, 9 | "strict": true, 10 | "skipLibCheck": true, 11 | "moduleResolution": "node", 12 | "lib": [ 13 | "es2015", 14 | "dom" 15 | ], 16 | }, 17 | "include": [ 18 | "./src/**/*.ts", 19 | "./global.d.ts", 20 | "./test/**/*.ts" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /demo/_data/egjs.yml: -------------------------------------------------------------------------------- 1 | component: Agent 2 | home: //naver.github.io/egjs 3 | desc: Extracts browser and operating system information from the user agent string or user agent object(userAgentData). 4 | dist: 5 | - release/latest/dist/agent.min.js 6 | hashtag: "#user-agent-parser #browser-detection #client-hints" 7 | GA: UA-70842526-15 8 | github: 9 | user: naver 10 | repo: egjs-agent 11 | js: 12 | - https://cdnjs.cloudflare.com/ajax/libs/autosize.js/3.0.21/autosize.min.js 13 | - assets/js/demo.js 14 | css: 15 | - assets/css/demo.css -------------------------------------------------------------------------------- /demo/common/css/gallery.css: -------------------------------------------------------------------------------- 1 | .highlighter-rouge { 2 | display:none !important; 3 | } 4 | 5 | .docs { 6 | padding : 20px 0; 7 | } 8 | 9 | .docs .docs-inner { 10 | padding: 1px 30px 30px 30px; 11 | } 12 | 13 | .moreBtn { 14 | float: right; 15 | background: #000; 16 | border-radius: 42px; 17 | border: none; 18 | margin-top:6px; 19 | display: inline-block; 20 | cursor: pointer; 21 | color: rgb(255, 255, 255); 22 | font-size: 14px; 23 | font-weight: bold; 24 | padding: 4px 6px; 25 | text-decoration: none; 26 | } 27 | 28 | h3 { 29 | padding-left: 10px; 30 | border: 0px; 31 | border-left-width: 10px; 32 | border-color: #eebf3f; 33 | border-style: solid; 34 | } -------------------------------------------------------------------------------- /demo/_includes/promo.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

6 | {{ site.data.egjs.component }}v{{ site.data.version }} 7 |

8 |

{{ site.data.egjs.desc }}
9 | {{ site.data.egjs.hashtag }} 10 |

11 |
12 |
-------------------------------------------------------------------------------- /demo/_includes/head.html: -------------------------------------------------------------------------------- 1 | 2 | {{ site.data.egjs.github.repo }} 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "plugins": [ 5 | "@typescript-eslint" 6 | ], 7 | "extends": [ 8 | "eslint:recommended", 9 | "plugin:@typescript-eslint/eslint-recommended", 10 | "plugin:@typescript-eslint/recommended" 11 | ], 12 | "rules": { 13 | "@typescript-eslint/explicit-module-boundary-types": "off", 14 | "@typescript-eslint/no-explicit-any": "off", 15 | "@typescript-eslint/no-non-null-assertion": "off", 16 | "@typescript-eslint/no-empty-interface": "off", 17 | "no-empty-interface": "off", 18 | "comma-dangle": [ 19 | "error", 20 | "always-multiline" 21 | ], 22 | "semi": [ 23 | "error", 24 | "always" 25 | ] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /demo/demo.md: -------------------------------------------------------------------------------- 1 | {% include_relative assets/html/demo.html %} 2 | 3 | ```js 4 | var uaInput = document.querySelector(".useragent-input"); 5 | uaInput.addEventListener("input", function() { 6 | var agentInfo = eg.agent(); 7 | 8 | osName.innerHTML = agentInfo.os.name; 9 | osVersion.innerHTML = agentInfo.os.version; 10 | osMajorVersion.innerHTML = agentInfo.os.majorVersion; 11 | 12 | browserName.innerHTML = agentInfo.browser.name; 13 | browserVersion.innerHTML = agentInfo.browser.version; 14 | browserMajorVersion.innerHTML = agentInfo.browser.majorVersion; 15 | 16 | browserWebview.innerHTML = agentInfo.browser.webview; 17 | browserWebkit.innerHTML = agentInfo.browser.webkit; 18 | browserChromium.innerHTML = agentInfo.browser.chromium; 19 | 20 | isHints.innerHTML = agentInfo.isHints; 21 | isMobile.innerHTML = agentInfo.isMobile; 22 | }) 23 | ``` 24 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 30 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 7 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - wontstale 8 | # Label to use when marking an issue as stale 9 | staleLabel: stale 10 | # Comment to post when marking an issue as stale. Set to `false` to disable 11 | markComment: > 12 | This issue/PR has been automatically marked as stale because it has not had any update (including 13 | commits, comments, labels, milestones, etc) for 30 days. It will be closed automatically if no 14 | further update occurs in 7 day. Thank you for your contributions! 15 |
한글 16 | 이 이슈/PR은 commits, comments, labels, milestones 등 30일간 활동이 없어 자동으로 stale 상태로 전환되었습니다. 이후 7일간 활동이 없다면 자동으로 닫힐 예정입니다. 프로젝트 개선에 기여해주셔서 감사합니다. 17 |
18 | # Comment to post when closing a stale issue. Set to `false` to disable 19 | closeComment: false 20 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | 2 | const buildHelper = require("@egjs/build-helper"); 3 | 4 | const external = { 5 | "@egjs/axes": "eg.Axes", 6 | "@egjs/component": "eg.Component", 7 | } 8 | const name = "eg.agent"; 9 | 10 | export default buildHelper([ 11 | { 12 | name, 13 | input: "./src/index.umd.ts", 14 | output: "./dist/agent.js", 15 | exports: "default", 16 | format: "umd", 17 | }, 18 | { 19 | name, 20 | input: "./src/index.umd.ts", 21 | output: "./dist/agent.min.js", 22 | format: "umd", 23 | exports: "default", 24 | uglify: true, 25 | }, 26 | { 27 | input: "./src/agent.ts", 28 | output: "./dist/agent.esm.js", 29 | format: "esm", 30 | external, 31 | exports: "named", 32 | }, 33 | { 34 | input: "./src/index.umd.ts", 35 | output: "./dist/agent.cjs.js", 36 | format: "cjs", 37 | external, 38 | exports: "default", 39 | }, 40 | ]); 41 | 42 | -------------------------------------------------------------------------------- /config/commit.template: -------------------------------------------------------------------------------- 1 | ========== Commit Format ========== 2 | (): 3 | 4 | (optional) 5 | 6 |