@analogjs/vite-plugin-angular 3.0.0-alpha.9 → 3.0.0-alpha.91

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 (184) hide show
  1. package/README.md +121 -0
  2. package/migrations/migrate-setup-vitest/migrate-setup-vitest.d.ts +2 -0
  3. package/migrations/migrate-setup-vitest/migrate-setup-vitest.js +49 -0
  4. package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -0
  5. package/migrations/migration.json +7 -1
  6. package/migrations/migrations.json +9 -0
  7. package/migrations/update-3-0-0/migrate-setup-vitest.d.ts +2 -0
  8. package/migrations/update-3-0-0/migrate-setup-vitest.js +36 -0
  9. package/migrations/update-3-0-0/migrate-setup-vitest.js.map +1 -0
  10. package/package.json +49 -8
  11. package/src/index.d.ts +7 -2
  12. package/src/index.js +3 -1
  13. package/src/index.js.map +1 -1
  14. package/src/lib/analog-plugin-interop.d.ts +78 -0
  15. package/src/lib/analog-plugin-interop.js +97 -0
  16. package/src/lib/analog-plugin-interop.js.map +1 -0
  17. package/src/lib/angular-build-optimizer-plugin.d.ts +8 -4
  18. package/src/lib/angular-build-optimizer-plugin.js +66 -31
  19. package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
  20. package/src/lib/angular-jit-plugin.d.ts +3 -3
  21. package/src/lib/angular-jit-plugin.js +28 -6
  22. package/src/lib/angular-jit-plugin.js.map +1 -1
  23. package/src/lib/angular-pending-tasks.plugin.d.ts +7 -7
  24. package/src/lib/angular-pending-tasks.plugin.js.map +1 -1
  25. package/src/lib/angular-vite-plugin.d.ts +79 -69
  26. package/src/lib/angular-vite-plugin.js +775 -352
  27. package/src/lib/angular-vite-plugin.js.map +1 -1
  28. package/src/lib/angular-vitest-plugin.d.ts +26 -21
  29. package/src/lib/angular-vitest-plugin.js +34 -25
  30. package/src/lib/angular-vitest-plugin.js.map +1 -1
  31. package/src/lib/compilation-api/compilation-api-plugin.d.ts +24 -0
  32. package/src/lib/compilation-api/compilation-api-plugin.js +548 -0
  33. package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -0
  34. package/src/lib/compilation-api/index.d.ts +1 -0
  35. package/src/lib/compilation-api/index.js +1 -0
  36. package/src/lib/compiler/angular-version.d.ts +19 -0
  37. package/src/lib/compiler/angular-version.js +31 -0
  38. package/src/lib/compiler/angular-version.js.map +1 -0
  39. package/src/lib/compiler/class-field-lowering.d.ts +23 -0
  40. package/src/lib/compiler/class-field-lowering.js +131 -0
  41. package/src/lib/compiler/class-field-lowering.js.map +1 -0
  42. package/src/lib/compiler/compile.d.ts +50 -0
  43. package/src/lib/compiler/compile.js +814 -0
  44. package/src/lib/compiler/compile.js.map +1 -0
  45. package/src/lib/compiler/constants.d.ts +24 -0
  46. package/src/lib/compiler/constants.js +59 -0
  47. package/src/lib/compiler/constants.js.map +1 -0
  48. package/src/lib/compiler/debug.d.ts +22 -0
  49. package/src/lib/compiler/debug.js +20 -0
  50. package/src/lib/compiler/debug.js.map +1 -0
  51. package/src/lib/compiler/defer.d.ts +57 -0
  52. package/src/lib/compiler/defer.js +154 -0
  53. package/src/lib/compiler/defer.js.map +1 -0
  54. package/src/lib/compiler/dts-reader.d.ts +45 -0
  55. package/src/lib/compiler/dts-reader.js +395 -0
  56. package/src/lib/compiler/dts-reader.js.map +1 -0
  57. package/src/lib/compiler/hmr.d.ts +16 -0
  58. package/src/lib/compiler/hmr.js +69 -0
  59. package/src/lib/compiler/hmr.js.map +1 -0
  60. package/src/lib/compiler/index.d.ts +8 -0
  61. package/src/lib/compiler/index.js +8 -0
  62. package/src/lib/compiler/jit-metadata.d.ts +14 -0
  63. package/src/lib/compiler/jit-metadata.js +168 -0
  64. package/src/lib/compiler/jit-metadata.js.map +1 -0
  65. package/src/lib/compiler/jit-transform.d.ts +24 -0
  66. package/src/lib/compiler/jit-transform.js +204 -0
  67. package/src/lib/compiler/jit-transform.js.map +1 -0
  68. package/src/lib/compiler/js-emitter.d.ts +10 -0
  69. package/src/lib/compiler/js-emitter.js +446 -0
  70. package/src/lib/compiler/js-emitter.js.map +1 -0
  71. package/src/lib/compiler/metadata.d.ts +36 -0
  72. package/src/lib/compiler/metadata.js +710 -0
  73. package/src/lib/compiler/metadata.js.map +1 -0
  74. package/src/lib/compiler/registry.d.ts +56 -0
  75. package/src/lib/compiler/registry.js +176 -0
  76. package/src/lib/compiler/registry.js.map +1 -0
  77. package/src/lib/compiler/resource-inliner.d.ts +43 -0
  78. package/src/lib/compiler/resource-inliner.js +230 -0
  79. package/src/lib/compiler/resource-inliner.js.map +1 -0
  80. package/src/lib/compiler/style-ast.d.ts +9 -0
  81. package/src/lib/compiler/style-ast.js +54 -0
  82. package/src/lib/compiler/style-ast.js.map +1 -0
  83. package/src/lib/compiler/styles.d.ts +13 -0
  84. package/src/lib/compiler/test-helpers.d.ts +7 -0
  85. package/src/lib/compiler/type-elision.d.ts +28 -0
  86. package/src/lib/compiler/type-elision.js +211 -0
  87. package/src/lib/compiler/type-elision.js.map +1 -0
  88. package/src/lib/compiler/utils.d.ts +40 -0
  89. package/src/lib/compiler/utils.js +76 -0
  90. package/src/lib/compiler/utils.js.map +1 -0
  91. package/src/lib/compiler-plugin.d.ts +13 -12
  92. package/src/lib/compiler-plugin.js +18 -18
  93. package/src/lib/compiler-plugin.js.map +1 -1
  94. package/src/lib/component-resolvers.d.ts +20 -4
  95. package/src/lib/component-resolvers.js +34 -20
  96. package/src/lib/component-resolvers.js.map +1 -1
  97. package/src/lib/encapsulation-plugin.d.ts +23 -0
  98. package/src/lib/encapsulation-plugin.js +68 -0
  99. package/src/lib/encapsulation-plugin.js.map +1 -0
  100. package/src/lib/fast-compile-plugin.d.ts +23 -0
  101. package/src/lib/fast-compile-plugin.js +434 -0
  102. package/src/lib/fast-compile-plugin.js.map +1 -0
  103. package/src/lib/host.d.ts +10 -8
  104. package/src/lib/host.js +59 -17
  105. package/src/lib/host.js.map +1 -1
  106. package/src/lib/live-reload-plugin.d.ts +5 -5
  107. package/src/lib/live-reload-plugin.js +10 -0
  108. package/src/lib/live-reload-plugin.js.map +1 -1
  109. package/src/lib/models.d.ts +9 -9
  110. package/src/lib/nx-folder-plugin.d.ts +5 -5
  111. package/src/lib/nx-folder-plugin.js.map +1 -1
  112. package/src/lib/plugins/file-replacements.plugin.d.ts +4 -4
  113. package/src/lib/plugins/file-replacements.plugin.js +6 -1
  114. package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
  115. package/src/lib/router-plugin.d.ts +1 -1
  116. package/src/lib/router-plugin.js +14 -2
  117. package/src/lib/router-plugin.js.map +1 -1
  118. package/src/lib/style-preprocessor.d.ts +35 -0
  119. package/src/lib/style-preprocessor.js +35 -0
  120. package/src/lib/style-preprocessor.js.map +1 -0
  121. package/src/lib/stylesheet-registry.d.ts +74 -0
  122. package/src/lib/stylesheet-registry.js +174 -0
  123. package/src/lib/stylesheet-registry.js.map +1 -0
  124. package/src/lib/tools/package.json +1 -3
  125. package/src/lib/tools/src/builders/vite/vite-build.impl.js +7 -5
  126. package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
  127. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +16 -19
  128. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
  129. package/src/lib/utils/compilation-shared.d.ts +62 -0
  130. package/src/lib/utils/compilation-shared.js +138 -0
  131. package/src/lib/utils/compilation-shared.js.map +1 -0
  132. package/src/lib/utils/compiler-plugin-options.d.ts +11 -11
  133. package/src/lib/utils/css-extension-resolver.d.ts +32 -0
  134. package/src/lib/utils/css-extension-resolver.js +73 -0
  135. package/src/lib/utils/css-extension-resolver.js.map +1 -0
  136. package/src/lib/utils/css-preprocessor-workers.d.ts +6 -0
  137. package/src/lib/utils/css-preprocessor-workers.js +29 -0
  138. package/src/lib/utils/css-preprocessor-workers.js.map +1 -0
  139. package/src/lib/utils/debug-harness.d.ts +23 -0
  140. package/src/lib/utils/debug-harness.js +88 -0
  141. package/src/lib/utils/debug-harness.js.map +1 -0
  142. package/src/lib/utils/debug-log-file.d.ts +5 -0
  143. package/src/lib/utils/debug-log-file.js +56 -0
  144. package/src/lib/utils/debug-log-file.js.map +1 -0
  145. package/src/lib/utils/debug.d.ts +26 -0
  146. package/src/lib/utils/debug.js +35 -0
  147. package/src/lib/utils/debug.js.map +1 -0
  148. package/src/lib/utils/devkit.d.ts +14 -6
  149. package/src/lib/utils/devkit.js +40 -2
  150. package/src/lib/utils/devkit.js.map +1 -1
  151. package/src/lib/utils/hmr-candidates.d.ts +28 -28
  152. package/src/lib/utils/jit-inline-styles.d.ts +3 -0
  153. package/src/lib/utils/jit-inline-styles.js +16 -0
  154. package/src/lib/utils/jit-inline-styles.js.map +1 -0
  155. package/src/lib/utils/plugin-config.d.ts +41 -0
  156. package/src/lib/utils/plugin-config.js +85 -0
  157. package/src/lib/utils/plugin-config.js.map +1 -0
  158. package/src/lib/utils/rolldown.d.ts +1 -1
  159. package/src/lib/utils/rolldown.js.map +1 -1
  160. package/src/lib/utils/safe-module-paths.d.ts +16 -0
  161. package/src/lib/utils/safe-module-paths.js +29 -0
  162. package/src/lib/utils/safe-module-paths.js.map +1 -0
  163. package/src/lib/utils/source-file-cache.d.ts +8 -15
  164. package/src/lib/utils/source-file-cache.js.map +1 -1
  165. package/src/lib/utils/transform-cache.d.ts +43 -0
  166. package/src/lib/utils/transform-cache.js +97 -0
  167. package/src/lib/utils/transform-cache.js.map +1 -0
  168. package/src/lib/utils/tsconfig-resolver.d.ts +34 -0
  169. package/src/lib/utils/tsconfig-resolver.js +205 -0
  170. package/src/lib/utils/tsconfig-resolver.js.map +1 -0
  171. package/src/lib/utils/virtual-ids.d.ts +4 -0
  172. package/src/lib/utils/virtual-ids.js +23 -0
  173. package/src/lib/utils/virtual-ids.js.map +1 -0
  174. package/src/lib/utils/virtual-resources.d.ts +19 -0
  175. package/src/lib/utils/virtual-resources.js +38 -0
  176. package/src/lib/utils/virtual-resources.js.map +1 -0
  177. package/src/lib/virtual-modules-plugin.d.ts +5 -0
  178. package/src/lib/virtual-modules-plugin.js +23 -0
  179. package/src/lib/virtual-modules-plugin.js.map +1 -0
  180. package/src/test-setup.d.ts +2 -0
  181. package/setup-vitest.d.ts +0 -4
  182. package/setup-vitest.js +0 -176
  183. package/setup-vitest.js.map +0 -1
  184. package/src/lib/tools/src/index.d.ts +0 -0
