@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.
@@ -1,18 +1,74 @@
1
1
  /** Webpack loader context */
2
2
  interface LoaderContext {
3
- /** Callback to return the result */
4
- callback: (error: Error | null, result?: string) => void;
5
3
  /** Whether in development mode */
6
4
  dev?: boolean;
7
5
  /** Loader options */
8
6
  getOptions: () => {
9
7
  debug?: boolean;
8
+ virtualDom?: boolean;
9
+ useSwc?: boolean;
10
10
  };
11
11
  }
12
+ /** Plugin options */
13
+ interface LarkMvcPluginOptions {
14
+ /** Enable debug mode with line tracking (default: false) */
15
+ debug?: boolean;
16
+ /** Enable virtual DOM output (default: false) */
17
+ virtualDom?: boolean;
18
+ /** Use SWC instead of Babel for AST analysis (default: false) */
19
+ useSwc?: boolean;
20
+ /** File extension to match (default: /\.html$/) */
21
+ test?: RegExp;
22
+ /** Exclude pattern (default: /node_modules/) */
23
+ exclude?: RegExp;
24
+ }
12
25
  /**
13
26
  * Webpack loader entry point.
14
27
  * Compiles .html template files into JS function modules.
28
+ *
29
+ * Uses this.callback() for async result delivery — this is the standard
30
+ * webpack pattern for async loaders. Unlike rspack, webpack 5 does not
31
+ * reliably support returning a Promise from the loader function; the
32
+ * callback approach works across all webpack 5.x versions.
33
+ */
34
+ declare function larkMvcLoader(this: LoaderContext, source: string): Promise<string>;
35
+ /**
36
+ * Webpack plugin that auto-registers the lark-mvc loader.
37
+ *
38
+ * This is the recommended integration approach. The plugin:
39
+ * 1. Automatically adds a loader rule for .html files
40
+ * 2. Passes through all configuration options
41
+ * 3. Handles edge cases (e.g., excluding node_modules)
42
+ *
43
+ * Usage:
44
+ * ```js
45
+ * import { LarkMvcPlugin } from '@lark.js/mvc/webpack';
46
+ *
47
+ * export default {
48
+ * plugins: [
49
+ * new LarkMvcPlugin({
50
+ * debug: true,
51
+ * virtualDom: false,
52
+ * useSwc: false,
53
+ * }),
54
+ * ],
55
+ * };
56
+ * ```
15
57
  */
16
- declare function larkMvcLoader(this: LoaderContext, source: string): void;
58
+ declare class LarkMvcPlugin {
59
+ private options;
60
+ constructor(options?: LarkMvcPluginOptions);
61
+ /**
62
+ * Webpack plugin entry point.
63
+ * Called by webpack when the plugin is applied.
64
+ */
65
+ apply(compiler: {
66
+ options: {
67
+ module: {
68
+ rules: unknown[];
69
+ };
70
+ };
71
+ }): void;
72
+ }
17
73
 
18
- export { larkMvcLoader as default, larkMvcLoader };
74
+ export { LarkMvcPlugin, larkMvcLoader as default, larkMvcLoader };
package/dist/webpack.d.ts CHANGED
@@ -1,18 +1,74 @@
1
1
  /** Webpack loader context */
2
2
  interface LoaderContext {
3
- /** Callback to return the result */
4
- callback: (error: Error | null, result?: string) => void;
5
3
  /** Whether in development mode */
6
4
  dev?: boolean;
7
5
  /** Loader options */
8
6
  getOptions: () => {
9
7
  debug?: boolean;
8
+ virtualDom?: boolean;
9
+ useSwc?: boolean;
10
10
  };
11
11
  }
12
+ /** Plugin options */
13
+ interface LarkMvcPluginOptions {
14
+ /** Enable debug mode with line tracking (default: false) */
15
+ debug?: boolean;
16
+ /** Enable virtual DOM output (default: false) */
17
+ virtualDom?: boolean;
18
+ /** Use SWC instead of Babel for AST analysis (default: false) */
19
+ useSwc?: boolean;
20
+ /** File extension to match (default: /\.html$/) */
21
+ test?: RegExp;
22
+ /** Exclude pattern (default: /node_modules/) */
23
+ exclude?: RegExp;
24
+ }
12
25
  /**
13
26
  * Webpack loader entry point.
14
27
  * Compiles .html template files into JS function modules.
28
+ *
29
+ * Uses this.callback() for async result delivery — this is the standard
30
+ * webpack pattern for async loaders. Unlike rspack, webpack 5 does not
31
+ * reliably support returning a Promise from the loader function; the
32
+ * callback approach works across all webpack 5.x versions.
33
+ */
34
+ declare function larkMvcLoader(this: LoaderContext, source: string): Promise<string>;
35
+ /**
36
+ * Webpack plugin that auto-registers the lark-mvc loader.
37
+ *
38
+ * This is the recommended integration approach. The plugin:
39
+ * 1. Automatically adds a loader rule for .html files
40
+ * 2. Passes through all configuration options
41
+ * 3. Handles edge cases (e.g., excluding node_modules)
42
+ *
43
+ * Usage:
44
+ * ```js
45
+ * import { LarkMvcPlugin } from '@lark.js/mvc/webpack';
46
+ *
47
+ * export default {
48
+ * plugins: [
49
+ * new LarkMvcPlugin({
50
+ * debug: true,
51
+ * virtualDom: false,
52
+ * useSwc: false,
53
+ * }),
54
+ * ],
55
+ * };
56
+ * ```
15
57
  */
16
- declare function larkMvcLoader(this: LoaderContext, source: string): void;
58
+ declare class LarkMvcPlugin {
59
+ private options;
60
+ constructor(options?: LarkMvcPluginOptions);
61
+ /**
62
+ * Webpack plugin entry point.
63
+ * Called by webpack when the plugin is applied.
64
+ */
65
+ apply(compiler: {
66
+ options: {
67
+ module: {
68
+ rules: unknown[];
69
+ };
70
+ };
71
+ }): void;
72
+ }
17
73
 
18
- export { larkMvcLoader as default, larkMvcLoader };
74
+ export { LarkMvcPlugin, larkMvcLoader as default, larkMvcLoader };