@joker.front/core 1.2.139 → 1.2.142
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/bundle.es.js +26 -9
- package/dist/bundle.js +26 -9
- package/package.json +2 -2
- package/types/component.d.ts +2 -2
- package/types/parser/vnode.d.ts +5 -0
package/dist/bundle.es.js
CHANGED
|
@@ -1048,10 +1048,15 @@ var VNode;
|
|
|
1048
1048
|
* 组件节点
|
|
1049
1049
|
*/
|
|
1050
1050
|
class Component extends Node {
|
|
1051
|
+
/** 组件名(template标签名) */
|
|
1051
1052
|
name;
|
|
1053
|
+
/** 组件实例 */
|
|
1052
1054
|
component;
|
|
1055
|
+
/** 事件 */
|
|
1053
1056
|
events = [];
|
|
1057
|
+
/** 参数 */
|
|
1054
1058
|
propValues = {};
|
|
1059
|
+
/** 是否保持存活 */
|
|
1055
1060
|
keepalive;
|
|
1056
1061
|
/**
|
|
1057
1062
|
* 当前组件第一个element vnode
|
|
@@ -1205,8 +1210,7 @@ var Render;
|
|
|
1205
1210
|
}
|
|
1206
1211
|
}
|
|
1207
1212
|
else if (node instanceof VNode.Html) {
|
|
1208
|
-
|
|
1209
|
-
this.appendNode(node);
|
|
1213
|
+
node.output.root.innerHTML = node.html;
|
|
1210
1214
|
}
|
|
1211
1215
|
else {
|
|
1212
1216
|
logger.error(LOGTAG$4, `该节点不支持${propertyKey}的更新`, node);
|
|
@@ -1333,7 +1337,9 @@ var Render;
|
|
|
1333
1337
|
}
|
|
1334
1338
|
}
|
|
1335
1339
|
else if (node instanceof VNode.Html) {
|
|
1336
|
-
|
|
1340
|
+
let conatiner = document.createElement("joker-html-container");
|
|
1341
|
+
conatiner.root.innerHTML = node.html;
|
|
1342
|
+
node.output = conatiner;
|
|
1337
1343
|
}
|
|
1338
1344
|
else if (node instanceof VNode.Element) {
|
|
1339
1345
|
let element;
|
|
@@ -1726,6 +1732,16 @@ function toMs(s) {
|
|
|
1726
1732
|
return 0;
|
|
1727
1733
|
return Number(s.slice(0, -1).replace(",", ".")) * 1000;
|
|
1728
1734
|
}
|
|
1735
|
+
// 创建一个自定义元素
|
|
1736
|
+
class HtmlContainerWebComponent extends HTMLElement {
|
|
1737
|
+
root;
|
|
1738
|
+
constructor() {
|
|
1739
|
+
super();
|
|
1740
|
+
this.root = this.attachShadow({ mode: "open" });
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
// 注册自定义元素
|
|
1744
|
+
customElements.define("joker-html-container", HtmlContainerWebComponent);
|
|
1729
1745
|
|
|
1730
1746
|
//全局方法
|
|
1731
1747
|
const __GLONAL_FUNTIONS__ = {};
|
|
@@ -2226,19 +2242,19 @@ class ParserCode extends IParser {
|
|
|
2226
2242
|
logger.error("模板指令", "解析AST转换VNode时发生错误,未找到指令名称", this.ast);
|
|
2227
2243
|
throw new Error("解析AST转换VNode时发生错误,未找到指令名称");
|
|
2228
2244
|
}
|
|
2229
|
-
let
|
|
2245
|
+
let express = undefined;
|
|
2230
2246
|
//全局过滤器
|
|
2231
2247
|
if (this.ast.cmdName === "Html" || this.ast.cmdName === "Text") {
|
|
2232
|
-
|
|
2248
|
+
express = this.ast.param;
|
|
2233
2249
|
}
|
|
2234
2250
|
else if (this.ast.cmdName.startsWith(GLOBAL_TAG + ".")) {
|
|
2235
|
-
|
|
2251
|
+
express = `${this.ast.cmdName}(${this.ast.param})`;
|
|
2236
2252
|
}
|
|
2237
2253
|
else if (this.ast.cmdName in this.ob && typeof this.ob[this.ast.cmdName] === "function") {
|
|
2238
|
-
|
|
2254
|
+
express = `${createFuntionBody(this.ast.cmdName)}(${this.ast.param})`;
|
|
2239
2255
|
}
|
|
2240
|
-
if (
|
|
2241
|
-
let data = this.runExpressWithWatcher(
|
|
2256
|
+
if (express) {
|
|
2257
|
+
let data = this.runExpressWithWatcher(express, this.ob, (newVal) => {
|
|
2242
2258
|
if (this.node instanceof VNode.Html) {
|
|
2243
2259
|
this.node.html = transformText(newVal);
|
|
2244
2260
|
}
|
|
@@ -2250,6 +2266,7 @@ class ParserCode extends IParser {
|
|
|
2250
2266
|
});
|
|
2251
2267
|
data = transformText(data);
|
|
2252
2268
|
if (this.ast.cmdName === "Html") {
|
|
2269
|
+
data ||= [];
|
|
2253
2270
|
this.node = new VNode.Html(data, this.parent);
|
|
2254
2271
|
}
|
|
2255
2272
|
else {
|
package/dist/bundle.js
CHANGED
|
@@ -1049,10 +1049,15 @@ exports.VNode = void 0;
|
|
|
1049
1049
|
* 组件节点
|
|
1050
1050
|
*/
|
|
1051
1051
|
class Component extends Node {
|
|
1052
|
+
/** 组件名(template标签名) */
|
|
1052
1053
|
name;
|
|
1054
|
+
/** 组件实例 */
|
|
1053
1055
|
component;
|
|
1056
|
+
/** 事件 */
|
|
1054
1057
|
events = [];
|
|
1058
|
+
/** 参数 */
|
|
1055
1059
|
propValues = {};
|
|
1060
|
+
/** 是否保持存活 */
|
|
1056
1061
|
keepalive;
|
|
1057
1062
|
/**
|
|
1058
1063
|
* 当前组件第一个element vnode
|
|
@@ -1206,8 +1211,7 @@ var Render;
|
|
|
1206
1211
|
}
|
|
1207
1212
|
}
|
|
1208
1213
|
else if (node instanceof exports.VNode.Html) {
|
|
1209
|
-
|
|
1210
|
-
this.appendNode(node);
|
|
1214
|
+
node.output.root.innerHTML = node.html;
|
|
1211
1215
|
}
|
|
1212
1216
|
else {
|
|
1213
1217
|
logger.error(LOGTAG$4, `该节点不支持${propertyKey}的更新`, node);
|
|
@@ -1334,7 +1338,9 @@ var Render;
|
|
|
1334
1338
|
}
|
|
1335
1339
|
}
|
|
1336
1340
|
else if (node instanceof exports.VNode.Html) {
|
|
1337
|
-
|
|
1341
|
+
let conatiner = document.createElement("joker-html-container");
|
|
1342
|
+
conatiner.root.innerHTML = node.html;
|
|
1343
|
+
node.output = conatiner;
|
|
1338
1344
|
}
|
|
1339
1345
|
else if (node instanceof exports.VNode.Element) {
|
|
1340
1346
|
let element;
|
|
@@ -1727,6 +1733,16 @@ function toMs(s) {
|
|
|
1727
1733
|
return 0;
|
|
1728
1734
|
return Number(s.slice(0, -1).replace(",", ".")) * 1000;
|
|
1729
1735
|
}
|
|
1736
|
+
// 创建一个自定义元素
|
|
1737
|
+
class HtmlContainerWebComponent extends HTMLElement {
|
|
1738
|
+
root;
|
|
1739
|
+
constructor() {
|
|
1740
|
+
super();
|
|
1741
|
+
this.root = this.attachShadow({ mode: "open" });
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
// 注册自定义元素
|
|
1745
|
+
customElements.define("joker-html-container", HtmlContainerWebComponent);
|
|
1730
1746
|
|
|
1731
1747
|
//全局方法
|
|
1732
1748
|
const __GLONAL_FUNTIONS__ = {};
|
|
@@ -2227,19 +2243,19 @@ class ParserCode extends IParser {
|
|
|
2227
2243
|
logger.error("模板指令", "解析AST转换VNode时发生错误,未找到指令名称", this.ast);
|
|
2228
2244
|
throw new Error("解析AST转换VNode时发生错误,未找到指令名称");
|
|
2229
2245
|
}
|
|
2230
|
-
let
|
|
2246
|
+
let express = undefined;
|
|
2231
2247
|
//全局过滤器
|
|
2232
2248
|
if (this.ast.cmdName === "Html" || this.ast.cmdName === "Text") {
|
|
2233
|
-
|
|
2249
|
+
express = this.ast.param;
|
|
2234
2250
|
}
|
|
2235
2251
|
else if (this.ast.cmdName.startsWith(GLOBAL_TAG + ".")) {
|
|
2236
|
-
|
|
2252
|
+
express = `${this.ast.cmdName}(${this.ast.param})`;
|
|
2237
2253
|
}
|
|
2238
2254
|
else if (this.ast.cmdName in this.ob && typeof this.ob[this.ast.cmdName] === "function") {
|
|
2239
|
-
|
|
2255
|
+
express = `${ast.createFuntionBody(this.ast.cmdName)}(${this.ast.param})`;
|
|
2240
2256
|
}
|
|
2241
|
-
if (
|
|
2242
|
-
let data = this.runExpressWithWatcher(
|
|
2257
|
+
if (express) {
|
|
2258
|
+
let data = this.runExpressWithWatcher(express, this.ob, (newVal) => {
|
|
2243
2259
|
if (this.node instanceof exports.VNode.Html) {
|
|
2244
2260
|
this.node.html = transformText(newVal);
|
|
2245
2261
|
}
|
|
@@ -2251,6 +2267,7 @@ class ParserCode extends IParser {
|
|
|
2251
2267
|
});
|
|
2252
2268
|
data = transformText(data);
|
|
2253
2269
|
if (this.ast.cmdName === "Html") {
|
|
2270
|
+
data ||= [];
|
|
2254
2271
|
this.node = new exports.VNode.Html(data, this.parent);
|
|
2255
2272
|
}
|
|
2256
2273
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joker.front/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.142",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/bundle.js",
|
|
6
6
|
"module": "./dist/bundle.es.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"test": "jest",
|
|
23
|
-
"test:temp": "jest test/parser/
|
|
23
|
+
"test:temp": "jest test/parser/html.spec.ts",
|
|
24
24
|
"build": "joker_build_library --sourcemap=false",
|
|
25
25
|
"release": "npm run test && npm run build && joker_release_library",
|
|
26
26
|
"release:prod": "npm run test && npm run build && npm publish --access public --registry https://registry.npmjs.org/"
|
package/types/component.d.ts
CHANGED
|
@@ -94,11 +94,11 @@ export declare class Component<T extends DefaultKeyVal = {}> implements ICompone
|
|
|
94
94
|
/**
|
|
95
95
|
* 根据ref获取单个VNode
|
|
96
96
|
*/
|
|
97
|
-
$getRef<T extends VNode.Node>(ref: string): T | undefined;
|
|
97
|
+
$getRef<T extends VNode.Node = VNode.Element & VNode.Component>(ref: string): T | undefined;
|
|
98
98
|
/**
|
|
99
99
|
* 获取相同ref的VNode集合
|
|
100
100
|
*/
|
|
101
|
-
$getRefs<T extends VNode.Node>(ref: string): Array<T> | undefined;
|
|
101
|
+
$getRefs<T extends VNode.Node = VNode.Element & VNode.Component>(ref: string): Array<T> | undefined;
|
|
102
102
|
/**
|
|
103
103
|
* 单向同步prop值,并监听变更后重新同步
|
|
104
104
|
* @param propKey 需要观察同步的props key
|
package/types/parser/vnode.d.ts
CHANGED
|
@@ -128,13 +128,18 @@ export declare namespace VNode {
|
|
|
128
128
|
* 组件节点
|
|
129
129
|
*/
|
|
130
130
|
class Component<T extends IComponent = IComponent & Record<string, any>> extends Node {
|
|
131
|
+
/** 组件名(template标签名) */
|
|
131
132
|
name?: string;
|
|
133
|
+
/** 组件实例 */
|
|
132
134
|
component: T;
|
|
135
|
+
/** 事件 */
|
|
133
136
|
events: Array<[string, {
|
|
134
137
|
modifiers?: string[];
|
|
135
138
|
callBack: EventCallBack;
|
|
136
139
|
}]>;
|
|
140
|
+
/** 参数 */
|
|
137
141
|
propValues: Record<string, any>;
|
|
142
|
+
/** 是否保持存活 */
|
|
138
143
|
keepalive?: boolean;
|
|
139
144
|
/**
|
|
140
145
|
* 当前组件第一个element vnode
|