@multiplatform.one/platform 7.11.0 → 7.15.0
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/cjs/config/devOrigin.cjs +42 -0
- package/dist/cjs/config/devOriginSource.cjs +32 -0
- package/dist/cjs/config/index.cjs +1 -0
- package/dist/esm/config/devOrigin.mjs +16 -0
- package/dist/esm/config/devOrigin.mjs.map +1 -0
- package/dist/esm/config/devOriginSource.mjs +7 -0
- package/dist/esm/config/devOriginSource.mjs.map +1 -0
- package/dist/esm/config/index.mjs +1 -0
- package/dist/esm/config/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/config/config.native.ts +2 -1
- package/src/config/devOrigin.spec.ts +79 -0
- package/src/config/devOrigin.ts +45 -0
- package/src/config/devOriginSource.native.ts +9 -0
- package/src/config/devOriginSource.ts +5 -0
- package/src/config/index.ts +1 -0
- package/types/config/config.native.d.ts.map +1 -1
- package/types/config/devOrigin.d.ts +28 -0
- package/types/config/devOrigin.d.ts.map +1 -0
- package/types/config/devOriginSource.d.ts +3 -0
- package/types/config/devOriginSource.d.ts.map +1 -0
- package/types/config/devOriginSource.native.d.ts +3 -0
- package/types/config/devOriginSource.native.d.ts.map +1 -0
- package/types/config/index.d.ts +1 -0
- package/types/config/index.d.ts.map +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var devOrigin_exports = {};
|
|
24
|
+
__export(devOrigin_exports, {
|
|
25
|
+
devHostFromHostUri: () => devHostFromHostUri,
|
|
26
|
+
resolveDevOrigin: () => resolveDevOrigin
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(devOrigin_exports);
|
|
29
|
+
var import_devOriginSource = require("./devOriginSource.cjs");
|
|
30
|
+
const loopbackOrigin = /^([a-z][a-z0-9+.-]*:\/\/)(localhost|127\.0\.0\.1)(?=[:/?#]|$)/i;
|
|
31
|
+
function devHostFromHostUri(hostUri) {
|
|
32
|
+
if (!hostUri) return void 0;
|
|
33
|
+
const authority = hostUri.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "").split(/[/?#]/, 1)[0];
|
|
34
|
+
const host = authority.startsWith("[") ? authority.slice(0, authority.indexOf("]") + 1) : authority.split(":", 1)[0];
|
|
35
|
+
return host || void 0;
|
|
36
|
+
}
|
|
37
|
+
function resolveDevOrigin(url, source = (0, import_devOriginSource.devOriginSource)()) {
|
|
38
|
+
if (source.isWeb) return url;
|
|
39
|
+
const host = devHostFromHostUri(source.hostUri);
|
|
40
|
+
if (!host) return url;
|
|
41
|
+
return url.replace(loopbackOrigin, `$1${host}`);
|
|
42
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var devOriginSource_exports = {};
|
|
24
|
+
__export(devOriginSource_exports, {
|
|
25
|
+
devOriginSource: () => devOriginSource
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(devOriginSource_exports);
|
|
28
|
+
function devOriginSource() {
|
|
29
|
+
return {
|
|
30
|
+
isWeb: true
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -28,5 +28,6 @@ __export(config_exports, {
|
|
|
28
28
|
module.exports = __toCommonJS(config_exports);
|
|
29
29
|
var import_config = require("./config.cjs");
|
|
30
30
|
__reExport(config_exports, require("./config.cjs"), module.exports);
|
|
31
|
+
__reExport(config_exports, require("./devOrigin.cjs"), module.exports);
|
|
31
32
|
__reExport(config_exports, require("./runtimeConfig.cjs"), module.exports);
|
|
32
33
|
const config = new import_config.Config();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { devOriginSource } from "./devOriginSource.mjs";
|
|
2
|
+
const loopbackOrigin = /^([a-z][a-z0-9+.-]*:\/\/)(localhost|127\.0\.0\.1)(?=[:/?#]|$)/i;
|
|
3
|
+
function devHostFromHostUri(hostUri) {
|
|
4
|
+
if (!hostUri) return void 0;
|
|
5
|
+
const authority = hostUri.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "").split(/[/?#]/, 1)[0];
|
|
6
|
+
const host = authority.startsWith("[") ? authority.slice(0, authority.indexOf("]") + 1) : authority.split(":", 1)[0];
|
|
7
|
+
return host || void 0;
|
|
8
|
+
}
|
|
9
|
+
function resolveDevOrigin(url, source = devOriginSource()) {
|
|
10
|
+
if (source.isWeb) return url;
|
|
11
|
+
const host = devHostFromHostUri(source.hostUri);
|
|
12
|
+
if (!host) return url;
|
|
13
|
+
return url.replace(loopbackOrigin, `$1${host}`);
|
|
14
|
+
}
|
|
15
|
+
export { devHostFromHostUri, resolveDevOrigin };
|
|
16
|
+
//# sourceMappingURL=devOrigin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["devOriginSource","loopbackOrigin","devHostFromHostUri","hostUri","authority","replace","split","host","startsWith","slice","indexOf","resolveDevOrigin","url","source","isWeb"],"sources":["../../../src/config/devOrigin.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,eAAA,QAAuB;AAgBhC,MAAMC,cAAA,GAAiB;AAGhB,SAASC,mBAAmBC,OAAA,EAAiD;EAClF,IAAI,CAACA,OAAA,EAAS,OAAO;EACrB,MAAMC,SAAA,GAAYD,OAAA,CAAQE,OAAA,CAAQ,4BAA4B,EAAE,EAAEC,KAAA,CAAM,SAAS,CAAC,EAAE,CAAC;EACrF,MAAMC,IAAA,GAAOH,SAAA,CAAUI,UAAA,CAAW,GAAG,IACjCJ,SAAA,CAAUK,KAAA,CAAM,GAAGL,SAAA,CAAUM,OAAA,CAAQ,GAAG,IAAI,CAAC,IAC7CN,SAAA,CAAUE,KAAA,CAAM,KAAK,CAAC,EAAE,CAAC;EAC7B,OAAOC,IAAA,IAAQ;AACjB;AAaO,SAASI,iBAAiBC,GAAA,EAAaC,MAAA,GAA0Bb,eAAA,CAAgB,GAAW;EACjG,IAAIa,MAAA,CAAOC,KAAA,EAAO,OAAOF,GAAA;EACzB,MAAML,IAAA,GAAOL,kBAAA,CAAmBW,MAAA,CAAOV,OAAO;EAC9C,IAAI,CAACI,IAAA,EAAM,OAAOK,GAAA;EAClB,OAAOA,GAAA,CAAIP,OAAA,CAAQJ,cAAA,EAAgB,KAAKM,IAAI,EAAE;AAChD","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["devOriginSource","isWeb"],"sources":["../../../src/config/devOriginSource.ts"],"sourcesContent":[null],"mappings":"AAEO,SAASA,gBAAA,EAAmC;EACjD,OAAO;IAAEC,KAAA,EAAO;EAAK;AACvB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Config","config"],"sources":["../../../src/config/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAc;AAKvB,cAAc;AACd,cAAc;
|
|
1
|
+
{"version":3,"names":["Config","config"],"sources":["../../../src/config/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAc;AAKvB,cAAc;AACd,cAAc;AACd,cAAc;AALd,MAAMC,MAAA,GAAS,IAAID,MAAA,CAAO","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/platform",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.15.0",
|
|
4
4
|
"description": "Platform detection flags and utilities for multiplatform.one",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"detection",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"author": "BitSpur",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "git+https://
|
|
15
|
+
"url": "git+https://git.corp.bitspur.com/multiplatform.one/mpo.git",
|
|
16
16
|
"directory": "public/platform"
|
|
17
17
|
},
|
|
18
18
|
"source": "src/index.ts",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@tamagui/constants": "2.7.6"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@multiplatform.one/config": "7.
|
|
59
|
+
"@multiplatform.one/config": "7.15.0",
|
|
60
60
|
"@tamagui/build": "2.7.6",
|
|
61
61
|
"@types/chrome": "^0.1.40",
|
|
62
62
|
"@types/firefox-webext-browser": "^143.0.0",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import constants from "expo-constants";
|
|
2
|
+
import { resolveDevOrigin } from "./devOrigin";
|
|
2
3
|
import type { IConfig } from "./types";
|
|
3
4
|
|
|
4
5
|
export class Config implements IConfig {
|
|
@@ -14,7 +15,7 @@ export class Config implements IConfig {
|
|
|
14
15
|
private _resolveConfig() {
|
|
15
16
|
return Object.keys(this._config).reduce<Record<string, string>>((config, key) => {
|
|
16
17
|
const value = this._lookupEnv(key) || this._config[key];
|
|
17
|
-
if (typeof value !== "undefined") config[key] = value;
|
|
18
|
+
if (typeof value !== "undefined") config[key] = resolveDevOrigin(value);
|
|
18
19
|
return config;
|
|
19
20
|
}, {});
|
|
20
21
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { devHostFromHostUri, resolveDevOrigin } from "./devOrigin";
|
|
3
|
+
|
|
4
|
+
const phone = { isWeb: false, hostUri: "10.0.0.5:3456" };
|
|
5
|
+
|
|
6
|
+
describe("resolveDevOrigin", () => {
|
|
7
|
+
it("returns the url unchanged on web, even with a hostUri", () => {
|
|
8
|
+
expect(
|
|
9
|
+
resolveDevOrigin("http://localhost:8000", { isWeb: true, hostUri: "10.0.0.5:3456" }),
|
|
10
|
+
).toBe("http://localhost:8000");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("rewrites a localhost origin to the hostUri host on native", () => {
|
|
14
|
+
expect(resolveDevOrigin("http://localhost:8000", phone)).toBe("http://10.0.0.5:8000");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("rewrites the 127.0.0.1 spelling too", () => {
|
|
18
|
+
expect(resolveDevOrigin("http://127.0.0.1:8000", phone)).toBe("http://10.0.0.5:8000");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("keeps the configured port, path, query and scheme", () => {
|
|
22
|
+
expect(resolveDevOrigin("http://localhost:8080/auth/realms/myrealm?x=1#f", phone)).toBe(
|
|
23
|
+
"http://10.0.0.5:8080/auth/realms/myrealm?x=1#f",
|
|
24
|
+
);
|
|
25
|
+
expect(resolveDevOrigin("ws://localhost:9000/socket.io", phone)).toBe(
|
|
26
|
+
"ws://10.0.0.5:9000/socket.io",
|
|
27
|
+
);
|
|
28
|
+
expect(resolveDevOrigin("http://localhost", phone)).toBe("http://10.0.0.5");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("leaves non-loopback hosts untouched", () => {
|
|
32
|
+
expect(resolveDevOrigin("http://192.168.1.20:8000", phone)).toBe("http://192.168.1.20:8000");
|
|
33
|
+
expect(resolveDevOrigin("https://bench.example.com", phone)).toBe("https://bench.example.com");
|
|
34
|
+
expect(resolveDevOrigin("http://localhost.example.com:8000", phone)).toBe(
|
|
35
|
+
"http://localhost.example.com:8000",
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("leaves the url alone when there is no hostUri (release build)", () => {
|
|
40
|
+
expect(resolveDevOrigin("http://localhost:8000", { isWeb: false })).toBe(
|
|
41
|
+
"http://localhost:8000",
|
|
42
|
+
);
|
|
43
|
+
expect(resolveDevOrigin("http://localhost:8000", { isWeb: false, hostUri: "" })).toBe(
|
|
44
|
+
"http://localhost:8000",
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("passes values that are not urls through untouched", () => {
|
|
49
|
+
expect(resolveDevOrigin("8080", phone)).toBe("8080");
|
|
50
|
+
expect(resolveDevOrigin("localhost:8000", phone)).toBe("localhost:8000");
|
|
51
|
+
expect(resolveDevOrigin("", phone)).toBe("");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("defaults to the web source in this environment", () => {
|
|
55
|
+
expect(resolveDevOrigin("http://localhost:8000")).toBe("http://localhost:8000");
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe("devHostFromHostUri", () => {
|
|
60
|
+
it("takes the host out of host:port", () => {
|
|
61
|
+
expect(devHostFromHostUri("10.0.0.5:3456")).toBe("10.0.0.5");
|
|
62
|
+
expect(devHostFromHostUri("dev.local")).toBe("dev.local");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("strips a scheme and a path when a manifest carries them", () => {
|
|
66
|
+
expect(devHostFromHostUri("http://10.0.0.5:3456/index.bundle")).toBe("10.0.0.5");
|
|
67
|
+
expect(devHostFromHostUri("exp://10.0.0.5:3456")).toBe("10.0.0.5");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("keeps an IPv6 literal bracketed", () => {
|
|
71
|
+
expect(devHostFromHostUri("[fd00::2]:3456")).toBe("[fd00::2]");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("returns undefined for nothing", () => {
|
|
75
|
+
expect(devHostFromHostUri(undefined)).toBeUndefined();
|
|
76
|
+
expect(devHostFromHostUri("")).toBeUndefined();
|
|
77
|
+
expect(devHostFromHostUri(":3456")).toBeUndefined();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { devOriginSource } from "./devOriginSource";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Where the running app learns the dev machine's address from.
|
|
5
|
+
*
|
|
6
|
+
* On native, `hostUri` is Expo's `Constants.expoConfig.hostUri`: the
|
|
7
|
+
* `host:port` the device fetched its manifest from, which @expo/cli fills in
|
|
8
|
+
* from the request's Host header. It is therefore the one address the device
|
|
9
|
+
* is already proven to reach, whatever the machine's LAN IP happens to be,
|
|
10
|
+
* and it is absent in a release build, where nothing points at localhost.
|
|
11
|
+
*/
|
|
12
|
+
export interface DevOriginSource {
|
|
13
|
+
isWeb: boolean;
|
|
14
|
+
hostUri?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const loopbackOrigin = /^([a-z][a-z0-9+.-]*:\/\/)(localhost|127\.0\.0\.1)(?=[:/?#]|$)/i;
|
|
18
|
+
|
|
19
|
+
/** The host part of a `host:port`, `scheme://host:port/path` or `[v6]:port` value. */
|
|
20
|
+
export function devHostFromHostUri(hostUri: string | undefined): string | undefined {
|
|
21
|
+
if (!hostUri) return undefined;
|
|
22
|
+
const authority = hostUri.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "").split(/[/?#]/, 1)[0];
|
|
23
|
+
const host = authority.startsWith("[")
|
|
24
|
+
? authority.slice(0, authority.indexOf("]") + 1)
|
|
25
|
+
: authority.split(":", 1)[0];
|
|
26
|
+
return host || undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Point a loopback-configured origin at the dev machine on native.
|
|
31
|
+
*
|
|
32
|
+
* `http://localhost:8000` in .env means "the machine running the dev server"
|
|
33
|
+
* on every platform. In a browser that is the page host; on a simulator, an
|
|
34
|
+
* emulator or a phone it is the host the bundle came from, so the same .env
|
|
35
|
+
* serves all of them. Web, and anything without a hostUri, is returned as is.
|
|
36
|
+
*
|
|
37
|
+
* String-based on purpose: React Native's URL polyfill has no `hostname`
|
|
38
|
+
* setter, so a new-URL-and-assign rewrite silently no-ops on device.
|
|
39
|
+
*/
|
|
40
|
+
export function resolveDevOrigin(url: string, source: DevOriginSource = devOriginSource()): string {
|
|
41
|
+
if (source.isWeb) return url;
|
|
42
|
+
const host = devHostFromHostUri(source.hostUri);
|
|
43
|
+
if (!host) return url;
|
|
44
|
+
return url.replace(loopbackOrigin, `$1${host}`);
|
|
45
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import constants from "expo-constants";
|
|
2
|
+
import type { DevOriginSource } from "./devOrigin";
|
|
3
|
+
|
|
4
|
+
export function devOriginSource(): DevOriginSource {
|
|
5
|
+
return {
|
|
6
|
+
isWeb: false,
|
|
7
|
+
hostUri: constants.expoConfig?.hostUri ?? constants.manifest2?.extra?.expoGo?.debuggerHost,
|
|
8
|
+
};
|
|
9
|
+
}
|
package/src/config/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.native.d.ts","sourceRoot":"","sources":["../../src/config/config.native.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.native.d.ts","sourceRoot":"","sources":["../../src/config/config.native.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,qBAAa,MAAO,YAAW,OAAO;IACpC,OAAO,CAAC,OAAO,CAA8B;IAE7C,OAAO,CAAC,UAAU,CAA4B;IAE9C,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,aAAa;gBAUT,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAM;IAY3D,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IACpC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;IAO9C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAK9B,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAQjC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAKxC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the running app learns the dev machine's address from.
|
|
3
|
+
*
|
|
4
|
+
* On native, `hostUri` is Expo's `Constants.expoConfig.hostUri`: the
|
|
5
|
+
* `host:port` the device fetched its manifest from, which @expo/cli fills in
|
|
6
|
+
* from the request's Host header. It is therefore the one address the device
|
|
7
|
+
* is already proven to reach, whatever the machine's LAN IP happens to be,
|
|
8
|
+
* and it is absent in a release build, where nothing points at localhost.
|
|
9
|
+
*/
|
|
10
|
+
export interface DevOriginSource {
|
|
11
|
+
isWeb: boolean;
|
|
12
|
+
hostUri?: string;
|
|
13
|
+
}
|
|
14
|
+
/** The host part of a `host:port`, `scheme://host:port/path` or `[v6]:port` value. */
|
|
15
|
+
export declare function devHostFromHostUri(hostUri: string | undefined): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Point a loopback-configured origin at the dev machine on native.
|
|
18
|
+
*
|
|
19
|
+
* `http://localhost:8000` in .env means "the machine running the dev server"
|
|
20
|
+
* on every platform. In a browser that is the page host; on a simulator, an
|
|
21
|
+
* emulator or a phone it is the host the bundle came from, so the same .env
|
|
22
|
+
* serves all of them. Web, and anything without a hostUri, is returned as is.
|
|
23
|
+
*
|
|
24
|
+
* String-based on purpose: React Native's URL polyfill has no `hostname`
|
|
25
|
+
* setter, so a new-URL-and-assign rewrite silently no-ops on device.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveDevOrigin(url: string, source?: DevOriginSource): string;
|
|
28
|
+
//# sourceMappingURL=devOrigin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devOrigin.d.ts","sourceRoot":"","sources":["../../src/config/devOrigin.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAID,sFAAsF;AACtF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAOlF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,eAAmC,GAAG,MAAM,CAKjG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devOriginSource.d.ts","sourceRoot":"","sources":["../../src/config/devOriginSource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,wBAAgB,eAAe,IAAI,eAAe,CAEjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devOriginSource.native.d.ts","sourceRoot":"","sources":["../../src/config/devOriginSource.native.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,wBAAgB,eAAe,IAAI,eAAe,CAKjD"}
|
package/types/config/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,MAAM,QAAe,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,MAAM,QAAe,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
|