@whzxc/agent-design-gallery 0.10.0 → 0.13.2
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 -3
- package/package.json +2 -2
- package/public/annotations.js +816 -0
- package/public/app.js +245 -12
- package/public/assets.js +4 -13
- package/public/frame-identity.js +223 -0
- package/public/icons.js +1 -0
- package/public/index.html +3 -0
- package/public/selection.js +1 -1
- package/public/style.css +72 -2
- package/src/annotations.mjs +238 -0
- package/src/cli-output.mjs +25 -2
- package/src/cli.mjs +46 -7
- package/src/http.mjs +2 -1
- package/src/hub/instances.mjs +1 -1
- package/src/hub/registry.mjs +1 -1
- package/src/hub.mjs +2 -2
- package/src/server.mjs +59 -11
- package/src/service.mjs +1 -1
- package/src/toolkit/arch-overlay.mjs +1 -1
- package/src/toolkit/asset-rules.mjs +42 -3
- package/src/toolkit/build-store.mjs +1 -1
- package/src/toolkit/build-worker.mjs +1 -1
- package/src/toolkit/build.mjs +27 -11
- package/src/toolkit/commands.mjs +61 -8
- package/src/toolkit/config.mjs +2 -1
- package/src/toolkit/diff.mjs +4 -1
- package/src/toolkit/document.mjs +6 -6
- package/src/toolkit/frame-document.mjs +1 -1
- package/src/toolkit/frame-facets.mjs +167 -0
- package/src/toolkit/frame-identity.mjs +100 -0
- package/src/toolkit/frame-observation.mjs +147 -0
- package/src/toolkit/frame-primitives.mjs +85 -0
- package/src/toolkit/html.mjs +1 -0
- package/src/toolkit/impact-inputs.mjs +2 -21
- package/src/toolkit/impact.mjs +3 -24
- package/src/toolkit/input-generation.mjs +51 -0
- package/src/toolkit/inspect-encoding.mjs +459 -0
- package/src/toolkit/inspect-observation.mjs +56 -0
- package/src/toolkit/inspect-output.mjs +169 -0
- package/src/toolkit/inspect-styles.mjs +34 -0
- package/src/toolkit/inspect.d.ts +118 -0
- package/src/toolkit/inspect.mjs +125 -0
- package/src/toolkit/owner-observation.mjs +23 -189
- package/src/toolkit/owner-search.mjs +2 -2
- package/src/toolkit/owner.mjs +33 -4
- package/src/toolkit/part-diff.mjs +2 -0
- package/src/toolkit/part-snapshot.mjs +15 -23
- package/src/toolkit/project-index.mjs +22 -5
- package/src/toolkit/project.mjs +52 -6
- package/src/toolkit/runtime.d.ts +7 -5
- package/src/toolkit/runtime.mjs +20 -7
package/src/toolkit/runtime.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { icons } from 'lucide';
|
|
2
|
-
|
|
2
|
+
import { escape } from './html.mjs';
|
|
3
|
+
export { escape };
|
|
3
4
|
const voids = new Set('area base br col embed hr img input link meta param source track wbr'.split(' '));
|
|
4
5
|
export const markup = html => ({ html, toString() { return this.html; } });
|
|
5
6
|
export function children(value) {
|
|
@@ -15,26 +16,36 @@ export function attributes(props) {
|
|
|
15
16
|
return ` ${key}="${escape(value === true ? '' : value)}"`;
|
|
16
17
|
}).join('');
|
|
17
18
|
}
|
|
19
|
+
const artworkSources = new Map();
|
|
20
|
+
export function registerArtwork(url, source) { artworkSources.set(url,source); return url; }
|
|
18
21
|
const componentOwners = new WeakMap();
|
|
19
22
|
export const componentOwner = component => componentOwners.get(component);
|
|
20
23
|
export function registerComponent(component, source, name) {
|
|
21
24
|
if (typeof component === 'function' && !componentOwners.has(component)) componentOwners.set(component, {source, export:name});
|
|
22
25
|
}
|
|
26
|
+
const stampIdentity = (value, identity) => Array.isArray(value) ? value.map((item, root) => stampIdentity(item, {...identity, root})) : value?.withIdentity ? value.withIdentity(identity) : value;
|
|
23
27
|
const stamp = (value, owner) => Array.isArray(value) ? value.map(item => stamp(item, owner)) : value?.withOwner ? value.withOwner(owner) : value;
|
|
24
|
-
export const Fragment = ({ children: value }) => ({...markup(children(value)), withOwner:owner => Fragment({children:stamp(value,owner)})});
|
|
25
|
-
export function jsx(type, props = {}) {
|
|
28
|
+
export const Fragment = ({ children: value }) => ({...markup(children(value)), withOwner:owner => Fragment({children:stamp(value,owner)}), withIdentity:identity => Fragment({children:stampIdentity(Array.isArray(value)?value:[value],identity)})});
|
|
29
|
+
export function jsx(type, props = {}, key = props.key) {
|
|
30
|
+
if (key !== undefined && key !== null && !(typeof key === 'string' && key.length || typeof key === 'number' && Number.isFinite(key))) throw Error('JSX key must be a nonempty string or finite number');
|
|
31
|
+
props={...props,key:undefined};
|
|
26
32
|
if (typeof type === 'function') {
|
|
27
33
|
const value = type(props), owner = componentOwners.get(type);
|
|
28
|
-
|
|
34
|
+
const owned = owner ? stamp(value, owner) : value;
|
|
35
|
+
return key == null ? owned : stampIdentity(owned, {key, ...(owner ? {owner} : {})});
|
|
29
36
|
}
|
|
30
37
|
if (['script', 'style'].includes(type.toLowerCase())) throw Error(`Forbidden <${type}>; use tokens and utility classes`);
|
|
38
|
+
const art=artworkSources.get(props.src ?? props.href ?? props['xlink:href']);
|
|
39
|
+
if(art)props={...props,'data-adg-art':art};
|
|
40
|
+
if (key != null) props = {...props, 'data-adg-keys':JSON.stringify([...(props['data-adg-keys'] ? JSON.parse(props['data-adg-keys']) : []), {key}])};
|
|
31
41
|
const result = markup(`<${type}${attributes(props)}>${voids.has(type) ? '' : children(props.children) + `</${type}>`}`);
|
|
32
42
|
result.withOwner = owner => jsx(type, {...props, 'data-adg-owners':JSON.stringify([...(props['data-adg-owners'] ? JSON.parse(props['data-adg-owners']) : []), owner])});
|
|
43
|
+
result.withIdentity = identity => jsx(type, {...props, key:undefined, 'data-adg-keys':JSON.stringify([...(props['data-adg-keys'] ? JSON.parse(props['data-adg-keys']) : []), identity])});
|
|
33
44
|
return result;
|
|
34
45
|
}
|
|
35
46
|
export const jsxs = jsx;
|
|
36
47
|
export function jsxDEV(type, props, key, isStatic, source) {
|
|
37
|
-
try { return jsx(type, props); }
|
|
48
|
+
try { return jsx(type, props, key); }
|
|
38
49
|
catch (error) { if (!error.located && source) { error.message = `${source.fileName}:${source.lineNumber}:${source.columnNumber}: ${error.message}`; error.located = true; } throw error; }
|
|
39
50
|
}
|
|
40
51
|
export function Frame({ children: content, ...props }) { return { frame: true, ...props, html: children(content) }; }
|
|
@@ -42,14 +53,16 @@ export function Icon({ name, size = 16, class: className, ...props }) {
|
|
|
42
53
|
const key = name.split('-').map(s => s[0].toUpperCase() + s.slice(1)).join('');
|
|
43
54
|
const geometry = icons[key];
|
|
44
55
|
if (!geometry) throw Error(`Unknown Lucide icon ${name}`);
|
|
45
|
-
return jsx('svg', { xmlns: 'http://www.w3.org/2000/svg', width: size, height: size, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', 'stroke-width': 1.75 * 24 / size, 'stroke-linecap': 'round', 'stroke-linejoin': 'round', 'aria-hidden': 'true', class: className, ...props, children: geometry.map(([tag, attrs]) => jsx(tag, attrs)) });
|
|
56
|
+
return jsx('svg', { xmlns: 'http://www.w3.org/2000/svg', width: size, height: size, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', 'stroke-width': 1.75 * 24 / size, 'stroke-linecap': 'round', 'stroke-linejoin': 'round', 'aria-hidden': 'true', class: className, ...props, 'data-adg-icon':name, children: geometry.map(([tag, attrs]) => jsx(tag, attrs)) });
|
|
46
57
|
}
|
|
47
|
-
export function artwork(source, props) {
|
|
58
|
+
export function artwork(source, props, provenance) {
|
|
59
|
+
if (provenance) props={...props,'data-adg-art':provenance};
|
|
48
60
|
const match = source.match(/<svg\b([^>]*)>([\s\S]*)<\/svg>/i);
|
|
49
61
|
if (!match) throw Error('Invalid SVG artwork');
|
|
50
62
|
let attrs = match[1];
|
|
51
63
|
for (const key of Object.keys(props)) attrs = attrs.replace(new RegExp(`\\s${key}\\s*=\\s*(["']).*?\\1`, 'g'), '');
|
|
52
64
|
const result = markup(`<svg${attrs}${attributes(props)}>${match[2]}</svg>`);
|
|
65
|
+
result.withIdentity = identity => artwork(source, {...props, 'data-adg-keys':JSON.stringify([...(props['data-adg-keys'] ? JSON.parse(props['data-adg-keys']) : []), identity])}, provenance);
|
|
53
66
|
result.withOwner = owner => artwork(source, {...props, 'data-adg-owners':JSON.stringify([...(props['data-adg-owners'] ? JSON.parse(props['data-adg-owners']) : []), owner])});
|
|
54
67
|
return result;
|
|
55
68
|
}
|