Commit Graph

33 Commits

Author SHA1 Message Date
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
Linden
9a60f3bd1d chore(callbacks): update annotations 2021-11-11 07:56:15 +11:00
Linden
ab4807fee0 refactor: remove modules system and fix indentation
Setting a "standard" module and resource structure is too limiting, so stick to import only.
2021-11-11 07:52:38 +11:00
Linden
bc5c7ad209 Add files via upload 2021-10-30 15:58:25 +11:00