From 9b394e5ecb4142edc28c3ff609d30eaada74c0ef Mon Sep 17 00:00:00 2001 From: Jon Uhlmann Date: Thu, 11 Apr 2024 22:11:33 +0200 Subject: [PATCH] Update: Remove console log --- Resources/Private/Editor/manifest.js | 3 +-- Resources/Public/Plugin.js | 2 +- Resources/Public/Plugin.js.map | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Resources/Private/Editor/manifest.js b/Resources/Private/Editor/manifest.js index 3888b8a..ca04cfa 100644 --- a/Resources/Private/Editor/manifest.js +++ b/Resources/Private/Editor/manifest.js @@ -31,13 +31,12 @@ manifest("Carbon.PreviewMode:Button", {}, (globalRegistry, { frontendConfigurati if (settings === true) { settings = { nodeTypeName: fallbackNodeTypeName, - } + }; } if (!settings?.nodeTypeName) { settings.nodeTypeName = fallbackNodeTypeName; } const position = settings?.position || "start"; - console.log("settings", viewEditModeName, settings); const Button = makeButton({ viewEditModeName, settings, i18nRegistry, nodeTypesRegistry }); containerRegistry.set(`SecondaryToolbar/Right/${viewEditModeName}`, connector(Button), position); } diff --git a/Resources/Public/Plugin.js b/Resources/Public/Plugin.js index 152def5..450e384 100644 --- a/Resources/Public/Plugin.js +++ b/Resources/Public/Plugin.js @@ -1,2 +1,2 @@ -var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __esm=(fn,res)=>function(){return fn&&(res=(0,fn[__getOwnPropNames(fn)[0]])(fn=0)),res};var __commonJS=(cb,mod)=>function(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod));function readFromConsumerApi(key){return(...args)=>{if(window["@Neos:HostPluginAPI"]&&window["@Neos:HostPluginAPI"][`@${key}`])return window["@Neos:HostPluginAPI"][`@${key}`](...args);throw new Error("You are trying to read from a consumer api that hasn't been initialized yet!")}}var init_readFromConsumerApi=__esm({"node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/dist/readFromConsumerApi.js"(){}});var require_react_redux=__commonJS({"node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/dist/shims/vendor/react-redux/index.js"(exports,module){init_readFromConsumerApi();module.exports=readFromConsumerApi("vendor")().reactRedux}});var require_neos_ui_redux_store=__commonJS({"node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/dist/shims/neosProjectPackages/neos-ui-redux-store/index.js"(exports,module){init_readFromConsumerApi();module.exports=readFromConsumerApi("NeosProjectPackages")().NeosUiReduxStore}});var require_react=__commonJS({"node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/dist/shims/vendor/react/index.js"(exports,module){init_readFromConsumerApi();module.exports=readFromConsumerApi("vendor")().React}});var require_react_ui_components=__commonJS({"node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/dist/shims/neosProjectPackages/react-ui-components/index.js"(exports,module){init_readFromConsumerApi();module.exports=readFromConsumerApi("NeosProjectPackages")().ReactUiComponents}});init_readFromConsumerApi();var dist_default=readFromConsumerApi("manifest");var import_react_redux=__toESM(require_react_redux()),import_neos_ui_redux_store=__toESM(require_neos_ui_redux_store());var import_react=__toESM(require_react()),import_react_ui_components=__toESM(require_react_ui_components());function makeButton({viewEditModeName,settings,i18nRegistry,nodeTypesRegistry}){return function({documentNode,editPreviewMode,setEditPreviewMode}){let[shouldRender,setShouldRender]=(0,import_react.useState)(!1),icon=settings?.icon||"fas fa-pencil",label=settings?.label||null,nodeTypeName=settings.nodeTypeName,registry=nodeTypesRegistry?._registry,documentNodeType=documentNode.nodeType;if((0,import_react.useEffect)(()=>{setShouldRender(hasMixin({documentNodeType,nodeTypeName,registry})),shouldRender===!1&&editPreviewMode===viewEditModeName&&setEditPreviewMode("inPlace")},[documentNode]),!shouldRender)return null;let title=label?i18nRegistry.translate(label):null;return import_react.default.createElement(import_react_ui_components.IconButton,{icon,isPressed:editPreviewMode===viewEditModeName,"aria-label":title,title,onClick:()=>{setEditPreviewMode(editPreviewMode===viewEditModeName?"inPlace":viewEditModeName)}})}}function hasMixin({documentNodeType,nodeTypeName,registry}){if(documentNodeType===nodeTypeName)return!0;for(let item of registry){if(item.key!==documentNodeType)continue;let superTypes=item?.value?.superTypes;if(!superTypes)return!1;for(let key in superTypes)if(key==nodeTypeName)return superTypes[key];return!1}return!1}var connector=(0,import_react_redux.connect)(state=>({documentNode:import_neos_ui_redux_store.selectors.CR.Nodes.documentNodeSelector(state),editPreviewMode:import_neos_ui_redux_store.selectors.UI.EditPreviewMode.currentEditPreviewMode(state)}),{setEditPreviewMode:import_neos_ui_redux_store.actions.UI.EditPreviewMode.set});dist_default("Carbon.PreviewMode:Button",{},(globalRegistry,{frontendConfiguration})=>{let configurations=frontendConfiguration["Carbon.PreviewMode:Button"];if(!configurations||typeof configurations!="object")return;let containerRegistry=globalRegistry.get("containers"),i18nRegistry=globalRegistry.get("i18n"),nodeTypesRegistry=globalRegistry.get("@neos-project/neos-ui-contentrepository"),fallbackNodeTypeName="Neos.Neos:Document";for(let viewEditModeName in configurations){let settings=configurations[viewEditModeName];settings===!0&&(settings={nodeTypeName:fallbackNodeTypeName}),settings?.nodeTypeName||(settings.nodeTypeName=fallbackNodeTypeName);let position=settings?.position||"start";console.log("settings",viewEditModeName,settings);let Button=makeButton({viewEditModeName,settings,i18nRegistry,nodeTypesRegistry});containerRegistry.set(`SecondaryToolbar/Right/${viewEditModeName}`,connector(Button),position)}}); +var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __esm=(fn,res)=>function(){return fn&&(res=(0,fn[__getOwnPropNames(fn)[0]])(fn=0)),res};var __commonJS=(cb,mod)=>function(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod));function readFromConsumerApi(key){return(...args)=>{if(window["@Neos:HostPluginAPI"]&&window["@Neos:HostPluginAPI"][`@${key}`])return window["@Neos:HostPluginAPI"][`@${key}`](...args);throw new Error("You are trying to read from a consumer api that hasn't been initialized yet!")}}var init_readFromConsumerApi=__esm({"node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/dist/readFromConsumerApi.js"(){}});var require_react_redux=__commonJS({"node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/dist/shims/vendor/react-redux/index.js"(exports,module){init_readFromConsumerApi();module.exports=readFromConsumerApi("vendor")().reactRedux}});var require_neos_ui_redux_store=__commonJS({"node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/dist/shims/neosProjectPackages/neos-ui-redux-store/index.js"(exports,module){init_readFromConsumerApi();module.exports=readFromConsumerApi("NeosProjectPackages")().NeosUiReduxStore}});var require_react=__commonJS({"node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/dist/shims/vendor/react/index.js"(exports,module){init_readFromConsumerApi();module.exports=readFromConsumerApi("vendor")().React}});var require_react_ui_components=__commonJS({"node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/dist/shims/neosProjectPackages/react-ui-components/index.js"(exports,module){init_readFromConsumerApi();module.exports=readFromConsumerApi("NeosProjectPackages")().ReactUiComponents}});init_readFromConsumerApi();var dist_default=readFromConsumerApi("manifest");var import_react_redux=__toESM(require_react_redux()),import_neos_ui_redux_store=__toESM(require_neos_ui_redux_store());var import_react=__toESM(require_react()),import_react_ui_components=__toESM(require_react_ui_components());function makeButton({viewEditModeName,settings,i18nRegistry,nodeTypesRegistry}){return function({documentNode,editPreviewMode,setEditPreviewMode}){let[shouldRender,setShouldRender]=(0,import_react.useState)(!1),icon=settings?.icon||"fas fa-pencil",label=settings?.label||null,nodeTypeName=settings.nodeTypeName,registry=nodeTypesRegistry?._registry,documentNodeType=documentNode.nodeType;if((0,import_react.useEffect)(()=>{setShouldRender(hasMixin({documentNodeType,nodeTypeName,registry})),shouldRender===!1&&editPreviewMode===viewEditModeName&&setEditPreviewMode("inPlace")},[documentNode]),!shouldRender)return null;let title=label?i18nRegistry.translate(label):null;return import_react.default.createElement(import_react_ui_components.IconButton,{icon,isPressed:editPreviewMode===viewEditModeName,"aria-label":title,title,onClick:()=>{setEditPreviewMode(editPreviewMode===viewEditModeName?"inPlace":viewEditModeName)}})}}function hasMixin({documentNodeType,nodeTypeName,registry}){if(documentNodeType===nodeTypeName)return!0;for(let item of registry){if(item.key!==documentNodeType)continue;let superTypes=item?.value?.superTypes;if(!superTypes)return!1;for(let key in superTypes)if(key==nodeTypeName)return superTypes[key];return!1}return!1}var connector=(0,import_react_redux.connect)(state=>({documentNode:import_neos_ui_redux_store.selectors.CR.Nodes.documentNodeSelector(state),editPreviewMode:import_neos_ui_redux_store.selectors.UI.EditPreviewMode.currentEditPreviewMode(state)}),{setEditPreviewMode:import_neos_ui_redux_store.actions.UI.EditPreviewMode.set});dist_default("Carbon.PreviewMode:Button",{},(globalRegistry,{frontendConfiguration})=>{let configurations=frontendConfiguration["Carbon.PreviewMode:Button"];if(!configurations||typeof configurations!="object")return;let containerRegistry=globalRegistry.get("containers"),i18nRegistry=globalRegistry.get("i18n"),nodeTypesRegistry=globalRegistry.get("@neos-project/neos-ui-contentrepository"),fallbackNodeTypeName="Neos.Neos:Document";for(let viewEditModeName in configurations){let settings=configurations[viewEditModeName];settings===!0&&(settings={nodeTypeName:fallbackNodeTypeName}),settings?.nodeTypeName||(settings.nodeTypeName=fallbackNodeTypeName);let position=settings?.position||"start",Button=makeButton({viewEditModeName,settings,i18nRegistry,nodeTypesRegistry});containerRegistry.set(`SecondaryToolbar/Right/${viewEditModeName}`,connector(Button),position)}}); //# sourceMappingURL=Plugin.js.map diff --git a/Resources/Public/Plugin.js.map b/Resources/Public/Plugin.js.map index 11f6142..e1a6d2b 100644 --- a/Resources/Public/Plugin.js.map +++ b/Resources/Public/Plugin.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/src/readFromConsumerApi.ts", "../../node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/src/shims/vendor/react-redux/index.js", "../../node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/src/shims/neosProjectPackages/neos-ui-redux-store/index.js", "../../node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/src/shims/vendor/react/index.js", "../../node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/src/shims/neosProjectPackages/react-ui-components/index.js", "../../node_modules/.pnpm/@neos-project+neos-ui-extensibility@8.3.7/node_modules/@neos-project/neos-ui-extensibility/src/index.ts", "../Private/Editor/manifest.js", "../Private/Editor/makeButton.tsx"], - "sourcesContent": [null, null, null, null, null, null, "import manifest from \"@neos-project/neos-ui-extensibility\";\nimport { connect } from \"react-redux\";\nimport { actions, selectors } from \"@neos-project/neos-ui-redux-store\";\nimport makeButton from \"./makeButton\";\n\nconst connector = connect(\n (state) => {\n return {\n documentNode: selectors.CR.Nodes.documentNodeSelector(state),\n editPreviewMode: selectors.UI.EditPreviewMode.currentEditPreviewMode(state),\n };\n },\n {\n setEditPreviewMode: actions.UI.EditPreviewMode.set,\n },\n);\n\nmanifest(\"Carbon.PreviewMode:Button\", {}, (globalRegistry, { frontendConfiguration }) => {\n const configurations = frontendConfiguration[\"Carbon.PreviewMode:Button\"];\n\n if (!configurations || typeof configurations !== \"object\") {\n return;\n }\n const containerRegistry = globalRegistry.get(\"containers\");\n const i18nRegistry = globalRegistry.get(\"i18n\");\n const nodeTypesRegistry = globalRegistry.get(\"@neos-project/neos-ui-contentrepository\");\n const fallbackNodeTypeName = \"Neos.Neos:Document\";\n\n for (const viewEditModeName in configurations) {\n let settings = configurations[viewEditModeName];\n if (settings === true) {\n settings = {\n nodeTypeName: fallbackNodeTypeName,\n }\n }\n if (!settings?.nodeTypeName) {\n settings.nodeTypeName = fallbackNodeTypeName;\n }\n const position = settings?.position || \"start\";\n console.log(\"settings\", viewEditModeName, settings);\n const Button = makeButton({ viewEditModeName, settings, i18nRegistry, nodeTypesRegistry });\n containerRegistry.set(`SecondaryToolbar/Right/${viewEditModeName}`, connector(Button), position);\n }\n});\n", "import React, { useEffect, useState } from \"react\";\nimport { IconButton } from \"@neos-project/react-ui-components\";\n\nexport default function makeButton({ viewEditModeName, settings, i18nRegistry, nodeTypesRegistry }) {\n return function Button({documentNode, editPreviewMode, setEditPreviewMode }) {\n const [shouldRender, setShouldRender] = useState(false);\n const icon = settings?.icon || \"fas fa-pencil\";\n const label = settings?.label || null;\n const nodeTypeName = settings.nodeTypeName;\n const registry = nodeTypesRegistry?._registry;\n const documentNodeType = documentNode.nodeType;\n\n useEffect(() => {\n // nodeTypesRegistry.isOfType(documentNode.nodeType, nodeTypeName) doesn't return superTypes\n // so we need to implement our own function to check if the node has the mixin\n setShouldRender(hasMixin({ documentNodeType, nodeTypeName, registry }));\n\n // this will cause the current page to reload, but it's a protection\n // mechanism prevent this mode to be activated on page that has not this node type\n if (shouldRender === false && editPreviewMode === viewEditModeName) {\n setEditPreviewMode(\"inPlace\");\n }\n }, [documentNode]);\n\n if (!shouldRender) {\n return null;\n }\n\n const title = label ? i18nRegistry.translate(label) : null;\n\n return (\n {\n setEditPreviewMode(editPreviewMode === viewEditModeName ? \"inPlace\" : viewEditModeName);\n }}\n />\n );\n };\n}\n\nfunction hasMixin({ documentNodeType, nodeTypeName, registry }) {\n if (documentNodeType === nodeTypeName) {\n return true;\n }\n for (const item of registry) {\n if (item.key !== documentNodeType) {\n continue;\n }\n const superTypes = item?.value?.superTypes;\n if (!superTypes) {\n return false;\n }\n for (const key in superTypes) {\n if (key == nodeTypeName) {\n return superTypes[key];\n }\n }\n return false;\n }\n return false;\n}\n"], - "mappings": "27BAAc,SAAP,oBAAqC,IAAW,CACnD,MAAO,IAAI,OAAe,CACtB,GAAK,OAAe,qBAAqB,GAAM,OAAe,qBAAqB,EAAE,IAAI,GAAG,EAAE,EAC1F,OAAQ,OAAe,qBAAqB,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,IAAI,EAGpE,MAAM,IAAI,MAAM,8EAA+E,CACnG,CACJ,CARA,sLCAA,sOAEA,OAAO,QAAU,oBAAoB,QAAQ,EAAC,EAAG,cCFjD,mQAEA,OAAO,QAAU,oBAAoB,qBAAqB,EAAC,EAAG,oBCF9D,0NA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G,MAAM,qBAAqB,KAAK,EAC3D,gBAAiB,qCAAU,GAAG,gBAAgB,uBAAuB,KAAK,CAC9E,GAEJ,CACI,mBAAoB,mCAAQ,GAAG,gBAAgB,GACnD,CACJ,EAEA,aAAS,4BAA6B,CAAC,EAAG,CAAC,eAAgB,CAAE,qBAAsB,IAAM,CACrF,IAAM,eAAiB,sBAAsB,2BAA2B,EAExE,GAAI,CAAC,gBAAkB,OAAO,gBAAmB,SAC7C,OAEJ,IAAM,kBAAoB,eAAe,IAAI,YAAY,EACnD,aAAe,eAAe,IAAI,MAAM,EACxC,kBAAoB,eAAe,IAAI,yCAAyC,EAChF,qBAAuB,qBAE7B,QAAW,oBAAoB,eAAgB,CAC3C,IAAI,SAAW,eAAe,gBAAgB,EAC1C,WAAa,KACb,SAAW,CACP,aAAc,oBAClB,GAEC,UAAU,eACX,SAAS,aAAe,sBAE5B,IAAM,SAAW,UAAU,UAAY,QACvC,QAAQ,IAAI,WAAY,iBAAkB,QAAQ,EAClD,IAAM,OAAS,WAAW,CAAE,iBAAkB,SAAU,aAAc,iBAAkB,CAAC,EACzF,kBAAkB,IAAI,0BAA0B,gBAAgB,GAAI,UAAU,MAAM,EAAG,QAAQ,CACnG,CACJ,CAAC", + "sourcesContent": [null, null, null, null, null, null, "import manifest from \"@neos-project/neos-ui-extensibility\";\nimport { connect } from \"react-redux\";\nimport { actions, selectors } from \"@neos-project/neos-ui-redux-store\";\nimport makeButton from \"./makeButton\";\n\nconst connector = connect(\n (state) => {\n return {\n documentNode: selectors.CR.Nodes.documentNodeSelector(state),\n editPreviewMode: selectors.UI.EditPreviewMode.currentEditPreviewMode(state),\n };\n },\n {\n setEditPreviewMode: actions.UI.EditPreviewMode.set,\n },\n);\n\nmanifest(\"Carbon.PreviewMode:Button\", {}, (globalRegistry, { frontendConfiguration }) => {\n const configurations = frontendConfiguration[\"Carbon.PreviewMode:Button\"];\n\n if (!configurations || typeof configurations !== \"object\") {\n return;\n }\n const containerRegistry = globalRegistry.get(\"containers\");\n const i18nRegistry = globalRegistry.get(\"i18n\");\n const nodeTypesRegistry = globalRegistry.get(\"@neos-project/neos-ui-contentrepository\");\n const fallbackNodeTypeName = \"Neos.Neos:Document\";\n\n for (const viewEditModeName in configurations) {\n let settings = configurations[viewEditModeName];\n if (settings === true) {\n settings = {\n nodeTypeName: fallbackNodeTypeName,\n };\n }\n if (!settings?.nodeTypeName) {\n settings.nodeTypeName = fallbackNodeTypeName;\n }\n const position = settings?.position || \"start\";\n const Button = makeButton({ viewEditModeName, settings, i18nRegistry, nodeTypesRegistry });\n containerRegistry.set(`SecondaryToolbar/Right/${viewEditModeName}`, connector(Button), position);\n }\n});\n", "import React, { useEffect, useState } from \"react\";\nimport { IconButton } from \"@neos-project/react-ui-components\";\n\nexport default function makeButton({ viewEditModeName, settings, i18nRegistry, nodeTypesRegistry }) {\n return function Button({ documentNode, editPreviewMode, setEditPreviewMode }) {\n const [shouldRender, setShouldRender] = useState(false);\n const icon = settings?.icon || \"fas fa-pencil\";\n const label = settings?.label || null;\n const nodeTypeName = settings.nodeTypeName;\n const registry = nodeTypesRegistry?._registry;\n const documentNodeType = documentNode.nodeType;\n\n useEffect(() => {\n // nodeTypesRegistry.isOfType(documentNode.nodeType, nodeTypeName) doesn't return superTypes\n // so we need to implement our own function to check if the node has the mixin\n setShouldRender(hasMixin({ documentNodeType, nodeTypeName, registry }));\n\n // this will cause the current page to reload, but it's a protection\n // mechanism prevent this mode to be activated on page that has not this node type\n if (shouldRender === false && editPreviewMode === viewEditModeName) {\n setEditPreviewMode(\"inPlace\");\n }\n }, [documentNode]);\n\n if (!shouldRender) {\n return null;\n }\n\n const title = label ? i18nRegistry.translate(label) : null;\n\n return (\n {\n setEditPreviewMode(editPreviewMode === viewEditModeName ? \"inPlace\" : viewEditModeName);\n }}\n />\n );\n };\n}\n\nfunction hasMixin({ documentNodeType, nodeTypeName, registry }) {\n if (documentNodeType === nodeTypeName) {\n return true;\n }\n for (const item of registry) {\n if (item.key !== documentNodeType) {\n continue;\n }\n const superTypes = item?.value?.superTypes;\n if (!superTypes) {\n return false;\n }\n for (const key in superTypes) {\n if (key == nodeTypeName) {\n return superTypes[key];\n }\n }\n return false;\n }\n return false;\n}\n"], + "mappings": "27BAAc,SAAP,oBAAqC,IAAW,CACnD,MAAO,IAAI,OAAe,CACtB,GAAK,OAAe,qBAAqB,GAAM,OAAe,qBAAqB,EAAE,IAAI,GAAG,EAAE,EAC1F,OAAQ,OAAe,qBAAqB,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,IAAI,EAGpE,MAAM,IAAI,MAAM,8EAA+E,CACnG,CACJ,CARA,sLCAA,sOAEA,OAAO,QAAU,oBAAoB,QAAQ,EAAC,EAAG,cCFjD,mQAEA,OAAO,QAAU,oBAAoB,qBAAqB,EAAC,EAAG,oBCF9D,0NAEA,OAAO,QAAU,oBAAoB,QAAQ,EAAC,EAAG,SCFjD,mQAEA,OAAO,QAAU,oBAAoB,qBAAqB,EAAC,EAAG,qBCD9D,2BAMA,IAAA,aAAe,oBAAoB,UAAU,ECN7C,uBAAwB,+BACxB,2BAAmC,uCCFnC,iBAA2C,yBAC3C,2BAA2B,uCAEZ,SAAR,WAA4B,CAAE,iBAAkB,SAAU,aAAc,iBAAkB,EAAG,CAChG,OAAO,SAAgB,CAAE,aAAc,gBAAiB,kBAAmB,EAAG,CAC1E,GAAM,CAAC,aAAc,eAAe,KAAI,uBAAS,EAAK,EAChD,KAAO,UAAU,MAAQ,gBACzB,MAAQ,UAAU,OAAS,KAC3B,aAAe,SAAS,aACxB,SAAW,mBAAmB,UAC9B,iBAAmB,aAAa,SActC,MAZA,wBAAU,IAAM,CAGZ,gBAAgB,SAAS,CAAE,iBAAkB,aAAc,QAAS,CAAC,CAAC,EAIlE,eAAiB,IAAS,kBAAoB,kBAC9C,mBAAmB,SAAS,CAEpC,EAAG,CAAC,YAAY,CAAC,EAEb,CAAC,aACD,OAAO,KAGX,IAAM,MAAQ,MAAQ,aAAa,UAAU,KAA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