@biuxiu/codegen 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +2 -1
- package/dist/gen-type.js +1 -1
- package/dist/lua_codegen.js +4 -176
- package/dist/lua_codegen_bg.js +174 -0
- package/dist/lua_codegen_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/gen-type.js
CHANGED
@@ -48,7 +48,7 @@ const genLuaTypes = async (path) => {
|
|
48
48
|
if (content.length > 0) {
|
49
49
|
const settionObj = JSON.parse(content);
|
50
50
|
settionObj["Lua.workspace.library"] = types.map(
|
51
|
-
(t) =>
|
51
|
+
(t) => `.vscode/${t}-type.lua`
|
52
52
|
);
|
53
53
|
(0, import_util.writeFormatFile)(settingPath, JSON.stringify(settionObj), true);
|
54
54
|
}
|
package/dist/lua_codegen.js
CHANGED
@@ -1,176 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
const { renderNestCode } = require(`./libs/nest-lib`);
|
6
|
-
const { genWebCode } = require(`./libs/vue-lib`);
|
7
|
-
const { TextDecoder, TextEncoder } = require(`util`);
|
8
|
-
|
9
|
-
const heap = new Array(128).fill(undefined);
|
10
|
-
|
11
|
-
heap.push(undefined, null, true, false);
|
12
|
-
|
13
|
-
function getObject(idx) { return heap[idx]; }
|
14
|
-
|
15
|
-
let heap_next = heap.length;
|
16
|
-
|
17
|
-
function dropObject(idx) {
|
18
|
-
if (idx < 132) return;
|
19
|
-
heap[idx] = heap_next;
|
20
|
-
heap_next = idx;
|
21
|
-
}
|
22
|
-
|
23
|
-
function takeObject(idx) {
|
24
|
-
const ret = getObject(idx);
|
25
|
-
dropObject(idx);
|
26
|
-
return ret;
|
27
|
-
}
|
28
|
-
|
29
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
30
|
-
|
31
|
-
cachedTextDecoder.decode();
|
32
|
-
|
33
|
-
let cachedUint8Memory0 = null;
|
34
|
-
|
35
|
-
function getUint8Memory0() {
|
36
|
-
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
37
|
-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
38
|
-
}
|
39
|
-
return cachedUint8Memory0;
|
40
|
-
}
|
41
|
-
|
42
|
-
function getStringFromWasm0(ptr, len) {
|
43
|
-
ptr = ptr >>> 0;
|
44
|
-
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
45
|
-
}
|
46
|
-
|
47
|
-
function addHeapObject(obj) {
|
48
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
49
|
-
const idx = heap_next;
|
50
|
-
heap_next = heap[idx];
|
51
|
-
|
52
|
-
heap[idx] = obj;
|
53
|
-
return idx;
|
54
|
-
}
|
55
|
-
|
56
|
-
let WASM_VECTOR_LEN = 0;
|
57
|
-
|
58
|
-
function passArray8ToWasm0(arg, malloc) {
|
59
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
60
|
-
getUint8Memory0().set(arg, ptr / 1);
|
61
|
-
WASM_VECTOR_LEN = arg.length;
|
62
|
-
return ptr;
|
63
|
-
}
|
64
|
-
|
65
|
-
let cachedTextEncoder = new TextEncoder('utf-8');
|
66
|
-
|
67
|
-
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
68
|
-
? function (arg, view) {
|
69
|
-
return cachedTextEncoder.encodeInto(arg, view);
|
70
|
-
}
|
71
|
-
: function (arg, view) {
|
72
|
-
const buf = cachedTextEncoder.encode(arg);
|
73
|
-
view.set(buf);
|
74
|
-
return {
|
75
|
-
read: arg.length,
|
76
|
-
written: buf.length
|
77
|
-
};
|
78
|
-
});
|
79
|
-
|
80
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
81
|
-
|
82
|
-
if (realloc === undefined) {
|
83
|
-
const buf = cachedTextEncoder.encode(arg);
|
84
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
85
|
-
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
86
|
-
WASM_VECTOR_LEN = buf.length;
|
87
|
-
return ptr;
|
88
|
-
}
|
89
|
-
|
90
|
-
let len = arg.length;
|
91
|
-
let ptr = malloc(len, 1) >>> 0;
|
92
|
-
|
93
|
-
const mem = getUint8Memory0();
|
94
|
-
|
95
|
-
let offset = 0;
|
96
|
-
|
97
|
-
for (; offset < len; offset++) {
|
98
|
-
const code = arg.charCodeAt(offset);
|
99
|
-
if (code > 0x7F) break;
|
100
|
-
mem[ptr + offset] = code;
|
101
|
-
}
|
102
|
-
|
103
|
-
if (offset !== len) {
|
104
|
-
if (offset !== 0) {
|
105
|
-
arg = arg.slice(offset);
|
106
|
-
}
|
107
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
108
|
-
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
109
|
-
const ret = encodeString(arg, view);
|
110
|
-
|
111
|
-
offset += ret.written;
|
112
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
113
|
-
}
|
114
|
-
|
115
|
-
WASM_VECTOR_LEN = offset;
|
116
|
-
return ptr;
|
117
|
-
}
|
118
|
-
/**
|
119
|
-
* 运行lua代码
|
120
|
-
* @param {Uint8Array} data
|
121
|
-
* @param {string} file_name
|
122
|
-
*/
|
123
|
-
module.exports.run = function(data, file_name) {
|
124
|
-
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
125
|
-
const len0 = WASM_VECTOR_LEN;
|
126
|
-
const ptr1 = passStringToWasm0(file_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
127
|
-
const len1 = WASM_VECTOR_LEN;
|
128
|
-
wasm.run(ptr0, len0, ptr1, len1);
|
129
|
-
};
|
130
|
-
|
131
|
-
function handleError(f, args) {
|
132
|
-
try {
|
133
|
-
return f.apply(this, args);
|
134
|
-
} catch (e) {
|
135
|
-
wasm.__wbindgen_exn_store(addHeapObject(e));
|
136
|
-
}
|
137
|
-
}
|
138
|
-
|
139
|
-
module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
140
|
-
takeObject(arg0);
|
141
|
-
};
|
142
|
-
|
143
|
-
module.exports.__wbg_renderNestCode_ba91730cbcd316b3 = function(arg0, arg1, arg2, arg3) {
|
144
|
-
renderNestCode(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
145
|
-
};
|
146
|
-
|
147
|
-
module.exports.__wbg_genWebCode_2826bcda9a2b9845 = function(arg0, arg1, arg2) {
|
148
|
-
genWebCode(getStringFromWasm0(arg0, arg1), getObject(arg2));
|
149
|
-
};
|
150
|
-
|
151
|
-
module.exports.__wbg_printToNode_f8646f4da26c5023 = function(arg0) {
|
152
|
-
printToNode(getObject(arg0));
|
153
|
-
};
|
154
|
-
|
155
|
-
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
156
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
157
|
-
return addHeapObject(ret);
|
158
|
-
};
|
159
|
-
|
160
|
-
module.exports.__wbg_parse_66d1801634e099ac = function() { return handleError(function (arg0, arg1) {
|
161
|
-
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
162
|
-
return addHeapObject(ret);
|
163
|
-
}, arguments) };
|
164
|
-
|
165
|
-
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
166
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
167
|
-
};
|
168
|
-
|
169
|
-
const path = require('./lua_codegen_bg.wasm');
|
170
|
-
const bytes = require('fs').readFileSync(path);
|
171
|
-
|
172
|
-
const wasmModule = new WebAssembly.Module(bytes);
|
173
|
-
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
174
|
-
wasm = wasmInstance.exports;
|
175
|
-
module.exports.__wasm = wasm;
|
176
|
-
|
1
|
+
import * as wasm from "./lua_codegen_bg.wasm";
|
2
|
+
import { __wbg_set_wasm } from "./lua_codegen_bg.js";
|
3
|
+
__wbg_set_wasm(wasm);
|
4
|
+
export * from "./lua_codegen_bg.js";
|
@@ -0,0 +1,174 @@
|
|
1
|
+
import { printToNode } from './libs';
|
2
|
+
import { renderNestCode } from './libs/nest-lib';
|
3
|
+
import { genWebCode } from './libs/vue-lib';
|
4
|
+
|
5
|
+
let wasm;
|
6
|
+
export function __wbg_set_wasm(val) {
|
7
|
+
wasm = val;
|
8
|
+
}
|
9
|
+
|
10
|
+
|
11
|
+
const heap = new Array(128).fill(undefined);
|
12
|
+
|
13
|
+
heap.push(undefined, null, true, false);
|
14
|
+
|
15
|
+
function getObject(idx) { return heap[idx]; }
|
16
|
+
|
17
|
+
let heap_next = heap.length;
|
18
|
+
|
19
|
+
function dropObject(idx) {
|
20
|
+
if (idx < 132) return;
|
21
|
+
heap[idx] = heap_next;
|
22
|
+
heap_next = idx;
|
23
|
+
}
|
24
|
+
|
25
|
+
function takeObject(idx) {
|
26
|
+
const ret = getObject(idx);
|
27
|
+
dropObject(idx);
|
28
|
+
return ret;
|
29
|
+
}
|
30
|
+
|
31
|
+
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
32
|
+
|
33
|
+
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
34
|
+
|
35
|
+
cachedTextDecoder.decode();
|
36
|
+
|
37
|
+
let cachedUint8Memory0 = null;
|
38
|
+
|
39
|
+
function getUint8Memory0() {
|
40
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
41
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
42
|
+
}
|
43
|
+
return cachedUint8Memory0;
|
44
|
+
}
|
45
|
+
|
46
|
+
function getStringFromWasm0(ptr, len) {
|
47
|
+
ptr = ptr >>> 0;
|
48
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
49
|
+
}
|
50
|
+
|
51
|
+
function addHeapObject(obj) {
|
52
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
53
|
+
const idx = heap_next;
|
54
|
+
heap_next = heap[idx];
|
55
|
+
|
56
|
+
heap[idx] = obj;
|
57
|
+
return idx;
|
58
|
+
}
|
59
|
+
|
60
|
+
let WASM_VECTOR_LEN = 0;
|
61
|
+
|
62
|
+
function passArray8ToWasm0(arg, malloc) {
|
63
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
64
|
+
getUint8Memory0().set(arg, ptr / 1);
|
65
|
+
WASM_VECTOR_LEN = arg.length;
|
66
|
+
return ptr;
|
67
|
+
}
|
68
|
+
|
69
|
+
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
70
|
+
|
71
|
+
let cachedTextEncoder = new lTextEncoder('utf-8');
|
72
|
+
|
73
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
74
|
+
? function (arg, view) {
|
75
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
76
|
+
}
|
77
|
+
: function (arg, view) {
|
78
|
+
const buf = cachedTextEncoder.encode(arg);
|
79
|
+
view.set(buf);
|
80
|
+
return {
|
81
|
+
read: arg.length,
|
82
|
+
written: buf.length
|
83
|
+
};
|
84
|
+
});
|
85
|
+
|
86
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
87
|
+
|
88
|
+
if (realloc === undefined) {
|
89
|
+
const buf = cachedTextEncoder.encode(arg);
|
90
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
91
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
92
|
+
WASM_VECTOR_LEN = buf.length;
|
93
|
+
return ptr;
|
94
|
+
}
|
95
|
+
|
96
|
+
let len = arg.length;
|
97
|
+
let ptr = malloc(len, 1) >>> 0;
|
98
|
+
|
99
|
+
const mem = getUint8Memory0();
|
100
|
+
|
101
|
+
let offset = 0;
|
102
|
+
|
103
|
+
for (; offset < len; offset++) {
|
104
|
+
const code = arg.charCodeAt(offset);
|
105
|
+
if (code > 0x7F) break;
|
106
|
+
mem[ptr + offset] = code;
|
107
|
+
}
|
108
|
+
|
109
|
+
if (offset !== len) {
|
110
|
+
if (offset !== 0) {
|
111
|
+
arg = arg.slice(offset);
|
112
|
+
}
|
113
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
114
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
115
|
+
const ret = encodeString(arg, view);
|
116
|
+
|
117
|
+
offset += ret.written;
|
118
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
119
|
+
}
|
120
|
+
|
121
|
+
WASM_VECTOR_LEN = offset;
|
122
|
+
return ptr;
|
123
|
+
}
|
124
|
+
/**
|
125
|
+
* 运行lua代码
|
126
|
+
* @param {Uint8Array} data
|
127
|
+
* @param {string} file_name
|
128
|
+
*/
|
129
|
+
export function run(data, file_name) {
|
130
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
131
|
+
const len0 = WASM_VECTOR_LEN;
|
132
|
+
const ptr1 = passStringToWasm0(file_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
133
|
+
const len1 = WASM_VECTOR_LEN;
|
134
|
+
wasm.run(ptr0, len0, ptr1, len1);
|
135
|
+
}
|
136
|
+
|
137
|
+
function handleError(f, args) {
|
138
|
+
try {
|
139
|
+
return f.apply(this, args);
|
140
|
+
} catch (e) {
|
141
|
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
export function __wbindgen_object_drop_ref(arg0) {
|
146
|
+
takeObject(arg0);
|
147
|
+
};
|
148
|
+
|
149
|
+
export function __wbg_renderNestCode_ba91730cbcd316b3(arg0, arg1, arg2, arg3) {
|
150
|
+
renderNestCode(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
151
|
+
};
|
152
|
+
|
153
|
+
export function __wbg_genWebCode_2826bcda9a2b9845(arg0, arg1, arg2) {
|
154
|
+
genWebCode(getStringFromWasm0(arg0, arg1), getObject(arg2));
|
155
|
+
};
|
156
|
+
|
157
|
+
export function __wbg_printToNode_f8646f4da26c5023(arg0) {
|
158
|
+
printToNode(getObject(arg0));
|
159
|
+
};
|
160
|
+
|
161
|
+
export function __wbindgen_string_new(arg0, arg1) {
|
162
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
163
|
+
return addHeapObject(ret);
|
164
|
+
};
|
165
|
+
|
166
|
+
export function __wbg_parse_66d1801634e099ac() { return handleError(function (arg0, arg1) {
|
167
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
168
|
+
return addHeapObject(ret);
|
169
|
+
}, arguments) };
|
170
|
+
|
171
|
+
export function __wbindgen_throw(arg0, arg1) {
|
172
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
173
|
+
};
|
174
|
+
|
package/dist/lua_codegen_bg.wasm
CHANGED
Binary file
|