@beastjs/page-builder 0.0.0-stage → 0.1.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/CHANGELOG.md +17 -0
- package/LICENSE +15 -0
- package/README.md +200 -2
- package/dist/client.js +234 -0
- package/dist/rsbuild.d.ts +1 -0
- package/dist/rsbuild.js +883 -0
- package/dist/rspack.d.ts +1 -0
- package/dist/rspack.js +892 -0
- package/dist/types/rsbuild.d.ts +4 -0
- package/dist/types/rspack.d.ts +9 -0
- package/dist/types/server/discovery.d.ts +8 -0
- package/dist/types/server/integration.d.ts +6 -0
- package/dist/types/server/project.d.ts +24 -0
- package/dist/types/server/server.d.ts +10 -0
- package/dist/types/shared/types.d.ts +121 -0
- package/dist/types/vite.d.ts +4 -0
- package/dist/vite.d.ts +1 -0
- package/dist/vite.js +887 -0
- package/package.json +103 -4
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
+
import type { BeastPageBuilderOptions } from './shared/types.js';
|
|
3
|
+
export type { BeastPageBuilderOptions, ProjectScan, DetectedCollection, DetectedItem, ItemType, ItemField, NavigationTarget } from './shared/types.js';
|
|
4
|
+
export declare function beastPageBuilder(options?: BeastPageBuilderOptions): RsbuildPlugin;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
2
|
+
import type { BeastPageBuilderOptions } from './shared/types.js';
|
|
3
|
+
export type { BeastPageBuilderOptions, ProjectScan, DetectedCollection, DetectedItem, ItemType, ItemField, NavigationTarget } from './shared/types.js';
|
|
4
|
+
export declare class BeastPageBuilderRspackPlugin implements RspackPluginInstance {
|
|
5
|
+
readonly options: BeastPageBuilderOptions;
|
|
6
|
+
constructor(options?: BeastPageBuilderOptions);
|
|
7
|
+
apply(compiler: Compiler): void;
|
|
8
|
+
}
|
|
9
|
+
export declare function beastPageBuilder(options?: BeastPageBuilderOptions): BeastPageBuilderRspackPlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DetectedCollection } from '../shared/types.js';
|
|
2
|
+
export interface DiscoverySource {
|
|
3
|
+
file: string;
|
|
4
|
+
source: string;
|
|
5
|
+
page: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** Inspect source and types without importing or executing the project's modules. */
|
|
8
|
+
export declare function discoverCollections(root: string, sources: DiscoverySource[]): DetectedCollection[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import type { BeastPageBuilderOptions, NavigationTarget } from '../shared/types.js';
|
|
3
|
+
export declare function parseTypeScript(source: string, file: string): ts.SourceFile;
|
|
4
|
+
export declare function registerRoute(source: string, file: string, pageFile: string, name: string, path: string): string;
|
|
5
|
+
export declare function discoverNavigation(source: string, file: string, config?: BeastPageBuilderOptions['navigation']): NavigationTarget[];
|
|
6
|
+
export declare function addNavigation(source: string, target: NavigationTarget, path: string, label: string, config?: BeastPageBuilderOptions['navigation']): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BeastPageBuilderOptions, PageDraft, PagePreview, ProjectScan } from '../shared/types.js';
|
|
2
|
+
export declare class BuilderError extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
constructor(message: string, status?: number);
|
|
5
|
+
}
|
|
6
|
+
export declare class BuilderProject {
|
|
7
|
+
private readonly options;
|
|
8
|
+
readonly root: string;
|
|
9
|
+
readonly include: string[];
|
|
10
|
+
readonly pagesDir: string;
|
|
11
|
+
readonly routerFile: string;
|
|
12
|
+
private compiler;
|
|
13
|
+
private mutation;
|
|
14
|
+
private creations;
|
|
15
|
+
constructor(root: string, options?: BeastPageBuilderOptions);
|
|
16
|
+
/** Check existing ancestors too, so a configured directory cannot escape through a symlink. */
|
|
17
|
+
private safe;
|
|
18
|
+
scan(): Promise<ProjectScan>;
|
|
19
|
+
source(path: string): Promise<string>;
|
|
20
|
+
preview(draft: PageDraft): Promise<PagePreview>;
|
|
21
|
+
create(draft: PageDraft, hash: string): Promise<PagePreview>;
|
|
22
|
+
/** A reload can interrupt the browser response while the file transaction finishes. */
|
|
23
|
+
creation(hash: string): Promise<PagePreview>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { type BeastPageBuilderOptions, type ClientConfig } from '../shared/types.js';
|
|
3
|
+
import { BuilderProject } from './project.js';
|
|
4
|
+
export declare const CLIENT_ENTRY: string;
|
|
5
|
+
export declare function clientConfig(options: BeastPageBuilderOptions): ClientConfig;
|
|
6
|
+
export declare function createBuilderServer(root: string, options?: BeastPageBuilderOptions, basePath?: string): {
|
|
7
|
+
middleware: (req: IncomingMessage, res: ServerResponse, next: (error?: unknown) => void) => void;
|
|
8
|
+
project: BuilderProject;
|
|
9
|
+
clientEntry: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export declare const BASE = "/__beast-page-builder";
|
|
2
|
+
export interface BeastPageBuilderOptions {
|
|
3
|
+
/** Project-relative folders to scan. */
|
|
4
|
+
include?: string[];
|
|
5
|
+
/** New pages are created here; existing files are never overwritten. */
|
|
6
|
+
pagesDir?: string;
|
|
7
|
+
/** TanStack Router module containing rootRoute.addChildren([...]). */
|
|
8
|
+
routerFile?: string;
|
|
9
|
+
/** Limit page-link insertion to this file and optionally one nav/array/group. */
|
|
10
|
+
navigation?: {
|
|
11
|
+
file: string;
|
|
12
|
+
selector?: string;
|
|
13
|
+
array?: string;
|
|
14
|
+
group?: string;
|
|
15
|
+
itemDefaults?: Record<string, string | number | boolean | string[]>;
|
|
16
|
+
};
|
|
17
|
+
/** Mod means Command on macOS and Control elsewhere. */
|
|
18
|
+
shortcut?: string;
|
|
19
|
+
position?: 'center' | 'bottom-right';
|
|
20
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
21
|
+
/** Minimum scan animation duration in milliseconds. */
|
|
22
|
+
scanDuration?: number;
|
|
23
|
+
launcher?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface ClientConfig {
|
|
26
|
+
shortcut: string;
|
|
27
|
+
position: 'center' | 'bottom-right';
|
|
28
|
+
theme: 'light' | 'dark' | 'auto';
|
|
29
|
+
scanDuration: number;
|
|
30
|
+
launcher: boolean;
|
|
31
|
+
pagesDir: string;
|
|
32
|
+
routerFile: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ProjectFile {
|
|
35
|
+
path: string;
|
|
36
|
+
name: string;
|
|
37
|
+
kind: 'page' | 'component';
|
|
38
|
+
lines: number;
|
|
39
|
+
components: string[];
|
|
40
|
+
error: string | null;
|
|
41
|
+
}
|
|
42
|
+
export interface ProjectScan {
|
|
43
|
+
name: string;
|
|
44
|
+
files: ProjectFile[];
|
|
45
|
+
scannedAt: string;
|
|
46
|
+
warnings: string[];
|
|
47
|
+
navigationTargets: NavigationTarget[];
|
|
48
|
+
collections: DetectedCollection[];
|
|
49
|
+
}
|
|
50
|
+
export interface ItemField {
|
|
51
|
+
name: string;
|
|
52
|
+
type: string;
|
|
53
|
+
optional: boolean;
|
|
54
|
+
values?: Array<string | number | boolean>;
|
|
55
|
+
}
|
|
56
|
+
export interface ItemType {
|
|
57
|
+
name: string;
|
|
58
|
+
origin: 'declared' | 'inferred';
|
|
59
|
+
fields: ItemField[];
|
|
60
|
+
variants?: ItemType[];
|
|
61
|
+
}
|
|
62
|
+
export interface DetectedItem {
|
|
63
|
+
label: string;
|
|
64
|
+
kind: 'internal-link' | 'external-link' | 'anchor' | 'action' | 'tab' | 'unknown';
|
|
65
|
+
line: number;
|
|
66
|
+
component?: string;
|
|
67
|
+
destination?: string;
|
|
68
|
+
value?: string;
|
|
69
|
+
itemType: ItemType;
|
|
70
|
+
}
|
|
71
|
+
export interface CollectionConsumer {
|
|
72
|
+
file: string;
|
|
73
|
+
line: number;
|
|
74
|
+
name: string;
|
|
75
|
+
}
|
|
76
|
+
export interface DetectedCollection {
|
|
77
|
+
id: string;
|
|
78
|
+
file: string;
|
|
79
|
+
line: number;
|
|
80
|
+
name: string;
|
|
81
|
+
kind: 'navigation' | 'tabs';
|
|
82
|
+
source: 'markup' | 'data';
|
|
83
|
+
itemType: ItemType;
|
|
84
|
+
items: DetectedItem[];
|
|
85
|
+
editable: boolean;
|
|
86
|
+
reason?: string;
|
|
87
|
+
array?: string;
|
|
88
|
+
group?: string;
|
|
89
|
+
bindings: string[];
|
|
90
|
+
consumers: CollectionConsumer[];
|
|
91
|
+
dataSources: string[];
|
|
92
|
+
}
|
|
93
|
+
export interface NavigationTarget {
|
|
94
|
+
id: string;
|
|
95
|
+
file: string;
|
|
96
|
+
label: string;
|
|
97
|
+
array?: string;
|
|
98
|
+
group?: string;
|
|
99
|
+
itemType?: ItemType;
|
|
100
|
+
}
|
|
101
|
+
export interface PageDraft {
|
|
102
|
+
name: string;
|
|
103
|
+
source: string;
|
|
104
|
+
routePath?: string;
|
|
105
|
+
navLabel?: string;
|
|
106
|
+
navigationTarget?: string;
|
|
107
|
+
}
|
|
108
|
+
export interface PlannedFile {
|
|
109
|
+
path: string;
|
|
110
|
+
action: 'create' | 'edit';
|
|
111
|
+
before: string | null;
|
|
112
|
+
source: string;
|
|
113
|
+
}
|
|
114
|
+
export interface PagePreview {
|
|
115
|
+
path: string;
|
|
116
|
+
source: string;
|
|
117
|
+
hash: string;
|
|
118
|
+
routePath: string;
|
|
119
|
+
navLabel: string;
|
|
120
|
+
files: PlannedFile[];
|
|
121
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import { type BeastPageBuilderOptions } from './shared/types.js';
|
|
3
|
+
export type { BeastPageBuilderOptions, ProjectScan, DetectedCollection, DetectedItem, ItemType, ItemField, NavigationTarget } from './shared/types.js';
|
|
4
|
+
export declare function beastPageBuilder(options?: BeastPageBuilderOptions): Plugin;
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types/vite.js'
|