@gamely/gly-engine-lite 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/main.lua +304 -261
  2. package/package.json +9 -2
  3. package/README.md +0 -3
package/dist/main.lua CHANGED
@@ -1,49 +1,54 @@
1
1
  local math = ((function() local x, y = pcall(require, 'math'); return x and y end)()) or _G.math
2
- local source_version_55e9adc93630 = nil
3
- local source_shared_module_55e9adcfcee0 = nil
4
- local source_engine_api_data_encoder_55e9adcde7b0 = nil
5
- local source_engine_api_system_app_55e9add022a0 = nil
6
- local source_engine_api_data_hash_55e9adcec2d0 = nil
7
- local source_engine_api_io_http_55e9add09cc0 = nil
8
- local source_engine_api_data_i18n_55e9adcfb4b0 = nil
9
- local source_engine_api_system_key_55e9adcdd690 = nil
10
- local source_engine_api_debug_log_55e9adc93400 = nil
11
- local source_engine_api_system_math_55e9add12fd0 = nil
12
- local source_engine_api_data_array_55e9add03280 = nil
13
- local source_engine_api_io_media_55e9add024e0 = nil
14
- local source_engine_api_draw_fps_55e9add01370 = nil
15
- local source_engine_api_draw_text_55e9adcfd720 = nil
16
- local source_engine_api_draw_poly_55e9add12880 = nil
17
- local source_engine_api_raw_memory_55e9add0b7e0 = nil
18
- local source_engine_protocol_http_callback_55e9adcfea60 = nil
19
- local source_shared_var_object_root_55e9add070f0 = nil
20
- local source_engine_api_system_color_55e9adc94310 = nil
21
- local source_shared_var_object_std_55e9adc94a00 = nil
22
- local source_shared_functional_pipeline_55e9adca5c50 = nil
23
- local source_shared_functional_decorator_55e9adca5750 = nil
24
- local source_shared_string_encode_http_55e9add02410 = nil
25
- local source_shared_string_encode_url_55e9adca91f0 = nil
26
- local function main_55e9adc932d0()
27
- local version = source_version_55e9adc93630()
28
- local zeebo_module = source_shared_module_55e9adcfcee0()
29
- local engine_encoder = source_engine_api_data_encoder_55e9adcde7b0()
30
- local engine_game = source_engine_api_system_app_55e9add022a0()
31
- local engine_hash = source_engine_api_data_hash_55e9adcec2d0()
32
- local engine_http = source_engine_api_io_http_55e9add09cc0()
33
- local engine_i18n = source_engine_api_data_i18n_55e9adcfb4b0()
34
- local engine_key = source_engine_api_system_key_55e9adcdd690()
35
- local engine_log = source_engine_api_debug_log_55e9adc93400()
36
- local engine_math = source_engine_api_system_math_55e9add12fd0()
37
- local engine_array = source_engine_api_data_array_55e9add03280()
38
- local engine_media = source_engine_api_io_media_55e9add024e0()
39
- local engine_api_draw_fps = source_engine_api_draw_fps_55e9add01370()
40
- local engine_api_draw_text = source_engine_api_draw_text_55e9adcfd720()
41
- local engine_api_draw_poly = source_engine_api_draw_poly_55e9add12880()
42
- local engine_raw_memory = source_engine_api_raw_memory_55e9add0b7e0()
43
- local callback_http = source_engine_protocol_http_callback_55e9adcfea60()
44
- local application_default = source_shared_var_object_root_55e9add070f0()
45
- local color = source_engine_api_system_color_55e9adc94310()
46
- local std = source_shared_var_object_std_55e9adc94a00()
2
+ local source_version_22e4 = nil
3
+ local source_shared_engine_loadcore_22ef = nil
4
+ local source_shared_engine_loadgame_22fa = nil
5
+ local source_engine_api_data_encoder_230c = nil
6
+ local source_engine_api_system_app_2317 = nil
7
+ local source_engine_api_data_hash_2322 = nil
8
+ local source_engine_api_io_http_232d = nil
9
+ local source_engine_api_data_i18n_2338 = nil
10
+ local source_engine_api_system_key_2343 = nil
11
+ local source_engine_api_debug_log_234e = nil
12
+ local source_engine_api_system_math_2359 = nil
13
+ local source_engine_api_data_array_2364 = nil
14
+ local source_engine_api_io_media_236f = nil
15
+ local source_engine_api_draw_fps_237a = nil
16
+ local source_engine_api_draw_text_2385 = nil
17
+ local source_engine_api_draw_poly_2390 = nil
18
+ local source_engine_api_raw_memory_239b = nil
19
+ local source_engine_protocol_http_callback_23ad = nil
20
+ local source_shared_var_object_root_23bf = nil
21
+ local source_engine_api_system_color_23ca = nil
22
+ local source_shared_var_object_std_23d5 = nil
23
+ local source_shared_functional_pipeline_288a = nil
24
+ local source_shared_string_dsl_requires_2895 = nil
25
+ local source_shared_string_eval_file_2afc = nil
26
+ local source_shared_string_eval_code_2b07 = nil
27
+ local source_shared_functional_decorator_2d77 = nil
28
+ local source_shared_string_encode_http_5c3f = nil
29
+ local source_shared_string_encode_url_5c4a = nil
30
+ local function main_22db()
31
+ local version = source_version_22e4()
32
+ local loadcore = source_shared_engine_loadcore_22ef()
33
+ local loadgame = source_shared_engine_loadgame_22fa()
34
+ local engine_encoder = source_engine_api_data_encoder_230c()
35
+ local engine_game = source_engine_api_system_app_2317()
36
+ local engine_hash = source_engine_api_data_hash_2322()
37
+ local engine_http = source_engine_api_io_http_232d()
38
+ local engine_i18n = source_engine_api_data_i18n_2338()
39
+ local engine_key = source_engine_api_system_key_2343()
40
+ local engine_log = source_engine_api_debug_log_234e()
41
+ local engine_math = source_engine_api_system_math_2359()
42
+ local engine_array = source_engine_api_data_array_2364()
43
+ local engine_media = source_engine_api_io_media_236f()
44
+ local engine_api_draw_fps = source_engine_api_draw_fps_237a()
45
+ local engine_api_draw_text = source_engine_api_draw_text_2385()
46
+ local engine_api_draw_poly = source_engine_api_draw_poly_2390()
47
+ local engine_raw_memory = source_engine_api_raw_memory_239b()
48
+ local callback_http = source_engine_protocol_http_callback_23ad()
49
+ local application_default = source_shared_var_object_root_23bf()
50
+ local color = source_engine_api_system_color_23ca()
51
+ local std = source_shared_var_object_std_23d5()
47
52
  local application = application_default
