@frontmcp/utils 0.12.2 → 1.0.0-beta.1
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/async-context/browser-async-context.d.ts +12 -0
- package/async-context/browser-async-context.js +49 -0
- package/async-context/index.d.ts +1 -0
- package/async-context/node-async-context.d.ts +1 -0
- package/async-context/node-async-context.js +30 -0
- package/crypto/browser.d.ts +16 -0
- package/crypto/browser.js +160 -0
- package/crypto/index.d.ts +15 -6
- package/crypto/jwt-alg.d.ts +5 -0
- package/crypto/key-persistence/factory.d.ts +8 -1
- package/crypto/key-persistence/types.d.ts +10 -2
- package/crypto/node.d.ts +2 -0
- package/crypto/node.js +185 -0
- package/env/browser-env.d.ts +17 -0
- package/env/browser-env.js +78 -0
- package/env/index.d.ts +1 -0
- package/env/node-env.d.ts +14 -0
- package/env/node-env.js +85 -0
- package/esm/async-context/browser-async-context.mjs +24 -0
- package/esm/async-context/node-async-context.mjs +5 -0
- package/esm/crypto/browser.mjs +131 -0
- package/esm/crypto/node.mjs +143 -0
- package/esm/env/browser-env.mjs +44 -0
- package/esm/env/node-env.mjs +51 -0
- package/esm/event-emitter/browser-event-emitter.mjs +49 -0
- package/esm/event-emitter/node-event-emitter.mjs +5 -0
- package/esm/index.mjs +3887 -3064
- package/event-emitter/browser-event-emitter.d.ts +19 -0
- package/event-emitter/browser-event-emitter.js +74 -0
- package/event-emitter/index.d.ts +1 -0
- package/event-emitter/node-event-emitter.d.ts +1 -0
- package/event-emitter/node-event-emitter.js +30 -0
- package/index.d.ts +14 -5
- package/index.js +4144 -3314
- package/llm/index.d.ts +2 -0
- package/llm/llm-tool-handler.types.d.ts +48 -0
- package/llm/llm-tool-handlers.d.ts +10 -0
- package/naming/index.d.ts +2 -1
- package/package.json +23 -1
- package/path/browser-path.d.ts +5 -0
- package/path/index.d.ts +1 -0
- package/path/node-path.d.ts +1 -0
- package/storage/adapters/index.d.ts +4 -0
- package/storage/adapters/indexeddb.d.ts +77 -0
- package/storage/adapters/localstorage.d.ts +84 -0
- package/storage/index.d.ts +2 -2
- package/uri/index.d.ts +2 -1
- package/esm/package.json +0 -69
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight browser polyfill for Node's EventEmitter.
|
|
3
|
+
*
|
|
4
|
+
* Implements the subset used by the FrontMCP codebase:
|
|
5
|
+
* emit, on, off, removeAllListeners, setMaxListeners, listenerCount.
|
|
6
|
+
*/
|
|
7
|
+
type Listener = Function;
|
|
8
|
+
export declare class EventEmitter {
|
|
9
|
+
private events;
|
|
10
|
+
emit(event: string | symbol, ...args: unknown[]): boolean;
|
|
11
|
+
on(event: string | symbol, handler: Listener): this;
|
|
12
|
+
off(event: string | symbol, handler: Listener): this;
|
|
13
|
+
addListener(event: string | symbol, handler: Listener): this;
|
|
14
|
+
removeListener(event: string | symbol, handler: Listener): this;
|
|
15
|
+
removeAllListeners(event?: string | symbol): this;
|
|
16
|
+
setMaxListeners(_n: number): this;
|
|
17
|
+
listenerCount(event: string | symbol): number;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// libs/utils/src/event-emitter/browser-event-emitter.ts
|
|
21
|
+
var browser_event_emitter_exports = {};
|
|
22
|
+
__export(browser_event_emitter_exports, {
|
|
23
|
+
EventEmitter: () => EventEmitter
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(browser_event_emitter_exports);
|
|
26
|
+
var EventEmitter = class {
|
|
27
|
+
events = /* @__PURE__ */ new Map();
|
|
28
|
+
emit(event, ...args) {
|
|
29
|
+
const handlers = this.events.get(event);
|
|
30
|
+
if (!handlers || handlers.length === 0) return false;
|
|
31
|
+
for (const handler of [...handlers]) {
|
|
32
|
+
handler(...args);
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
on(event, handler) {
|
|
37
|
+
const list = this.events.get(event) ?? [];
|
|
38
|
+
list.push(handler);
|
|
39
|
+
this.events.set(event, list);
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
off(event, handler) {
|
|
43
|
+
const list = this.events.get(event);
|
|
44
|
+
if (list) {
|
|
45
|
+
const idx = list.indexOf(handler);
|
|
46
|
+
if (idx >= 0) list.splice(idx, 1);
|
|
47
|
+
}
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
addListener(event, handler) {
|
|
51
|
+
return this.on(event, handler);
|
|
52
|
+
}
|
|
53
|
+
removeListener(event, handler) {
|
|
54
|
+
return this.off(event, handler);
|
|
55
|
+
}
|
|
56
|
+
removeAllListeners(event) {
|
|
57
|
+
if (event !== void 0) {
|
|
58
|
+
this.events.delete(event);
|
|
59
|
+
} else {
|
|
60
|
+
this.events.clear();
|
|
61
|
+
}
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
setMaxListeners(_n) {
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
listenerCount(event) {
|
|
68
|
+
return this.events.get(event)?.length ?? 0;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
EventEmitter
|
|
74
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EventEmitter } from '#event-emitter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EventEmitter } from 'events';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// libs/utils/src/event-emitter/node-event-emitter.ts
|
|
21
|
+
var node_event_emitter_exports = {};
|
|
22
|
+
__export(node_event_emitter_exports, {
|
|
23
|
+
EventEmitter: () => import_events.EventEmitter
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(node_event_emitter_exports);
|
|
26
|
+
var import_events = require("events");
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
EventEmitter
|
|
30
|
+
});
|
package/index.d.ts
CHANGED
|
@@ -5,14 +5,23 @@
|
|
|
5
5
|
* Provides generic, protocol-neutral utilities for string manipulation,
|
|
6
6
|
* URI handling, path operations, content processing, and more.
|
|
7
7
|
*/
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
8
|
+
export { splitWords, toCase, sepFor, shortHash, ensureMaxLen, idFromString } from './naming';
|
|
9
|
+
export type { NameCase } from './naming';
|
|
10
|
+
export { isValidMcpUri, extractUriScheme, isValidMcpUriTemplate, parseUriTemplate, matchUriTemplate, expandUriTemplate, extractTemplateParams, isUriTemplate, } from './uri';
|
|
11
|
+
export type { ParsedUriTemplate } from './uri';
|
|
12
|
+
export { trimSlashes, joinPath, pathResolve, pathJoin, basename, dirname, extname } from './path';
|
|
11
13
|
export { sanitizeToJson, inferMimeType } from './content';
|
|
12
14
|
export { validateBaseUrl } from './http';
|
|
13
15
|
export { readFile, readFileSync, readFileBuffer, writeFile, mkdir, rename, unlink, stat, copyFile, cp, readdir, rm, mkdtemp, access, fileExists, readJSON, writeJSON, ensureDir, isDirEmpty, runCmd, } from './fs';
|
|
14
16
|
export { escapeHtml, escapeHtmlAttr, escapeJsString, escapeScriptClose, safeJsonForScript } from './escape';
|
|
15
17
|
export { safeStringify } from './serialization';
|
|
16
|
-
export { getCrypto, rsaVerify, jwtAlgToNodeAlg, isRsaPssAlg, randomUUID, randomBytes, sha256, sha256Hex, sha256Base64url, hmacSha256, hkdfSha256, encryptAesGcm, decryptAesGcm, timingSafeEqual, bytesToHex, base64urlEncode, base64urlDecode, base64Encode, base64Decode, isNode, isBrowser, assertNode,
|
|
18
|
+
export { getCrypto, rsaVerify, jwtAlgToNodeAlg, isRsaPssAlg, randomUUID, randomBytes, sha256, sha256Hex, sha256Base64url, hmacSha256, hkdfSha256, encryptAesGcm, decryptAesGcm, timingSafeEqual, bytesToHex, base64urlEncode, base64urlDecode, base64Encode, base64Decode, isNode, isBrowser, assertNode, EncryptedBlobError, encryptValue, decryptValue, tryDecryptValue, serializeBlob, deserializeBlob, tryDeserializeBlob, isValidEncryptedBlob, encryptAndSerialize, deserializeAndDecrypt, tryDeserializeAndDecrypt, generateCodeVerifier, generateCodeChallenge, verifyCodeChallenge, generatePkcePair, isValidCodeVerifier, isValidCodeChallenge, MIN_CODE_VERIFIER_LENGTH, MAX_CODE_VERIFIER_LENGTH, DEFAULT_CODE_VERIFIER_LENGTH, PkceError, type PkcePair, type SecretData, type SecretPersistenceOptions, type SecretValidationResult, secretDataSchema, validateSecretData, parseSecretData, isSecretPersistenceEnabled, resolveSecretPath, loadSecret, saveSecret, deleteSecret, generateSecret, createSecretData, getOrCreateSecret, clearCachedSecret, isSecretCached, type SignedData, type HmacSigningConfig, signData, verifyData, isSignedData, verifyOrParseData, type BaseKeyData, type SecretKeyData, type AsymmetricKeyData, type AnyKeyData, type KeyPersistenceOptions, type CreateKeyPersistenceOptions, type CreateSecretOptions, type CreateAsymmetricOptions, type KeyValidationResult, asymmetricAlgSchema, secretKeyDataSchema, asymmetricKeyDataSchema, anyKeyDataSchema, validateKeyData, parseKeyData, isSecretKeyData, isAsymmetricKeyData, KeyPersistence, createKeyPersistence, createKeyPersistenceWithStorage, } from './crypto';
|
|
19
|
+
export type { CryptoProvider, EncBlob, EncryptedBlob } from './crypto';
|
|
20
|
+
export { AsyncLocalStorage } from './async-context';
|
|
21
|
+
export { EventEmitter } from './event-emitter';
|
|
22
|
+
export { getEnv, getCwd, isProduction, isDevelopment, getEnvFlag, isDebug, setEnv, isEdgeRuntime, isServerless, supportsAnsi, } from './env';
|
|
17
23
|
export { analyzePattern, isPatternSafe, createSafeRegExp, safeTest, safeMatch, safeReplace, safeExec, isInputLengthSafe, DEFAULT_MAX_INPUT_LENGTH, REDOS_THRESHOLDS, trimLeading, trimTrailing, trimBoth, trimChars, extractBracedParams, expandTemplate, hasTemplatePlaceholders, collapseChar, collapseWhitespace, type SafeRegexOptions, type PatternAnalysisResult, } from './regex';
|
|
18
|
-
export { createStorage, createMemoryStorage, getDetectedStorageType,
|
|
24
|
+
export { createStorage, createMemoryStorage, getDetectedStorageType, NamespacedStorageImpl, createRootStorage, createNamespacedStorage, buildPrefix, NAMESPACE_SEPARATOR, StorageError, StorageConnectionError, StorageOperationError, StorageNotSupportedError, StorageConfigError, StorageTTLError, StoragePatternError, StorageNotConnectedError, EncryptedStorageError, BaseStorageAdapter, MemoryStorageAdapter, RedisStorageAdapter, VercelKvStorageAdapter, UpstashStorageAdapter, FileSystemStorageAdapter, type FileSystemAdapterOptions, TypedStorage, type TypedStorageOptions, type TypedSetOptions, type TypedSetEntry, EncryptedTypedStorage, type EncryptedTypedStorageOptions, type EncryptedSetOptions, type EncryptedSetEntry, type EncryptionKey, type StoredEncryptedBlob, type ClientKeyBinding, globToRegex, matchesPattern, validatePattern, escapeGlob, MAX_TTL_SECONDS, validateTTL, validateOptionalTTL, ttlToExpiresAt, expiresAtToTTL, isExpired, normalizeTTL, } from './storage';
|
|
25
|
+
export type { StorageAdapter, NamespacedStorage, RootStorage, SetOptions, SetEntry, MessageHandler, Unsubscribe, MemoryAdapterOptions, RedisAdapterOptions, VercelKvAdapterOptions, UpstashAdapterOptions, StorageType, StorageConfig, } from './storage';
|
|
26
|
+
export { processPlatformToolCalls } from './llm';
|
|
27
|
+
export type { CallToolFn, OpenAIToolCallItem, OpenAIToolResponse, ClaudeToolUseBlock, ClaudeToolResultBlock, VercelToolCallInfo, PlatformToolCallsInput, PlatformToolCallsOutput, SupportedPlatform, } from './llm';
|