File tree Expand file tree Collapse file tree 4 files changed +27
-21
lines changed
Expand file tree Collapse file tree 4 files changed +27
-21
lines changed Original file line number Diff line number Diff line change 1- /build /
2- /.vscode /
1+ # ide files
32/.vscrof /
3+ /.vscode /
4+ /.idea /
5+
6+ /build /
47/node_modules /
58/* .tar.gz
69/package-lock.json
Original file line number Diff line number Diff line change @@ -64,14 +64,11 @@ declare module 'libsession_util_nodejs' {
6464 }
6565
6666 export type BaseWrapperActionsCalls = MakeWrapperActionCalls < BaseConfigWrapper > ;
67- }
68-
69- /**
70- * Constants wrapper logic
71- */
7267
73- export type ConstantsWrapper = {
74- "CONSTANTS" : {
75- MAX_NAME_LENGTH : number
68+ export type ConstantsType = {
69+ /** Maximum byte length for user, contact and group names */
70+ MAX_NAME_LENGTH : number ;
7671 }
72+
73+ export const CONSTANTS : ConstantsType ;
7774}
Original file line number Diff line number Diff line change 11#include " constants.hpp"
22
3- namespace session ::nodeapi {
4- Napi::Number ConstantsWrapper::MAX_NAME_LENGTH;
3+ #include " session/config/contacts.hpp"
54
5+ namespace session ::nodeapi {
66ConstantsWrapper::ConstantsWrapper (const Napi::CallbackInfo& info) :
77 Napi::ObjectWrap<ConstantsWrapper>(info) {}
88
99Napi::Object ConstantsWrapper::Init (Napi::Env env, Napi::Object exports) {
10- MAX_NAME_LENGTH = Napi::Number::New (env, session::config::contact_info::MAX_NAME_LENGTH);
10+ // fetch cpp constants
11+ Napi::Number MAX_NAME_LENGTH =
12+ Napi::Number::New (env, session::config::contact_info::MAX_NAME_LENGTH);
1113
12- Napi::Object constants = Napi::Object::New (env);
13- constants.Set (" MAX_NAME_LENGTH" , MAX_NAME_LENGTH);
14+ const char * class_name = " CONSTANTS" ;
1415
15- exports.Set (" CONSTANTS" , constants);
16+ // construct javascript constants object
17+ Napi::Function cls = DefineClass (
18+ env,
19+ class_name,
20+ {ObjectWrap::StaticValue (" MAX_NAME_LENGTH" , MAX_NAME_LENGTH, napi_enumerable)});
21+
22+ // export object as javascript module
23+ exports.Set (class_name, cls);
1624 return exports;
1725}
1826
1927} // namespace session::nodeapi
28+
Original file line number Diff line number Diff line change 22
33#include < napi.h>
44
5- #include " session/config/contacts.hpp"
6-
75namespace session ::nodeapi {
86class ConstantsWrapper : public Napi ::ObjectWrap<ConstantsWrapper> {
97 public:
10- static Napi::Object Init (Napi::Env env, Napi::Object exports);
118 ConstantsWrapper (const Napi::CallbackInfo& info);
129
13- private:
14- static Napi::Number MAX_NAME_LENGTH;
10+ static Napi::Object Init (Napi::Env env, Napi::Object exports);
1511};
1612} // namespace session::nodeapi
13+
You can’t perform that action at this time.
0 commit comments