@gamely/gly-engine-lite 0.0.15 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.lua +182 -4
  2. package/package.json +1 -1
package/dist/main.lua CHANGED
@@ -8,6 +8,7 @@ local core_src_lib_engine_api_http = nil
8
8
  local core_src_lib_engine_api_i18n = nil
9
9
  local core_src_lib_engine_api_key = nil
10
10
  local core_src_lib_engine_api_math = nil
11
+ local core_src_lib_engine_api_array = nil
11
12
  local core_src_lib_engine_draw_fps = nil
12
13
  local core_src_lib_engine_draw_text = nil
13
14
  local core_src_lib_engine_draw_poly = nil
@@ -27,6 +28,7 @@ local engine_http = core_src_lib_engine_api_http()
27
28
  local engine_i18n = core_src_lib_engine_api_i18n()
28
29
  local engine_key = core_src_lib_engine_api_key()
29
30
  local engine_math = core_src_lib_engine_api_math()
31
+ local engine_array = core_src_lib_engine_api_array()
30
32
  local engine_draw_fps = core_src_lib_engine_draw_fps()
31
33
  local engine_draw_text = core_src_lib_engine_draw_text()
32
34
  local engine_draw_poly = core_src_lib_engine_draw_poly()
@@ -93,9 +95,10 @@ zeebo_module.require(std, application, engine)
93
95
  :package('@memory', engine_raw_memory)
94
96
  :package('@game', engine_game, native_dict_game)
95
97
  :package('@math', engine_math)
98
+ :package('@array', engine_array)
96
99
  :package('@key', engine_key, {})
97
100
  :package('@draw.fps', engine_draw_fps)
98
- :package('@draw.fps', engine_draw_text, cfg_text)
101
+ :package('@draw.text', engine_draw_text, cfg_text)
99
102
  :package('@draw.poly', engine_draw_poly, native_dict_poly)
100
103
  :package('@color', color)
101
104
  :package('math', engine_math.clib)
@@ -124,7 +127,7 @@ version=version
124
127
  return P
125
128
  end
126
129
  core_src_version = function()
127
- return '0.0.15'
130
+ return '0.0.17'
128
131
  end
129
132
  --
130
133
  core_src_lib_common_module = function()
@@ -243,9 +246,9 @@ if not system and not self.lib_required[name] then return end
243
246
  if not system and self.engine.lib_installed[name] then return end
244
247
  if system and self.engine.stdlib_installed[name] then return end
245
248
  local try_install = function()
246
- module.install(self.std, self.engine, custom, module_name)
249
+ module.install(self.std, self.engine, custom, name)
247
250
  if module.event_bus then
248
- module.event_bus(self.std, self.engine, custom, module_name)
251
+ module.event_bus(self.std, self.engine, custom, name)
249
252
  end
250
253
  end
251
254
  local ok, msg = pcall(try_install)
@@ -841,6 +844,180 @@ install = install_clib_random
841
844
  return P;
842
845
  end
843
846
  --
