@africode/core 5.0.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.
Files changed (136) hide show
  1. package/AFRICODE_FRAMEWORK_GUIDE.md +707 -0
  2. package/LICENSE +623 -0
  3. package/README.md +442 -0
  4. package/bin/africode.js +73 -0
  5. package/bin/africode.js.1758507140 +343 -0
  6. package/bin/cli.ts +83 -0
  7. package/bin/create-africode.js +158 -0
  8. package/bin/scaffold.ts +219 -0
  9. package/components/accordion.js +183 -0
  10. package/components/alert.js +131 -0
  11. package/components/auth.js +172 -0
  12. package/components/avatar.js +117 -0
  13. package/components/badge.js +104 -0
  14. package/components/base.d.ts +139 -0
  15. package/components/base.js +184 -0
  16. package/components/button.js +164 -0
  17. package/components/card.js +137 -0
  18. package/components/cultural-card.js +243 -0
  19. package/components/divider.js +83 -0
  20. package/components/dropdown.js +171 -0
  21. package/components/error-boundary.js +155 -0
  22. package/components/form.js +131 -0
  23. package/components/grid.js +273 -0
  24. package/components/hero.js +138 -0
  25. package/components/icon.js +36 -0
  26. package/components/index.js +57 -0
  27. package/components/input.js +256 -0
  28. package/components/kanga-card.js +185 -0
  29. package/components/language-switcher.js +108 -0
  30. package/components/loader.js +80 -0
  31. package/components/modal.js +262 -0
  32. package/components/motion.js +84 -0
  33. package/components/navbar.js +236 -0
  34. package/components/pattern-showcase.js +225 -0
  35. package/components/progress.js +134 -0
  36. package/components/react.js +111 -0
  37. package/components/section.js +54 -0
  38. package/components/select.js +322 -0
  39. package/components/sidebar.js +180 -0
  40. package/components/skeleton.js +85 -0
  41. package/components/table.js +181 -0
  42. package/components/tabs.js +202 -0
  43. package/components/theme-toggle.js +82 -0
  44. package/components/toast.js +139 -0
  45. package/components/tooltip.js +167 -0
  46. package/core/a2ui-schema-manager.js +344 -0
  47. package/core/a2ui.js +431 -0
  48. package/core/bun-runtime.js +799 -0
  49. package/core/cli/commands/add.js +23 -0
  50. package/core/cli/commands/audit.js +58 -0
  51. package/core/cli/commands/build.js +137 -0
  52. package/core/cli/commands/create-plugin.js +241 -0
  53. package/core/cli/commands/dev.js +228 -0
  54. package/core/cli/commands/lint.js +23 -0
  55. package/core/cli/commands/test.js +34 -0
  56. package/core/cli/migrator.js +71 -0
  57. package/core/cli/ui.js +46 -0
  58. package/core/compliance.js +628 -0
  59. package/core/config.js +263 -0
  60. package/core/db-advanced.js +481 -0
  61. package/core/db.js +284 -0
  62. package/core/enhanced-hmr.js +404 -0
  63. package/core/errors.js +222 -0
  64. package/core/file-router.js +290 -0
  65. package/core/heartbeat.js +64 -0
  66. package/core/hmr-client.js +204 -0
  67. package/core/hmr.js +196 -0
  68. package/core/html.d.ts +116 -0
  69. package/core/html.js +160 -0
  70. package/core/hydration.js +52 -0
  71. package/core/lipa-namba-journey.js +572 -0
  72. package/core/motion.js +106 -0
  73. package/core/nida-cig-middleware.js +455 -0
  74. package/core/patterns.d.ts +124 -0
  75. package/core/patterns.js +833 -0
  76. package/core/plugins/index.js +312 -0
  77. package/core/router.js +387 -0
  78. package/core/sdk-client.js +62 -0
  79. package/core/sdk.d.ts +133 -0
  80. package/core/sdk.js +123 -0
  81. package/core/seo.js +76 -0
  82. package/core/server/auth-endpoints.js +339 -0
  83. package/core/server/auth.js +180 -0
  84. package/core/server/csrf.js +206 -0
  85. package/core/server/db.js +39 -0
  86. package/core/server/middleware.js +324 -0
  87. package/core/server/rate-limit.js +238 -0
  88. package/core/server/render.js +69 -0
  89. package/core/server/router.js +120 -0
  90. package/core/shim.js +28 -0
  91. package/core/state.d.ts +86 -0
  92. package/core/state.js +242 -0
  93. package/core/store.d.ts +122 -0
  94. package/core/store.js +61 -0
  95. package/core/validation.d.ts +233 -0
  96. package/core/validation.js +590 -0
  97. package/core/websocket.js +639 -0
  98. package/dist/africode.js +2905 -0
  99. package/dist/africode.js.map +61 -0
  100. package/dist/build-info.json +23 -0
  101. package/dist/components.js +2888 -0
  102. package/dist/components.js.map +58 -0
  103. package/dist/styles/africanity.css +322 -0
  104. package/dist/styles/typography.css +141 -0
  105. package/docs/IDE-Guide.md +50 -0
  106. package/package.json +110 -0
  107. package/src/index.ts +196 -0
  108. package/styles/africanity.css +322 -0
  109. package/styles/typography.css +141 -0
  110. package/templates/starter/.env.example +15 -0
  111. package/templates/starter/africode.config.js +40 -0
  112. package/templates/starter/package.json +14 -0
  113. package/templates/starter/src/pages/index.html +46 -0
  114. package/templates/starter/src/pages/index.js +32 -0
  115. package/templates/starter/src/styles/main.css +4 -0
  116. package/templates/starter-3d/.env.example +7 -0
  117. package/templates/starter-3d/africode.config.js +29 -0
  118. package/templates/starter-3d/components/af-model-viewer.js +125 -0
  119. package/templates/starter-3d/package.json +15 -0
  120. package/templates/starter-3d/src/pages/index.html +46 -0
  121. package/templates/starter-3d/src/pages/index.js +50 -0
  122. package/templates/starter-3d/src/styles/main.css +4 -0
  123. package/templates/starter-react/.env.example +15 -0
  124. package/templates/starter-react/africode.config.js +40 -0
  125. package/templates/starter-react/package.json +16 -0
  126. package/templates/starter-react/src/pages/index.html +46 -0
  127. package/templates/starter-react/src/pages/index.js +68 -0
  128. package/templates/starter-react/src/styles/main.css +4 -0
  129. package/templates/starter-tailwind/.env.example +15 -0
  130. package/templates/starter-tailwind/africode.config.js +40 -0
  131. package/templates/starter-tailwind/package.json +20 -0
  132. package/templates/starter-tailwind/src/pages/index.html +46 -0
  133. package/templates/starter-tailwind/src/pages/index.js +37 -0
  134. package/templates/starter-tailwind/src/styles/main.css +4 -0
  135. package/templates/starter-tailwind/src/styles/tailwind.css +1 -0
  136. package/templates/starter-tailwind/src/tailwind-loader.js +30 -0
