@jay-framework/compiler-jay-html 0.9.0 → 0.11.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,45 +1,7 @@
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
- contract?: any;
32
- contractRef?: string;
33
- hasInlineData?: boolean;
34
- }
35
-
36
- declare function generateElementDefinitionFile(parsedFile: WithValidations<JayHtmlSourceFile>): WithValidations<string>;
37
- declare function generateElementFile(jayFile: JayHtmlSourceFile, importerMode: MainRuntimeModes): WithValidations<string>;
38
- declare function generateElementBridgeFile(jayFile: JayHtmlSourceFile): string;
39
- declare function generateSandboxRootFile(jayFile: JayHtmlSourceFile): string;
40
-
41
- declare function generateElementFileReactTarget(jayFile: JayHtmlSourceFile, importerMode: MainRuntimeModes): WithValidations<string>;
42
-
43
5
  declare enum ContractTagType {
44
6
  data = 0,
45
7
  interactive = 1,
@@ -56,6 +18,7 @@ interface ContractTag {
56
18
  description?: Array<string>;
57
19
  tags?: Array<ContractTag>;
58
20
  repeated?: boolean;
21
+ trackBy?: string;
59
22
  link?: string;
60
23
  async?: boolean;
61
24
  phase?: RenderingPhase;
@@ -69,6 +32,14 @@ declare function compileContract(contractWithValidations: WithValidations<Contra
69
32
 
70
33
  declare function parseContract(contractYaml: string, fileName: string): WithValidations<Contract>;
71
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
+
72
43
  interface JayContractImportLink {
73
44
  module: string;
74
45
  viewState: string;
@@ -100,14 +71,61 @@ interface PhaseViewStates {
100
71
  */
101
72
  declare function contractToAllPhaseViewStates(contract: Contract, contractFilePath: string, jayImportResolver: JayImportResolver): Promise<WithValidations<PhaseViewStates>>;
102
73
 
103
- interface JayImportResolver {
104
- resolveLink(importingModuleDir: string, link: string): string;
105
- loadContract(fullPath: string): WithValidations<Contract>;
106
- analyzeExportedTypes(fullPath: string, options: ResolveTsConfigOptions): JayType[];
74
+ interface JayHtmlNamespace {
75
+ prefix: string;
76
+ namespace: string;
107
77
  }
108
- 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
+ /**
101
+ * Absolute paths to linked CSS files referenced via <link rel="stylesheet">.
102
+ * Used by the dev server to watch these files for changes.
103
+ */
104
+ linkedCssFiles?: string[];
105
+ filename?: string;
106
+ contract?: Contract;
107
+ contractRef?: string;
108
+ hasInlineData?: boolean;
109
+ /**
110
+ * TrackBy map for server-side merge (slow → fast).
111
+ * Includes all tracked arrays.
112
+ */
113
+ serverTrackByMap?: Record<string, string>;
114
+ /**
115
+ * TrackBy map for client-side merge (fast → interactive).
116
+ * Excludes arrays with phase 'fast+interactive' (dynamic arrays that can be fully replaced).
117
+ */
118
+ clientTrackByMap?: Record<string, string>;
119
+ }
120
+
121
+ declare function generateElementDefinitionFile(parsedFile: WithValidations<JayHtmlSourceFile>): WithValidations<string>;
122
+ declare function generateElementFile(jayFile: JayHtmlSourceFile, importerMode: MainRuntimeModes): WithValidations<string>;
123
+ declare function generateElementBridgeFile(jayFile: JayHtmlSourceFile): string;
124
+ declare function generateSandboxRootFile(jayFile: JayHtmlSourceFile): string;
125
+
126
+ declare function generateElementFileReactTarget(jayFile: JayHtmlSourceFile, importerMode: MainRuntimeModes): WithValidations<string>;
109
127
 
110
- declare function parseJayFile(html: string, filename: string, filePath: string, options: ResolveTsConfigOptions, linkedContractResolver: JayImportResolver): Promise<WithValidations<JayHtmlSourceFile>>;
128
+ declare function parseJayFile(html: string, filename: string, filePath: string, options: ResolveTsConfigOptions, linkedContractResolver: JayImportResolver, projectRoot: string): Promise<WithValidations<JayHtmlSourceFile>>;
111
129
  declare function getJayHtmlImports(html: string): string[];
112
130
 
113
131
  declare function parseIsEnum(expression: string): boolean;
@@ -120,4 +138,42 @@ declare function renderRefsType(refs: RefsTree, refsType: string, generateTarget
120
138
 
121
139
  declare function generateTypes(types: JayType): string;
122
140
 
123
- 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 };
141
+ /**
142
+ * Input for slow render transformation
143
+ */
144
+ interface SlowRenderInput {
145
+ /** Original jay-html content */
146
+ jayHtmlContent: string;
147
+ /** Slow phase view state data */
148
+ slowViewState: Record<string, unknown>;
149
+ /** Contract metadata for phase detection */
150
+ contract?: Contract;
151
+ /**
152
+ * Source directory of the original jay-html file.
153
+ * Used to resolve relative paths (contracts, CSS, components) to absolute paths
154
+ * so the pre-rendered file can be placed in a different directory.
155
+ */
156
+ sourceDir?: string;
157
+ }
158
+ /**
159
+ * Output of slow render transformation
160
+ */
161
+ interface SlowRenderOutput {
162
+ /** Pre-rendered jay-html content */
163
+ preRenderedJayHtml: string;
164
+ }
165
+ /**
166
+ * Transform a jay-html file by resolving slow-phase bindings
167
+ *
168
+ * This is the main entry point for slow rendering.
169
+ *
170
+ * @param input - The input containing jay-html content, slow view state, and contract
171
+ * @returns The pre-rendered jay-html with slow bindings resolved
172
+ */
173
+ declare function slowRenderTransform(input: SlowRenderInput): WithValidations<SlowRenderOutput>;
174
+ /**
175
+ * Check if a jay-html file has any slow-phase properties that can be pre-rendered
176
+ */
177
+ declare function hasSlowPhaseProperties(contract: Contract | undefined): boolean;
178
+
179
+ export { type Contract, type ContractTag, ContractTagType, type EnumToImport, JAY_IMPORT_RESOLVER, type JayContractImportLink, type JayHtmlSourceFile, type JayImportResolver, type PhaseViewStates, type RenderingPhase, type SlowRenderInput, type SlowRenderOutput, compileContract, contractToAllPhaseViewStates, contractToImportsViewStateAndRefs, contractToPhaseViewState, generateElementBridgeFile, generateElementDefinitionFile, generateElementFile, generateElementFileReactTarget, generateSandboxRootFile, generateTypes, getJayHtmlImports, hasSlowPhaseProperties, parseContract, parseEnumValues, parseIsEnum, parseJayFile, renderRefsType, slowRenderTransform };