@swipt/cli 0.1.0-nightly.83 → 0.1.0-nightly.85

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 (115) hide show
  1. package/dist/bin/swipt.js +9 -0
  2. package/dist/bin/swipt.js.map +1 -0
  3. package/dist/cli/cli.js +184 -0
  4. package/dist/cli/cli.js.map +1 -0
  5. package/dist/cli/command.js +5 -0
  6. package/dist/cli/command.js.map +1 -0
  7. package/dist/cli/commands/data/clear.js +27 -0
  8. package/dist/cli/commands/data/clear.js.map +1 -0
  9. package/dist/cli/commands/data/data.js +22 -0
  10. package/dist/cli/commands/data/data.js.map +1 -0
  11. package/dist/cli/commands/data/index.js +1 -0
  12. package/dist/cli/commands/data/list.js +37 -0
  13. package/dist/cli/commands/data/list.js.map +1 -0
  14. package/dist/cli/commands/data/operand.js +5 -0
  15. package/dist/cli/commands/data/operand.js.map +1 -0
  16. package/dist/cli/commands/data/read.js +122 -0
  17. package/dist/cli/commands/data/read.js.map +1 -0
  18. package/dist/cli/commands/data/remove.js +30 -0
  19. package/dist/cli/commands/data/remove.js.map +1 -0
  20. package/dist/cli/commands/data/write.js +37 -0
  21. package/dist/cli/commands/data/write.js.map +1 -0
  22. package/dist/cli/commands/device/add.js +14 -0
  23. package/dist/cli/commands/device/add.js.map +1 -0
  24. package/dist/cli/commands/device/device.js +22 -0
  25. package/dist/cli/commands/device/device.js.map +1 -0
  26. package/dist/cli/commands/device/index.js +1 -0
  27. package/dist/cli/commands/device/list.js +13 -0
  28. package/dist/cli/commands/device/list.js.map +1 -0
  29. package/dist/cli/commands/device/logs.js +104 -0
  30. package/dist/cli/commands/device/logs.js.map +1 -0
  31. package/dist/cli/commands/device/remove.js +14 -0
  32. package/dist/cli/commands/device/remove.js.map +1 -0
  33. package/dist/cli/commands/device/stop.js +19 -0
  34. package/dist/cli/commands/device/stop.js.map +1 -0
  35. package/dist/cli/commands/flags.js +57 -0
  36. package/dist/cli/commands/flags.js.map +1 -0
  37. package/dist/cli/commands/index.js +30 -0
  38. package/dist/cli/commands/index.js.map +1 -0
  39. package/dist/cli/commands/project/build.js +18 -0
  40. package/dist/cli/commands/project/build.js.map +1 -0
  41. package/dist/cli/commands/project/create.js +109 -0
  42. package/dist/cli/commands/project/create.js.map +1 -0
  43. package/dist/cli/commands/project/deploy.js +23 -0
  44. package/dist/cli/commands/project/deploy.js.map +1 -0
  45. package/dist/cli/commands/project/develop.js +146 -0
  46. package/dist/cli/commands/project/develop.js.map +1 -0
  47. package/dist/cli/commands/project/index.js +1 -0
  48. package/dist/cli/commands/project/project.js +22 -0
  49. package/dist/cli/commands/project/project.js.map +1 -0
  50. package/dist/cli/commands/project/source.js +126 -0
  51. package/dist/cli/commands/project/source.js.map +1 -0
  52. package/dist/cli/commands/repl/api.js +16 -0
  53. package/dist/cli/commands/repl/api.js.map +1 -0
  54. package/dist/cli/commands/repl/index.js +1 -0
  55. package/dist/cli/commands/repl/repl.js +29 -0
  56. package/dist/cli/commands/repl/repl.js.map +1 -0
  57. package/dist/cli/commands/repl/reset.js +14 -0
  58. package/dist/cli/commands/repl/reset.js.map +1 -0
  59. package/dist/cli/commands/repl/run.js +108 -0
  60. package/dist/cli/commands/repl/run.js.map +1 -0
  61. package/dist/cli/commands/sideload/index.js +1 -0
  62. package/dist/cli/commands/sideload/install.js +19 -0
  63. package/dist/cli/commands/sideload/install.js.map +1 -0
  64. package/dist/cli/commands/sideload/setup.js +18 -0
  65. package/dist/cli/commands/sideload/setup.js.map +1 -0
  66. package/dist/cli/commands/sideload/sideload.js +22 -0
  67. package/dist/cli/commands/sideload/sideload.js.map +1 -0
  68. package/dist/cli/commands/sideload/uninstall.js +13 -0
  69. package/dist/cli/commands/sideload/uninstall.js.map +1 -0
  70. package/dist/cli/commands/sideload/update.js +19 -0
  71. package/dist/cli/commands/sideload/update.js.map +1 -0
  72. package/dist/cli/commands/swiplet/call.js +57 -0
  73. package/dist/cli/commands/swiplet/call.js.map +1 -0
  74. package/dist/cli/commands/swiplet/index.js +1 -0
  75. package/dist/cli/commands/swiplet/install.js +21 -0
  76. package/dist/cli/commands/swiplet/install.js.map +1 -0
  77. package/dist/cli/commands/swiplet/list.js +42 -0
  78. package/dist/cli/commands/swiplet/list.js.map +1 -0
  79. package/dist/cli/commands/swiplet/remove.js +18 -0
  80. package/dist/cli/commands/swiplet/remove.js.map +1 -0
  81. package/dist/cli/commands/swiplet/service/disable.js +18 -0
  82. package/dist/cli/commands/swiplet/service/disable.js.map +1 -0
  83. package/dist/cli/commands/swiplet/service/enable.js +18 -0
  84. package/dist/cli/commands/swiplet/service/enable.js.map +1 -0
  85. package/dist/cli/commands/swiplet/service/index.js +1 -0
  86. package/dist/cli/commands/swiplet/service/service.js +18 -0
  87. package/dist/cli/commands/swiplet/service/service.js.map +1 -0
  88. package/dist/cli/commands/swiplet/service/services.js +21 -0
  89. package/dist/cli/commands/swiplet/service/services.js.map +1 -0
  90. package/dist/cli/commands/swiplet/service/watch.js +16 -0
  91. package/dist/cli/commands/swiplet/service/watch.js.map +1 -0
  92. package/dist/cli/commands/swiplet/show.js +38 -0
  93. package/dist/cli/commands/swiplet/show.js.map +1 -0
  94. package/dist/cli/commands/swiplet/swiplet.js +42 -0
  95. package/dist/cli/commands/swiplet/swiplet.js.map +1 -0
  96. package/dist/cli/commands/version/index.js +1 -0
  97. package/dist/cli/commands/version/version.js +17 -0
  98. package/dist/cli/commands/version/version.js.map +1 -0
  99. package/dist/cli/deploy.js +20 -0
  100. package/dist/cli/deploy.js.map +1 -0
  101. package/dist/cli/io.js +7 -0
  102. package/dist/cli/io.js.map +1 -0
  103. package/dist/cli/session.js +6 -0
  104. package/dist/cli/session.js.map +1 -0
  105. package/dist/metro.js +1 -1
  106. package/dist/project.d.ts +2 -3
  107. package/dist/project.js +2 -203
  108. package/dist/project.js.map +1 -1
  109. package/package.json +5 -5
  110. package/dist/device.d.ts +0 -130
  111. package/dist/device.js +0 -539
  112. package/dist/device.js.map +0 -1
  113. package/dist/swipt.js +0 -631
  114. package/dist/swipt.js.map +0 -1
  115. /package/dist/{swipt.d.ts → bin/swipt.d.ts} +0 -0
