@rindo/core 4.18.2 → 4.18.3-dev.1734304270.ca7046f

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 (42) hide show
  1. package/cli/index.cjs +27 -12
  2. package/cli/index.js +27 -12
  3. package/cli/package.json +1 -1
  4. package/compiler/package.json +1 -1
  5. package/compiler/rindo.js +939 -679
  6. package/dev-server/client/index.js +1 -1
  7. package/dev-server/client/package.json +1 -1
  8. package/dev-server/connector.html +2 -2
  9. package/dev-server/index.js +1 -1
  10. package/dev-server/package.json +1 -1
  11. package/dev-server/server-process.js +52 -40
  12. package/dev-server/ws.js +1 -1
  13. package/internal/app-data/package.json +1 -1
  14. package/internal/client/index.js +38 -17
  15. package/internal/client/package.json +1 -1
  16. package/internal/client/patch-browser.js +1 -1
  17. package/internal/hydrate/index.js +36 -17
  18. package/internal/hydrate/package.json +1 -1
  19. package/internal/hydrate/runner.js +70 -60
  20. package/internal/package.json +1 -1
  21. package/internal/rindo-private.d.ts +13 -7
  22. package/internal/rindo-public-compiler.d.ts +10 -3
  23. package/internal/testing/index.js +35 -16
  24. package/internal/testing/package.json +1 -1
  25. package/mock-doc/index.cjs +70 -60
  26. package/mock-doc/index.d.ts +36 -30
  27. package/mock-doc/index.js +70 -60
  28. package/mock-doc/package.json +1 -1
  29. package/package.json +18 -21
  30. package/screenshot/index.js +1 -1
  31. package/screenshot/package.json +1 -1
  32. package/screenshot/pixel-match.js +4 -1
  33. package/sys/node/autoprefixer.js +2 -2
  34. package/sys/node/glob.js +1 -1
  35. package/sys/node/index.js +2 -2
  36. package/sys/node/node-fetch.js +10 -2
  37. package/sys/node/package.json +1 -1
  38. package/sys/node/worker.js +1 -1
  39. package/testing/index.js +33 -15
  40. package/testing/mock-fetch.d.ts +4 -4
  41. package/testing/mocks.d.ts +9 -9
  42. package/testing/package.json +1 -1
package/testing/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Rindo Testing v4.18.2 | MIT Licensed | https://rindojs.web.app
2
+ Rindo Testing v4.18.3-dev.1734304270.ca7046f | MIT Licensed | https://rindojs.web.app
3
3
  */
4
4
  "use strict";
5
5
 
