tevrocsdk 0.1.84 → 0.1.85
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/tevroc-sdk.cjs.js +51580 -51023
- package/tevroc-sdk.cjs.js.map +7 -7
- package/tevroc-sdk.esm.js +45116 -44512
- package/tevroc-sdk.esm.js.map +7 -7
- package/tevroc-sdk.min.js +58 -56
- package/tevroc-sdk.umd.js +1035 -198
package/tevroc-sdk.umd.js
CHANGED
|
@@ -128,7 +128,22 @@ var Tevroc = (() => {
|
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
// node_modules/@capacitor/core/dist/index.js
|
|
131
|
-
var
|
|
131
|
+
var dist_exports = {};
|
|
132
|
+
__export(dist_exports, {
|
|
133
|
+
Capacitor: () => Capacitor,
|
|
134
|
+
CapacitorCookies: () => CapacitorCookies,
|
|
135
|
+
CapacitorException: () => CapacitorException,
|
|
136
|
+
CapacitorHttp: () => CapacitorHttp,
|
|
137
|
+
ExceptionCode: () => ExceptionCode,
|
|
138
|
+
SystemBarType: () => SystemBarType,
|
|
139
|
+
SystemBars: () => SystemBars,
|
|
140
|
+
SystemBarsStyle: () => SystemBarsStyle,
|
|
141
|
+
WebPlugin: () => WebPlugin,
|
|
142
|
+
WebView: () => WebView,
|
|
143
|
+
buildRequestInit: () => buildRequestInit,
|
|
144
|
+
registerPlugin: () => registerPlugin
|
|
145
|
+
});
|
|
146
|
+
var ExceptionCode, CapacitorException, getPlatformId, createCapacitor, initCapacitorGlobal, Capacitor, registerPlugin, WebPlugin, WebView, encode, decode, CapacitorCookiesPluginWeb, CapacitorCookies, readBlobAsBase64, normalizeHttpHeaders, buildUrlParams, buildRequestInit, CapacitorHttpPluginWeb, CapacitorHttp, SystemBarsStyle, SystemBarType, SystemBarsPluginWeb, SystemBars;
|
|
132
147
|
var init_dist = __esm({
|
|
133
148
|
"node_modules/@capacitor/core/dist/index.js"() {
|
|
134
149
|
(function(ExceptionCode2) {
|
|
@@ -398,6 +413,7 @@ var Tevroc = (() => {
|
|
|
398
413
|
});
|
|
399
414
|
}
|
|
400
415
|
};
|
|
416
|
+
WebView = /* @__PURE__ */ registerPlugin("WebView");
|
|
401
417
|
encode = (str) => encodeURIComponent(str).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
402
418
|
decode = (str) => str.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
403
419
|
CapacitorCookiesPluginWeb = class extends WebPlugin {
|
|
@@ -784,13 +800,52 @@ var Tevroc = (() => {
|
|
|
784
800
|
});
|
|
785
801
|
|
|
786
802
|
// node_modules/@tauri-apps/api/core.js
|
|
803
|
+
var core_exports = {};
|
|
804
|
+
__export(core_exports, {
|
|
805
|
+
Channel: () => Channel,
|
|
806
|
+
PluginListener: () => PluginListener,
|
|
807
|
+
Resource: () => Resource,
|
|
808
|
+
SERIALIZE_TO_IPC_FN: () => SERIALIZE_TO_IPC_FN,
|
|
809
|
+
addPluginListener: () => addPluginListener,
|
|
810
|
+
checkPermissions: () => checkPermissions,
|
|
811
|
+
convertFileSrc: () => convertFileSrc,
|
|
812
|
+
invoke: () => invoke,
|
|
813
|
+
isTauri: () => isTauri2,
|
|
814
|
+
requestPermissions: () => requestPermissions,
|
|
815
|
+
transformCallback: () => transformCallback
|
|
816
|
+
});
|
|
787
817
|
function transformCallback(callback, once2 = false) {
|
|
788
818
|
return window.__TAURI_INTERNALS__.transformCallback(callback, once2);
|
|
789
819
|
}
|
|
820
|
+
async function addPluginListener(plugin, event, cb) {
|
|
821
|
+
const handler = new Channel(cb);
|
|
822
|
+
try {
|
|
823
|
+
await invoke(`plugin:${plugin}|register_listener`, {
|
|
824
|
+
event,
|
|
825
|
+
handler
|
|
826
|
+
});
|
|
827
|
+
return new PluginListener(plugin, event, handler.id);
|
|
828
|
+
} catch {
|
|
829
|
+
await invoke(`plugin:${plugin}|registerListener`, { event, handler });
|
|
830
|
+
return new PluginListener(plugin, event, handler.id);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
async function checkPermissions(plugin) {
|
|
834
|
+
return invoke(`plugin:${plugin}|check_permissions`);
|
|
835
|
+
}
|
|
836
|
+
async function requestPermissions(plugin) {
|
|
837
|
+
return invoke(`plugin:${plugin}|request_permissions`);
|
|
838
|
+
}
|
|
790
839
|
async function invoke(cmd, args = {}, options) {
|
|
791
840
|
return window.__TAURI_INTERNALS__.invoke(cmd, args, options);
|
|
792
841
|
}
|
|
793
|
-
|
|
842
|
+
function convertFileSrc(filePath, protocol = "asset") {
|
|
843
|
+
return window.__TAURI_INTERNALS__.convertFileSrc(filePath, protocol);
|
|
844
|
+
}
|
|
845
|
+
function isTauri2() {
|
|
846
|
+
return !!(globalThis || window).isTauri;
|
|
847
|
+
}
|
|
848
|
+
var _Channel_onmessage, _Channel_nextMessageIndex, _Channel_pendingMessages, _Channel_messageEndIndex, _Resource_rid, SERIALIZE_TO_IPC_FN, Channel, PluginListener, Resource;
|
|
794
849
|
var init_core = __esm({
|
|
795
850
|
"node_modules/@tauri-apps/api/core.js"() {
|
|
796
851
|
init_tslib_es6();
|
|
@@ -847,6 +902,19 @@ var Tevroc = (() => {
|
|
|
847
902
|
return this[SERIALIZE_TO_IPC_FN]();
|
|
848
903
|
}
|
|
849
904
|
};
|
|
905
|
+
PluginListener = class {
|
|
906
|
+
constructor(plugin, event, channelId) {
|
|
907
|
+
this.plugin = plugin;
|
|
908
|
+
this.event = event;
|
|
909
|
+
this.channelId = channelId;
|
|
910
|
+
}
|
|
911
|
+
async unregister() {
|
|
912
|
+
return invoke(`plugin:${this.plugin}|remove_listener`, {
|
|
913
|
+
event: this.event,
|
|
914
|
+
channelId: this.channelId
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
};
|
|
850
918
|
Resource = class {
|
|
851
919
|
get rid() {
|
|
852
920
|
return __classPrivateFieldGet(this, _Resource_rid, "f");
|
|
@@ -8713,13 +8781,13 @@ var Tevroc = (() => {
|
|
|
8713
8781
|
var textList = toCodePoints$1(node2.data).map(function(i5) {
|
|
8714
8782
|
return fromCodePoint$1(i5);
|
|
8715
8783
|
});
|
|
8716
|
-
var
|
|
8784
|
+
var offset2 = 0;
|
|
8717
8785
|
var prev = {};
|
|
8718
8786
|
var supports = textList.every(function(text2, i5) {
|
|
8719
|
-
range.setStart(node2,
|
|
8720
|
-
range.setEnd(node2,
|
|
8787
|
+
range.setStart(node2, offset2);
|
|
8788
|
+
range.setEnd(node2, offset2 + text2.length);
|
|
8721
8789
|
var rect = range.getBoundingClientRect();
|
|
8722
|
-
|
|
8790
|
+
offset2 += text2.length;
|
|
8723
8791
|
var boundAhead = rect.x > prev.x || rect.y > prev.y;
|
|
8724
8792
|
prev = rect;
|
|
8725
8793
|
if (i5 === 0) {
|
|
@@ -8868,16 +8936,16 @@ var Tevroc = (() => {
|
|
|
8868
8936
|
var parseTextBounds = function(context, value, styles, node2) {
|
|
8869
8937
|
var textList = breakText(value, styles);
|
|
8870
8938
|
var textBounds = [];
|
|
8871
|
-
var
|
|
8939
|
+
var offset2 = 0;
|
|
8872
8940
|
textList.forEach(function(text2) {
|
|
8873
8941
|
if (styles.textDecorationLine.length || text2.trim().length > 0) {
|
|
8874
8942
|
if (FEATURES.SUPPORT_RANGE_BOUNDS) {
|
|
8875
|
-
var clientRects = createRange(node2,
|
|
8943
|
+
var clientRects = createRange(node2, offset2, text2.length).getClientRects();
|
|
8876
8944
|
if (clientRects.length > 1) {
|
|
8877
8945
|
var subSegments = segmentGraphemes(text2);
|
|
8878
8946
|
var subOffset_1 = 0;
|
|
8879
8947
|
subSegments.forEach(function(subSegment) {
|
|
8880
|
-
textBounds.push(new TextBounds(subSegment, Bounds.fromDOMRectList(context, createRange(node2, subOffset_1 +
|
|
8948
|
+
textBounds.push(new TextBounds(subSegment, Bounds.fromDOMRectList(context, createRange(node2, subOffset_1 + offset2, subSegment.length).getClientRects())));
|
|
8881
8949
|
subOffset_1 += subSegment.length;
|
|
8882
8950
|
});
|
|
8883
8951
|
} else {
|
|
@@ -8891,7 +8959,7 @@ var Tevroc = (() => {
|
|
|
8891
8959
|
} else if (!FEATURES.SUPPORT_RANGE_BOUNDS) {
|
|
8892
8960
|
node2 = node2.splitText(text2.length);
|
|
8893
8961
|
}
|
|
8894
|
-
|
|
8962
|
+
offset2 += text2.length;
|
|
8895
8963
|
});
|
|
8896
8964
|
return textBounds;
|
|
8897
8965
|
};
|
|
@@ -8912,14 +8980,14 @@ var Tevroc = (() => {
|
|
|
8912
8980
|
}
|
|
8913
8981
|
return Bounds.EMPTY;
|
|
8914
8982
|
};
|
|
8915
|
-
var createRange = function(node2,
|
|
8983
|
+
var createRange = function(node2, offset2, length) {
|
|
8916
8984
|
var ownerDocument = node2.ownerDocument;
|
|
8917
8985
|
if (!ownerDocument) {
|
|
8918
8986
|
throw new Error("Node has no owner document");
|
|
8919
8987
|
}
|
|
8920
8988
|
var range = ownerDocument.createRange();
|
|
8921
|
-
range.setStart(node2,
|
|
8922
|
-
range.setEnd(node2,
|
|
8989
|
+
range.setStart(node2, offset2);
|
|
8990
|
+
range.setEnd(node2, offset2 + length);
|
|
8923
8991
|
return range;
|
|
8924
8992
|
};
|
|
8925
8993
|
var segmentGraphemes = function(value) {
|
|
@@ -21230,13 +21298,13 @@ var Tevroc = (() => {
|
|
|
21230
21298
|
} else if (typeof ctx.mozDash !== "undefined" && !(gaps.length === 1 && gaps[0] === 0)) {
|
|
21231
21299
|
ctx.mozDash = gaps;
|
|
21232
21300
|
}
|
|
21233
|
-
var
|
|
21301
|
+
var offset2 = strokeDashoffsetProp.getPixels();
|
|
21234
21302
|
if (typeof ctx.lineDashOffset !== "undefined") {
|
|
21235
|
-
ctx.lineDashOffset =
|
|
21303
|
+
ctx.lineDashOffset = offset2;
|
|
21236
21304
|
} else if (typeof ctx.webkitLineDashOffset !== "undefined") {
|
|
21237
|
-
ctx.webkitLineDashOffset =
|
|
21305
|
+
ctx.webkitLineDashOffset = offset2;
|
|
21238
21306
|
} else if (typeof ctx.mozDashOffset !== "undefined") {
|
|
21239
|
-
ctx.mozDashOffset =
|
|
21307
|
+
ctx.mozDashOffset = offset2;
|
|
21240
21308
|
}
|
|
21241
21309
|
}
|
|
21242
21310
|
}
|
|
@@ -22673,7 +22741,7 @@ var Tevroc = (() => {
|
|
|
22673
22741
|
constructor(document2, node2, captureTextNodes) {
|
|
22674
22742
|
super(document2, node2, captureTextNodes);
|
|
22675
22743
|
this.type = "stop";
|
|
22676
|
-
var
|
|
22744
|
+
var offset2 = Math.max(0, Math.min(1, this.getAttribute("offset").getNumber()));
|
|
22677
22745
|
var stopOpacity = this.getStyle("stop-opacity");
|
|
22678
22746
|
var stopColor = this.getStyle("stop-color", true);
|
|
22679
22747
|
if (stopColor.getString() === "") {
|
|
@@ -22682,7 +22750,7 @@ var Tevroc = (() => {
|
|
|
22682
22750
|
if (stopOpacity.hasValue()) {
|
|
22683
22751
|
stopColor = stopColor.addOpacity(stopOpacity);
|
|
22684
22752
|
}
|
|
22685
|
-
this.offset =
|
|
22753
|
+
this.offset = offset2;
|
|
22686
22754
|
this.color = stopColor.getColor();
|
|
22687
22755
|
}
|
|
22688
22756
|
};
|
|
@@ -23081,17 +23149,17 @@ var Tevroc = (() => {
|
|
|
23081
23149
|
return this.letterSpacingCache[idx] || 0;
|
|
23082
23150
|
}
|
|
23083
23151
|
findSegmentToFitChar(ctx, anchor, textFullWidth, fullPathWidth, spacesNumber, inputOffset, dy, c4, charI) {
|
|
23084
|
-
var
|
|
23152
|
+
var offset2 = inputOffset;
|
|
23085
23153
|
var glyphWidth = this.measureText(ctx, c4);
|
|
23086
23154
|
if (c4 === " " && anchor === "justify" && textFullWidth < fullPathWidth) {
|
|
23087
23155
|
glyphWidth += (fullPathWidth - textFullWidth) / spacesNumber;
|
|
23088
23156
|
}
|
|
23089
23157
|
if (charI > -1) {
|
|
23090
|
-
|
|
23158
|
+
offset2 += this.getLetterSpacingAt(charI);
|
|
23091
23159
|
}
|
|
23092
23160
|
var splineStep = this.textHeight / 20;
|
|
23093
|
-
var p0 = this.getEquidistantPointOnPath(
|
|
23094
|
-
var p1 = this.getEquidistantPointOnPath(
|
|
23161
|
+
var p0 = this.getEquidistantPointOnPath(offset2, splineStep, 0);
|
|
23162
|
+
var p1 = this.getEquidistantPointOnPath(offset2 + glyphWidth, splineStep, 0);
|
|
23095
23163
|
var segment = {
|
|
23096
23164
|
p0,
|
|
23097
23165
|
p1
|
|
@@ -23109,9 +23177,9 @@ var Tevroc = (() => {
|
|
|
23109
23177
|
y: p1.y + dyY
|
|
23110
23178
|
});
|
|
23111
23179
|
}
|
|
23112
|
-
|
|
23180
|
+
offset2 += glyphWidth;
|
|
23113
23181
|
return {
|
|
23114
|
-
offset,
|
|
23182
|
+
offset: offset2,
|
|
23115
23183
|
segment,
|
|
23116
23184
|
rotation
|
|
23117
23185
|
};
|
|
@@ -23165,21 +23233,21 @@ var Tevroc = (() => {
|
|
|
23165
23233
|
this.glyphInfo = [];
|
|
23166
23234
|
var fullPathWidth = this.getPathLength();
|
|
23167
23235
|
var startOffset = this.getStyle("startOffset").getNumber(0) * fullPathWidth;
|
|
23168
|
-
var
|
|
23236
|
+
var offset2 = 0;
|
|
23169
23237
|
if (anchor === "middle" || anchor === "center") {
|
|
23170
|
-
|
|
23238
|
+
offset2 = -textFullWidth / 2;
|
|
23171
23239
|
}
|
|
23172
23240
|
if (anchor === "end" || anchor === "right") {
|
|
23173
|
-
|
|
23241
|
+
offset2 = -textFullWidth;
|
|
23174
23242
|
}
|
|
23175
|
-
|
|
23243
|
+
offset2 += startOffset;
|
|
23176
23244
|
chars.forEach((char, i5) => {
|
|
23177
23245
|
var {
|
|
23178
23246
|
offset: nextOffset,
|
|
23179
23247
|
segment,
|
|
23180
23248
|
rotation
|
|
23181
|
-
} = this.findSegmentToFitChar(ctx, anchor, textFullWidth, fullPathWidth, spacesNumber,
|
|
23182
|
-
|
|
23249
|
+
} = this.findSegmentToFitChar(ctx, anchor, textFullWidth, fullPathWidth, spacesNumber, offset2, dy, char, i5);
|
|
23250
|
+
offset2 = nextOffset;
|
|
23183
23251
|
if (!segment.p0 || !segment.p1) {
|
|
23184
23252
|
return;
|
|
23185
23253
|
}
|
|
@@ -24571,15 +24639,15 @@ var Tevroc = (() => {
|
|
|
24571
24639
|
}
|
|
24572
24640
|
static doUpgrade(event) {
|
|
24573
24641
|
const eventTarget = event.target;
|
|
24574
|
-
const
|
|
24642
|
+
const db2 = eventTarget.result;
|
|
24575
24643
|
switch (event.oldVersion) {
|
|
24576
24644
|
case 0:
|
|
24577
24645
|
case 1:
|
|
24578
24646
|
default: {
|
|
24579
|
-
if (
|
|
24580
|
-
|
|
24647
|
+
if (db2.objectStoreNames.contains("FileStorage")) {
|
|
24648
|
+
db2.deleteObjectStore("FileStorage");
|
|
24581
24649
|
}
|
|
24582
|
-
const store =
|
|
24650
|
+
const store = db2.createObjectStore("FileStorage", { keyPath: "path" });
|
|
24583
24651
|
store.createIndex("by_folder", "folder");
|
|
24584
24652
|
}
|
|
24585
24653
|
}
|
|
@@ -25807,10 +25875,10 @@ var Tevroc = (() => {
|
|
|
25807
25875
|
*
|
|
25808
25876
|
* @since 2.0.0
|
|
25809
25877
|
*/
|
|
25810
|
-
async seek(
|
|
25878
|
+
async seek(offset2, whence) {
|
|
25811
25879
|
return await invoke("plugin:fs|seek", {
|
|
25812
25880
|
rid: this.rid,
|
|
25813
|
-
offset,
|
|
25881
|
+
offset: offset2,
|
|
25814
25882
|
whence
|
|
25815
25883
|
});
|
|
25816
25884
|
}
|
|
@@ -27356,9 +27424,9 @@ var Tevroc = (() => {
|
|
|
27356
27424
|
* ```
|
|
27357
27425
|
* @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope.
|
|
27358
27426
|
*/
|
|
27359
|
-
async close(
|
|
27427
|
+
async close(db2) {
|
|
27360
27428
|
const success = await invoke("plugin:sql|close", {
|
|
27361
|
-
db
|
|
27429
|
+
db: db2
|
|
27362
27430
|
});
|
|
27363
27431
|
return success;
|
|
27364
27432
|
}
|
|
@@ -27476,6 +27544,134 @@ var Tevroc = (() => {
|
|
|
27476
27544
|
}
|
|
27477
27545
|
});
|
|
27478
27546
|
|
|
27547
|
+
// node_modules/@capacitor/geolocation/dist/esm/definitions.js
|
|
27548
|
+
var init_definitions7 = __esm({
|
|
27549
|
+
"node_modules/@capacitor/geolocation/dist/esm/definitions.js"() {
|
|
27550
|
+
}
|
|
27551
|
+
});
|
|
27552
|
+
|
|
27553
|
+
// node_modules/@capacitor/geolocation/dist/esm/web.js
|
|
27554
|
+
var web_exports7 = {};
|
|
27555
|
+
__export(web_exports7, {
|
|
27556
|
+
Geolocation: () => Geolocation,
|
|
27557
|
+
GeolocationWeb: () => GeolocationWeb
|
|
27558
|
+
});
|
|
27559
|
+
var GeolocationWeb, Geolocation;
|
|
27560
|
+
var init_web7 = __esm({
|
|
27561
|
+
"node_modules/@capacitor/geolocation/dist/esm/web.js"() {
|
|
27562
|
+
init_dist();
|
|
27563
|
+
GeolocationWeb = class extends WebPlugin {
|
|
27564
|
+
constructor() {
|
|
27565
|
+
super();
|
|
27566
|
+
this.latestOrientation = null;
|
|
27567
|
+
if (typeof window !== "undefined") {
|
|
27568
|
+
const win = window;
|
|
27569
|
+
if ("ondeviceorientationabsolute" in win) {
|
|
27570
|
+
win.addEventListener("deviceorientationabsolute", (event) => this.updateOrientation(event, true), true);
|
|
27571
|
+
} else if ("ondeviceorientation" in win) {
|
|
27572
|
+
win.addEventListener("deviceorientation", (event) => this.updateOrientation(event, false), true);
|
|
27573
|
+
}
|
|
27574
|
+
}
|
|
27575
|
+
}
|
|
27576
|
+
updateOrientation(event, isAbsolute2) {
|
|
27577
|
+
let trueHeading = null;
|
|
27578
|
+
let magneticHeading = null;
|
|
27579
|
+
let headingAccuracy = null;
|
|
27580
|
+
if (isAbsolute2 && event.alpha !== null) {
|
|
27581
|
+
trueHeading = (360 - event.alpha) % 360;
|
|
27582
|
+
} else if (event.webkitCompassHeading !== void 0 && event.webkitCompassHeading !== null) {
|
|
27583
|
+
magneticHeading = event.webkitCompassHeading;
|
|
27584
|
+
headingAccuracy = event.webkitCompassAccuracy;
|
|
27585
|
+
} else if (event.alpha !== null && event.absolute === true) {
|
|
27586
|
+
trueHeading = (360 - event.alpha) % 360;
|
|
27587
|
+
} else if (event.alpha !== null) {
|
|
27588
|
+
magneticHeading = (360 - event.alpha) % 360;
|
|
27589
|
+
}
|
|
27590
|
+
if (trueHeading !== null || magneticHeading !== null) {
|
|
27591
|
+
this.latestOrientation = {
|
|
27592
|
+
trueHeading,
|
|
27593
|
+
magneticHeading,
|
|
27594
|
+
headingAccuracy
|
|
27595
|
+
};
|
|
27596
|
+
}
|
|
27597
|
+
}
|
|
27598
|
+
augmentPosition(pos, isWatch = false) {
|
|
27599
|
+
var _a2, _b2, _c, _d, _e2, _f, _g;
|
|
27600
|
+
const coords = pos.coords;
|
|
27601
|
+
const orientation = isWatch ? this.latestOrientation : null;
|
|
27602
|
+
const heading = (_c = (_b2 = (_a2 = orientation === null || orientation === void 0 ? void 0 : orientation.trueHeading) !== null && _a2 !== void 0 ? _a2 : orientation === null || orientation === void 0 ? void 0 : orientation.magneticHeading) !== null && _b2 !== void 0 ? _b2 : isWatch ? coords.heading : null) !== null && _c !== void 0 ? _c : null;
|
|
27603
|
+
return {
|
|
27604
|
+
timestamp: pos.timestamp,
|
|
27605
|
+
coords: {
|
|
27606
|
+
latitude: coords.latitude,
|
|
27607
|
+
longitude: coords.longitude,
|
|
27608
|
+
accuracy: coords.accuracy,
|
|
27609
|
+
altitude: coords.altitude,
|
|
27610
|
+
altitudeAccuracy: coords.altitudeAccuracy,
|
|
27611
|
+
speed: coords.speed,
|
|
27612
|
+
heading,
|
|
27613
|
+
magneticHeading: (_d = orientation === null || orientation === void 0 ? void 0 : orientation.magneticHeading) !== null && _d !== void 0 ? _d : null,
|
|
27614
|
+
trueHeading: (_e2 = orientation === null || orientation === void 0 ? void 0 : orientation.trueHeading) !== null && _e2 !== void 0 ? _e2 : null,
|
|
27615
|
+
headingAccuracy: (_f = orientation === null || orientation === void 0 ? void 0 : orientation.headingAccuracy) !== null && _f !== void 0 ? _f : null,
|
|
27616
|
+
course: (_g = isWatch ? coords.heading : null) !== null && _g !== void 0 ? _g : null
|
|
27617
|
+
}
|
|
27618
|
+
};
|
|
27619
|
+
}
|
|
27620
|
+
async getCurrentPosition(options) {
|
|
27621
|
+
return new Promise((resolve3, reject) => {
|
|
27622
|
+
navigator.geolocation.getCurrentPosition((pos) => {
|
|
27623
|
+
resolve3(this.augmentPosition(pos, false));
|
|
27624
|
+
}, (err2) => {
|
|
27625
|
+
reject(err2);
|
|
27626
|
+
}, Object.assign({ enableHighAccuracy: false, timeout: 1e4, maximumAge: 0 }, options));
|
|
27627
|
+
});
|
|
27628
|
+
}
|
|
27629
|
+
async watchPosition(options, callback) {
|
|
27630
|
+
const id = navigator.geolocation.watchPosition((pos) => {
|
|
27631
|
+
callback(this.augmentPosition(pos, true));
|
|
27632
|
+
}, (err2) => {
|
|
27633
|
+
callback(null, err2);
|
|
27634
|
+
}, Object.assign({ enableHighAccuracy: false, timeout: 1e4, maximumAge: 0, minimumUpdateInterval: 5e3 }, options));
|
|
27635
|
+
return `${id}`;
|
|
27636
|
+
}
|
|
27637
|
+
async clearWatch(options) {
|
|
27638
|
+
navigator.geolocation.clearWatch(parseInt(options.id, 10));
|
|
27639
|
+
}
|
|
27640
|
+
async checkPermissions() {
|
|
27641
|
+
if (typeof navigator === "undefined" || !navigator.permissions) {
|
|
27642
|
+
throw this.unavailable("Permissions API not available in this browser");
|
|
27643
|
+
}
|
|
27644
|
+
const permission = await navigator.permissions.query({
|
|
27645
|
+
name: "geolocation"
|
|
27646
|
+
});
|
|
27647
|
+
return { location: permission.state, coarseLocation: permission.state };
|
|
27648
|
+
}
|
|
27649
|
+
async requestPermissions() {
|
|
27650
|
+
throw this.unimplemented("Not implemented on web.");
|
|
27651
|
+
}
|
|
27652
|
+
};
|
|
27653
|
+
Geolocation = new GeolocationWeb();
|
|
27654
|
+
}
|
|
27655
|
+
});
|
|
27656
|
+
|
|
27657
|
+
// node_modules/@capacitor/geolocation/dist/esm/index.js
|
|
27658
|
+
var esm_exports7 = {};
|
|
27659
|
+
__export(esm_exports7, {
|
|
27660
|
+
Geolocation: () => Geolocation2
|
|
27661
|
+
});
|
|
27662
|
+
var Geolocation2;
|
|
27663
|
+
var init_esm7 = __esm({
|
|
27664
|
+
"node_modules/@capacitor/geolocation/dist/esm/index.js"() {
|
|
27665
|
+
init_dist();
|
|
27666
|
+
init_synapse();
|
|
27667
|
+
init_definitions7();
|
|
27668
|
+
Geolocation2 = registerPlugin("Geolocation", {
|
|
27669
|
+
web: () => Promise.resolve().then(() => (init_web7(), web_exports7)).then((m4) => new m4.GeolocationWeb())
|
|
27670
|
+
});
|
|
27671
|
+
f3();
|
|
27672
|
+
}
|
|
27673
|
+
});
|
|
27674
|
+
|
|
27479
27675
|
// src/index.js
|
|
27480
27676
|
var index_exports = {};
|
|
27481
27677
|
__export(index_exports, {
|
|
@@ -27483,6 +27679,7 @@ var Tevroc = (() => {
|
|
|
27483
27679
|
TevrocError: () => TevrocError,
|
|
27484
27680
|
createChatbotClient: () => createChatbotClient,
|
|
27485
27681
|
createClient: () => createClient,
|
|
27682
|
+
createStorefrontClient: () => createStorefrontClient,
|
|
27486
27683
|
registerDebugHandler: () => registerDebugHandler,
|
|
27487
27684
|
unregisterDebugHandler: () => unregisterDebugHandler
|
|
27488
27685
|
});
|
|
@@ -28160,12 +28357,12 @@ var Tevroc = (() => {
|
|
|
28160
28357
|
dataIsGiven = true;
|
|
28161
28358
|
this.lastWrittenByte = data.byteLength;
|
|
28162
28359
|
}
|
|
28163
|
-
const
|
|
28164
|
-
const byteLength = data.byteLength -
|
|
28165
|
-
let dvOffset =
|
|
28360
|
+
const offset2 = options.offset ? options.offset >>> 0 : 0;
|
|
28361
|
+
const byteLength = data.byteLength - offset2;
|
|
28362
|
+
let dvOffset = offset2;
|
|
28166
28363
|
if (ArrayBuffer.isView(data) || data instanceof _IOBuffer) {
|
|
28167
28364
|
if (data.byteLength !== data.buffer.byteLength) {
|
|
28168
|
-
dvOffset = data.byteOffset +
|
|
28365
|
+
dvOffset = data.byteOffset + offset2;
|
|
28169
28366
|
}
|
|
28170
28367
|
data = data.buffer;
|
|
28171
28368
|
}
|
|
@@ -28247,8 +28444,8 @@ var Tevroc = (() => {
|
|
|
28247
28444
|
* @param offset - The offset to move to.
|
|
28248
28445
|
* @returns This.
|
|
28249
28446
|
*/
|
|
28250
|
-
seek(
|
|
28251
|
-
this.offset =
|
|
28447
|
+
seek(offset2) {
|
|
28448
|
+
this.offset = offset2;
|
|
28252
28449
|
return this;
|
|
28253
28450
|
}
|
|
28254
28451
|
/**
|
|
@@ -28285,11 +28482,11 @@ var Tevroc = (() => {
|
|
|
28285
28482
|
* @returns This.
|
|
28286
28483
|
*/
|
|
28287
28484
|
popMark() {
|
|
28288
|
-
const
|
|
28289
|
-
if (
|
|
28485
|
+
const offset2 = this._marks.pop();
|
|
28486
|
+
if (offset2 === void 0) {
|
|
28290
28487
|
throw new Error("Mark stack empty");
|
|
28291
28488
|
}
|
|
28292
|
-
this.seek(
|
|
28489
|
+
this.seek(offset2);
|
|
28293
28490
|
return this;
|
|
28294
28491
|
}
|
|
28295
28492
|
/**
|
|
@@ -28367,10 +28564,10 @@ var Tevroc = (() => {
|
|
|
28367
28564
|
*/
|
|
28368
28565
|
readArray(size2, type) {
|
|
28369
28566
|
const bytes = typedArrays[type].BYTES_PER_ELEMENT * size2;
|
|
28370
|
-
const
|
|
28371
|
-
const slice = this.buffer.slice(
|
|
28567
|
+
const offset2 = this.byteOffset + this.offset;
|
|
28568
|
+
const slice = this.buffer.slice(offset2, offset2 + bytes);
|
|
28372
28569
|
if (this.littleEndian === hostBigEndian && type !== "uint8" && type !== "int8") {
|
|
28373
|
-
const slice2 = new Uint8Array(this.buffer.slice(
|
|
28570
|
+
const slice2 = new Uint8Array(this.buffer.slice(offset2, offset2 + bytes));
|
|
28374
28571
|
slice2.reverse();
|
|
28375
28572
|
const returnArray2 = new typedArrays[type](slice2.buffer);
|
|
28376
28573
|
this.offset += bytes;
|
|
@@ -33074,7 +33271,7 @@ var Tevroc = (() => {
|
|
|
33074
33271
|
];
|
|
33075
33272
|
const bytesPerPixel = Math.ceil(depth / 8) * channels;
|
|
33076
33273
|
const resultData = new Uint8Array(height * width * bytesPerPixel);
|
|
33077
|
-
let
|
|
33274
|
+
let offset2 = 0;
|
|
33078
33275
|
for (let passIndex = 0; passIndex < 7; passIndex++) {
|
|
33079
33276
|
const pass = passes[passIndex];
|
|
33080
33277
|
const passWidth = Math.ceil((width - pass.x) / pass.xStep);
|
|
@@ -33084,9 +33281,9 @@ var Tevroc = (() => {
|
|
|
33084
33281
|
const passLineBytes = passWidth * bytesPerPixel;
|
|
33085
33282
|
const prevLine = new Uint8Array(passLineBytes);
|
|
33086
33283
|
for (let y3 = 0; y3 < passHeight; y3++) {
|
|
33087
|
-
const filterType = data[
|
|
33088
|
-
const currentLine = data.subarray(
|
|
33089
|
-
|
|
33284
|
+
const filterType = data[offset2++];
|
|
33285
|
+
const currentLine = data.subarray(offset2, offset2 + passLineBytes);
|
|
33286
|
+
offset2 += passLineBytes;
|
|
33090
33287
|
const newLine = new Uint8Array(passLineBytes);
|
|
33091
33288
|
applyUnfilter(filterType, currentLine, newLine, prevLine, passLineBytes, bytesPerPixel);
|
|
33092
33289
|
prevLine.set(newLine);
|
|
@@ -33128,13 +33325,13 @@ var Tevroc = (() => {
|
|
|
33128
33325
|
const bytesPerLine = Math.ceil(depth / 8 * channels * width);
|
|
33129
33326
|
const newData = new Uint8Array(height * bytesPerLine);
|
|
33130
33327
|
let prevLine = empty;
|
|
33131
|
-
let
|
|
33328
|
+
let offset2 = 0;
|
|
33132
33329
|
let currentLine;
|
|
33133
33330
|
let newLine;
|
|
33134
33331
|
for (let i4 = 0; i4 < height; i4++) {
|
|
33135
|
-
currentLine = data.subarray(
|
|
33332
|
+
currentLine = data.subarray(offset2 + 1, offset2 + 1 + bytesPerLine);
|
|
33136
33333
|
newLine = newData.subarray(i4 * bytesPerLine, (i4 + 1) * bytesPerLine);
|
|
33137
|
-
switch (data[
|
|
33334
|
+
switch (data[offset2]) {
|
|
33138
33335
|
case 0:
|
|
33139
33336
|
unfilterNone(currentLine, newLine, bytesPerLine);
|
|
33140
33337
|
break;
|
|
@@ -33151,10 +33348,10 @@ var Tevroc = (() => {
|
|
|
33151
33348
|
unfilterPaeth(currentLine, newLine, prevLine, bytesPerLine, bytesPerPixel);
|
|
33152
33349
|
break;
|
|
33153
33350
|
default:
|
|
33154
|
-
throw new Error(`Unsupported filter: ${data[
|
|
33351
|
+
throw new Error(`Unsupported filter: ${data[offset2]}`);
|
|
33155
33352
|
}
|
|
33156
33353
|
prevLine = newLine;
|
|
33157
|
-
|
|
33354
|
+
offset2 += bytesPerLine + 1;
|
|
33158
33355
|
}
|
|
33159
33356
|
if (depth === 16) {
|
|
33160
33357
|
const uint16Data = new Uint16Array(newData.buffer);
|
|
@@ -33339,7 +33536,7 @@ var Tevroc = (() => {
|
|
|
33339
33536
|
}
|
|
33340
33537
|
// https://www.w3.org/TR/PNG/#5Chunk-layout
|
|
33341
33538
|
decodeChunk(length, type) {
|
|
33342
|
-
const
|
|
33539
|
+
const offset2 = this.offset;
|
|
33343
33540
|
switch (type) {
|
|
33344
33541
|
// 11.2 Critical chunks
|
|
33345
33542
|
case "IHDR":
|
|
@@ -33371,7 +33568,7 @@ var Tevroc = (() => {
|
|
|
33371
33568
|
this.skip(length);
|
|
33372
33569
|
break;
|
|
33373
33570
|
}
|
|
33374
|
-
if (this.offset -
|
|
33571
|
+
if (this.offset - offset2 !== length) {
|
|
33375
33572
|
throw new Error(`Length mismatch while decoding chunk ${type}`);
|
|
33376
33573
|
}
|
|
33377
33574
|
if (this._checkCrc) {
|
|
@@ -33381,7 +33578,7 @@ var Tevroc = (() => {
|
|
|
33381
33578
|
}
|
|
33382
33579
|
}
|
|
33383
33580
|
decodeApngChunk(length, type) {
|
|
33384
|
-
const
|
|
33581
|
+
const offset2 = this.offset;
|
|
33385
33582
|
if (type !== "fdAT" && type !== "IDAT" && this._writingDataChunks) {
|
|
33386
33583
|
this.pushDataToFrame();
|
|
33387
33584
|
}
|
|
@@ -33397,10 +33594,10 @@ var Tevroc = (() => {
|
|
|
33397
33594
|
break;
|
|
33398
33595
|
default:
|
|
33399
33596
|
this.decodeChunk(length, type);
|
|
33400
|
-
this.offset =
|
|
33597
|
+
this.offset = offset2 + length;
|
|
33401
33598
|
break;
|
|
33402
33599
|
}
|
|
33403
|
-
if (this.offset -
|
|
33600
|
+
if (this.offset - offset2 !== length) {
|
|
33404
33601
|
throw new Error(`Length mismatch while decoding chunk ${type}`);
|
|
33405
33602
|
}
|
|
33406
33603
|
if (this._checkCrc) {
|
|
@@ -41697,19 +41894,19 @@ var Tevroc = (() => {
|
|
|
41697
41894
|
}
|
|
41698
41895
|
debugWarn("[tevrocsdk][useEntities] opening SQLite connection for appId", { appId });
|
|
41699
41896
|
const name = dbName(appId);
|
|
41700
|
-
const
|
|
41701
|
-
debugWarn("[tevrocsdk][useEntities] SQLite connection created", { name, db });
|
|
41702
|
-
await
|
|
41703
|
-
debugWarn("[tevrocsdk][useEntities] SQLite connection opened", { name, db });
|
|
41704
|
-
await
|
|
41897
|
+
const db2 = await sqlite.createConnection(name, false, "no-encryption", 1, false);
|
|
41898
|
+
debugWarn("[tevrocsdk][useEntities] SQLite connection created", { name, db: db2 });
|
|
41899
|
+
await db2.open();
|
|
41900
|
+
debugWarn("[tevrocsdk][useEntities] SQLite connection opened", { name, db: db2 });
|
|
41901
|
+
await db2.execute("CREATE TABLE IF NOT EXISTS kv (key TEXT PRIMARY KEY, value TEXT NOT NULL)");
|
|
41705
41902
|
debugLog("[tevrocsdk][useEntities] mobile SQLite opened", { name });
|
|
41706
41903
|
return {
|
|
41707
41904
|
async get(key) {
|
|
41708
|
-
const res = await
|
|
41905
|
+
const res = await db2.query("SELECT value FROM kv WHERE key = ? LIMIT 1", [key]);
|
|
41709
41906
|
return res.values?.[0]?.value ?? null;
|
|
41710
41907
|
},
|
|
41711
41908
|
async set(key, value) {
|
|
41712
|
-
await
|
|
41909
|
+
await db2.run("INSERT OR REPLACE INTO kv (key, value) VALUES (?, ?)", [key, value]);
|
|
41713
41910
|
}
|
|
41714
41911
|
};
|
|
41715
41912
|
}
|
|
@@ -41717,16 +41914,16 @@ var Tevroc = (() => {
|
|
|
41717
41914
|
debugLog("[tevrocsdk][useEntities] opening desktop SQLite for appId", appId);
|
|
41718
41915
|
const mod = await Promise.resolve().then(() => (init_dist_js3(), dist_js_exports3));
|
|
41719
41916
|
const Database2 = mod.default || mod.Database;
|
|
41720
|
-
const
|
|
41721
|
-
await
|
|
41917
|
+
const db2 = await Database2.load(`sqlite:${dbName(appId)}.db`);
|
|
41918
|
+
await db2.execute("CREATE TABLE IF NOT EXISTS kv (key TEXT PRIMARY KEY, value TEXT NOT NULL)");
|
|
41722
41919
|
debugLog("[tevrocsdk][useEntities] desktop SQLite opened", { dbFile: `${dbName(appId)}.db` });
|
|
41723
41920
|
return {
|
|
41724
41921
|
async get(key) {
|
|
41725
|
-
const rows = await
|
|
41922
|
+
const rows = await db2.select("SELECT value FROM kv WHERE key = ? LIMIT 1", [key]);
|
|
41726
41923
|
return rows?.[0]?.value ?? null;
|
|
41727
41924
|
},
|
|
41728
41925
|
async set(key, value) {
|
|
41729
|
-
await
|
|
41926
|
+
await db2.execute("INSERT OR REPLACE INTO kv (key, value) VALUES (?, ?)", [key, value]);
|
|
41730
41927
|
}
|
|
41731
41928
|
};
|
|
41732
41929
|
}
|
|
@@ -41761,14 +41958,14 @@ var Tevroc = (() => {
|
|
|
41761
41958
|
return sqliteDb;
|
|
41762
41959
|
}
|
|
41763
41960
|
async function readDB(appId) {
|
|
41764
|
-
const
|
|
41765
|
-
const stored = await
|
|
41961
|
+
const db2 = await openSqlite(appId);
|
|
41962
|
+
const stored = await db2.get("db");
|
|
41766
41963
|
return parseStoredJson(stored);
|
|
41767
41964
|
}
|
|
41768
41965
|
async function writeDB(appId, data) {
|
|
41769
41966
|
const json = JSON.stringify(data || {}, null, 2);
|
|
41770
|
-
const
|
|
41771
|
-
await
|
|
41967
|
+
const db2 = await openSqlite(appId);
|
|
41968
|
+
await db2.set("db", json);
|
|
41772
41969
|
}
|
|
41773
41970
|
function parseStoredJson(value) {
|
|
41774
41971
|
if (!value) return {};
|
|
@@ -41821,10 +42018,10 @@ var Tevroc = (() => {
|
|
|
41821
42018
|
}
|
|
41822
42019
|
function createNativeStore(appId = "default") {
|
|
41823
42020
|
async function getValue(pathRef) {
|
|
41824
|
-
const
|
|
42021
|
+
const db2 = await readDB(appId);
|
|
41825
42022
|
const path = pathRef?.path || pathRef || "";
|
|
41826
42023
|
const parts = String(path).split("/").filter(Boolean);
|
|
41827
|
-
let value =
|
|
42024
|
+
let value = db2;
|
|
41828
42025
|
for (const part of parts) {
|
|
41829
42026
|
value = value?.[part];
|
|
41830
42027
|
if (value === void 0) break;
|
|
@@ -41832,32 +42029,32 @@ var Tevroc = (() => {
|
|
|
41832
42029
|
return snap(value);
|
|
41833
42030
|
}
|
|
41834
42031
|
async function setValue(pathRef, value) {
|
|
41835
|
-
const
|
|
42032
|
+
const db2 = await readDB(appId);
|
|
41836
42033
|
const path = pathRef?.path || pathRef || "";
|
|
41837
|
-
const node2 = resolvePath(
|
|
42034
|
+
const node2 = resolvePath(db2, path, true);
|
|
41838
42035
|
if (!node2) return;
|
|
41839
42036
|
if (isEqual(node2.ref[node2.key], value)) return;
|
|
41840
42037
|
node2.ref[node2.key] = value;
|
|
41841
|
-
await writeDB(appId,
|
|
42038
|
+
await writeDB(appId, db2);
|
|
41842
42039
|
}
|
|
41843
42040
|
async function updateValue(pathRef, value) {
|
|
41844
|
-
const
|
|
42041
|
+
const db2 = await readDB(appId);
|
|
41845
42042
|
const path = pathRef?.path || pathRef || "";
|
|
41846
|
-
const node2 = resolvePath(
|
|
42043
|
+
const node2 = resolvePath(db2, path, true);
|
|
41847
42044
|
if (!node2) return;
|
|
41848
42045
|
const prev = node2.ref[node2.key] || {};
|
|
41849
42046
|
const next = deepMerge(structuredClone(prev), value);
|
|
41850
42047
|
if (isEqual(prev, next)) return;
|
|
41851
42048
|
node2.ref[node2.key] = next;
|
|
41852
|
-
await writeDB(appId,
|
|
42049
|
+
await writeDB(appId, db2);
|
|
41853
42050
|
}
|
|
41854
42051
|
async function removeValue(pathRef) {
|
|
41855
|
-
const
|
|
42052
|
+
const db2 = await readDB(appId);
|
|
41856
42053
|
const path = pathRef?.path || pathRef || "";
|
|
41857
|
-
const node2 = resolvePath(
|
|
42054
|
+
const node2 = resolvePath(db2, path);
|
|
41858
42055
|
if (!node2 || node2.ref[node2.key] === void 0) return;
|
|
41859
42056
|
delete node2.ref[node2.key];
|
|
41860
|
-
await writeDB(appId,
|
|
42057
|
+
await writeDB(appId, db2);
|
|
41861
42058
|
}
|
|
41862
42059
|
function ref(_db, path) {
|
|
41863
42060
|
return { path };
|
|
@@ -42158,15 +42355,15 @@ var Tevroc = (() => {
|
|
|
42158
42355
|
if (!url) return null;
|
|
42159
42356
|
if (!isNative) return null;
|
|
42160
42357
|
try {
|
|
42161
|
-
|
|
42358
|
+
debugLog(`[tevrocsdk][fileoffline] downloadUrlToBase64 fetching`, url);
|
|
42162
42359
|
const res = await fetch(url, { cache: "no-store" });
|
|
42163
42360
|
if (!res.ok) return null;
|
|
42164
42361
|
const b2 = await res.blob();
|
|
42165
42362
|
const base64 = await blobToBase642(b2).catch(() => null);
|
|
42166
|
-
|
|
42363
|
+
debugLog(`[tevrocsdk][fileoffline] downloadUrlToBase64 fetched -> base64 length`, base64 ? base64.length : 0);
|
|
42167
42364
|
return base64;
|
|
42168
42365
|
} catch (e2) {
|
|
42169
|
-
|
|
42366
|
+
debugWarn(`[tevrocsdk][fileoffline] downloadUrlToBase64 failed`, e2);
|
|
42170
42367
|
return null;
|
|
42171
42368
|
}
|
|
42172
42369
|
}
|
|
@@ -42184,34 +42381,34 @@ var Tevroc = (() => {
|
|
|
42184
42381
|
async function persistFileToNative(client, key, base64, contentType) {
|
|
42185
42382
|
try {
|
|
42186
42383
|
if (!isNative) return false;
|
|
42187
|
-
|
|
42384
|
+
debugLog("[tevrocsdk][fileoffline] persistFileToNative", { key, contentType, hasBase64: !!base64 });
|
|
42188
42385
|
if (!client?.native?.store || !base64) {
|
|
42189
|
-
|
|
42386
|
+
debugWarn("[tevrocsdk][fileoffline] persistFileToNative skipped - missing native.store or base64");
|
|
42190
42387
|
return false;
|
|
42191
42388
|
}
|
|
42192
42389
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
42193
42390
|
await client.native.store.set(`downloaded_files/${key}`, { data: base64, contentType: contentType || "application/octet-stream", key, updatedAt: now });
|
|
42194
|
-
|
|
42391
|
+
debugLog("[tevrocsdk][fileoffline] persistFileToNative stored", { key, updatedAt: now });
|
|
42195
42392
|
return true;
|
|
42196
42393
|
} catch (e2) {
|
|
42197
|
-
|
|
42394
|
+
debugWarn("[tevrocsdk][fileoffline] persistFileToNative error", e2);
|
|
42198
42395
|
return false;
|
|
42199
42396
|
}
|
|
42200
42397
|
}
|
|
42201
42398
|
async function walkAndPersistFiles(client, obj) {
|
|
42202
42399
|
if (!obj || typeof obj !== "object") return;
|
|
42203
42400
|
if (!isNative || !client?.native?.store) return;
|
|
42204
|
-
|
|
42401
|
+
debugLog("[tevrocsdk][fileoffline] walkAndPersistFiles start");
|
|
42205
42402
|
for (const k2 of Object.keys(obj)) {
|
|
42206
42403
|
const v3 = obj[k2];
|
|
42207
42404
|
if (typeof v3 === "string") {
|
|
42208
42405
|
if (isDataUrl(v3)) {
|
|
42209
|
-
|
|
42406
|
+
debugLog("[tevrocsdk][fileoffline] walkAndPersistFiles found data URL at key", k2);
|
|
42210
42407
|
const base64 = extractBase64FromDataUrl(v3);
|
|
42211
42408
|
const key = deriveKeyFromUrl(k2) || `inline_${Date.now()}`;
|
|
42212
42409
|
await persistFileToNative(client, key, base64, (v3.match(/^data:([^;]+);/) || [])[1] || "application/octet-stream");
|
|
42213
42410
|
} else if (/^https?:\/\//.test(v3) || v3.startsWith("filebase://")) {
|
|
42214
|
-
|
|
42411
|
+
debugLog("[tevrocsdk][fileoffline] walkAndPersistFiles found URL at key", k2, v3);
|
|
42215
42412
|
const url = v3.startsWith("filebase://") ? v3.replace(/^filebase:\/\//, "") : v3;
|
|
42216
42413
|
const base64 = await downloadUrlToBase64(v3).catch(() => null);
|
|
42217
42414
|
if (base64) {
|
|
@@ -42219,16 +42416,16 @@ var Tevroc = (() => {
|
|
|
42219
42416
|
await persistFileToNative(client, key, base64, "application/octet-stream");
|
|
42220
42417
|
}
|
|
42221
42418
|
} else if (isLikelyBase64(v3)) {
|
|
42222
|
-
|
|
42419
|
+
debugLog("[tevrocsdk][fileoffline] walkAndPersistFiles found inline base64 at key", k2);
|
|
42223
42420
|
const key = deriveKeyFromUrl(k2) || `inline_${Date.now()}`;
|
|
42224
42421
|
await persistFileToNative(client, key, v3, "application/octet-stream");
|
|
42225
42422
|
}
|
|
42226
42423
|
} else if (v3 && typeof v3 === "object") {
|
|
42227
|
-
|
|
42424
|
+
debugLog("[tevrocsdk][fileoffline] walkAndPersistFiles recursing into", k2);
|
|
42228
42425
|
await walkAndPersistFiles(client, v3);
|
|
42229
42426
|
}
|
|
42230
42427
|
}
|
|
42231
|
-
|
|
42428
|
+
debugLog("[tevrocsdk][fileoffline] walkAndPersistFiles end");
|
|
42232
42429
|
}
|
|
42233
42430
|
function createOfflineManager(client) {
|
|
42234
42431
|
const store = createNativeStore(client.appId);
|
|
@@ -42642,6 +42839,343 @@ var Tevroc = (() => {
|
|
|
42642
42839
|
};
|
|
42643
42840
|
}
|
|
42644
42841
|
|
|
42842
|
+
// src/native.js
|
|
42843
|
+
init_dist_js3();
|
|
42844
|
+
init_usePlatform();
|
|
42845
|
+
init_debug();
|
|
42846
|
+
var bluetoothBridgePromise;
|
|
42847
|
+
async function getBluetoothBridge() {
|
|
42848
|
+
if (bluetoothBridgePromise) return bluetoothBridgePromise;
|
|
42849
|
+
bluetoothBridgePromise = (async () => {
|
|
42850
|
+
if (isCapacitor) {
|
|
42851
|
+
try {
|
|
42852
|
+
const { registerPlugin: registerPlugin2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
|
|
42853
|
+
return registerPlugin2("Bluetooth");
|
|
42854
|
+
} catch {
|
|
42855
|
+
}
|
|
42856
|
+
}
|
|
42857
|
+
if (isTauri) return createTauriBluetoothBridge();
|
|
42858
|
+
if (typeof window !== "undefined") return window.__TEVROC_NATIVE_BLUETOOTH__ || window.__TEVROC_BLUETOOTH__ || null;
|
|
42859
|
+
return null;
|
|
42860
|
+
})();
|
|
42861
|
+
return bluetoothBridgePromise;
|
|
42862
|
+
}
|
|
42863
|
+
function createTauriBluetoothBridge() {
|
|
42864
|
+
let device = null;
|
|
42865
|
+
let characteristic = null;
|
|
42866
|
+
const invoke2 = async (command, args) => {
|
|
42867
|
+
const { invoke: call } = await Promise.resolve().then(() => (init_core(), core_exports));
|
|
42868
|
+
return call(command, args);
|
|
42869
|
+
};
|
|
42870
|
+
const browser = () => typeof navigator !== "undefined" && navigator.bluetooth;
|
|
42871
|
+
const browserScan = async () => {
|
|
42872
|
+
if (!browser()?.requestDevice) return [];
|
|
42873
|
+
const selected = await browser().requestDevice({ acceptAllDevices: true, optionalServices: [] });
|
|
42874
|
+
return [{ id: selected.id, name: selected.name || "Bluetooth device", native: true }];
|
|
42875
|
+
};
|
|
42876
|
+
const browserConnect = async (target) => {
|
|
42877
|
+
if (!browser()?.requestDevice) throw new Error("Tauri Bluetooth support is unavailable.");
|
|
42878
|
+
device = target?.id && device?.id === target.id ? device : await browser().requestDevice({ acceptAllDevices: true, optionalServices: [] });
|
|
42879
|
+
if (!device.gatt) throw new Error("Selected Bluetooth device does not expose GATT.");
|
|
42880
|
+
await device.gatt.connect();
|
|
42881
|
+
return { id: device.id, name: device.name, connected: true };
|
|
42882
|
+
};
|
|
42883
|
+
return {
|
|
42884
|
+
isAvailable: async () => {
|
|
42885
|
+
try {
|
|
42886
|
+
return Boolean(await invoke2("bluetooth_is_available"));
|
|
42887
|
+
} catch {
|
|
42888
|
+
return Boolean(browser()?.requestDevice);
|
|
42889
|
+
}
|
|
42890
|
+
},
|
|
42891
|
+
isEnabled: async () => {
|
|
42892
|
+
try {
|
|
42893
|
+
return Boolean(await invoke2("bluetooth_is_enabled"));
|
|
42894
|
+
} catch {
|
|
42895
|
+
return Boolean(browser());
|
|
42896
|
+
}
|
|
42897
|
+
},
|
|
42898
|
+
setEnabled: async (enabled) => {
|
|
42899
|
+
try {
|
|
42900
|
+
return await invoke2("bluetooth_set_enabled", { enabled });
|
|
42901
|
+
} catch {
|
|
42902
|
+
throw new Error("Tauri desktop Bluetooth power must be changed in operating system settings.");
|
|
42903
|
+
}
|
|
42904
|
+
},
|
|
42905
|
+
scan: async () => {
|
|
42906
|
+
try {
|
|
42907
|
+
return await invoke2("bluetooth_scan") || [];
|
|
42908
|
+
} catch {
|
|
42909
|
+
return browserScan();
|
|
42910
|
+
}
|
|
42911
|
+
},
|
|
42912
|
+
pair: async (target) => {
|
|
42913
|
+
try {
|
|
42914
|
+
return await invoke2("bluetooth_pair", { deviceId: target?.id || target?.address });
|
|
42915
|
+
} catch {
|
|
42916
|
+
return browserConnect(target);
|
|
42917
|
+
}
|
|
42918
|
+
},
|
|
42919
|
+
connect: async (target) => {
|
|
42920
|
+
try {
|
|
42921
|
+
return await invoke2("bluetooth_connect", { deviceId: target?.id || target?.address });
|
|
42922
|
+
} catch {
|
|
42923
|
+
return browserConnect(target);
|
|
42924
|
+
}
|
|
42925
|
+
},
|
|
42926
|
+
disconnect: async () => {
|
|
42927
|
+
try {
|
|
42928
|
+
await invoke2("bluetooth_disconnect");
|
|
42929
|
+
} catch {
|
|
42930
|
+
device?.gatt?.disconnect?.();
|
|
42931
|
+
}
|
|
42932
|
+
device = null;
|
|
42933
|
+
characteristic = null;
|
|
42934
|
+
},
|
|
42935
|
+
send: async (payload) => {
|
|
42936
|
+
const data = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
42937
|
+
try {
|
|
42938
|
+
return await invoke2("bluetooth_send", { data });
|
|
42939
|
+
} catch {
|
|
42940
|
+
if (!characteristic) throw new Error("Connect a Bluetooth device before sending data.");
|
|
42941
|
+
return characteristic.writeValue(new TextEncoder().encode(data));
|
|
42942
|
+
}
|
|
42943
|
+
},
|
|
42944
|
+
onMessage: (listener) => {
|
|
42945
|
+
let remove2;
|
|
42946
|
+
Promise.resolve().then(() => (init_event(), event_exports)).then(({ listen: listen2 }) => listen2("bluetooth-message", (event) => listener(event.payload))).then((unlisten) => {
|
|
42947
|
+
remove2 = unlisten;
|
|
42948
|
+
});
|
|
42949
|
+
return () => remove2?.();
|
|
42950
|
+
}
|
|
42951
|
+
};
|
|
42952
|
+
}
|
|
42953
|
+
function createGpsApi() {
|
|
42954
|
+
const capacitor = async () => {
|
|
42955
|
+
if (!isCapacitor) return null;
|
|
42956
|
+
const { Geolocation: Geolocation3 } = await Promise.resolve().then(() => (init_esm7(), esm_exports7));
|
|
42957
|
+
return Geolocation3;
|
|
42958
|
+
};
|
|
42959
|
+
const tauriInvoke = async (command, args) => {
|
|
42960
|
+
const { invoke: invoke2 } = await Promise.resolve().then(() => (init_core(), core_exports));
|
|
42961
|
+
return invoke2(command, args);
|
|
42962
|
+
};
|
|
42963
|
+
return {
|
|
42964
|
+
isAvailable: async () => {
|
|
42965
|
+
if (isCapacitor) return Boolean(await capacitor());
|
|
42966
|
+
if (isTauri) {
|
|
42967
|
+
try {
|
|
42968
|
+
return Boolean(await tauriInvoke("gps_is_available"));
|
|
42969
|
+
} catch {
|
|
42970
|
+
}
|
|
42971
|
+
}
|
|
42972
|
+
return typeof navigator !== "undefined" && Boolean(navigator.geolocation);
|
|
42973
|
+
},
|
|
42974
|
+
getCurrentPosition: async (options = {}) => {
|
|
42975
|
+
if (isCapacitor) return capacitor().then((api) => api.getCurrentPosition(options));
|
|
42976
|
+
if (isTauri) {
|
|
42977
|
+
try {
|
|
42978
|
+
return await tauriInvoke("gps_current_position", { options });
|
|
42979
|
+
} catch {
|
|
42980
|
+
}
|
|
42981
|
+
}
|
|
42982
|
+
return new Promise((resolve3, reject) => navigator.geolocation.getCurrentPosition(resolve3, reject, options));
|
|
42983
|
+
},
|
|
42984
|
+
watchPosition: async (callback, options = {}) => {
|
|
42985
|
+
if (isCapacitor) {
|
|
42986
|
+
const api = await capacitor();
|
|
42987
|
+
const handle = await api.watchPosition(options, callback);
|
|
42988
|
+
return { remove: () => api.clearWatch({ id: handle }) };
|
|
42989
|
+
}
|
|
42990
|
+
if (isTauri) {
|
|
42991
|
+
try {
|
|
42992
|
+
return await tauriInvoke("gps_watch_position", { options });
|
|
42993
|
+
} catch {
|
|
42994
|
+
}
|
|
42995
|
+
}
|
|
42996
|
+
return navigator.geolocation.watchPosition(callback, callback, options);
|
|
42997
|
+
},
|
|
42998
|
+
clearWatch: async (watchId) => {
|
|
42999
|
+
if (isCapacitor) return (await capacitor()).clearWatch({ id: watchId });
|
|
43000
|
+
if (isTauri) {
|
|
43001
|
+
try {
|
|
43002
|
+
return await tauriInvoke("gps_clear_watch", { watchId });
|
|
43003
|
+
} catch {
|
|
43004
|
+
}
|
|
43005
|
+
}
|
|
43006
|
+
return navigator.geolocation.clearWatch(watchId);
|
|
43007
|
+
},
|
|
43008
|
+
requestPermissions: async () => isCapacitor ? (await capacitor()).requestPermissions() : null
|
|
43009
|
+
};
|
|
43010
|
+
}
|
|
43011
|
+
function createBluetoothApi() {
|
|
43012
|
+
const call = async (method, ...args) => {
|
|
43013
|
+
const bridge = await getBluetoothBridge();
|
|
43014
|
+
return bridge?.[method]?.(...args);
|
|
43015
|
+
};
|
|
43016
|
+
return {
|
|
43017
|
+
isAvailable: async () => {
|
|
43018
|
+
const result = await call("isAvailable");
|
|
43019
|
+
return Boolean(result?.available ?? result);
|
|
43020
|
+
},
|
|
43021
|
+
isEnabled: async () => {
|
|
43022
|
+
const result = await call("isEnabled");
|
|
43023
|
+
return Boolean(result?.enabled ?? result);
|
|
43024
|
+
},
|
|
43025
|
+
setEnabled: async (enabled) => {
|
|
43026
|
+
const result = await call("setEnabled", Boolean(enabled));
|
|
43027
|
+
if (result === void 0 && !isCapacitor && !isTauri) throw new Error("Native Bluetooth power control is unavailable.");
|
|
43028
|
+
return result;
|
|
43029
|
+
},
|
|
43030
|
+
scan: async (options = {}) => {
|
|
43031
|
+
const result = await call("scan", options);
|
|
43032
|
+
return result?.devices || result || [];
|
|
43033
|
+
},
|
|
43034
|
+
connect: async (device) => {
|
|
43035
|
+
const result = await call("connect", isCapacitor ? { deviceId: device?.id || device?.address } : device);
|
|
43036
|
+
if (result === void 0) throw new Error("Native Bluetooth bridge is unavailable.");
|
|
43037
|
+
return result;
|
|
43038
|
+
},
|
|
43039
|
+
pair: async (device) => {
|
|
43040
|
+
const result = await call("pair", isCapacitor ? { deviceId: device?.id || device?.address } : device);
|
|
43041
|
+
if (result === void 0) throw new Error("Native Bluetooth pairing is unavailable.");
|
|
43042
|
+
return result;
|
|
43043
|
+
},
|
|
43044
|
+
disconnect: async (device) => call("disconnect", device),
|
|
43045
|
+
send: async (payload) => {
|
|
43046
|
+
const data = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
43047
|
+
const result = await call("send", isCapacitor ? { data } : payload);
|
|
43048
|
+
if (result === void 0) throw new Error("Native Bluetooth bridge is unavailable.");
|
|
43049
|
+
return result;
|
|
43050
|
+
},
|
|
43051
|
+
onMessage: (listener) => {
|
|
43052
|
+
let remove2;
|
|
43053
|
+
getBluetoothBridge().then((bridge) => {
|
|
43054
|
+
const subscription = bridge?.addListener ? bridge.addListener("message", listener) : bridge?.onMessage?.(listener);
|
|
43055
|
+
Promise.resolve(subscription).then((value) => {
|
|
43056
|
+
remove2 = value;
|
|
43057
|
+
});
|
|
43058
|
+
});
|
|
43059
|
+
return () => remove2?.remove?.() || remove2?.();
|
|
43060
|
+
}
|
|
43061
|
+
};
|
|
43062
|
+
}
|
|
43063
|
+
var db;
|
|
43064
|
+
async function getDb() {
|
|
43065
|
+
if (!db) {
|
|
43066
|
+
db = await Database.load("sqlite:app.db");
|
|
43067
|
+
}
|
|
43068
|
+
return db;
|
|
43069
|
+
}
|
|
43070
|
+
var unwrapData = (r2) => r2?.data ?? r2;
|
|
43071
|
+
var unwrapList = (r2) => Array.isArray(r2) ? r2 : r2?.data ?? [];
|
|
43072
|
+
function normalizeListArgs(o3, limit) {
|
|
43073
|
+
if (o3 && typeof o3 === "object") return o3;
|
|
43074
|
+
return { limit };
|
|
43075
|
+
}
|
|
43076
|
+
function createSQLiteEntity(table) {
|
|
43077
|
+
return {
|
|
43078
|
+
list: async (o3, l3) => {
|
|
43079
|
+
const db2 = await getDb();
|
|
43080
|
+
const res = await db2.select(
|
|
43081
|
+
`SELECT * FROM ${table} LIMIT ?`,
|
|
43082
|
+
[l3 || 100]
|
|
43083
|
+
);
|
|
43084
|
+
return unwrapList(res);
|
|
43085
|
+
},
|
|
43086
|
+
get: async (id) => {
|
|
43087
|
+
const db2 = await getDb();
|
|
43088
|
+
const res = await db2.select(
|
|
43089
|
+
`SELECT * FROM ${table} WHERE id = ? LIMIT 1`,
|
|
43090
|
+
[id]
|
|
43091
|
+
);
|
|
43092
|
+
return res?.[0] ?? null;
|
|
43093
|
+
},
|
|
43094
|
+
create: async (record) => {
|
|
43095
|
+
const db2 = await getDb();
|
|
43096
|
+
const keys = Object.keys(record);
|
|
43097
|
+
const values = Object.values(record);
|
|
43098
|
+
await db2.execute(
|
|
43099
|
+
`INSERT INTO ${table} (${keys.join(",")})
|
|
43100
|
+
VALUES (${keys.map(() => "?").join(",")})`,
|
|
43101
|
+
values
|
|
43102
|
+
);
|
|
43103
|
+
return record;
|
|
43104
|
+
},
|
|
43105
|
+
update: async (id, patch) => {
|
|
43106
|
+
const db2 = await getDb();
|
|
43107
|
+
const sets = Object.keys(patch).map((k2) => `${k2} = ?`).join(", ");
|
|
43108
|
+
await db2.execute(
|
|
43109
|
+
`UPDATE ${table} SET ${sets} WHERE id = ?`,
|
|
43110
|
+
[...Object.values(patch), id]
|
|
43111
|
+
);
|
|
43112
|
+
return { id, ...patch };
|
|
43113
|
+
},
|
|
43114
|
+
delete: async (id) => {
|
|
43115
|
+
const db2 = await getDb();
|
|
43116
|
+
await db2.execute(
|
|
43117
|
+
`DELETE FROM ${table} WHERE id = ?`,
|
|
43118
|
+
[id]
|
|
43119
|
+
);
|
|
43120
|
+
},
|
|
43121
|
+
query: async (sql, params = []) => {
|
|
43122
|
+
const db2 = await getDb();
|
|
43123
|
+
return await db2.select(sql, params);
|
|
43124
|
+
},
|
|
43125
|
+
bulkCreate: async (records) => {
|
|
43126
|
+
const db2 = await getDb();
|
|
43127
|
+
for (const r2 of records) {
|
|
43128
|
+
const keys = Object.keys(r2);
|
|
43129
|
+
const values = Object.values(r2);
|
|
43130
|
+
await db2.execute(
|
|
43131
|
+
`INSERT INTO ${table} (${keys.join(",")})
|
|
43132
|
+
VALUES (${keys.map(() => "?").join(",")})`,
|
|
43133
|
+
values
|
|
43134
|
+
);
|
|
43135
|
+
}
|
|
43136
|
+
return records;
|
|
43137
|
+
}
|
|
43138
|
+
};
|
|
43139
|
+
}
|
|
43140
|
+
function createUserEntityApi() {
|
|
43141
|
+
const table = "users";
|
|
43142
|
+
return {
|
|
43143
|
+
list: (o3, l3) => createSQLiteEntity(table).list(o3, l3),
|
|
43144
|
+
get: (id) => createSQLiteEntity(table).get(id),
|
|
43145
|
+
create: (r2) => createSQLiteEntity(table).create(r2),
|
|
43146
|
+
update: (id, p3) => createSQLiteEntity(table).update(id, p3),
|
|
43147
|
+
delete: (id) => createSQLiteEntity(table).delete(id),
|
|
43148
|
+
query: (sql, params) => createSQLiteEntity(table).query(sql, params)
|
|
43149
|
+
};
|
|
43150
|
+
}
|
|
43151
|
+
function createEntityApi(entityApi) {
|
|
43152
|
+
return {
|
|
43153
|
+
list: async (o3, l3) => unwrapList(await entityApi.list(normalizeListArgs(o3, l3))),
|
|
43154
|
+
get: async (id) => unwrapData(await entityApi.get(id)),
|
|
43155
|
+
create: async (r2) => unwrapData(await entityApi.create(r2)),
|
|
43156
|
+
update: async (id, p3) => unwrapData(await entityApi.update(id, p3)),
|
|
43157
|
+
delete: (id) => entityApi.delete(id),
|
|
43158
|
+
query: async (input) => unwrapList(await entityApi.query(input)),
|
|
43159
|
+
bulkCreate: (r2) => entityApi.bulkCreate(r2),
|
|
43160
|
+
bulkUpdate: (r2) => entityApi.bulkUpdate?.(r2),
|
|
43161
|
+
bulkDelete: (r2) => entityApi.bulkDelete?.(r2),
|
|
43162
|
+
import: (r2) => entityApi.import?.(r2)
|
|
43163
|
+
};
|
|
43164
|
+
}
|
|
43165
|
+
var entityRegistry = new Proxy(
|
|
43166
|
+
{},
|
|
43167
|
+
{
|
|
43168
|
+
get(_t2, entity) {
|
|
43169
|
+
if (typeof entity !== "string") return void 0;
|
|
43170
|
+
if (entity === "User") {
|
|
43171
|
+
return createUserEntityApi();
|
|
43172
|
+
}
|
|
43173
|
+
const table = entity.toLowerCase();
|
|
43174
|
+
return createEntityApi(createSQLiteEntity(table));
|
|
43175
|
+
}
|
|
43176
|
+
}
|
|
43177
|
+
);
|
|
43178
|
+
|
|
42645
43179
|
// src/index.js
|
|
42646
43180
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
42647
43181
|
var platformModule = null;
|
|
@@ -42694,6 +43228,41 @@ var Tevroc = (() => {
|
|
|
42694
43228
|
}
|
|
42695
43229
|
return `chat:${encoded}`;
|
|
42696
43230
|
}
|
|
43231
|
+
function createBluetoothSessionApi(client) {
|
|
43232
|
+
let connection = null;
|
|
43233
|
+
let currentEmail = "";
|
|
43234
|
+
return {
|
|
43235
|
+
...createBluetoothApi(),
|
|
43236
|
+
joinAccountRoom: (email, handlers = {}, options = {}) => {
|
|
43237
|
+
const normalizedEmail = String(email || "").trim().toLowerCase();
|
|
43238
|
+
if (!normalizedEmail) throw new TypeError("An account email is required to join the Bluetooth room.");
|
|
43239
|
+
connection?.close?.();
|
|
43240
|
+
currentEmail = normalizedEmail;
|
|
43241
|
+
connection = client.realtime.room(`bluetooth:${normalizedEmail}`, {
|
|
43242
|
+
...handlers,
|
|
43243
|
+
message: (message2, event) => {
|
|
43244
|
+
if (message2?.type === "bluetooth:presence" && message2.email === normalizedEmail) handlers.peer?.(message2, event);
|
|
43245
|
+
handlers.message?.(message2, event);
|
|
43246
|
+
}
|
|
43247
|
+
}, options);
|
|
43248
|
+
return {
|
|
43249
|
+
publish: (payload) => connection.publish({ ...payload, email: normalizedEmail }),
|
|
43250
|
+
send: (payload) => connection.send({ ...payload, email: normalizedEmail }),
|
|
43251
|
+
close: () => {
|
|
43252
|
+
connection?.close?.();
|
|
43253
|
+
connection = null;
|
|
43254
|
+
},
|
|
43255
|
+
room: () => `bluetooth:${normalizedEmail}`
|
|
43256
|
+
};
|
|
43257
|
+
},
|
|
43258
|
+
leaveAccountRoom: () => {
|
|
43259
|
+
connection?.close?.();
|
|
43260
|
+
connection = null;
|
|
43261
|
+
currentEmail = "";
|
|
43262
|
+
},
|
|
43263
|
+
accountRoom: () => currentEmail ? `bluetooth:${currentEmail}` : null
|
|
43264
|
+
};
|
|
43265
|
+
}
|
|
42697
43266
|
function createClient(options = {}) {
|
|
42698
43267
|
return new TevrocClient(options);
|
|
42699
43268
|
}
|
|
@@ -42731,14 +43300,33 @@ var Tevroc = (() => {
|
|
|
42731
43300
|
sendMessage: (conversationId, input) => request(`/chatbot/conversations/${encodeURIComponent(conversationId)}/messages`, { method: "POST", body: input })
|
|
42732
43301
|
};
|
|
42733
43302
|
}
|
|
43303
|
+
function createStorefrontClient(options = {}) {
|
|
43304
|
+
if (!options.apiKey) throw new TevrocError("apiKey is required to create a storefront client");
|
|
43305
|
+
const client = new TevrocClient({
|
|
43306
|
+
...options,
|
|
43307
|
+
appId: void 0,
|
|
43308
|
+
token: null,
|
|
43309
|
+
headers: { ...options.headers || {}, "x-api-key": options.apiKey }
|
|
43310
|
+
});
|
|
43311
|
+
const request = (path, requestOptions = {}) => client.request(path, { ...requestOptions, auth: false });
|
|
43312
|
+
return {
|
|
43313
|
+
getBusiness: () => request("/storefront/business"),
|
|
43314
|
+
listProducts: (query = {}) => request("/storefront/products", { query }),
|
|
43315
|
+
createOrder: (order) => request("/storefront/orders", { method: "POST", body: order })
|
|
43316
|
+
};
|
|
43317
|
+
}
|
|
42734
43318
|
var TevrocClient = class {
|
|
42735
43319
|
constructor(options = {}) {
|
|
42736
43320
|
const baseUrl = options.baseUrl ?? options.url;
|
|
42737
|
-
const serviceUrl = options.serviceUrl ?? options.url;
|
|
43321
|
+
const serviceUrl = options.serviceUrl ?? options.url ?? baseUrl;
|
|
43322
|
+
const vpsUrl = options.vpsUrl ?? serviceUrl;
|
|
42738
43323
|
if (!baseUrl) throw new TypeError("createClient requires a baseUrl");
|
|
42739
43324
|
this.baseUrl = normalizeBaseUrl(baseUrl);
|
|
42740
43325
|
this.serviceUrl = normalizeBaseUrl(serviceUrl);
|
|
43326
|
+
this.vpsUrl = normalizeBaseUrl(vpsUrl);
|
|
43327
|
+
this.vpsConfig = { ...options.vpsConfig || options.config || {} };
|
|
42741
43328
|
this.appId = options.appId;
|
|
43329
|
+
this.appInstance = options.appInstance || null;
|
|
42742
43330
|
this.appName = options.appName;
|
|
42743
43331
|
this.payAccount = options.payAccount ?? "default";
|
|
42744
43332
|
this.fetch = (options.fetch ?? globalThis.fetch).bind(globalThis);
|
|
@@ -42746,11 +43334,14 @@ var Tevroc = (() => {
|
|
|
42746
43334
|
throw new TypeError("No fetch implementation available");
|
|
42747
43335
|
}
|
|
42748
43336
|
this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
43337
|
+
this.axios = options.axios;
|
|
42749
43338
|
this.defaultHeaders = normalizeHeaders(options.headers);
|
|
42750
43339
|
this.token = options.token ?? null;
|
|
42751
43340
|
this.debug = options.debug ?? false;
|
|
42752
43341
|
setSdkDebug(this.debug);
|
|
42753
43342
|
this.auth = createAuthApi(this);
|
|
43343
|
+
this.vps = createVpsApi(this);
|
|
43344
|
+
this.database = this.vps.database;
|
|
42754
43345
|
this.entities = createEntityRegistry(this);
|
|
42755
43346
|
this.functions = createFunctionRegistry(this);
|
|
42756
43347
|
this.integrations = createIntegrationApi(this);
|
|
@@ -42761,10 +43352,13 @@ var Tevroc = (() => {
|
|
|
42761
43352
|
this.sso = createSsoApi(this);
|
|
42762
43353
|
this.files = createFileApi(this);
|
|
42763
43354
|
this.native = {
|
|
43355
|
+
runtime: platform,
|
|
42764
43356
|
store: createNativeStore(this.appId),
|
|
42765
43357
|
files: createNativeFileApi(this.appId),
|
|
42766
43358
|
googleDrive: createGoogleDriveApi(this.appId),
|
|
42767
|
-
projects: createProjectStore(this.appId)
|
|
43359
|
+
projects: createProjectStore(this.appId),
|
|
43360
|
+
bluetooth: null,
|
|
43361
|
+
gps: createGpsApi()
|
|
42768
43362
|
};
|
|
42769
43363
|
this.offline = createOfflineManager(this);
|
|
42770
43364
|
try {
|
|
@@ -42789,6 +43383,7 @@ var Tevroc = (() => {
|
|
|
42789
43383
|
this.payments = createPaymentApi(this);
|
|
42790
43384
|
this.commerce = createCommerceApi(this);
|
|
42791
43385
|
this.realtime = createRealtimeApi(this);
|
|
43386
|
+
this.native.bluetooth = createBluetoothSessionApi(this);
|
|
42792
43387
|
this.notifications = createNotificationService();
|
|
42793
43388
|
this.chatNotifications = createChatNotificationService(this);
|
|
42794
43389
|
this.agentNotifications = createAgentNotificationService(this);
|
|
@@ -42805,9 +43400,21 @@ var Tevroc = (() => {
|
|
|
42805
43400
|
}
|
|
42806
43401
|
return this;
|
|
42807
43402
|
}
|
|
43403
|
+
setAppInstance(appInstance) {
|
|
43404
|
+
this.appInstance = appInstance || null;
|
|
43405
|
+
return this;
|
|
43406
|
+
}
|
|
42808
43407
|
clearToken() {
|
|
42809
43408
|
this.token = null;
|
|
42810
|
-
safeLocalStorage()
|
|
43409
|
+
const storage = safeLocalStorage();
|
|
43410
|
+
[
|
|
43411
|
+
"tevroc_access_token",
|
|
43412
|
+
"base44_access_token",
|
|
43413
|
+
"native_access_token",
|
|
43414
|
+
"token",
|
|
43415
|
+
"idToken",
|
|
43416
|
+
"user"
|
|
43417
|
+
].forEach((key) => storage?.removeItem(key));
|
|
42811
43418
|
return this;
|
|
42812
43419
|
}
|
|
42813
43420
|
setDebug(enabled) {
|
|
@@ -42819,7 +43426,8 @@ var Tevroc = (() => {
|
|
|
42819
43426
|
const method = (options.method ?? "GET").toUpperCase();
|
|
42820
43427
|
const headers = new Headers(this.defaultHeaders);
|
|
42821
43428
|
const query = options.query ? toSearchParams(options.query) : "";
|
|
42822
|
-
const
|
|
43429
|
+
const requestBaseUrl = options.baseUrl ?? this.baseUrl;
|
|
43430
|
+
const url = `${requestBaseUrl}${path.startsWith("/") ? path : `/${path}`}${query}`;
|
|
42823
43431
|
const controller = new AbortController();
|
|
42824
43432
|
const timeoutMsActual = options.timeoutMs || this.timeoutMs || 2500;
|
|
42825
43433
|
let timeout = null;
|
|
@@ -42828,7 +43436,9 @@ var Tevroc = (() => {
|
|
|
42828
43436
|
if (token && options.auth !== false) {
|
|
42829
43437
|
headers.set("authorization", `Bearer ${token}`);
|
|
42830
43438
|
}
|
|
42831
|
-
if (this.
|
|
43439
|
+
if (this.appInstance && String(path).startsWith("/entities/")) {
|
|
43440
|
+
headers.set("x-app-instance", this.appInstance);
|
|
43441
|
+
} else if (this.appId && !this.appInstance) {
|
|
42832
43442
|
headers.set("x-app-id", this.appId);
|
|
42833
43443
|
}
|
|
42834
43444
|
let body = options.body;
|
|
@@ -42860,13 +43470,23 @@ var Tevroc = (() => {
|
|
|
42860
43470
|
debugWarn2(this, "[tevrocsdk] pending sync failed", err2);
|
|
42861
43471
|
}
|
|
42862
43472
|
}
|
|
42863
|
-
let
|
|
42864
|
-
|
|
42865
|
-
|
|
42866
|
-
|
|
42867
|
-
|
|
42868
|
-
|
|
42869
|
-
|
|
43473
|
+
let requestPromise;
|
|
43474
|
+
if (this.axios?.request) {
|
|
43475
|
+
requestPromise = this.axios.request({
|
|
43476
|
+
url,
|
|
43477
|
+
method,
|
|
43478
|
+
headers: Object.fromEntries(headers.entries()),
|
|
43479
|
+
data: body,
|
|
43480
|
+
signal: options.signal ?? controller.signal
|
|
43481
|
+
}).then((response) => parseAxiosResponse(response, options.parseAs));
|
|
43482
|
+
} else {
|
|
43483
|
+
requestPromise = this.fetch(url, {
|
|
43484
|
+
method,
|
|
43485
|
+
headers,
|
|
43486
|
+
body,
|
|
43487
|
+
signal: options.signal ?? controller.signal
|
|
43488
|
+
}).then((response) => parseResponse(response, options.parseAs));
|
|
43489
|
+
}
|
|
42870
43490
|
const timeoutPromise = new Promise((_3, reject) => {
|
|
42871
43491
|
timeout = setTimeout(() => {
|
|
42872
43492
|
try {
|
|
@@ -42876,8 +43496,7 @@ var Tevroc = (() => {
|
|
|
42876
43496
|
reject(new TevrocError("Request timed out", { code: "timeout" }));
|
|
42877
43497
|
}, timeoutMsActual);
|
|
42878
43498
|
});
|
|
42879
|
-
|
|
42880
|
-
let ret = await parseResponse(response, options.parseAs);
|
|
43499
|
+
let ret = await Promise.race([requestPromise, timeoutPromise]);
|
|
42881
43500
|
debugLog2(this, "Response from request:", ret);
|
|
42882
43501
|
return ret;
|
|
42883
43502
|
} catch (error) {
|
|
@@ -42890,6 +43509,67 @@ var Tevroc = (() => {
|
|
|
42890
43509
|
}
|
|
42891
43510
|
}
|
|
42892
43511
|
};
|
|
43512
|
+
function createVpsApi(client) {
|
|
43513
|
+
const request = (path, options = {}) => client.request(path, { ...options, baseUrl: client.vpsUrl });
|
|
43514
|
+
const withSession = (session, query = {}) => ({
|
|
43515
|
+
...query,
|
|
43516
|
+
session: session ?? client.vpsConfig.session
|
|
43517
|
+
});
|
|
43518
|
+
const encodeSql = (sql) => {
|
|
43519
|
+
if (typeof sql !== "string" || !sql.trim()) throw new TypeError("sql must be a non-empty string");
|
|
43520
|
+
if (typeof btoa === "function") return btoa(unescape(encodeURIComponent(sql)));
|
|
43521
|
+
return Buffer.from(sql, "utf8").toString("base64");
|
|
43522
|
+
};
|
|
43523
|
+
const database = {
|
|
43524
|
+
dialect: () => request("/database/sql", { auth: false }),
|
|
43525
|
+
tables: (options = {}) => request("/database/tables", { query: withSession(options.session, options), auth: false }),
|
|
43526
|
+
table: (table, options = {}) => request("/database/table", {
|
|
43527
|
+
query: withSession(options.session, { ...options, table }),
|
|
43528
|
+
auth: false
|
|
43529
|
+
}),
|
|
43530
|
+
exec: (sql, options = {}) => request("/database/query/exec", {
|
|
43531
|
+
query: withSession(options.session, { ...options, query: encodeSql(sql) }),
|
|
43532
|
+
auth: false
|
|
43533
|
+
}),
|
|
43534
|
+
query: (sql, options = {}) => database.exec(sql, options)
|
|
43535
|
+
};
|
|
43536
|
+
const auth = {
|
|
43537
|
+
login: async (email, password, options = {}) => {
|
|
43538
|
+
const result = await request("/login", { query: { ...options, email, password }, auth: false });
|
|
43539
|
+
if (result?.session) client.setToken(result.session);
|
|
43540
|
+
return result;
|
|
43541
|
+
},
|
|
43542
|
+
verifyOtp: async (email, otp, options = {}) => {
|
|
43543
|
+
const result = await request("/auth-otp", { query: { ...options, email, otp }, auth: false });
|
|
43544
|
+
if (result?.session) client.setToken(result.session);
|
|
43545
|
+
return result;
|
|
43546
|
+
},
|
|
43547
|
+
register: (input, options = {}) => request(options.path || "/auth/register", { method: "POST", body: input, auth: false }),
|
|
43548
|
+
resetPassword: (input, options = {}) => request(options.path || "/auth/reset-password", { method: "POST", body: input, auth: false }),
|
|
43549
|
+
changePassword: (input, options = {}) => request(options.path || "/auth/change-password", { method: "POST", body: input }),
|
|
43550
|
+
session: (session = client.token, options = {}) => request("/session", { query: withSession(session, options), auth: false }),
|
|
43551
|
+
userType: (session = client.token, options = {}) => request("/get-usertype", { query: withSession(session, options), auth: false }),
|
|
43552
|
+
user: (session = client.token, options = {}) => request("/get-user", { query: withSession(session, options), auth: false }),
|
|
43553
|
+
hasOnboarded: (session = client.token, options = {}) => request("/has-onboarded", { query: withSession(session, options), auth: false }),
|
|
43554
|
+
hasVerified: (session = client.token, options = {}) => request("/has-verified", { query: withSession(session, options), auth: false }),
|
|
43555
|
+
updateProfile: (session, data, options = {}) => request("/update-profile", { query: withSession(session, { ...options, jsonObject: JSON.stringify(data) }), auth: false }),
|
|
43556
|
+
updateOnboarding: (session, data, options = {}) => request("/update-onboarding", { query: withSession(session, { ...options, jsonObject: JSON.stringify(data) }), auth: false }),
|
|
43557
|
+
logout: () => {
|
|
43558
|
+
client.clearToken();
|
|
43559
|
+
return Promise.resolve({ ok: true });
|
|
43560
|
+
}
|
|
43561
|
+
};
|
|
43562
|
+
return {
|
|
43563
|
+
request,
|
|
43564
|
+
auth,
|
|
43565
|
+
database,
|
|
43566
|
+
environment: () => request("/api/environment", { auth: false }),
|
|
43567
|
+
platform: () => request("/platform", { auth: false }),
|
|
43568
|
+
notifications: (options = {}) => request("/api/notifications", { query: options, auth: false }),
|
|
43569
|
+
accountContext: (session = client.token, options = {}) => request("/api/mobile/account-context", { query: withSession(session, options), auth: false }),
|
|
43570
|
+
avatarUrl: (options = {}) => `${client.vpsUrl}/api/avatar${toSearchParams(options)}`
|
|
43571
|
+
};
|
|
43572
|
+
}
|
|
42893
43573
|
function createShiplogicApi(client) {
|
|
42894
43574
|
return {
|
|
42895
43575
|
getRates: (payload = {}) => client.request("/shiplogic/rates", { method: "POST", body: payload }),
|
|
@@ -43042,11 +43722,11 @@ var Tevroc = (() => {
|
|
|
43042
43722
|
}
|
|
43043
43723
|
function createPlatformApi(client) {
|
|
43044
43724
|
return (async function() {
|
|
43045
|
-
const { isNative: isNative2, isCapacitor: isCapacitor2, isTauri:
|
|
43725
|
+
const { isNative: isNative2, isCapacitor: isCapacitor2, isTauri: isTauri3, platform: platform2 } = await getPlatformModule();
|
|
43046
43726
|
return {
|
|
43047
43727
|
platform: platform2,
|
|
43048
43728
|
isCapacitor: isCapacitor2,
|
|
43049
|
-
isTauri:
|
|
43729
|
+
isTauri: isTauri3,
|
|
43050
43730
|
isNative: isNative2
|
|
43051
43731
|
};
|
|
43052
43732
|
})();
|
|
@@ -43065,6 +43745,15 @@ var Tevroc = (() => {
|
|
|
43065
43745
|
createCheckout: async (payload = {}) => {
|
|
43066
43746
|
return await client.request("/create-checkout", { method: "POST", body: payload, auth: false });
|
|
43067
43747
|
},
|
|
43748
|
+
createStorefrontCheckout: async (payload = {}) => {
|
|
43749
|
+
const serviceBaseUrl = `${client.serviceUrl.replace(/\/$/, "")}/.netlify/functions/api`;
|
|
43750
|
+
return await client.request("/yoco/storefront-pay", {
|
|
43751
|
+
method: "POST",
|
|
43752
|
+
body: payload,
|
|
43753
|
+
auth: false,
|
|
43754
|
+
baseUrl: serviceBaseUrl
|
|
43755
|
+
});
|
|
43756
|
+
},
|
|
43068
43757
|
onstatus: (callback) => {
|
|
43069
43758
|
if (typeof callback !== "function") {
|
|
43070
43759
|
throw new Error("onstatus requires a function");
|
|
@@ -43083,8 +43772,8 @@ var Tevroc = (() => {
|
|
|
43083
43772
|
},
|
|
43084
43773
|
// base44
|
|
43085
43774
|
loginWithProvider: async (provider, redirectTo, setToken = async () => {
|
|
43086
|
-
}) => {
|
|
43087
|
-
|
|
43775
|
+
}, authInput = {}) => {
|
|
43776
|
+
debugLog2(client, "loginWithProvider called", { provider, redirectTo });
|
|
43088
43777
|
if (provider === "google") {
|
|
43089
43778
|
const { createGoogleLogin: createGoogleLogin2, subscribeGoogleLogin: subscribeGoogleLogin2 } = await getGoogleModule();
|
|
43090
43779
|
debugLog2(client, {
|
|
@@ -43092,11 +43781,6 @@ var Tevroc = (() => {
|
|
|
43092
43781
|
appId: client.appId,
|
|
43093
43782
|
appName: client.appName
|
|
43094
43783
|
});
|
|
43095
|
-
await createGoogleLogin2({
|
|
43096
|
-
serviceUrl: client.serviceUrl,
|
|
43097
|
-
appId: client.appId,
|
|
43098
|
-
appName: client.appName
|
|
43099
|
-
});
|
|
43100
43784
|
if (redirectTo) {
|
|
43101
43785
|
const unsub = subscribeGoogleLogin2(async (user, err2) => {
|
|
43102
43786
|
debugLog2(client, "Google callback:", user, err2);
|
|
@@ -43104,7 +43788,7 @@ var Tevroc = (() => {
|
|
|
43104
43788
|
if (!user) return;
|
|
43105
43789
|
const result = await client.request("/auth/google", {
|
|
43106
43790
|
method: "POST",
|
|
43107
|
-
body: buildAuthPayload({ accessToken: user.accessToken }, client),
|
|
43791
|
+
body: buildAuthPayload({ ...authInput, accessToken: user.accessToken }, client),
|
|
43108
43792
|
auth: false
|
|
43109
43793
|
});
|
|
43110
43794
|
debugLog2(client, result);
|
|
@@ -43112,6 +43796,22 @@ var Tevroc = (() => {
|
|
|
43112
43796
|
debugLog2(client, "Redirecting to:", redirectTo);
|
|
43113
43797
|
window.location.href = redirectTo;
|
|
43114
43798
|
});
|
|
43799
|
+
try {
|
|
43800
|
+
await createGoogleLogin2({
|
|
43801
|
+
serviceUrl: client.serviceUrl,
|
|
43802
|
+
appId: client.appId,
|
|
43803
|
+
appName: client.appName
|
|
43804
|
+
});
|
|
43805
|
+
} catch (error) {
|
|
43806
|
+
unsub();
|
|
43807
|
+
throw error;
|
|
43808
|
+
}
|
|
43809
|
+
} else {
|
|
43810
|
+
await createGoogleLogin2({
|
|
43811
|
+
serviceUrl: client.serviceUrl,
|
|
43812
|
+
appId: client.appId,
|
|
43813
|
+
appName: client.appName
|
|
43814
|
+
});
|
|
43115
43815
|
}
|
|
43116
43816
|
}
|
|
43117
43817
|
if (provider === "facebook") {
|
|
@@ -43128,7 +43828,7 @@ var Tevroc = (() => {
|
|
|
43128
43828
|
if (!user) return;
|
|
43129
43829
|
const result = await client.request("/auth/facebook", {
|
|
43130
43830
|
method: "POST",
|
|
43131
|
-
body: buildAuthPayload({ accessToken: user.accessToken }, client),
|
|
43831
|
+
body: buildAuthPayload({ ...authInput, accessToken: user.accessToken }, client),
|
|
43132
43832
|
auth: false
|
|
43133
43833
|
});
|
|
43134
43834
|
debugLog2(client, result);
|
|
@@ -43168,7 +43868,7 @@ var Tevroc = (() => {
|
|
|
43168
43868
|
if (!user) return;
|
|
43169
43869
|
const result = await client.request("/auth/meta", {
|
|
43170
43870
|
method: "POST",
|
|
43171
|
-
body: buildAuthPayload({ accessToken: user.accessToken }, client),
|
|
43871
|
+
body: buildAuthPayload({ ...authInput, accessToken: user.accessToken }, client),
|
|
43172
43872
|
auth: false
|
|
43173
43873
|
});
|
|
43174
43874
|
debugLog2(client, result);
|
|
@@ -43243,9 +43943,11 @@ var Tevroc = (() => {
|
|
|
43243
43943
|
return result;
|
|
43244
43944
|
},
|
|
43245
43945
|
async logout() {
|
|
43246
|
-
|
|
43247
|
-
|
|
43248
|
-
|
|
43946
|
+
try {
|
|
43947
|
+
return await client.request("/auth/logout", { method: "POST", body: buildAuthPayload({}, client) });
|
|
43948
|
+
} finally {
|
|
43949
|
+
client.clearToken();
|
|
43950
|
+
}
|
|
43249
43951
|
},
|
|
43250
43952
|
inviteUser: (input) => client.request("/users/invite", { method: "POST", body: buildAuthPayload(input, client) }),
|
|
43251
43953
|
acceptInvite: (input) => client.request("/auth/accept-invite", { method: "POST", body: buildAuthPayload(input, client), auth: false }),
|
|
@@ -43290,12 +43992,12 @@ var Tevroc = (() => {
|
|
|
43290
43992
|
{
|
|
43291
43993
|
get(_target, entity) {
|
|
43292
43994
|
if (typeof entity !== "string") return void 0;
|
|
43293
|
-
return
|
|
43995
|
+
return createEntityApi2(client, entity);
|
|
43294
43996
|
}
|
|
43295
43997
|
}
|
|
43296
43998
|
);
|
|
43297
43999
|
}
|
|
43298
|
-
function
|
|
44000
|
+
function createEntityApi2(client, entity) {
|
|
43299
44001
|
const base = `/entities/${encodeURIComponent(entity)}`;
|
|
43300
44002
|
async function cacheEntityRecord(record) {
|
|
43301
44003
|
if (!client.native?.store || !isNative || !record || typeof record !== "object" || !record.id) return;
|
|
@@ -43554,6 +44256,7 @@ var Tevroc = (() => {
|
|
|
43554
44256
|
},
|
|
43555
44257
|
{
|
|
43556
44258
|
get(target, name) {
|
|
44259
|
+
if (name === "toJSON") return void 0;
|
|
43557
44260
|
if (name in target) return target[name];
|
|
43558
44261
|
if (typeof name !== "string") return void 0;
|
|
43559
44262
|
return (payload) => target.invoke(name, payload);
|
|
@@ -43781,10 +44484,10 @@ var Tevroc = (() => {
|
|
|
43781
44484
|
async function readCachedFileResponse(client, key) {
|
|
43782
44485
|
if (!client.native?.store || !isNative) return null;
|
|
43783
44486
|
const cached = (await client.native.store.get(`downloaded_files/${key}`)).val();
|
|
43784
|
-
|
|
44487
|
+
debugLog2(client, "[tevrocsdk][files] readCachedFileResponse", { key, hasCached: !!cached?.data });
|
|
43785
44488
|
if (!cached?.data) return null;
|
|
43786
44489
|
const blob = base64ToBlob(cached.data, cached.contentType || "application/octet-stream");
|
|
43787
|
-
|
|
44490
|
+
debugLog2(client, "[tevrocsdk][files] readCachedFileResponse built blob", { key, size: blob && blob.size });
|
|
43788
44491
|
return new Response(blob, {
|
|
43789
44492
|
headers: { "content-type": cached.contentType || "application/octet-stream" }
|
|
43790
44493
|
});
|
|
@@ -43792,14 +44495,14 @@ var Tevroc = (() => {
|
|
|
43792
44495
|
async function storeCachedFileResponse(client, key, response, fallbackContentType = "application/octet-stream") {
|
|
43793
44496
|
if (!client.native?.store || !isNative || !key) return;
|
|
43794
44497
|
try {
|
|
43795
|
-
|
|
44498
|
+
debugLog2(client, "[tevrocsdk][files] storeCachedFileResponse", { key });
|
|
43796
44499
|
const clone2 = response instanceof Response ? response.clone() : null;
|
|
43797
44500
|
const blob = clone2 ? await clone2.blob() : null;
|
|
43798
44501
|
const contentType = clone2 && clone2.headers.get("content-type") || fallbackContentType;
|
|
43799
44502
|
const data = blob ? await blobToBase643(blob) : "";
|
|
43800
|
-
|
|
44503
|
+
debugLog2(client, "[tevrocsdk][files] storeCachedFileResponse data length", { key, length: data ? data.length : 0, contentType });
|
|
43801
44504
|
if (!data) {
|
|
43802
|
-
|
|
44505
|
+
debugWarn2(client, "[tevrocsdk][files] storeCachedFileResponse no data to store", { key });
|
|
43803
44506
|
return;
|
|
43804
44507
|
}
|
|
43805
44508
|
await client.native.store.set(`downloaded_files/${key}`, {
|
|
@@ -43808,18 +44511,18 @@ var Tevroc = (() => {
|
|
|
43808
44511
|
key,
|
|
43809
44512
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
43810
44513
|
});
|
|
43811
|
-
|
|
44514
|
+
debugLog2(client, "[tevrocsdk][files] storeCachedFileResponse stored", { key });
|
|
43812
44515
|
} catch (error) {
|
|
43813
44516
|
debugWarn2(client, "Failed to cache downloaded file", error);
|
|
43814
|
-
|
|
44517
|
+
debugWarn2(client, "[tevrocsdk][files] storeCachedFileResponse error", error);
|
|
43815
44518
|
}
|
|
43816
44519
|
}
|
|
43817
44520
|
async function readCachedFileDataUrl(client, key) {
|
|
43818
44521
|
if (!client.native?.store || !isNative || !key) return null;
|
|
43819
44522
|
const cached = (await client.native.store.get(`downloaded_files/${key}`)).val();
|
|
43820
|
-
|
|
44523
|
+
debugLog2(client, "[tevrocsdk][files] readCachedFileDataUrl", { key, hasCached: !!cached?.data });
|
|
43821
44524
|
if (!cached?.data) return null;
|
|
43822
|
-
|
|
44525
|
+
debugLog2(client, "[tevrocsdk][files] readCachedFileDataUrl returning data url", { key, length: cached.data.length });
|
|
43823
44526
|
return `data:${cached.contentType || "application/octet-stream"};base64,${cached.data}`;
|
|
43824
44527
|
}
|
|
43825
44528
|
function base64ToBlob(base64, contentType = "application/octet-stream") {
|
|
@@ -43833,29 +44536,6 @@ var Tevroc = (() => {
|
|
|
43833
44536
|
}
|
|
43834
44537
|
return new Blob([bytes], { type: contentType });
|
|
43835
44538
|
}
|
|
43836
|
-
function arrayBufferToBase64(buffer) {
|
|
43837
|
-
let binary = "";
|
|
43838
|
-
const bytes = new Uint8Array(buffer);
|
|
43839
|
-
const chunkSize = 32768;
|
|
43840
|
-
for (let i4 = 0; i4 < bytes.length; i4 += chunkSize) {
|
|
43841
|
-
const chunk = bytes.subarray(i4, i4 + chunkSize);
|
|
43842
|
-
binary += String.fromCharCode.apply(null, chunk);
|
|
43843
|
-
}
|
|
43844
|
-
return btoa(binary);
|
|
43845
|
-
}
|
|
43846
|
-
async function normalizeUploadBody(file) {
|
|
43847
|
-
if (typeof Blob !== "undefined" && file instanceof Blob) {
|
|
43848
|
-
return { data: await blobToBase643(file), contentType: file.type || "application/octet-stream", bodyIsBase64: true };
|
|
43849
|
-
}
|
|
43850
|
-
if (file && typeof file.arrayBuffer === "function") {
|
|
43851
|
-
const buffer = await file.arrayBuffer();
|
|
43852
|
-
return { data: arrayBufferToBase64(buffer), contentType: "application/octet-stream", bodyIsBase64: true };
|
|
43853
|
-
}
|
|
43854
|
-
if (typeof file === "string") {
|
|
43855
|
-
return { data: file, contentType: "text/plain", bodyIsBase64: false };
|
|
43856
|
-
}
|
|
43857
|
-
return { data: JSON.stringify(file), contentType: "application/json", bodyIsBase64: false };
|
|
43858
|
-
}
|
|
43859
44539
|
function createFileApi(client) {
|
|
43860
44540
|
return {
|
|
43861
44541
|
url: async (key) => {
|
|
@@ -43874,7 +44554,7 @@ var Tevroc = (() => {
|
|
|
43874
44554
|
}
|
|
43875
44555
|
rounds += 1;
|
|
43876
44556
|
} while (rawKey !== prev && rawKey.includes("%25") && rounds < 5);
|
|
43877
|
-
if (rounds > 0)
|
|
44557
|
+
if (rounds > 0) debugLog2(client, "[tevrocsdk][files] iterative decode performed", { original: key, rawKey, rounds });
|
|
43878
44558
|
} catch (e2) {
|
|
43879
44559
|
}
|
|
43880
44560
|
debugLog2(client, "[tevrocsdk][files:url]", { key, rawKey, online, offline, isNative });
|
|
@@ -43904,7 +44584,7 @@ var Tevroc = (() => {
|
|
|
43904
44584
|
}
|
|
43905
44585
|
rounds += 1;
|
|
43906
44586
|
} while (rawKey !== prev && rawKey.includes("%25") && rounds < 5);
|
|
43907
|
-
if (rounds > 0)
|
|
44587
|
+
if (rounds > 0) debugLog2(client, "[tevrocsdk][files] iterative decode performed (privateUrl)", { original: key, rawKey, rounds });
|
|
43908
44588
|
} catch (e2) {
|
|
43909
44589
|
}
|
|
43910
44590
|
debugLog2(client, "[tevrocsdk][files:privateUrl]", { key, rawKey, online, offline, isNative });
|
|
@@ -43944,7 +44624,7 @@ var Tevroc = (() => {
|
|
|
43944
44624
|
}
|
|
43945
44625
|
rounds += 1;
|
|
43946
44626
|
} while (rawKey !== prev && rawKey.includes("%25") && rounds < 5);
|
|
43947
|
-
if (rounds > 0)
|
|
44627
|
+
if (rounds > 0) debugLog2(client, "[tevrocsdk][files] iterative decode performed (get)", { original: key, rawKey, rounds });
|
|
43948
44628
|
} catch (e2) {
|
|
43949
44629
|
}
|
|
43950
44630
|
debugLog2(client, "[tevrocsdk][files] get", { key, rawKey, isNative, online, offline });
|
|
@@ -43974,7 +44654,7 @@ var Tevroc = (() => {
|
|
|
43974
44654
|
}
|
|
43975
44655
|
rounds += 1;
|
|
43976
44656
|
} while (rawKey !== prev && rawKey.includes("%25") && rounds < 5);
|
|
43977
|
-
if (rounds > 0)
|
|
44657
|
+
if (rounds > 0) debugLog2(client, "[tevrocsdk][files] iterative decode performed (getPrivate)", { original: key, rawKey, rounds });
|
|
43978
44658
|
} catch (e2) {
|
|
43979
44659
|
}
|
|
43980
44660
|
debugLog2(client, "[tevrocsdk][files] getPrivate", { key, rawKey, isNative, online, offline });
|
|
@@ -43991,34 +44671,191 @@ var Tevroc = (() => {
|
|
|
43991
44671
|
};
|
|
43992
44672
|
}
|
|
43993
44673
|
async function upload(client, path, file, options = {}) {
|
|
43994
|
-
const
|
|
43995
|
-
if (
|
|
43996
|
-
|
|
43997
|
-
|
|
43998
|
-
|
|
43999
|
-
|
|
44000
|
-
|
|
44001
|
-
|
|
44002
|
-
|
|
44003
|
-
|
|
44674
|
+
const isElectron = await detectElectronEnvironment(client);
|
|
44675
|
+
if (isElectron) {
|
|
44676
|
+
return uploadViaElectronBridge(client, file, options);
|
|
44677
|
+
}
|
|
44678
|
+
return uploadViaGoogleStorage(client, file, { ...options, path });
|
|
44679
|
+
}
|
|
44680
|
+
async function detectElectronEnvironment(client) {
|
|
44681
|
+
try {
|
|
44682
|
+
const serviceUrl = String(client?.serviceUrl || "").replace(/\/$/, "");
|
|
44683
|
+
const response = await client.fetch(`${serviceUrl}/api/environment`, {
|
|
44684
|
+
method: "GET",
|
|
44685
|
+
headers: { Accept: "application/json" },
|
|
44686
|
+
cache: "no-store"
|
|
44687
|
+
});
|
|
44688
|
+
if (response && response.ok) {
|
|
44689
|
+
const data = await response.json();
|
|
44690
|
+
if (data && typeof data === "object" && "isElectron" in data) {
|
|
44691
|
+
return Boolean(data.isElectron);
|
|
44692
|
+
}
|
|
44693
|
+
}
|
|
44694
|
+
} catch (error) {
|
|
44695
|
+
debugLog2(client, "[tevrocsdk][env] /api/environment fallback", error);
|
|
44696
|
+
}
|
|
44697
|
+
if (typeof navigator !== "undefined") {
|
|
44698
|
+
const userAgent = navigator.userAgent || "";
|
|
44699
|
+
if (/electron/i.test(userAgent)) return true;
|
|
44700
|
+
}
|
|
44701
|
+
if (typeof window !== "undefined") {
|
|
44702
|
+
const bridge = window?.bridge || window?.electronBridge || window?.nativeBridge;
|
|
44703
|
+
if (bridge) return true;
|
|
44704
|
+
if (window.process && window.process.versions && window.process.versions.electron) return true;
|
|
44705
|
+
}
|
|
44706
|
+
return false;
|
|
44707
|
+
}
|
|
44708
|
+
async function uploadViaElectronBridge(client, file, options = {}) {
|
|
44709
|
+
const fileName = options.filename || "upload";
|
|
44710
|
+
const contentType = options.contentType || "application/octet-stream";
|
|
44711
|
+
const resolvedFile = file instanceof Blob ? file : new Blob([String(file ?? "")], { type: contentType });
|
|
44712
|
+
const dataUrl = resolvedFile instanceof Blob ? `data:${contentType};base64,${await blobToBase643(resolvedFile)}` : String(file);
|
|
44713
|
+
const packetSize = options.packetSize || 1024 * 1024;
|
|
44714
|
+
const packets = [];
|
|
44715
|
+
for (let offset2 = 0; offset2 < dataUrl.length; offset2 += packetSize) {
|
|
44716
|
+
const packetData2 = dataUrl.slice(offset2, offset2 + packetSize);
|
|
44717
|
+
packets.push({
|
|
44718
|
+
packetId: packets.length,
|
|
44719
|
+
packetData: encodeURIComponent(packetData2),
|
|
44720
|
+
isLastPacket: offset2 + packetSize >= dataUrl.length,
|
|
44721
|
+
filePanaroma: options.filePanaroma || "NO"
|
|
44722
|
+
});
|
|
44723
|
+
}
|
|
44724
|
+
if (!packets.length) throw new TevrocError("Cannot upload an empty file", { code: "empty_file" });
|
|
44725
|
+
let clientId = "";
|
|
44726
|
+
const endpoint = `${client.serviceUrl.replace(/\/$/, "")}/receivePacket`;
|
|
44727
|
+
for (const packet of packets) {
|
|
44728
|
+
const payload = {
|
|
44729
|
+
...packet,
|
|
44730
|
+
clientId,
|
|
44731
|
+
tableName: options.tableName || "",
|
|
44732
|
+
tableIdx: options.tableIdx ?? "",
|
|
44733
|
+
tableGallery: options.gallery === true || options.gallery === "YES",
|
|
44734
|
+
fileName,
|
|
44735
|
+
fileSize: resolvedFile.size,
|
|
44736
|
+
fileMime: contentType,
|
|
44737
|
+
server: options.server || "test",
|
|
44738
|
+
session: options.session || client.token || ""
|
|
44739
|
+
};
|
|
44740
|
+
let result;
|
|
44741
|
+
const bridge = typeof window !== "undefined" ? window : null;
|
|
44742
|
+
if (bridge && typeof bridge.syncRequest === "function") {
|
|
44743
|
+
const rawResult = bridge.syncRequest(endpoint, "POST", payload);
|
|
44744
|
+
if (!rawResult) throw new TevrocError("Electron upload failed", { code: "electron_upload_failed" });
|
|
44745
|
+
try {
|
|
44746
|
+
result = JSON.parse(rawResult);
|
|
44747
|
+
} catch (error) {
|
|
44748
|
+
throw new TevrocError("Electron upload returned invalid JSON", { code: "electron_upload_failed" });
|
|
44749
|
+
}
|
|
44750
|
+
} else {
|
|
44751
|
+
const response = await client.fetch(endpoint, {
|
|
44004
44752
|
method: "POST",
|
|
44005
|
-
headers,
|
|
44006
|
-
body:
|
|
44007
|
-
|
|
44008
|
-
|
|
44009
|
-
|
|
44010
|
-
|
|
44011
|
-
}
|
|
44012
|
-
|
|
44013
|
-
|
|
44014
|
-
|
|
44753
|
+
headers: { "Content-Type": "application/json", Accept: "application/json" },
|
|
44754
|
+
body: JSON.stringify(payload)
|
|
44755
|
+
});
|
|
44756
|
+
if (!response.ok) {
|
|
44757
|
+
const text2 = await response.text();
|
|
44758
|
+
throw new TevrocError(text2 || "Electron upload failed", { status: response.status, code: "electron_upload_failed" });
|
|
44759
|
+
}
|
|
44760
|
+
result = await response.json();
|
|
44761
|
+
}
|
|
44762
|
+
clientId = result.clientId || clientId;
|
|
44763
|
+
if (typeof options.onProgress === "function") {
|
|
44764
|
+
options.onProgress({ uploaded: Math.min(offset + packetData.length, dataUrl.length), total: dataUrl.length, progress: Math.round((offset + packetData.length) / dataUrl.length * 100) });
|
|
44015
44765
|
}
|
|
44016
44766
|
}
|
|
44017
|
-
|
|
44018
|
-
|
|
44767
|
+
return { success: true, clientId, fileName, fileSize: resolvedFile.size, runtime: "electron" };
|
|
44768
|
+
}
|
|
44769
|
+
async function uploadViaGoogleStorage(client, file, options = {}) {
|
|
44770
|
+
const contentType = options.contentType || "application/octet-stream";
|
|
44771
|
+
const fileName = options.filename || "upload";
|
|
44772
|
+
const body = file instanceof Blob ? file : new Blob([String(file ?? "")], { type: contentType });
|
|
44773
|
+
const serviceUrl = client.serviceUrl.replace(/\/$/, "");
|
|
44774
|
+
const initResponse = await client.fetch(`${serviceUrl}/api/uploads/create`, {
|
|
44775
|
+
method: "POST",
|
|
44776
|
+
headers: {
|
|
44777
|
+
"Content-Type": "application/json",
|
|
44778
|
+
Accept: "application/json"
|
|
44779
|
+
},
|
|
44780
|
+
body: JSON.stringify({
|
|
44781
|
+
filename: fileName,
|
|
44782
|
+
contentType,
|
|
44783
|
+
size: body.size,
|
|
44784
|
+
userId: options.userId || "anon"
|
|
44785
|
+
})
|
|
44786
|
+
});
|
|
44787
|
+
if (!initResponse.ok) {
|
|
44788
|
+
const text2 = await initResponse.text();
|
|
44789
|
+
throw new TevrocError(text2 || "Create upload session failed", { status: initResponse.status, code: "gcs_create_failed" });
|
|
44790
|
+
}
|
|
44791
|
+
const init = await initResponse.json();
|
|
44792
|
+
const uploadUrl = init && init.uploadUrl ? init.uploadUrl : null;
|
|
44793
|
+
const uploadId = init && init.uploadId ? init.uploadId : null;
|
|
44794
|
+
if (!uploadUrl || !uploadId) {
|
|
44795
|
+
throw new TevrocError("Google storage upload session is missing uploadUrl or uploadId", { code: "gcs_invalid_session" });
|
|
44796
|
+
}
|
|
44797
|
+
const chunkSize = options.chunkSize || 10 * 1024 * 1024;
|
|
44798
|
+
for (let offset2 = 0; offset2 < body.size; offset2 += chunkSize) {
|
|
44799
|
+
const end = Math.min(offset2 + chunkSize, body.size) - 1;
|
|
44800
|
+
let uploadResponse;
|
|
44801
|
+
for (let attempt = 1; attempt <= (options.retries || 5); attempt += 1) {
|
|
44802
|
+
try {
|
|
44803
|
+
uploadResponse = await client.fetch(uploadUrl, {
|
|
44804
|
+
method: "PUT",
|
|
44805
|
+
body: body.slice(offset2, end + 1),
|
|
44806
|
+
headers: {
|
|
44807
|
+
"Content-Length": String(end - offset2 + 1),
|
|
44808
|
+
"Content-Range": `bytes ${offset2}-${end}/${body.size}`,
|
|
44809
|
+
"Content-Type": contentType
|
|
44810
|
+
}
|
|
44811
|
+
});
|
|
44812
|
+
if (uploadResponse.ok || uploadResponse.status === 308) break;
|
|
44813
|
+
throw new Error(`HTTP ${uploadResponse.status}`);
|
|
44814
|
+
} catch (error) {
|
|
44815
|
+
if (attempt === (options.retries || 5)) throw new TevrocError(error.message, { code: "gcs_upload_failed" });
|
|
44816
|
+
await new Promise((resolve3) => setTimeout(resolve3, 1e3 * attempt));
|
|
44817
|
+
}
|
|
44818
|
+
}
|
|
44819
|
+
if (!uploadResponse || !uploadResponse.ok && uploadResponse.status !== 308) {
|
|
44820
|
+
throw new TevrocError("Google storage upload failed", { code: "gcs_upload_failed" });
|
|
44821
|
+
}
|
|
44822
|
+
if (typeof options.onProgress === "function") options.onProgress({ uploaded: end + 1, total: body.size, progress: Math.round((end + 1) / body.size * 100) });
|
|
44019
44823
|
}
|
|
44020
|
-
const
|
|
44021
|
-
|
|
44824
|
+
const finalizeResponse = await client.fetch(`${serviceUrl}/api/uploads/${encodeURIComponent(uploadId)}/complete`, {
|
|
44825
|
+
method: "POST",
|
|
44826
|
+
headers: { "Content-Type": "application/json", Accept: "application/json" },
|
|
44827
|
+
body: JSON.stringify({ storageKey: init.storageKey, userId: options.userId || "anon" })
|
|
44828
|
+
});
|
|
44829
|
+
if (!finalizeResponse.ok) {
|
|
44830
|
+
const text2 = await finalizeResponse.text();
|
|
44831
|
+
throw new TevrocError(text2 || "Finalize upload failed", { status: finalizeResponse.status, code: "gcs_finalize_failed" });
|
|
44832
|
+
}
|
|
44833
|
+
const result = await finalizeResponse.json();
|
|
44834
|
+
if (options.tableName && options.tableIdx !== void 0) {
|
|
44835
|
+
await client.fetch(`${serviceUrl}/api/files/gcs-store`, {
|
|
44836
|
+
method: "POST",
|
|
44837
|
+
headers: { "Content-Type": "application/json", Accept: "application/json" },
|
|
44838
|
+
body: JSON.stringify({ storageKey: result.storageKey || init.storageKey, tableName: options.tableName, tableIdx: options.tableIdx, fileName, fileSize: body.size, fileMime: contentType, gallery: options.gallery ? "YES" : "NO", filePanaroma: options.filePanaroma || "NO" })
|
|
44839
|
+
});
|
|
44840
|
+
}
|
|
44841
|
+
return { ...result, runtime: "gcs" };
|
|
44842
|
+
}
|
|
44843
|
+
async function parseAxiosResponse(response, parseAs) {
|
|
44844
|
+
if (parseAs === "response") return response;
|
|
44845
|
+
const headers = response.headers ?? {};
|
|
44846
|
+
const contentType = typeof headers.get === "function" ? headers.get("content-type") ?? "" : String(headers["content-type"] ?? headers["Content-Type"] ?? "");
|
|
44847
|
+
const isJson = contentType.includes("application/json");
|
|
44848
|
+
const data = response.data;
|
|
44849
|
+
if (response.status < 200 || response.status >= 300) {
|
|
44850
|
+
const error = isJson && data?.error ? data.error : {};
|
|
44851
|
+
throw new TevrocError(error.message ?? response.statusText ?? "Request failed", {
|
|
44852
|
+
status: response.status,
|
|
44853
|
+
code: error.code ?? "api_error",
|
|
44854
|
+
details: error.details ?? data,
|
|
44855
|
+
response
|
|
44856
|
+
});
|
|
44857
|
+
}
|
|
44858
|
+
return data;
|
|
44022
44859
|
}
|
|
44023
44860
|
async function parseResponse(response, parseAs) {
|
|
44024
44861
|
if (parseAs === "response") return response;
|
|
@@ -44056,13 +44893,13 @@ var Tevroc = (() => {
|
|
|
44056
44893
|
return Object.fromEntries(new Headers(headers).entries());
|
|
44057
44894
|
}
|
|
44058
44895
|
function debugLog2(client, ...args) {
|
|
44059
|
-
|
|
44896
|
+
debugLog(...args);
|
|
44060
44897
|
}
|
|
44061
44898
|
function debugWarn2(client, ...args) {
|
|
44062
|
-
|
|
44899
|
+
debugWarn(...args);
|
|
44063
44900
|
}
|
|
44064
44901
|
function debugError2(client, ...args) {
|
|
44065
|
-
|
|
44902
|
+
debugError(...args);
|
|
44066
44903
|
}
|
|
44067
44904
|
function safeLocalStorage() {
|
|
44068
44905
|
return typeof globalThis !== "undefined" ? globalThis.localStorage : void 0;
|