@@ -591,74 +591,67 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native
591
591
592
592
Local<Context> context = Context::New (isolate, nullptr , globalTemplate);
593
593
594
- auto blob_methods =
595
- " const BLOB_STORE = new Map();\n "
596
- " URL.createObjectURL = function (object, options = null) {\n "
597
- " try {\n "
598
- " if (object instanceof Blob || object instanceof File) {\n "
599
- " const id = java.util.UUID.randomUUID().toString();\n "
600
- " const ret = `blob:nativescript/${id}`;\n "
601
- " BLOB_STORE.set(ret, {\n "
602
- " blob: object,\n "
603
- " type: object?.type,\n "
604
- " ext: options?.ext,\n "
605
- " });\n "
606
- " return ret;\n "
607
- " }\n "
608
- " } catch (error) {\n "
609
- " return null;\n "
610
- " }\n "
611
- " return null;\n "
612
- " };\n "
613
- " \n "
614
- " URL.revokeObjectURL = function (url) {\n "
615
- " BLOB_STORE.delete(url);\n "
616
- " };\n "
617
- " \n "
618
- " const InternalAccessor = class {};\n "
619
- " \n "
620
- " InternalAccessor.getData = function (url) {\n "
621
- " return BLOB_STORE.get(url);\n "
622
- " };\n "
623
- " \n "
624
- " URL.InternalAccessor = InternalAccessor;\n "
625
- " Object.defineProperty(URL.prototype, 'searchParams', {\n "
626
- " get() {\n "
627
- " if (this._searchParams == null) {\n "
628
- " this._searchParams = new URLSearchParams(this.search);\n "
629
- " Object.defineProperty(this._searchParams, '_url', {\n "
630
- " enumerable: false,\n "
631
- " writable: false,\n "
632
- " value: this,\n "
633
- " });\n "
634
- " \n "
635
- " this._searchParams._append = this._searchParams.append;\n "
636
- " this._searchParams.append = function (name, value) {\n "
637
- " this._append(name, value);\n "
638
- " this._url.search = this.toString();\n "
639
- " };\n "
640
- " \n "
641
- " this._searchParams._delete = this._searchParams.delete;\n "
642
- " this._searchParams.delete = function (name) {\n "
643
- " this._delete(name);\n "
644
- " this._url.search = this.toString();\n "
645
- " };\n "
646
- " \n "
647
- " this._searchParams._set = this._searchParams.set;\n "
648
- " this._searchParams.set = function (name, value) {\n "
649
- " this._set(name, value);\n "
650
- " this._url.search = this.toString();\n "
651
- " };\n "
652
- " \n "
653
- " this._searchParams._sort = this._searchParams.sort;\n "
654
- " this._searchParams.sort = function () {\n "
655
- " this._sort();\n "
656
- " this._url.search = this.toString();\n "
657
- " };\n "
658
- " }\n "
659
- " return this._searchParams;\n "
660
- " },\n "
661
- " });" ;
594
+ auto blob_methods = R"js(
595
+ const BLOB_STORE = new Map();
596
+ URL.createObjectURL = function (object, options = null) {
597
+ try {
598
+ if (object instanceof Blob || object instanceof File) {
599
+ const id = java.util.UUID.randomUUID().toString();
600
+ const ret = `blob:nativescript/${id}`;
601
+ BLOB_STORE.set(ret, {
602
+ blob: object,
603
+ type: object?.type,
604
+ ext: options?.ext,
605
+ });
606
+ return ret;
607
+ }
608
+ } catch (error) {
609
+ return null;
610
+ }
611
+ return null;
612
+ };
613
+ URL.revokeObjectURL = function (url) {
614
+ BLOB_STORE.delete(url);
615
+ };
616
+ const InternalAccessor = class {};
617
+ InternalAccessor.getData = function (url) {
618
+ return BLOB_STORE.get(url);
619
+ };
620
+ URL.InternalAccessor = InternalAccessor;
621
+ Object.defineProperty(URL.prototype, 'searchParams', {
622
+ get() {
623
+ if (this._searchParams == null) {
624
+ this._searchParams = new URLSearchParams(this.search);
625
+ Object.defineProperty(this._searchParams, '_url', {
626
+ enumerable: false,
627
+ writable: false,
628
+ value: this,
629
+ });
630
+ this._searchParams._append = this._searchParams.append;
631
+ this._searchParams.append = function (name, value) {
632
+ this._append(name, value);
633
+ this._url.search = this.toString();
634
+ };
635
+ this._searchParams._delete = this._searchParams.delete;
636
+ this._searchParams.delete = function (name) {
637
+ this._delete(name);
638
+ this._url.search = this.toString();
639
+ };
640
+ this._searchParams._set = this._searchParams.set;
641
+ this._searchParams.set = function (name, value) {
642
+ this._set(name, value);
643
+ this._url.search = this.toString();
644
+ };
645
+ this._searchParams._sort = this._searchParams.sort;
646
+ this._searchParams.sort = function () {
647
+ this._sort();
648
+ this._url.search = this.toString();
649
+ };
650
+ }
651
+ return this._searchParams;
652
+ },
653
+ });
654
+ )js" ;
662
655
663
656
664
657
auto global = context->Global ();
0 commit comments