@africode/core 5.0.3 → 5.0.4
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/core/cli/commands/build.js +2 -1
- package/core/sdk-browser.js +140 -0
- package/dist/africode.js +184 -183
- package/dist/africode.js.map +16 -9
- package/dist/build-info.json +3 -3
- package/package.json +6 -5
- package/templates/starter/src/pages/index.html +2 -2
- package/templates/starter-3d/src/pages/index.html +2 -2
- package/templates/starter-react/src/pages/index.html +2 -2
- package/templates/starter-tailwind/src/pages/index.html +2 -2
- package/src/index.ts +0 -196
|
@@ -30,7 +30,8 @@ export async function build() {
|
|
|
30
30
|
const __filename = fileURLToPath(import.meta.url);
|
|
31
31
|
const __dirname = path.dirname(__filename);
|
|
32
32
|
const frameworkCoreDir = path.resolve(__dirname, '../../');
|
|
33
|
-
|
|
33
|
+
// Use sdk-browser.js for browser builds to avoid server-only imports
|
|
34
|
+
const sdkPath = path.join(frameworkCoreDir, 'sdk-browser.js');
|
|
34
35
|
const projectComponentsPath = path.resolve(cwd, `${componentsDir}/index.js`);
|
|
35
36
|
|
|
36
37
|
// Check if paths exist before building
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AfriCode Browser SDK
|
|
3
|
+
* Client-side only entry point. Does not include server-only APIs.
|
|
4
|
+
*
|
|
5
|
+
* Use this for Bun.build({ target: 'browser' })
|
|
6
|
+
* Use the full sdk.js for server/SSR contexts
|
|
7
|
+
*
|
|
8
|
+
* Philosophy: Browser-safe, tree-shakeable, zero server APIs
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { createReactiveState, subscribe, createSignal, createEffect } from './state.js';
|
|
12
|
+
import { store, actions } from './store.js';
|
|
13
|
+
import patterns from './patterns.js';
|
|
14
|
+
import * as motion from './motion.js';
|
|
15
|
+
import { hydrate } from './hydration.js';
|
|
16
|
+
import { html, Layout } from './html.js';
|
|
17
|
+
import { schemas, Validation, rules, afri, AfriFieldBuilder, normalizeInput, buildSchema } from './validation.js';
|
|
18
|
+
import { createFramework, getConfig } from './config.js';
|
|
19
|
+
import { getRequestIdentity, parseCookieHeader, createSessionId, SESSION_COOKIE_NAME } from './request-identity.js';
|
|
20
|
+
import { sessionStore } from './session-store.js';
|
|
21
|
+
import { actions as runtimeActions } from './actions.js';
|
|
22
|
+
import { MiddlewareManager, loggerMiddleware, authMiddleware } from './middleware.js';
|
|
23
|
+
import {
|
|
24
|
+
AfriCodeError, ValidationError, InvalidUrlError,
|
|
25
|
+
SecurityError, CsrfError, RateLimitError,
|
|
26
|
+
DatabaseError, ComponentError
|
|
27
|
+
} from './errors.js';
|
|
28
|
+
|
|
29
|
+
// v5.0.0 Browser-safe exports (A2UI protocol)
|
|
30
|
+
import { initA2UI, A2UIRenderer, A2UIProtocol } from './a2ui.js';
|
|
31
|
+
|
|
32
|
+
import { componentMap as coreMap } from '../components/index.js';
|
|
33
|
+
|
|
34
|
+
// Utility to initialize the browser framework
|
|
35
|
+
export function init(projectComponentMap = {}) {
|
|
36
|
+
if (typeof window !== 'undefined') {
|
|
37
|
+
console.log('🌍 AfriCode Browser SDK Initialized');
|
|
38
|
+
|
|
39
|
+
// Merge project map with core map
|
|
40
|
+
const finalMap = { ...coreMap, ...projectComponentMap };
|
|
41
|
+
|
|
42
|
+
if (Object.keys(finalMap).length > 0) {
|
|
43
|
+
hydrate(finalMap);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Browser-safe grouped exports
|
|
49
|
+
export {
|
|
50
|
+
createReactiveState,
|
|
51
|
+
subscribe,
|
|
52
|
+
createSignal,
|
|
53
|
+
createEffect
|
|
54
|
+
} from './state.js';
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
store,
|
|
58
|
+
actions,
|
|
59
|
+
patterns,
|
|
60
|
+
motion,
|
|
61
|
+
html,
|
|
62
|
+
Layout,
|
|
63
|
+
schemas,
|
|
64
|
+
Validation,
|
|
65
|
+
rules,
|
|
66
|
+
afri,
|
|
67
|
+
AfriFieldBuilder,
|
|
68
|
+
normalizeInput,
|
|
69
|
+
buildSchema,
|
|
70
|
+
createFramework,
|
|
71
|
+
getConfig,
|
|
72
|
+
getRequestIdentity,
|
|
73
|
+
parseCookieHeader,
|
|
74
|
+
createSessionId,
|
|
75
|
+
SESSION_COOKIE_NAME,
|
|
76
|
+
sessionStore,
|
|
77
|
+
runtimeActions,
|
|
78
|
+
MiddlewareManager,
|
|
79
|
+
loggerMiddleware,
|
|
80
|
+
authMiddleware,
|
|
81
|
+
AfriCodeError,
|
|
82
|
+
ValidationError,
|
|
83
|
+
InvalidUrlError,
|
|
84
|
+
SecurityError,
|
|
85
|
+
CsrfError,
|
|
86
|
+
RateLimitError,
|
|
87
|
+
DatabaseError,
|
|
88
|
+
ComponentError
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// Browser-only exports (A2UI for AI-safe rendering)
|
|
92
|
+
export {
|
|
93
|
+
initA2UI,
|
|
94
|
+
A2UIRenderer,
|
|
95
|
+
A2UIProtocol
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Default Export (Browser-safe)
|
|
99
|
+
export default {
|
|
100
|
+
createReactiveState,
|
|
101
|
+
subscribe,
|
|
102
|
+
createSignal,
|
|
103
|
+
createEffect,
|
|
104
|
+
store,
|
|
105
|
+
actions,
|
|
106
|
+
patterns,
|
|
107
|
+
motion,
|
|
108
|
+
html,
|
|
109
|
+
Layout,
|
|
110
|
+
schemas,
|
|
111
|
+
Validation,
|
|
112
|
+
rules,
|
|
113
|
+
afri,
|
|
114
|
+
AfriFieldBuilder,
|
|
115
|
+
normalizeInput,
|
|
116
|
+
buildSchema,
|
|
117
|
+
createFramework,
|
|
118
|
+
getConfig,
|
|
119
|
+
getRequestIdentity,
|
|
120
|
+
parseCookieHeader,
|
|
121
|
+
createSessionId,
|
|
122
|
+
SESSION_COOKIE_NAME,
|
|
123
|
+
sessionStore,
|
|
124
|
+
runtimeActions,
|
|
125
|
+
MiddlewareManager,
|
|
126
|
+
loggerMiddleware,
|
|
127
|
+
authMiddleware,
|
|
128
|
+
AfriCodeError,
|
|
129
|
+
ValidationError,
|
|
130
|
+
InvalidUrlError,
|
|
131
|
+
SecurityError,
|
|
132
|
+
CsrfError,
|
|
133
|
+
RateLimitError,
|
|
134
|
+
DatabaseError,
|
|
135
|
+
ComponentError,
|
|
136
|
+
initA2UI,
|
|
137
|
+
A2UIRenderer,
|
|
138
|
+
A2UIProtocol,
|
|
139
|
+
init
|
|
140
|
+
};
|