@jay-framework/stack-server-build 0.24.5 → 0.24.7
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 +75 -2
- package/dist/index.js +207 -9
- package/package.json +14 -13
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { Contract, HeadlessContractInfo, DiscoveredHeadlessInstance, ForEachHead
|
|
|
6
6
|
import { AnyJayStackComponentDefinition, HeadTag } from '@jay-framework/fullstack-component';
|
|
7
7
|
import { JayRollupConfig } from '@jay-framework/rollup-plugin';
|
|
8
8
|
import { TrackByMap } from '@jay-framework/view-state-merge';
|
|
9
|
-
import { PluginClientInitInfo, ActionRegistry, ViteSSRLoader as ViteSSRLoader$1, PluginAgentKitResult, PluginSetupPrompt, PluginSetupResult } from '@jay-framework/stack-server-runtime';
|
|
9
|
+
import { PluginClientInitInfo, ActionRegistry, ViteSSRLoader as ViteSSRLoader$1, ScannedPlugin, PluginAgentKitResult, PluginSetupPrompt, PluginSetupResult } from '@jay-framework/stack-server-runtime';
|
|
10
10
|
export * from '@jay-framework/stack-server-runtime';
|
|
11
11
|
export { PluginAgentKitContext, PluginAgentKitHandler, PluginAgentKitResult, PluginSetupContext, PluginSetupHandler, PluginSetupPrompt, PluginSetupResult } from '@jay-framework/stack-server-runtime';
|
|
12
12
|
|
|
@@ -408,6 +408,8 @@ interface PluginsIndexEntry {
|
|
|
408
408
|
}
|
|
409
409
|
interface PluginsIndex {
|
|
410
410
|
plugins: PluginsIndexEntry[];
|
|
411
|
+
/** DL#204 — pointer to the sibling design-system index (region/template catalog). */
|
|
412
|
+
designSystemIndex?: string;
|
|
411
413
|
}
|
|
412
414
|
interface MaterializeContractsOptions {
|
|
413
415
|
projectRoot: string;
|
|
@@ -437,6 +439,77 @@ declare function materializeContracts(options: MaterializeContractsOptions, serv
|
|
|
437
439
|
*/
|
|
438
440
|
declare function listContracts(options: MaterializeContractsOptions): Promise<PluginsIndex>;
|
|
439
441
|
|
|
442
|
+
/**
|
|
443
|
+
* Design-System Index (DL#204)
|
|
444
|
+
*
|
|
445
|
+
* Catalogs every headless component an agent could flatten as a `<jay:X>` region: its contract and
|
|
446
|
+
* the `.jay-html` template variants it ships. Two discovery sources, merged into one catalog:
|
|
447
|
+
* 1. Local components under `componentsBase` (default `./src/components`).
|
|
448
|
+
* 2. Plugin components (static `manifest.contracts`).
|
|
449
|
+
*
|
|
450
|
+
* Template↔contract association is by the template's *declared* contract reference
|
|
451
|
+
* (`<script type="application/jay-data" contract="…">`), not by a filename convention: a `.jay-html`
|
|
452
|
+
* is a variant of contract `X` iff its resolved `contract=` points at `X.jay-contract`. This handles
|
|
453
|
+
* a directory holding several contracts correctly and needs no new naming rule.
|
|
454
|
+
*
|
|
455
|
+
* @see Design Log #204 — A design-system (region/template) index in the agent-kit
|
|
456
|
+
*/
|
|
457
|
+
|
|
458
|
+
/** One `.jay-html` template that renders a given contract. */
|
|
459
|
+
interface TemplateVariant {
|
|
460
|
+
/** Path to the `.jay-html` (absolute from the lookup helpers; project-relative in the emitted index). */
|
|
461
|
+
path: string;
|
|
462
|
+
/** Stable label: `''` for `<contract-basename>.jay-html`, else the filename stem (e.g. `card.feature`). */
|
|
463
|
+
variant: string;
|
|
464
|
+
/** From the template's `<title>` static text; omitted when empty or interpolation-only. */
|
|
465
|
+
title?: string;
|
|
466
|
+
}
|
|
467
|
+
/** One component (contract) and every template that renders it. */
|
|
468
|
+
interface DesignSystemComponentEntry {
|
|
469
|
+
/** Contract name. */
|
|
470
|
+
name: string;
|
|
471
|
+
/** Path to the `.jay-contract` (project-relative in the emitted index). */
|
|
472
|
+
contractPath: string;
|
|
473
|
+
/** From the `.jay-contract` — a component-level property, read once (not per template). */
|
|
474
|
+
description?: string;
|
|
475
|
+
source: 'local' | 'plugin';
|
|
476
|
+
/** Plugin name when `source === 'plugin'`. */
|
|
477
|
+
plugin?: string;
|
|
478
|
+
/** Every `.jay-html` whose `contractRef` resolves to this contract. */
|
|
479
|
+
templates: TemplateVariant[];
|
|
480
|
+
}
|
|
481
|
+
interface DesignSystemIndex {
|
|
482
|
+
components: DesignSystemComponentEntry[];
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* DL#204 — every template variant for the contract at `contractFile`. A template counts when its
|
|
486
|
+
* resolved `contractRef` equals `contractFile` (reference match, not filename). Generalizes DL#200's
|
|
487
|
+
* boolean `hasTemplateForContractFile`.
|
|
488
|
+
*/
|
|
489
|
+
declare function listTemplatesForContractFile(contractFile: string | undefined): TemplateVariant[];
|
|
490
|
+
/** DL#200/204 — does any `.jay-html` render this contract? Thin wrapper over the enumeration. */
|
|
491
|
+
declare function hasTemplateForContractFile(contractFile: string | undefined): boolean;
|
|
492
|
+
interface BuildDesignSystemIndexOptions {
|
|
493
|
+
projectRoot: string;
|
|
494
|
+
/** Local component root; default `./src/components` (same base `validate`/`sync` use). */
|
|
495
|
+
componentsBase?: string;
|
|
496
|
+
/** Scanned plugins (reuse the same scan plugins-index did). */
|
|
497
|
+
plugins: Map<string, ScannedPlugin>;
|
|
498
|
+
/** Resolves a plugin contract spec to an absolute `.jay-contract` path (shared with the materializer). */
|
|
499
|
+
resolvePluginContractPath: (plugin: ScannedPlugin, contractSpec: string) => string;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* DL#204 — build the catalog from the two discovery sources. Dynamic (generated) plugin contracts are
|
|
503
|
+
* not included: they are materialized into agent-kit and have no co-located `.jay-html` to flatten.
|
|
504
|
+
*/
|
|
505
|
+
declare function buildDesignSystemIndex(options: BuildDesignSystemIndexOptions): DesignSystemIndex;
|
|
506
|
+
/**
|
|
507
|
+
* DL#204 — render the human/agent "add-menu": the `<title>` catalog of components and their template
|
|
508
|
+
* variants, each with a paste-ready `template=` import + `<jay:X>` region. Generated from the same
|
|
509
|
+
* `DesignSystemIndex` object, so it can never drift from the YAML.
|
|
510
|
+
*/
|
|
511
|
+
declare function renderAddMenu(index: DesignSystemIndex): string;
|
|
512
|
+
|
|
440
513
|
/**
|
|
441
514
|
* Plugin CLI Commands (Design Log #142)
|
|
442
515
|
*
|
|
@@ -680,4 +753,4 @@ declare class SlowRenderCache {
|
|
|
680
753
|
private scanAndDeleteCacheFiles;
|
|
681
754
|
}
|
|
682
755
|
|
|
683
|
-
export { type ActionDiscoveryOptions, type ActionDiscoveryResult, type ActionIndexEntry, type ActionMetadata, type ActionSchema, type CommandFlag, type CommandIndexEntry, type CommandMetadata, type ContextIndexEntry, type DevServerPagePart, type DiscoveredCommand, type GenerateClientScriptOptions, type HeadlessInstanceComponent, type LoadPagePartsOptions, type LoadedPageParts, type MaterializeContractsOptions, type MaterializeResult, type PluginActionDiscoveryOptions, type PluginContractEntry, type PluginWithAgentKit, type PluginWithSetup, type PluginsIndex, type PluginsIndexEntry, type ProjectClientInitInfo, type RouteIndexEntry, type ScriptFragments, type ServiceIndexEntry, SetupNeedsAnswerError, SlowRenderCache, type SlowRenderCacheEntry, type ViteSSRLoader, buildAutomationWrap, buildPageReloadHmrScript, buildScriptFragments, clearServerElementCache, commandSchemaToFlags, discoverAllPluginActions, discoverAndRegisterActions, discoverPluginActions, discoverPluginCommands, discoverPluginsWithAgentKit, discoverPluginsWithSetup, executePluginAgentKit, executePluginCommand, executePluginSetup, generateClientScript, generateFrozenPageHtml, generatePromiseReconstruction, generateSSRPageHtml, headMetaToHeadTags, invalidateServerElementCache, listContracts, loadActionMetadata, loadPageParts, materializeContracts, parseActionMetadata, parseInputFromFlags, resolveActionMetadataPath, resolveClientImportPath, resolveViewStatePromises };
|
|
756
|
+
export { type ActionDiscoveryOptions, type ActionDiscoveryResult, type ActionIndexEntry, type ActionMetadata, type ActionSchema, type BuildDesignSystemIndexOptions, type CommandFlag, type CommandIndexEntry, type CommandMetadata, type ContextIndexEntry, type DesignSystemComponentEntry, type DesignSystemIndex, type DevServerPagePart, type DiscoveredCommand, type GenerateClientScriptOptions, type HeadlessInstanceComponent, type LoadPagePartsOptions, type LoadedPageParts, type MaterializeContractsOptions, type MaterializeResult, type PluginActionDiscoveryOptions, type PluginContractEntry, type PluginWithAgentKit, type PluginWithSetup, type PluginsIndex, type PluginsIndexEntry, type ProjectClientInitInfo, type RouteIndexEntry, type ScriptFragments, type ServiceIndexEntry, SetupNeedsAnswerError, SlowRenderCache, type SlowRenderCacheEntry, type TemplateVariant, type ViteSSRLoader, buildAutomationWrap, buildDesignSystemIndex, buildPageReloadHmrScript, buildScriptFragments, clearServerElementCache, commandSchemaToFlags, discoverAllPluginActions, discoverAndRegisterActions, discoverPluginActions, discoverPluginCommands, discoverPluginsWithAgentKit, discoverPluginsWithSetup, executePluginAgentKit, executePluginCommand, executePluginSetup, generateClientScript, generateFrozenPageHtml, generatePromiseReconstruction, generateSSRPageHtml, hasTemplateForContractFile, headMetaToHeadTags, invalidateServerElementCache, listContracts, listTemplatesForContractFile, loadActionMetadata, loadPageParts, materializeContracts, parseActionMetadata, parseInputFromFlags, renderAddMenu, resolveActionMetadataPath, resolveClientImportPath, resolveViewStatePromises };
|
package/dist/index.js
CHANGED
|
@@ -4,19 +4,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4
4
|
import fs$1 from "node:fs/promises";
|
|
5
5
|
import * as path from "node:path";
|
|
6
6
|
import path__default from "node:path";
|
|
7
|
-
import { parseJayFile, JAY_IMPORT_RESOLVER,
|
|
7
|
+
import { parseJayFile, JAY_IMPORT_RESOLVER, discoverHeadlessInstances, assignCoordinatesToJayHtml, generateServerElementFile, parseAction } from "@jay-framework/compiler-jay-html";
|
|
8
|
+
import { makePassthroughInstanceComponent, serializeHeadTags, mergeHeadTags, actionRegistry, scanPlugins, resolveServices, sortPluginsByDependencies, getServiceRegistry } from "@jay-framework/stack-server-runtime";
|
|
9
|
+
export * from "@jay-framework/stack-server-runtime";
|
|
8
10
|
import { createRequire } from "module";
|
|
9
11
|
import jsBeautify from "js-beautify";
|
|
10
12
|
import fs$2 from "fs";
|
|
11
13
|
import path$1 from "path";
|
|
12
14
|
import YAML from "yaml";
|
|
13
|
-
import { serializeHeadTags, mergeHeadTags, actionRegistry, scanPlugins, resolveServices, sortPluginsByDependencies, getServiceRegistry } from "@jay-framework/stack-server-runtime";
|
|
14
|
-
export * from "@jay-framework/stack-server-runtime";
|
|
15
15
|
import crypto from "node:crypto";
|
|
16
16
|
import { getLogger } from "@jay-framework/logger";
|
|
17
17
|
import * as fs from "node:fs";
|
|
18
18
|
import { createRequire as createRequire$1 } from "node:module";
|
|
19
19
|
import { isJayAction, isJayStreamAction, isJayCliCommand } from "@jay-framework/fullstack-component";
|
|
20
|
+
import { parse } from "node-html-parser";
|
|
20
21
|
const require$3 = createRequire(import.meta.url);
|
|
21
22
|
function resolveClientImportPath(route) {
|
|
22
23
|
if (route.clientCompPath) return route.clientCompPath;
|
|
@@ -69,7 +70,14 @@ async function loadPageParts(vite, route, pagesBase, projectBase, jayRollupConfi
|
|
|
69
70
|
let clientModuleImport;
|
|
70
71
|
let isNpmPackage;
|
|
71
72
|
if (headlessImport.structural) {
|
|
72
|
-
|
|
73
|
+
compDefinition = makePassthroughInstanceComponent(
|
|
74
|
+
(headlessImport.contract?.tags ?? []).map((t) => ({
|
|
75
|
+
name: t.tag,
|
|
76
|
+
phase: t.phase
|
|
77
|
+
}))
|
|
78
|
+
);
|
|
79
|
+
isNpmPackage = false;
|
|
80
|
+
clientModuleImport = "";
|
|
73
81
|
} else {
|
|
74
82
|
const modulePath = isLocalModule ? path__default.resolve(dirName, module) : require$3.resolve(module, { paths: require$3.resolve.paths(dirName) });
|
|
75
83
|
compDefinition = (await vite.ssrLoadModule(modulePath))[name];
|
|
@@ -110,11 +118,7 @@ async function loadPageParts(vite, route, pagesBase, projectBase, jayRollupConfi
|
|
|
110
118
|
contract: hi.contract,
|
|
111
119
|
contractPath: hi.contractPath
|
|
112
120
|
}));
|
|
113
|
-
const jayHtmlForDiscovery =
|
|
114
|
-
jayHtmlSource,
|
|
115
|
-
dirName,
|
|
116
|
-
JAY_IMPORT_RESOLVER
|
|
117
|
-
);
|
|
121
|
+
const jayHtmlForDiscovery = jayHtmlSource;
|
|
118
122
|
let discoveryResult;
|
|
119
123
|
if (headlessInstanceComponents.length > 0) {
|
|
120
124
|
const firstDiscovery = discoverHeadlessInstances(jayHtmlForDiscovery);
|
|
@@ -151,6 +155,8 @@ async function loadPageParts(vite, route, pagesBase, projectBase, jayRollupConfi
|
|
|
151
155
|
var __defProp2 = Object.defineProperty;
|
|
152
156
|
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
153
157
|
var __publicField2 = (obj, key, value) => __defNormalProp2(obj, key + "", value);
|
|
158
|
+
const JAY_EXTENSION = ".jay-html";
|
|
159
|
+
const JAY_CONTRACT_EXTENSION = ".jay-contract";
|
|
154
160
|
class JayAtomicType {
|
|
155
161
|
constructor(name) {
|
|
156
162
|
__publicField2(this, "kind", 0);
|
|
@@ -1334,6 +1340,172 @@ async function discoverPluginActions(pluginPath, projectRoot, registry = actionR
|
|
|
1334
1340
|
}
|
|
1335
1341
|
return registeredActions;
|
|
1336
1342
|
}
|
|
1343
|
+
function readTemplateMeta(jayHtmlPath) {
|
|
1344
|
+
let content;
|
|
1345
|
+
try {
|
|
1346
|
+
content = fs.readFileSync(jayHtmlPath, "utf-8");
|
|
1347
|
+
} catch {
|
|
1348
|
+
return {};
|
|
1349
|
+
}
|
|
1350
|
+
const root = parse(content);
|
|
1351
|
+
const ref = root.querySelector('script[type="application/jay-data"]')?.getAttribute("contract");
|
|
1352
|
+
const contractRef = ref ? path.resolve(path.dirname(jayHtmlPath), ref) : void 0;
|
|
1353
|
+
const rawTitle = root.querySelector("title")?.text?.trim();
|
|
1354
|
+
const staticTitle = rawTitle ? rawTitle.replace(/\{[^}]*\}/g, "").trim() : "";
|
|
1355
|
+
return { contractRef, title: staticTitle.length > 0 ? staticTitle : void 0 };
|
|
1356
|
+
}
|
|
1357
|
+
function listTemplatesForContractFile(contractFile) {
|
|
1358
|
+
if (!contractFile) return [];
|
|
1359
|
+
const dir = path.dirname(contractFile);
|
|
1360
|
+
const target = path.resolve(contractFile);
|
|
1361
|
+
const contractBasename = path.basename(contractFile, JAY_CONTRACT_EXTENSION);
|
|
1362
|
+
let names;
|
|
1363
|
+
try {
|
|
1364
|
+
names = fs.readdirSync(dir);
|
|
1365
|
+
} catch {
|
|
1366
|
+
return [];
|
|
1367
|
+
}
|
|
1368
|
+
const variants = [];
|
|
1369
|
+
for (const f of names) {
|
|
1370
|
+
if (!f.endsWith(JAY_EXTENSION)) continue;
|
|
1371
|
+
const jayHtmlPath = path.join(dir, f);
|
|
1372
|
+
const meta = readTemplateMeta(jayHtmlPath);
|
|
1373
|
+
if (meta.contractRef !== target) continue;
|
|
1374
|
+
const stem = path.basename(f, JAY_EXTENSION);
|
|
1375
|
+
variants.push({
|
|
1376
|
+
path: jayHtmlPath,
|
|
1377
|
+
variant: stem === contractBasename ? "" : stem,
|
|
1378
|
+
...meta.title && { title: meta.title }
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
return variants.sort((a, b) => a.variant.localeCompare(b.variant));
|
|
1382
|
+
}
|
|
1383
|
+
function hasTemplateForContractFile(contractFile) {
|
|
1384
|
+
return listTemplatesForContractFile(contractFile).length > 0;
|
|
1385
|
+
}
|
|
1386
|
+
function readContractField(contractFile, field) {
|
|
1387
|
+
try {
|
|
1388
|
+
const parsed = YAML.parse(fs.readFileSync(contractFile, "utf-8"));
|
|
1389
|
+
const value = parsed?.[field];
|
|
1390
|
+
return typeof value === "string" ? value : void 0;
|
|
1391
|
+
} catch {
|
|
1392
|
+
return void 0;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
function findContractFilesSync(dir) {
|
|
1396
|
+
const out = [];
|
|
1397
|
+
let entries;
|
|
1398
|
+
try {
|
|
1399
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
1400
|
+
} catch {
|
|
1401
|
+
return out;
|
|
1402
|
+
}
|
|
1403
|
+
for (const entry of entries) {
|
|
1404
|
+
const full = path.join(dir, entry.name);
|
|
1405
|
+
if (entry.isDirectory()) out.push(...findContractFilesSync(full));
|
|
1406
|
+
else if (entry.name.endsWith(JAY_CONTRACT_EXTENSION)) out.push(full);
|
|
1407
|
+
}
|
|
1408
|
+
return out.sort();
|
|
1409
|
+
}
|
|
1410
|
+
function buildDesignSystemIndex(options) {
|
|
1411
|
+
const { projectRoot, plugins, resolvePluginContractPath } = options;
|
|
1412
|
+
const componentsBase = options.componentsBase ? path.resolve(projectRoot, options.componentsBase) : path.join(projectRoot, "src", "components");
|
|
1413
|
+
const rel = (p) => "./" + path.relative(projectRoot, p).replace(/\\/g, "/");
|
|
1414
|
+
const makeEntry = (contractFile, source, pluginName, nameOverride) => {
|
|
1415
|
+
const name = nameOverride ?? readContractField(contractFile, "name") ?? path.basename(contractFile, JAY_CONTRACT_EXTENSION);
|
|
1416
|
+
const description = readContractField(contractFile, "description");
|
|
1417
|
+
const templates = listTemplatesForContractFile(contractFile).map((t) => ({
|
|
1418
|
+
...t,
|
|
1419
|
+
path: rel(t.path)
|
|
1420
|
+
}));
|
|
1421
|
+
return {
|
|
1422
|
+
name,
|
|
1423
|
+
contractPath: rel(contractFile),
|
|
1424
|
+
...description && { description },
|
|
1425
|
+
source,
|
|
1426
|
+
...pluginName && { plugin: pluginName },
|
|
1427
|
+
templates
|
|
1428
|
+
};
|
|
1429
|
+
};
|
|
1430
|
+
const components = [];
|
|
1431
|
+
for (const contractFile of findContractFilesSync(componentsBase)) {
|
|
1432
|
+
components.push(makeEntry(contractFile, "local", void 0));
|
|
1433
|
+
}
|
|
1434
|
+
for (const [, plugin] of plugins) {
|
|
1435
|
+
const contracts = plugin.manifest.contracts;
|
|
1436
|
+
if (!Array.isArray(contracts)) continue;
|
|
1437
|
+
for (const contract of contracts) {
|
|
1438
|
+
const spec = contract.contract;
|
|
1439
|
+
if (!spec) continue;
|
|
1440
|
+
const contractFile = resolvePluginContractPath(plugin, spec);
|
|
1441
|
+
components.push(makeEntry(contractFile, "plugin", plugin.name, contract.name));
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
return { components };
|
|
1445
|
+
}
|
|
1446
|
+
function toKebabCase$1(str) {
|
|
1447
|
+
return str.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[\s_]+/g, "-").replace(/^-/, "");
|
|
1448
|
+
}
|
|
1449
|
+
function renderAddMenu(index) {
|
|
1450
|
+
const lines = [];
|
|
1451
|
+
lines.push("# Design-system elements you can add");
|
|
1452
|
+
lines.push("");
|
|
1453
|
+
lines.push(
|
|
1454
|
+
"Generated by `jay-stack agent-kit`. Each component ships a contract and one or more"
|
|
1455
|
+
);
|
|
1456
|
+
lines.push(
|
|
1457
|
+
"`.jay-html` templates you can flatten into a page as a `<jay:X>` region. Pick a variant,"
|
|
1458
|
+
);
|
|
1459
|
+
lines.push("paste its import + region, then run `jay-stack sync` to flatten the markup. See");
|
|
1460
|
+
lines.push("`designer/design-system-guide.md`.");
|
|
1461
|
+
lines.push("");
|
|
1462
|
+
if (index.components.length === 0) {
|
|
1463
|
+
lines.push("_No design-system components found._");
|
|
1464
|
+
lines.push("");
|
|
1465
|
+
return lines.join("\n");
|
|
1466
|
+
}
|
|
1467
|
+
for (const component of index.components) {
|
|
1468
|
+
lines.push(
|
|
1469
|
+
component.description ? `## ${component.name} — ${component.description}` : `## ${component.name}`
|
|
1470
|
+
);
|
|
1471
|
+
lines.push("");
|
|
1472
|
+
if (component.templates.length === 0) {
|
|
1473
|
+
lines.push(
|
|
1474
|
+
"_No template yet (COMPONENT-NO-TEMPLATE) — this component can't be flattened until it ships a `.jay-html`._"
|
|
1475
|
+
);
|
|
1476
|
+
lines.push("");
|
|
1477
|
+
continue;
|
|
1478
|
+
}
|
|
1479
|
+
lines.push("| Variant | Title | Template |");
|
|
1480
|
+
lines.push("| --- | --- | --- |");
|
|
1481
|
+
for (const template of component.templates) {
|
|
1482
|
+
const variant = template.variant === "" ? "(default)" : template.variant;
|
|
1483
|
+
lines.push(`| ${variant} | ${template.title ?? ""} | ${template.path} |`);
|
|
1484
|
+
}
|
|
1485
|
+
lines.push("");
|
|
1486
|
+
const first = component.templates[0];
|
|
1487
|
+
const regionTag = toKebabCase$1(component.name);
|
|
1488
|
+
const contractAttr = component.source === "plugin" ? component.name : component.contractPath;
|
|
1489
|
+
lines.push("```html");
|
|
1490
|
+
lines.push("<script");
|
|
1491
|
+
lines.push(' type="application/jay-headless"');
|
|
1492
|
+
if (component.source === "plugin" && component.plugin) {
|
|
1493
|
+
lines.push(` plugin="${component.plugin}"`);
|
|
1494
|
+
}
|
|
1495
|
+
lines.push(` contract="${contractAttr}"`);
|
|
1496
|
+
lines.push(` template="${first.path}"`);
|
|
1497
|
+
lines.push("><\/script>");
|
|
1498
|
+
lines.push("");
|
|
1499
|
+
lines.push(
|
|
1500
|
+
`<jay:${regionTag} ref="${regionTag}"><!-- flattened copy; edit freely --></jay:${regionTag}>`
|
|
1501
|
+
);
|
|
1502
|
+
lines.push("```");
|
|
1503
|
+
lines.push("");
|
|
1504
|
+
lines.push("Then run `jay-stack sync` to flatten it.");
|
|
1505
|
+
lines.push("");
|
|
1506
|
+
}
|
|
1507
|
+
return lines.join("\n");
|
|
1508
|
+
}
|
|
1337
1509
|
const require$1 = createRequire(import.meta.url);
|
|
1338
1510
|
async function executeDynamicGenerator(plugin, config, projectRoot, services, verbose, viteServer) {
|
|
1339
1511
|
const { pluginPath, name: pluginName, isLocal, packageName } = plugin;
|
|
@@ -1463,6 +1635,15 @@ function resolveActionFilePath(actionPath, packageName, pluginPath, isLocal, pro
|
|
|
1463
1635
|
function toKebabCase(str) {
|
|
1464
1636
|
return str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
|
|
1465
1637
|
}
|
|
1638
|
+
function readComponentsBase(projectRoot) {
|
|
1639
|
+
try {
|
|
1640
|
+
const parsed = YAML.parse(fs.readFileSync(path.join(projectRoot, ".jay"), "utf-8"));
|
|
1641
|
+
const base = parsed?.devServer?.componentsBase;
|
|
1642
|
+
if (typeof base === "string" && base.length > 0) return base;
|
|
1643
|
+
} catch {
|
|
1644
|
+
}
|
|
1645
|
+
return "./src/components";
|
|
1646
|
+
}
|
|
1466
1647
|
async function materializeContracts(options, services = /* @__PURE__ */ new Map()) {
|
|
1467
1648
|
const {
|
|
1468
1649
|
projectRoot,
|
|
@@ -1682,13 +1863,26 @@ async function materializeContracts(options, services = /* @__PURE__ */ new Map(
|
|
|
1682
1863
|
...data.commands?.length && { commands: data.commands }
|
|
1683
1864
|
}))
|
|
1684
1865
|
};
|
|
1866
|
+
const designSystem = buildDesignSystemIndex({
|
|
1867
|
+
projectRoot,
|
|
1868
|
+
componentsBase: readComponentsBase(projectRoot),
|
|
1869
|
+
plugins,
|
|
1870
|
+
resolvePluginContractPath: (plugin, spec) => resolveStaticContractPath(plugin, spec, projectRoot)
|
|
1871
|
+
});
|
|
1872
|
+
pluginsIndex.designSystemIndex = "./design-system-index.yaml";
|
|
1685
1873
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
1686
1874
|
const agentKitDir = path.dirname(outputDir);
|
|
1687
1875
|
const pluginsIndexPath = path.join(agentKitDir, "plugins-index.yaml");
|
|
1688
1876
|
fs.writeFileSync(pluginsIndexPath, YAML.stringify(pluginsIndex), "utf-8");
|
|
1877
|
+
const designSystemIndexPath = path.join(agentKitDir, "design-system-index.yaml");
|
|
1878
|
+
fs.writeFileSync(designSystemIndexPath, YAML.stringify(designSystem), "utf-8");
|
|
1879
|
+
const addMenuPath = path.join(agentKitDir, "design-system.md");
|
|
1880
|
+
fs.writeFileSync(addMenuPath, renderAddMenu(designSystem), "utf-8");
|
|
1689
1881
|
if (verbose) {
|
|
1690
1882
|
getLogger().info(`
|
|
1691
1883
|
✅ Plugins index written to: ${pluginsIndexPath}`);
|
|
1884
|
+
getLogger().info(`✅ Design-system index written to: ${designSystemIndexPath}`);
|
|
1885
|
+
getLogger().info(`✅ Design-system add-menu written to: ${addMenuPath}`);
|
|
1692
1886
|
}
|
|
1693
1887
|
return {
|
|
1694
1888
|
pluginsIndex,
|
|
@@ -2308,6 +2502,7 @@ export {
|
|
|
2308
2502
|
SetupNeedsAnswerError,
|
|
2309
2503
|
SlowRenderCache,
|
|
2310
2504
|
buildAutomationWrap,
|
|
2505
|
+
buildDesignSystemIndex,
|
|
2311
2506
|
buildPageReloadHmrScript,
|
|
2312
2507
|
buildScriptFragments,
|
|
2313
2508
|
clearServerElementCache,
|
|
@@ -2325,14 +2520,17 @@ export {
|
|
|
2325
2520
|
generateFrozenPageHtml,
|
|
2326
2521
|
generatePromiseReconstruction,
|
|
2327
2522
|
generateSSRPageHtml,
|
|
2523
|
+
hasTemplateForContractFile,
|
|
2328
2524
|
headMetaToHeadTags,
|
|
2329
2525
|
invalidateServerElementCache,
|
|
2330
2526
|
listContracts,
|
|
2527
|
+
listTemplatesForContractFile,
|
|
2331
2528
|
loadActionMetadata,
|
|
2332
2529
|
loadPageParts,
|
|
2333
2530
|
materializeContracts,
|
|
2334
2531
|
parseActionMetadata,
|
|
2335
2532
|
parseInputFromFlags,
|
|
2533
|
+
renderAddMenu,
|
|
2336
2534
|
resolveActionMetadataPath,
|
|
2337
2535
|
resolveClientImportPath,
|
|
2338
2536
|
resolveViewStatePromises
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/stack-server-build",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.7",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.mts",
|
|
@@ -24,21 +24,22 @@
|
|
|
24
24
|
"test:watch": "vitest"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@jay-framework/compiler-jay-html": "^0.24.
|
|
28
|
-
"@jay-framework/compiler-shared": "^0.24.
|
|
29
|
-
"@jay-framework/component": "^0.24.
|
|
30
|
-
"@jay-framework/fullstack-component": "^0.24.
|
|
31
|
-
"@jay-framework/logger": "^0.24.
|
|
32
|
-
"@jay-framework/runtime": "^0.24.
|
|
33
|
-
"@jay-framework/ssr-runtime": "^0.24.
|
|
34
|
-
"@jay-framework/stack-route-scanner": "^0.24.
|
|
35
|
-
"@jay-framework/stack-server-runtime": "^0.24.
|
|
36
|
-
"@jay-framework/view-state-merge": "^0.24.
|
|
27
|
+
"@jay-framework/compiler-jay-html": "^0.24.7",
|
|
28
|
+
"@jay-framework/compiler-shared": "^0.24.7",
|
|
29
|
+
"@jay-framework/component": "^0.24.7",
|
|
30
|
+
"@jay-framework/fullstack-component": "^0.24.7",
|
|
31
|
+
"@jay-framework/logger": "^0.24.7",
|
|
32
|
+
"@jay-framework/runtime": "^0.24.7",
|
|
33
|
+
"@jay-framework/ssr-runtime": "^0.24.7",
|
|
34
|
+
"@jay-framework/stack-route-scanner": "^0.24.7",
|
|
35
|
+
"@jay-framework/stack-server-runtime": "^0.24.7",
|
|
36
|
+
"@jay-framework/view-state-merge": "^0.24.7",
|
|
37
|
+
"node-html-parser": "^6.1.12",
|
|
37
38
|
"yaml": "^2.3.4"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@jay-framework/dev-environment": "^0.24.
|
|
41
|
-
"@jay-framework/rollup-plugin": "^0.24.
|
|
41
|
+
"@jay-framework/dev-environment": "^0.24.7",
|
|
42
|
+
"@jay-framework/rollup-plugin": "^0.24.7",
|
|
42
43
|
"@types/node": "^22.15.21",
|
|
43
44
|
"rimraf": "^5.0.5",
|
|
44
45
|
"tsup": "^8.0.1",
|