@popcraft/cli 0.2.0 → 0.4.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/dist/popcraft.mjs +51 -26
- package/package.json +2 -2
package/dist/popcraft.mjs
CHANGED
|
@@ -258877,6 +258877,7 @@ function loadEntitlements(workspaceId, opts = {}) {
|
|
|
258877
258877
|
var import_react3, TTL_MS, cache6, lastResolved, cachedLimits;
|
|
258878
258878
|
var init_entitlements = __esm({
|
|
258879
258879
|
"lib/client/cloud/entitlements.ts"() {
|
|
258880
|
+
"use strict";
|
|
258880
258881
|
import_react3 = __toESM(require_react());
|
|
258881
258882
|
init_api3();
|
|
258882
258883
|
init_config2();
|
|
@@ -258924,6 +258925,7 @@ function facetsOf(meta3) {
|
|
|
258924
258925
|
var TEMPLATE_CATEGORIES, FACET_KEYS;
|
|
258925
258926
|
var init_vocabulary = __esm({
|
|
258926
258927
|
"lib/templates/vocabulary.ts"() {
|
|
258928
|
+
"use strict";
|
|
258927
258929
|
init_markers();
|
|
258928
258930
|
init_groups();
|
|
258929
258931
|
init_format();
|
|
@@ -258934,6 +258936,34 @@ var init_vocabulary = __esm({
|
|
|
258934
258936
|
}
|
|
258935
258937
|
});
|
|
258936
258938
|
|
|
258939
|
+
// lib/templates/upload.ts
|
|
258940
|
+
function templateUploadBody(t3, opts = {}) {
|
|
258941
|
+
const m = t3.meta;
|
|
258942
|
+
return {
|
|
258943
|
+
meta: {
|
|
258944
|
+
localId: m.id,
|
|
258945
|
+
name: m.name,
|
|
258946
|
+
description: m.description,
|
|
258947
|
+
kind: m.kind,
|
|
258948
|
+
category: m.category,
|
|
258949
|
+
tags: m.tags,
|
|
258950
|
+
sizes: t3.payload.variants.map((v) => v.sizeId),
|
|
258951
|
+
fonts: m.fonts,
|
|
258952
|
+
brandSlots: m.brandSlots,
|
|
258953
|
+
media: t3.payload.media,
|
|
258954
|
+
thumbnail: m.thumbnail,
|
|
258955
|
+
...opts.workspaceId ? { workspaceId: opts.workspaceId } : {},
|
|
258956
|
+
...facetsOf(m)
|
|
258957
|
+
},
|
|
258958
|
+
payload: t3.payload
|
|
258959
|
+
};
|
|
258960
|
+
}
|
|
258961
|
+
var init_upload = __esm({
|
|
258962
|
+
"lib/templates/upload.ts"() {
|
|
258963
|
+
init_vocabulary();
|
|
258964
|
+
}
|
|
258965
|
+
});
|
|
258966
|
+
|
|
258937
258967
|
// lib/templates/card.ts
|
|
258938
258968
|
var cardPayload, marketplaceTemplateCard;
|
|
258939
258969
|
var init_card = __esm({
|
|
@@ -295217,25 +295247,7 @@ async function refreshCloudTemplates() {
|
|
|
295217
295247
|
}
|
|
295218
295248
|
}
|
|
295219
295249
|
async function saveTemplateToCloud(t3, opts = {}) {
|
|
295220
|
-
const
|
|
295221
|
-
const body = {
|
|
295222
|
-
meta: {
|
|
295223
|
-
localId: m.id,
|
|
295224
|
-
name: m.name,
|
|
295225
|
-
description: m.description,
|
|
295226
|
-
kind: m.kind,
|
|
295227
|
-
category: m.category,
|
|
295228
|
-
tags: m.tags,
|
|
295229
|
-
sizes: t3.payload.variants.map((v) => v.sizeId),
|
|
295230
|
-
fonts: m.fonts,
|
|
295231
|
-
brandSlots: m.brandSlots,
|
|
295232
|
-
media: t3.payload.media,
|
|
295233
|
-
thumbnail: m.thumbnail,
|
|
295234
|
-
workspaceId: opts.workspaceId,
|
|
295235
|
-
...facetsOf(m)
|
|
295236
|
-
},
|
|
295237
|
-
payload: t3.payload
|
|
295238
|
-
};
|
|
295250
|
+
const body = templateUploadBody(t3, opts);
|
|
295239
295251
|
const { template: template2 } = await api("/api/templates", { method: "POST", json: body });
|
|
295240
295252
|
useCloudTemplates.setState((s) => ({ available: [template2, ...s.available.filter((x2) => x2.id !== template2.id)] }));
|
|
295241
295253
|
return template2;
|
|
@@ -295282,6 +295294,7 @@ async function searchTemplates(o = {}) {
|
|
|
295282
295294
|
if (o.category) sp.set("category", o.category);
|
|
295283
295295
|
if (o.animated) sp.set("animated", "1");
|
|
295284
295296
|
if (o.scope) sp.set("scope", o.scope);
|
|
295297
|
+
if (o.sort) sp.set("sort", o.sort);
|
|
295285
295298
|
if (o.cursor) sp.set("cursor", o.cursor);
|
|
295286
295299
|
if (o.limit) sp.set("limit", String(o.limit));
|
|
295287
295300
|
return api(`/api/templates?${sp}`);
|
|
@@ -295298,7 +295311,7 @@ var init_templates = __esm({
|
|
|
295298
295311
|
init_idb_keyval();
|
|
295299
295312
|
init_api3();
|
|
295300
295313
|
init_session();
|
|
295301
|
-
|
|
295314
|
+
init_upload();
|
|
295302
295315
|
init_card();
|
|
295303
295316
|
useCloudTemplates = create2(() => ({ available: [], loading: false, error: null, at: null }));
|
|
295304
295317
|
CACHE_KEY = "popcraft-cloud-templates";
|
|
@@ -295394,7 +295407,14 @@ async function createNewCloudFile(place3 = {}, seed2 = {}) {
|
|
|
295394
295407
|
return { ok: true, key: key5, docId: doc2.id, name: doc2.name, path: cloudFilePath(key5) };
|
|
295395
295408
|
}
|
|
295396
295409
|
async function createNewFile(place3 = {}, seed2 = {}) {
|
|
295397
|
-
|
|
295410
|
+
const result = await (goesLocal() ? createNewLocalFile(seed2) : createNewCloudFile(place3, seed2));
|
|
295411
|
+
const used = seed2.templateId ?? seed2.template?.meta.id;
|
|
295412
|
+
if (result.ok && !(result.local && result.reused) && used) countTemplateUse(used);
|
|
295413
|
+
return result;
|
|
295414
|
+
}
|
|
295415
|
+
function countTemplateUse(id3) {
|
|
295416
|
+
void Promise.resolve().then(() => (init_api3(), api_exports)).then(({ api: api3 }) => api3(`/api/templates/${encodeURIComponent(id3)}/installs`, { method: "POST" })).catch(() => {
|
|
295417
|
+
});
|
|
295398
295418
|
}
|
|
295399
295419
|
async function createNewFileOrExplain(place3 = {}, seed2 = {}) {
|
|
295400
295420
|
const result = await createNewFile(place3, seed2);
|
|
@@ -295412,6 +295432,7 @@ async function createFreshFileOrExplain(place3 = {}, seed2 = {}) {
|
|
|
295412
295432
|
var online, goesLocal;
|
|
295413
295433
|
var init_new_file = __esm({
|
|
295414
295434
|
"lib/client/cloud/new-file.ts"() {
|
|
295435
|
+
"use strict";
|
|
295415
295436
|
init_scene_graph();
|
|
295416
295437
|
init_print_pages();
|
|
295417
295438
|
init_page_presets();
|
|
@@ -313989,6 +314010,7 @@ popcraftMount(document.querySelector('[data-pc="0"]'), ${JSON.stringify(spec)});
|
|
|
313989
314010
|
var routeFile, routeUp, bytesOf;
|
|
313990
314011
|
var init_files = __esm({
|
|
313991
314012
|
"lib/io/web/project/files.ts"() {
|
|
314013
|
+
"use strict";
|
|
313992
314014
|
routeFile = (route2) => route2 === "/" ? "index.html" : `${route2.replace(/^\//, "")}/index.html`;
|
|
313993
314015
|
routeUp = (route2) => route2 === "/" ? "" : "../".repeat(route2.replace(/^\//, "").split("/").length);
|
|
313994
314016
|
bytesOf = (f2) => typeof f2.content === "string" ? new TextEncoder().encode(f2.content) : f2.content;
|
|
@@ -315008,7 +315030,7 @@ var init_package = __esm({
|
|
|
315008
315030
|
"packages/runtime/package.json"() {
|
|
315009
315031
|
package_default = {
|
|
315010
315032
|
name: "@popcraft/runtime",
|
|
315011
|
-
version: "0.
|
|
315033
|
+
version: "0.4.0",
|
|
315012
315034
|
description: "What code exported from PopCraft shares: the meaning of expressions (operators and functions) and, as it grows, the parts of a design's behaviour that are common code rather than generated React.",
|
|
315013
315035
|
license: "MIT",
|
|
315014
315036
|
homepage: "https://popcraft.app/docs/exporting/nextjs",
|
|
@@ -339861,6 +339883,7 @@ function fieldPart(nodes, id3) {
|
|
|
339861
339883
|
var cleanName2;
|
|
339862
339884
|
var init_controls = __esm({
|
|
339863
339885
|
"lib/document/controls.ts"() {
|
|
339886
|
+
"use strict";
|
|
339864
339887
|
cleanName2 = (raw) => raw.trim().replace(/[^A-Za-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
339865
339888
|
}
|
|
339866
339889
|
});
|
|
@@ -340804,6 +340827,7 @@ function routesOf(screens) {
|
|
|
340804
340827
|
var slug2;
|
|
340805
340828
|
var init_routes = __esm({
|
|
340806
340829
|
"lib/document/routes.ts"() {
|
|
340830
|
+
"use strict";
|
|
340807
340831
|
slug2 = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
340808
340832
|
}
|
|
340809
340833
|
});
|
|
@@ -346722,7 +346746,7 @@ async function publishFiles(via, files, opts = {}) {
|
|
|
346722
346746
|
}));
|
|
346723
346747
|
return await via.manifest({ slug: opts.slug, files: manifest2, commit: true });
|
|
346724
346748
|
}
|
|
346725
|
-
var
|
|
346749
|
+
var init_upload2 = __esm({
|
|
346726
346750
|
"lib/sites/upload.ts"() {
|
|
346727
346751
|
}
|
|
346728
346752
|
});
|
|
@@ -346746,8 +346770,9 @@ function publishSite(key5, files, opts = {}) {
|
|
|
346746
346770
|
var siteStatus, setSiteVersion, renameSite;
|
|
346747
346771
|
var init_sites = __esm({
|
|
346748
346772
|
"lib/client/cloud/sites.ts"() {
|
|
346773
|
+
"use strict";
|
|
346749
346774
|
init_files();
|
|
346750
|
-
|
|
346775
|
+
init_upload2();
|
|
346751
346776
|
init_api3();
|
|
346752
346777
|
siteStatus = (key5) => api(`/api/sites${key5 ? `/${key5}` : ""}?t=${Date.now()}`);
|
|
346753
346778
|
setSiteVersion = (key5, version6) => api(`/api/sites/${key5}`, { method: "PATCH", json: { currentVersion: version6 } });
|
|
@@ -390802,7 +390827,7 @@ function operations(spec = openapi) {
|
|
|
390802
390827
|
}
|
|
390803
390828
|
async function call(target2, method, path, opts = {}) {
|
|
390804
390829
|
const qs = new URLSearchParams(opts.query ?? {}).toString();
|
|
390805
|
-
const headers = { "user-agent": `popcraft-cli/${"0.
|
|
390830
|
+
const headers = { "user-agent": `popcraft-cli/${"0.4.0"}`, ...opts.headers };
|
|
390806
390831
|
if (target2.token) headers.authorization = `Bearer ${target2.token}`;
|
|
390807
390832
|
if (opts.contentType) headers["content-type"] = opts.contentType;
|
|
390808
390833
|
try {
|
|
@@ -391762,7 +391787,7 @@ async function runPublish(root2, opts, target2, out) {
|
|
|
391762
391787
|
// packages/cli/src/main.ts
|
|
391763
391788
|
init_resources();
|
|
391764
391789
|
init_hypery();
|
|
391765
|
-
var VERSION2 = "0.
|
|
391790
|
+
var VERSION2 = "0.4.0";
|
|
391766
391791
|
var HELP = `popcraft ${VERSION2} \u2014 the PopCraft command line
|
|
391767
391792
|
|
|
391768
391793
|
Files (headless, on .popcraft files):
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@popcraft/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "The PopCraft command line: edit .popcraft files headlessly, call the REST API, publish to the marketplace and manage the desktop app's local plugins, themes, fonts, skills and agents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://popcraft.app/docs/api/cli",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"esbuild": "0.28.2"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@popcraft/kit": "0.
|
|
37
|
+
"@popcraft/kit": "0.4.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "node build.mjs",
|