@mirinjs/cli 0.0.1-alpha.17 → 0.0.1-alpha.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirinjs/cli",
3
- "version": "0.0.1-alpha.17",
3
+ "version": "0.0.1-alpha.18",
4
4
  "description": "CLI for mirin apps: dev, build, init.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -27,11 +27,11 @@
27
27
  "bun": ">=1.2.0"
28
28
  },
29
29
  "dependencies": {
30
- "create-mirinjs": "0.0.1-alpha.17",
31
- "mirinjs": "0.0.1-alpha.17"
30
+ "create-mirinjs": "0.0.1-alpha.18",
31
+ "mirinjs": "0.0.1-alpha.18"
32
32
  },
33
33
  "optionalDependencies": {
34
- "@mirinjs/darwin-arm64": "0.0.1-alpha.17"
34
+ "@mirinjs/darwin-arm64": "0.0.1-alpha.18"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"
package/src/build.ts CHANGED
@@ -111,6 +111,7 @@ export async function build(projectDir = process.cwd()): Promise<BuildResult> {
111
111
  version,
112
112
  icon: config.icon ? join(projectDir, config.icon) : undefined,
113
113
  signIdentity,
114
+ urlSchemes: config.urlSchemes,
114
115
  resources: {
115
116
  uiDir: join(projectDir, "dist"),
116
117
  workerJs,
package/src/bundle.ts CHANGED
@@ -39,6 +39,8 @@ export interface BundleOptions {
39
39
  icon?: string;
40
40
  /** Codesign identity; "-" (default) is ad-hoc. Set to a Developer ID to ship. */
41
41
  signIdentity?: string;
42
+ /** Custom URL schemes -> Info.plist CFBundleURLTypes (deep links). */
43
+ urlSchemes?: string[];
42
44
  /** Production-only resources placed under Contents/Resources. */
43
45
  resources?: {
44
46
  uiDir?: string; // Vite dist/, copied to Resources/ui (served via app://ui)
@@ -126,14 +128,18 @@ async function writeIcon(iconSrc: string, resources: string): Promise<string | u
126
128
  return "icon";
127
129
  }
128
130
 
129
- type PlistValue = string | boolean | Record<string, string>;
131
+ type PlistValue = string | boolean | PlistValue[] | { [k: string]: PlistValue };
132
+
133
+ const xmlEscape = (s: string) =>
134
+ s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
130
135
 
131
136
  function plist(entries: Record<string, PlistValue>): string {
132
137
  const render = (v: PlistValue): string => {
133
138
  if (typeof v === "boolean") return v ? "<true/>" : "<false/>";
134
- if (typeof v === "string") return `<string>${v}</string>`;
139
+ if (typeof v === "string") return `<string>${xmlEscape(v)}</string>`;
140
+ if (Array.isArray(v)) return `<array>${v.map(render).join("")}</array>`;
135
141
  const inner = Object.entries(v)
136
- .map(([k, val]) => `<key>${k}</key><string>${val}</string>`)
142
+ .map(([k, val]) => `<key>${k}</key>${render(val)}`)
137
143
  .join("");
138
144
  return `<dict>${inner}</dict>`;
139
145
  };
@@ -192,6 +198,13 @@ export async function buildAppBundle(opts: BundleOptions): Promise<{ app: string
192
198
  LSEnvironment: { MallocNanoZone: "0" },
193
199
  };
194
200
  if (iconFile) info.CFBundleIconFile = iconFile;
201
+ // Deep-link schemes: register this app as the macOS handler for app://-style
202
+ // URLs (e.g. anko://…). Delivered at runtime via app.on("open-url").
203
+ if (opts.urlSchemes?.length) {
204
+ info.CFBundleURLTypes = [
205
+ { CFBundleURLName: bundleId, CFBundleURLSchemes: opts.urlSchemes },
206
+ ];
207
+ }
195
208
 
196
209
  writeFileSync(join(contents, "Info.plist"), plist(info));
197
210
 
package/src/dev.ts CHANGED
@@ -68,6 +68,7 @@ export async function dev(projectDir = process.cwd()): Promise<number> {
68
68
  helperBin: artifacts.helperBin,
69
69
  cefPath: artifacts.cefPath,
70
70
  icon: config.icon ? join(projectDir, config.icon) : undefined,
71
+ urlSchemes: config.urlSchemes,
71
72
  });
72
73
 
73
74
  // --- start Vite on a free port so concurrent dev sessions don't collide ---