@pipelab/plugin-poki 1.0.0-beta.14 → 1.0.0-beta.15

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/index.mjs CHANGED
@@ -4,11 +4,11 @@ import { normalize } from "path";
4
4
  import { formatWithOptions, types } from "util";
5
5
  import path, { delimiter, dirname, join } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
- import { constants, tmpdir } from "node:os";
7
+ import { constants } from "node:os";
8
8
  import { appendFileSync, createReadStream, createWriteStream, existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
9
+ import { chmod, cp, mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
9
10
  import http from "node:http";
10
11
  import { webcrypto } from "node:crypto";
11
- import { chmod, cp, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
12
12
  import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
13
13
  import { StringDecoder } from "node:string_decoder";
14
14
  import { aborted, callbackify, debuglog, inspect, promisify, stripVTControlCharacters } from "node:util";
@@ -1595,6 +1595,56 @@ function literal(literal_, message) {
1595
1595
  }
1596
1596
  };
1597
1597
  }
1598
+ function looseObject(entries, message) {
1599
+ return {
1600
+ kind: "schema",
1601
+ type: "loose_object",
1602
+ reference: looseObject,
1603
+ expects: "Object",
1604
+ async: false,
1605
+ entries,
1606
+ message,
1607
+ _run(dataset, config2) {
1608
+ const input = dataset.value;
1609
+ if (input && typeof input === "object") {
1610
+ dataset.typed = true;
1611
+ dataset.value = {};
1612
+ for (const key in this.entries) {
1613
+ const value2 = input[key];
1614
+ const valueDataset = this.entries[key]._run({
1615
+ typed: false,
1616
+ value: value2
1617
+ }, config2);
1618
+ if (valueDataset.issues) {
1619
+ const pathItem = {
1620
+ type: "object",
1621
+ origin: "value",
1622
+ input,
1623
+ key,
1624
+ value: value2
1625
+ };
1626
+ for (const issue of valueDataset.issues) {
1627
+ if (issue.path) issue.path.unshift(pathItem);
1628
+ else issue.path = [pathItem];
1629
+ dataset.issues?.push(issue);
1630
+ }
1631
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
1632
+ if (config2.abortEarly) {
1633
+ dataset.typed = false;
1634
+ break;
1635
+ }
1636
+ }
1637
+ if (!valueDataset.typed) dataset.typed = false;
1638
+ if (valueDataset.value !== void 0 || key in input) dataset.value[key] = valueDataset.value;
1639
+ }
1640
+ if (!dataset.issues || !config2.abortEarly) {
1641
+ for (const key in input) if (_isValidObjectKey(input, key) && !(key in this.entries)) dataset.value[key] = input[key];
1642
+ }
1643
+ } else _addIssue(this, "type", dataset, config2);
1644
+ return dataset;
1645
+ }
1646
+ };
1647
+ }
1598
1648
  function number(message) {
1599
1649
  return {
1600
1650
  kind: "schema",
@@ -2132,6 +2182,18 @@ settingsMigratorInternal.createMigrations({
2132
2182
  })
2133
2183
  ]
2134
2184
  });
2185
+ const connectionsMigratorInternal = createMigrator();
2186
+ const defaultConnections = connectionsMigratorInternal.createDefault({
2187
+ version: "1.0.0",
2188
+ connections: []
2189
+ });
2190
+ connectionsMigratorInternal.createMigrations({
2191
+ defaultValue: defaultConnections,
2192
+ migrations: [createMigration({
2193
+ version: "1.0.0",
2194
+ up: finalVersion
2195
+ })]
2196
+ });
2135
2197
  const fileRepoMigratorInternal = createMigrator();
