@shuvi/shared 1.0.0-rc.0 → 1.0.0-rc.11
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/esm/constants.d.ts +2 -1
- package/esm/constants.js +2 -1
- package/esm/plugins.d.ts +16 -0
- package/esm/plugins.js +27 -0
- package/lib/constants.d.ts +2 -1
- package/lib/constants.js +3 -2
- package/lib/plugins.d.ts +16 -0
- package/lib/plugins.js +31 -0
- package/package.json +8 -5
package/esm/constants.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ export declare const DEV_STYLE_HIDE_FOUC = "data-shuvi-hide-fouc";
|
|
|
9
9
|
export declare const DEV_STYLE_PREPARE = "__shuvi_style_prepare";
|
|
10
10
|
export declare const DEV_HOT_MIDDLEWARE_PATH: string;
|
|
11
11
|
export declare const DEV_HOT_LAUNCH_EDITOR_ENDPOINT: string;
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const DEV_ORIGINAL_STACK_FRAME_ENDPOINT: string;
|
|
13
|
+
export declare const DEV_SOCKET_TIMEOUT_MS = 5000;
|
|
13
14
|
export declare const ROUTE_NOT_FOUND_NAME = "404";
|
|
14
15
|
export declare const SHUVI_ERROR: {
|
|
15
16
|
APP_ERROR: {
|
package/esm/constants.js
CHANGED
|
@@ -11,7 +11,8 @@ export const DEV_STYLE_HIDE_FOUC = 'data-shuvi-hide-fouc';
|
|
|
11
11
|
export const DEV_STYLE_PREPARE = '__shuvi_style_prepare';
|
|
12
12
|
export const DEV_HOT_MIDDLEWARE_PATH = `${DEV_ONLY_ASSETS_PREFIX}/webpack-hmr`;
|
|
13
13
|
export const DEV_HOT_LAUNCH_EDITOR_ENDPOINT = `${DEV_ONLY_ASSETS_PREFIX}/development/open-stack-frame-in-editor`;
|
|
14
|
-
export const
|
|
14
|
+
export const DEV_ORIGINAL_STACK_FRAME_ENDPOINT = `${DEV_ONLY_ASSETS_PREFIX}/development/original-stack-frame`;
|
|
15
|
+
export const DEV_SOCKET_TIMEOUT_MS = 5000;
|
|
15
16
|
export const ROUTE_NOT_FOUND_NAME = `404`;
|
|
16
17
|
export const SHUVI_ERROR = {
|
|
17
18
|
APP_ERROR: {
|
package/esm/plugins.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HookManager, HookMap, Setup, IPluginHandlers, PluginOptions as _PluginOptions, IPluginInstance } from '@shuvi/hook';
|
|
2
|
+
export declare const GROUP_BEFORE_USER = -1;
|
|
3
|
+
export declare const GROUP_USER = 0;
|
|
4
|
+
export declare const GROUP_AFTER_USER = 1;
|
|
5
|
+
export declare type PluginOptions = Omit<_PluginOptions, 'group' | 'order'>;
|
|
6
|
+
export interface PluginFunc<HM extends HookMap, C> {
|
|
7
|
+
(handler: IPluginHandlers<HM, C> & {
|
|
8
|
+
setup?: Setup;
|
|
9
|
+
}, options?: PluginOptions): IPluginInstance<HM, C>;
|
|
10
|
+
}
|
|
11
|
+
export interface CreatePluginByGroup<HM extends HookMap, C> {
|
|
12
|
+
createPluginBefore: PluginFunc<HM, C>;
|
|
13
|
+
createPlugin: PluginFunc<HM, C>;
|
|
14
|
+
createPluginAfter: PluginFunc<HM, C>;
|
|
15
|
+
}
|
|
16
|
+
export declare function createPluginCreator<HM extends HookMap, C>(manager: HookManager<HM, C>): CreatePluginByGroup<HM, C>;
|
package/esm/plugins.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const GROUP_BEFORE_USER = -1;
|
|
2
|
+
export const GROUP_USER = 0;
|
|
3
|
+
export const GROUP_AFTER_USER = 1;
|
|
4
|
+
export function createPluginCreator(manager) {
|
|
5
|
+
const { createPlugin } = manager;
|
|
6
|
+
const createOptions = (group, opt = {}) => {
|
|
7
|
+
return {
|
|
8
|
+
name: opt.name,
|
|
9
|
+
pre: opt.pre,
|
|
10
|
+
post: opt.post,
|
|
11
|
+
rivals: opt.rivals,
|
|
12
|
+
required: opt.required,
|
|
13
|
+
group
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
createPluginBefore(handler, options) {
|
|
18
|
+
return createPlugin(handler, createOptions(GROUP_BEFORE_USER, options));
|
|
19
|
+
},
|
|
20
|
+
createPlugin(handler, options) {
|
|
21
|
+
return createPlugin(handler, createOptions(GROUP_USER, options));
|
|
22
|
+
},
|
|
23
|
+
createPluginAfter(handler, options) {
|
|
24
|
+
return createPlugin(handler, createOptions(GROUP_AFTER_USER, options));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
package/lib/constants.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ export declare const DEV_STYLE_HIDE_FOUC = "data-shuvi-hide-fouc";
|
|
|
9
9
|
export declare const DEV_STYLE_PREPARE = "__shuvi_style_prepare";
|
|
10
10
|
export declare const DEV_HOT_MIDDLEWARE_PATH: string;
|
|
11
11
|
export declare const DEV_HOT_LAUNCH_EDITOR_ENDPOINT: string;
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const DEV_ORIGINAL_STACK_FRAME_ENDPOINT: string;
|
|
13
|
+
export declare const DEV_SOCKET_TIMEOUT_MS = 5000;
|
|
13
14
|
export declare const ROUTE_NOT_FOUND_NAME = "404";
|
|
14
15
|
export declare const SHUVI_ERROR: {
|
|
15
16
|
APP_ERROR: {
|
package/lib/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BUNDLER_TARGET_SERVER = exports.BUNDLER_TARGET_CLIENT = exports.BUNDLER_DEFAULT_TARGET = exports.SHUVI_ERROR = exports.ROUTE_NOT_FOUND_NAME = exports.
|
|
3
|
+
exports.BUNDLER_TARGET_SERVER = exports.BUNDLER_TARGET_CLIENT = exports.BUNDLER_DEFAULT_TARGET = exports.SHUVI_ERROR = exports.ROUTE_NOT_FOUND_NAME = exports.DEV_SOCKET_TIMEOUT_MS = exports.DEV_ORIGINAL_STACK_FRAME_ENDPOINT = exports.DEV_HOT_LAUNCH_EDITOR_ENDPOINT = exports.DEV_HOT_MIDDLEWARE_PATH = exports.DEV_STYLE_PREPARE = exports.DEV_STYLE_HIDE_FOUC = exports.DEV_STYLE_ANCHOR_ID = exports.CLIENT_APPDATA_ID = exports.CLIENT_CONTAINER_ID = exports.PUBLIC_ENV_PREFIX = exports.ROUTE_RESOURCE_QUERYSTRING = exports.DEV_ONLY_ASSETS_PREFIX = exports.NAME = void 0;
|
|
4
4
|
// common
|
|
5
5
|
exports.NAME = 'shuvi';
|
|
6
6
|
exports.DEV_ONLY_ASSETS_PREFIX = `/_${exports.NAME}`;
|
|
@@ -14,7 +14,8 @@ exports.DEV_STYLE_HIDE_FOUC = 'data-shuvi-hide-fouc';
|
|
|
14
14
|
exports.DEV_STYLE_PREPARE = '__shuvi_style_prepare';
|
|
15
15
|
exports.DEV_HOT_MIDDLEWARE_PATH = `${exports.DEV_ONLY_ASSETS_PREFIX}/webpack-hmr`;
|
|
16
16
|
exports.DEV_HOT_LAUNCH_EDITOR_ENDPOINT = `${exports.DEV_ONLY_ASSETS_PREFIX}/development/open-stack-frame-in-editor`;
|
|
17
|
-
exports.
|
|
17
|
+
exports.DEV_ORIGINAL_STACK_FRAME_ENDPOINT = `${exports.DEV_ONLY_ASSETS_PREFIX}/development/original-stack-frame`;
|
|
18
|
+
exports.DEV_SOCKET_TIMEOUT_MS = 5000;
|
|
18
19
|
exports.ROUTE_NOT_FOUND_NAME = `404`;
|
|
19
20
|
exports.SHUVI_ERROR = {
|
|
20
21
|
APP_ERROR: {
|
package/lib/plugins.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HookManager, HookMap, Setup, IPluginHandlers, PluginOptions as _PluginOptions, IPluginInstance } from '@shuvi/hook';
|
|
2
|
+
export declare const GROUP_BEFORE_USER = -1;
|
|
3
|
+
export declare const GROUP_USER = 0;
|
|
4
|
+
export declare const GROUP_AFTER_USER = 1;
|
|
5
|
+
export declare type PluginOptions = Omit<_PluginOptions, 'group' | 'order'>;
|
|
6
|
+
export interface PluginFunc<HM extends HookMap, C> {
|
|
7
|
+
(handler: IPluginHandlers<HM, C> & {
|
|
8
|
+
setup?: Setup;
|
|
9
|
+
}, options?: PluginOptions): IPluginInstance<HM, C>;
|
|
10
|
+
}
|
|
11
|
+
export interface CreatePluginByGroup<HM extends HookMap, C> {
|
|
12
|
+
createPluginBefore: PluginFunc<HM, C>;
|
|
13
|
+
createPlugin: PluginFunc<HM, C>;
|
|
14
|
+
createPluginAfter: PluginFunc<HM, C>;
|
|
15
|
+
}
|
|
16
|
+
export declare function createPluginCreator<HM extends HookMap, C>(manager: HookManager<HM, C>): CreatePluginByGroup<HM, C>;
|
package/lib/plugins.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPluginCreator = exports.GROUP_AFTER_USER = exports.GROUP_USER = exports.GROUP_BEFORE_USER = void 0;
|
|
4
|
+
exports.GROUP_BEFORE_USER = -1;
|
|
5
|
+
exports.GROUP_USER = 0;
|
|
6
|
+
exports.GROUP_AFTER_USER = 1;
|
|
7
|
+
function createPluginCreator(manager) {
|
|
8
|
+
const { createPlugin } = manager;
|
|
9
|
+
const createOptions = (group, opt = {}) => {
|
|
10
|
+
return {
|
|
11
|
+
name: opt.name,
|
|
12
|
+
pre: opt.pre,
|
|
13
|
+
post: opt.post,
|
|
14
|
+
rivals: opt.rivals,
|
|
15
|
+
required: opt.required,
|
|
16
|
+
group
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
createPluginBefore(handler, options) {
|
|
21
|
+
return createPlugin(handler, createOptions(exports.GROUP_BEFORE_USER, options));
|
|
22
|
+
},
|
|
23
|
+
createPlugin(handler, options) {
|
|
24
|
+
return createPlugin(handler, createOptions(exports.GROUP_USER, options));
|
|
25
|
+
},
|
|
26
|
+
createPluginAfter(handler, options) {
|
|
27
|
+
return createPlugin(handler, createOptions(exports.GROUP_AFTER_USER, options));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.createPluginCreator = createPluginCreator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/shared",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.11",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -13,9 +13,6 @@
|
|
|
13
13
|
"esm"
|
|
14
14
|
],
|
|
15
15
|
"sideEffects": false,
|
|
16
|
-
"engines": {
|
|
17
|
-
"node": ">= 12.0.0"
|
|
18
|
-
},
|
|
19
16
|
"scripts": {
|
|
20
17
|
"dev": "run-p watch:*",
|
|
21
18
|
"watch:esm": "tsc -p tsconfig.build.json -m esnext --outDir esm -w",
|
|
@@ -24,5 +21,11 @@
|
|
|
24
21
|
"build": "run-p build:*",
|
|
25
22
|
"build:esm": "tsc -p tsconfig.build.json -m esnext --outDir esm",
|
|
26
23
|
"build:cjs": "tsc -p tsconfig.build.json -m commonjs --outDir lib"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">= 12.0.0"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@shuvi/hook": "1.0.0-rc.11"
|
|
27
30
|
}
|
|
28
|
-
}
|
|
31
|
+
}
|