mikuru 1.0.23 → 1.0.25
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/CHANGELOG.md +14 -0
- package/README.md +11 -10
- package/dist/compiler/compatDiagnostics.d.ts +8 -0
- package/dist/compiler/compatDiagnostics.js +45 -0
- package/dist/compiler/compatDiagnostics.js.map +1 -0
- package/dist/compiler/compile.js +40 -16
- package/dist/compiler/compile.js.map +1 -1
- package/dist/compiler/compileHydration.js +31 -18
- package/dist/compiler/compileHydration.js.map +1 -1
- package/dist/compiler/compileSsr.js +27 -14
- package/dist/compiler/compileSsr.js.map +1 -1
- package/dist/compiler/css.d.ts +19 -0
- package/dist/compiler/css.js +420 -0
- package/dist/compiler/css.js.map +1 -0
- package/dist/compiler/generate.d.ts +17 -1
- package/dist/compiler/generate.js +169 -34
- package/dist/compiler/generate.js.map +1 -1
- package/dist/compiler/generateHydration.js +185 -30
- package/dist/compiler/generateHydration.js.map +1 -1
- package/dist/compiler/generateSsr.js +14 -4
- package/dist/compiler/generateSsr.js.map +1 -1
- package/dist/compiler/index.d.ts +2 -0
- package/dist/compiler/index.js +1 -0
- package/dist/compiler/index.js.map +1 -1
- package/dist/compiler/parseTemplate.js +18 -5
- package/dist/compiler/parseTemplate.js.map +1 -1
- package/dist/compiler/types.d.ts +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/router/index.js +27 -3
- package/dist/router/index.js.map +1 -1
- package/dist/runtime/asyncComponent.js +24 -4
- package/dist/runtime/asyncComponent.js.map +1 -1
- package/dist/runtime/devtools.d.ts +21 -0
- package/dist/runtime/devtools.js +36 -0
- package/dist/runtime/devtools.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -2
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/server.js +16 -6
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
- package/templates/basic/src/App.mikuru +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.25 - 2026-05-15
|
|
4
|
+
|
|
5
|
+
- Added Mikuru-native `m-*` directive syntax across DOM rendering, SSR, and hydration while keeping `v-*` as compatibility aliases.
|
|
6
|
+
- Added debug compiler warnings for `v-*` compatibility aliases, pointing users to the matching `m-*` directive spelling.
|
|
7
|
+
- Updated README, docs, examples, and templates to present `m-*` as the recommended directive syntax.
|
|
8
|
+
- Added shared Debug Inspector diagnostic payloads for compiler, runtime, router, SSR, and hydration warning/error events.
|
|
9
|
+
- Expanded the dogfood Debug Panel with a searchable and collapsible component tree, component root reveal, event filters/search, event-to-component navigation, and copyable compact debug snapshots.
|
|
10
|
+
- Split dogfood Debug Panel filtering, tree, formatting, and snapshot logic into tested example helpers while documenting that they are not public package exports.
|
|
11
|
+
- Improved scoped CSS rewriting coverage for complex selectors, nested at-rules, comments, strings, and malformed CSS diagnostics.
|
|
12
|
+
- Added support for `<template m-if>` / `<template m-else-if>` / `<template m-else>` fragment branches across DOM rendering, SSR, and hydration.
|
|
13
|
+
- Added support for keyed `<template m-for>` fragment rows across DOM rendering, SSR, and hydration.
|
|
14
|
+
- Expanded `<template m-for>` coverage for unkeyed fragments, nested fragment loops, and nested `m-if` / `m-else` branches.
|
|
15
|
+
- Added hydrated `m-for` reconciliation so element and `<template m-for>` lists can append, remove, replace, and recreate rows after SSR hydration.
|
|
16
|
+
|
|
3
17
|
## 1.0.23 - 2026-05-13
|
|
4
18
|
|
|
5
19
|
- Added structured hydration diagnostic payloads with warning kind, recovery action, inferred expected/actual values, and DOM path context.
|
package/README.md
CHANGED
|
@@ -132,23 +132,24 @@ declare const Greeting: MikuruComponent<GreetingProps>;
|
|
|
132
132
|
- `.mikuru` SFCs with `<template>`, `<script>`, and `<style>`
|
|
133
133
|
- Vite plugin support through `mikuru/vite`
|
|
134
134
|
- Template interpolation with `{{ value }}`
|
|
135
|
-
- DOM events with `@click`, `
|
|
135
|
+
- DOM events with `@click`, `m-on:click`, inline handlers, object-form option modifiers, `.prevent`, `.stop`, `.self`, `.once`, `.capture`, `.passive`, key, mouse button, system, and `.exact` modifiers
|
|
136
136
|
- Component events with `@select` and `.once`
|
|
137
|
-
- Attribute bindings with normalized `:class` and `:style`, boolean/form property sync, direct/object `
|
|
138
|
-
- `
|
|
139
|
-
- `
|
|
137
|
+
- Attribute bindings with normalized `:class` and `:style`, boolean/form property sync, direct/object `m-bind` modifiers like `.prop`, `.attr`, and `.camel`, plus dynamic arguments like `:[name]` and `@[event]`
|
|
138
|
+
- `m-if`, `m-else-if`, `m-else`, `m-show`, `m-for`, `m-html`, `m-text`, `m-pre`, and `m-cloak`
|
|
139
|
+
- `m-model` for common form controls, checkbox arrays, radio groups, multiple selects, modifiers, and named child component models
|
|
140
|
+
- `v-*` directive spellings remain available as compatibility aliases for existing components and Vue-oriented migrations
|
|
140
141
|
- Component props, events, DOM attribute fallthrough, `useAttrs`, template refs, `defineProps`, `defineEmits`, default slots, named/dynamic slots, and slot props with simple defaults
|
|
141
|
-
- CSS class transitions with built-in `<Transition name="fade">`, `
|
|
142
|
+
- CSS class transitions with built-in `<Transition name="fade">`, `m-if` chains, dynamic components, class overrides, `appear`, `mode="out-in"`, and `<TransitionGroup>` for keyed lists
|
|
142
143
|
- Built-in `<Teleport to="#target">` for rendering content outside the current DOM position
|
|
143
144
|
- Built-in `<AsyncBoundary :loading :fallback :delay :timeout>` for grouped async loading, delayed loading UI, boundary timeouts, and retryable async failures with aggregated fallback errors
|
|
144
145
|
- Built-in `<ErrorBoundary :fallback>` for local component mount, descendant event handler, lifecycle, and cleanup fallbacks, with `errorInfo`, `retry`, `reset`, and `:reset-key` recovery
|
|
145
146
|
- Runtime helpers including `ref`, `isRef`, `unref`, `toRef`, `toRefs`, `reactive`, `readonly`, lazy cached read-only and writable `computed`, `effect` with optional scheduling, `queueJob`/`flushJobs`, `watch`, `watchEffect` with cleanup callbacks, `nextTick`, lifecycle callbacks including KeepAlive activation hooks, `provide`, `inject`, and `defineAsyncComponent` with ErrorBoundary handoff and SSR loader resolution
|
|
146
147
|
- Routing through `mikuru/router` with route matching, history/hash/memory histories, guards, router context helpers, and `RouterView` / `RouterLink` across mount, SSR, and hydration
|
|
147
|
-
- SSR through `compileSsr()` and `mikuru/server`, covering escaped text, static and bound attributes, content directives, `
|
|
148
|
-
- Hydration through `compileHydration()` and `hydrateRoute()`, reusing existing SSR DOM while attaching events, syncing text/attributes, recovering structural mismatches with an opt-out remount fallback, hydrating component context/lifecycle hooks, `
|
|
148
|
+
- SSR through `compileSsr()` and `mikuru/server`, covering escaped text, static and bound attributes, content directives, `m-pre`, `m-cloak`, `m-if` chains, `m-for`, async child components, props, named/default slots, scoped slot props, component tree context, Teleport collection, string and async iterable stream rendering, and router route rendering with context propagation
|
|
149
|
+
- Hydration through `compileHydration()` and `hydrateRoute()`, reusing existing SSR DOM while attaching events, syncing text/attributes, recovering structural mismatches with an opt-out remount fallback, hydrating component context/lifecycle hooks, `m-show`, DOM and component `m-model`, `m-pre`, `m-cloak`, initial `m-if` / `m-for` DOM, Teleport target and disabled inline content, delegating child and route components to `hydrate()` when available, and optionally starting router history listening after route hydration
|
|
149
150
|
- Style injection and basic `<style scoped>` selector rewriting
|
|
150
151
|
- Compile errors with filenames, line/column information, code frames, and typo suggestions for built-in attributes, directives, and modifiers
|
|
151
|
-
- Debug diagnostics with optional generated `sourceURL`, unstable devtools metadata/events, and hydration warnings that include phase, component, and filename context
|
|
152
|
+
- Debug diagnostics with optional generated `sourceURL`, `v-*` compatibility warnings, unstable devtools metadata/events, and hydration warnings that include phase, component, and filename context
|
|
152
153
|
|
|
153
154
|
## Package Exports
|
|
154
155
|
|
|
@@ -199,8 +200,8 @@ npx mikuru --list-templates
|
|
|
199
200
|
<template>
|
|
200
201
|
<button @click="open = !open">Toggle</button>
|
|
201
202
|
<Transition name="fade">
|
|
202
|
-
<p
|
|
203
|
-
<p
|
|
203
|
+
<p m-if="open">Saved changes</p>
|
|
204
|
+
<p m-else>Waiting for edits</p>
|
|
204
205
|
</Transition>
|
|
205
206
|
</template>
|
|
206
207
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ElementNode } from "./types.js";
|
|
2
|
+
type CompatDirectiveDiagnosticOptions = {
|
|
3
|
+
debug?: boolean;
|
|
4
|
+
filename?: string;
|
|
5
|
+
phase: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function emitCompatDirectiveDiagnostics(ast: ElementNode, options: CompatDirectiveDiagnosticOptions): void;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { emitDebugDiagnostic } from "../runtime/devtools.js";
|
|
2
|
+
export function emitCompatDirectiveDiagnostics(ast, options) {
|
|
3
|
+
if (options.debug !== true) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
walkElement(ast, (node) => {
|
|
7
|
+
for (const attr of node.attrs) {
|
|
8
|
+
if (!isLegacyDirectiveAttr(attr)) {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
const sourceName = attr.sourceName ?? attr.name;
|
|
12
|
+
const preferredName = preferredDirectiveName(sourceName);
|
|
13
|
+
emitDebugDiagnostic("compiler", "warning", `${sourceName} is supported as a compatibility alias. Prefer ${preferredName} in Mikuru components.`, {
|
|
14
|
+
phase: options.phase,
|
|
15
|
+
filename: options.filename,
|
|
16
|
+
directive: sourceName,
|
|
17
|
+
preferredDirective: preferredName,
|
|
18
|
+
tag: node.tag,
|
|
19
|
+
loc: attr.loc
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function walkElement(node, visit) {
|
|
25
|
+
visit(node);
|
|
26
|
+
if (node.attrs.some((attr) => attr.name === "v-pre")) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
for (const child of node.children) {
|
|
30
|
+
if (isElementNode(child)) {
|
|
31
|
+
walkElement(child, visit);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function isElementNode(node) {
|
|
36
|
+
return node.type === "element";
|
|
37
|
+
}
|
|
38
|
+
function isLegacyDirectiveAttr(attr) {
|
|
39
|
+
const sourceName = attr.sourceName ?? attr.name;
|
|
40
|
+
return sourceName.startsWith("v-");
|
|
41
|
+
}
|
|
42
|
+
function preferredDirectiveName(name) {
|
|
43
|
+
return name.startsWith("v-") ? `m-${name.slice("v-".length)}` : name;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=compatDiagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatDiagnostics.js","sourceRoot":"","sources":["../../src/compiler/compatDiagnostics.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAQ7D,MAAM,UAAU,8BAA8B,CAAC,GAAgB,EAAE,OAAyC;IACxG,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAC3B,OAAO;IACT,CAAC;IAED,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;QACxB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC;gBACjC,SAAS;YACX,CAAC;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC;YAChD,MAAM,aAAa,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;YACzD,mBAAmB,CACjB,UAAU,EACV,SAAS,EACT,GAAG,UAAU,kDAAkD,aAAa,wBAAwB,EACpG;gBACE,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,SAAS,EAAE,UAAU;gBACrB,kBAAkB,EAAE,aAAa;gBACjC,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,GAAG,EAAE,IAAI,CAAC,GAAG;aACd,CACF,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,WAAW,CAAC,IAAiB,EAAE,KAAkC;IACxE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEZ,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,EAAE,CAAC;QACrD,OAAO;IACT,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClC,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,IAAkB;IACvC,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;AACjC,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAuB;IACpD,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC;IAChD,OAAO,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACvE,CAAC"}
|
package/dist/compiler/compile.js
CHANGED
|
@@ -1,24 +1,48 @@
|
|
|
1
1
|
import { analyzeTemplate } from "./analyzeTemplate.js";
|
|
2
|
+
import { emitCompatDirectiveDiagnostics } from "./compatDiagnostics.js";
|
|
3
|
+
import { compileDescriptorStyle } from "./css.js";
|
|
2
4
|
import { generate } from "./generate.js";
|
|
3
5
|
import { parseSfc } from "./parseSfc.js";
|
|
4
6
|
import { parseTemplate } from "./parseTemplate.js";
|
|
5
7
|
import { createSourceMap } from "./sourceMap.js";
|
|
8
|
+
import { emitDebugDiagnostic } from "../runtime/devtools.js";
|
|
6
9
|
export function compile(source, options = {}) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
try {
|
|
11
|
+
const descriptor = parseSfc(source, options.filename);
|
|
12
|
+
const ast = parseTemplate(descriptor.template, {
|
|
13
|
+
filename: options.filename,
|
|
14
|
+
source,
|
|
15
|
+
offset: descriptor.templateOffset
|
|
16
|
+
});
|
|
17
|
+
emitCompatDirectiveDiagnostics(ast, { debug: options.debug === true, filename: options.filename, phase: "compile" });
|
|
18
|
+
if (options.debug === true && descriptor.style?.trim()) {
|
|
19
|
+
const styleResult = compileDescriptorStyle(descriptor, descriptor.styleScoped ? `data-mikuru-scope-preview` : undefined);
|
|
20
|
+
for (const diagnostic of styleResult.diagnostics) {
|
|
21
|
+
emitDebugDiagnostic("compiler", diagnostic.level, diagnostic.message, {
|
|
22
|
+
phase: "style",
|
|
23
|
+
filename: options.filename,
|
|
24
|
+
offset: diagnostic.offset
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const bindings = analyzeTemplate(ast, { source, filename: options.filename });
|
|
29
|
+
const code = generate(descriptor, ast, { debug: options.debug === true, batchedUpdates: options.batchedUpdates === true });
|
|
30
|
+
const map = createSourceMap(code, descriptor, ast);
|
|
31
|
+
return {
|
|
32
|
+
code,
|
|
33
|
+
map,
|
|
34
|
+
descriptor,
|
|
35
|
+
ast,
|
|
36
|
+
bindings
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
emitDebugDiagnostic("compiler", "error", error instanceof Error ? error.message : String(error), {
|
|
41
|
+
phase: "compile",
|
|
42
|
+
filename: options.filename,
|
|
43
|
+
error
|
|
44
|
+
});
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
23
47
|
}
|
|
24
48
|
//# sourceMappingURL=compile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,UAAU,OAAO,CAAC,MAAc,EAAE,UAA0B,EAAE;IAClE,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,GAAG,GAAG,aAAa,CAAC,U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G;YACH,QAAQ;SACT,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,mBAAmB,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YAC/F,KAAK,EAAE,SAAS;YAChB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK;SACN,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1,27 +1,40 @@
|
|
|
1
1
|
import { analyzeTemplate } from "./analyzeTemplate.js";
|
|
2
|
+
import { emitCompatDirectiveDiagnostics } from "./compatDiagnostics.js";
|
|
2
3
|
import { generate } from "./generate.js";
|
|
3
4
|
import { generateHydration } from "./generateHydration.js";
|
|
4
5
|
import { parseSfc } from "./parseSfc.js";
|
|
5
6
|
import { parseTemplate } from "./parseTemplate.js";
|
|
6
7
|
import { createSourceMap } from "./sourceMap.js";
|
|
8
|
+
import { emitDebugDiagnostic } from "../runtime/devtools.js";
|
|
7
9
|
export function compileHydration(source, options = {}) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
code,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
try {
|
|
11
|
+
const descriptor = parseSfc(source, options.filename);
|
|
12
|
+
const ast = parseTemplate(descriptor.template, {
|
|
13
|
+
filename: options.filename,
|
|
14
|
+
source,
|
|
15
|
+
offset: descriptor.templateOffset
|
|
16
|
+
});
|
|
17
|
+
emitCompatDirectiveDiagnostics(ast, { debug: options.debug === true, filename: options.filename, phase: "compile-hydration" });
|
|
18
|
+
const bindings = analyzeTemplate(ast, { source, filename: options.filename });
|
|
19
|
+
const mountCode = generate(descriptor, ast, { debug: options.debug === true, batchedUpdates: options.batchedUpdates === true });
|
|
20
|
+
const hydrationCode = generateHydration(descriptor, ast, { includeImports: false });
|
|
21
|
+
const code = mountCode.replace("export default __mikuru_component;", `${hydrationCode}\nconst __mikuru_hydrationComponent = { ...__mikuru_component, hydrate };\nexport default __mikuru_hydrationComponent;`);
|
|
22
|
+
const map = createSourceMap(code, descriptor, ast);
|
|
23
|
+
return {
|
|
24
|
+
code,
|
|
25
|
+
map,
|
|
26
|
+
descriptor,
|
|
27
|
+
ast,
|
|
28
|
+
bindings
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
emitDebugDiagnostic("compiler", "error", error instanceof Error ? error.message : String(error), {
|
|
33
|
+
phase: "compile-hydration",
|
|
34
|
+
filename: options.filename,
|
|
35
|
+
error
|
|
36
|
+
});
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
26
39
|
}
|
|
27
40
|
//# sourceMappingURL=compileHydration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileHydration.js","sourceRoot":"","sources":["../../src/compiler/compileHydration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"compileHydration.js","sourceRoot":"","sources":["../../src/compiler/compileHydration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,8BAA8B,EAAE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AI,GAAG,SAAS,CAAC,OAAO,CAAC,oCAAoC,EAAE,GAAG,aAAa,wHAAwH,CAAC,CAAC;QAC/M,MAAM,GAAG,GAAG,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;QAEnD,OAAO;YACL,IAAI;YACJ,GAAG;YACH,UAAU;YACV,GAAG;YACH,QAAQ;SACT,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,mBAAmB,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YAC/F,KAAK,EAAE,mBAAmB;YAC1B,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK;SACN,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
import { analyzeTemplate } from "./analyzeTemplate.js";
|
|
2
|
+
import { emitCompatDirectiveDiagnostics } from "./compatDiagnostics.js";
|
|
2
3
|
import { generateSsr } from "./generateSsr.js";
|
|
3
4
|
import { parseSfc } from "./parseSfc.js";
|
|
4
5
|
import { parseTemplate } from "./parseTemplate.js";
|
|
6
|
+
import { emitDebugDiagnostic } from "../runtime/devtools.js";
|
|
5
7
|
export function compileSsr(source, options = {}) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
code,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
try {
|
|
9
|
+
const descriptor = parseSfc(source, options.filename);
|
|
10
|
+
const ast = parseTemplate(descriptor.template, {
|
|
11
|
+
filename: options.filename,
|
|
12
|
+
source,
|
|
13
|
+
offset: descriptor.templateOffset
|
|
14
|
+
});
|
|
15
|
+
emitCompatDirectiveDiagnostics(ast, { debug: options.debug === true, filename: options.filename, phase: "compile-ssr" });
|
|
16
|
+
const bindings = analyzeTemplate(ast, { source, filename: options.filename });
|
|
17
|
+
const code = generateSsr(descriptor, ast);
|
|
18
|
+
return {
|
|
19
|
+
code,
|
|
20
|
+
descriptor,
|
|
21
|
+
ast,
|
|
22
|
+
bindings
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
emitDebugDiagnostic("compiler", "error", error instanceof Error ? error.message : String(error), {
|
|
27
|
+
phase: "compile-ssr",
|
|
28
|
+
filename: options.filename,
|
|
29
|
+
error
|
|
30
|
+
});
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
20
33
|
}
|
|
21
34
|
//# sourceMappingURL=compileSsr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileSsr.js","sourceRoot":"","sources":["../../src/compiler/compileSsr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"compileSsr.js","sourceRoot":"","sources":["../../src/compiler/compileSsr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,UAA0B,EAAE;IACrE,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,GAAG,GAAG,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE;YAC7C,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,MAAM;YACN,MAAM,EAAE,UAAU,CAAC,cAAc;SAClC,CAAC,CAAC;QACH,8BAA8B,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;QACzH,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9E,MAAM,IAAI,GAAG,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAE1C,OAAO;YACL,IAAI;YACJ,UAAU;YACV,GAAG;YACH,QAAQ;SACT,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,mBAAmB,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YAC/F,KAAK,EAAE,aAAa;YACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK;SACN,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SfcDescriptor } from "./types.js";
|
|
2
|
+
export type CssCompileDiagnostic = {
|
|
3
|
+
level: "warning";
|
|
4
|
+
message: string;
|
|
5
|
+
offset?: number;
|
|
6
|
+
};
|
|
7
|
+
export type CssCompileOptions = {
|
|
8
|
+
filename?: string;
|
|
9
|
+
scoped?: boolean;
|
|
10
|
+
scopeAttr?: string;
|
|
11
|
+
};
|
|
12
|
+
export type CssCompileResult = {
|
|
13
|
+
code: string;
|
|
14
|
+
scoped: boolean;
|
|
15
|
+
scopeAttr?: string;
|
|
16
|
+
diagnostics: CssCompileDiagnostic[];
|
|
17
|
+
};
|
|
18
|
+
export declare function compileStyle(css: string, options?: CssCompileOptions): CssCompileResult;
|
|
19
|
+
export declare function compileDescriptorStyle(descriptor: SfcDescriptor, scopeAttr?: string): CssCompileResult;
|