sys-shim 0.0.1-13 → 0.0.1-15

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.
Binary file
package/src/util.js CHANGED
@@ -36,6 +36,7 @@ export function getCodeLine(inputStr) {
36
36
  return maxAsterisks
37
37
  }
38
38
 
39
+ export const sleep = (time = 1e3) => new Promise(resolve => setTimeout(resolve, time))
39
40
  export function deepProxy({
40
41
  keys = [`then`, `catch`],
41
42
  cb = (records) => {
@@ -73,7 +74,7 @@ export function deepProxy({
73
74
  let records = getRecords(this)
74
75
  setTimeout(() => {
75
76
  let recordsEnd = getRecords(this)
76
- !recordsEnd.hackRun && cb(recordsEnd)
77
+ !recordsEnd.hackRun && (cb(recordsEnd), recordsEnd.hackRun = true)
77
78
  }, 0)
78
79
  const key = records[records.length - 1].key
79
80
  records[records.length - 1] = { type: `apply`, key, arg: args }
@@ -284,6 +285,14 @@ export function getUuid () {
284
285
  })
285
286
  }
286
287
 
288
+ /**
289
+ * 获取 uuid
290
+ * @returns
291
+ */
292
+ export function getCodeId () {
293
+ return `c_${getUuid()}`.replace(/[_-]/g, ``)
294
+ }
295
+
287
296
  export function isUTF8MultiByteStart(byte) {
288
297
  // 如果字节的高位为11,则是多字节字符的起始字节
289
298
  return (byte & 0xC0) === 0xC0
@@ -1,22 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <title>sys-shim page</title>
6
- </head>
7
- <script>
8
- new Sys({
9
- log: true,
10
- wsUrl: undefined
11
- }).then(async main => {
12
- globalThis.native = main.native
13
- globalThis.nativeMain = main.nativeMain
14
- document.body.append(`${globalThis.ext.wsUrl}?token=${globalThis.ext.token}`)
15
- })
16
- </script>
17
- <body>
18
- <button onclick="native.win.msgbox(`hello`, `title`)">msgbox</button>
19
- <button onclick="nativeMain.win.quitMessage()">exit</button>
20
- <hr>
21
- </body>
22
- </html>