detect-templating-language 3.0.7 → 3.0.10

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/README.md CHANGED
@@ -38,6 +38,7 @@ If you need a legacy version which works with `require`, use version 2.1.0
38
38
 
39
39
  ```js
40
40
  import { strict as assert } from "assert";
41
+
41
42
  import { detectLang } from "detect-templating-language";
42
43
 
43
44
  // detects Nunjucks
@@ -57,7 +58,7 @@ assert.deepEqual(
57
58
 
58
59
  ## Documentation
59
60
 
60
- Please [visit codsen.com](https://codsen.com/os/detect-templating-language/) for a full description of the API and examples.
61
+ Please [visit codsen.com](https://codsen.com/os/detect-templating-language/) for a full description of the API.
61
62
 
62
63
  ## Contributing
63
64
 
@@ -69,4 +70,6 @@ MIT License
69
70
 
70
71
  Copyright (c) 2010-2021 Roy Revelt and other contributors
71
72
 
73
+
72
74
  <img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
75
+
@@ -1,41 +1,10 @@
1
1
  /**
2
2
  * @name detect-templating-language
3
3
  * @fileoverview Detects various templating languages present in string
4
- * @version 3.0.7
4
+ * @version 3.0.10
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/detect-templating-language/}
8
8
  */
9
9
 
10
- import { isJinjaNunjucksRegex } from 'regex-is-jinja-nunjucks';
11
- import { isJSP } from 'regex-is-jsp';
12
- import { isJinjaSpecific } from 'regex-jinja-specific';
13
-
14
- var version$1 = "3.0.7";
15
-
16
- const version = version$1;
17
- function detectLang(str) {
18
- let name = null;
19
- if (typeof str !== "string") {
20
- throw new TypeError(`detect-templating-language: [THROW_ID_01] Input must be string! It was given as ${JSON.stringify(str, null, 4)} (type ${typeof str}).`);
21
- }
22
- if (!str) {
23
- return {
24
- name,
25
- };
26
- }
27
- if (isJinjaNunjucksRegex().test(str)) {
28
- name = "Nunjucks";
29
- if (isJinjaSpecific().test(str)) {
30
- name = "Jinja";
31
- }
32
- }
33
- else if (isJSP().test(str)) {
34
- name = "JSP";
35
- }
36
- return {
37
- name,
38
- };
39
- }
40
-
41
- export { detectLang, version };
10
+ import{isJinjaNunjucksRegex as i}from"regex-is-jinja-nunjucks";import{isJSP as r}from"regex-is-jsp";import{isJinjaSpecific as a}from"regex-jinja-specific";var n="3.0.10";var g=n;function d(e){let t=null;if(typeof e!="string")throw new TypeError(`detect-templating-language: [THROW_ID_01] Input must be string! It was given as ${JSON.stringify(e,null,4)} (type ${typeof e}).`);return e?(i().test(e)?(t="Nunjucks",a().test(e)&&(t="Jinja")):r().test(e)&&(t="JSP"),{name:t}):{name:t}}export{d as detectLang,g as version};
@@ -1,18 +1,34 @@
1
1
  /**
2
2
  * @name detect-templating-language
3
3
  * @fileoverview Detects various templating languages present in string
4
- * @version 3.0.7
4
+ * @version 3.0.10
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/detect-templating-language/}
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).detectTemplatingLanguage={})}(this,(function(e){"use strict";
10
+ var detectTemplatingLanguage=(()=>{var i=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var d=e=>i(e,"__esModule",{value:!0});var m=(e,t)=>{for(var s in t)i(e,s,{get:t[s],enumerable:!0})},f=(e,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of l(t))!g.call(e,n)&&(s||n!=="default")&&i(e,n,{get:()=>t[n],enumerable:!(r=o(t,n))||r.enumerable});return e};var j=(e=>(t,s)=>e&&e.get(t)||(s=f(d({}),t,1),e&&e.set(t,s),s))(typeof WeakMap!="undefined"?new WeakMap:0);var h={};m(h,{detectLang:()=>x,version:()=>v});function a(){return/{%|{{|%}|}}/gi}function u(){return/<%|%>|<\s*jsp:|<\s*cms:|<\s*c:|\${\s*jsp/gi}function c(){return/(set\s*[\w]+\s*=\s*namespace\()|({{['"][\w]+['"]\s+if)|(['"]%x?[+0]?[.>^<]?\d+[\w%]['"]\|format\()/gi}var p="3.0.10";var v=p;function x(e){let t=null;if(typeof e!="string")throw new TypeError(`detect-templating-language: [THROW_ID_01] Input must be string! It was given as ${JSON.stringify(e,null,4)} (type ${typeof e}).`);return e?(a().test(e)?(t="Nunjucks",c().test(e)&&(t="Jinja")):u().test(e)&&(t="JSP"),{name:t}):{name:t}}return j(h);})();
11
11
  /**
12
12
  * @name regex-is-jinja-nunjucks
13
13
  * @fileoverview Regular expression for detecting Jinja or Nunjucks code
14
- * @version 3.0.7
14
+ * @version 3.0.10
15
15
  * @author Roy Revelt, Codsen Ltd
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/regex-is-jinja-nunjucks/}
18
- */e.detectLang=function(e){let t=null;if("string"!=typeof e)throw new TypeError(`detect-templating-language: [THROW_ID_01] Input must be string! It was given as ${JSON.stringify(e,null,4)} (type ${typeof e}).`);return e?(/{%|{{|%}|}}/gi.test(e)?(t="Nunjucks",/(set\s*[\w]+\s*=\s*namespace\()|({{['"][\w]+['"]\s+if)|(['"]%x?[+0]?[.>^<]?\d+[\w%]['"]\|format\()/gi.test(e)&&(t="Jinja")):/<%|%>|<\s*jsp:|<\s*cms:|<\s*c:|\${\s*jsp/gi.test(e)&&(t="JSP"),{name:t}):{name:t}},e.version="3.0.7",Object.defineProperty(e,"__esModule",{value:!0})}));
18
+ */
19
+ /**
20
+ * @name regex-is-jsp
21
+ * @fileoverview Regular expression for detecting JSP (Java Server Pages) code
22
+ * @version 3.0.10
23
+ * @author Roy Revelt, Codsen Ltd
24
+ * @license MIT
25
+ * {@link https://codsen.com/os/regex-is-jsp/}
26
+ */
27
+ /**
28
+ * @name regex-jinja-specific
29
+ * @fileoverview Regular expression for detecting Python-specific Jinja code
30
+ * @version 3.0.10
31
+ * @author Roy Revelt, Codsen Ltd
32
+ * @license MIT
33
+ * {@link https://codsen.com/os/regex-jinja-specific/}
34
+ */
@@ -1,6 +1,7 @@
1
1
  // Quick Take
2
2
 
3
3
  import { strict as assert } from "assert";
4
+
4
5
  import { detectLang } from "../dist/detect-templating-language.esm.js";
5
6
 
6
7
  // detects Nunjucks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "detect-templating-language",
3
- "version": "3.0.7",
3
+ "version": "3.0.10",
4
4
  "description": "Detects various templating languages present in string",
5
5
  "keywords": [
6
6
  "check",
@@ -29,92 +29,39 @@
29
29
  },
30
30
  "types": "types/index.d.ts",
31
31
  "scripts": {
32
- "build": "rollup -c",
33
- "build:esbuild": "node '../../scripts/esbuild.js'",
34
- "build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
35
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent",
36
- "clean_types": "../../scripts/cleanTypes.js",
37
- "dev": "rollup -c --dev",
38
- "devunittest": "npm run dev && tap --only -R 'base'",
39
- "format": "npm run lect && npm run prettier && npm run lint",
40
- "lect": "lect",
41
- "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
42
- "perf": "node perf/check",
43
- "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
44
- "republish": "npm publish || :",
45
- "tap": "tap",
46
- "pretest": "npm run build",
47
- "test": "npm run test:ci && npm run perf",
48
- "test:ci": "npm run unittest && npm run test:examples && npm run format",
49
- "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
50
- "tsc": "tsc",
51
- "unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
32
+ "build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
33
+ "dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
34
+ "dts": "rollup -c",
35
+ "examples": "node '../../ops/scripts/run-examples.js'",
36
+ "lect": "node '../../ops/lect/lect.js'",
37
+ "letspublish": "yarn publish || :",
38
+ "lint": "eslint . --fix",
39
+ "perf": "node perf/check.js",
40
+ "prepare": "echo 'ready'",
41
+ "pretest": "yarn run lect && yarn run build",
42
+ "test": "c8 yarn run unit && yarn run examples && yarn run lint",
43
+ "unit": "uvu test"
52
44
  },
53
- "tap": {
54
- "check-coverage": false,
55
- "node-arg": [
56
- "--no-warnings",
57
- "--experimental-loader",
58
- "@istanbuljs/esm-loader-hook"
45
+ "engines": {
46
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
47
+ },
48
+ "c8": {
49
+ "check-coverage": true,
50
+ "exclude": [
51
+ "**/test/**/*.*"
59
52
  ],
60
- "timeout": 0
53
+ "lines": 100
61
54
  },
62
55
  "lect": {
63
56
  "licence": {
64
57
  "extras": [
65
58
  ""
66
59
  ]
67
- },
68
- "req": "{ detectLang }",
69
- "various": {
70
- "devDependencies": []
71
60
  }
72
61
  },
73
62
  "dependencies": {
74
- "@babel/runtime": "^7.16.3",
75
- "regex-is-jinja-nunjucks": "^3.0.7",
76
- "regex-is-jsp": "^3.0.7",
77
- "regex-jinja-specific": "^3.0.7"
78
- },
79
- "devDependencies": {
80
- "@babel/cli": "^7.16.0",
81
- "@babel/core": "^7.16.0",
82
- "@babel/node": "^7.16.0",
83
- "@babel/plugin-external-helpers": "^7.16.0",
84
- "@babel/plugin-proposal-class-properties": "^7.16.0",
85
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
86
- "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
87
- "@babel/plugin-proposal-optional-chaining": "^7.16.0",
88
- "@babel/plugin-transform-runtime": "^7.16.4",
89
- "@babel/preset-env": "^7.16.4",
90
- "@babel/preset-typescript": "^7.16.0",
91
- "@babel/register": "^7.16.0",
92
- "@istanbuljs/esm-loader-hook": "^0.1.2",
93
- "@rollup/plugin-babel": "^5.3.0",
94
- "@rollup/plugin-commonjs": "^21.0.1",
95
- "@rollup/plugin-json": "^4.1.0",
96
- "@rollup/plugin-node-resolve": "^13.0.6",
97
- "@rollup/plugin-strip": "^2.1.0",
98
- "@rollup/plugin-typescript": "^8.3.0",
99
- "@types/node": "^16.11.10",
100
- "@types/tap": "^15.0.5",
101
- "@typescript-eslint/eslint-plugin": "^5.5.0",
102
- "@typescript-eslint/parser": "^5.5.0",
103
- "core-js": "^3.19.2",
104
- "cross-env": "^7.0.3",
105
- "eslint": "^8.3.0",
106
- "lect": "^0.18.7",
107
- "rollup": "^2.60.1",
108
- "rollup-plugin-ascii": "^0.0.3",
109
- "rollup-plugin-banner": "^0.2.1",
110
- "rollup-plugin-cleanup": "^3.2.1",
111
- "rollup-plugin-dts": "^4.0.1",
112
- "rollup-plugin-terser": "^7.0.2",
113
- "tap": "^15.1.5",
114
- "tslib": "^2.3.1",
115
- "typescript": "^4.5.2"
116
- },
117
- "engines": {
118
- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
63
+ "regex-is-jinja-nunjucks": "^3.0.10",
64
+ "regex-is-jsp": "^3.0.10",
65
+ "regex-jinja-specific": "^3.0.10"
119
66
  }
120
67
  }
package/types/index.d.ts CHANGED
File without changes
package/examples/api.json DELETED
@@ -1 +0,0 @@
1
- {"_quickTake.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; detectLang &#x7D; from \"detect-templating-language\";\n\n// detects Nunjucks\nassert.deepEqual(\n detectLang(`<div>&#x7B;% if something %&#x7D;x&#x7B;% else %&#x7D;y&#x7B;% endif %&#x7D;</div>`),\n &#x7B; name: \"Nunjucks\" &#x7D;\n);\n\n// detects JSP (Java Server Pages)\nassert.deepEqual(\n detectLang(\n `<div><c:set var=\"someList\" value=\"\\$&#x7B;jspProp.someList&#x7D;\" /></div>`\n ),\n &#x7B; name: \"JSP\" &#x7D;\n);"}}