{"version":3,"sources":["jsdelivr-header.js","/npm/scripthost-core@1.1.0/src/internal/guard.ts","/npm/scripthost-core@1.1.0/src/GenericMessage.ts","/npm/scripthost-core@1.1.0/src/GenericResponse.ts","/npm/scripthost-core@1.1.0/src/InitializeRequest.ts","/npm/scripthost-core@1.1.0/src/InitializeResponse.ts","/npm/scripthost-core@1.1.0/src/PingRequest.ts","/npm/scripthost-core@1.1.0/src/PingResponse.ts","/npm/scripthost-core@1.1.0/src/ErrorResponse.ts","/npm/scripthost-core@1.1.0/src/EvaluateScriptRequest.ts","/npm/scripthost-core@1.1.0/src/EvaluateScriptResponse.ts","/npm/scripthost-core@1.1.0/src/FunctionCallRequest.ts","/npm/scripthost-core@1.1.0/src/FunctionCallResponse.ts","/npm/scripthost-core@1.1.0/src/YieldRequest.ts","/npm/scripthost-core@1.1.0/src/YieldResponse.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,aCLM,SAAU,SAAS,GACrB,MAAwB,iBAAV,GAAgC,OAAV,CACxC,CAGM,SAAU,SAAS,GACrB,OAAO,QAAQ,EAAO,SAC1B,C,uDAEA,MAAM,QAAU,CAAC,KAAmB,IAAmB,EAAK,gBAAgB,GCW5D,SAAA,iBAAmC,EAAgB,GAC/D,QAAK,SAAS,OAIT,SAAS,EAAiB,aAI3B,SAAS,GACF,EAAY,OAAM,EAElB,SAAS,EAAY,OAEpC,CCjBgB,SAAA,kBAAoC,EAAgB,GAChE,OACI,iBAAiB,EAAO,IACxB,SAAS,EAAoB,aAErC,CCLM,SAAU,oBAAoB,GAChC,OAAO,iBAAiB,EAAO,OACnC,CCRM,SAAU,qBAAqB,GACjC,OAAO,kBAAkB,EAAO,QACpC,CCFM,SAAU,cAAc,GAC1B,OAAO,iBAAiB,EAAO,OACnC,CCFM,SAAU,eAAe,GAC3B,OAAO,kBAAkB,EAAO,OACpC,CCkBM,SAAU,gBAAgB,GAC5B,OAAO,kBAAkB,EAAO,QACpC,CCYM,SAAU,wBAAwB,GACpC,OAAO,iBAAiB,EAAO,SAAW,SAAS,EAAc,OACrE,CCNM,SAAU,yBAAyB,GACrC,OAAO,kBAAkB,EAAO,SACpC,CCNM,SAAU,sBAAsB,GAClC,OAAO,iBAAiB,EAAO,SAAW,SAAS,EAAW,IAClE,CCxBM,SAAU,uBAAuB,GACnC,OAAO,kBAAkB,EAAO,SACpC,CCQM,SAAU,eAAe,GAC3B,OAAO,iBAAiB,EAAO,QACnC,CChBM,SAAU,gBAAgB,GAC5B,OAAO,kBAAkB,EAAO,WACpC,C","file":"/npm/scripthost-core@1.1.0/dist/scripthost-core.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/scripthost-core@1.1.0/dist/scripthost-core.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/** @internal */\r\nexport function isObject(thing: unknown): thing is Record<string | number | symbol, unknown> {\r\n    return typeof thing === \"object\" && thing !== null;\r\n}\r\n\r\n/** @internal */\r\nexport function isString(thing: unknown): thing is string {\r\n    return hasType(thing, \"string\");\r\n}\r\n\r\nconst hasType = (thing: unknown, ...type: string[]) => type.includes(typeof thing);\r\n","import { isObject, isString } from \"./internal/guard\";\r\nimport { ScriptObject } from \"./ScriptValue\";\r\n\r\n/**\r\n * Generic message\r\n * @public\r\n */\r\nexport interface GenericMessage<T extends string = string> extends Partial<ScriptObject> {\r\n    /** Message discriminator */\r\n    type: T;\r\n\r\n    /** Unique message identifier */\r\n    messageId: string;\r\n}\r\n\r\n/**\r\n * Determines whether something is a {@link GenericMessage}\r\n * @param thing - The thing to test\r\n * @param type - Optionally specifies the message type to test\r\n * @public\r\n */\r\nexport function isGenericMessage<T extends string>(thing: unknown, type?: string): thing is GenericMessage<T> {\r\n    if (!isObject(thing)) {\r\n        return false;\r\n    }\r\n\r\n    if (!isString(thing[\"messageId\"])) {\r\n        return false;\r\n    }\r\n\r\n    if (isString(type)) {\r\n        return thing[\"type\"] === type;\r\n    } else {\r\n        return isString(thing[\"type\"]);\r\n    }\r\n}\r\n","import { GenericMessage, isGenericMessage } from \"./GenericMessage\";\r\nimport { isString } from \"./internal/guard\";\r\n\r\n/**\r\n * Generic response\r\n * @public\r\n */\r\nexport interface GenericResponse<T extends string = string> extends GenericMessage<T> {\r\n    /** Identifies the request message that this is a response to */\r\n    inResponseTo: string;\r\n}\r\n\r\n/**\r\n * Determines whether something is a {@link GenericResponse}\r\n * @param thing - The thing to test\r\n * @param type - Optionally specifies the message type to test\r\n * @public\r\n */\r\nexport function isGenericResponse<T extends string>(thing: unknown, type?: string): thing is GenericResponse<T> {\r\n    return (\r\n        isGenericMessage(thing, type) &&\r\n        isString(thing[\"inResponseTo\"])\r\n    );\r\n}\r\n","import { GenericMessage, isGenericMessage } from \"./GenericMessage\";\r\n\r\n/**\r\n * The message that is sent to initialize the underlying sandbox\r\n * @public\r\n */\r\nexport interface InitializeRequest extends GenericMessage<\"init\"> {\r\n    /** Keys of exposed functions */\r\n    funcs: Set<string>;\r\n\r\n    /** Specifies whether global variables shall be read-only */\r\n    readOnlyGlobals?: boolean;\r\n}\r\n\r\n/**\r\n * Determines whether something is a {@link InitializeRequest}\r\n * @public\r\n */\r\nexport function isInitializeRequest(thing: unknown): thing is InitializeRequest {\r\n    return isGenericMessage(thing, \"init\");\r\n}\r\n","import { GenericResponse, isGenericResponse } from \"./GenericResponse\";\r\n\r\n/**\r\n * The message that is sent when the underlying sandbox is ready\r\n * @public\r\n */\r\nexport type InitializeResponse = GenericResponse<\"ready\">;\r\n\r\n/**\r\n * Determines whether something is a {@link InitializeResponse}\r\n * @public\r\n */\r\nexport function isInitializeResponse(thing: unknown): thing is InitializeResponse {\r\n    return isGenericResponse(thing, \"ready\");\r\n}\r\n","import { GenericMessage, isGenericMessage } from \"./GenericMessage\";\r\n\r\n/**\r\n * The message that is sent to ping the other end of a messsage pipe\r\n * @public\r\n */\r\nexport type PingRequest = GenericMessage<\"ping\">;\r\n\r\n/**\r\n * Determines whether something is a {@link PingRequest}\r\n * @public\r\n */\r\nexport function isPingRequest(thing: unknown): thing is PingRequest {\r\n    return isGenericMessage(thing, \"ping\");\r\n}\r\n","import { GenericResponse, isGenericResponse } from \"./GenericResponse\";\r\n\r\n/**\r\n * The message that is sent to in response to a ping\r\n * @public\r\n */\r\nexport type PingResponse = GenericResponse<\"pong\">;\r\n\r\n/**\r\n * Determines whether something is a {@link PingResponse}\r\n * @public\r\n */\r\nexport function isPingResponse(thing: unknown): thing is PingResponse {\r\n    return isGenericResponse(thing, \"pong\");\r\n}\r\n","import { TrackedVariable } from \"./EvaluateScriptResponse\";\r\nimport { GenericResponse, isGenericResponse } from \"./GenericResponse\";\r\nimport { ScriptValue } from \"./ScriptValue\";\r\n\r\n/**\r\n * The response that is sent when an error occurred\r\n * @public\r\n */\r\nexport interface ErrorResponse extends GenericResponse<\"error\">{\r\n    message: string;\r\n\r\n    /**\r\n     * Optionally includes the global variables that were accessed during script evaluation.\r\n     * \r\n     * This property is omitted unless the error occurred during script evaluation and may \r\n     * be omitted unless the script is evaluated with the `track` option.\r\n     */\r\n    vars?: Map<string, TrackedVariable>;\r\n\r\n    /**\r\n     * The value assigned to `this.refresh` during script evaluation.\r\n     * \r\n     * This property is omitted unless the error occurred during script evaluation and may\r\n     * be omitted unless the script assigned `this.refresh`.\r\n     */\r\n    refresh?: ScriptValue;\r\n }\r\n\r\n/**\r\n * Determines whether something is an {@link ErrorResponse}\r\n * @public\r\n */\r\nexport function isErrorResponse(thing: unknown): thing is ErrorResponse {\r\n    return isGenericResponse(thing, \"error\");\r\n}\r\n","import { GenericMessage, isGenericMessage } from \"./GenericMessage\";\r\nimport { isString } from \"./internal/guard\";\r\nimport { ScriptValue } from \"./ScriptValue\";\r\n\r\n/**\r\n * The message that is sent to request script evaluation\r\n * @public\r\n */\r\nexport interface EvaluateScriptRequest extends GenericMessage<\"eval\"> {\r\n    /** The script that shall be evaluated */\r\n    script: string;\r\n\r\n    /**\r\n     * Optionally identifies the instance in which the script shall be evaluated\r\n     * \r\n     * @remarks\r\n     * This property shall be specified to use a specific `this` binding during script\r\n     * evaluation.\r\n     * \r\n     * When not specified, a temporary `this` binding is used for each evaluation.\r\n     */\r\n    instanceId?: string;\r\n\r\n    /**\r\n     * Optionally specifies that the script is idempotent, i.e. is not allowed to have side-effects.\r\n     * @remarks\r\n     * An idempotent script cannot write to variables or call functions that may have side-effects.\r\n     */\r\n    idempotent?: boolean;\r\n\r\n    /**\r\n     * Optionally specifies that variables that are accessed during script evaluation\r\n     * shall be tracked.\r\n     */\r\n    track?: boolean;\r\n\r\n    /**\r\n     * Optionally specifies variables that shall be made available to the script\r\n     */\r\n    vars?: Record<string, ScriptValue>;\r\n}\r\n\r\n/**\r\n * Determines whether something is a {@link EvaluateScriptRequest}\r\n * @public\r\n */\r\nexport function isEvaluateScriptRequest(thing: unknown): thing is EvaluateScriptRequest {\r\n    return isGenericMessage(thing, \"eval\") && isString(thing[\"script\"]);\r\n}\r\n","import { GenericResponse, isGenericResponse } from \"./GenericResponse\";\r\nimport { ScriptObject, ScriptValue } from \"./ScriptValue\";\r\n\r\n/**\r\n * The response that is sent back after successful script evaluation\r\n * @public\r\n */\r\nexport interface EvaluateScriptResponse extends GenericResponse<\"result\">{\r\n    /** The result value */\r\n    result: ScriptValue;\r\n\r\n    /**\r\n     * Optionally includes the global variables that were accessed during script evaluation.\r\n     * \r\n     * This property may be omitted unless the script is evaluated with the `track` option\r\n     */\r\n    vars?: Map<string, TrackedVariable>;\r\n\r\n    /** The value assigned to `this.refresh` during script evaluation */\r\n    refresh?: ScriptValue;\r\n}\r\n\r\n/**\r\n * A tracked variable\r\n * @public\r\n */\r\nexport interface TrackedVariable extends Partial<ScriptObject> {\r\n    /**\r\n     * The version of the global scope when the variable was first read\r\n     */\r\n    read?: number;\r\n\r\n    /**\r\n     * The version of the global scope after the variable was last written\r\n     */\r\n    write?: number;\r\n}\r\n\r\n/**\r\n * Determines whether something is a {@link EvaluateScriptResponse}\r\n * @public\r\n */\r\nexport function isEvaluateScriptResponse(thing: unknown): thing is EvaluateScriptResponse {\r\n    return isGenericResponse(thing, \"result\");\r\n}","import { GenericMessage, isGenericMessage } from \"./GenericMessage\";\r\nimport { isString } from \"./internal/guard\";\r\nimport { ScriptValue } from \"./ScriptValue\";\r\n\r\n/**\r\n * The message that is sent from the underlying sandbox to invoke a function\r\n * exposed by the script host.\r\n * @public\r\n */\r\nexport interface FunctionCallRequest extends GenericMessage<\"call\"> {\r\n    /** The function that shall be called */\r\n    key: string;\r\n\r\n    /** Function call arguments */\r\n    args: ScriptValue[];\r\n\r\n    /** Specifies whether the function is called from an idempotent script */\r\n    idempotent: boolean;\r\n\r\n    /** Unique identifier of the message that caused script evaluation */\r\n    correlationId: string;\r\n\r\n    /**\r\n     * Optionally includes the global variables that were written during script evaluation,\r\n     * before the current function call. \r\n     * \r\n     * The values of the provided map represents the version of the global scope that became\r\n     * current after the corresponding variable was last written.\r\n     * \r\n     * This property may be omitted unless the script is evaluated with the `track` option\r\n     */\r\n     written?: Map<string, number>\r\n}\r\n\r\n/**\r\n * Determines whether something is a {@link FunctionCallRequest}\r\n * @public\r\n */\r\nexport function isFunctionCallRequest(thing: unknown): thing is FunctionCallRequest {\r\n    return isGenericMessage(thing, \"call\") && isString(thing[\"key\"]);\r\n}\r\n","import { GenericResponse, isGenericResponse } from \"./GenericResponse\";\r\nimport { ScriptValue } from \"./ScriptValue\";\r\n\r\n/**\r\n * The response that is sent back to the sandbox after a successful function call\r\n * @public\r\n */\r\nexport interface FunctionCallResponse extends GenericResponse<\"return\">{\r\n    /** The return value */\r\n    result: ScriptValue;\r\n}\r\n\r\n/**\r\n * Determines whether something is a {@link FunctionCallResponse}\r\n * @public\r\n */\r\nexport function isFunctionCallResponse(thing: unknown): thing is FunctionCallResponse {\r\n    return isGenericResponse(thing, \"return\");\r\n}","import { GenericMessage, isGenericMessage } from \"./GenericMessage\";\r\n\r\n/**\r\n * The message that is sent from the underlying sandbox when script execution is yielded.\r\n * @public\r\n */\r\nexport interface YieldRequest extends GenericMessage<\"yield\"> {\r\n    /** Unique identifier of the message that caused script evaluation */\r\n    correlationId: string;\r\n\r\n    /**\r\n     * Optionally includes the global variables that were written during script evaluation,\r\n     * before the current function call. \r\n     * \r\n     * The values of the provided map represents the version of the global scope that became\r\n     * current after the corresponding variable was last written.\r\n     * \r\n     * This property may be omitted unless the script is evaluated with the `track` option.\r\n     */\r\n     written?: Map<string, number>\r\n}\r\n\r\n/**\r\n * Determines whether something is a {@link YieldRequest}\r\n * @public\r\n */\r\nexport function isYieldRequest(thing: unknown): thing is YieldRequest {\r\n    return isGenericMessage(thing, \"yield\");\r\n}\r\n","import { GenericResponse, isGenericResponse } from \"./GenericResponse\";\r\n\r\n/**\r\n * The response that is sent back to the sandbox to continue a yielded script\r\n * @public\r\n */\r\nexport type YieldResponse = GenericResponse<\"continue\">;\r\n\r\n/**\r\n * Determines whether something is a {@link YieldResponse}\r\n * @public\r\n */\r\nexport function isYieldResponse(thing: unknown): thing is YieldResponse {\r\n    return isGenericResponse(thing, \"continue\");\r\n}\r\n"]}