@noma.to/qwik-testing-library 1.3.1 → 1.3.2

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 (94) hide show
  1. package/README.md +12 -2
  2. package/lib/index.qwik.cjs +0 -4
  3. package/lib/index.qwik.mjs +0 -4
  4. package/lib/lib/qwik-testing-library.qwik.cjs +0 -4
  5. package/lib/lib/qwik-testing-library.qwik.mjs +0 -4
  6. package/lib-types/lib/qwik-testing-library.d.ts +1 -2
  7. package/package.json +9 -9
  8. package/lib/lib/mock.qwik.cjs +0 -14
  9. package/lib/lib/mock.qwik.mjs +0 -14
  10. package/lib/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.qwik.cjs +0 -89
  11. package/lib/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.qwik.mjs +0 -89
  12. package/lib/node_modules/.pnpm/@vitest_expect@3.0.5/node_modules/@vitest/expect/dist/index.qwik.cjs +0 -2191
  13. package/lib/node_modules/.pnpm/@vitest_expect@3.0.5/node_modules/@vitest/expect/dist/index.qwik.mjs +0 -2191
  14. package/lib/node_modules/.pnpm/@vitest_pretty-format@3.0.5/node_modules/@vitest/pretty-format/dist/index.qwik.cjs +0 -1499
  15. package/lib/node_modules/.pnpm/@vitest_pretty-format@3.0.5/node_modules/@vitest/pretty-format/dist/index.qwik.mjs +0 -1499
  16. package/lib/node_modules/.pnpm/@vitest_runner@3.0.5/node_modules/@vitest/runner/dist/chunk-tasks.qwik.cjs +0 -44
  17. package/lib/node_modules/.pnpm/@vitest_runner@3.0.5/node_modules/@vitest/runner/dist/chunk-tasks.qwik.mjs +0 -44
  18. package/lib/node_modules/.pnpm/@vitest_runner@3.0.5/node_modules/@vitest/runner/dist/index.qwik.cjs +0 -757
  19. package/lib/node_modules/.pnpm/@vitest_runner@3.0.5/node_modules/@vitest/runner/dist/index.qwik.mjs +0 -757
  20. package/lib/node_modules/.pnpm/@vitest_snapshot@3.0.5/node_modules/@vitest/snapshot/dist/index.qwik.cjs +0 -2079
  21. package/lib/node_modules/.pnpm/@vitest_snapshot@3.0.5/node_modules/@vitest/snapshot/dist/index.qwik.mjs +0 -2079
  22. package/lib/node_modules/.pnpm/@vitest_spy@3.0.5/node_modules/@vitest/spy/dist/index.qwik.cjs +0 -165
  23. package/lib/node_modules/.pnpm/@vitest_spy@3.0.5/node_modules/@vitest/spy/dist/index.qwik.mjs +0 -165
  24. package/lib/node_modules/.pnpm/@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.qwik.cjs +0 -162
  25. package/lib/node_modules/.pnpm/@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.qwik.mjs +0 -162
  26. package/lib/node_modules/.pnpm/@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/diff.qwik.cjs +0 -1755
  27. package/lib/node_modules/.pnpm/@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/diff.qwik.mjs +0 -1755
  28. package/lib/node_modules/.pnpm/@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/error.qwik.cjs +0 -137
  29. package/lib/node_modules/.pnpm/@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/error.qwik.mjs +0 -137
  30. package/lib/node_modules/.pnpm/@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/helpers.qwik.cjs +0 -150
  31. package/lib/node_modules/.pnpm/@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/helpers.qwik.mjs +0 -150
  32. package/lib/node_modules/.pnpm/@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/index.qwik.cjs +0 -474
  33. package/lib/node_modules/.pnpm/@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/index.qwik.mjs +0 -474
  34. package/lib/node_modules/.pnpm/@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/source-map.qwik.cjs +0 -216
  35. package/lib/node_modules/.pnpm/@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/source-map.qwik.mjs +0 -216
  36. package/lib/node_modules/.pnpm/chai@5.1.2/node_modules/chai/chai.qwik.cjs +0 -3937
  37. package/lib/node_modules/.pnpm/chai@5.1.2/node_modules/chai/chai.qwik.mjs +0 -3937
  38. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/arguments.qwik.cjs +0 -9
  39. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/arguments.qwik.mjs +0 -10
  40. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/array.qwik.cjs +0 -16
  41. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/array.qwik.mjs +0 -17
  42. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/bigint.qwik.cjs +0 -9
  43. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/bigint.qwik.mjs +0 -10
  44. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/class.qwik.cjs +0 -16
  45. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/class.qwik.mjs +0 -17
  46. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/date.qwik.cjs +0 -12
  47. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/date.qwik.mjs +0 -13
  48. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/error.qwik.cjs +0 -36
  49. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/error.qwik.mjs +0 -37
  50. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/function.qwik.cjs +0 -11
  51. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/function.qwik.mjs +0 -12
  52. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/helpers.qwik.cjs +0 -160
  53. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/helpers.qwik.mjs +0 -160
  54. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/html.qwik.cjs +0 -36
  55. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/html.qwik.mjs +0 -36
  56. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/index.qwik.cjs +0 -130
  57. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/index.qwik.mjs +0 -130
  58. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/map.qwik.cjs +0 -23
  59. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/map.qwik.mjs +0 -24
  60. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/number.qwik.cjs +0 -19
  61. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/number.qwik.mjs +0 -20
  62. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/object.qwik.cjs +0 -24
  63. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/object.qwik.mjs +0 -25
  64. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/promise.qwik.cjs +0 -17
  65. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/promise.qwik.mjs +0 -18
  66. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/regexp.qwik.cjs +0 -9
  67. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/regexp.qwik.mjs +0 -10
  68. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/set.qwik.cjs +0 -16
  69. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/set.qwik.mjs +0 -17
  70. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/string.qwik.cjs +0 -23
  71. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/string.qwik.mjs +0 -24
  72. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/symbol.qwik.cjs +0 -8
  73. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/symbol.qwik.mjs +0 -9
  74. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/typedarray.qwik.cjs +0 -34
  75. package/lib/node_modules/.pnpm/loupe@3.1.3/node_modules/loupe/lib/typedarray.qwik.mjs +0 -35
  76. package/lib/node_modules/.pnpm/magic-string@0.30.17/node_modules/magic-string/dist/magic-string.es.qwik.cjs +0 -979
  77. package/lib/node_modules/.pnpm/magic-string@0.30.17/node_modules/magic-string/dist/magic-string.es.qwik.mjs +0 -979
  78. package/lib/node_modules/.pnpm/pathe@2.0.2/node_modules/pathe/dist/shared/pathe.UZ-hd4nF.qwik.cjs +0 -101
  79. package/lib/node_modules/.pnpm/pathe@2.0.2/node_modules/pathe/dist/shared/pathe.UZ-hd4nF.qwik.mjs +0 -101
  80. package/lib/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/browser.qwik.cjs +0 -4
  81. package/lib/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/browser.qwik.mjs +0 -5
  82. package/lib/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.qwik.cjs +0 -80
  83. package/lib/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.qwik.mjs +0 -80
  84. package/lib/node_modules/.pnpm/tinyspy@3.0.2/node_modules/tinyspy/dist/index.qwik.cjs +0 -104
  85. package/lib/node_modules/.pnpm/tinyspy@3.0.2/node_modules/tinyspy/dist/index.qwik.mjs +0 -104
  86. package/lib/node_modules/.pnpm/vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.qwik.cjs +0 -8
  87. package/lib/node_modules/.pnpm/vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.qwik.mjs +0 -8
  88. package/lib/node_modules/.pnpm/vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/date.W2xKR2qe.qwik.cjs +0 -56
  89. package/lib/node_modules/.pnpm/vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/date.W2xKR2qe.qwik.mjs +0 -56
  90. package/lib/node_modules/.pnpm/vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/utils.C8RiOc4B.qwik.cjs +0 -66
  91. package/lib/node_modules/.pnpm/vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/utils.C8RiOc4B.qwik.mjs +0 -66
  92. package/lib/node_modules/.pnpm/vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.CjhMlMwf.qwik.cjs +0 -2977
  93. package/lib/node_modules/.pnpm/vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.CjhMlMwf.qwik.mjs +0 -2977
  94. package/lib-types/lib/mock.d.ts +0 -34
