@alauda/doom 1.10.12 → 1.12.0
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/assets/alert.svg +1 -0
- package/assets/angle-down.svg +1 -0
- package/assets/assistant.svg +1 -0
- package/assets/close.svg +1 -0
- package/assets/logout.svg +1 -0
- package/assets/new-chat.svg +1 -0
- package/assets/question-circle.svg +1 -0
- package/assets/send.svg +1 -0
- package/lib/cli/export.js +1 -1
- package/lib/cli/load-config.js +11 -6
- package/lib/global/Intelligence/AIAssistant/Chat/ChatRefDocs/index.d.ts +5 -0
- package/lib/global/Intelligence/AIAssistant/Chat/ChatRefDocs/index.js +16 -0
- package/lib/global/Intelligence/AIAssistant/Chat/ThinkingProcess/index.d.ts +4 -0
- package/lib/global/Intelligence/AIAssistant/Chat/ThinkingProcess/index.js +6 -0
- package/lib/global/Intelligence/AIAssistant/Chat/index.d.ts +7 -0
- package/lib/global/Intelligence/AIAssistant/Chat/index.js +8 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/ApiErrorAlert/index.d.ts +5 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/ApiErrorAlert/index.js +22 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/Button/index.d.ts +8 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/Button/index.js +5 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/CaptchaInput/index.d.ts +10 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/CaptchaInput/index.js +14 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/FocusInput/index.d.ts +6 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/FocusInput/index.js +19 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/FormItem/index.d.ts +16 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/FormItem/index.js +27 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/Input/index.d.ts +7 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/Input/index.js +5 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/LoginForm/index.d.ts +3 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/LoginForm/index.js +88 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/LoginForm/types.d.ts +18 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/LoginForm/utils.d.ts +3 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/LoginForm/utils.js +7 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/Radio/Radio.d.ts +7 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/Radio/Radio.js +11 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/Radio/RadioGroup.d.ts +11 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/Radio/RadioGroup.js +21 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/Radio/context.d.ts +7 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/Radio/context.js +2 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/Radio/index.d.ts +2 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/Radio/index.js +2 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/index.d.ts +4 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/index.js +10 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/types.d.ts +9 -0
- package/lib/global/Intelligence/AIAssistant/Preamble/types.js +1 -0
- package/lib/global/Intelligence/AIAssistant/ResizableUserInput/index.d.ts +8 -0
- package/lib/global/Intelligence/AIAssistant/ResizableUserInput/index.js +54 -0
- package/lib/global/Intelligence/AIAssistant/Thinking.d.ts +1 -0
- package/lib/global/Intelligence/AIAssistant/Thinking.js +15 -0
- package/lib/global/Intelligence/AIAssistant/index.d.ts +6 -0
- package/lib/global/Intelligence/AIAssistant/index.js +122 -0
- package/lib/global/Intelligence/AIAssistant/types.d.ts +14 -0
- package/lib/global/Intelligence/AIAssistant/types.js +1 -0
- package/lib/global/Intelligence/AIAssistant/utils.d.ts +8 -0
- package/lib/global/Intelligence/AIAssistant/utils.js +29 -0
- package/lib/global/Intelligence/constants.d.ts +6 -0
- package/lib/global/Intelligence/constants.js +21 -0
- package/lib/global/Intelligence/context.d.ts +18 -0
- package/lib/global/Intelligence/context.js +31 -0
- package/lib/global/Intelligence/index.d.ts +2 -0
- package/lib/global/Intelligence/index.js +33 -0
- package/lib/global/Intelligence/types.d.ts +32 -0
- package/lib/global/Intelligence/types.js +6 -0
- package/lib/global/Intelligence/utils.d.ts +3 -0
- package/lib/global/Intelligence/utils.js +32 -0
- package/lib/global/VersionsNav/NavMenuSingleItem.js +2 -2
- package/lib/plugins/index.d.ts +0 -1
- package/lib/plugins/index.js +0 -1
- package/lib/runtime/components/OpenAPIPath.js +2 -3
- package/lib/runtime/components/Overview.js +3 -6
- package/lib/runtime/components/_utils.d.ts +1 -1
- package/lib/runtime/components/_utils.js +2 -4
- package/lib/runtime/hooks/index.d.ts +5 -3
- package/lib/runtime/hooks/index.js +5 -3
- package/lib/runtime/hooks/useInterval.d.ts +1 -0
- package/lib/runtime/hooks/useInterval.js +19 -0
- package/lib/runtime/hooks/useMemoizedFn.d.ts +1 -0
- package/lib/runtime/hooks/useMemoizedFn.js +12 -0
- package/lib/runtime/hooks/useTranslation.d.ts +1 -1
- package/lib/runtime/translation.d.ts +148 -0
- package/lib/runtime/translation.js +111 -0
- package/package.json +32 -30
- package/styles/ai-assistant.module.scss +61 -0
- package/styles/chat-ref-docs.module.scss +50 -0
- package/styles/chat.module.scss +72 -0
- package/styles/global.scss +2 -0
- package/styles/intelligence.module.scss +26 -0
- package/styles/intelligence.scss +168 -0
- package/styles/preamble.module.scss +27 -0
- package/styles/resizable-user-input.module.scss +60 -0
- package/LICENSE +0 -21
- package/README.md +0 -29
- package/lib/cli/export-pdf-core/generatePdf.d.ts +0 -25
- package/lib/cli/export-pdf-core/generatePdf.js +0 -91
- package/lib/cli/export-pdf-core/index.d.ts +0 -3
- package/lib/cli/export-pdf-core/index.js +0 -3
- package/lib/cli/export-pdf-core/types.d.ts +0 -15
- package/lib/cli/export-pdf-core/utils/convertPathToPosix.d.ts +0 -8
- package/lib/cli/export-pdf-core/utils/convertPathToPosix.js +0 -26
- package/lib/cli/export-pdf-core/utils/getUrlLink.d.ts +0 -4
- package/lib/cli/export-pdf-core/utils/getUrlLink.js +0 -7
- package/lib/cli/export-pdf-core/utils/index.d.ts +0 -3
- package/lib/cli/export-pdf-core/utils/index.js +0 -3
- package/lib/cli/export-pdf-core/utils/mergePDF.d.ts +0 -26
- package/lib/cli/export-pdf-core/utils/mergePDF.js +0 -137
- package/lib/cli/html-export-pdf/core/index.d.ts +0 -3
- package/lib/cli/html-export-pdf/core/index.js +0 -3
- package/lib/cli/html-export-pdf/core/outline.d.ts +0 -47
- package/lib/cli/html-export-pdf/core/outline.js +0 -217
- package/lib/cli/html-export-pdf/core/postprocesser.d.ts +0 -14
- package/lib/cli/html-export-pdf/core/postprocesser.js +0 -36
- package/lib/cli/html-export-pdf/core/printer.d.ts +0 -59
- package/lib/cli/html-export-pdf/core/printer.js +0 -235
- package/lib/cli/html-export-pdf/index.d.ts +0 -2
- package/lib/cli/html-export-pdf/index.js +0 -2
- package/lib/cli/html-export-pdf/utils/cliProgress.d.ts +0 -13
- package/lib/cli/html-export-pdf/utils/cliProgress.js +0 -80
- package/lib/cli/html-export-pdf/utils/fs.d.ts +0 -5
- package/lib/cli/html-export-pdf/utils/fs.js +0 -18
- package/lib/cli/html-export-pdf/utils/getAbsFileName.d.ts +0 -1
- package/lib/cli/html-export-pdf/utils/getAbsFileName.js +0 -4
- package/lib/cli/html-export-pdf/utils/getDirname.d.ts +0 -1
- package/lib/cli/html-export-pdf/utils/getDirname.js +0 -5
- package/lib/cli/html-export-pdf/utils/index.d.ts +0 -7
- package/lib/cli/html-export-pdf/utils/index.js +0 -7
- package/lib/cli/html-export-pdf/utils/isValidUrl.d.ts +0 -1
- package/lib/cli/html-export-pdf/utils/isValidUrl.js +0 -3
- package/lib/cli/html-export-pdf/utils/optionsCustomProcessing.d.ts +0 -2
- package/lib/cli/html-export-pdf/utils/optionsCustomProcessing.js +0 -6
- package/lib/cli/html-export-pdf/utils/replaceExt.d.ts +0 -1
- package/lib/cli/html-export-pdf/utils/replaceExt.js +0 -19
- package/lib/cli/merge-pdfs/formatDate.d.ts +0 -1
- package/lib/cli/merge-pdfs/formatDate.js +0 -23
- package/lib/cli/merge-pdfs/index.d.ts +0 -8
- package/lib/cli/merge-pdfs/index.js +0 -62
- package/lib/plugins/sitemap/index.d.ts +0 -16
- package/lib/plugins/sitemap/index.js +0 -51
- package/pyodide/README.md +0 -90
- package/pyodide/console.html +0 -259
- package/pyodide/ffi.d.ts +0 -1118
- package/pyodide/micropip-0.8.0-py3-none-any.whl +0 -0
- package/pyodide/package.json +0 -59
- package/pyodide/packaging-24.2-py3-none-any.whl +0 -0
- package/pyodide/pyodide-lock.json +0 -1
- package/pyodide/pyodide.asm.js +0 -17
- package/pyodide/pyodide.asm.wasm +0 -0
- package/pyodide/pyodide.d.ts +0 -1627
- package/pyodide/pyodide.js +0 -6
- package/pyodide/pyodide.js.map +0 -1
- package/pyodide/pyodide.mjs +0 -4
- package/pyodide/pyodide.mjs.map +0 -1
- package/pyodide/pypdf-3.8.1-py3-none-any.whl +0 -0
- package/pyodide/python_stdlib.zip +0 -0
- package/pyodide/repodata.json +0 -1
- /package/lib/{cli/export-pdf-core → global/Intelligence/AIAssistant/Preamble/LoginForm}/types.js +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
.api-error-alert {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
margin: 16px 0;
|
|
5
|
+
padding: 6px 12px;
|
|
6
|
+
border: 1px solid var(--rp-container-danger-border);
|
|
7
|
+
color: var(--rp-container-danger-text);
|
|
8
|
+
background-color: var(--rp-container-danger-bg);
|
|
9
|
+
|
|
10
|
+
&__icon {
|
|
11
|
+
margin-right: 12px;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.button {
|
|
16
|
+
display: inline-flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
height: 40px;
|
|
20
|
+
|
|
21
|
+
&--block {
|
|
22
|
+
width: 100%;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&--primary {
|
|
26
|
+
background-color: var(--rp-c-brand-dark);
|
|
27
|
+
border-radius: 4px;
|
|
28
|
+
color: #fff;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.captcha-input {
|
|
33
|
+
width: 100%;
|
|
34
|
+
|
|
35
|
+
&__captcha {
|
|
36
|
+
height: 32px;
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.focus-input {
|
|
42
|
+
position: relative;
|
|
43
|
+
width: 100%;
|
|
44
|
+
|
|
45
|
+
&__placeholder {
|
|
46
|
+
position: absolute;
|
|
47
|
+
top: 50%;
|
|
48
|
+
left: 8px;
|
|
49
|
+
padding: 0 2px;
|
|
50
|
+
transform: translate3d(0, -50%, 0);
|
|
51
|
+
color: var(--rp-c-text-3);
|
|
52
|
+
line-height: 1;
|
|
53
|
+
transition: top 0.5s ease-in-out;
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
z-index: 1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&--active &__placeholder {
|
|
59
|
+
top: 0;
|
|
60
|
+
background-color: var(--rp-c-bg-soft);
|
|
61
|
+
|
|
62
|
+
pointer-events: unset;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&--focus &__placeholder {
|
|
66
|
+
color: var(--rp-c-brand-dark);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.form-item--error .focus-input__placeholder {
|
|
71
|
+
color: var(--rp-container-danger-text);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.form-item {
|
|
75
|
+
display: flex;
|
|
76
|
+
width: 100%;
|
|
77
|
+
align-items: center;
|
|
78
|
+
|
|
79
|
+
&,
|
|
80
|
+
&__error {
|
|
81
|
+
& + .form-item {
|
|
82
|
+
margin-top: 24px;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&__error {
|
|
87
|
+
color: var(--rp-container-danger-text);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&__prefix {
|
|
91
|
+
margin-right: 8px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&__suffix {
|
|
95
|
+
margin-left: 8px;
|
|
96
|
+
max-height: 100%;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.input {
|
|
101
|
+
flex: 1;
|
|
102
|
+
background-color: var(--rp-c-bg-soft);
|
|
103
|
+
border: 1px solid var(--rp-c-divider);
|
|
104
|
+
border-radius: 4px;
|
|
105
|
+
height: 32px;
|
|
106
|
+
outline: none;
|
|
107
|
+
padding: 6px 8px;
|
|
108
|
+
|
|
109
|
+
&__container {
|
|
110
|
+
display: flex;
|
|
111
|
+
width: 100%;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&__prefix {
|
|
115
|
+
margin-right: 8px;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&__suffix {
|
|
119
|
+
margin-left: 8px;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&:focus {
|
|
123
|
+
border-color: var(--rp-c-brand-dark);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.region-tip {
|
|
128
|
+
cursor: pointer;
|
|
129
|
+
color: var(--rp-c-text-3);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.form-item--error .input {
|
|
133
|
+
border-color: var(--rp-container-danger-text);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.radio-group {
|
|
137
|
+
display: flex;
|
|
138
|
+
align-items: center;
|
|
139
|
+
font-size: 12px;
|
|
140
|
+
|
|
141
|
+
&__prefix,
|
|
142
|
+
&__suffix {
|
|
143
|
+
display: inline-flex;
|
|
144
|
+
align-items: center;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&__prefix {
|
|
148
|
+
margin-right: 8px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&__suffix {
|
|
152
|
+
margin-left: 8px;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.radio {
|
|
157
|
+
display: inline-flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
accent-color: var(--rp-c-brand-dark);
|
|
160
|
+
|
|
161
|
+
+ .radio {
|
|
162
|
+
margin-left: 12px;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&__label {
|
|
166
|
+
margin-left: 8px;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.preamble {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex: 1;
|
|
4
|
+
margin-top: 60px;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
align-items: center;
|
|
7
|
+
|
|
8
|
+
&.logged-in {
|
|
9
|
+
margin-top: 120px;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.title {
|
|
14
|
+
font-size: 20px;
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
margin-top: 16px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.content {
|
|
20
|
+
text-align: center;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.content,
|
|
24
|
+
.form {
|
|
25
|
+
max-width: calc(100% - 80px);
|
|
26
|
+
width: 100%;
|
|
27
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
.input {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
padding: 12px;
|
|
5
|
+
border: 2px solid var(--rp-c-divider-light);
|
|
6
|
+
border-radius: 8px;
|
|
7
|
+
|
|
8
|
+
&.error {
|
|
9
|
+
border-color: #eb0027;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
textarea {
|
|
13
|
+
border: none;
|
|
14
|
+
resize: none;
|
|
15
|
+
outline: none;
|
|
16
|
+
background: none;
|
|
17
|
+
font-size: 14px;
|
|
18
|
+
line-height: calc(20 / 14);
|
|
19
|
+
padding: 0 12px;
|
|
20
|
+
margin: 0 -12px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&:has(textarea:focus) {
|
|
24
|
+
&:not(.error) {
|
|
25
|
+
border-color: var(--rp-c-brand-dark);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.send:not(.disabled) {
|
|
29
|
+
color: var(--rp-c-brand);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.actions {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: row-reverse;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
line-height: 0;
|
|
40
|
+
margin-top: 8px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.error-tip {
|
|
44
|
+
color: #eb0027;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.send {
|
|
48
|
+
color: var(--rp-c-divider);
|
|
49
|
+
|
|
50
|
+
&.disabled {
|
|
51
|
+
cursor: not-allowed;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&:not(.disabled) {
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
&:hover {
|
|
57
|
+
color: var(--rp-c-brand);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024-present Alauda.io
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# Doom
|
|
2
|
-
|
|
3
|
-
[](https://github.com/alauda/doom/actions/workflows/ci.yml?query=branch%3Amain)
|
|
4
|
-
[](https://github.com/plantain-00/type-coverage)
|
|
5
|
-
[](https://coderabbit.ai)
|
|
6
|
-
[](https://www.npmjs.com/package/@alauda/doom)
|
|
7
|
-
[](https://github.com/alauda/doom/releases)
|
|
8
|
-
[](https://deepwiki.com/alauda/doom)
|
|
9
|
-
|
|
10
|
-
[](https://conventionalcommits.org)
|
|
11
|
-
[](https://renovatebot.com)
|
|
12
|
-
[](https://standardjs.com)
|
|
13
|
-
[](https://github.com/prettier/prettier)
|
|
14
|
-
[](https://github.com/changesets/changesets)
|
|
15
|
-
|
|
16
|
-
Doctor Doom making docs.
|
|
17
|
-
|
|
18
|
-
Please view <https://doom.js.org/> for its documents.
|
|
19
|
-
|
|
20
|
-
## Changelog
|
|
21
|
-
|
|
22
|
-
Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md).
|
|
23
|
-
|
|
24
|
-
## License
|
|
25
|
-
|
|
26
|
-
[MIT][] © [Alauda][]
|
|
27
|
-
|
|
28
|
-
[alauda]: https://www.alauda.io
|
|
29
|
-
[MIT]: http://opensource.org/licenses/MIT
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type PrinterOptions } from '../html-export-pdf/index.js';
|
|
2
|
-
import type { LaunchOptions, Page, PDFOptions } from './types.js';
|
|
3
|
-
import { type PDFOutline } from './utils/index.js';
|
|
4
|
-
export interface GeneratePdfOptions {
|
|
5
|
-
pages: Page[];
|
|
6
|
-
tempDir: string;
|
|
7
|
-
port: number;
|
|
8
|
-
host: string;
|
|
9
|
-
outFile: string;
|
|
10
|
-
outDir: string;
|
|
11
|
-
cleanupTempDir?: boolean;
|
|
12
|
-
allOutlines?: PDFOutline[];
|
|
13
|
-
launchOptions?: LaunchOptions;
|
|
14
|
-
pdfOptions?: PDFOptions;
|
|
15
|
-
pdfOutlines?: boolean;
|
|
16
|
-
urlOrigin?: string;
|
|
17
|
-
printerOptions?: PrinterOptions;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Generate PDF from VuePress or VitePress dev server.
|
|
21
|
-
*/
|
|
22
|
-
export declare function generatePdf({ pages, tempDir, port, host, outFile, outDir, cleanupTempDir, allOutlines, urlOrigin, pdfOptions, pdfOutlines, launchOptions, printerOptions, }: GeneratePdfOptions): Promise<{
|
|
23
|
-
exportedPath: string;
|
|
24
|
-
allOutlines: PDFOutline[];
|
|
25
|
-
}>;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import process from 'node:process';
|
|
4
|
-
import { red, yellow } from 'yoctocolors';
|
|
5
|
-
import { createProgress, isValidUrl, Printer, writeFileSafe, } from '../html-export-pdf/index.js';
|
|
6
|
-
import { getUrlLink, mergePDF, } from './utils/index.js';
|
|
7
|
-
/**
|
|
8
|
-
* Generate PDF from VuePress or VitePress dev server.
|
|
9
|
-
*/
|
|
10
|
-
export async function generatePdf({ pages, tempDir, port, host, outFile, outDir, cleanupTempDir = true, allOutlines = [], urlOrigin, pdfOptions, pdfOutlines = true, launchOptions, printerOptions, }) {
|
|
11
|
-
await fs.mkdir(tempDir, { recursive: true });
|
|
12
|
-
const isValidUrlOrigin = isValidUrl(urlOrigin ?? '');
|
|
13
|
-
if (urlOrigin && !isValidUrlOrigin) {
|
|
14
|
-
process.stdout.write(red(`${urlOrigin} is not a valid URL`));
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
let userURLOrigin = '';
|
|
18
|
-
if (urlOrigin && isValidUrlOrigin) {
|
|
19
|
-
userURLOrigin = new URL(urlOrigin).origin;
|
|
20
|
-
}
|
|
21
|
-
const localURLOrigin = `${host}:${port}`;
|
|
22
|
-
const normalizePages = pages.map((page) => {
|
|
23
|
-
return {
|
|
24
|
-
url: page.path,
|
|
25
|
-
title: page.title,
|
|
26
|
-
location: urlOrigin
|
|
27
|
-
? `${userURLOrigin}${page.path}`
|
|
28
|
-
: `http://${localURLOrigin}${page.path}`,
|
|
29
|
-
pagePath: path.resolve(tempDir, `${page.key}.pdf`),
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
if (allOutlines.length) {
|
|
33
|
-
const allOutlinesMapping = new Map(allOutlines);
|
|
34
|
-
allOutlines = normalizePages.map(({ location }) => {
|
|
35
|
-
const { link } = getUrlLink(location);
|
|
36
|
-
return [link, allOutlinesMapping.get(link)];
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
const singleBar = createProgress();
|
|
41
|
-
singleBar.start(normalizePages.length);
|
|
42
|
-
const printer = new Printer(printerOptions);
|
|
43
|
-
const page = await printer.setup(launchOptions);
|
|
44
|
-
if (urlOrigin && isValidUrlOrigin) {
|
|
45
|
-
await page.route('**/*', (route) => {
|
|
46
|
-
const reqUrl = route.request().url();
|
|
47
|
-
if (!isValidUrl(reqUrl)) {
|
|
48
|
-
return route.continue();
|
|
49
|
-
}
|
|
50
|
-
// http or https
|
|
51
|
-
const parsedUrl = new URL(reqUrl);
|
|
52
|
-
if (userURLOrigin === parsedUrl.origin) {
|
|
53
|
-
parsedUrl.host = host;
|
|
54
|
-
parsedUrl.protocol = 'http:';
|
|
55
|
-
parsedUrl.port = `${port}`;
|
|
56
|
-
const parsedUrlString = parsedUrl.toString();
|
|
57
|
-
return route.continue({
|
|
58
|
-
url: parsedUrlString,
|
|
59
|
-
headers: Object.assign({}, route.request().headers(), {
|
|
60
|
-
refer: parsedUrlString,
|
|
61
|
-
// Same origin
|
|
62
|
-
// origin: parsedUrl.origin,
|
|
63
|
-
// CORS
|
|
64
|
-
// host: parsedUrl.host,
|
|
65
|
-
}),
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
for (const { location, pagePath, title } of normalizePages) {
|
|
71
|
-
const { data, outlineNodes } = await printer.pdf(location, {
|
|
72
|
-
format: 'A4',
|
|
73
|
-
...pdfOptions,
|
|
74
|
-
}, pdfOutlines);
|
|
75
|
-
if (pdfOutlines) {
|
|
76
|
-
allOutlines.push([getUrlLink(location).link, outlineNodes]);
|
|
77
|
-
}
|
|
78
|
-
await writeFileSafe(pagePath, data);
|
|
79
|
-
singleBar.increment(1, { headTitle: title || (await page.title()) });
|
|
80
|
-
}
|
|
81
|
-
singleBar.stop();
|
|
82
|
-
await printer.closeBrowser();
|
|
83
|
-
}
|
|
84
|
-
const exportedPath = await mergePDF(normalizePages, outFile, outDir, allOutlines);
|
|
85
|
-
const message = `Exported to ${yellow(exportedPath)}\n`;
|
|
86
|
-
process.stdout.write(message);
|
|
87
|
-
if (cleanupTempDir) {
|
|
88
|
-
await fs.rm(tempDir, { force: true, recursive: true });
|
|
89
|
-
}
|
|
90
|
-
return { exportedPath, allOutlines };
|
|
91
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface CommandOptions {
|
|
2
|
-
config?: string;
|
|
3
|
-
outDir?: string;
|
|
4
|
-
outFile?: string;
|
|
5
|
-
debug?: boolean;
|
|
6
|
-
urlOrigin?: string;
|
|
7
|
-
pdfOutlines?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface Page {
|
|
10
|
-
title?: string;
|
|
11
|
-
key: string;
|
|
12
|
-
path: string;
|
|
13
|
-
}
|
|
14
|
-
export type { Browser, PDFOptions } from '../html-export-pdf/index.js';
|
|
15
|
-
export type { LaunchOptions } from 'playwright';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a file path to a POSIX-style path.
|
|
3
|
-
* On Windows, it replaces DOS device paths and converts backslashes to forward slashes.
|
|
4
|
-
* @param path - The file path to convert.
|
|
5
|
-
* @returns The converted POSIX-style path.
|
|
6
|
-
* @see https://github.com/mrmlnc/fast-glob/blob/28a3d61e44d5d9193ba97de4f21df6dc7725f7c0/src/utils/path.ts
|
|
7
|
-
*/
|
|
8
|
-
export declare function convertPathToPosix(path: string): string;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { platform } from 'node:os';
|
|
2
|
-
/**
|
|
3
|
-
* The device path (\\.\ or \\?\).
|
|
4
|
-
* https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#dos-device-paths
|
|
5
|
-
*/
|
|
6
|
-
const DOS_DEVICE_PATH_RE = /^\\\\(?<path>[.?])/;
|
|
7
|
-
/**
|
|
8
|
-
* All backslashes except those escaping special characters.
|
|
9
|
-
* Windows: !()+@{}
|
|
10
|
-
* https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
|
|
11
|
-
*/
|
|
12
|
-
const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@{}])/g;
|
|
13
|
-
/**
|
|
14
|
-
* Converts a file path to a POSIX-style path.
|
|
15
|
-
* On Windows, it replaces DOS device paths and converts backslashes to forward slashes.
|
|
16
|
-
* @param path - The file path to convert.
|
|
17
|
-
* @returns The converted POSIX-style path.
|
|
18
|
-
* @see https://github.com/mrmlnc/fast-glob/blob/28a3d61e44d5d9193ba97de4f21df6dc7725f7c0/src/utils/path.ts
|
|
19
|
-
*/
|
|
20
|
-
export function convertPathToPosix(path) {
|
|
21
|
-
return platform() === 'win32'
|
|
22
|
-
? path
|
|
23
|
-
.replace(DOS_DEVICE_PATH_RE, '//$1')
|
|
24
|
-
.replaceAll(WINDOWS_BACKSLASHES_RE, '/')
|
|
25
|
-
: path;
|
|
26
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { PDFArray } from 'pdf-lib';
|
|
2
|
-
import type { OutlineNode } from '../../html-export-pdf/index.js';
|
|
3
|
-
export interface NormalizePage {
|
|
4
|
-
location: string;
|
|
5
|
-
pagePath: string;
|
|
6
|
-
url: string;
|
|
7
|
-
title?: string;
|
|
8
|
-
}
|
|
9
|
-
export type PDFOutline = [path: string, outlineNodes: OutlineNode[]];
|
|
10
|
-
export interface Outline {
|
|
11
|
-
title: string;
|
|
12
|
-
dest: PDFArray;
|
|
13
|
-
children: Outline[];
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Based on @see https://github.com/Hopding/pdf-lib/issues/867#issuecomment-827570106
|
|
17
|
-
*/
|
|
18
|
-
export declare const replaceLinksWithOutline: (pdfData: Buffer | Uint8Array, pdfOutlines: PDFOutline[]) => Promise<Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike>>;
|
|
19
|
-
/**
|
|
20
|
-
* Merge PDFs.
|
|
21
|
-
* @param pages - NormalizePage
|
|
22
|
-
* @param outFile - Output file
|
|
23
|
-
* @param outDir - Output directory
|
|
24
|
-
* @returns relativePath - Output relative path
|
|
25
|
-
*/
|
|
26
|
-
export declare function mergePDF(pages: NormalizePage[], outFile: string, outDir: string, pdfOutlines: PDFOutline[]): Promise<string>;
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import process from 'node:process';
|
|
4
|
-
import { asPDFName, PDFArray, PDFDict, PDFDocument, PDFObject, PDFString, } from 'pdf-lib';
|
|
5
|
-
import PDFMerger from 'pdf-merger-js';
|
|
6
|
-
import { mergePDFs } from '../../merge-pdfs/index.js';
|
|
7
|
-
import { convertPathToPosix } from './convertPathToPosix.js';
|
|
8
|
-
import { getUrlLink } from './getUrlLink.js';
|
|
9
|
-
const extractOutline = (doc, dict) => {
|
|
10
|
-
return {
|
|
11
|
-
title: dict.get(asPDFName('Title')).decodeText(),
|
|
12
|
-
dest: dict.get(asPDFName('Dest')),
|
|
13
|
-
children: extractOutlines(doc, dict),
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
const extractOutlines = (doc, dictObj) => {
|
|
17
|
-
const outlineDict = doc.context.lookup(dictObj, PDFDict);
|
|
18
|
-
const first = outlineDict.get(asPDFName('First'));
|
|
19
|
-
let dict = doc.context.lookupMaybe(first, PDFDict);
|
|
20
|
-
if (!dict) {
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
const outlines = [extractOutline(doc, dict)];
|
|
24
|
-
let obj;
|
|
25
|
-
while ((obj = dict.get(asPDFName('Next')))) {
|
|
26
|
-
dict = doc.context.lookup(obj, PDFDict);
|
|
27
|
-
outlines.push(extractOutline(doc, dict));
|
|
28
|
-
}
|
|
29
|
-
return outlines;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Based on @see https://github.com/Hopding/pdf-lib/issues/867#issuecomment-827570106
|
|
33
|
-
*/
|
|
34
|
-
export const replaceLinksWithOutline = async (pdfData, pdfOutlines) => {
|
|
35
|
-
const pdfDoc = await PDFDocument.load(pdfData);
|
|
36
|
-
const outlinesObj = pdfDoc.catalog.get(asPDFName('Outlines'));
|
|
37
|
-
if (!outlinesObj) {
|
|
38
|
-
return pdfData;
|
|
39
|
-
}
|
|
40
|
-
const outlineMap = new WeakMap();
|
|
41
|
-
const outlineNodes = pdfOutlines.flatMap(([, outlineNodes]) => outlineNodes);
|
|
42
|
-
const outlineNodeMap = new Map(pdfOutlines);
|
|
43
|
-
const outlines = extractOutlines(pdfDoc, outlinesObj);
|
|
44
|
-
for (const [index, outlineNode] of outlineNodes.entries()) {
|
|
45
|
-
const outline = outlines[index];
|
|
46
|
-
outlineMap.set(outlineNode, outline);
|
|
47
|
-
for (const [index, outlineChild] of outlineNode.children.entries()) {
|
|
48
|
-
outlineMap.set(outlineChild, outline.children[index]);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const pages = pdfDoc.getPages();
|
|
52
|
-
for (const page of pages) {
|
|
53
|
-
for (const annot of page.node.Annots()?.asArray() || []) {
|
|
54
|
-
const dict = pdfDoc.context.lookupMaybe(annot, PDFDict);
|
|
55
|
-
const aRecord = dict?.get(asPDFName(`A`));
|
|
56
|
-
const link = pdfDoc.context.lookupMaybe(aRecord, PDFDict);
|
|
57
|
-
const uri = link?.get(asPDFName('URI'))?.toString().slice(1, -1); // get the original link, remove parenthesis
|
|
58
|
-
if (!dict || !aRecord || !link || !uri) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
const url = uri.replace(/\\(\d{2,3})/g, (_, code) => String.fromCharCode(Number.parseInt(code, 8)));
|
|
62
|
-
if (/^https?:\/\//.test(url)) {
|
|
63
|
-
const { link, hash } = getUrlLink(url);
|
|
64
|
-
let matched = outlineNodeMap.get(link);
|
|
65
|
-
if (!matched && link.endsWith('/')) {
|
|
66
|
-
matched = outlineNodeMap.get(link + 'index.html');
|
|
67
|
-
}
|
|
68
|
-
if (!matched?.length) {
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
let matchedOutlineNode = matched[0];
|
|
72
|
-
if (hash) {
|
|
73
|
-
for (const node of matched) {
|
|
74
|
-
if (node.destination === hash) {
|
|
75
|
-
matchedOutlineNode = node;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
for (const child of node.children) {
|
|
79
|
-
if (child.destination === hash) {
|
|
80
|
-
matchedOutlineNode = child;
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const matchedOutline = outlineMap.get(matchedOutlineNode);
|
|
87
|
-
if (!matchedOutline) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
dict.set(asPDFName('A'), pdfDoc.context.obj({
|
|
91
|
-
S: 'GoTo',
|
|
92
|
-
D: matchedOutline.dest,
|
|
93
|
-
}));
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return pdfDoc.save();
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Merge PDFs.
|
|
101
|
-
* @param pages - NormalizePage
|
|
102
|
-
* @param outFile - Output file
|
|
103
|
-
* @param outDir - Output directory
|
|
104
|
-
* @returns relativePath - Output relative path
|
|
105
|
-
*/
|
|
106
|
-
export async function mergePDF(pages, outFile, outDir, pdfOutlines) {
|
|
107
|
-
const saveDirPath = path.resolve(outDir);
|
|
108
|
-
if (outDir) {
|
|
109
|
-
await fs.mkdir(saveDirPath, { recursive: true });
|
|
110
|
-
}
|
|
111
|
-
const saveFilePath = path.join(saveDirPath, outFile);
|
|
112
|
-
if (pages.length === 0) {
|
|
113
|
-
throw new Error('The website has no pages, please check whether the export path is set correctly');
|
|
114
|
-
}
|
|
115
|
-
else if (pages.length === 1) {
|
|
116
|
-
await fs.rename(pages[0].pagePath, saveFilePath);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
let pdfData;
|
|
120
|
-
if (pdfOutlines.length > 0) {
|
|
121
|
-
pdfData = await mergePDFs(pages.map(({ pagePath }) => {
|
|
122
|
-
const relativePagePath = path.relative(process.cwd(), pagePath);
|
|
123
|
-
return convertPathToPosix(relativePagePath);
|
|
124
|
-
}));
|
|
125
|
-
pdfData = await replaceLinksWithOutline(pdfData, pdfOutlines);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
const merger = new PDFMerger();
|
|
129
|
-
for (const { pagePath } of pages) {
|
|
130
|
-
await merger.add(pagePath);
|
|
131
|
-
}
|
|
132
|
-
pdfData = await merger.saveAsBuffer();
|
|
133
|
-
}
|
|
134
|
-
await fs.writeFile(saveFilePath, pdfData);
|
|
135
|
-
}
|
|
136
|
-
return path.relative(process.cwd(), saveFilePath);
|
|
137
|
-
}
|