@kehto/paja 0.32.0 → 0.33.0

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/cli.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { P as PajaRawOptions, s as startPajaServer, a as PajaCommand, w as waitForTargetUrl } from './server-bAe1oDUG.js';
2
+ import { P as PajaRawOptions, s as startPajaServer, a as PajaCommand, w as waitForTargetUrl } from './server-B7uqpu8g.js';
3
3
  import '@kehto/shell';
4
4
 
5
5
  /**
package/dist/cli.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  startPajaServer,
10
10
  summarizePajaSimulation,
11
11
  waitForTargetUrl
12
- } from "./chunk-DDYBKY5L.js";
12
+ } from "./chunk-ZAIBJIBA.js";
13
13
 
14
14
  // src/cli.ts
15
15
  import { spawn } from "child_process";
@@ -133,7 +133,6 @@ Options:
133
133
  --config-value <key=json> Add a JSON config value.
134
134
  --capability <domain:on|off> Toggle an advertised capability domain.
135
135
  --acl-mode <mode> allow or deny.
136
- --firewall-mode <mode> allow, deny, or observe.
137
136
  --help, -h Show this help.`;
138
137
  function readValue(args, index, option) {
139
138
  const value = args[index + 1];
@@ -224,8 +223,7 @@ function applySimulationOption(arg, args, index, raw) {
224
223
  ensureSimulation(raw).acl = { ...raw.simulation?.acl, mode: readEnum(args, index, arg, ["allow", "deny"]) };
225
224
  return true;
226
225
  case "--firewall-mode":
227
- ensureSimulation(raw).firewall = { ...raw.simulation?.firewall, mode: readEnum(args, index, arg, ["allow", "deny", "observe"]) };
228
- return true;
226
+ throw new PajaOptionsError("--firewall-mode was removed; approve exact scopes in Paja Firewall grants.");
229
227
  default:
230
228
  return false;
231
229
  }
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * CLI entrypoint for running the Paja local authoring runtime.\n *\n * @module\n */\nimport { spawn, type ChildProcess } from 'node:child_process';\nimport {\n createPajaHostConfig,\n formatPajaUrl,\n normalizePajaOptions,\n waitForTargetUrl,\n type PajaCommand,\n type PajaRawOptions,\n PajaOptionsError,\n} from './index.js';\nimport { resolvePajaRawOptions } from './config-file.js';\nimport { startPajaServer } from './server.js';\nimport {\n PAJA_SIMULATION_DOMAINS,\n summarizePajaSimulation,\n type PajaCapabilityDomain,\n type PajaSimulationRawOptions,\n type JsonValue,\n} from './simulation.js';\n\n/**\n * Minimal output streams used by the CLI runner.\n *\n * @remarks\n * Tests and embedders can pass custom streams to capture output without\n * patching global `process.stdout` or `process.stderr`.\n */\nexport interface CliIo {\n readonly stdout: { write(chunk: string): void };\n readonly stderr: { write(chunk: string): void };\n}\n\n/**\n * Parsed CLI arguments before full option normalization.\n */\nexport interface CliParseResult {\n readonly options?: PajaRawOptions;\n readonly help: boolean;\n}\n\n/**\n * Execution controls for embedding the CLI runner in tests or wrappers.\n */\nexport interface RunPajaCliOptions {\n readonly serve?: boolean;\n readonly startServer?: typeof startPajaServer;\n readonly startCommand?: (command: PajaCommand, io: CliIo) => ManagedChildProcess;\n readonly waitForTargetUrl?: typeof waitForTargetUrl;\n readonly targetDiscoveryGraceMs?: number;\n}\n\n/**\n * Parse raw `kehto paja` arguments into raw runtime options.\n *\n * @param args - Argument vector without the node executable or script path.\n * @returns Parsed raw options, or a help flag when `--help` is present.\n */\nexport function parsePajaArgs(args: readonly string[]): CliParseResult {\n const raw: MutablePajaRawOptions = {};\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index];\n\n if (arg === '--') {\n const argv = args.slice(index + 1);\n raw.command = { mode: 'argv', argv };\n break;\n }\n\n if (arg === '--help' || arg === '-h') {\n return { help: true };\n }\n\n if (applyCoreOption(arg, args, index, raw) || applySimulationOption(arg, args, index, raw)) {\n index += 1;\n continue;\n }\n\n throw new PajaOptionsError(`Unknown option \"${arg}\". Run kehto paja --help for usage.`);\n }\n\n return { help: false, options: raw };\n}\n\n/**\n * Run the Paja CLI command.\n *\n * @param args - Argument vector without the node executable or script path.\n * @param io - Output streams used by the command.\n * @param runOptions - Test/embedding controls for server and process spawning.\n * @returns Process exit code.\n */\nexport async function runPajaCli(\n args: readonly string[] = process.argv.slice(2),\n io: CliIo = defaultIo,\n runOptions: RunPajaCliOptions = {},\n): Promise<number> {\n try {\n const parsed = parsePajaArgs(args);\n if (parsed.help) {\n io.stdout.write(`${HELP_TEXT}\\n`);\n return 0;\n }\n\n const rawOptions = resolvePajaRawOptions(parsed.options ?? {});\n const options = normalizePajaOptions(rawOptions);\n const hostConfig = createPajaHostConfig(options);\n const shouldServe = runOptions.serve ?? true;\n const startServer = runOptions.startServer ?? startPajaServer;\n const startCommand = runOptions.startCommand ?? startManagedCommand;\n const waitForTarget = runOptions.waitForTargetUrl ?? waitForTargetUrl;\n let child: ManagedChildProcess | undefined;\n let server: Awaited<ReturnType<typeof startPajaServer>> | undefined;\n if (shouldServe) {\n try {\n server = await startServer({ options: rawOptions });\n writeRuntimeSummary(io, server.url, hostConfig, options);\n\n if (options.command) {\n child = startCommand(options.command, io);\n const targetUrl = await resolveManagedTargetUrl(options.targetUrl, child, {\n timeoutMs: options.readyTimeoutMs,\n discoveryGraceMs: runOptions.targetDiscoveryGraceMs,\n waitForTargetUrl: waitForTarget,\n });\n if (targetUrl !== options.targetUrl) {\n server.updateTargetUrl(targetUrl);\n io.stdout.write(`Target URL updated: ${targetUrl}\\n`);\n }\n }\n } catch (error) {\n child?.kill();\n await server?.close().catch(() => undefined);\n throw error;\n }\n }\n const runtimeUrl = server?.url ?? formatPajaUrl(options);\n\n if (!shouldServe) {\n writeRuntimeSummary(io, runtimeUrl, hostConfig, options);\n }\n\n return 0;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n io.stderr.write(`kehto paja: ${message}\\n`);\n return 1;\n }\n}\n\nfunction writeRuntimeSummary(\n io: CliIo,\n runtimeUrl: string,\n hostConfig: ReturnType<typeof createPajaHostConfig>,\n options: ReturnType<typeof normalizePajaOptions>,\n): void {\n io.stdout.write(`Kehto Paja\\n`);\n io.stdout.write(`Runtime URL: ${runtimeUrl}\\n`);\n io.stdout.write(`Target URL: ${hostConfig.target.url}\\n`);\n io.stdout.write(`Mode: ${options.mode}\\n`);\n io.stdout.write(`HMR: ${hostConfig.target.hmrStrategy}\\n`);\n io.stdout.write(`Simulation: ${summarizePajaSimulation(options.simulation)}\\n`);\n\n if (options.command) {\n io.stdout.write(`Command: ${formatCommand(options.command)}\\n`);\n }\n}\n\nconst HELP_TEXT = `Usage:\n kehto paja --target-url <url> [options]\n kehto paja --target-url <url> [options] -- <command...>\n\nOptions:\n --target-url, -u <url> App dev-server URL to load in the runtime iframe.\n --command, -c <command> Shell command to start before waiting for target URL.\n -- <command...> Argv command form; preserves arbitrary framework commands.\n --host <host> Runtime host. Default: 127.0.0.1.\n --port <port> Runtime port. Default: 5197.\n --ready-timeout <ms> Target readiness timeout. Default: 30000.\n --config <path> JSON config file using the same option schema.\n --nested-context-lock <v> Experimental frame-creation lock: on, off, or auto\n (default; on for napplets granted a private domain).\n --identity-mode <mode> anonymous or fixed.\n --identity-pubkey <hex> Required when identity mode is fixed.\n --relay-mode <mode> live, memory, or disabled.\n --relay-url <url> Add a relay URL for live or memory relay backends.\n --storage-mode <mode> local, memory, or disabled.\n --cache-mode <mode> memory or disabled.\n --upload-mode <mode> memory, blossom, or disabled.\n --upload-rail <name> Upload rail name for memory uploads.\n --upload-server <url> Add a shell-owned Blossom server (repeatable).\n --media <state> enabled or disabled.\n --notifications <state> enabled or disabled.\n --notify-grant <bool> Allow or block interactive notification permission prompts.\n --theme <mode> dark or light.\n --config-value <key=json> Add a JSON config value.\n --capability <domain:on|off> Toggle an advertised capability domain.\n --acl-mode <mode> allow or deny.\n --firewall-mode <mode> allow, deny, or observe.\n --help, -h Show this help.`;\n\nfunction readValue(args: readonly string[], index: number, option: string): string {\n const value = args[index + 1];\n if (!value || value.startsWith('--')) {\n throw new PajaOptionsError(`${option} requires a value.`);\n }\n return value;\n}\n\nfunction applyCoreOption(\n arg: string,\n args: readonly string[],\n index: number,\n raw: MutablePajaRawOptions,\n): boolean {\n switch (arg) {\n case '--target-url':\n case '-u':\n raw.targetUrl = readValue(args, index, arg);\n return true;\n case '--command':\n case '-c':\n raw.command = { mode: 'shell', command: readValue(args, index, arg) };\n return true;\n case '--host':\n raw.host = readValue(args, index, arg);\n return true;\n case '--port':\n raw.port = readValue(args, index, arg);\n return true;\n case '--ready-timeout':\n raw.readyTimeoutMs = readValue(args, index, arg);\n return true;\n case '--config':\n raw.configPath = readValue(args, index, arg);\n return true;\n case '--nested-context-lock':\n raw.experimental = {\n nestedContextLock: readEnum(args, index, arg, ['on', 'off', 'auto'] as const),\n };\n return true;\n default:\n return false;\n }\n}\n\nfunction applySimulationOption(\n arg: string,\n args: readonly string[],\n index: number,\n raw: MutablePajaRawOptions,\n): boolean {\n switch (arg) {\n case '--identity-mode':\n setIdentity(raw, { mode: readEnum(args, index, arg, ['anonymous', 'fixed']) });\n return true;\n case '--identity-pubkey':\n setIdentity(raw, { pubkey: readValue(args, index, arg) });\n return true;\n case '--relay-mode':\n setRelay(raw, { mode: readEnum(args, index, arg, ['live', 'memory', 'disabled']) });\n return true;\n case '--relay-url':\n setRelay(raw, { urls: [...(raw.simulation?.relay?.urls ?? []), readValue(args, index, arg)] });\n return true;\n case '--storage-mode':\n ensureSimulation(raw).storage = { ...raw.simulation?.storage, mode: readEnum(args, index, arg, ['local', 'memory', 'disabled']) };\n return true;\n case '--cache-mode':\n ensureSimulation(raw).cache = { ...raw.simulation?.cache, mode: readEnum(args, index, arg, ['memory', 'disabled']) };\n return true;\n case '--upload-mode':\n setUpload(raw, { mode: readEnum(args, index, arg, ['memory', 'blossom', 'disabled']) });\n return true;\n case '--upload-rail':\n setUpload(raw, { rail: readValue(args, index, arg) });\n return true;\n case '--upload-server':\n setUpload(raw, { servers: [...(raw.simulation?.upload?.servers ?? []), readValue(args, index, arg)] });\n return true;\n case '--media':\n ensureSimulation(raw).media = { ...raw.simulation?.media, enabled: readEnabled(args, index, arg) };\n return true;\n case '--notifications':\n setNotifications(raw, { enabled: readEnabled(args, index, arg) });\n return true;\n case '--notify-grant':\n setNotifications(raw, { grant: readBoolean(args, index, arg) });\n return true;\n case '--theme':\n ensureSimulation(raw).theme = { ...raw.simulation?.theme, mode: readEnum(args, index, arg, ['dark', 'light']) };\n return true;\n case '--config-value':\n setConfigValue(raw, readConfigValue(args, index, arg));\n return true;\n case '--capability':\n setCapability(raw, readCapability(args, index, arg));\n return true;\n case '--acl-mode':\n ensureSimulation(raw).acl = { ...raw.simulation?.acl, mode: readEnum(args, index, arg, ['allow', 'deny']) };\n return true;\n case '--firewall-mode':\n ensureSimulation(raw).firewall = { ...raw.simulation?.firewall, mode: readEnum(args, index, arg, ['allow', 'deny', 'observe']) };\n return true;\n default:\n return false;\n }\n}\n\nfunction formatCommand(command: PajaCommand): string {\n return command.mode === 'argv' ? command.argv.join(' ') : command.command;\n}\n\nfunction readEnum<const T extends readonly string[]>(\n args: readonly string[],\n index: number,\n option: string,\n allowed: T,\n): T[number] {\n const value = readValue(args, index, option);\n if (!allowed.includes(value)) {\n throw new PajaOptionsError(`${option} must be one of: ${allowed.join(', ')}.`);\n }\n return value;\n}\n\nfunction readEnabled(args: readonly string[], index: number, option: string): boolean {\n const value = readValue(args, index, option);\n if (value === 'enabled') return true;\n if (value === 'disabled') return false;\n throw new PajaOptionsError(`${option} must be \"enabled\" or \"disabled\".`);\n}\n\nfunction readBoolean(args: readonly string[], index: number, option: string): boolean {\n const value = readValue(args, index, option);\n if (value === 'true') return true;\n if (value === 'false') return false;\n throw new PajaOptionsError(`${option} must be \"true\" or \"false\".`);\n}\n\nfunction readConfigValue(\n args: readonly string[],\n index: number,\n option: string,\n): { key: string; value: JsonValue } {\n const raw = readValue(args, index, option);\n const separator = raw.indexOf('=');\n if (separator <= 0) {\n throw new PajaOptionsError(`${option} expects key=json.`);\n }\n const key = raw.slice(0, separator).trim();\n if (!key) {\n throw new PajaOptionsError(`${option} expects a non-empty key.`);\n }\n try {\n return { key, value: JSON.parse(raw.slice(separator + 1)) as JsonValue };\n } catch {\n throw new PajaOptionsError(`${option} value for \"${key}\" must be valid JSON.`);\n }\n}\n\nfunction readCapability(\n args: readonly string[],\n index: number,\n option: string,\n): { domain: PajaCapabilityDomain; enabled: boolean } {\n const raw = readValue(args, index, option);\n const [domainRaw, stateRaw] = raw.split(':') as [string | undefined, string | undefined];\n if (!domainRaw || (stateRaw !== 'on' && stateRaw !== 'off')) {\n throw new PajaOptionsError(`${option} expects domain:on or domain:off.`);\n }\n if (!PAJA_SIMULATION_DOMAINS.includes(domainRaw as PajaCapabilityDomain)) {\n throw new PajaOptionsError(`${option} unknown domain \"${domainRaw}\".`);\n }\n return {\n domain: domainRaw as PajaCapabilityDomain,\n enabled: stateRaw === 'on',\n };\n}\n\nfunction setIdentity(raw: MutablePajaRawOptions, identity: NonNullable<PajaSimulationRawOptions['identity']>): void {\n ensureSimulation(raw).identity = { ...raw.simulation?.identity, ...identity };\n}\n\nfunction setRelay(raw: MutablePajaRawOptions, relay: NonNullable<PajaSimulationRawOptions['relay']>): void {\n ensureSimulation(raw).relay = { ...raw.simulation?.relay, ...relay };\n}\n\nfunction setUpload(raw: MutablePajaRawOptions, upload: NonNullable<PajaSimulationRawOptions['upload']>): void {\n ensureSimulation(raw).upload = { ...raw.simulation?.upload, ...upload };\n}\n\nfunction setNotifications(\n raw: MutablePajaRawOptions,\n notifications: NonNullable<PajaSimulationRawOptions['notifications']>,\n): void {\n ensureSimulation(raw).notifications = { ...raw.simulation?.notifications, ...notifications };\n}\n\nfunction setConfigValue(\n raw: MutablePajaRawOptions,\n entry: { key: string; value: JsonValue },\n): void {\n ensureSimulation(raw).config = {\n ...raw.simulation?.config,\n values: {\n ...raw.simulation?.config?.values,\n [entry.key]: entry.value,\n },\n };\n}\n\nfunction setCapability(\n raw: MutablePajaRawOptions,\n entry: { domain: PajaCapabilityDomain; enabled: boolean },\n): void {\n ensureSimulation(raw).capabilities = {\n ...raw.simulation?.capabilities,\n domains: {\n ...raw.simulation?.capabilities?.domains,\n [entry.domain]: entry.enabled,\n },\n };\n}\n\nfunction ensureSimulation(raw: MutablePajaRawOptions): MutablePajaSimulationRawOptions {\n raw.simulation ??= {};\n return raw.simulation as MutablePajaSimulationRawOptions;\n}\n\nasync function resolveManagedTargetUrl(\n configuredUrl: string,\n child: ManagedChildProcess,\n options: {\n readonly timeoutMs: number;\n readonly discoveryGraceMs?: number;\n readonly waitForTargetUrl: typeof waitForTargetUrl;\n },\n): Promise<string> {\n let configuredError: unknown;\n const configuredReady = options.waitForTargetUrl(configuredUrl, { timeoutMs: options.timeoutMs })\n .then(() => configuredUrl)\n .catch((error) => {\n configuredError = error;\n return undefined;\n });\n const first = await Promise.race([\n configuredReady.then((url) => url ? { kind: 'configured' as const, url } : undefined),\n child.detectedTargetUrl.then((url) => ({ kind: 'detected' as const, url })),\n ]);\n\n if (first?.kind === 'detected') {\n await options.waitForTargetUrl(first.url, { timeoutMs: options.timeoutMs });\n return first.url;\n }\n\n const graceMs = options.discoveryGraceMs ?? Math.min(1000, options.timeoutMs);\n const detected = await resolveWithin(child.detectedTargetUrl, graceMs);\n if (!detected) {\n if (first?.url) {\n return first.url;\n }\n throw configuredError instanceof Error ? configuredError : new Error(String(configuredError ?? 'Target URL was not ready.'));\n }\n\n await options.waitForTargetUrl(detected, { timeoutMs: options.timeoutMs });\n return detected;\n}\n\nfunction resolveWithin<T>(promise: Promise<T>, timeoutMs: number): Promise<T | undefined> {\n return new Promise((resolve) => {\n let settled = false;\n const timeout = setTimeout(() => {\n if (settled) return;\n settled = true;\n resolve(undefined);\n }, Math.max(0, timeoutMs));\n\n promise.then((value) => {\n if (settled) return;\n settled = true;\n clearTimeout(timeout);\n resolve(value);\n }, () => {\n if (settled) return;\n settled = true;\n clearTimeout(timeout);\n resolve(undefined);\n });\n });\n}\n\nfunction startManagedCommand(command: PajaCommand, io: CliIo): ManagedChildProcess {\n const detector = createManagedTargetUrlDetector();\n const child = spawnManagedCommand(command);\n forwardManagedOutput(child, detector, io);\n return {\n kill: () => child.kill(),\n detectedTargetUrl: detector.detectedTargetUrl,\n };\n}\n\nfunction spawnManagedCommand(command: PajaCommand): ChildProcess {\n if (command.mode === 'shell') {\n return spawn(command.command, { shell: true, stdio: ['inherit', 'pipe', 'pipe'] as const });\n }\n\n const [executable, ...args] = command.argv;\n if (!executable) {\n throw new PajaOptionsError('Argv command mode requires an executable.');\n }\n return spawn(executable, args, { stdio: ['inherit', 'pipe', 'pipe'] as const });\n}\n\nfunction forwardManagedOutput(\n child: ChildProcess,\n detector: ManagedTargetUrlDetector,\n io: CliIo,\n): void {\n child.stdout?.on('data', (chunk: string | Uint8Array) => {\n const text = String(chunk);\n detector.observe(text);\n io.stdout.write(text);\n });\n child.stderr?.on('data', (chunk: string | Uint8Array) => {\n const text = String(chunk);\n detector.observe(text);\n io.stderr.write(text);\n });\n}\n\nfunction createManagedTargetUrlDetector(): ManagedTargetUrlDetector {\n let resolveDetected: (url: string) => void = () => {\n // Promise executor replaces this before any child-process output can arrive.\n };\n let detected: string | undefined;\n const detectedTargetUrl = new Promise<string>((resolve) => {\n resolveDetected = resolve;\n });\n\n return {\n detectedTargetUrl,\n observe(chunk) {\n if (detected) return;\n const text = stripAnsi(chunk);\n for (const match of text.matchAll(LOCAL_HTTP_URL_PATTERN)) {\n const rawUrl = match[0];\n let url: URL;\n try {\n url = new URL(rawUrl);\n } catch {\n continue;\n }\n detected = url.href;\n resolveDetected(detected);\n return;\n }\n },\n };\n}\n\nfunction stripAnsi(value: string): string {\n return value.replace(ANSI_PATTERN, '');\n}\n\ntype MutablePajaRawOptions = {\n -readonly [K in keyof PajaRawOptions]: PajaRawOptions[K];\n};\n\ntype MutablePajaSimulationRawOptions = {\n -readonly [K in keyof PajaSimulationRawOptions]: PajaSimulationRawOptions[K];\n};\n\nconst defaultIo: CliIo = {\n stdout: { write: (chunk) => process.stdout.write(chunk) },\n stderr: { write: (chunk) => process.stderr.write(chunk) },\n};\n\nif (isDirectPajaCli()) {\n void runPajaCli().then((code) => {\n process.exitCode = code;\n });\n}\n\n/**\n * Detect whether this module is running as the direct Paja CLI entrypoint.\n *\n * @param entryPath - Process entry path to inspect.\n * @returns `true` when the entry path looks like Paja's built CLI.\n */\nexport function isDirectPajaCli(entryPath = process.argv[1]): boolean {\n if (!entryPath) return false;\n return entryPath.endsWith('/cli.js') || entryPath.endsWith('/paja');\n}\n\ndeclare const process: {\n argv: string[];\n exitCode?: number;\n stdout: { write(chunk: string): void };\n stderr: { write(chunk: string): void };\n};\n\n/** Managed child process handle. */\nexport interface ManagedChildProcess {\n /** Stop the managed target process. */\n kill(): void;\n /** First local target URL detected from process output. */\n readonly detectedTargetUrl: Promise<string>;\n}\n\ninterface ManagedTargetUrlDetector {\n readonly detectedTargetUrl: Promise<string>;\n observe(chunk: string): void;\n}\n\nconst LOCAL_HTTP_URL_PATTERN = /https?:\\/\\/(?:localhost|127(?:\\.\\d{1,3}){3}|\\[::1\\])(?::\\d+)?(?:\\/[^\\s'\"<>)\\]]*)?/g;\nconst ANSI_PATTERN = /\\u001b\\[[0-?]*[ -/]*[@-~]/g;\n"],"mappings":";;;;;;;;;;;;;;AAMA,SAAS,aAAgC;AAyDlC,SAAS,cAAc,MAAyC;AACrE,QAAM,MAA6B,CAAC;AAEpC,WAAS,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;AACnD,UAAM,MAAM,KAAK,KAAK;AAEtB,QAAI,QAAQ,MAAM;AAChB,YAAM,OAAO,KAAK,MAAM,QAAQ,CAAC;AACjC,UAAI,UAAU,EAAE,MAAM,QAAQ,KAAK;AACnC;AAAA,IACF;AAEA,QAAI,QAAQ,YAAY,QAAQ,MAAM;AACpC,aAAO,EAAE,MAAM,KAAK;AAAA,IACtB;AAEA,QAAI,gBAAgB,KAAK,MAAM,OAAO,GAAG,KAAK,sBAAsB,KAAK,MAAM,OAAO,GAA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AAQO,SAAS,gBAAgB,YAAY,QAAQ,KAAK,CAAC,GAAY;AACpE,MAAI,CAAC,UAAW,QAAO;AACvB,SAAO,UAAU,SAAS,SAAS,KAAK,UAAU,SAAS,OAAO;AACpE;AAsBA,IAAM,yBAAyB;AAC/B,IAAM,eAAe;","names":[]}
1
+ {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * CLI entrypoint for running the Paja local authoring runtime.\n *\n * @module\n */\nimport { spawn, type ChildProcess } from 'node:child_process';\nimport {\n createPajaHostConfig,\n formatPajaUrl,\n normalizePajaOptions,\n waitForTargetUrl,\n type PajaCommand,\n type PajaRawOptions,\n PajaOptionsError,\n} from './index.js';\nimport { resolvePajaRawOptions } from './config-file.js';\nimport { startPajaServer } from './server.js';\nimport {\n PAJA_SIMULATION_DOMAINS,\n summarizePajaSimulation,\n type PajaCapabilityDomain,\n type PajaSimulationRawOptions,\n type JsonValue,\n} from './simulation.js';\n\n/**\n * Minimal output streams used by the CLI runner.\n *\n * @remarks\n * Tests and embedders can pass custom streams to capture output without\n * patching global `process.stdout` or `process.stderr`.\n */\nexport interface CliIo {\n readonly stdout: { write(chunk: string): void };\n readonly stderr: { write(chunk: string): void };\n}\n\n/**\n * Parsed CLI arguments before full option normalization.\n */\nexport interface CliParseResult {\n readonly options?: PajaRawOptions;\n readonly help: boolean;\n}\n\n/**\n * Execution controls for embedding the CLI runner in tests or wrappers.\n */\nexport interface RunPajaCliOptions {\n readonly serve?: boolean;\n readonly startServer?: typeof startPajaServer;\n readonly startCommand?: (command: PajaCommand, io: CliIo) => ManagedChildProcess;\n readonly waitForTargetUrl?: typeof waitForTargetUrl;\n readonly targetDiscoveryGraceMs?: number;\n}\n\n/**\n * Parse raw `kehto paja` arguments into raw runtime options.\n *\n * @param args - Argument vector without the node executable or script path.\n * @returns Parsed raw options, or a help flag when `--help` is present.\n */\nexport function parsePajaArgs(args: readonly string[]): CliParseResult {\n const raw: MutablePajaRawOptions = {};\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index];\n\n if (arg === '--') {\n const argv = args.slice(index + 1);\n raw.command = { mode: 'argv', argv };\n break;\n }\n\n if (arg === '--help' || arg === '-h') {\n return { help: true };\n }\n\n if (applyCoreOption(arg, args, index, raw) || applySimulationOption(arg, args, index, raw)) {\n index += 1;\n continue;\n }\n\n throw new PajaOptionsError(`Unknown option \"${arg}\". Run kehto paja --help for usage.`);\n }\n\n return { help: false, options: raw };\n}\n\n/**\n * Run the Paja CLI command.\n *\n * @param args - Argument vector without the node executable or script path.\n * @param io - Output streams used by the command.\n * @param runOptions - Test/embedding controls for server and process spawning.\n * @returns Process exit code.\n */\nexport async function runPajaCli(\n args: readonly string[] = process.argv.slice(2),\n io: CliIo = defaultIo,\n runOptions: RunPajaCliOptions = {},\n): Promise<number> {\n try {\n const parsed = parsePajaArgs(args);\n if (parsed.help) {\n io.stdout.write(`${HELP_TEXT}\\n`);\n return 0;\n }\n\n const rawOptions = resolvePajaRawOptions(parsed.options ?? {});\n const options = normalizePajaOptions(rawOptions);\n const hostConfig = createPajaHostConfig(options);\n const shouldServe = runOptions.serve ?? true;\n const startServer = runOptions.startServer ?? startPajaServer;\n const startCommand = runOptions.startCommand ?? startManagedCommand;\n const waitForTarget = runOptions.waitForTargetUrl ?? waitForTargetUrl;\n let child: ManagedChildProcess | undefined;\n let server: Awaited<ReturnType<typeof startPajaServer>> | undefined;\n if (shouldServe) {\n try {\n server = await startServer({ options: rawOptions });\n writeRuntimeSummary(io, server.url, hostConfig, options);\n\n if (options.command) {\n child = startCommand(options.command, io);\n const targetUrl = await resolveManagedTargetUrl(options.targetUrl, child, {\n timeoutMs: options.readyTimeoutMs,\n discoveryGraceMs: runOptions.targetDiscoveryGraceMs,\n waitForTargetUrl: waitForTarget,\n });\n if (targetUrl !== options.targetUrl) {\n server.updateTargetUrl(targetUrl);\n io.stdout.write(`Target URL updated: ${targetUrl}\\n`);\n }\n }\n } catch (error) {\n child?.kill();\n await server?.close().catch(() => undefined);\n throw error;\n }\n }\n const runtimeUrl = server?.url ?? formatPajaUrl(options);\n\n if (!shouldServe) {\n writeRuntimeSummary(io, runtimeUrl, hostConfig, options);\n }\n\n return 0;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n io.stderr.write(`kehto paja: ${message}\\n`);\n return 1;\n }\n}\n\nfunction writeRuntimeSummary(\n io: CliIo,\n runtimeUrl: string,\n hostConfig: ReturnType<typeof createPajaHostConfig>,\n options: ReturnType<typeof normalizePajaOptions>,\n): void {\n io.stdout.write(`Kehto Paja\\n`);\n io.stdout.write(`Runtime URL: ${runtimeUrl}\\n`);\n io.stdout.write(`Target URL: ${hostConfig.target.url}\\n`);\n io.stdout.write(`Mode: ${options.mode}\\n`);\n io.stdout.write(`HMR: ${hostConfig.target.hmrStrategy}\\n`);\n io.stdout.write(`Simulation: ${summarizePajaSimulation(options.simulation)}\\n`);\n\n if (options.command) {\n io.stdout.write(`Command: ${formatCommand(options.command)}\\n`);\n }\n}\n\nconst HELP_TEXT = `Usage:\n kehto paja --target-url <url> [options]\n kehto paja --target-url <url> [options] -- <command...>\n\nOptions:\n --target-url, -u <url> App dev-server URL to load in the runtime iframe.\n --command, -c <command> Shell command to start before waiting for target URL.\n -- <command...> Argv command form; preserves arbitrary framework commands.\n --host <host> Runtime host. Default: 127.0.0.1.\n --port <port> Runtime port. Default: 5197.\n --ready-timeout <ms> Target readiness timeout. Default: 30000.\n --config <path> JSON config file using the same option schema.\n --nested-context-lock <v> Experimental frame-creation lock: on, off, or auto\n (default; on for napplets granted a private domain).\n --identity-mode <mode> anonymous or fixed.\n --identity-pubkey <hex> Required when identity mode is fixed.\n --relay-mode <mode> live, memory, or disabled.\n --relay-url <url> Add a relay URL for live or memory relay backends.\n --storage-mode <mode> local, memory, or disabled.\n --cache-mode <mode> memory or disabled.\n --upload-mode <mode> memory, blossom, or disabled.\n --upload-rail <name> Upload rail name for memory uploads.\n --upload-server <url> Add a shell-owned Blossom server (repeatable).\n --media <state> enabled or disabled.\n --notifications <state> enabled or disabled.\n --notify-grant <bool> Allow or block interactive notification permission prompts.\n --theme <mode> dark or light.\n --config-value <key=json> Add a JSON config value.\n --capability <domain:on|off> Toggle an advertised capability domain.\n --acl-mode <mode> allow or deny.\n --help, -h Show this help.`;\n\nfunction readValue(args: readonly string[], index: number, option: string): string {\n const value = args[index + 1];\n if (!value || value.startsWith('--')) {\n throw new PajaOptionsError(`${option} requires a value.`);\n }\n return value;\n}\n\nfunction applyCoreOption(\n arg: string,\n args: readonly string[],\n index: number,\n raw: MutablePajaRawOptions,\n): boolean {\n switch (arg) {\n case '--target-url':\n case '-u':\n raw.targetUrl = readValue(args, index, arg);\n return true;\n case '--command':\n case '-c':\n raw.command = { mode: 'shell', command: readValue(args, index, arg) };\n return true;\n case '--host':\n raw.host = readValue(args, index, arg);\n return true;\n case '--port':\n raw.port = readValue(args, index, arg);\n return true;\n case '--ready-timeout':\n raw.readyTimeoutMs = readValue(args, index, arg);\n return true;\n case '--config':\n raw.configPath = readValue(args, index, arg);\n return true;\n case '--nested-context-lock':\n raw.experimental = {\n nestedContextLock: readEnum(args, index, arg, ['on', 'off', 'auto'] as const),\n };\n return true;\n default:\n return false;\n }\n}\n\nfunction applySimulationOption(\n arg: string,\n args: readonly string[],\n index: number,\n raw: MutablePajaRawOptions,\n): boolean {\n switch (arg) {\n case '--identity-mode':\n setIdentity(raw, { mode: readEnum(args, index, arg, ['anonymous', 'fixed']) });\n return true;\n case '--identity-pubkey':\n setIdentity(raw, { pubkey: readValue(args, index, arg) });\n return true;\n case '--relay-mode':\n setRelay(raw, { mode: readEnum(args, index, arg, ['live', 'memory', 'disabled']) });\n return true;\n case '--relay-url':\n setRelay(raw, { urls: [...(raw.simulation?.relay?.urls ?? []), readValue(args, index, arg)] });\n return true;\n case '--storage-mode':\n ensureSimulation(raw).storage = { ...raw.simulation?.storage, mode: readEnum(args, index, arg, ['local', 'memory', 'disabled']) };\n return true;\n case '--cache-mode':\n ensureSimulation(raw).cache = { ...raw.simulation?.cache, mode: readEnum(args, index, arg, ['memory', 'disabled']) };\n return true;\n case '--upload-mode':\n setUpload(raw, { mode: readEnum(args, index, arg, ['memory', 'blossom', 'disabled']) });\n return true;\n case '--upload-rail':\n setUpload(raw, { rail: readValue(args, index, arg) });\n return true;\n case '--upload-server':\n setUpload(raw, { servers: [...(raw.simulation?.upload?.servers ?? []), readValue(args, index, arg)] });\n return true;\n case '--media':\n ensureSimulation(raw).media = { ...raw.simulation?.media, enabled: readEnabled(args, index, arg) };\n return true;\n case '--notifications':\n setNotifications(raw, { enabled: readEnabled(args, index, arg) });\n return true;\n case '--notify-grant':\n setNotifications(raw, { grant: readBoolean(args, index, arg) });\n return true;\n case '--theme':\n ensureSimulation(raw).theme = { ...raw.simulation?.theme, mode: readEnum(args, index, arg, ['dark', 'light']) };\n return true;\n case '--config-value':\n setConfigValue(raw, readConfigValue(args, index, arg));\n return true;\n case '--capability':\n setCapability(raw, readCapability(args, index, arg));\n return true;\n case '--acl-mode':\n ensureSimulation(raw).acl = { ...raw.simulation?.acl, mode: readEnum(args, index, arg, ['allow', 'deny']) };\n return true;\n case '--firewall-mode':\n throw new PajaOptionsError('--firewall-mode was removed; approve exact scopes in Paja Firewall grants.');\n default:\n return false;\n }\n}\n\nfunction formatCommand(command: PajaCommand): string {\n return command.mode === 'argv' ? command.argv.join(' ') : command.command;\n}\n\nfunction readEnum<const T extends readonly string[]>(\n args: readonly string[],\n index: number,\n option: string,\n allowed: T,\n): T[number] {\n const value = readValue(args, index, option);\n if (!allowed.includes(value)) {\n throw new PajaOptionsError(`${option} must be one of: ${allowed.join(', ')}.`);\n }\n return value;\n}\n\nfunction readEnabled(args: readonly string[], index: number, option: string): boolean {\n const value = readValue(args, index, option);\n if (value === 'enabled') return true;\n if (value === 'disabled') return false;\n throw new PajaOptionsError(`${option} must be \"enabled\" or \"disabled\".`);\n}\n\nfunction readBoolean(args: readonly string[], index: number, option: string): boolean {\n const value = readValue(args, index, option);\n if (value === 'true') return true;\n if (value === 'false') return false;\n throw new PajaOptionsError(`${option} must be \"true\" or \"false\".`);\n}\n\nfunction readConfigValue(\n args: readonly string[],\n index: number,\n option: string,\n): { key: string; value: JsonValue } {\n const raw = readValue(args, index, option);\n const separator = raw.indexOf('=');\n if (separator <= 0) {\n throw new PajaOptionsError(`${option} expects key=json.`);\n }\n const key = raw.slice(0, separator).trim();\n if (!key) {\n throw new PajaOptionsError(`${option} expects a non-empty key.`);\n }\n try {\n return { key, value: JSON.parse(raw.slice(separator + 1)) as JsonValue };\n } catch {\n throw new PajaOptionsError(`${option} value for \"${key}\" must be valid JSON.`);\n }\n}\n\nfunction readCapability(\n args: readonly string[],\n index: number,\n option: string,\n): { domain: PajaCapabilityDomain; enabled: boolean } {\n const raw = readValue(args, index, option);\n const [domainRaw, stateRaw] = raw.split(':') as [string | undefined, string | undefined];\n if (!domainRaw || (stateRaw !== 'on' && stateRaw !== 'off')) {\n throw new PajaOptionsError(`${option} expects domain:on or domain:off.`);\n }\n if (!PAJA_SIMULATION_DOMAINS.includes(domainRaw as PajaCapabilityDomain)) {\n throw new PajaOptionsError(`${option} unknown domain \"${domainRaw}\".`);\n }\n return {\n domain: domainRaw as PajaCapabilityDomain,\n enabled: stateRaw === 'on',\n };\n}\n\nfunction setIdentity(raw: MutablePajaRawOptions, identity: NonNullable<PajaSimulationRawOptions['identity']>): void {\n ensureSimulation(raw).identity = { ...raw.simulation?.identity, ...identity };\n}\n\nfunction setRelay(raw: MutablePajaRawOptions, relay: NonNullable<PajaSimulationRawOptions['relay']>): void {\n ensureSimulation(raw).relay = { ...raw.simulation?.relay, ...relay };\n}\n\nfunction setUpload(raw: MutablePajaRawOptions, upload: NonNullable<PajaSimulationRawOptions['upload']>): void {\n ensureSimulation(raw).upload = { ...raw.simulation?.upload, ...upload };\n}\n\nfunction setNotifications(\n raw: MutablePajaRawOptions,\n notifications: NonNullable<PajaSimulationRawOptions['notifications']>,\n): void {\n ensureSimulation(raw).notifications = { ...raw.simulation?.notifications, ...notifications };\n}\n\nfunction setConfigValue(\n raw: MutablePajaRawOptions,\n entry: { key: string; value: JsonValue },\n): void {\n ensureSimulation(raw).config = {\n ...raw.simulation?.config,\n values: {\n ...raw.simulation?.config?.values,\n [entry.key]: entry.value,\n },\n };\n}\n\nfunction setCapability(\n raw: MutablePajaRawOptions,\n entry: { domain: PajaCapabilityDomain; enabled: boolean },\n): void {\n ensureSimulation(raw).capabilities = {\n ...raw.simulation?.capabilities,\n domains: {\n ...raw.simulation?.capabilities?.domains,\n [entry.domain]: entry.enabled,\n },\n };\n}\n\nfunction ensureSimulation(raw: MutablePajaRawOptions): MutablePajaSimulationRawOptions {\n raw.simulation ??= {};\n return raw.simulation as MutablePajaSimulationRawOptions;\n}\n\nasync function resolveManagedTargetUrl(\n configuredUrl: string,\n child: ManagedChildProcess,\n options: {\n readonly timeoutMs: number;\n readonly discoveryGraceMs?: number;\n readonly waitForTargetUrl: typeof waitForTargetUrl;\n },\n): Promise<string> {\n let configuredError: unknown;\n const configuredReady = options.waitForTargetUrl(configuredUrl, { timeoutMs: options.timeoutMs })\n .then(() => configuredUrl)\n .catch((error) => {\n configuredError = error;\n return undefined;\n });\n const first = await Promise.race([\n configuredReady.then((url) => url ? { kind: 'configured' as const, url } : undefined),\n child.detectedTargetUrl.then((url) => ({ kind: 'detected' as const, url })),\n ]);\n\n if (first?.kind === 'detected') {\n await options.waitForTargetUrl(first.url, { timeoutMs: options.timeoutMs });\n return first.url;\n }\n\n const graceMs = options.discoveryGraceMs ?? Math.min(1000, options.timeoutMs);\n const detected = await resolveWithin(child.detectedTargetUrl, graceMs);\n if (!detected) {\n if (first?.url) {\n return first.url;\n }\n throw configuredError instanceof Error ? configuredError : new Error(String(configuredError ?? 'Target URL was not ready.'));\n }\n\n await options.waitForTargetUrl(detected, { timeoutMs: options.timeoutMs });\n return detected;\n}\n\nfunction resolveWithin<T>(promise: Promise<T>, timeoutMs: number): Promise<T | undefined> {\n return new Promise((resolve) => {\n let settled = false;\n const timeout = setTimeout(() => {\n if (settled) return;\n settled = true;\n resolve(undefined);\n }, Math.max(0, timeoutMs));\n\n promise.then((value) => {\n if (settled) return;\n settled = true;\n clearTimeout(timeout);\n resolve(value);\n }, () => {\n if (settled) return;\n settled = true;\n clearTimeout(timeout);\n resolve(undefined);\n });\n });\n}\n\nfunction startManagedCommand(command: PajaCommand, io: CliIo): ManagedChildProcess {\n const detector = createManagedTargetUrlDetector();\n const child = spawnManagedCommand(command);\n forwardManagedOutput(child, detector, io);\n return {\n kill: () => child.kill(),\n detectedTargetUrl: detector.detectedTargetUrl,\n };\n}\n\nfunction spawnManagedCommand(command: PajaCommand): ChildProcess {\n if (command.mode === 'shell') {\n return spawn(command.command, { shell: true, stdio: ['inherit', 'pipe', 'pipe'] as const });\n }\n\n const [executable, ...args] = command.argv;\n if (!executable) {\n throw new PajaOptionsError('Argv command mode requires an executable.');\n }\n return spawn(executable, args, { stdio: ['inherit', 'pipe', 'pipe'] as const });\n}\n\nfunction forwardManagedOutput(\n child: ChildProcess,\n detector: ManagedTargetUrlDetector,\n io: CliIo,\n): void {\n child.stdout?.on('data', (chunk: string | Uint8Array) => {\n const text = String(chunk);\n detector.observe(text);\n io.stdout.write(text);\n });\n child.stderr?.on('data', (chunk: string | Uint8Array) => {\n const text = String(chunk);\n detector.observe(text);\n io.stderr.write(text);\n });\n}\n\nfunction createManagedTargetUrlDetector(): ManagedTargetUrlDetector {\n let resolveDetected: (url: string) => void = () => {\n // Promise executor replaces this before any child-process output can arrive.\n };\n let detected: string | undefined;\n const detectedTargetUrl = new Promise<string>((resolve) => {\n resolveDetected = resolve;\n });\n\n return {\n detectedTargetUrl,\n observe(chunk) {\n if (detected) return;\n const text = stripAnsi(chunk);\n for (const match of text.matchAll(LOCAL_HTTP_URL_PATTERN)) {\n const rawUrl = match[0];\n let url: URL;\n try {\n url = new URL(rawUrl);\n } catch {\n continue;\n }\n detected = url.href;\n resolveDetected(detected);\n return;\n }\n },\n };\n}\n\nfunction stripAnsi(value: string): string {\n return value.replace(ANSI_PATTERN, '');\n}\n\ntype MutablePajaRawOptions = {\n -readonly [K in keyof PajaRawOptions]: PajaRawOptions[K];\n};\n\ntype MutablePajaSimulationRawOptions = {\n -readonly [K in keyof PajaSimulationRawOptions]: PajaSimulationRawOptions[K];\n};\n\nconst defaultIo: CliIo = {\n stdout: { write: (chunk) => process.stdout.write(chunk) },\n stderr: { write: (chunk) => process.stderr.write(chunk) },\n};\n\nif (isDirectPajaCli()) {\n void runPajaCli().then((code) => {\n process.exitCode = code;\n });\n}\n\n/**\n * Detect whether this module is running as the direct Paja CLI entrypoint.\n *\n * @param entryPath - Process entry path to inspect.\n * @returns `true` when the entry path looks like Paja's built CLI.\n */\nexport function isDirectPajaCli(entryPath = process.argv[1]): boolean {\n if (!entryPath) return false;\n return entryPath.endsWith('/cli.js') || entryPath.endsWith('/paja');\n}\n\ndeclare const process: {\n argv: string[];\n exitCode?: number;\n stdout: { write(chunk: string): void };\n stderr: { write(chunk: string): void };\n};\n\n/** Managed child process handle. */\nexport interface ManagedChildProcess {\n /** Stop the managed target process. */\n kill(): void;\n /** First local target URL detected from process output. */\n readonly detectedTargetUrl: Promise<string>;\n}\n\ninterface ManagedTargetUrlDetector {\n readonly detectedTargetUrl: Promise<string>;\n observe(chunk: string): void;\n}\n\nconst LOCAL_HTTP_URL_PATTERN = /https?:\\/\\/(?:localhost|127(?:\\.\\d{1,3}){3}|\\[::1\\])(?::\\d+)?(?:\\/[^\\s'\"<>)\\]]*)?/g;\nconst ANSI_PATTERN = /\\u001b\\[[0-?]*[ -/]*[@-~]/g;\n"],"mappings":";;;;;;;;;;;;;;AAMA,SAAS,aAAgC;AAyDlC,SAAS,cAAc,MAAyC;AACrE,QAAM,MAA6B,CAAC;AAEpC,WAAS,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;AACnD,UAAM,MAAM,KAAK,KAAK;AAEtB,QAAI,QAAQ,MAAM;AAChB,YAAM,OAAO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AM,KAAK,EAAE;AAC1D;AAEA,IAAI,gBAAgB,GAAG;AACrB,OAAK,WAAW,EAAE,KAAK,CAAC,SAAS;AAC/B,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;AAQO,SAAS,gBAAgB,YAAY,QAAQ,KAAK,CAAC,GAAY;AACpE,MAAI,CAAC,UAAW,QAAO;AACvB,SAAO,UAAU,SAAS,SAAS,KAAK,UAAU,SAAS,OAAO;AACpE;AAsBA,IAAM,yBAAyB;AAC/B,IAAM,eAAe;","names":[]}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PajaRawOptions, b as PajaHostConfig } from './server-bAe1oDUG.js';
2
- export { D as DEFAULT_PAJA_AGGREGATE_HASH, c as DEFAULT_PAJA_DTAG, d as DEFAULT_PAJA_HOST, e as DEFAULT_PAJA_PORT, f as DEFAULT_PAJA_RUNTIME_WAIT_MS, g as DEFAULT_PAJA_WINDOW_ID, h as DEFAULT_READY_TIMEOUT_MS, J as JsonPrimitive, i as JsonRecord, j as JsonValue, k as PAJA_SIMULATION_DOMAINS, l as PajaCapabilityDomain, a as PajaCommand, m as PajaExperimentalConfig, n as PajaHmrStrategy, o as PajaNestedContextLockSetting, p as PajaOptions, q as PajaOptionsError, r as PajaPointerRuntimeConfig, t as PajaServer, u as PajaServerOptions, v as PajaSimulation, x as PajaSimulationError, y as PajaSimulationRawOptions, z as PajaTargetMode, R as ReadinessError, A as ReadinessFetch, W as WaitForTargetUrlOptions, B as createPajaHostConfig, C as createPajaRuntimeHostConfig, E as formatPajaUrl, F as normalizePajaOptions, G as normalizePajaSimulation, s as startPajaServer, H as summarizePajaSimulation, w as waitForTargetUrl } from './server-bAe1oDUG.js';
1
+ import { P as PajaRawOptions, b as PajaHostConfig } from './server-B7uqpu8g.js';
2
+ export { D as DEFAULT_PAJA_AGGREGATE_HASH, c as DEFAULT_PAJA_DTAG, d as DEFAULT_PAJA_HOST, e as DEFAULT_PAJA_PORT, f as DEFAULT_PAJA_RUNTIME_WAIT_MS, g as DEFAULT_PAJA_WINDOW_ID, h as DEFAULT_READY_TIMEOUT_MS, J as JsonPrimitive, i as JsonRecord, j as JsonValue, k as PAJA_SIMULATION_DOMAINS, l as PajaCapabilityDomain, a as PajaCommand, m as PajaExperimentalConfig, n as PajaHmrStrategy, o as PajaNestedContextLockSetting, p as PajaOptions, q as PajaOptionsError, r as PajaPointerRuntimeConfig, t as PajaServer, u as PajaServerOptions, v as PajaSimulation, x as PajaSimulationError, y as PajaSimulationRawOptions, z as PajaTargetMode, R as ReadinessError, A as ReadinessFetch, W as WaitForTargetUrlOptions, B as createPajaHostConfig, C as createPajaRuntimeHostConfig, E as formatPajaUrl, F as normalizePajaOptions, G as normalizePajaSimulation, s as startPajaServer, H as summarizePajaSimulation, w as waitForTargetUrl } from './server-B7uqpu8g.js';
3
3
  import { NostrEvent } from 'nostr-tools';
4
4
  import { Filter } from 'nostr-tools/filter';
5
5
  import { ResolvedNapplet } from '@kehto/nip/5d';
@@ -854,6 +854,7 @@ declare function createPajaLlmHost(options: PajaLlmHostOptions): PajaLlmHost;
854
854
  * These helpers probe the target with an explicit `Origin: null` request so
855
855
  * Paja can report the cause instead of leaving an empty frame behind.
856
856
  */
857
+
857
858
  /** Whether the target dev server will serve the sandboxed frame's subresources. */
858
859
  type PajaTargetCorsStatus = 'allowed' | 'blocked' | 'unreachable';
859
860
  /** Result of probing a target dev server for opaque-origin CORS support. */
package/dist/index.js CHANGED
@@ -59,7 +59,7 @@ import {
59
59
  summarizePajaSimulation,
60
60
  validatePajaLlmVaultPassword,
61
61
  waitForTargetUrl
62
- } from "./chunk-DDYBKY5L.js";
62
+ } from "./chunk-ZAIBJIBA.js";
63
63
  export {
64
64
  BrowserIntentController,
65
65
  DEFAULT_PAJA_AGGREGATE_HASH,
@@ -20,9 +20,6 @@ interface PajaSimulationRawOptions {
20
20
  readonly acl?: {
21
21
  readonly mode?: 'allow' | 'deny';
22
22
  };
23
- readonly firewall?: {
24
- readonly mode?: 'allow' | 'deny' | 'observe';
25
- };
26
23
  readonly identity?: {
27
24
  readonly mode?: 'anonymous' | 'fixed';
28
25
  readonly pubkey?: string;
@@ -77,9 +74,6 @@ interface PajaSimulation {
77
74
  readonly acl: {
78
75
  readonly mode: 'allow' | 'deny';
79
76
  };
80
- readonly firewall: {
81
- readonly mode: 'allow' | 'deny' | 'observe';
82
- };
83
77
  readonly identity: {
84
78
  readonly mode: 'anonymous' | 'fixed';
85
79
  readonly pubkey: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kehto/paja",
3
- "version": "0.32.0",
3
+ "version": "0.33.0",
4
4
  "description": "Paja local authoring workshop for hosting napplets in a real Kehto iframe during development",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -26,12 +26,12 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@kehto/acl": "^0.20.3",
29
- "@kehto/firewall": "^0.6.4",
30
29
  "@kehto/nip": "^0.8.0",
31
- "@kehto/runtime": "^0.27.3",
32
- "@kehto/services": "^0.30.0",
33
- "@kehto/shell": "^0.31.0",
34
- "@kehto/wm": "^0.0.2"
30
+ "@kehto/runtime": "^0.29.0",
31
+ "@kehto/shell": "^0.33.0",
32
+ "@kehto/firewall": "^0.8.0",
33
+ "@kehto/wm": "^0.0.2",
34
+ "@kehto/services": "^0.31.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@napplet/core": ">=0.38.0 <0.39.0",