rotion 3.6.3 → 4.0.1
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.ja.md +20 -12
- package/README.md +26 -17
- package/dist/exporter/api.d.ts +11 -1
- package/dist/exporter/api.js +35 -30
- package/dist/exporter/api.js.map +1 -1
- package/dist/exporter/bin.d.ts +2 -0
- package/dist/exporter/bin.js +4 -0
- package/dist/exporter/bin.js.map +1 -0
- package/dist/exporter/blocks.js +355 -322
- package/dist/exporter/blocks.js.map +1 -1
- package/dist/exporter/breadcrumbs.js +3 -3
- package/dist/exporter/breadcrumbs.js.map +1 -1
- package/dist/exporter/cli.d.ts +16 -0
- package/dist/exporter/cli.js +126 -0
- package/dist/exporter/cli.js.map +1 -0
- package/dist/exporter/database.js +82 -75
- package/dist/exporter/database.js.map +1 -1
- package/dist/exporter/dependencies.d.ts +38 -0
- package/dist/exporter/dependencies.js +102 -0
- package/dist/exporter/dependencies.js.map +1 -0
- package/dist/exporter/failures.d.ts +52 -0
- package/dist/exporter/failures.js +105 -0
- package/dist/exporter/failures.js.map +1 -0
- package/dist/exporter/files.d.ts +21 -0
- package/dist/exporter/files.js +164 -94
- package/dist/exporter/files.js.map +1 -1
- package/dist/exporter/github.d.ts +8 -0
- package/dist/exporter/github.js +22 -5
- package/dist/exporter/github.js.map +1 -1
- package/dist/exporter/index.d.ts +4 -0
- package/dist/exporter/index.js +2 -0
- package/dist/exporter/index.js.map +1 -1
- package/dist/exporter/log.d.ts +6 -0
- package/dist/exporter/log.js +15 -0
- package/dist/exporter/log.js.map +1 -0
- package/dist/exporter/mutex.js +55 -16
- package/dist/exporter/mutex.js.map +1 -1
- package/dist/exporter/page.js +51 -35
- package/dist/exporter/page.js.map +1 -1
- package/dist/exporter/prune.d.ts +27 -0
- package/dist/exporter/prune.js +95 -0
- package/dist/exporter/prune.js.map +1 -0
- package/dist/exporter/types.d.ts +13 -0
- package/dist/exporter/variables.d.ts +61 -17
- package/dist/exporter/variables.js +86 -23
- package/dist/exporter/variables.js.map +1 -1
- package/dist/ui/components/Gallery/GalleryCard/options.d.ts +11 -0
- package/dist/ui/esm/components/Gallery/GalleryCard/GalleryCard.js +2 -17
- package/dist/ui/esm/components/Gallery/GalleryCard/GalleryCard.js.map +1 -1
- package/dist/ui/esm/components/Gallery/GalleryCard/options.js +27 -0
- package/dist/ui/esm/components/Gallery/GalleryCard/options.js.map +1 -0
- package/dist/ui/esm/components/Page/CodeBlock/Code/Code.js +5 -0
- package/dist/ui/esm/components/Page/CodeBlock/Code/Code.js.map +1 -1
- package/dist/ui/index-without-dark.css +1 -1
- package/dist/ui/index.css +1 -1
- package/package.json +32 -25
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { notion, reqAPIWithBackoffAndCache } from './api.js';
|
|
3
|
+
const collectors = new AsyncLocalStorage();
|
|
4
|
+
/**
|
|
5
|
+
* recordDependency adds a dependency to the result that is being fetched.
|
|
6
|
+
*/
|
|
7
|
+
export function recordDependency(dependency) {
|
|
8
|
+
collectors.getStore()?.set(`${dependency.type}:${dependency.id}`, dependency);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* recordDependencies adds the dependencies of a result that came from the
|
|
12
|
+
* cache, so that a result which contains it depends on them too.
|
|
13
|
+
*/
|
|
14
|
+
export function recordDependencies(dependencies) {
|
|
15
|
+
for (const dependency of dependencies ?? []) {
|
|
16
|
+
recordDependency(dependency);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* collectDependencies runs fn and returns the dependencies recorded while it
|
|
21
|
+
* ran, including in nested calls. They are passed on to the caller's
|
|
22
|
+
* collector as well: the result of a nested FetchBlocks is copied into its
|
|
23
|
+
* parent's result, so the parent depends on the same pages.
|
|
24
|
+
*/
|
|
25
|
+
export async function collectDependencies(fn) {
|
|
26
|
+
const collector = new Map();
|
|
27
|
+
const value = await collectors.run(collector, fn);
|
|
28
|
+
const parent = collectors.getStore();
|
|
29
|
+
for (const [key, dependency] of collector) {
|
|
30
|
+
parent?.set(key, dependency);
|
|
31
|
+
}
|
|
32
|
+
return { value, dependencies: [...collector.values()] };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* editedTimeOf returns the current last_edited_time of a page or database.
|
|
36
|
+
* The response is cached for ROTION_CACHE_AVAILABLE_DURATION, so checking
|
|
37
|
+
* the same dependency again and again costs one request in that period.
|
|
38
|
+
*/
|
|
39
|
+
export async function editedTimeOf(type, id) {
|
|
40
|
+
if (type === 'page') {
|
|
41
|
+
const page = await reqAPIWithBackoffAndCache({
|
|
42
|
+
name: 'notion.pages.retrieve',
|
|
43
|
+
func: notion().pages.retrieve,
|
|
44
|
+
args: { page_id: id },
|
|
45
|
+
count: 3,
|
|
46
|
+
});
|
|
47
|
+
return page.last_edited_time;
|
|
48
|
+
}
|
|
49
|
+
const db = await reqAPIWithBackoffAndCache({
|
|
50
|
+
name: 'notion.databases.retrieve',
|
|
51
|
+
func: notion().databases.retrieve,
|
|
52
|
+
args: { database_id: id },
|
|
53
|
+
count: 3,
|
|
54
|
+
});
|
|
55
|
+
return db.last_edited_time;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* isAnyDependencyChanged tells whether a dependency has been edited since it
|
|
59
|
+
* was recorded. A dependency that can no longer be retrieved counts as
|
|
60
|
+
* changed, so that the result is fetched again and shows the failure.
|
|
61
|
+
*/
|
|
62
|
+
export async function isAnyDependencyChanged(dependencies) {
|
|
63
|
+
for (const dependency of dependencies ?? []) {
|
|
64
|
+
try {
|
|
65
|
+
if (await editedTimeOf(dependency.type, dependency.id) !== dependency.last_edited_time) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* pageOfBlock returns the id of the page a block is in, following the
|
|
77
|
+
* parents of nested blocks. It returns undefined for a block that is not in
|
|
78
|
+
* a page, or one nested deeper than the limit.
|
|
79
|
+
*/
|
|
80
|
+
export async function pageOfBlock(block_id, limit = 20) {
|
|
81
|
+
let id = block_id;
|
|
82
|
+
for (let i = 0; i < limit; i++) {
|
|
83
|
+
const block = await reqAPIWithBackoffAndCache({
|
|
84
|
+
name: 'notion.blocks.retrieve',
|
|
85
|
+
func: notion().blocks.retrieve,
|
|
86
|
+
args: { block_id: id },
|
|
87
|
+
count: 3,
|
|
88
|
+
});
|
|
89
|
+
if (!('parent' in block)) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
if (block.parent.type === 'page_id') {
|
|
93
|
+
return block.parent.page_id;
|
|
94
|
+
}
|
|
95
|
+
if (block.parent.type !== 'block_id') {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
id = block.parent.block_id;
|
|
99
|
+
}
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/exporter/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAA;AAQ5D,MAAM,UAAU,GAAG,IAAI,iBAAiB,EAA2B,CAAA;AAEnE;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAE,UAAsB;IACtD,UAAU,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,EAAE,EAAE,EAAE,UAAU,CAAC,CAAA;AAC/E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAE,YAAsC;IACxE,KAAK,MAAM,UAAU,IAAI,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AAQ,CAAA;IAC5B,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTPStatusError is thrown for a response whose status is not 2xx.
|
|
3
|
+
*/
|
|
4
|
+
export declare class HTTPStatusError extends Error {
|
|
5
|
+
status: number;
|
|
6
|
+
constructor(status: number, url: string);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Notion API errors that may succeed when the same request is sent again.
|
|
10
|
+
* They are retried, and a result that still misses something because of one
|
|
11
|
+
* of them is not cached.
|
|
12
|
+
*/
|
|
13
|
+
export declare const transientNotionErrorCodes: string[];
|
|
14
|
+
/**
|
|
15
|
+
* isTransientError tells whether a failure may go away on the next attempt.
|
|
16
|
+
* A missing page, a restricted resource or a 404 stays the same however many
|
|
17
|
+
* times it is requested, so a result that lacks it can be cached. A rate
|
|
18
|
+
* limit, a server error, a timeout or a network error can not, and anything
|
|
19
|
+
* that is not known to be permanent counts as transient.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isTransientError(error: unknown): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* StrictModeError is thrown by reportFailure when ROTION_STRICT is true.
|
|
24
|
+
*/
|
|
25
|
+
export declare class StrictModeError extends Error {
|
|
26
|
+
constructor(message: string, cause: unknown);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* reportFailure is called for content that was caught failing and replaced
|
|
30
|
+
* with a fallback, such as an image without a local copy. It warns, and
|
|
31
|
+
* records the failure for collectFailures, which decides from the record
|
|
32
|
+
* whether its result is complete. With ROTION_STRICT=true it throws instead,
|
|
33
|
+
* so that a build does not publish a site with missing content.
|
|
34
|
+
*/
|
|
35
|
+
export declare function reportFailure(what: string, error: unknown): void;
|
|
36
|
+
/**
|
|
37
|
+
* reportExtraFailure is reportFailure for extras that come from third
|
|
38
|
+
* parties: bookmark metadata, embeds and link previews. It only warns. One
|
|
39
|
+
* slow or rate-limited site should neither keep a page out of the cache nor
|
|
40
|
+
* fail a strict build.
|
|
41
|
+
*/
|
|
42
|
+
export declare function reportExtraFailure(what: string, error: unknown): void;
|
|
43
|
+
/**
|
|
44
|
+
* collectFailures runs fn and tells whether a transient failure was reported
|
|
45
|
+
* while it ran, including in nested calls. Such a result is incomplete and
|
|
46
|
+
* must not be cached. The failures are passed on to the caller's collector,
|
|
47
|
+
* so that a result that contains this one is not cached either.
|
|
48
|
+
*/
|
|
49
|
+
export declare function collectFailures<T>(fn: () => Promise<T>): Promise<{
|
|
50
|
+
value: T;
|
|
51
|
+
complete: boolean;
|
|
52
|
+
}>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { isNotionClientError, APIErrorCode, ClientErrorCode, } from '@notionhq/client';
|
|
3
|
+
import { warn } from './log.js';
|
|
4
|
+
import { config } from './variables.js';
|
|
5
|
+
/**
|
|
6
|
+
* HTTPStatusError is thrown for a response whose status is not 2xx.
|
|
7
|
+
*/
|
|
8
|
+
export class HTTPStatusError extends Error {
|
|
9
|
+
status;
|
|
10
|
+
constructor(status, url) {
|
|
11
|
+
super(`unexpected status ${status}: ${url}`);
|
|
12
|
+
this.name = 'HTTPStatusError';
|
|
13
|
+
this.status = status;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Notion API errors that may succeed when the same request is sent again.
|
|
18
|
+
* They are retried, and a result that still misses something because of one
|
|
19
|
+
* of them is not cached.
|
|
20
|
+
*/
|
|
21
|
+
export const transientNotionErrorCodes = [
|
|
22
|
+
APIErrorCode.RateLimited,
|
|
23
|
+
APIErrorCode.InternalServerError,
|
|
24
|
+
APIErrorCode.ServiceOverload,
|
|
25
|
+
APIErrorCode.ServiceUnavailable,
|
|
26
|
+
APIErrorCode.GatewayTimeout,
|
|
27
|
+
ClientErrorCode.ResponseError,
|
|
28
|
+
ClientErrorCode.RequestTimeout,
|
|
29
|
+
];
|
|
30
|
+
/**
|
|
31
|
+
* isTransientError tells whether a failure may go away on the next attempt.
|
|
32
|
+
* A missing page, a restricted resource or a 404 stays the same however many
|
|
33
|
+
* times it is requested, so a result that lacks it can be cached. A rate
|
|
34
|
+
* limit, a server error, a timeout or a network error can not, and anything
|
|
35
|
+
* that is not known to be permanent counts as transient.
|
|
36
|
+
*/
|
|
37
|
+
export function isTransientError(error) {
|
|
38
|
+
const seen = new Set();
|
|
39
|
+
let e = error;
|
|
40
|
+
while (e && typeof e === 'object' && !seen.has(e)) {
|
|
41
|
+
seen.add(e);
|
|
42
|
+
if (e instanceof HTTPStatusError) {
|
|
43
|
+
return e.status >= 500 || e.status === 408 || e.status === 429;
|
|
44
|
+
}
|
|
45
|
+
if (isNotionClientError(e)) {
|
|
46
|
+
return transientNotionErrorCodes.includes(e.code);
|
|
47
|
+
}
|
|
48
|
+
e = e.cause;
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
const collectors = new AsyncLocalStorage();
|
|
53
|
+
/**
|
|
54
|
+
* StrictModeError is thrown by reportFailure when ROTION_STRICT is true.
|
|
55
|
+
*/
|
|
56
|
+
export class StrictModeError extends Error {
|
|
57
|
+
constructor(message, cause) {
|
|
58
|
+
super(message, { cause });
|
|
59
|
+
this.name = 'StrictModeError';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* reportFailure is called for content that was caught failing and replaced
|
|
64
|
+
* with a fallback, such as an image without a local copy. It warns, and
|
|
65
|
+
* records the failure for collectFailures, which decides from the record
|
|
66
|
+
* whether its result is complete. With ROTION_STRICT=true it throws instead,
|
|
67
|
+
* so that a build does not publish a site with missing content.
|
|
68
|
+
*/
|
|
69
|
+
export function reportFailure(what, error) {
|
|
70
|
+
// Already reported where it happened, on its way out of an outer catch
|
|
71
|
+
if (error instanceof StrictModeError) {
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
warn(`failed to get ${what}`, error);
|
|
75
|
+
if (config().strict) {
|
|
76
|
+
throw new StrictModeError(`failed to get ${what} (ROTION_STRICT=true)`, error);
|
|
77
|
+
}
|
|
78
|
+
if (isTransientError(error)) {
|
|
79
|
+
collectors.getStore()?.transient.push(error);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* reportExtraFailure is reportFailure for extras that come from third
|
|
84
|
+
* parties: bookmark metadata, embeds and link previews. It only warns. One
|
|
85
|
+
* slow or rate-limited site should neither keep a page out of the cache nor
|
|
86
|
+
* fail a strict build.
|
|
87
|
+
*/
|
|
88
|
+
export function reportExtraFailure(what, error) {
|
|
89
|
+
warn(`failed to get ${what}`, error);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* collectFailures runs fn and tells whether a transient failure was reported
|
|
93
|
+
* while it ran, including in nested calls. Such a result is incomplete and
|
|
94
|
+
* must not be cached. The failures are passed on to the caller's collector,
|
|
95
|
+
* so that a result that contains this one is not cached either.
|
|
96
|
+
*/
|
|
97
|
+
export async function collectFailures(fn) {
|
|
98
|
+
const collector = { transient: [] };
|
|
99
|
+
const value = await collectors.run(collector, fn);
|
|
100
|
+
if (collector.transient.length > 0) {
|
|
101
|
+
collectors.getStore()?.transient.push(...collector.transient);
|
|
102
|
+
}
|
|
103
|
+
return { value, complete: collector.transient.length === 0 };
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=failures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failures.js","sourceRoot":"","sources":["../../src/exporter/failures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,eAAe,GAChB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC;;GAEG;AACH,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AC/D,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAA;AAC9D,CAAC"}
|
package/dist/exporter/files.d.ts
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
import type { VideoBlockObjectResponseEx, EmbedBlockObjectResponseEx, HtmlMetadata, ImagePathWithSize } from './types.js';
|
|
2
2
|
export declare const findLocationUrl: (rawHeaders: string[]) => string;
|
|
3
|
+
/**
|
|
4
|
+
* getHTTP returns the body of a successful response. Any other status is an
|
|
5
|
+
* error, so that an error page is never taken for the requested content.
|
|
6
|
+
*/
|
|
3
7
|
export declare function getHTTP(reqUrl: string): Promise<string>;
|
|
4
8
|
export declare function getJson<T>(reqUrl: string, httpFunc?: (reqUrl: string) => Promise<string>): Promise<T>;
|
|
5
9
|
export declare const atoh: (a: string) => string;
|
|
6
10
|
export declare const createDirWhenNotfound: (dir: string) => Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* markUsed sets the access time of files that Rotion has just used, so that
|
|
13
|
+
* pruneCache can tell them from files nothing uses any more. The modification
|
|
14
|
+
* time is kept, because it decides how long a cache file stays fresh. A file
|
|
15
|
+
* is marked at most once in markInterval by one process.
|
|
16
|
+
*/
|
|
17
|
+
export declare function markUsed(paths: string[]): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* localFilesIn returns the paths of downloaded images and files that a cached
|
|
20
|
+
* result refers to, such as /images/block-...webp, relative to the docroot.
|
|
21
|
+
*/
|
|
22
|
+
export declare function localFilesIn(data: unknown, prefixes: string[]): string[];
|
|
23
|
+
/**
|
|
24
|
+
* readCache returns a cached result. It marks the cache file and the images
|
|
25
|
+
* and files the result refers to as used: a page served from the cache still
|
|
26
|
+
* shows them, although nothing downloads them again.
|
|
27
|
+
*/
|
|
7
28
|
export declare function readCache<T>(f: string): Promise<T>;
|
|
8
29
|
export declare function writeCache(f: string, data: unknown): Promise<void>;
|
|
9
30
|
export declare function isAvailableCache(f: string, d?: number): Promise<boolean>;
|