From 615c8b06f9d37b83b23f8c0d4b1262ddb2305aa9 Mon Sep 17 00:00:00 2001 From: frankpagan Date: Wed, 14 Jun 2023 14:37:10 -0600 Subject: [PATCH 1/9] bump @cocreate dependencies --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 865210f..8a8aa5b 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,8 @@ "webpack-log": "^3.0.1" }, "dependencies": { - "@cocreate/crud-client": "^1.21.23", - "@cocreate/local-storage": "^1.7.20", - "@cocreate/observer": "^1.8.18" + "@cocreate/crud-client": "^1.21.24", + "@cocreate/local-storage": "^1.7.21", + "@cocreate/observer": "^1.8.19" } -} +} \ No newline at end of file From 345d8af1b8cf67fe98ee2314f52156701991076a Mon Sep 17 00:00:00 2001 From: frankpagan Date: Thu, 22 Jun 2023 15:21:06 -0600 Subject: [PATCH 2/9] fix: replace -target -selector --- demo/atomic-css.html | 10 +++--- demo/test.1.html | 85 +++++++++++++++++++++++++++++--------------- demo/test.html | 6 ++-- docs/index.html | 18 +++++----- 4 files changed, 73 insertions(+), 46 deletions(-) diff --git a/demo/atomic-css.html b/demo/atomic-css.html index e283f63..7a027d7 100644 --- a/demo/atomic-css.html +++ b/demo/atomic-css.html @@ -109,7 +109,7 @@

CoCreate helper CSS

+ hover-selector="[href='#css-parser-reference']">

Reference

Reference

+ hover-selector="[href='#css-parser-demo']">

Demo

Demo

show="#eye-slash" hide="#eye, #demo-preview" toggle="code-height" - toggle-target="#demo-code" + toggle-selector="#demo-code" >

Demo

show="#eye, #demo-preview" hide="#eye-slash" toggle="code-height" - toggle-target="#demo-code" + toggle-selector="#demo-code" >

Demo

+ fullscreen-selector="#playground"> diff --git a/demo/test.1.html b/demo/test.1.html index 4b043f0..9294abc 100644 --- a/demo/test.1.html +++ b/demo/test.1.html @@ -1,37 +1,64 @@ + + + + + CoCreateCSS - A utility first, atomic CSS framework + + - - - - - CoCreateCSS - A utility first, atomic CSS framework - - + + + + + + - - - - - - - - -
-
-

hello how are you

-
-
-

hello how are you

+ +
+
+

hello how are you

+
+
+

+ hello how are you +

+
+ Toggle Darkmode
- Toggle Darkmode
+ Toggle Darkmode
- Toggle Darkmode -
- - - - - \ No newline at end of file + + + + diff --git a/demo/test.html b/demo/test.html index c3c117a..eac34d3 100644 --- a/demo/test.html +++ b/demo/test.html @@ -71,7 +71,7 @@

Toggle Darkmode @@ -79,7 +79,7 @@

Toggle Darkmode @@ -98,7 +98,7 @@

id="menuL" class="position:fixed top:0px left:0px background:whitesmoke height:100vh width:50px width:300px:hover width:0px@xs" resizable - resize-target="[content_id='content']" + resize-selector="[content_id='content']" resize-property="margin-left" resize-value="width">

CoCreate utility CSS

share-width="700" share-media="https://cdn.cocreate.app/docs/css-parser.png" hover="display:block!important" - hover-target=".social-networks"> + hover-selector=".social-networks">

