@mulanjs/mulanjs 1.0.1-dev.20260220134357 → 1.0.1-dev.20260220155535

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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compileSFC = compileSFC;
3
+ exports.compileSFC = void 0;
4
4
  const sfc_parser_1 = require("./sfc-parser");
5
5
  const script_compiler_1 = require("./script-compiler");
6
6
  const template_compiler_1 = require("./template-compiler");
@@ -37,8 +37,8 @@ async function compileSFC(source, filename, options) {
37
37
  });
38
38
  // 1. Apply Script Map
39
39
  if (scriptResult.map) {
40
- const scriptConsumer = await new source_map_1.SourceMapConsumer(JSON.parse(scriptResult.map));
41
- scriptConsumer.eachMapping(mapping => {
40
+ const scriptConsumer = new source_map_1.SourceMapConsumer(JSON.parse(scriptResult.map));
41
+ scriptConsumer.eachMapping((mapping) => {
42
42
  if (mapping.source) {
43
43
  generator.addMapping({
44
44
  generated: {
@@ -56,19 +56,19 @@ async function compileSFC(source, filename, options) {
56
56
  });
57
57
  // Copy source content from script map
58
58
  if (scriptConsumer.sources) {
59
- scriptConsumer.sources.forEach(sourceFile => {
59
+ scriptConsumer.sources.forEach((sourceFile) => {
60
60
  const content = scriptConsumer.sourceContentFor(sourceFile);
61
61
  if (content) {
62
62
  generator.setSourceContent(sourceFile, content);
63
63
  }
64
64
  });
65
65
  }
66
- scriptConsumer.destroy();
66
+ // scriptConsumer.destroy() not needed in 0.6.x
67
67
  }
68
68
  // 2. Apply Template Map
69
69
  if (templateResult.map) {
70
- const templateConsumer = await new source_map_1.SourceMapConsumer(JSON.parse(templateResult.map));
71
- templateConsumer.eachMapping(mapping => {
70
+ const templateConsumer = new source_map_1.SourceMapConsumer(JSON.parse(templateResult.map));
71
+ templateConsumer.eachMapping((mapping) => {
72
72
  if (mapping.source) {
73
73
  generator.addMapping({
74
74
  generated: {
@@ -86,14 +86,14 @@ async function compileSFC(source, filename, options) {
86
86
  });
87
87
  // Copy source content from template map
88
88
  if (templateConsumer.sources) {
89
- templateConsumer.sources.forEach(sourceFile => {
89
+ templateConsumer.sources.forEach((sourceFile) => {
90
90
  const content = templateConsumer.sourceContentFor(sourceFile);
91
91
  if (content) {
92
92
  generator.setSourceContent(sourceFile, content);
93
93
  }
94
94
  });
95
95
  }
96
- templateConsumer.destroy();
96
+ // templateConsumer.destroy() not needed in 0.6.x
97
97
  }
98
98
  mergedMap = generator.toString();
99
99
  }
@@ -166,3 +166,4 @@ export default __component__;
166
166
  map: mergedMap || scriptResult.map // Fallback to script map if merge fails
167
167
  };
168
168
  }
169
+ exports.compileSFC = compileSFC;
@@ -15,25 +15,15 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
35
25
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.compileScript = compileScript;
26
+ exports.compileScript = void 0;
37
27
  const ts = __importStar(require("typescript"));
38
28
  const source_map_1 = require("source-map");
39
29
  const path = __importStar(require("path"));
@@ -78,6 +68,7 @@ async function compileScript(descriptor, options) {
78
68
  return { code: content, errors: [] };
79
69
  }
80
70
  }
71
+ exports.compileScript = compileScript;
81
72
  // Global list of Mulan hooks for auto-imports and reactivity exemption
82
73
  const COMMON_HOOKS = ['muState', 'onMuMount', 'onMuInit', 'onMuDestroy', 'muEffect', 'muMemo', 'muQubit', 'muGate', 'muMeasure', 'muRegister', 'muEntangle', 'persistent'];
83
74
  async function compileSetupScript(script, isTs, descriptor, content, filename, isExternal, externalPath) {
@@ -214,7 +205,7 @@ export default ${hasDefineComponent ? 'defineComponent' : '_defineComponent'}({
214
205
  originalSource = descriptor.source;
215
206
  linesBeforeScript = originalSource.substring(0, script.start).split('\n').length - 1;
216
207
  }
217
- const consumer = await new source_map_1.SourceMapConsumer(finalMap);
208
+ const consumer = new source_map_1.SourceMapConsumer(JSON.parse(finalMap));
218
209
  const generator = new source_map_1.SourceMapGenerator({
219
210
  file: filename,
220
211
  sourceRoot: ''
@@ -246,7 +237,7 @@ export default ${hasDefineComponent ? 'defineComponent' : '_defineComponent'}({
246
237
  // If inline, we set source content of .mujs (the whole file)
247
238
  // If external, we set source content of the .ts file
248
239
  generator.setSourceContent(relativePath, originalSource);
249
- consumer.eachMapping(m => {
240
+ consumer.eachMapping((m) => {
250
241
  if (m.originalLine === null)
251
242
  return;
252
243
  // m.originalLine is the line in `finalCode` (1-based because SourceMapConsumer uses 1-based)
@@ -278,7 +269,7 @@ export default ${hasDefineComponent ? 'defineComponent' : '_defineComponent'}({
278
269
  }
279
270
  });
280
271
  finalMap = generator.toString();
281
- consumer.destroy();
272
+ // consumer.destroy() not needed in 0.6.x
282
273
  }
283
274
  catch (e) {
284
275
  console.warn('[MulanJS] Failed to patch source map:', e);
@@ -328,7 +319,7 @@ async function compileStandardScript(script, descriptor, content, filename, isEx
328
319
  originalSource = descriptor.source;
329
320
  linesBeforeScript = descriptor.source.substring(0, script.start).split('\n').length - 1;
330
321
  }
331
- const consumer = await new source_map_1.SourceMapConsumer(finalMap);
322
+ const consumer = new source_map_1.SourceMapConsumer(JSON.parse(finalMap));
332
323
  const generator = new source_map_1.SourceMapGenerator({
333
324
  file: filename,
334
325
  sourceRoot: ''
@@ -353,7 +344,7 @@ async function compileStandardScript(script, descriptor, content, filename, isEx
353
344
  }
354
345
  }
355
346
  generator.setSourceContent(relativePath, originalSource);
356
- consumer.eachMapping(m => {
347
+ consumer.eachMapping((m) => {
357
348
  if (m.originalLine === null)
358
349
  return;
359
350
  const originalLine = m.originalLine + linesBeforeScript;
@@ -371,7 +362,7 @@ async function compileStandardScript(script, descriptor, content, filename, isEx
371
362
  });
372
363
  });
373
364
  finalMap = generator.toString();
374
- consumer.destroy();
365
+ // consumer.destroy() removed for v0.6.1
375
366
  }
376
367
  catch (e) { /* ignore */ }
377
368
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseMUJS = parseMUJS;
3
+ exports.parseMUJS = void 0;
4
4
  /**
5
5
  * Standardized State-Machine Parser for MulanJS
6
6
  * Parses .mujs files safely, handling attributes, quotes, and nested content.
@@ -91,3 +91,4 @@ function parseMUJS(source, filename) {
91
91
  }
92
92
  return descriptor;
93
93
  }
94
+ exports.parseMUJS = parseMUJS;
@@ -15,25 +15,15 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
35
25
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.compileStyle = compileStyle;
26
+ exports.compileStyle = void 0;
37
27
  const path = __importStar(require("path"));
38
28
  function compileStyle(descriptor, filename, options) {
39
29
  const styles = descriptor.styles;
@@ -101,6 +91,7 @@ function compileStyle(descriptor, filename, options) {
101
91
  errors: []
102
92
  };
103
93
  }
94
+ exports.compileStyle = compileStyle;
104
95
  // Simple hash for ID generation
105
96
  function hash(str) {
106
97
  let hash = 0;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compileTemplate = compileTemplate;
3
+ exports.compileTemplate = void 0;
4
4
  // --- Compile Function ---
5
5
  const source_map_1 = require("source-map");
6
6
  function compileTemplate(descriptor, scriptResult, scopedId) {
@@ -71,6 +71,7 @@ function compileTemplate(descriptor, scriptResult, scopedId) {
71
71
  map
72
72
  };
73
73
  }
74
+ exports.compileTemplate = compileTemplate;
74
75
  // --- Parser (Recursive Descent) ---
75
76
  function parse(template, errors) {
76
77
  // Root Wrapper
@@ -62,6 +62,12 @@ export class MuComponent {
62
62
  this._eventQueue.push([id, type, handler]);
63
63
  return "";
64
64
  }
65
+ // Manual binding helper for template literals
66
+ bind(handler, type = 'click') {
67
+ const id = 'ev_' + Math.random().toString(36).substr(2, 9);
68
+ this._e(id, type, handler);
69
+ return `data-mu-id="${id}"`;
70
+ }
65
71
  mount() {
66
72
  console.log(`[Mulan Cycle] Mounting component ${this.$uid}`);
67
73
  const stop = effect(() => {
package/dist/mulan.esm.js CHANGED
@@ -667,6 +667,12 @@ class MuComponent {
667
667
  this._eventQueue.push([id, type, handler]);
668
668
  return "";
669
669
  }
670
+ // Manual binding helper for template literals
671
+ bind(handler, type = 'click') {
672
+ const id = 'ev_' + Math.random().toString(36).substr(2, 9);
673
+ this._e(id, type, handler);
674
+ return `data-mu-id="${id}"`;
675
+ }
670
676
  mount() {
671
677
  console.log(`[Mulan Cycle] Mounting component ${this.$uid}`);
672
678
  const stop = effect(() => {