@coding-blocks/vmc-web-components 0.1.1 → 0.1.3
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 +11 -2
- package/dist/types/lib/api.d.ts +2 -1
- package/dist/vmc-web-components.js +1 -50
- package/package.json +3 -1
- package/dist/vmc-web-components.js.map +0 -1
package/README.md
CHANGED
|
@@ -5,8 +5,17 @@ inside, plain custom elements on the outside — a host page only needs one
|
|
|
5
5
|
`<script>` tag and the element.
|
|
6
6
|
|
|
7
7
|
Every component in this repo ships in **one bundle**: `dist/vmc-web-components.js`
|
|
8
|
-
|
|
9
|
-
network requests
|
|
8
|
+
— 37.8 kB, ~14 kB gzipped over the wire, with the runtime and the CSS inlined.
|
|
9
|
+
No peer dependencies, no extra network requests.
|
|
10
|
+
|
|
11
|
+
The source is written against React, but the build aliases `react`/`react-dom`
|
|
12
|
+
to `preact/compat`, which is what actually ships — same JSX and hooks, ~5x
|
|
13
|
+
smaller for a script that loads on other people's pages. Nothing in `src/`
|
|
14
|
+
imports Preact directly, so the alias in `vite.config.ts` is the only place that
|
|
15
|
+
knows. Two build notes worth keeping: the published bundle carries **no
|
|
16
|
+
sourcemap** (it was 4.5x the size of the code), and terser's `unsafe_*` /
|
|
17
|
+
`booleans_as_integers` options are deliberately off — they saved ~2 kB and broke
|
|
18
|
+
Preact's event proxy at runtime.
|
|
10
19
|
|
|
11
20
|
## Usage
|
|
12
21
|
|
package/dist/types/lib/api.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ export declare class ApiError extends Error {
|
|
|
2
2
|
status: number;
|
|
3
3
|
constructor(message: string, status: number);
|
|
4
4
|
}
|
|
5
|
+
export type Headers = Record<string, string>;
|
|
5
6
|
export type Api = {
|
|
6
7
|
get: <T>(path: string, params?: Record<string, string | undefined>) => Promise<T>;
|
|
7
|
-
post: <T>(path: string, body?: unknown) => Promise<T>;
|
|
8
|
+
post: <T>(path: string, body?: unknown, headers?: Headers) => Promise<T>;
|
|
8
9
|
};
|
|
9
10
|
export declare const createApi: (base: string) => Api;
|
|
10
11
|
export declare const errorMessage: (err: unknown) => string;
|