@swipt/cli 0.1.0-nightly.98 → 0.1.0-nightly.99
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/availability.d.ts +3 -1
- package/dist/availability.js +173 -151
- package/dist/availability.js.map +1 -1
- package/dist/cli/cli.js +52 -66
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/command.d.ts +9 -0
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/commands/data/clear.js +2 -2
- package/dist/cli/commands/data/clear.js.map +1 -1
- package/dist/cli/commands/data/data.js +2 -2
- package/dist/cli/commands/data/data.js.map +1 -1
- package/dist/cli/commands/data/list.js +3 -3
- package/dist/cli/commands/data/list.js.map +1 -1
- package/dist/cli/commands/data/operand.js.map +1 -1
- package/dist/cli/commands/data/read.js +4 -7
- package/dist/cli/commands/data/read.js.map +1 -1
- package/dist/cli/commands/data/remove.js +3 -3
- package/dist/cli/commands/data/remove.js.map +1 -1
- package/dist/cli/commands/data/write.js +2 -2
- package/dist/cli/commands/data/write.js.map +1 -1
- package/dist/cli/commands/device/add.js +2 -2
- package/dist/cli/commands/device/add.js.map +1 -1
- package/dist/cli/commands/device/device.js +2 -2
- package/dist/cli/commands/device/device.js.map +1 -1
- package/dist/cli/commands/device/list.js +2 -2
- package/dist/cli/commands/device/list.js.map +1 -1
- package/dist/cli/commands/device/logs.js +44 -46
- package/dist/cli/commands/device/logs.js.map +1 -1
- package/dist/cli/commands/device/remove.js +2 -2
- package/dist/cli/commands/device/remove.js.map +1 -1
- package/dist/cli/commands/device/stop.js +3 -3
- package/dist/cli/commands/device/stop.js.map +1 -1
- package/dist/cli/commands/driver/driver.js +6 -6
- package/dist/cli/commands/driver/driver.js.map +1 -1
- package/dist/cli/commands/flags.js +9 -9
- package/dist/cli/commands/flags.js.map +1 -1
- package/dist/cli/commands/index.js +2 -2
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/project/build.js +2 -2
- package/dist/cli/commands/project/build.js.map +1 -1
- package/dist/cli/commands/project/create.js +3 -3
- package/dist/cli/commands/project/create.js.map +1 -1
- package/dist/cli/commands/project/deploy.js +2 -2
- package/dist/cli/commands/project/deploy.js.map +1 -1
- package/dist/cli/commands/project/develop.js +19 -19
- package/dist/cli/commands/project/develop.js.map +1 -1
- package/dist/cli/commands/project/project.js +2 -2
- package/dist/cli/commands/project/project.js.map +1 -1
- package/dist/cli/commands/project/source.js +62 -37
- package/dist/cli/commands/project/source.js.map +1 -1
- package/dist/cli/commands/repl/api.js +2 -2
- package/dist/cli/commands/repl/api.js.map +1 -1
- package/dist/cli/commands/repl/repl.js +4 -4
- package/dist/cli/commands/repl/repl.js.map +1 -1
- package/dist/cli/commands/repl/reset.js +2 -2
- package/dist/cli/commands/repl/reset.js.map +1 -1
- package/dist/cli/commands/repl/run.js +5 -5
- package/dist/cli/commands/repl/run.js.map +1 -1
- package/dist/cli/commands/sideload/install.js +4 -4
- package/dist/cli/commands/sideload/install.js.map +1 -1
- package/dist/cli/commands/sideload/setup.js +3 -3
- package/dist/cli/commands/sideload/setup.js.map +1 -1
- package/dist/cli/commands/sideload/sideload.js +2 -2
- package/dist/cli/commands/sideload/sideload.js.map +1 -1
- package/dist/cli/commands/sideload/uninstall.js +2 -2
- package/dist/cli/commands/sideload/uninstall.js.map +1 -1
- package/dist/cli/commands/sideload/update.js +3 -3
- package/dist/cli/commands/sideload/update.js.map +1 -1
- package/dist/cli/commands/swiplet/call.js +6 -6
- package/dist/cli/commands/swiplet/call.js.map +1 -1
- package/dist/cli/commands/swiplet/install.js +3 -3
- package/dist/cli/commands/swiplet/install.js.map +1 -1
- package/dist/cli/commands/swiplet/list.js +8 -8
- package/dist/cli/commands/swiplet/list.js.map +1 -1
- package/dist/cli/commands/swiplet/remove.js +3 -3
- package/dist/cli/commands/swiplet/remove.js.map +1 -1
- package/dist/cli/commands/swiplet/service/disable.js +3 -3
- package/dist/cli/commands/swiplet/service/disable.js.map +1 -1
- package/dist/cli/commands/swiplet/service/enable.js +3 -3
- package/dist/cli/commands/swiplet/service/enable.js.map +1 -1
- package/dist/cli/commands/swiplet/service/service.js +2 -2
- package/dist/cli/commands/swiplet/service/service.js.map +1 -1
- package/dist/cli/commands/swiplet/service/services.js +2 -2
- package/dist/cli/commands/swiplet/service/services.js.map +1 -1
- package/dist/cli/commands/swiplet/service/watch.js +2 -2
- package/dist/cli/commands/swiplet/service/watch.js.map +1 -1
- package/dist/cli/commands/swiplet/show.js +6 -6
- package/dist/cli/commands/swiplet/show.js.map +1 -1
- package/dist/cli/commands/swiplet/swiplet.js +4 -4
- package/dist/cli/commands/swiplet/swiplet.js.map +1 -1
- package/dist/cli/commands/version/version.js +2 -2
- package/dist/cli/commands/version/version.js.map +1 -1
- package/dist/cli/deploy.js +9 -7
- package/dist/cli/deploy.js.map +1 -1
- package/dist/cli/session.js.map +1 -1
- package/dist/client.d.ts +145 -7
- package/dist/client.js +20 -22
- package/dist/client.js.map +1 -1
- package/dist/connection.d.ts +292 -25
- package/dist/connection.js +36 -35
- package/dist/connection.js.map +1 -1
- package/dist/driver.d.ts +62 -23
- package/dist/driver.js +29 -33
- package/dist/driver.js.map +1 -1
- package/dist/i18n.d.ts +2 -5
- package/dist/i18n.js +15 -13
- package/dist/i18n.js.map +1 -1
- package/dist/i18next.d.ts +7 -0
- package/dist/ignore.d.ts +14 -7
- package/dist/ignore.js +13 -14
- package/dist/ignore.js.map +1 -1
- package/dist/mdns.d.ts +2 -2
- package/dist/mdns.js +1 -1
- package/dist/mdns.js.map +1 -1
- package/dist/metro.d.ts +19 -5
- package/dist/metro.js +61 -63
- package/dist/metro.js.map +1 -1
- package/dist/output.d.ts +29 -14
- package/dist/output.js +17 -15
- package/dist/output.js.map +1 -1
- package/dist/passcode.d.ts +12 -8
- package/dist/passcode.js +18 -18
- package/dist/passcode.js.map +1 -1
- package/dist/project.d.ts +20 -10
- package/dist/project.js +72 -49
- package/dist/project.js.map +1 -1
- package/dist/proto/common_pb.d.ts +240 -0
- package/dist/proto/common_pb.js +7 -2
- package/dist/proto/common_pb.js.map +1 -1
- package/dist/proto/logs_pb.d.ts +38 -0
- package/dist/proto/repl_pb.d.ts +96 -0
- package/dist/proto/swiplets_pb.d.ts +361 -0
- package/dist/proto/swiplets_pb.js +7 -2
- package/dist/proto/swiplets_pb.js.map +1 -1
- package/dist/proto/system_pb.d.ts +33 -0
- package/dist/resources.d.ts +400 -0
- package/dist/serve.d.ts +9 -1
- package/dist/serve.js +17 -16
- package/dist/serve.js.map +1 -1
- package/dist/sideload.d.ts +27 -14
- package/dist/sideload.js +102 -89
- package/dist/sideload.js.map +1 -1
- package/dist/swipt-app.d.ts +19 -9
- package/dist/swipt-app.js +1 -1
- package/dist/swipt-app.js.map +1 -1
- package/locales/ar/translation.json +413 -0
- package/locales/bg/translation.json +397 -0
- package/locales/bn/translation.json +397 -0
- package/locales/ca/translation.json +401 -0
- package/locales/cs/translation.json +405 -0
- package/locales/da/translation.json +397 -0
- package/locales/de/translation.json +397 -0
- package/locales/el/translation.json +397 -0
- package/locales/en/translation.json +397 -0
- package/locales/es/translation.json +401 -0
- package/locales/es-419/translation.json +401 -0
- package/locales/fi/translation.json +397 -0
- package/locales/fr/translation.json +401 -0
- package/locales/fr-CA/translation.json +401 -0
- package/locales/gu/translation.json +397 -0
- package/locales/he/translation.json +401 -0
- package/locales/hi/translation.json +397 -0
- package/locales/hr/translation.json +401 -0
- package/locales/hu/translation.json +397 -0
- package/locales/id/translation.json +393 -0
- package/locales/it/translation.json +401 -0
- package/locales/ja/translation.json +393 -0
- package/locales/kk/translation.json +397 -0
- package/locales/kn/translation.json +397 -0
- package/locales/ko/translation.json +393 -0
- package/locales/lt/translation.json +405 -0
- package/locales/ml/translation.json +397 -0
- package/locales/mr/translation.json +397 -0
- package/locales/ms/translation.json +393 -0
- package/locales/nb/translation.json +397 -0
- package/locales/nl/translation.json +397 -0
- package/locales/or/translation.json +397 -0
- package/locales/pa/translation.json +397 -0
- package/locales/pl/translation.json +405 -0
- package/locales/pt-BR/translation.json +401 -0
- package/locales/pt-PT/translation.json +401 -0
- package/locales/ro/translation.json +401 -0
- package/locales/ru/translation.json +405 -0
- package/locales/sk/translation.json +405 -0
- package/locales/sl/translation.json +405 -0
- package/locales/sv/translation.json +397 -0
- package/locales/ta/translation.json +397 -0
- package/locales/te/translation.json +397 -0
- package/locales/th/translation.json +393 -0
- package/locales/tr/translation.json +397 -0
- package/locales/uk/translation.json +405 -0
- package/locales/ur/translation.json +397 -0
- package/locales/vi/translation.json +397 -0
- package/locales/zh-HK/translation.json +393 -0
- package/locales/zh-Hans/translation.json +393 -0
- package/locales/zh-Hant/translation.json +393 -0
- package/package.json +14 -9
- package/locales/ar.json +0 -311
- package/locales/bg.json +0 -295
- package/locales/bn.json +0 -295
- package/locales/ca.json +0 -299
- package/locales/cs.json +0 -303
- package/locales/da.json +0 -295
- package/locales/de.json +0 -295
- package/locales/el.json +0 -295
- package/locales/es-419.json +0 -299
- package/locales/es.json +0 -299
- package/locales/fi.json +0 -295
- package/locales/fr-CA.json +0 -299
- package/locales/fr.json +0 -299
- package/locales/gu.json +0 -295
- package/locales/he.json +0 -299
- package/locales/hi.json +0 -295
- package/locales/hr.json +0 -299
- package/locales/hu.json +0 -295
- package/locales/id.json +0 -283
- package/locales/it.json +0 -299
- package/locales/ja.json +0 -283
- package/locales/kk.json +0 -295
- package/locales/kn.json +0 -295
- package/locales/ko.json +0 -283
- package/locales/lt.json +0 -303
- package/locales/ml.json +0 -295
- package/locales/mr.json +0 -295
- package/locales/ms.json +0 -283
- package/locales/nb.json +0 -295
- package/locales/nl.json +0 -295
- package/locales/or.json +0 -295
- package/locales/pa.json +0 -295
- package/locales/pl.json +0 -303
- package/locales/pt-BR.json +0 -299
- package/locales/pt-PT.json +0 -299
- package/locales/ro.json +0 -299
- package/locales/ru.json +0 -303
- package/locales/sk.json +0 -303
- package/locales/sl.json +0 -303
- package/locales/sv.json +0 -295
- package/locales/ta.json +0 -295
- package/locales/te.json +0 -295
- package/locales/th.json +0 -283
- package/locales/tr.json +0 -295
- package/locales/uk.json +0 -303
- package/locales/ur.json +0 -295
- package/locales/vi.json +0 -295
- package/locales/zh-HK.json +0 -283
- package/locales/zh-Hans.json +0 -283
- package/locales/zh-Hant.json +0 -283
package/dist/project.d.ts
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
|
+
import { AvailabilityChecker } from "./availability.js";
|
|
1
2
|
export declare const idPattern: RegExp;
|
|
2
|
-
export declare function loadProject(root:
|
|
3
|
-
root:
|
|
4
|
-
|
|
5
|
-
config:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
export declare function loadProject(root: string): {
|
|
4
|
+
root: string;
|
|
5
|
+
version: unknown;
|
|
6
|
+
config: {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string | undefined;
|
|
10
|
+
versionCode: number | undefined;
|
|
11
|
+
icon: unknown;
|
|
12
|
+
minimumAPILevel: number | undefined;
|
|
13
|
+
minimumIOSVersion: number | undefined;
|
|
14
|
+
};
|
|
15
|
+
localizedNames: Record<string, string>;
|
|
16
|
+
apiLevel: number;
|
|
17
|
+
minimumIOSVersion: number;
|
|
9
18
|
apiDirectory: string;
|
|
10
19
|
app: string;
|
|
11
|
-
extension: string;
|
|
20
|
+
extension: string | undefined;
|
|
12
21
|
};
|
|
13
|
-
export
|
|
14
|
-
|
|
22
|
+
export type Project = ReturnType<typeof loadProject>;
|
|
23
|
+
export declare function buildProject(root: string, checker?: AvailabilityChecker): Promise<{
|
|
24
|
+
id: string;
|
|
15
25
|
archive: string;
|
|
16
26
|
digest: string;
|
|
17
27
|
}>;
|
package/dist/project.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { AvailabilityChecker } from "./availability.js";
|
|
3
|
-
import {
|
|
3
|
+
import { t } from "./i18n.js";
|
|
4
4
|
import { loadEnvironment, metro } from "./metro.js";
|
|
5
5
|
import { parseVersion, versionAtLeast } from "./version.js";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
@@ -75,28 +75,41 @@ const storedSuffixes = [
|
|
|
75
75
|
".xz"
|
|
76
76
|
];
|
|
77
77
|
const zipEpoch = new Date(1980, 0, 1).getTime();
|
|
78
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
79
|
+
const isStringRecord = (value) => isRecord(value) && Object.values(value).every((name) => typeof name === "string");
|
|
78
80
|
function loadProject(root) {
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
if (typeof config.
|
|
81
|
+
const parsed = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
82
|
+
const manifest = isRecord(parsed) ? parsed : {};
|
|
83
|
+
const config = isRecord(manifest.swiplet) ? manifest.swiplet : {};
|
|
84
|
+
if (typeof config.id !== "string" || !idPattern.test(config.id)) throw new Error(t("project.invalidID"));
|
|
85
|
+
if (typeof config.name !== "string" || config.name === "") throw new Error(t("project.invalidName"));
|
|
83
86
|
const localizedNames = config.localizedNames ?? {};
|
|
84
|
-
if (
|
|
85
|
-
if (config.description !== void 0 && typeof config.description !== "string") throw new Error(
|
|
86
|
-
if (config.versionCode !== void 0 && (!Number.isInteger(config.versionCode) || config.versionCode < 1)) throw new Error(
|
|
87
|
+
if (!isStringRecord(localizedNames)) throw new Error(t("project.invalidLocalizedNames"));
|
|
88
|
+
if (config.description !== void 0 && typeof config.description !== "string") throw new Error(t("project.invalidString", { field: "swiplet.description" }));
|
|
89
|
+
if (config.versionCode !== void 0 && (typeof config.versionCode !== "number" || !Number.isInteger(config.versionCode) || config.versionCode < 1)) throw new Error(t("project.invalidVersionCode"));
|
|
87
90
|
const apiManifest = require.resolve("@swipt/api/package.json", { paths: [root, import.meta.dirname] });
|
|
88
91
|
const { apiLevel, oldestAPILevel = 1, minimumIOSVersion = 27 } = JSON.parse(fs.readFileSync(apiManifest, "utf8"));
|
|
89
|
-
if (config.minimumAPILevel !== void 0 && !(Number.isInteger(config.minimumAPILevel) && config.minimumAPILevel >= oldestAPILevel && config.minimumAPILevel <= apiLevel)) throw new Error(
|
|
92
|
+
if (config.minimumAPILevel !== void 0 && !(typeof config.minimumAPILevel === "number" && Number.isInteger(config.minimumAPILevel) && config.minimumAPILevel >= oldestAPILevel && config.minimumAPILevel <= apiLevel)) throw new Error(t("project.invalidMinimumAPILevel", {
|
|
90
93
|
oldest: oldestAPILevel,
|
|
91
94
|
level: apiLevel
|
|
92
95
|
}));
|
|
93
96
|
const version = parseVersion(config.minimumIOSVersion);
|
|
94
|
-
|
|
95
|
-
if (
|
|
97
|
+
const oldestVersion = parseVersion(minimumIOSVersion);
|
|
98
|
+
if (config.minimumIOSVersion !== void 0 && !(typeof config.minimumIOSVersion === "number" && version && oldestVersion && versionAtLeast(version, oldestVersion))) throw new Error(t("project.invalidMinimumIOSVersion", { version: minimumIOSVersion }));
|
|
99
|
+
if (typeof config.app !== "string" || config.app === "") throw new Error(t("project.invalidString", { field: "swiplet.app" }));
|
|
100
|
+
if (config.extension !== void 0 && (typeof config.extension !== "string" || config.extension === "")) throw new Error(t("project.invalidString", { field: "swiplet.extension" }));
|
|
96
101
|
return {
|
|
97
102
|
root,
|
|
98
|
-
manifest,
|
|
99
|
-
config
|
|
103
|
+
version: manifest.version,
|
|
104
|
+
config: {
|
|
105
|
+
id: config.id,
|
|
106
|
+
name: config.name,
|
|
107
|
+
description: config.description,
|
|
108
|
+
versionCode: config.versionCode,
|
|
109
|
+
icon: config.icon,
|
|
110
|
+
minimumAPILevel: config.minimumAPILevel,
|
|
111
|
+
minimumIOSVersion: config.minimumIOSVersion
|
|
112
|
+
},
|
|
100
113
|
localizedNames,
|
|
101
114
|
apiLevel,
|
|
102
115
|
minimumIOSVersion,
|
|
@@ -110,7 +123,7 @@ const typeImport = (extension) => ({
|
|
|
110
123
|
setup(build) {
|
|
111
124
|
build.onLoad({ filter: /.*/ }, (args) => {
|
|
112
125
|
if (args.path !== extension) return;
|
|
113
|
-
return { errors: [{ text:
|
|
126
|
+
return { errors: [{ text: t("project.interfaceImport", { file: path.basename(extension) }) }] };
|
|
114
127
|
});
|
|
115
128
|
}
|
|
116
129
|
});
|
|
@@ -142,8 +155,11 @@ async function bundle(project) {
|
|
|
142
155
|
plugins: [metro(project.root, { sourcemap: true })]
|
|
143
156
|
});
|
|
144
157
|
out.metafiles.push(result.metafile);
|
|
145
|
-
|
|
146
|
-
const
|
|
158
|
+
const code = result.outputFiles.find((file) => file.path.endsWith(".js"));
|
|
159
|
+
const sourceMap = result.outputFiles.find((file) => file.path.endsWith(".map"));
|
|
160
|
+
if (code === void 0 || sourceMap === void 0) throw new Error("esbuild wrote no extension bundle or source map");
|
|
161
|
+
out.extension = code.text;
|
|
162
|
+
const map = JSON.parse(sourceMap.text);
|
|
147
163
|
const sources = map.sources.map((source) => path.relative(project.root, path.resolve(path.dirname(outfile), map.sourceRoot ?? "", source)).split(path.sep).join("/"));
|
|
148
164
|
out.extensionMap = JSON.stringify({
|
|
149
165
|
...map,
|
|
@@ -190,23 +206,26 @@ async function bundle(project) {
|
|
|
190
206
|
plugins: [...project.extension ? [typeImport(project.extension)] : [], metro(project.root, { assets: out.assets })]
|
|
191
207
|
});
|
|
192
208
|
out.metafiles.push(result.metafile);
|
|
193
|
-
|
|
209
|
+
const scoped = await transformAsync(result.outputFiles[0].text, {
|
|
194
210
|
babelrc: false,
|
|
195
211
|
configFile: false,
|
|
196
212
|
sourceType: "script",
|
|
197
213
|
compact: false,
|
|
198
214
|
plugins: [require.resolve("@babel/plugin-transform-block-scoping")]
|
|
199
|
-
})
|
|
215
|
+
});
|
|
216
|
+
if (typeof scoped?.code !== "string") throw new Error("Babel produced no code for the app bundle");
|
|
217
|
+
out.app = scoped.code;
|
|
200
218
|
return out;
|
|
201
219
|
}
|
|
202
220
|
const definitionKey = Symbol("definition");
|
|
221
|
+
const member = (value, key) => typeof value === "object" && value !== null || typeof value === "function" ? Reflect.get(value, key) : void 0;
|
|
203
222
|
function describeExtension(source) {
|
|
204
223
|
if (source === "") return {
|
|
205
224
|
service: false,
|
|
206
225
|
actions: []
|
|
207
226
|
};
|
|
208
227
|
const [newer, older] = [true, false].map((result) => evaluateExtension(source, result));
|
|
209
|
-
if (JSON.stringify(newer) !== JSON.stringify(older)) throw new Error(
|
|
228
|
+
if (JSON.stringify(newer) !== JSON.stringify(older)) throw new Error(t("project.conditionalActions"));
|
|
210
229
|
return newer;
|
|
211
230
|
}
|
|
212
231
|
function evaluateExtension(source, availableResult) {
|
|
@@ -214,16 +233,15 @@ function evaluateExtension(source, availableResult) {
|
|
|
214
233
|
const fail = () => {
|
|
215
234
|
throw new Error(message);
|
|
216
235
|
};
|
|
217
|
-
const get = (_, key) => key === "__esModule" ? true : typeof key === "symbol" || key === "then" ? void 0 : fail();
|
|
218
236
|
return new Proxy(fail, {
|
|
219
|
-
get,
|
|
237
|
+
get: (_, key) => key === "__esModule" ? true : typeof key === "symbol" || key === "then" ? void 0 : fail(),
|
|
220
238
|
apply: fail,
|
|
221
239
|
construct: fail
|
|
222
240
|
});
|
|
223
241
|
};
|
|
224
|
-
const loading = (name) => failing(
|
|
225
|
-
const database = () => failing(
|
|
226
|
-
const storage = failing(
|
|
242
|
+
const loading = (name) => failing(t("project.usedAtLoad", { name }));
|
|
243
|
+
const database = () => failing(t("project.databaseAtLoad"));
|
|
244
|
+
const storage = failing(t("project.storageAtLoad"));
|
|
227
245
|
const modules = {
|
|
228
246
|
"@swipt/api": { available: () => availableResult },
|
|
229
247
|
"@swipt/api/swiplet": {
|
|
@@ -234,13 +252,13 @@ function evaluateExtension(source, availableResult) {
|
|
|
234
252
|
},
|
|
235
253
|
"@swipt/api/file-system": {
|
|
236
254
|
get dataDirectory() {
|
|
237
|
-
throw new Error(
|
|
255
|
+
throw new Error(t("project.usedAtLoad", { name: "dataDirectory" }));
|
|
238
256
|
},
|
|
239
257
|
get cacheDirectory() {
|
|
240
|
-
throw new Error(
|
|
258
|
+
throw new Error(t("project.usedAtLoad", { name: "cacheDirectory" }));
|
|
241
259
|
},
|
|
242
260
|
get assets() {
|
|
243
|
-
throw new Error(
|
|
261
|
+
throw new Error(t("project.usedAtLoad", { name: "assets" }));
|
|
244
262
|
}
|
|
245
263
|
},
|
|
246
264
|
"@swipt/api/accessibility": loading("accessibility"),
|
|
@@ -281,13 +299,13 @@ function evaluateExtension(source, availableResult) {
|
|
|
281
299
|
if (a === b) return true;
|
|
282
300
|
if (a === null || b === null || typeof a !== "object" || typeof b !== "object") return false;
|
|
283
301
|
const keys = Object.keys(a);
|
|
284
|
-
return keys.length === Object.keys(b).length && keys.every((key) => deepEqual(a
|
|
302
|
+
return keys.length === Object.keys(b).length && keys.every((key) => deepEqual(member(a, key), member(b, key)));
|
|
285
303
|
},
|
|
286
304
|
SQLiteProvider: () => {
|
|
287
|
-
throw new Error(
|
|
305
|
+
throw new Error(t("project.interfaceOnly", { name: "SQLiteProvider" }));
|
|
288
306
|
},
|
|
289
307
|
useSQLiteContext: () => {
|
|
290
|
-
throw new Error(
|
|
308
|
+
throw new Error(t("project.interfaceOnly", { name: "useSQLiteContext" }));
|
|
291
309
|
}
|
|
292
310
|
},
|
|
293
311
|
"expo-sqlite/kv-store": {
|
|
@@ -355,7 +373,7 @@ function evaluateExtension(source, availableResult) {
|
|
|
355
373
|
"PerformanceMeasure",
|
|
356
374
|
"PerformanceObserver",
|
|
357
375
|
"PerformanceObserverEntryList"
|
|
358
|
-
].map((name) => [name, globalThis
|
|
376
|
+
].map((name) => [name, Reflect.get(globalThis, name)])),
|
|
359
377
|
fetch: loading("fetch"),
|
|
360
378
|
setTimeout: ignored,
|
|
361
379
|
setInterval: ignored,
|
|
@@ -370,36 +388,41 @@ function evaluateExtension(source, availableResult) {
|
|
|
370
388
|
const factory = vm.runInContext(`(function (require, module, exports) {${source}\n})`, context, { filename: "extension.js" });
|
|
371
389
|
const module = { exports: {} };
|
|
372
390
|
factory((specifier) => {
|
|
373
|
-
if (!Object.hasOwn(modules, specifier)) throw new Error(
|
|
391
|
+
if (typeof specifier !== "string" || !Object.hasOwn(modules, specifier)) throw new Error(t("project.unprovidedModule", { module: String(specifier) }));
|
|
374
392
|
return modules[specifier];
|
|
375
393
|
}, module, module.exports);
|
|
376
|
-
const definition = (module.exports
|
|
377
|
-
if (definition === void 0) throw new Error(
|
|
394
|
+
const definition = member(member(module.exports, "default") ?? module.exports, definitionKey);
|
|
395
|
+
if (definition === void 0) throw new Error(t("project.invalidExtension"));
|
|
378
396
|
const schema = (name, value, side) => {
|
|
379
397
|
if (value === void 0) return;
|
|
380
|
-
const converter = value
|
|
381
|
-
|
|
398
|
+
const converter = member(member(value, "~standard"), "jsonSchema");
|
|
399
|
+
const convert = member(converter, side);
|
|
400
|
+
if (typeof convert !== "function") throw new Error(t("project.invalidSchema", {
|
|
382
401
|
side,
|
|
383
402
|
action: JSON.stringify(name)
|
|
384
403
|
}));
|
|
385
|
-
return converter
|
|
404
|
+
return convert.call(converter, { target: "draft-2020-12" });
|
|
386
405
|
};
|
|
387
|
-
const actions = Object.entries(definition
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
406
|
+
const actions = Object.entries(member(definition, "actions") ?? {}).map(([name, action]) => {
|
|
407
|
+
const title = member(action, "title");
|
|
408
|
+
if (typeof title !== "string" || title === "") throw new Error(t("project.missingTitle", { action: JSON.stringify(name) }));
|
|
409
|
+
const expose = member(action, "expose") ?? [];
|
|
410
|
+
if (!Array.isArray(expose) || !expose.every((caller) => caller === "shortcuts")) throw new Error(t("project.invalidExposure", { action: JSON.stringify(name) }));
|
|
411
|
+
const description = member(action, "description");
|
|
412
|
+
const input = member(action, "input");
|
|
413
|
+
const output = member(action, "output");
|
|
391
414
|
return {
|
|
392
415
|
name,
|
|
393
|
-
title
|
|
394
|
-
...
|
|
416
|
+
title,
|
|
417
|
+
...description ? { description } : {},
|
|
395
418
|
...expose.length > 0 ? { expose } : {},
|
|
396
|
-
...typeof action
|
|
397
|
-
...
|
|
398
|
-
...
|
|
419
|
+
...typeof member(action, "stream") === "function" ? { stream: true } : {},
|
|
420
|
+
...input ? { input: schema(name, input, "input") } : {},
|
|
421
|
+
...output ? { output: schema(name, output, "output") } : {}
|
|
399
422
|
};
|
|
400
423
|
});
|
|
401
424
|
return {
|
|
402
|
-
service: typeof definition
|
|
425
|
+
service: typeof member(definition, "run") === "function",
|
|
403
426
|
actions
|
|
404
427
|
};
|
|
405
428
|
}
|
|
@@ -411,7 +434,7 @@ function swipletManifest(project, output) {
|
|
|
411
434
|
name: config.name,
|
|
412
435
|
...Object.keys(localizedNames).length > 0 ? { localizedNames } : {},
|
|
413
436
|
...config.description ? { description: config.description } : {},
|
|
414
|
-
...project.
|
|
437
|
+
...project.version ? { version: project.version } : {},
|
|
415
438
|
...config.versionCode ? { versionCode: config.versionCode } : {},
|
|
416
439
|
...config.icon ? { icon: config.icon } : {},
|
|
417
440
|
minimumAPILevel: config.minimumAPILevel ?? project.apiLevel,
|
|
@@ -454,7 +477,7 @@ async function buildProject(root, checker) {
|
|
|
454
477
|
});
|
|
455
478
|
for (const [name, source] of output.assets) {
|
|
456
479
|
const target = path.join(folder, "assets", name);
|
|
457
|
-
if (fs.existsSync(target)) throw new Error(
|
|
480
|
+
if (fs.existsSync(target)) throw new Error(t("project.assetConflict", {
|
|
458
481
|
source: path.relative(root, source),
|
|
459
482
|
asset: path.join("assets", name),
|
|
460
483
|
name
|
package/dist/project.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.js","names":[],"sources":["../src/project.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { createHash } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport vm from \"node:vm\";\n\nimport { transformAsync } from \"@babel/core\";\nimport { build } from \"esbuild\";\nimport { zipSync } from \"fflate\";\n\nimport { AvailabilityChecker } from \"./availability\";\nimport { tr } from \"./i18n\";\nimport { loadEnvironment, metro } from \"./metro\";\nimport { parseVersion, versionAtLeast } from \"./version\";\n\nconst require = createRequire(import.meta.url);\n\nconst appModules = [\n \"react\",\n \"react/jsx-runtime\",\n \"react-native\",\n \"react-native-worklets\",\n \"expo\",\n \"expo-localization\",\n \"expo-maps\",\n \"@expo/ui\",\n \"@expo/ui/*\",\n \"@swipt/api\",\n \"@swipt/api/swiplet\",\n \"@swipt/api/file-system\",\n \"@swipt/api/localization\",\n \"@swipt/api/maps\",\n \"@swipt/api/http\",\n \"@swipt/api/app-intents\",\n \"@swipt/api/swift-ui\",\n \"expo-sqlite\",\n \"expo-sqlite/kv-store\",\n \"expo-sqlite/localStorage/install\",\n];\nconst extensionModules = [\n \"@swipt/api\",\n \"@swipt/api/swiplet\",\n \"@swipt/api/file-system\",\n \"@swipt/api/accessibility\",\n \"@swipt/api/input\",\n \"@swipt/api/device\",\n \"@swipt/api/process\",\n \"@swipt/api/screen\",\n \"@swipt/api/image\",\n \"@swipt/api/app-intents\",\n \"@swipt/api/localization\",\n \"@swipt/api/http\",\n \"expo-sqlite\",\n \"expo-sqlite/kv-store\",\n \"expo-sqlite/localStorage/install\",\n];\n\nexport const idPattern = /^[a-z0-9][a-z0-9._-]{0,127}$/;\n\nconst storedSuffixes = [\n \".webp\",\n \".jxl\",\n \".avif\",\n \".heic\",\n \".heif\",\n \".jpg\",\n \".jpeg\",\n \".png\",\n \".gif\",\n \".mp4\",\n \".mov\",\n \".m4a\",\n \".mp3\",\n \".aac\",\n \".zip\",\n \".gz\",\n \".br\",\n \".zst\",\n \".xz\",\n];\n\nconst zipEpoch = new Date(1980, 0, 1).getTime();\n\nexport function loadProject(root) {\n const manifest = JSON.parse(\n fs.readFileSync(path.join(root, \"package.json\"), \"utf8\"),\n );\n const config = manifest.swiplet ?? {};\n if (typeof config.id !== \"string\" || !idPattern.test(config.id)) {\n throw new Error(\n tr(\n '\"swiplet.id\" in package.json must be 1 to 128 lowercase letters, digits, dots, underscores and hyphens starting with a letter or a digit.',\n ),\n );\n }\n if (typeof config.name !== \"string\" || config.name === \"\") {\n throw new Error(\n tr('\"swiplet.name\" in package.json must be a nonempty string.'),\n );\n }\n const localizedNames = config.localizedNames ?? {};\n if (\n localizedNames === null ||\n typeof localizedNames !== \"object\" ||\n !Object.values(localizedNames).every((name) => typeof name === \"string\")\n ) {\n throw new Error(\n tr(\n '\"swiplet.localizedNames\" in package.json must map languages to names.',\n ),\n );\n }\n if (\n config.description !== undefined &&\n typeof config.description !== \"string\"\n ) {\n throw new Error(\n tr('\"{field}\" in package.json must be a string.', {\n field: \"swiplet.description\",\n }),\n );\n }\n if (\n config.versionCode !== undefined &&\n (!Number.isInteger(config.versionCode) || config.versionCode < 1)\n ) {\n throw new Error(\n tr('\"swiplet.versionCode\" in package.json must be a positive integer.'),\n );\n }\n const apiManifest = require.resolve(\"@swipt/api/package.json\", {\n paths: [root, import.meta.dirname],\n });\n const {\n apiLevel,\n oldestAPILevel = 1,\n minimumIOSVersion = 27,\n } = JSON.parse(fs.readFileSync(apiManifest, \"utf8\"));\n if (\n config.minimumAPILevel !== undefined &&\n !(\n Number.isInteger(config.minimumAPILevel) &&\n config.minimumAPILevel >= oldestAPILevel &&\n config.minimumAPILevel <= apiLevel\n )\n ) {\n throw new Error(\n tr(\n '\"swiplet.minimumAPILevel\" in package.json must be an integer from {oldest} to {level}, the API level of @swipt/api.',\n { oldest: oldestAPILevel, level: apiLevel },\n ),\n );\n }\n const version = parseVersion(config.minimumIOSVersion);\n if (\n config.minimumIOSVersion !== undefined &&\n !(\n typeof config.minimumIOSVersion === \"number\" &&\n version &&\n versionAtLeast(version, parseVersion(minimumIOSVersion))\n )\n ) {\n throw new Error(\n tr(\n '\"swiplet.minimumIOSVersion\" in package.json must be a version number from {version}, the minimum iOS version of @swipt/api.',\n { version: minimumIOSVersion },\n ),\n );\n }\n if (typeof config.app !== \"string\" || config.app === \"\") {\n throw new Error(\n tr('\"{field}\" in package.json must be a string.', {\n field: \"swiplet.app\",\n }),\n );\n }\n return {\n root,\n manifest,\n config,\n localizedNames,\n apiLevel,\n minimumIOSVersion,\n apiDirectory: path.dirname(apiManifest),\n app: path.resolve(root, config.app),\n extension:\n config.extension === undefined\n ? undefined\n : path.resolve(root, config.extension),\n };\n}\n\nconst typeImport = (extension) => ({\n name: \"swiplet-type-import\",\n setup(build) {\n build.onLoad({ filter: /.*/ }, (args) => {\n if (args.path !== extension) {\n return undefined;\n }\n return {\n errors: [\n {\n text: tr(\n \"The interface imports {file} at runtime; import its type with `import type`.\",\n { file: path.basename(extension) },\n ),\n },\n ],\n };\n });\n },\n});\n\nasync function bundle(project) {\n const out = {\n app: \"\",\n extension: \"\",\n extensionMap: \"\",\n assets: new Map(),\n metafiles: [],\n };\n loadEnvironment(project.root);\n if (project.extension) {\n const outfile = path.join(\n project.root,\n \"dist\",\n project.config.id,\n \"src\",\n \"extension.js\",\n );\n const result = await build({\n entryPoints: [project.extension],\n outfile,\n bundle: true,\n format: \"cjs\",\n platform: \"neutral\",\n mainFields: [\"module\", \"main\"],\n target: \"es2022\",\n external: extensionModules,\n sourcemap: \"external\",\n sourcesContent: false,\n write: false,\n metafile: true,\n logLevel: \"silent\",\n plugins: [metro(project.root, { sourcemap: true })],\n });\n out.metafiles.push(result.metafile);\n out.extension = result.outputFiles.find((file) =>\n file.path.endsWith(\".js\"),\n ).text;\n const map = JSON.parse(\n result.outputFiles.find((file) => file.path.endsWith(\".map\")).text,\n );\n const sources = map.sources.map((source) =>\n path\n .relative(\n project.root,\n path.resolve(path.dirname(outfile), map.sourceRoot ?? \"\", source),\n )\n .split(path.sep)\n .join(\"/\"),\n );\n out.extensionMap = JSON.stringify({\n ...map,\n sourceRoot: undefined,\n sources,\n });\n }\n const result = await build({\n entryPoints: [project.app],\n bundle: true,\n format: \"cjs\",\n platform: \"neutral\",\n mainFields: [\"react-native\", \"browser\", \"module\", \"main\"],\n conditions: [\"react-native\"],\n resolveExtensions: [\n \".ios.tsx\",\n \".ios.ts\",\n \".native.tsx\",\n \".native.ts\",\n \".tsx\",\n \".ts\",\n \".ios.jsx\",\n \".ios.js\",\n \".native.js\",\n \".jsx\",\n \".js\",\n \".json\",\n ],\n jsx: \"automatic\",\n target: \"es2020\",\n define: { \"process.env.NODE_ENV\": '\"production\"', __DEV__: \"false\" },\n external: appModules,\n write: false,\n metafile: true,\n logLevel: \"silent\",\n plugins: [\n ...(project.extension ? [typeImport(project.extension)] : []),\n metro(project.root, { assets: out.assets }),\n ],\n });\n out.metafiles.push(result.metafile);\n const scoped = await transformAsync(result.outputFiles[0].text, {\n babelrc: false,\n configFile: false,\n sourceType: \"script\",\n compact: false,\n plugins: [require.resolve(\"@babel/plugin-transform-block-scoping\")],\n });\n out.app = scoped.code;\n return out;\n}\n\nconst definitionKey = Symbol(\"definition\");\n\nfunction describeExtension(source) {\n if (source === \"\") {\n return { service: false, actions: [] };\n }\n const [newer, older] = [true, false].map((result) =>\n evaluateExtension(source, result),\n );\n if (JSON.stringify(newer) !== JSON.stringify(older)) {\n throw new Error(\n tr(\n \"The extension defines different actions depending on available(); define the same actions on every system and check available() inside run or an action.\",\n ),\n );\n }\n return newer;\n}\n\nfunction evaluateExtension(source, availableResult) {\n const failing = (message) => {\n const fail = () => {\n throw new Error(message);\n };\n const get = (_, key) =>\n key === \"__esModule\"\n ? true\n : typeof key === \"symbol\" || key === \"then\"\n ? undefined\n : fail();\n return new Proxy(fail, { get, apply: fail, construct: fail });\n };\n const loading = (name) =>\n failing(\n tr(\n \"{name} is used while extension.js loads; use it inside run or an action.\",\n { name },\n ),\n );\n const database = () =>\n failing(\n tr(\n \"The database is used while extension.js loads; use it inside run or an action.\",\n ),\n );\n const storage = failing(\n tr(\n \"The storage is used while extension.js loads; use it inside run or an action.\",\n ),\n );\n const modules = {\n \"@swipt/api\": { available: () => availableResult },\n \"@swipt/api/swiplet\": {\n defineExtension: (definition) => ({ [definitionKey]: definition }),\n defineAction: (definition) => definition,\n actions: loading(\"actions\"),\n useService: loading(\"useService\"),\n },\n \"@swipt/api/file-system\": {\n get dataDirectory() {\n throw new Error(\n tr(\n \"{name} is used while extension.js loads; use it inside run or an action.\",\n { name: \"dataDirectory\" },\n ),\n );\n },\n get cacheDirectory() {\n throw new Error(\n tr(\n \"{name} is used while extension.js loads; use it inside run or an action.\",\n { name: \"cacheDirectory\" },\n ),\n );\n },\n get assets() {\n throw new Error(\n tr(\n \"{name} is used while extension.js loads; use it inside run or an action.\",\n { name: \"assets\" },\n ),\n );\n },\n },\n \"@swipt/api/accessibility\": loading(\"accessibility\"),\n \"@swipt/api/input\": loading(\"input\"),\n \"@swipt/api/device\": loading(\"device\"),\n \"@swipt/api/process\": loading(\"process\"),\n \"@swipt/api/screen\": loading(\"screen\"),\n \"@swipt/api/image\": loading(\"image\"),\n \"@swipt/api/app-intents\": loading(\"appIntents\"),\n \"@swipt/api/http\": {\n Client: function Client() {\n return loading(\"Client\");\n },\n CookieJar: function CookieJar() {\n return loading(\"CookieJar\");\n },\n },\n \"@swipt/api/localization\": {\n preferredLocalizations: (localizations) =>\n localizations.includes(\"en\") ? [\"en\"] : localizations.slice(0, 1),\n },\n \"expo-sqlite\": {\n SQLiteDatabase: loading(\"SQLiteDatabase\"),\n SQLiteStatement: loading(\"SQLiteStatement\"),\n SQLiteTaggedQuery: loading(\"SQLiteTaggedQuery\"),\n SQLiteSession: loading(\"SQLiteSession\"),\n openDatabaseSync: database,\n openDatabaseAsync: () => Promise.resolve(database()),\n deserializeDatabaseSync: database,\n deserializeDatabaseAsync: () => Promise.resolve(database()),\n deleteDatabaseSync: () => {},\n deleteDatabaseAsync: () => Promise.resolve(),\n backupDatabaseSync: () => {},\n backupDatabaseAsync: () => Promise.resolve(),\n importDatabaseFromAssetAsync: () => Promise.resolve(),\n addDatabaseChangeListener: () => ({ remove: () => {} }),\n defaultDatabaseDirectory: \"\",\n bundledExtensions: {},\n configureWeb: () => {},\n deepEqual: function deepEqual(a, b) {\n if (a === b) {\n return true;\n }\n if (\n a === null ||\n b === null ||\n typeof a !== \"object\" ||\n typeof b !== \"object\"\n ) {\n return false;\n }\n const keys = Object.keys(a);\n return (\n keys.length === Object.keys(b).length &&\n keys.every((key) => deepEqual(a[key], b[key]))\n );\n },\n SQLiteProvider: () => {\n throw new Error(\n tr(\"{name} works only in the swiplet interface.\", {\n name: \"SQLiteProvider\",\n }),\n );\n },\n useSQLiteContext: () => {\n throw new Error(\n tr(\"{name} works only in the swiplet interface.\", {\n name: \"useSQLiteContext\",\n }),\n );\n },\n },\n \"expo-sqlite/kv-store\": {\n SQLiteStorage: loading(\"SQLiteStorage\"),\n AsyncStorage: storage,\n Storage: storage,\n default: storage,\n },\n get \"expo-sqlite/localStorage/install\"() {\n context.localStorage = loading(\"localStorage\");\n return {};\n },\n };\n const ignored = () => 0;\n const webGlobals = [\n \"MessageEvent\",\n \"CloseEvent\",\n \"ErrorEvent\",\n \"File\",\n \"FormData\",\n \"Headers\",\n \"Request\",\n \"Response\",\n \"WebSocket\",\n \"EventSource\",\n \"ReadableStream\",\n \"ReadableStreamDefaultReader\",\n \"ReadableStreamBYOBReader\",\n \"ReadableStreamBYOBRequest\",\n \"ReadableStreamDefaultController\",\n \"ReadableByteStreamController\",\n \"WritableStream\",\n \"WritableStreamDefaultWriter\",\n \"WritableStreamDefaultController\",\n \"TransformStream\",\n \"TransformStreamDefaultController\",\n \"ByteLengthQueuingStrategy\",\n \"CountQueuingStrategy\",\n \"TextEncoderStream\",\n \"TextDecoderStream\",\n \"CompressionStream\",\n \"DecompressionStream\",\n \"performance\",\n \"Performance\",\n \"PerformanceEntry\",\n \"PerformanceMark\",\n \"PerformanceMeasure\",\n \"PerformanceObserver\",\n \"PerformanceObserverEntryList\",\n ];\n const context = vm.createContext({\n console,\n URL,\n URLSearchParams,\n TextEncoder,\n TextDecoder,\n atob,\n btoa,\n structuredClone,\n queueMicrotask,\n crypto,\n AbortController,\n AbortSignal,\n Event,\n EventTarget,\n CustomEvent,\n DOMException,\n Blob,\n ...Object.fromEntries(webGlobals.map((name) => [name, globalThis[name]])),\n fetch: loading(\"fetch\"),\n setTimeout: ignored,\n setInterval: ignored,\n clearTimeout: ignored,\n clearInterval: ignored,\n navigator: { userAgent: \"Swipt\", language: \"en\", languages: [\"en\"] },\n });\n const factory = vm.runInContext(\n `(function (require, module, exports) {${source}\\n})`,\n context,\n { filename: \"extension.js\" },\n );\n const module: { exports: any } = { exports: {} };\n factory(\n (specifier) => {\n if (!Object.hasOwn(modules, specifier)) {\n throw new Error(\n tr(\n 'Swipt doesn\\'t provide \"{module}\" to extensions; bundle it into extension.js.',\n { module: specifier },\n ),\n );\n }\n return modules[specifier];\n },\n module,\n module.exports,\n );\n const definition = (module.exports.default ?? module.exports)?.[\n definitionKey\n ];\n if (definition === undefined) {\n throw new Error(\n tr(\"The extension's default export isn't the result of defineExtension.\"),\n );\n }\n const schema = (name, value, side) => {\n if (value === undefined) {\n return undefined;\n }\n const converter = value?.[\"~standard\"]?.jsonSchema;\n if (typeof converter?.[side] !== \"function\") {\n throw new Error(\n tr(\n \"The {side} schema of the action {action} doesn't implement Standard JSON Schema; use a library that does, such as Zod 4.\",\n { side, action: JSON.stringify(name) },\n ),\n );\n }\n return converter[side]({ target: \"draft-2020-12\" });\n };\n const actions = Object.entries(definition.actions ?? {}).map(\n ([name, action]: [string, any]) => {\n if (typeof action?.title !== \"string\" || action.title === \"\") {\n throw new Error(\n tr(\"The action {action} needs a title.\", {\n action: JSON.stringify(name),\n }),\n );\n }\n const expose = action.expose ?? [];\n if (\n !Array.isArray(expose) ||\n !expose.every((caller) => caller === \"shortcuts\")\n ) {\n throw new Error(\n tr('The action {action} can only expose itself to \"shortcuts\".', {\n action: JSON.stringify(name),\n }),\n );\n }\n return {\n name,\n title: action.title,\n ...(action.description ? { description: action.description } : {}),\n ...(expose.length > 0 ? { expose } : {}),\n ...(typeof action.stream === \"function\" ? { stream: true } : {}),\n ...(action.input ? { input: schema(name, action.input, \"input\") } : {}),\n ...(action.output\n ? { output: schema(name, action.output, \"output\") }\n : {}),\n };\n },\n );\n return { service: typeof definition.run === \"function\", actions };\n}\n\nfunction swipletManifest(project, output) {\n const { service, actions } = describeExtension(output.extension);\n const { config, localizedNames } = project;\n return {\n id: config.id,\n name: config.name,\n ...(Object.keys(localizedNames).length > 0 ? { localizedNames } : {}),\n ...(config.description ? { description: config.description } : {}),\n ...(project.manifest.version ? { version: project.manifest.version } : {}),\n ...(config.versionCode ? { versionCode: config.versionCode } : {}),\n ...(config.icon ? { icon: config.icon } : {}),\n minimumAPILevel: config.minimumAPILevel ?? project.apiLevel,\n minimumIOSVersion: config.minimumIOSVersion ?? project.minimumIOSVersion,\n ...(service ? { service } : {}),\n ...(actions.length > 0 ? { actions } : {}),\n };\n}\n\nconst sourceFiles = (output) => ({\n \"app.js\": output.app,\n ...(output.extension ? { \"extension.js\": output.extension } : {}),\n});\n\nexport async function buildProject(root, checker?) {\n const project = loadProject(root);\n const output = await bundle(project);\n if (checker === undefined) {\n const owned = new AvailabilityChecker();\n try {\n owned.check(project, output.metafiles);\n } finally {\n owned.close();\n }\n } else {\n checker.check(project, output.metafiles);\n }\n const manifest = swipletManifest(project, output);\n const dist = path.join(root, \"dist\");\n const folder = path.join(dist, manifest.id);\n fs.rmSync(folder, { recursive: true, force: true });\n fs.mkdirSync(path.join(folder, \"src\"), { recursive: true });\n fs.writeFileSync(\n path.join(folder, \"manifest.json\"),\n `${JSON.stringify(manifest, null, 2)}\\n`,\n );\n for (const [file, contents] of Object.entries(sourceFiles(output))) {\n fs.writeFileSync(path.join(folder, \"src\", file), contents);\n }\n if (output.extensionMap) {\n fs.writeFileSync(\n path.join(folder, \"src\", \"extension.js.map\"),\n output.extensionMap,\n );\n }\n if (fs.existsSync(path.join(root, \"icon.png\"))) {\n fs.copyFileSync(path.join(root, \"icon.png\"), path.join(folder, \"icon.png\"));\n }\n if (fs.existsSync(path.join(root, \"assets\"))) {\n fs.cpSync(path.join(root, \"assets\"), path.join(folder, \"assets\"), {\n recursive: true,\n dereference: true,\n filter: (source) => !path.basename(source).startsWith(\".\"),\n });\n }\n for (const [name, source] of output.assets) {\n const target = path.join(folder, \"assets\", name);\n if (fs.existsSync(target)) {\n throw new Error(\n tr(\"{source} and {asset} would both be assets/{name} in the swiplet.\", {\n source: path.relative(root, source),\n asset: path.join(\"assets\", name),\n name,\n }),\n );\n }\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.copyFileSync(source, target);\n }\n const archive = path.join(dist, `${manifest.id}.swiplet`);\n fs.rmSync(archive, { force: true });\n fs.rmSync(path.join(dist, `${manifest.id}.zip`), { force: true });\n return { id: manifest.id, archive, digest: writeSwiplet(folder, archive) };\n}\n\nfunction writeSwiplet(folder, archive) {\n const hash = createHash(\"sha256\");\n const entries = {};\n const names = fs\n .readdirSync(folder, { recursive: true, withFileTypes: true })\n .filter((entry) => entry.isFile())\n .map((entry) =>\n path\n .relative(folder, path.join(entry.parentPath, entry.name))\n .split(path.sep)\n .join(\"/\"),\n )\n .sort();\n for (const name of names) {\n const file = path.join(folder, name);\n const data = fs.readFileSync(file);\n const stat = fs.statSync(file);\n hash.update(`${name}\\0`);\n hash.update(data);\n hash.update(\"\\0\");\n entries[name] = [\n data,\n {\n level: storedSuffixes.some((suffix) =>\n name.toLowerCase().endsWith(suffix),\n )\n ? 0\n : 6,\n mtime: Math.max(stat.mtimeMs, zipEpoch),\n os: 3,\n attrs: ((stat.mode & 0o777) | 0o100000) << 16,\n },\n ];\n }\n fs.writeFileSync(archive, zipSync(entries));\n return hash.digest(\"hex\");\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,UAAU,cAAc,YAAY,GAAG;AAE7C,MAAM,aAAa;CACjB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,YAAY;AAEzB,MAAM,iBAAiB;C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O,CAAC;CAC1C,OAAO,KAAK,OAAO,KAAK;AAC1B"}
|
|
1
|
+
{"version":3,"file":"project.js","names":[],"sources":["../src/project.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { createHash } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport vm from \"node:vm\";\n\nimport { transformAsync } from \"@babel/core\";\nimport { build, type Metafile, type Plugin } from \"esbuild\";\nimport { type Zippable, zipSync } from \"fflate\";\n\nimport { AvailabilityChecker } from \"./availability\";\nimport { t } from \"./i18n\";\nimport { loadEnvironment, metro } from \"./metro\";\nimport { parseVersion, versionAtLeast } from \"./version\";\n\nconst require = createRequire(import.meta.url);\n\nconst appModules = [\n \"react\",\n \"react/jsx-runtime\",\n \"react-native\",\n \"react-native-worklets\",\n \"expo\",\n \"expo-localization\",\n \"expo-maps\",\n \"@expo/ui\",\n \"@expo/ui/*\",\n \"@swipt/api\",\n \"@swipt/api/swiplet\",\n \"@swipt/api/file-system\",\n \"@swipt/api/localization\",\n \"@swipt/api/maps\",\n \"@swipt/api/http\",\n \"@swipt/api/app-intents\",\n \"@swipt/api/swift-ui\",\n \"expo-sqlite\",\n \"expo-sqlite/kv-store\",\n \"expo-sqlite/localStorage/install\",\n];\nconst extensionModules = [\n \"@swipt/api\",\n \"@swipt/api/swiplet\",\n \"@swipt/api/file-system\",\n \"@swipt/api/accessibility\",\n \"@swipt/api/input\",\n \"@swipt/api/device\",\n \"@swipt/api/process\",\n \"@swipt/api/screen\",\n \"@swipt/api/image\",\n \"@swipt/api/app-intents\",\n \"@swipt/api/localization\",\n \"@swipt/api/http\",\n \"expo-sqlite\",\n \"expo-sqlite/kv-store\",\n \"expo-sqlite/localStorage/install\",\n];\n\nexport const idPattern = /^[a-z0-9][a-z0-9._-]{0,127}$/;\n\nconst storedSuffixes = [\n \".webp\",\n \".jxl\",\n \".avif\",\n \".heic\",\n \".heif\",\n \".jpg\",\n \".jpeg\",\n \".png\",\n \".gif\",\n \".mp4\",\n \".mov\",\n \".m4a\",\n \".mp3\",\n \".aac\",\n \".zip\",\n \".gz\",\n \".br\",\n \".zst\",\n \".xz\",\n];\n\nconst zipEpoch = new Date(1980, 0, 1).getTime();\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isStringRecord = (value: unknown): value is Record<string, string> =>\n isRecord(value) &&\n Object.values(value).every((name) => typeof name === \"string\");\n\nexport function loadProject(root: string) {\n const parsed: unknown = JSON.parse(\n fs.readFileSync(path.join(root, \"package.json\"), \"utf8\"),\n );\n const manifest: Record<string, unknown> = isRecord(parsed) ? parsed : {};\n const config = isRecord(manifest.swiplet) ? manifest.swiplet : {};\n if (typeof config.id !== \"string\" || !idPattern.test(config.id)) {\n throw new Error(t(\"project.invalidID\"));\n }\n if (typeof config.name !== \"string\" || config.name === \"\") {\n throw new Error(t(\"project.invalidName\"));\n }\n const localizedNames = config.localizedNames ?? {};\n if (!isStringRecord(localizedNames)) {\n throw new Error(t(\"project.invalidLocalizedNames\"));\n }\n if (\n config.description !== undefined &&\n typeof config.description !== \"string\"\n ) {\n throw new Error(\n t(\"project.invalidString\", {\n field: \"swiplet.description\",\n }),\n );\n }\n if (\n config.versionCode !== undefined &&\n (typeof config.versionCode !== \"number\" ||\n !Number.isInteger(config.versionCode) ||\n config.versionCode < 1)\n ) {\n throw new Error(t(\"project.invalidVersionCode\"));\n }\n const apiManifest = require.resolve(\"@swipt/api/package.json\", {\n paths: [root, import.meta.dirname],\n });\n const {\n apiLevel,\n oldestAPILevel = 1,\n minimumIOSVersion = 27,\n }: {\n apiLevel: number;\n oldestAPILevel?: number;\n minimumIOSVersion?: number;\n } = JSON.parse(fs.readFileSync(apiManifest, \"utf8\"));\n if (\n config.minimumAPILevel !== undefined &&\n !(\n typeof config.minimumAPILevel === \"number\" &&\n Number.isInteger(config.minimumAPILevel) &&\n config.minimumAPILevel >= oldestAPILevel &&\n config.minimumAPILevel <= apiLevel\n )\n ) {\n throw new Error(\n t(\"project.invalidMinimumAPILevel\", {\n oldest: oldestAPILevel,\n level: apiLevel,\n }),\n );\n }\n const version = parseVersion(config.minimumIOSVersion);\n const oldestVersion = parseVersion(minimumIOSVersion);\n if (\n config.minimumIOSVersion !== undefined &&\n !(\n typeof config.minimumIOSVersion === \"number\" &&\n version &&\n oldestVersion &&\n versionAtLeast(version, oldestVersion)\n )\n ) {\n throw new Error(\n t(\"project.invalidMinimumIOSVersion\", { version: minimumIOSVersion }),\n );\n }\n if (typeof config.app !== \"string\" || config.app === \"\") {\n throw new Error(\n t(\"project.invalidString\", {\n field: \"swiplet.app\",\n }),\n );\n }\n if (\n config.extension !== undefined &&\n (typeof config.extension !== \"string\" || config.extension === \"\")\n ) {\n throw new Error(\n t(\"project.invalidString\", {\n field: \"swiplet.extension\",\n }),\n );\n }\n return {\n root,\n version: manifest.version,\n config: {\n id: config.id,\n name: config.name,\n description: config.description,\n versionCode: config.versionCode,\n icon: config.icon,\n minimumAPILevel: config.minimumAPILevel,\n minimumIOSVersion: config.minimumIOSVersion,\n },\n localizedNames,\n apiLevel,\n minimumIOSVersion,\n apiDirectory: path.dirname(apiManifest),\n app: path.resolve(root, config.app),\n extension:\n config.extension === undefined\n ? undefined\n : path.resolve(root, config.extension),\n };\n}\n\nexport type Project = ReturnType<typeof loadProject>;\n\nconst typeImport = (extension: string): Plugin => ({\n name: \"swiplet-type-import\",\n setup(build) {\n build.onLoad({ filter: /.*/ }, (args) => {\n if (args.path !== extension) {\n return undefined;\n }\n return {\n errors: [\n {\n text: t(\"project.interfaceImport\", {\n file: path.basename(extension),\n }),\n },\n ],\n };\n });\n },\n});\n\ninterface Bundle {\n app: string;\n extension: string;\n extensionMap: string;\n assets: Map<string, string>;\n metafiles: Metafile[];\n}\n\nasync function bundle(project: Project) {\n const out: Bundle = {\n app: \"\",\n extension: \"\",\n extensionMap: \"\",\n assets: new Map(),\n metafiles: [],\n };\n loadEnvironment(project.root);\n if (project.extension) {\n const outfile = path.join(\n project.root,\n \"dist\",\n project.config.id,\n \"src\",\n \"extension.js\",\n );\n const result = await build({\n entryPoints: [project.extension],\n outfile,\n bundle: true,\n format: \"cjs\",\n platform: \"neutral\",\n mainFields: [\"module\", \"main\"],\n target: \"es2022\",\n external: extensionModules,\n sourcemap: \"external\",\n sourcesContent: false,\n write: false,\n metafile: true,\n logLevel: \"silent\",\n plugins: [metro(project.root, { sourcemap: true })],\n });\n out.metafiles.push(result.metafile);\n const code = result.outputFiles.find((file) => file.path.endsWith(\".js\"));\n const sourceMap = result.outputFiles.find((file) =>\n file.path.endsWith(\".map\"),\n );\n if (code === undefined || sourceMap === undefined) {\n throw new Error(\"esbuild wrote no extension bundle or source map\");\n }\n out.extension = code.text;\n const map: { sources: string[]; sourceRoot?: string } = JSON.parse(\n sourceMap.text,\n );\n const sources = map.sources.map((source) =>\n path\n .relative(\n project.root,\n path.resolve(path.dirname(outfile), map.sourceRoot ?? \"\", source),\n )\n .split(path.sep)\n .join(\"/\"),\n );\n out.extensionMap = JSON.stringify({\n ...map,\n sourceRoot: undefined,\n sources,\n });\n }\n const result = await build({\n entryPoints: [project.app],\n bundle: true,\n format: \"cjs\",\n platform: \"neutral\",\n mainFields: [\"react-native\", \"browser\", \"module\", \"main\"],\n conditions: [\"react-native\"],\n resolveExtensions: [\n \".ios.tsx\",\n \".ios.ts\",\n \".native.tsx\",\n \".native.ts\",\n \".tsx\",\n \".ts\",\n \".ios.jsx\",\n \".ios.js\",\n \".native.js\",\n \".jsx\",\n \".js\",\n \".json\",\n ],\n jsx: \"automatic\",\n target: \"es2020\",\n define: { \"process.env.NODE_ENV\": '\"production\"', __DEV__: \"false\" },\n external: appModules,\n write: false,\n metafile: true,\n logLevel: \"silent\",\n plugins: [\n ...(project.extension ? [typeImport(project.extension)] : []),\n metro(project.root, { assets: out.assets }),\n ],\n });\n out.metafiles.push(result.metafile);\n const scoped = await transformAsync(result.outputFiles[0].text, {\n babelrc: false,\n configFile: false,\n sourceType: \"script\",\n compact: false,\n plugins: [require.resolve(\"@babel/plugin-transform-block-scoping\")],\n });\n if (typeof scoped?.code !== \"string\") {\n throw new Error(\"Babel produced no code for the app bundle\");\n }\n out.app = scoped.code;\n return out;\n}\n\nconst definitionKey = Symbol(\"definition\");\n\ninterface ExtensionDescription {\n service: boolean;\n actions: ActionDescription[];\n}\n\ninterface ActionDescription {\n name: string;\n title: string;\n description?: unknown;\n expose?: \"shortcuts\"[];\n stream?: true;\n input?: unknown;\n output?: unknown;\n}\n\nconst member = (value: unknown, key: PropertyKey): unknown =>\n (typeof value === \"object\" && value !== null) || typeof value === \"function\"\n ? Reflect.get(value, key)\n : undefined;\n\nfunction describeExtension(source: string): ExtensionDescription {\n if (source === \"\") {\n return { service: false, actions: [] };\n }\n const [newer, older] = [true, false].map((result) =>\n evaluateExtension(source, result),\n );\n if (JSON.stringify(newer) !== JSON.stringify(older)) {\n throw new Error(t(\"project.conditionalActions\"));\n }\n return newer;\n}\n\nfunction evaluateExtension(\n source: string,\n availableResult: boolean,\n): ExtensionDescription {\n const failing = (message: string) => {\n const fail = () => {\n throw new Error(message);\n };\n return new Proxy(fail, {\n get: (_, key) =>\n key === \"__esModule\"\n ? true\n : typeof key === \"symbol\" || key === \"then\"\n ? undefined\n : fail(),\n apply: fail,\n construct: fail,\n });\n };\n const loading = (name: string) => failing(t(\"project.usedAtLoad\", { name }));\n const database = () => failing(t(\"project.databaseAtLoad\"));\n const storage = failing(t(\"project.storageAtLoad\"));\n const modules: Record<string, unknown> = {\n \"@swipt/api\": { available: () => availableResult },\n \"@swipt/api/swiplet\": {\n defineExtension: (definition: unknown) => ({\n [definitionKey]: definition,\n }),\n defineAction: (definition: unknown) => definition,\n actions: loading(\"actions\"),\n useService: loading(\"useService\"),\n },\n \"@swipt/api/file-system\": {\n get dataDirectory() {\n throw new Error(t(\"project.usedAtLoad\", { name: \"dataDirectory\" }));\n },\n get cacheDirectory() {\n throw new Error(t(\"project.usedAtLoad\", { name: \"cacheDirectory\" }));\n },\n get assets() {\n throw new Error(t(\"project.usedAtLoad\", { name: \"assets\" }));\n },\n },\n \"@swipt/api/accessibility\": loading(\"accessibility\"),\n \"@swipt/api/input\": loading(\"input\"),\n \"@swipt/api/device\": loading(\"device\"),\n \"@swipt/api/process\": loading(\"process\"),\n \"@swipt/api/screen\": loading(\"screen\"),\n \"@swipt/api/image\": loading(\"image\"),\n \"@swipt/api/app-intents\": loading(\"appIntents\"),\n \"@swipt/api/http\": {\n Client: function Client() {\n return loading(\"Client\");\n },\n CookieJar: function CookieJar() {\n return loading(\"CookieJar\");\n },\n },\n \"@swipt/api/localization\": {\n preferredLocalizations: (localizations: readonly string[]) =>\n localizations.includes(\"en\") ? [\"en\"] : localizations.slice(0, 1),\n },\n \"expo-sqlite\": {\n SQLiteDatabase: loading(\"SQLiteDatabase\"),\n SQLiteStatement: loading(\"SQLiteStatement\"),\n SQLiteTaggedQuery: loading(\"SQLiteTaggedQuery\"),\n SQLiteSession: loading(\"SQLiteSession\"),\n openDatabaseSync: database,\n openDatabaseAsync: () => Promise.resolve(database()),\n deserializeDatabaseSync: database,\n deserializeDatabaseAsync: () => Promise.resolve(database()),\n deleteDatabaseSync: () => {},\n deleteDatabaseAsync: () => Promise.resolve(),\n backupDatabaseSync: () => {},\n backupDatabaseAsync: () => Promise.resolve(),\n importDatabaseFromAssetAsync: () => Promise.resolve(),\n addDatabaseChangeListener: () => ({ remove: () => {} }),\n defaultDatabaseDirectory: \"\",\n bundledExtensions: {},\n configureWeb: () => {},\n deepEqual: function deepEqual(a: unknown, b: unknown): boolean {\n if (a === b) {\n return true;\n }\n if (\n a === null ||\n b === null ||\n typeof a !== \"object\" ||\n typeof b !== \"object\"\n ) {\n return false;\n }\n const keys = Object.keys(a);\n return (\n keys.length === Object.keys(b).length &&\n keys.every((key) => deepEqual(member(a, key), member(b, key)))\n );\n },\n SQLiteProvider: () => {\n throw new Error(\n t(\"project.interfaceOnly\", {\n name: \"SQLiteProvider\",\n }),\n );\n },\n useSQLiteContext: () => {\n throw new Error(\n t(\"project.interfaceOnly\", {\n name: \"useSQLiteContext\",\n }),\n );\n },\n },\n \"expo-sqlite/kv-store\": {\n SQLiteStorage: loading(\"SQLiteStorage\"),\n AsyncStorage: storage,\n Storage: storage,\n default: storage,\n },\n get \"expo-sqlite/localStorage/install\"() {\n context.localStorage = loading(\"localStorage\");\n return {};\n },\n };\n const ignored = () => 0;\n const webGlobals = [\n \"MessageEvent\",\n \"CloseEvent\",\n \"ErrorEvent\",\n \"File\",\n \"FormData\",\n \"Headers\",\n \"Request\",\n \"Response\",\n \"WebSocket\",\n \"EventSource\",\n \"ReadableStream\",\n \"ReadableStreamDefaultReader\",\n \"ReadableStreamBYOBReader\",\n \"ReadableStreamBYOBRequest\",\n \"ReadableStreamDefaultController\",\n \"ReadableByteStreamController\",\n \"WritableStream\",\n \"WritableStreamDefaultWriter\",\n \"WritableStreamDefaultController\",\n \"TransformStream\",\n \"TransformStreamDefaultController\",\n \"ByteLengthQueuingStrategy\",\n \"CountQueuingStrategy\",\n \"TextEncoderStream\",\n \"TextDecoderStream\",\n \"CompressionStream\",\n \"DecompressionStream\",\n \"performance\",\n \"Performance\",\n \"PerformanceEntry\",\n \"PerformanceMark\",\n \"PerformanceMeasure\",\n \"PerformanceObserver\",\n \"PerformanceObserverEntryList\",\n ];\n const context = vm.createContext({\n console,\n URL,\n URLSearchParams,\n TextEncoder,\n TextDecoder,\n atob,\n btoa,\n structuredClone,\n queueMicrotask,\n crypto,\n AbortController,\n AbortSignal,\n Event,\n EventTarget,\n CustomEvent,\n DOMException,\n Blob,\n ...Object.fromEntries(\n webGlobals.map((name) => [name, Reflect.get(globalThis, name)]),\n ),\n fetch: loading(\"fetch\"),\n setTimeout: ignored,\n setInterval: ignored,\n clearTimeout: ignored,\n clearInterval: ignored,\n navigator: { userAgent: \"Swipt\", language: \"en\", languages: [\"en\"] },\n });\n const factory: (\n require: (specifier: unknown) => unknown,\n module: { exports: unknown },\n exports: unknown,\n ) => void = vm.runInContext(\n `(function (require, module, exports) {${source}\\n})`,\n context,\n { filename: \"extension.js\" },\n );\n const module: { exports: unknown } = { exports: {} };\n factory(\n (specifier) => {\n if (typeof specifier !== \"string\" || !Object.hasOwn(modules, specifier)) {\n throw new Error(\n t(\"project.unprovidedModule\", { module: String(specifier) }),\n );\n }\n return modules[specifier];\n },\n module,\n module.exports,\n );\n const definition = member(\n member(module.exports, \"default\") ?? module.exports,\n definitionKey,\n );\n if (definition === undefined) {\n throw new Error(t(\"project.invalidExtension\"));\n }\n const schema = (\n name: string,\n value: unknown,\n side: \"input\" | \"output\",\n ): unknown => {\n if (value === undefined) {\n return undefined;\n }\n const converter = member(member(value, \"~standard\"), \"jsonSchema\");\n const convert = member(converter, side);\n if (typeof convert !== \"function\") {\n throw new Error(\n t(\"project.invalidSchema\", { side, action: JSON.stringify(name) }),\n );\n }\n return convert.call(converter, { target: \"draft-2020-12\" });\n };\n const actions = Object.entries(member(definition, \"actions\") ?? {}).map(\n ([name, action]: [string, unknown]): ActionDescription => {\n const title = member(action, \"title\");\n if (typeof title !== \"string\" || title === \"\") {\n throw new Error(\n t(\"project.missingTitle\", {\n action: JSON.stringify(name),\n }),\n );\n }\n const expose = member(action, \"expose\") ?? [];\n if (\n !Array.isArray(expose) ||\n !expose.every(\n (caller: unknown): caller is \"shortcuts\" => caller === \"shortcuts\",\n )\n ) {\n throw new Error(\n t(\"project.invalidExposure\", {\n action: JSON.stringify(name),\n }),\n );\n }\n const description = member(action, \"description\");\n const input = member(action, \"input\");\n const output = member(action, \"output\");\n return {\n name,\n title,\n ...(description ? { description } : {}),\n ...(expose.length > 0 ? { expose } : {}),\n ...(typeof member(action, \"stream\") === \"function\"\n ? { stream: true }\n : {}),\n ...(input ? { input: schema(name, input, \"input\") } : {}),\n ...(output ? { output: schema(name, output, \"output\") } : {}),\n };\n },\n );\n return {\n service: typeof member(definition, \"run\") === \"function\",\n actions,\n };\n}\n\nfunction swipletManifest(project: Project, output: Bundle) {\n const { service, actions } = describeExtension(output.extension);\n const { config, localizedNames } = project;\n return {\n id: config.id,\n name: config.name,\n ...(Object.keys(localizedNames).length > 0 ? { localizedNames } : {}),\n ...(config.description ? { description: config.description } : {}),\n ...(project.version ? { version: project.version } : {}),\n ...(config.versionCode ? { versionCode: config.versionCode } : {}),\n ...(config.icon ? { icon: config.icon } : {}),\n minimumAPILevel: config.minimumAPILevel ?? project.apiLevel,\n minimumIOSVersion: config.minimumIOSVersion ?? project.minimumIOSVersion,\n ...(service ? { service } : {}),\n ...(actions.length > 0 ? { actions } : {}),\n };\n}\n\nconst sourceFiles = (output: Bundle) => ({\n \"app.js\": output.app,\n ...(output.extension ? { \"extension.js\": output.extension } : {}),\n});\n\nexport async function buildProject(\n root: string,\n checker?: AvailabilityChecker,\n) {\n const project = loadProject(root);\n const output = await bundle(project);\n if (checker === undefined) {\n const owned = new AvailabilityChecker();\n try {\n owned.check(project, output.metafiles);\n } finally {\n owned.close();\n }\n } else {\n checker.check(project, output.metafiles);\n }\n const manifest = swipletManifest(project, output);\n const dist = path.join(root, \"dist\");\n const folder = path.join(dist, manifest.id);\n fs.rmSync(folder, { recursive: true, force: true });\n fs.mkdirSync(path.join(folder, \"src\"), { recursive: true });\n fs.writeFileSync(\n path.join(folder, \"manifest.json\"),\n `${JSON.stringify(manifest, null, 2)}\\n`,\n );\n for (const [file, contents] of Object.entries(sourceFiles(output))) {\n fs.writeFileSync(path.join(folder, \"src\", file), contents);\n }\n if (output.extensionMap) {\n fs.writeFileSync(\n path.join(folder, \"src\", \"extension.js.map\"),\n output.extensionMap,\n );\n }\n if (fs.existsSync(path.join(root, \"icon.png\"))) {\n fs.copyFileSync(path.join(root, \"icon.png\"), path.join(folder, \"icon.png\"));\n }\n if (fs.existsSync(path.join(root, \"assets\"))) {\n fs.cpSync(path.join(root, \"assets\"), path.join(folder, \"assets\"), {\n recursive: true,\n dereference: true,\n filter: (source) => !path.basename(source).startsWith(\".\"),\n });\n }\n for (const [name, source] of output.assets) {\n const target = path.join(folder, \"assets\", name);\n if (fs.existsSync(target)) {\n throw new Error(\n t(\"project.assetConflict\", {\n source: path.relative(root, source),\n asset: path.join(\"assets\", name),\n name,\n }),\n );\n }\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.copyFileSync(source, target);\n }\n const archive = path.join(dist, `${manifest.id}.swiplet`);\n fs.rmSync(archive, { force: true });\n fs.rmSync(path.join(dist, `${manifest.id}.zip`), { force: true });\n return { id: manifest.id, archive, digest: writeSwiplet(folder, archive) };\n}\n\nfunction writeSwiplet(folder: string, archive: string) {\n const hash = createHash(\"sha256\");\n const entries: Zippable = {};\n const names = fs\n .readdirSync(folder, { recursive: true, withFileTypes: true })\n .filter((entry) => entry.isFile())\n .map((entry) =>\n path\n .relative(folder, path.join(entry.parentPath, entry.name))\n .split(path.sep)\n .join(\"/\"),\n )\n .sort();\n for (const name of names) {\n const file = path.join(folder, name);\n const data = fs.readFileSync(file);\n const stat = fs.statSync(file);\n hash.update(`${name}\\0`);\n hash.update(data);\n hash.update(\"\\0\");\n entries[name] = [\n data,\n {\n level: storedSuffixes.some((suffix) =>\n name.toLowerCase().endsWith(suffix),\n )\n ? 0\n : 6,\n mtime: Math.max(stat.mtimeMs, zipEpoch),\n os: 3,\n attrs: ((stat.mode & 0o777) | 0o100000) << 16,\n },\n ];\n }\n fs.writeFileSync(archive, zipSync(entries));\n return hash.digest(\"hex\");\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,UAAU,cAAc,YAAY,GAAG;AAE7C,MAAM,aAAa;CACjB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,YAAY;AAEzB,MAAM,iBAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CAC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