@unbase-app/layer 0.0.0-stage → 2.0.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 +400 -2
- package/bin/unbase-layer.mjs +28 -0
- package/cli/artifact-style.mjs +89 -0
- package/cli/fetch.mjs +142 -0
- package/cli/lib.mjs +160 -0
- package/cli/live.mjs +35 -0
- package/cli/overview-artifact.mjs +142 -0
- package/cli/plan-artifact.mjs +337 -0
- package/cli/post.mjs +309 -0
- package/cli/redispatch.mjs +99 -0
- package/cli/screenshot.mjs +189 -0
- package/cli/status.mjs +50 -0
- package/cli/store.mjs +143 -0
- package/dist/client/start.d.ts +4 -0
- package/dist/client/start.js +12888 -0
- package/package.json +119 -4
- package/skills/build-comment/SKILL.md +61 -0
- package/skills/get-comments/SKILL.md +127 -0
- package/skills/process-comments/SKILL.md +115 -0
- package/skills/propose-comment/SKILL.md +79 -0
- package/src/astro/component-marker.mjs +161 -0
- package/src/astro/content-map-extra.mjs +192 -0
- package/src/astro/content-map.mjs +584 -0
- package/src/astro/deploy-context.mjs +66 -0
- package/src/astro/index.d.ts +97 -0
- package/src/astro/index.mjs +277 -0
- package/src/astro/pages.mjs +192 -0
- package/src/astro/version.mjs +13 -0
- package/src/edit/index.d.mts +178 -0
- package/src/edit/index.mjs +1002 -0
- package/src/page/index.d.mts +71 -0
- package/src/page/index.mjs +216 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
export interface EditToolsOptions {
|
|
2
|
+
/** Elements that are not the page's own (the bridge's outline, a host's UI): never text, looked through. */
|
|
3
|
+
skip?: (el: Element) => boolean;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The content map: every string in the site's content files with its JSON Pointer
|
|
8
|
+
* (src/astro/content-map.mjs). Keys are English since 1.11; `readMap` reads a map with the Dutch
|
|
9
|
+
* keys of before (still written beside the English ones, and by Unbase's read_content).
|
|
10
|
+
*/
|
|
11
|
+
export interface ContentMap {
|
|
12
|
+
v: 1;
|
|
13
|
+
content: string;
|
|
14
|
+
/** file → (JSON Pointer → value) */
|
|
15
|
+
files: Record<string, Record<string, string>>;
|
|
16
|
+
/** file → pointers that may carry <em>, <strong> and <a href> */
|
|
17
|
+
inline: Record<string, string[]>;
|
|
18
|
+
/** Lists: file → (pointer of an array → count and fingerprint) */
|
|
19
|
+
lists?: Record<string, Record<string, { n: number; h: string }>>;
|
|
20
|
+
/** file → (pointer → a value that is no string) */
|
|
21
|
+
other?: Record<string, Record<string, number | boolean | null>>;
|
|
22
|
+
/** collection → JSON Schema */
|
|
23
|
+
schemas?: Record<string, Record<string, unknown>>;
|
|
24
|
+
/** collection → the ids (and labels) for an x-ref field */
|
|
25
|
+
refs?: Record<string, { id: string; label: string }[]>;
|
|
26
|
+
/** file → collection, only where that is not the first folder under content/ */
|
|
27
|
+
collections?: Record<string, string>;
|
|
28
|
+
/** file → where it is shared ("the whole site"): one text, on many pages. */
|
|
29
|
+
shared?: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Files that are in scope on this page whatever the count of their texts on it. Whoever gives the
|
|
32
|
+
* map sometimes knows which file the page shows: Unbase's CMS names the item it has open. A vacancy
|
|
33
|
+
* has one text of its own that stands on its page as written (its role name it shares with five
|
|
34
|
+
* others), so without this name the text match ties nothing of it.
|
|
35
|
+
*/
|
|
36
|
+
scope?: string[];
|
|
37
|
+
/** The shared files with the menu's, header's and footer's text (x-interface): only those match there. */
|
|
38
|
+
interface?: string[];
|
|
39
|
+
/** Template files (a page's or a component's code, not content): their text is written in them.
|
|
40
|
+
* Unbase builds these from the repository for a site without a map of its own (read_content). */
|
|
41
|
+
templates?: string[];
|
|
42
|
+
|
|
43
|
+
/** @deprecated LEGACY-NL: `files`. */
|
|
44
|
+
bestanden?: Record<string, Record<string, string>>;
|
|
45
|
+
/** @deprecated LEGACY-NL: `lists`. */
|
|
46
|
+
lijsten?: Record<string, Record<string, { n: number; h: string }>>;
|
|
47
|
+
/** @deprecated LEGACY-NL: `other`. */
|
|
48
|
+
overig?: Record<string, Record<string, number | boolean | null>>;
|
|
49
|
+
/** @deprecated LEGACY-NL: `collections`. */
|
|
50
|
+
collecties?: Record<string, string>;
|
|
51
|
+
/** @deprecated LEGACY-NL: `shared`. */
|
|
52
|
+
gedeeld?: Record<string, string>;
|
|
53
|
+
/** @deprecated LEGACY-NL: `scope`. */
|
|
54
|
+
bereik?: string[];
|
|
55
|
+
/** @deprecated LEGACY-NL: `templates`. */
|
|
56
|
+
bron?: string[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** "src/content/verlangens/x.json#/hero/titel" */
|
|
60
|
+
export type FieldKey = string;
|
|
61
|
+
|
|
62
|
+
export interface Field {
|
|
63
|
+
key: FieldKey;
|
|
64
|
+
file: string;
|
|
65
|
+
/** The JSON Pointer in `file`. */
|
|
66
|
+
pointer: string;
|
|
67
|
+
/** The value in the content map: what is live now. */
|
|
68
|
+
value: string;
|
|
69
|
+
inline: Inline;
|
|
70
|
+
elements: HTMLElement[];
|
|
71
|
+
/** Named by data-edit, not found by its text. */
|
|
72
|
+
explicit: boolean;
|
|
73
|
+
/** From a shared file: where else the text stands ("the whole site"). */
|
|
74
|
+
shared?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type Rejection = "ambiguous" | "repeated" | "structure" | "out-of-scope";
|
|
78
|
+
|
|
79
|
+
export interface Match {
|
|
80
|
+
fields: Map<FieldKey, Field>;
|
|
81
|
+
/** element → field, for hover and click */
|
|
82
|
+
byElement: Map<HTMLElement, Field>;
|
|
83
|
+
/** This page's files. */
|
|
84
|
+
scope: string[];
|
|
85
|
+
/** Candidates that were not, and why (for the measurement). */
|
|
86
|
+
rejected: { keys: FieldKey[]; text: string; reason: Rejection; count: number }[];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** A draft as a host knows it (a row of unbase.drafts, or one not saved yet). */
|
|
90
|
+
export interface EditorDraft {
|
|
91
|
+
file: string;
|
|
92
|
+
pointer: string;
|
|
93
|
+
value: string;
|
|
94
|
+
base_value: string;
|
|
95
|
+
conflict?: string | null;
|
|
96
|
+
kind?: string | null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface EditorLock {
|
|
100
|
+
key: FieldKey;
|
|
101
|
+
name?: string;
|
|
102
|
+
initials?: string;
|
|
103
|
+
/** A CSS colour: theirs. */
|
|
104
|
+
colour?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface FieldInfo {
|
|
108
|
+
key: FieldKey;
|
|
109
|
+
file: string;
|
|
110
|
+
pointer: string;
|
|
111
|
+
inline: boolean;
|
|
112
|
+
/** Where else a shared text stands, or null. */
|
|
113
|
+
shared: string | null;
|
|
114
|
+
/** Written in a template file, not a content file. */
|
|
115
|
+
template: boolean;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type EditorEvent =
|
|
119
|
+
| { type: "fields"; count: number; files: string[]; shared: string[] }
|
|
120
|
+
| { type: "active"; field: (FieldInfo & { rect: { x: number; y: number; width: number; height: number } }) | null }
|
|
121
|
+
| { type: "change"; value: string; base: string; same: boolean; page: { path: string; title: string } } & FieldInfo
|
|
122
|
+
| { type: "done"; key: FieldKey }
|
|
123
|
+
| { type: "refused"; key: FieldKey; by: string };
|
|
124
|
+
|
|
125
|
+
export interface EditorOptions {
|
|
126
|
+
/** Everything the editor has to say: (type, data). */
|
|
127
|
+
emit?: (type: EditorEvent["type"], data: Record<string, unknown>) => void;
|
|
128
|
+
/** The outline's colour. */
|
|
129
|
+
accent?: string;
|
|
130
|
+
/** Links outside a field do nothing while the tool is on (default true). */
|
|
131
|
+
blockLinks?: boolean;
|
|
132
|
+
/** The format bar's words. */
|
|
133
|
+
labels?: { bold: string; italic: string; link: string; linkPlaceholder: string };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface Editor {
|
|
137
|
+
setMap(map: ContentMap | null): void;
|
|
138
|
+
setTool(on: boolean): void;
|
|
139
|
+
setDrafts(list: EditorDraft[]): void;
|
|
140
|
+
setPending(values: Record<FieldKey, string>): void;
|
|
141
|
+
setLocal(key: FieldKey, value: string | null): void;
|
|
142
|
+
setLocks(list: EditorLock[]): void;
|
|
143
|
+
setScale(scale: number): void;
|
|
144
|
+
show(key: FieldKey): { x: number; y: number; width: number; height: number } | null;
|
|
145
|
+
stop(): void;
|
|
146
|
+
destroy(): void;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Plain (false), inline (em, strong, a), or inline with a styled span in its value ("span"). */
|
|
150
|
+
export type Inline = boolean | "span";
|
|
151
|
+
|
|
152
|
+
export interface EditTools {
|
|
153
|
+
keyOf(file: string, pointer: string): FieldKey;
|
|
154
|
+
splitKey(key: FieldKey): { file: string; pointer: string };
|
|
155
|
+
/** The map with English keys, whether it came with those or with the Dutch ones of before 1.11. */
|
|
156
|
+
readMap(map: Partial<ContentMap> | null | undefined): ContentMap | null;
|
|
157
|
+
normalize(s: string): string;
|
|
158
|
+
visibleText(value: string, inline: boolean): string;
|
|
159
|
+
match(map: ContentMap, root?: HTMLElement): Match;
|
|
160
|
+
mergeMaps(own: ContentMap | null, found: ContentMap | null): ContentMap | null;
|
|
161
|
+
sanitize(html: string, spans?: boolean): string;
|
|
162
|
+
safeLink(href: string): boolean;
|
|
163
|
+
plainText(el: HTMLElement): string;
|
|
164
|
+
valueFrom(el: HTMLElement, inline: Inline): string;
|
|
165
|
+
setValue(el: HTMLElement, value: string, inline: Inline): void;
|
|
166
|
+
sameAs(value: string, base: string, inline: Inline): boolean;
|
|
167
|
+
caretAt(el: HTMLElement, x: number, y: number): void;
|
|
168
|
+
begin(el: HTMLElement, field: Pick<Field, "inline">, value: string, x?: number, y?: number): void;
|
|
169
|
+
end(el: HTMLElement): void;
|
|
170
|
+
listen(el: HTMLElement, field: Pick<Field, "inline" | "elements">, handlers: { input: (value: string) => void; done: () => void; holding?: () => boolean }): () => void;
|
|
171
|
+
format(command: "bold" | "italic"): void;
|
|
172
|
+
applyLink(el: HTMLElement, range: Range | null, url: string): void;
|
|
173
|
+
documentCss(accent?: string): string;
|
|
174
|
+
fieldLabel(file: string, pointer: string, base?: string): string;
|
|
175
|
+
createEditor(options: EditorOptions): Editor;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function editTools(options?: EditToolsOptions): EditTools;
|