@gamely/gly-engine-lite 0.0.19 → 0.0.21

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 CHANGED
@@ -1,48 +1,48 @@
1
1
  local math = ((function() local x, y = pcall(require, 'math'); return x and y end)()) or _G.math
2
- local src_version_55d740741220 = nil
3
- local src_lib_common_module_55d74078d4c0 = nil
4
- local src_lib_engine_api_encoder_55d740797c20 = nil
5
- local src_lib_engine_api_app_55d7407cdb00 = nil
6
- local src_lib_engine_api_hash_55d740798450 = nil
7
- local src_lib_engine_api_http_55d74079e880 = nil
8
- local src_lib_engine_api_i18n_55d74075aa10 = nil
9
- local src_lib_engine_api_key_55d7407bfbd0 = nil
10
- local src_lib_engine_api_log_55d7407a7ec0 = nil
11
- local src_lib_engine_api_math_55d740799d40 = nil
12
- local src_lib_engine_api_array_55d740779000 = nil
13
- local src_lib_engine_api_media_55d7407489d0 = nil
14
- local src_lib_engine_draw_fps_55d740798890 = nil
15
- local src_lib_engine_draw_text_55d7407c8b90 = nil
16
- local src_lib_engine_draw_poly_55d740799b40 = nil
17
- local src_lib_engine_raw_memory_55d74079abd0 = nil
18
- local src_lib_protocol_http_callback_55d74079bca0 = nil
19
- local src_lib_object_root_55d7407b5bb0 = nil
20
- local src_lib_object_color_55d7407a8380 = nil
21
- local src_lib_object_std_55d74076e7c0 = nil
22
- local src_lib_util_pipeline_55d7407bc4c0 = nil
23
- local src_lib_util_decorator_55d7407a7e30 = nil
24
- local src_lib_util_http_55d74078aa00 = nil
25
- local function main_55d7407a19d0()
26
- local version = src_version_55d740741220()
27
- local zeebo_module = src_lib_common_module_55d74078d4c0()
28
- local engine_encoder = src_lib_engine_api_encoder_55d740797c20()
29
- local engine_game = src_lib_engine_api_app_55d7407cdb00()
30
- local engine_hash = src_lib_engine_api_hash_55d740798450()
31
- local engine_http = src_lib_engine_api_http_55d74079e880()
32
- local engine_i18n = src_lib_engine_api_i18n_55d74075aa10()
33
- local engine_key = src_lib_engine_api_key_55d7407bfbd0()
34
- local engine_log = src_lib_engine_api_log_55d7407a7ec0()
35
- local engine_math = src_lib_engine_api_math_55d740799d40()
36
- local engine_array = src_lib_engine_api_array_55d740779000()
37
- local engine_media = src_lib_engine_api_media_55d7407489d0()
38
- local engine_draw_fps = src_lib_engine_draw_fps_55d740798890()
39
- local engine_draw_text = src_lib_engine_draw_text_55d7407c8b90()
40
- local engine_draw_poly = src_lib_engine_draw_poly_55d740799b40()
41
- local engine_raw_memory = src_lib_engine_raw_memory_55d74079abd0()
42
- local callback_http = src_lib_protocol_http_callback_55d74079bca0()
43
- local application_default = src_lib_object_root_55d7407b5bb0()
44
- local color = src_lib_object_color_55d7407a8380()
45
- local std = src_lib_object_std_55d74076e7c0()
2
+ local src_version_560c51e6c020 = nil
3
+ local src_lib_common_module_560c51e81030 = nil
4
+ local src_lib_engine_api_encoder_560c51e671b0 = nil
5
+ local src_lib_engine_api_app_560c51e67890 = nil
6
+ local src_lib_engine_api_hash_560c51e82110 = nil
7
+ local src_lib_engine_api_http_560c51e8b270 = nil
8
+ local src_lib_engine_api_i18n_560c51e5e8f0 = nil
9
+ local src_lib_engine_api_key_560c51e7f130 = nil
10
+ local src_lib_engine_api_log_560c51e8c2a0 = nil
11
+ local src_lib_engine_api_math_560c51e81c30 = nil
12
+ local src_lib_engine_api_array_560c51e81500 = nil
13
+ local src_lib_engine_api_media_560c51e62230 = nil
14
+ local src_lib_engine_draw_fps_560c51e694a0 = nil
15
+ local src_lib_engine_draw_text_560c51e69bd0 = nil
16
+ local src_lib_engine_draw_poly_560c51e7e7e0 = nil
17
+ local src_lib_engine_raw_memory_560c51e82820 = nil
18
+ local src_lib_protocol_http_callback_560c51e7c810 = nil
19
+ local src_lib_object_root_560c51e6d3f0 = nil
20
+ local src_lib_object_color_560c51e80600 = nil
21
+ local src_lib_object_std_560c51e7d900 = nil
22
+ local src_lib_util_pipeline_560c51e36e60 = nil
23
+ local src_lib_util_decorator_560c51e7fd40 = nil
24
+ local src_lib_util_http_560c51e3c4b0 = nil
25
+ local function main_560c51e83670()
26
+ local version = src_version_560c51e6c020()
27
+ local zeebo_module = src_lib_common_module_560c51e81030()
28
+ local engine_encoder = src_lib_engine_api_encoder_560c51e671b0()
29
+ local engine_game = src_lib_engine_api_app_560c51e67890()
30
+ local engine_hash = src_lib_engine_api_hash_560c51e82110()
31
+ local engine_http = src_lib_engine_api_http_560c51e8b270()
32
+ local engine_i18n = src_lib_engine_api_i18n_560c51e5e8f0()
33
+ local engine_key = src_lib_engine_api_key_560c51e7f130()
34
+ local engine_log = src_lib_engine_api_log_560c51e8c2a0()
35
+ local engine_math = src_lib_engine_api_math_560c51e81c30()
36
+ local engine_array = src_lib_engine_api_array_560c51e81500()
37
+ local engine_media = src_lib_engine_api_media_560c51e62230()
38
+ local engine_draw_fps = src_lib_engine_draw_fps_560c51e694a0()
39
+ local engine_draw_text = src_lib_engine_draw_text_560c51e69bd0()
40
+ local engine_draw_poly = src_lib_engine_draw_poly_560c51e7e7e0()
41
+ local engine_raw_memory = src_lib_engine_raw_memory_560c51e82820()
42
+ local callback_http = src_lib_protocol_http_callback_560c51e7c810()
43
+ local application_default = src_lib_object_root_560c51e6d3f0()
44
+ local color = src_lib_object_color_560c51e80600()
45
+ local std = src_lib_object_std_560c51e7d900()
46
46
  local application = application_default
