@atproto-labs/rollup-plugin-bundle-manifest 0.0.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @atproto-labs/rollup-plugin-bundle-manifest
2
+
3
+ ## 0.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e134c79a0`](https://github.com/bluesky-social/atproto/commit/e134c79a0ffb000b2cb36437815673fa6bda664b) Thanks [@devinivy](https://github.com/devinivy)! - Initial publish of experimental oauth packages to @atproto-labs
package/LICENSE.txt ADDED
@@ -0,0 +1,7 @@
1
+ Dual MIT/Apache-2.0 License
2
+
3
+ Copyright (c) 2022-2024 Bluesky PBC, and Contributors
4
+
5
+ Except as otherwise noted in individual files, this software is licensed under the MIT license (<http://opensource.org/licenses/MIT>), or the Apache License, Version 2.0 (<http://www.apache.org/licenses/LICENSE-2.0>).
6
+
7
+ Downstream projects and end users may chose either license individually, or both together, at their discretion. The motivation for this dual-licensing is the additional software patent assurance provided by Apache 2.0.
@@ -0,0 +1,26 @@
1
+ import { Plugin } from 'rollup';
2
+ type AssetItem = {
3
+ type: 'asset';
4
+ mime?: string;
5
+ sha256: string;
6
+ data?: string;
7
+ };
8
+ type ChunkItem = {
9
+ type: 'chunk';
10
+ mime: string;
11
+ sha256: string;
12
+ dynamicImports: string[];
13
+ isDynamicEntry: boolean;
14
+ isEntry: boolean;
15
+ isImplicitEntry: boolean;
16
+ name: string;
17
+ data?: string;
18
+ };
19
+ export type ManifestItem = AssetItem | ChunkItem;
20
+ export type Manifest = Record<string, ManifestItem>;
21
+ export default function bundleManifest({ name, data, }?: {
22
+ name?: string;
23
+ data?: boolean;
24
+ }): Plugin;
25
+ export {};
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,cAAc,EAAE,OAAO,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,eAAe,EAAE,OAAO,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,CAAA;AAEhD,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;AAEnD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,IAA6B,EAC7B,IAAY,GACb,GAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;CACV,GAAG,MAAM,CAwCd"}
package/dist/index.js ADDED
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_crypto_1 = require("node:crypto");
7
+ const node_path_1 = require("node:path");
8
+ const mime_1 = __importDefault(require("mime"));
9
+ function bundleManifest({ name = 'bundle-manifest.json', data = false, } = {}) {
10
+ return {
11
+ name: 'bundle-manifest',
12
+ generateBundle(outputOptions, bundle) {
13
+ const manifest = {};
14
+ for (const [fileName, chunk] of Object.entries(bundle)) {
15
+ if (chunk.type === 'asset') {
16
+ manifest[fileName] = {
17
+ type: chunk.type,
18
+ data: data
19
+ ? Buffer.from(chunk.source).toString('base64')
20
+ : undefined,
21
+ mime: mime_1.default.getType((0, node_path_1.extname)(fileName)) || undefined,
22
+ sha256: (0, node_crypto_1.createHash)('sha256').update(chunk.source).digest('base64'),
23
+ };
24
+ }
25
+ if (chunk.type === 'chunk') {
26
+ manifest[fileName] = {
27
+ type: chunk.type,
28
+ data: data ? Buffer.from(chunk.code).toString('base64') : undefined,
29
+ mime: 'application/javascript',
30
+ sha256: (0, node_crypto_1.createHash)('sha256').update(chunk.code).digest('base64'),
31
+ dynamicImports: chunk.dynamicImports,
32
+ isDynamicEntry: chunk.isDynamicEntry,
33
+ isEntry: chunk.isEntry,
34
+ isImplicitEntry: chunk.isImplicitEntry,
35
+ name: chunk.name,
36
+ };
37
+ }
38
+ }
39
+ this.emitFile({
40
+ type: 'asset',
41
+ fileName: name,
42
+ source: JSON.stringify(manifest, null, 2),
43
+ });
44
+ },
45
+ };
46
+ }
47
+ exports.default = bundleManifest;
48
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,6CAAwC;AACxC,yCAAmC;AAEnC,gDAAuB;AA0BvB,SAAwB,cAAc,CAAC,EACrC,IAAI,GAAG,sBAAsB,EAC7B,IAAI,GAAG,KAAK,MAIV,EAAE;IACJ,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,cAAc,CAAC,aAAa,EAAE,MAAM;YAClC,MAAM,QAAQ,GAAa,EAAE,CAAA;YAE7B,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBACvD,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;oBAC3B,QAAQ,CAAC,QAAQ,CAAC,GAAG;wBACnB,IAAI,EAAE,KAAK,CAAC,IAAI;wBACh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AAC;KACF,CAAA;AACH,CAAC;AA9CD,iCA8CC"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@atproto-labs/rollup-plugin-bundle-manifest",
3
+ "version": "0.0.1",
4
+ "license": "MIT",
5
+ "description": "Library for generating a manifest of bundled files from a Rollup build",
6
+ "keywords": [
7
+ "atproto",
8
+ "rollup",
9
+ "manifest"
10
+ ],
11
+ "homepage": "https://atproto.com",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/bluesky-social/atproto",
15
+ "directory": "packages/rollup-plugin-bundle-manifest"
16
+ },
17
+ "type": "commonjs",
18
+ "main": "dist/index.js",
19
+ "types": "dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.js"
24
+ }
25
+ },
26
+ "dependencies": {
27
+ "mime": "^3.0.0"
28
+ },
29
+ "peerDependencies": {
30
+ "rollup": "^4.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "rollup": "^4.10.0",
34
+ "typescript": "^5.3.3"
35
+ },
36
+ "scripts": {
37
+ "build": "tsc --build tsconfig.json"
38
+ }
39
+ }
package/src/index.ts ADDED
@@ -0,0 +1,76 @@
1
+ import { createHash } from 'node:crypto'
2
+ import { extname } from 'node:path'
3
+
4
+ import mime from 'mime'
5
+ import { Plugin } from 'rollup'
6
+
7
+ type AssetItem = {
8
+ type: 'asset'
9
+ mime?: string
10
+ sha256: string
11
+ data?: string
12
+ }
13
+
14
+ type ChunkItem = {
15
+ type: 'chunk'
16
+ mime: string
17
+ sha256: string
18
+ dynamicImports: string[]
19
+ isDynamicEntry: boolean
20
+ isEntry: boolean
21
+ isImplicitEntry: boolean
22
+ name: string
23
+ data?: string
24
+ }
25
+
26
+ export type ManifestItem = AssetItem | ChunkItem
27
+
28
+ export type Manifest = Record<string, ManifestItem>
29
+
30
+ export default function bundleManifest({
31
+ name = 'bundle-manifest.json',
32
+ data = false,
33
+ }: {
34
+ name?: string
35
+ data?: boolean
36
+ } = {}): Plugin {
37
+ return {
38
+ name: 'bundle-manifest',
39
+ generateBundle(outputOptions, bundle) {
40
+ const manifest: Manifest = {}
41
+
42
+ for (const [fileName, chunk] of Object.entries(bundle)) {
43
+ if (chunk.type === 'asset') {
44
+ manifest[fileName] = {
45
+ type: chunk.type,
46
+ data: data
47
+ ? Buffer.from(chunk.source).toString('base64')
48
+ : undefined,
49
+ mime: mime.getType(extname(fileName)) || undefined,
50
+ sha256: createHash('sha256').update(chunk.source).digest('base64'),
51
+ }
52
+ }
53
+
54
+ if (chunk.type === 'chunk') {
55
+ manifest[fileName] = {
56
+ type: chunk.type,
57
+ data: data ? Buffer.from(chunk.code).toString('base64') : undefined,
58
+ mime: 'application/javascript',
59
+ sha256: createHash('sha256').update(chunk.code).digest('base64'),
60
+ dynamicImports: chunk.dynamicImports,
61
+ isDynamicEntry: chunk.isDynamicEntry,
62
+ isEntry: chunk.isEntry,
63
+ isImplicitEntry: chunk.isImplicitEntry,
64
+ name: chunk.name,
65
+ }
66
+ }
67
+ }
68
+
69
+ this.emitFile({
70
+ type: 'asset',
71
+ fileName: name,
72
+ source: JSON.stringify(manifest, null, 2),
73
+ })
74
+ },
75
+ }
76
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig/node.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "rootDir": "src"
6
+ },
7
+ "include": ["src"]
8
+ }