@coherentglobal/spark-execute-sdk 0.4.11 → 0.4.12
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/dist/browser.js +34 -6
- package/package.json +3 -2
- package/src/browser.js +0 -1
- package/types/browser.d.ts +6 -2
- package/types/browser.d.ts.map +1 -1
- package/types/node.d.ts +4 -1
- package/types/node.d.ts.map +1 -1
package/dist/browser.js
CHANGED
|
@@ -900,13 +900,19 @@ var unzipppedModel = function unzipppedModel(model) {
|
|
|
900
900
|
case 0:
|
|
901
901
|
servicename = model.servicename, wasm = model.wasm, js = model.js, data = model.data, metadata = model.metadata;
|
|
902
902
|
response = {
|
|
903
|
-
wasm: {
|
|
903
|
+
wasm: utils.isFilePath(wasm, "wasm") ? {
|
|
904
|
+
url: new URL(wasm, window.location.origin).toString(),
|
|
905
|
+
path: utils.last(wasm.split("/"))
|
|
906
|
+
} : {
|
|
904
907
|
url: URL.createObjectURL(new Blob([wasm], {
|
|
905
908
|
type: "application/wasm"
|
|
906
909
|
})),
|
|
907
910
|
path: "".concat(servicename, ".wasm")
|
|
908
911
|
},
|
|
909
|
-
js: {
|
|
912
|
+
js: utils.isFilePath(js, "js") ? {
|
|
913
|
+
url: new URL(js, window.location.origin).toString(),
|
|
914
|
+
path: utils.last(js.split("/"))
|
|
915
|
+
} : {
|
|
910
916
|
url: URL.createObjectURL(new Blob([js], {
|
|
911
917
|
type: "text/javascript"
|
|
912
918
|
})),
|
|
@@ -914,7 +920,10 @@ var unzipppedModel = function unzipppedModel(model) {
|
|
|
914
920
|
}
|
|
915
921
|
};
|
|
916
922
|
if (data) {
|
|
917
|
-
response.data = {
|
|
923
|
+
response.data = utils.isFilePath(data, "data") ? {
|
|
924
|
+
url: new URL(data, window.location.origin).toString(),
|
|
925
|
+
path: utils.last(data.split("/"))
|
|
926
|
+
} : {
|
|
918
927
|
url: URL.createObjectURL(new Blob([data], {
|
|
919
928
|
type: "application/octet-stream"
|
|
920
929
|
})),
|
|
@@ -922,7 +931,10 @@ var unzipppedModel = function unzipppedModel(model) {
|
|
|
922
931
|
};
|
|
923
932
|
}
|
|
924
933
|
if (metadata) {
|
|
925
|
-
response.metadata = {
|
|
934
|
+
response.metadata = utils.isFilePath(metadata, "json") ? {
|
|
935
|
+
url: new URL(metadata, window.location.origin).toString(),
|
|
936
|
+
path: utils.last(metadata.split("/"))
|
|
937
|
+
} : {
|
|
926
938
|
url: URL.createObjectURL(new Blob([metadata], {
|
|
927
939
|
type: "application/json"
|
|
928
940
|
})),
|
|
@@ -966,7 +978,7 @@ var getRuntimeContent = function getRuntimeContent(js, wasm) {
|
|
|
966
978
|
}, _callee7);
|
|
967
979
|
}));
|
|
968
980
|
}).then(function (text) {
|
|
969
|
-
return text.replace(wasm.path, wasm.url).replace(data.path, data.url).replace(data.path, data.url);
|
|
981
|
+
return text.replace(wasm.path, wasm.url).replace("\"".concat(data.path, "\""), "\"".concat(data.url, "\"")).replace("\"".concat(data.path, "\""), "\"".concat(data.url, "\"")).replace("'".concat(data.path, "'"), "'".concat(data.url, "'")).replace("'".concat(data.path, "'"), "'".concat(data.url, "'"));
|
|
970
982
|
});
|
|
971
983
|
case 3:
|
|
972
984
|
_runtime = _context9.sent;
|
|
@@ -1710,7 +1722,7 @@ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
|
1710
1722
|
Object.defineProperty(exports, "__esModule", {
|
|
1711
1723
|
value: true
|
|
1712
1724
|
});
|
|
1713
|
-
exports.addScript = exports.isEmpty = exports.fn2workerURL = exports.jsString2workerURL = exports.isCompatible = exports.isWorkerSupported = exports.isWasmSupported = exports.isBrowser = exports.isHttpURL = exports.isPath = exports.ENVIRONMENT_IS_NODE = exports.ENVIRONMENT_IS_WEB = void 0;
|
|
1725
|
+
exports.last = exports.addScript = exports.isEmpty = exports.fn2workerURL = exports.jsString2workerURL = exports.isCompatible = exports.isWorkerSupported = exports.isWasmSupported = exports.isBrowser = exports.isFilePath = exports.isHttpURL = exports.isPath = exports.ENVIRONMENT_IS_NODE = exports.ENVIRONMENT_IS_WEB = void 0;
|
|
1714
1726
|
var fs_1 = __importDefault(require("fs"));
|
|
1715
1727
|
var url_1 = __importDefault(require("url"));
|
|
1716
1728
|
var error_1 = __importDefault(require("./error"));
|
|
@@ -1757,6 +1769,11 @@ function isHttpURL(str) {
|
|
|
1757
1769
|
return urlInstance.protocol === "http:" || urlInstance.protocol === "https:";
|
|
1758
1770
|
}
|
|
1759
1771
|
exports.isHttpURL = isHttpURL;
|
|
1772
|
+
function isFilePath(str, ext) {
|
|
1773
|
+
var idx = str.indexOf(".".concat(ext));
|
|
1774
|
+
return idx > -1 && idx === str.length - ".".concat(ext).length;
|
|
1775
|
+
}
|
|
1776
|
+
exports.isFilePath = isFilePath;
|
|
1760
1777
|
function isBrowser() {
|
|
1761
1778
|
try {
|
|
1762
1779
|
// eslint-disable-next-line no-undef
|
|
@@ -1829,6 +1846,17 @@ function addScript(src) {
|
|
|
1829
1846
|
document.body.appendChild(s);
|
|
1830
1847
|
}
|
|
1831
1848
|
exports.addScript = addScript;
|
|
1849
|
+
function last(arr) {
|
|
1850
|
+
if (!Array.isArray(arr)) {
|
|
1851
|
+
throw new Error("Argument is not array");
|
|
1852
|
+
}
|
|
1853
|
+
var length = arr.length;
|
|
1854
|
+
if (length === 0) {
|
|
1855
|
+
return undefined;
|
|
1856
|
+
}
|
|
1857
|
+
return arr[length - 1];
|
|
1858
|
+
}
|
|
1859
|
+
exports.last = last;
|
|
1832
1860
|
|
|
1833
1861
|
}).call(this)}).call(this,require('_process'))
|
|
1834
1862
|
},{"./error":22,"@babel/runtime/helpers/interopRequireDefault":9,"@babel/runtime/helpers/typeof":17,"@babel/runtime/regenerator":19,"_process":36,"fs":25,"url":42}],24:[function(require,module,exports){
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coherentglobal/spark-execute-sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/node.js",
|
|
6
6
|
"browser": "dist/browser.js",
|
|
7
7
|
"types": "types/node.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
+
"build": "npm run build:types && npm run bundle:full && npm run bundle:min",
|
|
9
10
|
"build:types": "tsc --declaration",
|
|
10
11
|
"bundle:full": "browserify src/browser.js --standalone Spark > dist/browser.js",
|
|
11
12
|
"bundle:min": "browserify src/browser.js --standalone Spark | uglifyjs --compress --mangle --comments false > lib/sparkexecute.min.js",
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
"author": "",
|
|
23
24
|
"license": "ISC",
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@coherentglobal/wasm-runner": "^0.0.
|
|
26
|
+
"@coherentglobal/wasm-runner": "^0.0.63",
|
|
26
27
|
"@types/node": "^18.7.18",
|
|
27
28
|
"axios": "^0.27.2",
|
|
28
29
|
"chai": "^4.3.6",
|
package/src/browser.js
CHANGED
|
@@ -164,7 +164,6 @@ class Spark {
|
|
|
164
164
|
async offlineModel(input, versionID) {
|
|
165
165
|
const model = findModel(input.request_meta, this.model);
|
|
166
166
|
const modelVersionId = versionID || (model && model?.versionId);
|
|
167
|
-
|
|
168
167
|
if (!input?.request_meta) {
|
|
169
168
|
input.request_meta = {};
|
|
170
169
|
}
|
package/types/browser.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ declare class Spark {
|
|
|
4
4
|
* @param {object} config
|
|
5
5
|
*/
|
|
6
6
|
constructor(config: object, options?: {});
|
|
7
|
+
/**
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
private _registry;
|
|
7
11
|
logger: any;
|
|
8
12
|
/**
|
|
9
13
|
* @private
|
|
@@ -65,7 +69,7 @@ declare class Spark {
|
|
|
65
69
|
* @returns {object}
|
|
66
70
|
*/
|
|
67
71
|
execute(input: object, version_id?: string | undefined): object;
|
|
68
|
-
offlineModel(input: any, versionID: any
|
|
69
|
-
onlineModelEndpoint(input: any, versionID: any
|
|
72
|
+
offlineModel(input: any, versionID: any): Promise<unknown>;
|
|
73
|
+
onlineModelEndpoint(input: any, versionID: any): Promise<any>;
|
|
70
74
|
}
|
|
71
75
|
//# sourceMappingURL=browser.d.ts.map
|
package/types/browser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.js"],"names":[],"mappings":";AASA;IACE;;OAEG;IACH,oBAFW,MAAM,
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.js"],"names":[],"mappings":";AASA;IACE;;OAEG;IACH,oBAFW,MAAM,gBAqDhB;IAlDC;;MAEE;IACF,kBAA0B;IAMxB,YAAyB;IAG3B;;OAEG;IACH,eAAyC;IAEzC;;OAEG;IACH,eAAsD;IACtD;;OAEG;IACH,iBAA0D;IAC1D;;OAEG;IACH,cAGI;IACJ;;OAEG;IACH,YAAgD;IAChD;;OAEG;IACH,qBAA2C;IAE3C;;OAEG;IACH,iBAA2C;IAE3C;;MAEE;IACF,cAAqD;IAGvD,oBAEC;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACJ,MAAM,CAgBlB;IACD;;;;OAIG;IACH,uBAHW,MAAM,GACJ,MAAM,CAgBlB;IACD;;;;OAIG;IACH,cAHW,MAAM,GACJ,OAAO,CAOnB;IAED,wDASC;IAED;;;;;;OAMG;IACH,eAJW,MAAM,oCAEJ,MAAM,CAuBlB;IAED,2DAsEC;IAED,8DA6CC;CACF"}
|
package/types/node.d.ts
CHANGED
package/types/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.js"],"names":[],"mappings":";AAeA;IACE;;OAEG;IACH,oBAFW,MAAM,+
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.js"],"names":[],"mappings":";AAeA;IACE;;OAEG;IACH,oBAFW,MAAM,+CAoEhB;IAjEC;;OAEG;IACH,kBAA0B;IAGxB,SAAsB;IAGxB;;MAEE;IACF,mBAA4E;IAU1E,eAAsB;IAMxB;;OAEG;IACH,eAAsD;IACtD;;OAEG;IACH,iBAA0D;IAC1D;;OAEG;IACH,cAGI;IACJ;;OAEG;IACH,YAAgD;IAChD;;OAEG;IACH,qBAA2C;IAC3C;;OAEG;IACH,cAAqD;IAErD;;OAEG;IACH,yBAAmD;IAEnD;;OAEG;IACH,iBAA2C;IAG7C;;;;OAIG;IACH,iBAHW,MAAM,GACJ,MAAM,CAKlB;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACJ,MAAM,CAelB;IAED;;;;;;OAMG;IACH,eAJW,MAAM,oCAEJ,MAAM,CAqBlB;IAED,+BAkFC;IAED,wDAUC;IAED,uBAKC;IAED;;OAEG;IAGH,2DAkCC;IAED,8DA6CC;CACF"}
|