47
47
  local engine = {
48
48
  keyboard = function(a, b, c, d) end,
@@ -61,9 +61,11 @@ local cfg_media = {
61
61
  bootstrap=native_media_bootstrap,
62
62
  position=native_media_position,
63
63
  resize=native_media_resize,
64
+ resume=native_media_resume,
65
+ source=native_media_source,
64
66
  pause=native_media_pause,
65
- load=native_media_load,
66
- play=native_media_play
67
+ play=native_media_play,
68
+ stop=native_media_stop
67
69
  }
68
70
  local cfg_poly = {
69
71
  repeats = {
@@ -148,7 +150,9 @@ std.draw.color=native_draw_color
148
150
  std.draw.font=native_draw_font
149
151
  std.draw.rect=native_draw_rect
150
152
  std.draw.line=native_draw_line
151
- std.draw.image=native_draw_image
153
+ std.draw.image=native_image_draw
154
+ std.image.load=native_image_load
155
+ std.image.draw=native_image_draw
152
156
  std.text.print=native_text_print
153
157
  std.text.mensure=native_text_mensure
154
158
  std.text.font_size=native_text_font_size
@@ -170,6 +174,7 @@ zeebo_module.require(std, application, engine)
170
174
  :package('@color', color)
171
175
  :package('@log', engine_log, cfg_log)
172
176
  :package('math', engine_math.clib)
177
+ :package('math.wave', engine_math.wave)
173
178
  :package('math.random', engine_math.clib_random)
174
179
  :package('http', engine_http, cfg_http)
175
180
  :package('base64', engine_encoder, cfg_base64)
@@ -178,7 +183,6 @@ zeebo_module.require(std, application, engine)
178
183
  :package('i18n', engine_i18n, cfg_system)
179
184
  :package('hash', engine_hash, cfg_system)
180
185
  :package('media.video', engine_media, cfg_media)
181
- :package('media.audio', engine_media, cfg_media)
182
186
  :package('mock.video', engine_media)
183
187
  :package('mock.audio', engine_media)
184
188
  :run()
@@ -198,13 +202,13 @@ version=version
198
202
  }
199
203
  return P
200
204
  end
201
- src_version_55d740741220 = function()
202
- return '0.0.19'
205
+ src_version_560c51e6c020 = function()
206
+ return '0.0.21'
203
207
  end
204
208
  --
205
- src_lib_common_module_55d74078d4c0 = function()
206
- local zeebo_pipeline = src_lib_util_pipeline_55d7407bc4c0()
207
- local application_default = src_lib_object_root_55d7407b5bb0()
209
+ src_lib_common_module_560c51e81030 = function()
210
+ local zeebo_pipeline = src_lib_util_pipeline_560c51e36e60()
211
+ local application_default = src_lib_object_root_560c51e6d3f0()
208
212
  local function default(application, defaults)
209
213
  if not application then return nil end
210
214
  local index = 1
@@ -222,6 +226,7 @@ end
222
226
  index = index + 1
223
227
  end
224
228
  normalized_aplication.config.id = tostring(application)
229
+ normalized_aplication.fonts = application.fonts or {}
225
230
  normalized_aplication.assets = application.assets or {}
226
231
  if application.callbacks then
227
232
  for event, handler in pairs(application.callbacks) do
@@ -244,6 +249,7 @@ end
244
249
  local normalized_aplication = {
245
250
  data = {},
246
251
  meta = {},
252
+ fonts = {},
247
253
  assets = {},
248
254
  config = {},
249
255
  callbacks = {}
@@ -251,6 +257,8 @@ callbacks = {}
251
257
  for key, value in pairs(application) do
252
258
  if key == 'assets' then
253
259
  normalized_aplication.assets = value
260
+ elseif key == 'fonts' then
261
+ normalized_aplication.fonts = value
254
262
  elseif application_default.meta[key] then
255
263
  normalized_aplication.meta[key] = value
256
264
  elseif application_default.config[key] then
@@ -402,7 +410,7 @@ require = require
402
410
  return P
403
411
  end
404
412
  --
405
- src_lib_engine_api_encoder_55d740797c20 = function()
413
+ src_lib_engine_api_encoder_560c51e671b0 = function()
406
414
  local function install(std, engine, library, name)
407
415
  std = std or {}
408
416
  std[name] = {
@@ -417,8 +425,8 @@ install=install
417
425
  return P
418
426
  end
419
427
  --
420
- src_lib_engine_api_app_55d7407cdb00 = function()
421
- local util_decorator = src_lib_util_decorator_55d7407a7e30()
428
+ src_lib_engine_api_app_560c51e67890 = function()
429
+ local util_decorator = src_lib_util_decorator_560c51e7fd40()
422
430
  local function reset(std, engine)
423
431
  if std.node then
424
432
  std.bus.emit('exit')
@@ -458,7 +466,7 @@ install=install
458
466
  return P
459
467
  end
460
468
  --
461
- src_lib_engine_api_hash_55d740798450 = function()
469
+ src_lib_engine_api_hash_560c51e82110 = function()
462
470
  local function djb2(digest)
463
471
  local index = 1
464
472
  local hash = 5381
@@ -484,26 +492,38 @@ install = install
484
492
  return P
485
493
  end
486
494
  --
487
- src_lib_engine_api_http_55d74079e880 = function()
488
- local zeebo_pipeline = src_lib_util_pipeline_55d7407bc4c0()
489
- local function fast(self)
490
- self.speed = '_fast'
495
+ src_lib_engine_api_http_560c51e8b270 = function()
496
+ local zeebo_pipeline = src_lib_util_pipeline_560c51e36e60()
497
+ local function json(self)
498
+ self.options['json'] = true
491
499
  return self
492
500
  end
493
- local function body(self, content)
494
- self.body_content=content
501
+ local function noforce(self)
502
+ self.options['noforce'] = true
503
+ return self
504
+ end
505
+ local function fast(self)
506
+ self.speed = '_fast'
495
507
  return self
496
508
  end
497
509
  local function param(self, name, value)
498
510
  local index = #self.param_list + 1
499
- self.param_list[index] = name
500
- self.param_dict[name] = value
511
+ self.param_list[index] = tostring(name)
512
+ self.param_dict[name] = tostring(value)
501
513
  return self
502
514
  end
503
515
  local function header(self, name, value)
504
516
  local index = #self.header_list + 1
505
- self.header_list[index] = name
506
- self.header_dict[name] = value
517
+ self.header_list[index] = tostring(name)
518
+ self.header_dict[name] = tostring(value)
519
+ return self
520
+ end
521
+ local function body(self, content, json_encode)
522
+ if type(content) == 'table' then
523
+ header(self, 'Content-Type', 'application/json')
524
+ content = json_encode(content)
525
+ end
526
+ self.body_content=content
507
527
  return self
508
528
  end
509
529
  local function success(self, handler_func)
@@ -530,14 +550,15 @@ return function (url)
530
550
  if protocol.has_callback then
531
551
  engine.http_count = engine.http_count + 1
532
552
  end
533
- if protocol.force then
534
- url = url:gsub("^[^:]+://", protocol.force.."://")
535
- end
553
+ local json_encode = std.json and std.json.encode
554
+ local json_decode = std.json and std.json.decode
555
+ local http_body = function(self, content) return body(self, content, json_encode) end
536
556
  local game = engine.current.data
537
557
  local self = {
538
558
  id = engine.http_count,
539
559
  url = url,
540
560
  speed = '',
561
+ options = {},
541
562
  method = method,
542
563
  body_content = '',
543
564
  header_list = {},
@@ -548,7 +569,9 @@ success_handler = function (std, game) end,
548
569
  failed_handler = function (std, game) end,
549
570
  error_handler = function (std, game) end,
550
571
  fast = fast,
551
- body = body,
572
+ json = json,
573
+ noforce = noforce,
574
+ body = http_body,
552
575
  param = param,
553
576
  header = header,
554
577
  success = success,
@@ -567,14 +590,29 @@ std.http[key] = value
567
590
  end
568
591
  self.pipeline = {
569
592
  function()
593
+ if not protocol.force or self.options['noforce'] then return end
594
+ self.url = url:gsub("^[^:]+://", protocol.force.."://")
595
+ end,
596
+ function()
570
597
  if protocol.has_callback then engine.http_requests[self.id] = self end
571
598
  protocol.handler(self, self.id)
572
599
  end,
573
600
  function()
601
+ if self.options['json'] and json_decode and std.http.body then
602
+ pcall(function()
603
+ local new_body = json_decode(std.http.body)
604
+ std.http.body = new_body
605
+ end)
606
+ end
607
+ end,
608
+ function()
574
609
  callback_handler(std, game)
575
610
  if std.http.ok then
576
611
  self.success_handler(std, game)
577
- elseif std.http.error or not std.http.status then
612
+ elseif std.http.error then
613
+ self.error_handler(std, game)
614
+ elseif not std.http.status then
615
+ self.set('error', 'missing protocol response')
578
616
  self.error_handler(std, game)
579
617
  else
580
618
  self.failed_handler(std, game)
@@ -585,6 +623,7 @@ std.http.ok = nil
585
623
  std.http.body = nil
586
624
  std.http.error = nil
587
625
  std.http.status = nil
626
+ std.http.body_is_table = nil
588
627
  end,
589
628
  function()
590
629
  if protocol.has_callback then engine.http_requests[self.id] = nil end
@@ -595,7 +634,7 @@ return self
595
634
  end
596
635
  end
597
636
  local function install(std, engine, protocol)
598
- assert(protocol.handler, 'missing protocol handler')
637
+ assert(protocol and protocol.handler, 'missing protocol handler')
599
638
  if protocol.has_callback then
600
639
  engine.http_count = 0
601
640
  engine.http_requests = {}
@@ -617,7 +656,7 @@ install=install
617
656
  return P
618
657
  end
619
658
  --
620
- src_lib_engine_api_i18n_55d74075aa10 = function()
659
+ src_lib_engine_api_i18n_560c51e5e8f0 = function()
621
660
  local language = 'en-US'
622
661
  local language_default = 'en-US'
623
662
  local language_list = {}
@@ -709,7 +748,7 @@ install=install
709
748
  return P
710
749
  end
711
750
  --
712
- src_lib_engine_api_key_55d7407bfbd0 = function()
751
+ src_lib_engine_api_key_560c51e7f130 = function()
713
752
  local function real_key(std, engine, rkey, rvalue)
714
753
  local value = rvalue == 1 or rvalue == true
715
754
  local key = engine.key_bindings[rkey] or (std.key.axis[rkey] and rkey)
@@ -749,8 +788,8 @@ install = install
749
788
  return P
750
789
  end
751
790
  --
752
- src_lib_engine_api_log_55d7407a7ec0 = function()
753
- local util_decorator = src_lib_util_decorator_55d7407a7e30()
791
+ src_lib_engine_api_log_560c51e8c2a0 = function()
792
+ local util_decorator = src_lib_util_decorator_560c51e7fd40()
754
793
  local logging_types = {
755
794
  'none', 'fatal', 'error', 'warn', 'debug', 'info'
756
795
  }
@@ -796,7 +835,7 @@ install = install
796
835
  return P
797
836
  end
798
837
  --
799
- src_lib_engine_api_math_55d740799d40 = function()
838
+ src_lib_engine_api_math_560c51e81c30 = function()
800
839
  local function abs(value)
801
840
  if value < 0 then
802
841
  return -value
@@ -875,8 +914,31 @@ index = index + 1
875
914
  end
876
915
  return min_value
877
916
  end
917
+ local function sine(t, freq)
918
+ return math.pi and math.sin(2 * math.pi * freq * t) or 1
919
+ end
920
+ local function ramp(t, freq, ratio)
921
+ t = (t / 2) % (1 / freq) * freq
922
+ if t < ratio then
923
+ return 2 * t / ratio - 1
924
+ else
925
+ return (2 * t - ratio - 1) / (ratio - 1)
926
+ end
927
+ end
928
+ local function saw(t, freq)
929
+ return ramp(t, freq, 1)
930
+ end
931
+ local function triangle(t, freq)
932
+ return ramp(t, freq, 1/2)
933
+ end
934
+ local function rect(t, freq, duty)
935
+ duty = 1 - duty * 2
936
+ return saw(t, freq) > duty and 1 or -1
937
+ end
938
+ local function square(t, freq)
939
+ return rect(t, freq, 1/2)
940
+ end
878
941
  local function install(std)
879
- std = std or {}
880
942
  std.math = std.math or {}
881
943
  std.math.abs=abs
882
944
  std.math.clamp=clamp
@@ -889,10 +951,15 @@ std.math.lerp=lerp
889
951
  std.math.map=map
890
952
  std.math.max=max
891
953
  std.math.min=min
892
- return std.math
954
+ end
955
+ local function install_wave(std)
956
+ std.math = std.math or {}
957
+ std.math.sine=sine
958
+ std.math.saw=saw
959
+ std.math.square=square
960
+ std.math.triangle=triangle
893
961
  end
894
962
  local function install_clib(std)
895
- std = std or {}
896
963
  std.math = std.math or {}
897
964
  std.math.acos=math.acos
898
965
  std.math.asin=math.asin
@@ -919,20 +986,20 @@ std.math.sinh=math.sinh
919
986
  std.math.sqrt=math.sqrt
920
987
  std.math.tan=math.tan
921
988
  std.math.tanh=math.tanh
922
- return std.math
923
989
  end
924
990
  local function install_clib_random(std)
925
- std = std or {}
926
991
  std.math = std.math or {}
927
992
  std.math.random = function(a, b)
928
993
  a = a and math.floor(a)
929
994
  b = b and math.floor(b)
930
995
  return math.random(a, b)
931
996
  end
932
- return std.math
933
997
  end
934
998
  local P = {
935
999
  install = install,
1000
+ wave = {
1001
+ install = install_wave
1002
+ },
936
1003
  clib = {
937
1004
  install = install_clib
938
1005
  },
@@ -943,8 +1010,8 @@ install = install_clib_random
943
1010
  return P;
944
1011
  end
945
1012
  --
946
- src_lib_engine_api_array_55d740779000 = function()
947
- local util_decorator = src_lib_util_decorator_55d7407a7e30()
1013
+ src_lib_engine_api_array_560c51e81500 = function()
1014
+ local util_decorator = src_lib_util_decorator_560c51e7fd40()
948
1015
  local function array_map(array, func)
949
1016
  local res = {}
950
1017
  local index = 1
@@ -1105,77 +1172,45 @@ install = install
1105
1172
  return P
1106
1173
  end
1107
1174
  --
1108
- src_lib_engine_api_media_55d7407489d0 = function()
1109
- local util_decorator = src_lib_util_decorator_55d7407a7e30()
1110
- local function media_add(media, func, self, src)
1111
- func(media - 1, self.id - 1, src)
1112
- return self
1113
- end
1114
- local function media_play(media, func, self)
1115
- func(media - 1, self.id - 1)
1175
+ src_lib_engine_api_media_560c51e62230 = function()
1176
+ local function media_create(node, channels, handler)
1177
+ local decorator = function(func)
1178
+ func = func or function() end
1179
+ return function(self, a, b, c)
1180
+ func(0, a, b, c)
1116
1181
  return self
1117
1182
  end
1118
- local function media_pause(media, func, self)
1119
- func(media - 1, self.id - 1)
1120
- return self
1121
- end
1122
- local function media_resize(media, func, self, width, height)
1123
- func(media - 1, self.id - 1, width, height)
1124
- return self
1125
1183
  end
1126
- local function media_position(media, func, self, pos_x, pos_y)
1127
- func(media - 1, self.id - 1, pos_x, pos_y)
1128
- return self
1129
- end
1130
- local function media_channel(std, handler, mediatype, mediaid, max_channels)
1131
- return function(id)
1132
- local channels = std.media.channels[mediaid]
1133
- id = id or 1
1134
- if 0 >= id or id > max_channels then
1135
- error('Please, do not do that!')
1136
- end
1137
- if not channels[id] then
1138
- channels[id] = {
1139
- id = id,
1140
- add = util_decorator.prefix2(mediaid, handler.load, media_add),
1141
- play = util_decorator.prefix2(mediaid, handler.play, media_play),
1142
- pause = util_decorator.prefix2(mediaid, handler.pause, media_pause),
1143
- resize = util_decorator.prefix2(mediaid, handler.resize, media_resize),
1144
- position = util_decorator.prefix2(mediaid, handler.position, media_position)
1184
+ local self = {
1185
+ src = decorator(handler.source),
1186
+ play = decorator(handler.play),
1187
+ pause = decorator(handler.pause),
1188
+ resume = decorator(handler.resume),
1189
+ stop = decorator(handler.stop),
1190
+ position = decorator(handler.position),
1191
+ resize = decorator(handler.resize),
1192
+ in_mutex = handler.mutex or function() return false end,
1193
+ get_error = handler.error or function() return nil end,
1194
+ node = node,
1195
+ apply = function() end
1145
1196
  }
1146
- if std.node then
1147
- channels[id].node = std.node.load({})
1148
- channels[id].apply = function()
1149
- local node = channels[id].node
1150
- local depth = 0
1151
- local offset_x = 0
1152
- local offset_y = 0
1153
- while node and depth < 100 do
1154
- offset_x = offset_x + node.config.offset_x
1155
- offset_y = offset_y + node.config.offset_y
1156
- node = node.config.parent
1157
- depth = depth + 1
1158
- end
1159
- media_position(handler.position, channels[id], offset_x, offset_y)
1160
- media_resize(handler.resize, channels[id], channels[id].node.data.width, channels[id].node.data.height)
1161
- end
1162
- end
1163
- end
1164
- return channels[id]
1197
+ return function()
1198
+ return self
1165
1199
  end
1166
1200
  end
1167
- local function install(std, engine, handlers, name)
1168
- handlers = handlers or {}
1201
+ local function install(std, engine, handler, name)
1169
1202
  std.media = std.media or {}
1170
- std.media.types = std.media.types or {}
1171
- std.media.channels = std.media.channels or {}
1172
1203
  local mediatype = name:match('%w+%.(%w+)')
1173
- local mediaid = #std.media.types + 1
1204
+ if handler.install then
1205
+ handler.install(std, engine, mediatype, name)
1206
+ end
1174
1207
  if not std.media[mediatype] then
1175
- local max_channels = handlers.bootstrap and handlers.bootstrap(mediaid - 1, mediatype) or 8
1176
- std.media.channels[mediaid] = {}
1177
- std.media.types[mediaid] = mediatype
1178
- std.media[mediatype] = media_channel(std, handlers, mediatype, mediaid, max_channels)
1208
+ local channels = handler.bootstrap and handler.bootstrap(mediatype)
1209
+ if (not channels or channels == 0) and handler.bootstrap then
1210
+ error('media '..mediatype..' is not supported!')
1211
+ end
1212
+ local node = std.node and std.node.load({})
1213
+ std.media[mediatype] = media_create(node, channels, handler)
1179
1214
  end
1180
1215
  end
1181
1216
  local P = {
@@ -1184,7 +1219,7 @@ install=install
1184
1219
  return P
1185
1220
  end
1186
1221
  --
1187
- src_lib_engine_draw_fps_55d740798890 = function()
1222
+ src_lib_engine_draw_fps_560c51e694a0 = function()
1188
1223
  local function draw_fps(std, engine, show, pos_x, pos_y)
1189
1224
  if show < 1 then return end
1190
1225
  local x = engine.current.config.offset_x + pos_x
@@ -1236,8 +1271,8 @@ install=install
1236
1271
  return P
1237
1272
  end
1238
1273
  --
1239
- src_lib_engine_draw_text_55d7407c8b90 = function()
1240
- local util_decorator = src_lib_util_decorator_55d7407a7e30()
1274
+ src_lib_engine_draw_text_560c51e69bd0 = function()
1275
+ local util_decorator = src_lib_util_decorator_560c51e7fd40()
1241
1276
  local function text_put(std, engine, font_previous, pos_x, pos_y, text, size)
1242
1277
  size = size or 2
1243
1278
  local hem = engine.current.data.width / 80
@@ -1248,10 +1283,10 @@ std.text.font_size(font_size)
1248
1283
  std.text.print(pos_x * hem, pos_y * vem, text)
1249
1284
  font_previous()
1250
1285
  end
1251
- local function text_print_ex(std, engine, x, y, text, align)
1286
+ local function text_print_ex(std, engine, x, y, text, align_x, align_y)
1252
1287
  local w, h = std.text.mensure(text)
1253
- local aligns = {w, w/2, 0}
1254
- std.text.print(x - aligns[(align or 1) + 2], y, text)
1288
+ local aligns_x, aligns_y = {w, w/2, 0}, {h, h/2, 0}
1289
+ std.text.print(x - aligns_x[(align_x or 1) + 2], y - aligns_y[(align_y or 1) + 2], text)
1255
1290
  return w, h
1256
1291
  end
1257
1292
  local function install(std, engine, config)
@@ -1264,7 +1299,7 @@ install=install
1264
1299
  return P
1265
1300
  end
1266
1301
  --
1267
- src_lib_engine_draw_poly_55d740799b40 = function()
1302
+ src_lib_engine_draw_poly_560c51e7e7e0 = function()
1268
1303
  local function decorator_poo(object, func)
1269
1304
  if not object or not func then return func end
1270
1305
  return function(a, b, c, d)
@@ -1371,7 +1406,7 @@ install=install
1371
1406
  return P
1372
1407
  end
1373
1408
  --
1374
- src_lib_engine_raw_memory_55d74079abd0 = function()
1409
+ src_lib_engine_raw_memory_560c51e82820 = function()
1375
1410
  local memory_dict_unload = {}
1376
1411
  local memory_dict = {}
1377
1412
  local memory_list = {}
@@ -1426,8 +1461,8 @@ install=install
1426
1461
  return P
1427
1462
  end
1428
1463
  --
1429
- src_lib_protocol_http_callback_55d74079bca0 = function()
1430
- local http_util = src_lib_util_http_55d74078aa00()
1464
+ src_lib_protocol_http_callback_560c51e7c810 = function()
1465
+ local http_util = src_lib_util_http_560c51e3c4b0()
1431
1466
  local callbacks = {
1432
1467
  ['async-promise'] = function(self)
1433
1468
  return self:promise()
@@ -1494,7 +1529,7 @@ func = native_http_callback
1494
1529
  return P
1495
1530
  end
1496
1531
  --
1497
- src_lib_object_root_55d7407b5bb0 = function()
1532
+ src_lib_object_root_560c51e6d3f0 = function()
1498
1533
  local P = {
1499
1534
  data={
1500
1535
  width=1280,
@@ -1524,61 +1559,34 @@ callbacks={
1524
1559
  return P;
1525
1560
  end
1526
1561
  --
1527
- src_lib_object_color_55d7407a8380 = function()
1528
- local white = 0xFFFFFFFF
1529
- local lightgray = 0xC8CCCCFF
1530
- local gray = 0x828282FF
1531
- local darkgray = 0x505050FF
1532
- local yellow = 0xFDF900FF
1533
- local gold = 0xFFCB00FF
1534
- local orange = 0xFFA100FF
1535
- local pink = 0xFF6DC2FF
1536
- local red = 0xE62937FF
1537
- local maroon = 0xBE2137FF
1538
- local green = 0x00E430FF
1539
- local lime = 0x009E2FFF
1540
- local darkgreen = 0x00752CFF
1541
- local skyblue = 0x66BFFFFF
1542
- local blue = 0x0079F1FF
1543
- local darkblue = 0x0052ACFF
1544
- local purple = 0xC87AFFFF
1545
- local violet = 0x873CBEFF
1546
- local darkpurple = 0x701F7EFF
1547
- local beige = 0xD3B083FF
1548
- local brown = 0x7F6A4FFF
1549
- local darkbrown = 0x4C3F2FFF
1550
- local black = 0x000000FF
1551
- local blank = 0x00000000
1552
- local magenta = 0xFF00FFFF
1562
+ src_lib_object_color_560c51e80600 = function()
1553
1563
  local function install(std)
1554
- std = std or {}
1555
1564
  std.color = std.color or {}
1556
- std.color.white = white
1557
- std.color.lightgray = lightgray
1558
- std.color.gray = gray
1559
- std.color.darkgray = darkgray
1560
- std.color.yellow = yellow
1561
- std.color.gold = gold
1562
- std.color.orange = orange
1563
- std.color.pink = pink
1564
- std.color.red = red
1565
- std.color.maroon = maroon
1566
- std.color.green = green
1567
- std.color.lime = lime
1568
- std.color.darkgreen = darkgreen
1569
- std.color.skyblue = skyblue
1570
- std.color.blue = blue
1571
- std.color.darkblue = darkblue
1572
- std.color.purple = purple
1573
- std.color.violet = violet
1574
- std.color.darkpurple = darkpurple
1575
- std.color.beige = beige
1576
- std.color.brown = brown
1577
- std.color.darkbrown = darkbrown
1578
- std.color.black = black
1579
- std.color.blank = blank
1580
- std.color.magenta = magenta
1581
- return std.color
1565
+ std.color.white = 0xFFFFFFFF
1566
+ std.color.lightgray = 0xC8CCCCFF
1567
+ std.color.gray = 0x828282FF
1568
+ std.color.darkgray = 0x505050FF
1569
+ std.color.yellow = 0xFDF900FF
1570
+ std.color.gold = 0xFFCB00FF
1571
+ std.color.orange = 0xFFA100FF
1572
+ std.color.pink = 0xFF6DC2FF
1573
+ std.color.red = 0xE62937FF
1574
+ std.color.maroon = 0xBE2137FF
1575
+ std.color.green = 0x00E430FF
1576
+ std.color.lime = 0x009E2FFF
1577
+ std.color.darkgreen = 0x00752CFF
1578
+ std.color.skyblue = 0x66BFFFFF
1579
+ std.color.blue = 0x0079F1FF
1580
+ std.color.darkblue = 0x0052ACFF
1581
+ std.color.purple = 0xC87AFFFF
1582
+ std.color.violet = 0x873CBEFF
1583
+ std.color.darkpurple = 0x701F7EFF
1584
+ std.color.beige = 0xD3B083FF
1585
+ std.color.brown = 0x7F6A4FFF
1586
+ std.color.darkbrown = 0x4C3F2FFF
1587
+ std.color.black = 0x000000FF
1588
+ std.color.blank = 0x00000000
1589
+ std.color.magenta = 0xFF00FFFF
1582
1590
  end
1583
1591
  local P = {
1584
1592
  install = install
@@ -1586,7 +1594,7 @@ install = install
1586
1594
  return P
1587
1595
  end
1588
1596
  --
1589
- src_lib_object_std_55d74076e7c0 = function()
1597
+ src_lib_object_std_560c51e7d900 = function()
1590
1598
  local P = {
1591
1599
  milis = 0,
1592
1600
  delta = 0,
@@ -1609,6 +1617,10 @@ font_size = function() end,
1609
1617
  font_name = function() end,
1610
1618
  font_default = function() end
1611
1619
  },
1620
+ image = {
1621
+ load = function() end,
1622
+ draw = function() end
1623
+ },
1612
1624
  app = {
1613
1625
  width = 1280,
1614
1626
  height = 720,
@@ -1648,7 +1660,7 @@ any=false
1648
1660
  return P;
1649
1661
  end
1650
1662
  --
1651
- src_lib_util_pipeline_55d7407bc4c0 = function()
1663
+ src_lib_util_pipeline_560c51e36e60 = function()
1652
1664
  local function pipe(self)
1653
1665
  return function()
1654
1666
  self:run()
@@ -1698,7 +1710,7 @@ run=run
1698
1710
  return P
1699
1711
  end
1700
1712
  --
1701
- src_lib_util_decorator_55d7407a7e30 = function()
1713
+ src_lib_util_decorator_560c51e7fd40 = function()
1702
1714
  local function decorator_prefix3(zig, zag, zom, func)
1703
1715
  return function (a, b, c, d, e, f)
1704
1716
  return func(zig, zag, zom, a, b, c, d, e, f)
@@ -1737,18 +1749,26 @@ local y = object.offset_y + b
1737
1749
  return func(x, y, c, d, e, f)
1738
1750
  end
1739
1751
  end
1752
+ local function table_prefix1(prefix, fn_table)
1753
+ local new_table = {}
1754
+ for name, fn in pairs(fn_table) do
1755
+ new_table[name] = decorator_prefix1(prefix, fn)
1756
+ end
1757
+ return new_table
1758
+ end
1740
1759
  local P = {
1741
1760
  offset_xy1 = decorator_offset_xy1,
1742
1761
  offset_xy2 = decorator_offset_xy2,
1743
1762
  offset_xyxy1 = decorator_offset_xyxy1,
1744
1763
  prefix3 = decorator_prefix3,
1745
1764
  prefix2 = decorator_prefix2,
1746
- prefix1 = decorator_prefix1
1765
+ prefix1 = decorator_prefix1,
1766
+ prefix1_t = table_prefix1
1747
1767
  }
1748
1768
  return P
1749
1769
  end
1750
1770
  --
1751
- src_lib_util_http_55d74078aa00 = function()
1771
+ src_lib_util_http_560c51e3c4b0 = function()
1752
1772
  local function is_ok(status)
1753
1773
  return (status and 200 <= status and status < 300) or false
1754
1774
  end
@@ -1760,6 +1780,18 @@ end
1760
1780
  local function is_redirect(status)
1761
1781
  return (status and 300 <= status and status < 400) or false
1762
1782
  end
1783
+ local function get_content(response)
1784
+ local header, body = response:match("^(.-\r\n\r\n)(.*)")
1785
+ if not header or not body then return nil end
1786
+ local content_length = tonumber(header:match("Content%-Length:%s*(%d+)"))
1787
+ if not content_length then return nil end
1788
+ if #body < content_length then return nil end
1789
+ local content = body:sub(1, content_length)
1790
+ return content
1791
+ end
1792
+ local function get_user_agent()
1793
+ return 'Ginga (GlyOS;SmartTv/Linux)'
1794
+ end
1763
1795
  local function url_search_param(param_list, param_dict)
1764
1796
  local index, params = 1, ''
1765
1797
  while param_list and param_dict and index <= #param_list do
@@ -1770,7 +1802,7 @@ params = params..'?'
1770
1802
  else
1771
1803
  params = params..'&'
1772
1804
  end
1773
- params = params..param..'='..(value or '')
1805
+ params = params..param:gsub(' ', '%20')..'='..(value or ''):gsub(' ', '%20')
1774
1806
  index = index + 1
1775
1807
  end
1776
1808
  return params
@@ -1829,7 +1861,7 @@ return self
1829
1861
  end
1830
1862
  self.to_http_protocol = function ()
1831
1863
  local index = 1
1832
- local request = method..' '..uri..' HTTP/1.1\r\n'
1864
+ local request = method..' '..uri..' HTTP/1'..'.1\r\n'
1833
1865
  while index <= #self.header_list do
1834
1866
  local header = self.header_list[index]
1835
1867
  local value = self.header_dict[header]
@@ -1892,9 +1924,11 @@ return {
1892
1924
  is_ok=is_ok,
1893
1925
  is_ok_header=is_ok_header,
1894
1926
  is_redirect=is_redirect,
1927
+ get_content=get_content,
1928
+ get_user_agent=get_user_agent,
1895
1929
  url_search_param=url_search_param,
1896
1930
  create_request=create_request
1897
1931
  }
1898
1932
  end
1899
1933
  --
1900
- return main_55d7407a19d0()
1934
+ return main_560c51e83670()
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "@gamely/gly-engine-lite",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "author": "RodrigoDornelles",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://docs.gamely.com.br",
7
- "repository": "https://github.com/gamelly/gly-engine",
7
+ "repository": "https://github.com/gly-engine/gly-engine",
8
8
  "funding": "https://github.com/sponsors/RodrigoDornelles",
9
- "bugs": "https://github.com/gamelly/gly-engine/issues",
9
+ "bugs": "https://github.com/gly-engine/gly-engine/issues",
10
10
  "description": "Game Engine written in 100% lua that runs in a vacuum.",
11
11
  "main": "dist/main.lua",
12
+ "browser": "dist/main.lua",
13
+ "types": "types/main.d.ts",
12
14
  "keywords": [
13
15
  "game engine",
14
16
  "game",
@@ -0,0 +1,4 @@
1
+ declare module '@gamely/gly-engine-lite' {
2
+ const content: string;
3
+ export default content;
4
+ }