48
53
  local engine = {
49
54
  keyboard = function(a, b, c, d) end,
@@ -134,7 +139,7 @@ end
134
139
  return nil
135
140
  end
136
141
  function native_callback_init(width, height, game_lua)
137
- application = zeebo_module.loadgame(game_lua)
142
+ application = loadgame.script(game_lua, application_default)
138
143
  if application then
139
144
  application.data.width = width
140
145
  application.data.height = height
@@ -151,7 +156,6 @@ std.draw.color=native_draw_color
151
156
  std.draw.font=native_draw_font
152
157
  std.draw.rect=native_draw_rect
153
158
  std.draw.line=native_draw_line
154
- std.draw.image=native_image_draw
155
159
  std.image.load=native_image_load
156
160
  std.image.draw=native_image_draw
157
161
  std.text.print=native_text_print
@@ -163,7 +167,7 @@ std.draw.clear=function(tint)
163
167
  native_draw_clear(tint, 0, 0, application.data.width, application.data.height)
164
168
  end
165
169
  engine.root = application
166
- zeebo_module.require(std, application, engine)
170
+ loadcore.setup(std, application, engine)
167
171
  :package('@memory', engine_raw_memory)
168
172
  :package('@game', engine_game, cfg_system)
169
173
  :package('@math', engine_math)
@@ -203,215 +207,162 @@ version=version
203
207
  }
204
208
  return P
205
209
  end
206
- source_version_55e9adc93630 = function()
207
- return '0.1.1'
210
+ source_version_22e4 = function()
211
+ return '0.1.3'
208
212
  end
209
213
  --
