@intijs/core 0.1.0 → 0.1.1
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/package.json +2 -2
- package/dist/actions/local-fallback.d.ts +0 -23
- package/dist/actions/local-fallback.d.ts.map +0 -1
- package/dist/actions/local-fallback.js +0 -104
- package/dist/api/endpoint.d.ts +0 -13
- package/dist/api/endpoint.d.ts.map +0 -1
- package/dist/api/endpoint.js +0 -43
- package/dist/api/render-block.d.ts +0 -8
- package/dist/api/render-block.d.ts.map +0 -1
- package/dist/api/render-block.js +0 -44
- package/dist/api/types.d.ts +0 -6
- package/dist/api/types.d.ts.map +0 -1
- package/dist/api/types.js +0 -57
- package/dist/api/upload.d.ts +0 -7
- package/dist/api/upload.d.ts.map +0 -1
- package/dist/api/upload.js +0 -64
- package/dist/cache/adapter-cache.d.ts +0 -41
- package/dist/cache/adapter-cache.d.ts.map +0 -1
- package/dist/cache/adapter-cache.js +0 -123
- package/dist/db/index.d.ts +0 -2
- package/dist/db/index.d.ts.map +0 -1
- package/dist/db/index.js +0 -4
- package/dist/db/schema.d.ts +0 -20
- package/dist/db/schema.d.ts.map +0 -1
- package/dist/db/schema.js +0 -69
- package/dist/islands/auto-detect-framework.d.ts +0 -51
- package/dist/islands/auto-detect-framework.d.ts.map +0 -1
- package/dist/islands/auto-detect-framework.js +0 -322
- package/dist/islands/index.d.ts +0 -145
- package/dist/islands/index.d.ts.map +0 -1
- package/dist/islands/index.js +0 -263
- package/dist/islands/renderers/alpine.d.ts +0 -11
- package/dist/islands/renderers/alpine.d.ts.map +0 -1
- package/dist/islands/renderers/alpine.js +0 -25
- package/dist/islands/renderers/react.d.ts +0 -12
- package/dist/islands/renderers/react.d.ts.map +0 -1
- package/dist/islands/renderers/react.js +0 -23
- package/dist/islands/renderers/solid.d.ts +0 -12
- package/dist/islands/renderers/solid.d.ts.map +0 -1
- package/dist/islands/renderers/solid.js +0 -21
- package/dist/islands/renderers/svelte.d.ts +0 -8
- package/dist/islands/renderers/svelte.d.ts.map +0 -1
- package/dist/islands/renderers/svelte.js +0 -15
- package/dist/islands/renderers/vue.d.ts +0 -11
- package/dist/islands/renderers/vue.d.ts.map +0 -1
- package/dist/islands/renderers/vue.js +0 -19
- package/dist/logger.d.ts +0 -43
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -72
- package/dist/middleware/index.d.ts +0 -8
- package/dist/middleware/index.d.ts.map +0 -1
- package/dist/middleware/index.js +0 -43
package/dist/islands/index.js
DELETED
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Multi-Framework Islands System
|
|
3
|
-
*
|
|
4
|
-
* Permite mezclar componentes de diferentes frameworks (React, Vue, Svelte, Solid)
|
|
5
|
-
* en la misma página Astro, con estado compartido entre ellos.
|
|
6
|
-
*/
|
|
7
|
-
export class SharedStateManager {
|
|
8
|
-
state = new Map();
|
|
9
|
-
listeners = new Map();
|
|
10
|
-
/**
|
|
11
|
-
* Obtener valor del estado compartido
|
|
12
|
-
*/
|
|
13
|
-
get(key) {
|
|
14
|
-
return this.state.get(key)?.value ?? null;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Establecer valor y notificar suscriptores
|
|
18
|
-
*/
|
|
19
|
-
set(key, value, sourceIslandId) {
|
|
20
|
-
const entry = this.state.get(key);
|
|
21
|
-
if (entry) {
|
|
22
|
-
entry.value = value;
|
|
23
|
-
// Notificar a todos excepto el origen
|
|
24
|
-
entry.subscribers.forEach(islandId => {
|
|
25
|
-
if (islandId !== sourceIslandId) {
|
|
26
|
-
this.notifyIsland(islandId, key, value);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
this.state.set(key, {
|
|
32
|
-
value,
|
|
33
|
-
subscribers: new Set()
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
// Notificar listeners globales
|
|
37
|
-
this.listeners.get(key)?.forEach(cb => cb(value));
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Suscribir una island a cambios de una key
|
|
41
|
-
*/
|
|
42
|
-
subscribe(islandId, key) {
|
|
43
|
-
if (!this.state.has(key)) {
|
|
44
|
-
this.state.set(key, {
|
|
45
|
-
value: null,
|
|
46
|
-
subscribers: new Set()
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
this.state.get(key).subscribers.add(islandId);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Desuscribir una island
|
|
53
|
-
*/
|
|
54
|
-
unsubscribe(islandId, key) {
|
|
55
|
-
if (key) {
|
|
56
|
-
this.state.get(key)?.subscribers.delete(islandId);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
// Desuscribir de todas las keys
|
|
60
|
-
this.state.forEach(entry => {
|
|
61
|
-
entry.subscribers.delete(islandId);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Registrar listener global
|
|
67
|
-
*/
|
|
68
|
-
onChange(key, callback) {
|
|
69
|
-
if (!this.listeners.has(key)) {
|
|
70
|
-
this.listeners.set(key, new Set());
|
|
71
|
-
}
|
|
72
|
-
this.listeners.get(key).add(callback);
|
|
73
|
-
// Return unsubscribe function
|
|
74
|
-
return () => {
|
|
75
|
-
this.listeners.get(key)?.delete(callback);
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Notificar a una island específica
|
|
80
|
-
*/
|
|
81
|
-
notifyIsland(islandId, key, value) {
|
|
82
|
-
// Emitir evento global que las islands escuchan
|
|
83
|
-
if (typeof window !== 'undefined') {
|
|
84
|
-
window.dispatchEvent(new CustomEvent('inti:state-change', {
|
|
85
|
-
detail: { islandId, key, value }
|
|
86
|
-
}));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Obtener todo el estado (para debug/hydration)
|
|
91
|
-
*/
|
|
92
|
-
getAllState() {
|
|
93
|
-
const result = {};
|
|
94
|
-
this.state.forEach((entry, key) => {
|
|
95
|
-
result[key] = entry.value;
|
|
96
|
-
});
|
|
97
|
-
return result;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Limpiar estado
|
|
101
|
-
*/
|
|
102
|
-
clear() {
|
|
103
|
-
this.state.clear();
|
|
104
|
-
this.listeners.clear();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// ============================================
|
|
108
|
-
// Registry de Islands Multi-Framework
|
|
109
|
-
// ============================================
|
|
110
|
-
export class MultiFrameworkRegistry {
|
|
111
|
-
islands = new Map();
|
|
112
|
-
sharedState = new SharedStateManager();
|
|
113
|
-
frameworkLoaders = new Map();
|
|
114
|
-
loadedFrameworks = new Set();
|
|
115
|
-
/**
|
|
116
|
-
* Registrar una island
|
|
117
|
-
*/
|
|
118
|
-
register(blockType, registration) {
|
|
119
|
-
this.islands.set(blockType, registration);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Obtener registro de island
|
|
123
|
-
*/
|
|
124
|
-
get(blockType) {
|
|
125
|
-
return this.islands.get(blockType);
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Verificar si está registrado
|
|
129
|
-
*/
|
|
130
|
-
has(blockType) {
|
|
131
|
-
return this.islands.has(blockType);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Obtener estado compartido
|
|
135
|
-
*/
|
|
136
|
-
getSharedState() {
|
|
137
|
-
return this.sharedState;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Registrar loader de framework
|
|
141
|
-
*/
|
|
142
|
-
registerFrameworkLoader(framework, loader) {
|
|
143
|
-
this.frameworkLoaders.set(framework, loader);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Cargar framework bajo demanda
|
|
147
|
-
*/
|
|
148
|
-
async loadFramework(framework) {
|
|
149
|
-
// Skip if already loaded
|
|
150
|
-
if (this.loadedFrameworks.has(framework)) {
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
const loader = this.frameworkLoaders.get(framework);
|
|
154
|
-
if (!loader)
|
|
155
|
-
return false;
|
|
156
|
-
try {
|
|
157
|
-
await loader();
|
|
158
|
-
this.loadedFrameworks.add(framework);
|
|
159
|
-
return true;
|
|
160
|
-
}
|
|
161
|
-
catch (error) {
|
|
162
|
-
console.error(`[MultiFramework] Failed to load ${framework}:`, error);
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Obtener todos los frameworks registrados
|
|
168
|
-
*/
|
|
169
|
-
getRegisteredFrameworks() {
|
|
170
|
-
const frameworks = new Set();
|
|
171
|
-
this.islands.forEach(island => {
|
|
172
|
-
frameworks.add(island.framework);
|
|
173
|
-
});
|
|
174
|
-
return Array.from(frameworks);
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Obtener islands por framework
|
|
178
|
-
*/
|
|
179
|
-
getIslandsByFramework(framework) {
|
|
180
|
-
const result = [];
|
|
181
|
-
this.islands.forEach((registration, type) => {
|
|
182
|
-
if (registration.framework === framework) {
|
|
183
|
-
result.push({ type, registration });
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
return result;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
// ============================================
|
|
190
|
-
// Instancia Global
|
|
191
|
-
// ============================================
|
|
192
|
-
let globalRegistry = null;
|
|
193
|
-
export function getMultiFrameworkRegistry() {
|
|
194
|
-
if (!globalRegistry) {
|
|
195
|
-
globalRegistry = new MultiFrameworkRegistry();
|
|
196
|
-
}
|
|
197
|
-
return globalRegistry;
|
|
198
|
-
}
|
|
199
|
-
export function createMultiFrameworkRegistry() {
|
|
200
|
-
return new MultiFrameworkRegistry();
|
|
201
|
-
}
|
|
202
|
-
// ============================================
|
|
203
|
-
// Autodetección de Framework
|
|
204
|
-
// ============================================
|
|
205
|
-
export { detectFrameworkFromPath, detectFrameworkFromCode, loadFrameworkRuntime, preloadFrameworks, analyzeAndPreload } from './auto-detect-framework.js';
|
|
206
|
-
// ============================================
|
|
207
|
-
// Helpers
|
|
208
|
-
// ============================================
|
|
209
|
-
/**
|
|
210
|
-
* Crear registro de island React
|
|
211
|
-
*/
|
|
212
|
-
export function reactIsland(component, options) {
|
|
213
|
-
return {
|
|
214
|
-
framework: 'react',
|
|
215
|
-
component,
|
|
216
|
-
clientDirective: 'idle',
|
|
217
|
-
...options
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Crear registro de island Vue
|
|
222
|
-
*/
|
|
223
|
-
export function vueIsland(component, options) {
|
|
224
|
-
return {
|
|
225
|
-
framework: 'vue',
|
|
226
|
-
component,
|
|
227
|
-
clientDirective: 'idle',
|
|
228
|
-
...options
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Crear registro de island Svelte
|
|
233
|
-
*/
|
|
234
|
-
export function svelteIsland(component, options) {
|
|
235
|
-
return {
|
|
236
|
-
framework: 'svelte',
|
|
237
|
-
component,
|
|
238
|
-
clientDirective: 'idle',
|
|
239
|
-
...options
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Crear registro de island Solid
|
|
244
|
-
*/
|
|
245
|
-
export function solidIsland(component, options) {
|
|
246
|
-
return {
|
|
247
|
-
framework: 'solid',
|
|
248
|
-
component,
|
|
249
|
-
clientDirective: 'idle',
|
|
250
|
-
...options
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Crear registro de island Alpine
|
|
255
|
-
*/
|
|
256
|
-
export function alpineIsland(component, options) {
|
|
257
|
-
return {
|
|
258
|
-
framework: 'alpine',
|
|
259
|
-
component,
|
|
260
|
-
clientDirective: 'load',
|
|
261
|
-
...options
|
|
262
|
-
};
|
|
263
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Alpine Renderer - Cargado bajo demanda desde CDN
|
|
3
|
-
* @runtime-only Este archivo solo funciona en el navegador
|
|
4
|
-
*/
|
|
5
|
-
export declare function renderAlpine(Component: any, container: Element, props: any): Promise<void>;
|
|
6
|
-
declare global {
|
|
7
|
-
interface Window {
|
|
8
|
-
Alpine?: any;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=alpine.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"alpine.d.ts","sourceRoot":"","sources":["../../../src/islands/renderers/alpine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAsB,YAAY,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBhG;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,MAAM,CAAC,EAAE,GAAG,CAAC;KAChB;CACJ"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Alpine Renderer - Cargado bajo demanda desde CDN
|
|
3
|
-
* @runtime-only Este archivo solo funciona en el navegador
|
|
4
|
-
*/
|
|
5
|
-
export async function renderAlpine(Component, container, props) {
|
|
6
|
-
// Cargar Alpine desde CDN si no está disponible
|
|
7
|
-
if (!window.Alpine) {
|
|
8
|
-
// @ts-expect-error CDN import - runtime only
|
|
9
|
-
const module = await import('https://esm.sh/alpinejs@3.13.0');
|
|
10
|
-
window.Alpine = module.default;
|
|
11
|
-
window.Alpine.start();
|
|
12
|
-
}
|
|
13
|
-
// Alpine es declarativo, el componente define el markup
|
|
14
|
-
container.innerHTML = Component.template || '';
|
|
15
|
-
// Si hay datos iniciales, setearlos
|
|
16
|
-
if (props && Object.keys(props).length > 0) {
|
|
17
|
-
const wrapper = document.createElement('div');
|
|
18
|
-
wrapper.setAttribute('x-data', JSON.stringify(props));
|
|
19
|
-
wrapper.innerHTML = container.innerHTML;
|
|
20
|
-
container.innerHTML = '';
|
|
21
|
-
container.appendChild(wrapper);
|
|
22
|
-
}
|
|
23
|
-
// Inicializar Alpine en el container
|
|
24
|
-
window.Alpine.initTree(container);
|
|
25
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React Renderer - Cargado bajo demanda desde CDN
|
|
3
|
-
* @runtime-only Este archivo solo funciona en el navegador
|
|
4
|
-
*/
|
|
5
|
-
export declare function renderReact(Component: any, container: Element, props: any): Promise<void>;
|
|
6
|
-
declare global {
|
|
7
|
-
interface Window {
|
|
8
|
-
React?: any;
|
|
9
|
-
ReactDOM?: any;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=react.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../src/islands/renderers/react.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAsB,WAAW,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB/F;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,QAAQ,CAAC,EAAE,GAAG,CAAC;KAClB;CACJ"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React Renderer - Cargado bajo demanda desde CDN
|
|
3
|
-
* @runtime-only Este archivo solo funciona en el navegador
|
|
4
|
-
*/
|
|
5
|
-
export async function renderReact(Component, container, props) {
|
|
6
|
-
// Cargar React desde CDN si no está disponible
|
|
7
|
-
if (!window.React) {
|
|
8
|
-
// @ts-expect-error CDN import - runtime only
|
|
9
|
-
await import('https://esm.sh/react@18.2.0');
|
|
10
|
-
}
|
|
11
|
-
if (!window.ReactDOM) {
|
|
12
|
-
// @ts-expect-error CDN import - runtime only
|
|
13
|
-
await import('https://esm.sh/react-dom@18.2.0/client');
|
|
14
|
-
}
|
|
15
|
-
const React = window.React;
|
|
16
|
-
const ReactDOM = window.ReactDOM;
|
|
17
|
-
// Limpiar container
|
|
18
|
-
container.innerHTML = '';
|
|
19
|
-
// Crear root y renderizar
|
|
20
|
-
const root = ReactDOM.createRoot(container);
|
|
21
|
-
const element = React.createElement(Component, props);
|
|
22
|
-
root.render(element);
|
|
23
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Solid Renderer - Cargado bajo demanda desde CDN
|
|
3
|
-
* @runtime-only Este archivo solo funciona en el navegador
|
|
4
|
-
*/
|
|
5
|
-
export declare function renderSolid(Component: any, container: Element, props: any): Promise<void>;
|
|
6
|
-
declare global {
|
|
7
|
-
interface Window {
|
|
8
|
-
Solid?: any;
|
|
9
|
-
SolidWeb?: any;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=solid.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solid.d.ts","sourceRoot":"","sources":["../../../src/islands/renderers/solid.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAsB,WAAW,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAmB/F;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,QAAQ,CAAC,EAAE,GAAG,CAAC;KAClB;CACJ"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Solid Renderer - Cargado bajo demanda desde CDN
|
|
3
|
-
* @runtime-only Este archivo solo funciona en el navegador
|
|
4
|
-
*/
|
|
5
|
-
export async function renderSolid(Component, container, props) {
|
|
6
|
-
// Cargar Solid desde CDN si no está disponible
|
|
7
|
-
if (!window.Solid) {
|
|
8
|
-
// @ts-expect-error CDN import - runtime only
|
|
9
|
-
const solid = await import('https://esm.sh/solid-js@1.8.0/dist/solid.js');
|
|
10
|
-
// @ts-expect-error CDN import - runtime only
|
|
11
|
-
const web = await import('https://esm.sh/solid-js@1.8.0/web/dist/web.js');
|
|
12
|
-
window.Solid = solid;
|
|
13
|
-
window.SolidWeb = web;
|
|
14
|
-
}
|
|
15
|
-
const { createComponent } = window.Solid;
|
|
16
|
-
const { render } = window.SolidWeb;
|
|
17
|
-
// Limpiar container
|
|
18
|
-
container.innerHTML = '';
|
|
19
|
-
// Renderizar
|
|
20
|
-
render(() => createComponent(Component, props), container);
|
|
21
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Svelte Renderer - Cargado bajo demanda
|
|
3
|
-
*
|
|
4
|
-
* Nota: Svelte se compila, este renderer es para componentes
|
|
5
|
-
* pre-compilados que exportan el constructor.
|
|
6
|
-
*/
|
|
7
|
-
export declare function renderSvelte(Component: any, container: Element, props: any): Promise<void>;
|
|
8
|
-
//# sourceMappingURL=svelte.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"svelte.d.ts","sourceRoot":"","sources":["../../../src/islands/renderers/svelte.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAsB,YAAY,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAShG"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Svelte Renderer - Cargado bajo demanda
|
|
3
|
-
*
|
|
4
|
-
* Nota: Svelte se compila, este renderer es para componentes
|
|
5
|
-
* pre-compilados que exportan el constructor.
|
|
6
|
-
*/
|
|
7
|
-
export async function renderSvelte(Component, container, props) {
|
|
8
|
-
// Limpiar container
|
|
9
|
-
container.innerHTML = '';
|
|
10
|
-
// Svelte components son clases que se instancian
|
|
11
|
-
new Component({
|
|
12
|
-
target: container,
|
|
13
|
-
props
|
|
14
|
-
});
|
|
15
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vue Renderer - Cargado bajo demanda desde CDN
|
|
3
|
-
* @runtime-only Este archivo solo funciona en el navegador
|
|
4
|
-
*/
|
|
5
|
-
export declare function renderVue(Component: any, container: Element, props: any): Promise<void>;
|
|
6
|
-
declare global {
|
|
7
|
-
interface Window {
|
|
8
|
-
Vue?: any;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=vue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vue.d.ts","sourceRoot":"","sources":["../../../src/islands/renderers/vue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAsB,SAAS,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB7F;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,GAAG,CAAC,EAAE,GAAG,CAAC;KACb;CACJ"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vue Renderer - Cargado bajo demanda desde CDN
|
|
3
|
-
* @runtime-only Este archivo solo funciona en el navegador
|
|
4
|
-
*/
|
|
5
|
-
export async function renderVue(Component, container, props) {
|
|
6
|
-
// Cargar Vue desde CDN si no está disponible
|
|
7
|
-
if (!window.Vue) {
|
|
8
|
-
// @ts-expect-error CDN import - runtime only
|
|
9
|
-
await import('https://esm.sh/vue@3.3.0/dist/vue.esm-browser.js');
|
|
10
|
-
}
|
|
11
|
-
const { createApp, h } = window.Vue;
|
|
12
|
-
// Limpiar container
|
|
13
|
-
container.innerHTML = '';
|
|
14
|
-
// Crear app y renderizar
|
|
15
|
-
const app = createApp({
|
|
16
|
-
render: () => h(Component, props)
|
|
17
|
-
});
|
|
18
|
-
app.mount(container);
|
|
19
|
-
}
|
package/dist/logger.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { z } from 'astro:schema';
|
|
2
|
-
declare const logSchema: z.ZodObject<{
|
|
3
|
-
level: z.ZodEnum<["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]>;
|
|
4
|
-
service: z.ZodDefault<z.ZodString>;
|
|
5
|
-
event: z.ZodString;
|
|
6
|
-
message: z.ZodOptional<z.ZodString>;
|
|
7
|
-
request_id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
8
|
-
user_id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
9
|
-
error_code: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
10
|
-
trace_id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
11
|
-
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
12
|
-
}, "strip", z.ZodTypeAny, {
|
|
13
|
-
level: "DEBUG" | "INFO" | "WARNING" | "ERROR" | "CRITICAL";
|
|
14
|
-
service: string;
|
|
15
|
-
event: string;
|
|
16
|
-
context?: Record<string, any> | undefined;
|
|
17
|
-
message?: string | undefined;
|
|
18
|
-
request_id?: string | null | undefined;
|
|
19
|
-
user_id?: string | null | undefined;
|
|
20
|
-
error_code?: string | null | undefined;
|
|
21
|
-
trace_id?: string | null | undefined;
|
|
22
|
-
}, {
|
|
23
|
-
level: "DEBUG" | "INFO" | "WARNING" | "ERROR" | "CRITICAL";
|
|
24
|
-
event: string;
|
|
25
|
-
context?: Record<string, any> | undefined;
|
|
26
|
-
message?: string | undefined;
|
|
27
|
-
service?: string | undefined;
|
|
28
|
-
request_id?: string | null | undefined;
|
|
29
|
-
user_id?: string | null | undefined;
|
|
30
|
-
error_code?: string | null | undefined;
|
|
31
|
-
trace_id?: string | null | undefined;
|
|
32
|
-
}>;
|
|
33
|
-
export type LogEntry = z.input<typeof logSchema>;
|
|
34
|
-
export declare class IntiLogger {
|
|
35
|
-
/**
|
|
36
|
-
* Logs a structured JSON error to stdout (for Promtail/Loki) and Astro DB
|
|
37
|
-
*/
|
|
38
|
-
static log(entry: LogEntry): Promise<void>;
|
|
39
|
-
static info(event: string, context?: Partial<LogEntry>): Promise<void>;
|
|
40
|
-
static error(event: string, error_code: string, context?: Partial<LogEntry>): Promise<void>;
|
|
41
|
-
}
|
|
42
|
-
export {};
|
|
43
|
-
//# sourceMappingURL=logger.d.ts.map
|
package/dist/logger.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAGjC,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUb,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAEjD,qBAAa,UAAU;IAErB;;OAEG;WACU,GAAG,CAAC,KAAK,EAAE,QAAQ;IAgDhC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC;IAItD,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC;CAG5E"}
|
package/dist/logger.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { db } from 'astro:db';
|
|
2
|
-
import { IntiLog } from './db/schema.js';
|
|
3
|
-
import { z } from 'astro:schema';
|
|
4
|
-
// 1. ZOD SCHEMA (Cumpliendo con el estándar Enterprise para Promtail/Loki)
|
|
5
|
-
const logSchema = z.object({
|
|
6
|
-
level: z.enum(['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']),
|
|
7
|
-
service: z.string().default('inti.core'),
|
|
8
|
-
event: z.string().regex(/^[a-z_]+$/, 'Debe ser snake_case').min(1),
|
|
9
|
-
message: z.string().optional(),
|
|
10
|
-
request_id: z.string().uuid().optional().nullable(),
|
|
11
|
-
user_id: z.string().optional().nullable(),
|
|
12
|
-
error_code: z.string().optional().nullable(),
|
|
13
|
-
trace_id: z.string().optional().nullable(),
|
|
14
|
-
context: z.record(z.any()).optional()
|
|
15
|
-
});
|
|
16
|
-
export class IntiLogger {
|
|
17
|
-
/**
|
|
18
|
-
* Logs a structured JSON error to stdout (for Promtail/Loki) and Astro DB
|
|
19
|
-
*/
|
|
20
|
-
static async log(entry) {
|
|
21
|
-
try {
|
|
22
|
-
// 2. VALIDATION (Usando Zod para garantizar el estándar)
|
|
23
|
-
const validated = logSchema.parse(entry);
|
|
24
|
-
const logOutput = {
|
|
25
|
-
timestamp: new Date().toISOString(),
|
|
26
|
-
level: validated.level,
|
|
27
|
-
service: validated.service,
|
|
28
|
-
event: validated.event,
|
|
29
|
-
message: validated.message || validated.event,
|
|
30
|
-
request_id: validated.request_id || null,
|
|
31
|
-
user_id: validated.user_id || null,
|
|
32
|
-
error_code: validated.error_code || null,
|
|
33
|
-
trace_id: validated.trace_id || null,
|
|
34
|
-
...validated.context // Esparce el contexto adicional
|
|
35
|
-
};
|
|
36
|
-
// OPTION A: JSON Estructurado para Promtail/Loki (SIN COLORES)
|
|
37
|
-
if (['ERROR', 'CRITICAL'].includes(validated.level)) {
|
|
38
|
-
console.error(JSON.stringify(logOutput));
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
console.log(JSON.stringify(logOutput));
|
|
42
|
-
}
|
|
43
|
-
// OPTION B: Guardar en Astro DB para panel local de Inti
|
|
44
|
-
if (['ERROR', 'CRITICAL'].includes(validated.level)) {
|
|
45
|
-
await db.insert(IntiLog).values({
|
|
46
|
-
id: crypto.randomUUID(),
|
|
47
|
-
level: validated.level,
|
|
48
|
-
message: validated.message || validated.event,
|
|
49
|
-
context: logOutput,
|
|
50
|
-
createdAt: new Date()
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
// Fallback si Zod rechaza el log (no cumple el formato)
|
|
56
|
-
console.error(JSON.stringify({
|
|
57
|
-
timestamp: new Date().toISOString(),
|
|
58
|
-
level: 'CRITICAL',
|
|
59
|
-
service: 'inti.logger',
|
|
60
|
-
event: 'logger_validation_failed',
|
|
61
|
-
message: 'Intento de loggear formato inválido',
|
|
62
|
-
error_code: 'INTI_LOG_001'
|
|
63
|
-
}));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
static info(event, context) {
|
|
67
|
-
return this.log({ level: 'INFO', event, ...context });
|
|
68
|
-
}
|
|
69
|
-
static error(event, error_code, context) {
|
|
70
|
-
return this.log({ level: 'ERROR', event, error_code, ...context });
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Inti Meta-CMS Authentication Middleware
|
|
3
|
-
*
|
|
4
|
-
* Users should export this from their src/middleware.ts:
|
|
5
|
-
* export const onRequest = intiMiddleware;
|
|
6
|
-
*/
|
|
7
|
-
export declare const intiMiddleware: import("astro").MiddlewareHandler;
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,eAAO,MAAM,cAAc,mCAwCzB,CAAC"}
|
package/dist/middleware/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { defineMiddleware } from 'astro:middleware';
|
|
2
|
-
/**
|
|
3
|
-
* Inti Meta-CMS Authentication Middleware
|
|
4
|
-
*
|
|
5
|
-
* Users should export this from their src/middleware.ts:
|
|
6
|
-
* export const onRequest = intiMiddleware;
|
|
7
|
-
*/
|
|
8
|
-
export const intiMiddleware = defineMiddleware(async (context, next) => {
|
|
9
|
-
const url = new URL(context.request.url);
|
|
10
|
-
// Only protect /admin routes, but not the login page itself
|
|
11
|
-
if (url.pathname.startsWith('/admin') && url.pathname !== '/admin/login') {
|
|
12
|
-
const session = context.cookies.get('inti_session');
|
|
13
|
-
// If no valid session cookie, redirect to login
|
|
14
|
-
if (!session || !session.value) {
|
|
15
|
-
return context.redirect('/admin/login');
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
// For API protection
|
|
19
|
-
if (url.pathname.startsWith('/api/inti/') && context.request.method !== 'GET') {
|
|
20
|
-
// Only allow mutations with auth or specific API keys
|
|
21
|
-
const authHeader = context.request.headers.get('Authorization');
|
|
22
|
-
const session = context.cookies.get('inti_session');
|
|
23
|
-
if (!session && (!authHeader || !authHeader.startsWith('Bearer '))) {
|
|
24
|
-
return new Response(JSON.stringify({ error: 'Unauthorized' }), {
|
|
25
|
-
status: 401,
|
|
26
|
-
headers: { 'Content-Type': 'application/json' }
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
// --- CONTENT BRANCHING (Version Control) ---
|
|
31
|
-
// Detect if user wants to view a specific branch (e.g. ?branch=black-friday)
|
|
32
|
-
const branchQuery = url.searchParams.get('branch');
|
|
33
|
-
if (branchQuery) {
|
|
34
|
-
// Set a cookie so they stay on this branch while navigating
|
|
35
|
-
context.cookies.set('inti_branch', branchQuery, { path: '/' });
|
|
36
|
-
context.locals.intiBranch = branchQuery;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
// Fallback to cookie or 'main'
|
|
40
|
-
context.locals.intiBranch = context.cookies.get('inti_branch')?.value || 'main';
|
|
41
|
-
}
|
|
42
|
-
return next();
|
|
43
|
-
});
|