@tailwindcss/oxide-wasm32-wasi 0.0.0-insiders.231cddd

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.
Files changed (113) hide show
  1. package/README.md +3 -0
  2. package/node_modules/@emnapi/core/LICENSE +21 -0
  3. package/node_modules/@emnapi/core/README.md +1 -0
  4. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.js +6661 -0
  5. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.d.ts +363 -0
  6. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.js +1 -0
  7. package/node_modules/@emnapi/core/dist/emnapi-core.d.mts +363 -0
  8. package/node_modules/@emnapi/core/dist/emnapi-core.d.ts +365 -0
  9. package/node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.js +7411 -0
  10. package/node_modules/@emnapi/core/dist/emnapi-core.js +8390 -0
  11. package/node_modules/@emnapi/core/dist/emnapi-core.min.d.mts +363 -0
  12. package/node_modules/@emnapi/core/dist/emnapi-core.min.js +1 -0
  13. package/node_modules/@emnapi/core/dist/emnapi-core.min.mjs +1 -0
  14. package/node_modules/@emnapi/core/dist/emnapi-core.mjs +6650 -0
  15. package/node_modules/@emnapi/core/index.js +5 -0
  16. package/node_modules/@emnapi/core/package.json +49 -0
  17. package/node_modules/@emnapi/runtime/LICENSE +21 -0
  18. package/node_modules/@emnapi/runtime/README.md +1 -0
  19. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.js +1351 -0
  20. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.d.ts +663 -0
  21. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.js +1 -0
  22. package/node_modules/@emnapi/runtime/dist/emnapi.d.mts +663 -0
  23. package/node_modules/@emnapi/runtime/dist/emnapi.d.ts +665 -0
  24. package/node_modules/@emnapi/runtime/dist/emnapi.esm-bundler.js +1407 -0
  25. package/node_modules/@emnapi/runtime/dist/emnapi.iife.d.ts +420 -0
  26. package/node_modules/@emnapi/runtime/dist/emnapi.iife.js +1478 -0
  27. package/node_modules/@emnapi/runtime/dist/emnapi.js +1479 -0
  28. package/node_modules/@emnapi/runtime/dist/emnapi.min.d.mts +663 -0
  29. package/node_modules/@emnapi/runtime/dist/emnapi.min.js +1 -0
  30. package/node_modules/@emnapi/runtime/dist/emnapi.min.mjs +1 -0
  31. package/node_modules/@emnapi/runtime/dist/emnapi.mjs +1320 -0
  32. package/node_modules/@emnapi/runtime/index.js +5 -0
  33. package/node_modules/@emnapi/runtime/package.json +48 -0
  34. package/node_modules/@emnapi/wasi-threads/LICENSE +21 -0
  35. package/node_modules/@emnapi/wasi-threads/README.md +203 -0
  36. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.js +881 -0
  37. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.d.ts +214 -0
  38. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.js +1 -0
  39. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.mts +214 -0
  40. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +216 -0
  41. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.esm-bundler.js +929 -0
  42. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +941 -0
  43. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.d.mts +214 -0
  44. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.js +1 -0
  45. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.mjs +1 -0
  46. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.mjs +876 -0
  47. package/node_modules/@emnapi/wasi-threads/index.js +5 -0
  48. package/node_modules/@emnapi/wasi-threads/package.json +50 -0
  49. package/node_modules/@napi-rs/wasm-runtime/LICENSE +43 -0
  50. package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +23712 -0
  51. package/node_modules/@napi-rs/wasm-runtime/dist/runtime.js +12285 -0
  52. package/node_modules/@napi-rs/wasm-runtime/fs-proxy.cjs +209 -0
  53. package/node_modules/@napi-rs/wasm-runtime/package.json +61 -0
  54. package/node_modules/@napi-rs/wasm-runtime/runtime.cjs +15 -0
  55. package/node_modules/@tybys/wasm-util/README.md +193 -0
  56. package/node_modules/@tybys/wasm-util/dist/tsdoc-metadata.json +11 -0
  57. package/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +417 -0
  58. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +2738 -0
  59. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +2738 -0
  60. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -0
  61. package/node_modules/@tybys/wasm-util/dist/wasm-util.js +2760 -0
  62. package/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -0
  63. package/node_modules/@tybys/wasm-util/lib/cjs/asyncify.js +158 -0
  64. package/node_modules/@tybys/wasm-util/lib/cjs/index.js +13 -0
  65. package/node_modules/@tybys/wasm-util/lib/cjs/jspi.js +46 -0
  66. package/node_modules/@tybys/wasm-util/lib/cjs/load.js +97 -0
  67. package/node_modules/@tybys/wasm-util/lib/cjs/memory.js +35 -0
  68. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/error.js +103 -0
  69. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/fd.js +268 -0
  70. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/fs.js +3 -0
  71. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +194 -0
  72. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +174 -0
  73. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +1544 -0
  74. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/rights.js +141 -0
  75. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/types.js +220 -0
  76. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/util.js +128 -0
  77. package/node_modules/@tybys/wasm-util/lib/cjs/webassembly.js +13 -0
  78. package/node_modules/@tybys/wasm-util/lib/mjs/asyncify.mjs +153 -0
  79. package/node_modules/@tybys/wasm-util/lib/mjs/index.mjs +9 -0
  80. package/node_modules/@tybys/wasm-util/lib/mjs/jspi.mjs +39 -0
  81. package/node_modules/@tybys/wasm-util/lib/mjs/load.mjs +89 -0
  82. package/node_modules/@tybys/wasm-util/lib/mjs/memory.mjs +28 -0
  83. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/error.mjs +97 -0
  84. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/fd.mjs +256 -0
  85. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/fs.mjs +1 -0
  86. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +188 -0
  87. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +168 -0
  88. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +1539 -0
  89. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/rights.mjs +135 -0
  90. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/types.mjs +216 -0
  91. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/util.mjs +113 -0
  92. package/node_modules/@tybys/wasm-util/lib/mjs/webassembly.mjs +9 -0
  93. package/node_modules/@tybys/wasm-util/package.json +58 -0
  94. package/node_modules/tslib/CopyrightNotice.txt +15 -0
  95. package/node_modules/tslib/LICENSE.txt +12 -0
  96. package/node_modules/tslib/README.md +164 -0
  97. package/node_modules/tslib/SECURITY.md +41 -0
  98. package/node_modules/tslib/modules/index.d.ts +38 -0
  99. package/node_modules/tslib/modules/index.js +70 -0
  100. package/node_modules/tslib/modules/package.json +3 -0
  101. package/node_modules/tslib/package.json +47 -0
  102. package/node_modules/tslib/tslib.d.ts +460 -0
  103. package/node_modules/tslib/tslib.es6.html +1 -0
  104. package/node_modules/tslib/tslib.es6.js +393 -0
  105. package/node_modules/tslib/tslib.es6.mjs +392 -0
  106. package/node_modules/tslib/tslib.html +1 -0
  107. package/node_modules/tslib/tslib.js +475 -0
  108. package/package.json +45 -0
  109. package/tailwindcss-oxide.wasi-browser.js +63 -0
  110. package/tailwindcss-oxide.wasi.cjs +88 -0
  111. package/tailwindcss-oxide.wasm32-wasi.wasm +0 -0
  112. package/wasi-worker-browser.mjs +39 -0
  113. package/wasi-worker.mjs +63 -0