2136
2198
  const defaultFileRepo = fileRepoMigratorInternal.createDefault({
2137
2199
  version: "2.0.0",
@@ -2293,11 +2355,51 @@ const LEGACY_ID_MAP = {
2293
2355
  };
2294
2356
  const getStrictPluginId = (pluginId) => {
2295
2357
  if (!pluginId) return pluginId;
2296
- if (LEGACY_ID_MAP[pluginId]) return LEGACY_ID_MAP[pluginId];
2297
- if (pluginId.startsWith("@") || pluginId.includes("/") || pluginId.startsWith("pipelab-plugin-")) return pluginId;
2298
- const prefixed = `@pipelab/plugin-${pluginId}`;
2299
- return LEGACY_ID_MAP[prefixed] || prefixed;
2358
+ return LEGACY_ID_MAP[pluginId] || pluginId;
2300
2359
  };
2360
+ //#endregion
2361
+ //#region ../../packages/shared/src/save-location.ts
2362
+ const SaveLocationInternalValidator = object({
2363
+ id: string(),
2364
+ project: string(),
2365
+ lastModified: string(),
2366
+ type: literal("internal"),
2367
+ configName: string()
2368
+ });
2369
+ const SaveLocationValidator = union([
2370
+ object({
2371
+ id: string(),
2372
+ project: string(),
2373
+ path: string(),
2374
+ lastModified: string(),
2375
+ type: literal("external"),
2376
+ summary: object({
2377
+ plugins: array(string()),
2378
+ name: string(),
2379
+ description: string()
2380
+ })
2381
+ }),
2382
+ SaveLocationInternalValidator,
2383
+ object({
2384
+ id: string(),
2385
+ project: string(),
2386
+ type: literal("pipelab-cloud")
2387
+ })
2388
+ ]);
2389
+ object({
2390
+ version: literal("1.0.0"),
2391
+ data: optional(record(string(), SaveLocationValidator), {})
2392
+ });
2393
+ const FileRepoProjectValidatorV2$1 = object({
2394
+ id: string(),
2395
+ name: string(),
2396
+ description: string()
2397
+ });
2398
+ object({
2399
+ version: literal("2.0.0"),
2400
+ projects: array(FileRepoProjectValidatorV2$1),
2401
+ pipelines: optional(array(SaveLocationValidator), [])
2402
+ });
2301
2403
  object({
2302
2404
  cacheFolder: string(),
2303
2405
  theme: union([literal("light"), literal("dark")]),
@@ -2449,6 +2551,17 @@ object({
2449
2551
  })),
2450
2552
  isInternalMigrationBannerClosed: optional(boolean(), false)
2451
2553
  });
2554
+ const ConnectionValidator = looseObject({
2555
+ id: string(),
2556
+ pluginName: string(),
2557
+ name: string(),
2558
+ createdAt: string(),
2559
+ isDefault: boolean()
2560
+ });
2561
+ object({
2562
+ version: literal("1.0.0"),
2563
+ connections: array(ConnectionValidator)
2564
+ });
2452
2565
  //#endregion
2453
2566
  //#region ../../node_modules/tslog/dist/esm/prettyLogStyles.js
2454
2567
  const prettyLogStyles = {
@@ -2969,7 +3082,7 @@ const useLogger = () => {
2969
3082
  const OriginValidator = object({
2970
3083
  pluginId: string(),
2971
3084
  nodeId: string(),
2972
- version: pipe(optional(string()), description("Pinned version of the plugin for this block. Falls back to \"latest\" when absent."))
3085
+ version: optional(pipe(string(), description("Pinned version of the plugin for this block. Falls back to \"latest\" when absent.")))
2973
3086
  });
2974
3087
  const BlockActionValidatorV1 = object({
2975
3088
  type: literal("action"),
@@ -2982,7 +3095,7 @@ const EditorParamValidatorV3 = union([literal("simple"), literal("editor")]);
2982
3095
  const BlockActionValidatorV3 = object({
2983
3096
  type: literal("action"),
2984
3097
  uid: string(),
2985
- name: pipe(optional(string()), description("A custom name provided by the user")),
3098
+ name: optional(pipe(string(), description("A custom name provided by the user"))),
2986
3099
  disabled: optional(boolean()),
2987
3100
  params: record(string(), object({
2988
3101
  editor: EditorParamValidatorV3,
@@ -45282,35 +45395,6 @@ const createPathParam = (value, definition) => {
45282
45395
  };
45283
45396
  };
45284
45397
  //#endregion
45285
- //#region ../../packages/shared/src/save-location.ts
45286
- const SaveLocationInternalValidator = object({
45287
- id: string(),
45288
- project: string(),
45289
- lastModified: string(),
45290
- type: literal("internal"),
45291
- configName: string()
45292
- });
45293
- const SaveLocationValidator = union([
45294
- object({
45295
- id: string(),
45296
- project: string(),
45297
- path: string(),
45298
- lastModified: string(),
45299
- type: literal("external"),
45300
- summary: object({
45301
- plugins: array(string()),
45302
- name: string(),
45303
- description: string()
45304
- })
45305
- }),
45306
- SaveLocationInternalValidator,
45307
- object({
45308
- id: string(),
45309
- project: string(),
45310
- type: literal("pipelab-cloud")
45311
- })
45312
- ]);
45313
- //#endregion
45314
45398
  //#region ../../packages/shared/src/websocket.types.ts
45315
45399
  var WebSocketError = class extends Error {
45316
45400
  constructor(message, code, requestId) {
@@ -45327,20 +45411,6 @@ object({
45327
45411
  version: literal("1.0.0"),
45328
45412
  data: optional(record(string(), SaveLocationValidator), {})
45329
45413
  });
45330
- const FileRepoProjectValidatorV2$1 = object({
45331
- id: string(),
45332
- name: string(),
45333
- description: string()
45334
- });
45335
- object({
45336
- version: literal("2.0.0"),
45337
- projects: array(FileRepoProjectValidatorV2$1),
45338
- pipelines: optional(array(SaveLocationValidator), [])
45339
- });
45340
- object({
45341
- version: literal("1.0.0"),
45342
- data: optional(record(string(), SaveLocationValidator), {})
45343
- });
45344
45414
  const FileRepoProjectValidatorV2 = object({
45345
45415
  id: string(),
45346
45416
  name: string(),
@@ -45360,9 +45430,15 @@ var init_esm_shims = __esmMin((() => {
45360
45430
  __dirname = /* @__PURE__ */ getDirname();
45361
45431
  }));
45362
45432
  //#endregion
45363
- //#region ../../packages/core-node/src/context.ts
45433
+ //#region ../../packages/constants/src/index.ts
45364
45434
  init_esm_shims();
45365
- const _dirname = typeof __dirname !== "undefined" ? __dirname : typeof import.meta !== "undefined" && import.meta.url ? dirname(fileURLToPath(import.meta.url)) : process.cwd();
45435
+ const websocketPort = 33753;
45436
+ const DEFAULT_NODE_VERSION = "24.14.1";
45437
+ const DEFAULT_PNPM_VERSION = "10.12.0";
45438
+ //#endregion
45439
+ //#region ../../packages/core-node/src/context.ts
45440
+ const metaUrl = typeof import.meta !== "undefined" ? import.meta.url : void 0;
45441
+ const _dirname = typeof __dirname !== "undefined" ? __dirname : metaUrl ? dirname(fileURLToPath(metaUrl)) : process.cwd();
45366
45442
  const isDev = process.env.NODE_ENV === "development";
45367
45443
  /**
45368
45444
  * Finds the monorepo root by looking for pnpm-workspace.yaml.
@@ -48934,9 +49010,6 @@ const useAPI = () => {
48934
49010
  };
48935
49011
  };
48936
49012
  //#endregion
48937
- //#region ../../packages/constants/src/index.ts
48938
- const websocketPort = 33753;
48939
- //#endregion
48940
49013
  //#region ../../packages/core-node/src/websocket-server.ts
48941
49014
  var WebSocketServer = class {
48942
49015
  wss = null;
@@ -89341,14 +89414,6 @@ var import_tar = /* @__PURE__ */ __toESM(require_tar$1(), 1);
89341
89414
  var import_yauzl = /* @__PURE__ */ __toESM(require_yauzl(), 1);
89342
89415
  require_archiver();
89343
89416
  /**
89344
- * Generates a unique temporary folder.
89345
- */
89346
- const generateTempFolder = async (base) => {
89347
- const targetBase = base || tmpdir();
89348
- await mkdir(targetBase, { recursive: true });
89349
- return await mkdtemp(join(await realpath(targetBase), "pipelab-"));
89350
- };
89351
- /**
89352
89417
  * Extracts a .tar.gz archive.
89353
89418
  */
89354
89419
  async function extractTarGz(archivePath, destinationDir) {
@@ -100929,11 +100994,11 @@ var require_cp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100929
100994
  var require_with_temp_dir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100930
100995
  const { join: join$5, sep: sep$1 } = __require("path");
100931
100996
  const getOptions = require_get_options();
100932
- const { mkdir: mkdir$4, mkdtemp: mkdtemp$1, rm: rm$5 } = __require("fs/promises");
100997
+ const { mkdir: mkdir$4, mkdtemp, rm: rm$5 } = __require("fs/promises");
100933
100998
  const withTempDir = async (root, fn, opts) => {
100934
100999
  const options = getOptions(opts, { copy: ["tmpPrefix"] });
100935
101000
  await mkdir$4(root, { recursive: true });
100936
- const target = await mkdtemp$1(join$5(`${root}${sep$1}`, options.tmpPrefix || ""));
101001
+ const target = await mkdtemp(join$5(`${root}${sep$1}`, options.tmpPrefix || ""));
100937
101002
  let err;
100938
101003
  let result;
100939
101004
  try {
@@ -110532,9 +110597,9 @@ var require_protected = /* @__PURE__ */ __commonJSMin(((exports, module) => {
110532
110597
  //#region ../../node_modules/pacote/lib/util/cache-dir.js
110533
110598
  var require_cache_dir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
110534
110599
  const { resolve: resolve$6 } = __require("node:path");
110535
- const { tmpdir: tmpdir$1, homedir } = __require("node:os");
110600
+ const { tmpdir, homedir } = __require("node:os");
110536
110601
  module.exports = (fakePlatform = false) => {
110537
- const temp = tmpdir$1();
110602
+ const temp = tmpdir();
110538
110603
  const uidOrPid = process.getuid ? process.getuid() : process.pid;
110539
110604
  const home = homedir() || resolve$6(temp, "npm-" + uidOrPid);
110540
110605
  const platform = fakePlatform || process.platform;
@@ -150607,7 +150672,7 @@ var require_error = /* @__PURE__ */ __commonJSMin(((exports, module) => {
150607
150672
  const { promisify: promisify$1 } = __require("util");
150608
150673
  const path$1 = __require("path");
150609
150674
  const { createHash } = __require("crypto");
150610
- const { realpath: realpath$1, lstat, createReadStream: createReadStream$1, readdir: readdir$1 } = __require("fs");
150675
+ const { realpath, lstat, createReadStream: createReadStream$1, readdir: readdir$1 } = __require("fs");
150611
150676
  const url = __require("url");
150612
150677
  const slasher = require_glob_slash();
150613
150678
  const minimatch = require_minimatch();
@@ -150930,7 +150995,7 @@ var require_error = /* @__PURE__ */ __commonJSMin(((exports, module) => {
150930
150995
  };
150931
150996
  const getHandlers = (methods) => Object.assign({
150932
150997
  lstat: promisify$1(lstat),
150933
- realpath: promisify$1(realpath$1),
150998
+ realpath: promisify$1(realpath),
150934
150999
  createReadStream: createReadStream$1,
150935
151000
  readdir: promisify$1(readdir$1),
150936
151001
  sendError
@@ -151069,8 +151134,6 @@ const sendStartupProgress = (message) => {
151069
151134
  };
151070
151135
  //#endregion
151071
151136
  //#region ../../packages/core-node/src/utils/remote.ts
151072
- const DEFAULT_NODE_VERSION = "24.14.1";
151073
- const DEFAULT_PNPM_VERSION = "10.12.0";
151074
151137
  function isPackageComplete(packageDir) {
151075
151138
  return existsSync(join(packageDir, "package.json"));
151076
151139
  }
@@ -151262,7 +151325,7 @@ async function ensureNodeJS(context, version = DEFAULT_NODE_VERSION) {
151262
151325
  const extension = isWindows ? "zip" : "tar.gz";
151263
151326
  const fileName = `node-v${version}-${platform === "osx" ? "darwin" : platform}-${arch}.${extension}`;
151264
151327
  const downloadUrl = `https://nodejs.org/dist/v${version}/${fileName}`;
151265
- const tempDir = await generateTempFolder(tmpdir());
151328
+ const tempDir = await context.createTempFolder("node-download-");
151266
151329
  const archivePath = join(tempDir, fileName);
151267
151330
  sendStartupProgress(`Downloading Node.js v${version}...`);
151268
151331
  console.log(`Downloading Node.js from ${downloadUrl}...`);
@@ -151490,84 +151553,100 @@ if (isDev && projectRoot) {
151490
151553
  const createActionRunner = (runner) => runner;
151491
151554
  //#endregion
151492
151555
  //#region src/index.ts
151493
- var src_default = createNodeDefinition({ nodes: [{
151494
- node: createAction({
151495
- id: "poki-upload",
151496
- name: "Upload to Poki.io",
151497
- description: "",
151498
- icon: "",
151499
- displayString: "`Upload ${fmt.param(params['input-folder'], 'primary', 'No path selected')} to ${fmt.param(params['project'], 'primary', 'No project')} poki game (${fmt.param(params['name'], 'primary', 'No version name')})`",
151500
- meta: {},
151501
- params: {
151502
- "input-folder": createPathParam("", {
151503
- required: true,
151504
- label: "Folder to Upload",
151505
- control: {
151506
- type: "path",
151507
- options: { properties: ["openDirectory"] }
151508
- }
151509
- }),
151510
- project: createStringParam("", {
151511
- required: true,
151512
- label: "Project",
151513
- description: "This is you Poki game id"
151514
- }),
151515
- name: createStringParam("", {
151516
- required: true,
151517
- label: "Version name",
151518
- description: "This is the name of the version"
151519
- }),
151520
- notes: createStringParam("", {
151521
- required: true,
151522
- label: "Version notes",
151523
- description: "These are notes you want to specify with your version"
151524
- })
151525
- },
151526
- outputs: {}
151527
- }),
151528
- runner: createActionRunner(async ({ log, inputs, paths, abortSignal, cwd, context }) => {
151529
- const { node, thirdparty, pnpm } = paths;
151530
- const { packageDir: pokiDir } = await fetchPackage("@poki/cli", "0.1.19", {
151531
- context,
151532
- installDeps: true
151533
- });
151534
- const poki = join(pokiDir, "bin", "index.js");
151535
- const dist = join(cwd, "dist");
151536
- await mkdir(dist, { recursive: true });
151537
- await cp(inputs["input-folder"], dist, { recursive: true });
151538
- const pokiJsonPath = join(cwd, "poki.json");
151539
- console.log("pokiJsonPath", pokiJsonPath);
151540
- await writeFile(pokiJsonPath, JSON.stringify({
151541
- game_id: inputs.project,
151542
- build_dir: "dist"
151543
- }, void 0, 2), "utf-8");
151544
- log("process.env.MSW_BRIDGE_PORT", process.env.MSW_BRIDGE_PORT);
151545
- log("process.env.NODE_OPTIONS", process.env.NODE_OPTIONS);
151546
- await runWithLiveLogs(node, [
151547
- poki,
151548
- "upload",
151549
- "--name",
151550
- inputs.name,
151551
- "--notes",
151552
- inputs.notes
151553
- ], {
151554
- cwd,
151555
- env: {
151556
- ...process.env,
151557
- PATH: `${dirname(node)}${delimiter}${process.env.PATH}`
151558
- },
151559
- cancelSignal: abortSignal
151560
- }, log, {
151561
- onStderr(data, subprocess) {
151562
- log(data);
151556
+ var src_default = createNodeDefinition({
151557
+ nodes: [{
151558
+ node: createAction({
151559
+ id: "poki-upload",
151560
+ name: "Upload to Poki.io",
151561
+ description: "",
151562
+ icon: "",
151563
+ displayString: "`Upload ${fmt.param(params['input-folder'], 'primary', 'No path selected')} to ${fmt.param(params['project'], 'primary', 'No project')} poki game (${fmt.param(params['name'], 'primary', 'No version name')})`",
151564
+ meta: {},
151565
+ params: {
151566
+ "input-folder": createPathParam("", {
151567
+ required: true,
151568
+ label: "Folder to Upload",
151569
+ control: {
151570
+ type: "path",
151571
+ options: { properties: ["openDirectory"] }
151572
+ }
151573
+ }),
151574
+ project: createStringParam("", {
151575
+ required: true,
151576
+ label: "Project",
151577
+ description: "This is you Poki game id"
151578
+ }),
151579
+ name: createStringParam("", {
151580
+ required: true,
151581
+ label: "Version name",
151582
+ description: "This is the name of the version"
151583
+ }),
151584
+ notes: createStringParam("", {
151585
+ required: true,
151586
+ label: "Version notes",
151587
+ description: "These are notes you want to specify with your version"
151588
+ })
151563
151589
  },
151564
- onStdout(data, subprocess) {
151565
- log(data);
151566
- }
151567
- });
151568
- log("Uploaded to poki");
151569
- })
151570
- }] });
151590
+ outputs: {}
151591
+ }),
151592
+ runner: createActionRunner(async ({ log, inputs, paths, abortSignal, cwd, context }) => {
151593
+ const { node, thirdparty, pnpm } = paths;
151594
+ const { packageDir: pokiDir } = await fetchPackage("@poki/cli", "0.1.19", {
151595
+ context,
151596
+ installDeps: true
151597
+ });
151598
+ const poki = join(pokiDir, "bin", "index.js");
151599
+ const dist = join(cwd, "dist");
151600
+ await mkdir(dist, { recursive: true });
151601
+ await cp(inputs["input-folder"], dist, { recursive: true });
151602
+ const pokiJsonPath = join(cwd, "poki.json");
151603
+ console.log("pokiJsonPath", pokiJsonPath);
151604
+ await writeFile(pokiJsonPath, JSON.stringify({
151605
+ game_id: inputs.project,
151606
+ build_dir: "dist"
151607
+ }, void 0, 2), "utf-8");
151608
+ log("process.env.MSW_BRIDGE_PORT", process.env.MSW_BRIDGE_PORT);
151609
+ log("process.env.NODE_OPTIONS", process.env.NODE_OPTIONS);
151610
+ await runWithLiveLogs(node, [
151611
+ poki,
151612
+ "upload",
151613
+ "--name",
151614
+ inputs.name,
151615
+ "--notes",
151616
+ inputs.notes
151617
+ ], {
151618
+ cwd,
151619
+ env: {
151620
+ ...process.env,
151621
+ PATH: `${dirname(node)}${delimiter}${process.env.PATH}`
151622
+ },
151623
+ cancelSignal: abortSignal
151624
+ }, log, {
151625
+ onStderr(data, subprocess) {
151626
+ log(data);
151627
+ },
151628
+ onStdout(data, subprocess) {
151629
+ log(data);
151630
+ }
151631
+ });
151632
+ log("Uploaded to poki");
151633
+ })
151634
+ }],
151635
+ integrations: [{
151636
+ name: "Poki Developer Profile",
151637
+ fields: [{
151638
+ key: "gameId",
151639
+ label: "Game ID",
151640
+ type: "text",
151641
+ placeholder: "e.g., poki-game-id"
151642
+ }, {
151643
+ key: "apiKey",
151644
+ label: "Developer Token",
151645
+ type: "password",
151646
+ placeholder: "Poki Developer Token"
151647
+ }]
151648
+ }]
151649
+ });
151571
151650
  //#endregion
151572
151651
  export { src_default as default };
151573
151652