Commit Graph

53 Commits

Author SHA1 Message Date
Linden
6b12831817 feat(cache): send oldValue to onCache
Internally handle the cache events to prevent race conditions
and resolve #618.
Improved types.
2024-08-13 14:11:27 +10:00
Linden
45b9560a44 fix(init/cache): allow setting false cached value
Resolves #605.
2024-07-01 12:17:50 +10:00
Linden
3e66dccb4b fix(init): prevent loading multiple instances of ox_lib
Resolves #545.
2024-04-11 15:03:41 +10:00
Linden
aebe248e39 refactor: localise globals to prevent shadowing
See #456.
2023-12-07 08:36:40 +11:00
Andy
62ff7345b9 feat(imports): server-side entity iterators (#458)
Co-authored-by: Linden <65407488+thelindat@users.noreply.github.com>
2023-12-07 08:25:31 +11:00
Linden
3e527ac517 refactor(init): disallow loading ox_lib's import IN ox_lib
Seriously, why?
2023-08-20 10:37:45 +10:00
Linden
d1b8d0ec6c fix(init): set correct chunk name
Used in debugging and errors.
2023-08-13 09:22:37 +10:00
Linden
9df29d9d3a fix(init): check if ox_lib is started 2023-08-13 08:57:02 +10:00
Linden
b014e43e14 feat(init): importing modules with resource metadata
Allow loading modules through fxmanifest (i.e. ox_lib 'locale' or ox_libs { 'locale' }).
Useful in some cases where the module needs to be loaded (lib.locale()) first.
2023-08-02 16:16:37 +10:00
Linden
b68da917be feat(init): cache.__call metamethod for caching function results
See #385.
Included formatting changes (tabs->spaces).
2023-08-02 15:17:14 +10:00
Linden
9d98b9aada chore: types
mostly types anyway.
2023-07-31 16:29:27 +10:00
Linden
89b9016586 fix(init): enable ignore_invalid for msgpack
Needed to prevent errors when packing glm polygons and such.
2023-07-26 12:47:07 +10:00
Linden
639faa214d refactor(init): minor tweaks
Remove dead table (lib.exports) and annotate server-side lib.notify.
2023-02-22 10:08:43 +11:00
Linden
7ab2aac9be feat(imports/require): custom require for script files 2023-02-22 09:53:58 +11:00
Luke
b56e6826a8 Merge branch 'v3' 2023-02-17 15:54:20 +01:00
Linden
1565187860 refactor(init): change notify netevent name
Other name was too generic and may conflict with user-code.
2023-02-03 13:04:48 +11:00
Linden
74628a5167 refactor: remove deprecated code
getCore and player modules were deprecated long ago and only used once.
2023-01-25 15:39:35 +11:00
Scully
231d1c3c77 feat: improved RedM support (#162)
* Improvements + remove redm keybind system as it's pointless
2022-11-26 13:05:55 +11:00
Linden
e840bbb50f refactor(init): report ox_lib error when loading imports
People like to cry about resources not working because they
failed to install ox_lib and don't know how to read, missing the
fat error and stack trace on resource start.

Now we can remind these people they need to actually install
a release.
2022-10-28 18:46:56 +11:00
Linden
79dd3f5934 fix: no-op 2022-10-10 16:56:05 +11:00
Linden
21214728b7 refactor(init): module stub
If module doesn't return a result, create a stub function.
2022-09-18 22:42:05 +10:00
Linden
32e2da2d8f refactor(init): type-fixes and minor adjustments 2022-09-14 01:42:14 +10:00
Linden
7838a3cfe4 refactor(init): cache handling
lib.onCache serves as a helper to setup cache event listeners.
Removed _cache table and index method.
Only apply metatable to client-side cache (nothing exists on server yet).
When cache is indexed, setup an event handler for the key.
Remove some ox_core/ox_groups specific code (unused).
Remove the updateCache event, and interval.
2022-07-28 23:13:19 +10:00
Linden
770ae6396e relicense to LGPLv3
Allows resources importing ox_lib to ignore the "same license" condition.
Does not apply to snippets copied from ox_lib into other resources.
2022-07-05 05:17:52 +10:00
Linden
130ea5d17e refactor(init): lib.notify server function
Client handler attempts to translate the notification if locales are loaded.
2022-06-19 13:36:11 +10:00
Linden
3bb946001b refactor(init): separate global and local cache
Store temporary data in the _cache local, separate from the global cache.

This allows constants and other values to be added, rather than being
wiped every minute.
2022-05-25 13:28:19 +10:00
Linden
139ae0701b refactor(getCore/client): clean up hasGroup method and return values 2022-05-12 07:44:29 +10:00
Linden
ef4ca56889 refactor(init): return a stub for imports with no return
Modules that define globals or directly add several functions to the
lib namespace currently need to return empty functions (i.e. locales).
2022-05-12 00:02:25 +10:00
Linden
8bcae1937b tweak(init): store service and name in lib
lib.name for 'ox_lib', and service or 'client' or 'server'.
2022-05-01 22:47:34 +10:00
Linden
f6216af1ae refactor: rename lualib variable and move clipboard export 2022-04-29 03:02:06 +10:00
Linden
1ac844f20a tweak(init): store serverId 2022-04-11 04:59:01 +00:00
Linden
62e4fea5ad refactor(init): set cache[key] after triggering onCache
Allow for comparison of new and old values by checking cache[key]
against the value sent as an argument.
2022-03-15 10:34:22 +00:00
Linden
13c8c29811 refactor: change event names from lualib to ox_lib 2022-03-13 03:21:01 +00:00
Linden
3c7cd3dc6b refactor(init): throw an error if ox_lib is not started 2022-03-10 15:54:13 +11:00
Linden
6b8b7990c8 fix(init): incorrect server check 2022-03-01 14:20:14 +00:00
Linden
5a30dd7ad1 fix(init): initial cache index returns full table 2022-03-01 13:58:08 +00:00
Linden
a37a897b10 feat(init): callback hook when updating cache 2022-03-01 13:42:39 +00:00
Linden
58faab6217 feat(init): implement cache 2022-03-01 13:23:47 +00:00
Linden
aeccbece09 refactor: rename imports
BREAKING!
Since the folder name determines the import name (i.e. lib.callbacks), use better names and lowerCamelCase.
2022-02-28 16:30:58 +11:00
Linden
e83aa653cc refactor(init): call imports and exports via lib
Deprecate import (now just references lib); when calling or indexing
lib for the first time, attempt to load a module else call an export.
2022-02-28 02:40:25 +00:00
Linden
d3ef7d5018 refactor: rename resource 2022-02-28 00:48:36 +00:00
Linden
40b7fe2a77 refactor(init): don't cache function refs 2022-02-28 08:35:32 +11:00
Linden
d0c5f722db refactor(init): export cache and update intervals
BREAKING CHANGE: lib will store cached export functions and no longer uses the : syntax to call functions.

Allow SetInterval to return arguments to the callback function.
2021-12-27 12:19:37 +11:00
Linden
ec1a98b83a feat(keys): implement a DisableControlAction wrapper 2021-12-06 09:54:45 +11:00
Linden
d25cac3be4 Revert "feat(init): add custom packing for metatables"
This reverts commit 1ad137b8c5.

Prefer native solutions, this is too niche.
2021-12-05 04:58:48 +11:00
Linden
4d51879afd refactor(init): metatables and micro-optimise
import now stores all imported modules and uses call and index methods to load modules.

Defining an import as before (local ServerCallbacks = import 'callbacks') works as before, or you can use ServerCallbacks = import.callbacks

You could also use a lazy loading method by never defining ServerCallbacks, i.e. import.callbacks.Register(...) will work without explicitly importing the module previously.
2021-11-28 18:04:09 +11:00
Linden
1ad137b8c5 feat(init): add custom packing for metatables
Adds lib.unpack and lib.pack functions to the global lib table.
2021-11-25 01:00:12 +11:00
Linden
9adbccd2f8 feat(init): implement interval
This is different from the one implemented in Ox ESX.
2021-11-25 00:56:07 +11:00
Linden
78fdee1132 chore: update readme and license 2021-11-16 11:15:59 +11:00
Linden
52a3623e0e feat: add lib table for exports
Anything assigned to the table will be exported; it's just a hacky way to provide support for Lua Language Server.
2021-11-16 11:15:34 +11:00