@modern-js/devtools-kit 2.49.4 → 2.50.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/dist/channel.js +4 -2
- package/dist/client.d.ts +3 -6
- package/dist/client.js +1 -0
- package/dist/node.d.ts +5 -0
- package/dist/node.js +9 -1
- package/dist/promise.d.ts +28 -0
- package/dist/promise.js +128 -0
- package/dist/runtime.d.ts +5 -0
- package/dist/runtime.js +9 -1
- package/dist/serializer.d.ts +2 -0
- package/dist/serializer.js +47 -0
- package/dist/server.d.ts +24 -15
- package/dist/state.d.ts +37 -0
- package/dist/state.js +88 -0
- package/dist/storage-preset.d.ts +13 -0
- package/dist/storage-preset.js +16 -0
- package/dist/valtio.d.ts +5 -0
- package/dist/valtio.js +95 -0
- package/package.json +13 -12
package/dist/channel.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(channel_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(channel_exports);
|
|
36
36
|
var import_nanoid = require("nanoid");
|
|
37
37
|
var flatted = __toESM(require("flatted"));
|
|
38
|
+
var import_serializer = require("./serializer");
|
|
38
39
|
class WebSocketChannel {
|
|
39
40
|
static link(ws) {
|
|
40
41
|
return new Promise((resolve, reject) => {
|
|
@@ -75,10 +76,11 @@ class WebSocketChannel {
|
|
|
75
76
|
serialize(data) {
|
|
76
77
|
return flatted.stringify([
|
|
77
78
|
data
|
|
78
|
-
]);
|
|
79
|
+
], import_serializer.replacer);
|
|
79
80
|
}
|
|
80
81
|
deserialize(e) {
|
|
81
|
-
|
|
82
|
+
const msg = flatted.parse(e.data.toString(), import_serializer.reviver)[0];
|
|
83
|
+
return msg;
|
|
82
84
|
}
|
|
83
85
|
constructor(ws) {
|
|
84
86
|
this.ws = ws;
|
package/dist/client.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import type { ComponentType, ReactElement } from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
import { FileSystemRoutes } from './server';
|
|
2
|
+
import type { Op } from './valtio';
|
|
4
3
|
export interface ClientFunctions {
|
|
5
4
|
refresh: () => void;
|
|
6
|
-
|
|
7
|
-
entrypoint: Entrypoint;
|
|
8
|
-
routes: FileSystemRoutes;
|
|
9
|
-
}) => void;
|
|
5
|
+
applyStateOperations: (ops: Op[]) => Promise<void>;
|
|
10
6
|
}
|
|
11
7
|
export declare class NameDefinition {
|
|
12
8
|
formalName: string;
|
|
13
9
|
casualName: string;
|
|
14
10
|
prefixName: string;
|
|
11
|
+
shortName: string;
|
|
15
12
|
}
|
|
16
13
|
export interface ShortenAlias {
|
|
17
14
|
replace: string | RegExp;
|
package/dist/client.js
CHANGED
package/dist/node.d.ts
CHANGED
|
@@ -6,3 +6,8 @@ export * from './constants';
|
|
|
6
6
|
export * from './channel';
|
|
7
7
|
export * from './rsdoctor';
|
|
8
8
|
export * from './runtime-globals';
|
|
9
|
+
export * from './promise';
|
|
10
|
+
export * from './valtio';
|
|
11
|
+
export type * from './storage-preset';
|
|
12
|
+
export * from './state';
|
|
13
|
+
export * from './serializer';
|
package/dist/node.js
CHANGED
|
@@ -23,6 +23,10 @@ __reExport(node_exports, require("./constants"), module.exports);
|
|
|
23
23
|
__reExport(node_exports, require("./channel"), module.exports);
|
|
24
24
|
__reExport(node_exports, require("./rsdoctor"), module.exports);
|
|
25
25
|
__reExport(node_exports, require("./runtime-globals"), module.exports);
|
|
26
|
+
__reExport(node_exports, require("./promise"), module.exports);
|
|
27
|
+
__reExport(node_exports, require("./valtio"), module.exports);
|
|
28
|
+
__reExport(node_exports, require("./state"), module.exports);
|
|
29
|
+
__reExport(node_exports, require("./serializer"), module.exports);
|
|
26
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27
31
|
0 && (module.exports = {
|
|
28
32
|
...require("./server"),
|
|
@@ -32,5 +36,9 @@ __reExport(node_exports, require("./runtime-globals"), module.exports);
|
|
|
32
36
|
...require("./constants"),
|
|
33
37
|
...require("./channel"),
|
|
34
38
|
...require("./rsdoctor"),
|
|
35
|
-
...require("./runtime-globals")
|
|
39
|
+
...require("./runtime-globals"),
|
|
40
|
+
...require("./promise"),
|
|
41
|
+
...require("./valtio"),
|
|
42
|
+
...require("./state"),
|
|
43
|
+
...require("./serializer")
|
|
36
44
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Path } from './valtio';
|
|
2
|
+
export type PromiseResolve<T> = (value: T | PromiseLike<T>) => void;
|
|
3
|
+
export type PromiseReject = (reason?: any) => void;
|
|
4
|
+
export declare const isPromiseLike: <T = any>(obj: unknown) => obj is PromiseLike<T>;
|
|
5
|
+
export declare class PromiseStub<T> implements PromiseLike<T> {
|
|
6
|
+
static create<T>(): PromiseStub<T>;
|
|
7
|
+
static get<T>(promise: Promise<T>): PromiseStub<T>;
|
|
8
|
+
resolve: PromiseResolve<T>;
|
|
9
|
+
reject: PromiseReject;
|
|
10
|
+
promise: Promise<T>;
|
|
11
|
+
protected constructor();
|
|
12
|
+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2>;
|
|
13
|
+
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
|
|
14
|
+
}
|
|
15
|
+
export declare const traversePromises: (obj: any, path?: Path) => [PromiseLike<unknown>, Path][];
|
|
16
|
+
export declare const applySettled: <T = unknown>(promise: PromiseLike<T>) => Promise<unknown>;
|
|
17
|
+
export interface PromiseResolvers<T> {
|
|
18
|
+
resolve: PromiseResolve<T>;
|
|
19
|
+
reject: PromiseReject;
|
|
20
|
+
promise: Promise<T>;
|
|
21
|
+
}
|
|
22
|
+
type Primitive = string | number | boolean | null | undefined | symbol | bigint;
|
|
23
|
+
type DeepToResolversIgnore = Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | Error | RegExp | ((...args: any[]) => any) | Primitive;
|
|
24
|
+
export type DeepToResolvers<T> = T extends DeepToResolversIgnore ? T : T extends Promise<unknown> ? PromiseResolvers<Awaited<T>> : T extends object ? {
|
|
25
|
+
[K in keyof T]: DeepToResolvers<T[K]>;
|
|
26
|
+
} : T;
|
|
27
|
+
export declare const withResolvers: <T>() => PromiseResolvers<T>;
|
|
28
|
+
export {};
|
package/dist/promise.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
var promise_exports = {};
|
|
20
|
+
__export(promise_exports, {
|
|
21
|
+
PromiseStub: () => PromiseStub,
|
|
22
|
+
applySettled: () => applySettled,
|
|
23
|
+
isPromiseLike: () => isPromiseLike,
|
|
24
|
+
traversePromises: () => traversePromises,
|
|
25
|
+
withResolvers: () => withResolvers
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(promise_exports);
|
|
28
|
+
const isPromiseLike = (obj) => obj !== null && typeof obj === "object" && typeof obj.then === "function";
|
|
29
|
+
const _promiseResolveMapping = /* @__PURE__ */ new WeakMap();
|
|
30
|
+
const _promiseRejectMapping = /* @__PURE__ */ new WeakMap();
|
|
31
|
+
class PromiseStub {
|
|
32
|
+
static create() {
|
|
33
|
+
const stub = new PromiseStub();
|
|
34
|
+
stub.promise = new Promise((resolve, reject) => {
|
|
35
|
+
stub.resolve = resolve;
|
|
36
|
+
stub.reject = reject;
|
|
37
|
+
});
|
|
38
|
+
_promiseResolveMapping.set(stub.promise, stub.resolve);
|
|
39
|
+
_promiseRejectMapping.set(stub.promise, stub.reject);
|
|
40
|
+
return stub;
|
|
41
|
+
}
|
|
42
|
+
static get(promise) {
|
|
43
|
+
const resolve = _promiseResolveMapping.get(promise);
|
|
44
|
+
const reject = _promiseRejectMapping.get(promise);
|
|
45
|
+
if (!resolve || !reject) {
|
|
46
|
+
throw new Error("Invalid promise");
|
|
47
|
+
}
|
|
48
|
+
const stub = new PromiseStub();
|
|
49
|
+
stub.promise = promise;
|
|
50
|
+
stub.resolve = resolve;
|
|
51
|
+
stub.reject = reject;
|
|
52
|
+
return stub;
|
|
53
|
+
}
|
|
54
|
+
then(onfulfilled, onrejected) {
|
|
55
|
+
return this.promise.then(onfulfilled, onrejected);
|
|
56
|
+
}
|
|
57
|
+
catch(onrejected) {
|
|
58
|
+
return this.promise.catch(onrejected);
|
|
59
|
+
}
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
61
|
+
constructor() {
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const traversePromises = (obj, path = []) => {
|
|
65
|
+
const promises = /* @__PURE__ */ new Set();
|
|
66
|
+
const memo = /* @__PURE__ */ new WeakSet();
|
|
67
|
+
const traverse = (value, currentPath) => {
|
|
68
|
+
if (value === null)
|
|
69
|
+
return;
|
|
70
|
+
if (typeof value === "object") {
|
|
71
|
+
if (memo.has(value)) {
|
|
72
|
+
return;
|
|
73
|
+
} else {
|
|
74
|
+
memo.add(value);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (isPromiseLike(value)) {
|
|
78
|
+
promises.add([
|
|
79
|
+
value,
|
|
80
|
+
currentPath
|
|
81
|
+
]);
|
|
82
|
+
} else if (typeof value === "object") {
|
|
83
|
+
for (const [k, v] of Object.entries(value)) {
|
|
84
|
+
traverse(v, [
|
|
85
|
+
...currentPath,
|
|
86
|
+
k
|
|
87
|
+
]);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
traverse(obj, path);
|
|
92
|
+
return Array.from(promises.values());
|
|
93
|
+
};
|
|
94
|
+
const applySettled = (promise) => {
|
|
95
|
+
const settled = {};
|
|
96
|
+
promise.then((value) => {
|
|
97
|
+
settled.resolved = value;
|
|
98
|
+
});
|
|
99
|
+
if ("catch" in promise && typeof promise.catch === "function") {
|
|
100
|
+
promise.catch((err) => {
|
|
101
|
+
settled.rejected = err;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return new Promise(async (resolve, reject) => {
|
|
105
|
+
await Promise.resolve();
|
|
106
|
+
if ("rejected" in settled) {
|
|
107
|
+
reject(settled.rejected);
|
|
108
|
+
} else if ("resolved" in settled) {
|
|
109
|
+
resolve(settled.resolved);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
const withResolvers = () => {
|
|
114
|
+
const resolvers = {};
|
|
115
|
+
resolvers.promise = new Promise((resolve, reject) => {
|
|
116
|
+
resolvers.resolve = resolve;
|
|
117
|
+
resolvers.reject = reject;
|
|
118
|
+
});
|
|
119
|
+
return resolvers;
|
|
120
|
+
};
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
PromiseStub,
|
|
124
|
+
applySettled,
|
|
125
|
+
isPromiseLike,
|
|
126
|
+
traversePromises,
|
|
127
|
+
withResolvers
|
|
128
|
+
});
|
package/dist/runtime.d.ts
CHANGED
|
@@ -6,3 +6,8 @@ export * from './constants';
|
|
|
6
6
|
export * from './channel';
|
|
7
7
|
export type * from './rsdoctor';
|
|
8
8
|
export * from './runtime-globals';
|
|
9
|
+
export type * from './storage-preset';
|
|
10
|
+
export * from './promise';
|
|
11
|
+
export * from './valtio';
|
|
12
|
+
export * from './state';
|
|
13
|
+
export * from './serializer';
|
package/dist/runtime.js
CHANGED
|
@@ -21,6 +21,10 @@ __reExport(runtime_exports, require("./utils"), module.exports);
|
|
|
21
21
|
__reExport(runtime_exports, require("./constants"), module.exports);
|
|
22
22
|
__reExport(runtime_exports, require("./channel"), module.exports);
|
|
23
23
|
__reExport(runtime_exports, require("./runtime-globals"), module.exports);
|
|
24
|
+
__reExport(runtime_exports, require("./promise"), module.exports);
|
|
25
|
+
__reExport(runtime_exports, require("./valtio"), module.exports);
|
|
26
|
+
__reExport(runtime_exports, require("./state"), module.exports);
|
|
27
|
+
__reExport(runtime_exports, require("./serializer"), module.exports);
|
|
24
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
25
29
|
0 && (module.exports = {
|
|
26
30
|
...require("./client"),
|
|
@@ -28,5 +32,9 @@ __reExport(runtime_exports, require("./runtime-globals"), module.exports);
|
|
|
28
32
|
...require("./utils"),
|
|
29
33
|
...require("./constants"),
|
|
30
34
|
...require("./channel"),
|
|
31
|
-
...require("./runtime-globals")
|
|
35
|
+
...require("./runtime-globals"),
|
|
36
|
+
...require("./promise"),
|
|
37
|
+
...require("./valtio"),
|
|
38
|
+
...require("./state"),
|
|
39
|
+
...require("./serializer")
|
|
32
40
|
});
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
var serializer_exports = {};
|
|
20
|
+
__export(serializer_exports, {
|
|
21
|
+
replacer: () => replacer,
|
|
22
|
+
reviver: () => reviver
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(serializer_exports);
|
|
25
|
+
var import_promise = require("./promise");
|
|
26
|
+
function replacer(_key, value) {
|
|
27
|
+
if ((0, import_promise.isPromiseLike)(value)) {
|
|
28
|
+
return {
|
|
29
|
+
__type__: "promise"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
function reviver(_key, value) {
|
|
35
|
+
if (!value || typeof value !== "object") {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
if (value.__type__ === "promise" && Object.keys(value).length === 1) {
|
|
39
|
+
return import_promise.PromiseStub.create().promise;
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
replacer,
|
|
46
|
+
reviver
|
|
47
|
+
});
|
package/dist/server.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { AppTools, IAppContext, UserConfig } from '@modern-js/app-tools';
|
|
2
2
|
import type { RsbuildContext, NormalizedConfig as NormalizedBuilderConfig, RsbuildConfig, webpack, Rspack, WebpackConfig, RspackConfig } from '@modern-js/uni-builder';
|
|
3
|
-
import { NormalizedConfig } from '@modern-js/core';
|
|
4
|
-
import { RouteLegacy, NestedRouteForCli, PageRoute } from '@modern-js/types';
|
|
3
|
+
import type { NormalizedConfig } from '@modern-js/core';
|
|
4
|
+
import type { RouteLegacy, NestedRouteForCli, PageRoute } from '@modern-js/types';
|
|
5
5
|
import type { Manifest } from '@rsdoctor/types';
|
|
6
|
+
import type { StoragePresetConfig, StoragePresetContext, StoragePresetWithIdent } from './storage-preset';
|
|
7
|
+
import type { ServerExportedState } from './state';
|
|
6
8
|
import type { ClientDefinition } from './client';
|
|
7
9
|
export type BuilderContext = RsbuildContext;
|
|
8
10
|
export type FrameworkConfig = UserConfig<AppTools>;
|
|
@@ -11,6 +13,13 @@ export type BuilderConfig = RsbuildConfig;
|
|
|
11
13
|
export type { NormalizedBuilderConfig, WebpackConfig, RspackConfig };
|
|
12
14
|
export type Aliases = NonNullable<NonNullable<WebpackConfig['resolve']>['alias']>;
|
|
13
15
|
export type BundlerConfig = WebpackConfig | RspackConfig;
|
|
16
|
+
export interface DevtoolsContext {
|
|
17
|
+
enable: boolean;
|
|
18
|
+
endpoint: string;
|
|
19
|
+
dataSource: string;
|
|
20
|
+
def: ClientDefinition;
|
|
21
|
+
storagePresets: StoragePresetContext[];
|
|
22
|
+
}
|
|
14
23
|
export type Compiler = webpack.Compiler | Rspack.Compiler | webpack.MultiCompiler | Rspack.MultiCompiler;
|
|
15
24
|
export type AppContext = Omit<IAppContext, 'builder' | 'serverInternalPlugins'>;
|
|
16
25
|
export type FileSystemRoutes = RouteLegacy[] | (NestedRouteForCli | PageRoute)[];
|
|
@@ -21,19 +30,19 @@ export interface DoctorManifestOverview {
|
|
|
21
30
|
summary: Manifest.RsdoctorManifest['data']['summary'];
|
|
22
31
|
errors: Manifest.RsdoctorManifest['data']['errors'];
|
|
23
32
|
}
|
|
33
|
+
export interface DevtoolsConfig {
|
|
34
|
+
storagePresets?: StoragePresetConfig[];
|
|
35
|
+
}
|
|
36
|
+
export interface ResolvedDevtoolsConfig {
|
|
37
|
+
storagePresets: StoragePresetContext[];
|
|
38
|
+
}
|
|
24
39
|
export interface ServerFunctions {
|
|
25
|
-
getFrameworkConfig: () => Promise<FrameworkConfig>;
|
|
26
|
-
getTransformedFrameworkConfig: () => Promise<TransformedFrameworkConfig>;
|
|
27
|
-
getBuilderConfig: () => Promise<BuilderConfig>;
|
|
28
|
-
getTransformedBuilderConfig: () => Promise<NormalizedBuilderConfig>;
|
|
29
|
-
getBundlerConfigs: () => Promise<BundlerConfig[]>;
|
|
30
|
-
getTransformedBundlerConfigs: () => Promise<BundlerConfig[]>;
|
|
31
|
-
getAppContext: () => Promise<AppContext>;
|
|
32
|
-
getFileSystemRoutes: (entryName: string) => Promise<FileSystemRoutes>;
|
|
33
|
-
getBuilderContext: () => Promise<RsbuildContext>;
|
|
34
|
-
getDependencies: () => Promise<Record<string, string>>;
|
|
35
|
-
getCompileTimeCost: () => Promise<number>;
|
|
36
|
-
getClientDefinition: () => Promise<ClientDefinition>;
|
|
37
|
-
getDoctorOverview: () => Promise<DoctorManifestOverview>;
|
|
38
40
|
echo: (content: string) => string;
|
|
41
|
+
pullExportedState: () => Promise<ServerExportedState>;
|
|
42
|
+
createTemporaryStoragePreset: () => Promise<StoragePresetWithIdent>;
|
|
43
|
+
pasteStoragePreset: (target: {
|
|
44
|
+
filename: string;
|
|
45
|
+
id: string;
|
|
46
|
+
}) => Promise<void>;
|
|
47
|
+
open: (filename: string) => Promise<void>;
|
|
39
48
|
}
|
package/dist/state.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AppContext, BuilderConfig, BuilderContext, BundlerConfig, DevtoolsContext, DoctorManifestOverview, FileSystemRoutes, FrameworkConfig, NormalizedBuilderConfig, TransformedFrameworkConfig } from './server';
|
|
2
|
+
import { type DeepToResolvers } from './promise';
|
|
3
|
+
export interface ServerExportedState {
|
|
4
|
+
framework: {
|
|
5
|
+
context: Promise<AppContext>;
|
|
6
|
+
config: {
|
|
7
|
+
resolved: Promise<FrameworkConfig>;
|
|
8
|
+
transformed: Promise<TransformedFrameworkConfig>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
builder: {
|
|
12
|
+
context: Promise<BuilderContext>;
|
|
13
|
+
config: {
|
|
14
|
+
resolved: Promise<BuilderConfig>;
|
|
15
|
+
transformed: Promise<NormalizedBuilderConfig>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
bundler: {
|
|
19
|
+
configs: {
|
|
20
|
+
resolved: Promise<BundlerConfig[]>;
|
|
21
|
+
transformed: Promise<BundlerConfig[]>;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
doctor: Promise<DoctorManifestOverview | void>;
|
|
25
|
+
context: DevtoolsContext | Promise<DevtoolsContext>;
|
|
26
|
+
performance: Promise<{
|
|
27
|
+
compileDuration: number;
|
|
28
|
+
}>;
|
|
29
|
+
dependencies: Record<string, string>;
|
|
30
|
+
fileSystemRoutes: Record<string, FileSystemRoutes>;
|
|
31
|
+
}
|
|
32
|
+
export type ServerExportedStateResolvers = DeepToResolvers<ServerExportedState>;
|
|
33
|
+
export interface ServerExportedStateResult {
|
|
34
|
+
resolvers: ServerExportedStateResolvers;
|
|
35
|
+
state: ServerExportedState;
|
|
36
|
+
}
|
|
37
|
+
export declare const createServerExportedState: () => ServerExportedStateResult;
|
package/dist/state.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
var state_exports = {};
|
|
20
|
+
__export(state_exports, {
|
|
21
|
+
createServerExportedState: () => createServerExportedState
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(state_exports);
|
|
24
|
+
var import_promise = require("./promise");
|
|
25
|
+
const createServerExportedState = () => {
|
|
26
|
+
const resolvers = {
|
|
27
|
+
framework: {
|
|
28
|
+
context: import_promise.PromiseStub.create(),
|
|
29
|
+
config: {
|
|
30
|
+
resolved: import_promise.PromiseStub.create(),
|
|
31
|
+
transformed: import_promise.PromiseStub.create()
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
builder: {
|
|
35
|
+
context: import_promise.PromiseStub.create(),
|
|
36
|
+
config: {
|
|
37
|
+
resolved: import_promise.PromiseStub.create(),
|
|
38
|
+
transformed: import_promise.PromiseStub.create()
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
bundler: {
|
|
42
|
+
configs: {
|
|
43
|
+
resolved: import_promise.PromiseStub.create(),
|
|
44
|
+
transformed: import_promise.PromiseStub.create()
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
doctor: import_promise.PromiseStub.create(),
|
|
48
|
+
context: import_promise.PromiseStub.create(),
|
|
49
|
+
performance: import_promise.PromiseStub.create(),
|
|
50
|
+
dependencies: {},
|
|
51
|
+
fileSystemRoutes: {}
|
|
52
|
+
};
|
|
53
|
+
const state = {
|
|
54
|
+
framework: {
|
|
55
|
+
context: resolvers.framework.context.promise,
|
|
56
|
+
config: {
|
|
57
|
+
resolved: resolvers.framework.config.resolved.promise,
|
|
58
|
+
transformed: resolvers.framework.config.transformed.promise
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
builder: {
|
|
62
|
+
context: resolvers.builder.context.promise,
|
|
63
|
+
config: {
|
|
64
|
+
resolved: resolvers.builder.config.resolved.promise,
|
|
65
|
+
transformed: resolvers.builder.config.transformed.promise
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
bundler: {
|
|
69
|
+
configs: {
|
|
70
|
+
resolved: resolvers.bundler.configs.resolved.promise,
|
|
71
|
+
transformed: resolvers.bundler.configs.transformed.promise
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
doctor: resolvers.doctor.promise,
|
|
75
|
+
context: resolvers.context.promise,
|
|
76
|
+
performance: resolvers.performance.promise,
|
|
77
|
+
dependencies: resolvers.dependencies,
|
|
78
|
+
fileSystemRoutes: resolvers.fileSystemRoutes
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
resolvers,
|
|
82
|
+
state
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
createServerExportedState
|
|
88
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface StoragePresetConfig {
|
|
2
|
+
id?: string;
|
|
3
|
+
name: string;
|
|
4
|
+
cookie?: Record<string, string>;
|
|
5
|
+
localStorage?: Record<string, string>;
|
|
6
|
+
sessionStorage?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export interface StoragePresetWithIdent extends StoragePresetConfig {
|
|
9
|
+
id: string;
|
|
10
|
+
}
|
|
11
|
+
export interface StoragePresetContext extends StoragePresetWithIdent {
|
|
12
|
+
filename: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var storage_preset_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(storage_preset_exports);
|
package/dist/valtio.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type Path = (string | symbol)[];
|
|
2
|
+
export type Op = [op: 'set', path: Path, value: unknown, prevValue: unknown] | [op: 'delete', path: Path, prevValue: unknown] | [op: 'resolve', path: Path, value: unknown] | [op: 'reject', path: Path, error: unknown];
|
|
3
|
+
export declare const resolvePaths: (obj: any, path: Path) => any;
|
|
4
|
+
export declare const applyOperation: (state: Record<any, any>, op: Op) => void;
|
|
5
|
+
export declare const extractSettledOperations: (state: object) => Promise<Op[]>;
|
package/dist/valtio.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
var valtio_exports = {};
|
|
20
|
+
__export(valtio_exports, {
|
|
21
|
+
applyOperation: () => applyOperation,
|
|
22
|
+
extractSettledOperations: () => extractSettledOperations,
|
|
23
|
+
resolvePaths: () => resolvePaths
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(valtio_exports);
|
|
26
|
+
var import_promise = require("./promise");
|
|
27
|
+
const resolvePaths = (obj, path) => {
|
|
28
|
+
let current = obj;
|
|
29
|
+
for (const key of path) {
|
|
30
|
+
current = current[key];
|
|
31
|
+
}
|
|
32
|
+
return current;
|
|
33
|
+
};
|
|
34
|
+
const applyOperation = (state, op) => {
|
|
35
|
+
const [operation, path, value, _prevValue] = op;
|
|
36
|
+
const dirnames = path.slice(0, -1);
|
|
37
|
+
const basename = path[path.length - 1];
|
|
38
|
+
const parent = resolvePaths(state, dirnames);
|
|
39
|
+
if (operation === "delete") {
|
|
40
|
+
delete parent[basename];
|
|
41
|
+
} else if (operation === "set") {
|
|
42
|
+
if (value instanceof import_promise.PromiseStub) {
|
|
43
|
+
parent[basename] = value.promise;
|
|
44
|
+
} else {
|
|
45
|
+
parent[basename] = value;
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
const promise = parent[basename];
|
|
49
|
+
let promiseStub;
|
|
50
|
+
if (promise instanceof import_promise.PromiseStub) {
|
|
51
|
+
promiseStub = promise;
|
|
52
|
+
} else {
|
|
53
|
+
try {
|
|
54
|
+
promiseStub = import_promise.PromiseStub.get(promise);
|
|
55
|
+
} catch {
|
|
56
|
+
promiseStub = import_promise.PromiseStub.create();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (operation === "resolve") {
|
|
60
|
+
promiseStub.resolve(value);
|
|
61
|
+
} else {
|
|
62
|
+
promiseStub.reject(value);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const extractSettledOperations = async (state) => {
|
|
67
|
+
const ops = [];
|
|
68
|
+
const _promises = [];
|
|
69
|
+
for (const [promise, path] of (0, import_promise.traversePromises)(state)) {
|
|
70
|
+
const sendResolveMessage = (value) => {
|
|
71
|
+
ops.push([
|
|
72
|
+
"resolve",
|
|
73
|
+
path,
|
|
74
|
+
value
|
|
75
|
+
]);
|
|
76
|
+
};
|
|
77
|
+
const sendRejectMessage = (error) => {
|
|
78
|
+
ops.push([
|
|
79
|
+
"reject",
|
|
80
|
+
path,
|
|
81
|
+
error
|
|
82
|
+
]);
|
|
83
|
+
};
|
|
84
|
+
const _promise = (0, import_promise.applySettled)(promise).then(sendResolveMessage).catch(sendRejectMessage);
|
|
85
|
+
_promises.push(_promise);
|
|
86
|
+
}
|
|
87
|
+
await Promise.all(_promises);
|
|
88
|
+
return ops;
|
|
89
|
+
};
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
applyOperation,
|
|
93
|
+
extractSettledOperations,
|
|
94
|
+
resolvePaths
|
|
95
|
+
});
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"modern",
|
|
22
22
|
"modern.js"
|
|
23
23
|
],
|
|
24
|
-
"version": "2.
|
|
24
|
+
"version": "2.50.0",
|
|
25
25
|
"jsnext:source": "./src/index.ts",
|
|
26
26
|
"types": "./dist/index.d.ts",
|
|
27
27
|
"main": "./dist/index.js",
|
|
@@ -61,10 +61,11 @@
|
|
|
61
61
|
"ufo": "^1.3.0",
|
|
62
62
|
"flatted": "^3.2.9",
|
|
63
63
|
"ws": "^8.13.0",
|
|
64
|
-
"
|
|
65
|
-
"@rsdoctor/
|
|
66
|
-
"@
|
|
67
|
-
"@modern-js/utils": "2.
|
|
64
|
+
"cookie-es": "^1.0.0",
|
|
65
|
+
"@rsdoctor/types": "^0.2.4",
|
|
66
|
+
"@rsdoctor/utils": "^0.2.4",
|
|
67
|
+
"@modern-js/utils": "2.50.0",
|
|
68
|
+
"@modern-js/types": "2.50.0"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
71
|
"@babel/core": "^7.23.2",
|
|
@@ -79,13 +80,13 @@
|
|
|
79
80
|
"react": "~18.2.0",
|
|
80
81
|
"type-fest": "^4.1.0",
|
|
81
82
|
"typescript": "^5",
|
|
82
|
-
"@modern-js/
|
|
83
|
-
"@modern-js/
|
|
84
|
-
"@modern-js/
|
|
85
|
-
"@modern-js/
|
|
86
|
-
"@modern-js/uni-builder": "2.
|
|
87
|
-
"@scripts/build": "2.
|
|
88
|
-
"@scripts/jest-config": "2.
|
|
83
|
+
"@modern-js/module-tools": "2.50.0",
|
|
84
|
+
"@modern-js/app-tools": "2.50.0",
|
|
85
|
+
"@modern-js/types": "2.50.0",
|
|
86
|
+
"@modern-js/core": "2.50.0",
|
|
87
|
+
"@modern-js/uni-builder": "2.50.0",
|
|
88
|
+
"@scripts/build": "2.50.0",
|
|
89
|
+
"@scripts/jest-config": "2.50.0"
|
|
89
90
|
},
|
|
90
91
|
"peerDependencies": {
|
|
91
92
|
"react": "~18.2.0"
|