@@ -0,0 +1,18 @@
1
+ import { tr } from "../../../i18n.js";
2
+ import { defineCommand } from "../../command.js";
3
+ import { session } from "../../session.js";
4
+ // src/cli/commands/swiplet/remove.ts
5
+ const removeSwiplet = (context) => session(context, async (client) => {
6
+ await client.swiplets.removeSwiplet({ swipletId: context.args[0] }, { signal: context.signal });
7
+ console.log(tr("removed {name}", { name: context.args[0] }));
8
+ });
9
+ const remove = defineCommand({
10
+ name: "remove",
11
+ use: "remove ID",
12
+ short: tr("Remove a swiplet"),
13
+ args: [1, 1],
14
+ run: removeSwiplet
15
+ });
16
+ export { remove };
17
+
18
+ //# sourceMappingURL=remove.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.js","names":[],"sources":["../../../../src/cli/commands/swiplet/remove.ts"],"sourcesContent":["import { tr } from \"../../../i18n\";\nimport { defineCommand } from \"../../command\";\nimport { session } from \"../../session\";\n\nconst removeSwiplet = (context) =>\n session(context, async (client) => {\n await client.swiplets.removeSwiplet(\n { swipletId: context.args[0] },\n { signal: context.signal },\n );\n console.log(tr(\"removed {name}\", { name: context.args[0] }));\n });\n\nexport const remove = defineCommand({\n name: \"remove\",\n use: \"remove ID\",\n short: tr(\"Remove a swiplet\"),\n args: [1, 1],\n run: removeSwiplet,\n});\n"],"mappings":";;;;AAIA,MAAM,iBAAiB,YACrB,QAAQ,SAAS,OAAO,WAAW;CACjC,MAAM,OAAO,SAAS,cACpB,EAAE,WAAW,QAAQ,KAAK,GAAG,GAC7B,EAAE,QAAQ,QAAQ,OAAO,CAC3B;CACA,QAAQ,IAAI,GAAG,kBAAkB,EAAE,MAAM,QAAQ,KAAK,GAAG,CAAC,CAAC;AAC7D,CAAC;AAEH,MAAa,SAAS,cAAc;CAClC,MAAM;CACN,KAAK;CACL,OAAO,GAAG,kBAAkB;CAC5B,MAAM,CAAC,GAAG,CAAC;CACX,KAAK;AACP,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { tr } from "../../../../i18n.js";
2
+ import { defineCommand } from "../../../command.js";
3
+ import { setService } from "./services.js";
4
+ // src/cli/commands/swiplet/service/disable.ts
5
+ const disable = defineCommand({
6
+ name: "disable",
7
+ use: "disable ID",
8
+ short: tr("Turn off a swiplet service"),
9
+ args: [1, 1],
10
+ options: { watch: {
11
+ type: "boolean",
12
+ help: tr("watch the state")
13
+ } },
14
+ run: setService(false)
15
+ });
16
+ export { disable };
17
+
18
+ //# sourceMappingURL=disable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"disable.js","names":[],"sources":["../../../../../src/cli/commands/swiplet/service/disable.ts"],"sourcesContent":["import { tr } from \"../../../../i18n\";\nimport { defineCommand } from \"../../../command\";\nimport { setService } from \"./services\";\n\nexport const disable = defineCommand({\n name: \"disable\",\n use: \"disable ID\",\n short: tr(\"Turn off a swiplet service\"),\n args: [1, 1],\n options: {\n watch: { type: \"boolean\", help: tr(\"watch the state\") },\n },\n run: setService(false),\n});\n"],"mappings":";;;;AAIA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,KAAK;CACL,OAAO,GAAG,4BAA4B;CACtC,MAAM,CAAC,GAAG,CAAC;CACX,SAAS,EACP,OAAO;EAAE,MAAM;EAAW,MAAM,GAAG,iBAAiB;CAAE,EACxD;CACA,KAAK,WAAW,KAAK;AACvB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { tr } from "../../../../i18n.js";
2
+ import { defineCommand } from "../../../command.js";
3
+ import { setService } from "./services.js";
4
+ // src/cli/commands/swiplet/service/enable.ts
5
+ const enable = defineCommand({
6
+ name: "enable",
7
+ use: "enable ID",
8
+ short: tr("Turn on a swiplet service"),
9
+ args: [1, 1],
10
+ options: { watch: {
11
+ type: "boolean",
12
+ help: tr("watch the state")
13
+ } },
14
+ run: setService(true)
15
+ });
16
+ export { enable };
17
+
18
+ //# sourceMappingURL=enable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enable.js","names":[],"sources":["../../../../../src/cli/commands/swiplet/service/enable.ts"],"sourcesContent":["import { tr } from \"../../../../i18n\";\nimport { defineCommand } from \"../../../command\";\nimport { setService } from \"./services\";\n\nexport const enable = defineCommand({\n name: \"enable\",\n use: \"enable ID\",\n short: tr(\"Turn on a swiplet service\"),\n args: [1, 1],\n options: {\n watch: { type: \"boolean\", help: tr(\"watch the state\") },\n },\n run: setService(true),\n});\n"],"mappings":";;;;AAIA,MAAa,SAAS,cAAc;CAClC,MAAM;CACN,KAAK;CACL,OAAO,GAAG,2BAA2B;CACrC,MAAM,CAAC,GAAG,CAAC;CACX,SAAS,EACP,OAAO;EAAE,MAAM;EAAW,MAAM,GAAG,iBAAiB;CAAE,EACxD;CACA,KAAK,WAAW,IAAI;AACtB,CAAC"}
@@ -0,0 +1 @@
1
+ export { service } from "./service.js";
@@ -0,0 +1,18 @@
1
+ import { tr } from "../../../../i18n.js";
2
+ import { defineCommand } from "../../../command.js";
3
+ import { disable } from "./disable.js";
4
+ import { enable } from "./enable.js";
5
+ import { watch } from "./watch.js";
6
+ // src/cli/commands/swiplet/service/service.ts
7
+ const service = defineCommand({
8
+ name: "service",
9
+ short: tr("Manage swiplet services"),
10
+ commands: [
11
+ enable,
12
+ disable,
13
+ watch
14
+ ]
15
+ });
16
+ export { service };
17
+
18
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","names":[],"sources":["../../../../../src/cli/commands/swiplet/service/service.ts"],"sourcesContent":["import { tr } from \"../../../../i18n\";\nimport { defineCommand } from \"../../../command\";\nimport { disable } from \"./disable\";\nimport { enable } from \"./enable\";\nimport { watch } from \"./watch\";\n\nexport const service = defineCommand({\n name: \"service\",\n short: tr(\"Manage swiplet services\"),\n commands: [enable, disable, watch],\n});\n"],"mappings":";;;;;;AAMA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,OAAO,GAAG,yBAAyB;CACnC,UAAU;EAAC;EAAQ;EAAS;CAAK;AACnC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { serviceText } from "../../../../output.js";
2
+ import { session } from "../../../session.js";
3
+ // src/cli/commands/swiplet/service/services.ts
4
+ async function watchServices(client, id, signal) {
5
+ for await (const response of client.swiplets.watchServices({ swipletId: id }, { signal })) console.log(`${response.swipletId}: ${serviceText(response.swipletId, response.service)}`);
6
+ }
7
+ const setService = (enabled) => (context) => session(context, async (client) => {
8
+ const id = context.args[0];
9
+ const response = await client.swiplets.setServiceEnabled({
10
+ swipletId: id,
11
+ enabled
12
+ }, { signal: context.signal });
13
+ if (context.options.watch) {
14
+ await watchServices(client, id, context.signal);
15
+ return;
16
+ }
17
+ console.log(`${id}: ${serviceText(id, response.service)}`);
18
+ });
19
+ export { setService, watchServices };
20
+
21
+ //# sourceMappingURL=services.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.js","names":[],"sources":["../../../../../src/cli/commands/swiplet/service/services.ts"],"sourcesContent":["import { serviceText } from \"../../../../output\";\nimport { session } from \"../../../session\";\n\nexport async function watchServices(client, id, signal) {\n for await (const response of client.swiplets.watchServices(\n { swipletId: id },\n { signal },\n )) {\n console.log(\n `${response.swipletId}: ${serviceText(response.swipletId, response.service)}`,\n );\n }\n}\n\nexport const setService = (enabled) => (context) =>\n session(context, async (client) => {\n const id = context.args[0];\n const response = await client.swiplets.setServiceEnabled(\n { swipletId: id, enabled },\n { signal: context.signal },\n );\n if (context.options.watch) {\n await watchServices(client, id, context.signal);\n return;\n }\n console.log(`${id}: ${serviceText(id, response.service)}`);\n });\n"],"mappings":";;;AAGA,eAAsB,cAAc,QAAQ,IAAI,QAAQ;CACtD,WAAW,MAAM,YAAY,OAAO,SAAS,cAC3C,EAAE,WAAW,GAAG,GAChB,EAAE,OAAO,CACX,GACE,QAAQ,IACN,GAAG,SAAS,UAAU,IAAI,YAAY,SAAS,WAAW,SAAS,OAAO,GAC5E;AAEJ;AAEA,MAAa,cAAc,aAAa,YACtC,QAAQ,SAAS,OAAO,WAAW;CACjC,MAAM,KAAK,QAAQ,KAAK;CACxB,MAAM,WAAW,MAAM,OAAO,SAAS,kBACrC;EAAE,WAAW;EAAI;CAAQ,GACzB,EAAE,QAAQ,QAAQ,OAAO,CAC3B;CACA,IAAI,QAAQ,QAAQ,OAAO;EACzB,MAAM,cAAc,QAAQ,IAAI,QAAQ,MAAM;EAC9C;CACF;CACA,QAAQ,IAAI,GAAG,GAAG,IAAI,YAAY,IAAI,SAAS,OAAO,GAAG;AAC3D,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { tr } from "../../../../i18n.js";
2
+ import { defineCommand } from "../../../command.js";
3
+ import { session } from "../../../session.js";
4
+ import { watchServices } from "./services.js";
5
+ // src/cli/commands/swiplet/service/watch.ts
6
+ const serviceWatch = (context) => session(context, (client) => watchServices(client, context.args[0] ?? "", context.signal));
7
+ const watch = defineCommand({
8
+ name: "watch",
9
+ use: "watch [ID]",
10
+ short: tr("Watch swiplet services"),
11
+ args: [0, 1],
12
+ run: serviceWatch
13
+ });
14
+ export { watch };
15
+
16
+ //# sourceMappingURL=watch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.js","names":[],"sources":["../../../../../src/cli/commands/swiplet/service/watch.ts"],"sourcesContent":["import { tr } from \"../../../../i18n\";\nimport { defineCommand } from \"../../../command\";\nimport { session } from \"../../../session\";\nimport { watchServices } from \"./services\";\n\nconst serviceWatch = (context) =>\n session(context, (client) =>\n watchServices(client, context.args[0] ?? \"\", context.signal),\n );\n\nexport const watch = defineCommand({\n name: \"watch\",\n use: \"watch [ID]\",\n short: tr(\"Watch swiplet services\"),\n args: [0, 1],\n run: serviceWatch,\n});\n"],"mappings":";;;;;AAKA,MAAM,gBAAgB,YACpB,QAAQ,UAAU,WAChB,cAAc,QAAQ,QAAQ,KAAK,MAAM,IAAI,QAAQ,MAAM,CAC7D;AAEF,MAAa,QAAQ,cAAc;CACjC,MAAM;CACN,KAAK;CACL,OAAO,GAAG,wBAAwB;CAClC,MAAM,CAAC,GAAG,CAAC;CACX,KAAK;AACP,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { tr } from "../../../i18n.js";
2
+ import { serviceText } from "../../../output.js";
3
+ import { defineCommand } from "../../command.js";
4
+ import { session } from "../../session.js";
5
+ // src/cli/commands/swiplet/show.ts
6
+ const indented = (value) => JSON.stringify(value, null, 2).replaceAll("\n", "\n ");
7
+ const notInstalled = (id) => new Error(tr("there is no swiplet {id}", { id: JSON.stringify(id) }));
8
+ const showSwiplet = (context) => session(context, async (client) => {
9
+ const { swiplets } = await client.swiplets.listSwiplets({}, { signal: context.signal });
10
+ const swiplet = swiplets.find((it) => it.id === context.args[0]);
11
+ if (!swiplet) throw notInstalled(context.args[0]);
12
+ console.log(swiplet.id, JSON.stringify(swiplet.title), swiplet.version);
13
+ if (swiplet.hasUi) console.log(tr("ui: yes"));
14
+ if (swiplet.service) console.log(tr("service: {status}", { status: serviceText(swiplet.id, swiplet.service) }));
15
+ for (const action of swiplet.actions) {
16
+ console.log();
17
+ console.log(action.exposedToShortcuts ? tr("action {name} {title} (Shortcuts)", {
18
+ name: action.name,
19
+ title: JSON.stringify(action.title)
20
+ }) : tr("action {name} {title}", {
21
+ name: action.name,
22
+ title: JSON.stringify(action.title)
23
+ }));
24
+ if (action.description !== "") console.log(` ${action.description}`);
25
+ if (action.inputSchema) console.log(` ${tr("input: {schema}", { schema: indented(action.inputSchema) })}`);
26
+ if (action.outputSchema) console.log(` ${tr("output: {schema}", { schema: indented(action.outputSchema) })}`);
27
+ }
28
+ });
29
+ const show = defineCommand({
30
+ name: "show",
31
+ use: "show ID",
32
+ short: tr("Show a swiplet"),
33
+ args: [1, 1],
34
+ run: showSwiplet
35
+ });
36
+ export { show };
37
+
38
+ //# sourceMappingURL=show.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"show.js","names":[],"sources":["../../../../src/cli/commands/swiplet/show.ts"],"sourcesContent":["import { tr } from \"../../../i18n\";\nimport { serviceText } from \"../../../output\";\nimport { defineCommand } from \"../../command\";\nimport { session } from \"../../session\";\n\nconst indented = (value) =>\n JSON.stringify(value, null, 2).replaceAll(\"\\n\", \"\\n \");\n\nconst notInstalled = (id) =>\n new Error(tr(\"there is no swiplet {id}\", { id: JSON.stringify(id) }));\n\nconst showSwiplet = (context) =>\n session(context, async (client) => {\n const { swiplets } = await client.swiplets.listSwiplets(\n {},\n { signal: context.signal },\n );\n const swiplet = swiplets.find((it) => it.id === context.args[0]);\n if (!swiplet) {\n throw notInstalled(context.args[0]);\n }\n console.log(swiplet.id, JSON.stringify(swiplet.title), swiplet.version);\n if (swiplet.hasUi) {\n console.log(tr(\"ui: yes\"));\n }\n if (swiplet.service) {\n console.log(\n tr(\"service: {status}\", {\n status: serviceText(swiplet.id, swiplet.service),\n }),\n );\n }\n for (const action of swiplet.actions) {\n console.log();\n console.log(\n action.exposedToShortcuts\n ? tr(\"action {name} {title} (Shortcuts)\", {\n name: action.name,\n title: JSON.stringify(action.title),\n })\n : tr(\"action {name} {title}\", {\n name: action.name,\n title: JSON.stringify(action.title),\n }),\n );\n if (action.description !== \"\") {\n console.log(` ${action.description}`);\n }\n if (action.inputSchema) {\n console.log(\n ` ${tr(\"input: {schema}\", { schema: indented(action.inputSchema) })}`,\n );\n }\n if (action.outputSchema) {\n console.log(\n ` ${tr(\"output: {schema}\", { schema: indented(action.outputSchema) })}`,\n );\n }\n }\n });\n\nexport const show = defineCommand({\n name: \"show\",\n use: \"show ID\",\n short: tr(\"Show a swiplet\"),\n args: [1, 1],\n run: showSwiplet,\n});\n"],"mappings":";;;;;AAKA,MAAM,YAAY,UAChB,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC,CAAC,WAAW,MAAM,MAAM;AAExD,MAAM,gBAAgB,OACpB,IAAI,MAAM,GAAG,4BAA4B,EAAE,IAAI,KAAK,UAAU,EAAE,EAAE,CAAC,CAAC;AAEtE,MAAM,eAAe,YACnB,QAAQ,SAAS,OAAO,WAAW;CACjC,MAAM,EAAE,aAAa,MAAM,OAAO,SAAS,aACzC,CAAC,GACD,EAAE,QAAQ,QAAQ,OAAO,CAC3B;CACA,MAAM,UAAU,SAAS,MAAM,OAAO,GAAG,OAAO,QAAQ,KAAK,EAAE;CAC/D,IAAI,CAAC,SACH,MAAM,aAAa,QAAQ,KAAK,EAAE;CAEpC,QAAQ,IAAI,QAAQ,IAAI,KAAK,UAAU,QAAQ,KAAK,GAAG,QAAQ,OAAO;CACtE,IAAI,QAAQ,OACV,QAAQ,IAAI,GAAG,SAAS,CAAC;CAE3B,IAAI,QAAQ,SACV,QAAQ,IACN,GAAG,qBAAqB,EACtB,QAAQ,YAAY,QAAQ,IAAI,QAAQ,OAAO,EACjD,CAAC,CACH;CAEF,KAAK,MAAM,UAAU,QAAQ,SAAS;EACpC,QAAQ,IAAI;EACZ,QAAQ,IACN,OAAO,qBACH,GAAG,qCAAqC;GACtC,MAAM,OAAO;GACb,OAAO,KAAK,UAAU,OAAO,KAAK;EACpC,CAAC,IACD,GAAG,yBAAyB;GAC1B,MAAM,OAAO;GACb,OAAO,KAAK,UAAU,OAAO,KAAK;EACpC,CAAC,CACP;EACA,IAAI,OAAO,gBAAgB,IACzB,QAAQ,IAAI,KAAK,OAAO,aAAa;EAEvC,IAAI,OAAO,aACT,QAAQ,IACN,KAAK,GAAG,mBAAmB,EAAE,QAAQ,SAAS,OAAO,WAAW,EAAE,CAAC,GACrE;EAEF,IAAI,OAAO,cACT,QAAQ,IACN,KAAK,GAAG,oBAAoB,EAAE,QAAQ,SAAS,OAAO,YAAY,EAAE,CAAC,GACvE;CAEJ;AACF,CAAC;AAEH,MAAa,OAAO,cAAc;CAChC,MAAM;CACN,KAAK;CACL,OAAO,GAAG,gBAAgB;CAC1B,MAAM,CAAC,GAAG,CAAC;CACX,KAAK;AACP,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { tr } from "../../../i18n.js";
2
+ import { defineCommand } from "../../command.js";
3
+ import "../data/index.js";
4
+ import { data } from "../data/data.js";
5
+ import { deviceOption } from "../flags.js";
6
+ import { call } from "./call.js";
7
+ import { install } from "./install.js";
8
+ import { list } from "./list.js";
9
+ import { remove } from "./remove.js";
10
+ import { service } from "./service/service.js";
11
+ import "./service/index.js";
12
+ import { show } from "./show.js";
13
+ // src/cli/commands/swiplet/swiplet.ts
14
+ const swipletData = ([id, ...args]) => ({
15
+ id,
16
+ wholeDirectory: (name) => tr("{path} names the data directory of {swiplet}; save it with --output DIRECTORY", {
17
+ path: name,
18
+ swiplet: id
19
+ }),
20
+ subdirectory: (name) => tr("{path} is a directory in the data directory of {swiplet}; save it with --output DIRECTORY", {
21
+ path: name,
22
+ swiplet: id
23
+ }),
24
+ args
25
+ });
26
+ const swiplet = defineCommand({
27
+ name: "swiplet",
28
+ short: tr("Manage the swiplets on the device"),
29
+ options: deviceOption,
30
+ commands: [
31
+ list,
32
+ show,
33
+ install,
34
+ remove,
35
+ call,
36
+ service,
37
+ data("ID ", swipletData)
38
+ ]
39
+ });
40
+ export { swiplet };
41
+
42
+ //# sourceMappingURL=swiplet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swiplet.js","names":[],"sources":["../../../../src/cli/commands/swiplet/swiplet.ts"],"sourcesContent":["import { tr } from \"../../../i18n\";\nimport { defineCommand } from \"../../command\";\nimport { data } from \"../data\";\nimport { deviceOption } from \"../flags\";\nimport { call } from \"./call\";\nimport { install } from \"./install\";\nimport { list } from \"./list\";\nimport { remove } from \"./remove\";\nimport { service } from \"./service\";\nimport { show } from \"./show\";\n\nconst swipletData = ([id, ...args]) => ({\n id,\n wholeDirectory: (name) =>\n tr(\n \"{path} names the data directory of {swiplet}; save it with --output DIRECTORY\",\n { path: name, swiplet: id },\n ),\n subdirectory: (name) =>\n tr(\n \"{path} is a directory in the data directory of {swiplet}; save it with --output DIRECTORY\",\n { path: name, swiplet: id },\n ),\n args,\n});\n\nexport const swiplet = defineCommand({\n name: \"swiplet\",\n short: tr(\"Manage the swiplets on the device\"),\n options: deviceOption,\n commands: [\n list,\n show,\n install,\n remove,\n call,\n service,\n data(\"ID \", swipletData),\n ],\n});\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAM,eAAe,CAAC,IAAI,GAAG,WAAW;CACtC;CACA,iBAAiB,SACf,GACE,iFACA;EAAE,MAAM;EAAM,SAAS;CAAG,CAC5B;CACF,eAAe,SACb,GACE,6FACA;EAAE,MAAM;EAAM,SAAS;CAAG,CAC5B;CACF;AACF;AAEA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,OAAO,GAAG,mCAAmC;CAC7C,SAAS;CACT,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;EACA,KAAK,OAAO,WAAW;CACzB;AACF,CAAC"}
@@ -0,0 +1 @@
1
+ export { version } from "./version.js";
@@ -0,0 +1,17 @@
1
+ import { tr } from "../../../i18n.js";
2
+ import { defineCommand } from "../../command.js";
3
+ import { createRequire } from "node:module";
4
+ // src/cli/commands/version/version.ts
5
+ const { version: packageVersion } = createRequire(import.meta.url)("../../../../package.json");
6
+ function printVersion() {
7
+ console.log("swipt", packageVersion, `node ${process.versions.node}`, `${process.platform}/${process.arch}`);
8
+ }
9
+ const version = defineCommand({
10
+ name: "version",
11
+ short: tr("Print the version"),
12
+ args: [0, 0],
13
+ run: printVersion
14
+ });
15
+ export { version };
16
+
17
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../../../src/cli/commands/version/version.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport { tr } from \"../../../i18n\";\nimport { defineCommand } from \"../../command\";\n\nconst { version: packageVersion } = createRequire(import.meta.url)(\n \"../../../../package.json\",\n);\n\nfunction printVersion() {\n console.log(\n \"swipt\",\n packageVersion,\n `node ${process.versions.node}`,\n `${process.platform}/${process.arch}`,\n );\n}\n\nexport const version = defineCommand({\n name: \"version\",\n short: tr(\"Print the version\"),\n args: [0, 0],\n run: printVersion,\n});\n"],"mappings":";;;;AAKA,MAAM,EAAE,SAAS,mBAAmB,cAAc,YAAY,GAAG,CAAC,CAChE,0BACF;AAEA,SAAS,eAAe;CACtB,QAAQ,IACN,SACA,gBACA,QAAQ,QAAQ,SAAS,QACzB,GAAG,QAAQ,SAAS,GAAG,QAAQ,MACjC;AACF;AAEA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,OAAO,GAAG,mBAAmB;CAC7B,MAAM,CAAC,GAAG,CAAC;CACX,KAAK;AACP,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { tr } from "../i18n.js";
2
+ import { uploadChunk } from "./io.js";
3
+ import fs from "node:fs";
4
+ // src/cli/deploy.ts
5
+ async function deploy(client, archive, signal) {
6
+ const data = fs.readFileSync(archive);
7
+ return client.swiplets.deploySwiplet((async function* () {
8
+ for (let offset = 0; offset < data.length || offset === 0; offset += uploadChunk) yield { chunk: data.subarray(offset, offset + uploadChunk) };
9
+ })(), { signal });
10
+ }
11
+ const printDeployed = (deployed, toStdout) => (toStdout ? console.log : console.error)(deployed.replaced ? tr("replaced {id} {version}", {
12
+ id: deployed.swiplet.id,
13
+ version: deployed.swiplet.version
14
+ }) : tr("installed {id} {version}", {
15
+ id: deployed.swiplet.id,
16
+ version: deployed.swiplet.version
17
+ }));
18
+ export { deploy, printDeployed };
19
+
20
+ //# sourceMappingURL=deploy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.js","names":[],"sources":["../../src/cli/deploy.ts"],"sourcesContent":["import fs from \"node:fs\";\n\nimport { tr } from \"../i18n\";\nimport { uploadChunk } from \"./io\";\n\nexport async function deploy(client, archive, signal) {\n const data = fs.readFileSync(archive);\n return client.swiplets.deploySwiplet(\n (async function* () {\n for (\n let offset = 0;\n offset < data.length || offset === 0;\n offset += uploadChunk\n ) {\n yield { chunk: data.subarray(offset, offset + uploadChunk) };\n }\n })(),\n { signal },\n );\n}\n\nexport const printDeployed = (deployed, toStdout) =>\n (toStdout ? console.log : console.error)(\n deployed.replaced\n ? tr(\"replaced {id} {version}\", {\n id: deployed.swiplet.id,\n version: deployed.swiplet.version,\n })\n : tr(\"installed {id} {version}\", {\n id: deployed.swiplet.id,\n version: deployed.swiplet.version,\n }),\n );\n"],"mappings":";;;;AAKA,eAAsB,OAAO,QAAQ,SAAS,QAAQ;CACpD,MAAM,OAAO,GAAG,aAAa,OAAO;CACpC,OAAO,OAAO,SAAS,eACpB,mBAAmB;EAClB,KACE,IAAI,SAAS,GACb,SAAS,KAAK,UAAU,WAAW,GACnC,UAAU,aAEV,MAAM,EAAE,OAAO,KAAK,SAAS,QAAQ,SAAS,WAAW,EAAE;CAE/D,EAAA,CAAG,GACH,EAAE,OAAO,CACX;AACF;AAEA,MAAa,iBAAiB,UAAU,cACrC,WAAW,QAAQ,MAAM,QAAQ,MAAA,CAChC,SAAS,WACL,GAAG,2BAA2B;CAC5B,IAAI,SAAS,QAAQ;CACrB,SAAS,SAAS,QAAQ;AAC5B,CAAC,IACD,GAAG,4BAA4B;CAC7B,IAAI,SAAS,QAAQ;CACrB,SAAS,SAAS,QAAQ;AAC5B,CAAC,CACP"}
package/dist/cli/io.js ADDED
@@ -0,0 +1,7 @@
1
+ import fs from "node:fs";
2
+ // src/cli/io.ts
3
+ const uploadChunk = 262144;
4
+ const readStdin = () => fs.readFileSync(0);
5
+ export { readStdin, uploadChunk };
6
+
7
+ //# sourceMappingURL=io.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io.js","names":[],"sources":["../../src/cli/io.ts"],"sourcesContent":["import fs from \"node:fs\";\n\nexport const uploadChunk = 256 << 10;\n\nexport const readStdin = () => fs.readFileSync(0);\n"],"mappings":";;AAEA,MAAa,cAAc;AAE3B,MAAa,kBAAkB,GAAG,aAAa,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { attach } from "../connection.js";
2
+ // src/cli/session.ts
3
+ const session = (context, run) => attach(context).then(run);
4
+ export { session };
5
+
6
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","names":[],"sources":["../../src/cli/session.ts"],"sourcesContent":["import { attach } from \"../connection\";\n\nexport const session = (context, run) => attach(context).then(run);\n"],"mappings":";;AAEA,MAAa,WAAW,SAAS,QAAQ,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG"}
package/dist/metro.js CHANGED
@@ -2,8 +2,8 @@ import { tr } from "./i18n.js";
2
2
  import { createRequire } from "node:module";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
