@meekojs/meeko 0.0.3 → 0.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/README.md +18 -1
- package/dist/autoimports-ts.d.ts +26 -0
- package/dist/autoimports-ts.js +127 -0
- package/dist/autoimports-ts.js.map +1 -0
- package/dist/autoimports.d.ts +21 -0
- package/dist/autoimports.js +285 -0
- package/dist/autoimports.js.map +1 -0
- package/dist/check.js +35 -23
- package/dist/check.js.map +1 -0
- package/dist/cli.js +33 -4
- package/dist/cli.js.map +1 -0
- package/dist/compiler/import-graph.d.ts +8 -0
- package/dist/compiler/import-graph.js +33 -0
- package/dist/compiler/import-graph.js.map +1 -0
- package/dist/compiler/mapping.js +1 -0
- package/dist/compiler/mapping.js.map +1 -0
- package/dist/compiler/project-root.d.ts +2 -0
- package/dist/compiler/project-root.js +18 -0
- package/dist/compiler/project-root.js.map +1 -0
- package/dist/compiler/sfc.js +1 -0
- package/dist/compiler/sfc.js.map +1 -0
- package/dist/compiler/sourcemap.d.ts +3 -0
- package/dist/compiler/sourcemap.js +75 -0
- package/dist/compiler/sourcemap.js.map +1 -0
- package/dist/compiler/template.js +1 -0
- package/dist/compiler/template.js.map +1 -0
- package/dist/compiler.js +11 -5
- package/dist/compiler.js.map +1 -0
- package/dist/devtools-ui/index.js +1 -0
- package/dist/devtools-ui/index.js.map +1 -0
- package/dist/devtools.js +1 -0
- package/dist/devtools.js.map +1 -0
- package/dist/dom.d.ts +8 -1
- package/dist/dom.js +10 -5
- package/dist/dom.js.map +1 -0
- package/dist/framework/check-app.d.ts +5 -0
- package/dist/framework/check-app.js +59 -0
- package/dist/framework/check-app.js.map +1 -0
- package/dist/framework/client.d.ts +45 -0
- package/dist/framework/client.js +146 -0
- package/dist/framework/client.js.map +1 -0
- package/dist/framework/clients.d.ts +82 -0
- package/dist/framework/clients.js +182 -0
- package/dist/framework/clients.js.map +1 -0
- package/dist/framework/config-type.d.ts +10 -0
- package/dist/framework/config-type.js +4 -0
- package/dist/framework/config-type.js.map +1 -0
- package/dist/framework/config.d.ts +15 -0
- package/dist/framework/config.js +138 -0
- package/dist/framework/config.js.map +1 -0
- package/dist/framework/contracts-generate.d.ts +8 -0
- package/dist/framework/contracts-generate.js +227 -0
- package/dist/framework/contracts-generate.js.map +1 -0
- package/dist/framework/generate.d.ts +7 -0
- package/dist/framework/generate.js +67 -0
- package/dist/framework/generate.js.map +1 -0
- package/dist/framework/init.d.ts +2 -0
- package/dist/framework/init.js +362 -0
- package/dist/framework/init.js.map +1 -0
- package/dist/framework/modules.d.ts +22 -0
- package/dist/framework/modules.js +29 -0
- package/dist/framework/modules.js.map +1 -0
- package/dist/framework/page.d.ts +60 -0
- package/dist/framework/page.js +42 -0
- package/dist/framework/page.js.map +1 -0
- package/dist/framework/prerender.d.ts +14 -0
- package/dist/framework/prerender.js +104 -0
- package/dist/framework/prerender.js.map +1 -0
- package/dist/framework/router.d.ts +39 -0
- package/dist/framework/router.js +173 -0
- package/dist/framework/router.js.map +1 -0
- package/dist/framework/server.d.ts +51 -0
- package/dist/framework/server.js +192 -0
- package/dist/framework/server.js.map +1 -0
- package/dist/framework/socket-contracts-generate.d.ts +5 -0
- package/dist/framework/socket-contracts-generate.js +159 -0
- package/dist/framework/socket-contracts-generate.js.map +1 -0
- package/dist/framework/socket.d.ts +70 -0
- package/dist/framework/socket.js +150 -0
- package/dist/framework/socket.js.map +1 -0
- package/dist/framework/state.d.ts +15 -0
- package/dist/framework/state.js +72 -0
- package/dist/framework/state.js.map +1 -0
- package/dist/framework-server/auto-clients.d.ts +3 -0
- package/dist/framework-server/auto-clients.js +27 -0
- package/dist/framework-server/auto-clients.js.map +1 -0
- package/dist/framework-server/context.d.ts +21 -0
- package/dist/framework-server/context.js +22 -0
- package/dist/framework-server/context.js.map +1 -0
- package/dist/framework-server/contracts.d.ts +64 -0
- package/dist/framework-server/contracts.js +129 -0
- package/dist/framework-server/contracts.js.map +1 -0
- package/dist/framework-server/discovery.d.ts +40 -0
- package/dist/framework-server/discovery.js +252 -0
- package/dist/framework-server/discovery.js.map +1 -0
- package/dist/framework-server/local.d.ts +19 -0
- package/dist/framework-server/local.js +98 -0
- package/dist/framework-server/local.js.map +1 -0
- package/dist/framework-server/node-upgrade.d.ts +23 -0
- package/dist/framework-server/node-upgrade.js +78 -0
- package/dist/framework-server/node-upgrade.js.map +1 -0
- package/dist/framework-server/node-websocket.d.ts +16 -0
- package/dist/framework-server/node-websocket.js +125 -0
- package/dist/framework-server/node-websocket.js.map +1 -0
- package/dist/framework-server/openapi.d.ts +17 -0
- package/dist/framework-server/openapi.js +118 -0
- package/dist/framework-server/openapi.js.map +1 -0
- package/dist/framework-server/session-stores.d.ts +66 -0
- package/dist/framework-server/session-stores.js +96 -0
- package/dist/framework-server/session-stores.js.map +1 -0
- package/dist/framework-server/sessions.d.ts +64 -0
- package/dist/framework-server/sessions.js +136 -0
- package/dist/framework-server/sessions.js.map +1 -0
- package/dist/framework-server/socket.d.ts +83 -0
- package/dist/framework-server/socket.js +161 -0
- package/dist/framework-server/socket.js.map +1 -0
- package/dist/framework-server.d.ts +21 -0
- package/dist/framework-server.js +12 -0
- package/dist/framework-server.js.map +1 -0
- package/dist/framework.d.ts +29 -0
- package/dist/framework.js +13 -0
- package/dist/framework.js.map +1 -0
- package/dist/hmr.js +1 -0
- package/dist/hmr.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -0
- package/dist/init.js +4 -2
- package/dist/init.js.map +1 -0
- package/dist/internal.js +1 -0
- package/dist/internal.js.map +1 -0
- package/dist/node.d.ts +12 -0
- package/dist/node.js +52 -0
- package/dist/node.js.map +1 -0
- package/dist/reactivity.d.ts +12 -0
- package/dist/reactivity.js +40 -3
- package/dist/reactivity.js.map +1 -0
- package/dist/server.js +1 -0
- package/dist/server.js.map +1 -0
- package/dist/types.js +23 -8
- package/dist/types.js.map +1 -0
- package/dist/vite.js +91 -6
- package/dist/vite.js.map +1 -0
- package/package.json +14 -3
package/dist/reactivity.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/** Crea una clave única; el tipo no se infiere de un valor global compartido. */
|
|
2
|
+
export function createContext(description) {
|
|
3
|
+
return Symbol(description);
|
|
4
|
+
}
|
|
1
5
|
const writableSignals = new WeakSet();
|
|
2
6
|
const derivedSignals = new WeakSet();
|
|
3
7
|
const effectSources = new WeakMap();
|
|
@@ -10,6 +14,26 @@ let activeOwner;
|
|
|
10
14
|
let batchDepth = 0;
|
|
11
15
|
let flushing = false;
|
|
12
16
|
const pending = new Set();
|
|
17
|
+
/** Publica un valor en la instancia activa y sus descendientes. */
|
|
18
|
+
export function provide(key, value) {
|
|
19
|
+
if (!activeOwner)
|
|
20
|
+
throw new Error("provide() requires an active component root");
|
|
21
|
+
activeOwner.context.set(key, value);
|
|
22
|
+
}
|
|
23
|
+
/** Lee el proveedor más cercano; falla si falta para evitar un valor implícito. */
|
|
24
|
+
export function inject(key) {
|
|
25
|
+
for (let owner = activeOwner; owner; owner = owner.parent) {
|
|
26
|
+
if (owner.context.has(key))
|
|
27
|
+
return owner.context.get(key);
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`Missing Meeko context${key.description ? `: ${key.description}` : ""}`);
|
|
30
|
+
}
|
|
31
|
+
/** Registers an external resource to be released with the current component root. */
|
|
32
|
+
export function onCleanup(release) {
|
|
33
|
+
if (!activeOwner)
|
|
34
|
+
throw new Error("onCleanup() requires an active component root");
|
|
35
|
+
activeOwner.children.add(release);
|
|
36
|
+
}
|
|
13
37
|
function detach(observer) {
|
|
14
38
|
for (const dependency of observer.dependencies)
|
|
15
39
|
dependency.subscribers?.delete(observer);
|
|
@@ -144,12 +168,19 @@ export function untrack(fn) {
|
|
|
144
168
|
}
|
|
145
169
|
/** Asocia efectos a una instancia y entrega una función para liberarlos. */
|
|
146
170
|
export function createRoot(fn) {
|
|
147
|
-
const owner = { observers: new Set(), children: new Set(), parent: activeOwner };
|
|
171
|
+
const owner = { observers: new Set(), children: new Set(), parent: activeOwner, context: new Map() };
|
|
148
172
|
const previous = activeOwner;
|
|
149
173
|
activeOwner = owner;
|
|
150
174
|
const dispose = () => {
|
|
151
|
-
|
|
152
|
-
|
|
175
|
+
const failures = [];
|
|
176
|
+
for (const child of [...owner.children]) {
|
|
177
|
+
try {
|
|
178
|
+
child();
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
failures.push(error);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
153
184
|
owner.children.clear();
|
|
154
185
|
for (const observer of owner.observers) {
|
|
155
186
|
observer.disposed = true;
|
|
@@ -157,7 +188,12 @@ export function createRoot(fn) {
|
|
|
157
188
|
detach(observer);
|
|
158
189
|
}
|
|
159
190
|
owner.observers.clear();
|
|
191
|
+
owner.context.clear();
|
|
160
192
|
owner.parent?.children.delete(dispose);
|
|
193
|
+
if (failures.length === 1)
|
|
194
|
+
throw failures[0];
|
|
195
|
+
if (failures.length > 1)
|
|
196
|
+
throw new AggregateError(failures, "Meeko root cleanup failed");
|
|
161
197
|
};
|
|
162
198
|
owner.parent?.children.add(dispose);
|
|
163
199
|
try {
|
|
@@ -171,3 +207,4 @@ export function createRoot(fn) {
|
|
|
171
207
|
activeOwner = previous;
|
|
172
208
|
}
|
|
173
209
|
}
|
|
210
|
+
//# sourceMappingURL=reactivity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactivity.js","sourceRoot":"","sources":["../src/reactivity.ts"],"names":[],"mappings":"AAaA,iFAAiF;AACjF,MAAM,UAAU,aAAa,CAAI,WAAoB;IACnD,OAAO,MAAM,CAAC,WAAW,CAAkB,CAAC;AAC9C,CAAC;AA4BD,MAAM,eAAe,GAAG,IAAI,OAAO,EAAU,CAAC;AAC9C,MAAM,cAAc,GAAG,IAAI,OAAO,EAAU,CAAC;AAC7C,MAAM,aAAa,GAAG,IAAI,OAAO,EAAgE,CAAC;AAElG,oFAAoF;AACp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AAC,QAAQ,GAAG,IAAI,CAAC;YACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACzB,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnB,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACxB,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACtB,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC7C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,IAAI,cAAc,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAC;IAC3F,CAAC,CAAC;IACF,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,CAAC;QACV,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,WAAW,GAAG,QAAQ,CAAC;IACzB,CAAC;AACH,CAAC","sourcesContent":["/** Señal de solo lectura que registra dependencias al consultar su valor. */\nexport interface ReadonlySignal<T> {\n readonly value: T;\n}\n\n/** Señal cuyo valor puede actualizarse de forma reactiva. */\nexport interface Signal<T> extends ReadonlySignal<T> {\n value: T;\n}\n\n/** Clave nominal para compartir un valor tipado entre instancias anidadas. */\nexport type ContextKey<T> = symbol & { readonly __meekoValue?: (value: T) => T };\n\n/** Crea una clave única; el tipo no se infiere de un valor global compartido. */\nexport function createContext<T>(description?: string): ContextKey<T> {\n return Symbol(description) as ContextKey<T>;\n}\n\n/** Ubicación de una expresión de plantilla que lee una señal durante desarrollo. */\nexport interface EffectSource {\n file: string;\n line: number;\n column: number;\n expression: string;\n kind: \"text\" | \"attribute\";\n}\n\ninterface Observer {\n run: () => void;\n dependencies: Set<InternalSignal<unknown>>;\n disposed: boolean;\n}\n\ninterface Owner {\n observers: Set<Observer>;\n children: Set<() => void>;\n parent: Owner | undefined;\n context: Map<symbol, unknown>;\n}\n\ninterface InternalSignal<T> extends Signal<T> {\n subscribers: Set<Observer> | undefined;\n}\n\nconst writableSignals = new WeakSet<object>();\nconst derivedSignals = new WeakSet<object>();\nconst effectSources = new WeakMap<Observer, { owner: Owner | undefined; source: EffectSource }>();\n\n/** Identifica señales editables creadas por Meeko para conservarlas durante HMR. */\nexport function isWritableSignal(value: unknown): value is Signal<unknown> {\n return typeof value === \"object\" && value !== null && writableSignals.has(value) && !derivedSignals.has(value);\n}\n\nlet activeObserver: Observer | undefined;\nlet activeOwner: Owner | undefined;\nlet batchDepth = 0;\nlet flushing = false;\nconst pending = new Set<Observer>();\n\n/** Publica un valor en la instancia activa y sus descendientes. */\nexport function provide<T>(key: ContextKey<T>, value: T): void {\n if (!activeOwner) throw new Error(\"provide() requires an active component root\");\n activeOwner.context.set(key, value);\n}\n\n/** Lee el proveedor más cercano; falla si falta para evitar un valor implícito. */\nexport function inject<T>(key: ContextKey<T>): T {\n for (let owner = activeOwner; owner; owner = owner.parent) {\n if (owner.context.has(key)) return owner.context.get(key) as T;\n }\n throw new Error(`Missing Meeko context${key.description ? `: ${key.description}` : \"\"}`);\n}\n\n/** Registers an external resource to be released with the current component root. */\nexport function onCleanup(release: () => void): void {\n if (!activeOwner) throw new Error(\"onCleanup() requires an active component root\");\n activeOwner.children.add(release);\n}\n\nfunction detach(observer: Observer): void {\n for (const dependency of observer.dependencies) dependency.subscribers?.delete(observer);\n observer.dependencies.clear();\n}\n\nfunction flush(): void {\n if (flushing || batchDepth > 0) return;\n flushing = true;\n try {\n let iterations = 0;\n while (pending.size > 0) {\n if (++iterations > 1000) throw new Error(\"Reactive update cycle exceeded 1000 iterations\");\n const observers = [...pending];\n pending.clear();\n for (const observer of observers) if (!observer.disposed) observer.run();\n }\n } finally {\n flushing = false;\n }\n}\n\n/** Crea un valor observable. Las escrituras iguales no notifican cambios. */\nexport function signal<T>(initial: T): Signal<T> {\n let current = initial;\n const result: InternalSignal<T> = {\n subscribers: undefined,\n get value() {\n if (activeObserver) {\n (result.subscribers ??= new Set()).add(activeObserver);\n activeObserver.dependencies.add(result as InternalSignal<unknown>);\n }\n return current;\n },\n set value(next: T) {\n if (Object.is(current, next)) return;\n current = next;\n if (result.subscribers) for (const observer of result.subscribers) pending.add(observer);\n flush();\n },\n };\n writableSignals.add(result);\n return result;\n}\n\n/** Ejecuta una función cuando cambian las señales leídas por ella. */\nexport function effect(fn: () => void, source?: EffectSource): () => void {\n const owner = activeOwner;\n const observer: Observer = {\n dependencies: new Set(),\n disposed: false,\n run() {\n detach(observer);\n const previous = activeObserver;\n const previousOwner = activeOwner;\n activeObserver = observer;\n activeOwner = owner;\n try {\n fn();\n } finally {\n activeObserver = previous;\n activeOwner = previousOwner;\n }\n },\n };\n if (source) effectSources.set(observer, { owner, source });\n owner?.observers.add(observer);\n observer.run();\n return () => {\n observer.disposed = true;\n pending.delete(observer);\n detach(observer);\n owner?.observers.delete(observer);\n };\n}\n\n/** Identidad opaca de la raíz reactiva activa; permite aislar instancias anidadas. */\nexport function currentEffectOwner(): object | undefined {\n return activeOwner;\n}\n\n/** Devuelve expresiones de plantilla actualmente dependientes de una señal en una raíz. */\nexport function signalReadSites(value: Signal<unknown>, owner: object | undefined): EffectSource[] {\n if (!owner || !isWritableSignal(value)) return [];\n const sites = new Map<string, EffectSource>();\n for (const observer of (value as InternalSignal<unknown>).subscribers ?? []) {\n const metadata = effectSources.get(observer);\n if (observer.disposed || metadata?.owner !== owner || !metadata) continue;\n const source = metadata.source;\n const key = `${source.file}\\u0000${source.line}\\u0000${source.column}\\u0000${source.kind}\\u0000${source.expression}`;\n sites.set(key, source);\n }\n return [...sites.values()];\n}\n\n/** Deriva un valor de otras señales y lo actualiza cuando cambian. */\nexport function computed<T>(fn: () => T): ReadonlySignal<T> {\n const result = signal<T>(undefined as T);\n derivedSignals.add(result);\n effect(() => {\n result.value = fn();\n });\n return result;\n}\n\n/** Agrupa varias escrituras en una sola ronda de notificaciones. */\nexport function batch<T>(fn: () => T): T {\n batchDepth++;\n try {\n return fn();\n } finally {\n batchDepth--;\n flush();\n }\n}\n\n/** Lee señales sin registrar dependencias en el observador activo. */\nexport function untrack<T>(fn: () => T): T {\n const previous = activeObserver;\n activeObserver = undefined;\n try {\n return fn();\n } finally {\n activeObserver = previous;\n }\n}\n\n/** Asocia efectos a una instancia y entrega una función para liberarlos. */\nexport function createRoot<T>(fn: (dispose: () => void) => T): T {\n const owner: Owner = { observers: new Set(), children: new Set(), parent: activeOwner, context: new Map() };\n const previous = activeOwner;\n activeOwner = owner;\n const dispose = () => {\n const failures: unknown[] = [];\n for (const child of [...owner.children]) {\n try { child(); } catch (error) { failures.push(error); }\n }\n owner.children.clear();\n for (const observer of owner.observers) {\n observer.disposed = true;\n pending.delete(observer);\n detach(observer);\n }\n owner.observers.clear();\n owner.context.clear();\n owner.parent?.children.delete(dispose);\n if (failures.length === 1) throw failures[0];\n if (failures.length > 1) throw new AggregateError(failures, \"Meeko root cleanup failed\");\n };\n owner.parent?.children.add(dispose);\n try {\n return fn(dispose);\n } catch (error) {\n dispose();\n throw error;\n } finally {\n activeOwner = previous;\n }\n}\n"]}
|
package/dist/server.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,MAAM,CAAC,KAAK,CAAC;SACjB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,QAAQ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arlo en HTML generado por SSR. */\nexport function escapeHtml(value: unknown): string {\n return String(value)\n .replaceAll(\"&\", \"&\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\")\n .replaceAll('\"', \""\")\n .replaceAll(\"'\", \"'\");\n}\n\nconst booleanAttributes = new Set([\"allowfullscreen\", \"async\", \"autofocus\", \"autoplay\", \"checked\", \"controls\", \"default\", \"defer\", \"disabled\", \"formnovalidate\", \"hidden\", \"inert\", \"ismap\", \"loop\", \"multiple\", \"muted\", \"nomodule\", \"novalidate\", \"open\", \"playsinline\", \"readonly\", \"required\", \"reversed\", \"selected\"]);\n\n/** Convierte un valor de atributo dinámico en su forma DOM; null lo elimina. */\nexport function attributeValue(name: string, value: unknown): string | null {\n if (booleanAttributes.has(name)) return value ? \"\" : null;\n if (value === null || value === undefined || value === false) return null;\n return String(value);\n}\n\n/** Genera un atributo HTML dinámico con escape seguro para SSR. */\nexport function renderAttribute(name: string, value: unknown): string {\n if (!/^[a-zA-Z_:][a-zA-Z0-9_:.-]*$/.test(name)) throw new TypeError(`Invalid attribute name: ${name}`);\n const resolved = attributeValue(name, value);\n return resolved === null ? \"\" : ` ${name}=\"${escapeHtml(resolved)}\"`;\n}\n\nfunction assertSerializable(value: unknown, path: string, ancestors: WeakSet<object>): void {\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") return;\n if (typeof value === \"number\") {\n if (Number.isFinite(value)) return;\n throw new TypeError(`Non-finite number at ${path}`);\n }\n if (typeof value !== \"object\") throw new TypeError(`Non-serializable value at ${path}`);\n if (ancestors.has(value)) throw new TypeError(`Circular reference at ${path}`);\n const prototype: unknown = Object.getPrototypeOf(value);\n if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) {\n throw new TypeError(`Non-plain object at ${path}`);\n }\n if (Object.hasOwn(value, \"toJSON\")) throw new TypeError(`Custom toJSON at ${path}`);\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index++) {\n if (!Object.hasOwn(value, index)) throw new TypeError(`Sparse array at ${path}[${index}]`);\n }\n }\n ancestors.add(value);\n try {\n for (const key of Reflect.ownKeys(value)) {\n if (typeof key !== \"string\") throw new TypeError(`Symbol key at ${path}`);\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (!descriptor?.enumerable) continue;\n if (!(\"value\" in descriptor)) throw new TypeError(`Accessor property at ${path}.${key}`);\n assertSerializable(descriptor.value, `${path}.${key}`, ancestors);\n }\n } finally {\n ancestors.delete(value);\n }\n}\n\n/** Serializa estado y props transferibles al navegador, rechazando valores ambiguos. */\nexport function serializeJson(value: unknown): string {\n assertSerializable(value, \"$\", new WeakSet());\n const json = JSON.stringify(value);\n if (json === undefined) throw new TypeError(\"Value cannot be serialized to JSON\");\n return json\n .replaceAll(\"<\", \"\\\\u003c\")\n .replaceAll(\">\", \"\\\\u003e\")\n .replaceAll(\"&\", \"\\\\u0026\")\n .replaceAll(\"\\u2028\", \"\\\\u2028\")\n .replaceAll(\"\\u2029\", \"\\\\u2029\");\n}\n"]}
|
package/dist/types.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
import { dirname, resolve } from "node:path";
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
3
3
|
import ts from "@typescript/typescript6";
|
|
4
|
-
import {
|
|
4
|
+
import { compileWithAutoImports } from "./autoimports.js";
|
|
5
|
+
import { moduleSpecifiers, replaceModuleSpecifiers } from "./compiler/import-graph.js";
|
|
6
|
+
import { projectRoot } from "./compiler/project-root.js";
|
|
5
7
|
/** Genera declaraciones TypeScript para un componente y sus imports .meeko relativos. */
|
|
6
8
|
export async function generateTypes(source, filename) {
|
|
7
9
|
if (!filename.endsWith(".meeko"))
|
|
8
10
|
throw new TypeError("Type generation requires a .meeko input file");
|
|
11
|
+
const root = projectRoot(filename);
|
|
12
|
+
const outputRoot = join(root, ".meeko", "types");
|
|
9
13
|
const declarations = new Map();
|
|
10
14
|
async function collect(content, path) {
|
|
11
15
|
if (declarations.has(path))
|
|
12
16
|
return;
|
|
13
|
-
const
|
|
17
|
+
const target = relative(root, path).split(/[\\/]/)[0] === "server" ? "server" : "client";
|
|
18
|
+
const generated = (await compileWithAutoImports(content, path, {}, target)).code;
|
|
14
19
|
const result = ts.transpileDeclaration(generated, {
|
|
15
20
|
fileName: `${path}.ts`,
|
|
16
21
|
compilerOptions: { declaration: true, emitDeclarationOnly: true },
|
|
@@ -19,8 +24,9 @@ export async function generateTypes(source, filename) {
|
|
|
19
24
|
if (error)
|
|
20
25
|
throw new Error(ts.flattenDiagnosticMessageText(error.messageText, "\n"));
|
|
21
26
|
declarations.set(path, result.outputText);
|
|
22
|
-
for (const
|
|
23
|
-
|
|
27
|
+
for (const { value: specifier } of moduleSpecifiers(generated, path)) {
|
|
28
|
+
if (!specifier.endsWith(".meeko"))
|
|
29
|
+
continue;
|
|
24
30
|
if (!specifier.startsWith("."))
|
|
25
31
|
continue;
|
|
26
32
|
const child = resolve(dirname(path), specifier);
|
|
@@ -30,9 +36,18 @@ export async function generateTypes(source, filename) {
|
|
|
30
36
|
await collect(source, resolve(filename));
|
|
31
37
|
const outputs = [];
|
|
32
38
|
for (const [path, declaration] of declarations) {
|
|
33
|
-
const output = path.replace(/\.meeko$/, ".d.meeko.ts");
|
|
34
|
-
|
|
39
|
+
const output = join(outputRoot, relative(root, path)).replace(/\.meeko$/, ".d.meeko.ts");
|
|
40
|
+
const rewritten = replaceModuleSpecifiers(declaration, output, ({ value }) => {
|
|
41
|
+
if (!value.startsWith(".") || value.endsWith(".meeko"))
|
|
42
|
+
return value;
|
|
43
|
+
const original = resolve(dirname(path), value);
|
|
44
|
+
const target = relative(dirname(output), original).replaceAll("\\", "/");
|
|
45
|
+
return target.startsWith(".") ? target : `./${target}`;
|
|
46
|
+
});
|
|
47
|
+
await mkdir(dirname(output), { recursive: true });
|
|
48
|
+
await writeFile(output, rewritten, "utf8");
|
|
35
49
|
outputs.push(output);
|
|
36
50
|
}
|
|
37
51
|
return outputs;
|
|
38
52
|
}
|
|
53
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,yFAAyF;AACzF,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAc,EAAE,QAAgB;IAClE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,8CAA8C,CAAC,CAAC;IACtG,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACjD,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC/C,KAAK,UAAU,OAAO,CAAC,OAAe,EAAE,IAAY;QAClD,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO;QACnC,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,C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,KAAK,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,YAAY,EAAE,CAAC;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;QACzF,MAAM,SAAS,GAAG,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;YAC3E,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAAE,OAAO,KAAK,CAAC;YACrE,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;YAC/C,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACzE,OAAO,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC;QACzD,CAAC,CAAC,CAAC;QACH,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,MAAM,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { dirname, join, relative, resolve } from \"node:path\";\nimport ts from \"@typescript/typescript6\";\nimport { compileWithAutoImports } from \"./autoimports.js\";\nimport { moduleSpecifiers, replaceModuleSpecifiers } from \"./compiler/import-graph.js\";\nimport { projectRoot } from \"./compiler/project-root.js\";\n\n/** Genera declaraciones TypeScript para un componente y sus imports .meeko relativos. */\nexport async function generateTypes(source: string, filename: string): Promise<string[]> {\n if (!filename.endsWith(\".meeko\")) throw new TypeError(\"Type generation requires a .meeko input file\");\n const root = projectRoot(filename);\n const outputRoot = join(root, \".meeko\", \"types\");\n const declarations = new Map<string, string>();\n async function collect(content: string, path: string): Promise<void> {\n if (declarations.has(path)) return;\n const target = relative(root, path).split(/[\\\\/]/)[0] === \"server\" ? \"server\" : \"client\";\n const generated = (await compileWithAutoImports(content, path, {}, target)).code;\n const result = ts.transpileDeclaration(generated, {\n fileName: `${path}.ts`,\n compilerOptions: { declaration: true, emitDeclarationOnly: true },\n });\n const error = result.diagnostics?.find((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error);\n if (error) throw new Error(ts.flattenDiagnosticMessageText(error.messageText, \"\\n\"));\n declarations.set(path, result.outputText);\n for (const { value: specifier } of moduleSpecifiers(generated, path)) {\n if (!specifier.endsWith(\".meeko\")) continue;\n if (!specifier.startsWith(\".\")) continue;\n const child = resolve(dirname(path), specifier);\n await collect(await readFile(child, \"utf8\"), child);\n }\n }\n await collect(source, resolve(filename));\n const outputs: string[] = [];\n for (const [path, declaration] of declarations) {\n const output = join(outputRoot, relative(root, path)).replace(/\\.meeko$/, \".d.meeko.ts\");\n const rewritten = replaceModuleSpecifiers(declaration, output, ({ value }) => {\n if (!value.startsWith(\".\") || value.endsWith(\".meeko\")) return value;\n const original = resolve(dirname(path), value);\n const target = relative(dirname(output), original).replaceAll(\"\\\\\", \"/\");\n return target.startsWith(\".\") ? target : `./${target}`;\n });\n await mkdir(dirname(output), { recursive: true });\n await writeFile(output, rewritten, \"utf8\");\n outputs.push(output);\n }\n return outputs;\n}\n"]}
|
package/dist/vite.js
CHANGED
|
@@ -1,33 +1,102 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { dirname, resolve } from "node:path";
|
|
2
|
+
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { normalizePath, transformWithOxc } from "vite";
|
|
5
5
|
import { compile } from "./compiler.js";
|
|
6
|
+
import { moduleSpecifiers } from "./compiler/import-graph.js";
|
|
7
|
+
import { sourceMapForCompiled } from "./compiler/sourcemap.js";
|
|
8
|
+
import { discoverAutoImports, transformAutoImports } from "./autoimports.js";
|
|
9
|
+
import { transformTypeScriptAutoImports, typeScriptAutoImportMap } from "./autoimports-ts.js";
|
|
10
|
+
import { discoverConfiguredRoutes } from "./framework/config.js";
|
|
6
11
|
const stylePrefix = "\0virtual:meeko-style:";
|
|
12
|
+
const pageModules = new Map([
|
|
13
|
+
["virtual:meeko-client-pages", "client"],
|
|
14
|
+
["virtual:meeko-server-pages", "server"],
|
|
15
|
+
["virtual:meeko-server-routes", "routes"],
|
|
16
|
+
]);
|
|
7
17
|
const runtimeDirectory = `${normalizePath(dirname(fileURLToPath(import.meta.url)))}/`;
|
|
8
18
|
/** Transforma componentes .meeko para Vite, tanto en cliente como en SSR. */
|
|
9
19
|
export function meeko() {
|
|
10
20
|
let isDev = false;
|
|
21
|
+
let ssrBuild = false;
|
|
22
|
+
let root = "";
|
|
11
23
|
const styles = new Map();
|
|
12
24
|
return {
|
|
13
25
|
name: "meeko:components",
|
|
14
26
|
enforce: "pre",
|
|
15
27
|
configResolved(config) {
|
|
16
28
|
isDev = config.command === "serve";
|
|
29
|
+
ssrBuild = Boolean(config.build.ssr);
|
|
30
|
+
root = config.root;
|
|
17
31
|
},
|
|
18
32
|
resolveId(id) {
|
|
19
33
|
if (id.startsWith("virtual:meeko-style:"))
|
|
20
34
|
return `\0${id}`;
|
|
35
|
+
if (pageModules.has(id))
|
|
36
|
+
return `\0${id}`;
|
|
21
37
|
return null;
|
|
22
38
|
},
|
|
23
|
-
load(id) {
|
|
39
|
+
async load(id) {
|
|
40
|
+
const kind = pageModules.get(id.slice(1));
|
|
41
|
+
if (kind) {
|
|
42
|
+
const routes = await discoverConfiguredRoutes(root);
|
|
43
|
+
const files = kind === "routes"
|
|
44
|
+
? routes.flatMap((route) => route.sidecar ? [route.sidecar] : [])
|
|
45
|
+
: routes.flatMap((route) => [route.file, ...route.layouts, ...(route.error ? [route.error] : [])]);
|
|
46
|
+
const unique = [...new Set(files)];
|
|
47
|
+
const entries = unique.map((file, index) => {
|
|
48
|
+
const path = relative(root, file).replaceAll("\\", "/");
|
|
49
|
+
if (path === ".." || path.startsWith("../") || isAbsolute(path))
|
|
50
|
+
throw new Error(`Page outside Meeko project: ${file}`);
|
|
51
|
+
const specifier = `/${path}`;
|
|
52
|
+
return kind === "client"
|
|
53
|
+
? `${JSON.stringify(specifier)}: () => import(${JSON.stringify(specifier)})`
|
|
54
|
+
: `${JSON.stringify(specifier)}: module${index}`;
|
|
55
|
+
});
|
|
56
|
+
const imports = kind === "client" ? "" : unique.map((file, index) => {
|
|
57
|
+
const path = relative(root, file).replaceAll("\\", "/");
|
|
58
|
+
return `import * as module${index} from ${JSON.stringify(`/${path}`)};`;
|
|
59
|
+
}).join("\n");
|
|
60
|
+
return `${imports}\nexport const modules = {${entries.join(",")}};`;
|
|
61
|
+
}
|
|
24
62
|
if (!id.startsWith(stylePrefix) || !id.endsWith(".css"))
|
|
25
63
|
return null;
|
|
26
64
|
return styles.get(id) ?? null;
|
|
27
65
|
},
|
|
28
|
-
async transform(source, id) {
|
|
29
|
-
|
|
66
|
+
async transform(source, id, options) {
|
|
67
|
+
const serverTransform = Boolean(options?.ssr || ssrBuild);
|
|
68
|
+
const normalizedId = normalizePath(resolve(id));
|
|
69
|
+
const normalizedRoot = normalizePath(root);
|
|
70
|
+
const clientModule = !serverTransform && normalizedId.startsWith(`${normalizedRoot}/`);
|
|
71
|
+
if (clientModule && (normalizedId.startsWith(`${normalizedRoot}/server/`) || /\.server\.[cm]?[jt]sx?$/.test(id))) {
|
|
72
|
+
throw new Error(`Server-only module reached the client bundle: ${id}`);
|
|
73
|
+
}
|
|
74
|
+
if (serverTransform && normalizedId.startsWith(`${normalizedRoot}/`) && /\.client\.[cm]?[jt]sx?$/.test(id)) {
|
|
75
|
+
throw new Error(`Client-only module reached the server bundle: ${id}`);
|
|
76
|
+
}
|
|
77
|
+
const checkBoundary = async (code) => {
|
|
78
|
+
if (!clientModule)
|
|
79
|
+
return;
|
|
80
|
+
for (const { value } of moduleSpecifiers(code, id)) {
|
|
81
|
+
const dependency = await this.resolve(value, id, { skipSelf: true });
|
|
82
|
+
if (dependency && normalizePath(dependency.id).startsWith(`${normalizedRoot}/server/`)) {
|
|
83
|
+
throw new Error(`Client module ${id} imports server-only module ${value}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
if (!id.endsWith(".meeko")) {
|
|
88
|
+
if (/\.[cm]?[jt]sx?$/.test(id) && clientModule)
|
|
89
|
+
await checkBoundary(source);
|
|
90
|
+
if (/\.[cm]?tsx?$/.test(id) && normalizedId.startsWith(`${normalizedRoot}/`)) {
|
|
91
|
+
const registry = await discoverAutoImports(root);
|
|
92
|
+
const transformed = transformTypeScriptAutoImports(source, id, root, registry);
|
|
93
|
+
if (transformed) {
|
|
94
|
+
await checkBoundary(transformed);
|
|
95
|
+
return { code: transformed, map: typeScriptAutoImportMap(source, transformed, id) };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
30
98
|
return null;
|
|
99
|
+
}
|
|
31
100
|
const filename = normalizePath(resolve(id));
|
|
32
101
|
const result = compile(source, filename, { hot: isDev });
|
|
33
102
|
const styleId = `${stylePrefix}${createHash("sha256").update(filename).update("\0").update(result.css).digest("hex")}.css`;
|
|
@@ -35,13 +104,29 @@ export function meeko() {
|
|
|
35
104
|
styles.set(styleId, result.css);
|
|
36
105
|
const cssImport = result.css ? `\nimport ${JSON.stringify(styleId.slice(1))};` : "";
|
|
37
106
|
const hotCode = isDev ? `\nif (import.meta.hot) {\n __meeko.enableHotModule(__hotId);\n import.meta.hot.accept((next) => { if (next) __meeko.replaceHotModule(__hotId, next); });\n}\n` : "";
|
|
38
|
-
|
|
107
|
+
const registry = await discoverAutoImports(root);
|
|
108
|
+
const code = transformAutoImports(source, filename, result.code, registry, serverTransform ? "server" : "client");
|
|
109
|
+
await checkBoundary(code);
|
|
110
|
+
const shifted = code.length - result.code.length;
|
|
111
|
+
const mappings = result.mappings.map((mapping) => ({
|
|
112
|
+
...mapping,
|
|
113
|
+
generatedStart: mapping.generatedStart + shifted,
|
|
114
|
+
generatedEnd: mapping.generatedEnd + shifted,
|
|
115
|
+
}));
|
|
116
|
+
const generated = `${code}${cssImport}${hotCode}`;
|
|
117
|
+
return transformWithOxc(generated, `${filename}.ts`, { lang: "ts" }, sourceMapForCompiled(generated, source, filename, mappings));
|
|
39
118
|
},
|
|
40
119
|
handleHotUpdate({ file, server }) {
|
|
41
|
-
|
|
120
|
+
const normalized = normalizePath(file);
|
|
121
|
+
const relative = normalized.slice(normalizePath(root).length + 1);
|
|
122
|
+
const registrySource = /^(?:app\/(?:components|composables|utils|stores)|shared\/(?:types|schemas|utils|constants|enums)|server\/utils)\//.test(relative);
|
|
123
|
+
const routesSource = /^(?:app\/pages|layers\/|modules\/)/.test(relative) || relative.startsWith("meeko.config.");
|
|
124
|
+
if (!normalized.startsWith(runtimeDirectory) && !registrySource && !routesSource)
|
|
42
125
|
return;
|
|
126
|
+
server.moduleGraph.invalidateAll();
|
|
43
127
|
server.ws.send({ type: "full-reload" });
|
|
44
128
|
return [];
|
|
45
129
|
},
|
|
46
130
|
};
|
|
47
131
|
}
|
|
132
|
+
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;A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AI,CAAC,CAAC;YACvC,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAClE,MAAM,cAAc,GAAG,mHAAmH,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1J,MAAM,YAAY,GAAG,oCAAoC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YACjH,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,YAAY;gBAAE,OAAO;YACzF,MAAM,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC;YACnC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;YACxC,OAAO,EAAE,CAAC;QACZ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { dirname, isAbsolute, relative, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { normalizePath, transformWithOxc } from \"vite\";\nimport type { Plugin } from \"vite\";\nimport { compile } from \"./compiler.js\";\nimport { moduleSpecifiers } from \"./compiler/import-graph.js\";\nimport { sourceMapForCompiled } from \"./compiler/sourcemap.js\";\nimport { discoverAutoImports, transformAutoImports } from \"./autoimports.js\";\nimport { transformTypeScriptAutoImports, typeScriptAutoImportMap } from \"./autoimports-ts.js\";\nimport { discoverConfiguredRoutes } from \"./framework/config.js\";\n\nconst stylePrefix = \"\\0virtual:meeko-style:\";\nconst pageModules = new Map<string, \"client\" | \"server\" | \"routes\">([\n [\"virtual:meeko-client-pages\", \"client\"],\n [\"virtual:meeko-server-pages\", \"server\"],\n [\"virtual:meeko-server-routes\", \"routes\"],\n]);\nconst runtimeDirectory = `${normalizePath(dirname(fileURLToPath(import.meta.url)))}/`;\n\n/** Transforma componentes .meeko para Vite, tanto en cliente como en SSR. */\nexport function meeko(): Plugin {\n let isDev = false;\n let ssrBuild = false;\n let root = \"\";\n const styles = new Map<string, string>();\n return {\n name: \"meeko:components\",\n enforce: \"pre\",\n configResolved(config) {\n isDev = config.command === \"serve\";\n ssrBuild = Boolean(config.build.ssr);\n root = config.root;\n },\n resolveId(id) {\n if (id.startsWith(\"virtual:meeko-style:\")) return `\\0${id}`;\n if (pageModules.has(id)) return `\\0${id}`;\n return null;\n },\n async load(id) {\n const kind = pageModules.get(id.slice(1));\n if (kind) {\n const routes = await discoverConfiguredRoutes(root);\n const files = kind === \"routes\"\n ? routes.flatMap((route) => route.sidecar ? [route.sidecar] : [])\n : routes.flatMap((route) => [route.file, ...route.layouts, ...(route.error ? [route.error] : [])]);\n const unique = [...new Set(files)];\n const entries = unique.map((file, index) => {\n const path = relative(root, file).replaceAll(\"\\\\\", \"/\");\n if (path === \"..\" || path.startsWith(\"../\") || isAbsolute(path)) throw new Error(`Page outside Meeko project: ${file}`);\n const specifier = `/${path}`;\n return kind === \"client\"\n ? `${JSON.stringify(specifier)}: () => import(${JSON.stringify(specifier)})`\n : `${JSON.stringify(specifier)}: module${index}`;\n });\n const imports = kind === \"client\" ? \"\" : unique.map((file, index) => {\n const path = relative(root, file).replaceAll(\"\\\\\", \"/\");\n return `import * as module${index} from ${JSON.stringify(`/${path}`)};`;\n }).join(\"\\n\");\n return `${imports}\\nexport const modules = {${entries.join(\",\")}};`;\n }\n if (!id.startsWith(stylePrefix) || !id.endsWith(\".css\")) return null;\n return styles.get(id) ?? null;\n },\n async transform(source, id, options) {\n const serverTransform = Boolean(options?.ssr || ssrBuild);\n const normalizedId = normalizePath(resolve(id));\n const normalizedRoot = normalizePath(root);\n const clientModule = !serverTransform && normalizedId.startsWith(`${normalizedRoot}/`);\n if (clientModule && (normalizedId.startsWith(`${normalizedRoot}/server/`) || /\\.server\\.[cm]?[jt]sx?$/.test(id))) {\n throw new Error(`Server-only module reached the client bundle: ${id}`);\n }\n if (serverTransform && normalizedId.startsWith(`${normalizedRoot}/`) && /\\.client\\.[cm]?[jt]sx?$/.test(id)) {\n throw new Error(`Client-only module reached the server bundle: ${id}`);\n }\n const checkBoundary = async (code: string): Promise<void> => {\n if (!clientModule) return;\n for (const { value } of moduleSpecifiers(code, id)) {\n const dependency = await this.resolve(value, id, { skipSelf: true });\n if (dependency && normalizePath(dependency.id).startsWith(`${normalizedRoot}/server/`)) {\n throw new Error(`Client module ${id} imports server-only module ${value}`);\n }\n }\n };\n if (!id.endsWith(\".meeko\")) {\n if (/\\.[cm]?[jt]sx?$/.test(id) && clientModule) await checkBoundary(source);\n if (/\\.[cm]?tsx?$/.test(id) && normalizedId.startsWith(`${normalizedRoot}/`)) {\n const registry = await discoverAutoImports(root);\n const transformed = transformTypeScriptAutoImports(source, id, root, registry);\n if (transformed) {\n await checkBoundary(transformed);\n return { code: transformed, map: typeScriptAutoImportMap(source, transformed, id) };\n }\n }\n return null;\n }\n const filename = normalizePath(resolve(id));\n const result = compile(source, filename, { hot: isDev });\n const styleId = `${stylePrefix}${createHash(\"sha256\").update(filename).update(\"\\0\").update(result.css).digest(\"hex\")}.css`;\n if (result.css) styles.set(styleId, result.css);\n const cssImport = result.css ? `\\nimport ${JSON.stringify(styleId.slice(1))};` : \"\";\n const hotCode = isDev ? `\\nif (import.meta.hot) {\\n __meeko.enableHotModule(__hotId);\\n import.meta.hot.accept((next) => { if (next) __meeko.replaceHotModule(__hotId, next); });\\n}\\n` : \"\";\n const registry = await discoverAutoImports(root);\n const code = transformAutoImports(source, filename, result.code, registry, serverTransform ? \"server\" : \"client\");\n await checkBoundary(code);\n const shifted = code.length - result.code.length;\n const mappings = result.mappings.map((mapping) => ({\n ...mapping,\n generatedStart: mapping.generatedStart + shifted,\n generatedEnd: mapping.generatedEnd + shifted,\n }));\n const generated = `${code}${cssImport}${hotCode}`;\n return transformWithOxc(generated, `${filename}.ts`, { lang: \"ts\" }, sourceMapForCompiled(generated, source, filename, mappings));\n },\n handleHotUpdate({ file, server }) {\n const normalized = normalizePath(file);\n const relative = normalized.slice(normalizePath(root).length + 1);\n const registrySource = /^(?:app\\/(?:components|composables|utils|stores)|shared\\/(?:types|schemas|utils|constants|enums)|server\\/utils)\\//.test(relative);\n const routesSource = /^(?:app\\/pages|layers\\/|modules\\/)/.test(relative) || relative.startsWith(\"meeko.config.\");\n if (!normalized.startsWith(runtimeDirectory) && !registrySource && !routesSource) return;\n server.moduleGraph.invalidateAll();\n server.ws.send({ type: \"full-reload\" });\n return [];\n },\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meekojs/meeko",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"packageManager": "pnpm@12.14.0",
|
|
5
5
|
"description": "Typed .meeko component engine with SSR, hydration, signals, Vite, and DevTools.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,6 +21,14 @@
|
|
|
21
21
|
"types": "./dist/vite.d.ts",
|
|
22
22
|
"default": "./dist/vite.js"
|
|
23
23
|
},
|
|
24
|
+
"./framework": {
|
|
25
|
+
"types": "./dist/framework.d.ts",
|
|
26
|
+
"default": "./dist/framework.js"
|
|
27
|
+
},
|
|
28
|
+
"./server": {
|
|
29
|
+
"types": "./dist/node.d.ts",
|
|
30
|
+
"default": "./dist/node.js"
|
|
31
|
+
},
|
|
24
32
|
"./internal": {
|
|
25
33
|
"types": "./dist/internal.d.ts",
|
|
26
34
|
"default": "./dist/internal.js"
|
|
@@ -49,7 +57,7 @@
|
|
|
49
57
|
"pilot:check": "pnpm run build && node dist/cli.js check examples/pilot/App.meeko && node dist/cli.js types examples/pilot/App.meeko && tsc -p examples/pilot/tsconfig.json --noEmit",
|
|
50
58
|
"pilot:build": "tsx examples/pilot/build.ts",
|
|
51
59
|
"pilot:serve": "node examples/pilot/.output/server/http.js",
|
|
52
|
-
"pilot:e2e": "tsx --test tests/pilot.e2e.ts",
|
|
60
|
+
"pilot:e2e": "node --import tsx --test --test-force-exit tests/pilot.e2e.ts",
|
|
53
61
|
"e2e": "pnpm run example:bundle && pnpm run vite:build && tsx --test tests/browser.e2e.ts",
|
|
54
62
|
"benchmark:check": "pnpm run example:compile && node dist/cli.js compile benchmarks/cases/TreeLeaf.meeko benchmarks/cases/TreeLeaf.generated.ts && node dist/cli.js compile benchmarks/cases/TreeBranch.meeko benchmarks/cases/TreeBranch.generated.ts && node dist/cli.js compile benchmarks/cases/Tree.meeko benchmarks/cases/Tree.generated.ts && node dist/cli.js compile benchmarks/cases/List.meeko benchmarks/cases/List.generated.ts && node dist/cli.js compile benchmarks/cases/Navigation.meeko benchmarks/cases/Navigation.generated.ts && tsc -p tsconfig.benchmark.json --noEmit",
|
|
55
63
|
"benchmark": "pnpm run build && pnpm run benchmark:check && node --expose-gc --import tsx benchmarks/run.ts",
|
|
@@ -63,7 +71,8 @@
|
|
|
63
71
|
"parse5": "^8.0.0",
|
|
64
72
|
"postcss": "^8.5.31",
|
|
65
73
|
"postcss-selector-parser": "^7.1.7",
|
|
66
|
-
"typescript": "7.0.2"
|
|
74
|
+
"typescript": "7.0.2",
|
|
75
|
+
"ws": "8.22.0"
|
|
67
76
|
},
|
|
68
77
|
"peerDependencies": {
|
|
69
78
|
"vite": "^8.3.5"
|
|
@@ -73,9 +82,11 @@
|
|
|
73
82
|
},
|
|
74
83
|
"devDependencies": {
|
|
75
84
|
"@types/node": "^24.0.0",
|
|
85
|
+
"@types/ws": "8.18.2",
|
|
76
86
|
"esbuild": "0.28.2",
|
|
77
87
|
"happy-dom": "^20.0.0",
|
|
78
88
|
"playwright-core": "1.64.1",
|
|
89
|
+
"redis": "6.3.0",
|
|
79
90
|
"tsx": "^4.20.0",
|
|
80
91
|
"vite": "8.3.5",
|
|
81
92
|
"vue": "3.5.44"
|