@viewfly/platform-browser 1.1.9 → 2.0.0-alpha.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.
@@ -3,14 +3,19 @@ import { NativeRenderer, viewfly } from '@viewfly/core';
3
3
  class DomRenderer extends NativeRenderer {
4
4
  constructor() {
5
5
  super(...arguments);
6
- this.propMap = {
7
- INPUT: {
8
- readonly: 'readOnly'
9
- },
10
- TEXTAREA: {
11
- readonly: 'readOnly'
6
+ Object.defineProperty(this, "propMap", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: {
11
+ INPUT: {
12
+ readonly: 'readOnly'
13
+ },
14
+ TEXTAREA: {
15
+ readonly: 'readOnly'
16
+ }
12
17
  }
13
- };
18
+ });
14
19
  }
15
20
  createElement(name, namespace) {
16
21
  const ns = namespace && DomRenderer.NAMESPACES[namespace];
@@ -132,14 +137,19 @@ class DomRenderer extends NativeRenderer {
132
137
  }
133
138
  }
134
139
  }
135
- DomRenderer.NAMESPACES = {
136
- svg: 'http://www.w3.org/2000/svg',
137
- html: 'http://www.w3.org/1999/xhtml',
138
- xml: 'http://www.w3.org/XML/1998/namespace',
139
- xlink: 'http://www.w3.org/1999/xlink',
140
- xmlns: 'http://www.w3.org/2000/xmlns/',
141
- mathml: 'http://www.w3.org/1998/Math/MathML',
142
- };
140
+ Object.defineProperty(DomRenderer, "NAMESPACES", {
141
+ enumerable: true,
142
+ configurable: true,
143
+ writable: true,
144
+ value: {
145
+ svg: 'http://www.w3.org/2000/svg',
146
+ html: 'http://www.w3.org/1999/xhtml',
147
+ xml: 'http://www.w3.org/XML/1998/namespace',
148
+ xlink: 'http://www.w3.org/1999/xlink',
149
+ xmlns: 'http://www.w3.org/2000/xmlns/',
150
+ mathml: 'http://www.w3.org/1998/Math/MathML',
151
+ }
152
+ });
143
153
 
