@navecss/core 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1938,7 +1938,6 @@ function recordRun(state, walk) {
1938
1938
  canReorder: follows !== void 0 && !walk.isNestedBefore && firstAtomWithBlock(walk)?.atomIndex === follows.atom.atomIndex && !hasBlockOfOwn,
1939
1939
  directive,
1940
1940
  follows,
1941
- isWrappedBefore: state.hasOwnNested,
1942
1941
  nested
1943
1942
  });
1944
1943
  }
@@ -1969,10 +1968,7 @@ function emitAtom(state, walk, index) {
1969
1968
  noteAbove(state, walk);
1970
1969
  const last = planned.blocks.at(-1);
1971
1970
  walk.follows = { atom, where: blockWhere(last) };
1972
- state.lastNested = {
1973
- text: `the block of "${atom.name}" ${blockWhere(last)}`,
1974
- block: { atom, directive: walk.directive }
1975
- };
1971
+ state.lastNested = { text: `the block of "${atom.name}" ${blockWhere(last)}` };
1976
1972
  state.isNested = true;
1977
1973
  }
1978
1974
  function emitAtoms(state, directive, atoms2) {
@@ -2588,18 +2584,6 @@ function overriddenLonghands(pairs2) {
2588
2584
  return [...new Set(all)];
2589
2585
  }
2590
2586
 
2591
- // src/directive/migration.ts
2592
- var MIGRATION_VERSION = "0.5.0";
2593
- function overriderSentence(atom) {
2594
- return `Before @navecss/core ${MIGRATION_VERSION} "${atom}" won, because an atom's blocks were placed last in the rule.`;
2595
- }
2596
- function wrappedSpecificitySentence() {
2597
- return `Before @navecss/core ${MIGRATION_VERSION} they were left outside \`& { }\`, so they matched with each selector's own specificity.`;
2598
- }
2599
- function wrappedPseudoElementSentence() {
2600
- return `Before @navecss/core ${MIGRATION_VERSION} they did, because they were left outside \`& { }\`.`;
2601
- }
2602
-
2603
2587
  // src/directive/order-focus.ts
2604
2588
  var RING_CLAUSE = 'This hides the keyboard focus indicator that "focusRing" draws.';
2605
2589
  var REVEAL_CLAUSE = 'This hides again what "srOnlyFocusable" reveals on focus, such as a skip link.';
@@ -2812,19 +2796,12 @@ function markerSentence(finding, context) {
2812
2796
  const target = isSameDirective ? "mark the directive" : `mark the directive that names "${unit.atom.name}"`;
2813
2797
  return `If "${overrider.atom.name}" is meant to win, ${target}: ${printed}`;
2814
2798
  }
2815
- function migrationSentence(finding) {
2816
- const { overrider } = finding.candidate;
2817
- const isBlock = overrider.kind === "atom" && overrider.isBlock;
2818
- if (isBlock || finding.outward !== void 0) return void 0;
2819
- return overriderSentence(finding.unit.atom.name);
2820
- }
2821
2799
  function findingText(finding, context) {
2822
2800
  const opening = `${overriderName(finding)} comes after "${finding.unit.atom.name}"`;
2823
2801
  const reason = `so ${placeClause(finding)} ${valueClause(finding)}.`;
2824
2802
  const sentences = [
2825
2803
  `@nave: ${opening}, ${reason}`,
2826
2804
  focusClauseOf(finding),
2827
- migrationSentence(finding),
2828
2805
  fixSentence(finding, context),
2829
2806
  markerSentence(finding, context)
2830
2807
  ];
@@ -2916,7 +2893,6 @@ function createState(input) {
2916
2893
  directives: [],
2917
2894
  dropped: [],
2918
2895
  directiveTotal: input.nodes.filter((node) => node.kind === "directive").length,
2919
- hasOwnNested: false,
2920
2896
  input,
2921
2897
  isNested: false,
2922
2898
  isPseudoElementRule: isPseudoElementOnlyList(input.selector),
@@ -2949,19 +2925,17 @@ function anchorOf2(run) {
2949
2925
  function pseudoElementText(run, pseudo) {
2950
2926
  const other = `Or move ${pseudo} to a separate rule, with or without them.`;
2951
2927
  if (run.kind === "own") {
2952
- return `@nave: the declarations after ${run.nested} are written inside ${WRAP}, which cannot match a pseudo-element, so they do not apply to ${pseudo}. ${wrappedPseudoElementSentence()} To apply them there too, move them above ${run.above}. ${other}`;
2928
+ return `@nave: the declarations after ${run.nested} are written inside ${WRAP}, which cannot match a pseudo-element, so they do not apply to ${pseudo}. To apply them there too, move them above ${run.above}. ${other}`;
2953
2929
  }
2954
2930
  const atoms2 = quoted(run.atoms.map((atom) => atom.name));
2955
- const sentence = run.isWrappedBefore ? "" : ` ${wrappedPseudoElementSentence()}`;
2956
2931
  const separate = `Move ${pseudo} to a separate rule, with or without them.`;
2957
- if (run.follows) return followsText(run, { atoms: atoms2, pseudo, sentence, separate, other });
2958
- const nestedSentence = run.nested.block && !run.isWrappedBefore ? sentence : "";
2932
+ if (run.follows) return followsText(run, { atoms: atoms2, pseudo, separate, other });
2959
2933
  const move = run.canMoveDirective ? ` To apply them there too, move the directive above ${run.above}. ${other}` : ` ${separate}`;
2960
- return `@nave: this directive comes after ${run.nested.text}, so the declarations of ${atoms2} are written inside ${WRAP}, which cannot match a pseudo-element: they do not apply to ${pseudo}.${nestedSentence}${move}`;
2934
+ return `@nave: this directive comes after ${run.nested.text}, so the declarations of ${atoms2} are written inside ${WRAP}, which cannot match a pseudo-element: they do not apply to ${pseudo}.${move}`;
2961
2935
  }
2962
2936
  function followsText(run, parts) {
2963
2937
  const { follows } = run;
2964
- const head = `@nave: the declarations of ${parts.atoms} follow the block of "${follows.atom.name}" ${follows.where}, so they are written inside ${WRAP}, which cannot match a pseudo-element: they do not apply to ${parts.pseudo}.${parts.sentence}`;
2938
+ const head = `@nave: the declarations of ${parts.atoms} follow the block of "${follows.atom.name}" ${follows.where}, so they are written inside ${WRAP}, which cannot match a pseudo-element: they do not apply to ${parts.pseudo}.`;
2965
2939
  if (!run.canReorder) return `${head} ${parts.separate}`;
2966
2940
  const printed = directiveWithAtomsBefore(run.directive.prelude, run.directive.atoms, {
2967
2941
  moving: run.atoms.map((atom) => atom.atomIndex),
@@ -2991,8 +2965,7 @@ function wrapText(run, selectors) {
2991
2965
  const list = selectors.others.join(", ");
2992
2966
  const wholeList = [`:is(${list})`, ...selectors.pseudoElements].join(", ");
2993
2967
  const subject = run.kind === "own" ? `the declarations after ${run.nested}` : `the declarations of ${quoted(run.atoms.map((atom) => atom.name))}`;
2994
- const sentence = run.kind === "directive" && run.isWrappedBefore ? "" : ` ${wrappedSpecificitySentence()}`;
2995
- return `@nave: ${subject} are written inside ${WRAP}, which under the selector list ${list} matches with the specificity of ${most}, so where ${joinList(less, "or")} matches they can win over a rule elsewhere that is more specific than ${joinList(less, "or")}.${sentence} To give each selector its own specificity, write the rule once for each of ${groupsText(selectors, specificities)}. To give the whole rule the specificity of ${most}, write the list as \`${wholeList}\`.`;
2968
+ return `@nave: ${subject} are written inside ${WRAP}, which under the selector list ${list} matches with the specificity of ${most}, so where ${joinList(less, "or")} matches they can win over a rule elsewhere that is more specific than ${joinList(less, "or")}. To give each selector its own specificity, write the rule once for each of ${groupsText(selectors, specificities)}. To give the whole rule the specificity of ${most}, write the list as \`${wholeList}\`.`;
2996
2969
  }
2997
2970
  function isUnequal(selectors) {
2998
2971
  const [first, ...rest] = selectors.others.map((selector) => ampersandSpecificity(selector));
@@ -3099,7 +3072,6 @@ function keepNested(state, node) {
3099
3072
  flushRun(state);
3100
3073
  state.items.push({ kind: "keep", ref: node.ref });
3101
3074
  state.isNested = true;
3102
- state.hasOwnNested = true;
3103
3075
  state.lastNested = { text: nestedText(node) };
3104
3076
  state.above ??= nestedText(node);
3105
3077
  }
@@ -1,4 +1,4 @@
1
- import { foldLocated } from './chunk-MWHZ26S4.js';
1
+ import { foldLocated } from './chunk-KDLLTOAM.js';
2
2
  import { formatDiagnostic } from './chunk-SYNQJNVB.js';
3
3
 
4
4
  // src/directive/report-text.ts
package/dist/collect.d.ts CHANGED
@@ -55,6 +55,13 @@ interface Problem {
55
55
  * export), so a build-end check can tell whether an importer takes it.
56
56
  */
57
57
  readonly exportedAs?: readonly string[];
58
+ /**
59
+ * For a use in a dependency that hands Nave's `cx` out of its module where the build cannot
60
+ * follow it to an export (it is assigned to something other than a name of the module, passed
61
+ * as a value, bound, or imported in a form the build does not read). A hand-out the build can
62
+ * follow carries `exportedAs` instead.
63
+ */
64
+ readonly isUnboundHandOut?: boolean;
58
65
  /**
59
66
  * For a problem in a module listed in `cxModules`: whether the module also exports Nave's own
60
67
  * `cx`. An importer's `cx` is then Nave's, so what the build says of its calls is not an echo of
@@ -193,20 +200,16 @@ declare function inspectAtomicLayer(css: string): LayerReading;
193
200
  */
194
201
  declare function unprunedAtoms(css: string, emitted: ReadonlySet<string>): string[];
195
202
 
196
- /**
197
- * `atoms` with the atoms added that restore what an atom in it removes: `srOnlyFocusable` shows
198
- * again on focus what `srOnly` hides, so a set that holds `srOnly` holds it too. This adds to the
199
- * emitted set only, not to `keep` or to what `cx.dynamic()` accepts.
200
- */
201
- declare function withRestorers(atoms: Set<string>): Set<string>;
202
-
203
203
  /**
204
204
  * What an importer takes from a module that gives out Nave's `cx`: which of its `cx` exports it
205
205
  * imports, re-exports or reads off a namespace. The test is by name, not by file: an importer that
206
206
  * takes only `Button` from a module which also exports `cx` as `cn` takes no `cx` from it, so
207
207
  * nothing of its own routes calls through `cn`. A take the parse cannot tell apart (a namespace
208
208
  * passed on, a computed key, a rest element, an `import()` used any other way) counts as taken, and
209
- * so does an importer whose text names the module in no way the build reads (a `require()`).
209
+ * so does an importer whose text names the module in no way the build reads (a `require()`). A
210
+ * declaration written for the types only (`import type`, `export type`, a `type` specifier), and a
211
+ * named import that is referenced only in type positions, take nothing: TypeScript leaves them out
212
+ * of the compiled module.
210
213
  */
211
214
 
212
215
  /**
@@ -235,6 +238,12 @@ interface Taken {
235
238
  * Whether the take comes from what an earlier server command left in the cache directory.
236
239
  */
237
240
  readonly isRecorded?: boolean;
241
+ /**
242
+ * For a dependency's take: whether the build reads it neither as calls only nor as a forward, so
243
+ * it cannot tell where what is taken goes. `form` says what the dependency does, in words.
244
+ */
245
+ readonly isHeld?: boolean;
246
+ readonly form?: string;
238
247
  }
239
248
  interface Take extends Taken {
240
249
  /**
@@ -248,6 +257,46 @@ interface Take extends Taken {
248
257
  readonly isReached: boolean;
249
258
  }
250
259
 
260
+ /**
261
+ * `cxModules`: the modules a consumer lists as re-exporting Nave's `cx`, and what the post-order
262
+ * half does with them. An import is from a listed module when its specifier resolves, from the
263
+ * importing module, to a listed module's file, or, for an entry that is not relative, when it
264
+ * equals the entry as written (a relative specifier names a file relative to the module that
265
+ * writes it, so its text alone names nothing). An entry that is, or resolves to, Nave's own `cx`
266
+ * module is no entry: that module is always followed. A module is parsed only when its text can
267
+ * name a listed one (a text test, so an application of thousands of modules parses the importers
268
+ * and no more), and a build-end check compares the importers it recognised with the module
269
+ * graph's, so an import through a spelling the text test cannot see fails the build instead of
270
+ * shipping every call made through it with no rule.
271
+ */
272
+
273
+ interface DeclaredModules {
274
+ /**
275
+ * The entries a specifier may equal as written: every entry but a relative one.
276
+ */
277
+ readonly entries: ReadonlySet<string>;
278
+ /**
279
+ * The module id each entry resolves to from the project root; an entry that resolves to nothing
280
+ * has none.
281
+ */
282
+ readonly ids: ReadonlyMap<string, string>;
283
+ /**
284
+ * The files the entries resolve to.
285
+ */
286
+ readonly files: ReadonlySet<string>;
287
+ /**
288
+ * The names a specifier's last segment may carry to name a listed file: its name without its
289
+ * extension, and its directory's when it is an `index` file.
290
+ */
291
+ readonly names: ReadonlySet<string>;
292
+ /**
293
+ * Finds, in a module's text, a quoted specifier that can name a listed file: one whose last
294
+ * segment is one of `names`, or a directory specifier that writes no name when a listed file
295
+ * is an `index` file. `undefined` when no listed file resolved.
296
+ */
297
+ readonly textTest: RegExp | undefined;
298
+ }
299
+
251
300
  /**
252
301
  * The report a build fails with when it meets a use it cannot read: a first line counting the
253
302
  * problems and stating the cause, one line per problem with a 1-based, root-relative position,
@@ -292,12 +341,23 @@ interface LocatedProblem extends Problem {
292
341
  * application modules that take one of its `cx` exports, which `keepFor` does not clear.
293
342
  */
294
343
  readonly takes?: readonly Take[] | undefined;
344
+ /**
345
+ * For a problem with `takes`: how the host names the root a `cxModules` specifier resolves from,
346
+ * in the words the remedy line for those takes uses.
347
+ */
348
+ readonly rootName?: string | undefined;
295
349
  /**
296
350
  * For a dependency module that re-exports the `cx` of a module `cxModules` lists: the modules of
297
351
  * other dependencies that call through it, root-relative, which only the package's `keepFor`
298
352
  * entry can stand in for.
299
353
  */
300
354
  readonly callers?: readonly string[] | undefined;
355
+ /**
356
+ * For a dependency's problem that stays an error whatever the application imports, and that no
357
+ * `keepFor` entry clears: a hand-out of `cx` the build cannot follow to an export, or a take of a
358
+ * module that gives `cx` out that the build reads neither as calls only nor as a forward.
359
+ */
360
+ readonly isHeld?: boolean;
301
361
  }
302
362
  declare const REPORT_CAUSE = "the build cannot tell which atoms these apply, and it ships only the atoms it can read.";
303
363
  /**
@@ -305,13 +365,249 @@ declare const REPORT_CAUSE = "the build cannot tell which atoms these apply, and
305
365
  * lines of the application's kinds and before any package's line.
306
366
  */
307
367
  type HostRemedies = (application: readonly LocatedProblem[]) => readonly string[];
368
+ /**
369
+ * What a host adds to the report besides where its options are written: the remedy lines only it
370
+ * can write, and where its own documentation says how to ship every atom, which is the Vite
371
+ * plugin's README section when it names none.
372
+ */
373
+ interface ReportHost {
374
+ readonly remedies?: HostRemedies;
375
+ readonly everyAtom?: string;
376
+ }
308
377
  /**
309
378
  * The build report for every problem of an environment. `configured` is the `cxModules` list the
310
379
  * remedies that print one extend, and `home` is how the host spells where the options are written,
311
- * the call of its plugin or its wrapper: the one place the report names its host. `hostRemedies`
312
- * adds the lines only the host can write.
380
+ * the call of its plugin or its wrapper: the one place the report names its host. `host` adds
381
+ * what only the host can write, given as a {@link ReportHost} or, as before, as its remedy lines
382
+ * alone.
313
383
  */
314
- declare function buildReport(problems: readonly LocatedProblem[], configured: readonly string[], home: string, hostRemedies?: HostRemedies): string;
384
+ declare function buildReport(problems: readonly LocatedProblem[], configured: readonly string[], home: string, host?: HostRemedies | ReportHost): string;
385
+
386
+ /**
387
+ * One import a server module of the consumer's makes of a listed package: the module, root
388
+ * relative, the specifier it writes, what it takes from it (any name counting as a `cx` export),
389
+ * and the file the server loads for it when that is known.
390
+ */
391
+ interface ServerImport {
392
+ readonly file?: string;
393
+ /**
394
+ * Whether the module imports the package in a way the build cannot read, such as `require()`.
395
+ */
396
+ readonly isUnreadable?: boolean;
397
+ /**
398
+ * Whether an earlier server command recorded it, not a server environment of this process.
399
+ */
400
+ readonly isRecorded?: boolean;
401
+ readonly specifier: string;
402
+ readonly takes: readonly Taken[];
403
+ readonly taker: string;
404
+ }
405
+ /**
406
+ * A server import whose target the client graph holds: the file it resolves to.
407
+ */
408
+ interface ResolvedServerImport extends ServerImport {
409
+ readonly file: string;
410
+ }
411
+
412
+ /**
413
+ * What the build-end read of who takes a `cx` that a dependency gives out needs of its host: the
414
+ * module graph (who imports a module, the text of a module, what a specifier resolves to, how to
415
+ * parse a module) and a few lookups that need the file system, which a host supplies so this
416
+ * code imports no Node module. The Vite plugin supplies them from its `RenderContext` and
417
+ * `UsedContext`; another host supplies them from its own graph.
418
+ */
419
+
420
+ /**
421
+ * What a host's module graph holds about one module.
422
+ */
423
+ interface ModuleInfo {
424
+ readonly code: string | null;
425
+ readonly importers: readonly string[];
426
+ readonly dynamicImporters: readonly string[];
427
+ }
428
+ /**
429
+ * The module graph of a build, as the read of the takes asks it.
430
+ */
431
+ interface ModuleHost {
432
+ /**
433
+ * The environment the build-end read runs for, which keys what it resolves once.
434
+ */
435
+ readonly environment: {
436
+ readonly name: string;
437
+ };
438
+ /**
439
+ * What the graph holds about the module `id`, or `null` when it holds none.
440
+ */
441
+ getModuleInfo?(id: string): ModuleInfo | null;
442
+ /**
443
+ * Resolves `source` as imported from `importer`.
444
+ */
445
+ resolve?(source: string, importer?: string): Promise<{
446
+ readonly id: string;
447
+ } | null>;
448
+ /**
449
+ * Every file id the host's build may resolve `source` to, for a host whose build resolves one
450
+ * specifier to different files (by condition, or by mode). Used instead of `resolve`, which
451
+ * answers one of them, wherever a resolution is compared to a file.
452
+ */
453
+ resolveAll?(source: string, importer?: string): Promise<readonly string[]>;
454
+ /**
455
+ * The host's parse of `code`, an ESTree.
456
+ */
457
+ parse?(code: string): unknown;
458
+ /**
459
+ * The host's parse of the module `id` whose text is `code`, for a host that reads authored
460
+ * sources whose language follows from the file. Used instead of `parse` when the host has it.
461
+ */
462
+ parseModule?(code: string, id: string): unknown;
463
+ }
464
+ /**
465
+ * What the read of the takes needs of the build: the project root, the options that decide which
466
+ * packages are listed, the modules `cxModules` lists (resolved once per environment and kept in
467
+ * `state.declared`), and the two lookups that need the file system.
468
+ */
469
+ interface TakesContext {
470
+ readonly root: string;
471
+ /**
472
+ * How the host's messages name `root`, completing the phrase a specifier that resolves from
473
+ * <rootName>.
474
+ */
475
+ readonly rootName: string;
476
+ readonly options: {
477
+ readonly cxModules: readonly string[];
478
+ readonly keepFor: Readonly<Record<string, readonly string[]>>;
479
+ };
480
+ readonly state: {
481
+ readonly declared: Map<string, Promise<DeclaredModules>>;
482
+ };
483
+ /**
484
+ * The name of the package the module `id` belongs to, when it lies under `node_modules`.
485
+ */
486
+ packageOf(id: string): Promise<string | undefined>;
487
+ /**
488
+ * The path a message names the module `id` by: relative to the project root, forward slashes.
489
+ */
490
+ labelOf(id: string): string;
491
+ }
492
+
493
+ /**
494
+ * The modules that give out `cx` through one of its `cx` exports: the module that exports Nave's
495
+ * `cx`, and every module of a dependency, of the same package or of another, that only re-exports
496
+ * one of those exports (a forward, by `export ... from` or by one of the CommonJS forms
497
+ * `vite-require-takes.ts` reads), however many modules away. A module that takes `cx` from any of
498
+ * them takes it from the first. A dependency's other takes (a call, an assignment, a wrapper, a
499
+ * take the build cannot read) end the walk: they are the package's own calls.
500
+ */
501
+
502
+ /**
503
+ * A module that gives out `cx`: the `cx` exports it holds, and whether it holds them by forwarding
504
+ * another module's rather than by exporting Nave's itself.
505
+ */
506
+ interface Holder {
507
+ readonly id: string;
508
+ readonly names: ReadonlySet<string>;
509
+ readonly isReached: boolean;
510
+ }
511
+
512
+ /**
513
+ * A dependency's take of a module that gives out `cx` that the build reads neither as calls only
514
+ * nor as a forward: the importer's module, the package it belongs to and what it does, in words.
515
+ */
516
+ interface Held {
517
+ readonly form: string;
518
+ readonly importer: string;
519
+ readonly pkg: string;
520
+ readonly taker: string;
521
+ }
522
+ interface Routes {
523
+ readonly entry: Take[];
524
+ readonly told: Take[];
525
+ /**
526
+ * The takes a dependency makes of the module that do more than re-export it: its calls.
527
+ */
528
+ readonly calls: Take[];
529
+ /**
530
+ * The takes a dependency makes of the module that the build reads neither as calls only nor as a
531
+ * forward, whatever the dependency is: they stay errors whatever the application imports.
532
+ */
533
+ readonly held: Held[];
534
+ }
535
+
536
+ /**
537
+ * One module that gives out `cx` with what the build read of its takes: the holders of its `cx`
538
+ * exports and the takes the importers of the build make of each. The imports a server environment
539
+ * makes are added when they are known, which can be after the environment that read the rest has
540
+ * ended.
541
+ */
542
+ interface Prepared {
543
+ readonly holders: readonly Holder[];
544
+ readonly isHop: boolean;
545
+ readonly isListed: boolean;
546
+ /**
547
+ * Whether the module has a clearing specifier: a take of the module itself by an application
548
+ * module or a calling dependency is then on the `cxModules` route.
549
+ */
550
+ readonly hasEntry: boolean;
551
+ readonly problems: readonly LocatedProblem[];
552
+ /**
553
+ * How the host names its root, for the remedy line of the takes.
554
+ */
555
+ readonly rootName: string;
556
+ readonly routed: readonly Routes[];
557
+ }
558
+
559
+ /**
560
+ * The build-end judgement of the re-exports of `cx` that a package `keepFor` lists gives out: which
561
+ * of them stay errors because a module of the consumer takes a `cx` export through them, with the
562
+ * line that clears each. The Vite plugin calls it at build end, and a host with another module
563
+ * graph (see `ModuleHost`) calls it over its own, so both say the same thing about the same code.
564
+ */
565
+
566
+ /**
567
+ * What reading one module found: its problems, those a `keepFor` entry stands in for set aside
568
+ * (`suppressed`), and the listed files it reads a `cx` from when it reads no other (`onlyVia`).
569
+ */
570
+ interface ModuleOutcome {
571
+ readonly onlyVia?: ReadonlySet<string> | undefined;
572
+ readonly problems: readonly LocatedProblem[];
573
+ readonly suppressed: readonly LocatedProblem[];
574
+ }
575
+ /**
576
+ * The problems the build fails with, given what each module's reading found: those of a package
577
+ * `keepFor` lists are only the ones its listing does not stand in for, a listed module that
578
+ * exports a `cx` the build does not follow and a `cx` export that a module the consumer can
579
+ * change takes. `serverImports` are the imports a server environment makes of a listed package it
580
+ * leaves external, when the host has such environments.
581
+ * @param host The module graph of the build.
582
+ * @param context The project root, the options, and the lookups that need the file system.
583
+ * @param modules What each module's reading found.
584
+ * @param serverImports What the server environments imported of a listed package.
585
+ * @returns The problems to report, and what was read of the takes of each re-exporting module.
586
+ */
587
+ declare function judgeReexports(host: ModuleHost, context: TakesContext, modules: readonly ModuleOutcome[], serverImports?: readonly ResolvedServerImport[]): Promise<{
588
+ prepared: Prepared[];
589
+ problems: LocatedProblem[];
590
+ }>;
591
+
592
+ /**
593
+ * Whether a module of a dependency hands out the Nave `cx` it imports in a form the build does not
594
+ * bind: see `isImportedCxHandedOut`.
595
+ */
596
+
597
+ /**
598
+ * Whether a module of a dependency hands out the Nave `cx` it imports in a form the build does not
599
+ * bind (a `require()`, a dynamic import, or a specifier other than the package's own), the string
600
+ * naming it starting at `offset`: its result is used for more than calls, or the build cannot find
601
+ * the import. A `cx` that is only called is the package's own call.
602
+ */
603
+ declare function isImportedCxHandedOut(program: AstNode, offset: number): boolean;
604
+
605
+ /**
606
+ * `atoms` with the atoms added that restore what an atom in it removes: `srOnlyFocusable` shows
607
+ * again on focus what `srOnly` hides, so a set that holds `srOnly` holds it too. This adds to the
608
+ * emitted set only, not to `keep` or to what `cx.dynamic()` accepts.
609
+ */
610
+ declare function withRestorers(atoms: Set<string>): Set<string>;
315
611
 
316
- export { CX_SOURCE, REPORT_CAUSE, buildReport, inspectAtomicLayer, pruneAtomicLayer, readModule, unprunedAtoms, withRestorers };
317
- export type { AstNode, HostRemedies, LayerReading, LocatedProblem, ModuleReading, Problem, ProblemKind, ReadOptions };
612
+ export { CX_SOURCE, REPORT_CAUSE, buildReport, inspectAtomicLayer, isImportedCxHandedOut, judgeReexports, pruneAtomicLayer, readModule, unprunedAtoms, withRestorers };
613
+ export type { AstNode, HostRemedies, LayerReading, LocatedProblem, ModuleHost, ModuleInfo, ModuleOutcome, ModuleReading, Problem, ProblemKind, ReadOptions, ReportHost, TakesContext };
package/dist/collect.js CHANGED
@@ -1,5 +1,41 @@
1
- export { CX_SOURCE, REPORT_CAUSE, assertOptions, buildReport, inspectAtomicLayer, keptAtoms, pruneAtomicLayer, readModule, resolveUsedOptions, unprunedAtoms, withRestorers } from './chunk-BCUK4M4P.js';
1
+ import { analyze, isUsedAsCallsOnly, CX_ONLY, nodesAt, nodeAt, pushAll, childrenOf, staticStringOf, flowOf } from './chunk-EYMFWE3A.js';
2
+ export { CX_SOURCE, REPORT_CAUSE, assertOptions, buildReport, inspectAtomicLayer, judgeReexports, keptAtoms, pruneAtomicLayer, readModule, resolveUsedOptions, unprunedAtoms, withRestorers } from './chunk-EYMFWE3A.js';
2
3
  import './chunk-SYNQJNVB.js';
3
4
  import './chunk-CUL5PLPI.js';
4
5
  import './chunk-2K5EBBF2.js';
5
6
  import './chunk-GZL2VW7C.js';
7
+
8
+ // src/vite-require-handed-out.ts
9
+ function allNodes(program) {
10
+ const found = [];
11
+ const stack = [program];
12
+ while (stack.length > 0) {
13
+ const node = stack.pop();
14
+ found.push(node);
15
+ pushAll(stack, childrenOf(node));
16
+ }
17
+ return found;
18
+ }
19
+ function importAt(nodes, offset) {
20
+ return nodes.find((node) => {
21
+ const literal = node.type === "CallExpression" ? nodesAt(node, "arguments")[0] : nodeAt(node, "source") ?? nodeAt(nodeAt(node, "moduleReference") ?? node, "expression");
22
+ return literal?.start === offset && node.type !== "Literal";
23
+ });
24
+ }
25
+ function isDeclarationHandedOut(analysis, declaration) {
26
+ const source = staticStringOf(nodeAt(declaration, "source"));
27
+ return analysis.references.filter(({ binding }) => binding?.kind === "import" && binding.source === source).some(({ node }) => {
28
+ const flow = flowOf(analysis, node);
29
+ return flow.isUnbound || flow.names.size > 0;
30
+ });
31
+ }
32
+ function isImportedCxHandedOut(program, offset) {
33
+ const analysis = analyze(program);
34
+ const node = importAt(allNodes(program), offset);
35
+ if (!node) return true;
36
+ if (node.type === "ImportDeclaration") return isDeclarationHandedOut(analysis, node);
37
+ if (node.type === "ExportNamedDeclaration" || node.type === "ExportAllDeclaration") return true;
38
+ return !isUsedAsCallsOnly(analysis, node, CX_ONLY);
39
+ }
40
+
41
+ export { isImportedCxHandedOut };
@@ -1,7 +1,7 @@
1
1
  import { splitByteOrderMark } from './chunk-2TNTYI4L.js';
2
- import { orderWarningTexts, warningTexts, foldedText } from './chunk-KKUYU75D.js';
3
- import { validateExtendAtomsHostFree } from './chunk-63H2FLGU.js';
4
- import { snapshotExtendMap, expandText } from './chunk-MWHZ26S4.js';
2
+ import { orderWarningTexts, warningTexts, foldedText } from './chunk-R6R5DSTT.js';
3
+ import { validateExtendAtomsHostFree } from './chunk-B5CWZIBK.js';
4
+ import { snapshotExtendMap, expandText } from './chunk-KDLLTOAM.js';
5
5
  import './chunk-UVHGEVMV.js';
6
6
  import './chunk-SYNQJNVB.js';
7
7
  import './chunk-CUL5PLPI.js';
package/dist/postcss.js CHANGED
@@ -1,6 +1,6 @@
1
- import { framedText } from './chunk-KKUYU75D.js';
1
+ import { framedText } from './chunk-R6R5DSTT.js';
2
2
  import { resolveExtendSpecifier, applyExtendModule } from './chunk-NKUZNRF4.js';
3
- import { snapshotExtendMap, walkExtendAtoms, foldLocated, anchorSelectorList, plan, planRule, DirectiveFailure, WORKAROUND_GROUP_AT_RULE_NAMES } from './chunk-MWHZ26S4.js';
3
+ import { snapshotExtendMap, walkExtendAtoms, foldLocated, anchorSelectorList, plan, planRule, DirectiveFailure, WORKAROUND_GROUP_AT_RULE_NAMES } from './chunk-KDLLTOAM.js';
4
4
  import './chunk-UVHGEVMV.js';
5
5
  import { formatDiagnostic } from './chunk-SYNQJNVB.js';
6
6
  import './chunk-CUL5PLPI.js';