├── mocha.opts ├── demo ├── index.md ├── gallery.md ├── _config.yml ├── assets │ ├── css │ │ └── demo.css │ ├── html │ │ └── demo.html │ └── js │ │ └── demo.js ├── _includes │ ├── header.html │ ├── facebook.html │ ├── promo.html │ ├── head.html │ └── footer.html ├── _data │ └── egjs.yml ├── demo.md ├── 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 ├── _layouts │ ├── gallery.html │ └── page.html └── started.md ├── test ├── types │ ├── type-utils.ts │ ├── ComponentEvent.test-d.ts │ └── Component.test-d.ts ├── .eslintrc.js └── unit │ ├── ComponentEvent.spec.ts │ └── Component.spec.ts ├── .github ├── PULL_REQUEST_TEMPLATE.md ├── ISSUE_TEMPLATE.md └── stale.yml ├── src ├── utils.ts ├── index.ts ├── index.umd.ts ├── index.cjs.ts ├── ComponentEvent.ts ├── types.ts ├── ActualComponentEvent.ts └── Component.ts ├── tsconfig.eslint.json ├── .editorconfig ├── tsconfig.declaration.json ├── .npmignore ├── .travis.yml ├── tsconfig.test.json ├── tsconfig.json ├── rollup.config.js ├── config ├── commit.template └── validate-commit-msg.js ├── jsdoc.json ├── karma.conf.js ├── CONTRIBUTING.md ├── package.json ├── .gitignore ├── README.md └── .eslintrc.js /mocha.opts: -------------------------------------------------------------------------------- 1 | ---timeout 10000 -------------------------------------------------------------------------------- /demo/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | --- 4 | -------------------------------------------------------------------------------- /demo/gallery.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: gallery 3 | --- 4 | -------------------------------------------------------------------------------- /test/types/type-utils.ts: -------------------------------------------------------------------------------- 1 | export const test = (testName: string, func: (...args: any[]) => any) => {}; 2 | -------------------------------------------------------------------------------- /demo/_config.yml: -------------------------------------------------------------------------------- 1 | # Build settings 2 | source: demo 3 | destination: demo/_site 4 | exclude: [started.md, demo.md] 5 | markdown: kramdown -------------------------------------------------------------------------------- /demo/assets/css/demo.css: -------------------------------------------------------------------------------- 1 | .demo { 2 | margin-bottom: "20px"; 3 | border-radius: "4px"; 4 | } 5 | 6 | .desc { 7 | margin: 10px; 8 | } 9 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Issue 2 | 3 | 4 | ## Details 5 | 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | 4 | ## Steps to check or reproduce 5 | 6 | -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 NAVER Corp. 3 | * egjs projects are licensed under the MIT license 4 | */ 5 | export const isUndefined = (value: any): value is undefined => typeof value === "undefined"; 6 | -------------------------------------------------------------------------------- /tsconfig.eslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": [ 4 | "./src/**/*.ts", 5 | "./test/**/*.ts", 6 | "./demo/**/*.ts", 7 | "./**/*.js", 8 | "./**/.*.js" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_style = space 8 | indent_size = 2 9 | insert_final_newline = true 10 | max_line_length = 80 11 | trim_trailing_whitespace = true 12 | -------------------------------------------------------------------------------- /tsconfig.declaration.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "removeComments": true, 5 | "declaration": true, 6 | "emitDeclarationOnly": true, 7 | "declarationDir": "declaration", 8 | "strictNullChecks": false, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 NAVER Corp. 3 | * egjs projects are licensed under the MIT license 4 | */ 5 | import Component from "./Component"; 6 | import ComponentEvent from "./ComponentEvent"; 7 | 8 | export { ComponentEvent }; 9 | export default Component; 10 | -------------------------------------------------------------------------------- /demo/_includes/header.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /demo/_includes/facebook.html: -------------------------------------------------------------------------------- 1 |
2 | 9 | -------------------------------------------------------------------------------- /demo/_data/egjs.yml: -------------------------------------------------------------------------------- 1 | component: Component 2 | home: //naver.github.io/egjs 3 | desc: A class used to manage events and options in a component. 4 | dist: 5 | - release/latest/dist/component.min.js 6 | hashtag: "#eventemitter #options #typescript" 7 | GA: UA-70842526-14 8 | github: 9 | user: naver 10 | repo: egjs-component 11 | js: 12 | - assets/js/demo.js 13 | css: 14 | - assets/css/demo.css 15 | -------------------------------------------------------------------------------- /.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 | CHANGELOG.md 23 | 24 | #editor settings 25 | .idea 26 | .editorconfig 27 | 28 | coverage/ 29 | node_modules/ 30 | .github 31 | .babelrc 32 | mocha.opts 33 | demo 34 | -------------------------------------------------------------------------------- /src/index.umd.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unsafe-member-access */ 2 | /* eslint-disable @typescript-eslint/no-unsafe-assignment */ 3 | /* 4 | * Copyright (c) 2015 NAVER Corp. 5 | * egjs projects are licensed under the MIT license 6 | */ 7 | import Component, * as modules from "./index"; 8 | 9 | for (const name in modules) { 10 | (Component as any)[name] = (modules as any)[name]; 11 | } 12 | export default Component; 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "12" 4 | dist: trusty 5 | sudo: false 6 | before_install: 7 | - npm install -g npm@latest 8 | - npm cache verify 9 | - npm cache clean --force 10 | - rm -rf package-lock.json 11 | install: 12 | - npm i 13 | addons: 14 | chrome: stable 15 | before_script: 16 | - npm run lint 17 | script: 18 | - npm run coverage 19 | - npm run test:types 20 | after_success: 21 | - npm run coveralls 22 | -------------------------------------------------------------------------------- /tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "noImplicitAny": false, 6 | "strictNullChecks": false, 7 | "noUnusedLocals": false, 8 | "experimentalDecorators": true, 9 | "types": [ 10 | "karma-chai", 11 | "mocha", 12 | ] 13 | }, 14 | "include": [ 15 | "./src/**/*.ts", 16 | "./test/unit/*.ts" 17 | ], 18 | "exclude": [ 19 | "./node_modules/**/*.ts" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./outjs/", 4 | "module": "es2015", 5 | "target": "es5", 6 | "moduleResolution": "node", 7 | "lib": ["es2015", "dom"], 8 | "sourceMap": true, 9 | "strictNullChecks": true, 10 | "downlevelIteration": true, 11 | "experimentalDecorators": true, 12 | "esModuleInterop": true, 13 | "baseUrl": "." 14 | }, 15 | "include": [ 16 | "./src/**/*.ts", 17 | ], 18 | "exclude": [ 19 | "node_modules" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /demo/demo.md: -------------------------------------------------------------------------------- 1 | ### Basic 2 | 3 | {% include_relative assets/html/demo.html %} 4 | 5 | ```ts 6 | import Component, { ComponentEvent } from "@egjs/component"; 7 | 8 | class Some extends Component<{ 9 | hi: ComponentEvent; 10 | }> { 11 | foo() { 12 | this.trigger(new ComponentEvent("hi")); // fire hi event. 13 | } 14 | } 15 | 16 | const some = new Some(); 17 | some.on("hi", e => { 18 | console.log("hi event fired"); 19 | console.log(e.eventType); // "hi" 20 | console.log(e.currentTarget); // some 21 | }); 22 | ``` 23 | -------------------------------------------------------------------------------- /src/index.cjs.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unsafe-assignment */ 2 | /* eslint-disable @typescript-eslint/no-unsafe-member-access */ 3 | /* 4 | * Copyright (c) 2015 NAVER Corp. 5 | * egjs projects are licensed under the MIT license 6 | */ 7 | import Component, * as modules from "./index"; 8 | 9 | for (const name in modules) { 10 | (Component as any)[name] = (modules as any)[name]; 11 | } 12 | 13 | declare const module: any; 14 | module.exports = Component; 15 | export default Component; 16 | export * from "./index"; 17 | -------------------------------------------------------------------------------- /demo/assets/html/demo.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 8 |
9 |
10 |
11 |
12 | -------------------------------------------------------------------------------- /test/types/ComponentEvent.test-d.ts: -------------------------------------------------------------------------------- 1 | import assert from "static-type-assert"; 2 | 3 | import ComponentEvent from "../../declaration/ComponentEvent"; 4 | 5 | import { test } from "./type-utils"; 6 | 7 | // ✅ 8 | test("Can be created without properties", () => { 9 | assert<"test">(new ComponentEvent("test").eventType); 10 | assert(new ComponentEvent("test").currentTarget); 11 | }); 12 | 13 | test("Can be created with properties", () => { 14 | assert(new ComponentEvent("test", { a: 1, b: 2 }).a); 15 | assert(new ComponentEvent("test", { a: 1, b: 2 }).b); 16 | }); 17 | -------------------------------------------------------------------------------- /src/ComponentEvent.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 NAVER Corp. 3 | * egjs projects are licensed under the MIT license 4 | */ 5 | import ActualComponentEvent from "./ActualComponentEvent"; 6 | import { ComponentEventConstructor, DefaultProps } from "./types"; 7 | 8 | // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unsafe-assignment 9 | const ComponentEvent = ActualComponentEvent as ComponentEventConstructor; 10 | 11 | // eslint-disable-next-line @typescript-eslint/ban-types 12 | type ComponentEvent = DefaultProps & PROPS; 13 | 14 | export default ComponentEvent; 15 | -------------------------------------------------------------------------------- /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 |
-------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | const buildHelper = require("@egjs/build-helper"); 3 | 4 | const name = "Component"; 5 | 6 | export default buildHelper([ 7 | { 8 | name, 9 | input: "./src/index.umd.ts", 10 | output: "./dist/component.js", 11 | format: "umd", 12 | }, 13 | { 14 | name, 15 | input: "./src/index.umd.ts", 16 | output: "./dist/component.min.js", 17 | format: "umd", 18 | uglify: true, 19 | }, 20 | { 21 | input: "./src/index.ts", 22 | output: "./dist/component.esm.js", 23 | format: "esm", 24 | exports: "named", 25 | }, 26 | { 27 | input: "./src/index.cjs.ts", 28 | output: "./dist/component.cjs.js", 29 | format: "cjs", 30 | exports: "named", 31 | }, 32 | ]); 33 | -------------------------------------------------------------------------------- /demo/_includes/head.html: -------------------------------------------------------------------------------- 1 | 2 | {{ site.data.egjs.github.repo }} 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "extends": [ 3 | "../.eslintrc.js" 4 | ], 5 | "parser": "@typescript-eslint/parser", 6 | "parserOptions": { 7 | "project": "./tsconfig.eslint.json", 8 | "sourceType": "module" 9 | }, 10 | "rules": { 11 | "max-classes-per-file": "off", 12 | "@typescript-eslint/ban-types": "off", 13 | "@typescript-eslint/no-unused-expressions": "off", 14 | "@typescript-eslint/no-unsafe-assignment": "off", 15 | "@typescript-eslint/no-unused-vars": "off", 16 | "@typescript-eslint/ban-ts-comment": "off", 17 | "@typescript-eslint/no-empty-function": "off", 18 | "@typescript-eslint/no-unsafe-member-access": "off", 19 | "@typescript-eslint/no-unsafe-call": "off", 20 | "@typescript-eslint/unbound-method": "off", 21 | "@jsdoc/check-indentation": "off" 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 | -------------------------------------------------------------------------------- /config/commit.template: -------------------------------------------------------------------------------- 1 | ========== Commit Format ========== 2 | (): 3 | 4 | (optional) 5 | 6 |