@notionhq/custom-blocks 0.1.36 → 0.1.37
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.
|
@@ -15,8 +15,10 @@ const WORKER_ENTRY = "dist/index.js";
|
|
|
15
15
|
export async function buildCustomBlocks(args) {
|
|
16
16
|
const projectRoot = args.cwd ?? process.cwd();
|
|
17
17
|
const entryPath = path.resolve(projectRoot, WORKER_ENTRY);
|
|
18
|
-
const outDir = path.resolve(args.out);
|
|
19
|
-
const blocks =
|
|
18
|
+
const outDir = path.resolve(projectRoot, args.out);
|
|
19
|
+
const blocks = args.manifest === undefined
|
|
20
|
+
? await readCustomBlocks(entryPath)
|
|
21
|
+
: readAppBlocks(path.resolve(projectRoot, args.manifest));
|
|
20
22
|
if (blocks.length === 0) {
|
|
21
23
|
return { blocks: [] };
|
|
22
24
|
}
|
|
@@ -24,8 +26,13 @@ export async function buildCustomBlocks(args) {
|
|
|
24
26
|
for (const block of blocks) {
|
|
25
27
|
const bundleDir = path.join(outDir, block.key);
|
|
26
28
|
buildCustomBlock({ block, projectRoot, bundleDir });
|
|
27
|
-
const { checksumCrc32 } = packDirToTarGz(bundleDir);
|
|
28
|
-
built.push({
|
|
29
|
+
const { checksumCrc32, tarGz } = packDirToTarGz(bundleDir);
|
|
30
|
+
built.push({
|
|
31
|
+
key: block.key,
|
|
32
|
+
checksumCrc32,
|
|
33
|
+
bundleDir,
|
|
34
|
+
bundleSizeBytes: tarGz.length,
|
|
35
|
+
});
|
|
29
36
|
}
|
|
30
37
|
return { blocks: built };
|
|
31
38
|
}
|
|
@@ -185,3 +192,18 @@ function runCommand(key, command, cwd) {
|
|
|
185
192
|
throw new Error(`custom_block "${key}" build command "${command}" exited with code ${String(result.status)}`);
|
|
186
193
|
}
|
|
187
194
|
}
|
|
195
|
+
/** Read Apps SDK capabilities while retaining the worker manifest config contract. */
|
|
196
|
+
function readAppBlocks(manifestPath) {
|
|
197
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
198
|
+
const capabilities = readProp(manifest, "capabilities");
|
|
199
|
+
if (!Array.isArray(capabilities)) {
|
|
200
|
+
throw new Error(`manifest at ${manifestPath} has no capabilities array`);
|
|
201
|
+
}
|
|
202
|
+
return capabilities.flatMap(capability => {
|
|
203
|
+
const block = asCustomBlock({
|
|
204
|
+
...capability,
|
|
205
|
+
_tag: readProp(capability, "type") ?? readProp(capability, "_tag"),
|
|
206
|
+
});
|
|
207
|
+
return block ? [block] : [];
|
|
208
|
+
});
|
|
209
|
+
}
|
|
@@ -26,7 +26,8 @@ async function runBuild(args) {
|
|
|
26
26
|
process.stderr.write("usage: notion-custom-blocks build --out <dir>\n");
|
|
27
27
|
return 1;
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const { manifest, cwd } = flags;
|
|
30
|
+
const output = await buildCustomBlocks({ out, manifest, cwd });
|
|
30
31
|
printBuildOutput(output);
|
|
31
32
|
return 0;
|
|
32
33
|
}
|
package/dist/version.js
CHANGED
package/docs/deployment.md
CHANGED
|
@@ -19,3 +19,14 @@ At startup, the SDK fetches the page-relative `manifest` path only when the bund
|
|
|
19
19
|
- `ManifestDataSource` — a single entry in `dataSources`.
|
|
20
20
|
- `ManifestProperty` — a single property declaration inside a `ManifestDataSource`.
|
|
21
21
|
- `ManifestIcon` — the icon variant accepted on a `ManifestDataSource`.
|
|
22
|
+
|
|
23
|
+
## Apps SDK integration
|
|
24
|
+
|
|
25
|
+
`notion-custom-blocks build --manifest dist/manifest.json --out <dir>` reads
|
|
26
|
+
static Apps SDK capabilities. Paths in the manifest stay relative to the project
|
|
27
|
+
root (the current directory, or `--cwd`). Without `--manifest`, the command
|
|
28
|
+
continues to import the Workers SDK bundle at `dist/index.js`.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Relative `--out` paths also resolve from `--cwd`. Build results include
|
|
32
|
+
`bundleSizeBytes`, the exact compressed tarball length, for size-bound uploads.
|