210
- source_shared_module_55e9adcfcee0 = function()
211
- local zeebo_pipeline = source_shared_functional_pipeline_55e9adca5c50()
212
- local application_default = source_shared_var_object_root_55e9add070f0()
213
- local function default(application, defaults)
214
- if not application then return nil end
215
- local index = 1
216
- local items = {'data', 'meta', 'config', 'callbacks'}
217
- local normalized_aplication = {}
218
- defaults = defaults or application_default
219
- while index <= #items do
220
- local key1 = items[index]
221
- local keys = defaults[key1]
222
- normalized_aplication[key1] = {}
223
- for key2, default_value in pairs(keys) do
224
- local value = application[key1] and application[key1][key2]
225
- normalized_aplication[key1][key2] = value or default_value
226
- end
227
- index = index + 1
228
- end
229
- normalized_aplication.config.id = tostring(application)
230
- normalized_aplication.fonts = application.fonts or {}
231
- normalized_aplication.assets = application.assets or {}
232
- if application.callbacks then
233
- for event, handler in pairs(application.callbacks) do
234
- normalized_aplication.callbacks[event] = handler
235
- end
236
- end
237
- return normalized_aplication
238
- end
239
- local function normalize(application)
240
- if not application then return nil end
241
- if application.Game then
242
- application = application.Game
243
- end
244
- if application.new and type(application.new) == 'function' then
245
- application = application.new()
246
- end
247
- if application and (application.meta or application.callbacks) then
248
- return application
249
- end
250
- local normalized_aplication = {
251
- data = {},
252
- meta = {},
253
- fonts = {},
254
- assets = {},
255
- config = {},
256
- callbacks = {}
257
- }
258
- for key, value in pairs(application) do
259
- if key == 'assets' then
260
- normalized_aplication.assets = value
261
- elseif key == 'fonts' then
262
- normalized_aplication.fonts = value
263
- elseif application_default.meta[key] then
264
- normalized_aplication.meta[key] = value
265
- elseif application_default.config[key] then
266
- normalized_aplication.config[key] = value
267
- elseif type(value) == 'function' then
268
- normalized_aplication.callbacks[key] = value
269
- else
270
- normalized_aplication.data[key] = value
271
- end
272
- end
273
- return normalized_aplication
274
- end
275
- local function loadgame(game_file, defaults)
276
- if type(game_file) == 'table' or type(game_file) == 'userdata' then
277
- return default(normalize(game_file), defaults)
278
- end
279
- local cwd = '.'
280
- local application = type(game_file) == 'function' and game_file
281
- local game_title = not application and game_file and game_file:gsub('%.lua$', '') or 'game'
282
- if not application and game_file and game_file:find('\n') then
283
- local ok, app = pcall(load, game_file)
284
- if not ok then
285
- ok, app = pcall(loadstring, game_file)
286
- end
287
- application = ok and app
214
+ source_shared_engine_loadcore_22ef = function()
215
+ local zeebo_pipeline = source_shared_functional_pipeline_288a()
216
+ local requires = source_shared_string_dsl_requires_2895()
217
+ local function step_install_libsys(self, lib_name, library, custom, is_system)
218
+ if not is_system then return end
219
+ local ok, msg = pcall(function()
220
+ library.install(self.std, self.engine, custom, lib_name)
221
+ end)
222
+ if ok then
223
+ self.libsys[lib_name] = true
288
224
  else
289
- if love and love.filesystem and love.filesystem.getSource then
290
- cwd = love.filesystem.getSource()
291
- end
292
- if not application then
293
- application = loadfile(cwd..'/'..game_title..'.lua')
294
- end
295
- if not application then
296
- local ok, app = pcall(require, game_title)
297
- application = ok and app
298
- end
299
- end
300
- if not application and io and io.open and game_file then
301
- local app_file = io.open(game_file)
302
- if app_file then
303
- local app_src = app_file:read('*a')
304
- local ok, app = pcall(load, app_src)
305
- if not ok then
306
- ok, app = pcall(loadstring, app_src)
307
- end
308
- application = ok and app
309
- app_file:close()
310
- end
225
+ self.error('sys', lib_name, msg)
311
226
  end
312
- while application and type(application) == 'function' do
313
- application = application()
314
227
  end
315
- return default(normalize(application), defaults)
228
+ local function step_check_libsys(self, lib_name, library, custom, is_system)
229
+ if not is_system then return end
230
+ if not self.libsys[lib_name] then
231
+ self.error('sys', lib_name, 'is missing!')
316
232
  end
317
- local function package(self, module_name, module, custom)
318
- local system = module_name:sub(1, 1) == '@'
319
- local name = system and module_name:sub(2) or module_name
320
- if system then
321
- self.list_append(name)
322
- self.stdlib_required[name] = true
323
233
  end
