@acowale/orion-boneyard 0.0.0-stage → 1.10.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.md ADDED
@@ -0,0 +1,144 @@
1
+ # Licence
2
+
3
+ **@acowale/orion-boneyard**
4
+
5
+ `@acowale/orion-boneyard` is Acowale Technologies Private Limited's build of [boneyard](https://github.com/0xGF/boneyard), the open-source skeleton-loading library created by 0xGF, published for Acowale's Orion design system. Boneyard's code belongs to its authors and stays under the MIT License. Acowale's changes belong to Acowale.
6
+
7
+ | Part | Owner | Terms |
8
+ | --- | --- | --- |
9
+ | Boneyard's code and documentation (the "Original Work") | 0xGF and the boneyard contributors | MIT License (section 3) |
10
+ | Acowale's changes and additions (the "Acowale Changes") | Acowale Technologies Private Limited | Acowale's licence to Permitted Users (section 2) |
11
+
12
+ By installing or using this package, you accept these terms for the Acowale Changes and the MIT License for the Original Work.
13
+
14
+ ## About this package
15
+
16
+ Boneyard draws skeleton loading screens that match a component's real layout. A command-line tool, or a Vite plugin, opens the app in a browser, measures each component wrapped in `<Skeleton>` and saves its shape. While the data loads, the same `<Skeleton>` draws that shape. Boneyard has one core and separate entry points for React, Preact, Vue, Svelte, Angular and React Native. Acowale's React apps use `@acowale/orion-boneyard/react`, and an app loads only the entry point it imports.
17
+
18
+ This package is boneyard 1.10.0 (upstream package `boneyard-js`), including upstream's later build fix. Acowale's changes are limited to these:
19
+
20
+ 1. **Name.** The package is published as `@acowale/orion-boneyard` instead of `boneyard-js`, and the command-line tool is `orion-boneyard` instead of `boneyard-js`.
21
+ 2. **Generated imports.** The registry files that the command-line tool and the Vite plugin write import from `@acowale/orion-boneyard`.
22
+ 3. **Documentation.** Examples, help text and the README use the new names, and the README carries a short version of this licence.
23
+ 4. **Release.** Acowale's pipeline builds, tests and publishes the package.
24
+
25
+ Apart from these names, boneyard works exactly as upstream wrote it.
26
+
27
+ The package's source is `packages/boneyard` in Acowale's copy of the boneyard repository. The rest of that repository, such as boneyard's documentation site, is upstream's work under the MIT License and is not part of this package.
28
+
29
+ ## 1. Definitions
30
+
31
+ - **Acowale** means Acowale Technologies Private Limited.
32
+ - **Boneyard Authors** means 0xGF and the other contributors to boneyard, <https://github.com/0xGF/boneyard>.
33
+ - **Original Work** means boneyard's code and documentation as its authors publish them under the MIT License.
34
+ - **Acowale Changes** means the changes and additions listed in "About this package", and Acowale's later changes to this package.
35
+ - **Permitted Users** has the meaning given in section 2.2.
36
+
37
+ ## 2. The Acowale Changes
38
+
39
+ ### 2.1 Ownership
40
+
41
+ Copyright © 2026 Acowale Technologies Private Limited. All rights reserved.
42
+
43
+ The Acowale Changes are the work and the property of Acowale.
44
+
45
+ ### 2.2 Permitted Users
46
+
47
+ Acowale maintains this package for the following, each a "Permitted User":
48
+
49
+ - Acowale;
50
+ - Acowale's group companies, subsidiaries, affiliates and sister concerns;
51
+ - Acowale's associates and partners; and
52
+ - Acowale's clients.
53
+
54
+ A Permitted User's employees and contractors may use the package on that Permitted User's behalf, for its projects and products.
55
+
56
+ ### 2.3 Licence grant
57
+
58
+ Acowale grants each Permitted User a worldwide, non-exclusive, non-transferable, royalty-free licence to:
59
+
60
+ 1. install and use the Acowale Changes in its commercial and non-commercial projects and products; and
61
+ 2. include them, in source, compiled, bundled or minified form, in the products it builds and distributes to its own customers and users.
62
+
63
+ The end users of those products may use the Acowale Changes as part of them.
64
+
65
+ ### 2.4 Restrictions
66
+
67
+ A Permitted User must not:
68
+
69
+ 1. sell, license, sublicense or distribute this package on its own, or as a standalone package or library;
70
+ 2. publish a copy or a modified version of this package to any public package registry;
71
+ 3. remove or change the copyright notices in the package, including the MIT License in section 3; or
72
+ 4. use the Acowale name or logo to suggest that Acowale endorses its product, without Acowale's written permission.
73
+
74
+ ### 2.5 Everyone else
75
+
76
+ No licence to the Acowale Changes is granted to anyone who is not a Permitted User. That the package can be installed from a public registry does not make anyone a Permitted User. Any other use of the Acowale Changes needs Acowale's written permission: contact [support@acowale.com](mailto:support@acowale.com).
77
+
78
+ This section does not limit the Original Work. Anyone may use boneyard under the MIT License, for example from its authors' own package, `boneyard-js`.
79
+
80
+ ### 2.6 End of the licence
81
+
82
+ The licence in section 2.3 ends for a Permitted User when it stops being a Permitted User, or if it breaches these terms and does not put the breach right after Acowale gives notice. Products distributed before the licence ended may still be used by their end users.
83
+
84
+ ## 3. The Original Work
85
+
86
+ ### 3.1 Ownership
87
+
88
+ Boneyard was created by 0xGF, and its copyright belongs to the Boneyard Authors. Acowale does not claim ownership of boneyard or to have created it.
89
+
90
+ ### 3.2 The MIT License applies
91
+
92
+ The Original Work is licensed under the MIT License below, as its authors published it. Nothing in this file limits the rights that licence gives to anyone. If this file and the MIT License disagree about the Original Work, the MIT License applies.
93
+
94
+ ```text
95
+ MIT License
96
+
97
+ Copyright (c) 2025 0xGF
98
+
99
+ Permission is hereby granted, free of charge, to any person obtaining a copy
100
+ of this software and associated documentation files (the "Software"), to deal
101
+ in the Software without restriction, including without limitation the rights
102
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
103
+ copies of the Software, and to permit persons to whom the Software is
104
+ furnished to do so, subject to the following conditions:
105
+
106
+ The above copyright notice and this permission notice shall be included in all
107
+ copies or substantial portions of the Software.
108
+
109
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
110
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
111
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
112
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
113
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
114
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
115
+ SOFTWARE.
116
+ ```
117
+
118
+ ### 3.3 Credit to boneyard
119
+
120
+ Where a project or product credits the third-party work it uses, it should credit boneyard as:
121
+
122
+ > Skeleton screens by boneyard (https://github.com/0xGF/boneyard), © 2025 0xGF, MIT License.
123
+
124
+ ## 4. Third-party work
125
+
126
+ The packages this package installs, such as Playwright for the command-line tool, come under their own licences.
127
+
128
+ ## 5. Disclaimer of warranty and limitation of liability
129
+
130
+ The package, including the Original Work and the Acowale Changes, is provided "AS IS", without warranties of any kind, express or implied, including warranties of merchantability, fitness for a particular purpose and non-infringement.
131
+
132
+ To the extent permitted by law, Acowale shall not be held liable for any direct, indirect, incidental, special or consequential damages arising from the use, modification or distribution of the package.
133
+
134
+ ## 6. Trademarks
135
+
136
+ Boneyard is the name of its authors' project. Acowale is not affiliated with 0xGF or the boneyard project, and they do not sponsor or endorse this package. Acowale is a name and mark of Acowale Technologies Private Limited.
137
+
138
+ ## 7. Changes to these terms
139
+
140
+ Acowale may change these terms for later versions of the package. Each version of the package is governed by the terms included with it.
141
+
142
+ ## 8. Contact
143
+
144
+ For permissions, licence queries or concerns about this package, contact [support@acowale.com](mailto:support@acowale.com).
package/README.md CHANGED
@@ -1,3 +1,260 @@
1
- # Temporary Holding Version
1
+ # boneyard
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Pixel-perfect skeleton loading screens, extracted from your real DOM.
4
+
5
+ Wrap your component in `<Skeleton>`, run the CLI, and get positioned bone rectangles that match your actual layout. No manual sizing, no guesswork.
6
+
7
+ `@acowale/orion-boneyard` is Acowale Technologies Private Limited's build of [boneyard](https://github.com/0xGF/boneyard) by 0xGF, for the Orion design system. Boneyard's code belongs to its authors and is MIT licensed; only the names change. Who may use this build is set out in [Licence and attribution](#licence-and-attribution).
8
+
9
+ ## Quick start
10
+
11
+ ```bash
12
+ npm install @acowale/orion-boneyard
13
+ ```
14
+
15
+ ```tsx
16
+ import { Skeleton } from '@acowale/orion-boneyard/react'
17
+
18
+ function BlogPage() {
19
+ const { data, isLoading } = useFetch('/api/post')
20
+
21
+ return (
22
+ <Skeleton name="blog-card" loading={isLoading}>
23
+ <BlogCard data={data} />
24
+ </Skeleton>
25
+ )
26
+ }
27
+ ```
28
+
29
+ ```bash
30
+ npx orion-boneyard build http://localhost:3000
31
+ ```
32
+
33
+ ```ts
34
+ // app/layout.tsx — import once, all skeletons auto-resolve
35
+ import './bones/registry'
36
+ ```
37
+
38
+ ## Frameworks
39
+
40
+ ```tsx
41
+ // React
42
+ import { Skeleton } from '@acowale/orion-boneyard/react'
43
+
44
+ // Preact
45
+ import { Skeleton } from '@acowale/orion-boneyard/preact'
46
+
47
+ // React Native
48
+ import { Skeleton } from '@acowale/orion-boneyard/native'
49
+ ```
50
+
51
+ ```svelte
52
+ <!-- Svelte -->
53
+ <script lang="ts">
54
+ import Skeleton from '@acowale/orion-boneyard/svelte'
55
+ </script>
56
+
57
+ <Skeleton name="profile-card" loading={isLoading}>
58
+ <ProfileCard />
59
+ </Skeleton>
60
+ ```
61
+
62
+ ```vue
63
+ <!-- Vue -->
64
+ <script setup>
65
+ import Skeleton from '@acowale/orion-boneyard/vue'
66
+ </script>
67
+
68
+ <Skeleton name="profile-card" :loading="isLoading">
69
+ <ProfileCard />
70
+ </Skeleton>
71
+ ```
72
+
73
+ ```ts
74
+ // Angular
75
+ import { SkeletonComponent } from '@acowale/orion-boneyard/angular'
76
+ ```
77
+
78
+ ## Config
79
+
80
+ Create `boneyard.config.json` in your project root. Controls both the CLI and runtime defaults.
81
+
82
+ ```json
83
+ {
84
+ "breakpoints": [375, 768, 1280],
85
+ "out": "./src/bones",
86
+
87
+ "color": "#e5e5e5",
88
+ "darkColor": "#2a2a2a",
89
+ "animate": "shimmer",
90
+ "shimmerColor": "#ebebeb",
91
+ "darkShimmerColor": "#333333",
92
+ "speed": "2s",
93
+ "shimmerAngle": 110
94
+ }
95
+ ```
96
+
97
+ All color values accept any valid CSS color (hex, rgba, hsl, etc.).
98
+
99
+ | Key | Default | Description |
100
+ |-----|---------|-------------|
101
+ | `breakpoints` | auto | Viewport widths for capture (auto-detects Tailwind) |
102
+ | `out` | `./src/bones` | Output directory for `.bones.json` and `registry.js` |
103
+ | `wait` | `800` | ms to wait after page load before capturing |
104
+ | `color` | `#f0f0f0` | Bone fill color (light mode) |
105
+ | `darkColor` | `#222222` | Bone fill color (dark mode) |
106
+ | `animate` | `pulse` | `pulse`, `shimmer`, or `solid` |
107
+ | `shimmerColor` | `#f7f7f7` | Shimmer highlight (light mode) |
108
+ | `darkShimmerColor` | `#2c2c2c` | Shimmer highlight (dark mode) |
109
+ | `speed` | `2s` / `1.8s` | Animation duration (shimmer / pulse) |
110
+ | `shimmerAngle` | `110` | Shimmer gradient angle in degrees |
111
+ | `stagger` | `false` | Delay between bones in ms (`true` = 80ms) |
112
+ | `transition` | `false` | Fade out when loading ends in ms (`true` = 300ms) |
113
+ | `select` | `container` | Width used to pick the responsive breakpoint: `container` (measured width) or `viewport` (`window.innerWidth`). Use `viewport` for app-shell layouts where the container is narrower than the window |
114
+ | `url` | dev server | Capture origin for the Vite plugin, e.g. `https://myapp.dev` — use when the dev server sits behind a reverse proxy (portless, custom HTTPS origins) so auth cookies scoped to the real origin apply. Defaults to the server's own `localhost:<port>`. Also available as a `boneyardPlugin({ url })` option |
115
+
116
+ Per-component props override config. Config overrides package defaults.
117
+
118
+ ## Fixtures
119
+
120
+ When your component needs API data or auth to render, provide a fixture for the CLI to snapshot instead:
121
+
122
+ ```tsx
123
+ <Skeleton
124
+ name="dashboard"
125
+ loading={isLoading}
126
+ fixture={<DashboardFixture />}
127
+ snapshotConfig={{ leafTags: ["section"] }}
128
+ >
129
+ <Dashboard data={data} />
130
+ </Skeleton>
131
+ ```
132
+
133
+ Use `leafTags` to treat elements as atomic bones — prevents the extractor from recursing into children and creating unwanted internal shapes. A leaf tag is atomic only while everything it holds is inline: `<p>Hello <strong>world</strong></p>` is one bone, but an `li` (or any listed tag) wrapping block-level content — a card inside a list item, say — is walked into like a container, so lists of cards keep their inner structure.
134
+
135
+ ## Dark mode
136
+
137
+ Detected via the `.dark` class on `<html>` or any ancestor (standard Tailwind convention). Does **not** use `prefers-color-scheme` — gives you explicit control.
138
+
139
+ When `.dark` is present, `darkColor` and `darkShimmerColor` are used automatically.
140
+
141
+ ## CLI
142
+
143
+ The `build` command (and the Vite plugin) drive a headless Chromium via [Playwright](https://playwright.dev) to snapshot your rendered UI. Playwright ships as a dependency of `@acowale/orion-boneyard`, so it's already in `node_modules` — but its **browser binary** is downloaded separately. Install it **once** before your first build:
144
+
145
+ ```bash
146
+ npx playwright install chromium
147
+ ```
148
+
149
+ > Skipping this step is the most common first-run error. If Playwright reports a missing browser, run the command above. (Note: `playwright install` only works because Playwright is a dependency here — if you hit `Command "playwright" not found` in a strict pnpm/monorepo setup, use `npx playwright install chromium`.)
150
+
151
+ Prefer not to download a browser — e.g. in CI, or to reuse your logged-in session? See [Reusing an existing browser](#reusing-an-existing-browser).
152
+
153
+ ```bash
154
+ npx orion-boneyard build # auto-detect dev server
155
+ npx orion-boneyard build http://localhost:3000 # explicit URL
156
+ npx orion-boneyard build --out src/bones # custom output
157
+ npx orion-boneyard build --force # regenerate all
158
+ npx orion-boneyard build --breakpoints 375,768,1280 # custom breakpoints
159
+ npx orion-boneyard build --cookie "session=abc123" # auth cookies
160
+ npx orion-boneyard build --native --out ./bones # React Native
161
+ ```
162
+
163
+ ### Reusing an existing browser
164
+
165
+ Instead of launching (and downloading) Playwright's Chromium, boneyard can attach to a Chrome you're already running over the DevTools Protocol. This reuses your cookies and auth state, and skips the browser download — useful in CI or behind a login.
166
+
167
+ Chrome exposes two remote-debugging modes, and boneyard supports both:
168
+
169
+ **Mode 1 — debug port (separate profile).** Launch Chrome with a debugging port. Since Chrome 136, `--remote-debugging-port` is ignored on the default profile, so a non-default `--user-data-dir` is required:
170
+
171
+ ```bash
172
+ # 1. Fully quit Chrome, then start an isolated debugging profile:
173
+ google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug
174
+ # macOS:
175
+ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
176
+ --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug
177
+
178
+ # 2. CLI
179
+ npx orion-boneyard build --cdp 9222
180
+
181
+ # 2. …or the Vite plugin
182
+ # boneyardPlugin({ cdp: 9222 })
183
+ ```
184
+
185
+ **Mode 2 — attach to your normal running Chrome (Chrome 144+).** Enable `chrome://inspect/#remote-debugging` → *"Allow remote debugging for this browser instance"*. This mode doesn't expose the HTTP discovery endpoint (`/json/version` returns 404) — instead Chrome writes a WebSocket endpoint to `DevToolsActivePort` in your user data directory. Pass that full `ws://` endpoint to boneyard; Chrome will ask you to approve the incoming connection:
186
+
187
+ ```bash
188
+ # macOS default profile — the file holds a port and a path, join them:
189
+ cat ~/Library/Application\ Support/Google/Chrome/DevToolsActivePort
190
+ # → 9222
191
+ # → /devtools/browser/<uuid>
192
+
193
+ npx orion-boneyard build --cdp ws://127.0.0.1:9222/devtools/browser/<uuid>
194
+ # or: boneyardPlugin({ cdp: 'ws://127.0.0.1:9222/devtools/browser/<uuid>' })
195
+ ```
196
+
197
+ > A `404 when connecting to http://localhost:9222/json/version` means the port isn't exposing the DevTools HTTP endpoint — you're either on Chrome 136+ without `--user-data-dir` (Mode 1), or using the chrome://inspect toggle, which only exposes the WebSocket endpoint (use Mode 2's `ws://` form).
198
+
199
+ ## Layout APIs
200
+
201
+ For advanced use cases — SSR, responsive tooling, or rendering skeletons without the component.
202
+
203
+ ### `computeLayout(descriptor, width)`
204
+
205
+ ```ts
206
+ import { computeLayout } from '@acowale/orion-boneyard'
207
+
208
+ const result = computeLayout(descriptor, 375)
209
+ ```
210
+
211
+ The first call compiles the descriptor tree and measures text nodes. Later calls with the same descriptor reuse the compiled tree.
212
+
213
+ ### `compileDescriptor(descriptor)` + `computeLayout(compiled, width)`
214
+
215
+ Explicit control over compilation:
216
+
217
+ ```ts
218
+ import { compileDescriptor, computeLayout } from '@acowale/orion-boneyard'
219
+
220
+ const compiled = compileDescriptor(descriptor)
221
+
222
+ const mobile = computeLayout(compiled, 375)
223
+ const tablet = computeLayout(compiled, 768)
224
+ const desktop = computeLayout(compiled, 1280)
225
+ ```
226
+
227
+ Use `compileDescriptor` when you render the same skeleton at multiple breakpoints, keep a registry in memory, or want to benchmark cold vs hot performance.
228
+
229
+ If you mutate a descriptor in place, the engine detects the change and rebuilds automatically. To force an immediate rebuild, call `invalidateDescriptor(descriptor)`.
230
+
231
+ ## Docs
232
+
233
+ [boneyard.vercel.app](https://boneyard.vercel.app)
234
+
235
+ ## Licence and attribution
236
+
237
+ | Part | Owner | Terms |
238
+ | --- | --- | --- |
239
+ | Boneyard's code and documentation | 0xGF and the boneyard contributors | [MIT License](https://github.com/0xGF/boneyard/blob/main/LICENSE) |
240
+ | Acowale's changes: the package and command names, generated imports, documentation and release | Acowale Technologies Private Limited | All rights reserved. Licensed to the Permitted Users below |
241
+
242
+ **Boneyard belongs to its authors.** Boneyard was created by 0xGF and is open source under the MIT License. This package is Acowale's build of it: the code is boneyard's, unchanged apart from its names. Acowale does not claim ownership of boneyard. Anyone may use boneyard itself under the MIT License, from its authors' package [`boneyard-js`](https://www.npmjs.com/package/boneyard-js).
243
+
244
+ **Permitted Users.** Acowale, its group companies, subsidiaries, affiliates, associates, sister concerns, partners and clients may use this package in their commercial and non-commercial projects and products, and include it in the products they build and distribute. Anyone else needs Acowale's permission to use this build, even though the package can be installed from npm.
245
+
246
+ When you work with this package:
247
+
248
+ - Keep the copyright notices, including boneyard's MIT License.
249
+ - Do not sell or share this package on its own, and publish it only from its pipeline.
250
+ - Do not describe boneyard as Acowale's own work.
251
+
252
+ **Credit to boneyard.** Where a project or product credits the open-source work it uses, credit boneyard as:
253
+
254
+ > Skeleton screens by boneyard (https://github.com/0xGF/boneyard), © 2025 0xGF, MIT License.
255
+
256
+ The full terms are in [LICENSE.md](./LICENSE.md), included in the package.
257
+
258
+ ## Support
259
+
260
+ Questions, problems and licence queries: [support@acowale.com](mailto:support@acowale.com).
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Cross-run bone preservation.
3
+ *
4
+ * A capture pass only visits the routes reachable during that run. When a
5
+ * user adds `auth.cookies` and re-runs, previously captured bones for
6
+ * unauthenticated pages (e.g. /login) are no longer reachable, so those
7
+ * skeletons never enter `collected`. Historically the registry was
8
+ * regenerated from `collected` alone, silently dropping any skeleton whose
9
+ * page wasn't visited this run (#81).
10
+ *
11
+ * This helper merges a run's freshly-captured bones with whatever was
12
+ * already on disk: if a skeleton name only exists in the loaded set, keep
13
+ * it. If it exists in both, the fresh data wins.
14
+ *
15
+ * Kept separate from the CLI so it can be unit-tested from `src/`.
16
+ */
17
+
18
+ /**
19
+ * Merge previously-captured bones into the current run's collected map.
20
+ *
21
+ * Mutates `collected` in place (matches how the CLI already uses a
22
+ * long-lived `collected` object across breakpoints/routes) and also
23
+ * returns it for convenience. Fresh captures always win over loaded data.
24
+ *
25
+ * @param {Record<string, any>} collected - captured this run
26
+ * @param {Record<string, any>} existing - loaded from disk at startup
27
+ * @returns {Record<string, any>} the merged `collected`
28
+ */
29
+ export function mergePreservingExisting(collected, existing) {
30
+ if (!collected || typeof collected !== 'object') return collected
31
+ if (!existing || typeof existing !== 'object') return collected
32
+ for (const [name, data] of Object.entries(existing)) {
33
+ if (!(name in collected)) {
34
+ collected[name] = data
35
+ }
36
+ }
37
+ return collected
38
+ }