@absolutejs/absolute 0.1.0 → 0.1.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.
@@ -0,0 +1,4 @@
1
+ export * from "./constants";
2
+ export * from "./core/index";
3
+ export * from "./plugins/index";
4
+ export * from "./utils/index";
@@ -0,0 +1,2 @@
1
+ export * from "./networkingPlugin";
2
+ export * from "./pageRouterPlugin";
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{c as f}from"./networkingPlugin.js";import"./pageRouterPlugin.js";import"../core/build.js";import"../../build-s7a2qjm1.js";import"../utils/updateScriptTags.js";import"../utils/networking.js";import"../../build-sewy0hdv.js";export{f as networkingPlugin};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{h as r}from"../../build-s7a2qjm1.js";import{j as e}from"../utils/networking.js";import"../../build-sewy0hdv.js";import{argv as a}from"node:process";var{env:s}=globalThis.Bun;var t=s.HOST??"localhost",o=s.PORT??r,l,c=a,n=c.includes("--host");if(n)l=e(),t="0.0.0.0";var d=(i)=>i.listen({hostname:t,port:o},()=>{if(n)console.log(`Server started on http://localhost:${o}`),console.log(`Server started on network: http://${l}:${o}`);else console.log(`Server started on http://${t}:${o}`)});export{d as networkingPlugin};
3
+ export{d as c};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{d as i}from"../core/build.js";import"../../build-s7a2qjm1.js";import"../utils/updateScriptTags.js";import"../../build-sewy0hdv.js";var a=await i();
@@ -0,0 +1,2 @@
1
+ export * from "./networking";
2
+ export * from "./updateScriptTags";
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{i as f}from"./updateScriptTags.js";import{j as m}from"./networking.js";import"../../build-sewy0hdv.js";export{f as updateScriptTags,m as getLocalIPAddress};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import"../../build-sewy0hdv.js";import q from"node:os";var x=()=>{let m=q.networkInterfaces(),j=Object.values(m).flat().filter((g)=>g!==void 0).find((g)=>g.family==="IPv4"&&!g.internal);if(j)return j.address;return console.warn("No IP address found, falling back to localhost"),"localhost"};export{x as getLocalIPAddress};
3
+ export{x as j};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import"../../build-sewy0hdv.js";import{readFile as K,writeFile as L}from"node:fs/promises";var{Glob:M}=globalThis.Bun;var W=async(y,z)=>{let A=new M("*.html"),q=[];for await(let j of A.scan({cwd:z,absolute:!0}))q.push(j);for(let j of q){let k=await K(j,"utf8");for(let[B,C]of Object.entries(y)){let E=B.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),H=new RegExp(`(<script[^>]+src=["'])(/?(?:.*\\/)?${E})(?:\\.[^."'/]+)?(\\.js)(["'][^>]*>)`,"g");k=k.replace(H,(O,I,Q,T,J)=>{return`${I}${C}${J}`})}await L(j,k,"utf8")}};export{W as updateScriptTags};
3
+ export{W as i};
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@absolutejs/absolute",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A fullstack meta-framework for building web applications with TypeScript",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/alexkahndev/absolutejs.git"
8
8
  },
9
- "main": "dist/index.js",
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
10
11
  "license": "CC BY-NC 4.0",
11
12
  "author": "Alex Kahn",
12
13
  "scripts": {
package/src/core/build.ts CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  MILLISECONDS_IN_A_SECOND,
8
8
  TIME_PRECISION
9
9
  } from "../constants";
10
- import { updateScriptTags } from "../utils/updateScriptTags";
10
+ import { updateScriptTags } from "../utils/updateScriptTags";
11
11
 
12
12
  const projectRoot = join(import.meta.dir, "..", "..");
13
13
  const buildDir = join(projectRoot, "example/build");
@@ -0,0 +1,2 @@
1
+ export * from "./build";
2
+ export * from "./pageHandlers";
@@ -16,4 +16,4 @@ export const handleReactPageRequest = async (
16
16
  });
17
17
  };
18
18
 
19
- export const handleHTMLPageRequest = (html: string) => Bun.file(html);
19
+ export const handleHTMLPageRequest = (html: string) => Bun.file(html);
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./constants";
2
+ export * from "./core/index";
3
+ export * from "./plugins/index";
4
+ export * from "./utils/index";
@@ -0,0 +1,2 @@
1
+ export * from "./networkingPlugin";
2
+ export * from "./pageRouterPlugin";
@@ -0,0 +1,2 @@
1
+ export * from "./networking";
2
+ export * from "./updateScriptTags";
@@ -1,4 +1,4 @@
1
- // TODO : this script seems to only work after building twice maybe due to the async nature of it
1
+ // TODO : this script seems to only work after building twice maybe due to the async nature of it
2
2
 