@@ -1771,6 +1771,7 @@ function createJestPuppeteerEnvironment() {
1771
1771
  if (!this.browser) {
1772
1772
  this.browser = await connectBrowser();
1773
1773
  }
1774
+ await this.closeOpenPages();
1774
1775
  const page = await newBrowserPage(this.browser);
1775
1776
  this.pages.push(page);
1776
1777
  const env2 = process.env;
@@ -1780,7 +1781,7 @@ function createJestPuppeteerEnvironment() {
1780
1781
  return page;
1781
1782
  }
1782
1783
  async closeOpenPages() {
1783
- await Promise.all(this.pages.map((page) => page.close()));
1784
+ await Promise.all(this.pages.filter((page) => !page.isClosed()).map((page) => page.close()));
1784
1785
  this.pages.length = 0;
1785
1786
  }
1786
1787
  async teardown() {
@@ -3586,15 +3587,17 @@ function jestSetupTestFramework() {
3586
3587
  });
3587
3588
  afterEach(async () => {
3588
3589
  var _a, _b, _c, _d, _e, _f;
3589
- if (global.__CLOSE_OPEN_PAGES__) {
3590
- await global.__CLOSE_OPEN_PAGES__();
3591
- }
3592
3590
  (0, import_testing.stopAutoApplyChanges)();
3593
3591
  const bodyNode = (_e = (_d = (_c = (_b = (_a = global.window) == null ? void 0 : _a.document) == null ? void 0 : _b.childNodes) == null ? void 0 : _c[1]) == null ? void 0 : _d.childNodes) == null ? void 0 : _e.find((ref) => ref.nodeName === "BODY");
3594
3592
  (_f = bodyNode == null ? void 0 : bodyNode.childNodes) == null ? void 0 : _f.forEach(removeDomNodes);
3595
3593
  (0, import_mock_doc7.teardownGlobal)(global);
3596
3594
  global.resourcesUrl = "/build";
3597
3595
  });
3596
+ afterAll(async () => {
3597
+ if (global.__CLOSE_OPEN_PAGES__) {
3598
+ await global.__CLOSE_OPEN_PAGES__();
3599
+ }
3600
+ });
3598
3601
  const jasmineEnv = jasmine.getEnv();
3599
3602
  if (jasmineEnv != null) {
3600
3603
  jasmineEnv.addReporter({
@@ -3701,6 +3704,7 @@ function createJestPuppeteerEnvironment2() {
3701
3704
  if (!this.browser) {
3702
3705
  this.browser = await connectBrowser();
3703
3706
  }
3707
+ await this.closeOpenPages();
3704
3708
  const page = await newBrowserPage(this.browser);
3705
3709
  this.pages.push(page);
3706
3710
  const env2 = process.env;
@@ -3710,7 +3714,7 @@ function createJestPuppeteerEnvironment2() {
3710
3714
  return page;
3711
3715
  }
3712
3716
  async closeOpenPages() {
3713
- await Promise.all(this.pages.map((page) => page.close()));
3717
+ await Promise.all(this.pages.filter((page) => !page.isClosed()).map((page) => page.close()));
3714
3718
  this.pages.length = 0;
3715
3719
  }
3716
3720
  async teardown() {
@@ -4595,15 +4599,17 @@ function jestSetupTestFramework2() {
4595
4599
  });
4596
4600
  afterEach(async () => {
4597
4601
  var _a, _b, _c, _d, _e, _f;
4598
- if (global.__CLOSE_OPEN_PAGES__) {
4599
- await global.__CLOSE_OPEN_PAGES__();
4600
- }
4601
4602
  (0, import_testing2.stopAutoApplyChanges)();
4602
4603
  const bodyNode = (_e = (_d = (_c = (_b = (_a = global.window) == null ? void 0 : _a.document) == null ? void 0 : _b.childNodes) == null ? void 0 : _c[1]) == null ? void 0 : _d.childNodes) == null ? void 0 : _e.find((ref) => ref.nodeName === "BODY");
4603
4604
  (_f = bodyNode == null ? void 0 : bodyNode.childNodes) == null ? void 0 : _f.forEach(removeDomNodes2);
4604
4605
  (0, import_mock_doc12.teardownGlobal)(global);
4605
4606
  global.resourcesUrl = "/build";
4606
4607
  });
4608
+ afterAll(async () => {
4609
+ if (global.__CLOSE_OPEN_PAGES__) {
4610
+ await global.__CLOSE_OPEN_PAGES__();
4611
+ }
4612
+ });
4607
4613
  global.screenshotDescriptions = /* @__PURE__ */ new Set();
4608
4614
  const env2 = process.env;
4609
4615
  if (typeof env2.__RINDO_DEFAULT_TIMEOUT__ === "string") {
@@ -4701,6 +4707,7 @@ function createJestPuppeteerEnvironment3() {
4701
4707
  if (!this.browser) {
4702
4708
  this.browser = await connectBrowser();
4703
4709
  }
4710
+ await this.closeOpenPages();
4704
4711
  const page = await newBrowserPage(this.browser);
4705
4712
  this.pages.push(page);
4706
4713
  const env2 = process.env;
@@ -4710,7 +4717,7 @@ function createJestPuppeteerEnvironment3() {
4710
4717
  return page;
4711
4718
  }
4712
4719
  async closeOpenPages() {
4713
- await Promise.all(this.pages.map((page) => page.close()));
4720
+ await Promise.all(this.pages.filter((page) => !page.isClosed()).map((page) => page.close()));
4714
4721
  this.pages.length = 0;
4715
4722
  }
4716
4723
  async teardown() {
@@ -5595,15 +5602,17 @@ function jestSetupTestFramework3() {
5595
5602
  });
5596
5603
  afterEach(async () => {
5597
5604
  var _a, _b, _c, _d, _e, _f;
5598
- if (global.__CLOSE_OPEN_PAGES__) {
5599
- await global.__CLOSE_OPEN_PAGES__();
5600
- }
5601
5605
  (0, import_testing3.stopAutoApplyChanges)();
5602
5606
  const bodyNode = (_e = (_d = (_c = (_b = (_a = global.window) == null ? void 0 : _a.document) == null ? void 0 : _b.childNodes) == null ? void 0 : _c[1]) == null ? void 0 : _d.childNodes) == null ? void 0 : _e.find((ref) => ref.nodeName === "BODY");
5603
5607
  (_f = bodyNode == null ? void 0 : bodyNode.childNodes) == null ? void 0 : _f.forEach(removeDomNodes3);
5604
5608
  (0, import_mock_doc17.teardownGlobal)(global);
5605
5609
  global.resourcesUrl = "/build";
5606
5610
  });
5611
+ afterAll(async () => {
5612
+ if (global.__CLOSE_OPEN_PAGES__) {
5613
+ await global.__CLOSE_OPEN_PAGES__();
5614
+ }
5615
+ });
5607
5616
  global.screenshotDescriptions = /* @__PURE__ */ new Set();
5608
5617
  const env2 = process.env;
5609
5618
  if (typeof env2.__RINDO_DEFAULT_TIMEOUT__ === "string") {
@@ -5699,6 +5708,9 @@ var getJestFacade = () => {
5699
5708
  JEST_RINDO_FACADE = new Jest27Rindo();
5700
5709
  }
5701
5710
  }
5711
+ if (!JEST_RINDO_FACADE) {
5712
+ throw new Error("Rindo could not determine the Jest version being used.");
5713
+ }
5702
5714
  return JEST_RINDO_FACADE;
5703
5715
  };
5704
5716
  var getRunner = () => {
@@ -6951,6 +6963,7 @@ var validateConfig = (userConfig = {}, bootstrapConfig) => {
6951
6963
  devMode,
6952
6964
  extras: config.extras || {},
6953
6965
  flags,
6966
+ generateExportMaps: isBoolean(config.generateExportMaps) ? config.generateExportMaps : false,
6954
6967
  hashFileNames,
6955
6968
  hashedFileNameLength: (_c = config.hashedFileNameLength) != null ? _c : DEFAULT_HASHED_FILENAME_LENGTH,
6956
6969
  hydratedFlag: validateHydrated(config),
@@ -9711,6 +9724,9 @@ var E2EElement = class extends import_mock_doc19.MockHTMLElement {
9711
9724
  }
9712
9725
  const frag = (0, import_mock_doc19.parseHtmlToFragment)(outerHTML);
9713
9726
  const rootElm = frag.firstElementChild;
9727
+ if (!rootElm) {
9728
+ return;
9729
+ }
9714
9730
  this.nodeName = rootElm.nodeName;
9715
9731
  this.attributes = (0, import_mock_doc19.cloneAttributes)(rootElm.attributes);
9716
9732
  while (this.childNodes.length > 0) {
@@ -9906,7 +9922,6 @@ async function compareScreenshot(emulateConfig, screenshotBuildData, currentScre
9906
9922
  const currentImageName = `${currentImageHash}.png`;
9907
9923
  const currentImagePath = (0, import_path26.join)(screenshotBuildData.imagesDir, currentImageName);
9908
9924
  await writeScreenshotImage(currentImagePath, currentScreenshotBuf);
9909
- currentScreenshotBuf = null;
9910
9925
  if (testPath) {
9911
9926
  testPath = normalizePath((0, import_path26.relative)(screenshotBuildData.rootDir, testPath));
9912
9927
  }
@@ -9979,6 +9994,7 @@ async function compareScreenshot(emulateConfig, screenshotBuildData, currentScre
9979
9994
  }
9980
9995
  async function getMismatchedPixels(pixelmatchModulePath, pixelMatchInput, screenshotTimeoutMs) {
9981
9996
  return new Promise((resolve3, reject) => {
9997
+ var _a;
9982
9998
  const timeout = screenshotTimeoutMs !== null ? screenshotTimeoutMs : typeof jasmine !== "undefined" && jasmine.DEFAULT_TIMEOUT_INTERVAL ? jasmine.DEFAULT_TIMEOUT_INTERVAL * 0.5 : DEFAULT_SCREENSHOT_TIMEOUT;
9983
9999
  const tmr = setTimeout(() => {
9984
10000
  reject(`getMismatchedPixels timeout: ${timeout}ms`);
@@ -10002,7 +10018,7 @@ async function getMismatchedPixels(pixelmatchModulePath, pixelMatchInput, screen
10002
10018
  clearTimeout(tmr);
10003
10019
  reject(err2);
10004
10020
  });
10005
- pixelMatchProcess.stderr.on("data", (data) => {
10021
+ (_a = pixelMatchProcess.stderr) == null ? void 0 : _a.on("data", (data) => {
10006
10022
  error = data.toString();
10007
10023
  });
10008
10024
  pixelMatchProcess.on("exit", (code) => {
@@ -10149,6 +10165,7 @@ function createPuppeteerScreenshotOptions(opts, { width, height }) {
10149
10165
  encoding: "binary"
10150
10166
  };
10151
10167
  if (opts.clip) {
10168
+ puppeteerOpts.captureBeyondViewport = typeof opts.captureBeyondViewport === "boolean" ? opts.captureBeyondViewport : true;
10152
10169
  puppeteerOpts.clip = {
10153
10170
  x: opts.clip.x,
10154
10171
  y: opts.clip.y,
@@ -10156,6 +10173,7 @@ function createPuppeteerScreenshotOptions(opts, { width, height }) {
10156
10173
  height: opts.clip.height
10157
10174
  };
10158
10175
  } else {
10176
+ puppeteerOpts.captureBeyondViewport = typeof opts.captureBeyondViewport === "boolean" ? opts.captureBeyondViewport : false;
10159
10177
  puppeteerOpts.clip = {
10160
10178
  x: 0,
10161
10179
  y: 0,
@@ -2,10 +2,10 @@ import { MockResponse } from '@rindo/core/mock-doc';
2
2
  export declare function setupMockFetch(global: any): void;
3
3
  export declare function mockFetchReset(): void;
4
4
  export declare const mockFetch: {
5
- json(data: any, url?: string): void;
6
- text(data: string, url?: string): void;
7
- response(rsp: MockResponse, url?: string): void;
8
- reject(rsp?: MockResponse, url?: string): void;
5
+ json(data: any, url: string): void;
6
+ text(data: string, url: string): void;
7
+ response(rsp: MockResponse, url: string): void;
8
+ reject(rsp: MockResponse, url: string): void;
9
9
  reset: typeof mockFetchReset;
10
10
  };
11
11
  export { MockHeaders, MockRequest, MockRequestInfo, MockRequestInit, MockResponse, MockResponseInit, } from '@rindo/core/mock-doc';
@@ -1,4 +1,4 @@
1
- import type { BuildCtx, CompilerCtx, LoadConfigInit, Module, UnvalidatedConfig, ValidatedConfig } from '@rindo/core/internal';
1
+ import type * as d from '@rindo/core/internal';
2
2
  import { TestingLogger } from './testing-logger';
3
3
  import { TestingSystem } from './testing-sys';
4
4
  /**
@@ -8,7 +8,7 @@ import { TestingSystem } from './testing-sys';
8
8
  * provided by this function.
9
9
  * @returns the mock Rindo configuration
10
10
  */
11
- export declare function mockValidatedConfig(overrides?: Partial<ValidatedConfig>): ValidatedConfig;
11
+ export declare function mockValidatedConfig(overrides?: Partial<d.ValidatedConfig>): d.ValidatedConfig;
12
12
  /**
13
13
  * Creates a mock instance of a Rindo configuration entity. The mocked configuration has no guarantees around the
14
14
  * types/validity of its data.
@@ -16,7 +16,7 @@ export declare function mockValidatedConfig(overrides?: Partial<ValidatedConfig>
16
16
  * provided by this function.
17
17
  * @returns the mock Rindo configuration
18
18
  */
19
- export declare function mockConfig(overrides?: Partial<UnvalidatedConfig>): UnvalidatedConfig;
19
+ export declare function mockConfig(overrides?: Partial<d.UnvalidatedConfig>): d.UnvalidatedConfig;
20
20
  /**
21
21
  * Creates a configuration object used to bootstrap a Rindo task invocation
22
22
  *
@@ -27,16 +27,16 @@ export declare function mockConfig(overrides?: Partial<UnvalidatedConfig>): Unva
27
27
  * @param overrides the properties on the default entity to manually override
28
28
  * @returns the default configuration initialization object, with any overrides applied
29
29
  */
30
- export declare const mockLoadConfigInit: (overrides?: Partial<LoadConfigInit>) => LoadConfigInit;
31
- export declare function mockCompilerCtx(config?: ValidatedConfig): CompilerCtx;
32
- export declare function mockBuildCtx(config?: ValidatedConfig, compilerCtx?: CompilerCtx): BuildCtx;
30
+ export declare const mockLoadConfigInit: (overrides?: Partial<d.LoadConfigInit>) => d.LoadConfigInit;
31
+ export declare function mockCompilerCtx(config?: d.ValidatedConfig): d.CompilerCtx;
32
+ export declare function mockBuildCtx(config?: d.ValidatedConfig, compilerCtx?: d.CompilerCtx): d.BuildCtx;
33
33
  export declare function mockLogger(): TestingLogger;
34
34
  /**
35
- * Create a {@link CompilerSystem} entity for testing the compiler.
35
+ * Create a {@link d.CompilerSystem} entity for testing the compiler.
36
36
  *
37
37
  * This function acts as a thin wrapper around a {@link TestingSystem} entity creation. It exists to provide a logical
38
38
  * place in the codebase where we might expect Rindo engineers to reach for when attempting to mock a
39
- * {@link CompilerSystem} base type. Should there prove to be usage of both this function and the one it wraps,
39
+ * {@link d.CompilerSystem} base type. Should there prove to be usage of both this function and the one it wraps,
40
40
  * reconsider if this wrapper is necessary.
41
41
  *
42
42
  * @returns a System instance for testing purposes.
@@ -52,4 +52,4 @@ export declare function mockWindow(html?: string): Window;
52
52
  * @param mod is an override module that you can supply to set particular values
53
53
  * @returns a module object ready to use in tests!
54
54
  */
55
- export declare const mockModule: (mod?: Partial<Module>) => Module;
55
+ export declare const mockModule: (mod?: Partial<d.Module>) => d.Module;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rindo/core/testing",
3
- "version": "4.18.2",
3
+ "version": "4.18.3-dev.1734304270.ca7046f",
4
4
  "description": "Rindo testing suite.",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",