@gamely/gly-engine-lite 0.0.17 → 0.0.19
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 +568 -178
- package/package.json +2 -2
package/dist/main.lua
CHANGED
|
@@ -1,50 +1,110 @@
|
|
|
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
|
|
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()
|
|
39
46
|
local application = application_default
|
|
40
47
|
local engine = {
|
|
41
48
|
keyboard = function(a, b, c, d) end,
|
|
42
49
|
current = application_default,
|
|
43
50
|
root = application_default
|
|
44
51
|
}
|
|
52
|
+
local cfg_system = {
|
|
53
|
+
exit = native_system_exit,
|
|
54
|
+
reset = native_system_reset,
|
|
55
|
+
title = native_system_title,
|
|
56
|
+
get_fps = native_system_get_fps,
|
|
57
|
+
get_secret = native_system_get_secret,
|
|
58
|
+
get_language = native_system_get_language
|
|
59
|
+
}
|
|
60
|
+
local cfg_media = {
|
|
61
|
+
bootstrap=native_media_bootstrap,
|
|
62
|
+
position=native_media_position,
|
|
63
|
+
resize=native_media_resize,
|
|
64
|
+
pause=native_media_pause,
|
|
65
|
+
load=native_media_load,
|
|
66
|
+
play=native_media_play
|
|
67
|
+
}
|
|
68
|
+
local cfg_poly = {
|
|
69
|
+
repeats = {
|
|
70
|
+
native_cfg_poly_repeat_0 or false,
|
|
71
|
+
native_cfg_poly_repeat_1 or false,
|
|
72
|
+
native_cfg_poly_repeat_2 or false
|
|
73
|
+
},
|
|
74
|
+
triangle = native_draw_triangle,
|
|
75
|
+
poly2 = native_draw_poly2,
|
|
76
|
+
poly = native_draw_poly,
|
|
77
|
+
line = native_draw_line
|
|
78
|
+
}
|
|
45
79
|
local cfg_text = {
|
|
46
80
|
font_previous = native_text_font_previous
|
|
47
81
|
}
|
|
82
|
+
local cfg_http = {
|
|
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
|
|
95
|
+
}
|
|
96
|
+
local cfg_base64 = {
|
|
97
|
+
decode = native_base64_decode,
|
|
98
|
+
encode = native_base64_encode
|
|
99
|
+
}
|
|
100
|
+
local cfg_json = {
|
|
101
|
+
decode = native_json_decode,
|
|
102
|
+
encode = native_json_encode
|
|
103
|
+
}
|
|
104
|
+
local cfg_xml = {
|
|
105
|
+
decode = native_xml_decode,
|
|
106
|
+
encode = native_xml_encode
|
|
107
|
+
}
|
|
48
108
|
function native_callback_loop(dt)
|
|
49
109
|
std.milis = std.milis + dt
|
|
50
110
|
std.delta = dt
|
|
@@ -64,6 +124,12 @@ end
|
|
|
64
124
|
function native_callback_keyboard(key, value)
|
|
65
125
|
engine.keyboard(std, engine, key, value)
|
|
66
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
|
|
67
133
|
function native_callback_init(width, height, game_lua)
|
|
68
134
|
application = zeebo_module.loadgame(game_lua)
|
|
69
135
|
if application then
|
|
@@ -91,28 +157,34 @@ std.text.font_default=native_text_font_default
|
|
|
91
157
|
std.draw.clear=function(tint)
|
|
92
158
|
native_draw_clear(tint, 0, 0, application.data.width, application.data.height)
|
|
93
159
|
end
|
|
160
|
+
engine.root = application
|
|
94
161
|
zeebo_module.require(std, application, engine)
|
|
95
162
|
:package('@memory', engine_raw_memory)
|
|
96
|
-
:package('@game', engine_game,
|
|
163
|
+
:package('@game', engine_game, cfg_system)
|
|
97
164
|
:package('@math', engine_math)
|
|
98
165
|
:package('@array', engine_array)
|
|
99
166
|
:package('@key', engine_key, {})
|
|
100
167
|
:package('@draw.fps', engine_draw_fps)
|
|
101
168
|
:package('@draw.text', engine_draw_text, cfg_text)
|
|
102
|
-
:package('@draw.poly', engine_draw_poly,
|
|
169
|
+
:package('@draw.poly', engine_draw_poly, cfg_poly)
|
|
103
170
|
:package('@color', color)
|
|
171
|
+
:package('@log', engine_log, cfg_log)
|
|
104
172
|
:package('math', engine_math.clib)
|
|
105
173
|
:package('math.random', engine_math.clib_random)
|
|
106
|
-
:package('http', engine_http,
|
|
107
|
-
:package('
|
|
108
|
-
:package('
|
|
109
|
-
:package('
|
|
110
|
-
:package('
|
|
174
|
+
:package('http', engine_http, cfg_http)
|
|
175
|
+
:package('base64', engine_encoder, cfg_base64)
|
|
176
|
+
:package('json', engine_encoder, cfg_json)
|
|
177
|
+
:package('xml', engine_encoder, cfg_xml)
|
|
178
|
+
:package('i18n', engine_i18n, cfg_system)
|
|
179
|
+
:package('hash', engine_hash, cfg_system)
|
|
180
|
+
:package('media.video', engine_media, cfg_media)
|
|
181
|
+
:package('media.audio', engine_media, cfg_media)
|
|
182
|
+
:package('mock.video', engine_media)
|
|
183
|
+
:package('mock.audio', engine_media)
|
|
111
184
|
:run()
|
|
112
185
|
application.data.width, std.app.width = width, width
|
|
113
186
|
application.data.height, std.app.height = height, height
|
|
114
187
|
std.app.title(application.meta.title..' - '..application.meta.version)
|
|
115
|
-
engine.root = application
|
|
116
188
|
engine.current = application
|
|
117
189
|
application.callbacks.init(std, application.data)
|
|
118
190
|
end
|
|
@@ -126,13 +198,13 @@ version=version
|
|
|
126
198
|
}
|
|
127
199
|
return P
|
|
128
200
|
end
|
|
129
|
-
|
|
130
|
-
return '0.0.
|
|
201
|
+
src_version_55d740741220 = function()
|
|
202
|
+
return '0.0.19'
|
|
131
203
|
end
|
|
132
204
|
--
|
|
133
|
-
|
|
134
|
-
local zeebo_pipeline =
|
|
135
|
-
local application_default =
|
|
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()
|
|
136
208
|
local function default(application, defaults)
|
|
137
209
|
if not application then return nil end
|
|
138
210
|
local index = 1
|
|
@@ -330,7 +402,7 @@ require = require
|
|
|
330
402
|
return P
|
|
331
403
|
end
|
|
332
404
|
--
|
|
333
|
-
|
|
405
|
+
src_lib_engine_api_encoder_55d740797c20 = function()
|
|
334
406
|
local function install(std, engine, library, name)
|
|
335
407
|
std = std or {}
|
|
336
408
|
std[name] = {
|
|
@@ -345,8 +417,8 @@ install=install
|
|
|
345
417
|
return P
|
|
346
418
|
end
|
|
347
419
|
--
|
|
348
|
-
|
|
349
|
-
local util_decorator =
|
|
420
|
+
src_lib_engine_api_app_55d7407cdb00 = function()
|
|
421
|
+
local util_decorator = src_lib_util_decorator_55d7407a7e30()
|
|
350
422
|
local function reset(std, engine)
|
|
351
423
|
if std.node then
|
|
352
424
|
std.bus.emit('exit')
|
|
@@ -377,7 +449,7 @@ end)
|
|
|
377
449
|
std.app.title = util_decorator.prefix1(config.set_title, title)
|
|
378
450
|
std.app.exit = util_decorator.prefix1(std, exit)
|
|
379
451
|
std.app.reset = util_decorator.prefix2(std, engine, reset)
|
|
380
|
-
std.app.get_fps = config.
|
|
452
|
+
std.app.get_fps = config.get_fps
|
|
381
453
|
return std.app
|
|
382
454
|
end
|
|
383
455
|
local P = {
|
|
@@ -386,7 +458,7 @@ install=install
|
|
|
386
458
|
return P
|
|
387
459
|
end
|
|
388
460
|
--
|
|
389
|
-
|
|
461
|
+
src_lib_engine_api_hash_55d740798450 = function()
|
|
390
462
|
local function djb2(digest)
|
|
391
463
|
local index = 1
|
|
392
464
|
local hash = 5381
|
|
@@ -399,27 +471,12 @@ hash = string.format('%08x', hash)
|
|
|
399
471
|
hash = tonumber(hash:sub(#hash - 7), 16)
|
|
400
472
|
return hash
|
|
401
473
|
end
|
|
402
|
-
local function
|
|
403
|
-
local
|
|
404
|
-
local digest = ''
|
|
405
|
-
while index <= #all_your_secrets do
|
|
406
|
-
local value = all_your_secrets[index]
|
|
407
|
-
if type(value) == 'function' then
|
|
408
|
-
digest = digest..tostring(value())
|
|
409
|
-
else
|
|
410
|
-
digest = digest..tostring(value)
|
|
411
|
-
end
|
|
412
|
-
index = index + 1
|
|
413
|
-
end
|
|
414
|
-
return djb2(digest)
|
|
415
|
-
end
|
|
416
|
-
local function install(std, engine, all_your_secrets)
|
|
417
|
-
local id = fingerprint(all_your_secrets or {'not secret!'})
|
|
474
|
+
local function install(std, engine, cfg_system)
|
|
475
|
+
local id = djb2(cfg_system.get_secret())
|
|
418
476
|
std = std or {}
|
|
419
477
|
std.hash = std.hash or {}
|
|
420
478
|
std.hash.djb2 = djb2
|
|
421
479
|
std.hash.fingerprint = function() return id end
|
|
422
|
-
return {hash=std.hash}
|
|
423
480
|
end
|
|
424
481
|
local P = {
|
|
425
482
|
install = install
|
|
@@ -427,8 +484,8 @@ install = install
|
|
|
427
484
|
return P
|
|
428
485
|
end
|
|
429
486
|
--
|
|
430
|
-
|
|
431
|
-
local zeebo_pipeline =
|
|
487
|
+
src_lib_engine_api_http_55d74079e880 = function()
|
|
488
|
+
local zeebo_pipeline = src_lib_util_pipeline_55d7407bc4c0()
|
|
432
489
|
local function fast(self)
|
|
433
490
|
self.speed = '_fast'
|
|
434
491
|
return self
|
|
@@ -457,17 +514,28 @@ local function failed(self, handler_func)
|
|
|
457
514
|
self.failed_handler = handler_func
|
|
458
515
|
return self
|
|
459
516
|
end
|
|
460
|
-
local function
|
|
517
|
+
local function http_error(self, handler_func)
|
|
461
518
|
self.error_handler = handler_func
|
|
462
519
|
return self
|
|
463
520
|
end
|
|
464
|
-
local function request(method, std, engine,
|
|
521
|
+
local function request(method, std, engine, protocol)
|
|
465
522
|
local callback_handler = function()
|
|
523
|
+
if std.node then
|
|
466
524
|
std.node.emit(engine.current, 'http')
|
|
525
|
+
elseif engine.current.callbacks.http then
|
|
526
|
+
engine.current.callbacks.http(std, engine.current.data)
|
|
527
|
+
end
|
|
467
528
|
end
|
|
468
529
|
return function (url)
|
|
530
|
+
if protocol.has_callback then
|
|
531
|
+
engine.http_count = engine.http_count + 1
|
|
532
|
+
end
|
|
533
|
+
if protocol.force then
|
|
534
|
+
url = url:gsub("^[^:]+://", protocol.force.."://")
|
|
535
|
+
end
|
|
469
536
|
local game = engine.current.data
|
|
470
537
|
local self = {
|
|
538
|
+
id = engine.http_count,
|
|
471
539
|
url = url,
|
|
472
540
|
speed = '',
|
|
473
541
|
method = method,
|
|
@@ -476,21 +544,17 @@ header_list = {},
|
|
|
476
544
|
header_dict = {},
|
|
477
545
|
param_list = {},
|
|
478
546
|
param_dict = {},
|
|
479
|
-
callback_handler = callback_handler,
|
|
480
547
|
success_handler = function (std, game) end,
|
|
481
548
|
failed_handler = function (std, game) end,
|
|
482
549
|
error_handler = function (std, game) end,
|
|
483
|
-
std = std,
|
|
484
|
-
game = game,
|
|
485
550
|
fast = fast,
|
|
486
551
|
body = body,
|
|
487
552
|
param = param,
|
|
488
553
|
header = header,
|
|
489
554
|
success = success,
|
|
490
555
|
failed = failed,
|
|
491
|
-
error =
|
|
556
|
+
error = http_error,
|
|
492
557
|
run = zeebo_pipeline.run,
|
|
493
|
-
protocol_handler = protocol_handler
|
|
494
558
|
}
|
|
495
559
|
self.promise = function()
|
|
496
560
|
zeebo_pipeline.stop(self)
|
|
@@ -499,29 +563,31 @@ self.resolve = function()
|
|
|
499
563
|
zeebo_pipeline.resume(self)
|
|
500
564
|
end
|
|
501
565
|
self.set = function (key, value)
|
|
502
|
-
|
|
566
|
+
std.http[key] = value
|
|
503
567
|
end
|
|
504
568
|
self.pipeline = {
|
|
505
569
|
function()
|
|
506
|
-
self
|
|
570
|
+
if protocol.has_callback then engine.http_requests[self.id] = self end
|
|
571
|
+
protocol.handler(self, self.id)
|
|
507
572
|
end,
|
|
508
573
|
function()
|
|
509
|
-
|
|
510
|
-
if
|
|
511
|
-
self.success_handler(
|
|
512
|
-
elseif
|
|
513
|
-
self.error_handler(
|
|
574
|
+
callback_handler(std, game)
|
|
575
|
+
if std.http.ok then
|
|
576
|
+
self.success_handler(std, game)
|
|
577
|
+
elseif std.http.error or not std.http.status then
|
|
578
|
+
self.error_handler(std, game)
|
|
514
579
|
else
|
|
515
|
-
self.failed_handler(
|
|
580
|
+
self.failed_handler(std, game)
|
|
516
581
|
end
|
|
517
582
|
end,
|
|
518
583
|
function ()
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
584
|
+
std.http.ok = nil
|
|
585
|
+
std.http.body = nil
|
|
586
|
+
std.http.error = nil
|
|
587
|
+
std.http.status = nil
|
|
523
588
|
end,
|
|
524
589
|
function()
|
|
590
|
+
if protocol.has_callback then engine.http_requests[self.id] = nil end
|
|
525
591
|
zeebo_pipeline.reset(self)
|
|
526
592
|
end
|
|
527
593
|
}
|
|
@@ -529,20 +595,21 @@ return self
|
|
|
529
595
|
end
|
|
530
596
|
end
|
|
531
597
|
local function install(std, engine, protocol)
|
|
532
|
-
|
|
598
|
+
assert(protocol.handler, 'missing protocol handler')
|
|
599
|
+
if protocol.has_callback then
|
|
600
|
+
engine.http_count = 0
|
|
601
|
+
engine.http_requests = {}
|
|
602
|
+
end
|
|
533
603
|
std.http = std.http or {}
|
|
534
|
-
std.http.get=request('GET', std, engine,
|
|
535
|
-
std.http.head=request('HEAD', std, engine,
|
|
536
|
-
std.http.post=request('POST', std, engine,
|
|
537
|
-
std.http.put=request('PUT', std, engine,
|
|
538
|
-
std.http.delete=request('DELETE', std, engine,
|
|
539
|
-
std.http.patch=request('PATCH', std, engine,
|
|
604
|
+
std.http.get=request('GET', std, engine, protocol)
|
|
605
|
+
std.http.head=request('HEAD', std, engine, protocol)
|
|
606
|
+
std.http.post=request('POST', std, engine, protocol)
|
|
607
|
+
std.http.put=request('PUT', std, engine, protocol)
|
|
608
|
+
std.http.delete=request('DELETE', std, engine, protocol)
|
|
609
|
+
std.http.patch=request('PATCH', std, engine, protocol)
|
|
540
610
|
if protocol.install then
|
|
541
611
|
protocol.install(std, engine)
|
|
542
612
|
end
|
|
543
|
-
return {
|
|
544
|
-
std={http=std.http}
|
|
545
|
-
}
|
|
546
613
|
end
|
|
547
614
|
local P = {
|
|
548
615
|
install=install
|
|
@@ -550,7 +617,7 @@ install=install
|
|
|
550
617
|
return P
|
|
551
618
|
end
|
|
552
619
|
--
|
|
553
|
-
|
|
620
|
+
src_lib_engine_api_i18n_55d74075aa10 = function()
|
|
554
621
|
local language = 'en-US'
|
|
555
622
|
local language_default = 'en-US'
|
|
556
623
|
local language_list = {}
|
|
@@ -607,21 +674,24 @@ return function (x, y, text, a, b, c)
|
|
|
607
674
|
return func(x, y, get_text(text), a, b, c)
|
|
608
675
|
end
|
|
609
676
|
end
|
|
610
|
-
local function
|
|
611
|
-
std.bus.listen('ret_i18n', function(result)
|
|
612
|
-
update_languages(result)
|
|
613
|
-
end)
|
|
614
|
-
std.bus.emit_next('i18n')
|
|
615
|
-
end
|
|
616
|
-
local function install(std, engine, system_language)
|
|
677
|
+
local function install(std, engine, cfg)
|
|
617
678
|
if not (std and std.text and std.text.print) then
|
|
618
679
|
error('missing draw text')
|
|
619
680
|
end
|
|
620
681
|
local old_put = std.text.put
|
|
621
682
|
local old_print = std.text.print
|
|
622
683
|
local old_print_ex = std.text.print_ex
|
|
623
|
-
|
|
624
|
-
|
|
684
|
+
local callback_lang = function(result)
|
|
685
|
+
update_languages(result)
|
|
686
|
+
if cfg and cfg.get_language then
|
|
687
|
+
set_language(cfg.get_language())
|
|
688
|
+
end
|
|
689
|
+
end
|
|
690
|
+
if not std.node and engine.root.callbacks.i18n then
|
|
691
|
+
callback_lang(engine.root.callbacks.i18n())
|
|
692
|
+
else
|
|
693
|
+
std.bus.listen('ret_i18n', callback_lang)
|
|
694
|
+
std.bus.emit_next('i18n')
|
|
625
695
|
end
|
|
626
696
|
std.text.put = decorator_draw_text(old_put)
|
|
627
697
|
std.text.print = decorator_draw_text(old_print)
|
|
@@ -632,23 +702,14 @@ std.i18n.get_language = get_language
|
|
|
632
702
|
std.i18n.set_language = set_language
|
|
633
703
|
std.i18n.back = back_language
|
|
634
704
|
std.i18n.next = next_language
|
|
635
|
-
return {
|
|
636
|
-
std={
|
|
637
|
-
i18n=std.i18n,
|
|
638
|
-
draw={
|
|
639
|
-
text=std.draw.text
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
705
|
end
|
|
644
706
|
local P = {
|
|
645
|
-
event_bus=event_bus,
|
|
646
707
|
install=install
|
|
647
708
|
}
|
|
648
709
|
return P
|
|
649
710
|
end
|
|
650
711
|
--
|
|
651
|
-
|
|
712
|
+
src_lib_engine_api_key_55d7407bfbd0 = function()
|
|
652
713
|
local function real_key(std, engine, rkey, rvalue)
|
|
653
714
|
local value = rvalue == 1 or rvalue == true
|
|
654
715
|
local key = engine.key_bindings[rkey] or (std.key.axis[rkey] and rkey)
|
|
@@ -663,6 +724,8 @@ std.key.axis.y = std.key.axis.down - std.key.axis.up
|
|
|
663
724
|
end
|
|
664
725
|
std.bus.emit('key')
|
|
665
726
|
end
|
|
727
|
+
local a = std.key.axis
|
|
728
|
+
std.key.press.any = (a.left + a.right + a.down + a.up + a.a + a.b + a.c + a.d + a.menu) > 0
|
|
666
729
|
end
|
|
667
730
|
local function real_keydown(std, engine, key)
|
|
668
731
|
real_key(std, engine, key, 1)
|
|
@@ -686,7 +749,54 @@ install = install
|
|
|
686
749
|
return P
|
|
687
750
|
end
|
|
688
751
|
--
|
|
689
|
-
|
|
752
|
+
src_lib_engine_api_log_55d7407a7ec0 = function()
|
|
753
|
+
local util_decorator = src_lib_util_decorator_55d7407a7e30()
|
|
754
|
+
local logging_types = {
|
|
755
|
+
'none', 'fatal', 'error', 'warn', 'debug', 'info'
|
|
756
|
+
}
|
|
757
|
+
local function level(engine, lpf, lpn, level)
|
|
758
|
+
local l = lpf[level] or lpn[level] or level
|
|
759
|
+
if type(l) ~= 'number' or l <= 0 or l > #logging_types then
|
|
760
|
+
error('logging level not exist: '..tostring(level))
|
|
761
|
+
end
|
|
762
|
+
engine.loglevel = l
|
|
763
|
+
end
|
|
764
|
+
local function init(std, engine, printers)
|
|
765
|
+
local index = 1
|
|
766
|
+
local level_per_func = {}
|
|
767
|
+
local level_per_name = {}
|
|
768
|
+
while index <= #logging_types do
|
|
769
|
+
local ltype = logging_types[index]
|
|
770
|
+
local lfunc = function() end
|
|
771
|
+
if index > 1 and printers[ltype] then
|
|
772
|
+
lfunc = (function (level)
|
|
773
|
+
return function(message)
|
|
774
|
+
if engine.loglevel >= level then
|
|
775
|
+
printers[ltype](message)
|
|
776
|
+
end
|
|
777
|
+
end
|
|
778
|
+
end)(index - 1)
|
|
779
|
+
end
|
|
780
|
+
level_per_func[lfunc] = index - 1
|
|
781
|
+
level_per_name[ltype] = index - 1
|
|
782
|
+
std.log[ltype] = lfunc
|
|
783
|
+
index = index + 1
|
|
784
|
+
end
|
|
785
|
+
std.log.level = util_decorator.prefix3(engine, level_per_func, level_per_name, level)
|
|
786
|
+
end
|
|
787
|
+
local function install(std, engine, printers)
|
|
788
|
+
std.log = std.log or {}
|
|
789
|
+
engine.loglevel = #logging_types
|
|
790
|
+
std.log.init = util_decorator.prefix2(std, engine, init)
|
|
791
|
+
std.log.init(printers)
|
|
792
|
+
end
|
|
793
|
+
local P = {
|
|
794
|
+
install = install
|
|
795
|
+
}
|
|
796
|
+
return P
|
|
797
|
+
end
|
|
798
|
+
--
|
|
799
|
+
src_lib_engine_api_math_55d740799d40 = function()
|
|
690
800
|
local function abs(value)
|
|
691
801
|
if value < 0 then
|
|
692
802
|
return -value
|
|
@@ -705,10 +815,6 @@ end
|
|
|
705
815
|
local function clamp2(value, value_min, value_max)
|
|
706
816
|
return (value - value_min) % (value_max - value_min + 1) + value_min
|
|
707
817
|
end
|
|
708
|
-
local function cycle(passed, duration)
|
|
709
|
-
local endtime = (passed) % duration
|
|
710
|
-
return ((endtime == 0 and (passed % (duration * 2)) or endtime)) / duration
|
|
711
|
-
end
|
|
712
818
|
local function dir(value, alpha)
|
|
713
819
|
alpha = alpha or 0
|
|
714
820
|
if value < -alpha then
|
|
@@ -720,11 +826,15 @@ return 0
|
|
|
720
826
|
end
|
|
721
827
|
end
|
|
722
828
|
local function dis(x1,y1,x2,y2)
|
|
723
|
-
|
|
829
|
+
local sqr = 1/2
|
|
830
|
+
return ((x2 - x1) ^ 2 + (y2 - y1) ^ 2) ^ (sqr ~= 0 and sqr or 1)
|
|
724
831
|
end
|
|
725
832
|
local function dis2(x1,y1,x2,y2)
|
|
726
833
|
return (x2 - x1) ^ 2 + (y2 - y1) ^ 2
|
|
727
834
|
end
|
|
835
|
+
local function dis3(x1,y1,x2,y2)
|
|
836
|
+
return abs(x1 - x2) + abs(x2 - y2)
|
|
837
|
+
end
|
|
728
838
|
local function lerp(a, b, alpha)
|
|
729
839
|
return a + alpha * ( b - a )
|
|
730
840
|
end
|
|
@@ -765,31 +875,20 @@ index = index + 1
|
|
|
765
875
|
end
|
|
766
876
|
return min_value
|
|
767
877
|
end
|
|
768
|
-
local function saw(value)
|
|
769
|
-
if value < 0.25 then
|
|
770
|
-
return value * 4
|
|
771
|
-
elseif value < 0.50 then
|
|
772
|
-
return 1 - ((value - 0.25) * 4)
|
|
773
|
-
elseif value < 0.75 then
|
|
774
|
-
return ((value - 0.50) * 4) * (-1)
|
|
775
|
-
end
|
|
776
|
-
return ((value - 0.75) * 4) - 1
|
|
777
|
-
end
|
|
778
878
|
local function install(std)
|
|
779
879
|
std = std or {}
|
|
780
880
|
std.math = std.math or {}
|
|
781
881
|
std.math.abs=abs
|
|
782
882
|
std.math.clamp=clamp
|
|
783
883
|
std.math.clamp2=clamp2
|
|
784
|
-
std.math.cycle=cycle
|
|
785
884
|
std.math.dir=dir
|
|
786
885
|
std.math.dis=dis
|
|
787
886
|
std.math.dis2=dis2
|
|
887
|
+
std.math.dis3=dis3
|
|
788
888
|
std.math.lerp=lerp
|
|
789
889
|
std.math.map=map
|
|
790
890
|
std.math.max=max
|
|
791
891
|
std.math.min=min
|
|
792
|
-
std.math.saw=saw
|
|
793
892
|
return std.math
|
|
794
893
|
end
|
|
795
894
|
local function install_clib(std)
|
|
@@ -844,8 +943,8 @@ install = install_clib_random
|
|
|
844
943
|
return P;
|
|
845
944
|
end
|
|
846
945
|
--
|
|
847
|
-
|
|
848
|
-
local util_decorator =
|
|
946
|
+
src_lib_engine_api_array_55d740779000 = function()
|
|
947
|
+
local util_decorator = src_lib_util_decorator_55d7407a7e30()
|
|
849
948
|
local function array_map(array, func)
|
|
850
949
|
local res = {}
|
|
851
950
|
local index = 1
|
|
@@ -955,17 +1054,6 @@ index = index + 1
|
|
|
955
1054
|
end
|
|
956
1055
|
return true
|
|
957
1056
|
end
|
|
958
|
-
local function array_compare(array, func)
|
|
959
|
-
local index = 1
|
|
960
|
-
local length = #array
|
|
961
|
-
while index < length do
|
|
962
|
-
if not func(array[index], array[index + 1]) then
|
|
963
|
-
return false
|
|
964
|
-
end
|
|
965
|
-
index = index + 1
|
|
966
|
-
end
|
|
967
|
-
return true
|
|
968
|
-
end
|
|
969
1057
|
local function array_pipeline(std, array)
|
|
970
1058
|
local decorator_iterator = function(func)
|
|
971
1059
|
return function(self, func2, extra)
|
|
@@ -991,7 +1079,6 @@ first = decorator_reduce(array_first),
|
|
|
991
1079
|
last = decorator_reduce(array_last),
|
|
992
1080
|
some = decorator_reduce(array_some),
|
|
993
1081
|
every = decorator_reduce(array_every),
|
|
994
|
-
compare = decorator_reduce(array_compare),
|
|
995
1082
|
table = function(self) return self.array end,
|
|
996
1083
|
json = function(self) return std.json.encode(self.array) end
|
|
997
1084
|
}
|
|
@@ -999,6 +1086,7 @@ return self
|
|
|
999
1086
|
end
|
|
1000
1087
|
local function install(std, engine, library, name)
|
|
1001
1088
|
local lib = std[name] or {}
|
|
1089
|
+
lib.map = array_map
|
|
1002
1090
|
lib.filter = array_filter
|
|
1003
1091
|
lib.unique = array_unique
|
|
1004
1092
|
lib.each = array_foreach
|
|
@@ -1008,7 +1096,6 @@ lib.first = array_first
|
|
|
1008
1096
|
lib.last = array_last
|
|
1009
1097
|
lib.some = array_some
|
|
1010
1098
|
lib.every = array_every
|
|
1011
|
-
lib.compare = array_compare
|
|
1012
1099
|
lib.from = util_decorator.prefix1(std, array_pipeline)
|
|
1013
1100
|
std[name] = lib
|
|
1014
1101
|
end
|
|
@@ -1018,7 +1105,86 @@ install = install
|
|
|
1018
1105
|
return P
|
|
1019
1106
|
end
|
|
1020
1107
|
--
|
|
1021
|
-
|
|
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)
|
|
1116
|
+
return self
|
|
1117
|
+
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
|
+
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)
|
|
1145
|
+
}
|
|
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]
|
|
1165
|
+
end
|
|
1166
|
+
end
|
|
1167
|
+
local function install(std, engine, handlers, name)
|
|
1168
|
+
handlers = handlers or {}
|
|
1169
|
+
std.media = std.media or {}
|
|
1170
|
+
std.media.types = std.media.types or {}
|
|
1171
|
+
std.media.channels = std.media.channels or {}
|
|
1172
|
+
local mediatype = name:match('%w+%.(%w+)')
|
|
1173
|
+
local mediaid = #std.media.types + 1
|
|
1174
|
+
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)
|
|
1179
|
+
end
|
|
1180
|
+
end
|
|
1181
|
+
local P = {
|
|
1182
|
+
install=install
|
|
1183
|
+
}
|
|
1184
|
+
return P
|
|
1185
|
+
end
|
|
1186
|
+
--
|
|
1187
|
+
src_lib_engine_draw_fps_55d740798890 = function()
|
|
1022
1188
|
local function draw_fps(std, engine, show, pos_x, pos_y)
|
|
1023
1189
|
if show < 1 then return end
|
|
1024
1190
|
local x = engine.current.config.offset_x + pos_x
|
|
@@ -1035,19 +1201,19 @@ if show >= 3 then
|
|
|
1035
1201
|
std.draw.rect(0, x + 96, y, 40, 24)
|
|
1036
1202
|
end
|
|
1037
1203
|
std.draw.color(0x000000FF)
|
|
1038
|
-
std.
|
|
1204
|
+
std.text.font_size(16)
|
|
1039
1205
|
if show >= 3 then
|
|
1040
1206
|
local floor = std.math.floor or math.floor or function() return 'XX' end
|
|
1041
1207
|
local fps = floor((1/std.delta) * 1000)
|
|
1042
|
-
std.
|
|
1208
|
+
std.text.print(x + s, y, fps)
|
|
1043
1209
|
s = s + 46
|
|
1044
1210
|
end
|
|
1045
1211
|
if show >= 1 then
|
|
1046
|
-
std.
|
|
1212
|
+
std.text.print(x + s, y, engine.fps)
|
|
1047
1213
|
s = s + 46
|
|
1048
1214
|
end
|
|
1049
1215
|
if show >= 2 then
|
|
1050
|
-
std.
|
|
1216
|
+
std.text.print(x + s, y, engine.root.config.fps_max)
|
|
1051
1217
|
s = s + 46
|
|
1052
1218
|
end
|
|
1053
1219
|
end
|
|
@@ -1070,8 +1236,8 @@ install=install
|
|
|
1070
1236
|
return P
|
|
1071
1237
|
end
|
|
1072
1238
|
--
|
|
1073
|
-
|
|
1074
|
-
local util_decorator =
|
|
1239
|
+
src_lib_engine_draw_text_55d7407c8b90 = function()
|
|
1240
|
+
local util_decorator = src_lib_util_decorator_55d7407a7e30()
|
|
1075
1241
|
local function text_put(std, engine, font_previous, pos_x, pos_y, text, size)
|
|
1076
1242
|
size = size or 2
|
|
1077
1243
|
local hem = engine.current.data.width / 80
|
|
@@ -1098,7 +1264,7 @@ install=install
|
|
|
1098
1264
|
return P
|
|
1099
1265
|
end
|
|
1100
1266
|
--
|
|
1101
|
-
|
|
1267
|
+
src_lib_engine_draw_poly_55d740799b40 = function()
|
|
1102
1268
|
local function decorator_poo(object, func)
|
|
1103
1269
|
if not object or not func then return func end
|
|
1104
1270
|
return function(a, b, c, d)
|
|
@@ -1205,21 +1371,25 @@ install=install
|
|
|
1205
1371
|
return P
|
|
1206
1372
|
end
|
|
1207
1373
|
--
|
|
1208
|
-
|
|
1374
|
+
src_lib_engine_raw_memory_55d74079abd0 = function()
|
|
1209
1375
|
local memory_dict_unload = {}
|
|
1210
1376
|
local memory_dict = {}
|
|
1211
1377
|
local memory_list = {}
|
|
1212
|
-
local function
|
|
1213
|
-
if memory_dict[key] then
|
|
1378
|
+
local function cache_get(key)
|
|
1214
1379
|
return memory_dict[key]
|
|
1215
1380
|
end
|
|
1216
|
-
|
|
1217
|
-
return nil
|
|
1218
|
-
end
|
|
1381
|
+
local function cache_set(key, load_func, unload_func)
|
|
1219
1382
|
local value = load_func()
|
|
1220
1383
|
memory_list[#memory_list + 1] = key
|
|
1221
1384
|
memory_dict_unload[key] = unload_func
|
|
1222
1385
|
memory_dict[key] = value
|
|
1386
|
+
end
|
|
1387
|
+
local function cache(key, load_func, unload_func)
|
|
1388
|
+
local value = cache_get(key)
|
|
1389
|
+
if value == nil then
|
|
1390
|
+
cache_set(key, load_func, unload_func)
|
|
1391
|
+
value = cache_get(key)
|
|
1392
|
+
end
|
|
1223
1393
|
return value
|
|
1224
1394
|
end
|
|
1225
1395
|
local function unset(key)
|
|
@@ -1242,6 +1412,8 @@ local function install(std)
|
|
|
1242
1412
|
std = std or {}
|
|
1243
1413
|
std.mem = std.mem or {}
|
|
1244
1414
|
std.mem.cache = cache
|
|
1415
|
+
std.mem.cache_get = cache_get
|
|
1416
|
+
std.mem.cache_set = cache_set
|
|
1245
1417
|
std.mem.unset = unset
|
|
1246
1418
|
std.mem.gc_clear_all = gc_clear_all
|
|
1247
1419
|
return {
|
|
@@ -1254,7 +1426,75 @@ install=install
|
|
|
1254
1426
|
return P
|
|
1255
1427
|
end
|
|
1256
1428
|
--
|
|
1257
|
-
|
|
1429
|
+
src_lib_protocol_http_callback_55d74079bca0 = function()
|
|
1430
|
+
local http_util = src_lib_util_http_55d74078aa00()
|
|
1431
|
+
local callbacks = {
|
|
1432
|
+
['async-promise'] = function(self)
|
|
1433
|
+
return self:promise()
|
|
1434
|
+
end,
|
|
1435
|
+
['async-resolve'] = function(self)
|
|
1436
|
+
return self:resolve()
|
|
1437
|
+
end,
|
|
1438
|
+
['get-url'] = function(self)
|
|
1439
|
+
return self.url
|
|
1440
|
+
end,
|
|
1441
|
+
['get-fullurl'] = function(self)
|
|
1442
|
+
return self.url..http_util.url_search_param(self.param_list, self.param_dict)
|
|
1443
|
+
end,
|
|
1444
|
+
['get-method'] = function(self)
|
|
1445
|
+
return self.method
|
|
1446
|
+
end,
|
|
1447
|
+
['get-body'] = function(self)
|
|
1448
|
+
return self.body_content
|
|
1449
|
+
end,
|
|
1450
|
+
['get-param-count'] = function(self)
|
|
1451
|
+
return #self.param_list
|
|
1452
|
+
end,
|
|
1453
|
+
['get-param-name'] = function(self, data)
|
|
1454
|
+
return self.param_list[self.data]
|
|
1455
|
+
end,
|
|
1456
|
+
['get-param-data'] = function(self, data)
|
|
1457
|
+
return self.param_dict[self.data] or self.param_dict[self.param_list[self.data]]
|
|
1458
|
+
end,
|
|
1459
|
+
['get-header-count'] = function(self)
|
|
1460
|
+
return #self.header_list
|
|
1461
|
+
end,
|
|
1462
|
+
['get-header-name'] = function(self, data)
|
|
1463
|
+
return self.header_list[self.data]
|
|
1464
|
+
end,
|
|
1465
|
+
['get-header-data'] = function(self, data)
|
|
1466
|
+
return self.heeader_dict[self.data] or self.heeader_dict[self.header_list[self.data]]
|
|
1467
|
+
end,
|
|
1468
|
+
['set-status'] = function(self, data)
|
|
1469
|
+
self.set('status', data)
|
|
1470
|
+
self.set('ok', http_util.is_ok(data))
|
|
1471
|
+
end,
|
|
1472
|
+
['set-error'] = function(self, data)
|
|
1473
|
+
self.set('error', data)
|
|
1474
|
+
end,
|
|
1475
|
+
['set-ok'] = function(self, data)
|
|
1476
|
+
self.set('ok', data)
|
|
1477
|
+
end,
|
|
1478
|
+
['set-body'] = function(self, data)
|
|
1479
|
+
self.set('body', data)
|
|
1480
|
+
end,
|
|
1481
|
+
['add-body-data'] = function(self, data, std)
|
|
1482
|
+
self.set('body', (std.http.body or '')..data)
|
|
1483
|
+
end
|
|
1484
|
+
}
|
|
1485
|
+
local function native_http_callback(self, evt, data, std)
|
|
1486
|
+
if not callbacks[evt] then
|
|
1487
|
+
error('http evt '..evt..' not exist!')
|
|
1488
|
+
end
|
|
1489
|
+
return callbacks[evt](self, data, std)
|
|
1490
|
+
end
|
|
1491
|
+
local P = {
|
|
1492
|
+
func = native_http_callback
|
|
1493
|
+
}
|
|
1494
|
+
return P
|
|
1495
|
+
end
|
|
1496
|
+
--
|
|
1497
|
+
src_lib_object_root_55d7407b5bb0 = function()
|
|
1258
1498
|
local P = {
|
|
1259
1499
|
data={
|
|
1260
1500
|
width=1280,
|
|
@@ -1273,7 +1513,7 @@ config = {
|
|
|
1273
1513
|
offset_x = 0,
|
|
1274
1514
|
offset_y = 0,
|
|
1275
1515
|
require = '',
|
|
1276
|
-
fps_max =
|
|
1516
|
+
fps_max = 60,
|
|
1277
1517
|
fps_show = 0,
|
|
1278
1518
|
fps_drop = 5,
|
|
1279
1519
|
fps_time = 5
|
|
@@ -1284,7 +1524,7 @@ callbacks={
|
|
|
1284
1524
|
return P;
|
|
1285
1525
|
end
|
|
1286
1526
|
--
|
|
1287
|
-
|
|
1527
|
+
src_lib_object_color_55d7407a8380 = function()
|
|
1288
1528
|
local white = 0xFFFFFFFF
|
|
1289
1529
|
local lightgray = 0xC8CCCCFF
|
|
1290
1530
|
local gray = 0x828282FF
|
|
@@ -1346,7 +1586,7 @@ install = install
|
|
|
1346
1586
|
return P
|
|
1347
1587
|
end
|
|
1348
1588
|
--
|
|
1349
|
-
|
|
1589
|
+
src_lib_object_std_55d74076e7c0 = function()
|
|
1350
1590
|
local P = {
|
|
1351
1591
|
milis = 0,
|
|
1352
1592
|
delta = 0,
|
|
@@ -1400,14 +1640,15 @@ right=false,
|
|
|
1400
1640
|
a=false,
|
|
1401
1641
|
b=false,
|
|
1402
1642
|
c=false,
|
|
1403
|
-
d=false
|
|
1643
|
+
d=false,
|
|
1644
|
+
any=false
|
|
1404
1645
|
}
|
|
1405
1646
|
}
|
|
1406
1647
|
}
|
|
1407
1648
|
return P;
|
|
1408
1649
|
end
|
|
1409
1650
|
--
|
|
1410
|
-
|
|
1651
|
+
src_lib_util_pipeline_55d7407bc4c0 = function()
|
|
1411
1652
|
local function pipe(self)
|
|
1412
1653
|
return function()
|
|
1413
1654
|
self:run()
|
|
@@ -1457,7 +1698,7 @@ run=run
|
|
|
1457
1698
|
return P
|
|
1458
1699
|
end
|
|
1459
1700
|
--
|
|
1460
|
-
|
|
1701
|
+
src_lib_util_decorator_55d7407a7e30 = function()
|
|
1461
1702
|
local function decorator_prefix3(zig, zag, zom, func)
|
|
1462
1703
|
return function (a, b, c, d, e, f)
|
|
1463
1704
|
return func(zig, zag, zom, a, b, c, d, e, f)
|
|
@@ -1507,4 +1748,153 @@ prefix1 = decorator_prefix1
|
|
|
1507
1748
|
return P
|
|
1508
1749
|
end
|
|
1509
1750
|
--
|
|
1510
|
-
|
|
1751
|
+
src_lib_util_http_55d74078aa00 = function()
|
|
1752
|
+
local function is_ok(status)
|
|
1753
|
+
return (status and 200 <= status and status < 300) or false
|
|
1754
|
+
end
|
|
1755
|
+
local function is_ok_header(header)
|
|
1756
|
+
local status = tonumber(header:match('HTTP/%d.%d (%d%d%d)'))
|
|
1757
|
+
local ok = status and is_ok(status) or false
|
|
1758
|
+
return ok, status
|
|
1759
|
+
end
|
|
1760
|
+
local function is_redirect(status)
|
|
1761
|
+
return (status and 300 <= status and status < 400) or false
|
|
1762
|
+
end
|
|
1763
|
+
local function url_search_param(param_list, param_dict)
|
|
1764
|
+
local index, params = 1, ''
|
|
1765
|
+
while param_list and param_dict and index <= #param_list do
|
|
1766
|
+
local param = param_list[index]
|
|
1767
|
+
local value = param_dict[param]
|
|
1768
|
+
if #params == 0 then
|
|
1769
|
+
params = params..'?'
|
|
1770
|
+
else
|
|
1771
|
+
params = params..'&'
|
|
1772
|
+
end
|
|
1773
|
+
params = params..param..'='..(value or '')
|
|
1774
|
+
index = index + 1
|
|
1775
|
+
end
|
|
1776
|
+
return params
|
|
1777
|
+
end
|
|
1778
|
+
local function create_request(method, uri)
|
|
1779
|
+
local self = {
|
|
1780
|
+
body_content = '',
|
|
1781
|
+
header_list = {},
|
|
1782
|
+
header_dict = {},
|
|
1783
|
+
header_imutable = {},
|
|
1784
|
+
print_http_status = true
|
|
1785
|
+
}
|
|
1786
|
+
self.add_body_content = function (body)
|
|
1787
|
+
self.body_content = self.body_content..(body or '')
|
|
1788
|
+
return self
|
|
1789
|
+
end
|
|
1790
|
+
self.add_imutable_header = function (header, value, cond)
|
|
1791
|
+
if cond == false then return self end
|
|
1792
|
+
if self.header_imutable[header] == nil then
|
|
1793
|
+
self.header_list[#self.header_list + 1] = header
|
|
1794
|
+
self.header_dict[header] = value
|
|
1795
|
+
elseif self.header_imutable[header] == false then
|
|
1796
|
+
self.header_dict[header] = value
|
|
1797
|
+
end
|
|
1798
|
+
self.header_imutable[header] = true
|
|
1799
|
+
return self
|
|
1800
|
+
end
|
|
1801
|
+
self.add_mutable_header = function (header, value, cond)
|
|
1802
|
+
if cond == false then return self end
|
|
1803
|
+
if self.header_imutable[header] == nil then
|
|
1804
|
+
self.header_list[#self.header_list + 1] = header
|
|
1805
|
+
self.header_imutable[header] = false
|
|
1806
|
+
self.header_dict[header] = value
|
|
1807
|
+
end
|
|
1808
|
+
return self
|
|
1809
|
+
end
|
|
1810
|
+
self.add_custom_headers = function(header_list, header_dict)
|
|
1811
|
+
local index = 1
|
|
1812
|
+
while header_list and #header_list >= index do
|
|
1813
|
+
local header = header_list[index]
|
|
1814
|
+
local value = header_dict[header]
|
|
1815
|
+
if self.header_imutable[header] == nil then
|
|
1816
|
+
self.header_list[#self.header_list + 1] = header
|
|
1817
|
+
self.header_imutable[header] = false
|
|
1818
|
+
self.header_dict[header] = value
|
|
1819
|
+
elseif self.header_imutable[header] == false then
|
|
1820
|
+
self.header_dict[header] = value
|
|
1821
|
+
end
|
|
1822
|
+
index = index + 1
|
|
1823
|
+
end
|
|
1824
|
+
return self
|
|
1825
|
+
end
|
|
1826
|
+
self.not_status = function()
|
|
1827
|
+
self.print_http_status = false
|
|
1828
|
+
return self
|
|
1829
|
+
end
|
|
1830
|
+
self.to_http_protocol = function ()
|
|
1831
|
+
local index = 1
|
|
1832
|
+
local request = method..' '..uri..' HTTP/1.1\r\n'
|
|
1833
|
+
while index <= #self.header_list do
|
|
1834
|
+
local header = self.header_list[index]
|
|
1835
|
+
local value = self.header_dict[header]
|
|
1836
|
+
request = request..header..': '..value..'\r\n'
|
|
1837
|
+
index = index + 1
|
|
1838
|
+
end
|
|
1839
|
+
request = request..'\r\n'
|
|
1840
|
+
if method ~= 'GET' and method ~= 'HEAD' and #self.body_content > 0 then
|
|
1841
|
+
request = request..self.body_content..'\r\n\r\n'
|
|
1842
|
+
end
|
|
1843
|
+
return request, function() end
|
|
1844
|
+
end
|
|
1845
|
+
self.to_curl_cmd = function ()
|
|
1846
|
+
local index = 1
|
|
1847
|
+
local request = 'curl -L -'..'-silent -'..'-insecure '
|
|
1848
|
+
if self.print_http_status then
|
|
1849
|
+
request = request..'-w "\n%{http_code}" '
|
|
1850
|
+
end
|
|
1851
|
+
if method == 'HEAD' then
|
|
1852
|
+
request = request..'-'..'-HEAD '
|
|
1853
|
+
else
|
|
1854
|
+
request = request..'-X '..method..' '
|
|
1855
|
+
end
|
|
1856
|
+
while index <= #self.header_list do
|
|
1857
|
+
local header = self.header_list[index]
|
|
1858
|
+
local value = self.header_dict[header]
|
|
1859
|
+
request = request..'-H "'..header..': '..value..'" '
|
|
1860
|
+
index = index + 1
|
|
1861
|
+
end
|
|
1862
|
+
if method ~= 'GET' and method ~= 'HEAD' and #self.body_content > 0 then
|
|
1863
|
+
request = request..'-d \''..self.body_content..'\' '
|
|
1864
|
+
end
|
|
1865
|
+
request = request..uri
|
|
1866
|
+
return request, function() end
|
|
1867
|
+
end
|
|
1868
|
+
self.to_wget_cmd = function ()
|
|
1869
|
+
local request = 'wget -'..'-quiet -'..'-output-document=-'
|
|
1870
|
+
if method == 'HEAD' then
|
|
1871
|
+
request = request..' -'..'-method=HEAD'
|
|
1872
|
+
elseif method ~= 'GET' then
|
|
1873
|
+
request = request..' -'..'-method='..method
|
|
1874
|
+
end
|
|
1875
|
+
for index, header in ipairs(self.header_list) do
|
|
1876
|
+
local value = self.header_dict[header]
|
|
1877
|
+
if value then
|
|
1878
|
+
local escaped_value = value:gsub('"', '\\"')
|
|
1879
|
+
request = request..' -'..'-header="'..header..': '..escaped_value..'"'
|
|
1880
|
+
end
|
|
1881
|
+
end
|
|
1882
|
+
if method ~= 'GET' and method ~= 'HEAD' and #self.body_content > 0 then
|
|
1883
|
+
local escaped_body = self.body_content:gsub('"', '\\"')
|
|
1884
|
+
request = request..' -'..'-body-data="'..escaped_body..'"'
|
|
1885
|
+
end
|
|
1886
|
+
request = request..' '..uri
|
|
1887
|
+
return request, function() end
|
|
1888
|
+
end
|
|
1889
|
+
return self
|
|
1890
|
+
end
|
|
1891
|
+
return {
|
|
1892
|
+
is_ok=is_ok,
|
|
1893
|
+
is_ok_header=is_ok_header,
|
|
1894
|
+
is_redirect=is_redirect,
|
|
1895
|
+
url_search_param=url_search_param,
|
|
1896
|
+
create_request=create_request
|
|
1897
|
+
}
|
|
1898
|
+
end
|
|
1899
|
+
--
|
|
1900
|
+
return main_55d7407a19d0()
|
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.19",
|
|
4
4
|
"author": "RodrigoDornelles",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://docs.gamely.com.br",
|
|
@@ -8,7 +8,7 @@
|
|
|
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
12
|
"keywords": [
|
|
13
13
|
"game engine",
|
|
14
14
|
"game",
|