sinwan-compiler 0.2.3 → 0.2.4

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.
package/dist/index.js CHANGED
@@ -183,7 +183,18 @@ function elementToHtml(node, slots, path, filename, counter) {
183
183
  if (attrName === "children")
184
184
  continue;
185
185
  if (attrName === "ref") {
186
- throw new Error("Cannot hoist element with ref");
186
+ if (attr.value?.type === "JSXExpressionContainer") {
187
+ const expr = attr.value.expression;
188
+ if (expr.type !== "JSXEmptyExpression") {
189
+ slots.push({
190
+ path: [...path],
191
+ type: "ref",
192
+ name: "ref",
193
+ expr
194
+ });
195
+ }
196
+ }
197
+ continue;
187
198
  }
188
199
  if (attr.value?.type === "JSXExpressionContainer") {
189
200
  const expr = attr.value.expression;
@@ -35,9 +35,9 @@ export interface TransformOptions {
35
35
  * in sync.
36
36
  */
37
37
  export declare const COMPILER_TEMPLATE_SLOT_PROTOCOL: {
38
- readonly slotPrefix: "s";
39
- readonly encodeSlot: (index: number) => string;
40
- readonly decodeSlot: (data: string) => number | null;
38
+ slotPrefix: string;
39
+ encodeSlot(index: number): string;
40
+ decodeSlot(data: string): number | null;
41
41
  };
42
42
  export declare function transformJSX(code: string, filename: string, options?: TransformOptions): {
43
43
  code: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinwan-compiler",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Shared compiler core for Sinwan plugins",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",