diff --git a/Gruntfile.js b/Gruntfile.js index e0ba4b60..fe41a86f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,6 +1,6 @@ const fs = require('fs'); -function prepareFinalFile(content, stripAllImport = true, stripAllExport = true) { +function prepareFinalFile(content, stripAllImport = true, stripAllExport = true, transformToCommonJS = false) { // remove TimeZones iCal Library version output (do not do this, if your are using the time zone library standalone!) content = content.replace(/^console\.log\('Add to Calendar TimeZones iCal Library loaded \(version ' \+ tzlibVersion \+ '\)'\);$/m, ''); // add style inline @@ -39,9 +39,17 @@ function prepareFinalFile(content, stripAllImport = true, stripAllExport = true) // remove all export statements content = content.replace(/^export {[\w\s-_,]*};/gim, ''); } + if (transformToCommonJS) { + content = content + .replace(/tzlib_get_offset/gm, 'tzlibActions.tzlib_get_offset') + .replace(/tzlib_get_ical_block/gm, 'tzlibActions.tzlib_get_ical_block') + .replace(/tzlib_get_timezones/gm, 'tzlibActions.tzlib_get_timezones'); + } return content; } +const jsCoreFilesToCombine = ['src/atcb-globals.js', 'src/atcb-decorate.js', 'src/atcb-validate.js', 'src/atcb-control.js', 'src/atcb-generate.js', 'src/atcb-generate-rich-data.js', 'src/atcb-links.js', 'src/atcb-util.js', 'src/atcb-event.js', 'src/atcb-i18n.js', 'src/atcb-init.js']; + // The config. module.exports = function (grunt) { grunt.initConfig({ @@ -97,20 +105,7 @@ module.exports = function (grunt) { // generate the distributable JavaScript files (and also add a customized css file to the demo) concat: { main: { - src: [ - 'node_modules/timezones-ical-library/dist/tzlib.js', - 'src/atcb-globals.js', - 'src/atcb-decorate.js', - 'src/atcb-validate.js', - 'src/atcb-control.js', - 'src/atcb-generate.js', - 'src/atcb-generate-rich-data.js', - 'src/atcb-links.js', - 'src/atcb-util.js', - 'src/atcb-event.js', - 'src/atcb-i18n.js', - 'src/atcb-init.js', - ], + src: ['node_modules/timezones-ical-library/dist/tzlib.js', ...jsCoreFilesToCombine], // uncomment the following line instead of the line after (and also at line 161) that to additionally create a atcb script, which is not minified //dest: 'dist/atcb-unminified.js', dest: 'dist/atcb.js', @@ -120,7 +115,7 @@ module.exports = function (grunt) { }, }, module: { - src: ['src/atcb-globals.js', 'src/atcb-decorate.js', 'src/atcb-validate.js', 'src/atcb-control.js', 'src/atcb-generate.js', 'src/atcb-generate-rich-data.js', 'src/atcb-links.js', 'src/atcb-util.js', 'src/atcb-event.js', 'src/atcb-i18n.js', 'src/atcb-init.js'], + src: jsCoreFilesToCombine, dest: 'dist/module/index.js', options: { stripBanners: true, @@ -129,6 +124,16 @@ module.exports = function (grunt) { process: (content) => prepareFinalFile(content, true, true), }, }, + commonJS: { + src: jsCoreFilesToCombine, + dest: 'dist/commonjs/index.js', + options: { + stripBanners: true, + banner: "// eslint-disable-next-line @typescript-eslint/no-var-requires\r\nconst tzlibActions = require('timezones-ical-library');\r\n", + footer: 'module.exports = { atcb_action };', + process: (content) => prepareFinalFile(content, true, true, true), + }, + }, cssDemo: { src: ['assets/css/atcb.css'], dest: 'demo/public/atcb.css', @@ -145,6 +150,21 @@ module.exports = function (grunt) { done(); }, }, + 'package.json commonJS': { + 'dist/commonjs/package.json': function (fs, fd, done) { + fs.writeSync(fd, '{ "type": "commonjs" }'); + done(); + }, + }, + '.eslintrc.json commonJS': { + 'dist/commonjs/.eslintrc.json': function (fs, fd, done) { + fs.writeSync( + fd, + '{ "extends": "../../.eslintrc.json", "env": { "node": true }, "plugins": ["commonjs"] }' + ); + done(); + }, + }, }, // minifies the main js file uglify: { diff --git a/assets/css/atcb-3d.css b/assets/css/atcb-3d.css index fe9259b2..ed4fbee7 100644 --- a/assets/css/atcb-3d.css +++ b/assets/css/atcb-3d.css @@ -5,7 +5,7 @@ * * Style: 3D * - * Version: 2.0.2 + * Version: 2.1.0 * Creator: Jens Kuerschner (https://jenskuerschner.de) * Project: https://github.com/add2cal/add-to-calendar-button * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt) diff --git a/assets/css/atcb-date.css b/assets/css/atcb-date.css index cfad387a..24f57355 100644 --- a/assets/css/atcb-date.css +++ b/assets/css/atcb-date.css @@ -5,7 +5,7 @@ * * Style: Date * - * Version: 2.0.2 + * Version: 2.1.0 * Creator: Jens Kuerschner (https://jenskuerschner.de) * Project: https://github.com/add2cal/add-to-calendar-button * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt) diff --git a/assets/css/atcb-flat.css b/assets/css/atcb-flat.css index 1eb7f294..0c8c3a10 100644 --- a/assets/css/atcb-flat.css +++ b/assets/css/atcb-flat.css @@ -5,7 +5,7 @@ * * Style: Flat * - * Version: 2.0.2 + * Version: 2.1.0 * Creator: Jens Kuerschner (https://jenskuerschner.de) * Project: https://github.com/add2cal/add-to-calendar-button * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt) diff --git a/assets/css/atcb-neumorphism.css b/assets/css/atcb-neumorphism.css index 6050067d..e3c8af0e 100644 --- a/assets/css/atcb-neumorphism.css +++ b/assets/css/atcb-neumorphism.css @@ -5,7 +5,7 @@ * * Style: Neumorphism * - * Version: 2.0.2 + * Version: 2.1.0 * Creator: Jens Kuerschner (https://jenskuerschner.de) * Project: https://github.com/add2cal/add-to-calendar-button * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt) diff --git a/assets/css/atcb-round.css b/assets/css/atcb-round.css index c219f409..b1c231b3 100644 --- a/assets/css/atcb-round.css +++ b/assets/css/atcb-round.css @@ -5,7 +5,7 @@ * * Style: Round * - * Version: 2.0.2 + * Version: 2.1.0 * Creator: Jens Kuerschner (https://jenskuerschner.de) * Project: https://github.com/add2cal/add-to-calendar-button * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt) diff --git a/assets/css/atcb-text.css b/assets/css/atcb-text.css index 46d5e4b7..f5a23c99 100644 --- a/assets/css/atcb-text.css +++ b/assets/css/atcb-text.css @@ -5,7 +5,7 @@ * * Style: Text * - * Version: 2.0.2 + * Version: 2.1.0 * Creator: Jens Kuerschner (https://jenskuerschner.de) * Project: https://github.com/add2cal/add-to-calendar-button * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt) diff --git a/assets/css/atcb.css b/assets/css/atcb.css index 2f1e9271..80168d2c 100644 --- a/assets/css/atcb.css +++ b/assets/css/atcb.css @@ -5,7 +5,7 @@ * * Style: Default * - * Version: 2.0.2 + * Version: 2.1.0 * Creator: Jens Kuerschner (https://jenskuerschner.de) * Project: https://github.com/add2cal/add-to-calendar-button * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt) diff --git a/demo/public/atcb.css b/demo/public/atcb.css index 8c329b5d..6c47ae72 100644 --- a/demo/public/atcb.css +++ b/demo/public/atcb.css @@ -5,7 +5,7 @@ * * Style: Default * - * Version: 2.0.2 + * Version: 2.1.0 * Creator: Jens Kuerschner (https://jenskuerschner.de) * Project: https://github.com/add2cal/add-to-calendar-button * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt) diff --git a/demo/src/components/FooterArea.vue b/demo/src/components/FooterArea.vue index 478a2cde..5337a299 100644 --- a/demo/src/components/FooterArea.vue +++ b/demo/src/components/FooterArea.vue @@ -47,7 +47,7 @@ const { t, locale } = useI18n();