@pure-ds/core 0.6.10 → 0.7.1
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/.github/copilot-instructions.md +6 -1
- package/custom-elements.json +803 -16
- package/dist/types/pds.d.ts +1 -0
- package/dist/types/public/assets/js/pds-ask.d.ts +2 -0
- package/dist/types/public/assets/js/pds-ask.d.ts.map +1 -0
- package/dist/types/public/assets/js/pds-auto-definer.d.ts +14 -0
- package/dist/types/public/assets/js/pds-auto-definer.d.ts.map +1 -0
- package/dist/types/public/assets/js/pds-autocomplete.d.ts +79 -0
- package/dist/types/public/assets/js/pds-autocomplete.d.ts.map +1 -0
- package/dist/types/public/assets/js/pds-enhancers.d.ts +7 -0
- package/dist/types/public/assets/js/pds-enhancers.d.ts.map +1 -0
- package/dist/types/public/assets/js/pds-manager.d.ts +98 -1
- package/dist/types/public/assets/js/pds-manager.d.ts.map +1 -1
- package/dist/types/public/assets/js/pds-toast.d.ts +8 -0
- package/dist/types/public/assets/js/pds-toast.d.ts.map +1 -0
- package/dist/types/public/assets/js/pds.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-drawer.d.ts +1 -143
- package/dist/types/public/assets/pds/components/pds-drawer.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-form.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-icon.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-live-converter.d.ts +8 -0
- package/dist/types/public/assets/pds/components/pds-live-converter.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-live-importer.d.ts +2 -0
- package/dist/types/public/assets/pds/components/pds-live-importer.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-live-template-canvas.d.ts +2 -0
- package/dist/types/public/assets/pds/components/pds-live-template-canvas.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-omnibox.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-richtext.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-scrollrow.d.ts +1 -63
- package/dist/types/public/assets/pds/components/pds-scrollrow.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-splitpanel.d.ts +1 -89
- package/dist/types/public/assets/pds/components/pds-splitpanel.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-theme.d.ts +1 -22
- package/dist/types/public/assets/pds/components/pds-theme.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-toaster.d.ts +1 -1
- package/dist/types/public/assets/pds/components/pds-toaster.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-treeview.d.ts +37 -0
- package/dist/types/public/assets/pds/components/pds-treeview.d.ts.map +1 -0
- package/dist/types/public/assets/pds/components/pds-upload.d.ts.map +1 -1
- package/dist/types/src/js/common/ask.d.ts.map +1 -1
- package/dist/types/src/js/common/toast.d.ts +8 -0
- package/dist/types/src/js/common/toast.d.ts.map +1 -1
- package/dist/types/src/js/pds-ask.d.ts +2 -0
- package/dist/types/src/js/pds-ask.d.ts.map +1 -0
- package/dist/types/src/js/pds-auto-definer.d.ts +2 -0
- package/dist/types/src/js/pds-auto-definer.d.ts.map +1 -0
- package/dist/types/src/js/pds-autocomplete.d.ts +2 -0
- package/dist/types/src/js/pds-autocomplete.d.ts.map +1 -0
- package/dist/types/src/js/pds-core/pds-enhancers.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-generator.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-live.d.ts +2 -1
- package/dist/types/src/js/pds-core/pds-live.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-start-helpers.d.ts.map +1 -1
- package/dist/types/src/js/pds-enhancers.d.ts +2 -0
- package/dist/types/src/js/pds-enhancers.d.ts.map +1 -0
- package/dist/types/src/js/pds-live-manager/conversion-service.d.ts +66 -0
- package/dist/types/src/js/pds-live-manager/conversion-service.d.ts.map +1 -0
- package/dist/types/src/js/pds-live-manager/import-contract.d.ts +15 -0
- package/dist/types/src/js/pds-live-manager/import-contract.d.ts.map +1 -0
- package/dist/types/src/js/pds-live-manager/import-history-service.d.ts +32 -0
- package/dist/types/src/js/pds-live-manager/import-history-service.d.ts.map +1 -0
- package/dist/types/src/js/pds-live-manager/import-service.d.ts +21 -0
- package/dist/types/src/js/pds-live-manager/import-service.d.ts.map +1 -0
- package/dist/types/src/js/pds-live-manager/template-service.d.ts +17 -0
- package/dist/types/src/js/pds-live-manager/template-service.d.ts.map +1 -0
- package/dist/types/src/js/pds-manager.d.ts +4 -0
- package/dist/types/src/js/pds-toast.d.ts +2 -0
- package/dist/types/src/js/pds-toast.d.ts.map +1 -0
- package/dist/types/src/js/pds.d.ts.map +1 -1
- package/package.json +11 -5
- package/packages/pds-cli/README.md +60 -0
- package/packages/pds-cli/bin/pds-import.js +176 -0
- package/packages/pds-cli/bin/pds-static.js +27 -1
- package/packages/pds-cli/bin/postinstall.mjs +17 -8
- package/packages/pds-cli/bin/templates/bootstrap/pds.config.js +1 -5
- package/packages/pds-cli/bin/templates/bootstrap/public/index.html +2 -1
- package/packages/pds-cli/bin/templates/starter-templates.js +1 -3
- package/public/assets/js/app.js +9 -163
- package/public/assets/js/pds-ask.js +25 -0
- package/public/assets/js/pds-auto-definer.js +1 -0
- package/public/assets/js/pds-autocomplete.js +7 -0
- package/public/assets/js/pds-enhancers.js +1 -0
- package/public/assets/js/pds-manager.js +370 -267
- package/public/assets/js/pds-toast.js +1 -0
- package/public/assets/js/pds.js +2 -32
- package/public/assets/pds/components/pds-calendar.js +2 -2
- package/public/assets/pds/components/pds-drawer.js +1 -1
- package/public/assets/pds/components/pds-form.js +7 -6
- package/public/assets/pds/components/pds-icon.js +12 -9
- package/public/assets/pds/components/pds-live-converter.js +47 -0
- package/public/assets/pds/components/pds-live-edit.js +758 -44
- package/public/assets/pds/components/pds-live-importer.js +773 -0
- package/public/assets/pds/components/pds-live-template-canvas.js +172 -0
- package/public/assets/pds/components/pds-omnibox.js +147 -3
- package/public/assets/pds/components/pds-richtext.js +2 -0
- package/public/assets/pds/components/pds-scrollrow.js +61 -2
- package/public/assets/pds/components/pds-splitpanel.js +3 -1
- package/public/assets/pds/components/pds-theme.js +2 -0
- package/public/assets/pds/components/pds-toaster.js +52 -5
- package/public/assets/pds/components/pds-treeview.js +974 -0
- package/public/assets/pds/components/pds-upload.js +2 -0
- package/public/assets/pds/core/pds-ask.js +25 -0
- package/public/assets/pds/core/pds-auto-definer.js +1 -0
- package/public/assets/pds/core/pds-autocomplete.js +7 -0
- package/public/assets/pds/core/pds-enhancers.js +1 -0
- package/public/assets/pds/core/pds-manager.js +3646 -0
- package/public/assets/pds/core/pds-toast.js +1 -0
- package/public/assets/pds/core.js +2 -0
- package/public/assets/pds/custom-elements.json +803 -16
- package/public/assets/pds/pds-css-complete.json +7 -2
- package/public/assets/pds/templates/commerce-scroll-explorer.html +115 -0
- package/public/assets/pds/templates/content-brand-showcase.html +110 -0
- package/public/assets/pds/templates/feedback-ops-dashboard.html +91 -0
- package/public/assets/pds/templates/release-readiness-radar.html +69 -0
- package/public/assets/pds/templates/support-command-center.html +92 -0
- package/public/assets/pds/templates/templates.json +53 -0
- package/public/assets/pds/templates/workspace-settings-lab.html +131 -0
- package/public/assets/pds/vscode-custom-data.json +54 -4
- package/readme.md +38 -1
- package/src/js/pds-core/pds-config.js +9 -9
- package/src/js/pds-core/pds-enhancers.js +146 -0
- package/src/js/pds-core/pds-generator.js +170 -29
- package/src/js/pds-core/pds-live.js +456 -13
- package/src/js/pds-core/pds-start-helpers.js +5 -1
- package/src/js/pds-live-manager/conversion-service.js +3135 -0
- package/src/js/pds-live-manager/import-contract.js +57 -0
- package/src/js/pds-live-manager/import-history-service.js +145 -0
- package/src/js/pds-live-manager/import-service.js +255 -0
- package/src/js/pds-live-manager/tailwind-conversion-rules.json +383 -0
- package/src/js/pds-live-manager/template-service.js +170 -0
- package/src/js/pds.d.ts +1 -0
- package/src/js/pds.js +192 -12
|
@@ -39,6 +39,432 @@ import {
|
|
|
39
39
|
let __liveApiReady = false;
|
|
40
40
|
let __queryClass = null;
|
|
41
41
|
|
|
42
|
+
const LIVE_EDIT_TOGGLE_ID = "pds-live-edit-toggle";
|
|
43
|
+
const LIVE_EDIT_TOGGLE_STYLE_ID = "pds-live-edit-toggle-style";
|
|
44
|
+
|
|
45
|
+
function whenDocumentBodyReady(callback) {
|
|
46
|
+
if (typeof document === "undefined" || typeof callback !== "function") return;
|
|
47
|
+
if (document.body) {
|
|
48
|
+
callback();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const onReady = () => {
|
|
53
|
+
if (!document.body) return;
|
|
54
|
+
document.removeEventListener("DOMContentLoaded", onReady);
|
|
55
|
+
callback();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
document.addEventListener("DOMContentLoaded", onReady, { once: true });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function mountLiveEdit(options = {}) {
|
|
62
|
+
const interactive = options?.interactive !== false;
|
|
63
|
+
if (typeof document === "undefined") return;
|
|
64
|
+
whenDocumentBodyReady(() => {
|
|
65
|
+
if (!document.querySelector("pds-live-edit")) {
|
|
66
|
+
const liveEditor = document.createElement("pds-live-edit");
|
|
67
|
+
if (!interactive) {
|
|
68
|
+
liveEditor.setAttribute("data-pds-live-settings-only", "true");
|
|
69
|
+
}
|
|
70
|
+
document.body.appendChild(liveEditor);
|
|
71
|
+
} else if (!interactive) {
|
|
72
|
+
const existing = document.querySelector("pds-live-edit");
|
|
73
|
+
if (existing) {
|
|
74
|
+
existing.setAttribute("data-pds-live-settings-only", "true");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function waitFor(ms = 0) {
|
|
81
|
+
return new Promise((resolve) => {
|
|
82
|
+
setTimeout(resolve, Math.max(0, Number(ms) || 0));
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function ensureLiveEditInstance(options = {}) {
|
|
87
|
+
const mountIfMissing = options?.mountIfMissing !== false;
|
|
88
|
+
const interactive = options?.interactive !== false;
|
|
89
|
+
const requiredMethod =
|
|
90
|
+
typeof options?.requiredMethod === "string" && options.requiredMethod.trim()
|
|
91
|
+
? options.requiredMethod.trim()
|
|
92
|
+
: "openDesignSettings";
|
|
93
|
+
const timeoutMs = Number.isFinite(Number(options?.timeoutMs))
|
|
94
|
+
? Number(options.timeoutMs)
|
|
95
|
+
: 2400;
|
|
96
|
+
|
|
97
|
+
if (typeof document === "undefined") return null;
|
|
98
|
+
if (!mountIfMissing && !document.querySelector("pds-live-edit")) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
if (mountIfMissing) {
|
|
102
|
+
mountLiveEdit({ interactive });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const startedAt = Date.now();
|
|
106
|
+
while (Date.now() - startedAt < timeoutMs) {
|
|
107
|
+
const liveEditor = document.querySelector("pds-live-edit");
|
|
108
|
+
if (!liveEditor) {
|
|
109
|
+
await waitFor(40);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (typeof liveEditor?.[requiredMethod] === "function") {
|
|
114
|
+
return liveEditor;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (
|
|
118
|
+
typeof customElements !== "undefined" &&
|
|
119
|
+
typeof customElements.whenDefined === "function"
|
|
120
|
+
) {
|
|
121
|
+
try {
|
|
122
|
+
await Promise.race([customElements.whenDefined("pds-live-edit"), waitFor(80)]);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
await waitFor(40);
|
|
125
|
+
}
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
await waitFor(40);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const fallback = document.querySelector("pds-live-edit");
|
|
133
|
+
if (fallback && typeof fallback?.[requiredMethod] === "function") {
|
|
134
|
+
return fallback;
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function unmountLiveEdit() {
|
|
140
|
+
if (typeof document === "undefined") return;
|
|
141
|
+
const editors = document.querySelectorAll("pds-live-edit");
|
|
142
|
+
editors.forEach((editor) => {
|
|
143
|
+
if (typeof editor?.setInteractiveEditingEnabled === "function") {
|
|
144
|
+
editor.setInteractiveEditingEnabled(false);
|
|
145
|
+
}
|
|
146
|
+
editor.remove();
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function getLiveEditInteractiveState(liveEditor) {
|
|
151
|
+
if (!liveEditor) return false;
|
|
152
|
+
if (typeof liveEditor.isInteractiveEditingEnabled === "function") {
|
|
153
|
+
return Boolean(liveEditor.isInteractiveEditingEnabled());
|
|
154
|
+
}
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function ensureLiveEditToggleStyles() {
|
|
159
|
+
if (typeof document === "undefined") return;
|
|
160
|
+
if (document.getElementById(LIVE_EDIT_TOGGLE_STYLE_ID)) return;
|
|
161
|
+
|
|
162
|
+
const style = document.createElement("style");
|
|
163
|
+
style.id = LIVE_EDIT_TOGGLE_STYLE_ID;
|
|
164
|
+
style.textContent = /*css*/`
|
|
165
|
+
:where(.pds-live-edit-toggle-nav) {
|
|
166
|
+
position: fixed;
|
|
167
|
+
top: var(--spacing-3);
|
|
168
|
+
right: var(--spacing-3);
|
|
169
|
+
z-index: var(--z-dropdown, 1050);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
:where(.pds-live-edit-toggle-nav menu) {
|
|
173
|
+
min-width: 220px;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
:where(.pds-live-edit-toggle-nav menu a[data-pds-live-action]) {
|
|
177
|
+
cursor: pointer;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
:where(.pds-live-edit-toggle-nav menu li.pds-live-shared-quick-mode-item) {
|
|
181
|
+
list-style: none;
|
|
182
|
+
margin: 0;
|
|
183
|
+
padding: 0;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
:where(.pds-live-edit-toggle-nav menu li.pds-live-shared-quick-mode-item .pds-live-editor-menu) {
|
|
187
|
+
display: grid;
|
|
188
|
+
gap: var(--spacing-2);
|
|
189
|
+
padding: var(--spacing-2);
|
|
190
|
+
border-bottom: var(--border-width-thin) solid var(--color-border);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
:where(.pds-live-edit-toggle-nav menu li.pds-live-shared-quick-mode-item label) {
|
|
194
|
+
display: grid;
|
|
195
|
+
gap: var(--spacing-1);
|
|
196
|
+
margin: 0;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
:where(.pds-live-edit-toggle-nav menu li.pds-live-shared-quick-mode-item label > span) {
|
|
200
|
+
font-size: var(--font-size-xs);
|
|
201
|
+
color: var(--color-text-muted);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
:where(.pds-live-edit-toggle-nav menu li > hr) {
|
|
205
|
+
border: 0;
|
|
206
|
+
border-top: var(--border-width-thin) solid var(--color-border);
|
|
207
|
+
margin: var(--spacing-2) 0 var(--spacing-1) 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
:where(.pds-live-edit-toggle-nav menu li:has(> hr)) {
|
|
211
|
+
padding: 0;
|
|
212
|
+
margin: 0;
|
|
213
|
+
list-style: none;
|
|
214
|
+
pointer-events: none;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
:where(.pds-live-edit-toggle-nav menu a[data-pds-live-action="reset-config"]) {
|
|
218
|
+
color: var(--color-danger-700);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
:where(.pds-live-edit-toggle-nav menu a[data-pds-live-action="reset-config"] pds-icon) {
|
|
222
|
+
color: var(--color-danger-700);
|
|
223
|
+
}
|
|
224
|
+
`;
|
|
225
|
+
document.head.appendChild(style);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function updateLiveEditToggleState(button, isEnabled) {
|
|
229
|
+
if (!button) return;
|
|
230
|
+
|
|
231
|
+
button.classList.toggle("btn-primary", isEnabled);
|
|
232
|
+
button.classList.toggle("btn-secondary", !isEnabled);
|
|
233
|
+
button.setAttribute("aria-pressed", isEnabled ? "true" : "false");
|
|
234
|
+
|
|
235
|
+
const label = "PDS Manager";
|
|
236
|
+
button.setAttribute("aria-label", label);
|
|
237
|
+
button.setAttribute("title", label);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
async function ensureLiveEditToggleButton() {
|
|
241
|
+
if (typeof document === "undefined") return null;
|
|
242
|
+
|
|
243
|
+
ensureLiveEditToggleStyles();
|
|
244
|
+
|
|
245
|
+
let button = document.getElementById(LIVE_EDIT_TOGGLE_ID);
|
|
246
|
+
if (!button) {
|
|
247
|
+
const nav = document.createElement("nav");
|
|
248
|
+
nav.className = "pds-live-edit-toggle-nav";
|
|
249
|
+
nav.setAttribute("data-dropdown", "");
|
|
250
|
+
nav.setAttribute("data-mode", "auto");
|
|
251
|
+
nav.setAttribute("data-pds-live-edit-ignore", "true");
|
|
252
|
+
|
|
253
|
+
button = document.createElement("button");
|
|
254
|
+
button.id = LIVE_EDIT_TOGGLE_ID;
|
|
255
|
+
button.type = "button";
|
|
256
|
+
button.className = "icon-only btn-secondary";
|
|
257
|
+
button.setAttribute("data-pds-live-edit-ignore", "true");
|
|
258
|
+
button.innerHTML = '<pds-icon icon="cursor-click" size="sm"></pds-icon>';
|
|
259
|
+
|
|
260
|
+
const menu = document.createElement("menu");
|
|
261
|
+
menu.setAttribute("data-pds-live-edit-ignore", "true");
|
|
262
|
+
|
|
263
|
+
const createItem = (action, label, icon) => {
|
|
264
|
+
const li = document.createElement("li");
|
|
265
|
+
const link = document.createElement("a");
|
|
266
|
+
link.href = "#";
|
|
267
|
+
link.dataset.pdsLiveAction = action;
|
|
268
|
+
link.setAttribute("data-pds-live-edit-ignore", "true");
|
|
269
|
+
|
|
270
|
+
const iconEl = document.createElement("pds-icon");
|
|
271
|
+
iconEl.setAttribute("icon", icon);
|
|
272
|
+
iconEl.setAttribute("size", "sm");
|
|
273
|
+
|
|
274
|
+
link.append(iconEl, document.createTextNode(` ${label}`));
|
|
275
|
+
li.appendChild(link);
|
|
276
|
+
return li;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const createSeparator = () => {
|
|
280
|
+
const li = document.createElement("li");
|
|
281
|
+
li.setAttribute("data-pds-live-edit-ignore", "true");
|
|
282
|
+
const hr = document.createElement("hr");
|
|
283
|
+
hr.setAttribute("aria-hidden", "true");
|
|
284
|
+
li.appendChild(hr);
|
|
285
|
+
return li;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
menu.appendChild(createItem("toggle", "Toggle live editing", "pencil"));
|
|
289
|
+
menu.appendChild(createItem("open-settings", "Open Settings", "gear"));
|
|
290
|
+
menu.appendChild(createSeparator());
|
|
291
|
+
menu.appendChild(createItem("reset-config", "Reset Config", "arrow-counter-clockwise"));
|
|
292
|
+
|
|
293
|
+
await ensureSharedQuickModeToggleMenuItem(menu);
|
|
294
|
+
|
|
295
|
+
nav.append(button, menu);
|
|
296
|
+
|
|
297
|
+
whenDocumentBodyReady(() => {
|
|
298
|
+
if (!document.getElementById(LIVE_EDIT_TOGGLE_ID)) {
|
|
299
|
+
document.body.appendChild(nav);
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return button;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
async function ensureSharedQuickModeToggleMenuItem(menu) {
|
|
308
|
+
if (!(menu instanceof Element)) return;
|
|
309
|
+
if (menu.__pdsLiveSharedMenuItemInFlight) {
|
|
310
|
+
return menu.__pdsLiveSharedMenuItemInFlight;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
menu.__pdsLiveSharedMenuItemInFlight = (async () => {
|
|
314
|
+
menu
|
|
315
|
+
.querySelectorAll("li.pds-live-shared-quick-mode-item")
|
|
316
|
+
.forEach((node) => node.remove());
|
|
317
|
+
|
|
318
|
+
const liveEditor = await ensureLiveEditInstance({
|
|
319
|
+
mountIfMissing: true,
|
|
320
|
+
interactive: false,
|
|
321
|
+
requiredMethod: "createSharedQuickModeMenuItem",
|
|
322
|
+
timeoutMs: 7000,
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
if (!liveEditor || typeof liveEditor.createSharedQuickModeMenuItem !== "function") {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const sharedItem = await liveEditor.createSharedQuickModeMenuItem();
|
|
330
|
+
if (!(sharedItem instanceof Element)) return;
|
|
331
|
+
|
|
332
|
+
sharedItem.classList.add("pds-live-shared-quick-mode-item");
|
|
333
|
+
|
|
334
|
+
const resetLink = menu.querySelector('a[data-pds-live-action="reset-config"]');
|
|
335
|
+
const resetItem = resetLink?.closest("li") || null;
|
|
336
|
+
const previousItem = resetItem?.previousElementSibling || null;
|
|
337
|
+
const separatorBeforeReset =
|
|
338
|
+
previousItem && previousItem.querySelector?.(":scope > hr") ? previousItem : null;
|
|
339
|
+
|
|
340
|
+
if (separatorBeforeReset) {
|
|
341
|
+
menu.insertBefore(sharedItem, separatorBeforeReset);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (resetItem) {
|
|
346
|
+
menu.insertBefore(sharedItem, resetItem);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
menu.appendChild(sharedItem);
|
|
351
|
+
})();
|
|
352
|
+
|
|
353
|
+
try {
|
|
354
|
+
await menu.__pdsLiveSharedMenuItemInFlight;
|
|
355
|
+
} finally {
|
|
356
|
+
menu.__pdsLiveSharedMenuItemInFlight = null;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function teardownLiveEditToggle() {
|
|
361
|
+
if (typeof document === "undefined") return;
|
|
362
|
+
const button = document.getElementById(LIVE_EDIT_TOGGLE_ID);
|
|
363
|
+
if (button) {
|
|
364
|
+
const nav = button.closest(".pds-live-edit-toggle-nav");
|
|
365
|
+
if (nav) {
|
|
366
|
+
nav.remove();
|
|
367
|
+
} else {
|
|
368
|
+
button.remove();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
const style = document.getElementById(LIVE_EDIT_TOGGLE_STYLE_ID);
|
|
372
|
+
if (style) style.remove();
|
|
373
|
+
unmountLiveEdit();
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
async function initializeLiveEditToggle() {
|
|
377
|
+
if (typeof document === "undefined") return;
|
|
378
|
+
const toggleButton = await ensureLiveEditToggleButton();
|
|
379
|
+
if (!toggleButton) return;
|
|
380
|
+
|
|
381
|
+
const setLiveEditEnabled = async (enabled) => {
|
|
382
|
+
if (enabled) {
|
|
383
|
+
const liveEditor = await ensureLiveEditInstance({ mountIfMissing: true });
|
|
384
|
+
if (liveEditor && typeof liveEditor.setInteractiveEditingEnabled === "function") {
|
|
385
|
+
liveEditor.setInteractiveEditingEnabled(true);
|
|
386
|
+
}
|
|
387
|
+
} else {
|
|
388
|
+
unmountLiveEdit();
|
|
389
|
+
}
|
|
390
|
+
updateLiveEditToggleState(toggleButton, enabled);
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
void setLiveEditEnabled(false);
|
|
394
|
+
|
|
395
|
+
const actionHost = toggleButton.closest(".pds-live-edit-toggle-nav") || toggleButton;
|
|
396
|
+
if (toggleButton.__pdsLiveEditActionHandler) {
|
|
397
|
+
actionHost.removeEventListener("click", toggleButton.__pdsLiveEditActionHandler);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const actionHandler = async (event) => {
|
|
401
|
+
const actionElement = event.target?.closest?.("[data-pds-live-action]");
|
|
402
|
+
if (!actionElement) return;
|
|
403
|
+
|
|
404
|
+
event.preventDefault();
|
|
405
|
+
const action = String(actionElement.dataset.pdsLiveAction || "");
|
|
406
|
+
|
|
407
|
+
if (action === "toggle") {
|
|
408
|
+
const liveEditor = await ensureLiveEditInstance({ mountIfMissing: false });
|
|
409
|
+
const isEnabled = getLiveEditInteractiveState(liveEditor);
|
|
410
|
+
await setLiveEditEnabled(!isEnabled);
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (action === "open-settings") {
|
|
415
|
+
const liveEditor = await ensureLiveEditInstance({
|
|
416
|
+
mountIfMissing: true,
|
|
417
|
+
requiredMethod: "openDesignSettings",
|
|
418
|
+
interactive: false,
|
|
419
|
+
});
|
|
420
|
+
if (liveEditor && typeof liveEditor.setInteractiveEditingEnabled === "function") {
|
|
421
|
+
liveEditor.setInteractiveEditingEnabled(false);
|
|
422
|
+
}
|
|
423
|
+
if (liveEditor && typeof liveEditor.openDesignSettings === "function") {
|
|
424
|
+
updateLiveEditToggleState(toggleButton, false);
|
|
425
|
+
await liveEditor.openDesignSettings();
|
|
426
|
+
}
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
if (action === "reset-config") {
|
|
431
|
+
const liveEditor = await ensureLiveEditInstance({
|
|
432
|
+
mountIfMissing: true,
|
|
433
|
+
requiredMethod: "resetConfig",
|
|
434
|
+
interactive: false,
|
|
435
|
+
});
|
|
436
|
+
updateLiveEditToggleState(toggleButton, false);
|
|
437
|
+
if (liveEditor && typeof liveEditor.resetConfig === "function") {
|
|
438
|
+
await liveEditor.resetConfig();
|
|
439
|
+
}
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
toggleButton.__pdsLiveEditActionHandler = actionHandler;
|
|
445
|
+
actionHost.addEventListener("click", actionHandler);
|
|
446
|
+
|
|
447
|
+
if (toggleButton.__pdsLiveEditDisableHandler) {
|
|
448
|
+
document.removeEventListener("pds:live-edit:disable", toggleButton.__pdsLiveEditDisableHandler);
|
|
449
|
+
}
|
|
450
|
+
if (toggleButton.__pdsLiveEditEnableHandler) {
|
|
451
|
+
document.removeEventListener("pds:live-edit:enable", toggleButton.__pdsLiveEditEnableHandler);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
const disableHandler = () => {
|
|
455
|
+
void setLiveEditEnabled(false);
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
const enableHandler = () => {
|
|
459
|
+
void setLiveEditEnabled(true);
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
toggleButton.__pdsLiveEditDisableHandler = disableHandler;
|
|
463
|
+
document.addEventListener("pds:live-edit:disable", disableHandler);
|
|
464
|
+
toggleButton.__pdsLiveEditEnableHandler = enableHandler;
|
|
465
|
+
document.addEventListener("pds:live-edit:enable", enableHandler);
|
|
466
|
+
}
|
|
467
|
+
|
|
42
468
|
function getStoredLiveConfig() {
|
|
43
469
|
if (typeof window === "undefined" || !window.localStorage) return null;
|
|
44
470
|
try {
|
|
@@ -238,7 +664,7 @@ function buildPresetOmniboxSettings(PDS, options = {}) {
|
|
|
238
664
|
};
|
|
239
665
|
}
|
|
240
666
|
|
|
241
|
-
async function __attachLiveAPIs(PDS, { applyResolvedTheme, setupSystemListenerIfNeeded }) {
|
|
667
|
+
async function __attachLiveAPIs(PDS, { applyResolvedTheme, setupSystemListenerIfNeeded, emitConfigChanged }) {
|
|
242
668
|
if (__liveApiReady) return;
|
|
243
669
|
|
|
244
670
|
const [ontologyModule, enumsModule, queryModule, commonModule] =
|
|
@@ -268,7 +694,14 @@ async function __attachLiveAPIs(PDS, { applyResolvedTheme, setupSystemListenerIf
|
|
|
268
694
|
PDS.getConfigEditorMetadata = getDesignConfigEditorMetadata;
|
|
269
695
|
PDS.enhancerMetadata = defaultPDSEnhancerMetadata;
|
|
270
696
|
PDS.applyStyles = function(generator) {
|
|
271
|
-
|
|
697
|
+
const targetGenerator = generator || Generator.instance;
|
|
698
|
+
applyStyles(targetGenerator);
|
|
699
|
+
if (typeof emitConfigChanged === "function") {
|
|
700
|
+
emitConfigChanged({
|
|
701
|
+
mode: "live",
|
|
702
|
+
source: "live:styles-applied",
|
|
703
|
+
});
|
|
704
|
+
}
|
|
272
705
|
};
|
|
273
706
|
PDS.adoptLayers = function(shadowRoot, layers, additionalSheets) {
|
|
274
707
|
return adoptLayers(
|
|
@@ -347,7 +780,7 @@ async function __attachLiveAPIs(PDS, { applyResolvedTheme, setupSystemListenerIf
|
|
|
347
780
|
}
|
|
348
781
|
}
|
|
349
782
|
|
|
350
|
-
|
|
783
|
+
PDS.applyStyles?.(generator);
|
|
351
784
|
|
|
352
785
|
const presetInfo = normalized.presetInfo || { id: presetId, name: presetId };
|
|
353
786
|
PDS.currentPreset = presetInfo;
|
|
@@ -457,7 +890,7 @@ async function __attachLiveAPIs(PDS, { applyResolvedTheme, setupSystemListenerIf
|
|
|
457
890
|
}
|
|
458
891
|
|
|
459
892
|
|
|
460
|
-
export async function startLive(PDS, config, { emitReady, applyResolvedTheme, setupSystemListenerIfNeeded }) {
|
|
893
|
+
export async function startLive(PDS, config, { emitReady, emitConfigChanged, applyResolvedTheme, setupSystemListenerIfNeeded }) {
|
|
461
894
|
if (!config || typeof config !== "object") {
|
|
462
895
|
throw new Error(
|
|
463
896
|
"PDS.start({ mode: 'live', ... }) requires a valid configuration object"
|
|
@@ -467,7 +900,7 @@ export async function startLive(PDS, config, { emitReady, applyResolvedTheme, se
|
|
|
467
900
|
config = applyStoredConfigOverrides(config);
|
|
468
901
|
|
|
469
902
|
// Attach live-only API surface (ontology, presets, query, etc.)
|
|
470
|
-
await __attachLiveAPIs(PDS, { applyResolvedTheme, setupSystemListenerIfNeeded });
|
|
903
|
+
await __attachLiveAPIs(PDS, { applyResolvedTheme, setupSystemListenerIfNeeded, emitConfigChanged });
|
|
471
904
|
attachFoucListener(PDS);
|
|
472
905
|
|
|
473
906
|
// FOUC Prevention: Use constructable stylesheet for synchronous, immediate effect
|
|
@@ -610,7 +1043,7 @@ export async function startLive(PDS, config, { emitReady, applyResolvedTheme, se
|
|
|
610
1043
|
|
|
611
1044
|
// Apply styles globally if requested (default behavior)
|
|
612
1045
|
if (applyGlobalStyles) {
|
|
613
|
-
|
|
1046
|
+
PDS.applyStyles?.(Generator.instance);
|
|
614
1047
|
|
|
615
1048
|
if (typeof window !== "undefined") {
|
|
616
1049
|
setTimeout(() => {
|
|
@@ -656,6 +1089,9 @@ export async function startLive(PDS, config, { emitReady, applyResolvedTheme, se
|
|
|
656
1089
|
autoDefineMapper:
|
|
657
1090
|
(cfgAuto && typeof cfgAuto.mapper === "function" && cfgAuto.mapper) ||
|
|
658
1091
|
null,
|
|
1092
|
+
autoDefinerModuleURL:
|
|
1093
|
+
(cfgAuto && cfgAuto.moduleURL) ||
|
|
1094
|
+
`${assetRootURL}core/pds-auto-definer.js`,
|
|
659
1095
|
enhancers: userEnhancers,
|
|
660
1096
|
autoDefineOverrides: cfgAuto || null,
|
|
661
1097
|
autoDefinePreferModule: !(cfgAuto && cfgAuto.baseURL),
|
|
@@ -684,18 +1120,25 @@ export async function startLive(PDS, config, { emitReady, applyResolvedTheme, se
|
|
|
684
1120
|
PDS.configFormSchema = buildDesignConfigFormSchema(
|
|
685
1121
|
normalized.generatorConfig.design
|
|
686
1122
|
);
|
|
1123
|
+
if (typeof emitConfigChanged === "function") {
|
|
1124
|
+
emitConfigChanged({
|
|
1125
|
+
mode: "live",
|
|
1126
|
+
source: "live:config-applied",
|
|
1127
|
+
preset: normalized.generatorConfig.preset,
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
687
1130
|
|
|
688
|
-
|
|
689
|
-
if (config?.liveEdit && typeof document !== "undefined") {
|
|
1131
|
+
if (typeof document !== "undefined") {
|
|
690
1132
|
try {
|
|
691
|
-
if (
|
|
1133
|
+
if (config?.liveEdit) {
|
|
692
1134
|
setTimeout(() => {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
1135
|
+
void initializeLiveEditToggle();
|
|
1136
|
+
}, 0);
|
|
1137
|
+
} else {
|
|
1138
|
+
teardownLiveEditToggle();
|
|
696
1139
|
}
|
|
697
1140
|
} catch (error) {
|
|
698
|
-
generatorConfig?.log?.("warn", "Live editor failed to start:", error);
|
|
1141
|
+
generatorConfig?.log?.("warn", "Live editor toggle failed to start:", error);
|
|
699
1142
|
}
|
|
700
1143
|
}
|
|
701
1144
|
|
|
@@ -332,6 +332,7 @@ export async function setupAutoDefinerAndEnhancers(options, { baseEnhancers = []
|
|
|
332
332
|
autoDefineBaseURL = "/auto-define/",
|
|
333
333
|
autoDefinePreload = [],
|
|
334
334
|
autoDefineMapper = null,
|
|
335
|
+
autoDefinerModuleURL = null,
|
|
335
336
|
enhancers = [],
|
|
336
337
|
autoDefineOverrides = null,
|
|
337
338
|
autoDefinePreferModule = true,
|
|
@@ -351,7 +352,10 @@ export async function setupAutoDefinerAndEnhancers(options, { baseEnhancers = []
|
|
|
351
352
|
// Dynamically import AutoDefiner to avoid Node/CJS interop at build time
|
|
352
353
|
let AutoDefinerCtor = null;
|
|
353
354
|
try {
|
|
354
|
-
|
|
355
|
+
if (!autoDefinerModuleURL || typeof autoDefinerModuleURL !== "string") {
|
|
356
|
+
throw new Error("AutoDefiner module URL is not configured");
|
|
357
|
+
}
|
|
358
|
+
const mod = await import(autoDefinerModuleURL);
|
|
355
359
|
AutoDefinerCtor =
|
|
356
360
|
mod?.AutoDefiner || mod?.default?.AutoDefiner || mod?.default || null;
|
|
357
361
|
} catch (e) {
|