ember-native 1.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.
Files changed (116) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +16 -0
  3. package/addon-main.cjs +4 -0
  4. package/declarations/components/InspectorSupport.d.ts +32 -0
  5. package/declarations/components/InspectorSupport.d.ts.map +1 -0
  6. package/declarations/components/ListView.d.ts +31 -0
  7. package/declarations/components/ListView.d.ts.map +1 -0
  8. package/declarations/components/RadListView.d.ts +41 -0
  9. package/declarations/components/RadListView.d.ts.map +1 -0
  10. package/declarations/components/index.d.ts +4 -0
  11. package/declarations/components/index.d.ts.map +1 -0
  12. package/declarations/dom/element-registry.d.ts +16 -0
  13. package/declarations/dom/element-registry.d.ts.map +1 -0
  14. package/declarations/dom/native/FrameElement.d.ts +16 -0
  15. package/declarations/dom/native/FrameElement.d.ts.map +1 -0
  16. package/declarations/dom/native/NativeElementNode.d.ts +41 -0
  17. package/declarations/dom/native/NativeElementNode.d.ts.map +1 -0
  18. package/declarations/dom/native/PageElement.d.ts +6 -0
  19. package/declarations/dom/native/PageElement.d.ts.map +1 -0
  20. package/declarations/dom/native-elements-tag-name-map.d.ts +10 -0
  21. package/declarations/dom/native-elements-tag-name-map.d.ts.map +1 -0
  22. package/declarations/dom/nodes/CommentNode.d.ts +7 -0
  23. package/declarations/dom/nodes/CommentNode.d.ts.map +1 -0
  24. package/declarations/dom/nodes/DocumentNode.d.ts +47 -0
  25. package/declarations/dom/nodes/DocumentNode.d.ts.map +1 -0
  26. package/declarations/dom/nodes/ElementNode.d.ts +18 -0
  27. package/declarations/dom/nodes/ElementNode.d.ts.map +1 -0
  28. package/declarations/dom/nodes/PropertyNode.d.ts +13 -0
  29. package/declarations/dom/nodes/PropertyNode.d.ts.map +1 -0
  30. package/declarations/dom/nodes/TextNode.d.ts +10 -0
  31. package/declarations/dom/nodes/TextNode.d.ts.map +1 -0
  32. package/declarations/dom/nodes/ViewNode.d.ts +49 -0
  33. package/declarations/dom/nodes/ViewNode.d.ts.map +1 -0
  34. package/declarations/dom/setup-registry.d.ts +5 -0
  35. package/declarations/dom/setup-registry.d.ts.map +1 -0
  36. package/declarations/index.d.ts +4 -0
  37. package/declarations/index.d.ts.map +1 -0
  38. package/declarations/instance-initializers/history.d.ts +8 -0
  39. package/declarations/instance-initializers/history.d.ts.map +1 -0
  40. package/declarations/services/history.d.ts +9 -0
  41. package/declarations/services/history.d.ts.map +1 -0
  42. package/declarations/services/native-router.d.ts +12 -0
  43. package/declarations/services/native-router.d.ts.map +1 -0
  44. package/declarations/setup-inspector-support.d.ts +2 -0
  45. package/declarations/setup-inspector-support.d.ts.map +1 -0
  46. package/declarations/setup.d.ts +2 -0
  47. package/declarations/setup.d.ts.map +1 -0
  48. package/declarations/types/glint.d.ts +47 -0
  49. package/declarations/types/glint.d.ts.map +1 -0
  50. package/declarations/types/globals.d.ts +32 -0
  51. package/declarations/types/globals.d.ts.map +1 -0
  52. package/dist/_app_/components/ember-native/InspectorSupport.js +1 -0
  53. package/dist/_app_/components/ember-native/ListView.js +1 -0
  54. package/dist/_app_/components/ember-native/RadListView.js +1 -0
  55. package/dist/_app_/components/ember-native/index.js +1 -0
  56. package/dist/_app_/instance-initializers/ember-native/history.js +1 -0
  57. package/dist/_app_/services/ember-native/history.js +1 -0
  58. package/dist/_app_/services/ember-native/native-router.js +1 -0
  59. package/dist/_rollupPluginBabelHelpers-DZQzmiRH.js +41 -0
  60. package/dist/_rollupPluginBabelHelpers-DZQzmiRH.js.map +1 -0
  61. package/dist/components/InspectorSupport.js +75 -0
  62. package/dist/components/InspectorSupport.js.map +1 -0
  63. package/dist/components/ListView.js +69 -0
  64. package/dist/components/ListView.js.map +1 -0
  65. package/dist/components/RadListView.js +104 -0
  66. package/dist/components/RadListView.js.map +1 -0
  67. package/dist/components/index.js +4 -0
  68. package/dist/components/index.js.map +1 -0
  69. package/dist/dom/element-registry.js +65 -0
  70. package/dist/dom/element-registry.js.map +1 -0
  71. package/dist/dom/native/FrameElement.js +89 -0
  72. package/dist/dom/native/FrameElement.js.map +1 -0
  73. package/dist/dom/native/NativeElementNode.js +380 -0
  74. package/dist/dom/native/NativeElementNode.js.map +1 -0
  75. package/dist/dom/native/PageElement.js +11 -0
  76. package/dist/dom/native/PageElement.js.map +1 -0
  77. package/dist/dom/native-elements-tag-name-map.js +2 -0
  78. package/dist/dom/native-elements-tag-name-map.js.map +1 -0
  79. package/dist/dom/nodes/CommentNode.js +15 -0
  80. package/dist/dom/nodes/CommentNode.js.map +1 -0
  81. package/dist/dom/nodes/DocumentNode.js +198 -0
  82. package/dist/dom/nodes/DocumentNode.js.map +1 -0
  83. package/dist/dom/nodes/ElementNode.js +267 -0
  84. package/dist/dom/nodes/ElementNode.js.map +1 -0
  85. package/dist/dom/nodes/PropertyNode.js +39 -0
  86. package/dist/dom/nodes/PropertyNode.js.map +1 -0
  87. package/dist/dom/nodes/TextNode.js +35 -0
  88. package/dist/dom/nodes/TextNode.js.map +1 -0
  89. package/dist/dom/nodes/ViewNode.js +211 -0
  90. package/dist/dom/nodes/ViewNode.js.map +1 -0
  91. package/dist/dom/setup-registry.js +66 -0
  92. package/dist/dom/setup-registry.js.map +1 -0
  93. package/dist/index.js +6 -0
  94. package/dist/index.js.map +1 -0
  95. package/dist/instance-initializers/history.js +11 -0
  96. package/dist/instance-initializers/history.js.map +1 -0
  97. package/dist/services/history.js +58 -0
  98. package/dist/services/history.js.map +1 -0
  99. package/dist/services/native-router.js +34 -0
  100. package/dist/services/native-router.js.map +1 -0
  101. package/dist/setup-inspector-support.js +158 -0
  102. package/dist/setup-inspector-support.js.map +1 -0
  103. package/dist/setup.js +46 -0
  104. package/dist/setup.js.map +1 -0
  105. package/dist/types/glint.js +4 -0
  106. package/dist/types/glint.js.map +1 -0
  107. package/dist/types/globals.js +2 -0
  108. package/dist/types/globals.js.map +1 -0
  109. package/dist/utils/content-tag-loader.js +9 -0
  110. package/dist/utils/ember-native.js +9 -0
  111. package/dist/utils/eslint/ember-native.js +9 -0
  112. package/dist/utils/fix-glimmer-content-owner.js +13 -0
  113. package/dist/utils/glimmer-env.js +3 -0
  114. package/dist/utils/webpack.config.js +72 -0
  115. package/package.json +174 -0
  116. package/types/ember.d.ts +1 -0
