@lark.js/mvc 0.0.10 → 0.0.12
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/README.md +10 -10
- package/dist/chunk-66OZBBSP.js +108 -0
- package/dist/compiler.cjs +654 -114
- package/dist/compiler.d.cts +35 -35
- package/dist/compiler.d.ts +35 -35
- package/dist/compiler.js +651 -114
- package/dist/devtool.cjs +3436 -0
- package/dist/devtool.d.cts +83 -0
- package/dist/devtool.d.ts +83 -0
- package/dist/devtool.js +3348 -0
- package/dist/index.cjs +786 -170
- package/dist/index.d.cts +147 -85
- package/dist/index.d.ts +147 -85
- package/dist/index.js +782 -166
- package/dist/rspack.cjs +15982 -0
- package/dist/rspack.d.cts +122 -0
- package/dist/rspack.d.ts +122 -0
- package/dist/{chunk-SIQF4YLC.js → rspack.js} +769 -149
- package/dist/runtime.cjs +7 -7
- package/dist/runtime.d.cts +4 -4
- package/dist/runtime.d.ts +4 -4
- package/dist/runtime.js +10 -54
- package/dist/vite.cjs +774 -170
- package/dist/vite.d.cts +10 -1
- package/dist/vite.d.ts +10 -1
- package/dist/vite.js +15968 -12
- package/dist/webpack.cjs +760 -159
- package/dist/webpack.d.cts +60 -4
- package/dist/webpack.d.ts +60 -4
- package/dist/webpack.js +15966 -14
- package/package.json +25 -2
- package/src/client.d.ts +8 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { RspackPluginInstance, Compiler } from '@rspack/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @lark.js/mvc Rspack Integration for Template Compilation
|
|
5
|
+
*
|
|
6
|
+
* Provides two integration modes:
|
|
7
|
+
*
|
|
8
|
+
* 1. **Loader** (larkMvcLoader) — Direct file transformation
|
|
9
|
+
* - Transforms .html files into JS function modules
|
|
10
|
+
* - Requires manual rspack.config.ts setup
|
|
11
|
+
*
|
|
12
|
+
* 2. **Plugin** (LarkMvcPlugin) — Auto-registers the loader
|
|
13
|
+
* - Automatically configures the loader rule for .html files
|
|
14
|
+
* - Zero-config: just add the plugin to your rspack config
|
|
15
|
+
* - Recommended approach for most use cases
|
|
16
|
+
*
|
|
17
|
+
* Features:
|
|
18
|
+
* - All template operators: = (escape), ! (raw), @ (ref lookup), : (binding)
|
|
19
|
+
* - @event attribute processing with $g prefix
|
|
20
|
+
* - $encUri (URI encoding), $encQuote (quote encoding), $refFn (reference lookup)
|
|
21
|
+
* - Debug mode with line tracking
|
|
22
|
+
* - View ID injection
|
|
23
|
+
* - Auto variable extraction via AST analysis (Babel or SWC)
|
|
24
|
+
* - Virtual DOM support (optional)
|
|
25
|
+
*
|
|
26
|
+
* Usage with Plugin (recommended):
|
|
27
|
+
* ```js
|
|
28
|
+
* import { LarkMvcPlugin } from '@lark.js/mvc/rspack';
|
|
29
|
+
*
|
|
30
|
+
* export default {
|
|
31
|
+
* plugins: [
|
|
32
|
+
* new LarkMvcPlugin({
|
|
33
|
+
* debug: process.env.NODE_ENV !== 'production',
|
|
34
|
+
* virtualDom: false,
|
|
35
|
+
* useSwc: false,
|
|
36
|
+
* }),
|
|
37
|
+
* ],
|
|
38
|
+
* };
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Usage with Loader (manual):
|
|
42
|
+
* ```js
|
|
43
|
+
* export default {
|
|
44
|
+
* module: {
|
|
45
|
+
* rules: [{
|
|
46
|
+
* test: /\.html$/,
|
|
47
|
+
* loader: '@lark.js/mvc/rspack',
|
|
48
|
+
* options: { debug: false, virtualDom: false, useSwc: false },
|
|
49
|
+
* }],
|
|
50
|
+
* },
|
|
51
|
+
* };
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/** Rspack loader context */
|
|
56
|
+
interface LoaderContext {
|
|
57
|
+
/** Whether in development mode */
|
|
58
|
+
dev?: boolean;
|
|
59
|
+
/** Loader options */
|
|
60
|
+
getOptions: () => {
|
|
61
|
+
debug?: boolean;
|
|
62
|
+
virtualDom?: boolean;
|
|
63
|
+
useSwc?: boolean;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** Plugin options */
|
|
67
|
+
interface LarkMvcPluginOptions {
|
|
68
|
+
/** Enable debug mode with line tracking (default: false) */
|
|
69
|
+
debug?: boolean;
|
|
70
|
+
/** Enable virtual DOM output (default: false) */
|
|
71
|
+
virtualDom?: boolean;
|
|
72
|
+
/** Use SWC instead of Babel for AST analysis (default: false) */
|
|
73
|
+
useSwc?: boolean;
|
|
74
|
+
/** File extension to match (default: /\.html$/) */
|
|
75
|
+
test?: RegExp;
|
|
76
|
+
/** Exclude pattern (default: /node_modules/) */
|
|
77
|
+
exclude?: RegExp;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Rspack loader entry point.
|
|
81
|
+
* Compiles .html template files into JS function modules.
|
|
82
|
+
*
|
|
83
|
+
* Unlike the webpack version, rspack async loaders must return the result
|
|
84
|
+
* directly rather than calling `this.callback()`. Calling callback() inside
|
|
85
|
+
* an async function causes "callback already called" errors because the
|
|
86
|
+
* resolved promise also signals completion.
|
|
87
|
+
*/
|
|
88
|
+
declare function larkMvcLoader(this: LoaderContext, source: string): Promise<string>;
|
|
89
|
+
/**
|
|
90
|
+
* Rspack plugin that auto-registers the lark-mvc loader.
|
|
91
|
+
*
|
|
92
|
+
* This is the recommended integration approach. The plugin:
|
|
93
|
+
* 1. Automatically adds a loader rule for .html files
|
|
94
|
+
* 2. Passes through all configuration options
|
|
95
|
+
* 3. Handles edge cases (e.g., excluding node_modules)
|
|
96
|
+
*
|
|
97
|
+
* Usage:
|
|
98
|
+
* ```js
|
|
99
|
+
* import { LarkMvcPlugin } from '@lark.js/mvc/rspack';
|
|
100
|
+
*
|
|
101
|
+
* export default {
|
|
102
|
+
* plugins: [
|
|
103
|
+
* new LarkMvcPlugin({
|
|
104
|
+
* debug: true,
|
|
105
|
+
* virtualDom: false,
|
|
106
|
+
* useSwc: false,
|
|
107
|
+
* }),
|
|
108
|
+
* ],
|
|
109
|
+
* };
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
declare class LarkMvcPlugin implements RspackPluginInstance {
|
|
113
|
+
private options;
|
|
114
|
+
constructor(options?: LarkMvcPluginOptions);
|
|
115
|
+
/**
|
|
116
|
+
* Rspack plugin entry point.
|
|
117
|
+
* Called by rspack when the plugin is applied.
|
|
118
|
+
*/
|
|
119
|
+
apply(compiler: Compiler): void;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { LarkMvcPlugin, larkMvcLoader as default, larkMvcLoader };
|
package/dist/rspack.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { RspackPluginInstance, Compiler } from '@rspack/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @lark.js/mvc Rspack Integration for Template Compilation
|
|
5
|
+
*
|
|
6
|
+
* Provides two integration modes:
|
|
7
|
+
*
|
|
8
|
+
* 1. **Loader** (larkMvcLoader) — Direct file transformation
|
|
9
|
+
* - Transforms .html files into JS function modules
|
|
10
|
+
* - Requires manual rspack.config.ts setup
|
|
11
|
+
*
|
|
12
|
+
* 2. **Plugin** (LarkMvcPlugin) — Auto-registers the loader
|
|
13
|
+
* - Automatically configures the loader rule for .html files
|
|
14
|
+
* - Zero-config: just add the plugin to your rspack config
|
|
15
|
+
* - Recommended approach for most use cases
|
|
16
|
+
*
|
|
17
|
+
* Features:
|
|
18
|
+
* - All template operators: = (escape), ! (raw), @ (ref lookup), : (binding)
|
|
19
|
+
* - @event attribute processing with $g prefix
|
|
20
|
+
* - $encUri (URI encoding), $encQuote (quote encoding), $refFn (reference lookup)
|
|
21
|
+
* - Debug mode with line tracking
|
|
22
|
+
* - View ID injection
|
|
23
|
+
* - Auto variable extraction via AST analysis (Babel or SWC)
|
|
24
|
+
* - Virtual DOM support (optional)
|
|
25
|
+
*
|
|
26
|
+
* Usage with Plugin (recommended):
|
|
27
|
+
* ```js
|
|
28
|
+
* import { LarkMvcPlugin } from '@lark.js/mvc/rspack';
|
|
29
|
+
*
|
|
30
|
+
* export default {
|
|
31
|
+
* plugins: [
|
|
32
|
+
* new LarkMvcPlugin({
|
|
33
|
+
* debug: process.env.NODE_ENV !== 'production',
|
|
34
|
+
* virtualDom: false,
|
|
35
|
+
* useSwc: false,
|
|
36
|
+
* }),
|
|
37
|
+
* ],
|
|
38
|
+
* };
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Usage with Loader (manual):
|
|
42
|
+
* ```js
|
|
43
|
+
* export default {
|
|
44
|
+
* module: {
|
|
45
|
+
* rules: [{
|
|
46
|
+
* test: /\.html$/,
|
|
47
|
+
* loader: '@lark.js/mvc/rspack',
|
|
48
|
+
* options: { debug: false, virtualDom: false, useSwc: false },
|
|
49
|
+
* }],
|
|
50
|
+
* },
|
|
51
|
+
* };
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/** Rspack loader context */
|
|
56
|
+
interface LoaderContext {
|
|
57
|
+
/** Whether in development mode */
|
|
58
|
+
dev?: boolean;
|
|
59
|
+
/** Loader options */
|
|
60
|
+
getOptions: () => {
|
|
61
|
+
debug?: boolean;
|
|
62
|
+
virtualDom?: boolean;
|
|
63
|
+
useSwc?: boolean;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** Plugin options */
|
|
67
|
+
interface LarkMvcPluginOptions {
|
|
68
|
+
/** Enable debug mode with line tracking (default: false) */
|
|
69
|
+
debug?: boolean;
|
|
70
|
+
/** Enable virtual DOM output (default: false) */
|
|
71
|
+
virtualDom?: boolean;
|
|
72
|
+
/** Use SWC instead of Babel for AST analysis (default: false) */
|
|
73
|
+
useSwc?: boolean;
|
|
74
|
+
/** File extension to match (default: /\.html$/) */
|
|
75
|
+
test?: RegExp;
|
|
76
|
+
/** Exclude pattern (default: /node_modules/) */
|
|
77
|
+
exclude?: RegExp;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Rspack loader entry point.
|
|
81
|
+
* Compiles .html template files into JS function modules.
|
|
82
|
+
*
|
|
83
|
+
* Unlike the webpack version, rspack async loaders must return the result
|
|
84
|
+
* directly rather than calling `this.callback()`. Calling callback() inside
|
|
85
|
+
* an async function causes "callback already called" errors because the
|
|
86
|
+
* resolved promise also signals completion.
|
|
87
|
+
*/
|
|
88
|
+
declare function larkMvcLoader(this: LoaderContext, source: string): Promise<string>;
|
|
89
|
+
/**
|
|
90
|
+
* Rspack plugin that auto-registers the lark-mvc loader.
|
|
91
|
+
*
|
|
92
|
+
* This is the recommended integration approach. The plugin:
|
|
93
|
+
* 1. Automatically adds a loader rule for .html files
|
|
94
|
+
* 2. Passes through all configuration options
|
|
95
|
+
* 3. Handles edge cases (e.g., excluding node_modules)
|
|
96
|
+
*
|
|
97
|
+
* Usage:
|
|
98
|
+
* ```js
|
|
99
|
+
* import { LarkMvcPlugin } from '@lark.js/mvc/rspack';
|
|
100
|
+
*
|
|
101
|
+
* export default {
|
|
102
|
+
* plugins: [
|
|
103
|
+
* new LarkMvcPlugin({
|
|
104
|
+
* debug: true,
|
|
105
|
+
* virtualDom: false,
|
|
106
|
+
* useSwc: false,
|
|
107
|
+
* }),
|
|
108
|
+
* ],
|
|
109
|
+
* };
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
declare class LarkMvcPlugin implements RspackPluginInstance {
|
|
113
|
+
private options;
|
|
114
|
+
constructor(options?: LarkMvcPluginOptions);
|
|
115
|
+
/**
|
|
116
|
+
* Rspack plugin entry point.
|
|
117
|
+
* Called by rspack when the plugin is applied.
|
|
118
|
+
*/
|
|
119
|
+
apply(compiler: Compiler): void;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { LarkMvcPlugin, larkMvcLoader as default, larkMvcLoader };
|