From 4e317efe622a6a741e7f26bcc26a5f70daf969c0 Mon Sep 17 00:00:00 2001 From: frankpagan Date: Thu, 3 Aug 2023 17:43:02 -0600 Subject: [PATCH 3/9] fix: crud attributes renamed --- CoCreate.config.js | 4 +-- demo/atomic-css.html | 14 ++++----- demo/test.1.html | 6 ++-- demo/test.html | 12 ++++---- docs/index.html | 20 ++++++------ src/index.js | 73 ++++++++++++++++++++++---------------------- 6 files changed, 64 insertions(+), 65 deletions(-) diff --git a/CoCreate.config.js b/CoCreate.config.js index a87a336..201359d 100644 --- a/CoCreate.config.js +++ b/CoCreate.config.js @@ -4,8 +4,8 @@ module.exports = { "host": "", "sources": [ { - "collection": "files", - "document": { + "array": "files", + "object": { "_id": "637ca39950234ef1671ce312", "name": "index.html", "path": "/docs/css-parser/index.html", diff --git a/demo/atomic-css.html b/demo/atomic-css.html index 7a027d7..8985bf1 100644 --- a/demo/atomic-css.html +++ b/demo/atomic-css.html @@ -23,8 +23,8 @@ @@ -42,7 +42,7 @@ -
+
@@ -1023,8 +1023,8 @@

Demo

diff --git a/demo/test.1.html b/demo/test.1.html index fcd54d6..3f4cda5 100644 --- a/demo/test.1.html +++ b/demo/test.1.html @@ -6,7 +6,7 @@ CoCreateCSS - A utility first, atomic CSS framework - + diff --git a/demo/test.html b/demo/test.html index fb6b6e4..722f93d 100644 --- a/demo/test.html +++ b/demo/test.html @@ -6,7 +6,7 @@ CoCreateCSS - A utility first, atomic CSS framework @@ -93,7 +93,7 @@

scroll-down="10" array="files" object="60395ef42b3ac232657040fd" - name="src"> + key="src">

+ key="src">
@@ -129,7 +129,7 @@

+ classkey="test"> hehehe
first one
diff --git a/docs/index.html b/docs/index.html index 2781cc3..d932b42 100644 --- a/docs/index.html +++ b/docs/index.html @@ -11,10 +11,10 @@ sizes="32x32" href="https://cocreate.app/images/favicon.ico" /> @@ -56,7 +56,7 @@ scroll-down="10" array="files" object="60395ef42b3ac232657040fd" - name="src"> + key="src"> + key="src">

Demo

lang="html" array="demos" object="" - name="demo" + key="demo" save="false" id="demo" class="height:100% width:100% outline:none border:none resize:none padding:5px"> diff --git a/src/index.js b/src/index.js index c5a9bb8..562f370 100644 --- a/src/index.js +++ b/src/index.js @@ -321,7 +321,7 @@ observer.init({ } }); -let linkTag = document.querySelector('link[parse], link[array][object][name]'); +let linkTag = document.querySelector('link[parse], link[array][object][key]'); if (linkTag) init(linkTag); From d2a289fad2c17058baa733f2068087ebd334a954 Mon Sep 17 00:00:00 2001 From: frankpagan Date: Tue, 8 Aug 2023 19:36:38 -0600 Subject: [PATCH 5/9] feat: getValue function and use element.save() to execute crud save --- src/index.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/index.js b/src/index.js index 562f370..6ac3b10 100644 --- a/src/index.js +++ b/src/index.js @@ -5,7 +5,7 @@ * SPDX-License-Identifier: MIT ********************************************************************************/ import observer from '@cocreate/observer'; -import crud from '@cocreate/crud-client'; +// import crud from '@cocreate/crud-client'; import localStorage from '@cocreate/local-storage'; const themes = ["light", "dark"]; @@ -42,6 +42,12 @@ function init(linkTag) { if (parse == 'true') { parseLinkCSS(); + linkTag.getValue = () => { + const onlyUnique = (value, index, self) => { + return self.indexOf(value) === index; + }; + return parsedCSS.concat(linkCSS).filter(onlyUnique) + } let elements = document.querySelectorAll("[class]"); initElements(elements); observerInit(); @@ -260,7 +266,8 @@ function addNewRules() { parsedCSS.splice(low, 0, rule); } if (tempStyleList.length > 0) - save(); + if (linkTag.save) + linkTag.save(); tempStyleList = []; } @@ -269,13 +276,14 @@ function save() { if (linkTag && linkTag.hasAttribute('object') && linkTag.getAttribute('save') != 'false') { clearTimeout(delayTimer); delayTimer = setTimeout(function () { - const onlyUnique = (value, index, self) => { - return self.indexOf(value) === index; - }; - - let css = parsedCSS.concat(linkCSS).filter(onlyUnique); - crud.save(linkTag, css.join('\r\n')); - }, 3000); + linkTag.save(); + // const onlyUnique = (value, index, self) => { + // return self.indexOf(value) === index; + // }; + + // let css = parsedCSS.concat(linkCSS).filter(onlyUnique); + // crud.save(linkTag, css.join('\r\n')); + }, 5000); } } From 4e0affd917c4dfd7cab0ae619490dcc2d0fc4a78 Mon Sep 17 00:00:00 2001 From: frankpagan Date: Sat, 12 Aug 2023 16:51:44 -0600 Subject: [PATCH 6/9] feat: element.setValue and Remove unused import statement and optimize code for joining parsedCSS and linkCSS arrays into a single string with unique values. Also, remove unused code related to saving the linkTag. --- src/index.js | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/index.js b/src/index.js index 6ac3b10..cc7685a 100644 --- a/src/index.js +++ b/src/index.js @@ -5,7 +5,6 @@ * SPDX-License-Identifier: MIT ********************************************************************************/ import observer from '@cocreate/observer'; -// import crud from '@cocreate/crud-client'; import localStorage from '@cocreate/local-storage'; const themes = ["light", "dark"]; @@ -43,10 +42,13 @@ function init(linkTag) { if (parse == 'true') { parseLinkCSS(); linkTag.getValue = () => { + const onlyUnique = (value, index, self) => { return self.indexOf(value) === index; }; - return parsedCSS.concat(linkCSS).filter(onlyUnique) + // let css = parsedCSS.concat(linkCSS).filter(onlyUnique); + // css.join('\r\n' + return parsedCSS.concat(linkCSS).filter(onlyUnique).join('\r\n') } let elements = document.querySelectorAll("[class]"); initElements(elements); @@ -271,22 +273,6 @@ function addNewRules() { tempStyleList = []; } -let delayTimer; -function save() { - if (linkTag && linkTag.hasAttribute('object') && linkTag.getAttribute('save') != 'false') { - clearTimeout(delayTimer); - delayTimer = setTimeout(function () { - linkTag.save(); - // const onlyUnique = (value, index, self) => { - // return self.indexOf(value) === index; - // }; - - // let css = parsedCSS.concat(linkCSS).filter(onlyUnique); - // crud.save(linkTag, css.join('\r\n')); - }, 5000); - } -} - const observerInit = () => { observer.init({ From ca37c3a9b101cfde1b0f95f16ff8ec5c1a84b76c Mon Sep 17 00:00:00 2001 From: frankpagan Date: Sat, 12 Aug 2023 16:52:16 -0600 Subject: [PATCH 7/9] fix: Remove redundant dependency This commit removes a redundant dependency, specifically "@cocreate/crud-client", from the package.json file. --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 8a8aa5b..d736d66 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,6 @@ "webpack-log": "^3.0.1" }, "dependencies": { - "@cocreate/crud-client": "^1.21.24", "@cocreate/local-storage": "^1.7.21", "@cocreate/observer": "^1.8.19" } From 6382cc56209d43a4b35309ef1c5745baccf3e0f4 Mon Sep 17 00:00:00 2001 From: frankpagan Date: Wed, 16 Aug 2023 16:23:40 -0600 Subject: [PATCH 8/9] fix: webpack.config and package.json make use of mode=production instead of process.env --- package.json | 2 +- webpack.config.js | 152 ++++++++++++++++++++++++---------------------- 2 files changed, 80 insertions(+), 74 deletions(-) diff --git a/package.json b/package.json index d736d66..cbfa1f8 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ }, "scripts": { "start": "npx webpack --config webpack.config.js", - "build": "NODE_ENV=production npx webpack --config webpack.config.js", + "build": "npx webpack --mode=production --config webpack.config.js", "dev": "npx webpack --config webpack.config.js --watch", "postinstall": "node -e \"const { execSync } = require('child_process'); try { execSync('coc --version', { stdio: 'ignore' }); } catch (error) { try { execSync('npm install -g @cocreate/cli', { stdio: 'inherit' }); console.log('Installed \"@cocreate/cli\" globally.'); } catch (error) { console.error('Failed to install \"@cocreate/cli\" globally:', error); } }\"" }, diff --git a/webpack.config.js b/webpack.config.js index 2d8e006..49cf3d5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,84 +1,90 @@ const path = require("path") const TerserPlugin = require("terser-webpack-plugin") const MiniCssExtractPlugin = require("mini-css-extract-plugin") -let isProduction = process.env.NODE_ENV === "production" const { CleanWebpackPlugin } = require("clean-webpack-plugin") -module.exports = { - entry: { - "CoCreate-css-parser": "./src/index.js", - }, - output: { - path: path.resolve(__dirname, "dist"), - filename: isProduction ? "[name].min.js" : "[name].js", - libraryTarget: "umd", - libraryExport: "default", - library: ["CoCreate", "css-parser"], - globalObject: "this", - }, +module.exports = (env, argv) => { + let isProduction = false + if (argv.mode === 'production') + isProduction = true - plugins: [ - new CleanWebpackPlugin(), - new MiniCssExtractPlugin({ - filename: "[name].css", - }), - ], - // Default mode for Webpack is production. - // Depending on mode Webpack will apply different things - // on final bundle. For now we don't need production's JavaScript - // minifying and other thing so let's set mode to development - mode: isProduction ? "production" : "development", - module: { - rules: [ - { - test: /.js$/, - exclude: /(node_modules)/, - use: { - loader: "babel-loader", - options: { - plugins: ["@babel/plugin-transform-modules-commonjs"], - }, + const config = { + entry: { + "CoCreate-css-parser": "./src/index.js", }, - }, - { - test: /.css$/i, - use: [ - { loader: "style-loader", options: { injectType: "linkTag" } }, - "file-loader", + output: { + path: path.resolve(__dirname, "dist"), + filename: isProduction ? "[name].min.js" : "[name].js", + libraryTarget: "umd", + libraryExport: "default", + library: ["CoCreate", "css-parser"], + globalObject: "this", + }, + + plugins: [ + new CleanWebpackPlugin(), + new MiniCssExtractPlugin({ + filename: "[name].css", + }), ], - }, - ], - }, + // Default mode for Webpack is production. + // Depending on mode Webpack will apply different things + // on final bundle. For now we don't need production's JavaScript + // minifying and other thing so let's set mode to development + mode: isProduction ? "production" : "development", + module: { + rules: [ + { + test: /.js$/, + exclude: /(node_modules)/, + use: { + loader: "babel-loader", + options: { + plugins: ["@babel/plugin-transform-modules-commonjs"], + }, + }, + }, + { + test: /.css$/i, + use: [ + { loader: "style-loader", options: { injectType: "linkTag" } }, + "file-loader", + ], + }, + ], + }, - // add source map - ...(isProduction ? {} : { devtool: "eval-source-map" }), + // add source map + ...(isProduction ? {} : { devtool: "eval-source-map" }), - optimization: { - minimize: true, - minimizer: [ - new TerserPlugin({ - extractComments: true, - // cache: true, - parallel: true, - // sourceMap: true, // Must be set to true if using source-maps in production - terserOptions: { - // https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions - // extractComments: 'all', - compress: { - drop_console: true, - }, - }, - }), - ], - splitChunks: { - chunks: "all", - minSize: 200, - // maxSize: 99999, - //minChunks: 1, + optimization: { + minimize: true, + minimizer: [ + new TerserPlugin({ + extractComments: true, + // cache: true, + parallel: true, + // sourceMap: true, // Must be set to true if using source-maps in production + terserOptions: { + // https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions + // extractComments: 'all', + compress: { + drop_console: true, + }, + }, + }), + ], + splitChunks: { + chunks: "all", + minSize: 200, + // maxSize: 99999, + //minChunks: 1, - cacheGroups: { - defaultVendors: false, - }, - }, - }, -} + cacheGroups: { + defaultVendors: false, + }, + }, + }, + } + return config +} \ No newline at end of file From d0e9a629678cb4b9f880972ceb62eea217f30a1b Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 16 Aug 2023 23:32:07 +0000 Subject: [PATCH 9/9] chore(release): 1.8.0 [skip ci] # [1.8.0](https://github.com/CoCreate-app/CoCreate-css-parser/compare/v1.7.29...v1.8.0) (2023-08-16) ### Bug Fixes * crud attributes renamed ([4e317ef](https://github.com/CoCreate-app/CoCreate-css-parser/commit/4e317efe622a6a741e7f26bcc26a5f70daf969c0)) * Remove redundant dependency ([ca37c3a](https://github.com/CoCreate-app/CoCreate-css-parser/commit/ca37c3a9b101cfde1b0f95f16ff8ec5c1a84b76c)) * replace -target -selector ([345d8af](https://github.com/CoCreate-app/CoCreate-css-parser/commit/345d8af1b8cf67fe98ee2314f52156701991076a)) * webpack.config and package.json make use of mode=production instead of process.env ([6382cc5](https://github.com/CoCreate-app/CoCreate-css-parser/commit/6382cc56209d43a4b35309ef1c5745baccf3e0f4)) ### Features * element.setValue and Remove unused import statement and optimize code for joining parsedCSS and linkCSS arrays into a single string with unique values. Also, remove unused code related to saving the linkTag. ([4e0affd](https://github.com/CoCreate-app/CoCreate-css-parser/commit/4e0affd917c4dfd7cab0ae619490dcc2d0fc4a78)) * getValue function and use element.save() to execute crud save ([d2a289f](https://github.com/CoCreate-app/CoCreate-css-parser/commit/d2a289fad2c17058baa733f2068087ebd334a954)) * name attribute and variable renamed to key ([3a130e3](https://github.com/CoCreate-app/CoCreate-css-parser/commit/3a130e38f88c23c34ba294023f66732992103d6f)) --- CHANGELOG.md | 17 +++++++++++++++++ package.json | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1737ed3..1b516d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +# [1.8.0](https://github.com/CoCreate-app/CoCreate-css-parser/compare/v1.7.29...v1.8.0) (2023-08-16) + + +### Bug Fixes + +* crud attributes renamed ([4e317ef](https://github.com/CoCreate-app/CoCreate-css-parser/commit/4e317efe622a6a741e7f26bcc26a5f70daf969c0)) +* Remove redundant dependency ([ca37c3a](https://github.com/CoCreate-app/CoCreate-css-parser/commit/ca37c3a9b101cfde1b0f95f16ff8ec5c1a84b76c)) +* replace -target -selector ([345d8af](https://github.com/CoCreate-app/CoCreate-css-parser/commit/345d8af1b8cf67fe98ee2314f52156701991076a)) +* webpack.config and package.json make use of mode=production instead of process.env ([6382cc5](https://github.com/CoCreate-app/CoCreate-css-parser/commit/6382cc56209d43a4b35309ef1c5745baccf3e0f4)) + + +### Features + +* element.setValue and Remove unused import statement and optimize code for joining parsedCSS and linkCSS arrays into a single string with unique values. Also, remove unused code related to saving the linkTag. ([4e0affd](https://github.com/CoCreate-app/CoCreate-css-parser/commit/4e0affd917c4dfd7cab0ae619490dcc2d0fc4a78)) +* getValue function and use element.save() to execute crud save ([d2a289f](https://github.com/CoCreate-app/CoCreate-css-parser/commit/d2a289fad2c17058baa733f2068087ebd334a954)) +* name attribute and variable renamed to key ([3a130e3](https://github.com/CoCreate-app/CoCreate-css-parser/commit/3a130e38f88c23c34ba294023f66732992103d6f)) + ## [1.7.29](https://github.com/CoCreate-app/CoCreate-css-parser/compare/v1.7.28...v1.7.29) (2023-06-14) diff --git a/package.json b/package.json index cbfa1f8..4821f34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cocreate/css-parser", - "version": "1.7.29", + "version": "1.8.0", "description": "A simple css-parser component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.", "keywords": [ "css-parser", @@ -61,4 +61,4 @@ "@cocreate/local-storage": "^1.7.21", "@cocreate/observer": "^1.8.19" } -} \ No newline at end of file +}