onejs-core 0.3.44 → 0.3.46

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.
@@ -262,6 +262,7 @@ declare namespace CS {
262
262
  public createTextNode ($text: string) : OneJS.Dom.Dom
263
263
  public getElementById ($id: string) : OneJS.Dom.Dom
264
264
  public querySelectorAll ($selector: string) : System.Array$1<OneJS.Dom.Dom>
265
+ public getDomFromVE ($ve: UnityEngine.UIElements.VisualElement) : OneJS.Dom.Dom
265
266
  public loadImage ($path: string, $filterMode?: UnityEngine.FilterMode) : UnityEngine.Texture2D
266
267
  public loadFont ($path: string) : UnityEngine.Font
267
268
  public loadFontDefinition ($path: string) : UnityEngine.UIElements.FontDefinition
@@ -283,6 +284,7 @@ declare namespace CS {
283
284
  {
284
285
  protected [__keep_incompatibility]: never;
285
286
  public get veStyle(): UnityEngine.UIElements.IStyle;
287
+ public getProperty ($key: string) : any
286
288
  public setProperty ($key: string, $value: any) : void
287
289
  public SetAlignContent ($value: UnityEngine.UIElements.Align) : void
288
290
  public SetAlignItems ($value: UnityEngine.UIElements.Align) : void
@@ -5,7 +5,10 @@ interface ElementCreationOptions {
5
5
  export declare class DocumentWrapper {
6
6
  #private;
7
7
  get _doc(): CS.OneJS.Dom.Document;
8
- get body(): DomWrapper;
8
+ /**
9
+ * The body/root element of the document. Will be null for Editor documents.
10
+ */
11
+ get body(): DomWrapper | null;
9
12
  constructor(doc: CS.OneJS.Dom.Document);
10
13
  addRuntimeUSS(uss: string): void;
11
14
  clearRuntimeStyleSheets(): void;
@@ -3,11 +3,13 @@ export class DocumentWrapper {
3
3
  get _doc() { return this.#doc; }
4
4
  #doc;
5
5
  #body;
6
+ /**
7
+ * The body/root element of the document. Will be null for Editor documents.
8
+ */
6
9
  get body() { return this.#body; }
7
10
  constructor(doc) {
8
11
  this.#doc = doc;
9
- if (doc.body)
10
- this.#body = new DomWrapper(doc.body);
12
+ this.#body = doc.body ? new DomWrapper(doc.body) : null;
11
13
  }
12
14
  addRuntimeUSS(uss) {
13
15
  this.#doc.addRuntimeUSS(uss);
@@ -1,6 +1,7 @@
1
1
  export declare class DomStyleWrapper implements CS.OneJS.Dom.DomStyle {
2
2
  _domStyle: CS.OneJS.Dom.DomStyle;
3
3
  constructor(domStyle: CS.OneJS.Dom.DomStyle);
4
+ getProperty(name: string): any;
4
5
  setProperty(name: string, value: any): void;
5
6
  }
6
7
  export interface DomStyleWrapper extends CS.OneJS.Dom.DomStyle {
@@ -8,10 +8,13 @@ export class DomStyleWrapper {
8
8
  return true;
9
9
  },
10
10
  get(target, prop) {
11
- return target[prop];
11
+ return target.getProperty(prop);
12
12
  }
13
13
  });
14
14
  }
15
+ getProperty(name) {
16
+ return this._domStyle.getProperty(name);
17
+ }
15
18
  setProperty(name, value) {
16
19
  this._domStyle.setProperty(name, value);
17
20
  }
package/dist/index.js CHANGED
@@ -37,10 +37,3 @@ if (typeof ___document != "undefined") {
37
37
  // @ts-ignore
38
38
  globalThis.document = new DocumentWrapper(___document);
39
39
  }
40
- // @ts-ignore
41
- CS.OneJS.EngineHost.prototype.sub = function (a, b, c) {
42
- let unsubscribe = c ? this.subscribe(a, b, c) : this.subscribe(a, b);
43
- return () => {
44
- unsubscribe.Invoke();
45
- };
46
- };
package/dom/document.ts CHANGED
@@ -8,14 +8,16 @@ export class DocumentWrapper {
8
8
  public get _doc(): CS.OneJS.Dom.Document { return this.#doc }
9
9
 
10
10
  #doc: CS.OneJS.Dom.Document;
11
- #body: DomWrapper;
11
+ #body: DomWrapper | null;
12
12
 
13
- public get body(): DomWrapper { return this.#body }
13
+ /**
14
+ * The body/root element of the document. Will be null for Editor documents.
15
+ */
16
+ public get body(): DomWrapper | null { return this.#body }
14
17
 
15
18
  constructor(doc: CS.OneJS.Dom.Document) {
16
19
  this.#doc = doc
17
- if (doc.body)
18
- this.#body = new DomWrapper(doc.body)
20
+ this.#body = doc.body ? new DomWrapper(doc.body) : null
19
21
  }
20
22
 
21
23
  addRuntimeUSS(uss: string): void {
package/dom/dom-style.ts CHANGED
@@ -12,11 +12,15 @@ export class DomStyleWrapper implements CS.OneJS.Dom.DomStyle {
12
12
  return true;
13
13
  },
14
14
  get(target, prop) {
15
- return target[prop];
15
+ return target.getProperty(prop as string);
16
16
  }
17
17
  })
18
18
  }
19
19
 
20
+ getProperty(name: string) {
21
+ return this._domStyle.getProperty(name)
22
+ }
23
+
20
24
  setProperty(name: string, value: any) {
21
25
  this._domStyle.setProperty(name, value)
22
26
  }
package/index.ts CHANGED
@@ -49,12 +49,4 @@ declare global {
49
49
  if (typeof ___document != "undefined") {
50
50
  // @ts-ignore
51
51
  globalThis.document = new DocumentWrapper(___document)
52
- }
53
-
54
- // @ts-ignore
55
- CS.OneJS.EngineHost.prototype.sub = function (a, b, c) {
56
- let unsubscribe = c ? this.subscribe(a, b, c) : this.subscribe(a, b)
57
- return () => {
58
- unsubscribe.Invoke()
59
- }
60
52
  }
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.44",
4
+ "version": "0.3.46",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./typings.d.ts",
7
7
  "dependencies": {