@vite-hub/env 0.0.0 → 0.0.2
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 +103 -1
- package/dist/declarations-BIBfEwer.d.ts +23 -0
- package/dist/declarations-Cy5XamUA.js +144 -0
- package/dist/errors-RUmAFDJn.js +112 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +6 -0
- package/dist/presets.d.ts +11 -0
- package/dist/presets.js +25 -0
- package/dist/schema.d.ts +16 -0
- package/dist/schema.js +37 -0
- package/dist/secret.d.ts +11 -0
- package/dist/secret.js +26 -0
- package/dist/server-B2Dp8Nc0.js +59 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.js +3 -0
- package/dist/types-FcnPKias.d.ts +153 -0
- package/dist/virtual.d.ts +15 -0
- package/dist/virtual.js +1 -0
- package/dist/vite.d.ts +33 -0
- package/dist/vite.js +819 -0
- package/package.json +83 -5
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
type EnvDiagnostics = "off" | "summary" | "trace";
|
|
3
|
+
type EnvMode = "build" | "runtime";
|
|
4
|
+
interface EnvIntegrationOptions {
|
|
5
|
+
diagnostics?: EnvDiagnostics;
|
|
6
|
+
prefix?: string;
|
|
7
|
+
projectRoot?: string;
|
|
8
|
+
runtimeImports?: EnvRuntimeImportSpecifiers;
|
|
9
|
+
}
|
|
10
|
+
interface EnvRuntimeImportSpecifiers {
|
|
11
|
+
secret?: string;
|
|
12
|
+
server?: string;
|
|
13
|
+
}
|
|
14
|
+
interface EnvSourceContext {
|
|
15
|
+
build: {
|
|
16
|
+
timestamp: () => string;
|
|
17
|
+
};
|
|
18
|
+
env: Record<string, string | undefined>;
|
|
19
|
+
git: {
|
|
20
|
+
branch: () => Promise<string>;
|
|
21
|
+
commit: (options?: {
|
|
22
|
+
short?: boolean;
|
|
23
|
+
}) => Promise<string>;
|
|
24
|
+
ref: () => Promise<string>;
|
|
25
|
+
sha: (options?: {
|
|
26
|
+
short?: boolean;
|
|
27
|
+
}) => Promise<string>;
|
|
28
|
+
tag: () => Promise<string | undefined>;
|
|
29
|
+
};
|
|
30
|
+
mode: EnvMode;
|
|
31
|
+
packageJson: () => Promise<Record<string, unknown>>;
|
|
32
|
+
rootDir: string;
|
|
33
|
+
}
|
|
34
|
+
type EnvSourceResolver = (context: EnvSourceContext) => unknown | Promise<unknown>;
|
|
35
|
+
type EnvSource = {
|
|
36
|
+
kind: "custom";
|
|
37
|
+
label: string;
|
|
38
|
+
resolver: EnvSourceResolver;
|
|
39
|
+
serializable: false;
|
|
40
|
+
} | {
|
|
41
|
+
kind: "env";
|
|
42
|
+
label: string;
|
|
43
|
+
name: string;
|
|
44
|
+
names?: string[];
|
|
45
|
+
serializable: true;
|
|
46
|
+
} | {
|
|
47
|
+
kind: "git-branch";
|
|
48
|
+
label: "git:branch";
|
|
49
|
+
serializable: true;
|
|
50
|
+
} | {
|
|
51
|
+
kind: "git-commit";
|
|
52
|
+
label: "git:commit";
|
|
53
|
+
serializable: true;
|
|
54
|
+
short?: boolean;
|
|
55
|
+
} | {
|
|
56
|
+
kind: "git-ref";
|
|
57
|
+
label: "git:ref";
|
|
58
|
+
serializable: true;
|
|
59
|
+
} | {
|
|
60
|
+
kind: "git-sha";
|
|
61
|
+
label: "git:sha";
|
|
62
|
+
serializable: true;
|
|
63
|
+
short?: boolean;
|
|
64
|
+
} | {
|
|
65
|
+
kind: "git-tag";
|
|
66
|
+
label: "git:tag";
|
|
67
|
+
serializable: true;
|
|
68
|
+
} | {
|
|
69
|
+
kind: "build-timestamp";
|
|
70
|
+
label: "build:timestamp";
|
|
71
|
+
serializable: true;
|
|
72
|
+
} | {
|
|
73
|
+
kind: "package-json";
|
|
74
|
+
label: string;
|
|
75
|
+
path: string;
|
|
76
|
+
serializable: true;
|
|
77
|
+
};
|
|
78
|
+
interface EnvVariableDeclaration {
|
|
79
|
+
default?: unknown;
|
|
80
|
+
kind: "env-variable";
|
|
81
|
+
mode: EnvMode;
|
|
82
|
+
required: boolean;
|
|
83
|
+
schema: unknown;
|
|
84
|
+
secret: boolean;
|
|
85
|
+
source?: EnvSource;
|
|
86
|
+
type?: string;
|
|
87
|
+
}
|
|
88
|
+
interface EnvVariableOptions {
|
|
89
|
+
default?: unknown;
|
|
90
|
+
mode?: EnvMode;
|
|
91
|
+
optional?: boolean;
|
|
92
|
+
required?: boolean;
|
|
93
|
+
schema?: unknown;
|
|
94
|
+
secret?: boolean;
|
|
95
|
+
source?: EnvSource | EnvSourceResolver;
|
|
96
|
+
type?: string;
|
|
97
|
+
}
|
|
98
|
+
type EnvBuildStaticValue = null | string | number | boolean | EnvBuildStaticValue[];
|
|
99
|
+
type EnvBuildConfigValue = EnvBuildConfigOptions | EnvBuildStaticValue | EnvVariableDeclaration;
|
|
100
|
+
interface EnvBuildConfigOptions {
|
|
101
|
+
[key: string]: EnvBuildConfigValue;
|
|
102
|
+
}
|
|
103
|
+
interface EnvViteConfigOptions {
|
|
104
|
+
define?: Record<string, EnvBuildConfigValue>;
|
|
105
|
+
public?: Record<string, EnvVariableDeclaration>;
|
|
106
|
+
server?: EnvRuntimeConfigOptions;
|
|
107
|
+
}
|
|
108
|
+
type EnvRuntimeStaticValue = null | string | number | boolean | EnvRuntimeStaticValue[];
|
|
109
|
+
type EnvRuntimeConfigValue = EnvRuntimeConfigOptions | EnvRuntimeStaticValue | EnvVariableDeclaration;
|
|
110
|
+
interface EnvRuntimeConfigOptions {
|
|
111
|
+
[key: string]: EnvRuntimeConfigValue;
|
|
112
|
+
}
|
|
113
|
+
type EnvConfigOptions = EnvViteConfigOptions;
|
|
114
|
+
interface EnvViteUserConfig {
|
|
115
|
+
env?: EnvViteConfigOptions;
|
|
116
|
+
}
|
|
117
|
+
interface EnvDiagnosticEntry {
|
|
118
|
+
exposed: string;
|
|
119
|
+
key: string;
|
|
120
|
+
masked: boolean;
|
|
121
|
+
mode: EnvMode;
|
|
122
|
+
source: string;
|
|
123
|
+
status: "defaulted" | "missing" | "valid";
|
|
124
|
+
timing: string;
|
|
125
|
+
type?: string;
|
|
126
|
+
}
|
|
127
|
+
interface EnvRegistryEntry {
|
|
128
|
+
default?: unknown;
|
|
129
|
+
required: boolean;
|
|
130
|
+
schema?: EnvRuntimeSchema;
|
|
131
|
+
secret: boolean;
|
|
132
|
+
source: Extract<EnvSource, {
|
|
133
|
+
kind: "env";
|
|
134
|
+
}>;
|
|
135
|
+
type?: string;
|
|
136
|
+
}
|
|
137
|
+
interface EnvRuntimeSchema {
|
|
138
|
+
kind: "string";
|
|
139
|
+
}
|
|
140
|
+
interface EnvRuntimeLiteralEntry {
|
|
141
|
+
kind: "literal";
|
|
142
|
+
value: EnvRuntimeStaticValue;
|
|
143
|
+
}
|
|
144
|
+
type EnvRuntimeRegistryValue = EnvRegistryEntry | EnvRuntimeLiteralEntry | EnvRuntimeRegistry;
|
|
145
|
+
interface EnvRuntimeRegistry {
|
|
146
|
+
[key: string]: EnvRuntimeRegistryValue;
|
|
147
|
+
}
|
|
148
|
+
interface ServerEnv {
|
|
149
|
+
[key: string]: unknown;
|
|
150
|
+
}
|
|
151
|
+
type PublicEnv = Record<string, unknown>;
|
|
152
|
+
//#endregion
|
|
153
|
+
export { EnvMode as a, EnvSource as c, EnvVariableDeclaration as d, EnvVariableOptions as f, ServerEnv as g, PublicEnv as h, EnvIntegrationOptions as i, EnvSourceContext as l, EnvViteUserConfig as m, EnvDiagnosticEntry as n, EnvRuntimeConfigOptions as o, EnvViteConfigOptions as p, EnvDiagnostics as r, EnvRuntimeRegistry as s, EnvConfigOptions as t, EnvSourceResolver as u };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare module "#vitehub/env/public" {
|
|
2
|
+
export interface PublicEnv extends Record<string, unknown> {}
|
|
3
|
+
export const publicEnv: PublicEnv
|
|
4
|
+
export function usePublicEnv(): PublicEnv
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module "#vitehub/env/server" {
|
|
8
|
+
import type { SecretEnv } from "@vite-hub/env/secret"
|
|
9
|
+
|
|
10
|
+
export interface ServerEnv extends Record<string, unknown> {}
|
|
11
|
+
export function useServerEnv(event?: unknown): ServerEnv
|
|
12
|
+
export function runWithServerEnv<T>(event: unknown, callback: (env: ServerEnv) => T | Promise<T>): Promise<T>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {}
|
package/dist/virtual.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { i as EnvIntegrationOptions, p as EnvViteConfigOptions, s as EnvRuntimeRegistry } from "./types-FcnPKias.js";
|
|
2
|
+
import { t as env } from "./declarations-BIBfEwer.js";
|
|
3
|
+
import { Plugin } from "vite";
|
|
4
|
+
|
|
5
|
+
//#region ../internal/src/build/vite.d.ts
|
|
6
|
+
declare const VITEHUB_ENV_PUBLIC_ID: "#vitehub/env/public";
|
|
7
|
+
declare const VITEHUB_ENV_SERVER_ID: "#vitehub/env/server";
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/vite.d.ts
|
|
10
|
+
declare const ENV_VITE_PLUGIN_NAME = "@vite-hub/env/vite";
|
|
11
|
+
declare const ENV_PUBLIC_ID: typeof VITEHUB_ENV_PUBLIC_ID;
|
|
12
|
+
declare const ENV_SERVER_ID: typeof VITEHUB_ENV_SERVER_ID;
|
|
13
|
+
interface EnvVitePluginAPI {
|
|
14
|
+
getPublicEnv: () => Record<string, unknown>;
|
|
15
|
+
getServerEnvRegistry: () => EnvRuntimeRegistry;
|
|
16
|
+
}
|
|
17
|
+
type EnvVitePlugin = Plugin & {
|
|
18
|
+
api: EnvVitePluginAPI;
|
|
19
|
+
};
|
|
20
|
+
interface EnvGeneratedPathOptions {
|
|
21
|
+
projectRoot?: string;
|
|
22
|
+
relativeTo?: string;
|
|
23
|
+
}
|
|
24
|
+
declare function createEnvImportAliases(options?: EnvGeneratedPathOptions): Record<string, string>;
|
|
25
|
+
declare function createEnvTypeScriptPaths(options?: EnvGeneratedPathOptions): Record<string, string[]>;
|
|
26
|
+
declare function hubEnv(options?: EnvIntegrationOptions): EnvVitePlugin;
|
|
27
|
+
declare module "vite" {
|
|
28
|
+
interface UserConfig {
|
|
29
|
+
env?: EnvViteConfigOptions;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { ENV_PUBLIC_ID, ENV_SERVER_ID, ENV_VITE_PLUGIN_NAME, EnvGeneratedPathOptions, EnvVitePlugin, EnvVitePluginAPI, createEnvImportAliases, createEnvTypeScriptPaths, env, hubEnv };
|