@veryfront/ext-document-kreuzberg 0.1.985
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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +23 -0
- package/esm/_dnt.polyfills.d.ts +124 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +249 -0
- package/esm/_dnt.shims.d.ts +12 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +68 -0
- package/esm/extensions/ext-document-kreuzberg/src/index.d.ts +18 -0
- package/esm/extensions/ext-document-kreuzberg/src/index.d.ts.map +1 -0
- package/esm/extensions/ext-document-kreuzberg/src/index.js +82 -0
- package/esm/extensions/ext-document-kreuzberg/src/kreuzberg.d.ts +3 -0
- package/esm/extensions/ext-document-kreuzberg/src/kreuzberg.d.ts.map +1 -0
- package/esm/extensions/ext-document-kreuzberg/src/kreuzberg.js +67 -0
- package/esm/extensions/ext-document-kreuzberg/src/runtime.d.ts +3 -0
- package/esm/extensions/ext-document-kreuzberg/src/runtime.d.ts.map +1 -0
- package/esm/extensions/ext-document-kreuzberg/src/runtime.js +26 -0
- package/esm/extensions/ext-document-kreuzberg/src/upload-extraction-worker.js +20 -0
- package/esm/package.json +3 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @veryfront/ext-document-kreuzberg
|
|
2
|
+
|
|
3
|
+
> **Category:** Document extraction | **Contract:** `DocumentExtractor` |
|
|
4
|
+
> **Built-in**
|
|
5
|
+
|
|
6
|
+
Document text extraction for Veryfront via kreuzberg.
|
|
7
|
+
|
|
8
|
+
This extension registers the `DocumentExtractor` contract and keeps kreuzberg
|
|
9
|
+
out of core.
|
|
10
|
+
|
|
11
|
+
## Supply-chain boundary
|
|
12
|
+
|
|
13
|
+
This extension is a sensitive document extraction boundary. Keep
|
|
14
|
+
`@kreuzberg/wasm` and related document parsing dependencies in this extension
|
|
15
|
+
instead of importing them from core, CLI, React, or unrelated extensions.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import extDocumentKreuzberg from "@veryfront/ext-document-kreuzberg";
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
extensions: [extDocumentKreuzberg()],
|
|
22
|
+
};
|
|
23
|
+
```
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
|
|
3
|
+
* but instead of using npm to install additional dependencies,
|
|
4
|
+
* this approach manually consolidates cjs/mjs/d.ts into a single file.
|
|
5
|
+
*
|
|
6
|
+
* Note that this code might be imported multiple times
|
|
7
|
+
* (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
|
|
8
|
+
* or Node.js might dynamically clear the cache and then force a require).
|
|
9
|
+
* Therefore, it's important to avoid redundant writes to global objects.
|
|
10
|
+
* Additionally, consider that commonjs is used alongside esm,
|
|
11
|
+
* so the two ponyfill functions are stored independently in two separate global objects.
|
|
12
|
+
*/
|
|
13
|
+
import { createRequire } from "node:module";
|
|
14
|
+
import { type URL } from "node:url";
|
|
15
|
+
declare global {
|
|
16
|
+
interface ImportMeta {
|
|
17
|
+
/** A string representation of the fully qualified module URL. When the
|
|
18
|
+
* module is loaded locally, the value will be a file URL (e.g.
|
|
19
|
+
* `file:///path/module.ts`).
|
|
20
|
+
*
|
|
21
|
+
* You can also parse the string as a URL to determine more information about
|
|
22
|
+
* how the current module was loaded. For example to determine if a module was
|
|
23
|
+
* local or not:
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* const url = new URL(import.meta.url);
|
|
27
|
+
* if (url.protocol === "file:") {
|
|
28
|
+
* console.log("this module was loaded locally");
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
url: string;
|
|
33
|
+
/**
|
|
34
|
+
* A function that returns resolved specifier as if it would be imported
|
|
35
|
+
* using `import(specifier)`.
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* console.log(import.meta.resolve("./foo.js"));
|
|
39
|
+
* // file:///dev/foo.js
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param specifier The module specifier to resolve relative to `parent`.
|
|
43
|
+
* @param parent The absolute parent module URL to resolve from.
|
|
44
|
+
* @returns The absolute (`file:`) URL string for the resolved module.
|
|
45
|
+
*/
|
|
46
|
+
resolve(specifier: string, parent?: string | URL | undefined): string;
|
|
47
|
+
/** A flag that indicates if the current module is the main module that was
|
|
48
|
+
* called when starting the program under Deno.
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* if (import.meta.main) {
|
|
52
|
+
* // this was loaded as the main module, maybe do some bootstrapping
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
main: boolean;
|
|
57
|
+
/** The absolute path of the current module.
|
|
58
|
+
*
|
|
59
|
+
* This property is only provided for local modules (ie. using `file://` URLs).
|
|
60
|
+
*
|
|
61
|
+
* Example:
|
|
62
|
+
* ```
|
|
63
|
+
* // Unix
|
|
64
|
+
* console.log(import.meta.filename); // /home/alice/my_module.ts
|
|
65
|
+
*
|
|
66
|
+
* // Windows
|
|
67
|
+
* console.log(import.meta.filename); // C:\alice\my_module.ts
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
filename: string;
|
|
71
|
+
/** The absolute path of the directory containing the current module.
|
|
72
|
+
*
|
|
73
|
+
* This property is only provided for local modules (ie. using `file://` URLs).
|
|
74
|
+
*
|
|
75
|
+
* * Example:
|
|
76
|
+
* ```
|
|
77
|
+
* // Unix
|
|
78
|
+
* console.log(import.meta.dirname); // /home/alice
|
|
79
|
+
*
|
|
80
|
+
* // Windows
|
|
81
|
+
* console.log(import.meta.dirname); // C:\alice
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
dirname: string;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
type NodeRequest = ReturnType<typeof createRequire>;
|
|
88
|
+
type NodeModule = NonNullable<NodeRequest["main"]>;
|
|
89
|
+
interface ImportMetaPonyfillCommonjs {
|
|
90
|
+
(require: NodeRequest, module: NodeModule): ImportMeta;
|
|
91
|
+
}
|
|
92
|
+
interface ImportMetaPonyfillEsmodule {
|
|
93
|
+
(importMeta: ImportMeta): ImportMeta;
|
|
94
|
+
}
|
|
95
|
+
interface ImportMetaPonyfill extends ImportMetaPonyfillCommonjs, ImportMetaPonyfillEsmodule {
|
|
96
|
+
}
|
|
97
|
+
export declare let import_meta_ponyfill_commonjs: ImportMetaPonyfillCommonjs;
|
|
98
|
+
export declare let import_meta_ponyfill_esmodule: ImportMetaPonyfillEsmodule;
|
|
99
|
+
export declare let import_meta_ponyfill: ImportMetaPonyfill;
|
|
100
|
+
declare global {
|
|
101
|
+
interface Error {
|
|
102
|
+
cause?: unknown;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export {};
|
|
106
|
+
declare global {
|
|
107
|
+
interface ArrayConstructor {
|
|
108
|
+
fromAsync<T>(iterableOrArrayLike: AsyncIterable<T> | Iterable<T | Promise<T>> | ArrayLike<T | Promise<T>>): Promise<T[]>;
|
|
109
|
+
fromAsync<T, U>(iterableOrArrayLike: AsyncIterable<T> | Iterable<T> | ArrayLike<T>, mapFn: (value: Awaited<T>) => U, thisArg?: any): Promise<Awaited<U>[]>;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export {};
|
|
113
|
+
declare global {
|
|
114
|
+
interface Object {
|
|
115
|
+
/**
|
|
116
|
+
* Determines whether an object has a property with the specified name.
|
|
117
|
+
* @param o An object.
|
|
118
|
+
* @param v A property name.
|
|
119
|
+
*/
|
|
120
|
+
hasOwn(o: object, v: PropertyKey): boolean;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export {};
|
|
124
|
+
//# sourceMappingURL=_dnt.polyfills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAgC,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAGlE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB;;;;;;;;;;;;;;WAcG;QACH,GAAG,EAAE,MAAM,CAAC;QACZ;;;;;;;;;;;;WAYG;QACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,MAAM,CAAC;QACtE;;;;;;;;WAQG;QACH,IAAI,EAAE,OAAO,CAAC;QAEd;;;;;;;;;;;;WAYG;QACH,QAAQ,EAAE,MAAM,CAAC;QAEjB;;;;;;;;;;;;WAYG;QACH,OAAO,EAAE,MAAM,CAAC;KACjB;CACF;AAED,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,KAAK,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AACnD,UAAU,0BAA0B;IAClC,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;CACxD;AACD,UAAU,0BAA0B;IAClC,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;CACtC;AACD,UAAU,kBACR,SAAQ,0BAA0B,EAAE,0BAA0B;CAC/D;AAiBD,eAAO,IAAI,6BAA6B,EA2BnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,6BAA6B,EA4DnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,oBAAoB,EAoB1B,kBAAkB,CAAC;AACxB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK;QACb,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CACF;AAED,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,gBAAgB;QACxB,SAAS,CAAC,CAAC,EACP,mBAAmB,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAC7F,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;QAEhB,SAAS,CAAC,CAAC,EAAE,CAAC,EACV,mBAAmB,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EAClE,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,EAC/B,OAAO,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KAC1B;CACF;AAoID,OAAO,EAAE,CAAC;AAeV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd;;;;WAIG;QACH,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;KAC5C;CACF;AAED,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
|
|
3
|
+
* but instead of using npm to install additional dependencies,
|
|
4
|
+
* this approach manually consolidates cjs/mjs/d.ts into a single file.
|
|
5
|
+
*
|
|
6
|
+
* Note that this code might be imported multiple times
|
|
7
|
+
* (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
|
|
8
|
+
* or Node.js might dynamically clear the cache and then force a require).
|
|
9
|
+
* Therefore, it's important to avoid redundant writes to global objects.
|
|
10
|
+
* Additionally, consider that commonjs is used alongside esm,
|
|
11
|
+
* so the two ponyfill functions are stored independently in two separate global objects.
|
|
12
|
+
*/
|
|
13
|
+
//@ts-ignore
|
|
14
|
+
import { createRequire } from "node:module";
|
|
15
|
+
//@ts-ignore
|
|
16
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
17
|
+
//@ts-ignore
|
|
18
|
+
import { dirname } from "node:path";
|
|
19
|
+
const defineGlobalPonyfill = (symbolFor, fn) => {
|
|
20
|
+
if (!Reflect.has(globalThis, Symbol.for(symbolFor))) {
|
|
21
|
+
Object.defineProperty(globalThis, Symbol.for(symbolFor), {
|
|
22
|
+
configurable: true,
|
|
23
|
+
get() {
|
|
24
|
+
return fn;
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export let import_meta_ponyfill_commonjs = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-commonjs")) ??
|
|
30
|
+
(() => {
|
|
31
|
+
const moduleImportMetaWM = new WeakMap();
|
|
32
|
+
return (require, module) => {
|
|
33
|
+
let importMetaCache = moduleImportMetaWM.get(module);
|
|
34
|
+
if (importMetaCache == null) {
|
|
35
|
+
const importMeta = Object.assign(Object.create(null), {
|
|
36
|
+
url: pathToFileURL(module.filename).href,
|
|
37
|
+
main: require.main == module,
|
|
38
|
+
resolve: (specifier, parentURL = importMeta.url) => {
|
|
39
|
+
return pathToFileURL((importMeta.url === parentURL
|
|
40
|
+
? require
|
|
41
|
+
: createRequire(parentURL))
|
|
42
|
+
.resolve(specifier)).href;
|
|
43
|
+
},
|
|
44
|
+
filename: module.filename,
|
|
45
|
+
dirname: module.path,
|
|
46
|
+
});
|
|
47
|
+
moduleImportMetaWM.set(module, importMeta);
|
|
48
|
+
importMetaCache = importMeta;
|
|
49
|
+
}
|
|
50
|
+
return importMetaCache;
|
|
51
|
+
};
|
|
52
|
+
})());
|
|
53
|
+
defineGlobalPonyfill("import-meta-ponyfill-commonjs", import_meta_ponyfill_commonjs);
|
|
54
|
+
export let import_meta_ponyfill_esmodule = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-esmodule")) ??
|
|
55
|
+
((importMeta) => {
|
|
56
|
+
const resolveFunStr = String(importMeta.resolve);
|
|
57
|
+
const shimWs = new WeakSet();
|
|
58
|
+
//@ts-ignore
|
|
59
|
+
const mainUrl = ("file:///" + process.argv[1].replace(/\\/g, "/"))
|
|
60
|
+
.replace(/\/{3,}/, "///");
|
|
61
|
+
const commonShim = (importMeta) => {
|
|
62
|
+
if (typeof importMeta.main !== "boolean") {
|
|
63
|
+
importMeta.main = importMeta.url === mainUrl;
|
|
64
|
+
}
|
|
65
|
+
if (typeof importMeta.filename !== "string") {
|
|
66
|
+
importMeta.filename = fileURLToPath(importMeta.url);
|
|
67
|
+
importMeta.dirname = dirname(importMeta.filename);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
if (
|
|
71
|
+
// v16.2.0+, v14.18.0+: Add support for WHATWG URL object to parentURL parameter.
|
|
72
|
+
resolveFunStr === "undefined" ||
|
|
73
|
+
// v20.0.0+, v18.19.0+"" This API now returns a string synchronously instead of a Promise.
|
|
74
|
+
resolveFunStr.startsWith("async")
|
|
75
|
+
// enable by --experimental-import-meta-resolve flag
|
|
76
|
+
) {
|
|
77
|
+
import_meta_ponyfill_esmodule = (importMeta) => {
|
|
78
|
+
if (!shimWs.has(importMeta)) {
|
|
79
|
+
shimWs.add(importMeta);
|
|
80
|
+
const importMetaUrlRequire = {
|
|
81
|
+
url: importMeta.url,
|
|
82
|
+
require: createRequire(importMeta.url),
|
|
83
|
+
};
|
|
84
|
+
importMeta.resolve = function resolve(specifier, parentURL = importMeta.url) {
|
|
85
|
+
return pathToFileURL((importMetaUrlRequire.url === parentURL
|
|
86
|
+
? importMetaUrlRequire.require
|
|
87
|
+
: createRequire(parentURL)).resolve(specifier)).href;
|
|
88
|
+
};
|
|
89
|
+
commonShim(importMeta);
|
|
90
|
+
}
|
|
91
|
+
return importMeta;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
/// native support
|
|
96
|
+
import_meta_ponyfill_esmodule = (importMeta) => {
|
|
97
|
+
if (!shimWs.has(importMeta)) {
|
|
98
|
+
shimWs.add(importMeta);
|
|
99
|
+
commonShim(importMeta);
|
|
100
|
+
}
|
|
101
|
+
return importMeta;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return import_meta_ponyfill_esmodule(importMeta);
|
|
105
|
+
}));
|
|
106
|
+
defineGlobalPonyfill("import-meta-ponyfill-esmodule", import_meta_ponyfill_esmodule);
|
|
107
|
+
export let import_meta_ponyfill = ((...args) => {
|
|
108
|
+
const _MODULE = (() => {
|
|
109
|
+
if (typeof require === "function" && typeof module === "object") {
|
|
110
|
+
return "commonjs";
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// eval("typeof import.meta");
|
|
114
|
+
return "esmodule";
|
|
115
|
+
}
|
|
116
|
+
})();
|
|
117
|
+
if (_MODULE === "commonjs") {
|
|
118
|
+
//@ts-ignore
|
|
119
|
+
import_meta_ponyfill = (r, m) => import_meta_ponyfill_commonjs(r, m);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
//@ts-ignore
|
|
123
|
+
import_meta_ponyfill = (im) => import_meta_ponyfill_esmodule(im);
|
|
124
|
+
}
|
|
125
|
+
//@ts-ignore
|
|
126
|
+
return import_meta_ponyfill(...args);
|
|
127
|
+
});
|
|
128
|
+
// From https://github.com/es-shims/array-from-async/blob/4a5ff83947b861f35b380d5d4f20da2f07698638/index.mjs
|
|
129
|
+
// Tried to have dnt depend on the package instead, but it distributes as an
|
|
130
|
+
// ES module, so doesn't work with CommonJS.
|
|
131
|
+
//
|
|
132
|
+
// Code below:
|
|
133
|
+
//
|
|
134
|
+
// Copyright 2021 J. S. Choi
|
|
135
|
+
//
|
|
136
|
+
// Redistribution and use in source and binary forms, with or without
|
|
137
|
+
// modification, are permitted provided that the following conditions
|
|
138
|
+
// are met:
|
|
139
|
+
//
|
|
140
|
+
// 1. Redistributions of source code must retain the above copyright
|
|
141
|
+
// notice, this list of conditions and the following disclaimer.
|
|
142
|
+
//
|
|
143
|
+
// 2. Redistributions in binary form must reproduce the above copyright
|
|
144
|
+
// notice, this list of conditions and the following disclaimer in the
|
|
145
|
+
// documentation and/or other materials provided with the distribution.
|
|
146
|
+
//
|
|
147
|
+
// 3. Neither the name of the copyright holder nor the names of its
|
|
148
|
+
// contributors may be used to endorse or promote products derived from
|
|
149
|
+
// this software without specific prior written permission.
|
|
150
|
+
//
|
|
151
|
+
// **This software is provided by the copyright holders and contributors
|
|
152
|
+
// "as is" and any express or implied warranties, including, but not
|
|
153
|
+
// limited to, the implied warranties of merchantability and fitness for a
|
|
154
|
+
// particular purpose are disclaimed. In no event shall the copyright
|
|
155
|
+
// holder or contributors be liable for any direct, indirect, incidental,
|
|
156
|
+
// special, exemplary, or consequential damages (including, but not limited
|
|
157
|
+
// to, procurement of substitute goods or services; loss of use, data, or
|
|
158
|
+
// profits; or business interruption) however caused and on any theory of
|
|
159
|
+
// liability, whether in contract, strict liability, or tort (including
|
|
160
|
+
// negligence or otherwise) arising in any way out of the use of this
|
|
161
|
+
// software, even if advised of the possibility of such damage.**
|
|
162
|
+
const { MAX_SAFE_INTEGER } = Number;
|
|
163
|
+
const iteratorSymbol = Symbol.iterator;
|
|
164
|
+
const asyncIteratorSymbol = Symbol.asyncIterator;
|
|
165
|
+
const IntrinsicArray = Array;
|
|
166
|
+
const tooLongErrorMessage = 'Input is too long and exceeded Number.MAX_SAFE_INTEGER times.';
|
|
167
|
+
function isConstructor(obj) {
|
|
168
|
+
if (obj != null) {
|
|
169
|
+
const prox = new Proxy(obj, {
|
|
170
|
+
construct() {
|
|
171
|
+
return prox;
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
try {
|
|
175
|
+
new prox;
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
async function fromAsync(items, mapfn, thisArg) {
|
|
187
|
+
const itemsAreIterable = (asyncIteratorSymbol in items ||
|
|
188
|
+
iteratorSymbol in items);
|
|
189
|
+
if (itemsAreIterable) {
|
|
190
|
+
const result = isConstructor(this)
|
|
191
|
+
? new this
|
|
192
|
+
: IntrinsicArray(0);
|
|
193
|
+
let i = 0;
|
|
194
|
+
for await (const v of items) {
|
|
195
|
+
if (i > MAX_SAFE_INTEGER) {
|
|
196
|
+
throw TypeError(tooLongErrorMessage);
|
|
197
|
+
}
|
|
198
|
+
else if (mapfn) {
|
|
199
|
+
result[i] = await mapfn.call(thisArg, v, i);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
result[i] = v;
|
|
203
|
+
}
|
|
204
|
+
i++;
|
|
205
|
+
}
|
|
206
|
+
result.length = i;
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
// In this case, the items are assumed to be an arraylike object with
|
|
211
|
+
// a length property and integer properties for each element.
|
|
212
|
+
const { length } = items;
|
|
213
|
+
const result = isConstructor(this)
|
|
214
|
+
? new this(length)
|
|
215
|
+
: IntrinsicArray(length);
|
|
216
|
+
let i = 0;
|
|
217
|
+
while (i < length) {
|
|
218
|
+
if (i > MAX_SAFE_INTEGER) {
|
|
219
|
+
throw TypeError(tooLongErrorMessage);
|
|
220
|
+
}
|
|
221
|
+
const v = await items[i];
|
|
222
|
+
if (mapfn) {
|
|
223
|
+
result[i] = await mapfn.call(thisArg, v, i);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
result[i] = v;
|
|
227
|
+
}
|
|
228
|
+
i++;
|
|
229
|
+
}
|
|
230
|
+
result.length = i;
|
|
231
|
+
return result;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (!Array.fromAsync) {
|
|
235
|
+
Array.fromAsync = fromAsync;
|
|
236
|
+
}
|
|
237
|
+
if (!Object.hasOwn) {
|
|
238
|
+
Object.defineProperty(Object, "hasOwn", {
|
|
239
|
+
value: function (object, property) {
|
|
240
|
+
if (object == null) {
|
|
241
|
+
throw new TypeError("Cannot convert undefined or null to object");
|
|
242
|
+
}
|
|
243
|
+
return Object.prototype.hasOwnProperty.call(Object(object), property);
|
|
244
|
+
},
|
|
245
|
+
configurable: true,
|
|
246
|
+
enumerable: false,
|
|
247
|
+
writable: true,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Deno } from "@deno/shim-deno";
|
|
2
|
+
export { Deno } from "@deno/shim-deno";
|
|
3
|
+
export { crypto, type Crypto, type SubtleCrypto, type AlgorithmIdentifier, type Algorithm, type RsaOaepParams, type BufferSource, type AesCtrParams, type AesCbcParams, type AesGcmParams, type CryptoKey, type KeyAlgorithm, type KeyType, type KeyUsage, type EcdhKeyDeriveParams, type HkdfParams, type HashAlgorithmIdentifier, type Pbkdf2Params, type AesDerivedKeyParams, type HmacImportParams, type JsonWebKey, type RsaOtherPrimesInfo, type KeyFormat, type RsaHashedKeyGenParams, type RsaKeyGenParams, type BigInteger, type EcKeyGenParams, type NamedCurve, type CryptoKeyPair, type AesKeyGenParams, type HmacKeyGenParams, type RsaHashedImportParams, type EcKeyImportParams, type AesKeyAlgorithm, type RsaPssParams, type EcdsaParams } from "@deno/shim-crypto";
|
|
4
|
+
import { setInterval, setTimeout } from "@deno/shim-timers";
|
|
5
|
+
export { setInterval, setTimeout } from "@deno/shim-timers";
|
|
6
|
+
export declare const dntGlobalThis: Omit<typeof globalThis, "setInterval" | "setTimeout" | "crypto" | "Deno"> & {
|
|
7
|
+
Deno: typeof Deno;
|
|
8
|
+
crypto: import("@deno/shim-crypto").Crypto;
|
|
9
|
+
setInterval: typeof setInterval;
|
|
10
|
+
setTimeout: typeof setTimeout;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=_dnt.shims.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,KAAK,UAAU,EAAE,KAAK,uBAAuB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,kBAAkB,EAAE,KAAK,SAAS,EAAE,KAAK,qBAAqB,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrvB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQ5D,eAAO,MAAM,aAAa;;;;;CAA2C,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Deno } from "@deno/shim-deno";
|
|
2
|
+
export { Deno } from "@deno/shim-deno";
|
|
3
|
+
import { crypto } from "@deno/shim-crypto";
|
|
4
|
+
export { crypto } from "@deno/shim-crypto";
|
|
5
|
+
import { setInterval, setTimeout } from "@deno/shim-timers";
|
|
6
|
+
export { setInterval, setTimeout } from "@deno/shim-timers";
|
|
7
|
+
const dntGlobals = {
|
|
8
|
+
Deno,
|
|
9
|
+
crypto,
|
|
10
|
+
setInterval,
|
|
11
|
+
setTimeout,
|
|
12
|
+
};
|
|
13
|
+
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
14
|
+
function createMergeProxy(baseObj, extObj) {
|
|
15
|
+
return new Proxy(baseObj, {
|
|
16
|
+
get(_target, prop, _receiver) {
|
|
17
|
+
if (prop in extObj) {
|
|
18
|
+
return extObj[prop];
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return baseObj[prop];
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
set(_target, prop, value) {
|
|
25
|
+
if (prop in extObj) {
|
|
26
|
+
delete extObj[prop];
|
|
27
|
+
}
|
|
28
|
+
baseObj[prop] = value;
|
|
29
|
+
return true;
|
|
30
|
+
},
|
|
31
|
+
deleteProperty(_target, prop) {
|
|
32
|
+
let success = false;
|
|
33
|
+
if (prop in extObj) {
|
|
34
|
+
delete extObj[prop];
|
|
35
|
+
success = true;
|
|
36
|
+
}
|
|
37
|
+
if (prop in baseObj) {
|
|
38
|
+
delete baseObj[prop];
|
|
39
|
+
success = true;
|
|
40
|
+
}
|
|
41
|
+
return success;
|
|
42
|
+
},
|
|
43
|
+
ownKeys(_target) {
|
|
44
|
+
const baseKeys = Reflect.ownKeys(baseObj);
|
|
45
|
+
const extKeys = Reflect.ownKeys(extObj);
|
|
46
|
+
const extKeysSet = new Set(extKeys);
|
|
47
|
+
return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
|
|
48
|
+
},
|
|
49
|
+
defineProperty(_target, prop, desc) {
|
|
50
|
+
if (prop in extObj) {
|
|
51
|
+
delete extObj[prop];
|
|
52
|
+
}
|
|
53
|
+
Reflect.defineProperty(baseObj, prop, desc);
|
|
54
|
+
return true;
|
|
55
|
+
},
|
|
56
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
57
|
+
if (prop in extObj) {
|
|
58
|
+
return Reflect.getOwnPropertyDescriptor(extObj, prop);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return Reflect.getOwnPropertyDescriptor(baseObj, prop);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
has(_target, prop) {
|
|
65
|
+
return prop in extObj || prop in baseObj;
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ext-document-kreuzberg: document text extraction for Veryfront.
|
|
3
|
+
*
|
|
4
|
+
* Provides the `DocumentExtractor` contract via kreuzberg. Deno extraction can
|
|
5
|
+
* run inside an isolated Worker so a hung WASM call does not block the server.
|
|
6
|
+
*
|
|
7
|
+
* @module extensions/ext-document-kreuzberg
|
|
8
|
+
*/
|
|
9
|
+
import "../../../_dnt.polyfills.js";
|
|
10
|
+
import type { ExtensionFactory } from "veryfront/extensions";
|
|
11
|
+
import type { DocumentExtractor, KreuzbergExtractor } from "veryfront/extensions/compat";
|
|
12
|
+
export declare class KreuzbergDocumentExtractor implements DocumentExtractor {
|
|
13
|
+
importKreuzberg(): Promise<KreuzbergExtractor>;
|
|
14
|
+
extractInWorker(buffer: ArrayBuffer, mimeType: string): Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
declare const extDocumentKreuzberg: ExtensionFactory;
|
|
17
|
+
export default extDocumentKreuzberg;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-document-kreuzberg/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,4BAA4B,CAAC;AAKpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAsDrG,qBAAa,0BAA2B,YAAW,iBAAiB;IAClE,eAAe,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAIxC,eAAe,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAW9E;AAED,QAAA,MAAM,oBAAoB,EAAE,gBAkB3B,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ext-document-kreuzberg: document text extraction for Veryfront.
|
|
3
|
+
*
|
|
4
|
+
* Provides the `DocumentExtractor` contract via kreuzberg. Deno extraction can
|
|
5
|
+
* run inside an isolated Worker so a hung WASM call does not block the server.
|
|
6
|
+
*
|
|
7
|
+
* @module extensions/ext-document-kreuzberg
|
|
8
|
+
*/
|
|
9
|
+
import "../../../_dnt.polyfills.js";
|
|
10
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
11
|
+
import { loadKreuzberg } from "./kreuzberg.js";
|
|
12
|
+
import { isDeno } from "./runtime.js";
|
|
13
|
+
/** Maximum time to wait for document text extraction before aborting. */
|
|
14
|
+
const EXTRACTION_TIMEOUT_MS = 30_000;
|
|
15
|
+
function extractInWorkerDeno(buffer, mimeType) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
// The worker ships as raw TypeScript in the compiled binary and from source
|
|
18
|
+
// (where `compile-binary.ts` force-includes it), but as transpiled JS in the
|
|
19
|
+
// npm package consumed via `deno run npm:veryfront`. Pick the sibling that
|
|
20
|
+
// matches whichever build is executing this module.
|
|
21
|
+
const workerFile = globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url.endsWith(".ts")
|
|
22
|
+
? "./upload-extraction-worker.ts"
|
|
23
|
+
: "./upload-extraction-worker.js";
|
|
24
|
+
const workerUrl = new URL(workerFile, globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url);
|
|
25
|
+
const worker = new Worker(workerUrl, { type: "module" });
|
|
26
|
+
const timer = dntShim.setTimeout(() => {
|
|
27
|
+
worker.terminate();
|
|
28
|
+
reject(new Error(`Text extraction timed out after ${EXTRACTION_TIMEOUT_MS / 1000}s. The file may be corrupted or unsupported`));
|
|
29
|
+
}, EXTRACTION_TIMEOUT_MS);
|
|
30
|
+
worker.onmessage = (event) => {
|
|
31
|
+
clearTimeout(timer);
|
|
32
|
+
worker.terminate();
|
|
33
|
+
const { content, error } = event.data;
|
|
34
|
+
if (error) {
|
|
35
|
+
reject(new Error(error));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
resolve(content ?? "");
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
worker.onerror = (event) => {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
worker.terminate();
|
|
44
|
+
reject(new Error(`Text extraction worker failed: ${event.message ?? "unknown"}`));
|
|
45
|
+
};
|
|
46
|
+
worker.postMessage({ buffer, mimeType }, [buffer]);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export class KreuzbergDocumentExtractor {
|
|
50
|
+
importKreuzberg() {
|
|
51
|
+
return loadKreuzberg();
|
|
52
|
+
}
|
|
53
|
+
async extractInWorker(buffer, mimeType) {
|
|
54
|
+
// Only a real Deno runtime gets the isolated Worker; Node/Bun extract
|
|
55
|
+
// in-process via @kreuzberg/node. See ./runtime.ts for why a bare `Deno`
|
|
56
|
+
// check is unreliable in the dnt npm build.
|
|
57
|
+
if (!isDeno) {
|
|
58
|
+
const { extractBytes } = await loadKreuzberg();
|
|
59
|
+
const result = await extractBytes(new Uint8Array(buffer), mimeType);
|
|
60
|
+
return result.content;
|
|
61
|
+
}
|
|
62
|
+
return extractInWorkerDeno(buffer, mimeType);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const extDocumentKreuzberg = () => {
|
|
66
|
+
const extractor = new KreuzbergDocumentExtractor();
|
|
67
|
+
return {
|
|
68
|
+
name: "ext-document-kreuzberg",
|
|
69
|
+
version: "0.1.0",
|
|
70
|
+
contracts: {
|
|
71
|
+
provides: ["DocumentExtractor"],
|
|
72
|
+
},
|
|
73
|
+
capabilities: [
|
|
74
|
+
{ type: "fs:read" },
|
|
75
|
+
],
|
|
76
|
+
setup(ctx) {
|
|
77
|
+
ctx.provide("DocumentExtractor", extractor);
|
|
78
|
+
ctx.logger.info("[ext-document-kreuzberg] document extraction registered");
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export default extDocumentKreuzberg;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kreuzberg.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-document-kreuzberg/src/kreuzberg.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAwBlF,wBAAsB,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC,CA2BjE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared kreuzberg loader for the ext-document-kreuzberg extension.
|
|
3
|
+
*
|
|
4
|
+
* Used by both `KreuzbergDocumentExtractor.importKreuzberg()` (direct calls
|
|
5
|
+
* from Node/Bun) and the extension's upload-extraction worker (Deno isolate).
|
|
6
|
+
* Centralising the loader keeps the compiled-binary WASM glue + pdfium
|
|
7
|
+
* pre-import dance in one place.
|
|
8
|
+
*
|
|
9
|
+
* @module extensions/ext-document-kreuzberg/kreuzberg
|
|
10
|
+
*/
|
|
11
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
12
|
+
import { isDeno } from "./runtime.js";
|
|
13
|
+
// deno-lint-ignore no-explicit-any
|
|
14
|
+
async function loadKreuzbergNode() {
|
|
15
|
+
try {
|
|
16
|
+
return await import("@kreuzberg/node");
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (!isMissingPackageError(error))
|
|
20
|
+
throw error;
|
|
21
|
+
throw new Error('Document extraction on Node requires the optional package "@kreuzberg/node". ' +
|
|
22
|
+
"Install @kreuzberg/node@^4.4.2 or disable document extraction.");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export async function loadKreuzberg() {
|
|
26
|
+
// Node/Bun load the native @kreuzberg/node; only a real Deno runtime uses the
|
|
27
|
+
// WASM build. See ./runtime.ts for why a bare `Deno` check is unreliable here.
|
|
28
|
+
if (!isDeno) {
|
|
29
|
+
return loadKreuzbergNode();
|
|
30
|
+
}
|
|
31
|
+
const mod = await importKreuzbergWasm();
|
|
32
|
+
const mainModule = typeof dntShim.Deno.mainModule === "string"
|
|
33
|
+
? dntShim.Deno.mainModule
|
|
34
|
+
: "";
|
|
35
|
+
const isDenoCompiled = mainModule !== "" && !mainModule.endsWith(".ts");
|
|
36
|
+
if (isDenoCompiled) {
|
|
37
|
+
await import("@kreuzberg/wasm/dist/pkg/kreuzberg_wasm.js");
|
|
38
|
+
try {
|
|
39
|
+
const kreuzbergUrl = globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).resolve("@kreuzberg/wasm");
|
|
40
|
+
const pdfiumUrl = new URL("./pdfium.js", kreuzbergUrl).href;
|
|
41
|
+
await import(pdfiumUrl);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Non-fatal: PDF extraction may be degraded but other formats work.
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
await mod.initWasm?.();
|
|
48
|
+
return mod;
|
|
49
|
+
}
|
|
50
|
+
async function importKreuzbergWasm() {
|
|
51
|
+
try {
|
|
52
|
+
return await import("@kreuzberg/wasm");
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (!isMissingPackageError(error))
|
|
56
|
+
throw error;
|
|
57
|
+
throw new Error('Document extraction on Deno requires the optional package "@kreuzberg/wasm". ' +
|
|
58
|
+
"Install @kreuzberg/wasm@4.5.2 or disable document extraction.");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function isMissingPackageError(error) {
|
|
62
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
63
|
+
return message.includes("Cannot find package") ||
|
|
64
|
+
message.includes("Cannot find module") ||
|
|
65
|
+
message.includes("ERR_MODULE_NOT_FOUND") ||
|
|
66
|
+
message.includes("Module not found");
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-document-kreuzberg/src/runtime.ts"],"names":[],"mappings":"AAoCA,uEAAuE;AACvE,eAAO,MAAM,MAAM,EAAE,OAA+D,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime detection — inlined from src/platform/compat/runtime.ts so the
|
|
3
|
+
* extension stays dependency-free on core (mirrors ext-bundler-esbuild).
|
|
4
|
+
*
|
|
5
|
+
* The Node check is what makes this correct in the dnt npm build: dnt's
|
|
6
|
+
* `@deno/shim-deno` polyfill makes a bare `Deno` reference truthy on Node/Bun,
|
|
7
|
+
* but `hasNodeProcess()` short-circuits `isDeno` to false there regardless.
|
|
8
|
+
*
|
|
9
|
+
* @module extensions/ext-document-kreuzberg/runtime
|
|
10
|
+
*/
|
|
11
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
12
|
+
function hasRealDeno() {
|
|
13
|
+
return (typeof dntShim.Deno !== "undefined" &&
|
|
14
|
+
typeof dntShim.Deno.version === "object" &&
|
|
15
|
+
typeof dntShim.Deno.build === "object" &&
|
|
16
|
+
typeof dntShim.Deno.build.os === "string");
|
|
17
|
+
}
|
|
18
|
+
function hasBunGlobal() {
|
|
19
|
+
return dntShim.dntGlobalThis.Bun != null;
|
|
20
|
+
}
|
|
21
|
+
function hasNodeProcess() {
|
|
22
|
+
const g = dntShim.dntGlobalThis;
|
|
23
|
+
return g.process?.versions?.node != null && !g.process?.versions?.deno;
|
|
24
|
+
}
|
|
25
|
+
/** True only in a real Deno runtime — not the dnt shim on Node/Bun. */
|
|
26
|
+
export const isDeno = !hasNodeProcess() && !hasBunGlobal() && hasRealDeno();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { loadKreuzberg } from "./kreuzberg.js";
|
|
2
|
+
self.onmessage = async (event) => {
|
|
3
|
+
if (event.origin && event.origin !== self.location.origin) {
|
|
4
|
+
self.postMessage(
|
|
5
|
+
{
|
|
6
|
+
error: "Rejected document extraction request from invalid origin"
|
|
7
|
+
}
|
|
8
|
+
);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const { buffer, mimeType } = event.data;
|
|
13
|
+
const { extractBytes } = await loadKreuzberg();
|
|
14
|
+
const result = await extractBytes(new Uint8Array(buffer), mimeType);
|
|
15
|
+
self.postMessage({ content: result.content });
|
|
16
|
+
} catch (err) {
|
|
17
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
18
|
+
self.postMessage({ error: message });
|
|
19
|
+
}
|
|
20
|
+
};
|
package/esm/package.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@veryfront/ext-document-kreuzberg",
|
|
3
|
+
"version": "0.1.985",
|
|
4
|
+
"description": "Veryfront first-party extension package for ext-document-kreuzberg",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"veryfront",
|
|
7
|
+
"extension",
|
|
8
|
+
"ext-document-kreuzberg"
|
|
9
|
+
],
|
|
10
|
+
"author": "Veryfront",
|
|
11
|
+
"homepage": "https://github.com/veryfront/veryfront-code/tree/main/extensions/ext-document-kreuzberg",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/veryfront/veryfront-code.git",
|
|
15
|
+
"directory": "extensions/ext-document-kreuzberg"
|
|
16
|
+
},
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/veryfront/veryfront-code/issues"
|
|
20
|
+
},
|
|
21
|
+
"module": "./esm/extensions/ext-document-kreuzberg/src/index.js",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./esm/extensions/ext-document-kreuzberg/src/index.js",
|
|
25
|
+
"types": "./esm/extensions/ext-document-kreuzberg/src/index.d.ts"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"scripts": {},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18.0.0"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"veryfront": {
|
|
36
|
+
"extension": true,
|
|
37
|
+
"contracts": {
|
|
38
|
+
"provides": [
|
|
39
|
+
"DocumentExtractor"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"capabilities": [
|
|
43
|
+
{
|
|
44
|
+
"type": "fs:read"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@deno/shim-deno": "~0.18.0",
|
|
50
|
+
"@deno/shim-crypto": "~0.3.1",
|
|
51
|
+
"@deno/shim-timers": "~0.1.0",
|
|
52
|
+
"@kreuzberg/node": "4.4.2",
|
|
53
|
+
"@kreuzberg/wasm": "4.5.2"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"veryfront": "^0.1.985"
|
|
57
|
+
},
|
|
58
|
+
"type": "module",
|
|
59
|
+
"types": "./esm/extensions/ext-document-kreuzberg/src/index.d.ts",
|
|
60
|
+
"files": [
|
|
61
|
+
"esm",
|
|
62
|
+
"LICENSE",
|
|
63
|
+
"NOTICE",
|
|
64
|
+
"README.md"
|
|
65
|
+
]
|
|
66
|
+
}
|