@preptex/ui 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +54 -2
- package/dist/components/CatalogDialog.css +401 -0
- package/dist/components/CatalogDialog.d.ts +16 -0
- package/dist/components/CatalogDialog.js +224 -0
- package/dist/components/CatalogDialog.js.map +1 -0
- package/dist/components/Codeview.css +127 -0
- package/dist/components/Codeview.d.ts +14 -0
- package/dist/components/Codeview.js +74 -0
- package/dist/components/Codeview.js.map +1 -0
- package/dist/components/ConfigurationSummary.d.ts +18 -0
- package/dist/components/ConfigurationSummary.js +44 -0
- package/dist/components/ConfigurationSummary.js.map +1 -0
- package/dist/components/ControlPanel.css +792 -0
- package/dist/components/ControlPanel.d.ts +48 -0
- package/dist/components/ControlPanel.js +218 -0
- package/dist/components/ControlPanel.js.map +1 -0
- package/dist/components/EditPreviewDialog.css +308 -0
- package/dist/components/EditPreviewDialog.d.ts +18 -0
- package/dist/components/EditPreviewDialog.js +46 -0
- package/dist/components/EditPreviewDialog.js.map +1 -0
- package/dist/components/Filetree.css +344 -0
- package/dist/components/Filetree.d.ts +22 -0
- package/dist/components/Filetree.js +250 -0
- package/dist/components/Filetree.js.map +1 -0
- package/dist/components/LogDialog.css +154 -0
- package/dist/components/LogDialog.d.ts +16 -0
- package/dist/components/LogDialog.js +42 -0
- package/dist/components/LogDialog.js.map +1 -0
- package/dist/components/LogPanel.css +106 -0
- package/dist/components/LogPanel.d.ts +10 -0
- package/dist/components/LogPanel.js +30 -0
- package/dist/components/LogPanel.js.map +1 -0
- package/dist/components/MetadataDialog.css +275 -0
- package/dist/components/MetadataDialog.d.ts +13 -0
- package/dist/components/MetadataDialog.js +67 -0
- package/dist/components/MetadataDialog.js.map +1 -0
- package/dist/components/NodeActionBar.css +163 -0
- package/dist/components/NodeActionBar.d.ts +19 -0
- package/dist/components/NodeActionBar.js +114 -0
- package/dist/components/NodeActionBar.js.map +1 -0
- package/dist/components/OperationsDialog.css +154 -0
- package/dist/components/OperationsDialog.d.ts +8 -0
- package/dist/components/OperationsDialog.js +27 -0
- package/dist/components/OperationsDialog.js.map +1 -0
- package/dist/components/PrepTeXWorkspace.css +224 -0
- package/dist/components/PrepTeXWorkspace.d.ts +125 -0
- package/dist/components/PrepTeXWorkspace.js +593 -0
- package/dist/components/PrepTeXWorkspace.js.map +1 -0
- package/dist/components/ProjectSetupDialog.css +292 -0
- package/dist/components/ProjectSetupDialog.d.ts +18 -0
- package/dist/components/ProjectSetupDialog.js +134 -0
- package/dist/components/ProjectSetupDialog.js.map +1 -0
- package/dist/components/WelcomeEmptyState.css +105 -0
- package/dist/components/WelcomeEmptyState.d.ts +9 -0
- package/dist/components/WelcomeEmptyState.js +28 -0
- package/dist/components/WelcomeEmptyState.js.map +1 -0
- package/dist/components/WorkspaceHeader.css +410 -0
- package/dist/components/WorkspaceHeader.d.ts +66 -0
- package/dist/components/WorkspaceHeader.js +297 -0
- package/dist/components/WorkspaceHeader.js.map +1 -0
- package/dist/components/astview/ASTview.css +690 -0
- package/dist/components/astview/ASTview.d.ts +27 -0
- package/dist/components/astview/ASTview.js +314 -0
- package/dist/components/astview/ASTview.js.map +1 -0
- package/dist/components/astview/TreeNode.d.ts +8 -0
- package/dist/components/astview/TreeNode.js +237 -0
- package/dist/components/astview/TreeNode.js.map +1 -0
- package/dist/components/astview/treebuilder.d.ts +13 -0
- package/dist/components/astview/treebuilder.js +292 -0
- package/dist/components/astview/treebuilder.js.map +1 -0
- package/dist/components/index.d.ts +18 -0
- package/dist/components/index.js +19 -0
- package/dist/components/index.js.map +1 -0
- package/dist/docs/architecture.md +46 -0
- package/dist/docs/integration.md +107 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/model/useArtifacts.d.ts +14 -0
- package/dist/model/useArtifacts.js +32 -0
- package/dist/model/useArtifacts.js.map +1 -0
- package/dist/model/useControl.d.ts +15 -0
- package/dist/model/useControl.js +19 -0
- package/dist/model/useControl.js.map +1 -0
- package/dist/model/useFiles.d.ts +53 -0
- package/dist/model/useFiles.js +283 -0
- package/dist/model/useFiles.js.map +1 -0
- package/dist/model/useProjectConfiguration.d.ts +32 -0
- package/dist/model/useProjectConfiguration.js +151 -0
- package/dist/model/useProjectConfiguration.js.map +1 -0
- package/dist/model/useWorkspaceLayout.d.ts +26 -0
- package/dist/model/useWorkspaceLayout.js +55 -0
- package/dist/model/useWorkspaceLayout.js.map +1 -0
- package/dist/services/zip.d.ts +24 -0
- package/dist/services/zip.js +279 -0
- package/dist/services/zip.js.map +1 -0
- package/dist/styles/bundle.css +4652 -0
- package/dist/styles/tokens.css +77 -0
- package/dist/types/LayoutNode.d.ts +30 -0
- package/dist/types/LayoutNode.js +18 -0
- package/dist/types/LayoutNode.js.map +1 -0
- package/dist/types/artifacts.d.ts +9 -0
- package/dist/types/artifacts.js +2 -0
- package/dist/types/artifacts.js.map +1 -0
- package/dist/types/errors.d.ts +14 -0
- package/dist/types/errors.js +2 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/files.d.ts +12 -0
- package/dist/types/files.js +2 -0
- package/dist/types/files.js.map +1 -0
- package/dist/utils/dropEntries.d.ts +6 -0
- package/dist/utils/dropEntries.js +58 -0
- package/dist/utils/dropEntries.js.map +1 -0
- package/dist/utils/fileFilter.d.ts +10 -0
- package/dist/utils/fileFilter.js +68 -0
- package/dist/utils/fileFilter.js.map +1 -0
- package/dist/utils/transformOutput.d.ts +24 -0
- package/dist/utils/transformOutput.js +83 -0
- package/dist/utils/transformOutput.js.map +1 -0
- package/package.json +103 -4
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--font-sans:
|
|
3
|
+
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
|
4
|
+
'Helvetica Neue', Arial, sans-serif;
|
|
5
|
+
--font-mono:
|
|
6
|
+
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
|
|
7
|
+
monospace;
|
|
8
|
+
--color-bg: #f7f9ff;
|
|
9
|
+
--color-surface: #ffffff;
|
|
10
|
+
--color-surface-soft: #fbfcff;
|
|
11
|
+
--color-surface-muted: #f5f7ff;
|
|
12
|
+
--color-surface-subtle: #f1f5f9;
|
|
13
|
+
--color-border: rgba(64, 82, 137, 0.18);
|
|
14
|
+
--color-border-strong: rgba(76, 93, 146, 0.26);
|
|
15
|
+
--color-text: #0e1833;
|
|
16
|
+
--color-text-muted: #566385;
|
|
17
|
+
--color-primary: #3f7fc4;
|
|
18
|
+
--color-primary-hover: #2f68a5;
|
|
19
|
+
--color-primary-strong: #2f68a5;
|
|
20
|
+
--color-primary-start: #5b9cda;
|
|
21
|
+
--color-primary-soft: #eef6ff;
|
|
22
|
+
--color-title: #4f82b8;
|
|
23
|
+
--color-title-muted: #6f94bc;
|
|
24
|
+
--color-action: #2f68a5;
|
|
25
|
+
--color-action-soft: #edf6ff;
|
|
26
|
+
--color-action-border: rgba(47, 104, 165, 0.32);
|
|
27
|
+
--color-chip-bg: #f1f5fb;
|
|
28
|
+
--color-chip-text: #6f7d99;
|
|
29
|
+
--color-icon-bg: #eef6ff;
|
|
30
|
+
--color-icon-muted-bg: #f3f6fb;
|
|
31
|
+
--color-icon-muted-text: #53617f;
|
|
32
|
+
--color-icon-command-bg: #f1f2f4;
|
|
33
|
+
--color-icon-command-text: #4f5663;
|
|
34
|
+
--color-icon-success-bg: #eef9f2;
|
|
35
|
+
--color-icon-success-text: #277448;
|
|
36
|
+
--color-icon-warning-bg: #fff5df;
|
|
37
|
+
--color-icon-warning-text: #9a5a00;
|
|
38
|
+
--color-line-meta: #7a86a6;
|
|
39
|
+
--color-on-primary: #ffffff;
|
|
40
|
+
--color-danger: #8b1f1f;
|
|
41
|
+
--shadow-panel: 0 12px 32px rgba(70, 86, 130, 0.08);
|
|
42
|
+
--radius-panel: 10px;
|
|
43
|
+
--radius-control: 7px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
*,
|
|
47
|
+
*::before,
|
|
48
|
+
*::after {
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
body {
|
|
53
|
+
margin: 0;
|
|
54
|
+
background: var(--color-bg);
|
|
55
|
+
color: var(--color-text);
|
|
56
|
+
font-family: var(--font-sans);
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
-webkit-font-smoothing: antialiased;
|
|
59
|
+
-moz-osx-font-smoothing: grayscale;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
html,
|
|
63
|
+
body,
|
|
64
|
+
#root {
|
|
65
|
+
height: 100%;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
code {
|
|
69
|
+
font-family: var(--font-mono);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
button,
|
|
73
|
+
input,
|
|
74
|
+
select,
|
|
75
|
+
textarea {
|
|
76
|
+
font-family: inherit;
|
|
77
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CoarseNode, NodeLocation, SourceRange } from '@preptex/core';
|
|
2
|
+
export declare const LAYOUT_NODE_KINDS: readonly ["root", "section", "environment", "group", "math", "command", "argument", "text-block", "comment", "text", "space", "token"];
|
|
3
|
+
export type LayoutNodeKind = typeof LAYOUT_NODE_KINDS[number];
|
|
4
|
+
export type LayoutSectionLevel = 1 | 2 | 3 | 4 | 5;
|
|
5
|
+
export declare function isLayoutNodeKind(value: string): value is LayoutNodeKind;
|
|
6
|
+
/** Website display data; never attach layout or UI state to the core AST. */
|
|
7
|
+
export interface LayoutNode {
|
|
8
|
+
readonly kind: LayoutNodeKind;
|
|
9
|
+
readonly data?: string;
|
|
10
|
+
/** One-based source line in the selected input file. */
|
|
11
|
+
readonly line: number;
|
|
12
|
+
readonly range?: SourceRange;
|
|
13
|
+
readonly path?: string;
|
|
14
|
+
readonly icon: string;
|
|
15
|
+
readonly x: number;
|
|
16
|
+
readonly y: number;
|
|
17
|
+
readonly label?: string;
|
|
18
|
+
readonly sublabel?: string;
|
|
19
|
+
readonly sectionLevel?: LayoutSectionLevel;
|
|
20
|
+
readonly isStarred?: boolean;
|
|
21
|
+
readonly editableName?: boolean;
|
|
22
|
+
readonly argumentInfo?: CoarseNode['argumentInfo'];
|
|
23
|
+
readonly previewText?: string;
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly occurrenceKey?: string;
|
|
26
|
+
readonly location?: NodeLocation;
|
|
27
|
+
readonly strokeWidth: number;
|
|
28
|
+
readonly strokeColor?: string;
|
|
29
|
+
readonly children: readonly LayoutNode[];
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const LAYOUT_NODE_KINDS = [
|
|
2
|
+
'root',
|
|
3
|
+
'section',
|
|
4
|
+
'environment',
|
|
5
|
+
'group',
|
|
6
|
+
'math',
|
|
7
|
+
'command',
|
|
8
|
+
'argument',
|
|
9
|
+
'text-block',
|
|
10
|
+
'comment',
|
|
11
|
+
'text',
|
|
12
|
+
'space',
|
|
13
|
+
'token',
|
|
14
|
+
];
|
|
15
|
+
export function isLayoutNodeKind(value) {
|
|
16
|
+
return LAYOUT_NODE_KINDS.some((kind) => kind === value);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=LayoutNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LayoutNode.js","sourceRoot":"","sources":["../../src/types/LayoutNode.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,MAAM;IACN,SAAS;IACT,aAAa;IACb,OAAO;IACP,MAAM;IACN,SAAS;IACT,UAAU;IACV,YAAY;IACZ,SAAS;IACT,MAAM;IACN,OAAO;IACP,OAAO;CACC,CAAC;AAMX,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import type { CoarseNode, NodeLocation, SourceRange } from '@preptex/core';\n\nexport const LAYOUT_NODE_KINDS = [\n 'root',\n 'section',\n 'environment',\n 'group',\n 'math',\n 'command',\n 'argument',\n 'text-block',\n 'comment',\n 'text',\n 'space',\n 'token',\n] as const;\n\nexport type LayoutNodeKind = typeof LAYOUT_NODE_KINDS[number];\n\nexport type LayoutSectionLevel = 1 | 2 | 3 | 4 | 5;\n\nexport function isLayoutNodeKind(value: string): value is LayoutNodeKind {\n return LAYOUT_NODE_KINDS.some((kind) => kind === value);\n}\n\n/** Website display data; never attach layout or UI state to the core AST. */\nexport interface LayoutNode {\n readonly kind: LayoutNodeKind;\n readonly data?: string;\n /** One-based source line in the selected input file. */\n readonly line: number;\n readonly range?: SourceRange;\n readonly path?: string;\n readonly icon: string;\n readonly x: number;\n readonly y: number;\n readonly label?: string;\n readonly sublabel?: string;\n readonly sectionLevel?: LayoutSectionLevel;\n readonly isStarred?: boolean;\n readonly editableName?: boolean;\n readonly argumentInfo?: CoarseNode['argumentInfo'];\n readonly previewText?: string;\n readonly id: string;\n readonly occurrenceKey?: string;\n readonly location?: NodeLocation;\n readonly strokeWidth: number;\n readonly strokeColor?: string;\n readonly children: readonly LayoutNode[];\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GeneratedArtifact } from '@preptex/core';
|
|
2
|
+
export interface UIArtifactItem {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly source: string;
|
|
6
|
+
readonly timestamp: number;
|
|
7
|
+
readonly topology?: GeneratedArtifact['topology'];
|
|
8
|
+
readonly remainingInputs?: readonly string[];
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../src/types/artifacts.ts"],"names":[],"mappings":"","sourcesContent":["import type { GeneratedArtifact } from '@preptex/core';\n\nexport interface UIArtifactItem {\n readonly id: string;\n readonly path: string;\n readonly source: string;\n readonly timestamp: number;\n readonly topology?: GeneratedArtifact['topology'];\n readonly remainingInputs?: readonly string[];\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { OperationFailure, PrepTexErrorCode } from '@preptex/core';
|
|
2
|
+
export type ProcessingError = {
|
|
3
|
+
readonly kind: 'operation';
|
|
4
|
+
readonly message: string;
|
|
5
|
+
readonly code: PrepTexErrorCode;
|
|
6
|
+
readonly failure: OperationFailure;
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: 'core';
|
|
9
|
+
readonly message: string;
|
|
10
|
+
readonly code: PrepTexErrorCode;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: 'unexpected';
|
|
13
|
+
readonly message: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"","sourcesContent":["import type { OperationFailure, PrepTexErrorCode } from '@preptex/core';\n\nexport type ProcessingError =\n | {\n readonly kind: 'operation';\n readonly message: string;\n readonly code: PrepTexErrorCode;\n readonly failure: OperationFailure;\n }\n | { readonly kind: 'core'; readonly message: string; readonly code: PrepTexErrorCode }\n | { readonly kind: 'unexpected'; readonly message: string };\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ProjectFilePath } from '@preptex/core';
|
|
2
|
+
/** Immutable source buffers, keyed by forward-slash virtual project paths. */
|
|
3
|
+
export type FilesMap = Readonly<Record<ProjectFilePath, string>>;
|
|
4
|
+
/** Tagged viewed item identity to distinguish source files from generated artifacts */
|
|
5
|
+
export type ViewedItem = {
|
|
6
|
+
readonly kind: 'source';
|
|
7
|
+
readonly path: ProjectFilePath;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'artifact';
|
|
10
|
+
readonly artifactId: string;
|
|
11
|
+
readonly path: ProjectFilePath;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/types/files.ts"],"names":[],"mappings":"","sourcesContent":["import type { ProjectFilePath } from '@preptex/core';\n\n/** Immutable source buffers, keyed by forward-slash virtual project paths. */\nexport type FilesMap = Readonly<Record<ProjectFilePath, string>>;\n\n/** Tagged viewed item identity to distinguish source files from generated artifacts */\nexport type ViewedItem =\n | { readonly kind: 'source'; readonly path: ProjectFilePath }\n | { readonly kind: 'artifact'; readonly artifactId: string; readonly path: ProjectFilePath };\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function readAllDirectoryEntries(entry) {
|
|
2
|
+
return new Promise((resolve) => {
|
|
3
|
+
const reader = entry.createReader?.();
|
|
4
|
+
if (!reader) {
|
|
5
|
+
resolve([]);
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const collected = [];
|
|
9
|
+
const readBatch = () => {
|
|
10
|
+
reader.readEntries((batch) => {
|
|
11
|
+
if (batch.length === 0) {
|
|
12
|
+
resolve(collected);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
collected.push(...batch);
|
|
16
|
+
readBatch();
|
|
17
|
+
}, () => resolve(collected));
|
|
18
|
+
};
|
|
19
|
+
readBatch();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async function traverseEntry(entry, prefix, fromDirectory = false) {
|
|
23
|
+
const path = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
24
|
+
if (entry.isFile && entry.file) {
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
entry.file((file) => resolve([{ file, relativePath: path, fromDirectory }]), () => resolve([]));
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (entry.isDirectory) {
|
|
30
|
+
const children = await readAllDirectoryEntries(entry);
|
|
31
|
+
const nested = await Promise.all(children.map((child) => traverseEntry(child, path, true)));
|
|
32
|
+
return nested.flat();
|
|
33
|
+
}
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
export async function extractDroppedFiles(dataTransfer) {
|
|
37
|
+
if (!dataTransfer)
|
|
38
|
+
return [];
|
|
39
|
+
const items = dataTransfer.items ? Array.from(dataTransfer.items) : [];
|
|
40
|
+
const entries = items
|
|
41
|
+
.map((item) => item.webkitGetAsEntry?.() ?? null)
|
|
42
|
+
.filter((entry) => entry !== null);
|
|
43
|
+
if (entries.length > 0) {
|
|
44
|
+
const traversed = await Promise.all(entries.map((entry) => traverseEntry(entry, '', false)));
|
|
45
|
+
const flat = traversed.flat();
|
|
46
|
+
if (flat.length > 0)
|
|
47
|
+
return flat;
|
|
48
|
+
}
|
|
49
|
+
return Array.from(dataTransfer.files).map((file) => {
|
|
50
|
+
const relativePath = (file.webkitRelativePath || file.name).replace(/\\/g, '/');
|
|
51
|
+
return {
|
|
52
|
+
file,
|
|
53
|
+
relativePath,
|
|
54
|
+
fromDirectory: Boolean(file.webkitRelativePath && file.webkitRelativePath.includes('/')),
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=dropEntries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropEntries.js","sourceRoot":"","sources":["../../src/utils/dropEntries.ts"],"names":[],"mappings":"AAqBA,SAAS,uBAAuB,CAAC,KAAsB;IACrD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,EAAE,EAAE,CAAC;QACtC,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,CAAC,EAAE,CAAC,CAAC;YACZ,OAAO;SACR;QACD,MAAM,SAAS,GAAsB,EAAE,CAAC;QACxC,MAAM,SAAS,GAAG,GAAG,EAAE;YACrB,MAAM,CAAC,WAAW,CAChB,CAAC,KAAK,EAAE,EAAE;gBACR,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,E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readonly relativePath: string;\n readonly fromDirectory?: boolean;\n}\n\ninterface WebKitEntryLike {\n readonly isFile: boolean;\n readonly isDirectory: boolean;\n readonly name: string;\n file?: (success: (file: File) => void, error?: (err: unknown) => void) => void;\n createReader?: () => {\n readEntries: (success: (entries: WebKitEntryLike[]) => void, error?: (err: unknown) => void) => void;\n };\n}\n\ninterface DataTransferItemWithEntry {\n webkitGetAsEntry?: () => WebKitEntryLike | null;\n getAsFile?: () => File | null;\n}\n\nfunction readAllDirectoryEntries(entry: WebKitEntryLike): Promise<WebKitEntryLike[]> {\n return new Promise((resolve) => {\n const reader = entry.createReader?.();\n if (!reader) {\n resolve([]);\n return;\n }\n const collected: WebKitEntryLike[] = [];\n const readBatch = () => {\n reader.readEntries(\n (batch) => {\n if (batch.length === 0) {\n resolve(collected);\n return;\n }\n collected.push(...batch);\n readBatch();\n },\n () => resolve(collected),\n );\n };\n readBatch();\n });\n}\n\nasync function traverseEntry(\n entry: WebKitEntryLike,\n prefix: string,\n fromDirectory = false,\n): Promise<DroppedFileItem[]> {\n const path = prefix ? `${prefix}/${entry.name}` : entry.name;\n if (entry.isFile && entry.file) {\n return new Promise((resolve) => {\n entry.file!(\n (file) => resolve([{ file, relativePath: path, fromDirectory }]),\n () => resolve([]),\n );\n });\n }\n if (entry.isDirectory) {\n const children = await readAllDirectoryEntries(entry);\n const nested = await Promise.all(children.map((child) => traverseEntry(child, path, true)));\n return nested.flat();\n }\n return [];\n}\n\nexport async function extractDroppedFiles(dataTransfer: DataTransfer | null): Promise<DroppedFileItem[]> {\n if (!dataTransfer) return [];\n\n const items = dataTransfer.items ? Array.from(dataTransfer.items) : [];\n const entries = items\n .map((item) => (item as unknown as DataTransferItemWithEntry).webkitGetAsEntry?.() ?? null)\n .filter((entry): entry is WebKitEntryLike => entry !== null);\n\n if (entries.length > 0) {\n const traversed = await Promise.all(entries.map((entry) => traverseEntry(entry, '', false)));\n const flat = traversed.flat();\n if (flat.length > 0) return flat;\n }\n\n return Array.from(dataTransfer.files).map((file) => {\n const relativePath = (file.webkitRelativePath || file.name).replace(/\\\\/g, '/');\n return {\n file,\n relativePath,\n fromDirectory: Boolean(file.webkitRelativePath && file.webkitRelativePath.includes('/')),\n };\n });\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const RELEVANT_TEX_EXTENSIONS: ReadonlySet<string>;
|
|
2
|
+
export declare const IGNORED_FOLDER_SEGMENTS: ReadonlySet<string>;
|
|
3
|
+
export declare function getFileExtension(path: string): string;
|
|
4
|
+
export declare function isRelevantProjectFile(relativePath: string): boolean;
|
|
5
|
+
export interface FilteredUploadBatch<T> {
|
|
6
|
+
readonly accepted: readonly T[];
|
|
7
|
+
readonly skippedCount: number;
|
|
8
|
+
readonly skippedPaths: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
export declare function filterUploadedBatch<T>(items: readonly T[], getPath: (item: T) => string): FilteredUploadBatch<T>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export const RELEVANT_TEX_EXTENSIONS = new Set([
|
|
2
|
+
'.tex',
|
|
3
|
+
'.ltx',
|
|
4
|
+
'.sty',
|
|
5
|
+
'.cls',
|
|
6
|
+
'.clo',
|
|
7
|
+
'.def',
|
|
8
|
+
'.cfg',
|
|
9
|
+
'.fd',
|
|
10
|
+
'.dtx',
|
|
11
|
+
'.ins',
|
|
12
|
+
'.bib',
|
|
13
|
+
'.bst',
|
|
14
|
+
'.bbx',
|
|
15
|
+
'.cbx',
|
|
16
|
+
'.lbx',
|
|
17
|
+
'.tikz',
|
|
18
|
+
'.pgf',
|
|
19
|
+
]);
|
|
20
|
+
export const IGNORED_FOLDER_SEGMENTS = new Set([
|
|
21
|
+
'.git',
|
|
22
|
+
'node_modules',
|
|
23
|
+
'__macosx',
|
|
24
|
+
'.ds_store',
|
|
25
|
+
]);
|
|
26
|
+
export function getFileExtension(path) {
|
|
27
|
+
const normalized = path.replace(/\\/g, '/');
|
|
28
|
+
const slashIdx = normalized.lastIndexOf('/');
|
|
29
|
+
const baseName = slashIdx >= 0 ? normalized.slice(slashIdx + 1) : normalized;
|
|
30
|
+
const dotIdx = baseName.lastIndexOf('.');
|
|
31
|
+
if (dotIdx <= 0 || dotIdx === baseName.length - 1)
|
|
32
|
+
return '';
|
|
33
|
+
return baseName.slice(dotIdx).toLowerCase();
|
|
34
|
+
}
|
|
35
|
+
export function isRelevantProjectFile(relativePath) {
|
|
36
|
+
const normalized = relativePath.replace(/\\/g, '/').replace(/^(?:\.\/|\/)+/, '');
|
|
37
|
+
if (!normalized)
|
|
38
|
+
return false;
|
|
39
|
+
const segments = normalized.split('/').filter(Boolean);
|
|
40
|
+
if (segments.length === 0)
|
|
41
|
+
return false;
|
|
42
|
+
for (const segment of segments) {
|
|
43
|
+
if (IGNORED_FOLDER_SEGMENTS.has(segment.toLowerCase())) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const ext = getFileExtension(normalized);
|
|
48
|
+
return RELEVANT_TEX_EXTENSIONS.has(ext);
|
|
49
|
+
}
|
|
50
|
+
export function filterUploadedBatch(items, getPath) {
|
|
51
|
+
const accepted = [];
|
|
52
|
+
const skippedPaths = [];
|
|
53
|
+
for (const item of items) {
|
|
54
|
+
const path = getPath(item);
|
|
55
|
+
if (isRelevantProjectFile(path)) {
|
|
56
|
+
accepted.push(item);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
skippedPaths.push(path);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
accepted,
|
|
64
|
+
skippedCount: skippedPaths.length,
|
|
65
|
+
skippedPaths,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=fileFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileFilter.js","sourceRoot":"","sources":["../../src/utils/fileFilter.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAwB,I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C;IACvD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAExC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC9B,IAAI,uBAAuB,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE;YACtD,OAAO,KAAK,CAAC;SACd;KACF;IAED,MAAM,GAAG,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACzC,OAAO,uBAAuB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AAQD,MAAM,UAAU,mBAAmB,CACjC,KAAmB,EACnB,OAA4B;IAE5B,MAAM,QAAQ,GAAQ,EAAE,CAAC;IACzB,MAAM,YAAY,GAAa,EAAE,CAAC;IAElC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,qBAAqB,CAAC,IAAI,CAAC,EAAE;YAC/B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;aAAM;YACL,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACzB;KACF;IAED,OAAO;QACL,QAAQ;QACR,YAAY,EAAE,YAAY,CAAC,MAAM;QACjC,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["export const RELEVANT_TEX_EXTENSIONS: ReadonlySet<string> = new Set([\n '.tex',\n '.ltx',\n '.sty',\n '.cls',\n '.clo',\n '.def',\n '.cfg',\n '.fd',\n '.dtx',\n '.ins',\n '.bib',\n '.bst',\n '.bbx',\n '.cbx',\n '.lbx',\n '.tikz',\n '.pgf',\n]);\n\nexport const IGNORED_FOLDER_SEGMENTS: ReadonlySet<string> = new Set([\n '.git',\n 'node_modules',\n '__macosx',\n '.ds_store',\n]);\n\nexport function getFileExtension(path: string): string {\n const normalized = path.replace(/\\\\/g, '/');\n const slashIdx = normalized.lastIndexOf('/');\n const baseName = slashIdx >= 0 ? normalized.slice(slashIdx + 1) : normalized;\n const dotIdx = baseName.lastIndexOf('.');\n if (dotIdx <= 0 || dotIdx === baseName.length - 1) return '';\n return baseName.slice(dotIdx).toLowerCase();\n}\n\nexport function isRelevantProjectFile(relativePath: string): boolean {\n const normalized = relativePath.replace(/\\\\/g, '/').replace(/^(?:\\.\\/|\\/)+/, '');\n if (!normalized) return false;\n const segments = normalized.split('/').filter(Boolean);\n if (segments.length === 0) return false;\n\n for (const segment of segments) {\n if (IGNORED_FOLDER_SEGMENTS.has(segment.toLowerCase())) {\n return false;\n }\n }\n\n const ext = getFileExtension(normalized);\n return RELEVANT_TEX_EXTENSIONS.has(ext);\n}\n\nexport interface FilteredUploadBatch<T> {\n readonly accepted: readonly T[];\n readonly skippedCount: number;\n readonly skippedPaths: readonly string[];\n}\n\nexport function filterUploadedBatch<T>(\n items: readonly T[],\n getPath: (item: T) => string,\n): FilteredUploadBatch<T> {\n const accepted: T[] = [];\n const skippedPaths: string[] = [];\n\n for (const item of items) {\n const path = getPath(item);\n if (isRelevantProjectFile(path)) {\n accepted.push(item);\n } else {\n skippedPaths.push(path);\n }\n }\n\n return {\n accepted,\n skippedCount: skippedPaths.length,\n skippedPaths,\n };\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { GeneratedArtifact, ProjectFilePath } from '@preptex/core';
|
|
2
|
+
import type { FilesMap } from '../types/files.js';
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes a user-supplied virtual output folder path (`out`, `build/clean`).
|
|
5
|
+
* Returns `''` when omitted, or `null` if the path contains invalid traversal segments.
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalizeOutputFolder(raw: string): string | null;
|
|
8
|
+
export interface BuildNewFileOutputsArgs {
|
|
9
|
+
readonly artifacts: readonly GeneratedArtifact[];
|
|
10
|
+
readonly existingFiles: FilesMap;
|
|
11
|
+
readonly changedPaths?: ReadonlySet<string>;
|
|
12
|
+
readonly entryPath?: ProjectFilePath | null;
|
|
13
|
+
readonly outputFolder: string;
|
|
14
|
+
}
|
|
15
|
+
export interface BuildNewFileOutputsResult {
|
|
16
|
+
readonly files: FilesMap;
|
|
17
|
+
readonly primaryPath: ProjectFilePath | null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Maps generated artifacts into new virtual workspace paths, either inside a
|
|
21
|
+
* target subfolder (preserving relative project structure) or as sibling
|
|
22
|
+
* `*.transformed.tex` files when no folder is provided.
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildNewFileOutputs({ artifacts, existingFiles, changedPaths, entryPath, outputFolder, }: BuildNewFileOutputsArgs): BuildNewFileOutputsResult;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a user-supplied virtual output folder path (`out`, `build/clean`).
|
|
3
|
+
* Returns `''` when omitted, or `null` if the path contains invalid traversal segments.
|
|
4
|
+
*/
|
|
5
|
+
export function normalizeOutputFolder(raw) {
|
|
6
|
+
const normalized = raw
|
|
7
|
+
.trim()
|
|
8
|
+
.replace(/\\/g, '/')
|
|
9
|
+
.replace(/\/+/g, '/')
|
|
10
|
+
.replace(/^\/+|\/+$/g, '');
|
|
11
|
+
if (!normalized)
|
|
12
|
+
return '';
|
|
13
|
+
const segments = normalized.split('/');
|
|
14
|
+
if (segments.some((seg) => !seg || seg === '.' || seg === '..')) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return normalized;
|
|
18
|
+
}
|
|
19
|
+
function buildSiblingPath(path, taken) {
|
|
20
|
+
const slashIdx = path.lastIndexOf('/');
|
|
21
|
+
const dir = slashIdx >= 0 ? path.slice(0, slashIdx + 1) : '';
|
|
22
|
+
const base = slashIdx >= 0 ? path.slice(slashIdx + 1) : path;
|
|
23
|
+
const dotIdx = base.lastIndexOf('.');
|
|
24
|
+
const stem = dotIdx > 0 ? base.slice(0, dotIdx) : base;
|
|
25
|
+
const ext = dotIdx > 0 ? base.slice(dotIdx) : '.tex';
|
|
26
|
+
let candidate = `${dir}${stem}.transformed${ext}`;
|
|
27
|
+
let counter = 2;
|
|
28
|
+
while (taken.has(candidate)) {
|
|
29
|
+
candidate = `${dir}${stem}.transformed-${counter}${ext}`;
|
|
30
|
+
counter += 1;
|
|
31
|
+
}
|
|
32
|
+
return candidate;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Maps generated artifacts into new virtual workspace paths, either inside a
|
|
36
|
+
* target subfolder (preserving relative project structure) or as sibling
|
|
37
|
+
* `*.transformed.tex` files when no folder is provided.
|
|
38
|
+
*/
|
|
39
|
+
export function buildNewFileOutputs({ artifacts, existingFiles, changedPaths, entryPath, outputFolder, }) {
|
|
40
|
+
if (artifacts.length === 0) {
|
|
41
|
+
return { files: {}, primaryPath: null };
|
|
42
|
+
}
|
|
43
|
+
const folder = normalizeOutputFolder(outputFolder);
|
|
44
|
+
if (folder === null) {
|
|
45
|
+
return { files: {}, primaryPath: null };
|
|
46
|
+
}
|
|
47
|
+
const out = {};
|
|
48
|
+
let primaryPath = null;
|
|
49
|
+
if (folder.length > 0) {
|
|
50
|
+
for (const art of artifacts) {
|
|
51
|
+
const targetPath = `${folder}/${art.path}`;
|
|
52
|
+
out[targetPath] = art.source;
|
|
53
|
+
if (entryPath && art.path === entryPath) {
|
|
54
|
+
primaryPath = targetPath;
|
|
55
|
+
}
|
|
56
|
+
if (!primaryPath) {
|
|
57
|
+
primaryPath = targetPath;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { files: out, primaryPath };
|
|
61
|
+
}
|
|
62
|
+
// No folder specified: emit transformed sibling files for changed/single artifacts
|
|
63
|
+
const selected = artifacts.length === 1
|
|
64
|
+
? artifacts
|
|
65
|
+
: changedPaths && changedPaths.size > 0
|
|
66
|
+
? artifacts.filter((art) => changedPaths.has(art.path))
|
|
67
|
+
: artifacts;
|
|
68
|
+
const effectiveArtifacts = selected.length > 0 ? selected : artifacts.slice(0, 1);
|
|
69
|
+
const taken = new Set(Object.keys(existingFiles));
|
|
70
|
+
for (const art of effectiveArtifacts) {
|
|
71
|
+
const targetPath = buildSiblingPath(art.path, taken);
|
|
72
|
+
taken.add(targetPath);
|
|
73
|
+
out[targetPath] = art.source;
|
|
74
|
+
if (entryPath && art.path === entryPath) {
|
|
75
|
+
primaryPath = targetPath;
|
|
76
|
+
}
|
|
77
|
+
if (!primaryPath) {
|
|
78
|
+
primaryPath = targetPath;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return { files: out, primaryPath };
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=transformOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformOutput.js","sourceRoot":"","sources":["../../src/utils/transformOutput.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAW;IAC/C,MAAM,UAAU,GAAG,GAAG;SACnB,IAAI,EAAE;SACN,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAC7B,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAC3B,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,IAAI,CAAC,EAAE;QAC/D,OAAO,IAAI,CAAC;KACb;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,gBAAgB,CACvB,IAAqB,EACrB,KAA0B;IAE1B,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,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CAAC,CAAC;QACrD,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACtB,GAAG,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;QAC7B,IAAI,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,EAAE;YACvC,WAAW,GAAG,UAAU,CAAC;SAC1B;QACD,IAAI,CAAC,WAAW,EAAE;YAChB,WAAW,GAAG,UAAU,CAAC;SAC1B;KACF;IAED,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;AACrC,CAAC","sourcesContent":["import type { GeneratedArtifact, ProjectFilePath } from '@preptex/core';\nimport type { FilesMap } from '../types/files';\n\n/**\n * Normalizes a user-supplied virtual output folder path (`out`, `build/clean`).\n * Returns `''` when omitted, or `null` if the path contains invalid traversal segments.\n */\nexport function normalizeOutputFolder(raw: string): string | null {\n const normalized = raw\n .trim()\n .replace(/\\\\/g, '/')\n .replace(/\\/+/g, '/')\n .replace(/^\\/+|\\/+$/g, '');\n if (!normalized) return '';\n const segments = normalized.split('/');\n if (segments.some((seg) => !seg || seg === '.' || seg === '..')) {\n return null;\n }\n return normalized;\n}\n\nfunction buildSiblingPath(\n path: ProjectFilePath,\n taken: ReadonlySet<string>,\n): ProjectFilePath {\n const slashIdx = path.lastIndexOf('/');\n const dir = slashIdx >= 0 ? path.slice(0, slashIdx + 1) : '';\n const base = slashIdx >= 0 ? path.slice(slashIdx + 1) : path;\n const dotIdx = base.lastIndexOf('.');\n const stem = dotIdx > 0 ? base.slice(0, dotIdx) : base;\n const ext = dotIdx > 0 ? base.slice(dotIdx) : '.tex';\n\n let candidate = `${dir}${stem}.transformed${ext}`;\n let counter = 2;\n while (taken.has(candidate)) {\n candidate = `${dir}${stem}.transformed-${counter}${ext}`;\n counter += 1;\n }\n return candidate;\n}\n\nexport interface BuildNewFileOutputsArgs {\n readonly artifacts: readonly GeneratedArtifact[];\n readonly existingFiles: FilesMap;\n readonly changedPaths?: ReadonlySet<string>;\n readonly entryPath?: ProjectFilePath | null;\n readonly outputFolder: string;\n}\n\nexport interface BuildNewFileOutputsResult {\n readonly files: FilesMap;\n readonly primaryPath: ProjectFilePath | null;\n}\n\n/**\n * Maps generated artifacts into new virtual workspace paths, either inside a\n * target subfolder (preserving relative project structure) or as sibling\n * `*.transformed.tex` files when no folder is provided.\n */\nexport function buildNewFileOutputs({\n artifacts,\n existingFiles,\n changedPaths,\n entryPath,\n outputFolder,\n}: BuildNewFileOutputsArgs): BuildNewFileOutputsResult {\n if (artifacts.length === 0) {\n return { files: {}, primaryPath: null };\n }\n\n const folder = normalizeOutputFolder(outputFolder);\n if (folder === null) {\n return { files: {}, primaryPath: null };\n }\n\n const out: Record<string, string> = {};\n let primaryPath: ProjectFilePath | null = null;\n\n if (folder.length > 0) {\n for (const art of artifacts) {\n const targetPath = `${folder}/${art.path}`;\n out[targetPath] = art.source;\n if (entryPath && art.path === entryPath) {\n primaryPath = targetPath;\n }\n if (!primaryPath) {\n primaryPath = targetPath;\n }\n }\n return { files: out, primaryPath };\n }\n\n // No folder specified: emit transformed sibling files for changed/single artifacts\n const selected =\n artifacts.length === 1\n ? artifacts\n : changedPaths && changedPaths.size > 0\n ? artifacts.filter((art) => changedPaths.has(art.path))\n : artifacts;\n const effectiveArtifacts = selected.length > 0 ? selected : artifacts.slice(0, 1);\n\n const taken = new Set(Object.keys(existingFiles));\n for (const art of effectiveArtifacts) {\n const targetPath = buildSiblingPath(art.path, taken);\n taken.add(targetPath);\n out[targetPath] = art.source;\n if (entryPath && art.path === entryPath) {\n primaryPath = targetPath;\n }\n if (!primaryPath) {\n primaryPath = targetPath;\n }\n }\n\n return { files: out, primaryPath };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,105 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@preptex/ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Reusable React UI workspace, components, layout/file hooks, and design tokens for PrepTeX applications.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"preptex",
|
|
7
|
+
"latex",
|
|
8
|
+
"tex",
|
|
9
|
+
"react",
|
|
10
|
+
"ast",
|
|
11
|
+
"ui"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/preptex/preptex-ui.git"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/preptex/preptex-ui/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/preptex/preptex-ui#readme",
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": [
|
|
24
|
+
"*.css"
|
|
25
|
+
],
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"module": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"browser": "./dist/index.js",
|
|
33
|
+
"import": "./dist/index.js",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./tokens.css": "./dist/styles/tokens.css",
|
|
37
|
+
"./styles.css": "./dist/styles/bundle.css",
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"README.md",
|
|
43
|
+
"LICENSE"
|
|
44
|
+
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
47
|
+
"build": "node scripts/build.mjs",
|
|
48
|
+
"prepack": "npm run clean && npm run build",
|
|
49
|
+
"prepublishOnly": "npm run check",
|
|
50
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
51
|
+
"type-test": "npm run build && tsc -p tsconfig.type-tests.json",
|
|
52
|
+
"lint": "eslint src type-tests --ext .ts,.tsx --max-warnings=0",
|
|
53
|
+
"test": "jest",
|
|
54
|
+
"test:ci": "jest --watchAll=false --runInBand",
|
|
55
|
+
"pack:check": "npm pack --dry-run",
|
|
56
|
+
"verify:package": "node scripts/verify-package.mjs",
|
|
57
|
+
"consumer:check": "node scripts/verify-package.mjs --consumer",
|
|
58
|
+
"check": "npm run typecheck && npm run lint && npm run test:ci && npm run type-test && npm run verify:package"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"@codemirror/state": "^6.0.0",
|
|
62
|
+
"@codemirror/view": "^6.0.0",
|
|
63
|
+
"@preptex/core": "^0.6.2",
|
|
64
|
+
"react": ">=18 <20",
|
|
65
|
+
"react-dom": ">=18 <20"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@babel/core": "^7.28.0",
|
|
69
|
+
"@babel/preset-env": "^7.28.0",
|
|
70
|
+
"@babel/preset-react": "^7.27.1",
|
|
71
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
72
|
+
"@codemirror/state": "^6.5.2",
|
|
73
|
+
"@codemirror/view": "^6.39.4",
|
|
74
|
+
"@preptex/core": "^0.6.2",
|
|
75
|
+
"@testing-library/dom": "^10.4.1",
|
|
76
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
77
|
+
"@testing-library/react": "^16.3.1",
|
|
78
|
+
"@testing-library/user-event": "^13.5.0",
|
|
79
|
+
"@types/jest": "^27.5.2",
|
|
80
|
+
"@types/node": "^16.18.126",
|
|
81
|
+
"@types/react": "^19.2.7",
|
|
82
|
+
"@types/react-dom": "^19.2.3",
|
|
83
|
+
"babel-jest": "^27.5.1",
|
|
84
|
+
"codemirror": "^6.0.2",
|
|
85
|
+
"eslint": "^8.57.1",
|
|
86
|
+
"eslint-config-react-app": "^7.0.1",
|
|
87
|
+
"jest": "^27.5.1",
|
|
88
|
+
"jest-environment-jsdom": "^27.5.1",
|
|
89
|
+
"react": "^19.2.3",
|
|
90
|
+
"react-dom": "^19.2.3",
|
|
91
|
+
"typescript": "^4.9.5"
|
|
92
|
+
},
|
|
93
|
+
"eslintConfig": {
|
|
94
|
+
"extends": [
|
|
95
|
+
"react-app",
|
|
96
|
+
"react-app/jest"
|
|
97
|
+
],
|
|
98
|
+
"rules": {
|
|
99
|
+
"@typescript-eslint/no-explicit-any": "error"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"publishConfig": {
|
|
103
|
+
"access": "public"
|
|
104
|
+
}
|
|
105
|
+
}
|