{"version":3,"sources":["_init.js","Breakpoint.js","GetReference.js","Log.code.js","Log.js"],"names":["_Class","_GetReferenceNode","_Class2","window","globalThis","async","imports","urls","sf","loader","mjs","Promise","all","map","v","import","task","Blackprint","loadScope","url","hasInterface","hasDocs","Context","createContext","EventSlot","slot","registerNode","Node","constructor","instance","super","this","setInterface","title","init","ref","IInput","Any","on","cable","value","output","OutputPort","input","InputPort","update","routeIn","Types","node","iface","console","log","registerCode","Code","js","routes","code","python","_refreshLogger","val","Environment","isBrowser","cables","length","JSON","stringify","Input","undefined","syncIn","id","data","Port","ArrayOf","interfaceSync","type","placeholder","tooltip","registerInterface","IFace","Logger","Interface","args","_log","syncOut"],"mappings":";;AAAA,aAAA,IAAAA,OAAAC,kBAAAC,QAAA,QAAA,IAAAC,OAAA,IAAAA,OAAAC,WAAAC,eAAAC,QAAAC,GAAA,MAAA,oBAAAC,SAAA,IAAAA,GAAAC,aAAAD,GAAAC,OAAAC,IAAAH,GAAAI,QAAAC,IAAAL,EAAAM,IAAAC,GAAAC,OAAAD,IAAA,CAAAR,QAAAU,KAAA,WAAA,MAAA,oBAAAR,SAAA,IAAAA,GAAAC,OAAAD,GAAAC,OAAAO,KAAA,IAAA,EAGA,IAAAC,WAAAd,OAAAc,WAAAC,UAAA,CAGAC,gBAAAA,IAGAC,cAAA,EAGAC,SAAA,IAIAC,QAAAL,WAAAM,cAAA,WAIAD,QAAAE,UAAA,CAAAC,KAAA,yBCfAR,WAAAS,aAAA,uBAAA1B,OACA,cAAAiB,WAAAU,KAGAC,WAAAA,CAAAC,GACAC,MAAAD,GAEAE,KAAAC,eACAC,MAAA,YACA,CAEAC,IAAAA,GAGAH,KAAAI,IAAAC,OAAAC,IAAAC,GAAA,QAAA,EAAAC,YACA,IAAAC,MAAAA,EAAAC,OAAAC,EAAAC,MAAAC,GAAAL,GAGA,CAEAM,MAAAA,GAAA,CACAC,OAAAA,GAEA,IArBAH,MAAA,CAAAN,IAAApB,WAAA8B,MAAAV,KAAArC,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AAE,IAAAmB,EACA,IA1DA3B,MAAA,CAEAN,IAAApB,WAAAsD,KAAAC,QAAAvD,WAAA8B,MAAAV,MACAnC,QAGAuE,cAAA,CACA,CAAAC,KAAA,WAAAL,GAAA,MAAAM,YAAA,MAAAC,QAAA,6BACA1E,UAqDAe,WAAA4D,kBAAA,mBACAvD,QAAAwD,MAAAC,OAAA,cAAA9D,WAAA+D,UAAApD,WAAAA,IAAAqD,GAAAnD,SAAAmD,GAAAlD,KACAmD,KAAA,KAAA,CAEA,OAAA/B,GAAA,OAAApB,KAAAmD,IAAA,CACA,OAAA/B,CAAAQ,GACA5B,KAAAmD,KAAAvB,EACA5B,KAAAiB,KAAAmC,QAAA,MAAAxB,EACA","file":"nodes-console.mjs","sourcesContent":["// We don't have graphics node for non-browser :3\n// Let's just use this file to load .sf.mjs and .sf.css\n\nlet Blackprint = window.Blackprint.loadScope({\n\t// You can find the URL on Blackprint menu -> Modules\n\t// This will also be exported to JSON if this module's nodes is being used\n\turl: import.meta.url,\n\n\t// This will autoload (*.sf.mjs) and (*.sf.css) file for Browser\n\thasInterface: true,\n\n\t// This will autoload (*.docs.json) for Browser\n\thasDocs: true,\n});\n\n// Global shared context\nlet Context = Blackprint.createContext('Console');\n\n// This is needed to avoid duplicated event listener when using hot reload\n// Event listener that registered with same slot will be replaced\nContext.EventSlot = {slot: 'my-private-event-slot'};","/**\n * Add breakpoint that will pause the execution if any debugger was attached\n * @blackprint node\n * @summary Add breakpoint for debugging\n */\nBlackprint.registerNode('Console/Breakpoint',\nclass extends Blackprint.Node {\n\tstatic input = {Any: Blackprint.Types.Any};\n\n\tconstructor(instance){\n\t\tsuper(instance);\n\n\t\tlet iface = this.setInterface();\n\t\tiface.title = \"Breakpoint\";\n\t}\n\n\tinit(){\n\t\t// InputPort = port from this node (Breakpoint.Any)\n\t\t// OutputPort = port from other node (that connected to this node)\n\t\tthis.ref.IInput.Any.on('value', ({ cable }) => {\n\t\t\tlet { value, output: OutputPort, input: InputPort } = cable;\n\t\t\tdebugger;\n\t\t});\n\t}\n\n\tupdate(){}\n\trouteIn(){\n\t\tdebugger;\n\t}\n});","/**\n * Any data that being passed to this node\n * will be sent to Console on your DevTools\n * To open the DevTools you can use CTRL + Shift + I, then go to Console\n * @blackprint node\n * @summary Send reference to browser console\n */\nBlackprint.registerNode('Console/GetReference',\nclass GetReferenceNode extends Blackprint.Node {\n\tstatic input = {Any: Blackprint.Types.Any};\n\n\tconstructor(instance){\n\t\tsuper(instance);\n\n\t\tlet iface = this.setInterface();\n\t\tiface.title = \"Get Reference\";\n\t}\n\n\tinit(){\n\t\tlet node = this;\n\t\tthis.iface.input.Any.on('value', Context.EventSlot, function(){\n\t\t\tconsole.log('Ref >', node.input.Any);\n\t\t});\n\t}\n});","Blackprint.registerCode('Console/Log',\nclass extends Blackprint.Code {\n\t// routes == { traceRoute, routeIn, routeOut }\n\tjs(routes){\n\t\treturn {\n\t\t\tcode: `console.log(Input.Any);`,\n\t\t};\n\t}\n\tpython(routes){\n\t\treturn {\n\t\t\tcode: `print(Input['Any'])`,\n\t\t};\n\t}\n});","/**\n * Display value from a port\n * Primitive type will be converted into a string\n * Object will be converted with JSON.stringify\n * @blackprint node\n * @summary Print anything into text\n */\nBlackprint.registerNode('Console/Log',\nclass extends Blackprint.Node {\n\tstatic input = {\n\t\t/** Any data type, and can be used for many cable */\n\t\tAny: Blackprint.Port.ArrayOf(Blackprint.Types.Any),\n\t};\n\n\t// Create interface for puppet node\n\tstatic interfaceSync = [\n\t\t{type: \"text_out\", id: \"log\", placeholder: \"...\", tooltip: \"Output will written here\"},\n\t];\n\n\tconstructor(instance){\n\t\tsuper(instance);\n\n\t\tlet iface = this.setInterface('BPIC/Console/Log');\n\t\tiface.title = \"Log\";\n\t}\n\n\t_refreshLogger(val){\n\t\tlet iface = this.iface;\n\n\t\tif(!Blackprint.Environment.isBrowser)\n\t\t\tconsole.log(val);\n\n\t\tif(this.ref.IInput.Any.cables.length > 1)\n\t\t\tiface.log = JSON.stringify(val);\n\t\telse {\n\t\t\tlet val = this.ref.Input.Any?.[0];\n\n\t\t\tif(val === null)\n\t\t\t\tiface.log = \"null\";\n\t\t\telse if(val === undefined)\n\t\t\t\tiface.log = \"undefined\";\n\t\t\telse if(typeof val === 'object')\n\t\t\t\tiface.log = JSON.stringify(val);\n\t\t\telse iface.log = val;\n\t\t}\n\t}\n\n\tinit(){\n\t\tlet { Input } = this.ref;\n\n\t\t// Let's show data after new cable was connected or disconnected\n\t\tthis.iface.on('cable.disconnect', Context.EventSlot, () => {\n\t\t\tthis._refreshLogger(Input.Any);\n\t\t});\n\t}\n\n\tupdate(){\n\t\tlet { Input } = this.ref;\n\n\t\t// Let's take all data from all connected nodes\n\t\t// Instead showing new single data-> val\n\t\tthis._refreshLogger(Input.Any);\n\t}\n\n\t// Remote sync in\n\tsyncIn(id, data){\n\t\tif(id === 'log') this.iface.log = data;\n\t}\n});\n\nBlackprint.registerInterface('BPIC/Console/Log',\nContext.IFace.Logger = class extends Blackprint.Interface {\n\t_log = '...';\n\n\tget log(){ return this._log }\n\tset log(val){\n\t\tthis._log = val;\n\t\tthis.node.syncOut('log', val);\n\t}\n});"]}