@gravito/radiance 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -7
- package/README.zh-TW.md +238 -3
- package/dist/core/src/Application.d.ts +256 -0
- package/dist/core/src/CommandKernel.d.ts +33 -0
- package/dist/core/src/ConfigManager.d.ts +65 -0
- package/dist/core/src/Container/RequestScopeManager.d.ts +62 -0
- package/dist/core/src/Container/RequestScopeMetrics.d.ts +144 -0
- package/dist/core/src/Container.d.ts +153 -0
- package/dist/core/src/ErrorHandler.d.ts +66 -0
- package/dist/core/src/Event.d.ts +5 -0
- package/dist/core/src/EventManager.d.ts +123 -0
- package/dist/core/src/GlobalErrorHandlers.d.ts +47 -0
- package/dist/core/src/GravitoServer.d.ts +28 -0
- package/dist/core/src/HookManager.d.ts +435 -0
- package/dist/core/src/Listener.d.ts +4 -0
- package/dist/core/src/Logger.d.ts +20 -0
- package/dist/core/src/PlanetCore.d.ts +402 -0
- package/dist/core/src/RequestContext.d.ts +97 -0
- package/dist/core/src/Route.d.ts +36 -0
- package/dist/core/src/Router.d.ts +270 -0
- package/dist/core/src/ServiceProvider.d.ts +178 -0
- package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +27 -0
- package/dist/core/src/adapters/bun/BunContext.d.ts +54 -0
- package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +66 -0
- package/dist/core/src/adapters/bun/BunRequest.d.ts +31 -0
- package/dist/core/src/adapters/bun/BunWebSocketHandler.d.ts +48 -0
- package/dist/core/src/adapters/bun/RadixNode.d.ts +19 -0
- package/dist/core/src/adapters/bun/RadixRouter.d.ts +32 -0
- package/dist/core/src/adapters/bun/index.d.ts +7 -0
- package/dist/core/src/adapters/bun/types.d.ts +20 -0
- package/dist/core/src/adapters/types.d.ts +235 -0
- package/dist/core/src/binary/BinaryUtils.d.ts +105 -0
- package/dist/core/src/binary/index.d.ts +5 -0
- package/dist/core/src/cli/queue-commands.d.ts +6 -0
- package/dist/core/src/compat/async-local-storage.d.ts +7 -0
- package/dist/core/src/compat/crypto.d.ts +6 -0
- package/dist/core/src/engine/AOTRouter.d.ts +139 -0
- package/dist/core/src/engine/FastContext.d.ts +141 -0
- package/dist/core/src/engine/Gravito.d.ts +131 -0
- package/dist/core/src/engine/MinimalContext.d.ts +102 -0
- package/dist/core/src/engine/analyzer.d.ts +113 -0
- package/dist/core/src/engine/constants.d.ts +23 -0
- package/dist/core/src/engine/index.d.ts +26 -0
- package/dist/core/src/engine/path.d.ts +26 -0
- package/dist/core/src/engine/pool.d.ts +83 -0
- package/dist/core/src/engine/types.d.ts +149 -0
- package/dist/core/src/error-handling/RequestScopeErrorContext.d.ts +126 -0
- package/dist/core/src/events/BackpressureManager.d.ts +215 -0
- package/dist/core/src/events/CircuitBreaker.d.ts +229 -0
- package/dist/core/src/events/DeadLetterQueue.d.ts +219 -0
- package/dist/core/src/events/EventBackend.d.ts +12 -0
- package/dist/core/src/events/EventOptions.d.ts +204 -0
- package/dist/core/src/events/EventPriorityQueue.d.ts +63 -0
- package/dist/core/src/events/FlowControlStrategy.d.ts +109 -0
- package/dist/core/src/events/IdempotencyCache.d.ts +60 -0
- package/dist/core/src/events/MessageQueueBridge.d.ts +184 -0
- package/dist/core/src/events/PriorityEscalationManager.d.ts +82 -0
- package/dist/core/src/events/RetryScheduler.d.ts +104 -0
- package/dist/core/src/events/WorkerPool.d.ts +98 -0
- package/dist/core/src/events/WorkerPoolConfig.d.ts +153 -0
- package/dist/core/src/events/WorkerPoolMetrics.d.ts +65 -0
- package/dist/core/src/events/aggregation/AggregationWindow.d.ts +77 -0
- package/dist/core/src/events/aggregation/DeduplicationManager.d.ts +135 -0
- package/dist/core/src/events/aggregation/EventAggregationManager.d.ts +108 -0
- package/dist/core/src/events/aggregation/EventBatcher.d.ts +99 -0
- package/dist/core/src/events/aggregation/types.d.ts +117 -0
- package/dist/core/src/events/index.d.ts +26 -0
- package/dist/core/src/events/observability/EventMetrics.d.ts +132 -0
- package/dist/core/src/events/observability/EventTracer.d.ts +68 -0
- package/dist/core/src/events/observability/EventTracing.d.ts +161 -0
- package/dist/core/src/events/observability/OTelEventMetrics.d.ts +332 -0
- package/dist/core/src/events/observability/ObservableHookManager.d.ts +108 -0
- package/dist/core/src/events/observability/StreamWorkerMetrics.d.ts +76 -0
- package/dist/core/src/events/observability/index.d.ts +24 -0
- package/dist/core/src/events/observability/metrics-types.d.ts +16 -0
- package/dist/core/src/events/queue-core.d.ts +77 -0
- package/dist/core/src/events/task-executor.d.ts +51 -0
- package/dist/core/src/events/types.d.ts +134 -0
- package/dist/core/src/exceptions/AuthenticationException.d.ts +8 -0
- package/dist/core/src/exceptions/AuthorizationException.d.ts +8 -0
- package/dist/core/src/exceptions/CircularDependencyException.d.ts +9 -0
- package/dist/core/src/exceptions/GravitoException.d.ts +23 -0
- package/dist/core/src/exceptions/HttpException.d.ts +9 -0
- package/dist/core/src/exceptions/ModelNotFoundException.d.ts +10 -0
- package/dist/core/src/exceptions/ValidationException.d.ts +22 -0
- package/dist/core/src/exceptions/index.d.ts +7 -0
- package/dist/core/src/ffi/NativeAccelerator.d.ts +62 -0
- package/dist/core/src/ffi/NativeHasher.d.ts +139 -0
- package/dist/core/src/ffi/cbor-fallback.d.ts +96 -0
- package/dist/core/src/ffi/hash-fallback.d.ts +33 -0
- package/dist/core/src/ffi/index.d.ts +10 -0
- package/dist/core/src/ffi/types.d.ts +135 -0
- package/dist/core/src/health/HealthProvider.d.ts +67 -0
- package/dist/core/src/helpers/Arr.d.ts +19 -0
- package/dist/core/src/helpers/Str.d.ts +38 -0
- package/dist/core/src/helpers/data.d.ts +25 -0
- package/dist/core/src/helpers/errors.d.ts +34 -0
- package/dist/core/src/helpers/response.d.ts +41 -0
- package/dist/core/src/helpers.d.ts +338 -0
- package/dist/core/src/hooks/ActionManager.d.ts +132 -0
- package/dist/core/src/hooks/AsyncDetector.d.ts +84 -0
- package/dist/core/src/hooks/FilterManager.d.ts +71 -0
- package/dist/core/src/hooks/MigrationWarner.d.ts +24 -0
- package/dist/core/src/hooks/dlq-operations.d.ts +60 -0
- package/dist/core/src/hooks/types.d.ts +107 -0
- package/dist/core/src/http/CookieJar.d.ts +51 -0
- package/dist/core/src/http/cookie.d.ts +29 -0
- package/dist/core/src/http/types.d.ts +395 -0
- package/dist/core/src/index.d.ts +565 -0
- package/dist/core/src/observability/QueueDashboard.d.ts +136 -0
- package/dist/core/src/observability/contracts.d.ts +137 -0
- package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +349 -0
- package/dist/core/src/reliability/RetryPolicy.d.ts +217 -0
- package/dist/core/src/reliability/index.d.ts +6 -0
- package/dist/core/src/router/ControllerDispatcher.d.ts +12 -0
- package/dist/core/src/router/RequestValidator.d.ts +20 -0
- package/dist/core/src/runtime/adapter-bun.d.ts +12 -0
- package/dist/core/src/runtime/adapter-deno.d.ts +12 -0
- package/dist/core/src/runtime/adapter-node.d.ts +12 -0
- package/dist/core/src/runtime/adapter-unknown.d.ts +13 -0
- package/dist/core/src/runtime/archive.d.ts +17 -0
- package/dist/core/src/runtime/compression.d.ts +21 -0
- package/dist/core/src/runtime/deep-equals.d.ts +56 -0
- package/dist/core/src/runtime/detection.d.ts +22 -0
- package/dist/core/src/runtime/escape.d.ts +34 -0
- package/dist/core/src/runtime/index.d.ts +44 -0
- package/dist/core/src/runtime/markdown.d.ts +44 -0
- package/dist/core/src/runtime/types.d.ts +436 -0
- package/dist/core/src/runtime-helpers.d.ts +67 -0
- package/dist/core/src/runtime.d.ts +11 -0
- package/dist/core/src/security/Encrypter.d.ts +33 -0
- package/dist/core/src/security/Hasher.d.ts +29 -0
- package/dist/core/src/testing/HttpTester.d.ts +40 -0
- package/dist/core/src/testing/TestResponse.d.ts +78 -0
- package/dist/core/src/testing/index.d.ts +2 -0
- package/dist/core/src/transpiler-utils.d.ts +170 -0
- package/dist/core/src/types/events.d.ts +94 -0
- package/dist/index.js +1 -274
- package/dist/index.js.map +3 -10
- package/dist/radiance/src/BroadcastManager.d.ts +124 -0
- package/dist/radiance/src/OrbitRadiance.d.ts +98 -0
- package/dist/radiance/src/channels/Channel.d.ts +86 -0
- package/dist/radiance/src/drivers/AblyDriver.d.ts +73 -0
- package/dist/radiance/src/drivers/BroadcastDriver.d.ts +50 -0
- package/dist/radiance/src/drivers/PusherDriver.d.ts +95 -0
- package/dist/radiance/src/drivers/RedisDriver.d.ts +83 -0
- package/dist/radiance/src/drivers/WebSocketDriver.d.ts +89 -0
- package/dist/radiance/src/index.d.ts +39 -0
- package/package.json +10 -6
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GravitoHandler } from '../http/types';
|
|
2
|
+
import type { PlanetCore } from '../PlanetCore';
|
|
3
|
+
import type { ControllerClass } from '../Router';
|
|
4
|
+
export declare class ControllerDispatcher {
|
|
5
|
+
private core;
|
|
6
|
+
private controllers;
|
|
7
|
+
constructor(core: PlanetCore);
|
|
8
|
+
/**
|
|
9
|
+
* Resolve Controller Instance and Method
|
|
10
|
+
*/
|
|
11
|
+
resolve(CtrlClass: ControllerClass, methodName: string): GravitoHandler;
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { GravitoMiddleware } from '../http/types';
|
|
2
|
+
import { type FormRequestClass } from '../Router';
|
|
3
|
+
/**
|
|
4
|
+
* Handles validation of incoming requests using FormRequest classes.
|
|
5
|
+
* Provides mechanisms to detect and convert FormRequest classes into Gravito middleware.
|
|
6
|
+
*/
|
|
7
|
+
export declare class RequestValidator {
|
|
8
|
+
/**
|
|
9
|
+
* Check if a value is a FormRequest class.
|
|
10
|
+
* Optimized with Symbol check, prototype check, and caching.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
static isFormRequestClass(value: unknown): value is FormRequestClass;
|
|
14
|
+
/**
|
|
15
|
+
* Convert a FormRequest class to middleware.
|
|
16
|
+
* Uses instance caching to avoid re-instantiation on every request.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
static formRequestToMiddleware(RequestClass: FormRequestClass): GravitoMiddleware;
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bun runtime adapter implementation.
|
|
3
|
+
*
|
|
4
|
+
* @module runtime/adapter-bun
|
|
5
|
+
* @since 3.2.0
|
|
6
|
+
*/
|
|
7
|
+
import type { RuntimeAdapter } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Create a RuntimeAdapter for the Bun runtime.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function createBunAdapter(): RuntimeAdapter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deno runtime adapter implementation.
|
|
3
|
+
*
|
|
4
|
+
* @module runtime/adapter-deno
|
|
5
|
+
* @since 3.2.0
|
|
6
|
+
*/
|
|
7
|
+
import type { RuntimeAdapter } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Create a RuntimeAdapter for the Deno runtime.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function createDenoAdapter(): RuntimeAdapter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js runtime adapter implementation.
|
|
3
|
+
*
|
|
4
|
+
* @module runtime/adapter-node
|
|
5
|
+
* @since 3.2.0
|
|
6
|
+
*/
|
|
7
|
+
import type { RuntimeAdapter } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Create a RuntimeAdapter for the Node.js runtime.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function createNodeAdapter(): RuntimeAdapter;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unknown runtime adapter implementation (fallback).
|
|
3
|
+
*
|
|
4
|
+
* @module runtime/adapter-unknown
|
|
5
|
+
* @since 3.2.0
|
|
6
|
+
*/
|
|
7
|
+
import type { RuntimeAdapter } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Create a RuntimeAdapter for unsupported runtimes.
|
|
10
|
+
* All methods throw with descriptive error messages.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function createUnknownAdapter(): RuntimeAdapter;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime archive adapter implementations.
|
|
3
|
+
*
|
|
4
|
+
* @module runtime/archive
|
|
5
|
+
* @since 3.2.0
|
|
6
|
+
*/
|
|
7
|
+
import type { ArchiveFromDirectoryOptions, RuntimeArchiveAdapter } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* 取得封裝操作 adapter
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare function getArchiveAdapter(): RuntimeArchiveAdapter;
|
|
13
|
+
/**
|
|
14
|
+
* 將目錄封裝為歸檔檔案
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export declare function archiveFromDirectory(dirPath: string, archivePath: string, options?: ArchiveFromDirectoryOptions): Promise<Uint8Array>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime compression adapter implementations.
|
|
3
|
+
*
|
|
4
|
+
* Provides unified gzip/deflate compression across Bun and Node.js runtimes.
|
|
5
|
+
* Bun uses native C++ implementations (Bun.gzipSync etc.) for 2-5x better performance.
|
|
6
|
+
* Node.js falls back to the standard node:zlib module.
|
|
7
|
+
*
|
|
8
|
+
* @module runtime/compression
|
|
9
|
+
* @since 3.2.0
|
|
10
|
+
*/
|
|
11
|
+
import type { RuntimeCompressionAdapter } from './types';
|
|
12
|
+
/**
|
|
13
|
+
* 取得壓縮操作 adapter(依運行時自動選擇最佳實作)
|
|
14
|
+
*
|
|
15
|
+
* - Bun: 使用原生 C++ 壓縮(2-5x 更快)
|
|
16
|
+
* - Node.js: 使用 node:zlib
|
|
17
|
+
* - Deno/Unknown: 拋出錯誤
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare function getCompressionAdapter(): RuntimeCompressionAdapter;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep equality comparison abstraction.
|
|
3
|
+
*
|
|
4
|
+
* Provides unified deep equality checking across Bun, Node.js, and Deno runtimes.
|
|
5
|
+
* Uses Bun.deepEquals() when available, falls back to recursive comparison.
|
|
6
|
+
*
|
|
7
|
+
* @module runtime/deep-equals
|
|
8
|
+
* @since 3.2.0
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Options for deep equality comparison.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export interface DeepEqualsOptions {
|
|
15
|
+
/**
|
|
16
|
+
* When true, uses strict equality semantics:
|
|
17
|
+
* - NaN !== NaN
|
|
18
|
+
* - +0 !== -0
|
|
19
|
+
*
|
|
20
|
+
* When false (default), uses lenient semantics:
|
|
21
|
+
* - NaN === NaN
|
|
22
|
+
* - +0 === -0
|
|
23
|
+
*/
|
|
24
|
+
strict?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Function signature for deep equality comparison.
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export type DeepEqualsFn = (a: unknown, b: unknown, options?: DeepEqualsOptions) => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Get the optimized deep equality comparison function for the current runtime.
|
|
33
|
+
*
|
|
34
|
+
* - **Bun**: Uses native Bun.deepEquals() for maximum performance (C++ optimized)
|
|
35
|
+
* - **Node.js/Deno/Unknown**: Uses fallback recursive implementation with cycle detection
|
|
36
|
+
*
|
|
37
|
+
* Results are cached after first invocation for efficiency.
|
|
38
|
+
*
|
|
39
|
+
* @returns A function that performs deep equality comparison
|
|
40
|
+
* @public
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const deepEquals = getDeepEquals()
|
|
45
|
+
*
|
|
46
|
+
* const obj1 = { a: [1, 2], b: { c: 3 } }
|
|
47
|
+
* const obj2 = { a: [1, 2], b: { c: 3 } }
|
|
48
|
+
*
|
|
49
|
+
* console.log(deepEquals(obj1, obj2)) // true
|
|
50
|
+
*
|
|
51
|
+
* // Strict mode for +0 / -0 and NaN
|
|
52
|
+
* console.log(deepEquals(NaN, NaN)) // true (lenient)
|
|
53
|
+
* console.log(deepEquals(NaN, NaN, { strict: true })) // false
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function getDeepEquals(): DeepEqualsFn;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime detection utilities.
|
|
3
|
+
*
|
|
4
|
+
* @module runtime/detection
|
|
5
|
+
* @since 3.2.0
|
|
6
|
+
*/
|
|
7
|
+
import type { RuntimeKind } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Detect the current JavaScript runtime environment.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function getRuntimeKind(): RuntimeKind;
|
|
13
|
+
/**
|
|
14
|
+
* Get environment variables from the current runtime.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export declare function getRuntimeEnv(): Record<string, string | undefined>;
|
|
18
|
+
/**
|
|
19
|
+
* Convert various data types to Uint8Array.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare function toUint8Array(data: Blob | Buffer | string | ArrayBuffer | Uint8Array): Promise<Uint8Array>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime HTML escape abstraction.
|
|
3
|
+
*
|
|
4
|
+
* Provides unified HTML escaping across Bun, Node.js, and Deno runtimes.
|
|
5
|
+
* Bun uses the native C++ `Bun.escapeHTML()` for 10-100x better performance.
|
|
6
|
+
* Node.js/Deno fall back to manual entity replacement.
|
|
7
|
+
*
|
|
8
|
+
* @module runtime/escape
|
|
9
|
+
* @since 3.4.0
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* HTML escape function type.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export type EscapeHtmlFn = (value: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Get the HTML escape function (auto-selects best implementation based on runtime).
|
|
18
|
+
*
|
|
19
|
+
* - Bun: Uses native C++ `Bun.escapeHTML()` (10-100x faster, SIMD accelerated)
|
|
20
|
+
* - Node.js/Deno/Unknown: Uses .replace() chain fallback with same behavior
|
|
21
|
+
*
|
|
22
|
+
* @returns HTML escape function
|
|
23
|
+
* @public
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { getEscapeHtml } from '@gravito/core'
|
|
28
|
+
*
|
|
29
|
+
* const escapeHtml = getEscapeHtml()
|
|
30
|
+
* const safe = escapeHtml('<script>alert("xss")</script>')
|
|
31
|
+
* // '<script>alert("xss")</script>'
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function getEscapeHtml(): EscapeHtmlFn;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime abstraction module.
|
|
3
|
+
*
|
|
4
|
+
* Provides unified APIs for filesystem, process, archive, and compression
|
|
5
|
+
* operations across Bun, Node.js, and Deno runtimes.
|
|
6
|
+
*
|
|
7
|
+
* @module runtime
|
|
8
|
+
* @since 3.2.0
|
|
9
|
+
*/
|
|
10
|
+
import type { RuntimeAdapter, RuntimePasswordAdapter, RuntimeSqliteDatabase } from './types';
|
|
11
|
+
export type { ArchiveCreateOptions, ArchiveEntry, ArchiveExtractOptions, ArchiveFileInfo, ArchiveFromDirectoryOptions, CompressionOptions, MarkdownRenderCallbacks, MarkdownRenderOptions, OptionalRuntimeResourceUsage, RuntimeAdapter, RuntimeArchiveAdapter, RuntimeCompressionAdapter, RuntimeFileSink, RuntimeFileStat, RuntimeKind, RuntimeMarkdownAdapter, RuntimePasswordAdapter, RuntimeProcess, RuntimeProcessOutput, RuntimeResourceUsage, RuntimeServeConfig, RuntimeServer, RuntimeSpawnOptions, RuntimeSpawnSyncResult, RuntimeSqliteDatabase, RuntimeSqliteStatement, } from './types';
|
|
12
|
+
export { getRuntimeEnv, getRuntimeKind } from './detection';
|
|
13
|
+
export { archiveFromDirectory, getArchiveAdapter, } from './archive';
|
|
14
|
+
export { getCompressionAdapter } from './compression';
|
|
15
|
+
export { createHtmlRenderCallbacks, getMarkdownAdapter } from './markdown';
|
|
16
|
+
export type { DeepEqualsFn, DeepEqualsOptions } from './deep-equals';
|
|
17
|
+
export { getDeepEquals } from './deep-equals';
|
|
18
|
+
export type { EscapeHtmlFn } from './escape';
|
|
19
|
+
export { getEscapeHtml } from './escape';
|
|
20
|
+
/**
|
|
21
|
+
* Get the runtime abstraction adapter (Bun/Node/Deno).
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export declare function getRuntimeAdapter(): RuntimeAdapter;
|
|
25
|
+
/**
|
|
26
|
+
* Reset the runtime adapter (mainly for testing).
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare function resetRuntimeAdapter(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Get the password hashing adapter using native optimized implementations if available.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare function getPasswordAdapter(): RuntimePasswordAdapter;
|
|
35
|
+
/**
|
|
36
|
+
* Create a SQLite database connection using runtime-native drivers.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare function createSqliteDatabase(path: string): Promise<RuntimeSqliteDatabase>;
|
|
40
|
+
/**
|
|
41
|
+
* Convert various data types to Uint8Array.
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
export declare function toUint8Array(data: Blob | Buffer | string | ArrayBuffer | Uint8Array): Promise<Uint8Array>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime markdown adapter implementations.
|
|
3
|
+
*
|
|
4
|
+
* Provides unified Markdown -> HTML rendering across Bun and Node.js runtimes.
|
|
5
|
+
* Bun uses the native C++ Markdown parser (Bun.markdown) for 10-100x better performance.
|
|
6
|
+
* Node.js falls back to the `marked` library (lazy-loaded optional dependency).
|
|
7
|
+
*
|
|
8
|
+
* @module runtime/markdown
|
|
9
|
+
* @since 3.3.0
|
|
10
|
+
*/
|
|
11
|
+
import type { MarkdownRenderCallbacks, RuntimeMarkdownAdapter } from './types';
|
|
12
|
+
/**
|
|
13
|
+
* 建立預設的 HTML 渲染回調集合。
|
|
14
|
+
*
|
|
15
|
+
* 提供完整的 HTML 元素生成回調,產生與 `html()` 相同的 HTML 輸出。
|
|
16
|
+
* 使用者可透過覆寫個別回調來自訂特定元素的渲染行為(例如 XSS 防護、
|
|
17
|
+
* 自訂 CSS class 等),同時保留其他元素的預設 HTML 渲染。
|
|
18
|
+
*
|
|
19
|
+
* @param overrides - 要覆寫的回調。未指定的回調使用預設 HTML 渲染。
|
|
20
|
+
* @returns 完整的 MarkdownRenderCallbacks 物件
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // 自訂 link 和 html 渲染(XSS 防護)
|
|
25
|
+
* const callbacks = createHtmlRenderCallbacks({
|
|
26
|
+
* html: (raw) => escapeHtml(raw),
|
|
27
|
+
* link: (content, { href }) => `<a href="${href}" rel="noopener">${content}</a>`,
|
|
28
|
+
* })
|
|
29
|
+
* const result = adapter.render(markdown, callbacks)
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare function createHtmlRenderCallbacks(overrides?: Partial<MarkdownRenderCallbacks>): MarkdownRenderCallbacks;
|
|
35
|
+
/**
|
|
36
|
+
* 取得 Markdown 操作 adapter(依運行時自動選擇最佳實作)
|
|
37
|
+
*
|
|
38
|
+
* - Bun: 使用原生 C++ Markdown 解析器(10-100x 更快)
|
|
39
|
+
* - Node.js: 使用 marked 函式庫(延遲載入 optional dependency)
|
|
40
|
+
* - Deno/Unknown: 拋出錯誤
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare function getMarkdownAdapter(): RuntimeMarkdownAdapter;
|