onejs-core 2.0.19 → 2.0.20

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.
@@ -26,6 +26,7 @@ declare global {
26
26
  }
27
27
 
28
28
  const document: DocumentWrapper
29
+ const onejsDocument: DocumentWrapper
29
30
  const setTimeout: (callback: () => void, delay?: number) => number
30
31
  const clearTimeout: (id: number) => void
31
32
  const setInterval: (callback: () => void, delay?: number) => number
package/dist/index.js CHANGED
@@ -33,9 +33,12 @@ export function h(type, props, ...children) {
33
33
  return element;
34
34
  }
35
35
  export { emo } from "./styling/index";
36
- // @ts-ignore
37
- if (typeof ___document != "undefined") {
36
+ if (typeof globalThis.___document != "undefined") {
38
37
  // @ts-ignore
39
- globalThis.document = new DocumentWrapper(___document);
38
+ globalThis.onejsDocument = new DocumentWrapper(globalThis.___document);
39
+ if (!globalThis.ONEJS_WEBGL) {
40
+ // @ts-ignore
41
+ globalThis.document = globalThis.onejsDocument;
42
+ }
40
43
  }
41
44
  // puer.$extension(CS.UnityEngine.UIElements.VisualElement, CS.UnityEngine.UIElements.VisualElementExtensions)
@@ -1,5 +1,5 @@
1
1
  type float4 = CS.Unity.Mathematics.float4;
2
- declare var kCSSColorTable: {
2
+ declare const kCSSColorTable: {
3
3
  transparent: number[];
4
4
  aliceblue: number[];
5
5
  antiquewhite: number[];
@@ -27,7 +27,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27
27
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28
28
  IN THE SOFTWARE.
29
29
  */
30
- var kCSSColorTable = {
30
+ const kCSSColorTable = {
31
31
  "transparent": [0, 0, 0, 0], "aliceblue": [240, 248, 255, 1],
32
32
  "antiquewhite": [250, 235, 215, 1], "aqua": [0, 255, 255, 1],
33
33
  "aquamarine": [127, 255, 212, 1], "azure": [240, 255, 255, 1],
package/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./definitions/index.d.ts" />
2
- import { DocumentWrapper } from "./dom/document";
3
- import { DomWrapper } from "./dom/dom";
2
+ import { DocumentWrapper } from "./dom/document"
3
+ import { DomWrapper } from "./dom/dom"
4
4
 
5
5
  /**
6
6
  * OneJS's own h function. Use this to quickly create elements in jsx-like syntax
@@ -10,29 +10,29 @@ import { DomWrapper } from "./dom/dom";
10
10
  * @returns
11
11
  */
12
12
  export function h(type: any, props: any, ...children: any[]): any {
13
- const element = typeof type === "string" ? document.createElement(type) : type;
13
+ const element = typeof type === "string" ? document.createElement(type) : type
14
14
 
15
15
  // Assign properties to the element
16
16
  for (const [key, value] of Object.entries(props || {})) {
17
17
  if (key.startsWith("on") && typeof value === "function") {
18
- element.addEventListener(key.substring(2).toLowerCase(), value);
18
+ element.addEventListener(key.substring(2).toLowerCase(), value)
19
19
  } else if (key === "style" && typeof value === "object") {
20
- Object.assign(element.style, value);
20
+ Object.assign(element.style, value)
21
21
  } else {
22
- element.setAttribute(key, value);
22
+ element.setAttribute(key, value)
23
23
  }
24
24
  }
25
25
 
26
26
  // Append children
27
27
  for (const child of children) {
28
28
  if (typeof child === "string") {
29
- element.appendChild(document.createTextNode(child));
29
+ element.appendChild(document.createTextNode(child))
30
30
  } else {
31
- element.appendChild(child);
31
+ element.appendChild(child)
32
32
  }
33
33
  }
34
34
 
35
- return element;
35
+ return element
36
36
  }
37
37
 
38
38
  export { emo } from "./styling/index"
@@ -46,10 +46,13 @@ declare global {
46
46
  const toJsArray: <T>(csArr: CS.System.Array) => T[]
47
47
  }
48
48
 
49
- // @ts-ignore
50
- if (typeof ___document != "undefined") {
49
+ if (typeof globalThis.___document != "undefined") {
51
50
  // @ts-ignore
52
- globalThis.document = new DocumentWrapper(___document)
51
+ globalThis.onejsDocument = new DocumentWrapper(globalThis.___document)
52
+ if (!globalThis.ONEJS_WEBGL) {
53
+ // @ts-ignore
54
+ globalThis.document = globalThis.onejsDocument
55
+ }
53
56
  }
54
57
 
55
58
  // puer.$extension(CS.UnityEngine.UIElements.VisualElement, CS.UnityEngine.UIElements.VisualElementExtensions)
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": "2.0.19",
4
+ "version": "2.0.20",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/Singtaa/onejs-core"
@@ -13,9 +13,9 @@ const projectDir = path.resolve(process.cwd(), '..')
13
13
  const manifestPath = path.join(projectDir, 'Packages', 'manifest.json')
14
14
 
15
15
  const backends = [
16
- { name: "QuickJS", tgzUrl: "https://github.com/Tencent/puerts/releases/download/Unity_v2.2.1/PuerTS_Quickjs_2.2.1.tgz" },
17
- { name: "V8", tgzUrl: "https://github.com/Tencent/puerts/releases/download/Unity_v2.2.1/PuerTS_V8_2.2.1.tgz" },
18
- { name: "NodeJS", tgzUrl: "https://github.com/Tencent/puerts/releases/download/Unity_v2.2.1/PuerTS_Nodejs_2.2.1.tgz" }
16
+ { name: "QuickJS", tgzUrl: "https://github.com/Tencent/puerts/releases/download/Unity_v2.2.2/PuerTS_Quickjs_2.2.2.tgz" },
17
+ { name: "V8", tgzUrl: "https://github.com/Tencent/puerts/releases/download/Unity_v2.2.2/PuerTS_V8_2.2.2.tgz" },
18
+ { name: "NodeJS", tgzUrl: "https://github.com/Tencent/puerts/releases/download/Unity_v2.2.2/PuerTS_Nodejs_2.2.2.tgz" }
19
19
  ]
20
20
 
21
21
  const args = process.argv.slice(2)
@@ -64,7 +64,7 @@ async function Process(backend, outputDir) {
64
64
  }
65
65
  await extractTgz(downloadedPath, outputDir)
66
66
 
67
- // Safe keep asmdef files
67
+ // Safe keep asmdef files, et al.
68
68
  const onejsDir = await getOneJSUnityDir()
69
69
  const a = path.join(onejsDir, 'Puerts/Editor/com.tencent.puerts.core.Editor.asmdef')
70
70
  const b = path.join(upmDir, 'Editor/com.tencent.puerts.core.Editor.asmdef')
@@ -72,6 +72,9 @@ async function Process(backend, outputDir) {
72
72
  const d = path.join(upmDir, 'Runtime/com.tencent.puerts.core.asmdef')
73
73
  await fse.copy(a, b)
74
74
  await fse.copy(c, d)
75
+ const e = path.join(onejsDir, 'Puerts/Runtime/Src/Default/JsEnv.cs')
76
+ const f = path.join(upmDir, 'Runtime/Src/Default/JsEnv.cs')
77
+ await fse.copy(e, f)
75
78
 
76
79
  // Replace OneJS/Puerts with the new one
77
80
  const puertsDir = path.join(onejsDir, "Puerts")
@@ -31,7 +31,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
31
31
  IN THE SOFTWARE.
32
32
  */
33
33
 
34
- var kCSSColorTable = {
34
+ const kCSSColorTable = {
35
35
  "transparent": [0, 0, 0, 0], "aliceblue": [240, 248, 255, 1],
36
36
  "antiquewhite": [250, 235, 215, 1], "aqua": [0, 255, 255, 1],
37
37
  "aquamarine": [127, 255, 212, 1], "azure": [240, 255, 255, 1],