@jay-framework/compiler-jay-html 0.8.0 → 0.10.0

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.cts CHANGED
@@ -1,48 +1,14 @@
1
- import { CompilerSourceFile, SourceFileFormat, JayType, RefsTree, JayImportLink, WithValidations, MainRuntimeModes, JayEnumType, GenerateTarget, Imports } from '@jay-framework/compiler-shared';
1
+ import { JayType, WithValidations, PluginComponentResolution, JayEnumType, RefsTree, CompilerSourceFile, SourceFileFormat, JayImportLink, MainRuntimeModes, GenerateTarget, Imports } from '@jay-framework/compiler-shared';
2
2
  import { HTMLElement } from 'node-html-parser';
3
3
  import { ResolveTsConfigOptions } from '@jay-framework/compiler-analyze-exported-types';
4
4
 
5
- interface JayHtmlNamespace {
6
- prefix: string;
7
- namespace: string;
8
- }
9
- interface JayHeadlessImports {
10
- key: string;
11
- refs: RefsTree;
12
- rootType: JayType;
13
- contractLinks: JayImportLink[];
14
- codeLink: JayImportLink;
15
- }
16
- interface JayHtmlHeadLink {
17
- rel: string;
18
- href: string;
19
- attributes: Record<string, string>;
20
- }
21
- interface JayHtmlSourceFile extends CompilerSourceFile {
22
- format: SourceFileFormat.JayHtml;
23
- baseElementName: string;
24
- types: JayType;
25
- body: HTMLElement;
26
- namespaces: JayHtmlNamespace[];
27
- headlessImports: JayHeadlessImports[];
28
- headLinks: JayHtmlHeadLink[];
29
- css?: string;
30
- filename?: string;
31
- }
32
-
33
- declare function generateElementDefinitionFile(parsedFile: WithValidations<JayHtmlSourceFile>): WithValidations<string>;
34
- declare function generateElementFile(jayFile: JayHtmlSourceFile, importerMode: MainRuntimeModes): WithValidations<string>;
35
- declare function generateElementBridgeFile(jayFile: JayHtmlSourceFile): string;
36
- declare function generateSandboxRootFile(jayFile: JayHtmlSourceFile): string;
37
-
38
- declare function generateElementFileReactTarget(jayFile: JayHtmlSourceFile, importerMode: MainRuntimeModes): WithValidations<string>;
39
-
40
5
  declare enum ContractTagType {
41
6
  data = 0,
42
7
  interactive = 1,
43
8
  variant = 2,
44
9
  subContract = 3
45
10
  }
