@jay-framework/compiler-shared 0.10.0 → 0.12.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.ts +40 -6
- package/dist/index.js +166 -73
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ declare const Import: {
|
|
|
31
31
|
svgDynamicElement: ImportName;
|
|
32
32
|
mathMLDynamicElement: ImportName;
|
|
33
33
|
forEach: ImportName;
|
|
34
|
+
slowForEachItem: ImportName;
|
|
34
35
|
resolved: ImportName;
|
|
35
36
|
pending: ImportName;
|
|
36
37
|
rejected: ImportName;
|
|
@@ -68,6 +69,8 @@ declare const Import: {
|
|
|
68
69
|
mimicJayElement: ImportName;
|
|
69
70
|
jayContract: ImportName;
|
|
70
71
|
injectHeadLinks: ImportName;
|
|
72
|
+
makeJayComponent: ImportName;
|
|
73
|
+
makeHeadlessInstanceComponent: ImportName;
|
|
71
74
|
};
|
|
72
75
|
declare class Imports {
|
|
73
76
|
private readonly imports;
|
|
@@ -92,6 +95,7 @@ declare const JAY_SECURE = "@jay-framework/secure";
|
|
|
92
95
|
declare const JAY_RUNTIME = "@jay-framework/runtime";
|
|
93
96
|
declare const JAY_4_REACT = "@jay-framework/4-react";
|
|
94
97
|
declare const JAY_FULLSTACK_COMPONENTS = "@jay-framework/fullstack-component";
|
|
98
|
+
declare const JAY_STACK_CLIENT_RUNTIME = "@jay-framework/stack-client-runtime";
|
|
95
99
|
declare const REACT = "react";
|
|
96
100
|
declare const MAKE_JAY_COMPONENT = "makeJayComponent";
|
|
97
101
|
declare const MAKE_JAY_TSX_COMPONENT = "makeJayTsxComponent";
|
|
@@ -385,6 +389,20 @@ declare class WithValidations<Value> {
|
|
|
385
389
|
flatMap<R>(func: (v: Value) => WithValidations<R>): WithValidations<R>;
|
|
386
390
|
flatMapAsync<R>(func: (v: Value) => Promise<WithValidations<R>>): Promise<WithValidations<R>>;
|
|
387
391
|
merge(other: WithValidations<Value>, merge: (t1: Value, t2: Value) => Value): WithValidations<Value>;
|
|
392
|
+
/**
|
|
393
|
+
* Append validations from another WithValidations without changing the value.
|
|
394
|
+
* Useful for collecting validations from side-effect operations.
|
|
395
|
+
*/
|
|
396
|
+
withValidationsFrom<T>(other: WithValidations<T>): WithValidations<Value>;
|
|
397
|
+
/**
|
|
398
|
+
* Merge an array of WithValidations into a single WithValidations containing an array of values.
|
|
399
|
+
* All validations are collected.
|
|
400
|
+
*/
|
|
401
|
+
static all<T>(items: WithValidations<T>[]): WithValidations<T[]>;
|
|
402
|
+
/**
|
|
403
|
+
* Create a WithValidations with no validations (pure value).
|
|
404
|
+
*/
|
|
405
|
+
static pure<T>(value: T): WithValidations<T>;
|
|
388
406
|
}
|
|
389
407
|
declare function checkValidationErrors<T>(withValidations: WithValidations<T>): T;
|
|
390
408
|
|
|
@@ -474,6 +492,17 @@ declare function removeComments(code: string): string;
|
|
|
474
492
|
* ```
|
|
475
493
|
*/
|
|
476
494
|
type PluginInitConfig = string;
|
|
495
|
+
/**
|
|
496
|
+
* Dynamic contract generator configuration.
|
|
497
|
+
*/
|
|
498
|
+
interface DynamicContractConfig {
|
|
499
|
+
/** Path to the generator module (relative to plugin root) */
|
|
500
|
+
generator: string;
|
|
501
|
+
/** Path to the headless component (relative to plugin root) */
|
|
502
|
+
component: string;
|
|
503
|
+
/** Prefix for generated contract names (e.g., "cms" -> "cms/blog-posts") */
|
|
504
|
+
prefix: string;
|
|
505
|
+
}
|
|
477
506
|
/**
|
|
478
507
|
* Plugin manifest structure from plugin.yaml
|
|
479
508
|
*/
|
|
@@ -487,15 +516,20 @@ interface PluginManifest {
|
|
|
487
516
|
component: string;
|
|
488
517
|
description?: string;
|
|
489
518
|
}>;
|
|
490
|
-
dynamic_contracts?:
|
|
491
|
-
generator: string;
|
|
492
|
-
component: string;
|
|
493
|
-
prefix: string;
|
|
494
|
-
};
|
|
519
|
+
dynamic_contracts?: DynamicContractConfig | DynamicContractConfig[];
|
|
495
520
|
/** Named exports from plugin backend bundle that are JayAction instances */
|
|
496
521
|
actions?: string[];
|
|
497
522
|
/** Plugin initialization configuration */
|
|
498
523
|
init?: PluginInitConfig;
|
|
524
|
+
/** Plugin setup configuration (Design Log #87) */
|
|
525
|
+
setup?: {
|
|
526
|
+
/** Export name (NPM) or relative path (local) to setup handler function */
|
|
527
|
+
handler: string;
|
|
528
|
+
/** Export name for reference data generation (called by jay-stack agent-kit) */
|
|
529
|
+
references?: string;
|
|
530
|
+
/** Human-readable description of what setup does */
|
|
531
|
+
description?: string;
|
|
532
|
+
};
|
|
499
533
|
}
|
|
500
534
|
/**
|
|
501
535
|
* Result of resolving a plugin component
|
|
@@ -547,4 +581,4 @@ declare function resolveNpmPlugin(projectRoot: string, pluginName: string, contr
|
|
|
547
581
|
*/
|
|
548
582
|
declare function resolvePluginComponent(projectRoot: string, pluginName: string, contractName: string): WithValidations<PluginComponentResolution>;
|
|
549
583
|
|
|
550
|
-
export { CSS_EXTENSION, type CompilerSourceFile, GenerateTarget, type GenericTypescriptSourceFile, Import, type ImportName, type ImportedRefsTree, Imports, ImportsFor, JAY_4_REACT, JAY_COMPONENT, JAY_CONTRACT_DTS_EXTENSION, JAY_CONTRACT_EXTENSION, JAY_DTS_EXTENSION, JAY_EXTENSION, JAY_FULLSTACK_COMPONENTS, JAY_QUERY_CLIENT, 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_TS_EXTENSION, JayArrayType, JayAtomicType, JayBoolean, JayBuildEnvironment, JayComponentApiMember, JayComponentType, JayDate, JayElementConstructorType, JayElementType, JayEnumType, type JayEnvironment, JayErrorType, JayHTMLType, type JayImportLink, type JayImportName, JayImportedType, JayNumber, JayObjectType, JayPromiseType, JayRecursiveType, JayString, type JayType, JayTypeAlias, JayTypeKind, JayUnionType, JayUnknown, type JayValidations, 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, equalJayTypes, getBasePath, getBuildEnvironment, getJayTsFileSourcePath, getMode, getModeFileExtension, getModeFromExtension, hasBuildEnvironment, hasExtension, hasJayExtension, hasJayModeExtension, hasRefs, isArrayType, isAtomicType, isComponentType, isCurrencyType, isDateWithTimezoneType, isElementConstructorType, isElementType, isEnumType, isHTMLType, isImportedType, isLocalModule, isObjectType, isPromiseType, isRecursiveType, isTypeAliasType, isUnionType, loadPluginManifest, mergeRefsTrees, mkRef, mkRefsTree, nestRefs, parseJayModuleSpecifier, prettify, prettifyHtml, removeComments, resolveLocalPlugin, resolveNpmPlugin, resolvePluginComponent, resolvePrimitiveType, withOriginalTrace, withoutExtension };
|
|
584
|
+
export { CSS_EXTENSION, type CompilerSourceFile, type DynamicContractConfig, GenerateTarget, type GenericTypescriptSourceFile, Import, type ImportName, type ImportedRefsTree, Imports, ImportsFor, JAY_4_REACT, JAY_COMPONENT, JAY_CONTRACT_DTS_EXTENSION, JAY_CONTRACT_EXTENSION, JAY_DTS_EXTENSION, JAY_EXTENSION, JAY_FULLSTACK_COMPONENTS, JAY_QUERY_CLIENT, 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_STACK_CLIENT_RUNTIME, JAY_TS_EXTENSION, JayArrayType, JayAtomicType, JayBoolean, JayBuildEnvironment, JayComponentApiMember, JayComponentType, JayDate, JayElementConstructorType, JayElementType, JayEnumType, type JayEnvironment, JayErrorType, JayHTMLType, type JayImportLink, type JayImportName, JayImportedType, JayNumber, JayObjectType, JayPromiseType, JayRecursiveType, JayString, type JayType, JayTypeAlias, JayTypeKind, JayUnionType, JayUnknown, type JayValidations, 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, equalJayTypes, getBasePath, getBuildEnvironment, getJayTsFileSourcePath, getMode, getModeFileExtension, getModeFromExtension, hasBuildEnvironment, hasExtension, hasJayExtension, hasJayModeExtension, hasRefs, isArrayType, isAtomicType, isComponentType, isCurrencyType, isDateWithTimezoneType, isElementConstructorType, isElementType, isEnumType, isHTMLType, isImportedType, isLocalModule, isObjectType, isPromiseType, isRecursiveType, isTypeAliasType, isUnionType, loadPluginManifest, mergeRefsTrees, mkRef, mkRefsTree, nestRefs, parseJayModuleSpecifier, prettify, prettifyHtml, removeComments, resolveLocalPlugin, resolveNpmPlugin, resolvePluginComponent, resolvePrimitiveType, withOriginalTrace, withoutExtension };
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ const JAY_SECURE = "@jay-framework/secure";
|
|
|
21
21
|
const JAY_RUNTIME = "@jay-framework/runtime";
|
|
22
22
|
const JAY_4_REACT = "@jay-framework/4-react";
|
|
23
23
|
const JAY_FULLSTACK_COMPONENTS = "@jay-framework/fullstack-component";
|
|
24
|
+
const JAY_STACK_CLIENT_RUNTIME = "@jay-framework/stack-client-runtime";
|
|
24
25
|
const REACT = "react";
|
|
25
26
|
const MAKE_JAY_COMPONENT = "makeJayComponent";
|
|
26
27
|
const MAKE_JAY_TSX_COMPONENT = "makeJayTsxComponent";
|
|
@@ -155,6 +156,12 @@ const Import = {
|
|
|
155
156
|
1
|
|
156
157
|
/* implementation */
|
|
157
158
|
),
|
|
159
|
+
slowForEachItem: importStatementFragment(
|
|
160
|
+
JAY_RUNTIME,
|
|
161
|
+
"slowForEachItem",
|
|
162
|
+
1
|
|
163
|
+
/* implementation */
|
|
164
|
+
),
|
|
158
165
|
resolved: importStatementFragment(
|
|
159
166
|
JAY_RUNTIME,
|
|
160
167
|
"resolved",
|
|
@@ -394,6 +401,18 @@ const Import = {
|
|
|
394
401
|
"injectHeadLinks",
|
|
395
402
|
1
|
|
396
403
|
/* implementation */
|
|
404
|
+
),
|
|
405
|
+
makeJayComponent: importStatementFragment(
|
|
406
|
+
JAY_COMPONENT,
|
|
407
|
+
"makeJayComponent",
|
|
408
|
+
1
|
|
409
|
+
/* implementation */
|
|
410
|
+
),
|
|
411
|
+
makeHeadlessInstanceComponent: importStatementFragment(
|
|
412
|
+
JAY_STACK_CLIENT_RUNTIME,
|
|
413
|
+
"makeHeadlessInstanceComponent",
|
|
414
|
+
1
|
|
415
|
+
/* implementation */
|
|
397
416
|
)
|
|
398
417
|
};
|
|
399
418
|
class Imports {
|
|
@@ -922,6 +941,28 @@ class WithValidations {
|
|
|
922
941
|
...other.validations
|
|
923
942
|
]);
|
|
924
943
|
}
|
|
944
|
+
/**
|
|
945
|
+
* Append validations from another WithValidations without changing the value.
|
|
946
|
+
* Useful for collecting validations from side-effect operations.
|
|
947
|
+
*/
|
|
948
|
+
withValidationsFrom(other) {
|
|
949
|
+
return new WithValidations(this.val, [...this.validations, ...other.validations]);
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Merge an array of WithValidations into a single WithValidations containing an array of values.
|
|
953
|
+
* All validations are collected.
|
|
954
|
+
*/
|
|
955
|
+
static all(items) {
|
|
956
|
+
const values = items.map((item) => item.val).filter((v) => v !== void 0);
|
|
957
|
+
const validations = items.flatMap((item) => item.validations);
|
|
958
|
+
return new WithValidations(values, validations);
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Create a WithValidations with no validations (pure value).
|
|
962
|
+
*/
|
|
963
|
+
static pure(value) {
|
|
964
|
+
return new WithValidations(value, []);
|
|
965
|
+
}
|
|
925
966
|
}
|
|
926
967
|
function checkValidationErrors(withValidations) {
|
|
927
968
|
const { validations } = withValidations;
|
|
@@ -1096,6 +1137,18 @@ function loadPluginManifest(pluginDir) {
|
|
|
1096
1137
|
return null;
|
|
1097
1138
|
}
|
|
1098
1139
|
}
|
|
1140
|
+
function findDynamicContract(manifest, contractName) {
|
|
1141
|
+
if (!manifest.dynamic_contracts) {
|
|
1142
|
+
return null;
|
|
1143
|
+
}
|
|
1144
|
+
const slashIndex = contractName.indexOf("/");
|
|
1145
|
+
if (slashIndex === -1) {
|
|
1146
|
+
return null;
|
|
1147
|
+
}
|
|
1148
|
+
const prefix = contractName.substring(0, slashIndex);
|
|
1149
|
+
const dynamicConfigs = Array.isArray(manifest.dynamic_contracts) ? manifest.dynamic_contracts : [manifest.dynamic_contracts];
|
|
1150
|
+
return dynamicConfigs.find((config) => config.prefix === prefix) || null;
|
|
1151
|
+
}
|
|
1099
1152
|
function resolveLocalPlugin(projectRoot, pluginName, contractName) {
|
|
1100
1153
|
const localPluginPath = path.join(projectRoot, "src/plugins", pluginName);
|
|
1101
1154
|
const pluginYamlPath = path.join(localPluginPath, "plugin.yaml");
|
|
@@ -1113,30 +1166,46 @@ function resolveLocalPlugin(projectRoot, pluginName, contractName) {
|
|
|
1113
1166
|
`Failed to parse plugin.yaml for local plugin "${pluginName}" at ${pluginYamlPath}`
|
|
1114
1167
|
]);
|
|
1115
1168
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1169
|
+
const componentModule = manifest.module || "index.js";
|
|
1170
|
+
const componentPath = path.join(localPluginPath, componentModule);
|
|
1171
|
+
if (manifest.contracts && manifest.contracts.length > 0) {
|
|
1172
|
+
const contract = manifest.contracts.find((c2) => c2.name === contractName);
|
|
1173
|
+
if (contract) {
|
|
1174
|
+
return new WithValidations(
|
|
1175
|
+
{
|
|
1176
|
+
contractPath: path.join(localPluginPath, contract.contract),
|
|
1177
|
+
componentPath,
|
|
1178
|
+
componentName: contract.component,
|
|
1179
|
+
isNpmPackage: false
|
|
1180
|
+
},
|
|
1181
|
+
[]
|
|
1182
|
+
);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
const dynamicConfig = findDynamicContract(manifest, contractName);
|
|
1186
|
+
if (dynamicConfig) {
|
|
1187
|
+
return new WithValidations(
|
|
1188
|
+
{
|
|
1189
|
+
contractPath: "",
|
|
1190
|
+
// Dynamic contracts don't have a static path
|
|
1191
|
+
componentPath,
|
|
1192
|
+
componentName: dynamicConfig.component,
|
|
1193
|
+
isNpmPackage: false
|
|
1194
|
+
},
|
|
1195
|
+
[]
|
|
1196
|
+
);
|
|
1120
1197
|
}
|
|
1121
|
-
|
|
1122
|
-
if (!contract) {
|
|
1123
|
-
const availableContracts = manifest.contracts.map((c2) => c2.name).join(", ");
|
|
1198
|
+
if (!manifest.contracts && !manifest.dynamic_contracts) {
|
|
1124
1199
|
return new WithValidations(null, [
|
|
1125
|
-
`
|
|
1200
|
+
`Local plugin "${pluginName}" has no contracts or dynamic_contracts defined in plugin.yaml`
|
|
1126
1201
|
]);
|
|
1127
1202
|
}
|
|
1128
|
-
const
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
componentName: contract.component,
|
|
1135
|
-
// This is the exported member name
|
|
1136
|
-
isNpmPackage: false
|
|
1137
|
-
},
|
|
1138
|
-
[]
|
|
1139
|
-
);
|
|
1203
|
+
const availableContracts = manifest.contracts?.map((c2) => c2.name) || [];
|
|
1204
|
+
const dynamicPrefixes = manifest.dynamic_contracts ? (Array.isArray(manifest.dynamic_contracts) ? manifest.dynamic_contracts : [manifest.dynamic_contracts]).map((c2) => `${c2.prefix}/*`) : [];
|
|
1205
|
+
const allAvailable = [...availableContracts, ...dynamicPrefixes].join(", ");
|
|
1206
|
+
return new WithValidations(null, [
|
|
1207
|
+
`Contract "${contractName}" not found in local plugin "${pluginName}". Available: ${allAvailable}`
|
|
1208
|
+
]);
|
|
1140
1209
|
}
|
|
1141
1210
|
function resolveNpmPlugin(projectRoot, pluginName, contractName) {
|
|
1142
1211
|
let pluginYamlPath;
|
|
@@ -1161,65 +1230,88 @@ function resolveNpmPlugin(projectRoot, pluginName, contractName) {
|
|
|
1161
1230
|
`Failed to parse plugin.yaml for NPM package "${pluginName}" at ${pluginYamlPath}`
|
|
1162
1231
|
]);
|
|
1163
1232
|
}
|
|
1164
|
-
if (!manifest.contracts || manifest.contracts.length === 0) {
|
|
1165
|
-
return new WithValidations(null, [
|
|
1166
|
-
`NPM package "${pluginName}" has no contracts defined in plugin.yaml`
|
|
1167
|
-
]);
|
|
1168
|
-
}
|
|
1169
|
-
const contract = manifest.contracts.find((c2) => c2.name === contractName);
|
|
1170
|
-
if (!contract) {
|
|
1171
|
-
const availableContracts = manifest.contracts.map((c2) => c2.name).join(", ");
|
|
1172
|
-
return new WithValidations(null, [
|
|
1173
|
-
`Contract "${contractName}" not found in NPM package "${pluginName}". Available contracts: ${availableContracts}`
|
|
1174
|
-
]);
|
|
1175
|
-
}
|
|
1176
1233
|
const packageJsonPath = path.join(npmPluginPath, "package.json");
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
}
|
|
1189
|
-
componentPath = path.join(npmPluginPath, "dist/index.js");
|
|
1234
|
+
const getComponentPath = () => {
|
|
1235
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
1236
|
+
try {
|
|
1237
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
1238
|
+
const packageName = packageJson.name;
|
|
1239
|
+
const moduleName = manifest.module || packageName;
|
|
1240
|
+
if ((moduleName === packageName || !manifest.module) && packageJson.exports && packageJson.exports["."]) {
|
|
1241
|
+
const mainExport = packageJson.exports["."];
|
|
1242
|
+
const mainPath = typeof mainExport === "string" ? mainExport : mainExport.default || mainExport.import;
|
|
1243
|
+
return path.join(npmPluginPath, mainPath);
|
|
1244
|
+
}
|
|
1245
|
+
} catch {
|
|
1190
1246
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1247
|
+
}
|
|
1248
|
+
return path.join(npmPluginPath, "dist/index.js");
|
|
1249
|
+
};
|
|
1250
|
+
if (manifest.contracts && manifest.contracts.length > 0) {
|
|
1251
|
+
const contract = manifest.contracts.find((c2) => c2.name === contractName);
|
|
1252
|
+
if (contract) {
|
|
1253
|
+
const componentPath = getComponentPath();
|
|
1254
|
+
let contractPath;
|
|
1255
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
1256
|
+
try {
|
|
1257
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
1258
|
+
const contractSpec = contract.contract;
|
|
1259
|
+
const contractExportKey = "./" + contractSpec;
|
|
1260
|
+
if (packageJson.exports && packageJson.exports[contractExportKey]) {
|
|
1261
|
+
const exportPath = packageJson.exports[contractExportKey];
|
|
1262
|
+
contractPath = path.join(npmPluginPath, exportPath);
|
|
1263
|
+
} else {
|
|
1264
|
+
const possiblePaths = [
|
|
1265
|
+
path.join(npmPluginPath, "dist", contractSpec),
|
|
1266
|
+
path.join(npmPluginPath, "lib", contractSpec),
|
|
1267
|
+
path.join(npmPluginPath, contractSpec)
|
|
1268
|
+
];
|
|
1269
|
+
contractPath = possiblePaths.find((p) => fs.existsSync(p)) || possiblePaths[0];
|
|
1270
|
+
}
|
|
1271
|
+
} catch {
|
|
1272
|
+
contractPath = path.join(npmPluginPath, "dist", contract.contract);
|
|
1273
|
+
}
|
|
1196
1274
|
} else {
|
|
1197
|
-
|
|
1198
|
-
path.join(npmPluginPath, "dist", contractSpec),
|
|
1199
|
-
path.join(npmPluginPath, "lib", contractSpec),
|
|
1200
|
-
path.join(npmPluginPath, contractSpec)
|
|
1201
|
-
];
|
|
1202
|
-
contractPath = possiblePaths.find((p) => fs.existsSync(p)) || possiblePaths[0];
|
|
1275
|
+
contractPath = path.join(npmPluginPath, "dist", contract.contract);
|
|
1203
1276
|
}
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1277
|
+
return new WithValidations(
|
|
1278
|
+
{
|
|
1279
|
+
contractPath,
|
|
1280
|
+
componentPath,
|
|
1281
|
+
componentName: contract.component,
|
|
1282
|
+
isNpmPackage: true,
|
|
1283
|
+
packageName: pluginName
|
|
1284
|
+
},
|
|
1285
|
+
[]
|
|
1286
|
+
);
|
|
1207
1287
|
}
|
|
1208
|
-
} else {
|
|
1209
|
-
componentPath = path.join(npmPluginPath, "dist/index.js");
|
|
1210
|
-
contractPath = path.join(npmPluginPath, "dist", contract.contract);
|
|
1211
1288
|
}
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1289
|
+
const dynamicConfig = findDynamicContract(manifest, contractName);
|
|
1290
|
+
if (dynamicConfig) {
|
|
1291
|
+
const componentPath = getComponentPath();
|
|
1292
|
+
return new WithValidations(
|
|
1293
|
+
{
|
|
1294
|
+
contractPath: "",
|
|
1295
|
+
// Dynamic contracts don't have a static path
|
|
1296
|
+
componentPath,
|
|
1297
|
+
componentName: dynamicConfig.component,
|
|
1298
|
+
isNpmPackage: true,
|
|
1299
|
+
packageName: pluginName
|
|
1300
|
+
},
|
|
1301
|
+
[]
|
|
1302
|
+
);
|
|
1303
|
+
}
|
|
1304
|
+
if (!manifest.contracts && !manifest.dynamic_contracts) {
|
|
1305
|
+
return new WithValidations(null, [
|
|
1306
|
+
`NPM package "${pluginName}" has no contracts or dynamic_contracts defined in plugin.yaml`
|
|
1307
|
+
]);
|
|
1308
|
+
}
|
|
1309
|
+
const availableContracts = manifest.contracts?.map((c2) => c2.name) || [];
|
|
1310
|
+
const dynamicPrefixes = manifest.dynamic_contracts ? (Array.isArray(manifest.dynamic_contracts) ? manifest.dynamic_contracts : [manifest.dynamic_contracts]).map((c2) => `${c2.prefix}/*`) : [];
|
|
1311
|
+
const allAvailable = [...availableContracts, ...dynamicPrefixes].join(", ");
|
|
1312
|
+
return new WithValidations(null, [
|
|
1313
|
+
`Contract "${contractName}" not found in NPM package "${pluginName}". Available: ${allAvailable}`
|
|
1314
|
+
]);
|
|
1223
1315
|
}
|
|
1224
1316
|
function resolvePluginComponent(projectRoot, pluginName, contractName) {
|
|
1225
1317
|
const localResult = resolveLocalPlugin(projectRoot, pluginName, contractName);
|
|
@@ -1266,6 +1358,7 @@ export {
|
|
|
1266
1358
|
JAY_QUERY_WORKER_TRUSTED_TS,
|
|
1267
1359
|
JAY_RUNTIME,
|
|
1268
1360
|
JAY_SECURE,
|
|
1361
|
+
JAY_STACK_CLIENT_RUNTIME,
|
|
1269
1362
|
JAY_TS_EXTENSION,
|
|
1270
1363
|
JayArrayType,
|
|
1271
1364
|
JayAtomicType,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/compiler-shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
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.
|
|
29
|
-
"@jay-framework/runtime": "^0.
|
|
30
|
-
"@jay-framework/secure": "^0.
|
|
31
|
-
"@jay-framework/typescript-bridge": "^0.
|
|
28
|
+
"@jay-framework/component": "^0.12.0",
|
|
29
|
+
"@jay-framework/runtime": "^0.12.0",
|
|
30
|
+
"@jay-framework/secure": "^0.12.0",
|
|
31
|
+
"@jay-framework/typescript-bridge": "^0.7.0",
|
|
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.
|
|
44
|
+
"@jay-framework/dev-environment": "^0.12.0",
|
|
45
45
|
"@testing-library/jest-dom": "^6.2.0",
|
|
46
46
|
"@types/js-beautify": "^1",
|
|
47
47
|
"@types/node": "^20.11.5",
|