@zessjs/compiler 1.0.7 → 1.1.0

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/compiler.cjs CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  //#region rolldown:runtime
3
2
  var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
@@ -22,11 +21,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
21
  }) : target, mod));
23
22
 
24
23
  //#endregion
25
- const astring = __toESM(require("astring"));
26
- const entities = __toESM(require("entities"));
27
- const merge_source_map = __toESM(require("merge-source-map"));
28
- const meriyah = __toESM(require("meriyah"));
29
- const source_map = __toESM(require("source-map"));
24
+ let astring = require("astring");
25
+ astring = __toESM(astring);
26
+ let entities = require("entities");
27
+ entities = __toESM(entities);
28
+ let merge_source_map = require("merge-source-map");
29
+ merge_source_map = __toESM(merge_source_map);
30
+ let meriyah = require("meriyah");
31
+ meriyah = __toESM(meriyah);
32
+ let source_map = require("source-map");
33
+ source_map = __toESM(source_map);
30
34
 
31
35
  //#region src/visit.ts
32
36
  const ESTreeNodeKeys = {
@@ -464,8 +468,8 @@ function compile(code, options = {}) {
464
468
  },
465
469
  ast,
466
470
  events: [],
467
- eventsCache: new Set(),
468
- generatedFunctions: new WeakSet()
471
+ eventsCache: /* @__PURE__ */ new Set(),
472
+ generatedFunctions: /* @__PURE__ */ new WeakSet()
469
473
  };
