diff --git a/package-lock.json b/package-lock.json index fa79f1b..0e0ccc7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "zod": "^3.22.4" }, "devDependencies": { - "@babel/core": "7.26.0", + "@babel/core": "7.26.7", "@babel/preset-typescript": "^7.22.5", "@jest/globals": "^29.6.1", "@types/express": "^5.0.0", @@ -78,9 +78,9 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.26.2", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.2.tgz", - "integrity": "sha512-Z0WgzSEa+aUcdiJuCIqgujCshpMWgUpgOxXotrYPSA53hA3qopNaqcJpyr0hVb1FeWdnqFA35/fUtXgBK8srQg==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.5.tgz", + "integrity": "sha512-XvcZi1KWf88RVbF9wn8MN6tYFloU5qX8KjuF3E1PVBmJ9eypXfs4GRiJwLuTZL0iSnJUKn1BFPa5BPZZJyFzPg==", "dev": true, "license": "MIT", "engines": { @@ -88,22 +88,22 @@ } }, "node_modules/@babel/core": { - "version": "7.26.0", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.26.0.tgz", - "integrity": "sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg==", + "version": "7.26.7", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.26.7.tgz", + "integrity": "sha512-SRijHmF0PSPgLIBYlWnG0hyeJLwXE2CgpsXaMOrtt2yp9/86ALw6oUlj9KYuZ0JN07T4eBMVIW4li/9S1j2BGA==", "dev": true, "license": "MIT", "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.26.0", - "@babel/generator": "^7.26.0", - "@babel/helper-compilation-targets": "^7.25.9", + "@babel/code-frame": "^7.26.2", + "@babel/generator": "^7.26.5", + "@babel/helper-compilation-targets": "^7.26.5", "@babel/helper-module-transforms": "^7.26.0", - "@babel/helpers": "^7.26.0", - "@babel/parser": "^7.26.0", + "@babel/helpers": "^7.26.7", + "@babel/parser": "^7.26.7", "@babel/template": "^7.25.9", - "@babel/traverse": "^7.25.9", - "@babel/types": "^7.26.0", + "@babel/traverse": "^7.26.7", + "@babel/types": "^7.26.7", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -119,14 +119,14 @@ } }, "node_modules/@babel/generator": { - "version": "7.26.2", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.2.tgz", - "integrity": "sha512-zevQbhbau95nkoxSq3f/DC/SC+EEOUZd3DYqfSkMhY2/wfSeaHV1Ew4vk8e+x8lja31IbyuUa2uQ3JONqKbysw==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.5.tgz", + "integrity": "sha512-2caSP6fN9I7HOe6nqhtft7V4g7/V/gfDsC3Ag4W7kEzzvRGKqiv0pu0HogPiZ3KaVSoNDhUws6IJjDjpfmYIXw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/parser": "^7.26.2", - "@babel/types": "^7.26.0", + "@babel/parser": "^7.26.5", + "@babel/types": "^7.26.5", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^3.0.2" @@ -149,13 +149,13 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.9.tgz", - "integrity": "sha512-j9Db8Suy6yV/VHa4qzrj9yZfZxhLWQdVnRlXxmKLYlhWUVB1sB2G5sxuWYXk/whHD9iW76PmNzxZ4UCnTQTVEQ==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.26.5.tgz", + "integrity": "sha512-IXuyn5EkouFJscIDuFF5EsiSolseme1s0CZB+QxVugqJLYmKdxI1VfIBOst0SUu4rnk2Z7kqTwmoO1lp3HIfnA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.25.9", + "@babel/compat-data": "^7.26.5", "@babel/helper-validator-option": "^7.25.9", "browserslist": "^4.24.0", "lru-cache": "^5.1.1", @@ -332,27 +332,27 @@ } }, "node_modules/@babel/helpers": { - "version": "7.26.0", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.0.tgz", - "integrity": "sha512-tbhNuIxNcVb21pInl3ZSjksLCvgdZy9KwJ8brv993QtIVKJBBkYXz4q4ZbAv31GdnC+R90np23L5FbEBlthAEw==", + "version": "7.26.7", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.7.tgz", + "integrity": "sha512-8NHiL98vsi0mbPQmYAGWwfcFaOy4j2HY49fXJCfuDcdE7fMIsH9a7GdaeXpIBsbT7307WU8KCMp5pUVDNL4f9A==", "dev": true, "license": "MIT", "dependencies": { "@babel/template": "^7.25.9", - "@babel/types": "^7.26.0" + "@babel/types": "^7.26.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.26.2", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.2.tgz", - "integrity": "sha512-DWMCZH9WA4Maitz2q21SRKHo9QXZxkDsbNZoVD62gusNtNBBqDg9i7uOhASfTfIGNzW+O+r7+jAlM8dwphcJKQ==", + "version": "7.26.7", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.7.tgz", + "integrity": "sha512-kEvgGGgEjRUutvdVvZhbn/BxVt+5VSpwXz1j3WYXQbXDo8KzFOPNG2GQbdAiNq8g6wn1yKk7C/qrke03a84V+w==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.26.0" + "@babel/types": "^7.26.7" }, "bin": { "parser": "bin/babel-parser.js" @@ -614,17 +614,17 @@ } }, "node_modules/@babel/traverse": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.9.tgz", - "integrity": "sha512-ZCuvfwOwlz/bawvAuvcj8rrithP2/N55Tzz342AkTvq4qaWbGfmCk/tKhNaV2cthijKrPAA8SRJV5WWe7IBMJw==", + "version": "7.26.7", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.26.7.tgz", + "integrity": "sha512-1x1sgeyRLC3r5fQOM0/xtQKsYjyxmFjaOrLJNtZ81inNjyJHGIolTULPiSc/2qe1/qfpFLisLQYFnnZl7QoedA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.25.9", - "@babel/generator": "^7.25.9", - "@babel/parser": "^7.25.9", + "@babel/code-frame": "^7.26.2", + "@babel/generator": "^7.26.5", + "@babel/parser": "^7.26.7", "@babel/template": "^7.25.9", - "@babel/types": "^7.25.9", + "@babel/types": "^7.26.7", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -633,9 +633,9 @@ } }, "node_modules/@babel/types": { - "version": "7.26.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.0.tgz", - "integrity": "sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==", + "version": "7.26.7", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.7.tgz", + "integrity": "sha512-t8kDRGrKXyp6+tjUh7hw2RLyclsW4TRoRvRHtSyAX9Bb5ldlFh+90YAYY6awRXrlB4G5G2izNeGySpATlFzmOg==", "dev": true, "license": "MIT", "dependencies": { @@ -1537,9 +1537,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "22.10.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.2.tgz", - "integrity": "sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==", + "version": "22.13.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.1.tgz", + "integrity": "sha512-jK8uzQlrvXqEU91UxiK5J7pKHyzgnI1Qnl0QDHIgVGuolJhRb9EEl28Cj9b3rGR8B2lhFCtvIm5os8lFnO/1Ew==", "devOptional": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index b6bc8cd..948a440 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "zod": "^3.22.4" }, "devDependencies": { - "@babel/core": "7.26.0", + "@babel/core": "7.26.7", "@babel/preset-typescript": "^7.22.5", "@jest/globals": "^29.6.1", "@types/express": "^5.0.0", diff --git a/src/__tests__/unit/lib/co2js/index.test.ts b/src/__tests__/unit/lib/co2js/index.test.ts index 21c316c..803f94f 100644 --- a/src/__tests__/unit/lib/co2js/index.test.ts +++ b/src/__tests__/unit/lib/co2js/index.test.ts @@ -10,10 +10,10 @@ import {ERRORS} from '@grnsft/if-core/utils'; const {ConfigError, InputValidationError} = ERRORS; /** - * Disclaimer: the tests relying on carbon-operational values are unstable. + * Disclaimer: the tests relying on estimated-carbon values are unstable. * * The models used by co2js contain unversioned changes in the constants that - * go into the calculation of the carbon-operational value. + * go into the calculation of the estimated-carbon value. * * AzB copied these tests from the original plugin implementation * https://github.com/Green-Software-Foundation/if-unofficial-plugins/tree/main/src/lib/co2js @@ -79,7 +79,7 @@ describe('lib/co2js: ', () => { duration: 3600, 'network/data/bytes': 100000, 'green-web-host': true, - 'carbon-operational': 0.023, + 'estimated-carbon': 0.023, }, ]); }); @@ -131,7 +131,7 @@ describe('lib/co2js: ', () => { duration: 3600, 'network/data': 10, 'green-web-host': true, - 'carbon-operational': 2319.583, + 'estimated-carbon': 2319.583, }, ]); }); @@ -157,7 +157,7 @@ describe('lib/co2js: ', () => { duration: 3600, 'network/data/bytes': 100000, 'green-web-host': false, - 'carbon-operational': 0.029, + 'estimated-carbon': 0.029, }, ]); }); @@ -186,7 +186,7 @@ describe('lib/co2js: ', () => { duration: 3600, 'network/data/bytes': 100000, 'green-web-host': true, - 'carbon-operational': 0.025, + 'estimated-carbon': 0.025, }, ]); }); @@ -215,7 +215,7 @@ describe('lib/co2js: ', () => { duration: 3600, 'network/data/bytes': 100000, 'green-web-host': true, - 'carbon-operational': 0.012, + 'estimated-carbon': 0.012, }, ]); }); @@ -246,7 +246,7 @@ describe('lib/co2js: ', () => { timestamp: '2021-01-01T00:00:00Z', duration: 3600, 'network/data/bytes': 100000, - 'carbon-operational': 0.037, + 'estimated-carbon': 0.037, 'green-web-host': false, options: { dataReloadRatio: 0.6, diff --git a/src/lib/co2js/README.md b/src/lib/co2js/README.md index bec2806..ddf1b27 100644 --- a/src/lib/co2js/README.md +++ b/src/lib/co2js/README.md @@ -30,7 +30,7 @@ The value for `device`, `dataCenter`, or `networks` can be a number representing ## Returns -- `carbon-operational`: carbon emissions from the operation of the website, in grams of CO2e +- `estimated-carbon`: carbon emissions from the operation of the website, in grams of CO2e # IF Implementation @@ -87,7 +87,7 @@ You can run this by passing it to `if-run`. To compute the manifest file, first ```sh npm i -g @grnsft/if -npm i -g @tngtech/if-webpage-plugin +npm i -g @tngtech/if-webpage-plugins ``` Then, use the following command run from the project root to compute the manifest: @@ -144,7 +144,7 @@ tree: device: 560.98 dataCenter: country: TWN - carbon-operational: 0.11880509600000001 + carbon-operational: 0.119 ``` ## TypeScript diff --git a/src/lib/co2js/index.ts b/src/lib/co2js/index.ts index 70ec7d6..c2b1a1b 100644 --- a/src/lib/co2js/index.ts +++ b/src/lib/co2js/index.ts @@ -41,7 +41,7 @@ export const Co2js = PluginFactory({ return result ? { ...input, - 'carbon-operational': roundToDecimalPlaces(result, 3), + 'estimated-carbon': roundToDecimalPlaces(result, 3), } : input; });