@gamely/gly-engine-lite 0.3.0 → 0.3.1

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.
Files changed (2) hide show
  1. package/dist/main.lua +114 -86
  2. package/package.json +1 -1
package/dist/main.lua CHANGED
@@ -1,37 +1,37 @@
1
- local b2560 = {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 r2560 = function(i, f)
1
+ local b259c = {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 r259c = function(i, f)
3
3
  return function()
4
4
  local c = f()
5
- b2560[i] = function() return c end
5
+ b259c[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 m2560()
11
- local version = b2560[1]('source_version')
12
- local loadcore = b2560[2]('source_shared_engine_loadcore')
13
- local loadgame = b2560[3]('source_shared_engine_loadgame')
14
- local engine_encoder = b2560[4]('source_engine_api_data_encoder')
15
- local engine_game = b2560[5]('source_engine_api_system_app')
16
- local engine_hash = b2560[6]('source_engine_api_data_hash')
17
- local engine_http = b2560[7]('source_engine_api_io_http')
18
- local engine_i18n = b2560[8]('source_engine_api_data_i18n')
19
- local engine_key = b2560[9]('source_engine_api_system_key')
20
- local engine_env = b2560[10]('source_engine_api_system_getenv')
21
- local engine_log = b2560[11]('source_engine_api_debug_log')
22
- local engine_math = b2560[12]('source_engine_api_math_basic')
23
- local engine_math_clib = b2560[13]('source_engine_api_math_clib')
24
- local engine_math_random = b2560[14]('source_engine_api_math_random')
25
- local engine_array = b2560[15]('source_engine_api_data_array')
26
- local engine_media = b2560[16]('source_engine_api_io_media')
27
- local engine_api_draw_fps = b2560[17]('source_engine_api_draw_fps')
28
- local engine_api_draw_text = b2560[18]('source_engine_api_draw_text')
29
- local engine_api_draw_poly = b2560[19]('source_engine_api_draw_poly')
30
- local engine_raw_memory = b2560[20]('source_engine_api_raw_memory')
31
- local callback_http = b2560[21]('source_engine_protocol_http_callback')
32
- local application_default = b2560[22]('source_shared_var_object_root')
33
- local color = b2560[23]('source_engine_api_system_color')
34
- local std = b2560[24]('source_shared_var_object_std')
10
+ local function m259c()
11
+ local version = b259c[1]('source_version')
12
+ local loadcore = b259c[2]('source_shared_engine_loadcore')
13
+ local loadgame = b259c[3]('source_shared_engine_loadgame')
14
+ local engine_encoder = b259c[4]('source_engine_api_data_encoder')
15
+ local engine_game = b259c[5]('source_engine_api_system_app')
16
+ local engine_hash = b259c[6]('source_engine_api_data_hash')
17
+ local engine_http = b259c[7]('source_engine_api_io_http')
18
+ local engine_i18n = b259c[8]('source_engine_api_data_i18n')
19
+ local engine_key = b259c[9]('source_engine_api_system_key')
20
+ local engine_env = b259c[10]('source_engine_api_system_getenv')
21
+ local engine_log = b259c[11]('source_engine_api_debug_log')
22
+ local engine_math = b259c[12]('source_engine_api_math_basic')
23
+ local engine_math_clib = b259c[13]('source_engine_api_math_clib')
24
+ local engine_math_random = b259c[14]('source_engine_api_math_random')
25
+ local engine_array = b259c[15]('source_engine_api_data_array')
26
+ local engine_media = b259c[16]('source_engine_api_io_media')
27
+ local engine_api_draw_fps = b259c[17]('source_engine_api_draw_fps')
28
+ local engine_api_draw_text = b259c[18]('source_engine_api_draw_text')
29
+ local engine_api_draw_poly = b259c[19]('source_engine_api_draw_poly')
30
+ local engine_raw_memory = b259c[20]('source_engine_api_raw_memory')
31
+ local callback_http = b259c[21]('source_engine_protocol_http_callback')
32
+ local application_default = b259c[22]('source_shared_var_object_root')
33
+ local color = b259c[23]('source_engine_api_system_color')
34
+ local std = b259c[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
- b2560[1] = r2560(1, function()
197
- return '0.3.0'
196
+ b259c[1] = r259c(1, function()
197
+ return '0.3.1'
198
198
  end)
199
- b2560[2] = r2560(2, function()
200
- local zeebo_pipeline = b2560[25]('source_shared_functional_pipeline')
201
- local requires = b2560[26]('source_shared_string_dsl_requires')
199
+ b259c[2] = r259c(2, function()
200
+ local zeebo_pipeline = b259c[25]('source_shared_functional_pipeline')
201
+ local requires = b259c[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
- b2560[3] = r2560(3, function()
283
- local eval_file = b2560[27]('source_shared_string_eval_file')
284
- local eval_code = b2560[28]('source_shared_string_eval_code')
282
+ b259c[3] = r259c(3, function()
283
+ local eval_file = b259c[27]('source_shared_string_eval_file')
284
+ local eval_code = b259c[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
@@ -353,7 +353,7 @@ script = script
353
353
  }
354
354
  return P
355
355
  end)
356
- b2560[4] = r2560(4, function()
356
+ b259c[4] = r259c(4, function()
357
357
  local function install(std, engine, library, name)
358
358
  std = std or {}
359
359
  std[name] = {
@@ -367,26 +367,32 @@ install=install
367
367
  }
368
368
  return P
369
369
  end)
370
- b2560[5] = r2560(5, function()
371
- local util_decorator = b2560[29]('source_shared_functional_decorator')
370
+ b259c[5] = r259c(5, function()
372
371
  local function reset(std, engine)
373
372
  if std.node then
373
+ return function()
374
374
  std.bus.emit('exit')
375
375
  std.bus.emit('init')
376
- else
376
+ end
377
+ end
378
+ return function()
377
379
  engine.root.callbacks.exit(engine.root.data, std)
378
380
  engine.root.callbacks.init(engine.root.data, std)
379
381
  end
380
382
  end
381
383
  local function exit(std)
384
+ return function()
382
385
  std.bus.emit('exit')
383
386
  std.bus.emit('quit')
384
387
  end
385
- local function title(func, window_name)
388
+ end
389
+ local function title(func)
390
+ return function(window_name)
386
391
  if func then
387
392
  func(window_name)
388
393
  end
389
394
  end
395
+ end
390
396
  local function install(std, engine, config)
391
397
  std = std or {}
392
398
  config = config or {}
@@ -396,9 +402,9 @@ if config.quit then
396
402
  config.quit()
397
403
  end
398
404
  end)
399
- std.app.title = util_decorator.prefix1(config.set_title, title)
400
- std.app.exit = util_decorator.prefix1(std, exit)
401
- std.app.reset = util_decorator.prefix2(std, engine, reset)
405
+ std.app.title = title(config.set_title)
406
+ std.app.exit = exit(std)
407
+ std.app.reset = reset(std, engine)
402
408
  std.app.get_fps = config.get_fps
403
409
  return std.app
404
410
  end
@@ -407,7 +413,7 @@ install=install
407
413
  }
408
414
  return P
409
415
  end)
410
- b2560[6] = r2560(6, function()
416
+ b259c[6] = r259c(6, function()
411
417
  local function djb2(digest)
412
418
  local index = 1
413
419
  local hash = 5381
@@ -430,8 +436,8 @@ install = install
430
436
  }
431
437
  return P
432
438
  end)
433
- b2560[7] = r2560(7, function()
434
- local zeebo_pipeline = b2560[25]('source_shared_functional_pipeline')
439
+ b259c[7] = r259c(7, function()
440
+ local zeebo_pipeline = b259c[25]('source_shared_functional_pipeline')
435
441
  local function json(self)
436
442
  self.options['json'] = true
437
443
  return self
@@ -540,6 +546,11 @@ local new_body = json_decode(std.http.body)
540
546
  std.http.body = new_body
541
547
  end)
542
548
  end
549
+ local lower_header = {}
550
+ for k, v in pairs(std.http.headers or {}) do
551
+ lower_header[string.lower(k)] = v
552
+ end
553
+ std.http.headers = lower_header
543
554
  end,
544
555
  function()
545
556
  callback_handler(std, game)
@@ -588,7 +599,7 @@ install=install
588
599
  }
589
600
  return P
590
601
  end)
591
- b2560[8] = r2560(8, function()
602
+ b259c[8] = r259c(8, function()
592
603
  local language = 'en-US'
593
604
  local language_default = 'en-US'
594
605
  local language_list = {}
@@ -679,10 +690,15 @@ install=install
679
690
  }
680
691
  return P
681
692
  end)
682
- b2560[9] = r2560(9, function()
693
+ b259c[9] = r259c(9, function()
683
694
  local function real_key(std, engine, rkey, rvalue)
684
- local value = rvalue == 1 or rvalue == true
695
+ local value = (rvalue == 1 or rvalue == true) or false
685
696
  local key = engine.key_bindings[rkey] or (std.key.axis[rkey] and rkey)
697
+ local key_media = std.key.media and std.key.media[rkey] ~= nil and rkey
698
+ if key_media then
699
+ std.key.media[key_media] = value
700
+ std.bus.emit('key_media')
701
+ end
686
702
  if key then
687
703
  std.key.axis[key] = value and 1 or 0
688
704
  std.key.press[key] = value
@@ -703,19 +719,27 @@ end
703
719
  local function real_keyup(std, engine, key)
704
720
  real_key(std, engine, key, 0)
705
721
  end
706
- local function install(std, engine, key_bindings)
707
- engine.key_bindings = key_bindings or {}
722
+ local function install(std, engine, config)
723
+ config = config or {}
724
+ engine.key_bindings = config.bindings or {}
708
725
  engine.keyboard = real_key
726
+ if config.has_media then
727
+ std.key.media = {
728
+ ch_up = false,
729
+ ch_down = false,
730
+ vol_up = false,
731
+ vol_down = false
732
+ }
733
+ end
709
734
  std.bus.listen_std_engine('rkey', real_key)
710
735
  std.bus.listen_std_engine('rkey1', real_keydown)
711
736
  std.bus.listen_std_engine('rkey0', real_keyup)
712
737
  end
713
- local P = {
738
+ return {
714
739
  install = install
715
740
  }
716
- return P
717
741
  end)
718
- b2560[10] = r2560(10, function()
742
+ b259c[10] = r259c(10, function()
719
743
  local function setenv(engine)
720
744
  return function(varname, value)
721
745
  if engine.root ~= engine.current then
@@ -758,8 +782,8 @@ install = install
758
782
  }
759
783
  return P
760
784
  end)
761
- b2560[11] = r2560(11, function()
762
- local util_decorator = b2560[29]('source_shared_functional_decorator')
785
+ b259c[11] = r259c(11, function()
786
+ local util_decorator = b259c[29]('source_shared_functional_decorator')
763
787
  local logging_types = {
764
788
  'none', 'fatal', 'error', 'warn', 'debug', 'info'
765
789
  }
@@ -804,7 +828,7 @@ install = install
804
828
  }
805
829
  return P
806
830
  end)
807
- b2560[12] = r2560(12, function()
831
+ b259c[12] = r259c(12, function()
808
832
  local function abs(value)
809
833
  if value < 0 then
810
834
  return -value
@@ -902,7 +926,7 @@ install = install
902
926
  }
903
927
  return P
904
928
  end)
905
- b2560[13] = r2560(13, function()
929
+ b259c[13] = r259c(13, function()
906
930
  local function install(std)
907
931
  assert(math and (1/2 ~= 0))
908
932
  std.math = std.math or {}
@@ -937,7 +961,7 @@ install = install
937
961
  }
938
962
  return P
939
963
  end)
940
- b2560[14] = r2560(14, function()
964
+ b259c[14] = r259c(14, function()
941
965
  local function install(std)
942
966
  assert(math and (1/2 ~= 0))
943
967
  std.math = std.math or {}
@@ -953,8 +977,8 @@ install = install
953
977
  }
954
978
  return P
955
979
  end)
956
- b2560[15] = r2560(15, function()
957
- local util_decorator = b2560[29]('source_shared_functional_decorator')
980
+ b259c[15] = r259c(15, function()
981
+ local util_decorator = b259c[29]('source_shared_functional_decorator')
958
982
  local function array_map(array, func)
959
983
  local res = {}
960
984
  local index = 1
@@ -1114,7 +1138,7 @@ install = install
1114
1138
  }
1115
1139
  return P
1116
1140
  end)
1117
- b2560[16] = r2560(16, function()
1141
+ b259c[16] = r259c(16, function()
1118
1142
  local function media_create(node, channels, handler)
1119
1143
  local decorator = function(func)
1120
1144
  func = func or function() end
@@ -1126,6 +1150,7 @@ end
1126
1150
  local self = {
1127
1151
  src = decorator(handler.source),
1128
1152
  play = decorator(handler.play),
1153
+ prepare = decorator(handler.prepare),
1129
1154
  pause = decorator(handler.pause),
1130
1155
  resume = decorator(handler.resume),
1131
1156
  stop = decorator(handler.stop),
@@ -1159,7 +1184,7 @@ install=install
1159
1184
  }
1160
1185
  return P
1161
1186
  end)
1162
- b2560[17] = r2560(17, function()
1187
+ b259c[17] = r259c(17, function()
1163
1188
  local function draw_fps(std, engine, show, pos_x, pos_y)
1164
1189
  if show < 1 then return end
1165
1190
  local x = engine.current.config.offset_x + pos_x
@@ -1207,9 +1232,9 @@ install=install
1207
1232
  }
1208
1233
  return P
1209
1234
  end)
1210
- b2560[18] = r2560(18, function()
1211
- local util_decorator = b2560[29]('source_shared_functional_decorator')
1212
- local function text_put(std, engine, font_previous, pos_x, pos_y, text, size)
1235
+ b259c[18] = r259c(18, function()
1236
+ local function text_put(std, engine, font_previous)
1237
+ return function(pos_x, pos_y, text, size)
1213
1238
  size = size or 2
1214
1239
  local hem = engine.current.data.width / 80
1215
1240
  local vem = engine.current.data.height / 24
@@ -1219,24 +1244,27 @@ std.text.font_size(font_size)
1219
1244
  std.text.print(pos_x * hem, pos_y * vem, text)
1220
1245
  font_previous()
1221
1246
  end
1222
- local function text_print_ex(std, engine, x, y, text, align_x, align_y)
1247
+ end
1248
+ local function text_print_ex(std, engine)
1249
+ return function(x, y, text, align_x, align_y)
1223
1250
  local w, h = std.text.mensure(text)
1224
1251
  local aligns_x, aligns_y = {w, w/2, 0}, {h, h/2, 0}
1225
1252
  std.text.print(x - aligns_x[(align_x or 1) + 2], y - aligns_y[(align_y or 1) + 2], text)
1226
1253
  return w, h
1227
1254
  end
1255
+ end
1228
1256
  local function install(std, engine, config)
1229
1257
  std.text.font_previous = config.font_previous
1230
1258
  std.text.is_tui = config.is_tui or function() return false end
1231
- std.text.print_ex = util_decorator.prefix2(std, engine, text_print_ex)
1232
- std.text.put = util_decorator.prefix3(std, engine, config.font_previous, text_put)
1259
+ std.text.print_ex = text_print_ex(std, engine)
1260
+ std.text.put = text_put(std, engine, config.font_previous)
1233
1261
  end
1234
1262
  local P = {
1235
1263
  install=install
1236
1264
  }
1237
1265
  return P
1238
1266
  end)
1239
- b2560[19] = r2560(19, function()
1267
+ b259c[19] = r259c(19, function()
1240
1268
  local function decorator_poo(object, func)
1241
1269
  if not object or not func then return func end
1242
1270
  return function(a, b, c, d)
@@ -1342,7 +1370,7 @@ install=install
1342
1370
  }
1343
1371
  return P
1344
1372
  end)
1345
- b2560[20] = r2560(20, function()
1373
+ b259c[20] = r259c(20, function()
1346
1374
  local memory_dict_unload = {}
1347
1375
  local memory_dict = {}
1348
1376
  local memory_list = {}
@@ -1396,9 +1424,9 @@ install=install
1396
1424
  }
1397
1425
  return P
1398
1426
  end)
1399
- b2560[21] = r2560(21, function()
1400
- local str_http = b2560[31]('source_shared_string_encode_http')
1401
- local str_url = b2560[32]('source_shared_string_encode_url')
1427
+ b259c[21] = r259c(21, function()
1428
+ local str_http = b259c[31]('source_shared_string_encode_http')
1429
+ local str_url = b259c[32]('source_shared_string_encode_url')
1402
1430
  local callbacks = {
1403
1431
  ['async-promise'] = function(self)
1404
1432
  return self:promise()
@@ -1467,7 +1495,7 @@ func = native_http_callback
1467
1495
  }
1468
1496
  return P
1469
1497
  end)
1470
- b2560[22] = r2560(22, function()
1498
+ b259c[22] = r259c(22, function()
1471
1499
  local P = {
1472
1500
  data={
1473
1501
  width=1280,
@@ -1496,7 +1524,7 @@ callbacks={
1496
1524
  }
1497
1525
  return P;
1498
1526
  end)
1499
- b2560[23] = r2560(23, function()
1527
+ b259c[23] = r259c(23, function()
1500
1528
  local function install(std)
1501
1529
  std.color = std.color or {}
1502
1530
  std.color.white = 0xFFFFFFFF
@@ -1530,7 +1558,7 @@ install = install
1530
1558
  }
1531
1559
  return P
1532
1560
  end)
1533
- b2560[24] = r2560(24, function()
1561
+ b259c[24] = r259c(24, function()
1534
1562
  local P = {
1535
1563
  milis = 0,
1536
1564
  delta = 0,
@@ -1597,7 +1625,7 @@ any=false
1597
1625
  }
1598
1626
  return P;
1599
1627
  end)
1600
- b2560[25] = r2560(25, function()
1628
+ b259c[25] = r259c(25, function()
1601
1629
  local function pipe(self)
1602
1630
  return function()
1603
1631
  self:run()
@@ -1646,7 +1674,7 @@ run=run
1646
1674
  }
1647
1675
  return P
1648
1676
  end)
1649
- b2560[26] = r2560(26, function()
1677
+ b259c[26] = r259c(26, function()
1650
1678
  local function encode(dsl_string)
1651
1679
  local spec = {
1652
1680
  list = {},
@@ -1694,7 +1722,7 @@ should_import = should_import
1694
1722
  }
1695
1723
  return P
1696
1724
  end)
1697
- b2560[27] = r2560(27, function()
1725
+ b259c[27] = r259c(27, function()
1698
1726
  local function script(src)
1699
1727
  local ok, app = false, nil
1700
1728
  if require then
@@ -1719,7 +1747,7 @@ script = script,
1719
1747
  }
1720
1748
  return P
1721
1749
  end)
1722
- b2560[28] = r2560(28, function()
1750
+ b259c[28] = r259c(28, function()
1723
1751
  local function script(src)
1724
1752
  local loader = loadstring or load
1725
1753
  if not loader then
@@ -1739,7 +1767,7 @@ script = script,
1739
1767
  }
1740
1768
  return P
1741
1769
  end)
1742
- b2560[29] = r2560(29, function()
1770
+ b259c[29] = r259c(29, function()
1743
1771
  local function decorator_prefix3(zig, zag, zom, func)
1744
1772
  return function (a, b, c, d, e, f)
1745
1773
  return func(zig, zag, zom, a, b, c, d, e, f)
@@ -1796,7 +1824,7 @@ prefix1_t = table_prefix1
1796
1824
  }
1797
1825
  return P
1798
1826
  end)
1799
- b2560[31] = r2560(31, function()
1827
+ b259c[31] = r259c(31, function()
1800
1828
  local function is_ok(status)
1801
1829
  return (status and 200 <= status and status < 300) or false
1802
1830
  end
@@ -1942,7 +1970,7 @@ get_user_agent=get_user_agent,
1942
1970
  create_request=create_request
1943
1971
  }
1944
1972
  end)
1945
- b2560[32] = r2560(32, function()
1973
+ b259c[32] = r259c(32, function()
1946
1974
  local function search_param(param_list, param_dict)
1947
1975
  local index, params = 1, ''
1948
1976
  while param_list and param_dict and index <= #param_list do
@@ -1963,4 +1991,4 @@ search_param = search_param
1963
1991
  }
1964
1992
  return P
1965
1993
  end)
1966
- return m2560()
1994
+ return m259c()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamely/gly-engine-lite",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "author": "RodrigoDornelles",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://docs.gamely.com.br",