- import { transformAsync } from "@babel/core";
6
5
  import { fileURLToPath } from "node:url";
6
+ import { transformAsync } from "@babel/core";
7
7
  import { loadProjectEnv } from "@expo/env";
8
8
  import { imageSize } from "image-size";
9
9
  // src/metro.ts
package/dist/project.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export declare const idPattern: RegExp;
1
2
  export declare function loadProject(root: any): {
2
3
  root: any;
3
4
  manifest: any;
@@ -13,6 +14,4 @@ export declare function buildProject(root: any, checker?: any): Promise<{
13
14
  id: any;
14
15
  archive: string;
15
16
  digest: string;
16
- }>;
17
- export declare function sourceCommand(root: any, given: any): void;
18
- export declare function createCommand(directory: any): void;
17
+ }>;
package/dist/project.js CHANGED
@@ -8,13 +8,11 @@ import fs from "node:fs";
8
8
  import path from "node:path";
9
9
  import { execFileSync } from "node:child_process";
10
10
  import { createHash } from "node:crypto";
11
- import vm from "node:vm";
12
11
  import { transformAsync } from "@babel/core";
12
+ import vm from "node:vm";
13
13
  import { build } from "esbuild";
14
14
  // src/project.ts
15
- const { version } = JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8"));
16
15
  const require = createRequire(import.meta.url);
