@mearl/native-host 2.22.0 → 3.0.0-beta.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/LICENSE +201 -0
- package/README.md +4 -0
- package/dist/THIRD_PARTY_NOTICES.txt +773 -0
- package/dist/agent/event-transport.d.ts +3 -0
- package/dist/agent/manager.d.ts +59 -0
- package/dist/agent/skill-manager.d.ts +52 -0
- package/dist/agent/workspace-directory.d.ts +4 -0
- package/dist/alipay-auth-code.d.ts +13 -0
- package/dist/analytics.d.ts +3 -0
- package/dist/app-profile-catalog.d.ts +11 -0
- package/dist/browser-artifacts.d.ts +26 -0
- package/dist/browser-inventory.d.ts +22 -0
- package/dist/browser-provider-coordinator.d.ts +24 -0
- package/dist/browser-provider.d.ts +30 -0
- package/dist/browser-registry.d.ts +93 -0
- package/dist/browser-socket-request.d.ts +5 -0
- package/dist/builtin-browser-providers.d.ts +8 -0
- package/dist/builtin-provider-options.d.ts +11 -0
- package/dist/capability-contracts.d.ts +73 -0
- package/dist/cdp-backend/action-registry.d.ts +36 -0
- package/dist/cdp-backend/app-profile-handlers.d.ts +62 -0
- package/dist/cdp-backend/browser-handlers.d.ts +6 -0
- package/dist/cdp-backend/buffers.d.ts +72 -0
- package/dist/cdp-backend/cdp-session.d.ts +102 -0
- package/dist/cdp-backend/cdp-utils.d.ts +41 -0
- package/dist/cdp-backend/client.d.ts +41 -0
- package/dist/cdp-backend/composite-handlers.d.ts +17 -0
- package/dist/cdp-backend/controlled-indicator.d.ts +18 -0
- package/dist/cdp-backend/cookie-handlers.d.ts +7 -0
- package/dist/cdp-backend/cookie-transfer.d.ts +37 -0
- package/dist/cdp-backend/device-shell.d.ts +26 -0
- package/dist/cdp-backend/discover.d.ts +29 -0
- package/dist/cdp-backend/domain-manager.d.ts +4 -0
- package/dist/cdp-backend/download-handlers.d.ts +9 -0
- package/dist/cdp-backend/fetch-interceptor.d.ts +26 -0
- package/dist/cdp-backend/frame-evaluation.d.ts +3 -0
- package/dist/cdp-backend/frame-tree.d.ts +16 -0
- package/dist/cdp-backend/handlers.d.ts +30 -0
- package/dist/cdp-backend/http-handlers.d.ts +33 -0
- package/dist/cdp-backend/interaction-handlers.d.ts +19 -0
- package/dist/cdp-backend/mock-handlers.d.ts +10 -0
- package/dist/cdp-backend/mtop-environment.d.ts +7 -0
- package/dist/cdp-backend/navigation-observer.d.ts +9 -0
- package/dist/cdp-backend/page-observer.d.ts +5 -0
- package/dist/cdp-backend/page-refs.d.ts +9 -0
- package/dist/cdp-backend/page-session-initializers.d.ts +6 -0
- package/dist/cdp-backend/plugin-pages.d.ts +12 -0
- package/dist/cdp-backend/release-control.d.ts +13 -0
- package/dist/cdp-backend/request-handlers.d.ts +10 -0
- package/dist/cdp-backend/rule-handlers.d.ts +11 -0
- package/dist/cdp-backend/send-request.d.ts +2 -0
- package/dist/cdp-backend/snapshot-handlers.d.ts +7 -0
- package/dist/cdp-backend/tab-handlers.d.ts +8 -0
- package/dist/cdp-backend/timezone-handlers.d.ts +4 -0
- package/dist/cloud-connector.d.ts +61 -0
- package/dist/config.d.ts +7 -0
- package/dist/control-session-manager.d.ts +30 -0
- package/dist/control-session.d.ts +31 -0
- package/dist/extension-file-transfer.d.ts +7 -0
- package/dist/extension-updater.d.ts +18 -0
- package/dist/host-updater.d.ts +39 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +263 -350
- package/dist/install.d.ts +1 -0
- package/dist/internal-extension-actions.d.ts +10 -0
- package/dist/launcher.d.ts +1 -0
- package/dist/managed-browser.d.ts +61 -0
- package/dist/native-capability-services.d.ts +21 -0
- package/dist/node-capabilities.d.ts +20 -0
- package/dist/node-capabilities.js +4 -0
- package/dist/page-runtime-store.d.ts +27 -0
- package/dist/persistent-browser-record.d.ts +8 -0
- package/dist/plugin-host-services.d.ts +7 -0
- package/dist/plugin-page-results.d.ts +7 -0
- package/dist/plugin-task-host.js +21 -21
- package/dist/plugin-worker.js +19 -19
- package/dist/pluginModelSessionWorker.js +1 -1
- package/dist/preset-components.d.ts +35 -0
- package/dist/preset-installation.d.ts +19 -0
- package/dist/provider-control-host.d.ts +1 -0
- package/dist/provider-control.d.ts +28 -0
- package/dist/provider-request-timeout.d.ts +2 -0
- package/dist/runtimeArgs.d.ts +14 -0
- package/dist/sandbox-browser-access.d.ts +10 -0
- package/dist/send-request-file-utils.d.ts +14 -0
- package/dist/socketLines.d.ts +12 -0
- package/dist/toolbox-permissions.d.ts +8 -0
- package/dist/toolbox-service.d.ts +26 -0
- package/dist/version.d.ts +1 -0
- package/package.json +26 -16
package/dist/install.d.ts
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* import { installNativeHost } from '@mearl/native-host';
|
|
17
17
|
* await installNativeHost(); // installs both
|
|
18
18
|
*/
|
|
19
|
+
/// <reference types="node" preserve="true" />
|
|
19
20
|
import fs from 'node:fs';
|
|
20
21
|
export type IntegrationMode = 'skills' | 'mcp';
|
|
21
22
|
export interface InstallOptions {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ControlSource, type ControlSourceWireValue } from '@mearl/browser-core';
|
|
2
|
+
/** Browser clients cannot call either direction of the extension's private RPC. */
|
|
3
|
+
export declare function isPrivateExtensionAction(action: unknown): boolean;
|
|
4
|
+
export declare function createExtensionRequestMessage(id: string, action: string, data: any, trustedInternal?: boolean, controlSource?: ControlSource): {
|
|
5
|
+
id: string;
|
|
6
|
+
action: string;
|
|
7
|
+
data: any;
|
|
8
|
+
controlSource: ControlSourceWireValue;
|
|
9
|
+
trustedInternal?: true;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createLauncherScript(hostDir: string, hostPath: string, hostName: string, execPath?: string): string;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** Managed Chrome lifecycle for isolated, optionally headless browser instances. */
|
|
2
|
+
import { type DaemonRecord } from '@mearl/daemon-core';
|
|
3
|
+
import { type TransferableCookie } from './cdp-backend/cookie-transfer.js';
|
|
4
|
+
import type { BuiltinBrowserLaunchOptions } from './builtin-provider-options.js';
|
|
5
|
+
export type ManagedBrowserUserAgentMode = NonNullable<BuiltinBrowserLaunchOptions['userAgentMode']>;
|
|
6
|
+
interface ManagedBrowserRecord extends DaemonRecord {
|
|
7
|
+
pid: number;
|
|
8
|
+
hostPid: number;
|
|
9
|
+
browserId: string;
|
|
10
|
+
name: string;
|
|
11
|
+
headless: boolean;
|
|
12
|
+
persistent: boolean;
|
|
13
|
+
userDataDir: string;
|
|
14
|
+
executablePath: string;
|
|
15
|
+
cdpPort: number;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
copiedCookies?: {
|
|
18
|
+
domains: string[];
|
|
19
|
+
count: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface ManagedBrowserSummary {
|
|
23
|
+
browserId: string;
|
|
24
|
+
name: string;
|
|
25
|
+
provider: 'local';
|
|
26
|
+
headless: boolean;
|
|
27
|
+
persistent: boolean;
|
|
28
|
+
cdpPort: number;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
copiedCookies?: ManagedBrowserRecord['copiedCookies'];
|
|
31
|
+
running: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface ManagedBrowserManagerDeps {
|
|
34
|
+
nativeHostScript: string;
|
|
35
|
+
exportCookies: (domains: string[]) => Promise<TransferableCookie[]>;
|
|
36
|
+
log: (...args: any[]) => void;
|
|
37
|
+
}
|
|
38
|
+
export declare function validateName(value: unknown): string;
|
|
39
|
+
/** Use one case-insensitive identity for registry, locking, and persistent profile paths. */
|
|
40
|
+
export declare function managedBrowserId(name: string): string;
|
|
41
|
+
export declare function chromeExecutableCandidates(platform?: NodeJS.Platform): string[];
|
|
42
|
+
export declare function resolveChromeExecutable(explicitPath?: string): string;
|
|
43
|
+
export declare function desktopChromeUserAgent(version: string, platform?: NodeJS.Platform): string;
|
|
44
|
+
export declare function resolveChromeVersion(executablePath: string): string;
|
|
45
|
+
export declare function resolveUserAgentMode(value: unknown): ManagedBrowserUserAgentMode;
|
|
46
|
+
export declare function buildManagedChromeArgs(options: {
|
|
47
|
+
userDataDir: string;
|
|
48
|
+
headless: boolean;
|
|
49
|
+
userAgent?: string;
|
|
50
|
+
}): string[];
|
|
51
|
+
/** Verify both PID liveness and the instance-specific command line before managing a process. */
|
|
52
|
+
export declare function isManagedProcess(pid: number, commandMarker: string, platform?: NodeJS.Platform): boolean;
|
|
53
|
+
export declare function listManagedBrowsers(): ManagedBrowserSummary[];
|
|
54
|
+
export declare function waitForBrowserRegistration(browserId: string, expectedPid: number): Promise<void>;
|
|
55
|
+
export declare function stopProcess(pid: number, commandMarker: string): Promise<void>;
|
|
56
|
+
export declare function acquireLaunchLock(browserId: string): () => void;
|
|
57
|
+
export declare function launchManagedBrowser(input: BuiltinBrowserLaunchOptions, deps: ManagedBrowserManagerDeps): Promise<Record<string, any>>;
|
|
58
|
+
export declare function closeManagedBrowser(selector: string, options?: {
|
|
59
|
+
deleteProfile?: boolean;
|
|
60
|
+
}): Promise<Record<string, any>>;
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { NodeCapabilityHandler } from './node-capabilities.js';
|
|
2
|
+
/** Pure consumers can inspect optional hooks without starting any local services. */
|
|
3
|
+
export declare const nativeCapabilities: {
|
|
4
|
+
get<T extends NodeCapabilityHandler>(name: string): T | undefined;
|
|
5
|
+
require<T extends NodeCapabilityHandler>(name: string): T;
|
|
6
|
+
refresh(): Promise<string | undefined>;
|
|
7
|
+
status(): {
|
|
8
|
+
revision: string | null;
|
|
9
|
+
installationRevision: string | null;
|
|
10
|
+
};
|
|
11
|
+
synchronize(): Promise<{
|
|
12
|
+
accepted: boolean;
|
|
13
|
+
revision: string | null;
|
|
14
|
+
installationRevision: string | null;
|
|
15
|
+
} | {
|
|
16
|
+
accepted: boolean;
|
|
17
|
+
error: string;
|
|
18
|
+
revision: string | null;
|
|
19
|
+
installationRevision: string | null;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="node" preserve="true" />
|
|
2
|
+
export { NodeCapabilityRegistry } from '@mearl/daemon-core/capabilities';
|
|
3
|
+
export type { NodeCapabilityHandler, NodeCapabilityHandlers } from '@mearl/daemon-core/capabilities';
|
|
4
|
+
export interface NodeCapabilityHost {
|
|
5
|
+
version: string;
|
|
6
|
+
env: Readonly<NodeJS.ProcessEnv>;
|
|
7
|
+
fetch: typeof globalThis.fetch;
|
|
8
|
+
providers: {
|
|
9
|
+
listInstalled: typeof import('@mearl/provider/host').listInstalledProviders;
|
|
10
|
+
readLive: typeof import('@mearl/provider/runtime').readLiveProvider;
|
|
11
|
+
assertProtocol: typeof import('@mearl/provider').assertProviderProtocolVersion;
|
|
12
|
+
install: typeof import('@mearl/setup').installProviderPackage;
|
|
13
|
+
launch: typeof import('./browser-provider.js').launchProviderBrowser;
|
|
14
|
+
find: typeof import('./browser-provider.js').findProviderBrowser;
|
|
15
|
+
close: typeof import('./browser-provider.js').closeProviderBrowser;
|
|
16
|
+
request: typeof import('./browser-socket-request.js').requestBrowserSocket;
|
|
17
|
+
};
|
|
18
|
+
renderQr: (value: string) => string;
|
|
19
|
+
runCommand: typeof import('@mearl/daemon-core').runCommand;
|
|
20
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __mearlCreateRequire } from 'node:module'; const require = __mearlCreateRequire(import.meta.url);
|
|
2
|
+
var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __commonJS=(cb,mod)=>function(){try{return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports}catch(e){throw mod=0,e}};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod));var require_constants=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js"(exports,module){"use strict";var SEMVER_SPEC_VERSION="2.0.0",MAX_SAFE_INTEGER=Number.MAX_SAFE_INTEGER||9007199254740991,MAX_SAFE_COMPONENT_LENGTH=16,MAX_SAFE_BUILD_LENGTH=250,RELEASE_TYPES=["major","premajor","minor","preminor","patch","prepatch","prerelease"];module.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH,MAX_SAFE_BUILD_LENGTH,MAX_SAFE_INTEGER,RELEASE_TYPES,SEMVER_SPEC_VERSION,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}});var require_debug=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js"(exports,module){"use strict";var debug=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...args)=>console.error("SEMVER",...args):()=>{};module.exports=debug}});var require_re=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js"(exports,module){"use strict";var{MAX_SAFE_COMPONENT_LENGTH,MAX_SAFE_BUILD_LENGTH,MAX_LENGTH}=require_constants(),debug=require_debug();exports=module.exports={};var re=exports.re=[],safeRe=exports.safeRe=[],src=exports.src=[],safeSrc=exports.safeSrc=[],t=exports.t={},R=0,LETTERDASHNUMBER="[a-zA-Z0-9-]",safeRegexReplacements=[["\\s",1],["\\d",MAX_LENGTH],[LETTERDASHNUMBER,MAX_SAFE_BUILD_LENGTH]],makeSafeRegex=value=>{for(let[token,max]of safeRegexReplacements)value=value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);return value},createToken=(name,value,isGlobal)=>{let safe=makeSafeRegex(value),index=R++;debug(name,index,value),t[name]=index,src[index]=value,safeSrc[index]=safe,re[index]=new RegExp(value,isGlobal?"g":void 0),safeRe[index]=new RegExp(safe,isGlobal?"g":void 0)};createToken("NUMERICIDENTIFIER","0|[1-9]\\d*");createToken("NUMERICIDENTIFIERLOOSE","\\d+");createToken("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);createToken("MAINVERSION",`(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);createToken("MAINVERSIONLOOSE",`(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);createToken("PRERELEASEIDENTIFIER",`(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);createToken("PRERELEASEIDENTIFIERLOOSE",`(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);createToken("PRERELEASE",`(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);createToken("PRERELEASELOOSE",`(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);createToken("BUILDIDENTIFIER",`${LETTERDASHNUMBER}+`);createToken("BUILD",`(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);createToken("FULLPLAIN",`v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);createToken("FULL",`^${src[t.FULLPLAIN]}$`);createToken("LOOSEPLAIN",`[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);createToken("LOOSE",`^${src[t.LOOSEPLAIN]}$`);createToken("GTLT","((?:<|>)?=?)");createToken("XRANGEIDENTIFIERLOOSE",`${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);createToken("XRANGEIDENTIFIER",`${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);createToken("XRANGEPLAIN",`[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);createToken("XRANGEPLAINLOOSE",`[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);createToken("XRANGE",`^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);createToken("XRANGELOOSE",`^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);createToken("COERCEPLAIN",`(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);createToken("COERCE",`${src[t.COERCEPLAIN]}(?:$|[^\\d])`);createToken("COERCEFULL",src[t.COERCEPLAIN]+`(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);createToken("COERCERTL",src[t.COERCE],!0);createToken("COERCERTLFULL",src[t.COERCEFULL],!0);createToken("LONETILDE","(?:~>?)");createToken("TILDETRIM",`(\\s*)${src[t.LONETILDE]}\\s+`,!0);exports.tildeTrimReplace="$1~";createToken("TILDE",`^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);createToken("TILDELOOSE",`^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);createToken("LONECARET","(?:\\^)");createToken("CARETTRIM",`(\\s*)${src[t.LONECARET]}\\s+`,!0);exports.caretTrimReplace="$1^";createToken("CARET",`^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);createToken("CARETLOOSE",`^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);createToken("COMPARATORLOOSE",`^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);createToken("COMPARATOR",`^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);createToken("COMPARATORTRIM",`(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`,!0);exports.comparatorTrimReplace="$1$2$3";createToken("HYPHENRANGE",`^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);createToken("HYPHENRANGELOOSE",`^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);createToken("STAR","(<|>)?=?\\s*\\*");createToken("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");createToken("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}});var require_parse_options=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js"(exports,module){"use strict";var looseOption=Object.freeze({loose:!0}),emptyOpts=Object.freeze({}),parseOptions=options=>options?typeof options!="object"?looseOption:options:emptyOpts;module.exports=parseOptions}});var require_identifiers=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/identifiers.js"(exports,module){"use strict";var numeric=/^[0-9]+$/,compareIdentifiers=(a,b)=>{if(typeof a=="number"&&typeof b=="number")return a===b?0:a<b?-1:1;let anum=numeric.test(a),bnum=numeric.test(b);return anum&&bnum&&(a=+a,b=+b),a===b?0:anum&&!bnum?-1:bnum&&!anum?1:a<b?-1:1},rcompareIdentifiers=(a,b)=>compareIdentifiers(b,a);module.exports={compareIdentifiers,rcompareIdentifiers}}});var require_semver=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/semver.js"(exports,module){"use strict";var debug=require_debug(),{MAX_LENGTH,MAX_SAFE_INTEGER}=require_constants(),{safeRe:re,t}=require_re(),parseOptions=require_parse_options(),{compareIdentifiers}=require_identifiers(),isPrereleaseIdentifier=(prerelease,identifier2)=>{let identifiers=identifier2.split(".");if(identifiers.length>prerelease.length)return!1;for(let i=0;i<identifiers.length;i++)if(compareIdentifiers(prerelease[i],identifiers[i])!==0)return!1;return!0},SemVer=class _SemVer{constructor(version,options){if(options=parseOptions(options),version instanceof _SemVer){if(version.loose===!!options.loose&&version.includePrerelease===!!options.includePrerelease)return version;version=version.version}else if(typeof version!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);if(version.length>MAX_LENGTH)throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);debug("SemVer",version,options),this.options=options,this.loose=!!options.loose,this.includePrerelease=!!options.includePrerelease;let m=version.trim().match(options.loose?re[t.LOOSE]:re[t.FULL]);if(!m)throw new TypeError(`Invalid Version: ${version}`);if(this.raw=version,this.major=+m[1],this.minor=+m[2],this.patch=+m[3],this.major>MAX_SAFE_INTEGER||this.major<0)throw new TypeError("Invalid major version");if(this.minor>MAX_SAFE_INTEGER||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>MAX_SAFE_INTEGER||this.patch<0)throw new TypeError("Invalid patch version");m[4]?this.prerelease=m[4].split(".").map(id=>{if(/^[0-9]+$/.test(id)){let num=+id;if(num>=0&&num<MAX_SAFE_INTEGER)return num}return id}):this.prerelease=[],this.build=m[5]?m[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(other){if(debug("SemVer.compare",this.version,this.options,other),!(other instanceof _SemVer)){if(typeof other=="string"&&other===this.version)return 0;other=new _SemVer(other,this.options)}return other.version===this.version?0:this.compareMain(other)||this.comparePre(other)}compareMain(other){return other instanceof _SemVer||(other=new _SemVer(other,this.options)),this.major<other.major?-1:this.major>other.major?1:this.minor<other.minor?-1:this.minor>other.minor?1:this.patch<other.patch?-1:this.patch>other.patch?1:0}comparePre(other){if(other instanceof _SemVer||(other=new _SemVer(other,this.options)),this.prerelease.length&&!other.prerelease.length)return-1;if(!this.prerelease.length&&other.prerelease.length)return 1;if(!this.prerelease.length&&!other.prerelease.length)return 0;let i=0;do{let a=this.prerelease[i],b=other.prerelease[i];if(debug("prerelease compare",i,a,b),a===void 0&&b===void 0)return 0;if(b===void 0)return 1;if(a===void 0)return-1;if(a===b)continue;return compareIdentifiers(a,b)}while(++i)}compareBuild(other){other instanceof _SemVer||(other=new _SemVer(other,this.options));let i=0;do{let a=this.build[i],b=other.build[i];if(debug("build compare",i,a,b),a===void 0&&b===void 0)return 0;if(b===void 0)return 1;if(a===void 0)return-1;if(a===b)continue;return compareIdentifiers(a,b)}while(++i)}inc(release,identifier2,identifierBase){if(release.startsWith("pre")){if(!identifier2&&identifierBase===!1)throw new Error("invalid increment argument: identifier is empty");if(identifier2){let match=`-${identifier2}`.match(this.options.loose?re[t.PRERELEASELOOSE]:re[t.PRERELEASE]);if(!match||match[1]!==identifier2)throw new Error(`invalid identifier: ${identifier2}`)}}switch(release){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",identifier2,identifierBase);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",identifier2,identifierBase);break;case"prepatch":this.prerelease.length=0,this.inc("patch",identifier2,identifierBase),this.inc("pre",identifier2,identifierBase);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",identifier2,identifierBase),this.inc("pre",identifier2,identifierBase);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let base=Number(identifierBase)?1:0;if(this.prerelease.length===0)this.prerelease=[base];else{let i=this.prerelease.length;for(;--i>=0;)typeof this.prerelease[i]=="number"&&(this.prerelease[i]++,i=-2);if(i===-1){if(identifier2===this.prerelease.join(".")&&identifierBase===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(base)}}if(identifier2){let prerelease=[identifier2,base];if(identifierBase===!1&&(prerelease=[identifier2]),isPrereleaseIdentifier(this.prerelease,identifier2)){let prereleaseBase=this.prerelease[identifier2.split(".").length];isNaN(prereleaseBase)&&(this.prerelease=prerelease)}else this.prerelease=prerelease}break}default:throw new Error(`invalid increment argument: ${release}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};module.exports=SemVer}});var require_parse=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/parse.js"(exports,module){"use strict";var SemVer=require_semver(),parse=(version,options,throwErrors=!1)=>{if(version instanceof SemVer)return version;try{return new SemVer(version,options)}catch(er){if(!throwErrors)return null;throw er}};module.exports=parse}});var require_valid=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/valid.js"(exports,module){"use strict";var parse=require_parse(),valid4=(version,options)=>{let v=parse(version,options);return v?v.version:null};module.exports=valid4}});var require_clean=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/clean.js"(exports,module){"use strict";var parse=require_parse(),clean=(version,options)=>{let s=parse(version.trim().replace(/^[=v]+/,""),options);return s?s.version:null};module.exports=clean}});var require_inc=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/inc.js"(exports,module){"use strict";var SemVer=require_semver(),inc=(version,release,options,identifier2,identifierBase)=>{typeof options=="string"&&(identifierBase=identifier2,identifier2=options,options=void 0);try{return new SemVer(version instanceof SemVer?version.version:version,options).inc(release,identifier2,identifierBase).version}catch{return null}};module.exports=inc}});var require_diff=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/diff.js"(exports,module){"use strict";var parse=require_parse(),diff=(version1,version2)=>{let v1=parse(version1,null,!0),v2=parse(version2,null,!0),comparison=v1.compare(v2);if(comparison===0)return null;let v1Higher=comparison>0,highVersion=v1Higher?v1:v2,lowVersion=v1Higher?v2:v1,highHasPre=!!highVersion.prerelease.length;if(!!lowVersion.prerelease.length&&!highHasPre){if(!lowVersion.patch&&!lowVersion.minor)return"major";if(lowVersion.compareMain(highVersion)===0)return lowVersion.minor&&!lowVersion.patch?"minor":"patch"}let prefix=highHasPre?"pre":"";return v1.major!==v2.major?prefix+"major":v1.minor!==v2.minor?prefix+"minor":v1.patch!==v2.patch?prefix+"patch":"prerelease"};module.exports=diff}});var require_major=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/major.js"(exports,module){"use strict";var SemVer=require_semver(),major=(a,loose)=>new SemVer(a,loose).major;module.exports=major}});var require_minor=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/minor.js"(exports,module){"use strict";var SemVer=require_semver(),minor=(a,loose)=>new SemVer(a,loose).minor;module.exports=minor}});var require_patch=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/patch.js"(exports,module){"use strict";var SemVer=require_semver(),patch=(a,loose)=>new SemVer(a,loose).patch;module.exports=patch}});var require_prerelease=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/prerelease.js"(exports,module){"use strict";var parse=require_parse(),prerelease=(version,options)=>{let parsed=parse(version,options);return parsed&&parsed.prerelease.length?parsed.prerelease:null};module.exports=prerelease}});var require_compare=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare.js"(exports,module){"use strict";var SemVer=require_semver(),compare=(a,b,loose)=>new SemVer(a,loose).compare(new SemVer(b,loose));module.exports=compare}});var require_rcompare=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/rcompare.js"(exports,module){"use strict";var compare=require_compare(),rcompare=(a,b,loose)=>compare(b,a,loose);module.exports=rcompare}});var require_compare_loose=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare-loose.js"(exports,module){"use strict";var compare=require_compare(),compareLoose=(a,b)=>compare(a,b,!0);module.exports=compareLoose}});var require_compare_build=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare-build.js"(exports,module){"use strict";var SemVer=require_semver(),compareBuild=(a,b,loose)=>{let versionA=new SemVer(a,loose),versionB=new SemVer(b,loose);return versionA.compare(versionB)||versionA.compareBuild(versionB)};module.exports=compareBuild}});var require_sort=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/sort.js"(exports,module){"use strict";var compareBuild=require_compare_build(),sort=(list,loose)=>list.sort((a,b)=>compareBuild(a,b,loose));module.exports=sort}});var require_rsort=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/rsort.js"(exports,module){"use strict";var compareBuild=require_compare_build(),rsort=(list,loose)=>list.sort((a,b)=>compareBuild(b,a,loose));module.exports=rsort}});var require_gt=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gt.js"(exports,module){"use strict";var compare=require_compare(),gt=(a,b,loose)=>compare(a,b,loose)>0;module.exports=gt}});var require_lt=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lt.js"(exports,module){"use strict";var compare=require_compare(),lt=(a,b,loose)=>compare(a,b,loose)<0;module.exports=lt}});var require_eq=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/eq.js"(exports,module){"use strict";var compare=require_compare(),eq=(a,b,loose)=>compare(a,b,loose)===0;module.exports=eq}});var require_neq=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/neq.js"(exports,module){"use strict";var compare=require_compare(),neq=(a,b,loose)=>compare(a,b,loose)!==0;module.exports=neq}});var require_gte=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gte.js"(exports,module){"use strict";var compare=require_compare(),gte=(a,b,loose)=>compare(a,b,loose)>=0;module.exports=gte}});var require_lte=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lte.js"(exports,module){"use strict";var compare=require_compare(),lte=(a,b,loose)=>compare(a,b,loose)<=0;module.exports=lte}});var require_cmp=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/cmp.js"(exports,module){"use strict";var eq=require_eq(),neq=require_neq(),gt=require_gt(),gte=require_gte(),lt=require_lt(),lte=require_lte(),cmp=(a,op,b,loose)=>{switch(op){case"===":return typeof a=="object"&&(a=a.version),typeof b=="object"&&(b=b.version),a===b;case"!==":return typeof a=="object"&&(a=a.version),typeof b=="object"&&(b=b.version),a!==b;case"":case"=":case"==":return eq(a,b,loose);case"!=":return neq(a,b,loose);case">":return gt(a,b,loose);case">=":return gte(a,b,loose);case"<":return lt(a,b,loose);case"<=":return lte(a,b,loose);default:throw new TypeError(`Invalid operator: ${op}`)}};module.exports=cmp}});var require_coerce=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/coerce.js"(exports,module){"use strict";var SemVer=require_semver(),parse=require_parse(),{safeRe:re,t}=require_re(),coerce=(version,options)=>{if(version instanceof SemVer)return version;if(typeof version=="number"&&(version=String(version)),typeof version!="string")return null;options=options||{};let match=null;if(!options.rtl)match=version.match(options.includePrerelease?re[t.COERCEFULL]:re[t.COERCE]);else{let coerceRtlRegex=options.includePrerelease?re[t.COERCERTLFULL]:re[t.COERCERTL],next;for(;(next=coerceRtlRegex.exec(version))&&(!match||match.index+match[0].length!==version.length);)(!match||next.index+next[0].length!==match.index+match[0].length)&&(match=next),coerceRtlRegex.lastIndex=next.index+next[1].length+next[2].length;coerceRtlRegex.lastIndex=-1}if(match===null)return null;let major=match[2],minor=match[3]||"0",patch=match[4]||"0",prerelease=options.includePrerelease&&match[5]?`-${match[5]}`:"",build=options.includePrerelease&&match[6]?`+${match[6]}`:"";return parse(`${major}.${minor}.${patch}${prerelease}${build}`,options)};module.exports=coerce}});var require_truncate=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/truncate.js"(exports,module){"use strict";var parse=require_parse(),constants2=require_constants(),SemVer=require_semver(),truncate=(version,truncation,options)=>{if(!constants2.RELEASE_TYPES.includes(truncation))return null;let clonedVersion=cloneInputVersion(version,options);return clonedVersion&&doTruncation(clonedVersion,truncation)},cloneInputVersion=(version,options)=>{let versionStringToParse=version instanceof SemVer?version.version:version;return parse(versionStringToParse,options)},doTruncation=(version,truncation)=>{if(isPrerelease(truncation))return version.version;switch(version.prerelease=[],truncation){case"major":version.minor=0,version.patch=0;break;case"minor":version.patch=0;break}return version.format()},isPrerelease=type=>type.startsWith("pre");module.exports=truncate}});var require_lrucache=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/lrucache.js"(exports,module){"use strict";var LRUCache=class{constructor(){this.max=1e3,this.map=new Map}get(key){let value=this.map.get(key);if(value!==void 0)return this.map.delete(key),this.map.set(key,value),value}delete(key){return this.map.delete(key)}set(key,value){if(!this.delete(key)&&value!==void 0){if(this.map.size>=this.max){let firstKey=this.map.keys().next().value;this.delete(firstKey)}this.map.set(key,value)}return this}};module.exports=LRUCache}});var require_range=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/range.js"(exports,module){"use strict";var SPACE_CHARACTERS=/\s+/g,Range=class _Range{constructor(range,options){if(options=parseOptions(options),range instanceof _Range)return range.loose===!!options.loose&&range.includePrerelease===!!options.includePrerelease?range:new _Range(range.raw,options);if(range instanceof Comparator)return this.raw=range.value,this.set=[[range]],this.formatted=void 0,this;if(this.options=options,this.loose=!!options.loose,this.includePrerelease=!!options.includePrerelease,this.raw=range.trim().replace(SPACE_CHARACTERS," "),this.set=this.raw.split("||").map(r=>this.parseRange(r.trim())).filter(c=>c.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let first=this.set[0];if(this.set=this.set.filter(c=>!isNullSet(c[0])),this.set.length===0)this.set=[first];else if(this.set.length>1){for(let c of this.set)if(c.length===1&&isAny(c[0])){this.set=[c];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let i=0;i<this.set.length;i++){i>0&&(this.formatted+="||");let comps=this.set[i];for(let k=0;k<comps.length;k++)k>0&&(this.formatted+=" "),this.formatted+=comps[k].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(range){range=range.replace(BUILDSTRIPRE,"");let memoKey=((this.options.includePrerelease&&FLAG_INCLUDE_PRERELEASE)|(this.options.loose&&FLAG_LOOSE))+":"+range,cached=cache.get(memoKey);if(cached)return cached;let loose=this.options.loose,hr=loose?re[t.HYPHENRANGELOOSE]:re[t.HYPHENRANGE];range=range.replace(hr,hyphenReplace(this.options.includePrerelease)),debug("hyphen replace",range),range=range.replace(re[t.COMPARATORTRIM],comparatorTrimReplace),debug("comparator trim",range),range=range.replace(re[t.TILDETRIM],tildeTrimReplace),debug("tilde trim",range),range=range.replace(re[t.CARETTRIM],caretTrimReplace),debug("caret trim",range);let rangeList=range.split(" ").map(comp=>parseComparator(comp,this.options)).join(" ").split(/\s+/).map(comp=>replaceGTE0(comp,this.options));loose&&(rangeList=rangeList.filter(comp=>(debug("loose invalid filter",comp,this.options),!!comp.match(re[t.COMPARATORLOOSE])))),debug("range list",rangeList);let rangeMap=new Map,comparators=rangeList.map(comp=>new Comparator(comp,this.options));for(let comp of comparators){if(isNullSet(comp))return[comp];rangeMap.set(comp.value,comp)}rangeMap.size>1&&rangeMap.has("")&&rangeMap.delete("");let result=[...rangeMap.values()];return cache.set(memoKey,result),result}intersects(range,options){if(!(range instanceof _Range))throw new TypeError("a Range is required");return this.set.some(thisComparators=>isSatisfiable(thisComparators,options)&&range.set.some(rangeComparators=>isSatisfiable(rangeComparators,options)&&thisComparators.every(thisComparator=>rangeComparators.every(rangeComparator=>thisComparator.intersects(rangeComparator,options)))))}test(version){if(!version)return!1;if(typeof version=="string")try{version=new SemVer(version,this.options)}catch{return!1}for(let i=0;i<this.set.length;i++)if(testSet(this.set[i],version,this.options))return!0;return!1}};module.exports=Range;var LRU=require_lrucache(),cache=new LRU,parseOptions=require_parse_options(),Comparator=require_comparator(),debug=require_debug(),SemVer=require_semver(),{safeRe:re,src,t,comparatorTrimReplace,tildeTrimReplace,caretTrimReplace}=require_re(),{FLAG_INCLUDE_PRERELEASE,FLAG_LOOSE}=require_constants(),BUILDSTRIPRE=new RegExp(src[t.BUILD],"g"),isNullSet=c=>c.value==="<0.0.0-0",isAny=c=>c.value==="",isSatisfiable=(comparators,options)=>{let result=!0,remainingComparators=comparators.slice(),testComparator=remainingComparators.pop();for(;result&&remainingComparators.length;)result=remainingComparators.every(otherComparator=>testComparator.intersects(otherComparator,options)),testComparator=remainingComparators.pop();return result},parseComparator=(comp,options)=>(comp=comp.replace(re[t.BUILD],""),debug("comp",comp,options),comp=replaceCarets(comp,options),debug("caret",comp),comp=replaceTildes(comp,options),debug("tildes",comp),comp=replaceXRanges(comp,options),debug("xrange",comp),comp=replaceStars(comp,options),debug("stars",comp),comp),isX=id=>!id||id.toLowerCase()==="x"||id==="*",invalidXRangeOrder=(M,m,p)=>isX(M)&&!isX(m)||isX(m)&&p&&!isX(p),replaceTildes=(comp,options)=>comp.trim().split(/\s+/).map(c=>replaceTilde(c,options)).join(" "),replaceTilde=(comp,options)=>{let r=options.loose?re[t.TILDELOOSE]:re[t.TILDE],z=options.includePrerelease?"-0":"";return comp.replace(r,(_,M,m,p,pr)=>{debug("tilde",comp,_,M,m,p,pr);let ret;return isX(M)?ret="":isX(m)?ret=`>=${M}.0.0${z} <${+M+1}.0.0-0`:isX(p)?ret=`>=${M}.${m}.0${z} <${M}.${+m+1}.0-0`:pr?(debug("replaceTilde pr",pr),ret=`>=${M}.${m}.${p}-${pr} <${M}.${+m+1}.0-0`):ret=`>=${M}.${m}.${p} <${M}.${+m+1}.0-0`,debug("tilde return",ret),ret})},replaceCarets=(comp,options)=>comp.trim().split(/\s+/).map(c=>replaceCaret(c,options)).join(" "),replaceCaret=(comp,options)=>{debug("caret",comp,options);let r=options.loose?re[t.CARETLOOSE]:re[t.CARET],z=options.includePrerelease?"-0":"";return comp.replace(r,(_,M,m,p,pr)=>{debug("caret",comp,_,M,m,p,pr);let ret;return isX(M)?ret="":isX(m)?ret=`>=${M}.0.0${z} <${+M+1}.0.0-0`:isX(p)?M==="0"?ret=`>=${M}.${m}.0${z} <${M}.${+m+1}.0-0`:ret=`>=${M}.${m}.0${z} <${+M+1}.0.0-0`:pr?(debug("replaceCaret pr",pr),M==="0"?m==="0"?ret=`>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p+1}-0`:ret=`>=${M}.${m}.${p}-${pr} <${M}.${+m+1}.0-0`:ret=`>=${M}.${m}.${p}-${pr} <${+M+1}.0.0-0`):(debug("no pr"),M==="0"?m==="0"?ret=`>=${M}.${m}.${p} <${M}.${m}.${+p+1}-0`:ret=`>=${M}.${m}.${p} <${M}.${+m+1}.0-0`:ret=`>=${M}.${m}.${p} <${+M+1}.0.0-0`),debug("caret return",ret),ret})},replaceXRanges=(comp,options)=>(debug("replaceXRanges",comp,options),comp.split(/\s+/).map(c=>replaceXRange(c,options)).join(" ")),replaceXRange=(comp,options)=>{comp=comp.trim();let r=options.loose?re[t.XRANGELOOSE]:re[t.XRANGE];return comp.replace(r,(ret,gtlt,M,m,p,pr)=>{if(debug("xRange",comp,ret,gtlt,M,m,p,pr),invalidXRangeOrder(M,m,p))return comp;let xM=isX(M),xm=xM||isX(m),xp=xm||isX(p),anyX=xp;return gtlt==="="&&anyX&&(gtlt=""),pr=options.includePrerelease?"-0":"",xM?gtlt===">"||gtlt==="<"?ret="<0.0.0-0":ret="*":gtlt&&anyX?(xm&&(m=0),p=0,gtlt===">"?(gtlt=">=",xm?(M=+M+1,m=0,p=0):(m=+m+1,p=0)):gtlt==="<="&&(gtlt="<",xm?M=+M+1:m=+m+1),gtlt==="<"&&(pr="-0"),ret=`${gtlt+M}.${m}.${p}${pr}`):xm?ret=`>=${M}.0.0${pr} <${+M+1}.0.0-0`:xp&&(ret=`>=${M}.${m}.0${pr} <${M}.${+m+1}.0-0`),debug("xRange return",ret),ret})},replaceStars=(comp,options)=>(debug("replaceStars",comp,options),comp.trim().replace(re[t.STAR],"")),replaceGTE0=(comp,options)=>(debug("replaceGTE0",comp,options),comp.trim().replace(re[options.includePrerelease?t.GTE0PRE:t.GTE0],"")),hyphenReplace=incPr=>($0,from,fM,fm,fp,fpr,fb,to,tM,tm,tp,tpr)=>(isX(fM)?from="":isX(fm)?from=`>=${fM}.0.0${incPr?"-0":""}`:isX(fp)?from=`>=${fM}.${fm}.0${incPr?"-0":""}`:fpr?from=`>=${from}`:from=`>=${from}${incPr?"-0":""}`,isX(tM)?to="":isX(tm)?to=`<${+tM+1}.0.0-0`:isX(tp)?to=`<${tM}.${+tm+1}.0-0`:tpr?to=`<=${tM}.${tm}.${tp}-${tpr}`:incPr?to=`<${tM}.${tm}.${+tp+1}-0`:to=`<=${to}`,`${from} ${to}`.trim()),testSet=(set,version,options)=>{for(let i=0;i<set.length;i++)if(!set[i].test(version))return!1;if(version.prerelease.length&&!options.includePrerelease){for(let i=0;i<set.length;i++)if(debug(set[i].semver),set[i].semver!==Comparator.ANY&&set[i].semver.prerelease.length>0){let allowed=set[i].semver;if(allowed.major===version.major&&allowed.minor===version.minor&&allowed.patch===version.patch)return!0}return!1}return!0}}});var require_comparator=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/comparator.js"(exports,module){"use strict";var ANY=Symbol("SemVer ANY"),Comparator=class _Comparator{static get ANY(){return ANY}constructor(comp,options){if(options=parseOptions(options),comp instanceof _Comparator){if(comp.loose===!!options.loose)return comp;comp=comp.value}comp=comp.trim().split(/\s+/).join(" "),debug("comparator",comp,options),this.options=options,this.loose=!!options.loose,this.parse(comp),this.semver===ANY?this.value="":this.value=this.operator+this.semver.version,debug("comp",this)}parse(comp){let r=this.options.loose?re[t.COMPARATORLOOSE]:re[t.COMPARATOR],m=comp.match(r);if(!m)throw new TypeError(`Invalid comparator: ${comp}`);this.operator=m[1]!==void 0?m[1]:"",this.operator==="="&&(this.operator=""),m[2]?this.semver=new SemVer(m[2],this.options.loose):this.semver=ANY}toString(){return this.value}test(version){if(debug("Comparator.test",version,this.options.loose),this.semver===ANY||version===ANY)return!0;if(typeof version=="string")try{version=new SemVer(version,this.options)}catch{return!1}return cmp(version,this.operator,this.semver,this.options)}intersects(comp,options){if(!(comp instanceof _Comparator))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new Range(comp.value,options).test(this.value):comp.operator===""?comp.value===""?!0:new Range(this.value,options).test(comp.semver):(options=parseOptions(options),options.includePrerelease&&(this.value==="<0.0.0-0"||comp.value==="<0.0.0-0")||!options.includePrerelease&&(this.value.startsWith("<0.0.0")||comp.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&comp.operator.startsWith(">")||this.operator.startsWith("<")&&comp.operator.startsWith("<")||this.semver.version===comp.semver.version&&this.operator.includes("=")&&comp.operator.includes("=")||cmp(this.semver,"<",comp.semver,options)&&this.operator.startsWith(">")&&comp.operator.startsWith("<")||cmp(this.semver,">",comp.semver,options)&&this.operator.startsWith("<")&&comp.operator.startsWith(">")))}};module.exports=Comparator;var parseOptions=require_parse_options(),{safeRe:re,t}=require_re(),cmp=require_cmp(),debug=require_debug(),SemVer=require_semver(),Range=require_range()}});var require_satisfies=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/satisfies.js"(exports,module){"use strict";var Range=require_range(),satisfies3=(version,range,options)=>{try{range=new Range(range,options)}catch{return!1}return range.test(version)};module.exports=satisfies3}});var require_to_comparators=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/to-comparators.js"(exports,module){"use strict";var Range=require_range(),toComparators=(range,options)=>new Range(range,options).set.map(comp=>comp.map(c=>c.value).join(" ").trim().split(" "));module.exports=toComparators}});var require_max_satisfying=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/max-satisfying.js"(exports,module){"use strict";var SemVer=require_semver(),Range=require_range(),maxSatisfying=(versions,range,options)=>{let max=null,maxSV=null,rangeObj=null;try{rangeObj=new Range(range,options)}catch{return null}return versions.forEach(v=>{rangeObj.test(v)&&(!max||maxSV.compare(v)===-1)&&(max=v,maxSV=new SemVer(max,options))}),max};module.exports=maxSatisfying}});var require_min_satisfying=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/min-satisfying.js"(exports,module){"use strict";var SemVer=require_semver(),Range=require_range(),minSatisfying=(versions,range,options)=>{let min=null,minSV=null,rangeObj=null;try{rangeObj=new Range(range,options)}catch{return null}return versions.forEach(v=>{rangeObj.test(v)&&(!min||minSV.compare(v)===1)&&(min=v,minSV=new SemVer(min,options))}),min};module.exports=minSatisfying}});var require_min_version=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/min-version.js"(exports,module){"use strict";var SemVer=require_semver(),Range=require_range(),gt=require_gt(),minVersion=(range,loose)=>{range=new Range(range,loose);let minver=new SemVer("0.0.0");if(range.test(minver)||(minver=new SemVer("0.0.0-0"),range.test(minver)))return minver;minver=null;for(let i=0;i<range.set.length;++i){let comparators=range.set[i],setMin=null;comparators.forEach(comparator=>{let compver=new SemVer(comparator.semver.version);switch(comparator.operator){case">":compver.prerelease.length===0?compver.patch++:compver.prerelease.push(0),compver.raw=compver.format();case"":case">=":(!setMin||gt(compver,setMin))&&(setMin=compver);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${comparator.operator}`)}}),setMin&&(!minver||gt(minver,setMin))&&(minver=setMin)}return minver&&range.test(minver)?minver:null};module.exports=minVersion}});var require_valid2=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/valid.js"(exports,module){"use strict";var Range=require_range(),validRange3=(range,options)=>{try{return new Range(range,options).range||"*"}catch{return null}};module.exports=validRange3}});var require_outside=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/outside.js"(exports,module){"use strict";var SemVer=require_semver(),Comparator=require_comparator(),{ANY}=Comparator,Range=require_range(),satisfies3=require_satisfies(),gt=require_gt(),lt=require_lt(),lte=require_lte(),gte=require_gte(),outside=(version,range,hilo,options)=>{version=new SemVer(version,options),range=new Range(range,options);let gtfn,ltefn,ltfn,comp,ecomp;switch(hilo){case">":gtfn=gt,ltefn=lte,ltfn=lt,comp=">",ecomp=">=";break;case"<":gtfn=lt,ltefn=gte,ltfn=gt,comp="<",ecomp="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(satisfies3(version,range,options))return!1;for(let i=0;i<range.set.length;++i){let comparators=range.set[i],high=null,low=null;if(comparators.forEach(comparator=>{comparator.semver===ANY&&(comparator=new Comparator(">=0.0.0")),high=high||comparator,low=low||comparator,gtfn(comparator.semver,high.semver,options)?high=comparator:ltfn(comparator.semver,low.semver,options)&&(low=comparator)}),high.operator===comp||high.operator===ecomp||(!low.operator||low.operator===comp)&<efn(version,low.semver))return!1;if(low.operator===ecomp&<fn(version,low.semver))return!1}return!0};module.exports=outside}});var require_gtr=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/gtr.js"(exports,module){"use strict";var outside=require_outside(),gtr=(version,range,options)=>outside(version,range,">",options);module.exports=gtr}});var require_ltr=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/ltr.js"(exports,module){"use strict";var outside=require_outside(),ltr=(version,range,options)=>outside(version,range,"<",options);module.exports=ltr}});var require_intersects=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/intersects.js"(exports,module){"use strict";var Range=require_range(),intersects=(r1,r2,options)=>(r1=new Range(r1,options),r2=new Range(r2,options),r1.intersects(r2,options));module.exports=intersects}});var require_simplify=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/simplify.js"(exports,module){"use strict";var satisfies3=require_satisfies(),compare=require_compare();module.exports=(versions,range,options)=>{let set=[],first=null,prev=null,v=versions.sort((a,b)=>compare(a,b,options));for(let version of v)satisfies3(version,range,options)?(prev=version,first||(first=version)):(prev&&set.push([first,prev]),prev=null,first=null);first&&set.push([first,null]);let ranges=[];for(let[min,max]of set)min===max?ranges.push(min):!max&&min===v[0]?ranges.push("*"):max?min===v[0]?ranges.push(`<=${max}`):ranges.push(`${min} - ${max}`):ranges.push(`>=${min}`);let simplified=ranges.join(" || "),original=typeof range.raw=="string"?range.raw:String(range);return simplified.length<original.length?simplified:range}}});var require_subset=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/subset.js"(exports,module){"use strict";var Range=require_range(),Comparator=require_comparator(),{ANY}=Comparator,satisfies3=require_satisfies(),compare=require_compare(),subset=(sub,dom,options={})=>{if(sub===dom)return!0;sub=new Range(sub,options),dom=new Range(dom,options);let sawNonNull=!1;OUTER:for(let simpleSub of sub.set){for(let simpleDom of dom.set){let isSub=simpleSubset(simpleSub,simpleDom,options);if(sawNonNull=sawNonNull||isSub!==null,isSub)continue OUTER}if(sawNonNull)return!1}return!0},minimumVersionWithPreRelease=[new Comparator(">=0.0.0-0")],minimumVersion=[new Comparator(">=0.0.0")],simpleSubset=(sub,dom,options)=>{if(sub===dom)return!0;if(sub.length===1&&sub[0].semver===ANY){if(dom.length===1&&dom[0].semver===ANY)return!0;options.includePrerelease?sub=minimumVersionWithPreRelease:sub=minimumVersion}if(dom.length===1&&dom[0].semver===ANY){if(options.includePrerelease)return!0;dom=minimumVersion}let eqSet=new Set,gt,lt;for(let c of sub)c.operator===">"||c.operator===">="?gt=higherGT(gt,c,options):c.operator==="<"||c.operator==="<="?lt=lowerLT(lt,c,options):eqSet.add(c.semver);if(eqSet.size>1)return null;let gtltComp;if(gt&<){if(gtltComp=compare(gt.semver,lt.semver,options),gtltComp>0)return null;if(gtltComp===0&&(gt.operator!==">="||lt.operator!=="<="))return null}for(let eq of eqSet){if(gt&&!satisfies3(eq,String(gt),options)||lt&&!satisfies3(eq,String(lt),options))return null;for(let c of dom)if(!satisfies3(eq,String(c),options))return!1;return!0}let higher,lower,hasDomLT,hasDomGT,needDomLTPre=lt&&!options.includePrerelease&<.semver.prerelease.length?lt.semver:!1,needDomGTPre=gt&&!options.includePrerelease&>.semver.prerelease.length?gt.semver:!1;needDomLTPre&&needDomLTPre.prerelease.length===1&<.operator==="<"&&needDomLTPre.prerelease[0]===0&&(needDomLTPre=!1);for(let c of dom){if(hasDomGT=hasDomGT||c.operator===">"||c.operator===">=",hasDomLT=hasDomLT||c.operator==="<"||c.operator==="<=",gt){if(needDomGTPre&&c.semver.prerelease&&c.semver.prerelease.length&&c.semver.major===needDomGTPre.major&&c.semver.minor===needDomGTPre.minor&&c.semver.patch===needDomGTPre.patch&&(needDomGTPre=!1),c.operator===">"||c.operator===">="){if(higher=higherGT(gt,c,options),higher===c&&higher!==gt)return!1}else if(gt.operator===">="&&!c.test(gt.semver))return!1}if(lt){if(needDomLTPre&&c.semver.prerelease&&c.semver.prerelease.length&&c.semver.major===needDomLTPre.major&&c.semver.minor===needDomLTPre.minor&&c.semver.patch===needDomLTPre.patch&&(needDomLTPre=!1),c.operator==="<"||c.operator==="<="){if(lower=lowerLT(lt,c,options),lower===c&&lower!==lt)return!1}else if(lt.operator==="<="&&!c.test(lt.semver))return!1}if(!c.operator&&(lt||gt)&>ltComp!==0)return!1}return!(gt&&hasDomLT&&!lt&>ltComp!==0||lt&&hasDomGT&&!gt&>ltComp!==0||needDomGTPre||needDomLTPre)},higherGT=(a,b,options)=>{if(!a)return b;let comp=compare(a.semver,b.semver,options);return comp>0?a:comp<0||b.operator===">"&&a.operator===">="?b:a},lowerLT=(a,b,options)=>{if(!a)return b;let comp=compare(a.semver,b.semver,options);return comp<0?a:comp>0||b.operator==="<"&&a.operator==="<="?b:a};module.exports=subset}});var require_semver2=__commonJS({"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/index.js"(exports,module){"use strict";var internalRe=require_re(),constants2=require_constants(),SemVer=require_semver(),identifiers=require_identifiers(),parse=require_parse(),valid4=require_valid(),clean=require_clean(),inc=require_inc(),diff=require_diff(),major=require_major(),minor=require_minor(),patch=require_patch(),prerelease=require_prerelease(),compare=require_compare(),rcompare=require_rcompare(),compareLoose=require_compare_loose(),compareBuild=require_compare_build(),sort=require_sort(),rsort=require_rsort(),gt=require_gt(),lt=require_lt(),eq=require_eq(),neq=require_neq(),gte=require_gte(),lte=require_lte(),cmp=require_cmp(),coerce=require_coerce(),truncate=require_truncate(),Comparator=require_comparator(),Range=require_range(),satisfies3=require_satisfies(),toComparators=require_to_comparators(),maxSatisfying=require_max_satisfying(),minSatisfying=require_min_satisfying(),minVersion=require_min_version(),validRange3=require_valid2(),outside=require_outside(),gtr=require_gtr(),ltr=require_ltr(),intersects=require_intersects(),simplifyRange=require_simplify(),subset=require_subset();module.exports={parse,valid:valid4,clean,inc,diff,major,minor,patch,prerelease,compare,rcompare,compareLoose,compareBuild,sort,rsort,gt,lt,eq,neq,gte,lte,cmp,coerce,truncate,Comparator,Range,satisfies:satisfies3,toComparators,maxSatisfying,minSatisfying,minVersion,validRange:validRange3,outside,gtr,ltr,intersects,simplifyRange,subset,SemVer,re:internalRe.re,src:internalRe.src,tokens:internalRe.t,SEMVER_SPEC_VERSION:constants2.SEMVER_SPEC_VERSION,RELEASE_TYPES:constants2.RELEASE_TYPES,compareIdentifiers:identifiers.compareIdentifiers,rcompareIdentifiers:identifiers.rcompareIdentifiers}}});import{createHash}from"node:crypto";import{createRequire}from"node:module";import{Script}from"node:vm";import{constants}from"node:fs";import{lstat,open}from"node:fs/promises";import{join as join2}from"node:path";import{join}from"node:path";import{homedir}from"node:os";var DAEMON_HOME=join(homedir(),".mearl");var import_semver=__toESM(require_semver2(),1),PresetError=class extends Error{code;constructor(code,message){super(`${code}: ${message}`),this.code=code,this.name="PresetError"}},unsafeKeys=new Set(["__proto__","constructor","prototype"]);function invalid(path,reason){throw new PresetError("PRESET_INVALID",`${path}: ${reason}`)}function isJsonObject(value){return value!==null&&typeof value=="object"&&!Array.isArray(value)&&(Object.getPrototypeOf(value)===Object.prototype||Object.getPrototypeOf(value)===null)}function object(value,path){isJsonObject(value)||invalid(path,"expected a plain object");for(let key of Object.keys(value))unsafeKeys.has(key)&&invalid(path,`unsafe key ${key}`)}function json(value,path,depth=0){return depth>32&&invalid(path,"JSON nesting exceeds 32 levels"),value===null||typeof value=="string"||typeof value=="boolean"||typeof value=="number"&&Number.isFinite(value)?value:Array.isArray(value)?Array.from(value,(item,index)=>json(item,`${path}[${index}]`,depth+1)):(object(value,path),Object.fromEntries(Object.entries(value).map(([key,item])=>[key,json(item,`${path}.${key}`,depth+1)])))}function clonePresetDefaults(value){return object(value,"defaults"),json(value,"defaults")}var import_semver2=__toESM(require_semver2(),1);var import_semver3=__toESM(require_semver2(),1);var MAX_BUNDLE_BYTES=16*1024*1024,MAX_BUNDLE_MANIFEST_BYTES=64*1024,MAX_BROWSER_STORAGE_BYTES=64*1024*1024,MAX_PAGE_RUNTIME_BYTES=2*1024*1024,MAX_REQUEST_UI_BYTES=64*1024,BundleError=class extends Error{code;constructor(code,message){super(`${code}: ${message}`),this.code=code,this.name="BundleError"}};async function bundleDigest(bytes){let digest2=await crypto.subtle.digest("SHA-256",Uint8Array.from(bytes).buffer);return Array.from(new Uint8Array(digest2),byte=>byte.toString(16).padStart(2,"0")).join("")}var MAX_NODE_SELECTION_BYTES=262144,identifier=/^[a-z][a-z0-9-]{0,79}$/,hookName=/^[a-z][a-zA-Z0-9_.-]{0,127}$/,digest=/^[a-f0-9]{64}$/;function invalid2(message){throw new BundleError("BUNDLE_INVALID",message)}function fields(value,allowed){(!isJsonObject(value)||Object.keys(value).some(key=>!allowed.includes(key)))&&invalid2("Invalid Node capability selection structure")}async function prepareNodeCapabilitySnapshot(input){let value=clonePresetDefaults(input);if(fields(value,["schemaVersion","modules","bindings"]),(value.schemaVersion!==1||!isJsonObject(value.modules)||!isJsonObject(value.bindings))&&invalid2("Invalid Node capability selection"),Object.keys(value.modules).length>64||Object.keys(value.bindings).length>256)throw new BundleError("BUNDLE_QUOTA","Node capability selection exceeds the entry limit");let modules={},total=0;for(let id of Object.keys(value.modules).sort()){identifier.test(id)||invalid2("Invalid Node module ID");let entry=value.modules[id];if(fields(entry,["sha256","byteLength","config"]),(typeof entry.sha256!="string"||!digest.test(entry.sha256)||typeof entry.byteLength!="number"||!Number.isSafeInteger(entry.byteLength)||entry.byteLength<=0||entry.byteLength>MAX_BUNDLE_BYTES)&&invalid2("Invalid Node module resource"),entry.config!==void 0&&!isJsonObject(entry.config)&&invalid2("Node module configuration must be a JSON object"),total+=entry.byteLength,total>MAX_BROWSER_STORAGE_BYTES)throw new BundleError("BUNDLE_QUOTA","Node capability resources exceed 64 MiB");modules[id]={sha256:entry.sha256,byteLength:entry.byteLength,...entry.config===void 0?{}:{config:clonePresetDefaults(entry.config)}}}let bindings={};for(let name of Object.keys(value.bindings).sort()){hookName.test(name)||invalid2("Invalid Node hook name");let binding=value.bindings[name];fields(binding,["module","handler"]),(typeof binding.module!="string"||!Object.hasOwn(modules,binding.module)||typeof binding.handler!="string"||!hookName.test(binding.handler))&&invalid2("Node hook must bind a declared module handler"),bindings[name]={module:binding.module,handler:binding.handler}}let selection={schemaVersion:1,modules,bindings};if(new TextEncoder().encode(JSON.stringify(selection)).byteLength+80>MAX_NODE_SELECTION_BYTES)throw new BundleError("BUNDLE_QUOTA","Node capability selection metadata exceeds 256 KiB");return{...selection,revision:await bundleDigest(new TextEncoder().encode(JSON.stringify(selection)))}}async function verifyNodeCapabilitySnapshot(input){let value=clonePresetDefaults(input);fields(value,["schemaVersion","modules","bindings","revision"]),(typeof value.revision!="string"||!digest.test(value.revision))&&invalid2("Invalid Node capability revision");let{revision,...selection}=value,prepared=await prepareNodeCapabilitySnapshot(selection);if(prepared.revision!==revision)throw new BundleError("BUNDLE_INTEGRITY","Node capability selection revision does not match");return prepared}async function verifyNodeCapabilityActivation(input){let value=clonePresetDefaults(input),{installationRevision,...selection}=value;return installationRevision!==void 0&&(typeof installationRevision!="string"||!digest.test(installationRevision))&&invalid2("Invalid capability installation revision"),{...await verifyNodeCapabilitySnapshot(selection),...installationRevision===void 0?{}:{installationRevision}}}var MAX_SELECTION_BYTES=MAX_NODE_SELECTION_BYTES+128,handlerName=/^[a-z][a-zA-Z0-9_.-]{0,127}$/;async function readBoundedFile(file,limit){let stat=await lstat(file);if(!stat.isFile()||stat.isSymbolicLink()||stat.size>limit)throw new Error("Invalid Node capability resource file");let handle=await open(file,constants.O_RDONLY|(constants.O_NOFOLLOW??0));try{let opened=await handle.stat();if(!opened.isFile()||opened.size>limit)throw new Error("Invalid Node capability resource file");let bytes=Buffer.alloc(limit+1),length=0;for(;length<bytes.byteLength;){let read=await handle.read(bytes,length,bytes.byteLength-length,null);if(read.bytesRead===0)break;length+=read.bytesRead}if(length>limit)throw new Error("Node capability resource exceeds its declared size");return bytes.subarray(0,length)}finally{await handle.close()}}var NodeCapabilityRegistry=class{directory;active;queue=Promise.resolve();host;hooks;constructor(host,directory=join2(DAEMON_HOME,"capabilities"),options={}){if(options.hooks&&(options.hooks.length>256||options.hooks.some(name=>!handlerName.test(name))))throw new Error("Invalid Node hook selection");this.hooks=options.hooks?new Set(options.hooks):void 0,this.directory=directory,this.host=Object.freeze({...host})}get revision(){return this.active?.snapshot.revision}get installationRevision(){return this.active?.snapshot.installationRevision}get(name){return this.active&&Object.hasOwn(this.active.handlers,name)?this.active.handlers[name]:void 0}require(name){let handler=this.get(name);if(!handler)throw new Error(`Required capability is not installed: ${name}. Enable the preset that provides it.`);return handler}refresh(){let result=this.queue.catch(()=>{}).then(async()=>{let selection;try{return selection=await this.readSelection(),await this.load(selection)}catch(error){throw this.active||await this.restorePrevious(selection).catch(()=>{}),error}});return this.queue=result,result}async readSelection(){let file=join2(this.directory,"active-node.json"),bytes;try{bytes=await readBoundedFile(file,MAX_SELECTION_BYTES)}catch(error){if(error.code==="ENOENT")return;throw error}return verifyNodeCapabilityActivation(JSON.parse(bytes.toString("utf8")))}async load(snapshot){if(!snapshot){this.active=void 0;return}return snapshot.revision===this.active?.snapshot.revision?(this.active.snapshot=snapshot,snapshot.revision):this.prepareSelection(snapshot,async()=>{let current=await this.readSelection();return current?.revision===snapshot.revision?current:void 0})}async restorePrevious(failed){let pointer=join2(this.directory,"active-node.json"),bytes=await readBoundedFile(pointer,MAX_SELECTION_BYTES),requested=JSON.parse(bytes.toString("utf8")),current=await verifyNodeCapabilityActivation(requested).catch(()=>{});if(current&&(current.revision!==failed?.revision||current.installationRevision!==failed?.installationRevision))try{await this.load(current);return}catch{}if(typeof requested.installationRevision!="string"||!/^[a-f0-9]{64}$/.test(requested.installationRevision))return;let record=JSON.parse((await readBoundedFile(join2(this.directory,"rollback.json"),MAX_SELECTION_BYTES+256)).toString("utf8"));if(record.candidate!==requested.installationRevision||!record.previous)return;let previous=await verifyNodeCapabilityActivation(record.previous),expected=createHash("sha256").update(bytes).digest("hex");await this.prepareSelection(previous,async()=>{let current2=await readBoundedFile(pointer,MAX_SELECTION_BYTES);return createHash("sha256").update(current2).digest("hex")===expected?previous:void 0})}async prepareSelection(snapshot,guard){let bindings=Object.entries(snapshot.bindings).filter(([name])=>!this.hooks||this.hooks.has(name)),selected=new Set(bindings.map(([,binding])=>binding.module)),entries=Object.entries(snapshot.modules).filter(([id])=>!this.hooks||selected.has(id)),resources=new Map;for(let[id,resource]of entries){let file=join2(this.directory,"objects",`${resource.sha256}.cjs`),bytes=await readBoundedFile(file,resource.byteLength);if(bytes.byteLength!==resource.byteLength||createHash("sha256").update(bytes).digest("hex")!==resource.sha256)throw new Error(`Node capability integrity check failed: ${id}`);resources.set(id,bytes)}let modules=new Map;for(let[id,resource]of entries){let bytes=resources.get(id),module={exports:{}};new Script(`(function(module,exports,require){
|
|
3
|
+
${bytes.toString("utf8")}
|
|
4
|
+
})`,{filename:`mearl-capability-${resource.sha256}.cjs`}).runInThisContext()(module,module.exports,createRequire(import.meta.url));let loaded={default:typeof module.exports=="function"?module.exports:module.exports?.default};if(typeof loaded.default!="function")throw new Error(`Node capability ${id} requires a default factory`);let handlers2=await loaded.default(this.host,structuredClone(resource.config??{}));if(!handlers2||typeof handlers2!="object"||Array.isArray(handlers2)||Object.keys(handlers2).length>256||Object.entries(handlers2).some(([name,handler])=>!handlerName.test(name)||typeof handler!="function"))throw new Error(`Invalid Node capability handlers: ${id}`);modules.set(id,handlers2)}let handlers={};for(let[name,binding]of bindings){let module=modules.get(binding.module),handler=Object.hasOwn(module,binding.handler)?module[binding.handler]:void 0;if(typeof handler!="function")throw new Error(`Node capability handler is missing: ${name}`);handlers[name]=handler}let current=await guard();if(!current)throw new Error("Node capability selection changed while preparing modules");return this.active={snapshot:current,handlers:Object.freeze(handlers)},snapshot.revision}};export{NodeCapabilityRegistry};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type PageRuntimeBinding } from '@mearl/preset/bundles';
|
|
2
|
+
export interface PageRuntimeOwner {
|
|
3
|
+
browser: string;
|
|
4
|
+
target: string;
|
|
5
|
+
pid?: number;
|
|
6
|
+
processIdentity?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const MAX_NODE_PAGE_CACHE_BYTES: number;
|
|
9
|
+
export declare function nativeCapabilityDirectory(): string;
|
|
10
|
+
/** Browser references survive host restarts; unavailable remote browsers retain their exact code. */
|
|
11
|
+
export declare class NodePageRuntimeStore {
|
|
12
|
+
private readonly quota;
|
|
13
|
+
private readonly root;
|
|
14
|
+
private readonly index;
|
|
15
|
+
constructor(directory?: string, quota?: number);
|
|
16
|
+
resolve(binding: PageRuntimeBinding, provide?: (binding: PageRuntimeBinding) => string | undefined, owner?: PageRuntimeOwner): string;
|
|
17
|
+
release(owner: PageRuntimeOwner): void;
|
|
18
|
+
retain(owner: PageRuntimeOwner, binding?: PageRuntimeBinding): void;
|
|
19
|
+
/** A live target inventory is authoritative after a disconnected host lost close events. */
|
|
20
|
+
reconcile(browser: string, targets: ReadonlySet<string>): void;
|
|
21
|
+
private key;
|
|
22
|
+
private mutate;
|
|
23
|
+
private collect;
|
|
24
|
+
private read;
|
|
25
|
+
private write;
|
|
26
|
+
private verify;
|
|
27
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface PersistentBrowserProcessRecord {
|
|
2
|
+
pid: number;
|
|
3
|
+
hostPid?: number;
|
|
4
|
+
persistent?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** Keep restart metadata only when closing a persistent Profile without deleting it. */
|
|
7
|
+
export declare function stoppedPersistentBrowserRecord<T extends PersistentBrowserProcessRecord>(record: T, deleteProfile: boolean): T | null;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PluginExecutionContext } from '@mearl/client/plugin';
|
|
2
|
+
export declare function callPluginPageService(plugin: string, input: Record<string, unknown>, invoke: () => PluginExecutionContext['invoke'], event?: boolean, interactive?: boolean, scope?: string): Promise<any>;
|
|
3
|
+
export declare function callPluginStateService(plugin: string, input: Record<string, unknown>, invoke: () => PluginExecutionContext['invoke']): Promise<any>;
|
|
4
|
+
export declare function callPluginModelService(plugin: string, input: Record<string, any>, invoke: () => PluginExecutionContext['invoke'], execution?: {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
onProgress?: (progress: any) => void;
|
|
7
|
+
}): Promise<unknown>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Bounds native-messaging replies independently of the local service transport. */
|
|
2
|
+
export declare class PluginPageResults {
|
|
3
|
+
private readonly values;
|
|
4
|
+
private prune;
|
|
5
|
+
wrap(plugin: string, value: unknown): unknown;
|
|
6
|
+
read(plugin: string, operation: string, input: Record<string, any>): unknown;
|
|
7
|
+
}
|