@expo/metro-runtime 1.1.0 → 2.0.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.
Files changed (53) hide show
  1. package/build/async-require/__tests__/buildAsyncRequire.test.d.ts +3 -0
  2. package/build/async-require/__tests__/buildAsyncRequire.test.d.ts.map +1 -0
  3. package/build/async-require/__tests__/buildAsyncRequire.test.js +71 -0
  4. package/build/async-require/__tests__/buildAsyncRequire.test.js.map +1 -0
  5. package/build/async-require/__tests__/buildUrlForBundle.test.native.d.ts +3 -0
  6. package/build/async-require/__tests__/buildUrlForBundle.test.native.d.ts.map +1 -0
  7. package/build/async-require/__tests__/buildUrlForBundle.test.native.js +38 -0
  8. package/build/async-require/__tests__/buildUrlForBundle.test.native.js.map +1 -0
  9. package/build/async-require/__tests__/buildUrlForBundle.test.web.d.ts +2 -0
  10. package/build/async-require/__tests__/buildUrlForBundle.test.web.d.ts.map +1 -0
  11. package/build/async-require/__tests__/buildUrlForBundle.test.web.js +13 -0
  12. package/build/async-require/__tests__/buildUrlForBundle.test.web.js.map +1 -0
  13. package/build/async-require/__tests__/fetchAsync.test.web.d.ts +2 -0
  14. package/build/async-require/__tests__/fetchAsync.test.web.d.ts.map +1 -0
  15. package/build/async-require/__tests__/fetchAsync.test.web.js +22 -0
  16. package/build/async-require/__tests__/fetchAsync.test.web.js.map +1 -0
  17. package/build/async-require/__tests__/loadBundlePolyfill.test.ios.d.ts +2 -0
  18. package/build/async-require/__tests__/loadBundlePolyfill.test.ios.d.ts.map +1 -0
  19. package/build/async-require/__tests__/loadBundlePolyfill.test.ios.js +32 -0
  20. package/build/async-require/__tests__/loadBundlePolyfill.test.ios.js.map +1 -0
  21. package/build/async-require/__tests__/loadBundlePolyfill.test.web.d.ts +2 -0
  22. package/build/async-require/__tests__/loadBundlePolyfill.test.web.d.ts.map +1 -0
  23. package/build/async-require/__tests__/loadBundlePolyfill.test.web.js +31 -0
  24. package/build/async-require/__tests__/loadBundlePolyfill.test.web.js.map +1 -0
  25. package/build/async-require/fetchThenEval.web.d.ts.map +1 -1
  26. package/build/async-require/fetchThenEval.web.js +3 -0
  27. package/build/async-require/fetchThenEval.web.js.map +1 -1
  28. package/build/index.d.ts +1 -0
  29. package/build/index.d.ts.map +1 -1
  30. package/build/index.js +1 -0
  31. package/build/index.js.map +1 -1
  32. package/build/location/Location.d.ts +3 -0
  33. package/build/location/Location.d.ts.map +1 -0
  34. package/build/location/Location.js +8 -0
  35. package/build/location/Location.js.map +1 -0
  36. package/build/location/Location.native.d.ts +3 -0
  37. package/build/location/Location.native.d.ts.map +1 -0
  38. package/build/location/Location.native.js +195 -0
  39. package/build/location/Location.native.js.map +1 -0
  40. package/build/location/install.d.ts +1 -0
  41. package/build/location/install.d.ts.map +1 -0
  42. package/build/location/install.js +2 -0
  43. package/build/location/install.js.map +1 -0
  44. package/build/location/install.native.d.ts +2 -0
  45. package/build/location/install.native.d.ts.map +1 -0
  46. package/build/location/install.native.js +81 -0
  47. package/build/location/install.native.js.map +1 -0
  48. package/build/transformer/css/__tests__/css-transformer.test.web.d.ts +2 -0
  49. package/build/transformer/css/__tests__/css-transformer.test.web.d.ts.map +1 -0
  50. package/build/transformer/css/__tests__/css-transformer.test.web.js +111 -0
  51. package/build/transformer/css/__tests__/css-transformer.test.web.js.map +1 -0
  52. package/build/transformer/index.d.ts +1 -1
  53. package/package.json +1 -1