@@ -0,0 +1,23 @@
1
+ import { toVirtualRawId } from "./utils/virtual-ids.js";
2
+ import { dirname, isAbsolute, resolve } from "node:path";
3
+ import { normalizePath } from "vite";
4
+ //#region packages/vite-plugin-angular/src/lib/virtual-modules-plugin.ts
5
+ function virtualModulesPlugin(pluginOptions) {
6
+ return {
7
+ name: "@analogjs/vite-plugin-angular:virtual-modules",
8
+ enforce: "pre",
9
+ resolveId(id, importer) {
10
+ if (id.startsWith("virtual:@analogjs/vite-plugin-angular:raw:")) return `\0${id}`;
11
+ if (pluginOptions.jit && id.startsWith("angular:jit:")) return toVirtualRawId(normalizePath(resolve(dirname(importer), id.split(";")[1])));
12
+ if (id.includes(".html?raw")) {
13
+ const filePath = id.split("?")[0];
14
+ const resolved = isAbsolute(filePath) ? normalizePath(filePath) : importer ? normalizePath(resolve(dirname(importer), filePath)) : void 0;
15
+ if (resolved) return toVirtualRawId(resolved);
16
+ }
17
+ }
18
+ };
19
+ }
20
+ //#endregion
21
+ export { virtualModulesPlugin };
22
+
23
+ //# sourceMappingURL=virtual-modules-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtual-modules-plugin.js","names":[],"sources":["../../../src/lib/virtual-modules-plugin.ts"],"sourcesContent":["import { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath, Plugin } from 'vite';\nimport { VIRTUAL_RAW_PREFIX, toVirtualRawId } from './utils/virtual-ids.js';\n\nexport interface VirtualModulesPluginOptions {\n jit: boolean;\n}\n\nexport function virtualModulesPlugin(\n pluginOptions: VirtualModulesPluginOptions,\n): Plugin {\n return {\n name: '@analogjs/vite-plugin-angular:virtual-modules',\n enforce: 'pre',\n resolveId(id, importer) {\n if (id.startsWith(VIRTUAL_RAW_PREFIX)) {\n return `\\0${id}`;\n }\n\n if (pluginOptions.jit && id.startsWith('angular:jit:')) {\n const filePath = normalizePath(\n resolve(dirname(importer as string), id.split(';')[1]),\n );\n return toVirtualRawId(filePath);\n }\n\n // Intercept .html?raw imports to bypass Vite server.fs restrictions\n if (id.includes('.html?raw')) {\n const filePath = id.split('?')[0];\n const resolved = isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n if (resolved) {\n return toVirtualRawId(resolved);\n }\n }\n\n return undefined;\n },\n };\n}\n"],"mappings":";;;;AAQA,SAAgB,qBACd,eACQ;AACR,QAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,IAAI,UAAU;AACtB,OAAI,GAAG,WAAA,6CAA8B,CACnC,QAAO,KAAK;AAGd,OAAI,cAAc,OAAO,GAAG,WAAW,eAAe,CAIpD,QAAO,eAHU,cACf,QAAQ,QAAQ,SAAmB,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CACvD,CAC8B;AAIjC,OAAI,GAAG,SAAS,YAAY,EAAE;IAC5B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;IAC/B,MAAM,WAAW,WAAW,SAAS,GACjC,cAAc,SAAS,GACvB,WACE,cAAc,QAAQ,QAAQ,SAAS,EAAE,SAAS,CAAC,GACnD,KAAA;AACN,QAAI,SACF,QAAO,eAAe,SAAS;;;EAMtC"}
@@ -0,0 +1,2 @@
1
+ import "@angular/compiler";
2
+ export {};
package/setup-vitest.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import 'zone.js';
2
- import 'zone.js/plugins/sync-test';
3
- import 'zone.js/plugins/proxy';
4
- import 'zone.js/testing';
package/setup-vitest.js DELETED
@@ -1,176 +0,0 @@
1
- import "zone.js";
2
- import "zone.js/plugins/sync-test";
3
- import "zone.js/plugins/proxy";
4
- import "zone.js/testing";
5
- //#region packages/vite-plugin-angular/setup-vitest.ts
6
- /**
7
- * Patch Vitest's describe/test/beforeEach/afterEach functions so test code
8
- * always runs in a testZone (ProxyZone).
9
- */
10
- var { Zone } = globalThis;
11
- if (Zone === void 0) throw new Error("Missing: Zone (zone.js)");
12
- if (globalThis["__vitest_zone_patch__"] === true) throw new Error("'vitest' has already been patched with 'Zone'.");
13
- globalThis["__vitest_zone_patch__"] = true;
14
- var { SyncTestZoneSpec } = Zone;
15
- var { ProxyZoneSpec } = Zone;
16
- if (SyncTestZoneSpec === void 0) throw new Error("Missing: SyncTestZoneSpec (zone.js/plugins/sync-test)");
17
- if (ProxyZoneSpec === void 0) throw new Error("Missing: ProxyZoneSpec (zone.js/plugins/proxy.js)");
18
- var env = globalThis;
19
- var ambientZone = Zone.current;
20
- var syncZone = ambientZone.fork(new SyncTestZoneSpec("vitest.describe"));
21
- function wrapDescribeInZone(describeBody) {
22
- return function(...args) {
23
- return syncZone.run(describeBody, null, args);
24
- };
25
- }
26
- var testProxyZone = ambientZone.fork(new ProxyZoneSpec());
27
- function wrapTestInZone(testBody) {
28
- if (testBody === void 0) return;
29
- const wrappedFunc = function wrappedFunc(...args) {
30
- return testProxyZone.run(testBody, null, args);
31
- };
32
- try {
33
- Object.defineProperty(wrappedFunc, "length", {
34
- configurable: true,
35
- enumerable: false,
36
- writable: true
37
- });
38
- wrappedFunc.length = testBody.length;
39
- } catch (e) {
40
- return testBody.length === 0 ? () => testProxyZone.run(testBody, null) : (done) => testProxyZone.run(testBody, null, [done]);
41
- }
42
- return wrappedFunc;
43
- }
44
- /**
45
- * Allows Vitest to handle Angular test fixtures
46
- *
47
- * Vitest Snapshot guide ==> https://vitest.dev/guide/snapshot.html
48
- *
49
- * @returns customSnapshotSerializer for Angular Fixture Component
50
- */
51
- var customSnapshotSerializer = () => {
52
- function serialize(val, config, indentation, depth, refs, printer) {
53
- return `${printer(fixtureVitestSerializer(val), config, indentation, depth, refs)}`;
54
- }
55
- function test(val) {
56
- return val && isAngularFixture(val);
57
- }
58
- return {
59
- serialize,
60
- test
61
- };
62
- };
63
- /**
64
- * Check if is an Angular fixture
65
- *
66
- * @param val Angular fixture
67
- * @returns boolean who check if is an angular fixture
68
- */
69
- function isAngularFixture(val) {
70
- if (typeof val !== "object") return false;
71
- if (val["componentRef"] || val["componentInstance"]) return true;
72
- if (val["componentType"]) return true;
73
- return JSON.stringify(Object.keys(val)) === JSON.stringify([
74
- "componentRef",
75
- "ngZone",
76
- "effectRunner",
77
- "_autoDetect",
78
- "_isStable",
79
- "_isDestroyed",
80
- "_resolve",
81
- "_promise",
82
- "_onUnstableSubscription",
83
- "_onStableSubscription",
84
- "_onMicrotaskEmptySubscription",
85
- "_onErrorSubscription",
86
- "changeDetectorRef",
87
- "elementRef",
88
- "debugElement",
89
- "componentInstance",
90
- "nativeElement"
91
- ]) || JSON.stringify(Object.keys(val)) === JSON.stringify([
92
- "location",
93
- "_rootLView",
94
- "_tNode",
95
- "previousInputValues",
96
- "instance",
97
- "changeDetectorRef",
98
- "hostView",
99
- "componentType"
100
- ]);
101
- }
102
- /**
103
- * Serialize Angular fixture for Vitest
104
- *
105
- * @param fixture Angular Fixture Component
106
- * @returns HTML Child Node
107
- */
108
- function fixtureVitestSerializer(fixture) {
109
- const componentType = fixture && fixture.componentType ? fixture.componentType : fixture.componentRef.componentType;
110
- let inputsData = "";
111
- const selector = Reflect.getOwnPropertyDescriptor(componentType, "__annotations__")?.value[0].selector;
112
- if (componentType && componentType.propDecorators) inputsData = Object.entries(componentType.propDecorators).map(([key, value]) => `${key}="${value}"`).join("");
113
- const divElement = fixture && fixture.nativeElement ? fixture.nativeElement : fixture.location.nativeElement;
114
- return new DOMParser().parseFromString(`<${selector} ${inputsData}>${divElement.innerHTML}</${selector}>`, "text/html").body.childNodes[0];
115
- }
116
- /**
117
- * Bind describe method to wrap describe.each function
118
- */
119
- var bindDescribe = (self, originalVitestFn) => function bindDescribe(...eachArgs) {
120
- return function bindDescribe(...args) {
121
- args[1] = wrapDescribeInZone(args[1]);
122
- return originalVitestFn.apply(self, eachArgs).apply(self, args);
123
- };
124
- };
125
- /**
126
- * Bind test method to wrap test.each function
127
- */
128
- var bindTest = (self, originalVitestFn) => function bindTest(...eachArgs) {
129
- return function bindTest(...args) {
130
- args[1] = wrapTestInZone(args[1]);
131
- return originalVitestFn.apply(self, eachArgs).apply(self, args);
132
- };
133
- };
134
- ["describe"].forEach((methodName) => {
135
- const originalvitestFn = env[methodName];
136
- env[methodName] = function(...args) {
137
- args[1] = wrapDescribeInZone(args[1]);
138
- return originalvitestFn.apply(this, args);
139
- };
140
- env[methodName].each = bindDescribe(originalvitestFn, originalvitestFn.each);
141
- if (methodName === "describe") {
142
- env[methodName].only = bindDescribe(originalvitestFn, originalvitestFn.only);
143
- env[methodName].skip = bindDescribe(originalvitestFn, originalvitestFn.skip);
144
- }
145
- });
146
- ["test", "it"].forEach((methodName) => {
147
- const originalvitestFn = env[methodName];
148
- env[methodName] = function(...args) {
149
- args[1] = wrapTestInZone(args[1]);
150
- return originalvitestFn.apply(this, args);
151
- };
152
- env[methodName].each = bindTest(originalvitestFn, originalvitestFn.each);
153
- env[methodName].only = bindTest(originalvitestFn, originalvitestFn.only);
154
- env[methodName].skip = bindTest(originalvitestFn, originalvitestFn.skip);
155
- if (methodName === "test" || methodName === "it") env[methodName].todo = function todo(...args) {
156
- return originalvitestFn.todo.apply(this, args);
157
- };
158
- });
159
- [
160
- "beforeEach",
161
- "afterEach",
162
- "beforeAll",
163
- "afterAll"
164
- ].forEach((methodName) => {
165
- const originalvitestFn = env[methodName];
166
- env[methodName] = function(...args) {
167
- args[0] = wrapTestInZone(args[0]);
168
- return originalvitestFn.apply(this, args);
169
- };
170
- });
171
- ["expect"].forEach((methodName) => {
172
- return env[methodName].addSnapshotSerializer(customSnapshotSerializer());
173
- });
174
- //#endregion
175
-
176
- //# sourceMappingURL=setup-vitest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup-vitest.js","names":[],"sources":["../../../packages/vite-plugin-angular/setup-vitest.ts"],"sourcesContent":["import 'zone.js';\nimport 'zone.js/plugins/sync-test';\nimport 'zone.js/plugins/proxy';\nimport 'zone.js/testing';\n\n/**\n * Patch Vitest's describe/test/beforeEach/afterEach functions so test code\n * always runs in a testZone (ProxyZone).\n */\n/* global Zone */\nconst { Zone } = globalThis as any;\n\nif (Zone === undefined) {\n throw new Error('Missing: Zone (zone.js)');\n}\n\nif ((globalThis as any)['__vitest_zone_patch__'] === true) {\n throw new Error(\"'vitest' has already been patched with 'Zone'.\");\n}\n\n(globalThis as any)['__vitest_zone_patch__'] = true;\nconst { SyncTestZoneSpec } = Zone;\nconst { ProxyZoneSpec } = Zone;\n\nif (SyncTestZoneSpec === undefined) {\n throw new Error('Missing: SyncTestZoneSpec (zone.js/plugins/sync-test)');\n}\nif (ProxyZoneSpec === undefined) {\n throw new Error('Missing: ProxyZoneSpec (zone.js/plugins/proxy.js)');\n}\n\nconst env = globalThis as any;\nconst ambientZone = Zone.current;\n\n// Create a synchronous-only zone in which to run `describe` blocks in order to\n// Raise an error if any asynchronous operations are attempted\n// Inside of a `describe` but outside of a `beforeEach` or `it`.\nconst syncZone = ambientZone.fork(new SyncTestZoneSpec('vitest.describe'));\nfunction wrapDescribeInZone(describeBody: any) {\n return function (...args: any) {\n return syncZone.run(describeBody, null, args);\n };\n}\n\n// Create a proxy zone in which to run `test` blocks so that the tests function\n// Can retroactively install different zones.\nconst testProxyZone = ambientZone.fork(new ProxyZoneSpec());\nfunction wrapTestInZone(testBody: string | any[] | undefined) {\n if (testBody === undefined) {\n return;\n }\n\n const wrappedFunc = function wrappedFunc(...args: any[]) {\n return testProxyZone.run(testBody, null, args);\n };\n try {\n Object.defineProperty(wrappedFunc, 'length', {\n configurable: true,\n enumerable: false,\n writable: true,\n });\n wrappedFunc.length = testBody.length;\n } catch (e) {\n return testBody.length === 0\n ? () => testProxyZone.run(testBody, null)\n : (done: any) => testProxyZone.run(testBody, null, [done]);\n }\n\n return wrappedFunc;\n}\n\n/**\n * Allows Vitest to handle Angular test fixtures\n *\n * Vitest Snapshot guide ==> https://vitest.dev/guide/snapshot.html\n *\n * @returns customSnapshotSerializer for Angular Fixture Component\n */\nconst customSnapshotSerializer = () => {\n function serialize(\n val: any,\n config: any,\n indentation: any,\n depth: any,\n refs: any,\n printer: any,\n ): string {\n // `printer` is a function that serializes a value using existing plugins.\n return `${printer(\n fixtureVitestSerializer(val),\n config,\n indentation,\n depth,\n refs,\n )}`;\n }\n function test(val: any): boolean {\n // * If it's a ComponentFixture we apply the transformation rules\n return val && isAngularFixture(val);\n }\n return {\n serialize,\n test,\n };\n};\n\n/**\n * Check if is an Angular fixture\n *\n * @param val Angular fixture\n * @returns boolean who check if is an angular fixture\n */\nfunction isAngularFixture(val: any): boolean {\n if (typeof val !== 'object') {\n return false;\n }\n\n if (val['componentRef'] || val['componentInstance']) {\n return true;\n }\n\n if (val['componentType']) {\n return true;\n }\n\n // * Angular fixture keys in Fixture component Object\n const fixtureKeys = [\n 'componentRef',\n 'ngZone',\n 'effectRunner',\n '_autoDetect',\n '_isStable',\n '_isDestroyed',\n '_resolve',\n '_promise',\n '_onUnstableSubscription',\n '_onStableSubscription',\n '_onMicrotaskEmptySubscription',\n '_onErrorSubscription',\n 'changeDetectorRef',\n 'elementRef',\n 'debugElement',\n 'componentInstance',\n 'nativeElement',\n ];\n\n // * Angular fixture keys in Fixture componentRef Object\n const fixtureComponentRefKeys = [\n 'location',\n '_rootLView',\n '_tNode',\n 'previousInputValues',\n 'instance',\n 'changeDetectorRef',\n 'hostView',\n 'componentType',\n ];\n\n return (\n JSON.stringify(Object.keys(val)) === JSON.stringify(fixtureKeys) ||\n JSON.stringify(Object.keys(val)) === JSON.stringify(fixtureComponentRefKeys)\n );\n}\n\n/**\n * Serialize Angular fixture for Vitest\n *\n * @param fixture Angular Fixture Component\n * @returns HTML Child Node\n */\nfunction fixtureVitestSerializer(fixture: any) {\n // * Get Component meta data\n const componentType = (\n fixture && fixture.componentType\n ? fixture.componentType\n : fixture.componentRef.componentType\n ) as any;\n\n let inputsData = '';\n\n const selector = Reflect.getOwnPropertyDescriptor(\n componentType,\n '__annotations__',\n )?.value[0].selector;\n\n if (componentType && componentType.propDecorators) {\n inputsData = Object.entries(componentType.propDecorators)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join('');\n }\n\n // * Get DOM Elements\n const divElement =\n fixture && fixture.nativeElement\n ? fixture.nativeElement\n : fixture.location.nativeElement;\n\n // * Convert string data to HTML data\n const doc = new DOMParser().parseFromString(\n `<${selector} ${inputsData}>${divElement.innerHTML}</${selector}>`,\n 'text/html',\n );\n\n return doc.body.childNodes[0];\n}\n\n/**\n * Bind describe method to wrap describe.each function\n */\nconst bindDescribe = (\n self: any,\n originalVitestFn: {\n apply: (\n arg0: any,\n arg1: any[],\n ) => {\n (): any;\n new (): any;\n apply: { (arg0: any, arg1: any[]): any; new (): any };\n };\n },\n) =>\n function bindDescribe(...eachArgs: any) {\n return function bindDescribe(...args: any[]) {\n args[1] = wrapDescribeInZone(args[1]);\n\n return originalVitestFn.apply(self, eachArgs).apply(self, args);\n };\n };\n\n/**\n * Bind test method to wrap test.each function\n */\nconst bindTest = (\n self: any,\n originalVitestFn: {\n apply: (\n arg0: any,\n arg1: any[],\n ) => {\n (): any;\n new (): any;\n apply: { (arg0: any, arg1: any[]): any; new (): any };\n };\n },\n) =>\n function bindTest(...eachArgs: any) {\n return function bindTest(...args: any[]) {\n args[1] = wrapTestInZone(args[1]);\n\n return originalVitestFn.apply(self, eachArgs).apply(self, args);\n };\n };\n\n['describe'].forEach((methodName) => {\n const originalvitestFn = env[methodName];\n env[methodName] = function (...args: any[]) {\n args[1] = wrapDescribeInZone(args[1]);\n\n return originalvitestFn.apply(this, args);\n };\n env[methodName].each = bindDescribe(originalvitestFn, originalvitestFn.each);\n if (methodName === 'describe') {\n env[methodName].only = bindDescribe(\n originalvitestFn,\n originalvitestFn.only,\n );\n env[methodName].skip = bindDescribe(\n originalvitestFn,\n originalvitestFn.skip,\n );\n }\n});\n\n['test', 'it'].forEach((methodName) => {\n const originalvitestFn = env[methodName];\n env[methodName] = function (...args: any[]) {\n args[1] = wrapTestInZone(args[1]);\n\n return originalvitestFn.apply(this, args);\n };\n env[methodName].each = bindTest(originalvitestFn, originalvitestFn.each);\n env[methodName].only = bindTest(originalvitestFn, originalvitestFn.only);\n env[methodName].skip = bindTest(originalvitestFn, originalvitestFn.skip);\n\n if (methodName === 'test' || methodName === 'it') {\n env[methodName].todo = function todo(...args: any) {\n return originalvitestFn.todo.apply(this, args);\n };\n }\n});\n\n['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach((methodName) => {\n const originalvitestFn = env[methodName];\n\n env[methodName] = function (...args: any[]) {\n args[0] = wrapTestInZone(args[0]);\n\n return originalvitestFn.apply(this, args);\n };\n});\n\n['expect'].forEach((methodName) => {\n const originalvitestFn = env[methodName];\n return originalvitestFn.addSnapshotSerializer(customSnapshotSerializer());\n});\n"],"mappings":";;;;;;;;;AAUA,IAAM,EAAE,SAAS;AAEjB,IAAI,SAAS,KAAA,EACX,OAAM,IAAI,MAAM,0BAA0B;AAG5C,IAAK,WAAmB,6BAA6B,KACnD,OAAM,IAAI,MAAM,iDAAiD;AAGnE,WAAoB,2BAA2B;AAC/C,IAAM,EAAE,qBAAqB;AAC7B,IAAM,EAAE,kBAAkB;AAE1B,IAAI,qBAAqB,KAAA,EACvB,OAAM,IAAI,MAAM,wDAAwD;AAE1E,IAAI,kBAAkB,KAAA,EACpB,OAAM,IAAI,MAAM,oDAAoD;AAGtE,IAAM,MAAM;AACZ,IAAM,cAAc,KAAK;AAKzB,IAAM,WAAW,YAAY,KAAK,IAAI,iBAAiB,kBAAkB,CAAC;AAC1E,SAAS,mBAAmB,cAAmB;AAC7C,QAAO,SAAU,GAAG,MAAW;AAC7B,SAAO,SAAS,IAAI,cAAc,MAAM,KAAK;;;AAMjD,IAAM,gBAAgB,YAAY,KAAK,IAAI,eAAe,CAA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