@expo/metro-runtime 1.1.0 → 1.1.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.
Files changed (30) 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/transformer/css/__tests__/css-transformer.test.web.d.ts +2 -0
  26. package/build/transformer/css/__tests__/css-transformer.test.web.d.ts.map +1 -0
  27. package/build/transformer/css/__tests__/css-transformer.test.web.js +111 -0
  28. package/build/transformer/css/__tests__/css-transformer.test.web.js.map +1 -0
  29. package/build/transformer/index.d.ts +1 -1
  30. 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,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AACzC,UAAU,CAAC,GAAG,EAAE;IACd,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,aAAa,CAAC;AACvC,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,GAAG,EAAE;IACZ,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,WAAW,CAAC;AACrC,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;IACtC,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAC;IAClC,MAAM,YAAY,GAAG,IAAA,qCAAiB,EAAC,QAAQ,CAAC,CAAC;IAEjD,MAAM,CAAC,YAAY,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC9C,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IACvD,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC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,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;IACrD,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;IACpC,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAC;IAElC,IAAA,cAAM,EAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,mBAAmB,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;IAE/D,MAAM,YAAY,GAAG,IAAA,qCAAiB,EAAC,QAAQ,CAAC,CAAC;IAEjD,MAAM,CAAC,YAAY,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAE9C,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE;QACzC,GAAG,EAAE,KAAK;KACX,CAAC,CAAC;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;AAC9C,4DAAyD;AAElD,MAAM,MAAM,GAAG,CACpB,EAAK,EACmB,EAAE,CAAC,EAA4B,CAAC;AAF7C,QAAA,MAAM,UAEuC;AAE1D,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,GAAG,EAAE;IACnC,OAAO,IAAI,CAAC,EAAE,EAAE,CAAC;AACnB,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACjC,IAAA,cAAM,EAAC,sBAAY,CAAC,CAAC,mBAAmB,CAAC;QACvC,sBAAsB,EAAE,IAAI;QAC5B,aAAa,EACX,sGAAsG;QACxG,GAAG,EAAE,wBAAwB;KAC9B,CAAC,CAAC;IAEH,MAAM,CAAC,IAAA,qCAAiB,EAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAC9C,oHAAoH,CACrH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;IACvD,IAAA,cAAM,EAAC,sBAAY,CAAC,CAAC,mBAAmB,CAAC;QACvC,sBAAsB,EAAE,IAAI;QAC5B,aAAa,EAAE,yCAAyC;QACxD,GAAG,EAAE,wBAAwB;KAC9B,CAAC,CAAC;IAEH,MAAM,CAAC,IAAA,qCAAiB,EAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,CACpE,yEAAyE,CAC1E,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;IACxD,IAAA,cAAM,EAAC,sBAAY,CAAC,CAAC,mBAAmB,CAAC;QACvC,sBAAsB,EAAE,KAAK;QAC7B,aAAa,EAAE,SAAS;QACxB,GAAG,EAAE,SAAS;KACf,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,EAAE,CACV,IAAA,qCAAiB,EAAC,QAAQ,EAAE,EAAE,CAAC,CAChC,CAAC,kCAAkC,CAClC,+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":[],"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;AACJ,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,6BAA6B;AAE7B,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,GACP,4GAA4G,CAAC;IAC/G,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}));\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"]}
@@ -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,CA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AAqB;YAErB,aAAa;YACb,6BAA6B;YAC7B,0BAA0B;YAC1B,wCAAwC;SACzC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAA,gCAAc,EAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC;YACE,QAAQ;YACR,WAAW;YACX,eAAe;YACf,UAAU;YACV,cAAc;YACd,kBAAkB;YAClB,iBAAiB;YACjB,cAAc;YACd,WAAW;YACX,WAAW;YACX,MAAM;YACN,mBAAmB;YACnB,iCAAiC;SAClC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAA,gCAAc,EAAC,IAAI,CAAC,CAAC,CAAC,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": "1.1.1",
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",