@pure-ds/core 0.7.1 → 0.7.3
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/.cursorrules +38 -1
- package/.github/copilot-instructions.md +32 -0
- package/custom-elements.json +77 -46
- package/dist/types/public/assets/js/pds-manager.d.ts +1 -1
- package/dist/types/public/assets/js/pds-manager.d.ts.map +1 -1
- package/dist/types/public/assets/js/pds.d.ts.map +1 -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/package.json +1 -1
- package/packages/pds-cli/bin/pds-static.js +13 -2
- package/packages/pds-cli/bin/sync-assets.js +34 -0
- package/public/assets/js/app.js +1543 -4
- package/public/assets/js/app.js.map +7 -0
- package/public/assets/js/lit.js +1078 -3
- package/public/assets/js/lit.js.map +7 -0
- package/public/assets/js/pds-ask.js +239 -9
- package/public/assets/js/pds-ask.js.map +7 -0
- package/public/assets/js/pds-auto-definer.js +306 -1
- package/public/assets/js/pds-autocomplete.js +590 -7
- package/public/assets/js/pds-autocomplete.js.map +7 -0
- package/public/assets/js/pds-enhancers.js +689 -1
- package/public/assets/js/pds-enhancers.js.map +7 -0
- package/public/assets/js/pds-manager.js +15914 -3101
- package/public/assets/js/pds-manager.js.map +7 -0
- package/public/assets/js/pds-toast.js +30 -1
- package/public/assets/js/pds-toast.js.map +7 -0
- package/public/assets/js/pds.js +1409 -2
- package/public/assets/js/pds.js.map +7 -0
- package/public/assets/pds/components/pds-scrollrow.js +2 -4
- package/public/assets/pds/core/pds-ask.js +239 -9
- package/public/assets/pds/core/pds-auto-definer.js +306 -1
- package/public/assets/pds/core/pds-autocomplete.js +590 -7
- package/public/assets/pds/core/pds-enhancers.js +689 -1
- package/public/assets/pds/core/pds-manager.js +15914 -3101
- package/public/assets/pds/core/pds-toast.js +30 -1
- package/public/assets/pds/core.js +1409 -2
- package/public/assets/pds/custom-elements.json +77 -46
- package/public/assets/pds/external/lit.js +1078 -3
- package/public/assets/pds/pds-css-complete.json +2 -2
- package/public/assets/pds/pds.css-data.json +1 -1
- package/public/assets/pds/vscode-custom-data.json +5 -13
- package/src/js/pds-core/pds-live.js +0 -3
- package/src/js/pds-core/pds-start-helpers.js +13 -25
- package/src/js/pds.js +0 -4
|
@@ -1 +1,306 @@
|
|
|
1
|
-
|
|
1
|
+
// node_modules/pure-web/src/js/auto-definer.js
|
|
2
|
+
async function defineWebComponents(...args) {
|
|
3
|
+
let opts = {};
|
|
4
|
+
if (args.length && typeof args[args.length - 1] === "object") {
|
|
5
|
+
opts = args.pop() || {};
|
|
6
|
+
}
|
|
7
|
+
const tags = args;
|
|
8
|
+
const {
|
|
9
|
+
baseURL,
|
|
10
|
+
mapper = (tag) => `${tag}.js`,
|
|
11
|
+
onError = (tag, err) => console.error(`[defineWebComponents] ${tag}:`, err)
|
|
12
|
+
} = opts;
|
|
13
|
+
const base = baseURL ? new URL(
|
|
14
|
+
baseURL,
|
|
15
|
+
typeof location !== "undefined" ? location.href : import.meta.url
|
|
16
|
+
) : new URL("./", import.meta.url);
|
|
17
|
+
const toPascal = (tag) => tag.toLowerCase().replace(/(^|-)([a-z])/g, (_, __, c) => c.toUpperCase());
|
|
18
|
+
const loadOne = async (tag) => {
|
|
19
|
+
try {
|
|
20
|
+
if (customElements.get(tag))
|
|
21
|
+
return { tag, status: "already-defined" };
|
|
22
|
+
const spec = mapper(tag);
|
|
23
|
+
const href = spec instanceof URL ? spec.href : new URL(spec, base).href;
|
|
24
|
+
const mod = await import(href);
|
|
25
|
+
const Named = mod?.default ?? mod?.[toPascal(tag)];
|
|
26
|
+
if (!Named) {
|
|
27
|
+
if (customElements.get(tag))
|
|
28
|
+
return { tag, status: "self-defined" };
|
|
29
|
+
throw new Error(
|
|
30
|
+
`No export found for ${tag}. Expected default export or named export "${toPascal(
|
|
31
|
+
tag
|
|
32
|
+
)}".`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
if (!customElements.get(tag)) {
|
|
36
|
+
customElements.define(tag, Named);
|
|
37
|
+
return { tag, status: "defined" };
|
|
38
|
+
}
|
|
39
|
+
return { tag, status: "race-already-defined" };
|
|
40
|
+
} catch (err) {
|
|
41
|
+
onError(tag, err);
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return Promise.all(tags.map(loadOne));
|
|
46
|
+
}
|
|
47
|
+
var AutoDefiner = class {
|
|
48
|
+
constructor(options = {}) {
|
|
49
|
+
const {
|
|
50
|
+
baseURL,
|
|
51
|
+
mapper,
|
|
52
|
+
onError,
|
|
53
|
+
predicate = () => true,
|
|
54
|
+
attributeModule = "data-module",
|
|
55
|
+
root = document,
|
|
56
|
+
scanExisting = true,
|
|
57
|
+
debounceMs = 16,
|
|
58
|
+
observeShadows = true,
|
|
59
|
+
enhancers = [],
|
|
60
|
+
// [{String selector, Function run(elem)}]
|
|
61
|
+
patchAttachShadow = true
|
|
62
|
+
} = options;
|
|
63
|
+
const pending = /* @__PURE__ */ new Set();
|
|
64
|
+
const inFlight = /* @__PURE__ */ new Set();
|
|
65
|
+
const knownMissing = /* @__PURE__ */ new Set();
|
|
66
|
+
const perTagModulePath = /* @__PURE__ */ new Map();
|
|
67
|
+
const shadowObservers = /* @__PURE__ */ new WeakMap();
|
|
68
|
+
const enhancerApplied = /* @__PURE__ */ new WeakMap();
|
|
69
|
+
let timer = 0;
|
|
70
|
+
let stopped = false;
|
|
71
|
+
let restoreAttachShadow = null;
|
|
72
|
+
const applyEnhancers = (element) => {
|
|
73
|
+
if (!element || !enhancers.length)
|
|
74
|
+
return;
|
|
75
|
+
let appliedEnhancers = enhancerApplied.get(element);
|
|
76
|
+
if (!appliedEnhancers) {
|
|
77
|
+
appliedEnhancers = /* @__PURE__ */ new Set();
|
|
78
|
+
enhancerApplied.set(element, appliedEnhancers);
|
|
79
|
+
}
|
|
80
|
+
for (const enhancer of enhancers) {
|
|
81
|
+
if (!enhancer.selector || !enhancer.run)
|
|
82
|
+
continue;
|
|
83
|
+
if (appliedEnhancers.has(enhancer.selector))
|
|
84
|
+
continue;
|
|
85
|
+
try {
|
|
86
|
+
if (element.matches && element.matches(enhancer.selector)) {
|
|
87
|
+
enhancer.run(element);
|
|
88
|
+
appliedEnhancers.add(enhancer.selector);
|
|
89
|
+
}
|
|
90
|
+
} catch (err) {
|
|
91
|
+
console.warn(
|
|
92
|
+
`[AutoDefiner] Error applying enhancer for selector "${enhancer.selector}":`,
|
|
93
|
+
err
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const queueTag = (tag, el) => {
|
|
99
|
+
if (stopped)
|
|
100
|
+
return;
|
|
101
|
+
if (!tag || !tag.includes("-"))
|
|
102
|
+
return;
|
|
103
|
+
if (customElements.get(tag))
|
|
104
|
+
return;
|
|
105
|
+
if (inFlight.has(tag))
|
|
106
|
+
return;
|
|
107
|
+
if (knownMissing.has(tag))
|
|
108
|
+
return;
|
|
109
|
+
if (el && el.getAttribute) {
|
|
110
|
+
const override = el.getAttribute(attributeModule);
|
|
111
|
+
if (override && !perTagModulePath.has(tag)) {
|
|
112
|
+
perTagModulePath.set(tag, override);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
pending.add(tag);
|
|
116
|
+
schedule();
|
|
117
|
+
};
|
|
118
|
+
const schedule = () => {
|
|
119
|
+
if (timer)
|
|
120
|
+
return;
|
|
121
|
+
timer = setTimeout(flush, debounceMs);
|
|
122
|
+
};
|
|
123
|
+
const crawlTree = (rootNode) => {
|
|
124
|
+
if (!rootNode)
|
|
125
|
+
return;
|
|
126
|
+
if (rootNode.nodeType === 1) {
|
|
127
|
+
const el = (
|
|
128
|
+
/** @type {Element} */
|
|
129
|
+
rootNode
|
|
130
|
+
);
|
|
131
|
+
const tag = el.tagName?.toLowerCase();
|
|
132
|
+
if (tag && tag.includes("-") && !customElements.get(tag) && predicate(tag, el)) {
|
|
133
|
+
queueTag(tag, el);
|
|
134
|
+
}
|
|
135
|
+
applyEnhancers(el);
|
|
136
|
+
if (observeShadows && el.shadowRoot) {
|
|
137
|
+
observeShadowRoot(el.shadowRoot);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (rootNode.querySelectorAll) {
|
|
141
|
+
rootNode.querySelectorAll("*").forEach((e) => {
|
|
142
|
+
const t = e.tagName?.toLowerCase();
|
|
143
|
+
if (t && t.includes("-") && !customElements.get(t) && predicate(t, e)) {
|
|
144
|
+
queueTag(t, e);
|
|
145
|
+
}
|
|
146
|
+
applyEnhancers(e);
|
|
147
|
+
if (observeShadows && e.shadowRoot) {
|
|
148
|
+
observeShadowRoot(e.shadowRoot);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const observeShadowRoot = (sr) => {
|
|
154
|
+
if (!sr || shadowObservers.has(sr))
|
|
155
|
+
return;
|
|
156
|
+
crawlTree(sr);
|
|
157
|
+
const mo = new MutationObserver((mutations) => {
|
|
158
|
+
for (const m of mutations) {
|
|
159
|
+
m.addedNodes?.forEach((n) => {
|
|
160
|
+
crawlTree(n);
|
|
161
|
+
});
|
|
162
|
+
if (m.type === "attributes" && m.target) {
|
|
163
|
+
crawlTree(m.target);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
mo.observe(sr, {
|
|
168
|
+
childList: true,
|
|
169
|
+
subtree: true,
|
|
170
|
+
attributes: true,
|
|
171
|
+
attributeFilter: [
|
|
172
|
+
attributeModule,
|
|
173
|
+
...enhancers.map((e) => e.selector).filter((s) => s.startsWith("data-"))
|
|
174
|
+
]
|
|
175
|
+
});
|
|
176
|
+
shadowObservers.set(sr, mo);
|
|
177
|
+
};
|
|
178
|
+
async function flush() {
|
|
179
|
+
clearTimeout(timer);
|
|
180
|
+
timer = 0;
|
|
181
|
+
if (!pending.size)
|
|
182
|
+
return;
|
|
183
|
+
const tags = Array.from(pending);
|
|
184
|
+
pending.clear();
|
|
185
|
+
tags.forEach((t) => inFlight.add(t));
|
|
186
|
+
try {
|
|
187
|
+
const effectiveMapper = (tag) => perTagModulePath.get(tag) ?? (mapper ? mapper(tag) : `${tag}.js`);
|
|
188
|
+
await defineWebComponents(...tags, {
|
|
189
|
+
baseURL,
|
|
190
|
+
mapper: effectiveMapper,
|
|
191
|
+
onError: (tag, err) => {
|
|
192
|
+
knownMissing.add(tag);
|
|
193
|
+
onError?.(tag, err);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
} catch {
|
|
197
|
+
} finally {
|
|
198
|
+
tags.forEach((t) => inFlight.delete(t));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const mountNode = root === document ? document.documentElement : root;
|
|
202
|
+
const obs = new MutationObserver((mutations) => {
|
|
203
|
+
for (const m of mutations) {
|
|
204
|
+
m.addedNodes?.forEach((n) => {
|
|
205
|
+
crawlTree(n);
|
|
206
|
+
});
|
|
207
|
+
if (m.type === "attributes" && m.target) {
|
|
208
|
+
crawlTree(m.target);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
obs.observe(mountNode, {
|
|
213
|
+
childList: true,
|
|
214
|
+
subtree: true,
|
|
215
|
+
attributes: true,
|
|
216
|
+
attributeFilter: [
|
|
217
|
+
attributeModule,
|
|
218
|
+
...enhancers.map((e) => e.selector).filter((s) => s.startsWith("data-"))
|
|
219
|
+
]
|
|
220
|
+
});
|
|
221
|
+
if (observeShadows && patchAttachShadow && Element.prototype.attachShadow) {
|
|
222
|
+
const orig = Element.prototype.attachShadow;
|
|
223
|
+
Element.prototype.attachShadow = function patchedAttachShadow(init) {
|
|
224
|
+
const sr = orig.call(this, init);
|
|
225
|
+
if (init && init.mode === "open") {
|
|
226
|
+
observeShadowRoot(sr);
|
|
227
|
+
const tag = this.tagName?.toLowerCase();
|
|
228
|
+
if (tag && tag.includes("-") && !customElements.get(tag)) {
|
|
229
|
+
queueTag(tag, this);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return sr;
|
|
233
|
+
};
|
|
234
|
+
restoreAttachShadow = () => Element.prototype.attachShadow = orig;
|
|
235
|
+
}
|
|
236
|
+
if (scanExisting) {
|
|
237
|
+
crawlTree(mountNode);
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
stop() {
|
|
241
|
+
stopped = true;
|
|
242
|
+
obs.disconnect();
|
|
243
|
+
if (restoreAttachShadow)
|
|
244
|
+
restoreAttachShadow();
|
|
245
|
+
if (timer) {
|
|
246
|
+
clearTimeout(timer);
|
|
247
|
+
timer = 0;
|
|
248
|
+
}
|
|
249
|
+
shadowObservers.forEach((mo) => mo.disconnect());
|
|
250
|
+
},
|
|
251
|
+
flush
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Dynamically load and (idempotently) define a set of web components by tag name.
|
|
256
|
+
*/
|
|
257
|
+
static async define(...args) {
|
|
258
|
+
let opts = {};
|
|
259
|
+
if (args.length && typeof args[args.length - 1] === "object") {
|
|
260
|
+
opts = args.pop() || {};
|
|
261
|
+
}
|
|
262
|
+
const tags = args;
|
|
263
|
+
const {
|
|
264
|
+
baseURL,
|
|
265
|
+
mapper = (tag) => `${tag}.js`,
|
|
266
|
+
onError = (tag, err) => console.error(`[defineWebComponents] ${tag}:`, err)
|
|
267
|
+
} = opts;
|
|
268
|
+
const base = baseURL ? new URL(
|
|
269
|
+
baseURL,
|
|
270
|
+
typeof location !== "undefined" ? location.href : import.meta.url
|
|
271
|
+
) : new URL("./", import.meta.url);
|
|
272
|
+
const toPascal = (tag) => tag.toLowerCase().replace(/(^|-)([a-z])/g, (_, __, c) => c.toUpperCase());
|
|
273
|
+
const loadOne = async (tag) => {
|
|
274
|
+
try {
|
|
275
|
+
if (customElements.get(tag))
|
|
276
|
+
return { tag, status: "already-defined" };
|
|
277
|
+
const spec = mapper(tag);
|
|
278
|
+
const href = spec instanceof URL ? spec.href : new URL(spec, base).href;
|
|
279
|
+
const mod = await import(href);
|
|
280
|
+
const Named = mod?.default ?? mod?.[toPascal(tag)];
|
|
281
|
+
if (!Named) {
|
|
282
|
+
if (customElements.get(tag))
|
|
283
|
+
return { tag, status: "self-defined" };
|
|
284
|
+
throw new Error(
|
|
285
|
+
`No export found for ${tag}. Expected default export or named export "${toPascal(
|
|
286
|
+
tag
|
|
287
|
+
)}".`
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
if (!customElements.get(tag)) {
|
|
291
|
+
customElements.define(tag, Named);
|
|
292
|
+
return { tag, status: "defined" };
|
|
293
|
+
}
|
|
294
|
+
return { tag, status: "race-already-defined" };
|
|
295
|
+
} catch (err) {
|
|
296
|
+
onError(tag, err);
|
|
297
|
+
throw err;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
return Promise.all(tags.map(loadOne));
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
export {
|
|
304
|
+
AutoDefiner
|
|
305
|
+
};
|
|
306
|
+
//# sourceMappingURL=pds-auto-definer.js.map
|