@skyvexsoftware/stratos-sdk 0.1.12 → 0.1.14

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.
@@ -15,6 +15,12 @@ import { execSync } from "child_process";
15
15
  import * as https from "https";
16
16
  import * as http from "http";
17
17
  const API_BASE = "https://skyvexsoftware.com/api/stratos";
18
+ // ── CLI flags ───────────────────────────────────────────────────────
19
+ const releaseModeArg = process.argv.find((a) => a.startsWith("--release-mode="));
20
+ const releaseMode = releaseModeArg?.split("=")[1] ?? "automatic";
21
+ if (releaseMode !== "automatic" && releaseMode !== "manual") {
22
+ fatal("--release-mode must be 'automatic' or 'manual'");
23
+ }
18
24
  // ── Helpers ──────────────────────────────────────────────────────────
19
25
  function fatal(message) {
20
26
  console.error(`\n Error: ${message}\n`);
@@ -67,17 +73,18 @@ function createBundle(cwd) {
67
73
  return bundlePath;
68
74
  }
69
75
  // ── Upload ───────────────────────────────────────────────────────────
70
- function upload(pluginId, version, bundlePath, token) {
76
+ function upload(pluginId, bundlePath, token) {
71
77
  return new Promise((resolve) => {
72
78
  const boundary = `----StratosDeploy${Date.now()}`;
73
79
  const fileContent = fs.readFileSync(bundlePath);
74
80
  const parts = [];
75
- // Version field
76
- parts.push(Buffer.from(`--${boundary}\r\nContent-Disposition: form-data; name="version"\r\n\r\n${version}\r\n`));
77
- // File field
81
+ // File field (version is extracted from plugin.json inside the zip server-side)
78
82
  parts.push(Buffer.from(`--${boundary}\r\nContent-Disposition: form-data; name="file"; filename="bundle.zip"\r\nContent-Type: application/zip\r\n\r\n`));
79
83
  parts.push(fileContent);
80
- parts.push(Buffer.from(`\r\n--${boundary}--\r\n`));
84
+ parts.push(Buffer.from("\r\n"));
85
+ // Release mode field
86
+ parts.push(Buffer.from(`--${boundary}\r\nContent-Disposition: form-data; name="release_mode"\r\n\r\n${releaseMode}\r\n`));
87
+ parts.push(Buffer.from(`--${boundary}--\r\n`));
81
88
  const body = Buffer.concat(parts);
82
89
  const url = new URL(`${API_BASE}/plugins/${pluginId}/versions`);
83
90
  const options = {
@@ -114,10 +121,11 @@ async function main() {
114
121
  const bundlePath = createBundle(cwd);
115
122
  const bundleSize = fs.statSync(bundlePath).size;
116
123
  console.log(`\n ${name} v${version} — bundle.zip (${formatSize(bundleSize)})`);
124
+ console.log(` Release mode: ${releaseMode}`);
117
125
  const token = process.env.SKYVEX_API_TOKEN;
118
126
  if (token) {
119
127
  console.log(" Uploading to Skyvex...");
120
- const result = await upload(id, version, bundlePath, token);
128
+ const result = await upload(id, bundlePath, token);
121
129
  if (result.ok) {
122
130
  console.log(" Published! Server is signing and publishing to CDN.\n");
123
131
  fs.unlinkSync(bundlePath);
@@ -38,5 +38,7 @@ export type PluginManifest = {
38
38
  icon_dark: string;
39
39
  /** Typed settings this plugin declares. User-scoped settings render in the Settings page; airline-scoped settings are managed by the VA platform. */
40
40
  availableSettings?: PluginSettingDefinition[];
41
+ /** Whether to include source maps in the published CDN bundle. Defaults to false — source maps are stripped on approval. Set to true if you want end users to have access to source maps for debugging. */
42
+ includeSourceMaps?: boolean;
41
43
  };
42
44
  //# sourceMappingURL=manifest.d.ts.map
@@ -17,6 +17,7 @@
17
17
  */
18
18
  import * as fs from "fs";
19
19
  import * as path from "path";
20
+ import MagicString from "magic-string";
20
21
  import { UI_EXTERNALS } from "./externals.js";
21
22
  import { serveExternals } from "./serve-externals.js";
22
23
  import { stratosDevServer } from "./stratos-dev-server.js";
@@ -63,49 +64,84 @@ function stratosExternals() {
63
64
  return {
64
65
  name: "stratos-externals",
65
66
  renderChunk(code) {
66
- let result = code;
67
+ const s = new MagicString(code);
67
68
  for (const modId of UI_EXTERNALS) {
68
69
  const escaped = modId.replace(/[-/\\^$*+?.()|[\]{}@]/g, "\\$&");
69
70
  const global = `window.__stratos_modules__[${JSON.stringify(modId)}]`;
70
- // 1. import Default, { named as alias } from 'mod';
71
- // Note: [\w$]+ handles Rollup's conflict-resolution names like Map$1
72
- result = result.replace(new RegExp(`import\\s+([\\w$]+)\\s*,\\s*\\{([^}]+)\\}\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, def, names) => {
73
- const destructured = names.replace(/([\w$]+)\s+as\s+([\w$]+)/g, "$1: $2");
74
- return `const ${def} = ${global}.default || ${global};\nconst {${destructured}} = ${global};`;
75
- });
76
- // 2. import { named as alias } from 'mod';
77
- result = result.replace(new RegExp(`import\\s*\\{([^}]+)\\}\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, names) => {
78
- const destructured = names.replace(/([\w$]+)\s+as\s+([\w$]+)/g, "$1: $2");
79
- return `const {${destructured}} = ${global};`;
80
- });
81
- // 3. import * as ns from 'mod';
82
- result = result.replace(new RegExp(`import\\s+\\*\\s+as\\s+([\\w$]+)\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, name) => `const ${name} = ${global};`);
83
- // 4. import Default from 'mod';
84
- result = result.replace(new RegExp(`import\\s+([\\w$]+)\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, def) => `const ${def} = ${global}.default || ${global};`);
85
- // 5. import 'mod'; (side effect only)
86
- result = result.replace(new RegExp(`import\\s+['"]${escaped}['"]\\s*;?`, "g"), "");
87
- // 6. export { name } from 'mod'; (re-export)
88
- result = result.replace(new RegExp(`export\\s*\\{([^}]+)\\}\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, names) => {
89
- const parts = names.split(",").map((n) => n.trim());
90
- const decls = [];
91
- const exportNames = [];
92
- for (const part of parts) {
93
- const asMatch = part.match(/^([\w$]+)\s+as\s+([\w$]+)$/);
94
- if (asMatch) {
95
- decls.push(`const ${asMatch[2]} = ${global}[${JSON.stringify(asMatch[1])}];`);
96
- exportNames.push(asMatch[2]);
97
- }
98
- else {
99
- exportNames.push(part);
100
- }
71
+ const patterns = [
72
+ // 1. import Default, { named } from 'mod';
73
+ [
74
+ new RegExp(`import\\s+([\\w$]+)\\s*,\\s*\\{([^}]+)\\}\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"),
75
+ (_, def, names) => {
76
+ const destructured = names.replace(/([\w$]+)\s+as\s+([\w$]+)/g, "$1: $2");
77
+ return `const ${def} = ${global}.default || ${global};\nconst {${destructured}} = ${global};`;
78
+ },
79
+ ],
80
+ // 2. import { named } from 'mod';
81
+ [
82
+ new RegExp(`import\\s*\\{([^}]+)\\}\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"),
83
+ (_, names) => {
84
+ const destructured = names.replace(/([\w$]+)\s+as\s+([\w$]+)/g, "$1: $2");
85
+ return `const {${destructured}} = ${global};`;
86
+ },
87
+ ],
88
+ // 3. import * as ns from 'mod';
89
+ [
90
+ new RegExp(`import\\s+\\*\\s+as\\s+([\\w$]+)\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"),
91
+ (_, name) => `const ${name} = ${global};`,
92
+ ],
93
+ // 4. import Default from 'mod';
94
+ [
95
+ new RegExp(`import\\s+([\\w$]+)\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"),
96
+ (_, def) => `const ${def} = ${global}.default || ${global};`,
97
+ ],
98
+ // 5. import 'mod';
99
+ [new RegExp(`import\\s+['"]${escaped}['"]\\s*;?`, "g"), () => ""],
100
+ // 6. export { name } from 'mod';
101
+ [
102
+ new RegExp(`export\\s*\\{([^}]+)\\}\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"),
103
+ (_, names) => {
104
+ const parts = names.split(",").map((n) => n.trim());
105
+ const decls = [];
106
+ const exportNames = [];
107
+ for (const part of parts) {
108
+ const asMatch = part.match(/^([\w$]+)\s+as\s+([\w$]+)$/);
109
+ if (asMatch) {
110
+ decls.push(`const ${asMatch[2]} = ${global}[${JSON.stringify(asMatch[1])}];`);
111
+ exportNames.push(asMatch[2]);
112
+ }
113
+ else {
114
+ exportNames.push(part);
115
+ }
116
+ }
117
+ if (decls.length > 0) {
118
+ return `${decls.join("\n")}\nconst {${exportNames.join(", ")}} = ${global};\nexport {${exportNames.join(", ")}};`;
119
+ }
120
+ return `const {${exportNames.join(", ")}} = ${global};\nexport {${exportNames.join(", ")}};`;
121
+ },
122
+ ],
123
+ ];
124
+ // Collect all matches first, then apply in reverse order to preserve offsets
125
+ const matches = [];
126
+ for (const [re, replacer] of patterns) {
127
+ re.lastIndex = 0;
128
+ let match;
129
+ while ((match = re.exec(code)) !== null) {
130
+ matches.push({
131
+ start: match.index,
132
+ end: match.index + match[0].length,
133
+ replacement: replacer(match[0], ...match.slice(1)),
134
+ });
101
135
  }
102
- if (decls.length > 0) {
103
- return `${decls.join("\n")}\nconst {${exportNames.join(", ")}} = ${global};\nexport {${exportNames.join(", ")}};`;
104
- }
105
- return `const {${exportNames.join(", ")}} = ${global};\nexport {${exportNames.join(", ")}};`;
106
- });
136
+ }
137
+ // Apply in reverse so earlier offsets stay valid
138
+ matches
139
+ .sort((a, b) => b.start - a.start)
140
+ .forEach((m) => s.overwrite(m.start, m.end, m.replacement));
107
141
  }
108
- return result;
142
+ if (!s.hasChanged())
143
+ return null;
144
+ return { code: s.toString(), map: s.generateMap({ hires: true }) };
109
145
  },
110
146
  };
111
147
  }
@@ -203,7 +239,7 @@ function createUIConfig(pluginDir, entry, extraConfig) {
203
239
  rollupOptions: {
204
240
  external: [...UI_EXTERNALS],
205
241
  },
206
- sourcemap: !isProduction,
242
+ sourcemap: true,
207
243
  minify: isProduction ? "esbuild" : false,
208
244
  },
209
245
  esbuild: {
@@ -247,7 +283,7 @@ function createBackgroundConfig(pluginDir, entry) {
247
283
  return false;
248
284
  },
249
285
  },
250
- sourcemap: !isProduction,
286
+ sourcemap: true,
251
287
  minify: false,
252
288
  },
253
289
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyvexsoftware/stratos-sdk",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Plugin SDK for Stratos — types, hooks, and UI components",
5
5
  "author": {
6
6
  "name": "Skyvex Software",
@@ -84,6 +84,7 @@
84
84
  },
85
85
  "dependencies": {
86
86
  "clsx": "^2.1.1",
87
+ "magic-string": "^0.30.21",
87
88
  "tailwind-merge": "^3.2.0"
88
89
  },
89
90
  "devDependencies": {