isaacscript-common 1.2.80 → 1.2.81
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.
|
@@ -3,8 +3,8 @@ local ____lualib = require("lualib_bundle")
|
|
|
3
3
|
local __TS__StringTrim = ____lualib.__TS__StringTrim
|
|
4
4
|
local ____exports = {}
|
|
5
5
|
local readSaveDatFile, tryLoadModData, DEFAULT_MOD_DATA
|
|
6
|
-
local
|
|
7
|
-
local jsonDecode =
|
|
6
|
+
local ____jsonHelpers = require("functions.jsonHelpers")
|
|
7
|
+
local jsonDecode = ____jsonHelpers.jsonDecode
|
|
8
8
|
local ____log = require("functions.log")
|
|
9
9
|
local log = ____log.log
|
|
10
10
|
local ____debug = require("features.saveDataManager.debug")
|
|
@@ -7,8 +7,8 @@ local getAllSaveDataToWriteToDisk
|
|
|
7
7
|
local ____deepCopy = require("functions.deepCopy")
|
|
8
8
|
local deepCopy = ____deepCopy.deepCopy
|
|
9
9
|
local SerializationType = ____deepCopy.SerializationType
|
|
10
|
-
local
|
|
11
|
-
local jsonEncode =
|
|
10
|
+
local ____jsonHelpers = require("functions.jsonHelpers")
|
|
11
|
+
local jsonEncode = ____jsonHelpers.jsonEncode
|
|
12
12
|
local ____log = require("functions.log")
|
|
13
13
|
local log = ____log.log
|
|
14
14
|
function getAllSaveDataToWriteToDisk(self, saveDataMap, saveDataConditionalFuncMap)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
|
+
/**
|
|
3
|
+
* Converts a Lua table to a JSON string.
|
|
4
|
+
* In most cases, this function will be used for writing data to a "save#.dat" file.
|
|
5
|
+
* If encoding fails, it will throw an error to prevent writing a blank string or corrupted data to
|
|
6
|
+
* a user's "save#.dat" file.
|
|
7
|
+
*/
|
|
8
|
+
export declare function jsonEncode(table: unknown): string;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a JSON string to a Lua table.
|
|
11
|
+
* In most cases, this function will be used for reading data from a "save#.dat" file.
|
|
12
|
+
* If decoding fails, it will return a blank Lua table instead of throwing an error.
|
|
13
|
+
* (This allows execution to continue in cases where users have no current save data or have
|
|
14
|
+
* manually removed their existing save data.)
|
|
15
|
+
*/
|
|
16
|
+
export declare function jsonDecode(jsonString: string): LuaTable;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local tryEncode, tryDecode
|
|
4
|
+
local json = require("@NoResolution:json")
|
|
5
|
+
local ____log = require("functions.log")
|
|
6
|
+
local log = ____log.log
|
|
7
|
+
function tryEncode(____table)
|
|
8
|
+
return json.encode(____table)
|
|
9
|
+
end
|
|
10
|
+
function tryDecode(jsonString)
|
|
11
|
+
return json.decode(jsonString)
|
|
12
|
+
end
|
|
13
|
+
function ____exports.jsonEncode(self, ____table)
|
|
14
|
+
local ok, jsonStringOrErrMsg = pcall(tryEncode, ____table)
|
|
15
|
+
if not ok then
|
|
16
|
+
error("Failed to convert the Lua table to JSON: " .. jsonStringOrErrMsg)
|
|
17
|
+
end
|
|
18
|
+
return jsonStringOrErrMsg
|
|
19
|
+
end
|
|
20
|
+
function ____exports.jsonDecode(self, jsonString)
|
|
21
|
+
local ok, luaTableOrErrMsg = pcall(tryDecode, jsonString)
|
|
22
|
+
if not ok then
|
|
23
|
+
log("Failed to convert the JSON string to a Lua table: " .. jsonString)
|
|
24
|
+
return {}
|
|
25
|
+
end
|
|
26
|
+
return luaTableOrErrMsg
|
|
27
|
+
end
|
|
28
|
+
return ____exports
|
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export * from "./functions/flying";
|
|
|
29
29
|
export * from "./functions/globals";
|
|
30
30
|
export * from "./functions/gridEntity";
|
|
31
31
|
export * from "./functions/input";
|
|
32
|
-
export * from "./functions/
|
|
32
|
+
export * from "./functions/jsonHelpers";
|
|
33
33
|
export * from "./functions/jsonRoom";
|
|
34
34
|
export * from "./functions/language";
|
|
35
35
|
export * from "./functions/log";
|
package/dist/index.lua
CHANGED
|
@@ -243,7 +243,7 @@ do
|
|
|
243
243
|
end
|
|
244
244
|
end
|
|
245
245
|
do
|
|
246
|
-
local ____export = require("functions.
|
|
246
|
+
local ____export = require("functions.jsonHelpers")
|
|
247
247
|
for ____exportKey, ____exportValue in pairs(____export) do
|
|
248
248
|
if ____exportKey ~= "default" then
|
|
249
249
|
____exports[____exportKey] = ____exportValue
|