@interopio/iframes-api 0.1.0-beta.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"iframes.umd.min.js","sources":["../../../node_modules/decoder-validate/dist/index.es5.js","../src/shared/decoders.ts","../src/communication/bridge.ts","../src/shared/constants.ts","../../../node_modules/callback-registry/lib/index.js","../src/shared/utils.ts","../src/iframes/protocol.ts","../src/iframes/controller.ts","../src/shared/ioc.ts","../src/main.ts","../src/index.ts"],"sourcesContent":["/**\r\n * Wraps values in an `Ok` type.\r\n *\r\n * Example: `ok(5) // => {ok: true, result: 5}`\r\n */\r\nvar ok = function (result) { return ({ ok: true, result: result }); };\r\n/**\r\n * Typeguard for `Ok`.\r\n */\r\nvar isOk = function (r) { return r.ok === true; };\r\n/**\r\n * Wraps errors in an `Err` type.\r\n *\r\n * Example: `err('on fire') // => {ok: false, error: 'on fire'}`\r\n */\r\nvar err = function (error) { return ({ ok: false, error: error }); };\r\n/**\r\n * Typeguard for `Err`.\r\n */\r\nvar isErr = function (r) { return r.ok === false; };\r\n/**\r\n * Create a `Promise` that either resolves with the result of `Ok` or rejects\r\n * with the error of `Err`.\r\n */\r\nvar asPromise = function (r) {\r\n return r.ok === true ? Promise.resolve(r.result) : Promise.reject(r.error);\r\n};\r\n/**\r\n * Unwraps a `Result` and returns either the result of an `Ok`, or\r\n * `defaultValue`.\r\n *\r\n * Example:\r\n * ```\r\n * Result.withDefault(5, number().run(json))\r\n * ```\r\n *\r\n * It would be nice if `Decoder` had an instance method that mirrored this\r\n * function. Such a method would look something like this:\r\n * ```\r\n * class Decoder<A> {\r\n * runWithDefault = (defaultValue: A, json: any): A =>\r\n * Result.withDefault(defaultValue, this.run(json));\r\n * }\r\n *\r\n * number().runWithDefault(5, json)\r\n * ```\r\n * Unfortunately, the type of `defaultValue: A` on the method causes issues\r\n * with type inference on the `object` decoder in some situations. While these\r\n * inference issues can be solved by providing the optional type argument for\r\n * `object`s, the extra trouble and confusion doesn't seem worth it.\r\n */\r\nvar withDefault = function (defaultValue, r) {\r\n return r.ok === true ? r.result : defaultValue;\r\n};\r\n/**\r\n * Return the successful result, or throw an error.\r\n */\r\nvar withException = function (r) {\r\n if (r.ok === true) {\r\n return r.result;\r\n }\r\n else {\r\n throw r.error;\r\n }\r\n};\r\n/**\r\n * Given an array of `Result`s, return the successful values.\r\n */\r\nvar successes = function (results) {\r\n return results.reduce(function (acc, r) { return (r.ok === true ? acc.concat(r.result) : acc); }, []);\r\n};\r\n/**\r\n * Apply `f` to the result of an `Ok`, or pass the error through.\r\n */\r\nvar map = function (f, r) {\r\n return r.ok === true ? ok(f(r.result)) : r;\r\n};\r\n/**\r\n * Apply `f` to the result of two `Ok`s, or pass an error through. If both\r\n * `Result`s are errors then the first one is returned.\r\n */\r\nvar map2 = function (f, ar, br) {\r\n return ar.ok === false ? ar :\r\n br.ok === false ? br :\r\n ok(f(ar.result, br.result));\r\n};\r\n/**\r\n * Apply `f` to the error of an `Err`, or pass the success through.\r\n */\r\nvar mapError = function (f, r) {\r\n return r.ok === true ? r : err(f(r.error));\r\n};\r\n/**\r\n * Chain together a sequence of computations that may fail, similar to a\r\n * `Promise`. If the first computation fails then the error will propagate\r\n * through. If it succeeds, then `f` will be applied to the value, returning a\r\n * new `Result`.\r\n */\r\nvar andThen = function (f, r) {\r\n return r.ok === true ? f(r.result) : r;\r\n};\r\n\r\n\r\nvar result = Object.freeze({\r\n\tok: ok,\r\n\tisOk: isOk,\r\n\terr: err,\r\n\tisErr: isErr,\r\n\tasPromise: asPromise,\r\n\twithDefault: withDefault,\r\n\twithException: withException,\r\n\tsuccesses: successes,\r\n\tmap: map,\r\n\tmap2: map2,\r\n\tmapError: mapError,\r\n\tandThen: andThen\r\n});\r\n\r\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\n\r\n\r\nvar __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\n\r\nfunction __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nfunction isEqual(a, b) {\r\n if (a === b) {\r\n return true;\r\n }\r\n if (a === null && b === null) {\r\n return true;\r\n }\r\n if (typeof (a) !== typeof (b)) {\r\n return false;\r\n }\r\n if (typeof (a) === 'object') {\r\n // Array\r\n if (Array.isArray(a)) {\r\n if (!Array.isArray(b)) {\r\n return false;\r\n }\r\n if (a.length !== b.length) {\r\n return false;\r\n }\r\n for (var i = 0; i < a.length; i++) {\r\n if (!isEqual(a[i], b[i])) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n // Hash table\r\n var keys = Object.keys(a);\r\n if (keys.length !== Object.keys(b).length) {\r\n return false;\r\n }\r\n for (var i = 0; i < keys.length; i++) {\r\n if (!b.hasOwnProperty(keys[i])) {\r\n return false;\r\n }\r\n if (!isEqual(a[keys[i]], b[keys[i]])) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n}\r\n/**\r\n * Type guard for `DecoderError`. One use case of the type guard is in the\r\n * `catch` of a promise. Typescript types the error argument of `catch` as\r\n * `any`, so when dealing with a decoder as a promise you may need to\r\n * distinguish between a `DecoderError` and an error string.\r\n */\r\nvar isDecoderError = function (a) {\r\n return a.kind === 'DecoderError' && typeof a.at === 'string' && typeof a.message === 'string';\r\n};\r\n/*\r\n * Helpers\r\n */\r\nvar isJsonArray = function (json) { return Array.isArray(json); };\r\nvar isJsonObject = function (json) {\r\n return typeof json === 'object' && json !== null && !isJsonArray(json);\r\n};\r\nvar typeString = function (json) {\r\n switch (typeof json) {\r\n case 'string':\r\n return 'a string';\r\n case 'number':\r\n return 'a number';\r\n case 'boolean':\r\n return 'a boolean';\r\n case 'undefined':\r\n return 'undefined';\r\n case 'object':\r\n if (json instanceof Array) {\r\n return 'an array';\r\n }\r\n else if (json === null) {\r\n return 'null';\r\n }\r\n else {\r\n return 'an object';\r\n }\r\n default:\r\n return JSON.stringify(json);\r\n }\r\n};\r\nvar expectedGot = function (expected, got) {\r\n return \"expected \" + expected + \", got \" + typeString(got);\r\n};\r\nvar printPath = function (paths) {\r\n return paths.map(function (path) { return (typeof path === 'string' ? \".\" + path : \"[\" + path + \"]\"); }).join('');\r\n};\r\nvar prependAt = function (newAt, _a) {\r\n var at = _a.at, rest = __rest(_a, [\"at\"]);\r\n return (__assign({ at: newAt + (at || '') }, rest));\r\n};\r\n/**\r\n * Decoders transform json objects with unknown structure into known and\r\n * verified forms. You can create objects of type `Decoder<A>` with either the\r\n * primitive decoder functions, such as `boolean()` and `string()`, or by\r\n * applying higher-order decoders to the primitives, such as `array(boolean())`\r\n * or `dict(string())`.\r\n *\r\n * Each of the decoder functions are available both as a static method on\r\n * `Decoder` and as a function alias -- for example the string decoder is\r\n * defined at `Decoder.string()`, but is also aliased to `string()`. Using the\r\n * function aliases exported with the library is recommended.\r\n *\r\n * `Decoder` exposes a number of 'run' methods, which all decode json in the\r\n * same way, but communicate success and failure in different ways. The `map`\r\n * and `andThen` methods modify decoders without having to call a 'run' method.\r\n *\r\n * Alternatively, the main decoder `run()` method returns an object of type\r\n * `Result<A, DecoderError>`. This library provides a number of helper\r\n * functions for dealing with the `Result` type, so you can do all the same\r\n * things with a `Result` as with the decoder methods.\r\n */\r\nvar Decoder = /** @class */ (function () {\r\n /**\r\n * The Decoder class constructor is kept private to separate the internal\r\n * `decode` function from the external `run` function. The distinction\r\n * between the two functions is that `decode` returns a\r\n * `Partial<DecoderError>` on failure, which contains an unfinished error\r\n * report. When `run` is called on a decoder, the relevant series of `decode`\r\n * calls is made, and then on failure the resulting `Partial<DecoderError>`\r\n * is turned into a `DecoderError` by filling in the missing information.\r\n *\r\n * While hiding the constructor may seem restrictive, leveraging the\r\n * provided decoder combinators and helper functions such as\r\n * `andThen` and `map` should be enough to build specialized decoders as\r\n * needed.\r\n */\r\n function Decoder(decode) {\r\n var _this = this;\r\n this.decode = decode;\r\n /**\r\n * Run the decoder and return a `Result` with either the decoded value or a\r\n * `DecoderError` containing the json input, the location of the error, and\r\n * the error message.\r\n *\r\n * Examples:\r\n * ```\r\n * number().run(12)\r\n * // => {ok: true, result: 12}\r\n *\r\n * string().run(9001)\r\n * // =>\r\n * // {\r\n * // ok: false,\r\n * // error: {\r\n * // kind: 'DecoderError',\r\n * // input: 9001,\r\n * // at: 'input',\r\n * // message: 'expected a string, got 9001'\r\n * // }\r\n * // }\r\n * ```\r\n */\r\n this.run = function (json) {\r\n return mapError(function (error) { return ({\r\n kind: 'DecoderError',\r\n input: json,\r\n at: 'input' + (error.at || ''),\r\n message: error.message || ''\r\n }); }, _this.decode(json));\r\n };\r\n /**\r\n * Run the decoder as a `Promise`.\r\n */\r\n this.runPromise = function (json) { return asPromise(_this.run(json)); };\r\n /**\r\n * Run the decoder and return the value on success, or throw an exception\r\n * with a formatted error string.\r\n */\r\n this.runWithException = function (json) { return withException(_this.run(json)); };\r\n /**\r\n * Construct a new decoder that applies a transformation to the decoded\r\n * result. If the decoder succeeds then `f` will be applied to the value. If\r\n * it fails the error will propagated through.\r\n *\r\n * Example:\r\n * ```\r\n * number().map(x => x * 5).run(10)\r\n * // => {ok: true, result: 50}\r\n * ```\r\n */\r\n this.map = function (f) {\r\n return new Decoder(function (json) { return map(f, _this.decode(json)); });\r\n };\r\n /**\r\n * Chain together a sequence of decoders. The first decoder will run, and\r\n * then the function will determine what decoder to run second. If the result\r\n * of the first decoder succeeds then `f` will be applied to the decoded\r\n * value. If it fails the error will propagate through.\r\n *\r\n * This is a very powerful method -- it can act as both the `map` and `where`\r\n * methods, can improve error messages for edge cases, and can be used to\r\n * make a decoder for custom types.\r\n *\r\n * Example of adding an error message:\r\n * ```\r\n * const versionDecoder = valueAt(['version'], number());\r\n * const infoDecoder3 = object({a: boolean()});\r\n *\r\n * const decoder = versionDecoder.andThen(version => {\r\n * switch (version) {\r\n * case 3:\r\n * return infoDecoder3;\r\n * default:\r\n * return fail(`Unable to decode info, version ${version} is not supported.`);\r\n * }\r\n * });\r\n *\r\n * decoder.run({version: 3, a: true})\r\n * // => {ok: true, result: {a: true}}\r\n *\r\n * decoder.run({version: 5, x: 'abc'})\r\n * // =>\r\n * // {\r\n * // ok: false,\r\n * // error: {... message: 'Unable to decode info, version 5 is not supported.'}\r\n * // }\r\n * ```\r\n *\r\n * Example of decoding a custom type:\r\n * ```\r\n * // nominal type for arrays with a length of at least one\r\n * type NonEmptyArray<T> = T[] & { __nonEmptyArrayBrand__: void };\r\n *\r\n * const nonEmptyArrayDecoder = <T>(values: Decoder<T>): Decoder<NonEmptyArray<T>> =>\r\n * array(values).andThen(arr =>\r\n * arr.length > 0\r\n * ? succeed(createNonEmptyArray(arr))\r\n * : fail(`expected a non-empty array, got an empty array`)\r\n * );\r\n * ```\r\n */\r\n this.andThen = function (f) {\r\n return new Decoder(function (json) {\r\n return andThen(function (value) { return f(value).decode(json); }, _this.decode(json));\r\n });\r\n };\r\n /**\r\n * Add constraints to a decoder _without_ changing the resulting type. The\r\n * `test` argument is a predicate function which returns true for valid\r\n * inputs. When `test` fails on an input, the decoder fails with the given\r\n * `errorMessage`.\r\n *\r\n * ```\r\n * const chars = (length: number): Decoder<string> =>\r\n * string().where(\r\n * (s: string) => s.length === length,\r\n * `expected a string of length ${length}`\r\n * );\r\n *\r\n * chars(5).run('12345')\r\n * // => {ok: true, result: '12345'}\r\n *\r\n * chars(2).run('HELLO')\r\n * // => {ok: false, error: {... message: 'expected a string of length 2'}}\r\n *\r\n * chars(12).run(true)\r\n * // => {ok: false, error: {... message: 'expected a string, got a boolean'}}\r\n * ```\r\n */\r\n this.where = function (test, errorMessage) {\r\n return _this.andThen(function (value) { return (test(value) ? Decoder.succeed(value) : Decoder.fail(errorMessage)); });\r\n };\r\n }\r\n /**\r\n * Decoder primitive that validates strings, and fails on all other input.\r\n */\r\n Decoder.string = function () {\r\n return new Decoder(function (json) {\r\n return typeof json === 'string'\r\n ? ok(json)\r\n : err({ message: expectedGot('a string', json) });\r\n });\r\n };\r\n /**\r\n * Decoder primitive that validates numbers, and fails on all other input.\r\n */\r\n Decoder.number = function () {\r\n return new Decoder(function (json) {\r\n return typeof json === 'number'\r\n ? ok(json)\r\n : err({ message: expectedGot('a number', json) });\r\n });\r\n };\r\n /**\r\n * Decoder primitive that validates booleans, and fails on all other input.\r\n */\r\n Decoder.boolean = function () {\r\n return new Decoder(function (json) {\r\n return typeof json === 'boolean'\r\n ? ok(json)\r\n : err({ message: expectedGot('a boolean', json) });\r\n });\r\n };\r\n Decoder.constant = function (value) {\r\n return new Decoder(function (json) {\r\n return isEqual(json, value)\r\n ? ok(value)\r\n : err({ message: \"expected \" + JSON.stringify(value) + \", got \" + JSON.stringify(json) });\r\n });\r\n };\r\n Decoder.object = function (decoders) {\r\n return new Decoder(function (json) {\r\n if (isJsonObject(json) && decoders) {\r\n var obj = {};\r\n for (var key in decoders) {\r\n if (decoders.hasOwnProperty(key)) {\r\n var r = decoders[key].decode(json[key]);\r\n if (r.ok === true) {\r\n // tslint:disable-next-line:strict-type-predicates\r\n if (r.result !== undefined) {\r\n obj[key] = r.result;\r\n }\r\n }\r\n else if (json[key] === undefined) {\r\n return err({ message: \"the key '\" + key + \"' is required but was not present\" });\r\n }\r\n else {\r\n return err(prependAt(\".\" + key, r.error));\r\n }\r\n }\r\n }\r\n return ok(obj);\r\n }\r\n else if (isJsonObject(json)) {\r\n return ok(json);\r\n }\r\n else {\r\n return err({ message: expectedGot('an object', json) });\r\n }\r\n });\r\n };\r\n Decoder.array = function (decoder) {\r\n return new Decoder(function (json) {\r\n if (isJsonArray(json) && decoder) {\r\n var decodeValue_1 = function (v, i) {\r\n return mapError(function (err$$1) { return prependAt(\"[\" + i + \"]\", err$$1); }, decoder.decode(v));\r\n };\r\n return json.reduce(function (acc, v, i) {\r\n return map2(function (arr, result) { return arr.concat([result]); }, acc, decodeValue_1(v, i));\r\n }, ok([]));\r\n }\r\n else if (isJsonArray(json)) {\r\n return ok(json);\r\n }\r\n else {\r\n return err({ message: expectedGot('an array', json) });\r\n }\r\n });\r\n };\r\n Decoder.tuple = function (decoders) {\r\n return new Decoder(function (json) {\r\n if (isJsonArray(json)) {\r\n if (json.length !== decoders.length) {\r\n return err({\r\n message: \"expected a tuple of length \" + decoders.length + \", got one of length \" + json.length\r\n });\r\n }\r\n var result = [];\r\n for (var i = 0; i < decoders.length; i++) {\r\n var nth = decoders[i].decode(json[i]);\r\n if (nth.ok) {\r\n result[i] = nth.result;\r\n }\r\n else {\r\n return err(prependAt(\"[\" + i + \"]\", nth.error));\r\n }\r\n }\r\n return ok(result);\r\n }\r\n else {\r\n return err({ message: expectedGot(\"a tuple of length \" + decoders.length, json) });\r\n }\r\n });\r\n };\r\n Decoder.union = function (ad, bd) {\r\n var decoders = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n decoders[_i - 2] = arguments[_i];\r\n }\r\n return Decoder.oneOf.apply(Decoder, [ad, bd].concat(decoders));\r\n };\r\n Decoder.intersection = function (ad, bd) {\r\n var ds = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n ds[_i - 2] = arguments[_i];\r\n }\r\n return new Decoder(function (json) {\r\n return [ad, bd].concat(ds).reduce(function (acc, decoder) { return map2(Object.assign, acc, decoder.decode(json)); }, ok({}));\r\n });\r\n };\r\n /**\r\n * Escape hatch to bypass validation. Always succeeds and types the result as\r\n * `any`. Useful for defining decoders incrementally, particularly for\r\n * complex objects.\r\n *\r\n * Example:\r\n * ```\r\n * interface User {\r\n * name: string;\r\n * complexUserData: ComplexType;\r\n * }\r\n *\r\n * const userDecoder: Decoder<User> = object({\r\n * name: string(),\r\n * complexUserData: anyJson()\r\n * });\r\n * ```\r\n */\r\n Decoder.anyJson = function () { return new Decoder(function (json) { return ok(json); }); };\r\n /**\r\n * Decoder identity function which always succeeds and types the result as\r\n * `unknown`.\r\n */\r\n Decoder.unknownJson = function () {\r\n return new Decoder(function (json) { return ok(json); });\r\n };\r\n /**\r\n * Decoder for json objects where the keys are unknown strings, but the values\r\n * should all be of the same type.\r\n *\r\n * Example:\r\n * ```\r\n * dict(number()).run({chocolate: 12, vanilla: 10, mint: 37});\r\n * // => {ok: true, result: {chocolate: 12, vanilla: 10, mint: 37}}\r\n * ```\r\n */\r\n Decoder.dict = function (decoder) {\r\n return new Decoder(function (json) {\r\n if (isJsonObject(json)) {\r\n var obj = {};\r\n for (var key in json) {\r\n if (json.hasOwnProperty(key)) {\r\n var r = decoder.decode(json[key]);\r\n if (r.ok === true) {\r\n obj[key] = r.result;\r\n }\r\n else {\r\n return err(prependAt(\".\" + key, r.error));\r\n }\r\n }\r\n }\r\n return ok(obj);\r\n }\r\n else {\r\n return err({ message: expectedGot('an object', json) });\r\n }\r\n });\r\n };\r\n /**\r\n * Decoder for values that may be `undefined`. This is primarily helpful for\r\n * decoding interfaces with optional fields.\r\n *\r\n * Example:\r\n * ```\r\n * interface User {\r\n * id: number;\r\n * isOwner?: boolean;\r\n * }\r\n *\r\n * const decoder: Decoder<User> = object({\r\n * id: number(),\r\n * isOwner: optional(boolean())\r\n * });\r\n * ```\r\n */\r\n Decoder.optional = function (decoder) {\r\n return new Decoder(function (json) { return (json === undefined || json === null ? ok(undefined) : decoder.decode(json)); });\r\n };\r\n /**\r\n * Decoder that attempts to run each decoder in `decoders` and either succeeds\r\n * with the first successful decoder, or fails after all decoders have failed.\r\n *\r\n * Note that `oneOf` expects the decoders to all have the same return type,\r\n * while `union` creates a decoder for the union type of all the input\r\n * decoders.\r\n *\r\n * Examples:\r\n * ```\r\n * oneOf(string(), number().map(String))\r\n * oneOf(constant('start'), constant('stop'), succeed('unknown'))\r\n * ```\r\n */\r\n Decoder.oneOf = function () {\r\n var decoders = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n decoders[_i] = arguments[_i];\r\n }\r\n return new Decoder(function (json) {\r\n var errors = [];\r\n for (var i = 0; i < decoders.length; i++) {\r\n var r = decoders[i].decode(json);\r\n if (r.ok === true) {\r\n return r;\r\n }\r\n else {\r\n errors[i] = r.error;\r\n }\r\n }\r\n var errorsList = errors\r\n .map(function (error) { return \"at error\" + (error.at || '') + \": \" + error.message; })\r\n .join('\", \"');\r\n return err({\r\n message: \"expected a value matching one of the decoders, got the errors [\\\"\" + errorsList + \"\\\"]\"\r\n });\r\n });\r\n };\r\n /**\r\n * Decoder that always succeeds with either the decoded value, or a fallback\r\n * default value.\r\n */\r\n Decoder.withDefault = function (defaultValue, decoder) {\r\n return new Decoder(function (json) {\r\n return ok(withDefault(defaultValue, decoder.decode(json)));\r\n });\r\n };\r\n /**\r\n * Decoder that pulls a specific field out of a json structure, instead of\r\n * decoding and returning the full structure. The `paths` array describes the\r\n * object keys and array indices to traverse, so that values can be pulled out\r\n * of a nested structure.\r\n *\r\n * Example:\r\n * ```\r\n * const decoder = valueAt(['a', 'b', 0], string());\r\n *\r\n * decoder.run({a: {b: ['surprise!']}})\r\n * // => {ok: true, result: 'surprise!'}\r\n *\r\n * decoder.run({a: {x: 'cats'}})\r\n * // => {ok: false, error: {... at: 'input.a.b[0]' message: 'path does not exist'}}\r\n * ```\r\n *\r\n * Note that the `decoder` is ran on the value found at the last key in the\r\n * path, even if the last key is not found. This allows the `optional`\r\n * decoder to succeed when appropriate.\r\n * ```\r\n * const optionalDecoder = valueAt(['a', 'b', 'c'], optional(string()));\r\n *\r\n * optionalDecoder.run({a: {b: {c: 'surprise!'}}})\r\n * // => {ok: true, result: 'surprise!'}\r\n *\r\n * optionalDecoder.run({a: {b: 'cats'}})\r\n * // => {ok: false, error: {... at: 'input.a.b.c' message: 'expected an object, got \"cats\"'}\r\n *\r\n * optionalDecoder.run({a: {b: {z: 1}}})\r\n * // => {ok: true, result: undefined}\r\n * ```\r\n */\r\n Decoder.valueAt = function (paths, decoder) {\r\n return new Decoder(function (json) {\r\n var jsonAtPath = json;\r\n for (var i = 0; i < paths.length; i++) {\r\n if (jsonAtPath === undefined) {\r\n return err({\r\n at: printPath(paths.slice(0, i + 1)),\r\n message: 'path does not exist'\r\n });\r\n }\r\n else if (typeof paths[i] === 'string' && !isJsonObject(jsonAtPath)) {\r\n return err({\r\n at: printPath(paths.slice(0, i + 1)),\r\n message: expectedGot('an object', jsonAtPath)\r\n });\r\n }\r\n else if (typeof paths[i] === 'number' && !isJsonArray(jsonAtPath)) {\r\n return err({\r\n at: printPath(paths.slice(0, i + 1)),\r\n message: expectedGot('an array', jsonAtPath)\r\n });\r\n }\r\n else {\r\n jsonAtPath = jsonAtPath[paths[i]];\r\n }\r\n }\r\n return mapError(function (error) {\r\n return jsonAtPath === undefined\r\n ? { at: printPath(paths), message: 'path does not exist' }\r\n : prependAt(printPath(paths), error);\r\n }, decoder.decode(jsonAtPath));\r\n });\r\n };\r\n /**\r\n * Decoder that ignores the input json and always succeeds with `fixedValue`.\r\n */\r\n Decoder.succeed = function (fixedValue) {\r\n return new Decoder(function (json) { return ok(fixedValue); });\r\n };\r\n /**\r\n * Decoder that ignores the input json and always fails with `errorMessage`.\r\n */\r\n Decoder.fail = function (errorMessage) {\r\n return new Decoder(function (json) { return err({ message: errorMessage }); });\r\n };\r\n /**\r\n * Decoder that allows for validating recursive data structures. Unlike with\r\n * functions, decoders assigned to variables can't reference themselves\r\n * before they are fully defined. We can avoid prematurely referencing the\r\n * decoder by wrapping it in a function that won't be called until use, at\r\n * which point the decoder has been defined.\r\n *\r\n * Example:\r\n * ```\r\n * interface Comment {\r\n * msg: string;\r\n * replies: Comment[];\r\n * }\r\n *\r\n * const decoder: Decoder<Comment> = object({\r\n * msg: string(),\r\n * replies: lazy(() => array(decoder))\r\n * });\r\n * ```\r\n */\r\n Decoder.lazy = function (mkDecoder) {\r\n return new Decoder(function (json) { return mkDecoder().decode(json); });\r\n };\r\n return Decoder;\r\n}());\r\n\r\n/* tslint:disable:variable-name */\r\n/** See `Decoder.string` */\r\nvar string = Decoder.string;\r\n/** See `Decoder.number` */\r\nvar number = Decoder.number;\r\n/** See `Decoder.boolean` */\r\nvar boolean = Decoder.boolean;\r\n/** See `Decoder.anyJson` */\r\nvar anyJson = Decoder.anyJson;\r\n/** See `Decoder.unknownJson` */\r\nvar unknownJson = Decoder.unknownJson;\r\n/** See `Decoder.constant` */\r\nvar constant = Decoder.constant;\r\n/** See `Decoder.object` */\r\nvar object = Decoder.object;\r\n/** See `Decoder.array` */\r\nvar array = Decoder.array;\r\n/** See `Decoder.tuple` */\r\nvar tuple = Decoder.tuple;\r\n/** See `Decoder.dict` */\r\nvar dict = Decoder.dict;\r\n/** See `Decoder.optional` */\r\nvar optional = Decoder.optional;\r\n/** See `Decoder.oneOf` */\r\nvar oneOf = Decoder.oneOf;\r\n/** See `Decoder.union` */\r\nvar union = Decoder.union;\r\n/** See `Decoder.intersection` */\r\nvar intersection = Decoder.intersection;\r\n/** See `Decoder.withDefault` */\r\nvar withDefault$1 = Decoder.withDefault;\r\n/** See `Decoder.valueAt` */\r\nvar valueAt = Decoder.valueAt;\r\n/** See `Decoder.succeed` */\r\nvar succeed = Decoder.succeed;\r\n/** See `Decoder.fail` */\r\nvar fail = Decoder.fail;\r\n/** See `Decoder.lazy` */\r\nvar lazy = Decoder.lazy;\r\n\r\nexport { result as Result, Decoder, isDecoderError, string, number, boolean, anyJson, unknownJson, constant, object, array, tuple, dict, optional, oneOf, union, intersection, withDefault$1 as withDefault, valueAt, succeed, fail, lazy };\r\n//# sourceMappingURL=index.es5.js.map\r\n",null,null,null,"\"use strict\";\nfunction createRegistry(options) {\n if (options && options.errorHandling\n && typeof options.errorHandling !== \"function\"\n && options.errorHandling !== \"log\"\n && options.errorHandling !== \"silent\"\n && options.errorHandling !== \"throw\") {\n throw new Error(\"Invalid options passed to createRegistry. Prop errorHandling should be [\\\"log\\\" | \\\"silent\\\" | \\\"throw\\\" | (err) => void], but \" + typeof options.errorHandling + \" was passed\");\n }\n var _userErrorHandler = options && typeof options.errorHandling === \"function\" && options.errorHandling;\n var callbacks = {};\n function add(key, callback, replayArgumentsArr) {\n var callbacksForKey = callbacks[key];\n if (!callbacksForKey) {\n callbacksForKey = [];\n callbacks[key] = callbacksForKey;\n }\n callbacksForKey.push(callback);\n if (replayArgumentsArr) {\n setTimeout(function () {\n replayArgumentsArr.forEach(function (replayArgument) {\n var _a;\n if ((_a = callbacks[key]) === null || _a === void 0 ? void 0 : _a.includes(callback)) {\n try {\n if (Array.isArray(replayArgument)) {\n callback.apply(undefined, replayArgument);\n }\n else {\n callback.apply(undefined, [replayArgument]);\n }\n }\n catch (err) {\n _handleError(err, key);\n }\n }\n });\n }, 0);\n }\n return function () {\n var allForKey = callbacks[key];\n if (!allForKey) {\n return;\n }\n allForKey = allForKey.reduce(function (acc, element, index) {\n if (!(element === callback && acc.length === index)) {\n acc.push(element);\n }\n return acc;\n }, []);\n if (allForKey.length === 0) {\n delete callbacks[key];\n }\n else {\n callbacks[key] = allForKey;\n }\n };\n }\n function execute(key) {\n var argumentsArr = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n argumentsArr[_i - 1] = arguments[_i];\n }\n var callbacksForKey = callbacks[key];\n if (!callbacksForKey || callbacksForKey.length === 0) {\n return [];\n }\n var results = [];\n callbacksForKey.forEach(function (callback) {\n try {\n var result = callback.apply(undefined, argumentsArr);\n results.push(result);\n }\n catch (err) {\n results.push(undefined);\n _handleError(err, key);\n }\n });\n return results;\n }\n function _handleError(exceptionArtifact, key) {\n var errParam = exceptionArtifact instanceof Error ? exceptionArtifact : new Error(exceptionArtifact);\n if (_userErrorHandler) {\n _userErrorHandler(errParam);\n return;\n }\n var msg = \"[ERROR] callback-registry: User callback for key \\\"\" + key + \"\\\" failed: \" + errParam.stack;\n if (options) {\n switch (options.errorHandling) {\n case \"log\":\n return console.error(msg);\n case \"silent\":\n return;\n case \"throw\":\n throw new Error(msg);\n }\n }\n console.error(msg);\n }\n function clear() {\n callbacks = {};\n }\n function clearKey(key) {\n var callbacksForKey = callbacks[key];\n if (!callbacksForKey) {\n return;\n }\n delete callbacks[key];\n }\n return {\n add: add,\n execute: execute,\n clear: clear,\n clearKey: clearKey\n };\n}\n;\ncreateRegistry.default = createRegistry;\nmodule.exports = createRegistry;\n//# sourceMappingURL=index.js.map",null,null,null,null,null,null],"names":["ok","result","err","error","map2","f","ar","br","mapError","r","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","isEqual","a","b","Array","isArray","keys","isJsonArray","json","isJsonObject","expectedGot","expected","got","JSON","stringify","typeString","printPath","paths","map","path","join","prependAt","newAt","_a","at","rest","e","indexOf","getOwnPropertySymbols","propertyIsEnumerable","__rest","Decoder","decode","_this","run","kind","input","message","runPromise","Promise","resolve","reject","runWithException","withException","andThen","value","where","test","errorMessage","succeed","fail","string","number","boolean","constant","object","decoders","obj","key","undefined","array","decoder","reduce","acc","v","arr","concat","err$$1","decodeValue_1","tuple","nth","union","ad","bd","_i","oneOf","intersection","ds","anyJson","unknownJson","dict","optional","errors","errorsList","withDefault","defaultValue","valueAt","jsonAtPath","slice","fixedValue","lazy","mkDecoder","nonEmptyStringDecoder","operationCheckConfigDecoder","operation","operationCheckResultDecoder","isSupported","simpleWindowDecoder","windowId","iframesOperationTypesDecoder","iframesOpenAppConfigDecoder","appName","channelId","context","waitForAGMReady","reserveStandaloneIFrameAppDataDecoder","reserveStandaloneIFrameAppResultDecoder","instanceId","url","registerStandaloneIFrameAppDataDecoder","name","parentId","Bridge","io","constructor","getMyInstanceId","interop","instance","initiate","handleControlMessage","registerAsync","args","_","success","then","catch","reason","send","operationData","options","webOptions","dataDecoder","Error","includeOperationCheck","checkOperationSupported","operationResult","transmitMessage","resultDecoder","data","platformTarget","window","glue42core","iobrowser","communicationId","messageData","domain","invocationResult","baseErrorMessage","invoke","all_return_values","all_errors","invocationErrorMessage","returned","createRegistry","errorHandling","_userErrorHandler","callbacks","_handleError","exceptionArtifact","errParam","msg","stack","console","add","callback","replayArgumentsArr","callbacksForKey","push","setTimeout","forEach","replayArgument","includes","allForKey","element","index","execute","argumentsArr","results","clear","clearKey","default","operations","operationCheck","reserveStandaloneIFrameApp","registerStandaloneIFrameApp","unregisterStandaloneIFrameApp","closeRequested","IFramesController","bridge","registry","CallbackRegistryFactory","instances","Map","pendingCloseResolvers","supportedOperationsNames","confirmFrameClosedTimeoutMs","addOperationsExecutors","exposeApi","version","api","openApp","bind","onCloseRequested","confirmFrameClosed","freeze","operationName","async","config","handleOperationCheck","supportedOperations","some","toLowerCase","handleCloseRequested","filter","getSupportedOperationsNames","iframe","generateIframeElement","document","body","appendChild","remove","id","set","createElement","src","style","position","top","left","width","height","get","promise","wrapperResolve","wrapperReject","wrapPromise","timeoutMilliseconds","promiseActive","timeout","clearTimeout","delete","IoC","_bridge","_iframesController","iframesController","factoryFunction","ioc","iframes","IOIFrames"],"mappings":"qQAKA,IAAIA,EAAK,SAAUC,GAAU,OAAUD,IAAI,EAAMC,OAAQA,EAAW,EAUhEC,EAAM,SAAUC,GAAS,OAAUH,IAAI,EAAOG,MAAOA,EAAU,EAkE/DC,EAAO,SAAUC,EAAGC,EAAIC,GACxB,OAAiB,IAAVD,EAAGN,GAAeM,GACX,IAAVC,EAAGP,GAAeO,EACdP,EAAGK,EAAEC,EAAGL,OAAQM,EAAGN,QAC/B,EAIIO,EAAW,SAAUH,EAAGI,GACxB,OAAgB,IAATA,EAAET,GAAcS,EAAIP,EAAIG,EAAEI,EAAEN,OACvC,EA6CIO,EAAW,WAQX,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,CACX,EACOH,EAASa,MAAMC,KAAMP,UAChC,EAcA,SAASQ,EAAQC,EAAGC,GAChB,GAAID,IAAMC,EACN,OAAO,EAEX,GAAU,OAAND,GAAoB,OAANC,EACd,OAAO,EAEX,oBAAmB,EACf,OAAO,EAEX,GAAmB,iBAAf,EAAyB,CAEzB,GAAIC,MAAMC,QAAQH,GAAI,CAClB,IAAKE,MAAMC,QAAQF,GACf,OAAO,EAEX,GAAID,EAAER,SAAWS,EAAET,OACf,OAAO,EAEX,IAAK,IAAIH,EAAI,EAAGA,EAAIW,EAAER,OAAQH,IAC1B,IAAKU,EAAQC,EAAEX,GAAIY,EAAEZ,IACjB,OAAO,EAGf,OAAO,CACX,CAEA,IAAIe,EAAOnB,OAAOmB,KAAKJ,GACvB,GAAII,EAAKZ,SAAWP,OAAOmB,KAAKH,GAA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B3L,KAAK4L,SAGlD5L,KAAKmP,kBAChB,QCnBSE,EAA0CvC,MAAO7F,IAC1D,MAAMqI,EAAM,IAAIL,EAAIhI,SAEdqI,EAAI1D,OAAOtE,SAASgI,EAAIF,kBAAkB7H,qBAAqBkF,KAAK6C,EAAIF,oBAE9EnI,EAAGsI,QAAUD,EAAIF,kBAAkB/C,iCCRjB,oBAAXzD,SAENA,OAAe4G,UAAYH","x_google_ignoreList":[0,4]}
1
+ {"version":3,"file":"iframes.umd.min.js","sources":["../../../node_modules/decoder-validate/dist/index.es5.js","../src/shared/decoders.ts","../src/communication/bridge.ts","../src/shared/constants.ts","../../../node_modules/callback-registry/lib/index.js","../src/shared/utils.ts","../src/iframes/protocol.ts","../src/iframes/controller.ts","../src/shared/ioc.ts","../src/main.ts","../src/index.ts"],"sourcesContent":["/**\r\n * Wraps values in an `Ok` type.\r\n *\r\n * Example: `ok(5) // => {ok: true, result: 5}`\r\n */\r\nvar ok = function (result) { return ({ ok: true, result: result }); };\r\n/**\r\n * Typeguard for `Ok`.\r\n */\r\nvar isOk = function (r) { return r.ok === true; };\r\n/**\r\n * Wraps errors in an `Err` type.\r\n *\r\n * Example: `err('on fire') // => {ok: false, error: 'on fire'}`\r\n */\r\nvar err = function (error) { return ({ ok: false, error: error }); };\r\n/**\r\n * Typeguard for `Err`.\r\n */\r\nvar isErr = function (r) { return r.ok === false; };\r\n/**\r\n * Create a `Promise` that either resolves with the result of `Ok` or rejects\r\n * with the error of `Err`.\r\n */\r\nvar asPromise = function (r) {\r\n return r.ok === true ? Promise.resolve(r.result) : Promise.reject(r.error);\r\n};\r\n/**\r\n * Unwraps a `Result` and returns either the result of an `Ok`, or\r\n * `defaultValue`.\r\n *\r\n * Example:\r\n * ```\r\n * Result.withDefault(5, number().run(json))\r\n * ```\r\n *\r\n * It would be nice if `Decoder` had an instance method that mirrored this\r\n * function. Such a method would look something like this:\r\n * ```\r\n * class Decoder<A> {\r\n * runWithDefault = (defaultValue: A, json: any): A =>\r\n * Result.withDefault(defaultValue, this.run(json));\r\n * }\r\n *\r\n * number().runWithDefault(5, json)\r\n * ```\r\n * Unfortunately, the type of `defaultValue: A` on the method causes issues\r\n * with type inference on the `object` decoder in some situations. While these\r\n * inference issues can be solved by providing the optional type argument for\r\n * `object`s, the extra trouble and confusion doesn't seem worth it.\r\n */\r\nvar withDefault = function (defaultValue, r) {\r\n return r.ok === true ? r.result : defaultValue;\r\n};\r\n/**\r\n * Return the successful result, or throw an error.\r\n */\r\nvar withException = function (r) {\r\n if (r.ok === true) {\r\n return r.result;\r\n }\r\n else {\r\n throw r.error;\r\n }\r\n};\r\n/**\r\n * Given an array of `Result`s, return the successful values.\r\n */\r\nvar successes = function (results) {\r\n return results.reduce(function (acc, r) { return (r.ok === true ? acc.concat(r.result) : acc); }, []);\r\n};\r\n/**\r\n * Apply `f` to the result of an `Ok`, or pass the error through.\r\n */\r\nvar map = function (f, r) {\r\n return r.ok === true ? ok(f(r.result)) : r;\r\n};\r\n/**\r\n * Apply `f` to the result of two `Ok`s, or pass an error through. If both\r\n * `Result`s are errors then the first one is returned.\r\n */\r\nvar map2 = function (f, ar, br) {\r\n return ar.ok === false ? ar :\r\n br.ok === false ? br :\r\n ok(f(ar.result, br.result));\r\n};\r\n/**\r\n * Apply `f` to the error of an `Err`, or pass the success through.\r\n */\r\nvar mapError = function (f, r) {\r\n return r.ok === true ? r : err(f(r.error));\r\n};\r\n/**\r\n * Chain together a sequence of computations that may fail, similar to a\r\n * `Promise`. If the first computation fails then the error will propagate\r\n * through. If it succeeds, then `f` will be applied to the value, returning a\r\n * new `Result`.\r\n */\r\nvar andThen = function (f, r) {\r\n return r.ok === true ? f(r.result) : r;\r\n};\r\n\r\n\r\nvar result = Object.freeze({\r\n\tok: ok,\r\n\tisOk: isOk,\r\n\terr: err,\r\n\tisErr: isErr,\r\n\tasPromise: asPromise,\r\n\twithDefault: withDefault,\r\n\twithException: withException,\r\n\tsuccesses: successes,\r\n\tmap: map,\r\n\tmap2: map2,\r\n\tmapError: mapError,\r\n\tandThen: andThen\r\n});\r\n\r\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\n\r\n\r\nvar __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\n\r\nfunction __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nfunction isEqual(a, b) {\r\n if (a === b) {\r\n return true;\r\n }\r\n if (a === null && b === null) {\r\n return true;\r\n }\r\n if (typeof (a) !== typeof (b)) {\r\n return false;\r\n }\r\n if (typeof (a) === 'object') {\r\n // Array\r\n if (Array.isArray(a)) {\r\n if (!Array.isArray(b)) {\r\n return false;\r\n }\r\n if (a.length !== b.length) {\r\n return false;\r\n }\r\n for (var i = 0; i < a.length; i++) {\r\n if (!isEqual(a[i], b[i])) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n // Hash table\r\n var keys = Object.keys(a);\r\n if (keys.length !== Object.keys(b).length) {\r\n return false;\r\n }\r\n for (var i = 0; i < keys.length; i++) {\r\n if (!b.hasOwnProperty(keys[i])) {\r\n return false;\r\n }\r\n if (!isEqual(a[keys[i]], b[keys[i]])) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n}\r\n/**\r\n * Type guard for `DecoderError`. One use case of the type guard is in the\r\n * `catch` of a promise. Typescript types the error argument of `catch` as\r\n * `any`, so when dealing with a decoder as a promise you may need to\r\n * distinguish between a `DecoderError` and an error string.\r\n */\r\nvar isDecoderError = function (a) {\r\n return a.kind === 'DecoderError' && typeof a.at === 'string' && typeof a.message === 'string';\r\n};\r\n/*\r\n * Helpers\r\n */\r\nvar isJsonArray = function (json) { return Array.isArray(json); };\r\nvar isJsonObject = function (json) {\r\n return typeof json === 'object' && json !== null && !isJsonArray(json);\r\n};\r\nvar typeString = function (json) {\r\n switch (typeof json) {\r\n case 'string':\r\n return 'a string';\r\n case 'number':\r\n return 'a number';\r\n case 'boolean':\r\n return 'a boolean';\r\n case 'undefined':\r\n return 'undefined';\r\n case 'object':\r\n if (json instanceof Array) {\r\n return 'an array';\r\n }\r\n else if (json === null) {\r\n return 'null';\r\n }\r\n else {\r\n return 'an object';\r\n }\r\n default:\r\n return JSON.stringify(json);\r\n }\r\n};\r\nvar expectedGot = function (expected, got) {\r\n return \"expected \" + expected + \", got \" + typeString(got);\r\n};\r\nvar printPath = function (paths) {\r\n return paths.map(function (path) { return (typeof path === 'string' ? \".\" + path : \"[\" + path + \"]\"); }).join('');\r\n};\r\nvar prependAt = function (newAt, _a) {\r\n var at = _a.at, rest = __rest(_a, [\"at\"]);\r\n return (__assign({ at: newAt + (at || '') }, rest));\r\n};\r\n/**\r\n * Decoders transform json objects with unknown structure into known and\r\n * verified forms. You can create objects of type `Decoder<A>` with either the\r\n * primitive decoder functions, such as `boolean()` and `string()`, or by\r\n * applying higher-order decoders to the primitives, such as `array(boolean())`\r\n * or `dict(string())`.\r\n *\r\n * Each of the decoder functions are available both as a static method on\r\n * `Decoder` and as a function alias -- for example the string decoder is\r\n * defined at `Decoder.string()`, but is also aliased to `string()`. Using the\r\n * function aliases exported with the library is recommended.\r\n *\r\n * `Decoder` exposes a number of 'run' methods, which all decode json in the\r\n * same way, but communicate success and failure in different ways. The `map`\r\n * and `andThen` methods modify decoders without having to call a 'run' method.\r\n *\r\n * Alternatively, the main decoder `run()` method returns an object of type\r\n * `Result<A, DecoderError>`. This library provides a number of helper\r\n * functions for dealing with the `Result` type, so you can do all the same\r\n * things with a `Result` as with the decoder methods.\r\n */\r\nvar Decoder = /** @class */ (function () {\r\n /**\r\n * The Decoder class constructor is kept private to separate the internal\r\n * `decode` function from the external `run` function. The distinction\r\n * between the two functions is that `decode` returns a\r\n * `Partial<DecoderError>` on failure, which contains an unfinished error\r\n * report. When `run` is called on a decoder, the relevant series of `decode`\r\n * calls is made, and then on failure the resulting `Partial<DecoderError>`\r\n * is turned into a `DecoderError` by filling in the missing information.\r\n *\r\n * While hiding the constructor may seem restrictive, leveraging the\r\n * provided decoder combinators and helper functions such as\r\n * `andThen` and `map` should be enough to build specialized decoders as\r\n * needed.\r\n */\r\n function Decoder(decode) {\r\n var _this = this;\r\n this.decode = decode;\r\n /**\r\n * Run the decoder and return a `Result` with either the decoded value or a\r\n * `DecoderError` containing the json input, the location of the error, and\r\n * the error message.\r\n *\r\n * Examples:\r\n * ```\r\n * number().run(12)\r\n * // => {ok: true, result: 12}\r\n *\r\n * string().run(9001)\r\n * // =>\r\n * // {\r\n * // ok: false,\r\n * // error: {\r\n * // kind: 'DecoderError',\r\n * // input: 9001,\r\n * // at: 'input',\r\n * // message: 'expected a string, got 9001'\r\n * // }\r\n * // }\r\n * ```\r\n */\r\n this.run = function (json) {\r\n return mapError(function (error) { return ({\r\n kind: 'DecoderError',\r\n input: json,\r\n at: 'input' + (error.at || ''),\r\n message: error.message || ''\r\n }); }, _this.decode(json));\r\n };\r\n /**\r\n * Run the decoder as a `Promise`.\r\n */\r\n this.runPromise = function (json) { return asPromise(_this.run(json)); };\r\n /**\r\n * Run the decoder and return the value on success, or throw an exception\r\n * with a formatted error string.\r\n */\r\n this.runWithException = function (json) { return withException(_this.run(json)); };\r\n /**\r\n * Construct a new decoder that applies a transformation to the decoded\r\n * result. If the decoder succeeds then `f` will be applied to the value. If\r\n * it fails the error will propagated through.\r\n *\r\n * Example:\r\n * ```\r\n * number().map(x => x * 5).run(10)\r\n * // => {ok: true, result: 50}\r\n * ```\r\n */\r\n this.map = function (f) {\r\n return new Decoder(function (json) { return map(f, _this.decode(json)); });\r\n };\r\n /**\r\n * Chain together a sequence of decoders. The first decoder will run, and\r\n * then the function will determine what decoder to run second. If the result\r\n * of the first decoder succeeds then `f` will be applied to the decoded\r\n * value. If it fails the error will propagate through.\r\n *\r\n * This is a very powerful method -- it can act as both the `map` and `where`\r\n * methods, can improve error messages for edge cases, and can be used to\r\n * make a decoder for custom types.\r\n *\r\n * Example of adding an error message:\r\n * ```\r\n * const versionDecoder = valueAt(['version'], number());\r\n * const infoDecoder3 = object({a: boolean()});\r\n *\r\n * const decoder = versionDecoder.andThen(version => {\r\n * switch (version) {\r\n * case 3:\r\n * return infoDecoder3;\r\n * default:\r\n * return fail(`Unable to decode info, version ${version} is not supported.`);\r\n * }\r\n * });\r\n *\r\n * decoder.run({version: 3, a: true})\r\n * // => {ok: true, result: {a: true}}\r\n *\r\n * decoder.run({version: 5, x: 'abc'})\r\n * // =>\r\n * // {\r\n * // ok: false,\r\n * // error: {... message: 'Unable to decode info, version 5 is not supported.'}\r\n * // }\r\n * ```\r\n *\r\n * Example of decoding a custom type:\r\n * ```\r\n * // nominal type for arrays with a length of at least one\r\n * type NonEmptyArray<T> = T[] & { __nonEmptyArrayBrand__: void };\r\n *\r\n * const nonEmptyArrayDecoder = <T>(values: Decoder<T>): Decoder<NonEmptyArray<T>> =>\r\n * array(values).andThen(arr =>\r\n * arr.length > 0\r\n * ? succeed(createNonEmptyArray(arr))\r\n * : fail(`expected a non-empty array, got an empty array`)\r\n * );\r\n * ```\r\n */\r\n this.andThen = function (f) {\r\n return new Decoder(function (json) {\r\n return andThen(function (value) { return f(value).decode(json); }, _this.decode(json));\r\n });\r\n };\r\n /**\r\n * Add constraints to a decoder _without_ changing the resulting type. The\r\n * `test` argument is a predicate function which returns true for valid\r\n * inputs. When `test` fails on an input, the decoder fails with the given\r\n * `errorMessage`.\r\n *\r\n * ```\r\n * const chars = (length: number): Decoder<string> =>\r\n * string().where(\r\n * (s: string) => s.length === length,\r\n * `expected a string of length ${length}`\r\n * );\r\n *\r\n * chars(5).run('12345')\r\n * // => {ok: true, result: '12345'}\r\n *\r\n * chars(2).run('HELLO')\r\n * // => {ok: false, error: {... message: 'expected a string of length 2'}}\r\n *\r\n * chars(12).run(true)\r\n * // => {ok: false, error: {... message: 'expected a string, got a boolean'}}\r\n * ```\r\n */\r\n this.where = function (test, errorMessage) {\r\n return _this.andThen(function (value) { return (test(value) ? Decoder.succeed(value) : Decoder.fail(errorMessage)); });\r\n };\r\n }\r\n /**\r\n * Decoder primitive that validates strings, and fails on all other input.\r\n */\r\n Decoder.string = function () {\r\n return new Decoder(function (json) {\r\n return typeof json === 'string'\r\n ? ok(json)\r\n : err({ message: expectedGot('a string', json) });\r\n });\r\n };\r\n /**\r\n * Decoder primitive that validates numbers, and fails on all other input.\r\n */\r\n Decoder.number = function () {\r\n return new Decoder(function (json) {\r\n return typeof json === 'number'\r\n ? ok(json)\r\n : err({ message: expectedGot('a number', json) });\r\n });\r\n };\r\n /**\r\n * Decoder primitive that validates booleans, and fails on all other input.\r\n */\r\n Decoder.boolean = function () {\r\n return new Decoder(function (json) {\r\n return typeof json === 'boolean'\r\n ? ok(json)\r\n : err({ message: expectedGot('a boolean', json) });\r\n });\r\n };\r\n Decoder.constant = function (value) {\r\n return new Decoder(function (json) {\r\n return isEqual(json, value)\r\n ? ok(value)\r\n : err({ message: \"expected \" + JSON.stringify(value) + \", got \" + JSON.stringify(json) });\r\n });\r\n };\r\n Decoder.object = function (decoders) {\r\n return new Decoder(function (json) {\r\n if (isJsonObject(json) && decoders) {\r\n var obj = {};\r\n for (var key in decoders) {\r\n if (decoders.hasOwnProperty(key)) {\r\n var r = decoders[key].decode(json[key]);\r\n if (r.ok === true) {\r\n // tslint:disable-next-line:strict-type-predicates\r\n if (r.result !== undefined) {\r\n obj[key] = r.result;\r\n }\r\n }\r\n else if (json[key] === undefined) {\r\n return err({ message: \"the key '\" + key + \"' is required but was not present\" });\r\n }\r\n else {\r\n return err(prependAt(\".\" + key, r.error));\r\n }\r\n }\r\n }\r\n return ok(obj);\r\n }\r\n else if (isJsonObject(json)) {\r\n return ok(json);\r\n }\r\n else {\r\n return err({ message: expectedGot('an object', json) });\r\n }\r\n });\r\n };\r\n Decoder.array = function (decoder) {\r\n return new Decoder(function (json) {\r\n if (isJsonArray(json) && decoder) {\r\n var decodeValue_1 = function (v, i) {\r\n return mapError(function (err$$1) { return prependAt(\"[\" + i + \"]\", err$$1); }, decoder.decode(v));\r\n };\r\n return json.reduce(function (acc, v, i) {\r\n return map2(function (arr, result) { return arr.concat([result]); }, acc, decodeValue_1(v, i));\r\n }, ok([]));\r\n }\r\n else if (isJsonArray(json)) {\r\n return ok(json);\r\n }\r\n else {\r\n return err({ message: expectedGot('an array', json) });\r\n }\r\n });\r\n };\r\n Decoder.tuple = function (decoders) {\r\n return new Decoder(function (json) {\r\n if (isJsonArray(json)) {\r\n if (json.length !== decoders.length) {\r\n return err({\r\n message: \"expected a tuple of length \" + decoders.length + \", got one of length \" + json.length\r\n });\r\n }\r\n var result = [];\r\n for (var i = 0; i < decoders.length; i++) {\r\n var nth = decoders[i].decode(json[i]);\r\n if (nth.ok) {\r\n result[i] = nth.result;\r\n }\r\n else {\r\n return err(prependAt(\"[\" + i + \"]\", nth.error));\r\n }\r\n }\r\n return ok(result);\r\n }\r\n else {\r\n return err({ message: expectedGot(\"a tuple of length \" + decoders.length, json) });\r\n }\r\n });\r\n };\r\n Decoder.union = function (ad, bd) {\r\n var decoders = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n decoders[_i - 2] = arguments[_i];\r\n }\r\n return Decoder.oneOf.apply(Decoder, [ad, bd].concat(decoders));\r\n };\r\n Decoder.intersection = function (ad, bd) {\r\n var ds = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n ds[_i - 2] = arguments[_i];\r\n }\r\n return new Decoder(function (json) {\r\n return [ad, bd].concat(ds).reduce(function (acc, decoder) { return map2(Object.assign, acc, decoder.decode(json)); }, ok({}));\r\n });\r\n };\r\n /**\r\n * Escape hatch to bypass validation. Always succeeds and types the result as\r\n * `any`. Useful for defining decoders incrementally, particularly for\r\n * complex objects.\r\n *\r\n * Example:\r\n * ```\r\n * interface User {\r\n * name: string;\r\n * complexUserData: ComplexType;\r\n * }\r\n *\r\n * const userDecoder: Decoder<User> = object({\r\n * name: string(),\r\n * complexUserData: anyJson()\r\n * });\r\n * ```\r\n */\r\n Decoder.anyJson = function () { return new Decoder(function (json) { return ok(json); }); };\r\n /**\r\n * Decoder identity function which always succeeds and types the result as\r\n * `unknown`.\r\n */\r\n Decoder.unknownJson = function () {\r\n return new Decoder(function (json) { return ok(json); });\r\n };\r\n /**\r\n * Decoder for json objects where the keys are unknown strings, but the values\r\n * should all be of the same type.\r\n *\r\n * Example:\r\n * ```\r\n * dict(number()).run({chocolate: 12, vanilla: 10, mint: 37});\r\n * // => {ok: true, result: {chocolate: 12, vanilla: 10, mint: 37}}\r\n * ```\r\n */\r\n Decoder.dict = function (decoder) {\r\n return new Decoder(function (json) {\r\n if (isJsonObject(json)) {\r\n var obj = {};\r\n for (var key in json) {\r\n if (json.hasOwnProperty(key)) {\r\n var r = decoder.decode(json[key]);\r\n if (r.ok === true) {\r\n obj[key] = r.result;\r\n }\r\n else {\r\n return err(prependAt(\".\" + key, r.error));\r\n }\r\n }\r\n }\r\n return ok(obj);\r\n }\r\n else {\r\n return err({ message: expectedGot('an object', json) });\r\n }\r\n });\r\n };\r\n /**\r\n * Decoder for values that may be `undefined`. This is primarily helpful for\r\n * decoding interfaces with optional fields.\r\n *\r\n * Example:\r\n * ```\r\n * interface User {\r\n * id: number;\r\n * isOwner?: boolean;\r\n * }\r\n *\r\n * const decoder: Decoder<User> = object({\r\n * id: number(),\r\n * isOwner: optional(boolean())\r\n * });\r\n * ```\r\n */\r\n Decoder.optional = function (decoder) {\r\n return new Decoder(function (json) { return (json === undefined || json === null ? ok(undefined) : decoder.decode(json)); });\r\n };\r\n /**\r\n * Decoder that attempts to run each decoder in `decoders` and either succeeds\r\n * with the first successful decoder, or fails after all decoders have failed.\r\n *\r\n * Note that `oneOf` expects the decoders to all have the same return type,\r\n * while `union` creates a decoder for the union type of all the input\r\n * decoders.\r\n *\r\n * Examples:\r\n * ```\r\n * oneOf(string(), number().map(String))\r\n * oneOf(constant('start'), constant('stop'), succeed('unknown'))\r\n * ```\r\n */\r\n Decoder.oneOf = function () {\r\n var decoders = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n decoders[_i] = arguments[_i];\r\n }\r\n return new Decoder(function (json) {\r\n var errors = [];\r\n for (var i = 0; i < decoders.length; i++) {\r\n var r = decoders[i].decode(json);\r\n if (r.ok === true) {\r\n return r;\r\n }\r\n else {\r\n errors[i] = r.error;\r\n }\r\n }\r\n var errorsList = errors\r\n .map(function (error) { return \"at error\" + (error.at || '') + \": \" + error.message; })\r\n .join('\", \"');\r\n return err({\r\n message: \"expected a value matching one of the decoders, got the errors [\\\"\" + errorsList + \"\\\"]\"\r\n });\r\n });\r\n };\r\n /**\r\n * Decoder that always succeeds with either the decoded value, or a fallback\r\n * default value.\r\n */\r\n Decoder.withDefault = function (defaultValue, decoder) {\r\n return new Decoder(function (json) {\r\n return ok(withDefault(defaultValue, decoder.decode(json)));\r\n });\r\n };\r\n /**\r\n * Decoder that pulls a specific field out of a json structure, instead of\r\n * decoding and returning the full structure. The `paths` array describes the\r\n * object keys and array indices to traverse, so that values can be pulled out\r\n * of a nested structure.\r\n *\r\n * Example:\r\n * ```\r\n * const decoder = valueAt(['a', 'b', 0], string());\r\n *\r\n * decoder.run({a: {b: ['surprise!']}})\r\n * // => {ok: true, result: 'surprise!'}\r\n *\r\n * decoder.run({a: {x: 'cats'}})\r\n * // => {ok: false, error: {... at: 'input.a.b[0]' message: 'path does not exist'}}\r\n * ```\r\n *\r\n * Note that the `decoder` is ran on the value found at the last key in the\r\n * path, even if the last key is not found. This allows the `optional`\r\n * decoder to succeed when appropriate.\r\n * ```\r\n * const optionalDecoder = valueAt(['a', 'b', 'c'], optional(string()));\r\n *\r\n * optionalDecoder.run({a: {b: {c: 'surprise!'}}})\r\n * // => {ok: true, result: 'surprise!'}\r\n *\r\n * optionalDecoder.run({a: {b: 'cats'}})\r\n * // => {ok: false, error: {... at: 'input.a.b.c' message: 'expected an object, got \"cats\"'}\r\n *\r\n * optionalDecoder.run({a: {b: {z: 1}}})\r\n * // => {ok: true, result: undefined}\r\n * ```\r\n */\r\n Decoder.valueAt = function (paths, decoder) {\r\n return new Decoder(function (json) {\r\n var jsonAtPath = json;\r\n for (var i = 0; i < paths.length; i++) {\r\n if (jsonAtPath === undefined) {\r\n return err({\r\n at: printPath(paths.slice(0, i + 1)),\r\n message: 'path does not exist'\r\n });\r\n }\r\n else if (typeof paths[i] === 'string' && !isJsonObject(jsonAtPath)) {\r\n return err({\r\n at: printPath(paths.slice(0, i + 1)),\r\n message: expectedGot('an object', jsonAtPath)\r\n });\r\n }\r\n else if (typeof paths[i] === 'number' && !isJsonArray(jsonAtPath)) {\r\n return err({\r\n at: printPath(paths.slice(0, i + 1)),\r\n message: expectedGot('an array', jsonAtPath)\r\n });\r\n }\r\n else {\r\n jsonAtPath = jsonAtPath[paths[i]];\r\n }\r\n }\r\n return mapError(function (error) {\r\n return jsonAtPath === undefined\r\n ? { at: printPath(paths), message: 'path does not exist' }\r\n : prependAt(printPath(paths), error);\r\n }, decoder.decode(jsonAtPath));\r\n });\r\n };\r\n /**\r\n * Decoder that ignores the input json and always succeeds with `fixedValue`.\r\n */\r\n Decoder.succeed = function (fixedValue) {\r\n return new Decoder(function (json) { return ok(fixedValue); });\r\n };\r\n /**\r\n * Decoder that ignores the input json and always fails with `errorMessage`.\r\n */\r\n Decoder.fail = function (errorMessage) {\r\n return new Decoder(function (json) { return err({ message: errorMessage }); });\r\n };\r\n /**\r\n * Decoder that allows for validating recursive data structures. Unlike with\r\n * functions, decoders assigned to variables can't reference themselves\r\n * before they are fully defined. We can avoid prematurely referencing the\r\n * decoder by wrapping it in a function that won't be called until use, at\r\n * which point the decoder has been defined.\r\n *\r\n * Example:\r\n * ```\r\n * interface Comment {\r\n * msg: string;\r\n * replies: Comment[];\r\n * }\r\n *\r\n * const decoder: Decoder<Comment> = object({\r\n * msg: string(),\r\n * replies: lazy(() => array(decoder))\r\n * });\r\n * ```\r\n */\r\n Decoder.lazy = function (mkDecoder) {\r\n return new Decoder(function (json) { return mkDecoder().decode(json); });\r\n };\r\n return Decoder;\r\n}());\r\n\r\n/* tslint:disable:variable-name */\r\n/** See `Decoder.string` */\r\nvar string = Decoder.string;\r\n/** See `Decoder.number` */\r\nvar number = Decoder.number;\r\n/** See `Decoder.boolean` */\r\nvar boolean = Decoder.boolean;\r\n/** See `Decoder.anyJson` */\r\nvar anyJson = Decoder.anyJson;\r\n/** See `Decoder.unknownJson` */\r\nvar unknownJson = Decoder.unknownJson;\r\n/** See `Decoder.constant` */\r\nvar constant = Decoder.constant;\r\n/** See `Decoder.object` */\r\nvar object = Decoder.object;\r\n/** See `Decoder.array` */\r\nvar array = Decoder.array;\r\n/** See `Decoder.tuple` */\r\nvar tuple = Decoder.tuple;\r\n/** See `Decoder.dict` */\r\nvar dict = Decoder.dict;\r\n/** See `Decoder.optional` */\r\nvar optional = Decoder.optional;\r\n/** See `Decoder.oneOf` */\r\nvar oneOf = Decoder.oneOf;\r\n/** See `Decoder.union` */\r\nvar union = Decoder.union;\r\n/** See `Decoder.intersection` */\r\nvar intersection = Decoder.intersection;\r\n/** See `Decoder.withDefault` */\r\nvar withDefault$1 = Decoder.withDefault;\r\n/** See `Decoder.valueAt` */\r\nvar valueAt = Decoder.valueAt;\r\n/** See `Decoder.succeed` */\r\nvar succeed = Decoder.succeed;\r\n/** See `Decoder.fail` */\r\nvar fail = Decoder.fail;\r\n/** See `Decoder.lazy` */\r\nvar lazy = Decoder.lazy;\r\n\r\nexport { result as Result, Decoder, isDecoderError, string, number, boolean, anyJson, unknownJson, constant, object, array, tuple, dict, optional, oneOf, union, intersection, withDefault$1 as withDefault, valueAt, succeed, fail, lazy };\r\n//# sourceMappingURL=index.es5.js.map\r\n",null,null,null,"\"use strict\";\nfunction createRegistry(options) {\n if (options && options.errorHandling\n && typeof options.errorHandling !== \"function\"\n && options.errorHandling !== \"log\"\n && options.errorHandling !== \"silent\"\n && options.errorHandling !== \"throw\") {\n throw new Error(\"Invalid options passed to createRegistry. Prop errorHandling should be [\\\"log\\\" | \\\"silent\\\" | \\\"throw\\\" | (err) => void], but \" + typeof options.errorHandling + \" was passed\");\n }\n var _userErrorHandler = options && typeof options.errorHandling === \"function\" && options.errorHandling;\n var callbacks = {};\n function add(key, callback, replayArgumentsArr) {\n var callbacksForKey = callbacks[key];\n if (!callbacksForKey) {\n callbacksForKey = [];\n callbacks[key] = callbacksForKey;\n }\n callbacksForKey.push(callback);\n if (replayArgumentsArr) {\n setTimeout(function () {\n replayArgumentsArr.forEach(function (replayArgument) {\n var _a;\n if ((_a = callbacks[key]) === null || _a === void 0 ? void 0 : _a.includes(callback)) {\n try {\n if (Array.isArray(replayArgument)) {\n callback.apply(undefined, replayArgument);\n }\n else {\n callback.apply(undefined, [replayArgument]);\n }\n }\n catch (err) {\n _handleError(err, key);\n }\n }\n });\n }, 0);\n }\n return function () {\n var allForKey = callbacks[key];\n if (!allForKey) {\n return;\n }\n allForKey = allForKey.reduce(function (acc, element, index) {\n if (!(element === callback && acc.length === index)) {\n acc.push(element);\n }\n return acc;\n }, []);\n if (allForKey.length === 0) {\n delete callbacks[key];\n }\n else {\n callbacks[key] = allForKey;\n }\n };\n }\n function execute(key) {\n var argumentsArr = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n argumentsArr[_i - 1] = arguments[_i];\n }\n var callbacksForKey = callbacks[key];\n if (!callbacksForKey || callbacksForKey.length === 0) {\n return [];\n }\n var results = [];\n callbacksForKey.forEach(function (callback) {\n try {\n var result = callback.apply(undefined, argumentsArr);\n results.push(result);\n }\n catch (err) {\n results.push(undefined);\n _handleError(err, key);\n }\n });\n return results;\n }\n function _handleError(exceptionArtifact, key) {\n var errParam = exceptionArtifact instanceof Error ? exceptionArtifact : new Error(exceptionArtifact);\n if (_userErrorHandler) {\n _userErrorHandler(errParam);\n return;\n }\n var msg = \"[ERROR] callback-registry: User callback for key \\\"\" + key + \"\\\" failed: \" + errParam.stack;\n if (options) {\n switch (options.errorHandling) {\n case \"log\":\n return console.error(msg);\n case \"silent\":\n return;\n case \"throw\":\n throw new Error(msg);\n }\n }\n console.error(msg);\n }\n function clear() {\n callbacks = {};\n }\n function clearKey(key) {\n var callbacksForKey = callbacks[key];\n if (!callbacksForKey) {\n return;\n }\n delete callbacks[key];\n }\n return {\n add: add,\n execute: execute,\n clear: clear,\n clearKey: clearKey\n };\n}\n;\ncreateRegistry.default = createRegistry;\nmodule.exports = createRegistry;\n//# sourceMappingURL=index.js.map",null,null,null,null,null,null],"names":["ok","result","err","error","map2","f","ar","br","mapError","r","__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","isEqual","a","b","Array","isArray","keys","isJsonArray","json","isJsonObject","expectedGot","expected","got","JSON","stringify","typeString","printPath","paths","map","path","join","prependAt","newAt","_a","at","rest","e","indexOf","getOwnPropertySymbols","propertyIsEnumerable","__rest","Decoder","decode","_this","run","kind","input","message","runPromise","Promise","resolve","reject","runWithException","withException","andThen","value","where","test","errorMessage","succeed","fail","string","number","boolean","constant","object","decoders","obj","key","undefined","array","decoder","reduce","acc","v","arr","concat","err$$1","decodeValue_1","tuple","nth","union","ad","bd","_i","oneOf","intersection","ds","anyJson","unknownJson","dict","optional","errors","errorsList","withDefault","defaultValue","valueAt","jsonAtPath","slice","fixedValue","lazy","mkDecoder","nonEmptyStringDecoder","operationCheckConfigDecoder","operation","operationCheckResultDecoder","isSupported","simpleWindowDecoder","windowId","iframesOperationTypesDecoder","iframesOpenAppConfigDecoder","appName","channelId","container","context","iframeConfig","className","styles","reserveStandaloneIFrameAppDataDecoder","iframePermissionsPolicyConfigDecoder","flags","iframeSandboxConfigDecoder","reserveStandaloneIFrameAppResultDecoder","iframePermissionsPolicy","iframeSandbox","instanceId","url","registerStandaloneIFrameAppDataDecoder","parentId","closeRequestedResultDecoder","wasClosed","Bridge","io","operations","operationCheck","name","dataDecoder","resultDecoder","constructor","getMyInstanceId","interop","instance","initiate","handleControlMessage","registerAsync","args","_caller","success","then","catch","send","domain","operationData","options","webOptions","Error","includeOperationCheck","checkOperationSupported","operationResult","transmitMessage","data","platformTarget","window","glue42core","iobrowser","communicationId","messageData","invocationResult","baseErrorMessage","invoke","all_return_values","all_errors","invocationErrorMessage","returned","createRegistry","errorHandling","_userErrorHandler","callbacks","_handleError","exceptionArtifact","errParam","msg","stack","console","add","callback","replayArgumentsArr","callbacksForKey","push","setTimeout","forEach","replayArgument","includes","allForKey","element","index","execute","argumentsArr","results","clear","clearKey","default","reserveStandaloneIFrameApp","registerStandaloneIFrameApp","unregisterStandaloneIFrameApp","closeRequested","IFramesController","logger","bridge","registry","CallbackRegistryFactory","frames","Map","confirmFrameClosedTimeoutMs","supportedOperationsNames","addOperationsExecutors","exposeApi","version","api","openApp","bind","onCloseRequested","freeze","operationName","debug","handleCloseRequested","async","config","handleOperationCheck","supportedOperations","some","toLowerCase","filter","getSupportedOperationsNames","document","body","HTMLElement","TypeError","assertContainerConnected","iframe","generateIframeElement","appendChild","remove","id","set","isClosing","isConnected","createElement","src","style","setAttribute","frame","get","warn","promise","wrapperResolve","wrapperReject","wrapPromise","isHandled","delete","timeoutMilliseconds","promiseActive","timeout","clearTimeout","IoC","_bridge","_iframesController","iframesController","subLogger","factoryFunction","ioc","iframes","IOIFrames"],"mappings":"qQAKA,IAAIA,EAAK,SAAUC,GAAU,OAAUD,IAAI,EAAMC,OAAQA,EAAW,EAUhEC,EAAM,SAAUC,GAAS,OAAUH,IAAI,EAAOG,MAAOA,EAAU,EAkE/DC,EAAO,SAAUC,EAAGC,EAAIC,GACxB,OAAiB,IAAVD,EAAGN,GAAeM,GACX,IAAVC,EAAGP,GAAeO,EACdP,EAAGK,EAAEC,EAAGL,OAAQM,EAAGN,QAC/B,EAIIO,EAAW,SAAUH,EAAGI,GACxB,OAAgB,IAATA,EAAET,GAAcS,EAAIP,EAAIG,EAAEI,EAAEN,OACvC,EA6CIO,EAAW,WAQX,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,CACX,EACOH,EAASa,MAAMC,KAAMP,UAChC,EAcA,SAASQ,EAAQC,EAAGC,GAChB,GAAID,IAAMC,EACN,OAAO,EAEX,GAAU,OAAND,GAAoB,OAANC,EACd,OAAO,EAEX,oBAAmB,EACf,OAAO,EAEX,GAAmB,iBAAf,EAAyB,CAEzB,GAAIC,MAAMC,QAAQH,GAAI,CAClB,IAAK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AqB6E,KAAKkD,EAAIH,oBAE9EvI,EAAG2I,QAAUD,EAAIH,kBAAkBnD,0BCRjB,oBAAXtD,SAENA,OAAe8G,UAAYH","x_google_ignoreList":[0,4]}
package/iframes.d.ts CHANGED
@@ -8,6 +8,10 @@ export default IFramesFactory;
8
8
  declare module "@interopio/core" {
9
9
  export namespace IOConnectCore {
10
10
  export interface API {
11
+ /**
12
+ * IFrames API.
13
+ * @since io.Connect Browser 4.5
14
+ */
11
15
  iframes: IOConnectIFrames.API;
12
16
  }
13
17
  }
@@ -16,6 +20,9 @@ declare module "@interopio/core" {
16
20
  /**
17
21
  * @docname IFrames
18
22
  * @intro
23
+ * The IFrames API provides a convenient way to open io.Connect apps in `<iframe>` elements.
24
+ *
25
+ * *Available since **io.Connect Browser** 4.5.*
19
26
  */
20
27
  export namespace IOConnectIFrames {
21
28
 
@@ -24,34 +31,75 @@ export namespace IOConnectIFrames {
24
31
  */
25
32
  export type Unsubscribe = () => void;
26
33
 
34
+ /**
35
+ * Describes the instance of an app opened in an `<iframe>` element.
36
+ */
27
37
  export interface Instance {
38
+
39
+ /**
40
+ * Interop ID of the app instance.
41
+ */
28
42
  id: string;
29
43
 
44
+ /**
45
+ * Name of the app as specified in its definition.
46
+ */
30
47
  appName: string;
31
48
 
49
+ /**
50
+ * Interop ID of the parent app instance.
51
+ */
32
52
  parentId: string;
33
53
 
54
+ /**
55
+ * The `<iframe>` element in which the app is rendered.
56
+ */
34
57
  iframe: HTMLIFrameElement;
35
58
  }
36
59
 
60
+ /**
61
+ * Configuration for opening an app in an `<iframe>` element.
62
+ */
37
63
  export interface OpenAppConfig {
64
+
65
+ /**
66
+ * Name of the app as specified in its definition.
67
+ */
38
68
  appName: string;
39
69
 
40
70
  /**
41
- * Name of the Channel which the window will join.
71
+ * Name of the io.Connect Channel which the app instance will join.
42
72
  */
43
73
  channelId?: string;
44
74
 
45
75
  /**
46
- * The initial context of the application
76
+ * The HTML element to which the newly created `<iframe>` will be appended as a child element.
77
+ * @default document.body
78
+ */
79
+ container?: HTMLElement;
80
+
81
+ /**
82
+ * Starting context for the app instance.
47
83
  */
48
84
  context?: any;
49
85
 
50
86
  /**
51
- * If true, will wait for the Interop library to be initialized.
52
- * @default true
87
+ * Initial configuration that will be applied to the `<iframe>` element on creation.
88
+ * Passing CSS classes and styles before opening the app instance in an `<iframe>` element may help avoid
89
+ * undesirable visual flickering that may be caused by manipulating the `<iframe>` element after creation.
53
90
  */
54
- waitForAGMReady?: boolean;
91
+ iframeConfig?: {
92
+
93
+ /**
94
+ * CSS class names that will be applied to the `<iframe>` element on creation.
95
+ */
96
+ className?: string;
97
+
98
+ /**
99
+ * CSS styles that will be applied to the `<iframe>` element on creation.
100
+ */
101
+ styles?: Partial<CSSStyleDeclaration>;
102
+ }
55
103
  }
56
104
 
57
105
  /**
@@ -59,11 +107,23 @@ export namespace IOConnectIFrames {
59
107
  */
60
108
  export interface API {
61
109
 
110
+ /**
111
+ * Opens an app instance in a newly created `<iframe>` element within the current app instance.
112
+ * The app to open must be defined as an io.Connect app within the io.Connect framework.
113
+ * It's also required to provide a container HTML element to which the newly created `<iframe>` will be appended as a child.
114
+ * When the app is closed, you are responsible for removing the parent container element from the DOM if it's no longer needed.
115
+ * You must not alter the `id` and `name` attributes of the created `<iframe>` element, as they are used by the IFrames API to identify the app instance.
116
+ * @param config Settings for opening the app in an `<iframe>` element.
117
+ */
62
118
  openApp(config: OpenAppConfig): Promise<Instance>;
63
119
 
64
- onCloseRequested(callback: (instance: Instance) => void): Unsubscribe;
65
-
66
- confirmFrameClosed(id: string): Promise<void>;
120
+ /**
121
+ * Notifies when an app that has been opened in an `<iframe>` element is about to be closed.
122
+ * This method notifies about close requests only for `<iframe>` elements that have been created inside the current app instance.
123
+ * @param callback Callback function for handling the event. Receives as a first argument an object describing the app instance that is about to be closed.
124
+ * Receives as a second argument a function that can be invoked to confirm to the io.Connect framework that the `<iframe>` element can be removed from the DOM.
125
+ */
126
+ onCloseRequested(callback: (instance: Instance, confirmClose: () => Promise<void>) => Promise<void>): Unsubscribe;
67
127
 
68
128
  /**
69
129
  * Version of the IFrames API.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interopio/iframes-api",
3
- "version": "0.1.0-beta.0",
3
+ "version": "1.1.0",
4
4
  "description": "IOConnect IFrames API",
5
5
  "main": "dist/iframes.umd.js",
6
6
  "module": "dist/iframes.es.js",
@@ -26,13 +26,16 @@
26
26
  "name": "Interop.IO",
27
27
  "url": "https://interop.io/"
28
28
  },
29
- "license": "MIT",
30
- "dependencies": {
31
- "@interopio/core": "^6.10.4"
32
- },
29
+ "license": "SEE LICENSE IN LICENSE.md",
33
30
  "publishConfig": {
34
31
  "@interopio:registry": "https://registry.npmjs.org",
35
32
  "access": "public"
36
33
  },
37
- "gitHead": "3d731cc0a6305927219d5f180a808da731e3e95b"
34
+ "devDependencies": {
35
+ "@interopio/core": "^6.11.0"
36
+ },
37
+ "peerDependencies": {
38
+ "@interopio/core": ">=6.11.0"
39
+ },
40
+ "gitHead": "4687d65cc52f52aa706e2540faf3b95b3033d3b2"
38
41
  }
package/readme.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- The [`@interopio/iframes-api`](https://www.npmjs.com/package/@interopio/iframes-api) library provides a convenient API for starting applications in iframes.
5
+ The [`@interopio/iframes-api`](https://www.npmjs.com/package/@interopio/iframes-api) library provides a convenient API for starting apps in `<iframe>` elements.
6
6
 
7
7
  ## Installation
8
8
 
@@ -16,6 +16,8 @@ npm install @interopio/iframes-api
16
16
 
17
17
  The following examples demonstrate basic initialization of the `@interopio/iframes-api` library in **io.Connect Browser** projects.
18
18
 
19
+ > ℹ️ *For more details on using the `@interopio/iframes-api` library in **io.Connect Browser** projects, see the **io.Connect Browser** [official documentation](https://docs.interop.io/browser/capabilities/windows/iframes/index.html).*
20
+
19
21
  ### io.Connect Browser
20
22
 
21
23
  Initializing the `@interopio/iframes-api` library in the Main app of an **io.Connect Browser** project:
@@ -50,72 +52,3 @@ const io = await IOBrowser(config);
50
52
 
51
53
  // Now you can access the IFrames API via `io.iframes`.
52
54
  ```
53
-
54
- Using the IFrames API
55
-
56
- ```javascript
57
- // STEP 1 => create a map to store iframe containers by ID
58
- const iframeContainers = {};
59
-
60
- // STEP 2 => register listener for close requests
61
- // onCloseRequested can only listen for iframe instances that are inside the app that registers the listener
62
- const unsubscribe = io.iframes.onCloseRequested(async ({ id }) => {
63
-
64
- // remove the iframe container
65
- iframeContainers[id]?.remove();
66
- delete iframeContainers[id];
67
-
68
- // confirm to the platform that local cleanup is done, so it can remove the iframe and clean up its state
69
- await io.iframes.confirmFrameClosed(id);
70
- });
71
-
72
- // STEP 3 => start the app
73
- const start = async () => {
74
-
75
- // create a container where the iframe will be visualized
76
- const createIFrameContainer = () => {
77
- const container = document.createElement("div");
78
-
79
- container.style.width = "400px";
80
- container.style.height = "300px";
81
- container.style.boxSizing = "border-box";
82
- container.style.border = "1px solid orange";
83
-
84
- container.innerText = "Loading ...";
85
-
86
- document.body.appendChild(container);
87
-
88
- return container;
89
- }
90
-
91
- const iframeContainer = createIFrameContainer();
92
-
93
- // start the app (the returned iframe is automatically attached to document.body)
94
- const { id, iframe } = await io.iframes.openApp({ appName: "simple", context: { ticker: "TMDX" }});
95
-
96
- // store the container so it can be removed when a close request is received
97
- iframeContainers[id] = iframeContainer;
98
-
99
- // position the iframe inside the container
100
- const positionIFrame = (iframe) => {
101
- const { top, left, width, height } = iframeContainer.getBoundingClientRect();
102
-
103
- iframe.style.top = `${top}px`;
104
- iframe.style.left = `${left}px`;
105
- iframe.style.width = `${width}px`;
106
- iframe.style.height = `${height}px`;
107
- };
108
-
109
- iframeContainer.innerText = "";
110
-
111
- positionIFrame(iframe);
112
-
113
-
114
- return { windowId: id, iframe };
115
- };
116
-
117
- const { windowId, iframe } = await start();
118
-
119
- // STEP 4 => close the app
120
- await io.windows.findById(windowId).close();
121
- ```
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 interop.io
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.