@cfp-studio/plugin-preact 11.1.2 → 11.1.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.d.mts +32 -58
- package/dist/index.mjs +1 -1
- package/package.json +10 -9
- package/preview/error-boundary.tsx +1 -1
- package/preview/index.tsx +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import * as url$1 from "node:url";
|
|
3
3
|
import { URL as URL$1 } from "node:url";
|
|
4
4
|
import { Analyzer } from "@cfp-studio/analyzer-api";
|
|
5
|
+
import { FrameworkPluginInfo, Logger } from "@cfp-studio/api";
|
|
5
6
|
import { Reader } from "@cfp-studio/vfs";
|
|
6
7
|
import * as http from "node:http";
|
|
7
8
|
import { Agent, ClientRequest, ClientRequestArgs, IncomingMessage, OutgoingHttpHeaders, Server } from "node:http";
|
|
@@ -15,28 +16,11 @@ import * as stream from "node:stream";
|
|
|
15
16
|
import { Duplex, DuplexOptions } from "node:stream";
|
|
16
17
|
import { SecureContextOptions } from "node:tls";
|
|
17
18
|
import { ZlibOptions } from "node:zlib";
|
|
18
|
-
import Lightningcss from "lightningcss";
|
|
19
|
-
import DartSass from "sass";
|
|
20
19
|
import SassEmbedded from "sass-embedded";
|
|
21
20
|
import Less from "less";
|
|
22
21
|
import Stylus from "stylus";
|
|
23
22
|
|
|
24
|
-
//#region
|
|
25
|
-
/**
|
|
26
|
-
* 定义一个框架插件信息的类型,包含插件名称和 API 版本。
|
|
27
|
-
*/
|
|
28
|
-
type FrameworkPluginInfo = {
|
|
29
|
-
name: string;
|
|
30
|
-
apiVersion: number;
|
|
31
|
-
}; //#endregion
|
|
32
|
-
//#region src/axios-api.d.ts
|
|
33
|
-
/**
|
|
34
|
-
* 创建一个基于 Axios 的 API 实例
|
|
35
|
-
* @param url - API 基础 URL
|
|
36
|
-
* @returns 实现了 Api 接口的 AxiosApi 实例
|
|
37
|
-
*/
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region ../../../../node_modules/.pnpm/@types+estree@1.0.9/node_modules/@types/estree/index.d.ts
|
|
23
|
+
//#region ../../../../node_modules/.pnpm/@types+estree@1.0.8/node_modules/@types/estree/index.d.ts
|
|
40
24
|
// This definition file follows a somewhat unusual format. ESTree allows
|
|
41
25
|
// runtime type checks based on the `type` parameter. In order to explain this
|
|
42
26
|
// to typescript we want to use discriminated union types:
|
|
@@ -286,7 +270,7 @@ interface PrivateIdentifier extends BaseNode {
|
|
|
286
270
|
}
|
|
287
271
|
interface Property extends BaseNode {
|
|
288
272
|
type: "Property";
|
|
289
|
-
key: Expression;
|
|
273
|
+
key: Expression | PrivateIdentifier;
|
|
290
274
|
value: Expression | Pattern; // Could be an AssignmentProperty
|
|
291
275
|
kind: "init" | "get" | "set";
|
|
292
276
|
method: boolean;
|
|
@@ -560,7 +544,7 @@ interface AwaitExpression extends BaseExpression {
|
|
|
560
544
|
argument: Expression;
|
|
561
545
|
}
|
|
562
546
|
//#endregion
|
|
563
|
-
//#region ../../../../node_modules/.pnpm/rollup@4.
|
|
547
|
+
//#region ../../../../node_modules/.pnpm/rollup@4.52.0/node_modules/rollup/dist/rollup.d.ts
|
|
564
548
|
declare module 'estree' {
|
|
565
549
|
export interface Decorator extends BaseNode {
|
|
566
550
|
type: 'Decorator';
|
|
@@ -640,11 +624,11 @@ type DecodedSourceMapOrMissing = {
|
|
|
640
624
|
missing?: false | undefined;
|
|
641
625
|
});
|
|
642
626
|
interface SourceMap$1 {
|
|
643
|
-
file
|
|
627
|
+
file: string;
|
|
644
628
|
mappings: string;
|
|
645
629
|
names: string[];
|
|
646
630
|
sources: string[];
|
|
647
|
-
sourcesContent?:
|
|
631
|
+
sourcesContent?: string[] | undefined;
|
|
648
632
|
version: number;
|
|
649
633
|
debugId?: string | undefined;
|
|
650
634
|
toString(): string;
|
|
@@ -666,8 +650,7 @@ interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
|
|
|
666
650
|
}
|
|
667
651
|
interface TransformModuleJSON {
|
|
668
652
|
ast?: ProgramNode | undefined;
|
|
669
|
-
code: string;
|
|
670
|
-
safeVariableNames: Record<string, string> | null; // note if plugins use new this.cache to opt-out auto transform cache
|
|
653
|
+
code: string; // note if plugins use new this.cache to opt-out auto transform cache
|
|
671
654
|
customTransformCache: boolean;
|
|
672
655
|
originalCode: string;
|
|
673
656
|
originalSourcemap: ExistingDecodedSourceMap | null;
|
|
@@ -675,7 +658,6 @@ interface TransformModuleJSON {
|
|
|
675
658
|
transformDependencies: string[];
|
|
676
659
|
}
|
|
677
660
|
interface ModuleJSON extends TransformModuleJSON, ModuleOptions {
|
|
678
|
-
safeVariableNames: Record<string, string> | null;
|
|
679
661
|
ast: ProgramNode;
|
|
680
662
|
dependencies: string[];
|
|
681
663
|
id: string;
|
|
@@ -731,7 +713,6 @@ interface ModuleInfo extends ModuleOptions {
|
|
|
731
713
|
dynamicallyImportedIds: readonly string[];
|
|
732
714
|
exportedBindings: Record<string, string[]> | null;
|
|
733
715
|
exports: string[] | null;
|
|
734
|
-
safeVariableNames: Record<string, string> | null;
|
|
735
716
|
hasDefaultExport: boolean | null;
|
|
736
717
|
id: string;
|
|
737
718
|
implicitlyLoadedAfterOneOf: readonly string[];
|
|
@@ -779,7 +760,6 @@ interface PluginContext extends MinimalPluginContext$1 {
|
|
|
779
760
|
} & Partial<PartialNull<ModuleOptions>>) => Promise<ModuleInfo>;
|
|
780
761
|
parse: ParseAst;
|
|
781
762
|
resolve: (source: string, importer?: string, options?: {
|
|
782
|
-
importerAttributes?: Record<string, string>;
|
|
783
763
|
attributes?: Record<string, string>;
|
|
784
764
|
custom?: CustomPluginOptions;
|
|
785
765
|
isEntry?: boolean;
|
|
@@ -816,12 +796,10 @@ type ResolveIdResult = string | NullValue | false | PartialResolvedId;
|
|
|
816
796
|
type ResolveIdHook = (this: PluginContext, source: string, importer: string | undefined, options: {
|
|
817
797
|
attributes: Record<string, string>;
|
|
818
798
|
custom?: CustomPluginOptions;
|
|
819
|
-
importerAttributes?: Record<string, string> | undefined;
|
|
820
799
|
isEntry: boolean;
|
|
821
800
|
}) => ResolveIdResult;
|
|
822
801
|
type ShouldTransformCachedModuleHook = (this: PluginContext, options: {
|
|
823
802
|
ast: ProgramNode;
|
|
824
|
-
attributes: Record<string, string>;
|
|
825
803
|
code: string;
|
|
826
804
|
id: string;
|
|
827
805
|
meta: CustomPluginOptions;
|
|
@@ -832,12 +810,7 @@ type ShouldTransformCachedModuleHook = (this: PluginContext, options: {
|
|
|
832
810
|
type IsExternal = (source: string, importer: string | undefined, isResolved: boolean) => boolean;
|
|
833
811
|
type HasModuleSideEffects = (id: string, external: boolean) => boolean;
|
|
834
812
|
type LoadResult = SourceDescription | string | NullValue;
|
|
835
|
-
type LoadHook = (this: PluginContext, id: string
|
|
836
|
-
options?: {
|
|
837
|
-
// unused, temporarily added for better Vite type-compatibility
|
|
838
|
-
ssr?: boolean | undefined; // temporarily marked as optional for better Vite type-compatibility
|
|
839
|
-
attributes?: Record<string, string>;
|
|
840
|
-
} | undefined) => LoadResult;
|
|
813
|
+
type LoadHook = (this: PluginContext, id: string) => LoadResult;
|
|
841
814
|
interface TransformPluginContext extends PluginContext {
|
|
842
815
|
debug: LoggingFunctionWithPosition;
|
|
843
816
|
error: (error: RollupError | string, pos?: number | {
|
|
@@ -849,12 +822,7 @@ interface TransformPluginContext extends PluginContext {
|
|
|
849
822
|
warn: LoggingFunctionWithPosition;
|
|
850
823
|
}
|
|
851
824
|
type TransformResult$2 = string | NullValue | Partial<SourceDescription>;
|
|
852
|
-
type TransformHook = (this: TransformPluginContext, code: string, id: string
|
|
853
|
-
options?: {
|
|
854
|
-
// unused, temporarily added for better Vite type-compatibility
|
|
855
|
-
ssr?: boolean | undefined; // temporarily marked as optional for better Vite type-compatibility
|
|
856
|
-
attributes?: Record<string, string>;
|
|
857
|
-
} | undefined) => TransformResult$2;
|
|
825
|
+
type TransformHook = (this: TransformPluginContext, code: string, id: string) => TransformResult$2;
|
|
858
826
|
type ModuleParsedHook = (this: PluginContext, info: ModuleInfo) => void;
|
|
859
827
|
type RenderChunkHook = (this: PluginContext, code: string, chunk: RenderedChunk, options: NormalizedOutputOptions, meta: {
|
|
860
828
|
chunks: Record<string, RenderedChunk>;
|
|
@@ -864,16 +832,13 @@ type RenderChunkHook = (this: PluginContext, code: string, chunk: RenderedChunk,
|
|
|
864
832
|
} | string | NullValue;
|
|
865
833
|
type ResolveDynamicImportHook = (this: PluginContext, specifier: string | AstNode, importer: string, options: {
|
|
866
834
|
attributes: Record<string, string>;
|
|
867
|
-
importerAttributes: Record<string, string>;
|
|
868
835
|
}) => ResolveIdResult;
|
|
869
836
|
type ResolveImportMetaHook = (this: PluginContext, property: string | null, options: {
|
|
870
|
-
attributes: Record<string, string>;
|
|
871
837
|
chunkId: string;
|
|
872
838
|
format: InternalModuleFormat;
|
|
873
839
|
moduleId: string;
|
|
874
840
|
}) => string | NullValue;
|
|
875
841
|
type ResolveFileUrlHook = (this: PluginContext, options: {
|
|
876
|
-
attributes: Record<string, string>;
|
|
877
842
|
chunkId: string;
|
|
878
843
|
fileName: string;
|
|
879
844
|
format: InternalModuleFormat;
|
|
@@ -924,7 +889,6 @@ interface FunctionPluginHooks {
|
|
|
924
889
|
chunk: PreRenderedChunkWithFileName;
|
|
925
890
|
targetChunk: PreRenderedChunkWithFileName | null;
|
|
926
891
|
getTargetChunkImports: () => DynamicImportTargetChunk[] | null;
|
|
927
|
-
targetModuleAttributes: Record<string, string>;
|
|
928
892
|
}) => {
|
|
929
893
|
left: string;
|
|
930
894
|
right: string;
|
|
@@ -1340,14 +1304,16 @@ interface AwaitingEventEmitter<T extends Record<string, (...parameters: any) =>
|
|
|
1340
1304
|
off<K extends keyof T>(event: K, listener: AwaitedEventListener<T, K>): this;
|
|
1341
1305
|
/**
|
|
1342
1306
|
* Registers an event listener that will be awaited before Rollup continues.
|
|
1343
|
-
* All listeners
|
|
1344
|
-
*
|
|
1307
|
+
* All listeners will be awaited in parallel while rejections are tracked via
|
|
1308
|
+
* Promise.all.
|
|
1345
1309
|
*/
|
|
1346
1310
|
on<K extends keyof T>(event: K, listener: AwaitedEventListener<T, K>): this;
|
|
1347
1311
|
/**
|
|
1348
|
-
* Registers an event listener
|
|
1349
|
-
*
|
|
1350
|
-
*
|
|
1312
|
+
* Registers an event listener that will be awaited before Rollup continues.
|
|
1313
|
+
* All listeners will be awaited in parallel while rejections are tracked via
|
|
1314
|
+
* Promise.all.
|
|
1315
|
+
* Listeners are removed automatically when removeListenersForCurrentRun is
|
|
1316
|
+
* called, which happens automatically after each run.
|
|
1351
1317
|
*/
|
|
1352
1318
|
onCurrentRun<K extends keyof T>(event: K, listener: (...parameters: Parameters<T[K]>) => Promise<ReturnType<T[K]>>): this;
|
|
1353
1319
|
removeAllListeners(): this;
|
|
@@ -1448,7 +1414,7 @@ interface RollupFileStats {
|
|
|
1448
1414
|
birthtime: Date;
|
|
1449
1415
|
}
|
|
1450
1416
|
//#endregion
|
|
1451
|
-
//#region ../../../../node_modules/.pnpm/vite@6.4.5_@types+node@24.
|
|
1417
|
+
//#region ../../../../node_modules/.pnpm/vite@6.4.5_@types+node@24.19.2_jiti@2.7.0_less@4.9.1_lightningcss@1.30.2_sass@1.107.1_t_8ea963fdf6f230da68c5cacf71b7d6dc/node_modules/vite/types/hmrPayload.d.ts
|
|
1452
1418
|
type HotPayload = ConnectedPayload | PingPayload | UpdatePayload | FullReloadPayload | CustomPayload | ErrorPayload | PrunePayload;
|
|
1453
1419
|
interface ConnectedPayload {
|
|
1454
1420
|
type: 'connected';
|
|
@@ -1507,7 +1473,7 @@ interface ErrorPayload {
|
|
|
1507
1473
|
};
|
|
1508
1474
|
}
|
|
1509
1475
|
//#endregion
|
|
1510
|
-
//#region ../../../../node_modules/.pnpm/vite@6.4.5_@types+node@24.
|
|
1476
|
+
//#region ../../../../node_modules/.pnpm/vite@6.4.5_@types+node@24.19.2_jiti@2.7.0_less@4.9.1_lightningcss@1.30.2_sass@1.107.1_t_8ea963fdf6f230da68c5cacf71b7d6dc/node_modules/vite/types/customEvent.d.ts
|
|
1511
1477
|
interface CustomEventMap {
|
|
1512
1478
|
'vite:beforeUpdate': UpdatePayload;
|
|
1513
1479
|
'vite:afterUpdate': UpdatePayload;
|
|
@@ -1538,7 +1504,7 @@ interface InvalidatePayload {
|
|
|
1538
1504
|
*/
|
|
1539
1505
|
type InferCustomEventPayload<T extends string> = T extends keyof CustomEventMap ? CustomEventMap[T] : any;
|
|
1540
1506
|
//#endregion
|
|
1541
|
-
//#region ../../../../node_modules/.pnpm/vite@6.4.5_@types+node@24.
|
|
1507
|
+
//#region ../../../../node_modules/.pnpm/vite@6.4.5_@types+node@24.19.2_jiti@2.7.0_less@4.9.1_lightningcss@1.30.2_sass@1.107.1_t_8ea963fdf6f230da68c5cacf71b7d6dc/node_modules/vite/dist/node/moduleRunnerTransport.d-DJ_mE5sf.d.ts
|
|
1542
1508
|
interface FetchFunctionOptions {
|
|
1543
1509
|
cached?: boolean;
|
|
1544
1510
|
startOffset?: number;
|
|
@@ -2201,12 +2167,12 @@ declare global {
|
|
|
2201
2167
|
interface URL {}
|
|
2202
2168
|
}
|
|
2203
2169
|
//#endregion
|
|
2204
|
-
//#region ../../../../node_modules/.pnpm/vite@6.4.5_@types+node@24.
|
|
2170
|
+
//#region ../../../../node_modules/.pnpm/vite@6.4.5_@types+node@24.19.2_jiti@2.7.0_less@4.9.1_lightningcss@1.30.2_sass@1.107.1_t_8ea963fdf6f230da68c5cacf71b7d6dc/node_modules/vite/types/internal/lightningcssOptions.d.ts
|
|
2205
2171
|
/* eslint-enable @typescript-eslint/ban-ts-comment */
|
|
2206
2172
|
type LightningCSSOptions = Omit<Lightningcss.BundleAsyncOptions<Lightningcss.CustomAtRules>, 'filename' | 'resolver' | 'minify' | 'sourceMap' | 'analyzeDependencies' // properties not overridden by Vite, but does not make sense to set by end users
|
|
2207
2173
|
| 'inputSourceMap' | 'projectRoot'>;
|
|
2208
2174
|
//#endregion
|
|
2209
|
-
//#region ../../../../node_modules/.pnpm/vite@6.4.5_@types+node@24.
|
|
2175
|
+
//#region ../../../../node_modules/.pnpm/vite@6.4.5_@types+node@24.19.2_jiti@2.7.0_less@4.9.1_lightningcss@1.30.2_sass@1.107.1_t_8ea963fdf6f230da68c5cacf71b7d6dc/node_modules/vite/types/internal/cssPreprocessorOptions.d.ts
|
|
2210
2176
|
/* eslint-enable @typescript-eslint/ban-ts-comment */
|
|
2211
2177
|
// https://github.com/type-challenges/type-challenges/issues/29285
|
|
2212
2178
|
type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;
|
|
@@ -2229,7 +2195,7 @@ declare global {
|
|
|
2229
2195
|
interface HTMLLinkElement {}
|
|
2230
2196
|
}
|
|
2231
2197
|
//#endregion
|
|
2232
|
-
//#region ../../../../node_modules/.pnpm/vite@6.4.5_@types+node@24.
|
|
2198
|
+
//#region ../../../../node_modules/.pnpm/vite@6.4.5_@types+node@24.19.2_jiti@2.7.0_less@4.9.1_lightningcss@1.30.2_sass@1.107.1_t_8ea963fdf6f230da68c5cacf71b7d6dc/node_modules/vite/types/metadata.d.ts
|
|
2233
2199
|
interface ChunkMetadata {
|
|
2234
2200
|
importedAssets: Set<string>;
|
|
2235
2201
|
importedCss: Set<string>;
|
|
@@ -2262,7 +2228,7 @@ declare module 'rollup' {
|
|
|
2262
2228
|
}
|
|
2263
2229
|
}
|
|
2264
2230
|
//#endregion
|
|
2265
|
-
//#region ../../../../node_modules/.pnpm/vite@6.4.5_@types+node@24.
|
|
2231
|
+
//#region ../../../../node_modules/.pnpm/vite@6.4.5_@types+node@24.19.2_jiti@2.7.0_less@4.9.1_lightningcss@1.30.2_sass@1.107.1_t_8ea963fdf6f230da68c5cacf71b7d6dc/node_modules/vite/dist/node/index.d.ts
|
|
2266
2232
|
interface Alias {
|
|
2267
2233
|
find: string | RegExp;
|
|
2268
2234
|
replacement: string;
|
|
@@ -5693,6 +5659,7 @@ interface PluginHookUtils {
|
|
|
5693
5659
|
type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
|
|
5694
5660
|
//#endregion
|
|
5695
5661
|
//#region ../../engine/core/dist/index.d.mts
|
|
5662
|
+
//#endregion
|
|
5696
5663
|
//#region src/plugins/dependencies.d.ts
|
|
5697
5664
|
/**
|
|
5698
5665
|
* 定义包依赖项的类型,它是一个记录类型,键为包名,值为包含主要版本号和读取已安装版本方法的对象
|
|
@@ -5707,7 +5674,14 @@ type PackageDependencies = Record<string, {
|
|
|
5707
5674
|
* @returns {Promise<string | null>} - 一个 Promise,解析为已安装包的版本号字符串,如果读取失败则为 null
|
|
5708
5675
|
*/
|
|
5709
5676
|
readInstalledVersion(): Promise<string | null>;
|
|
5710
|
-
}>;
|
|
5677
|
+
}>;
|
|
5678
|
+
/**
|
|
5679
|
+
* 从指定根目录下的 package.json 文件中提取所有依赖项的信息
|
|
5680
|
+
* @param {Logger} logger - 用于记录错误信息的日志记录器
|
|
5681
|
+
* @param {string} rootDir - 项目的根目录路径
|
|
5682
|
+
* @returns {Promise<PackageDependencies>} - 一个 Promise,解析为包含所有依赖项信息的对象
|
|
5683
|
+
*/
|
|
5684
|
+
//#endregion
|
|
5711
5685
|
//#region src/plugins/framework.d.ts
|
|
5712
5686
|
/**
|
|
5713
5687
|
* 定义框架插件工厂的接口。
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"node:path";import t from"node:url";import{
|
|
1
|
+
import e from"node:path";import t from"node:url";import{collectFrameworkProps as n,decodePreviewableId as r,defineSpecialTypes as i,generatePreviewableId as a,readOwnVersion as o,wrapperPathFor as s}from"@cfp-studio/analyzer-api";import{createAnalyzer as c}from"@cfp-studio/analyzer-api/analyzer";import{polyfillNode as l}from"esbuild-plugin-polyfill-node";import u from"typescript";import{parseSerializableValue as d}from"@cfp-studio/serializable-values";import{extractArgs as f,extractCsf3Stories as p,extractStoriesInfo as m,resolvePreviewableId as h}from"@cfp-studio/storybook-helpers";import{EMPTY_OBJECT_TYPE as g,NODE_TYPE as _,UNKNOWN_TYPE as v,arrayType as y,dereferenceType as b,functionType as x,helpers as S,maybeOptionalType as C,objectType as w}from"@cfp-studio/type-analyzer";function T(e,t,n){let r=n.getParameters()[0];if(!r)return{props:g,types:{}};if(!r.valueDeclaration)return{props:v,types:{}};let i=t.checker.getTypeOfSymbolAtLocation(r,r.valueDeclaration);try{let{type:e,collected:n}=t.resolveType(i);[e]=b(e,n,[]);stripUnusedProps:if(e.kind===`object`&&u.isParameter(r.valueDeclaration)&&u.isObjectBindingPattern(r.valueDeclaration.name)){let t=r.valueDeclaration.name,n=new Set,i=new Set;for(let e of t.elements){if(e.dotDotDotToken)break stripUnusedProps;let t=e.propertyName||e.name;if(!u.isIdentifier(t))break stripUnusedProps;n.add(t.text),e.initializer&&i.add(t.text)}e=w(Object.fromEntries(Object.entries(e.fields).filter(([e])=>n.has(e)).map(([e,t])=>[e,C(t,i.has(e))])))}return e.kind===`object`&&(e={kind:`object`,fields:Object.fromEntries(Object.entries(e.fields).filter(([e])=>![`jsx`,`key`,`ref`].includes(e)))}),{props:e,types:n,frameworkProps:E(t,i)}}catch{e.warn(`Unable to resolve props type for ${t.checker.typeToString(i)}`)}return{props:v,types:{}}}function E(e,t){return n(e.checker,t,`preact`).map(e=>e.owner===void 0?e.name:`${e.name}:${e.owner}`)}async function D(t,n,i,o){let s=n.sourceFile(o);if(!s)return[];let c=[];for(let e of s.statements)if(u.isExportAssignment(e)){if(u.isIdentifier(e.expression))continue;c.push([`default`,e,e.expression])}else if(u.isVariableStatement(e))for(let t of e.declarationList.declarations)!u.isIdentifier(t.name)||!t.initializer||c.push([t.name.text,e,t.initializer]);else if(u.isFunctionDeclaration(e)){let t=!!e.modifiers?.find(e=>e.kind===u.SyntaxKind.ExportKeyword)&&!!e.modifiers?.find(e=>e.kind===u.SyntaxKind.DefaultKeyword),n=e.name?.text;(t||n)&&c.push([n||`default`,e,e])}else u.isClassDeclaration(e)&&e.name&&c.push([e.name.text,e,e]);let l=m(s),h=[],g=f(s),_=S.extractExportedNames(s);async function y(e,r,a){if(a===`default`&&l)return null;let o=g[a],s=a===`default`||!!_[a],c=k(n.checker,r);if(l&&s&&(o||c?.parameters.length===0)){let r=O(t,n,i,l.component);return{...e,analyze:async()=>({args:o?{sourcePosition:{start:o.getStart(),end:o.getEnd()},value:await d(o)}:null}),associatedComponent:r}}return c?{...e,exported:s,analyze:async()=>T(t,n,c)}:null}for(let[t,n,r]of c){let s=await y({id:a({filePath:e.relative(i,o),name:t}),sourcePosition:{start:n.getStart(),end:n.getEnd()}},r,t);s&&h.push(s)}return[...h,...await p(i,n,s,async a=>{let{filePath:o}=r(a),s=(await D(t,n,i,e.join(i,o))).find(e=>e.id===a);return!s||!(`exported`in s)?{props:v,types:{}}:s.analyze()})]}function O(e,t,n,r){let i=h(n,t.checker,r);return r&&i?{id:i,analyze:async()=>{let n=k(t.checker,r);return n?T(e,t,n):{props:v,types:{}}}}:null}function k(e,t){let n=e.getTypeAtLocation(t);for(let e of n.getCallSignatures())if(A(e.getReturnType()))return e;if(n.symbol){let r=e.getTypeOfSymbolAtLocation(n.symbol,t);for(let e of r.getConstructSignatures())if(e.getReturnType().getProperty(`render`))return e}return null}function A(e){return!!M(e)}const j=new Set([`Element`,`VNode`]);function M(e){if(e.isUnion()){for(let t of e.types)if(M(t))return!0}return j.has(e.symbol?.getEscapedName().toString())}const N=i({Component:_,ComponentClass:x(_),ComponentChildren:_,FunctionComponent:x(_),FunctionalComponent:x(_),PreactElement:_,PreactNode:_,PreactNodeArray:y(_),PreactPortal:_}),P={info:{apiVersion:5,version:o(import.meta.url),name:`@cfp-studio/plugin-preact`},isCompatible:async e=>{let t=await e.preact?.readInstalledVersion();return t?Number.parseInt(t)>=10:!1},async create({rootDir:n,reader:r,logger:i}){let a=t.fileURLToPath(new URL(`.`,import.meta.url)),o=e.resolve(a,`..`,`preview`);return{...c({typeAnalyzerOptions:({reader:e})=>({reader:e,specialTypes:N,tsCompilerOptions:{jsx:u.JsxEmit.ReactJSX,jsxImportSource:`preact`,jsxFactory:`h`,jsxFragmentFactory:`Fragment`}}),crawlFile:({logger:e,resolver:t,rootDir:n,absoluteFilePath:r})=>D(e,t,n,r)})({rootDir:n,reader:r,logger:i}),defaultWrapperPath:s(`tsx`),previewDirPath:o,viteConfig:e=>({optimizeDeps:{esbuildOptions:{plugins:[l()]}},resolve:{alias:{react:`preact/compat`,"react-dom/test-utils":`preact/test-utils`,"react-dom":`preact/compat`,"react/jsx-runtime":`preact/jsx-runtime`}},esbuild:{jsx:`automatic`,jsxImportSource:`preact`,jsxFactory:`h`,jsxFragment:`fragment`},plugins:[...e.filter(e=>e.name!==`prefresh`&&e.name!==`vite:preact-jsx`),{name:`previewjs:optimize-deps`,config:()=>({optimizeDeps:{include:[`preact`,`preact/jsx-runtime`]}})}]})}}};export{P as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cfp-studio/plugin-preact",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -13,22 +13,23 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"esbuild-plugin-polyfill-node": "0.3.0",
|
|
15
15
|
"typescript": "5.9.3",
|
|
16
|
-
"@cfp-studio/analyzer-api": "0.1.
|
|
16
|
+
"@cfp-studio/analyzer-api": "0.1.20",
|
|
17
|
+
"@cfp-studio/type-analyzer": "10.1.10",
|
|
18
|
+
"@cfp-studio/api": "16.1.3",
|
|
17
19
|
"@cfp-studio/storybook-helpers": "6.0.2",
|
|
18
|
-
"@cfp-studio/
|
|
19
|
-
"@cfp-studio/
|
|
20
|
-
"@cfp-studio/type-analyzer": "10.1.8"
|
|
20
|
+
"@cfp-studio/serializable-values": "9.0.10",
|
|
21
|
+
"@cfp-studio/vfs": "2.1.8"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@playwright/test": "1.64.1",
|
|
24
25
|
"pino": "9.11.0",
|
|
25
|
-
"pino-pretty": "
|
|
26
|
+
"pino-pretty": "13.1.1",
|
|
26
27
|
"preact": "10.26.4",
|
|
27
28
|
"rimraf": "6.0.1",
|
|
28
29
|
"vitest": "5.0.5",
|
|
29
|
-
"@cfp-studio/iframe": "18.4.
|
|
30
|
-
"@cfp-studio/
|
|
31
|
-
"@cfp-studio/
|
|
30
|
+
"@cfp-studio/iframe": "18.4.14",
|
|
31
|
+
"@cfp-studio/core": "1.0.21",
|
|
32
|
+
"@cfp-studio/testing": "14.0.1"
|
|
32
33
|
},
|
|
33
34
|
"cfp": {
|
|
34
35
|
"domain": "web-preview",
|
package/preview/index.tsx
CHANGED