17
- const { peerDependencies } = require("@swipt/api/package.json");
18
16
  const appModules = [
19
17
  "react",
20
18
  "react/jsx-runtime",
@@ -492,205 +490,6 @@ function folderDigest(folder) {
492
490
  walk(folder);
493
491
  return hash.digest("hex");
494
492
  }
495
- const manifestEntry = /^(?:[^/]+\/)?manifest\.json$/;
496
- function loadSource(root) {
497
- const manifest = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
498
- const config = manifest.source ?? {};
499
- for (const field of [
500
- "name",
501
- "image",
502
- "url"
503
- ]) if (config[field] !== void 0 && typeof config[field] !== "string") throw new Error(tr("\"{field}\" in package.json must be a string", { field: `source.${field}` }));
504
- const localizedNames = config.localizedNames ?? {};
505
- if (localizedNames === null || typeof localizedNames !== "object" || !Object.values(localizedNames).every((name) => typeof name === "string")) throw new Error(tr("\"source.localizedNames\" in package.json must map languages to names"));
506
- if (config.icon !== void 0 && (typeof config.icon?.symbol !== "string" || config.icon.color !== void 0 && typeof config.icon.color !== "string")) throw new Error(tr("\"source.icon\" in package.json must have a symbol and may have a color"));
507
- let prefix;
508
- if (config.url !== void 0) try {
509
- prefix = new URL(config.url.endsWith("/") ? config.url : `${config.url}/`);
510
- } catch {
511
- throw new Error(tr("\"source.url\" in package.json is not an absolute URL"));
512
- }
513
- const workspaces = Array.isArray(manifest.workspaces) ? manifest.workspaces : manifest.workspaces?.packages ?? [];
514
- return {
515
- root,
516
- config,
517
- localizedNames,
518
- prefix,
519
- workspaces
520
- };
521
- }
522
- function workspaceSwiplets(source) {
523
- const files = [];
524
- for (const pattern of source.workspaces) for (const directory of fs.globSync(pattern, { cwd: source.root }).sort()) {
525
- const project = path.join(source.root, directory, "package.json");
526
- if (!fs.existsSync(project)) continue;
527
- const id = JSON.parse(fs.readFileSync(project, "utf8")).swiplet?.id;
528
- if (typeof id !== "string") continue;
529
- const built = path.join(source.root, directory, "dist", `${id}.swiplet`);
530
- if (!fs.existsSync(built)) throw new Error(tr("{file} is missing; build {directory} first", {
531
- file: path.relative(source.root, built),
532
- directory
533
- }));
534
- files.push(built);
535
- }
536
- return files;
537
- }
538
- function readSwiplet(file) {
539
- const entry = execFileSync("unzip", ["-Z1", file], { encoding: "utf8" }).split("\n").filter((name) => manifestEntry.test(name)).sort((a, b) => a.length - b.length)[0];
540
- if (entry === void 0) throw new Error(`${file} has no manifest.json`);
541
- const manifest = JSON.parse(execFileSync("unzip", [
542
- "-p",
543
- file,
544
- entry
545
- ], { encoding: "utf8" }));
546
- if (typeof manifest.id !== "string" || !idPattern.test(manifest.id)) throw new Error(`${file} has no valid swiplet id in its manifest`);
547
- return {
548
- file,
549
- manifest,
550
- data: fs.readFileSync(file)
551
- };
552
- }
553
- function sourceCommand(root, given) {
554
- const source = loadSource(root);
555
- const files = given.length > 0 ? given.map((file) => path.resolve(file)) : workspaceSwiplets(source);
556
- if (files.length === 0) throw new Error(tr("package.json lists no workspaces with swiplets; name the swiplets to list"));
557
- const swiplets = /* @__PURE__ */ new Map();
558
- for (const read of files.map(readSwiplet)) {
559
- const { id } = read.manifest;
560
- if (swiplets.has(id)) throw new Error(tr("{id} is both {first} and {second}", {
561
- id,
562
- first: swiplets.get(id).file,
563
- second: read.file
564
- }));
565
- swiplets.set(id, read);
566
- }
567
- const image = source.config.image === void 0 ? void 0 : {
568
- name: path.basename(source.config.image),
569
- data: fs.readFileSync(path.resolve(root, source.config.image))
570
- };
571
- const located = (name) => source.prefix ? new URL(name, source.prefix).href : name;
572
- const dist = path.join(root, "dist");
573
- fs.rmSync(dist, {
574
- recursive: true,
575
- force: true
576
- });
577
- fs.mkdirSync(dist, { recursive: true });
578
- const entries = [...swiplets.keys()].map((id) => {
579
- const { manifest, data } = swiplets.get(id);
580
- const name = `${id}.swiplet`;
581
- fs.writeFileSync(path.join(dist, name), data);
582
- return {
583
- ...manifest,
584
- url: located(name),
585
- size: data.length,
586
- sha256: createHash("sha256").update(data).digest("hex")
587
- };
588
- });
589
- if (image) fs.writeFileSync(path.join(dist, image.name), image.data);
590
- const index = {
591
- ...source.config.name ? { name: source.config.name } : {},
592
- ...Object.keys(source.localizedNames).length > 0 ? { localizedNames: source.localizedNames } : {},
593
- ...source.config.icon ? { icon: {
594
- symbol: source.config.icon.symbol,
595
- ...source.config.icon.color ? { color: source.config.icon.color } : {}
596
- } } : {},
597
- ...image ? { image: located(image.name) } : {},
598
- swiplets: entries
599
- };
600
- fs.writeFileSync(path.join(dist, "swiplets.json"), `${JSON.stringify(index, null, 2)}\n`);
601
- console.log(path.relative(process.cwd(), path.join(dist, "swiplets.json")));
602
- }
603
- const swiptRange = version.includes("-") ? version : `>=${version}-0 <=${version}`;
604
- const idOf = (name) => name.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+/, "").slice(0, 128).replace(/[._-]+$/, "") || "swiplet";
605
- const templates = {
606
- "package.json": (name) => `${JSON.stringify({
607
- name: idOf(name),
608
- version: "0.1.0",
609
- private: true,
610
- swiplet: {
611
- id: idOf(name),
612
- name,
613
- versionCode: 1,
614
- icon: {
615
- color: "blue",
616
- symbol: "sparkles"
617
- },
618
- app: "./src/App.tsx",
619
- extension: "./src/extension.ts"
620
- },
621
- scripts: {
622
- build: "swipt project build",
623
- check: "tsc"
624
- },
625
- dependencies: { zod: "^4.6.7" },
626
- devDependencies: {
627
- "@swipt/api": swiptRange,
628
- "@swipt/cli": swiptRange,
629
- typescript: "^7.0.2",
630
- ...Object.fromEntries([
631
- "@expo/ui",
632
- "@types/react",
633
- "react"
634
- ].map((name) => [name, peerDependencies[name]]))
635
- }
636
- }, null, 2)}\n`,
637
- "tsconfig.json": () => `${JSON.stringify({ compilerOptions: {
638
- target: "ES2022",
639
- module: "ESNext",
640
- moduleResolution: "Bundler",
641
- jsx: "react-jsx",
642
- lib: ["ES2023", "DOM"],
643
- strict: true,
644
- noEmit: true,
645
- skipLibCheck: true
646
- } }, null, 2)}\n`,
647
- ".gitignore": () => "node_modules/\ndist/\n",
648
- "src/extension.ts": () => `import * as device from "@swipt/api/device";
649
- import { defineAction, defineExtension } from "@swipt/api/swiplet";
650
-
651
- export default defineExtension({
652
- actions: {
653
- frontApp: defineAction({
654
- title: "Find the App in Front",
655
- run: (_, { signal }) => device.foregroundApplication.get({ signal }),
656
- }),
657
- },
658
- });
659
- `,
660
- "src/App.tsx": () => `import { Button, Form, Host, Section, Text } from "@expo/ui/swift-ui";
661
- import { useState } from "react";
662
- import { actions } from "@swipt/api/swiplet";
663
-
664
- import type extension from "./extension";
665
-
666
- const { frontApp } = actions<typeof extension>();
667
-
668
- export default function App() {
669
- const [app, setApp] = useState("");
670
- return (
671
- <Host style={{ flex: 1 }}>
672
- <Form>
673
- <Section>
674
- <Button label="Find the App in Front" onPress={async () => setApp(await frontApp())} />
675
- {app === "" ? null : <Text>{app}</Text>}
676
- </Section>
677
- </Form>
678
- </Host>
679
- );
680
- }
681
- `
682
- };
683
- const quote = (value) => /^[\w@%+=:,./-]+$/.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`;
684
- function createCommand(directory) {
685
- const root = path.resolve(directory);
686
- if (fs.existsSync(root) && fs.readdirSync(root).length > 0) throw new Error(tr("{directory} is not empty", { directory }));
687
- for (const [file, template] of Object.entries(templates)) {
688
- fs.mkdirSync(path.dirname(path.join(root, file)), { recursive: true });
689
- fs.writeFileSync(path.join(root, file), template(path.basename(root)));
690
- }
691
- const manager = process.env.npm_config_user_agent?.split("/")[0] ?? "npm";
692
- console.log(`cd ${quote(directory)} && ${manager} install && ${manager} run build`);
693
- }
694
- export { buildProject, createCommand, loadProject, sourceCommand };
493
+ export { buildProject, idPattern, loadProject };
695
494
 
696
495
  //# sourceMappingURL=project.js.map