324
- self.pipeline[#self.pipeline + 1] = function ()
325
- if not self.list_exist(name) then return end
326
- if not system and not self.lib_required[name] then return end
327
- if not system and self.engine.lib_installed[name] then return end
328
- if system and self.engine.stdlib_installed[name] then return end
329
- local try_install = function()
330
- module.install(self.std, self.engine, custom, name)
331
- if module.event_bus then
332
- module.event_bus(self.std, self.engine, custom, name)
234
+ local function step_install_libusr(self, lib_name, library, custom, is_system)
235
+ if is_system then return end
236
+ if self.libusr[lib_name] then return end
237
+ if not requires.should_import(self.spec, lib_name) then return end
238
+ self.libusr[lib_name] = pcall(function()
239
+ library.install(self.std, self.engine, custom, lib_name)
240
+ end)
333
241
  end
242
+ local function step_check_libsys_all(self)
243
+ local missing = requires.missing(self.spec, self.libusr)
244
+ if #missing > 0 then
245
+ self.error('usr', '*', 'missing libs: '..table.concat(missing, ' '))
334
246
  end
335
- local ok, msg = pcall(try_install)
336
- if not ok then
337
- self.lib_error[name] = msg
338
- return
339
- end
340
- if system then
341
- self.engine.stdlib_installed[name] = true
342
- else
343
- self.engine.lib_installed[name] = true
344
247
  end
248
+ local function package(self, lib_name, library, custom)
249
+ self.pipeline[#self.pipeline + 1] = function()
250
+ local is_system = lib_name:sub(1, 1) == '@'
251
+ local name = is_system and lib_name:sub(2) or lib_name
252
+ self:step(name, library, custom, is_system)
345
253
  end
346
254
  return self
347
255
  end
348
- local function require(std, application, engine)
256
+ local function setup(std, application, engine)
349
257
  if not application then
350
258
  error('game not found!')
351
259
  end
352
- local application_require = application.config.require
353
- local next_library = application_require:gmatch('%S+')
260
+ local spec = requires.encode((application.config or application).require or '')
354
261
  local self = {
355
- std=std,
356
- engine=engine,
262
+ std = std,
263
+ spec = spec,
264
+ errmsg = '',
265
+ engine = engine,
357
266
  package = package,
358
- event = {},
359
- list = {},
360
- lib_error = {},
361
- lib_optional = {},
362
- lib_required = {},
363
- stdlib_required = {},
267
+ libusr = {},
268
+ libsys = {},
364
269
  pipeline = {},
365
270
  pipe = zeebo_pipeline.pipe
366
271
  }
367
- if not engine.lib_installed then
368
- engine.lib_installed = {}
369
- engine.stdlib_installed = {}
272
+ self.error = function (prefix, lib_name, message)
273
+ self.errmsg = self.errmsg..'['..prefix..':'..lib_name..'] '..message..'\n'
370
274
  end
371
- self.list_exist = function (name)
372
- return self.lib_optional[name] or self.lib_required[name] or self.stdlib_required[name]
275
+ self.run = function()
276
+ self.step = step_install_libsys
277
+ zeebo_pipeline.reset(self)
278
+ zeebo_pipeline.run(self)
279
+ self.step = step_check_libsys
280
+ zeebo_pipeline.reset(self)
281
+ zeebo_pipeline.run(self)
282
+ self.step = step_install_libusr
283
+ zeebo_pipeline.reset(self)
284
+ zeebo_pipeline.run(self)
285
+ step_check_libsys_all(self)
286
+ if #self.errmsg > 0 then
287
+ error(self.errmsg, 0)
373
288
  end
374
- self.list_append = function (name)
375
- if not self.list_exist(name) then
376
- self.list[#self.list + 1] = name
377
289
  end
290
+ return self
378
291
  end
379
- self.run = function()
380
- local index = 1
381
- zeebo_pipeline.run(self)
382
- while index <= #self.list do
383
- local name = self.list[index]
384
- if self.stdlib_required[name] and not self.engine.stdlib_installed[name] then
385
- error('system library not loaded: '..name..'\n'..(self.lib_error[name] or ''))
292
+ local P = {
293
+ setup = setup
294
+ }
295
+ return P
296
+ end
297
+ --
298
+ source_shared_engine_loadgame_22fa = function()
299
+ local eval_file = source_shared_string_eval_file_2afc()
300
+ local eval_code = source_shared_string_eval_code_2b07()
301
+ local has_io_open = io and io.open
302
+ local function normalize(app, base)
303
+ if not app then return nil end
304
+ if not app.callbacks then
305
+ local old_app = app
306
+ app = {meta={},config={},callbacks={}, data={}}
307
+ for key, value in pairs(old_app) do
308
+ local is_function = type(value) == 'function'
309
+ if base.meta and base.meta[key] and not is_function then
310
+ app.meta[key] = value
311
+ elseif base.config and base.config[key] and not is_function then
312
+ app.config[key] = value
313
+ elseif is_function then
314
+ app.callbacks[key] = value
315
+ else
316
+ app.data[key] = value
386
317
  end
387
- if self.lib_required[name] and not self.engine.lib_installed[name] then
388
- error('library not loaded: '..name..'\n'..(self.lib_error[name] or ''))
389
318
  end
390
- index = index + 1
391
319
  end
320
+ local function defaults(a, b, key)
321
+ if type(a[key]) ~= "table" then a[key] = {} end
322
+ for k, v in pairs(b[key]) do
323
+ if a[key][k] == nil then
324
+ a[key][k] = b[key][k]
392
325
  end
393
- repeat
394
- local lib = next_library()
395
- if lib then
396
- local name, optional = lib:match('([%w%.]+)([?]?)')
397
- self.list_append(name)
398
- if optional and #optional > 0 then
399
- self.lib_optional[name] = true
326
+ end
327
+ end
328
+ for field in pairs(base) do
329
+ defaults(app, base, field)
330
+ end
331
+ return app
332
+ end
333
+ local function script(src, base)
334
+ if type(src) == 'table' or type(src) == 'userdata' then
335
+ return normalize(src, base)
336
+ end
337
+ local application = type(src) == 'function' and src
338
+ if not src or #src == 0 then
339
+ src = 'game'
340
+ end
341
+ if not application and src and src:find('\n') then
342
+ local ok, app = eval_code.script(src)
343
+ application = ok and app
400
344
  else
401
- self.lib_required[name] = true
345
+ local ok, app = eval_file.script(src)
346
+ application = ok and app
402
347
  end
348
+ if not application and has_io_open then
349
+ local app_file = io.open(src)
350
+ if app_file then
351
+ local app_src = app_file:read('*a')
352
+ local ok, app = eval_code.script(app_src)
353
+ application = ok and app
354
+ app_file:close()
403
355
  end
404
- until not lib
405
- return self
356
+ end
357
+ return normalize(application, base)
406
358
  end
407
359
  local P = {
408
- loadgame = loadgame,
409
- require = require
360
+ script = script
410
361
  }
411
362
  return P
412
363
  end
413
364
  --
414
- source_engine_api_data_encoder_55e9adcde7b0 = function()
365
+ source_engine_api_data_encoder_230c = function()
415
366
  local function install(std, engine, library, name)
416
367
  std = std or {}
417
368
  std[name] = {
@@ -426,8 +377,8 @@ install=install
426
377
  return P
427
378
  end
428
379
  --
429
- source_engine_api_system_app_55e9add022a0 = function()
430
- local util_decorator = source_shared_functional_decorator_55e9adca5750()
380
+ source_engine_api_system_app_2317 = function()
381
+ local util_decorator = source_shared_functional_decorator_2d77()
431
382
  local function reset(std, engine)
432
383
  if std.node then
433
384
  std.bus.emit('exit')
@@ -467,7 +418,7 @@ install=install
467
418
  return P
468
419
  end
469
420
  --
470
- source_engine_api_data_hash_55e9adcec2d0 = function()
421
+ source_engine_api_data_hash_2322 = function()
471
422
  local function djb2(digest)
472
423
  local index = 1
473
424
  local hash = 5381
@@ -491,8 +442,8 @@ install = install
491
442
  return P
492
443
  end
493
444
  --
494
- source_engine_api_io_http_55e9add09cc0 = function()
495
- local zeebo_pipeline = source_shared_functional_pipeline_55e9adca5c50()
445
+ source_engine_api_io_http_232d = function()
446
+ local zeebo_pipeline = source_shared_functional_pipeline_288a()
496
447
  local function json(self)
497
448
  self.options['json'] = true
498
449
  return self
@@ -655,7 +606,7 @@ install=install
655
606
  return P
656
607
  end
657
608
  --
658
- source_engine_api_data_i18n_55e9adcfb4b0 = function()
609
+ source_engine_api_data_i18n_2338 = function()
659
610
  local language = 'en-US'
660
611
  local language_default = 'en-US'
661
612
  local language_list = {}
@@ -747,7 +698,7 @@ install=install
747
698
  return P
748
699
  end
749
700
  --
750
- source_engine_api_system_key_55e9adcdd690 = function()
701
+ source_engine_api_system_key_2343 = function()
751
702
  local function real_key(std, engine, rkey, rvalue)
752
703
  local value = rvalue == 1 or rvalue == true
753
704
  local key = engine.key_bindings[rkey] or (std.key.axis[rkey] and rkey)
@@ -771,24 +722,21 @@ end
771
722
  local function real_keyup(std, engine, key)
772
723
  real_key(std, engine, key, 0)
773
724
  end
774
- local function event_bus(std, engine)
775
- std.bus.listen_std_engine('rkey', real_key)
776
- std.bus.listen_std_engine('rkey1', real_keydown)
777
- std.bus.listen_std_engine('rkey0', real_keyup)
778
- end
779
725
  local function install(std, engine, key_bindings)
780
726
  engine.key_bindings = key_bindings or {}
781
727
  engine.keyboard = real_key
728
+ std.bus.listen_std_engine('rkey', real_key)
729
+ std.bus.listen_std_engine('rkey1', real_keydown)
730
+ std.bus.listen_std_engine('rkey0', real_keyup)
782
731
  end
783
732
  local P = {
784
- event_bus = event_bus,
785
733
  install = install
786
734
  }
787
735
  return P
788
736
  end
789
737
  --
790
- source_engine_api_debug_log_55e9adc93400 = function()
791
- local util_decorator = source_shared_functional_decorator_55e9adca5750()
738
+ source_engine_api_debug_log_234e = function()
739
+ local util_decorator = source_shared_functional_decorator_2d77()
792
740
  local logging_types = {
793
741
  'none', 'fatal', 'error', 'warn', 'debug', 'info'
794
742
  }
@@ -834,7 +782,7 @@ install = install
834
782
  return P
835
783
  end
836
784
  --
837
- source_engine_api_system_math_55e9add12fd0 = function()
785
+ source_engine_api_system_math_2359 = function()
838
786
  local function abs(value)
839
787
  if value < 0 then
840
788
  return -value
@@ -1009,8 +957,8 @@ install = install_clib_random
1009
957
  return P;
1010
958
  end
1011
959
  --
1012
- source_engine_api_data_array_55e9add03280 = function()
1013
- local util_decorator = source_shared_functional_decorator_55e9adca5750()
960
+ source_engine_api_data_array_2364 = function()
961
+ local util_decorator = source_shared_functional_decorator_2d77()
1014
962
  local function array_map(array, func)
1015
963
  local res = {}
1016
964
  local index = 1
@@ -1171,7 +1119,7 @@ install = install
1171
1119
  return P
1172
1120
  end
1173
1121
  --
1174
- source_engine_api_io_media_55e9add024e0 = function()
1122
+ source_engine_api_io_media_236f = function()
1175
1123
  local function media_create(node, channels, handler)
1176
1124
  local decorator = function(func)
1177
1125
  func = func or function() end
@@ -1218,7 +1166,7 @@ install=install
1218
1166
  return P
1219
1167
  end
1220
1168
  --
1221
- source_engine_api_draw_fps_55e9add01370 = function()
1169
+ source_engine_api_draw_fps_237a = function()
1222
1170
  local function draw_fps(std, engine, show, pos_x, pos_y)
1223
1171
  if show < 1 then return end
1224
1172
  local x = engine.current.config.offset_x + pos_x
@@ -1251,27 +1199,24 @@ std.text.print(x + s, y, engine.root.config.fps_max)
1251
1199
  s = s + 46
1252
1200
  end
1253
1201
  end
1254
- local function event_bus(std, engine)
1255
- std.bus.listen('post_draw', function()
1256
- engine.current = engine.root
1257
- draw_fps(std, engine, engine.root.config.fps_show, 8, 8)
1258
- end)
1259
- end
1260
1202
  local function install(std, engine)
1261
1203
  std.app = std.app or {}
1262
1204
  std.app.fps_show = function(show)
1263
1205
  engine.root.config.fps_show = show
1264
1206
  end
1207
+ std.bus.listen('post_draw', function()
1208
+ engine.current = engine.root
1209
+ draw_fps(std, engine, engine.root.config.fps_show, 8, 8)
1210
+ end)
1265
1211
  end
1266
1212
  local P = {
1267
- event_bus=event_bus,
1268
1213
  install=install
1269
1214
  }
1270
1215
  return P
1271
1216
  end
1272
1217
  --
1273
- source_engine_api_draw_text_55e9adcfd720 = function()
1274
- local util_decorator = source_shared_functional_decorator_55e9adca5750()
1218
+ source_engine_api_draw_text_2385 = function()
1219
+ local util_decorator = source_shared_functional_decorator_2d77()
1275
1220
  local function text_put(std, engine, font_previous, pos_x, pos_y, text, size)
1276
1221
  size = size or 2
1277
1222
  local hem = engine.current.data.width / 80
@@ -1298,7 +1243,7 @@ install=install
1298
1243
  return P
1299
1244
  end
1300
1245
  --
1301
- source_engine_api_draw_poly_55e9add12880 = function()
1246
+ source_engine_api_draw_poly_2390 = function()
1302
1247
  local function decorator_poo(object, func)
1303
1248
  if not object or not func then return func end
1304
1249
  return function(a, b, c, d)
@@ -1405,7 +1350,7 @@ install=install
1405
1350
  return P
1406
1351
  end
1407
1352
  --
1408
- source_engine_api_raw_memory_55e9add0b7e0 = function()
1353
+ source_engine_api_raw_memory_239b = function()
1409
1354
  local memory_dict_unload = {}
1410
1355
  local memory_dict = {}
1411
1356
  local memory_list = {}
@@ -1460,9 +1405,9 @@ install=install
1460
1405
  return P
1461
1406
  end
1462
1407
  --
1463
- source_engine_protocol_http_callback_55e9adcfea60 = function()
1464
- local str_http = source_shared_string_encode_http_55e9add02410()
1465
- local str_url = source_shared_string_encode_url_55e9adca91f0()
1408
+ source_engine_protocol_http_callback_23ad = function()
1409
+ local str_http = source_shared_string_encode_http_5c3f()
1410
+ local str_url = source_shared_string_encode_url_5c4a()
1466
1411
  local callbacks = {
1467
1412
  ['async-promise'] = function(self)
1468
1413
  return self:promise()
@@ -1529,7 +1474,7 @@ func = native_http_callback
1529
1474
  return P
1530
1475
  end
1531
1476
  --
1532
- source_shared_var_object_root_55e9add070f0 = function()
1477
+ source_shared_var_object_root_23bf = function()
1533
1478
  local P = {
1534
1479
  data={
1535
1480
  width=1280,
@@ -1559,7 +1504,7 @@ callbacks={
1559
1504
  return P;
1560
1505
  end
1561
1506
  --
1562
- source_engine_api_system_color_55e9adc94310 = function()
1507
+ source_engine_api_system_color_23ca = function()
1563
1508
  local function install(std)
1564
1509
  std.color = std.color or {}
1565
1510
  std.color.white = 0xFFFFFFFF
@@ -1594,12 +1539,14 @@ install = install
1594
1539
  return P
1595
1540
  end
1596
1541
  --
1597
- source_shared_var_object_std_55e9adc94a00 = function()
1542
+ source_shared_var_object_std_23d5 = function()
1598
1543
  local P = {
1599
1544
  milis = 0,
1600
1545
  delta = 0,
1601
1546
  math = {
1602
1547
  },
1548
+ media = {
1549
+ },
1603
1550
  draw = {
1604
1551
  image = function() end,
1605
1552
  clear = function () end,
@@ -1660,7 +1607,7 @@ any=false
1660
1607
  return P;
1661
1608
  end
1662
1609
  --
1663
- source_shared_functional_pipeline_55e9adca5c50 = function()
1610
+ source_shared_functional_pipeline_288a = function()
1664
1611
  local function pipe(self)
1665
1612
  return function()
1666
1613
  self:run()
@@ -1710,7 +1657,103 @@ run=run
1710
1657
  return P
1711
1658
  end
1712
1659
  --
1713
- source_shared_functional_decorator_55e9adca5750 = function()
1660
+ source_shared_string_dsl_requires_2895 = function()
1661
+ local function encode(dsl_string)
1662
+ local spec = {
1663
+ list = {},
1664
+ required = {},
1665
+ all = false
1666
+ }
1667
+ for entry in (dsl_string or ''):gmatch("[^%s]+") do
1668
+ if entry == "*" then
1669
+ spec.all = true
1670
+ else
1671
+ local is_optional = entry:sub(-1) == "?"
1672
+ local name = is_optional and entry:sub(1, -2) or entry
1673
+ spec.list[#spec.list + 1] = name
1674
+ spec.required[#spec.required + 1] = not is_optional
1675
+ end
1676
+ end
1677
+ return spec
1678
+ end
1679
+ local function missing(spec, imported)
1680
+ local result = {}
1681
+ do
1682
+ local index = 1
1683
+ while spec.list[index] do
1684
+ local name = spec.list[index]
1685
+ if spec.required[index] and not imported[name] then
1686
+ result[#result + 1] = name
1687
+ end
1688
+ index = index + 1
1689
+ end
1690
+ end
1691
+ return result
1692
+ end
1693
+ local function should_import(spec, libname)
1694
+ local index = 1
1695
+ while spec.list[index] do
1696
+ if spec.list[index] == libname then return true end
1697
+ index = index + 1
1698
+ end
1699
+ return spec.all
1700
+ end
1701
+ local P = {
1702
+ encode = encode,
1703
+ missing = missing,
1704
+ should_import = should_import
1705
+ }
1706
+ return P
1707
+ end
1708
+ --
1709
+ source_shared_string_eval_file_2afc = function()
1710
+ local function script(src)
1711
+ local ok, app = false, nil
1712
+ if require then
1713
+ ok, app = pcall(require, src:gsub('%.lua$', ''))
1714
+ end
1715
+ if not ok and dofile then
1716
+ ok, app = pcall(dofile, src)
1717
+ end
1718
+ if not ok and loadfile then
1719
+ ok, app = pcall(loadfile, src)
1720
+ end
1721
+ if type(app) == 'function' then
1722
+ ok, app = pcall(app)
1723
+ end
1724
+ if not ok then
1725
+ return false, 'failed to eval file'
1726
+ end
1727
+ return ok, app
1728
+ end
1729
+ local P = {
1730
+ script = script,
1731
+ }
1732
+ return P
1733
+ end
1734
+ --
1735
+ source_shared_string_eval_code_2b07 = function()
1736
+ local function script(src)
1737
+ local loader = loadstring or load
1738
+ if not loader then
1739
+ error('eval not allowed')
1740
+ end
1741
+ local ok, chunk = pcall(loader, src)
1742
+ if not ok then
1743
+ return false, chunk
1744
+ end
1745
+ if type(chunk) ~= 'function' then
1746
+ return false, 'failed to eval code'
1747
+ end
1748
+ return pcall(chunk)
1749
+ end
1750
+ local P = {
1751
+ script = script,
1752
+ }
1753
+ return P
1754
+ end
1755
+ --
1756
+ source_shared_functional_decorator_2d77 = function()
1714
1757
  local function decorator_prefix3(zig, zag, zom, func)
1715
1758
  return function (a, b, c, d, e, f)
1716
1759
  return func(zig, zag, zom, a, b, c, d, e, f)
@@ -1768,7 +1811,7 @@ prefix1_t = table_prefix1
1768
1811
  return P
1769
1812
  end
1770
1813
  --
1771
- source_shared_string_encode_http_55e9add02410 = function()
1814
+ source_shared_string_encode_http_5c3f = function()
1772
1815
  local function is_ok(status)
1773
1816
  return (status and 200 <= status and status < 300) or false
1774
1817
  end
@@ -1915,7 +1958,7 @@ create_request=create_request
1915
1958
  }
1916
1959
  end
1917
1960
  --
1918
- source_shared_string_encode_url_55e9adca91f0 = function()
1961
+ source_shared_string_encode_url_5c4a = function()
1919
1962
  local function search_param(param_list, param_dict)
1920
1963
  local index, params = 1, ''
1921
1964
  while param_list and param_dict and index <= #param_list do
@@ -1937,4 +1980,4 @@ search_param = search_param
1937
1980
  return P
1938
1981
  end
1939
1982
  --
1940
- return main_55e9adc932d0()
1983
+ return main_22db()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamely/gly-engine-lite",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "author": "RodrigoDornelles",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://docs.gamely.com.br",
@@ -15,5 +15,12 @@
15
15
  "game engine",
16
16
  "game",
17
17
  "engine"
18
- ]
18
+ ],
19
+ "scripts": {
20
+ "step1": "cd ../.. && rm -Rf dist && mkdir -p ./dist/types",
21
+ "step2": "cd ../.. && node cli.js build --core lite --bundler --outdir dist/dist",
22
+ "step3": "cd ../.. && node cli.js meta source/cli/main.lua --infile npm/gly-engine-lite/package.json --outfile dist/package.json",
23
+ "step4": "cd ../.. && echo \"declare module '@gamely/gly-engine-lite' {\n const content: string;\n export default content;\n}\" > dist/types/main.d.ts",
24
+ "build": "npm run step1 && npm run step2 && npm run step3 && npm run step4"
25
+ }
19
26
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- <div align="center">
2
- <h1>:mechanical_arm:<br>GLY Engine<br><sup><sub>powered by <a href="https://gamely.com.br" target="_blank">gamely.com.br</a></sub></sup></h1>
3
- </div>