xray16 1.3.1 → 1.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xray16",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "author": "Neloreck",
5
5
  "repository": "https://github.com/stalker-xrts/xray-16-types",
6
6
  "private": false,
@@ -3,9 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const comment = `-- Generated by xrf util at: ${new Date().toString()}\n\n`;
4
4
  const plugin = {
5
5
  beforeEmit(program, options, emitHost, result) {
6
- void program;
7
- void options;
8
- void emitHost;
9
6
  for (const file of result) {
10
7
  file.code = comment + file.code;
11
8
  }
@@ -1,14 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const path = require("path");
3
4
  const typescript_1 = require("typescript");
4
5
  const tracy_1 = require("./utils/tracy");
5
6
  const ast_1 = require("./utils/ast");
6
7
  const environment_1 = require("./utils/environment");
8
+ const sourceFile_1 = require("typescript-to-lua/dist/transformation/visitors/sourceFile");
7
9
  /**
8
10
  * Plugin that injects FILE_NAME in compile-time.
9
11
  */
10
12
  const plugin = {
11
13
  visitors: {
14
+ [typescript_1.SyntaxKind.SourceFile]: (node, context) => {
15
+ if ((0, environment_1.isTracyZonesInjectionEnabled)()) {
16
+ let filename = node.fileName ? path.basename(node.fileName) : "unknown";
17
+ if (filename.endsWith(".ts")) {
18
+ filename = filename.slice(0, -3) + ".script";
19
+ }
20
+ if (filename.startsWith("index.")) {
21
+ filename = `${path.basename(path.dirname(node.fileName))}::${filename}`;
22
+ }
23
+ return (0, sourceFile_1.transformSourceFileNode)(typescript_1.factory.updateSourceFile(node, [
24
+ (0, tracy_1.createTraceZoneBeginNExpression)(`file::${filename}@lua`),
25
+ ...node.statements,
26
+ (0, tracy_1.createTraceZoneEndExpression)(),
27
+ ], node.isDeclarationFile, node.referencedFiles, node.typeReferenceDirectives, node.hasNoDefaultLib, node.libReferenceDirectives), context);
28
+ }
29
+ return (0, sourceFile_1.transformSourceFileNode)(node, context);
30
+ },
12
31
  [typescript_1.SyntaxKind.FunctionDeclaration]: (node, context) => {
13
32
  return context.superTransformStatements((0, environment_1.isTracyZonesInjectionEnabled)() ? (0, tracy_1.transformWithInjectedZones)(node) : node);
14
33
  },
@@ -120,7 +120,7 @@ function transformWithInjectedZones(node, parentName) {
120
120
  }
121
121
  const statements = remapStatementsWithZoneEnd(node.body).map(transformNestedStatementsToInjectEndZones);
122
122
  // Zone start declaration.
123
- statements.unshift(createTraceZoneBeginNExpression(`${parentName ? `${parentName}.` : ""}${name}@lua`));
123
+ statements.unshift(createTraceZoneBeginNExpression(`${parentName ? `${parentName}::` : ""}${name}@lua`));
124
124
  // Zone end declaration without explicit return.
125
125
  if (!hasReturnStatement) {
126
126
  statements.push(createTraceZoneEndExpression());