@reddb-io/ui 0.1.1
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.
- package/LICENSE +17 -0
- package/bin/red-ui.js +259 -0
- package/build/CNAME +1 -0
- package/build/_app/env.js +1 -0
- package/build/_app/immutable/assets/0.C63jY5jX.css +1 -0
- package/build/_app/immutable/assets/10.Dblyk0Kr.css +1 -0
- package/build/_app/immutable/assets/EmptyState.RXcH7ryE.css +1 -0
- package/build/_app/immutable/assets/Workspace.BCzG1DsH.css +1 -0
- package/build/_app/immutable/assets/inter-cyrillic-ext-wght-normal.BOeWTOD4.woff2 +0 -0
- package/build/_app/immutable/assets/inter-cyrillic-wght-normal.DqGufNeO.woff2 +0 -0
- package/build/_app/immutable/assets/inter-greek-ext-wght-normal.DlzME5K_.woff2 +0 -0
- package/build/_app/immutable/assets/inter-greek-wght-normal.CkhJZR-_.woff2 +0 -0
- package/build/_app/immutable/assets/inter-latin-ext-wght-normal.DO1Apj_S.woff2 +0 -0
- package/build/_app/immutable/assets/inter-latin-wght-normal.Dx4kXJAl.woff2 +0 -0
- package/build/_app/immutable/assets/inter-vietnamese-wght-normal.CBcvBZtf.woff2 +0 -0
- package/build/_app/immutable/assets/jetbrains-mono-cyrillic-wght-normal.D73BlboJ.woff2 +0 -0
- package/build/_app/immutable/assets/jetbrains-mono-greek-wght-normal.Bw9x6K1M.woff2 +0 -0
- package/build/_app/immutable/assets/jetbrains-mono-latin-ext-wght-normal.DBQx-q_a.woff2 +0 -0
- package/build/_app/immutable/assets/jetbrains-mono-latin-wght-normal.B9CIFXIH.woff2 +0 -0
- package/build/_app/immutable/assets/jetbrains-mono-vietnamese-wght-normal.Bt-aOZkq.woff2 +0 -0
- package/build/_app/immutable/chunks/3j4cZ58b.js +1 -0
- package/build/_app/immutable/chunks/69_IOA4Y.js +1 -0
- package/build/_app/immutable/chunks/ALqaDrNQ.js +2 -0
- package/build/_app/immutable/chunks/BGcIe2ep.js +2 -0
- package/build/_app/immutable/chunks/BMHKbvs8.js +1 -0
- package/build/_app/immutable/chunks/BQHbwf54.js +916 -0
- package/build/_app/immutable/chunks/Bgso8cDH.js +311 -0
- package/build/_app/immutable/chunks/Bmgx1mfv.js +310 -0
- package/build/_app/immutable/chunks/BrvvOVaJ.js +1 -0
- package/build/_app/immutable/chunks/Bzak7iHL.js +1 -0
- package/build/_app/immutable/chunks/D9CTkMjK.js +1 -0
- package/build/_app/immutable/chunks/DIeogL5L.js +1 -0
- package/build/_app/immutable/chunks/DXY_Rxa7.js +113 -0
- package/build/_app/immutable/chunks/DhEqZVGG.js +1 -0
- package/build/_app/immutable/chunks/Ov8N-vxt.js +1 -0
- package/build/_app/immutable/chunks/oiO4RLqp.js +1 -0
- package/build/_app/immutable/entry/app.D_IVtpdv.js +2 -0
- package/build/_app/immutable/entry/start.3oC0UQ_Q.js +1 -0
- package/build/_app/immutable/nodes/0.CHPiFxDo.js +1 -0
- package/build/_app/immutable/nodes/1.BC_4YZ0h.js +1 -0
- package/build/_app/immutable/nodes/10.B7DMKSNc.js +60 -0
- package/build/_app/immutable/nodes/2.CAG5_cGP.js +1 -0
- package/build/_app/immutable/nodes/3.CAG5_cGP.js +1 -0
- package/build/_app/immutable/nodes/4.CAG5_cGP.js +1 -0
- package/build/_app/immutable/nodes/5.CAG5_cGP.js +1 -0
- package/build/_app/immutable/nodes/6.CAG5_cGP.js +1 -0
- package/build/_app/immutable/nodes/7.BZX9Iird.js +134 -0
- package/build/_app/immutable/nodes/8.CAG5_cGP.js +1 -0
- package/build/_app/immutable/nodes/9.CAG5_cGP.js +1 -0
- package/build/_app/version.json +1 -0
- package/build/favicon.png +0 -0
- package/build/index.html +59 -0
- package/dist/embed/RedUiEmbedRoot-BGoLxJf1.js +26562 -0
- package/dist/embed/RedUiEmbedRoot-BGoLxJf1.js.map +1 -0
- package/dist/embed/bundle-mjs-UuVRz3O4.js +3047 -0
- package/dist/embed/bundle-mjs-UuVRz3O4.js.map +1 -0
- package/dist/embed/core-QuRYvMt8.js +118 -0
- package/dist/embed/core-QuRYvMt8.js.map +1 -0
- package/dist/embed/index-B6ZQhCsu.js +577 -0
- package/dist/embed/index-B6ZQhCsu.js.map +1 -0
- package/dist/embed/index-client-ItCEU64C.js +3087 -0
- package/dist/embed/index-client-ItCEU64C.js.map +1 -0
- package/dist/embed/index-fad77a13.esm-BqPj0saH.js +1318 -0
- package/dist/embed/index-fad77a13.esm-BqPj0saH.js.map +1 -0
- package/dist/embed/index.js +11 -0
- package/dist/embed/index.js.map +1 -0
- package/dist/embed/sigma-node-border.esm-CGtlgqmo.js +432 -0
- package/dist/embed/sigma-node-border.esm-CGtlgqmo.js.map +1 -0
- package/dist/embed/sigma.esm-y0qgY-OC.js +2355 -0
- package/dist/embed/sigma.esm-y0qgY-OC.js.map +1 -0
- package/dist/embed/ui.css +1 -0
- package/package.json +101 -0
- package/src/app.css +238 -0
- package/src/lib/ActivityIndicator.svelte +100 -0
- package/src/lib/ClusterNode.svelte +119 -0
- package/src/lib/ClusterView.svelte +541 -0
- package/src/lib/CollectionHistory.svelte +266 -0
- package/src/lib/CollectionsView.svelte +14 -0
- package/src/lib/CommandPalette.svelte +237 -0
- package/src/lib/ConnectDropdown.svelte +222 -0
- package/src/lib/EmptyState.svelte +27 -0
- package/src/lib/LiveChanges.svelte +195 -0
- package/src/lib/MasterPasswordDialog.svelte +168 -0
- package/src/lib/PageHeader.svelte +32 -0
- package/src/lib/PendingChangesPanel.svelte +153 -0
- package/src/lib/QueryEditor.svelte +122 -0
- package/src/lib/ResultsPane.svelte +747 -0
- package/src/lib/SchemaTree.svelte +193 -0
- package/src/lib/SecurityView.svelte +255 -0
- package/src/lib/ShortcutOverlay.svelte +104 -0
- package/src/lib/Splash.svelte +46 -0
- package/src/lib/StatusBar.svelte +163 -0
- package/src/lib/SubNav.svelte +62 -0
- package/src/lib/Topbar.svelte +119 -0
- package/src/lib/Workspace.svelte +247 -0
- package/src/lib/activity.svelte.ts +91 -0
- package/src/lib/build-info.ts +41 -0
- package/src/lib/capability.ts +221 -0
- package/src/lib/cn.ts +6 -0
- package/src/lib/collection-catalog.ts +116 -0
- package/src/lib/collection-pages.ts +33 -0
- package/src/lib/connection-history.ts +301 -0
- package/src/lib/connections.svelte.ts +493 -0
- package/src/lib/embed/RedUiEmbedRoot.svelte +31 -0
- package/src/lib/embed/index.ts +234 -0
- package/src/lib/graph-loader/contract.ts +336 -0
- package/src/lib/graph-loader/drilldown.ts +334 -0
- package/src/lib/graph-loader/index.ts +13 -0
- package/src/lib/index.ts +114 -0
- package/src/lib/pending-changes.svelte.ts +149 -0
- package/src/lib/query-tabs.svelte.ts +130 -0
- package/src/lib/reddb/boot-params.ts +254 -0
- package/src/lib/reddb/cdc-stream-client.ts +234 -0
- package/src/lib/reddb/client.ts +698 -0
- package/src/lib/reddb/connection-bootstrap.ts +260 -0
- package/src/lib/reddb/connection-provider.contract.ts +72 -0
- package/src/lib/reddb/connection-provider.ts +72 -0
- package/src/lib/reddb/index.ts +14 -0
- package/src/lib/reddb/injected-client-provider.ts +76 -0
- package/src/lib/reddb/local-url-provider.ts +245 -0
- package/src/lib/reddb/secure-store.ts +41 -0
- package/src/lib/reddb/server-capabilities.ts +71 -0
- package/src/lib/reddb/tauri-encrypted-store.ts +64 -0
- package/src/lib/reddb/transports.ts +89 -0
- package/src/lib/reddb/types.ts +32 -0
- package/src/lib/reddb/uri.ts +54 -0
- package/src/lib/reddb/web-encrypted-store.ts +201 -0
- package/src/lib/renderers/DiffRenderer.svelte +184 -0
- package/src/lib/renderers/DocumentRenderer.svelte +134 -0
- package/src/lib/renderers/GraphRenderer.svelte +1328 -0
- package/src/lib/renderers/HypertableRenderer.svelte +253 -0
- package/src/lib/renderers/JsonRenderer.svelte +30 -0
- package/src/lib/renderers/KvRenderer.svelte +150 -0
- package/src/lib/renderers/QueueRenderer.svelte +286 -0
- package/src/lib/renderers/StatsRenderer.svelte +123 -0
- package/src/lib/renderers/TableRenderer.svelte +440 -0
- package/src/lib/renderers/VectorRenderer.svelte +388 -0
- package/src/lib/renderers/diff-render.ts +122 -0
- package/src/lib/renderers/diff.ts +9 -0
- package/src/lib/renderers/document-render.ts +64 -0
- package/src/lib/renderers/document.ts +9 -0
- package/src/lib/renderers/graph-render.ts +631 -0
- package/src/lib/renderers/graph-sigma.ts +395 -0
- package/src/lib/renderers/graph.ts +9 -0
- package/src/lib/renderers/hypertable-render.ts +320 -0
- package/src/lib/renderers/hypertable.ts +9 -0
- package/src/lib/renderers/index.ts +42 -0
- package/src/lib/renderers/json-render.ts +89 -0
- package/src/lib/renderers/json.ts +10 -0
- package/src/lib/renderers/kv-render.ts +193 -0
- package/src/lib/renderers/kv.ts +9 -0
- package/src/lib/renderers/queue-render.ts +197 -0
- package/src/lib/renderers/queue.ts +9 -0
- package/src/lib/renderers/registry.ts +68 -0
- package/src/lib/renderers/stats-render.ts +73 -0
- package/src/lib/renderers/stats.ts +9 -0
- package/src/lib/renderers/table-render.ts +156 -0
- package/src/lib/renderers/table.ts +11 -0
- package/src/lib/renderers/types.ts +33 -0
- package/src/lib/renderers/vector-render.ts +154 -0
- package/src/lib/renderers/vector.ts +9 -0
- package/src/lib/router.svelte.ts +163 -0
- package/src/lib/secureStore.svelte.ts +148 -0
- package/src/lib/shadow-dom-spike/ShadowDomSpikeCore.svelte +198 -0
- package/src/lib/shadow-dom-spike/mount-shadow-dom-spike.ts +94 -0
- package/src/lib/shortcuts.ts +22 -0
- package/src/lib/surface.ts +80 -0
- package/src/lib/tabs.svelte.ts +115 -0
- package/src/lib/theme.svelte.ts +63 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
function Ee(e,r){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var t=n.call(e,r);if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function re(e){var r=Ee(e,"string");return typeof r=="symbol"?r:r+""}function F(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function Y(e,r){for(var n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,re(t.key),t)}}function S(e,r,n){return r&&Y(e.prototype,r),n&&Y(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function k(e){return k=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},k(e)}function ne(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ne=function(){return!!e})()}function ge(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Re(e,r){if(r&&(typeof r=="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ge(e)}function O(e,r,n){return r=k(r),Re(e,ne()?Reflect.construct(r,n||[],k(e).constructor):r.apply(e,n))}function H(e,r){return H=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,t){return n.__proto__=t,n},H(e,r)}function D(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&H(e,r)}function be(e){if(Array.isArray(e))return e}function Ae(e,r){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var t,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,r===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(t=o.call(n)).done)&&(s.push(t.value),s.length!==r);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function $(e,r){(r==null||r>e.length)&&(r=e.length);for(var n=0,t=Array(r);n<r;n++)t[n]=e[n];return t}function ye(e,r){if(e){if(typeof e=="string")return $(e,r);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$(e,r):void 0}}function pe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Fe(e,r){return be(e)||Ae(e,r)||ye(e,r)||pe()}var U={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},ie=new Int8Array(4),G=new Int32Array(ie.buffer,0,1),te=new Float32Array(ie.buffer,0,1),Se=/^\s*rgba?\s*\(/,Ce=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function we(e){var r=0,n=0,t=0,i=1;if(e[0]==="#")e.length===4?(r=parseInt(e.charAt(1)+e.charAt(1),16),n=parseInt(e.charAt(2)+e.charAt(2),16),t=parseInt(e.charAt(3)+e.charAt(3),16)):(r=parseInt(e.charAt(1)+e.charAt(2),16),n=parseInt(e.charAt(3)+e.charAt(4),16),t=parseInt(e.charAt(5)+e.charAt(6),16)),e.length===9&&(i=parseInt(e.charAt(7)+e.charAt(8),16)/255);else if(Se.test(e)){var o=e.match(Ce);o&&(r=+o[1],n=+o[2],t=+o[3],o[4]&&(i=+o[4]))}return{r,g:n,b:t,a:i}}var w={};for(var P in U)w[P]=L(U[P]),w[U[P]]=w[P];function oe(e,r,n,t,i){return G[0]=t<<24|n<<16|r<<8|e,G[0]=G[0]&4278190079,te[0]}function L(e){if(e=e.toLowerCase(),typeof w[e]<"u")return w[e];var r=we(e),n=r.r,t=r.g,i=r.b,o=r.a;o=o*255|0;var a=oe(n,t,i,o);return w[e]=a,a}function tr(e,r){te[0]=L(e);var n=G[0],t=n&255,i=n>>8&255,o=n>>16&255,a=n>>24&255;return[t,i,o,a]}var z={};function ae(e){if(typeof z[e]<"u")return z[e];var r=(e&16711680)>>>16,n=(e&65280)>>>8,t=e&255,i=255,o=oe(r,n,t,i);return z[e]=o,o}function or(e,r,n,t){return n+(r<<8)+(e<<16)}function ar(e,r,n,t,i,o){var a=Math.floor(n/o*i),s=Math.floor(e.drawingBufferHeight/o-t/o*i),l=new Uint8Array(4);e.bindFramebuffer(e.FRAMEBUFFER,r),e.readPixels(a,s,1,1,e.RGBA,e.UNSIGNED_BYTE,l);var u=Fe(l,4),c=u[0],h=u[1],_=u[2],d=u[3];return[c,h,_,d]}function R(e,r,n){return(r=re(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function X(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,t)}return n}function N(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?X(Object(n),!0).forEach(function(t){R(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):X(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ke(e,r){for(;!{}.hasOwnProperty.call(e,r)&&(e=k(e))!==null;);return e}function V(){return V=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,r,n){var t=ke(e,r);if(t){var i=Object.getOwnPropertyDescriptor(t,r);return i.get?i.get.call(arguments.length<3?e:n):i.value}},V.apply(null,arguments)}function se(e,r,n,t){var i=V(k(e.prototype),r,n);return typeof i=="function"?function(o){return i.apply(n,o)}:i}function Ne(e){return e.normalized?1:e.size}function x(e){var r=0;return e.forEach(function(n){return r+=Ne(n)}),r}function le(e,r,n){var t=e==="VERTEX"?r.VERTEX_SHADER:r.FRAGMENT_SHADER,i=r.createShader(t);if(i===null)throw new Error("loadShader: error while creating the shader");r.shaderSource(i,n),r.compileShader(i);var o=r.getShaderParameter(i,r.COMPILE_STATUS);if(!o){var a=r.getShaderInfoLog(i);throw r.deleteShader(i),new Error(`loadShader: error while compiling the shader:
|
|
3
|
+
`.concat(a,`
|
|
4
|
+
`).concat(n))}return i}function Oe(e,r){return le("VERTEX",e,r)}function De(e,r){return le("FRAGMENT",e,r)}function Le(e,r){var n=e.createProgram();if(n===null)throw new Error("loadProgram: error while creating the program.");var t,i;for(t=0,i=r.length;t<i;t++)e.attachShader(n,r[t]);e.linkProgram(n);var o=e.getProgramParameter(n,e.LINK_STATUS);if(!o){var a=e.getProgramInfoLog(n);throw e.deleteProgram(n),new Error("loadProgram: error while linking the program: ".concat(a))}return n}function q(e){var r=e.gl,n=e.buffer,t=e.program,i=e.vertexShader,o=e.fragmentShader;r.deleteShader(i),r.deleteShader(o),r.deleteProgram(t),r.deleteBuffer(n)}function sr(e){return e%1===0?e.toFixed(1):e.toString()}var K=`#define PICKING_MODE
|
|
5
|
+
`,Ie=R(R(R(R(R(R(R(R({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4),ue=(function(){function e(r,n,t){F(this,e),R(this,"array",new Float32Array),R(this,"constantArray",new Float32Array),R(this,"capacity",0),R(this,"verticesCount",0);var i=this.getDefinition();if(this.VERTICES=i.VERTICES,this.VERTEX_SHADER_SOURCE=i.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=i.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=i.UNIFORMS,this.ATTRIBUTES=i.ATTRIBUTES,this.METHOD=i.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in i?i.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in i?i.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in i,this.ATTRIBUTES_ITEMS_COUNT=x(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=t,this.normalProgram=this.getProgramInfo("normal",r,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo("pick",r,K+i.VERTEX_SHADER_SOURCE,K+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=x(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error("Program: error while getting constant data (expected ".concat(this.VERTICES," items, received ").concat(this.CONSTANT_DATA.length," instead)"));this.constantArray=new Float32Array(this.CONSTANT_DATA.length*o);for(var a=0;a<this.CONSTANT_DATA.length;a++){var s=this.CONSTANT_DATA[a];if(s.length!==o)throw new Error("Program: error while getting constant data (one vector has ".concat(s.length," items instead of ").concat(o,")"));for(var l=0;l<s.length;l++)this.constantArray[a*o+l]=s[l]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return S(e,[{key:"kill",value:function(){q(this.normalProgram),this.pickProgram&&(q(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(n,t,i,o,a){var s=this.getDefinition(),l=t.createBuffer();if(l===null)throw new Error("Program: error while creating the WebGL buffer.");var u=Oe(t,i),c=De(t,o),h=Le(t,[u,c]),_={};s.UNIFORMS.forEach(function(m){var E=t.getUniformLocation(h,m);E&&(_[m]=E)});var d={};s.ATTRIBUTES.forEach(function(m){d[m.name]=t.getAttribLocation(h,m.name)});var v;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(m){d[m.name]=t.getAttribLocation(h,m.name)}),v=t.createBuffer(),v===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:h,gl:t,frameBuffer:a,buffer:l,constantBuffer:v||{},uniformLocations:_,attributeLocations:d,isPicking:n==="pick",vertexShader:u,fragmentShader:c}}},{key:"bindProgram",value:function(n){var t=this,i=0,o=n.gl,a=n.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,n.constantBuffer),i=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return i+=t.bindAttribute(s,n,i,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,n.buffer),i=0,this.ATTRIBUTES.forEach(function(s){return i+=t.bindAttribute(s,n,i,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,a),i=0,this.ATTRIBUTES.forEach(function(s){return i+=t.bindAttribute(s,n,i)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)),o.bindBuffer(o.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(n){var t=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(i){return t.unbindAttribute(i,n,!1)}),this.ATTRIBUTES.forEach(function(i){return t.unbindAttribute(i,n,!0)})):this.ATTRIBUTES.forEach(function(i){return t.unbindAttribute(i,n)})}},{key:"bindAttribute",value:function(n,t,i,o){var a=Ie[n.type];if(typeof a!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(n.type,'"'));var s=t.attributeLocations[n.name],l=t.gl;if(s!==-1){l.enableVertexAttribArray(s);var u=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:x(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(l.vertexAttribPointer(s,n.size,n.type,n.normalized||!1,u,i),this.isInstanced&&o)if(l instanceof WebGL2RenderingContext)l.vertexAttribDivisor(s,1);else{var c=l.getExtension("ANGLE_instanced_arrays");c&&c.vertexAttribDivisorANGLE(s,1)}}return n.size*a}},{key:"unbindAttribute",value:function(n,t,i){var o=t.attributeLocations[n.name],a=t.gl;if(o!==-1&&(a.disableVertexAttribArray(o),this.isInstanced&&i))if(a instanceof WebGL2RenderingContext)a.vertexAttribDivisor(o,0);else{var s=a.getExtension("ANGLE_instanced_arrays");s&&s.vertexAttribDivisorANGLE(o,0)}}},{key:"reallocate",value:function(n){n!==this.capacity&&(this.capacity=n,this.verticesCount=this.VERTICES*n,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(n,t){var i=t.gl,o=t.program;i.enable(i.BLEND),i.useProgram(o),this.setUniforms(n,t),this.drawWebGL(this.METHOD,t)}},{key:"render",value:function(n){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,n.width*n.pixelRatio/n.downSizingRatio,n.height*n.pixelRatio/n.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(N(N({},n),{},{pixelRatio:n.pixelRatio/n.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,n.width*n.pixelRatio,n.height*n.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(n,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(n,t){var i=t.gl,o=t.frameBuffer;if(i.bindFramebuffer(i.FRAMEBUFFER,o),!this.isInstanced)i.drawArrays(n,0,this.verticesCount);else if(i instanceof WebGL2RenderingContext)i.drawArraysInstanced(n,0,this.VERTICES,this.capacity);else{var a=i.getExtension("ANGLE_instanced_arrays");a&&a.drawArraysInstancedANGLE(n,0,this.VERTICES,this.capacity)}}}])})(),Pe=(function(e){function r(){return F(this,r),O(this,r,arguments)}return D(r,e),S(r,[{key:"kill",value:function(){se(r,"kill",this)([])}},{key:"process",value:function(t,i,o){var a=i*this.STRIDE;if(o.hidden){for(var s=a+this.STRIDE;a<s;a++)this.array[a]=0;return}return this.processVisibleItem(ae(t),a,o)}}])})(ue),W=(function(e){function r(){var n;F(this,r);for(var t=arguments.length,i=new Array(t),o=0;o<t;o++)i[o]=arguments[o];return n=O(this,r,[].concat(i)),R(n,"drawLabel",void 0),n}return D(r,e),S(r,[{key:"kill",value:function(){se(r,"kill",this)([])}},{key:"process",value:function(t,i,o,a,s){var l=i*this.STRIDE;if(s.hidden||o.hidden||a.hidden){for(var u=l+this.STRIDE;l<u;l++)this.array[l]=0;return}return this.processVisibleItem(ae(t),l,o,a,s)}}])})(ue);function Be(e,r){return(function(){function n(t,i,o){F(this,n),R(this,"drawLabel",r),this.programs=e.map(function(a){return new a(t,i,o)})}return S(n,[{key:"reallocate",value:function(i){this.programs.forEach(function(o){return o.reallocate(i)})}},{key:"process",value:function(i,o,a,s,l){this.programs.forEach(function(u){return u.process(i,o,a,s,l)})}},{key:"render",value:function(i){this.programs.forEach(function(o){return o.render(i)})}},{key:"kill",value:function(){this.programs.forEach(function(i){return i.kill()})}}])})()}function lr(e,r,n,t,i){var o=i.edgeLabelSize,a=i.edgeLabelFont,s=i.edgeLabelWeight,l=i.edgeLabelColor.attribute?r[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,u=r.label;if(u){e.fillStyle=l,e.font="".concat(s," ").concat(o,"px ").concat(a);var c=n.size,h=t.size,_=n.x,d=n.y,v=t.x,m=t.y,E=(_+v)/2,y=(d+m)/2,g=v-_,f=m-d,T=Math.sqrt(g*g+f*f);if(!(T<c+h)){_+=g*c/T,d+=f*c/T,v-=g*h/T,m-=f*h/T,E=(_+v)/2,y=(d+m)/2,g=v-_,f=m-d,T=Math.sqrt(g*g+f*f);var p=e.measureText(u).width;if(p>T){var b="…";for(u=u+b,p=e.measureText(u).width;p>T&&u.length>1;)u=u.slice(0,-2)+b,p=e.measureText(u).width;if(u.length<4)return}var A;g>0?f>0?A=Math.acos(g/T):A=Math.asin(f/T):f>0?A=Math.acos(g/T)+Math.PI:A=Math.asin(g/T)+Math.PI/2,e.save(),e.translate(E,y),e.rotate(A),e.fillText(u,-p/2,r.size/2+o),e.restore()}}}function Ge(e,r,n){if(r.label){var t=n.labelSize,i=n.labelFont,o=n.labelWeight,a=n.labelColor.attribute?r[n.labelColor.attribute]||n.labelColor.color||"#000":n.labelColor.color;e.fillStyle=a,e.font="".concat(o," ").concat(t,"px ").concat(i),e.fillText(r.label,r.x+r.size+3,r.y+t/3)}}function ur(e,r,n){var t=n.labelSize,i=n.labelFont,o=n.labelWeight;e.font="".concat(o," ").concat(t,"px ").concat(i),e.fillStyle="#FFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=8,e.shadowColor="#000";var a=2;if(typeof r.label=="string"){var s=e.measureText(r.label).width,l=Math.round(s+5),u=Math.round(t+2*a),c=Math.max(r.size,t/2)+a,h=Math.asin(u/2/c),_=Math.sqrt(Math.abs(Math.pow(c,2)-Math.pow(u/2,2)));e.beginPath(),e.moveTo(r.x+_,r.y+u/2),e.lineTo(r.x+c+l,r.y+u/2),e.lineTo(r.x+c+l,r.y-u/2),e.lineTo(r.x+_,r.y-u/2),e.arc(r.x,r.y,c,h,-h),e.closePath(),e.fill()}else e.beginPath(),e.arc(r.x,r.y,r.size+a,0,Math.PI*2),e.closePath(),e.fill();e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,Ge(e,r,n)}var Ue=`
|
|
6
|
+
precision highp float;
|
|
7
|
+
|
|
8
|
+
varying vec4 v_color;
|
|
9
|
+
varying vec2 v_diffVector;
|
|
10
|
+
varying float v_radius;
|
|
11
|
+
|
|
12
|
+
uniform float u_correctionRatio;
|
|
13
|
+
|
|
14
|
+
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
15
|
+
|
|
16
|
+
void main(void) {
|
|
17
|
+
float border = u_correctionRatio * 2.0;
|
|
18
|
+
float dist = length(v_diffVector) - v_radius + border;
|
|
19
|
+
|
|
20
|
+
// No antialiasing for picking mode:
|
|
21
|
+
#ifdef PICKING_MODE
|
|
22
|
+
if (dist > border)
|
|
23
|
+
gl_FragColor = transparent;
|
|
24
|
+
else
|
|
25
|
+
gl_FragColor = v_color;
|
|
26
|
+
|
|
27
|
+
#else
|
|
28
|
+
float t = 0.0;
|
|
29
|
+
if (dist > border)
|
|
30
|
+
t = 1.0;
|
|
31
|
+
else if (dist > 0.0)
|
|
32
|
+
t = dist / border;
|
|
33
|
+
|
|
34
|
+
gl_FragColor = mix(v_color, transparent, t);
|
|
35
|
+
#endif
|
|
36
|
+
}
|
|
37
|
+
`,ze=Ue,xe=`
|
|
38
|
+
attribute vec4 a_id;
|
|
39
|
+
attribute vec4 a_color;
|
|
40
|
+
attribute vec2 a_position;
|
|
41
|
+
attribute float a_size;
|
|
42
|
+
attribute float a_angle;
|
|
43
|
+
|
|
44
|
+
uniform mat3 u_matrix;
|
|
45
|
+
uniform float u_sizeRatio;
|
|
46
|
+
uniform float u_correctionRatio;
|
|
47
|
+
|
|
48
|
+
varying vec4 v_color;
|
|
49
|
+
varying vec2 v_diffVector;
|
|
50
|
+
varying float v_radius;
|
|
51
|
+
varying float v_border;
|
|
52
|
+
|
|
53
|
+
const float bias = 255.0 / 254.0;
|
|
54
|
+
|
|
55
|
+
void main() {
|
|
56
|
+
float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
|
|
57
|
+
vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
|
|
58
|
+
vec2 position = a_position + diffVector;
|
|
59
|
+
gl_Position = vec4(
|
|
60
|
+
(u_matrix * vec3(position, 1)).xy,
|
|
61
|
+
0,
|
|
62
|
+
1
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
v_diffVector = diffVector;
|
|
66
|
+
v_radius = size / 2.0;
|
|
67
|
+
|
|
68
|
+
#ifdef PICKING_MODE
|
|
69
|
+
// For picking mode, we use the ID as the color:
|
|
70
|
+
v_color = a_id;
|
|
71
|
+
#else
|
|
72
|
+
// For normal mode, we use the color:
|
|
73
|
+
v_color = a_color;
|
|
74
|
+
#endif
|
|
75
|
+
|
|
76
|
+
v_color.a *= bias;
|
|
77
|
+
}
|
|
78
|
+
`,Me=xe,ce=WebGLRenderingContext,Z=ce.UNSIGNED_BYTE,M=ce.FLOAT,He=["u_sizeRatio","u_correctionRatio","u_matrix"],j=(function(e){function r(){return F(this,r),O(this,r,arguments)}return D(r,e),S(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Me,FRAGMENT_SHADER_SOURCE:ze,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:He,ATTRIBUTES:[{name:"a_position",size:2,type:M},{name:"a_size",size:1,type:M},{name:"a_color",size:4,type:Z,normalized:!0},{name:"a_id",size:4,type:Z,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:M}],CONSTANT_DATA:[[r.ANGLE_1],[r.ANGLE_2],[r.ANGLE_3]]}}},{key:"processVisibleItem",value:function(t,i,o){var a=this.array,s=L(o.color);a[i++]=o.x,a[i++]=o.y,a[i++]=o.size,a[i++]=s,a[i++]=t}},{key:"setUniforms",value:function(t,i){var o=i.gl,a=i.uniformLocations,s=a.u_sizeRatio,l=a.u_correctionRatio,u=a.u_matrix;o.uniform1f(l,t.correctionRatio),o.uniform1f(s,t.sizeRatio),o.uniformMatrix3fv(u,!1,t.matrix)}}])})(Pe);R(j,"ANGLE_1",0);R(j,"ANGLE_2",2*Math.PI/3);R(j,"ANGLE_3",4*Math.PI/3);var Ve=`
|
|
79
|
+
precision mediump float;
|
|
80
|
+
|
|
81
|
+
varying vec4 v_color;
|
|
82
|
+
|
|
83
|
+
void main(void) {
|
|
84
|
+
gl_FragColor = v_color;
|
|
85
|
+
}
|
|
86
|
+
`,We=Ve,je=`
|
|
87
|
+
attribute vec2 a_position;
|
|
88
|
+
attribute vec2 a_normal;
|
|
89
|
+
attribute float a_radius;
|
|
90
|
+
attribute vec3 a_barycentric;
|
|
91
|
+
|
|
92
|
+
#ifdef PICKING_MODE
|
|
93
|
+
attribute vec4 a_id;
|
|
94
|
+
#else
|
|
95
|
+
attribute vec4 a_color;
|
|
96
|
+
#endif
|
|
97
|
+
|
|
98
|
+
uniform mat3 u_matrix;
|
|
99
|
+
uniform float u_sizeRatio;
|
|
100
|
+
uniform float u_correctionRatio;
|
|
101
|
+
uniform float u_minEdgeThickness;
|
|
102
|
+
uniform float u_lengthToThicknessRatio;
|
|
103
|
+
uniform float u_widenessToThicknessRatio;
|
|
104
|
+
|
|
105
|
+
varying vec4 v_color;
|
|
106
|
+
|
|
107
|
+
const float bias = 255.0 / 254.0;
|
|
108
|
+
|
|
109
|
+
void main() {
|
|
110
|
+
float minThickness = u_minEdgeThickness;
|
|
111
|
+
|
|
112
|
+
float normalLength = length(a_normal);
|
|
113
|
+
vec2 unitNormal = a_normal / normalLength;
|
|
114
|
+
|
|
115
|
+
// These first computations are taken from edge.vert.glsl and
|
|
116
|
+
// edge.clamped.vert.glsl. Please read it to get better comments on what's
|
|
117
|
+
// happening:
|
|
118
|
+
float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);
|
|
119
|
+
float webGLThickness = pixelsThickness * u_correctionRatio;
|
|
120
|
+
float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
121
|
+
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
122
|
+
float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;
|
|
123
|
+
|
|
124
|
+
float da = a_barycentric.x;
|
|
125
|
+
float db = a_barycentric.y;
|
|
126
|
+
float dc = a_barycentric.z;
|
|
127
|
+
|
|
128
|
+
vec2 delta = vec2(
|
|
129
|
+
da * (webGLNodeRadius * unitNormal.y)
|
|
130
|
+
+ db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)
|
|
131
|
+
+ dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),
|
|
132
|
+
|
|
133
|
+
da * (-webGLNodeRadius * unitNormal.x)
|
|
134
|
+
+ db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)
|
|
135
|
+
+ dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;
|
|
139
|
+
|
|
140
|
+
gl_Position = vec4(position, 0, 1);
|
|
141
|
+
|
|
142
|
+
#ifdef PICKING_MODE
|
|
143
|
+
// For picking mode, we use the ID as the color:
|
|
144
|
+
v_color = a_id;
|
|
145
|
+
#else
|
|
146
|
+
// For normal mode, we use the color:
|
|
147
|
+
v_color = a_color;
|
|
148
|
+
#endif
|
|
149
|
+
|
|
150
|
+
v_color.a *= bias;
|
|
151
|
+
}
|
|
152
|
+
`,Ye=je,fe=WebGLRenderingContext,J=fe.UNSIGNED_BYTE,B=fe.FLOAT,$e=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],he={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function _e(e){var r=N(N({},he),{});return(function(n){function t(){return F(this,t),O(this,t,arguments)}return D(t,n),S(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Ye,FRAGMENT_SHADER_SOURCE:We,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:$e,ATTRIBUTES:[{name:"a_position",size:2,type:B},{name:"a_normal",size:2,type:B},{name:"a_radius",size:1,type:B},{name:"a_color",size:4,type:J,normalized:!0},{name:"a_id",size:4,type:J,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:B}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,a,s,l,u){if(r.extremity==="source"){var c=[l,s];s=c[0],l=c[1]}var h=u.size||1,_=l.size||1,d=s.x,v=s.y,m=l.x,E=l.y,y=L(u.color),g=m-d,f=E-v,T=g*g+f*f,p=0,b=0;T&&(T=1/Math.sqrt(T),p=-f*T*h,b=g*T*h);var A=this.array;A[a++]=m,A[a++]=E,A[a++]=-p,A[a++]=-b,A[a++]=_,A[a++]=y,A[a++]=o}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,u=l.u_matrix,c=l.u_sizeRatio,h=l.u_correctionRatio,_=l.u_minEdgeThickness,d=l.u_lengthToThicknessRatio,v=l.u_widenessToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(c,o.sizeRatio),s.uniform1f(h,o.correctionRatio),s.uniform1f(_,o.minEdgeThickness),s.uniform1f(d,r.lengthToThicknessRatio),s.uniform1f(v,r.widenessToThicknessRatio)}}])})(W)}_e();var Xe=`
|
|
153
|
+
precision mediump float;
|
|
154
|
+
|
|
155
|
+
varying vec4 v_color;
|
|
156
|
+
varying vec2 v_normal;
|
|
157
|
+
varying float v_thickness;
|
|
158
|
+
varying float v_feather;
|
|
159
|
+
|
|
160
|
+
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
161
|
+
|
|
162
|
+
void main(void) {
|
|
163
|
+
// We only handle antialiasing for normal mode:
|
|
164
|
+
#ifdef PICKING_MODE
|
|
165
|
+
gl_FragColor = v_color;
|
|
166
|
+
#else
|
|
167
|
+
float dist = length(v_normal) * v_thickness;
|
|
168
|
+
|
|
169
|
+
float t = smoothstep(
|
|
170
|
+
v_thickness - v_feather,
|
|
171
|
+
v_thickness,
|
|
172
|
+
dist
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
gl_FragColor = mix(v_color, transparent, t);
|
|
176
|
+
#endif
|
|
177
|
+
}
|
|
178
|
+
`,me=Xe,qe=`
|
|
179
|
+
attribute vec4 a_id;
|
|
180
|
+
attribute vec4 a_color;
|
|
181
|
+
attribute vec2 a_normal;
|
|
182
|
+
attribute float a_normalCoef;
|
|
183
|
+
attribute vec2 a_positionStart;
|
|
184
|
+
attribute vec2 a_positionEnd;
|
|
185
|
+
attribute float a_positionCoef;
|
|
186
|
+
attribute float a_radius;
|
|
187
|
+
attribute float a_radiusCoef;
|
|
188
|
+
|
|
189
|
+
uniform mat3 u_matrix;
|
|
190
|
+
uniform float u_zoomRatio;
|
|
191
|
+
uniform float u_sizeRatio;
|
|
192
|
+
uniform float u_pixelRatio;
|
|
193
|
+
uniform float u_correctionRatio;
|
|
194
|
+
uniform float u_minEdgeThickness;
|
|
195
|
+
uniform float u_lengthToThicknessRatio;
|
|
196
|
+
uniform float u_feather;
|
|
197
|
+
|
|
198
|
+
varying vec4 v_color;
|
|
199
|
+
varying vec2 v_normal;
|
|
200
|
+
varying float v_thickness;
|
|
201
|
+
varying float v_feather;
|
|
202
|
+
|
|
203
|
+
const float bias = 255.0 / 254.0;
|
|
204
|
+
|
|
205
|
+
void main() {
|
|
206
|
+
float minThickness = u_minEdgeThickness;
|
|
207
|
+
|
|
208
|
+
float radius = a_radius * a_radiusCoef;
|
|
209
|
+
vec2 normal = a_normal * a_normalCoef;
|
|
210
|
+
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
211
|
+
|
|
212
|
+
float normalLength = length(normal);
|
|
213
|
+
vec2 unitNormal = normal / normalLength;
|
|
214
|
+
|
|
215
|
+
// These first computations are taken from edge.vert.glsl. Please read it to
|
|
216
|
+
// get better comments on what's happening:
|
|
217
|
+
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
218
|
+
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
219
|
+
|
|
220
|
+
// Here, we move the point to leave space for the arrow head:
|
|
221
|
+
float direction = sign(radius);
|
|
222
|
+
float webGLNodeRadius = direction * radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
223
|
+
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
224
|
+
|
|
225
|
+
vec2 compensationVector = vec2(-direction * unitNormal.y, direction * unitNormal.x) * (webGLNodeRadius + webGLArrowHeadLength);
|
|
226
|
+
|
|
227
|
+
// Here is the proper position of the vertex
|
|
228
|
+
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + compensationVector, 1)).xy, 0, 1);
|
|
229
|
+
|
|
230
|
+
v_thickness = webGLThickness / u_zoomRatio;
|
|
231
|
+
|
|
232
|
+
v_normal = unitNormal;
|
|
233
|
+
|
|
234
|
+
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
235
|
+
|
|
236
|
+
#ifdef PICKING_MODE
|
|
237
|
+
// For picking mode, we use the ID as the color:
|
|
238
|
+
v_color = a_id;
|
|
239
|
+
#else
|
|
240
|
+
// For normal mode, we use the color:
|
|
241
|
+
v_color = a_color;
|
|
242
|
+
#endif
|
|
243
|
+
|
|
244
|
+
v_color.a *= bias;
|
|
245
|
+
}
|
|
246
|
+
`,Ke=qe,de=WebGLRenderingContext,Q=de.UNSIGNED_BYTE,C=de.FLOAT,Ze=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],Je={lengthToThicknessRatio:he.lengthToThicknessRatio};function ve(e){var r=N(N({},Je),{});return(function(n){function t(){return F(this,t),O(this,t,arguments)}return D(t,n),S(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Ke,FRAGMENT_SHADER_SOURCE:me,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Ze,ATTRIBUTES:[{name:"a_positionStart",size:2,type:C},{name:"a_positionEnd",size:2,type:C},{name:"a_normal",size:2,type:C},{name:"a_color",size:4,type:Q,normalized:!0},{name:"a_id",size:4,type:Q,normalized:!0},{name:"a_radius",size:1,type:C}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:C},{name:"a_normalCoef",size:1,type:C},{name:"a_radiusCoef",size:1,type:C}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(o,a,s,l,u){var c=u.size||1,h=s.x,_=s.y,d=l.x,v=l.y,m=L(u.color),E=d-h,y=v-_,g=l.size||1,f=E*E+y*y,T=0,p=0;f&&(f=1/Math.sqrt(f),T=-y*f*c,p=E*f*c);var b=this.array;b[a++]=h,b[a++]=_,b[a++]=d,b[a++]=v,b[a++]=T,b[a++]=p,b[a++]=m,b[a++]=o,b[a++]=g}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,u=l.u_matrix,c=l.u_zoomRatio,h=l.u_feather,_=l.u_pixelRatio,d=l.u_correctionRatio,v=l.u_sizeRatio,m=l.u_minEdgeThickness,E=l.u_lengthToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(c,o.zoomRatio),s.uniform1f(v,o.sizeRatio),s.uniform1f(d,o.correctionRatio),s.uniform1f(_,o.pixelRatio),s.uniform1f(h,o.antiAliasingFeather),s.uniform1f(m,o.minEdgeThickness),s.uniform1f(E,r.lengthToThicknessRatio)}}])})(W)}ve();function Qe(e){return Be([ve(),_e()])}var er=Qe(),cr=er,rr=`
|
|
247
|
+
attribute vec4 a_id;
|
|
248
|
+
attribute vec4 a_color;
|
|
249
|
+
attribute vec2 a_normal;
|
|
250
|
+
attribute float a_normalCoef;
|
|
251
|
+
attribute vec2 a_positionStart;
|
|
252
|
+
attribute vec2 a_positionEnd;
|
|
253
|
+
attribute float a_positionCoef;
|
|
254
|
+
|
|
255
|
+
uniform mat3 u_matrix;
|
|
256
|
+
uniform float u_sizeRatio;
|
|
257
|
+
uniform float u_zoomRatio;
|
|
258
|
+
uniform float u_pixelRatio;
|
|
259
|
+
uniform float u_correctionRatio;
|
|
260
|
+
uniform float u_minEdgeThickness;
|
|
261
|
+
uniform float u_feather;
|
|
262
|
+
|
|
263
|
+
varying vec4 v_color;
|
|
264
|
+
varying vec2 v_normal;
|
|
265
|
+
varying float v_thickness;
|
|
266
|
+
varying float v_feather;
|
|
267
|
+
|
|
268
|
+
const float bias = 255.0 / 254.0;
|
|
269
|
+
|
|
270
|
+
void main() {
|
|
271
|
+
float minThickness = u_minEdgeThickness;
|
|
272
|
+
|
|
273
|
+
vec2 normal = a_normal * a_normalCoef;
|
|
274
|
+
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
275
|
+
|
|
276
|
+
float normalLength = length(normal);
|
|
277
|
+
vec2 unitNormal = normal / normalLength;
|
|
278
|
+
|
|
279
|
+
// We require edges to be at least "minThickness" pixels thick *on screen*
|
|
280
|
+
// (so we need to compensate the size ratio):
|
|
281
|
+
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
282
|
+
|
|
283
|
+
// Then, we need to retrieve the normalized thickness of the edge in the WebGL
|
|
284
|
+
// referential (in a ([0, 1], [0, 1]) space), using our "magic" correction
|
|
285
|
+
// ratio:
|
|
286
|
+
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
287
|
+
|
|
288
|
+
// Here is the proper position of the vertex
|
|
289
|
+
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness, 1)).xy, 0, 1);
|
|
290
|
+
|
|
291
|
+
// For the fragment shader though, we need a thickness that takes the "magic"
|
|
292
|
+
// correction ratio into account (as in webGLThickness), but so that the
|
|
293
|
+
// antialiasing effect does not depend on the zoom level. So here's yet
|
|
294
|
+
// another thickness version:
|
|
295
|
+
v_thickness = webGLThickness / u_zoomRatio;
|
|
296
|
+
|
|
297
|
+
v_normal = unitNormal;
|
|
298
|
+
|
|
299
|
+
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
300
|
+
|
|
301
|
+
#ifdef PICKING_MODE
|
|
302
|
+
// For picking mode, we use the ID as the color:
|
|
303
|
+
v_color = a_id;
|
|
304
|
+
#else
|
|
305
|
+
// For normal mode, we use the color:
|
|
306
|
+
v_color = a_color;
|
|
307
|
+
#endif
|
|
308
|
+
|
|
309
|
+
v_color.a *= bias;
|
|
310
|
+
}
|
|
311
|
+
`,nr=rr,Te=WebGLRenderingContext,ee=Te.UNSIGNED_BYTE,I=Te.FLOAT,ir=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],fr=(function(e){function r(){return F(this,r),O(this,r,arguments)}return D(r,e),S(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:nr,FRAGMENT_SHADER_SOURCE:me,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:ir,ATTRIBUTES:[{name:"a_positionStart",size:2,type:I},{name:"a_positionEnd",size:2,type:I},{name:"a_normal",size:2,type:I},{name:"a_color",size:4,type:ee,normalized:!0},{name:"a_id",size:4,type:ee,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:I},{name:"a_normalCoef",size:1,type:I}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(t,i,o,a,s){var l=s.size||1,u=o.x,c=o.y,h=a.x,_=a.y,d=L(s.color),v=h-u,m=_-c,E=v*v+m*m,y=0,g=0;E&&(E=1/Math.sqrt(E),y=-m*E*l,g=v*E*l);var f=this.array;f[i++]=u,f[i++]=c,f[i++]=h,f[i++]=_,f[i++]=y,f[i++]=g,f[i++]=d,f[i++]=t}},{key:"setUniforms",value:function(t,i){var o=i.gl,a=i.uniformLocations,s=a.u_matrix,l=a.u_zoomRatio,u=a.u_feather,c=a.u_pixelRatio,h=a.u_correctionRatio,_=a.u_sizeRatio,d=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,t.matrix),o.uniform1f(l,t.zoomRatio),o.uniform1f(_,t.sizeRatio),o.uniform1f(h,t.correctionRatio),o.uniform1f(c,t.pixelRatio),o.uniform1f(u,t.antiAliasingFeather),o.uniform1f(d,t.minEdgeThickness)}}])})(W);export{cr as E,j as N,$ as _,fr as a,Pe as b,O as c,F as d,S as e,R as f,D as g,N as h,Fe as i,re as j,ye as k,tr as l,or as m,ur as n,Ge as o,lr as p,L as q,ar as r,sr as s};
|