@@ -0,0 +1,3 @@
1
+ /// <reference types="jest" />
2
+ export declare const asMock: <T extends (...args: any[]) => any>(fn: T) => jest.MockedFunction<T>;
3
+ //# sourceMappingURL=buildAsyncRequire.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildAsyncRequire.test.d.ts","sourceRoot":"","sources":["../../../src/async-require/__tests__/buildAsyncRequire.test.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,MAAM,uBAAwB,GAAG,EAAE,KAAK,GAAG,kCAEC,CAAC"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asMock = void 0;
4
+ const buildAsyncRequire_1 = require("../buildAsyncRequire");
5
+ const loadBundle_1 = require("../loadBundle");
6
+ const asMock = (fn) => fn;
7
+ exports.asMock = asMock;
8
+ jest.mock("../loadBundle", () => ({
9
+ loadBundleAsync: jest.fn(async () => { }),
10
+ }));
11
+ function getMockRequire() {
12
+ const mockRequire = jest.fn();
13
+ mockRequire.importAll = jest.fn();
14
+ return mockRequire;
15
+ }
16
+ const originalEnv = process.env.NODE_ENV;
17
+ beforeEach(() => {
18
+ process.env.NODE_ENV = "development";
19
+ });
20
+ afterAll(() => {
21
+ process.env.NODE_ENV = originalEnv;
22
+ });
23
+ it(`builds required object`, async () => {
24
+ const _require = getMockRequire();
25
+ const asyncRequire = (0, buildAsyncRequire_1.buildAsyncRequire)(_require);
26
+ expect(asyncRequire).toBeInstanceOf(Function);
27
+ expect(asyncRequire.prefetch).toBeInstanceOf(Function);
28
+ expect(asyncRequire.resource).toBeInstanceOf(Function);
29
+ });
30
+ it(`loads the module with \`loadBundleAsync\` if the module has not been loaded already`, async () => {
31
+ const _require = getMockRequire();
32
+ const asyncRequire = (0, buildAsyncRequire_1.buildAsyncRequire)(_require);
33
+ const myModule = asyncRequire(650, "", { "650": "SixFiveZero" });
34
+ expect(myModule).toEqual(expect.any(Promise));
35
+ // Did attempt to fetch the bundle
36
+ expect(loadBundle_1.loadBundleAsync).toBeCalledWith("SixFiveZero");
37
+ expect(_require.importAll).not.toBeCalled();
38
+ });
39
+ it(`fetches and returns an async module`, async () => {
40
+ const _require = getMockRequire();
41
+ (0, exports.asMock)(_require).mockReturnValueOnce({ foo: "bar" });
42
+ const asyncRequire = (0, buildAsyncRequire_1.buildAsyncRequire)(_require);
43
+ expect(asyncRequire).toBeInstanceOf(Function);
44
+ const myModule = await asyncRequire(2, "", {
45
+ "2": "Two",
46
+ });
47
+ // Fetch and load the bundle into memory.
48
+ expect(loadBundle_1.loadBundleAsync).toBeCalledWith("Two");
49
+ // Ensure the module was required using Metro after the bundle was loaded.
50
+ expect(_require).toBeCalledWith(2);
51
+ // Ensure the module was returned.
52
+ expect(myModule).toEqual({ foo: "bar" });
53
+ });
54
+ it(`disables async requires in production`, async () => {
55
+ process.env.NODE_ENV = "production";
56
+ const _require = getMockRequire();
57
+ (0, exports.asMock)(_require.importAll).mockReturnValueOnce({ foo: "bar" });
58
+ const asyncRequire = (0, buildAsyncRequire_1.buildAsyncRequire)(_require);
59
+ expect(asyncRequire).toBeInstanceOf(Function);
60
+ const myModule = await asyncRequire(2, "", {
61
+ "2": "Two",
62
+ });
63
+ // Fetch and load the bundle into memory.
64
+ expect(loadBundle_1.loadBundleAsync).not.toBeCalled();
65
+ // Ensure the module was required using Metro after the bundle was loaded.
66
+ expect(_require.importAll).toBeCalledWith(2);
67
+ expect(_require).not.toBeCalled();
68
+ // Ensure the module was returned.
69
+ expect(myModule).toEqual({ foo: "bar" });
70
+ });
71
+ //# sourceMappingURL=buildAsyncRequire.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildAsyncRequire.test.js","sourceRoot":"","sources":["../../../src/async-require/__tests__/buildAsyncRequire.test.ts"],"names":[],"mappings":";;;AAAA,4DAAyD;AACzD,8CAAgD;AAEzC,MAAM,MAAM,GAAG,CACpB,EAAK,EACmB,EAAE,CAAC,EAA4B,CAAC;AAF7C,QAAA,MAAM,UAEuC;AAE1D,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;IAChC,eAAe,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,GAAE,CAAC,CAAC;CACzC,CAAC,CAAC,CAAC;AAEJ,SAAS,cAAc;IACrB,MAAM,WAAW,GAAQ,IAAI,CAAC,EAAE,EAAE,CAAC;IACnC,WAAW,CAAC,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAElC,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,WA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IAEH,yCAAyC;IACzC,MAAM,CAAC,4BAAe,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;IAEzC,0EAA0E;IAC1E,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAC7C,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;IAElC,kCAAkC;IAClC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC","sourcesContent":["import { buildAsyncRequire } from \"../buildAsyncRequire\";\nimport { loadBundleAsync } from \"../loadBundle\";\n\nexport const asMock = <T extends (...args: any[]) => any>(\n fn: T\n): jest.MockedFunction<T> => fn as jest.MockedFunction<T>;\n\njest.mock(\"../loadBundle\", () => ({\n loadBundleAsync: jest.fn(async () => {}),\n}));\n\nfunction getMockRequire() {\n const mockRequire: any = jest.fn();\n mockRequire.importAll = jest.fn();\n\n return mockRequire;\n}\n\nconst originalEnv = process.env.NODE_ENV;\nbeforeEach(() => {\n process.env.NODE_ENV = \"development\";\n});\n\nafterAll(() => {\n process.env.NODE_ENV = originalEnv;\n});\n\nit(`builds required object`, async () => {\n const _require = getMockRequire();\n const asyncRequire = buildAsyncRequire(_require);\n\n expect(asyncRequire).toBeInstanceOf(Function);\n expect(asyncRequire.prefetch).toBeInstanceOf(Function);\n expect(asyncRequire.resource).toBeInstanceOf(Function);\n});\n\nit(`loads the module with \\`loadBundleAsync\\` if the module has not been loaded already`, async () => {\n const _require = getMockRequire();\n const asyncRequire = buildAsyncRequire(_require);\n\n const myModule = asyncRequire(650, \"\", { \"650\": \"SixFiveZero\" });\n expect(myModule).toEqual(expect.any(Promise));\n\n // Did attempt to fetch the bundle\n expect(loadBundleAsync).toBeCalledWith(\"SixFiveZero\");\n expect(_require.importAll).not.toBeCalled();\n});\n\nit(`fetches and returns an async module`, async () => {\n const _require = getMockRequire();\n\n asMock(_require).mockReturnValueOnce({ foo: \"bar\" });\n\n const asyncRequire = buildAsyncRequire(_require);\n\n expect(asyncRequire).toBeInstanceOf(Function);\n\n const myModule = await asyncRequire(2, \"\", {\n \"2\": \"Two\",\n });\n\n // Fetch and load the bundle into memory.\n expect(loadBundleAsync).toBeCalledWith(\"Two\");\n\n // Ensure the module was required using Metro after the bundle was loaded.\n expect(_require).toBeCalledWith(2);\n\n // Ensure the module was returned.\n expect(myModule).toEqual({ foo: \"bar\" });\n});\n\nit(`disables async requires in production`, async () => {\n process.env.NODE_ENV = \"production\";\n const _require = getMockRequire();\n\n asMock(_require.importAll).mockReturnValueOnce({ foo: \"bar\" });\n\n const asyncRequire = buildAsyncRequire(_require);\n\n expect(asyncRequire).toBeInstanceOf(Function);\n\n const myModule = await asyncRequire(2, \"\", {\n \"2\": \"Two\",\n });\n\n // Fetch and load the bundle into memory.\n expect(loadBundleAsync).not.toBeCalled();\n\n // Ensure the module was required using Metro after the bundle was loaded.\n expect(_require.importAll).toBeCalledWith(2);\n expect(_require).not.toBeCalled();\n\n // Ensure the module was returned.\n expect(myModule).toEqual({ foo: \"bar\" });\n});\n"]}
@@ -0,0 +1,3 @@
1
+ /// <reference types="jest" />
2
+ export declare const asMock: <T extends (...args: any[]) => any>(fn: T) => jest.MockedFunction<T>;
3
+ //# sourceMappingURL=buildUrlForBundle.test.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildUrlForBundle.test.native.d.ts","sourceRoot":"","sources":["../../../src/async-require/__tests__/buildUrlForBundle.test.native.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,MAAM,uBAAwB,GAAG,EAAE,KAAK,GAAG,kCAEC,CAAC"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.asMock = void 0;
7
+ const getDevServer_1 = __importDefault(require("../../getDevServer"));
8
+ const buildUrlForBundle_1 = require("../buildUrlForBundle");
9
+ const asMock = (fn) => fn;
10
+ exports.asMock = asMock;
11
+ jest.mock("../../getDevServer", () => {
12
+ return jest.fn();
13
+ });
14
+ it(`returns an expected URL`, () => {
15
+ (0, exports.asMock)(getDevServer_1.default).mockReturnValueOnce({
16
+ bundleLoadedFromServer: true,
17
+ fullBundleUrl: "http://localhost:19000?platform=android&modulesOnly=true&runModule=false&runtimeBytecodeVersion=null",
18
+ url: "http://localhost:19000",
19
+ });
20
+ expect((0, buildUrlForBundle_1.buildUrlForBundle)("/foobar", {})).toEqual("http://localhost:19000/foobar.bundle?platform=android&modulesOnly=true&runModule=false&runtimeBytecodeVersion=null");
21
+ });
22
+ it(`returns an expected URL with extra parameters`, () => {
23
+ (0, exports.asMock)(getDevServer_1.default).mockReturnValueOnce({
24
+ bundleLoadedFromServer: true,
25
+ fullBundleUrl: "http://localhost:19000?platform=android",
26
+ url: "http://localhost:19000",
27
+ });
28
+ expect((0, buildUrlForBundle_1.buildUrlForBundle)("/more/than/one", { happy: "meal" })).toEqual("http://localhost:19000/more/than/one.bundle?platform=android&happy=meal");
29
+ });
30
+ it("throws on native when the bundle is not hosted", () => {
31
+ (0, exports.asMock)(getDevServer_1.default).mockReturnValueOnce({
32
+ bundleLoadedFromServer: false,
33
+ fullBundleUrl: "file://",
34
+ url: "file://",
35
+ });
36
+ expect(() => (0, buildUrlForBundle_1.buildUrlForBundle)("foobar", {})).toThrowErrorMatchingInlineSnapshot(`"This bundle was compiled with 'transformer.experimentalImportBundleSupport' in the 'metro.config.js' and can only be used when connected to a Metro server."`);
37
+ });
38
+ //# sourceMappingURL=buildUrlForBundle.test.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildUrlForBundle.test.native.js","sourceRoot":"","sources":["../../../src/async-require/__tests__/buildUrlForBundle.test.native.ts"],"names":[],"mappings":";;;;;;AAAA,sEAA8C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JAA+J,CAChK,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import getDevServer from \"../../getDevServer\";\nimport { buildUrlForBundle } from \"../buildUrlForBundle\";\n\nexport const asMock = <T extends (...args: any[]) => any>(\n fn: T\n): jest.MockedFunction<T> => fn as jest.MockedFunction<T>;\n\njest.mock(\"../../getDevServer\", () => {\n return jest.fn();\n});\n\nit(`returns an expected URL`, () => {\n asMock(getDevServer).mockReturnValueOnce({\n bundleLoadedFromServer: true,\n fullBundleUrl:\n \"http://localhost:19000?platform=android&modulesOnly=true&runModule=false&runtimeBytecodeVersion=null\",\n url: \"http://localhost:19000\",\n });\n\n expect(buildUrlForBundle(\"/foobar\", {})).toEqual(\n \"http://localhost:19000/foobar.bundle?platform=android&modulesOnly=true&runModule=false&runtimeBytecodeVersion=null\"\n );\n});\n\nit(`returns an expected URL with extra parameters`, () => {\n asMock(getDevServer).mockReturnValueOnce({\n bundleLoadedFromServer: true,\n fullBundleUrl: \"http://localhost:19000?platform=android\",\n url: \"http://localhost:19000\",\n });\n\n expect(buildUrlForBundle(\"/more/than/one\", { happy: \"meal\" })).toEqual(\n \"http://localhost:19000/more/than/one.bundle?platform=android&happy=meal\"\n );\n});\n\nit(\"throws on native when the bundle is not hosted\", () => {\n asMock(getDevServer).mockReturnValueOnce({\n bundleLoadedFromServer: false,\n fullBundleUrl: \"file://\",\n url: \"file://\",\n });\n\n expect(() =>\n buildUrlForBundle(\"foobar\", {})\n ).toThrowErrorMatchingInlineSnapshot(\n `\"This bundle was compiled with 'transformer.experimentalImportBundleSupport' in the 'metro.config.js' and can only be used when connected to a Metro server.\"`\n );\n});\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=buildUrlForBundle.test.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildUrlForBundle.test.web.d.ts","sourceRoot":"","sources":["../../../src/async-require/__tests__/buildUrlForBundle.test.web.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const buildUrlForBundle_1 = require("../buildUrlForBundle");
4
+ it(`returns an expected URL with no params`, () => {
5
+ expect((0, buildUrlForBundle_1.buildUrlForBundle)("/foobar", {})).toEqual("/foobar.bundle");
6
+ });
7
+ it(`returns an expected URL with params`, () => {
8
+ expect((0, buildUrlForBundle_1.buildUrlForBundle)("foobar", { platform: "web" })).toEqual("/foobar.bundle?platform=web");
9
+ });
10
+ it(`returns an expected URL with non standard root`, () => {
11
+ expect((0, buildUrlForBundle_1.buildUrlForBundle)("/more/than/one", { happy: "meal" })).toEqual("/more/than/one.bundle?happy=meal");
12
+ });
13
+ //# sourceMappingURL=buildUrlForBundle.test.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildUrlForBundle.test.web.js","sourceRoot":"","sources":["../../../src/async-require/__tests__/buildUrlForBundle.test.web.ts"],"names":[],"mappings":";;AAAA,4DAAyD;AAEzD,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;IAChD,MAAM,CAAC,IAAA,qCAAiB,EAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACrE,CAAC,CAAC,CAAC;AACH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;IAC7C,MAAM,CAAC,IAAA,qCAAiB,EAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAC9D,6BAA6B,CAC9B,CAAC;AACJ,CAAC,CAAC,CAAC;AACH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;IACxD,MAAM,CAAC,IAAA,qCAAiB,EAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,CACpE,kCAAkC,CACnC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { buildUrlForBundle } from \"../buildUrlForBundle\";\n\nit(`returns an expected URL with no params`, () => {\n expect(buildUrlForBundle(\"/foobar\", {})).toEqual(\"/foobar.bundle\");\n});\nit(`returns an expected URL with params`, () => {\n expect(buildUrlForBundle(\"foobar\", { platform: \"web\" })).toEqual(\n \"/foobar.bundle?platform=web\"\n );\n});\nit(`returns an expected URL with non standard root`, () => {\n expect(buildUrlForBundle(\"/more/than/one\", { happy: \"meal\" })).toEqual(\n \"/more/than/one.bundle?happy=meal\"\n );\n});\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=fetchAsync.test.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchAsync.test.web.d.ts","sourceRoot":"","sources":["../../../src/async-require/__tests__/fetchAsync.test.web.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-env jest browser */
4
+ const fetchAsync_1 = require("../fetchAsync");
5
+ const originalFetch = global.fetch;
6
+ beforeAll(() => {
7
+ // eslint-disable-next-line
8
+ global.fetch = jest.fn(() =>
9
+ // eslint-disable-next-line
10
+ Promise.resolve({ body: "", text: jest.fn(() => "mock"), headers: {} }));
11
+ });
12
+ afterAll(() => {
13
+ global.fetch = originalFetch;
14
+ });
15
+ it(`fetches`, async () => {
16
+ await expect((0, fetchAsync_1.fetchAsync)("https://example.com")).resolves.toBeDefined();
17
+ expect(global.fetch).toBeCalledWith("https://example.com", {
18
+ headers: { "expo-platform": "web" },
19
+ method: "GET",
20
+ });
21
+ });
22
+ //# sourceMappingURL=fetchAsync.test.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchAsync.test.web.js","sourceRoot":"","sources":["../../../src/async-require/__tests__/fetchAsync.test.web.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,8CAA2C;AAI3C,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC;AAEnC,SAAS,CAAC,GAAG,EAAE;IACb,2BAA2B;IAC3B,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE;IAC1B,2BAA2B;IAC3B,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CACxE,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,GAAG,EAAE;IACZ,MAAM,CAAC,KAAK,GAAG,aAAa,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,MAAM,CAAC,IAAA,uBAAU,EAAC,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IACvE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,qBAAqB,EAAE;QACzD,OAAO,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE;QACnC,MAAM,EAAE,KAAK;KACd,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-env jest browser */\nimport { fetchAsync } from \"../fetchAsync\";\n\ndeclare const global: any;\n\nconst originalFetch = global.fetch;\n\nbeforeAll(() => {\n // eslint-disable-next-line\n global.fetch = jest.fn(() =>\n // eslint-disable-next-line\n Promise.resolve({ body: \"\", text: jest.fn(() => \"mock\"), headers: {} })\n );\n});\n\nafterAll(() => {\n global.fetch = originalFetch;\n});\n\nit(`fetches`, async () => {\n await expect(fetchAsync(\"https://example.com\")).resolves.toBeDefined();\n expect(global.fetch).toBeCalledWith(\"https://example.com\", {\n headers: { \"expo-platform\": \"web\" },\n method: \"GET\",\n });\n});\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=loadBundlePolyfill.test.ios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadBundlePolyfill.test.ios.d.ts","sourceRoot":"","sources":["../../../src/async-require/__tests__/loadBundlePolyfill.test.ios.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const HMRClient_1 = __importDefault(require("../../HMRClient"));
7
+ const LoadingView_1 = __importDefault(require("../../LoadingView"));
8
+ const fetchThenEval_1 = require("../fetchThenEval");
9
+ const loadBundlePolyfill_1 = require("../loadBundlePolyfill");
10
+ jest.mock("../../getDevServer", () => jest.fn(() => ({
11
+ bundleLoadedFromServer: true,
12
+ fullBundleUrl: "http://localhost:19000?platform=android&modulesOnly=true&runModule=false&runtimeBytecodeVersion=null",
13
+ url: "http://localhost:19000/",
14
+ })));
15
+ jest.mock("../fetchThenEval", () => ({
16
+ fetchThenEvalAsync: jest.fn(async () => { }),
17
+ }));
18
+ jest.mock("../../HMRClient", () => ({ registerBundle: jest.fn() }));
19
+ jest.mock("../../LoadingView", () => ({
20
+ showMessage: jest.fn(),
21
+ hide: jest.fn(),
22
+ }));
23
+ // Android uses a native impl
24
+ it("loads a bundle", async () => {
25
+ await (0, loadBundlePolyfill_1.loadBundleAsync)("Second");
26
+ expect(LoadingView_1.default.showMessage).toBeCalledWith("Downloading...", "load");
27
+ expect(LoadingView_1.default.hide).toBeCalledWith();
28
+ const url = "http://localhost:19000/Second.bundle?platform=ios&modulesOnly=true&runModule=false&runtimeBytecodeVersion=";
29
+ expect(HMRClient_1.default.registerBundle).toBeCalledWith(url);
30
+ expect(fetchThenEval_1.fetchThenEvalAsync).toBeCalledWith(url);
31
+ });
32
+ //# sourceMappingURL=loadBundlePolyfill.test.ios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadBundlePolyfill.test.ios.js","sourceRoot":"","sources":["../../../src/async-require/__tests__/loadBundlePolyfill.test.ios.ts"],"names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AAG,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC","sourcesContent":["import HMRClient from \"../../HMRClient\";\nimport LoadingView from \"../../LoadingView\";\nimport { fetchThenEvalAsync } from \"../fetchThenEval\";\nimport { loadBundleAsync } from \"../loadBundlePolyfill\";\n\njest.mock(\"../../getDevServer\", () =>\n jest.fn(() => ({\n bundleLoadedFromServer: true,\n fullBundleUrl:\n \"http://localhost:19000?platform=android&modulesOnly=true&runModule=false&runtimeBytecodeVersion=null\",\n url: \"http://localhost:19000/\",\n }))\n);\n\njest.mock(\"../fetchThenEval\", () => ({\n fetchThenEvalAsync: jest.fn(async () => {}),\n}));\njest.mock(\"../../HMRClient\", () => ({ registerBundle: jest.fn() }));\njest.mock(\"../../LoadingView\", () => ({\n showMessage: jest.fn(),\n hide: jest.fn(),\n}));\n\n// Android uses a native impl\n\nit(\"loads a bundle\", async () => {\n await loadBundleAsync(\"Second\");\n expect(LoadingView.showMessage).toBeCalledWith(\"Downloading...\", \"load\");\n expect(LoadingView.hide).toBeCalledWith();\n const url =\n \"http://localhost:19000/Second.bundle?platform=ios&modulesOnly=true&runModule=false&runtimeBytecodeVersion=\";\n expect(HMRClient.registerBundle).toBeCalledWith(url);\n expect(fetchThenEvalAsync).toBeCalledWith(url);\n});\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=loadBundlePolyfill.test.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadBundlePolyfill.test.web.d.ts","sourceRoot":"","sources":["../../../src/async-require/__tests__/loadBundlePolyfill.test.web.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const HMRClient_1 = __importDefault(require("../../HMRClient"));
7
+ const LoadingView_1 = __importDefault(require("../../LoadingView"));
8
+ const fetchThenEval_1 = require("../fetchThenEval");
9
+ const loadBundlePolyfill_1 = require("../loadBundlePolyfill");
10
+ jest.mock("../../getDevServer", () => jest.fn(() => ({
11
+ bundleLoadedFromServer: true,
12
+ fullBundleUrl: "http://localhost:19000?platform=android&modulesOnly=true&runModule=false&runtimeBytecodeVersion=null",
13
+ url: "http://localhost:19000/",
14
+ })));
15
+ jest.mock("../fetchThenEval", () => ({
16
+ fetchThenEvalAsync: jest.fn(async () => { }),
17
+ }));
18
+ jest.mock("../../HMRClient", () => ({ registerBundle: jest.fn() }));
19
+ jest.mock("../../LoadingView", () => ({
20
+ showMessage: jest.fn(),
21
+ hide: jest.fn(),
22
+ }));
23
+ it("loads a bundle", async () => {
24
+ await (0, loadBundlePolyfill_1.loadBundleAsync)("Second");
25
+ expect(LoadingView_1.default.showMessage).toBeCalledWith("Downloading...", "load");
26
+ expect(LoadingView_1.default.hide).toBeCalledWith();
27
+ const url = `/Second.bundle?modulesOnly=true&runModule=false&platform=web&runtimeBytecodeVersion=`;
28
+ expect(HMRClient_1.default.registerBundle).toBeCalledWith(url);
29
+ expect(fetchThenEval_1.fetchThenEvalAsync).toBeCalledWith(url);
30
+ });
31
+ //# sourceMappingURL=loadBundlePolyfill.test.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadBundlePolyfill.test.web.js","sourceRoot":"","sources":["../../../src/async-require/__tests__/loadBundlePolyfill.test.web.ts"],"names":[],"mappings":";;;;;AAAA,gEAAwC;AACxC,oEAA4C;AAC5C,oDAAsD;AACtD,8DAAwD;AAExD,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,GAAG,EAAE,CACnC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IACb,sBAAsB,EAAE,IAAI;IAC5B,aAAa,EACX,sGAAsG;IACxG,GAAG,EAAE,yBAAyB;CAC/B,CAAC,CAAC,CACJ,CAAC;AAEF,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,CAAC;IACnC,kBAAkB,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,GAAE,CAAC,CAAC;CAC5C,CAAC,CAAC,CAAC;AAEJ,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AACpE,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;IACpC,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;IACtB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;CAChB,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,gBAAgB,EAAE,KAAK,IAAI,EAAE;IAC9B,MAAM,IAAA,oCAAe,EAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,CAAC,qBAAW,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACzE,MAAM,CAAC,qBAAW,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;IAC1C,MAAM,GAAG,GAAG,sFAAsF,CAAC;IACnG,MAAM,CAAC,mBAAS,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACrD,MAAM,CAAC,kCAAkB,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC","sourcesContent":["import HMRClient from \"../../HMRClient\";\nimport LoadingView from \"../../LoadingView\";\nimport { fetchThenEvalAsync } from \"../fetchThenEval\";\nimport { loadBundleAsync } from \"../loadBundlePolyfill\";\n\njest.mock(\"../../getDevServer\", () =>\n jest.fn(() => ({\n bundleLoadedFromServer: true,\n fullBundleUrl:\n \"http://localhost:19000?platform=android&modulesOnly=true&runModule=false&runtimeBytecodeVersion=null\",\n url: \"http://localhost:19000/\",\n }))\n);\n\njest.mock(\"../fetchThenEval\", () => ({\n fetchThenEvalAsync: jest.fn(async () => {}),\n}));\n\njest.mock(\"../../HMRClient\", () => ({ registerBundle: jest.fn() }));\njest.mock(\"../../LoadingView\", () => ({\n showMessage: jest.fn(),\n hide: jest.fn(),\n}));\n\nit(\"loads a bundle\", async () => {\n await loadBundleAsync(\"Second\");\n expect(LoadingView.showMessage).toBeCalledWith(\"Downloading...\", \"load\");\n expect(LoadingView.hide).toBeCalledWith();\n const url = `/Second.bundle?modulesOnly=true&runModule=false&platform=web&runtimeBytecodeVersion=`;\n expect(HMRClient.registerBundle).toBeCalledWith(url);\n expect(fetchThenEvalAsync).toBeCalledWith(url);\n});\n"]}
@@ -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,CAsDf"}
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,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;SAClC;QAED,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;YACnB,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAC3D,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;QACF,kEAAkE;QAClE,MAAM,KAAK,GAAG,IAAI,iBAAiB,EAAE,CAAC;QAEtC,iCAAiC;QACjC,MAAM,CAAC,OAAO,GAAG,CAAC,EAAE,EAAE,EAAE;;YACtB,IAAI,KAAY,CAAC;YACjB,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;gBAC1B,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;AA7DD,gDA6DC;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 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"]}
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,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;QACnC,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;KACH;IACD,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,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,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
@@ -1,2 +1,3 @@
1
+ import "./location/install";
1
2
  import "./effects";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -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
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("./location/install");
3
4
  require("./effects");
