@happyvertical/smrt-core 0.57.20 → 0.57.21
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/agents/build-knowledge.md +68 -0
- package/dist/consumer-plugin/index.d.ts +45 -0
- package/dist/consumer-plugin/index.d.ts.map +1 -1
- package/dist/consumer-plugin/index.js +96 -12
- package/dist/consumer-plugin/index.js.map +1 -1
- package/dist/consumer-plugin.js +2 -2
- 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 -5
- package/package.json +4 -4
|
@@ -94,6 +94,74 @@ so the artifact bundles them. SvelteKit
|
|
|
94
94
|
virtual modules (`$env/*`, `$app/*`) are not available to a worker; an object
|
|
95
95
|
importing one fails at worker startup. A failure fails the build.
|
|
96
96
|
|
|
97
|
+
**Register imports stay Node-loadable (#4219).** `.smrt/register.js`
|
|
98
|
+
(`generateRegistrationFile` in `src/consumer-plugin/index.ts`) is evaluated by
|
|
99
|
+
plain Node — `smrt db:migrate`, every CLI, and the worker artifact above — as
|
|
100
|
+
well as by Vite SSR, so it may only import modules Node can load. Each object
|
|
101
|
+
is imported from its manifest `importPath` (the scanner's export-subpath match,
|
|
102
|
+
e.g. `@happyvertical/smrt-products/models`). Each configured provider in
|
|
103
|
+
`smrtDependencies` is also imported once so it is evaluated in Node's installed
|
|
104
|
+
package context (#4187): the package root, unless the package declares that
|
|
105
|
+
root as a Svelte entry (`isComponentBearingRoot`: a `svelte` field, or a `.`
|
|
106
|
+
export with a `svelte` condition or a `.svelte`/`.css` target — e.g.
|
|
107
|
+
`@happyvertical/smrt-products`, whose root re-exports its components and so
|
|
108
|
+
reaches `@happyvertical/smrt-ui`'s `.svelte` files). Such a root is never
|
|
109
|
+
imported and no subpath is substituted for it (`resolveProviderContextImport`
|
|
110
|
+
returns `undefined`): its already-imported object entries establish the
|
|
111
|
+
context, a provider contributing only nested objects needs none because the
|
|
112
|
+
transitive loader uses only `import.meta.resolve(provider)`, and a substitute
|
|
113
|
+
`./models` whose JS reached `.svelte` would re-create the failure. A package that publishes Svelte
|
|
114
|
+
only under subpaths keeps its root import; the broader `isComponentBearingPackage`
|
|
115
|
+
test (any Svelte export) only selects `ssr.noExternal` packages. A `svelte`
|
|
116
|
+
condition counts even with a plain `.js` target — that is what svelte-package
|
|
117
|
+
and Vite library builds emit for a root that re-exports components, and every
|
|
118
|
+
Svelte root in this workspace (`smrt-products`, `smrt-ui`, `smrt-svelte`,
|
|
119
|
+
`smrt-planner`) has that shape and fails under plain Node; a Node-safe root
|
|
120
|
+
that declares `svelte` anyway only loses an optional context import.
|
|
121
|
+
Transitive-only object modules are loaded through `importSmrtDependency()`
|
|
122
|
+
from their provider's context, which needs no root import.
|
|
123
|
+
|
|
124
|
+
Not covered by contract: a package whose root is a Svelte entry AND whose
|
|
125
|
+
`@smrt()` objects are exported only from that root. The object loop must then
|
|
126
|
+
import the root (it is the only module exporting the constructors) — statically
|
|
127
|
+
when the app resolves the package, or through `importSmrtDependency()` when it
|
|
128
|
+
is reached only through its provider — so Vite SSR works but plain Node can
|
|
129
|
+
load the register only if that root happens to be Node-safe. Generation keeps
|
|
130
|
+
the import and warns once per package (`declares a Svelte root entry`), asking
|
|
131
|
+
to verify the root under plain Node or publish the objects from `./models` or
|
|
132
|
+
`./objects`. The declaration is a heuristic: a Node-safe root that declares
|
|
133
|
+
`svelte` only by convention gets the same warning (a false positive, harmless —
|
|
134
|
+
the import is kept) and, when its objects come from subpaths, loses only its
|
|
135
|
+
optional provider-context import. Regression: the `#4219` tests in
|
|
136
|
+
`index.test.ts` (unit cases for `isComponentBearingRoot` /
|
|
137
|
+
`resolveProviderContextImport`, a child-Node load of the generated register,
|
|
138
|
+
the nested-only provider that gets no import, and the root-only and transitive
|
|
139
|
+
warnings).
|
|
140
|
+
|
|
141
|
+
**Gate: `pnpm check:node-roots`** (root script; run after `pnpm build`). It
|
|
142
|
+
runs `scripts/survey-node-root-load.mjs --strict --allow=<packages>`, which
|
|
143
|
+
spawns `node --input-type=module -e "await import('<name>')"` from every
|
|
144
|
+
built workspace package whose manifest declares `@smrt()` objects and fails on
|
|
145
|
+
any root plain Node cannot evaluate that is not allow-listed. The allow-list
|
|
146
|
+
is explicit and lives in the root `package.json` script: currently only
|
|
147
|
+
`@happyvertical/smrt-products`, whose root re-exports its Svelte components by
|
|
148
|
+
documented contract. A new entry needs the same justification; a model root
|
|
149
|
+
that merely starts importing `@happyvertical/smrt-ui` must be fixed, not
|
|
150
|
+
allowed. `--strict` also fails when nothing was surveyed (run before
|
|
151
|
+
`pnpm build`) and when an allow-listed package was not surveyed or now loads,
|
|
152
|
+
so the list cannot go stale. `--all` surveys every published package,
|
|
153
|
+
including those without objects, as a report.
|
|
154
|
+
|
|
155
|
+
CI runs the gate in both Knowledge Freshness jobs of
|
|
156
|
+
`.github/workflows/test-suite.yml`. In full mode (the merge queue, and every PR
|
|
157
|
+
while `vars.CI_MERGE_QUEUE_ENABLED` is not `true`) it always runs. In affected
|
|
158
|
+
mode it runs only when the `knowledge` paths filter matches, which covers
|
|
159
|
+
`package.json` files and docs but not `packages/*/src/**`; a same-repo PR that
|
|
160
|
+
makes a model root import smrt-ui only through source is therefore first
|
|
161
|
+
caught in the merge queue, which still blocks the merge. The filter is not
|
|
162
|
+
widened for this, because that would run the knowledge job on every PR. Run
|
|
163
|
+
`pnpm check:node-roots` locally when changing a model package's root imports.
|
|
164
|
+
|
|
97
165
|
## Lightweight discovery
|
|
98
166
|
|
|
99
167
|
Filesystem-only discovery, module-doc parsing, and graph freshness are owned by
|
|
@@ -6,6 +6,51 @@ import type { Plugin } from 'vite';
|
|
|
6
6
|
import { type SmrtGenerationSnapshotOptions } from '../generation-snapshot.js';
|
|
7
7
|
import { type SvelteKitOptions } from '../vite-plugin/sveltekit-generator.js';
|
|
8
8
|
export { loadVerifiedSmrtGenerationSnapshot, type SerializeSmrtGenerationSnapshotOptions, type SmrtGenerationSnapshotArtifact, type SmrtGenerationSnapshotOptions, type SmrtGenerationSnapshotView, serializeSmrtGenerationSnapshot, sha256SmrtGenerationSnapshot, } from '../generation-snapshot.js';
|
|
9
|
+
/**
|
|
10
|
+
* The package.json fields the Svelte-root rule reads. `exports` is `unknown`
|
|
11
|
+
* because npm allows a bare string target as well as a conditions map.
|
|
12
|
+
*/
|
|
13
|
+
interface ProviderPackageShape {
|
|
14
|
+
svelte?: unknown;
|
|
15
|
+
exports?: unknown;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Whether the package declares its ROOT as a Svelte entry: a `svelte` field or
|
|
20
|
+
* a `.` export carrying a `svelte` condition (at any nesting) or a
|
|
21
|
+
* `.svelte`/`.css` target. Such a root (e.g. `@happyvertical/smrt-products`,
|
|
22
|
+
* which re-exports its components) cannot be evaluated by plain Node (#4219).
|
|
23
|
+
* A package that only publishes Svelte under a subpath keeps a Node-safe root,
|
|
24
|
+
* as the standards require.
|
|
25
|
+
*
|
|
26
|
+
* A `svelte` condition counts even when its target is plain `.js`: that is
|
|
27
|
+
* what svelte-package and Vite library builds emit for a root that re-exports
|
|
28
|
+
* components (the `.svelte` files sit one import deeper), and it is exactly
|
|
29
|
+
* the shape of every Svelte root in this workspace. Reading the condition as
|
|
30
|
+
* the package's declaration is deliberate — the trade-off is that a Node-safe
|
|
31
|
+
* root that nevertheless declares `svelte` loses its optional provider-context
|
|
32
|
+
* import, which costs nothing when its objects are imported from a subpath.
|
|
33
|
+
*
|
|
34
|
+
* A missing `exports` map, a `.` key absent from it, or an unreadable
|
|
35
|
+
* package.json (`undefined`) all answer `false`: the register then keeps the
|
|
36
|
+
* root import #4187 chose, as before.
|
|
37
|
+
*
|
|
38
|
+
* @internal Exported for tests.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isComponentBearingRoot(packageJson: ProviderPackageShape | undefined): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Pick the module the generated register imports so a configured provider is
|
|
43
|
+
* evaluated in Node's installed package context (#4187): the package root,
|
|
44
|
+
* unless the package declares that root as a Svelte entry, in which case
|
|
45
|
+
* nothing is imported for the provider (#4219). Its object entries, imported
|
|
46
|
+
* from their manifest `importPath`, already evaluate it in that context, and
|
|
47
|
+
* the transitive loader needs only `import.meta.resolve(provider)`, not an
|
|
48
|
+
* import. No substitute subpath is chosen: one that reaches `.svelte` would
|
|
49
|
+
* re-create the failure this avoids.
|
|
50
|
+
*
|
|
51
|
+
* @internal Exported for tests.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveProviderContextImport(packageName: string, packageJson: ProviderPackageShape | undefined): string | undefined;
|
|
9
54
|
/**
|
|
10
55
|
* SvelteKit route-hosting options for dependency models. Unlike `packages`,
|
|
11
56
|
* `objects` is an HTTP exposure boundary: every entry must be an exact,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consumer-plugin/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAa,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,2BAA2B,CAAC;AAYnC,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,uCAAuC,CAAC;AAqB/C,OAAO,EACL,kCAAkC,EAClC,KAAK,sCAAsC,EAC3C,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,+BAA+B,EAC/B,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consumer-plugin/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAa,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,2BAA2B,CAAC;AAYnC,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,uCAAuC,CAAC;AAqB/C,OAAO,EACL,kCAAkC,EAClC,KAAK,sCAAsC,EAC3C,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,+BAA+B,EAC/B,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;AAiJnC;;;GAGG;AACH,UAAU,oBAAoB;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,oBAAoB,GAAG,SAAS,GAC5C,OAAO,CAcT;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,oBAAoB,GAAG,SAAS,GAC5C,MAAM,GAAG,SAAS,CAEpB;AAED;;;;GAIG;AACH,MAAM,WAAW,4BACf,SAAQ,OAAO,CACb,IAAI,CACF,gBAAgB,EACd,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,gBAAgB,GAChB,aAAa,GACb,cAAc,GACd,aAAa,GACb,gBAAgB,CACnB,CACF;IACD,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,uCAAuC;IACvC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,6BAA6B,CAAC;IACnD;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,4BAA4B,CAAC;IACnD;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oDAAoD;IACpD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,4BAA4B;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAmXD;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM,CAykBtE"}
|
|
@@ -36,6 +36,77 @@ function findInstalledPackageJson(packageName, searchFrom) {
|
|
|
36
36
|
function sameInstalledPackage(left, right) {
|
|
37
37
|
return Boolean(left && right && fs$1.realpathSync(left) === fs$1.realpathSync(right));
|
|
38
38
|
}
|
|
39
|
+
function readInstalledPackageJson(packageJsonPath) {
|
|
40
|
+
if (!packageJsonPath) return void 0;
|
|
41
|
+
try {
|
|
42
|
+
return JSON.parse(fs$1.readFileSync(packageJsonPath, "utf8"));
|
|
43
|
+
} catch {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Whether an `exports` target (or any condition under it) needs Vite to
|
|
49
|
+
* compile it: a `.svelte`/`.css` file or a `svelte` resolution condition.
|
|
50
|
+
*/
|
|
51
|
+
function exportTargetNeedsViteCompilation(value) {
|
|
52
|
+
if (typeof value === "string") return value.endsWith(".svelte") || value.endsWith(".css");
|
|
53
|
+
if (!value || typeof value !== "object") return false;
|
|
54
|
+
return Object.entries(value).some(([condition, target]) => condition === "svelte" || exportTargetNeedsViteCompilation(target));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A component-bearing package publishes Svelte entries (a `svelte` field, a
|
|
58
|
+
* `svelte` condition, or a `.svelte`/`.css` export target). Plain Node cannot
|
|
59
|
+
* evaluate such a package's root: it may re-export `.svelte` files directly or
|
|
60
|
+
* through another component library (#4219).
|
|
61
|
+
*/
|
|
62
|
+
function isComponentBearingPackage(packageJson) {
|
|
63
|
+
return typeof packageJson?.svelte === "string" || exportTargetNeedsViteCompilation(packageJson?.exports);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Whether the package declares its ROOT as a Svelte entry: a `svelte` field or
|
|
67
|
+
* a `.` export carrying a `svelte` condition (at any nesting) or a
|
|
68
|
+
* `.svelte`/`.css` target. Such a root (e.g. `@happyvertical/smrt-products`,
|
|
69
|
+
* which re-exports its components) cannot be evaluated by plain Node (#4219).
|
|
70
|
+
* A package that only publishes Svelte under a subpath keeps a Node-safe root,
|
|
71
|
+
* as the standards require.
|
|
72
|
+
*
|
|
73
|
+
* A `svelte` condition counts even when its target is plain `.js`: that is
|
|
74
|
+
* what svelte-package and Vite library builds emit for a root that re-exports
|
|
75
|
+
* components (the `.svelte` files sit one import deeper), and it is exactly
|
|
76
|
+
* the shape of every Svelte root in this workspace. Reading the condition as
|
|
77
|
+
* the package's declaration is deliberate — the trade-off is that a Node-safe
|
|
78
|
+
* root that nevertheless declares `svelte` loses its optional provider-context
|
|
79
|
+
* import, which costs nothing when its objects are imported from a subpath.
|
|
80
|
+
*
|
|
81
|
+
* A missing `exports` map, a `.` key absent from it, or an unreadable
|
|
82
|
+
* package.json (`undefined`) all answer `false`: the register then keeps the
|
|
83
|
+
* root import #4187 chose, as before.
|
|
84
|
+
*
|
|
85
|
+
* @internal Exported for tests.
|
|
86
|
+
*/
|
|
87
|
+
function isComponentBearingRoot(packageJson) {
|
|
88
|
+
if (typeof packageJson?.svelte === "string") return true;
|
|
89
|
+
const exports = packageJson?.exports;
|
|
90
|
+
if (typeof exports === "string") return exportTargetNeedsViteCompilation(exports);
|
|
91
|
+
if (!exports || typeof exports !== "object") return false;
|
|
92
|
+
const exportsMap = exports;
|
|
93
|
+
return exportTargetNeedsViteCompilation(Object.keys(exportsMap).some((key) => key.startsWith(".")) ? exportsMap["."] : exportsMap);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Pick the module the generated register imports so a configured provider is
|
|
97
|
+
* evaluated in Node's installed package context (#4187): the package root,
|
|
98
|
+
* unless the package declares that root as a Svelte entry, in which case
|
|
99
|
+
* nothing is imported for the provider (#4219). Its object entries, imported
|
|
100
|
+
* from their manifest `importPath`, already evaluate it in that context, and
|
|
101
|
+
* the transitive loader needs only `import.meta.resolve(provider)`, not an
|
|
102
|
+
* import. No substitute subpath is chosen: one that reaches `.svelte` would
|
|
103
|
+
* re-create the failure this avoids.
|
|
104
|
+
*
|
|
105
|
+
* @internal Exported for tests.
|
|
106
|
+
*/
|
|
107
|
+
function resolveProviderContextImport(packageName, packageJson) {
|
|
108
|
+
return isComponentBearingRoot(packageJson) ? void 0 : packageName;
|
|
109
|
+
}
|
|
39
110
|
var VIRTUAL_MODULES = {
|
|
40
111
|
"@smrt/routes": "smrt-consumer:routes",
|
|
41
112
|
"@smrt/client": "smrt-consumer:client",
|
|
@@ -250,11 +321,6 @@ function smrtConsumer(options = {}) {
|
|
|
250
321
|
* AsyncLocalStorage instance.
|
|
251
322
|
*/
|
|
252
323
|
function resolveConsumerSsrExternalPackages(providerPackages) {
|
|
253
|
-
const needsViteCompilation = (value) => {
|
|
254
|
-
if (typeof value === "string") return value.endsWith(".svelte") || value.endsWith(".css");
|
|
255
|
-
if (!value || typeof value !== "object") return false;
|
|
256
|
-
return Object.entries(value).some(([condition, target]) => condition === "svelte" || needsViteCompilation(target));
|
|
257
|
-
};
|
|
258
324
|
const external = /* @__PURE__ */ new Set();
|
|
259
325
|
const selective = /* @__PURE__ */ new Map();
|
|
260
326
|
const visited = /* @__PURE__ */ new Set();
|
|
@@ -270,11 +336,8 @@ function smrtConsumer(options = {}) {
|
|
|
270
336
|
const visitKey = packageJsonPath ?? `${searchFrom}\0${packageName}`;
|
|
271
337
|
if (visited.has(visitKey)) continue;
|
|
272
338
|
visited.add(visitKey);
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
packageJson = JSON.parse(fs$1.readFileSync(packageJsonPath, "utf8"));
|
|
276
|
-
} catch {}
|
|
277
|
-
const needsSvelteCompilation = typeof packageJson?.svelte === "string" || needsViteCompilation(packageJson?.exports);
|
|
339
|
+
const packageJson = readInstalledPackageJson(packageJsonPath);
|
|
340
|
+
const needsSvelteCompilation = isComponentBearingPackage(packageJson);
|
|
278
341
|
const isAppResolvable = sameInstalledPackage(packageJsonPath, findInstalledPackageJson(packageName, projectRoot));
|
|
279
342
|
if (packageName !== "@happyvertical/smrt-app-runtime" && isAppResolvable) if (needsSvelteCompilation && packageJson) selective.set(packageName, {
|
|
280
343
|
packageJson,
|
|
@@ -818,7 +881,6 @@ async function generateRegistrationFile(manifest, projectRoot) {
|
|
|
818
881
|
if (!providerPackageJson) return false;
|
|
819
882
|
return sameInstalledPackage(projectPackageJson, importPackageName === providerPackageName ? providerPackageJson : findInstalledPackageJson(importPackageName, path$1.dirname(providerPackageJson)));
|
|
820
883
|
};
|
|
821
|
-
for (const packageName of manifest.smrtDependencies ?? []) if (isSameProjectAndProviderImport(packageName, packageName) && !importsByPath.has(packageName)) importsByPath.set(packageName, /* @__PURE__ */ new Map());
|
|
822
884
|
const registrations = [];
|
|
823
885
|
const registrationManifests = {};
|
|
824
886
|
let importedEntryCount = 0;
|
|
@@ -837,6 +899,17 @@ async function generateRegistrationFile(manifest, projectRoot) {
|
|
|
837
899
|
for (const lookupKey of lookupKeys) if (lookupKey && !manifestObjectLookup.has(lookupKey)) manifestObjectLookup.set(lookupKey, candidate);
|
|
838
900
|
}
|
|
839
901
|
const collectionClassMemo = /* @__PURE__ */ new WeakMap();
|
|
902
|
+
const svelteRootImportWarnings = /* @__PURE__ */ new Set();
|
|
903
|
+
const rootImportedObjects = /* @__PURE__ */ new Map();
|
|
904
|
+
for (const [objectName, def] of Object.entries(manifestObjects)) {
|
|
905
|
+
if (!def.packageName || def.packageName === manifest.packageName) continue;
|
|
906
|
+
const objectImportPath = def.importPath || def.packageName;
|
|
907
|
+
if (objectImportPath !== packageNameFromImportPath(objectImportPath)) continue;
|
|
908
|
+
const names = rootImportedObjects.get(objectImportPath) ?? [];
|
|
909
|
+
names.push(def.className || def.exportName || objectName);
|
|
910
|
+
names.sort((left, right) => left.localeCompare(right));
|
|
911
|
+
rootImportedObjects.set(objectImportPath, names);
|
|
912
|
+
}
|
|
840
913
|
const isCollectionClass = (def, seen = /* @__PURE__ */ new Set()) => {
|
|
841
914
|
if (!def || typeof def !== "object") return false;
|
|
842
915
|
const cached = collectionClassMemo.get(def);
|
|
@@ -868,6 +941,11 @@ async function generateRegistrationFile(manifest, projectRoot) {
|
|
|
868
941
|
const providerPackageName = def.providerPackageName;
|
|
869
942
|
const appResolvable = isSameProjectAndProviderImport(importPath, providerPackageName);
|
|
870
943
|
if (!appResolvable && !providerPackageName) throw new Error(`[smrt:consumer] ${objectName} has no configured provider provenance for ${importPath}`);
|
|
944
|
+
if (importPath === packageNameFromImportPath(importPath) && !svelteRootImportWarnings.has(importPath)) {
|
|
945
|
+
svelteRootImportWarnings.add(importPath);
|
|
946
|
+
const providerPackageJsonPath = appResolvable ? void 0 : findInstalledPackageJson(providerPackageName, projectRoot);
|
|
947
|
+
if (isComponentBearingRoot(readInstalledPackageJson(appResolvable ? findInstalledPackageJson(importPath, projectRoot) : providerPackageJsonPath && findInstalledPackageJson(importPath, path$1.dirname(providerPackageJsonPath))))) console.warn(`[smrt:consumer] ${importPath} declares a Svelte root entry (a "svelte" field, or a "svelte" condition or a .svelte/.css target on its "." export) and exports ${(rootImportedObjects.get(importPath) ?? [objectName]).join(", ")} only from that root; .smrt/register.js keeps the root import${appResolvable ? "" : ` (loaded through ${providerPackageName})`}. Verify that root loads under plain Node (smrt db:migrate, task/schedule workers), or publish the package's @smrt() objects from a ./models or ./objects export.`);
|
|
948
|
+
}
|
|
871
949
|
const exportBinding = appResolvable ? getImportBinding(importPath, exportName) : getTransitiveBinding(importPath, providerPackageName, exportName);
|
|
872
950
|
const collectionBinding = hasCollection && collectionExportName ? appResolvable ? getImportBinding(importPath, collectionExportName) : getTransitiveBinding(importPath, providerPackageName, collectionExportName) : void 0;
|
|
873
951
|
if (!appResolvable && collectionBinding) transitiveCollectionChecks.push({
|
|
@@ -890,6 +968,12 @@ async function generateRegistrationFile(manifest, projectRoot) {
|
|
|
890
968
|
}`);
|
|
891
969
|
registeredObjectCount++;
|
|
892
970
|
}
|
|
971
|
+
for (const packageName of manifest.smrtDependencies ?? []) {
|
|
972
|
+
if (!isSameProjectAndProviderImport(packageName, packageName)) continue;
|
|
973
|
+
const contextImport = resolveProviderContextImport(packageName, readInstalledPackageJson(findInstalledPackageJson(packageName, projectRoot)));
|
|
974
|
+
if (!contextImport || importsByPath.has(contextImport)) continue;
|
|
975
|
+
importsByPath.set(contextImport, /* @__PURE__ */ new Map());
|
|
976
|
+
}
|
|
893
977
|
if (importedEntryCount === 0) {
|
|
894
978
|
console.log("[smrt:consumer] No external entries - skipping register.js");
|
|
895
979
|
return;
|
|
@@ -1046,6 +1130,6 @@ export default manifest;
|
|
|
1046
1130
|
`;
|
|
1047
1131
|
}
|
|
1048
1132
|
//#endregion
|
|
1049
|
-
export { loadVerifiedSmrtGenerationSnapshot, serializeSmrtGenerationSnapshot, sha256SmrtGenerationSnapshot, smrtConsumer };
|
|
1133
|
+
export { isComponentBearingRoot, loadVerifiedSmrtGenerationSnapshot, resolveProviderContextImport, serializeSmrtGenerationSnapshot, sha256SmrtGenerationSnapshot, smrtConsumer };
|
|
1050
1134
|
|
|
1051
1135
|
//# sourceMappingURL=index.js.map
|