@gamely/gly-engine-lite 0.3.6 → 0.3.8
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/main.lua +232 -105
- package/package.json +1 -1
package/dist/main.lua
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
local
|
|
2
|
-
local
|
|
1
|
+
local b2967 = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
|
|
2
|
+
local r2967 = function(i, f)
|
|
3
3
|
return function()
|
|
4
4
|
local c = f()
|
|
5
|
-
|
|
5
|
+
b2967[i] = function() return c end
|
|
6
6
|
return c
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
local math = ((function() local x, y = pcall(require, 'math'); return x and y end)()) or _G.math
|
|
10
|
-
local function
|
|
11
|
-
local version =
|
|
12
|
-
local loadcore =
|
|
13
|
-
local loadgame =
|
|
14
|
-
local engine_encoder =
|
|
15
|
-
local engine_game =
|
|
16
|
-
local engine_hash =
|
|
17
|
-
local engine_http =
|
|
18
|
-
local engine_i18n =
|
|
19
|
-
local engine_key =
|
|
20
|
-
local engine_env =
|
|
21
|
-
local engine_log =
|
|
22
|
-
local engine_math =
|
|
23
|
-
local engine_math_clib =
|
|
24
|
-
local engine_math_random =
|
|
25
|
-
local engine_array =
|
|
26
|
-
local engine_media =
|
|
27
|
-
local engine_api_draw_fps =
|
|
28
|
-
local engine_api_draw_text =
|
|
29
|
-
local engine_api_draw_poly =
|
|
30
|
-
local engine_raw_memory =
|
|
31
|
-
local callback_http =
|
|
32
|
-
local application_default =
|
|
33
|
-
local color =
|
|
34
|
-
local std =
|
|
10
|
+
local function m2967()
|
|
11
|
+
local version = b2967[1]('source_version')
|
|
12
|
+
local loadcore = b2967[2]('source_shared_engine_loadcore')
|
|
13
|
+
local loadgame = b2967[3]('source_shared_engine_loadgame')
|
|
14
|
+
local engine_encoder = b2967[4]('source_engine_api_data_encoder')
|
|
15
|
+
local engine_game = b2967[5]('source_engine_api_system_app')
|
|
16
|
+
local engine_hash = b2967[6]('source_engine_api_data_hash')
|
|
17
|
+
local engine_http = b2967[7]('source_engine_api_io_http')
|
|
18
|
+
local engine_i18n = b2967[8]('source_engine_api_data_i18n')
|
|
19
|
+
local engine_key = b2967[9]('source_engine_api_system_key')
|
|
20
|
+
local engine_env = b2967[10]('source_engine_api_system_getenv')
|
|
21
|
+
local engine_log = b2967[11]('source_engine_api_debug_log')
|
|
22
|
+
local engine_math = b2967[12]('source_engine_api_math_basic')
|
|
23
|
+
local engine_math_clib = b2967[13]('source_engine_api_math_clib')
|
|
24
|
+
local engine_math_random = b2967[14]('source_engine_api_math_random')
|
|
25
|
+
local engine_array = b2967[15]('source_engine_api_data_array')
|
|
26
|
+
local engine_media = b2967[16]('source_engine_api_io_media')
|
|
27
|
+
local engine_api_draw_fps = b2967[17]('source_engine_api_draw_fps')
|
|
28
|
+
local engine_api_draw_text = b2967[18]('source_engine_api_draw_text')
|
|
29
|
+
local engine_api_draw_poly = b2967[19]('source_engine_api_draw_poly')
|
|
30
|
+
local engine_raw_memory = b2967[20]('source_engine_api_raw_memory')
|
|
31
|
+
local callback_http = b2967[21]('source_engine_protocol_http_callback')
|
|
32
|
+
local application_default = b2967[22]('source_shared_var_object_root')
|
|
33
|
+
local color = b2967[23]('source_engine_api_system_color')
|
|
34
|
+
local std = b2967[24]('source_shared_var_object_std')
|
|
35
35
|
local application = application_default
|
|
36
36
|
local engine = {
|
|
37
37
|
keyboard = function(a, b, c, d) end,
|
|
@@ -193,12 +193,12 @@ version=version
|
|
|
193
193
|
}
|
|
194
194
|
return P
|
|
195
195
|
end
|
|
196
|
-
|
|
197
|
-
return '0.3.
|
|
196
|
+
b2967[1] = r2967(1, function()
|
|
197
|
+
return '0.3.8'
|
|
198
198
|
end)
|
|
199
|
-
|
|
200
|
-
local zeebo_pipeline =
|
|
201
|
-
local requires =
|
|
199
|
+
b2967[2] = r2967(2, function()
|
|
200
|
+
local zeebo_pipeline = b2967[25]('source_shared_functional_pipeline')
|
|
201
|
+
local requires = b2967[26]('source_shared_string_dsl_requires')
|
|
202
202
|
local function step_install_libsys(self, lib_name, library, custom, is_system)
|
|
203
203
|
if not is_system then return end
|
|
204
204
|
local ok, msg = pcall(function()
|
|
@@ -279,9 +279,9 @@ setup = setup
|
|
|
279
279
|
}
|
|
280
280
|
return P
|
|
281
281
|
end)
|
|
282
|
-
|
|
283
|
-
local eval_file =
|
|
284
|
-
local eval_code =
|
|
282
|
+
b2967[3] = r2967(3, function()
|
|
283
|
+
local eval_file = b2967[27]('source_shared_string_eval_file')
|
|
284
|
+
local eval_code = b2967[28]('source_shared_string_eval_code')
|
|
285
285
|
local has_io_open = io and io.open
|
|
286
286
|
local function normalize(app, base)
|
|
287
287
|
if not app then return nil end
|
|
@@ -355,7 +355,7 @@ script = script
|
|
|
355
355
|
}
|
|
356
356
|
return P
|
|
357
357
|
end)
|
|
358
|
-
|
|
358
|
+
b2967[4] = r2967(4, function()
|
|
359
359
|
local function install(std, engine, library, name)
|
|
360
360
|
std = std or {}
|
|
361
361
|
std[name] = {
|
|
@@ -369,7 +369,7 @@ install=install
|
|
|
369
369
|
}
|
|
370
370
|
return P
|
|
371
371
|
end)
|
|
372
|
-
|
|
372
|
+
b2967[5] = r2967(5, function()
|
|
373
373
|
local function reset(std, engine)
|
|
374
374
|
if std.node then
|
|
375
375
|
return function()
|
|
@@ -404,11 +404,7 @@ local function install(std, engine, config)
|
|
|
404
404
|
std = std or {}
|
|
405
405
|
config = config or {}
|
|
406
406
|
std.app = std.app or {}
|
|
407
|
-
std.bus.listen('post_quit', function()
|
|
408
|
-
if config.quit then
|
|
409
|
-
config.quit()
|
|
410
|
-
end
|
|
411
|
-
end)
|
|
407
|
+
std.bus.listen('post_quit', config.quit or config.exit or function() end)
|
|
412
408
|
std.app.title = title(config.set_title)
|
|
413
409
|
std.app.exit = exit(std)
|
|
414
410
|
std.app.reset = reset(std, engine)
|
|
@@ -422,7 +418,7 @@ install=install
|
|
|
422
418
|
}
|
|
423
419
|
return P
|
|
424
420
|
end)
|
|
425
|
-
|
|
421
|
+
b2967[6] = r2967(6, function()
|
|
426
422
|
local function djb2(digest)
|
|
427
423
|
local index = 1
|
|
428
424
|
local hash = 5381
|
|
@@ -445,8 +441,8 @@ install = install
|
|
|
445
441
|
}
|
|
446
442
|
return P
|
|
447
443
|
end)
|
|
448
|
-
|
|
449
|
-
local zeebo_pipeline =
|
|
444
|
+
b2967[7] = r2967(7, function()
|
|
445
|
+
local zeebo_pipeline = b2967[25]('source_shared_functional_pipeline')
|
|
450
446
|
local function json(self)
|
|
451
447
|
self.options['json'] = true
|
|
452
448
|
return self
|
|
@@ -612,7 +608,7 @@ install=install
|
|
|
612
608
|
}
|
|
613
609
|
return P
|
|
614
610
|
end)
|
|
615
|
-
|
|
611
|
+
b2967[8] = r2967(8, function()
|
|
616
612
|
local language = 'en-US'
|
|
617
613
|
local language_default = 'en-US'
|
|
618
614
|
local language_list = {}
|
|
@@ -703,7 +699,7 @@ install=install
|
|
|
703
699
|
}
|
|
704
700
|
return P
|
|
705
701
|
end)
|
|
706
|
-
|
|
702
|
+
b2967[9] = r2967(9, function()
|
|
707
703
|
local function real_key(std, engine, rkey, rvalue)
|
|
708
704
|
local value = (rvalue == 1 or rvalue == true) or false
|
|
709
705
|
local key = engine.key_bindings[rkey] or (std.key.axis[rkey] and rkey)
|
|
@@ -752,7 +748,7 @@ return {
|
|
|
752
748
|
install = install
|
|
753
749
|
}
|
|
754
750
|
end)
|
|
755
|
-
|
|
751
|
+
b2967[10] = r2967(10, function()
|
|
756
752
|
local function setenv(engine)
|
|
757
753
|
return function(varname, value)
|
|
758
754
|
if engine.root ~= engine.current then
|
|
@@ -795,53 +791,66 @@ install = install
|
|
|
795
791
|
}
|
|
796
792
|
return P
|
|
797
793
|
end)
|
|
798
|
-
|
|
799
|
-
local
|
|
800
|
-
local
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
local
|
|
804
|
-
local
|
|
805
|
-
|
|
794
|
+
b2967[11] = r2967(11, function()
|
|
795
|
+
local yaml = b2967[29]('source_shared_string_encode_yaml')
|
|
796
|
+
local levels = { none = 0, fatal = 1, error = 2, warn = 3, info = 4, debug = 5, trace = 6}
|
|
797
|
+
local function printer(engine, printers, func_a, func_b)
|
|
798
|
+
local fn_a = func_a and printers[func_a]
|
|
799
|
+
local fn_b = func_b and printers[func_b]
|
|
800
|
+
local func = fn_a or fn_b or function() end
|
|
801
|
+
local level = levels[func_a] or 7
|
|
802
|
+
return function (...)
|
|
803
|
+
local msgs = {...}
|
|
804
|
+
local count = #msgs
|
|
805
|
+
if level <= engine.loglevel then
|
|
806
|
+
local content = ''
|
|
807
|
+
for i = 1, count do
|
|
808
|
+
local v = msgs[i]
|
|
809
|
+
local t = type(v)
|
|
810
|
+
if t == 'table' then
|
|
811
|
+
content = content..'\n'..yaml.encode(v)..'\n'
|
|
812
|
+
elseif t ~= 'function' then
|
|
813
|
+
local add_space = i ~= count and i > 1 and content:sub(-1) ~= '\n'
|
|
814
|
+
local prefix = add_space and ' ' or ''
|
|
815
|
+
content = content..prefix..tostring(v)
|
|
816
|
+
end
|
|
817
|
+
end
|
|
818
|
+
func(content)
|
|
819
|
+
end
|
|
820
|
+
end
|
|
821
|
+
end
|
|
822
|
+
local function level(engine)
|
|
823
|
+
return function(n)
|
|
824
|
+
local lv = levels[n] or (type(n) == 'number' and n) or -1
|
|
825
|
+
if lv < 0 or 6 < lv then
|
|
806
826
|
error('logging level not exist: '..tostring(level))
|
|
807
827
|
end
|
|
808
|
-
engine.loglevel =
|
|
828
|
+
engine.loglevel = lv
|
|
809
829
|
end
|
|
810
|
-
local function init(std, engine, printers)
|
|
811
|
-
local index = 1
|
|
812
|
-
local level_per_func = {}
|
|
813
|
-
local level_per_name = {}
|
|
814
|
-
while index <= #logging_types do
|
|
815
|
-
local ltype = logging_types[index]
|
|
816
|
-
local lfunc = function() end
|
|
817
|
-
if index > 1 and printers[ltype] then
|
|
818
|
-
lfunc = (function (level)
|
|
819
|
-
return function(message)
|
|
820
|
-
if engine.loglevel >= level then
|
|
821
|
-
printers[ltype](message)
|
|
822
|
-
end
|
|
823
|
-
end
|
|
824
|
-
end)(index - 1)
|
|
825
|
-
end
|
|
826
|
-
level_per_func[lfunc] = index - 1
|
|
827
|
-
level_per_name[ltype] = index - 1
|
|
828
|
-
std.log[ltype] = lfunc
|
|
829
|
-
index = index + 1
|
|
830
830
|
end
|
|
831
|
-
|
|
831
|
+
local function init(std, engine)
|
|
832
|
+
return function(printers)
|
|
833
|
+
std.log.fatal = printer(engine, printers, 'fatal', 'error')
|
|
834
|
+
std.log.error = printer(engine, printers, 'error')
|
|
835
|
+
std.log.warn = printer(engine, printers, 'warn')
|
|
836
|
+
std.log.info = printer(engine, printers, 'info')
|
|
837
|
+
std.log.debug = printer(engine, printers, 'debug', 'info')
|
|
838
|
+
std.log.trace = printer(engine, printers, 'trace', 'info')
|
|
839
|
+
end
|
|
832
840
|
end
|
|
833
841
|
local function install(std, engine, printers)
|
|
834
842
|
std.log = std.log or {}
|
|
835
|
-
|
|
836
|
-
std.log.
|
|
843
|
+
std.log.init = init(std, engine)
|
|
844
|
+
std.log.level = level(engine)
|
|
837
845
|
std.log.init(printers)
|
|
846
|
+
std.log.level('debug')
|
|
838
847
|
end
|
|
839
848
|
local P = {
|
|
840
849
|
install = install
|
|
841
850
|
}
|
|
842
851
|
return P
|
|
843
852
|
end)
|
|
844
|
-
|
|
853
|
+
b2967[12] = r2967(12, function()
|
|
845
854
|
local function abs(value)
|
|
846
855
|
if value < 0 then
|
|
847
856
|
return -value
|
|
@@ -939,7 +948,7 @@ install = install
|
|
|
939
948
|
}
|
|
940
949
|
return P
|
|
941
950
|
end)
|
|
942
|
-
|
|
951
|
+
b2967[13] = r2967(13, function()
|
|
943
952
|
local function install(std)
|
|
944
953
|
assert(math and (1/2 ~= 0))
|
|
945
954
|
std.math = std.math or {}
|
|
@@ -974,7 +983,7 @@ install = install
|
|
|
974
983
|
}
|
|
975
984
|
return P
|
|
976
985
|
end)
|
|
977
|
-
|
|
986
|
+
b2967[14] = r2967(14, function()
|
|
978
987
|
local function install(std)
|
|
979
988
|
assert(math and (1/2 ~= 0))
|
|
980
989
|
std.math = std.math or {}
|
|
@@ -990,8 +999,8 @@ install = install
|
|
|
990
999
|
}
|
|
991
1000
|
return P
|
|
992
1001
|
end)
|
|
993
|
-
|
|
994
|
-
local util_decorator =
|
|
1002
|
+
b2967[15] = r2967(15, function()
|
|
1003
|
+
local util_decorator = b2967[31]('source_shared_functional_decorator')
|
|
995
1004
|
local function array_map(array, func)
|
|
996
1005
|
local res = {}
|
|
997
1006
|
local index = 1
|
|
@@ -1151,7 +1160,7 @@ install = install
|
|
|
1151
1160
|
}
|
|
1152
1161
|
return P
|
|
1153
1162
|
end)
|
|
1154
|
-
|
|
1163
|
+
b2967[16] = r2967(16, function()
|
|
1155
1164
|
local function media_create(node, channels, handler)
|
|
1156
1165
|
local decorator = function(func)
|
|
1157
1166
|
func = func or function() end
|
|
@@ -1197,7 +1206,7 @@ install=install
|
|
|
1197
1206
|
}
|
|
1198
1207
|
return P
|
|
1199
1208
|
end)
|
|
1200
|
-
|
|
1209
|
+
b2967[17] = r2967(17, function()
|
|
1201
1210
|
local function draw_fps(std, engine, show, pos_x, pos_y)
|
|
1202
1211
|
if show < 1 then return end
|
|
1203
1212
|
local x = engine.current.config.offset_x + pos_x
|
|
@@ -1245,7 +1254,7 @@ install=install
|
|
|
1245
1254
|
}
|
|
1246
1255
|
return P
|
|
1247
1256
|
end)
|
|
1248
|
-
|
|
1257
|
+
b2967[18] = r2967(18, function()
|
|
1249
1258
|
local function text_put(std, engine, font_previous)
|
|
1250
1259
|
return function(pos_x, pos_y, text, size)
|
|
1251
1260
|
size = size or 2
|
|
@@ -1277,7 +1286,7 @@ install=install
|
|
|
1277
1286
|
}
|
|
1278
1287
|
return P
|
|
1279
1288
|
end)
|
|
1280
|
-
|
|
1289
|
+
b2967[19] = r2967(19, function()
|
|
1281
1290
|
local function decorator_poo(object, func)
|
|
1282
1291
|
if not object or not func then return func end
|
|
1283
1292
|
return function(a, b, c, d)
|
|
@@ -1383,7 +1392,7 @@ install=install
|
|
|
1383
1392
|
}
|
|
1384
1393
|
return P
|
|
1385
1394
|
end)
|
|
1386
|
-
|
|
1395
|
+
b2967[20] = r2967(20, function()
|
|
1387
1396
|
local memory_dict_unload = {}
|
|
1388
1397
|
local memory_dict = {}
|
|
1389
1398
|
local memory_list = {}
|
|
@@ -1437,9 +1446,9 @@ install=install
|
|
|
1437
1446
|
}
|
|
1438
1447
|
return P
|
|
1439
1448
|
end)
|
|
1440
|
-
|
|
1441
|
-
local str_http =
|
|
1442
|
-
local str_url =
|
|
1449
|
+
b2967[21] = r2967(21, function()
|
|
1450
|
+
local str_http = b2967[32]('source_shared_string_encode_http')
|
|
1451
|
+
local str_url = b2967[33]('source_shared_string_encode_url')
|
|
1443
1452
|
local callbacks = {
|
|
1444
1453
|
['async-promise'] = function(self)
|
|
1445
1454
|
return self:promise()
|
|
@@ -1508,7 +1517,7 @@ func = native_http_callback
|
|
|
1508
1517
|
}
|
|
1509
1518
|
return P
|
|
1510
1519
|
end)
|
|
1511
|
-
|
|
1520
|
+
b2967[22] = r2967(22, function()
|
|
1512
1521
|
local P = {
|
|
1513
1522
|
data={
|
|
1514
1523
|
width=1280,
|
|
@@ -1537,7 +1546,7 @@ callbacks={
|
|
|
1537
1546
|
}
|
|
1538
1547
|
return P;
|
|
1539
1548
|
end)
|
|
1540
|
-
|
|
1549
|
+
b2967[23] = r2967(23, function()
|
|
1541
1550
|
local function install(std)
|
|
1542
1551
|
std.color = std.color or {}
|
|
1543
1552
|
std.color.white = 0xFFFFFFFF
|
|
@@ -1571,7 +1580,7 @@ install = install
|
|
|
1571
1580
|
}
|
|
1572
1581
|
return P
|
|
1573
1582
|
end)
|
|
1574
|
-
|
|
1583
|
+
b2967[24] = r2967(24, function()
|
|
1575
1584
|
local P = {
|
|
1576
1585
|
milis = 0,
|
|
1577
1586
|
delta = 0,
|
|
@@ -1638,7 +1647,7 @@ any=false
|
|
|
1638
1647
|
}
|
|
1639
1648
|
return P;
|
|
1640
1649
|
end)
|
|
1641
|
-
|
|
1650
|
+
b2967[25] = r2967(25, function()
|
|
1642
1651
|
local function pipe(self)
|
|
1643
1652
|
return function()
|
|
1644
1653
|
self:run()
|
|
@@ -1687,7 +1696,7 @@ run=run
|
|
|
1687
1696
|
}
|
|
1688
1697
|
return P
|
|
1689
1698
|
end)
|
|
1690
|
-
|
|
1699
|
+
b2967[26] = r2967(26, function()
|
|
1691
1700
|
local function encode(dsl_string)
|
|
1692
1701
|
local spec = {
|
|
1693
1702
|
list = {},
|
|
@@ -1735,7 +1744,7 @@ should_import = should_import
|
|
|
1735
1744
|
}
|
|
1736
1745
|
return P
|
|
1737
1746
|
end)
|
|
1738
|
-
|
|
1747
|
+
b2967[27] = r2967(27, function()
|
|
1739
1748
|
local function script(src)
|
|
1740
1749
|
local ok, app = false, nil
|
|
1741
1750
|
if require then
|
|
@@ -1760,7 +1769,7 @@ script = script,
|
|
|
1760
1769
|
}
|
|
1761
1770
|
return P
|
|
1762
1771
|
end)
|
|
1763
|
-
|
|
1772
|
+
b2967[28] = r2967(28, function()
|
|
1764
1773
|
local function script(src)
|
|
1765
1774
|
local loader = loadstring or load
|
|
1766
1775
|
if not loader then
|
|
@@ -1780,7 +1789,125 @@ script = script,
|
|
|
1780
1789
|
}
|
|
1781
1790
|
return P
|
|
1782
1791
|
end)
|
|
1783
|
-
|
|
1792
|
+
b2967[29] = r2967(29, function()
|
|
1793
|
+
local function get_max_width(indent)
|
|
1794
|
+
if indent <= 40 then
|
|
1795
|
+
return 80
|
|
1796
|
+
else
|
|
1797
|
+
return nil
|
|
1798
|
+
end
|
|
1799
|
+
end
|
|
1800
|
+
local function wrap_text(text, indent)
|
|
1801
|
+
local max_width = get_max_width(indent)
|
|
1802
|
+
local prefix = string.rep(" ", indent)
|
|
1803
|
+
if not max_width then
|
|
1804
|
+
local lines = {}
|
|
1805
|
+
for line in text:gmatch("[^\n]+") do
|
|
1806
|
+
table.insert(lines, prefix .. line)
|
|
1807
|
+
end
|
|
1808
|
+
return table.concat(lines, "\n")
|
|
1809
|
+
end
|
|
1810
|
+
local words = {}
|
|
1811
|
+
for word in text:gmatch("%S+") do table.insert(words, word) end
|
|
1812
|
+
local lines = {}
|
|
1813
|
+
local line = ""
|
|
1814
|
+
for _, word in ipairs(words) do
|
|
1815
|
+
if #line + #word + 1 > max_width - indent * 2 then
|
|
1816
|
+
table.insert(lines, prefix .. line)
|
|
1817
|
+
line = word
|
|
1818
|
+
else
|
|
1819
|
+
if line == "" then
|
|
1820
|
+
line = word
|
|
1821
|
+
else
|
|
1822
|
+
line = line .. " " .. word
|
|
1823
|
+
end
|
|
1824
|
+
end
|
|
1825
|
+
end
|
|
1826
|
+
if line ~= "" then table.insert(lines, prefix .. line) end
|
|
1827
|
+
return table.concat(lines, "\n")
|
|
1828
|
+
end
|
|
1829
|
+
local function sanitize_key(key)
|
|
1830
|
+
if type(key) ~= "string" then
|
|
1831
|
+
key = tostring(key)
|
|
1832
|
+
end
|
|
1833
|
+
key = key:gsub("[^%w_-]", "_")
|
|
1834
|
+
return key
|
|
1835
|
+
end
|
|
1836
|
+
local function should_quote(s)
|
|
1837
|
+
if type(s) ~= "string" then return false end
|
|
1838
|
+
if s:match("^[^%a_]") or s:match("^%d+$") then
|
|
1839
|
+
return true
|
|
1840
|
+
end
|
|
1841
|
+
if s == "true" or s == "false" or s == "null" then
|
|
1842
|
+
return false
|
|
1843
|
+
end
|
|
1844
|
+
return false
|
|
1845
|
+
end
|
|
1846
|
+
local function format_string(s, indent)
|
|
1847
|
+
if type(s) ~= "string" then
|
|
1848
|
+
return tostring(s)
|
|
1849
|
+
end
|
|
1850
|
+
local max_width = get_max_width(indent)
|
|
1851
|
+
if s:find("\n") then
|
|
1852
|
+
local lines = {}
|
|
1853
|
+
for line in s:gmatch("[^\n]+") do
|
|
1854
|
+
if max_width then
|
|
1855
|
+
line = wrap_text(line, indent + 1)
|
|
1856
|
+
else
|
|
1857
|
+
line = string.rep(" ", indent + 1) .. line
|
|
1858
|
+
end
|
|
1859
|
+
table.insert(lines, line)
|
|
1860
|
+
end
|
|
1861
|
+
return "|-\n" .. table.concat(lines, "\n")
|
|
1862
|
+
elseif max_width and #s > max_width - indent * 2 then
|
|
1863
|
+
return ">-\n" .. wrap_text(s, indent + 1)
|
|
1864
|
+
elseif should_quote(s) then
|
|
1865
|
+
return string.format("%q", s)
|
|
1866
|
+
else
|
|
1867
|
+
return s
|
|
1868
|
+
end
|
|
1869
|
+
end
|
|
1870
|
+
local function to_yaml(tbl, indent)
|
|
1871
|
+
indent = indent or 0
|
|
1872
|
+
local yaml = ""
|
|
1873
|
+
local prefix = string.rep(" ", indent)
|
|
1874
|
+
local nums = {}
|
|
1875
|
+
local keys = {}
|
|
1876
|
+
for k, v in pairs(tbl) do
|
|
1877
|
+
if type(v) ~= "function" then
|
|
1878
|
+
if type(k) == "number" then
|
|
1879
|
+
table.insert(nums, k)
|
|
1880
|
+
else
|
|
1881
|
+
table.insert(keys, k)
|
|
1882
|
+
end
|
|
1883
|
+
end
|
|
1884
|
+
end
|
|
1885
|
+
table.sort(keys)
|
|
1886
|
+
for _, k in ipairs(keys) do
|
|
1887
|
+
local v = tbl[k]
|
|
1888
|
+
local safe_key = sanitize_key(k)
|
|
1889
|
+
if type(v) == "table" then
|
|
1890
|
+
yaml = yaml .. prefix .. safe_key .. ":\n" .. to_yaml(v, indent + 1)
|
|
1891
|
+
else
|
|
1892
|
+
yaml = yaml .. prefix .. safe_key .. ": " .. format_string(v, indent) .. "\n"
|
|
1893
|
+
end
|
|
1894
|
+
end
|
|
1895
|
+
table.sort(nums)
|
|
1896
|
+
for _, k in ipairs(nums) do
|
|
1897
|
+
local v = tbl[k]
|
|
1898
|
+
if type(v) == "table" then
|
|
1899
|
+
yaml = yaml .. prefix .. "-\n" .. to_yaml(v, indent + 1)
|
|
1900
|
+
else
|
|
1901
|
+
yaml = yaml .. prefix .. "- " .. format_string(v, indent) .. "\n"
|
|
1902
|
+
end
|
|
1903
|
+
end
|
|
1904
|
+
return yaml
|
|
1905
|
+
end
|
|
1906
|
+
return {
|
|
1907
|
+
encode = to_yaml
|
|
1908
|
+
}
|
|
1909
|
+
end)
|
|
1910
|
+
b2967[31] = r2967(31, function()
|
|
1784
1911
|
local function decorator_prefix3(zig, zag, zom, func)
|
|
1785
1912
|
return function (a, b, c, d, e, f)
|
|
1786
1913
|
return func(zig, zag, zom, a, b, c, d, e, f)
|
|
@@ -1837,7 +1964,7 @@ prefix1_t = table_prefix1
|
|
|
1837
1964
|
}
|
|
1838
1965
|
return P
|
|
1839
1966
|
end)
|
|
1840
|
-
|
|
1967
|
+
b2967[32] = r2967(32, function()
|
|
1841
1968
|
local function is_ok(status)
|
|
1842
1969
|
return (status and 200 <= status and status < 300) or false
|
|
1843
1970
|
end
|
|
@@ -1983,7 +2110,7 @@ get_user_agent=get_user_agent,
|
|
|
1983
2110
|
create_request=create_request
|
|
1984
2111
|
}
|
|
1985
2112
|
end)
|
|
1986
|
-
|
|
2113
|
+
b2967[33] = r2967(33, function()
|
|
1987
2114
|
local function search_param(param_list, param_dict)
|
|
1988
2115
|
local index, params = 1, ''
|
|
1989
2116
|
while param_list and param_dict and index <= #param_list do
|
|
@@ -2004,4 +2131,4 @@ search_param = search_param
|
|
|
2004
2131
|
}
|
|
2005
2132
|
return P
|
|
2006
2133
|
end)
|
|
2007
|
-
return
|
|
2134
|
+
return m2967()
|