4
5
  //# sourceMappingURL=index.js.map
@@ -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,3 @@
1
+ export declare function install(): void;
2
+ export declare function setLocationHref(href: string): void;
3
+ //# sourceMappingURL=Location.d.ts.map
@@ -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,3 @@
1
+ export declare function setLocationHref(href: string): void;
2
+ export declare function install(): void;
3
+ //# sourceMappingURL=Location.native.d.ts.map
@@ -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/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AAC,QAAQ;wBACvB,MAAM,EAAE,IAAI,CAAC,MAAM;qBACpB,CAAC;oBACF,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBACvD,CAAC;aACF;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,SAAS,EAAE;IAC1C,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE;QACnB,KAAK,EAAE,UAAU;QACjB,YAAY,EAAE,IAAI;KACnB;CACF,CAAC,CAAC;AAEH,IAAI,QAAQ,GAAyB,SAAS,CAAC;AAE/C,SAAgB,eAAe,CAAC,IAAY;IAC1C,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAFD,0CAEC;AAED,SAAgB,OAAO;IACrB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE;QACxC,KAAK,EAAE,QAAQ;QACf,YAAY,EAAE,IAAI;QAClB,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,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/location/install.ts"],"names":[],"mappings":"","sourcesContent":[""]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=install.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.native.d.ts","sourceRoot":"","sources":["../../src/location/install.native.ts"],"names":[],"mappings":""}
@@ -0,0 +1,81 @@
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
+ // TODO: How would someone even get this?
33
+ if (!productionBaseUrl) {
34
+ throw new Error("You must provide a production base URL to wrapFetchWithBaseUrl");
35
+ }
36
+ }
37
+ else {
38
+ // e.g. http://localhost:19006
39
+ productionBaseUrl = (0, getDevServer_1.default)().url;
40
+ }
41
+ // Ensure no trailing slash
42
+ return productionBaseUrl.replace(/\/$/, "");
43
+ }
44
+ function wrapFetchWithWindowLocation(fetch) {
45
+ if (fetch.__EXPO_BASE_URL_POLYFILLED) {
46
+ return fetch;
47
+ }
48
+ const _fetch = (...props) => {
49
+ if (props[0] && typeof props[0] === "string" && props[0].startsWith("/")) {
50
+ if (process.env.NODE_ENV !== "production") {
51
+ warnProductionOriginNotConfigured(props[0]);
52
+ }
53
+ props[0] = new url_parse_1.default(props[0], window.location.origin).toString();
54
+ }
55
+ else if (props[0] && typeof props[0] === "object") {
56
+ if (props[0].url &&
57
+ typeof props[0].url === "string" &&
58
+ props[0].url.startsWith("/")) {
59
+ if (process.env.NODE_ENV !== "production") {
60
+ warnProductionOriginNotConfigured(props[0]);
61
+ }
62
+ props[0].url = new url_parse_1.default(props[0].url, window.location.origin).toString();
63
+ }
64
+ }
65
+ return fetch(...props);
66
+ };
67
+ _fetch.__EXPO_BASE_URL_POLYFILLED = true;
68
+ return _fetch;
69
+ }
70
+ 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) {
71
+ // Polyfill window.location in native runtimes.
72
+ if (typeof window !== "undefined" && !window.location) {
73
+ (0, Location_1.setLocationHref)(getBaseUrl());
74
+ (0, Location_1.install)();
75
+ }
76
+ // Polyfill native fetch to support relative URLs
77
+ Object.defineProperty(global, "fetch", {
78
+ value: wrapFetchWithWindowLocation(fetch),
79
+ });
80
+ }
81
+ //# 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;AAC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ED,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 // TODO: How would someone even get this?\n if (!productionBaseUrl) {\n throw new Error(\n \"You must provide a production base URL to wrapFetchWithBaseUrl\"\n );\n }\n } else {\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"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=css-transformer.test.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-transformer.test.web.d.ts","sourceRoot":"","sources":["../../../../src/transformer/css/__tests__/css-transformer.test.web.ts"],"names":[],"mappings":""}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const css_transformer_1 = require("../css-transformer");
4
+ describe(css_transformer_1.transform, () => {
5
+ it(`should transform css in dev mode`, async () => {
6
+ const result = await (0, css_transformer_1.transform)({
7
+ filename: "test.css",
8
+ src: "body { color: red; }",
9
+ options: {
10
+ platform: "web",
11
+ dev: true,
12
+ hot: true,
13
+ },
14
+ });
15
+ expect(result.src).toMatchSnapshot();
16
+ expect(result.src).toMatch(/expo-css-hmr/);
17
+ });
18
+ it(`should transform css in prod mode`, async () => {
19
+ const result = await (0, css_transformer_1.transform)({
20
+ filename: "test.css",
21
+ src: "body { color: red; }",
22
+ options: {
23
+ platform: "web",
24
+ dev: false,
25
+ hot: false,
26
+ },
27
+ });
28
+ expect(result.src).toMatchSnapshot();
29
+ expect(result.src).not.toMatch(/expo-css-hmr/);
30
+ });
31
+ it(`should skip transforming css modules`, async () => {
32
+ const result = await (0, css_transformer_1.transform)({
33
+ filename: "test.module.css",
34
+ src: "body { color: red; }",
35
+ options: {
36
+ platform: "web",
37
+ dev: false,
38
+ hot: false,
39
+ },
40
+ });
41
+ expect(result.src).toEqual("module.exports = {}");
42
+ });
43
+ it(`should shim css on native`, async () => {
44
+ const result = await (0, css_transformer_1.transform)({
45
+ filename: "test.css",
46
+ src: "body { color: red; }",
47
+ options: {
48
+ platform: "ios",
49
+ dev: false,
50
+ hot: false,
51
+ },
52
+ });
53
+ expect(result.src).toEqual("");
54
+ });
55
+ it(`should shim css on native with comment in dev`, async () => {
56
+ const result = await (0, css_transformer_1.transform)({
57
+ filename: "test.css",
58
+ src: "body { color: red; }",
59
+ options: {
60
+ platform: "ios",
61
+ dev: true,
62
+ hot: false,
63
+ },
64
+ });
65
+ expect(result.src).toMatchSnapshot();
66
+ });
67
+ });
68
+ describe(css_transformer_1.pathToHtmlSafeName, () => {
69
+ it(`converts filepath to safe name`, () => {
70
+ expect((0, css_transformer_1.pathToHtmlSafeName)("foo")).toEqual("foo");
71
+ expect((0, css_transformer_1.pathToHtmlSafeName)("../123/abc/something.module.css")).toEqual("___123_abc_something_module_css");
72
+ });
73
+ });
74
+ describe(css_transformer_1.getHotReplaceTemplate, () => {
75
+ it(`should generate the correct template`, () => {
76
+ expect((0, css_transformer_1.getHotReplaceTemplate)("foo")).toMatchSnapshot();
77
+ });
78
+ });
79
+ describe(css_transformer_1.matchCssModule, () => {
80
+ it(`should match css modules`, () => {
81
+ [
82
+ "test.module.css",
83
+ "test.module.ios.css",
84
+ "test.module.android.css",
85
+ "test.module.native.css",
86
+ "test.module.web.css",
87
+ ".module.css",
88
+ "something-longer.module.css",
89
+ "../../foo-bar.module.css",
90
+ "./one/two/three/another.module.ios.css",
91
+ ].forEach((file) => expect((0, css_transformer_1.matchCssModule)(file)).toBe(true));
92
+ });
93
+ it(`should not match css modules`, () => {
94
+ [
95
+ "foo.js",
96
+ "something",
97
+ "one/two/three",
98
+ "test.css",
99
+ "test.ios.css",
100
+ "test.android.css",
101
+ "test.native.css",
102
+ "test.web.css",
103
+ "test.scss",
104
+ "test.sass",
105
+ ".css",
106
+ "../../foo-bar.css",
107
+ "./one/two/three/another.ios.css",
108
+ ].forEach((file) => expect((0, css_transformer_1.matchCssModule)(file)).toBe(false));
109
+ });
110
+ });
111
+ //# sourceMappingURL=css-transformer.test.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-transformer.test.web.js","sourceRoot":"","sources":["../../../../src/transformer/css/__tests__/css-transformer.test.web.ts"],"names":[],"mappings":";;AAAA,wDAK4B;AAE5B,QAAQ,CAAC,2BAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAS,EAAC;YAC7B,QAAQ,EAAE,UAAU;YACpB,GAAG,EAAE,sBAAsB;YAC3B,OAAO,EAAE;gBACP,QAAQ,EAAE,KAAK;gBACf,GAAG,EAAE,IAAI;gBACT,GAAG,EAAE,IAAI;aACH;SACT,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,CAAC;QAErC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAS,EAAC;YAC7B,QAAQ,EAAE,UAAU;YACpB,GAAG,EAAE,sBAAsB;YAC3B,OAAO,EAAE;gBACP,QAAQ,EAAE,KAAK;gBACf,GAAG,EAAE,KAAK;gBACV,GAAG,EAAE,KAAK;aACJ;SACT,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,CAAC;QAErC,MAAM,CAAC,MAAM,CAAC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AAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n matchCssModule,\n getHotReplaceTemplate,\n transform,\n pathToHtmlSafeName,\n} from \"../css-transformer\";\n\ndescribe(transform, () => {\n it(`should transform css in dev mode`, async () => {\n const result = await transform({\n filename: \"test.css\",\n src: \"body { color: red; }\",\n options: {\n platform: \"web\",\n dev: true,\n hot: true,\n } as any,\n });\n\n expect(result.src).toMatchSnapshot();\n\n expect(result.src).toMatch(/expo-css-hmr/);\n });\n\n it(`should transform css in prod mode`, async () => {\n const result = await transform({\n filename: \"test.css\",\n src: \"body { color: red; }\",\n options: {\n platform: \"web\",\n dev: false,\n hot: false,\n } as any,\n });\n\n expect(result.src).toMatchSnapshot();\n\n expect(result.src).not.toMatch(/expo-css-hmr/);\n });\n\n it(`should skip transforming css modules`, async () => {\n const result = await transform({\n filename: \"test.module.css\",\n src: \"body { color: red; }\",\n options: {\n platform: \"web\",\n dev: false,\n hot: false,\n } as any,\n });\n\n expect(result.src).toEqual(\"module.exports = {}\");\n });\n\n it(`should shim css on native`, async () => {\n const result = await transform({\n filename: \"test.css\",\n src: \"body { color: red; }\",\n options: {\n platform: \"ios\",\n dev: false,\n hot: false,\n } as any,\n });\n\n expect(result.src).toEqual(\"\");\n });\n it(`should shim css on native with comment in dev`, async () => {\n const result = await transform({\n filename: \"test.css\",\n src: \"body { color: red; }\",\n options: {\n platform: \"ios\",\n dev: true,\n hot: false,\n } as any,\n });\n\n expect(result.src).toMatchSnapshot();\n });\n});\n\ndescribe(pathToHtmlSafeName, () => {\n it(`converts filepath to safe name`, () => {\n expect(pathToHtmlSafeName(\"foo\")).toEqual(\"foo\");\n expect(pathToHtmlSafeName(\"../123/abc/something.module.css\")).toEqual(\n \"___123_abc_something_module_css\"\n );\n });\n});\n\ndescribe(getHotReplaceTemplate, () => {\n it(`should generate the correct template`, () => {\n expect(getHotReplaceTemplate(\"foo\")).toMatchSnapshot();\n });\n});\n\ndescribe(matchCssModule, () => {\n it(`should match css modules`, () => {\n [\n \"test.module.css\",\n \"test.module.ios.css\",\n \"test.module.android.css\",\n \"test.module.native.css\",\n \"test.module.web.css\",\n\n \".module.css\",\n \"something-longer.module.css\",\n \"../../foo-bar.module.css\",\n \"./one/two/three/another.module.ios.css\",\n ].forEach((file) => expect(matchCssModule(file)).toBe(true));\n });\n it(`should not match css modules`, () => {\n [\n \"foo.js\",\n \"something\",\n \"one/two/three\",\n \"test.css\",\n \"test.ios.css\",\n \"test.android.css\",\n \"test.native.css\",\n \"test.web.css\",\n \"test.scss\",\n \"test.sass\",\n \".css\",\n \"../../foo-bar.css\",\n \"./one/two/three/another.ios.css\",\n ].forEach((file) => expect(matchCssModule(file)).toBe(false));\n });\n});\n"]}
@@ -1,4 +1,4 @@
1
- /// <reference types="metro-source-map" />
1
+ /// <reference path="../../../../ts-declarations/metro-source-map/index.d.ts" />
2
2
  import type { BabelTransformerArgs } from "metro-babel-transformer";
3
3
  export declare function transform(props: BabelTransformerArgs): Promise<{
4
4
  ast: import("@babel/types").Node;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/metro-runtime",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "Tools for making experimental Metro bundler features work",
5
5
  "main": "build",
6
6
  "homepage": "https://github.com/expo/router/tree/main/packages/expo-metro-runtime",