@africode/core 5.0.2 → 5.0.3

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.
@@ -36,7 +36,8 @@ export async function dev() {
36
36
  // 3. JS-First Page Rendering
37
37
  const pageName = pathname.replace(/^\//, '').replace(/\.html$/, '');
38
38
  const cwd = process.cwd();
39
- const hasSrc = await Bun.file(nodePath.join(cwd, 'src/pages')).exists() || await Bun.file(nodePath.join(cwd, 'src')).exists();
39
+ const { existsSync } = await import('node:fs');
40
+ const hasSrc = existsSync(nodePath.join(cwd, 'src/pages'));
40
41
  const pagesDir = hasSrc ? 'src/pages' : 'pages';
41
42
  const jsPagePath = `./${pagesDir}/${pageName}.js`;
42
43
 
@@ -74,7 +75,7 @@ export async function dev() {
74
75
  return new Response(htmlContent, { headers: { 'Content-Type': 'text/html' } });
75
76
  }
76
77
 
77
- // 5. Static Assets
78
+ // 5. Static Assets (project root)
78
79
  const file = Bun.file('.' + url.pathname);
79
80
  if (await file.exists()) {
80
81
  if (pathname.endsWith('.html')) {
@@ -93,7 +94,26 @@ export async function dev() {
93
94
  return new Response(file, { headers: { 'Content-Type': types[ext] || 'application/octet-stream' } });
94
95
  }
95
96
 
96
- // 6. Framework Fallback (for linked projects)
97
+ // 6. node_modules serving (for bare import resolution via importmap)
98
+ if (pathname.startsWith('/node_modules/')) {
99
+ const nmFile = Bun.file('.' + pathname);
100
+ if (await nmFile.exists()) {
101
+ const ext = pathname.split('.').pop();
102
+ const types = {
103
+ css: 'text/css', js: 'application/javascript', mjs: 'application/javascript',
104
+ json: 'application/json', svg: 'image/svg+xml', woff: 'font/woff',
105
+ woff2: 'font/woff2', ttf: 'font/ttf'
106
+ };
107
+ return new Response(nmFile, {
108
+ headers: {
109
+ 'Content-Type': types[ext] || 'application/octet-stream',
110
+ 'Access-Control-Allow-Origin': '*'
111
+ }
112
+ });
113
+ }
114
+ }
115
+
116
+ // 7. Framework Fallback (for linked projects)
97
117
  const frameworkFile = Bun.file(nodePath.join(frameworkRoot, url.pathname));
98
118
  if (await frameworkFile.exists()) {
99
119
  const ext = pathname.split('.').pop();
@@ -1,6 +1,6 @@
1
1
  {
2
- "timestamp": "2026-06-27T15:33:50.289Z",
3
- "version": "5.0.2",
2
+ "timestamp": "2026-06-28T07:49:55.934Z",
3
+ "version": "5.0.3",
4
4
  "bundles": {
5
5
  "core": {
6
6
  "file": "africode.js",
@@ -19,5 +19,5 @@
19
19
  ]
20
20
  }
21
21
  },
22
- "buildTime": "168.11ms"
22
+ "buildTime": "155.00ms"
23
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@africode/core",
3
- "version": "5.0.2",
3
+ "version": "5.0.3",
4
4
  "description": "Bun-native full-stack framework with generative AI, fintech compliance, and real-time performance - built for Tanzanian digital economy",
5
5
  "module": "src/index.ts",
6
6
  "main": "src/index.ts",
@@ -9,6 +9,6 @@
9
9
  "migrate": "africode migrate"
10
10
  },
11
11
  "dependencies": {
12
- "africode": "^1.0.0"
12
+ "@africode/core": "^5.0.2"
13
13
  }
14
14
  }
@@ -6,11 +6,21 @@
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
7
  <title>Welcome to AfriCode</title>
8
8
 
9
+ <!-- Import Map: resolves bare module specifiers for the browser -->
10
+ <script type="importmap">
11
+ {
12
+ "imports": {
13
+ "africode": "/node_modules/@africode/core/src/index.ts",
14
+ "africode/components": "/node_modules/@africode/core/components/index.js"
15
+ }
16
+ }
17
+ </script>
18
+
9
19
  <!-- Theme -->
10
- <link rel="stylesheet" href="/node_modules/africode/styles/africanity.css">
11
- <link rel="stylesheet" href="/node_modules/africode/styles/typography.css">
20
+ <link rel="stylesheet" href="/node_modules/@africode/core/styles/africanity.css">
21
+ <link rel="stylesheet" href="/node_modules/@africode/core/styles/typography.css">
12
22
  <link rel="stylesheet" href="/styles/main.css">
13
- <script type="module" src="/node_modules/africode/core/sdk.js"></script>
23
+ <script type="module" src="/node_modules/@africode/core/src/index.ts"></script>
14
24
 
15
25
  <!-- SDK & Components -->
16
26
  <script type="module">
@@ -31,7 +41,7 @@
31
41
  <div
32
42
  style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; margin-top: 40px;">
33
43
  <af-card title="Getting Started">
34
- <p>Edit <code>pages/index.html</code> to change this page.</p>
44
+ <p>Edit <code>src/pages/index.html</code> to change this page.</p>
35
45
  <af-button variant="primary">Read Docs</af-button>
36
46
  </af-card>
37
47
 
@@ -1,32 +1,17 @@
1
1
  import { html, Layout } from 'africode';
2
2
 
3
- /**
4
- * Home Page
5
- * Route: /
6
- */
7
- export default function HomePage() {
8
- return Layout({
9
- title: "Welcome to AfriCode",
10
- children: html`
11
- <af-navbar logo="My App" theme="dark"></af-navbar>
12
-
13
- <main style="max-width: 1000px; margin: 0 auto; padding: 40px;">
14
- <af-hero
15
- title="Next-Gen African Web"
16
- subtitle="Built with the AfriCode JS Framework."
17
- pattern="kente">
18
- </af-hero>
19
-
20
- <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; margin-top: 40px;">
21
- <af-card title="JS-First Architecture">
22
- <p>No more HTML files. Logic and View utilize <code>pages/index.js</code>.</p>
23
- </af-card>
3
+ export function loader() {
4
+ return { title: 'Welcome to AfriCode' };
5
+ }
24
6
 
25
- <af-card title="Component System">
26
- <p>Import components and use them directly in your template literals.</p>
27
- </af-card>
28
- </div>
29
- </main>
30
- `
31
- });
7
+ export default function HomePage({ data }) {
8
+ return Layout({
9
+ title: data?.title || 'Welcome to AfriCode',
10
+ children: html`
11
+ <main>
12
+ <h1>Welcome to AfriCode</h1>
13
+ <p>Your African-centric full-stack framework is ready.</p>
14
+ </main>
15
+ `
16
+ });
32
17
  }
@@ -9,7 +9,7 @@
9
9
  "migrate": "africode migrate"
10
10
  },
11
11
  "dependencies": {
12
- "africode": "^2.4.0",
12
+ "@africode/core": "^5.0.2",
13
13
  "three": "^0.160.0"
14
14
  }
15
15
  }
@@ -6,11 +6,21 @@
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
7
  <title>Welcome to AfriCode</title>
8
8
 
9
+ <!-- Import Map: resolves bare module specifiers for the browser -->
10
+ <script type="importmap">
11
+ {
12
+ "imports": {
13
+ "africode": "/node_modules/@africode/core/src/index.ts",
14
+ "africode/components": "/node_modules/@africode/core/components/index.js"
15
+ }
16
+ }
17
+ </script>
18
+
9
19
  <!-- Theme -->
10
- <link rel="stylesheet" href="/node_modules/africode/styles/africanity.css">
11
- <link rel="stylesheet" href="/node_modules/africode/styles/typography.css">
20
+ <link rel="stylesheet" href="/node_modules/@africode/core/styles/africanity.css">
21
+ <link rel="stylesheet" href="/node_modules/@africode/core/styles/typography.css">
12
22
  <link rel="stylesheet" href="/styles/main.css">
13
- <script type="module" src="/node_modules/africode/core/sdk.js"></script>
23
+ <script type="module" src="/node_modules/@africode/core/src/index.ts"></script>
14
24
 
15
25
  <!-- SDK & Components -->
16
26
  <script type="module">
@@ -9,7 +9,7 @@
9
9
  "migrate": "africode migrate"
10
10
  },
11
11
  "dependencies": {
12
- "africode": "^1.0.0",
12
+ "@africode/core": "^5.0.2",
13
13
  "react": "^19.0.0",
14
14
  "react-dom": "^19.0.0"
15
15
  }
@@ -6,11 +6,21 @@
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
7
  <title>Welcome to AfriCode</title>
8
8
 
9
+ <!-- Import Map: resolves bare module specifiers for the browser -->
10
+ <script type="importmap">
11
+ {
12
+ "imports": {
13
+ "africode": "/node_modules/@africode/core/src/index.ts",
14
+ "africode/components": "/node_modules/@africode/core/components/index.js"
15
+ }
16
+ }
17
+ </script>
18
+
9
19
  <!-- Theme -->
10
- <link rel="stylesheet" href="/node_modules/africode/styles/africanity.css">
11
- <link rel="stylesheet" href="/node_modules/africode/styles/typography.css">
20
+ <link rel="stylesheet" href="/node_modules/@africode/core/styles/africanity.css">
21
+ <link rel="stylesheet" href="/node_modules/@africode/core/styles/typography.css">
12
22
  <link rel="stylesheet" href="/styles/main.css">
13
- <script type="module" src="/node_modules/africode/core/sdk.js"></script>
23
+ <script type="module" src="/node_modules/@africode/core/src/index.ts"></script>
14
24
 
15
25
  <!-- SDK & Components -->
16
26
  <script type="module">
@@ -10,7 +10,7 @@
10
10
  "migrate": "africode migrate"
11
11
  },