@@ -0,0 +1,198 @@
1
+ import { _ as _defineProperty } from '../../_rollupPluginBabelHelpers-DZQzmiRH.js';
2
+ import { createElement } from '../element-registry.js';
3
+ import CommentNode from './CommentNode.js';
4
+ import ElementNode from './ElementNode.js';
5
+ import PropertyNode from './PropertyNode.js';
6
+ import TextNode from './TextNode.js';
7
+ import ViewNode from './ViewNode.js';
8
+ import NativeElementNode from '../native/NativeElementNode.js';
9
+
10
+ function* elementIterator(el) {
11
+ yield el;
12
+ for (const child of el.childNodes) {
13
+ yield* elementIterator(child);
14
+ }
15
+ }
16
+ class HeadNode extends ElementNode {
17
+ constructor(tagName, document) {
18
+ super(tagName);
19
+ _defineProperty(this, "document", void 0);
20
+ this.document = document;
21
+ }
22
+ appendChild(childNode) {
23
+ if (childNode.tagName === 'style') {
24
+ this.document.page.nativeView.addCss(childNode.childNodes[0].text);
25
+ return;
26
+ }
27
+ super.appendChild(childNode);
28
+ }
29
+ }
30
+ let document = null;
31
+ class DocumentNode extends ViewNode {
32
+ static getInstance() {
33
+ if (!document) {
34
+ document = new DocumentNode();
35
+ }
36
+ return document;
37
+ }
38
+ constructor() {
39
+ if (document) return document;
40
+ super();
41
+ _defineProperty(this, "head", void 0);
42
+ _defineProperty(this, "config", void 0);
43
+ _defineProperty(this, "page", void 0);
44
+ _defineProperty(this, "body", void 0);
45
+ _defineProperty(this, "documentElement", {
46
+ dataset: {}
47
+ });
48
+ document = this;
49
+ this.tagName = 'docNode';
50
+ this.nodeType = 9;
51
+ this.head = new HeadNode('head', this);
52
+ this.appendChild(this.head);
53
+ this.nodeMap = new Map();
54
+ }
55
+ createComment(text) {
56
+ return new CommentNode(text);
57
+ }
58
+ static createPropertyNode(tagName, propertyName) {
59
+ return new PropertyNode(tagName, propertyName);
60
+ }
61
+ createElement(name) {
62
+ return DocumentNode.createElement(name);
63
+ }
64
+ static createElement(tagName) {
65
+ if (tagName.indexOf('.') >= 0) {
66
+ const bits = tagName.split('.', 2);
67
+ return this.createPropertyNode(bits[0], bits[1]);
68
+ }
69
+ const e = createElement(tagName);
70
+ e._ownerDocument = this.getInstance();
71
+ if (e instanceof NativeElementNode && e.nativeView) {
72
+ this.getInstance().nodeMap.set(e.nativeView._domId, e);
73
+ }
74
+ if (tagName === 'page') {
75
+ this.getInstance().page = e;
76
+ Object.defineProperty(this.getInstance(), 'body', {
77
+ configurable: true,
78
+ get() {
79
+ const page = this.page;
80
+ return {
81
+ insertAdjacentHTML() {
82
+ return null;
83
+ },
84
+ addEventListener: globalThis.addEventListener.bind(page),
85
+ get lastChild() {
86
+ return null;
87
+ }
88
+ };
89
+ }
90
+ });
91
+ }
92
+ return e;
93
+ }
94
+ createElementNS(_namespace, tagName) {
95
+ return DocumentNode.createElement(tagName);
96
+ }
97
+ createTextNode(text) {
98
+ return new TextNode(text);
99
+ }
100
+ addEventListener(event, callback) {
101
+ if (event === 'DOMContentLoaded') {
102
+ setTimeout(callback, 0);
103
+ return;
104
+ }
105
+ console.error('unsupported event on document', event);
106
+ }
107
+ removeEventListener(event, handler) {
108
+ if (event === 'DOMContentLoaded') {
109
+ return;
110
+ }
111
+ console.error('unsupported event on document', event, handler);
112
+ }
113
+ searchDom(node, startNode, endNode) {
114
+ const start = startNode || this.page;
115
+ if (start === node) {
116
+ return true;
117
+ }
118
+ if (node === endNode) {
119
+ return false;
120
+ }
121
+ for (const childNode of start.childNodes) {
122
+ if (this.searchDom(node, childNode, endNode)) {
123
+ return true;
124
+ }
125
+ }
126
+ let sibling = node;
127
+ while (sibling) {
128
+ if (this.searchDom(node, sibling, endNode)) {
129
+ return true;
130
+ }
131
+ sibling = sibling.nextSibling;
132
+ }
133
+ return false;
134
+ }
135
+ createRange() {
136
+ const self = this;
137
+ return {
138
+ startNode: null,
139
+ endNode: null,
140
+ setStartBefore(startNode) {
141
+ while (startNode && !startNode.nativeView) {
142
+ startNode = startNode.nextSibling;
143
+ }
144
+ this.startNode = startNode;
145
+ },
146
+ setEndAfter(endNode) {
147
+ while (endNode && !endNode.nativeView) {
148
+ endNode = endNode.prevSibling;
149
+ }
150
+ this.endNode = endNode;
151
+ },
152
+ isPointInRange(dom) {
153
+ return self.searchDom(dom, this.startNode, this.endNode);
154
+ },
155
+ getBoundingClientRect() {
156
+ if (!(this.startNode instanceof NativeElementNode)) return null;
157
+ if (!this.startNode?.nativeView) return null;
158
+ const point = this.startNode.nativeView.getLocationInWindow();
159
+ const size = this.startNode.nativeView.getActualSize();
160
+ let x = point.x;
161
+ let y = point.y;
162
+ let width = size.width;
163
+ let height = size.height;
164
+ for (const element of elementIterator(this.startNode)) {
165
+ const point = element.nativeView.getLocationInWindow();
166
+ const size = element.nativeView.getActualSize();
167
+ x = Math.min(x, point.x);
168
+ y = Math.min(y, point.y);
169
+ width = point.x + size.width - x;
170
+ height = point.y + size.height - y;
171
+ if (element === this.endNode) {
172
+ break;
173
+ }
174
+ }
175
+ return {
176
+ left: x,
177
+ top: y,
178
+ bottom: y + height,
179
+ width,
180
+ height
181
+ };
182
+ }
183
+ };
184
+ }
185
+ querySelectorAll(selector) {
186
+ if (selector.startsWith('meta')) {
187
+ const config = this.config;
188
+ return {
189
+ getAttribute() {
190
+ return JSON.stringify(config);
191
+ }
192
+ };
193
+ }
194
+ }
195
+ }
196
+
197
+ export { DocumentNode as default };
198
+ //# sourceMappingURL=DocumentNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentNode.js","sources":["../../../src/dom/nodes/DocumentNode.ts"],"sourcesContent":["import { createElement } from '../element-registry.ts';\nimport CommentNode from './CommentNode.ts';\nimport ElementNode from './ElementNode.ts';\nimport PropertyNode from './PropertyNode.ts';\nimport TextNode from './TextNode.ts';\nimport ViewNode from './ViewNode.ts';\nimport type { NativeElementsTagNameMap } from '../native-elements-tag-name-map.ts';\nimport type PageElement from '../native/PageElement.ts';\nimport NativeElementNode from '../native/NativeElementNode.ts';\n\nfunction* elementIterator(el: any): Generator<any, void, unknown> {\n yield el;\n for (const child of el.childNodes) {\n yield* elementIterator(child);\n }\n}\n\nclass HeadNode extends ElementNode {\n private document: any;\n constructor(tagName: string, document: DocumentNode) {\n super(tagName);\n this.document = document;\n }\n appendChild(childNode: ViewNode) {\n if (childNode.tagName === 'style') {\n this.document.page.nativeView.addCss(\n (childNode.childNodes[0]! as any).text,\n );\n return;\n }\n super.appendChild(childNode);\n }\n}\n\nlet document: DocumentNode | null = null;\n\nexport default class DocumentNode extends ViewNode {\n head: any;\n config: any;\n declare nodeMap: Map<any, any>;\n page: PageElement | undefined;\n body: ElementNode | undefined;\n documentElement = {\n dataset: {},\n };\n\n static getInstance() {\n if (!document) {\n document = new DocumentNode();\n }\n return document;\n }\n\n constructor() {\n if (document) return document;\n super();\n document = this;\n this.tagName = 'docNode';\n this.nodeType = 9;\n this.head = new HeadNode('head', this);\n this.appendChild(this.head);\n this.nodeMap = new Map();\n }\n\n createComment(text: string) {\n return new CommentNode(text);\n }\n\n static createPropertyNode(\n tagName: string,\n propertyName: string,\n ): PropertyNode {\n return new PropertyNode(tagName, propertyName);\n }\n\n createElement(name: string) {\n return DocumentNode.createElement(name as any);\n }\n\n static createElement<T extends keyof NativeElementsTagNameMap>(\n tagName: T,\n ): NativeElementsTagNameMap[T] {\n if (tagName.indexOf('.') >= 0) {\n const bits = tagName.split('.', 2);\n return this.createPropertyNode(bits[0]!, bits[1]!) as any;\n }\n const e = createElement(tagName);\n e._ownerDocument = this.getInstance();\n if (e instanceof NativeElementNode && e.nativeView) {\n this.getInstance().nodeMap.set(e.nativeView._domId, e);\n }\n if (tagName === 'page') {\n this.getInstance().page = e as PageElement;\n\n Object.defineProperty(this.getInstance(), 'body', {\n configurable: true,\n get() {\n const page = this.page;\n return {\n insertAdjacentHTML() {\n return null;\n },\n addEventListener: globalThis.addEventListener.bind(page),\n get lastChild() {\n return null;\n },\n };\n },\n });\n }\n return e;\n }\n\n createElementNS(_namespace: any, tagName: keyof NativeElementsTagNameMap) {\n return DocumentNode.createElement(tagName);\n }\n\n createTextNode(text: string) {\n return new TextNode(text);\n }\n\n addEventListener(event: string, callback: EventListener) {\n if (event === 'DOMContentLoaded') {\n setTimeout(callback, 0);\n return;\n }\n console.error('unsupported event on document', event);\n }\n\n removeEventListener(event: string, handler: EventListener) {\n if (event === 'DOMContentLoaded') {\n return;\n }\n console.error('unsupported event on document', event, handler);\n }\n\n searchDom(node: ViewNode, startNode: ViewNode, endNode: ViewNode) {\n const start = startNode || this.page;\n if (start === node) {\n return true;\n }\n if (node === endNode) {\n return false;\n }\n for (const childNode of start.childNodes) {\n if (this.searchDom(node, childNode, endNode)) {\n return true;\n }\n }\n let sibling: ViewNode | null = node;\n while (sibling) {\n if (this.searchDom(node, sibling, endNode)) {\n return true;\n }\n sibling = sibling.nextSibling;\n }\n return false;\n }\n\n createRange() {\n const self = this;\n return {\n startNode: null as ViewNode | null,\n endNode: null as ViewNode | null,\n setStartBefore(startNode: ViewNode | null) {\n while (startNode && !(startNode as NativeElementNode).nativeView) {\n startNode = startNode.nextSibling;\n }\n this.startNode = startNode;\n },\n setEndAfter(endNode: ViewNode | null) {\n while (endNode && !(endNode as NativeElementNode).nativeView) {\n endNode = endNode.prevSibling;\n }\n this.endNode = endNode;\n },\n isPointInRange(dom: ViewNode): boolean {\n return self.searchDom(dom, this.startNode!, this.endNode!);\n },\n getBoundingClientRect() {\n if (!(this.startNode instanceof NativeElementNode)) return null;\n if (!this.startNode?.nativeView) return null;\n const point = this.startNode.nativeView.getLocationInWindow();\n const size = this.startNode.nativeView.getActualSize();\n let x = point.x;\n let y = point.y;\n let width = size.width;\n let height = size.height;\n for (const element of elementIterator(this.startNode)) {\n const point = element.nativeView.getLocationInWindow();\n const size = element.nativeView.getActualSize();\n x = Math.min(x, point.x);\n y = Math.min(y, point.y);\n width = point.x + size.width - x;\n height = point.y + size.height - y;\n if (element === this.endNode) {\n break;\n }\n }\n return {\n left: x,\n top: y,\n bottom: y + height,\n width,\n height,\n };\n },\n };\n }\n\n querySelectorAll(selector: string) {\n if (selector.startsWith('meta')) {\n const config = this.config;\n return {\n getAttribute(): string {\n return JSON.stringify(config);\n },\n };\n }\n }\n}\n"],"names":["elementIterator","el","child","childNodes","HeadNode","ElementNode","constructor","tagName","document","_defineProperty","appendChild","childNode","page","nativeView","addCss","text","DocumentNode","ViewNode","getInstance","dataset","nodeType","head","nodeMap","Map","createComment","CommentNode","createPropertyNode","propertyName","PropertyNode","createElement","name","indexOf","bits","split","e","_ownerDocument","NativeElementNode","set","_domId","Object","defineProperty","configurable","get","insertAdjacentHTML","addEventListener","globalThis","bind","lastChild","createElementNS","_namespace","createTextNode","TextNode","event","callback","setTimeout","console","error","removeEventListener","handler","searchDom","node","startNode","endNode","start","sibling","nextSibling","createRange","self","setStartBefore","setEndAfter","prevSibling","isPointInRange","dom","getBoundingClientRect","point","getLocationInWindow","size","getActualSize","x","y","width","height","element","Math","min","left","top","bottom","querySelectorAll","selector","startsWith","config","getAttribute","JSON","stringify"],"mappings":";;;;;;;;;AAUA,UAAUA,eAAeA,CAACC,EAAO,EAAiC;AAChE,EAAA,MAAMA,EAAE;AACR,EAAA,KAAK,MAAMC,KAAK,IAAID,EAAE,CAACE,UAAU,EAAE;IACjC,OAAOH,eAAe,CAACE,KAAK,CAAC;AAC/B;AACF;AAEA,MAAME,QAAQ,SAASC,WAAW,CAAC;AAEjCC,EAAAA,WAAWA,CAACC,OAAe,EAAEC,QAAsB,EAAE;IACnD,KAAK,CAACD,OAAO,CAAC;IAAAE,eAAA,CAAA,IAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA;IACd,IAAI,CAACD,QAAQ,GAAGA,QAAQ;AAC1B;EACAE,WAAWA,CAACC,SAAmB,EAAE;AAC/B,IAAA,IAAIA,SAAS,CAACJ,OAAO,KAAK,OAA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ACrB,UAAA,OAAOC,IAAI,CAACC,SAAS,CAACH,MAAM,CAAC;AAC/B;OACD;AACH;AACF;AACF;;;;"}
@@ -0,0 +1,267 @@
1
+ import ViewNode from './ViewNode.js';
2
+
3
+ // import { KeyframeAnimation } from '@nativescript/core/ui/animation/keyframe-animation';
4
+ // import { Page } from '@nativescript/core/ui/page';
5
+ // import { CssAnimationParser } from '@nativescript/core/ui/styling/css-animation-parser';
6
+
7
+
8
+ // import { getViewClass } from '../element-registry';
9
+ // import ViewNode from './ViewNode';
10
+
11
+ // function camelize(kebab) {
12
+ // return kebab.replace(/[\-]+(\w)/g, (m, l) => l.toUpperCase());
13
+ // }
14
+
15
+ // const EVENT_ATTRIBUTES = Object.freeze(['tap']);
16
+
17
+ // export default class ElementNode extends ViewNode {
18
+ // style: any;
19
+ // animations: Map<string, KeyframeAnimation> = new Map();
20
+ // oldAnimations: KeyframeAnimation[] = [];
21
+ // constructor(tagName: any) {
22
+ // super();
23
+
24
+ // this.nodeType = 1;
25
+ // this.tagName = tagName;
26
+
27
+ // //there are some special elements that don't exist natively
28
+ // const viewClass = getViewClass(tagName);
29
+ // if (viewClass) {
30
+ // this._nativeView = new viewClass();
31
+ // this._nativeView.__GlimmerNativeElement__ = this;
32
+ // // console.log(`${this} has view class`);
33
+ // EVENT_ATTRIBUTES.forEach((event) => {
34
+ // // console.log(`Checking for atttribute ${event}`);
35
+ // let attribute = this.getAttribute(event);
36
+ // // console.log(`Attribute ${event}: ${attribute}`);
37
+ // // console.log(`Native view attribute ${event}: ${this._nativeView.getAttribute(event)}`);
38
+ // if (attribute) {
39
+ // this.addEventListener(event, attribute);
40
+ // }
41
+ // });
42
+ // }
43
+
44
+ // // console.log(`created ${this} ${this._nativeView}`);
45
+
46
+ // let setStyle = (value) => {
47
+ // this.setAttribute('style', value);
48
+ // };
49
+
50
+ // let getStyle = () => {
51
+ // return this.getAttribute('style');
52
+ // };
53
+
54
+ // this.style = {
55
+ // setProperty: (propertyName, value, priority) => {
56
+ // this.setStyle(camelize(propertyName), value);
57
+ // },
58
+
59
+ // removeProperty: (propertyName) => {
60
+ // this.setStyle(camelize(propertyName), null);
61
+ // },
62
+
63
+ // get cssText() {
64
+ // // console.log('got css text');
65
+ // return getStyle();
66
+ // },
67
+
68
+ // set cssText(value) {
69
+ // // console.log('set css text');
70
+ // setStyle(value);
71
+ // }
72
+ // };
73
+ // }
74
+
75
+ // animate(options) {
76
+ // if (this.nativeView) {
77
+ // this.nativeView.animate(options);
78
+ // }
79
+ // }
80
+
81
+ // getParentPage(): ElementNode {
82
+ // if (this.nativeView && this.nativeView.page) {
83
+ // return (this.nativeView.page as any).__GlimmerNativeElement__;
84
+ // }
85
+ // return null;
86
+ // }
87
+
88
+ // addAnimation(animation: string) {
89
+ // if (!this.nativeView) {
90
+ // throw Error('Attempt to apply animation to tag without a native view' + this.tagName);
91
+ // }
92
+
93
+ // let page = this.getParentPage();
94
+ // if (page === null) {
95
+ // this.animations.set(animation, null);
96
+ // return;
97
+ // }
98
+
99
+ // //quickly cancel any old ones
100
+ // while (this.oldAnimations.length) {
101
+ // let oldAnimation = this.oldAnimations.shift();
102
+ // if (oldAnimation.isPlaying) {
103
+ // oldAnimation.cancel();
104
+ // }
105
+ // }
106
+
107
+ // //Parse our "animation" style property into an animation info instance (this won't include the keyframes from the css)
108
+ // let animationInfos = CssAnimationParser.keyframeAnimationsFromCSSDeclarations([
109
+ // { property: 'animation', value: animation }
110
+ // ]);
111
+ // if (!animationInfos) {
112
+ // this.animations.set(animation, null);
113
+ // return;
114
+ // }
115
+ // let animationInfo = animationInfos[0];
116
+
117
+ // //Fetch an animationInfo instance that includes the keyframes from the css (this won't include the animation properties parsed above)
118
+ // let animationWithKeyframes = (page.nativeView as Page).getKeyframeAnimationWithName(animationInfo.name);
119
+ // if (!animationWithKeyframes) {
120
+ // this.animations.set(animation, null);
121
+ // return;
122
+ // }
123
+
124
+ // animationInfo.keyframes = animationWithKeyframes.keyframes;
125
+ // //combine the keyframes from the css with the animation from the parsed attribute to get a complete animationInfo object
126
+ // let animationInstance = KeyframeAnimation.keyframeAnimationFromInfo(animationInfo);
127
+
128
+ // // save and launch the animation
129
+ // this.animations.set(animation, animationInstance);
130
+ // animationInstance.play(this.nativeView);
131
+ // }
132
+
133
+ // removeAnimation(animation: string) {
134
+ // if (this.animations.has(animation)) {
135
+ // let animationInstance = this.animations.get(animation);
136
+ // this.animations.delete(animation);
137
+
138
+ // if (animationInstance) {
139
+ // if (animationInstance.isPlaying) {
140
+ // //we don't want to stop right away since svelte removes the animation before it is finished due to our lag time starting the animation.
141
+ // this.oldAnimations.push(animationInstance);
142
+ // }
143
+ // }
144
+ // }
145
+ // }
146
+
147
+ // get animation(): string {
148
+ // return [...this.animations.keys()].join(', ');
149
+ // }
150
+
151
+ // set animation(value: string) {
152
+ // let new_animations = value.trim() == '' ? [] : value.split(',').map((a) => a.trim());
153
+ // //add new ones
154
+ // for (let anim of new_animations) {
155
+ // if (!this.animations.has(anim)) {
156
+ // this.addAnimation(anim);
157
+ // }
158
+ // }
159
+ // //remove old ones
160
+ // for (let anim of this.animations.keys()) {
161
+ // if (new_animations.indexOf(anim) < 0) {
162
+ // this.removeAnimation(anim);
163
+ // }
164
+ // }
165
+ // }
166
+
167
+ // setAttribute(key, value) {
168
+ // // console.log(`setAttribute: ${key} - ${value}`);
169
+ // if (key.startsWith('on:')) {
170
+ // key = key.substr(3);
171
+ // this.addEventListener(key, value);
172
+ // } else {
173
+ // super.setAttribute(key, value);
174
+ // }
175
+ // }
176
+
177
+ // appendChild(childNode) {
178
+ // super.appendChild(childNode);
179
+
180
+ // if (childNode.nodeType === 3) {
181
+ // this.setText(childNode.text);
182
+ // }
183
+
184
+ // if (childNode.nodeType === 7) {
185
+ // childNode.setOnNode(this);
186
+ // }
187
+ // }
188
+
189
+ // insertBefore(childNode, referenceNode) {
190
+ // super.insertBefore(childNode, referenceNode);
191
+
192
+ // if (childNode.nodeType === 3) {
193
+ // this.setText(childNode.text);
194
+ // }
195
+
196
+ // if (childNode.nodeType === 7) {
197
+ // childNode.setOnNode(this);
198
+ // }
199
+ // }
200
+
201
+ // removeChild(childNode) {
202
+ // super.removeChild(childNode);
203
+
204
+ // if (childNode.nodeType === 3) {
205
+ // this.setText('');
206
+ // }
207
+
208
+ // if (childNode.nodeType === 7) {
209
+ // childNode.clearOnNode(this);
210
+ // }
211
+ // }
212
+ // }
213
+
214
+ class ElementNode extends ViewNode {
215
+ constructor(tagName) {
216
+ super();
217
+ this.nodeType = 1;
218
+ this.tagName = tagName;
219
+ }
220
+ get id() {
221
+ return this.getAttribute('id');
222
+ }
223
+ set id(value) {
224
+ this.setAttribute('id', value);
225
+ }
226
+ get classList() {
227
+ if (!this._classList) {
228
+ const getClasses = () => (this.getAttribute('class') || '').split(/\s+/).filter(k => k != '');
229
+ this._classList = {
230
+ add: (...classNames) => {
231
+ this.setAttribute('class', [...new Set(getClasses().concat(classNames))].join(' '));
232
+ },
233
+ contains(klass) {
234
+ return Boolean(getClasses().find(x => x === klass));
235
+ },
236
+ remove: (...classNames) => {
237
+ this.setAttribute('class', getClasses().filter(i => classNames.indexOf(i) == -1).join(' '));
238
+ },
239
+ get length() {
240
+ return getClasses().length;
241
+ }
242
+ };
243
+ }
244
+ return this._classList;
245
+ }
246
+ appendChild(childNode) {
247
+ super.appendChild(childNode);
248
+ if (childNode.nodeType === 7) {
249
+ childNode.setOnNode(this);
250
+ }
251
+ }
252
+ insertBefore(childNode, referenceNode) {
253
+ super.insertBefore(childNode, referenceNode);
254
+ if (childNode.nodeType === 7) {
255
+ childNode.setOnNode(this);
256
+ }
257
+ }
258
+ removeChild(childNode) {
259
+ super.removeChild(childNode);
260
+ if (childNode.nodeType === 7) {
261
+ childNode.clearOnNode(this);
262
+ }
263
+ }
264
+ }
265
+
266
+ export { ElementNode as default };
267
+ //# sourceMappingURL=ElementNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementNode.js","sources":["../../../src/dom/nodes/ElementNode.ts"],"sourcesContent":["// import { KeyframeAnimation } from '@nativescript/core/ui/animation/keyframe-animation';\n// import { Page } from '@nativescript/core/ui/page';\n// import { CssAnimationParser } from '@nativescript/core/ui/styling/css-animation-parser';\nimport PropertyNode from './PropertyNode.ts';\nimport ViewNode from './ViewNode.ts';\n\n// import { getViewClass } from '../element-registry';\n// import ViewNode from './ViewNode';\n\n// function camelize(kebab) {\n// return kebab.replace(/[\\-]+(\\w)/g, (m, l) => l.toUpperCase());\n// }\n\n// const EVENT_ATTRIBUTES = Object.freeze(['tap']);\n\n// export default class ElementNode extends ViewNode {\n// style: any;\n// animations: Map<string, KeyframeAnimation> = new Map();\n// oldAnimations: KeyframeAnimation[] = [];\n// constructor(tagName: any) {\n// super();\n\n// this.nodeType = 1;\n// this.tagName = tagName;\n\n// //there are some special elements that don't exist natively\n// const viewClass = getViewClass(tagName);\n// if (viewClass) {\n// this._nativeView = new viewClass();\n// this._nativeView.__GlimmerNativeElement__ = this;\n// // console.log(`${this} has view class`);\n// EVENT_ATTRIBUTES.forEach((event) => {\n// // console.log(`Checking for atttribute ${event}`);\n// let attribute = this.getAttribute(event);\n// // console.log(`Attribute ${event}: ${attribute}`);\n// // console.log(`Native view attribute ${event}: ${this._nativeView.getAttribute(event)}`);\n// if (attribute) {\n// this.addEventListener(event, attribute);\n// }\n// });\n// }\n\n// // console.log(`created ${this} ${this._nativeView}`);\n\n// let setStyle = (value) => {\n// this.setAttribute('style', value);\n// };\n\n// let getStyle = () => {\n// return this.getAttribute('style');\n// };\n\n// this.style = {\n// setProperty: (propertyName, value, priority) => {\n// this.setStyle(camelize(propertyName), value);\n// },\n\n// removeProperty: (propertyName) => {\n// this.setStyle(camelize(propertyName), null);\n// },\n\n// get cssText() {\n// // console.log('got css text');\n// return getStyle();\n// },\n\n// set cssText(value) {\n// // console.log('set css text');\n// setStyle(value);\n// }\n// };\n// }\n\n// animate(options) {\n// if (this.nativeView) {\n// this.nativeView.animate(options);\n// }\n// }\n\n// getParentPage(): ElementNode {\n// if (this.nativeView && this.nativeView.page) {\n// return (this.nativeView.page as any).__GlimmerNativeElement__;\n// }\n// return null;\n// }\n\n// addAnimation(animation: string) {\n// if (!this.nativeView) {\n// throw Error('Attempt to apply animation to tag without a native view' + this.tagName);\n// }\n\n// let page = this.getParentPage();\n// if (page === null) {\n// this.animations.set(animation, null);\n// return;\n// }\n\n// //quickly cancel any old ones\n// while (this.oldAnimations.length) {\n// let oldAnimation = this.oldAnimations.shift();\n// if (oldAnimation.isPlaying) {\n// oldAnimation.cancel();\n// }\n// }\n\n// //Parse our \"animation\" style property into an animation info instance (this won't include the keyframes from the css)\n// let animationInfos = CssAnimationParser.keyframeAnimationsFromCSSDeclarations([\n// { property: 'animation', value: animation }\n// ]);\n// if (!animationInfos) {\n// this.animations.set(animation, null);\n// return;\n// }\n// let animationInfo = animationInfos[0];\n\n// //Fetch an animationInfo instance that includes the keyframes from the css (this won't include the animation properties parsed above)\n// let animationWithKeyframes = (page.nativeView as Page).getKeyframeAnimationWithName(animationInfo.name);\n// if (!animationWithKeyframes) {\n// this.animations.set(animation, null);\n// return;\n// }\n\n// animationInfo.keyframes = animationWithKeyframes.keyframes;\n// //combine the keyframes from the css with the animation from the parsed attribute to get a complete animationInfo object\n// let animationInstance = KeyframeAnimation.keyframeAnimationFromInfo(animationInfo);\n\n// // save and launch the animation\n// this.animations.set(animation, animationInstance);\n// animationInstance.play(this.nativeView);\n// }\n\n// removeAnimation(animation: string) {\n// if (this.animations.has(animation)) {\n// let animationInstance = this.animations.get(animation);\n// this.animations.delete(animation);\n\n// if (animationInstance) {\n// if (animationInstance.isPlaying) {\n// //we don't want to stop right away since svelte removes the animation before it is finished due to our lag time starting the animation.\n// this.oldAnimations.push(animationInstance);\n// }\n// }\n// }\n// }\n\n// get animation(): string {\n// return [...this.animations.keys()].join(', ');\n// }\n\n// set animation(value: string) {\n// let new_animations = value.trim() == '' ? [] : value.split(',').map((a) => a.trim());\n// //add new ones\n// for (let anim of new_animations) {\n// if (!this.animations.has(anim)) {\n// this.addAnimation(anim);\n// }\n// }\n// //remove old ones\n// for (let anim of this.animations.keys()) {\n// if (new_animations.indexOf(anim) < 0) {\n// this.removeAnimation(anim);\n// }\n// }\n// }\n\n// setAttribute(key, value) {\n// // console.log(`setAttribute: ${key} - ${value}`);\n// if (key.startsWith('on:')) {\n// key = key.substr(3);\n// this.addEventListener(key, value);\n// } else {\n// super.setAttribute(key, value);\n// }\n// }\n\n// appendChild(childNode) {\n// super.appendChild(childNode);\n\n// if (childNode.nodeType === 3) {\n// this.setText(childNode.text);\n// }\n\n// if (childNode.nodeType === 7) {\n// childNode.setOnNode(this);\n// }\n// }\n\n// insertBefore(childNode, referenceNode) {\n// super.insertBefore(childNode, referenceNode);\n\n// if (childNode.nodeType === 3) {\n// this.setText(childNode.text);\n// }\n\n// if (childNode.nodeType === 7) {\n// childNode.setOnNode(this);\n// }\n// }\n\n// removeChild(childNode) {\n// super.removeChild(childNode);\n\n// if (childNode.nodeType === 3) {\n// this.setText('');\n// }\n\n// if (childNode.nodeType === 7) {\n// childNode.clearOnNode(this);\n// }\n// }\n// }\n\nexport interface IClassList {\n length: number;\n\n add(...classNames: string[]): void;\n\n remove(...classNames: string[]): void;\n\n contains(className: string): boolean;\n}\n\nexport default class ElementNode extends ViewNode {\n declare _classList: IClassList;\n\n constructor(tagName: string) {\n super();\n this.nodeType = 1;\n this.tagName = tagName;\n }\n\n get id() {\n return this.getAttribute('id') as string;\n }\n\n set id(value: string) {\n this.setAttribute('id', value);\n }\n\n get classList() {\n if (!this._classList) {\n const getClasses: () => string[] = () =>\n ((this.getAttribute('class') as string) || '')\n .split(/\\s+/)\n .filter((k: string) => k != '');\n\n this._classList = {\n add: (...classNames: string[]) => {\n this.setAttribute(\n 'class',\n [...new Set(getClasses().concat(classNames))].join(' '),\n );\n },\n\n contains(klass: string) {\n return Boolean(getClasses().find((x) => x === klass));\n },\n\n remove: (...classNames: string[]) => {\n this.setAttribute(\n 'class',\n getClasses()\n .filter((i: string) => classNames.indexOf(i) == -1)\n .join(' '),\n );\n },\n\n get length() {\n return getClasses().length;\n },\n };\n }\n return this._classList;\n }\n\n appendChild(childNode: ViewNode) {\n super.appendChild(childNode);\n\n if (childNode.nodeType === 7) {\n (childNode as PropertyNode).setOnNode(this);\n }\n }\n\n insertBefore(childNode: ViewNode, referenceNode: ViewNode) {\n super.insertBefore(childNode, referenceNode);\n\n if (childNode.nodeType === 7) {\n (childNode as PropertyNode).setOnNode(this);\n }\n }\n\n removeChild(childNode: ViewNode) {\n super.removeChild(childNode);\n\n if (childNode.nodeType === 7) {\n (childNode as PropertyNode).clearOnNode(this);\n }\n }\n}\n"],"names":["ElementNode","ViewNode","constructor","tagName","nodeType","id","getAttribute","value","setAttribute","classList","_classList","getClasses","split","filter","k","add","classNames","Set","concat","join","contains","klass","Boolean","find","x","remove","i","indexOf","length","appendChild","childNode","setOnNode","insertBefore","referenceNode","removeChild","clearOnNode"],"mappings":";;AAAA;AACA;AACA;;;AAIA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA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I,CAAEC,CAAC,IAAKA,CAAC,KAAKH,KAAK,CAAC,CAAC;SACtD;AAEDI,QAAAA,MAAM,EAAEA,CAAC,GAAGT,UAAoB,KAAK;AACnC,UAAA,IAAI,CAACR,YAAY,CACf,OAAO,EACPG,UAAU,EAAE,CACTE,MAAM,CAAEa,CAAS,IAAKV,UAAU,CAACW,OAAO,CAACD,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAClDP,IAAI,CAAC,GAAG,CACb,CAAC;SACF;QAED,IAAIS,MAAMA,GAAG;AACX,UAAA,OAAOjB,UAAU,EAAE,CAACiB,MAAM;AAC5B;OACD;AACH;IACA,OAAO,IAAI,CAAClB,UAAU;AACxB;EAEAmB,WAAWA,CAACC,SAAmB,EAAE;AAC/B,IAAA,KAAK,CAACD,WAAW,CAACC,SAAS,CAAC;AAE5B,IAAA,IAAIA,SAAS,CAAC1B,QAAQ,KAAK,CAAC,EAAE;AAC3B0B,MAAAA,SAAS,CAAkBC,SAAS,CAAC,IAAI,CAAC;AAC7C;AACF;AAEAC,EAAAA,YAAYA,CAACF,SAAmB,EAAEG,aAAuB,EAAE;AACzD,IAAA,KAAK,CAACD,YAAY,CAACF,SAAS,EAAEG,aAAa,CAAC;AAE5C,IAAA,IAAIH,SAAS,CAAC1B,QAAQ,KAAK,CAAC,EAAE;AAC3B0B,MAAAA,SAAS,CAAkBC,SAAS,CAAC,IAAI,CAAC;AAC7C;AACF;EAEAG,WAAWA,CAACJ,SAAmB,EAAE;AAC/B,IAAA,KAAK,CAACI,WAAW,CAACJ,SAAS,CAAC;AAE5B,IAAA,IAAIA,SAAS,CAAC1B,QAAQ,KAAK,CAAC,EAAE;AAC3B0B,MAAAA,SAAS,CAAkBK,WAAW,CAAC,IAAI,CAAC;AAC/C;AACF;AACF;;;;"}
@@ -0,0 +1,39 @@
1
+ import { _ as _defineProperty } from '../../_rollupPluginBabelHelpers-DZQzmiRH.js';
2
+ import { normalizeElementName } from '../element-registry.js';
3
+ import ElementNode from './ElementNode.js';
4
+
5
+ class PropertyNode extends ElementNode {
6
+ constructor(tagName, propertyName) {
7
+ super(`${tagName}.${propertyName}`);
8
+ _defineProperty(this, "propertyName", void 0);
9
+ _defineProperty(this, "propertyTagName", void 0);
10
+ this.propertyName = propertyName;
11
+ this.propertyTagName = normalizeElementName(tagName);
12
+ this.nodeType = 7; //processing instruction
13
+ }
14
+ onInsertedChild() {
15
+ this.setOnNode(this.parentNode);
16
+ }
17
+ onRemovedChild() {
18
+ this.setOnNode(this.parentNode);
19
+ }
20
+
21
+ /* istanbul ignore next */
22
+ toString() {
23
+ return `${this.constructor.name}(${this.tagName}, ${this.propertyName})`;
24
+ }
25
+ setOnNode(parent) {
26
+ if (parent && parent.tagName === this.propertyTagName) {
27
+ const el = this.firstElement();
28
+ parent.setAttribute(this.propertyName, el);
29
+ }
30
+ }
31
+ clearOnNode(parent) {
32
+ if (parent && parent.tagName === this.propertyTagName) {
33
+ parent.setAttribute(this.propertyName, null);
34
+ }
35
+ }
36
+ }
37
+
38
+ export { PropertyNode as default };
39
+ //# sourceMappingURL=PropertyNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropertyNode.js","sources":["../../../src/dom/nodes/PropertyNode.ts"],"sourcesContent":["import { normalizeElementName } from '../element-registry.ts';\nimport ElementNode from './ElementNode.ts';\nimport ViewNode from './ViewNode.ts';\n\nexport default class PropertyNode extends ElementNode {\n propertyName: string;\n propertyTagName: string;\n\n constructor(tagName: string, propertyName: string) {\n super(`${tagName}.${propertyName}`);\n this.propertyName = propertyName;\n this.propertyTagName = normalizeElementName(tagName);\n\n this.nodeType = 7; //processing instruction\n }\n\n onInsertedChild() {\n this.setOnNode(this.parentNode);\n }\n\n onRemovedChild() {\n this.setOnNode(this.parentNode);\n }\n\n /* istanbul ignore next */\n toString() {\n return `${this.constructor.name}(${this.tagName}, ${this.propertyName})`;\n }\n\n setOnNode(parent: ViewNode | null) {\n if (parent && parent.tagName === this.propertyTagName) {\n const el = this.firstElement();\n parent.setAttribute(this.propertyName, el);\n }\n }\n\n clearOnNode(parent: ViewNode) {\n if (parent && parent.tagName === this.propertyTagName) {\n parent.setAttribute(this.propertyName, null);\n }\n }\n}\n"],"names":["PropertyNode","ElementNode","constructor","tagName","propertyName","_defineProperty","propertyTagName","normalizeElementName","nodeType","onInsertedChild","setOnNode","parentNode","onRemovedChild","toString","name","parent","el","firstElement","setAttribute","clearOnNode"],"mappings":";;;;AAIe,MAAMA,YAAY,SAASC,WAAW,CAAC;AAIpDC,EAAAA,WAAWA,CAACC,OAAe,EAAEC,YAAoB,EAAE;AACjD,IAAA,KAAK,CAAC,CAAGD,EAAAA,OAAO,CAAIC,CAAAA,EAAAA,YAAY,EAAE,CAAC;IAAAC,eAAA,CAAA,IAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA;IAAAA,eAAA,CAAA,IAAA,EAAA,iBAAA,EAAA,KAAA,CAAA,CAAA;IACnC,IAAI,CAACD,YAAY,GAAGA,YAAY;AAChC,IAAA,IAAI,CAACE,eAAe,GAAGC,oBAAoB,CAACJ,OAAO,CAAC;AAEpD,IAAA,IAAI,CAACK,QAAQ,GAAG,CAAC,CAAC;AACpB;AAEAC,EAAAA,eAAeA,GAAG;AAChB,IAAA,IAAI,CAACC,SAAS,CAAC,IAAI,CAACC,UAAU,CAAC;AACjC;AAEAC,EAAAA,cAAcA,GAAG;AACf,IAAA,IAAI,CAACF,SAAS,CAAC,IAAI,CAACC,UAAU,CAAC;AACjC;;AAEA;AACAE,EAAAA,QAAQA,GAAG;AACT,IAAA,OAAO,CAAG,EAAA,IAAI,CAACX,WAAW,CAACY,IAAI,CAAA,CAAA,EAAI,IAAI,CAACX,OAAO,CAAA,EAAA,EAAK,IAAI,CAACC,YAAY,CAAG,CAAA,CAAA;AAC1E;EAEAM,SAASA,CAACK,MAAuB,EAAE;IACjC,IAAIA,MAAM,IAAIA,MAAM,CAACZ,OAAO,KAAK,IAAI,CAACG,eAAe,EAAE;AACrD,MAAA,MAAMU,EAAE,GAAG,IAAI,CAACC,YAAY,EAAE;MAC9BF,MAAM,CAACG,YAAY,CAAC,IAAI,CAACd,YAAY,EAAEY,EAAE,CAAC;AAC5C;AACF;EAEAG,WAAWA,CAACJ,MAAgB,EAAE;IAC5B,IAAIA,MAAM,IAAIA,MAAM,CAACZ,OAAO,KAAK,IAAI,CAACG,eAAe,EAAE;MACrDS,MAAM,CAACG,YAAY,CAAC,IAAI,CAACd,YAAY,EAAE,IAAI,CAAC;AAC9C;AACF;AACF;;;;"}
@@ -0,0 +1,35 @@
1
+ import { _ as _defineProperty } from '../../_rollupPluginBabelHelpers-DZQzmiRH.js';
2
+ import { TextBase } from '@nativescript/core';
3
+ import ViewNode from './ViewNode.js';
4
+ import NativeElementNode from '../native/NativeElementNode.js';
5
+
6
+ class TextNode extends ViewNode {
7
+ constructor(text) {
8
+ super();
9
+ _defineProperty(this, "text", void 0);
10
+ _defineProperty(this, "_parentNode", null);
11
+ this.nodeType = 3;
12
+ this.text = text;
13
+ this._meta = {
14
+ skipAddToDom: true
15
+ };
16
+ }
17
+
18
+ // @ts-expect-error override parent
19
+ set parentNode(node) {
20
+ this._parentNode = node;
21
+ this.setText(this.text);
22
+ }
23
+ get parentNode() {
24
+ return this._parentNode;
25
+ }
26
+ setText(text) {
27
+ this.text = text;
28
+ if (this.parentNode instanceof NativeElementNode && this.parentNode?.nativeView instanceof TextBase) {
29
+ this.parentNode.updateText();
30
+ }
31
+ }
32
+ }
33
+
34
+ export { TextNode as default };
35
+ //# sourceMappingURL=TextNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextNode.js","sources":["../../../src/dom/nodes/TextNode.ts"],"sourcesContent":["import { TextBase } from '@nativescript/core';\nimport ViewNode from './ViewNode.ts';\nimport NativeElementNode from '../native/NativeElementNode.ts';\n\nexport default class TextNode extends ViewNode {\n text: any;\n private _parentNode: ViewNode | null = null;\n constructor(text: string) {\n super();\n\n this.nodeType = 3;\n this.text = text;\n\n this._meta = {\n skipAddToDom: true,\n };\n }\n\n // @ts-expect-error override parent\n set parentNode(node: ViewNode | null) {\n this._parentNode = node;\n this.setText(this.text);\n }\n\n get parentNode() {\n return this._parentNode;\n }\n\n setText(text: string) {\n this.text = text;\n if (\n this.parentNode instanceof NativeElementNode &&\n this.parentNode?.nativeView instanceof TextBase\n ) {\n this.parentNode.updateText();\n }\n }\n}\n"],"names":["TextNode","ViewNode","constructor","text","_defineProperty","nodeType","_meta","skipAddToDom","parentNode","node","_parentNode","setText","NativeElementNode","nativeView","TextBase","updateText"],"mappings":";;;;;AAIe,MAAMA,QAAQ,SAASC,QAAQ,CAAC;EAG7CC,WAAWA,CAACC,IAAY,EAAE;AACxB,IAAA,KAAK,EAAE;IAAAC,eAAA,CAAA,IAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA;AAAAA,IAAAA,eAAA,sBAF8B,IAAI,CAAA;IAIzC,IAAI,CAACC,QAAQ,GAAG,CAAC;IACjB,IAAI,CAACF,IAAI,GAAGA,IAAI;IAEhB,IAAI,CAACG,KAAK,GAAG;AACXC,MAAAA,YAAY,EAAE;KACf;AACH;;AAEA;EACA,IAAIC,UAAUA,CAACC,IAAqB,EAAE;IACpC,IAAI,CAACC,WAAW,GAAGD,IAAI;AACvB,IAAA,IAAI,CAACE,OAAO,CAAC,IAAI,CAACR,IAAI,CAAC;AACzB;EAEA,IAAIK,UAAUA,GAAG;IACf,OAAO,IAAI,CAACE,WAAW;AACzB;EAEAC,OAAOA,CAACR,IAAY,EAAE;IACpB,IAAI,CAACA,IAAI,GAAGA,IAAI;AAChB,IAAA,IACE,IAAI,CAACK,UAAU,YAAYI,iBAAiB,IAC5C,IAAI,CAACJ,UAAU,EAAEK,UAAU,YAAYC,QAAQ,EAC/C;AACA,MAAA,IAAI,CAACN,UAAU,CAACO,UAAU,EAAE;AAC9B;AACF;AACF;;;;"}