@ttsc/unplugin 0.30.2 → 0.30.4

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.
@@ -1,4 +1,4 @@
1
- import type { ITtscCompilerTransformation } from "ttsc";
1
+ import { type TtscWatchInput } from "./transform.cjs";
2
2
  /** One module node inside a Vite module graph; opaque to this module. */
3
3
  type ViteModuleNodeLike = object;
4
4
  /**
@@ -30,49 +30,46 @@ interface ViteEnvironmentLike {
30
30
  * carries.
31
31
  */
32
32
  export interface ViteDevServerLike {
33
+ config?: {
34
+ root?: string;
35
+ };
33
36
  environments?: Record<string, ViteEnvironmentLike>;
34
37
  hot?: ViteHotChannelLike;
35
38
  moduleGraph?: ViteModuleGraphLike;
36
39
  ws?: ViteHotChannelLike;
37
40
  }
41
+ export interface ViteServeWatchOperations {
42
+ /** Override case-policy discovery for a simulated host filesystem. */
43
+ caseSensitive?(directory: string): boolean;
44
+ /** Override path semantics when testing a non-host platform. */
45
+ platform?: NodeJS.Platform;
46
+ poll(listener: () => void): {
47
+ close(): void;
48
+ };
49
+ watch(root: string, listener: (eventType: string, file: string | null) => void, onError: () => void): {
50
+ close(): void;
51
+ };
52
+ }
53
+ /** Serve-time compiler dependencies never enter Vite's runtime import graph. */
54
+ export interface ViteServeInputWatch {
55
+ attach(server: ViteDevServerLike): void;
56
+ begin(): number;
57
+ dispose(): Promise<void>;
58
+ /** Release every compiler input owned by one removed source module. */
59
+ forget(importer: string): void;
60
+ replace(importer: string, inputs: readonly TtscWatchInput[], failed?: boolean, startedAt?: number): void;
61
+ }
38
62
  /**
39
- * Filesystem watch for derived watch inputs that Vite cannot safely register as
40
- * added imports while a development server is running.
63
+ * A bounded recursive filesystem observer shared by all served modules.
41
64
  *
42
- * Vite serve treats every transform-context `addWatchFile()` registration as an
43
- * added import: `TransformPluginContext.addWatchFile` stores the path in
44
- * `_addedImports`, and `vite:import-analysis` resolves each entry like a real
45
- * import of the transformed module. A missing path or an existing directory
46
- * that failed a compiler file predicate then fails that resolve and turns the
47
- * importer's first request into a 500, even though the transform succeeded.
48
- *
49
- * This registry is the serve-only replacement for those registrations. Each
50
- * path is polled until its exact compiler predicate observation changes; legacy
51
- * envelopes retain their exists-or-file availability check. Its importers are
52
- * then invalidated in the server's module graphs and one full-reload is sent,
53
- * so the next request retransforms against the new resolution winner. The
54
- * project transform cache re-validates the compiler observation, so the
55
- * retransform recompiles instead of replaying.
65
+ * Vite resolves transform-context addWatchFile as a runtime import, including
66
+ * type-only .server files and non-module plugin assets. Use a separate watcher
67
+ * for compiler inputs, including node_modules, which Vite's watcher ignores.
68
+ * Ordinary files use events after their initial subscription is observed.
69
+ * Missing spellings and directory predicates use the recursive observer for
70
+ * their nearest available scope. Inputs a native scope cannot safely cover
71
+ * share one bounded fallback poll; linked files also share topology checks
72
+ * because retargeting a junction need not emit events on its old descendants.
56
73
  */
57
- export interface ViteServeMissingInputWatch {
58
- /** Adopt the dev server whose module graphs creation events invalidate. */
59
- attach(server: ViteDevServerLike): void;
60
- /** Stop every poll; safe to call repeatedly. */
61
- dispose(): void;
62
- /**
63
- * Report whether a dev server has ever been attached. This is not a liveness
64
- * predicate — the reference intentionally survives the server's close (see
65
- * {@link dispose}) — so route decisions must also gate on the resolved
66
- * config's `command`, as the adapter does.
67
- */
68
- serving(): boolean;
69
- /** Register one unsafe watch input and its exact recorded condition. */
70
- watch(input: string, importer: string, condition: ViteServeInputWatchCondition): void;
71
- }
72
- /** A legacy availability condition or an exact compiler predicate proof. */
73
- export type ViteServeInputWatchCondition = "exists" | "file" | ITtscCompilerTransformation.IInputObservation;
74
- /** Create an empty missing-input watch for one plugin instance. */
75
- export declare function createViteServeMissingInputWatch(): ViteServeMissingInputWatch;
76
- /** Key a private poll by predicate and exact lexical spelling. */
77
- export declare function viteServeMissingInputWatchKey(input: string, condition: ViteServeInputWatchCondition): string;
74
+ export declare function createViteServeInputWatch(operations?: Partial<ViteServeWatchOperations>): ViteServeInputWatch;
78
75
  export {};
