@walkeros/cli 4.8.0 → 4.8.1-next-1791586788897

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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Flow, PreviewKey, Elb, Simulation, Ingest, WalkerOS, ObserveWeb } from '@walkeros/core';
1
+ import { Flow, PreviewKey, Elb, Simulation, Ingest, WalkerOS, ObserveWeb, MoinTarget } from '@walkeros/core';
2
2
  export { Flow } from '@walkeros/core';
3
3
  import { BuildOptions as BuildOptions$1 } from 'esbuild';
4
4
  import { z, ValidateResult as ValidateResult$1, ValidationError as ValidationError$1, ValidationWarning as ValidationWarning$1, ValidationType } from '@walkeros/core/dev';
@@ -6190,6 +6190,12 @@ interface WrapSkeletonOptions {
6190
6190
  * token into the emitted bytes.
6191
6191
  */
6192
6192
  observe?: ObserveWeb;
6193
+ /**
6194
+ * Browser-only: the Tag Mode loader target, internal deploy data the stage
6195
+ * app passes like the preview keyring. Absent, the loader trusts the
6196
+ * production app.
6197
+ */
6198
+ moin?: MoinTarget;
6193
6199
  /**
6194
6200
  * esbuild target. @default 'es2018' for browser, 'node18' for node.
6195
6201
  */
@@ -6272,6 +6278,10 @@ declare const BuildWrapOptionsSchema: z.ZodObject<{
6272
6278
  }>>;
6273
6279
  sample: z.ZodOptional<z.ZodNumber>;
6274
6280
  }, z.core.$strict>>;
6281
+ moin: z.ZodOptional<z.ZodObject<{
6282
+ app: z.ZodString;
6283
+ base: z.ZodString;
6284
+ }, z.core.$strict>>;
6275
6285
  minify: z.ZodOptional<z.ZodBoolean>;
6276
6286
  minifyOptions: z.ZodOptional<z.ZodObject<{
6277
6287
  identifiers: z.ZodOptional<z.ZodBoolean>;
@@ -6330,6 +6340,10 @@ declare const BuildWrapArtifactSchema: z.ZodObject<{
6330
6340
  }>>;
6331
6341
  sample: z.ZodOptional<z.ZodNumber>;
6332
6342
  }, z.core.$strict>>;
6343
+ moin: z.ZodOptional<z.ZodObject<{
6344
+ app: z.ZodString;
6345
+ base: z.ZodString;
6346
+ }, z.core.$strict>>;
6333
6347
  minify: z.ZodOptional<z.ZodBoolean>;