847
+ core_src_lib_engine_api_array = function()
848
+ local util_decorator = core_src_lib_util_decorator()
849
+ local function array_map(array, func)
850
+ local res = {}
851
+ local index = 1
852
+ local length = #array
853
+ while index <= length do
854
+ res[#res + 1] = func(array[index], index)
855
+ index = index + 1
856
+ end
857
+ return res
858
+ end
859
+ local function array_filter(array, func)
860
+ func = func or (function(v) return v and v ~= 0 end)
861
+ local res = {}
862
+ local index = 1
863
+ local length = #array
864
+ while index <= length do
865
+ local value = array[index]
866
+ if func(value, index) then
867
+ res[#res + 1] = value
868
+ end
869
+ index = index + 1
870
+ end
871
+ return res
872
+ end
873
+ local function array_unique(array)
874
+ local res = {}
875
+ local index = 1
876
+ local length = #array
877
+ local setmap = {}
878
+ while index <= length do
879
+ local value = array[index]
880
+ if not setmap[value] then
881
+ res[#res + 1] = value
882
+ end
883
+ setmap[value] = true
884
+ index = index + 1
885
+ end
886
+ return res
887
+ end
888
+ local function array_foreach(array, func)
889
+ local index = 1
890
+ local length = #array
891
+ while index <= length do
892
+ func(array[index], index)
893
+ index = index + 1
894
+ end
895
+ end
896
+ local function array_reducer(array, func, value)
897
+ local index = value and 1 or 2
898
+ local length = #array
899
+ value = value or array[1]
900
+ while index <= length do
901
+ value = func(value, array[index], index)
902
+ index = index + 1
903
+ end
904
+ return value
905
+ end
906
+ local function array_index(array, func, reverse)
907
+ func = func or function() return true end
908
+ local index, inc, final = 1, 1, #array
909
+ if reverse then
910
+ index, inc, final = #array, -1, 1
911
+ end
912
+ repeat
913
+ if func(array[index], index) then
914
+ return index
915
+ end
916
+ index = index + inc
917
+ until (reverse and index < final) or (not reverse and index > final)
918
+ return nil
919
+ end
920
+ local function array_first(array, func)
921
+ local index = array_index(array, func)
922
+ if index then
923
+ return array[index]
924
+ end
925
+ return nil
926
+ end
927
+ local function array_last(array, func)
928
+ local index = array_index(array, func, true)
929
+ if index then
930
+ return array[index]
931
+ end
932
+ return nil
933
+ end
934
+ local function array_some(array, func, reverse)
935
+ local index, inc, final = 1, 1, #array
936
+ if reverse then
937
+ index, inc, final = #array, -1, 1
938
+ end
939
+ repeat
940
+ if func(array[index], index) then
941
+ return true
942
+ end
943
+ index = index + inc
944
+ until (reverse and index < final) or (not reverse and index > final)
945
+ return false
946
+ end
947
+ local function array_every(array, func)
948
+ local index = 1
949
+ local length = #array
950
+ while index <= length do
951
+ if not func(array[index], index) then
952
+ return false
953
+ end
954
+ index = index + 1
955
+ end
956
+ return true
957
+ 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
+ local function array_pipeline(std, array)
970
+ local decorator_iterator = function(func)
971
+ return function(self, func2, extra)
972
+ self.array = func(self.array, func2, extra)
973
+ return self
974
+ end
975
+ end
976
+ local decorator_reduce = function(func, return_self)
977
+ return function(self, func2, extra)
978
+ local res = func(self.array, func2, extra)
979
+ return (return_self and self) or res
980
+ end
981
+ end
982
+ local self = {
983
+ array = array,
984
+ map = decorator_iterator(array_map),
985
+ filter = decorator_iterator(array_filter),
986
+ unique = decorator_iterator(array_unique),
987
+ each = decorator_reduce(array_foreach, true),
988
+ reducer = decorator_reduce(array_reducer),
989
+ index = decorator_reduce(array_index),
990
+ first = decorator_reduce(array_first),
991
+ last = decorator_reduce(array_last),
992
+ some = decorator_reduce(array_some),
993
+ every = decorator_reduce(array_every),
994
+ compare = decorator_reduce(array_compare),
995
+ table = function(self) return self.array end,
996
+ json = function(self) return std.json.encode(self.array) end
997
+ }
998
+ return self
999
+ end
1000
+ local function install(std, engine, library, name)
1001
+ local lib = std[name] or {}
1002
+ lib.filter = array_filter
1003
+ lib.unique = array_unique
1004
+ lib.each = array_foreach
1005
+ lib.reducer = array_reducer
1006
+ lib.index = array_index
1007
+ lib.first = array_first
1008
+ lib.last = array_last
1009
+ lib.some = array_some
1010
+ lib.every = array_every
1011
+ lib.compare = array_compare
1012
+ lib.from = util_decorator.prefix1(std, array_pipeline)
1013
+ std[name] = lib
1014
+ end
1015
+ local P = {
1016
+ install = install
1017
+ }
1018
+ return P
1019
+ end
1020
+ --
844
1021
  core_src_lib_engine_draw_fps = function()
845
1022
  local function draw_fps(std, engine, show, pos_x, pos_y)
846
1023
  if show < 1 then return end
@@ -1089,6 +1266,7 @@ title='',
1089
1266
  author='',
1090
1267
  company='',
1091
1268
  description='',
1269
+ tizen_package='',
1092
1270
  version=''
1093
1271
  },
1094
1272
  config = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamely/gly-engine-lite",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "author": "RodrigoDornelles",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://docs.gamely.com.br",