@preference-sl/pref-configurator-sdk 0.1.0-beta.1
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/README.md +8 -0
- package/_framework/Microsoft.Extensions.Caching.Abstractions.xqpx5xxjzl.wasm +0 -0
- package/_framework/Microsoft.Extensions.Caching.Abstractions.xqpx5xxjzl.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Caching.Abstractions.xqpx5xxjzl.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Caching.Memory.q78n7r2wee.wasm +0 -0
- package/_framework/Microsoft.Extensions.Caching.Memory.q78n7r2wee.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Caching.Memory.q78n7r2wee.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Configuration.Abstractions.ugxmsyl8r9.wasm +0 -0
- package/_framework/Microsoft.Extensions.Configuration.Abstractions.ugxmsyl8r9.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Configuration.Abstractions.ugxmsyl8r9.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Configuration.Binder.u7uig3v6zu.wasm +0 -0
- package/_framework/Microsoft.Extensions.Configuration.Binder.u7uig3v6zu.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Configuration.Binder.u7uig3v6zu.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Configuration.CommandLine.rwfx1dpj0f.wasm +0 -0
- package/_framework/Microsoft.Extensions.Configuration.CommandLine.rwfx1dpj0f.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Configuration.CommandLine.rwfx1dpj0f.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Configuration.EnvironmentVariables.4iqygerjsu.wasm +0 -0
- package/_framework/Microsoft.Extensions.Configuration.EnvironmentVariables.4iqygerjsu.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Configuration.EnvironmentVariables.4iqygerjsu.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Configuration.FileExtensions.gkccepp1zw.wasm +0 -0
- package/_framework/Microsoft.Extensions.Configuration.FileExtensions.gkccepp1zw.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Configuration.FileExtensions.gkccepp1zw.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Configuration.Json.wulbkczaua.wasm +0 -0
- package/_framework/Microsoft.Extensions.Configuration.Json.wulbkczaua.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Configuration.Json.wulbkczaua.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Configuration.UserSecrets.3hquxzl9oa.wasm +0 -0
- package/_framework/Microsoft.Extensions.Configuration.UserSecrets.3hquxzl9oa.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Configuration.UserSecrets.3hquxzl9oa.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Configuration.bx39a9eeta.wasm +0 -0
- package/_framework/Microsoft.Extensions.Configuration.bx39a9eeta.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Configuration.bx39a9eeta.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.DependencyInjection.Abstractions.tnr9bu0qg4.wasm +0 -0
- package/_framework/Microsoft.Extensions.DependencyInjection.Abstractions.tnr9bu0qg4.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.DependencyInjection.Abstractions.tnr9bu0qg4.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.DependencyInjection.npo4ctt27h.wasm +0 -0
- package/_framework/Microsoft.Extensions.DependencyInjection.npo4ctt27h.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.DependencyInjection.npo4ctt27h.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Diagnostics.Abstractions.o01zsa67a9.wasm +0 -0
- package/_framework/Microsoft.Extensions.Diagnostics.Abstractions.o01zsa67a9.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Diagnostics.Abstractions.o01zsa67a9.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Diagnostics.bwnulo9rzd.wasm +0 -0
- package/_framework/Microsoft.Extensions.Diagnostics.bwnulo9rzd.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Diagnostics.bwnulo9rzd.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.FileProviders.Abstractions.73fjqjp4yj.wasm +0 -0
- package/_framework/Microsoft.Extensions.FileProviders.Abstractions.73fjqjp4yj.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.FileProviders.Abstractions.73fjqjp4yj.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.FileProviders.Physical.xb79vbn663.wasm +0 -0
- package/_framework/Microsoft.Extensions.FileProviders.Physical.xb79vbn663.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.FileProviders.Physical.xb79vbn663.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.FileSystemGlobbing.vnq2oqa19f.wasm +0 -0
- package/_framework/Microsoft.Extensions.FileSystemGlobbing.vnq2oqa19f.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.FileSystemGlobbing.vnq2oqa19f.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Hosting.Abstractions.wdrg1gt8sg.wasm +0 -0
- package/_framework/Microsoft.Extensions.Hosting.Abstractions.wdrg1gt8sg.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Hosting.Abstractions.wdrg1gt8sg.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Hosting.qbcheecaev.wasm +0 -0
- package/_framework/Microsoft.Extensions.Hosting.qbcheecaev.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Hosting.qbcheecaev.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Http.efsqq4vcly.wasm +0 -0
- package/_framework/Microsoft.Extensions.Http.efsqq4vcly.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Http.efsqq4vcly.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Logging.Abstractions.hvjrczjl5y.wasm +0 -0
- package/_framework/Microsoft.Extensions.Logging.Abstractions.hvjrczjl5y.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Logging.Abstractions.hvjrczjl5y.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Logging.Configuration.o5xjnd00ty.wasm +0 -0
- package/_framework/Microsoft.Extensions.Logging.Configuration.o5xjnd00ty.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Logging.Configuration.o5xjnd00ty.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Logging.Debug.wt9hqm6pwc.wasm +0 -0
- package/_framework/Microsoft.Extensions.Logging.Debug.wt9hqm6pwc.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Logging.Debug.wt9hqm6pwc.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Logging.EventLog.n0xbuqnamh.wasm +0 -0
- package/_framework/Microsoft.Extensions.Logging.EventLog.n0xbuqnamh.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Logging.EventLog.n0xbuqnamh.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Logging.EventSource.79232rb50z.wasm +0 -0
- package/_framework/Microsoft.Extensions.Logging.EventSource.79232rb50z.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Logging.EventSource.79232rb50z.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Logging.ai6yh3gwys.wasm +0 -0
- package/_framework/Microsoft.Extensions.Logging.ai6yh3gwys.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Logging.ai6yh3gwys.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Options.0xyfq7w7oa.wasm +0 -0
- package/_framework/Microsoft.Extensions.Options.0xyfq7w7oa.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Options.0xyfq7w7oa.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Options.ConfigurationExtensions.i146gqqpbz.wasm +0 -0
- package/_framework/Microsoft.Extensions.Options.ConfigurationExtensions.i146gqqpbz.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Options.ConfigurationExtensions.i146gqqpbz.wasm.gz +0 -0
- package/_framework/Microsoft.Extensions.Primitives.l6yivxpywg.wasm +0 -0
- package/_framework/Microsoft.Extensions.Primitives.l6yivxpywg.wasm.br +0 -0
- package/_framework/Microsoft.Extensions.Primitives.l6yivxpywg.wasm.gz +0 -0
- package/_framework/PrefConfigurator.Abstractions.4iq5j2fxji.wasm +0 -0
- package/_framework/PrefConfigurator.Abstractions.4iq5j2fxji.wasm.br +0 -0
- package/_framework/PrefConfigurator.Abstractions.4iq5j2fxji.wasm.gz +0 -0
- package/_framework/PrefConfigurator.Application.iq3v594t2c.wasm +0 -0
- package/_framework/PrefConfigurator.Application.iq3v594t2c.wasm.br +0 -0
- package/_framework/PrefConfigurator.Application.iq3v594t2c.wasm.gz +0 -0
- package/_framework/PrefConfigurator.Domain.h7gjm6qw1r.wasm +0 -0
- package/_framework/PrefConfigurator.Domain.h7gjm6qw1r.wasm.br +0 -0
- package/_framework/PrefConfigurator.Domain.h7gjm6qw1r.wasm.gz +0 -0
- package/_framework/PrefConfigurator.Infrastructure.zsapiey9zo.wasm +0 -0
- package/_framework/PrefConfigurator.Infrastructure.zsapiey9zo.wasm.br +0 -0
- package/_framework/PrefConfigurator.Infrastructure.zsapiey9zo.wasm.gz +0 -0
- package/_framework/PrefConfigurator.Wasm.v2gat54k7q.wasm +0 -0
- package/_framework/PrefConfigurator.Wasm.v2gat54k7q.wasm.br +0 -0
- package/_framework/PrefConfigurator.Wasm.v2gat54k7q.wasm.gz +0 -0
- package/_framework/System.0x1wb7tfot.wasm +0 -0
- package/_framework/System.0x1wb7tfot.wasm.br +0 -0
- package/_framework/System.0x1wb7tfot.wasm.gz +0 -0
- package/_framework/System.Collections.Concurrent.j3bbs5wmlv.wasm +0 -0
- package/_framework/System.Collections.Concurrent.j3bbs5wmlv.wasm.br +0 -0
- package/_framework/System.Collections.Concurrent.j3bbs5wmlv.wasm.gz +0 -0
- package/_framework/System.Collections.NonGeneric.yqu01kezsn.wasm +0 -0
- package/_framework/System.Collections.NonGeneric.yqu01kezsn.wasm.br +0 -0
- package/_framework/System.Collections.NonGeneric.yqu01kezsn.wasm.gz +0 -0
- package/_framework/System.Collections.Specialized.bpdebmac44.wasm +0 -0
- package/_framework/System.Collections.Specialized.bpdebmac44.wasm.br +0 -0
- package/_framework/System.Collections.Specialized.bpdebmac44.wasm.gz +0 -0
- package/_framework/System.Collections.q5k866g8l0.wasm +0 -0
- package/_framework/System.Collections.q5k866g8l0.wasm.br +0 -0
- package/_framework/System.Collections.q5k866g8l0.wasm.gz +0 -0
- package/_framework/System.ComponentModel.Primitives.03lga6t30g.wasm +0 -0
- package/_framework/System.ComponentModel.Primitives.03lga6t30g.wasm.br +0 -0
- package/_framework/System.ComponentModel.Primitives.03lga6t30g.wasm.gz +0 -0
- package/_framework/System.ComponentModel.TypeConverter.evmd54h9ff.wasm +0 -0
- package/_framework/System.ComponentModel.TypeConverter.evmd54h9ff.wasm.br +0 -0
- package/_framework/System.ComponentModel.TypeConverter.evmd54h9ff.wasm.gz +0 -0
- package/_framework/System.ComponentModel.xmxjt0ntly.wasm +0 -0
- package/_framework/System.ComponentModel.xmxjt0ntly.wasm.br +0 -0
- package/_framework/System.ComponentModel.xmxjt0ntly.wasm.gz +0 -0
- package/_framework/System.Console.n25kw3pp6f.wasm +0 -0
- package/_framework/System.Console.n25kw3pp6f.wasm.br +0 -0
- package/_framework/System.Console.n25kw3pp6f.wasm.gz +0 -0
- package/_framework/System.Diagnostics.DiagnosticSource.w6foamen3a.wasm +0 -0
- package/_framework/System.Diagnostics.DiagnosticSource.w6foamen3a.wasm.br +0 -0
- package/_framework/System.Diagnostics.DiagnosticSource.w6foamen3a.wasm.gz +0 -0
- package/_framework/System.Diagnostics.EventLog.r3m23h8juo.wasm +0 -0
- package/_framework/System.Diagnostics.EventLog.r3m23h8juo.wasm.br +0 -0
- package/_framework/System.Diagnostics.EventLog.r3m23h8juo.wasm.gz +0 -0
- package/_framework/System.IO.FileSystem.Watcher.eb5dfvbj5s.wasm +0 -0
- package/_framework/System.IO.FileSystem.Watcher.eb5dfvbj5s.wasm.br +0 -0
- package/_framework/System.IO.FileSystem.Watcher.eb5dfvbj5s.wasm.gz +0 -0
- package/_framework/System.IO.Pipelines.pwfw0zwx98.wasm +0 -0
- package/_framework/System.IO.Pipelines.pwfw0zwx98.wasm.br +0 -0
- package/_framework/System.IO.Pipelines.pwfw0zwx98.wasm.gz +0 -0
- package/_framework/System.Linq.l0hidjun71.wasm +0 -0
- package/_framework/System.Linq.l0hidjun71.wasm.br +0 -0
- package/_framework/System.Linq.l0hidjun71.wasm.gz +0 -0
- package/_framework/System.Memory.60lsd7b7gy.wasm +0 -0
- package/_framework/System.Memory.60lsd7b7gy.wasm.br +0 -0
- package/_framework/System.Memory.60lsd7b7gy.wasm.gz +0 -0
- package/_framework/System.Net.Http.1erjtemsp4.wasm +0 -0
- package/_framework/System.Net.Http.1erjtemsp4.wasm.br +0 -0
- package/_framework/System.Net.Http.1erjtemsp4.wasm.gz +0 -0
- package/_framework/System.Net.Http.Json.5ycgf70349.wasm +0 -0
- package/_framework/System.Net.Http.Json.5ycgf70349.wasm.br +0 -0
- package/_framework/System.Net.Http.Json.5ycgf70349.wasm.gz +0 -0
- package/_framework/System.Net.Primitives.yl1uus6nzv.wasm +0 -0
- package/_framework/System.Net.Primitives.yl1uus6nzv.wasm.br +0 -0
- package/_framework/System.Net.Primitives.yl1uus6nzv.wasm.gz +0 -0
- package/_framework/System.ObjectModel.lpjdvx9u1s.wasm +0 -0
- package/_framework/System.ObjectModel.lpjdvx9u1s.wasm.br +0 -0
- package/_framework/System.ObjectModel.lpjdvx9u1s.wasm.gz +0 -0
- package/_framework/System.Private.CoreLib.77dyhxu8ng.wasm +0 -0
- package/_framework/System.Private.CoreLib.77dyhxu8ng.wasm.br +0 -0
- package/_framework/System.Private.CoreLib.77dyhxu8ng.wasm.gz +0 -0
- package/_framework/System.Private.Uri.i08y2naikb.wasm +0 -0
- package/_framework/System.Private.Uri.i08y2naikb.wasm.br +0 -0
- package/_framework/System.Private.Uri.i08y2naikb.wasm.gz +0 -0
- package/_framework/System.Private.Xml.Linq.aggbm4zmvg.wasm +0 -0
- package/_framework/System.Private.Xml.Linq.aggbm4zmvg.wasm.br +0 -0
- package/_framework/System.Private.Xml.Linq.aggbm4zmvg.wasm.gz +0 -0
- package/_framework/System.Private.Xml.xynykvwzmm.wasm +0 -0
- package/_framework/System.Private.Xml.xynykvwzmm.wasm.br +0 -0
- package/_framework/System.Private.Xml.xynykvwzmm.wasm.gz +0 -0
- package/_framework/System.Runtime.InteropServices.JavaScript.hz5gi57d06.wasm +0 -0
- package/_framework/System.Runtime.InteropServices.JavaScript.hz5gi57d06.wasm.br +0 -0
- package/_framework/System.Runtime.InteropServices.JavaScript.hz5gi57d06.wasm.gz +0 -0
- package/_framework/System.Security.Cryptography.ar0yl9tyah.wasm +0 -0
- package/_framework/System.Security.Cryptography.ar0yl9tyah.wasm.br +0 -0
- package/_framework/System.Security.Cryptography.ar0yl9tyah.wasm.gz +0 -0
- package/_framework/System.Text.Encodings.Web.wom12sblxz.wasm +0 -0
- package/_framework/System.Text.Encodings.Web.wom12sblxz.wasm.br +0 -0
- package/_framework/System.Text.Encodings.Web.wom12sblxz.wasm.gz +0 -0
- package/_framework/System.Text.Json.p6fo7wpau6.wasm +0 -0
- package/_framework/System.Text.Json.p6fo7wpau6.wasm.br +0 -0
- package/_framework/System.Text.Json.p6fo7wpau6.wasm.gz +0 -0
- package/_framework/System.Text.RegularExpressions.91s5c47mla.wasm +0 -0
- package/_framework/System.Text.RegularExpressions.91s5c47mla.wasm.br +0 -0
- package/_framework/System.Text.RegularExpressions.91s5c47mla.wasm.gz +0 -0
- package/_framework/System.Xml.Linq.1t1f7abjkk.wasm +0 -0
- package/_framework/System.Xml.Linq.1t1f7abjkk.wasm.br +0 -0
- package/_framework/System.Xml.Linq.1t1f7abjkk.wasm.gz +0 -0
- package/_framework/dotnet.js +465 -0
- package/_framework/dotnet.js.br +0 -0
- package/_framework/dotnet.js.gz +0 -0
- package/_framework/dotnet.native.3hup5hq7f6.wasm +0 -0
- package/_framework/dotnet.native.3hup5hq7f6.wasm.br +0 -0
- package/_framework/dotnet.native.3hup5hq7f6.wasm.gz +0 -0
- package/_framework/dotnet.native.5hvkdrpygk.js +6521 -0
- package/_framework/dotnet.native.5hvkdrpygk.js.br +0 -0
- package/_framework/dotnet.native.5hvkdrpygk.js.gz +0 -0
- package/_framework/dotnet.runtime.2zl32tp6ah.js +4 -0
- package/_framework/dotnet.runtime.2zl32tp6ah.js.br +0 -0
- package/_framework/dotnet.runtime.2zl32tp6ah.js.gz +0 -0
- package/_framework/icudt_CJK.tjcz0u77k5.dat +0 -0
- package/_framework/icudt_CJK.tjcz0u77k5.dat.br +0 -0
- package/_framework/icudt_CJK.tjcz0u77k5.dat.gz +0 -0
- package/_framework/icudt_EFIGS.tptq2av103.dat +0 -0
- package/_framework/icudt_EFIGS.tptq2av103.dat.br +0 -0
- package/_framework/icudt_EFIGS.tptq2av103.dat.gz +0 -0
- package/_framework/icudt_no_CJK.lfu7j35m59.dat +0 -0
- package/_framework/icudt_no_CJK.lfu7j35m59.dat.br +0 -0
- package/_framework/icudt_no_CJK.lfu7j35m59.dat.gz +0 -0
- package/index.html +155 -0
- package/js/PrefGltfMergerWasm.js +2 -0
- package/js/PrefGltfMergerWasm.wasm +0 -0
- package/js/gltf-merger.js +92 -0
- package/js/gltf-storage.js +239 -0
- package/js/prefconfigurator-api.d.ts +380 -0
- package/js/prefconfigurator-api.js +44 -0
- package/main.d.ts +4 -0
- package/main.js +2 -0
- package/package.json +33 -0
- package/scripts/postinstall.js +128 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// wwwroot/js/gltf-storage.js
|
|
2
|
+
|
|
3
|
+
// Public, inspectable namespace
|
|
4
|
+
const PC = (globalThis.PrefConfigurator ??= {});
|
|
5
|
+
PC.version = PC.version ?? "1.0.1"; // bump if your schema changes!!
|
|
6
|
+
PC.db = PC.db ?? null;
|
|
7
|
+
PC.dbName = PC.dbName ?? null;
|
|
8
|
+
PC.storeName = PC.storeName ?? null;
|
|
9
|
+
|
|
10
|
+
function _getDbOrThrow() {
|
|
11
|
+
const db = PC.db;
|
|
12
|
+
if (!db) throw new Error("Database not initialized. Call initDb(...) first.");
|
|
13
|
+
return db;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// --- internal helpers -------------------------------------------------------
|
|
17
|
+
function _openEnsuringStore(dbName, storeName) {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
const open = indexedDB.open(dbName, 5);
|
|
20
|
+
|
|
21
|
+
open.onblocked = () => reject(new Error("Open blocked by another tab or worker"));
|
|
22
|
+
open.onerror = () => reject(open.error);
|
|
23
|
+
open.onsuccess = (e) => {
|
|
24
|
+
resolve(e.target.result);
|
|
25
|
+
}
|
|
26
|
+
open.onupgradeneeded = (ev) => {
|
|
27
|
+
const upgradeDb = ev.target.result;
|
|
28
|
+
const tx = ev.target.transaction;
|
|
29
|
+
|
|
30
|
+
let store;
|
|
31
|
+
if (!upgradeDb.objectStoreNames.contains(storeName)) {
|
|
32
|
+
store = upgradeDb.createObjectStore(storeName, { keyPath: 'id' });
|
|
33
|
+
} else if (tx) {
|
|
34
|
+
store = tx.objectStore(storeName);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (store && !store.indexNames.contains('expirationTimeStamp')) {
|
|
38
|
+
store.createIndex('expirationTimeStamp', 'expirationTimeStamp', { unique: false });
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function _isRecoverableDbError(err) {
|
|
45
|
+
const msg = String(err?.message ?? err ?? "");
|
|
46
|
+
if (!msg) return false;
|
|
47
|
+
return msg.includes("Database not initialized") ||
|
|
48
|
+
msg.includes("The database connection is closing") ||
|
|
49
|
+
msg.includes("InvalidStateError") ||
|
|
50
|
+
msg.includes("NotFoundError");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function _withDbRetry(work) {
|
|
54
|
+
try {
|
|
55
|
+
return await work(_getDbOrThrow());
|
|
56
|
+
} catch (e) {
|
|
57
|
+
if (!_isRecoverableDbError(e) || !PC.dbName || !PC.storeName) {
|
|
58
|
+
throw e;
|
|
59
|
+
}
|
|
60
|
+
await initDb(PC.dbName, PC.storeName);
|
|
61
|
+
return await work(_getDbOrThrow());
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// --- public API -------------------------------------------------------------
|
|
66
|
+
|
|
67
|
+
// Inicializar IndexedDB y dejar el handle en PrefConfigurator.db (público)
|
|
68
|
+
export async function initDb(dbName, storeName) {
|
|
69
|
+
PC.dbName = dbName;
|
|
70
|
+
PC.storeName = storeName;
|
|
71
|
+
|
|
72
|
+
const db = await _openEnsuringStore(dbName, storeName);
|
|
73
|
+
// Close any previous handle to avoid versionchange blocking
|
|
74
|
+
try { PC.db?.close?.(); } catch { }
|
|
75
|
+
PC.db = db;
|
|
76
|
+
|
|
77
|
+
// If another tab upgrades, close gracefully so next call can re-init
|
|
78
|
+
db.onversionchange = () => {
|
|
79
|
+
try { db.close(); } catch { }
|
|
80
|
+
if (PC.db === db) PC.db = null;
|
|
81
|
+
console.warn("[PrefConfigurator] DB connection closed due to versionchange. Re-run initDb().");
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Guardar modelo
|
|
86
|
+
export async function saveModel(modelDataStr, storeName) {
|
|
87
|
+
return _withDbRetry((db) => new Promise((resolve, reject) => {
|
|
88
|
+
let modelData;
|
|
89
|
+
try { modelData = JSON.parse(modelDataStr); }
|
|
90
|
+
catch (e) { reject(new Error("saveModel: modelDataStr is not valid JSON")); return; }
|
|
91
|
+
|
|
92
|
+
const dataToStore = {
|
|
93
|
+
...modelData,
|
|
94
|
+
data: modelData.data,
|
|
95
|
+
size: (modelData?.data?.length ?? 0)
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const tx = db.transaction([storeName], "readwrite");
|
|
99
|
+
const store = tx.objectStore(storeName);
|
|
100
|
+
const req = store.put(dataToStore);
|
|
101
|
+
|
|
102
|
+
req.onerror = () => reject(req.error);
|
|
103
|
+
req.onsuccess = () => resolve();
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Cargar modelo
|
|
108
|
+
export function loadModel(modelId, storeName) {
|
|
109
|
+
return _withDbRetry((db) => new Promise((resolve, reject) => {
|
|
110
|
+
const tx = db.transaction([storeName], "readonly");
|
|
111
|
+
const store = tx.objectStore(storeName);
|
|
112
|
+
const req = store.get(modelId);
|
|
113
|
+
|
|
114
|
+
req.onerror = () => reject(req.error);
|
|
115
|
+
req.onsuccess = () => resolve(req.result ?? null);
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Descargar archivo desde base64
|
|
120
|
+
export function downloadFileFromBytes(fileName, bytesBase64, mimeType) {
|
|
121
|
+
const link = document.createElement("a");
|
|
122
|
+
link.download = fileName;
|
|
123
|
+
link.href = `data:${mimeType};base64,${bytesBase64}`;
|
|
124
|
+
document.body.appendChild(link);
|
|
125
|
+
link.click();
|
|
126
|
+
link.remove();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Obtener todos los modelos (solo metadata)
|
|
130
|
+
export async function getAllModels(storeName) {
|
|
131
|
+
return _withDbRetry((db) => new Promise((resolve, reject) => {
|
|
132
|
+
const tx = db.transaction([storeName], "readonly");
|
|
133
|
+
const store = tx.objectStore(storeName);
|
|
134
|
+
const req = store.getAll();
|
|
135
|
+
|
|
136
|
+
req.onerror = () => reject(req.error);
|
|
137
|
+
req.onsuccess = () => {
|
|
138
|
+
const items = Array.isArray(req.result) ? req.result : [];
|
|
139
|
+
const results = items.map(item => ({
|
|
140
|
+
id: item.id,
|
|
141
|
+
metadata: item.metadata,
|
|
142
|
+
timeStamp: item.timeStamp,
|
|
143
|
+
size: item.size
|
|
144
|
+
}));
|
|
145
|
+
// keep old behavior: return JSON string
|
|
146
|
+
resolve(JSON.stringify(results));
|
|
147
|
+
};
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Eliminar modelo por id
|
|
152
|
+
export async function deleteModel(modelId, storeName) {
|
|
153
|
+
return _withDbRetry((db) => new Promise((resolve, reject) => {
|
|
154
|
+
const tx = db.transaction([storeName], "readwrite");
|
|
155
|
+
const store = tx.objectStore(storeName);
|
|
156
|
+
const req = store.delete(modelId);
|
|
157
|
+
|
|
158
|
+
req.onerror = () => reject(req.error);
|
|
159
|
+
req.onsuccess = () => resolve();
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Limpiar toda la store
|
|
164
|
+
export async function clearAll(storeName) {
|
|
165
|
+
return _withDbRetry((db) => new Promise((resolve, reject) => {
|
|
166
|
+
const tx = db.transaction([storeName], "readwrite");
|
|
167
|
+
const store = tx.objectStore(storeName);
|
|
168
|
+
const req = store.clear();
|
|
169
|
+
|
|
170
|
+
req.onerror = () => reject(req.error);
|
|
171
|
+
req.onsuccess = () => resolve();
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Borrar modelos expirados usando el índice "expirationTimeStamp"
|
|
176
|
+
export async function cleanExpiredModels(storeName) {
|
|
177
|
+
return _withDbRetry((db) => new Promise((resolve, reject) => {
|
|
178
|
+
const tx = db.transaction([storeName], "readwrite");
|
|
179
|
+
const store = tx.objectStore(storeName);
|
|
180
|
+
|
|
181
|
+
const index = store.index("expirationTimeStamp");
|
|
182
|
+
const now = Date.now();
|
|
183
|
+
const range = IDBKeyRange.upperBound(now);
|
|
184
|
+
const cursorRequest = index.openCursor(range);
|
|
185
|
+
|
|
186
|
+
cursorRequest.onerror = () => reject(cursorRequest.error);
|
|
187
|
+
cursorRequest.onsuccess = (event) => {
|
|
188
|
+
const cursor = event.target.result;
|
|
189
|
+
if (cursor) {
|
|
190
|
+
cursor.delete();
|
|
191
|
+
cursor.continue();
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
tx.oncomplete = () => resolve();
|
|
196
|
+
tx.onerror = () => reject(tx.error);
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Utilidades opcionales y visibles (por si las quieres usar en consola)
|
|
201
|
+
export function closeDb() {
|
|
202
|
+
if (PC.db) {
|
|
203
|
+
try { PC.db.close(); } catch { }
|
|
204
|
+
PC.db = null;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function deleteDatabase(dbName) {
|
|
209
|
+
return new Promise((resolve, reject) => {
|
|
210
|
+
// Close current handle if points to this DB
|
|
211
|
+
if (PC.db && PC.db.name === dbName) {
|
|
212
|
+
try { PC.db.close(); } catch { }
|
|
213
|
+
PC.db = null;
|
|
214
|
+
}
|
|
215
|
+
const req = indexedDB.deleteDatabase(dbName);
|
|
216
|
+
req.onblocked = () => reject(new Error("Delete blocked by another tab or worker"));
|
|
217
|
+
req.onerror = () => reject(req.error);
|
|
218
|
+
req.onsuccess = () => resolve();
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Attach a frozen, public API (no private state)
|
|
223
|
+
(function attachPublicAPI(global) {
|
|
224
|
+
const storage = {
|
|
225
|
+
initDb,
|
|
226
|
+
saveModel,
|
|
227
|
+
loadModel,
|
|
228
|
+
getAllModels,
|
|
229
|
+
deleteModel,
|
|
230
|
+
clearAll,
|
|
231
|
+
cleanExpiredModels,
|
|
232
|
+
downloadFileFromBytes,
|
|
233
|
+
// extras
|
|
234
|
+
closeDb,
|
|
235
|
+
deleteDatabase,
|
|
236
|
+
};
|
|
237
|
+
// free to inspect PC.db in devtools
|
|
238
|
+
global.PrefConfigurator.storage = Object.freeze(storage);
|
|
239
|
+
})(globalThis);
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
export interface ErrorInfo {
|
|
2
|
+
Code?: string;
|
|
3
|
+
Message?: string;
|
|
4
|
+
Source?: string;
|
|
5
|
+
HttpStatus?: number;
|
|
6
|
+
RequestId?: string;
|
|
7
|
+
CorrelationId?: string;
|
|
8
|
+
TraceParent?: string;
|
|
9
|
+
Detail?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface OperationResult<T> {
|
|
13
|
+
Ok: boolean;
|
|
14
|
+
Data?: T | null;
|
|
15
|
+
Error?: ErrorInfo | null;
|
|
16
|
+
CallId?: string | null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CreateItemResponse {
|
|
20
|
+
ItemId: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
24
|
+
export type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };
|
|
25
|
+
|
|
26
|
+
export interface OptionValueInfo {
|
|
27
|
+
ValueString?: string | null;
|
|
28
|
+
ValueNumeric?: number | null;
|
|
29
|
+
Hidden: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface OptionInfo {
|
|
33
|
+
Maker?: string | null;
|
|
34
|
+
Code?: string | null;
|
|
35
|
+
Type?: string | null;
|
|
36
|
+
Context?: string | null;
|
|
37
|
+
Description?: string | null;
|
|
38
|
+
ValueString?: string | null;
|
|
39
|
+
ValueNumeric?: number | null;
|
|
40
|
+
Hidden: boolean;
|
|
41
|
+
DefaultValueDefined: boolean;
|
|
42
|
+
Values?: OptionValueInfo[] | null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface OptionList {
|
|
46
|
+
Name?: string | null;
|
|
47
|
+
Childs?: OptionList[] | null;
|
|
48
|
+
Options?: OptionInfo[] | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type OptionLocation = { [key: string]: JsonValue };
|
|
52
|
+
|
|
53
|
+
export interface EnhancedOptionInfo extends OptionInfo {
|
|
54
|
+
PartitionPart?: string | null;
|
|
55
|
+
ValueChanged: boolean;
|
|
56
|
+
Locations?: OptionLocation[] | null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface EnhancedOptionList {
|
|
60
|
+
Name?: string | null;
|
|
61
|
+
Childs?: EnhancedOptionList[] | null;
|
|
62
|
+
Options?: EnhancedOptionInfo[] | null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface DimensionsResponse {
|
|
66
|
+
TotalL?: number | null;
|
|
67
|
+
TotalA?: number | null;
|
|
68
|
+
Values?: Record<string, number>;
|
|
69
|
+
ValuesText?: Record<string, string>;
|
|
70
|
+
LLabels?: string[];
|
|
71
|
+
ALabels?: string[];
|
|
72
|
+
LCount?: number;
|
|
73
|
+
ACount?: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface SetDimensionsResponse {
|
|
77
|
+
RawResults?: Array<boolean | null>;
|
|
78
|
+
Succeeded?: boolean | null;
|
|
79
|
+
Status?: string | null;
|
|
80
|
+
Message?: string | null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface SetDimensionValueRequest {
|
|
84
|
+
dimensionName: string;
|
|
85
|
+
dimensionValue: number;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface SetOptionValueResponse {
|
|
89
|
+
succeeded: boolean;
|
|
90
|
+
status?: string | null;
|
|
91
|
+
message?: string | null;
|
|
92
|
+
optionChanged?: boolean | null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface SetOptionValueRequest {
|
|
96
|
+
optionName: string;
|
|
97
|
+
optionValue: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface SetOptionValueBatchResult {
|
|
101
|
+
optionName: string;
|
|
102
|
+
sent: boolean;
|
|
103
|
+
reason?: string | null;
|
|
104
|
+
response?: SetOptionValueResponse | null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface SetOptionsResponse {
|
|
108
|
+
requestedCount: number;
|
|
109
|
+
sentCount: number;
|
|
110
|
+
skippedCount: number;
|
|
111
|
+
results: SetOptionValueBatchResult[];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface SceneTexCoord {
|
|
115
|
+
Scale: number[];
|
|
116
|
+
Offset: number[];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface ScenePlane {
|
|
120
|
+
Normal: number[];
|
|
121
|
+
Point: number[];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface SceneFloor {
|
|
125
|
+
Plane: ScenePlane;
|
|
126
|
+
TexCoord: SceneTexCoord;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface SceneMaterial {
|
|
130
|
+
Name: string;
|
|
131
|
+
BaseColor: string;
|
|
132
|
+
Roughness: string;
|
|
133
|
+
Normal: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface SceneWallData {
|
|
137
|
+
OuterWallTexCoord: SceneTexCoord;
|
|
138
|
+
InnerWallTexCoord: SceneTexCoord;
|
|
139
|
+
OuterFloor: SceneFloor;
|
|
140
|
+
InnerFloor: SceneFloor;
|
|
141
|
+
WallPolyline: string;
|
|
142
|
+
MinWallThickness: number;
|
|
143
|
+
Translation: number[];
|
|
144
|
+
FloorPath: string;
|
|
145
|
+
UpAxis: number;
|
|
146
|
+
RotationAngle: number;
|
|
147
|
+
Materials: SceneMaterial[];
|
|
148
|
+
InnerHeight?: number | null;
|
|
149
|
+
OuterHeight?: number | null;
|
|
150
|
+
ExtraInnerWallDepth?: number | null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface Scene {
|
|
154
|
+
Maker: string;
|
|
155
|
+
Name: string;
|
|
156
|
+
Format: string;
|
|
157
|
+
Uri: string;
|
|
158
|
+
ConfigFile: string;
|
|
159
|
+
HdrFile: string;
|
|
160
|
+
DbMaterialsId: string;
|
|
161
|
+
WallDatas: SceneWallData[];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface EnvJson {
|
|
165
|
+
version?: number | null;
|
|
166
|
+
|
|
167
|
+
services: {
|
|
168
|
+
baseUrl?: string | null;
|
|
169
|
+
serviceMappings?: Array<{ serviceName: string; kind: "path" | "port"; value: string }> | null;
|
|
170
|
+
urlResolutionMode?: "legacy" | "explicit" | null;
|
|
171
|
+
hydraBaseUrl?: string | null;
|
|
172
|
+
prefWebBaseUrl?: string | null;
|
|
173
|
+
kbApiBaseUrl?: string | null;
|
|
174
|
+
hcApiBaseUrl?: string | null;
|
|
175
|
+
hypercubeId?: string | null;
|
|
176
|
+
hypercubeDeploymentId?: string | null;
|
|
177
|
+
cloudPrefWebBaseUrl?: string | null;
|
|
178
|
+
kbUiBaseUrl?: string | null;
|
|
179
|
+
wallGeneratorBaseUrl?: string | null;
|
|
180
|
+
usdBaseUrl?: string | null;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
maker: {
|
|
184
|
+
name?: string | null;
|
|
185
|
+
prefix?: string | null;
|
|
186
|
+
environment?: string | null;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
ui: {
|
|
190
|
+
definitionName?: string | null;
|
|
191
|
+
optionListName?: string | null;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
auth: {
|
|
195
|
+
username?: string | null;
|
|
196
|
+
password?: string | null;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
images: {
|
|
200
|
+
model: {
|
|
201
|
+
onlyModelImage: boolean;
|
|
202
|
+
type2D: number;
|
|
203
|
+
type3D: number;
|
|
204
|
+
width: number;
|
|
205
|
+
height: number;
|
|
206
|
+
daysToLive: number;
|
|
207
|
+
};
|
|
208
|
+
scene: {
|
|
209
|
+
name: string;
|
|
210
|
+
format: string;
|
|
211
|
+
};
|
|
212
|
+
materials: {
|
|
213
|
+
daysToLive: number;
|
|
214
|
+
};
|
|
215
|
+
usd?: {
|
|
216
|
+
sceneName?: string | null;
|
|
217
|
+
generateWall?: boolean | null;
|
|
218
|
+
qualities?: string[] | null;
|
|
219
|
+
resolutions?: string[] | null;
|
|
220
|
+
cameras?: string[] | null;
|
|
221
|
+
imageFormat?: string | null;
|
|
222
|
+
variantSets?: UsdVariantSet[] | null;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
storage: {
|
|
227
|
+
gltf: {
|
|
228
|
+
dbName: string;
|
|
229
|
+
storeName: string;
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
runtime: {
|
|
234
|
+
logLevel: string;
|
|
235
|
+
httpTimeoutSeconds?: number | null;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
flags?: Record<string, boolean> | null;
|
|
239
|
+
extra?: Record<string, any | null> | null;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export enum ViewMode {
|
|
243
|
+
_0,
|
|
244
|
+
_1,
|
|
245
|
+
_2,
|
|
246
|
+
_3
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export enum ImageType {
|
|
250
|
+
_0,
|
|
251
|
+
_1,
|
|
252
|
+
_2,
|
|
253
|
+
_3,
|
|
254
|
+
_4,
|
|
255
|
+
_5,
|
|
256
|
+
_6,
|
|
257
|
+
_7,
|
|
258
|
+
_8,
|
|
259
|
+
_9,
|
|
260
|
+
_10,
|
|
261
|
+
_11,
|
|
262
|
+
_12,
|
|
263
|
+
_13,
|
|
264
|
+
_14,
|
|
265
|
+
_15,
|
|
266
|
+
_16,
|
|
267
|
+
_17
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface CadRendererData {
|
|
271
|
+
viewMode: ViewMode;
|
|
272
|
+
cameraProjection?: number | null;
|
|
273
|
+
cameraPosition?: number | null;
|
|
274
|
+
predefinedView?: string | null;
|
|
275
|
+
backgroundColor?: number | null;
|
|
276
|
+
customProperties?: string | null;
|
|
277
|
+
texturesRootPath?: string | null;
|
|
278
|
+
base64Textures?: boolean | null;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface ModelImageConfig {
|
|
282
|
+
imageType: ImageType;
|
|
283
|
+
width: number;
|
|
284
|
+
height: number;
|
|
285
|
+
useHypercube?: boolean | null;
|
|
286
|
+
hcGenerate?: boolean | null;
|
|
287
|
+
hcWait?: boolean | null;
|
|
288
|
+
units: number;
|
|
289
|
+
usePrefOne: boolean;
|
|
290
|
+
languageId: number;
|
|
291
|
+
visualPropertiesXML?: string | null;
|
|
292
|
+
cadRenderer?: CadRendererData | null;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface UsdVariantSet {
|
|
296
|
+
name: string;
|
|
297
|
+
selection: string;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface HcProductStatusResult {
|
|
301
|
+
available: boolean;
|
|
302
|
+
href?: string | null;
|
|
303
|
+
status?: string | null;
|
|
304
|
+
productHash?: string | null;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface UsdImagesModel {
|
|
308
|
+
itemId: string;
|
|
309
|
+
generateWall?: boolean | null;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export interface UsdImagesRequest {
|
|
313
|
+
sceneName?: string | null;
|
|
314
|
+
useHypercube?: boolean | null;
|
|
315
|
+
hcGenerate?: boolean | null;
|
|
316
|
+
hcWait?: boolean | null;
|
|
317
|
+
models?: UsdImagesModel[] | null;
|
|
318
|
+
qualities?: string[] | null;
|
|
319
|
+
resolutions?: string[] | null;
|
|
320
|
+
cameras?: string[] | null;
|
|
321
|
+
imageFormat?: string | null;
|
|
322
|
+
variantSets?: UsdVariantSet[] | null;
|
|
323
|
+
renderMode?: string | null;
|
|
324
|
+
visualProperties?: string | null;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export interface JsInteropApiRaw {
|
|
328
|
+
InitializeFromEnvJson(json: string): void;
|
|
329
|
+
|
|
330
|
+
GetOptions<T = EnhancedOptionList>(): Promise<OperationResult<T> | string>;
|
|
331
|
+
UpdateOptions<T = EnhancedOptionList>(optionListJson: string, optionNamesChangedJson: string): Promise<OperationResult<T> | string>;
|
|
332
|
+
CreateItem<T = CreateItemResponse>(modelCode: string, isPersistable: boolean): Promise<OperationResult<T> | string>;
|
|
333
|
+
GetDimensions<T = DimensionsResponse>(modelId: string): Promise<OperationResult<T> | string>;
|
|
334
|
+
SetDimensions<T = SetDimensionsResponse>(modelId: string, dimensions: SetDimensionValueRequest[]): Promise<OperationResult<T> | string>;
|
|
335
|
+
SetOptions<T = SetOptionsResponse>(modelId: string, options: SetOptionValueRequest[]): Promise<OperationResult<T> | string>;
|
|
336
|
+
GetModelOptions<T = OptionInfo[]>(modelId: string): Promise<OperationResult<T> | string>;
|
|
337
|
+
GetScene<T = Scene>(sceneName?: string, sceneFormat?: string, texturesRootPath?: string): Promise<OperationResult<T> | string>;
|
|
338
|
+
GetModelImage(modelId: string, modelImageConfigJson: string, sceneName?: string, optionListJson?: string): Promise<OperationResult<string> | string>;
|
|
339
|
+
GetUsdImages<T = string[]>(usdImagesRequestJson: string, optionListJson?: string): Promise<OperationResult<T> | string>;
|
|
340
|
+
GetUsdImagesHcStatus<T = HcProductStatusResult[]>(usdImagesRequestJson: string, optionListJson: string): Promise<OperationResult<T> | string>;
|
|
341
|
+
GetModelImageHcStatus<T = HcProductStatusResult>(modelId: string, modelImageConfigJson: string): Promise<OperationResult<T> | string>;
|
|
342
|
+
GetDefaultMaker(): string;
|
|
343
|
+
GetMakerPrefix(): string;
|
|
344
|
+
GetUiDefinitionName(): string;
|
|
345
|
+
GetOptionListName(): string;
|
|
346
|
+
GetBaseUrl(): string;
|
|
347
|
+
GetUsername(): string;
|
|
348
|
+
GetPassword(): string;
|
|
349
|
+
GetSceneName(): string;
|
|
350
|
+
GetSceneFormat(): string;
|
|
351
|
+
GetTextureRootPath(): string;
|
|
352
|
+
|
|
353
|
+
[key: string]: unknown;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export type RawOperation<T = JsonValue> = OperationResult<T> | string | null | undefined;
|
|
357
|
+
|
|
358
|
+
export function parse<T = JsonValue>(raw: RawOperation<T>): OperationResult<T>;
|
|
359
|
+
|
|
360
|
+
export function ensureOk<T = JsonValue>(raw: RawOperation<T>): T;
|
|
361
|
+
|
|
362
|
+
type AwaitedReturn<T> = T extends Promise<infer R> ? R : T;
|
|
363
|
+
type ExtractData<R> = AwaitedReturn<R> extends OperationResult<infer D> ? D : JsonValue;
|
|
364
|
+
type BoundMethod<F> = F extends (...args: infer A) => Promise<infer R> ? (...args: A) => Promise<ExtractData<R>> : F;
|
|
365
|
+
|
|
366
|
+
// BOUND API — PUBLIC API CORRECTLY TYPED
|
|
367
|
+
|
|
368
|
+
export type BoundApi<TRaw extends JsInteropApiRaw> = { [K in keyof TRaw]: TRaw[K] extends Function ? BoundMethod<TRaw[K]> : TRaw[K];
|
|
369
|
+
} & {
|
|
370
|
+
InitializeFromEnvJson(config: EnvJson): void;
|
|
371
|
+
UpdateOptions(optionList: OptionList, changedOptionNames: string[]): Promise<EnhancedOptionList>;
|
|
372
|
+
SetDimensions(modelId: string, updates: SetDimensionValueRequest[]): Promise<SetDimensionsResponse>;
|
|
373
|
+
SetOptions(modelId: string, updates: SetOptionValueRequest[]): Promise<SetOptionsResponse>;
|
|
374
|
+
GetModelImage(modelId: string, config: ModelImageConfig, sceneName?: string, optionList?: OptionList): Promise<string>;
|
|
375
|
+
GetUsdImages(request: UsdImagesRequest, optionList?: OptionList): Promise<string[]>;
|
|
376
|
+
GetUsdImagesHcStatus(request: UsdImagesRequest, optionList: OptionList): Promise<HcProductStatusResult[]>;
|
|
377
|
+
GetModelImageHcStatus(modelId: string, config: ModelImageConfig): Promise<HcProductStatusResult>;
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
export function bindApi<TRaw extends JsInteropApiRaw>(rawApi: TRaw): BoundApi<TRaw>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Helper utilities to deal with the OperationResult envelope returned by the WASM interop.
|
|
2
|
+
// - ensureOk(raw) -> returns the data payload or throws an Error enriched with error codes and callId.
|
|
3
|
+
// - bindApi(exportsAsm.PrefConfigurator.Wasm.JsInteropApi) -> proxy that auto-unwraps data for you.
|
|
4
|
+
|
|
5
|
+
export function parse(raw) {
|
|
6
|
+
if (raw === undefined || raw === null || raw === "") throw new Error("Empty response from WASM interop.");
|
|
7
|
+
if (typeof raw === "string") {
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(raw);
|
|
10
|
+
} catch (e) {
|
|
11
|
+
throw new Error("Malformed JSON from WASM interop.");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return raw;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function ensureOk(raw) {
|
|
18
|
+
const res = parse(raw);
|
|
19
|
+
const ok = res?.Ok;
|
|
20
|
+
if (ok) return res?.Data ?? null;
|
|
21
|
+
|
|
22
|
+
const errObj = res?.Error;
|
|
23
|
+
const err = new Error(errObj?.Message ?? "Operation failed.");
|
|
24
|
+
err.code = errObj?.Code;
|
|
25
|
+
err.source = errObj?.Source;
|
|
26
|
+
err.httpStatus = errObj?.HttpStatus;
|
|
27
|
+
err.requestId = errObj?.RequestId;
|
|
28
|
+
err.correlationId = errObj?.CorrelationId;
|
|
29
|
+
err.traceParent = errObj?.TraceParent;
|
|
30
|
+
err.detail = errObj?.Detail;
|
|
31
|
+
err.callId = res?.CallId;
|
|
32
|
+
err.result = res;
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function bindApi(rawApi) {
|
|
37
|
+
return new Proxy(rawApi, {
|
|
38
|
+
get(target, prop) {
|
|
39
|
+
const value = target[prop];
|
|
40
|
+
if (typeof value !== "function") return value;
|
|
41
|
+
return async (...args) => ensureOk(await value(...args));
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
package/main.d.ts
ADDED
package/main.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"private": false,
|
|
3
|
+
"files": [
|
|
4
|
+
"_framework/**",
|
|
5
|
+
"**/*.js",
|
|
6
|
+
"**/*.d.ts",
|
|
7
|
+
"**/*.wasm",
|
|
8
|
+
"index.html",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"description": ".NET WebAssembly SDK that embeds Preference's business logic for building product configurators (windows, doors, joinery) in browser-based ecommerce platforms.",
|
|
12
|
+
"author": "Alex Moreno Palacio <amoreno@preference.es>",
|
|
13
|
+
"types": "main.d.ts",
|
|
14
|
+
"version": "0.1.0-beta.1",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"name": "@preference-sl/pref-configurator-sdk",
|
|
17
|
+
"exports": {
|
|
18
|
+
"./js/prefconfigurator-api": {
|
|
19
|
+
"types": "./js/prefconfigurator-api.d.ts",
|
|
20
|
+
"default": "./js/prefconfigurator-api.js"
|
|
21
|
+
},
|
|
22
|
+
"./package.json": "./package.json",
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./main.d.ts",
|
|
25
|
+
"default": "./main.js"
|
|
26
|
+
},
|
|
27
|
+
"./index.html": "./index.html"
|
|
28
|
+
},
|
|
29
|
+
"main": "main.js",
|
|
30
|
+
"scripts": {
|
|
31
|
+
"postinstall": "node scripts/postinstall.js"
|
|
32
|
+
}
|
|
33
|
+
}
|