frontfire 0.1.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/.idea/infrontjs-frontfire.iml +8 -0
- package/.idea/modules.xml +8 -0
- package/.idea/php.xml +18 -0
- package/.idea/vcs.xml +6 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/package.json +25 -0
- package/src/index.js +102 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="inheritedJdk" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
</module>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/infrontjs-frontfire.iml" filepath="$PROJECT_DIR$/.idea/infrontjs-frontfire.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/php.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="MessDetectorOptionsConfiguration">
|
|
4
|
+
<option name="transferred" value="true" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="PHPCSFixerOptionsConfiguration">
|
|
7
|
+
<option name="transferred" value="true" />
|
|
8
|
+
</component>
|
|
9
|
+
<component name="PHPCodeSnifferOptionsConfiguration">
|
|
10
|
+
<option name="transferred" value="true" />
|
|
11
|
+
</component>
|
|
12
|
+
<component name="PhpStanOptionsConfiguration">
|
|
13
|
+
<option name="transferred" value="true" />
|
|
14
|
+
</component>
|
|
15
|
+
<component name="PsalmOptionsConfiguration">
|
|
16
|
+
<option name="transferred" value="true" />
|
|
17
|
+
</component>
|
|
18
|
+
</project>
|
package/.idea/vcs.xml
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 InfrontJS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# frontfire
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "frontfire",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/infrontjs/frontfire.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "benny00100",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/infrontjs/frontfire/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/infrontjs/frontfire#readme",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"esbuild": "^0.17.4",
|
|
22
|
+
"esbuild-copy-static-files": "^0.1.0",
|
|
23
|
+
"esbuild-plugin-copy": "^2.0.2"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as esbuild from 'esbuild';
|
|
2
|
+
import { copy } from "esbuild-plugin-copy";
|
|
3
|
+
import copyStaticFiles from "esbuild-copy-static-files";
|
|
4
|
+
import http from 'node:http';
|
|
5
|
+
|
|
6
|
+
const isWatch = process.argv.includes('-w');
|
|
7
|
+
const rootBuildDir = 'build';
|
|
8
|
+
|
|
9
|
+
// @todo Add PATH_SEPERATOR for paths
|
|
10
|
+
|
|
11
|
+
let opts = {
|
|
12
|
+
// esbuild options
|
|
13
|
+
bundle: true,
|
|
14
|
+
sourcemap: true,
|
|
15
|
+
minify: isWatch ? false : true,
|
|
16
|
+
logLevel: isWatch ? "info" : "error",
|
|
17
|
+
entryPoints : [ 'src/main.js', 'src/style.css' ],
|
|
18
|
+
outdir : isWatch ? `${rootBuildDir}/debug/bundles/` : `${rootBuildDir}/release/bundles`,
|
|
19
|
+
loader: {
|
|
20
|
+
".html" : "text"
|
|
21
|
+
},
|
|
22
|
+
plugins: [
|
|
23
|
+
copy({
|
|
24
|
+
resolveFrom : 'cwd',
|
|
25
|
+
assets: [
|
|
26
|
+
{
|
|
27
|
+
from: [ 'src/index.html' ],
|
|
28
|
+
to: [ isWatch ? `${rootBuildDir}/debug/` : `${rootBuildDir}/release/` ]
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}),
|
|
32
|
+
copyStaticFiles({
|
|
33
|
+
src: 'src/assets',
|
|
34
|
+
dest: isWatch ? `${rootBuildDir}/debug/assets` : `${rootBuildDir}/release/assets`,
|
|
35
|
+
dereference: true,
|
|
36
|
+
errorOnExist: false,
|
|
37
|
+
preserveTimestamps: true,
|
|
38
|
+
recursive: true
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if ( true === isWatch )
|
|
45
|
+
{
|
|
46
|
+
opts[ "banner" ] = {
|
|
47
|
+
js: "(() => { (new EventSource(\"/esbuild\")).addEventListener('change', () => location.reload()); })();"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let ctx = await esbuild.context( opts );
|
|
52
|
+
|
|
53
|
+
if ( true === isWatch )
|
|
54
|
+
{
|
|
55
|
+
await ctx.watch();
|
|
56
|
+
let { host, port } = await ctx.serve(
|
|
57
|
+
{
|
|
58
|
+
servedir : `./${rootBuildDir}/debug`
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// Then start a proxy server on port 3000
|
|
63
|
+
http.createServer((req, res) => {
|
|
64
|
+
|
|
65
|
+
const options = {
|
|
66
|
+
hostname: host,
|
|
67
|
+
port: port,
|
|
68
|
+
path: req.url,
|
|
69
|
+
method: req.method,
|
|
70
|
+
headers: req.headers,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Check if path is a valid state route
|
|
74
|
+
// then pass it as "index.html" to the server
|
|
75
|
+
|
|
76
|
+
// Forward each incoming request to esbuild
|
|
77
|
+
const proxyReq = http.request(options, proxyRes => {
|
|
78
|
+
// If esbuild returns "not found", send a custom 404 page
|
|
79
|
+
if (proxyRes.statusCode === 404) {
|
|
80
|
+
res.writeHead(404, { 'Content-Type': 'text/html' })
|
|
81
|
+
res.end('<h1>A custom 404 page</h1>')
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Otherwise, forward the response from esbuild to the client
|
|
86
|
+
res.writeHead(proxyRes.statusCode, proxyRes.headers)
|
|
87
|
+
|
|
88
|
+
proxyRes.pipe(res, { end: true })
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
// Forward the body of the request to esbuild
|
|
92
|
+
req.pipe(proxyReq, { end: true })
|
|
93
|
+
|
|
94
|
+
}).listen(3000);
|
|
95
|
+
|
|
96
|
+
console.log( '> InfrontJS:http://localhost:3000' );
|
|
97
|
+
}
|
|
98
|
+
else
|
|
99
|
+
{
|
|
100
|
+
await ctx.rebuild();
|
|
101
|
+
ctx.dispose();
|
|
102
|
+
}
|