ko-co 1.5.1 → 2.0.0

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.
package/CHANGELOG.md CHANGED
@@ -2,53 +2,67 @@
2
2
 
3
3
  The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
4
 
5
- ## [1.5.1] (2021-05-16)
5
+ ## 2.0.0 - 2026-12-06
6
+
7
+ ### Changed
8
+
9
+ - The CommonJS version is no longer using the Universal Module Definition (UMD), dropping support for AMD loading and the `window.koco` browser global.
10
+
11
+ ### Removed
12
+
13
+ - Removed support for ES5 environments; the library now targets `ES2015`.
14
+
15
+ ## 1.5.2 - 2024-05-26
16
+
17
+ The package repository has moved and it's now reflected in the package metadata; this version contains no functionality changes.
18
+
19
+ ## 1.5.1 - 2021-05-16
6
20
 
7
21
  ### Changed
8
22
 
9
23
  - Removed unnecessary files from the package making it more lightweight.
10
24
 
11
- ## [1.5.0] (2021-05-15)
25
+ ## 1.5.0 - 2021-05-15
12
26
 
13
27
  ### Added
14
28
 
15
29
  - Introduced an ESM version of this module that will be used when being imported using `import`.
16
30
 
17
- ### Updated
31
+ ### Changed
18
32
 
19
33
  - This module is now transpiled using Babel.
20
34
  - The UMD version of this module now exposes itself using the name `koco` instead of `KoCo`.
21
35
 
22
- ## [1.4.0] (2019-04-30)
36
+ ## 1.4.0 - 2019-04-30
23
37
 
24
38
  ### Added
25
39
 
26
40
  - Introduced a browser entry point that is ES5 compatible and minified.
27
41
 
28
- ## [1.3.0] (2018-12-06)
42
+ ## 1.3.0 - 2018-12-06
29
43
 
30
44
  ### Added
31
45
 
32
- - Introduced documentation to the Typescript type definitons.
46
+ - Introduced documentation to the Typescript type definitions.
33
47
 
34
- ## [1.2.1] (2018-02-07)
48
+ ## 1.2.1 - 2018-02-07
35
49
 
36
50
  ### Fixed
37
51
 
38
52
  - The `konamicode` event now fires even when the user has their caps lock enabled.
39
53
 
40
- ## [1.2.0] (2018-01-31)
54
+ ## 1.2.0 - 2018-01-31
41
55
 
42
56
  ### Changed
43
57
 
44
58
  - Updated `KoCo.addSupportForTheKonamiCode()` to return a function that will remove support for the Konami Code.
45
59
 
46
- ## [1.1.0] (2018-01-02)
60
+ ## 1.1.0 - 2018-01-02
47
61
 
48
62
  ### Changed
49
63
 
50
64
  - Updated the `konamicode` event so it is now cancelable.
51
65
 
52
- ## [1.0.0] (2017-05-16)
66
+ ## 1.0.0 - 2017-05-16
53
67
 
54
68
  The initial public release.
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017 - 2021 Luke Phillips
3
+ Copyright (c) 2017 - 2026 Luke Phillips
4
4
 
5
5
  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:
6
6
 
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # KoCo
1
+ # `ko-co`
2
2
 
