@tko/provider.mustache 4.0.0-beta1.6 → 4.0.0
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/dist/AttributeMustacheProvider.js +19 -20
- package/dist/AttributeMustacheProvider.js.map +2 -2
- package/dist/TextMustacheProvider.js +16 -9
- package/dist/TextMustacheProvider.js.map +2 -2
- package/dist/index.cjs +712 -410
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +4 -10
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +4 -10
- package/dist/index.mjs.map +2 -2
- package/dist/mustacheParser.js +6 -8
- package/dist/mustacheParser.js.map +2 -2
- package/package.json +7 -8
- package/LICENSE +0 -22
- package/helpers/jasmine-interpolation-helpers.ts +0 -31
package/dist/index.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
+
// @tko/provider.mustache 🥊 4.0.0 ESM
|
|
1
2
|
"use strict";
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
} from "./AttributeMustacheProvider";
|
|
6
|
-
export {
|
|
7
|
-
default as TextMustacheProvider
|
|
8
|
-
} from "./TextMustacheProvider";
|
|
9
|
-
export {
|
|
10
|
-
parseInterpolation
|
|
11
|
-
} from "./mustacheParser";
|
|
3
|
+
export { default as AttributeMustacheProvider } from "./AttributeMustacheProvider";
|
|
4
|
+
export { default as TextMustacheProvider } from "./TextMustacheProvider";
|
|
5
|
+
export { parseInterpolation } from "./mustacheParser";
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;
|
|
4
|
+
"sourcesContent": ["export { default as AttributeMustacheProvider } from './AttributeMustacheProvider'\n\nexport { default as TextMustacheProvider } from './TextMustacheProvider'\n\nexport { parseInterpolation } from './mustacheParser'\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,WAAW,iCAAiC;AAErD,SAAS,WAAW,4BAA4B;AAEhD,SAAS,0BAA0B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
+
// @tko/provider.mustache 🥊 4.0.0 MJS
|
|
1
2
|
"use strict";
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
} from "./AttributeMustacheProvider";
|
|
6
|
-
export {
|
|
7
|
-
default as TextMustacheProvider
|
|
8
|
-
} from "./TextMustacheProvider";
|
|
9
|
-
export {
|
|
10
|
-
parseInterpolation
|
|
11
|
-
} from "./mustacheParser";
|
|
3
|
+
export { default as AttributeMustacheProvider } from "./AttributeMustacheProvider";
|
|
4
|
+
export { default as TextMustacheProvider } from "./TextMustacheProvider";
|
|
5
|
+
export { parseInterpolation } from "./mustacheParser";
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;
|
|
4
|
+
"sourcesContent": ["export { default as AttributeMustacheProvider } from './AttributeMustacheProvider'\n\nexport { default as TextMustacheProvider } from './TextMustacheProvider'\n\nexport { parseInterpolation } from './mustacheParser'\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,WAAW,iCAAiC;AAErD,SAAS,WAAW,4BAA4B;AAEhD,SAAS,0BAA0B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/mustacheParser.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
// @tko/provider.mustache 🥊 4.0.0 ESM
|
|
1
2
|
"use strict";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Parser
|
|
5
|
-
} from "@tko/utils.parser";
|
|
3
|
+
import { Parser } from "@tko/utils.parser";
|
|
6
4
|
const INNER_EXPRESSION = /^([\s\S]*)}}([\s\S]*?)\{\{([\s\S]*)$/;
|
|
7
5
|
const OUTER_EXPRESSION = /^([\s\S]*?)\{\{([\s\S]*)}}([\s\S]*)$/;
|
|
8
6
|
const BINDING_EXPRESSION = /^([^,"'{}()/:[\]\s]+)\s+([^\s:].*)/;
|
|
@@ -23,8 +21,8 @@ class Expression extends Interpolated {
|
|
|
23
21
|
const ownerDocument = textNode ? textNode.ownerDocument : document;
|
|
24
22
|
const firstChar = text[0];
|
|
25
23
|
const lastChar = text[text.length - 1];
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
let closeComment = true;
|
|
25
|
+
let binding;
|
|
28
26
|
if (firstChar === "#") {
|
|
29
27
|
if (lastChar === "/") {
|
|
30
28
|
binding = text.slice(1, -1);
|
|
@@ -73,13 +71,13 @@ export function* parseOuterMatch(outerMatch) {
|
|
|
73
71
|
if (!outerMatch) {
|
|
74
72
|
return;
|
|
75
73
|
}
|
|
76
|
-
|
|
74
|
+
const [pre, inner, post] = outerMatch.slice(1);
|
|
77
75
|
yield new Text(pre);
|
|
78
76
|
yield* innerParse(inner);
|
|
79
77
|
yield new Text(post);
|
|
80
78
|
}
|
|
81
79
|
export function* parseInterpolation(text) {
|
|
82
|
-
for (const textOrExpr of parseOuterMatch(text
|
|
80
|
+
for (const textOrExpr of parseOuterMatch(text?.match(OUTER_EXPRESSION))) {
|
|
83
81
|
if (textOrExpr.text) {
|
|
84
82
|
yield textOrExpr;
|
|
85
83
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/mustacheParser.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;
|
|
4
|
+
"sourcesContent": ["import { Parser } from '@tko/utils.parser'\n\nconst INNER_EXPRESSION = /^([\\s\\S]*)}}([\\s\\S]*?)\\{\\{([\\s\\S]*)$/\nconst OUTER_EXPRESSION = /^([\\s\\S]*?)\\{\\{([\\s\\S]*)}}([\\s\\S]*)$/\nconst BINDING_EXPRESSION = /^([^,\"'{}()/:[\\]\\s]+)\\s+([^\\s:].*)/\n\nclass Interpolated {\n text: string\n constructor(text: string) {\n this.text = text\n }\n\n trim(string) {\n return string === null ? '' : string.trim()\n }\n}\n\nclass Expression extends Interpolated {\n asAttr(context, globals, node) {\n return new Parser().parseExpression(this.text, context, globals, node)()\n }\n\n *textNodeReplacement(textNode) {\n const text = this.trim(this.text)\n const ownerDocument = textNode ? textNode.ownerDocument : document\n const firstChar = text[0]\n const lastChar = text[text.length - 1]\n let closeComment = true\n let binding\n\n if (firstChar === '#') {\n if (lastChar === '/') {\n binding = text.slice(1, -1)\n } else {\n binding = text.slice(1)\n closeComment = false\n }\n const matches = binding.match(BINDING_EXPRESSION)\n if (matches) {\n binding = matches[1] + ':' + matches[2]\n }\n } else if (firstChar === '/') {\n // replace only with a closing comment\n } else if (firstChar === '{' && lastChar === '}') {\n binding = 'html:' + this.trim(text.slice(1, -1))\n } else {\n binding = 'text:' + this.trim(text)\n }\n\n if (binding) {\n yield ownerDocument.createComment('ko ' + binding)\n }\n if (closeComment) {\n yield ownerDocument.createComment('/ko')\n }\n }\n}\n\nclass Text extends Interpolated {\n asAttr(): string {\n return this.text\n }\n\n *textNodeReplacement() {\n yield document.createTextNode(this.text.replace(/\"/g, '\\\\\"'))\n }\n}\n\n/**\n * Interpolation Parsing\n */\nexport function* innerParse(text: string) {\n const innerMatch = text.match(INNER_EXPRESSION)\n if (innerMatch) {\n const [pre, inner, post] = innerMatch.slice(1)\n yield* innerParse(pre)\n yield new Text(inner)\n yield new Expression(post)\n } else {\n yield new Expression(text)\n }\n}\n\nexport function* parseOuterMatch(outerMatch?: RegExpMatchArray | null) {\n if (!outerMatch) {\n return\n }\n const [pre, inner, post] = outerMatch.slice(1)\n yield new Text(pre)\n yield* innerParse(inner)\n yield new Text(post)\n}\n\nexport function* parseInterpolation(text: string | null) {\n for (const textOrExpr of parseOuter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,OAAO;AAAA,IACnD;AACA,QAAI,cAAc;AAChB,YAAM,cAAc,cAAc,KAAK;AAAA,IACzC;AAAA,EACF;AACF;AAEA,MAAM,aAAa,aAAa;AAAA,EAC9B,SAAiB;AACf,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,CAAC,sBAAsB;AACrB,UAAM,SAAS,eAAe,KAAK,KAAK,QAAQ,MAAM,KAAK,CAAC;AAAA,EAC9D;AACF;AAKO,iBAAU,WAAW,MAAc;AACxC,QAAM,aAAa,KAAK,MAAM,gBAAgB;AAC9C,MAAI,YAAY;AACd,UAAM,CAAC,KAAK,OAAO,IAAI,IAAI,WAAW,MAAM,CAAC;AAC7C,WAAO,WAAW,GAAG;AACrB,UAAM,IAAI,KAAK,KAAK;AACpB,UAAM,IAAI,WAAW,IAAI;AAAA,EAC3B,OAAO;AACL,UAAM,IAAI,WAAW,IAAI;AAAA,EAC3B;AACF;AAEO,iBAAU,gBAAgB,YAAsC;AACrE,MAAI,CAAC,YAAY;AACf;AAAA,EACF;AACA,QAAM,CAAC,KAAK,OAAO,IAAI,IAAI,WAAW,MAAM,CAAC;AAC7C,QAAM,IAAI,KAAK,GAAG;AAClB,SAAO,WAAW,KAAK;AACvB,QAAM,IAAI,KAAK,IAAI;AACrB;AAEO,iBAAU,mBAAmB,MAAqB;AACvD,aAAW,cAAc,gBAAgB,MAAM,MAAM,gBAAgB,CAAC,GAAG;AACvE,QAAI,WAAW,MAAM;AACnB,YAAM;AAAA,IACR;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.0.0
|
|
2
|
+
"version": "4.0.0",
|
|
3
3
|
"name": "@tko/provider.mustache",
|
|
4
4
|
"description": "Interpolate text/node attributes {{ }}",
|
|
5
5
|
"module": "dist/provider.mustache.js",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://tko.io",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@tko/binding.template": "^4.0.0
|
|
27
|
-
"@tko/observable": "^4.0.0
|
|
28
|
-
"@tko/provider": "^4.0.0
|
|
29
|
-
"@tko/utils": "^4.0.0
|
|
30
|
-
"@tko/utils.parser": "^4.0.0
|
|
26
|
+
"@tko/binding.template": "^4.0.0",
|
|
27
|
+
"@tko/observable": "^4.0.0",
|
|
28
|
+
"@tko/provider": "^4.0.0",
|
|
29
|
+
"@tko/utils": "^4.0.0",
|
|
30
|
+
"@tko/utils.parser": "^4.0.0",
|
|
31
31
|
"tslib": "^2.2.0"
|
|
32
32
|
},
|
|
33
33
|
"karma": {
|
|
@@ -47,6 +47,5 @@
|
|
|
47
47
|
"import": "./dist/index.js"
|
|
48
48
|
},
|
|
49
49
|
"./helpers/*": "./helpers/*"
|
|
50
|
-
}
|
|
51
|
-
"gitHead": "c31dee2a2aa3f07e798d59e3aaf0da955dbcacb0"
|
|
50
|
+
}
|
|
52
51
|
}
|
package/LICENSE
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT) - http://www.opensource.org/licenses/mit-license.php
|
|
2
|
-
|
|
3
|
-
Copyright (c) Steven Sanderson, the Knockout.js team, and other contributors
|
|
4
|
-
http://knockoutjs.com/
|
|
5
|
-
|
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
in the Software without restriction, including without limitation the rights
|
|
9
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
furnished to do so, subject to the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be included in
|
|
14
|
-
all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
-
THE SOFTWARE.
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
arrayMap
|
|
4
|
-
} from '@tko/utils';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
jasmine.setNodeText = function(node, text) {
|
|
8
|
-
'textContent' in node ? node.textContent = text : node.innerText = text;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
jasmine.Matchers.prototype.toHaveNodeTypes = function (expectedTypes) {
|
|
12
|
-
var values = arrayMap(this.actual, function (node) {
|
|
13
|
-
return node.nodeType;
|
|
14
|
-
});
|
|
15
|
-
this.actual = values; // Fix explanatory message
|
|
16
|
-
return this.env.equals_(values, expectedTypes);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
function cleanedHtml(node) {
|
|
20
|
-
var cleanedHtml = node.innerHTML.toLowerCase().replace(/\r\n/g, "");
|
|
21
|
-
// IE < 9 strips whitespace immediately following comment nodes. Normalize by doing the same on all browsers.
|
|
22
|
-
cleanedHtml = cleanedHtml.replace(/(<!--.*?-->)\s*/g, "$1");
|
|
23
|
-
// Also remove __ko__ expando properties (for DOM data) - most browsers hide these anyway but IE < 9 includes them in innerHTML
|
|
24
|
-
cleanedHtml = cleanedHtml.replace(/ __ko__\d+=\"(ko\d+|null)\"/g, "");
|
|
25
|
-
return cleanedHtml;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
jasmine.Matchers.prototype.toContainHtmlElementsAndText = function (expectedHtml) {
|
|
29
|
-
this.actual = cleanedHtml(this.actual).replace(/<!--.+?-->/g, ""); // remove comments
|
|
30
|
-
return this.actual === expectedHtml;
|
|
31
|
-
};
|