6334
6348
  minifyOptions: z.ZodOptional<z.ZodObject<{
6335
6349
  identifiers: z.ZodOptional<z.ZodBoolean>;
@@ -6401,6 +6415,10 @@ declare const BuildArtifactSchema: z.ZodUnion<readonly [z.ZodObject<{
6401
6415
  }>>;
6402
6416
  sample: z.ZodOptional<z.ZodNumber>;
6403
6417
  }, z.core.$strict>>;
6418
+ moin: z.ZodOptional<z.ZodObject<{
6419
+ app: z.ZodString;
6420
+ base: z.ZodString;
6421
+ }, z.core.$strict>>;
6404
6422
  minify: z.ZodOptional<z.ZodBoolean>;
6405
6423
  minifyOptions: z.ZodOptional<z.ZodObject<{
6406
6424
  identifiers: z.ZodOptional<z.ZodBoolean>;
@@ -6478,6 +6496,10 @@ declare const BuildManifestSchema: z.ZodObject<{
6478
6496
  }>>;
6479
6497
  sample: z.ZodOptional<z.ZodNumber>;
6480
6498
  }, z.core.$strict>>;
6499
+ moin: z.ZodOptional<z.ZodObject<{
6500
+ app: z.ZodString;
6501
+ base: z.ZodString;
6502
+ }, z.core.$strict>>;
6481
6503
  minify: z.ZodOptional<z.ZodBoolean>;
6482
6504
  minifyOptions: z.ZodOptional<z.ZodObject<{
6483
6505
  identifiers: z.ZodOptional<z.ZodBoolean>;
package/dist/index.js CHANGED
@@ -1806,6 +1806,7 @@ function isPlainObject(value) {
1806
1806
  import esbuild2 from "esbuild";
1807
1807
  import { builtinModules } from "module";
1808
1808
  import path14 from "path";
1809
+ import { fileURLToPath as fileURLToPath2 } from "url";
1809
1810
  import fs14 from "fs-extra";
1810
1811
  import {
1811
1812
  packageNameToVariable as packageNameToVariable2,
@@ -3492,6 +3493,7 @@ ${dataDeclaration}${needs}`;
3492
3493
  };
3493
3494
  if (buildOptions.platform === "browser") {
3494
3495
  stage2Options.format = "iife";
3496
+ stage2Options.plugins = [cliCorePlugin()];
3495
3497
  stage2Options.define = {
3496
3498
  "process.env.NODE_ENV": '"production"',
3497
3499
  global: "globalThis",
@@ -3659,6 +3661,25 @@ function getNodeExternals() {
3659
3661
  }
3660
3662
  return externals;
3661
3663
  }
3664
+ var CLI_CORE = "walkeros-cli-core";
3665
+ function cliCorePlugin() {
3666
+ const resolveDir = path14.dirname(fileURLToPath2(import.meta.url));
3667
+ return {
3668
+ name: CLI_CORE,
3669
+ setup(build2) {
3670
+ build2.onResolve({ filter: /^@walkeros\/core$/ }, async (args) => {
3671
+ if (args.pluginData === CLI_CORE) return void 0;
3672
+ const resolved = await build2.resolve(args.path, {
3673
+ kind: args.kind,
3674
+ resolveDir,
3675
+ pluginData: CLI_CORE
3676
+ });
3677
+ if (resolved.errors.length > 0) return { errors: resolved.errors };
3678
+ return { path: resolved.path, sideEffects: resolved.sideEffects };
3679
+ });
3680
+ }
3681
+ };
3682
+ }
3662
3683
  async function runNftServerPath(outputPath, flowSettings, buildOptions, tempDir, declaredPackages, logger) {
3663
3684
  const outDir = path14.dirname(outputPath);
3664
3685
  const flowExtraIncludes = [
@@ -4170,6 +4191,34 @@ function emitObserveAssignment(observe) {
4170
4191
  return `
4171
4192
  config.observe = ${JSON.stringify(literal)};`;
4172
4193
  }
4194
+ var MOIN_IMPORT = "import { moin } from '@walkeros/core';\n";
4195
+ function emitMoinCall(target) {
4196
+ if (!target)
4197
+ return `
4198
+ moin();`;
4199
+ const app = parseHttps(target.app);
4200
+ if (!app || app.origin !== target.app) {
4201
+ throw new Error(
4202
+ `Invalid moin.app "${target.app}". Must be an https origin such as https://app.example.com.`
4203
+ );
4204
+ }
4205
+ const base = parseHttps(target.base);
4206
+ if (!base || base.href !== target.base || base.username || base.password || base.search || base.hash || !base.pathname.endsWith("/")) {
4207
+ throw new Error(
4208
+ `Invalid moin.base "${target.base}". Must be an https URL ending in "/" without query or fragment.`
4209
+ );
4210
+ }
4211
+ return `
4212
+ moin({ app: ${JSON.stringify(target.app)}, base: ${JSON.stringify(target.base)} });`;
4213
+ }
4214
+ function parseHttps(value) {
4215
+ try {
4216
+ const url = new URL(value);
4217
+ return url.protocol === "https:" ? url : void 0;
4218
+ } catch {
4219
+ return void 0;
4220
+ }
4221
+ }
4173
4222
  function generateWebEntry(stage1Path, dataPayload, options = {}) {
4174
4223
  const assignments = [];
4175
4224
  if (options.windowCollector) {
@@ -4191,11 +4240,13 @@ function generateWebEntry(stage1Path, dataPayload, options = {}) {
4191
4240
  }` : "";
4192
4241
  const stage1Specifier = toFileImportSpecifier(stage1Path);
4193
4242
  const observeBlock = options.observe ? emitObserveAssignment(options.observe) : "";
4194
- return `import { startFlow, wireConfig } from '${stage1Specifier}';
4243
+ const loaderImport = platform === "browser" ? MOIN_IMPORT : "";
4244
+ const loaderCall = platform === "browser" ? emitMoinCall() : "";
4245
+ return `${loaderImport}import { startFlow, wireConfig } from '${stage1Specifier}';
4195
4246
 
4196
4247
  const __configData = ${dataPayload};
4197
4248
 
4198
- (async () => {
4249
+ (async () => {${loaderCall}
4199
4250
  const config = wireConfig(__configData);${envBlock}${observeBlock}
4200
4251
  const { collector, elb } = await startFlow(config);${assignmentCode}
4201
4252
  })();`;
@@ -4266,9 +4317,11 @@ ${grantTargets.map((key) => {
4266
4317
  }` : "";
4267
4318
  const stage1Specifier = toFileImportSpecifier(stage1Path);
4268
4319
  const observeBlock = options.observe ? emitObserveAssignment(options.observe) : "";
4269
- return `${previewImport}import { startFlow, wireConfig, __configData } from '${stage1Specifier}';
4320
+ const loaderImport = platform === "browser" ? MOIN_IMPORT : "";
4321
+ const loaderCall = platform === "browser" ? emitMoinCall(options.moin) : "";
4322
+ return `${loaderImport}${previewImport}import { startFlow, wireConfig, __configData } from '${stage1Specifier}';
4270
4323
 
4271
- (async () => {${previewBlock}
4324
+ (async () => {${loaderCall}${previewBlock}
4272
4325
  const config = wireConfig(__configData);${envBlock}${previewGrantBlock}${observeBlock}
4273
4326
  const { collector, elb } = await startFlow(config);${assignmentCode}
4274
4327
  })();`;
@@ -7374,7 +7427,7 @@ import {
7374
7427
  REF_STORE,
7375
7428
  SECRET_MARKER_PREFIX as SECRET_MARKER_PREFIX3
7376
7429
  } from "@walkeros/core";
7377
- var CLIENT_HEADER = "walkeros-cli/4.8.0";
7430
+ var CLIENT_HEADER = "walkeros-cli/4.8.1-next-1791586788897";
7378
7431
  function createSettingsContext(configDir) {
7379
7432
  return { configDir, cache: /* @__PURE__ */ new Map(), compiled: /* @__PURE__ */ new Map() };
7380
7433
  }
@@ -10006,7 +10059,7 @@ import { validateFlowStructure as validateFlowStructure2 } from "@walkeros/core/
10006
10059
 
10007
10060
  // src/commands/bundle/wrap.ts
10008
10061
  import * as path21 from "path";
10009
- import { fileURLToPath as fileURLToPath2 } from "url";
10062
+ import { fileURLToPath as fileURLToPath3 } from "url";
10010
10063
  import fs21 from "fs-extra";
10011
10064
  import * as esbuild3 from "esbuild";
10012
10065
  function extractDevExternals(skeletonText) {
@@ -10019,7 +10072,7 @@ function extractDevExternals(skeletonText) {
10019
10072
  return Array.from(found);
10020
10073
  }
10021
10074
  function getNodeResolutionPaths() {
10022
- const here = path21.dirname(fileURLToPath2(import.meta.url));
10075
+ const here = path21.dirname(fileURLToPath3(import.meta.url));
10023
10076
  const candidates = [];
10024
10077
  let dir = here;
10025
10078
  for (let i = 0; i < 8; i++) {
@@ -10064,7 +10117,8 @@ async function wrapSkeleton(options) {
10064
10117
  ...options.preview ? { preview: options.preview } : {},
10065
10118
  ...options.previewGrantTargets ? { previewGrantTargets: options.previewGrantTargets } : {},
10066
10119
  platform,
10067
- ...options.observe ? { observe: options.observe } : {}
10120
+ ...options.observe ? { observe: options.observe } : {},
10121
+ ...options.moin ? { moin: options.moin } : {}
10068
10122
  }) : generateWrapEntryServer(absoluteSkeletonPath);
10069
10123
  const entryDir = await tmpRunDir("wrap");
10070
10124
  const entryPath = path21.join(entryDir, "flow.mjs");
@@ -10096,6 +10150,7 @@ async function wrapSkeleton(options) {
10096
10150
  };
10097
10151
  if (platform === "browser") {
10098
10152
  esbuildOptions.format = "iife";
10153
+ esbuildOptions.plugins = [cliCorePlugin()];
10099
10154
  const needs = readNeedsMarker(skeletonText);
10100
10155
  esbuildOptions.define = {
10101
10156
  "process.env.NODE_ENV": '"production"',
@@ -10185,6 +10240,7 @@ var BuildWrapOptionsSchema = z3.object({
10185
10240
  level: z3.enum(["off", "standard", "trace"]).optional(),
10186
10241
  sample: z3.number().min(0).max(1).optional()
10187
10242
  }).strict().optional(),
10243
+ moin: z3.object({ app: z3.string(), base: z3.string() }).strict().optional().describe("Tag Mode loader target; absent, the production app"),
10188
10244
  minify: z3.boolean().optional(),
10189
10245
  minifyOptions: z3.object({
10190
10246
  identifiers: z3.boolean().optional(),