revine 1.0.5 → 1.1.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.
- package/dist/client.d.ts +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -0
- package/dist/runtime/bundler/defaults/vite.d.ts +1 -0
- package/dist/runtime/bundler/defaults/vite.d.ts.map +1 -1
- package/dist/runtime/bundler/defaults/vite.js +3 -0
- package/dist/runtime/env.d.ts +20 -0
- package/dist/runtime/env.d.ts.map +1 -0
- package/dist/runtime/env.js +29 -0
- package/dist/runtime/routing.d.ts +4 -0
- package/dist/runtime/routing.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +2 -1
- package/src/runtime/bundler/defaults/vite.ts +3 -0
- package/src/runtime/env.ts +30 -0
- package/src/runtime/routing.ts +12 -3
- package/template/.env.example +10 -0
- package/template/src/vite-env.d.ts +21 -0
package/dist/client.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export { NavLink } from "./components/NavLink.js";
|
|
|
5
5
|
export { defineConfig } from "./runtime/defineConfig.js";
|
|
6
6
|
export type { LayoutProps } from "./runtime/types.js";
|
|
7
7
|
export type { LinkProps } from "./components/Link.js";
|
|
8
|
+
export { env, envAll } from "./runtime/env.js";
|
|
8
9
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,cAAc,EACd,WAAW,EACX,WAAW,EACX,SAAS,EACT,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,cAAc,EACd,WAAW,EACX,WAAW,EACX,SAAS,EACT,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/client.js
CHANGED
|
@@ -2,3 +2,4 @@ export { Outlet, RouterProvider, useLocation, useNavigate, useParams, useSearchP
|
|
|
2
2
|
export { Link } from "./components/Link.js";
|
|
3
3
|
export { NavLink } from "./components/NavLink.js";
|
|
4
4
|
export { defineConfig } from "./runtime/defineConfig.js";
|
|
5
|
+
export { env, envAll } from "./runtime/env.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../../src/runtime/bundler/defaults/vite.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../../src/runtime/bundler/defaults/vite.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;CAgB7B,CAAC"}
|
|
@@ -4,6 +4,9 @@ import { revineLoggerPlugin } from "../viteLoggerPlugin.js";
|
|
|
4
4
|
export const defaultViteConfig = {
|
|
5
5
|
plugins: [react(), revinePlugin(), revineLoggerPlugin()],
|
|
6
6
|
logLevel: "silent",
|
|
7
|
+
// Only expose env variables prefixed with REVINE_PUBLIC_ to the browser bundle.
|
|
8
|
+
// Variables without this prefix are never included in client-side code.
|
|
9
|
+
envPrefix: "REVINE_PUBLIC_",
|
|
7
10
|
server: {
|
|
8
11
|
clearScreen: false,
|
|
9
12
|
open: false,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* env() — Revine's typed helper for accessing public environment variables.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import { env } from "revine";
|
|
6
|
+
* const token = env("REVINE_PUBLIC_GITHUB_TOKEN");
|
|
7
|
+
*
|
|
8
|
+
* Rules:
|
|
9
|
+
* - Variables MUST be prefixed with REVINE_PUBLIC_ to be exposed to the browser.
|
|
10
|
+
* - Variables without this prefix are never included in the client bundle.
|
|
11
|
+
* - Values are replaced at build time by Vite (static string replacement).
|
|
12
|
+
* - Never use import.meta.env directly — always use this helper.
|
|
13
|
+
*/
|
|
14
|
+
export declare function env(key: string): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* All public env variables as a typed object.
|
|
17
|
+
* Keys are the full variable names including the REVINE_PUBLIC_ prefix.
|
|
18
|
+
*/
|
|
19
|
+
export declare function envAll(): Record<string, string | undefined>;
|
|
20
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/runtime/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEnD;AAED;;;GAGG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAQ3D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* env() — Revine's typed helper for accessing public environment variables.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import { env } from "revine";
|
|
6
|
+
* const token = env("REVINE_PUBLIC_GITHUB_TOKEN");
|
|
7
|
+
*
|
|
8
|
+
* Rules:
|
|
9
|
+
* - Variables MUST be prefixed with REVINE_PUBLIC_ to be exposed to the browser.
|
|
10
|
+
* - Variables without this prefix are never included in the client bundle.
|
|
11
|
+
* - Values are replaced at build time by Vite (static string replacement).
|
|
12
|
+
* - Never use import.meta.env directly — always use this helper.
|
|
13
|
+
*/
|
|
14
|
+
export function env(key) {
|
|
15
|
+
return import.meta.env[key];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* All public env variables as a typed object.
|
|
19
|
+
* Keys are the full variable names including the REVINE_PUBLIC_ prefix.
|
|
20
|
+
*/
|
|
21
|
+
export function envAll() {
|
|
22
|
+
const all = {};
|
|
23
|
+
for (const [key, value] of Object.entries(import.meta.env)) {
|
|
24
|
+
if (key.startsWith("REVINE_PUBLIC_")) {
|
|
25
|
+
all[key] = value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return all;
|
|
29
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/runtime/routing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/runtime/routing.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,QAAQ,gBAAgB,CAAC;IACvB,MAAM,MAAM,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;CAC7D;AAED,OAAO,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -11,4 +11,5 @@ export { Link } from "./components/Link.js";
|
|
|
11
11
|
export { NavLink } from "./components/NavLink.js";
|
|
12
12
|
export { defineConfig } from "./runtime/defineConfig.js";
|
|
13
13
|
export type { LayoutProps } from "./runtime/types.js";
|
|
14
|
-
export type { LinkProps } from "./components/Link.js";
|
|
14
|
+
export type { LinkProps } from "./components/Link.js";
|
|
15
|
+
export { env, envAll } from "./runtime/env.js";
|
|
@@ -5,6 +5,9 @@ import { revineLoggerPlugin } from "../viteLoggerPlugin.js";
|
|
|
5
5
|
export const defaultViteConfig = {
|
|
6
6
|
plugins: [react(), revinePlugin(), revineLoggerPlugin()],
|
|
7
7
|
logLevel: "silent",
|
|
8
|
+
// Only expose env variables prefixed with REVINE_PUBLIC_ to the browser bundle.
|
|
9
|
+
// Variables without this prefix are never included in client-side code.
|
|
10
|
+
envPrefix: "REVINE_PUBLIC_",
|
|
8
11
|
server: {
|
|
9
12
|
clearScreen: false,
|
|
10
13
|
open: false,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* env() — Revine's typed helper for accessing public environment variables.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import { env } from "revine";
|
|
6
|
+
* const token = env("REVINE_PUBLIC_GITHUB_TOKEN");
|
|
7
|
+
*
|
|
8
|
+
* Rules:
|
|
9
|
+
* - Variables MUST be prefixed with REVINE_PUBLIC_ to be exposed to the browser.
|
|
10
|
+
* - Variables without this prefix are never included in the client bundle.
|
|
11
|
+
* - Values are replaced at build time by Vite (static string replacement).
|
|
12
|
+
* - Never use import.meta.env directly — always use this helper.
|
|
13
|
+
*/
|
|
14
|
+
export function env(key: string): string | undefined {
|
|
15
|
+
return (import.meta.env as Record<string, string | undefined>)[key];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* All public env variables as a typed object.
|
|
20
|
+
* Keys are the full variable names including the REVINE_PUBLIC_ prefix.
|
|
21
|
+
*/
|
|
22
|
+
export function envAll(): Record<string, string | undefined> {
|
|
23
|
+
const all: Record<string, string | undefined> = {};
|
|
24
|
+
for (const [key, value] of Object.entries(import.meta.env)) {
|
|
25
|
+
if (key.startsWith("REVINE_PUBLIC_")) {
|
|
26
|
+
all[key] = value as string | undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return all;
|
|
30
|
+
}
|
package/src/runtime/routing.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
// This module is intentionally empty.
|
|
2
|
-
// `revine/routing` is a virtual module resolved by the Revine Vite plugin at build time.
|
|
1
|
+
// This module is intentionally empty at the source level.
|
|
2
|
+
// `revine/routing` is a virtual module resolved by the Revine Vite plugin at build/dev time.
|
|
3
3
|
// The actual router is injected via the plugin's resolveId/load hooks.
|
|
4
|
-
|
|
4
|
+
//
|
|
5
|
+
// The type declaration below tells TypeScript that `router` exists on this module
|
|
6
|
+
// so consumers don't get ts(2305) errors.
|
|
7
|
+
import { createBrowserRouter } from "react-router-dom";
|
|
8
|
+
|
|
9
|
+
declare module "revine/routing" {
|
|
10
|
+
export const router: ReturnType<typeof createBrowserRouter>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Public environment variables — exposed to the browser bundle.
|
|
2
|
+
# Variables MUST be prefixed with REVINE_PUBLIC_ to be accessible in your app.
|
|
3
|
+
# Copy this file to .env and fill in your values.
|
|
4
|
+
|
|
5
|
+
# Example:
|
|
6
|
+
# REVINE_PUBLIC_API_URL=https://api.example.com
|
|
7
|
+
# REVINE_PUBLIC_APP_NAME=My Revine App
|
|
8
|
+
|
|
9
|
+
# ⚠️ Variables WITHOUT the REVINE_PUBLIC_ prefix are NEVER sent to the browser.
|
|
10
|
+
# Use those for server-side secrets only (they stay in Node processes).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
/// <reference types="revine/routing" />
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Augment ImportMetaEnv so TypeScript knows about your REVINE_PUBLIC_ variables.
|
|
6
|
+
*
|
|
7
|
+
* Add your own variables here:
|
|
8
|
+
*
|
|
9
|
+
* interface ImportMetaEnv {
|
|
10
|
+
* readonly REVINE_PUBLIC_API_URL: string;
|
|
11
|
+
* readonly REVINE_PUBLIC_GITHUB_TOKEN: string;
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
interface ImportMetaEnv {
|
|
15
|
+
// Add your REVINE_PUBLIC_ variables here
|
|
16
|
+
[key: `REVINE_PUBLIC_${string}`]: string | undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface ImportMeta {
|
|
20
|
+
readonly env: ImportMetaEnv;
|
|
21
|
+
}
|