@jay-framework/compiler-jay-html 0.25.1 → 0.25.2
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 +26 -1
- package/dist/index.js +52 -3
- package/package.json +9 -9
package/dist/index.d.cts
CHANGED
|
@@ -49,6 +49,31 @@ interface Contract {
|
|
|
49
49
|
params?: Array<ContractParam>;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Built-in contracts the compiler recognizes without any plugin/module resolution (Design Log #218).
|
|
54
|
+
*
|
|
55
|
+
* The Error contract backs error pages: a page declares
|
|
56
|
+
* `<script type="application/jay-headless" plugin="jay-stack" contract="error" key="error">`
|
|
57
|
+
* and the compiler special-cases this pair to {@link ERROR_CONTRACT} (no filesystem lookup),
|
|
58
|
+
* giving the page a typed `error?: ErrorViewState` field. The matching `ErrorViewState` /
|
|
59
|
+
* `ErrorRefs` types are shipped (hand-written, type-only) from {@link ERROR_CONTRACT_MODULE}
|
|
60
|
+
* so the generated page imports resolve against a real, stable specifier.
|
|
61
|
+
*/
|
|
62
|
+
declare const ERROR_CONTRACT_PLUGIN = "jay-stack";
|
|
63
|
+
declare const ERROR_CONTRACT_NAME = "error";
|
|
64
|
+
/** The bare module specifier the generated `error` types are imported from. */
|
|
65
|
+
declare const ERROR_CONTRACT_MODULE = "@jay-framework/fullstack-component";
|
|
66
|
+
/**
|
|
67
|
+
* The built-in Error contract (Design Log #218).
|
|
68
|
+
*
|
|
69
|
+
* All fields are `fast` — the error data is a request-time pass-through injected at render,
|
|
70
|
+
* not build-time slow data. `details` is a repeated sub-contract so a page can
|
|
71
|
+
* `forEach="error.details"` over `{ key, value }` pairs.
|
|
72
|
+
*/
|
|
73
|
+
declare const ERROR_CONTRACT: Contract;
|
|
74
|
+
/** True when a headless import's plugin/contract pair is the built-in Error contract. */
|
|
75
|
+
declare function isBuiltInErrorContract(plugin: string | null | undefined, contract: string | null | undefined): boolean;
|
|
76
|
+
|
|
52
77
|
declare function compileContract(contractWithValidations: WithValidations<Contract>, contractFilePath: string, jayImportResolver: JayImportResolver): Promise<WithValidations<string>>;
|
|
53
78
|
|
|
54
79
|
declare function parseContract(contractYaml: string, fileName: string): WithValidations<Contract>;
|
|
@@ -621,4 +646,4 @@ declare function resolveHeadlessInstances(preRenderedJayHtml: string, instanceDa
|
|
|
621
646
|
*/
|
|
622
647
|
declare function hasSlowPhaseProperties(contract: Contract | undefined): boolean;
|
|
623
648
|
|
|
624
|
-
export { type ActionDefinition, type AssignCoordinatesOptions, type AssignCoordinatesResult, type Contract, type ContractImportInfo, type ContractParam, type ContractParamKind, type ContractProp, type ContractResolver, type ContractTag, ContractTagType, type DiscoveredHeadlessInstance, type EnumToImport, type ForEachHeadlessInstance, type HeadlessContractInfo, type HeadlessInstanceDiscoveryResult, type HeadlessInstanceResolvedData, JAY_IMPORT_RESOLVER, type JayContractImportLink, type JayHeadlessImports, type JayHtmlScript, type JayHtmlSourceFile, type JayImportResolver, type PhaseViewStates, type RenderingPhase, type ServerElementOptions, type SlowRenderInput, type SlowRenderOutput, assignCoordinates, assignCoordinatesToJayHtml, buildInstanceCoordinateKey, compileAction, compileContract, contractToAllPhaseViewStates, contractToImportsViewStateAndRefs, contractToPhaseViewState, createPhaseContract, defaultContractResolver, discoverHeadlessInstances, filterTagsByPhase, generateElementBridgeFile, generateElementDefinitionFile, generateElementFile, generateElementFileReactTarget, generateElementHydrateFile, generateSandboxRootFile, generateServerElementFile, generateTypes, getEffectivePhase, getJayHtmlImports, getLinkedContractDir, hasSlowPhaseProperties, htmlElementTagNameMap, isTagInPhase, loadLinkedContract, parseAction, parseContract, parseEnumValues, parseIsEnum, parseJayFile, parseTemplateParts, renderRefsType, resolveHeadlessInstances, slowRenderTransform, validateContractPhases };
|
|
649
|
+
export { type ActionDefinition, type AssignCoordinatesOptions, type AssignCoordinatesResult, type Contract, type ContractImportInfo, type ContractParam, type ContractParamKind, type ContractProp, type ContractResolver, type ContractTag, ContractTagType, type DiscoveredHeadlessInstance, ERROR_CONTRACT, ERROR_CONTRACT_MODULE, ERROR_CONTRACT_NAME, ERROR_CONTRACT_PLUGIN, type EnumToImport, type ForEachHeadlessInstance, type HeadlessContractInfo, type HeadlessInstanceDiscoveryResult, type HeadlessInstanceResolvedData, JAY_IMPORT_RESOLVER, type JayContractImportLink, type JayHeadlessImports, type JayHtmlScript, type JayHtmlSourceFile, type JayImportResolver, type PhaseViewStates, type RenderingPhase, type ServerElementOptions, type SlowRenderInput, type SlowRenderOutput, assignCoordinates, assignCoordinatesToJayHtml, buildInstanceCoordinateKey, compileAction, compileContract, contractToAllPhaseViewStates, contractToImportsViewStateAndRefs, contractToPhaseViewState, createPhaseContract, defaultContractResolver, discoverHeadlessInstances, filterTagsByPhase, generateElementBridgeFile, generateElementDefinitionFile, generateElementFile, generateElementFileReactTarget, generateElementHydrateFile, generateSandboxRootFile, generateServerElementFile, generateTypes, getEffectivePhase, getJayHtmlImports, getLinkedContractDir, hasSlowPhaseProperties, htmlElementTagNameMap, isBuiltInErrorContract, isTagInPhase, loadLinkedContract, parseAction, parseContract, parseEnumValues, parseIsEnum, parseJayFile, parseTemplateParts, renderRefsType, resolveHeadlessInstances, slowRenderTransform, validateContractPhases };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { camelCase as camelCase$1, JayImportedType, JayString, JayUnknown, isObjectType as isObjectType$1, isImportedType, isRecursiveType, Imports, Import, RenderFragment, WithValidations, isArrayType as isArrayType$1, isAtomicType, isPromiseType, isEnumType, GenerateTarget, hasRefs, JayTypeAlias, JayUnionType, mkRefsTree, equalJayTypes, mkRef, JayComponentType, JayHTMLType, getModeFileExtension, isHtmlStringType, RuntimeMode, nestRefs, mergeRefsTrees, SourceFileFormat, JayEnumType, JayObjectType, JayArrayType, JayPromiseType, resolvePrimitiveType, JayRecursiveType, JAY_CONTRACT_EXTENSION as JAY_CONTRACT_EXTENSION$1, ImportsFor, JAY_FULLSTACK_COMPONENTS, hoistFreeRefs, freeRefsAugmentedRefType, isComponentType as isComponentType$1, JayErrorType, JayOptionalType, JayRecordType, isOptionalType, isRecordType, resolvePluginManifest, resolvePluginComponent } from "@jay-framework/compiler-shared";
|
|
1
|
+
import { camelCase as camelCase$1, JayImportedType, JayString, JayUnknown, isObjectType as isObjectType$1, isImportedType, isRecursiveType, Imports, Import, RenderFragment, WithValidations, isArrayType as isArrayType$1, isAtomicType, isPromiseType, isEnumType, GenerateTarget, hasRefs, JayTypeAlias, JayUnionType, mkRefsTree, equalJayTypes, mkRef, JayComponentType, JayHTMLType, getModeFileExtension, isHtmlStringType, RuntimeMode, nestRefs, mergeRefsTrees, JayNumber, SourceFileFormat, JayEnumType, JayObjectType, JayArrayType, JayPromiseType, resolvePrimitiveType, JayRecursiveType, JAY_CONTRACT_EXTENSION as JAY_CONTRACT_EXTENSION$1, ImportsFor, JAY_FULLSTACK_COMPONENTS, hoistFreeRefs, freeRefsAugmentedRefType, isComponentType as isComponentType$1, JayErrorType, JayOptionalType, JayRecordType, isOptionalType, isRecordType, resolvePluginManifest, resolvePluginComponent } from "@jay-framework/compiler-shared";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { getLogger } from "@jay-framework/logger";
|
|
4
4
|
import fs from "fs/promises";
|
|
@@ -15375,6 +15375,34 @@ ${renderedRefsManager}
|
|
|
15375
15375
|
renderedBridge.refs
|
|
15376
15376
|
);
|
|
15377
15377
|
}
|
|
15378
|
+
const ERROR_CONTRACT_PLUGIN = "jay-stack";
|
|
15379
|
+
const ERROR_CONTRACT_NAME = "error";
|
|
15380
|
+
const ERROR_CONTRACT_MODULE = "@jay-framework/fullstack-component";
|
|
15381
|
+
const ERROR_CONTRACT = {
|
|
15382
|
+
name: "Error",
|
|
15383
|
+
description: "Built-in error information injected into error pages (Design Log #218).",
|
|
15384
|
+
tags: [
|
|
15385
|
+
{ tag: "status", type: [ContractTagType.data], dataType: JayNumber, phase: "fast" },
|
|
15386
|
+
{ tag: "title", type: [ContractTagType.data], dataType: JayString, phase: "fast" },
|
|
15387
|
+
{ tag: "message", type: [ContractTagType.data], dataType: JayString, phase: "fast" },
|
|
15388
|
+
{ tag: "url", type: [ContractTagType.data], dataType: JayString, phase: "fast" },
|
|
15389
|
+
{ tag: "code", type: [ContractTagType.data], dataType: JayString, phase: "fast" },
|
|
15390
|
+
{
|
|
15391
|
+
tag: "details",
|
|
15392
|
+
type: [ContractTagType.subContract],
|
|
15393
|
+
repeated: true,
|
|
15394
|
+
trackBy: "key",
|
|
15395
|
+
phase: "fast",
|
|
15396
|
+
tags: [
|
|
15397
|
+
{ tag: "key", type: [ContractTagType.data], dataType: JayString },
|
|
15398
|
+
{ tag: "value", type: [ContractTagType.data], dataType: JayString }
|
|
15399
|
+
]
|
|
15400
|
+
}
|
|
15401
|
+
]
|
|
15402
|
+
};
|
|
15403
|
+
function isBuiltInErrorContract(plugin, contract) {
|
|
15404
|
+
return plugin === ERROR_CONTRACT_PLUGIN && contract === ERROR_CONTRACT_NAME;
|
|
15405
|
+
}
|
|
15378
15406
|
function getDefaultExportFromCjs(x) {
|
|
15379
15407
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
15380
15408
|
}
|
|
@@ -19205,7 +19233,13 @@ async function parseHeadlessImports(elements, validations, filePath, importResol
|
|
|
19205
19233
|
let structural = false;
|
|
19206
19234
|
let contractTagName = contractAttr;
|
|
19207
19235
|
try {
|
|
19208
|
-
if (pluginAttr) {
|
|
19236
|
+
if (isBuiltInErrorContract(pluginAttr, contractAttr)) {
|
|
19237
|
+
loadedContract = ERROR_CONTRACT;
|
|
19238
|
+
contractFile = ERROR_CONTRACT_MODULE;
|
|
19239
|
+
name = pascalCase(ERROR_CONTRACT.name);
|
|
19240
|
+
module = ERROR_CONTRACT_MODULE;
|
|
19241
|
+
contractTagName = paramCase(ERROR_CONTRACT.name);
|
|
19242
|
+
} else if (pluginAttr) {
|
|
19209
19243
|
const resolveResult = importResolver.resolvePluginComponent(
|
|
19210
19244
|
pluginAttr,
|
|
19211
19245
|
contractAttr,
|
|
@@ -19292,7 +19326,7 @@ async function parseHeadlessImports(elements, validations, filePath, importResol
|
|
|
19292
19326
|
declaringModule: toRelativeModule(enumsToImport2.declaringModule)
|
|
19293
19327
|
})
|
|
19294
19328
|
);
|
|
19295
|
-
const relativeContractPath = toRelativeModule(contractFile);
|
|
19329
|
+
const relativeContractPath = contractFile === ERROR_CONTRACT_MODULE ? contractFile : toRelativeModule(contractFile);
|
|
19296
19330
|
const enumsFromContract = enumsToImportRelativeToJayHtml.filter((_) => _.declaringModule === relativeContractPath).map((_) => _.type);
|
|
19297
19331
|
const nestedTypeNames = collectNestedTypeNames(type2);
|
|
19298
19332
|
const nestedTypeImports = nestedTypeNames.filter((name2) => name2 !== type2.name).map((name2) => ({ name: name2, type: JayUnknown }));
|
|
@@ -19383,6 +19417,16 @@ function validateAndCollectScripts(root, validations) {
|
|
|
19383
19417
|
const src = script.getAttribute("src");
|
|
19384
19418
|
const inline = script.textContent?.trim();
|
|
19385
19419
|
const isInHead = !!script.closest("head");
|
|
19420
|
+
if (type2 === "application/ld+json" && !src) {
|
|
19421
|
+
const attributes2 = { ...script.attributes };
|
|
19422
|
+
delete attributes2["jay-script"];
|
|
19423
|
+
scripts.push({
|
|
19424
|
+
inline: inline ?? "",
|
|
19425
|
+
attributes: attributes2,
|
|
19426
|
+
position: isInHead ? "head" : "body"
|
|
19427
|
+
});
|
|
19428
|
+
continue;
|
|
19429
|
+
}
|
|
19386
19430
|
if (src && isLocalSrc(src)) {
|
|
19387
19431
|
validations.push(
|
|
19388
19432
|
`Local script imports are not supported in jay-html. Move the script logic into page.ts with makeJayStackComponent. See designer/script-tags.md.`
|
|
@@ -31438,6 +31482,10 @@ function hasSlowPhaseProperties(contract) {
|
|
|
31438
31482
|
}
|
|
31439
31483
|
export {
|
|
31440
31484
|
ContractTagType,
|
|
31485
|
+
ERROR_CONTRACT,
|
|
31486
|
+
ERROR_CONTRACT_MODULE,
|
|
31487
|
+
ERROR_CONTRACT_NAME,
|
|
31488
|
+
ERROR_CONTRACT_PLUGIN,
|
|
31441
31489
|
JAY_IMPORT_RESOLVER,
|
|
31442
31490
|
assignCoordinates,
|
|
31443
31491
|
assignCoordinatesToJayHtml,
|
|
@@ -31464,6 +31512,7 @@ export {
|
|
|
31464
31512
|
getLinkedContractDir,
|
|
31465
31513
|
hasSlowPhaseProperties,
|
|
31466
31514
|
htmlElementTagNameMap,
|
|
31515
|
+
isBuiltInErrorContract,
|
|
31467
31516
|
isTagInPhase,
|
|
31468
31517
|
loadLinkedContract,
|
|
31469
31518
|
parseAction,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/compiler-jay-html",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
},
|
|
35
35
|
"author": "",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@jay-framework/compiler-analyze-exported-types": "^0.25.
|
|
38
|
-
"@jay-framework/compiler-shared": "^0.25.
|
|
39
|
-
"@jay-framework/component": "^0.25.
|
|
40
|
-
"@jay-framework/logger": "^0.25.
|
|
41
|
-
"@jay-framework/runtime": "^0.25.
|
|
42
|
-
"@jay-framework/secure": "^0.25.
|
|
37
|
+
"@jay-framework/compiler-analyze-exported-types": "^0.25.2",
|
|
38
|
+
"@jay-framework/compiler-shared": "^0.25.2",
|
|
39
|
+
"@jay-framework/component": "^0.25.2",
|
|
40
|
+
"@jay-framework/logger": "^0.25.2",
|
|
41
|
+
"@jay-framework/runtime": "^0.25.2",
|
|
42
|
+
"@jay-framework/secure": "^0.25.2",
|
|
43
43
|
"@types/js-yaml": "^4.0.9",
|
|
44
44
|
"change-case": "^4.1.2",
|
|
45
45
|
"he": "^1.2.0",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@caiogondim/strip-margin": "^1.0.0",
|
|
55
|
-
"@jay-framework/4-react": "^0.25.
|
|
56
|
-
"@jay-framework/dev-environment": "^0.25.
|
|
55
|
+
"@jay-framework/4-react": "^0.25.2",
|
|
56
|
+
"@jay-framework/dev-environment": "^0.25.2",
|
|
57
57
|
"@testing-library/jest-dom": "^6.2.0",
|
|
58
58
|
"@types/js-beautify": "^1",
|
|
59
59
|
"@types/node": "^20.11.5",
|