@texonom/nutils 1.6.2 → 1.6.5
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/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +825 -732
- package/build/index.js.map +1 -1
- package/build/is-editable-block.d.ts +21 -0
- package/build/is-editable-block.d.ts.map +1 -0
- package/build/is-editable-block.test.d.ts +2 -0
- package/build/is-editable-block.test.d.ts.map +1 -0
- package/build/map-image-url.d.ts.map +1 -1
- package/build/map-image-url.test.d.ts +2 -0
- package/build/map-image-url.test.d.ts.map +1 -0
- package/build/normalize-url.d.ts.map +1 -1
- package/license +21 -0
- package/package.json +12 -8
package/build/index.js
CHANGED
|
@@ -1,752 +1,845 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
Z.call(t, c) && F(e, c, t[c]);
|
|
8
|
-
if (R)
|
|
9
|
-
for (var c of R(t))
|
|
10
|
-
G.call(t, c) && F(e, c, t[c]);
|
|
11
|
-
return e;
|
|
12
|
-
}, E = (e, t) => Y(e, x(t));
|
|
13
|
-
var L = (e, t, c) => new Promise((o, n) => {
|
|
14
|
-
var s = (a) => {
|
|
15
|
-
try {
|
|
16
|
-
i(c.next(a));
|
|
17
|
-
} catch (f) {
|
|
18
|
-
n(f);
|
|
19
|
-
}
|
|
20
|
-
}, l = (a) => {
|
|
21
|
-
try {
|
|
22
|
-
i(c.throw(a));
|
|
23
|
-
} catch (f) {
|
|
24
|
-
n(f);
|
|
25
|
-
}
|
|
26
|
-
}, i = (a) => a.done ? o(a.value) : Promise.resolve(a.value).then(s, l);
|
|
27
|
-
i((c = c.apply(e, t)).next());
|
|
28
|
-
});
|
|
29
|
-
import K from "is-url-superb";
|
|
30
|
-
import { default as qe } from "is-url-superb";
|
|
31
|
-
import M from "mem";
|
|
32
|
-
import ee from "normalize-url";
|
|
33
|
-
const W = (e) => {
|
|
34
|
-
var t;
|
|
35
|
-
return e ? Array.isArray(e) ? (t = e == null ? void 0 : e.reduce((c, o) => c + (o[0] !== "⁍" && o[0] !== "‣" ? o[0] : ""), "")) != null ? t : "" : e : "";
|
|
1
|
+
import e from "is-url-superb";
|
|
2
|
+
import t from "normalize-url";
|
|
3
|
+
//#region src/get-text-content.ts
|
|
4
|
+
var n = (e) => {
|
|
5
|
+
var t;
|
|
6
|
+
return e ? Array.isArray(e) ? (t = e == null ? void 0 : e.reduce((e, t) => e + (t[0] !== "⁍" && t[0] !== "‣" ? t[0] : ""), "")) == null ? "" : t : e : "";
|
|
36
7
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/get-block-collection-id.ts
|
|
10
|
+
function r(e, t) {
|
|
11
|
+
var n, r;
|
|
12
|
+
let i = e.collection_id || ((n = e.format) == null || (n = n.collection_pointer) == null ? void 0 : n.id);
|
|
13
|
+
if (i) return i;
|
|
14
|
+
let a = e == null || (r = e.view_ids) == null ? void 0 : r[0];
|
|
15
|
+
if (a) {
|
|
16
|
+
var o;
|
|
17
|
+
let e = (o = t.collection_view) == null || (o = o[a]) == null ? void 0 : o.value;
|
|
18
|
+
if (e) {
|
|
19
|
+
var s;
|
|
20
|
+
return (s = e.format) == null || (s = s.collection_pointer) == null ? void 0 : s.id;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/get-block-title.ts
|
|
27
|
+
function i(e, t) {
|
|
28
|
+
var i;
|
|
29
|
+
if ((i = e.properties) != null && i.title) return n(e.properties.title);
|
|
30
|
+
if (e.type === "collection_view_page" || e.type === "collection_view") {
|
|
31
|
+
let i = r(e, t);
|
|
32
|
+
if (i) {
|
|
33
|
+
var a;
|
|
34
|
+
let e = (a = t.collection[i]) == null ? void 0 : a.value;
|
|
35
|
+
if (e) return n(e.name);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/get-block-icon.ts
|
|
42
|
+
function a(e, t) {
|
|
43
|
+
var n, i;
|
|
44
|
+
if ((n = e.format) != null && n.page_icon) return (i = e.format) == null ? void 0 : i.page_icon;
|
|
45
|
+
if (e.type === "collection_view_page" || e.type === "collection_view") {
|
|
46
|
+
let n = r(e, t);
|
|
47
|
+
if (n) {
|
|
48
|
+
var a;
|
|
49
|
+
let e = (a = t.collection[n]) == null ? void 0 : a.value;
|
|
50
|
+
if (e) return e.icon;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/get-page-title.ts
|
|
57
|
+
function o(e) {
|
|
58
|
+
var t;
|
|
59
|
+
let n = (t = e.block[Object.keys(e.block)[0]]) == null ? void 0 : t.value;
|
|
60
|
+
return n ? i(n, e) : null;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/get-page-property.ts
|
|
64
|
+
function s(e, t, r) {
|
|
65
|
+
try {
|
|
66
|
+
var i;
|
|
67
|
+
if (!t.properties || !Object.keys(r.collection)) return null;
|
|
68
|
+
let a = (i = r.collection[t.parent_id]) == null ? void 0 : i.value;
|
|
69
|
+
if (a) {
|
|
70
|
+
let r = e.toLowerCase(), i = Object.keys(a.schema).find((e) => {
|
|
71
|
+
var t;
|
|
72
|
+
return ((t = a.schema[e]) == null || (t = t.name) == null ? void 0 : t.toLowerCase()) === r;
|
|
73
|
+
});
|
|
74
|
+
if (!i) return null;
|
|
75
|
+
let { type: o } = a.schema[i], s = n(t.properties[i]);
|
|
76
|
+
switch (o) {
|
|
77
|
+
case "created_time": return t.created_time;
|
|
78
|
+
case "multi_select": return s.split(",");
|
|
79
|
+
case "date": {
|
|
80
|
+
let e = t.properties[i][0][1][0][1];
|
|
81
|
+
if (e.type == "datetime") return (/* @__PURE__ */ new Date(`${e.start_date} ${e.start_time}`)).getTime();
|
|
82
|
+
if (e.type == "date") return new Date(e.start_date).getTime();
|
|
83
|
+
if (e.type == "datetimerange") {
|
|
84
|
+
let { start_date: t, start_time: n, end_date: r, end_time: i } = e;
|
|
85
|
+
return [(/* @__PURE__ */ new Date(`${t} ${n}`)).getTime(), (/* @__PURE__ */ new Date(`${r} ${i}`)).getTime()];
|
|
86
|
+
}
|
|
87
|
+
return [new Date(e.start_date).getTime(), new Date(e.end_date).getTime()];
|
|
88
|
+
}
|
|
89
|
+
case "checkbox": return s == "Yes";
|
|
90
|
+
case "last_edited_time": return t.last_edited_time;
|
|
91
|
+
default: return s;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
} catch (e) {}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/get-date-value.ts
|
|
99
|
+
var c = (e) => {
|
|
100
|
+
if (e && Array.isArray(e)) {
|
|
101
|
+
if (e[0] === "d") return e[1];
|
|
102
|
+
for (let t of e) {
|
|
103
|
+
let e = c(t);
|
|
104
|
+
if (e) return e;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}, l = (e, t, { inclusive: n = !1 } = {}) => {
|
|
109
|
+
let r = e;
|
|
110
|
+
for (; r != null;) {
|
|
111
|
+
if (n && (r == null ? void 0 : r.type) === "page") return r;
|
|
112
|
+
let e = r.parent_id, o = r.parent_table;
|
|
113
|
+
if (!e) break;
|
|
114
|
+
if (o === "collection") {
|
|
115
|
+
var i;
|
|
116
|
+
r = (i = t.collection[e]) == null ? void 0 : i.value;
|
|
117
|
+
} else {
|
|
118
|
+
var a;
|
|
119
|
+
if (r = (a = t.block[e]) == null ? void 0 : a.value, (r == null ? void 0 : r.type) === "page") return r;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}, u = (e, t, { inclusive: n = !1 } = {}) => {
|
|
124
|
+
let r = e;
|
|
125
|
+
for (; r != null;) {
|
|
126
|
+
if (n && (r == null ? void 0 : r.type) === "page") return r;
|
|
127
|
+
let e = r.parent_id, s = r.parent_table;
|
|
128
|
+
if (!e) break;
|
|
129
|
+
if (s === "collection") {
|
|
130
|
+
var i;
|
|
131
|
+
return (i = t.collection[e]) == null ? void 0 : i.value;
|
|
132
|
+
}
|
|
133
|
+
if (s === "space") {
|
|
134
|
+
var a;
|
|
135
|
+
return (a = t.space) == null || (a = a[e]) == null ? void 0 : a.value;
|
|
136
|
+
}
|
|
137
|
+
var o;
|
|
138
|
+
if (r = (o = t.block[e]) == null ? void 0 : o.value, (r == null ? void 0 : r.type) === "page") return r;
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}, d = {
|
|
142
|
+
header: 0,
|
|
143
|
+
sub_header: 1,
|
|
144
|
+
sub_sub_header: 2
|
|
145
|
+
}, f = (e, t) => {
|
|
146
|
+
var r;
|
|
147
|
+
let i = ((r = e.content) == null ? [] : r).map((e) => {
|
|
148
|
+
var r;
|
|
149
|
+
let i = (r = t.block[e]) == null ? void 0 : r.value;
|
|
150
|
+
if (i) {
|
|
151
|
+
var a;
|
|
152
|
+
let { type: t } = i;
|
|
153
|
+
if (t === "header" || t === "sub_header" || t === "sub_sub_header") return {
|
|
154
|
+
id: e,
|
|
155
|
+
type: t,
|
|
156
|
+
text: n((a = i.properties) == null ? void 0 : a.title),
|
|
157
|
+
indentLevel: d[t]
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return null;
|
|
161
|
+
}).filter(Boolean), a = [{
|
|
162
|
+
actual: -1,
|
|
163
|
+
effective: -1
|
|
164
|
+
}];
|
|
165
|
+
for (let e of i) {
|
|
166
|
+
let { indentLevel: t } = e, n = t;
|
|
167
|
+
do {
|
|
168
|
+
let { actual: t, effective: r } = a[a.length - 1];
|
|
169
|
+
if (n > t) e.indentLevel = r + 1, a.push({
|
|
170
|
+
actual: n,
|
|
171
|
+
effective: e.indentLevel
|
|
172
|
+
});
|
|
173
|
+
else if (n === t) {
|
|
174
|
+
e.indentLevel = r;
|
|
175
|
+
break;
|
|
176
|
+
} else a.pop();
|
|
177
|
+
} while (1);
|
|
178
|
+
}
|
|
179
|
+
return i;
|
|
180
|
+
}, p = (e, t, n = !1) => {
|
|
181
|
+
let r = t || Object.keys(e.block)[0], i = /* @__PURE__ */ new Set();
|
|
182
|
+
function a(t) {
|
|
183
|
+
var o;
|
|
184
|
+
if (i.has(t)) return;
|
|
185
|
+
i.add(t);
|
|
186
|
+
let s = (o = e.block[t]) == null ? void 0 : o.value;
|
|
187
|
+
if (!s) return;
|
|
188
|
+
let { content: c, type: l, properties: u, format: d } = s;
|
|
189
|
+
if (u) for (let e of Object.keys(u)) {
|
|
190
|
+
let t = u[e];
|
|
191
|
+
t.map((e) => {
|
|
192
|
+
var t;
|
|
193
|
+
let n = e == null || (t = e[0]) == null || (t = t[1]) == null ? void 0 : t[0];
|
|
194
|
+
(n == null ? void 0 : n[0]) === "p" && n[1] && a(n[1]);
|
|
195
|
+
}), t.map((e) => {
|
|
196
|
+
var t;
|
|
197
|
+
let n = e == null || (t = e[1]) == null ? void 0 : t[0];
|
|
198
|
+
((n == null ? void 0 : n[0]) === "p" || (n == null ? void 0 : n[0]) === "eoi") && n[1] && a(n[1]);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (d) {
|
|
202
|
+
var f;
|
|
203
|
+
let e = (f = d.transclusion_reference_pointer) == null ? void 0 : f.id;
|
|
204
|
+
e && a(e);
|
|
205
|
+
}
|
|
206
|
+
if (c && Array.isArray(c) && (t === r || n || l !== "page" && l !== "collection_view_page")) for (let e of c) a(e);
|
|
207
|
+
}
|
|
208
|
+
return a(r), Array.from(i);
|
|
209
|
+
}, m = (e, t) => {
|
|
210
|
+
var n;
|
|
211
|
+
let r = t || Object.keys(e.block)[0], i = /* @__PURE__ */ new Set(), a = (n = e.block[r]) == null ? void 0 : n.value;
|
|
212
|
+
a != null && a.created_by_id && i.add(a == null ? void 0 : a.created_by_id), a != null && a.last_edited_by_id && i.add(a == null ? void 0 : a.last_edited_by_id);
|
|
213
|
+
let { properties: o } = a;
|
|
214
|
+
if (o) for (let e of Object.keys(o)) o[e].map((e) => {
|
|
215
|
+
var t;
|
|
216
|
+
let n = e == null || (t = e[1]) == null ? void 0 : t[0];
|
|
217
|
+
(n == null ? void 0 : n[0]) === "u" && n[1] && i.add(n[1]);
|
|
218
|
+
});
|
|
219
|
+
return Array.from(i);
|
|
220
|
+
}, h = (e = "") => `${e.substr(0, 8)}-${e.substr(8, 4)}-${e.substr(12, 4)}-${e.substr(16, 4)}-${e.substr(20)}`, g = /\b([a-f0-9]{32})\b/, _ = /\b([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})\b/, v = (e = "", { uuid: t = !0 } = {}) => {
|
|
221
|
+
if (!e) return null;
|
|
222
|
+
e = e.split("?")[0];
|
|
223
|
+
let n = e.match(g);
|
|
224
|
+
if (n) return t ? h(n[1]) : n[1];
|
|
225
|
+
let r = e.match(_);
|
|
226
|
+
return r ? t ? r[1] : r[1].replace(/-/g, "") : null;
|
|
227
|
+
}, y = (e) => e.replace(/-/g, "");
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/find-ancestors.ts
|
|
230
|
+
function b(e, t, n = []) {
|
|
231
|
+
if (t.parent_id) {
|
|
232
|
+
var r;
|
|
233
|
+
n.push(t.parent_id);
|
|
234
|
+
let i = t.parent_table;
|
|
235
|
+
if ((r = e[i]) != null && (r = r[t.parent_id]) != null && r.value) return b(e, e[i][t.parent_id].value, n);
|
|
236
|
+
}
|
|
237
|
+
return n;
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
241
|
+
function x(e) {
|
|
242
|
+
"@babel/helpers - typeof";
|
|
243
|
+
return x = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
244
|
+
return typeof e;
|
|
245
|
+
} : function(e) {
|
|
246
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
247
|
+
}, x(e);
|
|
248
|
+
}
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
251
|
+
function ee(e, t) {
|
|
252
|
+
if (x(e) != "object" || !e) return e;
|
|
253
|
+
var n = e[Symbol.toPrimitive];
|
|
254
|
+
if (n !== void 0) {
|
|
255
|
+
var r = n.call(e, t || "default");
|
|
256
|
+
if (x(r) != "object") return r;
|
|
257
|
+
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
258
|
+
}
|
|
259
|
+
return (t === "string" ? String : Number)(e);
|
|
260
|
+
}
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
263
|
+
function te(e) {
|
|
264
|
+
var t = ee(e, "string");
|
|
265
|
+
return x(t) == "symbol" ? t : t + "";
|
|
48
266
|
}
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
269
|
+
function S(e, t, n) {
|
|
270
|
+
return (t = te(t)) in e ? Object.defineProperty(e, t, {
|
|
271
|
+
value: n,
|
|
272
|
+
enumerable: !0,
|
|
273
|
+
configurable: !0,
|
|
274
|
+
writable: !0
|
|
275
|
+
}) : e[t] = n, e;
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/objectSpread2.js
|
|
49
279
|
function C(e, t) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
return "";
|
|
280
|
+
var n = Object.keys(e);
|
|
281
|
+
if (Object.getOwnPropertySymbols) {
|
|
282
|
+
var r = Object.getOwnPropertySymbols(e);
|
|
283
|
+
t && (r = r.filter(function(t) {
|
|
284
|
+
return Object.getOwnPropertyDescriptor(e, t).enumerable;
|
|
285
|
+
})), n.push.apply(n, r);
|
|
286
|
+
}
|
|
287
|
+
return n;
|
|
60
288
|
}
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return null;
|
|
289
|
+
function w(e) {
|
|
290
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
291
|
+
var n = arguments[t] == null ? {} : arguments[t];
|
|
292
|
+
t % 2 ? C(Object(n), !0).forEach(function(t) {
|
|
293
|
+
S(e, t, n[t]);
|
|
294
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : C(Object(n)).forEach(function(t) {
|
|
295
|
+
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return e;
|
|
72
299
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/asyncToGenerator.js
|
|
302
|
+
function T(e, t, n, r, i, a, o) {
|
|
303
|
+
try {
|
|
304
|
+
var s = e[a](o), c = s.value;
|
|
305
|
+
} catch (e) {
|
|
306
|
+
n(e);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
s.done ? t(c) : Promise.resolve(c).then(r, i);
|
|
77
310
|
}
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const { type: i } = n.schema[l], a = W(t.properties[l]);
|
|
93
|
-
switch (i) {
|
|
94
|
-
case "created_time":
|
|
95
|
-
return t.created_time;
|
|
96
|
-
case "multi_select":
|
|
97
|
-
return a.split(",");
|
|
98
|
-
case "date": {
|
|
99
|
-
const r = t.properties[l][0][1][0][1];
|
|
100
|
-
if (r.type == "datetime")
|
|
101
|
-
return (/* @__PURE__ */ new Date(`${r.start_date} ${r.start_time}`)).getTime();
|
|
102
|
-
if (r.type == "date")
|
|
103
|
-
return new Date(r.start_date).getTime();
|
|
104
|
-
if (r.type == "datetimerange") {
|
|
105
|
-
const { start_date: m, start_time: b, end_date: $, end_time: v } = r, _ = (/* @__PURE__ */ new Date(`${m} ${b}`)).getTime(), h = (/* @__PURE__ */ new Date(`${$} ${v}`)).getTime();
|
|
106
|
-
return [_, h];
|
|
107
|
-
} else {
|
|
108
|
-
const m = new Date(r.start_date).getTime(), b = new Date(r.end_date).getTime();
|
|
109
|
-
return [m, b];
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
case "checkbox":
|
|
113
|
-
return a == "Yes";
|
|
114
|
-
case "last_edited_time":
|
|
115
|
-
return t.last_edited_time;
|
|
116
|
-
default:
|
|
117
|
-
return a;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
} catch (n) {
|
|
121
|
-
}
|
|
122
|
-
return null;
|
|
311
|
+
function E(e) {
|
|
312
|
+
return function() {
|
|
313
|
+
var t = this, n = arguments;
|
|
314
|
+
return new Promise(function(r, i) {
|
|
315
|
+
var a = e.apply(t, n);
|
|
316
|
+
function o(e) {
|
|
317
|
+
T(a, r, i, o, s, "next", e);
|
|
318
|
+
}
|
|
319
|
+
function s(e) {
|
|
320
|
+
T(a, r, i, o, s, "throw", e);
|
|
321
|
+
}
|
|
322
|
+
o(void 0);
|
|
323
|
+
});
|
|
324
|
+
};
|
|
123
325
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const c = ne(t);
|
|
129
|
-
if (c) return c;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return null;
|
|
133
|
-
}, oe = (e, t, {
|
|
134
|
-
inclusive: c = !1
|
|
135
|
-
} = {}) => {
|
|
136
|
-
var n, s;
|
|
137
|
-
let o = e;
|
|
138
|
-
for (; o != null; ) {
|
|
139
|
-
if (c && (o == null ? void 0 : o.type) === "page") return o;
|
|
140
|
-
const l = o.parent_id, i = o.parent_table;
|
|
141
|
-
if (!l) break;
|
|
142
|
-
if (i === "collection")
|
|
143
|
-
o = (n = t.collection[l]) == null ? void 0 : n.value;
|
|
144
|
-
else if (o = (s = t.block[l]) == null ? void 0 : s.value, (o == null ? void 0 : o.type) === "page") return o;
|
|
145
|
-
}
|
|
146
|
-
return null;
|
|
147
|
-
}, ye = (e, t, {
|
|
148
|
-
inclusive: c = !1
|
|
149
|
-
} = {}) => {
|
|
150
|
-
var n, s, l, i;
|
|
151
|
-
let o = e;
|
|
152
|
-
for (; o != null; ) {
|
|
153
|
-
if (c && (o == null ? void 0 : o.type) === "page") return o;
|
|
154
|
-
const a = o.parent_id, f = o.parent_table;
|
|
155
|
-
if (!a) break;
|
|
156
|
-
if (f === "collection")
|
|
157
|
-
return (n = t.collection[a]) == null ? void 0 : n.value;
|
|
158
|
-
if (f === "space")
|
|
159
|
-
return (l = (s = t.space) == null ? void 0 : s[a]) == null ? void 0 : l.value;
|
|
160
|
-
if (o = (i = t.block[a]) == null ? void 0 : i.value, (o == null ? void 0 : o.type) === "page") return o;
|
|
161
|
-
}
|
|
162
|
-
return null;
|
|
163
|
-
}, ce = {
|
|
164
|
-
header: 0,
|
|
165
|
-
sub_header: 1,
|
|
166
|
-
sub_sub_header: 2
|
|
167
|
-
}, se = (e, t) => {
|
|
168
|
-
var n;
|
|
169
|
-
const c = ((n = e.content) != null ? n : []).map((s) => {
|
|
170
|
-
var i, a;
|
|
171
|
-
const l = (i = t.block[s]) == null ? void 0 : i.value;
|
|
172
|
-
if (l) {
|
|
173
|
-
const { type: f } = l;
|
|
174
|
-
if (f === "header" || f === "sub_header" || f === "sub_sub_header")
|
|
175
|
-
return {
|
|
176
|
-
id: s,
|
|
177
|
-
type: f,
|
|
178
|
-
text: W((a = l.properties) == null ? void 0 : a.title),
|
|
179
|
-
indentLevel: ce[f]
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
return null;
|
|
183
|
-
}).filter(Boolean), o = [
|
|
184
|
-
{
|
|
185
|
-
actual: -1,
|
|
186
|
-
effective: -1
|
|
187
|
-
}
|
|
188
|
-
];
|
|
189
|
-
for (const s of c) {
|
|
190
|
-
const { indentLevel: l } = s, i = l;
|
|
191
|
-
do {
|
|
192
|
-
const a = o[o.length - 1], { actual: f, effective: r } = a;
|
|
193
|
-
if (i > f)
|
|
194
|
-
s.indentLevel = r + 1, o.push({
|
|
195
|
-
actual: i,
|
|
196
|
-
effective: s.indentLevel
|
|
197
|
-
});
|
|
198
|
-
else if (i === f) {
|
|
199
|
-
s.indentLevel = r;
|
|
200
|
-
break;
|
|
201
|
-
} else
|
|
202
|
-
o.pop();
|
|
203
|
-
} while (!0);
|
|
204
|
-
}
|
|
205
|
-
return c;
|
|
206
|
-
}, D = (e, t, c = !1) => {
|
|
207
|
-
const o = t || Object.keys(e.block)[0], n = /* @__PURE__ */ new Set();
|
|
208
|
-
function s(l) {
|
|
209
|
-
var b, $;
|
|
210
|
-
if (n.has(l)) return;
|
|
211
|
-
n.add(l);
|
|
212
|
-
const i = (b = e.block[l]) == null ? void 0 : b.value;
|
|
213
|
-
if (!i) return;
|
|
214
|
-
const { content: a, type: f, properties: r, format: m } = i;
|
|
215
|
-
if (r)
|
|
216
|
-
for (const v of Object.keys(r)) {
|
|
217
|
-
const _ = r[v];
|
|
218
|
-
_.map((h) => {
|
|
219
|
-
var I, w;
|
|
220
|
-
const k = (w = (I = h == null ? void 0 : h[0]) == null ? void 0 : I[1]) == null ? void 0 : w[0];
|
|
221
|
-
(k == null ? void 0 : k[0]) === "p" && k[1] && s(k[1]);
|
|
222
|
-
}), _.map((h) => {
|
|
223
|
-
var I;
|
|
224
|
-
const k = (I = h == null ? void 0 : h[1]) == null ? void 0 : I[0];
|
|
225
|
-
((k == null ? void 0 : k[0]) === "p" || (k == null ? void 0 : k[0]) === "eoi") && k[1] && s(k[1]);
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
if (m) {
|
|
229
|
-
const v = ($ = m.transclusion_reference_pointer) == null ? void 0 : $.id;
|
|
230
|
-
v && s(v);
|
|
231
|
-
}
|
|
232
|
-
if (!(!a || !Array.isArray(a)) && !(l !== o && !c && (f === "page" || f === "collection_view_page")))
|
|
233
|
-
for (const v of a) s(v);
|
|
234
|
-
}
|
|
235
|
-
return s(o), Array.from(n);
|
|
236
|
-
}, we = (e, t) => {
|
|
237
|
-
var l;
|
|
238
|
-
const c = t || Object.keys(e.block)[0], o = /* @__PURE__ */ new Set(), n = (l = e.block[c]) == null ? void 0 : l.value;
|
|
239
|
-
n != null && n.created_by_id && o.add(n == null ? void 0 : n.created_by_id), n != null && n.last_edited_by_id && o.add(n == null ? void 0 : n.last_edited_by_id);
|
|
240
|
-
const { properties: s } = n;
|
|
241
|
-
if (s)
|
|
242
|
-
for (const i of Object.keys(s))
|
|
243
|
-
s[i].map((f) => {
|
|
244
|
-
var m;
|
|
245
|
-
const r = (m = f == null ? void 0 : f[1]) == null ? void 0 : m[0];
|
|
246
|
-
(r == null ? void 0 : r[0]) === "u" && r[1] && o.add(r[1]);
|
|
247
|
-
});
|
|
248
|
-
return Array.from(o);
|
|
249
|
-
}, ie = (e = "") => `${e.substr(0, 8)}-${e.substr(8, 4)}-${e.substr(12, 4)}-${e.substr(16, 4)}-${e.substr(20)}`, le = /\b([a-f0-9]{32})\b/, ae = /\b([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})\b/, Ie = (e = "", { uuid: t = !0 } = {}) => {
|
|
250
|
-
if (!e) return null;
|
|
251
|
-
e = e.split("?")[0];
|
|
252
|
-
const c = e.match(le);
|
|
253
|
-
if (c) return t ? ie(c[1]) : c[1];
|
|
254
|
-
const o = e.match(ae);
|
|
255
|
-
return o ? t ? o[1] : o[1].replace(/-/g, "") : null;
|
|
256
|
-
}, re = (e) => e.replace(/-/g, "");
|
|
257
|
-
function X(e, t, c = []) {
|
|
258
|
-
var o, n;
|
|
259
|
-
if (t.parent_id) {
|
|
260
|
-
c.push(t.parent_id);
|
|
261
|
-
const s = t.parent_table;
|
|
262
|
-
if ((n = (o = e[s]) == null ? void 0 : o[t.parent_id]) != null && n.value)
|
|
263
|
-
return X(e, e[s][t.parent_id].value, c);
|
|
264
|
-
}
|
|
265
|
-
return c;
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/get-all-in-space.ts
|
|
328
|
+
function D(e, t, n, r) {
|
|
329
|
+
return O.apply(this, arguments);
|
|
266
330
|
}
|
|
267
|
-
function
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
type: "page"
|
|
318
|
-
};
|
|
319
|
-
return A(_, U), i && console.timeEnd("get page tree"), { pageMap: v, pageTree: U, recordMap: _ };
|
|
320
|
-
});
|
|
331
|
+
function O() {
|
|
332
|
+
return O = E(function* (e, t, n, r, { startRecordMap: a, fetchOption: o = { timeout: 1e5 }, maxPage: s, debug: c, concurrency: l = 100, collectionConcurrency: u = 100 } = {}) {
|
|
333
|
+
var d;
|
|
334
|
+
let f = {}, m = a || (yield t(e, { fetchOption: o })), h = JSON.parse(JSON.stringify(m));
|
|
335
|
+
c && console.time("Total fetch time");
|
|
336
|
+
let g = 1;
|
|
337
|
+
for (;;) {
|
|
338
|
+
c && console.debug(`Iteration ${g}`), c && console.debug("block length ", Object.keys(m.block).length), c && console.time("getPageContentBlockIds");
|
|
339
|
+
let e = Object.keys(h.block), t = Object.keys(e.reduce((e, t) => {
|
|
340
|
+
let n = p(m, t, !0);
|
|
341
|
+
for (let t of n) m.block[t] || (e[t] = !0);
|
|
342
|
+
return e;
|
|
343
|
+
}, {}));
|
|
344
|
+
for (let { value: e } of Object.values(h.block)) e && !m.block[e.parent_id] && e.parent_table === "block" && t.push(e.parent_id);
|
|
345
|
+
if (c && console.timeEnd("getPageContentBlockIds"), c && console.time("getBlocks"), h = (yield n(t, o)).recordMap, c && console.timeEnd("getBlocks"), !(h != null && h.block)) break;
|
|
346
|
+
c && console.time("mapBlocks");
|
|
347
|
+
let i = Object.values(m.block).map((e) => {
|
|
348
|
+
var t;
|
|
349
|
+
return (t = e.value) == null ? void 0 : t.id;
|
|
350
|
+
}).filter(Boolean);
|
|
351
|
+
m.block = w(w({}, m.block), h.block), c && console.timeEnd("mapBlocks"), c && console.time("fetchCollections"), yield r(i, m, void 0, {
|
|
352
|
+
fetchOption: o,
|
|
353
|
+
concurrency: l,
|
|
354
|
+
collectionConcurrency: u
|
|
355
|
+
}), c && console.timeEnd("fetchCollections"), c && console.debug("collection query length " + Object.keys(m.collection_query).length), c && console.debug("new block length ", Object.keys(h.block).length);
|
|
356
|
+
let a = Object.values(m.block).map((e) => {
|
|
357
|
+
var t;
|
|
358
|
+
return (t = e.value) == null ? void 0 : t.type;
|
|
359
|
+
}).filter((e) => e === "page").length;
|
|
360
|
+
if (c && console.debug("page length ", a), Number.isInteger(s) && a >= s) break;
|
|
361
|
+
c && console.debug(`memory usage ${process.memoryUsage().rss / 1024 / 1024}MB`), g += 1, c && console.debug();
|
|
362
|
+
}
|
|
363
|
+
c && console.timeEnd("Total fetch time"), c && console.time("get page map"), c && console.debug("Total block length ", Object.keys(m.block).length);
|
|
364
|
+
let _ = Object.keys(m.block), v = [];
|
|
365
|
+
for (let e of _) ((d = m.block[e].value) == null ? void 0 : d.type) === "page" && (v.push(A(e, m, n).then((t) => f[e] = t)), yield M(1));
|
|
366
|
+
yield Promise.all(v), c && console.timeEnd("get page map"), c && console.debug("Total page length ", Object.keys(f).length), c && console.time("get page tree");
|
|
367
|
+
let y = {
|
|
368
|
+
id: e,
|
|
369
|
+
title: i(m.block[e].value, m),
|
|
370
|
+
blocks: 1,
|
|
371
|
+
pages: 1,
|
|
372
|
+
children: [],
|
|
373
|
+
type: "page"
|
|
374
|
+
};
|
|
375
|
+
return k(m, y), c && console.timeEnd("get page tree"), {
|
|
376
|
+
pageMap: f,
|
|
377
|
+
pageTree: y,
|
|
378
|
+
recordMap: m
|
|
379
|
+
};
|
|
380
|
+
}), O.apply(this, arguments);
|
|
321
381
|
}
|
|
322
|
-
function
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
title: C(e.block[b].value, e),
|
|
363
|
-
blocks: m.length,
|
|
364
|
-
pages: m.length,
|
|
365
|
-
children: [],
|
|
366
|
-
type: n.type,
|
|
367
|
-
parent: t
|
|
368
|
-
})
|
|
369
|
-
);
|
|
370
|
-
}
|
|
371
|
-
return delete t.parent, t;
|
|
382
|
+
function k(e, t) {
|
|
383
|
+
var n, r;
|
|
384
|
+
let a = [t], o = t;
|
|
385
|
+
for (; o.parent;) a.push(o.parent), o = o.parent;
|
|
386
|
+
let s = (n = e.block[t.id]) == null ? void 0 : n.value;
|
|
387
|
+
if (!s) return console.warn(`No block value for ${t.id}`), delete t.parent, t;
|
|
388
|
+
if ((r = s.content) != null && r.length) {
|
|
389
|
+
for (let e of a) e.blocks += s.content.length;
|
|
390
|
+
for (let n of s.content) {
|
|
391
|
+
var c;
|
|
392
|
+
let r = (c = e.block[n]) == null ? void 0 : c.value;
|
|
393
|
+
if (r && (t.children.push(k(e, {
|
|
394
|
+
id: n,
|
|
395
|
+
title: i(r, e),
|
|
396
|
+
blocks: 1,
|
|
397
|
+
pages: 0,
|
|
398
|
+
children: [],
|
|
399
|
+
type: r.type,
|
|
400
|
+
parent: t
|
|
401
|
+
})), r.type === "page")) for (let e of a) e.pages++;
|
|
402
|
+
}
|
|
403
|
+
} else if ((s == null ? void 0 : s.type) === "collection_view") {
|
|
404
|
+
var l;
|
|
405
|
+
if (!((l = e.collection_query[s.collection_id]) != null && l[s.view_ids[0]])) return console.warn(`No collection query for ${t.id}`), delete t.parent, t;
|
|
406
|
+
let n = {};
|
|
407
|
+
for (let t of Object.values(e.collection_query[s.collection_id])) if (t.collection_group_results.blockIds) for (let e of t.collection_group_results.blockIds) n[e] = !0;
|
|
408
|
+
let r = Object.keys(n);
|
|
409
|
+
for (let e of a) e.pages += r.length;
|
|
410
|
+
for (let e of a) e.blocks += r.length;
|
|
411
|
+
for (let n of r) t.children.push(k(e, {
|
|
412
|
+
id: n,
|
|
413
|
+
title: i(e.block[n].value, e),
|
|
414
|
+
blocks: r.length,
|
|
415
|
+
pages: r.length,
|
|
416
|
+
children: [],
|
|
417
|
+
type: s.type,
|
|
418
|
+
parent: t
|
|
419
|
+
}));
|
|
420
|
+
}
|
|
421
|
+
return delete t.parent, t;
|
|
372
422
|
}
|
|
373
|
-
function
|
|
374
|
-
|
|
375
|
-
var r, m, b, $, v, _, h, k, I, w, U, O, T, B, S;
|
|
376
|
-
let o = D(t, e), n = { [e]: { value: t.block[e].value, role: "reader" } };
|
|
377
|
-
const s = {}, l = {}, i = {}, a = [];
|
|
378
|
-
for (const p of o) {
|
|
379
|
-
const u = (r = t.block[p]) == null ? void 0 : r.value;
|
|
380
|
-
if (!u) {
|
|
381
|
-
a.push(p);
|
|
382
|
-
continue;
|
|
383
|
-
}
|
|
384
|
-
if (n[p] = { value: u, role: "reader" }, u.type === "collection_view" || u.type === "collection_view_page") {
|
|
385
|
-
t.collection[u.collection_id] && (s[u.collection_id] = t.collection[u.collection_id]), t.collection_query[u.collection_id] && (i[u.collection_id] = t.collection_query[u.collection_id]);
|
|
386
|
-
for (const g of u.view_ids)
|
|
387
|
-
if (t.collection_view[g]) {
|
|
388
|
-
l[g] = t.collection_view[g];
|
|
389
|
-
const y = ($ = (b = (m = t.collection_query[u == null ? void 0 : u.collection_id]) == null ? void 0 : m[g]) == null ? void 0 : b.collection_group_results) == null ? void 0 : $.blockIds;
|
|
390
|
-
if (y != null && y.length)
|
|
391
|
-
for (const P of y) {
|
|
392
|
-
const j = (v = t.block[P]) == null ? void 0 : v.value;
|
|
393
|
-
j ? n[P] = { value: j, role: "reader" } : a.push(P);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
const f = X(t, t.block[e].value);
|
|
399
|
-
for (const p of f) {
|
|
400
|
-
const u = (_ = t.block[p]) == null ? void 0 : _.value;
|
|
401
|
-
u && (n[p] = { value: u, role: "reader" });
|
|
402
|
-
const g = (h = t.collection[p]) == null ? void 0 : h.value;
|
|
403
|
-
g && (s[p] = { value: g });
|
|
404
|
-
}
|
|
405
|
-
for (const p of Object.keys(n)) {
|
|
406
|
-
const u = n[p].value;
|
|
407
|
-
let g = u;
|
|
408
|
-
if ((u == null ? void 0 : u.type) === "alias")
|
|
409
|
-
for (; ; ) {
|
|
410
|
-
const y = (I = (k = g == null ? void 0 : g.format) == null ? void 0 : k.alias_pointer) == null ? void 0 : I.id;
|
|
411
|
-
if (!y) break;
|
|
412
|
-
g = (w = t.block[y]) == null ? void 0 : w.value, g ? n[y] = { value: g, role: "reader" } : a.push(y);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
if (a.length) {
|
|
416
|
-
const p = (yield c(a).catch(() => ({ recordMap: { block: null } }))).recordMap;
|
|
417
|
-
if (p != null && p.block) {
|
|
418
|
-
n = d(d({}, n), p.block);
|
|
419
|
-
for (const u in p.block) t.block[u] = p.block[u];
|
|
420
|
-
} else
|
|
421
|
-
console.warn(`fetching ${a.length} fail for ${e}`);
|
|
422
|
-
}
|
|
423
|
-
o = D(t, e);
|
|
424
|
-
for (const p of o) {
|
|
425
|
-
const u = (U = t.block[p]) == null ? void 0 : U.value;
|
|
426
|
-
if (u && (n[p] = { value: u, role: "reader" }, u.type === "collection_view" || u.type === "collection_view_page")) {
|
|
427
|
-
t.collection[u.collection_id] && (s[u.collection_id] = t.collection[u.collection_id]), t.collection_query[u.collection_id] && (i[u.collection_id] = t.collection_query[u.collection_id]);
|
|
428
|
-
for (const g of u.view_ids)
|
|
429
|
-
if (t.collection_view[g]) {
|
|
430
|
-
l[g] = t.collection_view[g];
|
|
431
|
-
const y = (B = (T = (O = t.collection_query[u == null ? void 0 : u.collection_id]) == null ? void 0 : O[g]) == null ? void 0 : T.collection_group_results) == null ? void 0 : B.blockIds;
|
|
432
|
-
if (y != null && y.length)
|
|
433
|
-
for (const P of y) {
|
|
434
|
-
const j = (S = t.block[P]) == null ? void 0 : S.value;
|
|
435
|
-
j && (n[P] = { value: j, role: "reader" });
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
return {
|
|
441
|
-
block: n,
|
|
442
|
-
collection: s,
|
|
443
|
-
collection_view: l,
|
|
444
|
-
collection_query: i,
|
|
445
|
-
signed_urls: {},
|
|
446
|
-
notion_user: {}
|
|
447
|
-
};
|
|
448
|
-
});
|
|
423
|
+
function A(e, t, n) {
|
|
424
|
+
return j.apply(this, arguments);
|
|
449
425
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
stripWWW: !0,
|
|
544
|
-
stripHash: !0,
|
|
545
|
-
stripTextFragment: !0,
|
|
546
|
-
removeQueryParameters: !0
|
|
547
|
-
});
|
|
548
|
-
} catch (t) {
|
|
549
|
-
return "";
|
|
550
|
-
}
|
|
551
|
-
});
|
|
552
|
-
function Ce(e, t) {
|
|
553
|
-
return {
|
|
554
|
-
block: d(d({}, e.block), t.block),
|
|
555
|
-
collection: d(d({}, e.collection), t.collection),
|
|
556
|
-
collection_view: d(d({}, e.collection_view), t.collection_view),
|
|
557
|
-
notion_user: d(d({}, e.notion_user), t.notion_user),
|
|
558
|
-
collection_query: d(d({}, e.collection_query), t.collection_query),
|
|
559
|
-
signed_urls: d(d({}, e.signed_urls), t.signed_urls),
|
|
560
|
-
preview_images: d(d({}, e.preview_images), t.preview_images)
|
|
561
|
-
};
|
|
426
|
+
function j() {
|
|
427
|
+
return j = E(function* (e, t, n) {
|
|
428
|
+
let r = p(t, e), i = { [e]: {
|
|
429
|
+
value: t.block[e].value,
|
|
430
|
+
role: "reader"
|
|
431
|
+
} }, a = {}, o = {}, s = {}, c = [];
|
|
432
|
+
for (let e of r) {
|
|
433
|
+
var l;
|
|
434
|
+
let n = (l = t.block[e]) == null ? void 0 : l.value;
|
|
435
|
+
if (!n) c.push(e);
|
|
436
|
+
else if (i[e] = {
|
|
437
|
+
value: n,
|
|
438
|
+
role: "reader"
|
|
439
|
+
}, n.type === "collection_view" || n.type === "collection_view_page") {
|
|
440
|
+
t.collection[n.collection_id] && (a[n.collection_id] = t.collection[n.collection_id]), t.collection_query[n.collection_id] && (s[n.collection_id] = t.collection_query[n.collection_id]);
|
|
441
|
+
for (let e of n.view_ids) if (t.collection_view[e]) {
|
|
442
|
+
var u;
|
|
443
|
+
o[e] = t.collection_view[e];
|
|
444
|
+
let r = (u = t.collection_query[n == null ? void 0 : n.collection_id]) == null || (u = u[e]) == null || (u = u.collection_group_results) == null ? void 0 : u.blockIds;
|
|
445
|
+
if (r != null && r.length) for (let e of r) {
|
|
446
|
+
var d;
|
|
447
|
+
let n = (d = t.block[e]) == null ? void 0 : d.value;
|
|
448
|
+
n ? i[e] = {
|
|
449
|
+
value: n,
|
|
450
|
+
role: "reader"
|
|
451
|
+
} : c.push(e);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
let f = b(t, t.block[e].value);
|
|
457
|
+
for (let e of f) {
|
|
458
|
+
var m, h;
|
|
459
|
+
let n = (m = t.block[e]) == null ? void 0 : m.value;
|
|
460
|
+
n && (i[e] = {
|
|
461
|
+
value: n,
|
|
462
|
+
role: "reader"
|
|
463
|
+
});
|
|
464
|
+
let r = (h = t.collection[e]) == null ? void 0 : h.value;
|
|
465
|
+
r && (a[e] = { value: r });
|
|
466
|
+
}
|
|
467
|
+
for (let e of Object.keys(i)) {
|
|
468
|
+
let n = i[e].value, r = n;
|
|
469
|
+
if ((n == null ? void 0 : n.type) === "alias") for (;;) {
|
|
470
|
+
var g, _;
|
|
471
|
+
let e = r == null || (g = r.format) == null || (g = g.alias_pointer) == null ? void 0 : g.id;
|
|
472
|
+
if (!e) break;
|
|
473
|
+
r = (_ = t.block[e]) == null ? void 0 : _.value, r ? i[e] = {
|
|
474
|
+
value: r,
|
|
475
|
+
role: "reader"
|
|
476
|
+
} : c.push(e);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (c.length) {
|
|
480
|
+
let r = (yield n(c).catch(() => ({ recordMap: { block: null } }))).recordMap;
|
|
481
|
+
if (r != null && r.block) {
|
|
482
|
+
i = w(w({}, i), r.block);
|
|
483
|
+
for (let e in r.block) t.block[e] = r.block[e];
|
|
484
|
+
} else console.warn(`fetching ${c.length} fail for ${e}`);
|
|
485
|
+
}
|
|
486
|
+
r = p(t, e);
|
|
487
|
+
for (let e of r) {
|
|
488
|
+
var v;
|
|
489
|
+
let n = (v = t.block[e]) == null ? void 0 : v.value;
|
|
490
|
+
if (n && (i[e] = {
|
|
491
|
+
value: n,
|
|
492
|
+
role: "reader"
|
|
493
|
+
}, n.type === "collection_view" || n.type === "collection_view_page")) {
|
|
494
|
+
t.collection[n.collection_id] && (a[n.collection_id] = t.collection[n.collection_id]), t.collection_query[n.collection_id] && (s[n.collection_id] = t.collection_query[n.collection_id]);
|
|
495
|
+
for (let e of n.view_ids) if (t.collection_view[e]) {
|
|
496
|
+
var y;
|
|
497
|
+
o[e] = t.collection_view[e];
|
|
498
|
+
let r = (y = t.collection_query[n == null ? void 0 : n.collection_id]) == null || (y = y[e]) == null || (y = y.collection_group_results) == null ? void 0 : y.blockIds;
|
|
499
|
+
if (r != null && r.length) for (let e of r) {
|
|
500
|
+
var x;
|
|
501
|
+
let n = (x = t.block[e]) == null ? void 0 : x.value;
|
|
502
|
+
n && (i[e] = {
|
|
503
|
+
value: n,
|
|
504
|
+
role: "reader"
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return {
|
|
511
|
+
block: i,
|
|
512
|
+
collection: a,
|
|
513
|
+
collection_view: o,
|
|
514
|
+
collection_query: s,
|
|
515
|
+
signed_urls: {},
|
|
516
|
+
notion_user: {}
|
|
517
|
+
};
|
|
518
|
+
}), j.apply(this, arguments);
|
|
562
519
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
|
|
520
|
+
var M = function() {
|
|
521
|
+
var e = E(function* (e) {
|
|
522
|
+
return new Promise((t) => setTimeout(t, e));
|
|
523
|
+
});
|
|
524
|
+
return function(t) {
|
|
525
|
+
return e.apply(this, arguments);
|
|
526
|
+
};
|
|
527
|
+
}(), N = (e) => (e || "").replace(/( |\/)/g, "-").replace(/[^a-zA-Z0-9-\u4e00-\u9FFF\uAC00-\uD7AF\u3130-\u318F\u3041-\u3096\u30A1-\u30FC\u3000-\u303F]/g, "").replace(/--+/g, "-").replace(/^-+|-+$/g, "").trim().toLowerCase(), ne = (e, t, { uuid: r = !0 } = {}) => {
|
|
528
|
+
var a;
|
|
529
|
+
if (!e || !t) return null;
|
|
530
|
+
let o = y(e), c = (a = t.block[e]) == null ? void 0 : a.value;
|
|
531
|
+
if (c) {
|
|
532
|
+
let e = s("slug", c, t) || N(i(c, t));
|
|
533
|
+
if (e) return r ? `${e}-${o}` : e;
|
|
534
|
+
} else {
|
|
535
|
+
var l;
|
|
536
|
+
let i = (l = t.collection[e]) == null ? void 0 : l.value;
|
|
537
|
+
if (i) {
|
|
538
|
+
let e = N(n(i.name));
|
|
539
|
+
if (e) return r ? `${e}-${o}` : e;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return o;
|
|
543
|
+
}, re = (e, t) => {
|
|
544
|
+
let n = e.block, r = [], o = t;
|
|
545
|
+
do {
|
|
546
|
+
var s;
|
|
547
|
+
let c = (s = n[o]) == null ? void 0 : s.value;
|
|
548
|
+
if (!c) break;
|
|
549
|
+
let u = i(c, e), d = a(c, e);
|
|
550
|
+
if (!(u || d)) break;
|
|
551
|
+
r.push({
|
|
552
|
+
block: c,
|
|
553
|
+
active: o === t,
|
|
554
|
+
pageId: o,
|
|
555
|
+
title: u,
|
|
556
|
+
icon: d
|
|
557
|
+
});
|
|
558
|
+
let f = l(c, e), p = f == null ? void 0 : f.id;
|
|
559
|
+
if (!p) break;
|
|
560
|
+
o = p;
|
|
561
|
+
} while (1);
|
|
562
|
+
return r.reverse(), r;
|
|
563
|
+
}, ie = (t, { mapImageUrl: n }) => {
|
|
564
|
+
let r = Object.keys(t.block).flatMap((n) => {
|
|
565
|
+
var r;
|
|
566
|
+
let i = (r = t.block[n]) == null ? void 0 : r.value, o = [];
|
|
567
|
+
if (i) {
|
|
568
|
+
var s, c, l;
|
|
569
|
+
if (i.type === "image") {
|
|
570
|
+
var u, d, f;
|
|
571
|
+
let e = ((u = t.signed_urls) == null ? void 0 : u[i.id]) || ((d = i.properties) == null || (d = d.source) == null || (d = d[0]) == null ? void 0 : d[0]);
|
|
572
|
+
e.includes("file.notion.so") && (e = (f = i.properties) == null || (f = f.source) == null || (f = f[0]) == null ? void 0 : f[0]), e && o.push({
|
|
573
|
+
block: i,
|
|
574
|
+
url: e
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
if ((s = i.format) != null && s.page_cover) {
|
|
578
|
+
let e = i.format.page_cover;
|
|
579
|
+
o.push({
|
|
580
|
+
block: i,
|
|
581
|
+
url: e
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
if ((c = i.format) != null && c.bookmark_cover) {
|
|
585
|
+
let e = i.format.bookmark_cover;
|
|
586
|
+
o.push({
|
|
587
|
+
block: i,
|
|
588
|
+
url: e
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
if ((l = i.format) != null && l.bookmark_icon) {
|
|
592
|
+
let e = i.format.bookmark_icon;
|
|
593
|
+
o.push({
|
|
594
|
+
block: i,
|
|
595
|
+
url: e
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
let n = a(i, t);
|
|
599
|
+
n && e(n) && o.push({
|
|
600
|
+
block: i,
|
|
601
|
+
url: n
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
return o;
|
|
605
|
+
}).filter(Boolean).map(({ block: e, url: t }) => n(t, e)).filter(Boolean);
|
|
606
|
+
return Array.from(new Set(r));
|
|
607
|
+
}, P = /* @__PURE__ */ new Set([
|
|
608
|
+
"text",
|
|
609
|
+
"header",
|
|
610
|
+
"sub_header",
|
|
611
|
+
"sub_sub_header",
|
|
612
|
+
"bulleted_list",
|
|
613
|
+
"numbered_list"
|
|
614
|
+
]), F = (e) => Array.isArray(e) && e.every((e) => Array.isArray(e) && typeof e[0] == "string" && (e[1] === void 0 || Array.isArray(e[1]) && e[1].length === 0)), ae = (e) => {
|
|
615
|
+
var t;
|
|
616
|
+
return P.has(e.type) && F((t = e.properties) == null ? void 0 : t.title);
|
|
617
|
+
}, oe = (e, t, n, r) => {
|
|
618
|
+
if (n === "length" || n === "prototype" || n === "arguments" || n === "caller") return;
|
|
619
|
+
let i = Object.getOwnPropertyDescriptor(e, n), a = Object.getOwnPropertyDescriptor(t, n);
|
|
620
|
+
(I(i, a) || !r) && Object.defineProperty(e, n, a);
|
|
621
|
+
}, I = function(e, t) {
|
|
622
|
+
return e === void 0 || e.configurable || e.writable === t.writable && e.enumerable === t.enumerable && e.configurable === t.configurable && (e.writable || e.value === t.value);
|
|
623
|
+
}, L = (e, t) => {
|
|
624
|
+
let n = Object.getPrototypeOf(t);
|
|
625
|
+
n !== Object.getPrototypeOf(e) && Object.setPrototypeOf(e, n);
|
|
626
|
+
}, R = (e, t) => `/* Wrapped ${e}*/\n${t}`, z = Object.getOwnPropertyDescriptor(Function.prototype, "toString"), B = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name"), V = (e, t, n) => {
|
|
627
|
+
let r = n === "" ? "" : `with ${n.trim()}() `, i = R.bind(null, r, t.toString());
|
|
628
|
+
Object.defineProperty(i, "name", B);
|
|
629
|
+
let { writable: a, enumerable: o, configurable: s } = z;
|
|
630
|
+
Object.defineProperty(e, "toString", {
|
|
631
|
+
value: i,
|
|
632
|
+
writable: a,
|
|
633
|
+
enumerable: o,
|
|
634
|
+
configurable: s
|
|
635
|
+
});
|
|
569
636
|
};
|
|
570
|
-
function
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
637
|
+
function H(e, t, { ignoreNonConfigurable: n = !1 } = {}) {
|
|
638
|
+
let { name: r } = e;
|
|
639
|
+
for (let r of Reflect.ownKeys(t)) oe(e, t, r, n);
|
|
640
|
+
return L(e, t), V(e, t, r), e;
|
|
641
|
+
}
|
|
642
|
+
//#endregion
|
|
643
|
+
//#region ../../node_modules/.pnpm/memoize@11.0.0/node_modules/memoize/distribution/index.js
|
|
644
|
+
var U = 2147483647, W = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap();
|
|
645
|
+
function se(e, t) {
|
|
646
|
+
let n = e.get(t);
|
|
647
|
+
if (n) {
|
|
648
|
+
if (n.maxAge <= Date.now()) e.delete(t);
|
|
649
|
+
else return n;
|
|
650
|
+
}
|
|
577
651
|
}
|
|
578
|
-
function
|
|
579
|
-
|
|
580
|
-
|
|
652
|
+
function q(e, t) {
|
|
653
|
+
if (e !== Infinity) {
|
|
654
|
+
if (!Number.isFinite(e)) throw TypeError(t === "`maxAge` option" ? "The `maxAge` option must be a finite number, `0`, or `Infinity`." : "The `maxAge` function must return a finite number, `0`, or `Infinity`.");
|
|
655
|
+
if (e > U) throw TypeError(t === "`maxAge` option" ? `The \`maxAge\` option cannot exceed ${U}.` : `The \`maxAge\` function result cannot exceed ${U}.`);
|
|
656
|
+
}
|
|
581
657
|
}
|
|
582
|
-
function
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
658
|
+
function ce(e, { cacheKey: t, cache: n = /* @__PURE__ */ new Map(), maxAge: r } = {}) {
|
|
659
|
+
if (typeof r == "number" && (q(r, "`maxAge` option"), r <= 0)) return e;
|
|
660
|
+
let i = function(...a) {
|
|
661
|
+
let o = t ? t(a) : a[0], s = se(n, o);
|
|
662
|
+
if (s) return s.data;
|
|
663
|
+
let c = e.apply(this, a), l = typeof r == "function" ? r(...a) : r;
|
|
664
|
+
if (l !== void 0 && l !== Infinity && (q(l, "`maxAge` function result"), l <= 0)) return c;
|
|
665
|
+
if (n.set(o, {
|
|
666
|
+
data: c,
|
|
667
|
+
maxAge: l === void 0 || l === Infinity ? Infinity : Date.now() + l
|
|
668
|
+
}), l !== void 0 && l !== Infinity) {
|
|
669
|
+
var u, d;
|
|
670
|
+
let e = setTimeout(() => {
|
|
671
|
+
var t;
|
|
672
|
+
n.delete(o), (t = G.get(i)) == null || t.delete(e);
|
|
673
|
+
}, l);
|
|
674
|
+
(u = e.unref) == null || u.call(e);
|
|
675
|
+
let t = (d = G.get(i)) == null ? /* @__PURE__ */ new Set() : d;
|
|
676
|
+
t.add(e), G.set(i, t);
|
|
677
|
+
}
|
|
678
|
+
return c;
|
|
679
|
+
};
|
|
680
|
+
return H(i, e, { ignoreNonConfigurable: !0 }), W.set(i, n), K.set(i, t == null ? ((e) => e[0]) : t), i;
|
|
681
|
+
}
|
|
682
|
+
//#endregion
|
|
683
|
+
//#region src/normalize-url.ts
|
|
684
|
+
var J = ce((e) => {
|
|
685
|
+
if (!e) return "";
|
|
686
|
+
try {
|
|
687
|
+
if (e.startsWith("https://www.notion.so/image/")) {
|
|
688
|
+
let t = new URL(e), n = J(decodeURIComponent(t.pathname.substring(7)));
|
|
689
|
+
t.pathname = `/image/${encodeURIComponent(n)}`, e = t.toString();
|
|
690
|
+
}
|
|
691
|
+
return t(e, {
|
|
692
|
+
stripProtocol: !0,
|
|
693
|
+
stripWWW: !0,
|
|
694
|
+
stripHash: !0,
|
|
695
|
+
stripTextFragment: !0,
|
|
696
|
+
removeQueryParameters: !0
|
|
697
|
+
});
|
|
698
|
+
} catch (e) {
|
|
699
|
+
return "";
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
//#endregion
|
|
703
|
+
//#region src/merge-record-maps.ts
|
|
704
|
+
function le(e, t) {
|
|
705
|
+
return {
|
|
706
|
+
block: w(w({}, e.block), t.block),
|
|
707
|
+
collection: w(w({}, e.collection), t.collection),
|
|
708
|
+
collection_view: w(w({}, e.collection_view), t.collection_view),
|
|
709
|
+
notion_user: w(w({}, e.notion_user), t.notion_user),
|
|
710
|
+
collection_query: w(w({}, e.collection_query), t.collection_query),
|
|
711
|
+
signed_urls: w(w({}, e.signed_urls), t.signed_urls),
|
|
712
|
+
preview_images: w(w({}, e.preview_images), t.preview_images)
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
//#endregion
|
|
716
|
+
//#region src/format-date.ts
|
|
717
|
+
var Y = (e, { month: t = "short" } = {}) => {
|
|
718
|
+
let n = new Date(e), r = n.toLocaleString("en-US", { month: t });
|
|
719
|
+
return `${n.getUTCFullYear()} ${r} ${n.getUTCDate()} ${n.getUTCHours()}:${n.getUTCMinutes()}`;
|
|
720
|
+
}, ue = (e) => Y(`${e.start_time || ""} ${e.start_date} ${e.time_zone || ""}`);
|
|
721
|
+
//#endregion
|
|
722
|
+
//#region src/estimate-page-read-time.ts
|
|
723
|
+
function X(e, t, { wordsPerMinute: n = 275, imageReadTimeInSeconds: r = 12 } = {}) {
|
|
724
|
+
let i = Z(e, t), a = i.numWords / n, o = (i.numImages > 10 ? i.numImages / 2 * (r + 3) + (i.numImages - 10) * 3 : i.numImages / 2 * (2 * r + (1 - i.numImages))) / 60, s = a + o;
|
|
725
|
+
return w(w({}, i), {}, {
|
|
726
|
+
totalWordsReadTimeInMinutes: a,
|
|
727
|
+
totalImageReadTimeInMinutes: o,
|
|
728
|
+
totalReadTimeInMinutes: s
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
function de(e, t, n) {
|
|
732
|
+
return fe(X(e, t, n).totalReadTimeInMinutes);
|
|
733
|
+
}
|
|
734
|
+
function Z(e, t) {
|
|
735
|
+
let n = {
|
|
736
|
+
numWords: 0,
|
|
737
|
+
numImages: 0
|
|
738
|
+
};
|
|
739
|
+
if (!e) return n;
|
|
740
|
+
for (let s of e.content || []) {
|
|
741
|
+
var r;
|
|
742
|
+
let c = (r = t.block[s]) == null ? void 0 : r.value, l = !1;
|
|
743
|
+
if (c) {
|
|
744
|
+
switch (c.type) {
|
|
745
|
+
case "quote":
|
|
746
|
+
case "alias":
|
|
747
|
+
case "header":
|
|
748
|
+
case "sub_header":
|
|
749
|
+
case "sub_sub_header": {
|
|
750
|
+
let e = i(c, t);
|
|
751
|
+
n.numWords += $(e);
|
|
752
|
+
break;
|
|
753
|
+
}
|
|
754
|
+
case "callout":
|
|
755
|
+
case "toggle":
|
|
756
|
+
case "to_do":
|
|
757
|
+
case "bulleted_list":
|
|
758
|
+
case "numbered_list":
|
|
759
|
+
case "text": {
|
|
760
|
+
let e = i(c, t);
|
|
761
|
+
n.numWords += $(e), l = !0;
|
|
762
|
+
break;
|
|
763
|
+
}
|
|
764
|
+
case "embed":
|
|
765
|
+
case "tweet":
|
|
766
|
+
case "maps":
|
|
767
|
+
case "pdf":
|
|
768
|
+
case "figma":
|
|
769
|
+
case "typeform":
|
|
770
|
+
case "codepen":
|
|
771
|
+
case "excalidraw":
|
|
772
|
+
case "gist":
|
|
773
|
+
case "video":
|
|
774
|
+
case "drive":
|
|
775
|
+
case "audio":
|
|
776
|
+
case "file":
|
|
777
|
+
case "image":
|
|
778
|
+
n.numImages += 1;
|
|
779
|
+
break;
|
|
780
|
+
case "bookmark":
|
|
781
|
+
n.numImages += .25;
|
|
782
|
+
break;
|
|
783
|
+
case "code":
|
|
784
|
+
n.numImages += 2;
|
|
785
|
+
break;
|
|
786
|
+
case "table":
|
|
787
|
+
case "collection_view":
|
|
788
|
+
n.numImages += 2;
|
|
789
|
+
break;
|
|
790
|
+
case "column":
|
|
791
|
+
case "column_list":
|
|
792
|
+
case "transclusion_container":
|
|
793
|
+
l = !0;
|
|
794
|
+
break;
|
|
795
|
+
case "table_of_contents": {
|
|
796
|
+
let r = e;
|
|
797
|
+
if (!r) continue;
|
|
798
|
+
let i = f(r, t);
|
|
799
|
+
for (let e of i) n.numWords += $(e.text);
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
case "transclusion_reference": {
|
|
803
|
+
var a, o;
|
|
804
|
+
let e = c == null || (a = c.format) == null || (a = a.transclusion_reference_pointer) == null ? void 0 : a.id;
|
|
805
|
+
if (!e) continue;
|
|
806
|
+
let r = (o = t.block[e]) == null ? void 0 : o.value;
|
|
807
|
+
r && Q(n, Z(r, t));
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
l && Q(n, Z(c, t));
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
return n;
|
|
688
815
|
}
|
|
689
816
|
function Q(e, t) {
|
|
690
|
-
|
|
817
|
+
e.numWords += t.numWords, e.numImages += t.numImages;
|
|
691
818
|
}
|
|
692
|
-
function
|
|
693
|
-
|
|
819
|
+
function $(e) {
|
|
820
|
+
return e ? (e.match(/\w+/g) || []).length : 0;
|
|
694
821
|
}
|
|
695
|
-
function
|
|
696
|
-
|
|
822
|
+
function fe(e) {
|
|
823
|
+
return e < .5 ? "less than a minute" : e < 1.5 ? "1 minute" : `${Math.ceil(e)} minutes`;
|
|
697
824
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
je as defaultMapImageUrl,
|
|
720
|
-
We as defaultMapPageUrl,
|
|
721
|
-
ge as estimatePageReadTime,
|
|
722
|
-
Oe as estimatePageReadTimeAsHumanizedString,
|
|
723
|
-
X as findAncestors,
|
|
724
|
-
_e as formatDate,
|
|
725
|
-
Be as formatNotionDateTime,
|
|
726
|
-
$e as getAllInSpace,
|
|
727
|
-
V as getBlockCollectionId,
|
|
728
|
-
H as getBlockIcon,
|
|
729
|
-
ye as getBlockParent,
|
|
730
|
-
oe as getBlockParentPage,
|
|
731
|
-
C as getBlockTitle,
|
|
732
|
-
Ue as getCanonicalPageId,
|
|
733
|
-
ne as getDateValue,
|
|
734
|
-
Pe as getPageBreadcrumbs,
|
|
735
|
-
D as getPageContentBlockIds,
|
|
736
|
-
we as getPageContentUserIds,
|
|
737
|
-
Te as getPageImageUrls,
|
|
738
|
-
te as getPageProperty,
|
|
739
|
-
ue as getPageSync,
|
|
740
|
-
se as getPageTableOfContents,
|
|
741
|
-
ve as getPageTitle,
|
|
742
|
-
W as getTextContent,
|
|
743
|
-
ie as idToUuid,
|
|
744
|
-
qe as isUrl,
|
|
745
|
-
Ce as mergeRecordMaps,
|
|
746
|
-
N as normalizeTitle,
|
|
747
|
-
me as normalizeUrl,
|
|
748
|
-
Ie as parsePageId,
|
|
749
|
-
A as recursivePageTree,
|
|
750
|
-
re as uuidToId
|
|
751
|
-
};
|
|
752
|
-
//# sourceMappingURL=index.js.map
|
|
825
|
+
//#endregion
|
|
826
|
+
//#region src/map-image-url.ts
|
|
827
|
+
var pe = (e, t) => {
|
|
828
|
+
if (!e) return null;
|
|
829
|
+
if (e.startsWith("data:") || e.startsWith("https://images.unsplash.com")) return e;
|
|
830
|
+
try {
|
|
831
|
+
let t = new URL(e);
|
|
832
|
+
if ((t.protocol === "https:" || t.protocol === "http:") && !t.hostname.endsWith(".notion.so") && !t.hostname.endsWith(".amazonaws.com") && t.hostname !== "www.notion.so" && t.hostname !== "notion.so") return e;
|
|
833
|
+
} catch (e) {}
|
|
834
|
+
try {
|
|
835
|
+
let t = new URL(e);
|
|
836
|
+
if (t.pathname.startsWith("/secure.notion-static.com") && t.hostname.endsWith(".amazonaws.com") && t.searchParams.has("X-Amz-Credential") && t.searchParams.has("X-Amz-Signature") && t.searchParams.has("X-Amz-Algorithm") || t.protocol === "https:" && !t.hostname.endsWith("notion.so") && !t.hostname.endsWith("amazonaws.com")) return e;
|
|
837
|
+
} catch (e) {}
|
|
838
|
+
e.startsWith("/images") && (e = `https://www.notion.so${e}`), e = `https://www.notion.so${e.startsWith("/image") ? e : `/image/${encodeURIComponent(e)}`}`;
|
|
839
|
+
let n = new URL(e), r = t.parent_table === "space" ? "block" : t.parent_table;
|
|
840
|
+
return (r === "collection" || r === "team") && (r = "block"), n.searchParams.set("table", r), n.searchParams.set("id", t.id), n.searchParams.set("cache", "v2"), e = n.toString(), e;
|
|
841
|
+
}, me = (e) => (t) => (t = (t || "").replace(/-/g, ""), e && t === e ? "/" : `/${t}`);
|
|
842
|
+
//#endregion
|
|
843
|
+
export { P as EDITABLE_BLOCK_TYPES, pe as defaultMapImageUrl, me as defaultMapPageUrl, X as estimatePageReadTime, de as estimatePageReadTimeAsHumanizedString, b as findAncestors, Y as formatDate, ue as formatNotionDateTime, D as getAllInSpace, r as getBlockCollectionId, a as getBlockIcon, u as getBlockParent, l as getBlockParentPage, i as getBlockTitle, ne as getCanonicalPageId, c as getDateValue, re as getPageBreadcrumbs, p as getPageContentBlockIds, m as getPageContentUserIds, ie as getPageImageUrls, s as getPageProperty, A as getPageSync, f as getPageTableOfContents, o as getPageTitle, n as getTextContent, h as idToUuid, ae as isEditableBlock, F as isPlainTitle, e as isUrl, le as mergeRecordMaps, N as normalizeTitle, J as normalizeUrl, v as parsePageId, k as recursivePageTree, y as uuidToId };
|
|
844
|
+
|
|
845
|
+
//# sourceMappingURL=index.js.map
|