@oiyo/core 0.4.0-beta.2 → 0.4.0-beta.4
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/index.cjs +2 -2
- package/dist/index.d.ts +42 -0
- package/dist/index.mjs +2 -2
- package/package.json +6 -9
- package/dist/index.d.cts +0 -359
- package/dist/index.d.mts +0 -359
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oiyo/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.0-beta.
|
|
4
|
+
"version": "0.4.0-beta.4",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "skiyee",
|
|
7
7
|
"email": "319619193@qq.com",
|
|
@@ -19,10 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
-
"types":
|
|
23
|
-
"import": "./dist/index.d.mts",
|
|
24
|
-
"require": "./dist/index.d.cts"
|
|
25
|
-
},
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
26
23
|
"import": "./dist/index.mjs",
|
|
27
24
|
"require": "./dist/index.cjs"
|
|
28
25
|
},
|
|
@@ -30,7 +27,7 @@
|
|
|
30
27
|
},
|
|
31
28
|
"main": "./dist/index.cjs",
|
|
32
29
|
"module": "./dist/index.mjs",
|
|
33
|
-
"types": "./dist/index.d.
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
34
31
|
"files": [
|
|
35
32
|
"THIRD_PARTY_NOTICES.md",
|
|
36
33
|
"dist"
|
|
@@ -55,7 +52,7 @@
|
|
|
55
52
|
"pathe": "^2.0.3",
|
|
56
53
|
"sucrase": "^3.35.1",
|
|
57
54
|
"tinyglobby": "^0.2.15",
|
|
58
|
-
"@oiyo/config": "0.4.0-beta.
|
|
55
|
+
"@oiyo/config": "0.4.0-beta.4"
|
|
59
56
|
},
|
|
60
57
|
"devDependencies": {
|
|
61
58
|
"@types/babel__traverse": "^7.28.0",
|
|
@@ -63,8 +60,8 @@
|
|
|
63
60
|
"vue": "3.4.21"
|
|
64
61
|
},
|
|
65
62
|
"scripts": {
|
|
66
|
-
"build": "tsdown",
|
|
67
|
-
"dev": "tsdown --watch",
|
|
63
|
+
"build": "tsdown --env.NODE_ENV production",
|
|
64
|
+
"dev": "tsdown --watch --env.NODE_ENV development",
|
|
68
65
|
"test": "vitest",
|
|
69
66
|
"test:run": "vitest run"
|
|
70
67
|
}
|
package/dist/index.d.cts
DELETED
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @oiyo/core v0.4.0-beta.2
|
|
3
|
-
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
|
-
* Commercial software. See LICENSE for terms.
|
|
5
|
-
* Official site: https://oiyo.js.org
|
|
6
|
-
*/
|
|
7
|
-
import { ComponentScanTarget, GlobalStyle, OiyoConfig, PagesConfig, TabBarItem } from "@oiyo/config";
|
|
8
|
-
import { Plugin } from "vite";
|
|
9
|
-
|
|
10
|
-
//#region src/logger.d.ts
|
|
11
|
-
type LogType = 'error' | 'warn' | 'info' | 'debug';
|
|
12
|
-
type LogLevel = 'silent' | LogType | 'verbose';
|
|
13
|
-
declare const LogLevels: Record<LogLevel, number>;
|
|
14
|
-
interface LogOptions {
|
|
15
|
-
clear?: boolean;
|
|
16
|
-
timestamp?: boolean;
|
|
17
|
-
scope?: string;
|
|
18
|
-
}
|
|
19
|
-
interface LogErrorOptions extends LogOptions {
|
|
20
|
-
error?: Error | null;
|
|
21
|
-
}
|
|
22
|
-
interface Logger {
|
|
23
|
-
withScope: (scope: string) => Logger;
|
|
24
|
-
debug: (msg: string, options?: LogOptions) => void;
|
|
25
|
-
info: (msg: string, options?: LogOptions) => void;
|
|
26
|
-
warn: (msg: string, options?: LogOptions) => void;
|
|
27
|
-
warnOnce: (msg: string, options?: LogOptions) => void;
|
|
28
|
-
error: (msg: string, options?: LogErrorOptions) => void;
|
|
29
|
-
clearScreen: (type: LogType) => void;
|
|
30
|
-
hasErrorLogged: (error: Error) => boolean;
|
|
31
|
-
hasWarned: boolean;
|
|
32
|
-
}
|
|
33
|
-
interface LoggerOptions {
|
|
34
|
-
prefix?: string;
|
|
35
|
-
scope?: string;
|
|
36
|
-
allowClearScreen?: boolean;
|
|
37
|
-
customLogger?: Logger;
|
|
38
|
-
console?: Console;
|
|
39
|
-
}
|
|
40
|
-
declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/module/api/types.d.ts
|
|
43
|
-
interface ApiFile {
|
|
44
|
-
filePath: string;
|
|
45
|
-
exportName: string;
|
|
46
|
-
importPath: string;
|
|
47
|
-
importName: string;
|
|
48
|
-
isType: boolean;
|
|
49
|
-
isNodeModule: boolean;
|
|
50
|
-
}
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region src/state/index.d.ts
|
|
53
|
-
interface OiyoMetadata {
|
|
54
|
-
hash: string;
|
|
55
|
-
project: {
|
|
56
|
-
rootDir: string;
|
|
57
|
-
};
|
|
58
|
-
versions: {
|
|
59
|
-
oiyo: string;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
declare class OiyoState {
|
|
63
|
-
private readonly config;
|
|
64
|
-
constructor(config: OiyoConfig);
|
|
65
|
-
get stateDir(): string;
|
|
66
|
-
get typesDir(): string;
|
|
67
|
-
get srcDir(): string;
|
|
68
|
-
get declarationEntryPath(): string;
|
|
69
|
-
get tsconfigPath(): string;
|
|
70
|
-
get metadataPath(): string;
|
|
71
|
-
get declarationPaths(): string[];
|
|
72
|
-
private relativeToState;
|
|
73
|
-
private stringifyJson;
|
|
74
|
-
private serializeMetadataInput;
|
|
75
|
-
generateMetadataHash(): string;
|
|
76
|
-
generateMetadata(): OiyoMetadata;
|
|
77
|
-
readMetadata(): OiyoMetadata | null;
|
|
78
|
-
writeMetadata(): OiyoMetadata;
|
|
79
|
-
canReuseGeneratedState(): boolean;
|
|
80
|
-
generateDeclarationEntry(): string;
|
|
81
|
-
generateTsconfig(): string;
|
|
82
|
-
writeTsconfig(): string;
|
|
83
|
-
writeDeclarationEntry(): string;
|
|
84
|
-
ensureDeclarationEntry(): string;
|
|
85
|
-
markGenerated(): OiyoMetadata;
|
|
86
|
-
}
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/module/api/instance.d.ts
|
|
89
|
-
declare class OiyoModApi {
|
|
90
|
-
private readonly config;
|
|
91
|
-
private readonly logger;
|
|
92
|
-
private readonly oiyoState;
|
|
93
|
-
private sources;
|
|
94
|
-
apis: Map<string, ApiFile>;
|
|
95
|
-
marcoNames: string[];
|
|
96
|
-
vmNames: string[];
|
|
97
|
-
constructor(config: OiyoConfig, deps: {
|
|
98
|
-
logger: Logger;
|
|
99
|
-
oiyoState: OiyoState;
|
|
100
|
-
});
|
|
101
|
-
private get srcDir();
|
|
102
|
-
private get declarationDir();
|
|
103
|
-
private get declarationFile();
|
|
104
|
-
shouldSkipImport(name: string): boolean;
|
|
105
|
-
forwardImport(api: ApiFile): ApiFile;
|
|
106
|
-
private recordApiSource;
|
|
107
|
-
private toApiSource;
|
|
108
|
-
private saveApi;
|
|
109
|
-
private directApi;
|
|
110
|
-
private scanApi;
|
|
111
|
-
scanApis(): Promise<(ApiFile[] | void[] | undefined)[]>;
|
|
112
|
-
private findApiSource;
|
|
113
|
-
isApi(file: string): boolean;
|
|
114
|
-
enterApi(file: string): Promise<boolean>;
|
|
115
|
-
exitApi(file: string): boolean;
|
|
116
|
-
generateDeclaration(): string;
|
|
117
|
-
writeDeclaration(): void;
|
|
118
|
-
applyApis(source: string, file: string): {
|
|
119
|
-
code: string;
|
|
120
|
-
map: import("magic-string").SourceMap;
|
|
121
|
-
} | null;
|
|
122
|
-
}
|
|
123
|
-
//#endregion
|
|
124
|
-
//#region src/module/component/types.d.ts
|
|
125
|
-
interface ComponentFile {
|
|
126
|
-
filePath: string;
|
|
127
|
-
exportName: string;
|
|
128
|
-
importName: string;
|
|
129
|
-
importPath: string;
|
|
130
|
-
isNodeModule: boolean;
|
|
131
|
-
}
|
|
132
|
-
interface ComponentScanSource extends ComponentScanTarget {
|
|
133
|
-
dir: string;
|
|
134
|
-
patterns?: string[];
|
|
135
|
-
isNodeModule: boolean;
|
|
136
|
-
}
|
|
137
|
-
//#endregion
|
|
138
|
-
//#region src/module/component/instance.d.ts
|
|
139
|
-
declare class OiyoModComponent {
|
|
140
|
-
private readonly config;
|
|
141
|
-
private readonly logger;
|
|
142
|
-
private readonly oiyoState;
|
|
143
|
-
private readonly oiyoApi;
|
|
144
|
-
private sources;
|
|
145
|
-
components: Map<string, ComponentFile>;
|
|
146
|
-
renderTagNames: string[];
|
|
147
|
-
constructor(config: OiyoConfig, deps: {
|
|
148
|
-
logger: Logger;
|
|
149
|
-
oiyoState: OiyoState;
|
|
150
|
-
oiyoApi: OiyoModApi;
|
|
151
|
-
});
|
|
152
|
-
private get srcDir();
|
|
153
|
-
private get declarationDir();
|
|
154
|
-
private get declarationFile();
|
|
155
|
-
shouldSkipImport(name: string): boolean;
|
|
156
|
-
private recordComponentSource;
|
|
157
|
-
private toComponentSource;
|
|
158
|
-
private saveComponent;
|
|
159
|
-
private scanComponentByDirect;
|
|
160
|
-
private scanComponentByDir;
|
|
161
|
-
private scanComponent;
|
|
162
|
-
scanComponents(): Promise<void>;
|
|
163
|
-
findComponentSource(file: string): ComponentScanSource | undefined;
|
|
164
|
-
isComponent(file: string): boolean;
|
|
165
|
-
enterComponent(file: string): boolean;
|
|
166
|
-
exitComponent(file: string): ComponentFile | undefined;
|
|
167
|
-
generateDeclaration(): string;
|
|
168
|
-
writeDeclaration(): void;
|
|
169
|
-
applyComponents(source: string, file: string, options?: {
|
|
170
|
-
withApis: boolean;
|
|
171
|
-
}): {
|
|
172
|
-
code: string;
|
|
173
|
-
map: import("magic-string").SourceMap;
|
|
174
|
-
} | null;
|
|
175
|
-
}
|
|
176
|
-
//#endregion
|
|
177
|
-
//#region src/module/layout/types.d.ts
|
|
178
|
-
interface LayoutFile {
|
|
179
|
-
useName: string;
|
|
180
|
-
componentName: string;
|
|
181
|
-
filePath: string;
|
|
182
|
-
}
|
|
183
|
-
//#endregion
|
|
184
|
-
//#region src/module/layout/instance.d.ts
|
|
185
|
-
declare class OiyoModLayout {
|
|
186
|
-
private readonly config;
|
|
187
|
-
private readonly logger;
|
|
188
|
-
private readonly oiyoState;
|
|
189
|
-
layouts: Map<string, LayoutFile>;
|
|
190
|
-
constructor(config: OiyoConfig, deps: {
|
|
191
|
-
logger: Logger;
|
|
192
|
-
oiyoState: OiyoState;
|
|
193
|
-
});
|
|
194
|
-
private get srcDir();
|
|
195
|
-
private get layoutDir();
|
|
196
|
-
get declarationDir(): string;
|
|
197
|
-
get declarationFile(): string;
|
|
198
|
-
private toLayout;
|
|
199
|
-
private saveLayout;
|
|
200
|
-
scanLayouts(): Promise<Map<string, LayoutFile>>;
|
|
201
|
-
isLayout(file: string): boolean;
|
|
202
|
-
enterLayout(file: string): boolean;
|
|
203
|
-
exitLayout(file: string): boolean;
|
|
204
|
-
generateDeclaration(): string;
|
|
205
|
-
writeDeclaration(): boolean;
|
|
206
|
-
}
|
|
207
|
-
//#endregion
|
|
208
|
-
//#region src/module/layout/placeholder.d.ts
|
|
209
|
-
declare const OiyoLayout: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
210
|
-
[key: string]: any;
|
|
211
|
-
}>[] | undefined, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
212
|
-
//#endregion
|
|
213
|
-
//#region src/module/shared/extractor/import.d.ts
|
|
214
|
-
interface ImportInfo {
|
|
215
|
-
importPath: string;
|
|
216
|
-
exportName: string;
|
|
217
|
-
importName: string;
|
|
218
|
-
offsetStart?: number;
|
|
219
|
-
offsetEnd?: number;
|
|
220
|
-
}
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region src/module/root/instance.d.ts
|
|
223
|
-
declare class OiyoModRoot {
|
|
224
|
-
readonly config: OiyoConfig;
|
|
225
|
-
private readonly logger;
|
|
226
|
-
rootTemplateImports: Map<string, ImportInfo>;
|
|
227
|
-
rootTemplateContent: string;
|
|
228
|
-
rootTemplateScript: string;
|
|
229
|
-
rootMarcoImports: Map<string, ImportInfo>;
|
|
230
|
-
rootMarcoScript: string;
|
|
231
|
-
rootVM?: string;
|
|
232
|
-
constructor(config: OiyoConfig, deps: {
|
|
233
|
-
logger: Logger;
|
|
234
|
-
});
|
|
235
|
-
get srcDir(): string;
|
|
236
|
-
get rootPath(): string;
|
|
237
|
-
isRootPath(absPath: string): boolean;
|
|
238
|
-
parseRoot(source: string): boolean;
|
|
239
|
-
transformRoot(source: string): {
|
|
240
|
-
code: string;
|
|
241
|
-
map: import("magic-string").SourceMap;
|
|
242
|
-
};
|
|
243
|
-
private resetRootTemplate;
|
|
244
|
-
shouldRefreshView(code: string): boolean;
|
|
245
|
-
private resetRootVM;
|
|
246
|
-
shouldRefreshVM: (code: string) => boolean;
|
|
247
|
-
}
|
|
248
|
-
//#endregion
|
|
249
|
-
//#region src/module/root/macro.d.ts
|
|
250
|
-
type RootContextFactory<T> = () => T;
|
|
251
|
-
declare const defineRootContext: <T>(factory: RootContextFactory<T>) => T;
|
|
252
|
-
declare const useRootContext: <T>() => T;
|
|
253
|
-
//#endregion
|
|
254
|
-
//#region src/module/root/virtual-module.d.ts
|
|
255
|
-
declare const VIRTUAL_ROOT_CONTEXT_ID = "virtual:oiyo-root-context";
|
|
256
|
-
declare const RESOLVED_VIRTUAL_ROOT_CONTEXT_ID = "\0virtual:oiyo-root-context";
|
|
257
|
-
//#endregion
|
|
258
|
-
//#region src/module/shared/type.d.ts
|
|
259
|
-
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
260
|
-
type RemoveIndexSignature<T> = { [K in keyof T as string extends K ? never : number extends K ? never : symbol extends K ? never : K]: T[K] };
|
|
261
|
-
type StrictOmit<T, K extends keyof RemoveIndexSignature<T>> = Prettify<Omit<RemoveIndexSignature<T>, K>>;
|
|
262
|
-
//#endregion
|
|
263
|
-
//#region src/module/route/types.d.ts
|
|
264
|
-
interface Route {
|
|
265
|
-
pagePath: string;
|
|
266
|
-
filePath: string;
|
|
267
|
-
pageBelong: string;
|
|
268
|
-
pageMeta: ResolvedPageMeta | null;
|
|
269
|
-
}
|
|
270
|
-
type MetaValue = string | number | boolean | object | null | MetaObject | MetaValue[];
|
|
271
|
-
interface MetaObject {
|
|
272
|
-
[key: string]: MetaValue | undefined;
|
|
273
|
-
}
|
|
274
|
-
interface Tab extends StrictOmit<TabBarItem, 'pagePath'> {
|
|
275
|
-
index: number;
|
|
276
|
-
}
|
|
277
|
-
interface BasePageMeta {
|
|
278
|
-
type?: 'page' | 'home';
|
|
279
|
-
layout?: string | false;
|
|
280
|
-
style?: GlobalStyle;
|
|
281
|
-
tab?: Tab;
|
|
282
|
-
}
|
|
283
|
-
interface ResolvedPageMeta extends BasePageMeta, MetaObject {}
|
|
284
|
-
//#endregion
|
|
285
|
-
//#region src/module/route/instance.d.ts
|
|
286
|
-
declare class OiyoModRoute {
|
|
287
|
-
private readonly config;
|
|
288
|
-
private readonly logger;
|
|
289
|
-
private readonly oiyoState;
|
|
290
|
-
private readonly oiyoRoot?;
|
|
291
|
-
private readonly oiyoLayout?;
|
|
292
|
-
routes: Map<string, Route>;
|
|
293
|
-
private pagesConfig;
|
|
294
|
-
private pagesConfigWatcher?;
|
|
295
|
-
constructor(config: OiyoConfig, deps: {
|
|
296
|
-
logger: Logger;
|
|
297
|
-
oiyoState: OiyoState;
|
|
298
|
-
});
|
|
299
|
-
constructor(config: OiyoConfig, deps: {
|
|
300
|
-
logger: Logger;
|
|
301
|
-
oiyoState: OiyoState;
|
|
302
|
-
oiyoRoot: OiyoModRoot;
|
|
303
|
-
oiyoLayout: OiyoModLayout;
|
|
304
|
-
});
|
|
305
|
-
private get srcDir();
|
|
306
|
-
private get mainPackageDir();
|
|
307
|
-
private get subPackageDirs();
|
|
308
|
-
private get pagesJsonFile();
|
|
309
|
-
private get declarationDir();
|
|
310
|
-
private get declarationFile();
|
|
311
|
-
private toRoute;
|
|
312
|
-
private saveRoute;
|
|
313
|
-
private loadPagesConfig;
|
|
314
|
-
scanRoutes(): Promise<Map<string, Route>>;
|
|
315
|
-
isRoute(file: string): boolean;
|
|
316
|
-
enterRoute(file: string): boolean;
|
|
317
|
-
exitRoute(file: string): boolean;
|
|
318
|
-
private resolvePagesJson;
|
|
319
|
-
writePagesJson(userPageJson?: PagesConfig): boolean;
|
|
320
|
-
generateDeclaration(userPageJson?: PagesConfig): string;
|
|
321
|
-
writeDeclaration(userPageJson?: PagesConfig): string;
|
|
322
|
-
watchPagesConfig(onUpdateCallback?: () => void | Promise<void>): Promise<void>;
|
|
323
|
-
unwatchPagesConfig(): Promise<void>;
|
|
324
|
-
transformPage(source: string, file: string): Promise<{
|
|
325
|
-
code: string;
|
|
326
|
-
map: import("magic-string").SourceMap;
|
|
327
|
-
}>;
|
|
328
|
-
}
|
|
329
|
-
//#endregion
|
|
330
|
-
//#region src/module/route/macro.d.ts
|
|
331
|
-
interface PageMeta extends BasePageMeta {
|
|
332
|
-
[key: string]: unknown;
|
|
333
|
-
}
|
|
334
|
-
declare const definePageMeta: (meta: PageMeta) => void;
|
|
335
|
-
//#endregion
|
|
336
|
-
//#region src/module/route/placeholder.d.ts
|
|
337
|
-
declare const OiyoPage: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
338
|
-
//#endregion
|
|
339
|
-
//#region src/plugin/context.d.ts
|
|
340
|
-
interface OiyoContext {
|
|
341
|
-
config: OiyoConfig;
|
|
342
|
-
api: OiyoModApi;
|
|
343
|
-
component: OiyoModComponent;
|
|
344
|
-
logger: Logger;
|
|
345
|
-
layout: OiyoModLayout;
|
|
346
|
-
state: OiyoState;
|
|
347
|
-
route: OiyoModRoute;
|
|
348
|
-
root: OiyoModRoot;
|
|
349
|
-
}
|
|
350
|
-
//#endregion
|
|
351
|
-
//#region src/plugin/index.d.ts
|
|
352
|
-
declare module 'vite' {
|
|
353
|
-
interface UserConfig {
|
|
354
|
-
oiyo?: OiyoContext;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
declare function OiyoCorePlugin(options?: OiyoConfig): Plugin[];
|
|
358
|
-
//#endregion
|
|
359
|
-
export { LogErrorOptions, LogLevel, LogLevels, LogOptions, LogType, Logger, LoggerOptions, OiyoCorePlugin, OiyoLayout, OiyoMetadata, OiyoModApi, OiyoModComponent, OiyoModLayout, OiyoModRoot, OiyoModRoute, OiyoPage, OiyoState, type PageMeta, RESOLVED_VIRTUAL_ROOT_CONTEXT_ID, VIRTUAL_ROOT_CONTEXT_ID, createLogger, definePageMeta, defineRootContext, useRootContext };
|