@evertondgn/solid-tooling 0.5.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 +543 -598
- package/app-env.d.ts +7 -0
- package/dist/architecture-plugin.mjs +1 -1
- package/dist/backend-plugin.mjs +139 -4
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +42 -0
- package/dist/{constants-Jqvtbvxu.mjs → constants-BZJm7ouk.mjs} +1 -1
- package/dist/css-filename-CEHQd2gz.mjs +40 -0
- package/dist/css-filename.mjs +1 -40
- package/dist/fmt-9dlUYOMk.mjs +34 -0
- package/dist/fmt.mjs +1 -34
- package/dist/i18n-generate.d.mts +1 -0
- package/dist/i18n-generate.mjs +23 -0
- package/dist/i18nPlugin-CS7Gob6R.mjs +109 -0
- package/dist/knip.d.mts +2 -1
- package/dist/knip.mjs +7 -2
- package/dist/{lint-UTfyg7AR.mjs → lint-ehdtTKfw.mjs} +33 -86
- package/dist/lint.mjs +1 -1
- package/dist/playwright-teardown.mjs +1 -1
- package/dist/playwright.d.mts +2 -1
- package/dist/playwright.mjs +4 -3
- package/dist/prepareMessages-BXmY6Ko2.mjs +222 -0
- package/dist/project-plugin.mjs +2 -2
- package/dist/protocol-DSNNUYja.mjs +18 -0
- package/dist/publication/read-llms-index.d.mts +12 -0
- package/dist/publication/read-llms-index.mjs +1 -0
- package/dist/publication-CRUTOB0B.mjs +885 -0
- package/dist/readLlmsIndex-Gj4iTxAk.mjs +27 -0
- package/dist/stylelint.mjs +2 -2
- package/dist/test-locale--tuH0Np5.mjs +3 -0
- package/dist/types-DHu2Z_ot.d.mts +49 -0
- package/dist/vite.d.mts +33 -7
- package/dist/vite.mjs +449 -88
- package/dist/vitest-BjLr7iLf.mjs +362 -0
- package/dist/vitest.d.mts +3 -7
- package/dist/vitest.mjs +1 -129
- package/lefthook.yml +3 -1
- package/node-env.d.ts +1 -0
- package/package.json +32 -39
- package/tsconfig.app.json +4 -9
- package/virtual-modules.d.ts +90 -0
package/app-env.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="vite-plus/test/globals" />
|
|
2
|
+
/// <reference types="@testing-library/jest-dom/vitest" />
|
|
3
|
+
/// <reference types="@solidjs/vite-plugin/boundary-modules" />
|
|
4
|
+
/// <reference types="@solidjs/vite-plugin/virtual-modules" />
|
|
5
|
+
/// <reference types="filesystem-routing/types" />
|
|
6
|
+
/// <reference types="@evertondgn/solid-tooling/virtual-modules" />
|
|
7
|
+
/// <reference types="vite-plus/client" />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as resolveProjectPath, t as readStaticSpecifier } from "./import-specifier-C7HWhMXB.mjs";
|
|
2
|
-
import { definePlugin, defineRule } from "vite-plus/lint/plugins";
|
|
3
2
|
import path from "node:path";
|
|
3
|
+
import { definePlugin, defineRule } from "vite-plus/lint/plugins";
|
|
4
4
|
// src/architecturePolicy/index.ts
|
|
5
5
|
const UI = [
|
|
6
6
|
"atoms",
|
package/dist/backend-plugin.mjs
CHANGED
|
@@ -1,6 +1,113 @@
|
|
|
1
1
|
import { t as readStaticSpecifier } from "./import-specifier-C7HWhMXB.mjs";
|
|
2
|
-
import { n as RENDER_INTEGRITY_MODULE } from "./constants-
|
|
2
|
+
import { n as RENDER_INTEGRITY_MODULE, t as RELATIVE_IMPORT_RESTRICTION } from "./constants-BZJm7ouk.mjs";
|
|
3
|
+
import path from "node:path";
|
|
3
4
|
import { definePlugin, defineRule } from "vite-plus/lint/plugins";
|
|
5
|
+
// src/backendPolicy/imports.ts
|
|
6
|
+
const RELATIVE_IMPORT = new RegExp(RELATIVE_IMPORT_RESTRICTION.regex, "u");
|
|
7
|
+
const RENDER_INTEGRITY$1 = new RegExp(RENDER_INTEGRITY_MODULE, "u");
|
|
8
|
+
const TRANSPORTS = new Set([
|
|
9
|
+
"http",
|
|
10
|
+
"https",
|
|
11
|
+
"http2",
|
|
12
|
+
"net",
|
|
13
|
+
"tls",
|
|
14
|
+
"undici"
|
|
15
|
+
].flatMap((name) => [name, `node:${name}`]));
|
|
16
|
+
const SERVER_CONFIG = /* @__PURE__ */ new Set([
|
|
17
|
+
"@solidjs/web/server-functions",
|
|
18
|
+
"@solidjs/web/server-functions/server",
|
|
19
|
+
"@evertondgn/solid-runtime/server/configure-server-errors"
|
|
20
|
+
]);
|
|
21
|
+
function importsName({ node, names }) {
|
|
22
|
+
if (node.type === "TSImportType" && node.qualifier !== null) {
|
|
23
|
+
let { qualifier } = node;
|
|
24
|
+
while (qualifier.type === "TSQualifiedName") qualifier = qualifier.left;
|
|
25
|
+
return names.includes(qualifier.name);
|
|
26
|
+
}
|
|
27
|
+
if (node.type !== "ImportDeclaration" && node.type !== "ExportNamedDeclaration") return true;
|
|
28
|
+
return node.specifiers.some((specifier) => {
|
|
29
|
+
if (specifier.type === "ImportNamespaceSpecifier") return true;
|
|
30
|
+
if (specifier.type === "ImportDefaultSpecifier") return names.includes("default");
|
|
31
|
+
const imported = specifier.type === "ImportSpecifier" ? specifier.imported : specifier.local;
|
|
32
|
+
return names.includes(imported.type === "Identifier" ? imported.name : imported.value);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function permission(options, name) {
|
|
36
|
+
return typeof options === "object" && options !== null && name in options && Reflect.get(options, name) === true;
|
|
37
|
+
}
|
|
38
|
+
function normalizeBackendSpecifier(specifier) {
|
|
39
|
+
const normalized = path.posix.normalize(specifier.replaceAll("\\", "/"));
|
|
40
|
+
return specifier.startsWith(".") && !normalized.startsWith(".") ? `./${normalized}` : normalized;
|
|
41
|
+
}
|
|
42
|
+
const restrictedImports = defineRule({
|
|
43
|
+
meta: {
|
|
44
|
+
type: "problem",
|
|
45
|
+
schema: [{
|
|
46
|
+
type: "object",
|
|
47
|
+
properties: {
|
|
48
|
+
allowSafeErrors: { type: "boolean" },
|
|
49
|
+
allowServerConfiguration: { type: "boolean" },
|
|
50
|
+
testFile: { type: "boolean" }
|
|
51
|
+
},
|
|
52
|
+
additionalProperties: false
|
|
53
|
+
}],
|
|
54
|
+
messages: {
|
|
55
|
+
relative: RELATIVE_IMPORT_RESTRICTION.message,
|
|
56
|
+
physical: "Do not import through node_modules. Use a public package export.",
|
|
57
|
+
safe: "Use createPublicError; only the runtime publicErrors module may mark an error as public.",
|
|
58
|
+
configuration: "Only src/infra/server/configureServerErrors/index.ts may configure server errors or observe render failures.",
|
|
59
|
+
transport: "Node transports cannot be imported in src/. Use requestJson or a protected server adapter."
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
create(context) {
|
|
63
|
+
const [options] = context.options;
|
|
64
|
+
const safeErrors = permission(options, "allowSafeErrors");
|
|
65
|
+
const configuration = permission(options, "allowServerConfiguration");
|
|
66
|
+
const testFile = permission(options, "testFile");
|
|
67
|
+
function check(node) {
|
|
68
|
+
const original = readStaticSpecifier(node);
|
|
69
|
+
if (original === void 0) return;
|
|
70
|
+
const specifier = normalizeBackendSpecifier(original);
|
|
71
|
+
if (RELATIVE_IMPORT.test(specifier)) context.report({
|
|
72
|
+
node,
|
|
73
|
+
messageId: "relative"
|
|
74
|
+
});
|
|
75
|
+
if (testFile) return;
|
|
76
|
+
if (original.replaceAll("\\", "/").split("/").includes("node_modules")) context.report({
|
|
77
|
+
node,
|
|
78
|
+
messageId: "physical"
|
|
79
|
+
});
|
|
80
|
+
if (TRANSPORTS.has(specifier)) context.report({
|
|
81
|
+
node,
|
|
82
|
+
messageId: "transport"
|
|
83
|
+
});
|
|
84
|
+
if (!safeErrors && specifier === "@solidjs/web" && importsName({
|
|
85
|
+
node,
|
|
86
|
+
names: ["markSafeError", "SAFE_ERROR"]
|
|
87
|
+
})) context.report({
|
|
88
|
+
node,
|
|
89
|
+
messageId: "safe"
|
|
90
|
+
});
|
|
91
|
+
if (!configuration && (SERVER_CONFIG.has(specifier) || specifier === "@solidjs/web" && importsName({
|
|
92
|
+
node,
|
|
93
|
+
names: ["configureServerErrors"]
|
|
94
|
+
}) || RENDER_INTEGRITY$1.test(specifier) && importsName({
|
|
95
|
+
node,
|
|
96
|
+
names: ["observeRenderFailures"]
|
|
97
|
+
}))) context.report({
|
|
98
|
+
node,
|
|
99
|
+
messageId: "configuration"
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
ImportDeclaration: check,
|
|
104
|
+
ExportNamedDeclaration: check,
|
|
105
|
+
ExportAllDeclaration: check,
|
|
106
|
+
ImportExpression: check,
|
|
107
|
+
TSImportType: check
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
});
|
|
4
111
|
// src/backendPolicy/plugin.ts
|
|
5
112
|
const RENDER_INTEGRITY = new RegExp(RENDER_INTEGRITY_MODULE, "u");
|
|
6
113
|
function staticImportRule({ matches, message }) {
|
|
@@ -13,7 +120,7 @@ function staticImportRule({ matches, message }) {
|
|
|
13
120
|
create(context) {
|
|
14
121
|
return { ImportExpression(node) {
|
|
15
122
|
const specifier = readStaticSpecifier(node);
|
|
16
|
-
if (specifier !== void 0 && matches(specifier)) context.report({
|
|
123
|
+
if (specifier !== void 0 && matches(normalizeBackendSpecifier(specifier))) context.report({
|
|
17
124
|
node,
|
|
18
125
|
messageId: "staticImport"
|
|
19
126
|
});
|
|
@@ -24,9 +131,37 @@ function staticImportRule({ matches, message }) {
|
|
|
24
131
|
const backendPlugin = definePlugin({
|
|
25
132
|
meta: { name: "backend" },
|
|
26
133
|
rules: {
|
|
134
|
+
"restricted-imports": restrictedImports,
|
|
135
|
+
"no-setup-exports": defineRule({
|
|
136
|
+
meta: {
|
|
137
|
+
type: "problem",
|
|
138
|
+
schema: [],
|
|
139
|
+
messages: { exported: "Server setup must not export anything. Import it only for its setup side effects." }
|
|
140
|
+
},
|
|
141
|
+
create(context) {
|
|
142
|
+
return {
|
|
143
|
+
ExportNamedDeclaration: (node) => context.report({
|
|
144
|
+
node,
|
|
145
|
+
messageId: "exported"
|
|
146
|
+
}),
|
|
147
|
+
ExportDefaultDeclaration: (node) => context.report({
|
|
148
|
+
node,
|
|
149
|
+
messageId: "exported"
|
|
150
|
+
}),
|
|
151
|
+
ExportAllDeclaration: (node) => context.report({
|
|
152
|
+
node,
|
|
153
|
+
messageId: "exported"
|
|
154
|
+
}),
|
|
155
|
+
TSExportAssignment: (node) => context.report({
|
|
156
|
+
node,
|
|
157
|
+
messageId: "exported"
|
|
158
|
+
})
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}),
|
|
27
162
|
"static-solid-imports": staticImportRule({
|
|
28
|
-
matches: (specifier) => specifier === "@solidjs/web" || specifier.startsWith("@solidjs/web/"),
|
|
29
|
-
message: "Use a static import for @solidjs/web and
|
|
163
|
+
matches: (specifier) => specifier === "@solidjs/web" || specifier.startsWith("@solidjs/web/") || specifier === "@evertondgn/solid-runtime/server/configure-server-errors",
|
|
164
|
+
message: "Use a static import for @solidjs/web, its subpaths and the runtime server configurator: the import restrictions on markSafeError and configureServerErrors cannot check import()."
|
|
30
165
|
}),
|
|
31
166
|
"static-render-integrity-imports": staticImportRule({
|
|
32
167
|
matches: (specifier) => RENDER_INTEGRITY.test(specifier),
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import process, { argv, execPath } from "node:process";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
// src/cli/index.ts
|
|
5
|
+
const CLI_ARGUMENT_OFFSET = 2;
|
|
6
|
+
const TOOLS = {
|
|
7
|
+
knip: {
|
|
8
|
+
runtime: "bun",
|
|
9
|
+
entry: () => new URL("../bin/knip-bun.js", import.meta.resolve("knip")).href
|
|
10
|
+
},
|
|
11
|
+
tsc: {
|
|
12
|
+
runtime: execPath,
|
|
13
|
+
entry: () => new URL("bin/tsc", import.meta.resolve("typescript/package.json")).href
|
|
14
|
+
},
|
|
15
|
+
playwright: {
|
|
16
|
+
runtime: execPath,
|
|
17
|
+
entry: () => import.meta.resolve("@playwright/test/cli")
|
|
18
|
+
},
|
|
19
|
+
lefthook: {
|
|
20
|
+
runtime: execPath,
|
|
21
|
+
entry: () => import.meta.resolve("lefthook")
|
|
22
|
+
},
|
|
23
|
+
commitlint: {
|
|
24
|
+
runtime: execPath,
|
|
25
|
+
entry: () => import.meta.resolve("@commitlint/cli/cli.js")
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const [name = "", ...args] = argv.slice(CLI_ARGUMENT_OFFSET);
|
|
29
|
+
const tool = Object.hasOwn(TOOLS, name) ? TOOLS[name] : void 0;
|
|
30
|
+
if (!tool) throw new Error(`Choose a packaged tool: ${Object.keys(TOOLS).join(", ")}`);
|
|
31
|
+
const child = spawn(tool.runtime, [fileURLToPath(tool.entry()), ...args], { stdio: "inherit" });
|
|
32
|
+
for (const signal of ["SIGINT", "SIGTERM"]) process.on(signal, () => {
|
|
33
|
+
if (child.exitCode === null && child.signalCode === null) child.kill(signal);
|
|
34
|
+
});
|
|
35
|
+
child.on("error", (error) => {
|
|
36
|
+
process.stderr.write(`${error.message}\n`);
|
|
37
|
+
process.exitCode = 1;
|
|
38
|
+
});
|
|
39
|
+
child.on("exit", (code) => {
|
|
40
|
+
process.exitCode = code ?? process.exitCode ?? 1;
|
|
41
|
+
});
|
|
42
|
+
export {};
|
|
@@ -3,5 +3,5 @@ const RELATIVE_IMPORT_RESTRICTION = {
|
|
|
3
3
|
regex: String.raw`^(\.\./){4,}`,
|
|
4
4
|
message: "Relative imports may go up at most three levels. Use the @/ alias for more distant paths."
|
|
5
5
|
};
|
|
6
|
-
const RENDER_INTEGRITY_MODULE = String.raw`(?:^|/)renderIntegrity(?:/index(?:\.ts)?)
|
|
6
|
+
const RENDER_INTEGRITY_MODULE = String.raw`(?:(?:^|/)renderIntegrity(?:/index(?:\.ts)?)?$|^@evertondgn/solid-runtime/server/render-integrity$)`;
|
|
7
7
|
export { RENDER_INTEGRITY_MODULE as n, RELATIVE_IMPORT_RESTRICTION as t };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { n as resolveProjectPath, t as readStaticSpecifier } from "./import-specifier-C7HWhMXB.mjs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { defineRule } from "vite-plus/lint/plugins";
|
|
4
|
+
// src/css/css-filename.ts
|
|
5
|
+
function cssFilenameError(file) {
|
|
6
|
+
const normalized = file.split("\\").join("/");
|
|
7
|
+
const basename = path.posix.basename(normalized);
|
|
8
|
+
if (normalized.startsWith("src/theme/")) return /^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$/u.test(basename.slice(0, -4)) ? void 0 : "Use camelCaseName.css inside src/theme/.";
|
|
9
|
+
return basename === "styles.module.css" ? void 0 : "Use styles.module.css outside src/theme/, including in routes.";
|
|
10
|
+
}
|
|
11
|
+
const cssFilename = defineRule({
|
|
12
|
+
meta: {
|
|
13
|
+
type: "problem",
|
|
14
|
+
schema: []
|
|
15
|
+
},
|
|
16
|
+
create(context) {
|
|
17
|
+
function check(node) {
|
|
18
|
+
const specifier = readStaticSpecifier(node);
|
|
19
|
+
if (specifier === void 0) return;
|
|
20
|
+
const relative = resolveProjectPath({
|
|
21
|
+
specifier,
|
|
22
|
+
filename: context.filename,
|
|
23
|
+
root: context.cwd
|
|
24
|
+
});
|
|
25
|
+
if (!relative.startsWith("src/") || !relative.endsWith(".css")) return;
|
|
26
|
+
const message = cssFilenameError(relative);
|
|
27
|
+
if (message) context.report({
|
|
28
|
+
node,
|
|
29
|
+
message
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
ImportDeclaration: check,
|
|
34
|
+
ExportNamedDeclaration: check,
|
|
35
|
+
ExportAllDeclaration: check,
|
|
36
|
+
ImportExpression: check
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
export { cssFilenameError as n, cssFilename as t };
|
package/dist/css-filename.mjs
CHANGED
|
@@ -1,40 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineRule } from "vite-plus/lint/plugins";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
// src/css/css-filename.ts
|
|
5
|
-
function cssFilenameError(file) {
|
|
6
|
-
const normalized = file.split("\\").join("/");
|
|
7
|
-
const basename = path.posix.basename(normalized);
|
|
8
|
-
if (normalized.startsWith("src/theme/")) return /^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$/u.test(basename.slice(0, -4)) ? void 0 : "Use camelCaseName.css inside src/theme/.";
|
|
9
|
-
return basename === "styles.module.css" ? void 0 : "Use styles.module.css outside src/theme/, including in routes.";
|
|
10
|
-
}
|
|
11
|
-
const cssFilename = defineRule({
|
|
12
|
-
meta: {
|
|
13
|
-
type: "problem",
|
|
14
|
-
schema: []
|
|
15
|
-
},
|
|
16
|
-
create(context) {
|
|
17
|
-
function check(node) {
|
|
18
|
-
const specifier = readStaticSpecifier(node);
|
|
19
|
-
if (specifier === void 0) return;
|
|
20
|
-
const relative = resolveProjectPath({
|
|
21
|
-
specifier,
|
|
22
|
-
filename: context.filename,
|
|
23
|
-
root: context.cwd
|
|
24
|
-
});
|
|
25
|
-
if (!relative.startsWith("src/") || !relative.endsWith(".css")) return;
|
|
26
|
-
const message = cssFilenameError(relative);
|
|
27
|
-
if (message) context.report({
|
|
28
|
-
node,
|
|
29
|
-
message
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
ImportDeclaration: check,
|
|
34
|
-
ExportNamedDeclaration: check,
|
|
35
|
-
ExportAllDeclaration: check,
|
|
36
|
-
ImportExpression: check
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
export { cssFilename, cssFilenameError };
|
|
1
|
+
export { t as cssFilename, n as cssFilenameError } from "./css-filename-CEHQd2gz.mjs";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/fmt.ts
|
|
2
|
+
const fmt = {
|
|
3
|
+
printWidth: 80,
|
|
4
|
+
singleQuote: true,
|
|
5
|
+
semi: false,
|
|
6
|
+
trailingComma: "none",
|
|
7
|
+
arrowParens: "avoid",
|
|
8
|
+
proseWrap: "always",
|
|
9
|
+
sortPackageJson: false,
|
|
10
|
+
embeddedLanguageFormatting: "off",
|
|
11
|
+
sortImports: { groups: [
|
|
12
|
+
"builtin",
|
|
13
|
+
"external",
|
|
14
|
+
["internal", "subpath"],
|
|
15
|
+
[
|
|
16
|
+
"parent",
|
|
17
|
+
"sibling",
|
|
18
|
+
"index"
|
|
19
|
+
],
|
|
20
|
+
"style",
|
|
21
|
+
"unknown"
|
|
22
|
+
] },
|
|
23
|
+
ignorePatterns: [
|
|
24
|
+
"public/**",
|
|
25
|
+
"src/assets/**",
|
|
26
|
+
"src/@types/routes.d.ts",
|
|
27
|
+
"**/*.svg",
|
|
28
|
+
"*.lock",
|
|
29
|
+
"AGENTS.md",
|
|
30
|
+
".agents/**",
|
|
31
|
+
".claude/**"
|
|
32
|
+
]
|
|
33
|
+
};
|
|
34
|
+
export { fmt as t };
|
package/dist/fmt.mjs
CHANGED
|
@@ -1,34 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const fmt = {
|
|
3
|
-
printWidth: 80,
|
|
4
|
-
singleQuote: true,
|
|
5
|
-
semi: false,
|
|
6
|
-
trailingComma: "none",
|
|
7
|
-
arrowParens: "avoid",
|
|
8
|
-
proseWrap: "always",
|
|
9
|
-
sortPackageJson: false,
|
|
10
|
-
embeddedLanguageFormatting: "off",
|
|
11
|
-
sortImports: { groups: [
|
|
12
|
-
"builtin",
|
|
13
|
-
"external",
|
|
14
|
-
["internal", "subpath"],
|
|
15
|
-
[
|
|
16
|
-
"parent",
|
|
17
|
-
"sibling",
|
|
18
|
-
"index"
|
|
19
|
-
],
|
|
20
|
-
"style",
|
|
21
|
-
"unknown"
|
|
22
|
-
] },
|
|
23
|
-
ignorePatterns: [
|
|
24
|
-
"public/**",
|
|
25
|
-
"src/assets/**",
|
|
26
|
-
"src/@types/routes.d.ts",
|
|
27
|
-
"**/*.svg",
|
|
28
|
-
"*.lock",
|
|
29
|
-
"AGENTS.md",
|
|
30
|
-
".agents/**",
|
|
31
|
-
".claude/**"
|
|
32
|
-
]
|
|
33
|
-
};
|
|
34
|
-
export { fmt };
|
|
1
|
+
export { t as fmt } from "./fmt-9dlUYOMk.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { t as prepareMessages } from "./prepareMessages-BXmY6Ko2.mjs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { execFile } from "node:child_process";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
// src/i18n/generateMessages/index.ts
|
|
7
|
+
const resolvePackage = createRequire(import.meta.url);
|
|
8
|
+
const COMPILER_CLI = path.resolve(path.dirname(resolvePackage.resolve("@inlang/paraglide-js")), "../bin/run.js");
|
|
9
|
+
const execute = promisify(execFile);
|
|
10
|
+
async function generateMessages(root = process.cwd()) {
|
|
11
|
+
const resolved = path.resolve(root);
|
|
12
|
+
await prepareMessages(resolved);
|
|
13
|
+
await execute("bun", [
|
|
14
|
+
COMPILER_CLI,
|
|
15
|
+
"compile",
|
|
16
|
+
"--project",
|
|
17
|
+
path.join(resolved, "project.inlang"),
|
|
18
|
+
"--silent"
|
|
19
|
+
], { cwd: resolved });
|
|
20
|
+
}
|
|
21
|
+
// src/i18n/generate.ts
|
|
22
|
+
await generateMessages();
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { n as canContainCatalogs, r as isCatalogFile, t as prepareMessages } from "./prepareMessages-BXmY6Ko2.mjs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { setTimeout } from "node:timers/promises";
|
|
4
|
+
import { paraglideVitePlugin } from "@inlang/paraglide-js";
|
|
5
|
+
// src/i18n/i18nPlugin/index.ts
|
|
6
|
+
const PROJECT = "./project.inlang";
|
|
7
|
+
const PROJECT_FILES = /* @__PURE__ */ new Set(["project.inlang/settings.json", "project.inlang/paraglide.config.ts"]);
|
|
8
|
+
const PREPARATION_DELAY_MS = 100;
|
|
9
|
+
function isProjectFile({ root, file }) {
|
|
10
|
+
const relative = path.relative(root, file).split(path.sep).join("/");
|
|
11
|
+
return PROJECT_FILES.has(relative);
|
|
12
|
+
}
|
|
13
|
+
function catalogPreparation() {
|
|
14
|
+
let root = process.cwd();
|
|
15
|
+
let server;
|
|
16
|
+
let failure;
|
|
17
|
+
let pendingPreparation;
|
|
18
|
+
let requested = 0;
|
|
19
|
+
let isRunning = false;
|
|
20
|
+
const prepare = async () => {
|
|
21
|
+
try {
|
|
22
|
+
await prepareMessages(root);
|
|
23
|
+
if (!failure) return;
|
|
24
|
+
failure = void 0;
|
|
25
|
+
server?.ws.send({ type: "full-reload" });
|
|
26
|
+
} catch (error) {
|
|
27
|
+
failure = error instanceof Error ? error : new Error(String(error));
|
|
28
|
+
server?.ws.send({
|
|
29
|
+
type: "error",
|
|
30
|
+
err: {
|
|
31
|
+
message: failure.message,
|
|
32
|
+
stack: failure.stack ?? ""
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const prepareRequested = async () => {
|
|
38
|
+
isRunning = true;
|
|
39
|
+
try {
|
|
40
|
+
let handled = 0;
|
|
41
|
+
while (handled < requested) {
|
|
42
|
+
handled = requested;
|
|
43
|
+
await setTimeout(PREPARATION_DELAY_MS);
|
|
44
|
+
if (handled < requested) continue;
|
|
45
|
+
await prepare();
|
|
46
|
+
}
|
|
47
|
+
} finally {
|
|
48
|
+
isRunning = false;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const request = () => {
|
|
52
|
+
requested += 1;
|
|
53
|
+
if (!isRunning) pendingPreparation = prepareRequested();
|
|
54
|
+
};
|
|
55
|
+
const schedule = () => {
|
|
56
|
+
request();
|
|
57
|
+
return pendingPreparation;
|
|
58
|
+
};
|
|
59
|
+
const reconcile = (directory) => {
|
|
60
|
+
if (canContainCatalogs({
|
|
61
|
+
root,
|
|
62
|
+
file: directory
|
|
63
|
+
})) request();
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
name: "project:i18n-catalogs",
|
|
67
|
+
enforce: "pre",
|
|
68
|
+
async configResolved(config) {
|
|
69
|
+
({root} = config);
|
|
70
|
+
await prepareMessages(root);
|
|
71
|
+
},
|
|
72
|
+
configureServer(devServer) {
|
|
73
|
+
server = devServer;
|
|
74
|
+
devServer.watcher.on("addDir", reconcile);
|
|
75
|
+
devServer.watcher.on("unlinkDir", reconcile);
|
|
76
|
+
devServer.middlewares.use((_request, response, next) => {
|
|
77
|
+
if (!failure) {
|
|
78
|
+
next();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
response.statusCode = 500;
|
|
82
|
+
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
83
|
+
response.end(failure.message);
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
watchChange: {
|
|
87
|
+
sequential: true,
|
|
88
|
+
handler(file) {
|
|
89
|
+
return isProjectFile({
|
|
90
|
+
root,
|
|
91
|
+
file
|
|
92
|
+
}) || isCatalogFile({
|
|
93
|
+
root,
|
|
94
|
+
file
|
|
95
|
+
}) ? schedule() : void 0;
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
closeServer() {
|
|
99
|
+
return pendingPreparation;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function i18nPlugin() {
|
|
104
|
+
return [catalogPreparation(), paraglideVitePlugin({
|
|
105
|
+
project: PROJECT,
|
|
106
|
+
devErrorResponse: true
|
|
107
|
+
})];
|
|
108
|
+
}
|
|
109
|
+
export { i18nPlugin };
|
package/dist/knip.d.mts
CHANGED
|
@@ -6,7 +6,8 @@ type KnipOptions = AppSettings & {
|
|
|
6
6
|
configFile?: string;
|
|
7
7
|
entry?: string[];
|
|
8
8
|
solidPluginImport?: SolidPluginImport;
|
|
9
|
+
packagedTestTools?: boolean;
|
|
9
10
|
};
|
|
10
11
|
type ConfigureKnip = () => Promise<KnipConfiguration>;
|
|
11
|
-
export declare function defineKnipConfig({ root, configFile, entry, solidPluginImport, ignoreBinaries, ignoreDependencies, ignoreIssues, exclude }: KnipOptions): ConfigureKnip;
|
|
12
|
+
export declare function defineKnipConfig({ root, configFile, entry, solidPluginImport, packagedTestTools, ignoreBinaries, ignoreDependencies, ignoreIssues, exclude }: KnipOptions): ConfigureKnip;
|
|
12
13
|
export {};
|
package/dist/knip.mjs
CHANGED
|
@@ -46,7 +46,7 @@ async function conventionEntries({ root, patterns }) {
|
|
|
46
46
|
pattern
|
|
47
47
|
}) ? [`${pattern}!`] : []))).flat();
|
|
48
48
|
}
|
|
49
|
-
function defineKnipConfig({ root, configFile = DEFAULT_CONFIG_FILE, entry = [], solidPluginImport = "lazy", ignoreBinaries, ignoreDependencies, ignoreIssues = {}, exclude }) {
|
|
49
|
+
function defineKnipConfig({ root, configFile = DEFAULT_CONFIG_FILE, entry = [], solidPluginImport = "lazy", packagedTestTools = true, ignoreBinaries, ignoreDependencies, ignoreIssues = {}, exclude }) {
|
|
50
50
|
const patterns = solidPluginImport === "static" ? RUNTIME_ENTRIES : [...SOLID_ENTRIES, ...RUNTIME_ENTRIES];
|
|
51
51
|
return async function configureKnip() {
|
|
52
52
|
const [conventions, routes, hasTooling] = await Promise.all([
|
|
@@ -78,8 +78,13 @@ function defineKnipConfig({ root, configFile = DEFAULT_CONFIG_FILE, entry = [],
|
|
|
78
78
|
"!src/**/*.test.{ts,tsx}!"
|
|
79
79
|
],
|
|
80
80
|
"filesystem-routing": false,
|
|
81
|
+
"unplugin-icons": true,
|
|
81
82
|
...ignoreBinaries ? { ignoreBinaries } : {},
|
|
82
|
-
|
|
83
|
+
ignoreDependencies: [...packagedTestTools ? [
|
|
84
|
+
"@vitest/coverage-v8",
|
|
85
|
+
"happy-dom",
|
|
86
|
+
"@testing-library/jest-dom"
|
|
87
|
+
] : [], ...ignoreDependencies ?? []],
|
|
83
88
|
ignoreIssues: {
|
|
84
89
|
...ignoreIssues,
|
|
85
90
|
[configFile]: [.../* @__PURE__ */ new Set([...configIssues, "unlisted"])]
|