@vesk/compiler 0.2.39 → 0.2.40

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 +1 @@
1
- {"version":3,"file":"ir-generator.d.ts","sourceRoot":"","sources":["../src/ir-generator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAsBP,MAAM,uBAAuB,CAAC;AAmT/B,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,GAAG,CAAC;IAAC,cAAc,CAAC,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC,GAAG,SAAS,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkCnL;AA48BD,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CA4N9E"}
1
+ {"version":3,"file":"ir-generator.d.ts","sourceRoot":"","sources":["../src/ir-generator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAsBP,MAAM,uBAAuB,CAAC;AA2T/B,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,GAAG,CAAC;IAAC,cAAc,CAAC,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC,GAAG,SAAS,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkCnL;AA48BD,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CA6N9E"}
@@ -15,6 +15,13 @@ let __vskAnnotations = [];
15
15
  * slot handed to it by a caller that wrote `name={<div/>}`.
16
16
  */
17
17
  let __slotProps = null;
18
+ /**
19
+ * The identifier a component binds its props to (`props` by convention, but
20
+ * any first-parameter name is legal). Slot detection used to hardcode the
21
+ * literal `props`, so a `Component`-typed prop read through a differently
22
+ * named parameter was treated as a plain value and stringified.
23
+ */
24
+ let __propsParam = null;
18
25
  function parseExprNode(text) {
19
26
  try {
20
27
  const ParserClass = createBaseParser();
@@ -463,7 +470,7 @@ function containsJSX(node) {
463
470
  */
464
471
  function slotReadPropName(expr) {
465
472
  if (expr.type === 'MemberExpression' && !expr.computed &&
466
- expr.object.type === 'Identifier' && expr.object.name === 'props' &&
473
+ expr.object.type === 'Identifier' && expr.object.name === (__propsParam || 'props') &&
467
474
  expr.property.type === 'Identifier') {
468
475
  return expr.property.name;
469
476
  }
@@ -719,7 +726,7 @@ function processJSXChildren(source, children) {
719
726
  continue;
720
727
  }
721
728
  if ((expr.type === 'MemberExpression' && !expr.computed &&
722
- expr.object.type === 'Identifier' && expr.object.name === 'props' &&
729
+ expr.object.type === 'Identifier' && expr.object.name === (__propsParam || 'props') &&
723
730
  expr.property.type === 'Identifier' && expr.property.name === 'children')
724
731
  || (expr.type === 'Identifier' && expr.name === 'children')) {
725
732
  result.push(new SlotNode());
@@ -818,7 +825,7 @@ function exprToIR(source, expr) {
818
825
  // insert the slot nodes — not degrade to a text binding that stringifies
819
826
  // the fragment (`String(props.children)` → "[object DocumentFragment]").
820
827
  if ((expr.type === 'MemberExpression' && !expr.computed &&
821
- expr.object.type === 'Identifier' && expr.object.name === 'props' &&
828
+ expr.object.type === 'Identifier' && expr.object.name === (__propsParam || 'props') &&
822
829
  expr.property.type === 'Identifier' && expr.property.name === 'children')
823
830
  || (expr.type === 'Identifier' && expr.name === 'children')) {
824
831
  return [new SlotNode()];
@@ -1500,6 +1507,7 @@ export function generateIR(ast, source, filename) {
1500
1507
  // value bindings for THIS component only.
1501
1508
  const prevSlotProps = __slotProps;
1502
1509
  __slotProps = slotPropNamesFromType(propsType);
1510
+ __propsParam = propsAlias || null;
1503
1511
  if (isStatementMode(bodyStmts)) {
1504
1512
  const raw = processStatementModeBody(source, bodyStmts, file);
1505
1513
  const { body, css } = extractStyle(raw);
@@ -1553,7 +1561,7 @@ export function generateIR(ast, source, filename) {
1553
1561
  const guardBody = buildGuardChain(source, guardClauses, mainReturn);
1554
1562
  const { body, css } = extractStyle([...preamble, ...guardBody]);
1555
1563
  validateBlocks(name, isClientComp, body, file, source);
1556
- const comp = new ComponentIR(name, paramNames, body, { exported, defaultExport, isClient: inner.client, isAsync: inner.async, ssrAwait: componentUsesFetch(body), propsType });
1564
+ const comp = new ComponentIR(name, paramNames, body, { exported, defaultExport, isClient: inner.client, isAsync: inner.async, ssrAwait: componentUsesFetch(body), propsType, propsAlias });
1557
1565
  comp.style = css;
1558
1566
  components.push(comp);
1559
1567
  __slotProps = prevSlotProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vesk/compiler",
3
- "version": "0.2.39",
3
+ "version": "0.2.40",
4
4
  "type": "module",
5
5
  "description": "Vesk compiler — lexer, parser, semantic analysis, IR, codegen",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@sveltejs/acorn-typescript": "^1.0.0",
23
- "@vesk/types": "^0.2.39",
23
+ "@vesk/types": "^0.2.40",
24
24
  "acorn": "^8.15.0",
25
25
  "esrap": "^2.3.0",
26
26
  "is-reference": "^3.0.0",