3
3
  import { readFile, writeFile } from "node:fs/promises";
4
4
  import { Glob } from "bun";
@@ -11,41 +11,50 @@ import { Glob } from "bun";
11
11
  * @param manifest - An object mapping script base names to the new file path.
12
12
  * @param htmlDir - The directory that contains the HTML files.
13
13
  */
14
- export const updateScriptTags = async (manifest: Record<string, string>, htmlDir: string) => {
15
- // Use Glob to find all HTML files in the specified directory
16
- const htmlGlob = new Glob("*.html");
17
- const htmlFiles: string[] = [];
18
- for await (const file of htmlGlob.scan({
19
- cwd: htmlDir,
20
- absolute: true,
21
- })) {
22
- htmlFiles.push(file);
23
- }
14
+ export const updateScriptTags = async (
15
+ manifest: Record<string, string>,
16
+ htmlDir: string
17
+ ) => {
18
+ // Use Glob to find all HTML files in the specified directory
19
+ const htmlGlob = new Glob("*.html");
20
+ const htmlFiles: string[] = [];
21
+ for await (const file of htmlGlob.scan({
22
+ cwd: htmlDir,
23
+ absolute: true
24
+ })) {
25
+ htmlFiles.push(file);
26
+ }
24
27
 
25
- // Process each HTML file
26
- for (const filePath of htmlFiles) {
27
- let content = await readFile(filePath, "utf8");
28
+ // Process each HTML file
29
+ for (const filePath of htmlFiles) {
30
+ let content = await readFile(filePath, "utf8");
28
31
 
29
- // For each script in the manifest, update matching <script> tags
30
- for (const [scriptName, newPath] of Object.entries(manifest)) {
31
- // Escape special regex characters in the scriptName
32
- const escapedScriptName = scriptName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
33
- // The regex explanation:
34
- // (1) (<script[^>]+src=["']) — capture the opening of the script tag up to the src attribute value
35
- // (2) (\/?(?:.*\\/)?${escapedScriptName}) — capture any preceding path and the base script name
36
- // (3) (?:\.[^."'/]+)? — optionally capture a dot and hash (if already hashed)
37
- // (4) (\.js) then capture the js extension
38
- // (5) (["'][^>]*>) — capture the closing quote and remainder of the script tag
39
- const regex = new RegExp(
40
- `(<script[^>]+src=["'])(\/?(?:.*\\/)?${escapedScriptName})(?:\\.[^."'/]+)?(\\.js)(["'][^>]*>)`,
41
- "g"
42
- );
43
- // Replace the matched src attribute with the new value from the manifest
44
- content = content.replace(regex, (_, prefix, _oldBase, _ext, suffix) => {
45
- return `${prefix}${newPath}${suffix}`;
46
- });
47
- }
32
+ // For each script in the manifest, update matching <script> tags
33
+ for (const [scriptName, newPath] of Object.entries(manifest)) {
34
+ // Escape special regex characters in the scriptName
35
+ const escapedScriptName = scriptName.replace(
36
+ /[.*+?^${}()|[\]\\]/g,
37
+ "\\$&"
38
+ );
39
+ // The regex explanation:
40
+ // (1) (<script[^>]+src=["']) — capture the opening of the script tag up to the src attribute value
41
+ // (2) (\/?(?:.*\\/)?${escapedScriptName}) — capture any preceding path and the base script name
42
+ // (3) (?:\.[^."'/]+)? optionally capture a dot and hash (if already hashed)
43
+ // (4) (\.js) — then capture the js extension
44
+ // (5) (["'][^>]*>) — capture the closing quote and remainder of the script tag
45
+ const regex = new RegExp(
46
+ `(<script[^>]+src=["'])(\/?(?:.*\\/)?${escapedScriptName})(?:\\.[^."'/]+)?(\\.js)(["'][^>]*>)`,
47
+ "g"
48
+ );
49
+ // Replace the matched src attribute with the new value from the manifest
50
+ content = content.replace(
51
+ regex,
52
+ (_, prefix, _oldBase, _ext, suffix) => {
53
+ return `${prefix}${newPath}${suffix}`;
54
+ }
55
+ );
56
+ }
48
57
 
49
- await writeFile(filePath, content, "utf8");
50
- }
58
+ await writeFile(filePath, content, "utf8");
59
+ }
51
60
  };