@wix/zero-config-implementation 1.80.0 → 1.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { g as x } from "./index-B8oF7hWg.js";
1
+ import { g as x } from "./index-CqoYtob0.js";
2
2
  function h(r, a) {
3
3
  for (var i = 0; i < a.length; i++) {
4
4
  const o = a[i];
@@ -6979,7 +6979,7 @@ const One = ({ isSSR: t, animatedScrollTo: e }) => {
6979
6979
  return Promise.resolve();
6980
6980
  if (!l)
6981
6981
  return Promise.reject({ error: "unable to copy null value" });
6982
- (await import("./index-CGnbp9jn.js").then((f) => f.i)).default(l);
6982
+ (await import("./index-B5j6kWzS.js").then((f) => f.i)).default(l);
6983
6983
  };
6984
6984
  function i(l, h, f) {
6985
6985
  if (typeof l !== f)
@@ -99767,7 +99767,9 @@ function oWe() {
99767
99767
  const r = new sWe();
99768
99768
  t.window = r, t.document = r.document, t.HTMLElement = r.HTMLElement, t.customElements = r.customElements;
99769
99769
  }
99770
- const e = t.window, n = e.IntersectionObserver ?? aWe;
99770
+ const e = t.window;
99771
+ t.navigator === void 0 && (t.navigator = e.navigator), t.Element === void 0 && (t.Element = e.Element);
99772
+ const n = e.IntersectionObserver ?? aWe;
99771
99773
  t.IntersectionObserver === void 0 && (t.IntersectionObserver = n), e.IntersectionObserver === void 0 && (e.IntersectionObserver = n), t.React === void 0 && (t.React = gr), t.ReactDOM === void 0 && (t.ReactDOM = _3), e.React === void 0 && (e.React = gr), e.ReactDOM === void 0 && (e.ReactDOM = _3);
99772
99774
  }
99773
99775
  function vKe(t) {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { B as t, D as e, E as o, I as n, N as c, P as l, R as i, a as p, V as E, b as m, c as x, d as f, e as d, f as u, h as C, i as I, j as k, k as y, l as A, m as D, n as P, o as R, p as h, q as B, r as M, s as T, t as b, w } from "./index-B8oF7hWg.js";
1
+ import { B as t, D as e, E as o, I as n, N as c, P as l, R as i, a as p, V as E, b as m, c as x, d as f, e as d, f as u, h as C, i as I, j as k, k as y, l as A, m as D, n as P, o as R, p as h, q as B, r as M, s as T, t as b, w } from "./index-CqoYtob0.js";
2
2
  import "react";
3
3
  export {
4
4
  t as BaseError,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "registry": "https://registry.npmjs.org/",
5
5
  "access": "public"
6
6
  },
7
- "version": "1.80.0",
7
+ "version": "1.81.0",
8
8
  "description": "Core library for extracting component manifests from JS and CSS files",
9
9
  "type": "module",
10
10
  "main": "dist/index.js",
@@ -82,5 +82,5 @@
82
82
  ]
83
83
  }
84
84
  },
85
- "falconPackageHash": "9e634a5f6a97f802dcc3b2dbc92f56c3c9623790346ee5278ca65f03"
85
+ "falconPackageHash": "a62684e6a36b7c409927242d6d286817a3aa7b2ef5601dac8e42ab5f"
86
86
  }
