detect-is-it-html-or-xhtml 4.0.16 → 5.0.2

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
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 5.0.1 (2021-09-13)
7
+
8
+ ### Bug Fixes
9
+
10
+ - bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
11
+
12
+ ## 5.0.0 (2021-09-09)
13
+
14
+ ### Features
15
+
16
+ - migrate to ES Modules ([8c9d95d](https://github.com/codsen/codsen/commit/8c9d95d5dea0b769c2f070397141918a4893d575))
17
+
18
+ ### BREAKING CHANGES
19
+
20
+ - programs now are in ES Modules and won't work with Common JS require()
21
+
22
+ ## 4.1.0 (2021-05-24)
23
+
24
+ ### Features
25
+
26
+ - config file based major bump blacklisting ([e15f9bb](https://github.com/codsen/codsen/commit/e15f9bba1c4fd5f847ac28b3f38fa6ee633f5dca))
27
+
6
28
  ## 4.0.15 (2021-04-11)
7
29
 
8
30
  ### Reverts
package/README.md CHANGED
@@ -26,10 +26,14 @@
26
26
 
27
27
  ## Install
28
28
 
29
+ This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
30
+
29
31
  ```bash
30
32
  npm i detect-is-it-html-or-xhtml
31
33
  ```
32
34
 
35
+ If you need a legacy version which works with `require`, use version 4.1.0
36
+
33
37
  ## Quick Take
34
38
 
35
39
  ```js
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * @name detect-is-it-html-or-xhtml
3
3
  * @fileoverview Answers, is the string input string more an HTML or XHTML (or neither)
4
- * @version 4.0.16
4
+ * @version 5.0.2
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/detect-is-it-html-or-xhtml/}
8
8
  */
9
9
 
10
- var version$1 = "4.0.16";
10
+ var version$1 = "5.0.2";
11
11
 
12
12
  const version = version$1;
13
13
  function detectIsItHTMLOrXhtml(input) {
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @name detect-is-it-html-or-xhtml
3
3
  * @fileoverview Answers, is the string input string more an HTML or XHTML (or neither)
4
- * @version 4.0.16
4
+ * @version 5.0.2
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/detect-is-it-html-or-xhtml/}
8
8
  */
9
9
 
10
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).detectIsItHtmlOrXhtml={})}(this,(function(t){"use strict";t.detectIsItHTMLOrXhtml=function(t){if(!t)return null;if("string"!=typeof t)throw new TypeError("detect-is-it-html-or-xhtml: [THROW_ID_01] Input must be string");const e=/\/\s*>/g,n=t.match(/<\s*!\s*doctype[^>]*>/im);if(n){const t=/svg/gi;return n[0].match(/xhtml/gi)||n[0].match(t)?"xhtml":"html"}const i=t.match(/<\s*img[^>]*>/gi)||[],l=t.match(/<\s*br[^>]*>/gi)||[],o=t.match(/<\s*hr[^>]*>/gi)||[],r=i.concat(l).concat(o);if(0===r.length)return null;let s=0;for(let t=0,n=r.length;t<n;t++)null!=r[t].match(e)&&(s+=1);return s>r.length/2?"xhtml":"html"},t.version="4.0.16",Object.defineProperty(t,"__esModule",{value:!0})}));
10
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).detectIsItHtmlOrXhtml={})}(this,(function(t){"use strict";t.detectIsItHTMLOrXhtml=function(t){if(!t)return null;if("string"!=typeof t)throw new TypeError("detect-is-it-html-or-xhtml: [THROW_ID_01] Input must be string");const e=/\/\s*>/g,n=t.match(/<\s*!\s*doctype[^>]*>/im);if(n){const t=/svg/gi;return n[0].match(/xhtml/gi)||n[0].match(t)?"xhtml":"html"}const i=t.match(/<\s*img[^>]*>/gi)||[],l=t.match(/<\s*br[^>]*>/gi)||[],o=t.match(/<\s*hr[^>]*>/gi)||[],r=i.concat(l).concat(o);if(0===r.length)return null;let s=0;for(let t=0,n=r.length;t<n;t++)null!=r[t].match(e)&&(s+=1);return s>r.length/2?"xhtml":"html"},t.version="5.0.2",Object.defineProperty(t,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "detect-is-it-html-or-xhtml",
3
- "version": "4.0.16",
3
+ "version": "5.0.2",
4
4
  "description": "Answers, is the string input string more an HTML or XHTML (or neither)",
5
5
  "keywords": [
6
6
  "check",
@@ -30,9 +30,11 @@
30
30
  "email": "roy@codsen.com",
31
31
  "url": "https://codsen.com"
32
32
  },
33
- "main": "dist/detect-is-it-html-or-xhtml.cjs.js",
34
- "module": "dist/detect-is-it-html-or-xhtml.esm.js",
35
- "browser": "dist/detect-is-it-html-or-xhtml.umd.js",
33
+ "type": "module",
34
+ "exports": {
35
+ "script": "./dist/detect-is-it-html-or-xhtml.umd.js",
36
+ "default": "./dist/detect-is-it-html-or-xhtml.esm.js"
37
+ },
36
38
  "types": "types/index.d.ts",
37
39
  "scripts": {
38
40
  "build": "rollup -c",
@@ -52,18 +54,20 @@
52
54
  "pretest": "npm run build",
53
55
  "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
54
56
  "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
55
- "unittest": "./node_modules/.bin/tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf",
57
+ "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf",
56
58
  "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
57
59
  "clean_types": "../../scripts/cleanTypes.js"
58
60
  },
59
61
  "tap": {
62
+ "check-coverage": false,
60
63
  "coverage-report": [
61
64
  "json-summary",
62
65
  "text"
63
66
  ],
64
- "nyc-arg": [
65
- "--exclude=**/*.cjs.js",
66
- "--exclude=**/*.umd.js"
67
+ "node-arg": [
68
+ "--no-warnings",
69
+ "--experimental-loader",
70
+ "@istanbuljs/esm-loader-hook"
67
71
  ],
68
72
  "timeout": 0
69
73
  },
@@ -79,44 +83,47 @@
79
83
  }
80
84
  },
81
85
  "dependencies": {
82
- "@babel/runtime": "^7.13.10"
86
+ "@babel/runtime": "^7.15.4"
83
87
  },
84
88
  "devDependencies": {
85
- "@babel/cli": "^7.13.14",
86
- "@babel/core": "^7.13.14",
87
- "@babel/node": "^7.13.13",
88
- "@babel/plugin-external-helpers": "^7.12.13",
89
- "@babel/plugin-proposal-class-properties": "^7.13.0",
90
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.13.8",
91
- "@babel/plugin-proposal-object-rest-spread": "^7.13.8",
92
- "@babel/plugin-proposal-optional-chaining": "^7.13.12",
93
- "@babel/plugin-transform-runtime": "^7.13.10",
94
- "@babel/preset-env": "^7.13.12",
95
- "@babel/preset-typescript": "^7.13.0",
96
- "@babel/register": "^7.13.14",
89
+ "@babel/cli": "^7.15.4",
90
+ "@babel/core": "^7.15.5",
91
+ "@babel/node": "^7.15.4",
92
+ "@babel/plugin-external-helpers": "^7.14.5",
93
+ "@babel/plugin-proposal-class-properties": "^7.14.5",
94
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
95
+ "@babel/plugin-proposal-object-rest-spread": "^7.15.6",
96
+ "@babel/plugin-proposal-optional-chaining": "^7.14.5",
97
+ "@babel/plugin-transform-runtime": "^7.15.0",
98
+ "@babel/preset-env": "^7.15.6",
99
+ "@babel/preset-typescript": "^7.15.0",
100
+ "@babel/register": "^7.15.3",
101
+ "@istanbuljs/esm-loader-hook": "^0.1.2",
97
102
  "@rollup/plugin-babel": "^5.3.0",
98
- "@rollup/plugin-commonjs": "^18.0.0",
103
+ "@rollup/plugin-commonjs": "^20.0.0",
99
104
  "@rollup/plugin-json": "^4.1.0",
100
- "@rollup/plugin-node-resolve": "^11.2.1",
101
- "@rollup/plugin-replace": "^2.4.2",
102
- "@rollup/plugin-strip": "^2.0.0",
103
- "@rollup/plugin-typescript": "^8.2.1",
104
- "@types/node": "^14.14.37",
105
- "@types/tap": "^14.10.3",
106
- "@typescript-eslint/eslint-plugin": "^4.20.0",
107
- "@typescript-eslint/parser": "^4.20.0",
108
- "core-js": "^3.10.0",
105
+ "@rollup/plugin-node-resolve": "^13.0.4",
106
+ "@rollup/plugin-strip": "^2.1.0",
107
+ "@rollup/plugin-typescript": "^8.2.5",
108
+ "@types/node": "^16.9.1",
109
+ "@types/tap": "^15.0.5",
110
+ "@typescript-eslint/eslint-plugin": "^4.31.0",
111
+ "@typescript-eslint/parser": "^4.31.0",
112
+ "core-js": "^3.17.3",
109
113
  "cross-env": "^7.0.3",
110
- "eslint": "^7.23.0",
111
- "lect": "^0.16.16",
112
- "rollup": "^2.44.0",
114
+ "eslint": "^7.32.0",
115
+ "lect": "^0.18.2",
116
+ "rollup": "^2.56.3",
113
117
  "rollup-plugin-ascii": "^0.0.3",
114
118
  "rollup-plugin-banner": "^0.2.1",
115
119
  "rollup-plugin-cleanup": "^3.2.1",
116
- "rollup-plugin-dts": "^3.0.1",
120
+ "rollup-plugin-dts": "^4.0.0",
117
121
  "rollup-plugin-terser": "^7.0.2",
118
- "tap": "^14.11.0",
119
- "tslib": "^2.1.0",
120
- "typescript": "^4.2.3"
122
+ "tap": "^15.0.9",
123
+ "tslib": "^2.3.1",
124
+ "typescript": "^4.4.3"
125
+ },
126
+ "engines": {
127
+ "node": ">=12"
121
128
  }
122
129
  }
@@ -1,61 +0,0 @@
1
- /**
2
- * @name detect-is-it-html-or-xhtml
3
- * @fileoverview Answers, is the string input string more an HTML or XHTML (or neither)
4
- * @version 4.0.16
5
- * @author Roy Revelt, Codsen Ltd
6
- * @license MIT
7
- * {@link https://codsen.com/os/detect-is-it-html-or-xhtml/}
8
- */
9
-
10
- 'use strict';
11
-
12
- Object.defineProperty(exports, '__esModule', { value: true });
13
-
14
- var version$1 = "4.0.16";
15
-
16
- var version = version$1;
17
- function detectIsItHTMLOrXhtml(input) {
18
- function existy(x) {
19
- return x != null;
20
- }
21
- if (!input) {
22
- return null;
23
- }
24
- if (typeof input !== "string") {
25
- throw new TypeError("detect-is-it-html-or-xhtml: [THROW_ID_01] Input must be string");
26
- }
27
- var metaTag = /<\s*!\s*doctype[^>]*>/im;
28
- var imgTag = /<\s*img[^>]*>/gi;
29
- var brTag = /<\s*br[^>]*>/gi;
30
- var hrTag = /<\s*hr[^>]*>/gi;
31
- var closingSlash = /\/\s*>/g;
32
- var extractedMetaTag = input.match(metaTag);
33
- if (extractedMetaTag) {
34
- var xhtmlRegex = /xhtml/gi;
35
- var svgRegex = /svg/gi;
36
- if (extractedMetaTag[0].match(xhtmlRegex) || extractedMetaTag[0].match(svgRegex)) {
37
- return "xhtml";
38
- }
39
- return "html";
40
- }
41
- var allImageTagsArr = input.match(imgTag) || [];
42
- var allBRTagsArr = input.match(brTag) || [];
43
- var allHRTagsArr = input.match(hrTag) || [];
44
- var allConcernedTagsArr = allImageTagsArr.concat(allBRTagsArr).concat(allHRTagsArr);
45
- if (allConcernedTagsArr.length === 0) {
46
- return null;
47
- }
48
- var slashCount = 0;
49
- for (var i = 0, len = allConcernedTagsArr.length; i < len; i++) {
50
- if (existy(allConcernedTagsArr[i].match(closingSlash))) {
51
- slashCount += 1;
52
- }
53
- }
54
- if (slashCount > allConcernedTagsArr.length / 2) {
55
- return "xhtml";
56
- }
57
- return "html";
58
- }
59
-
60
- exports.detectIsItHTMLOrXhtml = detectIsItHTMLOrXhtml;
61
- exports.version = version;
@@ -1,74 +0,0 @@
1
- /**
2
- * @name detect-is-it-html-or-xhtml
3
- * @fileoverview Answers, is the string input string more an HTML or XHTML (or neither)
4
- * @version 4.0.16
5
- * @author Roy Revelt, Codsen Ltd
6
- * @license MIT
7
- * {@link https://codsen.com/os/detect-is-it-html-or-xhtml/}
8
- */
9
-
10
- (function (global, factory) {
11
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
12
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
13
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.detectIsItHtmlOrXhtml = {}));
14
- }(this, (function (exports) { 'use strict';
15
-
16
- var version$1 = "4.0.16";
17
-
18
- const version = version$1;
19
- function detectIsItHTMLOrXhtml(input) {
20
- function existy(x) {
21
- return x != null;
22
- }
23
- if (!input) {
24
- return null;
25
- }
26
- if (typeof input !== "string") {
27
- throw new TypeError("detect-is-it-html-or-xhtml: [THROW_ID_01] Input must be string");
28
- }
29
- const metaTag = /<\s*!\s*doctype[^>]*>/im;
30
- const imgTag = /<\s*img[^>]*>/gi;
31
- const brTag = /<\s*br[^>]*>/gi;
32
- const hrTag = /<\s*hr[^>]*>/gi;
33
- const closingSlash = /\/\s*>/g;
34
- const extractedMetaTag = input.match(metaTag);
35
- if (extractedMetaTag) {
36
- // detect by doctype meta tag
37
- const xhtmlRegex = /xhtml/gi;
38
- const svgRegex = /svg/gi;
39
- if (extractedMetaTag[0].match(xhtmlRegex) ||
40
- extractedMetaTag[0].match(svgRegex)) {
41
- return "xhtml";
42
- }
43
- return "html";
44
- }
45
- // ELSE - detect by scanning single tags
46
- const allImageTagsArr = input.match(imgTag) || [];
47
- const allBRTagsArr = input.match(brTag) || [];
48
- const allHRTagsArr = input.match(hrTag) || [];
49
- // join all found tags
50
- const allConcernedTagsArr = allImageTagsArr
51
- .concat(allBRTagsArr)
52
- .concat(allHRTagsArr);
53
- if (allConcernedTagsArr.length === 0) {
54
- return null;
55
- }
56
- // count closing slashes
57
- let slashCount = 0;
58
- for (let i = 0, len = allConcernedTagsArr.length; i < len; i++) {
59
- if (existy(allConcernedTagsArr[i].match(closingSlash))) {
60
- slashCount += 1;
61
- }
62
- }
63
- if (slashCount > allConcernedTagsArr.length / 2) {
64
- return "xhtml";
65
- }
66
- return "html";
67
- }
68
-
69
- exports.detectIsItHTMLOrXhtml = detectIsItHTMLOrXhtml;
70
- exports.version = version;
71
-
72
- Object.defineProperty(exports, '__esModule', { value: true });
73
-
74
- })));