@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/db/schema.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { defineTable, column, NOW } from '@astrojs/db';
|
|
2
|
-
/**
|
|
3
|
-
* Users table for the Admin UI and API access
|
|
4
|
-
*/
|
|
5
|
-
export const IntiLog = defineTable({
|
|
6
|
-
columns: {
|
|
7
|
-
id: column.text({ primaryKey: true }),
|
|
8
|
-
level: column.text(), // 'info', 'warn', 'error', 'fatal'
|
|
9
|
-
message: column.text(),
|
|
10
|
-
context: column.json({ optional: true }), // Additional error details, stack traces, etc.
|
|
11
|
-
createdAt: column.date({ default: NOW }),
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
export const IntiUser = defineTable({
|
|
15
|
-
columns: {
|
|
16
|
-
id: column.text({ primaryKey: true }),
|
|
17
|
-
email: column.text({ unique: true }),
|
|
18
|
-
name: column.text(),
|
|
19
|
-
passwordHash: column.text(), // Security: Hashed password
|
|
20
|
-
role: column.text({ default: 'editor' }), // 'admin', 'editor', etc.
|
|
21
|
-
sessionToken: column.text({ optional: true }), // For secure cookie validation
|
|
22
|
-
createdAt: column.date({ default: NOW }),
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
/**
|
|
26
|
-
* Registry of dynamic collections that the user defines in the Meta-CMS
|
|
27
|
-
* (In a full dynamic CMS, documents reference collections)
|
|
28
|
-
*/
|
|
29
|
-
export const IntiCollection = defineTable({
|
|
30
|
-
columns: {
|
|
31
|
-
id: column.text({ primaryKey: true }),
|
|
32
|
-
name: column.text(), // e.g., "Blog Posts"
|
|
33
|
-
slug: column.text({ unique: true }), // e.g., "posts"
|
|
34
|
-
schema: column.json(), // JSON representation of fields
|
|
35
|
-
createdAt: column.date({ default: NOW }),
|
|
36
|
-
updatedAt: column.date({ default: NOW }),
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
/**
|
|
40
|
-
* Branches for Content Versioning (e.g., 'main', 'black-friday-promo')
|
|
41
|
-
*/
|
|
42
|
-
export const IntiBranch = defineTable({
|
|
43
|
-
columns: {
|
|
44
|
-
id: column.text({ primaryKey: true }),
|
|
45
|
-
name: column.text(),
|
|
46
|
-
isDefault: column.boolean({ default: false }),
|
|
47
|
-
createdAt: column.date({ default: NOW }),
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
/**
|
|
51
|
-
* The actual content documents
|
|
52
|
-
* They hold dynamic data in a JSON column to allow schema flexibility
|
|
53
|
-
*/
|
|
54
|
-
export const IntiDocument = defineTable({
|
|
55
|
-
columns: {
|
|
56
|
-
id: column.text({ primaryKey: true }),
|
|
57
|
-
collectionId: column.text({ references: () => IntiCollection.columns.id }),
|
|
58
|
-
branchId: column.text({ references: () => IntiBranch.columns.id, optional: true }), // For Branching
|
|
59
|
-
slug: column.text(),
|
|
60
|
-
title: column.text(),
|
|
61
|
-
status: column.text({ default: 'draft' }), // 'draft', 'published', 'archived'
|
|
62
|
-
data: column.json(), // The dynamic fields based on IntiCollection.schema
|
|
63
|
-
authorId: column.text({ references: () => IntiUser.columns.id, optional: true }),
|
|
64
|
-
version: column.number({ default: 1 }), // For version history
|
|
65
|
-
createdAt: column.date({ default: NOW }),
|
|
66
|
-
updatedAt: column.date({ default: NOW }),
|
|
67
|
-
},
|
|
68
|
-
// Indexes can be added here
|
|
69
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Autodetección de Framework
|
|
3
|
-
*
|
|
4
|
-
* Detecta automáticamente el framework de un componente
|
|
5
|
-
* para cargar solo el runtime necesario.
|
|
6
|
-
*
|
|
7
|
-
* @runtime-only Los imports de CDN solo funcionan en navegador
|
|
8
|
-
*/
|
|
9
|
-
import type { FrameworkType } from './index.js';
|
|
10
|
-
export interface FrameworkDetectionResult {
|
|
11
|
-
framework: FrameworkType;
|
|
12
|
-
confidence: number;
|
|
13
|
-
reason: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Detecta el framework basado en la extensión del archivo
|
|
17
|
-
*/
|
|
18
|
-
export declare function detectFrameworkFromPath(path: string): FrameworkDetectionResult;
|
|
19
|
-
/**
|
|
20
|
-
* Detecta el framework basado en el contenido del código
|
|
21
|
-
* (para cuando no tenemos la ruta del archivo)
|
|
22
|
-
*/
|
|
23
|
-
export declare function detectFrameworkFromCode(code: string): FrameworkDetectionResult;
|
|
24
|
-
/**
|
|
25
|
-
* Carga el runtime del framework bajo demanda
|
|
26
|
-
* Solo carga el framework que se necesita
|
|
27
|
-
*/
|
|
28
|
-
export declare function loadFrameworkRuntime(framework: FrameworkType): Promise<boolean>;
|
|
29
|
-
/**
|
|
30
|
-
* Precarga los runtimes de frameworks usados frecuentemente
|
|
31
|
-
* Útil cuando sabes qué frameworks usará la página
|
|
32
|
-
*/
|
|
33
|
-
export declare function preloadFrameworks(frameworks: FrameworkType[]): void;
|
|
34
|
-
/**
|
|
35
|
-
* Analiza la página para detectar qué frameworks se usan
|
|
36
|
-
* y precargarlos
|
|
37
|
-
*/
|
|
38
|
-
export declare function analyzeAndPreload(): void;
|
|
39
|
-
declare global {
|
|
40
|
-
interface Window {
|
|
41
|
-
React?: any;
|
|
42
|
-
ReactDOM?: any;
|
|
43
|
-
preact?: any;
|
|
44
|
-
Vue?: any;
|
|
45
|
-
Solid?: any;
|
|
46
|
-
Alpine?: any;
|
|
47
|
-
lit?: any;
|
|
48
|
-
svelte?: any;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=auto-detect-framework.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-detect-framework.d.ts","sourceRoot":"","sources":["../../src/islands/auto-detect-framework.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,wBAAwB;IACrC,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,wBAAwB,CAyE9E;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,wBAAwB,CAmG9E;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACtC,SAAS,EAAE,aAAa,GACzB,OAAO,CAAC,OAAO,CAAC,CA+BlB;AA6FD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,IAAI,CAanE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAiBxC;AAMD,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,QAAQ,CAAC,EAAE,GAAG,CAAC;QACf,MAAM,CAAC,EAAE,GAAG,CAAC;QACb,GAAG,CAAC,EAAE,GAAG,CAAC;QACV,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,MAAM,CAAC,EAAE,GAAG,CAAC;QACb,GAAG,CAAC,EAAE,GAAG,CAAC;QACV,MAAM,CAAC,EAAE,GAAG,CAAC;KAChB;CACJ"}
|
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Autodetección de Framework
|
|
3
|
-
*
|
|
4
|
-
* Detecta automáticamente el framework de un componente
|
|
5
|
-
* para cargar solo el runtime necesario.
|
|
6
|
-
*
|
|
7
|
-
* @runtime-only Los imports de CDN solo funcionan en navegador
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Detecta el framework basado en la extensión del archivo
|
|
11
|
-
*/
|
|
12
|
-
export function detectFrameworkFromPath(path) {
|
|
13
|
-
const lowerPath = path.toLowerCase();
|
|
14
|
-
// Check naming conventions FIRST (before extensions)
|
|
15
|
-
// Solid naming: Component.solid.tsx
|
|
16
|
-
if (lowerPath.includes('.solid.')) {
|
|
17
|
-
return {
|
|
18
|
-
framework: 'solid',
|
|
19
|
-
confidence: 0.95,
|
|
20
|
-
reason: 'Solid naming convention'
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
// Alpine naming: Component.alpine.js
|
|
24
|
-
if (lowerPath.includes('.alpine.')) {
|
|
25
|
-
return {
|
|
26
|
-
framework: 'alpine',
|
|
27
|
-
confidence: 0.95,
|
|
28
|
-
reason: 'Alpine naming convention'
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// Vue
|
|
32
|
-
if (lowerPath.endsWith('.vue')) {
|
|
33
|
-
return {
|
|
34
|
-
framework: 'vue',
|
|
35
|
-
confidence: 1.0,
|
|
36
|
-
reason: '.vue extension'
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
// Svelte
|
|
40
|
-
if (lowerPath.endsWith('.svelte')) {
|
|
41
|
-
return {
|
|
42
|
-
framework: 'svelte',
|
|
43
|
-
confidence: 1.0,
|
|
44
|
-
reason: '.svelte extension'
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
// React / Preact (JSX/TSX)
|
|
48
|
-
if (lowerPath.match(/\.(tsx|jsx)$/)) {
|
|
49
|
-
return {
|
|
50
|
-
framework: 'react',
|
|
51
|
-
confidence: 0.9,
|
|
52
|
-
reason: 'TSX/JSX extension'
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
// Lit
|
|
56
|
-
if (lowerPath.endsWith('.lit.ts') || lowerPath.endsWith('.lit.js')) {
|
|
57
|
-
return {
|
|
58
|
-
framework: 'lit',
|
|
59
|
-
confidence: 0.9,
|
|
60
|
-
reason: 'Lit naming convention'
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
// Astro (por defecto para .astro)
|
|
64
|
-
if (lowerPath.endsWith('.astro')) {
|
|
65
|
-
return {
|
|
66
|
-
framework: 'astro',
|
|
67
|
-
confidence: 1.0,
|
|
68
|
-
reason: '.astro extension'
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
// Fallback a React para .jsx/.tsx sin especificar
|
|
72
|
-
return {
|
|
73
|
-
framework: 'react',
|
|
74
|
-
confidence: 0.5,
|
|
75
|
-
reason: 'Default fallback'
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Detecta el framework basado en el contenido del código
|
|
80
|
-
* (para cuando no tenemos la ruta del archivo)
|
|
81
|
-
*/
|
|
82
|
-
export function detectFrameworkFromCode(code) {
|
|
83
|
-
const codeSample = code.slice(0, 2000).toLowerCase();
|
|
84
|
-
const trimmedCode = code.trim().toLowerCase();
|
|
85
|
-
// Astro - frontmatter at the start of file
|
|
86
|
-
// Astro files start with --- followed by frontmatter and another ---
|
|
87
|
-
if (trimmedCode.startsWith('---') &&
|
|
88
|
-
(trimmedCode.includes('</script>') || /^---\s*\n[\s\S]*?\n---/.test(code))) {
|
|
89
|
-
return {
|
|
90
|
-
framework: 'astro',
|
|
91
|
-
confidence: 0.95,
|
|
92
|
-
reason: 'Astro frontmatter detected'
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
// Svelte
|
|
96
|
-
if (codeSample.includes('<script') && codeSample.includes('export let') &&
|
|
97
|
-
(codeSample.includes('$:') || codeSample.includes('{#if'))) {
|
|
98
|
-
return {
|
|
99
|
-
framework: 'svelte',
|
|
100
|
-
confidence: 0.95,
|
|
101
|
-
reason: 'Svelte syntax detected'
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
// Vue Composition API
|
|
105
|
-
if (codeSample.includes('setup()') || codeSample.includes('<script setup>') ||
|
|
106
|
-
codeSample.includes('defineprops') || codeSample.includes('defineemits')) {
|
|
107
|
-
return {
|
|
108
|
-
framework: 'vue',
|
|
109
|
-
confidence: 0.95,
|
|
110
|
-
reason: 'Vue Composition API detected'
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
// Vue Options API
|
|
114
|
-
if (codeSample.includes('export default {') &&
|
|
115
|
-
(codeSample.includes('data()') || codeSample.includes('methods:'))) {
|
|
116
|
-
return {
|
|
117
|
-
framework: 'vue',
|
|
118
|
-
confidence: 0.9,
|
|
119
|
-
reason: 'Vue Options API detected'
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
// Solid
|
|
123
|
-
if (codeSample.includes('createsignal') || codeSample.includes('createeffect') ||
|
|
124
|
-
codeSample.includes('from \'solid-js\'') || codeSample.includes('from "solid-js"')) {
|
|
125
|
-
return {
|
|
126
|
-
framework: 'solid',
|
|
127
|
-
confidence: 0.95,
|
|
128
|
-
reason: 'SolidJS imports detected'
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
// Alpine
|
|
132
|
-
if (codeSample.includes('x-data') || codeSample.includes('x-show') ||
|
|
133
|
-
codeSample.includes('alpine')) {
|
|
134
|
-
return {
|
|
135
|
-
framework: 'alpine',
|
|
136
|
-
confidence: 0.9,
|
|
137
|
-
reason: 'Alpine.js directives detected'
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
// React/Preact hooks
|
|
141
|
-
if (codeSample.includes('usestate') || codeSample.includes('useeffect') ||
|
|
142
|
-
codeSample.includes('react')) {
|
|
143
|
-
return {
|
|
144
|
-
framework: 'react',
|
|
145
|
-
confidence: 0.9,
|
|
146
|
-
reason: 'React hooks detected'
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
// Lit
|
|
150
|
-
if (codeSample.includes('lit-element') || codeSample.includes('customelement') ||
|
|
151
|
-
codeSample.includes('@property')) {
|
|
152
|
-
return {
|
|
153
|
-
framework: 'lit',
|
|
154
|
-
confidence: 0.95,
|
|
155
|
-
reason: 'Lit decorators detected'
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
// React por defecto (JSX/TSX sin especificar)
|
|
159
|
-
if (codeSample.includes('jsx') || codeSample.includes('react')) {
|
|
160
|
-
return {
|
|
161
|
-
framework: 'react',
|
|
162
|
-
confidence: 0.7,
|
|
163
|
-
reason: 'JSX/React indicators'
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
return {
|
|
167
|
-
framework: 'react',
|
|
168
|
-
confidence: 0.3,
|
|
169
|
-
reason: 'Default fallback'
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Carga el runtime del framework bajo demanda
|
|
174
|
-
* Solo carga el framework que se necesita
|
|
175
|
-
*/
|
|
176
|
-
export async function loadFrameworkRuntime(framework) {
|
|
177
|
-
// Verificar si ya está cargado
|
|
178
|
-
if (isFrameworkLoaded(framework)) {
|
|
179
|
-
return true;
|
|
180
|
-
}
|
|
181
|
-
const loaders = {
|
|
182
|
-
react: loadReact,
|
|
183
|
-
preact: loadPreact,
|
|
184
|
-
vue: loadVue,
|
|
185
|
-
svelte: loadSvelte,
|
|
186
|
-
solid: loadSolid,
|
|
187
|
-
alpine: loadAlpine,
|
|
188
|
-
lit: loadLit,
|
|
189
|
-
astro: async () => { } // Astro no necesita runtime en cliente
|
|
190
|
-
};
|
|
191
|
-
const loader = loaders[framework];
|
|
192
|
-
if (!loader) {
|
|
193
|
-
console.warn(`[Inti] No loader for framework: ${framework}`);
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
try {
|
|
197
|
-
await loader();
|
|
198
|
-
markFrameworkLoaded(framework);
|
|
199
|
-
return true;
|
|
200
|
-
}
|
|
201
|
-
catch (error) {
|
|
202
|
-
console.error(`[Inti] Failed to load ${framework}:`, error);
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Verifica si un framework ya está cargado
|
|
208
|
-
*/
|
|
209
|
-
function isFrameworkLoaded(framework) {
|
|
210
|
-
const globals = {
|
|
211
|
-
react: ['React', 'ReactDOM'],
|
|
212
|
-
preact: ['preact'],
|
|
213
|
-
vue: ['Vue'],
|
|
214
|
-
svelte: ['svelte'],
|
|
215
|
-
solid: ['Solid'],
|
|
216
|
-
alpine: ['Alpine'],
|
|
217
|
-
lit: ['lit'],
|
|
218
|
-
astro: []
|
|
219
|
-
};
|
|
220
|
-
const checks = globals[framework];
|
|
221
|
-
if (!checks)
|
|
222
|
-
return false;
|
|
223
|
-
return checks.some(g => typeof window[g] !== 'undefined');
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Marca un framework como cargado
|
|
227
|
-
*/
|
|
228
|
-
const loadedFrameworks = new Set();
|
|
229
|
-
function markFrameworkLoaded(framework) {
|
|
230
|
-
loadedFrameworks.add(framework);
|
|
231
|
-
}
|
|
232
|
-
// ============================================
|
|
233
|
-
// Loaders específicos (import dinámico desde CDN)
|
|
234
|
-
// Los @ts-expect-error son necesarios porque estos imports CDN
|
|
235
|
-
// no pueden ser resueltos por TypeScript en tiempo de compilación
|
|
236
|
-
// ============================================
|
|
237
|
-
async function loadReact() {
|
|
238
|
-
// @ts-expect-error CDN import - runtime only
|
|
239
|
-
if (!window.React)
|
|
240
|
-
await import('https://esm.sh/react@18.2.0');
|
|
241
|
-
// @ts-expect-error CDN import - runtime only
|
|
242
|
-
if (!window.ReactDOM)
|
|
243
|
-
await import('https://esm.sh/react-dom@18.2.0/client');
|
|
244
|
-
}
|
|
245
|
-
async function loadPreact() {
|
|
246
|
-
if (!window.preact) {
|
|
247
|
-
// @ts-expect-error CDN import - runtime only
|
|
248
|
-
await import('https://esm.sh/preact@10.18.0');
|
|
249
|
-
// @ts-expect-error CDN import - runtime only
|
|
250
|
-
await import('https://esm.sh/preact@10.18.0/hooks');
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
async function loadVue() {
|
|
254
|
-
if (!window.Vue) {
|
|
255
|
-
// @ts-expect-error CDN import - runtime only
|
|
256
|
-
await import('https://esm.sh/vue@3.3.0');
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
async function loadSvelte() {
|
|
260
|
-
// Svelte no tiene runtime global, se compila
|
|
261
|
-
console.log('[Inti] Svelte runtime loaded (compiled)');
|
|
262
|
-
}
|
|
263
|
-
async function loadSolid() {
|
|
264
|
-
if (!window.Solid) {
|
|
265
|
-
// @ts-expect-error CDN import - runtime only
|
|
266
|
-
await import('https://esm.sh/solid-js@1.8.0');
|
|
267
|
-
// @ts-expect-error CDN import - runtime only
|
|
268
|
-
await import('https://esm.sh/solid-js@1.8.0/web');
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
async function loadAlpine() {
|
|
272
|
-
if (!window.Alpine) {
|
|
273
|
-
// @ts-expect-error CDN import - runtime only
|
|
274
|
-
await import('https://esm.sh/alpinejs@3.13.0');
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
async function loadLit() {
|
|
278
|
-
if (!window.lit) {
|
|
279
|
-
// @ts-expect-error CDN import - runtime only
|
|
280
|
-
await import('https://esm.sh/lit@3.0.0');
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
// ============================================
|
|
284
|
-
// Optimización: Precarga
|
|
285
|
-
// ============================================
|
|
286
|
-
/**
|
|
287
|
-
* Precarga los runtimes de frameworks usados frecuentemente
|
|
288
|
-
* Útil cuando sabes qué frameworks usará la página
|
|
289
|
-
*/
|
|
290
|
-
export function preloadFrameworks(frameworks) {
|
|
291
|
-
if (typeof window === 'undefined')
|
|
292
|
-
return;
|
|
293
|
-
// Usar requestIdleCallback para no bloquear
|
|
294
|
-
const schedule = window.requestIdleCallback || setTimeout;
|
|
295
|
-
schedule(() => {
|
|
296
|
-
frameworks.forEach(async (framework) => {
|
|
297
|
-
if (!isFrameworkLoaded(framework)) {
|
|
298
|
-
await loadFrameworkRuntime(framework);
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Analiza la página para detectar qué frameworks se usan
|
|
305
|
-
* y precargarlos
|
|
306
|
-
*/
|
|
307
|
-
export function analyzeAndPreload() {
|
|
308
|
-
if (typeof document === 'undefined')
|
|
309
|
-
return;
|
|
310
|
-
const islands = document.querySelectorAll('[data-island-framework]');
|
|
311
|
-
const frameworks = new Set();
|
|
312
|
-
islands.forEach(island => {
|
|
313
|
-
const fw = island.getAttribute('data-island-framework');
|
|
314
|
-
if (fw && fw !== 'astro') {
|
|
315
|
-
frameworks.add(fw);
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
if (frameworks.size > 0) {
|
|
319
|
-
console.log('[Inti] Preloading frameworks:', Array.from(frameworks));
|
|
320
|
-
preloadFrameworks(Array.from(frameworks));
|
|
321
|
-
}
|
|
322
|
-
}
|
package/dist/islands/index.d.ts
DELETED
|
@@ -1,145 +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 type FrameworkType = 'react' | 'vue' | 'svelte' | 'solid' | 'preact' | 'alpine' | 'lit' | 'astro';
|
|
8
|
-
export interface IslandRegistration {
|
|
9
|
-
/** Tipo de framework */
|
|
10
|
-
framework: FrameworkType;
|
|
11
|
-
/** Lazy loader del componente */
|
|
12
|
-
component: () => Promise<{
|
|
13
|
-
default: any;
|
|
14
|
-
}>;
|
|
15
|
-
/** Directiva de cliente Astro */
|
|
16
|
-
clientDirective?: 'load' | 'idle' | 'visible' | 'media' | 'only';
|
|
17
|
-
/** Props para el componente */
|
|
18
|
-
props?: Record<string, any>;
|
|
19
|
-
/** Slot children (para frameworks que lo soporten) */
|
|
20
|
-
children?: string;
|
|
21
|
-
}
|
|
22
|
-
export interface IslandMetadata {
|
|
23
|
-
/** ID único de la island */
|
|
24
|
-
id: string;
|
|
25
|
-
/** Tipo de bloque */
|
|
26
|
-
blockType: string;
|
|
27
|
-
/** Framework utilizado */
|
|
28
|
-
framework: FrameworkType;
|
|
29
|
-
/** Si está hidratada */
|
|
30
|
-
hydrated: boolean;
|
|
31
|
-
/** Timestamp de creación */
|
|
32
|
-
createdAt: number;
|
|
33
|
-
}
|
|
34
|
-
type SharedStateValue = string | number | boolean | object | null;
|
|
35
|
-
export declare class SharedStateManager {
|
|
36
|
-
private state;
|
|
37
|
-
private listeners;
|
|
38
|
-
/**
|
|
39
|
-
* Obtener valor del estado compartido
|
|
40
|
-
*/
|
|
41
|
-
get(key: string): SharedStateValue;
|
|
42
|
-
/**
|
|
43
|
-
* Establecer valor y notificar suscriptores
|
|
44
|
-
*/
|
|
45
|
-
set(key: string, value: SharedStateValue, sourceIslandId?: string): void;
|
|
46
|
-
/**
|
|
47
|
-
* Suscribir una island a cambios de una key
|
|
48
|
-
*/
|
|
49
|
-
subscribe(islandId: string, key: string): void;
|
|
50
|
-
/**
|
|
51
|
-
* Desuscribir una island
|
|
52
|
-
*/
|
|
53
|
-
unsubscribe(islandId: string, key?: string): void;
|
|
54
|
-
/**
|
|
55
|
-
* Registrar listener global
|
|
56
|
-
*/
|
|
57
|
-
onChange(key: string, callback: (value: SharedStateValue) => void): () => void;
|
|
58
|
-
/**
|
|
59
|
-
* Notificar a una island específica
|
|
60
|
-
*/
|
|
61
|
-
private notifyIsland;
|
|
62
|
-
/**
|
|
63
|
-
* Obtener todo el estado (para debug/hydration)
|
|
64
|
-
*/
|
|
65
|
-
getAllState(): Record<string, SharedStateValue>;
|
|
66
|
-
/**
|
|
67
|
-
* Limpiar estado
|
|
68
|
-
*/
|
|
69
|
-
clear(): void;
|
|
70
|
-
}
|
|
71
|
-
export declare class MultiFrameworkRegistry {
|
|
72
|
-
private islands;
|
|
73
|
-
private sharedState;
|
|
74
|
-
private frameworkLoaders;
|
|
75
|
-
private loadedFrameworks;
|
|
76
|
-
/**
|
|
77
|
-
* Registrar una island
|
|
78
|
-
*/
|
|
79
|
-
register(blockType: string, registration: IslandRegistration): void;
|
|
80
|
-
/**
|
|
81
|
-
* Obtener registro de island
|
|
82
|
-
*/
|
|
83
|
-
get(blockType: string): IslandRegistration | undefined;
|
|
84
|
-
/**
|
|
85
|
-
* Verificar si está registrado
|
|
86
|
-
*/
|
|
87
|
-
has(blockType: string): boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Obtener estado compartido
|
|
90
|
-
*/
|
|
91
|
-
getSharedState(): SharedStateManager;
|
|
92
|
-
/**
|
|
93
|
-
* Registrar loader de framework
|
|
94
|
-
*/
|
|
95
|
-
registerFrameworkLoader(framework: FrameworkType, loader: () => Promise<void>): void;
|
|
96
|
-
/**
|
|
97
|
-
* Cargar framework bajo demanda
|
|
98
|
-
*/
|
|
99
|
-
loadFramework(framework: FrameworkType): Promise<boolean>;
|
|
100
|
-
/**
|
|
101
|
-
* Obtener todos los frameworks registrados
|
|
102
|
-
*/
|
|
103
|
-
getRegisteredFrameworks(): FrameworkType[];
|
|
104
|
-
/**
|
|
105
|
-
* Obtener islands por framework
|
|
106
|
-
*/
|
|
107
|
-
getIslandsByFramework(framework: FrameworkType): Array<{
|
|
108
|
-
type: string;
|
|
109
|
-
registration: IslandRegistration;
|
|
110
|
-
}>;
|
|
111
|
-
}
|
|
112
|
-
export declare function getMultiFrameworkRegistry(): MultiFrameworkRegistry;
|
|
113
|
-
export declare function createMultiFrameworkRegistry(): MultiFrameworkRegistry;
|
|
114
|
-
export { detectFrameworkFromPath, detectFrameworkFromCode, loadFrameworkRuntime, preloadFrameworks, analyzeAndPreload } from './auto-detect-framework.js';
|
|
115
|
-
/**
|
|
116
|
-
* Crear registro de island React
|
|
117
|
-
*/
|
|
118
|
-
export declare function reactIsland(component: () => Promise<{
|
|
119
|
-
default: any;
|
|
120
|
-
}>, options?: Omit<IslandRegistration, 'framework' | 'component'>): IslandRegistration;
|
|
121
|
-
/**
|
|
122
|
-
* Crear registro de island Vue
|
|
123
|
-
*/
|
|
124
|
-
export declare function vueIsland(component: () => Promise<{
|
|
125
|
-
default: any;
|
|
126
|
-
}>, options?: Omit<IslandRegistration, 'framework' | 'component'>): IslandRegistration;
|
|
127
|
-
/**
|
|
128
|
-
* Crear registro de island Svelte
|
|
129
|
-
*/
|
|
130
|
-
export declare function svelteIsland(component: () => Promise<{
|
|
131
|
-
default: any;
|
|
132
|
-
}>, options?: Omit<IslandRegistration, 'framework' | 'component'>): IslandRegistration;
|
|
133
|
-
/**
|
|
134
|
-
* Crear registro de island Solid
|
|
135
|
-
*/
|
|
136
|
-
export declare function solidIsland(component: () => Promise<{
|
|
137
|
-
default: any;
|
|
138
|
-
}>, options?: Omit<IslandRegistration, 'framework' | 'component'>): IslandRegistration;
|
|
139
|
-
/**
|
|
140
|
-
* Crear registro de island Alpine
|
|
141
|
-
*/
|
|
142
|
-
export declare function alpineIsland(component: () => Promise<{
|
|
143
|
-
default: any;
|
|
144
|
-
}>, options?: Omit<IslandRegistration, 'framework' | 'component'>): IslandRegistration;
|
|
145
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/islands/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,MAAM,aAAa,GACnB,OAAO,GACP,KAAK,GACL,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,KAAK,GACL,OAAO,CAAC;AAEd,MAAM,WAAW,kBAAkB;IAC/B,wBAAwB;IACxB,SAAS,EAAE,aAAa,CAAC;IACzB,iCAAiC;IACjC,SAAS,EAAE,MAAM,OAAO,CAAC;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;IAC3C,iCAAiC;IACjC,eAAe,CAAC,EAAE,MAAM,GAAG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