@ariacompute/router-rn 1.3.0 → 1.3.2
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.
- package/package.json +1 -1
- package/src/index.js +26 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -82,6 +82,7 @@ function createKoffiBackend() {
|
|
|
82
82
|
init: lib.func('aria_router_init', 'void*', ['str']),
|
|
83
83
|
connect: lib.func('aria_router_connect', 'void*', ['str']),
|
|
84
84
|
destroy: lib.func('aria_router_destroy', 'void', ['void*']),
|
|
85
|
+
setup: lib.func('aria_router_setup', 'void', ['void*', 'str', 'str']),
|
|
85
86
|
complete: lib.func('aria_router_complete', 'int', ['void*', 'str', 'str', 'void*', 'size_t']),
|
|
86
87
|
models: lib.func('aria_router_models', 'int', ['void*', 'void*', 'size_t']),
|
|
87
88
|
lastRoute: lib.func('aria_router_last_route', 'int', ['void*', 'void*', 'size_t']),
|
|
@@ -99,6 +100,13 @@ class Router {
|
|
|
99
100
|
|
|
100
101
|
setup(u = {}) {
|
|
101
102
|
this._auth = applySetup(this._auth, u);
|
|
103
|
+
if (this._handle && this._fn?.setup) {
|
|
104
|
+
this._fn.setup(
|
|
105
|
+
this._handle,
|
|
106
|
+
u.base_url !== undefined ? u.base_url : null,
|
|
107
|
+
u.token !== undefined ? u.token : null,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
102
110
|
return this;
|
|
103
111
|
}
|
|
104
112
|
|
|
@@ -108,6 +116,9 @@ class Router {
|
|
|
108
116
|
|
|
109
117
|
setupClear() {
|
|
110
118
|
this._auth = defaultSetup();
|
|
119
|
+
if (this._handle && this._fn?.setup) {
|
|
120
|
+
this._fn.setup(this._handle, '', '');
|
|
121
|
+
}
|
|
111
122
|
return this;
|
|
112
123
|
}
|
|
113
124
|
|
|
@@ -125,10 +136,22 @@ class Router {
|
|
|
125
136
|
return fallback;
|
|
126
137
|
}
|
|
127
138
|
|
|
139
|
+
_syncAuthIfSet() {
|
|
140
|
+
if (!this._handle || !this._fn?.setup) return;
|
|
141
|
+
if (this._auth.base_url || this._auth.token) {
|
|
142
|
+
this._fn.setup(
|
|
143
|
+
this._handle,
|
|
144
|
+
this._auth.base_url || null,
|
|
145
|
+
this._auth.token || null,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
128
150
|
init(configPath) {
|
|
129
151
|
const mode = this._ensureHost();
|
|
130
152
|
if (mode === 'native') {
|
|
131
153
|
this._native.init(configPath || null);
|
|
154
|
+
this._native.setup?.(this._auth.base_url || null, this._auth.token || null);
|
|
132
155
|
return this;
|
|
133
156
|
}
|
|
134
157
|
if (this._handle) this.close();
|
|
@@ -138,6 +161,7 @@ class Router {
|
|
|
138
161
|
}
|
|
139
162
|
this._handle = this._fn.init(pathArg);
|
|
140
163
|
if (!this._handle) throw new Error(this._err('init failed'));
|
|
164
|
+
this._syncAuthIfSet();
|
|
141
165
|
return this;
|
|
142
166
|
}
|
|
143
167
|
|
|
@@ -145,11 +169,13 @@ class Router {
|
|
|
145
169
|
const mode = this._ensureHost();
|
|
146
170
|
if (mode === 'native') {
|
|
147
171
|
this._native.connect(baseUrl);
|
|
172
|
+
this._native.setup?.(this._auth.base_url || null, this._auth.token || null);
|
|
148
173
|
return this;
|
|
149
174
|
}
|
|
150
175
|
if (this._handle) this.close();
|
|
151
176
|
this._handle = this._fn.connect(baseUrl);
|
|
152
177
|
if (!this._handle) throw new Error(this._err('connect failed'));
|
|
178
|
+
this._syncAuthIfSet();
|
|
153
179
|
return this;
|
|
154
180
|
}
|
|
155
181
|
|