MessagesForMacintosh/JS/node_modules/apollo-utilities/lib/bundle.cjs.min.js

2 lines
14 KiB
JavaScript

exports.__esModule=!0,exports.addTypenameToDocument=function(e){return(0,n.visit)(y(e),{SelectionSet:{enter:function(e,n,t){if(!t||"OperationDefinition"!==t.kind){var i=e.selections;if(i){var o=i.some(function(e){return f(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))});if(!o){var a=t;if(!(f(a)&&a.directives&&a.directives.some(function(e){return"export"===e.name.value})))return(0,r.__assign)((0,r.__assign)({},e),{selections:(0,r.__spreadArrays)(i,[_])})}}}}}})},exports.argumentsObjectFromField=s,exports.assign=x,exports.buildQueryFromSelectionSet=function(e){if("query"===k(e).operation)return e;return(0,n.visit)(e,{OperationDefinition:{enter:function(e){return(0,r.__assign)((0,r.__assign)({},e),{operation:"query"})}}})},exports.checkDocument=y,exports.cloneDeep=function(e){return function e(n,t){switch(M.call(n)){case"[object Array]":if(t.has(n))return t.get(n);var r=n.slice(0);return t.set(n,r),r.forEach(function(n,i){r[i]=e(n,t)}),r;case"[object Object]":if(t.has(n))return t.get(n);var i=Object.create(Object.getPrototypeOf(n));return t.set(n,i),Object.keys(n).forEach(function(r){i[r]=e(n[r],t)}),i;default:return n}}(e,new Map)},exports.createFragmentMap=O,exports.getDefaultValues=function(e){if(e&&e.variableDefinitions&&e.variableDefinitions.length){var n=e.variableDefinitions.filter(function(e){var n=e.defaultValue;return n}).map(function(e){var n=e.variable,t=e.defaultValue,r={};return a(r,n.name,t),r});return x.apply(void 0,(0,r.__spreadArrays)([{}],n))}return{}},exports.getDirectiveInfoFromField=function(e,n){if(e.directives&&e.directives.length){var t={};return e.directives.forEach(function(e){t[e.name.value]=s(e,n)}),t}return null},exports.getDirectiveNames=m,exports.getDirectivesFromDocument=function(e,t){var i;return y(t),E((0,n.visit)(t,{SelectionSet:{enter:function(n,t,o,a){var u=a.join("-");if(!i||u===i||!u.startsWith(i)){if(n.selections){var c=n.selections.filter(function(n){return I(e,n)});return w(e,n,!1)&&(i=u),(0,r.__assign)((0,r.__assign)({},n),{selections:c})}return null}}}}))},exports.getEnv=J,exports.getFragmentDefinition=D,exports.getFragmentDefinitions=b,exports.getFragmentQueryDocument=function(e,n){var i=n,o=[];e.definitions.forEach(function(e){if("OperationDefinition"===e.kind)throw new t.InvariantError(11);"FragmentDefinition"===e.kind&&o.push(e)}),void 0===i&&((0,t.invariant)(1===o.length,12),i=o[0].name.value);return(0,r.__assign)((0,r.__assign)({},e),{definitions:(0,r.__spreadArrays)([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:i}}]}}],e.definitions)})},exports.getInclusionDirectives=g,exports.getMainDefinition=k,exports.getMutationDefinition=function(e){y(e);var n=e.definitions.filter(function(e){return"OperationDefinition"===e.kind&&"mutation"===e.operation})[0];return(0,t.invariant)(n,1),n},exports.getOperationDefinition=h,exports.getOperationDefinitionOrDie=function(e){var n=h(e);return(0,t.invariant)(n,5),n},exports.getOperationName=function(e){return e.definitions.filter(function(e){return"OperationDefinition"===e.kind&&e.name}).map(function(e){return e.name.value})[0]||null},exports.getQueryDefinition=function(e){var n=h(e);return(0,t.invariant)(n&&"query"===n.operation,6),n},exports.getStoreKeyName=c,exports.graphQLResultHasError=function(e){return e.errors&&e.errors.length},exports.hasClientExports=function(e){return e&&p(["client"],e)&&p(["export"],e)},exports.hasDirectives=p,exports.isDevelopment=Q,exports.isEnv=P,exports.isField=f,exports.isIdValue=function(e){return e&&"id"===e.type&&"boolean"==typeof e.generated},exports.isInlineFragment=l,exports.isJsonValue=function(e){return null!=e&&"object"==typeof e&&"json"===e.type},exports.isNumberValue=function(e){return["IntValue","FloatValue"].indexOf(e.kind)>-1},exports.isProduction=L,exports.isScalarValue=function(e){return["StringValue","BooleanValue","EnumValue"].indexOf(e.kind)>-1},exports.isTest=T,exports.maybeDeepFreeze=function(e){if(Q()||T()){var n="function"==typeof Symbol&&"string"==typeof Symbol("");if(!n)return function e(n){Object.freeze(n);Object.getOwnPropertyNames(n).forEach(function(t){null===n[t]||"object"!=typeof n[t]&&"function"!=typeof n[t]||Object.isFrozen(n[t])||e(n[t])});return n}(e)}return e},exports.mergeDeep=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return z(e)},exports.mergeDeepArray=z,exports.removeArgumentsFromDocument=N,exports.removeClientSetsFromDocument=function(e){y(e);var t=V([{test:function(e){return"client"===e.name.value},remove:!0}],e);t&&(t=(0,n.visit)(t,{FragmentDefinition:{enter:function(e){if(e.selectionSet){var n=e.selectionSet.selections.every(function(e){return f(e)&&"__typename"===e.name.value});if(n)return null}}}}));return t},exports.removeConnectionDirectiveFromDocument=function(e){return V([j],y(e))},exports.removeDirectivesFromDocument=V,exports.removeFragmentSpreadFromDocument=q,exports.resultKeyNameFromField=function(e){return e.alias?e.alias.value:e.name.value},exports.shouldInclude=function(e,n){void 0===n&&(n={});return g(e.directives).every(function(e){var r=e.directive,i=e.ifArgument,o=!1;return"Variable"===i.value.kind?(o=n[i.value.name.value],(0,t.invariant)(void 0!==o,13)):o=i.value.value,"skip"===r.name.value?!o:o})},exports.storeKeyNameFromField=function(e,n){var t=null;e.directives&&(t={},e.directives.forEach(function(e){t[e.name.value]={},e.arguments&&e.arguments.forEach(function(r){var i=r.name,o=r.value;return a(t[e.name.value],i,o,n)})}));var r=null;e.arguments&&e.arguments.length&&(r={},e.arguments.forEach(function(e){var t=e.name,i=e.value;return a(r,t,i,n)}));return c(e.name.value,r,t)},exports.stripSymbols=function(e){return JSON.parse(JSON.stringify(e))},exports.toIdValue=function(e,n){void 0===n&&(n=!1);return(0,r.__assign)({type:"id",generated:n},"string"==typeof e?{id:e,typename:void 0}:e)},exports.tryFunctionOrLogError=function(e){try{return e()}catch(e){console.error&&console.error(e)}},exports.valueFromNode=function e(n,t){void 0===t&&(t=v);switch(n.kind){case"Variable":return t(n);case"NullValue":return null;case"IntValue":return parseInt(n.value,10);case"FloatValue":return parseFloat(n.value);case"ListValue":return n.values.map(function(n){return e(n,t)});case"ObjectValue":for(var r={},i=0,o=n.fields;i<o.length;i++){var a=o[i];r[a.name.value]=e(a.value,t)}return r;default:return n.value}},exports.valueToObjectRepresentation=a,exports.variablesInOperation=function(e){var n=new Set;if(e.variableDefinitions)for(var t=0,r=e.variableDefinitions;t<r.length;t++){var i=r[t];n.add(i.variable.name.value)}return n},exports.warnOnceInDevelopment=function(e,n){void 0===n&&(n="warn");L()||R[e]||(T()||(R[e]=!0),"error"===n?console.error(e):console.warn(e))},exports.canUseWeakMap=exports.isEqual=void 0;var e,n=require("graphql/language/visitor"),t=require("ts-invariant"),r=require("tslib"),i=(e=require("fast-json-stable-stringify"))&&e.__esModule?e:{default:e},o=require("@wry/equality");function a(e,n,r,i){if(function(e){return"IntValue"===e.kind}(r)||function(e){return"FloatValue"===e.kind}(r))e[n.value]=Number(r.value);else if(function(e){return"BooleanValue"===e.kind}(r)||function(e){return"StringValue"===e.kind}(r))e[n.value]=r.value;else if(function(e){return"ObjectValue"===e.kind}(r)){var o={};r.fields.map(function(e){return a(o,e.name,e.value,i)}),e[n.value]=o}else if(function(e){return"Variable"===e.kind}(r)){var u=(i||{})[r.name.value];e[n.value]=u}else if(function(e){return"ListValue"===e.kind}(r))e[n.value]=r.values.map(function(e){var t={};return a(t,n,e,i),t[n.value]});else if(function(e){return"EnumValue"===e.kind}(r))e[n.value]=r.value;else{if(!function(e){return"NullValue"===e.kind}(r))throw new t.InvariantError(17);e[n.value]=null}}exports.isEqual=o.equal;var u=["connection","include","skip","client","rest","export"];function c(e,n,t){if(t&&t.connection&&t.connection.key){if(t.connection.filter&&t.connection.filter.length>0){var r=t.connection.filter?t.connection.filter:[];r.sort();var o=n,a={};return r.forEach(function(e){a[e]=o[e]}),t.connection.key+"("+JSON.stringify(a)+")"}return t.connection.key}var c=e;if(n){var s=(0,i.default)(n);c+="("+s+")"}return t&&Object.keys(t).forEach(function(e){-1===u.indexOf(e)&&(t[e]&&Object.keys(t[e]).length?c+="@"+e+"("+JSON.stringify(t[e])+")":c+="@"+e)}),c}function s(e,n){if(e.arguments&&e.arguments.length){var t={};return e.arguments.forEach(function(e){var r=e.name,i=e.value;return a(t,r,i,n)}),t}return null}function f(e){return"Field"===e.kind}function l(e){return"InlineFragment"===e.kind}function v(e){throw new t.InvariantError(18)}function m(e){var t=[];return(0,n.visit)(e,{Directive:function(e){t.push(e.name.value)}}),t}function p(e,n){return m(n).some(function(n){return e.indexOf(n)>-1})}function d(e){var n=e.name.value;return"skip"===n||"include"===n}function g(e){return e?e.filter(d).map(function(e){var n=e.arguments;e.name.value;(0,t.invariant)(n&&1===n.length,14);var r=n[0];(0,t.invariant)(r.name&&"if"===r.name.value,15);var i=r.value;return(0,t.invariant)(i&&("Variable"===i.kind||"BooleanValue"===i.kind),16),{directive:e,ifArgument:r}}):[]}function x(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return n.forEach(function(n){null!=n&&Object.keys(n).forEach(function(t){e[t]=n[t]})}),e}function y(e){(0,t.invariant)(e&&"Document"===e.kind,2);var n=e.definitions.filter(function(e){return"FragmentDefinition"!==e.kind}).map(function(e){if("OperationDefinition"!==e.kind)throw new t.InvariantError(3);return e});return(0,t.invariant)(n.length<=1,4),e}function h(e){return y(e),e.definitions.filter(function(e){return"OperationDefinition"===e.kind})[0]}function b(e){return e.definitions.filter(function(e){return"FragmentDefinition"===e.kind})}function D(e){(0,t.invariant)("Document"===e.kind,7),(0,t.invariant)(e.definitions.length<=1,8);var n=e.definitions[0];return(0,t.invariant)("FragmentDefinition"===n.kind,9),n}function k(e){var n;y(e);for(var r=0,i=e.definitions;r<i.length;r++){var o=i[r];if("OperationDefinition"===o.kind){var a=o.operation;if("query"===a||"mutation"===a||"subscription"===a)return o}"FragmentDefinition"!==o.kind||n||(n=o)}if(n)return n;throw new t.InvariantError(10)}function O(e){void 0===e&&(e=[]);var n={};return e.forEach(function(e){n[e.name.value]=e}),n}function F(e,n,t){var r=0;return e.forEach(function(t,i){n.call(this,t,i,e)&&(e[r++]=t)},t),e.length=r,e}var _={kind:"Field",name:{kind:"Name",value:"__typename"}};function E(e){return function e(n,t){return n.selectionSet.selections.every(function(n){return"FragmentSpread"===n.kind&&e(t[n.name.value],t)})}(h(e)||D(e),O(b(e)))?null:e}function S(e){return function(n){return e.some(function(e){return e.name&&e.name===n.name.value||e.test&&e.test(n)})}}function V(e,t){var r=Object.create(null),i=[],o=Object.create(null),a=[],u=E((0,n.visit)(t,{Variable:{enter:function(e,n,t){"VariableDefinition"!==t.kind&&(r[e.name.value]=!0)}},Field:{enter:function(n){if(e&&n.directives&&(e.some(function(e){return e.remove})&&n.directives&&n.directives.some(S(e))))return n.arguments&&n.arguments.forEach(function(e){"Variable"===e.value.kind&&i.push({name:e.value.name.value})}),n.selectionSet&&function e(n){var t=[];n.selections.forEach(function(n){(f(n)||l(n))&&n.selectionSet?e(n.selectionSet).forEach(function(e){return t.push(e)}):"FragmentSpread"===n.kind&&t.push(n)});return t}(n.selectionSet).forEach(function(e){a.push({name:e.name.value})}),null}},FragmentSpread:{enter:function(e){o[e.name.value]=!0}},Directive:{enter:function(n){if(S(e)(n))return null}}}));return u&&F(i,function(e){return!r[e.name]}).length&&(u=N(i,u)),u&&F(a,function(e){return!o[e.name]}).length&&(u=q(a,u)),u}var j={test:function(e){var n="connection"===e.name.value;return n&&(!e.arguments||e.arguments.some(function(e){return"key"===e.name.value})),n}};function w(e,n,t){return void 0===t&&(t=!0),n&&n.selections&&n.selections.some(function(n){return I(e,n,t)})}function I(e,n,t){return void 0===t&&(t=!0),!f(n)||!!n.directives&&(n.directives.some(S(e))||t&&w(e,n.selectionSet,t))}function N(e,t){var i=function(e){return function(n){return e.some(function(e){return n.value&&"Variable"===n.value.kind&&n.value.name&&(e.name===n.value.name.value||e.test&&e.test(n))})}}(e);return E((0,n.visit)(t,{OperationDefinition:{enter:function(n){return(0,r.__assign)((0,r.__assign)({},n),{variableDefinitions:n.variableDefinitions.filter(function(n){return!e.some(function(e){return e.name===n.variable.name.value})})})}},Field:{enter:function(n){if(e.some(function(e){return e.remove})){var t=0;if(n.arguments.forEach(function(e){i(e)&&(t+=1)}),1===t)return null}}},Argument:{enter:function(e){if(i(e))return null}}}))}function q(e,t){function r(n){if(e.some(function(e){return e.name===n.name.value}))return null}return E((0,n.visit)(t,{FragmentSpread:{enter:r},FragmentDefinition:{enter:r}}))}var A="function"==typeof WeakMap&&!("object"==typeof navigator&&"ReactNative"===navigator.product);exports.canUseWeakMap=A;var M=Object.prototype.toString;function J(){return"undefined"!=typeof process?"production":"development"}function P(e){return J()===e}function L(){return!0===P("production")}function Q(){return!0===P("development")}function T(){return!0===P("test")}var W=Object.prototype.hasOwnProperty;function z(e){var n=e[0]||{},t=e.length;if(t>1){var r=[];n=K(n,r);for(var i=1;i<t;++i)n=C(n,e[i],r)}return n}function B(e){return null!==e&&"object"==typeof e}function C(e,n,t){return B(n)&&B(e)?(Object.isExtensible&&!Object.isExtensible(e)&&(e=K(e,t)),Object.keys(n).forEach(function(r){var i=n[r];if(W.call(e,r)){var o=e[r];i!==o&&(e[r]=C(K(o,t),i,t))}else e[r]=i}),e):n}function K(e,n){return null!==e&&"object"==typeof e&&n.indexOf(e)<0&&(e=Array.isArray(e)?e.slice(0):(0,r.__assign)({__proto__:Object.getPrototypeOf(e)},e),n.push(e)),e}var R=Object.create({});