@@ -1,4 +1,4 @@
1
- import type { ITtscCompilerTransformation } from "ttsc";
1
+ import { type TtscWatchInput } from "./transform.mjs";
2
2
  /** One module node inside a Vite module graph; opaque to this module. */
3
3
  type ViteModuleNodeLike = object;
4
4
  /**
@@ -30,49 +30,46 @@ interface ViteEnvironmentLike {
30
30
  * carries.
31
31
  */
32
32
  export interface ViteDevServerLike {
33
+ config?: {
34
+ root?: string;
35
+ };
33
36
  environments?: Record<string, ViteEnvironmentLike>;
34
37
  hot?: ViteHotChannelLike;
35
38
  moduleGraph?: ViteModuleGraphLike;
36
39
  ws?: ViteHotChannelLike;
37
40
  }
41
+ export interface ViteServeWatchOperations {
42
+ /** Override case-policy discovery for a simulated host filesystem. */
43
+ caseSensitive?(directory: string): boolean;
44
+ /** Override path semantics when testing a non-host platform. */
45
+ platform?: NodeJS.Platform;
46
+ poll(listener: () => void): {
47
+ close(): void;
48
+ };
49
+ watch(root: string, listener: (eventType: string, file: string | null) => void, onError: () => void): {
50
+ close(): void;
51
+ };
52
+ }
53
+ /** Serve-time compiler dependencies never enter Vite's runtime import graph. */
54
+ export interface ViteServeInputWatch {
55
+ attach(server: ViteDevServerLike): void;
56
+ begin(): number;
57
+ dispose(): Promise<void>;
58
+ /** Release every compiler input owned by one removed source module. */
59
+ forget(importer: string): void;
60
+ replace(importer: string, inputs: readonly TtscWatchInput[], failed?: boolean, startedAt?: number): void;
61
+ }
38
62
  /**
39
- * Filesystem watch for derived watch inputs that Vite cannot safely register as
40
- * added imports while a development server is running.
63
+ * A bounded recursive filesystem observer shared by all served modules.
41
64
  *
42
- * Vite serve treats every transform-context `addWatchFile()` registration as an
43
- * added import: `TransformPluginContext.addWatchFile` stores the path in
44
- * `_addedImports`, and `vite:import-analysis` resolves each entry like a real
45
- * import of the transformed module. A missing path or an existing directory
46
- * that failed a compiler file predicate then fails that resolve and turns the
47
- * importer's first request into a 500, even though the transform succeeded.
48
- *
49
- * This registry is the serve-only replacement for those registrations. Each
50
- * path is polled until its exact compiler predicate observation changes; legacy
51
- * envelopes retain their exists-or-file availability check. Its importers are
52
- * then invalidated in the server's module graphs and one full-reload is sent,
53
- * so the next request retransforms against the new resolution winner. The
54
- * project transform cache re-validates the compiler observation, so the
55
- * retransform recompiles instead of replaying.
65
+ * Vite resolves transform-context addWatchFile as a runtime import, including
66
+ * type-only .server files and non-module plugin assets. Use a separate watcher
67
+ * for compiler inputs, including node_modules, which Vite's watcher ignores.
68
+ * Ordinary files use events after their initial subscription is observed.
69
+ * Missing spellings and directory predicates use the recursive observer for
70
+ * their nearest available scope. Inputs a native scope cannot safely cover
71
+ * share one bounded fallback poll; linked files also share topology checks
72
+ * because retargeting a junction need not emit events on its old descendants.
56
73
  */
57
- export interface ViteServeMissingInputWatch {
58
- /** Adopt the dev server whose module graphs creation events invalidate. */
59
- attach(server: ViteDevServerLike): void;
60
- /** Stop every poll; safe to call repeatedly. */
61
- dispose(): void;
62
- /**
63
- * Report whether a dev server has ever been attached. This is not a liveness
64
- * predicate — the reference intentionally survives the server's close (see
65
- * {@link dispose}) — so route decisions must also gate on the resolved
66
- * config's `command`, as the adapter does.
67
- */
68
- serving(): boolean;
69
- /** Register one unsafe watch input and its exact recorded condition. */
70
- watch(input: string, importer: string, condition: ViteServeInputWatchCondition): void;
71
- }
72
- /** A legacy availability condition or an exact compiler predicate proof. */
73
- export type ViteServeInputWatchCondition = "exists" | "file" | ITtscCompilerTransformation.IInputObservation;
74
- /** Create an empty missing-input watch for one plugin instance. */
75
- export declare function createViteServeMissingInputWatch(): ViteServeMissingInputWatch;
76
- /** Key a private poll by predicate and exact lexical spelling. */
77
- export declare function viteServeMissingInputWatchKey(input: string, condition: ViteServeInputWatchCondition): string;
74
+ export declare function createViteServeInputWatch(operations?: Partial<ViteServeWatchOperations>): ViteServeInputWatch;
78
75
  export {};
