mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-07 13:00:59 +08:00
Initial commit: NOFX AI Trading System
- Multi-AI competition mode (Qwen vs DeepSeek) - Binance Futures integration - AI self-learning mechanism - Professional web dashboard - Complete risk management system
This commit is contained in:
31
web/node_modules/swr/dist/subscription/index.d.mts
generated
vendored
Normal file
31
web/node_modules/swr/dist/subscription/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Key, MutatorCallback, SWRConfiguration, Middleware } from '../index/index.mjs';
|
||||
|
||||
type SWRSubscriptionOptions<Data = any, Error = any> = {
|
||||
next: (err?: Error | null, data?: Data | MutatorCallback<Data>) => void;
|
||||
};
|
||||
type SWRSubscription<SWRSubKey extends Key = Key, Data = any, Error = any> = SWRSubKey extends () => infer Arg | null | undefined | false ? (key: Arg, { next }: SWRSubscriptionOptions<Data, Error>) => void : SWRSubKey extends null | undefined | false ? never : SWRSubKey extends infer Arg ? (key: Arg, { next }: SWRSubscriptionOptions<Data, Error>) => void : never;
|
||||
type SWRSubscriptionResponse<Data = any, Error = any> = {
|
||||
data?: Data;
|
||||
error?: Error;
|
||||
};
|
||||
type SWRSubscriptionHook = <Data = any, Error = any, SWRSubKey extends Key = Key>(key: SWRSubKey, subscribe: SWRSubscription<SWRSubKey, Data, Error>, config?: SWRConfiguration) => SWRSubscriptionResponse<Data, Error>;
|
||||
|
||||
declare const subscription: Middleware;
|
||||
/**
|
||||
* A hook to subscribe a SWR resource to an external data source for continuous updates.
|
||||
* @experimental This API is experimental and might change in the future.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import useSWRSubscription from 'swr/subscription'
|
||||
*
|
||||
* const { data, error } = useSWRSubscription(key, (key, { next }) => {
|
||||
* const unsubscribe = dataSource.subscribe(key, (err, data) => {
|
||||
* next(err, data)
|
||||
* })
|
||||
* return unsubscribe
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
declare const useSWRSubscription: SWRSubscriptionHook;
|
||||
|
||||
export { type SWRSubscription, type SWRSubscriptionHook, type SWRSubscriptionOptions, type SWRSubscriptionResponse, useSWRSubscription as default, subscription };
|
||||
31
web/node_modules/swr/dist/subscription/index.d.ts
generated
vendored
Normal file
31
web/node_modules/swr/dist/subscription/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Key, MutatorCallback, SWRConfiguration, Middleware } from '../index/index.js';
|
||||
|
||||
type SWRSubscriptionOptions<Data = any, Error = any> = {
|
||||
next: (err?: Error | null, data?: Data | MutatorCallback<Data>) => void;
|
||||
};
|
||||
type SWRSubscription<SWRSubKey extends Key = Key, Data = any, Error = any> = SWRSubKey extends () => infer Arg | null | undefined | false ? (key: Arg, { next }: SWRSubscriptionOptions<Data, Error>) => void : SWRSubKey extends null | undefined | false ? never : SWRSubKey extends infer Arg ? (key: Arg, { next }: SWRSubscriptionOptions<Data, Error>) => void : never;
|
||||
type SWRSubscriptionResponse<Data = any, Error = any> = {
|
||||
data?: Data;
|
||||
error?: Error;
|
||||
};
|
||||
type SWRSubscriptionHook = <Data = any, Error = any, SWRSubKey extends Key = Key>(key: SWRSubKey, subscribe: SWRSubscription<SWRSubKey, Data, Error>, config?: SWRConfiguration) => SWRSubscriptionResponse<Data, Error>;
|
||||
|
||||
declare const subscription: Middleware;
|
||||
/**
|
||||
* A hook to subscribe a SWR resource to an external data source for continuous updates.
|
||||
* @experimental This API is experimental and might change in the future.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import useSWRSubscription from 'swr/subscription'
|
||||
*
|
||||
* const { data, error } = useSWRSubscription(key, (key, { next }) => {
|
||||
* const unsubscribe = dataSource.subscribe(key, (err, data) => {
|
||||
* next(err, data)
|
||||
* })
|
||||
* return unsubscribe
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
declare const useSWRSubscription: SWRSubscriptionHook;
|
||||
|
||||
export { type SWRSubscription, type SWRSubscriptionHook, type SWRSubscriptionOptions, type SWRSubscriptionResponse, useSWRSubscription as default, subscription };
|
||||
95
web/node_modules/swr/dist/subscription/index.js
generated
vendored
Normal file
95
web/node_modules/swr/dist/subscription/index.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var useSWR = require('../index/index.js');
|
||||
var index_js = require('../_internal/index.js');
|
||||
|
||||
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
||||
|
||||
var useSWR__default = /*#__PURE__*/_interopDefault(useSWR);
|
||||
|
||||
const subscriptionStorage = new WeakMap();
|
||||
const SUBSCRIPTION_PREFIX = '$sub$';
|
||||
const subscription = (useSWRNext)=>(_key, subscribe, config)=>{
|
||||
const [key, args] = index_js.serialize(_key);
|
||||
// Prefix the key to avoid conflicts with other SWR resources.
|
||||
const subscriptionKey = key ? SUBSCRIPTION_PREFIX + key : undefined;
|
||||
const swr = useSWRNext(subscriptionKey, null, config);
|
||||
const { cache } = config;
|
||||
// Ensure that the subscription state is scoped by the cache boundary, so
|
||||
// you can have multiple SWR zones with subscriptions having the same key.
|
||||
if (!subscriptionStorage.has(cache)) {
|
||||
subscriptionStorage.set(cache, [
|
||||
new Map(),
|
||||
new Map()
|
||||
]);
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const [subscriptions, disposers] = subscriptionStorage.get(cache);
|
||||
index_js.useIsomorphicLayoutEffect(()=>{
|
||||
if (!subscriptionKey) return;
|
||||
const [, set] = index_js.createCacheHelper(cache, subscriptionKey);
|
||||
const refCount = subscriptions.get(subscriptionKey) || 0;
|
||||
const next = (error, data)=>{
|
||||
if (error !== null && typeof error !== 'undefined') {
|
||||
set({
|
||||
error
|
||||
});
|
||||
} else {
|
||||
set({
|
||||
error: undefined
|
||||
});
|
||||
swr.mutate(data, false);
|
||||
}
|
||||
};
|
||||
// Increment the ref count.
|
||||
subscriptions.set(subscriptionKey, refCount + 1);
|
||||
if (!refCount) {
|
||||
const dispose = subscribe(args, {
|
||||
next
|
||||
});
|
||||
if (typeof dispose !== 'function') {
|
||||
throw new Error('The `subscribe` function must return a function to unsubscribe.');
|
||||
}
|
||||
disposers.set(subscriptionKey, dispose);
|
||||
}
|
||||
return ()=>{
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const count = subscriptions.get(subscriptionKey) - 1;
|
||||
subscriptions.set(subscriptionKey, count);
|
||||
// Dispose if it's the last one.
|
||||
if (!count) {
|
||||
const dispose = disposers.get(subscriptionKey);
|
||||
dispose == null ? undefined : dispose();
|
||||
}
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [
|
||||
subscriptionKey
|
||||
]);
|
||||
return {
|
||||
get data () {
|
||||
return swr.data;
|
||||
},
|
||||
get error () {
|
||||
return swr.error;
|
||||
}
|
||||
};
|
||||
};
|
||||
/**
|
||||
* A hook to subscribe a SWR resource to an external data source for continuous updates.
|
||||
* @experimental This API is experimental and might change in the future.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import useSWRSubscription from 'swr/subscription'
|
||||
*
|
||||
* const { data, error } = useSWRSubscription(key, (key, { next }) => {
|
||||
* const unsubscribe = dataSource.subscribe(key, (err, data) => {
|
||||
* next(err, data)
|
||||
* })
|
||||
* return unsubscribe
|
||||
* })
|
||||
* ```
|
||||
*/ const useSWRSubscription = index_js.withMiddleware(useSWR__default.default, subscription);
|
||||
|
||||
exports.default = useSWRSubscription;
|
||||
exports.subscription = subscription;
|
||||
88
web/node_modules/swr/dist/subscription/index.mjs
generated
vendored
Normal file
88
web/node_modules/swr/dist/subscription/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
import useSWR from '../index/index.mjs';
|
||||
import { withMiddleware, serialize, useIsomorphicLayoutEffect, createCacheHelper } from '../_internal/index.mjs';
|
||||
|
||||
const subscriptionStorage = new WeakMap();
|
||||
const SUBSCRIPTION_PREFIX = '$sub$';
|
||||
const subscription = (useSWRNext)=>(_key, subscribe, config)=>{
|
||||
const [key, args] = serialize(_key);
|
||||
// Prefix the key to avoid conflicts with other SWR resources.
|
||||
const subscriptionKey = key ? SUBSCRIPTION_PREFIX + key : undefined;
|
||||
const swr = useSWRNext(subscriptionKey, null, config);
|
||||
const { cache } = config;
|
||||
// Ensure that the subscription state is scoped by the cache boundary, so
|
||||
// you can have multiple SWR zones with subscriptions having the same key.
|
||||
if (!subscriptionStorage.has(cache)) {
|
||||
subscriptionStorage.set(cache, [
|
||||
new Map(),
|
||||
new Map()
|
||||
]);
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const [subscriptions, disposers] = subscriptionStorage.get(cache);
|
||||
useIsomorphicLayoutEffect(()=>{
|
||||
if (!subscriptionKey) return;
|
||||
const [, set] = createCacheHelper(cache, subscriptionKey);
|
||||
const refCount = subscriptions.get(subscriptionKey) || 0;
|
||||
const next = (error, data)=>{
|
||||
if (error !== null && typeof error !== 'undefined') {
|
||||
set({
|
||||
error
|
||||
});
|
||||
} else {
|
||||
set({
|
||||
error: undefined
|
||||
});
|
||||
swr.mutate(data, false);
|
||||
}
|
||||
};
|
||||
// Increment the ref count.
|
||||
subscriptions.set(subscriptionKey, refCount + 1);
|
||||
if (!refCount) {
|
||||
const dispose = subscribe(args, {
|
||||
next
|
||||
});
|
||||
if (typeof dispose !== 'function') {
|
||||
throw new Error('The `subscribe` function must return a function to unsubscribe.');
|
||||
}
|
||||
disposers.set(subscriptionKey, dispose);
|
||||
}
|
||||
return ()=>{
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const count = subscriptions.get(subscriptionKey) - 1;
|
||||
subscriptions.set(subscriptionKey, count);
|
||||
// Dispose if it's the last one.
|
||||
if (!count) {
|
||||
const dispose = disposers.get(subscriptionKey);
|
||||
dispose == null ? undefined : dispose();
|
||||
}
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [
|
||||
subscriptionKey
|
||||
]);
|
||||
return {
|
||||
get data () {
|
||||
return swr.data;
|
||||
},
|
||||
get error () {
|
||||
return swr.error;
|
||||
}
|
||||
};
|
||||
};
|
||||
/**
|
||||
* A hook to subscribe a SWR resource to an external data source for continuous updates.
|
||||
* @experimental This API is experimental and might change in the future.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import useSWRSubscription from 'swr/subscription'
|
||||
*
|
||||
* const { data, error } = useSWRSubscription(key, (key, { next }) => {
|
||||
* const unsubscribe = dataSource.subscribe(key, (err, data) => {
|
||||
* next(err, data)
|
||||
* })
|
||||
* return unsubscribe
|
||||
* })
|
||||
* ```
|
||||
*/ const useSWRSubscription = withMiddleware(useSWR, subscription);
|
||||
|
||||
export { useSWRSubscription as default, subscription };
|
||||
Reference in New Issue
Block a user