what-compiler 0.11.1 → 0.11.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/babel.d.ts +14 -0
- package/file-router.d.ts +44 -0
- package/index.d.ts +21 -0
- package/package.json +14 -3
- package/runtime.d.ts +4 -0
- package/vite.d.ts +42 -0
package/babel.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// what-compiler/babel — Babel plugin that transforms What JSX to optimized DOM
|
|
2
|
+
// operations (src/babel-plugin.js). Add to a Babel config's `plugins`.
|
|
3
|
+
|
|
4
|
+
export interface BabelPluginPass {
|
|
5
|
+
name?: string;
|
|
6
|
+
visitor: Record<string, unknown>;
|
|
7
|
+
inherits?: unknown;
|
|
8
|
+
manipulateOptions?: (opts: unknown, parserOpts: unknown) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Babel plugin factory — Babel calls this with its API (`{ types }`). */
|
|
12
|
+
declare function whatBabelPlugin(api: { types: any }): BabelPluginPass;
|
|
13
|
+
|
|
14
|
+
export default whatBabelPlugin;
|
package/file-router.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// what-compiler/file-router — filesystem route scanning + virtual-module
|
|
2
|
+
// codegen used by the Vite plugin (src/file-router.js).
|
|
3
|
+
|
|
4
|
+
export interface ScannedPage {
|
|
5
|
+
url: string;
|
|
6
|
+
file: string;
|
|
7
|
+
[meta: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ScannedRoutes {
|
|
11
|
+
pages: ScannedPage[];
|
|
12
|
+
layouts: ScannedPage[];
|
|
13
|
+
apiRoutes: ScannedPage[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Walk a pages directory and collect pages, layouts and API routes. */
|
|
17
|
+
export function scanPages(pagesDir: string): ScannedRoutes;
|
|
18
|
+
|
|
19
|
+
export interface PageConfig {
|
|
20
|
+
/** Render mode declared via `export const page = { mode }`. */
|
|
21
|
+
mode: string;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Parse `export const page = { ... }` from a page module's source. */
|
|
26
|
+
export function extractPageConfig(source: string): PageConfig;
|
|
27
|
+
|
|
28
|
+
export interface PageExports {
|
|
29
|
+
hasLoader: boolean;
|
|
30
|
+
hasGetStaticPaths: boolean;
|
|
31
|
+
hasPageConfig: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Detect which named exports (loader, getStaticPaths, page) a module declares. */
|
|
35
|
+
export function detectPageExports(source: string): PageExports;
|
|
36
|
+
|
|
37
|
+
/** Generate the `virtual:what-routes` client module source. */
|
|
38
|
+
export function generateRoutesModule(pagesDir: string, rootDir: string): string;
|
|
39
|
+
|
|
40
|
+
/** Generate the server-side routes module source. */
|
|
41
|
+
export function generateServerRoutesModule(
|
|
42
|
+
pagesDir: string,
|
|
43
|
+
rootDir: string,
|
|
44
|
+
): string;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// what-compiler — TypeScript declarations for the public compiler entry point
|
|
2
|
+
// (src/index.js). Types the surface that is actually exported so vite.config /
|
|
3
|
+
// babel.config authoring against what-compiler is type-checked, not `any`.
|
|
4
|
+
|
|
5
|
+
export { default as babelPlugin } from './babel';
|
|
6
|
+
export { default as vitePlugin, what } from './vite';
|
|
7
|
+
export * from './runtime';
|
|
8
|
+
export {
|
|
9
|
+
scanPages,
|
|
10
|
+
extractPageConfig,
|
|
11
|
+
generateRoutesModule,
|
|
12
|
+
} from './file-router';
|
|
13
|
+
|
|
14
|
+
export type { WhatVitePluginOptions, WhatVitePlugin } from './vite';
|
|
15
|
+
export type { BabelPluginPass } from './babel';
|
|
16
|
+
export type {
|
|
17
|
+
ScannedRoutes,
|
|
18
|
+
ScannedPage,
|
|
19
|
+
PageConfig,
|
|
20
|
+
PageExports,
|
|
21
|
+
} from './file-router';
|
package/package.json
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "what-compiler",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"description": "JSX compiler for What Framework - transforms JSX to optimized DOM operations",
|
|
5
5
|
"main": "src/index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
10
|
+
"types": "./index.d.ts",
|
|
9
11
|
"production": "./dist/index.min.js",
|
|
10
12
|
"import": "./src/index.js"
|
|
11
13
|
},
|
|
12
14
|
"./babel": {
|
|
15
|
+
"types": "./babel.d.ts",
|
|
13
16
|
"production": "./dist/babel-plugin.min.js",
|
|
14
17
|
"import": "./src/babel-plugin.js"
|
|
15
18
|
},
|
|
16
19
|
"./vite": {
|
|
20
|
+
"types": "./vite.d.ts",
|
|
17
21
|
"production": "./dist/vite-plugin.min.js",
|
|
18
22
|
"import": "./src/vite-plugin.js"
|
|
19
23
|
},
|
|
20
24
|
"./runtime": {
|
|
25
|
+
"types": "./runtime.d.ts",
|
|
21
26
|
"production": "./dist/runtime.min.js",
|
|
22
27
|
"import": "./src/runtime.js"
|
|
23
28
|
},
|
|
24
29
|
"./file-router": {
|
|
30
|
+
"types": "./file-router.d.ts",
|
|
25
31
|
"production": "./dist/file-router.min.js",
|
|
26
32
|
"import": "./src/file-router.js"
|
|
27
33
|
}
|
|
@@ -38,11 +44,16 @@
|
|
|
38
44
|
"license": "MIT",
|
|
39
45
|
"peerDependencies": {
|
|
40
46
|
"@babel/core": "^7.0.0",
|
|
41
|
-
"what-core": "^0.11.
|
|
47
|
+
"what-core": "^0.11.3"
|
|
42
48
|
},
|
|
43
49
|
"files": [
|
|
44
50
|
"src",
|
|
45
|
-
"dist/**/*.min.js"
|
|
51
|
+
"dist/**/*.min.js",
|
|
52
|
+
"index.d.ts",
|
|
53
|
+
"babel.d.ts",
|
|
54
|
+
"vite.d.ts",
|
|
55
|
+
"runtime.d.ts",
|
|
56
|
+
"file-router.d.ts"
|
|
46
57
|
],
|
|
47
58
|
"devDependencies": {
|
|
48
59
|
"@babel/core": "^7.23.0",
|
package/runtime.d.ts
ADDED
package/vite.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// what-compiler/vite — Vite plugin that compiles What JSX and wires the
|
|
2
|
+
// file-router / HMR (src/vite-plugin.js).
|
|
3
|
+
|
|
4
|
+
export interface WhatVitePluginOptions {
|
|
5
|
+
/** Files to process. Defaults to /\.[jt]sx$/. */
|
|
6
|
+
include?: RegExp | RegExp[];
|
|
7
|
+
/** Files to skip. Defaults to /node_modules/. */
|
|
8
|
+
exclude?: RegExp | RegExp[];
|
|
9
|
+
/** Emit source maps. Defaults to true. */
|
|
10
|
+
sourceMaps?: boolean;
|
|
11
|
+
/** Apply production optimizations. Defaults to NODE_ENV === 'production'. */
|
|
12
|
+
production?: boolean;
|
|
13
|
+
/** Pages directory, relative to project root. Defaults to 'src/pages'. */
|
|
14
|
+
pages?: string;
|
|
15
|
+
/** Enable HMR. Defaults to enabled in dev, disabled in production. */
|
|
16
|
+
hot?: boolean;
|
|
17
|
+
/** Resolve the `production` exports condition during build. Defaults to true. */
|
|
18
|
+
prodBundles?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Structural Vite plugin shape — assignable to Vite's `PluginOption` without a
|
|
22
|
+
// hard type dependency on `vite`.
|
|
23
|
+
export interface WhatVitePlugin {
|
|
24
|
+
name: string;
|
|
25
|
+
enforce?: 'pre' | 'post';
|
|
26
|
+
[hook: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface JsxPreserveConfigInput {
|
|
30
|
+
rolldownVersion?: string;
|
|
31
|
+
viteVersion?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** esbuild/JSX config so Vite preserves What JSX for the plugin to compile. */
|
|
35
|
+
export function jsxPreserveConfig(
|
|
36
|
+
input?: JsxPreserveConfigInput,
|
|
37
|
+
): Record<string, unknown>;
|
|
38
|
+
|
|
39
|
+
declare function whatVitePlugin(options?: WhatVitePluginOptions): WhatVitePlugin;
|
|
40
|
+
|
|
41
|
+
export { whatVitePlugin as what };
|
|
42
|
+
export default whatVitePlugin;
|