daily-color 1.3.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
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.0.0](https://github.com/aimeerivers/daily-color/compare/v1.3.1...v2.0.0) (2024-11-09)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * Importing with `require` will no longer work. Instead use `import { getDailyColor } from "daily-color";`
9
+
10
+ ### Features
11
+
12
+ * Convert to ES module ([#15](https://github.com/aimeerivers/daily-color/issues/15)) ([0444973](https://github.com/aimeerivers/daily-color/commit/04449739647216ddda101b5fdd4b3c7be2e0a662))
13
+
3
14
  ## [1.3.1](https://github.com/aimeerivers/daily-color/compare/v1.3.0...v1.3.1) (2024-11-09)
4
15
 
5
16
 
package/README.md CHANGED
@@ -15,7 +15,7 @@ npm install daily-color
15
15
  In a JavaScript/TypeScript project, using NPM:
16
16
 
17
17
  ```javascript
18
- const getDailyColor = require("daily-color");
18
+ import { getDailyColor } from "daily-color";
19
19
 
20
20
  console.log("Today's color is:", getDailyColor());
21
21
  ```
@@ -23,8 +23,9 @@ console.log("Today's color is:", getDailyColor());
23
23
  Directly loading the bundled JavaScript, for static projects not using NPM:
24
24
 
25
25
  ```html
26
- <script src="https://www.aimeerivers.com/daily-color/dist/daily-color.js"></script>
27
- <script>
26
+ <script type="module">
27
+ import { getDailyColor } from "https://www.aimeerivers.com/daily-color/dist/daily-color.js";
28
+
28
29
  console.log("Today's color is:", getDailyColor());
29
30
  </script>
30
31
  ```
package/bin/dailycolor.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const getDailyColor = require("../index");
3
+ import { getDailyColor } from "../index.js";
4
4
 
5
5
  console.log(getDailyColor());
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.getDailyColor=e():t.getDailyColor=e()}(self,(()=>{return t={237:t=>{t.exports=function(){const t=function(t){const e=t.getDate(),o=t.getMonth()+1,r=`${t.getFullYear()}-${o}-${e}`;let n=0;for(let t=0;t<r.length;t++)n=(n<<5)-n+r.charCodeAt(t),n|=0;return Math.abs(n)}(new Date),e=t>>8&255,o=255&t;return`#${(t>>16&255).toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}`}}},e={},function o(r){var n=e[r];if(void 0!==n)return n.exports;var a=e[r]={exports:{}};return t[r](a,a.exports,o),a.exports}(237);var t,e}));
1
+ var t={d:(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};function r(){const t=function(t){const e=t.getDate(),r=t.getMonth()+1,o=`${t.getFullYear()}-${r}-${e}`;let a=0;for(let t=0;t<o.length;t++)a=(a<<5)-a+o.charCodeAt(t),a|=0;return Math.abs(a)}(new Date),e=t>>8&255,r=255&t;return`#${(t>>16&255).toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}t.d(e,{x:()=>r});var o=e.x;export{o as getDailyColor};
package/index.html CHANGED
@@ -30,8 +30,9 @@
30
30
 
31
31
  <body>
32
32
  <div id="color"></div>
33
- <script src="https://www.aimeerivers.com/daily-color/dist/daily-color.js"></script>
34
- <script>
33
+ <script type="module">
34
+ import { getDailyColor } from "https://www.aimeerivers.com/daily-color/dist/daily-color.js";
35
+
35
36
  const color = getDailyColor();
36
37
  const colorDiv = document.getElementById("color");
37
38
  document.body.style.backgroundColor = color;
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- function getDailyColor() {
1
+ export function getDailyColor() {
2
2
  const date = new Date();
3
3
  const hash = getSimpleHash(date);
4
4
 
@@ -25,5 +25,3 @@ function getSimpleHash(date) {
25
25
 
26
26
  return Math.abs(hash);
27
27
  }
28
-
29
- module.exports = getDailyColor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "daily-color",
3
- "version": "1.3.1",
3
+ "version": "2.0.0",
4
4
  "description": "Provides a unique hex code each day",
5
5
  "keywords": [
6
6
  "color",
@@ -23,6 +23,7 @@
23
23
  "type": "git",
24
24
  "url": "git+https://github.com/aimeerivers/daily-color.git"
25
25
  },
26
+ "type": "module",
26
27
  "scripts": {
27
28
  "format": "prettier --write .",
28
29
  "format:check": "prettier --check .",
package/webpack.config.js CHANGED
@@ -1,12 +1,20 @@
1
- const path = require("path");
1
+ import path from "path";
2
+ import { fileURLToPath } from "url";
2
3
 
3
- module.exports = {
4
+ const __filename = fileURLToPath(import.meta.url);
5
+ const __dirname = path.dirname(__filename);
6
+
7
+ export default {
4
8
  entry: "./index.js",
5
9
  output: {
6
10
  path: path.resolve(__dirname, "dist"),
7
11
  filename: "daily-color.js",
8
- library: "getDailyColor",
9
- libraryTarget: "umd",
12
+ library: {
13
+ type: "module",
14
+ },
15
+ },
16
+ experiments: {
17
+ outputModule: true,
10
18
  },
11
19
  mode: "production",
12
20
  };