@modern-js/plugin-v2 2.63.7 → 2.63.8-alpha.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/cjs/cli/run/create.js +25 -14
- package/dist/cjs/hooks.js +74 -2
- package/dist/cjs/index.js +8 -2
- package/dist/cjs/manager.js +3 -5
- package/dist/cjs/runtime/api.js +79 -0
- package/dist/cjs/runtime/context.js +51 -0
- package/dist/cjs/runtime/hooks.js +36 -0
- package/dist/cjs/runtime/index.js +39 -0
- package/dist/cjs/runtime/run/create.js +74 -0
- package/dist/cjs/runtime/run/index.js +29 -0
- package/dist/cjs/runtime/run/types.js +16 -0
- package/dist/cjs/types/runtime/api.js +16 -0
- package/dist/cjs/types/runtime/context.js +16 -0
- package/dist/cjs/types/runtime/hooks.js +16 -0
- package/dist/cjs/types/runtime/index.js +16 -0
- package/dist/cjs/types/runtime/plugin.js +16 -0
- package/dist/esm/cli/api.js +103 -0
- package/dist/esm/cli/context.js +53 -0
- package/dist/esm/cli/hooks.js +42 -0
- package/dist/esm/cli/index.js +14 -0
- package/dist/esm/cli/run/config/createLoadedConfig.js +190 -0
- package/dist/esm/cli/run/config/createResolvedConfig.js +30 -0
- package/dist/esm/cli/run/config/loadConfig.js +210 -0
- package/dist/esm/cli/run/create.js +300 -0
- package/dist/esm/cli/run/index.js +10 -0
- package/dist/esm/cli/run/run.js +60 -0
- package/dist/esm/cli/run/types.js +0 -0
- package/dist/esm/cli/run/utils/checkIsDuplicationPlugin.js +24 -0
- package/dist/esm/cli/run/utils/commander.js +42 -0
- package/dist/esm/cli/run/utils/createFileWatcher.js +110 -0
- package/dist/esm/cli/run/utils/debug.js +5 -0
- package/dist/esm/cli/run/utils/initAppDir.js +36 -0
- package/dist/esm/cli/run/utils/loadEnv.js +24 -0
- package/dist/esm/cli/run/utils/mergeConfig.js +43 -0
- package/dist/esm/hooks.js +378 -0
- package/dist/esm/index.js +6 -357
- package/dist/esm/manager.js +161 -0
- package/dist/esm/runtime/api.js +59 -0
- package/dist/esm/runtime/context.js +25 -0
- package/dist/esm/runtime/hooks.js +12 -0
- package/dist/esm/runtime/index.js +11 -0
- package/dist/esm/runtime/run/create.js +72 -0
- package/dist/esm/runtime/run/index.js +5 -0
- package/dist/esm/runtime/run/types.js +0 -0
- package/dist/esm/types/cli/api.js +0 -0
- package/dist/esm/types/cli/context.js +0 -0
- package/dist/esm/types/cli/hooks.js +0 -0
- package/dist/esm/types/cli/index.js +0 -0
- package/dist/esm/types/cli/plugin.js +0 -0
- package/dist/esm/types/hooks.js +0 -0
- package/dist/esm/types/index.js +0 -0
- package/dist/esm/types/plugin.js +0 -0
- package/dist/esm/types/runtime/api.js +0 -0
- package/dist/esm/types/runtime/context.js +0 -0
- package/dist/esm/types/runtime/hooks.js +0 -0
- package/dist/esm/types/runtime/index.js +0 -0
- package/dist/esm/types/runtime/plugin.js +0 -0
- package/dist/esm/types/utils.js +0 -0
- package/dist/esm-node/cli/run/create.js +26 -15
- package/dist/esm-node/hooks.js +70 -1
- package/dist/esm-node/index.js +5 -2
- package/dist/esm-node/manager.js +2 -4
- package/dist/esm-node/runtime/api.js +55 -0
- package/dist/esm-node/runtime/context.js +26 -0
- package/dist/esm-node/runtime/hooks.js +12 -0
- package/dist/esm-node/runtime/index.js +11 -0
- package/dist/esm-node/runtime/run/create.js +50 -0
- package/dist/esm-node/runtime/run/index.js +5 -0
- package/dist/esm-node/runtime/run/types.js +0 -0
- package/dist/esm-node/types/runtime/api.js +0 -0
- package/dist/esm-node/types/runtime/context.js +0 -0
- package/dist/esm-node/types/runtime/hooks.js +0 -0
- package/dist/esm-node/types/runtime/index.js +0 -0
- package/dist/esm-node/types/runtime/plugin.js +0 -0
- package/dist/types/cli/run/create.d.ts +2 -1
- package/dist/types/hooks.d.ts +4 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/manager.d.ts +3 -0
- package/dist/types/runtime/api.d.ts +9 -0
- package/dist/types/runtime/context.d.ts +11 -0
- package/dist/types/runtime/hooks.d.ts +2 -0
- package/dist/types/runtime/index.d.ts +5 -0
- package/dist/types/runtime/run/create.d.ts +7 -0
- package/dist/types/runtime/run/index.d.ts +5 -0
- package/dist/types/runtime/run/types.d.ts +6 -0
- package/dist/types/types/cli/hooks.d.ts +2 -2
- package/dist/types/types/hooks.d.ts +14 -2
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/plugin.d.ts +1 -1
- package/dist/types/types/runtime/api.d.ts +15 -0
- package/dist/types/types/runtime/context.d.ts +13 -0
- package/dist/types/types/runtime/hooks.d.ts +12 -0
- package/dist/types/types/runtime/index.d.ts +4 -0
- package/dist/types/types/runtime/plugin.d.ts +14 -0
- package/dist/types/types/utils.d.ts +1 -0
- package/package.json +15 -11
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PluginHookTap } from '../hooks';
|
|
2
|
+
import type { DeepPartial } from '../utils';
|
|
3
|
+
import type { RuntimeContext } from './context';
|
|
4
|
+
import type { Hooks } from './hooks';
|
|
5
|
+
import type { ModifyRuntimeConfigFn, OnBeforeRenderFn, PickContextFn, WrapRootFn } from './hooks';
|
|
6
|
+
import type { RuntimePluginExtends } from './plugin';
|
|
7
|
+
export type RuntimePluginAPI<Extends extends RuntimePluginExtends> = Readonly<{
|
|
8
|
+
updateRuntimeContext: (updateContext: DeepPartial<RuntimeContext>) => void;
|
|
9
|
+
getHooks: () => Readonly<Hooks<Extends['config'], RuntimeContext & Extends['extendContext']> & Extends['extendHooks']>;
|
|
10
|
+
getRuntimeConfig: () => Readonly<Extends['config']>;
|
|
11
|
+
onBeforeRender: PluginHookTap<OnBeforeRenderFn<Extends['extendContext']>>;
|
|
12
|
+
wrapRoot: PluginHookTap<WrapRootFn>;
|
|
13
|
+
pickContext: PluginHookTap<PickContextFn<RuntimeContext>>;
|
|
14
|
+
modifyRuntimeConfig: PluginHookTap<ModifyRuntimeConfigFn<Extends['config']>>;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RuntimePluginAPI } from './api';
|
|
2
|
+
import type { Hooks } from './hooks';
|
|
3
|
+
import type { RuntimePluginExtends } from './plugin';
|
|
4
|
+
export type RuntimeContext = {};
|
|
5
|
+
export type InternalRuntimeContext<Extends extends RuntimePluginExtends> = RuntimeContext & {
|
|
6
|
+
/** All hooks. */
|
|
7
|
+
hooks: Hooks<Extends['config'], RuntimeContext & Extends['extendContext']> & Extends['extendHooks'];
|
|
8
|
+
/** All plugin registry hooks */
|
|
9
|
+
extendsHooks: Extends['extendHooks'];
|
|
10
|
+
config: Extends['config'];
|
|
11
|
+
pluginAPI?: RuntimePluginAPI<Extends>;
|
|
12
|
+
_internalContext?: InternalRuntimeContext<Extends>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { AsyncInterruptHook, CollectSyncHook, SyncHook } from '../hooks';
|
|
3
|
+
export type OnBeforeRenderFn<RuntimeContext> = (context: RuntimeContext, interrupt: (info: any) => any) => Promise<any> | any;
|
|
4
|
+
export type WrapRootFn = (root: React.ComponentType<any>) => React.ComponentType<any>;
|
|
5
|
+
export type PickContextFn<RuntimeContext> = (context: RuntimeContext) => RuntimeContext;
|
|
6
|
+
export type ModifyRuntimeConfigFn<RuntimeConfig> = (config: RuntimeConfig) => RuntimeConfig;
|
|
7
|
+
export type Hooks<RuntimeConfig, RuntimeContext> = {
|
|
8
|
+
onBeforeRender: AsyncInterruptHook<OnBeforeRenderFn<RuntimeContext>>;
|
|
9
|
+
wrapRoot: SyncHook<WrapRootFn>;
|
|
10
|
+
pickContext: SyncHook<PickContextFn<RuntimeContext>>;
|
|
11
|
+
modifyRuntimeConfig: CollectSyncHook<ModifyRuntimeConfigFn<RuntimeConfig>>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PluginHook } from '../hooks';
|
|
2
|
+
import type { Plugin } from '../plugin';
|
|
3
|
+
import type { RuntimePluginAPI } from './api';
|
|
4
|
+
import type { RuntimeContext } from './context';
|
|
5
|
+
export interface RuntimePluginExtends<Config extends Record<string, any> = {}, ExtendContext extends Record<string, any> = {}, ExtendAPI extends Record<string, any> = {}, ExtendHook extends Record<string, PluginHook<(...args: any[]) => any>> = {}> {
|
|
6
|
+
config?: Config;
|
|
7
|
+
extendContext?: ExtendContext;
|
|
8
|
+
extendApi?: ExtendAPI;
|
|
9
|
+
extendHooks?: ExtendHook;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The type of the Runtime plugin object.
|
|
13
|
+
*/
|
|
14
|
+
export type RuntimePlugin<Extends extends RuntimePluginExtends> = Plugin<RuntimePluginAPI<Extends> & Extends['extendApi'], RuntimeContext & Extends['extendContext']>;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.63.
|
|
18
|
+
"version": "2.63.8-alpha.0",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -30,11 +30,6 @@
|
|
|
30
30
|
},
|
|
31
31
|
"default": "./dist/esm/index.js"
|
|
32
32
|
},
|
|
33
|
-
"./types": {
|
|
34
|
-
"types": "./dist/types/types/index.d.ts",
|
|
35
|
-
"jsnext:source": "./src/types/index.ts",
|
|
36
|
-
"default": "./dist/cjs/types/index.js"
|
|
37
|
-
},
|
|
38
33
|
"./run": {
|
|
39
34
|
"types": "./dist/types/cli/run/run.d.ts",
|
|
40
35
|
"jsnext:source": "./src/cli/run/run.ts",
|
|
@@ -44,6 +39,11 @@
|
|
|
44
39
|
"types": "./dist/types/cli/index.d.ts",
|
|
45
40
|
"jsnext:source": "./src/cli/index.ts",
|
|
46
41
|
"default": "./dist/cjs/cli/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./runtime": {
|
|
44
|
+
"types": "./dist/types/runtime/index.d.ts",
|
|
45
|
+
"jsnext:source": "./src/runtime/index.ts",
|
|
46
|
+
"default": "./dist/esm/runtime/index.js"
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"typesVersions": {
|
|
@@ -56,30 +56,34 @@
|
|
|
56
56
|
],
|
|
57
57
|
"cli": [
|
|
58
58
|
"./dist/types/cli/index.d.ts"
|
|
59
|
+
],
|
|
60
|
+
"runtime": [
|
|
61
|
+
"./dist/types/runtime/index.d.ts"
|
|
59
62
|
]
|
|
60
63
|
}
|
|
61
64
|
},
|
|
62
65
|
"dependencies": {
|
|
63
66
|
"@swc/helpers": "0.5.13",
|
|
64
67
|
"@modern-js/node-bundle-require": "2.63.7",
|
|
68
|
+
"@modern-js/runtime-utils": "2.63.7",
|
|
65
69
|
"@modern-js/utils": "2.63.7"
|
|
66
70
|
},
|
|
67
71
|
"devDependencies": {
|
|
68
72
|
"@rsbuild/core": "1.1.13",
|
|
73
|
+
"@types/react": "^18.3.11",
|
|
69
74
|
"@types/jest": "^29",
|
|
70
75
|
"@types/node": "^14",
|
|
71
76
|
"jest": "^29",
|
|
72
77
|
"typescript": "^5",
|
|
73
|
-
"@
|
|
74
|
-
"@modern-js/uni-builder": "2.63.7",
|
|
78
|
+
"@scripts/jest-config": "2.63.7",
|
|
75
79
|
"@scripts/build": "2.63.7",
|
|
76
|
-
"@
|
|
80
|
+
"@modern-js/types": "2.63.7",
|
|
81
|
+
"@modern-js/uni-builder": "2.63.7"
|
|
77
82
|
},
|
|
78
83
|
"sideEffects": false,
|
|
79
84
|
"publishConfig": {
|
|
80
85
|
"registry": "https://registry.npmjs.org/",
|
|
81
|
-
"access": "public"
|
|
82
|
-
"provenance": true
|
|
86
|
+
"access": "public"
|
|
83
87
|
},
|
|
84
88
|
"scripts": {
|
|
85
89
|
"new": "modern-lib new",
|