@popcraft/cli 0.38.6 → 0.39.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.
Files changed (2) hide show
  1. package/dist/popcraft.mjs +105 -88
  2. package/package.json +2 -2
package/dist/popcraft.mjs CHANGED
@@ -1196,7 +1196,7 @@ function operations(spec = openapi) {
1196
1196
  }
1197
1197
  async function call(target2, method, path, opts = {}) {
1198
1198
  const qs = new URLSearchParams(opts.query ?? {}).toString();
1199
- const headers = { "user-agent": `popcraft-cli/${"0.38.6"}`, ...opts.headers };
1199
+ const headers = { "user-agent": `popcraft-cli/${"0.39.0"}`, ...opts.headers };
1200
1200
  if (target2.token) headers.authorization = `Bearer ${target2.token}`;
1201
1201
  if (opts.contentType) headers["content-type"] = opts.contentType;
1202
1202
  try {
@@ -96510,7 +96510,6 @@ function releaseMediaMemory(hash3) {
96510
96510
  var key2, peaksKey, objectUrls, sourceKey, remoteResolver, MEDIA_FETCH_TIMEOUT_MS, SHIPPED_MEDIA_PATH, notShipped, MEDIA_SCHEME, isImageDataUrl, memory, pendingLoads, sourceAliases, PAINT_KEYS, URL_KEYS;
96511
96511
  var init_media_store = __esm({
96512
96512
  "lib/storage/media-store.ts"() {
96513
- "use strict";
96514
96513
  init_media_types();
96515
96514
  init_idb();
96516
96515
  init_media_hash();
@@ -261894,6 +261893,87 @@ var init_runtime3 = __esm({
261894
261893
  }
261895
261894
  });
261896
261895
 
261896
+ // lib/desktop/tauri.ts
261897
+ function tauri() {
261898
+ if (typeof window === "undefined") return null;
261899
+ return window.__TAURI__ ?? null;
261900
+ }
261901
+ function storePlatform() {
261902
+ if (typeof window === "undefined") return null;
261903
+ const flag = window.__POPCRAFT_PLATFORM__;
261904
+ if (flag === "ios" || flag === "android" || flag === "macos") return flag;
261905
+ if (!tauri() || typeof navigator === "undefined") return null;
261906
+ if (/iPhone|iPad|iPod/.test(navigator.userAgent)) return "ios";
261907
+ if (/Macintosh/.test(navigator.userAgent) && navigator.maxTouchPoints > 1) return "ios";
261908
+ if (/Android/.test(navigator.userAgent)) return "android";
261909
+ return null;
261910
+ }
261911
+ async function shareFileNatively(blob, name2, print2 = false) {
261912
+ const t3 = tauri();
261913
+ if (!t3 || storePlatform() !== "ios") return false;
261914
+ await t3.core.invoke("share_file", { name: name2, print: print2, data: await blobToBase64(blob) });
261915
+ return true;
261916
+ }
261917
+ function blobToBase64(blob) {
261918
+ return new Promise((resolve6, reject) => {
261919
+ const reader = new FileReader();
261920
+ reader.onload = () => resolve6(String(reader.result).slice(String(reader.result).indexOf(",") + 1));
261921
+ reader.onerror = () => reject(reader.error ?? new Error("Could not read the file"));
261922
+ reader.readAsDataURL(blob);
261923
+ });
261924
+ }
261925
+ function invoke(cmd, args2) {
261926
+ const t3 = tauri();
261927
+ return t3 ? t3.core.invoke(cmd, args2) : Promise.reject(new Error("Not running in the desktop app"));
261928
+ }
261929
+ function listenDesktop(event, handler) {
261930
+ const t3 = tauri();
261931
+ if (!t3) return () => {
261932
+ };
261933
+ let off = null;
261934
+ let cancelled = false;
261935
+ void t3.event.listen(event, (e) => handler(e.payload)).then((fn) => {
261936
+ if (cancelled) fn();
261937
+ else off = fn;
261938
+ });
261939
+ return () => {
261940
+ cancelled = true;
261941
+ off?.();
261942
+ };
261943
+ }
261944
+ var isDesktop;
261945
+ var init_tauri = __esm({
261946
+ "lib/desktop/tauri.ts"() {
261947
+ isDesktop = () => !!tauri();
261948
+ }
261949
+ });
261950
+
261951
+ // lib/desktop/open-link.ts
261952
+ function openLink(href) {
261953
+ if (isDesktop()) window.location.assign(href);
261954
+ else window.open(href, "_blank", "noopener");
261955
+ }
261956
+ function openSitePage(path) {
261957
+ if (!isDesktop()) {
261958
+ window.open(path, "_blank", "noopener");
261959
+ return;
261960
+ }
261961
+ const url4 = new URL(path, window.location.origin).href;
261962
+ invoke("open_external", { url: url4 }).catch(() => window.location.assign(path));
261963
+ }
261964
+ function openBeside(href) {
261965
+ if (!isDesktop()) return !!window.open(href, "_blank", "noopener,noreferrer");
261966
+ const url4 = new URL(href, window.location.href);
261967
+ if (url4.origin === window.location.origin) openSitePage(url4.pathname + url4.search + url4.hash);
261968
+ else window.location.assign(url4.href);
261969
+ return true;
261970
+ }
261971
+ var init_open_link = __esm({
261972
+ "lib/desktop/open-link.ts"() {
261973
+ init_tauri();
261974
+ }
261975
+ });
261976
+
261897
261977
  // lib/plugins/plugin-store.ts
261898
261978
  var plugin_store_exports = {};
261899
261979
  __export(plugin_store_exports, {
@@ -261967,61 +262047,6 @@ var init_plan_limit = __esm({
261967
262047
  }
261968
262048
  });
261969
262049
 
261970
- // lib/desktop/tauri.ts
261971
- function tauri() {
261972
- if (typeof window === "undefined") return null;
261973
- return window.__TAURI__ ?? null;
261974
- }
261975
- function storePlatform() {
261976
- if (typeof window === "undefined") return null;
261977
- const flag = window.__POPCRAFT_PLATFORM__;
261978
- if (flag === "ios" || flag === "android" || flag === "macos") return flag;
261979
- if (!tauri() || typeof navigator === "undefined") return null;
261980
- if (/iPhone|iPad|iPod/.test(navigator.userAgent)) return "ios";
261981
- if (/Macintosh/.test(navigator.userAgent) && navigator.maxTouchPoints > 1) return "ios";
261982
- if (/Android/.test(navigator.userAgent)) return "android";
261983
- return null;
261984
- }
261985
- async function shareFileNatively(blob, name2, print2 = false) {
261986
- const t3 = tauri();
261987
- if (!t3 || storePlatform() !== "ios") return false;
261988
- await t3.core.invoke("share_file", { name: name2, print: print2, data: await blobToBase64(blob) });
261989
- return true;
261990
- }
261991
- function blobToBase64(blob) {
261992
- return new Promise((resolve6, reject) => {
261993
- const reader = new FileReader();
261994
- reader.onload = () => resolve6(String(reader.result).slice(String(reader.result).indexOf(",") + 1));
261995
- reader.onerror = () => reject(reader.error ?? new Error("Could not read the file"));
261996
- reader.readAsDataURL(blob);
261997
- });
261998
- }
261999
- function invoke(cmd, args2) {
262000
- const t3 = tauri();
262001
- return t3 ? t3.core.invoke(cmd, args2) : Promise.reject(new Error("Not running in the desktop app"));
262002
- }
262003
- function listenDesktop(event, handler) {
262004
- const t3 = tauri();
262005
- if (!t3) return () => {
262006
- };
262007
- let off = null;
262008
- let cancelled = false;
262009
- void t3.event.listen(event, (e) => handler(e.payload)).then((fn) => {
262010
- if (cancelled) fn();
262011
- else off = fn;
262012
- });
262013
- return () => {
262014
- cancelled = true;
262015
- off?.();
262016
- };
262017
- }
262018
- var isDesktop;
262019
- var init_tauri = __esm({
262020
- "lib/desktop/tauri.ts"() {
262021
- isDesktop = () => !!tauri();
262022
- }
262023
- });
262024
-
262025
262050
  // lib/i18n/format.ts
262026
262051
  function cached2(kind, opts, make) {
262027
262052
  const locale = intlLocale(getLocale());
@@ -310331,6 +310356,7 @@ async function createFreshFileOrExplain(place4 = {}, seed2 = {}) {
310331
310356
  var online, goesLocal;
310332
310357
  var init_new_file = __esm({
310333
310358
  "lib/client/cloud/new-file.ts"() {
310359
+ "use strict";
310334
310360
  init_scene_graph();
310335
310361
  init_print_pages();
310336
310362
  init_page_presets();
@@ -311077,6 +311103,7 @@ async function dispatchShaped(key5, options) {
311077
311103
  var onViolation;
311078
311104
  var init_dispatch = __esm({
311079
311105
  "lib/commands/dispatch.ts"() {
311106
+ "use strict";
311080
311107
  init_errors();
311081
311108
  init_registry();
311082
311109
  init_confirm();
@@ -311255,7 +311282,6 @@ function browserDownload(blob, filename) {
311255
311282
  }
311256
311283
  var init_download = __esm({
311257
311284
  "lib/io/download.ts"() {
311258
- "use strict";
311259
311285
  init_tauri();
311260
311286
  }
311261
311287
  });
@@ -327394,7 +327420,7 @@ var init_package = __esm({
327394
327420
  "packages/runtime/package.json"() {
327395
327421
  package_default = {
327396
327422
  name: "@popcraft/runtime",
327397
- version: "0.38.6",
327423
+ version: "0.39.0",
327398
327424
  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.",
327399
327425
  license: "MIT",
327400
327426
  homepage: "https://popcraft.app/docs/exporting/nextjs",
@@ -352060,6 +352086,7 @@ function exportsOf(source3) {
352060
352086
  var CODE_LIMITS, packageOf;
352061
352087
  var init_source2 = __esm({
352062
352088
  "lib/code/source.ts"() {
352089
+ "use strict";
352063
352090
  CODE_LIMITS = { modules: 100, sourceLength: 2e5, packages: 12 };
352064
352091
  packageOf = (spec) => spec.split("/").slice(0, spec.startsWith("@") ? 2 : 1).join("/");
352065
352092
  }
@@ -360703,6 +360730,7 @@ __export(integrations_exports, {
360703
360730
  siteBackend: () => siteBackend
360704
360731
  });
360705
360732
  function connectWithOAuth(workspaceId, provider2) {
360733
+ if (storePlatform() === "ios" || storePlatform() === "macos") return connectInSheet(workspaceId, provider2);
360706
360734
  const popup = window.open("", "popcraft-integration", "popup,width=640,height=760");
360707
360735
  if (!popup) return Promise.reject(new Error("The browser blocked the window. Allow pop-ups for PopCraft and try again."));
360708
360736
  return new Promise((resolve6, reject) => {
@@ -360733,6 +360761,11 @@ function connectWithOAuth(workspaceId, provider2) {
360733
360761
  });
360734
360762
  });
360735
360763
  }
360764
+ async function connectInSheet(workspaceId, provider2) {
360765
+ const { url: url4 } = await api(`/api/integrations/${encodeURIComponent(provider2)}/authorize`, { method: "POST", json: { workspaceId, app: true } });
360766
+ const done = new URL(await invoke("auth_session_open", { url: url4 }));
360767
+ if (done.searchParams.get("ok") !== "1") throw new Error(done.searchParams.get("error") || "The account was not connected.");
360768
+ }
360736
360769
  async function sha12(bytes2) {
360737
360770
  const digest = await crypto.subtle.digest("SHA-1", bytes2);
360738
360771
  return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
@@ -360753,6 +360786,7 @@ async function deployStore(key5, id3, files, env, onProgress) {
360753
360786
  var integrationsWorkspaceId, listWorkspaceIntegrations, connectWithToken, disconnect, listResources, createResource, listDestinations, addDestination, removeDestination, deployDestination, siteBackend, attachDatabase, setSignIn, detachDatabase, listSubmissions, listCandidates, createDatabase, createDestination;
360754
360787
  var init_integrations = __esm({
360755
360788
  "lib/client/cloud/integrations.ts"() {
360789
+ init_tauri();
360756
360790
  init_api4();
360757
360791
  init_team();
360758
360792
  integrationsWorkspaceId = () => activeTeamWorkspaceId() ?? useHyperyTeam.getState().personalWorkspaceId;
@@ -361126,6 +361160,7 @@ var init_delete_current_file = __esm({
361126
361160
  var storeOpsSeam;
361127
361161
  var init_seams = __esm({
361128
361162
  "lib/commands/seams.ts"() {
361163
+ "use strict";
361129
361164
  storeOpsSeam = (st) => ({
361130
361165
  booleanOperation: (op4) => st().booleanOperation(op4),
361131
361166
  flatten: () => st().flattenSelection(),
@@ -362268,17 +362303,6 @@ var init_billing = __esm({
362268
362303
  }
362269
362304
  });
362270
362305
 
362271
- // lib/desktop/open-link.ts
362272
- function openLink(href) {
362273
- if (isDesktop()) window.location.assign(href);
362274
- else window.open(href, "_blank", "noopener");
362275
- }
362276
- var init_open_link = __esm({
362277
- "lib/desktop/open-link.ts"() {
362278
- init_tauri();
362279
- }
362280
- });
362281
-
362282
362306
  // lib/client/cloud/buy-credits.ts
362283
362307
  var buy_credits_exports = {};
362284
362308
  __export(buy_credits_exports, {
@@ -365204,14 +365228,7 @@ function exportToJSON(document2) {
365204
365228
  async function downloadJSON(document2, filename = "document.json") {
365205
365229
  const json3 = exportToJSON(await portableDocument(document2));
365206
365230
  const blob = new Blob([json3], { type: "application/json" });
365207
- const url4 = URL.createObjectURL(blob);
365208
- const link2 = window.document.createElement("a");
365209
- link2.href = url4;
365210
- link2.download = filename;
365211
- window.document.body.appendChild(link2);
365212
- link2.click();
365213
- window.document.body.removeChild(link2);
365214
- URL.revokeObjectURL(url4);
365231
+ downloadBlob(blob, filename);
365215
365232
  }
365216
365233
  function importFromJSON(jsonString) {
365217
365234
  try {
@@ -365242,6 +365259,7 @@ var init_json_export = __esm({
365242
365259
  "lib/io/json-export.ts"() {
365243
365260
  init_media_store();
365244
365261
  init_document_fonts();
365262
+ init_download();
365245
365263
  }
365246
365264
  });
365247
365265
 
@@ -396128,8 +396146,7 @@ async function runPlugin(pluginId, commandId, opts = {}) {
396128
396146
  storageGet: (key5) => pluginStorageGet(pluginId, key5),
396129
396147
  storageSet: (key5, value3) => pluginStorageSet(pluginId, key5, value3),
396130
396148
  openExternal: (url4) => {
396131
- const opened = window.open(url4, "_blank", "noopener,noreferrer");
396132
- if (!opened) throw new Error("The browser blocked the new tab");
396149
+ if (!openBeside(url4)) throw new Error("The browser blocked the new tab");
396133
396150
  },
396134
396151
  createDocument: async (opts2) => {
396135
396152
  const { createFreshFileOrExplain: createFreshFileOrExplain2 } = await Promise.resolve().then(() => (init_new_file(), new_file_exports));
@@ -396297,6 +396314,7 @@ var init_host3 = __esm({
396297
396314
  init_sync2();
396298
396315
  init_theme_store();
396299
396316
  init_panels();
396317
+ init_open_link();
396300
396318
  running3 = /* @__PURE__ */ new Map();
396301
396319
  if (typeof window !== "undefined" && false) {
396302
396320
  window.__vpPlugins = { installPluginPayload, runPlugin, dispatchWidgetClick, closeSession, removePlugin, setEnabled, running: running3 };
@@ -398201,6 +398219,7 @@ function record(source, namespaces, globals, limits) {
398201
398219
  var HELPER_NAMES;
398202
398220
  var init_helper_names = __esm({
398203
398221
  "lib/agent/design-script/helper-names.ts"() {
398222
+ "use strict";
398204
398223
  HELPER_NAMES = ["draw", "marks", "fit", "motion", "captions", "overlays", "texture", "pointer", "windows", "devices", "type", "beat", "web", "social", "video", "site", "effects"];
398205
398224
  }
398206
398225
  });
@@ -398583,6 +398602,7 @@ function designRecorder() {
398583
398602
  var installed;
398584
398603
  var init_recorders = __esm({
398585
398604
  "lib/agent/design-script/recorders.ts"() {
398605
+ "use strict";
398586
398606
  installed = null;
398587
398607
  }
398588
398608
  });
@@ -399582,12 +399602,7 @@ async function exportLayerPng(id3) {
399582
399602
  const px5 = await l.readPixels(id3);
399583
399603
  if (!px5) return;
399584
399604
  const png = await encodePng(px5.width, px5.height, px5.data);
399585
- const url4 = URL.createObjectURL(new Blob([png], { type: "image/png" }));
399586
- const a = document.createElement("a");
399587
- a.href = url4;
399588
- a.download = `${node2.name || "paint-layer"}.png`;
399589
- a.click();
399590
- setTimeout(() => URL.revokeObjectURL(url4), 5e3);
399605
+ downloadBlob(new Blob([png], { type: "image/png" }), `${node2.name || "paint-layer"}.png`);
399591
399606
  }
399592
399607
  function clearPaintLayer(id3) {
399593
399608
  useEditorStore.getState().commitRasterTiles(id3, {}, "Clear paint layer");
@@ -399635,6 +399650,7 @@ var init_raster_actions = __esm({
399635
399650
  init_png();
399636
399651
  init_raster_tiles();
399637
399652
  init_canvas_dpr();
399653
+ init_download();
399638
399654
  notice4 = (text) => window.dispatchEvent(new CustomEvent("popcraft-notice", { detail: { text } }));
399639
399655
  }
399640
399656
  });
@@ -404755,6 +404771,7 @@ var init_editor_store = __esm({
404755
404771
  init_library_link();
404756
404772
  init_fonts();
404757
404773
  init_runtime3();
404774
+ init_open_link();
404758
404775
  STICKY_PROP_KEYS = [
404759
404776
  "strokes",
404760
404777
  "fills",
@@ -405320,7 +405337,7 @@ var init_editor_store = __esm({
405320
405337
  if (e.settle) setTimeout(() => get4().focusOnNode(e.screen), 10);
405321
405338
  else get4().focusOnNode(e.screen);
405322
405339
  } else if (e.kind === "open") {
405323
- window.open(e.href, "_blank", "noopener,noreferrer");
405340
+ openBeside(e.href);
405324
405341
  } else {
405325
405342
  setTimeout(() => {
405326
405343
  const at4 = runtimeOf(get4());
@@ -410993,7 +411010,7 @@ init_resources();
410993
411010
  init_desktop();
410994
411011
  init_hypery();
410995
411012
  import { createInterface } from "node:readline";
410996
- var VERSION2 = "0.38.6";
411013
+ var VERSION2 = "0.39.0";
410997
411014
  var HELP = `popcraft ${VERSION2} \u2014 the PopCraft command line
410998
411015
 
410999
411016
  Files (headless, on .popcraft files):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popcraft/cli",
3
- "version": "0.38.6",
3
+ "version": "0.39.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.38.6"
37
+ "@popcraft/kit": "0.39.0"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "node build.mjs",