@4399ywkf/core 4.0.61
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/README.md +3 -0
- package/compiled/dotenv/LICENSE +23 -0
- package/compiled/dotenv/index.js +1 -0
- package/compiled/dotenv/lib/main.d.ts +73 -0
- package/compiled/dotenv/package.json +1 -0
- package/compiled/dotenv/types/index.d.ts +59 -0
- package/compiled/dotenv-expand/LICENSE +24 -0
- package/compiled/dotenv-expand/index.js +1 -0
- package/compiled/dotenv-expand/lib/main.d.ts +29 -0
- package/compiled/dotenv-expand/package.json +1 -0
- package/compiled/just-diff/LICENSE +21 -0
- package/compiled/just-diff/index.d.ts +20 -0
- package/compiled/just-diff/index.js +1 -0
- package/compiled/just-diff/package.json +1 -0
- package/dist/config/config.d.ts +62 -0
- package/dist/config/config.js +240 -0
- package/dist/config/utils.d.ts +8 -0
- package/dist/config/utils.js +40 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.js +45 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +51 -0
- package/dist/route/defineRoutes.d.ts +1 -0
- package/dist/route/defineRoutes.js +61 -0
- package/dist/route/route.d.ts +3 -0
- package/dist/route/route.js +27 -0
- package/dist/route/routeUtils.d.ts +8 -0
- package/dist/route/routeUtils.js +46 -0
- package/dist/route/routesConfig.d.ts +6 -0
- package/dist/route/routesConfig.js +125 -0
- package/dist/route/routesConvention.d.ts +5 -0
- package/dist/route/routesConvention.js +88 -0
- package/dist/route/utils.d.ts +8 -0
- package/dist/route/utils.js +59 -0
- package/dist/service/command.d.ts +30 -0
- package/dist/service/command.js +46 -0
- package/dist/service/env.d.ts +4 -0
- package/dist/service/env.js +46 -0
- package/dist/service/generatePlugin.d.ts +4 -0
- package/dist/service/generatePlugin.js +102 -0
- package/dist/service/generator.d.ts +71 -0
- package/dist/service/generator.js +40 -0
- package/dist/service/hook.d.ts +16 -0
- package/dist/service/hook.js +57 -0
- package/dist/service/path.d.ts +15 -0
- package/dist/service/path.js +55 -0
- package/dist/service/plugin.d.ts +61 -0
- package/dist/service/plugin.js +177 -0
- package/dist/service/pluginAPI.d.ts +49 -0
- package/dist/service/pluginAPI.js +237 -0
- package/dist/service/service.d.ts +147 -0
- package/dist/service/service.js +538 -0
- package/dist/service/servicePlugin.d.ts +3 -0
- package/dist/service/servicePlugin.js +37 -0
- package/dist/service/telemetry.d.ts +32 -0
- package/dist/service/telemetry.js +127 -0
- package/dist/service/utils.d.ts +2 -0
- package/dist/service/utils.js +36 -0
- package/dist/types.d.ts +116 -0
- package/dist/types.js +77 -0
- package/package.json +49 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/service/telemetry.ts
|
|
20
|
+
var telemetry_exports = {};
|
|
21
|
+
__export(telemetry_exports, {
|
|
22
|
+
Telemetry: () => Telemetry,
|
|
23
|
+
noopStorage: () => noopStorage
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(telemetry_exports);
|
|
26
|
+
var Telemetry = class {
|
|
27
|
+
queuedEvents = [];
|
|
28
|
+
storage = new NoopStorage();
|
|
29
|
+
constructor() {
|
|
30
|
+
}
|
|
31
|
+
prefixWith(prefix) {
|
|
32
|
+
const upStream = this;
|
|
33
|
+
return {
|
|
34
|
+
record(e) {
|
|
35
|
+
const { name, ...rest } = e;
|
|
36
|
+
upStream.record({
|
|
37
|
+
name: `${prefix}:${name}`,
|
|
38
|
+
...rest
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
async flush() {
|
|
42
|
+
return upStream.flush();
|
|
43
|
+
},
|
|
44
|
+
recordAsync(e) {
|
|
45
|
+
const { name, ...rest } = e;
|
|
46
|
+
return upStream.recordAsync({
|
|
47
|
+
name: `${prefix}:${name}`,
|
|
48
|
+
...rest
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
useStorage(s) {
|
|
54
|
+
this.storage = s;
|
|
55
|
+
}
|
|
56
|
+
record(e) {
|
|
57
|
+
this.storage.save(this.addTimeStamp(e)).catch(() => {
|
|
58
|
+
this.queuedEvents.push({ event: e, tried: 1, status: "queued" });
|
|
59
|
+
this.scheduleFlush();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async recordAsync(e) {
|
|
63
|
+
try {
|
|
64
|
+
await this.storage.save(this.addTimeStamp(e));
|
|
65
|
+
return true;
|
|
66
|
+
} catch (e2) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async flush() {
|
|
71
|
+
const events = this.unFinishedEvents().map((e) => {
|
|
72
|
+
if (e.status === "queued") {
|
|
73
|
+
e.status = "sending";
|
|
74
|
+
e.tried++;
|
|
75
|
+
e.promise = this.storage.save(e.event).then(
|
|
76
|
+
() => {
|
|
77
|
+
e.status = "sent";
|
|
78
|
+
},
|
|
79
|
+
() => {
|
|
80
|
+
e.status = "queued";
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return e;
|
|
85
|
+
});
|
|
86
|
+
this.queuedEvents = events;
|
|
87
|
+
await Promise.all(events.map(({ promise }) => promise));
|
|
88
|
+
}
|
|
89
|
+
scheduleFlush() {
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
this.flush().then(this.afterFlush, this.afterFlush);
|
|
92
|
+
}, 5e3);
|
|
93
|
+
}
|
|
94
|
+
afterFlush = () => {
|
|
95
|
+
const un = this.unFinishedEvents();
|
|
96
|
+
if (un.length) {
|
|
97
|
+
this.scheduleFlush();
|
|
98
|
+
} else {
|
|
99
|
+
this.queuedEvents = [];
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
unFinishedEvents() {
|
|
103
|
+
return this.queuedEvents.filter((e) => {
|
|
104
|
+
if (e.status === "sent") {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
return e.tried < 3;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
addTimeStamp(e) {
|
|
111
|
+
if (!e.timestamp) {
|
|
112
|
+
e.timestamp = Date.now();
|
|
113
|
+
}
|
|
114
|
+
return e;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
var NoopStorage = class {
|
|
118
|
+
async save(_e) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var noopStorage = new NoopStorage();
|
|
123
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
+
0 && (module.exports = {
|
|
125
|
+
Telemetry,
|
|
126
|
+
noopStorage
|
|
127
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/service/utils.ts
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
isPromise: () => isPromise,
|
|
23
|
+
makeArray: () => makeArray
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(utils_exports);
|
|
26
|
+
function isPromise(obj) {
|
|
27
|
+
return (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
|
|
28
|
+
}
|
|
29
|
+
function makeArray(item) {
|
|
30
|
+
return Array.isArray(item) ? item : [item];
|
|
31
|
+
}
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
isPromise,
|
|
35
|
+
makeArray
|
|
36
|
+
});
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import joi from '@4399ywkf/utils/compiled/@hapi/joi';
|
|
2
|
+
import zod, { z } from '@4399ywkf/utils/compiled/zod';
|
|
3
|
+
export declare enum Env {
|
|
4
|
+
development = "development",
|
|
5
|
+
production = "production",
|
|
6
|
+
test = "test"
|
|
7
|
+
}
|
|
8
|
+
export declare enum PluginType {
|
|
9
|
+
preset = "preset",
|
|
10
|
+
plugin = "plugin"
|
|
11
|
+
}
|
|
12
|
+
export interface IPluginConfig {
|
|
13
|
+
default?: any;
|
|
14
|
+
schema?: {
|
|
15
|
+
(joi: joi.Root & {
|
|
16
|
+
zod: typeof z;
|
|
17
|
+
}): joi.Schema | zod.Schema;
|
|
18
|
+
};
|
|
19
|
+
onChange?: string | Function;
|
|
20
|
+
}
|
|
21
|
+
export declare enum ServiceStage {
|
|
22
|
+
uninitialized = 0,
|
|
23
|
+
init = 1,
|
|
24
|
+
initPresets = 2,
|
|
25
|
+
initPlugins = 3,
|
|
26
|
+
resolveConfig = 4,
|
|
27
|
+
collectAppData = 5,
|
|
28
|
+
onCheck = 6,
|
|
29
|
+
onStart = 7,
|
|
30
|
+
runCommand = 8
|
|
31
|
+
}
|
|
32
|
+
export declare enum ConfigChangeType {
|
|
33
|
+
reload = "reload",
|
|
34
|
+
regenerateTmpFiles = "regenerateTmpFiles"
|
|
35
|
+
}
|
|
36
|
+
export declare type ChangeTypeValue = string | `${ConfigChangeType}` | Function;
|
|
37
|
+
export declare type IOnChangeTypes = Record<string, ChangeTypeValue>;
|
|
38
|
+
export declare enum ApplyPluginsType {
|
|
39
|
+
add = "add",
|
|
40
|
+
modify = "modify",
|
|
41
|
+
event = "event"
|
|
42
|
+
}
|
|
43
|
+
export declare enum EnableBy {
|
|
44
|
+
register = "register",
|
|
45
|
+
config = "config"
|
|
46
|
+
}
|
|
47
|
+
export interface IRoute {
|
|
48
|
+
path: string;
|
|
49
|
+
absPath: string;
|
|
50
|
+
file: string;
|
|
51
|
+
id: string;
|
|
52
|
+
parentId?: string;
|
|
53
|
+
[key: string]: any;
|
|
54
|
+
}
|
|
55
|
+
export interface IEvent<T> {
|
|
56
|
+
(fn: {
|
|
57
|
+
(args: T): void;
|
|
58
|
+
}): void;
|
|
59
|
+
(args: {
|
|
60
|
+
fn: {
|
|
61
|
+
(args: T): void;
|
|
62
|
+
};
|
|
63
|
+
name?: string;
|
|
64
|
+
before?: string | string[];
|
|
65
|
+
stage?: number;
|
|
66
|
+
}): void;
|
|
67
|
+
}
|
|
68
|
+
export interface IModify<T, U> {
|
|
69
|
+
(fn: {
|
|
70
|
+
(initialValue: T, args: U): T;
|
|
71
|
+
}): void;
|
|
72
|
+
(fn: {
|
|
73
|
+
(initialValue: T, args: U): Promise<T>;
|
|
74
|
+
}): void;
|
|
75
|
+
(args: {
|
|
76
|
+
fn: {
|
|
77
|
+
(initialValue: T, args: U): T;
|
|
78
|
+
};
|
|
79
|
+
name?: string;
|
|
80
|
+
before?: string | string[];
|
|
81
|
+
stage?: number;
|
|
82
|
+
}): void;
|
|
83
|
+
(args: {
|
|
84
|
+
fn: {
|
|
85
|
+
(initialValue: T, args: U): Promise<T>;
|
|
86
|
+
};
|
|
87
|
+
name?: string;
|
|
88
|
+
before?: string | string[];
|
|
89
|
+
stage?: number;
|
|
90
|
+
}): void;
|
|
91
|
+
}
|
|
92
|
+
export interface IAdd<T, U> {
|
|
93
|
+
(fn: {
|
|
94
|
+
(args: T): U | U[];
|
|
95
|
+
}): void;
|
|
96
|
+
(fn: {
|
|
97
|
+
(args: T): Promise<U | U[]>;
|
|
98
|
+
}): void;
|
|
99
|
+
(args: {
|
|
100
|
+
fn: {
|
|
101
|
+
(args: T): U | U[];
|
|
102
|
+
};
|
|
103
|
+
name?: string;
|
|
104
|
+
before?: string | string[];
|
|
105
|
+
stage?: number;
|
|
106
|
+
}): void;
|
|
107
|
+
(args: {
|
|
108
|
+
fn: {
|
|
109
|
+
(args: T): Promise<U | U[]>;
|
|
110
|
+
name?: string;
|
|
111
|
+
before?: string | string[];
|
|
112
|
+
stage?: number;
|
|
113
|
+
};
|
|
114
|
+
}): void;
|
|
115
|
+
}
|
|
116
|
+
export declare type IFrameworkType = 'vue' | 'react';
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/types.ts
|
|
20
|
+
var types_exports = {};
|
|
21
|
+
__export(types_exports, {
|
|
22
|
+
ApplyPluginsType: () => ApplyPluginsType,
|
|
23
|
+
ConfigChangeType: () => ConfigChangeType,
|
|
24
|
+
EnableBy: () => EnableBy,
|
|
25
|
+
Env: () => Env,
|
|
26
|
+
PluginType: () => PluginType,
|
|
27
|
+
ServiceStage: () => ServiceStage
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(types_exports);
|
|
30
|
+
var Env = /* @__PURE__ */ ((Env2) => {
|
|
31
|
+
Env2["development"] = "development";
|
|
32
|
+
Env2["production"] = "production";
|
|
33
|
+
Env2["test"] = "test";
|
|
34
|
+
return Env2;
|
|
35
|
+
})(Env || {});
|
|
36
|
+
var PluginType = /* @__PURE__ */ ((PluginType2) => {
|
|
37
|
+
PluginType2["preset"] = "preset";
|
|
38
|
+
PluginType2["plugin"] = "plugin";
|
|
39
|
+
return PluginType2;
|
|
40
|
+
})(PluginType || {});
|
|
41
|
+
var ServiceStage = /* @__PURE__ */ ((ServiceStage2) => {
|
|
42
|
+
ServiceStage2[ServiceStage2["uninitialized"] = 0] = "uninitialized";
|
|
43
|
+
ServiceStage2[ServiceStage2["init"] = 1] = "init";
|
|
44
|
+
ServiceStage2[ServiceStage2["initPresets"] = 2] = "initPresets";
|
|
45
|
+
ServiceStage2[ServiceStage2["initPlugins"] = 3] = "initPlugins";
|
|
46
|
+
ServiceStage2[ServiceStage2["resolveConfig"] = 4] = "resolveConfig";
|
|
47
|
+
ServiceStage2[ServiceStage2["collectAppData"] = 5] = "collectAppData";
|
|
48
|
+
ServiceStage2[ServiceStage2["onCheck"] = 6] = "onCheck";
|
|
49
|
+
ServiceStage2[ServiceStage2["onStart"] = 7] = "onStart";
|
|
50
|
+
ServiceStage2[ServiceStage2["runCommand"] = 8] = "runCommand";
|
|
51
|
+
return ServiceStage2;
|
|
52
|
+
})(ServiceStage || {});
|
|
53
|
+
var ConfigChangeType = /* @__PURE__ */ ((ConfigChangeType2) => {
|
|
54
|
+
ConfigChangeType2["reload"] = "reload";
|
|
55
|
+
ConfigChangeType2["regenerateTmpFiles"] = "regenerateTmpFiles";
|
|
56
|
+
return ConfigChangeType2;
|
|
57
|
+
})(ConfigChangeType || {});
|
|
58
|
+
var ApplyPluginsType = /* @__PURE__ */ ((ApplyPluginsType2) => {
|
|
59
|
+
ApplyPluginsType2["add"] = "add";
|
|
60
|
+
ApplyPluginsType2["modify"] = "modify";
|
|
61
|
+
ApplyPluginsType2["event"] = "event";
|
|
62
|
+
return ApplyPluginsType2;
|
|
63
|
+
})(ApplyPluginsType || {});
|
|
64
|
+
var EnableBy = /* @__PURE__ */ ((EnableBy2) => {
|
|
65
|
+
EnableBy2["register"] = "register";
|
|
66
|
+
EnableBy2["config"] = "config";
|
|
67
|
+
return EnableBy2;
|
|
68
|
+
})(EnableBy || {});
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
ApplyPluginsType,
|
|
72
|
+
ConfigChangeType,
|
|
73
|
+
EnableBy,
|
|
74
|
+
Env,
|
|
75
|
+
PluginType,
|
|
76
|
+
ServiceStage
|
|
77
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@4399ywkf/core",
|
|
3
|
+
"version": "4.0.61",
|
|
4
|
+
"homepage": "https://github.com/umijs/umi/tree/master/packages/core#readme",
|
|
5
|
+
"bugs": "https://github.com/umijs/umi/issues",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/umijs/umi"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"types": "dist/index.d.ts",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"compiled"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@4399ywkf/bundler-utils": "4.0.61",
|
|
19
|
+
"@4399ywkf/utils": "4.0.61"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"dotenv": "16.0.0",
|
|
23
|
+
"dotenv-expand": "8.0.3",
|
|
24
|
+
"just-diff": "5.2.0"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"authors": [
|
|
30
|
+
"chencheng <sorrycc@gmail.com> (https://github.com/sorrycc)"
|
|
31
|
+
],
|
|
32
|
+
"compiledConfig": {
|
|
33
|
+
"deps": [
|
|
34
|
+
"dotenv",
|
|
35
|
+
"just-diff"
|
|
36
|
+
],
|
|
37
|
+
"externals": {
|
|
38
|
+
"dotenv": "$$LOCAL",
|
|
39
|
+
"just-diff": "$$LOCAL",
|
|
40
|
+
"tapable": "@4399ywkf/bundler-utils/compiled/tapable"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "umi-scripts father build",
|
|
45
|
+
"build:deps": "umi-scripts bundleDeps",
|
|
46
|
+
"dev": "umi-scripts father dev",
|
|
47
|
+
"test": "umi-scripts jest-turbo"
|
|
48
|
+
}
|
|
49
|
+
}
|