12
12
  "dependencies": {
13
- "africode": "^1.0.0"
13
+ "@africode/core": "^5.0.2"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@tailwindcss/cli": "^4.0.0",
@@ -6,11 +6,21 @@
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
7
  <title>Welcome to AfriCode</title>
8
8
 
9
+ <!-- Import Map: resolves bare module specifiers for the browser -->
10
+ <script type="importmap">
11
+ {
12
+ "imports": {
13
+ "africode": "/node_modules/@africode/core/src/index.ts",
14
+ "africode/components": "/node_modules/@africode/core/components/index.js"
15
+ }
16
+ }
17
+ </script>
18
+
9
19
  <!-- Theme -->
10
- <link rel="stylesheet" href="/node_modules/africode/styles/africanity.css">
11
- <link rel="stylesheet" href="/node_modules/africode/styles/typography.css">
20
+ <link rel="stylesheet" href="/node_modules/@africode/core/styles/africanity.css">
21
+ <link rel="stylesheet" href="/node_modules/@africode/core/styles/typography.css">
12
22
  <link rel="stylesheet" href="/styles/main.css">
13
- <script type="module" src="/node_modules/africode/core/sdk.js"></script>
23
+ <script type="module" src="/node_modules/@africode/core/src/index.ts"></script>
14
24
 
15
25
  <!-- SDK & Components -->
16
26
  <script type="module">