@pixeyedev/storybook 0.4.5 → 0.4.7

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pixeye (pixeye.dev)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/bundle.js CHANGED
@@ -6,16 +6,13 @@ import { createGzip } from 'node:zlib';
6
6
  import { glob } from 'glob';
7
7
  export const createBundle = async (dir) => {
8
8
  const files = await glob('**/*', { cwd: dir, nodir: true });
9
- files.sort(); // Deterministic ordering
10
- // Build a content map
9
+ files.sort();
11
10
  const contentMap = {};
12
11
  for (const file of files) {
13
12
  const content = await readFile(join(dir, file));
14
13
  contentMap[file] = content.toString('base64');
15
14
  }
16
- // Serialize deterministically (sorted keys)
17
15
  const json = JSON.stringify(contentMap, Object.keys(contentMap).sort());
18
- // Gzip compress
19
16
  const compressed = await new Promise((resolve, reject) => {
20
17
  const chunks = [];
21
18
  const gzip = createGzip({ level: 9 });
@@ -24,7 +21,6 @@ export const createBundle = async (dir) => {
24
21
  gzip.on('error', reject);
25
22
  Readable.from(json).pipe(gzip);
26
23
  });
27
- // Content hash for dedup
28
24
  const hash = createHash('sha256').update(compressed).digest('hex');
29
25
  return {
30
26
  hash,
package/dist/upload.d.ts CHANGED
@@ -14,12 +14,4 @@ export interface UploadBundleResult {
14
14
  pipelineId: string;
15
15
  skipped: boolean;
16
16
  }
17
- /**
18
- * Upload a Storybook bundle to Pixeye for server-side rendering.
19
- *
20
- * Flow:
21
- * 1. POST /api/v1/storybook/uploads — get presigned URL + upload record
22
- * 2. PUT bundle to presigned URL (skipped if bundle hash already exists)
23
- * 3. POST /api/v1/storybook/uploads/:id/finalize — create build + pipeline
24
- */
25
17
  export declare const uploadBundle: (opts: UploadBundleOptions) => Promise<UploadBundleResult>;
package/dist/upload.js CHANGED
@@ -1,16 +1,7 @@
1
1
  import { isRetryableHttpError, maskPresignedUrl, PixeyeError, withRetry } from '@pixeyedev/core';
2
2
  import { StorybookFinalizeResponseSchema, StorybookUploadResponseSchema } from '@pixeyedev/shared';
3
- /**
4
- * Upload a Storybook bundle to Pixeye for server-side rendering.
5
- *
6
- * Flow:
7
- * 1. POST /api/v1/storybook/uploads — get presigned URL + upload record
8
- * 2. PUT bundle to presigned URL (skipped if bundle hash already exists)
9
- * 3. POST /api/v1/storybook/uploads/:id/finalize — create build + pipeline
10
- */
11
3
  export const uploadBundle = async (opts) => {
12
4
  const baseUrl = opts.serverUrl.replace(/\/$/, '');
13
- // Step 1: Create upload record + get presigned URL
14
5
  const uploadRes = await fetch(`${baseUrl}/api/v1/storybook/uploads`, {
15
6
  method: 'POST',
16
7
  headers: {
@@ -34,7 +25,6 @@ export const uploadBundle = async (opts) => {
34
25
  }
35
26
  const uploadData = StorybookUploadResponseSchema.parse(await uploadRes.json());
36
27
  const skipped = uploadData.bundleExists;
37
- // Step 2: Upload bundle to presigned URL (skip if already exists)
38
28
  if (!skipped) {
39
29
  const maskedUrl = maskPresignedUrl(uploadData.presignedUrl);
40
30
  await withRetry(async () => {
@@ -55,7 +45,6 @@ export const uploadBundle = async (opts) => {
55
45
  }
56
46
  });
57
47
  }
58
- // Step 3: Finalize — creates build + pipeline, enqueues render job
59
48
  const finalizeRes = await fetch(`${baseUrl}/api/v1/storybook/uploads/${uploadData.uploadId}/finalize`, {
60
49
  method: 'POST',
61
50
  headers: {
package/dist/validate.js CHANGED
@@ -2,7 +2,6 @@ import { readFile, stat } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  import { glob } from 'glob';
4
4
  export const validateBundle = async (dir) => {
5
- // Check required files
6
5
  const indexHtml = join(dir, 'index.html');
7
6
  const iframeHtml = join(dir, 'iframe.html');
8
7
  try {
@@ -17,7 +16,6 @@ export const validateBundle = async (dir) => {
17
16
  catch {
18
17
  throw new Error('Not a valid Storybook build. Missing iframe.html.');
19
18
  }
20
- // Find story manifest (Storybook 7+)
21
19
  const indexJsonPath = join(dir, 'index.json');
22
20
  const storiesJsonPath = join(dir, 'stories.json');
23
21
  let manifestContent;
@@ -32,17 +30,12 @@ export const validateBundle = async (dir) => {
32
30
  throw new Error('Storybook 7+ required (index.json not found). Upgrade Storybook or use @pixeyedev/playwright for manual capture.');
33
31
  }
34
32
  }
35
- // Parse manifest to count stories and components
36
33
  const manifest = JSON.parse(manifestContent);
37
- // Storybook 7 index.json format: { v: 5, entries: { [storyId]: { type, title, name, ... } } }
38
- // Storybook 6 stories.json format: { v: 3, stories: { [storyId]: { ... } } }
39
34
  const entries = manifest.entries ?? manifest.stories ?? {};
40
35
  const storyEntries = Object.values(entries).filter((entry) => !entry.type || entry.type === 'story');
41
36
  const storyCount = storyEntries.length;
42
- // Components are unique titles (e.g., "Design System/Button")
43
37
  const componentTitles = new Set(storyEntries.map((entry) => entry.title).filter(Boolean));
44
38
  const componentCount = componentTitles.size;
45
- // Calculate total size
46
39
  const allFiles = await glob('**/*', { cwd: dir, nodir: true });
47
40
  let totalSizeBytes = 0;
48
41
  for (const file of allFiles) {
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@pixeyedev/storybook",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
+ "license": "MIT",
4
5
  "private": false,
5
6
  "type": "module",
6
7
  "files": [
@@ -16,14 +17,15 @@
16
17
  },
17
18
  "scripts": {
18
19
  "build": "tsc",
20
+ "prepack": "rm -rf dist && npm run build",
19
21
  "typecheck": "tsc --noEmit",
20
22
  "test": "vitest run",
21
23
  "lint": "echo 'ok'",
22
24
  "ai-check": "exit 0"
23
25
  },
24
26
  "dependencies": {
25
- "@pixeyedev/core": "^0.4.0",
26
- "@pixeyedev/shared": "^0.4.0",
27
+ "@pixeyedev/core": "^0.4.7",
28
+ "@pixeyedev/shared": "^0.4.7",
27
29
  "glob": "^11.0.0"
28
30
  },
29
31
  "devDependencies": {