@happyvertical/smrt-core 0.57.31 → 0.57.33
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/README.md +25 -1
- package/agents/data-query.md +21 -0
- package/dist/browser.d.ts +3 -2
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +4 -3
- package/dist/class.d.ts.map +1 -1
- package/dist/class.js +1 -1
- package/dist/class.js.map +1 -1
- package/dist/consumer-plugin/index.d.ts +2 -2
- package/dist/consumer-plugin/index.d.ts.map +1 -1
- package/dist/consumer-plugin/index.js.map +1 -1
- package/dist/data-query.d.ts +16 -1
- package/dist/data-query.d.ts.map +1 -1
- package/dist/data-query.js +104 -4
- package/dist/data-query.js.map +1 -1
- package/dist/db-errors.d.ts +7 -0
- package/dist/db-errors.d.ts.map +1 -1
- package/dist/db-errors.js +34 -1
- package/dist/db-errors.js.map +1 -1
- package/dist/dispatch/bus.d.ts +3 -0
- package/dist/dispatch/bus.d.ts.map +1 -1
- package/dist/dispatch/bus.js +27 -4
- package/dist/dispatch/bus.js.map +1 -1
- package/dist/dispatch/index.d.ts +1 -1
- package/dist/dispatch/index.d.ts.map +1 -1
- package/dist/dispatch/types.d.ts +17 -0
- package/dist/dispatch/types.d.ts.map +1 -1
- package/dist/external-agent-usage.d.ts +90 -0
- package/dist/external-agent-usage.d.ts.map +1 -0
- package/dist/external-agent-usage.js +272 -0
- package/dist/external-agent-usage.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/manifest/static-manifest.js +1 -1
- package/dist/manifest/static-manifest.js.map +1 -1
- package/dist/manifest/store.js +1 -1
- package/dist/manifest.json +1 -1
- package/dist/smrt-knowledge.json +5 -6
- package/dist/system/retention.d.ts.map +1 -1
- package/dist/system/retention.js +1 -0
- package/dist/system/retention.js.map +1 -1
- package/dist/testing/database.d.ts.map +1 -1
- package/dist/testing/database.js +18 -0
- package/dist/testing/database.js.map +1 -1
- package/dist/vite-plugin/asset-url-compatibility.d.ts +2 -2
- package/dist/vite-plugin/asset-url-compatibility.d.ts.map +1 -1
- package/dist/vite-plugin/asset-url-compatibility.js +13 -3
- package/dist/vite-plugin/asset-url-compatibility.js.map +1 -1
- package/dist/vite-plugin/index.d.ts +5 -2
- package/dist/vite-plugin/index.d.ts.map +1 -1
- package/dist/vite-plugin/index.js.map +1 -1
- package/dist/vite-plugin/plugin-contract.d.ts +164 -0
- package/dist/vite-plugin/plugin-contract.d.ts.map +1 -0
- package/dist/vite-plugin/sveltekit-route-coordinator.d.ts +5 -5
- package/dist/vite-plugin/sveltekit-route-coordinator.d.ts.map +1 -1
- package/dist/vite-plugin/sveltekit-route-coordinator.js.map +1 -1
- package/dist/vite-plugin/worker-registration.d.ts +4 -4
- package/dist/vite-plugin/worker-registration.d.ts.map +1 -1
- package/dist/vite-plugin/worker-registration.js.map +1 -1
- package/dist/vite-preset/index.d.ts +2 -2
- package/dist/vite-preset/index.d.ts.map +1 -1
- package/dist/vite-preset/index.js +9 -1
- package/dist/vite-preset/index.js.map +1 -1
- package/package.json +4 -5
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Vite 5–8 capabilities SMRT actually consumes and implements.
|
|
3
|
+
*
|
|
4
|
+
* Keep this contract independent of Vite and its bundler types. A runtime
|
|
5
|
+
* package must not acquire Vite peer contexts (and duplicate its registry),
|
|
6
|
+
* and its published plugin declarations must not borrow a hoisted Vite.
|
|
7
|
+
*/
|
|
8
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
9
|
+
export type SmrtAwaitable<T> = T | Promise<T>;
|
|
10
|
+
export type SmrtHook<F> = F | {
|
|
11
|
+
order?: 'pre' | 'post';
|
|
12
|
+
handler: F;
|
|
13
|
+
};
|
|
14
|
+
export interface SmrtConfigEnv {
|
|
15
|
+
command: 'build' | 'serve';
|
|
16
|
+
mode: string;
|
|
17
|
+
isSsrBuild?: boolean;
|
|
18
|
+
isPreview?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface SmrtAlias {
|
|
21
|
+
find: string | RegExp;
|
|
22
|
+
replacement: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SmrtDecoratorConfig {
|
|
25
|
+
legacy?: boolean;
|
|
26
|
+
emitDecoratorMetadata?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Input capabilities, not a replacement for the application's full config. */
|
|
29
|
+
export interface SmrtUserConfig {
|
|
30
|
+
root?: string;
|
|
31
|
+
mode?: string;
|
|
32
|
+
plugins?: readonly unknown[];
|
|
33
|
+
oxc?: false | {
|
|
34
|
+
decorator?: SmrtDecoratorConfig;
|
|
35
|
+
};
|
|
36
|
+
worker?: {
|
|
37
|
+
plugins?: () => SmrtInputPluginOption[];
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Config changes authored by SMRT's hooks. Every supported result is typed. */
|
|
41
|
+
export interface SmrtConfigResult {
|
|
42
|
+
oxc?: {
|
|
43
|
+
decorator: SmrtDecoratorConfig;
|
|
44
|
+
};
|
|
45
|
+
resolve?: {
|
|
46
|
+
dedupe: string[];
|
|
47
|
+
};
|
|
48
|
+
ssr?: {
|
|
49
|
+
external?: string[];
|
|
50
|
+
noExternal?: string[];
|
|
51
|
+
};
|
|
52
|
+
build?: {
|
|
53
|
+
rollupOptions?: {
|
|
54
|
+
external?: RegExp[];
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** The opaque api/transform of another plugin is inspected before use. */
|
|
59
|
+
export interface SmrtConfiguredPlugin {
|
|
60
|
+
name: string;
|
|
61
|
+
api?: unknown;
|
|
62
|
+
transform?: unknown;
|
|
63
|
+
}
|
|
64
|
+
/** Foreign plugins are passed through, never authored against SMRT's hooks. */
|
|
65
|
+
export type SmrtInputPluginOption = SmrtConfiguredPlugin | false | null | undefined | SmrtInputPluginOption[] | Promise<SmrtConfiguredPlugin | false | null | undefined | SmrtInputPluginOption[]>;
|
|
66
|
+
export interface SmrtResolvedConfig {
|
|
67
|
+
root: string;
|
|
68
|
+
mode: string;
|
|
69
|
+
command: 'build' | 'serve';
|
|
70
|
+
plugins: readonly SmrtConfiguredPlugin[];
|
|
71
|
+
oxc?: false | {
|
|
72
|
+
decorator?: SmrtDecoratorConfig;
|
|
73
|
+
};
|
|
74
|
+
resolve: {
|
|
75
|
+
alias: readonly SmrtAlias[];
|
|
76
|
+
};
|
|
77
|
+
build: {
|
|
78
|
+
ssr?: boolean | string;
|
|
79
|
+
target?: string | string[] | false;
|
|
80
|
+
lib?: false | {
|
|
81
|
+
entry: string | string[] | Record<string, string>;
|
|
82
|
+
};
|
|
83
|
+
minify?: boolean | string;
|
|
84
|
+
outDir?: string;
|
|
85
|
+
rollupOptions?: {
|
|
86
|
+
output?: {
|
|
87
|
+
dir?: string;
|
|
88
|
+
} | {
|
|
89
|
+
dir?: string;
|
|
90
|
+
}[];
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export interface SmrtResolveOptions {
|
|
95
|
+
ssr?: boolean;
|
|
96
|
+
skipSelf?: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface SmrtResolvedId {
|
|
99
|
+
id: string;
|
|
100
|
+
external?: boolean;
|
|
101
|
+
}
|
|
102
|
+
export interface SmrtHookContext {
|
|
103
|
+
resolve(id: string, importer?: string, options?: SmrtResolveOptions): Promise<{
|
|
104
|
+
id: string;
|
|
105
|
+
} | null>;
|
|
106
|
+
parse(code: string): {
|
|
107
|
+
type: string;
|
|
108
|
+
};
|
|
109
|
+
environment?: {
|
|
110
|
+
config: {
|
|
111
|
+
consumer?: string;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export type SmrtTransformResult = string | {
|
|
116
|
+
code: string;
|
|
117
|
+
map?: null;
|
|
118
|
+
} | null | void;
|
|
119
|
+
export type SmrtTransformHandler = (this: SmrtHookContext, code: string, id: string, options?: {
|
|
120
|
+
ssr?: boolean;
|
|
121
|
+
}) => SmrtAwaitable<SmrtTransformResult>;
|
|
122
|
+
export interface SmrtDevModule {
|
|
123
|
+
id: string | null;
|
|
124
|
+
}
|
|
125
|
+
export interface SmrtDevServer {
|
|
126
|
+
config: {
|
|
127
|
+
root: string;
|
|
128
|
+
};
|
|
129
|
+
middlewares: {
|
|
130
|
+
use(handler: (req: IncomingMessage, res: ServerResponse, next: () => void) => void): void;
|
|
131
|
+
};
|
|
132
|
+
transformIndexHtml(url: string, html: string): Promise<string>;
|
|
133
|
+
watcher: {
|
|
134
|
+
on(event: 'change' | 'add' | 'unlink', listener: (file: string) => void): void;
|
|
135
|
+
};
|
|
136
|
+
moduleGraph: {
|
|
137
|
+
getModuleById(id: string): SmrtDevModule | undefined;
|
|
138
|
+
};
|
|
139
|
+
reloadModule(module: SmrtDevModule): Promise<void>;
|
|
140
|
+
}
|
|
141
|
+
/** Accurate hook/result surface shared by the standalone plugins and preset. */
|
|
142
|
+
export interface SmrtVitePlugin<Api = undefined> {
|
|
143
|
+
name: string;
|
|
144
|
+
enforce?: 'pre' | 'post';
|
|
145
|
+
apply?: 'serve' | 'build' | ((config: SmrtUserConfig, env: SmrtConfigEnv) => boolean);
|
|
146
|
+
api?: Api;
|
|
147
|
+
config?: SmrtHook<(config: SmrtUserConfig, env: SmrtConfigEnv) => SmrtAwaitable<SmrtConfigResult | null | void>>;
|
|
148
|
+
configResolved?: SmrtHook<(config: SmrtResolvedConfig) => SmrtAwaitable<void>>;
|
|
149
|
+
buildStart?: SmrtHook<(this: SmrtHookContext, options: object) => SmrtAwaitable<void>>;
|
|
150
|
+
transform?: SmrtHook<SmrtTransformHandler>;
|
|
151
|
+
shouldTransformCachedModule?: SmrtHook<(this: SmrtHookContext, module: {
|
|
152
|
+
id: string;
|
|
153
|
+
}) => boolean | null | void>;
|
|
154
|
+
configureServer?: SmrtHook<(server: SmrtDevServer) => SmrtAwaitable<void>>;
|
|
155
|
+
resolveId?: SmrtHook<(this: SmrtHookContext, id: string, importer: string | undefined, options: SmrtResolveOptions) => SmrtAwaitable<string | SmrtResolvedId | null | void>>;
|
|
156
|
+
load?: SmrtHook<(this: SmrtHookContext, id: string) => SmrtAwaitable<string | null | void>>;
|
|
157
|
+
transformIndexHtml?: SmrtHook<(html: string, context: {
|
|
158
|
+
path: string;
|
|
159
|
+
filename: string;
|
|
160
|
+
}) => SmrtAwaitable<string>>;
|
|
161
|
+
closeBundle?: SmrtHook<(this: SmrtHookContext) => SmrtAwaitable<void>>;
|
|
162
|
+
}
|
|
163
|
+
export type SmrtPluginOption = SmrtVitePlugin<unknown> | false | null | undefined | SmrtPluginOption[] | Promise<SmrtVitePlugin<unknown> | false | null | undefined | SmrtPluginOption[]>;
|
|
164
|
+
//# sourceMappingURL=plugin-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-contract.d.ts","sourceRoot":"","sources":["../../src/vite-plugin/plugin-contract.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC9C,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC;AAErE,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB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,aAAa,CAAC,MAAM,GAAG,cAAc,GAAG,IAAI,GAAG,IAAI,CAAC,CAC1D,CAAC;IACF,IAAI,CAAC,EAAE,QAAQ,CACb,CAAC,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,KAAK,aAAa,CAAC,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC,CAC3E,CAAC;IACF,kBAAkB,CAAC,EAAE,QAAQ,CAC3B,CACE,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,KACxC,aAAa,CAAC,MAAM,CAAC,CAC3B,CAAC;IACF,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,eAAe,KAAK,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;CACxE;AAED,MAAM,MAAM,gBAAgB,GACxB,cAAc,CAAC,OAAO,CAAC,GACvB,KAAK,GACL,IAAI,GACJ,SAAS,GACT,gBAAgB,EAAE,GAClB,OAAO,CACL,cAAc,CAAC,OAAO,CAAC,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,gBAAgB,EAAE,CACxE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ConfigEnv, Plugin } from 'vite';
|
|
2
1
|
import type { SmartObjectManifest } from '../scanner/types.js';
|
|
2
|
+
import type { SmrtConfigEnv } from './plugin-contract.js';
|
|
3
3
|
import { type SvelteKitOptions } from './sveltekit-generator.js';
|
|
4
4
|
export type SvelteKitRouteOwner = 'producer' | 'consumer';
|
|
5
5
|
interface RouteContribution {
|
|
@@ -30,10 +30,10 @@ type ProjectRootResolver = (userConfig: unknown) => string;
|
|
|
30
30
|
/** Marks an enabled plugin instance so only real same-target participants block
|
|
31
31
|
* the initial shared route transaction. The marker is intentionally private to
|
|
32
32
|
* the plugin objects supplied to one Vite config invocation. */
|
|
33
|
-
export declare function markSvelteKitRouteParticipant(plugin:
|
|
34
|
-
export declare function expectedSvelteKitRouteOwners(userConfig: unknown, projectRoot: string, routesDir: string, env?:
|
|
33
|
+
export declare function markSvelteKitRouteParticipant(plugin: object, owner: SvelteKitRouteOwner, enabled: boolean, routesDir: string, resolveKnowledge?: ProducerKnowledgeResolver, resolveProjectRoot?: ProjectRootResolver): void;
|
|
34
|
+
export declare function expectedSvelteKitRouteOwners(userConfig: unknown, projectRoot: string, routesDir: string, env?: SmrtConfigEnv): Promise<SvelteKitRouteOwner[]>;
|
|
35
35
|
/** Active roots are either one shared target or separate directory owners. */
|
|
36
|
-
export declare function activeSvelteKitRouteParticipants(userConfig: unknown, projectRoot: string, env?:
|
|
36
|
+
export declare function activeSvelteKitRouteParticipants(userConfig: unknown, projectRoot: string, env?: SmrtConfigEnv): Promise<ActiveSvelteKitRouteParticipant[]>;
|
|
37
37
|
/**
|
|
38
38
|
* A durable consumer ownership record can outlive the route configuration
|
|
39
39
|
* that created it. Reconciliation uses this same guard before it sweeps a
|
|
@@ -62,6 +62,6 @@ export declare function assertSvelteKitRouteCoordinationComplete(lifecycle: obje
|
|
|
62
62
|
/** Current producer-owned knowledge handlers, which may sit outside its API root. */
|
|
63
63
|
export declare function producerKnowledgeRoutePaths(lifecycle: object): Set<string>;
|
|
64
64
|
/** Resolve active producer knowledge claims before consumer route mutation. */
|
|
65
|
-
export declare function activeProducerKnowledgeRoutePaths(userConfig: unknown, projectRoot: string, env?:
|
|
65
|
+
export declare function activeProducerKnowledgeRoutePaths(userConfig: unknown, projectRoot: string, env?: SmrtConfigEnv): Promise<Set<string>>;
|
|
66
66
|
export {};
|
|
67
67
|
//# sourceMappingURL=sveltekit-route-coordinator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit-route-coordinator.d.ts","sourceRoot":"","sources":["../../src/vite-plugin/sveltekit-route-coordinator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sveltekit-route-coordinator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BAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAY1E;AAED,+EAA+E;AAC/E,wBAAsB,iCAAiC,CACrD,UAAU,EAAE,OAAO,EACnB,WAAW,EAAE,MAAM,EACnB,GAAG,CAAC,EAAE,aAAa,GAClB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAyBtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit-route-coordinator.js","names":[],"sources":["../../src/vite-plugin/sveltekit-route-coordinator.ts"],"sourcesContent":["import { existsSync, readdirSync, statSync } from 'node:fs';\nimport { join, relative, resolve, sep } from 'node:path';\nimport type { ConfigEnv, Plugin } from 'vite';\nimport type { SmartObjectManifest } from '../scanner/types.js';\nimport {\n assertNoCrossObjectRouteCollisions,\n generateSvelteKitRoutes,\n knowledgeRoutePath,\n type SvelteKitGenerationHooks,\n type SvelteKitOptions,\n type SvelteKitUtilityManifests,\n} from './sveltekit-generator.js';\nimport { canonicalSvelteKitPath } from './sveltekit-path.js';\n\nexport type SvelteKitRouteOwner = 'producer' | 'consumer';\n\nconst ROUTE_PARTICIPANT = Symbol('smrt.sveltekit-route-participant');\nconst coordinators = new WeakMap<object, Map<string, RouteCoordinator>>();\n\ninterface RouteContribution {\n owner: SvelteKitRouteOwner;\n /** Keep the caller's lexical artifact root for its resolved output context. */\n projectRoot: string;\n routeManifest: SmartObjectManifest;\n semanticManifest: SmartObjectManifest;\n options: SvelteKitOptions;\n reservedRoutePaths?: ReadonlySet<string>;\n beforeCleanup?: () => void | Promise<void>;\n afterGenerate?: () => void | Promise<void>;\n}\ntype RouteContributionInput = Omit<RouteContribution, 'projectRoot'>;\n\ninterface RouteCoordinator {\n contributions: Map<SvelteKitRouteOwner, RouteContribution>;\n expectedOwners: Set<SvelteKitRouteOwner>;\n afterRevocation: Array<() => void | Promise<void>>;\n}\n\nexport interface ActiveSvelteKitRouteParticipant {\n owner: SvelteKitRouteOwner;\n projectRoot: string;\n routesDir: string;\n resolveKnowledge?: ProducerKnowledgeResolver;\n}\n\ntype ProducerKnowledgeResolver = (projectRoot: string) => Promise<{\n api?: { enabled?: boolean; basePath?: string };\n}>;\ntype ProjectRootResolver = (userConfig: unknown) => string;\n\n/** Marks an enabled plugin instance so only real same-target participants block\n * the initial shared route transaction. The marker is intentionally private to\n * the plugin objects supplied to one Vite config invocation. */\nexport function markSvelteKitRouteParticipant(\n plugin: Plugin,\n owner: SvelteKitRouteOwner,\n enabled: boolean,\n routesDir: string,\n resolveKnowledge?: ProducerKnowledgeResolver,\n resolveProjectRoot?: ProjectRootResolver,\n): void {\n Object.defineProperty(plugin, ROUTE_PARTICIPANT, {\n value: { owner, enabled, routesDir, resolveKnowledge, resolveProjectRoot },\n enumerable: false,\n });\n}\n\nexport async function expectedSvelteKitRouteOwners(\n userConfig: unknown,\n projectRoot: string,\n routesDir: string,\n env?: ConfigEnv,\n): Promise<SvelteKitRouteOwner[]> {\n const participants = await activeSvelteKitRouteParticipants(\n userConfig,\n projectRoot,\n env,\n );\n assertCompatibleSvelteKitRouteTargets(participants);\n const target = canonicalSvelteKitPath(resolve(projectRoot, routesDir));\n const owners = new Set<SvelteKitRouteOwner>();\n for (const participant of participants) {\n if (participant.routesDir === target) owners.add(participant.owner);\n }\n return [...owners];\n}\n\n/** Mirrors Vite's supported recursive PluginOption normalization for config hooks. */\nasync function flattenPluginOptions(value: unknown): Promise<unknown[]> {\n let values = Array.isArray(value) ? value : [];\n do {\n values = (await Promise.all(values)).flat(Infinity);\n } while (\n values.some(\n (entry) =>\n entry && typeof (entry as Promise<unknown>).then === 'function',\n )\n );\n return values.filter(Boolean);\n}\n\n/** Applies the same supported `Plugin.apply` gate Vite uses before config hooks. */\nfunction appliesToConfig(\n plugin: Plugin,\n userConfig: unknown,\n env: ConfigEnv | undefined,\n): boolean {\n const apply = plugin.apply;\n if (!apply) return true;\n if (!env) return false;\n if (typeof apply === 'function') {\n return apply(\n {\n ...((userConfig as Record<string, unknown> | undefined) ?? {}),\n mode: env.mode,\n },\n env,\n );\n }\n return apply === env.command;\n}\n\n/** Active roots are either one shared target or separate directory owners. */\nexport async function activeSvelteKitRouteParticipants(\n userConfig: unknown,\n projectRoot: string,\n env?: ConfigEnv,\n): Promise<ActiveSvelteKitRouteParticipant[]> {\n const plugins = await flattenPluginOptions(\n (userConfig as { plugins?: unknown } | undefined)?.plugins,\n );\n const participants: ActiveSvelteKitRouteParticipant[] = [];\n for (const plugin of plugins) {\n if (!appliesToConfig(plugin as Plugin, userConfig, env)) continue;\n const participant = (\n plugin as\n | {\n [ROUTE_PARTICIPANT]?: {\n owner: SvelteKitRouteOwner;\n enabled: boolean;\n routesDir: string;\n resolveKnowledge?: ProducerKnowledgeResolver;\n resolveProjectRoot?: ProjectRootResolver;\n };\n }\n | undefined\n )?.[ROUTE_PARTICIPANT];\n if (!participant?.enabled) continue;\n const participantRoot = canonicalSvelteKitPath(\n participant.resolveProjectRoot?.(userConfig) ?? projectRoot,\n );\n participants.push({\n owner: participant.owner,\n projectRoot: participantRoot,\n routesDir: canonicalSvelteKitPath(\n resolve(participantRoot, participant.routesDir),\n ),\n resolveKnowledge: participant.resolveKnowledge,\n });\n }\n return participants;\n}\n\nfunction assertCompatibleSvelteKitRouteTargets(\n participants: ActiveSvelteKitRouteParticipant[],\n): void {\n for (const [index, first] of participants.entries()) {\n for (const second of participants.slice(index + 1)) {\n if (first.routesDir === second.routesDir) continue;\n if (\n second.routesDir.startsWith(`${first.routesDir}${sep}`) ||\n first.routesDir.startsWith(`${second.routesDir}${sep}`)\n ) {\n throw new Error(\n `[smrt] Incompatible nested SvelteKit routesDir ownership: ${JSON.stringify(first.routesDir)} and ${JSON.stringify(second.routesDir)}. Use one shared routesDir or disjoint directories.`,\n );\n }\n }\n }\n assertNoSymlinkedSvelteKitRouteTargetConflicts(participants);\n}\n\n/**\n * Route generation and SvelteKit both traverse directory symlinks. A lexical\n * disjointness check alone therefore cannot let one active route root recurse\n * into another active root during cleanup.\n */\nfunction assertNoSymlinkedSvelteKitRouteTargetConflicts(\n participants: ActiveSvelteKitRouteParticipant[],\n): void {\n for (const participant of participants) {\n const foreignRoots = participants\n .filter(({ routesDir }) => routesDir !== participant.routesDir)\n .map(({ routesDir }) => routesDir);\n if (foreignRoots.length === 0) continue;\n assertRouteTreeDoesNotReachForeignRoot(\n participant.routesDir,\n foreignRoots,\n new Set(),\n );\n }\n}\n\n/**\n * A durable consumer ownership record can outlive the route configuration\n * that created it. Reconciliation uses this same guard before it sweeps a\n * former lexical root, so an old child symlink cannot cross into a current\n * active route surface and make the journal's ownership ambiguous.\n */\nexport function assertNoSvelteKitRouteRootSymlinkConflict(\n routeRoot: string,\n foreignRouteRoots: Iterable<string>,\n): void {\n const foreignRoots = [...foreignRouteRoots].filter(\n (candidate) => candidate !== canonicalSvelteKitPath(routeRoot),\n );\n if (foreignRoots.length === 0) return;\n assertRouteTreeDoesNotReachForeignRoot(routeRoot, foreignRoots, new Set());\n}\n\nfunction assertRouteTreeDoesNotReachForeignRoot(\n routeRoot: string,\n foreignRoots: readonly string[],\n visitedRoots: Set<string>,\n): void {\n const canonicalRoot = canonicalSvelteKitPath(routeRoot);\n if (visitedRoots.has(canonicalRoot) || !existsSync(routeRoot)) return;\n visitedRoots.add(canonicalRoot);\n\n for (const entry of readdirSync(routeRoot, { withFileTypes: true })) {\n const entryPath = join(routeRoot, entry.name);\n if (entry.isDirectory()) {\n assertRouteTreeDoesNotReachForeignRoot(\n entryPath,\n foreignRoots,\n visitedRoots,\n );\n continue;\n }\n if (!entry.isSymbolicLink()) continue;\n try {\n if (!statSync(entryPath).isDirectory()) continue;\n } catch {\n continue;\n }\n const canonicalEntry = canonicalSvelteKitPath(entryPath);\n const foreignRoot = foreignRoots.find((candidate) =>\n svelteKitPathsOverlap(canonicalEntry, candidate),\n );\n if (foreignRoot) {\n throw new Error(\n `[smrt] Incompatible SvelteKit routesDir ownership: ${JSON.stringify(routeRoot)} reaches active ${JSON.stringify(foreignRoot)} through directory symlink ${JSON.stringify(entryPath)}. Use one shared routesDir or disjoint physical directories.`,\n );\n }\n assertRouteTreeDoesNotReachForeignRoot(\n entryPath,\n foreignRoots,\n visitedRoots,\n );\n }\n}\n\nfunction svelteKitPathsOverlap(first: string, second: string): boolean {\n return (\n first === second ||\n first.startsWith(`${second}${sep}`) ||\n second.startsWith(`${first}${sep}`)\n );\n}\n\n/**\n * Bind generated route ownership to one Vite configuration lifecycle. Both\n * SMRT plugins run pre-config hooks, so the later hook regenerates the complete\n * current plan rather than deleting the earlier plugin's route files.\n */\nexport async function contributeSvelteKitRoutes(\n lifecycle: object,\n expectedOwners: Iterable<SvelteKitRouteOwner>,\n projectRoot: string,\n contribution: RouteContributionInput,\n): Promise<void> {\n const target = routeTarget(projectRoot, contribution.options.routesDir);\n const sessions = coordinators.get(lifecycle) ?? new Map();\n coordinators.set(lifecycle, sessions);\n const coordinator =\n sessions.get(target) ??\n ({\n contributions: new Map(),\n expectedOwners: new Set(expectedOwners),\n afterRevocation: [],\n } satisfies RouteCoordinator);\n sessions.set(target, coordinator);\n coordinator.contributions.set(contribution.owner, {\n ...contribution,\n projectRoot,\n });\n\n await generateWhenReady(sessions, coordinator, projectRoot);\n}\n\n/**\n * Reconcile a disabled consumer's formerly hosted route root through the\n * active target transaction. This lets a current producer re-emit its own\n * surface rather than a later consumer cleanup deleting it.\n */\nexport async function revokeSvelteKitRoutes(\n lifecycle: object,\n expectedOwners: Iterable<SvelteKitRouteOwner>,\n projectRoot: string,\n routesDir: string,\n afterGenerate?: () => void | Promise<void>,\n): Promise<void> {\n const target = routeTarget(projectRoot, routesDir);\n const sessions = coordinators.get(lifecycle) ?? new Map();\n coordinators.set(lifecycle, sessions);\n const coordinator =\n sessions.get(target) ??\n ({\n contributions: new Map(),\n expectedOwners: new Set(expectedOwners),\n afterRevocation: [],\n } satisfies RouteCoordinator);\n sessions.set(target, coordinator);\n if (afterGenerate) coordinator.afterRevocation.push(afterGenerate);\n\n await generateWhenReady(sessions, coordinator, projectRoot);\n}\n\n/**\n * Config hooks are the primary synchronization point because SvelteKit reads\n * its route inventory immediately afterwards. This is a fail-closed backstop\n * for Vite configurations where a marked, active peer never ran its hook.\n */\nexport function assertSvelteKitRouteCoordinationComplete(\n lifecycle: object,\n): void {\n for (const [target, coordinator] of coordinators.get(lifecycle) ?? []) {\n const missing = [...coordinator.expectedOwners].filter(\n (owner) => !coordinator.contributions.has(owner),\n );\n if (missing.length === 0) continue;\n throw new Error(\n `[smrt] Incomplete SvelteKit route coordination for ${JSON.stringify(target)}; active ${missing.join(', ')} plugin contribution${missing.length === 1 ? '' : 's'} did not run before config resolution.`,\n );\n }\n}\n\n/** Current producer-owned knowledge handlers, which may sit outside its API root. */\nexport function producerKnowledgeRoutePaths(lifecycle: object): Set<string> {\n const paths = new Set<string>();\n for (const coordinator of coordinators.get(lifecycle)?.values() ?? []) {\n const producer = coordinator.contributions.get('producer');\n if (!producer?.options.knowledge?.api?.enabled) continue;\n paths.add(\n canonicalSvelteKitPath(\n knowledgeRoutePath(producer.projectRoot, producer.options),\n ),\n );\n }\n return paths;\n}\n\n/** Resolve active producer knowledge claims before consumer route mutation. */\nexport async function activeProducerKnowledgeRoutePaths(\n userConfig: unknown,\n projectRoot: string,\n env?: ConfigEnv,\n): Promise<Set<string>> {\n const paths = new Set<string>();\n for (const participant of await activeSvelteKitRouteParticipants(\n userConfig,\n projectRoot,\n env,\n )) {\n if (participant.owner !== 'producer' || !participant.resolveKnowledge)\n continue;\n const knowledge = await participant.resolveKnowledge(\n participant.projectRoot,\n );\n if (!knowledge.api?.enabled) continue;\n paths.add(\n canonicalSvelteKitPath(\n knowledgeRoutePath(participant.projectRoot, {\n enabled: true,\n routesDir: relative(participant.projectRoot, participant.routesDir),\n objectsDir: '',\n knowledge,\n }),\n ),\n );\n }\n return paths;\n}\n\nasync function generateWhenReady(\n sessions: Map<string, RouteCoordinator>,\n coordinator: RouteCoordinator,\n _projectRoot: string,\n): Promise<void> {\n if (\n [...coordinator.expectedOwners].some(\n (owner) => !coordinator.contributions.has(owner),\n )\n )\n return;\n\n const contributions = [...coordinator.contributions.values()];\n const primary = primaryContribution(contributions);\n assertNoForeignKnowledgeRouteCollisions(sessions);\n const registrationContributions = [...sessions.values()].flatMap(\n ({ contributions }) =>\n [...contributions.values()].filter(\n (contribution) =>\n configTarget(contribution.projectRoot, contribution.options) ===\n configTarget(primary.projectRoot, primary.options),\n ),\n );\n const registrationPaths = consumerRegistrationPaths(\n registrationContributions,\n );\n const options = {\n ...mergeOptions(contributions),\n ...(registrationPaths.length > 0\n ? { consumerRegistrationPaths: registrationPaths }\n : {}),\n };\n const hooks: SvelteKitGenerationHooks = {\n beforeCleanup: async () => {\n for (const contribution of contributions) {\n await contribution.beforeCleanup?.();\n }\n },\n };\n await generateSvelteKitRoutes(\n primary.projectRoot,\n mergeManifests(contributions.map(({ routeManifest }) => routeManifest)),\n options,\n mergeManifests(\n contributions.map(({ semanticManifest }) => semanticManifest),\n ),\n utilityManifests(\n contributions,\n protectedProducerKnowledgeRoutePaths(sessions, coordinator),\n new Set(\n [...sessions.entries()]\n .filter(\n ([target, candidate]) =>\n target !==\n routeTarget(primary.projectRoot, primary.options.routesDir) &&\n candidate.contributions.size > 0,\n )\n .map(([target]) => target),\n ),\n ),\n mergeManifests(\n registrationContributions.map(({ routeManifest }) => routeManifest),\n ),\n hooks,\n );\n for (const contribution of contributions) {\n await contribution.afterGenerate?.();\n }\n const afterRevocation = coordinator.afterRevocation.splice(0);\n for (const callback of afterRevocation) await callback();\n}\n\nfunction routeTarget(projectRoot: string, routesDir: string): string {\n return canonicalSvelteKitPath(resolve(projectRoot, routesDir));\n}\n\nfunction configTarget(projectRoot: string, options: SvelteKitOptions): string {\n return canonicalSvelteKitPath(\n resolve(projectRoot, options.configPath || 'src/lib/server'),\n );\n}\n\nfunction effectiveConfigFileName(options: SvelteKitOptions): string {\n return options.configFileName || 'smrt.ts';\n}\n\nfunction consumerRegistrationPaths(\n contributions: RouteContribution[],\n): string[] {\n return [\n ...new Set(\n contributions\n .filter(({ owner }) => owner === 'consumer')\n .map(({ projectRoot }) =>\n canonicalSvelteKitPath(resolve(projectRoot, '.smrt/register.js')),\n ),\n ),\n ].sort();\n}\n\nfunction utilityManifests(\n contributions: RouteContribution[],\n protectedRoutePaths: ReadonlySet<string>,\n protectedRouteRoots: ReadonlySet<string>,\n): SvelteKitUtilityManifests {\n const selected = (key: 'changesRoute' | 'eventsRoute') =>\n contributions.find(({ options }) => options[key]?.enabled !== false) ??\n contributions[0]!;\n const changes = selected('changesRoute');\n const events = selected('eventsRoute');\n return {\n // sync/apply deliberately composes selected targets from every contributor.\n sync: mergeManifests(\n contributions.map(({ routeManifest }) => routeManifest),\n ),\n changes: changes.routeManifest,\n events: events.routeManifest,\n eventsSemantic: events.semanticManifest,\n // Knowledge routes are rooted at the SvelteKit app, rather than an API\n // routesDir. An external consumer must not reconcile a producer-owned\n // knowledge endpoint merely because it emits a separate route target.\n clearKnowledgeRoute: contributions.some(\n ({ options }) => options.knowledge !== undefined,\n ),\n protectedRoutePaths,\n protectedRouteRoots,\n };\n}\n\nfunction producerKnowledgeContributions(\n sessions: Map<string, RouteCoordinator>,\n): RouteContribution[] {\n return [...sessions.values()].flatMap(({ contributions }) =>\n [...contributions.values()].filter(\n (contribution) =>\n contribution.owner === 'producer' &&\n contribution.options.knowledge?.api?.enabled === true,\n ),\n );\n}\n\nfunction foreignProducerKnowledgeRoutePaths(\n sessions: Map<string, RouteCoordinator>,\n current: RouteCoordinator,\n): Set<string> {\n const paths = new Set<string>();\n for (const contribution of producerKnowledgeContributions(sessions)) {\n if (current.contributions.get('producer') === contribution) continue;\n paths.add(\n canonicalSvelteKitPath(\n knowledgeRoutePath(contribution.projectRoot, contribution.options),\n ),\n );\n }\n return paths;\n}\n\nfunction currentProducerKnowledgeRoutePaths(\n coordinator: RouteCoordinator,\n): Set<string> {\n const producer = coordinator.contributions.get('producer');\n if (!producer?.options.knowledge?.api?.enabled) return new Set();\n return new Set([\n canonicalSvelteKitPath(\n knowledgeRoutePath(producer.projectRoot, producer.options),\n ),\n ]);\n}\n\nfunction protectedProducerKnowledgeRoutePaths(\n sessions: Map<string, RouteCoordinator>,\n current: RouteCoordinator,\n): Set<string> {\n const ownPaths = currentProducerKnowledgeRoutePaths(current);\n return new Set([\n ...foreignProducerKnowledgeRoutePaths(sessions, current),\n ...[...current.contributions.values()].flatMap((contribution) =>\n [...(contribution.reservedRoutePaths ?? [])].filter(\n (path) => !ownPaths.has(canonicalSvelteKitPath(path)),\n ),\n ),\n ]);\n}\n\nfunction assertNoForeignKnowledgeRouteCollisions(\n sessions: Map<string, RouteCoordinator>,\n): void {\n const knowledgeContributions = producerKnowledgeContributions(sessions);\n for (const routeCoordinator of sessions.values()) {\n const ownPaths = currentProducerKnowledgeRoutePaths(routeCoordinator);\n for (const contribution of routeCoordinator.contributions.values()) {\n if (!contribution.options.rejectRouteCollisions) continue;\n const foreignPaths = new Set(\n knowledgeContributions\n .filter((knowledge) => knowledge !== contribution)\n .map((knowledge) =>\n canonicalSvelteKitPath(\n knowledgeRoutePath(knowledge.projectRoot, knowledge.options),\n ),\n ),\n );\n for (const path of contribution.reservedRoutePaths ?? []) {\n if (!ownPaths.has(canonicalSvelteKitPath(path))) foreignPaths.add(path);\n }\n if (foreignPaths.size === 0) continue;\n assertNoCrossObjectRouteCollisions(\n contribution.projectRoot,\n contribution.routeManifest,\n contribution.options,\n contribution.semanticManifest,\n foreignPaths,\n );\n }\n }\n}\n\nfunction primaryContribution(\n contributions: RouteContribution[],\n): RouteContribution {\n const primary =\n contributions.find(({ owner }) => owner === 'producer') ?? contributions[0];\n if (!primary) throw new Error('[smrt] Missing SvelteKit route contribution');\n return primary;\n}\n\nfunction mergeOptions(contributions: RouteContribution[]): SvelteKitOptions {\n const primary = primaryContribution(contributions);\n const merged: SvelteKitOptions = { ...primary.options };\n for (const contribution of contributions) {\n const incompatible =\n routeTarget(contribution.projectRoot, contribution.options.routesDir) !==\n routeTarget(primary.projectRoot, primary.options.routesDir) ||\n canonicalSvelteKitPath(\n resolve(contribution.projectRoot, contribution.options.objectsDir),\n ) !==\n canonicalSvelteKitPath(\n resolve(primary.projectRoot, primary.options.objectsDir),\n ) ||\n configTarget(contribution.projectRoot, contribution.options) !==\n configTarget(primary.projectRoot, primary.options) ||\n effectiveConfigFileName(contribution.options) !==\n effectiveConfigFileName(primary.options) ||\n contribution.options.kebabRoutes !== primary.options.kebabRoutes;\n if (incompatible) {\n throw new Error(\n `[smrt] Incompatible SvelteKit route settings for shared routesDir ${JSON.stringify(primary.options.routesDir)}`,\n );\n }\n }\n for (const key of [\n 'changesRoute',\n 'eventsRoute',\n 'resourcesRoute',\n ] as const) {\n const owners = contributions.filter(\n ({ options }) => options[key]?.enabled !== false,\n );\n if (owners.length > 1) {\n throw new Error(\n `[smrt] Conflicting SvelteKit utility route owner for ${key} in shared routesDir ${JSON.stringify(primary.options.routesDir)}`,\n );\n }\n if (owners.length === 1) merged[key] = owners[0]?.options[key];\n }\n // A hosted consumer always requests collision preflight. Preserve that\n // fail-closed policy when the producer provides the primary options.\n merged.rejectRouteCollisions = contributions.some(\n ({ options }) => options.rejectRouteCollisions === true,\n );\n return merged;\n}\n\nfunction mergeManifests(manifests: SmartObjectManifest[]): SmartObjectManifest {\n const first = manifests[0];\n if (!first) throw new Error('[smrt] Missing SvelteKit route manifest');\n const objects: SmartObjectManifest['objects'] = {};\n const dependencies = new Set<string>();\n for (const manifest of manifests) {\n for (const dependency of manifest.smrtDependencies ?? [])\n dependencies.add(dependency);\n for (const [key, objectDef] of Object.entries(manifest.objects)) {\n const existing = objects[key];\n if (existing && JSON.stringify(existing) !== JSON.stringify(objectDef)) {\n throw new Error(\n `[smrt] Conflicting SvelteKit route object definition for ${JSON.stringify(key)}`,\n );\n }\n objects[key] = objectDef;\n }\n }\n return { ...first, objects, smrtDependencies: [...dependencies].sort() };\n}\n"],"mappings":";;;;;AAgBA,IAAM,oBAAoB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IAAI,uBAAuB,KAAK,UAAU,QAAQ,QAAQ,SAAS,GAC7H;EAEF,IAAI,OAAO,WAAW,GAAG,OAAO,OAAO,OAAO,EAAE,EAAE,QAAQ;CAC5D;CAGA,OAAO,wBAAwB,cAAc,MAC1C,EAAE,cAAc,QAAQ,0BAA0B,IACrD;CACA,OAAO;AACT;AAEA,SAAS,eAAe,WAAuD;CAC7E,MAAM,QAAQ,UAAU;CACxB,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,yCAAyC;CACrE,MAAM,UAA0C,CAAC;CACjD,MAAM,+BAAe,IAAI,IAAY;CACrC,KAAK,MAAM,YAAY,WAAW;EAChC,KAAK,MAAM,cAAc,SAAS,oBAAoB,CAAC,GACrD,aAAa,IAAI,UAAU;EAC7B,KAAK,MAAM,CAAC,KAAK,cAAc,OAAO,QAAQ,SAAS,OAAO,GAAG;GAC/D,MAAM,WAAW,QAAQ;GACzB,IAAI,YAAY,KAAK,UAAU,QAAQ,MAAM,KAAK,UAAU,SAAS,GACnE,MAAM,IAAI,MACR,4DAA4D,KAAK,UAAU,GAAG,GAChF;GAEF,QAAQ,OAAO;EACjB;CACF;CACA,OAAO;EAAE,GAAG;EAAO;EAAS,kBAAkB,CAAC,GAAG,YAAY,CAAC,CAAC,KAAK;CAAE;AACzE"}
|
|
1
|
+
{"version":3,"file":"sveltekit-route-coordinator.js","names":[],"sources":["../../src/vite-plugin/sveltekit-route-coordinator.ts"],"sourcesContent":["import { existsSync, readdirSync, statSync } from 'node:fs';\nimport { join, relative, resolve, sep } from 'node:path';\nimport type { SmartObjectManifest } from '../scanner/types.js';\nimport type { SmrtConfigEnv, SmrtVitePlugin } from './plugin-contract.js';\nimport {\n assertNoCrossObjectRouteCollisions,\n generateSvelteKitRoutes,\n knowledgeRoutePath,\n type SvelteKitGenerationHooks,\n type SvelteKitOptions,\n type SvelteKitUtilityManifests,\n} from './sveltekit-generator.js';\nimport { canonicalSvelteKitPath } from './sveltekit-path.js';\n\nexport type SvelteKitRouteOwner = 'producer' | 'consumer';\n\nconst ROUTE_PARTICIPANT = Symbol('smrt.sveltekit-route-participant');\nconst coordinators = new WeakMap<object, Map<string, RouteCoordinator>>();\n\ninterface RouteContribution {\n owner: SvelteKitRouteOwner;\n /** Keep the caller's lexical artifact root for its resolved output context. */\n projectRoot: string;\n routeManifest: SmartObjectManifest;\n semanticManifest: SmartObjectManifest;\n options: SvelteKitOptions;\n reservedRoutePaths?: ReadonlySet<string>;\n beforeCleanup?: () => void | Promise<void>;\n afterGenerate?: () => void | Promise<void>;\n}\ntype RouteContributionInput = Omit<RouteContribution, 'projectRoot'>;\n\ninterface RouteCoordinator {\n contributions: Map<SvelteKitRouteOwner, RouteContribution>;\n expectedOwners: Set<SvelteKitRouteOwner>;\n afterRevocation: Array<() => void | Promise<void>>;\n}\n\nexport interface ActiveSvelteKitRouteParticipant {\n owner: SvelteKitRouteOwner;\n projectRoot: string;\n routesDir: string;\n resolveKnowledge?: ProducerKnowledgeResolver;\n}\n\ntype ProducerKnowledgeResolver = (projectRoot: string) => Promise<{\n api?: { enabled?: boolean; basePath?: string };\n}>;\ntype ProjectRootResolver = (userConfig: unknown) => string;\n\n/** Marks an enabled plugin instance so only real same-target participants block\n * the initial shared route transaction. The marker is intentionally private to\n * the plugin objects supplied to one Vite config invocation. */\nexport function markSvelteKitRouteParticipant(\n plugin: object,\n owner: SvelteKitRouteOwner,\n enabled: boolean,\n routesDir: string,\n resolveKnowledge?: ProducerKnowledgeResolver,\n resolveProjectRoot?: ProjectRootResolver,\n): void {\n Object.defineProperty(plugin, ROUTE_PARTICIPANT, {\n value: { owner, enabled, routesDir, resolveKnowledge, resolveProjectRoot },\n enumerable: false,\n });\n}\n\nexport async function expectedSvelteKitRouteOwners(\n userConfig: unknown,\n projectRoot: string,\n routesDir: string,\n env?: SmrtConfigEnv,\n): Promise<SvelteKitRouteOwner[]> {\n const participants = await activeSvelteKitRouteParticipants(\n userConfig,\n projectRoot,\n env,\n );\n assertCompatibleSvelteKitRouteTargets(participants);\n const target = canonicalSvelteKitPath(resolve(projectRoot, routesDir));\n const owners = new Set<SvelteKitRouteOwner>();\n for (const participant of participants) {\n if (participant.routesDir === target) owners.add(participant.owner);\n }\n return [...owners];\n}\n\n/** Mirrors Vite's supported recursive PluginOption normalization for config hooks. */\nasync function flattenPluginOptions(value: unknown): Promise<unknown[]> {\n let values = Array.isArray(value) ? value : [];\n do {\n values = (await Promise.all(values)).flat(Infinity);\n } while (\n values.some(\n (entry) =>\n entry && typeof (entry as Promise<unknown>).then === 'function',\n )\n );\n return values.filter(Boolean);\n}\n\n/** Applies the same supported `Plugin.apply` gate Vite uses before config hooks. */\nfunction appliesToConfig(\n plugin: SmrtVitePlugin<unknown>,\n userConfig: unknown,\n env: SmrtConfigEnv | undefined,\n): boolean {\n const apply = plugin.apply;\n if (!apply) return true;\n if (!env) return false;\n if (typeof apply === 'function') {\n return apply(\n {\n ...((userConfig as Record<string, unknown> | undefined) ?? {}),\n mode: env.mode,\n },\n env,\n );\n }\n return apply === env.command;\n}\n\n/** Active roots are either one shared target or separate directory owners. */\nexport async function activeSvelteKitRouteParticipants(\n userConfig: unknown,\n projectRoot: string,\n env?: SmrtConfigEnv,\n): Promise<ActiveSvelteKitRouteParticipant[]> {\n const plugins = await flattenPluginOptions(\n (userConfig as { plugins?: unknown } | undefined)?.plugins,\n );\n const participants: ActiveSvelteKitRouteParticipant[] = [];\n for (const plugin of plugins) {\n if (!appliesToConfig(plugin as SmrtVitePlugin<unknown>, userConfig, env))\n continue;\n const participant = (\n plugin as\n | {\n [ROUTE_PARTICIPANT]?: {\n owner: SvelteKitRouteOwner;\n enabled: boolean;\n routesDir: string;\n resolveKnowledge?: ProducerKnowledgeResolver;\n resolveProjectRoot?: ProjectRootResolver;\n };\n }\n | undefined\n )?.[ROUTE_PARTICIPANT];\n if (!participant?.enabled) continue;\n const participantRoot = canonicalSvelteKitPath(\n participant.resolveProjectRoot?.(userConfig) ?? projectRoot,\n );\n participants.push({\n owner: participant.owner,\n projectRoot: participantRoot,\n routesDir: canonicalSvelteKitPath(\n resolve(participantRoot, participant.routesDir),\n ),\n resolveKnowledge: participant.resolveKnowledge,\n });\n }\n return participants;\n}\n\nfunction assertCompatibleSvelteKitRouteTargets(\n participants: ActiveSvelteKitRouteParticipant[],\n): void {\n for (const [index, first] of participants.entries()) {\n for (const second of participants.slice(index + 1)) {\n if (first.routesDir === second.routesDir) continue;\n if (\n second.routesDir.startsWith(`${first.routesDir}${sep}`) ||\n first.routesDir.startsWith(`${second.routesDir}${sep}`)\n ) {\n throw new Error(\n `[smrt] Incompatible nested SvelteKit routesDir ownership: ${JSON.stringify(first.routesDir)} and ${JSON.stringify(second.routesDir)}. Use one shared routesDir or disjoint directories.`,\n );\n }\n }\n }\n assertNoSymlinkedSvelteKitRouteTargetConflicts(participants);\n}\n\n/**\n * Route generation and SvelteKit both traverse directory symlinks. A lexical\n * disjointness check alone therefore cannot let one active route root recurse\n * into another active root during cleanup.\n */\nfunction assertNoSymlinkedSvelteKitRouteTargetConflicts(\n participants: ActiveSvelteKitRouteParticipant[],\n): void {\n for (const participant of participants) {\n const foreignRoots = participants\n .filter(({ routesDir }) => routesDir !== participant.routesDir)\n .map(({ routesDir }) => routesDir);\n if (foreignRoots.length === 0) continue;\n assertRouteTreeDoesNotReachForeignRoot(\n participant.routesDir,\n foreignRoots,\n new Set(),\n );\n }\n}\n\n/**\n * A durable consumer ownership record can outlive the route configuration\n * that created it. Reconciliation uses this same guard before it sweeps a\n * former lexical root, so an old child symlink cannot cross into a current\n * active route surface and make the journal's ownership ambiguous.\n */\nexport function assertNoSvelteKitRouteRootSymlinkConflict(\n routeRoot: string,\n foreignRouteRoots: Iterable<string>,\n): void {\n const foreignRoots = [...foreignRouteRoots].filter(\n (candidate) => candidate !== canonicalSvelteKitPath(routeRoot),\n );\n if (foreignRoots.length === 0) return;\n assertRouteTreeDoesNotReachForeignRoot(routeRoot, foreignRoots, new Set());\n}\n\nfunction assertRouteTreeDoesNotReachForeignRoot(\n routeRoot: string,\n foreignRoots: readonly string[],\n visitedRoots: Set<string>,\n): void {\n const canonicalRoot = canonicalSvelteKitPath(routeRoot);\n if (visitedRoots.has(canonicalRoot) || !existsSync(routeRoot)) return;\n visitedRoots.add(canonicalRoot);\n\n for (const entry of readdirSync(routeRoot, { withFileTypes: true })) {\n const entryPath = join(routeRoot, entry.name);\n if (entry.isDirectory()) {\n assertRouteTreeDoesNotReachForeignRoot(\n entryPath,\n foreignRoots,\n visitedRoots,\n );\n continue;\n }\n if (!entry.isSymbolicLink()) continue;\n try {\n if (!statSync(entryPath).isDirectory()) continue;\n } catch {\n continue;\n }\n const canonicalEntry = canonicalSvelteKitPath(entryPath);\n const foreignRoot = foreignRoots.find((candidate) =>\n svelteKitPathsOverlap(canonicalEntry, candidate),\n );\n if (foreignRoot) {\n throw new Error(\n `[smrt] Incompatible SvelteKit routesDir ownership: ${JSON.stringify(routeRoot)} reaches active ${JSON.stringify(foreignRoot)} through directory symlink ${JSON.stringify(entryPath)}. Use one shared routesDir or disjoint physical directories.`,\n );\n }\n assertRouteTreeDoesNotReachForeignRoot(\n entryPath,\n foreignRoots,\n visitedRoots,\n );\n }\n}\n\nfunction svelteKitPathsOverlap(first: string, second: string): boolean {\n return (\n first === second ||\n first.startsWith(`${second}${sep}`) ||\n second.startsWith(`${first}${sep}`)\n );\n}\n\n/**\n * Bind generated route ownership to one Vite configuration lifecycle. Both\n * SMRT plugins run pre-config hooks, so the later hook regenerates the complete\n * current plan rather than deleting the earlier plugin's route files.\n */\nexport async function contributeSvelteKitRoutes(\n lifecycle: object,\n expectedOwners: Iterable<SvelteKitRouteOwner>,\n projectRoot: string,\n contribution: RouteContributionInput,\n): Promise<void> {\n const target = routeTarget(projectRoot, contribution.options.routesDir);\n const sessions = coordinators.get(lifecycle) ?? new Map();\n coordinators.set(lifecycle, sessions);\n const coordinator =\n sessions.get(target) ??\n ({\n contributions: new Map(),\n expectedOwners: new Set(expectedOwners),\n afterRevocation: [],\n } satisfies RouteCoordinator);\n sessions.set(target, coordinator);\n coordinator.contributions.set(contribution.owner, {\n ...contribution,\n projectRoot,\n });\n\n await generateWhenReady(sessions, coordinator, projectRoot);\n}\n\n/**\n * Reconcile a disabled consumer's formerly hosted route root through the\n * active target transaction. This lets a current producer re-emit its own\n * surface rather than a later consumer cleanup deleting it.\n */\nexport async function revokeSvelteKitRoutes(\n lifecycle: object,\n expectedOwners: Iterable<SvelteKitRouteOwner>,\n projectRoot: string,\n routesDir: string,\n afterGenerate?: () => void | Promise<void>,\n): Promise<void> {\n const target = routeTarget(projectRoot, routesDir);\n const sessions = coordinators.get(lifecycle) ?? new Map();\n coordinators.set(lifecycle, sessions);\n const coordinator =\n sessions.get(target) ??\n ({\n contributions: new Map(),\n expectedOwners: new Set(expectedOwners),\n afterRevocation: [],\n } satisfies RouteCoordinator);\n sessions.set(target, coordinator);\n if (afterGenerate) coordinator.afterRevocation.push(afterGenerate);\n\n await generateWhenReady(sessions, coordinator, projectRoot);\n}\n\n/**\n * Config hooks are the primary synchronization point because SvelteKit reads\n * its route inventory immediately afterwards. This is a fail-closed backstop\n * for Vite configurations where a marked, active peer never ran its hook.\n */\nexport function assertSvelteKitRouteCoordinationComplete(\n lifecycle: object,\n): void {\n for (const [target, coordinator] of coordinators.get(lifecycle) ?? []) {\n const missing = [...coordinator.expectedOwners].filter(\n (owner) => !coordinator.contributions.has(owner),\n );\n if (missing.length === 0) continue;\n throw new Error(\n `[smrt] Incomplete SvelteKit route coordination for ${JSON.stringify(target)}; active ${missing.join(', ')} plugin contribution${missing.length === 1 ? '' : 's'} did not run before config resolution.`,\n );\n }\n}\n\n/** Current producer-owned knowledge handlers, which may sit outside its API root. */\nexport function producerKnowledgeRoutePaths(lifecycle: object): Set<string> {\n const paths = new Set<string>();\n for (const coordinator of coordinators.get(lifecycle)?.values() ?? []) {\n const producer = coordinator.contributions.get('producer');\n if (!producer?.options.knowledge?.api?.enabled) continue;\n paths.add(\n canonicalSvelteKitPath(\n knowledgeRoutePath(producer.projectRoot, producer.options),\n ),\n );\n }\n return paths;\n}\n\n/** Resolve active producer knowledge claims before consumer route mutation. */\nexport async function activeProducerKnowledgeRoutePaths(\n userConfig: unknown,\n projectRoot: string,\n env?: SmrtConfigEnv,\n): Promise<Set<string>> {\n const paths = new Set<string>();\n for (const participant of await activeSvelteKitRouteParticipants(\n userConfig,\n projectRoot,\n env,\n )) {\n if (participant.owner !== 'producer' || !participant.resolveKnowledge)\n continue;\n const knowledge = await participant.resolveKnowledge(\n participant.projectRoot,\n );\n if (!knowledge.api?.enabled) continue;\n paths.add(\n canonicalSvelteKitPath(\n knowledgeRoutePath(participant.projectRoot, {\n enabled: true,\n routesDir: relative(participant.projectRoot, participant.routesDir),\n objectsDir: '',\n knowledge,\n }),\n ),\n );\n }\n return paths;\n}\n\nasync function generateWhenReady(\n sessions: Map<string, RouteCoordinator>,\n coordinator: RouteCoordinator,\n _projectRoot: string,\n): Promise<void> {\n if (\n [...coordinator.expectedOwners].some(\n (owner) => !coordinator.contributions.has(owner),\n )\n )\n return;\n\n const contributions = [...coordinator.contributions.values()];\n const primary = primaryContribution(contributions);\n assertNoForeignKnowledgeRouteCollisions(sessions);\n const registrationContributions = [...sessions.values()].flatMap(\n ({ contributions }) =>\n [...contributions.values()].filter(\n (contribution) =>\n configTarget(contribution.projectRoot, contribution.options) ===\n configTarget(primary.projectRoot, primary.options),\n ),\n );\n const registrationPaths = consumerRegistrationPaths(\n registrationContributions,\n );\n const options = {\n ...mergeOptions(contributions),\n ...(registrationPaths.length > 0\n ? { consumerRegistrationPaths: registrationPaths }\n : {}),\n };\n const hooks: SvelteKitGenerationHooks = {\n beforeCleanup: async () => {\n for (const contribution of contributions) {\n await contribution.beforeCleanup?.();\n }\n },\n };\n await generateSvelteKitRoutes(\n primary.projectRoot,\n mergeManifests(contributions.map(({ routeManifest }) => routeManifest)),\n options,\n mergeManifests(\n contributions.map(({ semanticManifest }) => semanticManifest),\n ),\n utilityManifests(\n contributions,\n protectedProducerKnowledgeRoutePaths(sessions, coordinator),\n new Set(\n [...sessions.entries()]\n .filter(\n ([target, candidate]) =>\n target !==\n routeTarget(primary.projectRoot, primary.options.routesDir) &&\n candidate.contributions.size > 0,\n )\n .map(([target]) => target),\n ),\n ),\n mergeManifests(\n registrationContributions.map(({ routeManifest }) => routeManifest),\n ),\n hooks,\n );\n for (const contribution of contributions) {\n await contribution.afterGenerate?.();\n }\n const afterRevocation = coordinator.afterRevocation.splice(0);\n for (const callback of afterRevocation) await callback();\n}\n\nfunction routeTarget(projectRoot: string, routesDir: string): string {\n return canonicalSvelteKitPath(resolve(projectRoot, routesDir));\n}\n\nfunction configTarget(projectRoot: string, options: SvelteKitOptions): string {\n return canonicalSvelteKitPath(\n resolve(projectRoot, options.configPath || 'src/lib/server'),\n );\n}\n\nfunction effectiveConfigFileName(options: SvelteKitOptions): string {\n return options.configFileName || 'smrt.ts';\n}\n\nfunction consumerRegistrationPaths(\n contributions: RouteContribution[],\n): string[] {\n return [\n ...new Set(\n contributions\n .filter(({ owner }) => owner === 'consumer')\n .map(({ projectRoot }) =>\n canonicalSvelteKitPath(resolve(projectRoot, '.smrt/register.js')),\n ),\n ),\n ].sort();\n}\n\nfunction utilityManifests(\n contributions: RouteContribution[],\n protectedRoutePaths: ReadonlySet<string>,\n protectedRouteRoots: ReadonlySet<string>,\n): SvelteKitUtilityManifests {\n const selected = (key: 'changesRoute' | 'eventsRoute') =>\n contributions.find(({ options }) => options[key]?.enabled !== false) ??\n contributions[0]!;\n const changes = selected('changesRoute');\n const events = selected('eventsRoute');\n return {\n // sync/apply deliberately composes selected targets from every contributor.\n sync: mergeManifests(\n contributions.map(({ routeManifest }) => routeManifest),\n ),\n changes: changes.routeManifest,\n events: events.routeManifest,\n eventsSemantic: events.semanticManifest,\n // Knowledge routes are rooted at the SvelteKit app, rather than an API\n // routesDir. An external consumer must not reconcile a producer-owned\n // knowledge endpoint merely because it emits a separate route target.\n clearKnowledgeRoute: contributions.some(\n ({ options }) => options.knowledge !== undefined,\n ),\n protectedRoutePaths,\n protectedRouteRoots,\n };\n}\n\nfunction producerKnowledgeContributions(\n sessions: Map<string, RouteCoordinator>,\n): RouteContribution[] {\n return [...sessions.values()].flatMap(({ contributions }) =>\n [...contributions.values()].filter(\n (contribution) =>\n contribution.owner === 'producer' &&\n contribution.options.knowledge?.api?.enabled === true,\n ),\n );\n}\n\nfunction foreignProducerKnowledgeRoutePaths(\n sessions: Map<string, RouteCoordinator>,\n current: RouteCoordinator,\n): Set<string> {\n const paths = new Set<string>();\n for (const contribution of producerKnowledgeContributions(sessions)) {\n if (current.contributions.get('producer') === contribution) continue;\n paths.add(\n canonicalSvelteKitPath(\n knowledgeRoutePath(contribution.projectRoot, contribution.options),\n ),\n );\n }\n return paths;\n}\n\nfunction currentProducerKnowledgeRoutePaths(\n coordinator: RouteCoordinator,\n): Set<string> {\n const producer = coordinator.contributions.get('producer');\n if (!producer?.options.knowledge?.api?.enabled) return new Set();\n return new Set([\n canonicalSvelteKitPath(\n knowledgeRoutePath(producer.projectRoot, producer.options),\n ),\n ]);\n}\n\nfunction protectedProducerKnowledgeRoutePaths(\n sessions: Map<string, RouteCoordinator>,\n current: RouteCoordinator,\n): Set<string> {\n const ownPaths = currentProducerKnowledgeRoutePaths(current);\n return new Set([\n ...foreignProducerKnowledgeRoutePaths(sessions, current),\n ...[...current.contributions.values()].flatMap((contribution) =>\n [...(contribution.reservedRoutePaths ?? [])].filter(\n (path) => !ownPaths.has(canonicalSvelteKitPath(path)),\n ),\n ),\n ]);\n}\n\nfunction assertNoForeignKnowledgeRouteCollisions(\n sessions: Map<string, RouteCoordinator>,\n): void {\n const knowledgeContributions = producerKnowledgeContributions(sessions);\n for (const routeCoordinator of sessions.values()) {\n const ownPaths = currentProducerKnowledgeRoutePaths(routeCoordinator);\n for (const contribution of routeCoordinator.contributions.values()) {\n if (!contribution.options.rejectRouteCollisions) continue;\n const foreignPaths = new Set(\n knowledgeContributions\n .filter((knowledge) => knowledge !== contribution)\n .map((knowledge) =>\n canonicalSvelteKitPath(\n knowledgeRoutePath(knowledge.projectRoot, knowledge.options),\n ),\n ),\n );\n for (const path of contribution.reservedRoutePaths ?? []) {\n if (!ownPaths.has(canonicalSvelteKitPath(path))) foreignPaths.add(path);\n }\n if (foreignPaths.size === 0) continue;\n assertNoCrossObjectRouteCollisions(\n contribution.projectRoot,\n contribution.routeManifest,\n contribution.options,\n contribution.semanticManifest,\n foreignPaths,\n );\n }\n }\n}\n\nfunction primaryContribution(\n contributions: RouteContribution[],\n): RouteContribution {\n const primary =\n contributions.find(({ owner }) => owner === 'producer') ?? contributions[0];\n if (!primary) throw new Error('[smrt] Missing SvelteKit route contribution');\n return primary;\n}\n\nfunction mergeOptions(contributions: RouteContribution[]): SvelteKitOptions {\n const primary = primaryContribution(contributions);\n const merged: SvelteKitOptions = { ...primary.options };\n for (const contribution of contributions) {\n const incompatible =\n routeTarget(contribution.projectRoot, contribution.options.routesDir) !==\n routeTarget(primary.projectRoot, primary.options.routesDir) ||\n canonicalSvelteKitPath(\n resolve(contribution.projectRoot, contribution.options.objectsDir),\n ) !==\n canonicalSvelteKitPath(\n resolve(primary.projectRoot, primary.options.objectsDir),\n ) ||\n configTarget(contribution.projectRoot, contribution.options) !==\n configTarget(primary.projectRoot, primary.options) ||\n effectiveConfigFileName(contribution.options) !==\n effectiveConfigFileName(primary.options) ||\n contribution.options.kebabRoutes !== primary.options.kebabRoutes;\n if (incompatible) {\n throw new Error(\n `[smrt] Incompatible SvelteKit route settings for shared routesDir ${JSON.stringify(primary.options.routesDir)}`,\n );\n }\n }\n for (const key of [\n 'changesRoute',\n 'eventsRoute',\n 'resourcesRoute',\n ] as const) {\n const owners = contributions.filter(\n ({ options }) => options[key]?.enabled !== false,\n );\n if (owners.length > 1) {\n throw new Error(\n `[smrt] Conflicting SvelteKit utility route owner for ${key} in shared routesDir ${JSON.stringify(primary.options.routesDir)}`,\n );\n }\n if (owners.length === 1) merged[key] = owners[0]?.options[key];\n }\n // A hosted consumer always requests collision preflight. Preserve that\n // fail-closed policy when the producer provides the primary options.\n merged.rejectRouteCollisions = contributions.some(\n ({ options }) => options.rejectRouteCollisions === true,\n );\n return merged;\n}\n\nfunction mergeManifests(manifests: SmartObjectManifest[]): SmartObjectManifest {\n const first = manifests[0];\n if (!first) throw new Error('[smrt] Missing SvelteKit route manifest');\n const objects: SmartObjectManifest['objects'] = {};\n const dependencies = new Set<string>();\n for (const manifest of manifests) {\n for (const dependency of manifest.smrtDependencies ?? [])\n dependencies.add(dependency);\n for (const [key, objectDef] of Object.entries(manifest.objects)) {\n const existing = objects[key];\n if (existing && JSON.stringify(existing) !== JSON.stringify(objectDef)) {\n throw new Error(\n `[smrt] Conflicting SvelteKit route object definition for ${JSON.stringify(key)}`,\n );\n }\n objects[key] = objectDef;\n }\n }\n return { ...first, objects, smrtDependencies: [...dependencies].sort() };\n}\n"],"mappings":";;;;;AAgBA,IAAM,oBAAoB,OAAO,kCAAkC;AACnE,IAAM,+BAAe,IAAI,QAA+C;;;;AAoCxE,SAAgB,8BACd,QACA,OACA,SACA,WACA,kBACA,oBACM;CACN,OAAO,eAAe,QAAQ,mBAAmB;EAC/C,OAAO;GAAE;GAAO;GAAS;GAAW;GAAkB;EAAmB;EACzE,YAAY;CACd,CAAC;AACH;AAEA,eAAsB,6BACpB,YACA,aACA,WACA,KACgC;CAChC,MAAM,eAAe,MAAM,iCACzB,YACA,aACA,GACF;CACA,sCAAsC,YAAY;CAClD,MAAM,SAAS,uBAAuB,QAAQ,aAAa,SAAS,CAAC;CACrE,MAAM,yBAAS,IAAI,IAAyB;CAC5C,KAAK,MAAM,eAAe,cACxB,IAAI,YAAY,cAAc,QAAQ,OAAO,IAAI,YAAY,KAAK;CAEpE,OAAO,CAAC,GAAG,MAAM;AACnB;;AAGA,eAAe,qBAAqB,OAAoC;CACtE,IAAI,SAAS,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC;CAC7C;EACE,UAAU,MAAM,QAAQ,IAA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R,4DAA4D,KAAK,UAAU,GAAG,GAChF;GAEF,QAAQ,OAAO;EACjB;CACF;CACA,OAAO;EAAE,GAAG;EAAO;EAAS,kBAAkB,CAAC,GAAG,YAAY,CAAC,CAAC,KAAK;CAAE;AACzE"}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* artifact bundles it. `@happyvertical/*` packages stay external so the worker
|
|
21
21
|
* and `@happyvertical/smrt-core` share one registry.
|
|
22
22
|
*/
|
|
23
|
-
import type {
|
|
23
|
+
import type { SmrtAlias, SmrtResolvedConfig } from './plugin-contract.js';
|
|
24
24
|
/** Directory (under the project root) the compiled registration is written to. */
|
|
25
25
|
export declare const WORKER_REGISTRATION_DIR = ".smrt/runtime";
|
|
26
26
|
/** Entry file name inside {@link WORKER_REGISTRATION_DIR}. */
|
|
@@ -33,19 +33,19 @@ export declare const WORKER_REGISTRATION_PATH = ".smrt/runtime/register.js";
|
|
|
33
33
|
* are dropped: the compiled registration must import packages exactly as the
|
|
34
34
|
* deployed process resolves them, from `node_modules`.
|
|
35
35
|
*/
|
|
36
|
-
export declare function projectSourceAliases(projectRoot: string, aliases: readonly
|
|
36
|
+
export declare function projectSourceAliases(projectRoot: string, aliases: readonly SmrtAlias[] | undefined): SmrtAlias[];
|
|
37
37
|
/**
|
|
38
38
|
* Rollup `external` predicate: bundle relative, absolute (resolved), virtual,
|
|
39
39
|
* and project-alias imports; keep every other bare specifier external.
|
|
40
40
|
*/
|
|
41
|
-
export declare function createWorkerRegistrationExternal(aliases: readonly
|
|
41
|
+
export declare function createWorkerRegistrationExternal(aliases: readonly SmrtAlias[]): (id: string) => boolean;
|
|
42
42
|
export interface BuildWorkerRegistrationOptions {
|
|
43
43
|
/** The application root (where `.smrt/` lives). */
|
|
44
44
|
projectRoot: string;
|
|
45
45
|
/** The generated `smrt-register.ts` to compile. */
|
|
46
46
|
registrationFile: string;
|
|
47
47
|
/** The consumer build's resolved config (aliases, decorator transform, mode). */
|
|
48
|
-
resolvedConfig: Pick<
|
|
48
|
+
resolvedConfig: Pick<SmrtResolvedConfig, 'mode' | 'oxc' | 'resolve'>;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Compile the generated registration into `.smrt/runtime/register.js`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-registration.d.ts","sourceRoot":"","sources":["../../src/vite-plugin/worker-registration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;
|
|
1
|
+
{"version":3,"file":"worker-registration.d.ts","sourceRoot":"","sources":["../../src/vite-plugin/worker-registration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1E,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AAEvD,8DAA8D;AAC9D,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AAEvD,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,8BAA4D,CAAC;AASlG;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,GACxC,SAAS,EAAE,CAOb;AASD;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,SAAS,SAAS,EAAE,GAC5B,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAiBzB;AAED,MAAM,WAAW,8BAA8B;IAC7C,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,CAAC;IACzB,iFAAiF;IACjF,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC,CAAC;CACtE;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,MAAM,CAAC,CA2CjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-registration.js","names":[],"sources":["../../src/vite-plugin/worker-registration.ts"],"sourcesContent":["/**\n * Compiled application registration for out-of-bundle Node processes (#3117).\n *\n * A SvelteKit app registers its own `@smrt()` objects through the generated\n * `smrt-register.ts`, which only the Vite build compiles — and adapter-node\n * re-bundles the server from its own entries, so that module never exists as\n * an importable file in `build/`. A deployed task or schedule worker is plain\n * ESM run by `node`, so without this artifact `ObjectRegistry.getClass()`\n * cannot resolve any application object and every app-defined job throws\n * `Unknown object type` before its method runs.\n *\n * After a production build, this compiles that same generated module into\n * `.smrt/runtime/register.js`: one ESM entry that registers the app's local\n * objects AND its consumed packages' objects (via the `.smrt/register.js` it\n * imports), with each class's package-qualified identity and isolated\n * manifest exactly as the web server registers them. Application sources are\n * bundled; package imports stay external and are resolved from `node_modules`\n * at runtime, except Oxc's decorator helper. Oxc injects that helper into\n * transformed application classes but applications do not declare it, so the\n * artifact bundles it. `@happyvertical/*` packages stay external so the worker\n * and `@happyvertical/smrt-core` share one registry.\n */\n\nimport { isAbsolute, join, relative, resolve } from 'node:path';\nimport
|
|
1
|
+
{"version":3,"file":"worker-registration.js","names":[],"sources":["../../src/vite-plugin/worker-registration.ts"],"sourcesContent":["/**\n * Compiled application registration for out-of-bundle Node processes (#3117).\n *\n * A SvelteKit app registers its own `@smrt()` objects through the generated\n * `smrt-register.ts`, which only the Vite build compiles — and adapter-node\n * re-bundles the server from its own entries, so that module never exists as\n * an importable file in `build/`. A deployed task or schedule worker is plain\n * ESM run by `node`, so without this artifact `ObjectRegistry.getClass()`\n * cannot resolve any application object and every app-defined job throws\n * `Unknown object type` before its method runs.\n *\n * After a production build, this compiles that same generated module into\n * `.smrt/runtime/register.js`: one ESM entry that registers the app's local\n * objects AND its consumed packages' objects (via the `.smrt/register.js` it\n * imports), with each class's package-qualified identity and isolated\n * manifest exactly as the web server registers them. Application sources are\n * bundled; package imports stay external and are resolved from `node_modules`\n * at runtime, except Oxc's decorator helper. Oxc injects that helper into\n * transformed application classes but applications do not declare it, so the\n * artifact bundles it. `@happyvertical/*` packages stay external so the worker\n * and `@happyvertical/smrt-core` share one registry.\n */\n\nimport { isAbsolute, join, relative, resolve } from 'node:path';\nimport { importProjectVite } from '../utils/import-project-vite.js';\nimport type { SmrtAlias, SmrtResolvedConfig } from './plugin-contract.js';\n\n/** Directory (under the project root) the compiled registration is written to. */\nexport const WORKER_REGISTRATION_DIR = '.smrt/runtime';\n\n/** Entry file name inside {@link WORKER_REGISTRATION_DIR}. */\nexport const WORKER_REGISTRATION_ENTRY = 'register.js';\n\n/** Project-relative path a worker imports: `.smrt/runtime/register.js`. */\nexport const WORKER_REGISTRATION_PATH = `${WORKER_REGISTRATION_DIR}/${WORKER_REGISTRATION_ENTRY}`;\n\n/** Is `child` the project root or inside it (and not under node_modules)? */\nfunction isProjectSource(projectRoot: string, child: string): boolean {\n const rel = relative(projectRoot, child);\n if (rel.startsWith('..') || isAbsolute(rel)) return false;\n return !rel.split(/[\\\\/]/).includes('node_modules');\n}\n\n/**\n * The resolved aliases that point at the application's own sources (e.g.\n * SvelteKit's `$lib` → `src/lib`). Aliases that map a package name elsewhere\n * are dropped: the compiled registration must import packages exactly as the\n * deployed process resolves them, from `node_modules`.\n */\nexport function projectSourceAliases(\n projectRoot: string,\n aliases: readonly SmrtAlias[] | undefined,\n): SmrtAlias[] {\n return (aliases ?? []).filter(\n (alias) =>\n typeof alias.replacement === 'string' &&\n isAbsolute(alias.replacement) &&\n isProjectSource(projectRoot, alias.replacement),\n );\n}\n\nfunction matchesAlias(id: string, alias: SmrtAlias): boolean {\n const { find } = alias;\n if (typeof find === 'string') return id === find || id.startsWith(`${find}/`);\n find.lastIndex = 0;\n return find.test(id);\n}\n\n/**\n * Rollup `external` predicate: bundle relative, absolute (resolved), virtual,\n * and project-alias imports; keep every other bare specifier external.\n */\nexport function createWorkerRegistrationExternal(\n aliases: readonly SmrtAlias[],\n): (id: string) => boolean {\n return (id) => {\n if (id.startsWith('.') || id.startsWith('\\0') || isAbsolute(id)) {\n return false;\n }\n if (aliases.some((alias) => matchesAlias(id, alias))) return false;\n // Vite/Oxc lowers legacy decorators to imports from this package. It is a\n // core build dependency, not a consumer dependency, so bundle its root and\n // helper subpaths into the standalone worker artifact.\n if (\n id === '@oxc-project/runtime' ||\n id.startsWith('@oxc-project/runtime/')\n ) {\n return false;\n }\n return true;\n };\n}\n\nexport interface BuildWorkerRegistrationOptions {\n /** The application root (where `.smrt/` lives). */\n projectRoot: string;\n /** The generated `smrt-register.ts` to compile. */\n registrationFile: string;\n /** The consumer build's resolved config (aliases, decorator transform, mode). */\n resolvedConfig: Pick<SmrtResolvedConfig, 'mode' | 'oxc' | 'resolve'>;\n}\n\n/**\n * Compile the generated registration into `.smrt/runtime/register.js`.\n * Returns the absolute output path. Throws on failure: a worker without it\n * cannot run any application-defined job, so the build must fail closed.\n */\nexport async function buildWorkerRegistration(\n options: BuildWorkerRegistrationOptions,\n): Promise<string> {\n const { projectRoot, registrationFile, resolvedConfig } = options;\n const outDir = resolve(projectRoot, WORKER_REGISTRATION_DIR);\n const aliases = projectSourceAliases(\n projectRoot,\n resolvedConfig.resolve.alias,\n );\n const { build } = await importProjectVite(projectRoot, 'Worker registration');\n await build({\n configFile: false,\n envFile: false,\n root: projectRoot,\n mode: resolvedConfig.mode,\n logLevel: 'warn',\n clearScreen: false,\n publicDir: false,\n // No consumer plugins: the generated module is plain TypeScript over the\n // app's decorated classes, and re-running smrtPlugin here would recurse.\n plugins: [],\n resolve: { alias: aliases },\n oxc: resolvedConfig.oxc,\n // Externalization is decided by `external` below, not Vite's SSR\n // heuristics, so a package import can never be inlined into the bundle.\n ssr: { target: 'node', noExternal: true },\n build: {\n ssr: registrationFile,\n outDir,\n emptyOutDir: true,\n copyPublicDir: false,\n minify: false,\n sourcemap: true,\n reportCompressedSize: false,\n rollupOptions: {\n external: createWorkerRegistrationExternal(aliases),\n output: {\n format: 'es',\n entryFileNames: WORKER_REGISTRATION_ENTRY,\n chunkFileNames: 'chunks/[name]-[hash].js',\n },\n },\n },\n });\n return join(outDir, WORKER_REGISTRATION_ENTRY);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAa,0BAA0B;;AAGvC,IAAa,4BAA4B;AAGD,GAAG,wBAAH,EAA8B,0BAA9B;;AAGxC,SAAS,gBAAgB,aAAqB,OAAwB;CACpE,MAAM,MAAM,SAAS,aAAa,KAAK;CACvC,IAAI,IAAI,WAAW,IAAI,KAAK,WAAW,GAAG,GAAG,OAAO;CACpD,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,SAAS,cAAc;AACpD;;;;;;;AAQA,SAAgB,qBACd,aACA,SACa;CACb,QAAQ,WAAW,CAAC,EAAA,CAAG,QACpB,UACC,OAAO,MAAM,gBAAgB,YAC7B,WAAW,MAAM,WAAW,KAC5B,gBAAgB,aAAa,MAAM,WAAW,CAClD;AACF;AAEA,SAAS,aAAa,IAAY,OAA2B;CAC3D,MAAM,EAAE,SAAS;CACjB,IAAI,OAAO,SAAS,UAAU,OAAO,OAAO,QAAQ,GAAG,WAAW,GAAG,KAAK,EAAE;CAC5E,KAAK,YAAY;CACjB,OAAO,KAAK,KAAK,EAAE;AACrB;;;;;AAMA,SAAgB,iCACd,SACyB;CACzB,QAAQ,OAAO;EACb,IAAI,GAAG,WAAW,GAAG,KAAK,GAAG,WAAW,IAAI,KAAK,WAAW,EAAE,GAC5D,OAAO;EAET,IAAI,QAAQ,MAAM,UAAU,aAAa,IAAI,KAAK,CAAC,GAAG,OAAO;EAI7D,IACE,OAAO,0BACP,GAAG,WAAW,uBAAuB,GAErC,OAAO;EAET,OAAO;CACT;AACF;;;;;;AAgBA,eAAsB,wBACpB,SACiB;CACjB,MAAM,EAAE,aAAa,kBAAkB,mBAAmB;CAC1D,MAAM,SAAS,QAAQ,aAAa,uBAAuB;CAC3D,MAAM,UAAU,qBACd,aACA,eAAe,QAAQ,KACzB;CACA,MAAM,EAAE,UAAU,MAAM,kBAAkB,aAAa,qBAAqB;CAC5E,MAAM,MAAM;EACV,YAAY;EACZ,SAAS;EACT,MAAM;EACN,MAAM,eAAe;EACrB,UAAU;EACV,aAAa;EACb,WAAW;EAGX,SAAS,CAAC;EACV,SAAS,EAAE,OAAO,QAAQ;EAC1B,KAAK,eAAe;EAGpB,KAAK;GAAE,QAAQ;GAAQ,YAAY;EAAK;EACxC,OAAO;GACL,KAAK;GACL;GACA,aAAa;GACb,eAAe;GACf,QAAQ;GACR,WAAW;GACX,sBAAsB;GACtB,eAAe;IACb,UAAU,iCAAiC,OAAO;IAClD,QAAQ;KACN,QAAQ;KACR,gBAAgB;KAChB,gBAAgB;IAClB;GACF;EACF;CACF,CAAC;CACD,OAAO,KAAK,QAAQ,yBAAyB;AAC/C"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* explicit package list, and `smrtPlugin({...})` with the SvelteKit path
|
|
7
7
|
* options. `smrtConsumer` and `smrtPlugin` stay public and unchanged.
|
|
8
8
|
*/
|
|
9
|
-
import type {
|
|
9
|
+
import type { SmrtVitePlugin } from '../vite-plugin/plugin-contract.js';
|
|
10
10
|
export interface SmrtPresetOptions {
|
|
11
11
|
/**
|
|
12
12
|
* SMRT packages whose object manifests this app consumes. Takes precedence
|
|
@@ -71,5 +71,5 @@ export declare const SMRT_SHARED_RUNTIME_PACKAGES: readonly ["@sveltejs/kit"];
|
|
|
71
71
|
* generation in one entry. Returns a promise because the package list is read
|
|
72
72
|
* from `smrt.config.ts`; Vite accepts promised plugins.
|
|
73
73
|
*/
|
|
74
|
-
export declare function smrt(options?: SmrtPresetOptions): Promise<
|
|
74
|
+
export declare function smrt(options?: SmrtPresetOptions): Promise<SmrtVitePlugin<unknown>[]>;
|
|
75
75
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite-preset/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite-preset/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAGV,cAAc,EACf,MAAM,mCAAmC,CAAC;AAG3C,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,oBAAoB;;;;;;;CAOvB,CAAC;AAiEX;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,4BAA6B,CAAC;AAiCvE;;;;GAIG;AACH,wBAAsB,IAAI,CACxB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,CAgEpC"}
|
|
@@ -2,6 +2,14 @@ import { smrtPlugin } from "../vite-plugin/index.js";
|
|
|
2
2
|
import { smrtConsumer } from "../consumer-plugin/index.js";
|
|
3
3
|
import { resolveCookbookHostedObjects } from "./cookbook-exposure.js";
|
|
4
4
|
//#region src/vite-preset/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* Single-plugin Vite preset for SMRT applications.
|
|
7
|
+
*
|
|
8
|
+
* `plugins: [sveltekit(), smrt()]` replaces the hand-copied glue every app
|
|
9
|
+
* carried: the Oxc legacy-decorator block, `smrtConsumer({...})` with an
|
|
10
|
+
* explicit package list, and `smrtPlugin({...})` with the SvelteKit path
|
|
11
|
+
* options. `smrtConsumer` and `smrtPlugin` stay public and unchanged.
|
|
12
|
+
*/
|
|
5
13
|
var SMRT_PRESET_DEFAULTS = {
|
|
6
14
|
objectsDir: "src/lib/objects",
|
|
7
15
|
typesDir: "src/lib/types/smrt-generated",
|
|
@@ -34,7 +42,7 @@ function decoratorPlugin() {
|
|
|
34
42
|
return {
|
|
35
43
|
name: "smrt:decorators",
|
|
36
44
|
config(user) {
|
|
37
|
-
const decorator = user.oxc
|
|
45
|
+
const decorator = user.oxc ? user.oxc.decorator : void 0;
|
|
38
46
|
const fill = {};
|
|
39
47
|
if (decorator?.legacy === void 0) fill.legacy = true;
|
|
40
48
|
if (decorator?.emitDecoratorMetadata === void 0) fill.emitDecoratorMetadata = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/vite-preset/index.ts"],"sourcesContent":["/**\n * Single-plugin Vite preset for SMRT applications.\n *\n * `plugins: [sveltekit(), smrt()]` replaces the hand-copied glue every app\n * carried: the Oxc legacy-decorator block, `smrtConsumer({...})` with an\n * explicit package list, and `smrtPlugin({...})` with the SvelteKit path\n * options. `smrtConsumer` and `smrtPlugin` stay public and unchanged.\n */\nimport type { Plugin, UserConfig } from 'vite';\nimport { smrtConsumer } from '../consumer-plugin/index.js';\nimport { type SmrtPluginOptions, smrtPlugin } from '../vite-plugin/index.js';\nimport { resolveCookbookHostedObjects } from './cookbook-exposure.js';\n\nexport interface SmrtPresetOptions {\n /**\n * SMRT packages whose object manifests this app consumes. Takes precedence\n * over `consumer.packages` in `smrt.config.ts`. An empty array declares that\n * the app consumes none. Tooling/UI packages must not be listed.\n */\n packages?: readonly string[];\n /**\n * Consumed package models to host over generated REST routes, as\n * provider-qualified refs (`@scope/pkg:Model`). This is an HTTP exposure\n * boundary: each model's own `api` config still applies, so an `api: false`\n * model stays closed. Omit to derive it from `smrt.cookbook.json` (the models\n * of its recipes and `features`, minus those its `exposure` turns off for\n * `api`); without a cookbook nothing is hosted. `[]` hosts nothing.\n */\n expose?: readonly string[];\n /**\n * Project root. Omit to follow the root Vite/SvelteKit resolve (the launch\n * cwd); `smrt.config.ts` is searched from this value or `process.cwd()`.\n */\n projectRoot?: string;\n /** Directory of the app's own `@smrt()` objects. Default `src/lib/objects`. */\n objectsDir?: string;\n /** Generated type declarations. Default `src/lib/types/smrt-generated`. */\n typesDir?: string;\n /** Generated API routes. Default `src/routes/api`. */\n routesDir?: string;\n /** Directory holding the generated runtime config module. Default `src/lib/server`. */\n configPath?: string;\n /** File name of that module. Default `smrt.ts`. */\n configFileName?: string;\n /** Source globs scanned for objects. Default `<objectsDir>/**\\/*.ts`. */\n include?: string[];\n /** Source globs excluded from the scan. Default test and spec files. */\n exclude?: string[];\n /**\n * Apply the Oxc legacy-decorator config. Default `true`. Values the app sets\n * under `oxc.decorator` itself are never overwritten.\n */\n decorators?: boolean;\n}\n\nexport const SMRT_PRESET_DEFAULTS = {\n objectsDir: 'src/lib/objects',\n typesDir: 'src/lib/types/smrt-generated',\n routesDir: 'src/routes/api',\n configPath: 'src/lib/server',\n configFileName: 'smrt.ts',\n exclude: ['**/*.test.ts', '**/*.spec.ts'],\n} as const;\n\nfunction validatePackages(value: unknown, source: string): string[] {\n if (\n !Array.isArray(value) ||\n value.some((p) => typeof p !== 'string' || p.trim() === '')\n ) {\n throw new Error(\n `[smrt] ${source} must be an array of non-empty package names, got ${JSON.stringify(value)}.`,\n );\n }\n return [...new Set(value.map((p: string) => p.trim()))];\n}\n\n/** Resolve the declared consumer package list: option first, then smrt.config. */\nasync function resolvePackages(\n options: SmrtPresetOptions,\n searchFrom: string,\n): Promise<string[]> {\n if (options.packages !== undefined) {\n return validatePackages(options.packages, 'smrt({ packages })');\n }\n\n let declared: unknown;\n try {\n const { loadConfig } = await import('@happyvertical/smrt-config');\n const config = await loadConfig({ cache: false, searchFrom });\n declared = config.consumer?.packages;\n } catch (error) {\n throw new Error(\n `[smrt] Could not read smrt.config to resolve consumer packages: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n if (declared === undefined) {\n throw new Error(\n '[smrt] No consumer package list declared. Set `consumer: { packages: [...] }` in smrt.config.ts ' +\n '(use [] when the app consumes no SMRT packages) or pass `smrt({ packages })`. ' +\n 'The list is explicit so runtime registration is deterministic; it is never inferred from package.json.',\n );\n }\n return validatePackages(declared, 'smrt.config `consumer.packages`');\n}\n\nfunction decoratorPlugin(): Plugin {\n return {\n name: 'smrt:decorators',\n // Vite merges a hook's result over the user config, so fill only the\n // values the app has not set itself.\n config(user: UserConfig) {\n const decorator = (\n user as { oxc?: { decorator?: Record<string, unknown> } }\n ).oxc?.decorator;\n const fill: Record<string, boolean> = {};\n if (decorator?.legacy === undefined) fill.legacy = true;\n if (decorator?.emitDecoratorMetadata === undefined) {\n fill.emitDecoratorMetadata = true;\n }\n return Object.keys(fill).length\n ? ({ oxc: { decorator: fill } } as UserConfig)\n : undefined;\n },\n };\n}\n\n/**\n * Packages SMRT's SvelteKit entries share with the app by identity. SvelteKit\n * recognizes `redirect()`/`fail()` results by class, so a server entry such as\n * `@happyvertical/smrt-app-runtime/sveltekit` must import the app's own copy.\n * Deduping selects the app peer for linked/workspace packages. The runtime\n * must also enter the SSR bundle: adapter-node bundles Kit itself, so leaving\n * runtime external would import a second Kit class through Node even when\n * both resolve to the same installed version.\n */\nexport const SMRT_SHARED_RUNTIME_PACKAGES = ['@sveltejs/kit'] as const;\n\nfunction sharedRuntimePlugin(): Plugin {\n let isBuild = false;\n return {\n name: 'smrt:shared-runtime',\n enforce: 'pre',\n resolveId(id, _importer, options) {\n // ssr.external on the package root would externalize every subpath.\n // Keep only this exact entry external, preserving native dependencies.\n if (isBuild && options.ssr && id === '@happyvertical/smrt-app-runtime') {\n return { id, external: true };\n }\n },\n config(_user, { command }) {\n // Only adapter builds need this split. Dev import analysis ignores a\n // resolver's external flag, so it must retain normal externalization.\n isBuild = command === 'build';\n return {\n resolve: { dedupe: [...SMRT_SHARED_RUNTIME_PACKAGES] },\n ...(isBuild\n ? {\n ssr: {\n noExternal: ['@happyvertical/smrt-app-runtime'],\n external: ['@happyvertical/smrt-app-runtime/sveltekit-runtime'],\n },\n }\n : {}),\n };\n },\n };\n}\n\n/**\n * SMRT Vite preset: decorators, dependency manifests, and app object\n * generation in one entry. Returns a promise because the package list is read\n * from `smrt.config.ts`; Vite accepts promised plugins.\n */\nexport async function smrt(options: SmrtPresetOptions = {}): Promise<Plugin[]> {\n const D = SMRT_PRESET_DEFAULTS;\n const objectsDir = options.objectsDir ?? D.objectsDir;\n const typesDir = options.typesDir ?? D.typesDir;\n const routesDir = options.routesDir ?? D.routesDir;\n const configPath = options.configPath ?? D.configPath;\n const configFileName = options.configFileName ?? D.configFileName;\n const rootOption = options.projectRoot\n ? { projectRoot: options.projectRoot }\n : {};\n\n const packages = await resolvePackages(\n options,\n options.projectRoot ?? process.cwd(),\n );\n\n const plugins: Plugin[] = [];\n if (options.decorators !== false) plugins.push(decoratorPlugin());\n plugins.push(sharedRuntimePlugin());\n // smrtConsumer must precede smrtPlugin, as in the template's hand-written form.\n // With no declared packages there is nothing to consume, and an empty list\n // would otherwise trigger dependency discovery.\n if (packages.length > 0) {\n const hosted = options.expose\n ? validatePackages(options.expose, 'smrt({ expose })')\n : resolveCookbookHostedObjects(\n options.projectRoot ?? process.cwd(),\n packages,\n );\n plugins.push(\n smrtConsumer({\n ...rootOption,\n packages,\n generateTypes: true,\n typesDir,\n svelteKit:\n hosted.length > 0\n ? {\n objects: hosted,\n routesDir,\n objectsDir,\n configPath,\n configFileName,\n }\n : true,\n }),\n );\n }\n const pluginOptions: SmrtPluginOptions = {\n ...rootOption,\n include: options.include ?? [`${objectsDir}/**/*.ts`],\n exclude: options.exclude ?? [...D.exclude],\n generateTypes: true,\n typeDeclarationsPath: typesDir,\n svelteKit: {\n enabled: true,\n routesDir,\n objectsDir,\n configPath,\n configFileName,\n },\n };\n plugins.push(smrtPlugin(pluginOptions));\n return plugins;\n}\n"],"mappings":";;;;AAuDA,IAAa,uBAAuB;CAClC,YAAY;CACZ,UAAU;CACV,WAAW;CACX,YAAY;CACZ,gBAAgB;CAChB,SAAS,CAAC,gBAAgB,cAAc;AAC1C;AAEA,SAAS,iBAAiB,OAAgB,QAA0B;CAClE,IACE,CAAC,MAAM,QAAQ,KAAK,KACpB,MAAM,MAAM,MAAM,OAAO,MAAM,YAAY,EAAE,KAAK,MAAM,EAAE,GAE1D,MAAM,IAAI,MACR,UAAU,OAAO,oDAAoD,KAAK,UAAU,KAAK,EAAE,EAC7F;CAEF,OAAO,CAAC,GAAG,IAAI,IAAI,MAAM,KAAK,MAAc,EAAE,KAAK,CAAC,CAAC,CAAC;AACxD;;AAGA,eAAe,gBACb,SACA,YACmB;CACnB,IAAI,QAAQ,aAAa,KAAA,GACvB,OAAO,iBAAiB,QAAQ,UAAU,oBAAoB;CAGhE,IAAI;CACJ,IAAI;EACF,MAAM,EAAE,eAAe,MAAM,OAAO;EAEpC,YAAW,MADU,WAAW;GAAE,OAAO;GAAO;EAAW,CAAC,EAAA,CAC1C,UAAU;CAC9B,SAAS,OAAO;EACd,MAAM,IAAI,MACR,mEACE,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAEzD;CACF;CAEA,IAAI,aAAa,KAAA,GACf,MAAM,IAAI,MACR,sRAGF;CAEF,OAAO,iBAAiB,UAAU,iCAAiC;AACrE;AAEA,SAAS,kBAA0B;CACjC,OAAO;EACL,MAAM;EAGN,OAAO,MAAkB;GACvB,MAAM,YACJ,KACA,KAAK;GACP,MAAM,OAAgC,CAAC;GACvC,IAAI,WA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nB,iBAAiB,QAAQ,QAAQ,kBAAkB,IACnD,6BACE,QAAQ,eAAe,QAAQ,IAAI,GACnC,QACF;EACJ,QAAQ,KACN,aAAa;GACX,GAAG;GACH;GACA,eAAe;GACf;GACA,WACE,OAAO,SAAS,IACZ;IACE,SAAS;IACT;IACA;IACA;IACA;GACF,IACA;EACR,CAAC,CACH;CACF;CACA,MAAM,gBAAmC;EACvC,GAAG;EACH,SAAS,QAAQ,WAAW,CAAC,GAAG,WAAW,SAAS;EACpD,SAAS,QAAQ,WAAW,CAAC,GAAG,EAAE,OAAO;EACzC,eAAe;EACf,sBAAsB;EACtB,WAAW;GACT,SAAS;GACT;GACA;GACA;GACA;EACF;CACF;CACA,QAAQ,KAAK,WAAW,aAAa,CAAC;CACtC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/vite-preset/index.ts"],"sourcesContent":["/**\n * Single-plugin Vite preset for SMRT applications.\n *\n * `plugins: [sveltekit(), smrt()]` replaces the hand-copied glue every app\n * carried: the Oxc legacy-decorator block, `smrtConsumer({...})` with an\n * explicit package list, and `smrtPlugin({...})` with the SvelteKit path\n * options. `smrtConsumer` and `smrtPlugin` stay public and unchanged.\n */\n\nimport { smrtConsumer } from '../consumer-plugin/index.js';\nimport { type SmrtPluginOptions, smrtPlugin } from '../vite-plugin/index.js';\nimport type {\n SmrtDecoratorConfig,\n SmrtUserConfig,\n SmrtVitePlugin,\n} from '../vite-plugin/plugin-contract.js';\nimport { resolveCookbookHostedObjects } from './cookbook-exposure.js';\n\nexport interface SmrtPresetOptions {\n /**\n * SMRT packages whose object manifests this app consumes. Takes precedence\n * over `consumer.packages` in `smrt.config.ts`. An empty array declares that\n * the app consumes none. Tooling/UI packages must not be listed.\n */\n packages?: readonly string[];\n /**\n * Consumed package models to host over generated REST routes, as\n * provider-qualified refs (`@scope/pkg:Model`). This is an HTTP exposure\n * boundary: each model's own `api` config still applies, so an `api: false`\n * model stays closed. Omit to derive it from `smrt.cookbook.json` (the models\n * of its recipes and `features`, minus those its `exposure` turns off for\n * `api`); without a cookbook nothing is hosted. `[]` hosts nothing.\n */\n expose?: readonly string[];\n /**\n * Project root. Omit to follow the root Vite/SvelteKit resolve (the launch\n * cwd); `smrt.config.ts` is searched from this value or `process.cwd()`.\n */\n projectRoot?: string;\n /** Directory of the app's own `@smrt()` objects. Default `src/lib/objects`. */\n objectsDir?: string;\n /** Generated type declarations. Default `src/lib/types/smrt-generated`. */\n typesDir?: string;\n /** Generated API routes. Default `src/routes/api`. */\n routesDir?: string;\n /** Directory holding the generated runtime config module. Default `src/lib/server`. */\n configPath?: string;\n /** File name of that module. Default `smrt.ts`. */\n configFileName?: string;\n /** Source globs scanned for objects. Default `<objectsDir>/**\\/*.ts`. */\n include?: string[];\n /** Source globs excluded from the scan. Default test and spec files. */\n exclude?: string[];\n /**\n * Apply the Oxc legacy-decorator config. Default `true`. Values the app sets\n * under `oxc.decorator` itself are never overwritten.\n */\n decorators?: boolean;\n}\n\nexport const SMRT_PRESET_DEFAULTS = {\n objectsDir: 'src/lib/objects',\n typesDir: 'src/lib/types/smrt-generated',\n routesDir: 'src/routes/api',\n configPath: 'src/lib/server',\n configFileName: 'smrt.ts',\n exclude: ['**/*.test.ts', '**/*.spec.ts'],\n} as const;\n\nfunction validatePackages(value: unknown, source: string): string[] {\n if (\n !Array.isArray(value) ||\n value.some((p) => typeof p !== 'string' || p.trim() === '')\n ) {\n throw new Error(\n `[smrt] ${source} must be an array of non-empty package names, got ${JSON.stringify(value)}.`,\n );\n }\n return [...new Set(value.map((p: string) => p.trim()))];\n}\n\n/** Resolve the declared consumer package list: option first, then smrt.config. */\nasync function resolvePackages(\n options: SmrtPresetOptions,\n searchFrom: string,\n): Promise<string[]> {\n if (options.packages !== undefined) {\n return validatePackages(options.packages, 'smrt({ packages })');\n }\n\n let declared: unknown;\n try {\n const { loadConfig } = await import('@happyvertical/smrt-config');\n const config = await loadConfig({ cache: false, searchFrom });\n declared = config.consumer?.packages;\n } catch (error) {\n throw new Error(\n `[smrt] Could not read smrt.config to resolve consumer packages: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n if (declared === undefined) {\n throw new Error(\n '[smrt] No consumer package list declared. Set `consumer: { packages: [...] }` in smrt.config.ts ' +\n '(use [] when the app consumes no SMRT packages) or pass `smrt({ packages })`. ' +\n 'The list is explicit so runtime registration is deterministic; it is never inferred from package.json.',\n );\n }\n return validatePackages(declared, 'smrt.config `consumer.packages`');\n}\n\nfunction decoratorPlugin(): SmrtVitePlugin {\n return {\n name: 'smrt:decorators',\n // Vite merges a hook's result over the user config, so fill only the\n // values the app has not set itself.\n config(user: SmrtUserConfig) {\n const decorator = user.oxc ? user.oxc.decorator : undefined;\n const fill: SmrtDecoratorConfig = {};\n if (decorator?.legacy === undefined) fill.legacy = true;\n if (decorator?.emitDecoratorMetadata === undefined) {\n fill.emitDecoratorMetadata = true;\n }\n return Object.keys(fill).length\n ? { oxc: { decorator: fill } }\n : undefined;\n },\n };\n}\n\n/**\n * Packages SMRT's SvelteKit entries share with the app by identity. SvelteKit\n * recognizes `redirect()`/`fail()` results by class, so a server entry such as\n * `@happyvertical/smrt-app-runtime/sveltekit` must import the app's own copy.\n * Deduping selects the app peer for linked/workspace packages. The runtime\n * must also enter the SSR bundle: adapter-node bundles Kit itself, so leaving\n * runtime external would import a second Kit class through Node even when\n * both resolve to the same installed version.\n */\nexport const SMRT_SHARED_RUNTIME_PACKAGES = ['@sveltejs/kit'] as const;\n\nfunction sharedRuntimePlugin(): SmrtVitePlugin {\n let isBuild = false;\n return {\n name: 'smrt:shared-runtime',\n enforce: 'pre',\n resolveId(id, _importer, options) {\n // ssr.external on the package root would externalize every subpath.\n // Keep only this exact entry external, preserving native dependencies.\n if (isBuild && options.ssr && id === '@happyvertical/smrt-app-runtime') {\n return { id, external: true };\n }\n },\n config(_user, { command }) {\n // Only adapter builds need this split. Dev import analysis ignores a\n // resolver's external flag, so it must retain normal externalization.\n isBuild = command === 'build';\n return {\n resolve: { dedupe: [...SMRT_SHARED_RUNTIME_PACKAGES] },\n ...(isBuild\n ? {\n ssr: {\n noExternal: ['@happyvertical/smrt-app-runtime'],\n external: ['@happyvertical/smrt-app-runtime/sveltekit-runtime'],\n },\n }\n : {}),\n };\n },\n };\n}\n\n/**\n * SMRT Vite preset: decorators, dependency manifests, and app object\n * generation in one entry. Returns a promise because the package list is read\n * from `smrt.config.ts`; Vite accepts promised plugins.\n */\nexport async function smrt(\n options: SmrtPresetOptions = {},\n): Promise<SmrtVitePlugin<unknown>[]> {\n const D = SMRT_PRESET_DEFAULTS;\n const objectsDir = options.objectsDir ?? D.objectsDir;\n const typesDir = options.typesDir ?? D.typesDir;\n const routesDir = options.routesDir ?? D.routesDir;\n const configPath = options.configPath ?? D.configPath;\n const configFileName = options.configFileName ?? D.configFileName;\n const rootOption = options.projectRoot\n ? { projectRoot: options.projectRoot }\n : {};\n\n const packages = await resolvePackages(\n options,\n options.projectRoot ?? process.cwd(),\n );\n\n const plugins: SmrtVitePlugin<unknown>[] = [];\n if (options.decorators !== false) plugins.push(decoratorPlugin());\n plugins.push(sharedRuntimePlugin());\n // smrtConsumer must precede smrtPlugin, as in the template's hand-written form.\n // With no declared packages there is nothing to consume, and an empty list\n // would otherwise trigger dependency discovery.\n if (packages.length > 0) {\n const hosted = options.expose\n ? validatePackages(options.expose, 'smrt({ expose })')\n : resolveCookbookHostedObjects(\n options.projectRoot ?? process.cwd(),\n packages,\n );\n plugins.push(\n smrtConsumer({\n ...rootOption,\n packages,\n generateTypes: true,\n typesDir,\n svelteKit:\n hosted.length > 0\n ? {\n objects: hosted,\n routesDir,\n objectsDir,\n configPath,\n configFileName,\n }\n : true,\n }),\n );\n }\n const pluginOptions: SmrtPluginOptions = {\n ...rootOption,\n include: options.include ?? [`${objectsDir}/**/*.ts`],\n exclude: options.exclude ?? [...D.exclude],\n generateTypes: true,\n typeDeclarationsPath: typesDir,\n svelteKit: {\n enabled: true,\n routesDir,\n objectsDir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;GACf;GACA,WACE,OAAO,SAAS,IACZ;IACE,SAAS;IACT;IACA;IACA;IACA;GACF,IACA;EACR,CAAC,CACH;CACF;CACA,MAAM,gBAAmC;EACvC,GAAG;EACH,SAAS,QAAQ,WAAW,CAAC,GAAG,WAAW,SAAS;EACpD,SAAS,QAAQ,WAAW,CAAC,GAAG,EAAE,OAAO;EACzC,eAAe;EACf,sBAAsB;EACtB,WAAW;GACT,SAAS;GACT;GACA;GACA;GACA;EACF;CACF;CACA,QAAQ,KAAK,WAAW,aAAa,CAAC;CACtC,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-core",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.33",
|
|
4
4
|
"description": "Core AI agent framework with standardized collections, object-relational mapping, and code generators",
|
|
5
5
|
"author": "HappyVertical",
|
|
6
6
|
"type": "module",
|
|
@@ -199,15 +199,14 @@
|
|
|
199
199
|
"@happyvertical/files": "^0.108.0",
|
|
200
200
|
"@happyvertical/json": "^0.108.0",
|
|
201
201
|
"@happyvertical/logger": "^0.108.0",
|
|
202
|
-
"@happyvertical/smrt-config": "0.57.
|
|
203
|
-
"@happyvertical/smrt-scanner": "0.57.
|
|
204
|
-
"@happyvertical/smrt-types": "0.57.
|
|
202
|
+
"@happyvertical/smrt-config": "0.57.33",
|
|
203
|
+
"@happyvertical/smrt-scanner": "0.57.33",
|
|
204
|
+
"@happyvertical/smrt-types": "0.57.33",
|
|
205
205
|
"@happyvertical/sql": "^0.108.0",
|
|
206
206
|
"@happyvertical/utils": "^0.108.0",
|
|
207
207
|
"@noble/hashes": "^2.4.0",
|
|
208
208
|
"@oxc-project/runtime": "^0.150.0",
|
|
209
209
|
"cheerio": "^1.2.0",
|
|
210
|
-
"fast-glob": "3.3.3",
|
|
211
210
|
"import-meta-resolve": "4.2.0",
|
|
212
211
|
"minimatch": "10.2.6",
|
|
213
212
|
"oxc-transform": "0.150.0",
|