@parity-app/cli 0.0.0 → 0.2.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/README.md +88 -3
- package/dist/bin.mjs +1133 -273
- package/dist/client-Cf66-n3R.mjs +724 -0
- package/dist/index.d.mts +211 -17
- package/dist/index.mjs +1 -1
- package/dist/libraries/aria.lib.par +5 -5
- package/dist/libraries/baseui.lib.par +25 -25
- package/dist/libraries/chakra.lib.par +61 -22
- package/dist/libraries/fluent.lib.par +27 -27
- package/dist/libraries/luma.lib.par +20 -20
- package/dist/libraries/lyra.lib.par +20 -20
- package/dist/libraries/maia.lib.par +20 -20
- package/dist/libraries/mantine.lib.par +14 -14
- package/dist/libraries/mira.lib.par +20 -20
- package/dist/libraries/mui.lib.par +5 -5
- package/dist/libraries/nova.lib.par +20 -20
- package/dist/libraries/radix.lib.par +11 -11
- package/dist/libraries/recharts.lib.par +5445 -0
- package/dist/libraries/rhea.lib.par +20 -20
- package/dist/libraries/sera.lib.par +20 -20
- package/dist/libraries/vega.lib.par +20 -20
- package/dist/{src-C8DCd2a1.mjs → src-BOUQtcWB.mjs} +1 -1
- package/dist/{src-WcAfq6g1.mjs → src-BRgxMRtE.mjs} +3 -2
- package/dist/{src-CSeISXoZ.mjs → src-BZ1p_ip_.mjs} +135 -38
- package/dist/{src-uPmBVSsB.mjs → src-CAm6EBIK.mjs} +1 -1
- package/dist/{src-rlZNC2MU.mjs → src-CcWc-KsX.mjs} +593 -212
- package/package.json +8 -6
- package/skills/SKILL.md +61 -14
- package/skills/document.md +6 -1
- package/skills/execute.md +96 -8
- package/skills/guide/states-and-modes.md +5 -3
- package/LICENSE +0 -21
- package/dist/client-DsTLQ2lT.mjs +0 -286
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
// ../core/src/css.ts
|
|
2
|
-
/**
|
|
3
|
-
* Custom properties holding 1% of a frame's viewport width and height, which viewport units are rewritten to: in a frame,
|
|
4
|
-
* `100vh` is the height of the screen the frame stands for, not of Parity's window.
|
|
5
|
-
*/
|
|
6
|
-
const viewportWidthProperty = "--canvas-vw";
|
|
7
|
-
const viewportHeightProperty = "--canvas-vh";
|
|
8
|
-
new RegExp(String.raw`"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|url\([^)]*\)|var\((?:${viewportWidthProperty}|${viewportHeightProperty}),[^)]*\)`, "g");
|
|
9
1
|
// ../core/src/devices.ts
|
|
10
2
|
const deviceKinds = [
|
|
11
3
|
"phone",
|
|
@@ -24,6 +16,110 @@ function lengthToPixels(value) {
|
|
|
24
16
|
if (!Number.isFinite(number)) return void 0;
|
|
25
17
|
return match[2] === "rem" || match[2] === "em" ? number * 16 : number;
|
|
26
18
|
}
|
|
19
|
+
// ../core/src/css.ts
|
|
20
|
+
/**
|
|
21
|
+
* Custom properties holding 1% of a frame's viewport width and height, which viewport units are rewritten to: in a frame,
|
|
22
|
+
* `100vh` is the height of the screen the frame stands for, not of Parity's window.
|
|
23
|
+
*/
|
|
24
|
+
const viewportWidthProperty = "--canvas-vw";
|
|
25
|
+
const viewportHeightProperty = "--canvas-vh";
|
|
26
|
+
/** Every custom property declaration in a stylesheet, in source order. */
|
|
27
|
+
function collectCustomProperties(css) {
|
|
28
|
+
const declarations = [];
|
|
29
|
+
const visit = (nodes, selector, atRules) => {
|
|
30
|
+
for (const node of nodes) if (node.kind === "block") {
|
|
31
|
+
const prelude = node.prelude.trim();
|
|
32
|
+
const atRule = /^@([\w-]+)\s*([\s\S]*)$/.exec(prelude);
|
|
33
|
+
if (atRule) visit(node.children, selector, [...atRules, {
|
|
34
|
+
name: atRule[1].toLowerCase(),
|
|
35
|
+
prelude: atRule[2].trim()
|
|
36
|
+
}]);
|
|
37
|
+
else visit(node.children, prelude, atRules);
|
|
38
|
+
} else if (selector !== void 0 || atRules.length > 0) for (const match of node.text.matchAll(/--([\w-]+)\s*:\s*([^;]+)/g)) declarations.push({
|
|
39
|
+
selector: selector ?? "",
|
|
40
|
+
atRules,
|
|
41
|
+
name: match[1],
|
|
42
|
+
value: match[2].trim()
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
visit(parse(css), void 0, []);
|
|
46
|
+
return declarations;
|
|
47
|
+
}
|
|
48
|
+
function parse(css) {
|
|
49
|
+
let index = 0;
|
|
50
|
+
function parseLevel() {
|
|
51
|
+
const nodes = [];
|
|
52
|
+
let buffer = "";
|
|
53
|
+
let afterLastSemicolon = 0;
|
|
54
|
+
let parens = 0;
|
|
55
|
+
while (index < css.length) {
|
|
56
|
+
const char = css[index];
|
|
57
|
+
if (char === "/" && css[index + 1] === "*") {
|
|
58
|
+
const end = css.indexOf("*/", index + 2);
|
|
59
|
+
index = end === -1 ? css.length : end + 2;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (char === "\\") {
|
|
63
|
+
buffer += css.slice(index, index + 2);
|
|
64
|
+
index += 2;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (char === "\"" || char === "'") {
|
|
68
|
+
const end = findStringEnd(css, index);
|
|
69
|
+
buffer += css.slice(index, end);
|
|
70
|
+
index = end;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
index++;
|
|
74
|
+
if (char === "(") parens++;
|
|
75
|
+
if (char === ")") parens = Math.max(0, parens - 1);
|
|
76
|
+
if (parens > 0) {
|
|
77
|
+
buffer += char;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (char === ";") {
|
|
81
|
+
buffer += char;
|
|
82
|
+
afterLastSemicolon = buffer.length;
|
|
83
|
+
} else if (char === "{") {
|
|
84
|
+
const text = buffer.slice(0, afterLastSemicolon);
|
|
85
|
+
if (text) nodes.push({
|
|
86
|
+
kind: "text",
|
|
87
|
+
text
|
|
88
|
+
});
|
|
89
|
+
nodes.push({
|
|
90
|
+
kind: "block",
|
|
91
|
+
prelude: buffer.slice(afterLastSemicolon),
|
|
92
|
+
children: parseLevel()
|
|
93
|
+
});
|
|
94
|
+
buffer = "";
|
|
95
|
+
afterLastSemicolon = 0;
|
|
96
|
+
} else if (char === "}") {
|
|
97
|
+
if (buffer) nodes.push({
|
|
98
|
+
kind: "text",
|
|
99
|
+
text: buffer
|
|
100
|
+
});
|
|
101
|
+
return nodes;
|
|
102
|
+
} else buffer += char;
|
|
103
|
+
}
|
|
104
|
+
if (buffer) nodes.push({
|
|
105
|
+
kind: "text",
|
|
106
|
+
text: buffer
|
|
107
|
+
});
|
|
108
|
+
return nodes;
|
|
109
|
+
}
|
|
110
|
+
const nodes = [];
|
|
111
|
+
while (index < css.length) nodes.push(...parseLevel());
|
|
112
|
+
return nodes;
|
|
113
|
+
}
|
|
114
|
+
function findStringEnd(css, start) {
|
|
115
|
+
const quote = css[start];
|
|
116
|
+
let index = start + 1;
|
|
117
|
+
while (index < css.length) if (css[index] === "\\") index += 2;
|
|
118
|
+
else if (css[index] === quote) return index + 1;
|
|
119
|
+
else index++;
|
|
120
|
+
return css.length;
|
|
121
|
+
}
|
|
122
|
+
new RegExp(String.raw`"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|url\([^)]*\)|var\((?:${viewportWidthProperty}|${viewportHeightProperty}),[^)]*\)`, "g");
|
|
27
123
|
// ../core/src/validate.ts
|
|
28
124
|
function expectObject(value, path) {
|
|
29
125
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${path || "/"}: expected an object`);
|
|
@@ -270,10 +366,7 @@ function parseDetection(value, path) {
|
|
|
270
366
|
export: expectString(ref.export, `${at}/${index}/export`)
|
|
271
367
|
};
|
|
272
368
|
});
|
|
273
|
-
return compact({
|
|
274
|
-
include: optional(detection.include, (list) => refs(list, `${path}/include`)),
|
|
275
|
-
exclude: optional(detection.exclude, (list) => refs(list, `${path}/exclude`))
|
|
276
|
-
});
|
|
369
|
+
return compact({ include: optional(detection.include, (list) => refs(list, `${path}/include`)) });
|
|
277
370
|
}
|
|
278
371
|
function parseNote(value, path) {
|
|
279
372
|
const note = expectObject(value, path);
|
|
@@ -729,7 +822,7 @@ const decoratorKeys = [
|
|
|
729
822
|
const libraryManifestExtension = ".lib.par";
|
|
730
823
|
function parseLibraryManifest(value) {
|
|
731
824
|
const manifest = expectObject(value, "");
|
|
732
|
-
|
|
825
|
+
expectKnownKeys(manifest, [
|
|
733
826
|
"$schema",
|
|
734
827
|
"version",
|
|
735
828
|
"id",
|
|
@@ -738,13 +831,16 @@ function parseLibraryManifest(value) {
|
|
|
738
831
|
"styles",
|
|
739
832
|
"breakpoints",
|
|
740
833
|
"tokens",
|
|
741
|
-
"canvas"
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
834
|
+
"canvas",
|
|
835
|
+
"package",
|
|
836
|
+
"components",
|
|
837
|
+
"icons",
|
|
838
|
+
"decorators",
|
|
839
|
+
"edits"
|
|
840
|
+
], "");
|
|
841
|
+
if (manifest.version !== 3) throw new TypeError("/version: expected 3");
|
|
746
842
|
return compact({
|
|
747
|
-
version:
|
|
843
|
+
version: 3,
|
|
748
844
|
id: optional(manifest.id, (v) => expectString(v, "/id")),
|
|
749
845
|
name: expectString(manifest.name, "/name"),
|
|
750
846
|
description: optional(manifest.description, (v) => expectString(v, "/description")),
|
|
@@ -1070,9 +1166,11 @@ function expectStringRecord(value, path) {
|
|
|
1070
1166
|
return record;
|
|
1071
1167
|
}
|
|
1072
1168
|
// ../core/src/library-insert.ts
|
|
1169
|
+
/** Nodes whose `children` is the name `componentNode` gave them, rather than text someone set. */
|
|
1170
|
+
const named = /* @__PURE__ */ new WeakSet();
|
|
1073
1171
|
/**
|
|
1074
1172
|
* A new node for a component, ready to show something: required props get their default or first option, and a
|
|
1075
|
-
* component that takes children gets its own name as text, so it isn't an empty box.
|
|
1173
|
+
* component that takes children gets its own name as text, so it isn't an empty box, unless `given` has its own.
|
|
1076
1174
|
*/
|
|
1077
1175
|
function componentNode(component, info, taken, given = {}) {
|
|
1078
1176
|
const props = { ...given };
|
|
@@ -1084,13 +1182,16 @@ function componentNode(component, info, taken, given = {}) {
|
|
|
1084
1182
|
else if (prop.kind === "number") props[prop.name] = 0;
|
|
1085
1183
|
else if (prop.kind === "string") props[prop.name] = prop.name;
|
|
1086
1184
|
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1185
|
+
const labelled = !("children" in given) && info?.props.some((prop) => prop.name === "children" && prop.kind === "node");
|
|
1186
|
+
if (labelled) props.children = component.split("/").at(-1) ?? component;
|
|
1187
|
+
const node = {
|
|
1089
1188
|
type: "component",
|
|
1090
1189
|
id: generateId(taken),
|
|
1091
1190
|
component,
|
|
1092
1191
|
...Object.keys(props).length > 0 ? { props } : {}
|
|
1093
1192
|
};
|
|
1193
|
+
if (labelled) named.add(node);
|
|
1194
|
+
return node;
|
|
1094
1195
|
}
|
|
1095
1196
|
/**
|
|
1096
1197
|
* A library component as its library file says it's used: with its sample (a collection's items, an Accordion's
|
|
@@ -1164,9 +1265,11 @@ function withLibraryContext(node, sources, around, taken) {
|
|
|
1164
1265
|
let placed = node;
|
|
1165
1266
|
const sample = source.sample;
|
|
1166
1267
|
if (sample) {
|
|
1268
|
+
const given = { ...node.props };
|
|
1269
|
+
if (sample.props && "children" in sample.props && named.has(node)) delete given.children;
|
|
1167
1270
|
const { props, slots } = held({
|
|
1168
1271
|
...sample.props,
|
|
1169
|
-
...
|
|
1272
|
+
...given
|
|
1170
1273
|
}, sample.children);
|
|
1171
1274
|
if (sample.children) delete props.children;
|
|
1172
1275
|
const { props: _label, ...rest } = node;
|
|
@@ -1240,10 +1343,10 @@ function withLibraryContext(node, sources, around, taken) {
|
|
|
1240
1343
|
}
|
|
1241
1344
|
}
|
|
1242
1345
|
/**
|
|
1243
|
-
* A library file's component as the canvas inserts it,
|
|
1244
|
-
*
|
|
1346
|
+
* A library file's component as the canvas inserts it, with its parents and sample named by component id.
|
|
1347
|
+
* Discovery has already rewritten module imports for the name the project installed the package under.
|
|
1245
1348
|
*/
|
|
1246
|
-
function librarySource(library, name, component, path
|
|
1349
|
+
function librarySource(library, name, component, path) {
|
|
1247
1350
|
return {
|
|
1248
1351
|
path,
|
|
1249
1352
|
export: name,
|
|
@@ -1251,16 +1354,16 @@ function librarySource(library, name, component, path, imported = (specifier) =>
|
|
|
1251
1354
|
...component.group ? { group: component.group } : {},
|
|
1252
1355
|
...component.parents ? { parents: component.parents.map((parent) => `${library}/${parent}`) } : {},
|
|
1253
1356
|
...component.internal ? { internal: true } : {},
|
|
1357
|
+
...component.visual === false ? { visual: false } : {},
|
|
1254
1358
|
...component.optionalParents ? { optionalParents: component.optionalParents.map((parent) => `${library}/${parent}`) } : {},
|
|
1255
1359
|
...component.parentParts ? { parentParts: true } : {},
|
|
1256
|
-
...component.sample ? { sample: sampleIds(component.sample, library
|
|
1360
|
+
...component.sample ? { sample: sampleIds(component.sample, library) } : {}
|
|
1257
1361
|
};
|
|
1258
1362
|
}
|
|
1259
1363
|
/**
|
|
1260
|
-
* A sample with its children's components named by id, as `nova/AccordionItem`; HTML elements keep their tag.
|
|
1261
|
-
* package makes (`{ $call: { import: "@chakra-ui/react", ... } }`) imports it by the name the project depends on.
|
|
1364
|
+
* A sample with its children's components named by id, as `nova/AccordionItem`; HTML elements keep their tag.
|
|
1262
1365
|
*/
|
|
1263
|
-
function sampleIds(sample, library
|
|
1366
|
+
function sampleIds(sample, library) {
|
|
1264
1367
|
const child = (node) => {
|
|
1265
1368
|
if (typeof node === "string") return node;
|
|
1266
1369
|
if (isSampleRender(node)) return {
|
|
@@ -1280,13 +1383,7 @@ function sampleIds(sample, library, imported = (specifier) => specifier) {
|
|
|
1280
1383
|
$render: item.$render.map(child)
|
|
1281
1384
|
};
|
|
1282
1385
|
if (isSampleElement(item)) return { $element: item.$element.map(child) };
|
|
1283
|
-
return
|
|
1284
|
-
...item,
|
|
1285
|
-
$call: {
|
|
1286
|
-
...item.$call,
|
|
1287
|
-
import: imported(item.$call.import)
|
|
1288
|
-
}
|
|
1289
|
-
} : item;
|
|
1386
|
+
return item;
|
|
1290
1387
|
};
|
|
1291
1388
|
const propIds = (props) => Object.fromEntries(Object.entries(props).map(([key, item]) => [key, propId(item)]));
|
|
1292
1389
|
return {
|
|
@@ -1295,4 +1392,4 @@ function sampleIds(sample, library, imported = (specifier) => specifier) {
|
|
|
1295
1392
|
...sample.children ? { children: sample.children.map(child) } : {}
|
|
1296
1393
|
};
|
|
1297
1394
|
}
|
|
1298
|
-
export {
|
|
1395
|
+
export { viewportWidthProperty as C, viewportHeightProperty as S, lengthToPixels as T, parseCanvasDocument as _, applyLibraryEdits as a, parseModeSettings as b, isSampleElement as c, parentSignals as d, parseLibraryEdits as f, paramTypes as g, imageFits as h, withLibraryContext as i, isSampleRender as l, renderSlotOf as m, librarySource as n, componentEvidence as o, parseLibraryManifest as p, sampleIds as r, isMadeValue as s, componentNode as t, libraryManifestExtension as u, styleKeys as v, deviceKinds as w, collectCustomProperties as x, generateId as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as parseLibraryManifest, u as libraryManifestExtension } from "./src-
|
|
1
|
+
import { p as parseLibraryManifest, u as libraryManifestExtension } from "./src-BZ1p_ip_.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { readFile, readdir } from "node:fs/promises";
|
|
4
4
|
import { dirname, join } from "node:path";
|