@@ -1,4 +1,4 @@
1
- import type { ITtscCompilerTransformation } from "ttsc";
1
+ import { type TtscWatchInput } from "./transform";
2
2
  /** One module node inside a Vite module graph; opaque to this module. */
3
3
  type ViteModuleNodeLike = object;
4
4
  /**
@@ -30,49 +30,46 @@ interface ViteEnvironmentLike {
30
30
  * carries.
31
31
  */
32
32
  export interface ViteDevServerLike {
33
+ config?: {
34
+ root?: string;
35
+ };
33
36
  environments?: Record<string, ViteEnvironmentLike>;
34
37
  hot?: ViteHotChannelLike;
35
38
  moduleGraph?: ViteModuleGraphLike;
36
39
  ws?: ViteHotChannelLike;
37
40
  }
41
+ export interface ViteServeWatchOperations {
42
+ /** Override case-policy discovery for a simulated host filesystem. */
43
+ caseSensitive?(directory: string): boolean;
44
+ /** Override path semantics when testing a non-host platform. */
45
+ platform?: NodeJS.Platform;
46
+ poll(listener: () => void): {
47
+ close(): void;
48
+ };
49
+ watch(root: string, listener: (eventType: string, file: string | null) => void, onError: () => void): {
50
+ close(): void;
51
+ };
52
+ }
53
+ /** Serve-time compiler dependencies never enter Vite's runtime import graph. */
54
+ export interface ViteServeInputWatch {
55
+ attach(server: ViteDevServerLike): void;
56
+ begin(): number;
57
+ dispose(): Promise<void>;
58
+ /** Release every compiler input owned by one removed source module. */
59
+ forget(importer: string): void;
60
+ replace(importer: string, inputs: readonly TtscWatchInput[], failed?: boolean, startedAt?: number): void;
61
+ }
38
62
  /**
39
- * Filesystem watch for derived watch inputs that Vite cannot safely register as
40
- * added imports while a development server is running.
63
+ * A bounded recursive filesystem observer shared by all served modules.
41
64
  *
42
- * Vite serve treats every transform-context `addWatchFile()` registration as an
43
- * added import: `TransformPluginContext.addWatchFile` stores the path in
44
- * `_addedImports`, and `vite:import-analysis` resolves each entry like a real
45
- * import of the transformed module. A missing path or an existing directory
46
- * that failed a compiler file predicate then fails that resolve and turns the
47
- * importer's first request into a 500, even though the transform succeeded.
48
- *
49
- * This registry is the serve-only replacement for those registrations. Each
50
- * path is polled until its exact compiler predicate observation changes; legacy
51
- * envelopes retain their exists-or-file availability check. Its importers are
52
- * then invalidated in the server's module graphs and one full-reload is sent,
53
- * so the next request retransforms against the new resolution winner. The
54
- * project transform cache re-validates the compiler observation, so the
55
- * retransform recompiles instead of replaying.
65
+ * Vite resolves transform-context addWatchFile as a runtime import, including
66
+ * type-only .server files and non-module plugin assets. Use a separate watcher
67
+ * for compiler inputs, including node_modules, which Vite's watcher ignores.
68
+ * Ordinary files use events after their initial subscription is observed.
69
+ * Missing spellings and directory predicates use the recursive observer for
70
+ * their nearest available scope. Inputs a native scope cannot safely cover
71
+ * share one bounded fallback poll; linked files also share topology checks
72
+ * because retargeting a junction need not emit events on its old descendants.
56
73
  */
57
- export interface ViteServeMissingInputWatch {
58
- /** Adopt the dev server whose module graphs creation events invalidate. */
59
- attach(server: ViteDevServerLike): void;
60
- /** Stop every poll; safe to call repeatedly. */
61
- dispose(): void;
62
- /**
63
- * Report whether a dev server has ever been attached. This is not a liveness
64
- * predicate — the reference intentionally survives the server's close (see
65
- * {@link dispose}) — so route decisions must also gate on the resolved
66
- * config's `command`, as the adapter does.
67
- */
68
- serving(): boolean;
69
- /** Register one unsafe watch input and its exact recorded condition. */
70
- watch(input: string, importer: string, condition: ViteServeInputWatchCondition): void;
71
- }
72
- /** A legacy availability condition or an exact compiler predicate proof. */
73
- export type ViteServeInputWatchCondition = "exists" | "file" | ITtscCompilerTransformation.IInputObservation;
74
- /** Create an empty missing-input watch for one plugin instance. */
75
- export declare function createViteServeMissingInputWatch(): ViteServeMissingInputWatch;
76
- /** Key a private poll by predicate and exact lexical spelling. */
77
- export declare function viteServeMissingInputWatchKey(input: string, condition: ViteServeInputWatchCondition): string;
74
+ export declare function createViteServeInputWatch(operations?: Partial<ViteServeWatchOperations>): ViteServeInputWatch;
78
75
  export {};