@notionhq/custom-blocks 0.1.12 → 0.1.14

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/README.md CHANGED
@@ -104,7 +104,6 @@ API surface, one page per category. Import framework-neutral APIs from `@notionh
104
104
  - [`docs/users.md`](./docs/users.md) — `users.list / get`, the `NotionUser` shape, paging.
105
105
  - [`docs/errors.md`](./docs/errors.md) — request results, error format, error codes, retries, and initialization failures.
106
106
  - [`docs/deployment.md`](./docs/deployment.md) — worker-backed deploys, localhost self-hosted fallback, where the manifest comes from.
107
- - [`docs/vite-plugin.md`](./docs/vite-plugin.md) — the `notionCustomBlock()` Vite plugin.
108
107
 
109
108
  ## Forbidden APIs
110
109
 
@@ -36,7 +36,7 @@ export const initMessageSchema = v.variant("status", [
36
36
  initializationId: v.string(),
37
37
  status: v.literal("success"),
38
38
  theme: notionThemeSchema,
39
- // TODO(custom-blocks): Make this required when next bumping the protocol version.
39
+ // TODO(custom-blocks): Make this required when bumping bridge protocol version 4.
40
40
  contrastMode: v.optional(notionContrastModeSchema, DEFAULT_CONTRAST_MODE),
41
41
  blockId: notionBlockIdSchema,
42
42
  parent: notionParentSchema,
package/dist/version.js CHANGED
@@ -4,4 +4,4 @@
4
4
  *
5
5
  * WARNING: Generated during SDK publish. Do not edit in the published package.
6
6
  */
7
- export const CUSTOM_BLOCKS_SDK_VERSION = "0.1.12"
7
+ export const CUSTOM_BLOCKS_SDK_VERSION = "0.1.14"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,17 +1,12 @@
1
- /**
2
- * Type declarations for the Vite plugin. The runtime lives in `vite.js` —
3
- * see that file for behavior, options, and the reasoning for splitting `.js`
4
- * + `.d.ts` instead of using a single `.ts` source.
5
- */
6
-
7
- type UserConfig = { base?: string }
8
-
9
1
  export type NotionCustomBlockPlugin = {
10
2
  name: string
11
- config: (userConfig: UserConfig) => { base: string }
12
3
  }
13
4
 
14
5
  /**
15
- * Vite plugin that configures relative asset paths for custom block bundles.
6
+ * Vite plugin for Notion custom blocks.
7
+ *
8
+ * @deprecated This compatibility stub does nothing. Remove it from Vite config when possible.
9
+ *
10
+ * TODO(custom-blocks): Remove this when bumping bridge SDK version to 0.2.0.
16
11
  */
17
12
  export function notionCustomBlock(): NotionCustomBlockPlugin
@@ -1,46 +1,11 @@
1
1
  /**
2
- * Vite plugin half of `@notionhq/custom-blocks`.
2
+ * Vite plugin for Notion custom blocks.
3
3
  *
4
- * Authored as plain JS (with `index.d.ts` co-located for types) the rest of
5
- * the SDK is `.ts` consumed directly via the workspace symlink, but Vite's
6
- * config loader resolves this subpath through Node's ESM resolver, which
7
- * can't load `.ts` source files. Lives in its own `vite-plugin/` directory
8
- * so it can grow its own tsconfig later.
4
+ * @deprecated This is just a compatibility stub to ensure existing block code can continue to work
5
+ * with the new SDK.
9
6
  *
10
- * Usage:
11
- *
12
- * import { notionCustomBlock } from "@notionhq/custom-blocks/vite"
13
- *
14
- * export default defineConfig({
15
- * plugins: [react(), notionCustomBlock()],
16
- * })
17
- *
18
- * Requires `"type": "module"` in the consuming project's `package.json` so
19
- * Vite's config loader uses Node's ESM resolver (not CommonJS `require`,
20
- * which fails for ESM-only deps).
21
- *
22
- * The worker dev shell owns the localhost `/manifest` route. This plugin only
23
- * controls bundle asset paths.
7
+ * TODO(custom-blocks): Remove this when bumping bridge SDK version to 0.2.0.
24
8
  */
25
- const REQUIRED_BASE = "./"
26
-
27
9
  export function notionCustomBlock() {
28
- return {
29
- name: "custom-blocks:bundle-base",
30
- config(userConfig) {
31
- // Custom blocks are served from a content-addressed path that
32
- // has trailing slashes, eg https://dev.notion.so/custom-block-bundle/357b35e6-e67f-81fd-b425-00e7b3e2afd1/
33
- // so all asset URLs in the built bundle must be relative.
34
- // Force `base: "./"` and reject any other explicit value
35
- //
36
- // Note: once we are set up with a wildcard subdomain host, this will no longer be necessary
37
- // and should be removed, since /assets will work fine.
38
- if (userConfig.base !== undefined && userConfig.base !== REQUIRED_BASE) {
39
- throw new Error(
40
- `@notionhq/custom-blocks/vite: \`base\` must be "${REQUIRED_BASE}" (got ${JSON.stringify(userConfig.base)}). Custom blocks need relative asset paths so the bundle works under any host-served prefix.`,
41
- )
42
- }
43
- return { base: REQUIRED_BASE }
44
- },
45
- }
10
+ return { name: "custom-blocks:legacy-vite-plugin" }
46
11
  }
@@ -1,17 +0,0 @@
1
- # Vite plugin
2
-
3
- The `notionCustomBlock()` plugin from `@notionhq/custom-blocks/vite` configures a block's build output for Notion hosting.
4
-
5
- ```ts
6
- import { defineConfig } from "vite";
7
- import react from "@vitejs/plugin-react";
8
- import { notionCustomBlock } from "@notionhq/custom-blocks/vite";
9
-
10
- export default defineConfig({
11
- plugins: [react(), notionCustomBlock()],
12
- });
13
- ```
14
-
15
- It forces `base: "./"` and rejects any other explicit value. Custom blocks are served from a content-addressed path, so asset URLs in the built bundle must be relative.
16
-
17
- The plugin does not serve or emit manifests. Declare the manifest with `worker.customBlock(...)`; the worker dev shell exposes it dynamically at `/manifest` during local development. See [deployment.md](./deployment.md) for more information.