@@ -0,0 +1,62 @@
1
+ /**
2
+ * AfriCode Client SDK
3
+ * Browser-safe entry point for client-side bundling
4
+ *
5
+ * This excludes server-side code like database, auth, and server utilities
6
+ * that can't be bundled for browser use.
7
+ */
8
+
9
+ import { createReactiveState, subscribe, createSignal, createEffect } from './state.js';
10
+ import { store, actions } from './store.js';
11
+ import patterns from './patterns.js';
12
+ import * as motion from './motion.js';
13
+ import { hydrate } from './hydration.js';
14
+ import { html, Layout } from './html.js';
15
+
16
+ import { componentMap as coreMap } from '../components/index.js';
17
+
18
+ // Utility to initialize the client-side framework
19
+ export function init(projectComponentMap = {}) {
20
+ if (typeof window !== 'undefined') {
21
+ console.log('🌍 AfriCode Client SDK Initialized (Zero-Config Mode)');
22
+
23
+ // Merge project map with core map
24
+ const finalMap = { ...coreMap, ...projectComponentMap };
25
+
26
+ if (Object.keys(finalMap).length > 0) {
27
+ hydrate(finalMap);
28
+ }
29
+ }
30
+ }
31
+
32
+ // Grouped exports for cleaner access (client-safe only)
33
+ export {
34
+ createReactiveState,
35
+ subscribe,
36
+ createSignal,
37
+ createEffect
38
+ } from './state.js';
39
+
40
+ export {
41
+ store,
42
+ actions,
43
+ patterns,
44
+ motion,
45
+ html,
46
+ Layout
47
+ };
48
+
49
+ // Default Export
50
+ export default {
51
+ createReactiveState,
52
+ subscribe,
53
+ createSignal,
54
+ createEffect,
55
+ store,
56
+ actions,
57
+ patterns,
58
+ motion,
59
+ html,
60
+ Layout,
61
+ init
62
+ };
package/core/sdk.d.ts ADDED
@@ -0,0 +1,133 @@
1
+ /**
2
+ * AfriCode SDK - TypeScript Definitions
3
+ * Main entry point and API surface
4
+ */
5
+
6
+ import {
7
+ createReactiveState,
8
+ subscribe,
9
+ createSignal,
10
+ createEffect
11
+ } from './state';
12
+
13
+ // State types
14
+ export interface ReactiveState<T extends Record<string, any>> {
15
+ [K in keyof T]: T[K];
16
+ }
17
+
18
+ export interface Signal<T> {
19
+ (): T;
20
+ }
21
+
22
+ export interface SignalSetter<T> {
23
+ (value: T | ((prev: T) => T)): void;
24
+ }
25
+
26
+ export interface Subscriber<T> {
27
+ (newValue: T, oldValue?: T): void;
28
+ }
29
+
30
+ export interface Effect {
31
+ (): void | (() => void);
32
+ }
33
+
34
+ // State management
35
+ export function createReactiveState<T extends Record<string, any>>(
36
+ initialState: T
37
+ ): ReactiveState<T>;
38
+
39
+ export function subscribe<T extends Record<string, any>>(
40
+ state: ReactiveState<T>,
41
+ callback: Subscriber<T>
42
+ ): () => void; // Unsubscribe function
43
+
44
+ export function createSignal<T>(initialValue: T): [Signal<T>, SignalSetter<T>];
45
+
46
+ export function createEffect(effect: Effect): () => void; // Cleanup function
47
+
48
+ // Patterns
49
+ export interface PatternOptions {
50
+ primaryColor?: string;
51
+ secondaryColor?: string;
52
+ accentColor?: string;
53
+ size?: number;
54
+ }
55
+
56
+ export const patterns: {
57
+ generateShuka: (options?: PatternOptions) => string;
58
+ generateKente: (options?: PatternOptions) => string;
59
+ generateKanga: (options?: PatternOptions) => string;
60
+ generateAdinkra: (options?: PatternOptions) => string;
61
+ generateKubaBorder: (options?: PatternOptions) => string;
62
+ generateZuluBeads: (options?: PatternOptions) => string;
63
+ generateMasaiShield: (options?: PatternOptions) => string;
64
+ generateNdebelePaint: (options?: PatternOptions) => string;
65
+ [key: string]: (options?: PatternOptions) => string;
66
+ };
67
+
68
+ // Motion/Animation
69
+ export const motion: {
70
+ fadeIn: animation config;
71
+ slideUp: animation config;
72
+ popIn: animation config;
73
+ [key: string]: any;
74
+ };
75
+
76
+ // HTML template engine
77
+ export function html(
78
+ strings: TemplateStringsArray,
79
+ ...values: any[]
80
+ ): string;
81
+
82
+ // Layout utilities
83
+ export interface LayoutProps {
84
+ vertical?: boolean;
85
+ gap?: number;
86
+ align?: 'start' | 'center' | 'end';
87
+ justify?: 'start' | 'center' | 'end' | 'between';
88
+ }
89
+
90
+ export class Layout {
91
+ constructor(props?: LayoutProps);
92
+ render(): HTMLElement;
93
+ }
94
+
95
+ // Hydration
96
+ export function hydrate(componentMap: Record<string, any>): void;
97
+
98
+ // Store
99
+ export interface GlobalStore {
100
+ theme: 'light' | 'dark' | string;
101
+ language: string;
102
+ [key: string]: any;
103
+ }
104
+
105
+ export interface StoreActions {
106
+ setTheme: (theme: string) => void;
107
+ setLanguage: (lang: string) => void;
108
+ [key: string]: any;
109
+ }
110
+
111
+ export const store: GlobalStore;
112
+ export const actions: StoreActions;
113
+
114
+ // Framework initialization
115
+ export function init(projectComponents?: Record<string, any>): void;
116
+
117
+ // Default export
118
+ declare const sdk: {
119
+ createReactiveState: typeof createReactiveState;
120
+ subscribe: typeof subscribe;
121
+ createSignal: typeof createSignal;
122
+ createEffect: typeof createEffect;
123
+ store: typeof store;
124
+ actions: typeof actions;
125
+ patterns: typeof patterns;
126
+ motion: typeof motion;
127
+ html: typeof html;
128
+ Layout: typeof Layout;
129
+ hydrate: typeof hydrate;
130
+ init: typeof init;
131
+ };
132
+
133
+ export default sdk;
package/core/sdk.js ADDED
@@ -0,0 +1,123 @@
1
+ /**
2
+ * AfriCode SDK
3
+ * The unified entry point for the AfriCode Framework.
4
+ *
5
+ * Philosophy: Strict by default. Convenient by composition. Secure early.
6
+ */
7
+
8
+ import { createReactiveState, subscribe, createSignal, createEffect } from './state.js';
9
+ import { store, actions } from './store.js';
10
+ import patterns from './patterns.js';
11
+ import * as motion from './motion.js';
12
+ import { hydrate } from './hydration.js';
13
+ import { html, Layout } from './html.js';
14
+ import { schemas, Validation, rules, afri, AfriFieldBuilder, normalizeInput, buildSchema } from './validation.js';
15
+ import { createFramework, getConfig } from './config.js';
16
+ import {
17
+ AfriCodeError, ValidationError, InvalidUrlError,
18
+ SecurityError, CsrfError, RateLimitError,
19
+ DatabaseError, ComponentError
20
+ } from './errors.js';
21
+
22
+ // v5.0.0 additions
23
+ import { initA2UI, A2UIRenderer, A2UIProtocol } from './a2ui.js';
24
+ import { NIDAClient, TIPSClient, AMLComplianceEngine, ComplianceMiddleware } from './compliance.js';
25
+ import { initBunRuntime, HotReloadEngine, BunHTTPServer, BunDatabase, PerformanceMonitor } from './bun-runtime.js';
26
+
27
+ import { componentMap as coreMap } from '../components/index.js';
28
+
29
+ // Utility to initialize the full framework
30
+ export function init(projectComponentMap = {}) {
31
+ if (typeof window !== 'undefined') {
32
+ console.log('🌍 AfriCode SDK Initialized (Zero-Config Mode)');
33
+
34
+ // Merge project map with core map
35
+ const finalMap = { ...coreMap, ...projectComponentMap };
36
+
37
+ if (Object.keys(finalMap).length > 0) {
38
+ hydrate(finalMap);
39
+ }
40
+ }
41
+ }
42
+
43
+ // Grouped exports for cleaner access
44
+ export {
45
+ createReactiveState,
46
+ subscribe,
47
+ createSignal,
48
+ createEffect
49
+ } from './state.js';
50
+
51
+ export {
52
+ store,
53
+ actions,
54
+ patterns,
55
+ motion,
56
+ html,
57
+ Layout,
58
+ schemas,
59
+ Validation,
60
+ rules,
61
+ afri,
62
+ AfriFieldBuilder,
63
+ normalizeInput,
64
+ buildSchema,
65
+ createFramework,
66
+ getConfig,
67
+ AfriCodeError,
68
+ ValidationError,
69
+ InvalidUrlError,
70
+ SecurityError,
71
+ CsrfError,
72
+ RateLimitError,
73
+ DatabaseError,
74
+ ComponentError
75
+ };
76
+
77
+ // v5.0.0 exports
78
+ export {
79
+ initA2UI,
80
+ A2UIRenderer,
81
+ A2UIProtocol,
82
+ NIDAClient,
83
+ TIPSClient,
84
+ AMLComplianceEngine,
85
+ ComplianceMiddleware,
86
+ initBunRuntime,
87
+ HotReloadEngine,
88
+ BunHTTPServer,
89
+ BunDatabase,
90
+ PerformanceMonitor
91
+ };
92
+
93
+ // Default Export
94
+ export default {
95
+ createReactiveState,
96
+ subscribe,
97
+ createSignal,
98
+ createEffect,
99
+ store,
100
+ actions,
101
+ patterns,
102
+ motion,
103
+ html,
104
+ Layout,
105
+ schemas,
106
+ Validation,
107
+ rules,
108
+ afri,
109
+ AfriFieldBuilder,
110
+ normalizeInput,
111
+ buildSchema,
112
+ createFramework,
113
+ getConfig,
114
+ AfriCodeError,
115
+ ValidationError,
116
+ InvalidUrlError,
117
+ SecurityError,
118
+ CsrfError,
119
+ RateLimitError,
120
+ DatabaseError,
121
+ ComponentError,
122
+ init
123
+ };
package/core/seo.js ADDED
@@ -0,0 +1,76 @@
1
+ /**
2
+ * AfriCode SEO Engine 🔍
3
+ *
4
+ * Utilities for metadata management, Open Graph tags, and Sitemap generation.
5
+ * Ensures "African Code" is discoverable by search engines.
6
+ *
7
+ * @module core/seo
8
+ */
9
+
10
+ import { html } from './html.js';
11
+
12
+ /**
13
+ * Generate standard SEO Metadata
14
+ * @param {Object} options
15
+ * @param {string} options.title - Page title
16
+ * @param {string} options.description - Meta description (150-160 chars)
17
+ * @param {string} options.image - URL to Open Graph image (social banner)
18
+ * @param {string} options.url - Canonical URL
19
+ * @param {string} options.type - 'website' or 'article'
20
+ * @returns {string} HTML string of meta tags
21
+ */
22
+ export function generateMetadata({
23
+ title = 'AfriCode App',
24
+ description = 'Built with the Rhythmic Web Framework.',
25
+ image = '/assets/og-default.png',
26
+ url = '',
27
+ type = 'website'
28
+ } = {}) {
29
+ return html`
30
+ <!-- Standard -->
31
+ <title>${title}</title>
32
+ <meta name="description" content="${description}">
33
+ <link rel="canonical" href="${url}">
34
+
35
+ <!-- Open Graph / Facebook -->
36
+ <meta property="og:type" content="${type}">
37
+ <meta property="og:url" content="${url}">
38
+ <meta property="og:title" content="${title}">
39
+ <meta property="og:description" content="${description}">
40
+ <meta property="og:image" content="${image}">
41
+
42
+ <!-- Twitter -->
43
+ <meta property="twitter:card" content="summary_large_image">
44
+ <meta property="twitter:url" content="${url}">
45
+ <meta property="twitter:title" content="${title}">
46
+ <meta property="twitter:description" content="${description}">
47
+ <meta property="twitter:image" content="${image}">
48
+ `;
49
+ }
50
+
51
+ /**
52
+ * Generate XML Sitemap
53
+ * @param {string} baseUrl - Domain (e.g., https://africode.dev)
54
+ * @param {string[]} routes - List of page routes (e.g., ['/', '/docs', '/about'])
55
+ * @returns {string} XML Sitemap content
56
+ */
57
+ export function generateSitemap(baseUrl, routes) {
58
+ const cleanUrl = (url) => url.replace(/\/$/, ''); // Remove trailing slash
59
+ const date = new Date().toISOString().split('T')[0];
60
+
61
+ const urls = routes.map(route => `
62
+ <url>
63
+ <loc>${cleanUrl(baseUrl)}${route}</loc>
64
+ <lastmod>${date}</lastmod>
65
+ <changefreq>weekly</changefreq>
66
+ <priority>${route === '/' ? '1.0' : '0.8'}</priority>
67
+ </url>
68
+ `).join('');
69
+
70
+ return `<?xml version="1.0" encoding="UTF-8"?>
71
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
72
+ ${urls}
73
+ </urlset>`;
74
+ }
75
+
76
+ export default { generateMetadata, generateSitemap };