@ricsam/isolate 0.0.1 → 0.1.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/dist/cjs/bridge/diagnostics.cjs +58 -0
- package/dist/cjs/bridge/diagnostics.cjs.map +10 -0
- package/dist/cjs/bridge/legacy-adapters.cjs +242 -0
- package/dist/cjs/bridge/legacy-adapters.cjs.map +10 -0
- package/dist/cjs/bridge/request-context.cjs +59 -0
- package/dist/cjs/bridge/request-context.cjs.map +10 -0
- package/dist/cjs/bridge/runtime-bindings.cjs +367 -0
- package/dist/cjs/bridge/runtime-bindings.cjs.map +10 -0
- package/dist/cjs/browser/browser-runtime.cjs +157 -0
- package/dist/cjs/browser/browser-runtime.cjs.map +10 -0
- package/dist/cjs/daemon.cjs +91 -0
- package/dist/cjs/daemon.cjs.map +10 -0
- package/dist/cjs/files/index.cjs +140 -0
- package/dist/cjs/files/index.cjs.map +10 -0
- package/dist/cjs/host/create-isolate-host.cjs +235 -0
- package/dist/cjs/host/create-isolate-host.cjs.map +10 -0
- package/dist/cjs/host/index.cjs +47 -0
- package/dist/cjs/host/index.cjs.map +10 -0
- package/dist/cjs/index.cjs +55 -0
- package/dist/cjs/index.cjs.map +10 -0
- package/dist/cjs/internal/client/connection.cjs +1919 -0
- package/dist/cjs/internal/client/connection.cjs.map +10 -0
- package/dist/cjs/internal/client/index.cjs +48 -0
- package/dist/cjs/internal/client/index.cjs.map +10 -0
- package/dist/cjs/internal/client/types.cjs +30 -0
- package/dist/cjs/internal/client/types.cjs.map +9 -0
- package/dist/cjs/internal/console/index.cjs +506 -0
- package/dist/cjs/internal/console/index.cjs.map +10 -0
- package/dist/cjs/internal/console/utils.cjs +70 -0
- package/dist/cjs/internal/console/utils.cjs.map +10 -0
- package/dist/cjs/internal/core/index.cjs +2745 -0
- package/dist/cjs/internal/core/index.cjs.map +10 -0
- package/dist/cjs/internal/crypto/index.cjs +470 -0
- package/dist/cjs/internal/crypto/index.cjs.map +10 -0
- package/dist/cjs/internal/daemon/callback-fs-handler.cjs +355 -0
- package/dist/cjs/internal/daemon/callback-fs-handler.cjs.map +10 -0
- package/dist/cjs/internal/daemon/connection.cjs +1952 -0
- package/dist/cjs/internal/daemon/connection.cjs.map +10 -0
- package/dist/cjs/internal/daemon/daemon.cjs +98 -0
- package/dist/cjs/internal/daemon/daemon.cjs.map +10 -0
- package/dist/cjs/internal/daemon/index.cjs +145 -0
- package/dist/cjs/internal/daemon/index.cjs.map +10 -0
- package/dist/cjs/internal/daemon/runtime-pool.cjs +106 -0
- package/dist/cjs/internal/daemon/runtime-pool.cjs.map +10 -0
- package/dist/cjs/internal/daemon/types.cjs +30 -0
- package/dist/cjs/internal/daemon/types.cjs.map +9 -0
- package/dist/cjs/internal/encoding/index.cjs +419 -0
- package/dist/cjs/internal/encoding/index.cjs.map +10 -0
- package/dist/cjs/internal/fetch/consistency/origins.cjs +598 -0
- package/dist/cjs/internal/fetch/consistency/origins.cjs.map +10 -0
- package/dist/cjs/internal/fetch/index.cjs +2640 -0
- package/dist/cjs/internal/fetch/index.cjs.map +10 -0
- package/dist/cjs/internal/fetch/stream-state.cjs +256 -0
- package/dist/cjs/internal/fetch/stream-state.cjs.map +10 -0
- package/dist/cjs/internal/fs/index.cjs +847 -0
- package/dist/cjs/internal/fs/index.cjs.map +10 -0
- package/dist/cjs/internal/fs/node-adapter.cjs +254 -0
- package/dist/cjs/internal/fs/node-adapter.cjs.map +10 -0
- package/dist/cjs/internal/module-loader/bundle.cjs +482 -0
- package/dist/cjs/internal/module-loader/bundle.cjs.map +10 -0
- package/dist/cjs/internal/module-loader/index.cjs +240 -0
- package/dist/cjs/internal/module-loader/index.cjs.map +10 -0
- package/dist/cjs/internal/module-loader/mappings.cjs +120 -0
- package/dist/cjs/internal/module-loader/mappings.cjs.map +10 -0
- package/dist/cjs/internal/module-loader/resolve.cjs +177 -0
- package/dist/cjs/internal/module-loader/resolve.cjs.map +10 -0
- package/dist/cjs/internal/module-loader/strip-types.cjs +236 -0
- package/dist/cjs/internal/module-loader/strip-types.cjs.map +10 -0
- package/dist/cjs/internal/path/index.cjs +503 -0
- package/dist/cjs/internal/path/index.cjs.map +10 -0
- package/dist/cjs/internal/playwright/client.cjs +49 -0
- package/dist/cjs/internal/playwright/client.cjs.map +10 -0
- package/dist/cjs/internal/playwright/handler.cjs +1416 -0
- package/dist/cjs/internal/playwright/handler.cjs.map +10 -0
- package/dist/cjs/internal/playwright/index.cjs +1289 -0
- package/dist/cjs/internal/playwright/index.cjs.map +10 -0
- package/dist/cjs/internal/playwright/types.cjs +47 -0
- package/dist/cjs/internal/playwright/types.cjs.map +10 -0
- package/dist/cjs/internal/protocol/codec.cjs +510 -0
- package/dist/cjs/internal/protocol/codec.cjs.map +10 -0
- package/dist/cjs/internal/protocol/framing.cjs +141 -0
- package/dist/cjs/internal/protocol/framing.cjs.map +10 -0
- package/dist/cjs/internal/protocol/index.cjs +110 -0
- package/dist/cjs/internal/protocol/index.cjs.map +10 -0
- package/dist/cjs/internal/protocol/marshalValue.cjs +518 -0
- package/dist/cjs/internal/protocol/marshalValue.cjs.map +10 -0
- package/dist/cjs/internal/protocol/serialization.cjs +109 -0
- package/dist/cjs/internal/protocol/serialization.cjs.map +10 -0
- package/dist/cjs/internal/protocol/types.cjs +181 -0
- package/dist/cjs/internal/protocol/types.cjs.map +10 -0
- package/dist/cjs/internal/runtime/index.cjs +1235 -0
- package/dist/cjs/internal/runtime/index.cjs.map +10 -0
- package/dist/cjs/internal/server/index.cjs +223 -0
- package/dist/cjs/internal/server/index.cjs.map +10 -0
- package/dist/cjs/internal/test-environment/index.cjs +1415 -0
- package/dist/cjs/internal/test-environment/index.cjs.map +10 -0
- package/dist/cjs/internal/timers/index.cjs +200 -0
- package/dist/cjs/internal/timers/index.cjs.map +10 -0
- package/dist/cjs/internal/transform/index.cjs +361 -0
- package/dist/cjs/internal/transform/index.cjs.map +10 -0
- package/dist/cjs/internal/typecheck/index.cjs +60 -0
- package/dist/cjs/internal/typecheck/index.cjs.map +10 -0
- package/dist/cjs/internal/typecheck/isolate-types.cjs +2614 -0
- package/dist/cjs/internal/typecheck/isolate-types.cjs.map +10 -0
- package/dist/cjs/internal/typecheck/typecheck.cjs +131 -0
- package/dist/cjs/internal/typecheck/typecheck.cjs.map +10 -0
- package/dist/cjs/modules/index.cjs +160 -0
- package/dist/cjs/modules/index.cjs.map +10 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/runtime/script-runtime.cjs +97 -0
- package/dist/cjs/runtime/script-runtime.cjs.map +10 -0
- package/dist/cjs/server/app-server.cjs +158 -0
- package/dist/cjs/server/app-server.cjs.map +10 -0
- package/dist/cjs/testing/integration-helpers.cjs +127 -0
- package/dist/cjs/testing/integration-helpers.cjs.map +10 -0
- package/dist/cjs/typecheck/index.cjs +96 -0
- package/dist/cjs/typecheck/index.cjs.map +10 -0
- package/dist/cjs/types.cjs +30 -0
- package/dist/cjs/types.cjs.map +9 -0
- package/dist/mjs/bridge/diagnostics.mjs +18 -0
- package/dist/mjs/bridge/diagnostics.mjs.map +10 -0
- package/dist/mjs/bridge/legacy-adapters.mjs +178 -0
- package/dist/mjs/bridge/legacy-adapters.mjs.map +10 -0
- package/dist/mjs/bridge/request-context.mjs +19 -0
- package/dist/mjs/bridge/request-context.mjs.map +10 -0
- package/dist/mjs/bridge/runtime-bindings.mjs +303 -0
- package/dist/mjs/bridge/runtime-bindings.mjs.map +10 -0
- package/dist/mjs/browser/browser-runtime.mjs +93 -0
- package/dist/mjs/browser/browser-runtime.mjs.map +10 -0
- package/dist/mjs/daemon.mjs +91 -0
- package/dist/mjs/daemon.mjs.map +10 -0
- package/dist/mjs/files/index.mjs +76 -0
- package/dist/mjs/files/index.mjs.map +10 -0
- package/dist/mjs/host/create-isolate-host.mjs +171 -0
- package/dist/mjs/host/create-isolate-host.mjs.map +10 -0
- package/dist/mjs/host/index.mjs +7 -0
- package/dist/mjs/host/index.mjs.map +10 -0
- package/dist/mjs/index.mjs +15 -0
- package/dist/mjs/index.mjs.map +10 -0
- package/dist/mjs/internal/client/connection.mjs +1872 -0
- package/dist/mjs/internal/client/connection.mjs.map +10 -0
- package/dist/mjs/internal/client/index.mjs +8 -0
- package/dist/mjs/internal/client/index.mjs.map +10 -0
- package/dist/mjs/internal/client/types.mjs +2 -0
- package/dist/mjs/internal/client/types.mjs.map +9 -0
- package/dist/mjs/internal/console/index.mjs +442 -0
- package/dist/mjs/internal/console/index.mjs.map +10 -0
- package/dist/mjs/internal/console/utils.mjs +30 -0
- package/dist/mjs/internal/console/utils.mjs.map +10 -0
- package/dist/mjs/internal/core/index.mjs +2681 -0
- package/dist/mjs/internal/core/index.mjs.map +10 -0
- package/dist/mjs/internal/crypto/index.mjs +406 -0
- package/dist/mjs/internal/crypto/index.mjs.map +10 -0
- package/dist/mjs/internal/daemon/callback-fs-handler.mjs +315 -0
- package/dist/mjs/internal/daemon/callback-fs-handler.mjs.map +10 -0
- package/dist/mjs/internal/daemon/connection.mjs +1931 -0
- package/dist/mjs/internal/daemon/connection.mjs.map +10 -0
- package/dist/mjs/internal/daemon/daemon.mjs +98 -0
- package/dist/mjs/internal/daemon/daemon.mjs.map +10 -0
- package/dist/mjs/internal/daemon/index.mjs +105 -0
- package/dist/mjs/internal/daemon/index.mjs.map +10 -0
- package/dist/mjs/internal/daemon/runtime-pool.mjs +66 -0
- package/dist/mjs/internal/daemon/runtime-pool.mjs.map +10 -0
- package/dist/mjs/internal/daemon/types.mjs +2 -0
- package/dist/mjs/internal/daemon/types.mjs.map +9 -0
- package/dist/mjs/internal/encoding/index.mjs +379 -0
- package/dist/mjs/internal/encoding/index.mjs.map +10 -0
- package/dist/mjs/internal/fetch/consistency/origins.mjs +558 -0
- package/dist/mjs/internal/fetch/consistency/origins.mjs.map +10 -0
- package/dist/mjs/internal/fetch/index.mjs +2580 -0
- package/dist/mjs/internal/fetch/index.mjs.map +10 -0
- package/dist/mjs/internal/fetch/stream-state.mjs +216 -0
- package/dist/mjs/internal/fetch/stream-state.mjs.map +10 -0
- package/dist/mjs/internal/fs/index.mjs +783 -0
- package/dist/mjs/internal/fs/index.mjs.map +10 -0
- package/dist/mjs/internal/fs/node-adapter.mjs +190 -0
- package/dist/mjs/internal/fs/node-adapter.mjs.map +10 -0
- package/dist/mjs/internal/module-loader/bundle.mjs +418 -0
- package/dist/mjs/internal/module-loader/bundle.mjs.map +10 -0
- package/dist/mjs/internal/module-loader/index.mjs +185 -0
- package/dist/mjs/internal/module-loader/index.mjs.map +10 -0
- package/dist/mjs/internal/module-loader/mappings.mjs +80 -0
- package/dist/mjs/internal/module-loader/mappings.mjs.map +10 -0
- package/dist/mjs/internal/module-loader/resolve.mjs +113 -0
- package/dist/mjs/internal/module-loader/resolve.mjs.map +10 -0
- package/dist/mjs/internal/module-loader/strip-types.mjs +172 -0
- package/dist/mjs/internal/module-loader/strip-types.mjs.map +10 -0
- package/dist/mjs/internal/path/index.mjs +463 -0
- package/dist/mjs/internal/path/index.mjs.map +10 -0
- package/dist/mjs/internal/playwright/client.mjs +13 -0
- package/dist/mjs/internal/playwright/client.mjs.map +10 -0
- package/dist/mjs/internal/playwright/handler.mjs +1378 -0
- package/dist/mjs/internal/playwright/handler.mjs.map +10 -0
- package/dist/mjs/internal/playwright/index.mjs +1234 -0
- package/dist/mjs/internal/playwright/index.mjs.map +10 -0
- package/dist/mjs/internal/playwright/types.mjs +7 -0
- package/dist/mjs/internal/playwright/types.mjs.map +10 -0
- package/dist/mjs/internal/protocol/codec.mjs +470 -0
- package/dist/mjs/internal/protocol/codec.mjs.map +10 -0
- package/dist/mjs/internal/protocol/framing.mjs +101 -0
- package/dist/mjs/internal/protocol/framing.mjs.map +10 -0
- package/dist/mjs/internal/protocol/index.mjs +98 -0
- package/dist/mjs/internal/protocol/index.mjs.map +10 -0
- package/dist/mjs/internal/protocol/marshalValue.mjs +494 -0
- package/dist/mjs/internal/protocol/marshalValue.mjs.map +10 -0
- package/dist/mjs/internal/protocol/serialization.mjs +69 -0
- package/dist/mjs/internal/protocol/serialization.mjs.map +10 -0
- package/dist/mjs/internal/protocol/types.mjs +141 -0
- package/dist/mjs/internal/protocol/types.mjs.map +10 -0
- package/dist/mjs/internal/runtime/index.mjs +1198 -0
- package/dist/mjs/internal/runtime/index.mjs.map +10 -0
- package/dist/mjs/internal/server/index.mjs +183 -0
- package/dist/mjs/internal/server/index.mjs.map +10 -0
- package/dist/mjs/internal/test-environment/index.mjs +1351 -0
- package/dist/mjs/internal/test-environment/index.mjs.map +10 -0
- package/dist/mjs/internal/timers/index.mjs +136 -0
- package/dist/mjs/internal/timers/index.mjs.map +10 -0
- package/dist/mjs/internal/transform/index.mjs +321 -0
- package/dist/mjs/internal/transform/index.mjs.map +10 -0
- package/dist/mjs/internal/typecheck/index.mjs +35 -0
- package/dist/mjs/internal/typecheck/index.mjs.map +10 -0
- package/dist/mjs/internal/typecheck/isolate-types.mjs +2574 -0
- package/dist/mjs/internal/typecheck/isolate-types.mjs.map +10 -0
- package/dist/mjs/internal/typecheck/typecheck.mjs +91 -0
- package/dist/mjs/internal/typecheck/typecheck.mjs.map +10 -0
- package/dist/mjs/modules/index.mjs +96 -0
- package/dist/mjs/modules/index.mjs.map +10 -0
- package/dist/mjs/package.json +5 -0
- package/dist/mjs/runtime/script-runtime.mjs +57 -0
- package/dist/mjs/runtime/script-runtime.mjs.map +10 -0
- package/dist/mjs/server/app-server.mjs +118 -0
- package/dist/mjs/server/app-server.mjs.map +10 -0
- package/dist/mjs/testing/integration-helpers.mjs +63 -0
- package/dist/mjs/testing/integration-helpers.mjs.map +10 -0
- package/dist/mjs/typecheck/index.mjs +56 -0
- package/dist/mjs/typecheck/index.mjs.map +10 -0
- package/dist/mjs/types.mjs +2 -0
- package/dist/mjs/types.mjs.map +9 -0
- package/dist/types/bridge/diagnostics.d.ts +12 -0
- package/dist/types/bridge/legacy-adapters.d.ts +14 -0
- package/dist/types/bridge/request-context.d.ts +10 -0
- package/dist/types/bridge/runtime-bindings.d.ts +14 -0
- package/dist/types/browser/browser-runtime.d.ts +3 -0
- package/dist/types/daemon.d.ts +2 -0
- package/dist/types/files/index.d.ts +5 -0
- package/dist/types/host/create-isolate-host.d.ts +2 -0
- package/dist/types/host/index.d.ts +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/internal/client/connection.d.ts +9 -0
- package/dist/types/internal/client/index.d.ts +8 -0
- package/dist/types/internal/client/types.d.ts +198 -0
- package/dist/types/internal/console/index.d.ts +108 -0
- package/dist/types/internal/console/utils.d.ts +27 -0
- package/dist/types/internal/core/index.d.ts +119 -0
- package/dist/types/internal/crypto/index.d.ts +18 -0
- package/dist/types/internal/daemon/callback-fs-handler.d.ts +28 -0
- package/dist/types/internal/daemon/connection.d.ts +9 -0
- package/dist/types/internal/daemon/daemon.d.ts +2 -0
- package/dist/types/internal/daemon/index.d.ts +14 -0
- package/dist/types/internal/daemon/runtime-pool.d.ts +16 -0
- package/dist/types/internal/daemon/types.d.ts +211 -0
- package/dist/types/internal/encoding/index.d.ts +21 -0
- package/dist/types/internal/fetch/consistency/origins.d.ts +179 -0
- package/dist/types/internal/fetch/index.d.ts +93 -0
- package/dist/types/internal/fetch/stream-state.d.ts +65 -0
- package/dist/types/internal/fs/index.d.ts +70 -0
- package/dist/types/internal/fs/node-adapter.d.ts +24 -0
- package/dist/types/internal/module-loader/bundle.d.ts +33 -0
- package/dist/types/internal/module-loader/index.d.ts +30 -0
- package/dist/types/internal/module-loader/mappings.d.ts +47 -0
- package/dist/types/internal/module-loader/resolve.d.ts +26 -0
- package/dist/types/internal/module-loader/strip-types.d.ts +19 -0
- package/dist/types/internal/path/index.d.ts +23 -0
- package/dist/types/internal/playwright/client.d.ts +7 -0
- package/dist/types/internal/playwright/handler.d.ts +44 -0
- package/dist/types/internal/playwright/index.d.ts +14 -0
- package/dist/types/internal/playwright/types.d.ts +145 -0
- package/dist/types/internal/protocol/codec.d.ts +242 -0
- package/dist/types/internal/protocol/framing.d.ts +89 -0
- package/dist/types/internal/protocol/index.d.ts +10 -0
- package/dist/types/internal/protocol/marshalValue.d.ts +79 -0
- package/dist/types/internal/protocol/serialization.d.ts +23 -0
- package/dist/types/internal/protocol/types.d.ts +996 -0
- package/dist/types/internal/runtime/index.d.ts +200 -0
- package/dist/types/internal/server/index.d.ts +42 -0
- package/dist/types/internal/test-environment/index.d.ts +112 -0
- package/dist/types/internal/timers/index.d.ts +22 -0
- package/dist/types/internal/transform/index.d.ts +36 -0
- package/dist/types/internal/typecheck/index.d.ts +7 -0
- package/dist/types/internal/typecheck/isolate-types.d.ts +94 -0
- package/dist/types/internal/typecheck/typecheck.d.ts +148 -0
- package/dist/types/modules/index.d.ts +2 -0
- package/dist/types/runtime/script-runtime.d.ts +6 -0
- package/dist/types/server/app-server.d.ts +3 -0
- package/dist/types/testing/integration-helpers.d.ts +9 -0
- package/dist/types/typecheck/index.d.ts +8 -0
- package/dist/types/types.d.ts +233 -0
- package/package.json +74 -6
- package/README.md +0 -45
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
__moduleCache.set(from, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, {
|
|
32
|
+
get: all[name],
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// packages/isolate/src/internal/path/index.ts
|
|
40
|
+
var exports_path = {};
|
|
41
|
+
__export(exports_path, {
|
|
42
|
+
setupPath: () => setupPath
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(exports_path);
|
|
45
|
+
function generatePathCode(cwd) {
|
|
46
|
+
return `
|
|
47
|
+
(function() {
|
|
48
|
+
const sep = '/';
|
|
49
|
+
const delimiter = ':';
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Normalize a path by resolving '.' and '..' segments and removing redundant separators
|
|
53
|
+
*/
|
|
54
|
+
function normalize(p) {
|
|
55
|
+
if (typeof p !== 'string') {
|
|
56
|
+
throw new TypeError('Path must be a string. Received ' + typeof p);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (p.length === 0) {
|
|
60
|
+
return '.';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const isAbsolutePath = p.charCodeAt(0) === 47; // '/'
|
|
64
|
+
const trailingSlash = p.charCodeAt(p.length - 1) === 47; // '/'
|
|
65
|
+
|
|
66
|
+
// Split by separator and filter empty segments
|
|
67
|
+
const segments = p.split('/');
|
|
68
|
+
const result = [];
|
|
69
|
+
|
|
70
|
+
for (let i = 0; i < segments.length; i++) {
|
|
71
|
+
const segment = segments[i];
|
|
72
|
+
|
|
73
|
+
// Skip empty segments (from consecutive slashes) and '.'
|
|
74
|
+
if (segment === '' || segment === '.') {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (segment === '..') {
|
|
79
|
+
// For absolute paths, don't go above root
|
|
80
|
+
// For relative paths, keep '..' if we can't go up further
|
|
81
|
+
if (result.length > 0 && result[result.length - 1] !== '..') {
|
|
82
|
+
result.pop();
|
|
83
|
+
} else if (!isAbsolutePath) {
|
|
84
|
+
result.push('..');
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
result.push(segment);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let normalized = result.join('/');
|
|
92
|
+
|
|
93
|
+
if (isAbsolutePath) {
|
|
94
|
+
normalized = '/' + normalized;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (trailingSlash && normalized.length > 1 && !normalized.endsWith('/')) {
|
|
98
|
+
normalized += '/';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!normalized) {
|
|
102
|
+
return isAbsolutePath ? '/' : '.';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return normalized;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Join path segments together and normalize the result
|
|
110
|
+
*/
|
|
111
|
+
function join(...segments) {
|
|
112
|
+
if (segments.length === 0) {
|
|
113
|
+
return '.';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
let joined = '';
|
|
117
|
+
for (let i = 0; i < segments.length; i++) {
|
|
118
|
+
const segment = segments[i];
|
|
119
|
+
if (typeof segment !== 'string') {
|
|
120
|
+
throw new TypeError('Path must be a string. Received ' + typeof segment);
|
|
121
|
+
}
|
|
122
|
+
if (segment.length > 0) {
|
|
123
|
+
if (joined.length === 0) {
|
|
124
|
+
joined = segment;
|
|
125
|
+
} else {
|
|
126
|
+
joined += '/' + segment;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (joined.length === 0) {
|
|
132
|
+
return '.';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return normalize(joined);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Get the directory name of a path
|
|
140
|
+
*/
|
|
141
|
+
function dirname(p) {
|
|
142
|
+
if (typeof p !== 'string') {
|
|
143
|
+
throw new TypeError('Path must be a string. Received ' + typeof p);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (p.length === 0) {
|
|
147
|
+
return '.';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const isAbsolutePath = p.charCodeAt(0) === 47;
|
|
151
|
+
let end = -1;
|
|
152
|
+
let matchedSlash = true;
|
|
153
|
+
|
|
154
|
+
for (let i = p.length - 1; i >= 1; i--) {
|
|
155
|
+
if (p.charCodeAt(i) === 47) {
|
|
156
|
+
if (!matchedSlash) {
|
|
157
|
+
end = i;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
matchedSlash = false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (end === -1) {
|
|
166
|
+
return isAbsolutePath ? '/' : '.';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (isAbsolutePath && end === 1) {
|
|
170
|
+
return '/';
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return p.slice(0, end);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Get the last portion of a path, optionally removing a suffix
|
|
178
|
+
*/
|
|
179
|
+
function basename(p, ext) {
|
|
180
|
+
if (typeof p !== 'string') {
|
|
181
|
+
throw new TypeError('Path must be a string. Received ' + typeof p);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (ext !== undefined && typeof ext !== 'string') {
|
|
185
|
+
throw new TypeError('ext must be a string');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
let start = 0;
|
|
189
|
+
let end = -1;
|
|
190
|
+
let matchedSlash = true;
|
|
191
|
+
|
|
192
|
+
for (let i = p.length - 1; i >= 0; i--) {
|
|
193
|
+
if (p.charCodeAt(i) === 47) {
|
|
194
|
+
if (!matchedSlash) {
|
|
195
|
+
start = i + 1;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
if (matchedSlash) {
|
|
200
|
+
end = i + 1;
|
|
201
|
+
matchedSlash = false;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (end === -1) {
|
|
207
|
+
return '';
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const base = p.slice(start, end);
|
|
211
|
+
|
|
212
|
+
if (ext !== undefined && base.endsWith(ext)) {
|
|
213
|
+
return base.slice(0, base.length - ext.length);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return base;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Get the extension of a path
|
|
221
|
+
*/
|
|
222
|
+
function extname(p) {
|
|
223
|
+
if (typeof p !== 'string') {
|
|
224
|
+
throw new TypeError('Path must be a string. Received ' + typeof p);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
let startDot = -1;
|
|
228
|
+
let startPart = 0;
|
|
229
|
+
let end = -1;
|
|
230
|
+
let matchedSlash = true;
|
|
231
|
+
let preDotState = 0;
|
|
232
|
+
|
|
233
|
+
for (let i = p.length - 1; i >= 0; i--) {
|
|
234
|
+
const code = p.charCodeAt(i);
|
|
235
|
+
if (code === 47) {
|
|
236
|
+
if (!matchedSlash) {
|
|
237
|
+
startPart = i + 1;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (end === -1) {
|
|
244
|
+
matchedSlash = false;
|
|
245
|
+
end = i + 1;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (code === 46) { // '.'
|
|
249
|
+
if (startDot === -1) {
|
|
250
|
+
startDot = i;
|
|
251
|
+
} else if (preDotState !== 1) {
|
|
252
|
+
preDotState = 1;
|
|
253
|
+
}
|
|
254
|
+
} else if (startDot !== -1) {
|
|
255
|
+
preDotState = -1;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (startDot === -1 || end === -1 ||
|
|
260
|
+
preDotState === 0 ||
|
|
261
|
+
(preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
|
|
262
|
+
return '';
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return p.slice(startDot, end);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Check if a path is absolute
|
|
270
|
+
*/
|
|
271
|
+
function isAbsolute(p) {
|
|
272
|
+
if (typeof p !== 'string') {
|
|
273
|
+
throw new TypeError('Path must be a string. Received ' + typeof p);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return p.length > 0 && p.charCodeAt(0) === 47;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Resolve a sequence of paths to an absolute path
|
|
281
|
+
*/
|
|
282
|
+
function resolve(...segments) {
|
|
283
|
+
let resolvedPath = '';
|
|
284
|
+
let resolvedAbsolute = false;
|
|
285
|
+
|
|
286
|
+
for (let i = segments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
287
|
+
let path;
|
|
288
|
+
if (i >= 0) {
|
|
289
|
+
path = segments[i];
|
|
290
|
+
if (typeof path !== 'string') {
|
|
291
|
+
throw new TypeError('Path must be a string. Received ' + typeof path);
|
|
292
|
+
}
|
|
293
|
+
} else {
|
|
294
|
+
// Use configured cwd
|
|
295
|
+
path = ${JSON.stringify(cwd)};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (path.length === 0) {
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (resolvedPath.length > 0) {
|
|
303
|
+
resolvedPath = path + '/' + resolvedPath;
|
|
304
|
+
} else {
|
|
305
|
+
resolvedPath = path;
|
|
306
|
+
}
|
|
307
|
+
resolvedAbsolute = path.charCodeAt(0) === 47;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
resolvedPath = normalize(resolvedPath);
|
|
311
|
+
|
|
312
|
+
// Remove trailing slash unless it's just root
|
|
313
|
+
if (resolvedPath.length > 1 && resolvedPath.endsWith('/')) {
|
|
314
|
+
resolvedPath = resolvedPath.slice(0, -1);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (resolvedAbsolute) {
|
|
318
|
+
return resolvedPath.length > 0 ? resolvedPath : '/';
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return resolvedPath.length > 0 ? resolvedPath : '.';
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Get the relative path from 'from' to 'to'
|
|
326
|
+
*/
|
|
327
|
+
function relative(from, to) {
|
|
328
|
+
if (typeof from !== 'string') {
|
|
329
|
+
throw new TypeError('Path must be a string. Received ' + typeof from);
|
|
330
|
+
}
|
|
331
|
+
if (typeof to !== 'string') {
|
|
332
|
+
throw new TypeError('Path must be a string. Received ' + typeof to);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (from === to) {
|
|
336
|
+
return '';
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
from = resolve(from);
|
|
340
|
+
to = resolve(to);
|
|
341
|
+
|
|
342
|
+
if (from === to) {
|
|
343
|
+
return '';
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const fromParts = from.split('/').filter(Boolean);
|
|
347
|
+
const toParts = to.split('/').filter(Boolean);
|
|
348
|
+
|
|
349
|
+
// Find common prefix
|
|
350
|
+
let commonLength = 0;
|
|
351
|
+
const minLength = Math.min(fromParts.length, toParts.length);
|
|
352
|
+
for (let i = 0; i < minLength; i++) {
|
|
353
|
+
if (fromParts[i] !== toParts[i]) {
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
commonLength++;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// Build relative path
|
|
360
|
+
const upCount = fromParts.length - commonLength;
|
|
361
|
+
const result = [];
|
|
362
|
+
|
|
363
|
+
for (let i = 0; i < upCount; i++) {
|
|
364
|
+
result.push('..');
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
for (let i = commonLength; i < toParts.length; i++) {
|
|
368
|
+
result.push(toParts[i]);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
return result.join('/');
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Parse a path into its components
|
|
376
|
+
*/
|
|
377
|
+
function parse(p) {
|
|
378
|
+
if (typeof p !== 'string') {
|
|
379
|
+
throw new TypeError('Path must be a string. Received ' + typeof p);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const ret = { root: '', dir: '', base: '', ext: '', name: '' };
|
|
383
|
+
|
|
384
|
+
if (p.length === 0) {
|
|
385
|
+
return ret;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const isAbsolutePath = p.charCodeAt(0) === 47;
|
|
389
|
+
if (isAbsolutePath) {
|
|
390
|
+
ret.root = '/';
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
let start = isAbsolutePath ? 1 : 0;
|
|
394
|
+
let end = -1;
|
|
395
|
+
let matchedSlash = true;
|
|
396
|
+
let startDot = -1;
|
|
397
|
+
let preDotState = 0;
|
|
398
|
+
|
|
399
|
+
// Get base and dir
|
|
400
|
+
for (let i = p.length - 1; i >= start; i--) {
|
|
401
|
+
const code = p.charCodeAt(i);
|
|
402
|
+
if (code === 47) {
|
|
403
|
+
if (!matchedSlash) {
|
|
404
|
+
start = i + 1;
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
} else {
|
|
408
|
+
if (matchedSlash) {
|
|
409
|
+
end = i + 1;
|
|
410
|
+
matchedSlash = false;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (code === 46) { // '.'
|
|
414
|
+
if (startDot === -1) {
|
|
415
|
+
startDot = i;
|
|
416
|
+
} else if (preDotState !== 1) {
|
|
417
|
+
preDotState = 1;
|
|
418
|
+
}
|
|
419
|
+
} else if (startDot !== -1) {
|
|
420
|
+
preDotState = -1;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (end !== -1) {
|
|
426
|
+
ret.base = p.slice(start, end);
|
|
427
|
+
|
|
428
|
+
// Determine extension
|
|
429
|
+
if (startDot !== -1 && startDot >= start &&
|
|
430
|
+
preDotState !== 0 &&
|
|
431
|
+
!(preDotState === 1 && startDot === end - 1 && startDot === start + 1)) {
|
|
432
|
+
ret.ext = p.slice(startDot, end);
|
|
433
|
+
ret.name = p.slice(start, startDot);
|
|
434
|
+
} else {
|
|
435
|
+
ret.name = ret.base;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
if (start > (isAbsolutePath ? 1 : 0)) {
|
|
440
|
+
ret.dir = p.slice(0, start - 1);
|
|
441
|
+
} else if (isAbsolutePath) {
|
|
442
|
+
ret.dir = '/';
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return ret;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Format a path object into a path string
|
|
450
|
+
*/
|
|
451
|
+
function format(pathObject) {
|
|
452
|
+
if (pathObject === null || typeof pathObject !== 'object') {
|
|
453
|
+
throw new TypeError("Parameter 'pathObject' must be an object, not " + typeof pathObject);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const dir = pathObject.dir || pathObject.root || '';
|
|
457
|
+
const base = pathObject.base ||
|
|
458
|
+
((pathObject.name || '') + (pathObject.ext || ''));
|
|
459
|
+
|
|
460
|
+
if (!dir) {
|
|
461
|
+
return base;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
if (dir === pathObject.root) {
|
|
465
|
+
return dir + base;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
return dir + '/' + base;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Create path object with posix namespace (for compatibility)
|
|
472
|
+
const pathModule = {
|
|
473
|
+
sep,
|
|
474
|
+
delimiter,
|
|
475
|
+
normalize,
|
|
476
|
+
join,
|
|
477
|
+
dirname,
|
|
478
|
+
basename,
|
|
479
|
+
extname,
|
|
480
|
+
isAbsolute,
|
|
481
|
+
resolve,
|
|
482
|
+
relative,
|
|
483
|
+
parse,
|
|
484
|
+
format,
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
// posix is the same as the main module since we only support POSIX
|
|
488
|
+
pathModule.posix = pathModule;
|
|
489
|
+
|
|
490
|
+
globalThis.path = pathModule;
|
|
491
|
+
})();
|
|
492
|
+
`;
|
|
493
|
+
}
|
|
494
|
+
async function setupPath(context, options) {
|
|
495
|
+
const cwd = options?.cwd ?? "/";
|
|
496
|
+
const pathCode = generatePathCode(cwd);
|
|
497
|
+
context.evalSync(pathCode);
|
|
498
|
+
return {
|
|
499
|
+
dispose() {}
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
//# debugId=0DA9EC853B8DE97064756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/internal/path/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type ivm from \"isolated-vm\";\n\nexport interface PathOptions {\n /** Current working directory for path.resolve(). Defaults to \"/\" */\n cwd?: string;\n}\n\nexport interface PathHandle {\n dispose(): void;\n}\n\n/**\n * Generate the path module code with optional cwd configuration.\n */\nfunction generatePathCode(cwd: string): string {\n return `\n(function() {\n const sep = '/';\n const delimiter = ':';\n\n /**\n * Normalize a path by resolving '.' and '..' segments and removing redundant separators\n */\n function normalize(p) {\n if (typeof p !== 'string') {\n throw new TypeError('Path must be a string. Received ' + typeof p);\n }\n\n if (p.length === 0) {\n return '.';\n }\n\n const isAbsolutePath = p.charCodeAt(0) === 47; // '/'\n const trailingSlash = p.charCodeAt(p.length - 1) === 47; // '/'\n\n // Split by separator and filter empty segments\n const segments = p.split('/');\n const result = [];\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n\n // Skip empty segments (from consecutive slashes) and '.'\n if (segment === '' || segment === '.') {\n continue;\n }\n\n if (segment === '..') {\n // For absolute paths, don't go above root\n // For relative paths, keep '..' if we can't go up further\n if (result.length > 0 && result[result.length - 1] !== '..') {\n result.pop();\n } else if (!isAbsolutePath) {\n result.push('..');\n }\n } else {\n result.push(segment);\n }\n }\n\n let normalized = result.join('/');\n\n if (isAbsolutePath) {\n normalized = '/' + normalized;\n }\n\n if (trailingSlash && normalized.length > 1 && !normalized.endsWith('/')) {\n normalized += '/';\n }\n\n if (!normalized) {\n return isAbsolutePath ? '/' : '.';\n }\n\n return normalized;\n }\n\n /**\n * Join path segments together and normalize the result\n */\n function join(...segments) {\n if (segments.length === 0) {\n return '.';\n }\n\n let joined = '';\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n if (typeof segment !== 'string') {\n throw new TypeError('Path must be a string. Received ' + typeof segment);\n }\n if (segment.length > 0) {\n if (joined.length === 0) {\n joined = segment;\n } else {\n joined += '/' + segment;\n }\n }\n }\n\n if (joined.length === 0) {\n return '.';\n }\n\n return normalize(joined);\n }\n\n /**\n * Get the directory name of a path\n */\n function dirname(p) {\n if (typeof p !== 'string') {\n throw new TypeError('Path must be a string. Received ' + typeof p);\n }\n\n if (p.length === 0) {\n return '.';\n }\n\n const isAbsolutePath = p.charCodeAt(0) === 47;\n let end = -1;\n let matchedSlash = true;\n\n for (let i = p.length - 1; i >= 1; i--) {\n if (p.charCodeAt(i) === 47) {\n if (!matchedSlash) {\n end = i;\n break;\n }\n } else {\n matchedSlash = false;\n }\n }\n\n if (end === -1) {\n return isAbsolutePath ? '/' : '.';\n }\n\n if (isAbsolutePath && end === 1) {\n return '/';\n }\n\n return p.slice(0, end);\n }\n\n /**\n * Get the last portion of a path, optionally removing a suffix\n */\n function basename(p, ext) {\n if (typeof p !== 'string') {\n throw new TypeError('Path must be a string. Received ' + typeof p);\n }\n\n if (ext !== undefined && typeof ext !== 'string') {\n throw new TypeError('ext must be a string');\n }\n\n let start = 0;\n let end = -1;\n let matchedSlash = true;\n\n for (let i = p.length - 1; i >= 0; i--) {\n if (p.charCodeAt(i) === 47) {\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else {\n if (matchedSlash) {\n end = i + 1;\n matchedSlash = false;\n }\n }\n }\n\n if (end === -1) {\n return '';\n }\n\n const base = p.slice(start, end);\n\n if (ext !== undefined && base.endsWith(ext)) {\n return base.slice(0, base.length - ext.length);\n }\n\n return base;\n }\n\n /**\n * Get the extension of a path\n */\n function extname(p) {\n if (typeof p !== 'string') {\n throw new TypeError('Path must be a string. Received ' + typeof p);\n }\n\n let startDot = -1;\n let startPart = 0;\n let end = -1;\n let matchedSlash = true;\n let preDotState = 0;\n\n for (let i = p.length - 1; i >= 0; i--) {\n const code = p.charCodeAt(i);\n if (code === 47) {\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n\n if (end === -1) {\n matchedSlash = false;\n end = i + 1;\n }\n\n if (code === 46) { // '.'\n if (startDot === -1) {\n startDot = i;\n } else if (preDotState !== 1) {\n preDotState = 1;\n }\n } else if (startDot !== -1) {\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n preDotState === 0 ||\n (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {\n return '';\n }\n\n return p.slice(startDot, end);\n }\n\n /**\n * Check if a path is absolute\n */\n function isAbsolute(p) {\n if (typeof p !== 'string') {\n throw new TypeError('Path must be a string. Received ' + typeof p);\n }\n\n return p.length > 0 && p.charCodeAt(0) === 47;\n }\n\n /**\n * Resolve a sequence of paths to an absolute path\n */\n function resolve(...segments) {\n let resolvedPath = '';\n let resolvedAbsolute = false;\n\n for (let i = segments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n let path;\n if (i >= 0) {\n path = segments[i];\n if (typeof path !== 'string') {\n throw new TypeError('Path must be a string. Received ' + typeof path);\n }\n } else {\n // Use configured cwd\n path = ${JSON.stringify(cwd)};\n }\n\n if (path.length === 0) {\n continue;\n }\n\n if (resolvedPath.length > 0) {\n resolvedPath = path + '/' + resolvedPath;\n } else {\n resolvedPath = path;\n }\n resolvedAbsolute = path.charCodeAt(0) === 47;\n }\n\n resolvedPath = normalize(resolvedPath);\n\n // Remove trailing slash unless it's just root\n if (resolvedPath.length > 1 && resolvedPath.endsWith('/')) {\n resolvedPath = resolvedPath.slice(0, -1);\n }\n\n if (resolvedAbsolute) {\n return resolvedPath.length > 0 ? resolvedPath : '/';\n }\n\n return resolvedPath.length > 0 ? resolvedPath : '.';\n }\n\n /**\n * Get the relative path from 'from' to 'to'\n */\n function relative(from, to) {\n if (typeof from !== 'string') {\n throw new TypeError('Path must be a string. Received ' + typeof from);\n }\n if (typeof to !== 'string') {\n throw new TypeError('Path must be a string. Received ' + typeof to);\n }\n\n if (from === to) {\n return '';\n }\n\n from = resolve(from);\n to = resolve(to);\n\n if (from === to) {\n return '';\n }\n\n const fromParts = from.split('/').filter(Boolean);\n const toParts = to.split('/').filter(Boolean);\n\n // Find common prefix\n let commonLength = 0;\n const minLength = Math.min(fromParts.length, toParts.length);\n for (let i = 0; i < minLength; i++) {\n if (fromParts[i] !== toParts[i]) {\n break;\n }\n commonLength++;\n }\n\n // Build relative path\n const upCount = fromParts.length - commonLength;\n const result = [];\n\n for (let i = 0; i < upCount; i++) {\n result.push('..');\n }\n\n for (let i = commonLength; i < toParts.length; i++) {\n result.push(toParts[i]);\n }\n\n return result.join('/');\n }\n\n /**\n * Parse a path into its components\n */\n function parse(p) {\n if (typeof p !== 'string') {\n throw new TypeError('Path must be a string. Received ' + typeof p);\n }\n\n const ret = { root: '', dir: '', base: '', ext: '', name: '' };\n\n if (p.length === 0) {\n return ret;\n }\n\n const isAbsolutePath = p.charCodeAt(0) === 47;\n if (isAbsolutePath) {\n ret.root = '/';\n }\n\n let start = isAbsolutePath ? 1 : 0;\n let end = -1;\n let matchedSlash = true;\n let startDot = -1;\n let preDotState = 0;\n\n // Get base and dir\n for (let i = p.length - 1; i >= start; i--) {\n const code = p.charCodeAt(i);\n if (code === 47) {\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else {\n if (matchedSlash) {\n end = i + 1;\n matchedSlash = false;\n }\n\n if (code === 46) { // '.'\n if (startDot === -1) {\n startDot = i;\n } else if (preDotState !== 1) {\n preDotState = 1;\n }\n } else if (startDot !== -1) {\n preDotState = -1;\n }\n }\n }\n\n if (end !== -1) {\n ret.base = p.slice(start, end);\n\n // Determine extension\n if (startDot !== -1 && startDot >= start &&\n preDotState !== 0 &&\n !(preDotState === 1 && startDot === end - 1 && startDot === start + 1)) {\n ret.ext = p.slice(startDot, end);\n ret.name = p.slice(start, startDot);\n } else {\n ret.name = ret.base;\n }\n }\n\n if (start > (isAbsolutePath ? 1 : 0)) {\n ret.dir = p.slice(0, start - 1);\n } else if (isAbsolutePath) {\n ret.dir = '/';\n }\n\n return ret;\n }\n\n /**\n * Format a path object into a path string\n */\n function format(pathObject) {\n if (pathObject === null || typeof pathObject !== 'object') {\n throw new TypeError(\"Parameter 'pathObject' must be an object, not \" + typeof pathObject);\n }\n\n const dir = pathObject.dir || pathObject.root || '';\n const base = pathObject.base ||\n ((pathObject.name || '') + (pathObject.ext || ''));\n\n if (!dir) {\n return base;\n }\n\n if (dir === pathObject.root) {\n return dir + base;\n }\n\n return dir + '/' + base;\n }\n\n // Create path object with posix namespace (for compatibility)\n const pathModule = {\n sep,\n delimiter,\n normalize,\n join,\n dirname,\n basename,\n extname,\n isAbsolute,\n resolve,\n relative,\n parse,\n format,\n };\n\n // posix is the same as the main module since we only support POSIX\n pathModule.posix = pathModule;\n\n globalThis.path = pathModule;\n})();\n`;\n}\n\n/**\n * Setup path utilities in an isolated-vm context\n *\n * Provides path manipulation utilities similar to Node.js path module\n * Uses POSIX-style paths only (always uses '/' as separator)\n *\n * @example\n * const handle = await setupPath(context, { cwd: \"/home/user\" });\n * await context.eval(\\`\n * const joined = path.join(\"/foo\", \"bar\", \"baz\");\n * const dir = path.dirname(\"/foo/bar/baz.txt\");\n * const resolved = path.resolve(\"relative\"); // Uses configured cwd\n * \\`);\n */\nexport async function setupPath(\n context: ivm.Context,\n options?: PathOptions\n): Promise<PathHandle> {\n const cwd = options?.cwd ?? \"/\";\n const pathCode = generatePathCode(cwd);\n context.evalSync(pathCode);\n return {\n dispose() {\n // No resources to cleanup for pure JS injection\n },\n };\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,gBAAgB,CAAC,KAAqB;AAAA,EAC7C,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAyPQ,KAAK,UAAU,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsNnC,eAAsB,SAAS,CAC7B,SACA,SACqB;AAAA,EACrB,MAAM,MAAM,SAAS,OAAO;AAAA,EAC5B,MAAM,WAAW,iBAAiB,GAAG;AAAA,EACrC,QAAQ,SAAS,QAAQ;AAAA,EACzB,OAAO;AAAA,IACL,OAAO,GAAG;AAAA,EAGZ;AAAA;",
|
|
8
|
+
"debugId": "0DA9EC853B8DE97064756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
__moduleCache.set(from, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, {
|
|
32
|
+
get: all[name],
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// packages/isolate/src/internal/playwright/client.ts
|
|
40
|
+
var exports_client = {};
|
|
41
|
+
__export(exports_client, {
|
|
42
|
+
getDefaultPlaywrightHandlerMetadata: () => import_handler.getDefaultPlaywrightHandlerMetadata,
|
|
43
|
+
defaultPlaywrightHandler: () => import_handler.defaultPlaywrightHandler,
|
|
44
|
+
createPlaywrightHandler: () => import_handler.createPlaywrightHandler
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(exports_client);
|
|
47
|
+
var import_handler = require("./handler.cjs");
|
|
48
|
+
|
|
49
|
+
//# debugId=29BE6FB5E46FEB4164756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/internal/playwright/client.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Client-safe exports for ./index.ts\n * This module can be imported without loading isolated-vm\n */\n\n// Re-export types from types.ts\nexport type {\n NetworkRequestInfo,\n NetworkResponseInfo,\n BrowserConsoleLogEntry,\n PageErrorInfo,\n RequestFailureInfo,\n DefaultPlaywrightHandler,\n DefaultPlaywrightHandlerMetadata,\n DefaultPlaywrightHandlerOptions,\n PlaywrightSetupOptions,\n PlaywrightHandle,\n PlaywrightCallback,\n} from \"./types.cjs\";\n\nexport type { PlaywrightOperation, PlaywrightResult, PlaywrightEvent, PlaywrightFileData } from \"../protocol/index.cjs\";\n\n// Re-export handler functions\nexport {\n createPlaywrightHandler,\n defaultPlaywrightHandler,\n getDefaultPlaywrightHandlerMetadata,\n} from \"./handler.cjs\";\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BO,IAJP;",
|
|
8
|
+
"debugId": "29BE6FB5E46FEB4164756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|