@lukas_holdings/castdom 1.0.0 → 1.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 +32 -22
- package/package.json +10 -1
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://img.shields.io/npm/v/castdom?style=flat-square&color=000" alt="npm version"
|
|
2
|
+
<a href="https://www.npmjs.com/package/@lukas_holdings/castdom"><img src="https://img.shields.io/npm/v/@lukas_holdings/castdom?style=flat-square&color=000" alt="npm version" /></a>
|
|
3
|
+
<a href="https://www.npmjs.com/package/@lukas_holdings/castdom"><img src="https://img.shields.io/npm/dm/@lukas_holdings/castdom?style=flat-square&color=000" alt="npm downloads" /></a>
|
|
3
4
|
<img src="https://img.shields.io/badge/license-MIT-000?style=flat-square" alt="license" />
|
|
4
5
|
<img src="https://img.shields.io/badge/runtime-CSS%20only-000?style=flat-square" alt="CSS only runtime" />
|
|
5
6
|
<img src="https://img.shields.io/badge/bundle-~14KB-000?style=flat-square" alt="bundle size" />
|
|
6
|
-
<img src="https://img.shields.io/badge/tests-71%20passed-000?style=flat-square" alt="tests" />
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<h1 align="center">CastDOM</h1>
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
No manual measurement. No hand-tuned placeholders. Zero-config, SSR-first, CSS-only runtime.
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
|
+
<p align="center">
|
|
17
|
+
<code>npm install @lukas_holdings/castdom</code>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
16
20
|
<p align="center">
|
|
17
21
|
<a href="#quick-start">Quick Start</a> •
|
|
18
22
|
<a href="#how-it-works">How It Works</a> •
|
|
@@ -65,7 +69,7 @@ Your Component CastDOM Skeleton
|
|
|
65
69
|
### 1. Install
|
|
66
70
|
|
|
67
71
|
```bash
|
|
68
|
-
npm install castdom
|
|
72
|
+
npm install @lukas_holdings/castdom
|
|
69
73
|
```
|
|
70
74
|
|
|
71
75
|
### 2. Mark your components
|
|
@@ -138,7 +142,7 @@ CastDOM Build
|
|
|
138
142
|
import ".castdom/loader.js";
|
|
139
143
|
|
|
140
144
|
// Use anywhere
|
|
141
|
-
import { CastDOM } from "castdom/react";
|
|
145
|
+
import { CastDOM } from "@lukas_holdings/castdom/react";
|
|
142
146
|
|
|
143
147
|
function UserProfile({ userId }) {
|
|
144
148
|
const { data, isLoading } = useFetch(`/api/users/${userId}`);
|
|
@@ -237,7 +241,7 @@ The compression pipeline:
|
|
|
237
241
|
### `<CastDOM>` Component
|
|
238
242
|
|
|
239
243
|
```tsx
|
|
240
|
-
import { CastDOM } from "castdom/react";
|
|
244
|
+
import { CastDOM } from "@lukas_holdings/castdom/react";
|
|
241
245
|
|
|
242
246
|
<CastDOM
|
|
243
247
|
name="user-card" // Registered skeleton name
|
|
@@ -260,7 +264,7 @@ import { CastDOM } from "castdom/react";
|
|
|
260
264
|
Add to your `<head>` for critical CSS:
|
|
261
265
|
|
|
262
266
|
```tsx
|
|
263
|
-
import { CastDOMStyle } from "castdom/react";
|
|
267
|
+
import { CastDOMStyle } from "@lukas_holdings/castdom/react";
|
|
264
268
|
|
|
265
269
|
function Layout({ children }) {
|
|
266
270
|
return (
|
|
@@ -277,7 +281,7 @@ function Layout({ children }) {
|
|
|
277
281
|
### `useCastDOM` Hook
|
|
278
282
|
|
|
279
283
|
```tsx
|
|
280
|
-
import { useCastDOM } from "castdom/react";
|
|
284
|
+
import { useCastDOM } from "@lukas_holdings/castdom/react";
|
|
281
285
|
|
|
282
286
|
function CustomSkeleton() {
|
|
283
287
|
const { exists, data, breakpoint, css, html } = useCastDOM("user-card");
|
|
@@ -296,7 +300,7 @@ function CustomSkeleton() {
|
|
|
296
300
|
|
|
297
301
|
```tsx
|
|
298
302
|
// app/layout.tsx
|
|
299
|
-
import { initCastDOM } from "castdom/next";
|
|
303
|
+
import { initCastDOM } from "@lukas_holdings/castdom/next";
|
|
300
304
|
import manifest from "../.castdom/manifest.json";
|
|
301
305
|
|
|
302
306
|
initCastDOM(manifest);
|
|
@@ -312,7 +316,7 @@ export default function RootLayout({ children }) {
|
|
|
312
316
|
|
|
313
317
|
```tsx
|
|
314
318
|
// app/dashboard/page.tsx
|
|
315
|
-
import { CastDOM } from "castdom/next";
|
|
319
|
+
import { CastDOM } from "@lukas_holdings/castdom/next";
|
|
316
320
|
|
|
317
321
|
export default async function Dashboard() {
|
|
318
322
|
const data = await fetchDashboard();
|
|
@@ -329,7 +333,7 @@ export default async function Dashboard() {
|
|
|
329
333
|
|
|
330
334
|
```tsx
|
|
331
335
|
// pages/_app.tsx
|
|
332
|
-
import { initCastDOM } from "castdom/next";
|
|
336
|
+
import { initCastDOM } from "@lukas_holdings/castdom/next";
|
|
333
337
|
import manifest from "../.castdom/manifest.json";
|
|
334
338
|
|
|
335
339
|
initCastDOM(manifest);
|
|
@@ -342,7 +346,7 @@ export default function App({ Component, pageProps }) {
|
|
|
342
346
|
### Server-Side Props
|
|
343
347
|
|
|
344
348
|
```tsx
|
|
345
|
-
import { getSkeletonProps } from "castdom/next";
|
|
349
|
+
import { getSkeletonProps } from "@lukas_holdings/castdom/next";
|
|
346
350
|
|
|
347
351
|
export async function getServerSideProps() {
|
|
348
352
|
const { skeletonHTML, skeletonCSS } = getSkeletonProps(["user-card"]);
|
|
@@ -367,7 +371,7 @@ cp .castdom/nextjs-loading.tsx app/dashboard/loading.tsx
|
|
|
367
371
|
```js
|
|
368
372
|
// astro.config.mjs
|
|
369
373
|
import { defineConfig } from "astro/config";
|
|
370
|
-
import { castdomIntegration } from "castdom/astro";
|
|
374
|
+
import { castdomIntegration } from "@lukas_holdings/castdom/astro";
|
|
371
375
|
|
|
372
376
|
export default defineConfig({
|
|
373
377
|
integrations: [castdomIntegration()],
|
|
@@ -378,7 +382,7 @@ export default defineConfig({
|
|
|
378
382
|
|
|
379
383
|
```astro
|
|
380
384
|
---
|
|
381
|
-
import { skeleton } from "castdom/astro";
|
|
385
|
+
import { skeleton } from "@lukas_holdings/castdom/astro";
|
|
382
386
|
const { html, css } = skeleton("user-card");
|
|
383
387
|
---
|
|
384
388
|
|
|
@@ -393,7 +397,7 @@ const { html, css } = skeleton("user-card");
|
|
|
393
397
|
|
|
394
398
|
```astro
|
|
395
399
|
---
|
|
396
|
-
import { skeleton, viewTransitionProps } from "castdom/astro";
|
|
400
|
+
import { skeleton, viewTransitionProps } from "@lukas_holdings/castdom/astro";
|
|
397
401
|
const { html } = skeleton("sidebar");
|
|
398
402
|
const transitionProps = viewTransitionProps("sidebar");
|
|
399
403
|
---
|
|
@@ -410,7 +414,7 @@ const transitionProps = viewTransitionProps("sidebar");
|
|
|
410
414
|
```ts
|
|
411
415
|
// vite.config.ts
|
|
412
416
|
import { defineConfig } from "vite";
|
|
413
|
-
import { castdom } from "castdom/vite";
|
|
417
|
+
import { castdom } from "@lukas_holdings/castdom/vite";
|
|
414
418
|
|
|
415
419
|
export default defineConfig({
|
|
416
420
|
plugins: [castdom()],
|
|
@@ -435,7 +439,7 @@ The plugin provides:
|
|
|
435
439
|
For non-framework usage:
|
|
436
440
|
|
|
437
441
|
```js
|
|
438
|
-
import { createCastDOM } from "castdom";
|
|
442
|
+
import { createCastDOM } from "@lukas_holdings/castdom";
|
|
439
443
|
import manifest from ".castdom/manifest.json";
|
|
440
444
|
|
|
441
445
|
const castdom = createCastDOM();
|
|
@@ -468,7 +472,7 @@ CastDOM is SSR-first. Skeletons render as server-side HTML with zero JavaScript.
|
|
|
468
472
|
### Server-Side Rendering
|
|
469
473
|
|
|
470
474
|
```ts
|
|
471
|
-
import { renderSkeleton, renderSSRFragment } from "castdom/ssr";
|
|
475
|
+
import { renderSkeleton, renderSSRFragment } from "@lukas_holdings/castdom/ssr";
|
|
472
476
|
|
|
473
477
|
// Single skeleton
|
|
474
478
|
const html = renderSkeleton(skeletonData);
|
|
@@ -485,7 +489,7 @@ const { head, body } = renderSSRFragment([skeleton1, skeleton2]);
|
|
|
485
489
|
SSR skeletons include `data-castdom-ssr` attributes. A tiny (~200 byte) inline hydration script automatically removes them once real content renders:
|
|
486
490
|
|
|
487
491
|
```ts
|
|
488
|
-
import { renderHydrationScript } from "castdom/ssr";
|
|
492
|
+
import { renderHydrationScript } from "@lukas_holdings/castdom/ssr";
|
|
489
493
|
|
|
490
494
|
const script = renderHydrationScript();
|
|
491
495
|
// <script data-castdom="hydration">(...)</script>
|
|
@@ -494,7 +498,7 @@ const script = renderHydrationScript();
|
|
|
494
498
|
### Critical CSS
|
|
495
499
|
|
|
496
500
|
```ts
|
|
497
|
-
import { renderCriticalStyleTag } from "castdom/ssr";
|
|
501
|
+
import { renderCriticalStyleTag } from "@lukas_holdings/castdom/ssr";
|
|
498
502
|
|
|
499
503
|
const styleTag = renderCriticalStyleTag([skeleton1, skeleton2]);
|
|
500
504
|
// <style data-castdom="critical">@keyframes castdom-shimmer{...}...</style>
|
|
@@ -630,7 +634,7 @@ import {
|
|
|
630
634
|
extractBones, // Extract bones from a DOM element (browser-side)
|
|
631
635
|
compressBones, // Compress bone data for storage
|
|
632
636
|
decompressBones, // Decompress bone data
|
|
633
|
-
} from "castdom";
|
|
637
|
+
} from "@lukas_holdings/castdom";
|
|
634
638
|
```
|
|
635
639
|
|
|
636
640
|
### React
|
|
@@ -640,7 +644,7 @@ import {
|
|
|
640
644
|
CastDOM, // Wrapper component
|
|
641
645
|
CastDOMStyle, // Critical CSS component for <head>
|
|
642
646
|
useCastDOM, // Hook for programmatic access
|
|
643
|
-
} from "castdom/react";
|
|
647
|
+
} from "@lukas_holdings/castdom/react";
|
|
644
648
|
```
|
|
645
649
|
|
|
646
650
|
### SSR
|
|
@@ -652,7 +656,7 @@ import {
|
|
|
652
656
|
renderCriticalStyleTag, // Generate <style> tag
|
|
653
657
|
renderHydrationScript, // Generate hydration <script>
|
|
654
658
|
renderSSRFragment, // Complete head + body fragments
|
|
655
|
-
} from "castdom/ssr";
|
|
659
|
+
} from "@lukas_holdings/castdom/ssr";
|
|
656
660
|
```
|
|
657
661
|
|
|
658
662
|
---
|
|
@@ -689,6 +693,12 @@ export type SkeletonName = "user-card" | "feed-item";
|
|
|
689
693
|
|
|
690
694
|
---
|
|
691
695
|
|
|
696
|
+
## AI-Friendly
|
|
697
|
+
|
|
698
|
+
CastDOM ships [`CASTDOM.md`](CASTDOM.md) — a comprehensive context file for AI coding assistants (Claude, Gemini, GPT, Cursor, Copilot, Windsurf, etc.). It contains every type, API, integration pattern, and CLI command so any AI can help you integrate CastDOM correctly.
|
|
699
|
+
|
|
700
|
+
---
|
|
701
|
+
|
|
692
702
|
## Browser Support
|
|
693
703
|
|
|
694
704
|
CastDOM's runtime is pure CSS — it works everywhere CSS animations work:
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lukas_holdings/castdom",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Pixel-perfect skeleton loading screens, extracted from your real DOM. Zero-config, SSR-first, CSS-only runtime.",
|
|
5
|
+
"homepage": "https://kameeleonn.github.io/CastDOM/",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/Kameeleonn/CastDOM.git"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/Kameeleonn/CastDOM/issues"
|
|
12
|
+
},
|
|
13
|
+
"author": "Lukas Holdings",
|
|
5
14
|
"type": "module",
|
|
6
15
|
"main": "./dist/index.cjs",
|
|
7
16
|
"module": "./dist/index.js",
|