mikuru 1.0.19 → 1.0.20
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 +74 -0
- package/README.md +18 -12
- package/dist/compiler/analyzeTemplate.js +116 -12
- package/dist/compiler/analyzeTemplate.js.map +1 -1
- package/dist/compiler/compile.js +2 -2
- package/dist/compiler/compile.js.map +1 -1
- package/dist/compiler/compileHydration.d.ts +2 -0
- package/dist/compiler/compileHydration.js +27 -0
- package/dist/compiler/compileHydration.js.map +1 -0
- package/dist/compiler/compileSsr.d.ts +2 -0
- package/dist/compiler/compileSsr.js +21 -0
- package/dist/compiler/compileSsr.js.map +1 -0
- package/dist/compiler/generate.d.ts +6 -1
- package/dist/compiler/generate.js +1399 -93
- package/dist/compiler/generate.js.map +1 -1
- package/dist/compiler/generateHydration.d.ts +2 -0
- package/dist/compiler/generateHydration.js +1281 -0
- package/dist/compiler/generateHydration.js.map +1 -0
- package/dist/compiler/generateSsr.d.ts +2 -0
- package/dist/compiler/generateSsr.js +764 -0
- package/dist/compiler/generateSsr.js.map +1 -0
- package/dist/compiler/index.d.ts +3 -1
- package/dist/compiler/index.js +2 -0
- package/dist/compiler/index.js.map +1 -1
- package/dist/compiler/parseTemplate.js +16 -1
- package/dist/compiler/parseTemplate.js.map +1 -1
- package/dist/compiler/sourceMap.d.ts +2 -2
- package/dist/compiler/sourceMap.js +110 -6
- package/dist/compiler/sourceMap.js.map +1 -1
- package/dist/compiler/types.d.ts +8 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/router/index.js +16 -3
- package/dist/router/index.js.map +1 -1
- package/dist/runtime/asyncComponent.d.ts +17 -1
- package/dist/runtime/asyncComponent.js +54 -2
- package/dist/runtime/asyncComponent.js.map +1 -1
- package/dist/runtime/devtools.d.ts +51 -0
- package/dist/runtime/devtools.js +113 -0
- package/dist/runtime/devtools.js.map +1 -0
- package/dist/runtime/dom.d.ts +5 -1
- package/dist/runtime/dom.js +100 -3
- package/dist/runtime/dom.js.map +1 -1
- package/dist/runtime/index.d.ts +7 -5
- package/dist/runtime/index.js +3 -2
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/lifecycle.d.ts +6 -0
- package/dist/runtime/lifecycle.js +66 -10
- package/dist/runtime/lifecycle.js.map +1 -1
- package/dist/runtime/reactivity.d.ts +33 -1
- package/dist/runtime/reactivity.js +254 -13
- package/dist/runtime/reactivity.js.map +1 -1
- package/dist/server.d.ts +31 -0
- package/dist/server.js +282 -0
- package/dist/server.js.map +1 -0
- package/dist/vite.d.ts +1 -0
- package/dist/vite.js +30 -13
- package/dist/vite.js.map +1 -1
- package/package.json +104 -100
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.20 - 2026-05-13
|
|
4
|
+
|
|
5
|
+
- Added SSR phase 1 with `compileSsr()` and `mikuru/server` helpers for escaped HTML, attributes, `v-if` chains, and `v-for` output.
|
|
6
|
+
- Added SSR child component rendering with props and default slot projection.
|
|
7
|
+
- Added async SSR child rendering plus named and scoped SSR slots.
|
|
8
|
+
- Added SSR support for dynamic `<component :is>` rendering with component props and slots.
|
|
9
|
+
- Added SSR and hydration support for initial `<KeepAlive><component :is>` children.
|
|
10
|
+
- Added SSR and hydration support for initial `<AsyncBoundary>` children.
|
|
11
|
+
- Added `renderRouteToString()` for router SSR with redirects, lazy route components, nested route slots, and route props.
|
|
12
|
+
- Added hydration phase 1 with `compileHydration()` for existing DOM reuse, event attachment, and text/attribute sync.
|
|
13
|
+
- Improved hydration mismatch diagnostics with expected/actual node details and extra-node warnings.
|
|
14
|
+
- Added hydration support for initial dynamic `<component :is>` branches with mount fallback.
|
|
15
|
+
- Added hydration static attribute mismatch diagnostics for SSR/client drift.
|
|
16
|
+
- Added hydration text content mismatch diagnostics before text nodes are synchronized.
|
|
17
|
+
- Added hydration `v-html` / `v-text` content mismatch diagnostics before content directives are synchronized.
|
|
18
|
+
- Added hydration `v-model` DOM property mismatch diagnostics before form controls are synchronized.
|
|
19
|
+
- Added hydration multiple-select `v-model` mismatch diagnostics before option selections are synchronized.
|
|
20
|
+
- Added object-valued `option :value` support for select, multiple select, checkbox, and radio `v-model` bindings.
|
|
21
|
+
- Added hydration support for initial `v-if` / `v-for` DOM reuse and child component `hydrate()` delegation with mount fallback.
|
|
22
|
+
- Added `hydrateRoute()` for router hydration with redirects, lazy route components, route props, nested route slots, and mount fallback.
|
|
23
|
+
- Added SSR Teleport collection and Teleport hydration for target-side DOM reuse.
|
|
24
|
+
- Added disabled Teleport SSR hydration for inline Teleport content reuse.
|
|
25
|
+
- Added dynamic disabled Teleport SSR hydration without shifting sibling hydration.
|
|
26
|
+
- Added SSR component tree context so generated SSR components can scope `provide()` / `inject()` and pass context to child components.
|
|
27
|
+
- Added router SSR and route hydration context propagation, including provided router access for route components.
|
|
28
|
+
- Added `hydrateRoute(..., { listen: true })` to start browser/router history listening after route hydration and stop it on unmount.
|
|
29
|
+
- Added hydration support for `v-show` and DOM `v-model` controls, including checkbox arrays and multiple selects.
|
|
30
|
+
- Improved hydration event handling so DOM event modifiers and object-form `v-on` option modifiers are applied during listener attachment.
|
|
31
|
+
- Added hydration support for child component `v-model` props, update handlers, named models, and modifiers.
|
|
32
|
+
- Added hydration support for DOM and component template refs, including `v-for` array refs and unmount cleanup.
|
|
33
|
+
- Improved hydration attribute reconciliation so static classes survive dynamic `:class` updates and object `v-bind` removes stale attrs.
|
|
34
|
+
- Improved class/style normalization across SSR, mount, and hydration so static styles survive dynamic `:style` and object `v-bind` updates.
|
|
35
|
+
- Added `v-html` and `v-text` content directives across generated DOM, SSR, and hydration.
|
|
36
|
+
- Added `v-pre` and `v-cloak` support across generated DOM, SSR, and hydration.
|
|
37
|
+
- Added dynamic template arguments with `:[name]`, `v-bind:[name]`, `@[event]`, and `v-on:[event]`.
|
|
38
|
+
- Added object-form `v-on.once`, `v-on.capture`, and `v-on.passive` option modifiers for native elements.
|
|
39
|
+
- Added `v-bind` modifiers `.prop`, `.attr`, and `.camel` for native element attribute/property control.
|
|
40
|
+
- Added object-form `v-bind.prop`, `v-bind.attr`, and `v-bind.camel` modifiers for native elements.
|
|
41
|
+
- Added DOM event key and system modifiers such as `@keydown.enter` and `@keydown.ctrl.enter`.
|
|
42
|
+
- Added DOM mouse button and exact modifiers such as `@click.right` and `@click.ctrl.exact`.
|
|
43
|
+
- Added inline DOM event handler assignments such as `@click="count += 1"` and `$event` usage.
|
|
44
|
+
- Improved boolean and form property bindings so `disabled`, `checked`, `selected`, and `value` sync DOM properties while non-boolean `false` renders as `"false"`.
|
|
45
|
+
- Added hydration component context for scoped `provide()` / `inject()`, lifecycle callbacks, and child component context forwarding.
|
|
46
|
+
- Added `isRef()`, `unref()`, `toRef()`, and `toRefs()` runtime ref interop helpers.
|
|
47
|
+
- Added built-in `<AsyncBoundary>` for grouped async loading and retryable async failures.
|
|
48
|
+
- Extended `<AsyncBoundary>` to support multiple child nodes with live `pending` updates.
|
|
49
|
+
- Added `<AsyncBoundary :delay :timeout>` for delayed loading UI and boundary-level async timeouts.
|
|
50
|
+
- Added `errors` to `MikuruAsyncBoundaryFallbackProps` so async fallbacks can inspect aggregated failures.
|
|
51
|
+
- Improved compile diagnostics for built-in component attribute typos with `Did you mean ...?` suggestions.
|
|
52
|
+
- Improved compile diagnostics for directive and event/model modifier typos with close-match suggestions.
|
|
53
|
+
- Improved Vite transform error forwarding so fallback compile-time errors include `id`, `loc`, and `frame`.
|
|
54
|
+
- Improved generated source maps for template element, interpolation, bound attribute, event handler, and script lines.
|
|
55
|
+
- Added an unstable debug-only `globalThis.__MIKURU_DEVTOOLS__` component metadata hook for future devtools experiments.
|
|
56
|
+
- Extended the unstable debug hook with component ids, props/attrs metadata, parent-child links, and component, async, and router event records.
|
|
57
|
+
- Added an unstable `createDebugInspector()` helper for reading debug components/events, clearing event history, and subscribing to debug events.
|
|
58
|
+
- Added a dogfood Debug Panel that uses `createDebugInspector()` to show mounted components, selected props/attrs, and the debug event log.
|
|
59
|
+
- Extended the dogfood Debug Panel with event category filters, selected event payload details, and a Router lab that emits navigation events.
|
|
60
|
+
- Added keyed `v-for` `v-memo` support to skip updating reused records while memo dependencies are unchanged.
|
|
61
|
+
- Added `v-once` support for one-time element/component rendering and keyed `v-for` records.
|
|
62
|
+
- Extended `v-model` with named component models, named model modifiers, and checkbox array support.
|
|
63
|
+
- Added writable `computed({ get, set })` refs and `watch(..., { once: true })` callbacks.
|
|
64
|
+
- Changed `computed` to evaluate lazily and cache values until dependencies change.
|
|
65
|
+
- Added `reactive()`, `readonly()`, `isReactive()`, `isReadonly()`, `isProxy()`, and `toRaw()` runtime helpers.
|
|
66
|
+
- Added `watchEffect()` with cleanup registration and `effect(fn, { scheduler })` for scheduled reruns.
|
|
67
|
+
- Added `queueJob()`, `flushJobs()`, and job-aware `nextTick()` for deduped microtask scheduling.
|
|
68
|
+
- Added `mikuru({ batchedUpdates: true })` and `compile(..., { batchedUpdates: true })` for opt-in queued generated DOM updates.
|
|
69
|
+
- Added built-in `<TransitionGroup>` for keyed list enter, leave, and move classes.
|
|
70
|
+
- Added minimal built-in `<KeepAlive>` support for caching a single dynamic `<component :is>` child.
|
|
71
|
+
- Extended `<KeepAlive>` with `:include`, `:exclude`, and `:max` cache controls.
|
|
72
|
+
- Added `onActivated()` and `onDeactivated()` lifecycle hooks for cached `<KeepAlive>` components, including async component forwarding.
|
|
73
|
+
- Added a dogfood AsyncBoundary lab and E2E coverage for loading and retryable async fallback.
|
|
74
|
+
- Added a dogfood ErrorBoundary lab and E2E coverage for diagnostics, fallback reset, and `:reset-key` recovery.
|
|
75
|
+
- Exported `MikuruErrorBoundaryFallbackProps` for typed ErrorBoundary fallback components.
|
|
76
|
+
|
|
3
77
|
## 1.0.19 - 2026-05-12
|
|
4
78
|
|
|
5
79
|
- Extended `<ErrorBoundary>` to catch descendant generated event handler, lifecycle callback, and cleanup errors through component tree error propagation.
|
package/README.md
CHANGED
|
@@ -67,6 +67,8 @@ export default defineConfig({
|
|
|
67
67
|
});
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
+
Use `mikuru({ batchedUpdates: true })` to opt into queued generated DOM effects. In that mode, DOM updates triggered by refs flush through the runtime job queue and can be awaited with `nextTick()`.
|
|
71
|
+
|
|
70
72
|
Create a `.mikuru` component:
|
|
71
73
|
|
|
72
74
|
```mikuru
|
|
@@ -130,19 +132,22 @@ declare const Greeting: MikuruComponent<GreetingProps>;
|
|
|
130
132
|
- `.mikuru` SFCs with `<template>`, `<script>`, and `<style>`
|
|
131
133
|
- Vite plugin support through `mikuru/vite`
|
|
132
134
|
- Template interpolation with `{{ value }}`
|
|
133
|
-
- DOM events with `@click`, `v-on:click`, `.prevent`, `.stop`, `.self`, `.once`, `.capture`, and `.
|
|
135
|
+
- DOM events with `@click`, `v-on:click`, inline handlers, object-form option modifiers, `.prevent`, `.stop`, `.self`, `.once`, `.capture`, `.passive`, key, mouse button, system, and `.exact` modifiers
|
|
134
136
|
- Component events with `@select` and `.once`
|
|
135
|
-
- Attribute bindings with normalized `:class` and `:style`
|
|
136
|
-
- `v-if`, `v-else-if`, `v-else`, `v-show`, and `v-
|
|
137
|
-
- `v-model` for common form controls, radio groups, multiple selects, modifiers, and child
|
|
137
|
+
- Attribute bindings with normalized `:class` and `:style`, boolean/form property sync, direct/object `v-bind` modifiers like `.prop`, `.attr`, and `.camel`, plus dynamic arguments like `:[name]` and `@[event]`
|
|
138
|
+
- `v-if`, `v-else-if`, `v-else`, `v-show`, `v-for`, `v-html`, `v-text`, `v-pre`, and `v-cloak`
|
|
139
|
+
- `v-model` for common form controls, checkbox arrays, radio groups, multiple selects, modifiers, and named child component models
|
|
138
140
|
- Component props, events, DOM attribute fallthrough, `useAttrs`, template refs, `defineProps`, `defineEmits`, default slots, named/dynamic slots, and slot props with simple defaults
|
|
139
|
-
- CSS class transitions with built-in `<Transition name="fade">`, `v-if` chains, dynamic components, class overrides, `appear`,
|
|
141
|
+
- CSS class transitions with built-in `<Transition name="fade">`, `v-if` chains, dynamic components, class overrides, `appear`, `mode="out-in"`, and `<TransitionGroup>` for keyed lists
|
|
140
142
|
- Built-in `<Teleport to="#target">` for rendering content outside the current DOM position
|
|
143
|
+
- Built-in `<AsyncBoundary :loading :fallback :delay :timeout>` for grouped async loading, delayed loading UI, boundary timeouts, and retryable async failures with aggregated fallback errors
|
|
141
144
|
- Built-in `<ErrorBoundary :fallback>` for local component mount, descendant event handler, lifecycle, and cleanup fallbacks, with `errorInfo`, `retry`, `reset`, and `:reset-key` recovery
|
|
142
|
-
- Runtime helpers including `ref`, `
|
|
145
|
+
- 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
|
|
143
146
|
- Routing through `mikuru/router` with route matching, history/hash/memory histories, guards, router context helpers, `RouterView`, and `RouterLink`
|
|
147
|
+
- SSR through `compileSsr()` and `mikuru/server`, covering escaped text, static and bound attributes, content directives, `v-pre`, `v-cloak`, `v-if` chains, `v-for`, async child components, props, named/default slots, scoped slot props, component tree context, Teleport collection, and router route rendering with context propagation
|
|
148
|
+
- Hydration through `compileHydration()` and `hydrateRoute()`, reusing existing SSR DOM while attaching events, syncing text/attributes, hydrating component context/lifecycle hooks, `v-show`, DOM and component `v-model`, `v-pre`, `v-cloak`, initial `v-if` / `v-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
|
|
144
149
|
- Style injection and basic `<style scoped>` selector rewriting
|
|
145
|
-
- Compile errors with filenames, line/column information, and
|
|
150
|
+
- Compile errors with filenames, line/column information, code frames, and typo suggestions for built-in attributes, directives, and modifiers
|
|
146
151
|
|
|
147
152
|
## Package Exports
|
|
148
153
|
|
|
@@ -170,12 +175,13 @@ The `.mikuru` TypeScript declaration is available from `mikuru/env`:
|
|
|
170
175
|
import "mikuru/env";
|
|
171
176
|
```
|
|
172
177
|
|
|
173
|
-
Compiler and
|
|
178
|
+
Compiler, runtime, and server entries are public for lower-level integrations:
|
|
174
179
|
|
|
175
180
|
```ts
|
|
176
|
-
import { compile } from "mikuru/compiler";
|
|
177
|
-
import { effect, nextTick, ref, unwrap, watch } from "mikuru/runtime";
|
|
178
|
-
import
|
|
181
|
+
import { compile, compileHydration, compileSsr } from "mikuru/compiler";
|
|
182
|
+
import { effect, isRef, nextTick, reactive, readonly, ref, toRef, toRefs, unref, unwrap, watch } from "mikuru/runtime";
|
|
183
|
+
import { hydrateRoute, renderComponentToString, renderRouteToString, renderToString } from "mikuru/server";
|
|
184
|
+
import type { MikuruAsyncBoundaryFallbackProps, MikuruErrorBoundaryFallbackProps, MikuruErrorInfo, MikuruErrorPhase } from "mikuru/runtime";
|
|
179
185
|
```
|
|
180
186
|
|
|
181
187
|
The package also provides the `mikuru` binary:
|
|
@@ -217,7 +223,7 @@ const open = ref(false);
|
|
|
217
223
|
|
|
218
224
|
## Not Included in v1
|
|
219
225
|
|
|
220
|
-
Mikuru does not claim Vue compatibility. The v1 package does not include
|
|
226
|
+
Mikuru does not claim Vue compatibility. The v1 package does not include stable devtools or full template type checking.
|
|
221
227
|
|
|
222
228
|
Scoped CSS is a basic selector rewrite, not a full CSS compiler. Avoid relying on `:global()`, deep selectors, complex nesting, CSS Modules, or preprocessors in v1.
|
|
223
229
|
|
|
@@ -2,11 +2,14 @@ import { createCompileError } from "./errors.js";
|
|
|
2
2
|
import { parseForExpression, validateAssignableExpression, validateTemplateExpression } from "./parseExpression.js";
|
|
3
3
|
export function analyzeTemplate(root, options = {}) {
|
|
4
4
|
const bindings = [];
|
|
5
|
-
visitNode(root, bindings, options);
|
|
5
|
+
visitNode(root, bindings, options, false);
|
|
6
6
|
return bindings;
|
|
7
7
|
}
|
|
8
|
-
function visitNode(node, bindings, options) {
|
|
8
|
+
function visitNode(node, bindings, options, inPre) {
|
|
9
9
|
if (node.type === "text") {
|
|
10
|
+
if (inPre) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
10
13
|
for (const part of node.parts) {
|
|
11
14
|
if (part.type === "expression") {
|
|
12
15
|
bindings.push({ type: "text", expression: part.value });
|
|
@@ -14,6 +17,13 @@ function visitNode(node, bindings, options) {
|
|
|
14
17
|
}
|
|
15
18
|
return;
|
|
16
19
|
}
|
|
20
|
+
const pre = inPre || hasAttr(node, "v-pre");
|
|
21
|
+
if (pre) {
|
|
22
|
+
for (const child of node.children) {
|
|
23
|
+
visitNode(child, bindings, options, true);
|
|
24
|
+
}
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
17
27
|
rejectUnsupportedNodeFeatures(node, options);
|
|
18
28
|
for (const attr of node.attrs) {
|
|
19
29
|
rejectUnsupportedAttribute(node, attr, options);
|
|
@@ -26,14 +36,35 @@ function visitNode(node, bindings, options) {
|
|
|
26
36
|
}
|
|
27
37
|
const event = parseEventDirective(attr.name);
|
|
28
38
|
if (event) {
|
|
39
|
+
if (event.nameExpression) {
|
|
40
|
+
bindings.push({
|
|
41
|
+
type: "attribute",
|
|
42
|
+
name: "event",
|
|
43
|
+
expression: validateTemplateExpression(event.nameExpression, attr.name, toExpressionContext(attr.loc, options))
|
|
44
|
+
});
|
|
45
|
+
}
|
|
29
46
|
bindings.push({
|
|
30
47
|
type: "event",
|
|
31
|
-
event: event.name,
|
|
32
|
-
handler:
|
|
48
|
+
event: event.name ?? "dynamic",
|
|
49
|
+
handler: requireEventHandlerValue(attr.name, attr.value),
|
|
33
50
|
modifiers: event.modifiers.length ? event.modifiers : undefined
|
|
34
51
|
});
|
|
35
52
|
continue;
|
|
36
53
|
}
|
|
54
|
+
const dynamicBinding = getDynamicBindingArgument(attr.name);
|
|
55
|
+
if (dynamicBinding) {
|
|
56
|
+
bindings.push({
|
|
57
|
+
type: "attribute",
|
|
58
|
+
name: "name",
|
|
59
|
+
expression: validateTemplateExpression(dynamicBinding.expression, attr.name, toExpressionContext(attr.loc, options))
|
|
60
|
+
});
|
|
61
|
+
bindings.push({
|
|
62
|
+
type: "attribute",
|
|
63
|
+
name: "value",
|
|
64
|
+
expression: validateTemplateExpression(requireStringValue(attr.name, attr.value), attr.name, toExpressionContext(attr.valueLoc, options))
|
|
65
|
+
});
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
37
68
|
const bindingName = getBindingName(attr.name);
|
|
38
69
|
if (bindingName) {
|
|
39
70
|
bindings.push({
|
|
@@ -71,20 +102,28 @@ function visitNode(node, bindings, options) {
|
|
|
71
102
|
});
|
|
72
103
|
continue;
|
|
73
104
|
}
|
|
105
|
+
if (attr.name === "v-html" || attr.name === "v-text") {
|
|
106
|
+
bindings.push({
|
|
107
|
+
type: "attribute",
|
|
108
|
+
name: attr.name === "v-html" ? "html" : "text",
|
|
109
|
+
expression: validateTemplateExpression(requireStringValue(attr.name, attr.value), attr.name, toExpressionContext(attr.valueLoc, options))
|
|
110
|
+
});
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
74
113
|
if (attr.name === "v-for") {
|
|
75
114
|
bindings.push(parseForBinding(requireStringValue(attr.name, attr.value), toExpressionContext(attr.valueLoc, options)));
|
|
76
115
|
}
|
|
77
116
|
}
|
|
78
117
|
for (const child of node.children) {
|
|
79
|
-
visitNode(child, bindings, options);
|
|
118
|
+
visitNode(child, bindings, options, false);
|
|
80
119
|
}
|
|
81
120
|
}
|
|
121
|
+
function hasAttr(node, name) {
|
|
122
|
+
return node.attrs.some((attr) => attr.name === name);
|
|
123
|
+
}
|
|
82
124
|
function rejectUnsupportedNodeFeatures(node, options) {
|
|
83
125
|
}
|
|
84
126
|
function rejectUnsupportedAttribute(node, attr, options) {
|
|
85
|
-
if (attr.name === "v-html") {
|
|
86
|
-
throwTemplateError("v-html is not supported in v1. Use text interpolation for plain text or set sanitized HTML from script code.", attr.loc, options);
|
|
87
|
-
}
|
|
88
127
|
if ((attr.name === "v-slot" || attr.name.startsWith("v-slot:") || attr.name.startsWith("#")) && node.tag !== "template") {
|
|
89
128
|
throwTemplateError("v-slot must be used on a <template> child in Mikuru. Wrap slot content in <template #name>...</template>.", attr.loc, options);
|
|
90
129
|
}
|
|
@@ -114,6 +153,13 @@ function requireStringValue(name, value) {
|
|
|
114
153
|
}
|
|
115
154
|
return value;
|
|
116
155
|
}
|
|
156
|
+
function requireEventHandlerValue(name, value) {
|
|
157
|
+
const source = requireStringValue(name, value).trim().replace(/;\s*$/, "");
|
|
158
|
+
if (!source) {
|
|
159
|
+
throw new Error(`Directive ${name} requires a value`);
|
|
160
|
+
}
|
|
161
|
+
return source;
|
|
162
|
+
}
|
|
117
163
|
function throwTemplateError(message, location, options) {
|
|
118
164
|
if (options.source && location) {
|
|
119
165
|
throw createCompileError(message, options.source, location.offset, options.filename);
|
|
@@ -121,6 +167,10 @@ function throwTemplateError(message, location, options) {
|
|
|
121
167
|
throw new Error(message);
|
|
122
168
|
}
|
|
123
169
|
function parseEventDirective(name) {
|
|
170
|
+
const dynamic = getDynamicEventArgument(name);
|
|
171
|
+
if (dynamic) {
|
|
172
|
+
return dynamic;
|
|
173
|
+
}
|
|
124
174
|
const rawName = getEventName(name);
|
|
125
175
|
if (!rawName) {
|
|
126
176
|
return undefined;
|
|
@@ -129,6 +179,9 @@ function parseEventDirective(name) {
|
|
|
129
179
|
return { name: eventName, modifiers };
|
|
130
180
|
}
|
|
131
181
|
function getEventName(name) {
|
|
182
|
+
if (name.startsWith("@[") || name.startsWith("v-on:[")) {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
132
185
|
if (name.startsWith("@")) {
|
|
133
186
|
return name.slice(1);
|
|
134
187
|
}
|
|
@@ -138,11 +191,62 @@ function getEventName(name) {
|
|
|
138
191
|
return undefined;
|
|
139
192
|
}
|
|
140
193
|
function getBindingName(name) {
|
|
141
|
-
|
|
142
|
-
|
|
194
|
+
const binding = parseBindingDirective(name);
|
|
195
|
+
if (!binding || "expression" in binding) {
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
return binding.name;
|
|
199
|
+
}
|
|
200
|
+
function getDynamicBindingArgument(name) {
|
|
201
|
+
const binding = parseBindingDirective(name);
|
|
202
|
+
if (!binding || !("expression" in binding)) {
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
return { expression: binding.expression };
|
|
206
|
+
}
|
|
207
|
+
function parseBindingDirective(name) {
|
|
208
|
+
const dynamic = parseDynamicArgument(name, [":", "v-bind:"]);
|
|
209
|
+
if (dynamic) {
|
|
210
|
+
return { expression: dynamic.expression };
|
|
211
|
+
}
|
|
212
|
+
const rawName = name.startsWith(":")
|
|
213
|
+
? name.slice(1)
|
|
214
|
+
: name.startsWith("v-bind:")
|
|
215
|
+
? name.slice("v-bind:".length)
|
|
216
|
+
: undefined;
|
|
217
|
+
if (!rawName) {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
const [bindingName, ...modifiers] = rawName.split(".");
|
|
221
|
+
if (!bindingName) {
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
return { name: modifiers.includes("camel") ? bindingName.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase()) : bindingName };
|
|
225
|
+
}
|
|
226
|
+
function getDynamicEventArgument(name) {
|
|
227
|
+
const dynamic = parseDynamicArgument(name, ["@", "v-on:"]);
|
|
228
|
+
if (!dynamic) {
|
|
229
|
+
return undefined;
|
|
143
230
|
}
|
|
144
|
-
|
|
145
|
-
|
|
231
|
+
return { nameExpression: dynamic.expression, modifiers: dynamic.modifiers };
|
|
232
|
+
}
|
|
233
|
+
function parseDynamicArgument(name, prefixes) {
|
|
234
|
+
for (const prefix of prefixes) {
|
|
235
|
+
if (!name.startsWith(`${prefix}[`)) {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
const argumentStart = prefix.length + 1;
|
|
239
|
+
const argumentEnd = name.indexOf("]", argumentStart);
|
|
240
|
+
if (argumentEnd === -1) {
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
const expression = name.slice(argumentStart, argumentEnd).trim();
|
|
244
|
+
if (!expression) {
|
|
245
|
+
return undefined;
|
|
246
|
+
}
|
|
247
|
+
const rest = name.slice(argumentEnd + 1);
|
|
248
|
+
const modifiers = rest.startsWith(".") ? rest.slice(1).split(".").filter(Boolean) : [];
|
|
249
|
+
return { expression, modifiers };
|
|
146
250
|
}
|
|
147
251
|
return undefined;
|
|
148
252
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeTemplate.js","sourceRoot":"","sources":["../../src/compiler/analyzeTemplate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAOpH,MAAM,UAAU,eAAe,CAAC,IAAiB,EAAE,UAAkC,EAAE;IACrF,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"analyzeTemplate.js","sourceRoot":"","sources":["../../src/compiler/analyzeTemplate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAOpH,MAAM,UAAU,eAAe,CAAC,IAAiB,EAAE,UAAkC,EAAE;IACrF,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC1C,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,SAAS,CAAC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AC;AAED,SAAS,oBAAoB,CAAC,IAAY,EAAE,QAAkB;IAC5D,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC;YACnC,SAAS;QACX,CAAC;QAED,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACxC,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;QACrD,IAAI,WAAW,KAAK,CAAC,CAAC,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC;QACjE,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;QACzC,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACvF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/compiler/compile.js
CHANGED
|
@@ -11,8 +11,8 @@ export function compile(source, options = {}) {
|
|
|
11
11
|
offset: descriptor.templateOffset
|
|
12
12
|
});
|
|
13
13
|
const bindings = analyzeTemplate(ast, { source, filename: options.filename });
|
|
14
|
-
const code = generate(descriptor, ast);
|
|
15
|
-
const map = createSourceMap(code, descriptor);
|
|
14
|
+
const code = generate(descriptor, ast, { debug: options.debug === true, batchedUpdates: options.batchedUpdates === true });
|
|
15
|
+
const map = createSourceMap(code, descriptor, ast);
|
|
16
16
|
return {
|
|
17
17
|
code,
|
|
18
18
|
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;AAGjD,MAAM,UAAU,OAAO,CAAC,MAAc,EAAE,UAA0B,EAAE;IAClE,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE;QAC7C,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,MAAM;QACN,MAAM,EAAE,UAAU,CAAC,cAAc;KAClC,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9E,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,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,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;AAGjD,MAAM,UAAU,OAAO,CAAC,MAAc,EAAE,UAA0B,EAAE;IAClE,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE;QAC7C,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,MAAM;QACN,MAAM,EAAE,UAAU,CAAC,cAAc;KAClC,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9E,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC,CAAC;IAC3H,MAAM,GAAG,GAAG,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IAEnD,OAAO;QACL,IAAI;QACJ,GAAG;QACH,UAAU;QACV,GAAG;QACH,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { analyzeTemplate } from "./analyzeTemplate.js";
|
|
2
|
+
import { generate } from "./generate.js";
|
|
3
|
+
import { generateHydration } from "./generateHydration.js";
|
|
4
|
+
import { parseSfc } from "./parseSfc.js";
|
|
5
|
+
import { parseTemplate } from "./parseTemplate.js";
|
|
6
|
+
import { createSourceMap } from "./sourceMap.js";
|
|
7
|
+
export function compileHydration(source, options = {}) {
|
|
8
|
+
const descriptor = parseSfc(source, options.filename);
|
|
9
|
+
const ast = parseTemplate(descriptor.template, {
|
|
10
|
+
filename: options.filename,
|
|
11
|
+
source,
|
|
12
|
+
offset: descriptor.templateOffset
|
|
13
|
+
});
|
|
14
|
+
const bindings = analyzeTemplate(ast, { source, filename: options.filename });
|
|
15
|
+
const mountCode = generate(descriptor, ast, { debug: options.debug === true, batchedUpdates: options.batchedUpdates === true });
|
|
16
|
+
const hydrationCode = generateHydration(descriptor, ast);
|
|
17
|
+
const code = mountCode.replace("export default __mikuru_component;", `${hydrationCode}\nexport { hydrate };\nconst __mikuru_hydrationComponent = { ...__mikuru_component, hydrate };\nexport default __mikuru_hydrationComponent;`);
|
|
18
|
+
const map = createSourceMap(code, descriptor, ast);
|
|
19
|
+
return {
|
|
20
|
+
code,
|
|
21
|
+
map,
|
|
22
|
+
descriptor,
|
|
23
|
+
ast,
|
|
24
|
+
bindings
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=compileHydration.js.map
|
|
@@ -0,0 +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;AAGjD,MAAM,UAAU,gBAAgB,CAAC,MAAc,EAAE,UAA0B,EAAE;IAC3E,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE;QAC7C,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,MAAM;QACN,MAAM,EAAE,UAAU,CAAC,cAAc;KAClC,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9E,MAAM,SAAS,GAAG,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC,CAAC;IAChI,MAAM,aAAa,GAAG,iBAAiB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACzD,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,oCAAoC,EAAE,GAAG,aAAa,6IAA6I,CAAC,CAAC;IACpO,MAAM,GAAG,GAAG,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IAEnD,OAAO;QACL,IAAI;QACJ,GAAG;QACH,UAAU;QACV,GAAG;QACH,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { analyzeTemplate } from "./analyzeTemplate.js";
|
|
2
|
+
import { generateSsr } from "./generateSsr.js";
|
|
3
|
+
import { parseSfc } from "./parseSfc.js";
|
|
4
|
+
import { parseTemplate } from "./parseTemplate.js";
|
|
5
|
+
export function compileSsr(source, options = {}) {
|
|
6
|
+
const descriptor = parseSfc(source, options.filename);
|
|
7
|
+
const ast = parseTemplate(descriptor.template, {
|
|
8
|
+
filename: options.filename,
|
|
9
|
+
source,
|
|
10
|
+
offset: descriptor.templateOffset
|
|
11
|
+
});
|
|
12
|
+
const bindings = analyzeTemplate(ast, { source, filename: options.filename });
|
|
13
|
+
const code = generateSsr(descriptor, ast);
|
|
14
|
+
return {
|
|
15
|
+
code,
|
|
16
|
+
descriptor,
|
|
17
|
+
ast,
|
|
18
|
+
bindings
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=compileSsr.js.map
|
|
@@ -0,0 +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;AAGnD,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,UAA0B,EAAE;IACrE,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE;QAC7C,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,MAAM;QACN,MAAM,EAAE,UAAU,CAAC,cAAc;KAClC,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9E,MAAM,IAAI,GAAG,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAE1C,OAAO;QACL,IAAI;QACJ,UAAU;QACV,GAAG;QACH,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { ElementNode, SfcDescriptor } from "./types.js";
|
|
2
|
-
|
|
2
|
+
type GenerateOptions = {
|
|
3
|
+
debug?: boolean;
|
|
4
|
+
batchedUpdates?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function generate(descriptor: SfcDescriptor, root: ElementNode, options?: GenerateOptions): string;
|
|
7
|
+
export {};
|