onejs-core 0.3.24 → 0.3.26

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.
@@ -228,6 +228,7 @@ declare namespace CS {
228
228
  public removeEventListener ($name: string, $callback: UnityEngine.UIElements.EventCallback$1<UnityEngine.UIElements.EventBase>, $useCapture?: boolean) : void
229
229
  public appendChild ($node: OneJS.Dom.Dom) : void
230
230
  public removeChild ($child: OneJS.Dom.Dom) : void
231
+ public contains ($child: OneJS.Dom.Dom) : boolean
231
232
  public insertBefore ($a: OneJS.Dom.Dom, $b: OneJS.Dom.Dom) : void
232
233
  public setAttribute ($name: string, $val: any) : void
233
234
  public removeAttribute ($name: string) : void
@@ -1,17 +1,23 @@
1
1
  declare global {
2
- interface Document {
3
- addRuntimeUSS(uss: string): void
4
- clearRuntimeStyleSheets(): void
5
2
 
6
- // createElement(tagName: string): CS.OneJS.Dom.Dom
7
- // createTextNode(text: string): CS.OneJS.Dom.Dom
8
- }
3
+ // interface ElementCreationOptions {
4
+ // is?: string
5
+ // }
9
6
 
10
- interface Element {
11
- classname: string
12
- nodeType: number
13
- ve: CS.UnityEngine.UIElements.VisualElement
14
- }
7
+ // interface Document {
8
+ // addRuntimeUSS(uss: string): void
9
+ // clearRuntimeStyleSheets(): void
10
+
11
+ // createElement(tagName: string, options?: ElementCreationOptions): Element
12
+ // createElementNS(ns: string, tagName: string, options?: ElementCreationOptions): Element
13
+ // createTextNode(text: string): Element
14
+ // }
15
+
16
+ // interface Element {
17
+ // classname: string
18
+ // nodeType: number
19
+ // ve: CS.UnityEngine.UIElements.VisualElement
20
+ // }
15
21
 
16
22
  interface HTMLElement {
17
23
  style: CS.OneJS.Dom.DomStyle
@@ -25,21 +31,21 @@ declare global {
25
31
  const requestAnimationFrame: (callback: (time: number) => void) => number
26
32
  const cancelAnimationFrame: (id: number) => void
27
33
 
28
- const console: {
34
+ const console: {
29
35
  log: (...args: any[]) => void
30
36
  error: (...args: any[]) => void
31
37
  warn: (...args: any[]) => void
32
38
  info: (...args: any[]) => void
33
39
  debug: (...args: any[]) => void
34
- }
40
+ }
35
41
 
36
42
  interface Event {
37
43
  type: string
38
- }
39
- interface Text {
44
+ }
45
+ interface Text {
40
46
  data: string
41
47
  nodeType: number
42
- }
48
+ }
43
49
  }
44
50
 
45
51
  export { }
@@ -9,7 +9,9 @@ export declare class DocumentWrapper {
9
9
  addRuntimeUSS(uss: string): void;
10
10
  clearRuntimeStyleSheets(): void;
11
11
  createElement(tagName: string, options?: ElementCreationOptions): DomWrapper;
12
- createElementNS(ns: string, tagName: string, options: ElementCreationOptions): DomWrapper;
12
+ createElementNS(ns: string, tagName: string, options?: ElementCreationOptions): DomWrapper;
13
13
  createTextNode(text: string): DomWrapper;
14
+ getElementById(id: string): DomWrapper;
15
+ querySelectorAll(selector: string): DomWrapper[];
14
16
  }
15
17
  export {};
@@ -22,4 +22,15 @@ export class DocumentWrapper {
22
22
  createTextNode(text) {
23
23
  return new DomWrapper(this.#doc.createTextNode(text));
24
24
  }
25
+ getElementById(id) {
26
+ return new DomWrapper(this.#doc.getElementById(id));
27
+ }
28
+ querySelectorAll(selector) {
29
+ let doms = this.#doc.querySelectorAll(selector);
30
+ let res = [];
31
+ for (let i = 0; i < doms.Length; i++) {
32
+ res.push(new DomWrapper(doms.get_Item(i)));
33
+ }
34
+ return res;
35
+ }
25
36
  }
package/dom/document.ts CHANGED
@@ -27,12 +27,24 @@ export class DocumentWrapper {
27
27
  return new DomWrapper(this.#doc.createElement(tagName))
28
28
  }
29
29
 
30
- createElementNS(ns: string, tagName: string, options: ElementCreationOptions): DomWrapper {
30
+ createElementNS(ns: string, tagName: string, options?: ElementCreationOptions): DomWrapper {
31
31
  return new DomWrapper(this.#doc.createElement(tagName))
32
32
  }
33
33
 
34
-
35
34
  createTextNode(text: string): DomWrapper {
36
35
  return new DomWrapper(this.#doc.createTextNode(text))
37
36
  }
37
+
38
+ getElementById(id: string): DomWrapper {
39
+ return new DomWrapper(this.#doc.getElementById(id))
40
+ }
41
+
42
+ querySelectorAll(selector: string): DomWrapper[] {
43
+ let doms = this.#doc.querySelectorAll(selector)
44
+ let res = []
45
+ for (let i = 0; i < doms.Length; i++) {
46
+ res.push(new DomWrapper(doms.get_Item(i)))
47
+ }
48
+ return res;
49
+ }
38
50
  }
package/dom/dom.ts CHANGED
@@ -48,6 +48,10 @@ export class DomWrapper {
48
48
  this.#dom.insertBefore(a?._dom, b?._dom)
49
49
  }
50
50
 
51
+ contains(child: DomWrapper) {
52
+ return this.#dom.contains(child._dom)
53
+ }
54
+
51
55
  clearChildren() {
52
56
  this.#dom.clearChildren()
53
57
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "onejs-core",
3
3
  "description": "The JS part of OneJS, a UI framework and Scripting Engine for Unity.",
4
- "version": "0.3.24",
4
+ "version": "0.3.26",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./typings.d.ts",
7
7
  "dependencies": {