veryfront 0.1.984 → 0.1.986
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 +16 -4
- package/NOTICE +2 -0
- package/esm/cli/commands/build/command.js +1 -1
- package/esm/cli/commands/build/handler.d.ts.map +1 -1
- package/esm/cli/commands/build/handler.js +3 -1
- package/esm/cli/commands/dev/handler.d.ts.map +1 -1
- package/esm/cli/commands/dev/handler.js +3 -1
- package/esm/cli/commands/knowledge/parser.d.ts.map +1 -1
- package/esm/cli/commands/knowledge/parser.js +2 -1
- package/esm/cli/commands/serve/handler.d.ts.map +1 -1
- package/esm/cli/commands/serve/handler.js +3 -1
- package/esm/cli/commands/start/handler.d.ts.map +1 -1
- package/esm/cli/commands/start/handler.js +3 -1
- package/esm/cli/main.js +0 -17
- package/esm/cli/router.d.ts.map +1 -1
- package/esm/cli/router.js +67 -98
- package/esm/cli/shared/default-contracts.d.ts +3 -0
- package/esm/cli/shared/default-contracts.d.ts.map +1 -0
- package/esm/cli/shared/default-contracts.js +19 -0
- package/esm/cli/shared/ensure-content-processor.d.ts +9 -1
- package/esm/cli/shared/ensure-content-processor.d.ts.map +1 -1
- package/esm/cli/shared/ensure-content-processor.js +23 -2
- package/esm/cli/shared/server-startup.d.ts.map +1 -1
- package/esm/cli/shared/server-startup.js +7 -4
- package/esm/deno.d.ts +3 -0
- package/esm/deno.js +5 -2
- package/esm/src/agent/hosted/veryfront-cloud-agent-service.d.ts.map +1 -1
- package/esm/src/agent/hosted/veryfront-cloud-agent-service.js +7 -5
- package/esm/src/agent/service/auth.d.ts.map +1 -1
- package/esm/src/agent/service/auth.js +2 -2
- package/esm/src/extensions/builtin-extensions.d.ts +9 -1
- package/esm/src/extensions/builtin-extensions.d.ts.map +1 -1
- package/esm/src/extensions/builtin-extensions.js +138 -54
- package/esm/src/extensions/first-party-import.d.ts +25 -0
- package/esm/src/extensions/first-party-import.d.ts.map +1 -0
- package/esm/src/extensions/first-party-import.js +120 -0
- package/esm/src/html/styles-builder/tailwind-compiler-cache.d.ts.map +1 -1
- package/esm/src/html/styles-builder/tailwind-compiler-cache.js +2 -1
- package/esm/src/internal-agents/run-stream.d.ts.map +1 -1
- package/esm/src/internal-agents/run-stream.js +2 -1
- package/esm/src/provider/local/local-engine.d.ts.map +1 -1
- package/esm/src/provider/local/local-engine.js +7 -4
- package/esm/src/provider/types.d.ts +1 -0
- package/esm/src/provider/types.d.ts.map +1 -1
- package/esm/src/provider/types.js +1 -1
- package/esm/src/proxy/main.js +4 -1
- package/esm/src/testing/init.js +18 -4
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +18 -94
- package/esm/extensions/ext-auth-jwt/src/index.d.ts +0 -39
- package/esm/extensions/ext-auth-jwt/src/index.d.ts.map +0 -1
- package/esm/extensions/ext-auth-jwt/src/index.js +0 -123
- package/esm/extensions/ext-bundler-esbuild/src/binary.d.ts +0 -7
- package/esm/extensions/ext-bundler-esbuild/src/binary.d.ts.map +0 -1
- package/esm/extensions/ext-bundler-esbuild/src/binary.js +0 -143
- package/esm/extensions/ext-bundler-esbuild/src/es-module-lexer.d.ts +0 -17
- package/esm/extensions/ext-bundler-esbuild/src/es-module-lexer.d.ts.map +0 -1
- package/esm/extensions/ext-bundler-esbuild/src/es-module-lexer.js +0 -29
- package/esm/extensions/ext-bundler-esbuild/src/esbuild-bundler.d.ts +0 -20
- package/esm/extensions/ext-bundler-esbuild/src/esbuild-bundler.d.ts.map +0 -1
- package/esm/extensions/ext-bundler-esbuild/src/esbuild-bundler.js +0 -98
- package/esm/extensions/ext-bundler-esbuild/src/index.d.ts +0 -19
- package/esm/extensions/ext-bundler-esbuild/src/index.d.ts.map +0 -1
- package/esm/extensions/ext-bundler-esbuild/src/index.js +0 -40
- package/esm/extensions/ext-bundler-esbuild/src/plugin-adapter.d.ts +0 -14
- package/esm/extensions/ext-bundler-esbuild/src/plugin-adapter.d.ts.map +0 -1
- package/esm/extensions/ext-bundler-esbuild/src/plugin-adapter.js +0 -55
- package/esm/extensions/ext-bundler-esbuild/src/runtime.d.ts +0 -4
- package/esm/extensions/ext-bundler-esbuild/src/runtime.d.ts.map +0 -1
- package/esm/extensions/ext-bundler-esbuild/src/runtime.js +0 -43
- package/esm/extensions/ext-content-mdx/src/compiler/markdown-compile.d.ts +0 -3
- package/esm/extensions/ext-content-mdx/src/compiler/markdown-compile.d.ts.map +0 -1
- package/esm/extensions/ext-content-mdx/src/compiler/markdown-compile.js +0 -99
- package/esm/extensions/ext-content-mdx/src/compiler/mdx-compile.d.ts +0 -3
- package/esm/extensions/ext-content-mdx/src/compiler/mdx-compile.d.ts.map +0 -1
- package/esm/extensions/ext-content-mdx/src/compiler/mdx-compile.js +0 -53
- package/esm/extensions/ext-content-mdx/src/index.d.ts +0 -30
- package/esm/extensions/ext-content-mdx/src/index.d.ts.map +0 -1
- package/esm/extensions/ext-content-mdx/src/index.js +0 -55
- package/esm/extensions/ext-content-mdx/src/plugins/plugin-loader.d.ts +0 -4
- package/esm/extensions/ext-content-mdx/src/plugins/plugin-loader.d.ts.map +0 -1
- package/esm/extensions/ext-content-mdx/src/plugins/plugin-loader.js +0 -18
- package/esm/extensions/ext-content-mdx/src/plugins/rehype-node-positions.d.ts +0 -20
- package/esm/extensions/ext-content-mdx/src/plugins/rehype-node-positions.d.ts.map +0 -1
- package/esm/extensions/ext-content-mdx/src/plugins/rehype-node-positions.js +0 -45
- package/esm/extensions/ext-content-mdx/src/plugins/remark-headings.d.ts +0 -4
- package/esm/extensions/ext-content-mdx/src/plugins/remark-headings.d.ts.map +0 -1
- package/esm/extensions/ext-content-mdx/src/plugins/remark-headings.js +0 -69
- package/esm/extensions/ext-content-mdx/src/plugins/remark-mdx-utils.d.ts +0 -14
- package/esm/extensions/ext-content-mdx/src/plugins/remark-mdx-utils.d.ts.map +0 -1
- package/esm/extensions/ext-content-mdx/src/plugins/remark-mdx-utils.js +0 -191
- package/esm/extensions/ext-css-tailwind/src/index.d.ts +0 -9
- package/esm/extensions/ext-css-tailwind/src/index.d.ts.map +0 -1
- package/esm/extensions/ext-css-tailwind/src/index.js +0 -71
- package/esm/extensions/ext-db-sqlite/src/index.d.ts +0 -15
- package/esm/extensions/ext-db-sqlite/src/index.d.ts.map +0 -1
- package/esm/extensions/ext-db-sqlite/src/index.js +0 -38
- package/esm/extensions/ext-document-kreuzberg/src/index.d.ts +0 -9
- package/esm/extensions/ext-document-kreuzberg/src/index.d.ts.map +0 -1
- package/esm/extensions/ext-document-kreuzberg/src/index.js +0 -81
- package/esm/extensions/ext-document-kreuzberg/src/kreuzberg.d.ts +0 -3
- package/esm/extensions/ext-document-kreuzberg/src/kreuzberg.d.ts.map +0 -1
- package/esm/extensions/ext-document-kreuzberg/src/kreuzberg.js +0 -67
- package/esm/extensions/ext-document-kreuzberg/src/runtime.d.ts +0 -3
- package/esm/extensions/ext-document-kreuzberg/src/runtime.d.ts.map +0 -1
- package/esm/extensions/ext-document-kreuzberg/src/runtime.js +0 -26
- package/esm/extensions/ext-document-kreuzberg/src/upload-extraction-worker.js +0 -20
- package/esm/extensions/ext-observability-opentelemetry/src/index.d.ts +0 -56
- package/esm/extensions/ext-observability-opentelemetry/src/index.d.ts.map +0 -1
- package/esm/extensions/ext-observability-opentelemetry/src/index.js +0 -338
- package/esm/extensions/ext-parser-babel/src/index.d.ts +0 -27
- package/esm/extensions/ext-parser-babel/src/index.d.ts.map +0 -1
- package/esm/extensions/ext-parser-babel/src/index.js +0 -82
- package/esm/extensions/ext-parser-babel/src/inject-node-positions.d.ts +0 -16
- package/esm/extensions/ext-parser-babel/src/inject-node-positions.d.ts.map +0 -1
- package/esm/extensions/ext-parser-babel/src/inject-node-positions.js +0 -129
- package/esm/extensions/ext-sandbox-shell-tools/src/index.d.ts +0 -16
- package/esm/extensions/ext-sandbox-shell-tools/src/index.d.ts.map +0 -1
- package/esm/extensions/ext-sandbox-shell-tools/src/index.js +0 -29
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remark-headings.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/ext-content-mdx/src/plugins/remark-headings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AA0BnC,wBAAgB,iBAAiB,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,KAAK,IAAI,CA8DrE"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import GithubSlugger from "github-slugger";
|
|
2
|
-
import { toString } from "mdast-util-to-string";
|
|
3
|
-
import { visit } from "unist-util-visit";
|
|
4
|
-
function createHeadingProperty(name, value) {
|
|
5
|
-
return {
|
|
6
|
-
type: "Property",
|
|
7
|
-
key: { type: "Identifier", name },
|
|
8
|
-
value: { type: "Literal", value },
|
|
9
|
-
kind: "init",
|
|
10
|
-
method: false,
|
|
11
|
-
shorthand: false,
|
|
12
|
-
computed: false,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export function remarkMdxHeadings() {
|
|
16
|
-
const slugger = new GithubSlugger();
|
|
17
|
-
return (tree, file) => {
|
|
18
|
-
const headings = [];
|
|
19
|
-
slugger.reset();
|
|
20
|
-
visit(tree, "heading", (node) => {
|
|
21
|
-
const text = toString(node);
|
|
22
|
-
const id = slugger.slug(text);
|
|
23
|
-
node.data ??= {};
|
|
24
|
-
node.data.hProperties ??= {};
|
|
25
|
-
node.data.hProperties.id = id;
|
|
26
|
-
headings.push({ text, id, level: node.depth });
|
|
27
|
-
});
|
|
28
|
-
file.data.headings = headings;
|
|
29
|
-
const headingsExport = {
|
|
30
|
-
type: "mdxjsEsm",
|
|
31
|
-
value: "",
|
|
32
|
-
data: {
|
|
33
|
-
estree: {
|
|
34
|
-
type: "Program",
|
|
35
|
-
sourceType: "module",
|
|
36
|
-
body: [
|
|
37
|
-
{
|
|
38
|
-
type: "ExportNamedDeclaration",
|
|
39
|
-
specifiers: [],
|
|
40
|
-
source: null,
|
|
41
|
-
declaration: {
|
|
42
|
-
type: "VariableDeclaration",
|
|
43
|
-
kind: "const",
|
|
44
|
-
declarations: [
|
|
45
|
-
{
|
|
46
|
-
type: "VariableDeclarator",
|
|
47
|
-
id: { type: "Identifier", name: "headings" },
|
|
48
|
-
init: {
|
|
49
|
-
type: "ArrayExpression",
|
|
50
|
-
elements: headings.map((h) => ({
|
|
51
|
-
type: "ObjectExpression",
|
|
52
|
-
properties: [
|
|
53
|
-
createHeadingProperty("text", h.text),
|
|
54
|
-
createHeadingProperty("id", h.id),
|
|
55
|
-
createHeadingProperty("level", h.level),
|
|
56
|
-
],
|
|
57
|
-
})),
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
tree.children.unshift(headingsExport);
|
|
68
|
-
};
|
|
69
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Root } from "@types/mdast";
|
|
2
|
-
import type { VFile } from "vfile";
|
|
3
|
-
/**
|
|
4
|
-
* Removes unnecessary <p> elements from MDX content.
|
|
5
|
-
*
|
|
6
|
-
* Handles edge cases where <p> elements get incorrectly nested inside JSX components:
|
|
7
|
-
* - `<Button><p>text</p></Button>` → `<Button>text</Button>`
|
|
8
|
-
* - Inline parents: `<span><p>text</p></span>` → `<span>text</span>`
|
|
9
|
-
* - Multiple children with mixed content
|
|
10
|
-
*/
|
|
11
|
-
export declare function remarkMdxRemoveParagraphs(): (tree: Root) => void;
|
|
12
|
-
export declare function remarkCodeBlocks(): (tree: Root) => void;
|
|
13
|
-
export declare function remarkMdxImports(): (tree: Root, file: VFile) => void;
|
|
14
|
-
//# sourceMappingURL=remark-mdx-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remark-mdx-utils.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/ext-content-mdx/src/plugins/remark-mdx-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,IAAI,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAoGnC;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,IAAI,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CA6EhE;AAYD,wBAAgB,gBAAgB,IAAI,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAmBvD;AAQD,wBAAgB,gBAAgB,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,KAAK,IAAI,CAmBpE"}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { CONTINUE, SKIP, visit } from "unist-util-visit";
|
|
2
|
-
/**
|
|
3
|
-
* Spacer node to preserve whitespace when unwrapping paragraphs
|
|
4
|
-
*/
|
|
5
|
-
const spacer = {
|
|
6
|
-
type: "mdxFlowExpression",
|
|
7
|
-
value: "' '",
|
|
8
|
-
data: {
|
|
9
|
-
estree: {
|
|
10
|
-
type: "Program",
|
|
11
|
-
body: [
|
|
12
|
-
{
|
|
13
|
-
type: "ExpressionStatement",
|
|
14
|
-
expression: {
|
|
15
|
-
type: "Literal",
|
|
16
|
-
value: " ",
|
|
17
|
-
raw: "' '",
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
sourceType: "module",
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
// Replace node at index with multiple children nodes
|
|
26
|
-
// Reference: https://github.com/mdx-js/mdx/issues/1451#issuecomment-780428572
|
|
27
|
-
function mergeChildren(node, index, children) {
|
|
28
|
-
node.children?.splice(index, 1, ...children);
|
|
29
|
-
}
|
|
30
|
-
const textNodeTypes = new Set([
|
|
31
|
-
"text",
|
|
32
|
-
"paragraph",
|
|
33
|
-
"heading",
|
|
34
|
-
"link",
|
|
35
|
-
"image",
|
|
36
|
-
"list",
|
|
37
|
-
"listItem",
|
|
38
|
-
"emphasis",
|
|
39
|
-
"strong",
|
|
40
|
-
"blockquote",
|
|
41
|
-
"code",
|
|
42
|
-
"inlineCode",
|
|
43
|
-
"thematicBreak",
|
|
44
|
-
"table",
|
|
45
|
-
"tableRow",
|
|
46
|
-
"tableCell",
|
|
47
|
-
"footnote",
|
|
48
|
-
"footnoteDefinition",
|
|
49
|
-
]);
|
|
50
|
-
const validParentBlockElements = new Set([
|
|
51
|
-
"address",
|
|
52
|
-
"article",
|
|
53
|
-
"aside",
|
|
54
|
-
"blockquote",
|
|
55
|
-
"details",
|
|
56
|
-
"dialog",
|
|
57
|
-
"canvas",
|
|
58
|
-
"dl",
|
|
59
|
-
"dt",
|
|
60
|
-
"dd",
|
|
61
|
-
"div",
|
|
62
|
-
"fieldset",
|
|
63
|
-
"figcaption",
|
|
64
|
-
"figure",
|
|
65
|
-
"footer",
|
|
66
|
-
"form",
|
|
67
|
-
"header",
|
|
68
|
-
"hgroup",
|
|
69
|
-
"main",
|
|
70
|
-
"nav",
|
|
71
|
-
"pre",
|
|
72
|
-
"section",
|
|
73
|
-
"video",
|
|
74
|
-
]);
|
|
75
|
-
function isJsxComponentName(name = "") {
|
|
76
|
-
// Check if name starts with a capital letter (JSX component, not HTML element)
|
|
77
|
-
return name.match(/^[A-Z]/);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Removes unnecessary <p> elements from MDX content.
|
|
81
|
-
*
|
|
82
|
-
* Handles edge cases where <p> elements get incorrectly nested inside JSX components:
|
|
83
|
-
* - `<Button><p>text</p></Button>` → `<Button>text</Button>`
|
|
84
|
-
* - Inline parents: `<span><p>text</p></span>` → `<span>text</span>`
|
|
85
|
-
* - Multiple children with mixed content
|
|
86
|
-
*/
|
|
87
|
-
export function remarkMdxRemoveParagraphs() {
|
|
88
|
-
return function transformer(tree) {
|
|
89
|
-
// First pass: add spacers between elements when parent has non-text children
|
|
90
|
-
visit(tree, "paragraph", (_node, _index, parent) => {
|
|
91
|
-
const extParent = parent;
|
|
92
|
-
if (!extParent)
|
|
93
|
-
return CONTINUE;
|
|
94
|
-
const parentName = extParent.name ?? extParent.type ?? extParent.tagName;
|
|
95
|
-
if (parentName === "root")
|
|
96
|
-
return CONTINUE;
|
|
97
|
-
const hasNonTextChild = extParent.children?.some((child) => !textNodeTypes.has(child.type));
|
|
98
|
-
if (!hasNonTextChild)
|
|
99
|
-
return CONTINUE;
|
|
100
|
-
if (extParent.children.some((c) => c.isMdxTextSpacer))
|
|
101
|
-
return CONTINUE;
|
|
102
|
-
const children = [];
|
|
103
|
-
extParent.children.forEach((child, i) => {
|
|
104
|
-
if (i > 0) {
|
|
105
|
-
children.push({ ...spacer, isMdxTextSpacer: true });
|
|
106
|
-
}
|
|
107
|
-
children.push(child);
|
|
108
|
-
});
|
|
109
|
-
extParent.children = children;
|
|
110
|
-
return CONTINUE;
|
|
111
|
-
});
|
|
112
|
-
// Second pass: unwrap paragraphs
|
|
113
|
-
visit(tree, "paragraph", (node, index, parent) => {
|
|
114
|
-
const extParent = parent;
|
|
115
|
-
if (!extParent)
|
|
116
|
-
return CONTINUE;
|
|
117
|
-
const paragraphNode = node;
|
|
118
|
-
const parentName = extParent.name ?? extParent.type ?? extParent.tagName;
|
|
119
|
-
const idx = typeof index === "number" ? index : -1;
|
|
120
|
-
const previousChild = idx >= 0 ? extParent.children[idx - 1] : undefined;
|
|
121
|
-
// Unwrap <p> elements when they appear inside a direct <p> parent
|
|
122
|
-
if (parentName === "p" && idx >= 0) {
|
|
123
|
-
const child = paragraphNode.children?.[0];
|
|
124
|
-
if (child)
|
|
125
|
-
extParent.children[idx] = child;
|
|
126
|
-
return [SKIP, idx];
|
|
127
|
-
}
|
|
128
|
-
// Keep behavior consistent between children
|
|
129
|
-
if (previousChild?.type === "paragraph")
|
|
130
|
-
return CONTINUE;
|
|
131
|
-
if (parentName === "root")
|
|
132
|
-
return CONTINUE;
|
|
133
|
-
const hasNonTextChild = extParent.children.some((child) => !textNodeTypes.has(child.type));
|
|
134
|
-
if (hasNonTextChild && idx >= 0) {
|
|
135
|
-
// Unwrap <p> elements when child contains other children besides text
|
|
136
|
-
mergeChildren(extParent, idx, paragraphNode.children);
|
|
137
|
-
return [SKIP, idx];
|
|
138
|
-
}
|
|
139
|
-
// Unwrap <p> elements with single text child elements
|
|
140
|
-
// e.g. <Button><p>Do not wrap</p></Button> => <Button>Do not wrap</Button>
|
|
141
|
-
if (extParent.children.length === 1) {
|
|
142
|
-
extParent.children = paragraphNode.children;
|
|
143
|
-
return [SKIP, idx >= 0 ? idx : 0];
|
|
144
|
-
}
|
|
145
|
-
const isElementParent = !isJsxComponentName(parentName);
|
|
146
|
-
const isInlineParent = !validParentBlockElements.has(parentName ?? "");
|
|
147
|
-
// Unwrap <p> elements which are children of inline elements
|
|
148
|
-
// e.g. <span><p>Do not wrap</p></span> => <span>Do not wrap</span>
|
|
149
|
-
if (isElementParent && isInlineParent && idx >= 0) {
|
|
150
|
-
const child = paragraphNode.children?.[0];
|
|
151
|
-
if (child)
|
|
152
|
-
extParent.children[idx] = child;
|
|
153
|
-
}
|
|
154
|
-
return CONTINUE;
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
export function remarkCodeBlocks() {
|
|
159
|
-
return function transformer(tree) {
|
|
160
|
-
visit(tree, "code", (node) => {
|
|
161
|
-
const codeNode = node;
|
|
162
|
-
codeNode.data ??= {};
|
|
163
|
-
codeNode.data.hProperties ??= {};
|
|
164
|
-
if (codeNode.lang) {
|
|
165
|
-
codeNode.data.hProperties.className = [`language-${codeNode.lang}`];
|
|
166
|
-
}
|
|
167
|
-
if (!codeNode.meta)
|
|
168
|
-
return;
|
|
169
|
-
const highlightMatch = codeNode.meta.match(/\{([\d,-]+)\}/);
|
|
170
|
-
if (highlightMatch) {
|
|
171
|
-
codeNode.data.hProperties["data-line-numbers"] = highlightMatch[1];
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
export function remarkMdxImports() {
|
|
177
|
-
return function transformer(tree, file) {
|
|
178
|
-
const imports = [];
|
|
179
|
-
visit(tree, "mdxjsEsm", (node) => {
|
|
180
|
-
if (!node.value?.includes("import"))
|
|
181
|
-
return;
|
|
182
|
-
const importMatches = node.value.matchAll(/import\s+(?:(?:\{[^}]*\}|\*\s+as\s+\w+|\w+)\s+from\s+)?['"]([^'"]+)['"]/g);
|
|
183
|
-
for (const match of importMatches) {
|
|
184
|
-
const path = match[1];
|
|
185
|
-
if (typeof path === "string")
|
|
186
|
-
imports.push(path);
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
file.data.imports = imports;
|
|
190
|
-
};
|
|
191
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ExtensionFactory } from "../../../src/extensions/index.js";
|
|
2
|
-
import type { CSSCompileOptions, CSSCompiler, CSSProcessor } from "../../../src/extensions/css/index.js";
|
|
3
|
-
declare class TailwindCSSProcessor implements CSSProcessor {
|
|
4
|
-
compile(stylesheet: string, options: CSSCompileOptions): Promise<CSSCompiler>;
|
|
5
|
-
}
|
|
6
|
-
declare const extTailwind: ExtensionFactory;
|
|
7
|
-
export default extTailwind;
|
|
8
|
-
export { TailwindCSSProcessor };
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-css-tailwind/src/index.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAgBzG,cAAM,oBAAqB,YAAW,YAAY;IAC1C,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;CAgBpF;AAED,QAAA,MAAM,WAAW,EAAE,gBAsBlB,CAAC;AAEF,eAAe,WAAW,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ext-css-tailwind — CSSProcessor implementation backed by Tailwind CSS v4.
|
|
3
|
-
*
|
|
4
|
-
* Provides the `CSSProcessor` contract:
|
|
5
|
-
* - `compile(stylesheet, options)` — delegates to tailwindcss `compile()`
|
|
6
|
-
* and returns a compiler whose `build(candidates)` emits CSS for the
|
|
7
|
-
* class-name candidates discovered at render time.
|
|
8
|
-
*
|
|
9
|
-
* The extension also installs three `globalThis` shims on setup so that
|
|
10
|
-
* Tailwind plugin bundles loaded at runtime from esm.sh can bind their
|
|
11
|
-
* `tailwindcss/plugin`, `tailwindcss/defaultTheme`, and `tailwindcss/colors`
|
|
12
|
-
* imports to the same tailwindcss copy this extension ships. Core's
|
|
13
|
-
* `plugin-loader.ts` rewrites plugin bundle code to reference these shims
|
|
14
|
-
* by name; without the shims installed, dynamic plugin loading fails.
|
|
15
|
-
*
|
|
16
|
-
* @module extensions/ext-css-tailwind
|
|
17
|
-
*/
|
|
18
|
-
import * as dntShim from "../../../_dnt.shims.js";
|
|
19
|
-
import { compile } from "tailwindcss";
|
|
20
|
-
import plugin from "tailwindcss/plugin";
|
|
21
|
-
import defaultTheme from "tailwindcss/defaultTheme";
|
|
22
|
-
import colors from "tailwindcss/colors";
|
|
23
|
-
function installTailwindPluginShims() {
|
|
24
|
-
const g = dntShim.dntGlobalThis;
|
|
25
|
-
g.__tailwindPluginShim = { default: plugin, __esModule: true };
|
|
26
|
-
g.__tailwindDefaultThemeShim = { default: defaultTheme, __esModule: true };
|
|
27
|
-
g.__tailwindColorsShim = { default: colors, __esModule: true };
|
|
28
|
-
}
|
|
29
|
-
class TailwindCSSProcessor {
|
|
30
|
-
async compile(stylesheet, options) {
|
|
31
|
-
const native = await compile(stylesheet, {
|
|
32
|
-
base: options.base,
|
|
33
|
-
loadStylesheet: options.loadStylesheet,
|
|
34
|
-
loadModule: async (id) => {
|
|
35
|
-
const loaded = await options.loadModule(id);
|
|
36
|
-
// deno-lint-ignore no-explicit-any -- loaded plugin modules are opaque to the contract
|
|
37
|
-
return { module: loaded.module, base: loaded.base, path: loaded.path };
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
return {
|
|
41
|
-
build(candidates) {
|
|
42
|
-
return native.build(candidates);
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const extTailwind = () => {
|
|
48
|
-
const impl = new TailwindCSSProcessor();
|
|
49
|
-
return {
|
|
50
|
-
name: "ext-css-tailwind",
|
|
51
|
-
version: "0.1.0",
|
|
52
|
-
contracts: {
|
|
53
|
-
provides: ["CSSProcessor"],
|
|
54
|
-
},
|
|
55
|
-
capabilities: [
|
|
56
|
-
{ type: "net:outbound", hosts: ["esm.sh"] },
|
|
57
|
-
],
|
|
58
|
-
setup(ctx) {
|
|
59
|
-
installTailwindPluginShims();
|
|
60
|
-
ctx.provide("CSSProcessor", impl);
|
|
61
|
-
ctx.logger.info("[ext-css-tailwind] CSSProcessor registered");
|
|
62
|
-
},
|
|
63
|
-
teardown() {
|
|
64
|
-
// Shims stay installed — removing them could break in-flight plugin
|
|
65
|
-
// loads. The globalThis pollution is intentional and scoped to keys
|
|
66
|
-
// with `__tailwind` prefix.
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
export default extTailwind;
|
|
71
|
-
export { TailwindCSSProcessor };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ext-db-sqlite: SQLite-backed storage for Veryfront.
|
|
3
|
-
*
|
|
4
|
-
* Provides the `SqliteStore` contract via better-sqlite3.
|
|
5
|
-
*
|
|
6
|
-
* @module extensions/ext-db-sqlite
|
|
7
|
-
*/
|
|
8
|
-
import type { ExtensionFactory } from "../../../src/extensions/index.js";
|
|
9
|
-
import type { SqliteDatabase, SqliteStore } from "../../../src/extensions/compat/index.js";
|
|
10
|
-
export declare class BetterSqliteStore implements SqliteStore {
|
|
11
|
-
openSqliteDatabase(path?: string): Promise<SqliteDatabase>;
|
|
12
|
-
}
|
|
13
|
-
declare const extDbSqlite: ExtensionFactory;
|
|
14
|
-
export default extDbSqlite;
|
|
15
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-db-sqlite/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAU3F,qBAAa,iBAAkB,YAAW,WAAW;IACnD,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;CAG3D;AAED,QAAA,MAAM,WAAW,EAAE,gBAmBlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ext-db-sqlite: SQLite-backed storage for Veryfront.
|
|
3
|
-
*
|
|
4
|
-
* Provides the `SqliteStore` contract via better-sqlite3.
|
|
5
|
-
*
|
|
6
|
-
* @module extensions/ext-db-sqlite
|
|
7
|
-
*/
|
|
8
|
-
async function loadSqliteDatabase(path) {
|
|
9
|
-
const mod = await import("better-sqlite3");
|
|
10
|
-
// deno-lint-ignore no-explicit-any
|
|
11
|
-
const DatabaseCtor = mod.default ?? mod;
|
|
12
|
-
// deno-lint-ignore no-explicit-any
|
|
13
|
-
return new DatabaseCtor(path ?? ":memory:");
|
|
14
|
-
}
|
|
15
|
-
export class BetterSqliteStore {
|
|
16
|
-
openSqliteDatabase(path) {
|
|
17
|
-
return loadSqliteDatabase(path);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const extDbSqlite = () => {
|
|
21
|
-
const store = new BetterSqliteStore();
|
|
22
|
-
return {
|
|
23
|
-
name: "ext-db-sqlite",
|
|
24
|
-
version: "0.1.0",
|
|
25
|
-
contracts: {
|
|
26
|
-
provides: ["SqliteStore"],
|
|
27
|
-
},
|
|
28
|
-
capabilities: [
|
|
29
|
-
{ type: "fs:read" },
|
|
30
|
-
{ type: "fs:write" },
|
|
31
|
-
],
|
|
32
|
-
setup(ctx) {
|
|
33
|
-
ctx.provide("SqliteStore", store);
|
|
34
|
-
ctx.logger.info("[ext-db-sqlite] SQLite store registered");
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export default extDbSqlite;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ExtensionFactory } from "../../../src/extensions/index.js";
|
|
2
|
-
import type { DocumentExtractor, KreuzbergExtractor } from "../../../src/extensions/compat/index.js";
|
|
3
|
-
export declare class KreuzbergDocumentExtractor implements DocumentExtractor {
|
|
4
|
-
importKreuzberg(): Promise<KreuzbergExtractor>;
|
|
5
|
-
extractInWorker(buffer: ArrayBuffer, mimeType: string): Promise<string>;
|
|
6
|
-
}
|
|
7
|
-
declare const extDocumentKreuzberg: ExtensionFactory;
|
|
8
|
-
export default extDocumentKreuzberg;
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-document-kreuzberg/src/index.ts"],"names":[],"mappings":"AAWA,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"}
|
|
@@ -1,81 +0,0 @@
|
|
|
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 * as dntShim from "../../../_dnt.shims.js";
|
|
10
|
-
import { loadKreuzberg } from "./kreuzberg.js";
|
|
11
|
-
import { isDeno } from "./runtime.js";
|
|
12
|
-
/** Maximum time to wait for document text extraction before aborting. */
|
|
13
|
-
const EXTRACTION_TIMEOUT_MS = 30_000;
|
|
14
|
-
function extractInWorkerDeno(buffer, mimeType) {
|
|
15
|
-
return new Promise((resolve, reject) => {
|
|
16
|
-
// The worker ships as raw TypeScript in the compiled binary and from source
|
|
17
|
-
// (where `compile-binary.ts` force-includes it), but as transpiled JS in the
|
|
18
|
-
// npm package consumed via `deno run npm:veryfront`. Pick the sibling that
|
|
19
|
-
// matches whichever build is executing this module.
|
|
20
|
-
const workerFile = globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url.endsWith(".ts")
|
|
21
|
-
? "./upload-extraction-worker.ts"
|
|
22
|
-
: "./upload-extraction-worker.js";
|
|
23
|
-
const workerUrl = new URL(workerFile, globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url);
|
|
24
|
-
const worker = new Worker(workerUrl, { type: "module" });
|
|
25
|
-
const timer = dntShim.setTimeout(() => {
|
|
26
|
-
worker.terminate();
|
|
27
|
-
reject(new Error(`Text extraction timed out after ${EXTRACTION_TIMEOUT_MS / 1000}s. The file may be corrupted or unsupported`));
|
|
28
|
-
}, EXTRACTION_TIMEOUT_MS);
|
|
29
|
-
worker.onmessage = (event) => {
|
|
30
|
-
clearTimeout(timer);
|
|
31
|
-
worker.terminate();
|
|
32
|
-
const { content, error } = event.data;
|
|
33
|
-
if (error) {
|
|
34
|
-
reject(new Error(error));
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
resolve(content ?? "");
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
worker.onerror = (event) => {
|
|
41
|
-
clearTimeout(timer);
|
|
42
|
-
worker.terminate();
|
|
43
|
-
reject(new Error(`Text extraction worker failed: ${event.message ?? "unknown"}`));
|
|
44
|
-
};
|
|
45
|
-
worker.postMessage({ buffer, mimeType }, [buffer]);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
export class KreuzbergDocumentExtractor {
|
|
49
|
-
importKreuzberg() {
|
|
50
|
-
return loadKreuzberg();
|
|
51
|
-
}
|
|
52
|
-
async extractInWorker(buffer, mimeType) {
|
|
53
|
-
// Only a real Deno runtime gets the isolated Worker; Node/Bun extract
|
|
54
|
-
// in-process via @kreuzberg/node. See ./runtime.ts for why a bare `Deno`
|
|
55
|
-
// check is unreliable in the dnt npm build.
|
|
56
|
-
if (!isDeno) {
|
|
57
|
-
const { extractBytes } = await loadKreuzberg();
|
|
58
|
-
const result = await extractBytes(new Uint8Array(buffer), mimeType);
|
|
59
|
-
return result.content;
|
|
60
|
-
}
|
|
61
|
-
return extractInWorkerDeno(buffer, mimeType);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const extDocumentKreuzberg = () => {
|
|
65
|
-
const extractor = new KreuzbergDocumentExtractor();
|
|
66
|
-
return {
|
|
67
|
-
name: "ext-document-kreuzberg",
|
|
68
|
-
version: "0.1.0",
|
|
69
|
-
contracts: {
|
|
70
|
-
provides: ["DocumentExtractor"],
|
|
71
|
-
},
|
|
72
|
-
capabilities: [
|
|
73
|
-
{ type: "fs:read" },
|
|
74
|
-
],
|
|
75
|
-
setup(ctx) {
|
|
76
|
-
ctx.provide("DocumentExtractor", extractor);
|
|
77
|
-
ctx.logger.info("[ext-document-kreuzberg] document extraction registered");
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
export default extDocumentKreuzberg;
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,67 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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();
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
};
|