Skip to content

Commit

Permalink
chore: format js code
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz authored and NathanWalker committed Jan 27, 2024
1 parent 0f61593 commit 54deb23
Showing 1 changed file with 61 additions and 68 deletions.
129 changes: 61 additions & 68 deletions test-app/runtime/src/main/cpp/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,74 +591,67 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native

Local<Context> context = Context::New(isolate, nullptr, globalTemplate);

auto blob_methods =
"const BLOB_STORE = new Map();\n"
"URL.createObjectURL = function (object, options = null) {\n"
"try {\n"
"if (object instanceof Blob || object instanceof File) {\n"
"const id = java.util.UUID.randomUUID().toString();\n"
"const ret = `blob:nativescript/${id}`;\n"
"BLOB_STORE.set(ret, {\n"
"blob: object,\n"
"type: object?.type,\n"
"ext: options?.ext,\n"
"});\n"
"return ret;\n"
"}\n"
"} catch (error) {\n"
"return null;\n"
"}\n"
"return null;\n"
"};\n"
"\n"
"URL.revokeObjectURL = function (url) {\n"
"BLOB_STORE.delete(url);\n"
"};\n"
"\n"
"const InternalAccessor = class {};\n"
"\n"
"InternalAccessor.getData = function (url) {\n"
"return BLOB_STORE.get(url);\n"
"};\n"
"\n"
"URL.InternalAccessor = InternalAccessor;\n"
"Object.defineProperty(URL.prototype, 'searchParams', {\n"
"get() {\n"
"if (this._searchParams == null) {\n"
"this._searchParams = new URLSearchParams(this.search);\n"
"Object.defineProperty(this._searchParams, '_url', {\n"
"enumerable: false,\n"
"writable: false,\n"
"value: this,\n"
"});\n"
"\n"
"this._searchParams._append = this._searchParams.append;\n"
"this._searchParams.append = function (name, value) {\n"
"this._append(name, value);\n"
"this._url.search = this.toString();\n"
"};\n"
"\n"
"this._searchParams._delete = this._searchParams.delete;\n"
"this._searchParams.delete = function (name) {\n"
"this._delete(name);\n"
"this._url.search = this.toString();\n"
"};\n"
"\n"
"this._searchParams._set = this._searchParams.set;\n"
"this._searchParams.set = function (name, value) {\n"
"this._set(name, value);\n"
"this._url.search = this.toString();\n"
"};\n"
"\n"
"this._searchParams._sort = this._searchParams.sort;\n"
"this._searchParams.sort = function () {\n"
"this._sort();\n"
"this._url.search = this.toString();\n"
"};\n"
"}\n"
"return this._searchParams;\n"
"},\n"
"});";
auto blob_methods = R"js(
const BLOB_STORE = new Map();
URL.createObjectURL = function (object, options = null) {
try {
if (object instanceof Blob || object instanceof File) {
const id = java.util.UUID.randomUUID().toString();
const ret = `blob:nativescript/${id}`;
BLOB_STORE.set(ret, {
blob: object,
type: object?.type,
ext: options?.ext,
});
return ret;
}
} catch (error) {
return null;
}
return null;
};
URL.revokeObjectURL = function (url) {
BLOB_STORE.delete(url);
};
const InternalAccessor = class {};
InternalAccessor.getData = function (url) {
return BLOB_STORE.get(url);
};
URL.InternalAccessor = InternalAccessor;
Object.defineProperty(URL.prototype, 'searchParams', {
get() {
if (this._searchParams == null) {
this._searchParams = new URLSearchParams(this.search);
Object.defineProperty(this._searchParams, '_url', {
enumerable: false,
writable: false,
value: this,
});
this._searchParams._append = this._searchParams.append;
this._searchParams.append = function (name, value) {
this._append(name, value);
this._url.search = this.toString();
};
this._searchParams._delete = this._searchParams.delete;
this._searchParams.delete = function (name) {
this._delete(name);
this._url.search = this.toString();
};
this._searchParams._set = this._searchParams.set;
this._searchParams.set = function (name, value) {
this._set(name, value);
this._url.search = this.toString();
};
this._searchParams._sort = this._searchParams.sort;
this._searchParams.sort = function () {
this._sort();
this._url.search = this.toString();
};
}
return this._searchParams;
},
});
)js";


auto global = context->Global();
Expand Down

0 comments on commit 54deb23

Please sign in to comment.