|
92 | 92 | Array.prototype.slice.call(arguments, 1) |
93 | 93 | ); |
94 | 94 | } else { |
95 | | - thiz = new (Function.prototype.bind.apply( |
| 95 | + thiz = new (Function.prototype.bind.apply( |
96 | 96 | Extended, |
97 | 97 | [null].concat(Array.prototype.slice.call(arguments, 1)) |
98 | 98 | ))(); |
99 | 99 | } |
100 | 100 | } else { |
101 | | - thiz = new Extended(); |
| 101 | + thiz = new Extended(); |
102 | 102 | } |
103 | 103 | return thiz; |
104 | 104 | }; |
|
107 | 107 | var Extended = extend(thiz); |
108 | 108 | thiz.__container__ = true; |
109 | 109 | if (args && args.length > 0) { |
110 | | - if (typeof Extended !== "function") { |
111 | | - thiz = Reflect.construct( |
112 | | - Extended, |
113 | | - [null].concat(args) |
114 | | - ); |
115 | | - } else { |
116 | | - thiz = new (Function.prototype.bind.apply( |
117 | | - Extended, |
118 | | - [null].concat(args) |
119 | | - ))(); |
120 | | - } |
| 110 | + if (typeof Extended !== "function") { |
| 111 | + thiz = Reflect.construct(Extended, [null].concat(args)); |
| 112 | + } else { |
| 113 | + thiz = new (Function.prototype.bind.apply( |
| 114 | + Extended, |
| 115 | + [null].concat(args) |
| 116 | + ))(); |
| 117 | + } |
121 | 118 | } else { |
122 | 119 | thiz = new Extended(); |
123 | 120 | } |
|
279 | 276 | return undefined; |
280 | 277 | } |
281 | 278 |
|
282 | | -globalThis.__prepareHostObject = function (hostObject, jsThis) { |
283 | | -// const prototype = Object.getPrototypeOf(jsThis); |
284 | | -// Object.setPrototypeOf(hostObject, prototype); |
285 | | - Object.defineProperty(hostObject, "super", { |
286 | | - get: () => jsThis["super"], |
| 279 | + globalThis.__prepareHostObject = function (hostObject, jsThis) { |
| 280 | + // const prototype = Object.getPrototypeOf(jsThis); |
| 281 | + // Object.setPrototypeOf(hostObject, prototype); |
| 282 | + Object.defineProperty(hostObject, "super", { |
| 283 | + get: () => jsThis["super"], |
287 | 284 | }); |
288 | | -}; |
289 | | - |
| 285 | + }; |
| 286 | + |
290 | 287 | const EXTERNAL_PROP = "[[external]]"; |
291 | 288 | const REFERENCE_PROP_JSC = "[[jsc_reference_info]]"; |
292 | 289 |
|
@@ -331,4 +328,66 @@ globalThis.__prepareHostObject = function (hostObject, jsThis) { |
331 | 328 | lines[2] = " at extend(native)"; |
332 | 329 | return lines.join("\n"); |
333 | 330 | }; |
| 331 | + |
| 332 | + if (globalThis.URL) { |
| 333 | + const BLOB_STORE = new Map(); |
| 334 | + URL.createObjectURL = function (object, options = null) { |
| 335 | + try { |
| 336 | + if (object instanceof Blob || object instanceof File) { |
| 337 | + const id = java.util.UUID.randomUUID().toString(); |
| 338 | + const ret = `blob:nativescript/${id}`; |
| 339 | + BLOB_STORE.set(ret, { |
| 340 | + blob: object, |
| 341 | + type: object?.type, |
| 342 | + ext: options?.ext, |
| 343 | + }); |
| 344 | + return ret; |
| 345 | + } |
| 346 | + } catch (error) { |
| 347 | + return null; |
| 348 | + } |
| 349 | + return null; |
| 350 | + }; |
| 351 | + URL.revokeObjectURL = function (url) { |
| 352 | + BLOB_STORE.delete(url); |
| 353 | + }; |
| 354 | + const InternalAccessor = class {}; |
| 355 | + InternalAccessor.getData = function (url) { |
| 356 | + return BLOB_STORE.get(url); |
| 357 | + }; |
| 358 | + URL.InternalAccessor = InternalAccessor; |
| 359 | + Object.defineProperty(URL.prototype, "searchParams", { |
| 360 | + get() { |
| 361 | + if (this._searchParams == null) { |
| 362 | + this._searchParams = new URLSearchParams(this.search); |
| 363 | + Object.defineProperty(this._searchParams, "_url", { |
| 364 | + enumerable: false, |
| 365 | + writable: false, |
| 366 | + value: this, |
| 367 | + }); |
| 368 | + this._searchParams._append = this._searchParams.append; |
| 369 | + this._searchParams.append = function (name, value) { |
| 370 | + this._append(name, value); |
| 371 | + this._url.search = this.toString(); |
| 372 | + }; |
| 373 | + this._searchParams._delete = this._searchParams.delete; |
| 374 | + this._searchParams.delete = function (name) { |
| 375 | + this._delete(name); |
| 376 | + this._url.search = this.toString(); |
| 377 | + }; |
| 378 | + this._searchParams._set = this._searchParams.set; |
| 379 | + this._searchParams.set = function (name, value) { |
| 380 | + this._set(name, value); |
| 381 | + this._url.search = this.toString(); |
| 382 | + }; |
| 383 | + this._searchParams._sort = this._searchParams.sort; |
| 384 | + this._searchParams.sort = function () { |
| 385 | + this._sort(); |
| 386 | + this._url.search = this.toString(); |
| 387 | + }; |
| 388 | + } |
| 389 | + return this._searchParams; |
| 390 | + }, |
| 391 | + }); |
| 392 | + } |
334 | 393 | })(); |
0 commit comments