@viewfly/platform-browser 0.6.0 → 0.6.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/bundles/html-renderer.d.ts +9 -9
- package/bundles/index.esm.js +17 -6
- package/bundles/index.js +17 -6
- package/bundles/jsx-dom.d.ts +6 -1
- package/package.json +3 -3
|
@@ -2,13 +2,13 @@ import { NativeRenderer } from '@viewfly/core';
|
|
|
2
2
|
export declare class VDOMElement {
|
|
3
3
|
name: string;
|
|
4
4
|
props: Map<string, any>;
|
|
5
|
-
children: Array<VDOMElement |
|
|
5
|
+
children: Array<VDOMElement | VDOMText>;
|
|
6
6
|
style: Map<string, any>;
|
|
7
7
|
className: string;
|
|
8
8
|
parent: VDOMElement | null;
|
|
9
9
|
constructor(name: string);
|
|
10
10
|
}
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class VDOMText {
|
|
12
12
|
text: string;
|
|
13
13
|
parent: VDOMElement | null;
|
|
14
14
|
constructor(text: string);
|
|
@@ -16,22 +16,22 @@ export declare class VDomText {
|
|
|
16
16
|
/**
|
|
17
17
|
* 用于生成模拟轻量 DOM 节点的渲染器
|
|
18
18
|
*/
|
|
19
|
-
export declare class HTMLRenderer extends NativeRenderer<VDOMElement,
|
|
19
|
+
export declare class HTMLRenderer extends NativeRenderer<VDOMElement, VDOMText> {
|
|
20
20
|
createElement(name: string): VDOMElement;
|
|
21
|
-
createTextNode(textContent: string):
|
|
21
|
+
createTextNode(textContent: string): VDOMText;
|
|
22
22
|
setProperty(node: VDOMElement, key: string, value: any): void;
|
|
23
|
-
appendChild(parent: VDOMElement, newChild: VDOMElement |
|
|
24
|
-
prependChild(parent: VDOMElement, newChild: VDOMElement |
|
|
23
|
+
appendChild(parent: VDOMElement, newChild: VDOMElement | VDOMText): void;
|
|
24
|
+
prependChild(parent: VDOMElement, newChild: VDOMElement | VDOMText): void;
|
|
25
25
|
removeProperty(node: VDOMElement, key: string): void;
|
|
26
26
|
setStyle(target: VDOMElement, key: string, value: any): void;
|
|
27
27
|
removeStyle(target: VDOMElement, key: string): void;
|
|
28
28
|
setClass(target: VDOMElement, value: string): void;
|
|
29
29
|
listen(): void;
|
|
30
30
|
unListen(): void;
|
|
31
|
-
remove(node: VDOMElement |
|
|
31
|
+
remove(node: VDOMElement | VDOMText): void;
|
|
32
32
|
cleanChildren(node: VDOMElement): void;
|
|
33
|
-
syncTextContent(target:
|
|
34
|
-
insertAfter(newNode: VDOMElement |
|
|
33
|
+
syncTextContent(target: VDOMText, content: string): void;
|
|
34
|
+
insertAfter(newNode: VDOMElement | VDOMText, ref: VDOMElement | VDOMText): void;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* 轻量 DOM 转换为 HTML 字符串的转换器
|
package/bundles/index.esm.js
CHANGED
|
@@ -31,9 +31,12 @@ class DomRenderer extends NativeRenderer {
|
|
|
31
31
|
if (ref.nextSibling) {
|
|
32
32
|
this.insertBefore(newNode, ref.nextSibling);
|
|
33
33
|
}
|
|
34
|
-
else {
|
|
34
|
+
else if (ref.parentNode) {
|
|
35
35
|
this.appendChild(ref.parentNode, newNode);
|
|
36
36
|
}
|
|
37
|
+
else {
|
|
38
|
+
console.warn(`Element "${ref instanceof Text ? ref.textContent : ref.tagName}" was accidentally deleted, and viewfly is unable to update the current view`);
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
41
|
remove(node) {
|
|
39
42
|
node.remove();
|
|
@@ -100,7 +103,12 @@ class DomRenderer extends NativeRenderer {
|
|
|
100
103
|
target.textContent = content;
|
|
101
104
|
}
|
|
102
105
|
insertBefore(newNode, ref) {
|
|
103
|
-
ref.parentNode
|
|
106
|
+
if (ref.parentNode) {
|
|
107
|
+
ref.parentNode.insertBefore(newNode, ref);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
console.warn(`Element "${ref instanceof Text ? ref.textContent : ref.tagName}" was accidentally deleted, and viewfly is unable to update the current view`);
|
|
111
|
+
}
|
|
104
112
|
}
|
|
105
113
|
}
|
|
106
114
|
DomRenderer.NAMESPACES = {
|
|
@@ -168,7 +176,7 @@ class VDOMElement {
|
|
|
168
176
|
this.parent = null;
|
|
169
177
|
}
|
|
170
178
|
}
|
|
171
|
-
class
|
|
179
|
+
class VDOMText {
|
|
172
180
|
constructor(text) {
|
|
173
181
|
this.text = text;
|
|
174
182
|
this.parent = null;
|
|
@@ -182,7 +190,7 @@ class HTMLRenderer extends NativeRenderer {
|
|
|
182
190
|
return new VDOMElement(name);
|
|
183
191
|
}
|
|
184
192
|
createTextNode(textContent) {
|
|
185
|
-
return new
|
|
193
|
+
return new VDOMText(textContent);
|
|
186
194
|
}
|
|
187
195
|
setProperty(node, key, value) {
|
|
188
196
|
node.props.set(key, value);
|
|
@@ -237,6 +245,9 @@ class HTMLRenderer extends NativeRenderer {
|
|
|
237
245
|
parent.children.splice(i + 1, 0, newNode);
|
|
238
246
|
}
|
|
239
247
|
}
|
|
248
|
+
else {
|
|
249
|
+
console.warn(`Element "${ref instanceof VDOMText ? ref.text : ref.name}" was accidentally deleted, and viewfly is unable to update the current view`);
|
|
250
|
+
}
|
|
240
251
|
}
|
|
241
252
|
}
|
|
242
253
|
/**
|
|
@@ -257,7 +268,7 @@ class OutputTranslator {
|
|
|
257
268
|
}
|
|
258
269
|
vDomToHTMLString(vDom) {
|
|
259
270
|
const xssFilter = OutputTranslator.simpleXSSFilter;
|
|
260
|
-
if (vDom instanceof
|
|
271
|
+
if (vDom instanceof VDOMText) {
|
|
261
272
|
return this.replaceEmpty(xssFilter.text(vDom.text), ' ');
|
|
262
273
|
}
|
|
263
274
|
const styles = Array.from(vDom.style.keys()).filter(key => {
|
|
@@ -332,4 +343,4 @@ OutputTranslator.simpleXSSFilter = {
|
|
|
332
343
|
}
|
|
333
344
|
};
|
|
334
345
|
|
|
335
|
-
export { DomRenderer, HTMLRenderer, OutputTranslator, VDOMElement,
|
|
346
|
+
export { DomRenderer, HTMLRenderer, OutputTranslator, VDOMElement, VDOMText, createApp, createPortal };
|
package/bundles/index.js
CHANGED
|
@@ -33,9 +33,12 @@ class DomRenderer extends core.NativeRenderer {
|
|
|
33
33
|
if (ref.nextSibling) {
|
|
34
34
|
this.insertBefore(newNode, ref.nextSibling);
|
|
35
35
|
}
|
|
36
|
-
else {
|
|
36
|
+
else if (ref.parentNode) {
|
|
37
37
|
this.appendChild(ref.parentNode, newNode);
|
|
38
38
|
}
|
|
39
|
+
else {
|
|
40
|
+
console.warn(`Element "${ref instanceof Text ? ref.textContent : ref.tagName}" was accidentally deleted, and viewfly is unable to update the current view`);
|
|
41
|
+
}
|
|
39
42
|
}
|
|
40
43
|
remove(node) {
|
|
41
44
|
node.remove();
|
|
@@ -102,7 +105,12 @@ class DomRenderer extends core.NativeRenderer {
|
|
|
102
105
|
target.textContent = content;
|
|
103
106
|
}
|
|
104
107
|
insertBefore(newNode, ref) {
|
|
105
|
-
ref.parentNode
|
|
108
|
+
if (ref.parentNode) {
|
|
109
|
+
ref.parentNode.insertBefore(newNode, ref);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
console.warn(`Element "${ref instanceof Text ? ref.textContent : ref.tagName}" was accidentally deleted, and viewfly is unable to update the current view`);
|
|
113
|
+
}
|
|
106
114
|
}
|
|
107
115
|
}
|
|
108
116
|
DomRenderer.NAMESPACES = {
|
|
@@ -170,7 +178,7 @@ class VDOMElement {
|
|
|
170
178
|
this.parent = null;
|
|
171
179
|
}
|
|
172
180
|
}
|
|
173
|
-
class
|
|
181
|
+
class VDOMText {
|
|
174
182
|
constructor(text) {
|
|
175
183
|
this.text = text;
|
|
176
184
|
this.parent = null;
|
|
@@ -184,7 +192,7 @@ class HTMLRenderer extends core.NativeRenderer {
|
|
|
184
192
|
return new VDOMElement(name);
|
|
185
193
|
}
|
|
186
194
|
createTextNode(textContent) {
|
|
187
|
-
return new
|
|
195
|
+
return new VDOMText(textContent);
|
|
188
196
|
}
|
|
189
197
|
setProperty(node, key, value) {
|
|
190
198
|
node.props.set(key, value);
|
|
@@ -239,6 +247,9 @@ class HTMLRenderer extends core.NativeRenderer {
|
|
|
239
247
|
parent.children.splice(i + 1, 0, newNode);
|
|
240
248
|
}
|
|
241
249
|
}
|
|
250
|
+
else {
|
|
251
|
+
console.warn(`Element "${ref instanceof VDOMText ? ref.text : ref.name}" was accidentally deleted, and viewfly is unable to update the current view`);
|
|
252
|
+
}
|
|
242
253
|
}
|
|
243
254
|
}
|
|
244
255
|
/**
|
|
@@ -259,7 +270,7 @@ class OutputTranslator {
|
|
|
259
270
|
}
|
|
260
271
|
vDomToHTMLString(vDom) {
|
|
261
272
|
const xssFilter = OutputTranslator.simpleXSSFilter;
|
|
262
|
-
if (vDom instanceof
|
|
273
|
+
if (vDom instanceof VDOMText) {
|
|
263
274
|
return this.replaceEmpty(xssFilter.text(vDom.text), ' ');
|
|
264
275
|
}
|
|
265
276
|
const styles = Array.from(vDom.style.keys()).filter(key => {
|
|
@@ -338,6 +349,6 @@ exports.DomRenderer = DomRenderer;
|
|
|
338
349
|
exports.HTMLRenderer = HTMLRenderer;
|
|
339
350
|
exports.OutputTranslator = OutputTranslator;
|
|
340
351
|
exports.VDOMElement = VDOMElement;
|
|
341
|
-
exports.
|
|
352
|
+
exports.VDOMText = VDOMText;
|
|
342
353
|
exports.createApp = createApp;
|
|
343
354
|
exports.createPortal = createPortal;
|
package/bundles/jsx-dom.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as CSS from 'csstype';
|
|
2
|
-
import { JSXInternal } from '@viewfly/core';
|
|
3
2
|
export interface CSSProperties extends CSS.Properties<string | number>, CSS.PropertiesHyphen<string | number> {
|
|
4
3
|
/**
|
|
5
4
|
* The index signature was removed to enable closed typing for style
|
|
@@ -1142,4 +1141,10 @@ export interface Events {
|
|
|
1142
1141
|
type EventHandlers<E> = {
|
|
1143
1142
|
[K in keyof E]?: E[K] extends (...args: any) => any ? E[K] : (payload: E[K]) => void;
|
|
1144
1143
|
};
|
|
1144
|
+
declare global {
|
|
1145
|
+
namespace JSXInternal {
|
|
1146
|
+
interface IntrinsicElements extends NativeElements {
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1145
1150
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/platform-browser",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "This project is used to enable the Viewfly framework to run in a browser.",
|
|
5
5
|
"main": "./bundles/index.js",
|
|
6
6
|
"module": "./bundles/index.esm.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"keywords": [],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@viewfly/core": "^0.6.
|
|
15
|
+
"@viewfly/core": "^0.6.2",
|
|
16
16
|
"csstype": "^3.1.2"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"bugs": {
|
|
34
34
|
"url": "https://github.com/viewfly/viewfly.git/issues"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "f3db648a596358d6966d006a24fb85b3b7d993d1"
|
|
37
37
|
}
|