@forthix/forthic
Advanced tools
| import { z } from "zod"; | ||
| /** | ||
| * Registry metadata types for stack objects and class instances. | ||
| */ | ||
| type StackObjectMetadata = { | ||
| objectType: "stackObject"; | ||
| stackObjectType: string; | ||
| className?: undefined; | ||
| OriginalClass?: undefined; | ||
| } | { | ||
| objectType: "class"; | ||
| OriginalClass: new (...args: any[]) => any; | ||
| className: string; | ||
| stackObjectType?: undefined; | ||
| }; | ||
| /** | ||
| * Track metadata for schema comparison in tests and documentation. | ||
| * Only required for schemas that can't be compared out of the box, | ||
| * like custom schemas or instanceof schemas. | ||
| */ | ||
| export declare const stackObjectRegistry: z.core.$ZodRegistry<StackObjectMetadata, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>; | ||
| /** | ||
| * Creates a Zod schema for stack objects that have a stackObjectType property. | ||
| * This is a helper to reduce boilerplate when creating custom stack object schemas. | ||
| * It also ensures the schema is registered in stackObjectRegistry, which enables | ||
| * proper type string generation in stack effects. | ||
| * | ||
| * Use this instead of z.custom() directly for stack objects. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * interface StackEmail { | ||
| * stackObjectType: "email"; | ||
| * to: string; | ||
| * subject: string; | ||
| * body: string; | ||
| * } | ||
| * | ||
| * const stackEmailSchema = createStackObjectSchema<StackEmail>("email"); | ||
| * | ||
| * // Use in stack effect: | ||
| * @ForthicWord(se`(email:${stackEmailSchema} -- sent:${z.boolean()})`, "Send email") | ||
| * async SEND(email: StackEmail): Promise<boolean> { ... } | ||
| * ``` | ||
| */ | ||
| export declare function createStackObjectSchema<T extends { | ||
| stackObjectType: string; | ||
| }>(stackObjectType: string, errorMessage?: string): z.ZodCustom<T>; | ||
| /** | ||
| * Creates a Zod instanceof schema with automatic metadata registration. | ||
| * This ensures the schema is registered in stackObjectRegistry, which enables | ||
| * proper type string generation in stack effects. | ||
| * | ||
| * Use this instead of z.instanceof() directly. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * import { Temporal } from "temporal-polyfill"; | ||
| * | ||
| * const plainDateSchema = createInstanceOfSchema(Temporal.PlainDate); | ||
| * | ||
| * // Use in stack effect: | ||
| * @ForthicWord(se`(date:${plainDateSchema} -- formatted:${z.string()})`, "Format date") | ||
| * async FORMAT(date: Temporal.PlainDate): Promise<string> { ... } | ||
| * ``` | ||
| */ | ||
| export declare function createInstanceOfSchema<T extends abstract new (...args: any[]) => any>(ClassToSchematize: T, | ||
| /** If not passed, falls back to class.name */ | ||
| className?: string): z.ZodType<InstanceType<T>>; | ||
| export {}; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.stackObjectRegistry = void 0; | ||
| exports.createStackObjectSchema = createStackObjectSchema; | ||
| exports.createInstanceOfSchema = createInstanceOfSchema; | ||
| const zod_1 = require("zod"); | ||
| /** | ||
| * Track metadata for schema comparison in tests and documentation. | ||
| * Only required for schemas that can't be compared out of the box, | ||
| * like custom schemas or instanceof schemas. | ||
| */ | ||
| exports.stackObjectRegistry = zod_1.z.registry(); | ||
| /** | ||
| * Creates a Zod schema for stack objects that have a stackObjectType property. | ||
| * This is a helper to reduce boilerplate when creating custom stack object schemas. | ||
| * It also ensures the schema is registered in stackObjectRegistry, which enables | ||
| * proper type string generation in stack effects. | ||
| * | ||
| * Use this instead of z.custom() directly for stack objects. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * interface StackEmail { | ||
| * stackObjectType: "email"; | ||
| * to: string; | ||
| * subject: string; | ||
| * body: string; | ||
| * } | ||
| * | ||
| * const stackEmailSchema = createStackObjectSchema<StackEmail>("email"); | ||
| * | ||
| * // Use in stack effect: | ||
| * @ForthicWord(se`(email:${stackEmailSchema} -- sent:${z.boolean()})`, "Send email") | ||
| * async SEND(email: StackEmail): Promise<boolean> { ... } | ||
| * ``` | ||
| */ | ||
| function createStackObjectSchema(stackObjectType, errorMessage) { | ||
| const schema = zod_1.z.custom((maybeStackObject) => maybeStackObject?.stackObjectType === stackObjectType, errorMessage ?? `expected ${stackObjectType} stackObjectType`); | ||
| // Register schema with metadata | ||
| exports.stackObjectRegistry.add(schema, { | ||
| objectType: "stackObject", | ||
| stackObjectType, | ||
| }); | ||
| return schema; | ||
| } | ||
| /** | ||
| * Creates a Zod instanceof schema with automatic metadata registration. | ||
| * This ensures the schema is registered in stackObjectRegistry, which enables | ||
| * proper type string generation in stack effects. | ||
| * | ||
| * Use this instead of z.instanceof() directly. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * import { Temporal } from "temporal-polyfill"; | ||
| * | ||
| * const plainDateSchema = createInstanceOfSchema(Temporal.PlainDate); | ||
| * | ||
| * // Use in stack effect: | ||
| * @ForthicWord(se`(date:${plainDateSchema} -- formatted:${z.string()})`, "Format date") | ||
| * async FORMAT(date: Temporal.PlainDate): Promise<string> { ... } | ||
| * ``` | ||
| */ | ||
| function createInstanceOfSchema(ClassToSchematize, | ||
| /** If not passed, falls back to class.name */ | ||
| className) { | ||
| const schema = zod_1.z.instanceof(ClassToSchematize); | ||
| // Register schema with metadata | ||
| const resolvedClassName = className ?? ClassToSchematize.name; | ||
| exports.stackObjectRegistry.add(schema, { | ||
| objectType: "class", | ||
| OriginalClass: ClassToSchematize, | ||
| className: resolvedClassName, | ||
| }); | ||
| return schema; | ||
| } | ||
| //# sourceMappingURL=schemaUtils.js.map |
| {"version":3,"file":"schemaUtils.js","sourceRoot":"","sources":["../../../../src/forthic/decorators/schemaUtils.ts"],"names":[],"mappings":";;;AAkDA,0DAgBC;AAoBD,wDAgBC;AAtGD,6BAAwB;AAmBxB;;;;GAIG;AACU,QAAA,mBAAmB,GAAG,OAAC,CAAC,QAAQ,EAAuB,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,uBAAuB,CACrC,eAAuB,EACvB,YAAqB;IAErB,MAAM,MAAM,GAAG,OAAC,CAAC,MAAM,CACrB,CAAC,gBAAgB,EAAE,EAAE,CAAE,gBAAkC,EAAE,eAAe,KAAK,eAAe,EAC9F,YAAY,IAAI,YAAY,eAAe,kBAAkB,CAC9D,CAAC;IAEF,gCAAgC;IAChC,2BAAmB,CAAC,GAAG,CAAC,MAAM,EAAE;QAC9B,UAAU,EAAE,aAAa;QACzB,eAAe;KAChB,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,sBAAsB,CACpC,iBAAoB;AACpB,8CAA8C;AAC9C,SAAkB;IAElB,MAAM,MAAM,GAAG,OAAC,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAE/C,gCAAgC;IAChC,MAAM,iBAAiB,GAAG,SAAS,IAAI,iBAAiB,CAAC,IAAI,CAAC;IAC9D,2BAAmB,CAAC,GAAG,CAAC,MAAM,EAAE;QAC9B,UAAU,EAAE,OAAO;QACnB,aAAa,EAAE,iBAAiB;QAChC,SAAS,EAAE,iBAAiB;KAC7B,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"} |
| import { z } from "zod"; | ||
| import type { util as zodUtil } from "zod/v4/core"; | ||
| /** | ||
| * Map the set of Zod types to the strings we use in Forthic stack effects. | ||
| * Uses Zod's internal def.type for comprehensive type detection. | ||
| */ | ||
| export declare const mapZodToStackEffectType: (zodType: z.ZodTypeAny) => string; | ||
| type InferTupleTypes<T extends zodUtil.TupleItems> = { | ||
| [K in keyof T]: T[K] extends z.ZodTypeAny ? z.infer<T[K]> : never; | ||
| }; | ||
| /** | ||
| * Represents a type-safe stack effect with Zod schemas for validation. | ||
| * | ||
| * @template Args - Tuple of Zod schemas for input parameters | ||
| * @template Return - Zod schema for the return type | ||
| */ | ||
| export type TaggedStackEffect<Args extends zodUtil.TupleItems, Return extends z.core.$ZodFunctionOut = z.core.$ZodFunctionOut> = { | ||
| /** The human-readable stack effect string (e.g., "( a:number b:string -- result:string )") */ | ||
| stackEffect: string; | ||
| /** Zod schemas for runtime validation */ | ||
| schema: { | ||
| inputSchemas: z.ZodTypeAny[]; | ||
| outputSchema: z.ZodTypeAny; | ||
| }; | ||
| /** | ||
| * Phantom property to convey the expected function signature, constructed from the input + output types. | ||
| * DO NOT USE AT RUNTIME - it's only used for type inference. | ||
| */ | ||
| _implType: (...args: InferTupleTypes<Args>) => Promise<z.infer<Return>>; | ||
| }; | ||
| /** | ||
| * Tagged template literal for stack effects. Use with the @ForthicWord decorator to | ||
| * create a type-safe stack effect. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * // Type-safe stack effect with Zod validation | ||
| * @ForthicWord(se`(a:${z.number()} b:${z.string()} -- result:${z.string()})`, "Concatenate number and string") | ||
| * async CONCAT(a: number, b: string): Promise<string> { | ||
| * return `${a}${b}`; | ||
| * } | ||
| * ``` | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * // No parameters, returns string | ||
| * @ForthicWord(se`( -- message:${z.string()})`, "Get greeting") | ||
| * async GREET(): Promise<string> { | ||
| * return "Hello!"; | ||
| * } | ||
| * ``` | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * // Takes string, no return (void) | ||
| * @ForthicWord(se`(input:${z.string()} -- ${z.void()})`, "Log to console") | ||
| * async LOG(input: string): Promise<void> { | ||
| * console.log(input); | ||
| * } | ||
| * ``` | ||
| */ | ||
| export declare const se: <Args extends zodUtil.TupleItems, Return extends z.core.$ZodFunctionOut>(template: TemplateStringsArray, ...values: [...Args, Return]) => TaggedStackEffect<Args, Return>; | ||
| export {}; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.se = exports.mapZodToStackEffectType = void 0; | ||
| const schemaUtils_js_1 = require("./schemaUtils.js"); | ||
| /** | ||
| * Map the set of Zod types to the strings we use in Forthic stack effects. | ||
| * Uses Zod's internal def.type for comprehensive type detection. | ||
| */ | ||
| const mapZodToStackEffectType = (zodType) => { | ||
| const def = zodType.def; | ||
| switch (def.type) { | ||
| case "string": | ||
| return "string"; | ||
| case "int": | ||
| case "bigint": | ||
| return "number"; | ||
| case "number": | ||
| return "number"; | ||
| case "boolean": | ||
| return "boolean"; | ||
| case "null": | ||
| return "null"; | ||
| case "undefined": | ||
| case "void": | ||
| return ""; | ||
| case "date": | ||
| return "date"; | ||
| case "symbol": | ||
| return "symbol"; | ||
| case "object": { | ||
| const objectDef = def; | ||
| const objectShape = objectDef.shape; | ||
| // Get all property types | ||
| const properties = Object.entries(objectShape).map(([key, fieldSchema]) => { | ||
| const fieldType = (0, exports.mapZodToStackEffectType)(fieldSchema); | ||
| return `${key}: ${fieldType}`; | ||
| }); | ||
| // Return formatted object type | ||
| return properties.length > 0 ? `{ ${properties.join(", ")} }` : "{}"; | ||
| } | ||
| case "literal": { | ||
| const literalDef = def; | ||
| const value = literalDef.values[0]; | ||
| // Quote string literals | ||
| return typeof value === "string" ? `"${value}"` : String(value); | ||
| } | ||
| case "enum": { | ||
| const enumDef = def; | ||
| const enumEntries = Object.values(enumDef.entries); | ||
| // Return union of quoted values - zod enums are always strings | ||
| return enumEntries.map((entry) => `"${entry}"`).join("|"); | ||
| } | ||
| case "optional": { | ||
| const optionalDef = def; | ||
| const innerType = (0, exports.mapZodToStackEffectType)(optionalDef.innerType); | ||
| // Optional is a union with undefined | ||
| return innerType ? `${innerType}|undefined` : "undefined"; | ||
| } | ||
| case "nullable": { | ||
| const nullableDef = def; | ||
| const innerType = (0, exports.mapZodToStackEffectType)(nullableDef.innerType); | ||
| // Nullable is a union with null | ||
| return innerType ? `${innerType}|null` : "null"; | ||
| } | ||
| case "union": { | ||
| const unionDef = def; | ||
| const unionOptions = unionDef.options; | ||
| // Recursively get types for all union options | ||
| const optionTypes = unionOptions.map((option) => (0, exports.mapZodToStackEffectType)(option)); | ||
| // Dedupe | ||
| return [...new Set(optionTypes)].join("|"); | ||
| } | ||
| case "tuple": { | ||
| const tupleDef = def; | ||
| const tupleItems = tupleDef.items; | ||
| const elementTypes = tupleItems.map((item) => (0, exports.mapZodToStackEffectType)(item)); | ||
| return `[${elementTypes.join(", ")}]`; | ||
| } | ||
| case "array": { | ||
| const arrayDef = def; | ||
| const elementType = (0, exports.mapZodToStackEffectType)(arrayDef.element); | ||
| // If the element is a union (contains "|") but not already an array type (doesn't end with "]"), | ||
| // wrap it in parentheses | ||
| const needsParens = elementType.includes("|") && !elementType.endsWith("]"); | ||
| const wrappedType = needsParens ? `(${elementType})` : elementType; | ||
| return `${wrappedType}[]`; | ||
| } | ||
| case "custom": { | ||
| const metadata = schemaUtils_js_1.stackObjectRegistry.get(zodType); | ||
| if (!metadata) { | ||
| throw new Error(`Custom schema found without stack object registry entry. Consider using createStackObjectSchema or createInstanceOfSchema or manually registering the schema.`); | ||
| } | ||
| return metadata.stackObjectType ?? metadata.className ?? "object"; | ||
| } | ||
| case "any": | ||
| return "any"; | ||
| case "record": | ||
| case "function": | ||
| case "promise": | ||
| case "map": | ||
| case "set": | ||
| case "lazy": | ||
| case "never": | ||
| case "unknown": | ||
| case "file": | ||
| case "nonoptional": | ||
| case "success": | ||
| case "transform": | ||
| case "prefault": | ||
| case "nan": | ||
| case "pipe": | ||
| case "template_literal": | ||
| case "intersection": | ||
| case "catch": | ||
| case "default": | ||
| case "readonly": | ||
| // Unsupported types - throw error to ensure we handle everything | ||
| throw new Error(`Stack effect string generation not supported for type: "${def.type}" - you may either update mapZodToStackEffectType or use a simpler type (e.g. use createStackObjectSchema)`); | ||
| default: | ||
| throw new Error(`Unknown type: "${def.type}". You either need to update mapZodToStackEffectType, or zod is doing something unexpected.`); | ||
| } | ||
| }; | ||
| exports.mapZodToStackEffectType = mapZodToStackEffectType; | ||
| /** | ||
| * Tagged template literal for stack effects. Use with the @ForthicWord decorator to | ||
| * create a type-safe stack effect. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * // Type-safe stack effect with Zod validation | ||
| * @ForthicWord(se`(a:${z.number()} b:${z.string()} -- result:${z.string()})`, "Concatenate number and string") | ||
| * async CONCAT(a: number, b: string): Promise<string> { | ||
| * return `${a}${b}`; | ||
| * } | ||
| * ``` | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * // No parameters, returns string | ||
| * @ForthicWord(se`( -- message:${z.string()})`, "Get greeting") | ||
| * async GREET(): Promise<string> { | ||
| * return "Hello!"; | ||
| * } | ||
| * ``` | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * // Takes string, no return (void) | ||
| * @ForthicWord(se`(input:${z.string()} -- ${z.void()})`, "Log to console") | ||
| * async LOG(input: string): Promise<void> { | ||
| * console.log(input); | ||
| * } | ||
| * ``` | ||
| */ | ||
| const se = (template, ...values) => { | ||
| const stackEffectTypes = values.map((value) => (0, exports.mapZodToStackEffectType)(value)); | ||
| // Outputs the template string as if it weren't tagged, e.g. "( a:string b:number -- c:number )" | ||
| const parts = []; | ||
| for (let i = 0; i < template.length; i++) { | ||
| parts.push(template[i]); | ||
| if (i < stackEffectTypes.length) { | ||
| parts.push(stackEffectTypes[i]); | ||
| } | ||
| } | ||
| const outStr = parts.join(""); | ||
| const taggedStackEffect = { | ||
| stackEffect: outStr, | ||
| schema: { | ||
| inputSchemas: values.slice(0, -1), | ||
| outputSchema: values[values.length - 1], | ||
| }, | ||
| _implType: async () => { | ||
| throw new Error("This function should not be called at runtime, it's only used for type inference"); | ||
| }, | ||
| }; | ||
| return taggedStackEffect; | ||
| }; | ||
| exports.se = se; | ||
| //# sourceMappingURL=stackEffect.js.map |
| {"version":3,"file":"stackEffect.js","sourceRoot":"","sources":["../../../../src/forthic/decorators/stackEffect.ts"],"names":[],"mappings":";;;AAEA,qDAAuD;AAEvD;;;GAGG;AACI,MAAM,uBAAuB,GAAG,CAAC,OAAqB,EAAU,EAAE;IACvE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAExB,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAElB,KAAK,KAAK,CAAC;QACX,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAElB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAElB,KAAK,SAAS;YAC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AAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAiB;SACxD;QACD,SAAS,EAAE,KAAK,IAAI,EAAE;YACpB,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;QACtG,CAAC;KACF,CAAC;IAEF,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AA5BW,QAAA,EAAE,MA4Bb"} |
| import { z } from "zod"; | ||
| /** | ||
| * Registry metadata types for stack objects and class instances. | ||
| */ | ||
| type StackObjectMetadata = { | ||
| objectType: "stackObject"; | ||
| stackObjectType: string; | ||
| className?: undefined; | ||
| OriginalClass?: undefined; | ||
| } | { | ||
| objectType: "class"; | ||
| OriginalClass: new (...args: any[]) => any; | ||
| className: string; | ||
| stackObjectType?: undefined; | ||
| }; | ||
| /** | ||
| * Track metadata for schema comparison in tests and documentation. | ||
| * Only required for schemas that can't be compared out of the box, | ||
| * like custom schemas or instanceof schemas. | ||
| */ | ||
| export declare const stackObjectRegistry: z.core.$ZodRegistry<StackObjectMetadata, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>; | ||
| /** | ||
| * Creates a Zod schema for stack objects that have a stackObjectType property. | ||
| * This is a helper to reduce boilerplate when creating custom stack object schemas. | ||
| * It also ensures the schema is registered in stackObjectRegistry, which enables | ||
| * proper type string generation in stack effects. | ||
| * | ||
| * Use this instead of z.custom() directly for stack objects. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * interface StackEmail { | ||
| * stackObjectType: "email"; | ||
| * to: string; | ||
| * subject: string; | ||
| * body: string; | ||
| * } | ||
| * | ||
| * const stackEmailSchema = createStackObjectSchema<StackEmail>("email"); | ||
| * | ||
| * // Use in stack effect: | ||
| * @ForthicWord(se`(email:${stackEmailSchema} -- sent:${z.boolean()})`, "Send email") | ||
| * async SEND(email: StackEmail): Promise<boolean> { ... } | ||
| * ``` | ||
| */ | ||
| export declare function createStackObjectSchema<T extends { | ||
| stackObjectType: string; | ||
| }>(stackObjectType: string, errorMessage?: string): z.ZodCustom<T>; | ||
| /** | ||
| * Creates a Zod instanceof schema with automatic metadata registration. | ||
| * This ensures the schema is registered in stackObjectRegistry, which enables | ||
| * proper type string generation in stack effects. | ||
| * | ||
| * Use this instead of z.instanceof() directly. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * import { Temporal } from "temporal-polyfill"; | ||
| * | ||
| * const plainDateSchema = createInstanceOfSchema(Temporal.PlainDate); | ||
| * | ||
| * // Use in stack effect: | ||
| * @ForthicWord(se`(date:${plainDateSchema} -- formatted:${z.string()})`, "Format date") | ||
| * async FORMAT(date: Temporal.PlainDate): Promise<string> { ... } | ||
| * ``` | ||
| */ | ||
| export declare function createInstanceOfSchema<T extends abstract new (...args: any[]) => any>(ClassToSchematize: T, | ||
| /** If not passed, falls back to class.name */ | ||
| className?: string): z.ZodType<InstanceType<T>>; | ||
| export {}; |
| import { z } from "zod"; | ||
| /** | ||
| * Track metadata for schema comparison in tests and documentation. | ||
| * Only required for schemas that can't be compared out of the box, | ||
| * like custom schemas or instanceof schemas. | ||
| */ | ||
| export const stackObjectRegistry = z.registry(); | ||
| /** | ||
| * Creates a Zod schema for stack objects that have a stackObjectType property. | ||
| * This is a helper to reduce boilerplate when creating custom stack object schemas. | ||
| * It also ensures the schema is registered in stackObjectRegistry, which enables | ||
| * proper type string generation in stack effects. | ||
| * | ||
| * Use this instead of z.custom() directly for stack objects. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * interface StackEmail { | ||
| * stackObjectType: "email"; | ||
| * to: string; | ||
| * subject: string; | ||
| * body: string; | ||
| * } | ||
| * | ||
| * const stackEmailSchema = createStackObjectSchema<StackEmail>("email"); | ||
| * | ||
| * // Use in stack effect: | ||
| * @ForthicWord(se`(email:${stackEmailSchema} -- sent:${z.boolean()})`, "Send email") | ||
| * async SEND(email: StackEmail): Promise<boolean> { ... } | ||
| * ``` | ||
| */ | ||
| export function createStackObjectSchema(stackObjectType, errorMessage) { | ||
| const schema = z.custom((maybeStackObject) => maybeStackObject?.stackObjectType === stackObjectType, errorMessage ?? `expected ${stackObjectType} stackObjectType`); | ||
| // Register schema with metadata | ||
| stackObjectRegistry.add(schema, { | ||
| objectType: "stackObject", | ||
| stackObjectType, | ||
| }); | ||
| return schema; | ||
| } | ||
| /** | ||
| * Creates a Zod instanceof schema with automatic metadata registration. | ||
| * This ensures the schema is registered in stackObjectRegistry, which enables | ||
| * proper type string generation in stack effects. | ||
| * | ||
| * Use this instead of z.instanceof() directly. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * import { Temporal } from "temporal-polyfill"; | ||
| * | ||
| * const plainDateSchema = createInstanceOfSchema(Temporal.PlainDate); | ||
| * | ||
| * // Use in stack effect: | ||
| * @ForthicWord(se`(date:${plainDateSchema} -- formatted:${z.string()})`, "Format date") | ||
| * async FORMAT(date: Temporal.PlainDate): Promise<string> { ... } | ||
| * ``` | ||
| */ | ||
| export function createInstanceOfSchema(ClassToSchematize, | ||
| /** If not passed, falls back to class.name */ | ||
| className) { | ||
| const schema = z.instanceof(ClassToSchematize); | ||
| // Register schema with metadata | ||
| const resolvedClassName = className ?? ClassToSchematize.name; | ||
| stackObjectRegistry.add(schema, { | ||
| objectType: "class", | ||
| OriginalClass: ClassToSchematize, | ||
| className: resolvedClassName, | ||
| }); | ||
| return schema; | ||
| } | ||
| //# sourceMappingURL=schemaUtils.js.map |
| {"version":3,"file":"schemaUtils.js","sourceRoot":"","sources":["../../../../src/forthic/decorators/schemaUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmBxB;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,QAAQ,EAAuB,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,uBAAuB,CACrC,eAAuB,EACvB,YAAqB;IAErB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CACrB,CAAC,gBAAgB,EAAE,EAAE,CAAE,gBAAkC,EAAE,eAAe,KAAK,eAAe,EAC9F,YAAY,IAAI,YAAY,eAAe,kBAAkB,CAC9D,CAAC;IAEF,gCAAgC;IAChC,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE;QAC9B,UAAU,EAAE,aAAa;QACzB,eAAe;KAChB,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,sBAAsB,CACpC,iBAAoB;AACpB,8CAA8C;AAC9C,SAAkB;IAElB,MAAM,MAAM,GAAG,CAAC,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAE/C,gCAAgC;IAChC,MAAM,iBAAiB,GAAG,SAAS,IAAI,iBAAiB,CAAC,IAAI,CAAC;IAC9D,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE;QAC9B,UAAU,EAAE,OAAO;QACnB,aAAa,EAAE,iBAAiB;QAChC,SAAS,EAAE,iBAAiB;KAC7B,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"} |
| import { z } from "zod"; | ||
| import type { util as zodUtil } from "zod/v4/core"; | ||
| /** | ||
| * Map the set of Zod types to the strings we use in Forthic stack effects. | ||
| * Uses Zod's internal def.type for comprehensive type detection. | ||
| */ | ||
| export declare const mapZodToStackEffectType: (zodType: z.ZodTypeAny) => string; | ||
| type InferTupleTypes<T extends zodUtil.TupleItems> = { | ||
| [K in keyof T]: T[K] extends z.ZodTypeAny ? z.infer<T[K]> : never; | ||
| }; | ||
| /** | ||
| * Represents a type-safe stack effect with Zod schemas for validation. | ||
| * | ||
| * @template Args - Tuple of Zod schemas for input parameters | ||
| * @template Return - Zod schema for the return type | ||
| */ | ||
| export type TaggedStackEffect<Args extends zodUtil.TupleItems, Return extends z.core.$ZodFunctionOut = z.core.$ZodFunctionOut> = { | ||
| /** The human-readable stack effect string (e.g., "( a:number b:string -- result:string )") */ | ||
| stackEffect: string; | ||
| /** Zod schemas for runtime validation */ | ||
| schema: { | ||
| inputSchemas: z.ZodTypeAny[]; | ||
| outputSchema: z.ZodTypeAny; | ||
| }; | ||
| /** | ||
| * Phantom property to convey the expected function signature, constructed from the input + output types. | ||
| * DO NOT USE AT RUNTIME - it's only used for type inference. | ||
| */ | ||
| _implType: (...args: InferTupleTypes<Args>) => Promise<z.infer<Return>>; | ||
| }; | ||
| /** | ||
| * Tagged template literal for stack effects. Use with the @ForthicWord decorator to | ||
| * create a type-safe stack effect. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * // Type-safe stack effect with Zod validation | ||
| * @ForthicWord(se`(a:${z.number()} b:${z.string()} -- result:${z.string()})`, "Concatenate number and string") | ||
| * async CONCAT(a: number, b: string): Promise<string> { | ||
| * return `${a}${b}`; | ||
| * } | ||
| * ``` | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * // No parameters, returns string | ||
| * @ForthicWord(se`( -- message:${z.string()})`, "Get greeting") | ||
| * async GREET(): Promise<string> { | ||
| * return "Hello!"; | ||
| * } | ||
| * ``` | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * // Takes string, no return (void) | ||
| * @ForthicWord(se`(input:${z.string()} -- ${z.void()})`, "Log to console") | ||
| * async LOG(input: string): Promise<void> { | ||
| * console.log(input); | ||
| * } | ||
| * ``` | ||
| */ | ||
| export declare const se: <Args extends zodUtil.TupleItems, Return extends z.core.$ZodFunctionOut>(template: TemplateStringsArray, ...values: [...Args, Return]) => TaggedStackEffect<Args, Return>; | ||
| export {}; |
| import { stackObjectRegistry } from "./schemaUtils.js"; | ||
| /** | ||
| * Map the set of Zod types to the strings we use in Forthic stack effects. | ||
| * Uses Zod's internal def.type for comprehensive type detection. | ||
| */ | ||
| export const mapZodToStackEffectType = (zodType) => { | ||
| const def = zodType.def; | ||
| switch (def.type) { | ||
| case "string": | ||
| return "string"; | ||
| case "int": | ||
| case "bigint": | ||
| return "number"; | ||
| case "number": | ||
| return "number"; | ||
| case "boolean": | ||
| return "boolean"; | ||
| case "null": | ||
| return "null"; | ||
| case "undefined": | ||
| case "void": | ||
| return ""; | ||
| case "date": | ||
| return "date"; | ||
| case "symbol": | ||
| return "symbol"; | ||
| case "object": { | ||
| const objectDef = def; | ||
| const objectShape = objectDef.shape; | ||
| // Get all property types | ||
| const properties = Object.entries(objectShape).map(([key, fieldSchema]) => { | ||
| const fieldType = mapZodToStackEffectType(fieldSchema); | ||
| return `${key}: ${fieldType}`; | ||
| }); | ||
| // Return formatted object type | ||
| return properties.length > 0 ? `{ ${properties.join(", ")} }` : "{}"; | ||
| } | ||
| case "literal": { | ||
| const literalDef = def; | ||
| const value = literalDef.values[0]; | ||
| // Quote string literals | ||
| return typeof value === "string" ? `"${value}"` : String(value); | ||
| } | ||
| case "enum": { | ||
| const enumDef = def; | ||
| const enumEntries = Object.values(enumDef.entries); | ||
| // Return union of quoted values - zod enums are always strings | ||
| return enumEntries.map((entry) => `"${entry}"`).join("|"); | ||
| } | ||
| case "optional": { | ||
| const optionalDef = def; | ||
| const innerType = mapZodToStackEffectType(optionalDef.innerType); | ||
| // Optional is a union with undefined | ||
| return innerType ? `${innerType}|undefined` : "undefined"; | ||
| } | ||
| case "nullable": { | ||
| const nullableDef = def; | ||
| const innerType = mapZodToStackEffectType(nullableDef.innerType); | ||
| // Nullable is a union with null | ||
| return innerType ? `${innerType}|null` : "null"; | ||
| } | ||
| case "union": { | ||
| const unionDef = def; | ||
| const unionOptions = unionDef.options; | ||
| // Recursively get types for all union options | ||
| const optionTypes = unionOptions.map((option) => mapZodToStackEffectType(option)); | ||
| // Dedupe | ||
| return [...new Set(optionTypes)].join("|"); | ||
| } | ||
| case "tuple": { | ||
| const tupleDef = def; | ||
| const tupleItems = tupleDef.items; | ||
| const elementTypes = tupleItems.map((item) => mapZodToStackEffectType(item)); | ||
| return `[${elementTypes.join(", ")}]`; | ||
| } | ||
| case "array": { | ||
| const arrayDef = def; | ||
| const elementType = mapZodToStackEffectType(arrayDef.element); | ||
| // If the element is a union (contains "|") but not already an array type (doesn't end with "]"), | ||
| // wrap it in parentheses | ||
| const needsParens = elementType.includes("|") && !elementType.endsWith("]"); | ||
| const wrappedType = needsParens ? `(${elementType})` : elementType; | ||
| return `${wrappedType}[]`; | ||
| } | ||
| case "custom": { | ||
| const metadata = stackObjectRegistry.get(zodType); | ||
| if (!metadata) { | ||
| throw new Error(`Custom schema found without stack object registry entry. Consider using createStackObjectSchema or createInstanceOfSchema or manually registering the schema.`); | ||
| } | ||
| return metadata.stackObjectType ?? metadata.className ?? "object"; | ||
| } | ||
| case "any": | ||
| return "any"; | ||
| case "record": | ||
| case "function": | ||
| case "promise": | ||
| case "map": | ||
| case "set": | ||
| case "lazy": | ||
| case "never": | ||
| case "unknown": | ||
| case "file": | ||
| case "nonoptional": | ||
| case "success": | ||
| case "transform": | ||
| case "prefault": | ||
| case "nan": | ||
| case "pipe": | ||
| case "template_literal": | ||
| case "intersection": | ||
| case "catch": | ||
| case "default": | ||
| case "readonly": | ||
| // Unsupported types - throw error to ensure we handle everything | ||
| throw new Error(`Stack effect string generation not supported for type: "${def.type}" - you may either update mapZodToStackEffectType or use a simpler type (e.g. use createStackObjectSchema)`); | ||
| default: | ||
| throw new Error(`Unknown type: "${def.type}". You either need to update mapZodToStackEffectType, or zod is doing something unexpected.`); | ||
| } | ||
| }; | ||
| /** | ||
| * Tagged template literal for stack effects. Use with the @ForthicWord decorator to | ||
| * create a type-safe stack effect. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * // Type-safe stack effect with Zod validation | ||
| * @ForthicWord(se`(a:${z.number()} b:${z.string()} -- result:${z.string()})`, "Concatenate number and string") | ||
| * async CONCAT(a: number, b: string): Promise<string> { | ||
| * return `${a}${b}`; | ||
| * } | ||
| * ``` | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * // No parameters, returns string | ||
| * @ForthicWord(se`( -- message:${z.string()})`, "Get greeting") | ||
| * async GREET(): Promise<string> { | ||
| * return "Hello!"; | ||
| * } | ||
| * ``` | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * // Takes string, no return (void) | ||
| * @ForthicWord(se`(input:${z.string()} -- ${z.void()})`, "Log to console") | ||
| * async LOG(input: string): Promise<void> { | ||
| * console.log(input); | ||
| * } | ||
| * ``` | ||
| */ | ||
| export const se = (template, ...values) => { | ||
| const stackEffectTypes = values.map((value) => mapZodToStackEffectType(value)); | ||
| // Outputs the template string as if it weren't tagged, e.g. "( a:string b:number -- c:number )" | ||
| const parts = []; | ||
| for (let i = 0; i < template.length; i++) { | ||
| parts.push(template[i]); | ||
| if (i < stackEffectTypes.length) { | ||
| parts.push(stackEffectTypes[i]); | ||
| } | ||
| } | ||
| const outStr = parts.join(""); | ||
| const taggedStackEffect = { | ||
| stackEffect: outStr, | ||
| schema: { | ||
| inputSchemas: values.slice(0, -1), | ||
| outputSchema: values[values.length - 1], | ||
| }, | ||
| _implType: async () => { | ||
| throw new Error("This function should not be called at runtime, it's only used for type inference"); | ||
| }, | ||
| }; | ||
| return taggedStackEffect; | ||
| }; | ||
| //# sourceMappingURL=stackEffect.js.map |
| {"version":3,"file":"stackEffect.js","sourceRoot":"","sources":["../../../../src/forthic/decorators/stackEffect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,OAAqB,EAAU,EAAE;IACvE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAExB,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAElB,KAAK,KAAK,CAAC;QACX,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAElB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAElB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QAEnB,KAAK,MAAM;YACT,OAAO,MAAM,CAAC;QAEhB,KAAK,WAAW,CAAC;QACjB,K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AEF,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC"} |
@@ -152,3 +152,3 @@ "use strict"; | ||
| if (typeof item === "number") { | ||
| const instant = temporal_polyfill_1.Temporal.Instant.fromEpochSeconds(item); | ||
| const instant = temporal_polyfill_1.Temporal.Instant.fromEpochMilliseconds(item * 1000); | ||
| const zoned = instant.toZonedDateTimeISO(interp.get_timezone()); | ||
@@ -254,3 +254,3 @@ interp.stack_push(zoned); | ||
| // Assume timestamp is in seconds, convert to milliseconds | ||
| const instant = temporal_polyfill_1.Temporal.Instant.fromEpochSeconds(timestamp); | ||
| const instant = temporal_polyfill_1.Temporal.Instant.fromEpochMilliseconds(timestamp * 1000); | ||
| const zoned = instant.toZonedDateTimeISO(interp.get_timezone()); | ||
@@ -257,0 +257,0 @@ interp.stack_push(zoned); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"datetime_module.js","sourceRoot":"","sources":["../../../../../src/forthic/modules/standard/datetime_module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAmD;AACnD,sDAA8G;AAC9G,yDAA6C;AAE7C,MAAa,cAAe,SAAQ,yBAAe;IACjD;QACE,IAAA,2BAAiB,EAAC,cAAc,EAAE;;;;;;;;;;;;;;;;;;CAkBrC,CAAC,CAAC;IACD,CAAC;IAED;QACE,KAAK,CAAC,UAAU,CAAC,CAAC;IACpB,CAAC;IAIK,AAAN,KAAK,CAAC,KAAK,CAAC,MAAmB;QAC7B,MAAM,KAAK,GAAG,4BAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;QAC/D,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAGK,AAAN,KAAK,CAAC,GAAG,CAAC,MAAmB;QAC3B,MAAM,GAAG,GAAG,4BAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;QACjE,MAAM,CAAC,UAAU,C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E,oBAAoB,CAAC;;qCAC/G,4BAAW;;2DAY9C;AAKK;IADL,IAAA,qBAAW,EAAC,wEAAwE,EAAE,oBAAoB,EAAE,UAAU,CAAC;;;;8CAOvH;AAIK;IADL,IAAA,qBAAW,EAAC,0EAA0E,EAAE,sDAAsD,EAAE,gBAAgB,CAAC;;;;oDAUjK"} | ||
| {"version":3,"file":"datetime_module.js","sourceRoot":"","sources":["../../../../../src/forthic/modules/standard/datetime_module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAmD;AACnD,sDAA8G;AAC9G,yDAA6C;AAE7C,MAAa,cAAe,SAAQ,yBAAe;IACjD;QACE,IAAA,2BAAiB,EAAC,cAAc,EAAE;;;;;;;;;;;;;;;;;;CAkBrC,CAAC,CAAC;IACD,CAAC;IAED;QACE,KAAK,CAAC,UAAU,CAAC,CAAC;IACpB,CAAC;IAIK,AAAN,KAAK,CAAC,KAAK,CAAC,MAAmB;QAC7B,MAAM,KAAK,GAAG,4BAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;QAC/D,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAGK,AAAN,KAAK,CAAC,GAAG,CAAC,MAAmB;QAC3B,MAAM,GAAG,GAAG,4BAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;QACjE,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAIK,AAAN,KAAK,CAAC,EAAE,CAAC,IAAS;QAChB,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC3C,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAA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AC;;qCACzE,4BAAW;;yCAG5B;AAIK;IADL,IAAA,qBAAW,EAAC,wDAAwD,EAAE,qDAAqD,CAAC;;;;wCAS5H;AAGK;IADL,IAAA,qBAAW,EAAC,wDAAwD,EAAE,6CAA6C,CAAC;;;;wCASpH;AAIK;IADL,IAAA,qBAAW,EAAC,yCAAyC,EAAE,yCAAyC,EAAE,OAAO,CAAC;;;;6CAyC1G;AAGK;IADL,IAAA,qBAAW,EAAC,yCAAyC,EAAE,yCAAyC,EAAE,OAAO,CAAC;;;;6CAuC1G;AAGK;IADL,IAAA,2BAAiB,EAAC,6DAA6D,EAAE,8CAA8C,EAAE,WAAW,CAAC;;qCACpH,4BAAW;;iDAwCpC;AAGK;IADL,IAAA,2BAAiB,EAAC,wFAAwF,EAAE,qCAAqC,EAAE,IAAI,CAAC;;qCACxI,4BAAW;;wCAuB3B;AAIK;IADL,IAAA,qBAAW,EAAC,2CAA2C,EAAE,8BAA8B,EAAE,UAAU,CAAC;;;;iDASpG;AAGK;IADL,IAAA,qBAAW,EAAC,2CAA2C,EAAE,mCAAmC,EAAE,UAAU,CAAC;;;;iDAOzG;AAGK;IADL,IAAA,qBAAW,EAAC,2CAA2C,EAAE,oCAAoC,EAAE,UAAU,CAAC;;;;iDAU1G;AAIK;IADL,IAAA,2BAAiB,EAAC,yDAAyD,EAAE,8CAA8C,EAAE,YAAY,CAAC;;qCAChH,4BAAW;;kDA2BrC;AAGK;IADL,IAAA,2BAAiB,EAAC,yDAAyD,EAAE,8CAA8C,EAAE,oBAAoB,CAAC;;qCAC/G,4BAAW;;2DAY9C;AAKK;IADL,IAAA,qBAAW,EAAC,wEAAwE,EAAE,oBAAoB,EAAE,UAAU,CAAC;;;;8CAOvH;AAIK;IADL,IAAA,qBAAW,EAAC,0EAA0E,EAAE,sDAAsD,EAAE,gBAAgB,CAAC;;;;oDAUjK"} |
@@ -145,3 +145,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
| if (typeof item === "number") { | ||
| const instant = Temporal.Instant.fromEpochSeconds(item); | ||
| const instant = Temporal.Instant.fromEpochMilliseconds(item * 1000); | ||
| const zoned = instant.toZonedDateTimeISO(interp.get_timezone()); | ||
@@ -247,3 +247,3 @@ interp.stack_push(zoned); | ||
| // Assume timestamp is in seconds, convert to milliseconds | ||
| const instant = Temporal.Instant.fromEpochSeconds(timestamp); | ||
| const instant = Temporal.Instant.fromEpochMilliseconds(timestamp * 1000); | ||
| const zoned = instant.toZonedDateTimeISO(interp.get_timezone()); | ||
@@ -250,0 +250,0 @@ interp.stack_push(zoned); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"datetime_module.js","sourceRoot":"","sources":["../../../../../src/forthic/modules/standard/datetime_module.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC9G,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,OAAO,cAAe,SAAQ,eAAe;IACjD;QACE,iBAAiB,CAAC,cAAc,EAAE;;;;;;;;;;;;;;;;;;CAkBrC,CAAC,CAAC;IACD,CAAC;IAED;QACE,KAAK,CAAC,UAAU,CAAC,CAAC;IACpB,CAAC;IAIK,AAAN,KAAK,CAAC,KAAK,CAAC,MAAmB;QAC7B,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;QAC/D,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAGK,AAAN,KAAK,CAAC,GAAG,CAAC,MAAmB;QAC3B,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;QACjE,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAIK,AAAN,KAAK,CAAC,E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I,CAAC;IACvB,CAAC;CACF;AAlSO;IADL,iBAAiB,CAAC,gCAAgC,EAAE,kBAAkB,EAAE,OAAO,CAAC;2CAIhF;AAGK;IADL,iBAAiB,CAAC,wCAAwC,EAAE,sBAAsB,EAAE,KAAK,CAAC;yCAI1F;AAIK;IADL,WAAW,CAAC,wDAAwD,EAAE,qDAAqD,CAAC;wCAS5H;AAGK;IADL,WAAW,CAAC,wDAAwD,EAAE,6CAA6C,CAAC;wCASpH;AAIK;IADL,WAAW,CAAC,yCAAyC,EAAE,yCAAyC,EAAE,OAAO,CAAC;6CAyC1G;AAGK;IADL,WAAW,CAAC,yCAAyC,EAAE,yCAAyC,EAAE,OAAO,CAAC;6CAuC1G;AAGK;IADL,iBAAiB,CAAC,6DAA6D,EAAE,8CAA8C,EAAE,WAAW,CAAC;iDAyC7I;AAGK;IADL,iBAAiB,CAAC,wFAAwF,EAAE,qCAAqC,EAAE,IAAI,CAAC;wCAwBxJ;AAIK;IADL,WAAW,CAAC,2CAA2C,EAAE,8BAA8B,EAAE,UAAU,CAAC;iDASpG;AAGK;IADL,WAAW,CAAC,2CAA2C,EAAE,mCAAmC,EAAE,UAAU,CAAC;iDAOzG;AAGK;IADL,WAAW,CAAC,2CAA2C,EAAE,oCAAoC,EAAE,UAAU,CAAC;iDAU1G;AAIK;IADL,iBAAiB,CAAC,yDAAyD,EAAE,8CAA8C,EAAE,YAAY,CAAC;kDA4B1I;AAGK;IADL,iBAAiB,CAAC,yDAAyD,EAAE,8CAA8C,EAAE,oBAAoB,CAAC;2DAalJ;AAKK;IADL,WAAW,CAAC,wEAAwE,EAAE,oBAAoB,EAAE,UAAU,CAAC;8CAOvH;AAIK;IADL,WAAW,CAAC,0EAA0E,EAAE,sDAAsD,EAAE,gBAAgB,CAAC;oDAUjK"} | ||
| {"version":3,"file":"datetime_module.js","sourceRoot":"","sources":["../../../../../src/forthic/modules/standard/datetime_module.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,eAAe,EAA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E,8CAA8C,EAAE,WAAW,CAAC;iDAyC7I;AAGK;IADL,iBAAiB,CAAC,wFAAwF,EAAE,qCAAqC,EAAE,IAAI,CAAC;wCAwBxJ;AAIK;IADL,WAAW,CAAC,2CAA2C,EAAE,8BAA8B,EAAE,UAAU,CAAC;iDASpG;AAGK;IADL,WAAW,CAAC,2CAA2C,EAAE,mCAAmC,EAAE,UAAU,CAAC;iDAOzG;AAGK;IADL,WAAW,CAAC,2CAA2C,EAAE,oCAAoC,EAAE,UAAU,CAAC;iDAU1G;AAIK;IADL,iBAAiB,CAAC,yDAAyD,EAAE,8CAA8C,EAAE,YAAY,CAAC;kDA4B1I;AAGK;IADL,iBAAiB,CAAC,yDAAyD,EAAE,8CAA8C,EAAE,oBAAoB,CAAC;2DAalJ;AAKK;IADL,WAAW,CAAC,wEAAwE,EAAE,oBAAoB,EAAE,UAAU,CAAC;8CAOvH;AAIK;IADL,WAAW,CAAC,0EAA0E,EAAE,sDAAsD,EAAE,gBAAgB,CAAC;oDAUjK"} |
+2
-2
| { | ||
| "name": "@forthix/forthic", | ||
| "version": "0.6.0", | ||
| "version": "0.6.1", | ||
| "description": "Stack-based, concatenative language for composable transformations - TypeScript/JavaScript runtime", | ||
@@ -84,3 +84,3 @@ "main": "dist/cjs/index.js", | ||
| "dependencies": { | ||
| "temporal-polyfill": "^0.2.5", | ||
| "temporal-polyfill": "^0.3.0", | ||
| "yaml": "^2.8.1" | ||
@@ -87,0 +87,0 @@ }, |
| export {}; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || (function () { | ||
| var ownKeys = function(o) { | ||
| ownKeys = Object.getOwnPropertyNames || function (o) { | ||
| var ar = []; | ||
| for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; | ||
| return ar; | ||
| }; | ||
| return ownKeys(o); | ||
| }; | ||
| return function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| })(); | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| /** | ||
| * Phase 11.1: Basic server tests | ||
| * Verify that the TypeScript gRPC server can start and listen on port 50052 | ||
| */ | ||
| const server_1 = require("./server"); | ||
| const grpc = __importStar(require("@grpc/grpc-js")); | ||
| const protoLoader = __importStar(require("@grpc/proto-loader")); | ||
| const path = __importStar(require("path")); | ||
| describe('TypeScript gRPC Server', () => { | ||
| let server = null; | ||
| const TEST_PORT = 50053; // Use different port to avoid conflicts | ||
| afterEach(async () => { | ||
| // Clean up server if running | ||
| if (server) { | ||
| await new Promise((resolve) => { | ||
| server.tryShutdown(() => { | ||
| resolve(); | ||
| }); | ||
| }); | ||
| server = null; | ||
| } | ||
| }); | ||
| test('server starts and listens on specified port', async () => { | ||
| // Start server in background (don't await) | ||
| const serverPromise = (0, server_1.serve)(TEST_PORT); | ||
| // Give server time to start | ||
| await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
| // Try to connect with a client | ||
| const possiblePaths = [ | ||
| path.join(__dirname, '../../../../forthic/protos/forthic_runtime.proto'), | ||
| path.join(__dirname, '../../../forthic/protos/forthic_runtime.proto'), | ||
| path.join(process.cwd(), '../forthic/protos/forthic_runtime.proto'), | ||
| ]; | ||
| let PROTO_PATH = possiblePaths[0]; | ||
| const fs = require('fs'); | ||
| for (const tryPath of possiblePaths) { | ||
| if (fs.existsSync(tryPath)) { | ||
| PROTO_PATH = tryPath; | ||
| break; | ||
| } | ||
| } | ||
| const packageDefinition = protoLoader.loadSync(PROTO_PATH, { | ||
| keepCase: true, | ||
| longs: Number, | ||
| enums: String, | ||
| defaults: true, | ||
| oneofs: true, | ||
| }); | ||
| const protoDescriptor = grpc.loadPackageDefinition(packageDefinition); | ||
| const forthicProto = protoDescriptor.forthic; | ||
| // Create client | ||
| const client = new forthicProto.ForthicRuntime(`localhost:${TEST_PORT}`, grpc.credentials.createInsecure()); | ||
| // Test that we can connect by calling ListModules | ||
| const response = await new Promise((resolve, reject) => { | ||
| client.ListModules({}, (error, response) => { | ||
| if (error) { | ||
| reject(error); | ||
| } | ||
| else { | ||
| resolve(response); | ||
| } | ||
| }); | ||
| }); | ||
| // Should succeed with empty module list (no TS-specific modules yet) | ||
| expect(response).toBeDefined(); | ||
| expect(response.modules).toBeDefined(); | ||
| expect(Array.isArray(response.modules)).toBe(true); | ||
| // Clean up client | ||
| grpc.closeClient(client); | ||
| }, 10000); // 10 second timeout | ||
| test('server can execute simple stdlib word', async () => { | ||
| // Start server | ||
| const serverPromise = (0, server_1.serve)(TEST_PORT); | ||
| await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
| // Load proto | ||
| const possiblePaths = [ | ||
| path.join(__dirname, '../../../../forthic/protos/forthic_runtime.proto'), | ||
| path.join(__dirname, '../../../forthic/protos/forthic_runtime.proto'), | ||
| path.join(process.cwd(), '../forthic/protos/forthic_runtime.proto'), | ||
| ]; | ||
| let PROTO_PATH = possiblePaths[0]; | ||
| const fs = require('fs'); | ||
| for (const tryPath of possiblePaths) { | ||
| if (fs.existsSync(tryPath)) { | ||
| PROTO_PATH = tryPath; | ||
| break; | ||
| } | ||
| } | ||
| const packageDefinition = protoLoader.loadSync(PROTO_PATH, { | ||
| keepCase: true, | ||
| longs: Number, | ||
| enums: String, | ||
| defaults: true, | ||
| oneofs: true, | ||
| }); | ||
| const protoDescriptor = grpc.loadPackageDefinition(packageDefinition); | ||
| const forthicProto = protoDescriptor.forthic; | ||
| const client = new forthicProto.ForthicRuntime(`localhost:${TEST_PORT}`, grpc.credentials.createInsecure()); | ||
| // Execute DUP word (duplicates top stack item) | ||
| const response = await new Promise((resolve, reject) => { | ||
| client.ExecuteWord({ | ||
| word_name: 'DUP', | ||
| stack: [{ int_value: 42 }], | ||
| }, (error, response) => { | ||
| if (error) { | ||
| reject(error); | ||
| } | ||
| else { | ||
| resolve(response); | ||
| } | ||
| }); | ||
| }); | ||
| // Should have [42, 42] on stack | ||
| expect(response.result_stack).toBeDefined(); | ||
| expect(response.result_stack.length).toBe(2); | ||
| expect(response.result_stack[0].int_value).toBe(42); | ||
| expect(response.result_stack[1].int_value).toBe(42); | ||
| grpc.closeClient(client); | ||
| }, 10000); | ||
| }); | ||
| //# sourceMappingURL=server.test.js.map |
| {"version":3,"file":"server.test.js","sourceRoot":"","sources":["../../../src/grpc/server.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,qCAAiC;AACjC,oDAAsC;AACtC,gEAAkD;AAClD,2CAA6B;AAE7B,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,IAAI,MAAM,GAAuB,IAAI,CAAC;IACtC,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,wCAAwC;IAEjE,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,6BAA6B;QAC7B,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBAClC,MAAO,CAAC,WAAW,CAAC,GAAG,EAAE;oBACvB,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC,CAAC;YACL,CAAC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AC,CAAC;QAEH,gCAAgC;QAChC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5C,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpD,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEpD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC,EAAE,KAAK,CAAC,CAAC;AACZ,CAAC,CAAC,CAAC"} |
| /** | ||
| * Temporal Type Utilities | ||
| * | ||
| * Provides duck-typing helpers for checking Temporal types. | ||
| * Uses duck typing instead of instanceof to avoid issues with multiple | ||
| * instances of temporal-polyfill being loaded. | ||
| */ | ||
| /** | ||
| * Check if a value is a Temporal.PlainDate | ||
| * PlainDate has year, month, day properties but no hour property | ||
| */ | ||
| export declare function isPlainDate(value: any): boolean; | ||
| /** | ||
| * Check if a value is a Temporal.Instant | ||
| * Instant has epochNanoseconds property as a bigint | ||
| */ | ||
| export declare function isInstant(value: any): boolean; | ||
| /** | ||
| * Check if a value is a Temporal.ZonedDateTime | ||
| * ZonedDateTime has a timeZoneId property | ||
| */ | ||
| export declare function isZonedDateTime(value: any): boolean; | ||
| /** | ||
| * Check if a value is a Temporal.PlainTime | ||
| * PlainTime has hour and minute properties but no year | ||
| */ | ||
| export declare function isPlainTime(value: any): boolean; | ||
| /** | ||
| * Check if a value is a Temporal.PlainDateTime | ||
| * PlainDateTime has year, month, day, hour properties but no timeZoneId | ||
| */ | ||
| export declare function isPlainDateTime(value: any): boolean; | ||
| /** | ||
| * Check if a value is any Temporal type | ||
| */ | ||
| export declare function isTemporal(value: any): boolean; |
| "use strict"; | ||
| /** | ||
| * Temporal Type Utilities | ||
| * | ||
| * Provides duck-typing helpers for checking Temporal types. | ||
| * Uses duck typing instead of instanceof to avoid issues with multiple | ||
| * instances of temporal-polyfill being loaded. | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.isPlainDate = isPlainDate; | ||
| exports.isInstant = isInstant; | ||
| exports.isZonedDateTime = isZonedDateTime; | ||
| exports.isPlainTime = isPlainTime; | ||
| exports.isPlainDateTime = isPlainDateTime; | ||
| exports.isTemporal = isTemporal; | ||
| /** | ||
| * Check if a value is a Temporal.PlainDate | ||
| * PlainDate has year, month, day properties but no hour property | ||
| */ | ||
| function isPlainDate(value) { | ||
| return value && typeof value === 'object' && | ||
| typeof value.year === 'number' && | ||
| typeof value.month === 'number' && | ||
| typeof value.day === 'number' && | ||
| typeof value.toString === 'function' && | ||
| !value.hour; // PlainDate doesn't have hour | ||
| } | ||
| /** | ||
| * Check if a value is a Temporal.Instant | ||
| * Instant has epochNanoseconds property as a bigint | ||
| */ | ||
| function isInstant(value) { | ||
| return value && typeof value === 'object' && | ||
| typeof value.epochNanoseconds === 'bigint' && | ||
| typeof value.toString === 'function'; | ||
| } | ||
| /** | ||
| * Check if a value is a Temporal.ZonedDateTime | ||
| * ZonedDateTime has a timeZoneId property | ||
| */ | ||
| function isZonedDateTime(value) { | ||
| return value && typeof value === 'object' && | ||
| typeof value.timeZoneId === 'string' && | ||
| typeof value.toString === 'function'; | ||
| } | ||
| /** | ||
| * Check if a value is a Temporal.PlainTime | ||
| * PlainTime has hour and minute properties but no year | ||
| */ | ||
| function isPlainTime(value) { | ||
| return value && typeof value === 'object' && | ||
| typeof value.hour === 'number' && | ||
| typeof value.minute === 'number' && | ||
| typeof value.toString === 'function' && | ||
| !value.year; // PlainTime doesn't have year | ||
| } | ||
| /** | ||
| * Check if a value is a Temporal.PlainDateTime | ||
| * PlainDateTime has year, month, day, hour properties but no timeZoneId | ||
| */ | ||
| function isPlainDateTime(value) { | ||
| return value && typeof value === 'object' && | ||
| typeof value.year === 'number' && | ||
| typeof value.month === 'number' && | ||
| typeof value.day === 'number' && | ||
| typeof value.hour === 'number' && | ||
| typeof value.toString === 'function' && | ||
| !value.timeZoneId; // PlainDateTime doesn't have timeZoneId | ||
| } | ||
| /** | ||
| * Check if a value is any Temporal type | ||
| */ | ||
| function isTemporal(value) { | ||
| return isPlainDate(value) || | ||
| isInstant(value) || | ||
| isZonedDateTime(value) || | ||
| isPlainTime(value) || | ||
| isPlainDateTime(value); | ||
| } | ||
| //# sourceMappingURL=temporal_utils.js.map |
| {"version":3,"file":"temporal_utils.js","sourceRoot":"","sources":["../../../src/grpc/temporal_utils.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAMH,kCAOC;AAMD,8BAIC;AAMD,0CAIC;AAMD,kCAMC;AAMD,0CAQC;AAKD,gCAMC;AApED;;;GAGG;AACH,SAAgB,WAAW,CAAC,KAAU;IACpC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAClC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;QAC/B,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ;QAC7B,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU;QACpC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAE,8BAA8B;AACrD,CAAC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,KAAU;IAClC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAClC,OAAO,KAAK,CAAC,gBAAgB,KAAK,QAAQ;QAC1C,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAAC,KAAU;IACxC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAClC,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ;QACpC,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,SAAgB,WAAW,CAAC,KAAU;IACpC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAClC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;QAChC,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU;QACpC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAE,8BAA8B;AACrD,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAAC,KAAU;IACxC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAClC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;QAC/B,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ;QAC7B,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU;QACpC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAE,wCAAwC;AACrE,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,KAAU;IACnC,OAAO,WAAW,CAAC,KAAK,CAAC;QAClB,SAAS,CAAC,KAAK,CAAC;QAChB,eAAe,CAAC,KAAK,CAAC;QACtB,WAAW,CAAC,KAAK,CAAC;QAClB,eAAe,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC"} |
| /** | ||
| * ActionCable Client for Forthic | ||
| * Browser-compatible client that mirrors GrpcClient API | ||
| * Specifically designed for Rails ActionCable WebSocket protocol | ||
| */ | ||
| import { StackValue } from './serializer.js'; | ||
| export interface ModuleSummary { | ||
| name: string; | ||
| description: string; | ||
| word_count: number; | ||
| } | ||
| export interface WordInfo { | ||
| name: string; | ||
| stack_effect: string; | ||
| description: string; | ||
| } | ||
| export interface ModuleInfo { | ||
| module_name: string; | ||
| words: WordInfo[]; | ||
| } | ||
| export interface ProgressUpdate { | ||
| step: number; | ||
| total_steps: number; | ||
| current_word: string; | ||
| message?: string; | ||
| partial_stack?: StackValue[]; | ||
| } | ||
| export interface ActionCableClientConfig { | ||
| url: string; | ||
| timezone?: string; | ||
| reconnect?: boolean; | ||
| reconnectDelay?: number; | ||
| channel?: string; | ||
| } | ||
| /** | ||
| * ActionCable client for executing words in remote Forthic runtimes | ||
| * Mirrors the GrpcClient API for compatibility | ||
| * Uses Rails ActionCable WebSocket protocol | ||
| */ | ||
| export declare class ActionCableClient { | ||
| private ws?; | ||
| private config; | ||
| private pendingRequests; | ||
| private messageId; | ||
| private connected; | ||
| private connectionPromise?; | ||
| constructor(config: ActionCableClientConfig); | ||
| /** | ||
| * Connect to the WebSocket server | ||
| */ | ||
| private connect; | ||
| /** | ||
| * Handle incoming WebSocket messages | ||
| */ | ||
| private handleMessage; | ||
| /** | ||
| * Generate next message ID | ||
| */ | ||
| private nextMessageId; | ||
| /** | ||
| * Send a request and wait for response | ||
| * @template T The expected result type (the value of the `result` field) | ||
| */ | ||
| private sendRequest; | ||
| /** | ||
| * Send a streaming request with progress callbacks | ||
| * @template T The expected result type (the value of the `result` field) | ||
| */ | ||
| private sendStreamingRequest; | ||
| /** | ||
| * Ensure WebSocket is connected | ||
| */ | ||
| private ensureConnected; | ||
| /** | ||
| * Execute a word in the remote runtime | ||
| * Mirrors GrpcClient.executeWord | ||
| */ | ||
| executeWord(word: string, stack: any[]): Promise<any[]>; | ||
| /** | ||
| * Execute a sequence of words (batched execution) | ||
| * Mirrors GrpcClient.executeSequence | ||
| */ | ||
| executeSequence(words: string[], stack: any[]): Promise<any[]>; | ||
| /** | ||
| * List available runtime-specific modules | ||
| * Mirrors GrpcClient.listModules | ||
| */ | ||
| listModules(): Promise<ModuleSummary[]>; | ||
| /** | ||
| * Get detailed information about a specific module | ||
| * Mirrors GrpcClient.getModuleInfo | ||
| */ | ||
| getModuleInfo(moduleName: string): Promise<ModuleInfo>; | ||
| /** | ||
| * Execute code with streaming progress updates (NEW capability) | ||
| */ | ||
| streamingExecute(code: string, stack: any[], onProgress?: (progress: ProgressUpdate) => void): Promise<any[]>; | ||
| /** | ||
| * Close the WebSocket connection | ||
| */ | ||
| close(): void; | ||
| /** | ||
| * Check if the client is connected | ||
| */ | ||
| isConnected(): boolean; | ||
| } |
| "use strict"; | ||
| /** | ||
| * ActionCable Client for Forthic | ||
| * Browser-compatible client that mirrors GrpcClient API | ||
| * Specifically designed for Rails ActionCable WebSocket protocol | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.ActionCableClient = void 0; | ||
| const serializer_js_1 = require("./serializer.js"); | ||
| const errors_js_1 = require("./errors.js"); | ||
| /** | ||
| * ActionCable client for executing words in remote Forthic runtimes | ||
| * Mirrors the GrpcClient API for compatibility | ||
| * Uses Rails ActionCable WebSocket protocol | ||
| */ | ||
| class ActionCableClient { | ||
| ws; | ||
| config; | ||
| pendingRequests = new Map(); | ||
| messageId = 0; | ||
| connected = false; | ||
| connectionPromise; | ||
| constructor(config) { | ||
| this.config = { | ||
| url: config.url, | ||
| timezone: config.timezone || 'UTC', | ||
| reconnect: config.reconnect ?? true, | ||
| reconnectDelay: config.reconnectDelay || 3000, | ||
| channel: config.channel || 'ForthicRuntimeChannel', | ||
| }; | ||
| this.connect(); | ||
| } | ||
| /** | ||
| * Connect to the WebSocket server | ||
| */ | ||
| connect() { | ||
| if (this.connectionPromise) { | ||
| return this.connectionPromise; | ||
| } | ||
| this.connectionPromise = new Promise((resolve, reject) => { | ||
| try { | ||
| this.ws = new WebSocket(this.config.url); | ||
| this.ws.onopen = () => { | ||
| this.connected = true; | ||
| // Subscribe to ActionCable channel | ||
| const subscribeMessage = { | ||
| command: 'subscribe', | ||
| identifier: JSON.stringify({ | ||
| channel: this.config.channel, | ||
| timezone: this.config.timezone, | ||
| }), | ||
| }; | ||
| this.ws.send(JSON.stringify(subscribeMessage)); | ||
| resolve(); | ||
| }; | ||
| this.ws.onmessage = (event) => { | ||
| this.handleMessage(event); | ||
| }; | ||
| this.ws.onerror = (error) => { | ||
| console.error('WebSocket error:', error); | ||
| reject(new Error('WebSocket connection error')); | ||
| }; | ||
| this.ws.onclose = () => { | ||
| this.connected = false; | ||
| this.connectionPromise = undefined; | ||
| // Reject all pending requests | ||
| for (const [id, pending] of this.pendingRequests.entries()) { | ||
| pending.reject(new Error('WebSocket connection closed')); | ||
| } | ||
| this.pendingRequests.clear(); | ||
| // Attempt reconnect if enabled | ||
| if (this.config.reconnect) { | ||
| setTimeout(() => this.connect(), this.config.reconnectDelay); | ||
| } | ||
| }; | ||
| } | ||
| catch (error) { | ||
| reject(error); | ||
| } | ||
| }); | ||
| return this.connectionPromise; | ||
| } | ||
| /** | ||
| * Handle incoming WebSocket messages | ||
| */ | ||
| handleMessage(event) { | ||
| try { | ||
| const data = JSON.parse(event.data); | ||
| // Handle ActionCable control messages | ||
| if (data.type === 'welcome' || data.type === 'ping' || data.type === 'confirm_subscription') { | ||
| return; | ||
| } | ||
| // Extract the actual message from ActionCable envelope | ||
| const message = data.message || data; | ||
| if (!message.id) { | ||
| console.warn('Received message without ID:', message); | ||
| return; | ||
| } | ||
| // Handle streaming progress updates | ||
| if (message.type === 'streaming_progress') { | ||
| const pending = this.pendingRequests.get(message.id); | ||
| if (pending?.onProgress) { | ||
| pending.onProgress(message.progress); | ||
| } | ||
| return; | ||
| } | ||
| // Handle final responses | ||
| const pending = this.pendingRequests.get(message.id); | ||
| if (!pending) { | ||
| console.warn('Received response for unknown request:', message.id); | ||
| return; | ||
| } | ||
| if (message.error) { | ||
| pending.reject(new errors_js_1.RemoteRuntimeError(message.error)); | ||
| } | ||
| else { | ||
| pending.resolve(message.result); | ||
| } | ||
| this.pendingRequests.delete(message.id); | ||
| } | ||
| catch (error) { | ||
| console.error('Error handling WebSocket message:', error); | ||
| } | ||
| } | ||
| /** | ||
| * Generate next message ID | ||
| */ | ||
| nextMessageId() { | ||
| return `msg-${++this.messageId}-${Date.now()}`; | ||
| } | ||
| /** | ||
| * Send a request and wait for response | ||
| * @template T The expected result type (the value of the `result` field) | ||
| */ | ||
| async sendRequest(message) { | ||
| await this.ensureConnected(); | ||
| return new Promise((resolve, reject) => { | ||
| this.pendingRequests.set(message.id, { resolve, reject }); | ||
| // Wrap message in ActionCable format | ||
| const actionCableMessage = { | ||
| command: 'message', | ||
| identifier: JSON.stringify({ | ||
| channel: this.config.channel, | ||
| }), | ||
| data: JSON.stringify(message), | ||
| }; | ||
| this.ws.send(JSON.stringify(actionCableMessage)); | ||
| }); | ||
| } | ||
| /** | ||
| * Send a streaming request with progress callbacks | ||
| * @template T The expected result type (the value of the `result` field) | ||
| */ | ||
| async sendStreamingRequest(message, onProgress) { | ||
| await this.ensureConnected(); | ||
| return new Promise((resolve, reject) => { | ||
| this.pendingRequests.set(message.id, { resolve, reject, onProgress }); | ||
| // Wrap message in ActionCable format | ||
| const actionCableMessage = { | ||
| command: 'message', | ||
| identifier: JSON.stringify({ | ||
| channel: this.config.channel, | ||
| }), | ||
| data: JSON.stringify(message), | ||
| }; | ||
| this.ws.send(JSON.stringify(actionCableMessage)); | ||
| }); | ||
| } | ||
| /** | ||
| * Ensure WebSocket is connected | ||
| */ | ||
| async ensureConnected() { | ||
| if (!this.connected) { | ||
| await this.connect(); | ||
| } | ||
| } | ||
| /** | ||
| * Execute a word in the remote runtime | ||
| * Mirrors GrpcClient.executeWord | ||
| */ | ||
| async executeWord(word, stack) { | ||
| const message = { | ||
| type: 'execute_word', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| word, | ||
| stack: (0, serializer_js_1.serializeStack)(stack), | ||
| }, | ||
| }; | ||
| const result = await this.sendRequest(message); | ||
| return (0, serializer_js_1.deserializeStack)(result.stack); | ||
| } | ||
| /** | ||
| * Execute a sequence of words (batched execution) | ||
| * Mirrors GrpcClient.executeSequence | ||
| */ | ||
| async executeSequence(words, stack) { | ||
| const message = { | ||
| type: 'execute_sequence', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| words, | ||
| stack: (0, serializer_js_1.serializeStack)(stack), | ||
| }, | ||
| }; | ||
| const result = await this.sendRequest(message); | ||
| return (0, serializer_js_1.deserializeStack)(result.stack); | ||
| } | ||
| /** | ||
| * List available runtime-specific modules | ||
| * Mirrors GrpcClient.listModules | ||
| */ | ||
| async listModules() { | ||
| const message = { | ||
| type: 'list_modules', | ||
| id: this.nextMessageId(), | ||
| }; | ||
| const result = await this.sendRequest(message); | ||
| return result.modules || []; | ||
| } | ||
| /** | ||
| * Get detailed information about a specific module | ||
| * Mirrors GrpcClient.getModuleInfo | ||
| */ | ||
| async getModuleInfo(moduleName) { | ||
| const message = { | ||
| type: 'get_module_info', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| module_name: moduleName, | ||
| }, | ||
| }; | ||
| return await this.sendRequest(message); | ||
| } | ||
| /** | ||
| * Execute code with streaming progress updates (NEW capability) | ||
| */ | ||
| async streamingExecute(code, stack, onProgress) { | ||
| const message = { | ||
| type: 'streaming_execute', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| code, | ||
| stack: (0, serializer_js_1.serializeStack)(stack), | ||
| }, | ||
| }; | ||
| const result = await this.sendStreamingRequest(message, onProgress); | ||
| return (0, serializer_js_1.deserializeStack)(result.stack); | ||
| } | ||
| /** | ||
| * Close the WebSocket connection | ||
| */ | ||
| close() { | ||
| if (this.ws) { | ||
| this.config.reconnect = false; // Disable auto-reconnect | ||
| this.ws.close(); | ||
| this.ws = undefined; | ||
| this.connected = false; | ||
| } | ||
| } | ||
| /** | ||
| * Check if the client is connected | ||
| */ | ||
| isConnected() { | ||
| return this.connected; | ||
| } | ||
| } | ||
| exports.ActionCableClient = ActionCableClient; | ||
| //# sourceMappingURL=action_cable_client.js.map |
| {"version":3,"file":"action_cable_client.js","sourceRoot":"","sources":["../../../src/websocket/action_cable_client.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,mDAA+E;AAC/E,2CAAiD;AAoIjD;;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AS,GAAG,KAAK,CAAC,CAAC,yBAAyB;YACxD,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AA1SD,8CA0SC"} |
| /** | ||
| * WebSocket Client for Forthic | ||
| * Browser-compatible client that mirrors GrpcClient API | ||
| * Connects to Rails ActionCable server and executes remote words | ||
| */ | ||
| import { StackValue } from './serializer.js'; | ||
| export interface ModuleSummary { | ||
| name: string; | ||
| description: string; | ||
| word_count: number; | ||
| } | ||
| export interface WordInfo { | ||
| name: string; | ||
| stack_effect: string; | ||
| description: string; | ||
| } | ||
| export interface ModuleInfo { | ||
| module_name: string; | ||
| words: WordInfo[]; | ||
| } | ||
| export interface ProgressUpdate { | ||
| step: number; | ||
| total_steps: number; | ||
| current_word: string; | ||
| message?: string; | ||
| partial_stack?: StackValue[]; | ||
| } | ||
| export interface WebSocketClientConfig { | ||
| url: string; | ||
| timezone?: string; | ||
| reconnect?: boolean; | ||
| reconnectDelay?: number; | ||
| channel?: string; | ||
| } | ||
| /** | ||
| * WebSocket client for executing words in remote Forthic runtimes | ||
| * Mirrors the GrpcClient API for compatibility | ||
| */ | ||
| export declare class WebSocketClient { | ||
| private ws?; | ||
| private config; | ||
| private pendingRequests; | ||
| private messageId; | ||
| private connected; | ||
| private connectionPromise?; | ||
| constructor(config: WebSocketClientConfig); | ||
| /** | ||
| * Connect to the WebSocket server | ||
| */ | ||
| private connect; | ||
| /** | ||
| * Handle incoming WebSocket messages | ||
| */ | ||
| private handleMessage; | ||
| /** | ||
| * Generate next message ID | ||
| */ | ||
| private nextMessageId; | ||
| /** | ||
| * Send a request and wait for response | ||
| */ | ||
| private sendRequest; | ||
| /** | ||
| * Send a streaming request with progress callbacks | ||
| */ | ||
| private sendStreamingRequest; | ||
| /** | ||
| * Ensure WebSocket is connected | ||
| */ | ||
| private ensureConnected; | ||
| /** | ||
| * Execute a word in the remote runtime | ||
| * Mirrors GrpcClient.executeWord | ||
| */ | ||
| executeWord(word: string, stack: any[]): Promise<any[]>; | ||
| /** | ||
| * Execute a sequence of words (batched execution) | ||
| * Mirrors GrpcClient.executeSequence | ||
| */ | ||
| executeSequence(words: string[], stack: any[]): Promise<any[]>; | ||
| /** | ||
| * List available runtime-specific modules | ||
| * Mirrors GrpcClient.listModules | ||
| */ | ||
| listModules(): Promise<ModuleSummary[]>; | ||
| /** | ||
| * Get detailed information about a specific module | ||
| * Mirrors GrpcClient.getModuleInfo | ||
| */ | ||
| getModuleInfo(moduleName: string): Promise<ModuleInfo>; | ||
| /** | ||
| * Execute code with streaming progress updates (NEW capability) | ||
| */ | ||
| streamingExecute(code: string, stack: any[], onProgress?: (progress: ProgressUpdate) => void): Promise<any[]>; | ||
| /** | ||
| * Close the WebSocket connection | ||
| */ | ||
| close(): void; | ||
| /** | ||
| * Check if the client is connected | ||
| */ | ||
| isConnected(): boolean; | ||
| } |
| "use strict"; | ||
| /** | ||
| * WebSocket Client for Forthic | ||
| * Browser-compatible client that mirrors GrpcClient API | ||
| * Connects to Rails ActionCable server and executes remote words | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.WebSocketClient = void 0; | ||
| const serializer_js_1 = require("./serializer.js"); | ||
| const errors_js_1 = require("./errors.js"); | ||
| /** | ||
| * WebSocket client for executing words in remote Forthic runtimes | ||
| * Mirrors the GrpcClient API for compatibility | ||
| */ | ||
| class WebSocketClient { | ||
| ws; | ||
| config; | ||
| pendingRequests = new Map(); | ||
| messageId = 0; | ||
| connected = false; | ||
| connectionPromise; | ||
| constructor(config) { | ||
| this.config = { | ||
| url: config.url, | ||
| timezone: config.timezone || 'UTC', | ||
| reconnect: config.reconnect ?? true, | ||
| reconnectDelay: config.reconnectDelay || 3000, | ||
| channel: config.channel || 'ForthicRuntimeChannel', | ||
| }; | ||
| this.connect(); | ||
| } | ||
| /** | ||
| * Connect to the WebSocket server | ||
| */ | ||
| connect() { | ||
| if (this.connectionPromise) { | ||
| return this.connectionPromise; | ||
| } | ||
| this.connectionPromise = new Promise((resolve, reject) => { | ||
| try { | ||
| this.ws = new WebSocket(this.config.url); | ||
| this.ws.onopen = () => { | ||
| this.connected = true; | ||
| // Subscribe to ActionCable channel | ||
| const subscribeMessage = { | ||
| command: 'subscribe', | ||
| identifier: JSON.stringify({ | ||
| channel: this.config.channel, | ||
| timezone: this.config.timezone, | ||
| }), | ||
| }; | ||
| this.ws.send(JSON.stringify(subscribeMessage)); | ||
| resolve(); | ||
| }; | ||
| this.ws.onmessage = (event) => { | ||
| this.handleMessage(event); | ||
| }; | ||
| this.ws.onerror = (error) => { | ||
| console.error('WebSocket error:', error); | ||
| reject(new Error('WebSocket connection error')); | ||
| }; | ||
| this.ws.onclose = () => { | ||
| this.connected = false; | ||
| this.connectionPromise = undefined; | ||
| // Reject all pending requests | ||
| for (const [id, pending] of this.pendingRequests.entries()) { | ||
| pending.reject(new Error('WebSocket connection closed')); | ||
| } | ||
| this.pendingRequests.clear(); | ||
| // Attempt reconnect if enabled | ||
| if (this.config.reconnect) { | ||
| setTimeout(() => this.connect(), this.config.reconnectDelay); | ||
| } | ||
| }; | ||
| } | ||
| catch (error) { | ||
| reject(error); | ||
| } | ||
| }); | ||
| return this.connectionPromise; | ||
| } | ||
| /** | ||
| * Handle incoming WebSocket messages | ||
| */ | ||
| handleMessage(event) { | ||
| try { | ||
| const data = JSON.parse(event.data); | ||
| // Handle ActionCable control messages | ||
| if (data.type === 'welcome' || data.type === 'ping' || data.type === 'confirm_subscription') { | ||
| return; | ||
| } | ||
| // Extract the actual message from ActionCable envelope | ||
| const message = data.message || data; | ||
| if (!message.id) { | ||
| console.warn('Received message without ID:', message); | ||
| return; | ||
| } | ||
| // Handle streaming progress updates | ||
| if (message.type === 'streaming_progress') { | ||
| const pending = this.pendingRequests.get(message.id); | ||
| if (pending?.onProgress) { | ||
| pending.onProgress(message.progress); | ||
| } | ||
| return; | ||
| } | ||
| // Handle final responses | ||
| const pending = this.pendingRequests.get(message.id); | ||
| if (!pending) { | ||
| console.warn('Received response for unknown request:', message.id); | ||
| return; | ||
| } | ||
| if (message.error) { | ||
| pending.reject(new errors_js_1.RemoteRuntimeError(message.error)); | ||
| } | ||
| else { | ||
| pending.resolve(message.result); | ||
| } | ||
| this.pendingRequests.delete(message.id); | ||
| } | ||
| catch (error) { | ||
| console.error('Error handling WebSocket message:', error); | ||
| } | ||
| } | ||
| /** | ||
| * Generate next message ID | ||
| */ | ||
| nextMessageId() { | ||
| return `msg-${++this.messageId}-${Date.now()}`; | ||
| } | ||
| /** | ||
| * Send a request and wait for response | ||
| */ | ||
| async sendRequest(message) { | ||
| await this.ensureConnected(); | ||
| return new Promise((resolve, reject) => { | ||
| this.pendingRequests.set(message.id, { resolve, reject }); | ||
| // Wrap message in ActionCable format | ||
| const actionCableMessage = { | ||
| command: 'message', | ||
| identifier: JSON.stringify({ | ||
| channel: this.config.channel, | ||
| }), | ||
| data: JSON.stringify(message), | ||
| }; | ||
| this.ws.send(JSON.stringify(actionCableMessage)); | ||
| }); | ||
| } | ||
| /** | ||
| * Send a streaming request with progress callbacks | ||
| */ | ||
| async sendStreamingRequest(message, onProgress) { | ||
| await this.ensureConnected(); | ||
| return new Promise((resolve, reject) => { | ||
| this.pendingRequests.set(message.id, { resolve, reject, onProgress }); | ||
| // Wrap message in ActionCable format | ||
| const actionCableMessage = { | ||
| command: 'message', | ||
| identifier: JSON.stringify({ | ||
| channel: this.config.channel, | ||
| }), | ||
| data: JSON.stringify(message), | ||
| }; | ||
| this.ws.send(JSON.stringify(actionCableMessage)); | ||
| }); | ||
| } | ||
| /** | ||
| * Ensure WebSocket is connected | ||
| */ | ||
| async ensureConnected() { | ||
| if (!this.connected) { | ||
| await this.connect(); | ||
| } | ||
| } | ||
| /** | ||
| * Execute a word in the remote runtime | ||
| * Mirrors GrpcClient.executeWord | ||
| */ | ||
| async executeWord(word, stack) { | ||
| const message = { | ||
| type: 'execute_word', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| word, | ||
| stack: (0, serializer_js_1.serializeStack)(stack), | ||
| }, | ||
| }; | ||
| const result = await this.sendRequest(message); | ||
| return (0, serializer_js_1.deserializeStack)(result.stack); | ||
| } | ||
| /** | ||
| * Execute a sequence of words (batched execution) | ||
| * Mirrors GrpcClient.executeSequence | ||
| */ | ||
| async executeSequence(words, stack) { | ||
| const message = { | ||
| type: 'execute_sequence', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| words, | ||
| stack: (0, serializer_js_1.serializeStack)(stack), | ||
| }, | ||
| }; | ||
| const result = await this.sendRequest(message); | ||
| return (0, serializer_js_1.deserializeStack)(result.stack); | ||
| } | ||
| /** | ||
| * List available runtime-specific modules | ||
| * Mirrors GrpcClient.listModules | ||
| */ | ||
| async listModules() { | ||
| const message = { | ||
| type: 'list_modules', | ||
| id: this.nextMessageId(), | ||
| }; | ||
| const result = await this.sendRequest(message); | ||
| return result.modules || []; | ||
| } | ||
| /** | ||
| * Get detailed information about a specific module | ||
| * Mirrors GrpcClient.getModuleInfo | ||
| */ | ||
| async getModuleInfo(moduleName) { | ||
| const message = { | ||
| type: 'get_module_info', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| module_name: moduleName, | ||
| }, | ||
| }; | ||
| return await this.sendRequest(message); | ||
| } | ||
| /** | ||
| * Execute code with streaming progress updates (NEW capability) | ||
| */ | ||
| async streamingExecute(code, stack, onProgress) { | ||
| const message = { | ||
| type: 'streaming_execute', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| code, | ||
| stack: (0, serializer_js_1.serializeStack)(stack), | ||
| }, | ||
| }; | ||
| const result = await this.sendStreamingRequest(message, onProgress); | ||
| return (0, serializer_js_1.deserializeStack)(result.stack); | ||
| } | ||
| /** | ||
| * Close the WebSocket connection | ||
| */ | ||
| close() { | ||
| if (this.ws) { | ||
| this.config.reconnect = false; // Disable auto-reconnect | ||
| this.ws.close(); | ||
| this.ws = undefined; | ||
| this.connected = false; | ||
| } | ||
| } | ||
| /** | ||
| * Check if the client is connected | ||
| */ | ||
| isConnected() { | ||
| return this.connected; | ||
| } | ||
| } | ||
| exports.WebSocketClient = WebSocketClient; | ||
| //# sourceMappingURL=client.js.map |
| {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/websocket/client.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,mDAA+E;AAC/E,2CAAiD;AAoIjD;;;GAGG;AACH,MAAa,eAAe;IAClB,EAAE,CAAa;IACf,MAAM,CAAkC;IACxC,eAAe,GAAgC,IAAI,GAAG,EAAE,CAAC;IACzD,SAAS,GAAW,CAAC,CAAC;IACtB,SAAS,GAAY,KAAK,CAAC;IAC3B,iBAAiB,CAAiB;IAE1C,YAAY,MAA6B;QACvC,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;YAClC,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;YACnC,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,IAAI;YAC7C,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,uBAAuB;SACnD,CAAC;QAEF,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED;;OAEG;IACK,OAAO;QACb,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,iBAAiB,CAAC;QAChC,CAAC;QAED,IAAI,CAAC,iBAAiB,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACvD,IAAI,CAAC;gBACH,IAAI,CAAC,EAAE,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAEzC,IAAI,C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AE;YACxB,MAAM,EAAE;gBACN,IAAI;gBACJ,KAAK,EAAE,IAAA,8BAAc,EAAC,KAAK,CAAC;aAC7B;SACF,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACpE,OAAO,IAAA,gCAAgB,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,yBAAyB;YACxD,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AAxSD,0CAwSC"} |
| /** | ||
| * WebSocketRemoteModule - Module that wraps runtime-specific words from a remote runtime | ||
| * Mirrors RemoteModule from gRPC implementation | ||
| */ | ||
| import { Module } from '../forthic/module.js'; | ||
| import { Interpreter } from '../forthic/interpreter.js'; | ||
| import { ActionCableClient, type ModuleInfo } from './action_cable_client.js'; | ||
| /** | ||
| * WebSocketRemoteModule - Module containing proxy words that execute in a remote runtime | ||
| * | ||
| * This module discovers words from a remote runtime (e.g., pandas module in Ruby) | ||
| * and creates WebSocketRemoteWord proxies for each discovered word. When used in TypeScript | ||
| * Forthic code, these words execute in the remote runtime via ActionCable. | ||
| * | ||
| * Example usage: | ||
| * ```typescript | ||
| * const client = new ActionCableClient({ url: 'ws://localhost:3000/cable' }); | ||
| * const pandasModule = new WebSocketRemoteModule('pandas', client, 'rails'); | ||
| * await pandasModule.initialize(); | ||
| * interp.register_module(pandasModule); | ||
| * interp.use_modules(['pandas']); | ||
| * | ||
| * // Now pandas words execute in Rails runtime | ||
| * await interp.run(` | ||
| * [ [[.name "Alice"] [.age 30]] REC] | ||
| * DF-FROM-RECORDS # Executes in Rails! | ||
| * `); | ||
| * ``` | ||
| */ | ||
| export declare class WebSocketRemoteModule extends Module { | ||
| private client; | ||
| private runtimeName; | ||
| private initialized; | ||
| private moduleInfo; | ||
| /** | ||
| * @param moduleName - Name of the module in the remote runtime (e.g., "pandas") | ||
| * @param client - ActionCable client connected to the remote runtime | ||
| * @param runtimeName - Name of the runtime (e.g., "rails") for debugging | ||
| */ | ||
| constructor(moduleName: string, client: ActionCableClient, runtimeName?: string); | ||
| /** | ||
| * Initialize the module by discovering words from the remote runtime | ||
| * | ||
| * This must be called before the module is registered with an interpreter. | ||
| * It fetches the module metadata and creates WebSocketRemoteWord proxies for each word. | ||
| */ | ||
| initialize(): Promise<void>; | ||
| /** | ||
| * Override set_interp to ensure module is initialized | ||
| */ | ||
| set_interp(interp: Interpreter): void; | ||
| /** | ||
| * Get the module metadata from the remote runtime | ||
| */ | ||
| getModuleInfo(): ModuleInfo | null; | ||
| /** | ||
| * Get runtime name for debugging | ||
| */ | ||
| getRuntimeName(): string; | ||
| /** | ||
| * Check if module is initialized | ||
| */ | ||
| isInitialized(): boolean; | ||
| /** | ||
| * Get count of discovered words | ||
| */ | ||
| getWordCount(): number; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.WebSocketRemoteModule = void 0; | ||
| /** | ||
| * WebSocketRemoteModule - Module that wraps runtime-specific words from a remote runtime | ||
| * Mirrors RemoteModule from gRPC implementation | ||
| */ | ||
| const module_js_1 = require("../forthic/module.js"); | ||
| const remote_word_js_1 = require("./remote_word.js"); | ||
| /** | ||
| * WebSocketRemoteModule - Module containing proxy words that execute in a remote runtime | ||
| * | ||
| * This module discovers words from a remote runtime (e.g., pandas module in Ruby) | ||
| * and creates WebSocketRemoteWord proxies for each discovered word. When used in TypeScript | ||
| * Forthic code, these words execute in the remote runtime via ActionCable. | ||
| * | ||
| * Example usage: | ||
| * ```typescript | ||
| * const client = new ActionCableClient({ url: 'ws://localhost:3000/cable' }); | ||
| * const pandasModule = new WebSocketRemoteModule('pandas', client, 'rails'); | ||
| * await pandasModule.initialize(); | ||
| * interp.register_module(pandasModule); | ||
| * interp.use_modules(['pandas']); | ||
| * | ||
| * // Now pandas words execute in Rails runtime | ||
| * await interp.run(` | ||
| * [ [[.name "Alice"] [.age 30]] REC] | ||
| * DF-FROM-RECORDS # Executes in Rails! | ||
| * `); | ||
| * ``` | ||
| */ | ||
| class WebSocketRemoteModule extends module_js_1.Module { | ||
| client; | ||
| runtimeName; | ||
| initialized = false; | ||
| moduleInfo = null; | ||
| /** | ||
| * @param moduleName - Name of the module in the remote runtime (e.g., "pandas") | ||
| * @param client - ActionCable client connected to the remote runtime | ||
| * @param runtimeName - Name of the runtime (e.g., "rails") for debugging | ||
| */ | ||
| constructor(moduleName, client, runtimeName = 'remote') { | ||
| super(moduleName); | ||
| this.client = client; | ||
| this.runtimeName = runtimeName; | ||
| } | ||
| /** | ||
| * Initialize the module by discovering words from the remote runtime | ||
| * | ||
| * This must be called before the module is registered with an interpreter. | ||
| * It fetches the module metadata and creates WebSocketRemoteWord proxies for each word. | ||
| */ | ||
| async initialize() { | ||
| if (this.initialized) { | ||
| return; | ||
| } | ||
| try { | ||
| // Discover module info from remote runtime | ||
| this.moduleInfo = await this.client.getModuleInfo(this.name); | ||
| // Create WebSocketRemoteWord for each discovered word | ||
| for (const wordInfo of this.moduleInfo.words) { | ||
| const remoteWord = new remote_word_js_1.WebSocketRemoteWord(wordInfo.name, this.client, this.runtimeName, this.name, wordInfo.stack_effect, wordInfo.description); | ||
| // Add as exportable word (visible when module is imported) | ||
| this.add_exportable_word(remoteWord); | ||
| } | ||
| this.initialized = true; | ||
| } | ||
| catch (error) { | ||
| throw new Error(`Failed to initialize remote module '${this.name}' from ${this.runtimeName} runtime: ${error.message}`); | ||
| } | ||
| } | ||
| /** | ||
| * Override set_interp to ensure module is initialized | ||
| */ | ||
| set_interp(interp) { | ||
| if (!this.initialized) { | ||
| throw new Error(`WebSocketRemoteModule '${this.name}' must be initialized before being registered with an interpreter. Call await module.initialize() first.`); | ||
| } | ||
| super.set_interp(interp); | ||
| } | ||
| /** | ||
| * Get the module metadata from the remote runtime | ||
| */ | ||
| getModuleInfo() { | ||
| return this.moduleInfo; | ||
| } | ||
| /** | ||
| * Get runtime name for debugging | ||
| */ | ||
| getRuntimeName() { | ||
| return this.runtimeName; | ||
| } | ||
| /** | ||
| * Check if module is initialized | ||
| */ | ||
| isInitialized() { | ||
| return this.initialized; | ||
| } | ||
| /** | ||
| * Get count of discovered words | ||
| */ | ||
| getWordCount() { | ||
| return this.moduleInfo?.words?.length || 0; | ||
| } | ||
| } | ||
| exports.WebSocketRemoteModule = WebSocketRemoteModule; | ||
| //# sourceMappingURL=remote_module.js.map |
| {"version":3,"file":"remote_module.js","sourceRoot":"","sources":["../../../src/websocket/remote_module.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,oDAA8C;AAG9C,qDAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,qBAAsB,SAAQ,kBAAM;IACvC,MAAM,CAAoB;IAC1B,WAAW,CAAS;IACpB,WAAW,GAAY,KAAK,CAAC;IAC7B,UAAU,GAAsB,IAAI,CAAC;IAE7C;;;;OAIG;IACH,YAAY,UAAkB,EAAE,MAAyB,EAAE,cAAsB,QAAQ;QACvF,KAAK,CAAC,UAAU,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACH,2CAA2C;YAC3C,IAAI,CAAC,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,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WebSocketRemoteWord - Word that executes in a remote runtime via ActionCable | ||
| * Mirrors RemoteWord from gRPC implementation | ||
| */ | ||
| import { Word, RuntimeInfo } from '../forthic/module.js'; | ||
| import { Interpreter } from '../forthic/interpreter.js'; | ||
| import { ActionCableClient } from './action_cable_client.js'; | ||
| /** | ||
| * WebSocketRemoteWord - Proxy word that delegates execution to a remote runtime | ||
| * | ||
| * When executed: | ||
| * 1. Captures current interpreter stack | ||
| * 2. Sends word name + stack to remote runtime via ActionCable | ||
| * 3. Replaces local stack with result stack from remote execution | ||
| * | ||
| * This allows seamless integration of remote runtime words | ||
| * into the local TypeScript interpreter. | ||
| */ | ||
| export declare class WebSocketRemoteWord extends Word { | ||
| private client; | ||
| private runtimeName; | ||
| private moduleName; | ||
| stackEffect: string; | ||
| description: string; | ||
| /** | ||
| * @param name - Word name (e.g., "DF_FROM_RECORDS") | ||
| * @param client - ActionCable client connected to remote runtime | ||
| * @param runtimeName - Name of remote runtime (e.g., "rails", "ruby") | ||
| * @param moduleName - Module name (e.g., "pandas") | ||
| * @param stackEffect - Stack notation (e.g., "( records:array -- df:DataFrame )") | ||
| * @param description - Human-readable description | ||
| */ | ||
| constructor(name: string, client: ActionCableClient, runtimeName: string, moduleName: string, stackEffect?: string, description?: string); | ||
| /** | ||
| * Execute word in remote runtime | ||
| * | ||
| * Captures entire stack, sends to remote runtime, and replaces stack with result. | ||
| */ | ||
| execute(interp: Interpreter): Promise<void>; | ||
| /** | ||
| * Get runtime name for debugging/introspection | ||
| */ | ||
| getRuntimeName(): string; | ||
| /** | ||
| * Get module name for debugging/introspection | ||
| */ | ||
| getModuleName(): string; | ||
| /** | ||
| * Get runtime execution information | ||
| * RemoteWords are runtime-specific and can only execute in their designated runtime | ||
| */ | ||
| getRuntimeInfo(): RuntimeInfo; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.WebSocketRemoteWord = void 0; | ||
| /** | ||
| * WebSocketRemoteWord - Word that executes in a remote runtime via ActionCable | ||
| * Mirrors RemoteWord from gRPC implementation | ||
| */ | ||
| const module_js_1 = require("../forthic/module.js"); | ||
| /** | ||
| * WebSocketRemoteWord - Proxy word that delegates execution to a remote runtime | ||
| * | ||
| * When executed: | ||
| * 1. Captures current interpreter stack | ||
| * 2. Sends word name + stack to remote runtime via ActionCable | ||
| * 3. Replaces local stack with result stack from remote execution | ||
| * | ||
| * This allows seamless integration of remote runtime words | ||
| * into the local TypeScript interpreter. | ||
| */ | ||
| class WebSocketRemoteWord extends module_js_1.Word { | ||
| client; | ||
| runtimeName; | ||
| moduleName; | ||
| stackEffect; | ||
| description; | ||
| /** | ||
| * @param name - Word name (e.g., "DF_FROM_RECORDS") | ||
| * @param client - ActionCable client connected to remote runtime | ||
| * @param runtimeName - Name of remote runtime (e.g., "rails", "ruby") | ||
| * @param moduleName - Module name (e.g., "pandas") | ||
| * @param stackEffect - Stack notation (e.g., "( records:array -- df:DataFrame )") | ||
| * @param description - Human-readable description | ||
| */ | ||
| constructor(name, client, runtimeName, moduleName, stackEffect = '( -- )', description = '') { | ||
| super(name); | ||
| this.client = client; | ||
| this.runtimeName = runtimeName; | ||
| this.moduleName = moduleName; | ||
| this.stackEffect = stackEffect; | ||
| this.description = description; | ||
| } | ||
| /** | ||
| * Execute word in remote runtime | ||
| * | ||
| * Captures entire stack, sends to remote runtime, and replaces stack with result. | ||
| */ | ||
| async execute(interp) { | ||
| try { | ||
| // Capture current stack state | ||
| const stack = interp.get_stack(); | ||
| const stackItems = stack.get_items(); | ||
| // Execute word in remote runtime | ||
| const resultStack = await this.client.executeWord(this.name, stackItems); | ||
| // Clear local stack and replace with result | ||
| while (interp.get_stack().length > 0) { | ||
| interp.stack_pop(); | ||
| } | ||
| // Push all result items | ||
| for (const item of resultStack) { | ||
| interp.stack_push(item); | ||
| } | ||
| } | ||
| catch (error) { | ||
| throw new Error(`Error executing remote word ${this.moduleName}.${this.name} in ${this.runtimeName} runtime: ${error.message}`); | ||
| } | ||
| } | ||
| /** | ||
| * Get runtime name for debugging/introspection | ||
| */ | ||
| getRuntimeName() { | ||
| return this.runtimeName; | ||
| } | ||
| /** | ||
| * Get module name for debugging/introspection | ||
| */ | ||
| getModuleName() { | ||
| return this.moduleName; | ||
| } | ||
| /** | ||
| * Get runtime execution information | ||
| * RemoteWords are runtime-specific and can only execute in their designated runtime | ||
| */ | ||
| getRuntimeInfo() { | ||
| return { | ||
| runtime: this.runtimeName, | ||
| isRemote: true, | ||
| isStandard: false, | ||
| availableIn: [this.runtimeName] | ||
| }; | ||
| } | ||
| } | ||
| exports.WebSocketRemoteWord = WebSocketRemoteWord; | ||
| //# sourceMappingURL=remote_word.js.map |
| {"version":3,"file":"remote_word.js","sourceRoot":"","sources":["../../../src/websocket/remote_word.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,oDAAyD;AAIzD;;;;;;;;;;GAUG;AACH,MAAa,mBAAoB,SAAQ,gBAAI;IACnC,MAAM,CAAoB;IAC1B,WAAW,CAAS;IACpB,UAAU,CAAS;IACpB,WAAW,CAAS;IACpB,WAAW,CAAS;IAE3B;;;;;;;OAOG;IACH,YACE,IAAY,EACZ,MAAyB,EACzB,WAAmB,EACnB,UAAkB,EAClB,cAAsB,QAAQ,EAC9B,cAAsB,EAAE;QAExB,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,MAAmB;QAC/B,IAAI,CAAC;YACH,8BAA8B;YAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;YACjC,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YAErC,iCAAiC;YACjC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAEzE,4CAA4C;YAC5C,OAAO,MAAM,CAAC,SAAS,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrC,MAAM,CAAC,SAAS,EAAE,CAAC;YACrB,CAAC;YAED,wBAAwB;YACxB,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;gBAC/B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,+BAA+B,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,WAAW,aAAc,KAAe,CAAC,OAAO,EAAE,CAC1H,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,cAAc;QACZ,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,WAAW;YACzB,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,KAAK;YACjB,WAAW,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;SAChC,CAAC;IACJ,CAAC;CACF;AAvFD,kDAuFC"} |
| /** | ||
| * WebSocketRuntimeManager - Singleton for managing ActionCable connections to remote runtimes | ||
| * | ||
| * Provides centralized access to ActionCable clients for different runtimes | ||
| * Mirrors the gRPC RuntimeManager API for compatibility | ||
| */ | ||
| import { ActionCableClient, ActionCableClientConfig } from './action_cable_client.js'; | ||
| /** | ||
| * WebSocketRuntimeManager - Manages ActionCable connections to remote Forthic runtimes | ||
| */ | ||
| export declare class WebSocketRuntimeManager { | ||
| private static instance; | ||
| private clients; | ||
| private constructor(); | ||
| /** | ||
| * Get the singleton instance | ||
| */ | ||
| static getInstance(): WebSocketRuntimeManager; | ||
| /** | ||
| * Connect to a runtime and register the client | ||
| * | ||
| * @param runtimeName - Name of the runtime (e.g., "rails", "ruby") | ||
| * @param url - ActionCable URL (e.g., "ws://localhost:3000/cable") | ||
| * @param config - Optional additional configuration | ||
| * @returns ActionCableClient instance | ||
| */ | ||
| connectRuntime(runtimeName: string, url: string, config?: Partial<ActionCableClientConfig>): ActionCableClient; | ||
| /** | ||
| * Register an ActionCable client for a specific runtime | ||
| * | ||
| * @param runtimeName - Name of the runtime (e.g., "rails", "ruby") | ||
| * @param client - ActionCableClient instance connected to that runtime | ||
| */ | ||
| registerClient(runtimeName: string, client: ActionCableClient): void; | ||
| /** | ||
| * Get the ActionCable client for a specific runtime | ||
| * | ||
| * @param runtimeName - Name of the runtime | ||
| * @returns ActionCableClient instance or undefined if not registered | ||
| */ | ||
| getClient(runtimeName: string): ActionCableClient | undefined; | ||
| /** | ||
| * Check if a runtime has a registered client | ||
| * | ||
| * @param runtimeName - Name of the runtime | ||
| * @returns True if client is registered | ||
| */ | ||
| hasClient(runtimeName: string): boolean; | ||
| /** | ||
| * Get all registered runtime names | ||
| * | ||
| * @returns Array of runtime names | ||
| */ | ||
| getRegisteredRuntimes(): string[]; | ||
| /** | ||
| * Disconnect a specific runtime | ||
| * | ||
| * @param runtimeName - Name of the runtime to disconnect | ||
| */ | ||
| disconnectRuntime(runtimeName: string): void; | ||
| /** | ||
| * Clear all registered clients (useful for testing) | ||
| */ | ||
| clearAll(): void; | ||
| /** | ||
| * Reset the singleton (useful for testing) | ||
| */ | ||
| static reset(): void; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.WebSocketRuntimeManager = void 0; | ||
| /** | ||
| * WebSocketRuntimeManager - Singleton for managing ActionCable connections to remote runtimes | ||
| * | ||
| * Provides centralized access to ActionCable clients for different runtimes | ||
| * Mirrors the gRPC RuntimeManager API for compatibility | ||
| */ | ||
| const action_cable_client_js_1 = require("./action_cable_client.js"); | ||
| /** | ||
| * WebSocketRuntimeManager - Manages ActionCable connections to remote Forthic runtimes | ||
| */ | ||
| class WebSocketRuntimeManager { | ||
| static instance = null; | ||
| clients; | ||
| constructor() { | ||
| this.clients = new Map(); | ||
| } | ||
| /** | ||
| * Get the singleton instance | ||
| */ | ||
| static getInstance() { | ||
| if (!WebSocketRuntimeManager.instance) { | ||
| WebSocketRuntimeManager.instance = new WebSocketRuntimeManager(); | ||
| } | ||
| return WebSocketRuntimeManager.instance; | ||
| } | ||
| /** | ||
| * Connect to a runtime and register the client | ||
| * | ||
| * @param runtimeName - Name of the runtime (e.g., "rails", "ruby") | ||
| * @param url - ActionCable URL (e.g., "ws://localhost:3000/cable") | ||
| * @param config - Optional additional configuration | ||
| * @returns ActionCableClient instance | ||
| */ | ||
| connectRuntime(runtimeName, url, config) { | ||
| // Create a new client for the runtime | ||
| const client = new action_cable_client_js_1.ActionCableClient({ url, ...config }); | ||
| // Register it | ||
| this.clients.set(runtimeName, client); | ||
| return client; | ||
| } | ||
| /** | ||
| * Register an ActionCable client for a specific runtime | ||
| * | ||
| * @param runtimeName - Name of the runtime (e.g., "rails", "ruby") | ||
| * @param client - ActionCableClient instance connected to that runtime | ||
| */ | ||
| registerClient(runtimeName, client) { | ||
| this.clients.set(runtimeName, client); | ||
| } | ||
| /** | ||
| * Get the ActionCable client for a specific runtime | ||
| * | ||
| * @param runtimeName - Name of the runtime | ||
| * @returns ActionCableClient instance or undefined if not registered | ||
| */ | ||
| getClient(runtimeName) { | ||
| return this.clients.get(runtimeName); | ||
| } | ||
| /** | ||
| * Check if a runtime has a registered client | ||
| * | ||
| * @param runtimeName - Name of the runtime | ||
| * @returns True if client is registered | ||
| */ | ||
| hasClient(runtimeName) { | ||
| return this.clients.has(runtimeName); | ||
| } | ||
| /** | ||
| * Get all registered runtime names | ||
| * | ||
| * @returns Array of runtime names | ||
| */ | ||
| getRegisteredRuntimes() { | ||
| return Array.from(this.clients.keys()); | ||
| } | ||
| /** | ||
| * Disconnect a specific runtime | ||
| * | ||
| * @param runtimeName - Name of the runtime to disconnect | ||
| */ | ||
| disconnectRuntime(runtimeName) { | ||
| const client = this.clients.get(runtimeName); | ||
| if (client) { | ||
| client.close(); | ||
| this.clients.delete(runtimeName); | ||
| } | ||
| } | ||
| /** | ||
| * Clear all registered clients (useful for testing) | ||
| */ | ||
| clearAll() { | ||
| // Close all clients | ||
| for (const client of this.clients.values()) { | ||
| client.close(); | ||
| } | ||
| this.clients.clear(); | ||
| } | ||
| /** | ||
| * Reset the singleton (useful for testing) | ||
| */ | ||
| static reset() { | ||
| if (WebSocketRuntimeManager.instance) { | ||
| WebSocketRuntimeManager.instance.clearAll(); | ||
| WebSocketRuntimeManager.instance = null; | ||
| } | ||
| } | ||
| } | ||
| exports.WebSocketRuntimeManager = WebSocketRuntimeManager; | ||
| //# sourceMappingURL=runtime_manager.js.map |
| {"version":3,"file":"runtime_manager.js","sourceRoot":"","sources":["../../../src/websocket/runtime_manager.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,qEAAsF;AAEtF;;GAEG;AACH,MAAa,uBAAuB;IAC1B,MAAM,CAAC,QAAQ,GAAmC,IAAI,CAAC;IACvD,OAAO,CAAiC;IAEhD;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,CAAC;YACtC,uBAAuB,CAAC,QAAQ,GAAG,IAAI,uBAAuB,EAAE,CAAC;QACnE,CAAC;QACD,OAAO,uBAAuB,CAAC,QAAQ,CAAC;IAC1C,CAAC;IAED;;;;;;;OAOG;IACH,cAAc,CACZ,WAAmB,EACnB,GAAW,EACX,MAAyC;QAEzC,sCAAsC;QACtC,MAAM,MAAM,GAA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AAuB,CAAC,QAAQ,EAAE,CAAC;YACrC,uBAAuB,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC5C,uBAAuB,CAAC,QAAQ,GAAG,IAAI,CAAC;QAC1C,CAAC;IACH,CAAC;;AA/GH,0DAgHC"} |
| export {}; |
| /** | ||
| * Phase 11.1: Basic server tests | ||
| * Verify that the TypeScript gRPC server can start and listen on port 50052 | ||
| */ | ||
| import { serve } from './server'; | ||
| import * as grpc from '@grpc/grpc-js'; | ||
| import * as protoLoader from '@grpc/proto-loader'; | ||
| import * as path from 'path'; | ||
| describe('TypeScript gRPC Server', () => { | ||
| let server = null; | ||
| const TEST_PORT = 50053; // Use different port to avoid conflicts | ||
| afterEach(async () => { | ||
| // Clean up server if running | ||
| if (server) { | ||
| await new Promise((resolve) => { | ||
| server.tryShutdown(() => { | ||
| resolve(); | ||
| }); | ||
| }); | ||
| server = null; | ||
| } | ||
| }); | ||
| test('server starts and listens on specified port', async () => { | ||
| // Start server in background (don't await) | ||
| const serverPromise = serve(TEST_PORT); | ||
| // Give server time to start | ||
| await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
| // Try to connect with a client | ||
| const possiblePaths = [ | ||
| path.join(__dirname, '../../../../forthic/protos/forthic_runtime.proto'), | ||
| path.join(__dirname, '../../../forthic/protos/forthic_runtime.proto'), | ||
| path.join(process.cwd(), '../forthic/protos/forthic_runtime.proto'), | ||
| ]; | ||
| let PROTO_PATH = possiblePaths[0]; | ||
| const fs = require('fs'); | ||
| for (const tryPath of possiblePaths) { | ||
| if (fs.existsSync(tryPath)) { | ||
| PROTO_PATH = tryPath; | ||
| break; | ||
| } | ||
| } | ||
| const packageDefinition = protoLoader.loadSync(PROTO_PATH, { | ||
| keepCase: true, | ||
| longs: Number, | ||
| enums: String, | ||
| defaults: true, | ||
| oneofs: true, | ||
| }); | ||
| const protoDescriptor = grpc.loadPackageDefinition(packageDefinition); | ||
| const forthicProto = protoDescriptor.forthic; | ||
| // Create client | ||
| const client = new forthicProto.ForthicRuntime(`localhost:${TEST_PORT}`, grpc.credentials.createInsecure()); | ||
| // Test that we can connect by calling ListModules | ||
| const response = await new Promise((resolve, reject) => { | ||
| client.ListModules({}, (error, response) => { | ||
| if (error) { | ||
| reject(error); | ||
| } | ||
| else { | ||
| resolve(response); | ||
| } | ||
| }); | ||
| }); | ||
| // Should succeed with empty module list (no TS-specific modules yet) | ||
| expect(response).toBeDefined(); | ||
| expect(response.modules).toBeDefined(); | ||
| expect(Array.isArray(response.modules)).toBe(true); | ||
| // Clean up client | ||
| grpc.closeClient(client); | ||
| }, 10000); // 10 second timeout | ||
| test('server can execute simple stdlib word', async () => { | ||
| // Start server | ||
| const serverPromise = serve(TEST_PORT); | ||
| await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
| // Load proto | ||
| const possiblePaths = [ | ||
| path.join(__dirname, '../../../../forthic/protos/forthic_runtime.proto'), | ||
| path.join(__dirname, '../../../forthic/protos/forthic_runtime.proto'), | ||
| path.join(process.cwd(), '../forthic/protos/forthic_runtime.proto'), | ||
| ]; | ||
| let PROTO_PATH = possiblePaths[0]; | ||
| const fs = require('fs'); | ||
| for (const tryPath of possiblePaths) { | ||
| if (fs.existsSync(tryPath)) { | ||
| PROTO_PATH = tryPath; | ||
| break; | ||
| } | ||
| } | ||
| const packageDefinition = protoLoader.loadSync(PROTO_PATH, { | ||
| keepCase: true, | ||
| longs: Number, | ||
| enums: String, | ||
| defaults: true, | ||
| oneofs: true, | ||
| }); | ||
| const protoDescriptor = grpc.loadPackageDefinition(packageDefinition); | ||
| const forthicProto = protoDescriptor.forthic; | ||
| const client = new forthicProto.ForthicRuntime(`localhost:${TEST_PORT}`, grpc.credentials.createInsecure()); | ||
| // Execute DUP word (duplicates top stack item) | ||
| const response = await new Promise((resolve, reject) => { | ||
| client.ExecuteWord({ | ||
| word_name: 'DUP', | ||
| stack: [{ int_value: 42 }], | ||
| }, (error, response) => { | ||
| if (error) { | ||
| reject(error); | ||
| } | ||
| else { | ||
| resolve(response); | ||
| } | ||
| }); | ||
| }); | ||
| // Should have [42, 42] on stack | ||
| expect(response.result_stack).toBeDefined(); | ||
| expect(response.result_stack.length).toBe(2); | ||
| expect(response.result_stack[0].int_value).toBe(42); | ||
| expect(response.result_stack[1].int_value).toBe(42); | ||
| grpc.closeClient(client); | ||
| }, 10000); | ||
| }); | ||
| //# sourceMappingURL=server.test.js.map |
| {"version":3,"file":"server.test.js","sourceRoot":"","sources":["../../../src/grpc/server.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,IAAI,MAAM,GAAuB,IAAI,CAAC;IACtC,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,wCAAwC;IAEjE,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,6BAA6B;QAC7B,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBAClC,MAAO,CAAC,WAAW,CAAC,GAAG,EAAE;oBACvB,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YACH,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;QAC7D,2CAA2C;QAC3C,MAAM,aAAa,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;QAEvC,4BAA4B;QAC5B,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;QAE1D,+BAA+B;QAC/B,MA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,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEpD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC,EAAE,KAAK,CAAC,CAAC;AACZ,CAAC,CAAC,CAAC"} |
| /** | ||
| * Temporal Type Utilities | ||
| * | ||
| * Provides duck-typing helpers for checking Temporal types. | ||
| * Uses duck typing instead of instanceof to avoid issues with multiple | ||
| * instances of temporal-polyfill being loaded. | ||
| */ | ||
| /** | ||
| * Check if a value is a Temporal.PlainDate | ||
| * PlainDate has year, month, day properties but no hour property | ||
| */ | ||
| export declare function isPlainDate(value: any): boolean; | ||
| /** | ||
| * Check if a value is a Temporal.Instant | ||
| * Instant has epochNanoseconds property as a bigint | ||
| */ | ||
| export declare function isInstant(value: any): boolean; | ||
| /** | ||
| * Check if a value is a Temporal.ZonedDateTime | ||
| * ZonedDateTime has a timeZoneId property | ||
| */ | ||
| export declare function isZonedDateTime(value: any): boolean; | ||
| /** | ||
| * Check if a value is a Temporal.PlainTime | ||
| * PlainTime has hour and minute properties but no year | ||
| */ | ||
| export declare function isPlainTime(value: any): boolean; | ||
| /** | ||
| * Check if a value is a Temporal.PlainDateTime | ||
| * PlainDateTime has year, month, day, hour properties but no timeZoneId | ||
| */ | ||
| export declare function isPlainDateTime(value: any): boolean; | ||
| /** | ||
| * Check if a value is any Temporal type | ||
| */ | ||
| export declare function isTemporal(value: any): boolean; |
| /** | ||
| * Temporal Type Utilities | ||
| * | ||
| * Provides duck-typing helpers for checking Temporal types. | ||
| * Uses duck typing instead of instanceof to avoid issues with multiple | ||
| * instances of temporal-polyfill being loaded. | ||
| */ | ||
| /** | ||
| * Check if a value is a Temporal.PlainDate | ||
| * PlainDate has year, month, day properties but no hour property | ||
| */ | ||
| export function isPlainDate(value) { | ||
| return value && typeof value === 'object' && | ||
| typeof value.year === 'number' && | ||
| typeof value.month === 'number' && | ||
| typeof value.day === 'number' && | ||
| typeof value.toString === 'function' && | ||
| !value.hour; // PlainDate doesn't have hour | ||
| } | ||
| /** | ||
| * Check if a value is a Temporal.Instant | ||
| * Instant has epochNanoseconds property as a bigint | ||
| */ | ||
| export function isInstant(value) { | ||
| return value && typeof value === 'object' && | ||
| typeof value.epochNanoseconds === 'bigint' && | ||
| typeof value.toString === 'function'; | ||
| } | ||
| /** | ||
| * Check if a value is a Temporal.ZonedDateTime | ||
| * ZonedDateTime has a timeZoneId property | ||
| */ | ||
| export function isZonedDateTime(value) { | ||
| return value && typeof value === 'object' && | ||
| typeof value.timeZoneId === 'string' && | ||
| typeof value.toString === 'function'; | ||
| } | ||
| /** | ||
| * Check if a value is a Temporal.PlainTime | ||
| * PlainTime has hour and minute properties but no year | ||
| */ | ||
| export function isPlainTime(value) { | ||
| return value && typeof value === 'object' && | ||
| typeof value.hour === 'number' && | ||
| typeof value.minute === 'number' && | ||
| typeof value.toString === 'function' && | ||
| !value.year; // PlainTime doesn't have year | ||
| } | ||
| /** | ||
| * Check if a value is a Temporal.PlainDateTime | ||
| * PlainDateTime has year, month, day, hour properties but no timeZoneId | ||
| */ | ||
| export function isPlainDateTime(value) { | ||
| return value && typeof value === 'object' && | ||
| typeof value.year === 'number' && | ||
| typeof value.month === 'number' && | ||
| typeof value.day === 'number' && | ||
| typeof value.hour === 'number' && | ||
| typeof value.toString === 'function' && | ||
| !value.timeZoneId; // PlainDateTime doesn't have timeZoneId | ||
| } | ||
| /** | ||
| * Check if a value is any Temporal type | ||
| */ | ||
| export function isTemporal(value) { | ||
| return isPlainDate(value) || | ||
| isInstant(value) || | ||
| isZonedDateTime(value) || | ||
| isPlainTime(value) || | ||
| isPlainDateTime(value); | ||
| } | ||
| //# sourceMappingURL=temporal_utils.js.map |
| {"version":3,"file":"temporal_utils.js","sourceRoot":"","sources":["../../../src/grpc/temporal_utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAU;IACpC,OAAO,KAAK,IAAI,OAAO,KAAK,KA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,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU;QACpC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAE,wCAAwC;AACrE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAU;IACnC,OAAO,WAAW,CAAC,KAAK,CAAC;QAClB,SAAS,CAAC,KAAK,CAAC;QAChB,eAAe,CAAC,KAAK,CAAC;QACtB,WAAW,CAAC,KAAK,CAAC;QAClB,eAAe,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC"} |
| /** | ||
| * ActionCable Client for Forthic | ||
| * Browser-compatible client that mirrors GrpcClient API | ||
| * Specifically designed for Rails ActionCable WebSocket protocol | ||
| */ | ||
| import { StackValue } from './serializer.js'; | ||
| export interface ModuleSummary { | ||
| name: string; | ||
| description: string; | ||
| word_count: number; | ||
| } | ||
| export interface WordInfo { | ||
| name: string; | ||
| stack_effect: string; | ||
| description: string; | ||
| } | ||
| export interface ModuleInfo { | ||
| module_name: string; | ||
| words: WordInfo[]; | ||
| } | ||
| export interface ProgressUpdate { | ||
| step: number; | ||
| total_steps: number; | ||
| current_word: string; | ||
| message?: string; | ||
| partial_stack?: StackValue[]; | ||
| } | ||
| export interface ActionCableClientConfig { | ||
| url: string; | ||
| timezone?: string; | ||
| reconnect?: boolean; | ||
| reconnectDelay?: number; | ||
| channel?: string; | ||
| } | ||
| /** | ||
| * ActionCable client for executing words in remote Forthic runtimes | ||
| * Mirrors the GrpcClient API for compatibility | ||
| * Uses Rails ActionCable WebSocket protocol | ||
| */ | ||
| export declare class ActionCableClient { | ||
| private ws?; | ||
| private config; | ||
| private pendingRequests; | ||
| private messageId; | ||
| private connected; | ||
| private connectionPromise?; | ||
| constructor(config: ActionCableClientConfig); | ||
| /** | ||
| * Connect to the WebSocket server | ||
| */ | ||
| private connect; | ||
| /** | ||
| * Handle incoming WebSocket messages | ||
| */ | ||
| private handleMessage; | ||
| /** | ||
| * Generate next message ID | ||
| */ | ||
| private nextMessageId; | ||
| /** | ||
| * Send a request and wait for response | ||
| * @template T The expected result type (the value of the `result` field) | ||
| */ | ||
| private sendRequest; | ||
| /** | ||
| * Send a streaming request with progress callbacks | ||
| * @template T The expected result type (the value of the `result` field) | ||
| */ | ||
| private sendStreamingRequest; | ||
| /** | ||
| * Ensure WebSocket is connected | ||
| */ | ||
| private ensureConnected; | ||
| /** | ||
| * Execute a word in the remote runtime | ||
| * Mirrors GrpcClient.executeWord | ||
| */ | ||
| executeWord(word: string, stack: any[]): Promise<any[]>; | ||
| /** | ||
| * Execute a sequence of words (batched execution) | ||
| * Mirrors GrpcClient.executeSequence | ||
| */ | ||
| executeSequence(words: string[], stack: any[]): Promise<any[]>; | ||
| /** | ||
| * List available runtime-specific modules | ||
| * Mirrors GrpcClient.listModules | ||
| */ | ||
| listModules(): Promise<ModuleSummary[]>; | ||
| /** | ||
| * Get detailed information about a specific module | ||
| * Mirrors GrpcClient.getModuleInfo | ||
| */ | ||
| getModuleInfo(moduleName: string): Promise<ModuleInfo>; | ||
| /** | ||
| * Execute code with streaming progress updates (NEW capability) | ||
| */ | ||
| streamingExecute(code: string, stack: any[], onProgress?: (progress: ProgressUpdate) => void): Promise<any[]>; | ||
| /** | ||
| * Close the WebSocket connection | ||
| */ | ||
| close(): void; | ||
| /** | ||
| * Check if the client is connected | ||
| */ | ||
| isConnected(): boolean; | ||
| } |
| /** | ||
| * ActionCable Client for Forthic | ||
| * Browser-compatible client that mirrors GrpcClient API | ||
| * Specifically designed for Rails ActionCable WebSocket protocol | ||
| */ | ||
| import { serializeStack, deserializeStack } from './serializer.js'; | ||
| import { RemoteRuntimeError } from './errors.js'; | ||
| /** | ||
| * ActionCable client for executing words in remote Forthic runtimes | ||
| * Mirrors the GrpcClient API for compatibility | ||
| * Uses Rails ActionCable WebSocket protocol | ||
| */ | ||
| export class ActionCableClient { | ||
| ws; | ||
| config; | ||
| pendingRequests = new Map(); | ||
| messageId = 0; | ||
| connected = false; | ||
| connectionPromise; | ||
| constructor(config) { | ||
| this.config = { | ||
| url: config.url, | ||
| timezone: config.timezone || 'UTC', | ||
| reconnect: config.reconnect ?? true, | ||
| reconnectDelay: config.reconnectDelay || 3000, | ||
| channel: config.channel || 'ForthicRuntimeChannel', | ||
| }; | ||
| this.connect(); | ||
| } | ||
| /** | ||
| * Connect to the WebSocket server | ||
| */ | ||
| connect() { | ||
| if (this.connectionPromise) { | ||
| return this.connectionPromise; | ||
| } | ||
| this.connectionPromise = new Promise((resolve, reject) => { | ||
| try { | ||
| this.ws = new WebSocket(this.config.url); | ||
| this.ws.onopen = () => { | ||
| this.connected = true; | ||
| // Subscribe to ActionCable channel | ||
| const subscribeMessage = { | ||
| command: 'subscribe', | ||
| identifier: JSON.stringify({ | ||
| channel: this.config.channel, | ||
| timezone: this.config.timezone, | ||
| }), | ||
| }; | ||
| this.ws.send(JSON.stringify(subscribeMessage)); | ||
| resolve(); | ||
| }; | ||
| this.ws.onmessage = (event) => { | ||
| this.handleMessage(event); | ||
| }; | ||
| this.ws.onerror = (error) => { | ||
| console.error('WebSocket error:', error); | ||
| reject(new Error('WebSocket connection error')); | ||
| }; | ||
| this.ws.onclose = () => { | ||
| this.connected = false; | ||
| this.connectionPromise = undefined; | ||
| // Reject all pending requests | ||
| for (const [id, pending] of this.pendingRequests.entries()) { | ||
| pending.reject(new Error('WebSocket connection closed')); | ||
| } | ||
| this.pendingRequests.clear(); | ||
| // Attempt reconnect if enabled | ||
| if (this.config.reconnect) { | ||
| setTimeout(() => this.connect(), this.config.reconnectDelay); | ||
| } | ||
| }; | ||
| } | ||
| catch (error) { | ||
| reject(error); | ||
| } | ||
| }); | ||
| return this.connectionPromise; | ||
| } | ||
| /** | ||
| * Handle incoming WebSocket messages | ||
| */ | ||
| handleMessage(event) { | ||
| try { | ||
| const data = JSON.parse(event.data); | ||
| // Handle ActionCable control messages | ||
| if (data.type === 'welcome' || data.type === 'ping' || data.type === 'confirm_subscription') { | ||
| return; | ||
| } | ||
| // Extract the actual message from ActionCable envelope | ||
| const message = data.message || data; | ||
| if (!message.id) { | ||
| console.warn('Received message without ID:', message); | ||
| return; | ||
| } | ||
| // Handle streaming progress updates | ||
| if (message.type === 'streaming_progress') { | ||
| const pending = this.pendingRequests.get(message.id); | ||
| if (pending?.onProgress) { | ||
| pending.onProgress(message.progress); | ||
| } | ||
| return; | ||
| } | ||
| // Handle final responses | ||
| const pending = this.pendingRequests.get(message.id); | ||
| if (!pending) { | ||
| console.warn('Received response for unknown request:', message.id); | ||
| return; | ||
| } | ||
| if (message.error) { | ||
| pending.reject(new RemoteRuntimeError(message.error)); | ||
| } | ||
| else { | ||
| pending.resolve(message.result); | ||
| } | ||
| this.pendingRequests.delete(message.id); | ||
| } | ||
| catch (error) { | ||
| console.error('Error handling WebSocket message:', error); | ||
| } | ||
| } | ||
| /** | ||
| * Generate next message ID | ||
| */ | ||
| nextMessageId() { | ||
| return `msg-${++this.messageId}-${Date.now()}`; | ||
| } | ||
| /** | ||
| * Send a request and wait for response | ||
| * @template T The expected result type (the value of the `result` field) | ||
| */ | ||
| async sendRequest(message) { | ||
| await this.ensureConnected(); | ||
| return new Promise((resolve, reject) => { | ||
| this.pendingRequests.set(message.id, { resolve, reject }); | ||
| // Wrap message in ActionCable format | ||
| const actionCableMessage = { | ||
| command: 'message', | ||
| identifier: JSON.stringify({ | ||
| channel: this.config.channel, | ||
| }), | ||
| data: JSON.stringify(message), | ||
| }; | ||
| this.ws.send(JSON.stringify(actionCableMessage)); | ||
| }); | ||
| } | ||
| /** | ||
| * Send a streaming request with progress callbacks | ||
| * @template T The expected result type (the value of the `result` field) | ||
| */ | ||
| async sendStreamingRequest(message, onProgress) { | ||
| await this.ensureConnected(); | ||
| return new Promise((resolve, reject) => { | ||
| this.pendingRequests.set(message.id, { resolve, reject, onProgress }); | ||
| // Wrap message in ActionCable format | ||
| const actionCableMessage = { | ||
| command: 'message', | ||
| identifier: JSON.stringify({ | ||
| channel: this.config.channel, | ||
| }), | ||
| data: JSON.stringify(message), | ||
| }; | ||
| this.ws.send(JSON.stringify(actionCableMessage)); | ||
| }); | ||
| } | ||
| /** | ||
| * Ensure WebSocket is connected | ||
| */ | ||
| async ensureConnected() { | ||
| if (!this.connected) { | ||
| await this.connect(); | ||
| } | ||
| } | ||
| /** | ||
| * Execute a word in the remote runtime | ||
| * Mirrors GrpcClient.executeWord | ||
| */ | ||
| async executeWord(word, stack) { | ||
| const message = { | ||
| type: 'execute_word', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| word, | ||
| stack: serializeStack(stack), | ||
| }, | ||
| }; | ||
| const result = await this.sendRequest(message); | ||
| return deserializeStack(result.stack); | ||
| } | ||
| /** | ||
| * Execute a sequence of words (batched execution) | ||
| * Mirrors GrpcClient.executeSequence | ||
| */ | ||
| async executeSequence(words, stack) { | ||
| const message = { | ||
| type: 'execute_sequence', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| words, | ||
| stack: serializeStack(stack), | ||
| }, | ||
| }; | ||
| const result = await this.sendRequest(message); | ||
| return deserializeStack(result.stack); | ||
| } | ||
| /** | ||
| * List available runtime-specific modules | ||
| * Mirrors GrpcClient.listModules | ||
| */ | ||
| async listModules() { | ||
| const message = { | ||
| type: 'list_modules', | ||
| id: this.nextMessageId(), | ||
| }; | ||
| const result = await this.sendRequest(message); | ||
| return result.modules || []; | ||
| } | ||
| /** | ||
| * Get detailed information about a specific module | ||
| * Mirrors GrpcClient.getModuleInfo | ||
| */ | ||
| async getModuleInfo(moduleName) { | ||
| const message = { | ||
| type: 'get_module_info', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| module_name: moduleName, | ||
| }, | ||
| }; | ||
| return await this.sendRequest(message); | ||
| } | ||
| /** | ||
| * Execute code with streaming progress updates (NEW capability) | ||
| */ | ||
| async streamingExecute(code, stack, onProgress) { | ||
| const message = { | ||
| type: 'streaming_execute', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| code, | ||
| stack: serializeStack(stack), | ||
| }, | ||
| }; | ||
| const result = await this.sendStreamingRequest(message, onProgress); | ||
| return deserializeStack(result.stack); | ||
| } | ||
| /** | ||
| * Close the WebSocket connection | ||
| */ | ||
| close() { | ||
| if (this.ws) { | ||
| this.config.reconnect = false; // Disable auto-reconnect | ||
| this.ws.close(); | ||
| this.ws = undefined; | ||
| this.connected = false; | ||
| } | ||
| } | ||
| /** | ||
| * Check if the client is connected | ||
| */ | ||
| isConnected() { | ||
| return this.connected; | ||
| } | ||
| } | ||
| //# sourceMappingURL=action_cable_client.js.map |
| {"version":3,"file":"action_cable_client.js","sourceRoot":"","sources":["../../../src/websocket/action_cable_client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAc,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAoIjD;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACpB,EAAE,CAAa;IACf,MAAM,CAAoC;IAC1C,eAAe,GAAgC,IAAI,GAAG,EAAE,CAAC;IACzD,SAAS,GAAW,CAAC,CAAC;IACtB,SAAS,GAAY,KAAK,CAAC;IAC3B,iBAAiB,CAAiB;IAE1C,YAAY,MAA+B;QACzC,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;YAClC,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;YACnC,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,IAAI;YAC7C,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,uBAAuB;SACnD,CAAC;QAEF,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED;;OAEG;IACK,OAAO;QACb,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,iBAAiB,CAAC;QAChC,CAAC;QAED,IAAI,CAAC,iBAAiB,GAAG,IAAI,OAAO,CAAC,CAAC,O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AgB,CACpB,IAAY,EACZ,KAAY,EACZ,UAA+C;QAE/C,MAAM,OAAO,GAA4B;YACvC,IAAI,EAAE,mBAAmB;YACzB,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE;YACxB,MAAM,EAAE;gBACN,IAAI;gBACJ,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;aAC7B;SACF,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAA0B,OAAO,EAAE,UAAU,CAAC,CAAC;QAC7F,OAAO,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,yBAAyB;YACxD,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"} |
| /** | ||
| * WebSocket Client for Forthic | ||
| * Browser-compatible client that mirrors GrpcClient API | ||
| * Connects to Rails ActionCable server and executes remote words | ||
| */ | ||
| import { StackValue } from './serializer.js'; | ||
| export interface ModuleSummary { | ||
| name: string; | ||
| description: string; | ||
| word_count: number; | ||
| } | ||
| export interface WordInfo { | ||
| name: string; | ||
| stack_effect: string; | ||
| description: string; | ||
| } | ||
| export interface ModuleInfo { | ||
| module_name: string; | ||
| words: WordInfo[]; | ||
| } | ||
| export interface ProgressUpdate { | ||
| step: number; | ||
| total_steps: number; | ||
| current_word: string; | ||
| message?: string; | ||
| partial_stack?: StackValue[]; | ||
| } | ||
| export interface WebSocketClientConfig { | ||
| url: string; | ||
| timezone?: string; | ||
| reconnect?: boolean; | ||
| reconnectDelay?: number; | ||
| channel?: string; | ||
| } | ||
| /** | ||
| * WebSocket client for executing words in remote Forthic runtimes | ||
| * Mirrors the GrpcClient API for compatibility | ||
| */ | ||
| export declare class WebSocketClient { | ||
| private ws?; | ||
| private config; | ||
| private pendingRequests; | ||
| private messageId; | ||
| private connected; | ||
| private connectionPromise?; | ||
| constructor(config: WebSocketClientConfig); | ||
| /** | ||
| * Connect to the WebSocket server | ||
| */ | ||
| private connect; | ||
| /** | ||
| * Handle incoming WebSocket messages | ||
| */ | ||
| private handleMessage; | ||
| /** | ||
| * Generate next message ID | ||
| */ | ||
| private nextMessageId; | ||
| /** | ||
| * Send a request and wait for response | ||
| */ | ||
| private sendRequest; | ||
| /** | ||
| * Send a streaming request with progress callbacks | ||
| */ | ||
| private sendStreamingRequest; | ||
| /** | ||
| * Ensure WebSocket is connected | ||
| */ | ||
| private ensureConnected; | ||
| /** | ||
| * Execute a word in the remote runtime | ||
| * Mirrors GrpcClient.executeWord | ||
| */ | ||
| executeWord(word: string, stack: any[]): Promise<any[]>; | ||
| /** | ||
| * Execute a sequence of words (batched execution) | ||
| * Mirrors GrpcClient.executeSequence | ||
| */ | ||
| executeSequence(words: string[], stack: any[]): Promise<any[]>; | ||
| /** | ||
| * List available runtime-specific modules | ||
| * Mirrors GrpcClient.listModules | ||
| */ | ||
| listModules(): Promise<ModuleSummary[]>; | ||
| /** | ||
| * Get detailed information about a specific module | ||
| * Mirrors GrpcClient.getModuleInfo | ||
| */ | ||
| getModuleInfo(moduleName: string): Promise<ModuleInfo>; | ||
| /** | ||
| * Execute code with streaming progress updates (NEW capability) | ||
| */ | ||
| streamingExecute(code: string, stack: any[], onProgress?: (progress: ProgressUpdate) => void): Promise<any[]>; | ||
| /** | ||
| * Close the WebSocket connection | ||
| */ | ||
| close(): void; | ||
| /** | ||
| * Check if the client is connected | ||
| */ | ||
| isConnected(): boolean; | ||
| } |
| /** | ||
| * WebSocket Client for Forthic | ||
| * Browser-compatible client that mirrors GrpcClient API | ||
| * Connects to Rails ActionCable server and executes remote words | ||
| */ | ||
| import { serializeStack, deserializeStack } from './serializer.js'; | ||
| import { RemoteRuntimeError } from './errors.js'; | ||
| /** | ||
| * WebSocket client for executing words in remote Forthic runtimes | ||
| * Mirrors the GrpcClient API for compatibility | ||
| */ | ||
| export class WebSocketClient { | ||
| ws; | ||
| config; | ||
| pendingRequests = new Map(); | ||
| messageId = 0; | ||
| connected = false; | ||
| connectionPromise; | ||
| constructor(config) { | ||
| this.config = { | ||
| url: config.url, | ||
| timezone: config.timezone || 'UTC', | ||
| reconnect: config.reconnect ?? true, | ||
| reconnectDelay: config.reconnectDelay || 3000, | ||
| channel: config.channel || 'ForthicRuntimeChannel', | ||
| }; | ||
| this.connect(); | ||
| } | ||
| /** | ||
| * Connect to the WebSocket server | ||
| */ | ||
| connect() { | ||
| if (this.connectionPromise) { | ||
| return this.connectionPromise; | ||
| } | ||
| this.connectionPromise = new Promise((resolve, reject) => { | ||
| try { | ||
| this.ws = new WebSocket(this.config.url); | ||
| this.ws.onopen = () => { | ||
| this.connected = true; | ||
| // Subscribe to ActionCable channel | ||
| const subscribeMessage = { | ||
| command: 'subscribe', | ||
| identifier: JSON.stringify({ | ||
| channel: this.config.channel, | ||
| timezone: this.config.timezone, | ||
| }), | ||
| }; | ||
| this.ws.send(JSON.stringify(subscribeMessage)); | ||
| resolve(); | ||
| }; | ||
| this.ws.onmessage = (event) => { | ||
| this.handleMessage(event); | ||
| }; | ||
| this.ws.onerror = (error) => { | ||
| console.error('WebSocket error:', error); | ||
| reject(new Error('WebSocket connection error')); | ||
| }; | ||
| this.ws.onclose = () => { | ||
| this.connected = false; | ||
| this.connectionPromise = undefined; | ||
| // Reject all pending requests | ||
| for (const [id, pending] of this.pendingRequests.entries()) { | ||
| pending.reject(new Error('WebSocket connection closed')); | ||
| } | ||
| this.pendingRequests.clear(); | ||
| // Attempt reconnect if enabled | ||
| if (this.config.reconnect) { | ||
| setTimeout(() => this.connect(), this.config.reconnectDelay); | ||
| } | ||
| }; | ||
| } | ||
| catch (error) { | ||
| reject(error); | ||
| } | ||
| }); | ||
| return this.connectionPromise; | ||
| } | ||
| /** | ||
| * Handle incoming WebSocket messages | ||
| */ | ||
| handleMessage(event) { | ||
| try { | ||
| const data = JSON.parse(event.data); | ||
| // Handle ActionCable control messages | ||
| if (data.type === 'welcome' || data.type === 'ping' || data.type === 'confirm_subscription') { | ||
| return; | ||
| } | ||
| // Extract the actual message from ActionCable envelope | ||
| const message = data.message || data; | ||
| if (!message.id) { | ||
| console.warn('Received message without ID:', message); | ||
| return; | ||
| } | ||
| // Handle streaming progress updates | ||
| if (message.type === 'streaming_progress') { | ||
| const pending = this.pendingRequests.get(message.id); | ||
| if (pending?.onProgress) { | ||
| pending.onProgress(message.progress); | ||
| } | ||
| return; | ||
| } | ||
| // Handle final responses | ||
| const pending = this.pendingRequests.get(message.id); | ||
| if (!pending) { | ||
| console.warn('Received response for unknown request:', message.id); | ||
| return; | ||
| } | ||
| if (message.error) { | ||
| pending.reject(new RemoteRuntimeError(message.error)); | ||
| } | ||
| else { | ||
| pending.resolve(message.result); | ||
| } | ||
| this.pendingRequests.delete(message.id); | ||
| } | ||
| catch (error) { | ||
| console.error('Error handling WebSocket message:', error); | ||
| } | ||
| } | ||
| /** | ||
| * Generate next message ID | ||
| */ | ||
| nextMessageId() { | ||
| return `msg-${++this.messageId}-${Date.now()}`; | ||
| } | ||
| /** | ||
| * Send a request and wait for response | ||
| */ | ||
| async sendRequest(message) { | ||
| await this.ensureConnected(); | ||
| return new Promise((resolve, reject) => { | ||
| this.pendingRequests.set(message.id, { resolve, reject }); | ||
| // Wrap message in ActionCable format | ||
| const actionCableMessage = { | ||
| command: 'message', | ||
| identifier: JSON.stringify({ | ||
| channel: this.config.channel, | ||
| }), | ||
| data: JSON.stringify(message), | ||
| }; | ||
| this.ws.send(JSON.stringify(actionCableMessage)); | ||
| }); | ||
| } | ||
| /** | ||
| * Send a streaming request with progress callbacks | ||
| */ | ||
| async sendStreamingRequest(message, onProgress) { | ||
| await this.ensureConnected(); | ||
| return new Promise((resolve, reject) => { | ||
| this.pendingRequests.set(message.id, { resolve, reject, onProgress }); | ||
| // Wrap message in ActionCable format | ||
| const actionCableMessage = { | ||
| command: 'message', | ||
| identifier: JSON.stringify({ | ||
| channel: this.config.channel, | ||
| }), | ||
| data: JSON.stringify(message), | ||
| }; | ||
| this.ws.send(JSON.stringify(actionCableMessage)); | ||
| }); | ||
| } | ||
| /** | ||
| * Ensure WebSocket is connected | ||
| */ | ||
| async ensureConnected() { | ||
| if (!this.connected) { | ||
| await this.connect(); | ||
| } | ||
| } | ||
| /** | ||
| * Execute a word in the remote runtime | ||
| * Mirrors GrpcClient.executeWord | ||
| */ | ||
| async executeWord(word, stack) { | ||
| const message = { | ||
| type: 'execute_word', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| word, | ||
| stack: serializeStack(stack), | ||
| }, | ||
| }; | ||
| const result = await this.sendRequest(message); | ||
| return deserializeStack(result.stack); | ||
| } | ||
| /** | ||
| * Execute a sequence of words (batched execution) | ||
| * Mirrors GrpcClient.executeSequence | ||
| */ | ||
| async executeSequence(words, stack) { | ||
| const message = { | ||
| type: 'execute_sequence', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| words, | ||
| stack: serializeStack(stack), | ||
| }, | ||
| }; | ||
| const result = await this.sendRequest(message); | ||
| return deserializeStack(result.stack); | ||
| } | ||
| /** | ||
| * List available runtime-specific modules | ||
| * Mirrors GrpcClient.listModules | ||
| */ | ||
| async listModules() { | ||
| const message = { | ||
| type: 'list_modules', | ||
| id: this.nextMessageId(), | ||
| }; | ||
| const result = await this.sendRequest(message); | ||
| return result.modules || []; | ||
| } | ||
| /** | ||
| * Get detailed information about a specific module | ||
| * Mirrors GrpcClient.getModuleInfo | ||
| */ | ||
| async getModuleInfo(moduleName) { | ||
| const message = { | ||
| type: 'get_module_info', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| module_name: moduleName, | ||
| }, | ||
| }; | ||
| return await this.sendRequest(message); | ||
| } | ||
| /** | ||
| * Execute code with streaming progress updates (NEW capability) | ||
| */ | ||
| async streamingExecute(code, stack, onProgress) { | ||
| const message = { | ||
| type: 'streaming_execute', | ||
| id: this.nextMessageId(), | ||
| params: { | ||
| code, | ||
| stack: serializeStack(stack), | ||
| }, | ||
| }; | ||
| const result = await this.sendStreamingRequest(message, onProgress); | ||
| return deserializeStack(result.stack); | ||
| } | ||
| /** | ||
| * Close the WebSocket connection | ||
| */ | ||
| close() { | ||
| if (this.ws) { | ||
| this.config.reconnect = false; // Disable auto-reconnect | ||
| this.ws.close(); | ||
| this.ws = undefined; | ||
| this.connected = false; | ||
| } | ||
| } | ||
| /** | ||
| * Check if the client is connected | ||
| */ | ||
| isConnected() { | ||
| return this.connected; | ||
| } | ||
| } | ||
| //# sourceMappingURL=client.js.map |
| {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/websocket/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAc,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAoIjD;;;GAGG;AACH,MAAM,OAAO,eAAe;IAClB,EAAE,CAAa;IACf,MAAM,CAAkC;IACxC,eAAe,GAAgC,IAAI,GAAG,EAAE,CAAC;IACzD,SAAS,GAAW,CAAC,CAAC;IACtB,SAAS,GAAY,KAAK,CAAC;IAC3B,iBAAiB,CAAiB;IAE1C,YAAY,MAA6B;QACvC,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;YAClC,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;YACnC,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,IAAI;YAC7C,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,uBAAuB;SACnD,CAAC;QAEF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AiB;YACvB,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE;YACxB,MAAM,EAAE;gBACN,WAAW,EAAE,UAAU;aACxB;SACF,CAAC;QAEF,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB,CACpB,IAAY,EACZ,KAAY,EACZ,UAA+C;QAE/C,MAAM,OAAO,GAA4B;YACvC,IAAI,EAAE,mBAAmB;YACzB,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE;YACxB,MAAM,EAAE;gBACN,IAAI;gBACJ,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;aAC7B;SACF,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACpE,OAAO,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,yBAAyB;YACxD,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"} |
| /** | ||
| * WebSocketRemoteModule - Module that wraps runtime-specific words from a remote runtime | ||
| * Mirrors RemoteModule from gRPC implementation | ||
| */ | ||
| import { Module } from '../forthic/module.js'; | ||
| import { Interpreter } from '../forthic/interpreter.js'; | ||
| import { ActionCableClient, type ModuleInfo } from './action_cable_client.js'; | ||
| /** | ||
| * WebSocketRemoteModule - Module containing proxy words that execute in a remote runtime | ||
| * | ||
| * This module discovers words from a remote runtime (e.g., pandas module in Ruby) | ||
| * and creates WebSocketRemoteWord proxies for each discovered word. When used in TypeScript | ||
| * Forthic code, these words execute in the remote runtime via ActionCable. | ||
| * | ||
| * Example usage: | ||
| * ```typescript | ||
| * const client = new ActionCableClient({ url: 'ws://localhost:3000/cable' }); | ||
| * const pandasModule = new WebSocketRemoteModule('pandas', client, 'rails'); | ||
| * await pandasModule.initialize(); | ||
| * interp.register_module(pandasModule); | ||
| * interp.use_modules(['pandas']); | ||
| * | ||
| * // Now pandas words execute in Rails runtime | ||
| * await interp.run(` | ||
| * [ [[.name "Alice"] [.age 30]] REC] | ||
| * DF-FROM-RECORDS # Executes in Rails! | ||
| * `); | ||
| * ``` | ||
| */ | ||
| export declare class WebSocketRemoteModule extends Module { | ||
| private client; | ||
| private runtimeName; | ||
| private initialized; | ||
| private moduleInfo; | ||
| /** | ||
| * @param moduleName - Name of the module in the remote runtime (e.g., "pandas") | ||
| * @param client - ActionCable client connected to the remote runtime | ||
| * @param runtimeName - Name of the runtime (e.g., "rails") for debugging | ||
| */ | ||
| constructor(moduleName: string, client: ActionCableClient, runtimeName?: string); | ||
| /** | ||
| * Initialize the module by discovering words from the remote runtime | ||
| * | ||
| * This must be called before the module is registered with an interpreter. | ||
| * It fetches the module metadata and creates WebSocketRemoteWord proxies for each word. | ||
| */ | ||
| initialize(): Promise<void>; | ||
| /** | ||
| * Override set_interp to ensure module is initialized | ||
| */ | ||
| set_interp(interp: Interpreter): void; | ||
| /** | ||
| * Get the module metadata from the remote runtime | ||
| */ | ||
| getModuleInfo(): ModuleInfo | null; | ||
| /** | ||
| * Get runtime name for debugging | ||
| */ | ||
| getRuntimeName(): string; | ||
| /** | ||
| * Check if module is initialized | ||
| */ | ||
| isInitialized(): boolean; | ||
| /** | ||
| * Get count of discovered words | ||
| */ | ||
| getWordCount(): number; | ||
| } |
| /** | ||
| * WebSocketRemoteModule - Module that wraps runtime-specific words from a remote runtime | ||
| * Mirrors RemoteModule from gRPC implementation | ||
| */ | ||
| import { Module } from '../forthic/module.js'; | ||
| import { WebSocketRemoteWord } from './remote_word.js'; | ||
| /** | ||
| * WebSocketRemoteModule - Module containing proxy words that execute in a remote runtime | ||
| * | ||
| * This module discovers words from a remote runtime (e.g., pandas module in Ruby) | ||
| * and creates WebSocketRemoteWord proxies for each discovered word. When used in TypeScript | ||
| * Forthic code, these words execute in the remote runtime via ActionCable. | ||
| * | ||
| * Example usage: | ||
| * ```typescript | ||
| * const client = new ActionCableClient({ url: 'ws://localhost:3000/cable' }); | ||
| * const pandasModule = new WebSocketRemoteModule('pandas', client, 'rails'); | ||
| * await pandasModule.initialize(); | ||
| * interp.register_module(pandasModule); | ||
| * interp.use_modules(['pandas']); | ||
| * | ||
| * // Now pandas words execute in Rails runtime | ||
| * await interp.run(` | ||
| * [ [[.name "Alice"] [.age 30]] REC] | ||
| * DF-FROM-RECORDS # Executes in Rails! | ||
| * `); | ||
| * ``` | ||
| */ | ||
| export class WebSocketRemoteModule extends Module { | ||
| client; | ||
| runtimeName; | ||
| initialized = false; | ||
| moduleInfo = null; | ||
| /** | ||
| * @param moduleName - Name of the module in the remote runtime (e.g., "pandas") | ||
| * @param client - ActionCable client connected to the remote runtime | ||
| * @param runtimeName - Name of the runtime (e.g., "rails") for debugging | ||
| */ | ||
| constructor(moduleName, client, runtimeName = 'remote') { | ||
| super(moduleName); | ||
| this.client = client; | ||
| this.runtimeName = runtimeName; | ||
| } | ||
| /** | ||
| * Initialize the module by discovering words from the remote runtime | ||
| * | ||
| * This must be called before the module is registered with an interpreter. | ||
| * It fetches the module metadata and creates WebSocketRemoteWord proxies for each word. | ||
| */ | ||
| async initialize() { | ||
| if (this.initialized) { | ||
| return; | ||
| } | ||
| try { | ||
| // Discover module info from remote runtime | ||
| this.moduleInfo = await this.client.getModuleInfo(this.name); | ||
| // Create WebSocketRemoteWord for each discovered word | ||
| for (const wordInfo of this.moduleInfo.words) { | ||
| const remoteWord = new WebSocketRemoteWord(wordInfo.name, this.client, this.runtimeName, this.name, wordInfo.stack_effect, wordInfo.description); | ||
| // Add as exportable word (visible when module is imported) | ||
| this.add_exportable_word(remoteWord); | ||
| } | ||
| this.initialized = true; | ||
| } | ||
| catch (error) { | ||
| throw new Error(`Failed to initialize remote module '${this.name}' from ${this.runtimeName} runtime: ${error.message}`); | ||
| } | ||
| } | ||
| /** | ||
| * Override set_interp to ensure module is initialized | ||
| */ | ||
| set_interp(interp) { | ||
| if (!this.initialized) { | ||
| throw new Error(`WebSocketRemoteModule '${this.name}' must be initialized before being registered with an interpreter. Call await module.initialize() first.`); | ||
| } | ||
| super.set_interp(interp); | ||
| } | ||
| /** | ||
| * Get the module metadata from the remote runtime | ||
| */ | ||
| getModuleInfo() { | ||
| return this.moduleInfo; | ||
| } | ||
| /** | ||
| * Get runtime name for debugging | ||
| */ | ||
| getRuntimeName() { | ||
| return this.runtimeName; | ||
| } | ||
| /** | ||
| * Check if module is initialized | ||
| */ | ||
| isInitialized() { | ||
| return this.initialized; | ||
| } | ||
| /** | ||
| * Get count of discovered words | ||
| */ | ||
| getWordCount() { | ||
| return this.moduleInfo?.words?.length || 0; | ||
| } | ||
| } | ||
| //# sourceMappingURL=remote_module.js.map |
| {"version":3,"file":"remote_module.js","sourceRoot":"","sources":["../../../src/websocket/remote_module.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,qBAAsB,SAAQ,MAAM;IACvC,MAAM,CAAoB;IAC1B,WAAW,CAAS;IACpB,WAAW,GAAY,KAAK,CAAC;IAC7B,UAAU,GAAsB,IAAI,CAAC;IAE7C;;;;OAIG;IACH,YAAY,UAAkB,EAAE,MAAyB,EAAE,cAAsB,QAAQ;QACvF,KAAK,CAAC,UAAU,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,G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,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC;IAC7C,CAAC;CACF"} |
| /** | ||
| * WebSocketRemoteWord - Word that executes in a remote runtime via ActionCable | ||
| * Mirrors RemoteWord from gRPC implementation | ||
| */ | ||
| import { Word, RuntimeInfo } from '../forthic/module.js'; | ||
| import { Interpreter } from '../forthic/interpreter.js'; | ||
| import { ActionCableClient } from './action_cable_client.js'; | ||
| /** | ||
| * WebSocketRemoteWord - Proxy word that delegates execution to a remote runtime | ||
| * | ||
| * When executed: | ||
| * 1. Captures current interpreter stack | ||
| * 2. Sends word name + stack to remote runtime via ActionCable | ||
| * 3. Replaces local stack with result stack from remote execution | ||
| * | ||
| * This allows seamless integration of remote runtime words | ||
| * into the local TypeScript interpreter. | ||
| */ | ||
| export declare class WebSocketRemoteWord extends Word { | ||
| private client; | ||
| private runtimeName; | ||
| private moduleName; | ||
| stackEffect: string; | ||
| description: string; | ||
| /** | ||
| * @param name - Word name (e.g., "DF_FROM_RECORDS") | ||
| * @param client - ActionCable client connected to remote runtime | ||
| * @param runtimeName - Name of remote runtime (e.g., "rails", "ruby") | ||
| * @param moduleName - Module name (e.g., "pandas") | ||
| * @param stackEffect - Stack notation (e.g., "( records:array -- df:DataFrame )") | ||
| * @param description - Human-readable description | ||
| */ | ||
| constructor(name: string, client: ActionCableClient, runtimeName: string, moduleName: string, stackEffect?: string, description?: string); | ||
| /** | ||
| * Execute word in remote runtime | ||
| * | ||
| * Captures entire stack, sends to remote runtime, and replaces stack with result. | ||
| */ | ||
| execute(interp: Interpreter): Promise<void>; | ||
| /** | ||
| * Get runtime name for debugging/introspection | ||
| */ | ||
| getRuntimeName(): string; | ||
| /** | ||
| * Get module name for debugging/introspection | ||
| */ | ||
| getModuleName(): string; | ||
| /** | ||
| * Get runtime execution information | ||
| * RemoteWords are runtime-specific and can only execute in their designated runtime | ||
| */ | ||
| getRuntimeInfo(): RuntimeInfo; | ||
| } |
| /** | ||
| * WebSocketRemoteWord - Word that executes in a remote runtime via ActionCable | ||
| * Mirrors RemoteWord from gRPC implementation | ||
| */ | ||
| import { Word } from '../forthic/module.js'; | ||
| /** | ||
| * WebSocketRemoteWord - Proxy word that delegates execution to a remote runtime | ||
| * | ||
| * When executed: | ||
| * 1. Captures current interpreter stack | ||
| * 2. Sends word name + stack to remote runtime via ActionCable | ||
| * 3. Replaces local stack with result stack from remote execution | ||
| * | ||
| * This allows seamless integration of remote runtime words | ||
| * into the local TypeScript interpreter. | ||
| */ | ||
| export class WebSocketRemoteWord extends Word { | ||
| client; | ||
| runtimeName; | ||
| moduleName; | ||
| stackEffect; | ||
| description; | ||
| /** | ||
| * @param name - Word name (e.g., "DF_FROM_RECORDS") | ||
| * @param client - ActionCable client connected to remote runtime | ||
| * @param runtimeName - Name of remote runtime (e.g., "rails", "ruby") | ||
| * @param moduleName - Module name (e.g., "pandas") | ||
| * @param stackEffect - Stack notation (e.g., "( records:array -- df:DataFrame )") | ||
| * @param description - Human-readable description | ||
| */ | ||
| constructor(name, client, runtimeName, moduleName, stackEffect = '( -- )', description = '') { | ||
| super(name); | ||
| this.client = client; | ||
| this.runtimeName = runtimeName; | ||
| this.moduleName = moduleName; | ||
| this.stackEffect = stackEffect; | ||
| this.description = description; | ||
| } | ||
| /** | ||
| * Execute word in remote runtime | ||
| * | ||
| * Captures entire stack, sends to remote runtime, and replaces stack with result. | ||
| */ | ||
| async execute(interp) { | ||
| try { | ||
| // Capture current stack state | ||
| const stack = interp.get_stack(); | ||
| const stackItems = stack.get_items(); | ||
| // Execute word in remote runtime | ||
| const resultStack = await this.client.executeWord(this.name, stackItems); | ||
| // Clear local stack and replace with result | ||
| while (interp.get_stack().length > 0) { | ||
| interp.stack_pop(); | ||
| } | ||
| // Push all result items | ||
| for (const item of resultStack) { | ||
| interp.stack_push(item); | ||
| } | ||
| } | ||
| catch (error) { | ||
| throw new Error(`Error executing remote word ${this.moduleName}.${this.name} in ${this.runtimeName} runtime: ${error.message}`); | ||
| } | ||
| } | ||
| /** | ||
| * Get runtime name for debugging/introspection | ||
| */ | ||
| getRuntimeName() { | ||
| return this.runtimeName; | ||
| } | ||
| /** | ||
| * Get module name for debugging/introspection | ||
| */ | ||
| getModuleName() { | ||
| return this.moduleName; | ||
| } | ||
| /** | ||
| * Get runtime execution information | ||
| * RemoteWords are runtime-specific and can only execute in their designated runtime | ||
| */ | ||
| getRuntimeInfo() { | ||
| return { | ||
| runtime: this.runtimeName, | ||
| isRemote: true, | ||
| isStandard: false, | ||
| availableIn: [this.runtimeName] | ||
| }; | ||
| } | ||
| } | ||
| //# sourceMappingURL=remote_word.js.map |
| {"version":3,"file":"remote_word.js","sourceRoot":"","sources":["../../../src/websocket/remote_word.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAe,MAAM,sBAAsB,CAAC;AAIzD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,mBAAoB,SAAQ,IAAI;IACnC,MAAM,CAAoB;IAC1B,WAAW,CAAS;IACpB,UAAU,CAAS;IACpB,WAAW,CAAS;IACpB,WAAW,CAAS;IAE3B;;;;;;;OAOG;IACH,YACE,IAAY,EACZ,MAAyB,EACzB,WAAmB,EACnB,UAAkB,EAClB,cAAsB,QAAQ,EAC9B,cAAsB,EAAE;QAExB,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,MAAmB;QAC/B,IAAI,CAAC;YACH,8BAA8B;YAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;YACjC,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YAErC,iCAAiC;YACjC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAEzE,4CAA4C;YAC5C,OAAO,MAAM,CAAC,SAAS,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrC,MAAM,CAAC,SAAS,EAAE,CAAC;YACrB,CAAC;YAED,wBAAwB;YACxB,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;gBAC/B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,+BAA+B,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,WAAW,aAAc,KAAe,CAAC,OAAO,EAAE,CAC1H,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,cAAc;QACZ,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,WAAW;YACzB,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,KAAK;YACjB,WAAW,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;SAChC,CAAC;IACJ,CAAC;CACF"} |
| /** | ||
| * WebSocketRuntimeManager - Singleton for managing ActionCable connections to remote runtimes | ||
| * | ||
| * Provides centralized access to ActionCable clients for different runtimes | ||
| * Mirrors the gRPC RuntimeManager API for compatibility | ||
| */ | ||
| import { ActionCableClient, ActionCableClientConfig } from './action_cable_client.js'; | ||
| /** | ||
| * WebSocketRuntimeManager - Manages ActionCable connections to remote Forthic runtimes | ||
| */ | ||
| export declare class WebSocketRuntimeManager { | ||
| private static instance; | ||
| private clients; | ||
| private constructor(); | ||
| /** | ||
| * Get the singleton instance | ||
| */ | ||
| static getInstance(): WebSocketRuntimeManager; | ||
| /** | ||
| * Connect to a runtime and register the client | ||
| * | ||
| * @param runtimeName - Name of the runtime (e.g., "rails", "ruby") | ||
| * @param url - ActionCable URL (e.g., "ws://localhost:3000/cable") | ||
| * @param config - Optional additional configuration | ||
| * @returns ActionCableClient instance | ||
| */ | ||
| connectRuntime(runtimeName: string, url: string, config?: Partial<ActionCableClientConfig>): ActionCableClient; | ||
| /** | ||
| * Register an ActionCable client for a specific runtime | ||
| * | ||
| * @param runtimeName - Name of the runtime (e.g., "rails", "ruby") | ||
| * @param client - ActionCableClient instance connected to that runtime | ||
| */ | ||
| registerClient(runtimeName: string, client: ActionCableClient): void; | ||
| /** | ||
| * Get the ActionCable client for a specific runtime | ||
| * | ||
| * @param runtimeName - Name of the runtime | ||
| * @returns ActionCableClient instance or undefined if not registered | ||
| */ | ||
| getClient(runtimeName: string): ActionCableClient | undefined; | ||
| /** | ||
| * Check if a runtime has a registered client | ||
| * | ||
| * @param runtimeName - Name of the runtime | ||
| * @returns True if client is registered | ||
| */ | ||
| hasClient(runtimeName: string): boolean; | ||
| /** | ||
| * Get all registered runtime names | ||
| * | ||
| * @returns Array of runtime names | ||
| */ | ||
| getRegisteredRuntimes(): string[]; | ||
| /** | ||
| * Disconnect a specific runtime | ||
| * | ||
| * @param runtimeName - Name of the runtime to disconnect | ||
| */ | ||
| disconnectRuntime(runtimeName: string): void; | ||
| /** | ||
| * Clear all registered clients (useful for testing) | ||
| */ | ||
| clearAll(): void; | ||
| /** | ||
| * Reset the singleton (useful for testing) | ||
| */ | ||
| static reset(): void; | ||
| } |
| /** | ||
| * WebSocketRuntimeManager - Singleton for managing ActionCable connections to remote runtimes | ||
| * | ||
| * Provides centralized access to ActionCable clients for different runtimes | ||
| * Mirrors the gRPC RuntimeManager API for compatibility | ||
| */ | ||
| import { ActionCableClient } from './action_cable_client.js'; | ||
| /** | ||
| * WebSocketRuntimeManager - Manages ActionCable connections to remote Forthic runtimes | ||
| */ | ||
| export class WebSocketRuntimeManager { | ||
| static instance = null; | ||
| clients; | ||
| constructor() { | ||
| this.clients = new Map(); | ||
| } | ||
| /** | ||
| * Get the singleton instance | ||
| */ | ||
| static getInstance() { | ||
| if (!WebSocketRuntimeManager.instance) { | ||
| WebSocketRuntimeManager.instance = new WebSocketRuntimeManager(); | ||
| } | ||
| return WebSocketRuntimeManager.instance; | ||
| } | ||
| /** | ||
| * Connect to a runtime and register the client | ||
| * | ||
| * @param runtimeName - Name of the runtime (e.g., "rails", "ruby") | ||
| * @param url - ActionCable URL (e.g., "ws://localhost:3000/cable") | ||
| * @param config - Optional additional configuration | ||
| * @returns ActionCableClient instance | ||
| */ | ||
| connectRuntime(runtimeName, url, config) { | ||
| // Create a new client for the runtime | ||
| const client = new ActionCableClient({ url, ...config }); | ||
| // Register it | ||
| this.clients.set(runtimeName, client); | ||
| return client; | ||
| } | ||
| /** | ||
| * Register an ActionCable client for a specific runtime | ||
| * | ||
| * @param runtimeName - Name of the runtime (e.g., "rails", "ruby") | ||
| * @param client - ActionCableClient instance connected to that runtime | ||
| */ | ||
| registerClient(runtimeName, client) { | ||
| this.clients.set(runtimeName, client); | ||
| } | ||
| /** | ||
| * Get the ActionCable client for a specific runtime | ||
| * | ||
| * @param runtimeName - Name of the runtime | ||
| * @returns ActionCableClient instance or undefined if not registered | ||
| */ | ||
| getClient(runtimeName) { | ||
| return this.clients.get(runtimeName); | ||
| } | ||
| /** | ||
| * Check if a runtime has a registered client | ||
| * | ||
| * @param runtimeName - Name of the runtime | ||
| * @returns True if client is registered | ||
| */ | ||
| hasClient(runtimeName) { | ||
| return this.clients.has(runtimeName); | ||
| } | ||
| /** | ||
| * Get all registered runtime names | ||
| * | ||
| * @returns Array of runtime names | ||
| */ | ||
| getRegisteredRuntimes() { | ||
| return Array.from(this.clients.keys()); | ||
| } | ||
| /** | ||
| * Disconnect a specific runtime | ||
| * | ||
| * @param runtimeName - Name of the runtime to disconnect | ||
| */ | ||
| disconnectRuntime(runtimeName) { | ||
| const client = this.clients.get(runtimeName); | ||
| if (client) { | ||
| client.close(); | ||
| this.clients.delete(runtimeName); | ||
| } | ||
| } | ||
| /** | ||
| * Clear all registered clients (useful for testing) | ||
| */ | ||
| clearAll() { | ||
| // Close all clients | ||
| for (const client of this.clients.values()) { | ||
| client.close(); | ||
| } | ||
| this.clients.clear(); | ||
| } | ||
| /** | ||
| * Reset the singleton (useful for testing) | ||
| */ | ||
| static reset() { | ||
| if (WebSocketRuntimeManager.instance) { | ||
| WebSocketRuntimeManager.instance.clearAll(); | ||
| WebSocketRuntimeManager.instance = null; | ||
| } | ||
| } | ||
| } | ||
| //# sourceMappingURL=runtime_manager.js.map |
| {"version":3,"file":"runtime_manager.js","sourceRoot":"","sources":["../../../src/websocket/runtime_manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,iBAAiB,EAA2B,MAAM,0BAA0B,CAAC;AAEtF;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAC1B,MAAM,CAAC,QAAQ,GAAmC,IAAI,CAAC;IACvD,OAAO,CAAiC;IAEhD;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,CAAC;YACtC,uBAAuB,CAAC,QAAQ,GAAG,IAAI,uBAAuB,EAAE,CAAC;QACnE,CAAC;QACD,OAAO,uBAAuB,CAAC,QAAQ,CAAC;IAC1C,CAAC;IAED;;;;;;;OAOG;IACH,cAAc,CACZ,WAAmB,EACnB,GAAW,E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IAED;;OAEG;IACH,MAAM,CAAC,KAAK;QACV,IAAI,uBAAuB,CAAC,QAAQ,EAAE,CAAC;YACrC,uBAAuB,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC5C,uBAAuB,CAAC,QAAQ,GAAG,IAAI,CAAC;QAC1C,CAAC;IACH,CAAC"} |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
47
-7.84%1257262
-7.91%263
-10.24%21570
-9.24%+ Added
+ Added
- Removed
- Removed
Updated