@ubean/build 0.1.1 → 0.1.3
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/index.d.ts +88 -0
- package/dist/index.js +43 -0
- package/dist/production.d.ts +27 -0
- package/dist/production.js +611 -0
- package/dist/virtual-modules-DXIaZdQI.js +404 -0
- package/dist/vite.d.ts +41 -0
- package/dist/vite.js +209 -0
- package/package.json +9 -9
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { CompiledLayout, CompiledMiddleware, CompiledPage, CompiledRoute, ScannedApiRoute, ScannedLocale, ScannedMiddleware, ScannedPageRoute } from "@ubean/routing";
|
|
2
|
+
//#region src/virtual-registry.d.ts
|
|
3
|
+
interface VirtualModuleContext {
|
|
4
|
+
resolveId(id: string): string | undefined;
|
|
5
|
+
load(id: string): string | undefined;
|
|
6
|
+
invalidate(id: string): void;
|
|
7
|
+
}
|
|
8
|
+
type VirtualModuleTransform = (id: string, code: string) => string | Promise<string>;
|
|
9
|
+
interface VirtualModule {
|
|
10
|
+
id: string;
|
|
11
|
+
resolve(id: string, importer?: string): string | undefined;
|
|
12
|
+
load(): string | Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
declare class VirtualModuleRegistry {
|
|
15
|
+
private modules;
|
|
16
|
+
private invalidated;
|
|
17
|
+
register(mod: VirtualModule): void;
|
|
18
|
+
resolveId(id: string, importer?: string): string | undefined;
|
|
19
|
+
load(id: string): Promise<string | undefined>;
|
|
20
|
+
invalidate(id: string): void;
|
|
21
|
+
isInvalidated(id: string): boolean;
|
|
22
|
+
clearInvalidated(): void;
|
|
23
|
+
getModules(): VirtualModule[];
|
|
24
|
+
clear(): void;
|
|
25
|
+
}
|
|
26
|
+
declare function useVirtualRegistry(): VirtualModuleRegistry;
|
|
27
|
+
declare function resetVirtualRegistry(): void;
|
|
28
|
+
declare function defineVirtualModule(id: string, loader: () => string | Promise<string>): VirtualModule;
|
|
29
|
+
declare function defineVirtualModulePrefix(prefix: string, loader: (id: string) => string | Promise<string>): VirtualModule;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/macros.d.ts
|
|
32
|
+
declare function stripMacros(code: string, macros?: readonly string[]): string;
|
|
33
|
+
declare function transformMacros(code: string, id: string): string | null;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/virtual-modules.d.ts
|
|
36
|
+
declare function createRoutingVirtualModule(routes: CompiledRoute[], middlewares: CompiledMiddleware[]): VirtualModule;
|
|
37
|
+
declare function createPagesVirtualModule(pages: CompiledPage[], layouts: CompiledLayout[]): VirtualModule;
|
|
38
|
+
declare function createMetaVirtualModule(): VirtualModule;
|
|
39
|
+
declare function createAppVirtualModule(apiRoutes: ScannedApiRoute[], middlewares: ScannedMiddleware[], pages: ScannedPageRoute[], srcDir: string): VirtualModule;
|
|
40
|
+
declare function createLocalesVirtualModule(_locales: ScannedLocale[], defaultLocale: string | undefined, srcDir?: string): VirtualModule;
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/registry.d.ts
|
|
43
|
+
/**
|
|
44
|
+
* Module extension registry.
|
|
45
|
+
*
|
|
46
|
+
* Allows built-in extension modules (@ubean/ui, @ubean/icon, etc.) to inject
|
|
47
|
+
* component resolvers and CSS imports into the core Vite plugin pipeline
|
|
48
|
+
* without modifying ubeanVuePlugin directly.
|
|
49
|
+
*
|
|
50
|
+
* Registration happens at module load time (when ubeanUiPlugin() etc. are
|
|
51
|
+
* called by the module system, before ubeanVuePlugin reads the registry).
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* Generic component resolver type compatible with unplugin-vue-components.
|
|
55
|
+
* Accepts both function resolvers and object resolvers (ComponentResolverObject).
|
|
56
|
+
*/
|
|
57
|
+
type ComponentResolver = ((name: string) => any) | {
|
|
58
|
+
type: 'component' | 'directive';
|
|
59
|
+
resolve: (name: string) => any;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Register a component resolver (e.g. `UiResolver()` from `@soybeanjs/ui/resolver`).
|
|
63
|
+
* The resolver will be merged into `unplugin-vue-components`'s `resolvers` array.
|
|
64
|
+
*/
|
|
65
|
+
declare function registerComponentResolver(resolver: ComponentResolver): void;
|
|
66
|
+
/**
|
|
67
|
+
* Get all registered component resolvers.
|
|
68
|
+
* Called by `ubeanVuePlugin` when constructing the `Components()` plugin.
|
|
69
|
+
*/
|
|
70
|
+
declare function getComponentResolvers(): ComponentResolver[];
|
|
71
|
+
/**
|
|
72
|
+
* Register a CSS import path to be injected into the client entry.
|
|
73
|
+
* e.g. `registerCssImport('@soybeanjs/ui/styles.css')` makes the client
|
|
74
|
+
* entry module prepend `import '@soybeanjs/ui/styles.css'`.
|
|
75
|
+
*/
|
|
76
|
+
declare function registerCssImport(cssPath: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* Get all registered CSS import paths.
|
|
79
|
+
* Called by `createClientEntryVirtualModule` to prepend CSS imports.
|
|
80
|
+
*/
|
|
81
|
+
declare function getCssImports(): string[];
|
|
82
|
+
/**
|
|
83
|
+
* Reset the registry (for testing).
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
declare function resetModuleRegistry(): void;
|
|
87
|
+
//#endregion
|
|
88
|
+
export { type VirtualModule, type VirtualModuleContext, VirtualModuleRegistry, type VirtualModuleTransform, createAppVirtualModule, createLocalesVirtualModule, createMetaVirtualModule, createPagesVirtualModule, createRoutingVirtualModule, defineVirtualModule, defineVirtualModulePrefix, getComponentResolvers, getCssImports, registerComponentResolver, registerCssImport, resetModuleRegistry, resetVirtualRegistry, stripMacros, transformMacros, useVirtualRegistry };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { a as createRoutingVirtualModule, c as VirtualModuleRegistry, d as resetVirtualRegistry, f as useVirtualRegistry, i as createPagesVirtualModule, l as defineVirtualModule, n as createLocalesVirtualModule, o as stripMacros, r as createMetaVirtualModule, s as transformMacros, t as createAppVirtualModule, u as defineVirtualModulePrefix } from "./virtual-modules-DXIaZdQI.js";
|
|
2
|
+
//#region src/registry.ts
|
|
3
|
+
const componentResolvers = [];
|
|
4
|
+
const cssImports = [];
|
|
5
|
+
/**
|
|
6
|
+
* Register a component resolver (e.g. `UiResolver()` from `@soybeanjs/ui/resolver`).
|
|
7
|
+
* The resolver will be merged into `unplugin-vue-components`'s `resolvers` array.
|
|
8
|
+
*/
|
|
9
|
+
function registerComponentResolver(resolver) {
|
|
10
|
+
componentResolvers.push(resolver);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get all registered component resolvers.
|
|
14
|
+
* Called by `ubeanVuePlugin` when constructing the `Components()` plugin.
|
|
15
|
+
*/
|
|
16
|
+
function getComponentResolvers() {
|
|
17
|
+
return [...componentResolvers];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Register a CSS import path to be injected into the client entry.
|
|
21
|
+
* e.g. `registerCssImport('@soybeanjs/ui/styles.css')` makes the client
|
|
22
|
+
* entry module prepend `import '@soybeanjs/ui/styles.css'`.
|
|
23
|
+
*/
|
|
24
|
+
function registerCssImport(cssPath) {
|
|
25
|
+
if (!cssImports.includes(cssPath)) cssImports.push(cssPath);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get all registered CSS import paths.
|
|
29
|
+
* Called by `createClientEntryVirtualModule` to prepend CSS imports.
|
|
30
|
+
*/
|
|
31
|
+
function getCssImports() {
|
|
32
|
+
return [...cssImports];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Reset the registry (for testing).
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
function resetModuleRegistry() {
|
|
39
|
+
componentResolvers.length = 0;
|
|
40
|
+
cssImports.length = 0;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { VirtualModuleRegistry, createAppVirtualModule, createLocalesVirtualModule, createMetaVirtualModule, createPagesVirtualModule, createRoutingVirtualModule, defineVirtualModule, defineVirtualModulePrefix, getComponentResolvers, getCssImports, registerComponentResolver, registerCssImport, resetModuleRegistry, resetVirtualRegistry, stripMacros, transformMacros, useVirtualRegistry };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ResolvedConfig } from "@ubean/config";
|
|
2
|
+
import { ScanResult } from "@ubean/routing";
|
|
3
|
+
import { Preset } from "@ubean/preset";
|
|
4
|
+
//#region src/production.d.ts
|
|
5
|
+
interface BuildOptions {
|
|
6
|
+
cwd: string;
|
|
7
|
+
config: ResolvedConfig;
|
|
8
|
+
preset: Preset;
|
|
9
|
+
scanResult: ScanResult;
|
|
10
|
+
minify?: boolean;
|
|
11
|
+
sourcemap?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface BuildManifest {
|
|
14
|
+
assets: Array<{
|
|
15
|
+
file: string;
|
|
16
|
+
src?: string;
|
|
17
|
+
isEntry?: boolean;
|
|
18
|
+
css?: string[];
|
|
19
|
+
}>;
|
|
20
|
+
entry: string;
|
|
21
|
+
clientDir: string;
|
|
22
|
+
serverDir: string;
|
|
23
|
+
preset: string;
|
|
24
|
+
}
|
|
25
|
+
declare function buildProduction(options: BuildOptions): Promise<BuildManifest>;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { BuildManifest, BuildOptions, buildProduction };
|