144
154
  function createApp(root, config = true) {
145
155
  const c = { autoUpdate: true };
@@ -190,7 +200,12 @@ function createPortal(childRender, host) {
190
200
 
191
201
  class VDOMNode {
192
202
  constructor() {
193
- this.parent = null;
203
+ Object.defineProperty(this, "parent", {
204
+ enumerable: true,
205
+ configurable: true,
206
+ writable: true,
207
+ value: null
208
+ });
194
209
  }
195
210
  remove() {
196
211
  if (this.parent) {
@@ -205,17 +220,47 @@ class VDOMNode {
205
220
  class VDOMElement extends VDOMNode {
206
221
  constructor(name) {
207
222
  super();
208
- this.name = name;
209
- this.props = new Map();
210
- this.children = [];
211
- this.style = new Map();
212
- this.className = '';
223
+ Object.defineProperty(this, "name", {
224
+ enumerable: true,
225
+ configurable: true,
226
+ writable: true,
227
+ value: name
228
+ });
229
+ Object.defineProperty(this, "props", {
230
+ enumerable: true,
231
+ configurable: true,
232
+ writable: true,
233
+ value: new Map()
234
+ });
235
+ Object.defineProperty(this, "children", {
236
+ enumerable: true,
237
+ configurable: true,
238
+ writable: true,
239
+ value: []
240
+ });
241
+ Object.defineProperty(this, "style", {
242
+ enumerable: true,
243
+ configurable: true,
244
+ writable: true,
245
+ value: new Map()
246
+ });
247
+ Object.defineProperty(this, "className", {
248
+ enumerable: true,
249
+ configurable: true,
250
+ writable: true,
251
+ value: ''
252
+ });
213
253
  }
214
254
  }
215
255
  class VDOMText extends VDOMNode {
216
256
  constructor(text) {
217
257
  super();
218
- this.text = text;
258
+ Object.defineProperty(this, "text", {
259
+ enumerable: true,
260
+ configurable: true,
261
+ writable: true,
262
+ value: text
263
+ });
219
264
  }
220
265
  }
221
266
  /**
@@ -290,7 +335,12 @@ class HTMLRenderer extends NativeRenderer {
290
335
  */
291
336
  class OutputTranslator {
292
337
  constructor() {
293
- this.singleTagTest = new RegExp(`^(${OutputTranslator.singleTags.join('|')})$`, 'i');
338
+ Object.defineProperty(this, "singleTagTest", {
339
+ enumerable: true,
340
+ configurable: true,
341
+ writable: true,
342
+ value: new RegExp(`^(${OutputTranslator.singleTags.join('|')})$`, 'i')
343
+ });
294
344
  }
295
345
  /**
296
346
  * 将虚拟 DOM 转换为 HTML 字符串的方法
@@ -346,36 +396,46 @@ class OutputTranslator {
346
396
  }).replace(/^\s|\s$/g, target);
347
397
  }
348
398
  }
349
- OutputTranslator.singleTags = 'area,base,br,col,embed,hr,img,input,link,meta,source,track,wbr'.split(',');
350
- OutputTranslator.simpleXSSFilter = {
351
- text(text) {
352
- return text.replace(/[><&]/g, str => {
353
- return {
354
- '<': '&lt;',
355
- '>': '&gt;',
356
- '&': '&amp;'
357
- }[str];
358
- });
359
- },
360
- attrName(text) {
361
- return text.replace(/[><"'&]/g, str => {
362
- return {
363
- '<': '&lt;',
364
- '>': '&gt;',
365
- '"': '&quot;',
366
- '\'': '&#x27;',
367
- '&': '&amp;'
368
- }[str];
369
- });
370
- },
371
- attrValue(text) {
372
- return text.replace(/["']/g, str => {
373
- return {
374
- '"': '&quot;',
375
- '\'': '&#x27;'
376
- }[str];
377
- });
399
+ Object.defineProperty(OutputTranslator, "singleTags", {
400
+ enumerable: true,
401
+ configurable: true,
402
+ writable: true,
403
+ value: 'area,base,br,col,embed,hr,img,input,link,meta,source,track,wbr'.split(',')
404
+ });
405
+ Object.defineProperty(OutputTranslator, "simpleXSSFilter", {
406
+ enumerable: true,
407
+ configurable: true,
408
+ writable: true,
409
+ value: {
410
+ text(text) {
411
+ return text.replace(/[><&]/g, str => {
412
+ return {
413
+ '<': '&lt;',
414
+ '>': '&gt;',
415
+ '&': '&amp;'
416
+ }[str];
417
+ });
418
+ },
419
+ attrName(text) {
420
+ return text.replace(/[><"'&]/g, str => {
421
+ return {
422
+ '<': '&lt;',
423
+ '>': '&gt;',
424
+ '"': '&quot;',
425
+ '\'': '&#x27;',
426
+ '&': '&amp;'
427
+ }[str];
428
+ });
429
+ },
430
+ attrValue(text) {
431
+ return text.replace(/["']/g, str => {
432
+ return {
433
+ '"': '&quot;',
434
+ '\'': '&#x27;'
435
+ }[str];
436
+ });
437
+ }
378
438
  }
379
- };
439
+ });
380
440
 
381
441
  export { DomRenderer, HTMLRenderer, OutputTranslator, VDOMElement, VDOMNode, VDOMText, createApp, createPortal };
package/bundles/index.js CHANGED
@@ -5,14 +5,19 @@ var core = require('@viewfly/core');
5
5
  class DomRenderer extends core.NativeRenderer {
6
6
  constructor() {
7
7
  super(...arguments);
8
- this.propMap = {
9
- INPUT: {
10
- readonly: 'readOnly'
11
- },
12
- TEXTAREA: {
13
- readonly: 'readOnly'
8
+ Object.defineProperty(this, "propMap", {
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true,
12
+ value: {
13
+ INPUT: {
14
+ readonly: 'readOnly'
15
+ },
16
+ TEXTAREA: {
17
+ readonly: 'readOnly'
18
+ }
14
19
  }
15
- };
20
+ });
16
21
  }
17
22
  createElement(name, namespace) {
18
23
  const ns = namespace && DomRenderer.NAMESPACES[namespace];
@@ -134,14 +139,19 @@ class DomRenderer extends core.NativeRenderer {
134
139
  }
135
140
  }
136
141
  }
137
- DomRenderer.NAMESPACES = {
138
- svg: 'http://www.w3.org/2000/svg',
139
- html: 'http://www.w3.org/1999/xhtml',
140
- xml: 'http://www.w3.org/XML/1998/namespace',
141
- xlink: 'http://www.w3.org/1999/xlink',
142
- xmlns: 'http://www.w3.org/2000/xmlns/',
143
- mathml: 'http://www.w3.org/1998/Math/MathML',
144
- };
142
+ Object.defineProperty(DomRenderer, "NAMESPACES", {
143
+ enumerable: true,
144
+ configurable: true,
145
+ writable: true,
146
+ value: {
147
+ svg: 'http://www.w3.org/2000/svg',
148
+ html: 'http://www.w3.org/1999/xhtml',
149
+ xml: 'http://www.w3.org/XML/1998/namespace',
150
+ xlink: 'http://www.w3.org/1999/xlink',
151
+ xmlns: 'http://www.w3.org/2000/xmlns/',
152
+ mathml: 'http://www.w3.org/1998/Math/MathML',
153
+ }
154
+ });
145
155
 
146
156
  function createApp(root, config = true) {
147
157
  const c = { autoUpdate: true };
@@ -192,7 +202,12 @@ function createPortal(childRender, host) {
192
202
 
193
203
  class VDOMNode {
194
204
  constructor() {
195
- this.parent = null;
205
+ Object.defineProperty(this, "parent", {
206
+ enumerable: true,
207
+ configurable: true,
208
+ writable: true,
209
+ value: null
210
+ });
196
211
  }
197
212
  remove() {
198
213
  if (this.parent) {
@@ -207,17 +222,47 @@ class VDOMNode {
207
222
  class VDOMElement extends VDOMNode {
208
223
  constructor(name) {
209
224
  super();
210
- this.name = name;
211
- this.props = new Map();
212
- this.children = [];
213
- this.style = new Map();
214
- this.className = '';
225
+ Object.defineProperty(this, "name", {
226
+ enumerable: true,
227
+ configurable: true,
228
+ writable: true,
229
+ value: name
230
+ });
231
+ Object.defineProperty(this, "props", {
232
+ enumerable: true,
233
+ configurable: true,
234
+ writable: true,
235
+ value: new Map()
236
+ });
237
+ Object.defineProperty(this, "children", {
238
+ enumerable: true,
239
+ configurable: true,
240
+ writable: true,
241
+ value: []
242
+ });
243
+ Object.defineProperty(this, "style", {
244
+ enumerable: true,
245
+ configurable: true,
246
+ writable: true,
247
+ value: new Map()
248
+ });
249
+ Object.defineProperty(this, "className", {
250
+ enumerable: true,
251
+ configurable: true,
252
+ writable: true,
253
+ value: ''
254
+ });
215
255
  }
216
256
  }
217
257
  class VDOMText extends VDOMNode {
218
258
  constructor(text) {
219
259
  super();
220
- this.text = text;
260
+ Object.defineProperty(this, "text", {
261
+ enumerable: true,
262
+ configurable: true,
263
+ writable: true,
264
+ value: text
265
+ });
221
266
  }
222
267
  }
223
268
  /**
@@ -292,7 +337,12 @@ class HTMLRenderer extends core.NativeRenderer {
292
337
  */
293
338
  class OutputTranslator {
294
339
  constructor() {
295
- this.singleTagTest = new RegExp(`^(${OutputTranslator.singleTags.join('|')})$`, 'i');
340
+ Object.defineProperty(this, "singleTagTest", {
341
+ enumerable: true,
342
+ configurable: true,
343
+ writable: true,
344
+ value: new RegExp(`^(${OutputTranslator.singleTags.join('|')})$`, 'i')
345
+ });
296
346
  }
297
347
  /**
298
348
  * 将虚拟 DOM 转换为 HTML 字符串的方法
@@ -348,37 +398,47 @@ class OutputTranslator {
348
398
  }).replace(/^\s|\s$/g, target);
349
399
  }
350
400
  }
351
- OutputTranslator.singleTags = 'area,base,br,col,embed,hr,img,input,link,meta,source,track,wbr'.split(',');
352
- OutputTranslator.simpleXSSFilter = {
353
- text(text) {
354
- return text.replace(/[><&]/g, str => {
355
- return {
356
- '<': '&lt;',
357
- '>': '&gt;',
358
- '&': '&amp;'
359
- }[str];
360
- });
361
- },
362
- attrName(text) {
363
- return text.replace(/[><"'&]/g, str => {
364
- return {
365
- '<': '&lt;',
366
- '>': '&gt;',
367
- '"': '&quot;',
368
- '\'': '&#x27;',
369
- '&': '&amp;'
370
- }[str];
371
- });
372
- },
373
- attrValue(text) {
374
- return text.replace(/["']/g, str => {
375
- return {
376
- '"': '&quot;',
377
- '\'': '&#x27;'
378
- }[str];
379
- });
401
+ Object.defineProperty(OutputTranslator, "singleTags", {
402
+ enumerable: true,
403
+ configurable: true,
404
+ writable: true,
405
+ value: 'area,base,br,col,embed,hr,img,input,link,meta,source,track,wbr'.split(',')
406
+ });
407
+ Object.defineProperty(OutputTranslator, "simpleXSSFilter", {
408
+ enumerable: true,
409
+ configurable: true,
410
+ writable: true,
411
+ value: {
412
+ text(text) {
413
+ return text.replace(/[><&]/g, str => {
414
+ return {
415
+ '<': '&lt;',
416
+ '>': '&gt;',
417
+ '&': '&amp;'
418
+ }[str];
419
+ });
420
+ },
421
+ attrName(text) {
422
+ return text.replace(/[><"'&]/g, str => {
423
+ return {
424
+ '<': '&lt;',
425
+ '>': '&gt;',
426
+ '"': '&quot;',
427
+ '\'': '&#x27;',
428
+ '&': '&amp;'
429
+ }[str];
430
+ });
431
+ },
432
+ attrValue(text) {
433
+ return text.replace(/["']/g, str => {
434
+ return {
435
+ '"': '&quot;',
436
+ '\'': '&#x27;'
437
+ }[str];
438
+ });
439
+ }
380
440
  }
381
- };
441
+ });
382
442
 
383
443
  exports.DomRenderer = DomRenderer;
384
444
  exports.HTMLRenderer = HTMLRenderer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viewfly/platform-browser",
3
- "version": "1.1.9",
3
+ "version": "2.0.0-alpha.0",
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",
@@ -14,7 +14,7 @@
14
14
  "license": "MIT",
15
15
  "keywords": [],
16
16
  "dependencies": {
17
- "@viewfly/core": "^1.1.9",
17
+ "@viewfly/core": "^2.0.0-alpha.0",
18
18
  "csstype": "^3.1.2"
19
19
  },
20
20
  "devDependencies": {
@@ -36,5 +36,5 @@
36
36
  "bugs": {
37
37
  "url": "https://github.com/viewfly/viewfly.git/issues"
38
38
  },
39
- "gitHead": "eb5d5ce380467cb05637ef42fdb539c327b19feb"
39
+ "gitHead": "5fdcdcdca224d1eecdfd6a68abb1c3fb9c01d88a"
40
40
  }