@aglyn/aglyn 1.0.0-beta.215 → 1.0.0-beta.217
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/package.json +11 -11
- package/src/lib/app-utils/deferred-image.d.ts +3 -3
- package/src/lib/app-utils/deferred-image.js +3 -3
- package/src/lib/app-utils/deferred-image.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.d.ts +2 -2
- package/src/lib/app-utils/docs-help.generated.js +2 -1
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +35 -21
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/marketplace-theme.d.ts +9 -4
- package/src/lib/app-utils/marketplace-theme.js +11 -1
- package/src/lib/app-utils/marketplace-theme.js.map +1 -1
- package/src/lib/app-utils/publisher-agreement.d.ts +36 -1
- package/src/lib/app-utils/publisher-agreement.js +48 -1
- package/src/lib/app-utils/publisher-agreement.js.map +1 -1
- package/src/lib/app-utils/realm-host-surface.generated.js +2 -0
- package/src/lib/app-utils/realm-host-surface.generated.js.map +1 -1
- package/src/lib/app-utils/theme-library.d.ts +206 -0
- package/src/lib/app-utils/theme-library.js +566 -0
- package/src/lib/app-utils/theme-library.js.map +1 -0
- package/src/lib/foundation/definitions/platform.types.js +2 -1
- package/src/lib/foundation/definitions/platform.types.js.map +1 -1
- package/src/lib/plugin-manager/feature-plugins.d.ts +44 -0
- package/src/lib/plugin-manager/feature-plugins.js +25 -0
- package/src/lib/plugin-manager/feature-plugins.js.map +1 -1
- package/src/lib/plugin-manager/first-party-plugins.generated.js +11 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
- package/src/lib/plugin-manager/plugin-services.js +20 -2
- package/src/lib/plugin-manager/plugin-services.js.map +1 -1
- package/src/lib/plugin-manager/realm-host-aglyn.generated.js +2 -0
- package/src/lib/plugin-manager/realm-host-aglyn.generated.js.map +1 -1
- package/src/lib/plugin-manager/record-captured-contact.js +12 -3
- package/src/lib/plugin-manager/record-captured-contact.js.map +1 -1
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type { HostTheme } from '@aglyn/shared-data-types';
|
|
18
|
+
import { type ThemeHostDocument } from './marketplace-theme';
|
|
19
|
+
/**
|
|
20
|
+
* A site's theme library (AGL-3404): the themes a site can switch between,
|
|
21
|
+
* and the rule that switching, editing and saving never destroy one.
|
|
22
|
+
*
|
|
23
|
+
* ## Three layers, one of them picked
|
|
24
|
+
*
|
|
25
|
+
* The site renders `theme ⊕ themeOverride` (`resolveSiteTheme`), exactly as
|
|
26
|
+
* it did before there was a library. What the library adds is WHERE `theme`
|
|
27
|
+
* came from, named by `themeSelection`:
|
|
28
|
+
*
|
|
29
|
+
* - `default` — the platform default. `theme` is empty.
|
|
30
|
+
* - `preset` — a built-in theme a plugin contributes. `theme` is a copy.
|
|
31
|
+
* - `custom` — one of the site's own saved themes, kept in the library.
|
|
32
|
+
* - `installed` — a marketplace theme, kept in the library with the
|
|
33
|
+
* provenance an update needs.
|
|
34
|
+
*
|
|
35
|
+
* Every edit is an override patch over the picked theme and never a write to
|
|
36
|
+
* it, so "Restore" is deleting the patch and the theme it restores to is
|
|
37
|
+
* still exactly the one that was picked. "Save as custom theme" copies the
|
|
38
|
+
* resolved result into a new library entry; the theme it started from stays
|
|
39
|
+
* as it was.
|
|
40
|
+
*
|
|
41
|
+
* ## Switching keeps each theme's own edits
|
|
42
|
+
*
|
|
43
|
+
* Leaving a theme stashes its override on its library entry, and coming back
|
|
44
|
+
* restores it — so trying another theme is not a way to lose work. A preset
|
|
45
|
+
* or the default has no content to keep, so its entry holds only the stash.
|
|
46
|
+
*
|
|
47
|
+
* ## The site's own settings travel with the site
|
|
48
|
+
*
|
|
49
|
+
* `darkScheme` is a decision about the site's content, not about a design
|
|
50
|
+
* (`THEME_ARTIFACT_FIELDS` says the same for publishing), so it survives every
|
|
51
|
+
* switch, save and restore: whichever theme is picked, a site that switched
|
|
52
|
+
* dark off stays light.
|
|
53
|
+
*
|
|
54
|
+
* Pure: the console route and the marketplace install route both plan here
|
|
55
|
+
* and write the plan in their own transaction, so neither can file a switch
|
|
56
|
+
* differently from the other.
|
|
57
|
+
*/
|
|
58
|
+
/** The host subcollection the library lives in. */
|
|
59
|
+
export declare const THEME_LIBRARY_COLLECTION = "themes";
|
|
60
|
+
/**
|
|
61
|
+
* The most custom themes one site keeps. A client can read the library, so an
|
|
62
|
+
* unbounded one is an unbounded read on every visit to the theme page.
|
|
63
|
+
*/
|
|
64
|
+
export declare const THEME_LIBRARY_MAX_CUSTOM = 25;
|
|
65
|
+
/** The longest name a saved theme takes. */
|
|
66
|
+
export declare const THEME_NAME_MAX = 60;
|
|
67
|
+
export type ThemeLibraryKind = 'default' | 'preset' | 'custom' | 'installed';
|
|
68
|
+
/** What `themeSelection` on a host names. */
|
|
69
|
+
export interface HostThemeSelection {
|
|
70
|
+
kind: ThemeLibraryKind;
|
|
71
|
+
/** The library entry id (or the preset's entry id). */
|
|
72
|
+
id: string;
|
|
73
|
+
/** Shown in the picker; a copy, so a renamed entry renames the selection too. */
|
|
74
|
+
name: string;
|
|
75
|
+
}
|
|
76
|
+
/** A document in `hosts/{hostId}/themes`. */
|
|
77
|
+
export interface ThemeLibraryEntry {
|
|
78
|
+
kind: ThemeLibraryKind;
|
|
79
|
+
name: string;
|
|
80
|
+
/** The theme itself, for `custom` and `installed`. Never edited in place by the editor. */
|
|
81
|
+
theme?: HostTheme | null;
|
|
82
|
+
/** The override stashed while this theme is not the picked one. */
|
|
83
|
+
override?: unknown;
|
|
84
|
+
/** Marketplace provenance, for `installed` — what `themeInstalledFrom` is restored from. */
|
|
85
|
+
installedFrom?: Record<string, unknown> | null;
|
|
86
|
+
createdAt?: unknown;
|
|
87
|
+
updatedAt?: unknown;
|
|
88
|
+
}
|
|
89
|
+
/** The entry id the platform default's stash lives under. */
|
|
90
|
+
export declare const DEFAULT_THEME_ENTRY_ID = "default";
|
|
91
|
+
/**
|
|
92
|
+
* The entry id a pre-library site's own theme is filed under when it first
|
|
93
|
+
* leaves it. Before the library a site had exactly one theme of its own, so
|
|
94
|
+
* a fixed id cannot collide with another.
|
|
95
|
+
*/
|
|
96
|
+
export declare const SITE_THEME_ENTRY_ID = "site-theme";
|
|
97
|
+
/** The default's name when nothing else names it. */
|
|
98
|
+
export declare const DEFAULT_THEME_NAME = "Material UI";
|
|
99
|
+
/** A preset's entry id, which holds only its stash. */
|
|
100
|
+
export declare function presetEntryId(presetId: string): string;
|
|
101
|
+
/** A marketplace theme's entry id: one per listing, so reinstalling updates it. */
|
|
102
|
+
export declare function installedEntryId(listingId: string): string;
|
|
103
|
+
/** A host document as the library reads it. */
|
|
104
|
+
export interface ThemeLibraryHost extends ThemeHostDocument {
|
|
105
|
+
themeSelection?: unknown;
|
|
106
|
+
themeInstalledFrom?: ({
|
|
107
|
+
sha256?: string | null;
|
|
108
|
+
listingId?: string;
|
|
109
|
+
name?: string;
|
|
110
|
+
} & Record<string, unknown>) | null;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The theme a site has picked.
|
|
114
|
+
*
|
|
115
|
+
* A site from before the library has no `themeSelection`, and reads as what
|
|
116
|
+
* it was: a marketplace theme, its own theme, or the default. That is what
|
|
117
|
+
* lets the library ship without touching a single existing host document.
|
|
118
|
+
*/
|
|
119
|
+
export declare function readThemeSelection(host: ThemeLibraryHost | null | undefined): HostThemeSelection;
|
|
120
|
+
/** A name as stored: trimmed, bounded, and never empty. */
|
|
121
|
+
export declare function normalizeThemeName(name: unknown): string | null;
|
|
122
|
+
/** Marks a field for deletion; the route writing the plan maps it to its store's delete. */
|
|
123
|
+
export declare const THEME_FIELD_DELETE = "__aglynThemeFieldDelete";
|
|
124
|
+
export type ThemeLibraryEntryWrite = {
|
|
125
|
+
id: string;
|
|
126
|
+
op: 'create';
|
|
127
|
+
data: ThemeLibraryEntry;
|
|
128
|
+
} | {
|
|
129
|
+
id: string;
|
|
130
|
+
op: 'update';
|
|
131
|
+
data: Record<string, unknown>;
|
|
132
|
+
} | {
|
|
133
|
+
id: string;
|
|
134
|
+
op: 'delete';
|
|
135
|
+
};
|
|
136
|
+
export type ThemeLibraryPlan = {
|
|
137
|
+
ok: true;
|
|
138
|
+
/**
|
|
139
|
+
* Host fields to replace WHOLESALE (`update`, never a deep merge: a
|
|
140
|
+
* merged override is the union of two patches, and a merged theme keeps
|
|
141
|
+
* the tokens of the one it replaced).
|
|
142
|
+
*/
|
|
143
|
+
host: Record<string, unknown>;
|
|
144
|
+
entries: ThemeLibraryEntryWrite[];
|
|
145
|
+
/** The theme picked once the plan is written. */
|
|
146
|
+
selection: HostThemeSelection;
|
|
147
|
+
} | {
|
|
148
|
+
ok: false;
|
|
149
|
+
status: number;
|
|
150
|
+
error: string;
|
|
151
|
+
};
|
|
152
|
+
export type ThemeLibraryTarget = {
|
|
153
|
+
kind: 'default';
|
|
154
|
+
}
|
|
155
|
+
/** A plugin's theme, sent by the console that listed it. */
|
|
156
|
+
| {
|
|
157
|
+
kind: 'preset';
|
|
158
|
+
id: string;
|
|
159
|
+
name: string;
|
|
160
|
+
theme: HostTheme;
|
|
161
|
+
} | {
|
|
162
|
+
kind: 'custom' | 'installed';
|
|
163
|
+
id: string;
|
|
164
|
+
};
|
|
165
|
+
export type ThemeLibraryAction = {
|
|
166
|
+
action: 'select';
|
|
167
|
+
target: ThemeLibraryTarget;
|
|
168
|
+
} | {
|
|
169
|
+
action: 'save-as';
|
|
170
|
+
name: string;
|
|
171
|
+
} | {
|
|
172
|
+
action: 'update';
|
|
173
|
+
} | {
|
|
174
|
+
action: 'restore';
|
|
175
|
+
} | {
|
|
176
|
+
action: 'rename';
|
|
177
|
+
id: string;
|
|
178
|
+
name: string;
|
|
179
|
+
} | {
|
|
180
|
+
action: 'delete';
|
|
181
|
+
id: string;
|
|
182
|
+
} | {
|
|
183
|
+
action: 'install';
|
|
184
|
+
listingId: string;
|
|
185
|
+
name: string;
|
|
186
|
+
theme: HostTheme;
|
|
187
|
+
installedFrom: Record<string, unknown>;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Plans one library action against the host document and its library as
|
|
191
|
+
* read in the same transaction.
|
|
192
|
+
*
|
|
193
|
+
* `newId` mints a library entry id for a new custom theme.
|
|
194
|
+
*/
|
|
195
|
+
export declare function planThemeLibraryAction(input: {
|
|
196
|
+
host: ThemeLibraryHost | null | undefined;
|
|
197
|
+
entries: Readonly<Record<string, ThemeLibraryEntry>>;
|
|
198
|
+
action: ThemeLibraryAction;
|
|
199
|
+
newId: () => string;
|
|
200
|
+
}): ThemeLibraryPlan;
|
|
201
|
+
/**
|
|
202
|
+
* Whether the picked theme carries edits of this site's own — what "Restore"
|
|
203
|
+
* and "Update" act on. The site's dark-scheme setting is not an edit to the
|
|
204
|
+
* theme, so an override holding only that does not count.
|
|
205
|
+
*/
|
|
206
|
+
export declare function hasThemeEdits(host: ThemeLibraryHost | null | undefined): boolean;
|