@viewfly/platform-browser 1.0.6 → 1.1.1

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.
@@ -1,4 +1,4 @@
1
- import { NativeNode, ViewFlyNode, Application, Config, JSXNode, NativeRenderer, JSX, ClassNames } from '@viewfly/core';
1
+ import { NativeNode, ViewFlyNode, Application, Config, JSXNode, NativeRenderer, ElementNamespace, JSX, ClassNames } from '@viewfly/core';
2
2
  import * as CSS from 'csstype';
3
3
 
4
4
  /**
@@ -109,23 +109,17 @@ declare class OutputTranslator {
109
109
  }
110
110
 
111
111
  declare class DomRenderer extends NativeRenderer<HTMLElement, Text> {
112
- static NAMESPACES: {
113
- svg: string;
114
- html: string;
115
- xml: string;
116
- xlink: string;
117
- xmlns: string;
118
- };
112
+ static NAMESPACES: Record<string, string>;
119
113
  propMap: Record<string, Record<string, string>>;
120
- createElement(name: string, isSvg: boolean): HTMLElement;
114
+ createElement(name: string, namespace: ElementNamespace): HTMLElement;
121
115
  createTextNode(textContent: string): Text;
122
116
  appendChild(parent: HTMLElement, newChild: any): void;
123
117
  prependChild(parent: HTMLElement, newChild: HTMLElement | Text): void;
124
118
  insertAfter(newNode: HTMLElement | Text, ref: HTMLElement | Text): void;
125
119
  remove(node: HTMLElement | Text): void;
126
120
  cleanChildren(node: HTMLElement): void;
127
- setProperty(node: HTMLElement, key: string, value: any, isSvg: boolean): void;
128
- removeProperty(node: HTMLElement, key: string, isSvg: boolean): void;
121
+ setProperty(node: HTMLElement, key: string, value: any, namespace: ElementNamespace): void;
122
+ removeProperty(node: HTMLElement, key: string, namespace: ElementNamespace): void;
129
123
  setClass(target: HTMLElement, className: string): void;
130
124
  setStyle(target: HTMLElement, key: string, value: any): void;
131
125
  removeStyle(target: HTMLElement, key: string): void;
@@ -1191,7 +1185,105 @@ interface SVGElements {
1191
1185
  use: SVGAttributes<SVGUseElement>;
1192
1186
  view: SVGAttributes<SVGViewElement>;
1193
1187
  }
1194
- interface NativeElements extends DOMElements, SVGElements {
1188
+ interface MathMLAttributes extends JSX.RefAttributes<MathMLElement> {
1189
+ children?: JSXNode;
1190
+ scriptlevel?: string;
1191
+ }
1192
+ interface MathMLMoAttributes extends MathMLAttributes {
1193
+ accent?: Booleanish;
1194
+ fence?: Booleanish;
1195
+ lspace?: string;
1196
+ maxsize?: string;
1197
+ minsize?: string;
1198
+ movablelimits?: Booleanish;
1199
+ rspace?: string;
1200
+ separator?: Booleanish;
1201
+ stretchy?: Booleanish;
1202
+ symmetric?: Booleanish;
1203
+ }
1204
+ interface MathMLMathAttributes extends MathMLAttributes {
1205
+ xmlns?: 'http://www.w3.org/1998/Math/MathML';
1206
+ display?: 'block' | 'inline';
1207
+ }
1208
+ interface MathMLMfracAttributes extends MathMLAttributes {
1209
+ linethickness?: string;
1210
+ }
1211
+ interface MathMLMoverAttributes extends MathMLAttributes {
1212
+ accent?: Booleanish;
1213
+ }
1214
+ interface MathMLMpaddedAttributes extends MathMLAttributes {
1215
+ depth?: string;
1216
+ height?: string;
1217
+ lspace?: string;
1218
+ voffset?: string;
1219
+ width?: string;
1220
+ }
1221
+ interface MathMLMspaceAttributes extends MathMLAttributes {
1222
+ width?: string;
1223
+ height?: string;
1224
+ }
1225
+ interface MathMLMtableAttribute extends MathMLAttributes {
1226
+ align?: string;
1227
+ columnalign?: string;
1228
+ columnlines?: Numberish;
1229
+ columnspacing?: Numberish;
1230
+ frame?: 'solid' | 'dashed' | 'none';
1231
+ framespacing?: Numberish;
1232
+ rowalign?: string;
1233
+ rowlines?: Numberish;
1234
+ rowspacing?: Numberish;
1235
+ width?: string;
1236
+ }
1237
+ interface MathMLMtdAttributes extends MathMLAttributes {
1238
+ columnalign?: string;
1239
+ columnspan?: Numberish;
1240
+ rowalign?: string;
1241
+ rowspan?: Numberish;
1242
+ }
1243
+ interface MathMLMtrAttributes extends MathMLAttributes {
1244
+ columnalign?: string;
1245
+ rowalign?: string;
1246
+ }
1247
+ interface MathMLMunderAttributes extends MathMLAttributes {
1248
+ accentunder?: Booleanish;
1249
+ }
1250
+ interface MathMLMunderoverAttributes extends MathMLAttributes {
1251
+ accent?: Booleanish;
1252
+ accentunder?: Booleanish;
1253
+ }
1254
+ interface MathMLElements {
1255
+ annotation: MathMLAttributes;
1256
+ 'annotation-xml': MathMLAttributes;
1257
+ maction: MathMLAttributes;
1258
+ math: MathMLMathAttributes;
1259
+ merror: MathMLAttributes;
1260
+ mfrac: MathMLMfracAttributes;
1261
+ mi: MathMLAttributes;
1262
+ mmultiscripts: MathMLAttributes;
1263
+ mn: MathMLAttributes;
1264
+ mo: MathMLMoAttributes;
1265
+ mover: MathMLMoverAttributes;
1266
+ mpadded: MathMLMpaddedAttributes;
1267
+ mphantom: MathMLAttributes;
1268
+ mprescripts: MathMLAttributes;
1269
+ mroot: MathMLAttributes;
1270
+ mrow: MathMLAttributes;
1271
+ ms: MathMLAttributes;
1272
+ mspace: MathMLMspaceAttributes;
1273
+ msqrt: MathMLAttributes;
1274
+ mstyle: MathMLAttributes;
1275
+ msub: MathMLAttributes;
1276
+ msubsup: MathMLAttributes;
1277
+ msup: MathMLAttributes;
1278
+ mtable: MathMLMtableAttribute;
1279
+ mtd: MathMLMtdAttributes;
1280
+ mtext: MathMLAttributes;
1281
+ mtr: MathMLMtrAttributes;
1282
+ munder: MathMLMunderAttributes;
1283
+ semantics: MathMLAttributes;
1284
+ munderover: MathMLMunderoverAttributes;
1285
+ }
1286
+ interface NativeElements extends DOMElements, SVGElements, MathMLElements {
1195
1287
  }
1196
1288
  interface Events {
1197
1289
  onCopy: ClipboardEvent;
@@ -1287,4 +1379,4 @@ declare module '@viewfly/core' {
1287
1379
  }
1288
1380
  }
1289
1381
 
1290
- export { type AnchorHTMLAttributes, type AreaHTMLAttributes, type AudioHTMLAttributes, type BaseHTMLAttributes, type BlockquoteHTMLAttributes, type ButtonHTMLAttributes, type CSSProperties, type CanvasHTMLAttributes, type ColHTMLAttributes, type ColgroupHTMLAttributes, type DOMElements, type DataHTMLAttributes, type DelHTMLAttributes, type DetailsHTMLAttributes, type DialogHTMLAttributes, DomRenderer, type EmbedHTMLAttributes, type Events, type FieldsetHTMLAttributes, type FormHTMLAttributes, type HTMLAttributes, HTMLRenderer, type HtmlHTMLAttributes, type IframeHTMLAttributes, type ImgHTMLAttributes, type InputHTMLAttributes, type InsHTMLAttributes, type KeygenHTMLAttributes, type LabelHTMLAttributes, type LiHTMLAttributes, type LinkHTMLAttributes, type MapHTMLAttributes, type MediaHTMLAttributes, type MenuHTMLAttributes, type MetaHTMLAttributes, type MeterHTMLAttributes, type NativeElements, type ObjectHTMLAttributes, type OlHTMLAttributes, type OptgroupHTMLAttributes, type OptionHTMLAttributes, type OutputHTMLAttributes, OutputTranslator, type ParamHTMLAttributes, type ProgressHTMLAttributes, type QuoteHTMLAttributes, type SVGAttributes, type SVGElements, type ScriptHTMLAttributes, type SelectHTMLAttributes, type SourceHTMLAttributes, type StyleHTMLAttributes, type StyleValue, type TableHTMLAttributes, type TdHTMLAttributes, type TextareaHTMLAttributes, type ThHTMLAttributes, type TimeHTMLAttributes, type TrackHTMLAttributes, VDOMElement, VDOMNode, VDOMText, type VideoHTMLAttributes, type WebViewHTMLAttributes, createApp, createPortal };
1382
+ export { type AnchorHTMLAttributes, type AreaHTMLAttributes, type AudioHTMLAttributes, type BaseHTMLAttributes, type BlockquoteHTMLAttributes, type ButtonHTMLAttributes, type CSSProperties, type CanvasHTMLAttributes, type ColHTMLAttributes, type ColgroupHTMLAttributes, type DOMElements, type DataHTMLAttributes, type DelHTMLAttributes, type DetailsHTMLAttributes, type DialogHTMLAttributes, DomRenderer, type EmbedHTMLAttributes, type Events, type FieldsetHTMLAttributes, type FormHTMLAttributes, type HTMLAttributes, HTMLRenderer, type HtmlHTMLAttributes, type IframeHTMLAttributes, type ImgHTMLAttributes, type InputHTMLAttributes, type InsHTMLAttributes, type KeygenHTMLAttributes, type LabelHTMLAttributes, type LiHTMLAttributes, type LinkHTMLAttributes, type MapHTMLAttributes, type MathMLAttributes, type MathMLElements, type MathMLMathAttributes, type MathMLMfracAttributes, type MathMLMoAttributes, type MathMLMoverAttributes, type MathMLMpaddedAttributes, type MathMLMspaceAttributes, type MathMLMtableAttribute, type MathMLMtdAttributes, type MathMLMtrAttributes, type MathMLMunderAttributes, type MathMLMunderoverAttributes, type MediaHTMLAttributes, type MenuHTMLAttributes, type MetaHTMLAttributes, type MeterHTMLAttributes, type NativeElements, type ObjectHTMLAttributes, type OlHTMLAttributes, type OptgroupHTMLAttributes, type OptionHTMLAttributes, type OutputHTMLAttributes, OutputTranslator, type ParamHTMLAttributes, type ProgressHTMLAttributes, type QuoteHTMLAttributes, type SVGAttributes, type SVGElements, type ScriptHTMLAttributes, type SelectHTMLAttributes, type SourceHTMLAttributes, type StyleHTMLAttributes, type StyleValue, type TableHTMLAttributes, type TdHTMLAttributes, type TextareaHTMLAttributes, type ThHTMLAttributes, type TimeHTMLAttributes, type TrackHTMLAttributes, VDOMElement, VDOMNode, VDOMText, type VideoHTMLAttributes, type WebViewHTMLAttributes, createApp, createPortal };
@@ -12,9 +12,10 @@ class DomRenderer extends NativeRenderer {
12
12
  }
13
13
  };
14
14
  }
15
- createElement(name, isSvg) {
16
- if (isSvg) {
17
- return document.createElementNS(DomRenderer.NAMESPACES.svg, name);
15
+ createElement(name, namespace) {
16
+ const ns = namespace && DomRenderer.NAMESPACES[namespace];
17
+ if (ns) {
18
+ return document.createElementNS(ns, name);
18
19
  }
19
20
  return document.createElement(name);
20
21
  }
@@ -45,13 +46,13 @@ class DomRenderer extends NativeRenderer {
45
46
  cleanChildren(node) {
46
47
  node.textContent = '';
47
48
  }
48
- setProperty(node, key, value, isSvg) {
49
- const nameSpace = DomRenderer.NAMESPACES;
50
- if (isSvg) {
49
+ setProperty(node, key, value, namespace) {
50
+ const NAMESPACE = DomRenderer.NAMESPACES;
51
+ if (namespace) {
51
52
  const [prefix, ...unqualifiedName] = key.split(/(?=[A-Z])/);
52
53
  let ns = null;
53
- if (prefix === 'xmlns' || unqualifiedName.length && nameSpace[prefix]) {
54
- ns = nameSpace[prefix];
54
+ if (prefix === 'xmlns' || unqualifiedName.length && NAMESPACE[prefix]) {
55
+ ns = NAMESPACE[prefix];
55
56
  }
56
57
  node.setAttributeNS(ns, key, String(value));
57
58
  return;
@@ -70,13 +71,13 @@ class DomRenderer extends NativeRenderer {
70
71
  node.setAttribute(key, value);
71
72
  }
72
73
  }
73
- removeProperty(node, key, isSvg) {
74
- if (isSvg) {
75
- const nameSpace = DomRenderer.NAMESPACES;
74
+ removeProperty(node, key, namespace) {
75
+ if (namespace) {
76
+ const NAMESPACE = DomRenderer.NAMESPACES;
76
77
  const [prefix, ...unqualifiedName] = key.split(/(?=[A-Z])/);
77
78
  let ns = null;
78
- if (prefix === 'xmlns' || unqualifiedName.length && nameSpace[prefix]) {
79
- ns = nameSpace[prefix];
79
+ if (prefix === 'xmlns' || unqualifiedName.length && NAMESPACE[prefix]) {
80
+ ns = NAMESPACE[prefix];
80
81
  }
81
82
  node.removeAttributeNS(ns, key);
82
83
  return;
@@ -126,7 +127,8 @@ DomRenderer.NAMESPACES = {
126
127
  html: 'http://www.w3.org/1999/xhtml',
127
128
  xml: 'http://www.w3.org/XML/1998/namespace',
128
129
  xlink: 'http://www.w3.org/1999/xlink',
129
- xmlns: 'http://www.w3.org/2000/xmlns/'
130
+ xmlns: 'http://www.w3.org/2000/xmlns/',
131
+ mathml: 'http://www.w3.org/1998/Math/MathML',
130
132
  };
131
133
 
132
134
  function createApp(root, config = true) {
package/bundles/index.js CHANGED
@@ -14,9 +14,10 @@ class DomRenderer extends core.NativeRenderer {
14
14
  }
15
15
  };
16
16
  }
17
- createElement(name, isSvg) {
18
- if (isSvg) {
19
- return document.createElementNS(DomRenderer.NAMESPACES.svg, name);
17
+ createElement(name, namespace) {
18
+ const ns = namespace && DomRenderer.NAMESPACES[namespace];
19
+ if (ns) {
20
+ return document.createElementNS(ns, name);
20
21
  }
21
22
  return document.createElement(name);
22
23
  }
@@ -47,13 +48,13 @@ class DomRenderer extends core.NativeRenderer {
47
48
  cleanChildren(node) {
48
49
  node.textContent = '';
49
50
  }
50
- setProperty(node, key, value, isSvg) {
51
- const nameSpace = DomRenderer.NAMESPACES;
52
- if (isSvg) {
51
+ setProperty(node, key, value, namespace) {
52
+ const NAMESPACE = DomRenderer.NAMESPACES;
53
+ if (namespace) {
53
54
  const [prefix, ...unqualifiedName] = key.split(/(?=[A-Z])/);
54
55
  let ns = null;
55
- if (prefix === 'xmlns' || unqualifiedName.length && nameSpace[prefix]) {
56
- ns = nameSpace[prefix];
56
+ if (prefix === 'xmlns' || unqualifiedName.length && NAMESPACE[prefix]) {
57
+ ns = NAMESPACE[prefix];
57
58
  }
58
59
  node.setAttributeNS(ns, key, String(value));
59
60
  return;
@@ -72,13 +73,13 @@ class DomRenderer extends core.NativeRenderer {
72
73
  node.setAttribute(key, value);
73
74
  }
74
75
  }
75
- removeProperty(node, key, isSvg) {
76
- if (isSvg) {
77
- const nameSpace = DomRenderer.NAMESPACES;
76
+ removeProperty(node, key, namespace) {
77
+ if (namespace) {
78
+ const NAMESPACE = DomRenderer.NAMESPACES;
78
79
  const [prefix, ...unqualifiedName] = key.split(/(?=[A-Z])/);
79
80
  let ns = null;
80
- if (prefix === 'xmlns' || unqualifiedName.length && nameSpace[prefix]) {
81
- ns = nameSpace[prefix];
81
+ if (prefix === 'xmlns' || unqualifiedName.length && NAMESPACE[prefix]) {
82
+ ns = NAMESPACE[prefix];
82
83
  }
83
84
  node.removeAttributeNS(ns, key);
84
85
  return;
@@ -128,7 +129,8 @@ DomRenderer.NAMESPACES = {
128
129
  html: 'http://www.w3.org/1999/xhtml',
129
130
  xml: 'http://www.w3.org/XML/1998/namespace',
130
131
  xlink: 'http://www.w3.org/1999/xlink',
131
- xmlns: 'http://www.w3.org/2000/xmlns/'
132
+ xmlns: 'http://www.w3.org/2000/xmlns/',
133
+ mathml: 'http://www.w3.org/1998/Math/MathML',
132
134
  };
133
135
 
134
136
  function createApp(root, config = true) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viewfly/platform-browser",
3
- "version": "1.0.6",
3
+ "version": "1.1.1",
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.0.5",
17
+ "@viewfly/core": "^1.1.1",
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": "b66ca589f7662cd518fc2e5955b3e3ff9de83f94"
39
+ "gitHead": "091ae70c42965cbd99538b162e6f560121589bac"
40
40
  }