470
474
  visit(ast, {
471
475
  JSXElement(node) {
@@ -477,8 +481,7 @@ function compile(code, options = {}) {
477
481
  if (stmts.length === 1) if (stmts[0].type === "VariableDeclaration") expression = stmts[0].declarations[0].init;
478
482
  else expression = stmts[0].expression;
479
483
  else {
480
- const stmt = stmts[0];
481
- const id = stmt.declarations[0].id;
484
+ const id = stmts[0].declarations[0].id;
482
485
  const callExpressionPosition = copyPosition(node);
483
486
  expression = createCallExpression(createArrowFunctionExpression(createBlockStatement([...stmts, createReturnStatement(id, callExpressionPosition)], callExpressionPosition), callExpressionPosition), [], callExpressionPosition);
484
487
  }
@@ -597,8 +600,7 @@ function transformFragment(children, position, isInComponent) {
597
600
  const stmts = transformElement(childNode);
598
601
  if (isInComponent) hasDynamicChildren = true;
599
602
  if (stmts.length > 1) {
600
- const stmt = stmts[0];
601
- const id = stmt.declarations[0].id;
603
+ const id = stmts[0].declarations[0].id;
602
604
  childElement = createCallExpression(createArrowFunctionExpression(createBlockStatement([...stmts, createReturnStatement(id, childPosition)], childPosition), childPosition), [], childPosition);
603
605
  } else if (stmts[0].type === "VariableDeclaration") childElement = stmts[0].declarations[0].init;
604
606
  else childElement = stmts[0].expression;
@@ -642,7 +644,7 @@ function transformThisExpression(node) {
642
644
  currentContext.hasThisInProgram = true;
643
645
  for (let i = 0; i < body.length; ++i) {
644
646
  if (body[i].type === "ImportDeclaration") continue;
645
- body.splice(i, 0, createVariableDeclaration(thisId, createThisExpression(programPosition), programPosition));
647
+ body.splice(i, 0, createVariableDeclaration(thisId, createIdentifier("globalThis", programPosition), programPosition));
646
648
  break;
647
649
  }
648
650
  } else if (!currentContext.hasThisInFunction) {
@@ -1095,8 +1097,7 @@ function transformProperties(attrs, children, position) {
1095
1097
  }
1096
1098
  function getAttributeName(node) {
1097
1099
  if (node.type === "JSXIdentifier") return node.name;
1098
- const namespace = node.namespace;
1099
- return `${namespace.name}:${node.name.name}`;
1100
+ return `${node.namespace.name}:${node.name.name}`;
1100
1101
  }
1101
1102
  function copyPosition(node) {
1102
1103
  return {
@@ -1372,4 +1373,4 @@ function isDynamicExpression(node, checkTags) {
1372
1373
  }
1373
1374
 
1374
1375
  //#endregion
1375
- exports.compile = compile
1376
+ exports.compile = compile;
@@ -1,18 +1,17 @@
1
1
  import { ESTree } from "meriyah";
2
2
  import { RawSourceMap } from "source-map";
3
3
 
4
- //#region dist/.tsdown-types-cjs/compiler.d.cts
4
+ //#region src/compiler.d.ts
5
5
  type CompilerOptions = {
6
- modulePath?: string
7
- file?: string
8
- sourceRoot?: string
9
- sourcemap?: RawSourceMap
6
+ modulePath?: string;
7
+ file?: string;
8
+ sourceRoot?: string;
9
+ sourcemap?: RawSourceMap;
10
10
  };
11
11
  type CompilerResult = {
12
- code: string
13
- map: RawSourceMap
12
+ code: string;
13
+ map: RawSourceMap;
14
14
  };
15
15
  declare function compile(code: string, options?: CompilerOptions): CompilerResult;
16
-
17
16
  //#endregion
18
- export { ESTree, RawSourceMap, compile };
17
+ export { type ESTree, type RawSourceMap, compile };
@@ -1,18 +1,17 @@
1
1
  import { ESTree } from "meriyah";
2
2
  import { RawSourceMap } from "source-map";
3
3
 
4
- //#region dist/.tsdown-types-es/compiler.d.ts
4
+ //#region src/compiler.d.ts
5
5
  type CompilerOptions = {
6
- modulePath?: string
7
- file?: string
8
- sourceRoot?: string
9
- sourcemap?: RawSourceMap
6
+ modulePath?: string;
7
+ file?: string;
8
+ sourceRoot?: string;
9
+ sourcemap?: RawSourceMap;
10
10
  };
11
11
  type CompilerResult = {
12
- code: string
13
- map: RawSourceMap
12
+ code: string;
13
+ map: RawSourceMap;
14
14
  };
15
15
  declare function compile(code: string, options?: CompilerOptions): CompilerResult;
16
-
17
16
  //#endregion
18
- export { ESTree, RawSourceMap, compile };
17
+ export { type ESTree, type RawSourceMap, compile };
package/dist/compiler.js CHANGED
@@ -440,8 +440,8 @@ function compile(code, options = {}) {
440
440
  },
441
441
  ast,
442
442
  events: [],
443
- eventsCache: new Set(),
444
- generatedFunctions: new WeakSet()
443
+ eventsCache: /* @__PURE__ */ new Set(),
444
+ generatedFunctions: /* @__PURE__ */ new WeakSet()
445
445
  };
446
446
  visit(ast, {
447
447
  JSXElement(node) {
@@ -453,8 +453,7 @@ function compile(code, options = {}) {
453
453
  if (stmts.length === 1) if (stmts[0].type === "VariableDeclaration") expression = stmts[0].declarations[0].init;
454
454
  else expression = stmts[0].expression;
455
455
  else {
456
- const stmt = stmts[0];
457
- const id = stmt.declarations[0].id;
456
+ const id = stmts[0].declarations[0].id;
458
457
  const callExpressionPosition = copyPosition(node);
459
458
  expression = createCallExpression(createArrowFunctionExpression(createBlockStatement([...stmts, createReturnStatement(id, callExpressionPosition)], callExpressionPosition), callExpressionPosition), [], callExpressionPosition);
460
459
  }
@@ -573,8 +572,7 @@ function transformFragment(children, position, isInComponent) {
573
572
  const stmts = transformElement(childNode);
574
573
  if (isInComponent) hasDynamicChildren = true;
575
574
  if (stmts.length > 1) {
576
- const stmt = stmts[0];
577
- const id = stmt.declarations[0].id;
575
+ const id = stmts[0].declarations[0].id;
578
576
  childElement = createCallExpression(createArrowFunctionExpression(createBlockStatement([...stmts, createReturnStatement(id, childPosition)], childPosition), childPosition), [], childPosition);
579
577
  } else if (stmts[0].type === "VariableDeclaration") childElement = stmts[0].declarations[0].init;
580
578
  else childElement = stmts[0].expression;
@@ -618,7 +616,7 @@ function transformThisExpression(node) {
618
616
  currentContext.hasThisInProgram = true;
619
617
  for (let i = 0; i < body.length; ++i) {
620
618
  if (body[i].type === "ImportDeclaration") continue;
621
- body.splice(i, 0, createVariableDeclaration(thisId, createThisExpression(programPosition), programPosition));
619
+ body.splice(i, 0, createVariableDeclaration(thisId, createIdentifier("globalThis", programPosition), programPosition));
622
620
  break;
623
621
  }
624
622
  } else if (!currentContext.hasThisInFunction) {
@@ -1071,8 +1069,7 @@ function transformProperties(attrs, children, position) {
1071
1069
  }
1072
1070
  function getAttributeName(node) {
1073
1071
  if (node.type === "JSXIdentifier") return node.name;
1074
- const namespace = node.namespace;
1075
- return `${namespace.name}:${node.name.name}`;
1072
+ return `${node.namespace.name}:${node.name.name}`;
1076
1073
  }
1077
1074
  function copyPosition(node) {
1078
1075
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zessjs/compiler",
3
- "version": "1.0.7",
3
+ "version": "1.1.0",
4
4
  "description": "Zess JSX compiler 💥 Delivers efficient code conversion for super - responsive web experiences.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "astring": "^1.9.0",
39
- "entities": "^6.0.1",
39
+ "entities": "^7.0.0",
40
40
  "merge-source-map": "^1.1.0",
41
41
  "meriyah": "^6.1.4",
42
42
  "source-map": "^0.7.6"