@bleedingdev/modern-js-runtime-utils 3.2.0-ultramodern.0 → 3.2.0-ultramodern.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/package.json +3 -3
- package/dist/types/browser/deferreds.d.ts +0 -31
- package/dist/types/browser/index.d.ts +0 -2
- package/dist/types/browser/nestedRoutes.d.ts +0 -12
- package/dist/types/merge.d.ts +0 -6
- package/dist/types/node/fileReader.d.ts +0 -19
- package/dist/types/node/index.d.ts +0 -8
- package/dist/types/node/loaderContext/createLoaderCtx.d.ts +0 -7
- package/dist/types/node/loaderContext/createRequestCtx.d.ts +0 -16
- package/dist/types/node/loaderContext/index.d.ts +0 -4
- package/dist/types/node/nestedRoutes.d.ts +0 -1
- package/dist/types/node/sanitize.d.ts +0 -11
- package/dist/types/node/serialize.d.ts +0 -1
- package/dist/types/node/storer/container.d.ts +0 -27
- package/dist/types/node/storer/index.d.ts +0 -3
- package/dist/types/node/storer/storage.d.ts +0 -26
- package/dist/types/parsed.d.ts +0 -1
- package/dist/types/router.d.ts +0 -6
- package/dist/types/rsc.d.ts +0 -1
- package/dist/types/server/index.d.ts +0 -1
- package/dist/types/server/nestedRoutes.d.ts +0 -2
- package/dist/types/time.d.ts +0 -1
- package/dist/types/universal/async_storage.d.ts +0 -2
- package/dist/types/universal/async_storage.server.d.ts +0 -29
- package/dist/types/universal/cache.d.ts +0 -68
- package/dist/types/universal/request.d.ts +0 -17
- package/dist/types/url.d.ts +0 -11
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.2.0-ultramodern.
|
|
20
|
+
"version": "3.2.0-ultramodern.1",
|
|
21
21
|
"_comment": "Provide ESM and CJS exports, ESM is used by runtime package, for treeshaking",
|
|
22
22
|
"exports": {
|
|
23
23
|
"./router": {
|
|
@@ -161,8 +161,8 @@
|
|
|
161
161
|
"lru-cache": "^11.3.6",
|
|
162
162
|
"react-router": "7.15.1",
|
|
163
163
|
"serialize-javascript": "^7.0.5",
|
|
164
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.
|
|
165
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.
|
|
164
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.1",
|
|
165
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.1"
|
|
166
166
|
},
|
|
167
167
|
"peerDependencies": {
|
|
168
168
|
"react": "^19.2.6",
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export declare function invariant(value: boolean, message?: string): asserts value;
|
|
2
|
-
export declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
|
|
3
|
-
export declare class AbortedDeferredError extends Error {
|
|
4
|
-
}
|
|
5
|
-
export interface TrackedPromise extends Promise<any> {
|
|
6
|
-
_tracked?: boolean;
|
|
7
|
-
_data?: any;
|
|
8
|
-
_error?: any;
|
|
9
|
-
}
|
|
10
|
-
export declare class DeferredData {
|
|
11
|
-
private pendingKeysSet;
|
|
12
|
-
private controller;
|
|
13
|
-
private abortPromise;
|
|
14
|
-
private unlistenAbortSignal;
|
|
15
|
-
private subscribers;
|
|
16
|
-
__modern_deferred: boolean;
|
|
17
|
-
data: Record<string, unknown>;
|
|
18
|
-
init?: ResponseInit;
|
|
19
|
-
deferredKeys: string[];
|
|
20
|
-
constructor(data: Record<string, unknown>, responseInit?: ResponseInit);
|
|
21
|
-
private trackPromise;
|
|
22
|
-
private onSettle;
|
|
23
|
-
private emit;
|
|
24
|
-
subscribe(fn: (aborted: boolean, settledKey?: string) => void): () => boolean;
|
|
25
|
-
cancel(): void;
|
|
26
|
-
resolveData(signal: AbortSignal): Promise<boolean>;
|
|
27
|
-
get done(): boolean;
|
|
28
|
-
get unwrappedData(): {};
|
|
29
|
-
get pendingKeys(): string[];
|
|
30
|
-
}
|
|
31
|
-
export declare const activeDeferreds: Map<string, DeferredData>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { NestedRoute } from '@modern-js/types';
|
|
2
|
-
import { type JSX } from 'react';
|
|
3
|
-
export declare const transformNestedRoutes: (routes: NestedRoute[]) => import("react-router").RouteObject[];
|
|
4
|
-
type DeferredDataComponentType = (props?: {
|
|
5
|
-
nonce?: string;
|
|
6
|
-
}) => JSX.Element | null;
|
|
7
|
-
export declare const renderNestedRoute: (nestedRoute: NestedRoute, options?: {
|
|
8
|
-
parent?: NestedRoute;
|
|
9
|
-
DeferredDataComponent?: DeferredDataComponentType;
|
|
10
|
-
props?: Record<string, any>;
|
|
11
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export {};
|
package/dist/types/merge.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
type PlainObject = {
|
|
2
|
-
[key: string]: any;
|
|
3
|
-
};
|
|
4
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
5
|
-
export declare function merge<T extends PlainObject, U extends PlainObject[]>(target: T, ...sources: U): T & UnionToIntersection<U[number]>;
|
|
6
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import Fs from '@modern-js/utils/fs-extra';
|
|
2
|
-
import type { Buffer } from 'buffer';
|
|
3
|
-
import type { Storage } from './storer/storage';
|
|
4
|
-
export declare class FileReader {
|
|
5
|
-
private storage;
|
|
6
|
-
private fs;
|
|
7
|
-
constructor(storage: Storage<Buffer | null>);
|
|
8
|
-
readFile(path: string, encoding?: 'utf-8'): Promise<string | null>;
|
|
9
|
-
readFile(path: string, encoding?: 'buffer'): Promise<Buffer | null>;
|
|
10
|
-
readFileFromSystem(path: string, encoding?: 'utf-8'): Promise<string | null>;
|
|
11
|
-
readFileFromSystem(path: string, encoding?: 'buffer'): Promise<Buffer | null>;
|
|
12
|
-
_readFileFactory(fs: typeof Fs): (path: string, encoding?: "utf-8" | "buffer") => Promise<string | Buffer | null>;
|
|
13
|
-
/**
|
|
14
|
-
* Clear the fileCache entriely.
|
|
15
|
-
*/
|
|
16
|
-
reset(fs?: typeof Fs): Promise<void>;
|
|
17
|
-
private encodingContent;
|
|
18
|
-
}
|
|
19
|
-
export declare const fileReader: FileReader;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { RequestPayload } from '@modern-js/types';
|
|
2
|
-
import type { LoaderContext } from './createLoaderCtx';
|
|
3
|
-
interface Get<P extends Record<string, unknown>> {
|
|
4
|
-
<Key extends keyof P>(key: Key): P[Key];
|
|
5
|
-
<T>(key: LoaderContext<T>): T;
|
|
6
|
-
}
|
|
7
|
-
interface Set<P extends Record<string, unknown>> {
|
|
8
|
-
<Key extends keyof P>(key: Key, value: P[Key]): void;
|
|
9
|
-
<T>(key: LoaderContext<T>, value: T): void;
|
|
10
|
-
}
|
|
11
|
-
export type RequestContext<P extends Record<string, unknown> = {}> = {
|
|
12
|
-
get: Get<P & RequestPayload>;
|
|
13
|
-
set: Set<P & RequestPayload>;
|
|
14
|
-
};
|
|
15
|
-
export declare function createRequestContext<P extends Record<string, unknown>>(context?: Map<string | symbol, unknown>): RequestContext<P>;
|
|
16
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Reporter } from '@modern-js/types';
|
|
2
|
-
export type { LoaderContext } from './createLoaderCtx';
|
|
3
|
-
export { createRequestContext, type RequestContext, } from './createRequestCtx';
|
|
4
|
-
export declare const reporterCtx: import("./createLoaderCtx").LoaderContext<Reporter>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../server/nestedRoutes';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const DEFAULT_UNSAFE_SSR_HEADERS: readonly ["authorization", "proxy-authorization", "cookie", "set-cookie", "x-api-key", "x-auth-token", "x-csrf-token", "x-xsrf-token", "x-forwarded-client-cert", "cf-access-jwt-assertion"];
|
|
2
|
-
type SanitizeSSRPayloadOptions = {
|
|
3
|
-
unsafeHeaders?: string[];
|
|
4
|
-
treatRootAsHeaders?: boolean;
|
|
5
|
-
};
|
|
6
|
-
type SanitizeSSRPayloadResult<T> = {
|
|
7
|
-
payload: T;
|
|
8
|
-
removed: string[];
|
|
9
|
-
};
|
|
10
|
-
export declare const sanitizeSSRPayload: <T>(payload: T, options?: SanitizeSSRPayloadOptions) => SanitizeSSRPayloadResult<T>;
|
|
11
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const serializeJson: (data: any) => string;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Container } from '@modern-js/types';
|
|
2
|
-
interface MemoryContainerOptions {
|
|
3
|
-
/** The maximum size of the cache, unit(MB). The default of value is 256. */
|
|
4
|
-
max?: number;
|
|
5
|
-
maxAge?: number;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* MemoryContainer, it use lur-cache as cahe layer.
|
|
9
|
-
* It has a Time to Live, by default as 1 hour.
|
|
10
|
-
*/
|
|
11
|
-
export declare class MemoryContainer<K extends string, V extends {}> implements Container<K, V> {
|
|
12
|
-
private static BYTE;
|
|
13
|
-
private static KB;
|
|
14
|
-
private static MB;
|
|
15
|
-
private static ms;
|
|
16
|
-
private static second;
|
|
17
|
-
private static minute;
|
|
18
|
-
private static hour;
|
|
19
|
-
private cache;
|
|
20
|
-
constructor({ max, maxAge }?: MemoryContainerOptions);
|
|
21
|
-
get(key: K): Promise<V | undefined>;
|
|
22
|
-
set(key: K, value: V): Promise<this>;
|
|
23
|
-
has(key: K): Promise<boolean>;
|
|
24
|
-
delete(key: K): Promise<boolean>;
|
|
25
|
-
forEach(callbackFn: (v: V, k: K, container: this) => void): void;
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Container } from '@modern-js/types';
|
|
2
|
-
export declare class Storage<V = unknown> {
|
|
3
|
-
private namespace;
|
|
4
|
-
private container;
|
|
5
|
-
constructor(namespace: string, container: Container<string, V>);
|
|
6
|
-
keys?(): Promise<string[]>;
|
|
7
|
-
values?(): Promise<V[]>;
|
|
8
|
-
/**
|
|
9
|
-
* Returns a specified element from the container. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Container.
|
|
10
|
-
* @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
|
|
11
|
-
*/
|
|
12
|
-
get(key: string): Promise<V | undefined>;
|
|
13
|
-
/**
|
|
14
|
-
* Adds a new element with a specified key and value to the storage. If an element with the same key already exists, the element will be updated.
|
|
15
|
-
*/
|
|
16
|
-
set(key: string, value: V): Promise<this>;
|
|
17
|
-
/**
|
|
18
|
-
* @returns boolean indicating whether an element with the specified key exists or not.
|
|
19
|
-
*/
|
|
20
|
-
has(key: string): Promise<boolean>;
|
|
21
|
-
delete(key: string): Promise<boolean>;
|
|
22
|
-
clear?(): Promise<void>;
|
|
23
|
-
forEach?(fallbackFn: (v: V, k: string, storage: this) => void): void;
|
|
24
|
-
private computedUniqueKey;
|
|
25
|
-
private checkIsOwnkey;
|
|
26
|
-
}
|
package/dist/types/parsed.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const parsedJSONFromElement: (id: string) => any;
|
package/dist/types/router.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from 'react-router';
|
|
2
|
-
export declare const DEFERRED_SYMBOL: unique symbol;
|
|
3
|
-
/** @deprecated Please use Response.json instead. */
|
|
4
|
-
export declare const json: (data: any, init?: number | ResponseInit) => Response;
|
|
5
|
-
/** @deprecated defer is deprecated, You don't need to use it. */
|
|
6
|
-
export declare const defer: (data: any, init?: number | ResponseInit) => any;
|
package/dist/types/rsc.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from 'react-router';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './nestedRoutes';
|
package/dist/types/time.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const time: () => () => number;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Monitors } from '@modern-js/types';
|
|
2
|
-
import type { IncomingHttpHeaders } from 'http';
|
|
3
|
-
declare const storage: {
|
|
4
|
-
run: <O>(context: {
|
|
5
|
-
monitors?: Monitors;
|
|
6
|
-
headers?: IncomingHttpHeaders;
|
|
7
|
-
request?: Request;
|
|
8
|
-
responseProxy?: {
|
|
9
|
-
headers: Record<string, string>;
|
|
10
|
-
status: number;
|
|
11
|
-
};
|
|
12
|
-
activeDeferreds?: Map<string, unknown>;
|
|
13
|
-
serverPayload?: unknown;
|
|
14
|
-
}, cb: () => O | Promise<O>) => Promise<O>;
|
|
15
|
-
useContext: () => {
|
|
16
|
-
monitors?: Monitors;
|
|
17
|
-
headers?: IncomingHttpHeaders;
|
|
18
|
-
request?: Request;
|
|
19
|
-
responseProxy?: {
|
|
20
|
-
headers: Record<string, string>;
|
|
21
|
-
status: number;
|
|
22
|
-
};
|
|
23
|
-
activeDeferreds?: Map<string, unknown>;
|
|
24
|
-
serverPayload?: unknown;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
type Storage = typeof storage;
|
|
28
|
-
export { type Storage, storage };
|
|
29
|
-
export declare const getAsyncLocalStorage: () => Promise<Storage>;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
export declare const CacheSize: {
|
|
2
|
-
readonly KB: 1024;
|
|
3
|
-
readonly MB: number;
|
|
4
|
-
readonly GB: number;
|
|
5
|
-
};
|
|
6
|
-
export declare const CacheTime: {
|
|
7
|
-
readonly SECOND: 1000;
|
|
8
|
-
readonly MINUTE: number;
|
|
9
|
-
readonly HOUR: number;
|
|
10
|
-
readonly DAY: number;
|
|
11
|
-
readonly WEEK: number;
|
|
12
|
-
readonly MONTH: number;
|
|
13
|
-
};
|
|
14
|
-
export type CacheStatus = 'hit' | 'stale' | 'miss';
|
|
15
|
-
export interface CacheStatsInfo {
|
|
16
|
-
status: CacheStatus;
|
|
17
|
-
key: string;
|
|
18
|
-
params: any[];
|
|
19
|
-
result: any;
|
|
20
|
-
/**
|
|
21
|
-
* Cache miss reason:
|
|
22
|
-
* 1: Caching is disabled for the current request
|
|
23
|
-
* 2: Item not found in cache
|
|
24
|
-
* 3: Item found in cache but has expired
|
|
25
|
-
* 4: Failed to parse data from cache
|
|
26
|
-
* 5: Execution error
|
|
27
|
-
*/
|
|
28
|
-
reason?: number;
|
|
29
|
-
}
|
|
30
|
-
export interface Container {
|
|
31
|
-
get: (key: string) => Promise<any | undefined | null>;
|
|
32
|
-
set: (key: string, value: any, options?: {
|
|
33
|
-
ttl?: number;
|
|
34
|
-
}) => Promise<any>;
|
|
35
|
-
has: (key: string) => Promise<boolean>;
|
|
36
|
-
delete: (key: string) => Promise<boolean>;
|
|
37
|
-
clear: () => Promise<void>;
|
|
38
|
-
}
|
|
39
|
-
interface CacheOptions<T extends (...args: any[]) => any> {
|
|
40
|
-
tag?: string | string[];
|
|
41
|
-
maxAge?: number;
|
|
42
|
-
revalidate?: number;
|
|
43
|
-
getKey?: (...args: Parameters<T>) => string;
|
|
44
|
-
customKey?: (options: {
|
|
45
|
-
params: Parameters<T>;
|
|
46
|
-
fn: T;
|
|
47
|
-
generatedKey: string;
|
|
48
|
-
}) => string;
|
|
49
|
-
onCache?: (info: CacheStatsInfo) => void;
|
|
50
|
-
unstable_shouldCache?: (info: {
|
|
51
|
-
params: Parameters<T>;
|
|
52
|
-
result: Awaited<ReturnType<T>>;
|
|
53
|
-
}) => boolean | Promise<boolean>;
|
|
54
|
-
}
|
|
55
|
-
interface CacheConfig {
|
|
56
|
-
maxSize?: number;
|
|
57
|
-
container?: Container;
|
|
58
|
-
unstable_shouldDisable?: ({ request, }: {
|
|
59
|
-
request: Request;
|
|
60
|
-
}) => boolean | Promise<boolean>;
|
|
61
|
-
}
|
|
62
|
-
export declare function configureCache(config: CacheConfig): void;
|
|
63
|
-
export declare function generateKey(args: unknown[]): string;
|
|
64
|
-
export declare function cache<T extends (...args: any[]) => Promise<any>>(fn: T, options?: CacheOptions<T>): T;
|
|
65
|
-
export declare function withRequestCache<T extends (req: Request, ...args: any[]) => Promise<any>>(handler: T): T;
|
|
66
|
-
export declare function revalidateTag(tag: string): Promise<void>;
|
|
67
|
-
export declare function clearStore(): Promise<void>;
|
|
68
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type Query = Record<string, string>;
|
|
2
|
-
export declare function parseQuery(req: Request): Query;
|
|
3
|
-
export type HeadersData = Record<string, string | undefined>;
|
|
4
|
-
export declare function parseHeaders(request: Request): HeadersData;
|
|
5
|
-
/**
|
|
6
|
-
* The function is modified based on
|
|
7
|
-
* https://github.com/honojs/hono/blob/main/src/utils/url.ts
|
|
8
|
-
*
|
|
9
|
-
* MIT Licensed
|
|
10
|
-
* https://github.com/honojs/hono/blob/main/LICENSE
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
export declare function getPathname(request: Request): string;
|
|
14
|
-
export declare function getHost(request: Request): string;
|
|
15
|
-
type Cookie = Record<string, string>;
|
|
16
|
-
export declare function parseCookie(req: Request): Cookie;
|
|
17
|
-
export {};
|
package/dist/types/url.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* we use `pathname.replace(/\/+$/, '')` to remove the '/' with end.
|
|
3
|
-
*
|
|
4
|
-
* examples:
|
|
5
|
-
*
|
|
6
|
-
* pathname1: '/api', pathname2: '/api/',
|
|
7
|
-
* pathname1 as same as pathname2
|
|
8
|
-
*
|
|
9
|
-
* pathname3: '/', the nomalizeResult also as '/'
|
|
10
|
-
*/
|
|
11
|
-
export declare function normalizePathname(pathname: string): string;
|