truecanvas 0.1.0 → 0.2.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/README.md +3 -1
- package/dist/catalog-worker.js +1 -1
- package/dist/chunk-C4SATRZT.js +196 -0
- package/dist/{chunk-753N4QRO.js → chunk-T2TCBSTG.js} +18 -6
- package/dist/{chunk-WB35FXGP.js → chunk-ZPARY6OD.js} +994 -439
- package/dist/cli.js +592 -391
- package/dist/core/index.d.ts +143 -8
- package/dist/core/index.js +26 -2
- package/dist/editor/assets/Menu-BFifVcgz.js +9 -0
- package/dist/editor/assets/Menu-DXPm0EXo.css +1 -0
- package/dist/editor/assets/hub-BnbEAnt6.js +2 -0
- package/dist/editor/assets/main-DlADROMw.js +26 -0
- package/dist/editor/hub.html +3 -3
- package/dist/editor/index.html +3 -3
- package/dist/icons-worker.js +7 -0
- package/dist/next/index.d.ts +6 -1
- package/dist/next/index.js +13 -1
- package/dist/runtime/host.js +3 -1
- package/package.json +1 -1
- package/dist/editor/assets/controls-BQYSgX53.css +0 -1
- package/dist/editor/assets/controls-BYFjuGCq.js +0 -9
- package/dist/editor/assets/hub-C4_700Hv.js +0 -2
- package/dist/editor/assets/main-CfAJbDf1.js +0 -25
package/dist/core/index.d.ts
CHANGED
|
@@ -85,6 +85,11 @@ interface ImportInfo {
|
|
|
85
85
|
source: string;
|
|
86
86
|
typeOnly: boolean;
|
|
87
87
|
names: string[];
|
|
88
|
+
/** named value imports, `{ Search as SearchIcon }` → { imported: "Search", local: "SearchIcon" } */
|
|
89
|
+
bindings: {
|
|
90
|
+
imported: string;
|
|
91
|
+
local: string;
|
|
92
|
+
}[];
|
|
88
93
|
defaultName: string | null;
|
|
89
94
|
start: number;
|
|
90
95
|
end: number;
|
|
@@ -92,6 +97,8 @@ interface ImportInfo {
|
|
|
92
97
|
lastSpecifierEnd: number | null;
|
|
93
98
|
}
|
|
94
99
|
interface CanvasDoc {
|
|
100
|
+
/** increases every time a doc is computed: lets clients drop a stale one that arrives late */
|
|
101
|
+
rev?: number;
|
|
95
102
|
name: string;
|
|
96
103
|
file: string;
|
|
97
104
|
frames: CanvasFrame[];
|
|
@@ -188,7 +195,11 @@ declare class CanvasEditor {
|
|
|
188
195
|
contentStart(n: CanvasNode): number;
|
|
189
196
|
contentEnd(n: CanvasNode): number;
|
|
190
197
|
childIndent(parent: CanvasNode): string;
|
|
191
|
-
/**
|
|
198
|
+
/**
|
|
199
|
+
* Re-indents lines 2..n of a snippet so it sits at `indent`. Lines that start
|
|
200
|
+
* inside a multi-line string or template literal are content, not code: they
|
|
201
|
+
* are kept exactly as written.
|
|
202
|
+
*/
|
|
192
203
|
shift(code: string, indent: string): string;
|
|
193
204
|
private openToClose;
|
|
194
205
|
private insertAt;
|
|
@@ -205,6 +216,14 @@ declare class CanvasEditor {
|
|
|
205
216
|
replace(node: CanvasNode, jsx: string): void;
|
|
206
217
|
private added;
|
|
207
218
|
ensureImport(name: string, from: string): void;
|
|
219
|
+
/**
|
|
220
|
+
* Imports `name` from `from` and returns the local name to write in JSX. When
|
|
221
|
+
* the name is already taken by something else (another import, a local
|
|
222
|
+
* component), it is imported under `alias` instead: `{ Search as SearchIcon }`.
|
|
223
|
+
*/
|
|
224
|
+
importAs(name: string, from: string, alias: string): string;
|
|
225
|
+
private importedAs;
|
|
226
|
+
private addImportLine;
|
|
208
227
|
/** Adds a whole import statement unless every name it binds is already imported. */
|
|
209
228
|
addImportStatement(statement: string): void;
|
|
210
229
|
private importsPrepended;
|
|
@@ -332,7 +351,7 @@ declare class Comments {
|
|
|
332
351
|
|
|
333
352
|
interface GitFile {
|
|
334
353
|
path: string;
|
|
335
|
-
status: "modified" | "added" | "deleted" | "renamed" | "untracked";
|
|
354
|
+
status: "modified" | "added" | "deleted" | "renamed" | "untracked" | "conflicted";
|
|
336
355
|
staged: boolean;
|
|
337
356
|
}
|
|
338
357
|
interface GitStatus {
|
|
@@ -410,6 +429,11 @@ declare class Git {
|
|
|
410
429
|
publish(name: string, isPrivate: boolean): Promise<string>;
|
|
411
430
|
/** git reports paths from the repo root; we show them from the project root. */
|
|
412
431
|
private rel;
|
|
432
|
+
/**
|
|
433
|
+
* The project folder as git sees it: git reports real paths, so a folder
|
|
434
|
+
* reached through a symlink (macOS /var → /private/var) must be resolved too.
|
|
435
|
+
*/
|
|
436
|
+
private realCwd;
|
|
413
437
|
branches(): Promise<{
|
|
414
438
|
current: string | null;
|
|
415
439
|
local: string[];
|
|
@@ -463,6 +487,14 @@ type Command = {
|
|
|
463
487
|
component: string;
|
|
464
488
|
props?: Record<string, Literal>;
|
|
465
489
|
text?: string;
|
|
490
|
+
} | {
|
|
491
|
+
op: "insert_icon";
|
|
492
|
+
canvas: string;
|
|
493
|
+
parent: string;
|
|
494
|
+
index?: number;
|
|
495
|
+
library: string;
|
|
496
|
+
name: string;
|
|
497
|
+
className?: string;
|
|
466
498
|
} | {
|
|
467
499
|
op: "replace";
|
|
468
500
|
canvas: string;
|
|
@@ -665,7 +697,8 @@ declare class Workspace {
|
|
|
665
697
|
private sources;
|
|
666
698
|
private undoStacks;
|
|
667
699
|
private redoStacks;
|
|
668
|
-
|
|
700
|
+
/** Activity across canvases: labels only, never file copies. */
|
|
701
|
+
readonly feed: PublicEntry[];
|
|
669
702
|
private seq;
|
|
670
703
|
private queue;
|
|
671
704
|
private listeners;
|
|
@@ -684,8 +717,16 @@ declare class Workspace {
|
|
|
684
717
|
relFile(canvas: string): string;
|
|
685
718
|
read(canvas: string): string;
|
|
686
719
|
doc(canvas: string): CanvasDoc;
|
|
687
|
-
/**
|
|
720
|
+
/**
|
|
721
|
+
* A canvas doc with linked frames resolved to their page's layers. Resolving
|
|
722
|
+
* reads and parses every linked page and layout, so the result is reused
|
|
723
|
+
* until the canvas source or one of those files changes (checked with stat).
|
|
724
|
+
*/
|
|
688
725
|
docFrom(canvas: string, source: string): CanvasDoc;
|
|
726
|
+
/** a doc computed later reflects the files at least as recently: its rev is higher */
|
|
727
|
+
private revision;
|
|
728
|
+
private docCache;
|
|
729
|
+
private stamp;
|
|
689
730
|
/** Where a node's code lives: the canvas, or a linked page/layout file. */
|
|
690
731
|
nodeSource(canvas: string, id: string): {
|
|
691
732
|
node: CanvasNode;
|
|
@@ -735,11 +776,19 @@ declare class Workspace {
|
|
|
735
776
|
private routeLinked;
|
|
736
777
|
/** The page/layout file the command's layers live in, or null for the canvas. */
|
|
737
778
|
private targetOf;
|
|
779
|
+
/** Applies a command to the file being edited and returns its history label. */
|
|
738
780
|
private apply;
|
|
781
|
+
/** Edits to layers: props, text, classes, inserting, moving, wrapping. */
|
|
782
|
+
private applyLayerEdit;
|
|
783
|
+
/** Frames: creating, updating, backgrounds, presets, variant grids, main component frames. */
|
|
784
|
+
private applyFrameEdit;
|
|
785
|
+
/** Linked pages: adding a page, exploring a copy, applying it back. */
|
|
786
|
+
private applyPageEdit;
|
|
787
|
+
/** Scroll reveals and text animations. */
|
|
788
|
+
private applyMotionEdit;
|
|
789
|
+
/** New components, from scratch or from selected layers. */
|
|
790
|
+
private applyComponentEdit;
|
|
739
791
|
private autoImport;
|
|
740
|
-
private motion;
|
|
741
|
-
/** work resolved (async) in exec before the synchronous apply */
|
|
742
|
-
private pending;
|
|
743
792
|
private cleanCache;
|
|
744
793
|
isPrettierClean(source: string, file: string): Promise<boolean>;
|
|
745
794
|
/** Pretty-prints an agent's JSX snippet so it lands in the file readable. */
|
|
@@ -747,6 +796,12 @@ declare class Workspace {
|
|
|
747
796
|
private prettier;
|
|
748
797
|
format(source: string, file: string): Promise<string>;
|
|
749
798
|
private record;
|
|
799
|
+
/**
|
|
800
|
+
* Undo entries hold whole files (before and after). Keep their total under a
|
|
801
|
+
* budget by dropping the oldest entries across canvases, so long sessions on
|
|
802
|
+
* big pages don't grow without limit.
|
|
803
|
+
*/
|
|
804
|
+
private trimHistory;
|
|
750
805
|
/** Changes still in effect (not undone) on a canvas since a time, oldest first. */
|
|
751
806
|
changesSince(canvas: string, since: number): PublicEntry[];
|
|
752
807
|
historyState(canvas: string): {
|
|
@@ -817,4 +872,84 @@ declare function writeCompare(config: TruecanvasConfig, canvas: string, source:
|
|
|
817
872
|
/** Per frame: same, changed, added (only now) or removed (only before). */
|
|
818
873
|
declare function frameChanges(before: string, after: string): Record<string, "changed" | "added" | "removed" | "same">;
|
|
819
874
|
|
|
820
|
-
|
|
875
|
+
interface IconLibrary {
|
|
876
|
+
id: string;
|
|
877
|
+
label: string;
|
|
878
|
+
/** npm package to install */
|
|
879
|
+
package: string;
|
|
880
|
+
/** module the icons are imported from */
|
|
881
|
+
from: string;
|
|
882
|
+
homepage: string;
|
|
883
|
+
/** keeps one name per icon: drops aliases and non-icon exports */
|
|
884
|
+
pick: (name: string, all: Set<string>) => boolean;
|
|
885
|
+
}
|
|
886
|
+
declare const ICON_LIBRARIES: IconLibrary[];
|
|
887
|
+
declare function iconLibrary(id: string): IconLibrary | undefined;
|
|
888
|
+
interface Icon {
|
|
889
|
+
name: string;
|
|
890
|
+
svg: string;
|
|
891
|
+
}
|
|
892
|
+
/** Every icon of an installed library, from the disk cache or rendered once. */
|
|
893
|
+
declare function loadIcons(root: string, id: string): Promise<Icon[]>;
|
|
894
|
+
/**
|
|
895
|
+
* Ranks icons for a query: exact name, prefix, a near-typo of the whole name,
|
|
896
|
+
* substring; letters-in-order matches only fill in when there are few direct
|
|
897
|
+
* matches, tightest first.
|
|
898
|
+
*/
|
|
899
|
+
declare function searchIcons(icons: Icon[], query: string, limit?: number): {
|
|
900
|
+
total: number;
|
|
901
|
+
icons: Icon[];
|
|
902
|
+
};
|
|
903
|
+
/** Which icon libraries are installed, for the picker and agents. */
|
|
904
|
+
declare function iconLibraries(root: string): {
|
|
905
|
+
id: string;
|
|
906
|
+
label: string;
|
|
907
|
+
package: string;
|
|
908
|
+
from: string;
|
|
909
|
+
homepage: string;
|
|
910
|
+
version: string | null;
|
|
911
|
+
}[];
|
|
912
|
+
|
|
913
|
+
interface ShadcnStatus {
|
|
914
|
+
/** components.json exists */
|
|
915
|
+
initialized: boolean;
|
|
916
|
+
/** where components land, relative to the project */
|
|
917
|
+
uiDir: string | null;
|
|
918
|
+
/** components already in the project */
|
|
919
|
+
installed: string[];
|
|
920
|
+
}
|
|
921
|
+
declare function shadcnStatus(root: string): ShadcnStatus;
|
|
922
|
+
/** Component names from the official registry, cached for an hour. */
|
|
923
|
+
declare function shadcnRegistry(): Promise<{
|
|
924
|
+
names: string[];
|
|
925
|
+
offline: boolean;
|
|
926
|
+
}>;
|
|
927
|
+
/** `shadcn init` with the defaults (writes components.json, lib/utils, theme CSS). */
|
|
928
|
+
declare function shadcnInit(root: string): Promise<{
|
|
929
|
+
ok: boolean;
|
|
930
|
+
out: string;
|
|
931
|
+
}>;
|
|
932
|
+
/** `shadcn add <names>`; initializes the project first when needed. */
|
|
933
|
+
declare function shadcnAdd(root: string, names: string[]): Promise<{
|
|
934
|
+
ok: boolean;
|
|
935
|
+
out: string;
|
|
936
|
+
added: string[];
|
|
937
|
+
}>;
|
|
938
|
+
|
|
939
|
+
interface InitReport {
|
|
940
|
+
done: string[];
|
|
941
|
+
todo: string[];
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Sets up a Next.js project: wraps next.config, adds a `canvas` script and
|
|
945
|
+
* ignores the generated route. Every step is idempotent and reported.
|
|
946
|
+
*/
|
|
947
|
+
declare function initProject(config: TruecanvasConfig): InitReport;
|
|
948
|
+
/**
|
|
949
|
+
* Wraps a next.config's export in withTruecanvas(), touching only the exported
|
|
950
|
+
* expression: comments and code after it stay as they are. Null when the
|
|
951
|
+
* export can't be found (the user is told to wrap it by hand).
|
|
952
|
+
*/
|
|
953
|
+
declare function wrapConfigExport(src: string): string | null;
|
|
954
|
+
|
|
955
|
+
export { type Actor, type AttrRange, type CanvasDoc, CanvasEditor, type CanvasFrame, type CanvasNode, Catalog, type Command, Comments, type ComponentSpec, DEVICES, type DarkMode, type Device, EditError, type FrameLink, Git, type HistoryEntry, ICON_LIBRARIES, type Icon, type IconLibrary, type ImportInfo, type NodeKind, type Preset, type PropSpec, type PropValue, type ShadcnStatus, type TruecanvasConfig, Workspace, type WorkspaceEvent, allNodes, attrCode, componentJsx, describeComponent, findDevice, findFrame, findNode, frameChanges, iconLibraries, iconLibrary, initProject, injectIds, loadConfig, loadIcons, outlineDoc, parseCanvas, readDesignTokens, searchIcons, shadcnAdd, shadcnInit, shadcnRegistry, shadcnStatus, textCode, wrapConfigExport, writeCompare };
|
package/dist/core/index.js
CHANGED
|
@@ -14,18 +14,31 @@ import {
|
|
|
14
14
|
findNode,
|
|
15
15
|
frameChanges,
|
|
16
16
|
idOf,
|
|
17
|
+
initProject,
|
|
17
18
|
loadConfig,
|
|
18
19
|
outlineDoc,
|
|
19
20
|
parseCanvas,
|
|
20
21
|
parseModule,
|
|
21
22
|
readDesignTokens,
|
|
23
|
+
shadcnAdd,
|
|
24
|
+
shadcnInit,
|
|
25
|
+
shadcnRegistry,
|
|
26
|
+
shadcnStatus,
|
|
22
27
|
textCode,
|
|
23
28
|
walk,
|
|
29
|
+
wrapConfigExport,
|
|
24
30
|
writeCompare
|
|
25
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-ZPARY6OD.js";
|
|
26
32
|
import {
|
|
27
33
|
Catalog
|
|
28
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-T2TCBSTG.js";
|
|
35
|
+
import {
|
|
36
|
+
ICON_LIBRARIES,
|
|
37
|
+
iconLibraries,
|
|
38
|
+
iconLibrary,
|
|
39
|
+
loadIcons,
|
|
40
|
+
searchIcons
|
|
41
|
+
} from "../chunk-C4SATRZT.js";
|
|
29
42
|
|
|
30
43
|
// src/core/inject.ts
|
|
31
44
|
import MagicString from "magic-string";
|
|
@@ -52,6 +65,7 @@ export {
|
|
|
52
65
|
DEVICES,
|
|
53
66
|
EditError,
|
|
54
67
|
Git,
|
|
68
|
+
ICON_LIBRARIES,
|
|
55
69
|
Workspace,
|
|
56
70
|
allNodes,
|
|
57
71
|
attrCode,
|
|
@@ -61,11 +75,21 @@ export {
|
|
|
61
75
|
findFrame,
|
|
62
76
|
findNode,
|
|
63
77
|
frameChanges,
|
|
78
|
+
iconLibraries,
|
|
79
|
+
iconLibrary,
|
|
80
|
+
initProject,
|
|
64
81
|
injectIds,
|
|
65
82
|
loadConfig,
|
|
83
|
+
loadIcons,
|
|
66
84
|
outlineDoc,
|
|
67
85
|
parseCanvas,
|
|
68
86
|
readDesignTokens,
|
|
87
|
+
searchIcons,
|
|
88
|
+
shadcnAdd,
|
|
89
|
+
shadcnInit,
|
|
90
|
+
shadcnRegistry,
|
|
91
|
+
shadcnStatus,
|
|
69
92
|
textCode,
|
|
93
|
+
wrapConfigExport,
|
|
70
94
|
writeCompare
|
|
71
95
|
};
|