package/README.md CHANGED
@@ -318,17 +318,27 @@ describe("<Counter />", () => {
318
318
  > This feature is under a testing phase and thus experimental.
319
319
  > Its API may change in the future, so use it at your own risk.
320
320
 
321
- The Qwik Testing Library provides a `mock$` function
321
+ #### Setup
322
+
323
+ Optionally, you can install `@noma.to/qwik-mock` to mock callbacks of Qwik components. It provides a `mock$` function
322
324
  that can be used to create a mock of a QRL and verify interactions on your Qwik components.
323
325
 
326
+ ```shell
327
+ npm install --save-dev @noma.to/qwik-mock
328
+ ```
329
+
324
330
  It is _not_ a replacement of regular mocking functions (such as `vi.fn` and `vi.mock`) as its intended use is only for
325
331
  testing callbacks of Qwik components.
326
332
 
333
+ #### Usage
334
+
327
335
  Here's an example on how to use the `mock$` function:
328
336
 
329
337
  ```tsx title="counter.spec.tsx"
330
338
  // import qwik-testing methods
331
- import {mock$, clearAllMock, render, screen, waitFor} from "@noma.to/qwik-testing-library";
339
+ import {render, screen, waitFor} from "@noma.to/qwik-testing-library";
340
+ // import qwik-mock methods
341
+ import {mock$, clearAllMock} from "@noma.to/qwik-mock";
332
342
  // import the userEvent methods to interact with the DOM
333
343
  import {userEvent} from "@testing-library/user-event";
334
344
 
@@ -2,12 +2,8 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const qwikTestingLibrary = require("./lib/qwik-testing-library.qwik.cjs");
4
4
  const dom = require("@testing-library/dom");
5
- const mock = require("./lib/mock.qwik.cjs");
6
5
  exports.cleanup = qwikTestingLibrary.cleanup;
7
6
  exports.render = qwikTestingLibrary.render;
8
- exports.clearAllMocks = mock.clearAllMocks;
9
- exports.mock$ = mock.mock$;
10
- exports.mockQrl = mock.mockQrl;
11
7
  Object.keys(dom).forEach((k) => {
12
8
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
13
9
  enumerable: true,
@@ -1,10 +1,6 @@
1
1
  import { cleanup, render } from "./lib/qwik-testing-library.qwik.mjs";
2
2
  export * from "@testing-library/dom";
3
- import { clearAllMocks, mock$, mockQrl } from "./lib/mock.qwik.mjs";
4
3
  export {
5
4
  cleanup,
6
- clearAllMocks,
7
- mock$,
8
- mockQrl,
9
5
  render
10
6
  };
@@ -24,7 +24,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
25
  const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
26
26
  const dom = require("@testing-library/dom");
27
- const mock = require("./mock.qwik.cjs");
28
27
  const qwikloader = require("./qwikloader.qwik.cjs");
29
28
  if (typeof process === "undefined" || !process.env?.QTL_SKIP_AUTO_CLEANUP) {
30
29
  if (typeof afterEach === "function") {
@@ -86,9 +85,6 @@ function cleanupAtContainer(ref) {
86
85
  function cleanup() {
87
86
  mountedContainers.forEach(cleanupAtContainer);
88
87
  }
89
- exports.clearAllMocks = mock.clearAllMocks;
90
- exports.mock$ = mock.mock$;
91
- exports.mockQrl = mock.mockQrl;
92
88
  exports.cleanup = cleanup;
93
89
  exports.render = render;
94
90
  Object.keys(dom).forEach((k) => {
@@ -1,7 +1,6 @@
1
1
  import { jsx } from "@builder.io/qwik/jsx-runtime";
2
2
  import { getQueriesForElement, prettyDOM } from "@testing-library/dom";
3
3
  export * from "@testing-library/dom";
4
- import { clearAllMocks, mock$, mockQrl } from "./mock.qwik.mjs";
5
4
  import { qwikLoader } from "./qwikloader.qwik.mjs";
6
5
  if (typeof process === "undefined" || !process.env?.QTL_SKIP_AUTO_CLEANUP) {
7
6
  if (typeof afterEach === "function") {
@@ -65,8 +64,5 @@ function cleanup() {
65
64
  }
66
65
  export {
67
66
  cleanup,
68
- clearAllMocks,
69
- mock$,
70
- mockQrl,
71
67
  render
72
68
  };
@@ -1,7 +1,6 @@
1
1
  import { JSXOutput } from "@builder.io/qwik";
2
2
  import type { Options, Result } from "./types";
3
- import { clearAllMocks, mock$, mockQrl } from "./mock";
4
3
  declare function render(ui: JSXOutput, options?: Options): Promise<Result>;
5
4
  declare function cleanup(): void;
6
5
  export * from "@testing-library/dom";
7
- export { cleanup, render, mock$, mockQrl, clearAllMocks };
6
+ export { cleanup, render };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noma.to/qwik-testing-library",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Simple and complete Qwik testing utilities that encourage good testing practices.",
5
5
  "repository": "https://github.com/ianlet/qwik-testing-library",
6
6
  "homepage": "https://github.com/ianlet/qwik-testing-library",
@@ -35,17 +35,17 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/eslint": "8.56.10",
38
- "@types/node": "22.13.1",
39
- "@typescript-eslint/eslint-plugin": "8.24.0",
40
- "@typescript-eslint/parser": "8.24.0",
38
+ "@types/node": "22.13.8",
39
+ "@typescript-eslint/eslint-plugin": "8.28.0",
40
+ "@typescript-eslint/parser": "8.28.0",
41
41
  "eslint": "8.57.1",
42
- "eslint-plugin-qwik": "1.12.0",
43
- "prettier": "3.5.0",
44
- "typescript": "5.7.3",
42
+ "eslint-plugin-qwik": "1.12.1",
43
+ "prettier": "3.5.3",
44
+ "typescript": "5.8.2",
45
45
  "undici": "*",
46
- "vite": "6.1.0",
46
+ "vite": "6.2.3",
47
47
  "vite-tsconfig-paths": "^5.1.4",
48
- "vitest": "^3.0.5"
48
+ "vitest": "^3.0.9"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@builder.io/qwik": ">= 1.12.0 < 2",
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const qwik = require("@builder.io/qwik");
4
- const vi_CjhMlMwf = require("../node_modules/.pnpm/vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.CjhMlMwf.qwik.cjs");
5
- const mockQrl = () => {
6
- return qwik.$(vi_CjhMlMwf.v.fn());
7
- };
8
- const mock$ = qwik.implicit$FirstArg(mockQrl);
9
- function clearAllMocks() {
10
- vi_CjhMlMwf.v.clearAllMocks();
11
- }
12
- exports.clearAllMocks = clearAllMocks;
13
- exports.mock$ = mock$;
14
- exports.mockQrl = mockQrl;
@@ -1,14 +0,0 @@
1
- import { implicit$FirstArg, $ } from "@builder.io/qwik";
2
- import { v as vi } from "../node_modules/.pnpm/vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.CjhMlMwf.qwik.mjs";
3
- const mockQrl = () => {
4
- return $(vi.fn());
5
- };
6
- const mock$ = implicit$FirstArg(mockQrl);
7
- function clearAllMocks() {
8
- vi.clearAllMocks();
9
- }
10
- export {
11
- clearAllMocks,
12
- mock$,
13
- mockQrl
14
- };
@@ -1,89 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const comma = ",".charCodeAt(0);
4
- const semicolon = ";".charCodeAt(0);
5
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
6
- const intToChar = new Uint8Array(64);
7
- const charToInt = new Uint8Array(128);
8
- for (let i = 0; i < chars.length; i++) {
9
- const c = chars.charCodeAt(i);
10
- intToChar[i] = c;
11
- charToInt[c] = i;
12
- }
13
- function encodeInteger(builder, num, relative) {
14
- let delta = num - relative;
15
- delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
16
- do {
17
- let clamped = delta & 31;
18
- delta >>>= 5;
19
- if (delta > 0)
20
- clamped |= 32;
21
- builder.write(intToChar[clamped]);
22
- } while (delta > 0);
23
- return num;
24
- }
25
- const bufLength = 1024 * 16;
26
- const td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
27
- decode(buf) {
28
- const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
29
- return out.toString();
30
- }
31
- } : {
32
- decode(buf) {
33
- let out = "";
34
- for (let i = 0; i < buf.length; i++) {
35
- out += String.fromCharCode(buf[i]);
36
- }
37
- return out;
38
- }
39
- };
40
- class StringWriter {
41
- constructor() {
42
- this.pos = 0;
43
- this.out = "";
44
- this.buffer = new Uint8Array(bufLength);
45
- }
46
- write(v) {
47
- const { buffer } = this;
48
- buffer[this.pos++] = v;
49
- if (this.pos === bufLength) {
50
- this.out += td.decode(buffer);
51
- this.pos = 0;
52
- }
53
- }
54
- flush() {
55
- const { buffer, out, pos } = this;
56
- return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
57
- }
58
- }
59
- function encode(decoded) {
60
- const writer = new StringWriter();
61
- let sourcesIndex = 0;
62
- let sourceLine = 0;
63
- let sourceColumn = 0;
64
- let namesIndex = 0;
65
- for (let i = 0; i < decoded.length; i++) {
66
- const line = decoded[i];
67
- if (i > 0)
68
- writer.write(semicolon);
69
- if (line.length === 0)
70
- continue;
71
- let genColumn = 0;
72
- for (let j = 0; j < line.length; j++) {
73
- const segment = line[j];
74
- if (j > 0)
75
- writer.write(comma);
76
- genColumn = encodeInteger(writer, segment[0], genColumn);
77
- if (segment.length === 1)
78
- continue;
79
- sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
80
- sourceLine = encodeInteger(writer, segment[2], sourceLine);
81
- sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
82
- if (segment.length === 4)
83
- continue;
84
- namesIndex = encodeInteger(writer, segment[4], namesIndex);
85
- }
86
- }
87
- return writer.flush();
88
- }
89
- exports.encode = encode;
@@ -1,89 +0,0 @@
1
- const comma = ",".charCodeAt(0);
2
- const semicolon = ";".charCodeAt(0);
3
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
4
- const intToChar = new Uint8Array(64);
5
- const charToInt = new Uint8Array(128);
6
- for (let i = 0; i < chars.length; i++) {
7
- const c = chars.charCodeAt(i);
8
- intToChar[i] = c;
9
- charToInt[c] = i;
10
- }
11
- function encodeInteger(builder, num, relative) {
12
- let delta = num - relative;
13
- delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
14
- do {
15
- let clamped = delta & 31;
16
- delta >>>= 5;
17
- if (delta > 0)
18
- clamped |= 32;
19
- builder.write(intToChar[clamped]);
20
- } while (delta > 0);
21
- return num;
22
- }
23
- const bufLength = 1024 * 16;
24
- const td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
25
- decode(buf) {
26
- const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
27
- return out.toString();
28
- }
29
- } : {
30
- decode(buf) {
31
- let out = "";
32
- for (let i = 0; i < buf.length; i++) {
33
- out += String.fromCharCode(buf[i]);
34
- }
35
- return out;
36
- }
37
- };
38
- class StringWriter {
39
- constructor() {
40
- this.pos = 0;
41
- this.out = "";
42
- this.buffer = new Uint8Array(bufLength);
43
- }
44
- write(v) {
45
- const { buffer } = this;
46
- buffer[this.pos++] = v;
47
- if (this.pos === bufLength) {
48
- this.out += td.decode(buffer);
49
- this.pos = 0;
50
- }
51
- }
52
- flush() {
53
- const { buffer, out, pos } = this;
54
- return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
55
- }
56
- }
57
- function encode(decoded) {
58
- const writer = new StringWriter();
59
- let sourcesIndex = 0;
60
- let sourceLine = 0;
61
- let sourceColumn = 0;
62
- let namesIndex = 0;
63
- for (let i = 0; i < decoded.length; i++) {
64
- const line = decoded[i];
65
- if (i > 0)
66
- writer.write(semicolon);
67
- if (line.length === 0)
68
- continue;
69
- let genColumn = 0;
70
- for (let j = 0; j < line.length; j++) {
71
- const segment = line[j];
72
- if (j > 0)
73
- writer.write(comma);
74
- genColumn = encodeInteger(writer, segment[0], genColumn);
75
- if (segment.length === 1)
76
- continue;
77
- sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
78
- sourceLine = encodeInteger(writer, segment[2], sourceLine);
79
- sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
80
- if (segment.length === 4)
81
- continue;
82
- namesIndex = encodeInteger(writer, segment[4], namesIndex);
83
- }
84
- }
85
- return writer.flush();
86
- }
87
- export {
88
- encode
89
- };