@notionhq/custom-blocks-dev-shell 0.1.6 → 0.1.8
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/assets/index-D-HHV2_c.js +9 -0
- package/dist/index.html +1 -1
- package/dist-cli/block-server.js +2 -2
- package/dist-cli/data-sources.js +3 -1
- package/dist-cli/main.js +3 -3
- package/dist-cli/materialize.js +4 -4
- package/dist-cli/serve-ui.js +3 -3
- package/package.json +2 -2
- package/dist/assets/index-CDRf4GRS.js +0 -9
package/dist/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Workers local shell</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-D-HHV2_c.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-x1e1jng3.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/dist-cli/block-server.js
CHANGED
|
@@ -6,8 +6,8 @@ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
|
6
6
|
import { relative, resolve } from "node:path";
|
|
7
7
|
/** First port handed to per-block Vite servers; blocks count up from here. */
|
|
8
8
|
export const BLOCK_BASE_PORT = 9876;
|
|
9
|
-
/** Port the dev-shell
|
|
10
|
-
export const
|
|
9
|
+
/** Port the dev-shell UI is served on. */
|
|
10
|
+
export const SHELL_PORT = 9873;
|
|
11
11
|
/** The registry for a worker's blocks, assuming sequential port assignment. */
|
|
12
12
|
export function buildBlockRegistry(blocks, basePort = BLOCK_BASE_PORT) {
|
|
13
13
|
return blocks.map((capability, index) => ({
|
package/dist-cli/data-sources.js
CHANGED
|
@@ -91,10 +91,12 @@ function readSource(file) {
|
|
|
91
91
|
throw new Error(`${file}: ${path ? `${path}: ` : ""}${issue.message}`);
|
|
92
92
|
}
|
|
93
93
|
const { type, icon, schema, rows } = result.output;
|
|
94
|
-
const
|
|
94
|
+
const filename = basename(file, ".json");
|
|
95
|
+
const key = result.output.key ?? filename;
|
|
95
96
|
return {
|
|
96
97
|
type,
|
|
97
98
|
key,
|
|
99
|
+
filename,
|
|
98
100
|
name: result.output.name ?? key,
|
|
99
101
|
...(icon !== undefined ? { icon } : {}),
|
|
100
102
|
schema: Object.fromEntries(Object.entries(schema).map(([propertyKey, property]) => [
|
package/dist-cli/main.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Entry point for the published dev-shell CLI (`npx`-run from a worker
|
|
3
3
|
* project). Mirrors the worker mode of the repo's `scripts/dev.ts`: build the
|
|
4
4
|
* worker, extract its manifest, serve one Vite dev server per custom block
|
|
5
|
-
* (using the worker's own Vite install), and serve the prebuilt dev-shell
|
|
5
|
+
* (using the worker's own Vite install), and serve the prebuilt dev-shell UI
|
|
6
6
|
* with the block registry injected at runtime.
|
|
7
7
|
*/
|
|
8
8
|
import { spawn } from "node:child_process";
|
|
@@ -10,7 +10,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
10
10
|
import { createRequire } from "node:module";
|
|
11
11
|
import { basename, dirname, join, resolve } from "node:path";
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
|
-
import { BLOCK_BASE_PORT, buildBlockRegistry,
|
|
13
|
+
import { BLOCK_BASE_PORT, buildBlockRegistry, SHELL_PORT, writeBlockViteConfig, } from "./block-server.js";
|
|
14
14
|
import { readDataSources } from "./data-sources.js";
|
|
15
15
|
import { materializeWorkerSchemaDataSources } from "./materialize.js";
|
|
16
16
|
import { serveUi } from "./serve-ui.js";
|
|
@@ -24,7 +24,7 @@ const label = (name) => `${cyan}[${name}]${reset}`;
|
|
|
24
24
|
function parseCliArgs(argv) {
|
|
25
25
|
const args = {
|
|
26
26
|
worker: undefined,
|
|
27
|
-
shellPort:
|
|
27
|
+
shellPort: SHELL_PORT,
|
|
28
28
|
blockBasePort: BLOCK_BASE_PORT,
|
|
29
29
|
};
|
|
30
30
|
const takeValue = (name, index) => {
|
package/dist-cli/materialize.js
CHANGED
|
@@ -27,7 +27,7 @@ const TYPE_ALIASES = {
|
|
|
27
27
|
* be unambiguous — while the display name stays as declared, so the sidebar
|
|
28
28
|
* shows the clean name.
|
|
29
29
|
*/
|
|
30
|
-
const
|
|
30
|
+
const WORKER_PREFIX = "worker_";
|
|
31
31
|
export function materializeWorkerSchemaDataSources(manifest, dataDir) {
|
|
32
32
|
mkdirSync(dataDir, { recursive: true });
|
|
33
33
|
// One descriptor per data source key: databases first (source of truth for
|
|
@@ -51,7 +51,7 @@ export function materializeWorkerSchemaDataSources(manifest, dataDir) {
|
|
|
51
51
|
if (existing.blockKey !== undefined &&
|
|
52
52
|
!samePropertySchemas(existing.properties, properties)) {
|
|
53
53
|
console.warn(`Blocks "${existing.blockKey}" and "${block.key}" both declare data source ` +
|
|
54
|
-
`"${key}" with different schemas; ${
|
|
54
|
+
`"${key}" with different schemas; ${WORKER_PREFIX}${key}.json uses the ` +
|
|
55
55
|
`schema from "${existing.blockKey}". Author a src/data file for "${block.key}" by hand.`);
|
|
56
56
|
}
|
|
57
57
|
continue;
|
|
@@ -67,7 +67,7 @@ export function materializeWorkerSchemaDataSources(manifest, dataDir) {
|
|
|
67
67
|
// The key is the worker's contract and lands verbatim in the file's
|
|
68
68
|
// `key`; the filename is ours, so path-hostile characters (`/`, `..`)
|
|
69
69
|
// are encoded rather than allowed to leave `dataDir` or crash the write.
|
|
70
|
-
const file = resolve(dataDir, `${
|
|
70
|
+
const file = resolve(dataDir, `${WORKER_PREFIX}${fileSafe(key)}.json`);
|
|
71
71
|
if (existsSync(file)) {
|
|
72
72
|
continue;
|
|
73
73
|
}
|
|
@@ -96,7 +96,7 @@ function buildSource(key, descriptor) {
|
|
|
96
96
|
}
|
|
97
97
|
return {
|
|
98
98
|
type: "worker",
|
|
99
|
-
key: `${
|
|
99
|
+
key: `${WORKER_PREFIX}${key}`,
|
|
100
100
|
name,
|
|
101
101
|
schema,
|
|
102
102
|
rows: [],
|
package/dist-cli/serve-ui.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Dependency-free static server for the prebuilt dev-shell
|
|
2
|
+
* Dependency-free static server for the prebuilt dev-shell UI (`dist/`).
|
|
3
3
|
*
|
|
4
4
|
* The published UI is a plain Vite build, so the block registry can't ride in
|
|
5
5
|
* through build-time `import.meta.env` vars the way it does under
|
|
6
|
-
* `scripts/dev.ts`. Instead, this server injects a `window.
|
|
6
|
+
* `scripts/dev.ts`. Instead, this server injects a `window.__DEV_SHELL_CONFIG__`
|
|
7
7
|
* script into `index.html` as it is served; `src/helpers/blocks.ts` prefers
|
|
8
8
|
* that global over the baked-in env values.
|
|
9
9
|
*/
|
|
@@ -25,7 +25,7 @@ const CONTENT_TYPES = {
|
|
|
25
25
|
};
|
|
26
26
|
/** `index.html` with the runtime config injected ahead of the bundle script. */
|
|
27
27
|
function injectConfig(html, config) {
|
|
28
|
-
const tag = `<script>window.
|
|
28
|
+
const tag = `<script>window.__DEV_SHELL_CONFIG__ = ${JSON.stringify(config)}</script>`;
|
|
29
29
|
if (html.includes("<head>")) {
|
|
30
30
|
return html.replace("<head>", `<head>\n\t\t${tag}`);
|
|
31
31
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notionhq/custom-blocks-dev-shell",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Local preview shell for Notion custom block workers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/makenotion/custom-blocks",
|
|
9
|
-
"directory": "dev-shell
|
|
9
|
+
"directory": "dev-shell"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"bin": {
|