@bapla/site-theme 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +169 -2
- package/dist/base.css +331 -0
- package/dist/chunk-RYCW4YWV.js +69 -0
- package/dist/imgproxy-rioGvvyv.d.ts +189 -0
- package/dist/index.d.ts +220 -0
- package/dist/index.js +904 -0
- package/dist/server.d.ts +26 -0
- package/dist/server.js +31 -0
- package/package.json +65 -4
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { e as ImageUrl } from './imgproxy-rioGvvyv.js';
|
|
2
|
+
export { o as imgproxyPath, p as isTransformable } from './imgproxy-rioGvvyv.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
|
|
5
|
+
interface ImgproxyOptions {
|
|
6
|
+
/** imgproxy's key, hex (`BAPLA_IMAGES_KEY`). */
|
|
7
|
+
key: string;
|
|
8
|
+
/** imgproxy's salt, hex (`BAPLA_IMAGES_SALT`). */
|
|
9
|
+
salt: string;
|
|
10
|
+
/** Where the companion answers on the site's domain (`BAPLA_IMAGES_PATH`, `/_img`). */
|
|
11
|
+
prefix?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Signed image URLs at the site's image companion (`features/websites.md`
|
|
15
|
+
* §5.9) — **on the server only**: the key never reaches a browser. Give the
|
|
16
|
+
* result to `BlocksProvider`'s `imageUrl`. What the companion does not
|
|
17
|
+
* transform (SVG, GIF, video) keeps its `/_media` address.
|
|
18
|
+
*/
|
|
19
|
+
declare function imgproxyUrls({ key, salt, prefix }: ImgproxyOptions): ImageUrl;
|
|
20
|
+
/**
|
|
21
|
+
* {@link imgproxyUrls} from the variables the hosting gives the site, or
|
|
22
|
+
* undefined without them (a site not yet given its companion: `/_media`).
|
|
23
|
+
*/
|
|
24
|
+
declare function imgproxyUrlsFromEnv(env?: Record<string, string | undefined>): ImageUrl | undefined;
|
|
25
|
+
|
|
26
|
+
export { type ImgproxyOptions, imgproxyUrls, imgproxyUrlsFromEnv };
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
imgproxyPath,
|
|
3
|
+
isTransformable,
|
|
4
|
+
mediaUrl
|
|
5
|
+
} from "./chunk-RYCW4YWV.js";
|
|
6
|
+
|
|
7
|
+
// src/server.ts
|
|
8
|
+
import { createHmac } from "crypto";
|
|
9
|
+
function imgproxyUrls({ key, salt, prefix = "/_img" }) {
|
|
10
|
+
const keyBytes = Buffer.from(key, "hex");
|
|
11
|
+
const saltBytes = Buffer.from(salt, "hex");
|
|
12
|
+
const base = prefix.replace(/\/+$/, "");
|
|
13
|
+
return (media, transform = {}) => {
|
|
14
|
+
if (!isTransformable(media)) return mediaUrl(media);
|
|
15
|
+
const path = imgproxyPath(media, transform);
|
|
16
|
+
const signature = createHmac("sha256", keyBytes).update(saltBytes).update(path).digest("base64url");
|
|
17
|
+
return `${base}/${signature}${path}`;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function imgproxyUrlsFromEnv(env = process.env) {
|
|
21
|
+
const key = env.BAPLA_IMAGES_KEY;
|
|
22
|
+
const salt = env.BAPLA_IMAGES_SALT;
|
|
23
|
+
if (!key || !salt) return void 0;
|
|
24
|
+
return imgproxyUrls({ key, salt, prefix: env.BAPLA_IMAGES_PATH || "/_img" });
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
imgproxyPath,
|
|
28
|
+
imgproxyUrls,
|
|
29
|
+
imgproxyUrlsFromEnv,
|
|
30
|
+
isTransformable
|
|
31
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bapla/site-theme",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "The starter theme of the sites hosted by Bapla Websites: the theme from the Appearance, the standard blocks, media and menus, in React and Tailwind CSS 4.",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public",
|
|
7
|
+
"registry": "https://registry.npmjs.org/"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"module": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./server": {
|
|
19
|
+
"types": "./dist/server.d.ts",
|
|
20
|
+
"import": "./dist/server.js"
|
|
21
|
+
},
|
|
22
|
+
"./base.css": "./dist/base.css"
|
|
23
|
+
},
|
|
24
|
+
"sideEffects": [
|
|
25
|
+
"*.css"
|
|
26
|
+
],
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsup && cp src/base.css dist/base.css",
|
|
33
|
+
"dev": "tsup --watch",
|
|
34
|
+
"test": "vitest run"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": "^18.2 || ^19",
|
|
38
|
+
"react-dom": "^18.2 || ^19",
|
|
39
|
+
"tailwindcss": "^4"
|
|
40
|
+
},
|
|
41
|
+
"peerDependenciesMeta": {
|
|
42
|
+
"tailwindcss": {
|
|
43
|
+
"optional": true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@testing-library/jest-dom": "^6",
|
|
48
|
+
"@testing-library/react": "^16",
|
|
49
|
+
"@testing-library/user-event": "^14.6.6",
|
|
50
|
+
"@types/node": "^22.20.5",
|
|
51
|
+
"@types/react": "^19",
|
|
52
|
+
"@types/react-dom": "^19",
|
|
53
|
+
"@vitejs/plugin-react": "^6",
|
|
54
|
+
"jsdom": "^29",
|
|
55
|
+
"react": "^19",
|
|
56
|
+
"react-dom": "^19",
|
|
57
|
+
"tsup": "^8",
|
|
58
|
+
"typescript": "~6.0.2",
|
|
59
|
+
"vitest": "^4"
|
|
60
|
+
},
|
|
61
|
+
"license": "MIT",
|
|
62
|
+
"repository": {
|
|
63
|
+
"type": "git",
|
|
64
|
+
"url": "git+https://gitlab.com/bapla-digital/bapla/central.git",
|
|
65
|
+
"directory": "packages/site-theme"
|
|
66
|
+
}
|
|
67
|
+
}
|