@makano/rew 1.1.72 → 1.1.81
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/build.sh +3 -1
- package/lib/rew/cli/cli.js +189 -144
- package/lib/rew/cli/log.js +18 -19
- package/lib/rew/cli/run.js +7 -9
- package/lib/rew/cli/utils.js +109 -95
- package/lib/rew/const/config_path.js +4 -0
- package/lib/rew/const/default.js +21 -3
- package/lib/rew/const/files.js +11 -8
- package/lib/rew/const/opt.js +6 -6
- package/lib/rew/css/theme.css +1 -1
- package/lib/rew/functions/core.js +7 -9
- package/lib/rew/functions/emitter.js +2 -2
- package/lib/rew/functions/exec.js +19 -15
- package/lib/rew/functions/export.js +4 -6
- package/lib/rew/functions/fs.js +21 -18
- package/lib/rew/functions/future.js +1 -1
- package/lib/rew/functions/import.js +55 -25
- package/lib/rew/functions/map.js +2 -5
- package/lib/rew/functions/match.js +21 -5
- package/lib/rew/functions/path.js +2 -2
- package/lib/rew/functions/require.js +16 -13
- package/lib/rew/functions/stdout.js +11 -11
- package/lib/rew/functions/types.js +67 -42
- package/lib/rew/html/ui.html +5 -6
- package/lib/rew/html/ui.js +100 -58
- package/lib/rew/main.js +3 -3
- package/lib/rew/misc/findAppInfo.js +16 -0
- package/lib/rew/misc/findAppPath.js +21 -0
- package/lib/rew/misc/seededid.js +13 -0
- package/lib/rew/models/struct.js +1 -1
- package/lib/rew/modules/compiler.js +90 -58
- package/lib/rew/modules/context.js +35 -22
- package/lib/rew/modules/runtime.js +1 -1
- package/lib/rew/pkgs/conf.js +50 -33
- package/lib/rew/pkgs/data.js +7 -2
- package/lib/rew/pkgs/date.js +8 -9
- package/lib/rew/pkgs/env.js +3 -5
- package/lib/rew/pkgs/modules/data/bintree.js +1 -1
- package/lib/rew/pkgs/modules/data/doublylinked.js +1 -1
- package/lib/rew/pkgs/modules/data/linkedList.js +1 -1
- package/lib/rew/pkgs/modules/data/queue.js +1 -2
- package/lib/rew/pkgs/modules/data/stack.js +1 -1
- package/lib/rew/pkgs/modules/threads/worker.js +31 -21
- package/lib/rew/pkgs/modules/ui/classes.js +68 -61
- package/lib/rew/pkgs/pkgs.js +5 -6
- package/lib/rew/pkgs/rune.js +437 -0
- package/lib/rew/pkgs/threads.js +30 -22
- package/lib/rew/pkgs/ui.js +68 -44
- package/meson.build +1 -1
- package/package.json +8 -2
package/lib/rew/html/ui.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
try{
|
1
|
+
try {
|
2
2
|
window.execContext = $OPTIONS(json.execContext);
|
3
|
-
} catch(e){
|
3
|
+
} catch (e) {
|
4
4
|
window.execContext = {};
|
5
5
|
}
|
6
6
|
|
7
|
-
try{
|
7
|
+
try {
|
8
8
|
window.exec = $OPTIONS(exec);
|
9
|
-
} catch(e){
|
10
|
-
window.exec = function(){};
|
9
|
+
} catch (e) {
|
10
|
+
window.exec = function () {};
|
11
11
|
}
|
12
12
|
|
13
13
|
const DOM = [];
|
@@ -27,31 +27,31 @@ const addTo = (el, parent) => {
|
|
27
27
|
};
|
28
28
|
|
29
29
|
const initElement = (el, options, update = false) => {
|
30
|
-
if(el.widgetOptions){
|
30
|
+
if (el.widgetOptions) {
|
31
31
|
if (el.widgetOptions.style) {
|
32
|
-
for(let i in options.style){
|
32
|
+
for (let i in options.style) {
|
33
33
|
el.style.removeProperty(i, el.widgetOptions.style[i]);
|
34
34
|
}
|
35
35
|
}
|
36
36
|
if (el.widgetOptions.attr) {
|
37
|
-
for(let i in el.widgetOptions.attr){
|
37
|
+
for (let i in el.widgetOptions.attr) {
|
38
38
|
el.removeAttribute(i);
|
39
39
|
}
|
40
40
|
}
|
41
41
|
}
|
42
|
-
|
42
|
+
|
43
43
|
el.widgetOptions = options;
|
44
44
|
el.id = options.id;
|
45
45
|
el.textContent = options.data.text;
|
46
46
|
|
47
47
|
if (options.style) {
|
48
|
-
for(let i in options.style){
|
48
|
+
for (let i in options.style) {
|
49
49
|
el.style.setProperty(i, options.style[i]);
|
50
50
|
}
|
51
51
|
}
|
52
52
|
|
53
53
|
if (options.attr) {
|
54
|
-
for(let i in options.attr){
|
54
|
+
for (let i in options.attr) {
|
55
55
|
el.setAttribute(i, options.attr[i]);
|
56
56
|
}
|
57
57
|
}
|
@@ -59,7 +59,7 @@ const initElement = (el, options, update = false) => {
|
|
59
59
|
if (options.children.length) {
|
60
60
|
options.children.forEach((option) => {
|
61
61
|
option.parent = options.uuid;
|
62
|
-
if(update) updateElement(findInDom(option.uuid), option);
|
62
|
+
if (update) updateElement(findInDom(option.uuid), option);
|
63
63
|
else createElement(option);
|
64
64
|
});
|
65
65
|
}
|
@@ -67,46 +67,75 @@ const initElement = (el, options, update = false) => {
|
|
67
67
|
if (options.parent) {
|
68
68
|
addTo(el, options.parent);
|
69
69
|
}
|
70
|
-
}
|
70
|
+
};
|
71
71
|
|
72
72
|
const updateElement = (el, options) => {
|
73
|
-
if(!el) return;
|
73
|
+
if (!el) return;
|
74
74
|
initElement(el, options, true);
|
75
75
|
return el;
|
76
|
-
}
|
76
|
+
};
|
77
77
|
|
78
78
|
const events = [
|
79
|
-
"click",
|
80
|
-
"
|
81
|
-
"
|
82
|
-
"
|
83
|
-
"
|
79
|
+
"click",
|
80
|
+
"dblclick",
|
81
|
+
"mousedown",
|
82
|
+
"mouseup",
|
83
|
+
"mouseover",
|
84
|
+
"mouseout",
|
85
|
+
"mousemove",
|
86
|
+
"mouseenter",
|
87
|
+
"mouseleave",
|
88
|
+
"keydown",
|
89
|
+
"keypress",
|
90
|
+
"keyup",
|
91
|
+
"change",
|
92
|
+
"input",
|
93
|
+
"submit",
|
94
|
+
"focus",
|
95
|
+
"blur",
|
96
|
+
"copy",
|
97
|
+
"cut",
|
98
|
+
"paste",
|
99
|
+
"scroll",
|
100
|
+
"wheel",
|
101
|
+
"resize",
|
102
|
+
"contextmenu",
|
103
|
+
"drag",
|
104
|
+
"dragstart",
|
105
|
+
"dragend",
|
106
|
+
"dragenter",
|
107
|
+
"dragleave",
|
108
|
+
"dragover",
|
109
|
+
"drop",
|
110
|
+
"error",
|
111
|
+
"load",
|
112
|
+
"abort",
|
84
113
|
];
|
85
114
|
const handleListeners = (el) => {
|
86
|
-
events.forEach(event => {
|
115
|
+
events.forEach((event) => {
|
87
116
|
el.addEventListener(event, (e) => {
|
88
117
|
sendData({
|
89
|
-
action:
|
118
|
+
action: "hook:eventTrigger",
|
90
119
|
data: {
|
91
|
-
rid:
|
120
|
+
rid: "event_trigger",
|
92
121
|
object: {
|
93
122
|
uuid: el.widgetOptions.uuid,
|
94
123
|
event,
|
95
124
|
data: {
|
96
125
|
mouse: { x: e.clientX, y: e.clientY },
|
97
|
-
key: { code: e.keyCode, key: e.key }
|
98
|
-
}
|
99
|
-
}
|
100
|
-
}
|
126
|
+
key: { code: e.keyCode, key: e.key },
|
127
|
+
},
|
128
|
+
},
|
129
|
+
},
|
101
130
|
});
|
102
131
|
});
|
103
132
|
});
|
104
|
-
}
|
133
|
+
};
|
105
134
|
|
106
|
-
function eventHandlerFunction({ uuid, hookID, event }){
|
107
|
-
return function(e){
|
135
|
+
function eventHandlerFunction({ uuid, hookID, event }) {
|
136
|
+
return function (e) {
|
108
137
|
sendData({
|
109
|
-
action:
|
138
|
+
action: "hook:event_" + event,
|
110
139
|
data: {
|
111
140
|
rid: hookID,
|
112
141
|
object: {
|
@@ -114,12 +143,12 @@ function eventHandlerFunction({ uuid, hookID, event }){
|
|
114
143
|
event,
|
115
144
|
data: {
|
116
145
|
mouse: { x: e.clientX, y: e.clientY },
|
117
|
-
key: { code: e.keyCode, key: e.key }
|
118
|
-
}
|
119
|
-
}
|
120
|
-
}
|
146
|
+
key: { code: e.keyCode, key: e.key },
|
147
|
+
},
|
148
|
+
},
|
149
|
+
},
|
121
150
|
});
|
122
|
-
}
|
151
|
+
};
|
123
152
|
}
|
124
153
|
|
125
154
|
const createElement = (options) => {
|
@@ -139,18 +168,25 @@ const stringifyJSON = (json) => {
|
|
139
168
|
|
140
169
|
const log = (...strings) => {
|
141
170
|
window.webkit.messageHandlers.external.postMessage(
|
142
|
-
JSON.stringify(
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
171
|
+
JSON.stringify(
|
172
|
+
{
|
173
|
+
action: "log",
|
174
|
+
data: strings
|
175
|
+
.map((r) =>
|
176
|
+
typeof r == "object" ? stringifyJSON(r) : `${r.toString()}`,
|
177
|
+
)
|
178
|
+
// .map((i) => i.replace(/\"/g, '\\\\"').replace(/\n/g, "\\\\n"))
|
179
|
+
.join("\n"),
|
180
|
+
},
|
181
|
+
null,
|
182
|
+
4,
|
183
|
+
),
|
148
184
|
);
|
149
185
|
};
|
150
186
|
|
151
187
|
const sendData = (data) => {
|
152
|
-
log("RESPONSE::"+stringifyJSON(data));
|
153
|
-
}
|
188
|
+
log("RESPONSE::" + stringifyJSON(data));
|
189
|
+
};
|
154
190
|
|
155
191
|
function process_data(data) {
|
156
192
|
return JSON.parse(data);
|
@@ -158,10 +194,10 @@ function process_data(data) {
|
|
158
194
|
|
159
195
|
window.recieveMessage = (data) => {
|
160
196
|
const edata = data;
|
161
|
-
if(edata.action ==
|
197
|
+
if (edata.action == "eventListen") {
|
162
198
|
const el = findInDom(edata.data.uuid);
|
163
|
-
if(el){
|
164
|
-
el.addEventListener(edata.data.event, eventHandlerFunction(edata.data))
|
199
|
+
if (el) {
|
200
|
+
el.addEventListener(edata.data.event, eventHandlerFunction(edata.data));
|
165
201
|
}
|
166
202
|
} else if (edata.action == "createElement") {
|
167
203
|
const options = edata.data;
|
@@ -171,7 +207,7 @@ window.recieveMessage = (data) => {
|
|
171
207
|
log(e.toString());
|
172
208
|
}
|
173
209
|
} else if (edata.action == "addStyleSheet") {
|
174
|
-
const style = document.createElement(
|
210
|
+
const style = document.createElement("style");
|
175
211
|
style.textContent = edata.data;
|
176
212
|
document.head.appendChild(style);
|
177
213
|
} else if (edata.action == "updateElement") {
|
@@ -185,24 +221,30 @@ window.recieveMessage = (data) => {
|
|
185
221
|
const id = edata.data.id;
|
186
222
|
const rid = edata.data.rid;
|
187
223
|
try {
|
188
|
-
sendData({
|
224
|
+
sendData({
|
225
|
+
action: "hook:findElement",
|
226
|
+
data: { rid, object: findInDom(id)?.widgetOptions },
|
227
|
+
});
|
189
228
|
} catch (e) {
|
190
229
|
log(e.toString());
|
191
230
|
}
|
192
|
-
} else if(edata.action ==
|
193
|
-
window.dispatchEvent(
|
194
|
-
|
195
|
-
|
231
|
+
} else if (edata.action == "message") {
|
232
|
+
window.dispatchEvent(
|
233
|
+
new CustomEvent("message", {
|
234
|
+
detail: edata.data,
|
235
|
+
}),
|
236
|
+
);
|
196
237
|
}
|
197
238
|
};
|
198
239
|
|
199
|
-
window.addEventListener(
|
240
|
+
window.addEventListener("load", () => {
|
200
241
|
window.exec({
|
201
242
|
...window.execContext,
|
202
243
|
window,
|
203
244
|
log,
|
204
|
-
send: (data) => sendData({ action:
|
205
|
-
onRecieve: (cb) =>
|
245
|
+
send: (data) => sendData({ action: "message", data }),
|
246
|
+
onRecieve: (cb) =>
|
247
|
+
window.addEventListener("message", (e) => cb(e.detail || {})),
|
206
248
|
});
|
207
|
-
log(
|
208
|
-
});
|
249
|
+
log("SETUP::READY");
|
250
|
+
});
|
package/lib/rew/main.js
CHANGED
@@ -5,9 +5,9 @@ const { imp } = require("./functions/import");
|
|
5
5
|
const { FILES } = require("./const/files");
|
6
6
|
|
7
7
|
module.exports.run = function (filepath, options = {}, custom_context = {}) {
|
8
|
-
FILES.forEach(file => {
|
9
|
-
if(fs.existsSync(file.path)) return;
|
10
|
-
if(file.content){
|
8
|
+
FILES.forEach((file) => {
|
9
|
+
if (fs.existsSync(file.path)) return;
|
10
|
+
if (file.content) {
|
11
11
|
fs.writeFileSync(file.path, file.content);
|
12
12
|
} else {
|
13
13
|
fs.mkdirSync(file.path, { recursive: true });
|
@@ -0,0 +1,16 @@
|
|
1
|
+
const jsYaml = require("js-yaml");
|
2
|
+
const { findAppPath } = require("./findAppPath");
|
3
|
+
const path = require("path");
|
4
|
+
const { readFileSync } = require("fs");
|
5
|
+
|
6
|
+
module.exports.findAppInfo = function (filepath) {
|
7
|
+
const appPath = findAppPath(path.dirname(filepath));
|
8
|
+
if (appPath) {
|
9
|
+
const config = jsYaml.load(readFileSync(path.join(appPath, "app.yaml")));
|
10
|
+
return {
|
11
|
+
path: appPath,
|
12
|
+
config,
|
13
|
+
};
|
14
|
+
}
|
15
|
+
return null;
|
16
|
+
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
const path = require("path"); // Import the 'path' module
|
2
|
+
const fs = require("fs"); // Import the 'path' module
|
3
|
+
|
4
|
+
module.exports.findAppPath = (currentDir = __dirname) => {
|
5
|
+
// Check if app.yaml exists in the current directory
|
6
|
+
const appYamlPath = path.join(currentDir, "app.yaml");
|
7
|
+
if (fs.existsSync(appYamlPath)) {
|
8
|
+
return currentDir;
|
9
|
+
}
|
10
|
+
|
11
|
+
// If not found, move up a directory level
|
12
|
+
const parentDir = path.dirname(currentDir);
|
13
|
+
|
14
|
+
// Check if we reached the root directory
|
15
|
+
if (parentDir === currentDir) {
|
16
|
+
return null; // Not found
|
17
|
+
}
|
18
|
+
|
19
|
+
// Recursively call the function on the parent directory
|
20
|
+
return module.exports.findAppPath(parentDir);
|
21
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module.exports.seededID = function (seed) {
|
2
|
+
const charCodes = seed.split("").map((char) => char.charCodeAt(0));
|
3
|
+
|
4
|
+
let result = "";
|
5
|
+
let sum = 0;
|
6
|
+
|
7
|
+
for (let i = 0; i < charCodes.length; i++) {
|
8
|
+
sum += charCodes[i];
|
9
|
+
result += String.fromCharCode(((charCodes[i] + sum) % 26) + 97);
|
10
|
+
}
|
11
|
+
|
12
|
+
return result.slice(0, 12);
|
13
|
+
};
|
package/lib/rew/models/struct.js
CHANGED
@@ -1,21 +1,24 @@
|
|
1
1
|
const { compile } = require("../../coffeescript/coffeescript");
|
2
2
|
const { execOptions } = require("../const/opt");
|
3
3
|
const { getFile } = require("./fs");
|
4
|
-
const babel = require(
|
5
|
-
const babelReact = require(
|
4
|
+
const babel = require("@babel/core");
|
5
|
+
const babelReact = require("@babel/preset-react");
|
6
6
|
|
7
7
|
function tokenizeCoffeeScript(code) {
|
8
8
|
const tokens = [];
|
9
|
-
let currentToken =
|
9
|
+
let currentToken = "";
|
10
10
|
|
11
11
|
for (let i = 0; i < code.length; i++) {
|
12
12
|
const char = code[i];
|
13
13
|
const nextChar = code[i + 1];
|
14
14
|
|
15
|
-
if (char ===
|
15
|
+
if (char === "#") {
|
16
16
|
// Comment
|
17
|
-
tokens.push({
|
18
|
-
|
17
|
+
tokens.push({
|
18
|
+
type: "COMMENT",
|
19
|
+
value: char + code.substring(i + 1).split("\n")[0] + "\n",
|
20
|
+
});
|
21
|
+
i = code.indexOf("\n", i);
|
19
22
|
} else if (char === '"' || char === "'") {
|
20
23
|
// String
|
21
24
|
let string = char;
|
@@ -23,7 +26,7 @@ function tokenizeCoffeeScript(code) {
|
|
23
26
|
i++;
|
24
27
|
while (i < code.length && (code[i] !== char || escaped)) {
|
25
28
|
string += code[i];
|
26
|
-
if (code[i] ===
|
29
|
+
if (code[i] === "\\" && !escaped) {
|
27
30
|
escaped = true;
|
28
31
|
} else {
|
29
32
|
escaped = false;
|
@@ -31,25 +34,26 @@ function tokenizeCoffeeScript(code) {
|
|
31
34
|
i++;
|
32
35
|
}
|
33
36
|
string += char; // Include closing quote
|
34
|
-
tokens.push({ type:
|
35
|
-
} else if (char ===
|
37
|
+
tokens.push({ type: "STRING", value: string });
|
38
|
+
} else if (char === "/" && (nextChar === "/" || nextChar === "*")) {
|
36
39
|
// Regular expression
|
37
40
|
let regex = char;
|
38
41
|
i++;
|
39
|
-
while (i < code.length && (code[i] !==
|
42
|
+
while (i < code.length && (code[i] !== "/" || regex.endsWith("\\"))) {
|
40
43
|
regex += code[i];
|
41
44
|
i++;
|
42
45
|
}
|
43
|
-
regex +=
|
44
|
-
tokens.push({ type:
|
46
|
+
regex += "/";
|
47
|
+
tokens.push({ type: "REGEX", value: regex });
|
45
48
|
} else if (/\s/.test(char)) {
|
46
49
|
// Whitespace
|
47
|
-
if(
|
48
|
-
|
49
|
-
|
50
|
-
|
50
|
+
if (
|
51
|
+
tokens[tokens.length - 1]?.type == "WHITESPACE" &&
|
52
|
+
tokens[tokens.length - 1].value[0] == char
|
53
|
+
) {
|
54
|
+
tokens[tokens.length - 1].value += char;
|
51
55
|
} else {
|
52
|
-
tokens.push({ type:
|
56
|
+
tokens.push({ type: "WHITESPACE", value: char });
|
53
57
|
}
|
54
58
|
} else if (/[a-zA-Z_$]/.test(char)) {
|
55
59
|
// Identifier
|
@@ -59,11 +63,11 @@ function tokenizeCoffeeScript(code) {
|
|
59
63
|
identifier += code[i];
|
60
64
|
i++;
|
61
65
|
}
|
62
|
-
tokens.push({ type:
|
66
|
+
tokens.push({ type: "IDENTIFIER", value: identifier });
|
63
67
|
i--; // Move back one character to recheck
|
64
68
|
} else {
|
65
69
|
// Other characters
|
66
|
-
tokens.push({ type:
|
70
|
+
tokens.push({ type: "OTHER", value: char });
|
67
71
|
}
|
68
72
|
}
|
69
73
|
|
@@ -71,16 +75,31 @@ function tokenizeCoffeeScript(code) {
|
|
71
75
|
}
|
72
76
|
|
73
77
|
const gnextToken = (i, n, tokens) => {
|
74
|
-
return tokens[i + n]
|
75
|
-
|
78
|
+
return tokens[i + n]
|
79
|
+
? tokens[i + n].type == "WHITESPACE"
|
80
|
+
? gnextToken(i, n + 1, tokens)
|
81
|
+
: { nextToken: tokens[i + n], n }
|
82
|
+
: null;
|
83
|
+
};
|
76
84
|
|
77
85
|
const fnextToken = (i, tokens, type, value) => {
|
78
|
-
return tokens
|
79
|
-
|
86
|
+
return tokens
|
87
|
+
.map((t, ind) => {
|
88
|
+
t.ti = ind;
|
89
|
+
return t;
|
90
|
+
})
|
91
|
+
.slice(i, tokens.length - 1)
|
92
|
+
.map((t, ind) => {
|
93
|
+
t.ri = ind;
|
94
|
+
t.index = ind - i;
|
95
|
+
return t;
|
96
|
+
})
|
97
|
+
.find((t) => t.type == type && (value ? t.value == value : true));
|
98
|
+
};
|
80
99
|
|
81
100
|
function compileRewStuff(content, options) {
|
82
101
|
const tokens = tokenizeCoffeeScript(content);
|
83
|
-
let result =
|
102
|
+
let result = "";
|
84
103
|
|
85
104
|
let hooks = [];
|
86
105
|
|
@@ -88,53 +107,60 @@ function compileRewStuff(content, options) {
|
|
88
107
|
const token = tokens[i];
|
89
108
|
let { nextToken, n } = gnextToken(i, 1, tokens) || {};
|
90
109
|
|
91
|
-
if (token.type ===
|
110
|
+
if (token.type === "IDENTIFIER" && token.value === "opt") {
|
92
111
|
const { nextToken: nextNextToken } = gnextToken(i, 2, tokens) || {};
|
93
|
-
if(nextNextToken && nextNextToken.value ==
|
112
|
+
if (nextNextToken && nextNextToken.value == "jsxPragma") {
|
94
113
|
const { nextToken: nextLastToken } = gnextToken(i, 5, tokens) || {};
|
95
114
|
execOptions.jsxPragma = nextLastToken.value.slice(1).slice(0, -1);
|
96
115
|
}
|
97
116
|
}
|
98
117
|
|
99
|
-
if (token.type ===
|
118
|
+
if (token.type === "COMMENT" && token.value.slice(1).trim() === "@jsx") {
|
100
119
|
options.jsx = true;
|
101
120
|
}
|
102
121
|
|
103
|
-
if (token.type ===
|
122
|
+
if (token.type === "IDENTIFIER" && token.value === "import") {
|
104
123
|
// console.log(nextToken.type);
|
105
124
|
let ind = i + n + 2;
|
106
125
|
|
107
126
|
let defaultName;
|
108
|
-
if (nextToken.type ===
|
127
|
+
if (nextToken.type === "STRING") {
|
109
128
|
result += `inc ${nextToken.value}`;
|
110
129
|
i += n;
|
111
|
-
} else if (nextToken.value ===
|
112
|
-
const closingBraceToken = fnextToken(ind, tokens,
|
113
|
-
const nameToken = fnextToken(ind, tokens,
|
130
|
+
} else if (nextToken.value === "{") {
|
131
|
+
const closingBraceToken = fnextToken(ind, tokens, "OTHER", "}");
|
132
|
+
const nameToken = fnextToken(ind, tokens, "STRING");
|
114
133
|
if (closingBraceToken) {
|
115
134
|
const exportsTokens = tokens.slice(ind, closingBraceToken.ti);
|
116
|
-
const exports = exportsTokens
|
135
|
+
const exports = exportsTokens
|
136
|
+
.filter((t) => t.type === "IDENTIFIER")
|
137
|
+
.map((t) => t.value)
|
138
|
+
.join(", ");
|
117
139
|
result += `{ ${exports} } = inc ${nameToken.value}`;
|
118
140
|
i = nameToken.ti;
|
119
141
|
}
|
120
|
-
} else if (nextToken.value ===
|
121
|
-
const asToken = fnextToken(ind, tokens,
|
122
|
-
const nameToken = fnextToken(asToken.ri, tokens,
|
142
|
+
} else if (nextToken.value === "*") {
|
143
|
+
const asToken = fnextToken(ind, tokens, "IDENTIFIER", "as");
|
144
|
+
const nameToken = fnextToken(asToken.ri, tokens, "STRING");
|
123
145
|
if (asToken) {
|
124
|
-
const nextToken = fnextToken(asToken.ti + 1, tokens,
|
146
|
+
const nextToken = fnextToken(asToken.ti + 1, tokens, "IDENTIFIER");
|
125
147
|
defaultName = nextToken.value;
|
126
148
|
result += `${defaultName} = inc ${nameToken.value}`;
|
127
149
|
i = ind + 6;
|
128
150
|
}
|
129
|
-
} else if(nextToken) {
|
130
|
-
const nameToken = fnextToken(ind, tokens,
|
151
|
+
} else if (nextToken) {
|
152
|
+
const nameToken = fnextToken(ind, tokens, "STRING");
|
131
153
|
defaultName = nextToken.value;
|
132
|
-
let { nextToken: nextNextToken, n: n2 } =
|
133
|
-
|
134
|
-
|
135
|
-
|
154
|
+
let { nextToken: nextNextToken, n: n2 } =
|
155
|
+
gnextToken(i + 2, 1, tokens) || {};
|
156
|
+
if (nextNextToken?.type == "OTHER" && nextNextToken?.value == ",") {
|
157
|
+
const closingBraceToken = fnextToken(ind, tokens, "OTHER", "}");
|
158
|
+
if (closingBraceToken) {
|
136
159
|
const exportsTokens = tokens.slice(ind, closingBraceToken.ti);
|
137
|
-
const exports = exportsTokens
|
160
|
+
const exports = exportsTokens
|
161
|
+
.filter((t) => t.type === "IDENTIFIER")
|
162
|
+
.map((t) => t.value)
|
163
|
+
.join(", ");
|
138
164
|
result += `{ default: ${defaultName}, ${exports} } = inc ${nameToken?.value || ""}`;
|
139
165
|
i = closingBraceToken.ti + 4;
|
140
166
|
}
|
@@ -142,27 +168,29 @@ function compileRewStuff(content, options) {
|
|
142
168
|
result += `{ default: ${defaultName} } = inc ${nameToken?.value || ""}`;
|
143
169
|
i = ind + 2;
|
144
170
|
}
|
145
|
-
|
146
171
|
}
|
147
172
|
|
148
|
-
const nextLastToken = fnextToken(i, tokens,
|
173
|
+
const nextLastToken = fnextToken(i, tokens, "IDENTIFIER");
|
149
174
|
|
150
|
-
if(nextLastToken?.value ==
|
151
|
-
result +=
|
175
|
+
if (nextLastToken?.value == "assert") {
|
176
|
+
result += ", ";
|
152
177
|
i += 3;
|
153
178
|
}
|
154
179
|
|
155
180
|
continue;
|
156
181
|
}
|
157
182
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
nextToken
|
162
|
-
|
183
|
+
if (
|
184
|
+
token.type === "IDENTIFIER" &&
|
185
|
+
token.value === "pub" &&
|
186
|
+
nextToken &&
|
187
|
+
nextToken.type === "IDENTIFIER" &&
|
188
|
+
nextToken.value &&
|
189
|
+
nextToken.value !== "undefined"
|
190
|
+
) {
|
163
191
|
hooks.push({
|
164
192
|
index: i + 1,
|
165
|
-
value: `"${nextToken.value}",
|
193
|
+
value: `"${nextToken.value}", `,
|
166
194
|
});
|
167
195
|
}
|
168
196
|
|
@@ -182,13 +210,17 @@ function compileRewStuff(content, options) {
|
|
182
210
|
return result;
|
183
211
|
}
|
184
212
|
|
185
|
-
|
186
213
|
const cpl = (module.exports.compile = function (file, options = {}) {
|
187
|
-
let c = compile(compileRewStuff(file.content, options), {
|
188
|
-
|
214
|
+
let c = compile(compileRewStuff(file.content, options), {
|
215
|
+
...options,
|
216
|
+
filename: file.path,
|
217
|
+
bare: false,
|
218
|
+
inlineMap: false,
|
219
|
+
});
|
220
|
+
if (execOptions.jsx || options.jsx) {
|
189
221
|
c = babel.transformSync(c, {
|
190
222
|
presets: [[babelReact, { pragma: execOptions.jsxPragma }]],
|
191
|
-
plugins: []
|
223
|
+
plugins: [],
|
192
224
|
}).code;
|
193
225
|
}
|
194
226
|
return c;
|