@pixeyedev/storybook 0.4.6 → 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/dist/bundle.js +1 -5
- package/dist/upload.d.ts +0 -8
- package/dist/upload.js +0 -11
- package/dist/validate.js +0 -7
- package/package.json +3 -3
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();
|
|
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,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixeyedev/storybook",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"ai-check": "exit 0"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@pixeyedev/core": "^0.4.
|
|
28
|
-
"@pixeyedev/shared": "^0.4.
|
|
27
|
+
"@pixeyedev/core": "^0.4.7",
|
|
28
|
+
"@pixeyedev/shared": "^0.4.7",
|
|
29
29
|
"glob": "^11.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|