@notionhq/custom-blocks-dev-shell 0.1.99 → 0.1.101
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/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-ClOA7w72.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-B6v5FUFk.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
@@ -59,6 +59,22 @@ const captureRuntimeErrors = {
|
|
|
59
59
|
},
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Allows Notion apps and local hosts to read the dev server's manifest.
|
|
64
|
+
* CORS checks the requesting page's origin, so hosted Notion origins must
|
|
65
|
+
* be allowed even though the manifest is served from localhost.
|
|
66
|
+
*/
|
|
67
|
+
function isAllowedManifestOrigin(origin) {
|
|
68
|
+
if (!origin) {
|
|
69
|
+
return false
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const localOrigin = ${/^https?:\/\/(?:(?:[a-z0-9-]+\.)*localhost|127\.0\.0\.1|\[::1\]|local\.notion\.so)(?::[0-9]+)?$/i}
|
|
73
|
+
const notionOrigin = ${/^https:\/\/(?:(?:dev|stg|www)\.notion\.so|app(?:\.(?:local|dev|stg|prod|canary))?\.notion\.com)$/i}
|
|
74
|
+
|
|
75
|
+
return localOrigin.test(origin) || notionOrigin.test(origin)
|
|
76
|
+
}
|
|
77
|
+
|
|
62
78
|
const serveWorkerManifest = {
|
|
63
79
|
name: "dev-shell:worker-block-manifest",
|
|
64
80
|
enforce: "pre",
|
|
@@ -68,6 +84,13 @@ const serveWorkerManifest = {
|
|
|
68
84
|
next()
|
|
69
85
|
return
|
|
70
86
|
}
|
|
87
|
+
// Notion hosts read custom blocks' manifests for in-app preview.
|
|
88
|
+
// Allow CORS for these reads without opening other routes.
|
|
89
|
+
const { origin } = req.headers
|
|
90
|
+
if (isAllowedManifestOrigin(origin)) {
|
|
91
|
+
res.setHeader("Access-Control-Allow-Origin", origin)
|
|
92
|
+
}
|
|
93
|
+
res.setHeader("Vary", "Origin")
|
|
71
94
|
res.setHeader("Content-Type", "application/json")
|
|
72
95
|
res.end(manifest)
|
|
73
96
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notionhq/custom-blocks-dev-shell",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.101",
|
|
4
4
|
"description": "Local preview shell for Notion custom block workers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"typescript": "^7.0.2",
|
|
36
36
|
"vite": "^8.2.2",
|
|
37
37
|
"vitest": "^5.0.0",
|
|
38
|
-
"@notionhq/custom-blocks-
|
|
39
|
-
"@notionhq/custom-blocks-
|
|
38
|
+
"@notionhq/custom-blocks-host": "0.2.17",
|
|
39
|
+
"@notionhq/custom-blocks-protocol": "0.1.0"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"dev": "vite",
|