@swipt/cli 0.1.0-nightly.86 → 0.1.0-nightly.88
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.js +5 -5
- package/dist/availability.js.map +1 -1
- package/dist/cli/cli.js +16 -7
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/commands/data/read.js +4 -1
- package/dist/cli/commands/data/read.js.map +1 -1
- package/dist/cli/commands/device/add.js +1 -1
- package/dist/cli/commands/device/add.js.map +1 -1
- package/dist/cli/commands/device/logs.js +2 -2
- package/dist/cli/commands/device/logs.js.map +1 -1
- package/dist/cli/commands/flags.js +3 -3
- package/dist/cli/commands/flags.js.map +1 -1
- package/dist/cli/commands/project/create.js +1 -1
- package/dist/cli/commands/project/create.js.map +1 -1
- package/dist/cli/commands/project/develop.js +5 -2
- package/dist/cli/commands/project/develop.js.map +1 -1
- package/dist/cli/commands/project/source.js +6 -6
- package/dist/cli/commands/project/source.js.map +1 -1
- package/dist/cli/commands/repl/run.js +1 -1
- package/dist/cli/commands/repl/run.js.map +1 -1
- package/dist/cli/commands/sideload/install.js +4 -0
- package/dist/cli/commands/sideload/install.js.map +1 -1
- package/dist/cli/commands/swiplet/call.js +1 -1
- package/dist/cli/commands/swiplet/call.js.map +1 -1
- package/dist/cli/commands/swiplet/install.js +1 -1
- package/dist/cli/commands/swiplet/install.js.map +1 -1
- package/dist/cli/commands/swiplet/show.js +1 -1
- package/dist/cli/commands/swiplet/show.js.map +1 -1
- package/dist/client.js +6 -6
- package/dist/client.js.map +1 -1
- package/dist/connection.js +8 -8
- package/dist/connection.js.map +1 -1
- package/dist/coredevice.js +7 -7
- package/dist/coredevice.js.map +1 -1
- package/dist/i18n.d.ts +4 -1
- package/dist/i18n.js +2 -2
- package/dist/i18n.js.map +1 -1
- package/dist/metro.js +4 -4
- package/dist/metro.js.map +1 -1
- package/dist/output.js +1 -1
- package/dist/output.js.map +1 -1
- package/dist/project.js +29 -29
- package/dist/project.js.map +1 -1
- package/dist/sideload.js +58 -43
- package/dist/sideload.js.map +1 -1
- package/locales/ar.json +109 -106
- package/locales/bg.json +109 -106
- package/locales/bn.json +109 -106
- package/locales/ca.json +109 -106
- package/locales/cs.json +109 -106
- package/locales/da.json +109 -106
- package/locales/de.json +109 -106
- package/locales/el.json +109 -106
- package/locales/es-419.json +109 -106
- package/locales/es.json +109 -106
- package/locales/fi.json +109 -106
- package/locales/fr-CA.json +109 -106
- package/locales/fr.json +109 -106
- package/locales/gu.json +109 -106
- package/locales/he.json +109 -106
- package/locales/hi.json +109 -106
- package/locales/hr.json +109 -106
- package/locales/hu.json +109 -106
- package/locales/id.json +109 -106
- package/locales/it.json +109 -106
- package/locales/ja.json +110 -107
- package/locales/kk.json +109 -106
- package/locales/kn.json +109 -106
- package/locales/ko.json +109 -106
- package/locales/lt.json +109 -106
- package/locales/ml.json +109 -106
- package/locales/mr.json +109 -106
- package/locales/ms.json +109 -106
- package/locales/nb.json +109 -106
- package/locales/nl.json +109 -106
- package/locales/or.json +109 -106
- package/locales/pa.json +109 -106
- package/locales/pl.json +109 -106
- package/locales/pt-BR.json +109 -106
- package/locales/pt-PT.json +109 -106
- package/locales/ro.json +109 -106
- package/locales/ru.json +109 -106
- package/locales/sk.json +109 -106
- package/locales/sl.json +109 -106
- package/locales/sv.json +109 -106
- package/locales/ta.json +109 -106
- package/locales/te.json +109 -106
- package/locales/th.json +109 -106
- package/locales/tr.json +109 -106
- package/locales/uk.json +109 -106
- package/locales/ur.json +109 -106
- package/locales/vi.json +109 -106
- package/locales/zh-HK.json +109 -106
- package/locales/zh-Hans.json +109 -106
- package/locales/zh-Hant.json +109 -106
- package/package.json +4 -4
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 { execFileSync } from \"node:child_process\";\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\";\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 \"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/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].join(\":\");\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 non-empty 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 run time; 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 loading = (name) => {\n const fail = () => {\n throw new Error(\n tr(\n \"{name} is used while extension.js loads; use it inside run or an action\",\n { name },\n ),\n );\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 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/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: () => loading(tr(\"the database\")),\n openDatabaseAsync: () => Promise.resolve(loading(tr(\"the database\"))),\n deserializeDatabaseSync: () => loading(tr(\"the database\")),\n deserializeDatabaseAsync: () =>\n Promise.resolve(loading(tr(\"the 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(\n \"SQLiteProvider renders React, so it works only in the swiplet interface\",\n ),\n );\n },\n useSQLiteContext: () => {\n throw new Error(\n tr(\n \"useSQLiteContext renders React, so it works only in the swiplet interface\",\n ),\n );\n },\n },\n \"expo-sqlite/kv-store\": {\n SQLiteStorage: loading(\"SQLiteStorage\"),\n AsyncStorage: loading(tr(\"the storage\")),\n Storage: loading(tr(\"the storage\")),\n default: loading(tr(\"the 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 is not 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 ...(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 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 execFileSync(\n \"zip\",\n [\"-qr\", \"-n\", storedSuffixes, archive, ...fs.readdirSync(folder)],\n { cwd: folder },\n );\n return { id: manifest.id, archive, digest: folderDigest(folder) };\n}\n\nfunction folderDigest(folder) {\n const hash = createHash(\"sha256\");\n const walk = (directory) => {\n for (const entry of fs\n .readdirSync(directory, { withFileTypes: true })\n .sort((a, b) => (a.name < b.name ? -1 : 1))) {\n const name = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n walk(name);\n } else {\n hash.update(`${path.relative(folder, name)}\\0`);\n hash.update(fs.readFileSync(name));\n hash.update(\"\\0\");\n }\n }\n };\n walk(folder);\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;AACF;AACA,MAAM,mBAAmB;CACvB;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;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,GAAG;AAEV,SAAgB,YAAY,MAAM;CAChC,MAAM,WAAW,KAAK,MACpB,GAAG,aAAa,KAAK,KAAK,MAAM,cAAc,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AAY,MAAM;CAAC,GAChE,EAAE,KAAK,OAAO,CAChB;CACA,OAAO;EAAE,IAAI,SAAS;EAAI;EAAS,QAAQ,aAAa,MAAM;CAAE;AAClE;AAEA,SAAS,aAAa,QAAQ;CAC5B,MAAM,OAAO,WAAW,QAAQ;CAChC,MAAM,QAAQ,cAAc;EAC1B,KAAK,MAAM,SAAS,GACjB,YAAY,WAAW,EAAE,eAAe,KAAK,CAAC,CAAC,CAC/C,MAAM,GAAG,MAAO,EAAE,OAAO,EAAE,OAAO,KAAK,CAAE,GAAG;GAC7C,MAAM,OAAO,KAAK,KAAK,WAAW,MAAM,IAAI;GAC5C,IAAI,MAAM,YAAY,GACpB,KAAK,IAAI;QACJ;IACL,KAAK,OAAO,GAAG,KAAK,SAAS,QAAQ,IAAI,EAAE,GAAG;IAC9C,KAAK,OAAO,GAAG,aAAa,IAAI,CAAC;IACjC,KAAK,OAAO,IAAI;GAClB;EACF;CACF;CACA,KAAK,MAAM;CACX,OAAO,KAAK,OAAO,KAAK;AAC1B"}
|
|
1
|
+
{"version":3,"file":"project.js","names":[],"sources":["../src/project.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { execFileSync } from \"node:child_process\";\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\";\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 \"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/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].join(\":\");\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 loading = (name) => {\n const fail = () => {\n throw new Error(\n tr(\n \"{name} is used while extension.js loads; use it inside run or an action.\",\n { name },\n ),\n );\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 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/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: () => loading(tr(\"The database\")),\n openDatabaseAsync: () => Promise.resolve(loading(tr(\"The database\"))),\n deserializeDatabaseSync: () => loading(tr(\"The database\")),\n deserializeDatabaseAsync: () =>\n Promise.resolve(loading(tr(\"The 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(\n \"SQLiteProvider renders React, so it works only in the swiplet interface.\",\n ),\n );\n },\n useSQLiteContext: () => {\n throw new Error(\n tr(\n \"useSQLiteContext renders React, so it works only in the swiplet interface.\",\n ),\n );\n },\n },\n \"expo-sqlite/kv-store\": {\n SQLiteStorage: loading(\"SQLiteStorage\"),\n AsyncStorage: loading(tr(\"The storage\")),\n Storage: loading(tr(\"The storage\")),\n default: loading(tr(\"The 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 ...(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 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 execFileSync(\n \"zip\",\n [\"-qr\", \"-n\", storedSuffixes, archive, ...fs.readdirSync(folder)],\n { cwd: folder },\n );\n return { id: manifest.id, archive, digest: folderDigest(folder) };\n}\n\nfunction folderDigest(folder) {\n const hash = createHash(\"sha256\");\n const walk = (directory) => {\n for (const entry of fs\n .readdirSync(directory, { withFileTypes: true })\n .sort((a, b) => (a.name < b.name ? -1 : 1))) {\n const name = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n walk(name);\n } else {\n hash.update(`${path.relative(folder, name)}\\0`);\n hash.update(fs.readFileSync(name));\n hash.update(\"\\0\");\n }\n }\n };\n walk(folder);\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;AACF;AACA,MAAM,mBAAmB;CACvB;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;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,GAAG;AAEV,SAAgB,YAAY,MAAM;CAChC,MAAM,WAAW,KAAK,MACpB,GAAG,aAAa,KAAK,KAAK,MAAM,cAAc,GAAG,MAAM,CACzD;CACA,MAAM,SAAS,SAAS,WAAW,CAAC;CACpC,IAAI,OAAO,OAAO,OAAO,YAAY,CAAC,UAAU,KAAK,OAAO,EAAE,GAC5D,MAAM,IAAI,MACR,GACE,6IACF,CACF;CAEF,IAAI,OAAO,OAAO,SAAS,YAAY,OAAO,SAAS,IACrD,MAAM,IAAI,MACR,GAAG,6DAA2D,CAChE;CAEF,MAAM,iBAAiB,OAAO,kBAAkB,CAAC;CACjD,IACE,mBAAmB,QACnB,OAAO,mBAAmB,YAC1B,CAAC,OAAO,OAAO,cAAc,CAAC,CAAC,OAAO,SAAS,OAAO,SAAS,QAAQ,GAEvE,MAAM,IA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KAAK,IAAI;QACJ;IACL,KAAK,OAAO,GAAG,KAAK,SAAS,QAAQ,IAAI,EAAE,GAAG;IAC9C,KAAK,OAAO,GAAG,aAAa,IAAI,CAAC;IACjC,KAAK,OAAO,IAAI;GAClB;EACF;CACF;CACA,KAAK,MAAM;CACX,OAAO,KAAK,OAAO,KAAK;AAC1B"}
|
package/dist/sideload.js
CHANGED
|
@@ -56,16 +56,16 @@ const passcodeTypes = [
|
|
|
56
56
|
const plistValueMissing = /No value at that key path/;
|
|
57
57
|
function passcodeOf(options) {
|
|
58
58
|
const type = options["passcode-type"] ?? "pin";
|
|
59
|
-
if (!passcodeTypes.includes(type)) throw new UsageError(tr("invalid argument {value} for --passcode-type: it
|
|
59
|
+
if (!passcodeTypes.includes(type)) throw new UsageError(tr("invalid argument {value} for --passcode-type: it's {types}", {
|
|
60
60
|
value: JSON.stringify(type),
|
|
61
61
|
types: passcodeTypes.join(", ")
|
|
62
62
|
}));
|
|
63
63
|
const passcode = options.passcode;
|
|
64
64
|
if (!passcode) return;
|
|
65
65
|
const digits = /^\d+$/.test(passcode);
|
|
66
|
-
if (type === "pin" && !(digits && [4, 6].includes(passcode.length))) throw new UsageError(tr("
|
|
67
|
-
if (type === "numeric" && !digits) throw new UsageError(tr("
|
|
68
|
-
if (!/^[\x20-\x7e]{1,64}$/.test(passcode)) throw new UsageError(tr("
|
|
66
|
+
if (type === "pin" && !(digits && [4, 6].includes(passcode.length))) throw new UsageError(tr("A pin passcode is 4 or 6 digits; a custom one needs --passcode-type numeric or alphanumeric"));
|
|
67
|
+
if (type === "numeric" && !digits) throw new UsageError(tr("A numeric passcode is digits only."));
|
|
68
|
+
if (!/^[\x20-\x7e]{1,64}$/.test(passcode)) throw new UsageError(tr("A passcode is up to 64 printable ASCII characters."));
|
|
69
69
|
return {
|
|
70
70
|
passcode,
|
|
71
71
|
type
|
|
@@ -202,11 +202,11 @@ const pbxproj = (id, team) => `// !$*UTF8*$!
|
|
|
202
202
|
`;
|
|
203
203
|
function explain(output, team) {
|
|
204
204
|
const errors = [...new Set(output.split("\n").filter((line) => /^(xcodebuild: )?error: /.test(line)).map((line) => line.replace(/^(xcodebuild: )?error: /, "")))].join("; ");
|
|
205
|
-
if (/No Accounts?\b/.test(output)) return tr("Xcode has no account for team {team}; sign in
|
|
205
|
+
if (/No Accounts?\b/.test(output)) return tr("Xcode has no account for team {team}; sign in to its Apple Account at {accounts}.", {
|
|
206
206
|
team,
|
|
207
207
|
accounts: accountsHint
|
|
208
208
|
});
|
|
209
|
-
if (/signing certificate|certificateType/i.test(output)) return tr("Xcode
|
|
209
|
+
if (/signing certificate|certificateType/i.test(output)) return tr("Xcode couldn't make a development certificate for team {team}; add one at {accounts} › Manage Certificates ({errors}).", {
|
|
210
210
|
team,
|
|
211
211
|
accounts: accountsHint,
|
|
212
212
|
errors
|
|
@@ -297,7 +297,7 @@ async function provision(work, id, team, device, update) {
|
|
|
297
297
|
try {
|
|
298
298
|
await running;
|
|
299
299
|
} catch (error) {
|
|
300
|
-
if (error.code === "ENOENT") throw new Error(tr("xcodebuild is missing; install Xcode"));
|
|
300
|
+
if (error.code === "ENOENT") throw new Error(tr("xcodebuild is missing; install Xcode."));
|
|
301
301
|
if (typeof error.code !== "number") throw error;
|
|
302
302
|
throw new Error(explain(`${error.stdout}${error.stderr}`, team));
|
|
303
303
|
}
|
|
@@ -446,7 +446,7 @@ const teamChoice = ({ id, name }) => ({
|
|
|
446
446
|
short: name ?? id,
|
|
447
447
|
value: id
|
|
448
448
|
});
|
|
449
|
-
async function sideloadedDevices(devices, missing = tr("Swipt
|
|
449
|
+
async function sideloadedDevices(devices, missing = tr("Swipt isn't sideloaded on any online iPhone or iPad.")) {
|
|
450
450
|
const sideloaded = await step(tr("looking for Swipt on the devices"), () => Promise.all(devices.map((device) => apps(device).then((listed) => listed.some((app) => sideloadedPattern.test(app.bundleIdentifier)), () => true))), { transient: true });
|
|
451
451
|
const found = devices.filter((_, index) => sideloaded[index]);
|
|
452
452
|
if (found.length === 0) throw new Error(missing);
|
|
@@ -464,7 +464,7 @@ async function locate(context, device, fresh = false) {
|
|
|
464
464
|
};
|
|
465
465
|
}).filter((app) => app.team !== null);
|
|
466
466
|
if (options.team !== void 0) {
|
|
467
|
-
if (!teamPattern.test(options.team)) throw new UsageError(tr("invalid argument {value} for --team: it
|
|
467
|
+
if (!teamPattern.test(options.team)) throw new UsageError(tr("invalid argument {value} for --team: it's the 10-character team ID shown in {accounts}", {
|
|
468
468
|
value: JSON.stringify(options.team),
|
|
469
469
|
accounts: accountsHint
|
|
470
470
|
}));
|
|
@@ -489,7 +489,7 @@ async function locate(context, device, fresh = false) {
|
|
|
489
489
|
const teams = xcodeTeams();
|
|
490
490
|
if (teams.length === 0) throw new Error(xcodeSignedIn() ? tr("Xcode has no development certificate; add one at {accounts} › Manage Certificates, or choose a team with --team ID", { accounts: accountsHint }) : tr("Xcode has no account; sign in at {accounts}, or choose a team with --team ID", { accounts: accountsHint }));
|
|
491
491
|
return {
|
|
492
|
-
team: teams.some((it) => it.id === bundleTeam) ? bundleTeam : teams.length === 1 ? teams[0].id : await choose(context, tr("Choose a team"), teams.map(teamChoice), /* @__PURE__ */ new Error(`${tr("
|
|
492
|
+
team: teams.some((it) => it.id === bundleTeam) ? bundleTeam : teams.length === 1 ? teams[0].id : await choose(context, tr("Choose a team"), teams.map(teamChoice), /* @__PURE__ */ new Error(`${tr("Choose a team with --team ID:")}\n${teamList(teams)}`)),
|
|
493
493
|
current: void 0
|
|
494
494
|
};
|
|
495
495
|
}
|
|
@@ -517,7 +517,7 @@ function expirationText(time) {
|
|
|
517
517
|
}
|
|
518
518
|
async function askPasscode(context) {
|
|
519
519
|
const type = await select({
|
|
520
|
-
message: tr("Set up auto-unlock? Swipt can then unlock this device by itself"),
|
|
520
|
+
message: tr("Set up auto-unlock? Swipt can then unlock this device by itself."),
|
|
521
521
|
theme: selectTheme,
|
|
522
522
|
choices: [
|
|
523
523
|
{
|
|
@@ -555,7 +555,7 @@ async function askPasscode(context) {
|
|
|
555
555
|
validate(passcode) {
|
|
556
556
|
try {
|
|
557
557
|
passcodeOf(options(passcode));
|
|
558
|
-
return passcode !== "" || tr("
|
|
558
|
+
return passcode !== "" || tr("Enter the passcode.");
|
|
559
559
|
} catch (error) {
|
|
560
560
|
return error.message;
|
|
561
561
|
}
|
|
@@ -569,9 +569,9 @@ async function installPasscode(context, device, current) {
|
|
|
569
569
|
return current === void 0 && !device.virtual && interactive(context) && context.options.passcode === void 0 && context.options["passcode-type"] === void 0 && !context.options["no-setup"] ? askPasscode(context) : passcodeOf(context.options);
|
|
570
570
|
}
|
|
571
571
|
async function findInstalled(context) {
|
|
572
|
-
const device = await coreDevice(context, { filter: (devices) => sideloadedDevices(devices, tr("Swipt
|
|
572
|
+
const device = await coreDevice(context, { filter: (devices) => sideloadedDevices(devices, tr("Swipt isn't sideloaded on any online iPhone or iPad; install it with \"swipt sideload install\".")) });
|
|
573
573
|
const { team, current } = await locate(context, device);
|
|
574
|
-
if (current === void 0) throw new Error(team === void 0 ? tr("Swipt
|
|
574
|
+
if (current === void 0) throw new Error(team === void 0 ? tr("Swipt isn't sideloaded on {device}; install it with \"swipt sideload install\".", { device: device.name }) : tr("Swipt isn't sideloaded on {device} by team {team}; install it with \"swipt sideload install\".", {
|
|
575
575
|
device: device.name,
|
|
576
576
|
team
|
|
577
577
|
}));
|
|
@@ -630,7 +630,7 @@ async function mountDiskImage(context, device, app) {
|
|
|
630
630
|
}, { transient: true });
|
|
631
631
|
} catch (error) {
|
|
632
632
|
if (context.signal.aborted) throw error;
|
|
633
|
-
console.error(tr("
|
|
633
|
+
console.error(tr("couldn't prepare the Developer Disk Image on {device}: {error}", {
|
|
634
634
|
device: device.name,
|
|
635
635
|
error: /^Error: (.*)$/m.exec(error.stderr ?? "")?.[1] ?? error.message
|
|
636
636
|
}));
|
|
@@ -643,15 +643,35 @@ async function deploy(context, { device, team, current }, updateOnly) {
|
|
|
643
643
|
if (current !== void 0) {
|
|
644
644
|
const installed = Number(current.bundleVersion);
|
|
645
645
|
const signing = device.virtual ? void 0 : await signingPeriod(device, id, team);
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
646
|
+
const parameters = {
|
|
647
|
+
build: buildText(current),
|
|
648
|
+
device: device.name,
|
|
649
|
+
release: release.tag,
|
|
650
|
+
releaseBuild: release.build
|
|
651
|
+
};
|
|
652
|
+
const asks = !updateOnly && !context.options.force && installed > release.build && interactive(context);
|
|
653
|
+
if (installed >= release.build && !asks) console.log(installed === release.build ? tr("{build} on {device} is already {release}.", parameters) : tr("{build} on {device} is later than {release} ({releaseBuild}).", parameters));
|
|
654
|
+
const versions = {
|
|
655
|
+
device: device.name,
|
|
656
|
+
version: `${current.version} (${current.bundleVersion})`,
|
|
657
|
+
releaseVersion: `${release.version} (${release.build})`
|
|
658
|
+
};
|
|
659
|
+
const replaces = asks ? await select({
|
|
660
|
+
message: release.tag === "nightly" ? tr("Downgrade Swipt on {device} from {version} to {releaseVersion}? Swipt resets its data when the earlier version can't read it.", versions) : tr("Downgrade Swipt on {device} from nightly {version} to stable {releaseVersion}? Swipt resets its data when the earlier version can't read it.", versions),
|
|
661
|
+
theme: selectTheme,
|
|
662
|
+
choices: [{
|
|
663
|
+
name: tr("Downgrade"),
|
|
664
|
+
value: true
|
|
665
|
+
}, {
|
|
666
|
+
name: tr("No Thanks"),
|
|
667
|
+
value: false
|
|
668
|
+
}]
|
|
669
|
+
}, {
|
|
670
|
+
output: process.stderr,
|
|
671
|
+
signal: context.signal
|
|
672
|
+
}) : !updateOnly && context.options.force;
|
|
673
|
+
if (!replaces && installed >= release.build && (signing === void 0 || !expiresSoon(signing))) {
|
|
674
|
+
if (signing !== void 0) console.log(tr("Its signing expires {expiration}.", { expiration: expirationText(signing.expiration) }));
|
|
655
675
|
const saves = !updateOnly && passcode !== void 0;
|
|
656
676
|
const pairs = !context.options["no-setup"] && !context.options["no-setup-pair"] && !await step(tr("checking Swipt on {device}", { device: device.name }), () => containerHasFile(device, id, pairingPath), { transient: true });
|
|
657
677
|
if (!saves && !pairs) return;
|
|
@@ -667,12 +687,7 @@ async function deploy(context, { device, team, current }, updateOnly) {
|
|
|
667
687
|
});
|
|
668
688
|
return;
|
|
669
689
|
}
|
|
670
|
-
if (installed > release.build
|
|
671
|
-
build: buildText(current),
|
|
672
|
-
device: device.name,
|
|
673
|
-
release: release.tag,
|
|
674
|
-
releaseBuild: release.build
|
|
675
|
-
}));
|
|
690
|
+
if (!replaces && installed > release.build) throw new Error(tr("{build} on {device} needs new signing, but {release} ({releaseBuild}) is earlier; use --nightly, or downgrade with \"swipt sideload install --force\".", parameters));
|
|
676
691
|
}
|
|
677
692
|
const work = fs.mkdtempSync(path.join(os.tmpdir(), "swipt-sideload-"));
|
|
678
693
|
try {
|
|
@@ -747,8 +762,8 @@ async function installAndOpen(context, { device, id, current }, app, build, { pa
|
|
|
747
762
|
build: buildText(result),
|
|
748
763
|
device: device.name
|
|
749
764
|
};
|
|
750
|
-
console.log(current
|
|
751
|
-
if (!device.virtual) console.log(tr("
|
|
765
|
+
console.log(current !== void 0 && Number(current.bundleVersion) < build ? tr("{build} is updated on {device}.", parameters) : tr("{build} is installed on {device}.", parameters));
|
|
766
|
+
if (!device.virtual) console.log(tr("Its signing expires {expiration}.", { expiration: expirationText(Date.parse(profileField(path.join(app, "embedded.mobileprovision"), "ExpirationDate"))) }));
|
|
752
767
|
if (context.options["no-setup"]) {
|
|
753
768
|
await launch(device, id);
|
|
754
769
|
return;
|
|
@@ -761,7 +776,7 @@ const setupArgument = "--setup";
|
|
|
761
776
|
async function printAPI(context, device) {
|
|
762
777
|
const found = await step(tr("checking Swipt on {device}", { device: device.name }), () => findPublished(device.name, context.signal), { transient: true });
|
|
763
778
|
if (found === void 0) {
|
|
764
|
-
console.error(tr("{device}
|
|
779
|
+
console.error(tr("{device} wasn't found on the local network; find its API URLs in Swipt › Developer › Local Network.", { device: device.name }));
|
|
765
780
|
return;
|
|
766
781
|
}
|
|
767
782
|
const url = found.authenticates ? withToken(found.url) : found.url;
|
|
@@ -781,7 +796,7 @@ async function openConfigured(context, device, id, passcode, updated, app) {
|
|
|
781
796
|
await trustAndOpen(context, device, id, passcode, updated, path.join(app, "DeveloperDiskImage"));
|
|
782
797
|
} catch (error) {
|
|
783
798
|
if (error.message !== serverHint) throw error;
|
|
784
|
-
console.error(tr("{hint}; its developer
|
|
799
|
+
console.error(tr("{hint}; its developer isn't trusted automatically.", { hint: serverHint }));
|
|
785
800
|
if (!await launch(device, id, publishes ? [publishArgument] : [])) return;
|
|
786
801
|
}
|
|
787
802
|
if (publishes) await printAPI(context, device);
|
|
@@ -802,8 +817,8 @@ async function launch(device, id, args) {
|
|
|
802
817
|
"prefs:root=General&path=ManagedConfigurationList",
|
|
803
818
|
"com.apple.Preferences"
|
|
804
819
|
]));
|
|
805
|
-
console.log(tr("
|
|
806
|
-
} else if (lockedError.test(error.message)) console.log(tr("
|
|
820
|
+
console.log(tr("Its developer isn't trusted yet; trust it in the Settings page opened on {device}, then open Swipt.", { device: device.name }));
|
|
821
|
+
} else if (lockedError.test(error.message)) console.log(tr("It opens after {device} is unlocked.", { device: device.name }));
|
|
807
822
|
else throw error;
|
|
808
823
|
return false;
|
|
809
824
|
}
|
|
@@ -831,11 +846,11 @@ async function setup(context) {
|
|
|
831
846
|
});
|
|
832
847
|
}
|
|
833
848
|
const trustMessages = JSON.stringify({
|
|
834
|
-
unlockToContinue: tr("
|
|
849
|
+
unlockToContinue: tr("Unlock the device to continue."),
|
|
835
850
|
unlocking: tr("unlocking the device"),
|
|
836
851
|
trusting: tr("trusting {developer} in Settings", { developer: "{developer}" }),
|
|
837
|
-
running: tr("{app} is running", { app: "{app}" }),
|
|
838
|
-
trusted: tr("{developer} is trusted", { developer: "{developer}" })
|
|
852
|
+
running: tr("{app} is running.", { app: "{app}" }),
|
|
853
|
+
trusted: tr("{developer} is trusted.", { developer: "{developer}" })
|
|
839
854
|
});
|
|
840
855
|
const deviceNotListedExit = 3;
|
|
841
856
|
const schema = [
|
|
@@ -913,8 +928,8 @@ async function pair(device, id, overwrite = false) {
|
|
|
913
928
|
record
|
|
914
929
|
]);
|
|
915
930
|
} catch (error) {
|
|
916
|
-
if (typeof error.code === "number") warning = tr("
|
|
917
|
-
else if (error.code === "ENOENT") warning = tr("{hint}; Swipt pairs in Settings instead", { hint: serverHint });
|
|
931
|
+
if (typeof error.code === "number") warning = tr("Pairing failed, so Swipt pairs in Settings instead: {error}", { error: error.stderr.trim() });
|
|
932
|
+
else if (error.code === "ENOENT") warning = tr("{hint}; Swipt pairs in Settings instead.", { hint: serverHint });
|
|
918
933
|
throw error;
|
|
919
934
|
}
|
|
920
935
|
await pushToContainer(device, id, record, pairingPath);
|
|
@@ -1073,7 +1088,7 @@ async function trustAndOpen(context, device, id, given, updated, diskImage) {
|
|
|
1073
1088
|
for (const output of lines) (output.level === 1 || output.level === 2 ? console.error : console.log)(output.text);
|
|
1074
1089
|
}
|
|
1075
1090
|
if (failure) {
|
|
1076
|
-
if (passcode === void 0 && failure.name === "UnavailableError" && /\bdevice is locked\b/.test(failure.message)) throw new Error(tr("{device}: {message}; unlock it or pass --passcode, then run this again", {
|
|
1091
|
+
if (passcode === void 0 && failure.name === "UnavailableError" && /\bdevice is locked\b/.test(failure.message)) throw new Error(tr("{device}: {message}; unlock it or pass --passcode, then run this again.", {
|
|
1077
1092
|
device: device.name,
|
|
1078
1093
|
message: failure.message
|
|
1079
1094
|
}));
|
|
@@ -1083,7 +1098,7 @@ async function trustAndOpen(context, device, id, given, updated, diskImage) {
|
|
|
1083
1098
|
async function uninstall(context) {
|
|
1084
1099
|
const device = await coreDevice(context, { filter: sideloadedDevices });
|
|
1085
1100
|
const { team, current } = await locate(context, device);
|
|
1086
|
-
if (current === void 0) throw new Error(team === void 0 ? tr("Swipt
|
|
1101
|
+
if (current === void 0) throw new Error(team === void 0 ? tr("Swipt isn't sideloaded on {device}.", { device: device.name }) : tr("Swipt isn't sideloaded on {device} by team {team}.", {
|
|
1087
1102
|
device: device.name,
|
|
1088
1103
|
team
|
|
1089
1104
|
}));
|