@tailorkit/vite 0.1.0-beta.33 → 0.1.0-beta.35
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/dist/builder.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as createTailorKitUploadManifest, f as tailorkitUploadManifestSchema, l as drizzleGenerateArguments, o as checkAppSchema, r as getClientSourceFiles, u as appDatabasePaths } from "./file-routes-
|
|
1
|
+
import { d as createTailorKitUploadManifest, f as tailorkitUploadManifestSchema, l as drizzleGenerateArguments, o as checkAppSchema, r as getClientSourceFiles, u as appDatabasePaths } from "./file-routes-QA78W6x5.mjs";
|
|
2
2
|
import { loadTailorKitConfig } from "./config-loader.mjs";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import { access } from "node:fs/promises";
|
|
@@ -257,9 +257,10 @@ const createDefineViewMatcher = (program) => {
|
|
|
257
257
|
//#region src/builder/file-routes.ts
|
|
258
258
|
const isObjectValue = (value) => typeof value === "object" && value !== null;
|
|
259
259
|
const clientRuntimeImport = "tailorkit:file-client-runtime";
|
|
260
|
-
const routePath = (name, filename) => {
|
|
260
|
+
const routePath = (name, filename, indexView = false) => {
|
|
261
261
|
const segments = name.split(/[./]/u);
|
|
262
262
|
if (segments.some((segment) => !segment || segment === "..")) throw new Error(`${filename} has an empty route segment. Use route.nested-route.view.tsx.`);
|
|
263
|
+
if (indexView && segments.at(-1) === "index") segments.pop();
|
|
263
264
|
return `/${segments.join("/")}`;
|
|
264
265
|
};
|
|
265
266
|
const fileViewLocation = (filename, root) => {
|
|
@@ -269,10 +270,22 @@ const fileViewLocation = (filename, root) => {
|
|
|
269
270
|
if (!(slot !== void 0 && slot !== null && slot !== "")) return;
|
|
270
271
|
const basename = routeSegments.join("/").slice(0, -9);
|
|
271
272
|
return {
|
|
272
|
-
path: routePath(basename, filename),
|
|
273
|
+
path: routePath(basename, filename, true),
|
|
273
274
|
slot
|
|
274
275
|
};
|
|
275
276
|
};
|
|
277
|
+
const validateViewOptions = (options, expected, filename) => {
|
|
278
|
+
const properties = /* @__PURE__ */ new Set();
|
|
279
|
+
for (const property of options.properties) {
|
|
280
|
+
if (property.type !== "Property" || property.computed && property.key.type !== "Literal") throw new Error(`${filename}: use named defineView properties so the build can validate the slot and view against the file location.`);
|
|
281
|
+
let key;
|
|
282
|
+
if (property.key.type === "Identifier") key = property.key.name;
|
|
283
|
+
else if (property.key.type === "Literal") key = String(property.key.value);
|
|
284
|
+
if ((key === "slot" || key === "view") && (property.kind !== "init" || property.method || property.value.type !== "Literal" || property.value.value !== expected[key])) throw new Error(`${filename}: defineView ${key} must be ${JSON.stringify(expected[key])} to match the file location. Omit ${key} to infer it, or move the file to the matching location.`);
|
|
285
|
+
if (key !== void 0) properties.add(key);
|
|
286
|
+
}
|
|
287
|
+
return properties;
|
|
288
|
+
};
|
|
276
289
|
/** Fill missing defineView options before instance extraction, on both build sides. */
|
|
277
290
|
const inferFileView = (initialSource, filename, root) => {
|
|
278
291
|
let source = initialSource;
|
|
@@ -287,12 +300,10 @@ const inferFileView = (initialSource, filename, root) => {
|
|
|
287
300
|
if (isDefineViewCall(node)) {
|
|
288
301
|
const [options] = node.arguments;
|
|
289
302
|
if (options?.type !== "ObjectExpression") throw new Error(`${filename}: file views require defineView with an inline options object.`);
|
|
290
|
-
const properties =
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
return [];
|
|
295
|
-
}));
|
|
303
|
+
const properties = validateViewOptions(options, {
|
|
304
|
+
slot,
|
|
305
|
+
view: viewPath
|
|
306
|
+
}, filename);
|
|
296
307
|
const defaults = [properties.has("slot") ? "" : `slot: ${JSON.stringify(slot)},`, properties.has("view") ? "" : `view: ${JSON.stringify(viewPath)},`].join("");
|
|
297
308
|
if (defaults) edits.push({
|
|
298
309
|
position: options.start + 1,
|
|
@@ -327,10 +338,10 @@ const discoverFileRoutes = async (root) => {
|
|
|
327
338
|
if (entry.isDirectory()) await scan(filename, slot ?? entry.name, slot !== void 0 && slot !== null && slot !== "" ? `${prefix}${entry.name}/` : "");
|
|
328
339
|
else if (entry.isFile() && slot !== void 0 && slot !== null && slot !== "") {
|
|
329
340
|
if (entry.name.endsWith(".view.tsx")) {
|
|
330
|
-
fileViewLocation(filename, root);
|
|
331
|
-
views.push({
|
|
341
|
+
const location = fileViewLocation(filename, root);
|
|
342
|
+
if (location) views.push({
|
|
332
343
|
filename,
|
|
333
|
-
|
|
344
|
+
...location
|
|
334
345
|
});
|
|
335
346
|
} else if (entry.name === "root.tsx" && !prefix) roots.push({
|
|
336
347
|
filename,
|
|
@@ -380,7 +391,7 @@ const fileClientSource = async (root) => {
|
|
|
380
391
|
const rootModule = discovered.root ? `${module(discovered.root)} }` : "undefined";
|
|
381
392
|
const roots = discovered.roots.map((entry) => `${module(entry)}, slot: ${JSON.stringify(entry.slot)} }`);
|
|
382
393
|
const layouts = discovered.layouts.map((entry) => `${module(entry)}, slot: ${JSON.stringify(entry.slot)}, path: ${JSON.stringify(entry.path)} }`);
|
|
383
|
-
const views = discovered.views.map((entry) => `${module(entry)}, slot: ${JSON.stringify(entry.slot)} }`);
|
|
394
|
+
const views = discovered.views.map((entry) => `${module(entry)}, slot: ${JSON.stringify(entry.slot)}, path: ${JSON.stringify(entry.path)} }`);
|
|
384
395
|
return `${imports.join("\n")}\nexport default createFileClient({ root: ${rootModule}, roots: [${roots.join(",")}], layouts: [${layouts.join(",")}], views: [${views.join(",")}] });`;
|
|
385
396
|
};
|
|
386
397
|
/** A generated entry in build output lets the bundler track imports normally.
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createDefineViewMatcher, c as getBuildEnvironment, d as createTailorKitUploadManifest, f as tailorkitUploadManifestSchema, i as inferFileView, n as fileRoutesPlugin, o as checkAppSchema, s as isMissingFile, t as createFileRouteEntry, u as appDatabasePaths } from "./file-routes-
|
|
1
|
+
import { a as createDefineViewMatcher, c as getBuildEnvironment, d as createTailorKitUploadManifest, f as tailorkitUploadManifestSchema, i as inferFileView, n as fileRoutesPlugin, o as checkAppSchema, s as isMissingFile, t as createFileRouteEntry, u as appDatabasePaths } from "./file-routes-QA78W6x5.mjs";
|
|
2
2
|
import { loadTailorKitConfig } from "./config-loader.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { z } from "zod";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailorkit/vite",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.35",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@tailorkit/app": "0.1.0-beta.
|
|
46
|
+
"@tailorkit/app": "0.1.0-beta.35",
|
|
47
47
|
"cosmiconfig": "^10.0.1",
|
|
48
48
|
"zod": "^4.6.5"
|
|
49
49
|
},
|