isaacscript-common 1.0.516 → 1.0.517

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/debug.d.ts CHANGED
@@ -1 +1,2 @@
1
+ /** Set this to true to enable more verbosity in the save data manger. */
1
2
  export declare const DEBUG = false;
@@ -1,9 +1,15 @@
1
+ /**
2
+ * Helper function to get a stack trace.
3
+ *
4
+ * This will only work if the `--luadebug` launch option is enabled or the Racing+ sandbox is
5
+ * enabled.
6
+ */
7
+ export declare function getTraceback(): string;
1
8
  /**
2
9
  * Helper function to print a stack trace to the "log.txt" file, similar to JavaScript's
3
- * `console.trace()` function. This will only work if the `--luadebug` launch option is enabled or
4
- * the Racing+ sandbox is enabled.
10
+ * `console.trace()` function.
5
11
  *
6
- * @param silent Optional. Whether or not to print an error message if the `--luadebug` launch
7
- * option is not turned on. False by default.
12
+ * This will only work if the `--luadebug` launch option is enabled or the Racing+ sandbox is
13
+ * enabled.
8
14
  */
9
- export declare function traceback(silent?: boolean): void;
15
+ export declare function traceback(): void;
@@ -1,20 +1,16 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
- function ____exports.traceback(self, silent)
4
- if silent == nil then
5
- silent = false
6
- end
3
+ function ____exports.getTraceback(self)
7
4
  if debug ~= nil then
8
- local tracebackMsg = debug.traceback()
9
- Isaac.DebugString(tracebackMsg)
10
- return
11
- end
12
- if sandboxTraceback ~= nil then
13
- sandboxTraceback()
14
- return
5
+ return debug.traceback()
15
6
  end
16
- if not silent then
17
- Isaac.DebugString("Error: Cannot perform a traceback since --luadebug is not enabled.")
7
+ if sandboxGetTraceback ~= nil then
8
+ return sandboxGetTraceback()
18
9
  end
10
+ return "stack traceback:\n(the \"--luadebug\" flag is not enabled)"
11
+ end
12
+ function ____exports.traceback(self)
13
+ local tracebackOutput = ____exports.getTraceback(nil)
14
+ Isaac.DebugString(tracebackOutput)
19
15
  end
20
16
  return ____exports
@@ -1,16 +1,34 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ require("lualib_bundle");
2
3
  local ____exports = {}
3
- local errorWithTraceback, vanillaError
4
+ local errorWithTraceback, slimTracebackOutput, vanillaError
4
5
  local ____debug = require("functions.debug")
5
- local traceback = ____debug.traceback
6
+ local getTraceback = ____debug.getTraceback
6
7
  local ____util = require("functions.util")
7
8
  local isLuaDebugEnabled = ____util.isLuaDebugEnabled
8
9
  function errorWithTraceback(message, level)
9
10
  if vanillaError == nil then
10
11
  error(message, level)
11
12
  end
12
- traceback(nil)
13
- vanillaError(message, level)
13
+ if level == nil then
14
+ level = 1
15
+ end
16
+ local tracebackOutput = getTraceback(nil)
17
+ local slimmedTracebackOutput = slimTracebackOutput(nil, tracebackOutput)
18
+ Isaac.DebugString(slimmedTracebackOutput)
19
+ vanillaError(message, level + 1)
20
+ end
21
+ function slimTracebackOutput(self, tracebackOutput)
22
+ local lineSeparator = "\n"
23
+ local lines = __TS__StringSplit(tracebackOutput, lineSeparator)
24
+ if __TS__StringIncludes(lines[2], "in upvalue 'getTraceback'") then
25
+ __TS__ArraySplice(lines, 1, 1)
26
+ end
27
+ if __TS__StringIncludes(lines[2], "in function 'error'") then
28
+ __TS__ArraySplice(lines, 1, 1)
29
+ end
30
+ local slimmedTracebackOutput = table.concat(lines, lineSeparator or ",")
31
+ return slimmedTracebackOutput
14
32
  end
15
33
  function ____exports.patchErrorFunction(self)
16
34
  if not isLuaDebugEnabled(nil) then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.516",
3
+ "version": "1.0.517",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,7 +25,7 @@
25
25
  "dist/**/*.d.ts"
26
26
  ],
27
27
  "devDependencies": {
28
- "isaac-typescript-definitions": "^1.0.294",
28
+ "isaac-typescript-definitions": "^1.0.295",
29
29
  "isaacscript-lint": "^1.0.71",
30
30
  "typedoc": "^0.22.10",
31
31
  "typescript": "4.4.4",