@cfp-studio/core 1.0.0 → 1.0.1
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +15 -10
- package/package.json +5 -4
package/dist/index.d.mts
CHANGED
|
@@ -135,7 +135,7 @@ type OnServerStart = (options: {
|
|
|
135
135
|
* @param frameworkPlugins - 框架插件工厂数组
|
|
136
136
|
* @returns 兼容插件的名称,如果未找到则返回 null
|
|
137
137
|
*/
|
|
138
|
-
declare function findCompatiblePlugin(logger: Logger, rootDir: string, frameworkPlugins: FrameworkPluginFactory[]): Promise<string
|
|
138
|
+
declare function findCompatiblePlugin(logger: Logger, rootDir: string, frameworkPlugins: FrameworkPluginFactory[]): Promise<string>;
|
|
139
139
|
|
|
140
140
|
declare function toVitePath(absoluteFilePath: string): string;
|
|
141
141
|
|
package/dist/index.d.ts
CHANGED
|
@@ -135,7 +135,7 @@ type OnServerStart = (options: {
|
|
|
135
135
|
* @param frameworkPlugins - 框架插件工厂数组
|
|
136
136
|
* @returns 兼容插件的名称,如果未找到则返回 null
|
|
137
137
|
*/
|
|
138
|
-
declare function findCompatiblePlugin(logger: Logger, rootDir: string, frameworkPlugins: FrameworkPluginFactory[]): Promise<string
|
|
138
|
+
declare function findCompatiblePlugin(logger: Logger, rootDir: string, frameworkPlugins: FrameworkPluginFactory[]): Promise<string>;
|
|
139
139
|
|
|
140
140
|
declare function toVitePath(absoluteFilePath: string): string;
|
|
141
141
|
|
package/dist/index.mjs
CHANGED
|
@@ -372,7 +372,7 @@ function cssModulesWithoutSuffixPlugin() {
|
|
|
372
372
|
name: "previewjs:css-modules-without-suffix",
|
|
373
373
|
/**
|
|
374
374
|
* 转换代码,为不带有 .module.css 后缀的 CSS 模块导入添加后缀
|
|
375
|
-
*
|
|
375
|
+
*
|
|
376
376
|
* @param code - 要转换的代码
|
|
377
377
|
* @param id - 模块的唯一标识符
|
|
378
378
|
* @returns 转换后的代码,如果不需要转换则返回 undefined
|
|
@@ -381,10 +381,10 @@ function cssModulesWithoutSuffixPlugin() {
|
|
|
381
381
|
const parts = id.split("?");
|
|
382
382
|
const _id = parts[0];
|
|
383
383
|
if (!_id) {
|
|
384
|
-
return;
|
|
384
|
+
return null;
|
|
385
385
|
}
|
|
386
386
|
if (!extensions.has(path.extname(_id))) {
|
|
387
|
-
return;
|
|
387
|
+
return null;
|
|
388
388
|
}
|
|
389
389
|
return code.replace(
|
|
390
390
|
importRegexp,
|
|
@@ -461,7 +461,7 @@ function previewScriptPlugin() {
|
|
|
461
461
|
*/
|
|
462
462
|
load(id) {
|
|
463
463
|
if (!id.startsWith(PATH_PREFIX)) {
|
|
464
|
-
return;
|
|
464
|
+
return null;
|
|
465
465
|
}
|
|
466
466
|
const base64EncodedOptions = id.substring(PATH_PREFIX.length);
|
|
467
467
|
const options = JSON.parse(
|
|
@@ -580,15 +580,15 @@ function publicAssetImportPluginPlugin({
|
|
|
580
580
|
*/
|
|
581
581
|
resolveId: async (source, importer) => {
|
|
582
582
|
if (!importer || !source.startsWith("/") || source.startsWith("/__previewjs__/")) {
|
|
583
|
-
return;
|
|
583
|
+
return null;
|
|
584
584
|
}
|
|
585
585
|
const publicDirAbsolutePath = path.join(rootDir, publicDir);
|
|
586
586
|
const potentialPublicFilePath = path.join(publicDirAbsolutePath, source);
|
|
587
587
|
if (!potentialPublicFilePath.startsWith(publicDirAbsolutePath + path.sep)) {
|
|
588
|
-
return;
|
|
588
|
+
return null;
|
|
589
589
|
}
|
|
590
590
|
if (!await fs$1.pathExists(potentialPublicFilePath)) {
|
|
591
|
-
return;
|
|
591
|
+
return null;
|
|
592
592
|
}
|
|
593
593
|
return source;
|
|
594
594
|
}
|
|
@@ -759,13 +759,13 @@ function virtualPlugin(options) {
|
|
|
759
759
|
handleHotUpdate: async (context) => {
|
|
760
760
|
const moduleGraph = options.moduleGraph();
|
|
761
761
|
if (!moduleGraph) {
|
|
762
|
-
return;
|
|
762
|
+
return null;
|
|
763
763
|
}
|
|
764
764
|
const filePath = path.relative(rootDir, context.file);
|
|
765
765
|
const absoluteFilePath = path.join(rootDir, filePath);
|
|
766
766
|
const entry = await reader.read(absoluteFilePath);
|
|
767
767
|
if (!entry || entry.kind !== "file") {
|
|
768
|
-
return;
|
|
768
|
+
return null;
|
|
769
769
|
}
|
|
770
770
|
const virtualModuleId = VIRTUAL_PREFIX + toVitePath(absoluteFilePath);
|
|
771
771
|
const node = moduleGraph.getModuleById(virtualModuleId);
|
|
@@ -1708,19 +1708,24 @@ async function createWorkspace({
|
|
|
1708
1708
|
logger.debug(`\u5206\u6790 story: ${id}`);
|
|
1709
1709
|
({ props, types: componentTypes } = await story.associatedComponent.analyze());
|
|
1710
1710
|
logger.debug(`\u5B8C\u6210 story: ${id} \u5206\u6790`);
|
|
1711
|
+
logger.debug(`props: ${JSON.stringify(props)}`);
|
|
1712
|
+
logger.debug(`types: ${JSON.stringify(types)}`);
|
|
1711
1713
|
} else {
|
|
1712
1714
|
logger.debug(`story: ${id} \u6CA1\u6709\u5173\u8054\u7684\u7EC4\u4EF6`);
|
|
1713
1715
|
props = UNKNOWN_TYPE;
|
|
1714
1716
|
componentTypes = {};
|
|
1715
1717
|
}
|
|
1718
|
+
let args = null;
|
|
1719
|
+
({ args } = await story.analyze());
|
|
1716
1720
|
previewables.push({
|
|
1717
1721
|
kind: "story",
|
|
1718
1722
|
id,
|
|
1719
1723
|
sourcePosition: story.sourcePosition,
|
|
1720
1724
|
associatedComponentId: story.associatedComponent?.id || null,
|
|
1721
1725
|
props,
|
|
1722
|
-
args
|
|
1726
|
+
args
|
|
1723
1727
|
});
|
|
1728
|
+
logger.debug(`story args: ${JSON.stringify(args)}`);
|
|
1724
1729
|
} else {
|
|
1725
1730
|
const { filePath, name } = decodePreviewableId(id);
|
|
1726
1731
|
throw new Error(`\u5728 ${filePath} \u4E2D\u672A\u627E\u5230\u7EC4\u4EF6 ${name}. `);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cfp-studio/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@cfp-studio/middleware": "2.1.99",
|
|
13
|
-
"@fwouts/vite-tsconfig-paths": "^4.2.1",
|
|
14
12
|
"@cfp-studio/analyzer-api": "0.1.9",
|
|
15
13
|
"@cfp-studio/api": "16.1.0",
|
|
16
14
|
"@cfp-studio/config": "7.0.1",
|
|
17
|
-
"@cfp-studio/iframe": "^18.0.
|
|
15
|
+
"@cfp-studio/iframe": "^18.0.1",
|
|
16
|
+
"@cfp-studio/middleware": "2.1.100",
|
|
18
17
|
"@cfp-studio/serializable-values": "^9.0.6",
|
|
19
18
|
"@cfp-studio/type-analyzer": "^10.1.5",
|
|
20
19
|
"@cfp-studio/vfs": "2.1.4",
|
|
20
|
+
"@fwouts/vite-tsconfig-paths": "^4.2.1",
|
|
21
21
|
"assert-never": "1.4.0",
|
|
22
22
|
"axios": "1.8.1",
|
|
23
23
|
"cors": "2.8.5",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsc && unbuild",
|
|
51
|
+
"release": "tsc && unbuild --minify",
|
|
51
52
|
"test": "vitest"
|
|
52
53
|
}
|
|
53
54
|
}
|