@expo/metro-runtime 1.1.1 → 2.0.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/build/async-require/fetchThenEval.web.d.ts.map +1 -1
- package/build/async-require/fetchThenEval.web.js +3 -0
- package/build/async-require/fetchThenEval.web.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/location/Location.d.ts +3 -0
- package/build/location/Location.d.ts.map +1 -0
- package/build/location/Location.js +8 -0
- package/build/location/Location.js.map +1 -0
- package/build/location/Location.native.d.ts +3 -0
- package/build/location/Location.native.d.ts.map +1 -0
- package/build/location/Location.native.js +195 -0
- package/build/location/Location.native.js.map +1 -0
- package/build/location/install.d.ts +1 -0
- package/build/location/install.d.ts.map +1 -0
- package/build/location/install.js +2 -0
- package/build/location/install.js.map +1 -0
- package/build/location/install.native.d.ts +2 -0
- package/build/location/install.native.d.ts.map +1 -0
- package/build/location/install.native.js +75 -0
- package/build/location/install.native.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchThenEval.web.d.ts","sourceRoot":"","sources":["../../src/async-require/fetchThenEval.web.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,EACE,UAAU,EACV,KAAK,EACL,WAAW,GACZ,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GACpE,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"fetchThenEval.web.d.ts","sourceRoot":"","sources":["../../src/async-require/fetchThenEval.web.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,EACE,UAAU,EACV,KAAK,EACL,WAAW,GACZ,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GACpE,OAAO,CAAC,IAAI,CAAC,CA2Df"}
|
|
@@ -9,6 +9,9 @@ exports.fetchThenEvalAsync = void 0;
|
|
|
9
9
|
*/
|
|
10
10
|
// Basically `__webpack_require__.l`.
|
|
11
11
|
function fetchThenEvalAsync(url, { scriptType, nonce, crossOrigin, } = {}) {
|
|
12
|
+
if (typeof document === "undefined") {
|
|
13
|
+
throw new Error("Cannot use fetchThenEvalAsync in a non-browser environment.");
|
|
14
|
+
}
|
|
12
15
|
return new Promise((resolve, reject) => {
|
|
13
16
|
const script = document.createElement("script");
|
|
14
17
|
if (scriptType)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchThenEval.web.js","sourceRoot":"","sources":["../../src/async-require/fetchThenEval.web.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,qCAAqC;AACrC,SAAgB,kBAAkB,CAChC,GAAW,EACX,EACE,UAAU,EACV,KAAK,EACL,WAAW,MACsD,EAAE;IAErE,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAI,UAAU;YAAE,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC;QACzC,IAAI,KAAK;YAAE,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC/C,+CAA+C;QAC/C,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;QAEjB,IAAI,WAAW,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE;YACzE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B,KAAK,GAAG;oBACN,IAAI,EAAE,OAAO;oBACb,MAAM,EAAE;wBACN,mBAAmB;wBACnB,GAAG,EAAE,KAAK;qBACX;iBACF,CAAC;aACH;iBAAM;gBACL,KAAK,GAAG,EAAE,CAAC;aACZ;YAED,MAAM,SAAS,GACb,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5D,mBAAmB;YACnB,MAAM,OAAO,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,0CAAE,GAAG,CAAC;YACnC,KAAK,CAAC,OAAO;gBACX,iBAAiB;oBACjB,GAAG;oBACH,aAAa;oBACb,SAAS;oBACT,IAAI;oBACJ,OAAO;oBACP,GAAG,CAAC;YACN,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC;YACvB,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;YAExB,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAC3D,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC;QACF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC;AAlED,gDAkEC;AAED,MAAM,iBAAkB,SAAQ,KAAK;IAArC;;QACW,SAAI,GAAG,mBAAmB,CAAC;IAGtC,CAAC;CAAA","sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n// Basically `__webpack_require__.l`.\nexport function fetchThenEvalAsync(\n url: string,\n {\n scriptType,\n nonce,\n crossOrigin,\n }: { scriptType?: string; nonce?: string; crossOrigin?: string } = {}\n): Promise<void> {\n if (typeof document === \"undefined\") {\n throw new Error(\n \"Cannot use fetchThenEvalAsync in a non-browser environment.\"\n );\n }\n return new Promise<void>((resolve, reject) => {\n const script = document.createElement(\"script\");\n if (scriptType) script.type = scriptType;\n if (nonce) script.setAttribute(\"nonce\", nonce);\n // script.setAttribute('data-expo-metro', ...);\n script.src = url;\n\n if (crossOrigin && script.src.indexOf(window.location.origin + \"/\") !== 0) {\n script.crossOrigin = crossOrigin;\n }\n\n script.onload = () => {\n script.parentNode && script.parentNode.removeChild(script);\n resolve();\n };\n // Create a new error object to preserve the original stack trace.\n const error = new AsyncRequireError();\n\n // Server error or network error.\n script.onerror = (ev) => {\n let event: Event;\n if (typeof ev === \"string\") {\n event = {\n type: \"error\",\n target: {\n // @ts-expect-error\n src: event,\n },\n };\n } else {\n event = ev;\n }\n\n const errorType =\n event && (event.type === \"load\" ? \"missing\" : event.type);\n // @ts-expect-error\n const realSrc = event?.target?.src;\n error.message =\n \"Loading module \" +\n url +\n \" failed.\\n(\" +\n errorType +\n \": \" +\n realSrc +\n \")\";\n error.type = errorType;\n error.request = realSrc;\n\n script.parentNode && script.parentNode.removeChild(script);\n reject(error);\n };\n document.head.appendChild(script);\n });\n}\n\nclass AsyncRequireError extends Error {\n readonly name = \"AsyncRequireError\";\n type?: string;\n request?: string;\n}\n"]}
|
package/build/index.d.ts
CHANGED
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,WAAW,CAAC"}
|
package/build/index.js
CHANGED
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,qBAAmB","sourcesContent":["import \"./effects\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,8BAA4B;AAC5B,qBAAmB","sourcesContent":["import \"./location/install\";\nimport \"./effects\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Location.d.ts","sourceRoot":"","sources":["../../src/location/Location.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,SAAK;AAE5B,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,QAAI"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setLocationHref = exports.install = void 0;
|
|
4
|
+
function install() { }
|
|
5
|
+
exports.install = install;
|
|
6
|
+
function setLocationHref(href) { }
|
|
7
|
+
exports.setLocationHref = setLocationHref;
|
|
8
|
+
//# sourceMappingURL=Location.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Location.js","sourceRoot":"","sources":["../../src/location/Location.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO,KAAI,CAAC;AAA5B,0BAA4B;AAE5B,SAAgB,eAAe,CAAC,IAAY,IAAG,CAAC;AAAhD,0CAAgD","sourcesContent":["export function install() {}\n\nexport function setLocationHref(href: string) {}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Location.native.d.ts","sourceRoot":"","sources":["../../src/location/Location.native.ts"],"names":[],"mappings":"AAiNA,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,QAE3C;AAED,wBAAgB,OAAO,SAgBtB"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright © 2023 650 Industries.
|
|
3
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.install = exports.setLocationHref = void 0;
|
|
9
|
+
const url_parse_1 = __importDefault(require("url-parse"));
|
|
10
|
+
class DOMException extends Error {
|
|
11
|
+
constructor(message, name) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = name;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// The differences between the definitions of `Location` and `WorkerLocation`
|
|
17
|
+
// are because of the `LegacyUnforgeable` attribute only specified upon
|
|
18
|
+
// `Location`'s properties. See:
|
|
19
|
+
// - https://html.spec.whatwg.org/multipage/history.html#the-location-interface
|
|
20
|
+
// - https://heycam.github.io/webidl/#LegacyUnforgeable
|
|
21
|
+
class Location {
|
|
22
|
+
constructor(href = null) {
|
|
23
|
+
const url = new url_parse_1.default(
|
|
24
|
+
// @ts-expect-error
|
|
25
|
+
href);
|
|
26
|
+
// @ts-expect-error
|
|
27
|
+
url.username = "";
|
|
28
|
+
// @ts-expect-error
|
|
29
|
+
url.password = "";
|
|
30
|
+
Object.defineProperties(this, {
|
|
31
|
+
hash: {
|
|
32
|
+
get() {
|
|
33
|
+
return url.hash;
|
|
34
|
+
},
|
|
35
|
+
set() {
|
|
36
|
+
throw new DOMException(`Cannot set "location.hash".`, "NotSupportedError");
|
|
37
|
+
},
|
|
38
|
+
enumerable: true,
|
|
39
|
+
},
|
|
40
|
+
host: {
|
|
41
|
+
get() {
|
|
42
|
+
return url.host;
|
|
43
|
+
},
|
|
44
|
+
set() {
|
|
45
|
+
throw new DOMException(`Cannot set "location.host".`, "NotSupportedError");
|
|
46
|
+
},
|
|
47
|
+
enumerable: true,
|
|
48
|
+
},
|
|
49
|
+
hostname: {
|
|
50
|
+
get() {
|
|
51
|
+
return url.hostname;
|
|
52
|
+
},
|
|
53
|
+
set() {
|
|
54
|
+
throw new DOMException(`Cannot set "location.hostname".`, "NotSupportedError");
|
|
55
|
+
},
|
|
56
|
+
enumerable: true,
|
|
57
|
+
},
|
|
58
|
+
href: {
|
|
59
|
+
get() {
|
|
60
|
+
return url.href;
|
|
61
|
+
},
|
|
62
|
+
set() {
|
|
63
|
+
throw new DOMException(`Cannot set "location.href".`, "NotSupportedError");
|
|
64
|
+
},
|
|
65
|
+
enumerable: true,
|
|
66
|
+
},
|
|
67
|
+
origin: {
|
|
68
|
+
get() {
|
|
69
|
+
return url.origin;
|
|
70
|
+
},
|
|
71
|
+
enumerable: true,
|
|
72
|
+
},
|
|
73
|
+
pathname: {
|
|
74
|
+
get() {
|
|
75
|
+
return url.pathname;
|
|
76
|
+
},
|
|
77
|
+
set() {
|
|
78
|
+
throw new DOMException(`Cannot set "location.pathname".`, "NotSupportedError");
|
|
79
|
+
},
|
|
80
|
+
enumerable: true,
|
|
81
|
+
},
|
|
82
|
+
port: {
|
|
83
|
+
get() {
|
|
84
|
+
return url.port;
|
|
85
|
+
},
|
|
86
|
+
set() {
|
|
87
|
+
throw new DOMException(`Cannot set "location.port".`, "NotSupportedError");
|
|
88
|
+
},
|
|
89
|
+
enumerable: true,
|
|
90
|
+
},
|
|
91
|
+
protocol: {
|
|
92
|
+
get() {
|
|
93
|
+
return url.protocol;
|
|
94
|
+
},
|
|
95
|
+
set() {
|
|
96
|
+
throw new DOMException(`Cannot set "location.protocol".`, "NotSupportedError");
|
|
97
|
+
},
|
|
98
|
+
enumerable: true,
|
|
99
|
+
},
|
|
100
|
+
search: {
|
|
101
|
+
get() {
|
|
102
|
+
// @ts-expect-error
|
|
103
|
+
return url.search;
|
|
104
|
+
},
|
|
105
|
+
set() {
|
|
106
|
+
throw new DOMException(`Cannot set "location.search".`, "NotSupportedError");
|
|
107
|
+
},
|
|
108
|
+
enumerable: true,
|
|
109
|
+
},
|
|
110
|
+
ancestorOrigins: {
|
|
111
|
+
get() {
|
|
112
|
+
return {
|
|
113
|
+
length: 0,
|
|
114
|
+
item: () => null,
|
|
115
|
+
contains: () => false,
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
enumerable: true,
|
|
119
|
+
},
|
|
120
|
+
assign: {
|
|
121
|
+
value: function assign() {
|
|
122
|
+
throw new DOMException(`Cannot call "location.assign()".`, "NotSupportedError");
|
|
123
|
+
},
|
|
124
|
+
enumerable: true,
|
|
125
|
+
},
|
|
126
|
+
reload: {
|
|
127
|
+
value: function reload() {
|
|
128
|
+
if (process.env.NODE_ENV !== "production") {
|
|
129
|
+
const DevSettings = require("react-native").DevSettings;
|
|
130
|
+
DevSettings.reload();
|
|
131
|
+
}
|
|
132
|
+
throw new DOMException(`Cannot call "location.reload()".`, "NotSupportedError");
|
|
133
|
+
},
|
|
134
|
+
enumerable: true,
|
|
135
|
+
},
|
|
136
|
+
replace: {
|
|
137
|
+
value: function replace() {
|
|
138
|
+
throw new DOMException(`Cannot call "location.replace()".`, "NotSupportedError");
|
|
139
|
+
},
|
|
140
|
+
enumerable: true,
|
|
141
|
+
},
|
|
142
|
+
toString: {
|
|
143
|
+
value: function toString() {
|
|
144
|
+
return url.href;
|
|
145
|
+
},
|
|
146
|
+
enumerable: true,
|
|
147
|
+
},
|
|
148
|
+
[Symbol.for("Expo.privateCustomInspect")]: {
|
|
149
|
+
value(inspect) {
|
|
150
|
+
const object = {
|
|
151
|
+
hash: this.hash,
|
|
152
|
+
host: this.host,
|
|
153
|
+
hostname: this.hostname,
|
|
154
|
+
href: this.href,
|
|
155
|
+
origin: this.origin,
|
|
156
|
+
pathname: this.pathname,
|
|
157
|
+
port: this.port,
|
|
158
|
+
protocol: this.protocol,
|
|
159
|
+
search: this.search,
|
|
160
|
+
};
|
|
161
|
+
return `${this.constructor.name} ${inspect(object)}`;
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
Object.defineProperties(Location.prototype, {
|
|
168
|
+
[Symbol.toString()]: {
|
|
169
|
+
value: "Location",
|
|
170
|
+
configurable: true,
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
let location = undefined;
|
|
174
|
+
function setLocationHref(href) {
|
|
175
|
+
location = new Location(href);
|
|
176
|
+
}
|
|
177
|
+
exports.setLocationHref = setLocationHref;
|
|
178
|
+
function install() {
|
|
179
|
+
Object.defineProperty(global, "Location", {
|
|
180
|
+
value: Location,
|
|
181
|
+
configurable: true,
|
|
182
|
+
writable: true,
|
|
183
|
+
});
|
|
184
|
+
Object.defineProperty(window, "location", {
|
|
185
|
+
get() {
|
|
186
|
+
return location;
|
|
187
|
+
},
|
|
188
|
+
set() {
|
|
189
|
+
throw new DOMException(`Cannot set "location".`, "NotSupportedError");
|
|
190
|
+
},
|
|
191
|
+
enumerable: true,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
exports.install = install;
|
|
195
|
+
//# sourceMappingURL=Location.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Location.native.js","sourceRoot":"","sources":["../../src/location/Location.native.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,0EAA0E;;;;;;AAE1E,0DAA4B;AAE5B,MAAM,YAAa,SAAQ,KAAK;IAC9B,YAAY,OAAe,EAAE,IAAY;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,6EAA6E;AAC7E,uEAAuE;AACvE,gCAAgC;AAChC,+EAA+E;AAC/E,uDAAuD;AACvD,MAAM,QAAQ;IACZ,YAAY,OAAsB,IAAI;QACpC,MAAM,GAAG,GAAG,IAAI,mBAAG;QACjB,mBAAmB;QACnB,IAAI,CACL,CAAC;QACF,mBAAmB;QACnB,GAAG,CAAC,QAAQ,GAAG,EAAE,CAAC;QAClB,mBAAmB;QACnB,GAAG,CAAC,QAAQ,GAAG,EAAE,CAAC;QAClB,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE;YAC5B,IAAI,EAAE;gBACJ,GAAG;oBACD,OAAO,GAAG,CAAC,IAAI,CAAC;gBACl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B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IAEH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE;QACxC,GAAG;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,GAAG;YACD,MAAM,IAAI,YAAY,CAAC,wBAAwB,EAAE,mBAAmB,CAAC,CAAC;QACxE,CAAC;QACD,UAAU,EAAE,IAAI;KACjB,CAAC,CAAC;AACL,CAAC;AAhBD,0BAgBC","sourcesContent":["// Copyright © 2023 650 Industries.\n// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.\n\nimport URL from \"url-parse\";\n\nclass DOMException extends Error {\n constructor(message: string, name: string) {\n super(message);\n this.name = name;\n }\n}\n\n// The differences between the definitions of `Location` and `WorkerLocation`\n// are because of the `LegacyUnforgeable` attribute only specified upon\n// `Location`'s properties. See:\n// - https://html.spec.whatwg.org/multipage/history.html#the-location-interface\n// - https://heycam.github.io/webidl/#LegacyUnforgeable\nclass Location {\n constructor(href: string | null = null) {\n const url = new URL(\n // @ts-expect-error\n href\n );\n // @ts-expect-error\n url.username = \"\";\n // @ts-expect-error\n url.password = \"\";\n Object.defineProperties(this, {\n hash: {\n get() {\n return url.hash;\n },\n set() {\n throw new DOMException(\n `Cannot set \"location.hash\".`,\n \"NotSupportedError\"\n );\n },\n enumerable: true,\n },\n host: {\n get() {\n return url.host;\n },\n set() {\n throw new DOMException(\n `Cannot set \"location.host\".`,\n \"NotSupportedError\"\n );\n },\n enumerable: true,\n },\n hostname: {\n get() {\n return url.hostname;\n },\n set() {\n throw new DOMException(\n `Cannot set \"location.hostname\".`,\n \"NotSupportedError\"\n );\n },\n enumerable: true,\n },\n href: {\n get() {\n return url.href;\n },\n set() {\n throw new DOMException(\n `Cannot set \"location.href\".`,\n \"NotSupportedError\"\n );\n },\n enumerable: true,\n },\n origin: {\n get() {\n return url.origin;\n },\n enumerable: true,\n },\n pathname: {\n get() {\n return url.pathname;\n },\n set() {\n throw new DOMException(\n `Cannot set \"location.pathname\".`,\n \"NotSupportedError\"\n );\n },\n enumerable: true,\n },\n port: {\n get() {\n return url.port;\n },\n set() {\n throw new DOMException(\n `Cannot set \"location.port\".`,\n \"NotSupportedError\"\n );\n },\n enumerable: true,\n },\n protocol: {\n get() {\n return url.protocol;\n },\n set() {\n throw new DOMException(\n `Cannot set \"location.protocol\".`,\n \"NotSupportedError\"\n );\n },\n enumerable: true,\n },\n search: {\n get() {\n // @ts-expect-error\n return url.search;\n },\n set() {\n throw new DOMException(\n `Cannot set \"location.search\".`,\n \"NotSupportedError\"\n );\n },\n enumerable: true,\n },\n ancestorOrigins: {\n get() {\n return {\n length: 0,\n item: () => null,\n contains: () => false,\n };\n },\n enumerable: true,\n },\n assign: {\n value: function assign() {\n throw new DOMException(\n `Cannot call \"location.assign()\".`,\n \"NotSupportedError\"\n );\n },\n enumerable: true,\n },\n reload: {\n value: function reload() {\n if (process.env.NODE_ENV !== \"production\") {\n const DevSettings = (\n require(\"react-native\") as typeof import(\"react-native\")\n ).DevSettings;\n DevSettings.reload();\n }\n throw new DOMException(\n `Cannot call \"location.reload()\".`,\n \"NotSupportedError\"\n );\n },\n enumerable: true,\n },\n replace: {\n value: function replace() {\n throw new DOMException(\n `Cannot call \"location.replace()\".`,\n \"NotSupportedError\"\n );\n },\n enumerable: true,\n },\n toString: {\n value: function toString() {\n return url.href;\n },\n enumerable: true,\n },\n [Symbol.for(\"Expo.privateCustomInspect\")]: {\n value(inspect: any) {\n const object = {\n hash: this.hash,\n host: this.host,\n hostname: this.hostname,\n href: this.href,\n origin: this.origin,\n pathname: this.pathname,\n port: this.port,\n protocol: this.protocol,\n search: this.search,\n };\n return `${this.constructor.name} ${inspect(object)}`;\n },\n },\n });\n }\n}\n\nObject.defineProperties(Location.prototype, {\n [Symbol.toString()]: {\n value: \"Location\",\n configurable: true,\n },\n});\n\nlet location: Location | undefined = undefined;\n\nexport function setLocationHref(href: string) {\n location = new Location(href);\n}\n\nexport function install() {\n Object.defineProperty(global, \"Location\", {\n value: Location,\n configurable: true,\n writable: true,\n });\n\n Object.defineProperty(window, \"location\", {\n get() {\n return location;\n },\n set() {\n throw new DOMException(`Cannot set \"location\".`, \"NotSupportedError\");\n },\n enumerable: true,\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=install.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/location/install.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/location/install.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.native.d.ts","sourceRoot":"","sources":["../../src/location/install.native.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a, _b, _c;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const expo_constants_1 = __importDefault(require("expo-constants"));
|
|
8
|
+
const url_parse_1 = __importDefault(require("url-parse"));
|
|
9
|
+
const Location_1 = require("./Location");
|
|
10
|
+
const getDevServer_1 = __importDefault(require("../getDevServer"));
|
|
11
|
+
let hasWarned = false;
|
|
12
|
+
// Add a development warning for fetch requests with relative paths
|
|
13
|
+
// to ensure developers are aware of the need to configure a production
|
|
14
|
+
// base URL in the Expo config (app.json) under `expo.extra.router.origin`.
|
|
15
|
+
function warnProductionOriginNotConfigured(requestUrl) {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
if (hasWarned) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
hasWarned = true;
|
|
21
|
+
if (!((_c = (_b = (_a = expo_constants_1.default.manifest) === null || _a === void 0 ? void 0 : _a.extra) === null || _b === void 0 ? void 0 : _b.router) === null || _c === void 0 ? void 0 : _c.origin)) {
|
|
22
|
+
console.warn(`The relative fetch request "${requestUrl}" will not work in production until the Expo config (app.json) \`expo.extra.router.origin\` field is set to the base URL of your web server. [Learn more](https://expo.github.io/router/docs/lab/runtime-location)`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// TODO: This would be better if native and tied as close to the JS engine as possible, i.e. it should
|
|
26
|
+
// reflect the exact location of the JS file that was executed.
|
|
27
|
+
function getBaseUrl() {
|
|
28
|
+
var _a, _b, _c;
|
|
29
|
+
// TODO: Make it official by moving out of `extra`
|
|
30
|
+
let productionBaseUrl = (_c = (_b = (_a = expo_constants_1.default.manifest) === null || _a === void 0 ? void 0 : _a.extra) === null || _b === void 0 ? void 0 : _b.router) === null || _c === void 0 ? void 0 : _c.origin;
|
|
31
|
+
if (process.env.NODE_ENV !== "production") {
|
|
32
|
+
// e.g. http://localhost:19006
|
|
33
|
+
productionBaseUrl = (0, getDevServer_1.default)().url;
|
|
34
|
+
}
|
|
35
|
+
// Ensure no trailing slash
|
|
36
|
+
return productionBaseUrl.replace(/\/$/, "");
|
|
37
|
+
}
|
|
38
|
+
function wrapFetchWithWindowLocation(fetch) {
|
|
39
|
+
if (fetch.__EXPO_BASE_URL_POLYFILLED) {
|
|
40
|
+
return fetch;
|
|
41
|
+
}
|
|
42
|
+
const _fetch = (...props) => {
|
|
43
|
+
if (props[0] && typeof props[0] === "string" && props[0].startsWith("/")) {
|
|
44
|
+
if (process.env.NODE_ENV !== "production") {
|
|
45
|
+
warnProductionOriginNotConfigured(props[0]);
|
|
46
|
+
}
|
|
47
|
+
props[0] = new url_parse_1.default(props[0], window.location.origin).toString();
|
|
48
|
+
}
|
|
49
|
+
else if (props[0] && typeof props[0] === "object") {
|
|
50
|
+
if (props[0].url &&
|
|
51
|
+
typeof props[0].url === "string" &&
|
|
52
|
+
props[0].url.startsWith("/")) {
|
|
53
|
+
if (process.env.NODE_ENV !== "production") {
|
|
54
|
+
warnProductionOriginNotConfigured(props[0]);
|
|
55
|
+
}
|
|
56
|
+
props[0].url = new url_parse_1.default(props[0].url, window.location.origin).toString();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return fetch(...props);
|
|
60
|
+
};
|
|
61
|
+
_fetch.__EXPO_BASE_URL_POLYFILLED = true;
|
|
62
|
+
return _fetch;
|
|
63
|
+
}
|
|
64
|
+
if (((_c = (_b = (_a = expo_constants_1.default.manifest) === null || _a === void 0 ? void 0 : _a.extra) === null || _b === void 0 ? void 0 : _b.router) === null || _c === void 0 ? void 0 : _c.origin) !== false) {
|
|
65
|
+
// Polyfill window.location in native runtimes.
|
|
66
|
+
if (typeof window !== "undefined" && !window.location) {
|
|
67
|
+
(0, Location_1.setLocationHref)(getBaseUrl());
|
|
68
|
+
(0, Location_1.install)();
|
|
69
|
+
}
|
|
70
|
+
// Polyfill native fetch to support relative URLs
|
|
71
|
+
Object.defineProperty(global, "fetch", {
|
|
72
|
+
value: wrapFetchWithWindowLocation(fetch),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=install.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.native.js","sourceRoot":"","sources":["../../src/location/install.native.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAuC;AACvC,0DAA4B;AAE5B,yCAAsD;AACtD,mEAA2C;AAE3C,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,mEAAmE;AACnE,uEAAuE;AACvE,2EAA2E;AAC3E,SAAS,iCAAiC,CAAC,UAAkB;;IAC3D,IAAI,SAAS,EAAE;QACb,OAAO;KACR;IACD,SAAS,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,CAAA,MAAA,MAAA,MAAA,wBAAS,CAAC,QAAQ,0CAAE,KAAK,0CAAE,MAAM,0CAAE,MAAM,CAAA,EAAE;QAC9C,OAAO,CAA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AC,CAAC,GAAG,KAAK,QAAQ;gBAChC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAC5B;gBACA,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;oBACzC,iCAAiC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC7C;gBAED,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,mBAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;aACzE;SACF;QACD,OAAO,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,MAAM,CAAC,0BAA0B,GAAG,IAAI,CAAC;IAEzC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,IAAI,CAAA,MAAA,MAAA,MAAA,wBAAS,CAAC,QAAQ,0CAAE,KAAK,0CAAE,MAAM,0CAAE,MAAM,MAAK,KAAK,EAAE;IACvD,+CAA+C;IAC/C,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QACrD,IAAA,0BAAe,EAAC,UAAU,EAAE,CAAC,CAAC;QAC9B,IAAA,kBAAO,GAAE,CAAC;KACX;IAED,iDAAiD;IACjD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE;QACrC,KAAK,EAAE,2BAA2B,CAAC,KAAK,CAAC;KAC1C,CAAC,CAAC;CACJ","sourcesContent":["import Constants from \"expo-constants\";\nimport URL from \"url-parse\";\n\nimport { install, setLocationHref } from \"./Location\";\nimport getDevServer from \"../getDevServer\";\n\nlet hasWarned = false;\n\n// Add a development warning for fetch requests with relative paths\n// to ensure developers are aware of the need to configure a production\n// base URL in the Expo config (app.json) under `expo.extra.router.origin`.\nfunction warnProductionOriginNotConfigured(requestUrl: string) {\n if (hasWarned) {\n return;\n }\n hasWarned = true;\n if (!Constants.manifest?.extra?.router?.origin) {\n console.warn(\n `The relative fetch request \"${requestUrl}\" will not work in production until the Expo config (app.json) \\`expo.extra.router.origin\\` field is set to the base URL of your web server. [Learn more](https://expo.github.io/router/docs/lab/runtime-location)`\n );\n }\n}\n\n// TODO: This would be better if native and tied as close to the JS engine as possible, i.e. it should\n// reflect the exact location of the JS file that was executed.\nfunction getBaseUrl() {\n // TODO: Make it official by moving out of `extra`\n let productionBaseUrl = Constants.manifest?.extra?.router?.origin;\n\n if (process.env.NODE_ENV !== \"production\") {\n // e.g. http://localhost:19006\n productionBaseUrl = getDevServer().url;\n }\n\n // Ensure no trailing slash\n return productionBaseUrl.replace(/\\/$/, \"\");\n}\n\nfunction wrapFetchWithWindowLocation(\n fetch: Function & { __EXPO_BASE_URL_POLYFILLED?: boolean }\n) {\n if (fetch.__EXPO_BASE_URL_POLYFILLED) {\n return fetch;\n }\n\n const _fetch = (...props: any[]) => {\n if (props[0] && typeof props[0] === \"string\" && props[0].startsWith(\"/\")) {\n if (process.env.NODE_ENV !== \"production\") {\n warnProductionOriginNotConfigured(props[0]);\n }\n\n props[0] = new URL(props[0], window.location.origin).toString();\n } else if (props[0] && typeof props[0] === \"object\") {\n if (\n props[0].url &&\n typeof props[0].url === \"string\" &&\n props[0].url.startsWith(\"/\")\n ) {\n if (process.env.NODE_ENV !== \"production\") {\n warnProductionOriginNotConfigured(props[0]);\n }\n\n props[0].url = new URL(props[0].url, window.location.origin).toString();\n }\n }\n return fetch(...props);\n };\n\n _fetch.__EXPO_BASE_URL_POLYFILLED = true;\n\n return _fetch;\n}\n\nif (Constants.manifest?.extra?.router?.origin !== false) {\n // Polyfill window.location in native runtimes.\n if (typeof window !== \"undefined\" && !window.location) {\n setLocationHref(getBaseUrl());\n install();\n }\n\n // Polyfill native fetch to support relative URLs\n Object.defineProperty(global, \"fetch\", {\n value: wrapFetchWithWindowLocation(fetch),\n });\n}\n"]}
|
package/package.json
CHANGED