@lark.js/mvc 0.0.1

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,38 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ /**
4
+ * @lark/framework Vite Plugin for Template Compilation
5
+ *
6
+ * Compiles .html template files using @lark/framework template syntax
7
+ * into JS function modules at build/dev time.
8
+ *
9
+ * 0 configuration — just add the plugin and it works.
10
+ * - All template operators: = (escape), ! (raw), @ (ref lookup), : (binding)
11
+ * - lark-event attribute processing with $g prefix
12
+ * - $eu (URI encoding), $eq (quote encoding), $i (reference lookup)
13
+ * - Debug mode with line tracking
14
+ * - View ID injection
15
+ * - Auto variable extraction
16
+ *
17
+ * Usage in vite.config.ts:
18
+ * ```ts
19
+ * import { larkTmplPlugin } from '@lark/framework/vite-plugin';
20
+ *
21
+ * export default defineConfig({
22
+ * plugins: [larkTmplPlugin()],
23
+ * });
24
+ * ```
25
+ */
26
+
27
+ /**
28
+ * Create a Vite plugin that compiles .html template files.
29
+ *
30
+ * @param options - Plugin options
31
+ * @param options.debug - Enable debug mode with line tracking (default: false)
32
+ * @returns Vite plugin instance
33
+ */
34
+ declare function larkTmplPlugin(options?: {
35
+ debug?: boolean;
36
+ }): Plugin;
37
+
38
+ export { larkTmplPlugin as default, larkTmplPlugin };
package/dist/vite.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ /**
4
+ * @lark/framework Vite Plugin for Template Compilation
5
+ *
6
+ * Compiles .html template files using @lark/framework template syntax
7
+ * into JS function modules at build/dev time.
8
+ *
9
+ * 0 configuration — just add the plugin and it works.
10
+ * - All template operators: = (escape), ! (raw), @ (ref lookup), : (binding)
11
+ * - lark-event attribute processing with $g prefix
12
+ * - $eu (URI encoding), $eq (quote encoding), $i (reference lookup)
13
+ * - Debug mode with line tracking
14
+ * - View ID injection
15
+ * - Auto variable extraction
16
+ *
17
+ * Usage in vite.config.ts:
18
+ * ```ts
19
+ * import { larkTmplPlugin } from '@lark/framework/vite-plugin';
20
+ *
21
+ * export default defineConfig({
22
+ * plugins: [larkTmplPlugin()],
23
+ * });
24
+ * ```
25
+ */
26
+
27
+ /**
28
+ * Create a Vite plugin that compiles .html template files.
29
+ *
30
+ * @param options - Plugin options
31
+ * @param options.debug - Enable debug mode with line tracking (default: false)
32
+ * @returns Vite plugin instance
33
+ */
34
+ declare function larkTmplPlugin(options?: {
35
+ debug?: boolean;
36
+ }): Plugin;
37
+
38
+ export { larkTmplPlugin as default, larkTmplPlugin };
package/dist/vite.js ADDED
@@ -0,0 +1,36 @@
1
+ import {
2
+ compileTemplate,
3
+ extractGlobalVars
4
+ } from "./chunk-DZUOIUWX.js";
5
+
6
+ // src/vite.ts
7
+ import path from "path";
8
+ import fs from "fs";
9
+ var LARK_TMPL_SUFFIX = "?lark-tmpl";
10
+ function larkTmplPlugin(options = {}) {
11
+ const { debug = false } = options;
12
+ return {
13
+ name: "lark-tmpl",
14
+ enforce: "pre",
15
+ resolveId(source, importer) {
16
+ if (source.endsWith(".html") && importer) {
17
+ return path.resolve(path.dirname(importer), source) + LARK_TMPL_SUFFIX;
18
+ }
19
+ return void 0;
20
+ },
21
+ load(id) {
22
+ if (id.endsWith(LARK_TMPL_SUFFIX)) {
23
+ const filePath = id.slice(0, -LARK_TMPL_SUFFIX.length);
24
+ const raw = fs.readFileSync(filePath, "utf-8");
25
+ const globalVars = extractGlobalVars(raw);
26
+ return compileTemplate(raw, { debug, globalVars });
27
+ }
28
+ return void 0;
29
+ }
30
+ };
31
+ }
32
+ var vite_default = larkTmplPlugin;
33
+ export {
34
+ vite_default as default,
35
+ larkTmplPlugin
36
+ };