dslinter 0.1.2 → 0.1.4

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.
@@ -10,15 +10,44 @@ export type PlaygroundJoinSkip = {
10
10
  reason: PlaygroundJoinSkipReason;
11
11
  };
12
12
 
13
+ const DEFAULT_CONSUMER_STRIP_PREFIXES = ["src/", "resources/js/"] as const;
14
+
15
+ /**
16
+ * Build `globKeyFromRelPath` for a registry file one level below a source root
17
+ * (e.g. `src/playground/` or `resources/js/playground/`).
18
+ */
19
+ export function createConsumerGlobKeyFromRelPath(
20
+ options: {
21
+ /** Path prefixes removed from report `rel_path` before prepending `relativePrefix`. */
22
+ stripPrefixes?: readonly string[];
23
+ /** Prepended to the stripped path (default `../`). */
24
+ relativePrefix?: string;
25
+ } = {},
26
+ ): (relPath: string) => string {
27
+ const stripPrefixes = options.stripPrefixes ?? DEFAULT_CONSUMER_STRIP_PREFIXES;
28
+ const relativePrefix = options.relativePrefix ?? "../";
29
+ return (relPath: string) => {
30
+ let trimmed = relPath.replace(/^\/+/, "");
31
+ for (const prefix of stripPrefixes) {
32
+ if (trimmed.startsWith(prefix)) {
33
+ trimmed = trimmed.slice(prefix.length);
34
+ break;
35
+ }
36
+ }
37
+ return `${relativePrefix}${trimmed}`;
38
+ };
39
+ }
40
+
13
41
  /**
14
42
  * Maps report `rel_path` to a Vite `import.meta.glob` key when the registry lives in
15
- * `src/playground/` and components live under `src/components/`.
43
+ * `src/playground/` or `resources/js/playground/` next to your components.
16
44
  *
17
- * Example: `src/components/ui/button.tsx` → `../components/ui/button.tsx`
45
+ * Examples:
46
+ * - `src/components/ui/button.tsx` → `../components/ui/button.tsx`
47
+ * - `resources/js/Components/Icons/Activity.tsx` → `../Components/Icons/Activity.tsx`
18
48
  */
19
49
  export function defaultConsumerGlobKeyFromRelPath(relPath: string): string {
20
- const trimmed = relPath.replace(/^\/+/, "").replace(/^src\//, "");
21
- return `../${trimmed}`;
50
+ return createConsumerGlobKeyFromRelPath()(relPath);
22
51
  }
23
52
 
24
53
  export function defaultEmbedGlobKeyFromRelPath(relPath: string): string {
@@ -10,7 +10,7 @@ import {
10
10
  import type { PlaygroundEntry } from "../types/playground";
11
11
  import type { TokenCatalog } from "../types/tokenCatalog";
12
12
  import type { DslinterReportState } from "../dashboard/useWorkspaceReport";
13
- import { Button } from "@/components/ui/button";
13
+ import { Button } from "../components/ui/button";
14
14
  import { cn } from "../lib/utils";
15
15
  import { ComponentInspectPane } from "../components/ComponentInspectPane";
16
16
  import { ComponentPlaygroundPane } from "../components/ComponentPlaygroundPane";
@@ -0,0 +1,26 @@
1
+ import type { PlaygroundEntry, WorkspaceReport } from "dslinter";
2
+ import { createPlaygroundRegistry } from "dslinter";
3
+
4
+ /**
5
+ * Registry lives in `resources/js/playground/`.
6
+ * Glob is relative to this file — covers Inertia/React components under `resources/js/`.
7
+ */
8
+ const modules = import.meta.glob("../**/*.{tsx,jsx}", {
9
+ eager: true,
10
+ }) as Record<string, Record<string, unknown>>;
11
+
12
+ const buildWithSkips = createPlaygroundRegistry(modules, {
13
+ stripPrefixes: ["resources/js/", "src/"],
14
+ });
15
+
16
+ export function buildPlaygroundEntries(
17
+ report: WorkspaceReport | null | undefined,
18
+ ): PlaygroundEntry[] {
19
+ return buildWithSkips(report).entries;
20
+ }
21
+
22
+ export function getPlaygroundJoinSkips(
23
+ report: WorkspaceReport | null | undefined,
24
+ ) {
25
+ return buildWithSkips(report).skipped;
26
+ }
@@ -0,0 +1,14 @@
1
+ // Add to vite.config.ts when using @dslint-scan embed-style glob in App:
2
+ //
3
+ // import path from "node:path";
4
+ // const scanRoot = path.resolve(process.env.DSLINT_SCAN_ROOT ?? ".");
5
+ //
6
+ // resolve: { alias: { "@dslint-scan": scanRoot } },
7
+ // server: { fs: { allow: [scanRoot] } },
8
+ //
9
+ // App — glob every .tsx/.jsx under @dslint-scan (use ** recursive glob in import.meta.glob).
10
+ // buildPlaygroundEntriesFromReport(report, modules);
11
+ //
12
+ // Prefer: npx dslinter init --laravel (relative glob) for Inertia resources/js layouts.
13
+
14
+ export {};
@@ -1,9 +1,11 @@
1
1
  /**
2
- * Add to your existing `vite.config.ts` when using `npx dslinter` dev mode.
3
- * Adjust paths if your app layout differs from `src/` + `public/dslint-report.json`.
2
+ * Merge into your existing `vite.config.ts` when using `npx dslinter` dev mode.
3
+ *
4
+ * Published dslinter source uses relative imports only — your app's `@/*` alias
5
+ * (e.g. Laravel `@/*` → `resources/js/*`) does not need remapping for package UI.
6
+ *
7
+ * Adjust proxy paths if your report is not served from the Vite dev server root.
4
8
  */
5
- import path from "node:path";
6
-
7
9
  const DSLINT_SERVE_PORT = Number(process.env.DSLINT_SERVE_PORT ?? "7878");
8
10
 
9
11
  // Inside defineConfig(({ mode }) => ({ ... })):
@@ -11,6 +13,10 @@ export const dslinterViteSnippet = {
11
13
  resolve: {
12
14
  dedupe: ["react", "react-dom"],
13
15
  },
16
+ optimizeDeps: {
17
+ /** Source-first package: transpile from node_modules instead of pre-bundling. */
18
+ exclude: ["dslinter"],
19
+ },
14
20
  server: {
15
21
  proxy:
16
22
  // mode === "serve" when started via `npx dslinter` (not plain `vite`)