@jay-framework/compiler-shared 0.12.0 → 0.14.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 +174 -16
- package/dist/index.js +306 -23
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -71,6 +71,19 @@ declare const Import: {
|
|
|
71
71
|
injectHeadLinks: ImportName;
|
|
72
72
|
makeJayComponent: ImportName;
|
|
73
73
|
makeHeadlessInstanceComponent: ImportName;
|
|
74
|
+
HEADLESS_INSTANCES: ImportName;
|
|
75
|
+
useContext: ImportName;
|
|
76
|
+
currentConstructionContext: ImportName;
|
|
77
|
+
adoptText: ImportName;
|
|
78
|
+
adoptElement: ImportName;
|
|
79
|
+
childCompHydrate: ImportName;
|
|
80
|
+
hydrateConditional: ImportName;
|
|
81
|
+
hydrateForEach: ImportName;
|
|
82
|
+
adoptDynamicElement: ImportName;
|
|
83
|
+
STATIC: ImportName;
|
|
84
|
+
escapeHtml: ImportName;
|
|
85
|
+
escapeAttr: ImportName;
|
|
86
|
+
ServerRenderContext: ImportName;
|
|
74
87
|
};
|
|
75
88
|
declare class Imports {
|
|
76
89
|
private readonly imports;
|
|
@@ -87,15 +100,18 @@ declare class Imports {
|
|
|
87
100
|
declare const JAY_EXTENSION = ".jay-html";
|
|
88
101
|
declare const CSS_EXTENSION = ".css";
|
|
89
102
|
declare const JAY_CONTRACT_EXTENSION = ".jay-contract";
|
|
103
|
+
declare const JAY_ACTION_EXTENSION = ".jay-action";
|
|
90
104
|
declare const JAY_TS_EXTENSION = ".jay-html.ts";
|
|
91
105
|
declare const JAY_DTS_EXTENSION = ".jay-html.d.ts";
|
|
92
106
|
declare const JAY_CONTRACT_DTS_EXTENSION = ".jay-contract.d.ts";
|
|
107
|
+
declare const JAY_ACTION_DTS_EXTENSION = ".jay-action.d.ts";
|
|
93
108
|
declare const JAY_COMPONENT = "@jay-framework/component";
|
|
94
109
|
declare const JAY_SECURE = "@jay-framework/secure";
|
|
95
110
|
declare const JAY_RUNTIME = "@jay-framework/runtime";
|
|
96
111
|
declare const JAY_4_REACT = "@jay-framework/4-react";
|
|
97
112
|
declare const JAY_FULLSTACK_COMPONENTS = "@jay-framework/fullstack-component";
|
|
98
113
|
declare const JAY_STACK_CLIENT_RUNTIME = "@jay-framework/stack-client-runtime";
|
|
114
|
+
declare const JAY_SSR_RUNTIME = "@jay-framework/ssr-runtime";
|
|
99
115
|
declare const REACT = "react";
|
|
100
116
|
declare const MAKE_JAY_COMPONENT = "makeJayComponent";
|
|
101
117
|
declare const MAKE_JAY_TSX_COMPONENT = "makeJayTsxComponent";
|
|
@@ -114,7 +130,8 @@ declare enum JayTypeKind {
|
|
|
114
130
|
array = 9,
|
|
115
131
|
union = 10,
|
|
116
132
|
promise = 11,
|
|
117
|
-
recursive = 12
|
|
133
|
+
recursive = 12,
|
|
134
|
+
optional = 13
|
|
118
135
|
}
|
|
119
136
|
interface JayType {
|
|
120
137
|
name: string;
|
|
@@ -212,7 +229,14 @@ declare class JayRecursiveType implements JayType {
|
|
|
212
229
|
readonly kind = JayTypeKind.recursive;
|
|
213
230
|
get name(): string;
|
|
214
231
|
}
|
|
232
|
+
declare class JayOptionalType implements JayType {
|
|
233
|
+
readonly innerType: JayType;
|
|
234
|
+
constructor(innerType: JayType);
|
|
235
|
+
readonly kind = JayTypeKind.optional;
|
|
236
|
+
get name(): string;
|
|
237
|
+
}
|
|
215
238
|
declare const JayErrorType: JayObjectType;
|
|
239
|
+
declare function isOptionalType(aType: JayType): aType is JayOptionalType;
|
|
216
240
|
declare function isAtomicType(aType: JayType): aType is JayAtomicType;
|
|
217
241
|
declare function isTypeAliasType(aType: JayType): aType is JayTypeAlias;
|
|
218
242
|
declare function isEnumType(aType: JayType): aType is JayEnumType;
|
|
@@ -230,6 +254,29 @@ declare function isCurrencyType(aType: JayType): aType is JayAtomicType;
|
|
|
230
254
|
declare function isDateWithTimezoneType(aType: JayType): aType is JayAtomicType;
|
|
231
255
|
declare function equalJayTypes(a: JayType, b: JayType): any;
|
|
232
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Converts JayType trees to JSON Schema.
|
|
259
|
+
*
|
|
260
|
+
* Used by the runtime to convert parsed .jay-action files into JSON Schema
|
|
261
|
+
* for AI agent tool definitions (e.g., Gemini function declarations).
|
|
262
|
+
*/
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* JSON Schema property definition.
|
|
266
|
+
*/
|
|
267
|
+
interface JsonSchemaProperty {
|
|
268
|
+
type: string;
|
|
269
|
+
description?: string;
|
|
270
|
+
enum?: string[];
|
|
271
|
+
items?: JsonSchemaProperty;
|
|
272
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
273
|
+
required?: string[];
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Converts a JayType to a JSON Schema property.
|
|
277
|
+
*/
|
|
278
|
+
declare function jayTypeToJsonSchema(type: JayType): JsonSchemaProperty | null;
|
|
279
|
+
|
|
233
280
|
interface JayImportName {
|
|
234
281
|
name: string;
|
|
235
282
|
as?: string;
|
|
@@ -254,6 +301,7 @@ declare const JAY_QUERY_PREFIX = "?jay-";
|
|
|
254
301
|
declare const JAY_QUERY_MAIN_SANDBOX = "?jay-mainSandbox";
|
|
255
302
|
declare const JAY_QUERY_WORKER_TRUSTED = "?jay-workerTrusted";
|
|
256
303
|
declare const JAY_QUERY_WORKER_SANDBOX = "?jay-workerSandbox";
|
|
304
|
+
declare const JAY_QUERY_HYDRATE = "?jay-hydrate";
|
|
257
305
|
declare const JAY_QUERY_MAIN_SANDBOX_TS = "?jay-mainSandbox.ts";
|
|
258
306
|
declare const JAY_QUERY_WORKER_TRUSTED_TS = "?jay-workerTrusted.ts";
|
|
259
307
|
declare const JAY_QUERY_WORKER_SANDBOX_TS = "?jay-workerSandbox.ts";
|
|
@@ -308,6 +356,8 @@ interface ParsedJayModuleSpecifier {
|
|
|
308
356
|
buildEnvironment?: JayBuildEnvironment;
|
|
309
357
|
/** The runtime mode (sandbox modes) if present */
|
|
310
358
|
runtimeMode?: RuntimeMode;
|
|
359
|
+
/** Whether this is a hydrate target (?jay-hydrate) */
|
|
360
|
+
isHydrate?: boolean;
|
|
311
361
|
/** Any remaining query parameters (not jay-related) */
|
|
312
362
|
otherQueryParams: string;
|
|
313
363
|
/** The full query string for reconstruction */
|
|
@@ -477,6 +527,7 @@ declare function prettify(code: string, options?: prettier.Options): Promise<str
|
|
|
477
527
|
declare function prettifyHtml(html: string): string;
|
|
478
528
|
declare function removeComments(code: string): string;
|
|
479
529
|
|
|
530
|
+
declare const LOCAL_PLUGIN_PATH = "src/plugins";
|
|
480
531
|
/**
|
|
481
532
|
* Plugin initialization configuration.
|
|
482
533
|
*
|
|
@@ -510,6 +561,9 @@ interface PluginManifest {
|
|
|
510
561
|
name: string;
|
|
511
562
|
version?: string;
|
|
512
563
|
module?: string;
|
|
564
|
+
/** When true, this plugin is loaded on every page regardless of usage in jay-html.
|
|
565
|
+
* Useful for global tools like WebMCP, analytics, or dev tools. */
|
|
566
|
+
global?: boolean;
|
|
513
567
|
contracts?: Array<{
|
|
514
568
|
name: string;
|
|
515
569
|
contract: string;
|
|
@@ -517,8 +571,10 @@ interface PluginManifest {
|
|
|
517
571
|
description?: string;
|
|
518
572
|
}>;
|
|
519
573
|
dynamic_contracts?: DynamicContractConfig | DynamicContractConfig[];
|
|
520
|
-
/** Named exports from plugin backend bundle that are JayAction instances
|
|
521
|
-
|
|
574
|
+
/** Named exports from plugin backend bundle that are JayAction instances.
|
|
575
|
+
* Can be a string (export name, no metadata) or an object with a .jay-action file reference.
|
|
576
|
+
* Actions with .jay-action metadata are exposed to AI agents; those without are not. */
|
|
577
|
+
actions?: ActionManifestEntry[];
|
|
522
578
|
/** Plugin initialization configuration */
|
|
523
579
|
init?: PluginInitConfig;
|
|
524
580
|
/** Plugin setup configuration (Design Log #87) */
|
|
@@ -531,6 +587,23 @@ interface PluginManifest {
|
|
|
531
587
|
description?: string;
|
|
532
588
|
};
|
|
533
589
|
}
|
|
590
|
+
/**
|
|
591
|
+
* Action entry in plugin.yaml.
|
|
592
|
+
* - `string`: export name only, no metadata (not exposed to AI agents)
|
|
593
|
+
* - `{ name, action }`: export name + path to .jay-action metadata file
|
|
594
|
+
*/
|
|
595
|
+
type ActionManifestEntry = string | {
|
|
596
|
+
name: string;
|
|
597
|
+
action: string;
|
|
598
|
+
};
|
|
599
|
+
/**
|
|
600
|
+
* Normalizes an action manifest entry to { name, action? }.
|
|
601
|
+
* Strings become { name: string, action: undefined }.
|
|
602
|
+
*/
|
|
603
|
+
declare function normalizeActionEntry(entry: ActionManifestEntry): {
|
|
604
|
+
name: string;
|
|
605
|
+
action?: string;
|
|
606
|
+
};
|
|
534
607
|
/**
|
|
535
608
|
* Result of resolving a plugin component
|
|
536
609
|
*/
|
|
@@ -554,31 +627,116 @@ interface PluginComponentResolution {
|
|
|
554
627
|
*/
|
|
555
628
|
declare function loadPluginManifest(pluginDir: string): PluginManifest | null;
|
|
556
629
|
/**
|
|
557
|
-
*
|
|
630
|
+
* Finds a dynamic contract config that matches the given contract name.
|
|
631
|
+
* Dynamic contracts use a prefix format: "prefix/name" (e.g., "list/recipes-list")
|
|
558
632
|
*
|
|
559
|
-
* @param
|
|
560
|
-
* @param
|
|
561
|
-
* @
|
|
562
|
-
* @returns Resolution result with validation messages
|
|
633
|
+
* @param manifest - The plugin manifest
|
|
634
|
+
* @param contractName - The contract name to match (e.g., "list/recipes-list")
|
|
635
|
+
* @returns The matching DynamicContractConfig or null if not found
|
|
563
636
|
*/
|
|
564
|
-
declare function
|
|
637
|
+
declare function findDynamicContract(manifest: PluginManifest, contractName: string): DynamicContractConfig | null;
|
|
565
638
|
/**
|
|
566
|
-
* Resolves a plugin component
|
|
639
|
+
* Resolves a plugin component, trying local plugins first, then NPM packages
|
|
567
640
|
*
|
|
568
641
|
* @param projectRoot - Project root directory
|
|
569
|
-
* @param pluginName - Name of the
|
|
642
|
+
* @param pluginName - Name of the plugin
|
|
570
643
|
* @param contractName - Name of the contract to resolve
|
|
571
644
|
* @returns Resolution result with validation messages
|
|
572
645
|
*/
|
|
573
|
-
declare function
|
|
646
|
+
declare function resolvePluginComponent(projectRoot: string, pluginName: string, contractName: string): WithValidations<PluginComponentResolution>;
|
|
574
647
|
/**
|
|
575
|
-
* Resolves a plugin
|
|
648
|
+
* Resolves a plugin manifest from a local plugin or NPM package
|
|
576
649
|
*
|
|
577
650
|
* @param projectRoot - Project root directory
|
|
578
651
|
* @param pluginName - Name of the plugin
|
|
579
|
-
* @param contractName - Name of the contract to resolve
|
|
580
652
|
* @returns Resolution result with validation messages
|
|
581
653
|
*/
|
|
582
|
-
declare function
|
|
654
|
+
declare function resolvePluginManifest(projectRoot: string, pluginName: string): WithValidations<PluginManifest>;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Build-time utilities for coordinate template compilation.
|
|
658
|
+
*
|
|
659
|
+
* Coordinates may contain $placeholder segments (e.g. "0/$_id/1") that
|
|
660
|
+
* reference forEach trackBy variables. These utilities compile templates
|
|
661
|
+
* into JS string concatenation expressions — no runtime dependency.
|
|
662
|
+
*/
|
|
663
|
+
/**
|
|
664
|
+
* Compile a coordinate template with $placeholder syntax into a JS expression string.
|
|
665
|
+
*
|
|
666
|
+
* Static templates (no placeholders) return a quoted string literal.
|
|
667
|
+
* Dynamic templates compile to string concatenation expressions.
|
|
668
|
+
*
|
|
669
|
+
* @param template - Coordinate template, e.g. "0/$_id/1" or "product-card:0/0"
|
|
670
|
+
* @param varMappings - Maps placeholder names to JS expressions, e.g. { _id: "vs1._id" }
|
|
671
|
+
* @returns A JS expression string that evaluates to the final coordinate value
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* // Static (no placeholders):
|
|
675
|
+
* compileCoordinateExpr("product-card:0/0", {})
|
|
676
|
+
* // → "'product-card:0/0'"
|
|
677
|
+
*
|
|
678
|
+
* // Dynamic (with placeholder):
|
|
679
|
+
* compileCoordinateExpr("0/$_id/1", { _id: "vs1._id" })
|
|
680
|
+
* // → "'0/' + escapeAttr(String(vs1._id)) + '/1'"
|
|
681
|
+
*
|
|
682
|
+
* // Placeholder at start:
|
|
683
|
+
* compileCoordinateExpr("$_id/product-card:0/0", { _id: "vs1._id" })
|
|
684
|
+
* // → "escapeAttr(String(vs1._id)) + '/product-card:0/0'"
|
|
685
|
+
*/
|
|
686
|
+
declare function compileCoordinateExpr(template: string, varMappings: Record<string, string>): string;
|
|
687
|
+
/**
|
|
688
|
+
* Check if a coordinate template contains dynamic placeholders.
|
|
689
|
+
*/
|
|
690
|
+
declare function isStaticCoordinate(template: string): boolean;
|
|
691
|
+
/**
|
|
692
|
+
* Compute the `__headlessInstances` key for a headless instance.
|
|
693
|
+
*
|
|
694
|
+
* The key format differs by context:
|
|
695
|
+
* - **Static**: `"product-card:0"` (just the coordinate suffix)
|
|
696
|
+
* - **forEach**: `"trackByValue,product-card:0"` (comma-separated, matching Array.toString())
|
|
697
|
+
* - **slowForEach**: `"p1/product-card:0"` (slash-separated, same as DOM coordinate)
|
|
698
|
+
*
|
|
699
|
+
* This function is used by both:
|
|
700
|
+
* - Server runtime (dev-server) when storing data in `__headlessInstances`
|
|
701
|
+
* - Client compiler when generating the key lookup in `makeHeadlessInstanceComponent`
|
|
702
|
+
*
|
|
703
|
+
* @param coordinateSuffix - The instance's coordinate suffix, e.g. "product-card:0"
|
|
704
|
+
* @param context - The context in which the instance appears
|
|
705
|
+
* @param prefix - For slowForEach: the jayTrackBy value (e.g. "p1").
|
|
706
|
+
* For forEach: not used (key is computed at runtime from trackBy values).
|
|
707
|
+
* @returns For static/slowForEach: a literal key string.
|
|
708
|
+
* For forEach: undefined (key must be computed at runtime).
|
|
709
|
+
*/
|
|
710
|
+
declare function computeInstanceKey(coordinateSuffix: string, context: 'static' | 'forEach' | 'slowForEach', prefix?: string): string | undefined;
|
|
711
|
+
/**
|
|
712
|
+
* Compile a forEach instance key expression for generated code.
|
|
713
|
+
*
|
|
714
|
+
* For the server target, produces a JS expression that computes the key
|
|
715
|
+
* at runtime using the trackBy variable.
|
|
716
|
+
*
|
|
717
|
+
* For the client target (hydrate adopt path), the key is computed by
|
|
718
|
+
* `(dataIds) => dataIds.join(',')` — the coordinateBase already includes
|
|
719
|
+
* the suffix via `childCompHydrate`'s `forInstance` call.
|
|
720
|
+
*
|
|
721
|
+
* @param coordinateSuffix - e.g. "product-card:0"
|
|
722
|
+
* @param trackByExpr - JS expression for the trackBy value, e.g. "vs1._id"
|
|
723
|
+
* @returns A JS expression string that evaluates to the key
|
|
724
|
+
*
|
|
725
|
+
* @example
|
|
726
|
+
* compileForEachInstanceKeyExpr("product-card:0", "vs1._id")
|
|
727
|
+
* // → "String(vs1._id) + ',product-card:0'"
|
|
728
|
+
*/
|
|
729
|
+
declare function compileForEachInstanceKeyExpr(coordinateSuffix: string, trackByExpr: string): string;
|
|
730
|
+
/**
|
|
731
|
+
* Runtime computation of a forEach instance key.
|
|
732
|
+
*
|
|
733
|
+
* Used by the dev server when storing data in `__headlessInstances`.
|
|
734
|
+
* Produces the same format as `compileForEachInstanceKeyExpr` generates
|
|
735
|
+
* at compile time: `"trackByValue,coordinateSuffix"`.
|
|
736
|
+
*
|
|
737
|
+
* @param trackByValue - The resolved trackBy value for the current item
|
|
738
|
+
* @param coordinateSuffix - e.g. "product-card:0"
|
|
739
|
+
*/
|
|
740
|
+
declare function computeForEachInstanceKey(trackByValue: string, coordinateSuffix: string): string;
|
|
583
741
|
|
|
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,
|
|
742
|
+
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, JayHTMLType, type JayImportLink, type JayImportName, JayImportedType, JayNumber, JayObjectType, JayOptionalType, JayPromiseType, 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, computeInstanceKey, equalJayTypes, findDynamicContract, getBasePath, getBuildEnvironment, getJayTsFileSourcePath, getMode, getModeFileExtension, getModeFromExtension, hasBuildEnvironment, hasExtension, hasJayExtension, hasJayModeExtension, hasRefs, isArrayType, isAtomicType, isComponentType, isCurrencyType, isDateWithTimezoneType, isElementConstructorType, isElementType, isEnumType, isHTMLType, isImportedType, isLocalModule, isObjectType, isOptionalType, isPromiseType, isRecursiveType, isStaticCoordinate, isTypeAliasType, isUnionType, jayTypeToJsonSchema, loadPluginManifest, mergeRefsTrees, mkRef, mkRefsTree, nestRefs, normalizeActionEntry, parseJayModuleSpecifier, prettify, prettifyHtml, removeComments, resolvePluginComponent, resolvePluginManifest, resolvePrimitiveType, withOriginalTrace, withoutExtension };
|
package/dist/index.js
CHANGED
|
@@ -13,15 +13,18 @@ import { createRequire } from "module";
|
|
|
13
13
|
const JAY_EXTENSION = ".jay-html";
|
|
14
14
|
const CSS_EXTENSION = ".css";
|
|
15
15
|
const JAY_CONTRACT_EXTENSION = ".jay-contract";
|
|
16
|
+
const JAY_ACTION_EXTENSION = ".jay-action";
|
|
16
17
|
const JAY_TS_EXTENSION = ".jay-html.ts";
|
|
17
18
|
const JAY_DTS_EXTENSION = ".jay-html.d.ts";
|
|
18
19
|
const JAY_CONTRACT_DTS_EXTENSION = ".jay-contract.d.ts";
|
|
20
|
+
const JAY_ACTION_DTS_EXTENSION = ".jay-action.d.ts";
|
|
19
21
|
const JAY_COMPONENT = "@jay-framework/component";
|
|
20
22
|
const JAY_SECURE = "@jay-framework/secure";
|
|
21
23
|
const JAY_RUNTIME = "@jay-framework/runtime";
|
|
22
24
|
const JAY_4_REACT = "@jay-framework/4-react";
|
|
23
25
|
const JAY_FULLSTACK_COMPONENTS = "@jay-framework/fullstack-component";
|
|
24
26
|
const JAY_STACK_CLIENT_RUNTIME = "@jay-framework/stack-client-runtime";
|
|
27
|
+
const JAY_SSR_RUNTIME = "@jay-framework/ssr-runtime";
|
|
25
28
|
const REACT = "react";
|
|
26
29
|
const MAKE_JAY_COMPONENT = "makeJayComponent";
|
|
27
30
|
const MAKE_JAY_TSX_COMPONENT = "makeJayTsxComponent";
|
|
@@ -413,6 +416,84 @@ const Import = {
|
|
|
413
416
|
"makeHeadlessInstanceComponent",
|
|
414
417
|
1
|
|
415
418
|
/* implementation */
|
|
419
|
+
),
|
|
420
|
+
HEADLESS_INSTANCES: importStatementFragment(
|
|
421
|
+
JAY_STACK_CLIENT_RUNTIME,
|
|
422
|
+
"HEADLESS_INSTANCES",
|
|
423
|
+
1
|
|
424
|
+
/* implementation */
|
|
425
|
+
),
|
|
426
|
+
useContext: importStatementFragment(
|
|
427
|
+
JAY_RUNTIME,
|
|
428
|
+
"useContext",
|
|
429
|
+
1
|
|
430
|
+
/* implementation */
|
|
431
|
+
),
|
|
432
|
+
currentConstructionContext: importStatementFragment(
|
|
433
|
+
JAY_RUNTIME,
|
|
434
|
+
"currentConstructionContext",
|
|
435
|
+
1
|
|
436
|
+
/* implementation */
|
|
437
|
+
),
|
|
438
|
+
adoptText: importStatementFragment(
|
|
439
|
+
JAY_RUNTIME,
|
|
440
|
+
"adoptText",
|
|
441
|
+
1
|
|
442
|
+
/* implementation */
|
|
443
|
+
),
|
|
444
|
+
adoptElement: importStatementFragment(
|
|
445
|
+
JAY_RUNTIME,
|
|
446
|
+
"adoptElement",
|
|
447
|
+
1
|
|
448
|
+
/* implementation */
|
|
449
|
+
),
|
|
450
|
+
childCompHydrate: importStatementFragment(
|
|
451
|
+
JAY_RUNTIME,
|
|
452
|
+
"childCompHydrate",
|
|
453
|
+
1
|
|
454
|
+
/* implementation */
|
|
455
|
+
),
|
|
456
|
+
hydrateConditional: importStatementFragment(
|
|
457
|
+
JAY_RUNTIME,
|
|
458
|
+
"hydrateConditional",
|
|
459
|
+
1
|
|
460
|
+
/* implementation */
|
|
461
|
+
),
|
|
462
|
+
hydrateForEach: importStatementFragment(
|
|
463
|
+
JAY_RUNTIME,
|
|
464
|
+
"hydrateForEach",
|
|
465
|
+
1
|
|
466
|
+
/* implementation */
|
|
467
|
+
),
|
|
468
|
+
adoptDynamicElement: importStatementFragment(
|
|
469
|
+
JAY_RUNTIME,
|
|
470
|
+
"adoptDynamicElement",
|
|
471
|
+
1
|
|
472
|
+
/* implementation */
|
|
473
|
+
),
|
|
474
|
+
STATIC: importStatementFragment(
|
|
475
|
+
JAY_RUNTIME,
|
|
476
|
+
"STATIC",
|
|
477
|
+
1
|
|
478
|
+
/* implementation */
|
|
479
|
+
),
|
|
480
|
+
escapeHtml: importStatementFragment(
|
|
481
|
+
JAY_SSR_RUNTIME,
|
|
482
|
+
"escapeHtml",
|
|
483
|
+
1
|
|
484
|
+
/* implementation */
|
|
485
|
+
),
|
|
486
|
+
escapeAttr: importStatementFragment(
|
|
487
|
+
JAY_SSR_RUNTIME,
|
|
488
|
+
"escapeAttr",
|
|
489
|
+
1
|
|
490
|
+
/* implementation */
|
|
491
|
+
),
|
|
492
|
+
ServerRenderContext: importStatementFragment(
|
|
493
|
+
JAY_SSR_RUNTIME,
|
|
494
|
+
"type ServerRenderContext",
|
|
495
|
+
1
|
|
496
|
+
/* implementation */
|
|
416
497
|
)
|
|
417
498
|
};
|
|
418
499
|
class Imports {
|
|
@@ -493,6 +574,7 @@ var JayTypeKind = /* @__PURE__ */ ((JayTypeKind2) => {
|
|
|
493
574
|
JayTypeKind2[JayTypeKind2["union"] = 10] = "union";
|
|
494
575
|
JayTypeKind2[JayTypeKind2["promise"] = 11] = "promise";
|
|
495
576
|
JayTypeKind2[JayTypeKind2["recursive"] = 12] = "recursive";
|
|
577
|
+
JayTypeKind2[JayTypeKind2["optional"] = 13] = "optional";
|
|
496
578
|
return JayTypeKind2;
|
|
497
579
|
})(JayTypeKind || {});
|
|
498
580
|
class JayAtomicType {
|
|
@@ -615,11 +697,23 @@ class JayRecursiveType {
|
|
|
615
697
|
return this.resolvedType?.name || `Recursive<${this.referencePath}>`;
|
|
616
698
|
}
|
|
617
699
|
}
|
|
700
|
+
class JayOptionalType {
|
|
701
|
+
constructor(innerType) {
|
|
702
|
+
__publicField(this, "kind", 13);
|
|
703
|
+
this.innerType = innerType;
|
|
704
|
+
}
|
|
705
|
+
get name() {
|
|
706
|
+
return `${this.innerType.name}?`;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
618
709
|
const JayErrorType = new JayObjectType("Error", {
|
|
619
710
|
message: new JayAtomicType("string"),
|
|
620
711
|
name: new JayAtomicType("string"),
|
|
621
712
|
stack: new JayAtomicType("string")
|
|
622
713
|
});
|
|
714
|
+
function isOptionalType(aType) {
|
|
715
|
+
return aType.kind === 13;
|
|
716
|
+
}
|
|
623
717
|
function isAtomicType(aType) {
|
|
624
718
|
return aType.kind === 0;
|
|
625
719
|
}
|
|
@@ -695,7 +789,9 @@ function equalJayTypes(a, b) {
|
|
|
695
789
|
else if (a instanceof JayObjectType && b instanceof JayObjectType) {
|
|
696
790
|
const aProps = new Set(Object.keys(a.props));
|
|
697
791
|
const bProps = new Set(Object.keys(b.props));
|
|
698
|
-
return aProps.size === bProps.size && [...aProps].
|
|
792
|
+
return aProps.size === bProps.size && [...aProps].every(
|
|
793
|
+
(aProp) => bProps.has(aProp) && equalJayTypes(a.props[aProp], b.props[aProp])
|
|
794
|
+
);
|
|
699
795
|
} else if (a instanceof JayUnionType && b instanceof JayUnionType) {
|
|
700
796
|
return a.ofTypes.length === b.ofTypes.length && a.ofTypes.reduce((res, aType) => res && b.hasType(aType), true);
|
|
701
797
|
} else if (a instanceof JayPromiseType && b instanceof JayPromiseType) {
|
|
@@ -705,6 +801,51 @@ function equalJayTypes(a, b) {
|
|
|
705
801
|
} else
|
|
706
802
|
;
|
|
707
803
|
}
|
|
804
|
+
function jayTypeToJsonSchema(type) {
|
|
805
|
+
if (isOptionalType(type)) {
|
|
806
|
+
return jayTypeToJsonSchema(type.innerType);
|
|
807
|
+
}
|
|
808
|
+
if (isAtomicType(type)) {
|
|
809
|
+
const name = type.name.toLowerCase();
|
|
810
|
+
if (name === "string" || name === "number" || name === "boolean") {
|
|
811
|
+
return { type: name };
|
|
812
|
+
}
|
|
813
|
+
return { type: "string" };
|
|
814
|
+
}
|
|
815
|
+
if (isEnumType(type)) {
|
|
816
|
+
return { type: "string", enum: type.values };
|
|
817
|
+
}
|
|
818
|
+
if (isImportedType(type)) {
|
|
819
|
+
return { type: "object", description: `Contract: ${type.name}` };
|
|
820
|
+
}
|
|
821
|
+
if (isArrayType(type)) {
|
|
822
|
+
const itemSchema = jayTypeToJsonSchema(type.itemType);
|
|
823
|
+
if (itemSchema) {
|
|
824
|
+
return { type: "array", items: itemSchema };
|
|
825
|
+
}
|
|
826
|
+
return { type: "array" };
|
|
827
|
+
}
|
|
828
|
+
if (isObjectType(type)) {
|
|
829
|
+
const properties = {};
|
|
830
|
+
const required = [];
|
|
831
|
+
for (const [key, propType] of Object.entries(type.props)) {
|
|
832
|
+
const isOpt = isOptionalType(propType);
|
|
833
|
+
const schema = jayTypeToJsonSchema(propType);
|
|
834
|
+
if (schema) {
|
|
835
|
+
properties[key] = schema;
|
|
836
|
+
if (!isOpt) {
|
|
837
|
+
required.push(key);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
return {
|
|
842
|
+
type: "object",
|
|
843
|
+
properties,
|
|
844
|
+
...required.length > 0 && { required }
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
return null;
|
|
848
|
+
}
|
|
708
849
|
var RuntimeMode = /* @__PURE__ */ ((RuntimeMode2) => {
|
|
709
850
|
RuntimeMode2["MainTrusted"] = "mainTrusted";
|
|
710
851
|
RuntimeMode2["MainSandbox"] = "mainSandbox";
|
|
@@ -718,6 +859,7 @@ const JAY_QUERY_PREFIX = "?jay-";
|
|
|
718
859
|
const JAY_QUERY_MAIN_SANDBOX = `${JAY_QUERY_PREFIX}${"mainSandbox"}`;
|
|
719
860
|
const JAY_QUERY_WORKER_TRUSTED = `${JAY_QUERY_PREFIX}${"workerTrusted"}`;
|
|
720
861
|
const JAY_QUERY_WORKER_SANDBOX = `${JAY_QUERY_PREFIX}${"workerSandbox"}`;
|
|
862
|
+
const JAY_QUERY_HYDRATE = `${JAY_QUERY_PREFIX}hydrate`;
|
|
721
863
|
const JAY_QUERY_MAIN_SANDBOX_TS = `${JAY_QUERY_PREFIX}${"mainSandbox"}${TS_EXTENSION}`;
|
|
722
864
|
const JAY_QUERY_WORKER_TRUSTED_TS = `${JAY_QUERY_PREFIX}${"workerTrusted"}${TS_EXTENSION}`;
|
|
723
865
|
const JAY_QUERY_WORKER_SANDBOX_TS = `${JAY_QUERY_PREFIX}${"workerSandbox"}${TS_EXTENSION}`;
|
|
@@ -780,6 +922,12 @@ var JayBuildEnvironment = /* @__PURE__ */ ((JayBuildEnvironment2) => {
|
|
|
780
922
|
const JAY_QUERY_CLIENT = `${JAY_QUERY_PREFIX}${"client"}`;
|
|
781
923
|
const JAY_QUERY_SERVER = `${JAY_QUERY_PREFIX}${"server"}`;
|
|
782
924
|
const JAY_QUERY_PATTERNS = [
|
|
925
|
+
// Hydrate target
|
|
926
|
+
{
|
|
927
|
+
pattern: JAY_QUERY_HYDRATE,
|
|
928
|
+
buildEnv: "client",
|
|
929
|
+
isHydrate: true
|
|
930
|
+
},
|
|
783
931
|
// Build environments
|
|
784
932
|
{
|
|
785
933
|
pattern: `${JAY_QUERY_PREFIX}${"client"}`,
|
|
@@ -831,13 +979,21 @@ function parseJayModuleSpecifier(specifier) {
|
|
|
831
979
|
const fullQueryString = specifier.substring(queryIndex);
|
|
832
980
|
let buildEnvironment;
|
|
833
981
|
let runtimeMode;
|
|
982
|
+
let isHydrate;
|
|
834
983
|
let remainingQuery = fullQueryString;
|
|
835
|
-
for (const {
|
|
984
|
+
for (const {
|
|
985
|
+
pattern,
|
|
986
|
+
buildEnv,
|
|
987
|
+
runtimeMode: rtMode,
|
|
988
|
+
isHydrate: hydrate
|
|
989
|
+
} of JAY_QUERY_PATTERNS) {
|
|
836
990
|
if (remainingQuery.includes(pattern)) {
|
|
837
991
|
if (buildEnv)
|
|
838
992
|
buildEnvironment = buildEnv;
|
|
839
993
|
if (rtMode)
|
|
840
994
|
runtimeMode = rtMode;
|
|
995
|
+
if (hydrate)
|
|
996
|
+
isHydrate = true;
|
|
841
997
|
remainingQuery = remainingQuery.replace(pattern, "");
|
|
842
998
|
}
|
|
843
999
|
}
|
|
@@ -846,6 +1002,7 @@ function parseJayModuleSpecifier(specifier) {
|
|
|
846
1002
|
basePath,
|
|
847
1003
|
buildEnvironment,
|
|
848
1004
|
runtimeMode,
|
|
1005
|
+
isHydrate,
|
|
849
1006
|
otherQueryParams,
|
|
850
1007
|
fullQueryString
|
|
851
1008
|
};
|
|
@@ -907,13 +1064,13 @@ class WithValidations {
|
|
|
907
1064
|
this.validations = validations;
|
|
908
1065
|
}
|
|
909
1066
|
map(func) {
|
|
910
|
-
if (this.val)
|
|
1067
|
+
if (this.val !== void 0)
|
|
911
1068
|
return new WithValidations(func(this.val), this.validations);
|
|
912
1069
|
else
|
|
913
1070
|
return new WithValidations(void 0, this.validations);
|
|
914
1071
|
}
|
|
915
1072
|
async mapAsync(func) {
|
|
916
|
-
if (this.val) {
|
|
1073
|
+
if (this.val !== void 0) {
|
|
917
1074
|
const result = await func(this.val);
|
|
918
1075
|
return new WithValidations(result, this.validations);
|
|
919
1076
|
} else {
|
|
@@ -921,14 +1078,14 @@ class WithValidations {
|
|
|
921
1078
|
}
|
|
922
1079
|
}
|
|
923
1080
|
flatMap(func) {
|
|
924
|
-
if (this.val) {
|
|
1081
|
+
if (this.val !== void 0) {
|
|
925
1082
|
let that = func(this.val);
|
|
926
1083
|
return new WithValidations(that.val, [...this.validations, ...that.validations]);
|
|
927
1084
|
} else
|
|
928
1085
|
return new WithValidations(void 0, this.validations);
|
|
929
1086
|
}
|
|
930
1087
|
async flatMapAsync(func) {
|
|
931
|
-
if (this.val) {
|
|
1088
|
+
if (this.val !== void 0) {
|
|
932
1089
|
const result = await func(this.val);
|
|
933
1090
|
return new WithValidations(result.val, [...this.validations, ...result.validations]);
|
|
934
1091
|
} else {
|
|
@@ -1125,6 +1282,13 @@ function removeComments(code) {
|
|
|
1125
1282
|
).join("\n");
|
|
1126
1283
|
}
|
|
1127
1284
|
const require2 = createRequire(import.meta.url);
|
|
1285
|
+
const LOCAL_PLUGIN_PATH = "src/plugins";
|
|
1286
|
+
function normalizeActionEntry(entry) {
|
|
1287
|
+
if (typeof entry === "string") {
|
|
1288
|
+
return { name: entry };
|
|
1289
|
+
}
|
|
1290
|
+
return { name: entry.name, action: entry.action };
|
|
1291
|
+
}
|
|
1128
1292
|
function loadPluginManifest(pluginDir) {
|
|
1129
1293
|
const pluginYamlPath = path.join(pluginDir, "plugin.yaml");
|
|
1130
1294
|
if (!fs.existsSync(pluginYamlPath)) {
|
|
@@ -1149,8 +1313,8 @@ function findDynamicContract(manifest, contractName) {
|
|
|
1149
1313
|
const dynamicConfigs = Array.isArray(manifest.dynamic_contracts) ? manifest.dynamic_contracts : [manifest.dynamic_contracts];
|
|
1150
1314
|
return dynamicConfigs.find((config) => config.prefix === prefix) || null;
|
|
1151
1315
|
}
|
|
1152
|
-
function
|
|
1153
|
-
const localPluginPath = path.join(projectRoot,
|
|
1316
|
+
function resolveLocalPluginManifest(projectRoot, pluginName) {
|
|
1317
|
+
const localPluginPath = path.join(projectRoot, LOCAL_PLUGIN_PATH, pluginName);
|
|
1154
1318
|
const pluginYamlPath = path.join(localPluginPath, "plugin.yaml");
|
|
1155
1319
|
if (!fs.existsSync(localPluginPath)) {
|
|
1156
1320
|
return null;
|
|
@@ -1166,7 +1330,23 @@ function resolveLocalPlugin(projectRoot, pluginName, contractName) {
|
|
|
1166
1330
|
`Failed to parse plugin.yaml for local plugin "${pluginName}" at ${pluginYamlPath}`
|
|
1167
1331
|
]);
|
|
1168
1332
|
}
|
|
1333
|
+
if (!manifest.contracts && !manifest.dynamic_contracts) {
|
|
1334
|
+
return new WithValidations(null, [
|
|
1335
|
+
`Local plugin "${pluginName}" has no contracts or dynamic_contracts defined in plugin.yaml`
|
|
1336
|
+
]);
|
|
1337
|
+
}
|
|
1338
|
+
return new WithValidations(manifest, []);
|
|
1339
|
+
}
|
|
1340
|
+
function resolveLocalPlugin(projectRoot, pluginName, contractName) {
|
|
1341
|
+
const manifestWithValidations = resolveLocalPluginManifest(projectRoot, pluginName);
|
|
1342
|
+
if (!manifestWithValidations) {
|
|
1343
|
+
return null;
|
|
1344
|
+
}
|
|
1345
|
+
if (!manifestWithValidations.val || manifestWithValidations.validations.length > 0)
|
|
1346
|
+
return new WithValidations(null, manifestWithValidations.validations);
|
|
1347
|
+
const manifest = manifestWithValidations.val;
|
|
1169
1348
|
const componentModule = manifest.module || "index.js";
|
|
1349
|
+
const localPluginPath = path.join(projectRoot, LOCAL_PLUGIN_PATH, pluginName);
|
|
1170
1350
|
const componentPath = path.join(localPluginPath, componentModule);
|
|
1171
1351
|
if (manifest.contracts && manifest.contracts.length > 0) {
|
|
1172
1352
|
const contract = manifest.contracts.find((c2) => c2.name === contractName);
|
|
@@ -1195,11 +1375,6 @@ function resolveLocalPlugin(projectRoot, pluginName, contractName) {
|
|
|
1195
1375
|
[]
|
|
1196
1376
|
);
|
|
1197
1377
|
}
|
|
1198
|
-
if (!manifest.contracts && !manifest.dynamic_contracts) {
|
|
1199
|
-
return new WithValidations(null, [
|
|
1200
|
-
`Local plugin "${pluginName}" has no contracts or dynamic_contracts defined in plugin.yaml`
|
|
1201
|
-
]);
|
|
1202
|
-
}
|
|
1203
1378
|
const availableContracts = manifest.contracts?.map((c2) => c2.name) || [];
|
|
1204
1379
|
const dynamicPrefixes = manifest.dynamic_contracts ? (Array.isArray(manifest.dynamic_contracts) ? manifest.dynamic_contracts : [manifest.dynamic_contracts]).map((c2) => `${c2.prefix}/*`) : [];
|
|
1205
1380
|
const allAvailable = [...availableContracts, ...dynamicPrefixes].join(", ");
|
|
@@ -1207,7 +1382,7 @@ function resolveLocalPlugin(projectRoot, pluginName, contractName) {
|
|
|
1207
1382
|
`Contract "${contractName}" not found in local plugin "${pluginName}". Available: ${allAvailable}`
|
|
1208
1383
|
]);
|
|
1209
1384
|
}
|
|
1210
|
-
function
|
|
1385
|
+
function resolveNpmPluginManifest(projectRoot, pluginName) {
|
|
1211
1386
|
let pluginYamlPath;
|
|
1212
1387
|
try {
|
|
1213
1388
|
pluginYamlPath = require2.resolve(`${pluginName}/plugin.yaml`, {
|
|
@@ -1230,6 +1405,25 @@ function resolveNpmPlugin(projectRoot, pluginName, contractName) {
|
|
|
1230
1405
|
`Failed to parse plugin.yaml for NPM package "${pluginName}" at ${pluginYamlPath}`
|
|
1231
1406
|
]);
|
|
1232
1407
|
}
|
|
1408
|
+
if (!manifest.contracts && !manifest.dynamic_contracts) {
|
|
1409
|
+
return new WithValidations(null, [
|
|
1410
|
+
`NPM package "${pluginName}" has no contracts or dynamic_contracts defined in plugin.yaml`
|
|
1411
|
+
]);
|
|
1412
|
+
}
|
|
1413
|
+
return new WithValidations(manifest, []);
|
|
1414
|
+
}
|
|
1415
|
+
function resolveNpmPlugin(projectRoot, pluginName, contractName) {
|
|
1416
|
+
const manifestWithValidations = resolveNpmPluginManifest(projectRoot, pluginName);
|
|
1417
|
+
if (!manifestWithValidations) {
|
|
1418
|
+
return null;
|
|
1419
|
+
}
|
|
1420
|
+
if (!manifestWithValidations.val || manifestWithValidations.validations.length > 0)
|
|
1421
|
+
return new WithValidations(null, manifestWithValidations.validations);
|
|
1422
|
+
const manifest = manifestWithValidations.val;
|
|
1423
|
+
const pluginYamlPath = require2.resolve(`${pluginName}/plugin.yaml`, {
|
|
1424
|
+
paths: [projectRoot]
|
|
1425
|
+
});
|
|
1426
|
+
const npmPluginPath = path.dirname(pluginYamlPath);
|
|
1233
1427
|
const packageJsonPath = path.join(npmPluginPath, "package.json");
|
|
1234
1428
|
const getComponentPath = () => {
|
|
1235
1429
|
if (fs.existsSync(packageJsonPath)) {
|
|
@@ -1301,11 +1495,6 @@ function resolveNpmPlugin(projectRoot, pluginName, contractName) {
|
|
|
1301
1495
|
[]
|
|
1302
1496
|
);
|
|
1303
1497
|
}
|
|
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
1498
|
const availableContracts = manifest.contracts?.map((c2) => c2.name) || [];
|
|
1310
1499
|
const dynamicPrefixes = manifest.dynamic_contracts ? (Array.isArray(manifest.dynamic_contracts) ? manifest.dynamic_contracts : [manifest.dynamic_contracts]).map((c2) => `${c2.prefix}/*`) : [];
|
|
1311
1500
|
const allAvailable = [...availableContracts, ...dynamicPrefixes].join(", ");
|
|
@@ -1315,17 +1504,97 @@ function resolveNpmPlugin(projectRoot, pluginName, contractName) {
|
|
|
1315
1504
|
}
|
|
1316
1505
|
function resolvePluginComponent(projectRoot, pluginName, contractName) {
|
|
1317
1506
|
const localResult = resolveLocalPlugin(projectRoot, pluginName, contractName);
|
|
1318
|
-
if (localResult !== null) {
|
|
1507
|
+
if (localResult && localResult.val !== null && localResult.validations.length === 0) {
|
|
1319
1508
|
return localResult;
|
|
1320
1509
|
}
|
|
1321
1510
|
const npmResult = resolveNpmPlugin(projectRoot, pluginName, contractName);
|
|
1322
|
-
if (npmResult !== null) {
|
|
1511
|
+
if (npmResult && npmResult.val !== null && npmResult.validations.length === 0) {
|
|
1512
|
+
return npmResult;
|
|
1513
|
+
}
|
|
1514
|
+
if (localResult && localResult.validations.length > 0) {
|
|
1515
|
+
return localResult;
|
|
1516
|
+
}
|
|
1517
|
+
if (npmResult && npmResult.validations.length > 0 && localResult === null) {
|
|
1518
|
+
const npmError = npmResult.validations[0];
|
|
1519
|
+
const isGenericPackageNotFound = npmError.startsWith("NPM package") && npmError.includes("not found") || npmError.startsWith("Plugin") && npmError.includes("not found");
|
|
1520
|
+
if (!isGenericPackageNotFound) {
|
|
1521
|
+
return npmResult;
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
return new WithValidations(null, [
|
|
1525
|
+
`Plugin "${pluginName}" not found. Searched in src/plugins/${pluginName}/ and node_modules/${pluginName}/. Ensure the plugin is installed or exists in your project.`
|
|
1526
|
+
]);
|
|
1527
|
+
}
|
|
1528
|
+
function resolvePluginManifest(projectRoot, pluginName) {
|
|
1529
|
+
const localResult = resolveLocalPluginManifest(projectRoot, pluginName);
|
|
1530
|
+
if (localResult && localResult.val !== null && localResult.validations.length === 0) {
|
|
1531
|
+
return localResult;
|
|
1532
|
+
}
|
|
1533
|
+
const npmResult = resolveNpmPluginManifest(projectRoot, pluginName);
|
|
1534
|
+
if (npmResult && npmResult.val !== null && npmResult.validations.length === 0) {
|
|
1323
1535
|
return npmResult;
|
|
1324
1536
|
}
|
|
1537
|
+
if (localResult && localResult.validations.length > 0) {
|
|
1538
|
+
return localResult;
|
|
1539
|
+
}
|
|
1540
|
+
if (npmResult && npmResult.validations.length > 0 && localResult === null) {
|
|
1541
|
+
const npmError = npmResult.validations[0];
|
|
1542
|
+
const isGenericPackageNotFound = npmError.startsWith("NPM package") && npmError.includes("not found") || npmError.startsWith("Plugin") && npmError.includes("not found");
|
|
1543
|
+
if (!isGenericPackageNotFound) {
|
|
1544
|
+
return npmResult;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1325
1547
|
return new WithValidations(null, [
|
|
1326
1548
|
`Plugin "${pluginName}" not found. Searched in src/plugins/${pluginName}/ and node_modules/${pluginName}/. Ensure the plugin is installed or exists in your project.`
|
|
1327
1549
|
]);
|
|
1328
1550
|
}
|
|
1551
|
+
function compileCoordinateExpr(template, varMappings) {
|
|
1552
|
+
if (!template.includes("$")) {
|
|
1553
|
+
return `'${template}'`;
|
|
1554
|
+
}
|
|
1555
|
+
const parts = [];
|
|
1556
|
+
let remaining = template;
|
|
1557
|
+
while (remaining.length > 0) {
|
|
1558
|
+
const match = remaining.match(/\$([a-zA-Z_]\w*)/);
|
|
1559
|
+
if (!match) {
|
|
1560
|
+
parts.push(`'${remaining}'`);
|
|
1561
|
+
break;
|
|
1562
|
+
}
|
|
1563
|
+
const placeholderName = match[1];
|
|
1564
|
+
const placeholderStart = match.index;
|
|
1565
|
+
if (placeholderStart > 0) {
|
|
1566
|
+
parts.push(`'${remaining.substring(0, placeholderStart)}'`);
|
|
1567
|
+
}
|
|
1568
|
+
const varExpr = varMappings[placeholderName];
|
|
1569
|
+
if (varExpr === void 0) {
|
|
1570
|
+
throw new Error(
|
|
1571
|
+
`compileCoordinateExpr: no mapping for placeholder "$${placeholderName}" in template "${template}"`
|
|
1572
|
+
);
|
|
1573
|
+
}
|
|
1574
|
+
parts.push(`escapeAttr(String(${varExpr}))`);
|
|
1575
|
+
remaining = remaining.substring(placeholderStart + match[0].length);
|
|
1576
|
+
}
|
|
1577
|
+
return parts.join(" + ");
|
|
1578
|
+
}
|
|
1579
|
+
function isStaticCoordinate(template) {
|
|
1580
|
+
return !template.includes("$");
|
|
1581
|
+
}
|
|
1582
|
+
function computeInstanceKey(coordinateSuffix, context, prefix) {
|
|
1583
|
+
switch (context) {
|
|
1584
|
+
case "static":
|
|
1585
|
+
return coordinateSuffix;
|
|
1586
|
+
case "slowForEach":
|
|
1587
|
+
return `${prefix}/${coordinateSuffix}`;
|
|
1588
|
+
case "forEach":
|
|
1589
|
+
return void 0;
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
function compileForEachInstanceKeyExpr(coordinateSuffix, trackByExpr) {
|
|
1593
|
+
return `String(${trackByExpr}) + ',${coordinateSuffix}'`;
|
|
1594
|
+
}
|
|
1595
|
+
function computeForEachInstanceKey(trackByValue, coordinateSuffix) {
|
|
1596
|
+
return [trackByValue, coordinateSuffix].toString();
|
|
1597
|
+
}
|
|
1329
1598
|
const s = createRequire(import.meta.url), e = s("typescript"), u = e, c = new Proxy(e, {
|
|
1330
1599
|
get(t, r) {
|
|
1331
1600
|
return t[r];
|
|
@@ -1341,6 +1610,8 @@ export {
|
|
|
1341
1610
|
Imports,
|
|
1342
1611
|
ImportsFor,
|
|
1343
1612
|
JAY_4_REACT,
|
|
1613
|
+
JAY_ACTION_DTS_EXTENSION,
|
|
1614
|
+
JAY_ACTION_EXTENSION,
|
|
1344
1615
|
JAY_COMPONENT,
|
|
1345
1616
|
JAY_CONTRACT_DTS_EXTENSION,
|
|
1346
1617
|
JAY_CONTRACT_EXTENSION,
|
|
@@ -1348,6 +1619,7 @@ export {
|
|
|
1348
1619
|
JAY_EXTENSION,
|
|
1349
1620
|
JAY_FULLSTACK_COMPONENTS,
|
|
1350
1621
|
JAY_QUERY_CLIENT,
|
|
1622
|
+
JAY_QUERY_HYDRATE,
|
|
1351
1623
|
JAY_QUERY_MAIN_SANDBOX,
|
|
1352
1624
|
JAY_QUERY_MAIN_SANDBOX_TS,
|
|
1353
1625
|
JAY_QUERY_PREFIX,
|
|
@@ -1358,6 +1630,7 @@ export {
|
|
|
1358
1630
|
JAY_QUERY_WORKER_TRUSTED_TS,
|
|
1359
1631
|
JAY_RUNTIME,
|
|
1360
1632
|
JAY_SECURE,
|
|
1633
|
+
JAY_SSR_RUNTIME,
|
|
1361
1634
|
JAY_STACK_CLIENT_RUNTIME,
|
|
1362
1635
|
JAY_TS_EXTENSION,
|
|
1363
1636
|
JayArrayType,
|
|
@@ -1375,6 +1648,7 @@ export {
|
|
|
1375
1648
|
JayImportedType,
|
|
1376
1649
|
JayNumber,
|
|
1377
1650
|
JayObjectType,
|
|
1651
|
+
JayOptionalType,
|
|
1378
1652
|
JayPromiseType,
|
|
1379
1653
|
JayRecursiveType,
|
|
1380
1654
|
JayString,
|
|
@@ -1382,6 +1656,7 @@ export {
|
|
|
1382
1656
|
JayTypeKind,
|
|
1383
1657
|
JayUnionType,
|
|
1384
1658
|
JayUnknown,
|
|
1659
|
+
LOCAL_PLUGIN_PATH,
|
|
1385
1660
|
MAKE_JAY_4_REACT_COMPONENT,
|
|
1386
1661
|
MAKE_JAY_COMPONENT,
|
|
1387
1662
|
MAKE_JAY_TSX_COMPONENT,
|
|
@@ -1394,7 +1669,12 @@ export {
|
|
|
1394
1669
|
WithValidations,
|
|
1395
1670
|
addBuildEnvironment,
|
|
1396
1671
|
checkValidationErrors,
|
|
1672
|
+
compileCoordinateExpr,
|
|
1673
|
+
compileForEachInstanceKeyExpr,
|
|
1674
|
+
computeForEachInstanceKey,
|
|
1675
|
+
computeInstanceKey,
|
|
1397
1676
|
equalJayTypes,
|
|
1677
|
+
findDynamicContract,
|
|
1398
1678
|
getBasePath,
|
|
1399
1679
|
getBuildEnvironment,
|
|
1400
1680
|
getJayTsFileSourcePath,
|
|
@@ -1419,22 +1699,25 @@ export {
|
|
|
1419
1699
|
isImportedType,
|
|
1420
1700
|
isLocalModule,
|
|
1421
1701
|
isObjectType,
|
|
1702
|
+
isOptionalType,
|
|
1422
1703
|
isPromiseType,
|
|
1423
1704
|
isRecursiveType,
|
|
1705
|
+
isStaticCoordinate,
|
|
1424
1706
|
isTypeAliasType,
|
|
1425
1707
|
isUnionType,
|
|
1708
|
+
jayTypeToJsonSchema,
|
|
1426
1709
|
loadPluginManifest,
|
|
1427
1710
|
mergeRefsTrees,
|
|
1428
1711
|
mkRef,
|
|
1429
1712
|
mkRefsTree,
|
|
1430
1713
|
nestRefs,
|
|
1714
|
+
normalizeActionEntry,
|
|
1431
1715
|
parseJayModuleSpecifier,
|
|
1432
1716
|
prettify,
|
|
1433
1717
|
prettifyHtml,
|
|
1434
1718
|
removeComments,
|
|
1435
|
-
resolveLocalPlugin,
|
|
1436
|
-
resolveNpmPlugin,
|
|
1437
1719
|
resolvePluginComponent,
|
|
1720
|
+
resolvePluginManifest,
|
|
1438
1721
|
resolvePrimitiveType,
|
|
1439
1722
|
u as ts,
|
|
1440
1723
|
c as tsBridge,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/compiler-shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.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.14.0",
|
|
29
|
+
"@jay-framework/runtime": "^0.14.0",
|
|
30
|
+
"@jay-framework/secure": "^0.14.0",
|
|
31
|
+
"@jay-framework/typescript-bridge": "^0.9.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.14.0",
|
|
45
45
|
"@testing-library/jest-dom": "^6.2.0",
|
|
46
46
|
"@types/js-beautify": "^1",
|
|
47
47
|
"@types/node": "^20.11.5",
|