@notionhq/custom-blocks 0.1.12 → 0.1.13
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 +0 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/vite-plugin/index.d.ts +1 -10
- package/vite-plugin/index.js +4 -42
- package/docs/vite-plugin.md +0 -17
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
|
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
package/vite-plugin/index.d.ts
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
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
|
-
*
|
|
6
|
+
* @deprecated This compatibility stub does nothing. Remove it from Vite config when possible.
|
|
16
7
|
*/
|
|
17
8
|
export function notionCustomBlock(): NotionCustomBlockPlugin
|
package/vite-plugin/index.js
CHANGED
|
@@ -1,46 +1,8 @@
|
|
|
1
|
+
// Compatibility export for existing blocks.
|
|
2
|
+
// TODO(custom-blocks): Remove the Vite server entirely when bumping bridge protocol version.
|
|
1
3
|
/**
|
|
2
|
-
* Vite
|
|
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.
|
|
9
|
-
*
|
|
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.
|
|
4
|
+
* @deprecated This compatibility stub does nothing. Remove it from Vite config when possible.
|
|
24
5
|
*/
|
|
25
|
-
const REQUIRED_BASE = "./"
|
|
26
|
-
|
|
27
6
|
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
|
-
}
|
|
7
|
+
return { name: "custom-blocks:legacy-vite-plugin" }
|
|
46
8
|
}
|
package/docs/vite-plugin.md
DELETED
|
@@ -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.
|