@lark.js/mvc 0.0.9 → 0.0.11

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.
@@ -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 };
@@ -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 };