mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-14 18:42:24 +03:00
chore: update build system and dependencies (#155)
* chore: fix swc + rollup transform * chore: fix pkg-task args parsing * chore: update lerna, rollup and swc to build proper es6 files * chore: fix swc build for es targets * ci: nodes matrix to newest versions * ci: rollup to mjs, swc to json * ci: add canary publish * ci: no git tag for canary * ci: no private publish for canary * ci: remove --canary from publish-canary * fix: remove gitHead from package.json * fix: tests setup * fix: bbob plugin helper imports * fix: plugin helper build priority and circular deps * fix: add nx for parallel build * fix: npm ci * fix: code ql * fix: remove exports directive * fix: rollup build * fix: vue2 test and minify * fix: bundle size limits * feat: bundlephobia pr review * feat: bundlephobia more popular action * feat: publish branch to npm * fix: secret NPM token * fix: bundlephobia version * fix: remove bundlephobia checker * fix: npm publish in PR * chore: release 2.8.3 * chore: fix test runs on CI, removed 14.x version * fix: sync package-lock * fix: remove lock files in sub packages * fix: bundlesize > bundlesize2 * fix: update lock files * fix: lock file in vue2-example
This commit is contained in:
@@ -3,6 +3,22 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.8.3](https://github.com/JiLiZART/bbob/compare/v2.8.2...v2.8.3) (2022-12-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* bbob plugin helper imports ([5f76548](https://github.com/JiLiZART/bbob/commit/5f76548b78b29f0905f74804e4a1d0634f085c1b))
|
||||
* bundle size limits ([edfdfed](https://github.com/JiLiZART/bbob/commit/edfdfedd06214ec9769f892407153d5b023e35aa))
|
||||
* code ql ([d6cbafe](https://github.com/JiLiZART/bbob/commit/d6cbafe8ba24e1e837333e644073a0e76c3eed07))
|
||||
* plugin helper build priority and circular deps ([cac47c6](https://github.com/JiLiZART/bbob/commit/cac47c6fc7e30c419691f7e8bc33f118211fc044))
|
||||
* remove exports directive ([a6efc40](https://github.com/JiLiZART/bbob/commit/a6efc4023b5cb09b56436a0dbe698423b2feecf1))
|
||||
* remove gitHead from package.json ([2b3ffa9](https://github.com/JiLiZART/bbob/commit/2b3ffa93233decdb3f2c93e91bd93582525f9210))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [2.8.2](https://github.com/JiLiZART/bbob/compare/v2.8.1...v2.8.2) (2022-11-28)
|
||||
|
||||
**Note:** Version bump only for package @bbob/plugin-helper
|
||||
|
||||
+9
-1
@@ -1,5 +1,13 @@
|
||||
{
|
||||
"name": "@bbob/plugin-helper",
|
||||
"version": "2.8.2",
|
||||
"lockfileVersion": 1
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@bbob/plugin-helper",
|
||||
"version": "2.8.2",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"bundlesize": [
|
||||
{
|
||||
"path": "./dist/index.min.js",
|
||||
"maxSize": "850 B"
|
||||
"maxSize": "1024 B"
|
||||
}
|
||||
],
|
||||
"publishConfig": {
|
||||
@@ -53,6 +53,5 @@
|
||||
"lib",
|
||||
"src",
|
||||
"es"
|
||||
],
|
||||
"gitHead": "01b0916b4a92c14e205397bebd58cf9c691cd540"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { OPEN_BRAKET, CLOSE_BRAKET, SLASH } from './char';
|
||||
import {
|
||||
getNodeLength, appendToNode, attrsToString, attrValue, getUniqAttr,
|
||||
} from './index';
|
||||
} from './helpers';
|
||||
|
||||
const getTagAttrs = (tag, params) => {
|
||||
const uniqAattr = getUniqAttr(params);
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
import { N } from './char';
|
||||
|
||||
const isTagNode = (el) => typeof el === 'object' && !!el.tag;
|
||||
const isStringNode = (el) => typeof el === 'string';
|
||||
const isEOL = (el) => el === N;
|
||||
|
||||
const keysReduce = (obj, reduce, def) => Object.keys(obj).reduce(reduce, def);
|
||||
|
||||
const getNodeLength = (node) => {
|
||||
if (isTagNode(node)) {
|
||||
return node.content.reduce((count, contentNode) => count + getNodeLength(contentNode), 0);
|
||||
} if (isStringNode(node)) {
|
||||
return node.length;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Appends value to Tag Node
|
||||
* @param {TagNode} node
|
||||
* @param value
|
||||
*/
|
||||
const appendToNode = (node, value) => {
|
||||
node.content.push(value);
|
||||
};
|
||||
|
||||
/**
|
||||
* Replaces " to &qquot;
|
||||
* @param {String} value
|
||||
*/
|
||||
const escapeHTML = (value) => value
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
// eslint-disable-next-line no-script-url
|
||||
.replace(/(javascript|data|vbscript):/gi, '$1%3A');
|
||||
|
||||
/**
|
||||
* Acept name and value and return valid html5 attribute string
|
||||
* @param {String} name
|
||||
* @param {String} value
|
||||
* @return {string}
|
||||
*/
|
||||
const attrValue = (name, value) => {
|
||||
const type = typeof value;
|
||||
|
||||
const types = {
|
||||
boolean: () => (value ? `${name}` : ''),
|
||||
number: () => `${name}="${value}"`,
|
||||
string: () => `${name}="${escapeHTML(value)}"`,
|
||||
object: () => `${name}="${escapeHTML(JSON.stringify(value))}"`,
|
||||
};
|
||||
|
||||
return types[type] ? types[type]() : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Transforms attrs to html params string
|
||||
* @param values
|
||||
*/
|
||||
const attrsToString = (values) => {
|
||||
// To avoid some malformed attributes
|
||||
if (values == null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return keysReduce(
|
||||
values,
|
||||
(arr, key) => [...arr, attrValue(key, values[key])],
|
||||
[''],
|
||||
).join(' ');
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets value from
|
||||
* @example
|
||||
* getUniqAttr({ 'foo': true, 'bar': bar' }) => 'bar'
|
||||
* @param attrs
|
||||
* @returns {string}
|
||||
*/
|
||||
const getUniqAttr = (attrs) => keysReduce(
|
||||
attrs,
|
||||
(res, key) => (attrs[key] === key ? attrs[key] : null),
|
||||
null,
|
||||
);
|
||||
|
||||
export {
|
||||
attrsToString,
|
||||
attrValue,
|
||||
appendToNode,
|
||||
escapeHTML,
|
||||
getNodeLength,
|
||||
getUniqAttr,
|
||||
isTagNode,
|
||||
isStringNode,
|
||||
isEOL,
|
||||
};
|
||||
@@ -1,100 +1,3 @@
|
||||
import { N } from './char';
|
||||
|
||||
const isTagNode = (el) => typeof el === 'object' && !!el.tag;
|
||||
const isStringNode = (el) => typeof el === 'string';
|
||||
const isEOL = (el) => el === N;
|
||||
|
||||
const keysReduce = (obj, reduce, def) => Object.keys(obj).reduce(reduce, def);
|
||||
|
||||
const getNodeLength = (node) => {
|
||||
if (isTagNode(node)) {
|
||||
return node.content.reduce((count, contentNode) => count + getNodeLength(contentNode), 0);
|
||||
} if (isStringNode(node)) {
|
||||
return node.length;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Appends value to Tag Node
|
||||
* @param {TagNode} node
|
||||
* @param value
|
||||
*/
|
||||
const appendToNode = (node, value) => {
|
||||
node.content.push(value);
|
||||
};
|
||||
|
||||
/**
|
||||
* Replaces " to &qquot;
|
||||
* @param {String} value
|
||||
*/
|
||||
const escapeHTML = (value) => value
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
// eslint-disable-next-line no-script-url
|
||||
.replace(/(javascript):/gi, '$1%3A');
|
||||
|
||||
/**
|
||||
* Acept name and value and return valid html5 attribute string
|
||||
* @param {String} name
|
||||
* @param {String} value
|
||||
* @return {string}
|
||||
*/
|
||||
const attrValue = (name, value) => {
|
||||
const type = typeof value;
|
||||
|
||||
const types = {
|
||||
boolean: () => (value ? `${name}` : ''),
|
||||
number: () => `${name}="${value}"`,
|
||||
string: () => `${name}="${escapeHTML(value)}"`,
|
||||
object: () => `${name}="${escapeHTML(JSON.stringify(value))}"`,
|
||||
};
|
||||
|
||||
return types[type] ? types[type]() : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Transforms attrs to html params string
|
||||
* @param values
|
||||
*/
|
||||
const attrsToString = (values) => {
|
||||
// To avoid some malformed attributes
|
||||
if (values == null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return keysReduce(
|
||||
values,
|
||||
(arr, key) => [...arr, attrValue(key, values[key])],
|
||||
[''],
|
||||
).join(' ');
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets value from
|
||||
* @example
|
||||
* getUniqAttr({ 'foo': true, 'bar': bar' }) => 'bar'
|
||||
* @param attrs
|
||||
* @returns {string}
|
||||
*/
|
||||
const getUniqAttr = (attrs) => keysReduce(
|
||||
attrs,
|
||||
(res, key) => (attrs[key] === key ? attrs[key] : null),
|
||||
null,
|
||||
);
|
||||
|
||||
export {
|
||||
attrsToString,
|
||||
attrValue,
|
||||
appendToNode,
|
||||
escapeHTML,
|
||||
getNodeLength,
|
||||
getUniqAttr,
|
||||
isTagNode,
|
||||
isStringNode,
|
||||
isEOL,
|
||||
};
|
||||
export * from './helpers';
|
||||
export * from './char';
|
||||
export { TagNode } from './TagNode';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import TagNode from '../src/TagNode'
|
||||
import { TagNode } from '../src'
|
||||
|
||||
describe('@bbob/plugin-helper/lib/TagNode', () => {
|
||||
describe('@bbob/plugin-helper/TagNode', () => {
|
||||
test('create', () => {
|
||||
const tagNode = TagNode.create('test', {test: 1}, ['Hello']);
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import {
|
||||
isEOL,
|
||||
} from '../src';
|
||||
|
||||
describe('@bbob/plugin-helper', () => {
|
||||
describe('@bbob/plugin-helper/helpers', () => {
|
||||
test('appendToNode', () => {
|
||||
const value = 'test';
|
||||
const node = { content: [] };
|
||||
Reference in New Issue
Block a user