chemicaljs 1.8.6 → 2.0.0
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.
- package/client/chemical.components.js +63 -14
- package/client/chemical.js +63 -47
- package/index.js +60 -89
- package/package.json +2 -2
|
@@ -4,10 +4,23 @@ class ChemicalInput extends HTMLInputElement {
|
|
|
4
4
|
}
|
|
5
5
|
connectedCallback() {
|
|
6
6
|
this.addEventListener("keydown", async function (e) {
|
|
7
|
-
if (e.key
|
|
8
|
-
let service =
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
if (e.key === "Enter" && window.chemical.loaded && e.target.value) {
|
|
8
|
+
let service =
|
|
9
|
+
this.dataset.serviceStore !== undefined
|
|
10
|
+
? localStorage.getItem("@chemical/service") ||
|
|
11
|
+
this.dataset.service ||
|
|
12
|
+
"uv"
|
|
13
|
+
: this.dataset.service || "uv";
|
|
14
|
+
let autoHttps =
|
|
15
|
+
this.dataset.autoHttpsStore !== undefined
|
|
16
|
+
? localStorage.getItem("@chemical/autoHttps") === "true"
|
|
17
|
+
: this.dataset.autoHttps !== undefined
|
|
18
|
+
? true
|
|
19
|
+
: false;
|
|
20
|
+
let searchEngine =
|
|
21
|
+
this.dataset.searchEngineStore !== undefined
|
|
22
|
+
? localStorage.getItem("@chemical/searchEngine")
|
|
23
|
+
: this.dataset.searchEngine;
|
|
11
24
|
let action = this.dataset.action;
|
|
12
25
|
let target = this.dataset.target;
|
|
13
26
|
let frame = this.dataset.frame;
|
|
@@ -28,9 +41,9 @@ class ChemicalInput extends HTMLInputElement {
|
|
|
28
41
|
}
|
|
29
42
|
|
|
30
43
|
if (target) {
|
|
31
|
-
if (target
|
|
44
|
+
if (target === "_self") {
|
|
32
45
|
window.location = encodedURL;
|
|
33
|
-
} else if (target
|
|
46
|
+
} else if (target === "_blank") {
|
|
34
47
|
window.open(encodedURL);
|
|
35
48
|
}
|
|
36
49
|
}
|
|
@@ -65,12 +78,12 @@ class ChemicalIFrame extends HTMLIFrameElement {
|
|
|
65
78
|
}
|
|
66
79
|
connectedCallback() {
|
|
67
80
|
let open = this.dataset.open;
|
|
68
|
-
this.style.display = open
|
|
81
|
+
this.style.display = open === "true" ? "" : "none";
|
|
69
82
|
}
|
|
70
83
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
71
|
-
if (name
|
|
84
|
+
if (name === "data-open") {
|
|
72
85
|
let open = this.dataset.open;
|
|
73
|
-
this.style.display = open
|
|
86
|
+
this.style.display = open === "true" ? "" : "none";
|
|
74
87
|
|
|
75
88
|
let controls = document.getElementById(this.dataset.controls);
|
|
76
89
|
|
|
@@ -88,12 +101,12 @@ class ChemicalControls extends HTMLElement {
|
|
|
88
101
|
}
|
|
89
102
|
connectedCallback() {
|
|
90
103
|
let open = this.dataset.open;
|
|
91
|
-
this.style.display = open
|
|
104
|
+
this.style.display = open === "true" ? "" : "none";
|
|
92
105
|
}
|
|
93
106
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
94
|
-
if (name
|
|
107
|
+
if (name === "data-open") {
|
|
95
108
|
let open = this.dataset.open;
|
|
96
|
-
this.style.display = open
|
|
109
|
+
this.style.display = open === "true" ? "" : "none";
|
|
97
110
|
}
|
|
98
111
|
}
|
|
99
112
|
}
|
|
@@ -135,6 +148,41 @@ class ChemicalLink extends HTMLAnchorElement {
|
|
|
135
148
|
}
|
|
136
149
|
}
|
|
137
150
|
|
|
151
|
+
class ChemicalSelect extends HTMLSelectElement {
|
|
152
|
+
constructor() {
|
|
153
|
+
super();
|
|
154
|
+
}
|
|
155
|
+
connectedCallback() {
|
|
156
|
+
const store = this.dataset.defaultStore;
|
|
157
|
+
|
|
158
|
+
this.addEventListener("change", function () {
|
|
159
|
+
window.chemical.setStore(store, this.value);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
if (store) {
|
|
163
|
+
const value = window.chemical.getStore(store);
|
|
164
|
+
|
|
165
|
+
const observerOptions = {
|
|
166
|
+
childList: true,
|
|
167
|
+
subtree: false,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const observer = new MutationObserver((records, observer) => {
|
|
171
|
+
for (const record of records) {
|
|
172
|
+
for (const addedNode of record.addedNodes) {
|
|
173
|
+
if (addedNode.tagName === "OPTION") {
|
|
174
|
+
if (addedNode.getAttribute("value") === value) {
|
|
175
|
+
addedNode.setAttribute("selected", "");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
observer.observe(this, observerOptions);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
138
186
|
customElements.define("chemical-input", ChemicalInput, { extends: "input" });
|
|
139
187
|
customElements.define("chemical-button", ChemicalButton, { extends: "button" });
|
|
140
188
|
customElements.define("chemical-iframe", ChemicalIFrame, { extends: "iframe" });
|
|
@@ -142,8 +190,9 @@ customElements.define("chemical-controls", ChemicalControls, {
|
|
|
142
190
|
extends: "section",
|
|
143
191
|
});
|
|
144
192
|
customElements.define("chemical-link", ChemicalLink, { extends: "a" });
|
|
193
|
+
customElements.define("chemical-select", ChemicalSelect, { extends: "select" });
|
|
145
194
|
|
|
146
|
-
function
|
|
195
|
+
window.chemical.componentAction = function (action, frameID) {
|
|
147
196
|
let frame = document.getElementById(frameID);
|
|
148
197
|
|
|
149
198
|
if (frame) {
|
|
@@ -162,4 +211,4 @@ function chemicalAction(action, frameID) {
|
|
|
162
211
|
frame.src = "";
|
|
163
212
|
}
|
|
164
213
|
}
|
|
165
|
-
}
|
|
214
|
+
};
|
package/client/chemical.js
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
|
+
const currentScript = document.currentScript;
|
|
2
|
+
|
|
1
3
|
window.chemical = {
|
|
2
4
|
loaded: false,
|
|
3
|
-
transport:
|
|
5
|
+
transport:
|
|
6
|
+
currentScript.dataset.transportStore !== undefined
|
|
7
|
+
? localStorage.getItem("@chemical/transport") ||
|
|
8
|
+
currentScript.dataset.transport ||
|
|
9
|
+
"libcurl"
|
|
10
|
+
: currentScript.dataset.transport || "libcurl",
|
|
4
11
|
wisp:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
currentScript.dataset.wispStore !== undefined
|
|
13
|
+
? localStorage.getItem("@chemical/wisp") ||
|
|
14
|
+
currentScript.dataset.wisp ||
|
|
15
|
+
(location.protocol === "https:" ? "wss" : "ws") +
|
|
16
|
+
"://" +
|
|
17
|
+
location.host +
|
|
18
|
+
"/wisp/"
|
|
19
|
+
: currentScript.dataset.wisp ||
|
|
20
|
+
(location.protocol === "https:" ? "wss" : "ws") +
|
|
21
|
+
"://" +
|
|
22
|
+
location.host +
|
|
23
|
+
"/wisp/",
|
|
10
24
|
};
|
|
11
25
|
|
|
12
26
|
function rammerheadEncode(baseUrl, decode = false) {
|
|
@@ -242,18 +256,18 @@ window.chemical.encode = async function (url, config) {
|
|
|
242
256
|
};
|
|
243
257
|
}
|
|
244
258
|
|
|
245
|
-
if (config.service
|
|
259
|
+
if (config.service === undefined) {
|
|
246
260
|
config.service = defaultService;
|
|
247
261
|
}
|
|
248
262
|
|
|
249
|
-
if (config.autoHttps
|
|
263
|
+
if (config.autoHttps === undefined) {
|
|
250
264
|
config.autoHttps = false;
|
|
251
265
|
}
|
|
252
266
|
|
|
253
267
|
if (url.match(/^https?:\/\//)) {
|
|
254
268
|
return await encodeService(url, config.service);
|
|
255
269
|
} else if (
|
|
256
|
-
config.autoHttps
|
|
270
|
+
config.autoHttps === true &&
|
|
257
271
|
url.includes(".") &&
|
|
258
272
|
!url.includes(" ")
|
|
259
273
|
) {
|
|
@@ -304,43 +318,39 @@ window.chemical.decode = async function (url, config) {
|
|
|
304
318
|
}
|
|
305
319
|
};
|
|
306
320
|
|
|
307
|
-
function
|
|
308
|
-
|
|
309
|
-
for (let entry of entries) {
|
|
310
|
-
if (filter(entry)) {
|
|
311
|
-
matched = true;
|
|
312
|
-
break;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
return !matched;
|
|
316
|
-
}
|
|
321
|
+
window.chemical.setStore = function (key, value) {
|
|
322
|
+
const allowed = ["transport", "wisp", "service", "autoHttps", "searchEngine"];
|
|
317
323
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
if (
|
|
324
|
+
if (allowed.includes(key)) {
|
|
325
|
+
localStorage.setItem("@chemical/" + key, String(value));
|
|
326
|
+
if (key === "transport") {
|
|
327
|
+
window.chemical.setTransport(value);
|
|
328
|
+
}
|
|
329
|
+
if (key === "wisp") {
|
|
330
|
+
window.chemical.setWisp(value);
|
|
331
|
+
}
|
|
332
|
+
window.dispatchEvent(
|
|
333
|
+
new CustomEvent("chemicalStoreChange", {
|
|
334
|
+
detail: { key, value },
|
|
335
|
+
})
|
|
336
|
+
);
|
|
321
337
|
}
|
|
322
|
-
|
|
323
|
-
}
|
|
338
|
+
};
|
|
324
339
|
|
|
325
|
-
window.chemical.
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
340
|
+
window.chemical.getStore = function (key) {
|
|
341
|
+
const value =
|
|
342
|
+
key === "autoHttps"
|
|
343
|
+
? localStorage.getItem("@chemical/" + key) === "true"
|
|
344
|
+
: localStorage.getItem("@chemical/" + key);
|
|
345
|
+
|
|
346
|
+
const defaults = {
|
|
347
|
+
transport: window.chemical.transport,
|
|
348
|
+
wisp: window.chemical.wisp,
|
|
349
|
+
service: "uv",
|
|
350
|
+
autoHttps: false,
|
|
351
|
+
};
|
|
332
352
|
|
|
333
|
-
|
|
334
|
-
return check_whitelist(hostnameWhitelist, (entry) =>
|
|
335
|
-
entry.test(parsedURL.hostname)
|
|
336
|
-
);
|
|
337
|
-
} else if (hostnameBlacklist.length) {
|
|
338
|
-
return checkBlacklist(hostnameBlacklist, (entry) =>
|
|
339
|
-
entry.test(parsedURL.hostname)
|
|
340
|
-
);
|
|
341
|
-
} else {
|
|
342
|
-
return false;
|
|
343
|
-
}
|
|
353
|
+
return value || defaults[key];
|
|
344
354
|
};
|
|
345
355
|
|
|
346
356
|
function getTransport(transport) {
|
|
@@ -355,16 +365,22 @@ function getTransport(transport) {
|
|
|
355
365
|
}
|
|
356
366
|
}
|
|
357
367
|
|
|
358
|
-
window.chemical.setTransport = async function (
|
|
359
|
-
newTransport =
|
|
360
|
-
) {
|
|
368
|
+
window.chemical.setTransport = async function (newTransport) {
|
|
369
|
+
newTransport = newTransport || currentScript.dataset.transport || "libcurl";
|
|
361
370
|
await window.chemical.connection.setTransport(getTransport(newTransport), [
|
|
362
371
|
{ wisp: window.chemical.wisp },
|
|
363
372
|
]);
|
|
364
373
|
window.chemical.transport = newTransport;
|
|
365
374
|
};
|
|
366
375
|
|
|
367
|
-
window.chemical.setWisp = async function (wisp
|
|
376
|
+
window.chemical.setWisp = async function (wisp) {
|
|
377
|
+
wisp =
|
|
378
|
+
wisp ||
|
|
379
|
+
currentScript.dataset.wisp ||
|
|
380
|
+
(location.protocol === "https:" ? "wss" : "ws") +
|
|
381
|
+
"://" +
|
|
382
|
+
location.host +
|
|
383
|
+
"/wisp/";
|
|
368
384
|
await window.chemical.connection.setTransport(
|
|
369
385
|
getTransport(window.chemical.transport),
|
|
370
386
|
[{ wisp: wisp }]
|
|
@@ -450,7 +466,7 @@ if (meteorEnabled) {
|
|
|
450
466
|
window.chemical.connection = new window.BareMux.BareMuxConnection(
|
|
451
467
|
"/baremux/worker.js"
|
|
452
468
|
);
|
|
453
|
-
await window.chemical.setTransport();
|
|
469
|
+
await window.chemical.setTransport(window.chemical.transport);
|
|
454
470
|
setupFetch();
|
|
455
471
|
await registerSW();
|
|
456
472
|
window.chemical.loaded = true;
|
package/index.js
CHANGED
|
@@ -40,19 +40,23 @@ class ChemicalServer {
|
|
|
40
40
|
options = {};
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
if (options.uv
|
|
43
|
+
if (options.uv === undefined) {
|
|
44
44
|
options.uv = true;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
if (options.
|
|
48
|
-
options.
|
|
47
|
+
if (options.experimental === undefined) {
|
|
48
|
+
options.experimental = {};
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
if (options.
|
|
52
|
-
options.
|
|
51
|
+
if (options.experimental.scramjet === undefined) {
|
|
52
|
+
options.experimental.scramjet = false;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
if (options.
|
|
55
|
+
if (options.experimental.meteor === undefined) {
|
|
56
|
+
options.experimental.meteor = false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (options.rammerhead === undefined) {
|
|
56
60
|
options.rammerhead = true;
|
|
57
61
|
}
|
|
58
62
|
|
|
@@ -95,12 +99,12 @@ class ChemicalServer {
|
|
|
95
99
|
"const uvEnabled = " + String(this.options.uv) + ";\n" + chemicalMain;
|
|
96
100
|
chemicalMain =
|
|
97
101
|
"const scramjetEnabled = " +
|
|
98
|
-
String(this.options.scramjet) +
|
|
102
|
+
String(this.options.experimental.scramjet) +
|
|
99
103
|
";\n" +
|
|
100
104
|
chemicalMain;
|
|
101
105
|
chemicalMain =
|
|
102
106
|
"const meteorEnabled = " +
|
|
103
|
-
String(this.options.meteor) +
|
|
107
|
+
String(this.options.experimental.meteor) +
|
|
104
108
|
";\n" +
|
|
105
109
|
chemicalMain;
|
|
106
110
|
chemicalMain =
|
|
@@ -108,20 +112,6 @@ class ChemicalServer {
|
|
|
108
112
|
String(this.options.rammerhead) +
|
|
109
113
|
";\n" +
|
|
110
114
|
chemicalMain;
|
|
111
|
-
chemicalMain =
|
|
112
|
-
"const hostnameBlacklist = [" +
|
|
113
|
-
(this.options.hostname_blacklist
|
|
114
|
-
? this.options.hostname_blacklist.join(", ")
|
|
115
|
-
: "") +
|
|
116
|
-
"];\n" +
|
|
117
|
-
chemicalMain;
|
|
118
|
-
chemicalMain =
|
|
119
|
-
"const hostnameWhitelist = [" +
|
|
120
|
-
(this.options.hostname_whitelist
|
|
121
|
-
? this.options.hostname_whitelist.join(", ")
|
|
122
|
-
: "") +
|
|
123
|
-
"];\n" +
|
|
124
|
-
chemicalMain;
|
|
125
115
|
|
|
126
116
|
chemicalMain = "(async () => {\n" + chemicalMain + "\n})();";
|
|
127
117
|
|
|
@@ -138,12 +128,12 @@ class ChemicalServer {
|
|
|
138
128
|
"const uvEnabled = " + String(this.options.uv) + ";\n" + chemicalSW;
|
|
139
129
|
chemicalSW =
|
|
140
130
|
"const scramjetEnabled = " +
|
|
141
|
-
String(this.options.scramjet) +
|
|
131
|
+
String(this.options.experimental.scramjet) +
|
|
142
132
|
";\n" +
|
|
143
133
|
chemicalSW;
|
|
144
134
|
chemicalSW =
|
|
145
135
|
"const meteorEnabled = " +
|
|
146
|
-
String(this.options.meteor) +
|
|
136
|
+
String(this.options.experimental.meteor) +
|
|
147
137
|
";\n" +
|
|
148
138
|
chemicalSW;
|
|
149
139
|
chemicalSW =
|
|
@@ -163,14 +153,14 @@ class ChemicalServer {
|
|
|
163
153
|
this.app.use("/uv/", express.static(resolve(__dirname, "config/uv")));
|
|
164
154
|
this.app.use("/uv/", express.static(uvPath));
|
|
165
155
|
}
|
|
166
|
-
if (this.options.scramjet) {
|
|
156
|
+
if (this.options.experimental.scramjet) {
|
|
167
157
|
this.app.use(
|
|
168
158
|
"/scramjet/",
|
|
169
159
|
express.static(resolve(__dirname, "config/scramjet"))
|
|
170
160
|
);
|
|
171
161
|
this.app.use("/scramjet/", express.static(scramjetPath));
|
|
172
162
|
}
|
|
173
|
-
if (this.options.meteor) {
|
|
163
|
+
if (this.options.experimental.meteor) {
|
|
174
164
|
this.app.use(
|
|
175
165
|
"/meteor/",
|
|
176
166
|
express.static(resolve(__dirname, "config/meteor"))
|
|
@@ -186,11 +176,10 @@ class ChemicalServer {
|
|
|
186
176
|
});
|
|
187
177
|
this.server.on("upgrade", (req, socket, head) => {
|
|
188
178
|
if (req.url && req.url.endsWith("/wisp/")) {
|
|
189
|
-
if (this.options.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
wisp.options.hostname_whitelist = this.options.hostname_whitelist;
|
|
179
|
+
if (this.options.wispOptions) {
|
|
180
|
+
for (let option in this.options.wispOptions) {
|
|
181
|
+
wisp.options[option] = this.options.wispOptions[option];
|
|
182
|
+
}
|
|
194
183
|
}
|
|
195
184
|
wisp.routeRequest(req, socket, head);
|
|
196
185
|
} else if (this.options.rammerhead && shouldRouteRh(req)) {
|
|
@@ -217,19 +206,23 @@ const ChemicalVitePlugin = (options) => ({
|
|
|
217
206
|
options = {};
|
|
218
207
|
}
|
|
219
208
|
|
|
220
|
-
if (options.uv
|
|
209
|
+
if (options.uv === undefined) {
|
|
221
210
|
options.uv = true;
|
|
222
211
|
}
|
|
223
212
|
|
|
224
|
-
if (options.
|
|
225
|
-
options.
|
|
213
|
+
if (options.experimental === undefined) {
|
|
214
|
+
options.experimental = {};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (options.experimental.scramjet === undefined) {
|
|
218
|
+
options.experimental.scramjet = false;
|
|
226
219
|
}
|
|
227
220
|
|
|
228
|
-
if (options.meteor
|
|
229
|
-
options.meteor =
|
|
221
|
+
if (options.experimental.meteor === undefined) {
|
|
222
|
+
options.experimental.meteor = false;
|
|
230
223
|
}
|
|
231
224
|
|
|
232
|
-
if (options.rammerhead
|
|
225
|
+
if (options.rammerhead === undefined) {
|
|
233
226
|
options.rammerhead = true;
|
|
234
227
|
}
|
|
235
228
|
|
|
@@ -262,12 +255,12 @@ const ChemicalVitePlugin = (options) => ({
|
|
|
262
255
|
"const uvEnabled = " + String(options.uv) + ";\n" + chemicalMain;
|
|
263
256
|
chemicalMain =
|
|
264
257
|
"const scramjetEnabled = " +
|
|
265
|
-
String(options.scramjet) +
|
|
258
|
+
String(options.experimental.scramjet) +
|
|
266
259
|
";\n" +
|
|
267
260
|
chemicalMain;
|
|
268
261
|
chemicalMain =
|
|
269
262
|
"const meteorEnabled = " +
|
|
270
|
-
String(options.meteor) +
|
|
263
|
+
String(options.experimental.meteor) +
|
|
271
264
|
";\n" +
|
|
272
265
|
chemicalMain;
|
|
273
266
|
chemicalMain =
|
|
@@ -275,20 +268,6 @@ const ChemicalVitePlugin = (options) => ({
|
|
|
275
268
|
String(options.rammerhead) +
|
|
276
269
|
";\n" +
|
|
277
270
|
chemicalMain;
|
|
278
|
-
chemicalMain =
|
|
279
|
-
"const hostnameBlacklist = [" +
|
|
280
|
-
(options.hostname_blacklist
|
|
281
|
-
? options.hostname_blacklist.join(", ")
|
|
282
|
-
: "") +
|
|
283
|
-
"];\n" +
|
|
284
|
-
chemicalMain;
|
|
285
|
-
chemicalMain =
|
|
286
|
-
"const hostnameWhitelist = [" +
|
|
287
|
-
(options.hostname_whitelist
|
|
288
|
-
? options.hostname_whitelist.join(", ")
|
|
289
|
-
: "") +
|
|
290
|
-
"];\n" +
|
|
291
|
-
chemicalMain;
|
|
292
271
|
|
|
293
272
|
chemicalMain = "(async () => {\n" + chemicalMain + "\n})();";
|
|
294
273
|
|
|
@@ -305,11 +284,14 @@ const ChemicalVitePlugin = (options) => ({
|
|
|
305
284
|
"const uvEnabled = " + String(options.uv) + ";\n" + chemicalSW;
|
|
306
285
|
chemicalSW =
|
|
307
286
|
"const scramjetEnabled = " +
|
|
308
|
-
String(options.scramjet) +
|
|
287
|
+
String(options.experimental.scramjet) +
|
|
309
288
|
";\n" +
|
|
310
289
|
chemicalSW;
|
|
311
290
|
chemicalSW =
|
|
312
|
-
"const meteorEnabled = " +
|
|
291
|
+
"const meteorEnabled = " +
|
|
292
|
+
String(options.experimental.meteor) +
|
|
293
|
+
";\n" +
|
|
294
|
+
chemicalSW;
|
|
313
295
|
chemicalSW =
|
|
314
296
|
"const rammerheadEnabled = " +
|
|
315
297
|
String(options.rammerhead) +
|
|
@@ -327,14 +309,14 @@ const ChemicalVitePlugin = (options) => ({
|
|
|
327
309
|
app.use("/uv/", express.static(resolve(__dirname, "config/uv")));
|
|
328
310
|
app.use("/uv/", express.static(uvPath));
|
|
329
311
|
}
|
|
330
|
-
if (options.scramjet) {
|
|
312
|
+
if (options.experimental.scramjet) {
|
|
331
313
|
app.use(
|
|
332
314
|
"/scramjet/",
|
|
333
315
|
express.static(resolve(__dirname, "config/scramjet"))
|
|
334
316
|
);
|
|
335
317
|
app.use("/scramjet/", express.static(scramjetPath));
|
|
336
318
|
}
|
|
337
|
-
if (options.meteor) {
|
|
319
|
+
if (options.experimental.meteor) {
|
|
338
320
|
app.use("/meteor/", express.static(resolve(__dirname, "config/meteor")));
|
|
339
321
|
app.use("/meteor/", express.static(meteorPath));
|
|
340
322
|
}
|
|
@@ -357,11 +339,10 @@ const ChemicalVitePlugin = (options) => ({
|
|
|
357
339
|
|
|
358
340
|
server.httpServer.on("upgrade", (req, socket, head) => {
|
|
359
341
|
if (req.url && req.url.endsWith("/wisp/")) {
|
|
360
|
-
if (options.
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
wisp.options.hostname_whitelist = options.hostname_whitelist;
|
|
342
|
+
if (options.wispOptions) {
|
|
343
|
+
for (let option in options.wispOptions) {
|
|
344
|
+
wisp.options[option] = options.wispOptions[option];
|
|
345
|
+
}
|
|
365
346
|
}
|
|
366
347
|
wisp.routeRequest(req, socket, head);
|
|
367
348
|
} else if (options.rammerhead && shouldRouteRh(req)) {
|
|
@@ -386,7 +367,7 @@ class ChemicalBuild {
|
|
|
386
367
|
options = {};
|
|
387
368
|
}
|
|
388
369
|
|
|
389
|
-
if (options.path
|
|
370
|
+
if (options.path === undefined) {
|
|
390
371
|
options.path = "dist";
|
|
391
372
|
}
|
|
392
373
|
|
|
@@ -398,19 +379,23 @@ class ChemicalBuild {
|
|
|
398
379
|
options.path = options.path.slice(0, -1);
|
|
399
380
|
}
|
|
400
381
|
|
|
401
|
-
if (options.uv
|
|
382
|
+
if (options.uv === undefined) {
|
|
402
383
|
options.uv = true;
|
|
403
384
|
}
|
|
404
385
|
|
|
405
|
-
if (options.
|
|
406
|
-
options.
|
|
386
|
+
if (options.experimental === undefined) {
|
|
387
|
+
options.experimental = {};
|
|
407
388
|
}
|
|
408
389
|
|
|
409
|
-
if (options.
|
|
410
|
-
options.
|
|
390
|
+
if (options.experimental.scramjet === undefined) {
|
|
391
|
+
options.experimental.scramjet = false;
|
|
411
392
|
}
|
|
412
393
|
|
|
413
|
-
if (options.
|
|
394
|
+
if (options.experimental.meteor === undefined) {
|
|
395
|
+
options.experimental.meteor = false;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
if (options.rammerhead === undefined) {
|
|
414
399
|
options.rammerhead = true;
|
|
415
400
|
}
|
|
416
401
|
|
|
@@ -453,12 +438,12 @@ class ChemicalBuild {
|
|
|
453
438
|
"const uvEnabled = " + String(this.options.uv) + ";\n" + chemicalMain;
|
|
454
439
|
chemicalMain =
|
|
455
440
|
"const scramjetEnabled = " +
|
|
456
|
-
String(this.options.scramjet) +
|
|
441
|
+
String(this.options.experimental.scramjet) +
|
|
457
442
|
";\n" +
|
|
458
443
|
chemicalMain;
|
|
459
444
|
chemicalMain =
|
|
460
445
|
"const meteorEnabled = " +
|
|
461
|
-
String(this.options.meteor) +
|
|
446
|
+
String(this.options.experimental.meteor) +
|
|
462
447
|
";\n" +
|
|
463
448
|
chemicalMain;
|
|
464
449
|
chemicalMain =
|
|
@@ -466,20 +451,6 @@ class ChemicalBuild {
|
|
|
466
451
|
String(this.options.rammerhead) +
|
|
467
452
|
";\n" +
|
|
468
453
|
chemicalMain;
|
|
469
|
-
chemicalMain =
|
|
470
|
-
"const hostnameBlacklist = [" +
|
|
471
|
-
(this.options.hostname_blacklist
|
|
472
|
-
? this.options.hostname_blacklist.join(", ")
|
|
473
|
-
: "") +
|
|
474
|
-
"];\n" +
|
|
475
|
-
chemicalMain;
|
|
476
|
-
chemicalMain =
|
|
477
|
-
"const hostnameWhitelist = [" +
|
|
478
|
-
(this.options.hostname_whitelist
|
|
479
|
-
? this.options.hostname_whitelist.join(", ")
|
|
480
|
-
: "") +
|
|
481
|
-
"];\n" +
|
|
482
|
-
chemicalMain;
|
|
483
454
|
|
|
484
455
|
chemicalMain = "(async () => {\n" + chemicalMain + "\n})();";
|
|
485
456
|
|
|
@@ -494,12 +465,12 @@ class ChemicalBuild {
|
|
|
494
465
|
"const uvEnabled = " + String(this.options.uv) + ";\n" + chemicalSW;
|
|
495
466
|
chemicalSW =
|
|
496
467
|
"const scramjetEnabled = " +
|
|
497
|
-
String(this.options.scramjet) +
|
|
468
|
+
String(this.options.experimental.scramjet) +
|
|
498
469
|
";\n" +
|
|
499
470
|
chemicalSW;
|
|
500
471
|
chemicalSW =
|
|
501
472
|
"const meteorEnabled = " +
|
|
502
|
-
String(this.options.meteor) +
|
|
473
|
+
String(this.options.experimental.meteor) +
|
|
503
474
|
";\n" +
|
|
504
475
|
chemicalSW;
|
|
505
476
|
chemicalSW =
|
|
@@ -527,7 +498,7 @@ class ChemicalBuild {
|
|
|
527
498
|
resolve(this.options.path, "uv/uv.config.js")
|
|
528
499
|
);
|
|
529
500
|
}
|
|
530
|
-
if (this.options.scramjet) {
|
|
501
|
+
if (this.options.experimental.scramjet) {
|
|
531
502
|
cpSync(scramjetPath, resolve(this.options.path, "scramjet"), {
|
|
532
503
|
recursive: true,
|
|
533
504
|
});
|
|
@@ -536,7 +507,7 @@ class ChemicalBuild {
|
|
|
536
507
|
resolve(this.options.path, "scramjet/scramjet.config.js")
|
|
537
508
|
);
|
|
538
509
|
}
|
|
539
|
-
if (this.options.meteor) {
|
|
510
|
+
if (this.options.experimental.meteor) {
|
|
540
511
|
cpSync(meteorPath, resolve(this.options.path, "meteor"), {
|
|
541
512
|
recursive: true,
|
|
542
513
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chemicaljs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Easily create your own web proxy with no experience required.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@mercuryworkshop/epoxy-transport": "^2.1.11",
|
|
19
19
|
"@mercuryworkshop/libcurl-transport": "^1.3.10",
|
|
20
20
|
"@mercuryworkshop/scramjet": "^1.0.2",
|
|
21
|
-
"@mercuryworkshop/wisp-js": "^0.3.
|
|
21
|
+
"@mercuryworkshop/wisp-js": "^0.3.1",
|
|
22
22
|
"@rubynetwork/rammerhead": "^1.3.2",
|
|
23
23
|
"@titaniumnetwork-dev/ultraviolet": "^3.2.7",
|
|
24
24
|
"express": "^4.21.0",
|