@package-verse/esmpack 1.0.6 → 1.0.8
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/.vscode/launch.json +10 -7
- package/.vscode/settings.json +2 -0
- package/package.json +2 -2
- package/src/ProcessArgs.ts +3 -0
- package/src/pack/FilePacker.ts +14 -2
- package/src/parser/babel.ts +15 -4
- package/src/serve/WebServer.ts +8 -2
- package/src/serve/send/packageInfo.ts +10 -0
- package/src/serve/send/sendJS.ts +51 -11
- package/src/serve/send/sendJSHost.ts +10 -1
- package/src/serve/send/sendNonJSModule.ts +39 -0
- package/src/tags.d.ts +32 -0
- package/src/test/Clock.svg +1 -0
- package/src/test/Clock2.svg +1 -0
- package/src/test/TestView.ts +14 -1
- package/src/serve/send/sendCSSJS.ts +0 -22
package/.vscode/launch.json
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "0.2.0",
|
|
3
3
|
"configurations": [
|
|
4
|
-
{
|
|
5
|
-
"name": "Launch Edge",
|
|
6
|
-
"request": "launch",
|
|
7
|
-
"type": "pwa-msedge",
|
|
8
|
-
"url": "http://127.0.0.1:8080/uiv/$CURRENT$/dist/c8-front-end",
|
|
9
|
-
"webRoot": "${workspaceFolder}"
|
|
10
|
-
},
|
|
11
4
|
{
|
|
12
5
|
"type": "node",
|
|
13
6
|
"request": "launch",
|
|
@@ -16,6 +9,16 @@
|
|
|
16
9
|
"outFiles": [
|
|
17
10
|
"${workspaceRoot}/out/**/*.js"
|
|
18
11
|
]
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "Attach to Process",
|
|
15
|
+
"type": "node",
|
|
16
|
+
"request": "attach",
|
|
17
|
+
"port": 9229,
|
|
18
|
+
"localRoot": "${workspaceRoot}",
|
|
19
|
+
"outFiles": [
|
|
20
|
+
"${workspaceFolder}/dist/**/*.js",
|
|
21
|
+
]
|
|
19
22
|
}
|
|
20
23
|
]
|
|
21
24
|
}
|
package/.vscode/settings.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@package-verse/esmpack",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "ESM Pack Packer and Web Server with PostCSS and ESM Loader",
|
|
5
5
|
"homepage": "https://github.com/package-verse/esmpack#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"test": "exit 0",
|
|
18
18
|
"push": "git add -A && git commit -m \"dep vb\" && npm version patch",
|
|
19
19
|
"build-css-watch": "npx postcss \"./src/**/*.css\" --base src --dir dist --map --verbose -w",
|
|
20
|
-
"test-server": "node --enable-source-maps ./serve.js",
|
|
20
|
+
"test-server": "node --enable-source-maps --inspect=0.0.0.0:9229 ./serve.js",
|
|
21
21
|
"postversion": "git push --follow-tags"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
package/src/ProcessArgs.ts
CHANGED
package/src/pack/FilePacker.ts
CHANGED
|
@@ -3,7 +3,18 @@
|
|
|
3
3
|
* 1. Visit every JavaScript file
|
|
4
4
|
* 2. Change all imports, redirect CSS imports as css.js file that will include CSS on the page ...
|
|
5
5
|
* 3. Create .pack.js with all nested imports if file imports `@web-atoms/core/dist/Pack`
|
|
6
|
-
* 4. Packed file must set all css as installed.
|
|
6
|
+
* 4. Packed file must set all css as installed. And other modules will simply return absolute paths.
|
|
7
|
+
*
|
|
8
|
+
* For App.js following packed scripts will be generated.
|
|
9
|
+
* 1. App.pack.js
|
|
10
|
+
* Push Import Maps script tag
|
|
11
|
+
* Imports all nested dependencies of App.js that should not contain fully qualified path
|
|
12
|
+
* Import dynamically loaded modules as well
|
|
13
|
+
* Loads App.pack.global.css
|
|
14
|
+
* Loads App.pack.local.css
|
|
15
|
+
* Imports App.js dynamically so CSS can be ready before hosting the User interface
|
|
16
|
+
* 2. App.pack.global.css
|
|
17
|
+
* 3. App.pack.local.css
|
|
7
18
|
*/
|
|
8
19
|
export default class FilePacker {
|
|
9
20
|
|
|
@@ -12,7 +23,8 @@ export default class FilePacker {
|
|
|
12
23
|
|
|
13
24
|
constructor(
|
|
14
25
|
public readonly root: string,
|
|
15
|
-
public readonly src: string
|
|
26
|
+
public readonly src: string,
|
|
27
|
+
public readonly prefix: string
|
|
16
28
|
) {
|
|
17
29
|
// empty
|
|
18
30
|
}
|
package/src/parser/babel.ts
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { transformSync } from "@babel/core";
|
|
2
2
|
import { readFileSync } from "fs";
|
|
3
|
+
import { ProcessOptions } from "../ProcessArgs.js";
|
|
4
|
+
import { parse } from "path";
|
|
3
5
|
|
|
4
6
|
export class Babel {
|
|
5
7
|
|
|
6
|
-
static transform({ file, resolve }: { file: string, resolve: (url: string) => string }) {
|
|
8
|
+
static transform({ file, resolve }: { file: string, resolve: (url: string, sourceFile: string) => string }) {
|
|
9
|
+
|
|
10
|
+
const { base: name } = parse(file);
|
|
7
11
|
|
|
8
12
|
const presets = {
|
|
9
13
|
sourceType: "module",
|
|
10
14
|
sourceMaps: true,
|
|
11
15
|
inputSourceMap: true,
|
|
16
|
+
caller: {
|
|
17
|
+
name,
|
|
18
|
+
supportsDynamicImport: true,
|
|
19
|
+
supportsTopLevelAwait: true,
|
|
20
|
+
},
|
|
12
21
|
compact: false,
|
|
13
22
|
comments: false,
|
|
23
|
+
root: ProcessOptions.cwd,
|
|
14
24
|
getModuleId: () => "v",
|
|
15
25
|
"plugins": [
|
|
16
26
|
[
|
|
@@ -24,7 +34,8 @@ export class Babel {
|
|
|
24
34
|
if (!source) {
|
|
25
35
|
return node;
|
|
26
36
|
}
|
|
27
|
-
|
|
37
|
+
const sourceFile = node.hub?.file?.inputMap?.sourcemap?.sources?.[0];
|
|
38
|
+
source = resolve(source, sourceFile);
|
|
28
39
|
e.source.value = source;
|
|
29
40
|
return node;
|
|
30
41
|
},
|
|
@@ -38,7 +49,7 @@ export class Babel {
|
|
|
38
49
|
|
|
39
50
|
const p = { ... presets, filename: file };
|
|
40
51
|
const code = readFileSync(file, "utf8");
|
|
41
|
-
const result =
|
|
52
|
+
const result = transformSync(code, p);
|
|
42
53
|
return result.code;
|
|
43
54
|
}
|
|
44
55
|
|
package/src/serve/WebServer.ts
CHANGED
|
@@ -6,7 +6,7 @@ import sendLocalFile from "./send/sendLocalFile.js";
|
|
|
6
6
|
import { createProxyMiddleware, fixRequestBody } from "http-proxy-middleware";
|
|
7
7
|
import colors from "colors";
|
|
8
8
|
import sendJSHost from "./send/sendJSHost.js";
|
|
9
|
-
import
|
|
9
|
+
import sendNonJSModule from "./send/sendNonJSModule.js";
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
let middleware;
|
|
@@ -24,7 +24,7 @@ export default function WebServer(req: IncomingMessage, res: ServerResponse) {
|
|
|
24
24
|
|
|
25
25
|
const css = fullPath.replace(/\.js$/, "");
|
|
26
26
|
if (existsSync(css)) {
|
|
27
|
-
|
|
27
|
+
sendNonJSModule(pathname.substring(0, pathname.length - 3), req, res);
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -34,6 +34,12 @@ export default function WebServer(req: IncomingMessage, res: ServerResponse) {
|
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// if (!fileArgument) {
|
|
38
|
+
// res.writeHead(404,{});
|
|
39
|
+
// res.end("");
|
|
40
|
+
// return;
|
|
41
|
+
// }
|
|
42
|
+
|
|
37
43
|
// proxy...
|
|
38
44
|
middleware ??= createProxyMiddleware({
|
|
39
45
|
target: fileArgument,
|
|
@@ -5,3 +5,13 @@ import { join } from "path";
|
|
|
5
5
|
const jsonText = readFileSync(join(ProcessOptions.cwd, "package.json"), "utf-8");
|
|
6
6
|
|
|
7
7
|
export const packageInfo = JSON.parse(jsonText);
|
|
8
|
+
|
|
9
|
+
const imports = {
|
|
10
|
+
[packageInfo.name + "/"]: "/"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
for (const [key] of Object.entries(packageInfo.dependencies)) {
|
|
14
|
+
imports[key + "/"] = "/node_modules/" + key + "/";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const importMap = { imports };
|
package/src/serve/send/sendJS.ts
CHANGED
|
@@ -2,33 +2,73 @@ import { IncomingMessage, ServerResponse } from "node:http";
|
|
|
2
2
|
import { Babel } from "../../parser/babel.js";
|
|
3
3
|
import path, { parse } from "node:path";
|
|
4
4
|
import { ProcessOptions } from "../../ProcessArgs.js";
|
|
5
|
-
import { readFileSync } from "node:fs";
|
|
5
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
6
6
|
|
|
7
7
|
export default function sendJS(filePath: string, req: IncomingMessage, res: ServerResponse) {
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
let text = Babel.transform({ file: filePath, resolve(url) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
let text = Babel.transform({ file: filePath, resolve(url, sourceFile) {
|
|
11
|
+
|
|
12
|
+
const originalUrl = url;
|
|
13
|
+
|
|
14
14
|
// check if it has no extension...
|
|
15
15
|
const { ext } = parse(url);
|
|
16
16
|
if (!ext) {
|
|
17
|
+
|
|
18
|
+
// this is case for tslib, reflect_metadata
|
|
19
|
+
|
|
17
20
|
// fetch module...
|
|
18
21
|
const tokens = url.split("/");
|
|
19
|
-
let
|
|
22
|
+
let packageName = tokens.shift();
|
|
20
23
|
if (packageName.startsWith("@")) {
|
|
21
24
|
packageName += "/" + tokens.shift();
|
|
22
25
|
}
|
|
26
|
+
|
|
23
27
|
const packageJsonPath = path.resolve(ProcessOptions.cwd, "node_modules", packageName, "package.json");
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
if (existsSync(packageJsonPath)) {
|
|
29
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
30
|
+
const start = packageJson["module"] || packageJson["main"];
|
|
31
|
+
return url + "/" + start;
|
|
32
|
+
}
|
|
33
|
+
|
|
27
34
|
}
|
|
35
|
+
|
|
36
|
+
|
|
28
37
|
if (!url.startsWith(".")) {
|
|
29
|
-
|
|
38
|
+
|
|
39
|
+
if (!url.endsWith(".js")) {
|
|
40
|
+
url += ".js";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return url;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const jsFile = path.resolve(path.dirname(filePath), url);
|
|
47
|
+
if (existsSync(jsFile)) {
|
|
48
|
+
if (!jsFile.endsWith(".js")) {
|
|
49
|
+
url += ".js";
|
|
50
|
+
}
|
|
51
|
+
return url;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (url.endsWith(".js")) {
|
|
55
|
+
return url;
|
|
30
56
|
}
|
|
31
|
-
|
|
57
|
+
|
|
58
|
+
// is it referenced from source...
|
|
59
|
+
const dir = path.dirname(filePath);
|
|
60
|
+
const absoluteSourcePath = path.resolve( dir, path.dirname(sourceFile));
|
|
61
|
+
console.log(`Absolute Path is ${absoluteSourcePath}`);
|
|
62
|
+
const referencedAbsolutePath = path.join(absoluteSourcePath, url);
|
|
63
|
+
if (existsSync(referencedAbsolutePath)) {
|
|
64
|
+
const relative = path.relative(dir, referencedAbsolutePath).replaceAll("\\", "/");
|
|
65
|
+
if(!relative.endsWith(".js")) {
|
|
66
|
+
return relative + ".js";
|
|
67
|
+
}
|
|
68
|
+
return relative;
|
|
69
|
+
}
|
|
70
|
+
return originalUrl;
|
|
71
|
+
|
|
32
72
|
}});
|
|
33
73
|
|
|
34
74
|
const { base } = parse(filePath);
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import { importMap, packageInfo } from "./packageInfo.js";
|
|
2
3
|
|
|
3
4
|
export default function sendJSHost(path: string, req: IncomingMessage, res: ServerResponse) {
|
|
5
|
+
|
|
6
|
+
// generate import maps
|
|
7
|
+
// for dynamic scripts
|
|
8
|
+
// this is to avoid path renaming and support dynamic module loading
|
|
9
|
+
|
|
4
10
|
const text = `
|
|
5
11
|
<!DOCTYPE html>
|
|
6
12
|
<html lang="en">
|
|
@@ -10,9 +16,12 @@ export default function sendJSHost(path: string, req: IncomingMessage, res: Serv
|
|
|
10
16
|
<title>Index of ${path}</title>
|
|
11
17
|
</head>
|
|
12
18
|
<body>
|
|
19
|
+
<script type="importmap">
|
|
20
|
+
${JSON.stringify(importMap, void 0, 2)}
|
|
21
|
+
</script>
|
|
13
22
|
<script>
|
|
14
23
|
const cs = document.currentScript;
|
|
15
|
-
import("/${path}").then((r) => ESMPack.render(r, cs), (error) => cs.replaceWith(document.createTextNode(error.stack || error)));
|
|
24
|
+
import("${packageInfo.name}/${path}").then((r) => ESMPack.render(r, cs), (error) => cs.replaceWith(document.createTextNode(error.stack || error)));
|
|
16
25
|
</script>
|
|
17
26
|
</body>
|
|
18
27
|
</html>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
export default function sendNonJSModule(path: string, req: IncomingMessage, res: ServerResponse) {
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
if (path.endsWith(".css")) {
|
|
9
|
+
|
|
10
|
+
const init = fileURLToPath(import.meta.resolve("../../../init.js"));
|
|
11
|
+
const initText = readFileSync(init, "utf-8");
|
|
12
|
+
|
|
13
|
+
const text = `
|
|
14
|
+
(function (link) {
|
|
15
|
+
${initText};
|
|
16
|
+
ESMPack.installStyleSheet(link);
|
|
17
|
+
}("/${path}"))
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
res.writeHead(200, {
|
|
21
|
+
"content-type": "text/javascript",
|
|
22
|
+
"cache-control": "no-cache"
|
|
23
|
+
});
|
|
24
|
+
res.end(text);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// just send a path...
|
|
30
|
+
res.writeHead(200, {
|
|
31
|
+
"content-type": "text/javascript",
|
|
32
|
+
"cache-control": "no-cache"
|
|
33
|
+
});
|
|
34
|
+
res.end(`
|
|
35
|
+
const value = "/${path}";
|
|
36
|
+
export default value;
|
|
37
|
+
`);
|
|
38
|
+
|
|
39
|
+
}
|
package/src/tags.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare module "*.png" {
|
|
2
|
+
const value: string;
|
|
3
|
+
export default value;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module "*.jpg" {
|
|
7
|
+
const value: string;
|
|
8
|
+
export default value;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare module "*.jpeg" {
|
|
12
|
+
const value: string;
|
|
13
|
+
export default value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare module "*.gif" {
|
|
17
|
+
const value: string;
|
|
18
|
+
export default value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare module "*.svg" {
|
|
22
|
+
const value: string;
|
|
23
|
+
export default value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare module "*.css" {
|
|
27
|
+
const value: string;
|
|
28
|
+
export default value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module "*.json" {
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2026 Fonticons, Inc.--><path opacity=".4" d="M96 352C96 402.3 112.6 448.8 140.6 486.2L105.4 521.4C92.9 533.9 92.9 554.2 105.4 566.7C117.9 579.2 138.2 579.2 150.7 566.7L185.9 531.5C223.3 559.5 269.7 576.1 320 576.1C370.3 576.1 416.8 559.5 454.2 531.5L489.4 566.7C501.9 579.2 522.2 579.2 534.7 566.7C547.2 554.2 547.2 533.9 534.7 521.4L499.5 486.2C527.5 448.8 544.1 402.4 544.1 352C544.1 228.3 443.8 128 320.1 128C196.4 128 96 228.3 96 352zM296 248C296 234.7 306.7 224 320 224C333.3 224 344 234.7 344 248L344 342.1L393 391.1C402.4 400.5 402.4 415.7 393 425C383.6 434.3 368.4 434.4 359.1 425L303.1 369C298.6 364.5 296.1 358.4 296.1 352L296.1 248z"/><path d="M543.5 196.9C550 206.3 564 207 568.4 196.5C573.3 185 576 172.4 576 159.2C576 106.6 533.4 64 480.8 64C461.5 64 443.5 69.8 428.5 79.7C418.9 86 422.2 99.6 432.6 104.3C477.4 124.7 515.7 156.9 543.6 196.9zM71.6 196.5C76.1 207 90 206.3 96.5 196.9C124.3 156.9 162.6 124.7 207.5 104.3C217.9 99.6 221.2 86 211.6 79.7C196.6 69.8 178.6 64 159.3 64C106.7 64 64.1 106.6 64.1 159.2C64.1 172.4 66.8 185 71.7 196.5zM344 248C344 234.7 333.3 224 320 224C306.7 224 296 234.7 296 248L296 352C296 358.4 298.5 364.5 303 369L359 425C368.4 434.4 383.6 434.4 392.9 425C402.2 415.6 402.3 400.4 392.9 391.1L343.9 342.1L343.9 248z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2026 Fonticons, Inc.--><path opacity=".4" d="M96 352C96 402.3 112.6 448.8 140.6 486.2L105.4 521.4C92.9 533.9 92.9 554.2 105.4 566.7C117.9 579.2 138.2 579.2 150.7 566.7L185.9 531.5C223.3 559.5 269.7 576.1 320 576.1C370.3 576.1 416.8 559.5 454.2 531.5L489.4 566.7C501.9 579.2 522.2 579.2 534.7 566.7C547.2 554.2 547.2 533.9 534.7 521.4L499.5 486.2C527.5 448.8 544.1 402.4 544.1 352C544.1 228.3 443.8 128 320.1 128C196.4 128 96 228.3 96 352zM296 248C296 234.7 306.7 224 320 224C333.3 224 344 234.7 344 248L344 342.1L393 391.1C402.4 400.5 402.4 415.7 393 425C383.6 434.3 368.4 434.4 359.1 425L303.1 369C298.6 364.5 296.1 358.4 296.1 352L296.1 248z"/><path d="M543.5 196.9C550 206.3 564 207 568.4 196.5C573.3 185 576 172.4 576 159.2C576 106.6 533.4 64 480.8 64C461.5 64 443.5 69.8 428.5 79.7C418.9 86 422.2 99.6 432.6 104.3C477.4 124.7 515.7 156.9 543.6 196.9zM71.6 196.5C76.1 207 90 206.3 96.5 196.9C124.3 156.9 162.6 124.7 207.5 104.3C217.9 99.6 221.2 86 211.6 79.7C196.6 69.8 178.6 64 159.3 64C106.7 64 64.1 106.6 64.1 159.2C64.1 172.4 66.8 185 71.7 196.5zM344 248C344 234.7 333.3 224 320 224C306.7 224 296 234.7 296 248L296 352C296 358.4 298.5 364.5 303 369L359 425C368.4 434.4 383.6 434.4 392.9 425C402.2 415.6 402.3 400.4 392.9 391.1L343.9 342.1L343.9 248z"/></svg>
|
package/src/test/TestView.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import DateTime from "@web-atoms/date-time/dist/DateTime.js";
|
|
2
2
|
|
|
3
|
+
import clock from "@package-verse/esmpack/src/test/Clock.svg";
|
|
4
|
+
|
|
3
5
|
// irrespective of loading order
|
|
4
6
|
// global must be loaded first and
|
|
5
7
|
// local must override the global style
|
|
@@ -8,13 +10,24 @@ import "./TestView.local.css";
|
|
|
8
10
|
import "./TestView.global.css";
|
|
9
11
|
import LogDecorator from "./LogDecorator.js";
|
|
10
12
|
|
|
13
|
+
import Clock2 from "./Clock2.svg";
|
|
14
|
+
|
|
11
15
|
@LogDecorator
|
|
12
16
|
export default class DateView extends HTMLElement {
|
|
13
17
|
|
|
14
18
|
connectedCallback() {
|
|
19
|
+
|
|
20
|
+
let img = document.createElement("img");
|
|
21
|
+
img.src = clock;
|
|
22
|
+
const span = document.createElement("span");
|
|
23
|
+
this.appendChild(img);
|
|
24
|
+
this.appendChild(span);
|
|
25
|
+
img = document.createElement("img");
|
|
26
|
+
img.src = Clock2;
|
|
27
|
+
this.appendChild(img);
|
|
15
28
|
setInterval(() => {
|
|
16
29
|
const now = DateTime.now;
|
|
17
|
-
|
|
30
|
+
span.textContent = now.toJSON();
|
|
18
31
|
}, 1000);
|
|
19
32
|
}
|
|
20
33
|
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { IncomingMessage, ServerResponse } from "node:http";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
|
|
5
|
-
export default function sendCSSJS(path: string, req: IncomingMessage, res: ServerResponse) {
|
|
6
|
-
|
|
7
|
-
const init = fileURLToPath(import.meta.resolve("../../../init.js"));
|
|
8
|
-
const initText = readFileSync(init, "utf-8");
|
|
9
|
-
|
|
10
|
-
const text = `
|
|
11
|
-
(function (link) {
|
|
12
|
-
${initText};
|
|
13
|
-
ESMPack.installStyleSheet(link);
|
|
14
|
-
}("/${path}"))
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
res.writeHead(200, {
|
|
18
|
-
"content-type": "text/javascript",
|
|
19
|
-
"cache-control": "no-cache"
|
|
20
|
-
});
|
|
21
|
-
res.end(text);
|
|
22
|
-
}
|