11
+ type RenderingPhase = 'slow' | 'fast' | 'fast+interactive';
46
12
  interface ContractTag {
47
13
  tag: string;
48
14
  required?: boolean;
@@ -52,8 +18,10 @@ interface ContractTag {
52
18
  description?: Array<string>;
53
19
  tags?: Array<ContractTag>;
54
20
  repeated?: boolean;
21
+ trackBy?: string;
55
22
  link?: string;
56
23
  async?: boolean;
24
+ phase?: RenderingPhase;
57
25
  }
58
26
  interface Contract {
59
27
  name: string;
@@ -64,6 +32,14 @@ declare function compileContract(contractWithValidations: WithValidations<Contra
64
32
 
65
33
  declare function parseContract(contractYaml: string, fileName: string): WithValidations<Contract>;
66
34
 
35
+ interface JayImportResolver {
36
+ resolveLink(importingModuleDir: string, link: string): string;
37
+ loadContract(fullPath: string): WithValidations<Contract>;
38
+ analyzeExportedTypes(fullPath: string, options: ResolveTsConfigOptions): JayType[];
39
+ resolvePluginComponent(pluginName: string, contractName: string, projectRoot: string): WithValidations<PluginComponentResolution>;
40
+ }
41
+ declare const JAY_IMPORT_RESOLVER: JayImportResolver;
42
+
67
43
  interface JayContractImportLink {
68
44
  module: string;
69
45
  viewState: string;
@@ -81,15 +57,70 @@ interface SubContractTraverseResult {
81
57
  enumsToImport: EnumToImport[];
82
58
  }
83
59
  declare function contractToImportsViewStateAndRefs(contract: Contract, contractFilePath: string, jayImportResolver: JayImportResolver, isRepeated?: boolean, isAsync?: boolean): Promise<WithValidations<SubContractTraverseResult>>;
60
+ /**
61
+ * Generate phase-specific ViewState type
62
+ */
63
+ declare function contractToPhaseViewState(contract: Contract, contractFilePath: string, jayImportResolver: JayImportResolver, phase: RenderingPhase, isRepeated?: boolean, isAsync?: boolean): Promise<WithValidations<SubContractTraverseResult>>;
64
+ interface PhaseViewStates {
65
+ slow: SubContractTraverseResult;
66
+ fast: SubContractTraverseResult;
67
+ interactive: SubContractTraverseResult;
68
+ }
69
+ /**
70
+ * Generate all three phase-specific ViewState types
71
+ */
72
+ declare function contractToAllPhaseViewStates(contract: Contract, contractFilePath: string, jayImportResolver: JayImportResolver): Promise<WithValidations<PhaseViewStates>>;
84
73
 
85
- interface JayImportResolver {
86
- resolveLink(importingModuleDir: string, link: string): string;
87
- loadContract(fullPath: string): WithValidations<Contract>;
88
- analyzeExportedTypes(fullPath: string, options: ResolveTsConfigOptions): JayType[];
74
+ interface JayHtmlNamespace {
75
+ prefix: string;
76
+ namespace: string;
89
77
  }
90
- declare const JAY_IMPORT_RESOLVER: JayImportResolver;
78
+ interface JayHeadlessImports {
79
+ key: string;
80
+ refs: RefsTree;
81
+ rootType: JayType;
82
+ contractLinks: JayImportLink[];
83
+ codeLink: JayImportLink;
84
+ contract?: Contract;
85
+ }
86
+ interface JayHtmlHeadLink {
87
+ rel: string;
88
+ href: string;
89
+ attributes: Record<string, string>;
90
+ }
91
+ interface JayHtmlSourceFile extends CompilerSourceFile {
92
+ format: SourceFileFormat.JayHtml;
93
+ baseElementName: string;
94
+ types: JayType;
95
+ body: HTMLElement;
96
+ namespaces: JayHtmlNamespace[];
97
+ headlessImports: JayHeadlessImports[];
98
+ headLinks: JayHtmlHeadLink[];
99
+ css?: string;
100
+ filename?: string;
101
+ contract?: Contract;
102
+ contractRef?: string;
103
+ hasInlineData?: boolean;
104
+ /**
105
+ * TrackBy map for server-side merge (slow → fast).
106
+ * Includes all tracked arrays.
107
+ */
108
+ serverTrackByMap?: Record<string, string>;
109
+ /**
110
+ * TrackBy map for client-side merge (fast → interactive).
111
+ * Excludes arrays with phase 'fast+interactive' (dynamic arrays that can be fully replaced).
112
+ */
113
+ clientTrackByMap?: Record<string, string>;
114
+ }
115
+
116
+ declare function generateElementDefinitionFile(parsedFile: WithValidations<JayHtmlSourceFile>): WithValidations<string>;
117
+ declare function generateElementFile(jayFile: JayHtmlSourceFile, importerMode: MainRuntimeModes): WithValidations<string>;
118
+ declare function generateElementBridgeFile(jayFile: JayHtmlSourceFile): string;
119
+ declare function generateSandboxRootFile(jayFile: JayHtmlSourceFile): string;
120
+
121
+ declare function generateElementFileReactTarget(jayFile: JayHtmlSourceFile, importerMode: MainRuntimeModes): WithValidations<string>;
91
122
 
92
- declare function parseJayFile(html: string, filename: string, filePath: string, options: ResolveTsConfigOptions, linkedContractResolver: JayImportResolver): Promise<WithValidations<JayHtmlSourceFile>>;
123
+ declare function parseJayFile(html: string, filename: string, filePath: string, options: ResolveTsConfigOptions, linkedContractResolver: JayImportResolver, projectRoot: string): Promise<WithValidations<JayHtmlSourceFile>>;
93
124
  declare function getJayHtmlImports(html: string): string[];
94
125
 
95
126
  declare function parseIsEnum(expression: string): boolean;
@@ -102,4 +133,4 @@ declare function renderRefsType(refs: RefsTree, refsType: string, generateTarget
102
133
 
103
134
  declare function generateTypes(types: JayType): string;
104
135
 
105
- export { type Contract, type ContractTag, ContractTagType, type EnumToImport, JAY_IMPORT_RESOLVER, type JayContractImportLink, type JayHtmlSourceFile, type JayImportResolver, compileContract, contractToImportsViewStateAndRefs, generateElementBridgeFile, generateElementDefinitionFile, generateElementFile, generateElementFileReactTarget, generateSandboxRootFile, generateTypes, getJayHtmlImports, parseContract, parseEnumValues, parseIsEnum, parseJayFile, renderRefsType };
136
+ export { type Contract, type ContractTag, ContractTagType, type EnumToImport, JAY_IMPORT_RESOLVER, type JayContractImportLink, type JayHtmlSourceFile, type JayImportResolver, type PhaseViewStates, type RenderingPhase, compileContract, contractToAllPhaseViewStates, contractToImportsViewStateAndRefs, contractToPhaseViewState, generateElementBridgeFile, generateElementDefinitionFile, generateElementFile, generateElementFileReactTarget, generateSandboxRootFile, generateTypes, getJayHtmlImports, parseContract, parseEnumValues, parseIsEnum, parseJayFile, renderRefsType };