chemicaljs 1.6.0 → 1.6.2
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/README.md +3 -3
- package/examples/example/index.js +1 -1
- package/examples/example/package-lock.json +4 -4
- package/examples/example/package.json +1 -1
- package/examples/{example build/build.js → example-build/build.js} +3 -1
- package/examples/{example build/index.js → example-build/index.js} +1 -1
- package/examples/{example build/package-lock.json → example-build/package-lock.json} +6 -6
- package/examples/{example build/package.json → example-build/package.json} +1 -1
- package/examples/example-components/index.js +1 -1
- package/examples/example-components/package-lock.json +4 -4
- package/examples/example-components/package.json +1 -1
- package/examples/example-styled/index.js +1 -1
- package/examples/example-styled/package-lock.json +4 -4
- package/examples/example-styled/package.json +1 -1
- package/examples/example-vite/index.js +1 -1
- package/examples/example-vite/package-lock.json +12 -12
- package/examples/example-vite/package.json +3 -3
- package/index.js +43 -36
- package/package.json +1 -1
- package/update.bash +3 -0
- /package/examples/{example build → example-build}/README.md +0 -0
- /package/examples/{example build → example-build}/public/index.html +0 -0
package/README.md
CHANGED
|
@@ -51,10 +51,10 @@ chemical.app.get("/", function(req, res){
|
|
|
51
51
|
});
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
4. Use `chemical.
|
|
54
|
+
4. Use `chemical.listen` on a port of your choosing.
|
|
55
55
|
|
|
56
56
|
```js
|
|
57
|
-
chemical.
|
|
57
|
+
chemical.listen(3000);
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
Below is an example of a simple backend. This example will setup Chemical and serve the "public" folder along with the `index.html` file as `/` and `.html` files without the extension.
|
|
@@ -71,7 +71,7 @@ chemical.app.use(express.static("public", {
|
|
|
71
71
|
extensions: ["html"]
|
|
72
72
|
}));
|
|
73
73
|
|
|
74
|
-
chemical.
|
|
74
|
+
chemical.listen(port, () => {
|
|
75
75
|
console.log(`Chemical demo listening on port ${port}`);
|
|
76
76
|
});
|
|
77
77
|
```
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"chemicaljs": "^1.
|
|
12
|
+
"chemicaljs": "^1.6.1",
|
|
13
13
|
"express": "^4.19.2"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
@@ -1167,9 +1167,9 @@
|
|
|
1167
1167
|
}
|
|
1168
1168
|
},
|
|
1169
1169
|
"node_modules/chemicaljs": {
|
|
1170
|
-
"version": "1.
|
|
1171
|
-
"resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.
|
|
1172
|
-
"integrity": "sha512-
|
|
1170
|
+
"version": "1.6.1",
|
|
1171
|
+
"resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.1.tgz",
|
|
1172
|
+
"integrity": "sha512-iolcUgXd4eHC9vB6/7CMXIOpRNEEErO5SMPCv54h0wgPdnoOP/pfZqseYgDfyMl398zKDCWSC5x8GPhLaqNK4g==",
|
|
1173
1173
|
"dependencies": {
|
|
1174
1174
|
"@mercuryworkshop/bare-mux": "^2.0.4",
|
|
1175
1175
|
"@mercuryworkshop/epoxy-transport": "^2.1.3",
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "chemical-example",
|
|
2
|
+
"name": "chemical-example-build",
|
|
3
3
|
"version": "1.0.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
|
-
"name": "chemical-example",
|
|
8
|
+
"name": "chemical-example-build",
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"chemicaljs": "^1.
|
|
12
|
+
"chemicaljs": "^1.6.1",
|
|
13
13
|
"express": "^4.19.2"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
@@ -1167,9 +1167,9 @@
|
|
|
1167
1167
|
}
|
|
1168
1168
|
},
|
|
1169
1169
|
"node_modules/chemicaljs": {
|
|
1170
|
-
"version": "1.
|
|
1171
|
-
"resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.
|
|
1172
|
-
"integrity": "sha512-
|
|
1170
|
+
"version": "1.6.1",
|
|
1171
|
+
"resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.1.tgz",
|
|
1172
|
+
"integrity": "sha512-iolcUgXd4eHC9vB6/7CMXIOpRNEEErO5SMPCv54h0wgPdnoOP/pfZqseYgDfyMl398zKDCWSC5x8GPhLaqNK4g==",
|
|
1173
1173
|
"dependencies": {
|
|
1174
1174
|
"@mercuryworkshop/bare-mux": "^2.0.4",
|
|
1175
1175
|
"@mercuryworkshop/epoxy-transport": "^2.1.3",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"chemicaljs": "^1.
|
|
12
|
+
"chemicaljs": "^1.6.1",
|
|
13
13
|
"express": "^4.19.2"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
@@ -1167,9 +1167,9 @@
|
|
|
1167
1167
|
}
|
|
1168
1168
|
},
|
|
1169
1169
|
"node_modules/chemicaljs": {
|
|
1170
|
-
"version": "1.
|
|
1171
|
-
"resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.
|
|
1172
|
-
"integrity": "sha512-
|
|
1170
|
+
"version": "1.6.1",
|
|
1171
|
+
"resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.1.tgz",
|
|
1172
|
+
"integrity": "sha512-iolcUgXd4eHC9vB6/7CMXIOpRNEEErO5SMPCv54h0wgPdnoOP/pfZqseYgDfyMl398zKDCWSC5x8GPhLaqNK4g==",
|
|
1173
1173
|
"dependencies": {
|
|
1174
1174
|
"@mercuryworkshop/bare-mux": "^2.0.4",
|
|
1175
1175
|
"@mercuryworkshop/epoxy-transport": "^2.1.3",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"chemicaljs": "^1.
|
|
12
|
+
"chemicaljs": "^1.6.1",
|
|
13
13
|
"express": "^4.19.2"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
@@ -1167,9 +1167,9 @@
|
|
|
1167
1167
|
}
|
|
1168
1168
|
},
|
|
1169
1169
|
"node_modules/chemicaljs": {
|
|
1170
|
-
"version": "1.
|
|
1171
|
-
"resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.
|
|
1172
|
-
"integrity": "sha512-
|
|
1170
|
+
"version": "1.6.1",
|
|
1171
|
+
"resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.1.tgz",
|
|
1172
|
+
"integrity": "sha512-iolcUgXd4eHC9vB6/7CMXIOpRNEEErO5SMPCv54h0wgPdnoOP/pfZqseYgDfyMl398zKDCWSC5x8GPhLaqNK4g==",
|
|
1173
1173
|
"dependencies": {
|
|
1174
1174
|
"@mercuryworkshop/bare-mux": "^2.0.4",
|
|
1175
1175
|
"@mercuryworkshop/epoxy-transport": "^2.1.3",
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
"": {
|
|
7
7
|
"name": "chemical-example-vite",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"chemicaljs": "^1.
|
|
9
|
+
"chemicaljs": "^1.6.1",
|
|
10
10
|
"express": "^4.19.2",
|
|
11
|
-
"preact": "^10.23.
|
|
11
|
+
"preact": "^10.23.1"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@preact/preset-vite": "^2.9.0",
|
|
15
|
-
"vite": "^5.3.
|
|
15
|
+
"vite": "^5.3.5"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"node_modules/@ampproject/remapping": {
|
|
@@ -1730,9 +1730,9 @@
|
|
|
1730
1730
|
}
|
|
1731
1731
|
},
|
|
1732
1732
|
"node_modules/chemicaljs": {
|
|
1733
|
-
"version": "1.
|
|
1734
|
-
"resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.
|
|
1735
|
-
"integrity": "sha512-
|
|
1733
|
+
"version": "1.6.1",
|
|
1734
|
+
"resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.1.tgz",
|
|
1735
|
+
"integrity": "sha512-iolcUgXd4eHC9vB6/7CMXIOpRNEEErO5SMPCv54h0wgPdnoOP/pfZqseYgDfyMl398zKDCWSC5x8GPhLaqNK4g==",
|
|
1736
1736
|
"dependencies": {
|
|
1737
1737
|
"@mercuryworkshop/bare-mux": "^2.0.4",
|
|
1738
1738
|
"@mercuryworkshop/epoxy-transport": "^2.1.3",
|
|
@@ -3615,9 +3615,9 @@
|
|
|
3615
3615
|
}
|
|
3616
3616
|
},
|
|
3617
3617
|
"node_modules/preact": {
|
|
3618
|
-
"version": "10.23.
|
|
3619
|
-
"resolved": "https://registry.npmjs.org/preact/-/preact-10.23.
|
|
3620
|
-
"integrity": "sha512-
|
|
3618
|
+
"version": "10.23.1",
|
|
3619
|
+
"resolved": "https://registry.npmjs.org/preact/-/preact-10.23.1.tgz",
|
|
3620
|
+
"integrity": "sha512-O5UdRsNh4vdZaTieWe3XOgSpdMAmkIYBCT3VhQDlKrzyCm8lUYsk0fmVEvoQQifoOjFRTaHZO69ylrzTW2BH+A==",
|
|
3621
3621
|
"funding": {
|
|
3622
3622
|
"type": "opencollective",
|
|
3623
3623
|
"url": "https://opencollective.com/preact"
|
|
@@ -4713,9 +4713,9 @@
|
|
|
4713
4713
|
}
|
|
4714
4714
|
},
|
|
4715
4715
|
"node_modules/vite": {
|
|
4716
|
-
"version": "5.3.
|
|
4717
|
-
"resolved": "https://registry.npmjs.org/vite/-/vite-5.3.
|
|
4718
|
-
"integrity": "sha512-
|
|
4716
|
+
"version": "5.3.5",
|
|
4717
|
+
"resolved": "https://registry.npmjs.org/vite/-/vite-5.3.5.tgz",
|
|
4718
|
+
"integrity": "sha512-MdjglKR6AQXQb9JGiS7Rc2wC6uMjcm7Go/NHNO63EwiJXfuk9PgqiP/n5IDJCziMkfw9n4Ubp7lttNwz+8ZVKA==",
|
|
4719
4719
|
"dev": true,
|
|
4720
4720
|
"dependencies": {
|
|
4721
4721
|
"esbuild": "^0.21.3",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"build": "vite build"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"chemicaljs": "^1.
|
|
11
|
+
"chemicaljs": "^1.6.1",
|
|
12
12
|
"express": "^4.19.2",
|
|
13
|
-
"preact": "^10.23.
|
|
13
|
+
"preact": "^10.23.1"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@preact/preset-vite": "^2.9.0",
|
|
17
|
-
"vite": "^5.3.
|
|
17
|
+
"vite": "^5.3.5"
|
|
18
18
|
}
|
|
19
19
|
}
|
package/index.js
CHANGED
|
@@ -38,6 +38,13 @@ class ChemicalServer {
|
|
|
38
38
|
options.rammerhead = true;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
this.options = options;
|
|
42
|
+
|
|
43
|
+
this.app = express();
|
|
44
|
+
}
|
|
45
|
+
listen(port, callback) {
|
|
46
|
+
const server = createServer();
|
|
47
|
+
|
|
41
48
|
const rh = createRammerhead()
|
|
42
49
|
|
|
43
50
|
const rammerheadScopes = [
|
|
@@ -75,14 +82,12 @@ class ChemicalServer {
|
|
|
75
82
|
rh.emit("upgrade", req, socket, head)
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
this.
|
|
79
|
-
this.app = express();
|
|
80
|
-
this.app.get("/chemical.js", async function (req, res) {
|
|
85
|
+
this.app.get("/chemical.js", async (req, res) => {
|
|
81
86
|
let chemicalMain = await readFileSync(resolve(__dirname, "client/chemical.js"), "utf8");
|
|
82
87
|
|
|
83
|
-
if (options.default) {
|
|
84
|
-
if (["uv", "rammerhead", "scramjet"].includes(options.default)) {
|
|
85
|
-
chemicalMain = `const defaultService = "${options.default}";\n\n` + chemicalMain
|
|
88
|
+
if (this.options.default) {
|
|
89
|
+
if (["uv", "rammerhead", "scramjet"].includes(this.options.default)) {
|
|
90
|
+
chemicalMain = `const defaultService = "${this.options.default}";\n\n` + chemicalMain
|
|
86
91
|
} else {
|
|
87
92
|
chemicalMain = `const defaultService = "uv";\n\n` + chemicalMain
|
|
88
93
|
console.error("Error: Chemical default option invalid.")
|
|
@@ -91,19 +96,19 @@ class ChemicalServer {
|
|
|
91
96
|
chemicalMain = `const defaultService = "uv";\n\n` + chemicalMain;
|
|
92
97
|
}
|
|
93
98
|
|
|
94
|
-
chemicalMain = "const uvEnabled = " + String(options.uv) + ";\n" + chemicalMain
|
|
95
|
-
chemicalMain = "const scramjetEnabled = " + String(options.scramjet) + ";\n" + chemicalMain
|
|
96
|
-
chemicalMain = "const rammerheadEnabled = " + String(options.rammerhead) + ";\n" + chemicalMain
|
|
99
|
+
chemicalMain = "const uvEnabled = " + String(this.options.uv) + ";\n" + chemicalMain
|
|
100
|
+
chemicalMain = "const scramjetEnabled = " + String(this.options.scramjet) + ";\n" + chemicalMain
|
|
101
|
+
chemicalMain = "const rammerheadEnabled = " + String(this.options.rammerhead) + ";\n" + chemicalMain
|
|
97
102
|
|
|
98
103
|
res.type("application/javascript");
|
|
99
104
|
return res.send(chemicalMain);
|
|
100
105
|
});
|
|
101
|
-
this.app.get("/chemical.sw.js", async
|
|
106
|
+
this.app.get("/chemical.sw.js", async (req, res) => {
|
|
102
107
|
let chemicalSW = await readFileSync(resolve(__dirname, "client/chemical.sw.js"), "utf8");
|
|
103
108
|
|
|
104
|
-
chemicalSW = "const uvEnabled = " + String(options.uv) + ";\n" + chemicalSW
|
|
105
|
-
chemicalSW = "const scramjetEnabled = " + String(options.scramjet) + ";\n" + chemicalSW
|
|
106
|
-
chemicalSW = "const rammerheadEnabled = " + String(options.rammerhead) + ";\n" + chemicalSW
|
|
109
|
+
chemicalSW = "const uvEnabled = " + String(this.options.uv) + ";\n" + chemicalSW
|
|
110
|
+
chemicalSW = "const scramjetEnabled = " + String(this.options.scramjet) + ";\n" + chemicalSW
|
|
111
|
+
chemicalSW = "const rammerheadEnabled = " + String(this.options.rammerhead) + ";\n" + chemicalSW
|
|
107
112
|
|
|
108
113
|
res.type("application/javascript");
|
|
109
114
|
return res.send(chemicalSW);
|
|
@@ -112,36 +117,38 @@ class ChemicalServer {
|
|
|
112
117
|
this.app.use("/baremux/", express.static(baremuxPath));
|
|
113
118
|
this.app.use("/libcurl/", express.static(libcurlPath));
|
|
114
119
|
this.app.use("/epoxy/", express.static(epoxyPath));
|
|
115
|
-
if (options.uv) {
|
|
120
|
+
if (this.options.uv) {
|
|
116
121
|
this.app.use("/uv/", express.static(resolve(__dirname, "config/uv")));
|
|
117
122
|
this.app.use("/uv/", express.static(uvPath));
|
|
118
123
|
}
|
|
119
|
-
if (options.scramjet) {
|
|
124
|
+
if (this.options.scramjet) {
|
|
120
125
|
this.app.use("/scramjet/", express.static(resolve(__dirname, "config/scramjet")));
|
|
121
126
|
this.app.use("/scramjet/", express.static(scramjetPath));
|
|
122
127
|
}
|
|
123
|
-
|
|
124
|
-
if (options.rammerhead && shouldRouteRh(req)) {
|
|
128
|
+
server.on("request", (req, res) => {
|
|
129
|
+
if (this.options.rammerhead && shouldRouteRh(req)) {
|
|
125
130
|
routeRhRequest(req, res);
|
|
126
131
|
} else {
|
|
127
132
|
this.app(req, res);
|
|
128
133
|
}
|
|
129
134
|
});
|
|
130
|
-
|
|
135
|
+
server.on("upgrade", (req, socket, head) => {
|
|
131
136
|
if (req.url && req.url.endsWith("/wisp/")) {
|
|
132
|
-
if (options.hostname_blacklist) {
|
|
133
|
-
wisp.options.hostname_blacklist = options.hostname_blacklist
|
|
137
|
+
if (this.options.hostname_blacklist) {
|
|
138
|
+
wisp.this.options.hostname_blacklist = this.options.hostname_blacklist
|
|
134
139
|
}
|
|
135
|
-
if (options.hostname_whitelist) {
|
|
136
|
-
wisp.options.hostname_whitelist = options.hostname_whitelist
|
|
140
|
+
if (this.options.hostname_whitelist) {
|
|
141
|
+
wisp.this.options.hostname_whitelist = this.options.hostname_whitelist
|
|
137
142
|
}
|
|
138
143
|
wisp.routeRequest(req, socket, head);
|
|
139
|
-
} else if (options.rammerhead && shouldRouteRh(req)) {
|
|
144
|
+
} else if (this.options.rammerhead && shouldRouteRh(req)) {
|
|
140
145
|
routeRhUpgrade(req, socket, head);
|
|
141
146
|
} else {
|
|
142
147
|
socket.end();
|
|
143
148
|
}
|
|
144
149
|
});
|
|
150
|
+
|
|
151
|
+
server.listen(port, callback)
|
|
145
152
|
}
|
|
146
153
|
}
|
|
147
154
|
|
|
@@ -325,11 +332,11 @@ class ChemicalBuild {
|
|
|
325
332
|
this.options = options;
|
|
326
333
|
}
|
|
327
334
|
async write(deletePath = false) {
|
|
328
|
-
if (!existsSync(resolve(
|
|
329
|
-
mkdirSync(resolve(
|
|
335
|
+
if (!existsSync(resolve(this.options.path))) {
|
|
336
|
+
mkdirSync(resolve(this.options.path), { recursive: true });
|
|
330
337
|
} else {
|
|
331
338
|
if (deletePath) {
|
|
332
|
-
readdirSync(resolve(
|
|
339
|
+
readdirSync(resolve(this.options.path)).forEach((file) => rmSync(resolve(this.options.path, file), { recursive: true }));
|
|
333
340
|
}
|
|
334
341
|
}
|
|
335
342
|
|
|
@@ -350,7 +357,7 @@ class ChemicalBuild {
|
|
|
350
357
|
chemicalMain = "const scramjetEnabled = " + String(this.options.scramjet) + ";\n" + chemicalMain
|
|
351
358
|
chemicalMain = "const rammerheadEnabled = " + String(this.options.rammerhead) + ";\n" + chemicalMain
|
|
352
359
|
|
|
353
|
-
writeFileSync(resolve(
|
|
360
|
+
writeFileSync(resolve(this.options.path, "chemical.js"), chemicalMain);
|
|
354
361
|
|
|
355
362
|
let chemicalSW = await readFileSync(resolve(__dirname, "client/chemical.sw.js"), "utf8");
|
|
356
363
|
|
|
@@ -358,19 +365,19 @@ class ChemicalBuild {
|
|
|
358
365
|
chemicalSW = "const scramjetEnabled = " + String(this.options.scramjet) + ";\n" + chemicalSW
|
|
359
366
|
chemicalSW = "const rammerheadEnabled = " + String(this.options.rammerhead) + ";\n" + chemicalSW
|
|
360
367
|
|
|
361
|
-
writeFileSync(resolve(
|
|
368
|
+
writeFileSync(resolve(this.options.path, "chemical.sw.js"), chemicalSW);
|
|
362
369
|
|
|
363
|
-
cpSync(baremuxPath, resolve(
|
|
364
|
-
cpSync(libcurlPath, resolve(
|
|
365
|
-
cpSync(epoxyPath, resolve(
|
|
366
|
-
cpSync(libcurlPath, resolve(
|
|
370
|
+
cpSync(baremuxPath, resolve(this.options.path, "baremux"), { recursive: true });
|
|
371
|
+
cpSync(libcurlPath, resolve(this.options.path, "libcurl"), { recursive: true });
|
|
372
|
+
cpSync(epoxyPath, resolve(this.options.path, "epoxy"), { recursive: true });
|
|
373
|
+
cpSync(libcurlPath, resolve(this.options.path, "libcurl"), { recursive: true });
|
|
367
374
|
if (this.options.uv) {
|
|
368
|
-
cpSync(uvPath, resolve(
|
|
369
|
-
copyFileSync(resolve(__dirname, "config/uv/uv.config.js"), resolve(
|
|
375
|
+
cpSync(uvPath, resolve(this.options.path, "uv"), { recursive: true });
|
|
376
|
+
copyFileSync(resolve(__dirname, "config/uv/uv.config.js"), resolve(this.options.path, "uv/uv.config.js"));
|
|
370
377
|
}
|
|
371
378
|
if (this.options.scramjet) {
|
|
372
|
-
cpSync(scramjetPath, resolve(
|
|
373
|
-
copyFileSync(resolve(__dirname, "config/scramjet/scramjet.config.js"), resolve(
|
|
379
|
+
cpSync(scramjetPath, resolve(this.options.path, "scramjet"), { recursive: true });
|
|
380
|
+
copyFileSync(resolve(__dirname, "config/scramjet/scramjet.config.js"), resolve(this.options.path, "scramjet/scramjet.config.js"));
|
|
374
381
|
}
|
|
375
382
|
}
|
|
376
383
|
}
|
package/package.json
CHANGED
package/update.bash
CHANGED
|
File without changes
|
|
File without changes
|