Skip to content

Commit 4b7f9de

Browse files
committedFeb 10, 2025·
fix: imports
1 parent 88194c6 commit 4b7f9de

27 files changed

+1628
-1582
lines changed
 

‎Assets/Plugins/Preactor/Editor/JavascriptImporter.cs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using NUglify;
21
using System.IO;
32
using UnityEditor.AssetImporters;
43
using UnityEngine;
@@ -7,12 +6,12 @@
76
public class JavascriptImporter : ScriptedImporter {
87
public override void OnImportAsset(AssetImportContext ctx) {
98
var content = File.ReadAllText(ctx.assetPath);
10-
var res = Uglify.Js(content);
11-
12-
if (res.HasErrors) {
13-
Debug.LogError($"Cannot uglify {ctx.assetPath}\n\n" + string.Join("\n\n", res.Errors));
14-
return;
15-
}
9+
// var res = Uglify.Js(content);
10+
11+
// if (res.HasErrors) {
12+
// Debug.LogError($"Cannot uglify {ctx.assetPath}\n\n" + string.Join("\n\n", res.Errors));
13+
// return;
14+
// }
1615

1716
// var subAsset = new TextAsset(res.Code);
1817
var subAsset = new TextAsset(content);

‎Preactor/core/dom/document.d.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import { DomWrapper } from './dom';
22
interface ElementCreationOptions {
3-
is?: string;
3+
is?: string;
44
}
55
export declare class DocumentWrapper {
6-
#private;
7-
get body(): DomWrapper;
8-
constructor(doc: CS.Preactor.Document);
9-
addRuntimeUss(uss: string): void;
10-
clearRuntimeStyleSheets(): void;
11-
createElement(tagName: string, _options?: ElementCreationOptions): DomWrapper;
12-
createElementNS(_ns: string, tagName: string, _options?: ElementCreationOptions): DomWrapper;
13-
createTextNode(text: string): DomWrapper;
14-
getElementById(id: string): DomWrapper;
15-
querySelectorAll(selector: string): DomWrapper[];
16-
loadImage(path: string): Sprite;
17-
loadFont(path: string): Font;
18-
loadFontDefinition(path: string): FontDefinition;
6+
#private;
7+
get body(): DomWrapper;
8+
constructor(doc: CS.Preactor.Document);
9+
addRuntimeUss(uss: string): void;
10+
clearRuntimeStyleSheets(): void;
11+
createElement(tagName: string, _options?: ElementCreationOptions): DomWrapper;
12+
createElementNS(_ns: string, tagName: string, _options?: ElementCreationOptions): DomWrapper;
13+
createTextNode(text: string): DomWrapper;
14+
getElementById(id: string): DomWrapper;
15+
querySelectorAll(selector: string): DomWrapper[];
16+
loadImage(path: string): Sprite;
17+
loadFont(path: string): Font;
18+
loadFontDefinition(path: string): FontDefinition;
1919
}
2020
export {};

‎Preactor/core/dom/document.js

+44-44
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
import { DomWrapper } from './dom';
22
export class DocumentWrapper {
3-
#doc;
4-
#body;
5-
get body() {
6-
return this.#body;
7-
}
8-
constructor(doc) {
9-
this.#doc = doc;
10-
this.#body = new DomWrapper(doc.Body);
11-
}
12-
addRuntimeUss(uss) {
13-
this.#doc.AddRuntimeUss(uss);
14-
}
15-
clearRuntimeStyleSheets() {
16-
this.#doc.ClearRuntimeStyleSheets();
17-
}
18-
createElement(tagName, _options) {
19-
return new DomWrapper(this.#doc.CreateElement(tagName));
20-
}
21-
createElementNS(_ns, tagName, _options) {
22-
return new DomWrapper(this.#doc.CreateElement(tagName));
23-
}
24-
createTextNode(text) {
25-
return new DomWrapper(this.#doc.CreateTextNode(text));
26-
}
27-
getElementById(id) {
28-
return new DomWrapper(this.#doc.GetElementById(id));
29-
}
30-
querySelectorAll(selector) {
31-
let doms = this.#doc.QuerySelectorAll(selector);
32-
let res = [];
33-
for (let i = 0; i < doms.Length; i++) {
34-
res.push(new DomWrapper(doms.get_Item(i)));
35-
}
36-
return res;
37-
}
38-
loadImage(path) {
39-
return this.#doc.LoadImage(path);
40-
}
41-
loadFont(path) {
42-
return this.#doc.LoadFont(path);
43-
}
44-
loadFontDefinition(path) {
45-
return this.#doc.LoadFontDefinition(path);
46-
}
3+
#doc;
4+
#body;
5+
get body() {
6+
return this.#body;
7+
}
8+
constructor(doc) {
9+
this.#doc = doc;
10+
this.#body = new DomWrapper(doc.Body);
11+
}
12+
addRuntimeUss(uss) {
13+
this.#doc.AddRuntimeUss(uss);
14+
}
15+
clearRuntimeStyleSheets() {
16+
this.#doc.ClearRuntimeStyleSheets();
17+
}
18+
createElement(tagName, _options) {
19+
return new DomWrapper(this.#doc.CreateElement(tagName));
20+
}
21+
createElementNS(_ns, tagName, _options) {
22+
return new DomWrapper(this.#doc.CreateElement(tagName));
23+
}
24+
createTextNode(text) {
25+
return new DomWrapper(this.#doc.CreateTextNode(text));
26+
}
27+
getElementById(id) {
28+
return new DomWrapper(this.#doc.GetElementById(id));
29+
}
30+
querySelectorAll(selector) {
31+
let doms = this.#doc.QuerySelectorAll(selector);
32+
let res = [];
33+
for (let i = 0; i < doms.Length; i++) {
34+
res.push(new DomWrapper(doms.get_Item(i)));
35+
}
36+
return res;
37+
}
38+
loadImage(path) {
39+
return this.#doc.LoadImage(path);
40+
}
41+
loadFont(path) {
42+
return this.#doc.LoadFont(path);
43+
}
44+
loadFontDefinition(path) {
45+
return this.#doc.LoadFontDefinition(path);
46+
}
4747
}

‎Preactor/core/dom/document.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class DocumentWrapper {
4343

4444
querySelectorAll(selector: string): DomWrapper[] {
4545
let doms = this.#doc.QuerySelectorAll(selector);
46-
let res = [];
46+
let res: DomWrapper[] = [];
4747

4848
for (let i = 0; i < doms.Length; i++) {
4949
res.push(new DomWrapper(doms.get_Item(i)));

‎Preactor/core/dom/dom-style.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export declare class DomStyleWrapper {
2-
#private;
3-
constructor(domStyle: CS.Preactor.DomStyle);
4-
setProperty(name: string, value: any): void;
2+
#private;
3+
constructor(domStyle: CS.Preactor.DomStyle);
4+
setProperty(name: string, value: any): void;
55
}

‎Preactor/core/dom/dom-style.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
export class DomStyleWrapper {
2-
#domStyle;
3-
constructor(domStyle) {
4-
this.#domStyle = domStyle;
5-
return new Proxy(this, {
6-
set(target, prop, value) {
7-
target.setProperty(prop, value);
8-
return true;
9-
},
10-
get(target, prop) {
11-
return target[prop];
12-
}
13-
});
14-
}
15-
setProperty(name, value) {
16-
this.#domStyle.SetProperty(name, value);
17-
}
2+
#domStyle;
3+
constructor(domStyle) {
4+
this.#domStyle = domStyle;
5+
return new Proxy(this, {
6+
set(target, prop, value) {
7+
target.setProperty(prop, value);
8+
return true;
9+
},
10+
get(target, prop) {
11+
return target[prop];
12+
}
13+
});
14+
}
15+
setProperty(name, value) {
16+
this.#domStyle.SetProperty(name, value);
17+
}
1818
}

‎Preactor/core/dom/dom.d.ts

+30-30
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
import { EventBase } from 'UnityEngine/UIElements';
22
import { DomStyleWrapper } from './dom-style';
33
export declare class DomWrapper {
4-
#private;
5-
get _dom(): CS.Preactor.Dom;
6-
get ve(): CS.UnityEngine.UIElements.VisualElement;
7-
get childNodes(): DomWrapper[];
8-
get firstChild(): DomWrapper | null;
9-
get parentNode(): DomWrapper | null;
10-
get nextSibling(): DomWrapper | null;
11-
get nodeType(): number;
12-
get Id(): string;
13-
set Id(value: string);
14-
get key(): string;
15-
set key(value: string);
16-
get style(): DomStyleWrapper;
17-
get value(): any;
18-
get checked(): boolean;
19-
get data(): any;
20-
set data(value: any);
21-
get classname(): string;
22-
set classname(value: string);
23-
constructor(dom: CS.Preactor.Dom);
24-
appendChild(child: DomWrapper): void;
25-
removeChild(child: DomWrapper): void;
26-
insertBefore(a: DomWrapper, b: DomWrapper): void;
27-
clearChildren(): void;
28-
focus(): void;
29-
contains(element: DomWrapper): boolean;
30-
addEventListener(type: string, listener: (event: EventBase) => void, useCapture?: boolean): void;
31-
removeEventListener(type: string, listener: (event: EventBase) => void, useCapture?: boolean): void;
32-
setAttribute(name: string, value: any): void;
33-
removeAttribute(name: string): void;
4+
#private;
5+
get _dom(): CS.Preactor.Dom;
6+
get ve(): CS.UnityEngine.UIElements.VisualElement;
7+
get childNodes(): DomWrapper[];
8+
get firstChild(): DomWrapper | null;
9+
get parentNode(): DomWrapper | null;
10+
get nextSibling(): DomWrapper | null;
11+
get nodeType(): number;
12+
get Id(): string;
13+
set Id(value: string);
14+
get key(): string;
15+
set key(value: string);
16+
get style(): DomStyleWrapper;
17+
get value(): any;
18+
get checked(): boolean;
19+
get data(): any;
20+
set data(value: any);
21+
get classname(): string;
22+
set classname(value: string);
23+
constructor(dom: CS.Preactor.Dom);
24+
appendChild(child: DomWrapper): void;
25+
removeChild(child: DomWrapper): void;
26+
insertBefore(a: DomWrapper, b: DomWrapper): void;
27+
clearChildren(): void;
28+
focus(): void;
29+
contains(element: DomWrapper): boolean;
30+
addEventListener(type: string, listener: (event: EventBase) => void, useCapture?: boolean): void;
31+
removeEventListener(type: string, listener: (event: EventBase) => void, useCapture?: boolean): void;
32+
setAttribute(name: string, value: any): void;
33+
removeAttribute(name: string): void;
3434
}

0 commit comments

Comments
 (0)
Please sign in to comment.