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