@@ -0,0 +1,2 @@
1
+ export const navigatorUserAgent = navigator.userAgent
2
+ export const elementPrototype = Element.prototype
@@ -0,0 +1,2 @@
1
+ export const navigatorUserAgent = navigator.userAgent
2
+ export const elementPrototype = Element.prototype
@@ -0,0 +1,2 @@
1
+ export const navigatorUserAgent = navigator.userAgent
2
+ export const elementPrototype = Element.prototype
@@ -0,0 +1,4 @@
1
+ void navigator.userAgent
2
+ void Element.prototype
3
+
4
+ throw new Error('browser-global fixture runtime failure')
@@ -8,7 +8,170 @@ import { readLoaderPortRefStateForTests, readRegisteredRefElementModuleUrlsForTe
8
8
 
9
9
  const require = createRequire(import.meta.url)
10
10
 
11
+ const extractionGlobalPropertyNames = [
12
+ 'window',
13
+ 'document',
14
+ 'HTMLElement',
15
+ 'Element',
16
+ 'navigator',
17
+ 'customElements',
18
+ 'IntersectionObserver',
19
+ 'React',
20
+ 'ReactDOM',
21
+ ] as const
22
+
23
+ type ExtractionGlobalPropertyName = (typeof extractionGlobalPropertyNames)[number]
24
+
25
+ function snapshotExtractionGlobalDescriptors(): Map<ExtractionGlobalPropertyName, PropertyDescriptor | undefined> {
26
+ return new Map(
27
+ extractionGlobalPropertyNames.map((propertyName) => [
28
+ propertyName,
29
+ Object.getOwnPropertyDescriptor(globalThis, propertyName),
30
+ ]),
31
+ )
32
+ }
33
+
34
+ function clearExtractionGlobals(): void {
35
+ for (const propertyName of extractionGlobalPropertyNames) {
36
+ Reflect.deleteProperty(globalThis, propertyName)
37
+ }
38
+ }
39
+
40
+ function restoreExtractionGlobalDescriptors(
41
+ originalDescriptors: Map<ExtractionGlobalPropertyName, PropertyDescriptor | undefined>,
42
+ ): void {
43
+ clearExtractionGlobals()
44
+ for (const [propertyName, propertyDescriptor] of originalDescriptors) {
45
+ if (propertyDescriptor !== undefined) {
46
+ Object.defineProperty(globalThis, propertyName, propertyDescriptor)
47
+ }
48
+ }
49
+ }
50
+
11
51
  describe('module loading', () => {
52
+ it('loads an ESM entry that reads navigator and Element during module evaluation', async () => {
53
+ const originalDescriptors = snapshotExtractionGlobalDescriptors()
54
+ clearExtractionGlobals()
55
+
56
+ try {
57
+ const entryPath = path.resolve(__dirname, '__fixtures__/esm-browser-globals-entry.mjs')
58
+ const loadedModuleResult = await loadModuleForExtraction(entryPath)
59
+ const loadedModule = loadedModuleResult._unsafeUnwrap()
60
+ const globals = globalThis as Record<string, unknown>
61
+ const configuredWindow = globals.window as Record<string, unknown>
62
+
63
+ expect(loadedModule.moduleExports.navigatorUserAgent).toBe(
64
+ (configuredWindow.navigator as { userAgent: string }).userAgent,
65
+ )
66
+ expect(loadedModule.moduleExports.elementPrototype).toBe(
67
+ (configuredWindow.Element as { prototype: unknown }).prototype,
68
+ )
69
+ expect(globals.navigator).toBe(configuredWindow.navigator)
70
+ expect(globals.Element).toBe(configuredWindow.Element)
71
+
72
+ await loadedModule.cleanup()
73
+ } finally {
74
+ restoreExtractionGlobalDescriptors(originalDescriptors)
75
+ }
76
+ })
77
+
78
+ it('preserves caller-provided navigator and Element globals', async () => {
79
+ const originalDescriptors = snapshotExtractionGlobalDescriptors()
80
+ clearExtractionGlobals()
81
+
82
+ const callerNavigator = { userAgent: 'caller-provided navigator' }
83
+ class CallerProvidedElement {}
84
+
85
+ try {
86
+ Object.defineProperty(globalThis, 'navigator', {
87
+ configurable: true,
88
+ value: callerNavigator,
89
+ writable: true,
90
+ })
91
+ Object.defineProperty(globalThis, 'Element', {
92
+ configurable: true,
93
+ value: CallerProvidedElement,
94
+ writable: true,
95
+ })
96
+
97
+ const entryPath = path.resolve(__dirname, '__fixtures__/esm-browser-globals-preservation-entry.mjs')
98
+ const loadedModuleResult = await loadModuleForExtraction(entryPath)
99
+ const loadedModule = loadedModuleResult._unsafeUnwrap()
100
+ const globals = globalThis as Record<string, unknown>
101
+
102
+ expect(globals.navigator).toBe(callerNavigator)
103
+ expect(globals.Element).toBe(CallerProvidedElement)
104
+ expect(loadedModule.moduleExports.elementPrototype).toBe(CallerProvidedElement.prototype)
105
+
106
+ await loadedModule.cleanup()
107
+ } finally {
108
+ restoreExtractionGlobalDescriptors(originalDescriptors)
109
+ }
110
+ })
111
+
112
+ it('preserves an existing navigator while adding a missing Element global', async () => {
113
+ const originalDescriptors = snapshotExtractionGlobalDescriptors()
114
+ clearExtractionGlobals()
115
+
116
+ const existingNavigator = { userAgent: 'existing Node navigator' }
117
+
118
+ try {
119
+ Object.defineProperty(globalThis, 'navigator', {
120
+ configurable: true,
121
+ value: existingNavigator,
122
+ writable: true,
123
+ })
124
+
125
+ const entryPath = path.resolve(__dirname, '__fixtures__/esm-browser-globals-existing-navigator-entry.mjs')
126
+ const loadedModuleResult = await loadModuleForExtraction(entryPath)
127
+ const loadedModule = loadedModuleResult._unsafeUnwrap()
128
+ const globals = globalThis as Record<string, unknown>
129
+ const configuredWindow = globals.window as Record<string, unknown>
130
+
131
+ expect(loadedModule.moduleExports.navigatorUserAgent).toBe(existingNavigator.userAgent)
132
+ expect(loadedModule.moduleExports.elementPrototype).toBe(
133
+ (configuredWindow.Element as { prototype: unknown }).prototype,
134
+ )
135
+ expect(globals.navigator).toBe(existingNavigator)
136
+ expect(globals.Element).toBe(configuredWindow.Element)
137
+
138
+ await loadedModule.cleanup()
139
+ } finally {
140
+ restoreExtractionGlobalDescriptors(originalDescriptors)
141
+ }
142
+ })
143
+
144
+ it('keeps unrelated module-evaluation failures visible after browser-global setup', async () => {
145
+ const originalDescriptors = snapshotExtractionGlobalDescriptors()
146
+ clearExtractionGlobals()
147
+
148
+ const callerNavigator = { userAgent: 'caller-provided navigator' }
149
+ class CallerProvidedElement {}
150
+
151
+ try {
152
+ Object.defineProperty(globalThis, 'navigator', {
153
+ configurable: true,
154
+ value: callerNavigator,
155
+ writable: true,
156
+ })
157
+ Object.defineProperty(globalThis, 'Element', {
158
+ configurable: true,
159
+ value: CallerProvidedElement,
160
+ writable: true,
161
+ })
162
+
163
+ const entryPath = path.resolve(__dirname, '__fixtures__/esm-browser-globals-runtime-error-entry.mjs')
164
+ const loadedModuleResult = await loadModuleForExtraction(entryPath)
165
+
166
+ expect(loadedModuleResult.isErr()).toBe(true)
167
+ if (loadedModuleResult.isErr()) {
168
+ expect(loadedModuleResult.error.esmError?.message).toContain('browser-global fixture runtime failure')
169
+ }
170
+ } finally {
171
+ restoreExtractionGlobalDescriptors(originalDescriptors)
172
+ }
173
+ })
174
+
12
175
  it('temporarily tags ref-element modules in the CJS fallback and cleans them up afterwards', async () => {
13
176
  const entryPath = path.resolve(__dirname, '__fixtures__/cjs-ref-element-entry.cjs')
14
177
  const targetPath = path.resolve(__dirname, '__fixtures__/cjs-ref-element-target.cjs')
@@ -44,6 +44,8 @@ function setupWindowGlobals(): void {
44
44
  }
45
45
 
46
46
  const windowObj = globals.window as Record<string, unknown>
47
+ if (globals.navigator === undefined) globals.navigator = windowObj.navigator
48
+ if (globals.Element === undefined) globals.Element = windowObj.Element
47
49
  const intersectionObserver = windowObj.IntersectionObserver ?? NoopIntersectionObserver
48
50
  if (globals.IntersectionObserver === undefined) globals.IntersectionObserver = intersectionObserver
49
51
  if (windowObj.IntersectionObserver === undefined) windowObj.IntersectionObserver = intersectionObserver