@jay-framework/compiler-shared 0.18.1 → 0.18.3
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.ts +70 -1
- package/dist/index.js +70 -0
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -628,6 +628,12 @@ interface PluginManifest {
|
|
|
628
628
|
/** Path to .jay-command metadata file (for input schema and description) */
|
|
629
629
|
command?: string;
|
|
630
630
|
}>;
|
|
631
|
+
/** Jay-HTML validators provided by this plugin (DL#145) */
|
|
632
|
+
validators?: Array<{
|
|
633
|
+
name: string;
|
|
634
|
+
handler: string;
|
|
635
|
+
description?: string;
|
|
636
|
+
}>;
|
|
631
637
|
/** Plugin setup configuration (Design Log #87) */
|
|
632
638
|
setup?: {
|
|
633
639
|
/** Export name (NPM) or relative path (local) to setup handler function */
|
|
@@ -704,6 +710,69 @@ declare function resolvePluginComponent(projectRoot: string, pluginName: string,
|
|
|
704
710
|
*/
|
|
705
711
|
declare function resolvePluginManifest(projectRoot: string, pluginName: string): WithValidations<PluginManifest>;
|
|
706
712
|
|
|
713
|
+
interface JayHtmlValidationFinding {
|
|
714
|
+
severity: 'error' | 'warning';
|
|
715
|
+
message: string;
|
|
716
|
+
suggestion?: string;
|
|
717
|
+
element?: string;
|
|
718
|
+
attribute?: string;
|
|
719
|
+
}
|
|
720
|
+
interface JayHtmlValidationContext {
|
|
721
|
+
body: any;
|
|
722
|
+
filePath: string;
|
|
723
|
+
projectRoot: string;
|
|
724
|
+
contract?: {
|
|
725
|
+
name: string;
|
|
726
|
+
tags: Array<{
|
|
727
|
+
tag: string;
|
|
728
|
+
type: number[];
|
|
729
|
+
meta?: Record<string, string>;
|
|
730
|
+
tags?: any[];
|
|
731
|
+
repeated?: boolean;
|
|
732
|
+
[key: string]: any;
|
|
733
|
+
}>;
|
|
734
|
+
props?: Array<{
|
|
735
|
+
name: string;
|
|
736
|
+
required?: boolean;
|
|
737
|
+
[key: string]: any;
|
|
738
|
+
}>;
|
|
739
|
+
params?: Array<{
|
|
740
|
+
name: string;
|
|
741
|
+
kind: string;
|
|
742
|
+
}>;
|
|
743
|
+
};
|
|
744
|
+
headlessImports: Array<{
|
|
745
|
+
key?: string;
|
|
746
|
+
contractName: string;
|
|
747
|
+
contract?: JayHtmlValidationContext['contract'];
|
|
748
|
+
}>;
|
|
749
|
+
}
|
|
750
|
+
type JayHtmlValidatorFn = (context: JayHtmlValidationContext) => JayHtmlValidationFinding[] | Promise<JayHtmlValidationFinding[]>;
|
|
751
|
+
|
|
752
|
+
interface TemplatePart {
|
|
753
|
+
kind: 'static' | 'binding';
|
|
754
|
+
value: string;
|
|
755
|
+
}
|
|
756
|
+
interface DataScope {
|
|
757
|
+
tags: Array<{
|
|
758
|
+
tag: string;
|
|
759
|
+
tags?: any[];
|
|
760
|
+
meta?: Record<string, string>;
|
|
761
|
+
[key: string]: any;
|
|
762
|
+
}>;
|
|
763
|
+
parent?: DataScope;
|
|
764
|
+
}
|
|
765
|
+
interface ResolvedBinding {
|
|
766
|
+
path: string;
|
|
767
|
+
tag?: {
|
|
768
|
+
tag: string;
|
|
769
|
+
meta?: Record<string, string>;
|
|
770
|
+
[key: string]: any;
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
declare function resolveBinding(bindingPath: string, scope: DataScope): ResolvedBinding;
|
|
774
|
+
declare function walkElements(root: any, ctx: JayHtmlValidationContext, visitor: (el: any, scope: DataScope) => void): void;
|
|
775
|
+
|
|
707
776
|
/**
|
|
708
777
|
* Build-time utilities for coordinate template compilation.
|
|
709
778
|
*
|
|
@@ -777,4 +846,4 @@ declare function compileForEachInstanceKeyExpr(coordinateSuffix: string, trackBy
|
|
|
777
846
|
*/
|
|
778
847
|
declare function computeForEachInstanceKey(trackByValue: string, coordinateSuffix: string): string;
|
|
779
848
|
|
|
780
|
-
export { type ActionManifestEntry, CSS_EXTENSION, type CompilerSourceFile, type DynamicContractConfig, GenerateTarget, type GenericTypescriptSourceFile, Import, type ImportName, type ImportedRefsTree, Imports, ImportsFor, JAY_4_REACT, JAY_ACTION_DTS_EXTENSION, JAY_ACTION_EXTENSION, JAY_COMPONENT, JAY_CONTRACT_DTS_EXTENSION, JAY_CONTRACT_EXTENSION, JAY_DTS_EXTENSION, JAY_EXTENSION, JAY_FULLSTACK_COMPONENTS, JAY_QUERY_CLIENT, JAY_QUERY_HYDRATE, JAY_QUERY_MAIN_SANDBOX, JAY_QUERY_MAIN_SANDBOX_TS, JAY_QUERY_PREFIX, JAY_QUERY_SERVER, JAY_QUERY_WORKER_SANDBOX, JAY_QUERY_WORKER_SANDBOX_TS, JAY_QUERY_WORKER_TRUSTED, JAY_QUERY_WORKER_TRUSTED_TS, JAY_RUNTIME, JAY_SECURE, JAY_SSR_RUNTIME, JAY_STACK_CLIENT_RUNTIME, JAY_TS_EXTENSION, JayArrayType, JayAtomicType, JayBoolean, JayBuildEnvironment, JayComponentApiMember, JayComponentType, JayDate, JayElementConstructorType, JayElementType, JayEnumType, type JayEnvironment, JayErrorType, JayFileType, JayHTMLType, JayHtmlString, type JayImportLink, type JayImportName, JayImportedType, JayNumber, JayObjectType, JayOptionalType, JayPromiseType, JayRecordType, JayRecursiveType, JayString, type JayType, JayTypeAlias, JayTypeKind, JayUnionType, JayUnknown, type JayValidations, type JsonSchemaProperty, LOCAL_PLUGIN_PATH, MAKE_JAY_4_REACT_COMPONENT, MAKE_JAY_COMPONENT, MAKE_JAY_TSX_COMPONENT, type MainRuntimeModes, type ParsedJayModuleSpecifier, type PluginComponentResolution, type PluginInitConfig, type PluginManifest, REACT, type RecursiveRegion, type Ref, type RefsTree, RenderFragment, RuntimeMode, SourceFileFormat, TSX_EXTENSION, TS_EXTENSION, WithValidations, addBuildEnvironment, checkValidationErrors, compileCoordinateExpr, compileForEachInstanceKeyExpr, computeForEachInstanceKey, equalJayTypes, findDynamicContract, getBasePath, getBuildEnvironment, getJayTsFileSourcePath, getMode, getModeFileExtension, getModeFromExtension, hasBuildEnvironment, hasExtension, hasJayExtension, hasJayModeExtension, hasRefs, isArrayType, isAtomicType, isComponentType, isCurrencyType, isDateWithTimezoneType, isElementConstructorType, isElementType, isEnumType, isHTMLType, isHtmlStringType, isImportedType, isLocalModule, isObjectType, isOptionalType, isPromiseType, isRecordType, isRecursiveType, isStaticCoordinate, isTypeAliasType, isUnionType, jayTypeToJsonSchema, loadPluginManifest, mergeRefsTrees, mkRef, mkRefsTree, nestRefs, normalizeActionEntry, parseJayModuleSpecifier, prettify, prettifyHtml, removeComments, resolvePluginComponent, resolvePluginManifest, resolvePrimitiveType, withOriginalTrace, withoutExtension };
|
|
849
|
+
export { type ActionManifestEntry, CSS_EXTENSION, type CompilerSourceFile, type DataScope, type DynamicContractConfig, GenerateTarget, type GenericTypescriptSourceFile, Import, type ImportName, type ImportedRefsTree, Imports, ImportsFor, JAY_4_REACT, JAY_ACTION_DTS_EXTENSION, JAY_ACTION_EXTENSION, JAY_COMPONENT, JAY_CONTRACT_DTS_EXTENSION, JAY_CONTRACT_EXTENSION, JAY_DTS_EXTENSION, JAY_EXTENSION, JAY_FULLSTACK_COMPONENTS, JAY_QUERY_CLIENT, JAY_QUERY_HYDRATE, JAY_QUERY_MAIN_SANDBOX, JAY_QUERY_MAIN_SANDBOX_TS, JAY_QUERY_PREFIX, JAY_QUERY_SERVER, JAY_QUERY_WORKER_SANDBOX, JAY_QUERY_WORKER_SANDBOX_TS, JAY_QUERY_WORKER_TRUSTED, JAY_QUERY_WORKER_TRUSTED_TS, JAY_RUNTIME, JAY_SECURE, JAY_SSR_RUNTIME, JAY_STACK_CLIENT_RUNTIME, JAY_TS_EXTENSION, JayArrayType, JayAtomicType, JayBoolean, JayBuildEnvironment, JayComponentApiMember, JayComponentType, JayDate, JayElementConstructorType, JayElementType, JayEnumType, type JayEnvironment, JayErrorType, JayFileType, JayHTMLType, JayHtmlString, type JayHtmlValidationContext, type JayHtmlValidationFinding, type JayHtmlValidatorFn, type JayImportLink, type JayImportName, JayImportedType, JayNumber, JayObjectType, JayOptionalType, JayPromiseType, JayRecordType, JayRecursiveType, JayString, type JayType, JayTypeAlias, JayTypeKind, JayUnionType, JayUnknown, type JayValidations, type JsonSchemaProperty, LOCAL_PLUGIN_PATH, MAKE_JAY_4_REACT_COMPONENT, MAKE_JAY_COMPONENT, MAKE_JAY_TSX_COMPONENT, type MainRuntimeModes, type ParsedJayModuleSpecifier, type PluginComponentResolution, type PluginInitConfig, type PluginManifest, REACT, type RecursiveRegion, type Ref, type RefsTree, RenderFragment, type ResolvedBinding, RuntimeMode, SourceFileFormat, TSX_EXTENSION, TS_EXTENSION, type TemplatePart, WithValidations, addBuildEnvironment, checkValidationErrors, compileCoordinateExpr, compileForEachInstanceKeyExpr, computeForEachInstanceKey, equalJayTypes, findDynamicContract, getBasePath, getBuildEnvironment, getJayTsFileSourcePath, getMode, getModeFileExtension, getModeFromExtension, hasBuildEnvironment, hasExtension, hasJayExtension, hasJayModeExtension, hasRefs, isArrayType, isAtomicType, isComponentType, isCurrencyType, isDateWithTimezoneType, isElementConstructorType, isElementType, isEnumType, isHTMLType, isHtmlStringType, isImportedType, isLocalModule, isObjectType, isOptionalType, isPromiseType, isRecordType, isRecursiveType, isStaticCoordinate, isTypeAliasType, isUnionType, jayTypeToJsonSchema, loadPluginManifest, mergeRefsTrees, mkRef, mkRefsTree, nestRefs, normalizeActionEntry, parseJayModuleSpecifier, prettify, prettifyHtml, removeComments, resolveBinding, resolvePluginComponent, resolvePluginManifest, resolvePrimitiveType, walkElements, withOriginalTrace, withoutExtension };
|
package/dist/index.js
CHANGED
|
@@ -1595,6 +1595,74 @@ function resolvePluginManifest(projectRoot, pluginName) {
|
|
|
1595
1595
|
`Plugin "${pluginName}" not found. Searched in src/plugins/${pluginName}/ and node_modules/${pluginName}/. Ensure the plugin is installed or exists in your project.`
|
|
1596
1596
|
]);
|
|
1597
1597
|
}
|
|
1598
|
+
function resolveBinding(bindingPath, scope) {
|
|
1599
|
+
const segments = bindingPath.split(".");
|
|
1600
|
+
let tags = scope.tags;
|
|
1601
|
+
for (let i2 = 0; i2 < segments.length; i2++) {
|
|
1602
|
+
const match = tags.find((t) => t.tag === segments[i2]);
|
|
1603
|
+
if (!match)
|
|
1604
|
+
return { path: bindingPath };
|
|
1605
|
+
if (i2 === segments.length - 1)
|
|
1606
|
+
return { path: bindingPath, tag: match };
|
|
1607
|
+
if (!match.tags)
|
|
1608
|
+
return { path: bindingPath };
|
|
1609
|
+
tags = match.tags;
|
|
1610
|
+
}
|
|
1611
|
+
return { path: bindingPath };
|
|
1612
|
+
}
|
|
1613
|
+
function resolveTagPath(dotPath, tags) {
|
|
1614
|
+
const segments = dotPath.split(".");
|
|
1615
|
+
let currentTags = tags;
|
|
1616
|
+
for (let i2 = 0; i2 < segments.length; i2++) {
|
|
1617
|
+
const match = currentTags.find((t) => t.tag === segments[i2]);
|
|
1618
|
+
if (!match)
|
|
1619
|
+
return void 0;
|
|
1620
|
+
if (i2 === segments.length - 1)
|
|
1621
|
+
return match;
|
|
1622
|
+
if (!match.tags)
|
|
1623
|
+
return void 0;
|
|
1624
|
+
currentTags = match.tags;
|
|
1625
|
+
}
|
|
1626
|
+
return void 0;
|
|
1627
|
+
}
|
|
1628
|
+
function walkElements(root, ctx, visitor) {
|
|
1629
|
+
const pageScope = {
|
|
1630
|
+
tags: ctx.contract?.tags ?? []
|
|
1631
|
+
};
|
|
1632
|
+
doWalk(root, ctx, pageScope, visitor);
|
|
1633
|
+
}
|
|
1634
|
+
function doWalk(el, ctx, scope, visitor) {
|
|
1635
|
+
let currentScope = scope;
|
|
1636
|
+
const tagName = el.rawTagName?.toLowerCase();
|
|
1637
|
+
if (tagName?.startsWith("jay:")) {
|
|
1638
|
+
const contractName = tagName.substring(4);
|
|
1639
|
+
const headless = ctx.headlessImports.find(
|
|
1640
|
+
(h) => h.contractName === contractName && h.contract
|
|
1641
|
+
);
|
|
1642
|
+
if (headless?.contract) {
|
|
1643
|
+
currentScope = {
|
|
1644
|
+
tags: headless.contract.tags,
|
|
1645
|
+
parent: scope
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
const forEach = el.getAttribute?.("forEach");
|
|
1650
|
+
if (forEach) {
|
|
1651
|
+
const arrayTag = resolveTagPath(forEach, currentScope.tags);
|
|
1652
|
+
if (arrayTag?.tags) {
|
|
1653
|
+
currentScope = {
|
|
1654
|
+
tags: arrayTag.tags,
|
|
1655
|
+
parent: currentScope
|
|
1656
|
+
};
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
visitor(el, currentScope);
|
|
1660
|
+
for (const child of el.childNodes ?? []) {
|
|
1661
|
+
if (child.nodeType === 1) {
|
|
1662
|
+
doWalk(child, ctx, currentScope, visitor);
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1598
1666
|
function compileCoordinateExpr(template, varMappings) {
|
|
1599
1667
|
if (!template.includes("$")) {
|
|
1600
1668
|
return `'${template}'`;
|
|
@@ -1757,11 +1825,13 @@ export {
|
|
|
1757
1825
|
prettify,
|
|
1758
1826
|
prettifyHtml,
|
|
1759
1827
|
removeComments,
|
|
1828
|
+
resolveBinding,
|
|
1760
1829
|
resolvePluginComponent,
|
|
1761
1830
|
resolvePluginManifest,
|
|
1762
1831
|
resolvePrimitiveType,
|
|
1763
1832
|
u as ts,
|
|
1764
1833
|
c as tsBridge,
|
|
1834
|
+
walkElements,
|
|
1765
1835
|
withOriginalTrace,
|
|
1766
1836
|
withoutExtension
|
|
1767
1837
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/compiler-shared",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
},
|
|
26
26
|
"author": "",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@jay-framework/component": "^0.18.
|
|
29
|
-
"@jay-framework/runtime": "^0.18.
|
|
30
|
-
"@jay-framework/secure": "^0.18.
|
|
31
|
-
"@jay-framework/typescript-bridge": "^0.18.
|
|
28
|
+
"@jay-framework/component": "^0.18.3",
|
|
29
|
+
"@jay-framework/runtime": "^0.18.3",
|
|
30
|
+
"@jay-framework/secure": "^0.18.3",
|
|
31
|
+
"@jay-framework/typescript-bridge": "^0.18.3",
|
|
32
32
|
"@types/js-yaml": "^4.0.9",
|
|
33
33
|
"change-case": "^4.1.2",
|
|
34
34
|
"js-beautify": "^1.14.11",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@caiogondim/strip-margin": "^1.0.0",
|
|
44
|
-
"@jay-framework/dev-environment": "^0.18.
|
|
44
|
+
"@jay-framework/dev-environment": "^0.18.3",
|
|
45
45
|
"@testing-library/jest-dom": "^6.2.0",
|
|
46
46
|
"@types/js-beautify": "^1",
|
|
47
47
|
"@types/node": "^20.11.5",
|