@gamely/gly-engine-lite 0.0.18 → 0.0.20
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 +517 -218
- package/package.json +3 -2
- package/types/main.d.ts +4 -0
package/dist/main.lua
CHANGED
|
@@ -1,43 +1,48 @@
|
|
|
1
1
|
local math = ((function() local x, y = pcall(require, 'math'); return x and y end)()) or _G.math
|
|
2
|
-
local
|
|
3
|
-
local
|
|
4
|
-
local
|
|
5
|
-
local
|
|
6
|
-
local
|
|
7
|
-
local
|
|
8
|
-
local
|
|
9
|
-
local
|
|
10
|
-
local
|
|
11
|
-
local
|
|
12
|
-
local
|
|
13
|
-
local
|
|
14
|
-
local
|
|
15
|
-
local
|
|
16
|
-
local
|
|
17
|
-
local
|
|
18
|
-
local
|
|
19
|
-
local
|
|
20
|
-
local
|
|
21
|
-
local
|
|
22
|
-
local
|
|
23
|
-
local
|
|
24
|
-
local
|
|
25
|
-
local
|
|
26
|
-
local
|
|
27
|
-
local
|
|
28
|
-
local
|
|
29
|
-
local
|
|
30
|
-
local
|
|
31
|
-
local
|
|
32
|
-
local
|
|
33
|
-
local
|
|
34
|
-
local
|
|
35
|
-
local
|
|
36
|
-
local
|
|
37
|
-
local
|
|
38
|
-
local
|
|
39
|
-
local
|
|
40
|
-
local
|
|
2
|
+
local src_version_55789ed81210 = nil
|
|
3
|
+
local src_lib_common_module_55789ed58c40 = nil
|
|
4
|
+
local src_lib_engine_api_encoder_55789ed92660 = nil
|
|
5
|
+
local src_lib_engine_api_app_55789eda8c90 = nil
|
|
6
|
+
local src_lib_engine_api_hash_55789ed5fba0 = nil
|
|
7
|
+
local src_lib_engine_api_http_55789ed73940 = nil
|
|
8
|
+
local src_lib_engine_api_i18n_55789ed73390 = nil
|
|
9
|
+
local src_lib_engine_api_key_55789ed67430 = nil
|
|
10
|
+
local src_lib_engine_api_log_55789ed6ec50 = nil
|
|
11
|
+
local src_lib_engine_api_math_55789ed97690 = nil
|
|
12
|
+
local src_lib_engine_api_array_55789ed6a870 = nil
|
|
13
|
+
local src_lib_engine_api_media_55789ed5bbd0 = nil
|
|
14
|
+
local src_lib_engine_draw_fps_55789edb30e0 = nil
|
|
15
|
+
local src_lib_engine_draw_text_55789ed7cb30 = nil
|
|
16
|
+
local src_lib_engine_draw_poly_55789ed758d0 = nil
|
|
17
|
+
local src_lib_engine_raw_memory_55789ed6cc30 = nil
|
|
18
|
+
local src_lib_protocol_http_callback_55789ed506b0 = nil
|
|
19
|
+
local src_lib_object_root_55789ed7d4c0 = nil
|
|
20
|
+
local src_lib_object_color_55789edbd130 = nil
|
|
21
|
+
local src_lib_object_std_55789ed51260 = nil
|
|
22
|
+
local src_lib_util_pipeline_55789ed7d870 = nil
|
|
23
|
+
local src_lib_util_decorator_55789ed6a3c0 = nil
|
|
24
|
+
local src_lib_util_http_55789eda0210 = nil
|
|
25
|
+
local function main_55789ed4b7f0()
|
|
26
|
+
local version = src_version_55789ed81210()
|
|
27
|
+
local zeebo_module = src_lib_common_module_55789ed58c40()
|
|
28
|
+
local engine_encoder = src_lib_engine_api_encoder_55789ed92660()
|
|
29
|
+
local engine_game = src_lib_engine_api_app_55789eda8c90()
|
|
30
|
+
local engine_hash = src_lib_engine_api_hash_55789ed5fba0()
|
|
31
|
+
local engine_http = src_lib_engine_api_http_55789ed73940()
|
|
32
|
+
local engine_i18n = src_lib_engine_api_i18n_55789ed73390()
|
|
33
|
+
local engine_key = src_lib_engine_api_key_55789ed67430()
|
|
34
|
+
local engine_log = src_lib_engine_api_log_55789ed6ec50()
|
|
35
|
+
local engine_math = src_lib_engine_api_math_55789ed97690()
|
|
36
|
+
local engine_array = src_lib_engine_api_array_55789ed6a870()
|
|
37
|
+
local engine_media = src_lib_engine_api_media_55789ed5bbd0()
|
|
38
|
+
local engine_draw_fps = src_lib_engine_draw_fps_55789edb30e0()
|
|
39
|
+
local engine_draw_text = src_lib_engine_draw_text_55789ed7cb30()
|
|
40
|
+
local engine_draw_poly = src_lib_engine_draw_poly_55789ed758d0()
|
|
41
|
+
local engine_raw_memory = src_lib_engine_raw_memory_55789ed6cc30()
|
|
42
|
+
local callback_http = src_lib_protocol_http_callback_55789ed506b0()
|
|
43
|
+
local application_default = src_lib_object_root_55789ed7d4c0()
|
|
44
|
+
local color = src_lib_object_color_55789edbd130()
|
|
45
|
+
local std = src_lib_object_std_55789ed51260()
|
|
41
46
|
local application = application_default
|
|
42
47
|
local engine = {
|
|
43
48
|
keyboard = function(a, b, c, d) end,
|
|
@@ -53,6 +58,7 @@ get_secret = native_system_get_secret,
|
|
|
53
58
|
get_language = native_system_get_language
|
|
54
59
|
}
|
|
55
60
|
local cfg_media = {
|
|
61
|
+
bootstrap=native_media_bootstrap,
|
|
56
62
|
position=native_media_position,
|
|
57
63
|
resize=native_media_resize,
|
|
58
64
|
pause=native_media_pause,
|
|
@@ -74,8 +80,18 @@ local cfg_text = {
|
|
|
74
80
|
font_previous = native_text_font_previous
|
|
75
81
|
}
|
|
76
82
|
local cfg_http = {
|
|
77
|
-
|
|
78
|
-
handler = native_http_handler
|
|
83
|
+
install = native_http_install,
|
|
84
|
+
handler = native_http_handler,
|
|
85
|
+
has_ssl = native_http_has_ssl,
|
|
86
|
+
has_callback = native_http_has_callback,
|
|
87
|
+
force = native_http_force_protocol
|
|
88
|
+
}
|
|
89
|
+
local cfg_log = {
|
|
90
|
+
fatal = native_log_fatal,
|
|
91
|
+
error = native_log_error,
|
|
92
|
+
warn = native_log_warn,
|
|
93
|
+
info = native_log_info,
|
|
94
|
+
debug = native_log_debug
|
|
79
95
|
}
|
|
80
96
|
local cfg_base64 = {
|
|
81
97
|
decode = native_base64_decode,
|
|
@@ -108,6 +124,12 @@ end
|
|
|
108
124
|
function native_callback_keyboard(key, value)
|
|
109
125
|
engine.keyboard(std, engine, key, value)
|
|
110
126
|
end
|
|
127
|
+
function native_callback_http(id, key, data)
|
|
128
|
+
if cfg_http.has_callback then
|
|
129
|
+
return callback_http.func(engine['http_requests'][id], key, data)
|
|
130
|
+
end
|
|
131
|
+
return nil
|
|
132
|
+
end
|
|
111
133
|
function native_callback_init(width, height, game_lua)
|
|
112
134
|
application = zeebo_module.loadgame(game_lua)
|
|
113
135
|
if application then
|
|
@@ -126,7 +148,9 @@ std.draw.color=native_draw_color
|
|
|
126
148
|
std.draw.font=native_draw_font
|
|
127
149
|
std.draw.rect=native_draw_rect
|
|
128
150
|
std.draw.line=native_draw_line
|
|
129
|
-
std.draw.image=
|
|
151
|
+
std.draw.image=native_image_draw
|
|
152
|
+
std.image.load=native_image_load
|
|
153
|
+
std.image.draw=native_image_draw
|
|
130
154
|
std.text.print=native_text_print
|
|
131
155
|
std.text.mensure=native_text_mensure
|
|
132
156
|
std.text.font_size=native_text_font_size
|
|
@@ -146,7 +170,9 @@ zeebo_module.require(std, application, engine)
|
|
|
146
170
|
:package('@draw.text', engine_draw_text, cfg_text)
|
|
147
171
|
:package('@draw.poly', engine_draw_poly, cfg_poly)
|
|
148
172
|
:package('@color', color)
|
|
173
|
+
:package('@log', engine_log, cfg_log)
|
|
149
174
|
:package('math', engine_math.clib)
|
|
175
|
+
:package('math.wave', engine_math.wave)
|
|
150
176
|
:package('math.random', engine_math.clib_random)
|
|
151
177
|
:package('http', engine_http, cfg_http)
|
|
152
178
|
:package('base64', engine_encoder, cfg_base64)
|
|
@@ -154,7 +180,10 @@ zeebo_module.require(std, application, engine)
|
|
|
154
180
|
:package('xml', engine_encoder, cfg_xml)
|
|
155
181
|
:package('i18n', engine_i18n, cfg_system)
|
|
156
182
|
:package('hash', engine_hash, cfg_system)
|
|
157
|
-
:package('media', engine_media, cfg_media)
|
|
183
|
+
:package('media.video', engine_media, cfg_media)
|
|
184
|
+
:package('media.audio', engine_media, cfg_media)
|
|
185
|
+
:package('mock.video', engine_media)
|
|
186
|
+
:package('mock.audio', engine_media)
|
|
158
187
|
:run()
|
|
159
188
|
application.data.width, std.app.width = width, width
|
|
160
189
|
application.data.height, std.app.height = height, height
|
|
@@ -172,13 +201,13 @@ version=version
|
|
|
172
201
|
}
|
|
173
202
|
return P
|
|
174
203
|
end
|
|
175
|
-
|
|
176
|
-
return '0.0.
|
|
204
|
+
src_version_55789ed81210 = function()
|
|
205
|
+
return '0.0.20'
|
|
177
206
|
end
|
|
178
207
|
--
|
|
179
|
-
|
|
180
|
-
local zeebo_pipeline =
|
|
181
|
-
local application_default =
|
|
208
|
+
src_lib_common_module_55789ed58c40 = function()
|
|
209
|
+
local zeebo_pipeline = src_lib_util_pipeline_55789ed7d870()
|
|
210
|
+
local application_default = src_lib_object_root_55789ed7d4c0()
|
|
182
211
|
local function default(application, defaults)
|
|
183
212
|
if not application then return nil end
|
|
184
213
|
local index = 1
|
|
@@ -376,7 +405,7 @@ require = require
|
|
|
376
405
|
return P
|
|
377
406
|
end
|
|
378
407
|
--
|
|
379
|
-
|
|
408
|
+
src_lib_engine_api_encoder_55789ed92660 = function()
|
|
380
409
|
local function install(std, engine, library, name)
|
|
381
410
|
std = std or {}
|
|
382
411
|
std[name] = {
|
|
@@ -391,8 +420,8 @@ install=install
|
|
|
391
420
|
return P
|
|
392
421
|
end
|
|
393
422
|
--
|
|
394
|
-
|
|
395
|
-
local util_decorator =
|
|
423
|
+
src_lib_engine_api_app_55789eda8c90 = function()
|
|
424
|
+
local util_decorator = src_lib_util_decorator_55789ed6a3c0()
|
|
396
425
|
local function reset(std, engine)
|
|
397
426
|
if std.node then
|
|
398
427
|
std.bus.emit('exit')
|
|
@@ -432,7 +461,7 @@ install=install
|
|
|
432
461
|
return P
|
|
433
462
|
end
|
|
434
463
|
--
|
|
435
|
-
|
|
464
|
+
src_lib_engine_api_hash_55789ed5fba0 = function()
|
|
436
465
|
local function djb2(digest)
|
|
437
466
|
local index = 1
|
|
438
467
|
local hash = 5381
|
|
@@ -458,8 +487,8 @@ install = install
|
|
|
458
487
|
return P
|
|
459
488
|
end
|
|
460
489
|
--
|
|
461
|
-
|
|
462
|
-
local zeebo_pipeline =
|
|
490
|
+
src_lib_engine_api_http_55789ed73940 = function()
|
|
491
|
+
local zeebo_pipeline = src_lib_util_pipeline_55789ed7d870()
|
|
463
492
|
local function fast(self)
|
|
464
493
|
self.speed = '_fast'
|
|
465
494
|
return self
|
|
@@ -492,13 +521,24 @@ local function http_error(self, handler_func)
|
|
|
492
521
|
self.error_handler = handler_func
|
|
493
522
|
return self
|
|
494
523
|
end
|
|
495
|
-
local function request(method, std, engine,
|
|
524
|
+
local function request(method, std, engine, protocol)
|
|
496
525
|
local callback_handler = function()
|
|
526
|
+
if std.node then
|
|
497
527
|
std.node.emit(engine.current, 'http')
|
|
528
|
+
elseif engine.current.callbacks.http then
|
|
529
|
+
engine.current.callbacks.http(std, engine.current.data)
|
|
530
|
+
end
|
|
498
531
|
end
|
|
499
532
|
return function (url)
|
|
533
|
+
if protocol.has_callback then
|
|
534
|
+
engine.http_count = engine.http_count + 1
|
|
535
|
+
end
|
|
536
|
+
if protocol.force then
|
|
537
|
+
url = url:gsub("^[^:]+://", protocol.force.."://")
|
|
538
|
+
end
|
|
500
539
|
local game = engine.current.data
|
|
501
540
|
local self = {
|
|
541
|
+
id = engine.http_count,
|
|
502
542
|
url = url,
|
|
503
543
|
speed = '',
|
|
504
544
|
method = method,
|
|
@@ -507,12 +547,9 @@ header_list = {},
|
|
|
507
547
|
header_dict = {},
|
|
508
548
|
param_list = {},
|
|
509
549
|
param_dict = {},
|
|
510
|
-
callback_handler = callback_handler,
|
|
511
550
|
success_handler = function (std, game) end,
|
|
512
551
|
failed_handler = function (std, game) end,
|
|
513
552
|
error_handler = function (std, game) end,
|
|
514
|
-
std = std,
|
|
515
|
-
game = game,
|
|
516
553
|
fast = fast,
|
|
517
554
|
body = body,
|
|
518
555
|
param = param,
|
|
@@ -521,7 +558,6 @@ success = success,
|
|
|
521
558
|
failed = failed,
|
|
522
559
|
error = http_error,
|
|
523
560
|
run = zeebo_pipeline.run,
|
|
524
|
-
protocol_handler = protocol_handler
|
|
525
561
|
}
|
|
526
562
|
self.promise = function()
|
|
527
563
|
zeebo_pipeline.stop(self)
|
|
@@ -530,29 +566,34 @@ self.resolve = function()
|
|
|
530
566
|
zeebo_pipeline.resume(self)
|
|
531
567
|
end
|
|
532
568
|
self.set = function (key, value)
|
|
533
|
-
|
|
569
|
+
std.http[key] = value
|
|
534
570
|
end
|
|
535
571
|
self.pipeline = {
|
|
536
572
|
function()
|
|
537
|
-
self
|
|
573
|
+
if protocol.has_callback then engine.http_requests[self.id] = self end
|
|
574
|
+
protocol.handler(self, self.id)
|
|
538
575
|
end,
|
|
539
576
|
function()
|
|
540
|
-
|
|
541
|
-
if
|
|
542
|
-
self.success_handler(
|
|
543
|
-
elseif
|
|
544
|
-
self.error_handler(
|
|
577
|
+
callback_handler(std, game)
|
|
578
|
+
if std.http.ok then
|
|
579
|
+
self.success_handler(std, game)
|
|
580
|
+
elseif std.http.error then
|
|
581
|
+
self.error_handler(std, game)
|
|
582
|
+
elseif not std.http.status then
|
|
583
|
+
self.set('error', 'missing protocol response')
|
|
584
|
+
self.error_handler(std, game)
|
|
545
585
|
else
|
|
546
|
-
self.failed_handler(
|
|
586
|
+
self.failed_handler(std, game)
|
|
547
587
|
end
|
|
548
588
|
end,
|
|
549
589
|
function ()
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
590
|
+
std.http.ok = nil
|
|
591
|
+
std.http.body = nil
|
|
592
|
+
std.http.error = nil
|
|
593
|
+
std.http.status = nil
|
|
554
594
|
end,
|
|
555
595
|
function()
|
|
596
|
+
if protocol.has_callback then engine.http_requests[self.id] = nil end
|
|
556
597
|
zeebo_pipeline.reset(self)
|
|
557
598
|
end
|
|
558
599
|
}
|
|
@@ -560,23 +601,21 @@ return self
|
|
|
560
601
|
end
|
|
561
602
|
end
|
|
562
603
|
local function install(std, engine, protocol)
|
|
563
|
-
|
|
564
|
-
if
|
|
565
|
-
|
|
604
|
+
assert(protocol and protocol.handler, 'missing protocol handler')
|
|
605
|
+
if protocol.has_callback then
|
|
606
|
+
engine.http_count = 0
|
|
607
|
+
engine.http_requests = {}
|
|
566
608
|
end
|
|
567
609
|
std.http = std.http or {}
|
|
568
|
-
std.http.get=request('GET', std, engine,
|
|
569
|
-
std.http.head=request('HEAD', std, engine,
|
|
570
|
-
std.http.post=request('POST', std, engine,
|
|
571
|
-
std.http.put=request('PUT', std, engine,
|
|
572
|
-
std.http.delete=request('DELETE', std, engine,
|
|
573
|
-
std.http.patch=request('PATCH', std, engine,
|
|
610
|
+
std.http.get=request('GET', std, engine, protocol)
|
|
611
|
+
std.http.head=request('HEAD', std, engine, protocol)
|
|
612
|
+
std.http.post=request('POST', std, engine, protocol)
|
|
613
|
+
std.http.put=request('PUT', std, engine, protocol)
|
|
614
|
+
std.http.delete=request('DELETE', std, engine, protocol)
|
|
615
|
+
std.http.patch=request('PATCH', std, engine, protocol)
|
|
574
616
|
if protocol.install then
|
|
575
617
|
protocol.install(std, engine)
|
|
576
618
|
end
|
|
577
|
-
return {
|
|
578
|
-
std={http=std.http}
|
|
579
|
-
}
|
|
580
619
|
end
|
|
581
620
|
local P = {
|
|
582
621
|
install=install
|
|
@@ -584,7 +623,7 @@ install=install
|
|
|
584
623
|
return P
|
|
585
624
|
end
|
|
586
625
|
--
|
|
587
|
-
|
|
626
|
+
src_lib_engine_api_i18n_55789ed73390 = function()
|
|
588
627
|
local language = 'en-US'
|
|
589
628
|
local language_default = 'en-US'
|
|
590
629
|
local language_list = {}
|
|
@@ -676,7 +715,7 @@ install=install
|
|
|
676
715
|
return P
|
|
677
716
|
end
|
|
678
717
|
--
|
|
679
|
-
|
|
718
|
+
src_lib_engine_api_key_55789ed67430 = function()
|
|
680
719
|
local function real_key(std, engine, rkey, rvalue)
|
|
681
720
|
local value = rvalue == 1 or rvalue == true
|
|
682
721
|
local key = engine.key_bindings[rkey] or (std.key.axis[rkey] and rkey)
|
|
@@ -691,6 +730,8 @@ std.key.axis.y = std.key.axis.down - std.key.axis.up
|
|
|
691
730
|
end
|
|
692
731
|
std.bus.emit('key')
|
|
693
732
|
end
|
|
733
|
+
local a = std.key.axis
|
|
734
|
+
std.key.press.any = (a.left + a.right + a.down + a.up + a.a + a.b + a.c + a.d + a.menu) > 0
|
|
694
735
|
end
|
|
695
736
|
local function real_keydown(std, engine, key)
|
|
696
737
|
real_key(std, engine, key, 1)
|
|
@@ -714,7 +755,54 @@ install = install
|
|
|
714
755
|
return P
|
|
715
756
|
end
|
|
716
757
|
--
|
|
717
|
-
|
|
758
|
+
src_lib_engine_api_log_55789ed6ec50 = function()
|
|
759
|
+
local util_decorator = src_lib_util_decorator_55789ed6a3c0()
|
|
760
|
+
local logging_types = {
|
|
761
|
+
'none', 'fatal', 'error', 'warn', 'debug', 'info'
|
|
762
|
+
}
|
|
763
|
+
local function level(engine, lpf, lpn, level)
|
|
764
|
+
local l = lpf[level] or lpn[level] or level
|
|
765
|
+
if type(l) ~= 'number' or l <= 0 or l > #logging_types then
|
|
766
|
+
error('logging level not exist: '..tostring(level))
|
|
767
|
+
end
|
|
768
|
+
engine.loglevel = l
|
|
769
|
+
end
|
|
770
|
+
local function init(std, engine, printers)
|
|
771
|
+
local index = 1
|
|
772
|
+
local level_per_func = {}
|
|
773
|
+
local level_per_name = {}
|
|
774
|
+
while index <= #logging_types do
|
|
775
|
+
local ltype = logging_types[index]
|
|
776
|
+
local lfunc = function() end
|
|
777
|
+
if index > 1 and printers[ltype] then
|
|
778
|
+
lfunc = (function (level)
|
|
779
|
+
return function(message)
|
|
780
|
+
if engine.loglevel >= level then
|
|
781
|
+
printers[ltype](message)
|
|
782
|
+
end
|
|
783
|
+
end
|
|
784
|
+
end)(index - 1)
|
|
785
|
+
end
|
|
786
|
+
level_per_func[lfunc] = index - 1
|
|
787
|
+
level_per_name[ltype] = index - 1
|
|
788
|
+
std.log[ltype] = lfunc
|
|
789
|
+
index = index + 1
|
|
790
|
+
end
|
|
791
|
+
std.log.level = util_decorator.prefix3(engine, level_per_func, level_per_name, level)
|
|
792
|
+
end
|
|
793
|
+
local function install(std, engine, printers)
|
|
794
|
+
std.log = std.log or {}
|
|
795
|
+
engine.loglevel = #logging_types
|
|
796
|
+
std.log.init = util_decorator.prefix2(std, engine, init)
|
|
797
|
+
std.log.init(printers)
|
|
798
|
+
end
|
|
799
|
+
local P = {
|
|
800
|
+
install = install
|
|
801
|
+
}
|
|
802
|
+
return P
|
|
803
|
+
end
|
|
804
|
+
--
|
|
805
|
+
src_lib_engine_api_math_55789ed97690 = function()
|
|
718
806
|
local function abs(value)
|
|
719
807
|
if value < 0 then
|
|
720
808
|
return -value
|
|
@@ -793,8 +881,31 @@ index = index + 1
|
|
|
793
881
|
end
|
|
794
882
|
return min_value
|
|
795
883
|
end
|
|
884
|
+
local function sine(t, freq)
|
|
885
|
+
return math.pi and math.sin(2 * math.pi * freq * t) or 1
|
|
886
|
+
end
|
|
887
|
+
local function ramp(t, freq, ratio)
|
|
888
|
+
t = (t / 2) % (1 / freq) * freq
|
|
889
|
+
if t < ratio then
|
|
890
|
+
return 2 * t / ratio - 1
|
|
891
|
+
else
|
|
892
|
+
return (2 * t - ratio - 1) / (ratio - 1)
|
|
893
|
+
end
|
|
894
|
+
end
|
|
895
|
+
local function saw(t, freq)
|
|
896
|
+
return ramp(t, freq, 1)
|
|
897
|
+
end
|
|
898
|
+
local function triangle(t, freq)
|
|
899
|
+
return ramp(t, freq, 1/2)
|
|
900
|
+
end
|
|
901
|
+
local function rect(t, freq, duty)
|
|
902
|
+
duty = 1 - duty * 2
|
|
903
|
+
return saw(t, freq) > duty and 1 or -1
|
|
904
|
+
end
|
|
905
|
+
local function square(t, freq)
|
|
906
|
+
return rect(t, freq, 1/2)
|
|
907
|
+
end
|
|
796
908
|
local function install(std)
|
|
797
|
-
std = std or {}
|
|
798
909
|
std.math = std.math or {}
|
|
799
910
|
std.math.abs=abs
|
|
800
911
|
std.math.clamp=clamp
|
|
@@ -807,10 +918,15 @@ std.math.lerp=lerp
|
|
|
807
918
|
std.math.map=map
|
|
808
919
|
std.math.max=max
|
|
809
920
|
std.math.min=min
|
|
810
|
-
|
|
921
|
+
end
|
|
922
|
+
local function install_wave(std)
|
|
923
|
+
std.math = std.math or {}
|
|
924
|
+
std.math.sine=sine
|
|
925
|
+
std.math.saw=saw
|
|
926
|
+
std.math.square=square
|
|
927
|
+
std.math.triangle=triangle
|
|
811
928
|
end
|
|
812
929
|
local function install_clib(std)
|
|
813
|
-
std = std or {}
|
|
814
930
|
std.math = std.math or {}
|
|
815
931
|
std.math.acos=math.acos
|
|
816
932
|
std.math.asin=math.asin
|
|
@@ -837,20 +953,20 @@ std.math.sinh=math.sinh
|
|
|
837
953
|
std.math.sqrt=math.sqrt
|
|
838
954
|
std.math.tan=math.tan
|
|
839
955
|
std.math.tanh=math.tanh
|
|
840
|
-
return std.math
|
|
841
956
|
end
|
|
842
957
|
local function install_clib_random(std)
|
|
843
|
-
std = std or {}
|
|
844
958
|
std.math = std.math or {}
|
|
845
959
|
std.math.random = function(a, b)
|
|
846
960
|
a = a and math.floor(a)
|
|
847
961
|
b = b and math.floor(b)
|
|
848
962
|
return math.random(a, b)
|
|
849
963
|
end
|
|
850
|
-
return std.math
|
|
851
964
|
end
|
|
852
965
|
local P = {
|
|
853
966
|
install = install,
|
|
967
|
+
wave = {
|
|
968
|
+
install = install_wave
|
|
969
|
+
},
|
|
854
970
|
clib = {
|
|
855
971
|
install = install_clib
|
|
856
972
|
},
|
|
@@ -861,8 +977,8 @@ install = install_clib_random
|
|
|
861
977
|
return P;
|
|
862
978
|
end
|
|
863
979
|
--
|
|
864
|
-
|
|
865
|
-
local util_decorator =
|
|
980
|
+
src_lib_engine_api_array_55789ed6a870 = function()
|
|
981
|
+
local util_decorator = src_lib_util_decorator_55789ed6a3c0()
|
|
866
982
|
local function array_map(array, func)
|
|
867
983
|
local res = {}
|
|
868
984
|
local index = 1
|
|
@@ -1004,6 +1120,7 @@ return self
|
|
|
1004
1120
|
end
|
|
1005
1121
|
local function install(std, engine, library, name)
|
|
1006
1122
|
local lib = std[name] or {}
|
|
1123
|
+
lib.map = array_map
|
|
1007
1124
|
lib.filter = array_filter
|
|
1008
1125
|
lib.unique = array_unique
|
|
1009
1126
|
lib.each = array_foreach
|
|
@@ -1022,68 +1139,41 @@ install = install
|
|
|
1022
1139
|
return P
|
|
1023
1140
|
end
|
|
1024
1141
|
--
|
|
1025
|
-
|
|
1026
|
-
local
|
|
1027
|
-
local function
|
|
1028
|
-
func
|
|
1142
|
+
src_lib_engine_api_media_55789ed5bbd0 = function()
|
|
1143
|
+
local function media_create(node, channels, handler)
|
|
1144
|
+
local decorator = function(func)
|
|
1145
|
+
func = func or function() end
|
|
1146
|
+
return function(self, a, b, c)
|
|
1147
|
+
func(0, a, b, c)
|
|
1029
1148
|
return self
|
|
1030
1149
|
end
|
|
1031
|
-
local function media_play(func, self)
|
|
1032
|
-
func(self.id - 1)
|
|
1033
|
-
return self
|
|
1034
|
-
end
|
|
1035
|
-
local function media_pause(func, self)
|
|
1036
|
-
func(self.id - 1)
|
|
1037
|
-
return self
|
|
1038
|
-
end
|
|
1039
|
-
local function media_resize(func, self, width, height)
|
|
1040
|
-
func(self.id - 1, width, height)
|
|
1041
|
-
return self
|
|
1042
1150
|
end
|
|
1043
|
-
local
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
end
|
|
1054
|
-
if not channels[id] then
|
|
1055
|
-
channels[id] = {
|
|
1056
|
-
id = id,
|
|
1057
|
-
add = util_decorator.prefix1(handler.load, media_add),
|
|
1058
|
-
play = util_decorator.prefix1(handler.play, media_play),
|
|
1059
|
-
pause = util_decorator.prefix1(handler.pause, media_pause),
|
|
1060
|
-
resize = util_decorator.prefix1(handler.resize, media_resize),
|
|
1061
|
-
position = util_decorator.prefix1(handler.position, media_position)
|
|
1151
|
+
local self = {
|
|
1152
|
+
src = decorator(handler.source),
|
|
1153
|
+
play = decorator(handler.play),
|
|
1154
|
+
pause = decorator(handler.pause),
|
|
1155
|
+
resume = decorator(handler.resume),
|
|
1156
|
+
stop = decorator(handler.stop),
|
|
1157
|
+
position = decorator(handler.position),
|
|
1158
|
+
resize = decorator(handler.resize),
|
|
1159
|
+
node = node,
|
|
1160
|
+
apply = function() end
|
|
1062
1161
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
channels[id].apply = function()
|
|
1066
|
-
local node = channels[id].node
|
|
1067
|
-
local depth = 0
|
|
1068
|
-
local offset_x = 0
|
|
1069
|
-
local offset_y = 0
|
|
1070
|
-
while node and depth < 100 do
|
|
1071
|
-
offset_x = offset_x + node.config.offset_x
|
|
1072
|
-
offset_y = offset_y + node.config.offset_y
|
|
1073
|
-
node = node.config.parent
|
|
1074
|
-
depth = depth + 1
|
|
1075
|
-
end
|
|
1076
|
-
media_position(handler.position, channels[id], offset_x, offset_y)
|
|
1077
|
-
media_resize(handler.resize, channels[id], channels[id].node.data.width, channels[id].node.data.height)
|
|
1078
|
-
end
|
|
1162
|
+
return function()
|
|
1163
|
+
return self
|
|
1079
1164
|
end
|
|
1080
1165
|
end
|
|
1081
|
-
|
|
1166
|
+
local function install(std, engine, handler, name)
|
|
1167
|
+
std.media = std.media or {}
|
|
1168
|
+
local mediatype = name:match('%w+%.(%w+)')
|
|
1169
|
+
if not std.media[mediatype] then
|
|
1170
|
+
local channels = handler.bootstrap and handler.bootstrap(mediatype)
|
|
1171
|
+
if (not channels or channels == 0) and handler.bootstrap then
|
|
1172
|
+
error('media '..mediatype..' is not supported!')
|
|
1082
1173
|
end
|
|
1174
|
+
local node = std.node and std.node.load({})
|
|
1175
|
+
std.media[mediatype] = media_create(node, channels, handler)
|
|
1083
1176
|
end
|
|
1084
|
-
local function install(std, engine, handlers)
|
|
1085
|
-
std.media = std.media or {}
|
|
1086
|
-
std.media.video = media_channel(std, handlers)
|
|
1087
1177
|
end
|
|
1088
1178
|
local P = {
|
|
1089
1179
|
install=install
|
|
@@ -1091,7 +1181,7 @@ install=install
|
|
|
1091
1181
|
return P
|
|
1092
1182
|
end
|
|
1093
1183
|
--
|
|
1094
|
-
|
|
1184
|
+
src_lib_engine_draw_fps_55789edb30e0 = function()
|
|
1095
1185
|
local function draw_fps(std, engine, show, pos_x, pos_y)
|
|
1096
1186
|
if show < 1 then return end
|
|
1097
1187
|
local x = engine.current.config.offset_x + pos_x
|
|
@@ -1143,8 +1233,8 @@ install=install
|
|
|
1143
1233
|
return P
|
|
1144
1234
|
end
|
|
1145
1235
|
--
|
|
1146
|
-
|
|
1147
|
-
local util_decorator =
|
|
1236
|
+
src_lib_engine_draw_text_55789ed7cb30 = function()
|
|
1237
|
+
local util_decorator = src_lib_util_decorator_55789ed6a3c0()
|
|
1148
1238
|
local function text_put(std, engine, font_previous, pos_x, pos_y, text, size)
|
|
1149
1239
|
size = size or 2
|
|
1150
1240
|
local hem = engine.current.data.width / 80
|
|
@@ -1171,7 +1261,7 @@ install=install
|
|
|
1171
1261
|
return P
|
|
1172
1262
|
end
|
|
1173
1263
|
--
|
|
1174
|
-
|
|
1264
|
+
src_lib_engine_draw_poly_55789ed758d0 = function()
|
|
1175
1265
|
local function decorator_poo(object, func)
|
|
1176
1266
|
if not object or not func then return func end
|
|
1177
1267
|
return function(a, b, c, d)
|
|
@@ -1278,21 +1368,25 @@ install=install
|
|
|
1278
1368
|
return P
|
|
1279
1369
|
end
|
|
1280
1370
|
--
|
|
1281
|
-
|
|
1371
|
+
src_lib_engine_raw_memory_55789ed6cc30 = function()
|
|
1282
1372
|
local memory_dict_unload = {}
|
|
1283
1373
|
local memory_dict = {}
|
|
1284
1374
|
local memory_list = {}
|
|
1285
|
-
local function
|
|
1286
|
-
if memory_dict[key] then
|
|
1375
|
+
local function cache_get(key)
|
|
1287
1376
|
return memory_dict[key]
|
|
1288
1377
|
end
|
|
1289
|
-
|
|
1290
|
-
return nil
|
|
1291
|
-
end
|
|
1378
|
+
local function cache_set(key, load_func, unload_func)
|
|
1292
1379
|
local value = load_func()
|
|
1293
1380
|
memory_list[#memory_list + 1] = key
|
|
1294
1381
|
memory_dict_unload[key] = unload_func
|
|
1295
1382
|
memory_dict[key] = value
|
|
1383
|
+
end
|
|
1384
|
+
local function cache(key, load_func, unload_func)
|
|
1385
|
+
local value = cache_get(key)
|
|
1386
|
+
if value == nil then
|
|
1387
|
+
cache_set(key, load_func, unload_func)
|
|
1388
|
+
value = cache_get(key)
|
|
1389
|
+
end
|
|
1296
1390
|
return value
|
|
1297
1391
|
end
|
|
1298
1392
|
local function unset(key)
|
|
@@ -1315,6 +1409,8 @@ local function install(std)
|
|
|
1315
1409
|
std = std or {}
|
|
1316
1410
|
std.mem = std.mem or {}
|
|
1317
1411
|
std.mem.cache = cache
|
|
1412
|
+
std.mem.cache_get = cache_get
|
|
1413
|
+
std.mem.cache_set = cache_set
|
|
1318
1414
|
std.mem.unset = unset
|
|
1319
1415
|
std.mem.gc_clear_all = gc_clear_all
|
|
1320
1416
|
return {
|
|
@@ -1327,7 +1423,75 @@ install=install
|
|
|
1327
1423
|
return P
|
|
1328
1424
|
end
|
|
1329
1425
|
--
|
|
1330
|
-
|
|
1426
|
+
src_lib_protocol_http_callback_55789ed506b0 = function()
|
|
1427
|
+
local http_util = src_lib_util_http_55789eda0210()
|
|
1428
|
+
local callbacks = {
|
|
1429
|
+
['async-promise'] = function(self)
|
|
1430
|
+
return self:promise()
|
|
1431
|
+
end,
|
|
1432
|
+
['async-resolve'] = function(self)
|
|
1433
|
+
return self:resolve()
|
|
1434
|
+
end,
|
|
1435
|
+
['get-url'] = function(self)
|
|
1436
|
+
return self.url
|
|
1437
|
+
end,
|
|
1438
|
+
['get-fullurl'] = function(self)
|
|
1439
|
+
return self.url..http_util.url_search_param(self.param_list, self.param_dict)
|
|
1440
|
+
end,
|
|
1441
|
+
['get-method'] = function(self)
|
|
1442
|
+
return self.method
|
|
1443
|
+
end,
|
|
1444
|
+
['get-body'] = function(self)
|
|
1445
|
+
return self.body_content
|
|
1446
|
+
end,
|
|
1447
|
+
['get-param-count'] = function(self)
|
|
1448
|
+
return #self.param_list
|
|
1449
|
+
end,
|
|
1450
|
+
['get-param-name'] = function(self, data)
|
|
1451
|
+
return self.param_list[self.data]
|
|
1452
|
+
end,
|
|
1453
|
+
['get-param-data'] = function(self, data)
|
|
1454
|
+
return self.param_dict[self.data] or self.param_dict[self.param_list[self.data]]
|
|
1455
|
+
end,
|
|
1456
|
+
['get-header-count'] = function(self)
|
|
1457
|
+
return #self.header_list
|
|
1458
|
+
end,
|
|
1459
|
+
['get-header-name'] = function(self, data)
|
|
1460
|
+
return self.header_list[self.data]
|
|
1461
|
+
end,
|
|
1462
|
+
['get-header-data'] = function(self, data)
|
|
1463
|
+
return self.heeader_dict[self.data] or self.heeader_dict[self.header_list[self.data]]
|
|
1464
|
+
end,
|
|
1465
|
+
['set-status'] = function(self, data)
|
|
1466
|
+
self.set('status', data)
|
|
1467
|
+
self.set('ok', http_util.is_ok(data))
|
|
1468
|
+
end,
|
|
1469
|
+
['set-error'] = function(self, data)
|
|
1470
|
+
self.set('error', data)
|
|
1471
|
+
end,
|
|
1472
|
+
['set-ok'] = function(self, data)
|
|
1473
|
+
self.set('ok', data)
|
|
1474
|
+
end,
|
|
1475
|
+
['set-body'] = function(self, data)
|
|
1476
|
+
self.set('body', data)
|
|
1477
|
+
end,
|
|
1478
|
+
['add-body-data'] = function(self, data, std)
|
|
1479
|
+
self.set('body', (std.http.body or '')..data)
|
|
1480
|
+
end
|
|
1481
|
+
}
|
|
1482
|
+
local function native_http_callback(self, evt, data, std)
|
|
1483
|
+
if not callbacks[evt] then
|
|
1484
|
+
error('http evt '..evt..' not exist!')
|
|
1485
|
+
end
|
|
1486
|
+
return callbacks[evt](self, data, std)
|
|
1487
|
+
end
|
|
1488
|
+
local P = {
|
|
1489
|
+
func = native_http_callback
|
|
1490
|
+
}
|
|
1491
|
+
return P
|
|
1492
|
+
end
|
|
1493
|
+
--
|
|
1494
|
+
src_lib_object_root_55789ed7d4c0 = function()
|
|
1331
1495
|
local P = {
|
|
1332
1496
|
data={
|
|
1333
1497
|
width=1280,
|
|
@@ -1357,61 +1521,34 @@ callbacks={
|
|
|
1357
1521
|
return P;
|
|
1358
1522
|
end
|
|
1359
1523
|
--
|
|
1360
|
-
|
|
1361
|
-
local white = 0xFFFFFFFF
|
|
1362
|
-
local lightgray = 0xC8CCCCFF
|
|
1363
|
-
local gray = 0x828282FF
|
|
1364
|
-
local darkgray = 0x505050FF
|
|
1365
|
-
local yellow = 0xFDF900FF
|
|
1366
|
-
local gold = 0xFFCB00FF
|
|
1367
|
-
local orange = 0xFFA100FF
|
|
1368
|
-
local pink = 0xFF6DC2FF
|
|
1369
|
-
local red = 0xE62937FF
|
|
1370
|
-
local maroon = 0xBE2137FF
|
|
1371
|
-
local green = 0x00E430FF
|
|
1372
|
-
local lime = 0x009E2FFF
|
|
1373
|
-
local darkgreen = 0x00752CFF
|
|
1374
|
-
local skyblue = 0x66BFFFFF
|
|
1375
|
-
local blue = 0x0079F1FF
|
|
1376
|
-
local darkblue = 0x0052ACFF
|
|
1377
|
-
local purple = 0xC87AFFFF
|
|
1378
|
-
local violet = 0x873CBEFF
|
|
1379
|
-
local darkpurple = 0x701F7EFF
|
|
1380
|
-
local beige = 0xD3B083FF
|
|
1381
|
-
local brown = 0x7F6A4FFF
|
|
1382
|
-
local darkbrown = 0x4C3F2FFF
|
|
1383
|
-
local black = 0x000000FF
|
|
1384
|
-
local blank = 0x00000000
|
|
1385
|
-
local magenta = 0xFF00FFFF
|
|
1524
|
+
src_lib_object_color_55789edbd130 = function()
|
|
1386
1525
|
local function install(std)
|
|
1387
|
-
std = std or {}
|
|
1388
1526
|
std.color = std.color or {}
|
|
1389
|
-
std.color.white =
|
|
1390
|
-
std.color.lightgray =
|
|
1391
|
-
std.color.gray =
|
|
1392
|
-
std.color.darkgray =
|
|
1393
|
-
std.color.yellow =
|
|
1394
|
-
std.color.gold =
|
|
1395
|
-
std.color.orange =
|
|
1396
|
-
std.color.pink =
|
|
1397
|
-
std.color.red =
|
|
1398
|
-
std.color.maroon =
|
|
1399
|
-
std.color.green =
|
|
1400
|
-
std.color.lime =
|
|
1401
|
-
std.color.darkgreen =
|
|
1402
|
-
std.color.skyblue =
|
|
1403
|
-
std.color.blue =
|
|
1404
|
-
std.color.darkblue =
|
|
1405
|
-
std.color.purple =
|
|
1406
|
-
std.color.violet =
|
|
1407
|
-
std.color.darkpurple =
|
|
1408
|
-
std.color.beige =
|
|
1409
|
-
std.color.brown =
|
|
1410
|
-
std.color.darkbrown =
|
|
1411
|
-
std.color.black =
|
|
1412
|
-
std.color.blank =
|
|
1413
|
-
std.color.magenta =
|
|
1414
|
-
return std.color
|
|
1527
|
+
std.color.white = 0xFFFFFFFF
|
|
1528
|
+
std.color.lightgray = 0xC8CCCCFF
|
|
1529
|
+
std.color.gray = 0x828282FF
|
|
1530
|
+
std.color.darkgray = 0x505050FF
|
|
1531
|
+
std.color.yellow = 0xFDF900FF
|
|
1532
|
+
std.color.gold = 0xFFCB00FF
|
|
1533
|
+
std.color.orange = 0xFFA100FF
|
|
1534
|
+
std.color.pink = 0xFF6DC2FF
|
|
1535
|
+
std.color.red = 0xE62937FF
|
|
1536
|
+
std.color.maroon = 0xBE2137FF
|
|
1537
|
+
std.color.green = 0x00E430FF
|
|
1538
|
+
std.color.lime = 0x009E2FFF
|
|
1539
|
+
std.color.darkgreen = 0x00752CFF
|
|
1540
|
+
std.color.skyblue = 0x66BFFFFF
|
|
1541
|
+
std.color.blue = 0x0079F1FF
|
|
1542
|
+
std.color.darkblue = 0x0052ACFF
|
|
1543
|
+
std.color.purple = 0xC87AFFFF
|
|
1544
|
+
std.color.violet = 0x873CBEFF
|
|
1545
|
+
std.color.darkpurple = 0x701F7EFF
|
|
1546
|
+
std.color.beige = 0xD3B083FF
|
|
1547
|
+
std.color.brown = 0x7F6A4FFF
|
|
1548
|
+
std.color.darkbrown = 0x4C3F2FFF
|
|
1549
|
+
std.color.black = 0x000000FF
|
|
1550
|
+
std.color.blank = 0x00000000
|
|
1551
|
+
std.color.magenta = 0xFF00FFFF
|
|
1415
1552
|
end
|
|
1416
1553
|
local P = {
|
|
1417
1554
|
install = install
|
|
@@ -1419,7 +1556,7 @@ install = install
|
|
|
1419
1556
|
return P
|
|
1420
1557
|
end
|
|
1421
1558
|
--
|
|
1422
|
-
|
|
1559
|
+
src_lib_object_std_55789ed51260 = function()
|
|
1423
1560
|
local P = {
|
|
1424
1561
|
milis = 0,
|
|
1425
1562
|
delta = 0,
|
|
@@ -1442,6 +1579,10 @@ font_size = function() end,
|
|
|
1442
1579
|
font_name = function() end,
|
|
1443
1580
|
font_default = function() end
|
|
1444
1581
|
},
|
|
1582
|
+
image = {
|
|
1583
|
+
load = function() end,
|
|
1584
|
+
draw = function() end
|
|
1585
|
+
},
|
|
1445
1586
|
app = {
|
|
1446
1587
|
width = 1280,
|
|
1447
1588
|
height = 720,
|
|
@@ -1473,14 +1614,15 @@ right=false,
|
|
|
1473
1614
|
a=false,
|
|
1474
1615
|
b=false,
|
|
1475
1616
|
c=false,
|
|
1476
|
-
d=false
|
|
1617
|
+
d=false,
|
|
1618
|
+
any=false
|
|
1477
1619
|
}
|
|
1478
1620
|
}
|
|
1479
1621
|
}
|
|
1480
1622
|
return P;
|
|
1481
1623
|
end
|
|
1482
1624
|
--
|
|
1483
|
-
|
|
1625
|
+
src_lib_util_pipeline_55789ed7d870 = function()
|
|
1484
1626
|
local function pipe(self)
|
|
1485
1627
|
return function()
|
|
1486
1628
|
self:run()
|
|
@@ -1530,7 +1672,7 @@ run=run
|
|
|
1530
1672
|
return P
|
|
1531
1673
|
end
|
|
1532
1674
|
--
|
|
1533
|
-
|
|
1675
|
+
src_lib_util_decorator_55789ed6a3c0 = function()
|
|
1534
1676
|
local function decorator_prefix3(zig, zag, zom, func)
|
|
1535
1677
|
return function (a, b, c, d, e, f)
|
|
1536
1678
|
return func(zig, zag, zom, a, b, c, d, e, f)
|
|
@@ -1569,15 +1711,172 @@ local y = object.offset_y + b
|
|
|
1569
1711
|
return func(x, y, c, d, e, f)
|
|
1570
1712
|
end
|
|
1571
1713
|
end
|
|
1714
|
+
local function table_prefix1(prefix, fn_table)
|
|
1715
|
+
local new_table = {}
|
|
1716
|
+
for name, fn in pairs(fn_table) do
|
|
1717
|
+
new_table[name] = decorator_prefix1(prefix, fn)
|
|
1718
|
+
end
|
|
1719
|
+
return new_table
|
|
1720
|
+
end
|
|
1572
1721
|
local P = {
|
|
1573
1722
|
offset_xy1 = decorator_offset_xy1,
|
|
1574
1723
|
offset_xy2 = decorator_offset_xy2,
|
|
1575
1724
|
offset_xyxy1 = decorator_offset_xyxy1,
|
|
1576
1725
|
prefix3 = decorator_prefix3,
|
|
1577
1726
|
prefix2 = decorator_prefix2,
|
|
1578
|
-
prefix1 = decorator_prefix1
|
|
1727
|
+
prefix1 = decorator_prefix1,
|
|
1728
|
+
prefix1_t = table_prefix1
|
|
1579
1729
|
}
|
|
1580
1730
|
return P
|
|
1581
1731
|
end
|
|
1582
1732
|
--
|
|
1583
|
-
|
|
1733
|
+
src_lib_util_http_55789eda0210 = function()
|
|
1734
|
+
local function is_ok(status)
|
|
1735
|
+
return (status and 200 <= status and status < 300) or false
|
|
1736
|
+
end
|
|
1737
|
+
local function is_ok_header(header)
|
|
1738
|
+
local status = tonumber(header:match('HTTP/%d.%d (%d%d%d)'))
|
|
1739
|
+
local ok = status and is_ok(status) or false
|
|
1740
|
+
return ok, status
|
|
1741
|
+
end
|
|
1742
|
+
local function is_redirect(status)
|
|
1743
|
+
return (status and 300 <= status and status < 400) or false
|
|
1744
|
+
end
|
|
1745
|
+
local function url_search_param(param_list, param_dict)
|
|
1746
|
+
local index, params = 1, ''
|
|
1747
|
+
while param_list and param_dict and index <= #param_list do
|
|
1748
|
+
local param = param_list[index]
|
|
1749
|
+
local value = param_dict[param]
|
|
1750
|
+
if #params == 0 then
|
|
1751
|
+
params = params..'?'
|
|
1752
|
+
else
|
|
1753
|
+
params = params..'&'
|
|
1754
|
+
end
|
|
1755
|
+
params = params..param..'='..(value or '')
|
|
1756
|
+
index = index + 1
|
|
1757
|
+
end
|
|
1758
|
+
return params
|
|
1759
|
+
end
|
|
1760
|
+
local function create_request(method, uri)
|
|
1761
|
+
local self = {
|
|
1762
|
+
body_content = '',
|
|
1763
|
+
header_list = {},
|
|
1764
|
+
header_dict = {},
|
|
1765
|
+
header_imutable = {},
|
|
1766
|
+
print_http_status = true
|
|
1767
|
+
}
|
|
1768
|
+
self.add_body_content = function (body)
|
|
1769
|
+
self.body_content = self.body_content..(body or '')
|
|
1770
|
+
return self
|
|
1771
|
+
end
|
|
1772
|
+
self.add_imutable_header = function (header, value, cond)
|
|
1773
|
+
if cond == false then return self end
|
|
1774
|
+
if self.header_imutable[header] == nil then
|
|
1775
|
+
self.header_list[#self.header_list + 1] = header
|
|
1776
|
+
self.header_dict[header] = value
|
|
1777
|
+
elseif self.header_imutable[header] == false then
|
|
1778
|
+
self.header_dict[header] = value
|
|
1779
|
+
end
|
|
1780
|
+
self.header_imutable[header] = true
|
|
1781
|
+
return self
|
|
1782
|
+
end
|
|
1783
|
+
self.add_mutable_header = function (header, value, cond)
|
|
1784
|
+
if cond == false then return self end
|
|
1785
|
+
if self.header_imutable[header] == nil then
|
|
1786
|
+
self.header_list[#self.header_list + 1] = header
|
|
1787
|
+
self.header_imutable[header] = false
|
|
1788
|
+
self.header_dict[header] = value
|
|
1789
|
+
end
|
|
1790
|
+
return self
|
|
1791
|
+
end
|
|
1792
|
+
self.add_custom_headers = function(header_list, header_dict)
|
|
1793
|
+
local index = 1
|
|
1794
|
+
while header_list and #header_list >= index do
|
|
1795
|
+
local header = header_list[index]
|
|
1796
|
+
local value = header_dict[header]
|
|
1797
|
+
if self.header_imutable[header] == nil then
|
|
1798
|
+
self.header_list[#self.header_list + 1] = header
|
|
1799
|
+
self.header_imutable[header] = false
|
|
1800
|
+
self.header_dict[header] = value
|
|
1801
|
+
elseif self.header_imutable[header] == false then
|
|
1802
|
+
self.header_dict[header] = value
|
|
1803
|
+
end
|
|
1804
|
+
index = index + 1
|
|
1805
|
+
end
|
|
1806
|
+
return self
|
|
1807
|
+
end
|
|
1808
|
+
self.not_status = function()
|
|
1809
|
+
self.print_http_status = false
|
|
1810
|
+
return self
|
|
1811
|
+
end
|
|
1812
|
+
self.to_http_protocol = function ()
|
|
1813
|
+
local index = 1
|
|
1814
|
+
local request = method..' '..uri..' HTTP/1'..'.1\r\n'
|
|
1815
|
+
while index <= #self.header_list do
|
|
1816
|
+
local header = self.header_list[index]
|
|
1817
|
+
local value = self.header_dict[header]
|
|
1818
|
+
request = request..header..': '..value..'\r\n'
|
|
1819
|
+
index = index + 1
|
|
1820
|
+
end
|
|
1821
|
+
request = request..'\r\n'
|
|
1822
|
+
if method ~= 'GET' and method ~= 'HEAD' and #self.body_content > 0 then
|
|
1823
|
+
request = request..self.body_content..'\r\n\r\n'
|
|
1824
|
+
end
|
|
1825
|
+
return request, function() end
|
|
1826
|
+
end
|
|
1827
|
+
self.to_curl_cmd = function ()
|
|
1828
|
+
local index = 1
|
|
1829
|
+
local request = 'curl -L -'..'-silent -'..'-insecure '
|
|
1830
|
+
if self.print_http_status then
|
|
1831
|
+
request = request..'-w "\n%{http_code}" '
|
|
1832
|
+
end
|
|
1833
|
+
if method == 'HEAD' then
|
|
1834
|
+
request = request..'-'..'-HEAD '
|
|
1835
|
+
else
|
|
1836
|
+
request = request..'-X '..method..' '
|
|
1837
|
+
end
|
|
1838
|
+
while index <= #self.header_list do
|
|
1839
|
+
local header = self.header_list[index]
|
|
1840
|
+
local value = self.header_dict[header]
|
|
1841
|
+
request = request..'-H "'..header..': '..value..'" '
|
|
1842
|
+
index = index + 1
|
|
1843
|
+
end
|
|
1844
|
+
if method ~= 'GET' and method ~= 'HEAD' and #self.body_content > 0 then
|
|
1845
|
+
request = request..'-d \''..self.body_content..'\' '
|
|
1846
|
+
end
|
|
1847
|
+
request = request..uri
|
|
1848
|
+
return request, function() end
|
|
1849
|
+
end
|
|
1850
|
+
self.to_wget_cmd = function ()
|
|
1851
|
+
local request = 'wget -'..'-quiet -'..'-output-document=-'
|
|
1852
|
+
if method == 'HEAD' then
|
|
1853
|
+
request = request..' -'..'-method=HEAD'
|
|
1854
|
+
elseif method ~= 'GET' then
|
|
1855
|
+
request = request..' -'..'-method='..method
|
|
1856
|
+
end
|
|
1857
|
+
for index, header in ipairs(self.header_list) do
|
|
1858
|
+
local value = self.header_dict[header]
|
|
1859
|
+
if value then
|
|
1860
|
+
local escaped_value = value:gsub('"', '\\"')
|
|
1861
|
+
request = request..' -'..'-header="'..header..': '..escaped_value..'"'
|
|
1862
|
+
end
|
|
1863
|
+
end
|
|
1864
|
+
if method ~= 'GET' and method ~= 'HEAD' and #self.body_content > 0 then
|
|
1865
|
+
local escaped_body = self.body_content:gsub('"', '\\"')
|
|
1866
|
+
request = request..' -'..'-body-data="'..escaped_body..'"'
|
|
1867
|
+
end
|
|
1868
|
+
request = request..' '..uri
|
|
1869
|
+
return request, function() end
|
|
1870
|
+
end
|
|
1871
|
+
return self
|
|
1872
|
+
end
|
|
1873
|
+
return {
|
|
1874
|
+
is_ok=is_ok,
|
|
1875
|
+
is_ok_header=is_ok_header,
|
|
1876
|
+
is_redirect=is_redirect,
|
|
1877
|
+
url_search_param=url_search_param,
|
|
1878
|
+
create_request=create_request
|
|
1879
|
+
}
|
|
1880
|
+
end
|
|
1881
|
+
--
|
|
1882
|
+
return main_55789ed4b7f0()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gamely/gly-engine-lite",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"author": "RodrigoDornelles",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://docs.gamely.com.br",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"funding": "https://github.com/sponsors/RodrigoDornelles",
|
|
9
9
|
"bugs": "https://github.com/gamelly/gly-engine/issues",
|
|
10
10
|
"description": "Game Engine written in 100% lua that runs in a vacuum.",
|
|
11
|
-
"main": "dist/
|
|
11
|
+
"main": "dist/main.lua",
|
|
12
|
+
"types": "types/main.d.ts",
|
|
12
13
|
"keywords": [
|
|
13
14
|
"game engine",
|
|
14
15
|
"game",
|
package/types/main.d.ts
ADDED