3
3
  [![Available from NPM](https://img.shields.io/npm/v/ko-co.svg?maxAge=900)](https://www.npmjs.com/package/ko-co)
4
- [![Built using Travis](https://img.shields.io/travis/com/lsphillips/KoCo/master.svg?maxAge=900)](https://travis-ci.com/lsphillips/KoCo)
4
+ [![Built using GitHub Action](https://github.com/lsphillips/ko-co/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/lsphillips/ko-co/actions)
5
5
 
6
6
  Adds support for the Konami Code; making your website automatically cool.
7
7
 
@@ -92,7 +92,7 @@ npm install ko-co
92
92
 
93
93
  ### Building
94
94
 
95
- You can build UMD and ESM versions of this module that are both ES5 compatible and minified:
95
+ You can use esbuild to generate minified CommonJS and ESM bundles:
96
96
 
97
97
  ``` sh
98
98
  npm run build
@@ -106,7 +106,7 @@ This module also has a robust test suite:
106
106
  npm test
107
107
  ```
108
108
 
109
- This includes a code quality check using ESLint. Please refer to the `.eslintrc` files to familiar yourself with the rules.
109
+ This includes a code quality powered by Oxlint.
110
110
 
111
111
  ## License
112
112
 
package/ko-co.cjs CHANGED
@@ -1 +1 @@
1
- !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self).koco={})}(this,(function(e){"use strict";var o=["arrowup","arrowup","arrowdown","arrowdown","arrowleft","arrowright","arrowleft","arrowright","b","a"],t=[].concat(o,["enter"]);function n(e,o){var t,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=!0,i=!0;"function"==typeof window.CustomEvent?t=new window.CustomEvent(o,{detail:n,bubbles:r,cancelable:i}):(t=document.createEvent("CustomEvent")).initCustomEvent(o,r,i,n),e.dispatchEvent(t)}e.addSupportForTheKonamiCode=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.requireEnterPress,i=void 0!==r&&r,d=e.allowedTimeBetweenKeys,u=void 0===d?0:d,a=o,l=null,c=0;function f(e){return l&&clearTimeout(l),a[c]!==e.key.toLowerCase()?(l=null,void(c=0)):(++c,a.length===c?(l=null,c=0,void n(e.target,"konamicode",{})):void(u>0&&(l=setTimeout((function(){l=null,c=0}),u))))}return i&&(a=t),document.addEventListener("keydown",f,!0),function(){document.removeEventListener("keydown",f,!0)}},Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ var a=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var d=(o,e)=>{for(var r in e)a(o,r,{get:e[r],enumerable:!0})},l=(o,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of E(e))!f.call(o,t)&&t!==r&&a(o,t,{get:()=>e[t],enumerable:!(n=s(e,t))||n.enumerable});return o};var w=o=>l(a({},"__esModule",{value:!0}),o);var p={};d(p,{addSupportForTheKonamiCode:()=>v});module.exports=w(p);var c=["arrowup","arrowup","arrowdown","arrowdown","arrowleft","arrowright","arrowleft","arrowright","b","a"],m=[...c,"enter"];function C(o,e,r={}){let n,t=!0,u=!0;typeof window.CustomEvent=="function"?n=new window.CustomEvent(e,{detail:r,bubbles:t,cancelable:u}):(n=document.createEvent("CustomEvent"),n.initCustomEvent(e,t,u,r)),o.dispatchEvent(n)}function v({requireEnterPress:o=!1,allowedTimeBetweenKeys:e=0}={}){let r=c,n=null,t=0;o&&(r=m);function u(i){if(n&&clearTimeout(n),r[t]!==i.key.toLowerCase()){n=null,t=0;return}if(++t,r.length===t){n=null,t=0,C(i.target,"konamicode",{});return}e>0&&(n=setTimeout(function(){n=null,t=0},e))}return document.addEventListener("keydown",u,!0),function(){document.removeEventListener("keydown",u,!0)}}
package/ko-co.d.ts CHANGED
@@ -1,56 +1,56 @@
1
- /**
2
- * Options that define how a Konami Code sequence is detected.
3
- */
4
- export interface KonamiCodeDetectionOptions
5
- {
6
- /**
7
- * Determines whether the enter key is required to conclude a Konami Code sequence.
8
- */
9
- requireEnterPress? : boolean;
10
-
11
- /**
12
- * The maximum amount of time (in milliseconds) to wait between key presses before sequence progress is reset.
13
- */
14
- allowedTimeBetweenKeys? : number;
15
- }
16
-
17
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
18
-
19
- /**
20
- * A synchronous function that will remove support for the Konami Code.
21
- */
22
- export interface KonamiCodeSupportRemover
23
- {
24
- () : void
25
- }
26
-
27
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
28
-
29
- /**
30
- * Adds support for the Konami Code.
31
- *
32
- * Example usage:
33
- *
34
- * ``` js
35
- * koco.addSupportForTheKonamiCode(
36
- * {
37
- * allowedTimeBetweenKeys : 500
38
- * });
39
- * ```
40
- *
41
- * Once support is added, all elements will now fire a `konamicode` event whenever the user enters the Konami Code sequence:
42
- *
43
- * ``` js
44
- * target.addEventListener('konamicode', () =>
45
- * {
46
- * console.log('The Konami Code has been entered. 30 more lives for you!');
47
- * });
48
- * ```
49
- *
50
- * **Note:** The `konamicode` event bubbles and is cancelable.
51
- *
52
- * @param options Options that define how a Konami Code sequence is detected. By default, the enter key is not required to conclude the Konami Code sequence and it will wait indefinitely between key presses.
53
- *
54
- * @returns A synchronous function that can be called to remove support for the Konami Code.
55
- */
56
- export function addSupportForTheKonamiCode(options? : KonamiCodeDetectionOptions) : KonamiCodeSupportRemover;
1
+ /**
2
+ * Options that define how a Konami Code sequence is detected.
3
+ */
4
+ export interface KonamiCodeDetectionOptions
5
+ {
6
+ /**
7
+ * Determines whether the enter key is required to conclude a Konami Code sequence.
8
+ */
9
+ requireEnterPress? : boolean;
10
+
11
+ /**
12
+ * The maximum amount of time (in milliseconds) to wait between key presses before sequence progress is reset.
13
+ */
14
+ allowedTimeBetweenKeys? : number;
15
+ }
16
+
17
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
18
+
19
+ /**
20
+ * A synchronous function that will remove support for the Konami Code.
21
+ */
22
+ export interface KonamiCodeSupportRemover
23
+ {
24
+ () : void
25
+ }
26
+
27
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
28
+
29
+ /**
30
+ * Adds support for the Konami Code.
31
+ *
32
+ * Example usage:
33
+ *
34
+ * ``` js
35
+ * koco.addSupportForTheKonamiCode(
36
+ * {
37
+ * allowedTimeBetweenKeys : 500
38
+ * });
39
+ * ```
40
+ *
41
+ * Once support is added, all elements will now fire a `konamicode` event whenever the user enters the Konami Code sequence:
42
+ *
43
+ * ``` js
44
+ * target.addEventListener('konamicode', () =>
45
+ * {
46
+ * console.log('The Konami Code has been entered. 30 more lives for you!');
47
+ * });
48
+ * ```
49
+ *
50
+ * **Note:** The `konamicode` event bubbles and is cancelable.
51
+ *
52
+ * @param options Options that define how a Konami Code sequence is detected. By default, the enter key is not required to conclude the Konami Code sequence and it will wait indefinitely between key presses.
53
+ *
54
+ * @returns A synchronous function that can be called to remove support for the Konami Code.
55
+ */
56
+ export function addSupportForTheKonamiCode(options? : KonamiCodeDetectionOptions) : KonamiCodeSupportRemover;
package/ko-co.js CHANGED
@@ -1 +1 @@
1
- var e=["arrowup","arrowup","arrowdown","arrowdown","arrowleft","arrowright","arrowleft","arrowright","b","a"],n=[].concat(e,["enter"]);function t(e,n){var t,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=!0,i=!0;"function"==typeof window.CustomEvent?t=new window.CustomEvent(n,{detail:o,bubbles:r,cancelable:i}):(t=document.createEvent("CustomEvent")).initCustomEvent(n,r,i,o),e.dispatchEvent(t)}function o(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=o.requireEnterPress,i=void 0!==r&&r,u=o.allowedTimeBetweenKeys,a=void 0===u?0:u,d=e,l=null,w=0;function v(e){return l&&clearTimeout(l),d[w]!==e.key.toLowerCase()?(l=null,void(w=0)):(++w,d.length===w?(l=null,w=0,void t(e.target,"konamicode",{})):void(a>0&&(l=setTimeout((function(){l=null,w=0}),a))))}return i&&(d=n),document.addEventListener("keydown",v,!0),function(){document.removeEventListener("keydown",v,!0)}}export{o as addSupportForTheKonamiCode};
1
+ var a=["arrowup","arrowup","arrowdown","arrowdown","arrowleft","arrowright","arrowleft","arrowright","b","a"],c=[...a,"enter"];function s(u,o,n={}){let e,t=!0,r=!0;typeof window.CustomEvent=="function"?e=new window.CustomEvent(o,{detail:n,bubbles:t,cancelable:r}):(e=document.createEvent("CustomEvent"),e.initCustomEvent(o,t,r,n)),u.dispatchEvent(e)}function f({requireEnterPress:u=!1,allowedTimeBetweenKeys:o=0}={}){let n=a,e=null,t=0;u&&(n=c);function r(i){if(e&&clearTimeout(e),n[t]!==i.key.toLowerCase()){e=null,t=0;return}if(++t,n.length===t){e=null,t=0,s(i.target,"konamicode",{});return}o>0&&(e=setTimeout(function(){e=null,t=0},o))}return document.addEventListener("keydown",r,!0),function(){document.removeEventListener("keydown",r,!0)}}export{f as addSupportForTheKonamiCode};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name" : "ko-co",
3
3
 
4
- "version" : "1.5.1",
4
+ "version" : "2.0.0",
5
5
 
6
6
  "type" : "module",
7
7
 
@@ -20,34 +20,18 @@
20
20
  "cool"
21
21
  ],
22
22
 
23
- "homepage" : "https://github.com/lsphillips/KoCo",
23
+ "homepage" : "https://github.com/lsphillips/ko-co",
24
24
 
25
25
  "bugs" :
26
26
  {
27
- "url" : "https://github.com/lsphillips/KoCo/issues"
27
+ "url" : "https://github.com/lsphillips/ko-co/issues"
28
28
  },
29
29
 
30
30
  "devDependencies" :
31
31
  {
32
- "rollup" : "2.48.0",
33
- "rollup-plugin-terser" : "7.0.2",
34
- "@rollup/plugin-node-resolve" : "13.0.0",
35
- "@rollup/plugin-commonjs" : "19.0.0",
36
- "@rollup/plugin-babel" : "5.3.0",
37
- "mocha" : "8.4.0",
38
- "sinon" : "10.0.0",
39
- "eslint" : "7.26.0",
40
- "eslint-plugin-import" : "2.23.1",
41
- "eslint-plugin-promise" : "5.1.0",
42
- "eslint-config-protect-me-from-my-stupidity" : "7.2.1",
43
- "karma" : "6.3.2",
44
- "karma-mocha" : "2.0.1",
45
- "karma-mocha-reporter" : "2.2.5",
46
- "karma-rollup-preprocessor" : "7.0.7",
47
- "karma-chrome-launcher" : "3.1.0",
48
- "@babel/core" : "7.14.2",
49
- "@babel/preset-env" : "7.14.2",
50
- "timeout-as-promise" : "1.0.0"
32
+ "oxlint" : "1.96.0",
33
+ "esbuild" : "0.28.2",
34
+ "jsdom" : "31.0.1"
51
35
  },
52
36
 
53
37
  "main" : "ko-co.cjs",
@@ -72,18 +56,23 @@
72
56
  "repository" :
73
57
  {
74
58
  "type" : "git",
75
- "url" : "https://github.com/lsphillips/KoCo.git"
59
+ "url" : "https://github.com/lsphillips/ko-co.git"
76
60
  },
77
61
 
78
62
  "scripts" :
79
63
  {
80
- "test:lint" : "eslint \"**/*.{js,cjs}\" --ignore-path .gitignore",
81
- "test:unit" : "karma start karma.conf.cjs --single-run",
64
+ "test:lint" : "oxlint --deny-warnings",
65
+ "test:unit" : "node --test",
82
66
  "test" : "npm run test:lint && npm run test:unit",
83
- "build" : "rollup --config rollup.config.cjs",
67
+ "build" : "node build.js",
84
68
  "prepack" : "npm run test && npm run build"
85
69
  },
86
70
 
71
+ "allowScripts" :
72
+ {
73
+ "esbuild" : true
74
+ },
75
+
87
76
  "license" : "MIT",
88
77
 
89
78
  "types" : "ko-co.d.ts"