@@ -0,0 +1,209 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * @param {unknown} value
5
+ */
6
+ const getType = (value) => {
7
+ if (value === undefined) return 0
8
+ if (value === null) return 1
9
+ const t = typeof value
10
+ if (t === 'boolean') return 2
11
+ if (t === 'number') return 3
12
+ if (t === 'string') return 4
13
+ if (t === 'object') return 6
14
+ if (t === 'bigint') return 9
15
+ return -1
16
+ }
17
+
18
+ /**
19
+ * @param {import('memfs').IFs} memfs
20
+ * @param {any} value
21
+ * @param {ReturnType<typeof getType>} type
22
+ * @returns {Uint8Array}
23
+ */
24
+ const encodeValue = (memfs, value, type) => {
25
+ switch (type) {
26
+ case 0:
27
+ case 1:
28
+ return new Uint8Array(0)
29
+ case 2: {
30
+ const view = new Int32Array(1)
31
+ view[0] = value ? 1 : 0
32
+ return new Uint8Array(view.buffer)
33
+ }
34
+ case 3: {
35
+ const view = new Float64Array(1)
36
+ view[0] = value
37
+ return new Uint8Array(view.buffer)
38
+ }
39
+ case 4: {
40
+ const view = new TextEncoder().encode(value)
41
+ return view
42
+ }
43
+ case 6: {
44
+ const [entry] = Object.entries(memfs).filter(([_, v]) => v === value.constructor)[0] ?? []
45
+ if (entry) {
46
+ Object.defineProperty(value, '__constructor__', {
47
+ configurable: true,
48
+ writable: true,
49
+ enumerable: true,
50
+ value: entry
51
+ })
52
+ }
53
+
54
+ const json = JSON.stringify(value, (_, value) => {
55
+ if (typeof value === 'bigint') {
56
+ return `BigInt(${String(value)})`
57
+ }
58
+ if (value instanceof Error) {
59
+ return {
60
+ ...value,
61
+ message: value.message,
62
+ stack: value.stack,
63
+ __error__: value.constructor.name,
64
+ }
65
+ }
66
+ return value
67
+ })
68
+ const view = new TextEncoder().encode(json)
69
+ return view
70
+ }
71
+ case 9: {
72
+ const view = new BigInt64Array(1)
73
+ view[0] = value
74
+ return new Uint8Array(view.buffer)
75
+ }
76
+ case -1:
77
+ default:
78
+ throw new Error('unsupported data')
79
+ }
80
+ }
81
+
82
+ /**
83
+ * @param {typeof import('memfs')} memfs
84
+ * @param {Uint8Array} payload
85
+ * @param {number} type
86
+ * @returns {any}
87
+ */
88
+ const decodeValue = (memfs, payload, type) => {
89
+ if (type === 0) return undefined
90
+ if (type === 1) return null
91
+ if (type === 2) return Boolean(payload[0])
92
+ if (type === 3) return new Float64Array(payload.buffer, payload.byteOffset, 1)[0]
93
+ if (type === 4) return new TextDecoder().decode(payload.slice())
94
+ if (type === 6) {
95
+ const obj = JSON.parse(new TextDecoder().decode(payload.slice()), (_key, value) => {
96
+ if (typeof value === 'string') {
97
+ const matched = value.match(/^BigInt\((-?\d+)\)$/)
98
+ if (matched && matched[1]) {
99
+ return BigInt(matched[1])
100
+ }
101
+ }
102
+ return value
103
+ })
104
+ if (obj.__constructor__) {
105
+ const ctor = obj.__constructor__
106
+ delete obj.__constructor__
107
+ Object.setPrototypeOf(obj, memfs[ctor].prototype)
108
+ }
109
+ if (obj.__error__) {
110
+ const name = obj.__error__
111
+ const ErrorConstructor = globalThis[name] || Error
112
+ delete obj.__error__
113
+ const err = new ErrorConstructor(obj.message)
114
+ Object.defineProperty(err, 'stack', {
115
+ configurable: true,
116
+ enumerable: false,
117
+ writable: true,
118
+ value: err.stack
119
+ })
120
+ Object.defineProperty(err, Symbol.toStringTag, {
121
+ configurable: true,
122
+ enumerable: false,
123
+ writable: true,
124
+ value: name
125
+ })
126
+ for (const [k, v] of Object.entries(obj)) {
127
+ if (k === 'message' || k === 'stack') continue
128
+ err[k] = v
129
+ }
130
+ return err
131
+ }
132
+ return obj
133
+ }
134
+ if (type === 9) return new BigInt64Array(payload.buffer, payload.byteOffset, 1)[0]
135
+ throw new Error('unsupported data')
136
+ }
137
+
138
+ /**
139
+ * @param {import('memfs').IFs} fs
140
+ * @returns {(e: { data: { __fs__: { sab: Int32Array, type: keyof import('memfs').IFs, payload: any[] } } }) => void}
141
+ */
142
+ // oxlint-disable-next-line no-unused-vars -- fixed in an upcoming release
143
+ module.exports.createOnMessage = (fs) => function onMessage(e) {
144
+ if (e.data.__fs__) {
145
+ /**
146
+ * 0..4 status(int32_t): 21(waiting) 0(success) 1(error)
147
+ * 5..8 type(napi_valuetype): 0(undefined) 1(null) 2(boolean) 3(number) 4(string) 6(jsonstring) 9(bigint) -1(unsupported)
148
+ * 9..16 payload_size(uint32_t) <= 1024
149
+ * 16..16 + payload_size payload_content
150
+ */
151
+ const { sab, type, payload } = e.data.__fs__
152
+ const fn = fs[type]
153
+ try {
154
+ const ret = fn.apply(fs, payload)
155
+ Atomics.store(sab, 0, 0)
156
+ const t = getType(ret)
157
+ Atomics.store(sab, 1, t)
158
+ const v = encodeValue(fs, ret, t)
159
+ Atomics.store(sab, 2, v.length)
160
+ new Uint8Array(sab.buffer).set(v, 16)
161
+
162
+ } catch (/** @type {any} */ err) {
163
+ Atomics.store(sab, 0, 1)
164
+ const t = getType(err)
165
+ Atomics.store(sab, 1, t)
166
+ const v = encodeValue(fs, err, t)
167
+ Atomics.store(sab, 2, v.length)
168
+ new Uint8Array(sab.buffer).set(v, 16)
169
+ } finally {
170
+ Atomics.notify(sab, 0)
171
+ }
172
+ }
173
+ }
174
+
175
+ /**
176
+ * @param {typeof import('memfs')} memfs
177
+ */
178
+ module.exports.createFsProxy = (memfs) => new Proxy({}, {
179
+ get (_target, p, _receiver) {
180
+ /**
181
+ * @param {any[]} args
182
+ */
183
+ return function (...args) {
184
+ const sab = new SharedArrayBuffer(16 + 10240)
185
+ const i32arr = new Int32Array(sab)
186
+ Atomics.store(i32arr, 0, 21)
187
+
188
+ postMessage({
189
+ __fs__: {
190
+ sab: i32arr,
191
+ type: p,
192
+ payload: args
193
+ }
194
+ })
195
+
196
+ Atomics.wait(i32arr, 0, 21)
197
+
198
+ const status = Atomics.load(i32arr, 0)
199
+ const type = Atomics.load(i32arr, 1)
200
+ const size = Atomics.load(i32arr, 2)
201
+ const content = new Uint8Array(sab, 16, size)
202
+ const value = decodeValue(memfs, content, type)
203
+ if (status === 1) {
204
+ throw value
205
+ }
206
+ return value
207
+ }
208
+ }
209
+ })
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@napi-rs/wasm-runtime",
3
+ "version": "0.2.9",
4
+ "type": "module",
5
+ "description": "Runtime and polyfill for wasm targets",
6
+ "author": {
7
+ "name": "LongYinan",
8
+ "url": "https://github.com/Brooooooklyn"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/napi-rs/napi-rs.git",
13
+ "directory": "wasi-runtime"
14
+ },
15
+ "license": "MIT",
16
+ "publishConfig": {
17
+ "registry": "https://registry.npmjs.org/",
18
+ "access": "public"
19
+ },
20
+ "files": [
21
+ "runtime.cjs",
22
+ "fs-proxy.cjs",
23
+ "dist/*.js"
24
+ ],
25
+ "devDependencies": {
26
+ "@rollup/plugin-alias": "^5.1.1",
27
+ "@rollup/plugin-commonjs": "^28.0.3",
28
+ "@rollup/plugin-inject": "^5.0.5",
29
+ "@rollup/plugin-json": "^6.1.0",
30
+ "@rollup/plugin-node-resolve": "^16.0.1",
31
+ "@rollup/plugin-replace": "^6.0.2",
32
+ "buffer": "^6.0.3",
33
+ "memfs": "^4.17.0",
34
+ "node-inspect-extracted": "^3.0.2",
35
+ "path-browserify": "^1.0.1",
36
+ "process": "^0.11.10",
37
+ "readable-stream": "^4.7.0",
38
+ "rollup": "^4.38.0",
39
+ "rollup-plugin-polyfill-node": "^0.13.0",
40
+ "tslib": "^2.8.1"
41
+ },
42
+ "dependencies": {
43
+ "@emnapi/core": "^1.4.0",
44
+ "@emnapi/runtime": "^1.4.0",
45
+ "@tybys/wasm-util": "^0.9.0"
46
+ },
47
+ "scripts": {
48
+ "build": "rollup -c rollup.config.js",
49
+ "test": "node --test"
50
+ },
51
+ "exports": {
52
+ ".": {
53
+ "import": "./dist/runtime.js",
54
+ "require": "./runtime.cjs"
55
+ },
56
+ "./fs": {
57
+ "import": "./dist/fs.js"
58
+ }
59
+ },
60
+ "gitHead": "84209fc82931e8c6ef93e61e4a0e1d1a0ffaf511"
61
+ }
@@ -0,0 +1,15 @@
1
+ const { MessageHandler, instantiateNapiModuleSync, instantiateNapiModule } = require('@emnapi/core')
2
+ const { getDefaultContext } = require('@emnapi/runtime')
3
+ const { WASI } = require('@tybys/wasm-util')
4
+
5
+ const { createFsProxy, createOnMessage } = require('./fs-proxy.cjs')
6
+
7
+ module.exports = {
8
+ MessageHandler,
9
+ instantiateNapiModule,
10
+ instantiateNapiModuleSync,
11
+ getDefaultContext,
12
+ WASI,
13
+ createFsProxy,
14
+ createOnMessage,
15
+ }
@@ -0,0 +1,193 @@
1
+ # @tybys/wasm-util
2
+
3
+ WebAssembly related utils for browser environment
4
+
5
+ **The output code is ES2019**
6
+
7
+ ## Features
8
+
9
+ All example code below need to be bundled by ES module bundlers like `webpack` / `rollup`, or specify import map in browser native ES module runtime.
10
+
11
+ ### WASI polyfill for browser
12
+
13
+ The API is similar to the `require('wasi').WASI` in Node.js.
14
+
15
+ You can use `memfs-browser` to provide filesystem capability.
16
+
17
+ - Example: [https://github.com/toyobayashi/wasi-wabt](https://github.com/toyobayashi/wasi-wabt)
18
+ - Demo: [https://toyobayashi.github.io/wasi-wabt/](https://toyobayashi.github.io/wasi-wabt/)
19
+
20
+ ```js
21
+ import { load, WASI } from '@tybys/wasm-util'
22
+ import { Volume, createFsFromVolume } from 'memfs-browser'
23
+
24
+ const fs = createFsFromVolume(Volume.fromJSON({
25
+ '/home/wasi': null
26
+ }))
27
+
28
+ const wasi = new WASI({
29
+ args: ['chrome', 'file.wasm'],
30
+ env: {
31
+ NODE_ENV: 'development',
32
+ WASI_SDK_PATH: '/opt/wasi-sdk'
33
+ },
34
+ preopens: {
35
+ '/': '/'
36
+ },
37
+ fs,
38
+
39
+ // redirect stdout / stderr
40
+
41
+ // print (text) { console.log(text) },
42
+ // printErr (text) { console.error(text) }
43
+ })
44
+
45
+ const imports = {
46
+ wasi_snapshot_preview1: wasi.wasiImport
47
+ }
48
+
49
+ const { module, instance } = await load('/path/to/file.wasm', imports)
50
+ wasi.start(instance)
51
+ // wasi.initialize(instance)
52
+ ```
53
+
54
+ Implemented syscalls: [wasi_snapshot_preview1](#wasi_snapshot_preview1)
55
+
56
+ ### `load` / `loadSync`
57
+
58
+ `loadSync` has 4KB wasm size limit in browser.
59
+
60
+ ```js
61
+ // bundler
62
+ import { load, loadSync } from '@tybys/wasm-util'
63
+
64
+ const imports = { /* ... */ }
65
+
66
+ // using path
67
+ const { module, instance } = await load('/path/to/file.wasm', imports)
68
+ const { module, instance } = loadSync('/path/to/file.wasm', imports)
69
+
70
+ // using URL
71
+ const { module, instance } = await load(new URL('./file.wasm', import.meta.url), imports)
72
+ const { module, instance } = loadSync(new URL('./file.wasm', import.meta.url), imports)
73
+
74
+ // using Uint8Array
75
+ const buffer = new Uint8Array([
76
+ 0x00, 0x61, 0x73, 0x6d,
77
+ 0x01, 0x00, 0x00, 0x00
78
+ ])
79
+ const { module, instance } = await load(buffer, imports)
80
+ const { module, instance } = loadSync(buffer, imports)
81
+
82
+ // auto asyncify
83
+ const {
84
+ module,
85
+ instance: asyncifiedInstance
86
+ } = await load(buffer, imports, { /* asyncify options */})
87
+ asyncifiedInstance.exports.fn() // => return Promise
88
+ ```
89
+
90
+ ### Extend Memory instance
91
+
92
+ ```js
93
+ import { Memory, extendMemory } from '@tybys/wasm-util'
94
+
95
+ const memory = new WebAssembly.Memory({ initial: 256 })
96
+ // const memory = instance.exports.memory
97
+
98
+ extendMemory(memory)
99
+ console.log(memory instanceof Memory)
100
+ console.log(memory instanceof WebAssembly.Memory)
101
+ // expose memory view getters like Emscripten
102
+ const { HEAPU8, HEAPU32, view } = memory
103
+ ```
104
+
105
+ ### Asyncify wrap
106
+
107
+ Build the C code using `clang`, `wasm-ld` and `wasm-opt`
108
+
109
+ ```c
110
+ void async_sleep(int ms);
111
+
112
+ int main() {
113
+ async_sleep(200);
114
+ return 0;
115
+ }
116
+ ```
117
+
118
+ ```js
119
+ import { Asyncify } from '@tybys/wasm-util'
120
+
121
+ const asyncify = new Asyncify()
122
+
123
+ const imports = {
124
+ env: {
125
+ async_sleep: asyncify.wrapImportFunction(function (ms) {
126
+ return new Promise((resolve) => {
127
+ setTimeout(resolve, ms)
128
+ })
129
+ })
130
+ }
131
+ }
132
+
133
+ // async_sleep(200)
134
+ const bytes = await (await fetch('/asyncfied_by_wasm-opt.wasm')).arrayBuffer()
135
+ const { instance } = await WebAssembly.instantiate(bytes, imports)
136
+ const asyncifiedInstance = asyncify.init(instance.exports.memory, instance, {
137
+ wrapExports: ['_start']
138
+ })
139
+
140
+ const p = asyncifedInstance._start()
141
+ console.log(typeof p.then === 'function')
142
+ const now = Date.now()
143
+ await p
144
+ console.log(Date.now() - now >= 200)
145
+ ```
146
+
147
+ ### wasi_snapshot_preview1
148
+
149
+ - [x] args_get
150
+ - [x] args_sizes_get
151
+ - [x] environ_get
152
+ - [x] environ_sizes_get
153
+ - [x] clock_res_get
154
+ - [x] clock_time_get
155
+ - [ ] ~~fd_advise~~
156
+ - [x] fd_allocate
157
+ - [x] fd_close
158
+ - [x] fd_datasync
159
+ - [x] fd_fdstat_get
160
+ - [ ] ~~fd_fdstat_set_flags~~
161
+ - [x] fd_fdstat_set_rights
162
+ - [x] fd_filestat_get
163
+ - [x] fd_filestat_set_size
164
+ - [x] fd_filestat_set_times
165
+ - [x] fd_pread
166
+ - [x] fd_prestat_get
167
+ - [x] fd_prestat_dir_name
168
+ - [x] fd_pwrite
169
+ - [x] fd_read
170
+ - [x] fd_readdir
171
+ - [x] fd_renumber
172
+ - [x] fd_seek
173
+ - [x] fd_sync
174
+ - [x] fd_tell
175
+ - [x] fd_write
176
+ - [x] path_create_directory
177
+ - [x] path_filestat_get
178
+ - [x] path_filestat_set_times
179
+ - [x] path_link
180
+ - [x] path_open
181
+ - [x] path_readlink
182
+ - [x] path_remove_directory
183
+ - [x] path_rename
184
+ - [x] path_symlink
185
+ - [x] path_unlink_file
186
+ - [x] poll_oneoff (timer only)
187
+ - [x] proc_exit
188
+ - [ ] ~~proc_raise~~
189
+ - [x] sched_yield
190
+ - [x] random_get
191
+ - [ ] ~~sock_recv~~
192
+ - [ ] ~~sock_send~~
193
+ - [ ] ~~sock_shutdown~~
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.34.4"
9
+ }
10
+ ]
11
+ }