@noego/testing 0.6.0 → 0.7.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.
- package/README.md +100 -0
- package/dist/browser/index.cjs +458 -0
- package/dist/browser/index.cjs.map +1 -0
- package/dist/browser/index.d.cts +61 -0
- package/dist/browser/index.d.ts +61 -0
- package/dist/browser/index.js +291 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/setup.cjs +88 -0
- package/dist/browser/setup.cjs.map +1 -0
- package/dist/browser/setup.d.cts +8 -0
- package/dist/browser/setup.d.ts +8 -0
- package/dist/browser/setup.js +14 -0
- package/dist/browser/setup.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +11 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/chunk-UINJYNO7.js +97 -0
- package/dist/chunk-UINJYNO7.js.map +1 -0
- package/dist/chunk-YX44DAOH.js +38 -0
- package/dist/chunk-YX44DAOH.js.map +1 -0
- package/dist/fetch/index.cjs +279 -0
- package/dist/fetch/index.cjs.map +1 -0
- package/dist/fetch/index.d.cts +6 -0
- package/dist/fetch/index.d.ts +6 -0
- package/dist/fetch/index.js +219 -0
- package/dist/fetch/index.js.map +1 -0
- package/dist/index.cjs +781 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +264 -2
- package/dist/index.d.ts +264 -2
- package/dist/index.js +762 -73
- package/dist/index.js.map +1 -1
- package/dist/runtime-CdrMRuv2.d.cts +61 -0
- package/dist/runtime-CdrMRuv2.d.ts +61 -0
- package/package.json +35 -3
package/README.md
CHANGED
|
@@ -1,5 +1,105 @@
|
|
|
1
1
|
# @noego/testing
|
|
2
2
|
|
|
3
|
+
## Application tests: original config, shared stubs, per-test resources
|
|
4
|
+
|
|
5
|
+
Use root `testApp` from `@noego/app`, or root `testWood` from
|
|
6
|
+
`@noego/wood` for Desktop. Keep the production config. Each selected owner
|
|
7
|
+
accepts `{ module: ['auth', 'projects'] }`, `{ path: ['/api/auth/'] }`, or
|
|
8
|
+
`{}` for all of that owner. Use actual source identities; unknown members fail.
|
|
9
|
+
Omitted owners remain omitted. Client selection enables SSR automatically.
|
|
10
|
+
|
|
11
|
+
The recommended Node runner pattern is `resourceCase`:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { expect, it } from 'vitest';
|
|
15
|
+
import { testApp } from '@noego/app';
|
|
16
|
+
import { resourceCase, testStub } from '@noego/testing';
|
|
17
|
+
|
|
18
|
+
it('prepares a fresh application root', resourceCase(async () => {
|
|
19
|
+
const app = await testApp('./noego.config.yml')
|
|
20
|
+
.select({ server: {} })
|
|
21
|
+
.use(testStub())
|
|
22
|
+
.build();
|
|
23
|
+
|
|
24
|
+
expect(app.root.isDisposed()).toBe(false);
|
|
25
|
+
}));
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This example checks preparation/lifetime, not business behavior. Add assertions
|
|
29
|
+
through the selected application's request, service, loader, or frontend surface
|
|
30
|
+
at the depth your claim needs. Build registers the graph; it does not run loaders,
|
|
31
|
+
open a database, render, or launch the deployed application. App test registration
|
|
32
|
+
receives a fresh empty environment instead of implicitly inheriting process.env;
|
|
33
|
+
supply the product's Env/configuration token explicitly through a value/provider
|
|
34
|
+
overlay when a case needs bindings or its SQLStack fixture URL.
|
|
35
|
+
|
|
36
|
+
`testStub()` is an immutable description, not an environment. It and both
|
|
37
|
+
application builders share exactly six replacement verbs: `.class`,
|
|
38
|
+
`.function`, `.method`, `.value`, `.middleware`, and `.load`.
|
|
39
|
+
`.use(otherStub)` composes descriptions in fluent order. The last entry for the
|
|
40
|
+
same owner/token/slot wins; methods apply to the final binding. Use `.class`
|
|
41
|
+
for class replacements and `.function` for declared factories/providers.
|
|
42
|
+
Ambiguous bindings require an owner option. Loader replacements name actual
|
|
43
|
+
source loaders; they are not controller-import substitutions.
|
|
44
|
+
|
|
45
|
+
Mutable objects supplied to `.value` are borrowed caller data, not cloned.
|
|
46
|
+
Use immutable values or fresh declared providers for reusable presets. Never
|
|
47
|
+
share a live fixture database or fake's mutable history between cases.
|
|
48
|
+
|
|
49
|
+
Inside `resourceCase`, successful App/Wood builds and SQLStack fixture builds
|
|
50
|
+
register automatically. Acquire fixture resources before their app borrowers.
|
|
51
|
+
Finalization settles owned work, verifies expectations, and disposes borrowers
|
|
52
|
+
before their fixtures, attempting all steps and retaining failures. Each retry
|
|
53
|
+
gets a new scope. Arbitrary floating promises are not discoverable.
|
|
54
|
+
|
|
55
|
+
For other acquired resources use the callback's `resources.own(resource)`;
|
|
56
|
+
for lower-level IoC environments use `resources.environment(environment)`.
|
|
57
|
+
`createTestScope`, `withTestScope`, and `runInResourceScope` support explicit
|
|
58
|
+
ownership, including nested owners for lazily allocated child resources.
|
|
59
|
+
Vitest 2/3/4 timeout cleanup uses its per-test `onTestFinished` hook.
|
|
60
|
+
On hosts without async-local propagation, register resources explicitly; do
|
|
61
|
+
not assume browser or another runner's timeout/cancellation integration.
|
|
62
|
+
|
|
63
|
+
Use `test.inspect(app.server, Token, 'method')` or
|
|
64
|
+
`test.inspect(app.client, Token, 'method')` for explicit App owner histories;
|
|
65
|
+
the App environment itself defaults to its server owner.
|
|
66
|
+
|
|
67
|
+
## Runner coverage and lane checks
|
|
68
|
+
|
|
69
|
+
`vitestCoverage({ runnerVersion, providerVersion, include, exclusions, thresholds })`
|
|
70
|
+
returns native V8 `options` and a frozen `provenance` record. Resolve versions
|
|
71
|
+
from the installed packages, pass all eligible authored source patterns, and
|
|
72
|
+
publish the provenance beside the runner's reports. The default target is 99%
|
|
73
|
+
for each metric; existing stricter targets should remain stricter. Every
|
|
74
|
+
exclusion needs a kind/reason; generated and separately qualified runtime
|
|
75
|
+
exclusions also need an evidence reference. Test/type declarations have
|
|
76
|
+
documented defaults. Never hide maintained bootstrap, container, UI, or loader
|
|
77
|
+
files behind blanket exclusions.
|
|
78
|
+
|
|
79
|
+
Vitest 2/3 options include `all: true`; Vitest 4 uses explicit `include`
|
|
80
|
+
without the removed `all` option. Packed native counter probes currently qualify
|
|
81
|
+
2.1.9 and 4.1.11 on Node 22: an unimported source file must appear with zero
|
|
82
|
+
hits and fail the threshold; executing both branches must then pass. Counter
|
|
83
|
+
totals differ between provider generations; do not average their reports.
|
|
84
|
+
Version 3 configuration is unit-tested but needs the same native probe for a
|
|
85
|
+
particular installed provider. Use canonical filesystem roots so source maps
|
|
86
|
+
and uncovered-file discovery identify the same files.
|
|
87
|
+
|
|
88
|
+
`assertTestLanes(requiredNames, nativeLaneCounts)` rejects missing/empty
|
|
89
|
+
required lanes, skipped required cases, failures, and inconsistent counts.
|
|
90
|
+
It validates counts from actual runner reports; it does not discover or execute
|
|
91
|
+
tests. Also require the runner's successful exit and retain collection/runtime
|
|
92
|
+
errors, source identity, and per-host reports. JavaScript coverage does not
|
|
93
|
+
establish SQL/native/browser behavior.
|
|
94
|
+
|
|
95
|
+
Repository probe (from this package):
|
|
96
|
+
```sh
|
|
97
|
+
node qualification/coverage-versions.mjs ../../desktops/demo-assistant ../../websites/kazidoc
|
|
98
|
+
node qualification/application-docs.mjs ../../desktops/demo-assistant ../../websites/kazidoc
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Lower-level IoC composition
|
|
102
|
+
|
|
3
103
|
The canonical shared owner of NoEgo test composition and method control:
|
|
4
104
|
`testIoc` real-IoC environments plus the lowercase `test.*` behavior, watch,
|
|
5
105
|
inspection, and expectation language. Built on `@noego/ioc`'s production seams
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/browser/index.ts
|
|
31
|
+
var browser_exports = {};
|
|
32
|
+
__export(browser_exports, {
|
|
33
|
+
acquireNativeBrowser: () => acquireNativeBrowser,
|
|
34
|
+
assetContentType: () => assetContentType,
|
|
35
|
+
browserPackageDirectory: () => browserPackageDirectory,
|
|
36
|
+
createBrowserResolver: () => createBrowserResolver,
|
|
37
|
+
createHappyDomTransfer: () => createHappyDomTransfer,
|
|
38
|
+
disposeNativeResources: () => disposeNativeResources,
|
|
39
|
+
fulfillWebResponse: () => fulfillWebResponse,
|
|
40
|
+
hostDeadline: () => hostDeadline,
|
|
41
|
+
importBrowserPackage: () => importBrowserPackage,
|
|
42
|
+
installBrowserFetch: () => installBrowserFetch,
|
|
43
|
+
installHappyDomFetch: () => installHappyDomFetch,
|
|
44
|
+
loadBrowserCompiler: () => loadBrowserCompiler,
|
|
45
|
+
playwrightRequest: () => playwrightRequest,
|
|
46
|
+
startSharedBrowser: () => startSharedBrowser
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(browser_exports);
|
|
49
|
+
|
|
50
|
+
// src/browser/pool.ts
|
|
51
|
+
var import_node_module = require("module");
|
|
52
|
+
var import_node_url = require("url");
|
|
53
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
54
|
+
var POOL = /* @__PURE__ */ Symbol.for("@noego/testing.native-browser-pool");
|
|
55
|
+
var globals = globalThis;
|
|
56
|
+
var pool = globals[POOL] ??= /* @__PURE__ */ new Map();
|
|
57
|
+
async function chromiumAt(rootDir) {
|
|
58
|
+
const require2 = (0, import_node_module.createRequire)(import_node_path.default.join(rootDir, "package.json"));
|
|
59
|
+
let entry;
|
|
60
|
+
try {
|
|
61
|
+
entry = require2.resolve("playwright");
|
|
62
|
+
} catch {
|
|
63
|
+
throw new Error(".browser() requires Playwright in the application. Install playwright and its Chromium browser.");
|
|
64
|
+
}
|
|
65
|
+
const module2 = await import((0, import_node_url.pathToFileURL)(entry).href);
|
|
66
|
+
return module2.chromium;
|
|
67
|
+
}
|
|
68
|
+
async function acquireNativeBrowser(rootDir) {
|
|
69
|
+
const endpoint = process.env.NOEGO_BROWSER_WS_ENDPOINT ?? process.env.WOOD_BROWSER_WS_ENDPOINT;
|
|
70
|
+
const key = endpoint ?? `local:${rootDir}`;
|
|
71
|
+
let entry = pool.get(key);
|
|
72
|
+
if (!entry) {
|
|
73
|
+
entry = {
|
|
74
|
+
opening: chromiumAt(process.env.NOEGO_BROWSER_PACKAGE_ROOT ?? rootDir).then((chromium) => endpoint ? chromium.connect(endpoint) : chromium.launch({ headless: true })),
|
|
75
|
+
borrowers: 0,
|
|
76
|
+
idle: null
|
|
77
|
+
};
|
|
78
|
+
pool.set(key, entry);
|
|
79
|
+
}
|
|
80
|
+
entry.borrowers++;
|
|
81
|
+
if (entry.idle) clearTimeout(entry.idle);
|
|
82
|
+
entry.idle = null;
|
|
83
|
+
const owned = entry;
|
|
84
|
+
let browser;
|
|
85
|
+
try {
|
|
86
|
+
browser = await owned.opening;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
owned.borrowers--;
|
|
89
|
+
if (pool.get(key) === owned) pool.delete(key);
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
if (!browser.isConnected()) {
|
|
93
|
+
owned.borrowers--;
|
|
94
|
+
if (pool.get(key) === owned) pool.delete(key);
|
|
95
|
+
return acquireNativeBrowser(rootDir);
|
|
96
|
+
}
|
|
97
|
+
let released = false;
|
|
98
|
+
return {
|
|
99
|
+
browser,
|
|
100
|
+
release() {
|
|
101
|
+
if (released) return;
|
|
102
|
+
released = true;
|
|
103
|
+
owned.borrowers--;
|
|
104
|
+
if (owned.borrowers !== 0) return;
|
|
105
|
+
owned.idle = setTimeout(() => {
|
|
106
|
+
if (owned.borrowers !== 0) return;
|
|
107
|
+
if (pool.get(key) === owned) pool.delete(key);
|
|
108
|
+
void browser.close().catch((error) => console.error("[wood] Browser pool close failed", error));
|
|
109
|
+
}, 5e3);
|
|
110
|
+
owned.idle.unref?.();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async function startSharedBrowser(rootDir = process.cwd()) {
|
|
115
|
+
const previous = process.env.NOEGO_BROWSER_WS_ENDPOINT ?? process.env.WOOD_BROWSER_WS_ENDPOINT;
|
|
116
|
+
if (previous) return { async dispose() {
|
|
117
|
+
} };
|
|
118
|
+
const chromium = await chromiumAt(rootDir);
|
|
119
|
+
const server = await chromium.launchServer({ headless: true });
|
|
120
|
+
const endpoint = server.wsEndpoint();
|
|
121
|
+
const previousPackageRoot = process.env.NOEGO_BROWSER_PACKAGE_ROOT;
|
|
122
|
+
process.env.NOEGO_BROWSER_PACKAGE_ROOT = rootDir;
|
|
123
|
+
process.env.NOEGO_BROWSER_WS_ENDPOINT = endpoint;
|
|
124
|
+
process.env.WOOD_BROWSER_WS_ENDPOINT = endpoint;
|
|
125
|
+
let closing = null;
|
|
126
|
+
return {
|
|
127
|
+
dispose() {
|
|
128
|
+
closing ??= Promise.resolve().then(async () => {
|
|
129
|
+
if (process.env.WOOD_BROWSER_WS_ENDPOINT === endpoint) delete process.env.WOOD_BROWSER_WS_ENDPOINT;
|
|
130
|
+
if (process.env.NOEGO_BROWSER_WS_ENDPOINT === endpoint) delete process.env.NOEGO_BROWSER_WS_ENDPOINT;
|
|
131
|
+
if (process.env.NOEGO_BROWSER_PACKAGE_ROOT === rootDir) {
|
|
132
|
+
if (previousPackageRoot === void 0) delete process.env.NOEGO_BROWSER_PACKAGE_ROOT;
|
|
133
|
+
else process.env.NOEGO_BROWSER_PACKAGE_ROOT = previousPackageRoot;
|
|
134
|
+
}
|
|
135
|
+
await server.close();
|
|
136
|
+
});
|
|
137
|
+
return closing;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/browser/lifecycle.ts
|
|
143
|
+
async function hostDeadline(work, label, milliseconds = 2e4) {
|
|
144
|
+
let timer;
|
|
145
|
+
try {
|
|
146
|
+
return await Promise.race([work, new Promise((_resolve, reject) => {
|
|
147
|
+
timer = setTimeout(() => reject(new Error(`NoEgo native browser ${label} timed out after ${milliseconds}ms`)), milliseconds);
|
|
148
|
+
})]);
|
|
149
|
+
} finally {
|
|
150
|
+
if (timer) clearTimeout(timer);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function disposeNativeResources(label, steps) {
|
|
154
|
+
const failures = [];
|
|
155
|
+
for (const step of steps) {
|
|
156
|
+
try {
|
|
157
|
+
await step();
|
|
158
|
+
} catch (error) {
|
|
159
|
+
failures.push(error);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (failures.length) throw Object.assign(new Error(`${label}: ${failures.map((error) => error instanceof Error ? error.message : String(error)).join("; ")}`), { errors: failures });
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// src/browser/happy_dom_transfer.ts
|
|
166
|
+
function createHappyDomTransfer(window) {
|
|
167
|
+
const prototypeNames = [
|
|
168
|
+
"Object",
|
|
169
|
+
"Array",
|
|
170
|
+
"Date",
|
|
171
|
+
"RegExp",
|
|
172
|
+
"Map",
|
|
173
|
+
"Set",
|
|
174
|
+
"ArrayBuffer",
|
|
175
|
+
"SharedArrayBuffer",
|
|
176
|
+
"DataView",
|
|
177
|
+
"Int8Array",
|
|
178
|
+
"Uint8Array",
|
|
179
|
+
"Uint8ClampedArray",
|
|
180
|
+
"Int16Array",
|
|
181
|
+
"Uint16Array",
|
|
182
|
+
"Int32Array",
|
|
183
|
+
"Uint32Array",
|
|
184
|
+
"Float32Array",
|
|
185
|
+
"Float64Array",
|
|
186
|
+
"BigInt64Array",
|
|
187
|
+
"BigUint64Array",
|
|
188
|
+
"Error",
|
|
189
|
+
"TypeError",
|
|
190
|
+
"RangeError",
|
|
191
|
+
"ReferenceError",
|
|
192
|
+
"SyntaxError",
|
|
193
|
+
"URIError",
|
|
194
|
+
"EvalError"
|
|
195
|
+
];
|
|
196
|
+
const prototypes = window.eval(`Object.fromEntries(${JSON.stringify(prototypeNames)}
|
|
197
|
+
.filter(name => typeof globalThis[name] === 'function')
|
|
198
|
+
.map(name => [name, globalThis[name].prototype]))`);
|
|
199
|
+
return (input) => {
|
|
200
|
+
const copy = structuredClone(input);
|
|
201
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
202
|
+
const visit = (value) => {
|
|
203
|
+
if (value === null || typeof value !== "object" || seen.has(value)) return;
|
|
204
|
+
seen.add(value);
|
|
205
|
+
const prototype = Object.getPrototypeOf(value);
|
|
206
|
+
const name = prototype?.constructor.name ?? "Object";
|
|
207
|
+
const target = prototypes[name];
|
|
208
|
+
if (!target) throw new TypeError(`Native happy-dom transport cannot carry ${name} into the renderer realm`);
|
|
209
|
+
if (value instanceof Map) for (const [key, entry] of value) {
|
|
210
|
+
visit(key);
|
|
211
|
+
visit(entry);
|
|
212
|
+
}
|
|
213
|
+
else if (value instanceof Set) for (const entry of value) visit(entry);
|
|
214
|
+
else if (ArrayBuffer.isView(value)) visit(value.buffer);
|
|
215
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
216
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
217
|
+
if (descriptor && "value" in descriptor) visit(descriptor.value);
|
|
218
|
+
}
|
|
219
|
+
Object.setPrototypeOf(value, target);
|
|
220
|
+
};
|
|
221
|
+
visit(copy);
|
|
222
|
+
return copy;
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// src/browser/compiler.ts
|
|
227
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
228
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
229
|
+
var import_node_module2 = require("module");
|
|
230
|
+
var import_node_url2 = require("url");
|
|
231
|
+
function browserPackageDirectory(rootDir, name) {
|
|
232
|
+
for (const root of [rootDir, process.cwd()]) {
|
|
233
|
+
for (let ancestor = import_node_path2.default.resolve(root); ; ancestor = import_node_path2.default.dirname(ancestor)) {
|
|
234
|
+
const manifest = import_node_path2.default.join(ancestor, "package.json");
|
|
235
|
+
if (import_node_fs.default.existsSync(manifest) && JSON.parse(import_node_fs.default.readFileSync(manifest, "utf8")).name === name) return import_node_fs.default.realpathSync(ancestor);
|
|
236
|
+
if (ancestor === import_node_path2.default.dirname(ancestor)) break;
|
|
237
|
+
}
|
|
238
|
+
const require2 = (0, import_node_module2.createRequire)(import_node_path2.default.join(root, "package.json"));
|
|
239
|
+
for (const dir of require2.resolve.paths(name) ?? []) {
|
|
240
|
+
const candidate = import_node_path2.default.join(dir, name);
|
|
241
|
+
if (import_node_fs.default.existsSync(import_node_path2.default.join(candidate, "package.json"))) return import_node_fs.default.realpathSync(candidate);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
throw new Error(`Native browser host requires ${name} installed in the application`);
|
|
245
|
+
}
|
|
246
|
+
function importExport(value) {
|
|
247
|
+
if (typeof value === "string") return value;
|
|
248
|
+
if (value && typeof value === "object") {
|
|
249
|
+
const conditions = value;
|
|
250
|
+
for (const key of ["browser", "svelte", "import", "default"]) {
|
|
251
|
+
const entry = importExport(conditions[key]);
|
|
252
|
+
if (entry) return entry;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return void 0;
|
|
256
|
+
}
|
|
257
|
+
async function importBrowserPackage(rootDir, name) {
|
|
258
|
+
const dir = browserPackageDirectory(rootDir, name);
|
|
259
|
+
const pkg = JSON.parse(import_node_fs.default.readFileSync(import_node_path2.default.join(dir, "package.json"), "utf8"));
|
|
260
|
+
const entry = importExport(pkg.exports?.["."] ?? pkg.exports) ?? pkg.module ?? pkg.main;
|
|
261
|
+
if (!entry) throw new Error(`Cannot resolve the ESM entry of ${name}`);
|
|
262
|
+
return import((0, import_node_url2.pathToFileURL)(import_node_path2.default.resolve(dir, entry)).href);
|
|
263
|
+
}
|
|
264
|
+
function createBrowserResolver(rootDir) {
|
|
265
|
+
const svelte = browserPackageDirectory(rootDir, "svelte");
|
|
266
|
+
return {
|
|
267
|
+
name: "noego-native-browser-resolver",
|
|
268
|
+
enforce: "pre",
|
|
269
|
+
async resolveId(source, importer) {
|
|
270
|
+
if (source === "svelte") return import_node_path2.default.join(svelte, "src/index-client.js");
|
|
271
|
+
if (source === "svelte/legacy") return import_node_path2.default.join(svelte, "src/legacy/legacy-client.js");
|
|
272
|
+
if (source === "svelte/reactivity") return import_node_path2.default.join(svelte, "src/reactivity/index-client.js");
|
|
273
|
+
if (source.startsWith("@noego/") || source.startsWith("svelte/")) {
|
|
274
|
+
const pieces = source.split("/");
|
|
275
|
+
const name = source.startsWith("@") ? pieces.slice(0, 2).join("/") : pieces[0];
|
|
276
|
+
const subpath = "." + source.slice(name.length);
|
|
277
|
+
let directory;
|
|
278
|
+
try {
|
|
279
|
+
directory = browserPackageDirectory(rootDir, name);
|
|
280
|
+
} catch (error) {
|
|
281
|
+
if (!importer || importer.startsWith("\0")) throw error;
|
|
282
|
+
directory = browserPackageDirectory(import_node_path2.default.dirname(importer), name);
|
|
283
|
+
}
|
|
284
|
+
const manifest = JSON.parse(import_node_fs.default.readFileSync(import_node_path2.default.join(directory, "package.json"), "utf8"));
|
|
285
|
+
const entry = importExport(manifest.exports?.[subpath]);
|
|
286
|
+
if (entry) return import_node_path2.default.resolve(directory, entry);
|
|
287
|
+
return this.resolve(source, import_node_path2.default.join(rootDir, "__noego_native_entry.ts"), { skipSelf: true });
|
|
288
|
+
}
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
async function loadBrowserCompiler(rootDir) {
|
|
294
|
+
const vite = await importBrowserPackage(rootDir, "vite");
|
|
295
|
+
const plugin = await importBrowserPackage(rootDir, "@sveltejs/vite-plugin-svelte");
|
|
296
|
+
return { build: vite.build, svelte: plugin.svelte };
|
|
297
|
+
}
|
|
298
|
+
function assetContentType(file) {
|
|
299
|
+
const extension = file.split(".").pop()?.toLowerCase();
|
|
300
|
+
const known = { js: "text/javascript", mjs: "text/javascript", css: "text/css", wasm: "application/wasm", json: "application/json", svg: "image/svg+xml", png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg", webp: "image/webp", woff: "font/woff", woff2: "font/woff2" };
|
|
301
|
+
return known[extension ?? ""] ?? "application/octet-stream";
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// src/fetch/redirects.ts
|
|
305
|
+
async function followFetchRedirects(request, send) {
|
|
306
|
+
for (let hop = 0; ; hop++) {
|
|
307
|
+
const saved = request.clone();
|
|
308
|
+
const response = await send(request, saved);
|
|
309
|
+
const location = response.headers.get("location");
|
|
310
|
+
const redirect = [301, 302, 303, 307, 308].includes(response.status) && location !== null;
|
|
311
|
+
if (!redirect || saved.redirect === "manual") {
|
|
312
|
+
if (!response.url) Object.defineProperty(response, "url", { value: saved.url });
|
|
313
|
+
if (hop) Object.defineProperty(response, "redirected", { value: true });
|
|
314
|
+
return response;
|
|
315
|
+
}
|
|
316
|
+
if (saved.redirect === "error") throw new TypeError("Fetch redirect mode is error");
|
|
317
|
+
if (hop >= 20) throw new TypeError("Fetch exceeded 20 redirects");
|
|
318
|
+
const destination = new URL(location, saved.url);
|
|
319
|
+
if (!["http:", "https:"].includes(destination.protocol)) throw new TypeError("Unsupported fetch redirect scheme");
|
|
320
|
+
const headers = new Headers(saved.headers);
|
|
321
|
+
let method = saved.method;
|
|
322
|
+
let body = saved.body;
|
|
323
|
+
if ([301, 302].includes(response.status) && method === "POST" || response.status === 303 && method !== "GET" && method !== "HEAD") {
|
|
324
|
+
method = "GET";
|
|
325
|
+
body = null;
|
|
326
|
+
for (const name of ["content-type", "content-length", "content-encoding", "content-language", "content-location"]) headers.delete(name);
|
|
327
|
+
}
|
|
328
|
+
if (destination.origin !== new URL(saved.url).origin) {
|
|
329
|
+
for (const name of ["authorization", "proxy-authorization", "cookie", "cookie2"]) headers.delete(name);
|
|
330
|
+
}
|
|
331
|
+
await response.body?.cancel();
|
|
332
|
+
const next = { method, headers, body, signal: saved.signal, redirect: saved.redirect, credentials: saved.credentials };
|
|
333
|
+
if (body) next.duplex = "half";
|
|
334
|
+
request = new Request(destination, next);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// src/browser/network.ts
|
|
339
|
+
async function fulfillWebResponse(route, response) {
|
|
340
|
+
const headers = Object.fromEntries(response.headers.entries());
|
|
341
|
+
delete headers["content-encoding"];
|
|
342
|
+
delete headers["content-length"];
|
|
343
|
+
delete headers["transfer-encoding"];
|
|
344
|
+
const cookies = response.headers.getSetCookie?.();
|
|
345
|
+
if (cookies?.length) headers["set-cookie"] = cookies.join("\n");
|
|
346
|
+
await route.fulfill({ status: response.status, headers, body: Buffer.from(await response.arrayBuffer()) });
|
|
347
|
+
}
|
|
348
|
+
async function playwrightRequest(route) {
|
|
349
|
+
const request = route.request();
|
|
350
|
+
const body = request.postDataBuffer();
|
|
351
|
+
return new Request(request.url(), { method: request.method(), headers: await request.allHeaders(), ...body ? { body: new Uint8Array(body) } : {} });
|
|
352
|
+
}
|
|
353
|
+
async function installBrowserFetch(context, network, internalOrigin) {
|
|
354
|
+
await context.route("**/*", async (route) => {
|
|
355
|
+
if (new URL(route.request().url()).origin === internalOrigin) {
|
|
356
|
+
await route.fallback();
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
try {
|
|
360
|
+
const response = await network.dispatch(await playwrightRequest(route));
|
|
361
|
+
if (response) await fulfillWebResponse(route, response);
|
|
362
|
+
else await route.continue();
|
|
363
|
+
} catch {
|
|
364
|
+
await route.abort("failed").catch(() => {
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
function installHappyDomFetch(window, dispatch) {
|
|
370
|
+
const nativeFetch = window.fetch.bind(window);
|
|
371
|
+
const pending = /* @__PURE__ */ new Set();
|
|
372
|
+
const close = new AbortController();
|
|
373
|
+
const execute = async (input, init) => {
|
|
374
|
+
const source = new window.Request(typeof input === "string" ? new URL(input, window.location.href).href : input, init);
|
|
375
|
+
if (source.mode === "websocket") throw new TypeError("fetch does not accept websocket mode");
|
|
376
|
+
const cancellation = new AbortController();
|
|
377
|
+
const cancel = () => cancellation.abort(source.signal.reason);
|
|
378
|
+
if (source.signal.aborted) cancel();
|
|
379
|
+
else source.signal.addEventListener("abort", cancel, { once: true });
|
|
380
|
+
try {
|
|
381
|
+
const request = new Request(source.url, {
|
|
382
|
+
method: source.method,
|
|
383
|
+
headers: [...source.headers],
|
|
384
|
+
signal: AbortSignal.any([cancellation.signal, close.signal]),
|
|
385
|
+
...source.body ? { body: new Uint8Array(await source.arrayBuffer()) } : {},
|
|
386
|
+
redirect: source.redirect,
|
|
387
|
+
credentials: source.credentials,
|
|
388
|
+
mode: source.mode
|
|
389
|
+
});
|
|
390
|
+
const response = await followFetchRedirects(request, async (current, replay) => {
|
|
391
|
+
current.signal.throwIfAborted();
|
|
392
|
+
const intercepted = await dispatch(current);
|
|
393
|
+
if (intercepted) return intercepted;
|
|
394
|
+
const nativeCancellation = new window.AbortController();
|
|
395
|
+
const cancelNative = () => nativeCancellation.abort(replay.signal.reason);
|
|
396
|
+
if (replay.signal.aborted) cancelNative();
|
|
397
|
+
else replay.signal.addEventListener("abort", cancelNative, { once: true });
|
|
398
|
+
try {
|
|
399
|
+
const received = await nativeFetch(replay.url, {
|
|
400
|
+
method: replay.method,
|
|
401
|
+
headers: [...replay.headers],
|
|
402
|
+
...replay.body ? { body: new Uint8Array(await replay.arrayBuffer()) } : {},
|
|
403
|
+
signal: nativeCancellation.signal,
|
|
404
|
+
redirect: "manual",
|
|
405
|
+
credentials: replay.credentials,
|
|
406
|
+
mode: replay.mode
|
|
407
|
+
});
|
|
408
|
+
const result2 = new Response(received.body ? new Uint8Array(await received.arrayBuffer()) : null, {
|
|
409
|
+
status: received.status,
|
|
410
|
+
statusText: received.statusText,
|
|
411
|
+
headers: [...received.headers]
|
|
412
|
+
});
|
|
413
|
+
return result2;
|
|
414
|
+
} finally {
|
|
415
|
+
replay.signal.removeEventListener("abort", cancelNative);
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
const bytes = response.body ? new Uint8Array(await response.arrayBuffer()) : null;
|
|
419
|
+
const result = new window.Response(bytes, { status: response.status, statusText: response.statusText, headers: [...response.headers] });
|
|
420
|
+
Object.defineProperties(result, { url: { value: response.url || request.url }, redirected: { value: response.redirected } });
|
|
421
|
+
return result;
|
|
422
|
+
} finally {
|
|
423
|
+
source.signal.removeEventListener("abort", cancel);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
window.fetch = ((input, init) => {
|
|
427
|
+
const work = execute(input, init);
|
|
428
|
+
pending.add(work);
|
|
429
|
+
void work.then(() => pending.delete(work), () => pending.delete(work));
|
|
430
|
+
return work;
|
|
431
|
+
});
|
|
432
|
+
return {
|
|
433
|
+
async settle() {
|
|
434
|
+
while (pending.size) await Promise.all([...pending]);
|
|
435
|
+
},
|
|
436
|
+
dispose() {
|
|
437
|
+
close.abort(new DOMException("Native fetch host disposed", "AbortError"));
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
442
|
+
0 && (module.exports = {
|
|
443
|
+
acquireNativeBrowser,
|
|
444
|
+
assetContentType,
|
|
445
|
+
browserPackageDirectory,
|
|
446
|
+
createBrowserResolver,
|
|
447
|
+
createHappyDomTransfer,
|
|
448
|
+
disposeNativeResources,
|
|
449
|
+
fulfillWebResponse,
|
|
450
|
+
hostDeadline,
|
|
451
|
+
importBrowserPackage,
|
|
452
|
+
installBrowserFetch,
|
|
453
|
+
installHappyDomFetch,
|
|
454
|
+
loadBrowserCompiler,
|
|
455
|
+
playwrightRequest,
|
|
456
|
+
startSharedBrowser
|
|
457
|
+
});
|
|
458
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/browser/index.ts","../../src/browser/pool.ts","../../src/browser/lifecycle.ts","../../src/browser/happy_dom_transfer.ts","../../src/browser/compiler.ts","../../src/fetch/redirects.ts","../../src/browser/network.ts"],"sourcesContent":["export { acquireNativeBrowser, startSharedBrowser } from './pool.js';\nexport { disposeNativeResources, hostDeadline } from './lifecycle.js';\nexport { createHappyDomTransfer } from './happy_dom_transfer.js';\nexport { browserPackageDirectory, importBrowserPackage, createBrowserResolver, loadBrowserCompiler, assetContentType } from './compiler.js';\nexport { installBrowserFetch, installHappyDomFetch, playwrightRequest, fulfillWebResponse } from './network.js';\nexport type BrowserHost = 'playwright' | 'happy_dom';\nexport type NativeBrowserPage<H extends BrowserHost> = H extends 'happy_dom' ? import('happy-dom').Window : import('playwright').Page;\n","import { createRequire } from 'node:module';\nimport { pathToFileURL } from 'node:url';\nimport path from 'node:path';\nimport type { Browser, BrowserServer, BrowserType } from 'playwright';\n\ninterface BrowserLease {\n readonly browser: Browser;\n release(): void;\n}\ninterface PoolEntry {\n readonly opening: Promise<Browser>;\n borrowers: number;\n idle: ReturnType<typeof setTimeout> | null;\n}\n// Vitest may reload a module per file. Keep only the shared PROCESS resource\n// here; contexts, pages, application state and database handles never enter it.\nconst POOL = Symbol.for('@noego/testing.native-browser-pool');\nconst globals = globalThis as typeof globalThis & { [POOL]?: Map<string, PoolEntry> };\nconst pool = globals[POOL] ??= new Map<string, PoolEntry>();\n\nasync function chromiumAt(rootDir: string): Promise<BrowserType> {\n const require = createRequire(path.join(rootDir, 'package.json'));\n let entry: string;\n try { entry = require.resolve('playwright'); }\n catch { throw new Error('.browser() requires Playwright in the application. Install playwright and its Chromium browser.'); }\n const module = await import(pathToFileURL(entry).href) as typeof import('playwright');\n return module.chromium;\n}\n\nexport async function acquireNativeBrowser(rootDir: string): Promise<BrowserLease> {\n const endpoint = process.env.NOEGO_BROWSER_WS_ENDPOINT ?? process.env.WOOD_BROWSER_WS_ENDPOINT;\n const key = endpoint ?? `local:${rootDir}`;\n let entry = pool.get(key);\n if (!entry) {\n entry = {\n opening: chromiumAt(process.env.NOEGO_BROWSER_PACKAGE_ROOT ?? rootDir).then(chromium => endpoint\n ? chromium.connect(endpoint) // An explicit shared endpoint MUST NOT silently launch another browser.\n : chromium.launch({headless: true})),\n borrowers: 0, idle: null,\n };\n pool.set(key, entry);\n }\n // Reserve before awaiting so concurrent acquires/disposes cannot close a\n // browser another admitted environment is still acquiring.\n entry.borrowers++;\n if (entry.idle) clearTimeout(entry.idle);\n entry.idle = null;\n const owned = entry;\n let browser: Browser;\n try { browser = await owned.opening; }\n catch (error) {\n owned.borrowers--;\n if (pool.get(key) === owned) pool.delete(key);\n throw error;\n }\n if (!browser.isConnected()) {\n owned.borrowers--;\n if (pool.get(key) === owned) pool.delete(key);\n return acquireNativeBrowser(rootDir);\n }\n let released = false;\n return {\n browser,\n release() {\n if (released) return;\n released = true;\n owned.borrowers--;\n if (owned.borrowers !== 0) return;\n // Disconnect idle worker clients, not the run-owned BrowserServer.\n // Without global setup this also bounds local fallback resource lifetime.\n owned.idle = setTimeout(() => {\n if (owned.borrowers !== 0) return;\n if (pool.get(key) === owned) pool.delete(key);\n void browser.close().catch(error => console.error('[wood] Browser pool close failed', error));\n }, 5_000);\n owned.idle.unref?.();\n },\n };\n}\n\n/** Runner owns ONE Chromium server; workers create isolated contexts/tabs. */\nexport async function startSharedBrowser(rootDir = process.cwd()): Promise<{ dispose(): Promise<void> }> {\n const previous = process.env.NOEGO_BROWSER_WS_ENDPOINT ?? process.env.WOOD_BROWSER_WS_ENDPOINT;\n // An outer runner already owns the browser; never launch a second server.\n if (previous) return {async dispose() {}};\n const chromium = await chromiumAt(rootDir);\n const server: BrowserServer = await chromium.launchServer({headless: true});\n const endpoint = server.wsEndpoint();\n const previousPackageRoot = process.env.NOEGO_BROWSER_PACKAGE_ROOT;\n process.env.NOEGO_BROWSER_PACKAGE_ROOT = rootDir;\n process.env.NOEGO_BROWSER_WS_ENDPOINT = endpoint;\n process.env.WOOD_BROWSER_WS_ENDPOINT = endpoint; // compatibility for existing Wood runner setup\n let closing: Promise<void> | null = null;\n return {\n dispose() {\n closing ??= Promise.resolve().then(async () => {\n if (process.env.WOOD_BROWSER_WS_ENDPOINT === endpoint) delete process.env.WOOD_BROWSER_WS_ENDPOINT;\n if (process.env.NOEGO_BROWSER_WS_ENDPOINT === endpoint) delete process.env.NOEGO_BROWSER_WS_ENDPOINT;\n if (process.env.NOEGO_BROWSER_PACKAGE_ROOT === rootDir) {\n if (previousPackageRoot === undefined) delete process.env.NOEGO_BROWSER_PACKAGE_ROOT;\n else process.env.NOEGO_BROWSER_PACKAGE_ROOT = previousPackageRoot;\n }\n await server.close();\n });\n return closing;\n },\n };\n}\n","/** An infrastructure deadline, not a sleep-based assertion or a mock clock. */\nexport async function hostDeadline<T>(work: Promise<T>, label: string, milliseconds = 20_000): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([work, new Promise<never>((_resolve, reject) => {\n timer = setTimeout(() => reject(new Error(`NoEgo native browser ${label} timed out after ${milliseconds}ms`)), milliseconds);\n })]);\n } finally { if (timer) clearTimeout(timer); }\n}\n\n/** Attempt every owned teardown step; preserve primary cleanup errors. */\nexport async function disposeNativeResources(label: string, steps: ReadonlyArray<() => unknown | Promise<unknown>>): Promise<void> {\n const failures: unknown[] = [];\n for (const step of steps) { try { await step(); } catch (error) { failures.push(error); } }\n if (failures.length) throw Object.assign(new Error(`${label}: ${failures.map(error =>\n error instanceof Error ? error.message : String(error)).join('; ')}`), {errors: failures});\n}\n","import type { Window } from 'happy-dom';\n\n/**\n * Node structuredClone snapshots data but constructs its result in Node's\n * realm. Re-home the clone's built-in prototypes into the receiving Window:\n * otherwise renderer validators see foreign \"plain objects\" unlike Chromium.\n * No caller-owned value is mutated. Native slots (Date/Map/buffers) remain the\n * engine's slots; we are not implementing a second serializer or DOM mock.\n */\nexport function createHappyDomTransfer(window: Window): (input: unknown) => unknown {\n const prototypeNames = [\n 'Object', 'Array', 'Date', 'RegExp', 'Map', 'Set', 'ArrayBuffer',\n 'SharedArrayBuffer', 'DataView', 'Int8Array', 'Uint8Array', 'Uint8ClampedArray',\n 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array',\n 'Float64Array', 'BigInt64Array', 'BigUint64Array', 'Error', 'TypeError',\n 'RangeError', 'ReferenceError', 'SyntaxError', 'URIError', 'EvalError',\n ];\n const prototypes = window.eval(`Object.fromEntries(${JSON.stringify(prototypeNames)}\n .filter(name => typeof globalThis[name] === 'function')\n .map(name => [name, globalThis[name].prototype]))`) as Record<string, object>;\n\n return (input: unknown): unknown => {\n const copy: unknown = structuredClone(input);\n const seen = new WeakSet<object>();\n const visit = (value: unknown): void => {\n if (value === null || typeof value !== 'object' || seen.has(value)) return;\n seen.add(value);\n const prototype: object | null = Object.getPrototypeOf(value);\n const name = prototype?.constructor.name ?? 'Object';\n const target = prototypes[name];\n if (!target) throw new TypeError(`Native happy-dom transport cannot carry ${name} into the renderer realm`);\n if (value instanceof Map) for (const [key, entry] of value) {visit(key); visit(entry);}\n else if (value instanceof Set) for (const entry of value) visit(entry);\n else if (ArrayBuffer.isView(value)) visit(value.buffer);\n for (const key of Reflect.ownKeys(value)) {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (descriptor && 'value' in descriptor) visit(descriptor.value);\n }\n Object.setPrototypeOf(value, target);\n };\n visit(copy);\n return copy;\n };\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { createRequire } from 'node:module';\nimport { pathToFileURL } from 'node:url';\nimport type { Plugin } from 'vite';\n\n/** Resolve optional compiler/host packages from the caller's project, not a published global installation. */\nexport function browserPackageDirectory(rootDir: string, name: string): string {\n for (const root of [rootDir, process.cwd()]) {\n // A package's own qualification fixtures use Node's package self-reference.\n for (let ancestor = path.resolve(root); ; ancestor = path.dirname(ancestor)) {\n const manifest = path.join(ancestor, 'package.json');\n if (fs.existsSync(manifest) && JSON.parse(fs.readFileSync(manifest, 'utf8')).name === name) return fs.realpathSync(ancestor);\n if (ancestor === path.dirname(ancestor)) break;\n }\n const require = createRequire(path.join(root, 'package.json'));\n for (const dir of require.resolve.paths(name) ?? []) {\n const candidate = path.join(dir, name);\n if (fs.existsSync(path.join(candidate, 'package.json'))) return fs.realpathSync(candidate);\n }\n }\n throw new Error(`Native browser host requires ${name} installed in the application`);\n}\nfunction importExport(value: unknown): string | undefined {\n if (typeof value === 'string') return value;\n if (value && typeof value === 'object') {\n const conditions = value as Record<string, unknown>;\n for (const key of ['browser', 'svelte', 'import', 'default']) {\n const entry = importExport(conditions[key]);\n if (entry) return entry;\n }\n }\n return undefined;\n}\nexport async function importBrowserPackage(rootDir: string, name: string): Promise<unknown> {\n const dir = browserPackageDirectory(rootDir, name);\n const pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8')) as {exports?: Record<string, unknown>; module?: string; main?: string};\n const entry = importExport(pkg.exports?.['.'] ?? pkg.exports) ?? pkg.module ?? pkg.main;\n if (!entry) throw new Error(`Cannot resolve the ESM entry of ${name}`);\n return import(pathToFileURL(path.resolve(dir, entry)).href);\n}\n\n/** Generated temporary entries resolve packages in the ORIGINAL application. */\nexport function createBrowserResolver(rootDir: string): Plugin {\n const svelte = browserPackageDirectory(rootDir, 'svelte');\n return {\n name: 'noego-native-browser-resolver', enforce: 'pre',\n async resolveId(source, importer) {\n if (source === 'svelte') return path.join(svelte, 'src/index-client.js');\n if (source === 'svelte/legacy') return path.join(svelte, 'src/legacy/legacy-client.js');\n if (source === 'svelte/reactivity') return path.join(svelte, 'src/reactivity/index-client.js');\n if (source.startsWith('@noego/') || source.startsWith('svelte/')) {\n const pieces = source.split('/');\n const name = source.startsWith('@') ? pieces.slice(0, 2).join('/') : pieces[0]!;\n const subpath = '.' + source.slice(name.length);\n let directory: string;\n try { directory = browserPackageDirectory(rootDir, name); }\n catch (error) {\n if (!importer || importer.startsWith('\\0')) throw error;\n directory = browserPackageDirectory(path.dirname(importer), name);\n }\n const manifest = JSON.parse(fs.readFileSync(path.join(directory, 'package.json'), 'utf8')) as {exports?: Record<string, unknown>};\n const entry = importExport(manifest.exports?.[subpath]);\n if (entry) return path.resolve(directory, entry);\n return this.resolve(source, path.join(rootDir, '__noego_native_entry.ts'), {skipSelf: true});\n }\n return null;\n },\n };\n}\nexport async function loadBrowserCompiler(rootDir: string) {\n const vite = await importBrowserPackage(rootDir, 'vite') as typeof import('vite');\n const plugin = await importBrowserPackage(rootDir, '@sveltejs/vite-plugin-svelte') as {svelte(options?: {hot?: boolean; configFile?: false}): Plugin[]};\n return {build: vite.build, svelte: plugin.svelte};\n}\n\nexport function assetContentType(file: string): string {\n const extension = file.split('.').pop()?.toLowerCase();\n const known: Record<string, string> = {js: 'text/javascript', mjs: 'text/javascript', css: 'text/css', wasm: 'application/wasm', json: 'application/json', svg: 'image/svg+xml', png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', webp: 'image/webp', woff: 'font/woff', woff2: 'font/woff2'};\n return known[extension ?? ''] ?? 'application/octet-stream';\n}\n","/** Shared single-hop redirect semantics; native browser adapters need no parallel HTTP DSL. */\nexport async function followFetchRedirects(\n request: Request,\n send: (request: Request, replay: Request) => Promise<Response>,\n): Promise<Response> {\n // Every redirect re-enters the same router (catch-all routes still apply).\n for (let hop = 0; ; hop++) {\n const saved = request.clone();\n const response = await send(request, saved);\n const location = response.headers.get('location');\n const redirect = [301, 302, 303, 307, 308].includes(response.status) && location !== null;\n if (!redirect || saved.redirect === 'manual') {\n if (!response.url) Object.defineProperty(response, 'url', {value: saved.url});\n if (hop) Object.defineProperty(response, 'redirected', {value: true});\n return response;\n }\n if (saved.redirect === 'error') throw new TypeError('Fetch redirect mode is error');\n if (hop >= 20) throw new TypeError('Fetch exceeded 20 redirects');\n const destination = new URL(location, saved.url);\n if (!['http:', 'https:'].includes(destination.protocol)) throw new TypeError('Unsupported fetch redirect scheme');\n const headers = new Headers(saved.headers);\n let method = saved.method;\n let body: BodyInit | null = saved.body;\n if (([301, 302].includes(response.status) && method === 'POST') || (response.status === 303 && method !== 'GET' && method !== 'HEAD')) {\n method = 'GET'; body = null;\n for (const name of ['content-type', 'content-length', 'content-encoding', 'content-language', 'content-location']) headers.delete(name);\n }\n if (destination.origin !== new URL(saved.url).origin) {\n for (const name of ['authorization', 'proxy-authorization', 'cookie', 'cookie2']) headers.delete(name);\n }\n await response.body?.cancel();\n const next: RequestInit & {duplex?: 'half'} = {method, headers, body, signal: saved.signal, redirect: saved.redirect, credentials: saved.credentials};\n if (body) next.duplex = 'half';\n request = new Request(destination, next);\n }\n}\n","import { followFetchRedirects } from '../fetch/redirects.js';\nimport type { BrowserContext, Route } from 'playwright';\nimport type { Window } from 'happy-dom';\nimport type { TestFetchRuntime } from '../fetch/index.js';\n\n/** Fulfil a native browser request. Chromium retains its HTTP/CORS/redirect semantics. */\nexport async function fulfillWebResponse(route: Route, response: Response): Promise<void> {\n const headers: Record<string, string> = Object.fromEntries(response.headers.entries());\n // These describe wire compression/length, not the decoded body we are forwarding.\n delete headers['content-encoding']; delete headers['content-length']; delete headers['transfer-encoding'];\n const cookies = response.headers.getSetCookie?.();\n if (cookies?.length) headers['set-cookie'] = cookies.join('\\n');\n await route.fulfill({status: response.status, headers, body: Buffer.from(await response.arrayBuffer())});\n}\nexport async function playwrightRequest(route: Route): Promise<Request> {\n const request = route.request();\n const body = request.postDataBuffer();\n return new Request(request.url(), {method: request.method(), headers: await request.allHeaders(), ...(body ? {body: new Uint8Array(body)} : {})});\n}\n\n/** One env/context owns these routes. Unmatched traffic keeps the actual browser network. */\nexport async function installBrowserFetch(context: BrowserContext, network: TestFetchRuntime, internalOrigin?: string): Promise<void> {\n await context.route('**/*', async route => {\n if (new URL(route.request().url()).origin === internalOrigin) {await route.fallback(); return;}\n try {\n const response = await network.dispatch(await playwrightRequest(route));\n if (response) await fulfillWebResponse(route, response);\n else await route.continue();\n } catch {\n // A thrown test handler is a network failure, not an invented HTTP 500.\n await route.abort('failed').catch(() => {});\n }\n });\n}\n\n/** Patch only this Window's host boundary, never Node globalThis.fetch. */\nexport function installHappyDomFetch(\n window: Window,\n dispatch: (request: Request) => Promise<Response | null>,\n): {settle(): Promise<void>; dispose(): void} {\n const nativeFetch = window.fetch.bind(window);\n const pending = new Set<Promise<unknown>>();\n const close = new AbortController();\n const execute = async (input: Parameters<Window['fetch']>[0], init?: Parameters<Window['fetch']>[1]) => {\n const source = new window.Request(typeof input === 'string' ? new URL(input, window.location.href).href : input, init);\n if (source.mode === 'websocket') throw new TypeError('fetch does not accept websocket mode');\n const cancellation = new AbortController();\n const cancel = () => cancellation.abort(source.signal.reason);\n if (source.signal.aborted) cancel();\n else source.signal.addEventListener('abort', cancel, {once: true});\n try {\n const request = new Request(source.url, {\n method: source.method, headers: [...source.headers],\n signal: AbortSignal.any([cancellation.signal, close.signal]),\n ...(source.body ? {body: new Uint8Array(await source.arrayBuffer())} : {}),\n redirect: source.redirect, credentials: source.credentials, mode: source.mode,\n });\n const response = await followFetchRedirects(request, async (current, replay) => {\n current.signal.throwIfAborted();\n const intercepted = await dispatch(current);\n if (intercepted) return intercepted;\n // Fallthrough uses HAPPY-DOM'S fetch, cookies and origin behavior, not Node's global fetch.\n const nativeCancellation = new window.AbortController();\n const cancelNative = () => nativeCancellation.abort(replay.signal.reason);\n if (replay.signal.aborted) cancelNative();\n else replay.signal.addEventListener('abort', cancelNative, {once: true});\n try {\n const received = await nativeFetch(replay.url, {\n method: replay.method, headers: [...replay.headers],\n ...(replay.body ? {body: new Uint8Array(await replay.arrayBuffer())} : {}),\n signal: nativeCancellation.signal,\n redirect: 'manual', credentials: replay.credentials, mode: replay.mode,\n });\n const result = new Response(received.body ? new Uint8Array(await received.arrayBuffer()) : null, {\n status: received.status, statusText: received.statusText, headers: [...received.headers],\n });\n return result;\n } finally {replay.signal.removeEventListener('abort', cancelNative);}\n });\n const bytes = response.body ? new Uint8Array(await response.arrayBuffer()) : null;\n const result = new window.Response(bytes, {status: response.status, statusText: response.statusText, headers: [...response.headers]});\n Object.defineProperties(result, {url: {value: response.url || request.url}, redirected: {value: response.redirected}});\n return result;\n } finally {source.signal.removeEventListener('abort', cancel);}\n };\n window.fetch = ((input, init) => {\n const work = execute(input, init);\n pending.add(work);\n void work.then(() => pending.delete(work), () => pending.delete(work));\n return work;\n }) as Window['fetch'];\n return {\n async settle() {while (pending.size) await Promise.all([...pending]);},\n dispose() {close.abort(new DOMException('Native fetch host disposed', 'AbortError'));},\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,yBAA8B;AAC9B,sBAA8B;AAC9B,uBAAiB;AAcjB,IAAM,OAAO,uBAAO,IAAI,oCAAoC;AAC5D,IAAM,UAAU;AAChB,IAAM,OAAO,QAAQ,IAAI,MAAM,oBAAI,IAA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