ferrovue 0.6.0 → 0.7.0
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 +106 -13
- package/dist/args.d.ts +28 -0
- package/dist/args.js +69 -0
- package/dist/attrs.js +3 -0
- package/dist/calls.js +5 -2
- package/dist/children.js +18 -3
- package/dist/cli.js +80 -81
- package/dist/client-render.d.ts +23 -0
- package/dist/client-render.js +143 -0
- package/dist/client.d.ts +65 -6
- package/dist/client.js +269 -27
- package/dist/compiler.d.ts +9 -5
- package/dist/compiler.js +48 -14
- package/dist/component.d.ts +7 -3
- package/dist/component.js +37 -25
- package/dist/conformance.d.ts +24 -3
- package/dist/conformance.js +58 -7
- package/dist/constants.js +4 -2
- package/dist/context.d.ts +51 -4
- package/dist/context.js +173 -5
- package/dist/diagnostics.d.ts +6 -4
- package/dist/diagnostics.js +7 -3
- package/dist/editor.d.ts +18 -0
- package/dist/editor.js +59 -0
- package/dist/errors.d.ts +45 -3
- package/dist/errors.js +33 -3
- package/dist/expr.d.ts +2 -0
- package/dist/expr.js +91 -12
- package/dist/fallthrough.d.ts +1 -0
- package/dist/fallthrough.js +10 -2
- package/dist/files.d.ts +13 -0
- package/dist/files.js +49 -0
- package/dist/fixture.d.ts +3 -3
- package/dist/hydration.d.ts +12 -1
- package/dist/hydration.js +47 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/inputs.d.ts +24 -0
- package/dist/inputs.js +40 -0
- package/dist/link-router.d.ts +6 -2
- package/dist/link-router.js +7 -4
- package/dist/lists.d.ts +12 -1
- package/dist/lists.js +76 -2
- package/dist/model.d.ts +9 -1
- package/dist/model.js +2 -0
- package/dist/page-routes.d.ts +1 -0
- package/dist/paths.d.ts +5 -0
- package/dist/paths.js +7 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugins/css-modules.d.ts +39 -0
- package/dist/plugins/css-modules.js +135 -0
- package/dist/plugins/head.js +4 -4
- package/dist/plugins/i18n.js +5 -12
- package/dist/plugins/index.js +2 -1
- package/dist/plugins/provide.js +4 -2
- package/dist/plugins/router.js +3 -2
- package/dist/plugins/scoped.d.ts +10 -0
- package/dist/plugins/scoped.js +17 -4
- package/dist/plugins/shared-types.js +2 -1
- package/dist/plugins/stores.js +7 -6
- package/dist/rust.d.ts +9 -1
- package/dist/rust.js +38 -15
- package/dist/schema.d.ts +25 -0
- package/dist/schema.js +73 -0
- package/dist/script.js +12 -5
- package/dist/slots.js +2 -0
- package/dist/ssr.js +42 -4
- package/dist/styles.d.ts +5 -1
- package/dist/styles.js +131 -4
- package/dist/testing.d.ts +2 -1
- package/dist/testing.js +1 -1
- package/dist/typescript.d.ts +11 -1
- package/dist/typescript.js +124 -33
- package/dist/vite.d.ts +18 -10
- package/dist/vite.js +106 -51
- package/dist/volar.d.ts +15 -0
- package/dist/volar.js +87 -0
- package/package.json +27 -7
- package/schema.json +333 -0
package/dist/vite.js
CHANGED
|
@@ -1,46 +1,20 @@
|
|
|
1
1
|
import { readdirSync, readFileSync } from "node:fs";
|
|
2
|
-
import { join,
|
|
2
|
+
import { join, resolve, sep } from "node:path";
|
|
3
3
|
import { CONFIG_FILE, loadConfig, write } from "./compiler.js";
|
|
4
|
-
import { formatRefusal, isRefusal } from "./diagnostics.js";
|
|
4
|
+
import { formatRefusal, formatWarning, isRefusal } from "./diagnostics.js";
|
|
5
5
|
import { allPages, fileRoutes, pagesFolder } from "./file-routes.js";
|
|
6
|
-
|
|
7
|
-
* routes or the configuration: anything but the output itself, dependencies and build output. */
|
|
8
|
-
export function affects(root, file) {
|
|
9
|
-
const rel = relative(root, file);
|
|
10
|
-
if (rel.startsWith("..") || !/\.(vue|ts|json)$/.test(rel))
|
|
11
|
-
return false;
|
|
12
|
-
let out = "";
|
|
13
|
-
try {
|
|
14
|
-
out = loadConfig(root).out;
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
}
|
|
18
|
-
const parts = rel.split(sep);
|
|
19
|
-
if (parts.some((p) => p === "node_modules" || p === "target" || p === ".git" || p === "dist"))
|
|
20
|
-
return false;
|
|
21
|
-
return out === "" || !(rel === out || rel.startsWith(out + sep));
|
|
22
|
-
}
|
|
6
|
+
import { affects, inputsOf, watched } from "./inputs.js";
|
|
23
7
|
/** How `@vitejs/plugin-vue`, as this build configures it, computes a `<style scoped>` id: from the
|
|
24
|
-
* path alone or the path and source, hashed from Vite's root
|
|
25
|
-
* id generator of its own. */
|
|
8
|
+
* path alone or the path and source, hashed from Vite's root; and whether it compiles for production.
|
|
9
|
+
* `null` without the plugin, or with an id generator of its own. */
|
|
26
10
|
export function vueScopeIds(config) {
|
|
27
11
|
const vue = config.plugins.find((p) => p.name === "vite:vue");
|
|
28
12
|
const generator = vue?.api?.options?.features?.componentIdGenerator;
|
|
29
13
|
if (!vue || (generator !== undefined && generator !== "filepath" && generator !== "filepath-source"))
|
|
30
14
|
return null;
|
|
31
|
-
return { mode: generator ?? (config.isProduction ? "filepath-source" : "filepath"), root: resolve(config.root) };
|
|
15
|
+
return { mode: generator ?? (config.isProduction ? "filepath-source" : "filepath"), root: resolve(config.root), production: config.isProduction };
|
|
32
16
|
}
|
|
33
|
-
|
|
34
|
-
* and `ferrovue.config.json` computes them otherwise than plugin-vue: a page would hydrate cleanly
|
|
35
|
-
* and show unstyled. */
|
|
36
|
-
export function scopeIdMismatch(root, vue) {
|
|
37
|
-
if (!vue)
|
|
38
|
-
return null;
|
|
39
|
-
const config = loadConfig(root);
|
|
40
|
-
const mode = config.scopeId ?? "filepath-source";
|
|
41
|
-
const viteRoot = resolve(root, config.viteRoot ?? ".");
|
|
42
|
-
if (mode === vue.mode && viteRoot === vue.root)
|
|
43
|
-
return null;
|
|
17
|
+
function componentSources(root, config) {
|
|
44
18
|
let files = [];
|
|
45
19
|
try {
|
|
46
20
|
files = readdirSync(join(root, config.components))
|
|
@@ -57,10 +31,69 @@ export function scopeIdMismatch(root, vue) {
|
|
|
57
31
|
catch {
|
|
58
32
|
}
|
|
59
33
|
}
|
|
60
|
-
|
|
34
|
+
return files.map((f) => readFileSync(join(root, f), "utf8"));
|
|
35
|
+
}
|
|
36
|
+
const SCOPED = /<style\b[^>]*\bscoped\b/;
|
|
37
|
+
const CSS_VARS = /<style\b[^>]*>[^]*?\bv-bind\s*\([^]*?<\/style>/;
|
|
38
|
+
const MODULE = /<style\b[^>]*\bmodule\b/;
|
|
39
|
+
/** Why the server's scope ids, or the CSS variables `v-bind()` sets, would differ from the client's,
|
|
40
|
+
* when a component has `<style scoped>` or `v-bind()` in `<style>` and the configuration,
|
|
41
|
+
* `configFile`, computes them otherwise than plugin-vue: a page would hydrate and show unstyled. */
|
|
42
|
+
export function scopeIdMismatch(root, vue, configFile = CONFIG_FILE) {
|
|
43
|
+
if (!vue)
|
|
44
|
+
return null;
|
|
45
|
+
const config = loadConfig(root, configFile, ignore);
|
|
46
|
+
const mode = config.scopeId ?? "filepath-source";
|
|
47
|
+
const viteRoot = resolve(root, config.viteRoot ?? ".");
|
|
48
|
+
const production = config.isProduction ?? true;
|
|
49
|
+
const sameIds = mode === vue.mode && viteRoot === vue.root;
|
|
50
|
+
const sameNames = vue.production === undefined || production === vue.production;
|
|
51
|
+
if (sameIds && sameNames)
|
|
52
|
+
return null;
|
|
53
|
+
const sources = componentSources(root, config);
|
|
54
|
+
const scoped = sources.some((s) => SCOPED.test(s));
|
|
55
|
+
const vars = sources.some((s) => CSS_VARS.test(s));
|
|
56
|
+
if (!sameIds && (scoped || vars)) {
|
|
57
|
+
return `${scoped ? "`<style scoped>` ids" : "the ids `v-bind()` in `<style>` names its variables by"}: @vitejs/plugin-vue hashes "${vue.mode}" from ${vue.root}, ${configFile} "${mode}" from ${viteRoot}; set \`scopeId\` and \`viteRoot\` to match, or plugin-vue's \`features.componentIdGenerator\``;
|
|
58
|
+
}
|
|
59
|
+
if (!sameNames && vars) {
|
|
60
|
+
return `\`v-bind()\` in \`<style>\`: @vitejs/plugin-vue compiles ${vue.production ? "for production" : "for development"}, where ${configFile} has \`"isProduction": ${production}\`; set \`isProduction\` to ${vue.production}`;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
/** Why the class names of the server's CSS modules would differ from those Vite gives the client,
|
|
65
|
+
* when a component has `<style module>` and Vite's `css`, run from `cwd`, names them otherwise than
|
|
66
|
+
* `cssModules` in the configuration, `configFile`. */
|
|
67
|
+
export function cssModulesMismatch(root, css, cwd, configFile = CONFIG_FILE) {
|
|
68
|
+
const config = loadConfig(root, configFile, ignore);
|
|
69
|
+
const own = config.cssModules;
|
|
70
|
+
if (!own || !componentSources(root, config).some((s) => MODULE.test(s)))
|
|
61
71
|
return null;
|
|
62
|
-
|
|
72
|
+
const modules = css?.modules;
|
|
73
|
+
const set = (what) => `\`<style module>\` class names: ${what}`;
|
|
74
|
+
if (css?.transformer === "lightningcss")
|
|
75
|
+
return set("Vite names them with lightningcss (`css.transformer`), where ferrovue computes postcss-modules' names; use the PostCSS transformer");
|
|
76
|
+
if (modules === false)
|
|
77
|
+
return set("Vite's `css.modules` is `false`, which leaves CSS modules unprocessed");
|
|
78
|
+
if (modules?.generateScopedName !== own.generateScopedName) {
|
|
79
|
+
const theirs = typeof modules?.generateScopedName === "function" ? "a function" : modules?.generateScopedName === undefined ? "unset" : JSON.stringify(modules.generateScopedName);
|
|
80
|
+
return set(`Vite's \`css.modules.generateScopedName\` is ${theirs}, ${configFile}'s \`cssModules.generateScopedName\` ${JSON.stringify(own.generateScopedName)}; set the two alike, to a string`);
|
|
81
|
+
}
|
|
82
|
+
if ((modules.hashPrefix ?? "") !== (own.hashPrefix ?? "")) {
|
|
83
|
+
return set(`Vite's \`css.modules.hashPrefix\` is ${JSON.stringify(modules.hashPrefix ?? "")}, ${configFile}'s \`cssModules.hashPrefix\` ${JSON.stringify(own.hashPrefix ?? "")}`);
|
|
84
|
+
}
|
|
85
|
+
if (modules.localsConvention !== undefined)
|
|
86
|
+
return set("Vite's `css.modules.localsConvention` renames the classes a template reads; leave it unset");
|
|
87
|
+
if (modules.scopeBehaviour === "global" || modules.globalModulePaths?.length || modules.exportGlobals) {
|
|
88
|
+
return set("Vite's `css.modules` makes some names global (`scopeBehaviour`, `globalModulePaths`, `exportGlobals`); leave those unset");
|
|
89
|
+
}
|
|
90
|
+
const context = resolve(root, own.context ?? config.viteRoot ?? ".");
|
|
91
|
+
if (/\[(?:[^\]]*:)?(?:hash|contenthash|path|folder)\b/i.test(own.generateScopedName) && context !== resolve(cwd)) {
|
|
92
|
+
return set(`Vite runs in ${resolve(cwd)}, from which it hashes a module's path, where ${configFile}'s \`cssModules.context\` is ${context}; run Vite there, or set \`cssModules.context\``);
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
63
95
|
}
|
|
96
|
+
const ignore = () => { };
|
|
64
97
|
const ISLANDS = "ferrovue/islands";
|
|
65
98
|
const ISLANDS_ID = `\0${ISLANDS}`;
|
|
66
99
|
const ROUTES = "ferrovue/routes";
|
|
@@ -101,20 +134,30 @@ ${routesTree(root, routes, " ", false)}
|
|
|
101
134
|
* and `ferrovue/routes` modules. */
|
|
102
135
|
export default function ferrovue(options = {}) {
|
|
103
136
|
const root = resolve(options.root ?? process.cwd());
|
|
137
|
+
const configFile = options.config ?? CONFIG_FILE;
|
|
104
138
|
let islands = null;
|
|
105
139
|
let routes = null;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
140
|
+
let inputs = null;
|
|
141
|
+
const regenerate = (warn) => {
|
|
142
|
+
let config = null;
|
|
143
|
+
try {
|
|
144
|
+
config = loadConfig(root, configFile, warn);
|
|
145
|
+
const written = write(root, config);
|
|
146
|
+
islands = written.islands;
|
|
147
|
+
return written;
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
inputs = inputsOf(root, configFile, config);
|
|
151
|
+
}
|
|
110
152
|
};
|
|
111
153
|
const pagesModule = () => {
|
|
112
|
-
const pages = pagesFolder(loadConfig(root));
|
|
154
|
+
const pages = pagesFolder(loadConfig(root, configFile, ignore));
|
|
113
155
|
if (pages === null)
|
|
114
|
-
throw new Error(`ferrovue: \`${ROUTES}\` is written from a folder of pages: set \`"routes": { "pages": "…" }\` in ${
|
|
156
|
+
throw new Error(`ferrovue: \`${ROUTES}\` is written from a folder of pages: set \`"routes": { "pages": "…" }\` in ${configFile}`);
|
|
115
157
|
return routesModule(root, fileRoutes(root, pages));
|
|
116
158
|
};
|
|
117
159
|
let vue = null;
|
|
160
|
+
let css;
|
|
118
161
|
let building = true;
|
|
119
162
|
return {
|
|
120
163
|
name: "ferrovue",
|
|
@@ -128,7 +171,7 @@ export default function ferrovue(options = {}) {
|
|
|
128
171
|
try {
|
|
129
172
|
if (id === ROUTES_ID)
|
|
130
173
|
return (routes ??= pagesModule());
|
|
131
|
-
return islandsModule(root, islands ?? regenerate().islands);
|
|
174
|
+
return islandsModule(root, islands ?? regenerate((w) => this.warn(formatWarning(w))).islands);
|
|
132
175
|
}
|
|
133
176
|
catch (e) {
|
|
134
177
|
if (isRefusal(e))
|
|
@@ -138,12 +181,13 @@ export default function ferrovue(options = {}) {
|
|
|
138
181
|
},
|
|
139
182
|
configResolved(config) {
|
|
140
183
|
vue = vueScopeIds(config);
|
|
184
|
+
css = config.css;
|
|
141
185
|
building = config.command === "build";
|
|
142
186
|
},
|
|
143
187
|
buildStart() {
|
|
144
188
|
try {
|
|
145
|
-
regenerate();
|
|
146
|
-
const mismatch = scopeIdMismatch(root, vue);
|
|
189
|
+
regenerate((w) => this.warn(formatWarning(w)));
|
|
190
|
+
const mismatch = scopeIdMismatch(root, vue, configFile) ?? cssModulesMismatch(root, css, process.cwd(), configFile);
|
|
147
191
|
if (mismatch && building)
|
|
148
192
|
this.error(`ferrovue: ${mismatch}`);
|
|
149
193
|
if (mismatch)
|
|
@@ -156,13 +200,22 @@ export default function ferrovue(options = {}) {
|
|
|
156
200
|
}
|
|
157
201
|
},
|
|
158
202
|
configureServer(server) {
|
|
159
|
-
|
|
203
|
+
if (!inputs) {
|
|
204
|
+
let config = null;
|
|
205
|
+
try {
|
|
206
|
+
config = loadConfig(root, configFile, ignore);
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
}
|
|
210
|
+
inputs = inputsOf(root, configFile, config);
|
|
211
|
+
}
|
|
212
|
+
server.watcher.add(watched(inputs));
|
|
160
213
|
const onChange = (file) => {
|
|
161
|
-
if (!affects(
|
|
214
|
+
if (!inputs || !affects(inputs, resolve(file)))
|
|
162
215
|
return;
|
|
163
216
|
try {
|
|
164
217
|
const before = JSON.stringify(islands);
|
|
165
|
-
const { changed, removed } = regenerate();
|
|
218
|
+
const { changed, removed } = regenerate((w) => server.config.logger.warn(`ferrovue: ${formatWarning(w)}`, { timestamp: true }));
|
|
166
219
|
if (changed.length || removed.length) {
|
|
167
220
|
server.config.logger.info(`ferrovue: ${changed.length} changed, ${removed.length} removed`, { timestamp: true });
|
|
168
221
|
}
|
|
@@ -182,11 +235,13 @@ export default function ferrovue(options = {}) {
|
|
|
182
235
|
}
|
|
183
236
|
}
|
|
184
237
|
catch (e) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
server.
|
|
238
|
+
// Thrown from a watcher's listener, anything but a refusal would take the dev server down:
|
|
239
|
+
// show it like one, and regenerate on the change that puts it right.
|
|
240
|
+
const message = isRefusal(e) ? formatRefusal(e) : `error: ${e instanceof Error ? e.message : String(e)}`;
|
|
241
|
+
server.config.logger.error(`ferrovue: ${message}`, { timestamp: true });
|
|
242
|
+
server.ws.send({ type: "error", err: { message: `ferrovue: ${message}`, stack: "", plugin: "ferrovue" } });
|
|
189
243
|
}
|
|
244
|
+
server.watcher.add(watched(inputs));
|
|
190
245
|
};
|
|
191
246
|
server.watcher.on("change", onChange);
|
|
192
247
|
server.watcher.on("add", onChange);
|
package/dist/volar.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { VueLanguagePlugin } from "@vue/language-core";
|
|
2
|
+
/** What the plugin takes beside its name in `vueCompilerOptions.plugins`. */
|
|
3
|
+
export interface VolarOptions {
|
|
4
|
+
/** The configuration file's path from the project root, `ferrovue.config.json` by default. */
|
|
5
|
+
config?: string;
|
|
6
|
+
/** `false` gives each error its code as plain text, with the docs link in the message, for an
|
|
7
|
+
* editor that cannot follow a code's link. */
|
|
8
|
+
codeLinks?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** A Vue language tools plugin that reports what ferrovue refuses in a component where the editor
|
|
11
|
+
* shows Vue's own template errors: as an error on the construct, with its code linked to the docs.
|
|
12
|
+
* Name it in `vueCompilerOptions.plugins` in `tsconfig.json`. */
|
|
13
|
+
declare const plugin: VueLanguagePlugin<VolarOptions>;
|
|
14
|
+
export default plugin;
|
|
15
|
+
export { plugin as "module.exports" };
|
package/dist/volar.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { refusalsIn } from "./editor.js";
|
|
2
|
+
const SYNTAX = new Set(["FV0001", "FV0002"]);
|
|
3
|
+
const ours = new WeakSet();
|
|
4
|
+
function inTypeScriptHost() {
|
|
5
|
+
return /tsserver|vue-tsc/.test(process.argv[1] ?? "");
|
|
6
|
+
}
|
|
7
|
+
function htmlTemplate(d) {
|
|
8
|
+
const t = d.template;
|
|
9
|
+
return t && (t.lang ?? "html") === "html" ? t : null;
|
|
10
|
+
}
|
|
11
|
+
function inside(offset, block) {
|
|
12
|
+
return offset >= block.loc.start.offset && offset <= block.loc.end.offset;
|
|
13
|
+
}
|
|
14
|
+
function errorFor(r, start, end, links, where = "") {
|
|
15
|
+
const text = `ferrovue: ${r.message}${where}${links ? "" : `\n${r.docs}`}`;
|
|
16
|
+
const error = Object.assign(new SyntaxError(text), {
|
|
17
|
+
code: links ? { value: r.code, target: r.docs } : r.code,
|
|
18
|
+
loc: { start: { offset: start, line: 0, column: 0 }, end: { offset: end, line: 0, column: 0 }, source: "" },
|
|
19
|
+
});
|
|
20
|
+
ours.add(error);
|
|
21
|
+
return error;
|
|
22
|
+
}
|
|
23
|
+
function outsideTemplate(d, source, r, links) {
|
|
24
|
+
const blocks = [d.template, d.script, d.scriptSetup, ...d.styles, ...d.customBlocks].filter((b) => !!b);
|
|
25
|
+
const block = blocks.find((b) => inside(r.start, b));
|
|
26
|
+
if (!block)
|
|
27
|
+
return errorFor(r, r.start, r.end ?? r.start, links);
|
|
28
|
+
const tagStart = source.lastIndexOf(`<${block.type}`, block.loc.start.offset);
|
|
29
|
+
return errorFor(r, tagStart, block.loc.start.offset, links, ` (at ${r.line}:${r.column})`);
|
|
30
|
+
}
|
|
31
|
+
function refusals(fileName, text, options) {
|
|
32
|
+
return fileName.endsWith(".vue") ? refusalsIn(fileName, text, options).filter((r) => !SYNTAX.has(r.code)) : [];
|
|
33
|
+
}
|
|
34
|
+
/** A Vue language tools plugin that reports what ferrovue refuses in a component where the editor
|
|
35
|
+
* shows Vue's own template errors: as an error on the construct, with its code linked to the docs.
|
|
36
|
+
* Name it in `vueCompilerOptions.plugins` in `tsconfig.json`. */
|
|
37
|
+
const plugin = (context) => {
|
|
38
|
+
if (inTypeScriptHost())
|
|
39
|
+
return [];
|
|
40
|
+
const options = context.config;
|
|
41
|
+
const links = options.codeLinks !== false;
|
|
42
|
+
const builtIn = context.modules["@vue/language-core"]
|
|
43
|
+
.createPlugins({ ...context, vueCompilerOptions: { ...context.vueCompilerOptions, plugins: [] }, config: {} });
|
|
44
|
+
const parsed = (fileName, languageId, content) => {
|
|
45
|
+
for (const p of builtIn) {
|
|
46
|
+
const sfc = p.parseSFC2?.(fileName, languageId, content);
|
|
47
|
+
if (sfc)
|
|
48
|
+
return sfc;
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
};
|
|
52
|
+
const result = {
|
|
53
|
+
version: 2.2,
|
|
54
|
+
name: "ferrovue",
|
|
55
|
+
order: -1,
|
|
56
|
+
parseSFC2(fileName, languageId, content) {
|
|
57
|
+
if (languageId !== "vue")
|
|
58
|
+
return undefined;
|
|
59
|
+
const sfc = parsed(fileName, languageId, content);
|
|
60
|
+
if (!sfc)
|
|
61
|
+
return undefined;
|
|
62
|
+
const template = htmlTemplate(sfc.descriptor);
|
|
63
|
+
for (const r of refusals(fileName, content, options)) {
|
|
64
|
+
if (!template || !inside(r.start, template))
|
|
65
|
+
sfc.errors.push(outsideTemplate(sfc.descriptor, content, r, links));
|
|
66
|
+
}
|
|
67
|
+
return sfc;
|
|
68
|
+
},
|
|
69
|
+
resolveEmbeddedCode(fileName, ir, code) {
|
|
70
|
+
if (code.id !== "template" || !ir.template)
|
|
71
|
+
return;
|
|
72
|
+
const { errors, startTagEnd, endTagStart } = ir.template;
|
|
73
|
+
for (let i = errors.length - 1; i >= 0; i--)
|
|
74
|
+
if (ours.has(errors[i]))
|
|
75
|
+
errors.splice(i, 1);
|
|
76
|
+
for (const r of refusals(fileName, ir.content, options)) {
|
|
77
|
+
if (r.start < startTagEnd || r.start > endTagStart)
|
|
78
|
+
continue;
|
|
79
|
+
const start = r.start - startTagEnd;
|
|
80
|
+
errors.push(errorFor(r, start, (r.end ?? r.start) - startTagEnd, links));
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
return result;
|
|
85
|
+
};
|
|
86
|
+
export default plugin;
|
|
87
|
+
export { plugin as "module.exports" };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ferrovue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Vue templates compiled to Rust render functions: server-side rendering with no JavaScript at run time",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
26
|
+
"schema.json",
|
|
26
27
|
"README.md",
|
|
27
28
|
"LICENSE-MIT",
|
|
28
29
|
"LICENSE-APACHE"
|
|
@@ -63,36 +64,49 @@
|
|
|
63
64
|
"./vite": {
|
|
64
65
|
"types": "./dist/vite.d.ts",
|
|
65
66
|
"default": "./dist/vite.js"
|
|
66
|
-
}
|
|
67
|
+
},
|
|
68
|
+
"./volar": {
|
|
69
|
+
"types": "./dist/volar.d.ts",
|
|
70
|
+
"default": "./dist/volar.js"
|
|
71
|
+
},
|
|
72
|
+
"./schema.json": "./schema.json"
|
|
67
73
|
},
|
|
68
74
|
"sideEffects": false,
|
|
69
75
|
"bin": {
|
|
70
76
|
"ferrovue": "./dist/cli.js"
|
|
71
77
|
},
|
|
72
|
-
"scripts": {
|
|
73
|
-
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json",
|
|
74
|
-
"prepack": "pnpm run build && cp ../../README.md ../../LICENSE-MIT ../../LICENSE-APACHE ."
|
|
75
|
-
},
|
|
76
78
|
"dependencies": {
|
|
77
79
|
"@babel/parser": "^7.29.9",
|
|
78
80
|
"@intlify/message-compiler": "11.4.13",
|
|
79
81
|
"@vue/compiler-sfc": "3.5.43",
|
|
80
82
|
"@vue/shared": "3.5.43",
|
|
83
|
+
"generic-names": "^4.0.0",
|
|
84
|
+
"postcss": "^8.5.28",
|
|
85
|
+
"postcss-modules-extract-imports": "^3.1.0",
|
|
86
|
+
"postcss-modules-local-by-default": "^4.2.0",
|
|
87
|
+
"postcss-modules-scope": "^3.2.1",
|
|
88
|
+
"postcss-modules-values": "^4.0.0",
|
|
81
89
|
"source-map-js": "^1.2.2"
|
|
82
90
|
},
|
|
83
91
|
"devDependencies": {
|
|
84
92
|
"@unhead/vue": "^3.4.2",
|
|
93
|
+
"@vue/language-core": "3.3.12",
|
|
94
|
+
"@vue/language-service": "3.3.12",
|
|
85
95
|
"@vue/server-renderer": "3.5.43",
|
|
86
96
|
"pinia": "^4.0.3",
|
|
87
97
|
"playwright": "1.63.0",
|
|
98
|
+
"typescript": "^7.0.2",
|
|
99
|
+
"typescript-js": "npm:typescript@6.0.3",
|
|
88
100
|
"vite": "^8.3.0",
|
|
89
101
|
"vitest": "^5.0.1",
|
|
102
|
+
"vscode-uri": "3.1.0",
|
|
90
103
|
"vue": "3.5.43",
|
|
91
104
|
"vue-i18n": "11.4.13",
|
|
92
105
|
"vue-router": "^5.3.1"
|
|
93
106
|
},
|
|
94
107
|
"peerDependencies": {
|
|
95
108
|
"@unhead/vue": "~3.4.2",
|
|
109
|
+
"@vue/language-core": "^3.3.0",
|
|
96
110
|
"pinia": "~4.0.3",
|
|
97
111
|
"vite": ">=6",
|
|
98
112
|
"vitest": ">=5",
|
|
@@ -118,6 +132,12 @@
|
|
|
118
132
|
},
|
|
119
133
|
"vitest": {
|
|
120
134
|
"optional": true
|
|
135
|
+
},
|
|
136
|
+
"@vue/language-core": {
|
|
137
|
+
"optional": true
|
|
121
138
|
}
|
|
139
|
+
},
|
|
140
|
+
"scripts": {
|
|
141
|
+
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json"
|
|
122
142
|
}
|
|
123
|
-
}
|
|
143
|
+
}
|