Repository: HelloZeroNet/ZeroNet Branch: py3 Commit: 454c0b2e7e00 Files: 537 Total size: 5.3 MB Directory structure: gitextract__wvjr9ao/ ├── .github/ │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE/ │ │ ├── bug-report.md │ │ └── feature_request.md │ └── workflows/ │ └── tests.yml ├── .gitignore ├── .gitlab-ci.yml ├── .travis.yml ├── CHANGELOG.md ├── COPYING ├── Dockerfile ├── Dockerfile.arm64v8 ├── LICENSE ├── README-ru.md ├── README-zh-cn.md ├── README.md ├── Vagrantfile ├── plugins/ │ ├── AnnounceBitTorrent/ │ │ ├── AnnounceBitTorrentPlugin.py │ │ ├── __init__.py │ │ └── plugin_info.json │ ├── AnnounceLocal/ │ │ ├── AnnounceLocalPlugin.py │ │ ├── BroadcastServer.py │ │ ├── Test/ │ │ │ ├── TestAnnounce.py │ │ │ ├── conftest.py │ │ │ └── pytest.ini │ │ ├── __init__.py │ │ └── plugin_info.json │ ├── AnnounceShare/ │ │ ├── AnnounceSharePlugin.py │ │ ├── Test/ │ │ │ ├── TestAnnounceShare.py │ │ │ ├── conftest.py │ │ │ └── pytest.ini │ │ ├── __init__.py │ │ └── plugin_info.json │ ├── AnnounceZero/ │ │ ├── AnnounceZeroPlugin.py │ │ ├── __init__.py │ │ └── plugin_info.json │ ├── Benchmark/ │ │ ├── BenchmarkDb.py │ │ ├── BenchmarkPack.py │ │ ├── BenchmarkPlugin.py │ │ ├── __init__.py │ │ ├── media/ │ │ │ └── benchmark.html │ │ └── plugin_info.json │ ├── Bigfile/ │ │ ├── BigfilePiecefield.py │ │ ├── BigfilePlugin.py │ │ ├── Test/ │ │ │ ├── TestBigfile.py │ │ │ ├── conftest.py │ │ │ └── pytest.ini │ │ └── __init__.py │ ├── Chart/ │ │ ├── ChartCollector.py │ │ ├── ChartDb.py │ │ ├── ChartPlugin.py │ │ ├── __init__.py │ │ └── plugin_info.json │ ├── ContentFilter/ │ │ ├── ContentFilterPlugin.py │ │ ├── ContentFilterStorage.py │ │ ├── Test/ │ │ │ ├── TestContentFilter.py │ │ │ ├── conftest.py │ │ │ └── pytest.ini │ │ ├── __init__.py │ │ ├── languages/ │ │ │ ├── hu.json │ │ │ ├── it.json │ │ │ ├── jp.json │ │ │ ├── pt-br.json │ │ │ ├── zh-tw.json │ │ │ └── zh.json │ │ ├── media/ │ │ │ ├── blocklisted.html │ │ │ └── js/ │ │ │ └── ZeroFrame.js │ │ └── plugin_info.json │ ├── Cors/ │ │ ├── CorsPlugin.py │ │ ├── __init__.py │ │ └── plugin_info.json │ ├── CryptMessage/ │ │ ├── CryptMessage.py │ │ ├── CryptMessagePlugin.py │ │ ├── Test/ │ │ │ ├── TestCrypt.py │ │ │ ├── conftest.py │ │ │ └── pytest.ini │ │ ├── __init__.py │ │ └── plugin_info.json │ ├── FilePack/ │ │ ├── FilePackPlugin.py │ │ ├── __init__.py │ │ └── plugin_info.json │ ├── MergerSite/ │ │ ├── MergerSitePlugin.py │ │ ├── __init__.py │ │ └── languages/ │ │ ├── es.json │ │ ├── fr.json │ │ ├── hu.json │ │ ├── it.json │ │ ├── jp.json │ │ ├── pt-br.json │ │ ├── tr.json │ │ ├── zh-tw.json │ │ └── zh.json │ ├── Newsfeed/ │ │ ├── NewsfeedPlugin.py │ │ └── __init__.py │ ├── OptionalManager/ │ │ ├── ContentDbPlugin.py │ │ ├── OptionalManagerPlugin.py │ │ ├── Test/ │ │ │ ├── TestOptionalManager.py │ │ │ ├── conftest.py │ │ │ └── pytest.ini │ │ ├── UiWebsocketPlugin.py │ │ ├── __init__.py │ │ └── languages/ │ │ ├── es.json │ │ ├── fr.json │ │ ├── hu.json │ │ ├── jp.json │ │ ├── pt-br.json │ │ ├── zh-tw.json │ │ └── zh.json │ ├── PeerDb/ │ │ ├── PeerDbPlugin.py │ │ ├── __init__.py │ │ └── plugin_info.json │ ├── Sidebar/ │ │ ├── ConsolePlugin.py │ │ ├── SidebarPlugin.py │ │ ├── ZipStream.py │ │ ├── __init__.py │ │ ├── languages/ │ │ │ ├── da.json │ │ │ ├── de.json │ │ │ ├── es.json │ │ │ ├── fr.json │ │ │ ├── hu.json │ │ │ ├── it.json │ │ │ ├── jp.json │ │ │ ├── pl.json │ │ │ ├── pt-br.json │ │ │ ├── ru.json │ │ │ ├── tr.json │ │ │ ├── zh-tw.json │ │ │ └── zh.json │ │ ├── media/ │ │ │ ├── Class.coffee │ │ │ ├── Console.coffee │ │ │ ├── Console.css │ │ │ ├── Menu.coffee │ │ │ ├── Menu.css │ │ │ ├── Prototypes.coffee │ │ │ ├── RateLimit.coffee │ │ │ ├── Scrollable.js │ │ │ ├── Scrollbable.css │ │ │ ├── Sidebar.coffee │ │ │ ├── Sidebar.css │ │ │ ├── all.css │ │ │ ├── all.js │ │ │ └── morphdom.js │ │ ├── media_globe/ │ │ │ ├── Detector.js │ │ │ ├── Tween.js │ │ │ ├── all.js │ │ │ └── globe.js │ │ └── plugin_info.json │ ├── Stats/ │ │ ├── StatsPlugin.py │ │ ├── __init__.py │ │ └── plugin_info.json │ ├── TranslateSite/ │ │ ├── TranslateSitePlugin.py │ │ ├── __init__.py │ │ └── plugin_info.json │ ├── Trayicon/ │ │ ├── TrayiconPlugin.py │ │ ├── __init__.py │ │ ├── languages/ │ │ │ ├── es.json │ │ │ ├── fr.json │ │ │ ├── hu.json │ │ │ ├── it.json │ │ │ ├── jp.json │ │ │ ├── pl.json │ │ │ ├── pt-br.json │ │ │ ├── tr.json │ │ │ ├── zh-tw.json │ │ │ └── zh.json │ │ ├── lib/ │ │ │ ├── __init__.py │ │ │ ├── notificationicon.py │ │ │ └── winfolders.py │ │ └── plugin_info.json │ ├── UiConfig/ │ │ ├── UiConfigPlugin.py │ │ ├── __init__.py │ │ ├── languages/ │ │ │ ├── hu.json │ │ │ ├── jp.json │ │ │ ├── pl.json │ │ │ ├── pt-br.json │ │ │ └── zh.json │ │ ├── media/ │ │ │ ├── config.html │ │ │ ├── css/ │ │ │ │ ├── Config.css │ │ │ │ ├── all.css │ │ │ │ ├── button.css │ │ │ │ └── fonts.css │ │ │ └── js/ │ │ │ ├── ConfigStorage.coffee │ │ │ ├── ConfigView.coffee │ │ │ ├── UiConfig.coffee │ │ │ ├── all.js │ │ │ ├── lib/ │ │ │ │ ├── Class.coffee │ │ │ │ ├── Promise.coffee │ │ │ │ ├── Prototypes.coffee │ │ │ │ └── maquette.js │ │ │ └── utils/ │ │ │ ├── Animation.coffee │ │ │ ├── Dollar.coffee │ │ │ └── ZeroFrame.coffee │ │ └── plugin_info.json │ ├── UiFileManager/ │ │ ├── UiFileManagerPlugin.py │ │ ├── __init__.py │ │ ├── languages/ │ │ │ ├── hu.json │ │ │ └── jp.json │ │ └── media/ │ │ ├── codemirror/ │ │ │ ├── LICENSE │ │ │ ├── all.css │ │ │ ├── all.js │ │ │ ├── base/ │ │ │ │ ├── codemirror.css │ │ │ │ └── codemirror.js │ │ │ ├── extension/ │ │ │ │ ├── dialog/ │ │ │ │ │ ├── dialog.css │ │ │ │ │ └── dialog.js │ │ │ │ ├── edit/ │ │ │ │ │ ├── closebrackets.js │ │ │ │ │ ├── closetag.js │ │ │ │ │ ├── continuelist.js │ │ │ │ │ ├── matchbrackets.js │ │ │ │ │ ├── matchtags.js │ │ │ │ │ └── trailingspace.js │ │ │ │ ├── fold/ │ │ │ │ │ ├── brace-fold.js │ │ │ │ │ ├── comment-fold.js │ │ │ │ │ ├── foldcode.js │ │ │ │ │ ├── foldgutter.css │ │ │ │ │ ├── foldgutter.js │ │ │ │ │ ├── indent-fold.js │ │ │ │ │ ├── markdown-fold.js │ │ │ │ │ └── xml-fold.js │ │ │ │ ├── hint/ │ │ │ │ │ ├── anyword-hint.js │ │ │ │ │ ├── html-hint.js │ │ │ │ │ ├── show-hint.css │ │ │ │ │ ├── show-hint.js │ │ │ │ │ ├── sql-hint.js │ │ │ │ │ └── xml-hint.js │ │ │ │ ├── lint/ │ │ │ │ │ ├── json-lint.js │ │ │ │ │ ├── jsonlint.js │ │ │ │ │ ├── lint.css │ │ │ │ │ └── lint.js │ │ │ │ ├── mdn-like-custom.css │ │ │ │ ├── scroll/ │ │ │ │ │ ├── annotatescrollbar.js │ │ │ │ │ ├── scrollpastend.js │ │ │ │ │ ├── simplescrollbars.css │ │ │ │ │ └── simplescrollbars.js │ │ │ │ ├── search/ │ │ │ │ │ ├── jump-to-line.js │ │ │ │ │ ├── match-highlighter.js │ │ │ │ │ ├── matchesonscrollbar.css │ │ │ │ │ ├── matchesonscrollbar.js │ │ │ │ │ ├── search.js │ │ │ │ │ └── searchcursor.js │ │ │ │ ├── selection/ │ │ │ │ │ ├── active-line.js │ │ │ │ │ ├── mark-selection.js │ │ │ │ │ └── selection-pointer.js │ │ │ │ ├── simple.js │ │ │ │ └── sublime.js │ │ │ └── mode/ │ │ │ ├── coffeescript.js │ │ │ ├── css.js │ │ │ ├── go.js │ │ │ ├── htmlembedded.js │ │ │ ├── htmlmixed.js │ │ │ ├── javascript.js │ │ │ ├── markdown.js │ │ │ ├── python.js │ │ │ ├── rust.js │ │ │ └── xml.js │ │ ├── css/ │ │ │ ├── Menu.css │ │ │ ├── Selectbar.css │ │ │ ├── UiFileManager.css │ │ │ └── all.css │ │ ├── js/ │ │ │ ├── Config.coffee │ │ │ ├── FileEditor.coffee │ │ │ ├── FileItemList.coffee │ │ │ ├── FileList.coffee │ │ │ ├── UiFileManager.coffee │ │ │ ├── all.js │ │ │ └── lib/ │ │ │ ├── Animation.coffee │ │ │ ├── Class.coffee │ │ │ ├── Dollar.coffee │ │ │ ├── ItemList.coffee │ │ │ ├── Menu.coffee │ │ │ ├── Promise.coffee │ │ │ ├── Prototypes.coffee │ │ │ ├── RateLimitCb.coffee │ │ │ ├── Text.coffee │ │ │ ├── Time.coffee │ │ │ ├── ZeroFrame.coffee │ │ │ └── maquette.js │ │ └── list.html │ ├── UiPluginManager/ │ │ ├── UiPluginManagerPlugin.py │ │ ├── __init__.py │ │ └── media/ │ │ ├── css/ │ │ │ ├── PluginManager.css │ │ │ ├── all.css │ │ │ ├── button.css │ │ │ └── fonts.css │ │ ├── js/ │ │ │ ├── PluginList.coffee │ │ │ ├── UiPluginManager.coffee │ │ │ ├── all.js │ │ │ ├── lib/ │ │ │ │ ├── Class.coffee │ │ │ │ ├── Promise.coffee │ │ │ │ ├── Prototypes.coffee │ │ │ │ └── maquette.js │ │ │ └── utils/ │ │ │ ├── Animation.coffee │ │ │ ├── Dollar.coffee │ │ │ └── ZeroFrame.coffee │ │ └── plugin_manager.html │ ├── Zeroname/ │ │ ├── README.md │ │ ├── SiteManagerPlugin.py │ │ ├── __init__.py │ │ └── updater/ │ │ └── zeroname_updater.py │ ├── __init__.py │ ├── disabled-Bootstrapper/ │ │ ├── BootstrapperDb.py │ │ ├── BootstrapperPlugin.py │ │ ├── Test/ │ │ │ ├── TestBootstrapper.py │ │ │ ├── conftest.py │ │ │ └── pytest.ini │ │ ├── __init__.py │ │ └── plugin_info.json │ ├── disabled-Dnschain/ │ │ ├── SiteManagerPlugin.py │ │ ├── UiRequestPlugin.py │ │ └── __init__.py │ ├── disabled-DonationMessage/ │ │ ├── DonationMessagePlugin.py │ │ └── __init__.py │ ├── disabled-Multiuser/ │ │ ├── MultiuserPlugin.py │ │ ├── Test/ │ │ │ ├── TestMultiuser.py │ │ │ ├── conftest.py │ │ │ └── pytest.ini │ │ ├── UserPlugin.py │ │ ├── __init__.py │ │ └── plugin_info.json │ ├── disabled-StemPort/ │ │ ├── StemPortPlugin.py │ │ └── __init__.py │ ├── disabled-UiPassword/ │ │ ├── UiPasswordPlugin.py │ │ ├── __init__.py │ │ ├── login.html │ │ └── plugin_info.json │ └── disabled-ZeronameLocal/ │ ├── SiteManagerPlugin.py │ ├── UiRequestPlugin.py │ └── __init__.py ├── requirements.txt ├── src/ │ ├── Config.py │ ├── Connection/ │ │ ├── Connection.py │ │ ├── ConnectionServer.py │ │ └── __init__.py │ ├── Content/ │ │ ├── ContentDb.py │ │ ├── ContentDbDict.py │ │ ├── ContentManager.py │ │ └── __init__.py │ ├── Crypt/ │ │ ├── Crypt.py │ │ ├── CryptBitcoin.py │ │ ├── CryptConnection.py │ │ ├── CryptHash.py │ │ ├── CryptRsa.py │ │ └── __init__.py │ ├── Db/ │ │ ├── Db.py │ │ ├── DbCursor.py │ │ ├── DbQuery.py │ │ └── __init__.py │ ├── Debug/ │ │ ├── Debug.py │ │ ├── DebugHook.py │ │ ├── DebugLock.py │ │ ├── DebugMedia.py │ │ ├── DebugReloader.py │ │ └── __init__.py │ ├── File/ │ │ ├── FileRequest.py │ │ ├── FileServer.py │ │ └── __init__.py │ ├── Peer/ │ │ ├── Peer.py │ │ ├── PeerHashfield.py │ │ ├── PeerPortchecker.py │ │ └── __init__.py │ ├── Plugin/ │ │ ├── PluginManager.py │ │ └── __init__.py │ ├── Site/ │ │ ├── Site.py │ │ ├── SiteAnnouncer.py │ │ ├── SiteManager.py │ │ ├── SiteStorage.py │ │ └── __init__.py │ ├── Test/ │ │ ├── BenchmarkSsl.py │ │ ├── Spy.py │ │ ├── TestCached.py │ │ ├── TestConfig.py │ │ ├── TestConnectionServer.py │ │ ├── TestContent.py │ │ ├── TestContentUser.py │ │ ├── TestCryptBitcoin.py │ │ ├── TestCryptConnection.py │ │ ├── TestCryptHash.py │ │ ├── TestDb.py │ │ ├── TestDbQuery.py │ │ ├── TestDebug.py │ │ ├── TestDiff.py │ │ ├── TestEvent.py │ │ ├── TestFileRequest.py │ │ ├── TestFlag.py │ │ ├── TestHelper.py │ │ ├── TestMsgpack.py │ │ ├── TestNoparallel.py │ │ ├── TestPeer.py │ │ ├── TestRateLimit.py │ │ ├── TestSafeRe.py │ │ ├── TestSite.py │ │ ├── TestSiteDownload.py │ │ ├── TestSiteStorage.py │ │ ├── TestThreadPool.py │ │ ├── TestTor.py │ │ ├── TestTranslate.py │ │ ├── TestUiWebsocket.py │ │ ├── TestUpnpPunch.py │ │ ├── TestUser.py │ │ ├── TestWeb.py │ │ ├── TestWorkerTaskManager.py │ │ ├── __init__.py │ │ ├── conftest.py │ │ ├── coverage.ini │ │ ├── pytest.ini │ │ └── testdata/ │ │ └── 1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/ │ │ ├── content.json │ │ ├── css/ │ │ │ └── all.css │ │ ├── data/ │ │ │ ├── data.json │ │ │ ├── optional.txt │ │ │ ├── test_include/ │ │ │ │ ├── content.json │ │ │ │ └── data.json │ │ │ └── users/ │ │ │ ├── 1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/ │ │ │ │ ├── content.json │ │ │ │ └── data.json │ │ │ ├── 1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/ │ │ │ │ ├── content.json │ │ │ │ └── data.json │ │ │ ├── 1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/ │ │ │ │ ├── content.json │ │ │ │ └── data.json │ │ │ └── content.json │ │ ├── data-default/ │ │ │ ├── data.json │ │ │ └── users/ │ │ │ └── content-default.json │ │ ├── dbschema.json │ │ ├── index.html │ │ └── js/ │ │ └── all.js │ ├── Tor/ │ │ ├── TorManager.py │ │ └── __init__.py │ ├── Translate/ │ │ ├── Translate.py │ │ ├── __init__.py │ │ └── languages/ │ │ ├── da.json │ │ ├── de.json │ │ ├── es.json │ │ ├── fa.json │ │ ├── fr.json │ │ ├── hu.json │ │ ├── it.json │ │ ├── jp.json │ │ ├── nl.json │ │ ├── pl.json │ │ ├── pt-br.json │ │ ├── ru.json │ │ ├── sk.json │ │ ├── sl.json │ │ ├── tr.json │ │ ├── zh-tw.json │ │ └── zh.json │ ├── Ui/ │ │ ├── UiRequest.py │ │ ├── UiServer.py │ │ ├── UiWebsocket.py │ │ ├── __init__.py │ │ ├── media/ │ │ │ ├── Fixbutton.coffee │ │ │ ├── Infopanel.coffee │ │ │ ├── Loading.coffee │ │ │ ├── Notifications.coffee │ │ │ ├── Wrapper.coffee │ │ │ ├── Wrapper.css │ │ │ ├── WrapperZeroFrame.coffee │ │ │ ├── ZeroSiteTheme.coffee │ │ │ ├── all.css │ │ │ ├── all.js │ │ │ ├── img/ │ │ │ │ ├── favicon.psd │ │ │ │ └── logo.psd │ │ │ └── lib/ │ │ │ ├── RateLimit.coffee │ │ │ ├── Translate.coffee │ │ │ ├── ZeroWebsocket.coffee │ │ │ ├── jquery.cssanim.js │ │ │ ├── jquery.csslater.coffee │ │ │ └── jquery.easing.js │ │ └── template/ │ │ ├── site_add.html │ │ └── wrapper.html │ ├── User/ │ │ ├── User.py │ │ ├── UserManager.py │ │ └── __init__.py │ ├── Worker/ │ │ ├── Worker.py │ │ ├── WorkerManager.py │ │ ├── WorkerTaskManager.py │ │ └── __init__.py │ ├── __init__.py │ ├── lib/ │ │ ├── __init__.py │ │ ├── bencode_open/ │ │ │ ├── LICENSE │ │ │ └── __init__.py │ │ ├── cssvendor/ │ │ │ ├── __init__.py │ │ │ └── cssvendor.py │ │ ├── gevent_ws/ │ │ │ └── __init__.py │ │ ├── libsecp256k1message/ │ │ │ ├── __init__.py │ │ │ └── libsecp256k1message.py │ │ ├── openssl/ │ │ │ └── openssl.cnf │ │ ├── pyaes/ │ │ │ ├── LICENSE.txt │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── aes.py │ │ │ ├── blockfeeder.py │ │ │ └── util.py │ │ ├── sslcrypto/ │ │ │ ├── LICENSE │ │ │ ├── __init__.py │ │ │ ├── _aes.py │ │ │ ├── _ecc.py │ │ │ ├── _ripemd.py │ │ │ ├── fallback/ │ │ │ │ ├── __init__.py │ │ │ │ ├── _jacobian.py │ │ │ │ ├── _util.py │ │ │ │ ├── aes.py │ │ │ │ ├── ecc.py │ │ │ │ └── rsa.py │ │ │ └── openssl/ │ │ │ ├── __init__.py │ │ │ ├── aes.py │ │ │ ├── discovery.py │ │ │ ├── ecc.py │ │ │ ├── library.py │ │ │ └── rsa.py │ │ └── subtl/ │ │ ├── LICENCE │ │ ├── README.md │ │ ├── __init__.py │ │ └── subtl.py │ ├── main.py │ └── util/ │ ├── Cached.py │ ├── Diff.py │ ├── Electrum.py │ ├── Event.py │ ├── Flag.py │ ├── GreenletManager.py │ ├── Msgpack.py │ ├── Noparallel.py │ ├── OpensslFindPatch.py │ ├── Platform.py │ ├── Pooled.py │ ├── QueryJson.py │ ├── RateLimit.py │ ├── SafeRe.py │ ├── SocksProxy.py │ ├── ThreadPool.py │ ├── UpnpPunch.py │ ├── __init__.py │ └── helper.py ├── start.py ├── tools/ │ └── coffee/ │ ├── README.md │ ├── coffee-script.js │ ├── coffee.cmd │ └── coffee.wsf ├── update.py └── zeronet.py ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/FUNDING.yml ================================================ custom: https://zeronet.io/docs/help_zeronet/donate/ ================================================ FILE: .github/ISSUE_TEMPLATE/bug-report.md ================================================ --- name: Bug report about: Create a report to help us improve ZeroNet title: '' labels: '' assignees: '' --- ### Step 1: Please describe your environment * ZeroNet version: _____ * Operating system: _____ * Web browser: _____ * Tor status: not available/always/disabled * Opened port: yes/no * Special configuration: ____ ### Step 2: Describe the problem: #### Steps to reproduce: 1. _____ 2. _____ 3. _____ #### Observed Results: * What happened? This could be a screenshot, a description, log output (you can send log/debug.log file to hello@zeronet.io if necessary), etc. #### Expected Results: * What did you expect to happen? ================================================ FILE: .github/ISSUE_TEMPLATE/feature_request.md ================================================ --- name: Feature request about: Suggest an idea for ZeroNet title: '' labels: '' assignees: '' --- **Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] **Describe the solution you'd like** A clear and concise description of what you want to happen. **Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered. **Additional context** Add any other context or screenshots about the feature request here. ================================================ FILE: .github/workflows/tests.yml ================================================ name: tests on: [push, pull_request] jobs: test: runs-on: ubuntu-16.04 strategy: max-parallel: 16 matrix: python-version: [3.5, 3.6, 3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v1 with: python-version: ${{ matrix.python-version }} - name: Prepare for installation run: | python3 -m pip install setuptools python3 -m pip install --upgrade pip wheel python3 -m pip install --upgrade codecov coveralls flake8 mock pytest==4.6.3 pytest-cov selenium - name: Install run: | python3 -m pip install --upgrade -r requirements.txt python3 -m pip list - name: Prepare for tests run: | openssl version -a echo 0 | sudo tee /proc/sys/net/ipv6/conf/all/disable_ipv6 - name: Test run: | catchsegv python3 -m pytest src/Test --cov=src --cov-config src/Test/coverage.ini export ZERONET_LOG_DIR="log/CryptMessage"; catchsegv python3 -m pytest -x plugins/CryptMessage/Test export ZERONET_LOG_DIR="log/Bigfile"; catchsegv python3 -m pytest -x plugins/Bigfile/Test export ZERONET_LOG_DIR="log/AnnounceLocal"; catchsegv python3 -m pytest -x plugins/AnnounceLocal/Test export ZERONET_LOG_DIR="log/OptionalManager"; catchsegv python3 -m pytest -x plugins/OptionalManager/Test export ZERONET_LOG_DIR="log/Multiuser"; mv plugins/disabled-Multiuser plugins/Multiuser && catchsegv python -m pytest -x plugins/Multiuser/Test export ZERONET_LOG_DIR="log/Bootstrapper"; mv plugins/disabled-Bootstrapper plugins/Bootstrapper && catchsegv python -m pytest -x plugins/Bootstrapper/Test find src -name "*.json" | xargs -n 1 python3 -c "import json, sys; print(sys.argv[1], end=' '); json.load(open(sys.argv[1])); print('[OK]')" find plugins -name "*.json" | xargs -n 1 python3 -c "import json, sys; print(sys.argv[1], end=' '); json.load(open(sys.argv[1])); print('[OK]')" flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics --exclude=src/lib/pyaes/ ================================================ FILE: .gitignore ================================================ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] # Log files **/*.log # Hidden files .* !/.github !/.gitignore !/.travis.yml !/.gitlab-ci.yml # Temporary files *.bak # Data dir data/* *.db # Virtualenv env/* # Tor data tools/tor/data # PhantomJS, downloaded manually for unit tests tools/phantomjs # ZeroNet config file zeronet.conf # ZeroNet log files log/* ================================================ FILE: .gitlab-ci.yml ================================================ stages: - test .test_template: &test_template stage: test before_script: - pip install --upgrade pip wheel # Selenium and requests can't be installed without a requests hint on Python 3.4 - pip install --upgrade requests>=2.22.0 - pip install --upgrade codecov coveralls flake8 mock pytest==4.6.3 pytest-cov selenium - pip install --upgrade -r requirements.txt script: - pip list - openssl version -a - python -m pytest -x plugins/CryptMessage/Test --color=yes - python -m pytest -x plugins/Bigfile/Test --color=yes - python -m pytest -x plugins/AnnounceLocal/Test --color=yes - python -m pytest -x plugins/OptionalManager/Test --color=yes - python -m pytest src/Test --cov=src --cov-config src/Test/coverage.ini --color=yes - mv plugins/disabled-Multiuser plugins/Multiuser - python -m pytest -x plugins/Multiuser/Test --color=yes - mv plugins/disabled-Bootstrapper plugins/Bootstrapper - python -m pytest -x plugins/Bootstrapper/Test --color=yes - flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics --exclude=src/lib/pyaes/ test:py3.4: image: python:3.4.3 <<: *test_template test:py3.5: image: python:3.5.7 <<: *test_template test:py3.6: image: python:3.6.9 <<: *test_template test:py3.7-openssl1.1.0: image: python:3.7.0b5 <<: *test_template test:py3.7-openssl1.1.1: image: python:3.7.4 <<: *test_template test:py3.8: image: python:3.8.0b3 <<: *test_template ================================================ FILE: .travis.yml ================================================ language: python python: - 3.4 - 3.5 - 3.6 - 3.7 - 3.8 services: - docker cache: pip before_install: - pip install --upgrade pip wheel - pip install --upgrade codecov coveralls flake8 mock pytest==4.6.3 pytest-cov selenium # - docker build -t zeronet . # - docker run -d -v $PWD:/root/data -p 15441:15441 -p 127.0.0.1:43110:43110 zeronet install: - pip install --upgrade -r requirements.txt - pip list before_script: - openssl version -a # Add an IPv6 config - see the corresponding Travis issue # https://github.com/travis-ci/travis-ci/issues/8361 - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6'; fi script: - catchsegv python -m pytest src/Test --cov=src --cov-config src/Test/coverage.ini - export ZERONET_LOG_DIR="log/CryptMessage"; catchsegv python -m pytest -x plugins/CryptMessage/Test - export ZERONET_LOG_DIR="log/Bigfile"; catchsegv python -m pytest -x plugins/Bigfile/Test - export ZERONET_LOG_DIR="log/AnnounceLocal"; catchsegv python -m pytest -x plugins/AnnounceLocal/Test - export ZERONET_LOG_DIR="log/OptionalManager"; catchsegv python -m pytest -x plugins/OptionalManager/Test - export ZERONET_LOG_DIR="log/Multiuser"; mv plugins/disabled-Multiuser plugins/Multiuser && catchsegv python -m pytest -x plugins/Multiuser/Test - export ZERONET_LOG_DIR="log/Bootstrapper"; mv plugins/disabled-Bootstrapper plugins/Bootstrapper && catchsegv python -m pytest -x plugins/Bootstrapper/Test - find src -name "*.json" | xargs -n 1 python3 -c "import json, sys; print(sys.argv[1], end=' '); json.load(open(sys.argv[1])); print('[OK]')" - find plugins -name "*.json" | xargs -n 1 python3 -c "import json, sys; print(sys.argv[1], end=' '); json.load(open(sys.argv[1])); print('[OK]')" - flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics --exclude=src/lib/pyaes/ after_failure: - zip -r log.zip log/ - curl --upload-file ./log.zip https://transfer.sh/log.zip after_success: - codecov - coveralls --rcfile=src/Test/coverage.ini notifications: email: recipients: hello@zeronet.io on_success: change ================================================ FILE: CHANGELOG.md ================================================ ### ZeroNet 0.7.2 (2020-09-?) Rev4206? ### ZeroNet 0.7.1 (2019-07-01) Rev4206 ### Added - Built-in logging console in the web UI to see what's happening in the background. (pull down top-right 0 button to see it) - Display database rebuild errors [Thanks to Lola] - New plugin system that allows to install and manage builtin/third party extensions to the ZeroNet client using the web interface. - Support multiple trackers_file - Add OpenSSL 1.1 support to CryptMessage plugin based on Bitmessage modifications [Thanks to radfish] - Display visual error message on startup errors - Fix max opened files changing on Windows platform - Display TLS1.3 compatibility on /Stats page - Add fake SNI and ALPN to peer connections to make it more like standard https connections - Hide and ignore tracker_proxy setting in Tor: Always mode as it's going to use Tor anyway. - Deny websocket connections from unknown origins - Restrict open_browser values to avoid RCE on sandbox escape - Offer access web interface by IP address in case of unknown host - Link to site's sidebar with "#ZeroNet:OpenSidebar" hash ### Changed - Allow .. in file names [Thanks to imachug] - Change unstable trackers - More clean errors on sites.json/users.json load error - Various tweaks for tracker rating on unstable connections - Use OpenSSL 1.1 dlls from default Python Windows distribution if possible - Re-factor domain resolving for easier domain plugins - Disable UDP connections if --proxy is used - New, decorator-based Websocket API permission system to avoid future typo mistakes ### Fixed - Fix parsing config lines that have no value - Fix start.py [Thanks to imachug] - Allow multiple values of the same key in the config file [Thanks ssdifnskdjfnsdjk for reporting] - Fix parsing config file lines that has % in the value [Thanks slrslr for reporting] - Fix bootstrapper plugin hash reloads [Thanks geekless for reporting] - Fix CryptMessage plugin OpenSSL dll loading on Windows (ZeroMail errors) [Thanks cxgreat2014 for reporting] - Fix startup error when using OpenSSL 1.1 [Thanks to imachug] - Fix a bug that did not loaded merged site data for 5 sec after the merged site got added - Fix typo that allowed to add new plugins in public proxy mode. [Thanks styromaniac for reporting] - Fix loading non-big files with "|all" postfix [Thanks to krzotr] - Fix OpenSSL cert generation error crash by change Windows console encoding to utf8 #### Wrapper html injection vulnerability [Reported by ivanq] In ZeroNet before rev4188 the wrapper template variables was rendered incorrectly. Result: The opened site was able to gain WebSocket connection with unrestricted ADMIN/NOSANDBOX access, change configuration values and possible RCE on client's machine. Fix: Fixed the template rendering code, disallowed WebSocket connections from unknown locations, restricted open_browser configuration values to avoid possible RCE in case of sandbox escape. Note: The fix is also back ported to ZeroNet Py 2.x version (Rev3870) ### ZeroNet 0.7.0 (2019-06-12) Rev4106 (First release targeting Python 3.4+) ### Added - 5-10x faster signature verification by using libsecp256k1 (Thanks to ZeroMux) - Generated SSL certificate randomization to avoid protocol filters (Thanks to ValdikSS) - Offline mode - P2P source code update using ZeroNet protocol - ecdsaSign/Verify commands to CryptMessage plugin (Thanks to imachug) - Efficient file rename: change file names instead of re-downloading the file. - Make redirect optional on site cloning (Thanks to Lola) - EccPrivToPub / EccPubToPriv functions (Thanks to imachug) - Detect and change dark/light theme based on OS setting (Thanks to filips123) ### Changed - Re-factored code to Python3 runtime (compatible with Python 3.4-3.8) - More safe database sync mode - Removed bundled third-party libraries where it's possible - Use lang=en instead of lang={lang} in urls to avoid url encode problems - Remove environment details from error page - Don't push content.json updates larger than 10kb to significantly reduce bw usage for site with many files ### Fixed - Fix sending files with \0 characters - Security fix: Escape error detail to avoid XSS (reported by krzotr) - Fix signature verification using libsecp256k1 for compressed addresses (mostly certificates generated in the browser) - Fix newsfeed if you have more than 1000 followed topic/post on one site. - Fix site download as zip file - Fix displaying sites with utf8 title - Error message if dbRebuild fails (Thanks to Lola) - Fix browser reopen if executing start.py again. (Thanks to imachug) ### ZeroNet 0.6.5 (2019-02-16) Rev3851 (Last release targeting Python 2.7.x) ### Added - IPv6 support in peer exchange, bigfiles, optional file finding, tracker sharing, socket listening and connecting (based on tangdou1 modifications) - New tracker database format with IPv6 support - Display notification if there is an unpublished modification for your site - Listen and shut down normally for SIGTERM (Thanks to blurHY) - Support tilde `~` in filenames (by d14na) - Support map for Namecoin subdomain names (Thanks to lola) - Add log level to config page - Support `{data}` for data dir variable in trackers_file value - Quick check content.db on startup and rebuild if necessary - Don't show meek proxy option if the tor client does not supports it ### Changed - Refactored port open checking with IPv6 support - Consider non-local IPs as external even is the open port check fails (for CJDNS and Yggdrasil support) - Add IPv6 tracker and change unstable tracker - Don't correct sent local time with the calculated time correction - Disable CSP for Edge - Only support CREATE commands in dbschema indexes node and SELECT from storage.query ### Fixed - Check the length of master seed when executing cryptGetPrivatekey CLI command - Only reload source code on file modification / creation - Detection and issue warning for latest no-script plugin - Fix atomic write of a non-existent file - Fix sql queries with lots of variables and sites with lots of content.json - Fix multi-line parsing of zeronet.conf - Fix site deletion from users.json - Fix site cloning before site downloaded (Reported by unsystemizer) - Fix queryJson for non-list nodes (Reported by MingchenZhang) ## ZeroNet 0.6.4 (2018-10-20) Rev3660 ### Added - New plugin: UiConfig. A web interface that allows changing ZeroNet settings. - New plugin: AnnounceShare. Share trackers between users, automatically announce client's ip as tracker if Bootstrapper plugin is enabled. - Global tracker stats on ZeroHello: Include statistics from all served sites instead of displaying request statistics only for one site. - Support custom proxy for trackers. (Configurable with /Config) - Adding peers to sites manually using zeronet_peers get parameter - Copy site address with peers link on the sidebar. - Zip file listing and streaming support for Bigfiles. - Tracker statistics on /Stats page - Peer reputation save/restore to speed up sync time after startup. - Full support fileGet, fileList, dirList calls on tar.gz/zip files. - Archived_before support to user content rules to allow deletion of all user files before the specified date - Show and manage "Connecting" sites on ZeroHello - Add theme support to ZeroNet sites - Dark theme for ZeroHello, ZeroBlog, ZeroTalk ### Changed - Dynamic big file allocation: More efficient storage usage by don't pre-allocate the whole file at the beginning, but expand the size as the content downloads. - Reduce the request frequency to unreliable trackers. - Only allow 5 concurrent checkSites to run in parallel to reduce load under Tor/slow connection. - Stop site downloading if it reached 95% of site limit to avoid download loop for sites out of limit - The pinned optional files won't be removed from download queue after 30 retries and won't be deleted even if the site owner removes it. - Don't remove incomplete (downloading) sites on startup - Remove --pin_bigfile argument as big files are automatically excluded from optional files limit. ### Fixed - Trayicon compatibility with latest gevent - Request number counting for zero:// trackers - Peer reputation boost for zero:// trackers. - Blocklist of peers loaded from peerdb (Thanks tangdou1 for report) - Sidebar map loading on foreign languages (Thx tangdou1 for report) - FileGet on non-existent files (Thanks mcdev for reporting) - Peer connecting bug for sites with low amount of peers #### "The Vacation" Sandbox escape bug [Reported by GitCenter / Krixano / ZeroLSTN] In ZeroNet 0.6.3 Rev3615 and earlier as a result of invalid file type detection, a malicious site could escape the iframe sandbox. Result: Browser iframe sandbox escape Applied fix: Replaced the previous, file extension based file type identification with a proper one. Affected versions: All versions before ZeroNet Rev3616 ## ZeroNet 0.6.3 (2018-06-26) ### Added - New plugin: ContentFilter that allows to have shared site and user block list. - Support Tor meek proxies to avoid tracker blocking of GFW - Detect network level tracker blocking and easy setting meek proxy for tracker connections. - Support downloading 2GB+ sites as .zip (Thx to Radtoo) - Support ZeroNet as a transparent proxy (Thx to JeremyRand) - Allow fileQuery as CORS command (Thx to imachug) - Windows distribution includes Tor and meek client by default - Download sites as zip link to sidebar - File server port randomization - Implicit SSL for all connection - fileList API command for zip files - Auto download bigfiles size limit on sidebar - Local peer number to the sidebar - Open site directory button in sidebar ### Changed - Switched to Azure Tor meek proxy as Amazon one became unavailable - Refactored/rewritten tracker connection manager - Improved peer discovery for optional files without opened port - Also delete Bigfile's piecemap on deletion ### Fixed - Important security issue: Iframe sandbox escape [Reported by Ivanq / gitcenter] - Local peer discovery when running multiple clients on the same machine - Uploading small files with Bigfile plugin - Ctrl-c shutdown when running CLI commands - High CPU/IO usage when Multiuser plugin enabled - Firefox back button - Peer discovery on older Linux kernels - Optional file handling when multiple files have the same hash_id (first 4 chars of the hash) - Msgpack 0.5.5 and 0.5.6 compatibility ## ZeroNet 0.6.2 (2018-02-18) ### Added - New plugin: AnnounceLocal to make ZeroNet work without an internet connection on the local network. - Allow dbQuey and userGetSettings using the `as` API command on different sites with Cors permission - New config option: `--log_level` to reduce log verbosity and IO load - Prefer to connect to recent peers from trackers first - Mark peers with port 1 is also unconnectable for future fix for trackers that do not support port 0 announce ### Changed - Don't keep connection for sites that have not been modified in the last week - Change unreliable trackers to new ones - Send maximum 10 findhash request in one find optional files round (15sec) - Change "Unique to site" to "No certificate" for default option in cert selection dialog. - Dont print warnings if not in debug mode - Generalized tracker logging format - Only recover sites from sites.json if they had peers - Message from local peers does not means internet connection - Removed `--debug_gevent` and turned on Gevent block logging by default ### Fixed - Limit connections to 512 to avoid reaching 1024 limit on windows - Exception when logging foreign operating system socket errors - Don't send private (local) IPs on pex - Don't connect to private IPs in tor always mode - Properly recover data from msgpack unpacker on file stream start - Symlinked data directory deletion when deleting site using Windows - De-duplicate peers before publishing - Bigfile info for non-existing files ## ZeroNet 0.6.1 (2018-01-25) ### Added - New plugin: Chart - Collect and display charts about your contribution to ZeroNet network - Allow list as argument replacement in sql queries. (Thanks to imachug) - Newsfeed query time statistics (Click on "From XX sites in X.Xs on ZeroHello) - New UiWebsocket API command: As to run commands as other site - Ranged ajax queries for big files - Filter feed by type and site address - FileNeed, Bigfile upload command compatibility with merger sites - Send event on port open / tor status change - More description on permission request ### Changed - Reduce memory usage of sidebar geoip database cache - Change unreliable tracker to new one - Don't display Cors permission ask if it already granted - Avoid UI blocking when rebuilding a merger site - Skip listing ignored directories on signing - In Multiuser mode show the seed welcome message when adding new certificate instead of first visit - Faster async port opening on multiple network interfaces - Allow javascript modals - Only zoom sidebar globe if mouse button is pressed down ### Fixed - Open port checking error reporting (Thanks to imachug) - Out-of-range big file requests - Don't output errors happened on gevent greenlets twice - Newsfeed skip sites with no database - Newsfeed queries with multiple params - Newsfeed queries with UNION and UNION ALL - Fix site clone with sites larger that 10MB - Unreliable Websocket connection when requesting files from different sites at the same time ## ZeroNet 0.6.0 (2017-10-17) ### Added - New plugin: Big file support - Automatic pinning on Big file download - Enable TCP_NODELAY for supporting sockets - actionOptionalFileList API command arguments to list non-downloaded files or only big files - serverShowdirectory API command arguments to allow to display site's directory in OS file browser - fileNeed API command to initialize optional file downloading - wrapperGetAjaxKey API command to request nonce for AJAX request - Json.gz support for database files - P2P port checking (Thanks for grez911) - `--download_optional auto` argument to enable automatic optional file downloading for newly added site - Statistics for big files and protocol command requests on /Stats - Allow to set user limitation based on auth_address ### Changed - More aggressive and frequent connection timeout checking - Use out of msgpack context file streaming for files larger than 512KB - Allow optional files workers over the worker limit - Automatic redirection to wrapper on nonce_error - Send websocket event on optional file deletion - Optimize sites.json saving - Enable faster C-based msgpack packer by default - Major optimization on Bootstrapper plugin SQL queries - Don't reset bad file counter on restart, to allow easier give up on unreachable files - Incoming connection limit changed from 1000 to 500 to avoid reaching socket limit on Windows - Changed tracker boot.zeronet.io domain, because zeronet.io got banned in some countries #### Fixed - Sub-directories in user directories ## ZeroNet 0.5.7 (2017-07-19) ### Added - New plugin: CORS to request read permission to other site's content - New API command: userSetSettings/userGetSettings to store site's settings in users.json - Avoid file download if the file size does not match with the requested one - JavaScript and wrapper less file access using /raw/ prefix ([Example](http://127.0.0.1:43110/raw/1AsRLpuRxr3pb9p3TKoMXPSWHzh6i7fMGi/en.tar.gz/index.html)) - --silent command line option to disable logging to stdout ### Changed - Better error reporting on sign/verification errors - More test for sign and verification process - Update to OpenSSL v1.0.2l - Limit compressed files to 6MB to avoid zip/tar.gz bomb - Allow space, [], () characters in filenames - Disable cross-site resource loading to improve privacy. [Reported by Beardog108] - Download directly accessed Pdf/Svg/Swf files instead of displaying them to avoid wrapper escape using in JS in SVG file. [Reported by Beardog108] - Disallow potentially unsafe regular expressions to avoid ReDoS [Reported by MuxZeroNet] ### Fixed - Detecting data directory when running Windows distribution exe [Reported by Plasmmer] - OpenSSL loading under Android 6+ - Error on exiting when no connection server started ## ZeroNet 0.5.6 (2017-06-15) ### Added - Callback for certSelect API command - More compact list formatting in json ### Changed - Remove obsolete auth_key_sha512 and signature format - Improved Spanish translation (Thanks to Pupiloho) ### Fixed - Opened port checking (Thanks l5h5t7 & saber28 for reporting) - Standalone update.py argument parsing (Thanks Zalex for reporting) - uPnP crash on startup (Thanks Vertux for reporting) - CoffeeScript 1.12.6 compatibility (Thanks kavamaken & imachug) - Multi value argument parsing - Database error when running from directory that contains special characters (Thanks Pupiloho for reporting) - Site lock violation logging #### Proxy bypass during source upgrade [Reported by ZeroMux] In ZeroNet before 0.5.6 during the client's built-in source code upgrade mechanism, ZeroNet did not respect Tor and/or proxy settings. Result: ZeroNet downloaded the update without using the Tor network and potentially leaked the connections. Fix: Removed the problematic code line from the updater that removed the proxy settings from the socket library. Affected versions: ZeroNet 0.5.5 and earlier, Fixed in: ZeroNet 0.5.6 #### XSS vulnerability using DNS rebinding. [Reported by Beardog108] In ZeroNet before 0.5.6 the web interface did not validate the request's Host parameter. Result: An attacker using a specially crafted DNS entry could have bypassed the browser's cross-site-scripting protection and potentially gained access to user's private data stored on site. Fix: By default ZeroNet only accept connections from 127.0.0.1 and localhost hosts. If you bind the ui server to an external interface, then it also adds the first http request's host to the allowed host list or you can define it manually using --ui_host. Affected versions: ZeroNet 0.5.5 and earlier, Fixed in: ZeroNet 0.5.6 ## ZeroNet 0.5.5 (2017-05-18) ### Added - Outgoing socket binding by --bind parameter - Database rebuilding progress bar - Protect low traffic site's peers from cleanup closing - Local site blacklisting - Cloned site source code upgrade from parent - Input placeholder support for displayPrompt - Alternative interaction for wrapperConfirm ### Changed - New file priorities for faster site display on first visit - Don't add ? to url if push/replaceState url starts with # ### Fixed - PermissionAdd/Remove admin command requirement - Multi-line confirmation dialog ## ZeroNet 0.5.4 (2017-04-14) ### Added - Major speed and CPU usage enhancements in Tor always mode - Send skipped modifications to outdated clients ### Changed - Upgrade libs to latest version - Faster port opening and closing - Deny site limit modification in MultiUser mode ### Fixed - Filling database from optional files - OpenSSL detection on systems with OpenSSL 1.1 - Users.json corruption on systems with slow hdd - Fix leaking files in data directory by webui ## ZeroNet 0.5.3 (2017-02-27) ### Added - Tar.gz/zip packed site support - Utf8 filenames in archive files - Experimental --db_mode secure database mode to prevent data loss on systems with unreliable power source. - Admin user support in MultiUser mode - Optional deny adding new sites in MultiUser mode ### Changed - Faster update and publish times by new socket sharing algorithm ### Fixed - Fix missing json_row errors when using Mute plugin ## ZeroNet 0.5.2 (2017-02-09) ### Added - User muting - Win/Mac signed exe/.app - Signed commits ### Changed - Faster site updates after startup - New macOS package for 10.10 compatibility ### Fixed - Fix "New version just released" popup on page first visit - Fix disappearing optional files bug (Thanks l5h5t7 for reporting) - Fix skipped updates on unreliable connections (Thanks P2P for reporting) - Sandbox escape security fix (Thanks Firebox for reporting) - Fix error reporting on async websocket functions ## ZeroNet 0.5.1 (2016-11-18) ### Added - Multi language interface - New plugin: Translation helper for site html and js files - Per-site favicon ### Fixed - Parallel optional file downloading ## ZeroNet 0.5.0 (2016-11-08) ### Added - New Plugin: Allow list/delete/pin/manage files on ZeroHello - New API commands to follow user's optional files, and query stats for optional files - Set total size limit on optional files. - New Plugin: Save peers to database and keep them between restarts to allow more faster optional file search and make it work without trackers - Rewritten uPnP port opener + close port on exit (Thanks to sirMackk!) - Lower memory usage by lazy PeerHashfield creation - Loaded json files statistics and database info at /Stats page ### Changed - Separate lock file for better Windows compatibility - When executing start.py open browser even if ZeroNet is already running - Keep plugin order after reload to allow plugins to extends an another plug-in - Only save sites.json if fully loaded to avoid data loss - Change aletorrenty tracker to a more reliable one - Much lower findhashid CPU usage - Pooled downloading of large amount of optional files - Lots of other optional file changes to make it better - If we have 1000 peers for a site make cleanup more aggressive - Use warning instead of error on verification errors - Push updates to newer clients first - Bad file reset improvements ### Fixed - Fix site deletion errors on startup - Delay websocket messages until it's connected - Fix database import if data file contains extra data - Fix big site download - Fix diff sending bug (been chasing it for a long time) - Fix random publish errors when json file contained [] characters - Fix site delete and siteCreate bug - Fix file write confirmation dialog ## ZeroNet 0.4.1 (2016-09-05) ### Added - Major core changes to allow fast startup and lower memory usage - Try to reconnect to Tor on lost connection - Sidebar fade-in - Try to avoid incomplete data files overwrite - Faster database open - Display user file sizes in sidebar - Concurrent worker number depends on --connection_limit ### Changed - Close databases after 5 min idle time - Better site size calculation - Allow "-" character in domains - Always try to keep connections for sites - Remove merger permission from merged sites - Newsfeed scans only last 3 days to speed up database queries - Updated ZeroBundle-win to Python 2.7.12 ### Fixed - Fix for important security problem, which is allowed anyone to publish new content without valid certificate from ID provider. Thanks Kaffie for pointing it out! - Fix sidebar error when no certificate provider selected - Skip invalid files on database rebuilding - Fix random websocket connection error popups - Fix new siteCreate command - Fix site size calculation - Fix port open checking after computer wake up - Fix --size_limit parsing from command line ## ZeroNet 0.4.0 (2016-08-11) ### Added - Merger site plugin - Live source code reloading: Faster core development by allowing me to make changes in ZeroNet source code without restarting it. - New json table format for merger sites - Database rebuild from sidebar. - Allow to store custom data directly in json table: Much simpler and faster SQL queries. - User file archiving: Allows the site owner to archive inactive user's content into single file. (Reducing initial sync time/cpu/memory usage) - Also trigger onUpdated/update database on file delete. - Permission request from ZeroFrame API. - Allow to store extra data in content.json using fileWrite API command. - Faster optional files downloading - Use alternative sources (Gogs, Gitlab) to download updates - Track provided sites/connection and prefer to keep the ones with more sites to reduce connection number ### Changed - Keep at least 5 connection per site - Changed target connection for sites to 10 from 15 - ZeroHello search function stability/speed improvements - Improvements for clients with slower HDD ### Fixed - Fix IE11 wrapper nonce errors - Fix sidebar on mobile devices - Fix site size calculation - Fix IE10 compatibility - Windows XP ZeroBundle compatibility (THX to people of China) ## ZeroNet 0.3.7 (2016-05-27) ### Changed - Patch command to reduce bandwidth usage by transfer only the changed lines - Other cpu/memory optimizations ## ZeroNet 0.3.6 (2016-05-27) ### Added - New ZeroHello - Newsfeed function ### Fixed - Security fixes ## ZeroNet 0.3.5 (2016-02-02) ### Added - Full Tor support with .onion hidden services - Bootstrap using ZeroNet protocol ### Fixed - Fix Gevent 1.0.2 compatibility ## ZeroNet 0.3.4 (2015-12-28) ### Added - AES, ECIES API function support - PushState and ReplaceState url manipulation support in API - Multiuser localstorage ================================================ FILE: COPYING ================================================ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ================================================ FILE: Dockerfile ================================================ FROM alpine:3.11 #Base settings ENV HOME /root COPY requirements.txt /root/requirements.txt #Install ZeroNet RUN apk --update --no-cache --no-progress add python3 python3-dev gcc libffi-dev musl-dev make tor openssl \ && pip3 install -r /root/requirements.txt \ && apk del python3-dev gcc libffi-dev musl-dev make \ && echo "ControlPort 9051" >> /etc/tor/torrc \ && echo "CookieAuthentication 1" >> /etc/tor/torrc RUN python3 -V \ && python3 -m pip list \ && tor --version \ && openssl version #Add Zeronet source COPY . /root VOLUME /root/data #Control if Tor proxy is started ENV ENABLE_TOR false WORKDIR /root #Set upstart command CMD (! ${ENABLE_TOR} || tor&) && python3 zeronet.py --ui_ip 0.0.0.0 --fileserver_port 26552 #Expose ports EXPOSE 43110 26552 ================================================ FILE: Dockerfile.arm64v8 ================================================ FROM alpine:3.12 #Base settings ENV HOME /root COPY requirements.txt /root/requirements.txt #Install ZeroNet RUN apk --update --no-cache --no-progress add python3 python3-dev gcc libffi-dev musl-dev make tor openssl \ && pip3 install -r /root/requirements.txt \ && apk del python3-dev gcc libffi-dev musl-dev make \ && echo "ControlPort 9051" >> /etc/tor/torrc \ && echo "CookieAuthentication 1" >> /etc/tor/torrc RUN python3 -V \ && python3 -m pip list \ && tor --version \ && openssl version #Add Zeronet source COPY . /root VOLUME /root/data #Control if Tor proxy is started ENV ENABLE_TOR false WORKDIR /root #Set upstart command CMD (! ${ENABLE_TOR} || tor&) && python3 zeronet.py --ui_ip 0.0.0.0 --fileserver_port 26552 #Expose ports EXPOSE 43110 26552 ================================================ FILE: LICENSE ================================================ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Additional Conditions : Contributing to this repo This repo is governed by GPLv3, same is located at the root of the ZeroNet git repo, unless specified separately all code is governed by that license, contributions to this repo are divided into two key types, key contributions and non-key contributions, key contributions are which, directly affects the code performance, quality and features of software, non key contributions include things like translation datasets, image, graphic or video contributions that does not affect the main usability of software but improves the existing usability of certain thing or feature, these also include tests written with code, since their purpose is to check, whether something is working or not as intended. All the non-key contributions are governed by [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/), unless specified above, a contribution is ruled by the type of contribution if there is a conflict between two contributing parties of repo in any case. ================================================ FILE: README-ru.md ================================================ # ZeroNet [![Build Status](https://travis-ci.org/HelloZeroNet/ZeroNet.svg?branch=master)](https://travis-ci.org/HelloZeroNet/ZeroNet) [![Documentation](https://img.shields.io/badge/docs-faq-brightgreen.svg)](https://zeronet.io/docs/faq/) [![Help](https://img.shields.io/badge/keep_this_project_alive-donate-yellow.svg)](https://zeronet.io/docs/help_zeronet/donate/) [简体中文](./README-zh-cn.md) [English](./README.md) Децентрализованные вебсайты использующие Bitcoin криптографию и BitTorrent сеть - https://zeronet.io ## Зачем? * Мы верим в открытую, свободную, и не отцензуренную сеть и коммуникацию. * Нет единой точки отказа: Сайт онлайн пока по крайней мере 1 пир обслуживает его. * Никаких затрат на хостинг: Сайты обслуживаются посетителями. * Невозможно отключить: Он нигде, потому что он везде. * Быстр и работает оффлайн: Вы можете получить доступ к сайту, даже если Интернет недоступен. ## Особенности * Обновляемые в реальном времени сайты * Поддержка Namecoin .bit доменов * Лёгок в установке: распаковал & запустил * Клонирование вебсайтов в один клик * Password-less [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) based authorization: Ваша учетная запись защищена той же криптографией, что и ваш Bitcoin-кошелек * Встроенный SQL-сервер с синхронизацией данных P2P: Позволяет упростить разработку сайта и ускорить загрузку страницы * Анонимность: Полная поддержка сети Tor с помощью скрытых служб .onion вместо адресов IPv4 * TLS зашифрованные связи * Автоматическое открытие uPnP порта * Плагин для поддержки многопользовательской (openproxy) * Работает с любыми браузерами и операционными системами ## Как это работает? * После запуска `zeronet.py` вы сможете посетить зайты (zeronet сайты) используя адрес `http://127.0.0.1:43110/{zeronet_address}` (например. `http://127.0.0.1:43110/1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D`). * Когда вы посещаете новый сайт zeronet, он пытается найти пиров с помощью BitTorrent чтобы загрузить файлы сайтов (html, css, js ...) из них. * Каждый посещенный зайт также обслуживается вами. (Т.е хранится у вас на компьютере) * Каждый сайт содержит файл `content.json`, который содержит все остальные файлы в хэше sha512 и подпись, созданную с использованием частного ключа сайта. * Если владелец сайта (у которого есть закрытый ключ для адреса сайта) изменяет сайт, то он/она подписывает новый `content.json` и публикует его для пиров. После этого пиры проверяют целостность `content.json` (используя подпись), они загружают измененные файлы и публикуют новый контент для других пиров. #### [Слайд-шоу о криптографии ZeroNet, обновлениях сайтов, многопользовательских сайтах »](https://docs.google.com/presentation/d/1_2qK1IuOKJ51pgBvllZ9Yu7Au2l551t3XBgyTSvilew/pub?start=false&loop=false&delayms=3000) #### [Часто задаваемые вопросы »](https://zeronet.io/docs/faq/) #### [Документация разработчика ZeroNet »](https://zeronet.io/docs/site_development/getting_started/) ## Скриншоты ![Screenshot](https://i.imgur.com/H60OAHY.png) ![ZeroTalk](https://zeronet.io/docs/img/zerotalk.png) #### [Больше скриншотов в ZeroNet документации »](https://zeronet.io/docs/using_zeronet/sample_sites/) ## Как вступить * Скачайте ZeroBundle пакет: * [Microsoft Windows](https://github.com/HelloZeroNet/ZeroNet-win/archive/dist/ZeroNet-win.zip) * [Apple macOS](https://github.com/HelloZeroNet/ZeroNet-mac/archive/dist/ZeroNet-mac.zip) * [Linux 64-bit](https://github.com/HelloZeroNet/ZeroBundle/raw/master/dist/ZeroBundle-linux64.tar.gz) * [Linux 32-bit](https://github.com/HelloZeroNet/ZeroBundle/raw/master/dist/ZeroBundle-linux32.tar.gz) * Распакуйте где угодно * Запустите `ZeroNet.exe` (win), `ZeroNet(.app)` (osx), `ZeroNet.sh` (linux) ### Linux терминал * `wget https://github.com/HelloZeroNet/ZeroBundle/raw/master/dist/ZeroBundle-linux64.tar.gz` * `tar xvpfz ZeroBundle-linux64.tar.gz` * `cd ZeroBundle` * Запустите с помощью `./ZeroNet.sh` Он загружает последнюю версию ZeroNet, затем запускает её автоматически. #### Ручная установка для Debian Linux * `sudo apt-get update` * `sudo apt-get install msgpack-python python-gevent` * `wget https://github.com/HelloZeroNet/ZeroNet/archive/master.tar.gz` * `tar xvpfz master.tar.gz` * `cd ZeroNet-master` * Запустите с помощью `python2 zeronet.py` * Откройте http://127.0.0.1:43110/ в вашем браузере. ### [Arch Linux](https://www.archlinux.org) * `git clone https://aur.archlinux.org/zeronet.git` * `cd zeronet` * `makepkg -srci` * `systemctl start zeronet` * Откройте http://127.0.0.1:43110/ в вашем браузере. Смотрите [ArchWiki](https://wiki.archlinux.org)'s [ZeroNet article](https://wiki.archlinux.org/index.php/ZeroNet) для дальнейшей помощи. ### [Gentoo Linux](https://www.gentoo.org) * [`layman -a raiagent`](https://github.com/leycec/raiagent) * `echo '>=net-vpn/zeronet-0.5.4' >> /etc/portage/package.accept_keywords` * *(Опционально)* Включить поддержку Tor: `echo 'net-vpn/zeronet tor' >> /etc/portage/package.use` * `emerge zeronet` * `rc-service zeronet start` * Откройте http://127.0.0.1:43110/ в вашем браузере. Смотрите `/usr/share/doc/zeronet-*/README.gentoo.bz2` для дальнейшей помощи. ### [FreeBSD](https://www.freebsd.org/) * `pkg install zeronet` or `cd /usr/ports/security/zeronet/ && make install clean` * `sysrc zeronet_enable="YES"` * `service zeronet start` * Откройте http://127.0.0.1:43110/ в вашем браузере. ### [Vagrant](https://www.vagrantup.com/) * `vagrant up` * Подключитесь к VM с помощью `vagrant ssh` * `cd /vagrant` * Запустите `python2 zeronet.py --ui_ip 0.0.0.0` * Откройте http://127.0.0.1:43110/ в вашем браузере. ### [Docker](https://www.docker.com/) * `docker run -d -v :/root/data -p 15441:15441 -p 127.0.0.1:43110:43110 nofish/zeronet` * Это изображение Docker включает в себя прокси-сервер Tor, который по умолчанию отключён. Остерегайтесь что некоторые хостинг-провайдеры могут не позволить вам запускать Tor на своих серверах. Если вы хотите включить его,установите переменную среды `ENABLE_TOR` в` true` (по умолчанию: `false`) Например: `docker run -d -e "ENABLE_TOR=true" -v :/root/data -p 15441:15441 -p 127.0.0.1:43110:43110 nofish/zeronet` * Откройте http://127.0.0.1:43110/ в вашем браузере. ### [Virtualenv](https://virtualenv.readthedocs.org/en/latest/) * `virtualenv env` * `source env/bin/activate` * `pip install msgpack gevent` * `python2 zeronet.py` * Откройте http://127.0.0.1:43110/ в вашем браузере. ## Текущие ограничения * ~~Нет torrent-похожего файла разделения для поддержки больших файлов~~ (поддержка больших файлов добавлена) * ~~Не анонимнее чем Bittorrent~~ (добавлена встроенная поддержка Tor) * Файловые транзакции не сжаты ~~ или незашифрованы еще ~~ (добавлено шифрование TLS) * Нет приватных сайтов ## Как я могу создать сайт в Zeronet? Завершите работу zeronet, если он запущен ```bash $ zeronet.py siteCreate ... - Site private key (Приватный ключ сайта): 23DKQpzxhbVBrAtvLEc2uvk7DZweh4qL3fn3jpM3LgHDczMK2TtYUq - Site address (Адрес сайта): 13DNDkMUExRf9Xa9ogwPKqp7zyHFEqbhC2 ... - Site created! (Сайт создан) $ zeronet.py ... ``` Поздравляем, вы закончили! Теперь каждый может получить доступ к вашему зайту используя `http://localhost:43110/13DNDkMUExRf9Xa9ogwPKqp7zyHFEqbhC2` Следующие шаги: [ZeroNet Developer Documentation](https://zeronet.io/docs/site_development/getting_started/) ## Как я могу модифицировать Zeronet сайт? * Измените файлы расположенные в data/13DNDkMUExRf9Xa9ogwPKqp7zyHFEqbhC2 директории. Когда закончите с изменением: ```bash $ zeronet.py siteSign 13DNDkMUExRf9Xa9ogwPKqp7zyHFEqbhC2 - Signing site (Подпись сайта): 13DNDkMUExRf9Xa9ogwPKqp7zyHFEqbhC2... Private key (Приватный ключ) (input hidden): ``` * Введите секретный ключ, который вы получили при создании сайта, потом: ```bash $ zeronet.py sitePublish 13DNDkMUExRf9Xa9ogwPKqp7zyHFEqbhC2 ... Site:13DNDk..bhC2 Publishing to 3/10 peers... Site:13DNDk..bhC2 Successfuly published to 3 peers - Serving files.... ``` * Вот и всё! Вы успешно подписали и опубликовали свои изменения. ## Поддержите проект - Bitcoin: 1QDhxQ6PraUZa21ET5fYUCPgdrwBomnFgX - Paypal: https://zeronet.io/docs/help_zeronet/donate/ ### Спонсоры * Улучшенная совместимость с MacOS / Safari стала возможной благодаря [BrowserStack.com](https://www.browserstack.com) #### Спасибо! * Больше информации, помощь, журнал изменений, zeronet сайты: https://www.reddit.com/r/zeronet/ * Приходите, пообщайтесь с нами: [#zeronet @ FreeNode](https://kiwiirc.com/client/irc.freenode.net/zeronet) или на [gitter](https://gitter.im/HelloZeroNet/ZeroNet) * Email: hello@zeronet.io (PGP: CB9613AE) ================================================ FILE: README-zh-cn.md ================================================ # ZeroNet [![Build Status](https://travis-ci.org/HelloZeroNet/ZeroNet.svg?branch=py3)](https://travis-ci.org/HelloZeroNet/ZeroNet) [![Documentation](https://img.shields.io/badge/docs-faq-brightgreen.svg)](https://zeronet.io/docs/faq/) [![Help](https://img.shields.io/badge/keep_this_project_alive-donate-yellow.svg)](https://zeronet.io/docs/help_zeronet/donate/) [English](./README.md) 使用 Bitcoin 加密和 BitTorrent 网络的去中心化网络 - https://zeronet.io ## 为什么? * 我们相信开放,自由,无审查的网络和通讯 * 不会受单点故障影响:只要有在线的节点,站点就会保持在线 * 无托管费用:站点由访问者托管 * 无法关闭:因为节点无处不在 * 快速并可离线运行:即使没有互联网连接也可以使用 ## 功能 * 实时站点更新 * 支持 Namecoin 的 .bit 域名 * 安装方便:只需解压并运行 * 一键克隆存在的站点 * 无需密码、基于 [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) 的认证:您的账户被与比特币钱包相同的加密方法保护 * 内建 SQL 服务器和 P2P 数据同步:让开发更简单并提升加载速度 * 匿名性:完整的 Tor 网络支持,支持通过 .onion 隐藏服务相互连接而不是通过 IPv4 地址连接 * TLS 加密连接 * 自动打开 uPnP 端口 * 多用户(openproxy)支持的插件 * 适用于任何浏览器 / 操作系统 ## 原理 * 在运行 `zeronet.py` 后,您将可以通过 `http://127.0.0.1:43110/{zeronet_address}`(例如: `http://127.0.0.1:43110/1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D`)访问 zeronet 中的站点 * 在您浏览 zeronet 站点时,客户端会尝试通过 BitTorrent 网络来寻找可用的节点,从而下载需要的文件(html,css,js...) * 您将会储存每一个浏览过的站点 * 每个站点都包含一个名为 `content.json` 的文件,它储存了其他所有文件的 sha512 散列值以及一个通过站点私钥生成的签名 * 如果站点的所有者(拥有站点地址的私钥)修改了站点,并且他 / 她签名了新的 `content.json` 然后推送至其他节点, 那么这些节点将会在使用签名验证 `content.json` 的真实性后,下载修改后的文件并将新内容推送至另外的节点 #### [关于 ZeroNet 加密,站点更新,多用户站点的幻灯片 »](https://docs.google.com/presentation/d/1_2qK1IuOKJ51pgBvllZ9Yu7Au2l551t3XBgyTSvilew/pub?start=false&loop=false&delayms=3000) #### [常见问题 »](https://zeronet.io/docs/faq/) #### [ZeroNet 开发者文档 »](https://zeronet.io/docs/site_development/getting_started/) ## 屏幕截图 ![Screenshot](https://i.imgur.com/H60OAHY.png) ![ZeroTalk](https://zeronet.io/docs/img/zerotalk.png) #### [ZeroNet 文档中的更多屏幕截图 »](https://zeronet.io/docs/using_zeronet/sample_sites/) ## 如何加入 ### Windows - 下载 [ZeroNet-py3-win64.zip](https://github.com/HelloZeroNet/ZeroNet-win/archive/dist-win64/ZeroNet-py3-win64.zip) (18MB) - 在任意位置解压缩 - 运行 `ZeroNet.exe` ### macOS - 下载 [ZeroNet-dist-mac.zip](https://github.com/HelloZeroNet/ZeroNet-dist/archive/mac/ZeroNet-dist-mac.zip) (13.2MB) - 在任意位置解压缩 - 运行 `ZeroNet.app` ### Linux (x86-64bit) - `wget https://github.com/HelloZeroNet/ZeroNet-linux/archive/dist-linux64/ZeroNet-py3-linux64.tar.gz` - `tar xvpfz ZeroNet-py3-linux64.tar.gz` - `cd ZeroNet-linux-dist-linux64/` - 使用以下命令启动 `./ZeroNet.sh` - 在浏览器打开 http://127.0.0.1:43110/ 即可访问 ZeroHello 页面 __提示:__ 若要允许在 Web 界面上的远程连接,使用以下命令启动 `./ZeroNet.sh --ui_ip '*' --ui_restrict your.ip.address` ### 从源代码安装 - `wget https://github.com/HelloZeroNet/ZeroNet/archive/py3/ZeroNet-py3.tar.gz` - `tar xvpfz ZeroNet-py3.tar.gz` - `cd ZeroNet-py3` - `sudo apt-get update` - `sudo apt-get install python3-pip` - `sudo python3 -m pip install -r requirements.txt` - 使用以下命令启动 `python3 zeronet.py` - 在浏览器打开 http://127.0.0.1:43110/ 即可访问 ZeroHello 页面 ## 现有限制 * ~~没有类似于 torrent 的文件拆分来支持大文件~~ (已添加大文件支持) * ~~没有比 BitTorrent 更好的匿名性~~ (已添加内置的完整 Tor 支持) * 传输文件时没有压缩~~和加密~~ (已添加 TLS 支持) * 不支持私有站点 ## 如何创建一个 ZeroNet 站点? * 点击 [ZeroHello](http://127.0.0.1:43110/1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D) 站点的 **⋮** > **「新建空站点」** 菜单项 * 您将被**重定向**到一个全新的站点,该站点只能由您修改 * 您可以在 **data/[您的站点地址]** 目录中找到并修改网站的内容 * 修改后打开您的网站,将右上角的「0」按钮拖到左侧,然后点击底部的**签名**并**发布**按钮 接下来的步骤:[ZeroNet 开发者文档](https://zeronet.io/docs/site_development/getting_started/) ## 帮助这个项目 - Bitcoin: 1QDhxQ6PraUZa21ET5fYUCPgdrwBomnFgX - Paypal: https://zeronet.io/docs/help_zeronet/donate/ ### 赞助商 * [BrowserStack.com](https://www.browserstack.com) 使更好的 macOS/Safari 兼容性成为可能 #### 感谢您! * 更多信息,帮助,变更记录和 zeronet 站点:https://www.reddit.com/r/zeronet/ * 前往 [#zeronet @ FreeNode](https://kiwiirc.com/client/irc.freenode.net/zeronet) 或 [gitter](https://gitter.im/HelloZeroNet/ZeroNet) 和我们聊天 * [这里](https://gitter.im/ZeroNet-zh/Lobby)是一个 gitter 上的中文聊天室 * Email: hello@zeronet.io (PGP: [960F FF2D 6C14 5AA6 13E8 491B 5B63 BAE6 CB96 13AE](https://zeronet.io/files/tamas@zeronet.io_pub.asc)) ================================================ FILE: README.md ================================================ # ZeroNet [![Build Status](https://travis-ci.org/HelloZeroNet/ZeroNet.svg?branch=py3)](https://travis-ci.org/HelloZeroNet/ZeroNet) [![Documentation](https://img.shields.io/badge/docs-faq-brightgreen.svg)](https://zeronet.io/docs/faq/) [![Help](https://img.shields.io/badge/keep_this_project_alive-donate-yellow.svg)](https://zeronet.io/docs/help_zeronet/donate/) ![tests](https://github.com/HelloZeroNet/ZeroNet/workflows/tests/badge.svg) [![Docker Pulls](https://img.shields.io/docker/pulls/nofish/zeronet)](https://hub.docker.com/r/nofish/zeronet) Decentralized websites using Bitcoin crypto and the BitTorrent network - https://zeronet.io / [onion](http://zeronet34m3r5ngdu54uj57dcafpgdjhxsgq5kla5con4qvcmfzpvhad.onion) ## Why? * We believe in open, free, and uncensored network and communication. * No single point of failure: Site remains online so long as at least 1 peer is serving it. * No hosting costs: Sites are served by visitors. * Impossible to shut down: It's nowhere because it's everywhere. * Fast and works offline: You can access the site even if Internet is unavailable. ## Features * Real-time updated sites * Namecoin .bit domains support * Easy to setup: unpack & run * Clone websites in one click * Password-less [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) based authorization: Your account is protected by the same cryptography as your Bitcoin wallet * Built-in SQL server with P2P data synchronization: Allows easier site development and faster page load times * Anonymity: Full Tor network support with .onion hidden services instead of IPv4 addresses * TLS encrypted connections * Automatic uPnP port opening * Plugin for multiuser (openproxy) support * Works with any browser/OS ## How does it work? * After starting `zeronet.py` you will be able to visit zeronet sites using `http://127.0.0.1:43110/{zeronet_address}` (eg. `http://127.0.0.1:43110/1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D`). * When you visit a new zeronet site, it tries to find peers using the BitTorrent network so it can download the site files (html, css, js...) from them. * Each visited site is also served by you. * Every site contains a `content.json` file which holds all other files in a sha512 hash and a signature generated using the site's private key. * If the site owner (who has the private key for the site address) modifies the site, then he/she signs the new `content.json` and publishes it to the peers. Afterwards, the peers verify the `content.json` integrity (using the signature), they download the modified files and publish the new content to other peers. #### [Slideshow about ZeroNet cryptography, site updates, multi-user sites »](https://docs.google.com/presentation/d/1_2qK1IuOKJ51pgBvllZ9Yu7Au2l551t3XBgyTSvilew/pub?start=false&loop=false&delayms=3000) #### [Frequently asked questions »](https://zeronet.io/docs/faq/) #### [ZeroNet Developer Documentation »](https://zeronet.io/docs/site_development/getting_started/) ## Screenshots ![Screenshot](https://i.imgur.com/H60OAHY.png) ![ZeroTalk](https://zeronet.io/docs/img/zerotalk.png) #### [More screenshots in ZeroNet docs »](https://zeronet.io/docs/using_zeronet/sample_sites/) ## How to join ### Windows - Download [ZeroNet-py3-win64.zip](https://github.com/HelloZeroNet/ZeroNet-win/archive/dist-win64/ZeroNet-py3-win64.zip) (18MB) - Unpack anywhere - Run `ZeroNet.exe` ### macOS - Download [ZeroNet-dist-mac.zip](https://github.com/HelloZeroNet/ZeroNet-dist/archive/mac/ZeroNet-dist-mac.zip) (13.2MB) - Unpack anywhere - Run `ZeroNet.app` ### Linux (x86-64bit) - `wget https://github.com/HelloZeroNet/ZeroNet-linux/archive/dist-linux64/ZeroNet-py3-linux64.tar.gz` - `tar xvpfz ZeroNet-py3-linux64.tar.gz` - `cd ZeroNet-linux-dist-linux64/` - Start with: `./ZeroNet.sh` - Open the ZeroHello landing page in your browser by navigating to: http://127.0.0.1:43110/ __Tip:__ Start with `./ZeroNet.sh --ui_ip '*' --ui_restrict your.ip.address` to allow remote connections on the web interface. ### Android (arm, arm64, x86) - minimum Android version supported 16 (JellyBean) - [Download from Google Play](https://play.google.com/store/apps/details?id=in.canews.zeronetmobile) - APK download: https://github.com/canewsin/zeronet_mobile/releases - XDA Labs: https://labs.xda-developers.com/store/app/in.canews.zeronet #### Docker There is an official image, built from source at: https://hub.docker.com/r/nofish/zeronet/ ### Install from source - `wget https://github.com/HelloZeroNet/ZeroNet/archive/py3/ZeroNet-py3.tar.gz` - `tar xvpfz ZeroNet-py3.tar.gz` - `cd ZeroNet-py3` - `sudo apt-get update` - `sudo apt-get install python3-pip` - `sudo python3 -m pip install -r requirements.txt` - Start with: `python3 zeronet.py` - Open the ZeroHello landing page in your browser by navigating to: http://127.0.0.1:43110/ ## Current limitations * ~~No torrent-like file splitting for big file support~~ (big file support added) * ~~No more anonymous than Bittorrent~~ (built-in full Tor support added) * File transactions are not compressed ~~or encrypted yet~~ (TLS encryption added) * No private sites ## How can I create a ZeroNet site? * Click on **⋮** > **"Create new, empty site"** menu item on the site [ZeroHello](http://127.0.0.1:43110/1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D). * You will be **redirected** to a completely new site that is only modifiable by you! * You can find and modify your site's content in **data/[yoursiteaddress]** directory * After the modifications open your site, drag the topright "0" button to left, then press **sign** and **publish** buttons on the bottom Next steps: [ZeroNet Developer Documentation](https://zeronet.io/docs/site_development/getting_started/) ## Help keep this project alive - Bitcoin: 1QDhxQ6PraUZa21ET5fYUCPgdrwBomnFgX - Paypal: https://zeronet.io/docs/help_zeronet/donate/ ### Sponsors * Better macOS/Safari compatibility made possible by [BrowserStack.com](https://www.browserstack.com) #### Thank you! * More info, help, changelog, zeronet sites: https://www.reddit.com/r/zeronet/ * Come, chat with us: [#zeronet @ FreeNode](https://kiwiirc.com/client/irc.freenode.net/zeronet) or on [gitter](https://gitter.im/HelloZeroNet/ZeroNet) * Email: hello@zeronet.io (PGP: [960F FF2D 6C14 5AA6 13E8 491B 5B63 BAE6 CB96 13AE](https://zeronet.io/files/tamas@zeronet.io_pub.asc)) ================================================ FILE: Vagrantfile ================================================ # -*- mode: ruby -*- # vi: set ft=ruby : VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| #Set box config.vm.box = "ubuntu/trusty64" #Do not check fo updates config.vm.box_check_update = false #Add private network config.vm.network "private_network", type: "dhcp" #Redirect ports config.vm.network "forwarded_port", guest: 43110, host: 43110 config.vm.network "forwarded_port", guest: 15441, host: 15441 #Sync folder using NFS if not windows config.vm.synced_folder ".", "/vagrant", :nfs => !Vagrant::Util::Platform.windows? #Virtal Box settings config.vm.provider "virtualbox" do |vb| # Don't boot with headless mode #vb.gui = true # Set VM settings vb.customize ["modifyvm", :id, "--memory", "512"] vb.customize ["modifyvm", :id, "--cpus", 1] end #Update system config.vm.provision "shell", inline: "sudo apt-get update -y && sudo apt-get upgrade -y" #Install deps config.vm.provision "shell", inline: "sudo apt-get install msgpack-python python-gevent python-pip python-dev -y" config.vm.provision "shell", inline: "sudo pip install msgpack --upgrade" end ================================================ FILE: plugins/AnnounceBitTorrent/AnnounceBitTorrentPlugin.py ================================================ import time import urllib.request import struct import socket import lib.bencode_open as bencode_open from lib.subtl.subtl import UdpTrackerClient import socks import sockshandler import gevent from Plugin import PluginManager from Config import config from Debug import Debug from util import helper # We can only import plugin host clases after the plugins are loaded @PluginManager.afterLoad def importHostClasses(): global Peer, AnnounceError from Peer import Peer from Site.SiteAnnouncer import AnnounceError @PluginManager.registerTo("SiteAnnouncer") class SiteAnnouncerPlugin(object): def getSupportedTrackers(self): trackers = super(SiteAnnouncerPlugin, self).getSupportedTrackers() if config.disable_udp or config.trackers_proxy != "disable": trackers = [tracker for tracker in trackers if not tracker.startswith("udp://")] return trackers def getTrackerHandler(self, protocol): if protocol == "udp": handler = self.announceTrackerUdp elif protocol == "http": handler = self.announceTrackerHttp elif protocol == "https": handler = self.announceTrackerHttps else: handler = super(SiteAnnouncerPlugin, self).getTrackerHandler(protocol) return handler def announceTrackerUdp(self, tracker_address, mode="start", num_want=10): s = time.time() if config.disable_udp: raise AnnounceError("Udp disabled by config") if config.trackers_proxy != "disable": raise AnnounceError("Udp trackers not available with proxies") ip, port = tracker_address.split("/")[0].split(":") tracker = UdpTrackerClient(ip, int(port)) if helper.getIpType(ip) in self.getOpenedServiceTypes(): tracker.peer_port = self.fileserver_port else: tracker.peer_port = 0 tracker.connect() if not tracker.poll_once(): raise AnnounceError("Could not connect") tracker.announce(info_hash=self.site.address_sha1, num_want=num_want, left=431102370) back = tracker.poll_once() if not back: raise AnnounceError("No response after %.0fs" % (time.time() - s)) elif type(back) is dict and "response" in back: peers = back["response"]["peers"] else: raise AnnounceError("Invalid response: %r" % back) return peers def httpRequest(self, url): headers = { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'Accept-Encoding': 'none', 'Accept-Language': 'en-US,en;q=0.8', 'Connection': 'keep-alive' } req = urllib.request.Request(url, headers=headers) if config.trackers_proxy == "tor": tor_manager = self.site.connection_server.tor_manager handler = sockshandler.SocksiPyHandler(socks.SOCKS5, tor_manager.proxy_ip, tor_manager.proxy_port) opener = urllib.request.build_opener(handler) return opener.open(req, timeout=50) elif config.trackers_proxy == "disable": return urllib.request.urlopen(req, timeout=25) else: proxy_ip, proxy_port = config.trackers_proxy.split(":") handler = sockshandler.SocksiPyHandler(socks.SOCKS5, proxy_ip, int(proxy_port)) opener = urllib.request.build_opener(handler) return opener.open(req, timeout=50) def announceTrackerHttps(self, *args, **kwargs): kwargs["protocol"] = "https" return self.announceTrackerHttp(*args, **kwargs) def announceTrackerHttp(self, tracker_address, mode="start", num_want=10, protocol="http"): tracker_ip, tracker_port = tracker_address.rsplit(":", 1) if helper.getIpType(tracker_ip) in self.getOpenedServiceTypes(): port = self.fileserver_port else: port = 1 params = { 'info_hash': self.site.address_sha1, 'peer_id': self.peer_id, 'port': port, 'uploaded': 0, 'downloaded': 0, 'left': 431102370, 'compact': 1, 'numwant': num_want, 'event': 'started' } url = protocol + "://" + tracker_address + "?" + urllib.parse.urlencode(params) s = time.time() response = None # Load url if config.tor == "always" or config.trackers_proxy != "disable": timeout = 60 else: timeout = 30 with gevent.Timeout(timeout, False): # Make sure of timeout req = self.httpRequest(url) response = req.read() req.close() req = None if not response: raise AnnounceError("No response after %.0fs" % (time.time() - s)) # Decode peers try: peer_data = bencode_open.loads(response)[b"peers"] response = None peer_count = int(len(peer_data) / 6) peers = [] for peer_offset in range(peer_count): off = 6 * peer_offset peer = peer_data[off:off + 6] addr, port = struct.unpack('!LH', peer) peers.append({"addr": socket.inet_ntoa(struct.pack('!L', addr)), "port": port}) except Exception as err: raise AnnounceError("Invalid response: %r (%s)" % (response, Debug.formatException(err))) return peers ================================================ FILE: plugins/AnnounceBitTorrent/__init__.py ================================================ from . import AnnounceBitTorrentPlugin ================================================ FILE: plugins/AnnounceBitTorrent/plugin_info.json ================================================ { "name": "AnnounceBitTorrent", "description": "Discover new peers using BitTorrent trackers.", "default": "enabled" } ================================================ FILE: plugins/AnnounceLocal/AnnounceLocalPlugin.py ================================================ import time import gevent from Plugin import PluginManager from Config import config from . import BroadcastServer @PluginManager.registerTo("SiteAnnouncer") class SiteAnnouncerPlugin(object): def announce(self, force=False, *args, **kwargs): local_announcer = self.site.connection_server.local_announcer thread = None if local_announcer and (force or time.time() - local_announcer.last_discover > 5 * 60): thread = gevent.spawn(local_announcer.discover, force=force) back = super(SiteAnnouncerPlugin, self).announce(force=force, *args, **kwargs) if thread: thread.join() return back class LocalAnnouncer(BroadcastServer.BroadcastServer): def __init__(self, server, listen_port): super(LocalAnnouncer, self).__init__("zeronet", listen_port=listen_port) self.server = server self.sender_info["peer_id"] = self.server.peer_id self.sender_info["port"] = self.server.port self.sender_info["broadcast_port"] = listen_port self.sender_info["rev"] = config.rev self.known_peers = {} self.last_discover = 0 def discover(self, force=False): self.log.debug("Sending discover request (force: %s)" % force) self.last_discover = time.time() if force: # Probably new site added, clean cache self.known_peers = {} for peer_id, known_peer in list(self.known_peers.items()): if time.time() - known_peer["found"] > 20 * 60: del(self.known_peers[peer_id]) self.log.debug("Timeout, removing from known_peers: %s" % peer_id) self.broadcast({"cmd": "discoverRequest", "params": {}}, port=self.listen_port) def actionDiscoverRequest(self, sender, params): back = { "cmd": "discoverResponse", "params": { "sites_changed": self.server.site_manager.sites_changed } } if sender["peer_id"] not in self.known_peers: self.known_peers[sender["peer_id"]] = {"added": time.time(), "sites_changed": 0, "updated": 0, "found": time.time()} self.log.debug("Got discover request from unknown peer %s (%s), time to refresh known peers" % (sender["ip"], sender["peer_id"])) gevent.spawn_later(1.0, self.discover) # Let the response arrive first to the requester return back def actionDiscoverResponse(self, sender, params): if sender["peer_id"] in self.known_peers: self.known_peers[sender["peer_id"]]["found"] = time.time() if params["sites_changed"] != self.known_peers.get(sender["peer_id"], {}).get("sites_changed"): # Peer's site list changed, request the list of new sites return {"cmd": "siteListRequest"} else: # Peer's site list is the same for site in self.server.sites.values(): peer = site.peers.get("%s:%s" % (sender["ip"], sender["port"])) if peer: peer.found("local") def actionSiteListRequest(self, sender, params): back = [] sites = list(self.server.sites.values()) # Split adresses to group of 100 to avoid UDP size limit site_groups = [sites[i:i + 100] for i in range(0, len(sites), 100)] for site_group in site_groups: res = {} res["sites_changed"] = self.server.site_manager.sites_changed res["sites"] = [site.address_hash for site in site_group] back.append({"cmd": "siteListResponse", "params": res}) return back def actionSiteListResponse(self, sender, params): s = time.time() peer_sites = set(params["sites"]) num_found = 0 added_sites = [] for site in self.server.sites.values(): if site.address_hash in peer_sites: added = site.addPeer(sender["ip"], sender["port"], source="local") num_found += 1 if added: site.worker_manager.onPeers() site.updateWebsocket(peers_added=1) added_sites.append(site) # Save sites changed value to avoid unnecessary site list download if sender["peer_id"] not in self.known_peers: self.known_peers[sender["peer_id"]] = {"added": time.time()} self.known_peers[sender["peer_id"]]["sites_changed"] = params["sites_changed"] self.known_peers[sender["peer_id"]]["updated"] = time.time() self.known_peers[sender["peer_id"]]["found"] = time.time() self.log.debug( "Tracker result: Discover from %s response parsed in %.3fs, found: %s added: %s of %s" % (sender["ip"], time.time() - s, num_found, added_sites, len(peer_sites)) ) @PluginManager.registerTo("FileServer") class FileServerPlugin(object): def __init__(self, *args, **kwargs): super(FileServerPlugin, self).__init__(*args, **kwargs) if config.broadcast_port and config.tor != "always" and not config.disable_udp: self.local_announcer = LocalAnnouncer(self, config.broadcast_port) else: self.local_announcer = None def start(self, *args, **kwargs): if self.local_announcer: gevent.spawn(self.local_announcer.start) return super(FileServerPlugin, self).start(*args, **kwargs) def stop(self): if self.local_announcer: self.local_announcer.stop() res = super(FileServerPlugin, self).stop() return res @PluginManager.registerTo("ConfigPlugin") class ConfigPlugin(object): def createArguments(self): group = self.parser.add_argument_group("AnnounceLocal plugin") group.add_argument('--broadcast_port', help='UDP broadcasting port for local peer discovery', default=1544, type=int, metavar='port') return super(ConfigPlugin, self).createArguments() ================================================ FILE: plugins/AnnounceLocal/BroadcastServer.py ================================================ import socket import logging import time from contextlib import closing from Debug import Debug from util import UpnpPunch from util import Msgpack class BroadcastServer(object): def __init__(self, service_name, listen_port=1544, listen_ip=''): self.log = logging.getLogger("BroadcastServer") self.listen_port = listen_port self.listen_ip = listen_ip self.running = False self.sock = None self.sender_info = {"service": service_name} def createBroadcastSocket(self): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) if hasattr(socket, 'SO_REUSEPORT'): try: sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) except Exception as err: self.log.warning("Error setting SO_REUSEPORT: %s" % err) binded = False for retry in range(3): try: sock.bind((self.listen_ip, self.listen_port)) binded = True break except Exception as err: self.log.error( "Socket bind to %s:%s error: %s, retry #%s" % (self.listen_ip, self.listen_port, Debug.formatException(err), retry) ) time.sleep(retry) if binded: return sock else: return False def start(self): # Listens for discover requests self.sock = self.createBroadcastSocket() if not self.sock: self.log.error("Unable to listen on port %s" % self.listen_port) return self.log.debug("Started on port %s" % self.listen_port) self.running = True while self.running: try: data, addr = self.sock.recvfrom(8192) except Exception as err: if self.running: self.log.error("Listener receive error: %s" % err) continue if not self.running: break try: message = Msgpack.unpack(data) response_addr, message = self.handleMessage(addr, message) if message: self.send(response_addr, message) except Exception as err: self.log.error("Handlemessage error: %s" % Debug.formatException(err)) self.log.debug("Stopped listening on port %s" % self.listen_port) def stop(self): self.log.debug("Stopping, socket: %s" % self.sock) self.running = False if self.sock: self.sock.close() def send(self, addr, message): if type(message) is not list: message = [message] for message_part in message: message_part["sender"] = self.sender_info self.log.debug("Send to %s: %s" % (addr, message_part["cmd"])) with closing(socket.socket(socket.AF_INET, socket.SOCK_DGRAM)) as sock: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.sendto(Msgpack.pack(message_part), addr) def getMyIps(self): return UpnpPunch._get_local_ips() def broadcast(self, message, port=None): if not port: port = self.listen_port my_ips = self.getMyIps() addr = ("255.255.255.255", port) message["sender"] = self.sender_info self.log.debug("Broadcast using ips %s on port %s: %s" % (my_ips, port, message["cmd"])) for my_ip in my_ips: try: with closing(socket.socket(socket.AF_INET, socket.SOCK_DGRAM)) as sock: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) sock.bind((my_ip, 0)) sock.sendto(Msgpack.pack(message), addr) except Exception as err: self.log.warning("Error sending broadcast using ip %s: %s" % (my_ip, err)) def handleMessage(self, addr, message): self.log.debug("Got from %s: %s" % (addr, message["cmd"])) cmd = message["cmd"] params = message.get("params", {}) sender = message["sender"] sender["ip"] = addr[0] func_name = "action" + cmd[0].upper() + cmd[1:] func = getattr(self, func_name, None) if sender["service"] != "zeronet" or sender["peer_id"] == self.sender_info["peer_id"]: # Skip messages not for us or sent by us message = None elif func: message = func(sender, params) else: self.log.debug("Unknown cmd: %s" % cmd) message = None return (sender["ip"], sender["broadcast_port"]), message ================================================ FILE: plugins/AnnounceLocal/Test/TestAnnounce.py ================================================ import time import copy import gevent import pytest import mock from AnnounceLocal import AnnounceLocalPlugin from File import FileServer from Test import Spy @pytest.fixture def announcer(file_server, site): file_server.sites[site.address] = site announcer = AnnounceLocalPlugin.LocalAnnouncer(file_server, listen_port=1100) file_server.local_announcer = announcer announcer.listen_port = 1100 announcer.sender_info["broadcast_port"] = 1100 announcer.getMyIps = mock.MagicMock(return_value=["127.0.0.1"]) announcer.discover = mock.MagicMock(return_value=False) # Don't send discover requests automatically gevent.spawn(announcer.start) time.sleep(0.5) assert file_server.local_announcer.running return file_server.local_announcer @pytest.fixture def announcer_remote(request, site_temp): file_server_remote = FileServer("127.0.0.1", 1545) file_server_remote.sites[site_temp.address] = site_temp announcer = AnnounceLocalPlugin.LocalAnnouncer(file_server_remote, listen_port=1101) file_server_remote.local_announcer = announcer announcer.listen_port = 1101 announcer.sender_info["broadcast_port"] = 1101 announcer.getMyIps = mock.MagicMock(return_value=["127.0.0.1"]) announcer.discover = mock.MagicMock(return_value=False) # Don't send discover requests automatically gevent.spawn(announcer.start) time.sleep(0.5) assert file_server_remote.local_announcer.running def cleanup(): file_server_remote.stop() request.addfinalizer(cleanup) return file_server_remote.local_announcer @pytest.mark.usefixtures("resetSettings") @pytest.mark.usefixtures("resetTempSettings") class TestAnnounce: def testSenderInfo(self, announcer): sender_info = announcer.sender_info assert sender_info["port"] > 0 assert len(sender_info["peer_id"]) == 20 assert sender_info["rev"] > 0 def testIgnoreSelfMessages(self, announcer): # No response to messages that has same peer_id as server assert not announcer.handleMessage(("0.0.0.0", 123), {"cmd": "discoverRequest", "sender": announcer.sender_info, "params": {}})[1] # Response to messages with different peer id sender_info = copy.copy(announcer.sender_info) sender_info["peer_id"] += "-" addr, res = announcer.handleMessage(("0.0.0.0", 123), {"cmd": "discoverRequest", "sender": sender_info, "params": {}}) assert res["params"]["sites_changed"] > 0 def testDiscoverRequest(self, announcer, announcer_remote): assert len(announcer_remote.known_peers) == 0 with Spy.Spy(announcer_remote, "handleMessage") as responses: announcer_remote.broadcast({"cmd": "discoverRequest", "params": {}}, port=announcer.listen_port) time.sleep(0.1) response_cmds = [response[1]["cmd"] for response in responses] assert response_cmds == ["discoverResponse", "siteListResponse"] assert len(responses[-1][1]["params"]["sites"]) == 1 # It should only request siteList if sites_changed value is different from last response with Spy.Spy(announcer_remote, "handleMessage") as responses: announcer_remote.broadcast({"cmd": "discoverRequest", "params": {}}, port=announcer.listen_port) time.sleep(0.1) response_cmds = [response[1]["cmd"] for response in responses] assert response_cmds == ["discoverResponse"] def testPeerDiscover(self, announcer, announcer_remote, site): assert announcer.server.peer_id != announcer_remote.server.peer_id assert len(list(announcer.server.sites.values())[0].peers) == 0 announcer.broadcast({"cmd": "discoverRequest"}, port=announcer_remote.listen_port) time.sleep(0.1) assert len(list(announcer.server.sites.values())[0].peers) == 1 def testRecentPeerList(self, announcer, announcer_remote, site): assert len(site.peers_recent) == 0 assert len(site.peers) == 0 with Spy.Spy(announcer, "handleMessage") as responses: announcer.broadcast({"cmd": "discoverRequest", "params": {}}, port=announcer_remote.listen_port) time.sleep(0.1) assert [response[1]["cmd"] for response in responses] == ["discoverResponse", "siteListResponse"] assert len(site.peers_recent) == 1 assert len(site.peers) == 1 # It should update peer without siteListResponse last_time_found = list(site.peers.values())[0].time_found site.peers_recent.clear() with Spy.Spy(announcer, "handleMessage") as responses: announcer.broadcast({"cmd": "discoverRequest", "params": {}}, port=announcer_remote.listen_port) time.sleep(0.1) assert [response[1]["cmd"] for response in responses] == ["discoverResponse"] assert len(site.peers_recent) == 1 assert list(site.peers.values())[0].time_found > last_time_found ================================================ FILE: plugins/AnnounceLocal/Test/conftest.py ================================================ from src.Test.conftest import * from Config import config config.broadcast_port = 0 ================================================ FILE: plugins/AnnounceLocal/Test/pytest.ini ================================================ [pytest] python_files = Test*.py addopts = -rsxX -v --durations=6 markers = webtest: mark a test as a webtest. ================================================ FILE: plugins/AnnounceLocal/__init__.py ================================================ from . import AnnounceLocalPlugin ================================================ FILE: plugins/AnnounceLocal/plugin_info.json ================================================ { "name": "AnnounceLocal", "description": "Discover LAN clients using UDP broadcasting.", "default": "enabled" } ================================================ FILE: plugins/AnnounceShare/AnnounceSharePlugin.py ================================================ import time import os import logging import json import atexit import gevent from Config import config from Plugin import PluginManager from util import helper class TrackerStorage(object): def __init__(self): self.log = logging.getLogger("TrackerStorage") self.file_path = "%s/trackers.json" % config.data_dir self.load() self.time_discover = 0.0 atexit.register(self.save) def getDefaultFile(self): return {"shared": {}} def onTrackerFound(self, tracker_address, type="shared", my=False): if not tracker_address.startswith("zero://"): return False trackers = self.getTrackers() added = False if tracker_address not in trackers: trackers[tracker_address] = { "time_added": time.time(), "time_success": 0, "latency": 99.0, "num_error": 0, "my": False } self.log.debug("New tracker found: %s" % tracker_address) added = True trackers[tracker_address]["time_found"] = time.time() trackers[tracker_address]["my"] = my return added def onTrackerSuccess(self, tracker_address, latency): trackers = self.getTrackers() if tracker_address not in trackers: return False trackers[tracker_address]["latency"] = latency trackers[tracker_address]["time_success"] = time.time() trackers[tracker_address]["num_error"] = 0 def onTrackerError(self, tracker_address): trackers = self.getTrackers() if tracker_address not in trackers: return False trackers[tracker_address]["time_error"] = time.time() trackers[tracker_address]["num_error"] += 1 if len(self.getWorkingTrackers()) >= config.working_shared_trackers_limit: error_limit = 5 else: error_limit = 30 error_limit if trackers[tracker_address]["num_error"] > error_limit and trackers[tracker_address]["time_success"] < time.time() - 60 * 60: self.log.debug("Tracker %s looks down, removing." % tracker_address) del trackers[tracker_address] def getTrackers(self, type="shared"): return self.file_content.setdefault(type, {}) def getWorkingTrackers(self, type="shared"): trackers = { key: tracker for key, tracker in self.getTrackers(type).items() if tracker["time_success"] > time.time() - 60 * 60 } return trackers def getFileContent(self): if not os.path.isfile(self.file_path): open(self.file_path, "w").write("{}") return self.getDefaultFile() try: return json.load(open(self.file_path)) except Exception as err: self.log.error("Error loading trackers list: %s" % err) return self.getDefaultFile() def load(self): self.file_content = self.getFileContent() trackers = self.getTrackers() self.log.debug("Loaded %s shared trackers" % len(trackers)) for address, tracker in list(trackers.items()): tracker["num_error"] = 0 if not address.startswith("zero://"): del trackers[address] def save(self): s = time.time() helper.atomicWrite(self.file_path, json.dumps(self.file_content, indent=2, sort_keys=True).encode("utf8")) self.log.debug("Saved in %.3fs" % (time.time() - s)) def discoverTrackers(self, peers): if len(self.getWorkingTrackers()) > config.working_shared_trackers_limit: return False s = time.time() num_success = 0 for peer in peers: if peer.connection and peer.connection.handshake.get("rev", 0) < 3560: continue # Not supported res = peer.request("getTrackers") if not res or "error" in res: continue num_success += 1 for tracker_address in res["trackers"]: if type(tracker_address) is bytes: # Backward compatibilitys tracker_address = tracker_address.decode("utf8") added = self.onTrackerFound(tracker_address) if added: # Only add one tracker from one source break if not num_success and len(peers) < 20: self.time_discover = 0.0 if num_success: self.save() self.log.debug("Trackers discovered from %s/%s peers in %.3fs" % (num_success, len(peers), time.time() - s)) if "tracker_storage" not in locals(): tracker_storage = TrackerStorage() @PluginManager.registerTo("SiteAnnouncer") class SiteAnnouncerPlugin(object): def getTrackers(self): if tracker_storage.time_discover < time.time() - 5 * 60: tracker_storage.time_discover = time.time() gevent.spawn(tracker_storage.discoverTrackers, self.site.getConnectedPeers()) trackers = super(SiteAnnouncerPlugin, self).getTrackers() shared_trackers = list(tracker_storage.getTrackers("shared").keys()) if shared_trackers: return trackers + shared_trackers else: return trackers def announceTracker(self, tracker, *args, **kwargs): res = super(SiteAnnouncerPlugin, self).announceTracker(tracker, *args, **kwargs) if res: latency = res tracker_storage.onTrackerSuccess(tracker, latency) elif res is False: tracker_storage.onTrackerError(tracker) return res @PluginManager.registerTo("FileRequest") class FileRequestPlugin(object): def actionGetTrackers(self, params): shared_trackers = list(tracker_storage.getWorkingTrackers("shared").keys()) self.response({"trackers": shared_trackers}) @PluginManager.registerTo("FileServer") class FileServerPlugin(object): def portCheck(self, *args, **kwargs): res = super(FileServerPlugin, self).portCheck(*args, **kwargs) if res and not config.tor == "always" and "Bootstrapper" in PluginManager.plugin_manager.plugin_names: for ip in self.ip_external_list: my_tracker_address = "zero://%s:%s" % (ip, config.fileserver_port) tracker_storage.onTrackerFound(my_tracker_address, my=True) return res @PluginManager.registerTo("ConfigPlugin") class ConfigPlugin(object): def createArguments(self): group = self.parser.add_argument_group("AnnounceShare plugin") group.add_argument('--working_shared_trackers_limit', help='Stop discovering new shared trackers after this number of shared trackers reached', default=5, type=int, metavar='limit') return super(ConfigPlugin, self).createArguments() ================================================ FILE: plugins/AnnounceShare/Test/TestAnnounceShare.py ================================================ import pytest from AnnounceShare import AnnounceSharePlugin from Peer import Peer from Config import config @pytest.mark.usefixtures("resetSettings") @pytest.mark.usefixtures("resetTempSettings") class TestAnnounceShare: def testAnnounceList(self, file_server): open("%s/trackers.json" % config.data_dir, "w").write("{}") tracker_storage = AnnounceSharePlugin.tracker_storage tracker_storage.load() peer = Peer(file_server.ip, 1544, connection_server=file_server) assert peer.request("getTrackers")["trackers"] == [] tracker_storage.onTrackerFound("zero://%s:15441" % file_server.ip) assert peer.request("getTrackers")["trackers"] == [] # It needs to have at least one successfull announce to be shared to other peers tracker_storage.onTrackerSuccess("zero://%s:15441" % file_server.ip, 1.0) assert peer.request("getTrackers")["trackers"] == ["zero://%s:15441" % file_server.ip] ================================================ FILE: plugins/AnnounceShare/Test/conftest.py ================================================ from src.Test.conftest import * from Config import config ================================================ FILE: plugins/AnnounceShare/Test/pytest.ini ================================================ [pytest] python_files = Test*.py addopts = -rsxX -v --durations=6 markers = webtest: mark a test as a webtest. ================================================ FILE: plugins/AnnounceShare/__init__.py ================================================ from . import AnnounceSharePlugin ================================================ FILE: plugins/AnnounceShare/plugin_info.json ================================================ { "name": "AnnounceShare", "description": "Share possible trackers between clients.", "default": "enabled" } ================================================ FILE: plugins/AnnounceZero/AnnounceZeroPlugin.py ================================================ import time import itertools from Plugin import PluginManager from util import helper from Crypt import CryptRsa allow_reload = False # No source reload supported in this plugin time_full_announced = {} # Tracker address: Last announced all site to tracker connection_pool = {} # Tracker address: Peer object # We can only import plugin host clases after the plugins are loaded @PluginManager.afterLoad def importHostClasses(): global Peer, AnnounceError from Peer import Peer from Site.SiteAnnouncer import AnnounceError # Process result got back from tracker def processPeerRes(tracker_address, site, peers): added = 0 # Onion found_onion = 0 for packed_address in peers["onion"]: found_onion += 1 peer_onion, peer_port = helper.unpackOnionAddress(packed_address) if site.addPeer(peer_onion, peer_port, source="tracker"): added += 1 # Ip4 found_ipv4 = 0 peers_normal = itertools.chain(peers.get("ip4", []), peers.get("ipv4", []), peers.get("ipv6", [])) for packed_address in peers_normal: found_ipv4 += 1 peer_ip, peer_port = helper.unpackAddress(packed_address) if site.addPeer(peer_ip, peer_port, source="tracker"): added += 1 if added: site.worker_manager.onPeers() site.updateWebsocket(peers_added=added) return added @PluginManager.registerTo("SiteAnnouncer") class SiteAnnouncerPlugin(object): def getTrackerHandler(self, protocol): if protocol == "zero": return self.announceTrackerZero else: return super(SiteAnnouncerPlugin, self).getTrackerHandler(protocol) def announceTrackerZero(self, tracker_address, mode="start", num_want=10): global time_full_announced s = time.time() need_types = ["ip4"] # ip4 for backward compatibility reasons need_types += self.site.connection_server.supported_ip_types if self.site.connection_server.tor_manager.enabled: need_types.append("onion") if mode == "start" or mode == "more": # Single: Announce only this site sites = [self.site] full_announce = False else: # Multi: Announce all currently serving site full_announce = True if time.time() - time_full_announced.get(tracker_address, 0) < 60 * 15: # No reannounce all sites within short time return None time_full_announced[tracker_address] = time.time() from Site import SiteManager sites = [site for site in SiteManager.site_manager.sites.values() if site.isServing()] # Create request add_types = self.getOpenedServiceTypes() request = { "hashes": [], "onions": [], "port": self.fileserver_port, "need_types": need_types, "need_num": 20, "add": add_types } for site in sites: if "onion" in add_types: onion = self.site.connection_server.tor_manager.getOnion(site.address) request["onions"].append(onion) request["hashes"].append(site.address_hash) # Tracker can remove sites that we don't announce if full_announce: request["delete"] = True # Sent request to tracker tracker_peer = connection_pool.get(tracker_address) # Re-use tracker connection if possible if not tracker_peer: tracker_ip, tracker_port = tracker_address.rsplit(":", 1) tracker_peer = Peer(str(tracker_ip), int(tracker_port), connection_server=self.site.connection_server) tracker_peer.is_tracker_connection = True connection_pool[tracker_address] = tracker_peer res = tracker_peer.request("announce", request) if not res or "peers" not in res: if full_announce: time_full_announced[tracker_address] = 0 raise AnnounceError("Invalid response: %s" % res) # Add peers from response to site site_index = 0 peers_added = 0 for site_res in res["peers"]: site = sites[site_index] peers_added += processPeerRes(tracker_address, site, site_res) site_index += 1 # Check if we need to sign prove the onion addresses if "onion_sign_this" in res: self.site.log.debug("Signing %s for %s to add %s onions" % (res["onion_sign_this"], tracker_address, len(sites))) request["onion_signs"] = {} request["onion_sign_this"] = res["onion_sign_this"] request["need_num"] = 0 for site in sites: onion = self.site.connection_server.tor_manager.getOnion(site.address) publickey = self.site.connection_server.tor_manager.getPublickey(onion) if publickey not in request["onion_signs"]: sign = CryptRsa.sign(res["onion_sign_this"].encode("utf8"), self.site.connection_server.tor_manager.getPrivatekey(onion)) request["onion_signs"][publickey] = sign res = tracker_peer.request("announce", request) if not res or "onion_sign_this" in res: if full_announce: time_full_announced[tracker_address] = 0 raise AnnounceError("Announce onion address to failed: %s" % res) if full_announce: tracker_peer.remove() # Close connection, we don't need it in next 5 minute self.site.log.debug( "Tracker announce result: zero://%s (sites: %s, new peers: %s, add: %s, mode: %s) in %.3fs" % (tracker_address, site_index, peers_added, add_types, mode, time.time() - s) ) return True ================================================ FILE: plugins/AnnounceZero/__init__.py ================================================ from . import AnnounceZeroPlugin ================================================ FILE: plugins/AnnounceZero/plugin_info.json ================================================ { "name": "AnnounceZero", "description": "Announce using ZeroNet protocol.", "default": "enabled" } ================================================ FILE: plugins/Benchmark/BenchmarkDb.py ================================================ import os import json import contextlib import time from Plugin import PluginManager from Config import config @PluginManager.registerTo("Actions") class ActionsPlugin: def getBenchmarkTests(self, online=False): tests = super().getBenchmarkTests(online) tests.extend([ {"func": self.testDbConnect, "num": 10, "time_standard": 0.27}, {"func": self.testDbInsert, "num": 10, "time_standard": 0.91}, {"func": self.testDbInsertMultiuser, "num": 1, "time_standard": 0.57}, {"func": self.testDbQueryIndexed, "num": 1000, "time_standard": 0.84}, {"func": self.testDbQueryNotIndexed, "num": 1000, "time_standard": 1.30} ]) return tests @contextlib.contextmanager def getTestDb(self): from Db import Db path = "%s/benchmark.db" % config.data_dir if os.path.isfile(path): os.unlink(path) schema = { "db_name": "TestDb", "db_file": path, "maps": { ".*": { "to_table": { "test": "test" } } }, "tables": { "test": { "cols": [ ["test_id", "INTEGER"], ["title", "TEXT"], ["json_id", "INTEGER REFERENCES json (json_id)"] ], "indexes": ["CREATE UNIQUE INDEX test_key ON test(test_id, json_id)"], "schema_changed": 1426195822 } } } db = Db.Db(schema, path) yield db db.close() if os.path.isfile(path): os.unlink(path) def testDbConnect(self, num_run=1): import sqlite3 for i in range(num_run): with self.getTestDb() as db: db.checkTables() yield "." yield "(SQLite version: %s, API: %s)" % (sqlite3.sqlite_version, sqlite3.version) def testDbInsert(self, num_run=1): yield "x 1000 lines " for u in range(num_run): with self.getTestDb() as db: db.checkTables() data = {"test": []} for i in range(1000): # 1000 line of data data["test"].append({"test_id": i, "title": "Testdata for %s message %s" % (u, i)}) json.dump(data, open("%s/test_%s.json" % (config.data_dir, u), "w")) db.updateJson("%s/test_%s.json" % (config.data_dir, u)) os.unlink("%s/test_%s.json" % (config.data_dir, u)) assert db.execute("SELECT COUNT(*) FROM test").fetchone()[0] == 1000 yield "." def fillTestDb(self, db): db.checkTables() cur = db.getCursor() cur.logging = False for u in range(100, 200): # 100 user data = {"test": []} for i in range(100): # 1000 line of data data["test"].append({"test_id": i, "title": "Testdata for %s message %s" % (u, i)}) json.dump(data, open("%s/test_%s.json" % (config.data_dir, u), "w")) db.updateJson("%s/test_%s.json" % (config.data_dir, u), cur=cur) os.unlink("%s/test_%s.json" % (config.data_dir, u)) if u % 10 == 0: yield "." def testDbInsertMultiuser(self, num_run=1): yield "x 100 users x 100 lines " for u in range(num_run): with self.getTestDb() as db: for progress in self.fillTestDb(db): yield progress num_rows = db.execute("SELECT COUNT(*) FROM test").fetchone()[0] assert num_rows == 10000, "%s != 10000" % num_rows def testDbQueryIndexed(self, num_run=1): s = time.time() with self.getTestDb() as db: for progress in self.fillTestDb(db): pass yield " (Db warmup done in %.3fs) " % (time.time() - s) found_total = 0 for i in range(num_run): # 1000x by test_id found = 0 res = db.execute("SELECT * FROM test WHERE test_id = %s" % (i % 100)) for row in res: found_total += 1 found += 1 del(res) yield "." assert found == 100, "%s != 100 (i: %s)" % (found, i) yield "Found: %s" % found_total def testDbQueryNotIndexed(self, num_run=1): s = time.time() with self.getTestDb() as db: for progress in self.fillTestDb(db): pass yield " (Db warmup done in %.3fs) " % (time.time() - s) found_total = 0 for i in range(num_run): # 1000x by test_id found = 0 res = db.execute("SELECT * FROM test WHERE json_id = %s" % i) for row in res: found_total += 1 found += 1 yield "." del(res) if i == 0 or i > 100: assert found == 0, "%s != 0 (i: %s)" % (found, i) else: assert found == 100, "%s != 100 (i: %s)" % (found, i) yield "Found: %s" % found_total ================================================ FILE: plugins/Benchmark/BenchmarkPack.py ================================================ import os import io from collections import OrderedDict from Plugin import PluginManager from Config import config from util import Msgpack @PluginManager.registerTo("Actions") class ActionsPlugin: def createZipFile(self, path): import zipfile test_data = b"Test" * 1024 file_name = b"\xc3\x81rv\xc3\xadzt\xc5\xb1r\xc5\x91%s.txt".decode("utf8") with zipfile.ZipFile(path, 'w') as archive: for y in range(100): zip_info = zipfile.ZipInfo(file_name % y, (1980, 1, 1, 0, 0, 0)) zip_info.compress_type = zipfile.ZIP_DEFLATED zip_info.create_system = 3 zip_info.flag_bits = 0 zip_info.external_attr = 25165824 archive.writestr(zip_info, test_data) def testPackZip(self, num_run=1): """ Test zip file creating """ yield "x 100 x 5KB " from Crypt import CryptHash zip_path = '%s/test.zip' % config.data_dir for i in range(num_run): self.createZipFile(zip_path) yield "." archive_size = os.path.getsize(zip_path) / 1024 yield "(Generated file size: %.2fkB)" % archive_size hash = CryptHash.sha512sum(open(zip_path, "rb")) valid = "cb32fb43783a1c06a2170a6bc5bb228a032b67ff7a1fd7a5efb9b467b400f553" assert hash == valid, "Invalid hash: %s != %s
" % (hash, valid) os.unlink(zip_path) def testUnpackZip(self, num_run=1): """ Test zip file reading """ yield "x 100 x 5KB " import zipfile zip_path = '%s/test.zip' % config.data_dir test_data = b"Test" * 1024 file_name = b"\xc3\x81rv\xc3\xadzt\xc5\xb1r\xc5\x91".decode("utf8") self.createZipFile(zip_path) for i in range(num_run): with zipfile.ZipFile(zip_path) as archive: for f in archive.filelist: assert f.filename.startswith(file_name), "Invalid filename: %s != %s" % (f.filename, file_name) data = archive.open(f.filename).read() assert archive.open(f.filename).read() == test_data, "Invalid data: %s..." % data[0:30] yield "." os.unlink(zip_path) def createArchiveFile(self, path, archive_type="gz"): import tarfile import gzip # Monkey patch _init_write_gz to use fixed date in order to keep the hash independent from datetime def nodate_write_gzip_header(self): self._write_mtime = 0 original_write_gzip_header(self) test_data_io = io.BytesIO(b"Test" * 1024) file_name = b"\xc3\x81rv\xc3\xadzt\xc5\xb1r\xc5\x91%s.txt".decode("utf8") original_write_gzip_header = gzip.GzipFile._write_gzip_header gzip.GzipFile._write_gzip_header = nodate_write_gzip_header with tarfile.open(path, 'w:%s' % archive_type) as archive: for y in range(100): test_data_io.seek(0) tar_info = tarfile.TarInfo(file_name % y) tar_info.size = 4 * 1024 archive.addfile(tar_info, test_data_io) def testPackArchive(self, num_run=1, archive_type="gz"): """ Test creating tar archive files """ yield "x 100 x 5KB " from Crypt import CryptHash hash_valid_db = { "gz": "92caec5121a31709cbbc8c11b0939758e670b055bbbe84f9beb3e781dfde710f", "bz2": "b613f41e6ee947c8b9b589d3e8fa66f3e28f63be23f4faf015e2f01b5c0b032d", "xz": "ae43892581d770959c8d993daffab25fd74490b7cf9fafc7aaee746f69895bcb", } archive_path = '%s/test.tar.%s' % (config.data_dir, archive_type) for i in range(num_run): self.createArchiveFile(archive_path, archive_type=archive_type) yield "." archive_size = os.path.getsize(archive_path) / 1024 yield "(Generated file size: %.2fkB)" % archive_size hash = CryptHash.sha512sum(open("%s/test.tar.%s" % (config.data_dir, archive_type), "rb")) valid = hash_valid_db[archive_type] assert hash == valid, "Invalid hash: %s != %s
" % (hash, valid) if os.path.isfile(archive_path): os.unlink(archive_path) def testUnpackArchive(self, num_run=1, archive_type="gz"): """ Test reading tar archive files """ yield "x 100 x 5KB " import tarfile test_data = b"Test" * 1024 file_name = b"\xc3\x81rv\xc3\xadzt\xc5\xb1r\xc5\x91%s.txt".decode("utf8") archive_path = '%s/test.tar.%s' % (config.data_dir, archive_type) self.createArchiveFile(archive_path, archive_type=archive_type) for i in range(num_run): with tarfile.open(archive_path, 'r:%s' % archive_type) as archive: for y in range(100): assert archive.extractfile(file_name % y).read() == test_data yield "." if os.path.isfile(archive_path): os.unlink(archive_path) def testPackMsgpack(self, num_run=1): """ Test msgpack encoding """ yield "x 100 x 5KB " binary = b'fqv\xf0\x1a"e\x10,\xbe\x9cT\x9e(\xa5]u\x072C\x8c\x15\xa2\xa8\x93Sw)\x19\x02\xdd\t\xfb\xf67\x88\xd9\xee\x86\xa1\xe4\xb6,\xc6\x14\xbb\xd7$z\x1d\xb2\xda\x85\xf5\xa0\x97^\x01*\xaf\xd3\xb0!\xb7\x9d\xea\x89\xbbh8\xa1"\xa7]e(@\xa2\xa5g\xb7[\xae\x8eE\xc2\x9fL\xb6s\x19\x19\r\xc8\x04S\xd0N\xe4]?/\x01\xea\xf6\xec\xd1\xb3\xc2\x91\x86\xd7\xf4K\xdf\xc2lV\xf4\xe8\x80\xfc\x8ep\xbb\x82\xb3\x86\x98F\x1c\xecS\xc8\x15\xcf\xdc\xf1\xed\xfc\xd8\x18r\xf9\x80\x0f\xfa\x8cO\x97(\x0b]\xf1\xdd\r\xe7\xbf\xed\x06\xbd\x1b?\xc5\xa0\xd7a\x82\xf3\xa8\xe6@\xf3\ri\xa1\xb10\xf6\xd4W\xbc\x86\x1a\xbb\xfd\x94!bS\xdb\xaeM\x92\x00#\x0b\xf7\xad\xe9\xc2\x8e\x86\xbfi![%\xd31]\xc6\xfc2\xc9\xda\xc6v\x82P\xcc\xa9\xea\xb9\xff\xf6\xc8\x17iD\xcf\xf3\xeeI\x04\xe9\xa1\x19\xbb\x01\x92\xf5nn4K\xf8\xbb\xc6\x17e>\xa7 \xbbv' data = OrderedDict( sorted({"int": 1024 * 1024 * 1024, "float": 12345.67890, "text": "hello" * 1024, "binary": binary}.items()) ) data_packed_valid = b'\x84\xa6binary\xc5\x01\x00fqv\xf0\x1a"e\x10,\xbe\x9cT\x9e(\xa5]u\x072C\x8c\x15\xa2\xa8\x93Sw)\x19\x02\xdd\t\xfb\xf67\x88\xd9\xee\x86\xa1\xe4\xb6,\xc6\x14\xbb\xd7$z\x1d\xb2\xda\x85\xf5\xa0\x97^\x01*\xaf\xd3\xb0!\xb7\x9d\xea\x89\xbbh8\xa1"\xa7]e(@\xa2\xa5g\xb7[\xae\x8eE\xc2\x9fL\xb6s\x19\x19\r\xc8\x04S\xd0N\xe4]?/\x01\xea\xf6\xec\xd1\xb3\xc2\x91\x86\xd7\xf4K\xdf\xc2lV\xf4\xe8\x80\xfc\x8ep\xbb\x82\xb3\x86\x98F\x1c\xecS\xc8\x15\xcf\xdc\xf1\xed\xfc\xd8\x18r\xf9\x80\x0f\xfa\x8cO\x97(\x0b]\xf1\xdd\r\xe7\xbf\xed\x06\xbd\x1b?\xc5\xa0\xd7a\x82\xf3\xa8\xe6@\xf3\ri\xa1\xb10\xf6\xd4W\xbc\x86\x1a\xbb\xfd\x94!bS\xdb\xaeM\x92\x00#\x0b\xf7\xad\xe9\xc2\x8e\x86\xbfi![%\xd31]\xc6\xfc2\xc9\xda\xc6v\x82P\xcc\xa9\xea\xb9\xff\xf6\xc8\x17iD\xcf\xf3\xeeI\x04\xe9\xa1\x19\xbb\x01\x92\xf5nn4K\xf8\xbb\xc6\x17e>\xa7 \xbbv\xa5float\xcb@\xc8\x1c\xd6\xe61\xf8\xa1\xa3int\xce@\x00\x00\x00\xa4text\xda\x14\x00' data_packed_valid += b'hello' * 1024 for y in range(num_run): for i in range(100): data_packed = Msgpack.pack(data) yield "." assert data_packed == data_packed_valid, "%s
!=
%s" % (repr(data_packed), repr(data_packed_valid)) def testUnpackMsgpack(self, num_run=1): """ Test msgpack decoding """ yield "x 5KB " binary = b'fqv\xf0\x1a"e\x10,\xbe\x9cT\x9e(\xa5]u\x072C\x8c\x15\xa2\xa8\x93Sw)\x19\x02\xdd\t\xfb\xf67\x88\xd9\xee\x86\xa1\xe4\xb6,\xc6\x14\xbb\xd7$z\x1d\xb2\xda\x85\xf5\xa0\x97^\x01*\xaf\xd3\xb0!\xb7\x9d\xea\x89\xbbh8\xa1"\xa7]e(@\xa2\xa5g\xb7[\xae\x8eE\xc2\x9fL\xb6s\x19\x19\r\xc8\x04S\xd0N\xe4]?/\x01\xea\xf6\xec\xd1\xb3\xc2\x91\x86\xd7\xf4K\xdf\xc2lV\xf4\xe8\x80\xfc\x8ep\xbb\x82\xb3\x86\x98F\x1c\xecS\xc8\x15\xcf\xdc\xf1\xed\xfc\xd8\x18r\xf9\x80\x0f\xfa\x8cO\x97(\x0b]\xf1\xdd\r\xe7\xbf\xed\x06\xbd\x1b?\xc5\xa0\xd7a\x82\xf3\xa8\xe6@\xf3\ri\xa1\xb10\xf6\xd4W\xbc\x86\x1a\xbb\xfd\x94!bS\xdb\xaeM\x92\x00#\x0b\xf7\xad\xe9\xc2\x8e\x86\xbfi![%\xd31]\xc6\xfc2\xc9\xda\xc6v\x82P\xcc\xa9\xea\xb9\xff\xf6\xc8\x17iD\xcf\xf3\xeeI\x04\xe9\xa1\x19\xbb\x01\x92\xf5nn4K\xf8\xbb\xc6\x17e>\xa7 \xbbv' data = OrderedDict( sorted({"int": 1024 * 1024 * 1024, "float": 12345.67890, "text": "hello" * 1024, "binary": binary}.items()) ) data_packed = b'\x84\xa6binary\xc5\x01\x00fqv\xf0\x1a"e\x10,\xbe\x9cT\x9e(\xa5]u\x072C\x8c\x15\xa2\xa8\x93Sw)\x19\x02\xdd\t\xfb\xf67\x88\xd9\xee\x86\xa1\xe4\xb6,\xc6\x14\xbb\xd7$z\x1d\xb2\xda\x85\xf5\xa0\x97^\x01*\xaf\xd3\xb0!\xb7\x9d\xea\x89\xbbh8\xa1"\xa7]e(@\xa2\xa5g\xb7[\xae\x8eE\xc2\x9fL\xb6s\x19\x19\r\xc8\x04S\xd0N\xe4]?/\x01\xea\xf6\xec\xd1\xb3\xc2\x91\x86\xd7\xf4K\xdf\xc2lV\xf4\xe8\x80\xfc\x8ep\xbb\x82\xb3\x86\x98F\x1c\xecS\xc8\x15\xcf\xdc\xf1\xed\xfc\xd8\x18r\xf9\x80\x0f\xfa\x8cO\x97(\x0b]\xf1\xdd\r\xe7\xbf\xed\x06\xbd\x1b?\xc5\xa0\xd7a\x82\xf3\xa8\xe6@\xf3\ri\xa1\xb10\xf6\xd4W\xbc\x86\x1a\xbb\xfd\x94!bS\xdb\xaeM\x92\x00#\x0b\xf7\xad\xe9\xc2\x8e\x86\xbfi![%\xd31]\xc6\xfc2\xc9\xda\xc6v\x82P\xcc\xa9\xea\xb9\xff\xf6\xc8\x17iD\xcf\xf3\xeeI\x04\xe9\xa1\x19\xbb\x01\x92\xf5nn4K\xf8\xbb\xc6\x17e>\xa7 \xbbv\xa5float\xcb@\xc8\x1c\xd6\xe61\xf8\xa1\xa3int\xce@\x00\x00\x00\xa4text\xda\x14\x00' data_packed += b'hello' * 1024 for y in range(num_run): data_unpacked = Msgpack.unpack(data_packed, decode=False) yield "." assert data_unpacked == data, "%s
!=
%s" % (data_unpacked, data) def testUnpackMsgpackStreaming(self, num_run=1, fallback=False): """ Test streaming msgpack decoding """ yield "x 1000 x 5KB " binary = b'fqv\xf0\x1a"e\x10,\xbe\x9cT\x9e(\xa5]u\x072C\x8c\x15\xa2\xa8\x93Sw)\x19\x02\xdd\t\xfb\xf67\x88\xd9\xee\x86\xa1\xe4\xb6,\xc6\x14\xbb\xd7$z\x1d\xb2\xda\x85\xf5\xa0\x97^\x01*\xaf\xd3\xb0!\xb7\x9d\xea\x89\xbbh8\xa1"\xa7]e(@\xa2\xa5g\xb7[\xae\x8eE\xc2\x9fL\xb6s\x19\x19\r\xc8\x04S\xd0N\xe4]?/\x01\xea\xf6\xec\xd1\xb3\xc2\x91\x86\xd7\xf4K\xdf\xc2lV\xf4\xe8\x80\xfc\x8ep\xbb\x82\xb3\x86\x98F\x1c\xecS\xc8\x15\xcf\xdc\xf1\xed\xfc\xd8\x18r\xf9\x80\x0f\xfa\x8cO\x97(\x0b]\xf1\xdd\r\xe7\xbf\xed\x06\xbd\x1b?\xc5\xa0\xd7a\x82\xf3\xa8\xe6@\xf3\ri\xa1\xb10\xf6\xd4W\xbc\x86\x1a\xbb\xfd\x94!bS\xdb\xaeM\x92\x00#\x0b\xf7\xad\xe9\xc2\x8e\x86\xbfi![%\xd31]\xc6\xfc2\xc9\xda\xc6v\x82P\xcc\xa9\xea\xb9\xff\xf6\xc8\x17iD\xcf\xf3\xeeI\x04\xe9\xa1\x19\xbb\x01\x92\xf5nn4K\xf8\xbb\xc6\x17e>\xa7 \xbbv' data = OrderedDict( sorted({"int": 1024 * 1024 * 1024, "float": 12345.67890, "text": "hello" * 1024, "binary": binary}.items()) ) data_packed = b'\x84\xa6binary\xc5\x01\x00fqv\xf0\x1a"e\x10,\xbe\x9cT\x9e(\xa5]u\x072C\x8c\x15\xa2\xa8\x93Sw)\x19\x02\xdd\t\xfb\xf67\x88\xd9\xee\x86\xa1\xe4\xb6,\xc6\x14\xbb\xd7$z\x1d\xb2\xda\x85\xf5\xa0\x97^\x01*\xaf\xd3\xb0!\xb7\x9d\xea\x89\xbbh8\xa1"\xa7]e(@\xa2\xa5g\xb7[\xae\x8eE\xc2\x9fL\xb6s\x19\x19\r\xc8\x04S\xd0N\xe4]?/\x01\xea\xf6\xec\xd1\xb3\xc2\x91\x86\xd7\xf4K\xdf\xc2lV\xf4\xe8\x80\xfc\x8ep\xbb\x82\xb3\x86\x98F\x1c\xecS\xc8\x15\xcf\xdc\xf1\xed\xfc\xd8\x18r\xf9\x80\x0f\xfa\x8cO\x97(\x0b]\xf1\xdd\r\xe7\xbf\xed\x06\xbd\x1b?\xc5\xa0\xd7a\x82\xf3\xa8\xe6@\xf3\ri\xa1\xb10\xf6\xd4W\xbc\x86\x1a\xbb\xfd\x94!bS\xdb\xaeM\x92\x00#\x0b\xf7\xad\xe9\xc2\x8e\x86\xbfi![%\xd31]\xc6\xfc2\xc9\xda\xc6v\x82P\xcc\xa9\xea\xb9\xff\xf6\xc8\x17iD\xcf\xf3\xeeI\x04\xe9\xa1\x19\xbb\x01\x92\xf5nn4K\xf8\xbb\xc6\x17e>\xa7 \xbbv\xa5float\xcb@\xc8\x1c\xd6\xe61\xf8\xa1\xa3int\xce@\x00\x00\x00\xa4text\xda\x14\x00' data_packed += b'hello' * 1024 for i in range(num_run): unpacker = Msgpack.getUnpacker(decode=False, fallback=fallback) for y in range(1000): unpacker.feed(data_packed) for data_unpacked in unpacker: pass yield "." assert data == data_unpacked, "%s != %s" % (data_unpacked, data) ================================================ FILE: plugins/Benchmark/BenchmarkPlugin.py ================================================ import os import time import io import math import hashlib import re import sys from Config import config from Crypt import CryptHash from Plugin import PluginManager from Debug import Debug from util import helper plugin_dir = os.path.dirname(__file__) benchmark_key = None @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object): @helper.encodeResponse def actionBenchmark(self): global benchmark_key script_nonce = self.getScriptNonce() if not benchmark_key: benchmark_key = CryptHash.random(encoding="base64") self.sendHeader(script_nonce=script_nonce) if "Multiuser" in PluginManager.plugin_manager.plugin_names and not config.multiuser_local: yield "This function is disabled on this proxy" return data = self.render( plugin_dir + "/media/benchmark.html", script_nonce=script_nonce, benchmark_key=benchmark_key, filter=re.sub("[^A-Za-z0-9]", "", self.get.get("filter", "")) ) yield data @helper.encodeResponse def actionBenchmarkResult(self): global benchmark_key if self.get.get("benchmark_key", "") != benchmark_key: return self.error403("Invalid benchmark key") self.sendHeader(content_type="text/plain", noscript=True) if "Multiuser" in PluginManager.plugin_manager.plugin_names and not config.multiuser_local: yield "This function is disabled on this proxy" return yield " " * 1024 # Head (required for streaming) import main s = time.time() for part in main.actions.testBenchmark(filter=self.get.get("filter", "")): yield part yield "\n - Total time: %.3fs" % (time.time() - s) @PluginManager.registerTo("Actions") class ActionsPlugin: def getMultiplerTitle(self, multipler): if multipler < 0.3: multipler_title = "Sloooow" elif multipler < 0.6: multipler_title = "Ehh" elif multipler < 0.8: multipler_title = "Goodish" elif multipler < 1.2: multipler_title = "OK" elif multipler < 1.7: multipler_title = "Fine" elif multipler < 2.5: multipler_title = "Fast" elif multipler < 3.5: multipler_title = "WOW" else: multipler_title = "Insane!!" return multipler_title def formatResult(self, taken, standard): if not standard: return " Done in %.3fs" % taken if taken > 0: multipler = standard / taken else: multipler = 99 multipler_title = self.getMultiplerTitle(multipler) return " Done in %.3fs = %s (%.2fx)" % (taken, multipler_title, multipler) def getBenchmarkTests(self, online=False): if hasattr(super(), "getBenchmarkTests"): tests = super().getBenchmarkTests(online) else: tests = [] tests.extend([ {"func": self.testHdPrivatekey, "num": 50, "time_standard": 0.57}, {"func": self.testSign, "num": 20, "time_standard": 0.46}, {"func": self.testVerify, "kwargs": {"lib_verify": "sslcrypto_fallback"}, "num": 20, "time_standard": 0.38}, {"func": self.testVerify, "kwargs": {"lib_verify": "sslcrypto"}, "num": 200, "time_standard": 0.30}, {"func": self.testVerify, "kwargs": {"lib_verify": "libsecp256k1"}, "num": 200, "time_standard": 0.10}, {"func": self.testPackMsgpack, "num": 100, "time_standard": 0.35}, {"func": self.testUnpackMsgpackStreaming, "kwargs": {"fallback": False}, "num": 100, "time_standard": 0.35}, {"func": self.testUnpackMsgpackStreaming, "kwargs": {"fallback": True}, "num": 10, "time_standard": 0.5}, {"func": self.testPackZip, "num": 5, "time_standard": 0.065}, {"func": self.testPackArchive, "kwargs": {"archive_type": "gz"}, "num": 5, "time_standard": 0.08}, {"func": self.testPackArchive, "kwargs": {"archive_type": "bz2"}, "num": 5, "time_standard": 0.68}, {"func": self.testPackArchive, "kwargs": {"archive_type": "xz"}, "num": 5, "time_standard": 0.47}, {"func": self.testUnpackZip, "num": 20, "time_standard": 0.25}, {"func": self.testUnpackArchive, "kwargs": {"archive_type": "gz"}, "num": 20, "time_standard": 0.28}, {"func": self.testUnpackArchive, "kwargs": {"archive_type": "bz2"}, "num": 20, "time_standard": 0.83}, {"func": self.testUnpackArchive, "kwargs": {"archive_type": "xz"}, "num": 20, "time_standard": 0.38}, {"func": self.testCryptHash, "kwargs": {"hash_type": "sha256"}, "num": 10, "time_standard": 0.50}, {"func": self.testCryptHash, "kwargs": {"hash_type": "sha512"}, "num": 10, "time_standard": 0.33}, {"func": self.testCryptHashlib, "kwargs": {"hash_type": "sha3_256"}, "num": 10, "time_standard": 0.33}, {"func": self.testCryptHashlib, "kwargs": {"hash_type": "sha3_512"}, "num": 10, "time_standard": 0.65}, {"func": self.testRandom, "num": 100, "time_standard": 0.08}, ]) if online: tests += [ {"func": self.testHttps, "num": 1, "time_standard": 2.1} ] return tests def testBenchmark(self, num_multipler=1, online=False, num_run=None, filter=None): """ Run benchmark on client functions """ tests = self.getBenchmarkTests(online=online) if filter: tests = [test for test in tests[:] if filter.lower() in test["func"].__name__.lower()] yield "\n" res = {} res_time_taken = {} multiplers = [] for test in tests: s = time.time() if num_run: num_run_test = num_run else: num_run_test = math.ceil(test["num"] * num_multipler) func = test["func"] func_name = func.__name__ kwargs = test.get("kwargs", {}) key = "%s %s" % (func_name, kwargs) if kwargs: yield "* Running %s (%s) x %s " % (func_name, kwargs, num_run_test) else: yield "* Running %s x %s " % (func_name, num_run_test) i = 0 try: for progress in func(num_run_test, **kwargs): i += 1 if num_run_test > 10: should_print = i % (num_run_test / 10) == 0 or progress != "." else: should_print = True if should_print: if num_run_test == 1 and progress == ".": progress = "..." yield progress time_taken = time.time() - s if num_run: time_standard = 0 else: time_standard = test["time_standard"] * num_multipler yield self.formatResult(time_taken, time_standard) yield "\n" res[key] = "ok" res_time_taken[key] = time_taken multiplers.append(time_standard / max(time_taken, 0.001)) except Exception as err: res[key] = err yield "Failed!\n! Error: %s\n\n" % Debug.formatException(err) yield "\n== Result ==\n" # Check verification speed if "testVerify {'lib_verify': 'sslcrypto'}" in res_time_taken: speed_order = ["sslcrypto_fallback", "sslcrypto", "libsecp256k1"] time_taken = {} for lib_verify in speed_order: time_taken[lib_verify] = res_time_taken["testVerify {'lib_verify': '%s'}" % lib_verify] time_taken["sslcrypto_fallback"] *= 10 # fallback benchmark only run 20 times instead of 200 speedup_sslcrypto = time_taken["sslcrypto_fallback"] / time_taken["sslcrypto"] speedup_libsecp256k1 = time_taken["sslcrypto_fallback"] / time_taken["libsecp256k1"] yield "\n* Verification speedup:\n" yield " - OpenSSL: %.1fx (reference: 7.0x)\n" % speedup_sslcrypto yield " - libsecp256k1: %.1fx (reference: 23.8x)\n" % speedup_libsecp256k1 if speedup_sslcrypto < 2: res["Verification speed"] = "error: OpenSSL speedup low: %.1fx" % speedup_sslcrypto if speedup_libsecp256k1 < speedup_sslcrypto: res["Verification speed"] = "error: libsecp256k1 speedup low: %.1fx" % speedup_libsecp256k1 if not res: yield "! No tests found" if config.action == "test": sys.exit(1) else: num_failed = len([res_key for res_key, res_val in res.items() if res_val != "ok"]) num_success = len([res_key for res_key, res_val in res.items() if res_val == "ok"]) yield "\n* Tests:\n" yield " - Total: %s tests\n" % len(res) yield " - Success: %s tests\n" % num_success yield " - Failed: %s tests\n" % num_failed if any(multiplers): multipler_avg = sum(multiplers) / len(multiplers) multipler_title = self.getMultiplerTitle(multipler_avg) yield " - Average speed factor: %.2fx (%s)\n" % (multipler_avg, multipler_title) # Display errors for res_key, res_val in res.items(): if res_val != "ok": yield " ! %s %s\n" % (res_key, res_val) if num_failed != 0 and config.action == "test": sys.exit(1) def testHttps(self, num_run=1): """ Test https connection with valid and invalid certs """ import urllib.request import urllib.error body = urllib.request.urlopen("https://google.com").read() assert len(body) > 100 yield "." badssl_urls = [ "https://expired.badssl.com/", "https://wrong.host.badssl.com/", "https://self-signed.badssl.com/", "https://untrusted-root.badssl.com/" ] for badssl_url in badssl_urls: try: body = urllib.request.urlopen(badssl_url).read() https_err = None except urllib.error.URLError as err: https_err = err assert https_err yield "." def testCryptHash(self, num_run=1, hash_type="sha256"): """ Test hashing functions """ yield "(5MB) " from Crypt import CryptHash hash_types = { "sha256": {"func": CryptHash.sha256sum, "hash_valid": "8cd629d9d6aff6590da8b80782a5046d2673d5917b99d5603c3dcb4005c45ffa"}, "sha512": {"func": CryptHash.sha512sum, "hash_valid": "9ca7e855d430964d5b55b114e95c6bbb114a6d478f6485df93044d87b108904d"} } hash_func = hash_types[hash_type]["func"] hash_valid = hash_types[hash_type]["hash_valid"] data = io.BytesIO(b"Hello" * 1024 * 1024) # 5MB for i in range(num_run): data.seek(0) hash = hash_func(data) yield "." assert hash == hash_valid, "%s != %s" % (hash, hash_valid) def testCryptHashlib(self, num_run=1, hash_type="sha3_256"): """ Test SHA3 hashing functions """ yield "x 5MB " hash_types = { "sha3_256": {"func": hashlib.sha3_256, "hash_valid": "c8aeb3ef9fe5d6404871c0d2a4410a4d4e23268e06735648c9596f436c495f7e"}, "sha3_512": {"func": hashlib.sha3_512, "hash_valid": "b75dba9472d8af3cc945ce49073f3f8214d7ac12086c0453fb08944823dee1ae83b3ffbc87a53a57cc454521d6a26fe73ff0f3be38dddf3f7de5d7692ebc7f95"}, } hash_func = hash_types[hash_type]["func"] hash_valid = hash_types[hash_type]["hash_valid"] data = io.BytesIO(b"Hello" * 1024 * 1024) # 5MB for i in range(num_run): data.seek(0) h = hash_func() while 1: buff = data.read(1024 * 64) if not buff: break h.update(buff) hash = h.hexdigest() yield "." assert hash == hash_valid, "%s != %s" % (hash, hash_valid) def testRandom(self, num_run=1): """ Test generating random data """ yield "x 1000 x 256 bytes " for i in range(num_run): data_last = None for y in range(1000): data = os.urandom(256) assert data != data_last assert len(data) == 256 data_last = data yield "." def testHdPrivatekey(self, num_run=2): """ Test generating deterministic private keys from a master seed """ from Crypt import CryptBitcoin seed = "e180efa477c63b0f2757eac7b1cce781877177fe0966be62754ffd4c8592ce38" privatekeys = [] for i in range(num_run): privatekeys.append(CryptBitcoin.hdPrivatekey(seed, i * 10)) yield "." valid = "5JSbeF5PevdrsYjunqpg7kAGbnCVYa1T4APSL3QRu8EoAmXRc7Y" assert privatekeys[0] == valid, "%s != %s" % (privatekeys[0], valid) if len(privatekeys) > 1: assert privatekeys[0] != privatekeys[-1] def testSign(self, num_run=1): """ Test signing data using a private key """ from Crypt import CryptBitcoin data = "Hello" * 1024 privatekey = "5JsunC55XGVqFQj5kPGK4MWgTL26jKbnPhjnmchSNPo75XXCwtk" for i in range(num_run): yield "." sign = CryptBitcoin.sign(data, privatekey) valid = "G1GXaDauZ8vX/N9Jn+MRiGm9h+I94zUhDnNYFaqMGuOiBHB+kp4cRPZOL7l1yqK5BHa6J+W97bMjvTXtxzljp6w=" assert sign == valid, "%s != %s" % (sign, valid) def testVerify(self, num_run=1, lib_verify="sslcrypto"): """ Test verification of generated signatures """ from Crypt import CryptBitcoin CryptBitcoin.loadLib(lib_verify, silent=True) data = "Hello" * 1024 privatekey = "5JsunC55XGVqFQj5kPGK4MWgTL26jKbnPhjnmchSNPo75XXCwtk" address = CryptBitcoin.privatekeyToAddress(privatekey) sign = "G1GXaDauZ8vX/N9Jn+MRiGm9h+I94zUhDnNYFaqMGuOiBHB+kp4cRPZOL7l1yqK5BHa6J+W97bMjvTXtxzljp6w=" for i in range(num_run): ok = CryptBitcoin.verify(data, address, sign, lib_verify=lib_verify) yield "." assert ok, "does not verify from %s" % address if lib_verify == "sslcrypto": yield("(%s)" % CryptBitcoin.sslcrypto.ecc.get_backend()) def testPortCheckers(self): """ Test all active open port checker """ from Peer import PeerPortchecker for ip_type, func_names in PeerPortchecker.PeerPortchecker.checker_functions.items(): yield "\n- %s:" % ip_type for func_name in func_names: yield "\n - Tracker %s: " % func_name try: for res in self.testPortChecker(func_name): yield res except Exception as err: yield Debug.formatException(err) def testPortChecker(self, func_name): """ Test single open port checker """ from Peer import PeerPortchecker peer_portchecker = PeerPortchecker.PeerPortchecker(None) announce_func = getattr(peer_portchecker, func_name) res = announce_func(3894) yield res def testAll(self): """ Run all tests to check system compatibility with ZeroNet functions """ for progress in self.testBenchmark(online=not config.offline, num_run=1): yield progress @PluginManager.registerTo("ConfigPlugin") class ConfigPlugin(object): def createArguments(self): back = super(ConfigPlugin, self).createArguments() if self.getCmdlineValue("test") == "benchmark": self.test_parser.add_argument( '--num_multipler', help='Benchmark run time multipler', default=1.0, type=float, metavar='num' ) self.test_parser.add_argument( '--filter', help='Filter running benchmark', default=None, metavar='test name' ) elif self.getCmdlineValue("test") == "portChecker": self.test_parser.add_argument( '--func_name', help='Name of open port checker function', default=None, metavar='func_name' ) return back ================================================ FILE: plugins/Benchmark/__init__.py ================================================ from . import BenchmarkPlugin from . import BenchmarkDb from . import BenchmarkPack ================================================ FILE: plugins/Benchmark/media/benchmark.html ================================================

Benchmark

Start benchmark (It will take around 20 sec)
================================================ FILE: plugins/Benchmark/plugin_info.json ================================================ { "name": "Benchmark", "description": "Test and benchmark database and cryptographic functions related to ZeroNet.", "default": "enabled" } ================================================ FILE: plugins/Bigfile/BigfilePiecefield.py ================================================ import array def packPiecefield(data): if not isinstance(data, bytes) and not isinstance(data, bytearray): raise Exception("Invalid data type: %s" % type(data)) res = [] if not data: return array.array("H", b"") if data[0] == b"\x00": res.append(0) find = b"\x01" else: find = b"\x00" last_pos = 0 pos = 0 while 1: pos = data.find(find, pos) if find == b"\x00": find = b"\x01" else: find = b"\x00" if pos == -1: res.append(len(data) - last_pos) break res.append(pos - last_pos) last_pos = pos return array.array("H", res) def unpackPiecefield(data): if not data: return b"" res = [] char = b"\x01" for times in data: if times > 10000: return b"" res.append(char * times) if char == b"\x01": char = b"\x00" else: char = b"\x01" return b"".join(res) def spliceBit(data, idx, bit): if bit != b"\x00" and bit != b"\x01": raise Exception("Invalid bit: %s" % bit) if len(data) < idx: data = data.ljust(idx + 1, b"\x00") return data[:idx] + bit + data[idx+ 1:] class Piecefield(object): def tostring(self): return "".join(["1" if b else "0" for b in self.tobytes()]) class BigfilePiecefield(Piecefield): __slots__ = ["data"] def __init__(self): self.data = b"" def frombytes(self, s): if not isinstance(s, bytes) and not isinstance(s, bytearray): raise Exception("Invalid type: %s" % type(s)) self.data = s def tobytes(self): return self.data def pack(self): return packPiecefield(self.data).tobytes() def unpack(self, s): self.data = unpackPiecefield(array.array("H", s)) def __getitem__(self, key): try: return self.data[key] except IndexError: return False def __setitem__(self, key, value): self.data = spliceBit(self.data, key, value) class BigfilePiecefieldPacked(Piecefield): __slots__ = ["data"] def __init__(self): self.data = b"" def frombytes(self, data): if not isinstance(data, bytes) and not isinstance(data, bytearray): raise Exception("Invalid type: %s" % type(data)) self.data = packPiecefield(data).tobytes() def tobytes(self): return unpackPiecefield(array.array("H", self.data)) def pack(self): return array.array("H", self.data).tobytes() def unpack(self, data): self.data = data def __getitem__(self, key): try: return self.tobytes()[key] except IndexError: return False def __setitem__(self, key, value): data = spliceBit(self.tobytes(), key, value) self.frombytes(data) if __name__ == "__main__": import os import psutil import time testdata = b"\x01" * 100 + b"\x00" * 900 + b"\x01" * 4000 + b"\x00" * 4999 + b"\x01" meminfo = psutil.Process(os.getpid()).memory_info for storage in [BigfilePiecefieldPacked, BigfilePiecefield]: print("-- Testing storage: %s --" % storage) m = meminfo()[0] s = time.time() piecefields = {} for i in range(10000): piecefield = storage() piecefield.frombytes(testdata[:i] + b"\x00" + testdata[i + 1:]) piecefields[i] = piecefield print("Create x10000: +%sKB in %.3fs (len: %s)" % ((meminfo()[0] - m) / 1024, time.time() - s, len(piecefields[0].data))) m = meminfo()[0] s = time.time() for piecefield in list(piecefields.values()): val = piecefield[1000] print("Query one x10000: +%sKB in %.3fs" % ((meminfo()[0] - m) / 1024, time.time() - s)) m = meminfo()[0] s = time.time() for piecefield in list(piecefields.values()): piecefield[1000] = b"\x01" print("Change one x10000: +%sKB in %.3fs" % ((meminfo()[0] - m) / 1024, time.time() - s)) m = meminfo()[0] s = time.time() for piecefield in list(piecefields.values()): packed = piecefield.pack() print("Pack x10000: +%sKB in %.3fs (len: %s)" % ((meminfo()[0] - m) / 1024, time.time() - s, len(packed))) m = meminfo()[0] s = time.time() for piecefield in list(piecefields.values()): piecefield.unpack(packed) print("Unpack x10000: +%sKB in %.3fs (len: %s)" % ((meminfo()[0] - m) / 1024, time.time() - s, len(piecefields[0].data))) piecefields = {} ================================================ FILE: plugins/Bigfile/BigfilePlugin.py ================================================ import time import os import subprocess import shutil import collections import math import warnings import base64 import binascii import json import gevent import gevent.lock from Plugin import PluginManager from Debug import Debug from Crypt import CryptHash with warnings.catch_warnings(): warnings.filterwarnings("ignore") # Ignore missing sha3 warning import merkletools from util import helper from util import Msgpack from util.Flag import flag import util from .BigfilePiecefield import BigfilePiecefield, BigfilePiecefieldPacked # We can only import plugin host clases after the plugins are loaded @PluginManager.afterLoad def importPluginnedClasses(): global VerifyError, config from Content.ContentManager import VerifyError from Config import config if "upload_nonces" not in locals(): upload_nonces = {} @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object): def isCorsAllowed(self, path): if path == "/ZeroNet-Internal/BigfileUpload": return True else: return super(UiRequestPlugin, self).isCorsAllowed(path) @helper.encodeResponse def actionBigfileUpload(self): nonce = self.get.get("upload_nonce") if nonce not in upload_nonces: return self.error403("Upload nonce error.") upload_info = upload_nonces[nonce] del upload_nonces[nonce] self.sendHeader(200, "text/html", noscript=True, extra_headers={ "Access-Control-Allow-Origin": "null", "Access-Control-Allow-Credentials": "true" }) self.readMultipartHeaders(self.env['wsgi.input']) # Skip http headers result = self.handleBigfileUpload(upload_info, self.env['wsgi.input'].read) return json.dumps(result) def actionBigfileUploadWebsocket(self): ws = self.env.get("wsgi.websocket") if not ws: self.start_response("400 Bad Request", []) return [b"Not a websocket request!"] nonce = self.get.get("upload_nonce") if nonce not in upload_nonces: return self.error403("Upload nonce error.") upload_info = upload_nonces[nonce] del upload_nonces[nonce] ws.send("poll") buffer = b"" def read(size): nonlocal buffer while len(buffer) < size: buffer += ws.receive() ws.send("poll") part, buffer = buffer[:size], buffer[size:] return part result = self.handleBigfileUpload(upload_info, read) ws.send(json.dumps(result)) def handleBigfileUpload(self, upload_info, read): site = upload_info["site"] inner_path = upload_info["inner_path"] with site.storage.open(inner_path, "wb", create_dirs=True) as out_file: merkle_root, piece_size, piecemap_info = site.content_manager.hashBigfile( read, upload_info["size"], upload_info["piece_size"], out_file ) if len(piecemap_info["sha512_pieces"]) == 1: # Small file, don't split hash = binascii.hexlify(piecemap_info["sha512_pieces"][0]) hash_id = site.content_manager.hashfield.getHashId(hash) site.content_manager.optionalDownloaded(inner_path, hash_id, upload_info["size"], own=True) else: # Big file file_name = helper.getFilename(inner_path) site.storage.open(upload_info["piecemap"], "wb").write(Msgpack.pack({file_name: piecemap_info})) # Find piecemap and file relative path to content.json file_info = site.content_manager.getFileInfo(inner_path, new_file=True) content_inner_path_dir = helper.getDirname(file_info["content_inner_path"]) piecemap_relative_path = upload_info["piecemap"][len(content_inner_path_dir):] file_relative_path = inner_path[len(content_inner_path_dir):] # Add file to content.json if site.storage.isFile(file_info["content_inner_path"]): content = site.storage.loadJson(file_info["content_inner_path"]) else: content = {} if "files_optional" not in content: content["files_optional"] = {} content["files_optional"][file_relative_path] = { "sha512": merkle_root, "size": upload_info["size"], "piecemap": piecemap_relative_path, "piece_size": piece_size } merkle_root_hash_id = site.content_manager.hashfield.getHashId(merkle_root) site.content_manager.optionalDownloaded(inner_path, merkle_root_hash_id, upload_info["size"], own=True) site.storage.writeJson(file_info["content_inner_path"], content) site.content_manager.contents.loadItem(file_info["content_inner_path"]) # reload cache return { "merkle_root": merkle_root, "piece_num": len(piecemap_info["sha512_pieces"]), "piece_size": piece_size, "inner_path": inner_path } def readMultipartHeaders(self, wsgi_input): found = False for i in range(100): line = wsgi_input.readline() if line == b"\r\n": found = True break if not found: raise Exception("No multipart header found") return i def actionFile(self, file_path, *args, **kwargs): if kwargs.get("file_size", 0) > 1024 * 1024 and kwargs.get("path_parts"): # Only check files larger than 1MB path_parts = kwargs["path_parts"] site = self.server.site_manager.get(path_parts["address"]) big_file = site.storage.openBigfile(path_parts["inner_path"], prebuffer=2 * 1024 * 1024) if big_file: kwargs["file_obj"] = big_file kwargs["file_size"] = big_file.size return super(UiRequestPlugin, self).actionFile(file_path, *args, **kwargs) @PluginManager.registerTo("UiWebsocket") class UiWebsocketPlugin(object): def actionBigfileUploadInit(self, to, inner_path, size, protocol="xhr"): valid_signers = self.site.content_manager.getValidSigners(inner_path) auth_address = self.user.getAuthAddress(self.site.address) if not self.site.settings["own"] and auth_address not in valid_signers: self.log.error("FileWrite forbidden %s not in valid_signers %s" % (auth_address, valid_signers)) return self.response(to, {"error": "Forbidden, you can only modify your own files"}) nonce = CryptHash.random() piece_size = 1024 * 1024 inner_path = self.site.content_manager.sanitizePath(inner_path) file_info = self.site.content_manager.getFileInfo(inner_path, new_file=True) content_inner_path_dir = helper.getDirname(file_info["content_inner_path"]) file_relative_path = inner_path[len(content_inner_path_dir):] upload_nonces[nonce] = { "added": time.time(), "site": self.site, "inner_path": inner_path, "websocket_client": self, "size": size, "piece_size": piece_size, "piecemap": inner_path + ".piecemap.msgpack" } if protocol == "xhr": return { "url": "/ZeroNet-Internal/BigfileUpload?upload_nonce=" + nonce, "piece_size": piece_size, "inner_path": inner_path, "file_relative_path": file_relative_path } elif protocol == "websocket": server_url = self.request.getWsServerUrl() if server_url: proto, host = server_url.split("://") origin = proto.replace("http", "ws") + "://" + host else: origin = "{origin}" return { "url": origin + "/ZeroNet-Internal/BigfileUploadWebsocket?upload_nonce=" + nonce, "piece_size": piece_size, "inner_path": inner_path, "file_relative_path": file_relative_path } else: return {"error": "Unknown protocol"} @flag.no_multiuser def actionSiteSetAutodownloadBigfileLimit(self, to, limit): permissions = self.getPermissions(to) if "ADMIN" not in permissions: return self.response(to, "You don't have permission to run this command") self.site.settings["autodownload_bigfile_size_limit"] = int(limit) self.response(to, "ok") def actionFileDelete(self, to, inner_path): piecemap_inner_path = inner_path + ".piecemap.msgpack" if self.hasFilePermission(inner_path) and self.site.storage.isFile(piecemap_inner_path): # Also delete .piecemap.msgpack file if exists self.log.debug("Deleting piecemap: %s" % piecemap_inner_path) file_info = self.site.content_manager.getFileInfo(piecemap_inner_path) if file_info: content_json = self.site.storage.loadJson(file_info["content_inner_path"]) relative_path = file_info["relative_path"] if relative_path in content_json.get("files_optional", {}): del content_json["files_optional"][relative_path] self.site.storage.writeJson(file_info["content_inner_path"], content_json) self.site.content_manager.loadContent(file_info["content_inner_path"], add_bad_files=False, force=True) try: self.site.storage.delete(piecemap_inner_path) except Exception as err: self.log.error("File %s delete error: %s" % (piecemap_inner_path, err)) return super(UiWebsocketPlugin, self).actionFileDelete(to, inner_path) @PluginManager.registerTo("ContentManager") class ContentManagerPlugin(object): def getFileInfo(self, inner_path, *args, **kwargs): if "|" not in inner_path: return super(ContentManagerPlugin, self).getFileInfo(inner_path, *args, **kwargs) inner_path, file_range = inner_path.split("|") pos_from, pos_to = map(int, file_range.split("-")) file_info = super(ContentManagerPlugin, self).getFileInfo(inner_path, *args, **kwargs) return file_info def readFile(self, read_func, size, buff_size=1024 * 64): part_num = 0 recv_left = size while 1: part_num += 1 read_size = min(buff_size, recv_left) part = read_func(read_size) if not part: break yield part if part_num % 100 == 0: # Avoid blocking ZeroNet execution during upload time.sleep(0.001) recv_left -= read_size if recv_left <= 0: break def hashBigfile(self, read_func, size, piece_size=1024 * 1024, file_out=None): self.site.settings["has_bigfile"] = True recv = 0 try: piece_hash = CryptHash.sha512t() piece_hashes = [] piece_recv = 0 mt = merkletools.MerkleTools() mt.hash_function = CryptHash.sha512t part = "" for part in self.readFile(read_func, size): if file_out: file_out.write(part) recv += len(part) piece_recv += len(part) piece_hash.update(part) if piece_recv >= piece_size: piece_digest = piece_hash.digest() piece_hashes.append(piece_digest) mt.leaves.append(piece_digest) piece_hash = CryptHash.sha512t() piece_recv = 0 if len(piece_hashes) % 100 == 0 or recv == size: self.log.info("- [HASHING:%.0f%%] Pieces: %s, %.1fMB/%.1fMB" % ( float(recv) / size * 100, len(piece_hashes), recv / 1024 / 1024, size / 1024 / 1024 )) part = "" if len(part) > 0: piece_digest = piece_hash.digest() piece_hashes.append(piece_digest) mt.leaves.append(piece_digest) except Exception as err: raise err finally: if file_out: file_out.close() mt.make_tree() merkle_root = mt.get_merkle_root() if type(merkle_root) is bytes: # Python <3.5 merkle_root = merkle_root.decode() return merkle_root, piece_size, { "sha512_pieces": piece_hashes } def hashFile(self, dir_inner_path, file_relative_path, optional=False): inner_path = dir_inner_path + file_relative_path file_size = self.site.storage.getSize(inner_path) # Only care about optional files >1MB if not optional or file_size < 1 * 1024 * 1024: return super(ContentManagerPlugin, self).hashFile(dir_inner_path, file_relative_path, optional) back = {} content = self.contents.get(dir_inner_path + "content.json") hash = None piecemap_relative_path = None piece_size = None # Don't re-hash if it's already in content.json if content and file_relative_path in content.get("files_optional", {}): file_node = content["files_optional"][file_relative_path] if file_node["size"] == file_size: self.log.info("- [SAME SIZE] %s" % file_relative_path) hash = file_node.get("sha512") piecemap_relative_path = file_node.get("piecemap") piece_size = file_node.get("piece_size") if not hash or not piecemap_relative_path: # Not in content.json yet if file_size < 5 * 1024 * 1024: # Don't create piecemap automatically for files smaller than 5MB return super(ContentManagerPlugin, self).hashFile(dir_inner_path, file_relative_path, optional) self.log.info("- [HASHING] %s" % file_relative_path) merkle_root, piece_size, piecemap_info = self.hashBigfile(self.site.storage.open(inner_path, "rb").read, file_size) if not hash: hash = merkle_root if not piecemap_relative_path: file_name = helper.getFilename(file_relative_path) piecemap_relative_path = file_relative_path + ".piecemap.msgpack" piecemap_inner_path = inner_path + ".piecemap.msgpack" self.site.storage.open(piecemap_inner_path, "wb").write(Msgpack.pack({file_name: piecemap_info})) back.update(super(ContentManagerPlugin, self).hashFile(dir_inner_path, piecemap_relative_path, optional=True)) piece_num = int(math.ceil(float(file_size) / piece_size)) # Add the merkle root to hashfield hash_id = self.site.content_manager.hashfield.getHashId(hash) self.optionalDownloaded(inner_path, hash_id, file_size, own=True) self.site.storage.piecefields[hash].frombytes(b"\x01" * piece_num) back[file_relative_path] = {"sha512": hash, "size": file_size, "piecemap": piecemap_relative_path, "piece_size": piece_size} return back def getPiecemap(self, inner_path): file_info = self.site.content_manager.getFileInfo(inner_path) piecemap_inner_path = helper.getDirname(file_info["content_inner_path"]) + file_info["piecemap"] self.site.needFile(piecemap_inner_path, priority=20) piecemap = Msgpack.unpack(self.site.storage.open(piecemap_inner_path, "rb").read())[helper.getFilename(inner_path)] piecemap["piece_size"] = file_info["piece_size"] return piecemap def verifyPiece(self, inner_path, pos, piece): try: piecemap = self.getPiecemap(inner_path) except Exception as err: raise VerifyError("Unable to download piecemap: %s" % Debug.formatException(err)) piece_i = int(pos / piecemap["piece_size"]) if CryptHash.sha512sum(piece, format="digest") != piecemap["sha512_pieces"][piece_i]: raise VerifyError("Invalid hash") return True def verifyFile(self, inner_path, file, ignore_same=True): if "|" not in inner_path: return super(ContentManagerPlugin, self).verifyFile(inner_path, file, ignore_same) inner_path, file_range = inner_path.split("|") pos_from, pos_to = map(int, file_range.split("-")) return self.verifyPiece(inner_path, pos_from, file) def optionalDownloaded(self, inner_path, hash_id, size=None, own=False): if "|" in inner_path: inner_path, file_range = inner_path.split("|") pos_from, pos_to = map(int, file_range.split("-")) file_info = self.getFileInfo(inner_path) # Mark piece downloaded piece_i = int(pos_from / file_info["piece_size"]) self.site.storage.piecefields[file_info["sha512"]][piece_i] = b"\x01" # Only add to site size on first request if hash_id in self.hashfield: size = 0 elif size > 1024 * 1024: file_info = self.getFileInfo(inner_path) if file_info and "sha512" in file_info: # We already have the file, but not in piecefield sha512 = file_info["sha512"] if sha512 not in self.site.storage.piecefields: self.site.storage.checkBigfile(inner_path) return super(ContentManagerPlugin, self).optionalDownloaded(inner_path, hash_id, size, own) def optionalRemoved(self, inner_path, hash_id, size=None): if size and size > 1024 * 1024: file_info = self.getFileInfo(inner_path) sha512 = file_info["sha512"] if sha512 in self.site.storage.piecefields: del self.site.storage.piecefields[sha512] # Also remove other pieces of the file from download queue for key in list(self.site.bad_files.keys()): if key.startswith(inner_path + "|"): del self.site.bad_files[key] self.site.worker_manager.removeSolvedFileTasks() return super(ContentManagerPlugin, self).optionalRemoved(inner_path, hash_id, size) @PluginManager.registerTo("SiteStorage") class SiteStoragePlugin(object): def __init__(self, *args, **kwargs): super(SiteStoragePlugin, self).__init__(*args, **kwargs) self.piecefields = collections.defaultdict(BigfilePiecefield) if "piecefields" in self.site.settings.get("cache", {}): for sha512, piecefield_packed in self.site.settings["cache"].get("piecefields").items(): if piecefield_packed: self.piecefields[sha512].unpack(base64.b64decode(piecefield_packed)) self.site.settings["cache"]["piecefields"] = {} def createSparseFile(self, inner_path, size, sha512=None): file_path = self.getPath(inner_path) self.ensureDir(os.path.dirname(inner_path)) f = open(file_path, 'wb') f.truncate(min(1024 * 1024 * 5, size)) # Only pre-allocate up to 5MB f.close() if os.name == "nt": startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW subprocess.call(["fsutil", "sparse", "setflag", file_path], close_fds=True, startupinfo=startupinfo) if sha512 and sha512 in self.piecefields: self.log.debug("%s: File not exists, but has piecefield. Deleting piecefield." % inner_path) del self.piecefields[sha512] def write(self, inner_path, content): if "|" not in inner_path: return super(SiteStoragePlugin, self).write(inner_path, content) # Write to specific position by passing |{pos} after the filename inner_path, file_range = inner_path.split("|") pos_from, pos_to = map(int, file_range.split("-")) file_path = self.getPath(inner_path) # Create dir if not exist self.ensureDir(os.path.dirname(inner_path)) if not os.path.isfile(file_path): file_info = self.site.content_manager.getFileInfo(inner_path) self.createSparseFile(inner_path, file_info["size"]) # Write file with open(file_path, "rb+") as file: file.seek(pos_from) if hasattr(content, 'read'): # File-like object shutil.copyfileobj(content, file) # Write buff to disk else: # Simple string file.write(content) del content self.onUpdated(inner_path) def checkBigfile(self, inner_path): file_info = self.site.content_manager.getFileInfo(inner_path) if not file_info or (file_info and "piecemap" not in file_info): # It's not a big file return False self.site.settings["has_bigfile"] = True file_path = self.getPath(inner_path) sha512 = file_info["sha512"] piece_num = int(math.ceil(float(file_info["size"]) / file_info["piece_size"])) if os.path.isfile(file_path): if sha512 not in self.piecefields: if open(file_path, "rb").read(128) == b"\0" * 128: piece_data = b"\x00" else: piece_data = b"\x01" self.log.debug("%s: File exists, but not in piecefield. Filling piecefiled with %s * %s." % (inner_path, piece_num, piece_data)) self.piecefields[sha512].frombytes(piece_data * piece_num) else: self.log.debug("Creating bigfile: %s" % inner_path) self.createSparseFile(inner_path, file_info["size"], sha512) self.piecefields[sha512].frombytes(b"\x00" * piece_num) self.log.debug("Created bigfile: %s" % inner_path) return True def openBigfile(self, inner_path, prebuffer=0): if not self.checkBigfile(inner_path): return False self.site.needFile(inner_path, blocking=False) # Download piecemap return BigFile(self.site, inner_path, prebuffer=prebuffer) class BigFile(object): def __init__(self, site, inner_path, prebuffer=0): self.site = site self.inner_path = inner_path file_path = site.storage.getPath(inner_path) file_info = self.site.content_manager.getFileInfo(inner_path) self.piece_size = file_info["piece_size"] self.sha512 = file_info["sha512"] self.size = file_info["size"] self.prebuffer = prebuffer self.read_bytes = 0 self.piecefield = self.site.storage.piecefields[self.sha512] self.f = open(file_path, "rb+") self.read_lock = gevent.lock.Semaphore() def read(self, buff=64 * 1024): with self.read_lock: pos = self.f.tell() read_until = min(self.size, pos + buff) requests = [] # Request all required blocks while 1: piece_i = int(pos / self.piece_size) if piece_i * self.piece_size >= read_until: break pos_from = piece_i * self.piece_size pos_to = pos_from + self.piece_size if not self.piecefield[piece_i]: requests.append(self.site.needFile("%s|%s-%s" % (self.inner_path, pos_from, pos_to), blocking=False, update=True, priority=10)) pos += self.piece_size if not all(requests): return None # Request prebuffer if self.prebuffer: prebuffer_until = min(self.size, read_until + self.prebuffer) priority = 3 while 1: piece_i = int(pos / self.piece_size) if piece_i * self.piece_size >= prebuffer_until: break pos_from = piece_i * self.piece_size pos_to = pos_from + self.piece_size if not self.piecefield[piece_i]: self.site.needFile("%s|%s-%s" % (self.inner_path, pos_from, pos_to), blocking=False, update=True, priority=max(0, priority)) priority -= 1 pos += self.piece_size gevent.joinall(requests) self.read_bytes += buff # Increase buffer for long reads if self.read_bytes > 7 * 1024 * 1024 and self.prebuffer < 5 * 1024 * 1024: self.site.log.debug("%s: Increasing bigfile buffer size to 5MB..." % self.inner_path) self.prebuffer = 5 * 1024 * 1024 return self.f.read(buff) def seek(self, pos, whence=0): with self.read_lock: if whence == 2: # Relative from file end pos = self.size + pos # Use the real size instead of size on the disk whence = 0 return self.f.seek(pos, whence) def seekable(self): return self.f.seekable() def tell(self): return self.f.tell() def close(self): self.f.close() def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): self.close() @PluginManager.registerTo("WorkerManager") class WorkerManagerPlugin(object): def addTask(self, inner_path, *args, **kwargs): file_info = kwargs.get("file_info") if file_info and "piecemap" in file_info: # Bigfile self.site.settings["has_bigfile"] = True piecemap_inner_path = helper.getDirname(file_info["content_inner_path"]) + file_info["piecemap"] piecemap_task = None if not self.site.storage.isFile(piecemap_inner_path): # Start download piecemap piecemap_task = super(WorkerManagerPlugin, self).addTask(piecemap_inner_path, priority=30) autodownload_bigfile_size_limit = self.site.settings.get("autodownload_bigfile_size_limit", config.autodownload_bigfile_size_limit) if "|" not in inner_path and self.site.isDownloadable(inner_path) and file_info["size"] / 1024 / 1024 <= autodownload_bigfile_size_limit: gevent.spawn_later(0.1, self.site.needFile, inner_path + "|all") # Download all pieces if "|" in inner_path: # Start download piece task = super(WorkerManagerPlugin, self).addTask(inner_path, *args, **kwargs) inner_path, file_range = inner_path.split("|") pos_from, pos_to = map(int, file_range.split("-")) task["piece_i"] = int(pos_from / file_info["piece_size"]) task["sha512"] = file_info["sha512"] else: if inner_path in self.site.bad_files: del self.site.bad_files[inner_path] if piecemap_task: task = piecemap_task else: fake_evt = gevent.event.AsyncResult() # Don't download anything if no range specified fake_evt.set(True) task = {"evt": fake_evt} if not self.site.storage.isFile(inner_path): self.site.storage.createSparseFile(inner_path, file_info["size"], file_info["sha512"]) piece_num = int(math.ceil(float(file_info["size"]) / file_info["piece_size"])) self.site.storage.piecefields[file_info["sha512"]].frombytes(b"\x00" * piece_num) else: task = super(WorkerManagerPlugin, self).addTask(inner_path, *args, **kwargs) return task def taskAddPeer(self, task, peer): if "piece_i" in task: if not peer.piecefields[task["sha512"]][task["piece_i"]]: if task["sha512"] not in peer.piecefields: gevent.spawn(peer.updatePiecefields, force=True) elif not task["peers"]: gevent.spawn(peer.updatePiecefields) return False # Deny to add peers to task if file not in piecefield return super(WorkerManagerPlugin, self).taskAddPeer(task, peer) @PluginManager.registerTo("FileRequest") class FileRequestPlugin(object): def isReadable(self, site, inner_path, file, pos): # Peek into file if file.read(10) == b"\0" * 10: # Looks empty, but makes sures we don't have that piece file_info = site.content_manager.getFileInfo(inner_path) if "piece_size" in file_info: piece_i = int(pos / file_info["piece_size"]) if not site.storage.piecefields[file_info["sha512"]][piece_i]: return False # Seek back to position we want to read file.seek(pos) return super(FileRequestPlugin, self).isReadable(site, inner_path, file, pos) def actionGetPiecefields(self, params): site = self.sites.get(params["site"]) if not site or not site.isServing(): # Site unknown or not serving self.response({"error": "Unknown site"}) return False # Add peer to site if not added before peer = site.addPeer(self.connection.ip, self.connection.port, return_peer=True) if not peer.connection: # Just added peer.connect(self.connection) # Assign current connection to peer piecefields_packed = {sha512: piecefield.pack() for sha512, piecefield in site.storage.piecefields.items()} self.response({"piecefields_packed": piecefields_packed}) def actionSetPiecefields(self, params): site = self.sites.get(params["site"]) if not site or not site.isServing(): # Site unknown or not serving self.response({"error": "Unknown site"}) self.connection.badAction(5) return False # Add or get peer peer = site.addPeer(self.connection.ip, self.connection.port, return_peer=True, connection=self.connection) if not peer.connection: peer.connect(self.connection) peer.piecefields = collections.defaultdict(BigfilePiecefieldPacked) for sha512, piecefield_packed in params["piecefields_packed"].items(): peer.piecefields[sha512].unpack(piecefield_packed) site.settings["has_bigfile"] = True self.response({"ok": "Updated"}) @PluginManager.registerTo("Peer") class PeerPlugin(object): def __getattr__(self, key): if key == "piecefields": self.piecefields = collections.defaultdict(BigfilePiecefieldPacked) return self.piecefields elif key == "time_piecefields_updated": self.time_piecefields_updated = None return self.time_piecefields_updated else: return super(PeerPlugin, self).__getattr__(key) @util.Noparallel(ignore_args=True) def updatePiecefields(self, force=False): if self.connection and self.connection.handshake.get("rev", 0) < 2190: return False # Not supported # Don't update piecefield again in 1 min if self.time_piecefields_updated and time.time() - self.time_piecefields_updated < 60 and not force: return False self.time_piecefields_updated = time.time() res = self.request("getPiecefields", {"site": self.site.address}) if not res or "error" in res: return False self.piecefields = collections.defaultdict(BigfilePiecefieldPacked) try: for sha512, piecefield_packed in res["piecefields_packed"].items(): self.piecefields[sha512].unpack(piecefield_packed) except Exception as err: self.log("Invalid updatePiecefields response: %s" % Debug.formatException(err)) return self.piecefields def sendMyHashfield(self, *args, **kwargs): return super(PeerPlugin, self).sendMyHashfield(*args, **kwargs) def updateHashfield(self, *args, **kwargs): if self.site.settings.get("has_bigfile"): thread = gevent.spawn(self.updatePiecefields, *args, **kwargs) back = super(PeerPlugin, self).updateHashfield(*args, **kwargs) thread.join() return back else: return super(PeerPlugin, self).updateHashfield(*args, **kwargs) def getFile(self, site, inner_path, *args, **kwargs): if "|" in inner_path: inner_path, file_range = inner_path.split("|") pos_from, pos_to = map(int, file_range.split("-")) kwargs["pos_from"] = pos_from kwargs["pos_to"] = pos_to return super(PeerPlugin, self).getFile(site, inner_path, *args, **kwargs) @PluginManager.registerTo("Site") class SitePlugin(object): def isFileDownloadAllowed(self, inner_path, file_info): if "piecemap" in file_info: file_size_mb = file_info["size"] / 1024 / 1024 if config.bigfile_size_limit and file_size_mb > config.bigfile_size_limit: self.log.debug( "Bigfile size %s too large: %sMB > %sMB, skipping..." % (inner_path, file_size_mb, config.bigfile_size_limit) ) return False file_info = file_info.copy() file_info["size"] = file_info["piece_size"] return super(SitePlugin, self).isFileDownloadAllowed(inner_path, file_info) def getSettingsCache(self): back = super(SitePlugin, self).getSettingsCache() if self.storage.piecefields: back["piecefields"] = {sha512: base64.b64encode(piecefield.pack()).decode("utf8") for sha512, piecefield in self.storage.piecefields.items()} return back def needFile(self, inner_path, *args, **kwargs): if inner_path.endswith("|all"): @util.Pooled(20) def pooledNeedBigfile(inner_path, *args, **kwargs): if inner_path not in self.bad_files: self.log.debug("Cancelled piece, skipping %s" % inner_path) return False return self.needFile(inner_path, *args, **kwargs) inner_path = inner_path.replace("|all", "") file_info = self.needFileInfo(inner_path) # Use default function to download non-optional file if "piece_size" not in file_info: return super(SitePlugin, self).needFile(inner_path, *args, **kwargs) file_size = file_info["size"] piece_size = file_info["piece_size"] piece_num = int(math.ceil(float(file_size) / piece_size)) file_threads = [] piecefield = self.storage.piecefields.get(file_info["sha512"]) for piece_i in range(piece_num): piece_from = piece_i * piece_size piece_to = min(file_size, piece_from + piece_size) if not piecefield or not piecefield[piece_i]: inner_path_piece = "%s|%s-%s" % (inner_path, piece_from, piece_to) self.bad_files[inner_path_piece] = self.bad_files.get(inner_path_piece, 1) res = pooledNeedBigfile(inner_path_piece, blocking=False) if res is not True and res is not False: file_threads.append(res) gevent.joinall(file_threads) else: return super(SitePlugin, self).needFile(inner_path, *args, **kwargs) @PluginManager.registerTo("ConfigPlugin") class ConfigPlugin(object): def createArguments(self): group = self.parser.add_argument_group("Bigfile plugin") group.add_argument('--autodownload_bigfile_size_limit', help='Also download bigfiles smaller than this limit if help distribute option is checked', default=10, metavar="MB", type=int) group.add_argument('--bigfile_size_limit', help='Maximum size of downloaded big files', default=False, metavar="MB", type=int) return super(ConfigPlugin, self).createArguments() ================================================ FILE: plugins/Bigfile/Test/TestBigfile.py ================================================ import time import io import binascii import pytest import mock from Connection import ConnectionServer from Content.ContentManager import VerifyError from File import FileServer from File import FileRequest from Worker import WorkerManager from Peer import Peer from Bigfile import BigfilePiecefield, BigfilePiecefieldPacked from Test import Spy from util import Msgpack @pytest.mark.usefixtures("resetSettings") @pytest.mark.usefixtures("resetTempSettings") class TestBigfile: privatekey = "5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv" piece_size = 1024 * 1024 def createBigfile(self, site, inner_path="data/optional.any.iso", pieces=10): f = site.storage.open(inner_path, "w") for i in range(pieces * 100): f.write(("Test%s" % i).ljust(10, "-") * 1000) f.close() assert site.content_manager.sign("content.json", self.privatekey) return inner_path def testPiecemapCreate(self, site): inner_path = self.createBigfile(site) content = site.storage.loadJson("content.json") assert "data/optional.any.iso" in content["files_optional"] file_node = content["files_optional"][inner_path] assert file_node["size"] == 10 * 1000 * 1000 assert file_node["sha512"] == "47a72cde3be80b4a829e7674f72b7c6878cf6a70b0c58c6aa6c17d7e9948daf6" assert file_node["piecemap"] == inner_path + ".piecemap.msgpack" piecemap = Msgpack.unpack(site.storage.open(file_node["piecemap"], "rb").read())["optional.any.iso"] assert len(piecemap["sha512_pieces"]) == 10 assert piecemap["sha512_pieces"][0] != piecemap["sha512_pieces"][1] assert binascii.hexlify(piecemap["sha512_pieces"][0]) == b"a73abad9992b3d0b672d0c2a292046695d31bebdcb1e150c8410bbe7c972eff3" def testVerifyPiece(self, site): inner_path = self.createBigfile(site) # Verify all 10 piece f = site.storage.open(inner_path, "rb") for i in range(10): piece = io.BytesIO(f.read(1024 * 1024)) piece.seek(0) site.content_manager.verifyPiece(inner_path, i * 1024 * 1024, piece) f.close() # Try to verify piece 0 with piece 1 hash with pytest.raises(VerifyError) as err: i = 1 f = site.storage.open(inner_path, "rb") piece = io.BytesIO(f.read(1024 * 1024)) f.close() site.content_manager.verifyPiece(inner_path, i * 1024 * 1024, piece) assert "Invalid hash" in str(err.value) def testSparseFile(self, site): inner_path = "sparsefile" # Create a 100MB sparse file site.storage.createSparseFile(inner_path, 100 * 1024 * 1024) # Write to file beginning s = time.time() f = site.storage.write("%s|%s-%s" % (inner_path, 0, 1024 * 1024), b"hellostart" * 1024) time_write_start = time.time() - s # Write to file end s = time.time() f = site.storage.write("%s|%s-%s" % (inner_path, 99 * 1024 * 1024, 99 * 1024 * 1024 + 1024 * 1024), b"helloend" * 1024) time_write_end = time.time() - s # Verify writes f = site.storage.open(inner_path) assert f.read(10) == b"hellostart" f.seek(99 * 1024 * 1024) assert f.read(8) == b"helloend" f.close() site.storage.delete(inner_path) # Writing to end shold not take much longer, than writing to start assert time_write_end <= max(0.1, time_write_start * 1.1) def testRangedFileRequest(self, file_server, site, site_temp): inner_path = self.createBigfile(site) file_server.sites[site.address] = site client = FileServer(file_server.ip, 1545) client.sites[site_temp.address] = site_temp site_temp.connection_server = client connection = client.getConnection(file_server.ip, 1544) # Add file_server as peer to client peer_file_server = site_temp.addPeer(file_server.ip, 1544) buff = peer_file_server.getFile(site_temp.address, "%s|%s-%s" % (inner_path, 5 * 1024 * 1024, 6 * 1024 * 1024)) assert len(buff.getvalue()) == 1 * 1024 * 1024 # Correct block size assert buff.getvalue().startswith(b"Test524") # Correct data buff.seek(0) assert site.content_manager.verifyPiece(inner_path, 5 * 1024 * 1024, buff) # Correct hash connection.close() client.stop() def testRangedFileDownload(self, file_server, site, site_temp): inner_path = self.createBigfile(site) # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Make sure the file and the piecemap in the optional hashfield file_info = site.content_manager.getFileInfo(inner_path) assert site.content_manager.hashfield.hasHash(file_info["sha512"]) piecemap_hash = site.content_manager.getFileInfo(file_info["piecemap"])["sha512"] assert site.content_manager.hashfield.hasHash(piecemap_hash) # Init client server client = ConnectionServer(file_server.ip, 1545) site_temp.connection_server = client peer_client = site_temp.addPeer(file_server.ip, 1544) # Download site site_temp.download(blind_includes=True, retry_bad_files=False).join(timeout=10) bad_files = site_temp.storage.verifyFiles(quick_check=True)["bad_files"] assert not bad_files # client_piecefield = peer_client.piecefields[file_info["sha512"]].tostring() # assert client_piecefield == "1" * 10 # Download 5. and 10. block site_temp.needFile("%s|%s-%s" % (inner_path, 5 * 1024 * 1024, 6 * 1024 * 1024)) site_temp.needFile("%s|%s-%s" % (inner_path, 9 * 1024 * 1024, 10 * 1024 * 1024)) # Verify 0. block not downloaded f = site_temp.storage.open(inner_path) assert f.read(10) == b"\0" * 10 # Verify 5. and 10. block downloaded f.seek(5 * 1024 * 1024) assert f.read(7) == b"Test524" f.seek(9 * 1024 * 1024) assert f.read(7) == b"943---T" # Verify hashfield assert set(site_temp.content_manager.hashfield) == set([18343, 43727]) # 18343: data/optional.any.iso, 43727: data/optional.any.iso.hashmap.msgpack def testOpenBigfile(self, file_server, site, site_temp): inner_path = self.createBigfile(site) # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server client = ConnectionServer(file_server.ip, 1545) site_temp.connection_server = client site_temp.addPeer(file_server.ip, 1544) # Download site site_temp.download(blind_includes=True, retry_bad_files=False).join(timeout=10) # Open virtual file assert not site_temp.storage.isFile(inner_path) with site_temp.storage.openBigfile(inner_path) as f: with Spy.Spy(FileRequest, "route") as requests: f.seek(5 * 1024 * 1024) assert f.read(7) == b"Test524" f.seek(9 * 1024 * 1024) assert f.read(7) == b"943---T" assert len(requests) == 4 # 1x peicemap + 1x getpiecefield + 2x for pieces assert set(site_temp.content_manager.hashfield) == set([18343, 43727]) assert site_temp.storage.piecefields[f.sha512].tostring() == "0000010001" assert f.sha512 in site_temp.getSettingsCache()["piecefields"] # Test requesting already downloaded with Spy.Spy(FileRequest, "route") as requests: f.seek(5 * 1024 * 1024) assert f.read(7) == b"Test524" assert len(requests) == 0 # Test requesting multi-block overflow reads with Spy.Spy(FileRequest, "route") as requests: f.seek(5 * 1024 * 1024) # We already have this block data = f.read(1024 * 1024 * 3) # Our read overflow to 6. and 7. block assert data.startswith(b"Test524") assert data.endswith(b"Test838-") assert b"\0" not in data # No null bytes allowed assert len(requests) == 2 # Two block download # Test out of range request f.seek(5 * 1024 * 1024) data = f.read(1024 * 1024 * 30) assert len(data) == 10 * 1000 * 1000 - (5 * 1024 * 1024) f.seek(30 * 1024 * 1024) data = f.read(1024 * 1024 * 30) assert len(data) == 0 @pytest.mark.parametrize("piecefield_obj", [BigfilePiecefield, BigfilePiecefieldPacked]) def testPiecefield(self, piecefield_obj, site): testdatas = [ b"\x01" * 100 + b"\x00" * 900 + b"\x01" * 4000 + b"\x00" * 4999 + b"\x01", b"\x00\x01\x00\x01\x00\x01" * 10 + b"\x00\x01" * 90 + b"\x01\x00" * 400 + b"\x00" * 4999, b"\x01" * 10000, b"\x00" * 10000 ] for testdata in testdatas: piecefield = piecefield_obj() piecefield.frombytes(testdata) assert piecefield.tobytes() == testdata assert piecefield[0] == testdata[0] assert piecefield[100] == testdata[100] assert piecefield[1000] == testdata[1000] assert piecefield[len(testdata) - 1] == testdata[len(testdata) - 1] packed = piecefield.pack() piecefield_new = piecefield_obj() piecefield_new.unpack(packed) assert piecefield.tobytes() == piecefield_new.tobytes() assert piecefield_new.tobytes() == testdata def testFileGet(self, file_server, site, site_temp): inner_path = self.createBigfile(site) # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server site_temp.connection_server = FileServer(file_server.ip, 1545) site_temp.connection_server.sites[site_temp.address] = site_temp site_temp.addPeer(file_server.ip, 1544) # Download site site_temp.download(blind_includes=True, retry_bad_files=False).join(timeout=10) # Download second block with site_temp.storage.openBigfile(inner_path) as f: f.seek(1024 * 1024) assert f.read(1024)[0:1] != b"\0" # Make sure first block not download with site_temp.storage.open(inner_path) as f: assert f.read(1024)[0:1] == b"\0" peer2 = site.addPeer(file_server.ip, 1545, return_peer=True) # Should drop error on first block request assert not peer2.getFile(site.address, "%s|0-%s" % (inner_path, 1024 * 1024 * 1)) # Should not drop error for second block request assert peer2.getFile(site.address, "%s|%s-%s" % (inner_path, 1024 * 1024 * 1, 1024 * 1024 * 2)) def benchmarkPeerMemory(self, site, file_server): # Init source server site.connection_server = file_server file_server.sites[site.address] = site import psutil, os meminfo = psutil.Process(os.getpid()).memory_info mem_s = meminfo()[0] s = time.time() for i in range(25000): site.addPeer(file_server.ip, i) print("%.3fs MEM: + %sKB" % (time.time() - s, (meminfo()[0] - mem_s) / 1024)) # 0.082s MEM: + 6800KB print(list(site.peers.values())[0].piecefields) def testUpdatePiecefield(self, file_server, site, site_temp): inner_path = self.createBigfile(site) server1 = file_server server1.sites[site.address] = site server2 = FileServer(file_server.ip, 1545) server2.sites[site_temp.address] = site_temp site_temp.connection_server = server2 # Add file_server as peer to client server2_peer1 = site_temp.addPeer(file_server.ip, 1544) # Testing piecefield sync assert len(server2_peer1.piecefields) == 0 assert server2_peer1.updatePiecefields() # Query piecefields from peer assert len(server2_peer1.piecefields) > 0 def testWorkerManagerPiecefieldDeny(self, file_server, site, site_temp): inner_path = self.createBigfile(site) server1 = file_server server1.sites[site.address] = site server2 = FileServer(file_server.ip, 1545) server2.sites[site_temp.address] = site_temp site_temp.connection_server = server2 # Add file_server as peer to client server2_peer1 = site_temp.addPeer(file_server.ip, 1544) # Working site_temp.downloadContent("content.json", download_files=False) site_temp.needFile("data/optional.any.iso.piecemap.msgpack") # Add fake peers with optional files downloaded for i in range(5): fake_peer = site_temp.addPeer("127.0.1.%s" % i, 1544) fake_peer.hashfield = site.content_manager.hashfield fake_peer.has_hashfield = True with Spy.Spy(WorkerManager, "addWorker") as requests: site_temp.needFile("%s|%s-%s" % (inner_path, 5 * 1024 * 1024, 6 * 1024 * 1024)) site_temp.needFile("%s|%s-%s" % (inner_path, 6 * 1024 * 1024, 7 * 1024 * 1024)) # It should only request parts from peer1 as the other peers does not have the requested parts in piecefields assert len([request[1] for request in requests if request[1] != server2_peer1]) == 0 def testWorkerManagerPiecefieldDownload(self, file_server, site, site_temp): inner_path = self.createBigfile(site) server1 = file_server server1.sites[site.address] = site server2 = FileServer(file_server.ip, 1545) server2.sites[site_temp.address] = site_temp site_temp.connection_server = server2 sha512 = site.content_manager.getFileInfo(inner_path)["sha512"] # Create 10 fake peer for each piece for i in range(10): peer = Peer(file_server.ip, 1544, site_temp, server2) peer.piecefields[sha512][i] = b"\x01" peer.updateHashfield = mock.MagicMock(return_value=False) peer.updatePiecefields = mock.MagicMock(return_value=False) peer.findHashIds = mock.MagicMock(return_value={"nope": []}) peer.hashfield = site.content_manager.hashfield peer.has_hashfield = True peer.key = "Peer:%s" % i site_temp.peers["Peer:%s" % i] = peer site_temp.downloadContent("content.json", download_files=False) site_temp.needFile("data/optional.any.iso.piecemap.msgpack") with Spy.Spy(Peer, "getFile") as requests: for i in range(10): site_temp.needFile("%s|%s-%s" % (inner_path, i * 1024 * 1024, (i + 1) * 1024 * 1024)) assert len(requests) == 10 for i in range(10): assert requests[i][0] == site_temp.peers["Peer:%s" % i] # Every part should be requested from piece owner peer def testDownloadStats(self, file_server, site, site_temp): inner_path = self.createBigfile(site) # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server client = ConnectionServer(file_server.ip, 1545) site_temp.connection_server = client site_temp.addPeer(file_server.ip, 1544) # Download site site_temp.download(blind_includes=True, retry_bad_files=False).join(timeout=10) # Open virtual file assert not site_temp.storage.isFile(inner_path) # Check size before downloads assert site_temp.settings["size"] < 10 * 1024 * 1024 assert site_temp.settings["optional_downloaded"] == 0 size_piecemap = site_temp.content_manager.getFileInfo(inner_path + ".piecemap.msgpack")["size"] size_bigfile = site_temp.content_manager.getFileInfo(inner_path)["size"] with site_temp.storage.openBigfile(inner_path) as f: assert b"\0" not in f.read(1024) assert site_temp.settings["optional_downloaded"] == size_piecemap + size_bigfile with site_temp.storage.openBigfile(inner_path) as f: # Don't count twice assert b"\0" not in f.read(1024) assert site_temp.settings["optional_downloaded"] == size_piecemap + size_bigfile # Add second block assert b"\0" not in f.read(1024 * 1024) assert site_temp.settings["optional_downloaded"] == size_piecemap + size_bigfile def testPrebuffer(self, file_server, site, site_temp): inner_path = self.createBigfile(site) # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server client = ConnectionServer(file_server.ip, 1545) site_temp.connection_server = client site_temp.addPeer(file_server.ip, 1544) # Download site site_temp.download(blind_includes=True, retry_bad_files=False).join(timeout=10) # Open virtual file assert not site_temp.storage.isFile(inner_path) with site_temp.storage.openBigfile(inner_path, prebuffer=1024 * 1024 * 2) as f: with Spy.Spy(FileRequest, "route") as requests: f.seek(5 * 1024 * 1024) assert f.read(7) == b"Test524" # assert len(requests) == 3 # 1x piecemap + 1x getpiecefield + 1x for pieces assert len([task for task in site_temp.worker_manager.tasks if task["inner_path"].startswith(inner_path)]) == 2 time.sleep(0.5) # Wait prebuffer download sha512 = site.content_manager.getFileInfo(inner_path)["sha512"] assert site_temp.storage.piecefields[sha512].tostring() == "0000011100" # No prebuffer beyond end of the file f.seek(9 * 1024 * 1024) assert b"\0" not in f.read(7) assert len([task for task in site_temp.worker_manager.tasks if task["inner_path"].startswith(inner_path)]) == 0 def testDownloadAllPieces(self, file_server, site, site_temp): inner_path = self.createBigfile(site) # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server client = ConnectionServer(file_server.ip, 1545) site_temp.connection_server = client site_temp.addPeer(file_server.ip, 1544) # Download site site_temp.download(blind_includes=True, retry_bad_files=False).join(timeout=10) # Open virtual file assert not site_temp.storage.isFile(inner_path) with Spy.Spy(FileRequest, "route") as requests: site_temp.needFile("%s|all" % inner_path) assert len(requests) == 12 # piecemap.msgpack, getPiecefields, 10 x piece # Don't re-download already got pieces with Spy.Spy(FileRequest, "route") as requests: site_temp.needFile("%s|all" % inner_path) assert len(requests) == 0 def testFileSize(self, file_server, site, site_temp): inner_path = self.createBigfile(site) # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server client = ConnectionServer(file_server.ip, 1545) site_temp.connection_server = client site_temp.addPeer(file_server.ip, 1544) # Download site site_temp.download(blind_includes=True, retry_bad_files=False).join(timeout=10) # Open virtual file assert not site_temp.storage.isFile(inner_path) # Download first block site_temp.needFile("%s|%s-%s" % (inner_path, 0 * 1024 * 1024, 1 * 1024 * 1024)) assert site_temp.storage.getSize(inner_path) < 1000 * 1000 * 10 # Size on the disk should be smaller than the real size site_temp.needFile("%s|%s-%s" % (inner_path, 9 * 1024 * 1024, 10 * 1024 * 1024)) assert site_temp.storage.getSize(inner_path) == site.storage.getSize(inner_path) def testFileRename(self, file_server, site, site_temp): inner_path = self.createBigfile(site) # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server site_temp.connection_server = FileServer(file_server.ip, 1545) site_temp.connection_server.sites[site_temp.address] = site_temp site_temp.addPeer(file_server.ip, 1544) # Download site site_temp.download(blind_includes=True, retry_bad_files=False).join(timeout=10) with Spy.Spy(FileRequest, "route") as requests: site_temp.needFile("%s|%s-%s" % (inner_path, 0, 1 * self.piece_size)) assert len([req for req in requests if req[1] == "streamFile"]) == 2 # 1 piece + piecemap # Rename the file inner_path_new = inner_path.replace(".iso", "-new.iso") site.storage.rename(inner_path, inner_path_new) site.storage.delete("data/optional.any.iso.piecemap.msgpack") assert site.content_manager.sign("content.json", self.privatekey, remove_missing_optional=True) files_optional = site.content_manager.contents["content.json"]["files_optional"].keys() assert "data/optional.any-new.iso.piecemap.msgpack" in files_optional assert "data/optional.any.iso.piecemap.msgpack" not in files_optional assert "data/optional.any.iso" not in files_optional with Spy.Spy(FileRequest, "route") as requests: site.publish() time.sleep(0.1) site_temp.download(blind_includes=True, retry_bad_files=False).join(timeout=10) # Wait for download assert len([req[1] for req in requests if req[1] == "streamFile"]) == 0 with site_temp.storage.openBigfile(inner_path_new, prebuffer=0) as f: f.read(1024) # First piece already downloaded assert [req for req in requests if req[1] == "streamFile"] == [] # Second piece needs to be downloaded + changed piecemap f.seek(self.piece_size) f.read(1024) assert [req[3]["inner_path"] for req in requests if req[1] == "streamFile"] == [inner_path_new + ".piecemap.msgpack", inner_path_new] @pytest.mark.parametrize("size", [1024 * 3, 1024 * 1024 * 3, 1024 * 1024 * 30]) def testNullFileRead(self, file_server, site, site_temp, size): inner_path = "data/optional.iso" f = site.storage.open(inner_path, "w") f.write("\0" * size) f.close() assert site.content_manager.sign("content.json", self.privatekey) # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server site_temp.connection_server = FileServer(file_server.ip, 1545) site_temp.connection_server.sites[site_temp.address] = site_temp site_temp.addPeer(file_server.ip, 1544) # Download site site_temp.download(blind_includes=True, retry_bad_files=False).join(timeout=10) if "piecemap" in site.content_manager.getFileInfo(inner_path): # Bigfile site_temp.needFile(inner_path + "|all") else: site_temp.needFile(inner_path) assert site_temp.storage.getSize(inner_path) == size ================================================ FILE: plugins/Bigfile/Test/conftest.py ================================================ from src.Test.conftest import * ================================================ FILE: plugins/Bigfile/Test/pytest.ini ================================================ [pytest] python_files = Test*.py addopts = -rsxX -v --durations=6 markers = webtest: mark a test as a webtest. ================================================ FILE: plugins/Bigfile/__init__.py ================================================ from . import BigfilePlugin from .BigfilePiecefield import BigfilePiecefield, BigfilePiecefieldPacked ================================================ FILE: plugins/Chart/ChartCollector.py ================================================ import time import sys import collections import itertools import logging import gevent from util import helper from Config import config class ChartCollector(object): def __init__(self, db): self.db = db if config.action == "main": gevent.spawn_later(60 * 3, self.collector) self.log = logging.getLogger("ChartCollector") self.last_values = collections.defaultdict(dict) def setInitialLastValues(self, sites): # Recover last value of site bytes/sent for site in sites: self.last_values["site:" + site.address]["site_bytes_recv"] = site.settings.get("bytes_recv", 0) self.last_values["site:" + site.address]["site_bytes_sent"] = site.settings.get("bytes_sent", 0) def getCollectors(self): collectors = {} import main file_server = main.file_server sites = file_server.sites if not sites: return collectors content_db = list(sites.values())[0].content_manager.contents.db # Connection stats collectors["connection"] = lambda: len(file_server.connections) collectors["connection_in"] = ( lambda: len([1 for connection in file_server.connections if connection.type == "in"]) ) collectors["connection_onion"] = ( lambda: len([1 for connection in file_server.connections if connection.ip.endswith(".onion")]) ) collectors["connection_ping_avg"] = ( lambda: round(1000 * helper.avg( [connection.last_ping_delay for connection in file_server.connections if connection.last_ping_delay] )) ) collectors["connection_ping_min"] = ( lambda: round(1000 * min( [connection.last_ping_delay for connection in file_server.connections if connection.last_ping_delay] )) ) collectors["connection_rev_avg"] = ( lambda: helper.avg( [connection.handshake["rev"] for connection in file_server.connections if connection.handshake] ) ) # Request stats collectors["file_bytes_recv|change"] = lambda: file_server.bytes_recv collectors["file_bytes_sent|change"] = lambda: file_server.bytes_sent collectors["request_num_recv|change"] = lambda: file_server.num_recv collectors["request_num_sent|change"] = lambda: file_server.num_sent # Limit collectors["optional_limit"] = lambda: content_db.getOptionalLimitBytes() collectors["optional_used"] = lambda: content_db.getOptionalUsedBytes() collectors["optional_downloaded"] = lambda: sum([site.settings.get("optional_downloaded", 0) for site in sites.values()]) # Peers collectors["peer"] = lambda peers: len(peers) collectors["peer_onion"] = lambda peers: len([True for peer in peers if ".onion" in peer]) # Size collectors["size"] = lambda: sum([site.settings.get("size", 0) for site in sites.values()]) collectors["size_optional"] = lambda: sum([site.settings.get("size_optional", 0) for site in sites.values()]) collectors["content"] = lambda: sum([len(site.content_manager.contents) for site in sites.values()]) return collectors def getSiteCollectors(self): site_collectors = {} # Size site_collectors["site_size"] = lambda site: site.settings.get("size", 0) site_collectors["site_size_optional"] = lambda site: site.settings.get("size_optional", 0) site_collectors["site_optional_downloaded"] = lambda site: site.settings.get("optional_downloaded", 0) site_collectors["site_content"] = lambda site: len(site.content_manager.contents) # Data transfer site_collectors["site_bytes_recv|change"] = lambda site: site.settings.get("bytes_recv", 0) site_collectors["site_bytes_sent|change"] = lambda site: site.settings.get("bytes_sent", 0) # Peers site_collectors["site_peer"] = lambda site: len(site.peers) site_collectors["site_peer_onion"] = lambda site: len( [True for peer in site.peers.values() if peer.ip.endswith(".onion")] ) site_collectors["site_peer_connected"] = lambda site: len([True for peer in site.peers.values() if peer.connection]) return site_collectors def getUniquePeers(self): import main sites = main.file_server.sites return set(itertools.chain.from_iterable( [site.peers.keys() for site in sites.values()] )) def collectDatas(self, collectors, last_values, site=None): if site is None: peers = self.getUniquePeers() datas = {} for key, collector in collectors.items(): try: if site: value = collector(site) elif key.startswith("peer"): value = collector(peers) else: value = collector() except ValueError: value = None except Exception as err: self.log.info("Collector %s error: %s" % (key, err)) value = None if "|change" in key: # Store changes relative to last value key = key.replace("|change", "") last_value = last_values.get(key, 0) last_values[key] = value value = value - last_value if value is None: datas[key] = None else: datas[key] = round(value, 3) return datas def collectGlobal(self, collectors, last_values): now = int(time.time()) s = time.time() datas = self.collectDatas(collectors, last_values["global"]) values = [] for key, value in datas.items(): values.append((self.db.getTypeId(key), value, now)) self.log.debug("Global collectors done in %.3fs" % (time.time() - s)) s = time.time() cur = self.db.getCursor() cur.executemany("INSERT INTO data (type_id, value, date_added) VALUES (?, ?, ?)", values) self.log.debug("Global collectors inserted in %.3fs" % (time.time() - s)) def collectSites(self, sites, collectors, last_values): now = int(time.time()) s = time.time() values = [] for address, site in list(sites.items()): site_datas = self.collectDatas(collectors, last_values["site:%s" % address], site) for key, value in site_datas.items(): values.append((self.db.getTypeId(key), self.db.getSiteId(address), value, now)) time.sleep(0.001) self.log.debug("Site collections done in %.3fs" % (time.time() - s)) s = time.time() cur = self.db.getCursor() cur.executemany("INSERT INTO data (type_id, site_id, value, date_added) VALUES (?, ?, ?, ?)", values) self.log.debug("Site collectors inserted in %.3fs" % (time.time() - s)) def collector(self): collectors = self.getCollectors() site_collectors = self.getSiteCollectors() import main sites = main.file_server.sites i = 0 while 1: self.collectGlobal(collectors, self.last_values) if i % 12 == 0: # Only collect sites data every hour self.collectSites(sites, site_collectors, self.last_values) time.sleep(60 * 5) i += 1 ================================================ FILE: plugins/Chart/ChartDb.py ================================================ from Config import config from Db.Db import Db import time class ChartDb(Db): def __init__(self): self.version = 2 super(ChartDb, self).__init__(self.getSchema(), "%s/chart.db" % config.data_dir) self.foreign_keys = True self.checkTables() self.sites = self.loadSites() self.types = self.loadTypes() def getSchema(self): schema = {} schema["db_name"] = "Chart" schema["tables"] = {} schema["tables"]["data"] = { "cols": [ ["data_id", "INTEGER PRIMARY KEY ASC AUTOINCREMENT NOT NULL UNIQUE"], ["type_id", "INTEGER NOT NULL"], ["site_id", "INTEGER"], ["value", "INTEGER"], ["date_added", "DATETIME DEFAULT (CURRENT_TIMESTAMP)"] ], "indexes": [ "CREATE INDEX site_id ON data (site_id)", "CREATE INDEX date_added ON data (date_added)" ], "schema_changed": 2 } schema["tables"]["type"] = { "cols": [ ["type_id", "INTEGER PRIMARY KEY NOT NULL UNIQUE"], ["name", "TEXT"] ], "schema_changed": 1 } schema["tables"]["site"] = { "cols": [ ["site_id", "INTEGER PRIMARY KEY NOT NULL UNIQUE"], ["address", "TEXT"] ], "schema_changed": 1 } return schema def getTypeId(self, name): if name not in self.types: res = self.execute("INSERT INTO type ?", {"name": name}) self.types[name] = res.lastrowid return self.types[name] def getSiteId(self, address): if address not in self.sites: res = self.execute("INSERT INTO site ?", {"address": address}) self.sites[address] = res.lastrowid return self.sites[address] def loadSites(self): sites = {} for row in self.execute("SELECT * FROM site"): sites[row["address"]] = row["site_id"] return sites def loadTypes(self): types = {} for row in self.execute("SELECT * FROM type"): types[row["name"]] = row["type_id"] return types def deleteSite(self, address): if address in self.sites: site_id = self.sites[address] del self.sites[address] self.execute("DELETE FROM site WHERE ?", {"site_id": site_id}) self.execute("DELETE FROM data WHERE ?", {"site_id": site_id}) def archive(self): week_back = 1 while 1: s = time.time() date_added_from = time.time() - 60 * 60 * 24 * 7 * (week_back + 1) date_added_to = date_added_from + 60 * 60 * 24 * 7 res = self.execute(""" SELECT MAX(date_added) AS date_added, SUM(value) AS value, GROUP_CONCAT(data_id) AS data_ids, type_id, site_id, COUNT(*) AS num FROM data WHERE site_id IS NULL AND date_added > :date_added_from AND date_added < :date_added_to GROUP BY strftime('%Y-%m-%d %H', date_added, 'unixepoch', 'localtime'), type_id """, {"date_added_from": date_added_from, "date_added_to": date_added_to}) num_archived = 0 cur = self.getCursor() for row in res: if row["num"] == 1: continue cur.execute("INSERT INTO data ?", { "type_id": row["type_id"], "site_id": row["site_id"], "value": row["value"], "date_added": row["date_added"] }) cur.execute("DELETE FROM data WHERE data_id IN (%s)" % row["data_ids"]) num_archived += row["num"] self.log.debug("Archived %s data from %s weeks ago in %.3fs" % (num_archived, week_back, time.time() - s)) week_back += 1 time.sleep(0.1) if num_archived == 0: break # Only keep 6 month of global stats self.execute( "DELETE FROM data WHERE site_id IS NULL AND date_added < :date_added_limit", {"date_added_limit": time.time() - 60 * 60 * 24 * 30 * 6 } ) # Only keep 1 month of site stats self.execute( "DELETE FROM data WHERE site_id IS NOT NULL AND date_added < :date_added_limit", {"date_added_limit": time.time() - 60 * 60 * 24 * 30 } ) if week_back > 1: self.execute("VACUUM") ================================================ FILE: plugins/Chart/ChartPlugin.py ================================================ import time import itertools import gevent from Config import config from util import helper from util.Flag import flag from Plugin import PluginManager from .ChartDb import ChartDb from .ChartCollector import ChartCollector if "db" not in locals().keys(): # Share on reloads db = ChartDb() gevent.spawn_later(10 * 60, db.archive) helper.timer(60 * 60 * 6, db.archive) collector = ChartCollector(db) @PluginManager.registerTo("SiteManager") class SiteManagerPlugin(object): def load(self, *args, **kwargs): back = super(SiteManagerPlugin, self).load(*args, **kwargs) collector.setInitialLastValues(self.sites.values()) return back def delete(self, address, *args, **kwargs): db.deleteSite(address) return super(SiteManagerPlugin, self).delete(address, *args, **kwargs) @PluginManager.registerTo("UiWebsocket") class UiWebsocketPlugin(object): @flag.admin def actionChartDbQuery(self, to, query, params=None): if config.debug or config.verbose: s = time.time() rows = [] try: if not query.strip().upper().startswith("SELECT"): raise Exception("Only SELECT query supported") res = db.execute(query, params) except Exception as err: # Response the error to client self.log.error("ChartDbQuery error: %s" % err) return {"error": str(err)} # Convert result to dict for row in res: rows.append(dict(row)) if config.verbose and time.time() - s > 0.1: # Log slow query self.log.debug("Slow query: %s (%.3fs)" % (query, time.time() - s)) return rows @flag.admin def actionChartGetPeerLocations(self, to): peers = {} for site in self.server.sites.values(): peers.update(site.peers) peer_locations = self.getPeerLocations(peers) return peer_locations ================================================ FILE: plugins/Chart/__init__.py ================================================ from . import ChartPlugin ================================================ FILE: plugins/Chart/plugin_info.json ================================================ { "name": "Chart", "description": "Collect and provide stats of client information.", "default": "enabled" } ================================================ FILE: plugins/ContentFilter/ContentFilterPlugin.py ================================================ import time import re import html import os from Plugin import PluginManager from Translate import Translate from Config import config from util.Flag import flag from .ContentFilterStorage import ContentFilterStorage plugin_dir = os.path.dirname(__file__) if "_" not in locals(): _ = Translate(plugin_dir + "/languages/") @PluginManager.registerTo("SiteManager") class SiteManagerPlugin(object): def load(self, *args, **kwargs): global filter_storage super(SiteManagerPlugin, self).load(*args, **kwargs) filter_storage = ContentFilterStorage(site_manager=self) def add(self, address, *args, **kwargs): should_ignore_block = kwargs.get("ignore_block") or kwargs.get("settings") if should_ignore_block: block_details = None elif filter_storage.isSiteblocked(address): block_details = filter_storage.getSiteblockDetails(address) else: address_hashed = filter_storage.getSiteAddressHashed(address) if filter_storage.isSiteblocked(address_hashed): block_details = filter_storage.getSiteblockDetails(address_hashed) else: block_details = None if block_details: raise Exception("Site blocked: %s" % html.escape(block_details.get("reason", "unknown reason"))) else: return super(SiteManagerPlugin, self).add(address, *args, **kwargs) @PluginManager.registerTo("UiWebsocket") class UiWebsocketPlugin(object): # Mute def cbMuteAdd(self, to, auth_address, cert_user_id, reason): filter_storage.file_content["mutes"][auth_address] = { "cert_user_id": cert_user_id, "reason": reason, "source": self.site.address, "date_added": time.time() } filter_storage.save() filter_storage.changeDbs(auth_address, "remove") self.response(to, "ok") @flag.no_multiuser def actionMuteAdd(self, to, auth_address, cert_user_id, reason): if "ADMIN" in self.getPermissions(to): self.cbMuteAdd(to, auth_address, cert_user_id, reason) else: self.cmd( "confirm", [_["Hide all content from %s?"] % html.escape(cert_user_id), _["Mute"]], lambda res: self.cbMuteAdd(to, auth_address, cert_user_id, reason) ) @flag.no_multiuser def cbMuteRemove(self, to, auth_address): del filter_storage.file_content["mutes"][auth_address] filter_storage.save() filter_storage.changeDbs(auth_address, "load") self.response(to, "ok") @flag.no_multiuser def actionMuteRemove(self, to, auth_address): if "ADMIN" in self.getPermissions(to): self.cbMuteRemove(to, auth_address) else: cert_user_id = html.escape(filter_storage.file_content["mutes"][auth_address]["cert_user_id"]) self.cmd( "confirm", [_["Unmute %s?"] % cert_user_id, _["Unmute"]], lambda res: self.cbMuteRemove(to, auth_address) ) @flag.admin def actionMuteList(self, to): self.response(to, filter_storage.file_content["mutes"]) # Siteblock @flag.no_multiuser @flag.admin def actionSiteblockIgnoreAddSite(self, to, site_address): if site_address in filter_storage.site_manager.sites: return {"error": "Site already added"} else: if filter_storage.site_manager.need(site_address, ignore_block=True): return "ok" else: return {"error": "Invalid address"} @flag.no_multiuser @flag.admin def actionSiteblockAdd(self, to, site_address, reason=None): filter_storage.file_content["siteblocks"][site_address] = {"date_added": time.time(), "reason": reason} filter_storage.save() self.response(to, "ok") @flag.no_multiuser @flag.admin def actionSiteblockRemove(self, to, site_address): del filter_storage.file_content["siteblocks"][site_address] filter_storage.save() self.response(to, "ok") @flag.admin def actionSiteblockList(self, to): self.response(to, filter_storage.file_content["siteblocks"]) @flag.admin def actionSiteblockGet(self, to, site_address): if filter_storage.isSiteblocked(site_address): res = filter_storage.getSiteblockDetails(site_address) else: site_address_hashed = filter_storage.getSiteAddressHashed(site_address) if filter_storage.isSiteblocked(site_address_hashed): res = filter_storage.getSiteblockDetails(site_address_hashed) else: res = {"error": "Site block not found"} self.response(to, res) # Include @flag.no_multiuser def actionFilterIncludeAdd(self, to, inner_path, description=None, address=None): if address: if "ADMIN" not in self.getPermissions(to): return self.response(to, {"error": "Forbidden: Only ADMIN sites can manage different site include"}) site = self.server.sites[address] else: address = self.site.address site = self.site if "ADMIN" in self.getPermissions(to): self.cbFilterIncludeAdd(to, True, address, inner_path, description) else: content = site.storage.loadJson(inner_path) title = _["New shared global content filter: %s (%s sites, %s users)"] % ( html.escape(inner_path), len(content.get("siteblocks", {})), len(content.get("mutes", {})) ) self.cmd( "confirm", [title, "Add"], lambda res: self.cbFilterIncludeAdd(to, res, address, inner_path, description) ) def cbFilterIncludeAdd(self, to, res, address, inner_path, description): if not res: self.response(to, res) return False filter_storage.includeAdd(address, inner_path, description) self.response(to, "ok") @flag.no_multiuser def actionFilterIncludeRemove(self, to, inner_path, address=None): if address: if "ADMIN" not in self.getPermissions(to): return self.response(to, {"error": "Forbidden: Only ADMIN sites can manage different site include"}) else: address = self.site.address key = "%s/%s" % (address, inner_path) if key not in filter_storage.file_content["includes"]: self.response(to, {"error": "Include not found"}) filter_storage.includeRemove(address, inner_path) self.response(to, "ok") def actionFilterIncludeList(self, to, all_sites=False, filters=False): if all_sites and "ADMIN" not in self.getPermissions(to): return self.response(to, {"error": "Forbidden: Only ADMIN sites can list all sites includes"}) back = [] includes = filter_storage.file_content.get("includes", {}).values() for include in includes: if not all_sites and include["address"] != self.site.address: continue if filters: include = dict(include) # Don't modify original file_content include_site = filter_storage.site_manager.get(include["address"]) if not include_site: continue content = include_site.storage.loadJson(include["inner_path"]) include["mutes"] = content.get("mutes", {}) include["siteblocks"] = content.get("siteblocks", {}) back.append(include) self.response(to, back) @PluginManager.registerTo("SiteStorage") class SiteStoragePlugin(object): def updateDbFile(self, inner_path, file=None, cur=None): if file is not False: # File deletion always allowed # Find for bitcoin addresses in file path matches = re.findall("/(1[A-Za-z0-9]{26,35})/", inner_path) # Check if any of the adresses are in the mute list for auth_address in matches: if filter_storage.isMuted(auth_address): self.log.debug("Mute match: %s, ignoring %s" % (auth_address, inner_path)) return False return super(SiteStoragePlugin, self).updateDbFile(inner_path, file=file, cur=cur) def onUpdated(self, inner_path, file=None): file_path = "%s/%s" % (self.site.address, inner_path) if file_path in filter_storage.file_content["includes"]: self.log.debug("Filter file updated: %s" % inner_path) filter_storage.includeUpdateAll() return super(SiteStoragePlugin, self).onUpdated(inner_path, file=file) @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object): def actionWrapper(self, path, extra_headers=None): match = re.match(r"/(?P
[A-Za-z0-9\._-]+)(?P/.*|$)", path) if not match: return False address = match.group("address") if self.server.site_manager.get(address): # Site already exists return super(UiRequestPlugin, self).actionWrapper(path, extra_headers) if self.isDomain(address): address = self.resolveDomain(address) if address: address_hashed = filter_storage.getSiteAddressHashed(address) else: address_hashed = None if filter_storage.isSiteblocked(address) or filter_storage.isSiteblocked(address_hashed): site = self.server.site_manager.get(config.homepage) if not extra_headers: extra_headers = {} script_nonce = self.getScriptNonce() self.sendHeader(extra_headers=extra_headers, script_nonce=script_nonce) return iter([super(UiRequestPlugin, self).renderWrapper( site, path, "uimedia/plugins/contentfilter/blocklisted.html?address=" + address, "Blacklisted site", extra_headers, show_loadingscreen=False, script_nonce=script_nonce )]) else: return super(UiRequestPlugin, self).actionWrapper(path, extra_headers) def actionUiMedia(self, path, *args, **kwargs): if path.startswith("/uimedia/plugins/contentfilter/"): file_path = path.replace("/uimedia/plugins/contentfilter/", plugin_dir + "/media/") return self.actionFile(file_path) else: return super(UiRequestPlugin, self).actionUiMedia(path) ================================================ FILE: plugins/ContentFilter/ContentFilterStorage.py ================================================ import os import json import logging import collections import time import hashlib from Debug import Debug from Plugin import PluginManager from Config import config from util import helper class ContentFilterStorage(object): def __init__(self, site_manager): self.log = logging.getLogger("ContentFilterStorage") self.file_path = "%s/filters.json" % config.data_dir self.site_manager = site_manager self.file_content = self.load() # Set default values for filters.json if not self.file_content: self.file_content = {} # Site blacklist renamed to site blocks if "site_blacklist" in self.file_content: self.file_content["siteblocks"] = self.file_content["site_blacklist"] del self.file_content["site_blacklist"] for key in ["mutes", "siteblocks", "includes"]: if key not in self.file_content: self.file_content[key] = {} self.include_filters = collections.defaultdict(set) # Merged list of mutes and blacklists from all include self.includeUpdateAll(update_site_dbs=False) def load(self): # Rename previously used mutes.json -> filters.json if os.path.isfile("%s/mutes.json" % config.data_dir): self.log.info("Renaming mutes.json to filters.json...") os.rename("%s/mutes.json" % config.data_dir, self.file_path) if os.path.isfile(self.file_path): try: return json.load(open(self.file_path)) except Exception as err: self.log.error("Error loading filters.json: %s" % err) return None else: return None def includeUpdateAll(self, update_site_dbs=True): s = time.time() new_include_filters = collections.defaultdict(set) # Load all include files data into a merged set for include_path in self.file_content["includes"]: address, inner_path = include_path.split("/", 1) try: content = self.site_manager.get(address).storage.loadJson(inner_path) except Exception as err: self.log.warning( "Error loading include %s: %s" % (include_path, Debug.formatException(err)) ) continue for key, val in content.items(): if type(val) is not dict: continue new_include_filters[key].update(val.keys()) mutes_added = new_include_filters["mutes"].difference(self.include_filters["mutes"]) mutes_removed = self.include_filters["mutes"].difference(new_include_filters["mutes"]) self.include_filters = new_include_filters if update_site_dbs: for auth_address in mutes_added: self.changeDbs(auth_address, "remove") for auth_address in mutes_removed: if not self.isMuted(auth_address): self.changeDbs(auth_address, "load") num_mutes = len(self.include_filters["mutes"]) num_siteblocks = len(self.include_filters["siteblocks"]) self.log.debug( "Loaded %s mutes, %s blocked sites from %s includes in %.3fs" % (num_mutes, num_siteblocks, len(self.file_content["includes"]), time.time() - s) ) def includeAdd(self, address, inner_path, description=None): self.file_content["includes"]["%s/%s" % (address, inner_path)] = { "date_added": time.time(), "address": address, "description": description, "inner_path": inner_path } self.includeUpdateAll() self.save() def includeRemove(self, address, inner_path): del self.file_content["includes"]["%s/%s" % (address, inner_path)] self.includeUpdateAll() self.save() def save(self): s = time.time() helper.atomicWrite(self.file_path, json.dumps(self.file_content, indent=2, sort_keys=True).encode("utf8")) self.log.debug("Saved in %.3fs" % (time.time() - s)) def isMuted(self, auth_address): if auth_address in self.file_content["mutes"] or auth_address in self.include_filters["mutes"]: return True else: return False def getSiteAddressHashed(self, address): return "0x" + hashlib.sha256(address.encode("ascii")).hexdigest() def isSiteblocked(self, address): if address in self.file_content["siteblocks"] or address in self.include_filters["siteblocks"]: return True return False def getSiteblockDetails(self, address): details = self.file_content["siteblocks"].get(address) if not details: address_sha256 = self.getSiteAddressHashed(address) details = self.file_content["siteblocks"].get(address_sha256) if not details: includes = self.file_content.get("includes", {}).values() for include in includes: include_site = self.site_manager.get(include["address"]) if not include_site: continue content = include_site.storage.loadJson(include["inner_path"]) details = content.get("siteblocks", {}).get(address) if details: details["include"] = include break return details # Search and remove or readd files of an user def changeDbs(self, auth_address, action): self.log.debug("Mute action %s on user %s" % (action, auth_address)) res = list(self.site_manager.list().values())[0].content_manager.contents.db.execute( "SELECT * FROM content LEFT JOIN site USING (site_id) WHERE inner_path LIKE :inner_path", {"inner_path": "%%/%s/%%" % auth_address} ) for row in res: site = self.site_manager.sites.get(row["address"]) if not site: continue dir_inner_path = helper.getDirname(row["inner_path"]) for file_name in site.storage.walk(dir_inner_path): if action == "remove": site.storage.onUpdated(dir_inner_path + file_name, False) else: site.storage.onUpdated(dir_inner_path + file_name) site.onFileDone(dir_inner_path + file_name) ================================================ FILE: plugins/ContentFilter/Test/TestContentFilter.py ================================================ import pytest from ContentFilter import ContentFilterPlugin from Site import SiteManager @pytest.fixture def filter_storage(): ContentFilterPlugin.filter_storage = ContentFilterPlugin.ContentFilterStorage(SiteManager.site_manager) return ContentFilterPlugin.filter_storage @pytest.mark.usefixtures("resetSettings") @pytest.mark.usefixtures("resetTempSettings") class TestContentFilter: def createInclude(self, site): site.storage.writeJson("filters.json", { "mutes": {"1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C": {}}, "siteblocks": {site.address: {}} }) def testIncludeLoad(self, site, filter_storage): self.createInclude(site) filter_storage.file_content["includes"]["%s/%s" % (site.address, "filters.json")] = { "date_added": 1528295893, } assert not filter_storage.include_filters["mutes"] assert not filter_storage.isMuted("1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C") assert not filter_storage.isSiteblocked(site.address) filter_storage.includeUpdateAll(update_site_dbs=False) assert len(filter_storage.include_filters["mutes"]) == 1 assert filter_storage.isMuted("1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C") assert filter_storage.isSiteblocked(site.address) def testIncludeAdd(self, site, filter_storage): self.createInclude(site) query_num_json = "SELECT COUNT(*) AS num FROM json WHERE directory = 'users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C'" assert not filter_storage.isSiteblocked(site.address) assert not filter_storage.isMuted("1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C") assert site.storage.query(query_num_json).fetchone()["num"] == 2 # Add include filter_storage.includeAdd(site.address, "filters.json") assert filter_storage.isSiteblocked(site.address) assert filter_storage.isMuted("1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C") assert site.storage.query(query_num_json).fetchone()["num"] == 0 # Remove include filter_storage.includeRemove(site.address, "filters.json") assert not filter_storage.isSiteblocked(site.address) assert not filter_storage.isMuted("1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C") assert site.storage.query(query_num_json).fetchone()["num"] == 2 def testIncludeChange(self, site, filter_storage): self.createInclude(site) filter_storage.includeAdd(site.address, "filters.json") assert filter_storage.isSiteblocked(site.address) assert filter_storage.isMuted("1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C") # Add new blocked site assert not filter_storage.isSiteblocked("1Hello") filter_content = site.storage.loadJson("filters.json") filter_content["siteblocks"]["1Hello"] = {} site.storage.writeJson("filters.json", filter_content) assert filter_storage.isSiteblocked("1Hello") # Add new muted user query_num_json = "SELECT COUNT(*) AS num FROM json WHERE directory = 'users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q'" assert not filter_storage.isMuted("1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q") assert site.storage.query(query_num_json).fetchone()["num"] == 2 filter_content["mutes"]["1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q"] = {} site.storage.writeJson("filters.json", filter_content) assert filter_storage.isMuted("1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q") assert site.storage.query(query_num_json).fetchone()["num"] == 0 ================================================ FILE: plugins/ContentFilter/Test/conftest.py ================================================ from src.Test.conftest import * ================================================ FILE: plugins/ContentFilter/Test/pytest.ini ================================================ [pytest] python_files = Test*.py addopts = -rsxX -v --durations=6 markers = webtest: mark a test as a webtest. ================================================ FILE: plugins/ContentFilter/__init__.py ================================================ from . import ContentFilterPlugin ================================================ FILE: plugins/ContentFilter/languages/hu.json ================================================ { "Hide all content from %s?": "%s tartalmaniak elrejtése?", "Mute": "Elnémítás", "Unmute %s?": "%s tartalmaniak megjelenítése?", "Unmute": "Némítás visszavonása" } ================================================ FILE: plugins/ContentFilter/languages/it.json ================================================ { "Hide all content from %s?": "%s Vuoi nascondere i contenuti di questo utente ?", "Mute": "Attiva Silenzia", "Unmute %s?": "%s Vuoi mostrare i contenuti di questo utente ?", "Unmute": "Disattiva Silenzia" } ================================================ FILE: plugins/ContentFilter/languages/jp.json ================================================ { "Hide all content from %s?": "%s のコンテンツをすべて隠しますか?", "Mute": "ミュート", "Unmute %s?": "%s のミュートを解除しますか?", "Unmute": "ミュート解除" } ================================================ FILE: plugins/ContentFilter/languages/pt-br.json ================================================ { "Hide all content from %s?": "%s Ocultar todo o conteúdo de ?", "Mute": "Ativar o Silêncio", "Unmute %s?": "%s Você quer mostrar o conteúdo deste usuário ?", "Unmute": "Desligar o silêncio" } ================================================ FILE: plugins/ContentFilter/languages/zh-tw.json ================================================ { "Hide all content from %s?": "屏蔽 %s 的所有內容?", "Mute": "屏蔽", "Unmute %s?": "對 %s 解除屏蔽?", "Unmute": "解除屏蔽" } ================================================ FILE: plugins/ContentFilter/languages/zh.json ================================================ { "Hide all content from %s?": "屏蔽 %s 的所有内容?", "Mute": "屏蔽", "Unmute %s?": "对 %s 解除屏蔽?", "Unmute": "解除屏蔽" } ================================================ FILE: plugins/ContentFilter/media/blocklisted.html ================================================

Site blocked

This site is on your blocklist:

Too much image
on 2015-01-25 12:32:11
================================================ FILE: plugins/ContentFilter/media/js/ZeroFrame.js ================================================ // Version 1.0.0 - Initial release // Version 1.1.0 (2017-08-02) - Added cmdp function that returns promise instead of using callback // Version 1.2.0 (2017-08-02) - Added Ajax monkey patch to emulate XMLHttpRequest over ZeroFrame API const CMD_INNER_READY = 'innerReady' const CMD_RESPONSE = 'response' const CMD_WRAPPER_READY = 'wrapperReady' const CMD_PING = 'ping' const CMD_PONG = 'pong' const CMD_WRAPPER_OPENED_WEBSOCKET = 'wrapperOpenedWebsocket' const CMD_WRAPPER_CLOSE_WEBSOCKET = 'wrapperClosedWebsocket' class ZeroFrame { constructor(url) { this.url = url this.waiting_cb = {} this.wrapper_nonce = document.location.href.replace(/.*wrapper_nonce=([A-Za-z0-9]+).*/, "$1") this.connect() this.next_message_id = 1 this.init() } init() { return this } connect() { this.target = window.parent window.addEventListener('message', e => this.onMessage(e), false) this.cmd(CMD_INNER_READY) } onMessage(e) { let message = e.data let cmd = message.cmd if (cmd === CMD_RESPONSE) { if (this.waiting_cb[message.to] !== undefined) { this.waiting_cb[message.to](message.result) } else { this.log("Websocket callback not found:", message) } } else if (cmd === CMD_WRAPPER_READY) { this.cmd(CMD_INNER_READY) } else if (cmd === CMD_PING) { this.response(message.id, CMD_PONG) } else if (cmd === CMD_WRAPPER_OPENED_WEBSOCKET) { this.onOpenWebsocket() } else if (cmd === CMD_WRAPPER_CLOSE_WEBSOCKET) { this.onCloseWebsocket() } else { this.onRequest(cmd, message) } } onRequest(cmd, message) { this.log("Unknown request", message) } response(to, result) { this.send({ cmd: CMD_RESPONSE, to: to, result: result }) } cmd(cmd, params={}, cb=null) { this.send({ cmd: cmd, params: params }, cb) } cmdp(cmd, params={}) { return new Promise((resolve, reject) => { this.cmd(cmd, params, (res) => { if (res && res.error) { reject(res.error) } else { resolve(res) } }) }) } send(message, cb=null) { message.wrapper_nonce = this.wrapper_nonce message.id = this.next_message_id this.next_message_id++ this.target.postMessage(message, '*') if (cb) { this.waiting_cb[message.id] = cb } } log(...args) { console.log.apply(console, ['[ZeroFrame]'].concat(args)) } onOpenWebsocket() { this.log('Websocket open') } onCloseWebsocket() { this.log('Websocket close') } monkeyPatchAjax() { var page = this XMLHttpRequest.prototype.realOpen = XMLHttpRequest.prototype.open this.cmd("wrapperGetAjaxKey", [], (res) => { this.ajax_key = res }) var newOpen = function (method, url, async) { url += "?ajax_key=" + page.ajax_key return this.realOpen(method, url, async) } XMLHttpRequest.prototype.open = newOpen } } ================================================ FILE: plugins/ContentFilter/plugin_info.json ================================================ { "name": "ContentFilter", "description": "Manage site and user block list.", "default": "enabled" } ================================================ FILE: plugins/Cors/CorsPlugin.py ================================================ import re import html import copy import os import gevent from Plugin import PluginManager from Translate import Translate plugin_dir = os.path.dirname(__file__) if "_" not in locals(): _ = Translate(plugin_dir + "/languages/") def getCorsPath(site, inner_path): match = re.match("^cors-([A-Za-z0-9]{26,35})/(.*)", inner_path) if not match: raise Exception("Invalid cors path: %s" % inner_path) cors_address = match.group(1) cors_inner_path = match.group(2) if not "Cors:%s" % cors_address in site.settings["permissions"]: raise Exception("This site has no permission to access site %s" % cors_address) return cors_address, cors_inner_path @PluginManager.registerTo("UiWebsocket") class UiWebsocketPlugin(object): def hasSitePermission(self, address, cmd=None): if super(UiWebsocketPlugin, self).hasSitePermission(address, cmd=cmd): return True allowed_commands = [ "fileGet", "fileList", "dirList", "fileRules", "optionalFileInfo", "fileQuery", "dbQuery", "userGetSettings", "siteInfo" ] if not "Cors:%s" % address in self.site.settings["permissions"] or cmd not in allowed_commands: return False else: return True # Add cors support for file commands def corsFuncWrapper(self, func_name, to, inner_path, *args, **kwargs): if inner_path.startswith("cors-"): cors_address, cors_inner_path = getCorsPath(self.site, inner_path) req_self = copy.copy(self) req_self.site = self.server.sites.get(cors_address) # Change the site to the merged one if not req_self.site: return {"error": "No site found"} func = getattr(super(UiWebsocketPlugin, req_self), func_name) back = func(to, cors_inner_path, *args, **kwargs) return back else: func = getattr(super(UiWebsocketPlugin, self), func_name) return func(to, inner_path, *args, **kwargs) def actionFileGet(self, to, inner_path, *args, **kwargs): return self.corsFuncWrapper("actionFileGet", to, inner_path, *args, **kwargs) def actionFileList(self, to, inner_path, *args, **kwargs): return self.corsFuncWrapper("actionFileList", to, inner_path, *args, **kwargs) def actionDirList(self, to, inner_path, *args, **kwargs): return self.corsFuncWrapper("actionDirList", to, inner_path, *args, **kwargs) def actionFileRules(self, to, inner_path, *args, **kwargs): return self.corsFuncWrapper("actionFileRules", to, inner_path, *args, **kwargs) def actionOptionalFileInfo(self, to, inner_path, *args, **kwargs): return self.corsFuncWrapper("actionOptionalFileInfo", to, inner_path, *args, **kwargs) def actionCorsPermission(self, to, address): if isinstance(address, list): addresses = address else: addresses = [address] button_title = _["Grant"] site_names = [] site_addresses = [] for address in addresses: site = self.server.sites.get(address) if site: site_name = site.content_manager.contents.get("content.json", {}).get("title", address) else: site_name = address # If at least one site is not downloaded yet, show "Grant & Add" instead button_title = _["Grant & Add"] if not (site and "Cors:" + address in self.permissions): # No site or no permission site_names.append(site_name) site_addresses.append(address) if len(site_names) == 0: return "ignored" self.cmd( "confirm", [_["This site requests read permission to: %s"] % ", ".join(map(html.escape, site_names)), button_title], lambda res: self.cbCorsPermission(to, site_addresses) ) def cbCorsPermission(self, to, addresses): # Add permissions for address in addresses: permission = "Cors:" + address if permission not in self.site.settings["permissions"]: self.site.settings["permissions"].append(permission) self.site.saveSettings() self.site.updateWebsocket(permission_added=permission) self.response(to, "ok") for address in addresses: site = self.server.sites.get(address) if not site: gevent.spawn(self.server.site_manager.need, address) @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object): # Allow to load cross origin files using /cors-address/file.jpg def parsePath(self, path): path_parts = super(UiRequestPlugin, self).parsePath(path) if "cors-" not in path: # Optimization return path_parts site = self.server.sites[path_parts["address"]] try: path_parts["address"], path_parts["inner_path"] = getCorsPath(site, path_parts["inner_path"]) except Exception: return None return path_parts ================================================ FILE: plugins/Cors/__init__.py ================================================ from . import CorsPlugin ================================================ FILE: plugins/Cors/plugin_info.json ================================================ { "name": "Cors", "description": "Cross site resource read.", "default": "enabled" } ================================================ FILE: plugins/CryptMessage/CryptMessage.py ================================================ import hashlib import base64 import struct from lib import sslcrypto from Crypt import Crypt curve = sslcrypto.ecc.get_curve("secp256k1") def eciesEncrypt(data, pubkey, ciphername="aes-256-cbc"): ciphertext, key_e = curve.encrypt( data, base64.b64decode(pubkey), algo=ciphername, derivation="sha512", return_aes_key=True ) return key_e, ciphertext @Crypt.thread_pool_crypt.wrap def eciesDecryptMulti(encrypted_datas, privatekey): texts = [] # Decoded texts for encrypted_data in encrypted_datas: try: text = eciesDecrypt(encrypted_data, privatekey).decode("utf8") texts.append(text) except Exception: texts.append(None) return texts def eciesDecrypt(ciphertext, privatekey): return curve.decrypt(base64.b64decode(ciphertext), curve.wif_to_private(privatekey.encode()), derivation="sha512") def decodePubkey(pubkey): i = 0 curve = struct.unpack('!H', pubkey[i:i + 2])[0] i += 2 tmplen = struct.unpack('!H', pubkey[i:i + 2])[0] i += 2 pubkey_x = pubkey[i:i + tmplen] i += tmplen tmplen = struct.unpack('!H', pubkey[i:i + 2])[0] i += 2 pubkey_y = pubkey[i:i + tmplen] i += tmplen return curve, pubkey_x, pubkey_y, i def split(encrypted): iv = encrypted[0:16] curve, pubkey_x, pubkey_y, i = decodePubkey(encrypted[16:]) ciphertext = encrypted[16 + i:-32] return iv, ciphertext ================================================ FILE: plugins/CryptMessage/CryptMessagePlugin.py ================================================ import base64 import os import gevent from Plugin import PluginManager from Crypt import CryptBitcoin, CryptHash from Config import config import sslcrypto from . import CryptMessage curve = sslcrypto.ecc.get_curve("secp256k1") @PluginManager.registerTo("UiWebsocket") class UiWebsocketPlugin(object): # - Actions - # Returns user's public key unique to site # Return: Public key def actionUserPublickey(self, to, index=0): self.response(to, self.user.getEncryptPublickey(self.site.address, index)) # Encrypt a text using the publickey or user's sites unique publickey # Return: Encrypted text using base64 encoding def actionEciesEncrypt(self, to, text, publickey=0, return_aes_key=False): if type(publickey) is int: # Encrypt using user's publickey publickey = self.user.getEncryptPublickey(self.site.address, publickey) aes_key, encrypted = CryptMessage.eciesEncrypt(text.encode("utf8"), publickey) if return_aes_key: self.response(to, [base64.b64encode(encrypted).decode("utf8"), base64.b64encode(aes_key).decode("utf8")]) else: self.response(to, base64.b64encode(encrypted).decode("utf8")) # Decrypt a text using privatekey or the user's site unique private key # Return: Decrypted text or list of decrypted texts def actionEciesDecrypt(self, to, param, privatekey=0): if type(privatekey) is int: # Decrypt using user's privatekey privatekey = self.user.getEncryptPrivatekey(self.site.address, privatekey) if type(param) == list: encrypted_texts = param else: encrypted_texts = [param] texts = CryptMessage.eciesDecryptMulti(encrypted_texts, privatekey) if type(param) == list: self.response(to, texts) else: self.response(to, texts[0]) # Encrypt a text using AES # Return: Iv, AES key, Encrypted text def actionAesEncrypt(self, to, text, key=None): if key: key = base64.b64decode(key) else: key = sslcrypto.aes.new_key() if text: encrypted, iv = sslcrypto.aes.encrypt(text.encode("utf8"), key) else: encrypted, iv = b"", b"" res = [base64.b64encode(item).decode("utf8") for item in [key, iv, encrypted]] self.response(to, res) # Decrypt a text using AES # Return: Decrypted text def actionAesDecrypt(self, to, *args): if len(args) == 3: # Single decrypt encrypted_texts = [(args[0], args[1])] keys = [args[2]] else: # Batch decrypt encrypted_texts, keys = args texts = [] # Decoded texts for iv, encrypted_text in encrypted_texts: encrypted_text = base64.b64decode(encrypted_text) iv = base64.b64decode(iv) text = None for key in keys: try: decrypted = sslcrypto.aes.decrypt(encrypted_text, iv, base64.b64decode(key)) if decrypted and decrypted.decode("utf8"): # Valid text decoded text = decrypted.decode("utf8") except Exception as err: pass texts.append(text) if len(args) == 3: self.response(to, texts[0]) else: self.response(to, texts) # Sign data using ECDSA # Return: Signature def actionEcdsaSign(self, to, data, privatekey=None): if privatekey is None: # Sign using user's privatekey privatekey = self.user.getAuthPrivatekey(self.site.address) self.response(to, CryptBitcoin.sign(data, privatekey)) # Verify data using ECDSA (address is either a address or array of addresses) # Return: bool def actionEcdsaVerify(self, to, data, address, signature): self.response(to, CryptBitcoin.verify(data, address, signature)) # Gets the publickey of a given privatekey def actionEccPrivToPub(self, to, privatekey): self.response(to, curve.private_to_public(curve.wif_to_private(privatekey.encode()))) # Gets the address of a given publickey def actionEccPubToAddr(self, to, publickey): self.response(to, curve.public_to_address(bytes.fromhex(publickey))) @PluginManager.registerTo("User") class UserPlugin(object): def getEncryptPrivatekey(self, address, param_index=0): if param_index < 0 or param_index > 1000: raise Exception("Param_index out of range") site_data = self.getSiteData(address) if site_data.get("cert"): # Different privatekey for different cert provider index = param_index + self.getAddressAuthIndex(site_data["cert"]) else: index = param_index if "encrypt_privatekey_%s" % index not in site_data: address_index = self.getAddressAuthIndex(address) crypt_index = address_index + 1000 + index site_data["encrypt_privatekey_%s" % index] = CryptBitcoin.hdPrivatekey(self.master_seed, crypt_index) self.log.debug("New encrypt privatekey generated for %s:%s" % (address, index)) return site_data["encrypt_privatekey_%s" % index] def getEncryptPublickey(self, address, param_index=0): if param_index < 0 or param_index > 1000: raise Exception("Param_index out of range") site_data = self.getSiteData(address) if site_data.get("cert"): # Different privatekey for different cert provider index = param_index + self.getAddressAuthIndex(site_data["cert"]) else: index = param_index if "encrypt_publickey_%s" % index not in site_data: privatekey = self.getEncryptPrivatekey(address, param_index).encode() publickey = curve.private_to_public(curve.wif_to_private(privatekey) + b"\x01") site_data["encrypt_publickey_%s" % index] = base64.b64encode(publickey).decode("utf8") return site_data["encrypt_publickey_%s" % index] @PluginManager.registerTo("Actions") class ActionsPlugin: publickey = "A3HatibU4S6eZfIQhVs2u7GLN5G9wXa9WwlkyYIfwYaj" privatekey = "5JBiKFYBm94EUdbxtnuLi6cvNcPzcKymCUHBDf2B6aq19vvG3rL" utf8_text = '\xc1rv\xedzt\xfbr\xf5t\xfck\xf6rf\xfar\xf3g\xe9p' def getBenchmarkTests(self, online=False): if hasattr(super(), "getBenchmarkTests"): tests = super().getBenchmarkTests(online) else: tests = [] aes_key, encrypted = CryptMessage.eciesEncrypt(self.utf8_text.encode("utf8"), self.publickey) # Warm-up tests.extend([ {"func": self.testCryptEciesEncrypt, "kwargs": {}, "num": 100, "time_standard": 1.2}, {"func": self.testCryptEciesDecrypt, "kwargs": {}, "num": 500, "time_standard": 1.3}, {"func": self.testCryptEciesDecryptMulti, "kwargs": {}, "num": 5, "time_standard": 0.68}, {"func": self.testCryptAesEncrypt, "kwargs": {}, "num": 10000, "time_standard": 0.27}, {"func": self.testCryptAesDecrypt, "kwargs": {}, "num": 10000, "time_standard": 0.25} ]) return tests def testCryptEciesEncrypt(self, num_run=1): for i in range(num_run): aes_key, encrypted = CryptMessage.eciesEncrypt(self.utf8_text.encode("utf8"), self.publickey) assert len(aes_key) == 32 yield "." def testCryptEciesDecrypt(self, num_run=1): aes_key, encrypted = CryptMessage.eciesEncrypt(self.utf8_text.encode("utf8"), self.publickey) for i in range(num_run): assert len(aes_key) == 32 decrypted = CryptMessage.eciesDecrypt(base64.b64encode(encrypted), self.privatekey) assert decrypted == self.utf8_text.encode("utf8"), "%s != %s" % (decrypted, self.utf8_text.encode("utf8")) yield "." def testCryptEciesDecryptMulti(self, num_run=1): yield "x 100 (%s threads) " % config.threads_crypt aes_key, encrypted = CryptMessage.eciesEncrypt(self.utf8_text.encode("utf8"), self.publickey) threads = [] for i in range(num_run): assert len(aes_key) == 32 threads.append(gevent.spawn( CryptMessage.eciesDecryptMulti, [base64.b64encode(encrypted)] * 100, self.privatekey )) for thread in threads: res = thread.get() assert res[0] == self.utf8_text, "%s != %s" % (res[0], self.utf8_text) assert res[0] == res[-1], "%s != %s" % (res[0], res[-1]) yield "." gevent.joinall(threads) def testCryptAesEncrypt(self, num_run=1): for i in range(num_run): key = os.urandom(32) encrypted = sslcrypto.aes.encrypt(self.utf8_text.encode("utf8"), key) yield "." def testCryptAesDecrypt(self, num_run=1): key = os.urandom(32) encrypted_text, iv = sslcrypto.aes.encrypt(self.utf8_text.encode("utf8"), key) for i in range(num_run): decrypted = sslcrypto.aes.decrypt(encrypted_text, iv, key).decode("utf8") assert decrypted == self.utf8_text yield "." ================================================ FILE: plugins/CryptMessage/Test/TestCrypt.py ================================================ import pytest import base64 from CryptMessage import CryptMessage @pytest.mark.usefixtures("resetSettings") class TestCrypt: publickey = "A3HatibU4S6eZfIQhVs2u7GLN5G9wXa9WwlkyYIfwYaj" privatekey = "5JBiKFYBm94EUdbxtnuLi6cvNcPzcKymCUHBDf2B6aq19vvG3rL" utf8_text = '\xc1rv\xedzt\xfbr\xf5t\xfck\xf6rf\xfar\xf3g\xe9' ecies_encrypted_text = "R5J1RFIDOzE5bnWopvccmALKACCk/CRcd/KSE9OgExJKASyMbZ57JVSUenL2TpABMmcT+wAgr2UrOqClxpOWvIUwvwwupXnMbRTzthhIJJrTRW3sCJVaYlGEMn9DAcvbflgEkQX/MVVdLV3tWKySs1Vk8sJC/y+4pGYCrZz7vwDNEEERaqU=" @pytest.mark.parametrize("text", [b"hello", '\xc1rv\xedzt\xfbr\xf5t\xfck\xf6rf\xfar\xf3g\xe9'.encode("utf8")]) @pytest.mark.parametrize("text_repeat", [1, 10, 128, 1024]) def testEncryptEcies(self, text, text_repeat): text_repeated = text * text_repeat aes_key, encrypted = CryptMessage.eciesEncrypt(text_repeated, self.publickey) assert len(aes_key) == 32 # assert len(encrypted) == 134 + int(len(text) / 16) * 16 # Not always true assert CryptMessage.eciesDecrypt(base64.b64encode(encrypted), self.privatekey) == text_repeated def testDecryptEcies(self, user): assert CryptMessage.eciesDecrypt(self.ecies_encrypted_text, self.privatekey) == b"hello" def testPublickey(self, ui_websocket): pub = ui_websocket.testAction("UserPublickey", 0) assert len(pub) == 44 # Compressed, b64 encoded publickey # Different pubkey for specificed index assert ui_websocket.testAction("UserPublickey", 1) != ui_websocket.testAction("UserPublickey", 0) # Same publickey for same index assert ui_websocket.testAction("UserPublickey", 2) == ui_websocket.testAction("UserPublickey", 2) # Different publickey for different cert site_data = ui_websocket.user.getSiteData(ui_websocket.site.address) site_data["cert"] = None pub1 = ui_websocket.testAction("UserPublickey", 0) site_data = ui_websocket.user.getSiteData(ui_websocket.site.address) site_data["cert"] = "zeroid.bit" pub2 = ui_websocket.testAction("UserPublickey", 0) assert pub1 != pub2 def testEcies(self, ui_websocket): pub = ui_websocket.testAction("UserPublickey") encrypted = ui_websocket.testAction("EciesEncrypt", "hello", pub) assert len(encrypted) == 180 # Don't allow decrypt using other privatekey index decrypted = ui_websocket.testAction("EciesDecrypt", encrypted, 123) assert decrypted != "hello" # Decrypt using correct privatekey decrypted = ui_websocket.testAction("EciesDecrypt", encrypted) assert decrypted == "hello" # Decrypt incorrect text decrypted = ui_websocket.testAction("EciesDecrypt", "baad") assert decrypted is None # Decrypt batch decrypted = ui_websocket.testAction("EciesDecrypt", [encrypted, "baad", encrypted]) assert decrypted == ["hello", None, "hello"] def testEciesUtf8(self, ui_websocket): # Utf8 test ui_websocket.actionEciesEncrypt(0, self.utf8_text) encrypted = ui_websocket.ws.getResult() ui_websocket.actionEciesDecrypt(0, encrypted) assert ui_websocket.ws.getResult() == self.utf8_text def testEciesAes(self, ui_websocket): ui_websocket.actionEciesEncrypt(0, "hello", return_aes_key=True) ecies_encrypted, aes_key = ui_websocket.ws.getResult() # Decrypt using Ecies ui_websocket.actionEciesDecrypt(0, ecies_encrypted) assert ui_websocket.ws.getResult() == "hello" # Decrypt using AES aes_iv, aes_encrypted = CryptMessage.split(base64.b64decode(ecies_encrypted)) ui_websocket.actionAesDecrypt(0, base64.b64encode(aes_iv), base64.b64encode(aes_encrypted), aes_key) assert ui_websocket.ws.getResult() == "hello" def testEciesAesLongpubkey(self, ui_websocket): privatekey = "5HwVS1bTFnveNk9EeGaRenWS1QFzLFb5kuncNbiY3RiHZrVR6ok" ecies_encrypted, aes_key = ["lWiXfEikIjw1ac3J/RaY/gLKACALRUfksc9rXYRFyKDSaxhwcSFBYCgAdIyYlY294g/6VgAf/68PYBVMD3xKH1n7Zbo+ge8b4i/XTKmCZRJvy0eutMKWckYCMVcxgIYNa/ZL1BY1kvvH7omgzg1wBraoLfdbNmVtQgdAZ9XS8PwRy6OB2Q==", "Rvlf7zsMuBFHZIGHcbT1rb4If+YTmsWDv6kGwcvSeMM="] # Decrypt using Ecies ui_websocket.actionEciesDecrypt(0, ecies_encrypted, privatekey) assert ui_websocket.ws.getResult() == "hello" # Decrypt using AES aes_iv, aes_encrypted = CryptMessage.split(base64.b64decode(ecies_encrypted)) ui_websocket.actionAesDecrypt(0, base64.b64encode(aes_iv), base64.b64encode(aes_encrypted), aes_key) assert ui_websocket.ws.getResult() == "hello" def testAes(self, ui_websocket): ui_websocket.actionAesEncrypt(0, "hello") key, iv, encrypted = ui_websocket.ws.getResult() assert len(key) == 44 assert len(iv) == 24 assert len(encrypted) == 24 # Single decrypt ui_websocket.actionAesDecrypt(0, iv, encrypted, key) assert ui_websocket.ws.getResult() == "hello" # Batch decrypt ui_websocket.actionAesEncrypt(0, "hello") key2, iv2, encrypted2 = ui_websocket.ws.getResult() assert [key, iv, encrypted] != [key2, iv2, encrypted2] # 2 correct key ui_websocket.actionAesDecrypt(0, [[iv, encrypted], [iv, encrypted], [iv, "baad"], [iv2, encrypted2]], [key]) assert ui_websocket.ws.getResult() == ["hello", "hello", None, None] # 3 key ui_websocket.actionAesDecrypt(0, [[iv, encrypted], [iv, encrypted], [iv, "baad"], [iv2, encrypted2]], [key, key2]) assert ui_websocket.ws.getResult() == ["hello", "hello", None, "hello"] def testAesUtf8(self, ui_websocket): ui_websocket.actionAesEncrypt(0, self.utf8_text) key, iv, encrypted = ui_websocket.ws.getResult() ui_websocket.actionAesDecrypt(0, iv, encrypted, key) assert ui_websocket.ws.getResult() == self.utf8_text ================================================ FILE: plugins/CryptMessage/Test/conftest.py ================================================ from src.Test.conftest import * ================================================ FILE: plugins/CryptMessage/Test/pytest.ini ================================================ [pytest] python_files = Test*.py addopts = -rsxX -v --durations=6 markers = webtest: mark a test as a webtest. ================================================ FILE: plugins/CryptMessage/__init__.py ================================================ from . import CryptMessagePlugin ================================================ FILE: plugins/CryptMessage/plugin_info.json ================================================ { "name": "CryptMessage", "description": "Cryptographic functions of ECIES and AES data encryption/decryption.", "default": "enabled" } ================================================ FILE: plugins/FilePack/FilePackPlugin.py ================================================ import os import re import gevent from Plugin import PluginManager from Config import config from Debug import Debug # Keep archive open for faster reponse times for large sites archive_cache = {} def closeArchive(archive_path): if archive_path in archive_cache: del archive_cache[archive_path] def openArchive(archive_path, file_obj=None): if archive_path not in archive_cache: if archive_path.endswith("tar.gz"): import tarfile archive_cache[archive_path] = tarfile.open(archive_path, fileobj=file_obj, mode="r:gz") else: import zipfile archive_cache[archive_path] = zipfile.ZipFile(file_obj or archive_path) gevent.spawn_later(5, lambda: closeArchive(archive_path)) # Close after 5 sec archive = archive_cache[archive_path] return archive def openArchiveFile(archive_path, path_within, file_obj=None): archive = openArchive(archive_path, file_obj=file_obj) if archive_path.endswith(".zip"): return archive.open(path_within) else: return archive.extractfile(path_within) @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object): def actionSiteMedia(self, path, **kwargs): if ".zip/" in path or ".tar.gz/" in path: file_obj = None path_parts = self.parsePath(path) file_path = "%s/%s/%s" % (config.data_dir, path_parts["address"], path_parts["inner_path"]) match = re.match("^(.*\.(?:tar.gz|zip))/(.*)", file_path) archive_path, path_within = match.groups() if archive_path not in archive_cache: site = self.server.site_manager.get(path_parts["address"]) if not site: return self.actionSiteAddPrompt(path) archive_inner_path = site.storage.getInnerPath(archive_path) if not os.path.isfile(archive_path): # Wait until file downloads result = site.needFile(archive_inner_path, priority=10) # Send virutal file path download finished event to remove loading screen site.updateWebsocket(file_done=archive_inner_path) if not result: return self.error404(archive_inner_path) file_obj = site.storage.openBigfile(archive_inner_path) if file_obj == False: file_obj = None header_allow_ajax = False if self.get.get("ajax_key"): requester_site = self.server.site_manager.get(path_parts["request_address"]) if self.get["ajax_key"] == requester_site.settings["ajax_key"]: header_allow_ajax = True else: return self.error403("Invalid ajax_key") try: file = openArchiveFile(archive_path, path_within, file_obj=file_obj) content_type = self.getContentType(file_path) self.sendHeader(200, content_type=content_type, noscript=kwargs.get("header_noscript", False), allow_ajax=header_allow_ajax) return self.streamFile(file) except Exception as err: self.log.debug("Error opening archive file: %s" % Debug.formatException(err)) return self.error404(path) return super(UiRequestPlugin, self).actionSiteMedia(path, **kwargs) def streamFile(self, file): for i in range(100): # Read max 6MB try: block = file.read(60 * 1024) if block: yield block else: raise StopIteration except StopIteration: file.close() break @PluginManager.registerTo("SiteStorage") class SiteStoragePlugin(object): def isFile(self, inner_path): if ".zip/" in inner_path or ".tar.gz/" in inner_path: match = re.match("^(.*\.(?:tar.gz|zip))/(.*)", inner_path) archive_inner_path, path_within = match.groups() return super(SiteStoragePlugin, self).isFile(archive_inner_path) else: return super(SiteStoragePlugin, self).isFile(inner_path) def openArchive(self, inner_path): archive_path = self.getPath(inner_path) file_obj = None if archive_path not in archive_cache: if not os.path.isfile(archive_path): result = self.site.needFile(inner_path, priority=10) self.site.updateWebsocket(file_done=inner_path) if not result: raise Exception("Unable to download file") file_obj = self.site.storage.openBigfile(inner_path) if file_obj == False: file_obj = None try: archive = openArchive(archive_path, file_obj=file_obj) except Exception as err: raise Exception("Unable to download file: %s" % Debug.formatException(err)) return archive def walk(self, inner_path, *args, **kwags): if ".zip" in inner_path or ".tar.gz" in inner_path: match = re.match("^(.*\.(?:tar.gz|zip))(.*)", inner_path) archive_inner_path, path_within = match.groups() archive = self.openArchive(archive_inner_path) path_within = path_within.lstrip("/") if archive_inner_path.endswith(".zip"): namelist = [name for name in archive.namelist() if not name.endswith("/")] else: namelist = [item.name for item in archive.getmembers() if not item.isdir()] namelist_relative = [] for name in namelist: if not name.startswith(path_within): continue name_relative = name.replace(path_within, "", 1).rstrip("/") namelist_relative.append(name_relative) return namelist_relative else: return super(SiteStoragePlugin, self).walk(inner_path, *args, **kwags) def list(self, inner_path, *args, **kwags): if ".zip" in inner_path or ".tar.gz" in inner_path: match = re.match("^(.*\.(?:tar.gz|zip))(.*)", inner_path) archive_inner_path, path_within = match.groups() archive = self.openArchive(archive_inner_path) path_within = path_within.lstrip("/") if archive_inner_path.endswith(".zip"): namelist = [name for name in archive.namelist()] else: namelist = [item.name for item in archive.getmembers()] namelist_relative = [] for name in namelist: if not name.startswith(path_within): continue name_relative = name.replace(path_within, "", 1).rstrip("/") if "/" in name_relative: # File is in sub-directory continue namelist_relative.append(name_relative) return namelist_relative else: return super(SiteStoragePlugin, self).list(inner_path, *args, **kwags) def read(self, inner_path, mode="rb", **kwargs): if ".zip/" in inner_path or ".tar.gz/" in inner_path: match = re.match("^(.*\.(?:tar.gz|zip))(.*)", inner_path) archive_inner_path, path_within = match.groups() archive = self.openArchive(archive_inner_path) path_within = path_within.lstrip("/") if archive_inner_path.endswith(".zip"): return archive.open(path_within).read() else: return archive.extractfile(path_within).read() else: return super(SiteStoragePlugin, self).read(inner_path, mode, **kwargs) ================================================ FILE: plugins/FilePack/__init__.py ================================================ from . import FilePackPlugin ================================================ FILE: plugins/FilePack/plugin_info.json ================================================ { "name": "FilePack", "description": "Transparent web access for Zip and Tar.gz files.", "default": "enabled" } ================================================ FILE: plugins/MergerSite/MergerSitePlugin.py ================================================ import re import time import copy import os from Plugin import PluginManager from Translate import Translate from util import RateLimit from util import helper from util.Flag import flag from Debug import Debug try: import OptionalManager.UiWebsocketPlugin # To make optioanlFileInfo merger sites compatible except Exception: pass if "merger_db" not in locals().keys(): # To keep merger_sites between module reloads merger_db = {} # Sites that allowed to list other sites {address: [type1, type2...]} merged_db = {} # Sites that allowed to be merged to other sites {address: type, ...} merged_to_merger = {} # {address: [site1, site2, ...]} cache site_manager = None # Site manager for merger sites plugin_dir = os.path.dirname(__file__) if "_" not in locals(): _ = Translate(plugin_dir + "/languages/") # Check if the site has permission to this merger site def checkMergerPath(address, inner_path): merged_match = re.match("^merged-(.*?)/([A-Za-z0-9]{26,35})/", inner_path) if merged_match: merger_type = merged_match.group(1) # Check if merged site is allowed to include other sites if merger_type in merger_db.get(address, []): # Check if included site allows to include merged_address = merged_match.group(2) if merged_db.get(merged_address) == merger_type: inner_path = re.sub("^merged-(.*?)/([A-Za-z0-9]{26,35})/", "", inner_path) return merged_address, inner_path else: raise Exception( "Merger site (%s) does not have permission for merged site: %s (%s)" % (merger_type, merged_address, merged_db.get(merged_address)) ) else: raise Exception("No merger (%s) permission to load:
%s (%s not in %s)" % ( address, inner_path, merger_type, merger_db.get(address, [])) ) else: raise Exception("Invalid merger path: %s" % inner_path) @PluginManager.registerTo("UiWebsocket") class UiWebsocketPlugin(object): # Download new site def actionMergerSiteAdd(self, to, addresses): if type(addresses) != list: # Single site add addresses = [addresses] # Check if the site has merger permission merger_types = merger_db.get(self.site.address) if not merger_types: return self.response(to, {"error": "Not a merger site"}) if RateLimit.isAllowed(self.site.address + "-MergerSiteAdd", 10) and len(addresses) == 1: # Without confirmation if only one site address and not called in last 10 sec self.cbMergerSiteAdd(to, addresses) else: self.cmd( "confirm", [_["Add %s new site?"] % len(addresses), "Add"], lambda res: self.cbMergerSiteAdd(to, addresses) ) self.response(to, "ok") # Callback of adding new site confirmation def cbMergerSiteAdd(self, to, addresses): added = 0 for address in addresses: try: site_manager.need(address) added += 1 except Exception as err: self.cmd("notification", ["error", _["Adding %s failed: %s"] % (address, err)]) if added: self.cmd("notification", ["done", _["Added %s new site"] % added, 5000]) RateLimit.called(self.site.address + "-MergerSiteAdd") site_manager.updateMergerSites() # Delete a merged site @flag.no_multiuser def actionMergerSiteDelete(self, to, address): site = self.server.sites.get(address) if not site: return self.response(to, {"error": "No site found: %s" % address}) merger_types = merger_db.get(self.site.address) if not merger_types: return self.response(to, {"error": "Not a merger site"}) if merged_db.get(address) not in merger_types: return self.response(to, {"error": "Merged type (%s) not in %s" % (merged_db.get(address), merger_types)}) self.cmd("notification", ["done", _["Site deleted: %s"] % address, 5000]) self.response(to, "ok") # Lists merged sites def actionMergerSiteList(self, to, query_site_info=False): merger_types = merger_db.get(self.site.address) ret = {} if not merger_types: return self.response(to, {"error": "Not a merger site"}) for address, merged_type in merged_db.items(): if merged_type not in merger_types: continue # Site not for us if query_site_info: site = self.server.sites.get(address) ret[address] = self.formatSiteInfo(site, create_user=False) else: ret[address] = merged_type self.response(to, ret) def hasSitePermission(self, address, *args, **kwargs): if super(UiWebsocketPlugin, self).hasSitePermission(address, *args, **kwargs): return True else: if self.site.address in [merger_site.address for merger_site in merged_to_merger.get(address, [])]: return True else: return False # Add support merger sites for file commands def mergerFuncWrapper(self, func_name, to, inner_path, *args, **kwargs): if inner_path.startswith("merged-"): merged_address, merged_inner_path = checkMergerPath(self.site.address, inner_path) # Set the same cert for merged site merger_cert = self.user.getSiteData(self.site.address).get("cert") if merger_cert and self.user.getSiteData(merged_address).get("cert") != merger_cert: self.user.setCert(merged_address, merger_cert) req_self = copy.copy(self) req_self.site = self.server.sites.get(merged_address) # Change the site to the merged one func = getattr(super(UiWebsocketPlugin, req_self), func_name) return func(to, merged_inner_path, *args, **kwargs) else: func = getattr(super(UiWebsocketPlugin, self), func_name) return func(to, inner_path, *args, **kwargs) def actionFileList(self, to, inner_path, *args, **kwargs): return self.mergerFuncWrapper("actionFileList", to, inner_path, *args, **kwargs) def actionDirList(self, to, inner_path, *args, **kwargs): return self.mergerFuncWrapper("actionDirList", to, inner_path, *args, **kwargs) def actionFileGet(self, to, inner_path, *args, **kwargs): return self.mergerFuncWrapper("actionFileGet", to, inner_path, *args, **kwargs) def actionFileWrite(self, to, inner_path, *args, **kwargs): return self.mergerFuncWrapper("actionFileWrite", to, inner_path, *args, **kwargs) def actionFileDelete(self, to, inner_path, *args, **kwargs): return self.mergerFuncWrapper("actionFileDelete", to, inner_path, *args, **kwargs) def actionFileRules(self, to, inner_path, *args, **kwargs): return self.mergerFuncWrapper("actionFileRules", to, inner_path, *args, **kwargs) def actionFileNeed(self, to, inner_path, *args, **kwargs): return self.mergerFuncWrapper("actionFileNeed", to, inner_path, *args, **kwargs) def actionOptionalFileInfo(self, to, inner_path, *args, **kwargs): return self.mergerFuncWrapper("actionOptionalFileInfo", to, inner_path, *args, **kwargs) def actionOptionalFileDelete(self, to, inner_path, *args, **kwargs): return self.mergerFuncWrapper("actionOptionalFileDelete", to, inner_path, *args, **kwargs) def actionBigfileUploadInit(self, to, inner_path, *args, **kwargs): back = self.mergerFuncWrapper("actionBigfileUploadInit", to, inner_path, *args, **kwargs) if inner_path.startswith("merged-"): merged_address, merged_inner_path = checkMergerPath(self.site.address, inner_path) back["inner_path"] = "merged-%s/%s/%s" % (merged_db[merged_address], merged_address, back["inner_path"]) return back # Add support merger sites for file commands with privatekey parameter def mergerFuncWrapperWithPrivatekey(self, func_name, to, privatekey, inner_path, *args, **kwargs): func = getattr(super(UiWebsocketPlugin, self), func_name) if inner_path.startswith("merged-"): merged_address, merged_inner_path = checkMergerPath(self.site.address, inner_path) merged_site = self.server.sites.get(merged_address) # Set the same cert for merged site merger_cert = self.user.getSiteData(self.site.address).get("cert") if merger_cert: self.user.setCert(merged_address, merger_cert) site_before = self.site # Save to be able to change it back after we ran the command self.site = merged_site # Change the site to the merged one try: back = func(to, privatekey, merged_inner_path, *args, **kwargs) finally: self.site = site_before # Change back to original site return back else: return func(to, privatekey, inner_path, *args, **kwargs) def actionSiteSign(self, to, privatekey=None, inner_path="content.json", *args, **kwargs): return self.mergerFuncWrapperWithPrivatekey("actionSiteSign", to, privatekey, inner_path, *args, **kwargs) def actionSitePublish(self, to, privatekey=None, inner_path="content.json", *args, **kwargs): return self.mergerFuncWrapperWithPrivatekey("actionSitePublish", to, privatekey, inner_path, *args, **kwargs) def actionPermissionAdd(self, to, permission): super(UiWebsocketPlugin, self).actionPermissionAdd(to, permission) if permission.startswith("Merger"): self.site.storage.rebuildDb() def actionPermissionDetails(self, to, permission): if not permission.startswith("Merger"): return super(UiWebsocketPlugin, self).actionPermissionDetails(to, permission) merger_type = permission.replace("Merger:", "") if not re.match("^[A-Za-z0-9-]+$", merger_type): raise Exception("Invalid merger_type: %s" % merger_type) merged_sites = [] for address, merged_type in merged_db.items(): if merged_type != merger_type: continue site = self.server.sites.get(address) try: merged_sites.append(site.content_manager.contents.get("content.json").get("title", address)) except Exception: merged_sites.append(address) details = _["Read and write permissions to sites with merged type of %s "] % merger_type details += _["(%s sites)"] % len(merged_sites) details += "
%s
" % ", ".join(merged_sites) self.response(to, details) @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object): # Allow to load merged site files using /merged-ZeroMe/address/file.jpg def parsePath(self, path): path_parts = super(UiRequestPlugin, self).parsePath(path) if "merged-" not in path: # Optimization return path_parts path_parts["address"], path_parts["inner_path"] = checkMergerPath(path_parts["address"], path_parts["inner_path"]) return path_parts @PluginManager.registerTo("SiteStorage") class SiteStoragePlugin(object): # Also rebuild from merged sites def getDbFiles(self): merger_types = merger_db.get(self.site.address) # First return the site's own db files for item in super(SiteStoragePlugin, self).getDbFiles(): yield item # Not a merger site, that's all if not merger_types: return merged_sites = [ site_manager.sites[address] for address, merged_type in merged_db.items() if merged_type in merger_types ] found = 0 for merged_site in merged_sites: self.log.debug("Loading merged site: %s" % merged_site) merged_type = merged_db[merged_site.address] for content_inner_path, content in merged_site.content_manager.contents.items(): # content.json file itself if merged_site.storage.isFile(content_inner_path): # Missing content.json file merged_inner_path = "merged-%s/%s/%s" % (merged_type, merged_site.address, content_inner_path) yield merged_inner_path, merged_site.storage.getPath(content_inner_path) else: merged_site.log.error("[MISSING] %s" % content_inner_path) # Data files in content.json content_inner_path_dir = helper.getDirname(content_inner_path) # Content.json dir relative to site for file_relative_path in list(content.get("files", {}).keys()) + list(content.get("files_optional", {}).keys()): if not file_relative_path.endswith(".json"): continue # We only interesed in json files file_inner_path = content_inner_path_dir + file_relative_path # File Relative to site dir file_inner_path = file_inner_path.strip("/") # Strip leading / if merged_site.storage.isFile(file_inner_path): merged_inner_path = "merged-%s/%s/%s" % (merged_type, merged_site.address, file_inner_path) yield merged_inner_path, merged_site.storage.getPath(file_inner_path) else: merged_site.log.error("[MISSING] %s" % file_inner_path) found += 1 if found % 100 == 0: time.sleep(0.001) # Context switch to avoid UI block # Also notice merger sites on a merged site file change def onUpdated(self, inner_path, file=None): super(SiteStoragePlugin, self).onUpdated(inner_path, file) merged_type = merged_db.get(self.site.address) for merger_site in merged_to_merger.get(self.site.address, []): if merger_site.address == self.site.address: # Avoid infinite loop continue virtual_path = "merged-%s/%s/%s" % (merged_type, self.site.address, inner_path) if inner_path.endswith(".json"): if file is not None: merger_site.storage.onUpdated(virtual_path, file=file) else: merger_site.storage.onUpdated(virtual_path, file=self.open(inner_path)) else: merger_site.storage.onUpdated(virtual_path) @PluginManager.registerTo("Site") class SitePlugin(object): def fileDone(self, inner_path): super(SitePlugin, self).fileDone(inner_path) for merger_site in merged_to_merger.get(self.address, []): if merger_site.address == self.address: continue for ws in merger_site.websockets: ws.event("siteChanged", self, {"event": ["file_done", inner_path]}) def fileFailed(self, inner_path): super(SitePlugin, self).fileFailed(inner_path) for merger_site in merged_to_merger.get(self.address, []): if merger_site.address == self.address: continue for ws in merger_site.websockets: ws.event("siteChanged", self, {"event": ["file_failed", inner_path]}) @PluginManager.registerTo("SiteManager") class SiteManagerPlugin(object): # Update merger site for site types def updateMergerSites(self): global merger_db, merged_db, merged_to_merger, site_manager s = time.time() merger_db_new = {} merged_db_new = {} merged_to_merger_new = {} site_manager = self if not self.sites: return for site in self.sites.values(): # Update merged sites try: merged_type = site.content_manager.contents.get("content.json", {}).get("merged_type") except Exception as err: self.log.error("Error loading site %s: %s" % (site.address, Debug.formatException(err))) continue if merged_type: merged_db_new[site.address] = merged_type # Update merger sites for permission in site.settings["permissions"]: if not permission.startswith("Merger:"): continue if merged_type: self.log.error( "Removing permission %s from %s: Merger and merged at the same time." % (permission, site.address) ) site.settings["permissions"].remove(permission) continue merger_type = permission.replace("Merger:", "") if site.address not in merger_db_new: merger_db_new[site.address] = [] merger_db_new[site.address].append(merger_type) site_manager.sites[site.address] = site # Update merged to merger if merged_type: for merger_site in self.sites.values(): if "Merger:" + merged_type in merger_site.settings["permissions"]: if site.address not in merged_to_merger_new: merged_to_merger_new[site.address] = [] merged_to_merger_new[site.address].append(merger_site) # Update globals merger_db = merger_db_new merged_db = merged_db_new merged_to_merger = merged_to_merger_new self.log.debug("Updated merger sites in %.3fs" % (time.time() - s)) def load(self, *args, **kwags): super(SiteManagerPlugin, self).load(*args, **kwags) self.updateMergerSites() def saveDelayed(self, *args, **kwags): super(SiteManagerPlugin, self).saveDelayed(*args, **kwags) self.updateMergerSites() ================================================ FILE: plugins/MergerSite/__init__.py ================================================ from . import MergerSitePlugin ================================================ FILE: plugins/MergerSite/languages/es.json ================================================ { "Add %s new site?": "¿Agregar %s nuevo sitio?", "Added %s new site": "Sitio %s agregado", "Site deleted: %s": "Sitio removido: %s" } ================================================ FILE: plugins/MergerSite/languages/fr.json ================================================ { "Add %s new site?": "Ajouter le site %s ?", "Added %s new site": "Site %s ajouté", "Site deleted: %s": "Site %s supprimé" } ================================================ FILE: plugins/MergerSite/languages/hu.json ================================================ { "Add %s new site?": "Új oldal hozzáadása: %s?", "Added %s new site": "Új oldal hozzáadva: %s", "Site deleted: %s": "Oldal törölve: %s" } ================================================ FILE: plugins/MergerSite/languages/it.json ================================================ { "Add %s new site?": "Aggiungere %s nuovo sito ?", "Added %s new site": "Sito %s aggiunto", "Site deleted: %s": "Sito %s eliminato" } ================================================ FILE: plugins/MergerSite/languages/jp.json ================================================ { "Add %s new site?": "サイト: %s を追加しますか?", "Added %s new site": "サイト: %s を追加しました", "Site deleted: %s": "サイト: %s を削除しました" } ================================================ FILE: plugins/MergerSite/languages/pt-br.json ================================================ { "Add %s new site?": "Adicionar %s novo site?", "Added %s new site": "Site %s adicionado", "Site deleted: %s": "Site removido: %s" } ================================================ FILE: plugins/MergerSite/languages/tr.json ================================================ { "Add %s new site?": "%s sitesi eklensin mi?", "Added %s new site": "%s sitesi eklendi", "Site deleted: %s": "%s sitesi silindi" } ================================================ FILE: plugins/MergerSite/languages/zh-tw.json ================================================ { "Add %s new site?": "添加新網站: %s?", "Added %s new site": "已添加到新網站:%s", "Site deleted: %s": "網站已刪除:%s" } ================================================ FILE: plugins/MergerSite/languages/zh.json ================================================ { "Add %s new site?": "添加新站点: %s?", "Added %s new site": "已添加到新站点:%s", "Site deleted: %s": "站点已删除:%s" } ================================================ FILE: plugins/Newsfeed/NewsfeedPlugin.py ================================================ import time import re from Plugin import PluginManager from Db.DbQuery import DbQuery from Debug import Debug from util import helper from util.Flag import flag @PluginManager.registerTo("UiWebsocket") class UiWebsocketPlugin(object): def formatSiteInfo(self, site, create_user=True): site_info = super(UiWebsocketPlugin, self).formatSiteInfo(site, create_user=create_user) feed_following = self.user.sites.get(site.address, {}).get("follow", None) if feed_following == None: site_info["feed_follow_num"] = None else: site_info["feed_follow_num"] = len(feed_following) return site_info def actionFeedFollow(self, to, feeds): self.user.setFeedFollow(self.site.address, feeds) self.user.save() self.response(to, "ok") def actionFeedListFollow(self, to): feeds = self.user.sites.get(self.site.address, {}).get("follow", {}) self.response(to, feeds) @flag.admin def actionFeedQuery(self, to, limit=10, day_limit=3): from Site import SiteManager rows = [] stats = [] total_s = time.time() num_sites = 0 for address, site_data in list(self.user.sites.items()): feeds = site_data.get("follow") if not feeds: continue if type(feeds) is not dict: self.log.debug("Invalid feed for site %s" % address) continue num_sites += 1 for name, query_set in feeds.items(): site = SiteManager.site_manager.get(address) if not site or not site.storage.has_db: continue s = time.time() try: query_raw, params = query_set query_parts = re.split(r"UNION(?:\s+ALL|)", query_raw) for i, query_part in enumerate(query_parts): db_query = DbQuery(query_part) if day_limit: where = " WHERE %s > strftime('%%s', 'now', '-%s day')" % (db_query.fields.get("date_added", "date_added"), day_limit) if "WHERE" in query_part: query_part = re.sub("WHERE (.*?)(?=$| GROUP BY)", where+" AND (\\1)", query_part) else: query_part += where query_parts[i] = query_part query = " UNION ".join(query_parts) if ":params" in query: query_params = map(helper.sqlquote, params) query = query.replace(":params", ",".join(query_params)) res = site.storage.query(query + " ORDER BY date_added DESC LIMIT %s" % limit) except Exception as err: # Log error self.log.error("%s feed query %s error: %s" % (address, name, Debug.formatException(err))) stats.append({"site": site.address, "feed_name": name, "error": str(err)}) continue for row in res: row = dict(row) if not isinstance(row["date_added"], (int, float, complex)): self.log.debug("Invalid date_added from site %s: %r" % (address, row["date_added"])) continue if row["date_added"] > 1000000000000: # Formatted as millseconds row["date_added"] = row["date_added"] / 1000 if "date_added" not in row or row["date_added"] > time.time() + 120: self.log.debug("Newsfeed item from the future from from site %s" % address) continue # Feed item is in the future, skip it row["site"] = address row["feed_name"] = name rows.append(row) stats.append({"site": site.address, "feed_name": name, "taken": round(time.time() - s, 3)}) time.sleep(0.001) return self.response(to, {"rows": rows, "stats": stats, "num": len(rows), "sites": num_sites, "taken": round(time.time() - total_s, 3)}) def parseSearch(self, search): parts = re.split("(site|type):", search) if len(parts) > 1: # Found filter search_text = parts[0] parts = [part.strip() for part in parts] filters = dict(zip(parts[1::2], parts[2::2])) else: search_text = search filters = {} return [search_text, filters] def actionFeedSearch(self, to, search, limit=30, day_limit=30): if "ADMIN" not in self.site.settings["permissions"]: return self.response(to, "FeedSearch not allowed") from Site import SiteManager rows = [] stats = [] num_sites = 0 total_s = time.time() search_text, filters = self.parseSearch(search) for address, site in SiteManager.site_manager.list().items(): if not site.storage.has_db: continue if "site" in filters: if filters["site"].lower() not in [site.address, site.content_manager.contents["content.json"].get("title").lower()]: continue if site.storage.db: # Database loaded feeds = site.storage.db.schema.get("feeds") else: try: feeds = site.storage.loadJson("dbschema.json").get("feeds") except: continue if not feeds: continue num_sites += 1 for name, query in feeds.items(): s = time.time() try: db_query = DbQuery(query) params = [] # Filters if search_text: db_query.wheres.append("(%s LIKE ? OR %s LIKE ?)" % (db_query.fields["body"], db_query.fields["title"])) search_like = "%" + search_text.replace(" ", "%") + "%" params.append(search_like) params.append(search_like) if filters.get("type") and filters["type"] not in query: continue if day_limit: db_query.wheres.append( "%s > strftime('%%s', 'now', '-%s day')" % (db_query.fields.get("date_added", "date_added"), day_limit) ) # Order db_query.parts["ORDER BY"] = "date_added DESC" db_query.parts["LIMIT"] = str(limit) res = site.storage.query(str(db_query), params) except Exception as err: self.log.error("%s feed query %s error: %s" % (address, name, Debug.formatException(err))) stats.append({"site": site.address, "feed_name": name, "error": str(err), "query": query}) continue for row in res: row = dict(row) if not row["date_added"] or row["date_added"] > time.time() + 120: continue # Feed item is in the future, skip it row["site"] = address row["feed_name"] = name rows.append(row) stats.append({"site": site.address, "feed_name": name, "taken": round(time.time() - s, 3)}) return self.response(to, {"rows": rows, "num": len(rows), "sites": num_sites, "taken": round(time.time() - total_s, 3), "stats": stats}) @PluginManager.registerTo("User") class UserPlugin(object): # Set queries that user follows def setFeedFollow(self, address, feeds): site_data = self.getSiteData(address) site_data["follow"] = feeds self.save() return site_data ================================================ FILE: plugins/Newsfeed/__init__.py ================================================ from . import NewsfeedPlugin ================================================ FILE: plugins/OptionalManager/ContentDbPlugin.py ================================================ import time import collections import itertools import re import gevent from util import helper from Plugin import PluginManager from Config import config from Debug import Debug if "content_db" not in locals().keys(): # To keep between module reloads content_db = None @PluginManager.registerTo("ContentDb") class ContentDbPlugin(object): def __init__(self, *args, **kwargs): global content_db content_db = self self.filled = {} # Site addresses that already filled from content.json self.need_filling = False # file_optional table just created, fill data from content.json files self.time_peer_numbers_updated = 0 self.my_optional_files = {} # Last 50 site_address/inner_path called by fileWrite (auto-pinning these files) self.optional_files = collections.defaultdict(dict) self.optional_files_loaded = False self.timer_check_optional = helper.timer(60 * 5, self.checkOptionalLimit) super(ContentDbPlugin, self).__init__(*args, **kwargs) def getSchema(self): schema = super(ContentDbPlugin, self).getSchema() # Need file_optional table schema["tables"]["file_optional"] = { "cols": [ ["file_id", "INTEGER PRIMARY KEY UNIQUE NOT NULL"], ["site_id", "INTEGER REFERENCES site (site_id) ON DELETE CASCADE"], ["inner_path", "TEXT"], ["hash_id", "INTEGER"], ["size", "INTEGER"], ["peer", "INTEGER DEFAULT 0"], ["uploaded", "INTEGER DEFAULT 0"], ["is_downloaded", "INTEGER DEFAULT 0"], ["is_pinned", "INTEGER DEFAULT 0"], ["time_added", "INTEGER DEFAULT 0"], ["time_downloaded", "INTEGER DEFAULT 0"], ["time_accessed", "INTEGER DEFAULT 0"] ], "indexes": [ "CREATE UNIQUE INDEX file_optional_key ON file_optional (site_id, inner_path)", "CREATE INDEX is_downloaded ON file_optional (is_downloaded)" ], "schema_changed": 11 } return schema def initSite(self, site): super(ContentDbPlugin, self).initSite(site) if self.need_filling: self.fillTableFileOptional(site) def checkTables(self): changed_tables = super(ContentDbPlugin, self).checkTables() if "file_optional" in changed_tables: self.need_filling = True return changed_tables # Load optional files ending def loadFilesOptional(self): s = time.time() num = 0 total = 0 total_downloaded = 0 res = content_db.execute("SELECT site_id, inner_path, size, is_downloaded FROM file_optional") site_sizes = collections.defaultdict(lambda: collections.defaultdict(int)) for row in res: self.optional_files[row["site_id"]][row["inner_path"][-8:]] = 1 num += 1 # Update site size stats site_sizes[row["site_id"]]["size_optional"] += row["size"] if row["is_downloaded"]: site_sizes[row["site_id"]]["optional_downloaded"] += row["size"] # Site site size stats to sites.json settings site_ids_reverse = {val: key for key, val in self.site_ids.items()} for site_id, stats in site_sizes.items(): site_address = site_ids_reverse.get(site_id) if not site_address or site_address not in self.sites: self.log.error("Not found site_id: %s" % site_id) continue site = self.sites[site_address] site.settings["size_optional"] = stats["size_optional"] site.settings["optional_downloaded"] = stats["optional_downloaded"] total += stats["size_optional"] total_downloaded += stats["optional_downloaded"] self.log.info( "Loaded %s optional files: %.2fMB, downloaded: %.2fMB in %.3fs" % (num, float(total) / 1024 / 1024, float(total_downloaded) / 1024 / 1024, time.time() - s) ) if self.need_filling and self.getOptionalLimitBytes() >= 0 and self.getOptionalLimitBytes() < total_downloaded: limit_bytes = self.getOptionalLimitBytes() limit_new = round((float(total_downloaded) / 1024 / 1024 / 1024) * 1.1, 2) # Current limit + 10% self.log.info( "First startup after update and limit is smaller than downloaded files size (%.2fGB), increasing it from %.2fGB to %.2fGB" % (float(total_downloaded) / 1024 / 1024 / 1024, float(limit_bytes) / 1024 / 1024 / 1024, limit_new) ) config.saveValue("optional_limit", limit_new) config.optional_limit = str(limit_new) # Predicts if the file is optional def isOptionalFile(self, site_id, inner_path): return self.optional_files[site_id].get(inner_path[-8:]) # Fill file_optional table with optional files found in sites def fillTableFileOptional(self, site): s = time.time() site_id = self.site_ids.get(site.address) if not site_id: return False cur = self.getCursor() res = cur.execute("SELECT * FROM content WHERE size_files_optional > 0 AND site_id = %s" % site_id) num = 0 for row in res.fetchall(): content = site.content_manager.contents[row["inner_path"]] try: num += self.setContentFilesOptional(site, row["inner_path"], content, cur=cur) except Exception as err: self.log.error("Error loading %s into file_optional: %s" % (row["inner_path"], err)) cur.close() # Set my files to pinned from User import UserManager user = UserManager.user_manager.get() if not user: user = UserManager.user_manager.create() auth_address = user.getAuthAddress(site.address) res = self.execute( "UPDATE file_optional SET is_pinned = 1 WHERE site_id = :site_id AND inner_path LIKE :inner_path", {"site_id": site_id, "inner_path": "%%/%s/%%" % auth_address} ) self.log.debug( "Filled file_optional table for %s in %.3fs (loaded: %s, is_pinned: %s)" % (site.address, time.time() - s, num, res.rowcount) ) self.filled[site.address] = True def setContentFilesOptional(self, site, content_inner_path, content, cur=None): if not cur: cur = self num = 0 site_id = self.site_ids[site.address] content_inner_dir = helper.getDirname(content_inner_path) for relative_inner_path, file in content.get("files_optional", {}).items(): file_inner_path = content_inner_dir + relative_inner_path hash_id = int(file["sha512"][0:4], 16) if hash_id in site.content_manager.hashfield: is_downloaded = 1 else: is_downloaded = 0 if site.address + "/" + content_inner_dir in self.my_optional_files: is_pinned = 1 else: is_pinned = 0 cur.insertOrUpdate("file_optional", { "hash_id": hash_id, "size": int(file["size"]) }, { "site_id": site_id, "inner_path": file_inner_path }, oninsert={ "time_added": int(time.time()), "time_downloaded": int(time.time()) if is_downloaded else 0, "is_downloaded": is_downloaded, "peer": is_downloaded, "is_pinned": is_pinned }) self.optional_files[site_id][file_inner_path[-8:]] = 1 num += 1 return num def setContent(self, site, inner_path, content, size=0): super(ContentDbPlugin, self).setContent(site, inner_path, content, size=size) old_content = site.content_manager.contents.get(inner_path, {}) if (not self.need_filling or self.filled.get(site.address)) and ("files_optional" in content or "files_optional" in old_content): self.setContentFilesOptional(site, inner_path, content) # Check deleted files if old_content: old_files = old_content.get("files_optional", {}).keys() new_files = content.get("files_optional", {}).keys() content_inner_dir = helper.getDirname(inner_path) deleted = [content_inner_dir + key for key in old_files if key not in new_files] if deleted: site_id = self.site_ids[site.address] self.execute("DELETE FROM file_optional WHERE ?", {"site_id": site_id, "inner_path": deleted}) def deleteContent(self, site, inner_path): content = site.content_manager.contents.get(inner_path) if content and "files_optional" in content: site_id = self.site_ids[site.address] content_inner_dir = helper.getDirname(inner_path) optional_inner_paths = [ content_inner_dir + relative_inner_path for relative_inner_path in content.get("files_optional", {}).keys() ] self.execute("DELETE FROM file_optional WHERE ?", {"site_id": site_id, "inner_path": optional_inner_paths}) super(ContentDbPlugin, self).deleteContent(site, inner_path) def updatePeerNumbers(self): s = time.time() num_file = 0 num_updated = 0 num_site = 0 for site in list(self.sites.values()): if not site.content_manager.has_optional_files: continue if not site.isServing(): continue has_updated_hashfield = next(( peer for peer in site.peers.values() if peer.has_hashfield and peer.hashfield.time_changed > self.time_peer_numbers_updated ), None) if not has_updated_hashfield and site.content_manager.hashfield.time_changed < self.time_peer_numbers_updated: continue hashfield_peers = itertools.chain.from_iterable( peer.hashfield.storage for peer in site.peers.values() if peer.has_hashfield ) peer_nums = collections.Counter( itertools.chain( hashfield_peers, site.content_manager.hashfield ) ) site_id = self.site_ids[site.address] if not site_id: continue res = self.execute("SELECT file_id, hash_id, peer FROM file_optional WHERE ?", {"site_id": site_id}) updates = {} for row in res: peer_num = peer_nums.get(row["hash_id"], 0) if peer_num != row["peer"]: updates[row["file_id"]] = peer_num for file_id, peer_num in updates.items(): self.execute("UPDATE file_optional SET peer = ? WHERE file_id = ?", (peer_num, file_id)) num_updated += len(updates) num_file += len(peer_nums) num_site += 1 self.time_peer_numbers_updated = time.time() self.log.debug("%s/%s peer number for %s site updated in %.3fs" % (num_updated, num_file, num_site, time.time() - s)) def queryDeletableFiles(self): # First return the files with atleast 10 seeder and not accessed in last week query = """ SELECT * FROM file_optional WHERE peer > 10 AND %s ORDER BY time_accessed < %s DESC, uploaded / size """ % (self.getOptionalUsedWhere(), int(time.time() - 60 * 60 * 7)) limit_start = 0 while 1: num = 0 res = self.execute("%s LIMIT %s, 50" % (query, limit_start)) for row in res: yield row num += 1 if num < 50: break limit_start += 50 self.log.debug("queryDeletableFiles returning less-seeded files") # Then return files less seeder but still not accessed in last week query = """ SELECT * FROM file_optional WHERE peer <= 10 AND %s ORDER BY peer DESC, time_accessed < %s DESC, uploaded / size """ % (self.getOptionalUsedWhere(), int(time.time() - 60 * 60 * 7)) limit_start = 0 while 1: num = 0 res = self.execute("%s LIMIT %s, 50" % (query, limit_start)) for row in res: yield row num += 1 if num < 50: break limit_start += 50 self.log.debug("queryDeletableFiles returning everyting") # At the end return all files query = """ SELECT * FROM file_optional WHERE peer <= 10 AND %s ORDER BY peer DESC, time_accessed, uploaded / size """ % self.getOptionalUsedWhere() limit_start = 0 while 1: num = 0 res = self.execute("%s LIMIT %s, 50" % (query, limit_start)) for row in res: yield row num += 1 if num < 50: break limit_start += 50 def getOptionalLimitBytes(self): if config.optional_limit.endswith("%"): limit_percent = float(re.sub("[^0-9.]", "", config.optional_limit)) limit_bytes = helper.getFreeSpace() * (limit_percent / 100) else: limit_bytes = float(re.sub("[^0-9.]", "", config.optional_limit)) * 1024 * 1024 * 1024 return limit_bytes def getOptionalUsedWhere(self): maxsize = config.optional_limit_exclude_minsize * 1024 * 1024 query = "is_downloaded = 1 AND is_pinned = 0 AND size < %s" % maxsize # Don't delete optional files from owned sites my_site_ids = [] for address, site in self.sites.items(): if site.settings["own"]: my_site_ids.append(str(self.site_ids[address])) if my_site_ids: query += " AND site_id NOT IN (%s)" % ", ".join(my_site_ids) return query def getOptionalUsedBytes(self): size = self.execute("SELECT SUM(size) FROM file_optional WHERE %s" % self.getOptionalUsedWhere()).fetchone()[0] if not size: size = 0 return size def getOptionalNeedDelete(self, size): if config.optional_limit.endswith("%"): limit_percent = float(re.sub("[^0-9.]", "", config.optional_limit)) need_delete = size - ((helper.getFreeSpace() + size) * (limit_percent / 100)) else: need_delete = size - self.getOptionalLimitBytes() return need_delete def checkOptionalLimit(self, limit=None): if not limit: limit = self.getOptionalLimitBytes() if limit < 0: self.log.debug("Invalid limit for optional files: %s" % limit) return False size = self.getOptionalUsedBytes() need_delete = self.getOptionalNeedDelete(size) self.log.debug( "Optional size: %.1fMB/%.1fMB, Need delete: %.1fMB" % (float(size) / 1024 / 1024, float(limit) / 1024 / 1024, float(need_delete) / 1024 / 1024) ) if need_delete <= 0: return False self.updatePeerNumbers() site_ids_reverse = {val: key for key, val in self.site_ids.items()} deleted_file_ids = [] for row in self.queryDeletableFiles(): site_address = site_ids_reverse.get(row["site_id"]) site = self.sites.get(site_address) if not site: self.log.error("No site found for id: %s" % row["site_id"]) continue site.log.debug("Deleting %s %.3f MB left" % (row["inner_path"], float(need_delete) / 1024 / 1024)) deleted_file_ids.append(row["file_id"]) try: site.content_manager.optionalRemoved(row["inner_path"], row["hash_id"], row["size"]) site.storage.delete(row["inner_path"]) need_delete -= row["size"] except Exception as err: site.log.error("Error deleting %s: %s" % (row["inner_path"], err)) if need_delete <= 0: break cur = self.getCursor() for file_id in deleted_file_ids: cur.execute("UPDATE file_optional SET is_downloaded = 0, is_pinned = 0, peer = peer - 1 WHERE ?", {"file_id": file_id}) cur.close() @PluginManager.registerTo("SiteManager") class SiteManagerPlugin(object): def load(self, *args, **kwargs): back = super(SiteManagerPlugin, self).load(*args, **kwargs) if self.sites and not content_db.optional_files_loaded and content_db.conn: content_db.optional_files_loaded = True content_db.loadFilesOptional() return back ================================================ FILE: plugins/OptionalManager/OptionalManagerPlugin.py ================================================ import time import re import collections import gevent from util import helper from Plugin import PluginManager from . import ContentDbPlugin # We can only import plugin host clases after the plugins are loaded @PluginManager.afterLoad def importPluginnedClasses(): global config from Config import config def processAccessLog(): global access_log if access_log: content_db = ContentDbPlugin.content_db if not content_db.conn: return False s = time.time() access_log_prev = access_log access_log = collections.defaultdict(dict) now = int(time.time()) num = 0 for site_id in access_log_prev: content_db.execute( "UPDATE file_optional SET time_accessed = %s WHERE ?" % now, {"site_id": site_id, "inner_path": list(access_log_prev[site_id].keys())} ) num += len(access_log_prev[site_id]) content_db.log.debug("Inserted %s web request stat in %.3fs" % (num, time.time() - s)) def processRequestLog(): global request_log if request_log: content_db = ContentDbPlugin.content_db if not content_db.conn: return False s = time.time() request_log_prev = request_log request_log = collections.defaultdict(lambda: collections.defaultdict(int)) # {site_id: {inner_path1: 1, inner_path2: 1...}} num = 0 for site_id in request_log_prev: for inner_path, uploaded in request_log_prev[site_id].items(): content_db.execute( "UPDATE file_optional SET uploaded = uploaded + %s WHERE ?" % uploaded, {"site_id": site_id, "inner_path": inner_path} ) num += 1 content_db.log.debug("Inserted %s file request stat in %.3fs" % (num, time.time() - s)) if "access_log" not in locals().keys(): # To keep between module reloads access_log = collections.defaultdict(dict) # {site_id: {inner_path1: 1, inner_path2: 1...}} request_log = collections.defaultdict(lambda: collections.defaultdict(int)) # {site_id: {inner_path1: 1, inner_path2: 1...}} helper.timer(61, processAccessLog) helper.timer(60, processRequestLog) @PluginManager.registerTo("ContentManager") class ContentManagerPlugin(object): def __init__(self, *args, **kwargs): self.cache_is_pinned = {} super(ContentManagerPlugin, self).__init__(*args, **kwargs) def optionalDownloaded(self, inner_path, hash_id, size=None, own=False): if "|" in inner_path: # Big file piece file_inner_path, file_range = inner_path.split("|") else: file_inner_path = inner_path self.contents.db.executeDelayed( "UPDATE file_optional SET time_downloaded = :now, is_downloaded = 1, peer = peer + 1 WHERE site_id = :site_id AND inner_path = :inner_path AND is_downloaded = 0", {"now": int(time.time()), "site_id": self.contents.db.site_ids[self.site.address], "inner_path": file_inner_path} ) return super(ContentManagerPlugin, self).optionalDownloaded(inner_path, hash_id, size, own) def optionalRemoved(self, inner_path, hash_id, size=None): res = self.contents.db.execute( "UPDATE file_optional SET is_downloaded = 0, is_pinned = 0, peer = peer - 1 WHERE site_id = :site_id AND inner_path = :inner_path AND is_downloaded = 1", {"site_id": self.contents.db.site_ids[self.site.address], "inner_path": inner_path} ) if res.rowcount > 0: back = super(ContentManagerPlugin, self).optionalRemoved(inner_path, hash_id, size) # Re-add to hashfield if we have other file with the same hash_id if self.isDownloaded(hash_id=hash_id, force_check_db=True): self.hashfield.appendHashId(hash_id) else: back = False self.cache_is_pinned = {} return back def optionalRenamed(self, inner_path_old, inner_path_new): back = super(ContentManagerPlugin, self).optionalRenamed(inner_path_old, inner_path_new) self.cache_is_pinned = {} self.contents.db.execute( "UPDATE file_optional SET inner_path = :inner_path_new WHERE site_id = :site_id AND inner_path = :inner_path_old", {"site_id": self.contents.db.site_ids[self.site.address], "inner_path_old": inner_path_old, "inner_path_new": inner_path_new} ) return back def isDownloaded(self, inner_path=None, hash_id=None, force_check_db=False): if hash_id and not force_check_db and hash_id not in self.hashfield: return False if inner_path: res = self.contents.db.execute( "SELECT is_downloaded FROM file_optional WHERE site_id = :site_id AND inner_path = :inner_path LIMIT 1", {"site_id": self.contents.db.site_ids[self.site.address], "inner_path": inner_path} ) else: res = self.contents.db.execute( "SELECT is_downloaded FROM file_optional WHERE site_id = :site_id AND hash_id = :hash_id AND is_downloaded = 1 LIMIT 1", {"site_id": self.contents.db.site_ids[self.site.address], "hash_id": hash_id} ) row = res.fetchone() if row and row["is_downloaded"]: return True else: return False def isPinned(self, inner_path): if inner_path in self.cache_is_pinned: self.site.log.debug("Cached is pinned: %s" % inner_path) return self.cache_is_pinned[inner_path] res = self.contents.db.execute( "SELECT is_pinned FROM file_optional WHERE site_id = :site_id AND inner_path = :inner_path LIMIT 1", {"site_id": self.contents.db.site_ids[self.site.address], "inner_path": inner_path} ) row = res.fetchone() if row and row[0]: is_pinned = True else: is_pinned = False self.cache_is_pinned[inner_path] = is_pinned self.site.log.debug("Cache set is pinned: %s %s" % (inner_path, is_pinned)) return is_pinned def setPin(self, inner_path, is_pinned): content_db = self.contents.db site_id = content_db.site_ids[self.site.address] content_db.execute("UPDATE file_optional SET is_pinned = %d WHERE ?" % is_pinned, {"site_id": site_id, "inner_path": inner_path}) self.cache_is_pinned = {} def optionalDelete(self, inner_path): if self.isPinned(inner_path): self.site.log.debug("Skip deleting pinned optional file: %s" % inner_path) return False else: return super(ContentManagerPlugin, self).optionalDelete(inner_path) @PluginManager.registerTo("WorkerManager") class WorkerManagerPlugin(object): def doneTask(self, task): super(WorkerManagerPlugin, self).doneTask(task) if task["optional_hash_id"] and not self.tasks: # Execute delayed queries immedietly after tasks finished ContentDbPlugin.content_db.processDelayed() @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object): def parsePath(self, path): global access_log path_parts = super(UiRequestPlugin, self).parsePath(path) if path_parts: site_id = ContentDbPlugin.content_db.site_ids.get(path_parts["request_address"]) if site_id: if ContentDbPlugin.content_db.isOptionalFile(site_id, path_parts["inner_path"]): access_log[site_id][path_parts["inner_path"]] = 1 return path_parts @PluginManager.registerTo("FileRequest") class FileRequestPlugin(object): def actionGetFile(self, params): stats = super(FileRequestPlugin, self).actionGetFile(params) self.recordFileRequest(params["site"], params["inner_path"], stats) return stats def actionStreamFile(self, params): stats = super(FileRequestPlugin, self).actionStreamFile(params) self.recordFileRequest(params["site"], params["inner_path"], stats) return stats def recordFileRequest(self, site_address, inner_path, stats): if not stats: # Only track the last request of files return False site_id = ContentDbPlugin.content_db.site_ids[site_address] if site_id and ContentDbPlugin.content_db.isOptionalFile(site_id, inner_path): request_log[site_id][inner_path] += stats["bytes_sent"] @PluginManager.registerTo("Site") class SitePlugin(object): def isDownloadable(self, inner_path): is_downloadable = super(SitePlugin, self).isDownloadable(inner_path) if is_downloadable: return is_downloadable for path in self.settings.get("optional_help", {}).keys(): if inner_path.startswith(path): return True return False def fileForgot(self, inner_path): if "|" in inner_path and self.content_manager.isPinned(re.sub(r"\|.*", "", inner_path)): self.log.debug("File %s is pinned, no fileForgot" % inner_path) return False else: return super(SitePlugin, self).fileForgot(inner_path) def fileDone(self, inner_path): if "|" in inner_path and self.bad_files.get(inner_path, 0) > 5: # Idle optional file done inner_path_file = re.sub(r"\|.*", "", inner_path) num_changed = 0 for key, val in self.bad_files.items(): if key.startswith(inner_path_file) and val > 1: self.bad_files[key] = 1 num_changed += 1 self.log.debug("Idle optional file piece done, changed retry number of %s pieces." % num_changed) if num_changed: gevent.spawn(self.retryBadFiles) return super(SitePlugin, self).fileDone(inner_path) @PluginManager.registerTo("ConfigPlugin") class ConfigPlugin(object): def createArguments(self): group = self.parser.add_argument_group("OptionalManager plugin") group.add_argument('--optional_limit', help='Limit total size of optional files', default="10%", metavar="GB or free space %") group.add_argument('--optional_limit_exclude_minsize', help='Exclude files larger than this limit from optional size limit calculation', default=20, metavar="MB", type=int) return super(ConfigPlugin, self).createArguments() ================================================ FILE: plugins/OptionalManager/Test/TestOptionalManager.py ================================================ import copy import pytest @pytest.mark.usefixtures("resetSettings") class TestOptionalManager: def testDbFill(self, site): contents = site.content_manager.contents assert len(site.content_manager.hashfield) > 0 assert contents.db.execute("SELECT COUNT(*) FROM file_optional WHERE is_downloaded = 1").fetchone()[0] == len(site.content_manager.hashfield) def testSetContent(self, site): contents = site.content_manager.contents # Add new file new_content = copy.deepcopy(contents["content.json"]) new_content["files_optional"]["testfile"] = { "size": 1234, "sha512": "aaaabbbbcccc" } num_optional_files_before = contents.db.execute("SELECT COUNT(*) FROM file_optional").fetchone()[0] contents["content.json"] = new_content assert contents.db.execute("SELECT COUNT(*) FROM file_optional").fetchone()[0] > num_optional_files_before # Remove file new_content = copy.deepcopy(contents["content.json"]) del new_content["files_optional"]["testfile"] num_optional_files_before = contents.db.execute("SELECT COUNT(*) FROM file_optional").fetchone()[0] contents["content.json"] = new_content assert contents.db.execute("SELECT COUNT(*) FROM file_optional").fetchone()[0] < num_optional_files_before def testDeleteContent(self, site): contents = site.content_manager.contents num_optional_files_before = contents.db.execute("SELECT COUNT(*) FROM file_optional").fetchone()[0] del contents["content.json"] assert contents.db.execute("SELECT COUNT(*) FROM file_optional").fetchone()[0] < num_optional_files_before def testVerifyFiles(self, site): contents = site.content_manager.contents # Add new file new_content = copy.deepcopy(contents["content.json"]) new_content["files_optional"]["testfile"] = { "size": 1234, "sha512": "aaaabbbbcccc" } contents["content.json"] = new_content file_row = contents.db.execute("SELECT * FROM file_optional WHERE inner_path = 'testfile'").fetchone() assert not file_row["is_downloaded"] # Write file from outside of ZeroNet site.storage.open("testfile", "wb").write(b"A" * 1234) # For quick check hash does not matter only file size hashfield_len_before = len(site.content_manager.hashfield) site.storage.verifyFiles(quick_check=True) assert len(site.content_manager.hashfield) == hashfield_len_before + 1 file_row = contents.db.execute("SELECT * FROM file_optional WHERE inner_path = 'testfile'").fetchone() assert file_row["is_downloaded"] # Delete file outside of ZeroNet site.storage.delete("testfile") site.storage.verifyFiles(quick_check=True) file_row = contents.db.execute("SELECT * FROM file_optional WHERE inner_path = 'testfile'").fetchone() assert not file_row["is_downloaded"] def testVerifyFilesSameHashId(self, site): contents = site.content_manager.contents new_content = copy.deepcopy(contents["content.json"]) # Add two files with same hashid (first 4 character) new_content["files_optional"]["testfile1"] = { "size": 1234, "sha512": "aaaabbbbcccc" } new_content["files_optional"]["testfile2"] = { "size": 2345, "sha512": "aaaabbbbdddd" } contents["content.json"] = new_content assert site.content_manager.hashfield.getHashId("aaaabbbbcccc") == site.content_manager.hashfield.getHashId("aaaabbbbdddd") # Write files from outside of ZeroNet (For quick check hash does not matter only file size) site.storage.open("testfile1", "wb").write(b"A" * 1234) site.storage.open("testfile2", "wb").write(b"B" * 2345) site.storage.verifyFiles(quick_check=True) # Make sure that both is downloaded assert site.content_manager.isDownloaded("testfile1") assert site.content_manager.isDownloaded("testfile2") assert site.content_manager.hashfield.getHashId("aaaabbbbcccc") in site.content_manager.hashfield # Delete one of the files site.storage.delete("testfile1") site.storage.verifyFiles(quick_check=True) assert not site.content_manager.isDownloaded("testfile1") assert site.content_manager.isDownloaded("testfile2") assert site.content_manager.hashfield.getHashId("aaaabbbbdddd") in site.content_manager.hashfield def testIsPinned(self, site): assert not site.content_manager.isPinned("data/img/zerotalk-upvote.png") site.content_manager.setPin("data/img/zerotalk-upvote.png", True) assert site.content_manager.isPinned("data/img/zerotalk-upvote.png") assert len(site.content_manager.cache_is_pinned) == 1 site.content_manager.cache_is_pinned = {} assert site.content_manager.isPinned("data/img/zerotalk-upvote.png") def testBigfilePieceReset(self, site): site.bad_files = { "data/fake_bigfile.mp4|0-1024": 10, "data/fake_bigfile.mp4|1024-2048": 10, "data/fake_bigfile.mp4|2048-3064": 10 } site.onFileDone("data/fake_bigfile.mp4|0-1024") assert site.bad_files["data/fake_bigfile.mp4|1024-2048"] == 1 assert site.bad_files["data/fake_bigfile.mp4|2048-3064"] == 1 def testOptionalDelete(self, site): contents = site.content_manager.contents site.content_manager.setPin("data/img/zerotalk-upvote.png", True) site.content_manager.setPin("data/img/zeroid.png", False) new_content = copy.deepcopy(contents["content.json"]) del new_content["files_optional"]["data/img/zerotalk-upvote.png"] del new_content["files_optional"]["data/img/zeroid.png"] assert site.storage.isFile("data/img/zerotalk-upvote.png") assert site.storage.isFile("data/img/zeroid.png") site.storage.writeJson("content.json", new_content) site.content_manager.loadContent("content.json", force=True) assert not site.storage.isFile("data/img/zeroid.png") assert site.storage.isFile("data/img/zerotalk-upvote.png") def testOptionalRename(self, site): contents = site.content_manager.contents site.content_manager.setPin("data/img/zerotalk-upvote.png", True) new_content = copy.deepcopy(contents["content.json"]) new_content["files_optional"]["data/img/zerotalk-upvote-new.png"] = new_content["files_optional"]["data/img/zerotalk-upvote.png"] del new_content["files_optional"]["data/img/zerotalk-upvote.png"] assert site.storage.isFile("data/img/zerotalk-upvote.png") assert site.content_manager.isPinned("data/img/zerotalk-upvote.png") site.storage.writeJson("content.json", new_content) site.content_manager.loadContent("content.json", force=True) assert not site.storage.isFile("data/img/zerotalk-upvote.png") assert not site.content_manager.isPinned("data/img/zerotalk-upvote.png") assert site.content_manager.isPinned("data/img/zerotalk-upvote-new.png") assert site.storage.isFile("data/img/zerotalk-upvote-new.png") ================================================ FILE: plugins/OptionalManager/Test/conftest.py ================================================ from src.Test.conftest import * ================================================ FILE: plugins/OptionalManager/Test/pytest.ini ================================================ [pytest] python_files = Test*.py addopts = -rsxX -v --durations=6 markers = webtest: mark a test as a webtest. ================================================ FILE: plugins/OptionalManager/UiWebsocketPlugin.py ================================================ import re import time import html import os import gevent from Plugin import PluginManager from Config import config from util import helper from util.Flag import flag from Translate import Translate plugin_dir = os.path.dirname(__file__) if "_" not in locals(): _ = Translate(plugin_dir + "/languages/") bigfile_sha512_cache = {} @PluginManager.registerTo("UiWebsocket") class UiWebsocketPlugin(object): def __init__(self, *args, **kwargs): self.time_peer_numbers_updated = 0 super(UiWebsocketPlugin, self).__init__(*args, **kwargs) def actionSiteSign(self, to, privatekey=None, inner_path="content.json", *args, **kwargs): # Add file to content.db and set it as pinned content_db = self.site.content_manager.contents.db content_inner_dir = helper.getDirname(inner_path) content_db.my_optional_files[self.site.address + "/" + content_inner_dir] = time.time() if len(content_db.my_optional_files) > 50: # Keep only last 50 oldest_key = min( iter(content_db.my_optional_files.keys()), key=(lambda key: content_db.my_optional_files[key]) ) del content_db.my_optional_files[oldest_key] return super(UiWebsocketPlugin, self).actionSiteSign(to, privatekey, inner_path, *args, **kwargs) def updatePeerNumbers(self): self.site.updateHashfield() content_db = self.site.content_manager.contents.db content_db.updatePeerNumbers() self.site.updateWebsocket(peernumber_updated=True) def addBigfileInfo(self, row): global bigfile_sha512_cache content_db = self.site.content_manager.contents.db site = content_db.sites[row["address"]] if not site.settings.get("has_bigfile"): return False file_key = row["address"] + "/" + row["inner_path"] sha512 = bigfile_sha512_cache.get(file_key) file_info = None if not sha512: file_info = site.content_manager.getFileInfo(row["inner_path"]) if not file_info or not file_info.get("piece_size"): return False sha512 = file_info["sha512"] bigfile_sha512_cache[file_key] = sha512 if sha512 in site.storage.piecefields: piecefield = site.storage.piecefields[sha512].tobytes() else: piecefield = None if piecefield: row["pieces"] = len(piecefield) row["pieces_downloaded"] = piecefield.count(b"\x01") row["downloaded_percent"] = 100 * row["pieces_downloaded"] / row["pieces"] if row["pieces_downloaded"]: if row["pieces"] == row["pieces_downloaded"]: row["bytes_downloaded"] = row["size"] else: if not file_info: file_info = site.content_manager.getFileInfo(row["inner_path"]) row["bytes_downloaded"] = row["pieces_downloaded"] * file_info.get("piece_size", 0) else: row["bytes_downloaded"] = 0 row["is_downloading"] = bool(next((inner_path for inner_path in site.bad_files if inner_path.startswith(row["inner_path"])), False)) # Add leech / seed stats row["peer_seed"] = 0 row["peer_leech"] = 0 for peer in site.peers.values(): if not peer.time_piecefields_updated or sha512 not in peer.piecefields: continue peer_piecefield = peer.piecefields[sha512].tobytes() if not peer_piecefield: continue if peer_piecefield == b"\x01" * len(peer_piecefield): row["peer_seed"] += 1 else: row["peer_leech"] += 1 # Add myself if piecefield: if row["pieces_downloaded"] == row["pieces"]: row["peer_seed"] += 1 else: row["peer_leech"] += 1 return True # Optional file functions def actionOptionalFileList(self, to, address=None, orderby="time_downloaded DESC", limit=10, filter="downloaded", filter_inner_path=None): if not address: address = self.site.address # Update peer numbers if necessary content_db = self.site.content_manager.contents.db if time.time() - content_db.time_peer_numbers_updated > 60 * 1 and time.time() - self.time_peer_numbers_updated > 60 * 5: # Start in new thread to avoid blocking self.time_peer_numbers_updated = time.time() gevent.spawn(self.updatePeerNumbers) if address == "all" and "ADMIN" not in self.permissions: return self.response(to, {"error": "Forbidden"}) if not self.hasSitePermission(address): return self.response(to, {"error": "Forbidden"}) if not all([re.match("^[a-z_*/+-]+( DESC| ASC|)$", part.strip()) for part in orderby.split(",")]): return self.response(to, "Invalid order_by") if type(limit) != int: return self.response(to, "Invalid limit") back = [] content_db = self.site.content_manager.contents.db wheres = {} wheres_raw = [] if "bigfile" in filter: wheres["size >"] = 1024 * 1024 * 1 if "downloaded" in filter: wheres_raw.append("(is_downloaded = 1 OR is_pinned = 1)") if "pinned" in filter: wheres["is_pinned"] = 1 if filter_inner_path: wheres["inner_path__like"] = filter_inner_path if address == "all": join = "LEFT JOIN site USING (site_id)" else: wheres["site_id"] = content_db.site_ids[address] join = "" if wheres_raw: query_wheres_raw = "AND" + " AND ".join(wheres_raw) else: query_wheres_raw = "" query = "SELECT * FROM file_optional %s WHERE ? %s ORDER BY %s LIMIT %s" % (join, query_wheres_raw, orderby, limit) for row in content_db.execute(query, wheres): row = dict(row) if address != "all": row["address"] = address if row["size"] > 1024 * 1024: has_bigfile_info = self.addBigfileInfo(row) else: has_bigfile_info = False if not has_bigfile_info and "bigfile" in filter: continue if not has_bigfile_info: if row["is_downloaded"]: row["bytes_downloaded"] = row["size"] row["downloaded_percent"] = 100 else: row["bytes_downloaded"] = 0 row["downloaded_percent"] = 0 back.append(row) self.response(to, back) def actionOptionalFileInfo(self, to, inner_path): content_db = self.site.content_manager.contents.db site_id = content_db.site_ids[self.site.address] # Update peer numbers if necessary if time.time() - content_db.time_peer_numbers_updated > 60 * 1 and time.time() - self.time_peer_numbers_updated > 60 * 5: # Start in new thread to avoid blocking self.time_peer_numbers_updated = time.time() gevent.spawn(self.updatePeerNumbers) query = "SELECT * FROM file_optional WHERE site_id = :site_id AND inner_path = :inner_path LIMIT 1" res = content_db.execute(query, {"site_id": site_id, "inner_path": inner_path}) row = next(res, None) if row: row = dict(row) if row["size"] > 1024 * 1024: row["address"] = self.site.address self.addBigfileInfo(row) self.response(to, row) else: self.response(to, None) def setPin(self, inner_path, is_pinned, address=None): if not address: address = self.site.address if not self.hasSitePermission(address): return {"error": "Forbidden"} site = self.server.sites[address] site.content_manager.setPin(inner_path, is_pinned) return "ok" @flag.no_multiuser def actionOptionalFilePin(self, to, inner_path, address=None): if type(inner_path) is not list: inner_path = [inner_path] back = self.setPin(inner_path, 1, address) num_file = len(inner_path) if back == "ok": if num_file == 1: self.cmd("notification", ["done", _["Pinned %s"] % html.escape(helper.getFilename(inner_path[0])), 5000]) else: self.cmd("notification", ["done", _["Pinned %s files"] % num_file, 5000]) self.response(to, back) @flag.no_multiuser def actionOptionalFileUnpin(self, to, inner_path, address=None): if type(inner_path) is not list: inner_path = [inner_path] back = self.setPin(inner_path, 0, address) num_file = len(inner_path) if back == "ok": if num_file == 1: self.cmd("notification", ["done", _["Removed pin from %s"] % html.escape(helper.getFilename(inner_path[0])), 5000]) else: self.cmd("notification", ["done", _["Removed pin from %s files"] % num_file, 5000]) self.response(to, back) @flag.no_multiuser def actionOptionalFileDelete(self, to, inner_path, address=None): if not address: address = self.site.address if not self.hasSitePermission(address): return self.response(to, {"error": "Forbidden"}) site = self.server.sites[address] content_db = site.content_manager.contents.db site_id = content_db.site_ids[site.address] res = content_db.execute("SELECT * FROM file_optional WHERE ? LIMIT 1", {"site_id": site_id, "inner_path": inner_path, "is_downloaded": 1}) row = next(res, None) if not row: return self.response(to, {"error": "Not found in content.db"}) removed = site.content_manager.optionalRemoved(inner_path, row["hash_id"], row["size"]) # if not removed: # return self.response(to, {"error": "Not found in hash_id: %s" % row["hash_id"]}) content_db.execute("UPDATE file_optional SET is_downloaded = 0, is_pinned = 0, peer = peer - 1 WHERE ?", {"site_id": site_id, "inner_path": inner_path}) try: site.storage.delete(inner_path) except Exception as err: return self.response(to, {"error": "File delete error: %s" % err}) site.updateWebsocket(file_delete=inner_path) if inner_path in site.content_manager.cache_is_pinned: site.content_manager.cache_is_pinned = {} self.response(to, "ok") # Limit functions @flag.admin def actionOptionalLimitStats(self, to): back = {} back["limit"] = config.optional_limit back["used"] = self.site.content_manager.contents.db.getOptionalUsedBytes() back["free"] = helper.getFreeSpace() self.response(to, back) @flag.no_multiuser @flag.admin def actionOptionalLimitSet(self, to, limit): config.optional_limit = re.sub(r"\.0+$", "", limit) # Remove unnecessary digits from end config.saveValue("optional_limit", limit) self.response(to, "ok") # Distribute help functions def actionOptionalHelpList(self, to, address=None): if not address: address = self.site.address if not self.hasSitePermission(address): return self.response(to, {"error": "Forbidden"}) site = self.server.sites[address] self.response(to, site.settings.get("optional_help", {})) @flag.no_multiuser def actionOptionalHelp(self, to, directory, title, address=None): if not address: address = self.site.address if not self.hasSitePermission(address): return self.response(to, {"error": "Forbidden"}) site = self.server.sites[address] content_db = site.content_manager.contents.db site_id = content_db.site_ids[address] if "optional_help" not in site.settings: site.settings["optional_help"] = {} stats = content_db.execute( "SELECT COUNT(*) AS num, SUM(size) AS size FROM file_optional WHERE site_id = :site_id AND inner_path LIKE :inner_path", {"site_id": site_id, "inner_path": directory + "%"} ).fetchone() stats = dict(stats) if not stats["size"]: stats["size"] = 0 if not stats["num"]: stats["num"] = 0 self.cmd("notification", [ "done", _["You started to help distribute %s.
Directory: %s"] % (html.escape(title), html.escape(directory)), 10000 ]) site.settings["optional_help"][directory] = title self.response(to, dict(stats)) @flag.no_multiuser def actionOptionalHelpRemove(self, to, directory, address=None): if not address: address = self.site.address if not self.hasSitePermission(address): return self.response(to, {"error": "Forbidden"}) site = self.server.sites[address] try: del site.settings["optional_help"][directory] self.response(to, "ok") except Exception: self.response(to, {"error": "Not found"}) def cbOptionalHelpAll(self, to, site, value): site.settings["autodownloadoptional"] = value self.response(to, value) @flag.no_multiuser def actionOptionalHelpAll(self, to, value, address=None): if not address: address = self.site.address if not self.hasSitePermission(address): return self.response(to, {"error": "Forbidden"}) site = self.server.sites[address] if value: if "ADMIN" in self.site.settings["permissions"]: self.cbOptionalHelpAll(to, site, True) else: site_title = site.content_manager.contents["content.json"].get("title", address) self.cmd( "confirm", [ _["Help distribute all new optional files on site %s"] % html.escape(site_title), _["Yes, I want to help!"] ], lambda res: self.cbOptionalHelpAll(to, site, True) ) else: site.settings["autodownloadoptional"] = False self.response(to, False) ================================================ FILE: plugins/OptionalManager/__init__.py ================================================ from . import OptionalManagerPlugin from . import UiWebsocketPlugin ================================================ FILE: plugins/OptionalManager/languages/es.json ================================================ { "Pinned %s files": "Archivos %s fijados", "Removed pin from %s files": "Archivos %s que no estan fijados", "You started to help distribute %s.
Directory: %s": "Tu empezaste a ayudar a distribuir %s.
Directorio: %s", "Help distribute all new optional files on site %s": "Ayude a distribuir todos los archivos opcionales en el sitio %s", "Yes, I want to help!": "¡Si, yo quiero ayudar!" } ================================================ FILE: plugins/OptionalManager/languages/fr.json ================================================ { "Pinned %s files": "Fichiers %s épinglés", "Removed pin from %s files": "Fichiers %s ne sont plus épinglés", "You started to help distribute %s.
Directory: %s": "Vous avez commencé à aider à distribuer %s.
Dossier : %s", "Help distribute all new optional files on site %s": "Aider à distribuer tous les fichiers optionnels du site %s", "Yes, I want to help!": "Oui, je veux aider !" } ================================================ FILE: plugins/OptionalManager/languages/hu.json ================================================ { "Pinned %s files": "%s fájl rögzítve", "Removed pin from %s files": "%s fájl rögzítés eltávolítva", "You started to help distribute %s.
Directory: %s": "Új segítség a terjesztésben: %s.
Könyvtár: %s", "Help distribute all new optional files on site %s": "Segítség az összes új opcionális fájl terjesztésében az %s oldalon", "Yes, I want to help!": "Igen, segíteni akarok!" } ================================================ FILE: plugins/OptionalManager/languages/jp.json ================================================ { "Pinned %s files": "%s 件のファイルを固定", "Removed pin from %s files": "%s 件のファイルの固定を解除", "You started to help distribute %s.
Directory: %s": "あなたはサイト: %s の配布の援助を開始しました。
ディレクトリ: %s", "Help distribute all new optional files on site %s": "サイト: %s のすべての新しいオプションファイルの配布を援助しますか?", "Yes, I want to help!": "はい、やります!" } ================================================ FILE: plugins/OptionalManager/languages/pt-br.json ================================================ { "Pinned %s files": "Arquivos %s fixados", "Removed pin from %s files": "Arquivos %s não estão fixados", "You started to help distribute %s.
Directory: %s": "Você começou a ajudar a distribuir %s.
Pasta: %s", "Help distribute all new optional files on site %s": "Ajude a distribuir todos os novos arquivos opcionais no site %s", "Yes, I want to help!": "Sim, eu quero ajudar!" } ================================================ FILE: plugins/OptionalManager/languages/zh-tw.json ================================================ { "Pinned %s files": "已固定 %s 個檔", "Removed pin from %s files": "已解除固定 %s 個檔", "You started to help distribute %s.
Directory: %s": "你已經開始幫助分發 %s
目錄:%s", "Help distribute all new optional files on site %s": "你想要幫助分發 %s 網站的所有檔嗎?", "Yes, I want to help!": "是,我想要幫助!" } ================================================ FILE: plugins/OptionalManager/languages/zh.json ================================================ { "Pinned %s files": "已固定 %s 个文件", "Removed pin from %s files": "已解除固定 %s 个文件", "You started to help distribute %s.
Directory: %s": "您已经开始帮助分发 %s
目录:%s", "Help distribute all new optional files on site %s": "您想要帮助分发 %s 站点的所有文件吗?", "Yes, I want to help!": "是,我想要帮助!" } ================================================ FILE: plugins/PeerDb/PeerDbPlugin.py ================================================ import time import sqlite3 import random import atexit import gevent from Plugin import PluginManager @PluginManager.registerTo("ContentDb") class ContentDbPlugin(object): def __init__(self, *args, **kwargs): atexit.register(self.saveAllPeers) super(ContentDbPlugin, self).__init__(*args, **kwargs) def getSchema(self): schema = super(ContentDbPlugin, self).getSchema() schema["tables"]["peer"] = { "cols": [ ["site_id", "INTEGER REFERENCES site (site_id) ON DELETE CASCADE"], ["address", "TEXT NOT NULL"], ["port", "INTEGER NOT NULL"], ["hashfield", "BLOB"], ["reputation", "INTEGER NOT NULL"], ["time_added", "INTEGER NOT NULL"], ["time_found", "INTEGER NOT NULL"] ], "indexes": [ "CREATE UNIQUE INDEX peer_key ON peer (site_id, address, port)" ], "schema_changed": 2 } return schema def loadPeers(self, site): s = time.time() site_id = self.site_ids.get(site.address) res = self.execute("SELECT * FROM peer WHERE site_id = :site_id", {"site_id": site_id}) num = 0 num_hashfield = 0 for row in res: peer = site.addPeer(str(row["address"]), row["port"]) if not peer: # Already exist continue if row["hashfield"]: peer.hashfield.replaceFromBytes(row["hashfield"]) num_hashfield += 1 peer.time_added = row["time_added"] peer.time_found = row["time_found"] peer.reputation = row["reputation"] if row["address"].endswith(".onion"): peer.reputation = peer.reputation / 2 - 1 # Onion peers less likely working num += 1 if num_hashfield: site.content_manager.has_optional_files = True site.log.debug("%s peers (%s with hashfield) loaded in %.3fs" % (num, num_hashfield, time.time() - s)) def iteratePeers(self, site): site_id = self.site_ids.get(site.address) for key, peer in list(site.peers.items()): address, port = key.rsplit(":", 1) if peer.has_hashfield: hashfield = sqlite3.Binary(peer.hashfield.tobytes()) else: hashfield = "" yield (site_id, address, port, hashfield, peer.reputation, int(peer.time_added), int(peer.time_found)) def savePeers(self, site, spawn=False): if spawn: # Save peers every hour (+random some secs to not update very site at same time) site.greenlet_manager.spawnLater(60 * 60 + random.randint(0, 60), self.savePeers, site, spawn=True) if not site.peers: site.log.debug("Peers not saved: No peers found") return s = time.time() site_id = self.site_ids.get(site.address) cur = self.getCursor() try: cur.execute("DELETE FROM peer WHERE site_id = :site_id", {"site_id": site_id}) cur.executemany( "INSERT INTO peer (site_id, address, port, hashfield, reputation, time_added, time_found) VALUES (?, ?, ?, ?, ?, ?, ?)", self.iteratePeers(site) ) except Exception as err: site.log.error("Save peer error: %s" % err) site.log.debug("Peers saved in %.3fs" % (time.time() - s)) def initSite(self, site): super(ContentDbPlugin, self).initSite(site) site.greenlet_manager.spawnLater(0.5, self.loadPeers, site) site.greenlet_manager.spawnLater(60*60, self.savePeers, site, spawn=True) def saveAllPeers(self): for site in list(self.sites.values()): try: self.savePeers(site) except Exception as err: site.log.error("Save peer error: %s" % err) ================================================ FILE: plugins/PeerDb/__init__.py ================================================ from . import PeerDbPlugin ================================================ FILE: plugins/PeerDb/plugin_info.json ================================================ { "name": "PeerDb", "description": "Save/restore peer list on client restart.", "default": "enabled" } ================================================ FILE: plugins/Sidebar/ConsolePlugin.py ================================================ import re import logging from Plugin import PluginManager from Config import config from Debug import Debug from util import SafeRe from util.Flag import flag class WsLogStreamer(logging.StreamHandler): def __init__(self, stream_id, ui_websocket, filter): self.stream_id = stream_id self.ui_websocket = ui_websocket if filter: if not SafeRe.isSafePattern(filter): raise Exception("Not a safe prex pattern") self.filter_re = re.compile(".*" + filter) else: self.filter_re = None return super(WsLogStreamer, self).__init__() def emit(self, record): if self.ui_websocket.ws.closed: self.stop() return line = self.format(record) if self.filter_re and not self.filter_re.match(line): return False self.ui_websocket.cmd("logLineAdd", {"stream_id": self.stream_id, "lines": [line]}) def stop(self): logging.getLogger('').removeHandler(self) @PluginManager.registerTo("UiWebsocket") class UiWebsocketPlugin(object): def __init__(self, *args, **kwargs): self.log_streamers = {} return super(UiWebsocketPlugin, self).__init__(*args, **kwargs) @flag.no_multiuser @flag.admin def actionConsoleLogRead(self, to, filter=None, read_size=32 * 1024, limit=500): log_file_path = "%s/debug.log" % config.log_dir log_file = open(log_file_path, encoding="utf-8") log_file.seek(0, 2) end_pos = log_file.tell() log_file.seek(max(0, end_pos - read_size)) if log_file.tell() != 0: log_file.readline() # Partial line junk pos_start = log_file.tell() lines = [] if filter: assert SafeRe.isSafePattern(filter) filter_re = re.compile(".*" + filter) last_match = False for line in log_file: if not line.startswith("[") and last_match: # Multi-line log entry lines.append(line.replace(" ", " ")) continue if filter and not filter_re.match(line): last_match = False continue last_match = True lines.append(line) num_found = len(lines) lines = lines[-limit:] return {"lines": lines, "pos_end": log_file.tell(), "pos_start": pos_start, "num_found": num_found} def addLogStreamer(self, stream_id, filter=None): logger = WsLogStreamer(stream_id, self, filter) logger.setFormatter(logging.Formatter('[%(asctime)s] %(levelname)-8s %(name)s %(message)s')) logger.setLevel(logging.getLevelName("DEBUG")) logging.getLogger('').addHandler(logger) return logger @flag.no_multiuser @flag.admin def actionConsoleLogStream(self, to, filter=None): stream_id = to self.log_streamers[stream_id] = self.addLogStreamer(stream_id, filter) self.response(to, {"stream_id": stream_id}) @flag.no_multiuser @flag.admin def actionConsoleLogStreamRemove(self, to, stream_id): try: self.log_streamers[stream_id].stop() del self.log_streamers[stream_id] return "ok" except Exception as err: return {"error": Debug.formatException(err)} ================================================ FILE: plugins/Sidebar/SidebarPlugin.py ================================================ import re import os import html import sys import math import time import json import io import urllib import urllib.parse import gevent import util from Config import config from Plugin import PluginManager from Debug import Debug from Translate import Translate from util import helper from util.Flag import flag from .ZipStream import ZipStream plugin_dir = os.path.dirname(__file__) media_dir = plugin_dir + "/media" loc_cache = {} if "_" not in locals(): _ = Translate(plugin_dir + "/languages/") @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object): # Inject our resources to end of original file streams def actionUiMedia(self, path): if path == "/uimedia/all.js" or path == "/uimedia/all.css": # First yield the original file and header body_generator = super(UiRequestPlugin, self).actionUiMedia(path) for part in body_generator: yield part # Append our media file to the end ext = re.match(".*(js|css)$", path).group(1) plugin_media_file = "%s/all.%s" % (media_dir, ext) if config.debug: # If debugging merge *.css to all.css and *.js to all.js from Debug import DebugMedia DebugMedia.merge(plugin_media_file) if ext == "js": yield _.translateData(open(plugin_media_file).read()).encode("utf8") else: for part in self.actionFile(plugin_media_file, send_header=False): yield part elif path.startswith("/uimedia/globe/"): # Serve WebGL globe files file_name = re.match(".*/(.*)", path).group(1) plugin_media_file = "%s_globe/%s" % (media_dir, file_name) if config.debug and path.endswith("all.js"): # If debugging merge *.css to all.css and *.js to all.js from Debug import DebugMedia DebugMedia.merge(plugin_media_file) for part in self.actionFile(plugin_media_file): yield part else: for part in super(UiRequestPlugin, self).actionUiMedia(path): yield part def actionZip(self): address = self.get["address"] site = self.server.site_manager.get(address) if not site: return self.error404("Site not found") title = site.content_manager.contents.get("content.json", {}).get("title", "") filename = "%s-backup-%s.zip" % (title, time.strftime("%Y-%m-%d_%H_%M")) filename_quoted = urllib.parse.quote(filename) self.sendHeader(content_type="application/zip", extra_headers={'Content-Disposition': 'attachment; filename="%s"' % filename_quoted}) return self.streamZip(site.storage.getPath(".")) def streamZip(self, dir_path): zs = ZipStream(dir_path) while 1: data = zs.read() if not data: break yield data @PluginManager.registerTo("UiWebsocket") class UiWebsocketPlugin(object): def sidebarRenderPeerStats(self, body, site): connected = len([peer for peer in list(site.peers.values()) if peer.connection and peer.connection.connected]) connectable = len([peer_id for peer_id in list(site.peers.keys()) if not peer_id.endswith(":0")]) onion = len([peer_id for peer_id in list(site.peers.keys()) if ".onion" in peer_id]) local = len([peer for peer in list(site.peers.values()) if helper.isPrivateIp(peer.ip)]) peers_total = len(site.peers) # Add myself if site.isServing(): peers_total += 1 if any(site.connection_server.port_opened.values()): connectable += 1 if site.connection_server.tor_manager.start_onions: onion += 1 if peers_total: percent_connected = float(connected) / peers_total percent_connectable = float(connectable) / peers_total percent_onion = float(onion) / peers_total else: percent_connectable = percent_connected = percent_onion = 0 if local: local_html = _("
  • {_[Local]}:{local}
  • ") else: local_html = "" peer_ips = [peer.key for peer in site.getConnectablePeers(20, allow_private=False)] peer_ips.sort(key=lambda peer_ip: ".onion:" in peer_ip) copy_link = "http://127.0.0.1:43110/%s/?zeronet_peers=%s" % ( site.content_manager.contents.get("content.json", {}).get("domain", site.address), ",".join(peer_ips) ) body.append(_("""
    • {_[Connected]}:{connected}
    • {_[Connectable]}:{connectable}
    • {_[Onion]}:{onion}
    • {local_html}
    • {_[Total]}:{peers_total}
  • """.replace("{local_html}", local_html))) def sidebarRenderTransferStats(self, body, site): recv = float(site.settings.get("bytes_recv", 0)) / 1024 / 1024 sent = float(site.settings.get("bytes_sent", 0)) / 1024 / 1024 transfer_total = recv + sent if transfer_total: percent_recv = recv / transfer_total percent_sent = sent / transfer_total else: percent_recv = 0.5 percent_sent = 0.5 body.append(_("""
    • {_[Received]}:{recv:.2f}MB
    • {_[Sent]}:{sent:.2f}MB
  • """)) def sidebarRenderFileStats(self, body, site): body.append(_("""
    • """)) extensions = ( ("html", "yellow"), ("css", "orange"), ("js", "purple"), ("Image", "green"), ("json", "darkblue"), ("User data", "blue"), ("Other", "white"), ("Total", "black") ) # Collect stats size_filetypes = {} size_total = 0 contents = site.content_manager.listContents() # Without user files for inner_path in contents: content = site.content_manager.contents[inner_path] if "files" not in content or content["files"] is None: continue for file_name, file_details in list(content["files"].items()): size_total += file_details["size"] ext = file_name.split(".")[-1] size_filetypes[ext] = size_filetypes.get(ext, 0) + file_details["size"] # Get user file sizes size_user_content = site.content_manager.contents.execute( "SELECT SUM(size) + SUM(size_files) AS size FROM content WHERE ?", {"not__inner_path": contents} ).fetchone()["size"] if not size_user_content: size_user_content = 0 size_filetypes["User data"] = size_user_content size_total += size_user_content # The missing difference is content.json sizes if "json" in size_filetypes: size_filetypes["json"] += max(0, site.settings["size"] - size_total) size_total = size_other = site.settings["size"] # Bar for extension, color in extensions: if extension == "Total": continue if extension == "Other": size = max(0, size_other) elif extension == "Image": size = size_filetypes.get("jpg", 0) + size_filetypes.get("png", 0) + size_filetypes.get("gif", 0) size_other -= size else: size = size_filetypes.get(extension, 0) size_other -= size if size_total == 0: percent = 0 else: percent = 100 * (float(size) / size_total) percent = math.floor(percent * 100) / 100 # Floor to 2 digits body.append( """
    • """ % (percent, _[extension], color, _[extension]) ) # Legend body.append("
      ") for extension, color in extensions: if extension == "Other": size = max(0, size_other) elif extension == "Image": size = size_filetypes.get("jpg", 0) + size_filetypes.get("png", 0) + size_filetypes.get("gif", 0) elif extension == "Total": size = size_total else: size = size_filetypes.get(extension, 0) if extension == "js": title = "javascript" else: title = extension if size > 1024 * 1024 * 10: # Format as mB is more than 10mB size_formatted = "%.0fMB" % (size / 1024 / 1024) else: size_formatted = "%.0fkB" % (size / 1024) body.append("
    • %s:%s
    • " % (color, _[title], size_formatted)) body.append("
  • ") def sidebarRenderSizeLimit(self, body, site): free_space = helper.getFreeSpace() / 1024 / 1024 size = float(site.settings["size"]) / 1024 / 1024 size_limit = site.getSizeLimit() percent_used = size / size_limit body.append(_("""
  • MB {_[Set]}
  • """)) def sidebarRenderOptionalFileStats(self, body, site): size_total = float(site.settings["size_optional"]) size_downloaded = float(site.settings["optional_downloaded"]) if not size_total: return False percent_downloaded = size_downloaded / size_total size_formatted_total = size_total / 1024 / 1024 size_formatted_downloaded = size_downloaded / 1024 / 1024 body.append(_("""
    • {_[Downloaded]}:{size_formatted_downloaded:.2f}MB
    • {_[Total]}:{size_formatted_total:.2f}MB
  • """)) return True def sidebarRenderOptionalFileSettings(self, body, site): if self.site.settings.get("autodownloadoptional"): checked = "checked='checked'" else: checked = "" body.append(_("""
  • """)) if hasattr(config, "autodownload_bigfile_size_limit"): autodownload_bigfile_size_limit = int(site.settings.get("autodownload_bigfile_size_limit", config.autodownload_bigfile_size_limit)) body.append(_("""
    MB {_[Set]} {_[Download previous files]}
    """)) body.append("
  • ") def sidebarRenderBadFiles(self, body, site): body.append(_("""
    • """)) i = 0 for bad_file, tries in site.bad_files.items(): i += 1 body.append(_("""
    • {bad_filename}
    • """, { "bad_file_path": bad_file, "bad_filename": helper.getFilename(bad_file), "tries": _.pluralize(tries, "{} try", "{} tries") })) if i > 30: break if len(site.bad_files) > 30: num_bad_files = len(site.bad_files) - 30 body.append(_("""
    • {_[+ {num_bad_files} more]}
    • """, nested=True)) body.append("""
  • """) def sidebarRenderDbOptions(self, body, site): if site.storage.db: inner_path = site.storage.getInnerPath(site.storage.db.db_path) size = float(site.storage.getSize(inner_path)) / 1024 feeds = len(site.storage.db.schema.get("feeds", {})) else: inner_path = _["No database found"] size = 0.0 feeds = 0 body.append(_("""
  • """, nested=True)) def sidebarRenderIdentity(self, body, site): auth_address = self.user.getAuthAddress(self.site.address, create=False) rules = self.site.content_manager.getRules("data/users/%s/content.json" % auth_address) if rules and rules.get("max_size"): quota = rules["max_size"] / 1024 try: content = site.content_manager.contents["data/users/%s/content.json" % auth_address] used = len(json.dumps(content)) + sum([file["size"] for file in list(content["files"].values())]) except: used = 0 used = used / 1024 else: quota = used = 0 body.append(_("""
  • {auth_address} {_[Change]}
  • """)) def sidebarRenderControls(self, body, site): auth_address = self.user.getAuthAddress(self.site.address, create=False) if self.site.settings["serving"]: class_pause = "" class_resume = "hidden" else: class_pause = "hidden" class_resume = "" body.append(_("""
  • {_[Update]} {_[Pause]} {_[Resume]} {_[Delete]}
  • """)) donate_key = site.content_manager.contents.get("content.json", {}).get("donate", True) site_address = self.site.address body.append(_("""

  • {site_address} """)) if donate_key == False or donate_key == "": pass elif (type(donate_key) == str or type(donate_key) == str) and len(donate_key) > 0: body.append(_("""

  • {donate_key} """)) else: body.append(_(""" {_[Donate]} """)) body.append(_("""
  • """)) def sidebarRenderOwnedCheckbox(self, body, site): if self.site.settings["own"]: checked = "checked='checked'" else: checked = "" body.append(_("""

    {_[This is my site]}

    """)) def sidebarRenderOwnSettings(self, body, site): title = site.content_manager.contents.get("content.json", {}).get("title", "") description = site.content_manager.contents.get("content.json", {}).get("description", "") body.append(_("""
  • {_[Save site settings]}
  • """)) def sidebarRenderContents(self, body, site): has_privatekey = bool(self.user.getSiteData(site.address, create=False).get("privatekey")) if has_privatekey: tag_privatekey = _("{_[Private key saved.]} {_[Forget]}") else: tag_privatekey = _("{_[Add saved private key]}") body.append(_("""
  • """.replace("{tag_privatekey}", tag_privatekey))) # Choose content you want to sign body.append(_(""" """)) contents = ["content.json"] contents += list(site.content_manager.contents.get("content.json", {}).get("includes", {}).keys()) body.append(_("
    {_[Choose]}: ")) for content in contents: body.append(_("{content} ")) body.append("
    ") body.append("
  • ") @flag.admin def actionSidebarGetHtmlTag(self, to): site = self.site body = [] body.append("
    ") body.append("×") body.append("

    %s

    " % html.escape(site.content_manager.contents.get("content.json", {}).get("title", ""), True)) body.append("
    ") body.append("
      ") self.sidebarRenderPeerStats(body, site) self.sidebarRenderTransferStats(body, site) self.sidebarRenderFileStats(body, site) self.sidebarRenderSizeLimit(body, site) has_optional = self.sidebarRenderOptionalFileStats(body, site) if has_optional: self.sidebarRenderOptionalFileSettings(body, site) self.sidebarRenderDbOptions(body, site) self.sidebarRenderIdentity(body, site) self.sidebarRenderControls(body, site) if site.bad_files: self.sidebarRenderBadFiles(body, site) self.sidebarRenderOwnedCheckbox(body, site) body.append("
      ") self.sidebarRenderOwnSettings(body, site) self.sidebarRenderContents(body, site) body.append("
      ") body.append("
    ") body.append("
    ") body.append("") self.response(to, "".join(body)) def downloadGeoLiteDb(self, db_path): import gzip import shutil from util import helper if config.offline: return False self.log.info("Downloading GeoLite2 City database...") self.cmd("progress", ["geolite-info", _["Downloading GeoLite2 City database (one time only, ~20MB)..."], 0]) db_urls = [ "https://raw.githubusercontent.com/aemr3/GeoLite2-Database/master/GeoLite2-City.mmdb.gz", "https://raw.githubusercontent.com/texnikru/GeoLite2-Database/master/GeoLite2-City.mmdb.gz" ] for db_url in db_urls: downloadl_err = None try: # Download response = helper.httpRequest(db_url) data_size = response.getheader('content-length') data_recv = 0 data = io.BytesIO() while True: buff = response.read(1024 * 512) if not buff: break data.write(buff) data_recv += 1024 * 512 if data_size: progress = int(float(data_recv) / int(data_size) * 100) self.cmd("progress", ["geolite-info", _["Downloading GeoLite2 City database (one time only, ~20MB)..."], progress]) self.log.info("GeoLite2 City database downloaded (%s bytes), unpacking..." % data.tell()) data.seek(0) # Unpack with gzip.GzipFile(fileobj=data) as gzip_file: shutil.copyfileobj(gzip_file, open(db_path, "wb")) self.cmd("progress", ["geolite-info", _["GeoLite2 City database downloaded!"], 100]) time.sleep(2) # Wait for notify animation self.log.info("GeoLite2 City database is ready at: %s" % db_path) return True except Exception as err: download_err = err self.log.error("Error downloading %s: %s" % (db_url, err)) pass self.cmd("progress", [ "geolite-info", _["GeoLite2 City database download error: {}!
    Please download manually and unpack to data dir:
    {}"].format(download_err, db_urls[0]), -100 ]) def getLoc(self, geodb, ip): global loc_cache if ip in loc_cache: return loc_cache[ip] else: try: loc_data = geodb.get(ip) except: loc_data = None if not loc_data or "location" not in loc_data: loc_cache[ip] = None return None loc = { "lat": loc_data["location"]["latitude"], "lon": loc_data["location"]["longitude"], } if "city" in loc_data: loc["city"] = loc_data["city"]["names"]["en"] if "country" in loc_data: loc["country"] = loc_data["country"]["names"]["en"] loc_cache[ip] = loc return loc @util.Noparallel() def getGeoipDb(self): db_name = 'GeoLite2-City.mmdb' sys_db_paths = [] if sys.platform == "linux": sys_db_paths += ['/usr/share/GeoIP/' + db_name] data_dir_db_path = os.path.join(config.data_dir, db_name) db_paths = sys_db_paths + [data_dir_db_path] for path in db_paths: if os.path.isfile(path) and os.path.getsize(path) > 0: return path self.log.info("GeoIP database not found at [%s]. Downloading to: %s", " ".join(db_paths), data_dir_db_path) if self.downloadGeoLiteDb(data_dir_db_path): return data_dir_db_path return None def getPeerLocations(self, peers): import maxminddb db_path = self.getGeoipDb() if not db_path: self.log.debug("Not showing peer locations: no GeoIP database") return False geodb = maxminddb.open_database(db_path) peers = list(peers.values()) # Place bars peer_locations = [] placed = {} # Already placed bars here for peer in peers: # Height of bar if peer.connection and peer.connection.last_ping_delay: ping = round(peer.connection.last_ping_delay * 1000) else: ping = None loc = self.getLoc(geodb, peer.ip) if not loc: continue # Create position array lat, lon = loc["lat"], loc["lon"] latlon = "%s,%s" % (lat, lon) if latlon in placed and helper.getIpType(peer.ip) == "ipv4": # Dont place more than 1 bar to same place, fake repos using ip address last two part lat += float(128 - int(peer.ip.split(".")[-2])) / 50 lon += float(128 - int(peer.ip.split(".")[-1])) / 50 latlon = "%s,%s" % (lat, lon) placed[latlon] = True peer_location = {} peer_location.update(loc) peer_location["lat"] = lat peer_location["lon"] = lon peer_location["ping"] = ping peer_locations.append(peer_location) # Append myself for ip in self.site.connection_server.ip_external_list: my_loc = self.getLoc(geodb, ip) if my_loc: my_loc["ping"] = 0 peer_locations.append(my_loc) return peer_locations @flag.admin @flag.async_run def actionSidebarGetPeers(self, to): try: peer_locations = self.getPeerLocations(self.site.peers) globe_data = [] ping_times = [ peer_location["ping"] for peer_location in peer_locations if peer_location["ping"] ] if ping_times: ping_avg = sum(ping_times) / float(len(ping_times)) else: ping_avg = 0 for peer_location in peer_locations: if peer_location["ping"] == 0: # Me height = -0.135 elif peer_location["ping"]: height = min(0.20, math.log(1 + peer_location["ping"] / ping_avg, 300)) else: height = -0.03 globe_data += [peer_location["lat"], peer_location["lon"], height] self.response(to, globe_data) except Exception as err: self.log.debug("sidebarGetPeers error: %s" % Debug.formatException(err)) self.response(to, {"error": str(err)}) @flag.admin @flag.no_multiuser def actionSiteSetOwned(self, to, owned): if self.site.address == config.updatesite: return {"error": "You can't change the ownership of the updater site"} self.site.settings["own"] = bool(owned) self.site.updateWebsocket(owned=owned) return "ok" @flag.admin @flag.no_multiuser def actionSiteRecoverPrivatekey(self, to): from Crypt import CryptBitcoin site_data = self.user.sites[self.site.address] if site_data.get("privatekey"): return {"error": "This site already has saved privated key"} address_index = self.site.content_manager.contents.get("content.json", {}).get("address_index") if not address_index: return {"error": "No address_index in content.json"} privatekey = CryptBitcoin.hdPrivatekey(self.user.master_seed, address_index) privatekey_address = CryptBitcoin.privatekeyToAddress(privatekey) if privatekey_address == self.site.address: site_data["privatekey"] = privatekey self.user.save() self.site.updateWebsocket(recover_privatekey=True) return "ok" else: return {"error": "Unable to deliver private key for this site from current user's master_seed"} @flag.admin @flag.no_multiuser def actionUserSetSitePrivatekey(self, to, privatekey): site_data = self.user.sites[self.site.address] site_data["privatekey"] = privatekey self.site.updateWebsocket(set_privatekey=bool(privatekey)) self.user.save() return "ok" @flag.admin @flag.no_multiuser def actionSiteSetAutodownloadoptional(self, to, owned): self.site.settings["autodownloadoptional"] = bool(owned) self.site.worker_manager.removeSolvedFileTasks() @flag.no_multiuser @flag.admin def actionDbReload(self, to): self.site.storage.closeDb() self.site.storage.getDb() return self.response(to, "ok") @flag.no_multiuser @flag.admin def actionDbRebuild(self, to): try: self.site.storage.rebuildDb() except Exception as err: return self.response(to, {"error": str(err)}) return self.response(to, "ok") ================================================ FILE: plugins/Sidebar/ZipStream.py ================================================ import io import os import zipfile class ZipStream(object): def __init__(self, dir_path): self.dir_path = dir_path self.pos = 0 self.buff_pos = 0 self.zf = zipfile.ZipFile(self, 'w', zipfile.ZIP_DEFLATED, allowZip64=True) self.buff = io.BytesIO() self.file_list = self.getFileList() def getFileList(self): for root, dirs, files in os.walk(self.dir_path): for file in files: file_path = root + "/" + file relative_path = os.path.join(os.path.relpath(root, self.dir_path), file) yield file_path, relative_path self.zf.close() def read(self, size=60 * 1024): for file_path, relative_path in self.file_list: self.zf.write(file_path, relative_path) if self.buff.tell() >= size: break self.buff.seek(0) back = self.buff.read() self.buff.truncate(0) self.buff.seek(0) self.buff_pos += len(back) return back def write(self, data): self.pos += len(data) self.buff.write(data) def tell(self): return self.pos def seek(self, pos, whence=0): if pos >= self.buff_pos: self.buff.seek(pos - self.buff_pos, whence) self.pos = pos def flush(self): pass if __name__ == "__main__": zs = ZipStream(".") out = open("out.zip", "wb") while 1: data = zs.read() print("Write %s" % len(data)) if not data: break out.write(data) out.close() ================================================ FILE: plugins/Sidebar/__init__.py ================================================ from . import SidebarPlugin from . import ConsolePlugin ================================================ FILE: plugins/Sidebar/languages/da.json ================================================ { "Peers": "Klienter", "Connected": "Forbundet", "Connectable": "Mulige", "Connectable peers": "Mulige klienter", "Data transfer": "Data overførsel", "Received": "Modtaget", "Received bytes": "Bytes modtaget", "Sent": "Sendt", "Sent bytes": "Bytes sendt", "Files": "Filer", "Total": "I alt", "Image": "Image", "Other": "Andet", "User data": "Bruger data", "Size limit": "Side max størrelse", "limit used": "brugt", "free space": "fri", "Set": "Opdater", "Optional files": "Valgfri filer", "Downloaded": "Downloadet", "Download and help distribute all files": "Download og hjælp med at dele filer", "Total size": "Størrelse i alt", "Downloaded files": "Filer downloadet", "Database": "Database", "search feeds": "søgninger", "{feeds} query": "{feeds} søgninger", "Reload": "Genindlæs", "Rebuild": "Genopbyg", "No database found": "Ingen database fundet", "Identity address": "Autorisations ID", "Change": "Skift", "Update": "Opdater", "Pause": "Pause", "Resume": "Aktiv", "Delete": "Slet", "Are you sure?": "Er du sikker?", "Site address": "Side addresse", "Donate": "Doner penge", "Missing files": "Manglende filer", "{} try": "{} forsøg", "{} tries": "{} forsøg", "+ {num_bad_files} more": "+ {num_bad_files} mere", "This is my site": "Dette er min side", "Site title": "Side navn", "Site description": "Side beskrivelse", "Save site settings": "Gem side opsætning", "Content publishing": "Indhold offentliggøres", "Choose": "Vælg", "Sign": "Signer", "Publish": "Offentliggør", "This function is disabled on this proxy": "Denne funktion er slået fra på denne ZeroNet proxyEz a funkció ki van kapcsolva ezen a proxy-n", "GeoLite2 City database download error: {}!
    Please download manually and unpack to data dir:
    {}": "GeoLite2 City database kunne ikke downloades: {}!
    Download venligst databasen manuelt og udpak i data folder:
    {}", "Downloading GeoLite2 City database (one time only, ~20MB)...": "GeoLite2 város adatbázis letöltése (csak egyszer kell, kb 20MB)...", "GeoLite2 City database downloaded!": "GeoLite2 City database downloadet!", "Are you sure?": "Er du sikker?", "Site storage limit modified!": "Side max størrelse ændret!", "Database schema reloaded!": "Database definition genindlæst!", "Database rebuilding....": "Genopbygger database...", "Database rebuilt!": "Database genopbygget!", "Site updated!": "Side opdateret!", "Delete this site": "Slet denne side", "File write error: ": "Fejl ved skrivning af fil: ", "Site settings saved!": "Side opsætning gemt!", "Enter your private key:": "Indtast din private nøgle:", " Signed!": " Signeret!", "WebGL not supported": "WebGL er ikke supporteret" } ================================================ FILE: plugins/Sidebar/languages/de.json ================================================ { "Peers": "Peers", "Connected": "Verbunden", "Connectable": "Verbindbar", "Connectable peers": "Verbindbare Peers", "Data transfer": "Datei Transfer", "Received": "Empfangen", "Received bytes": "Empfangene Bytes", "Sent": "Gesendet", "Sent bytes": "Gesendete Bytes", "Files": "Dateien", "Total": "Gesamt", "Image": "Bilder", "Other": "Sonstiges", "User data": "Nutzer Daten", "Size limit": "Speicher Limit", "limit used": "Limit benutzt", "free space": "freier Speicher", "Set": "Setzten", "Optional files": "Optionale Dateien", "Downloaded": "Heruntergeladen", "Download and help distribute all files": "Herunterladen und helfen alle Dateien zu verteilen", "Total size": "Gesamte Größe", "Downloaded files": "Heruntergeladene Dateien", "Database": "Datenbank", "search feeds": "Feeds durchsuchen", "{feeds} query": "{feeds} Abfrage", "Reload": "Neu laden", "Rebuild": "Neu bauen", "No database found": "Keine Datenbank gefunden", "Identity address": "Identitäts Adresse", "Change": "Ändern", "Update": "Aktualisieren", "Pause": "Pausieren", "Resume": "Fortsetzen", "Delete": "Löschen", "Are you sure?": "Bist du sicher?", "Site address": "Seiten Adresse", "Donate": "Spenden", "Missing files": "Fehlende Dateien", "{} try": "{} versuch", "{} tries": "{} versuche", "+ {num_bad_files} more": "+ {num_bad_files} mehr", "This is my site": "Das ist meine Seite", "Site title": "Seiten Titel", "Site description": "Seiten Beschreibung", "Save site settings": "Einstellungen der Seite speichern", "Content publishing": "Inhaltsveröffentlichung", "Choose": "Wähle", "Sign": "Signieren", "Publish": "Veröffentlichen", "This function is disabled on this proxy": "Diese Funktion ist auf dieser Proxy deaktiviert", "GeoLite2 City database download error: {}!
    Please download manually and unpack to data dir:
    {}": "GeoLite2 City Datenbank Download Fehler: {}!
    Bitte manuell herunterladen und die Datei in das Datei Verzeichnis extrahieren:
    {}", "Downloading GeoLite2 City database (one time only, ~20MB)...": "Herunterladen der GeoLite2 City Datenbank (einmalig, ~20MB)...", "GeoLite2 City database downloaded!": "GeoLite2 City Datenbank heruntergeladen!", "Are you sure?": "Bist du sicher?", "Site storage limit modified!": "Speicher Limit der Seite modifiziert!", "Database schema reloaded!": "Datebank Schema neu geladen!", "Database rebuilding....": "Datenbank neu bauen...", "Database rebuilt!": "Datenbank neu gebaut!", "Site updated!": "Seite aktualisiert!", "Delete this site": "Diese Seite löschen", "File write error: ": "Datei schreib fehler:", "Site settings saved!": "Seiten Einstellungen gespeichert!", "Enter your private key:": "Gib deinen privaten Schlüssel ein:", " Signed!": " Signiert!", "WebGL not supported": "WebGL nicht unterstützt" } ================================================ FILE: plugins/Sidebar/languages/es.json ================================================ { "Peers": "Pares", "Connected": "Conectados", "Connectable": "Conectables", "Connectable peers": "Pares conectables", "Data transfer": "Transferencia de datos", "Received": "Recibidos", "Received bytes": "Bytes recibidos", "Sent": "Enviados", "Sent bytes": "Bytes envidados", "Files": "Ficheros", "Total": "Total", "Image": "Imagen", "Other": "Otro", "User data": "Datos del usuario", "Size limit": "Límite de tamaño", "limit used": "Límite utilizado", "free space": "Espacio libre", "Set": "Establecer", "Optional files": "Ficheros opcionales", "Downloaded": "Descargado", "Download and help distribute all files": "Descargar y ayudar a distribuir todos los ficheros", "Total size": "Tamaño total", "Downloaded files": "Ficheros descargados", "Database": "Base de datos", "search feeds": "Fuentes de búsqueda", "{feeds} query": "{feeds} consulta", "Reload": "Recargar", "Rebuild": "Reconstruir", "No database found": "No se ha encontrado la base de datos", "Identity address": "Dirección de la identidad", "Change": "Cambiar", "Update": "Actualizar", "Pause": "Pausar", "Resume": "Reanudar", "Delete": "Borrar", "Site address": "Dirección del sitio", "Donate": "Donar", "Missing files": "Ficheros perdidos", "{} try": "{} intento", "{} tries": "{} intentos", "+ {num_bad_files} more": "+ {num_bad_files} más", "This is my site": "Este es mi sitio", "Site title": "Título del sitio", "Site description": "Descripción del sitio", "Save site settings": "Guardar la configuración del sitio", "Content publishing": "Publicación del contenido", "Choose": "Elegir", "Sign": "Firmar", "Publish": "Publicar", "This function is disabled on this proxy": "Esta función está deshabilitada en este proxy", "GeoLite2 City database download error: {}!
    Please download manually and unpack to data dir:
    {}": "¡Error de la base de datos GeoLite2: {}!
    Por favor, descárgalo manualmente y descomprime al directorio de datos:
    {}", "Downloading GeoLite2 City database (one time only, ~20MB)...": "Descargando la base de datos de GeoLite2 (una única vez, ~20MB)...", "GeoLite2 City database downloaded!": "¡Base de datos de GeoLite2 descargada!", "Are you sure?": "¿Estás seguro?", "Site storage limit modified!": "¡Límite de almacenamiento del sitio modificado!", "Database schema reloaded!": "¡Esquema de la base de datos recargado!", "Database rebuilding....": "Reconstruyendo la base de datos...", "Database rebuilt!": "¡Base de datos reconstruida!", "Site updated!": "¡Sitio actualizado!", "Delete this site": "Borrar este sitio", "File write error: ": "Error de escritura de fichero:", "Site settings saved!": "¡Configuración del sitio guardada!", "Enter your private key:": "Introduce tu clave privada:", " Signed!": " ¡firmado!", "WebGL not supported": "WebGL no está soportado" } ================================================ FILE: plugins/Sidebar/languages/fr.json ================================================ { "Peers": "Pairs", "Connected": "Connectés", "Connectable": "Accessibles", "Connectable peers": "Pairs accessibles", "Data transfer": "Données transférées", "Received": "Reçues", "Received bytes": "Bytes reçus", "Sent": "Envoyées", "Sent bytes": "Bytes envoyés", "Files": "Fichiers", "Total": "Total", "Image": "Image", "Other": "Autre", "User data": "Utilisateurs", "Size limit": "Taille maximale", "limit used": "utlisé", "free space": "libre", "Set": "Modifier", "Optional files": "Fichiers optionnels", "Downloaded": "Téléchargé", "Download and help distribute all files": "Télécharger et distribuer tous les fichiers", "Total size": "Taille totale", "Downloaded files": "Fichiers téléchargés", "Database": "Base de données", "search feeds": "recherche", "{feeds} query": "{feeds} requête", "Reload": "Recharger", "Rebuild": "Reconstruire", "No database found": "Aucune base de données trouvée", "Identity address": "Adresse d'identité", "Change": "Modifier", "Site control": "Opérations", "Update": "Mettre à jour", "Pause": "Suspendre", "Resume": "Reprendre", "Delete": "Supprimer", "Are you sure?": "Êtes-vous certain?", "Site address": "Adresse du site", "Donate": "Faire un don", "Missing files": "Fichiers manquants", "{} try": "{} essai", "{} tries": "{} essais", "+ {num_bad_files} more": "+ {num_bad_files} manquants", "This is my site": "Ce site m'appartient", "Site title": "Nom du site", "Site description": "Description du site", "Save site settings": "Enregistrer les paramètres", "Content publishing": "Publication du contenu", "Choose": "Sélectionner", "Sign": "Signer", "Publish": "Publier", "This function is disabled on this proxy": "Cette fonction est désactivé sur ce proxy", "GeoLite2 City database download error: {}!
    Please download manually and unpack to data dir:
    {}": "Erreur au téléchargement de la base de données GeoLite2: {}!
    Téléchargez et décompressez dans le dossier data:
    {}", "Downloading GeoLite2 City database (one time only, ~20MB)...": "Téléchargement de la base de données GeoLite2 (une seule fois, ~20MB)...", "GeoLite2 City database downloaded!": "Base de données GeoLite2 téléchargée!", "Are you sure?": "Êtes-vous certain?", "Site storage limit modified!": "Taille maximale modifiée!", "Database schema reloaded!": "Base de données rechargée!", "Database rebuilding....": "Reconstruction de la base de données...", "Database rebuilt!": "Base de données reconstruite!", "Site updated!": "Site mis à jour!", "Delete this site": "Supprimer ce site", "File write error: ": "Erreur à l'écriture du fichier: ", "Site settings saved!": "Paramètres du site enregistrés!", "Enter your private key:": "Entrez votre clé privée:", " Signed!": " Signé!", "WebGL not supported": "WebGL n'est pas supporté" } ================================================ FILE: plugins/Sidebar/languages/hu.json ================================================ { "Peers": "Csatlakozási pontok", "Connected": "Csaltakozva", "Connectable": "Csatlakozható", "Connectable peers": "Csatlakozható peer-ek", "Data transfer": "Adatátvitel", "Received": "Fogadott", "Received bytes": "Fogadott byte-ok", "Sent": "Küldött", "Sent bytes": "Küldött byte-ok", "Files": "Fájlok", "Total": "Összesen", "Image": "Kép", "Other": "Egyéb", "User data": "Felh. adat", "Size limit": "Méret korlát", "limit used": "felhasznált", "free space": "szabad hely", "Set": "Beállít", "Optional files": "Opcionális fájlok", "Downloaded": "Letöltött", "Download and help distribute all files": "Minden opcionális fájl letöltése", "Total size": "Teljes méret", "Downloaded files": "Letöltve", "Database": "Adatbázis", "search feeds": "Keresés források", "{feeds} query": "{feeds} lekérdezés", "Reload": "Újratöltés", "Rebuild": "Újraépítés", "No database found": "Adatbázis nem található", "Identity address": "Azonosító cím", "Change": "Módosít", "Site control": "Oldal műveletek", "Update": "Frissít", "Pause": "Szünteltet", "Resume": "Folytat", "Delete": "Töröl", "Are you sure?": "Biztos vagy benne?", "Site address": "Oldal címe", "Donate": "Támogatás", "Missing files": "Hiányzó fájlok", "{} try": "{} próbálkozás", "{} tries": "{} próbálkozás", "+ {num_bad_files} more": "+ még {num_bad_files} darab", "This is my site": "Ez az én oldalam", "Site title": "Oldal neve", "Site description": "Oldal leírása", "Save site settings": "Oldal beállítások mentése", "Content publishing": "Tartalom publikálás", "Choose": "Válassz", "Sign": "Aláírás", "Publish": "Publikálás", "This function is disabled on this proxy": "Ez a funkció ki van kapcsolva ezen a proxy-n", "GeoLite2 City database download error: {}!
    Please download manually and unpack to data dir:
    {}": "GeoLite2 város adatbázis letöltési hiba: {}!
    A térképhez töltsd le és csomagold ki a data könyvtárba:
    {}", "Downloading GeoLite2 City database (one time only, ~20MB)...": "GeoLite2 város adatbázis letöltése (csak egyszer kell, kb 20MB)...", "GeoLite2 City database downloaded!": "GeoLite2 város adatbázis letöltve!", "Are you sure?": "Biztos vagy benne?", "Site storage limit modified!": "Az oldalt méret korlát módosítva!", "Database schema reloaded!": "Adatbázis séma újratöltve!", "Database rebuilding....": "Adatbázis újraépítés...", "Database rebuilt!": "Adatbázis újraépítve!", "Site updated!": "Az oldal frissítve!", "Delete this site": "Az oldal törlése", "File write error: ": "Fájl írási hiba: ", "Site settings saved!": "Az oldal beállításai elmentve!", "Enter your private key:": "Add meg a privát kulcsod:", " Signed!": " Aláírva!", "WebGL not supported": "WebGL nem támogatott" } ================================================ FILE: plugins/Sidebar/languages/it.json ================================================ { "Peers": "Peer", "Connected": "Connessi", "Connectable": "Collegabili", "Connectable peers": "Peer collegabili", "Data transfer": "Trasferimento dati", "Received": "Ricevuti", "Received bytes": "Byte ricevuti", "Sent": "Inviati", "Sent bytes": "Byte inviati", "Files": "File", "Total": "Totale", "Image": "Imagine", "Other": "Altro", "User data": "Dati utente", "Size limit": "Limite dimensione", "limit used": "limite usato", "free space": "spazio libero", "Set": "Imposta", "Optional files": "File facoltativi", "Downloaded": "Scaricati", "Download and help distribute all files": "Scarica e aiuta a distribuire tutti i file", "Total size": "Dimensione totale", "Downloaded files": "File scaricati", "Database": "Database", "search feeds": "ricerca di feed", "{feeds} query": "{feeds} interrogazione", "Reload": "Ricaricare", "Rebuild": "Ricostruire", "No database found": "Nessun database trovato", "Identity address": "Indirizzo di identità", "Change": "Cambia", "Update": "Aggiorna", "Pause": "Sospendi", "Resume": "Riprendi", "Delete": "Cancella", "Are you sure?": "Sei sicuro?", "Site address": "Indirizzo sito", "Donate": "Dona", "Missing files": "File mancanti", "{} try": "{} tenta", "{} tries": "{} prova", "+ {num_bad_files} more": "+ {num_bad_files} altri", "This is my site": "Questo è il mio sito", "Site title": "Titolo sito", "Site description": "Descrizione sito", "Save site settings": "Salva impostazioni sito", "Content publishing": "Pubblicazione contenuto", "Choose": "Scegli", "Sign": "Firma", "Publish": "Pubblica", "This function is disabled on this proxy": "Questa funzione è disabilitata su questo proxy", "GeoLite2 City database download error: {}!
    Please download manually and unpack to data dir:
    {}": "Errore scaricamento database GeoLite2 City: {}!
    Si prega di scaricarlo manualmente e spacchetarlo nella cartella dir:
    {}", "Downloading GeoLite2 City database (one time only, ~20MB)...": "Scaricamento database GeoLite2 City (solo una volta, ~20MB)...", "GeoLite2 City database downloaded!": "Database GeoLite2 City scaricato!", "Are you sure?": "Sei sicuro?", "Site storage limit modified!": "Limite di archiviazione del sito modificato!", "Database schema reloaded!": "Schema database ricaricato!", "Database rebuilding....": "Ricostruzione database...", "Database rebuilt!": "Database ricostruito!", "Site updated!": "Sito aggiornato!", "Delete this site": "Cancella questo sito", "File write error: ": "Errore scrittura file:", "Site settings saved!": "Impostazioni sito salvate!", "Enter your private key:": "Inserisci la tua chiave privata:", " Signed!": " Firmato!", "WebGL not supported": "WebGL non supportato" } ================================================ FILE: plugins/Sidebar/languages/jp.json ================================================ { "Copy to clipboard": "クリップボードにコピー", "Peers": "ピア", "Connected": "接続済み", "Connectable": "利用可能", "Connectable peers": "ピアに接続可能", "Onion": "Onion", "Local": "ローカル", "Data transfer": "データ転送", "Received": "受信", "Received bytes": "受信バイト数", "Sent": "送信", "Sent bytes": "送信バイト数", "Files": "ファイル", "Browse files": "ファイルを見る", "Save as .zip": "ZIP形式で保存", "Total": "合計", "Image": "画像", "Other": "その他", "User data": "ユーザーデータ", "Size limit": "サイズ制限", "limit used": "使用上限", "free space": "フリースペース", "Set": "セット", "Optional files": "オプション ファイル", "Downloaded": "ダウンロード済み", "Help distribute added optional files": "オプションファイルの配布を支援する", "Auto download big file size limit": "大きなファイルの自動ダウンロードのサイズ制限", "Download previous files": "以前のファイルのダウンロード", "Optional files download started": "オプションファイルのダウンロードを開始", "Optional files downloaded": "オプションファイルのダウンロードが完了しました", "Download and help distribute all files": "ダウンロードしてすべてのファイルの配布を支援する", "Total size": "合計サイズ", "Downloaded files": "ダウンロードされたファイル", "Database": "データベース", "search feeds": "フィードを検索する", "{feeds} query": "{feeds} お問い合わせ", "Reload": "再読込", "Rebuild": "再ビルド", "No database found": "データベースが見つかりません", "Identity address": "あなたの識別アドレス", "Change": "編集", "Site control": "サイト管理", "Update": "更新", "Pause": "一時停止", "Resume": "再開", "Delete": "削除", "Are you sure?": "本当によろしいですか?", "Site address": "サイトアドレス", "Donate": "寄付する", "Missing files": "ファイルがありません", "{} try": "{} 試す", "{} tries": "{} 試行", "+ {num_bad_files} more": "+ {num_bad_files} more", "This is my site": "これは私のサイトです", "Site title": "サイトタイトル", "Site description": "サイトの説明", "Save site settings": "サイトの設定を保存する", "Open site directory": "サイトのディレクトリを開く", "Content publishing": "コンテンツを公開する", "Add saved private key": "秘密鍵の追加と保存", "Save": "保存", "Private key saved.": "秘密鍵が保存されています", "Private key saved for site signing": "サイトに署名するための秘密鍵を保存", "Forgot": "わすれる", "Saved private key removed": "保存された秘密鍵を削除しました", "Choose": "選択", "Sign": "署名", "Publish": "公開する", "Sign and publish": "署名して公開", "This function is disabled on this proxy": "この機能はこのプロキシで無効になっています", "GeoLite2 City database download error: {}!
    Please download manually and unpack to data dir:
    {}": "GeoLite2 Cityデータベースのダウンロードエラー: {}!
    手動でダウンロードして、フォルダに解凍してください。:
    {}", "Downloading GeoLite2 City database (one time only, ~20MB)...": "GeoLite2 Cityデータベースの読み込み (これは一度だけ行われます, ~20MB)...", "GeoLite2 City database downloaded!": "GeoLite2 Cityデータベースがダウンロードされました!", "Are you sure?": "本当によろしいですか?", "Site storage limit modified!": "サイトの保存容量の制限が変更されました!", "Database schema reloaded!": "データベーススキーマがリロードされました!", "Database rebuilding....": "データベースの再構築中....", "Database rebuilt!": "データベースが再構築されました!", "Site updated!": "サイトが更新されました!", "Delete this site": "このサイトを削除する", "Blacklist": "NG", "Blacklist this site": "NGリストに入れる", "Reason": "理由", "Delete and Blacklist": "削除してNG", "File write error: ": "ファイル書き込みエラー:", "Site settings saved!": "サイト設定が保存されました!", "Enter your private key:": "秘密鍵を入力してください:", " Signed!": " 署名しました!", "WebGL not supported": "WebGLはサポートされていません" } ================================================ FILE: plugins/Sidebar/languages/pl.json ================================================ { "Peers": "Użytkownicy równorzędni", "Connected": "Połączony", "Connectable": "Możliwy do podłączenia", "Connectable peers": "Połączeni użytkownicy równorzędni", "Data transfer": "Transfer danych", "Received": "Odebrane", "Received bytes": "Odebrany bajty", "Sent": "Wysłane", "Sent bytes": "Wysłane bajty", "Files": "Pliki", "Total": "Sumarycznie", "Image": "Obraz", "Other": "Inne", "User data": "Dane użytkownika", "Size limit": "Rozmiar limitu", "limit used": "zużyty limit", "free space": "wolna przestrzeń", "Set": "Ustaw", "Optional files": "Pliki opcjonalne", "Downloaded": "Ściągnięte", "Download and help distribute all files": "Ściągnij i pomóż rozpowszechniać wszystkie pliki", "Total size": "Rozmiar sumaryczny", "Downloaded files": "Ściągnięte pliki", "Database": "Baza danych", "search feeds": "przeszukaj zasoby", "{feeds} query": "{feeds} pytanie", "Reload": "Odśwież", "Rebuild": "Odbuduj", "No database found": "Nie odnaleziono bazy danych", "Identity address": "Adres identyfikacyjny", "Change": "Zmień", "Site control": "Kontrola strony", "Update": "Zaktualizuj", "Pause": "Wstrzymaj", "Resume": "Wznów", "Delete": "Skasuj", "Are you sure?": "Jesteś pewien?", "Site address": "Adres strony", "Donate": "Wspomóż", "Missing files": "Brakujące pliki", "{} try": "{} próba", "{} tries": "{} próby", "+ {num_bad_files} more": "+ {num_bad_files} więcej", "This is my site": "To moja strona", "Site title": "Tytuł strony", "Site description": "Opis strony", "Save site settings": "Zapisz ustawienia strony", "Content publishing": "Publikowanie treści", "Choose": "Wybierz", "Sign": "Podpisz", "Publish": "Opublikuj", "This function is disabled on this proxy": "Ta funkcja jest zablokowana w tym proxy", "GeoLite2 City database download error: {}!
    Please download manually and unpack to data dir:
    {}": "Błąd ściągania bazy danych GeoLite2 City: {}!
    Proszę ściągnąć ją recznie i wypakować do katalogu danych:
    {}", "Downloading GeoLite2 City database (one time only, ~20MB)...": "Ściąganie bazy danych GeoLite2 City (tylko jednorazowo, ok. 20MB)...", "GeoLite2 City database downloaded!": "Baza danych GeoLite2 City ściagnięta!", "Are you sure?": "Jesteś pewien?", "Site storage limit modified!": "Limit pamięci strony zmodyfikowany!", "Database schema reloaded!": "Schemat bazy danych załadowany ponownie!", "Database rebuilding....": "Przebudowywanie bazy danych...", "Database rebuilt!": "Baza danych przebudowana!", "Site updated!": "Strona zaktualizowana!", "Delete this site": "Usuń tę stronę", "File write error: ": "Błąd zapisu pliku: ", "Site settings saved!": "Ustawienia strony zapisane!", "Enter your private key:": "Wpisz swój prywatny klucz:", " Signed!": " Podpisane!", "WebGL not supported": "WebGL nie jest obsługiwany" } ================================================ FILE: plugins/Sidebar/languages/pt-br.json ================================================ { "Copy to clipboard": "Copiar para área de transferência (clipboard)", "Peers": "Peers", "Connected": "Ligados", "Connectable": "Disponíveis", "Onion": "Onion", "Local": "Locais", "Connectable peers": "Peers disponíveis", "Data transfer": "Transferência de dados", "Received": "Recebidos", "Received bytes": "Bytes recebidos", "Sent": "Enviados", "Sent bytes": "Bytes enviados", "Files": "Arquivos", "Save as .zip": "Salvar como .zip", "Total": "Total", "Image": "Imagem", "Other": "Outros", "User data": "Dados do usuário", "Size limit": "Limite de tamanho", "limit used": "limite utilizado", "free space": "espaço livre", "Set": "Definir", "Optional files": "Arquivos opcionais", "Downloaded": "Baixados", "Download and help distribute all files": "Baixar e ajudar a distribuir todos os arquivos", "Total size": "Tamanho total", "Downloaded files": "Arquivos baixados", "Database": "Banco de dados", "search feeds": "pesquisar feeds", "{feeds} query": "consulta de {feeds}", "Reload": "Recarregar", "Rebuild": "Reconstruir", "No database found": "Base de dados não encontrada", "Identity address": "Endereço de identidade", "Change": "Alterar", "Site control": "Controle do site", "Update": "Atualizar", "Pause": "Suspender", "Resume": "Continuar", "Delete": "Remover", "Are you sure?": "Tem certeza?", "Site address": "Endereço do site", "Donate": "Doar", "Needs to be updated": "Necessitam ser atualizados", "{} try": "{} tentativa", "{} tries": "{} tentativas", "+ {num_bad_files} more": "+ {num_bad_files} adicionais", "This is my site": "Este é o meu site", "Site title": "Título do site", "Site description": "Descrição do site", "Save site settings": "Salvar definições do site", "Open site directory": "Abrir diretório do site", "Content publishing": "Publicação do conteúdo", "Choose": "Escolher", "Sign": "Assinar", "Publish": "Publicar", "Sign and publish": "Assinar e publicar", "add saved private key": "adicionar privatekey (chave privada) para salvar", "Private key saved for site signing": "Privatekey foi salva para assinar o site", "Private key saved.": "Privatekey salva.", "forgot": "esquecer", "Saved private key removed": "Privatekey salva foi removida", "This function is disabled on this proxy": "Esta função encontra-se desativada neste proxy", "GeoLite2 City database download error: {}!
    Please download manually and unpack to data dir:
    {}": "Erro ao baixar a base de dados GeoLite2 City: {}!
    Por favor baixe manualmente e descompacte os dados para a seguinte pasta:
    {}", "Downloading GeoLite2 City database (one time only, ~20MB)...": "Baixando a base de dados GeoLite2 City (uma única vez, ~20MB)...", "GeoLite2 City database downloaded!": "A base de dados GeoLite2 City foi baixada!", "Are you sure?": "Tem certeza?", "Site storage limit modified!": "O limite de armazenamento do site foi modificado!", "Database schema reloaded!": "O esquema da base de dados foi atualizado!", "Database rebuilding....": "Reconstruindo base de dados...", "Database rebuilt!": "Base de dados reconstruída!", "Site updated!": "Site atualizado!", "Delete this site": "Remover este site", "Blacklist": "Blacklist", "Blacklist this site": "Blacklistar este site", "Reason": "Motivo", "Delete and Blacklist": "Deletar e blacklistar", "File write error: ": "Erro de escrita de arquivo: ", "Site settings saved!": "Definições do site salvas!", "Enter your private key:": "Digite sua chave privada:", " Signed!": " Assinado!", "WebGL not supported": "WebGL não é suportado", "Save as .zip": "Salvar como .zip" } ================================================ FILE: plugins/Sidebar/languages/ru.json ================================================ { "Peers": "Пиры", "Connected": "Подключенные", "Connectable": "Доступные", "Connectable peers": "Пиры доступны для подключения", "Data transfer": "Передача данных", "Received": "Получено", "Received bytes": "Получено байн", "Sent": "Отправлено", "Sent bytes": "Отправлено байт", "Files": "Файлы", "Total": "Всего", "Image": "Изображений", "Other": "Другое", "User data": "Ваш контент", "Size limit": "Ограничение по размеру", "limit used": "Использовано", "free space": "Доступно", "Set": "Установить", "Optional files": "Опциональные файлы", "Downloaded": "Загружено", "Download and help distribute all files": "Загрузить опциональные файлы для помощи сайту", "Total size": "Объём", "Downloaded files": "Загруженные файлы", "Database": "База данных", "search feeds": "поиск подписок", "{feeds} query": "{feeds} запрос", "Reload": "Перезагрузить", "Rebuild": "Перестроить", "No database found": "База данных не найдена", "Identity address": "Уникальный адрес", "Change": "Изменить", "Site control": "Управление сайтом", "Update": "Обновить", "Pause": "Пауза", "Resume": "Продолжить", "Delete": "Удалить", "Are you sure?": "Вы уверены?", "Site address": "Адрес сайта", "Donate": "Пожертвовать", "Missing files": "Отсутствующие файлы", "{} try": "{} попробовать", "{} tries": "{} попыток", "+ {num_bad_files} more": "+ {num_bad_files} ещё", "This is my site": "Это мой сайт", "Site title": "Название сайта", "Site description": "Описание сайта", "Save site settings": "Сохранить настройки сайта", "Content publishing": "Публикация контента", "Choose": "Выбрать", "Sign": "Подписать", "Publish": "Опубликовать", "This function is disabled on this proxy": "Эта функция отключена на этом прокси", "GeoLite2 City database download error: {}!
    Please download manually and unpack to data dir:
    {}": "Ошибка загрузки базы городов GeoLite2: {}!
    Пожалуйста, загрузите её вручную и распакуйте в папку:
    {}", "Downloading GeoLite2 City database (one time only, ~20MB)...": "Загрузка базы городов GeoLite2 (это делается только 1 раз, ~20MB)...", "GeoLite2 City database downloaded!": "База GeoLite2 успешно загружена!", "Are you sure?": "Вы уверены?", "Site storage limit modified!": "Лимит хранилища для сайта изменен!", "Database schema reloaded!": "Схема базы данных перезагружена!", "Database rebuilding....": "Перестройка базы данных...", "Database rebuilt!": "База данных перестроена!", "Site updated!": "Сайт обновлён!", "Delete this site": "Удалить этот сайт", "File write error: ": "Ошибка записи файла:", "Site settings saved!": "Настройки сайта сохранены!", "Enter your private key:": "Введите свой приватный ключ:", " Signed!": " Подписано!", "WebGL not supported": "WebGL не поддерживается" } ================================================ FILE: plugins/Sidebar/languages/tr.json ================================================ { "Peers": "Eşler", "Connected": "Bağlı", "Connectable": "Erişilebilir", "Connectable peers": "Bağlanılabilir eşler", "Data transfer": "Veri aktarımı", "Received": "Alınan", "Received bytes": "Bayt alındı", "Sent": "Gönderilen", "Sent bytes": "Bayt gönderildi", "Files": "Dosyalar", "Total": "Toplam", "Image": "Resim", "Other": "Diğer", "User data": "Kullanıcı verisi", "Size limit": "Boyut sınırı", "limit used": "kullanılan", "free space": "boş", "Set": "Ayarla", "Optional files": "İsteğe bağlı dosyalar", "Downloaded": "İndirilen", "Download and help distribute all files": "Tüm dosyaları indir ve yayılmalarına yardım et", "Total size": "Toplam boyut", "Downloaded files": "İndirilen dosyalar", "Database": "Veritabanı", "search feeds": "kaynak ara", "{feeds} query": "{feeds} sorgu", "Reload": "Yenile", "Rebuild": "Yapılandır", "No database found": "Veritabanı yok", "Identity address": "Kimlik adresi", "Change": "Değiştir", "Site control": "Site kontrolü", "Update": "Güncelle", "Pause": "Duraklat", "Resume": "Sürdür", "Delete": "Sil", "Are you sure?": "Emin misin?", "Site address": "Site adresi", "Donate": "Bağış yap", "Missing files": "Eksik dosyalar", "{} try": "{} deneme", "{} tries": "{} deneme", "+ {num_bad_files} more": "+ {num_bad_files} tane daha", "This is my site": "Bu benim sitem", "Site title": "Site başlığı", "Site description": "Site açıklaması", "Save site settings": "Site ayarlarını kaydet", "Content publishing": "İçerik yayımlanıyor", "Choose": "Seç", "Sign": "İmzala", "Publish": "Yayımla", "This function is disabled on this proxy": "Bu özellik bu vekilde kullanılamaz", "GeoLite2 City database download error: {}!
    Please download manually and unpack to data dir:
    {}": "GeoLite2 Şehir veritabanı indirme hatası: {}!
    Lütfen kendiniz indirip aşağıdaki konuma açınınız:
    {}", "Downloading GeoLite2 City database (one time only, ~20MB)...": "GeoLite2 Şehir veritabanı indiriliyor (sadece bir kere, ~20MB)...", "GeoLite2 City database downloaded!": "GeoLite2 Şehir veritabanı indirildi!", "Are you sure?": "Emin misiniz?", "Site storage limit modified!": "Site saklama sınırı değiştirildi!", "Database schema reloaded!": "Veritabanı şeması yeniden yüklendi!", "Database rebuilding....": "Veritabanı yeniden inşa ediliyor...", "Database rebuilt!": "Veritabanı yeniden inşa edildi!", "Site updated!": "Site güncellendi!", "Delete this site": "Bu siteyi sil", "File write error: ": "Dosya yazma hatası: ", "Site settings saved!": "Site ayarları kaydedildi!", "Enter your private key:": "Özel anahtarınızı giriniz:", " Signed!": " İmzala!", "WebGL not supported": "WebGL desteklenmiyor" } ================================================ FILE: plugins/Sidebar/languages/zh-tw.json ================================================ { "Peers": "節點數", "Connected": "已連線", "Connectable": "可連線", "Connectable peers": "可連線節點", "Data transfer": "數據傳輸", "Received": "已接收", "Received bytes": "已接收位元組", "Sent": "已傳送", "Sent bytes": "已傳送位元組", "Files": "檔案", "Total": "共計", "Image": "圖片", "Other": "其他", "User data": "使用者數據", "Size limit": "大小限制", "limit used": "已使用", "free space": "可用空間", "Set": "偏好設定", "Optional files": "可選檔案", "Downloaded": "已下載", "Download and help distribute all files": "下載並幫助分發所有檔案", "Total size": "總大小", "Downloaded files": "下載的檔案", "Database": "資料庫", "search feeds": "搜尋供稿", "{feeds} query": "{feeds} 查詢 ", "Reload": "重新整理", "Rebuild": "重建", "No database found": "未找到資料庫", "Identity address": "身分位址", "Change": "變更", "Site control": "網站控制", "Update": "更新", "Pause": "暫停", "Resume": "恢復", "Delete": "刪除", "Are you sure?": "你確定?", "Site address": "網站位址", "Donate": "捐贈", "Missing files": "缺少的檔案", "{} try": "{} 嘗試", "{} tries": "{} 已嘗試", "+ {num_bad_files} more": "+ {num_bad_files} 更多", "This is my site": "這是我的網站", "Site title": "網站標題", "Site description": "網站描述", "Save site settings": "存儲網站設定", "Open site directory": "打開所在資料夾", "Content publishing": "內容發布", "Choose": "選擇", "Sign": "簽署", "Publish": "發布", "Sign and publish": "簽名並發布", "This function is disabled on this proxy": "此代理上禁用此功能", "GeoLite2 City database download error: {}!
    Please download manually and unpack to data dir:
    {}": "GeoLite2 地理位置資料庫下載錯誤:{}!
    請手動下載並解壓到數據目錄:
    {}", "Downloading GeoLite2 City database (one time only, ~20MB)...": "正在下載 GeoLite2 地理位置資料庫 (僅一次,約 20MB )...", "GeoLite2 City database downloaded!": "GeoLite2 地理位置資料庫已下載!", "Are you sure?": "你確定?", "Site storage limit modified!": "網站存儲限制已變更!", "Database schema reloaded!": "資料庫架構重新加載!", "Database rebuilding....": "資料庫重建中...", "Database rebuilt!": "資料庫已重建!", "Site updated!": "網站已更新!", "Delete this site": "刪除此網站", "File write error: ": "檔案寫入錯誤:", "Site settings saved!": "網站設置已保存!", "Enter your private key:": "輸入您的私鑰:", " Signed!": " 已簽署!", "WebGL not supported": "不支援 WebGL" } ================================================ FILE: plugins/Sidebar/languages/zh.json ================================================ { "Copy to clipboard": "复制到剪切板", "Peers": "节点数", "Connected": "已连接", "Connectable": "可连接", "Onion": "洋葱点", "Local": "局域网", "Connectable peers": "可连接节点", "Data transfer": "数据传输", "Received": "已接收", "Received bytes": "已接收字节", "Sent": "已发送", "Sent bytes": "已发送字节", "Files": "文件", "Save as .zip": "打包成zip文件", "Total": "总计", "Image": "图像", "Other": "其他", "User data": "用户数据", "Size limit": "大小限制", "limit used": "限额", "free space": "剩余空间", "Set": "设置", "Optional files": "可选文件", "Downloaded": "已下载", "Help distribute added optional files": "帮助分发新的可选文件", "Auto download big file size limit": "自动下载大文件大小限制", "Download previous files": "下载之前的文件", "Optional files download started": "可选文件下载启动", "Optional files downloaded": "可选文件下载完成", "Total size": "总大小", "Downloaded files": "已下载文件", "Database": "数据库", "search feeds": "搜索数据源", "{feeds} query": "{feeds} 请求", "Reload": "重载", "Rebuild": "重建", "No database found": "没有找到数据库", "Identity address": "身份地址", "Change": "更改", "Site control": "站点控制", "Update": "更新", "Pause": "暂停", "Resume": "恢复", "Delete": "删除", "Are you sure?": "您确定吗?", "Site address": "站点地址", "Donate": "捐赠", "Needs to be updated": "需要更新", "{} try": "{} 尝试", "{} tries": "{} 已尝试", "+ {num_bad_files} more": "+ {num_bad_files} 更多", "This is my site": "这是我的站点", "Site title": "站点标题", "Site description": "站点描述", "Save site settings": "保存站点设置", "Open site directory": "打开所在文件夹", "Content publishing": "内容发布", "Add saved private key": "添加并保存私钥", "Save": "保存", "Private key saved.": "私钥已保存", "Private key saved for site signing": "已保存用于站点签名的私钥", "Forgot": "删除私钥", "Saved private key removed": "保存的私钥已删除", "Choose": "选择", "Sign": "签名", "Publish": "发布", "Sign and publish": "签名并发布", "This function is disabled on this proxy": "此功能在代理上被禁用", "GeoLite2 City database download error: {}!
    Please download manually and unpack to data dir:
    {}": "GeoLite2 地理位置数据库下载错误:{}!
    请手动下载并解压在数据目录:
    {}", "Downloading GeoLite2 City database (one time only, ~20MB)...": "正在下载 GeoLite2 地理位置数据库 (仅需一次,约 20MB )...", "GeoLite2 City database downloaded!": "GeoLite2 地理位置数据库已下载!", "Are you sure?": "您确定吗?", "Site storage limit modified!": "站点存储限制已更改!", "Database schema reloaded!": "数据库模式已重新加载!", "Database rebuilding....": "数据库重建中...", "Database rebuilt!": "数据库已重建!", "Site updated!": "站点已更新!", "Delete this site": "删除此站点", "Blacklist": "黑名单", "Blacklist this site": "拉黑此站点", "Reason": "原因", "Delete and Blacklist": "删除并拉黑", "File write error: ": "文件写入错误:", "Site settings saved!": "站点设置已保存!", "Enter your private key:": "输入您的私钥:", " Signed!": " 已签名!", "WebGL not supported": "不支持 WebGL" } ================================================ FILE: plugins/Sidebar/media/Class.coffee ================================================ class Class trace: true log: (args...) -> return unless @trace return if typeof console is 'undefined' args.unshift("[#{@.constructor.name}]") console.log(args...) @ logStart: (name, args...) -> return unless @trace @logtimers or= {} @logtimers[name] = +(new Date) @log "#{name}", args..., "(started)" if args.length > 0 @ logEnd: (name, args...) -> ms = +(new Date)-@logtimers[name] @log "#{name}", args..., "(Done in #{ms}ms)" @ window.Class = Class ================================================ FILE: plugins/Sidebar/media/Console.coffee ================================================ class Console extends Class constructor: (@sidebar) -> @tag = null @opened = false @filter = null @tab_types = [ {title: "All", filter: ""}, {title: "Info", filter: "INFO"}, {title: "Warning", filter: "WARNING"}, {title: "Error", filter: "ERROR"} ] @read_size = 32 * 1024 @tab_active = "" #@filter = @sidebar.wrapper.site_info.address_short handleMessageWebsocket_original = @sidebar.wrapper.handleMessageWebsocket @sidebar.wrapper.handleMessageWebsocket = (message) => if message.cmd == "logLineAdd" and message.params.stream_id == @stream_id @addLines(message.params.lines) else handleMessageWebsocket_original(message) $(window).on "hashchange", => if window.top.location.hash.startsWith("#ZeroNet:Console") @open() if window.top.location.hash.startsWith("#ZeroNet:Console") setTimeout (=> @open()), 10 createHtmltag: -> if not @container @container = $("""
    Loading...
    """) @text = @container.find(".console-text") @text_elem = @text[0] @tabs = @container.find(".console-tabs") @text.on "mousewheel", (e) => # Stop animation on manual scrolling if e.originalEvent.deltaY < 0 @text.stop() RateLimit 300, @checkTextIsBottom @text.is_bottom = true @container.appendTo(document.body) @tag = @container.find(".console") for tab_type in @tab_types tab = $("", {href: "#", "data-filter": tab_type.filter, "data-title": tab_type.title}).text(tab_type.title) if tab_type.filter == @tab_active tab.addClass("active") tab.on("click", @handleTabClick) if window.top.location.hash.endsWith(tab_type.title) @log "Triggering click on", tab tab.trigger("click") @tabs.append(tab) @container.on "mousedown touchend touchcancel", (e) => if e.target != e.currentTarget return true @log "closing" if $(document.body).hasClass("body-console") @close() return true @loadConsoleText() checkTextIsBottom: => @text.is_bottom = Math.round(@text_elem.scrollTop + @text_elem.clientHeight) >= @text_elem.scrollHeight - 15 toColor: (text, saturation=60, lightness=70) -> hash = 0 for i in [0..text.length-1] hash += text.charCodeAt(i)*i hash = hash % 1777 return "hsl(" + (hash % 360) + ",#{saturation}%,#{lightness}%)"; formatLine: (line) => match = line.match(/(\[.*?\])[ ]+(.*?)[ ]+(.*?)[ ]+(.*)/) if not match return line.replace(/\/g, ">") [line, added, level, module, text] = line.match(/(\[.*?\])[ ]+(.*?)[ ]+(.*?)[ ]+(.*)/) added = "#{added}" level = "#{level}" module = "#{module}" text = text.replace(/(Site:[A-Za-z0-9\.]+)/g, "$1") text = text.replace(/\/g, ">") #text = text.replace(/( [0-9\.]+(|s|ms))/g, "$1") return "#{added} #{level} #{module} #{text}" addLines: (lines, animate=true) => html_lines = [] @logStart "formatting" for line in lines html_lines.push @formatLine(line) @logEnd "formatting" @logStart "adding" @text.append(html_lines.join("
    ") + "
    ") @logEnd "adding" if @text.is_bottom and animate @text.stop().animate({scrollTop: @text_elem.scrollHeight - @text_elem.clientHeight + 1}, 600, 'easeInOutCubic') loadConsoleText: => @sidebar.wrapper.ws.cmd "consoleLogRead", {filter: @filter, read_size: @read_size}, (res) => @text.html("") pos_diff = res["pos_end"] - res["pos_start"] size_read = Math.round(pos_diff/1024) size_total = Math.round(res['pos_end']/1024) @text.append("

    ") @text.append("Displaying #{res.lines.length} of #{res.num_found} lines found in the last #{size_read}kB of the log file. (#{size_total}kB total)
    ") @addLines res.lines, false @text_elem.scrollTop = @text_elem.scrollHeight if @stream_id @sidebar.wrapper.ws.cmd "consoleLogStreamRemove", {stream_id: @stream_id} @sidebar.wrapper.ws.cmd "consoleLogStream", {filter: @filter}, (res) => @stream_id = res.stream_id close: => window.top.location.hash = "" @sidebar.move_lock = "y" @sidebar.startDrag() @sidebar.stopDrag() open: => @sidebar.startDrag() @sidebar.moved("y") @sidebar.fixbutton_targety = @sidebar.page_height - @sidebar.fixbutton_inity - 50 @sidebar.stopDrag() onOpened: => @sidebar.onClosed() @log "onOpened" onClosed: => $(document.body).removeClass("body-console") if @stream_id @sidebar.wrapper.ws.cmd "consoleLogStreamRemove", {stream_id: @stream_id} cleanup: => if @container @container.remove() @container = null stopDragY: => # Animate sidebar and iframe if @sidebar.fixbutton_targety == @sidebar.fixbutton_inity # Closed targety = 0 @opened = false else # Opened targety = @sidebar.fixbutton_targety - @sidebar.fixbutton_inity @onOpened() @opened = true # Revent sidebar transitions if @tag @tag.css("transition", "0.5s ease-out") @tag.css("transform", "translateY(#{targety}px)").one transitionEnd, => @tag.css("transition", "") if not @opened @cleanup() # Revert body transformations @log "stopDragY", "opened:", @opened, targety if not @opened @onClosed() changeFilter: (filter) => @filter = filter if @filter == "" @read_size = 32 * 1024 else @read_size = 5 * 1024 * 1024 @loadConsoleText() handleTabClick: (e) => elem = $(e.currentTarget) @tab_active = elem.data("filter") $("a", @tabs).removeClass("active") elem.addClass("active") @changeFilter(@tab_active) window.top.location.hash = "#ZeroNet:Console:" + elem.data("title") return false window.Console = Console ================================================ FILE: plugins/Sidebar/media/Console.css ================================================ .console-container { width: 100%; z-index: 998; position: absolute; top: -100vh; padding-bottom: 100%; } .console-container .console { background-color: #212121; height: 100vh; transform: translateY(0px); padding-top: 80px; box-sizing: border-box; } .console-top { color: white; font-family: Consolas, monospace; font-size: 11px; line-height: 20px; height: 100%; box-sizing: border-box; letter-spacing: 0.5px;} .console-text { overflow-y: scroll; height: calc(100% - 10px); color: #DDD; padding: 5px; margin-top: -36px; overflow-wrap: break-word; } .console-tabs { background-color: #41193fad; position: relative; margin-right: 17px; /*backdrop-filter: blur(2px);*/ box-shadow: -30px 0px 45px #7d2463; background: linear-gradient(-75deg, #591a48ed, #70305e66); border-bottom: 1px solid #792e6473; } .console-tabs a { margin-right: 5px; padding: 5px 15px; text-decoration: none; color: #AAA; font-size: 11px; font-family: "Consolas"; text-transform: uppercase; border: 1px solid #666; border-bottom: 0px; display: inline-block; margin: 5px; margin-bottom: 0px; background-color: rgba(0,0,0,0.5); } .console-tabs a:hover { color: #FFF } .console-tabs a.active { background-color: #46223c; color: #FFF } .console-middle {height: 0px; top: 50%; position: absolute; width: 100%; left: 50%; display: none; } .console .mynode { border: 0.5px solid #aaa; width: 50px; height: 50px; transform: rotateZ(45deg); margin-top: -25px; margin-left: -25px; opacity: 1; display: inline-block; background-color: #EEE; z-index: 9; position: absolute; outline: 5px solid #EEE; } .console .peers { width: 0px; height: 0px; position: absolute; left: -20px; top: -20px; text-align: center; } .console .peer { left: 0px; top: 0px; position: absolute; } .console .peer .icon { width: 20px; height: 20px; padding: 10px; display: inline-block; text-decoration: none; left: 200px; position: absolute; color: #666; } .console .peer .icon:before { content: "\25BC"; position: absolute; margin-top: 3px; margin-left: -1px; opacity: 0; transition: all 0.3s } .console .peer .icon:hover:before { opacity: 1; transition: none } .console .peer .line { width: 187px; border-top: 1px solid #CCC; position: absolute; top: 20px; left: 20px; transform: rotateZ(334deg); transform-origin: bottom left; } ================================================ FILE: plugins/Sidebar/media/Menu.coffee ================================================ class Menu constructor: (@button) -> @elem = $(".menu.template").clone().removeClass("template") @elem.appendTo("body") @items = [] show: -> if window.visible_menu and window.visible_menu.button[0] == @button[0] # Same menu visible then hide it window.visible_menu.hide() @hide() else button_pos = @button.offset() left = button_pos.left @elem.css({"top": button_pos.top+@button.outerHeight(), "left": left}) @button.addClass("menu-active") @elem.addClass("visible") if @elem.position().left + @elem.width() + 20 > window.innerWidth @elem.css("left", window.innerWidth - @elem.width() - 20) if window.visible_menu then window.visible_menu.hide() window.visible_menu = @ hide: -> @elem.removeClass("visible") @button.removeClass("menu-active") window.visible_menu = null addItem: (title, cb) -> item = $(".menu-item.template", @elem).clone().removeClass("template") item.html(title) item.on "click", => if not cb(item) @hide() return false item.appendTo(@elem) @items.push item return item log: (args...) -> console.log "[Menu]", args... window.Menu = Menu # Hide menu on outside click $("body").on "click", (e) -> if window.visible_menu and e.target != window.visible_menu.button[0] and $(e.target).parent()[0] != window.visible_menu.elem[0] window.visible_menu.hide() ================================================ FILE: plugins/Sidebar/media/Menu.css ================================================ .menu { background-color: white; padding: 10px 0px; position: absolute; top: 0px; left: 0px; max-height: 0px; overflow: hidden; transform: translate(0px, -30px); pointer-events: none; box-shadow: 0px 2px 8px rgba(0,0,0,0.3); border-radius: 2px; opacity: 0; transition: opacity 0.2s ease-out, transform 1s ease-out, max-height 0.2s ease-in-out; } .menu.visible { opacity: 1; max-height: 350px; transform: translate(0px, 0px); transition: opacity 0.1s ease-out, transform 0.3s ease-out, max-height 0.3s ease-in-out; pointer-events: all } .menu-item { display: block; text-decoration: none; color: black; padding: 6px 24px; transition: all 0.2s; border-bottom: none; font-weight: normal; padding-left: 30px; } .menu-item-separator { margin-top: 5px; border-top: 1px solid #eee } .menu-item:hover { background-color: #F6F6F6; transition: none; color: inherit; border: none } .menu-item:active, .menu-item:focus { background-color: #AF3BFF; color: white; transition: none } .menu-item.selected:before { content: "L"; display: inline-block; transform: rotateZ(45deg) scaleX(-1); font-weight: bold; position: absolute; margin-left: -17px; font-size: 12px; margin-top: 2px; } @media only screen and (max-width: 800px) { .menu, .menu.visible { position: absolute; left: unset !important; right: 20px; } } ================================================ FILE: plugins/Sidebar/media/Prototypes.coffee ================================================ String::startsWith = (s) -> @[...s.length] is s String::endsWith = (s) -> s is '' or @[-s.length..] is s String::capitalize = -> if @.length then @[0].toUpperCase() + @.slice(1) else "" String::repeat = (count) -> new Array( count + 1 ).join(@) window.isEmpty = (obj) -> for key of obj return false return true ================================================ FILE: plugins/Sidebar/media/RateLimit.coffee ================================================ limits = {} call_after_interval = {} window.RateLimit = (interval, fn) -> if not limits[fn] call_after_interval[fn] = false fn() # First call is not delayed limits[fn] = setTimeout (-> if call_after_interval[fn] fn() delete limits[fn] delete call_after_interval[fn] ), interval else # Called within iterval, delay the call call_after_interval[fn] = true ================================================ FILE: plugins/Sidebar/media/Scrollable.js ================================================ /* via http://jsfiddle.net/elGrecode/00dgurnn/ */ window.initScrollable = function () { var scrollContainer = document.querySelector('.scrollable'), scrollContentWrapper = document.querySelector('.scrollable .content-wrapper'), scrollContent = document.querySelector('.scrollable .content'), contentPosition = 0, scrollerBeingDragged = false, scroller, topPosition, scrollerHeight; function calculateScrollerHeight() { // *Calculation of how tall scroller should be var visibleRatio = scrollContainer.offsetHeight / scrollContentWrapper.scrollHeight; if (visibleRatio == 1) scroller.style.display = "none"; else scroller.style.display = "block"; return visibleRatio * scrollContainer.offsetHeight; } function moveScroller(evt) { // Move Scroll bar to top offset var scrollPercentage = evt.target.scrollTop / scrollContentWrapper.scrollHeight; topPosition = scrollPercentage * (scrollContainer.offsetHeight - 5); // 5px arbitrary offset so scroll bar doesn't move too far beyond content wrapper bounding box scroller.style.top = topPosition + 'px'; } function startDrag(evt) { normalizedPosition = evt.pageY; contentPosition = scrollContentWrapper.scrollTop; scrollerBeingDragged = true; window.addEventListener('mousemove', scrollBarScroll); return false; } function stopDrag(evt) { scrollerBeingDragged = false; window.removeEventListener('mousemove', scrollBarScroll); } function scrollBarScroll(evt) { if (scrollerBeingDragged === true) { evt.preventDefault(); var mouseDifferential = evt.pageY - normalizedPosition; var scrollEquivalent = mouseDifferential * (scrollContentWrapper.scrollHeight / scrollContainer.offsetHeight); scrollContentWrapper.scrollTop = contentPosition + scrollEquivalent; } } function updateHeight() { scrollerHeight = calculateScrollerHeight() - 10; scroller.style.height = scrollerHeight + 'px'; } function createScroller() { // *Creates scroller element and appends to '.scrollable' div // create scroller element scroller = document.createElement("div"); scroller.className = 'scroller'; // determine how big scroller should be based on content scrollerHeight = calculateScrollerHeight() - 10; if (scrollerHeight / scrollContainer.offsetHeight < 1) { // *If there is a need to have scroll bar based on content size scroller.style.height = scrollerHeight + 'px'; // append scroller to scrollContainer div scrollContainer.appendChild(scroller); // show scroll path divot scrollContainer.className += ' showScroll'; // attach related draggable listeners scroller.addEventListener('mousedown', startDrag); window.addEventListener('mouseup', stopDrag); } } createScroller(); // *** Listeners *** scrollContentWrapper.addEventListener('scroll', moveScroller); return updateHeight; }; ================================================ FILE: plugins/Sidebar/media/Scrollbable.css ================================================ .scrollable { overflow: hidden; } .scrollable.showScroll::after { position: absolute; content: ''; top: 5%; right: 7px; height: 90%; width: 3px; background: rgba(224, 224, 255, .3); } .scrollable .content-wrapper { width: 100%; height: 100%; padding-right: 50%; overflow-y: scroll; } .scroller { margin-top: 5px; z-index: 5; cursor: pointer; position: absolute; width: 7px; border-radius: 5px; background: #3A3A3A; top: 0px; left: 395px; -webkit-transition: top .08s; -moz-transition: top .08s; -ms-transition: top .08s; -o-transition: top .08s; transition: top .08s; } .scroller { -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } ================================================ FILE: plugins/Sidebar/media/Sidebar.coffee ================================================ class Sidebar extends Class constructor: (@wrapper) -> @tag = null @container = null @opened = false @width = 410 @console = new Console(@) @fixbutton = $(".fixbutton") @fixbutton_addx = 0 @fixbutton_addy = 0 @fixbutton_initx = 0 @fixbutton_inity = 15 @fixbutton_targetx = 0 @move_lock = null @page_width = $(window).width() @page_height = $(window).height() @frame = $("#inner-iframe") @initFixbutton() @dragStarted = 0 @globe = null @preload_html = null @original_set_site_info = @wrapper.setSiteInfo # We going to override this, save the original # Start in opened state for debugging if window.top.location.hash == "#ZeroNet:OpenSidebar" @startDrag() @moved("x") @fixbutton_targetx = @fixbutton_initx - @width @stopDrag() initFixbutton: -> # Detect dragging @fixbutton.on "mousedown touchstart", (e) => if e.button > 0 # Right or middle click return e.preventDefault() # Disable previous listeners @fixbutton.off "click touchend touchcancel" # Make sure its not a click @dragStarted = (+ new Date) # Fullscreen drag bg to capture mouse events over iframe $(".drag-bg").remove() $("
    ").appendTo(document.body) $("body").one "mousemove touchmove", (e) => mousex = e.pageX mousey = e.pageY if not mousex mousex = e.originalEvent.touches[0].pageX mousey = e.originalEvent.touches[0].pageY @fixbutton_addx = @fixbutton.offset().left - mousex @fixbutton_addy = @fixbutton.offset().top - mousey @startDrag() @fixbutton.parent().on "click touchend touchcancel", (e) => if (+ new Date) - @dragStarted < 100 window.top.location = @fixbutton.find(".fixbutton-bg").attr("href") @stopDrag() @resized() $(window).on "resize", @resized resized: => @page_width = $(window).width() @page_height = $(window).height() @fixbutton_initx = @page_width - 75 # Initial x position if @opened @fixbutton.css left: @fixbutton_initx - @width else @fixbutton.css left: @fixbutton_initx # Start dragging the fixbutton startDrag: -> #@move_lock = "x" # Temporary until internals not finished @log "startDrag", @fixbutton_initx, @fixbutton_inity @fixbutton_targetx = @fixbutton_initx # Fallback x position @fixbutton_targety = @fixbutton_inity # Fallback y position @fixbutton.addClass("dragging") # IE position wrap fix if navigator.userAgent.indexOf('MSIE') != -1 or navigator.appVersion.indexOf('Trident/') > 0 @fixbutton.css("pointer-events", "none") # Don't go to homepage @fixbutton.one "click", (e) => @stopDrag() @fixbutton.removeClass("dragging") moved_x = Math.abs(@fixbutton.offset().left - @fixbutton_initx) moved_y = Math.abs(@fixbutton.offset().top - @fixbutton_inity) if moved_x > 5 or moved_y > 10 # If moved more than some pixel the button then don't go to homepage e.preventDefault() # Animate drag @fixbutton.parents().on "mousemove touchmove", @animDrag @fixbutton.parents().on "mousemove touchmove" ,@waitMove # Stop dragging listener @fixbutton.parents().one "mouseup touchend touchcancel", (e) => e.preventDefault() @stopDrag() # Wait for moving the fixbutton waitMove: (e) => document.body.style.perspective = "1000px" document.body.style.height = "100%" document.body.style.willChange = "perspective" document.documentElement.style.height = "100%" #$(document.body).css("backface-visibility", "hidden").css("perspective", "1000px").css("height", "900px") # $("iframe").css("backface-visibility", "hidden") moved_x = Math.abs(parseInt(@fixbutton[0].style.left) - @fixbutton_targetx) moved_y = Math.abs(parseInt(@fixbutton[0].style.top) - @fixbutton_targety) if moved_x > 5 and (+ new Date) - @dragStarted + moved_x > 50 @moved("x") @fixbutton.stop().animate {"top": @fixbutton_inity}, 1000 @fixbutton.parents().off "mousemove touchmove" ,@waitMove else if moved_y > 5 and (+ new Date) - @dragStarted + moved_y > 50 @moved("y") @fixbutton.parents().off "mousemove touchmove" ,@waitMove moved: (direction) -> @log "Moved", direction @move_lock = direction if direction == "y" $(document.body).addClass("body-console") return @console.createHtmltag() @createHtmltag() $(document.body).addClass("body-sidebar") @container.on "mousedown touchend touchcancel", (e) => if e.target != e.currentTarget return true @log "closing" if $(document.body).hasClass("body-sidebar") @close() return true $(window).off "resize" $(window).on "resize", => $(document.body).css "height", $(window).height() @scrollable() @resized() # Override setsiteinfo to catch changes @wrapper.setSiteInfo = (site_info) => @setSiteInfo(site_info) @original_set_site_info.apply(@wrapper, arguments) # Preload world.jpg img = new Image(); img.src = "/uimedia/globe/world.jpg"; setSiteInfo: (site_info) -> RateLimit 1500, => @updateHtmlTag() RateLimit 30000, => @displayGlobe() # Create the sidebar html tag createHtmltag: -> @when_loaded = $.Deferred() if not @container @container = $(""" """) @container.appendTo(document.body) @tag = @container.find(".sidebar") @updateHtmlTag() @scrollable = window.initScrollable() updateHtmlTag: -> if @preload_html @setHtmlTag(@preload_html) @preload_html = null else @wrapper.ws.cmd "sidebarGetHtmlTag", {}, @setHtmlTag setHtmlTag: (res) => if @tag.find(".content").children().length == 0 # First update @log "Creating content" @container.addClass("loaded") morphdom(@tag.find(".content")[0], '
    '+res+'
    ') # @scrollable() @when_loaded.resolve() else # Not first update, patch the html to keep unchanged dom elements morphdom @tag.find(".content")[0], '
    '+res+'
    ', { onBeforeMorphEl: (from_el, to_el) -> # Ignore globe loaded state if from_el.className == "globe" or from_el.className.indexOf("noupdate") >= 0 return false else return true } # Save and forget privatekey for site signing @tag.find("#privatekey-add").off("click, touchend").on "click touchend", (e) => @wrapper.displayPrompt "Enter your private key:", "password", "Save", "", (privatekey) => @wrapper.ws.cmd "userSetSitePrivatekey", [privatekey], (res) => @wrapper.notifications.add "privatekey", "done", "Private key saved for site signing", 5000 return false @tag.find("#privatekey-forget").off("click, touchend").on "click touchend", (e) => @wrapper.displayConfirm "Remove saved private key for this site?", "Forget", (res) => if not res return false @wrapper.ws.cmd "userSetSitePrivatekey", [""], (res) => @wrapper.notifications.add "privatekey", "done", "Saved private key removed", 5000 return false # Use requested address for browse files urls @tag.find("#browse-files").attr("href", document.location.pathname.replace(/(\/.*?(\/|$)).*$/, "/list$1")) animDrag: (e) => mousex = e.pageX mousey = e.pageY if not mousex and e.originalEvent.touches mousex = e.originalEvent.touches[0].pageX mousey = e.originalEvent.touches[0].pageY overdrag = @fixbutton_initx - @width - mousex if overdrag > 0 # Overdragged overdrag_percent = 1 + overdrag/300 mousex = (mousex + (@fixbutton_initx-@width)*overdrag_percent)/(1+overdrag_percent) targetx = @fixbutton_initx - mousex - @fixbutton_addx targety = @fixbutton_inity - mousey - @fixbutton_addy if @move_lock == "x" targety = @fixbutton_inity else if @move_lock == "y" targetx = @fixbutton_initx if not @move_lock or @move_lock == "x" @fixbutton[0].style.left = (mousex + @fixbutton_addx) + "px" if @tag @tag[0].style.transform = "translateX(#{0 - targetx}px)" if not @move_lock or @move_lock == "y" @fixbutton[0].style.top = (mousey + @fixbutton_addy) + "px" if @console.tag @console.tag[0].style.transform = "translateY(#{0 - targety}px)" #if @move_lock == "x" # @fixbutton[0].style.left = "#{@fixbutton_targetx} px" #@fixbutton[0].style.top = "#{@fixbutton_inity}px" #if @move_lock == "y" # @fixbutton[0].style.top = "#{@fixbutton_targety} px" # Check if opened if (not @opened and targetx > @width/3) or (@opened and targetx > @width*0.9) @fixbutton_targetx = @fixbutton_initx - @width # Make it opened else @fixbutton_targetx = @fixbutton_initx if (not @console.opened and 0 - targety > @page_height/10) or (@console.opened and 0 - targety > @page_height*0.8) @fixbutton_targety = @page_height - @fixbutton_inity - 50 else @fixbutton_targety = @fixbutton_inity # Stop dragging the fixbutton stopDrag: -> @fixbutton.parents().off "mousemove touchmove" @fixbutton.off "mousemove touchmove" @fixbutton.css("pointer-events", "") $(".drag-bg").remove() if not @fixbutton.hasClass("dragging") return @fixbutton.removeClass("dragging") # Move back to initial position if @fixbutton_targetx != @fixbutton.offset().left or @fixbutton_targety != @fixbutton.offset().top # Animate fixbutton if @move_lock == "y" top = @fixbutton_targety left = @fixbutton_initx if @move_lock == "x" top = @fixbutton_inity left = @fixbutton_targetx @fixbutton.stop().animate {"left": left, "top": top}, 500, "easeOutBack", => # Switch back to auto align if @fixbutton_targetx == @fixbutton_initx # Closed @fixbutton.css("left", "auto") else # Opened @fixbutton.css("left", left) $(".fixbutton-bg").trigger "mouseout" # Switch fixbutton back to normal status @stopDragX() @console.stopDragY() @move_lock = null stopDragX: -> # Animate sidebar and iframe if @fixbutton_targetx == @fixbutton_initx or @move_lock == "y" # Closed targetx = 0 @opened = false else # Opened targetx = @width if @opened @onOpened() else @when_loaded.done => @onOpened() @opened = true # Revent sidebar transitions if @tag @tag.css("transition", "0.4s ease-out") @tag.css("transform", "translateX(-#{targetx}px)").one transitionEnd, => @tag.css("transition", "") if not @opened @container.remove() @container = null if @tag @tag.remove() @tag = null # Revert body transformations @log "stopdrag", "opened:", @opened if not @opened @onClosed() sign: (inner_path, privatekey) -> @wrapper.displayProgress("sign", "Signing: #{inner_path}...", 0) @wrapper.ws.cmd "siteSign", {privatekey: privatekey, inner_path: inner_path, update_changed_files: true}, (res) => if res == "ok" @wrapper.displayProgress("sign", "#{inner_path} signed!", 100) else @wrapper.displayProgress("sign", "Error signing #{inner_path}", -1) publish: (inner_path, privatekey) -> @wrapper.ws.cmd "sitePublish", {privatekey: privatekey, inner_path: inner_path, sign: true, update_changed_files: true}, (res) => if res == "ok" @wrapper.notifications.add "sign", "done", "#{inner_path} Signed and published!", 5000 handleSiteDeleteClick: -> if @wrapper.site_info.privatekey question = "Are you sure?
    This site has a saved private key" options = ["Forget private key and delete site"] else question = "Are you sure?" options = ["Delete this site", "Blacklist"] @wrapper.displayConfirm question, options, (confirmed) => if confirmed == 1 @tag.find("#button-delete").addClass("loading") @wrapper.ws.cmd "siteDelete", @wrapper.site_info.address, -> document.location = $(".fixbutton-bg").attr("href") else if confirmed == 2 @wrapper.displayPrompt "Blacklist this site", "text", "Delete and Blacklist", "Reason", (reason) => @tag.find("#button-delete").addClass("loading") @wrapper.ws.cmd "siteblockAdd", [@wrapper.site_info.address, reason] @wrapper.ws.cmd "siteDelete", @wrapper.site_info.address, -> document.location = $(".fixbutton-bg").attr("href") onOpened: -> @log "Opened" @scrollable() # Re-calculate height when site admin opened or closed @tag.find("#checkbox-owned, #checkbox-autodownloadoptional").off("click touchend").on "click touchend", => setTimeout (=> @scrollable() ), 300 # Site limit button @tag.find("#button-sitelimit").off("click touchend").on "click touchend", => @wrapper.ws.cmd "siteSetLimit", $("#input-sitelimit").val(), (res) => if res == "ok" @wrapper.notifications.add "done-sitelimit", "done", "Site storage limit modified!", 5000 @updateHtmlTag() return false # Site autodownload limit button @tag.find("#button-autodownload_bigfile_size_limit").off("click touchend").on "click touchend", => @wrapper.ws.cmd "siteSetAutodownloadBigfileLimit", $("#input-autodownload_bigfile_size_limit").val(), (res) => if res == "ok" @wrapper.notifications.add "done-bigfilelimit", "done", "Site bigfile auto download limit modified!", 5000 @updateHtmlTag() return false # Site start download optional files @tag.find("#button-autodownload_previous").off("click touchend").on "click touchend", => @wrapper.ws.cmd "siteUpdate", {"address": @wrapper.site_info.address, "check_files": true}, => @wrapper.notifications.add "done-download_optional", "done", "Optional files downloaded", 5000 @wrapper.notifications.add "start-download_optional", "info", "Optional files download started", 5000 return false # Database reload @tag.find("#button-dbreload").off("click touchend").on "click touchend", => @wrapper.ws.cmd "dbReload", [], => @wrapper.notifications.add "done-dbreload", "done", "Database schema reloaded!", 5000 @updateHtmlTag() return false # Database rebuild @tag.find("#button-dbrebuild").off("click touchend").on "click touchend", => @wrapper.notifications.add "done-dbrebuild", "info", "Database rebuilding...." @wrapper.ws.cmd "dbRebuild", [], => @wrapper.notifications.add "done-dbrebuild", "done", "Database rebuilt!", 5000 @updateHtmlTag() return false # Update site @tag.find("#button-update").off("click touchend").on "click touchend", => @tag.find("#button-update").addClass("loading") @wrapper.ws.cmd "siteUpdate", @wrapper.site_info.address, => @wrapper.notifications.add "done-updated", "done", "Site updated!", 5000 @tag.find("#button-update").removeClass("loading") return false # Pause site @tag.find("#button-pause").off("click touchend").on "click touchend", => @tag.find("#button-pause").addClass("hidden") @wrapper.ws.cmd "sitePause", @wrapper.site_info.address return false # Resume site @tag.find("#button-resume").off("click touchend").on "click touchend", => @tag.find("#button-resume").addClass("hidden") @wrapper.ws.cmd "siteResume", @wrapper.site_info.address return false # Delete site @tag.find("#button-delete").off("click touchend").on "click touchend", => @handleSiteDeleteClick() return false # Owned checkbox @tag.find("#checkbox-owned").off("click touchend").on "click touchend", => owned = @tag.find("#checkbox-owned").is(":checked") @wrapper.ws.cmd "siteSetOwned", [owned], (res_set_owned) => @log "Owned", owned if owned @wrapper.ws.cmd "siteRecoverPrivatekey", [], (res_recover) => if res_recover == "ok" @wrapper.notifications.add("recover", "done", "Private key recovered from master seed", 5000) else @log "Unable to recover private key: #{res_recover.error}" # Owned auto download checkbox @tag.find("#checkbox-autodownloadoptional").off("click touchend").on "click touchend", => @wrapper.ws.cmd "siteSetAutodownloadoptional", [@tag.find("#checkbox-autodownloadoptional").is(":checked")] # Change identity button @tag.find("#button-identity").off("click touchend").on "click touchend", => @wrapper.ws.cmd "certSelect" return false # Save settings @tag.find("#button-settings").off("click touchend").on "click touchend", => @wrapper.ws.cmd "fileGet", "content.json", (res) => data = JSON.parse(res) data["title"] = $("#settings-title").val() data["description"] = $("#settings-description").val() json_raw = unescape(encodeURIComponent(JSON.stringify(data, undefined, '\t'))) @wrapper.ws.cmd "fileWrite", ["content.json", btoa(json_raw), true], (res) => if res != "ok" # fileWrite failed @wrapper.notifications.add "file-write", "error", "File write error: #{res}" else @wrapper.notifications.add "file-write", "done", "Site settings saved!", 5000 if @wrapper.site_info.privatekey @wrapper.ws.cmd "siteSign", {privatekey: "stored", inner_path: "content.json", update_changed_files: true} @updateHtmlTag() return false # Open site directory @tag.find("#link-directory").off("click touchend").on "click touchend", => @wrapper.ws.cmd "serverShowdirectory", ["site", @wrapper.site_info.address] return false # Copy site with peers @tag.find("#link-copypeers").off("click touchend").on "click touchend", (e) => copy_text = e.currentTarget.href handler = (e) => e.clipboardData.setData('text/plain', copy_text) e.preventDefault() @wrapper.notifications.add "copy", "done", "Site address with peers copied to your clipboard", 5000 document.removeEventListener('copy', handler, true) document.addEventListener('copy', handler, true) document.execCommand('copy') return false # Sign and publish content.json $(document).on "click touchend", => @tag?.find("#button-sign-publish-menu").removeClass("visible") @tag?.find(".contents + .flex").removeClass("sign-publish-flex") @tag.find(".contents-content").off("click touchend").on "click touchend", (e) => $("#input-contents").val(e.currentTarget.innerText); return false; menu = new Menu(@tag.find("#menu-sign-publish")) menu.elem.css("margin-top", "-130px") # Open upwards menu.addItem "Sign", => inner_path = @tag.find("#input-contents").val() @wrapper.ws.cmd "fileRules", {inner_path: inner_path}, (rules) => if @wrapper.site_info.auth_address in rules.signers # ZeroID or other ID provider @sign(inner_path) else if @wrapper.site_info.privatekey # Privatekey stored in users.json @sign(inner_path, "stored") else # Ask the user for privatekey @wrapper.displayPrompt "Enter your private key:", "password", "Sign", "", (privatekey) => # Prompt the private key @sign(inner_path, privatekey) @tag.find(".contents + .flex").removeClass "active" menu.hide() menu.addItem "Publish", => inner_path = @tag.find("#input-contents").val() @wrapper.ws.cmd "sitePublish", {"inner_path": inner_path, "sign": false} @tag.find(".contents + .flex").removeClass "active" menu.hide() @tag.find("#menu-sign-publish").off("click touchend").on "click touchend", => if window.visible_menu == menu @tag.find(".contents + .flex").removeClass "active" menu.hide() else @tag.find(".contents + .flex").addClass "active" @tag.find(".content-wrapper").prop "scrollTop", 10000 menu.show() return false $("body").on "click", => if @tag @tag.find(".contents + .flex").removeClass "active" @tag.find("#button-sign-publish").off("click touchend").on "click touchend", => inner_path = @tag.find("#input-contents").val() @wrapper.ws.cmd "fileRules", {inner_path: inner_path}, (rules) => if @wrapper.site_info.auth_address in rules.signers # ZeroID or other ID provider @publish(inner_path, null) else if @wrapper.site_info.privatekey # Privatekey stored in users.json @publish(inner_path, "stored") else # Ask the user for privatekey @wrapper.displayPrompt "Enter your private key:", "password", "Sign", "", (privatekey) => # Prompt the private key @publish(inner_path, privatekey) return false # Close @tag.find(".close").off("click touchend").on "click touchend", (e) => @close() return false @loadGlobe() close: -> @move_lock = "x" @startDrag() @stopDrag() onClosed: -> $(window).off "resize" $(window).on "resize", @resized $(document.body).css("transition", "0.6s ease-in-out").removeClass("body-sidebar").on transitionEnd, (e) => if e.target == document.body and not $(document.body).hasClass("body-sidebar") and not $(document.body).hasClass("body-console") $(document.body).css("height", "auto").css("perspective", "").css("will-change", "").css("transition", "").off transitionEnd @unloadGlobe() # We dont need site info anymore @wrapper.setSiteInfo = @original_set_site_info loadGlobe: => if @tag.find(".globe").hasClass("loading") setTimeout (=> if typeof(DAT) == "undefined" # Globe script not loaded, do it first script_tag = $(" ================================================ FILE: plugins/UiConfig/media/css/Config.css ================================================ body { background-color: #EDF2F5; font-family: Roboto, 'Segoe UI', Arial, 'Helvetica Neue'; margin: 0px; padding: 0px; backface-visibility: hidden; } h1, h2, h3, h4 { font-family: 'Roboto', Arial, sans-serif; font-weight: 200; font-size: 30px; margin: 0px; padding: 0px } h1 { background: linear-gradient(33deg,#af3bff,#0d99c9); color: white; padding: 16px 30px; } h2 { margin-top: 10px; } h3 { font-weight: normal } a { color: #9760F9 } a:hover { text-decoration: none } .link { background-color: transparent; outline: 5px solid transparent; transition: all 0.3s } .link:active { background-color: #EFEFEF; outline: 5px solid #EFEFEF; transition: none } .content { max-width: 800px; margin: auto; background-color: white; padding: 60px 20px; box-sizing: border-box; padding-bottom: 150px; } .section { margin: 0px 10%; } .config-items { font-size: 19px; margin-top: 25px; margin-bottom: 75px; } .config-item { transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); position: relative; padding-bottom: 20px; padding-top: 10px; } .config-item.hidden { opacity: 0; height: 0px; padding: 0px; } .config-item .title { display: inline-block; line-height: 36px; } .config-item .title h3 { font-size: 20px; font-weight: lighter; margin-right: 100px; } .config-item .description { font-size: 14px; color: #666; line-height: 24px; } .config-item .value { display: inline-block; white-space: nowrap; } .config-item .value-right { right: 0px; position: absolute; } .config-item .value-fullwidth { width: 100% } .config-item .marker { font-weight: bold; text-decoration: none; font-size: 25px; position: absolute; padding: 2px 15px; line-height: 32px; opacity: 0; pointer-events: none; transition: all 0.6s; transform: scale(2); color: #9760F9; } .config-item .marker.visible { opacity: 1; pointer-events: all; transform: scale(1); } .config-item .marker.changed { color: #2ecc71; } .config-item .marker.pending { color: #ffa200; } .input-text, .input-select { padding: 8px 18px; border: 1px solid #CCC; border-radius: 3px; font-size: 17px; box-sizing: border-box; } .input-text:focus, .input-select:focus { border: 1px solid #3396ff; outline: none; } .input-textarea { overflow-x: auto; overflow-y: hidden; white-space: pre; line-height: 22px; } .input-select { width: initial; font-size: 14px; padding-right: 10px; padding-left: 10px; } .value-right .input-text { text-align: right; width: 100px; } .value-fullwidth .input-text { width: 100%; font-size: 14px; font-family: 'Segoe UI', Arial, 'Helvetica Neue'; } .value-fullwidth { margin-top: 10px; } /* Checkbox */ .checkbox-skin { background-color: #CCC; width: 50px; height: 24px; border-radius: 15px; transition: all 0.3s ease-in-out; display: inline-block; } .checkbox-skin:before { content: ""; position: relative; width: 20px; background-color: white; height: 20px; display: block; border-radius: 100%; margin-top: 2px; margin-left: 2px; transition: all 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86); } .checkbox { font-size: 14px; font-weight: normal; display: inline-block; cursor: pointer; margin-top: 5px; } .checkbox .title { display: inline; line-height: 30px; vertical-align: 4px; margin-left: 11px } .checkbox.checked .checkbox-skin:before { margin-left: 27px; } .checkbox.checked .checkbox-skin { background-color: #2ECC71 } /* Bottom */ .bottom { width: 100%; text-align: center; background-color: #ffffffde; padding: 25px; bottom: -120px; -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); position: fixed; backface-visibility: hidden; box-sizing: border-box; } .bottom-content { max-width: 750px; width: 100%; margin: 0px auto; } .bottom .button { float: right; } .bottom.visible { bottom: 0px; box-shadow: 0px 0px 35px #dcdcdc; } .bottom .title { padding: 10px 10px; color: #363636; float: left; text-transform: uppercase; letter-spacing: 1px; } .bottom .title:before { content: "•"; display: inline-block; color: #2ecc71; font-size: 31px; vertical-align: -7px; margin-right: 8px; line-height: 25px; } .bottom-restart .title:before { color: #ffa200; } .animate { transition: all 0.3s ease-out !important; } .animate-back { transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important; } .animate-inout { transition: all 0.6s cubic-bezier(0.77, 0, 0.175, 1) !important; } ================================================ FILE: plugins/UiConfig/media/css/all.css ================================================ /* ---- Config.css ---- */ body { background-color: #EDF2F5; font-family: Roboto, 'Segoe UI', Arial, 'Helvetica Neue'; margin: 0px; padding: 0px; -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; -o-backface-visibility: hidden; -ms-backface-visibility: hidden; backface-visibility: hidden ; } h1, h2, h3, h4 { font-family: 'Roboto', Arial, sans-serif; font-weight: 200; font-size: 30px; margin: 0px; padding: 0px } h1 { background: -webkit-linear-gradient(33deg,#af3bff,#0d99c9);background: -moz-linear-gradient(33deg,#af3bff,#0d99c9);background: -o-linear-gradient(33deg,#af3bff,#0d99c9);background: -ms-linear-gradient(33deg,#af3bff,#0d99c9);background: linear-gradient(33deg,#af3bff,#0d99c9); color: white; padding: 16px 30px; } h2 { margin-top: 10px; } h3 { font-weight: normal } a { color: #9760F9 } a:hover { text-decoration: none } .link { background-color: transparent; outline: 5px solid transparent; -webkit-transition: all 0.3s ; -moz-transition: all 0.3s ; -o-transition: all 0.3s ; -ms-transition: all 0.3s ; transition: all 0.3s } .link:active { background-color: #EFEFEF; outline: 5px solid #EFEFEF; -webkit-transition: none ; -moz-transition: none ; -o-transition: none ; -ms-transition: none ; transition: none } .content { max-width: 800px; margin: auto; background-color: white; padding: 60px 20px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; padding-bottom: 150px; } .section { margin: 0px 10%; } .config-items { font-size: 19px; margin-top: 25px; margin-bottom: 75px; } .config-item { -webkit-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); -moz-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); -o-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); -ms-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1) ; position: relative; padding-bottom: 20px; padding-top: 10px; } .config-item.hidden { opacity: 0; height: 0px; padding: 0px; } .config-item .title { display: inline-block; line-height: 36px; } .config-item .title h3 { font-size: 20px; font-weight: lighter; margin-right: 100px; } .config-item .description { font-size: 14px; color: #666; line-height: 24px; } .config-item .value { display: inline-block; white-space: nowrap; } .config-item .value-right { right: 0px; position: absolute; } .config-item .value-fullwidth { width: 100% } .config-item .marker { font-weight: bold; text-decoration: none; font-size: 25px; position: absolute; padding: 2px 15px; line-height: 32px; opacity: 0; pointer-events: none; -webkit-transition: all 0.6s; -moz-transition: all 0.6s; -o-transition: all 0.6s; -ms-transition: all 0.6s; transition: all 0.6s ; -webkit-transform: scale(2); -moz-transform: scale(2); -o-transform: scale(2); -ms-transform: scale(2); transform: scale(2) ; color: #9760F9; } .config-item .marker.visible { opacity: 1; pointer-events: all; -webkit-transform: scale(1); -moz-transform: scale(1); -o-transform: scale(1); -ms-transform: scale(1); transform: scale(1) ; } .config-item .marker.changed { color: #2ecc71; } .config-item .marker.pending { color: #ffa200; } .input-text, .input-select { padding: 8px 18px; border: 1px solid #CCC; -webkit-border-radius: 3px; -moz-border-radius: 3px; -o-border-radius: 3px; -ms-border-radius: 3px; border-radius: 3px ; font-size: 17px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; } .input-text:focus, .input-select:focus { border: 1px solid #3396ff; outline: none; } .input-textarea { overflow-x: auto; overflow-y: hidden; white-space: pre; line-height: 22px; } .input-select { width: initial; font-size: 14px; padding-right: 10px; padding-left: 10px; } .value-right .input-text { text-align: right; width: 100px; } .value-fullwidth .input-text { width: 100%; font-size: 14px; font-family: 'Segoe UI', Arial, 'Helvetica Neue'; } .value-fullwidth { margin-top: 10px; } /* Checkbox */ .checkbox-skin { background-color: #CCC; width: 50px; height: 24px; -webkit-border-radius: 15px; -moz-border-radius: 15px; -o-border-radius: 15px; -ms-border-radius: 15px; border-radius: 15px ; -webkit-transition: all 0.3s ease-in-out; -moz-transition: all 0.3s ease-in-out; -o-transition: all 0.3s ease-in-out; -ms-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out ; display: inline-block; } .checkbox-skin:before { content: ""; position: relative; width: 20px; background-color: white; height: 20px; display: block; -webkit-border-radius: 100%; -moz-border-radius: 100%; -o-border-radius: 100%; -ms-border-radius: 100%; border-radius: 100% ; margin-top: 2px; margin-left: 2px; -webkit-transition: all 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86); -moz-transition: all 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86); -o-transition: all 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86); -ms-transition: all 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86); transition: all 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86) ; } .checkbox { font-size: 14px; font-weight: normal; display: inline-block; cursor: pointer; margin-top: 5px; } .checkbox .title { display: inline; line-height: 30px; vertical-align: 4px; margin-left: 11px } .checkbox.checked .checkbox-skin:before { margin-left: 27px; } .checkbox.checked .checkbox-skin { background-color: #2ECC71 } /* Bottom */ .bottom { width: 100%; text-align: center; background-color: #ffffffde; padding: 25px; bottom: -120px; -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); -webkit-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); -moz-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); -o-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); -ms-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1) ; position: fixed; -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; -o-backface-visibility: hidden; -ms-backface-visibility: hidden; backface-visibility: hidden ; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; } .bottom-content { max-width: 750px; width: 100%; margin: 0px auto; } .bottom .button { float: right; } .bottom.visible { bottom: 0px; -webkit-box-shadow: 0px 0px 35px #dcdcdc; -moz-box-shadow: 0px 0px 35px #dcdcdc; -o-box-shadow: 0px 0px 35px #dcdcdc; -ms-box-shadow: 0px 0px 35px #dcdcdc; box-shadow: 0px 0px 35px #dcdcdc ; } .bottom .title { padding: 10px 10px; color: #363636; float: left; text-transform: uppercase; letter-spacing: 1px; } .bottom .title:before { content: "•"; display: inline-block; color: #2ecc71; font-size: 31px; vertical-align: -7px; margin-right: 8px; line-height: 25px; } .bottom-restart .title:before { color: #ffa200; } .animate { -webkit-transition: all 0.3s ease-out !important; -moz-transition: all 0.3s ease-out !important; -o-transition: all 0.3s ease-out !important; -ms-transition: all 0.3s ease-out !important; transition: all 0.3s ease-out !important ; } .animate-back { -webkit-transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important; -moz-transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important; -o-transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important; -ms-transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important; transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important ; } .animate-inout { -webkit-transition: all 0.6s cubic-bezier(0.77, 0, 0.175, 1) !important; -moz-transition: all 0.6s cubic-bezier(0.77, 0, 0.175, 1) !important; -o-transition: all 0.6s cubic-bezier(0.77, 0, 0.175, 1) !important; -ms-transition: all 0.6s cubic-bezier(0.77, 0, 0.175, 1) !important; transition: all 0.6s cubic-bezier(0.77, 0, 0.175, 1) !important ; } /* ---- button.css ---- */ /* Button */ .button { background-color: #FFDC00; color: black; padding: 10px 20px; display: inline-block; background-position: left center; -webkit-border-radius: 2px; -moz-border-radius: 2px; -o-border-radius: 2px; -ms-border-radius: 2px; border-radius: 2px ; border-bottom: 2px solid #E8BE29; -webkit-transition: all 0.5s ease-out; -moz-transition: all 0.5s ease-out; -o-transition: all 0.5s ease-out; -ms-transition: all 0.5s ease-out; transition: all 0.5s ease-out ; text-decoration: none; } .button:hover { border-color: white; border-bottom: 2px solid #BD960C; -webkit-transition: none ; -moz-transition: none ; -o-transition: none ; -ms-transition: none ; transition: none ; background-color: #FDEB07 } .button:active { position: relative; top: 1px } .button.loading { color: rgba(0,0,0,0); background: #999 url(../img/loading.gif) no-repeat center center; -webkit-transition: all 0.5s ease-out ; -moz-transition: all 0.5s ease-out ; -o-transition: all 0.5s ease-out ; -ms-transition: all 0.5s ease-out ; transition: all 0.5s ease-out ; pointer-events: none; border-bottom: 2px solid #666 } .button.disabled { color: #DDD; background-color: #999; pointer-events: none; border-bottom: 2px solid #666 } /* ---- fonts.css ---- */ /* Base64 encoder: http://www.motobit.com/util/base64-decoder-encoder.asp */ /* Generated by Font Squirrel (http://www.fontsquirrel.com) on January 21, 2015 */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; src: local('Roboto'), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAGfcABIAAAAAx5wAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABHREVGAAABlAAAAEcAAABYB30Hd0dQT1MAAAHcAAAH8AAAFLywggk9R1NVQgAACcwAAACmAAABFMK7zVBPUy8yAAAKdAAAAFYAAABgoKexpmNtYXAAAArMAAADZAAABnjIFMucY3Z0IAAADjAAAABMAAAATCRBBuVmcGdtAAAOfAAAATsAAAG8Z/Rcq2dhc3AAAA+4AAAADAAAAAwACAATZ2x5ZgAAD8QAAE7fAACZfgdaOmpoZG14AABepAAAAJoAAAGo8AnZfGhlYWQAAF9AAAAANgAAADb4RqsOaGhlYQAAX3gAAAAgAAAAJAq6BzxobXR4AABfmAAAA4cAAAZwzpCM0GxvY2EAAGMgAAADKQAAAzowggjbbWF4cAAAZkwAAAAgAAAAIAPMAvluYW1lAABmbAAAAJkAAAEQEG8sqXBvc3QAAGcIAAAAEwAAACD/bQBkcHJlcAAAZxwAAAC9AAAA23Sgj+x4AQXBsQFBMQAFwHvRZg0bgEpnDXukA4AWYBvqv9O/E1RAUQ3NxcJSNM3A2lpsbcXBQZydxdVdPH3Fz1/RZSyZ5Ss9lqEL+AB4AWSOA4ydQRgAZ7a2bdu2bdu2bduI07hubF2s2gx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Tujh7WeogiQuZ0pwsNCA8xiDnI2URUDsVjifG20JUEsVjMdJUl+EIutMNbNSBrEYp9YHmOlDGJx1KUHWEqBWJwhrmZq4iAWV1mCt5ksiMXdnOIHUcdzc1NXsg2IxSsiyMvJBmLx2RipywiCHLNJgIsd6FgF19pMCZdNBkKMxZs2iACJABHGkk0NIKJAhLF0E78MUCxfhrEUAOkaMm8AAAA=) format('woff'); } @font-face { font-family: 'Roboto'; font-style: normal; font-weight: bold; src: local('Roboto Medium'), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAEbcABAAAAAAfQwAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABHUE9TAAABbAAABOQAAAv2MtQEeUdTVUIAAAZQAAAAQQAAAFCyIrRQT1MvMgAABpQAAABXAAAAYLorAUBjbWFwAAAG7AAAAI8AAADEj/6wZGN2dCAAAAd8AAAAMAAAADAX3wLxZnBnbQAAB6wAAAE/AAABvC/mTqtnYXNwAAAI7AAAAAwAAAAMAAgAE2dseWYAAAj4AAA2eQAAYlxNsqlBaGVhZAAAP3QAAAA0AAAANve2KKdoaGVhAAA/qAAAAB8AAAAkDRcHFmhtdHgAAD/IAAACPAAAA3CPSUvWbG9jYQAAQgQAAAG6AAABusPVqwRtYXhwAABDwAAAACAAAAAgAwkC3m5hbWUAAEPgAAAAtAAAAU4XNjG1cG9zdAAARJQAAAF3AAACF7VLITZwcmVwAABGDAAAAM8AAAEuQJ9pDngBpJUDrCVbE0ZX9znX1ti2bdu2bU/w89nm1di2bdu2jXjqfWO7V1ajUru2Otk4QCD5qIRbqUqtRoT2aj+oDynwApjhwNN34fbsPKAPobrrDjggvbggAz21cOiHFyjoKeIpwkH3sHvRve4pxWVnojPdve7MdZY7e53zrq+bzL3r5nDzuTXcfm6iJ587Wa5U/lMuekp5hHv9Ge568okijyiFQ0F8CCSITGQhK9nITh7yUkDxQhSmKMUpQSlKU4bq1KExzWlBK9rwCZ/yGZ/zBV/yNd/wLd/xM7/yG7/zB3+SyF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ro0atKsRas27Tp06tKtR68+/QYMGjJsxKgx4yZMmjJtxqw58xYsWrJsxao16zZs2rJtx649+w4cOnLsxKkz5y5cunLtxq079x48evLsxas37z58+vLtx68//0LCIqJi4hKSUtIyshWC4GErEAAAAOAs/3NtI+tluy7Ztm3zZZ6z69yMBuVixBqU50icNMkK1ap48kySXdGy3biVKl+CcYeuFalz786DMo1mTWvy2hsZ3po3Y86yBYuWHHtvzYpVzT64kmnTug0fnTqX6LNPvvjmq+9K/PDLT7/98c9f/wU4EShYkBBhQvUoFSFcpChnLvTZ0qLVtgM72rTr0m1Ch06T4g0ZNvDk+ZMXLo08efk4RnZGDkZOhlQWv1AfH/bSvEwDA0cXEG1kYG7C4lpalM+Rll9apFdcWsBZklGUmgpisZeU54Pp/DwwHwBPQXTqAHgBLc4lXMVQFIDxe5+/Ke4uCXd3KLhLWsWdhvWynugFl7ieRu+dnsb5flD+V44+W03Pqkm96nSsSX3pwfbG8hyVafqKLY53NhRyi8/1/P8l1md6//6SRzsznWXcUiuTXQ3F3NJTfU3V3NRrJp2WrjUzN3sl06/thr54PYV7+IYaQ1++jlly8+AO2iz5W4IT8OEJIqi29NXrGHhwB65DLfxAtSN5HvgQQgRjjiSfQJDDoBz5e4AA3BwJtOVAHgtBBGGeRNsK5DYGd8IvM61XFAA=) format('woff'), } @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 200; src: local('Roboto Light'), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAEScABMAAAAAdFQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABqAAAABwAAAAcXzC5yUdERUYAAAHEAAAAHgAAACAAzgAER1BPUwAAAeQAAAVxAAANIkezYOlHU1VCAAAHWAAAACwAAAAwuP+4/k9TLzIAAAeEAAAAVgAAAGC3ouDrY21hcAAAB9wAAAG+AAACioYHy/VjdnQgAAAJnAAAADQAAAA0CnAOGGZwZ20AAAnQAAABsQAAAmVTtC+nZ2FzcAAAC4QAAAAIAAAAC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VKhjVlxDmcNhZTibyxMJ8wlp3ZQy1+qBkHW3Hfv3dQqSv9yi5lQBlUditDyh5lrzJcUld3dd3xNJMy8nPJxFK6NPLHSgZj5qiRzxZLdO+P/+/adfZ42j3OKRLCQBAF0Bkm+0JWE0Ex6LkCksTEUKikiuIGWCwYcHABOEQHReE5BYcJHWjG9fst/n/w/gj8zGpwlk3H+aXtKks1M4jbGvIVHod2ApZaNwyELEGoBRiyvItipL4wEcaUYMnyyUy+ZWQbn9ab4CDsF8FFODeCh3CvBB/hnQgBwq8IISL4V40RofyBQ0TTUkwj7OhEtUMmyHSjGSOTuWY2rI32PdNJPiQZL3TSQq4+STRSagAAAAFR3VVMAAA=) format('woff'); } ================================================ FILE: plugins/UiConfig/media/css/button.css ================================================ /* Button */ .button { background-color: #FFDC00; color: black; padding: 10px 20px; display: inline-block; background-position: left center; border-radius: 2px; border-bottom: 2px solid #E8BE29; transition: all 0.5s ease-out; text-decoration: none; } .button:hover { border-color: white; border-bottom: 2px solid #BD960C; transition: none ; background-color: #FDEB07 } .button:active { position: relative; top: 1px } .button.loading { color: rgba(0,0,0,0); background: #999 url(../img/loading.gif) no-repeat center center; transition: all 0.5s ease-out ; pointer-events: none; border-bottom: 2px solid #666 } .button.disabled { color: #DDD; background-color: #999; pointer-events: none; border-bottom: 2px solid #666 } ================================================ FILE: plugins/UiConfig/media/css/fonts.css ================================================ /* Base64 encoder: http://www.motobit.com/util/base64-decoder-encoder.asp */ /* Generated by Font Squirrel (http://www.fontsquirrel.com) on January 21, 2015 */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; src: local('Roboto'), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAGfcABIAAAAAx5wAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABHREVGAAABlAAAAEcAAABYB30Hd0dQT1MAAAHcAAAH8AAAFLywggk9R1NVQgAACcwAAACmAAABFMK7zVBPUy8yAAAKdAAAAFYAAABgoKexpmNtYXAAAArMAAADZAAABn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HRZTFaS9SSTveU4uVTukZfkPflKfpNBMlUVVuVVbdVcEdVLDVIz1Xp1TN1Rn1WUzq0r6Ja6kz5tipo6hpheZoxZavaYy+aVCTQptpCtaaHtbkfZhXaHPW+f2f82xRV2tRxyPdxoN90tduvdbnfJvXQBLsmP8Qv9Wr/TH/UX/d0sCRMZsgAAAAABAAABnACPABYAVAAFAAEAAAAAAA4AAAIAAhQABgABeAFdjjN7AwAYhN/a3evuZTAlW2x7im3+/VyM5zPvgCtynHFyfsMJ97DOT3lUtcrP9vrne/kF3zyv80teca3zRxIUidGT7zGWxahQY0KbAkNSVORHNDTp8omRX/4lBok8VtRbZuaDLz9Hf+qMJX0s/ElmS/nVpC8raVpR1WNITdM2DfUqdBlRkf0RwIsdJyHi8j8rFnNKFSE1AAAAeAFjYGYAg/9ZDCkMWAAAKh8B0QB4AdvAo72BQZthEyMfkzbjJn5GILmd38pAVVqAgUObYTujh7WeogiQuZ0pwsNCA8xiDnI2URUDsVjifG20JUEsVjMdJUl+EIutMNbNSBrEYp9YHmOlDGJx1KUHWEqBWJwhrmZq4iAWV1mCt5ksiMXdnOIHUcdzc1NXsg2IxSsiyMvJBmLx2RipywiCHLNJgIsd6FgF19pMCZdNBkKMxZs2iACJABHGkk0NIKJAhLF0E78MUCxfhrEUAOkaMm8AAAA=) format('woff'); } @font-face { font-family: 'Roboto'; font-style: normal; font-weight: bold; src: local('Roboto Medium'), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAEbcABAAAAAAfQwAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABHUE9TAAABbAAABOQAAAv2MtQEeUdTVUIAAAZQAAAAQQAAAFCyIrRQT1MvMgAABpQAAABXAAAAYLorAUBjbWFwAAAG7AAAAI8AAADEj/6wZGN2dCAAAAd8AAAAMAAAADAX3wLxZnBnbQAAB6wAAAE/AAABvC/mTqtnYXNwAAAI7AAAAAwAAAAMAAgAE2dseWYAAAj4AAA2eQAAYlxNsqlBaGVhZAAAP3QAA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N3sl06/thr54PYV7+IYaQ1++jlly8+AO2iz5W4IT8OEJIqi29NXrGHhwB65DLfxAtSN5HvgQQgRjjiSfQJDDoBz5e4AA3BwJtOVAHgtBBGGeRNsK5DYGd8IvM61XFAA=) format('woff'), } @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 200; src: local('Roboto Light'), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAEScABMAAAAAdFQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABqAAAABwAAAAcXzC5yUdERUYAAAHEAAAAHgAAACAAzgAER1BPUwAAAeQAAAVxAAANIkezYOlHU1VCAAAHWAAAACwAAAAwuP+4/k9TLzIAAAeEAAAAVgAAAGC3ouDrY21hcAAAB9wAAAG+AAACioYHy/VjdnQgAAAJnAAAADQAAAA0CnAOGGZwZ20AAAnQAAABsQAAAmVTtC+nZ2FzcAAAC4QAAAAIAAAACAAAABBnbHlmAAALjAAAMaIAAFTUMXgLR2hlYWQAAD0wAAAAMQAAADYBsFYkaGhlYQAAPWQAAAAfAAAAJA7cBhlobXR4AAA9hAAAAeEAAAKEbjk+b2xvY2EAAD9oAAABNgAAAUQwY0cibWF4cAAAQKAAAAAgAAAAIAG+AZluYW1lAABAwAAAAZAAAANoT6qDDHBvc3QAAEJQAAABjAAAAktoPRGfcHJlcAAAQ9wAAAC2AAABI0qzIoZ3ZWJmAABElAAAAAYAAAAGVU1R3QAAAAEAAAAAzD2izwAAAADE8BEuAAAAAM4DBct42mNgZGBg4ANiCQYQYGJgBMIFQMwC5jEAAAsqANMAAHjapZZ5bNRFFMff79dtd7u03UNsORWwKYhWGwFLsRBiGuSKkdIDsBg0kRCVGq6GcpSEFINKghzlMDFBVBITNRpDJEGCBlBBRSEQIQYJyLHd/pA78a99fn6zy3ZbykJxXr7zm3nz5s2b7xy/EUtE/FIiY8SuGDe5SvLeeHlhvfQRD3pRFbc9tWy9/ur8evG5JQOP2Hxt8ds7xLJrjO1AmYxUyiyZLQtlpay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FvM96i5SeZRzwkgNl+zhDFe4oS0I5997/W9PDXI1ObvZn1RSHA3ptMpeBypq0wb7drivfdoy8XyDP0JQfA542m3Ou0+TcRTG8e+hpTcol9JSoCqKIiqI71taCqJCtS3ekIsWARVoUmxrgDaFd2hiTEx0AXVkZ1Q3Edlw0cHEwcEBBv1XlNLfAAnP8slzknNyKGM//56R5Kisg5SJCRNmyrFgxYYdBxVU4qSKamqoxUUdbjzU46WBRprwcYzjnKCZk5yihdOcoZWztHGO81ygnQ4u0sklNHT8dBEgSDcheujlMn1c4SrX6GeAMNe5QYQoMQa5yS1uc4e7DHGPYUYYZYz7PCDOOA+ZYJIpHvGYJ0wzwywJMfOK16zxjlXeSzkrvOUvH/jBHD/5RYrfpMmQY5kCz3nBS7GIVWxiZ4c/7IpDKqRSnFIl1VIjteKSOnGLR+rFyyc2+MIW3/jMJt/5KA1s81UapYk34rOk5gu5tG41FjOapkVKhjVlxDmcNhZTibyxMJ8wlp3ZQy1+qBkHW3Hfv3dQqSv9yi5lQBlUditDyh5lrzJcUld3dd3xNJMy8nPJxFK6NPLHSgZj5qiRzxZLdO+P/+/adfZ42j3OKRLCQBAF0Bkm+0JWE0Ex6LkCksTEUKikiuIGWCwYcHABOEQHReE5BYcJHWjG9fst/n/w/gj8zGpwlk3H+aXtKks1M4jbGvIVHod2ApZaNwyELEGoBRiyvItipL4wEcaUYMnyyUy+ZWQbn9ab4CDsF8FFODeCh3CvBB/hnQgBwq8IISL4V40RofyBQ0TTUkwj7OhEtUMmyHSjGSOTuWY2rI32PdNJPiQZL3TSQq4+STRSagAAAAFR3VVMAAA=) format('woff'); } ================================================ FILE: plugins/UiConfig/media/js/ConfigStorage.coffee ================================================ class ConfigStorage extends Class constructor: (@config) -> @items = [] @createSections() @setValues(@config) setValues: (values) -> for section in @items for item in section.items if not values[item.key] continue item.value = @formatValue(values[item.key].value) item.default = @formatValue(values[item.key].default) item.pending = values[item.key].pending values[item.key].item = item formatValue: (value) -> if not value return false else if typeof(value) == "object" return value.join("\n") else if typeof(value) == "number" return value.toString() else return value deformatValue: (value, type) -> if type == "object" and typeof(value) == "string" if not value.length return value = null else return value.split("\n") if type == "boolean" and not value return false else if type == "number" if typeof(value) == "number" return value.toString() else if not value return "0" else return value else return value createSections: -> # Web Interface section = @createSection("Web Interface") section.items.push key: "open_browser" title: "Open web browser on ZeroNet startup" type: "checkbox" # Network section = @createSection("Network") section.items.push key: "offline" title: "Offline mode" type: "checkbox" description: "Disable network communication." section.items.push key: "fileserver_ip_type" title: "File server network" type: "select" options: [ {title: "IPv4", value: "ipv4"} {title: "IPv6", value: "ipv6"} {title: "Dual (IPv4 & IPv6)", value: "dual"} ] description: "Accept incoming peers using IPv4 or IPv6 address. (default: dual)" section.items.push key: "fileserver_port" title: "File server port" type: "text" valid_pattern: /[0-9]*/ description: "Other peers will use this port to reach your served sites. (default: randomize)" section.items.push key: "ip_external" title: "File server external ip" type: "textarea" placeholder: "Detect automatically" description: "Your file server is accessible on these ips. (default: detect automatically)" section.items.push title: "Tor" key: "tor" type: "select" options: [ {title: "Disable", value: "disable"} {title: "Enable", value: "enable"} {title: "Always", value: "always"} ] description: [ "Disable: Don't connect to peers on Tor network", h("br"), "Enable: Only use Tor for Tor network peers", h("br"), "Always: Use Tor for every connections to hide your IP address (slower)" ] section.items.push title: "Use Tor bridges" key: "tor_use_bridges" type: "checkbox" description: "Use obfuscated bridge relays to avoid network level Tor block (even slower)" isHidden: -> return not Page.server_info.tor_has_meek_bridges section.items.push title: "Trackers" key: "trackers" type: "textarea" description: "Discover new peers using these adresses" section.items.push title: "Trackers files" key: "trackers_file" type: "textarea" description: "Load additional list of torrent trackers dynamically, from a file" placeholder: "Eg.: {data_dir}/trackers.json" value_pos: "fullwidth" section.items.push title: "Proxy for tracker connections" key: "trackers_proxy" type: "select" options: [ {title: "Custom", value: ""} {title: "Tor", value: "tor"} {title: "Disable", value: "disable"} ] isHidden: -> Page.values["tor"] == "always" section.items.push title: "Custom socks proxy address for trackers" key: "trackers_proxy" type: "text" placeholder: "Eg.: 127.0.0.1:1080" value_pos: "fullwidth" valid_pattern: /.+:[0-9]+/ isHidden: => Page.values["trackers_proxy"] in ["tor", "disable"] # Performance section = @createSection("Performance") section.items.push key: "log_level" title: "Level of logging to file" type: "select" options: [ {title: "Everything", value: "DEBUG"} {title: "Only important messages", value: "INFO"} {title: "Only errors", value: "ERROR"} ] section.items.push key: "threads_fs_read" title: "Threads for async file system reads" type: "select" options: [ {title: "Sync read", value: 0} {title: "1 thread", value: 1} {title: "2 threads", value: 2} {title: "3 threads", value: 3} {title: "4 threads", value: 4} {title: "5 threads", value: 5} {title: "10 threads", value: 10} ] section.items.push key: "threads_fs_write" title: "Threads for async file system writes" type: "select" options: [ {title: "Sync write", value: 0} {title: "1 thread", value: 1} {title: "2 threads", value: 2} {title: "3 threads", value: 3} {title: "4 threads", value: 4} {title: "5 threads", value: 5} {title: "10 threads", value: 10} ] section.items.push key: "threads_crypt" title: "Threads for cryptographic functions" type: "select" options: [ {title: "Sync execution", value: 0} {title: "1 thread", value: 1} {title: "2 threads", value: 2} {title: "3 threads", value: 3} {title: "4 threads", value: 4} {title: "5 threads", value: 5} {title: "10 threads", value: 10} ] section.items.push key: "threads_db" title: "Threads for database operations" type: "select" options: [ {title: "Sync execution", value: 0} {title: "1 thread", value: 1} {title: "2 threads", value: 2} {title: "3 threads", value: 3} {title: "4 threads", value: 4} {title: "5 threads", value: 5} {title: "10 threads", value: 10} ] createSection: (title) => section = {} section.title = title section.items = [] @items.push(section) return section window.ConfigStorage = ConfigStorage ================================================ FILE: plugins/UiConfig/media/js/ConfigView.coffee ================================================ class ConfigView extends Class constructor: () -> @ render: -> @config_storage.items.map @renderSection renderSection: (section) => h("div.section", {key: section.title}, [ h("h2", section.title), h("div.config-items", section.items.map @renderSectionItem) ]) handleResetClick: (e) => node = e.currentTarget config_key = node.attributes.config_key.value default_value = node.attributes.default_value?.value Page.cmd "wrapperConfirm", ["Reset #{config_key} value?", "Reset to default"], (res) => if (res) @values[config_key] = default_value Page.projector.scheduleRender() renderSectionItem: (item) => value_pos = item.value_pos if item.type == "textarea" value_pos ?= "fullwidth" else value_pos ?= "right" value_changed = @config_storage.formatValue(@values[item.key]) != item.value value_default = @config_storage.formatValue(@values[item.key]) == item.default if item.key in ["open_browser", "fileserver_port"] # Value default for some settings makes no sense value_default = true marker_title = "Changed from default value: #{item.default} -> #{@values[item.key]}" if item.pending marker_title += " (change pending until client restart)" if item.isHidden?() return null h("div.config-item", {key: item.title, enterAnimation: Animation.slideDown, exitAnimation: Animation.slideUpInout}, [ h("div.title", [ h("h3", item.title), h("div.description", item.description) ]) h("div.value.value-#{value_pos}", if item.type == "select" @renderValueSelect(item) else if item.type == "checkbox" @renderValueCheckbox(item) else if item.type == "textarea" @renderValueTextarea(item) else @renderValueText(item) h("a.marker", { href: "#Reset", title: marker_title, onclick: @handleResetClick, config_key: item.key, default_value: item.default, classes: {default: value_default, changed: value_changed, visible: not value_default or value_changed or item.pending, pending: item.pending} }, "\u2022") ) ]) # Values handleInputChange: (e) => node = e.target config_key = node.attributes.config_key.value @values[config_key] = node.value Page.projector.scheduleRender() handleCheckboxChange: (e) => node = e.currentTarget config_key = node.attributes.config_key.value value = not node.classList.contains("checked") @values[config_key] = value Page.projector.scheduleRender() renderValueText: (item) => value = @values[item.key] if not value value = "" h("input.input-#{item.type}", {type: item.type, config_key: item.key, value: value, placeholder: item.placeholder, oninput: @handleInputChange}) autosizeTextarea: (e) => if e.currentTarget # @handleInputChange(e) node = e.currentTarget else node = e height_before = node.style.height if height_before node.style.height = "0px" h = node.offsetHeight scrollh = node.scrollHeight + 20 if scrollh > h node.style.height = scrollh + "px" else node.style.height = height_before renderValueTextarea: (item) => value = @values[item.key] if not value value = "" h("textarea.input-#{item.type}.input-text",{ type: item.type, config_key: item.key, oninput: @handleInputChange, afterCreate: @autosizeTextarea, updateAnimation: @autosizeTextarea, value: value, placeholder: item.placeholder }) renderValueCheckbox: (item) => if @values[item.key] and @values[item.key] != "False" checked = true else checked = false h("div.checkbox", {onclick: @handleCheckboxChange, config_key: item.key, classes: {checked: checked}}, h("div.checkbox-skin")) renderValueSelect: (item) => h("select.input-select", {config_key: item.key, oninput: @handleInputChange}, item.options.map (option) => h("option", {selected: option.value.toString() == @values[item.key], value: option.value}, option.title) ) window.ConfigView = ConfigView ================================================ FILE: plugins/UiConfig/media/js/UiConfig.coffee ================================================ window.h = maquette.h class UiConfig extends ZeroFrame init: -> @save_visible = true @config = null # Setting currently set on the server @values = null # Entered values on the page @config_view = new ConfigView() window.onbeforeunload = => if @getValuesChanged().length > 0 return true else return null onOpenWebsocket: => @cmd("wrapperSetTitle", "Config - ZeroNet") @cmd "serverInfo", {}, (server_info) => @server_info = server_info @restart_loading = false @updateConfig() updateConfig: (cb) => @cmd "configList", [], (res) => @config = res @values = {} @config_storage = new ConfigStorage(@config) @config_view.values = @values @config_view.config_storage = @config_storage for key, item of res value = item.value @values[key] = @config_storage.formatValue(value) @projector.scheduleRender() cb?() createProjector: => @projector = maquette.createProjector() @projector.replace($("#content"), @render) @projector.replace($("#bottom-save"), @renderBottomSave) @projector.replace($("#bottom-restart"), @renderBottomRestart) getValuesChanged: => values_changed = [] for key, value of @values if @config_storage.formatValue(value) != @config_storage.formatValue(@config[key]?.value) values_changed.push({key: key, value: value}) return values_changed getValuesPending: => values_pending = [] for key, item of @config if item.pending values_pending.push(key) return values_pending saveValues: (cb) => changed_values = @getValuesChanged() for item, i in changed_values last = i == changed_values.length - 1 value = @config_storage.deformatValue(item.value, typeof(@config[item.key].default)) default_value = @config_storage.deformatValue(@config[item.key].default, typeof(@config[item.key].default)) value_same_as_default = JSON.stringify(default_value) == JSON.stringify(value) if @config[item.key].item.valid_pattern and not @config[item.key].item.isHidden?() match = value.match(@config[item.key].item.valid_pattern) if not match or match[0] != value message = "Invalid value of #{@config[item.key].item.title}: #{value} (does not matches #{@config[item.key].item.valid_pattern})" Page.cmd("wrapperNotification", ["error", message]) cb(false) break if value_same_as_default value = null @saveValue(item.key, value, if last then cb else null) saveValue: (key, value, cb) => if key == "open_browser" if value value = "default_browser" else value = "False" Page.cmd "configSet", [key, value], (res) => if res != "ok" Page.cmd "wrapperNotification", ["error", res.error] cb?(true) render: => if not @config return h("div.content") h("div.content", [ @config_view.render() ]) handleSaveClick: => @save_loading = true @logStart "Save" @saveValues (success) => @save_loading = false @logEnd "Save" if success @updateConfig() Page.projector.scheduleRender() return false renderBottomSave: => values_changed = @getValuesChanged() h("div.bottom.bottom-save", {classes: {visible: values_changed.length}}, h("div.bottom-content", [ h("div.title", "#{values_changed.length} configuration item value changed"), h("a.button.button-submit.button-save", {href: "#Save", classes: {loading: @save_loading}, onclick: @handleSaveClick}, "Save settings") ])) handleRestartClick: => @restart_loading = true Page.cmd("serverShutdown", {restart: true}) Page.projector.scheduleRender() return false renderBottomRestart: => values_pending = @getValuesPending() values_changed = @getValuesChanged() h("div.bottom.bottom-restart", {classes: {visible: values_pending.length and not values_changed.length}}, h("div.bottom-content", [ h("div.title", "Some changed settings requires restart"), h("a.button.button-submit.button-restart", {href: "#Restart", classes: {loading: @restart_loading}, onclick: @handleRestartClick}, "Restart ZeroNet client") ])) window.Page = new UiConfig() window.Page.createProjector() ================================================ FILE: plugins/UiConfig/media/js/all.js ================================================ /* ---- lib/Class.coffee ---- */ (function() { var Class, slice = [].slice; Class = (function() { function Class() {} Class.prototype.trace = true; Class.prototype.log = function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; if (!this.trace) { return; } if (typeof console === 'undefined') { return; } args.unshift("[" + this.constructor.name + "]"); console.log.apply(console, args); return this; }; Class.prototype.logStart = function() { var args, name; name = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; if (!this.trace) { return; } this.logtimers || (this.logtimers = {}); this.logtimers[name] = +(new Date); if (args.length > 0) { this.log.apply(this, ["" + name].concat(slice.call(args), ["(started)"])); } return this; }; Class.prototype.logEnd = function() { var args, ms, name; name = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; ms = +(new Date) - this.logtimers[name]; this.log.apply(this, ["" + name].concat(slice.call(args), ["(Done in " + ms + "ms)"])); return this; }; return Class; })(); window.Class = Class; }).call(this); /* ---- lib/Promise.coffee ---- */ (function() { var Promise, slice = [].slice; Promise = (function() { Promise.when = function() { var args, fn, i, len, num_uncompleted, promise, task, task_id, tasks; tasks = 1 <= arguments.length ? slice.call(arguments, 0) : []; num_uncompleted = tasks.length; args = new Array(num_uncompleted); promise = new Promise(); fn = function(task_id) { return task.then(function() { args[task_id] = Array.prototype.slice.call(arguments); num_uncompleted--; if (num_uncompleted === 0) { return promise.complete.apply(promise, args); } }); }; for (task_id = i = 0, len = tasks.length; i < len; task_id = ++i) { task = tasks[task_id]; fn(task_id); } return promise; }; function Promise() { this.resolved = false; this.end_promise = null; this.result = null; this.callbacks = []; } Promise.prototype.resolve = function() { var back, callback, i, len, ref; if (this.resolved) { return false; } this.resolved = true; this.data = arguments; if (!arguments.length) { this.data = [true]; } this.result = this.data[0]; ref = this.callbacks; for (i = 0, len = ref.length; i < len; i++) { callback = ref[i]; back = callback.apply(callback, this.data); } if (this.end_promise) { return this.end_promise.resolve(back); } }; Promise.prototype.fail = function() { return this.resolve(false); }; Promise.prototype.then = function(callback) { if (this.resolved === true) { callback.apply(callback, this.data); return; } this.callbacks.push(callback); return this.end_promise = new Promise(); }; return Promise; })(); window.Promise = Promise; /* s = Date.now() log = (text) -> console.log Date.now()-s, Array.prototype.slice.call(arguments).join(", ") log "Started" cmd = (query) -> p = new Promise() setTimeout ( -> p.resolve query+" Result" ), 100 return p back = cmd("SELECT * FROM message").then (res) -> log res return "Return from query" .then (res) -> log "Back then", res log "Query started", back */ }).call(this); /* ---- lib/Prototypes.coffee ---- */ (function() { String.prototype.startsWith = function(s) { return this.slice(0, s.length) === s; }; String.prototype.endsWith = function(s) { return s === '' || this.slice(-s.length) === s; }; String.prototype.repeat = function(count) { return new Array(count + 1).join(this); }; window.isEmpty = function(obj) { var key; for (key in obj) { return false; } return true; }; }).call(this); /* ---- lib/maquette.js ---- */ (function (root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['exports'], factory); } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') { // CommonJS factory(exports); } else { // Browser globals factory(root.maquette = {}); } }(this, function (exports) { 'use strict'; ; ; ; ; var NAMESPACE_W3 = 'http://www.w3.org/'; var NAMESPACE_SVG = NAMESPACE_W3 + '2000/svg'; var NAMESPACE_XLINK = NAMESPACE_W3 + '1999/xlink'; // Utilities var emptyArray = []; var extend = function (base, overrides) { var result = {}; Object.keys(base).forEach(function (key) { result[key] = base[key]; }); if (overrides) { Object.keys(overrides).forEach(function (key) { result[key] = overrides[key]; }); } return result; }; // Hyperscript helper functions var same = function (vnode1, vnode2) { if (vnode1.vnodeSelector !== vnode2.vnodeSelector) { return false; } if (vnode1.properties && vnode2.properties) { if (vnode1.properties.key !== vnode2.properties.key) { return false; } return vnode1.properties.bind === vnode2.properties.bind; } return !vnode1.properties && !vnode2.properties; }; var toTextVNode = function (data) { return { vnodeSelector: '', properties: undefined, children: undefined, text: data.toString(), domNode: null }; }; var appendChildren = function (parentSelector, insertions, main) { for (var i = 0; i < insertions.length; i++) { var item = insertions[i]; if (Array.isArray(item)) { appendChildren(parentSelector, item, main); } else { if (item !== null && item !== undefined) { if (!item.hasOwnProperty('vnodeSelector')) { item = toTextVNode(item); } main.push(item); } } } }; // Render helper functions var missingTransition = function () { throw new Error('Provide a transitions object to the projectionOptions to do animations'); }; var DEFAULT_PROJECTION_OPTIONS = { namespace: undefined, eventHandlerInterceptor: undefined, styleApplyer: function (domNode, styleName, value) { // Provides a hook to add vendor prefixes for browsers that still need it. domNode.style[styleName] = value; }, transitions: { enter: missingTransition, exit: missingTransition } }; var applyDefaultProjectionOptions = function (projectorOptions) { return extend(DEFAULT_PROJECTION_OPTIONS, projectorOptions); }; var checkStyleValue = function (styleValue) { if (typeof styleValue !== 'string') { throw new Error('Style values must be strings'); } }; var setProperties = function (domNode, properties, projectionOptions) { if (!properties) { return; } var eventHandlerInterceptor = projectionOptions.eventHandlerInterceptor; var propNames = Object.keys(properties); var propCount = propNames.length; for (var i = 0; i < propCount; i++) { var propName = propNames[i]; /* tslint:disable:no-var-keyword: edge case */ var propValue = properties[propName]; /* tslint:enable:no-var-keyword */ if (propName === 'className') { throw new Error('Property "className" is not supported, use "class".'); } else if (propName === 'class') { if (domNode.className) { // May happen if classes is specified before class domNode.className += ' ' + propValue; } else { domNode.className = propValue; } } else if (propName === 'classes') { // object with string keys and boolean values var classNames = Object.keys(propValue); var classNameCount = classNames.length; for (var j = 0; j < classNameCount; j++) { var className = classNames[j]; if (propValue[className]) { domNode.classList.add(className); } } } else if (propName === 'styles') { // object with string keys and string (!) values var styleNames = Object.keys(propValue); var styleCount = styleNames.length; for (var j = 0; j < styleCount; j++) { var styleName = styleNames[j]; var styleValue = propValue[styleName]; if (styleValue) { checkStyleValue(styleValue); projectionOptions.styleApplyer(domNode, styleName, styleValue); } } } else if (propName === 'key') { continue; } else if (propValue === null || propValue === undefined) { continue; } else { var type = typeof propValue; if (type === 'function') { if (propName.lastIndexOf('on', 0) === 0) { if (eventHandlerInterceptor) { propValue = eventHandlerInterceptor(propName, propValue, domNode, properties); // intercept eventhandlers } if (propName === 'oninput') { (function () { // record the evt.target.value, because IE and Edge sometimes do a requestAnimationFrame between changing value and running oninput var oldPropValue = propValue; propValue = function (evt) { evt.target['oninput-value'] = evt.target.value; // may be HTMLTextAreaElement as well oldPropValue.apply(this, [evt]); }; }()); } domNode[propName] = propValue; } } else if (type === 'string' && propName !== 'value' && propName !== 'innerHTML') { if (projectionOptions.namespace === NAMESPACE_SVG && propName === 'href') { domNode.setAttributeNS(NAMESPACE_XLINK, propName, propValue); } else { domNode.setAttribute(propName, propValue); } } else { domNode[propName] = propValue; } } } }; var updateProperties = function (domNode, previousProperties, properties, projectionOptions) { if (!properties) { return; } var propertiesUpdated = false; var propNames = Object.keys(properties); var propCount = propNames.length; for (var i = 0; i < propCount; i++) { var propName = propNames[i]; // assuming that properties will be nullified instead of missing is by design var propValue = properties[propName]; var previousValue = previousProperties[propName]; if (propName === 'class') { if (previousValue !== propValue) { throw new Error('"class" property may not be updated. Use the "classes" property for conditional css classes.'); } } else if (propName === 'classes') { var classList = domNode.classList; var classNames = Object.keys(propValue); var classNameCount = classNames.length; for (var j = 0; j < classNameCount; j++) { var className = classNames[j]; var on = !!propValue[className]; var previousOn = !!previousValue[className]; if (on === previousOn) { continue; } propertiesUpdated = true; if (on) { classList.add(className); } else { classList.remove(className); } } } else if (propName === 'styles') { var styleNames = Object.keys(propValue); var styleCount = styleNames.length; for (var j = 0; j < styleCount; j++) { var styleName = styleNames[j]; var newStyleValue = propValue[styleName]; var oldStyleValue = previousValue[styleName]; if (newStyleValue === oldStyleValue) { continue; } propertiesUpdated = true; if (newStyleValue) { checkStyleValue(newStyleValue); projectionOptions.styleApplyer(domNode, styleName, newStyleValue); } else { projectionOptions.styleApplyer(domNode, styleName, ''); } } } else { if (!propValue && typeof previousValue === 'string') { propValue = ''; } if (propName === 'value') { if (domNode[propName] !== propValue && domNode['oninput-value'] !== propValue) { domNode[propName] = propValue; // Reset the value, even if the virtual DOM did not change domNode['oninput-value'] = undefined; } // else do not update the domNode, otherwise the cursor position would be changed if (propValue !== previousValue) { propertiesUpdated = true; } } else if (propValue !== previousValue) { var type = typeof propValue; if (type === 'function') { throw new Error('Functions may not be updated on subsequent renders (property: ' + propName + '). Hint: declare event handler functions outside the render() function.'); } if (type === 'string' && propName !== 'innerHTML') { if (projectionOptions.namespace === NAMESPACE_SVG && propName === 'href') { domNode.setAttributeNS(NAMESPACE_XLINK, propName, propValue); } else { domNode.setAttribute(propName, propValue); } } else { if (domNode[propName] !== propValue) { domNode[propName] = propValue; } } propertiesUpdated = true; } } } return propertiesUpdated; }; var findIndexOfChild = function (children, sameAs, start) { if (sameAs.vnodeSelector !== '') { // Never scan for text-nodes for (var i = start; i < children.length; i++) { if (same(children[i], sameAs)) { return i; } } } return -1; }; var nodeAdded = function (vNode, transitions) { if (vNode.properties) { var enterAnimation = vNode.properties.enterAnimation; if (enterAnimation) { if (typeof enterAnimation === 'function') { enterAnimation(vNode.domNode, vNode.properties); } else { transitions.enter(vNode.domNode, vNode.properties, enterAnimation); } } } }; var nodeToRemove = function (vNode, transitions) { var domNode = vNode.domNode; if (vNode.properties) { var exitAnimation = vNode.properties.exitAnimation; if (exitAnimation) { domNode.style.pointerEvents = 'none'; var removeDomNode = function () { if (domNode.parentNode) { domNode.parentNode.removeChild(domNode); } }; if (typeof exitAnimation === 'function') { exitAnimation(domNode, removeDomNode, vNode.properties); return; } else { transitions.exit(vNode.domNode, vNode.properties, exitAnimation, removeDomNode); return; } } } if (domNode.parentNode) { domNode.parentNode.removeChild(domNode); } }; var checkDistinguishable = function (childNodes, indexToCheck, parentVNode, operation) { var childNode = childNodes[indexToCheck]; if (childNode.vnodeSelector === '') { return; // Text nodes need not be distinguishable } var properties = childNode.properties; var key = properties ? properties.key === undefined ? properties.bind : properties.key : undefined; if (!key) { for (var i = 0; i < childNodes.length; i++) { if (i !== indexToCheck) { var node = childNodes[i]; if (same(node, childNode)) { if (operation === 'added') { throw new Error(parentVNode.vnodeSelector + ' had a ' + childNode.vnodeSelector + ' child ' + 'added, but there is now more than one. You must add unique key properties to make them distinguishable.'); } else { throw new Error(parentVNode.vnodeSelector + ' had a ' + childNode.vnodeSelector + ' child ' + 'removed, but there were more than one. You must add unique key properties to make them distinguishable.'); } } } } } }; var createDom; var updateDom; var updateChildren = function (vnode, domNode, oldChildren, newChildren, projectionOptions) { if (oldChildren === newChildren) { return false; } oldChildren = oldChildren || emptyArray; newChildren = newChildren || emptyArray; var oldChildrenLength = oldChildren.length; var newChildrenLength = newChildren.length; var transitions = projectionOptions.transitions; var oldIndex = 0; var newIndex = 0; var i; var textUpdated = false; while (newIndex < newChildrenLength) { var oldChild = oldIndex < oldChildrenLength ? oldChildren[oldIndex] : undefined; var newChild = newChildren[newIndex]; if (oldChild !== undefined && same(oldChild, newChild)) { textUpdated = updateDom(oldChild, newChild, projectionOptions) || textUpdated; oldIndex++; } else { var findOldIndex = findIndexOfChild(oldChildren, newChild, oldIndex + 1); if (findOldIndex >= 0) { // Remove preceding missing children for (i = oldIndex; i < findOldIndex; i++) { nodeToRemove(oldChildren[i], transitions); checkDistinguishable(oldChildren, i, vnode, 'removed'); } textUpdated = updateDom(oldChildren[findOldIndex], newChild, projectionOptions) || textUpdated; oldIndex = findOldIndex + 1; } else { // New child createDom(newChild, domNode, oldIndex < oldChildrenLength ? oldChildren[oldIndex].domNode : undefined, projectionOptions); nodeAdded(newChild, transitions); checkDistinguishable(newChildren, newIndex, vnode, 'added'); } } newIndex++; } if (oldChildrenLength > oldIndex) { // Remove child fragments for (i = oldIndex; i < oldChildrenLength; i++) { nodeToRemove(oldChildren[i], transitions); checkDistinguishable(oldChildren, i, vnode, 'removed'); } } return textUpdated; }; var addChildren = function (domNode, children, projectionOptions) { if (!children) { return; } for (var i = 0; i < children.length; i++) { createDom(children[i], domNode, undefined, projectionOptions); } }; var initPropertiesAndChildren = function (domNode, vnode, projectionOptions) { addChildren(domNode, vnode.children, projectionOptions); // children before properties, needed for value property of . if (vnode.text) { domNode.textContent = vnode.text; } setProperties(domNode, vnode.properties, projectionOptions); if (vnode.properties && vnode.properties.afterCreate) { vnode.properties.afterCreate(domNode, projectionOptions, vnode.vnodeSelector, vnode.properties, vnode.children); } }; createDom = function (vnode, parentNode, insertBefore, projectionOptions) { var domNode, i, c, start = 0, type, found; var vnodeSelector = vnode.vnodeSelector; if (vnodeSelector === '') { domNode = vnode.domNode = document.createTextNode(vnode.text); if (insertBefore !== undefined) { parentNode.insertBefore(domNode, insertBefore); } else { parentNode.appendChild(domNode); } } else { for (i = 0; i <= vnodeSelector.length; ++i) { c = vnodeSelector.charAt(i); if (i === vnodeSelector.length || c === '.' || c === '#') { type = vnodeSelector.charAt(start - 1); found = vnodeSelector.slice(start, i); if (type === '.') { domNode.classList.add(found); } else if (type === '#') { domNode.id = found; } else { if (found === 'svg') { projectionOptions = extend(projectionOptions, { namespace: NAMESPACE_SVG }); } if (projectionOptions.namespace !== undefined) { domNode = vnode.domNode = document.createElementNS(projectionOptions.namespace, found); } else { domNode = vnode.domNode = document.createElement(found); } if (insertBefore !== undefined) { parentNode.insertBefore(domNode, insertBefore); } else { parentNode.appendChild(domNode); } } start = i + 1; } } initPropertiesAndChildren(domNode, vnode, projectionOptions); } }; updateDom = function (previous, vnode, projectionOptions) { var domNode = previous.domNode; var textUpdated = false; if (previous === vnode) { return false; // By contract, VNode objects may not be modified anymore after passing them to maquette } var updated = false; if (vnode.vnodeSelector === '') { if (vnode.text !== previous.text) { var newVNode = document.createTextNode(vnode.text); domNode.parentNode.replaceChild(newVNode, domNode); vnode.domNode = newVNode; textUpdated = true; return textUpdated; } } else { if (vnode.vnodeSelector.lastIndexOf('svg', 0) === 0) { projectionOptions = extend(projectionOptions, { namespace: NAMESPACE_SVG }); } if (previous.text !== vnode.text) { updated = true; if (vnode.text === undefined) { domNode.removeChild(domNode.firstChild); // the only textnode presumably } else { domNode.textContent = vnode.text; } } updated = updateChildren(vnode, domNode, previous.children, vnode.children, projectionOptions) || updated; updated = updateProperties(domNode, previous.properties, vnode.properties, projectionOptions) || updated; if (vnode.properties && vnode.properties.afterUpdate) { vnode.properties.afterUpdate(domNode, projectionOptions, vnode.vnodeSelector, vnode.properties, vnode.children); } } if (updated && vnode.properties && vnode.properties.updateAnimation) { vnode.properties.updateAnimation(domNode, vnode.properties, previous.properties); } vnode.domNode = previous.domNode; return textUpdated; }; var createProjection = function (vnode, projectionOptions) { return { update: function (updatedVnode) { if (vnode.vnodeSelector !== updatedVnode.vnodeSelector) { throw new Error('The selector for the root VNode may not be changed. (consider using dom.merge and add one extra level to the virtual DOM)'); } updateDom(vnode, updatedVnode, projectionOptions); vnode = updatedVnode; }, domNode: vnode.domNode }; }; ; // The other two parameters are not added here, because the Typescript compiler creates surrogate code for desctructuring 'children'. exports.h = function (selector) { var properties = arguments[1]; if (typeof selector !== 'string') { throw new Error(); } var childIndex = 1; if (properties && !properties.hasOwnProperty('vnodeSelector') && !Array.isArray(properties) && typeof properties === 'object') { childIndex = 2; } else { // Optional properties argument was omitted properties = undefined; } var text = undefined; var children = undefined; var argsLength = arguments.length; // Recognize a common special case where there is only a single text node if (argsLength === childIndex + 1) { var onlyChild = arguments[childIndex]; if (typeof onlyChild === 'string') { text = onlyChild; } else if (onlyChild !== undefined && onlyChild.length === 1 && typeof onlyChild[0] === 'string') { text = onlyChild[0]; } } if (text === undefined) { children = []; for (; childIndex < arguments.length; childIndex++) { var child = arguments[childIndex]; if (child === null || child === undefined) { continue; } else if (Array.isArray(child)) { appendChildren(selector, child, children); } else if (child.hasOwnProperty('vnodeSelector')) { children.push(child); } else { children.push(toTextVNode(child)); } } } return { vnodeSelector: selector, properties: properties, children: children, text: text === '' ? undefined : text, domNode: null }; }; /** * Contains simple low-level utility functions to manipulate the real DOM. */ exports.dom = { /** * Creates a real DOM tree from `vnode`. The [[Projection]] object returned will contain the resulting DOM Node in * its [[Projection.domNode|domNode]] property. * This is a low-level method. Users wil typically use a [[Projector]] instead. * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] * objects may only be rendered once. * @param projectionOptions - Options to be used to create and update the projection. * @returns The [[Projection]] which also contains the DOM Node that was created. */ create: function (vnode, projectionOptions) { projectionOptions = applyDefaultProjectionOptions(projectionOptions); createDom(vnode, document.createElement('div'), undefined, projectionOptions); return createProjection(vnode, projectionOptions); }, /** * Appends a new childnode to the DOM which is generated from a [[VNode]]. * This is a low-level method. Users wil typically use a [[Projector]] instead. * @param parentNode - The parent node for the new childNode. * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] * objects may only be rendered once. * @param projectionOptions - Options to be used to create and update the [[Projection]]. * @returns The [[Projection]] that was created. */ append: function (parentNode, vnode, projectionOptions) { projectionOptions = applyDefaultProjectionOptions(projectionOptions); createDom(vnode, parentNode, undefined, projectionOptions); return createProjection(vnode, projectionOptions); }, /** * Inserts a new DOM node which is generated from a [[VNode]]. * This is a low-level method. Users wil typically use a [[Projector]] instead. * @param beforeNode - The node that the DOM Node is inserted before. * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. * NOTE: [[VNode]] objects may only be rendered once. * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]]. * @returns The [[Projection]] that was created. */ insertBefore: function (beforeNode, vnode, projectionOptions) { projectionOptions = applyDefaultProjectionOptions(projectionOptions); createDom(vnode, beforeNode.parentNode, beforeNode, projectionOptions); return createProjection(vnode, projectionOptions); }, /** * Merges a new DOM node which is generated from a [[VNode]] with an existing DOM Node. * This means that the virtual DOM and the real DOM will have one overlapping element. * Therefore the selector for the root [[VNode]] will be ignored, but its properties and children will be applied to the Element provided. * This is a low-level method. Users wil typically use a [[Projector]] instead. * @param domNode - The existing element to adopt as the root of the new virtual DOM. Existing attributes and childnodes are preserved. * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] objects * may only be rendered once. * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]]. * @returns The [[Projection]] that was created. */ merge: function (element, vnode, projectionOptions) { projectionOptions = applyDefaultProjectionOptions(projectionOptions); vnode.domNode = element; initPropertiesAndChildren(element, vnode, projectionOptions); return createProjection(vnode, projectionOptions); } }; /** * Creates a [[CalculationCache]] object, useful for caching [[VNode]] trees. * In practice, caching of [[VNode]] trees is not needed, because achieving 60 frames per second is almost never a problem. * For more information, see [[CalculationCache]]. * * @param The type of the value that is cached. */ exports.createCache = function () { var cachedInputs = undefined; var cachedOutcome = undefined; var result = { invalidate: function () { cachedOutcome = undefined; cachedInputs = undefined; }, result: function (inputs, calculation) { if (cachedInputs) { for (var i = 0; i < inputs.length; i++) { if (cachedInputs[i] !== inputs[i]) { cachedOutcome = undefined; } } } if (!cachedOutcome) { cachedOutcome = calculation(); cachedInputs = inputs; } return cachedOutcome; } }; return result; }; /** * Creates a {@link Mapping} instance that keeps an array of result objects synchronized with an array of source objects. * See {@link http://maquettejs.org/docs/arrays.html|Working with arrays}. * * @param The type of source items. A database-record for instance. * @param The type of target items. A [[Component]] for instance. * @param getSourceKey `function(source)` that must return a key to identify each source object. The result must either be a string or a number. * @param createResult `function(source, index)` that must create a new result object from a given source. This function is identical * to the `callback` argument in `Array.map(callback)`. * @param updateResult `function(source, target, index)` that updates a result to an updated source. */ exports.createMapping = function (getSourceKey, createResult, updateResult) { var keys = []; var results = []; return { results: results, map: function (newSources) { var newKeys = newSources.map(getSourceKey); var oldTargets = results.slice(); var oldIndex = 0; for (var i = 0; i < newSources.length; i++) { var source = newSources[i]; var sourceKey = newKeys[i]; if (sourceKey === keys[oldIndex]) { results[i] = oldTargets[oldIndex]; updateResult(source, oldTargets[oldIndex], i); oldIndex++; } else { var found = false; for (var j = 1; j < keys.length; j++) { var searchIndex = (oldIndex + j) % keys.length; if (keys[searchIndex] === sourceKey) { results[i] = oldTargets[searchIndex]; updateResult(newSources[i], oldTargets[searchIndex], i); oldIndex = searchIndex + 1; found = true; break; } } if (!found) { results[i] = createResult(source, i); } } } results.length = newSources.length; keys = newKeys; } }; }; /** * Creates a [[Projector]] instance using the provided projectionOptions. * * For more information, see [[Projector]]. * * @param projectionOptions Options that influence how the DOM is rendered and updated. */ exports.createProjector = function (projectorOptions) { var projector; var projectionOptions = applyDefaultProjectionOptions(projectorOptions); projectionOptions.eventHandlerInterceptor = function (propertyName, eventHandler, domNode, properties) { return function () { // intercept function calls (event handlers) to do a render afterwards. projector.scheduleRender(); return eventHandler.apply(properties.bind || this, arguments); }; }; var renderCompleted = true; var scheduled; var stopped = false; var projections = []; var renderFunctions = []; // matches the projections array var doRender = function () { scheduled = undefined; if (!renderCompleted) { return; // The last render threw an error, it should be logged in the browser console. } renderCompleted = false; for (var i = 0; i < projections.length; i++) { var updatedVnode = renderFunctions[i](); projections[i].update(updatedVnode); } renderCompleted = true; }; projector = { scheduleRender: function () { if (!scheduled && !stopped) { scheduled = requestAnimationFrame(doRender); } }, stop: function () { if (scheduled) { cancelAnimationFrame(scheduled); scheduled = undefined; } stopped = true; }, resume: function () { stopped = false; renderCompleted = true; projector.scheduleRender(); }, append: function (parentNode, renderMaquetteFunction) { projections.push(exports.dom.append(parentNode, renderMaquetteFunction(), projectionOptions)); renderFunctions.push(renderMaquetteFunction); }, insertBefore: function (beforeNode, renderMaquetteFunction) { projections.push(exports.dom.insertBefore(beforeNode, renderMaquetteFunction(), projectionOptions)); renderFunctions.push(renderMaquetteFunction); }, merge: function (domNode, renderMaquetteFunction) { projections.push(exports.dom.merge(domNode, renderMaquetteFunction(), projectionOptions)); renderFunctions.push(renderMaquetteFunction); }, replace: function (domNode, renderMaquetteFunction) { var vnode = renderMaquetteFunction(); createDom(vnode, domNode.parentNode, domNode, projectionOptions); domNode.parentNode.removeChild(domNode); projections.push(createProjection(vnode, projectionOptions)); renderFunctions.push(renderMaquetteFunction); }, detach: function (renderMaquetteFunction) { for (var i = 0; i < renderFunctions.length; i++) { if (renderFunctions[i] === renderMaquetteFunction) { renderFunctions.splice(i, 1); return projections.splice(i, 1)[0]; } } throw new Error('renderMaquetteFunction was not found'); } }; return projector; }; })); ================================================ FILE: plugins/UiConfig/media/js/utils/Animation.coffee ================================================ class Animation slideDown: (elem, props) -> if elem.offsetTop > 2000 return h = elem.offsetHeight cstyle = window.getComputedStyle(elem) margin_top = cstyle.marginTop margin_bottom = cstyle.marginBottom padding_top = cstyle.paddingTop padding_bottom = cstyle.paddingBottom transition = cstyle.transition elem.style.boxSizing = "border-box" elem.style.overflow = "hidden" elem.style.transform = "scale(0.6)" elem.style.opacity = "0" elem.style.height = "0px" elem.style.marginTop = "0px" elem.style.marginBottom = "0px" elem.style.paddingTop = "0px" elem.style.paddingBottom = "0px" elem.style.transition = "none" setTimeout (-> elem.className += " animate-inout" elem.style.height = h+"px" elem.style.transform = "scale(1)" elem.style.opacity = "1" elem.style.marginTop = margin_top elem.style.marginBottom = margin_bottom elem.style.paddingTop = padding_top elem.style.paddingBottom = padding_bottom ), 1 elem.addEventListener "transitionend", -> elem.classList.remove("animate-inout") elem.style.transition = elem.style.transform = elem.style.opacity = elem.style.height = null elem.style.boxSizing = elem.style.marginTop = elem.style.marginBottom = null elem.style.paddingTop = elem.style.paddingBottom = elem.style.overflow = null elem.removeEventListener "transitionend", arguments.callee, false slideUp: (elem, remove_func, props) -> if elem.offsetTop > 1000 return remove_func() elem.className += " animate-back" elem.style.boxSizing = "border-box" elem.style.height = elem.offsetHeight+"px" elem.style.overflow = "hidden" elem.style.transform = "scale(1)" elem.style.opacity = "1" elem.style.pointerEvents = "none" setTimeout (-> elem.style.height = "0px" elem.style.marginTop = "0px" elem.style.marginBottom = "0px" elem.style.paddingTop = "0px" elem.style.paddingBottom = "0px" elem.style.transform = "scale(0.8)" elem.style.borderTopWidth = "0px" elem.style.borderBottomWidth = "0px" elem.style.opacity = "0" ), 1 elem.addEventListener "transitionend", (e) -> if e.propertyName == "opacity" or e.elapsedTime >= 0.6 elem.removeEventListener "transitionend", arguments.callee, false remove_func() slideUpInout: (elem, remove_func, props) -> elem.className += " animate-inout" elem.style.boxSizing = "border-box" elem.style.height = elem.offsetHeight+"px" elem.style.overflow = "hidden" elem.style.transform = "scale(1)" elem.style.opacity = "1" elem.style.pointerEvents = "none" setTimeout (-> elem.style.height = "0px" elem.style.marginTop = "0px" elem.style.marginBottom = "0px" elem.style.paddingTop = "0px" elem.style.paddingBottom = "0px" elem.style.transform = "scale(0.8)" elem.style.borderTopWidth = "0px" elem.style.borderBottomWidth = "0px" elem.style.opacity = "0" ), 1 elem.addEventListener "transitionend", (e) -> if e.propertyName == "opacity" or e.elapsedTime >= 0.6 elem.removeEventListener "transitionend", arguments.callee, false remove_func() showRight: (elem, props) -> elem.className += " animate" elem.style.opacity = 0 elem.style.transform = "TranslateX(-20px) Scale(1.01)" setTimeout (-> elem.style.opacity = 1 elem.style.transform = "TranslateX(0px) Scale(1)" ), 1 elem.addEventListener "transitionend", -> elem.classList.remove("animate") elem.style.transform = elem.style.opacity = null show: (elem, props) -> delay = arguments[arguments.length-2]?.delay*1000 or 1 elem.style.opacity = 0 setTimeout (-> elem.className += " animate" ), 1 setTimeout (-> elem.style.opacity = 1 ), delay elem.addEventListener "transitionend", -> elem.classList.remove("animate") elem.style.opacity = null elem.removeEventListener "transitionend", arguments.callee, false hide: (elem, remove_func, props) -> delay = arguments[arguments.length-2]?.delay*1000 or 1 elem.className += " animate" setTimeout (-> elem.style.opacity = 0 ), delay elem.addEventListener "transitionend", (e) -> if e.propertyName == "opacity" remove_func() addVisibleClass: (elem, props) -> setTimeout -> elem.classList.add("visible") window.Animation = new Animation() ================================================ FILE: plugins/UiConfig/media/js/utils/Dollar.coffee ================================================ window.$ = (selector) -> if selector.startsWith("#") return document.getElementById(selector.replace("#", "")) ================================================ FILE: plugins/UiConfig/media/js/utils/ZeroFrame.coffee ================================================ class ZeroFrame extends Class constructor: (url) -> @url = url @waiting_cb = {} @wrapper_nonce = document.location.href.replace(/.*wrapper_nonce=([A-Za-z0-9]+).*/, "$1") @connect() @next_message_id = 1 @history_state = {} @init() init: -> @ connect: -> @target = window.parent window.addEventListener("message", @onMessage, false) @cmd("innerReady") # Save scrollTop window.addEventListener "beforeunload", (e) => @log "save scrollTop", window.pageYOffset @history_state["scrollTop"] = window.pageYOffset @cmd "wrapperReplaceState", [@history_state, null] # Restore scrollTop @cmd "wrapperGetState", [], (state) => @history_state = state if state? @log "restore scrollTop", state, window.pageYOffset if window.pageYOffset == 0 and state window.scroll(window.pageXOffset, state.scrollTop) onMessage: (e) => message = e.data cmd = message.cmd if cmd == "response" if @waiting_cb[message.to]? @waiting_cb[message.to](message.result) else @log "Websocket callback not found:", message else if cmd == "wrapperReady" # Wrapper inited later @cmd("innerReady") else if cmd == "ping" @response message.id, "pong" else if cmd == "wrapperOpenedWebsocket" @onOpenWebsocket() else if cmd == "wrapperClosedWebsocket" @onCloseWebsocket() else @onRequest cmd, message.params onRequest: (cmd, message) => @log "Unknown request", message response: (to, result) -> @send {"cmd": "response", "to": to, "result": result} cmd: (cmd, params={}, cb=null) -> @send {"cmd": cmd, "params": params}, cb send: (message, cb=null) -> message.wrapper_nonce = @wrapper_nonce message.id = @next_message_id @next_message_id += 1 @target.postMessage(message, "*") if cb @waiting_cb[message.id] = cb onOpenWebsocket: => @log "Websocket open" onCloseWebsocket: => @log "Websocket close" window.ZeroFrame = ZeroFrame ================================================ FILE: plugins/UiConfig/plugin_info.json ================================================ { "name": "UiConfig", "description": "Change client settings using the web interface.", "default": "enabled" } ================================================ FILE: plugins/UiFileManager/UiFileManagerPlugin.py ================================================ import io import os import re import urllib from Plugin import PluginManager from Config import config from Translate import Translate plugin_dir = os.path.dirname(__file__) if "_" not in locals(): _ = Translate(plugin_dir + "/languages/") @PluginManager.registerTo("UiRequest") class UiFileManagerPlugin(object): def actionWrapper(self, path, extra_headers=None): match = re.match("/list/(.*?)(/.*|)$", path) if not match: return super().actionWrapper(path, extra_headers) if not extra_headers: extra_headers = {} request_address, inner_path = match.groups() script_nonce = self.getScriptNonce() self.sendHeader(extra_headers=extra_headers, script_nonce=script_nonce) site = self.server.site_manager.need(request_address) if not site: return super().actionWrapper(path, extra_headers) request_params = urllib.parse.urlencode( {"address": site.address, "site": request_address, "inner_path": inner_path.strip("/")} ) is_content_loaded = "content.json" in site.content_manager.contents return iter([super().renderWrapper( site, path, "uimedia/plugins/uifilemanager/list.html?%s" % request_params, "List", extra_headers, show_loadingscreen=not is_content_loaded, script_nonce=script_nonce )]) def actionUiMedia(self, path, *args, **kwargs): if path.startswith("/uimedia/plugins/uifilemanager/"): file_path = path.replace("/uimedia/plugins/uifilemanager/", plugin_dir + "/media/") if config.debug and (file_path.endswith("all.js") or file_path.endswith("all.css")): # If debugging merge *.css to all.css and *.js to all.js from Debug import DebugMedia DebugMedia.merge(file_path) if file_path.endswith("js"): data = _.translateData(open(file_path).read(), mode="js").encode("utf8") elif file_path.endswith("html"): if self.get.get("address"): site = self.server.site_manager.need(self.get.get("address")) if "content.json" not in site.content_manager.contents: site.needFile("content.json") data = _.translateData(open(file_path).read(), mode="html").encode("utf8") else: data = open(file_path, "rb").read() return self.actionFile(file_path, file_obj=io.BytesIO(data), file_size=len(data)) else: return super().actionUiMedia(path) def error404(self, path=""): if not path.endswith("index.html") and not path.endswith("/"): return super().error404(path) path_parts = self.parsePath(path) if not path_parts: return super().error404(path) site = self.server.site_manager.get(path_parts["request_address"]) if not site or not site.content_manager.contents.get("content.json"): return super().error404(path) if path_parts["inner_path"] in site.content_manager.contents.get("content.json").get("files", {}): return super().error404(path) self.sendHeader(200) path_redirect = "/list" + re.sub("^/media/", "/", path) self.log.debug("Index.html not found: %s, redirecting to: %s" % (path, path_redirect)) return self.formatRedirect(path_redirect) ================================================ FILE: plugins/UiFileManager/__init__.py ================================================ from . import UiFileManagerPlugin ================================================ FILE: plugins/UiFileManager/languages/hu.json ================================================ { "New file name:": "Új fájl neve:", "Delete": "Törlés", "Cancel": "Mégse", "Selected:": "Köjelölt:", "Delete and remove optional:": "Törlés és opcionális fájl eltávolítása", " files": " fájl", " (modified)": " (módostott)", " (new)": " (új)", " (optional)": " (opcionális)", " (ignored from content.json)": " (content.json-ból kihagyott)", "Total: ": "Összesen: ", " dir, ": " könyvtár, ", " file in ": " fájl, ", "+ New": "+ Új", "Edit": "Módosít", "View": "Megnyit", "Save": "Mentés", "Save: done!": "Mentés: Kész!" } ================================================ FILE: plugins/UiFileManager/languages/jp.json ================================================ { "New file name:": "新しいファイルの名前:", "Delete": "削除", "Cancel": "キャンセル", "Selected:": "選択済み: ", "Delete and remove optional:": "オプションを削除", " files": " ファイル", " (modified)": " (編集済み)", " (new)": " (新しい)", " (optional)": " (オプション)", " (ignored from content.json)": " (content.jsonから無視されます)", "Total: ": "合計: ", " dir, ": " のディレクトリ, ", " file in ": " のファイル, ", "+ New": "+ 新規作成", "Edit": "編集", "View": "閲覧", "Save": "保存", "Save: done!": "保存完了!" } ================================================ FILE: plugins/UiFileManager/media/codemirror/LICENSE ================================================ MIT License Copyright (C) 2017 by Marijn Haverbeke and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: plugins/UiFileManager/media/codemirror/all.css ================================================ /* ---- base/codemirror.css ---- */ /* BASICS */ .CodeMirror { /* Set height, width, borders, and global font properties here */ font-family: monospace; height: 300px; color: black; direction: ltr; } /* PADDING */ .CodeMirror-lines { padding: 4px 0; /* Vertical padding around content */ } .CodeMirror pre.CodeMirror-line, .CodeMirror pre.CodeMirror-line-like { padding: 0 4px; /* Horizontal padding of content */ } .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { background-color: white; /* The little square between H and V scrollbars */ } /* GUTTER */ .CodeMirror-gutters { border-right: 1px solid #ddd; background-color: #f7f7f7; white-space: nowrap; } .CodeMirror-linenumbers {} .CodeMirror-linenumber { padding: 0 3px 0 5px; min-width: 20px; text-align: right; color: #999; white-space: nowrap; } .CodeMirror-guttermarker { color: black; } .CodeMirror-guttermarker-subtle { color: #999; } /* CURSOR */ .CodeMirror-cursor { border-left: 1px solid black; border-right: none; width: 0; } /* Shown when moving in bi-directional text */ .CodeMirror div.CodeMirror-secondarycursor { border-left: 1px solid silver; } .cm-fat-cursor .CodeMirror-cursor { width: auto; border: 0 !important; background: #7e7; } .cm-fat-cursor div.CodeMirror-cursors { z-index: 1; } .cm-fat-cursor-mark { background-color: rgba(20, 255, 20, 0.5); -webkit-animation: blink 1.06s steps(1) infinite; -moz-animation: blink 1.06s steps(1) infinite; -webkit-animation: blink 1.06s steps(1) infinite; -moz-animation: blink 1.06s steps(1) infinite; -o-animation: blink 1.06s steps(1) infinite; -ms-animation: blink 1.06s steps(1) infinite; animation: blink 1.06s steps(1) infinite ; } .cm-animate-fat-cursor { width: auto; border: 0; -webkit-animation: blink 1.06s steps(1) infinite; -moz-animation: blink 1.06s steps(1) infinite; -webkit-animation: blink 1.06s steps(1) infinite; -moz-animation: blink 1.06s steps(1) infinite; -o-animation: blink 1.06s steps(1) infinite; -ms-animation: blink 1.06s steps(1) infinite; animation: blink 1.06s steps(1) infinite ; background-color: #7e7; } @-moz-keyframes blink { 0% {} 50% { background-color: transparent; } 100% {} } @-webkit-keyframes blink { 0% {} 50% { background-color: transparent; } 100% {} } @keyframes blink { 0% {} 50% { background-color: transparent; } 100% {} } @-webkit-keyframes blink { 0% {} 50% { background-color: transparent; } 100% {} } @-moz-keyframes blink { 0% {} 50% { background-color: transparent; } 100% {} } /* Can style cursor different in overwrite (non-insert) mode */ .CodeMirror-overwrite .CodeMirror-cursor {} .cm-tab { display: inline-block; text-decoration: inherit; } .CodeMirror-rulers { position: absolute; left: 0; right: 0; top: -50px; bottom: 0; overflow: hidden; } .CodeMirror-ruler { border-left: 1px solid #ccc; top: 0; bottom: 0; position: absolute; } /* DEFAULT THEME */ .cm-s-default .cm-header {color: blue;} .cm-s-default .cm-quote {color: #090;} .cm-negative {color: #d44;} .cm-positive {color: #292;} .cm-header, .cm-strong {font-weight: bold;} .cm-em {font-style: italic;} .cm-link {text-decoration: underline;} .cm-strikethrough {text-decoration: line-through;} .cm-s-default .cm-keyword {color: #708;} .cm-s-default .cm-atom {color: #219;} .cm-s-default .cm-number {color: #164;} .cm-s-default .cm-def {color: #00f;} .cm-s-default .cm-variable, .cm-s-default .cm-punctuation, .cm-s-default .cm-property, .cm-s-default .cm-operator {} .cm-s-default .cm-variable-2 {color: #05a;} .cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;} .cm-s-default .cm-comment {color: #a50;} .cm-s-default .cm-string {color: #a11;} .cm-s-default .cm-string-2 {color: #f50;} .cm-s-default .cm-meta {color: #555;} .cm-s-default .cm-qualifier {color: #555;} .cm-s-default .cm-builtin {color: #30a;} .cm-s-default .cm-bracket {color: #997;} .cm-s-default .cm-tag {color: #170;} .cm-s-default .cm-attribute {color: #00c;} .cm-s-default .cm-hr {color: #999;} .cm-s-default .cm-link {color: #00c;} .cm-s-default .cm-error {color: #f00;} .cm-invalidchar {color: #f00;} .CodeMirror-composing { border-bottom: 2px solid; } /* Default styles for common addons */ div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;} div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;} .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); } .CodeMirror-activeline-background {background: #e8f2ff;} /* STOP */ /* The rest of this file contains styles related to the mechanics of the editor. You probably shouldn't touch them. */ .CodeMirror { position: relative; overflow: hidden; background: white; } .CodeMirror-scroll { overflow: scroll !important; /* Things will break if this is overridden */ /* 50px is the magic margin used to hide the element's real scrollbars */ /* See overflow: hidden in .CodeMirror */ margin-bottom: -50px; margin-right: -50px; padding-bottom: 50px; height: 100%; outline: none; /* Prevent dragging from highlighting the element */ position: relative; } .CodeMirror-sizer { position: relative; border-right: 50px solid transparent; } /* The fake, visible scrollbars. Used to force redraw during scrolling before actual scrolling happens, thus preventing shaking and flickering artifacts. */ .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { position: absolute; z-index: 6; display: none; } .CodeMirror-vscrollbar { right: 0; top: 0; overflow-x: hidden; overflow-y: scroll; } .CodeMirror-hscrollbar { bottom: 0; left: 0; overflow-y: hidden; overflow-x: scroll; } .CodeMirror-scrollbar-filler { right: 0; bottom: 0; } .CodeMirror-gutter-filler { left: 0; bottom: 0; } .CodeMirror-gutters { position: absolute; left: 0; top: 0; min-height: 100%; z-index: 3; } .CodeMirror-gutter { white-space: normal; height: 100%; display: inline-block; vertical-align: top; margin-bottom: -50px; } .CodeMirror-gutter-wrapper { position: absolute; z-index: 4; background: none !important; border: none !important; } .CodeMirror-gutter-background { position: absolute; top: 0; bottom: 0; z-index: 4; } .CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; } .CodeMirror-gutter-wrapper ::selection { background-color: transparent } .CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent } .CodeMirror-lines { cursor: text; min-height: 1px; /* prevents collapsing before first draw */ } .CodeMirror pre.CodeMirror-line, .CodeMirror pre.CodeMirror-line-like { /* Reset some styles that the rest of the page might have set */ -moz-border-radius: 0; -webkit-border-radius: 0; -webkit-border-radius: 0; -moz-border-radius: 0; -o-border-radius: 0; -ms-border-radius: 0; border-radius: 0 ; border-width: 0; background: transparent; font-family: inherit; font-size: inherit; margin: 0; white-space: pre; word-wrap: normal; line-height: inherit; color: inherit; z-index: 2; position: relative; overflow: visible; -webkit-tap-highlight-color: transparent; -webkit-font-variant-ligatures: contextual; font-variant-ligatures: contextual; } .CodeMirror-wrap pre.CodeMirror-line, .CodeMirror-wrap pre.CodeMirror-line-like { word-wrap: break-word; white-space: pre-wrap; word-break: normal; } .CodeMirror-linebackground { position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: 0; } .CodeMirror-linewidget { position: relative; z-index: 2; padding: 0.1px; /* Force widget margins to stay inside of the container */ } .CodeMirror-widget {} .CodeMirror-rtl pre { direction: rtl; } .CodeMirror-code { outline: none; } /* Force content-box sizing for the elements where we expect it */ .CodeMirror-scroll, .CodeMirror-sizer, .CodeMirror-gutter, .CodeMirror-gutters, .CodeMirror-linenumber { -moz-box-sizing: content-box; -webkit-box-sizing: content-box; -moz-box-sizing: content-box; -o-box-sizing: content-box; -ms-box-sizing: content-box; box-sizing: content-box ; } .CodeMirror-measure { position: absolute; width: 100%; height: 0; overflow: hidden; visibility: hidden; } .CodeMirror-cursor { position: absolute; pointer-events: none; } .CodeMirror-measure pre { position: static; } div.CodeMirror-cursors { visibility: hidden; position: relative; z-index: 3; } div.CodeMirror-dragcursors { visibility: visible; } .CodeMirror-focused div.CodeMirror-cursors { visibility: visible; } .CodeMirror-selected { background: #d9d9d9; } .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } .CodeMirror-crosshair { cursor: crosshair; } .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; } .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; } .cm-searching { background-color: #ffa; background-color: rgba(255, 255, 0, .4); } /* Used to force a border model for a node */ .cm-force-border { padding-right: .1px; } @media print { /* Hide the cursor when printing */ .CodeMirror div.CodeMirror-cursors { visibility: hidden; } } /* See issue #2901 */ .cm-tab-wrap-hack:after { content: ''; } /* Help users use markselection to safely style text background */ span.CodeMirror-selectedtext { background: none; } /* ---- extension/mdn-like-custom.css ---- */ /* MDN-LIKE Theme - Mozilla Ported to CodeMirror by Peter Kroon Report bugs/issues here: https://github.com/codemirror/CodeMirror/issues GitHub: @peterkroon The mdn-like theme is inspired on the displayed code examples at: https://developer.mozilla.org/en-US/docs/Web/CSS/animation */ .cm-s-mdn-like.CodeMirror { color: #666; background-color: #fff; } .cm-s-mdn-like div.CodeMirror-selected { background: #fefdb5; } .cm-s-mdn-like .CodeMirror-line::selection, .cm-s-mdn-like .CodeMirror-line > span::selection, .cm-s-mdn-like .CodeMirror-line > span > span::selection { background: #fefdb5; } .cm-s-mdn-like .CodeMirror-line::-moz-selection, .cm-s-mdn-like .CodeMirror-line > span::-moz-selection, .cm-s-mdn-like .CodeMirror-line > span > span::-moz-selection { background: #fefdb5; } .cm-s-mdn-like .CodeMirror-gutters { background: #f8f8f8; color: #333; } .cm-s-mdn-like .CodeMirror-linenumber { color: #aaa; padding-left: 8px; } .cm-s-mdn-like .CodeMirror-cursor { border-left: 2px solid #222; } .cm-s-mdn-like .cm-keyword { color: #6262FF; } .cm-s-mdn-like .cm-atom { color: #F90; } .cm-s-mdn-like .cm-number { color: #ca7841; } .cm-s-mdn-like .cm-def { color: #8DA6CE; } .cm-s-mdn-like span.cm-variable-2, .cm-s-mdn-like span.cm-tag { color: #690; } .cm-s-mdn-like span.cm-variable-3, .cm-s-mdn-like span.cm-def, .cm-s-mdn-like span.cm-type { color: #07a; } .cm-s-mdn-like .cm-variable { color: #07a; } .cm-s-mdn-like .cm-property { color: #905; } .cm-s-mdn-like .cm-qualifier { color: #690; } .cm-s-mdn-like .cm-operator { color: #cda869; } .cm-s-mdn-like .cm-comment { color:#777; font-weight:normal; } .cm-s-mdn-like .cm-string { color:#07a; } .cm-s-mdn-like .cm-string-2 { color:#bd6b18; } /*?*/ .cm-s-mdn-like .cm-meta { color: #000; } /*?*/ .cm-s-mdn-like .cm-builtin { color: #9B7536; } /*?*/ .cm-s-mdn-like .cm-tag { color: #997643; } .cm-s-mdn-like .cm-attribute { color: #d6bb6d; } /*?*/ .cm-s-mdn-like .cm-header { color: #FF6400; } .cm-s-mdn-like .cm-hr { color: #AEAEAE; } .cm-s-mdn-like .cm-link { color:#ad9361; font-style:italic; text-decoration:none; } .cm-s-mdn-like .cm-error { border-bottom: 1px solid red; } div.cm-s-mdn-like .CodeMirror-activeline-background { background: #efefff; } div.cm-s-mdn-like span.CodeMirror-matchingbracket { outline:1px solid grey; color: inherit; } /* ---- extension/dialog/dialog.css ---- */ .CodeMirror-dialog { position: absolute; left: 0; right: 0; background: inherit; z-index: 15; padding: .1em .8em; overflow: hidden; color: inherit; } .CodeMirror-dialog-top { border-bottom: 1px solid #eee; top: 0; } .CodeMirror-dialog-bottom { border-top: 1px solid #eee; bottom: 0; } .CodeMirror-dialog input { border: none; outline: none; background: transparent; width: 20em; color: inherit; font-family: monospace; } .CodeMirror-dialog button { font-size: 70%; } /* ---- extension/fold/foldgutter.css ---- */ .CodeMirror-foldmarker { color: blue; text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px; font-family: arial; line-height: .3; cursor: pointer; } .CodeMirror-foldgutter { width: .7em; } .CodeMirror-foldgutter-open, .CodeMirror-foldgutter-folded { cursor: pointer; } .CodeMirror-foldgutter-open:after { content: "\25BE"; } .CodeMirror-foldgutter-folded:after { content: "\25B8"; } /* ---- extension/hint/show-hint.css ---- */ .CodeMirror-hints { position: absolute; z-index: 10; overflow: hidden; list-style: none; margin: 0; padding: 2px; -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2); -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2); -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2); -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2); -o-box-shadow: 2px 3px 5px rgba(0,0,0,.2); -ms-box-shadow: 2px 3px 5px rgba(0,0,0,.2); box-shadow: 2px 3px 5px rgba(0,0,0,.2) ; -webkit-border-radius: 3px; -moz-border-radius: 3px; -o-border-radius: 3px; -ms-border-radius: 3px; border-radius: 3px ; border: 1px solid silver; background: white; font-size: 90%; font-family: monospace; max-height: 20em; overflow-y: auto; } .CodeMirror-hint { margin: 0; padding: 0 4px; -webkit-border-radius: 2px; -moz-border-radius: 2px; -o-border-radius: 2px; -ms-border-radius: 2px; border-radius: 2px ; white-space: pre; color: black; cursor: pointer; } li.CodeMirror-hint-active { background: #08f; color: white; } /* ---- extension/lint/lint.css ---- */ /* The lint marker gutter */ .CodeMirror-lint-markers { width: 16px; } .CodeMirror-lint-tooltip { background-color: #ffd; border: 1px solid black; -webkit-border-radius: 4px 4px 4px 4px; -moz-border-radius: 4px 4px 4px 4px; -o-border-radius: 4px 4px 4px 4px; -ms-border-radius: 4px 4px 4px 4px; border-radius: 4px 4px 4px 4px ; color: black; font-family: monospace; font-size: 10pt; overflow: hidden; padding: 2px 5px; position: fixed; white-space: pre; white-space: pre-wrap; z-index: 100; max-width: 600px; opacity: 0; -webkit-transition: opacity .4s; -moz-transition: opacity .4s; -o-transition: opacity .4s; -ms-transition: opacity .4s; transition: opacity .4s ; -moz-transition: opacity .4s; -webkit-transition: opacity .4s; -o-transition: opacity .4s; -ms-transition: opacity .4s; } .CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning { background-position: left bottom; background-repeat: repeat-x; } .CodeMirror-lint-mark-error { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==") ; } .CodeMirror-lint-mark-warning { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII="); } .CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning { background-position: center center; background-repeat: no-repeat; cursor: pointer; display: inline-block; height: 16px; width: 16px; vertical-align: middle; position: relative; } .CodeMirror-lint-message-error, .CodeMirror-lint-message-warning { padding-left: 18px; background-position: top left; background-repeat: no-repeat; } .CodeMirror-lint-marker-error, .CodeMirror-lint-message-error { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII="); } .CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII="); } .CodeMirror-lint-marker-multiple { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC"); background-repeat: no-repeat; background-position: right bottom; width: 100%; height: 100%; } /* ---- extension/scroll/simplescrollbars.css ---- */ .CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div { position: absolute; background: #ccc; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; border: 1px solid #bbb; -webkit-border-radius: 2px; -moz-border-radius: 2px; -o-border-radius: 2px; -ms-border-radius: 2px; border-radius: 2px ; } .CodeMirror-simplescroll-horizontal, .CodeMirror-simplescroll-vertical { position: absolute; z-index: 6; background: #eee; } .CodeMirror-simplescroll-horizontal { bottom: 0; left: 0; height: 8px; } .CodeMirror-simplescroll-horizontal div { bottom: 0; height: 100%; } .CodeMirror-simplescroll-vertical { right: 0; top: 0; width: 8px; } .CodeMirror-simplescroll-vertical div { right: 0; width: 100%; } .CodeMirror-overlayscroll .CodeMirror-scrollbar-filler, .CodeMirror-overlayscroll .CodeMirror-gutter-filler { display: none; } .CodeMirror-overlayscroll-horizontal div, .CodeMirror-overlayscroll-vertical div { position: absolute; background: #bcd; -webkit-border-radius: 3px; -moz-border-radius: 3px; -o-border-radius: 3px; -ms-border-radius: 3px; border-radius: 3px ; } .CodeMirror-overlayscroll-horizontal, .CodeMirror-overlayscroll-vertical { position: absolute; z-index: 6; } .CodeMirror-overlayscroll-horizontal { bottom: 0; left: 0; height: 6px; } .CodeMirror-overlayscroll-horizontal div { bottom: 0; height: 100%; } .CodeMirror-overlayscroll-vertical { right: 0; top: 0; width: 6px; } .CodeMirror-overlayscroll-vertical div { right: 0; width: 100%; } /* ---- extension/search/matchesonscrollbar.css ---- */ .CodeMirror-search-match { background: gold; border-top: 1px solid orange; border-bottom: 1px solid orange; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; opacity: .5; } ================================================ FILE: plugins/UiFileManager/media/codemirror/all.js ================================================ /* ---- base/codemirror.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // This is CodeMirror (https://codemirror.net), a code editor // implemented in JavaScript on top of the browser's DOM. // // You can find some technical background for some of the code below // at http://marijnhaverbeke.nl/blog/#cm-internals . (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = global || self, global.CodeMirror = factory()); }(this, (function () { 'use strict'; // Kludges for bugs and behavior differences that can't be feature // detected are enabled based on userAgent etc sniffing. var userAgent = navigator.userAgent; var platform = navigator.platform; var gecko = /gecko\/\d/i.test(userAgent); var ie_upto10 = /MSIE \d/.test(userAgent); var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent); var edge = /Edge\/(\d+)/.exec(userAgent); var ie = ie_upto10 || ie_11up || edge; var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]); var webkit = !edge && /WebKit\//.test(userAgent); var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent); var chrome = !edge && /Chrome\//.test(userAgent); var presto = /Opera\//.test(userAgent); var safari = /Apple Computer/.test(navigator.vendor); var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent); var phantom = /PhantomJS/.test(userAgent); var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent); var android = /Android/.test(userAgent); // This is woefully incomplete. Suggestions for alternative methods welcome. var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent); var mac = ios || /Mac/.test(platform); var chromeOS = /\bCrOS\b/.test(userAgent); var windows = /win/i.test(platform); var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/); if (presto_version) { presto_version = Number(presto_version[1]); } if (presto_version && presto_version >= 15) { presto = false; webkit = true; } // Some browsers use the wrong event properties to signal cmd/ctrl on OS X var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11)); var captureRightClick = gecko || (ie && ie_version >= 9); function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") } var rmClass = function(node, cls) { var current = node.className; var match = classTest(cls).exec(current); if (match) { var after = current.slice(match.index + match[0].length); node.className = current.slice(0, match.index) + (after ? match[1] + after : ""); } }; function removeChildren(e) { for (var count = e.childNodes.length; count > 0; --count) { e.removeChild(e.firstChild); } return e } function removeChildrenAndAdd(parent, e) { return removeChildren(parent).appendChild(e) } function elt(tag, content, className, style) { var e = document.createElement(tag); if (className) { e.className = className; } if (style) { e.style.cssText = style; } if (typeof content == "string") { e.appendChild(document.createTextNode(content)); } else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]); } } return e } // wrapper for elt, which removes the elt from the accessibility tree function eltP(tag, content, className, style) { var e = elt(tag, content, className, style); e.setAttribute("role", "presentation"); return e } var range; if (document.createRange) { range = function(node, start, end, endNode) { var r = document.createRange(); r.setEnd(endNode || node, end); r.setStart(node, start); return r }; } else { range = function(node, start, end) { var r = document.body.createTextRange(); try { r.moveToElementText(node.parentNode); } catch(e) { return r } r.collapse(true); r.moveEnd("character", end); r.moveStart("character", start); return r }; } function contains(parent, child) { if (child.nodeType == 3) // Android browser always returns false when child is a textnode { child = child.parentNode; } if (parent.contains) { return parent.contains(child) } do { if (child.nodeType == 11) { child = child.host; } if (child == parent) { return true } } while (child = child.parentNode) } function activeElt() { // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement. // IE < 10 will throw when accessed while the page is loading or in an iframe. // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable. var activeElement; try { activeElement = document.activeElement; } catch(e) { activeElement = document.body || null; } while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement) { activeElement = activeElement.shadowRoot.activeElement; } return activeElement } function addClass(node, cls) { var current = node.className; if (!classTest(cls).test(current)) { node.className += (current ? " " : "") + cls; } } function joinClasses(a, b) { var as = a.split(" "); for (var i = 0; i < as.length; i++) { if (as[i] && !classTest(as[i]).test(b)) { b += " " + as[i]; } } return b } var selectInput = function(node) { node.select(); }; if (ios) // Mobile Safari apparently has a bug where select() is broken. { selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; }; } else if (ie) // Suppress mysterious IE10 errors { selectInput = function(node) { try { node.select(); } catch(_e) {} }; } function bind(f) { var args = Array.prototype.slice.call(arguments, 1); return function(){return f.apply(null, args)} } function copyObj(obj, target, overwrite) { if (!target) { target = {}; } for (var prop in obj) { if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop))) { target[prop] = obj[prop]; } } return target } // Counts the column offset in a string, taking tabs into account. // Used mostly to find indentation. function countColumn(string, end, tabSize, startIndex, startValue) { if (end == null) { end = string.search(/[^\s\u00a0]/); if (end == -1) { end = string.length; } } for (var i = startIndex || 0, n = startValue || 0;;) { var nextTab = string.indexOf("\t", i); if (nextTab < 0 || nextTab >= end) { return n + (end - i) } n += nextTab - i; n += tabSize - (n % tabSize); i = nextTab + 1; } } var Delayed = function() { this.id = null; this.f = null; this.time = 0; this.handler = bind(this.onTimeout, this); }; Delayed.prototype.onTimeout = function (self) { self.id = 0; if (self.time <= +new Date) { self.f(); } else { setTimeout(self.handler, self.time - +new Date); } }; Delayed.prototype.set = function (ms, f) { this.f = f; var time = +new Date + ms; if (!this.id || time < this.time) { clearTimeout(this.id); this.id = setTimeout(this.handler, ms); this.time = time; } }; function indexOf(array, elt) { for (var i = 0; i < array.length; ++i) { if (array[i] == elt) { return i } } return -1 } // Number of pixels added to scroller and sizer to hide scrollbar var scrollerGap = 50; // Returned or thrown by various protocols to signal 'I'm not // handling this'. var Pass = {toString: function(){return "CodeMirror.Pass"}}; // Reused option objects for setSelection & friends var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"}; // The inverse of countColumn -- find the offset that corresponds to // a particular column. function findColumn(string, goal, tabSize) { for (var pos = 0, col = 0;;) { var nextTab = string.indexOf("\t", pos); if (nextTab == -1) { nextTab = string.length; } var skipped = nextTab - pos; if (nextTab == string.length || col + skipped >= goal) { return pos + Math.min(skipped, goal - col) } col += nextTab - pos; col += tabSize - (col % tabSize); pos = nextTab + 1; if (col >= goal) { return pos } } } var spaceStrs = [""]; function spaceStr(n) { while (spaceStrs.length <= n) { spaceStrs.push(lst(spaceStrs) + " "); } return spaceStrs[n] } function lst(arr) { return arr[arr.length-1] } function map(array, f) { var out = []; for (var i = 0; i < array.length; i++) { out[i] = f(array[i], i); } return out } function insertSorted(array, value, score) { var pos = 0, priority = score(value); while (pos < array.length && score(array[pos]) <= priority) { pos++; } array.splice(pos, 0, value); } function nothing() {} function createObj(base, props) { var inst; if (Object.create) { inst = Object.create(base); } else { nothing.prototype = base; inst = new nothing(); } if (props) { copyObj(props, inst); } return inst } var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/; function isWordCharBasic(ch) { return /\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)) } function isWordChar(ch, helper) { if (!helper) { return isWordCharBasic(ch) } if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) { return true } return helper.test(ch) } function isEmpty(obj) { for (var n in obj) { if (obj.hasOwnProperty(n) && obj[n]) { return false } } return true } // Extending unicode characters. A series of a non-extending char + // any number of extending chars is treated as a single unit as far // as editing and measuring is concerned. This is not fully correct, // since some scripts/fonts/browsers also treat other configurations // of code points as a group. var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/; function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) } // Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range. function skipExtendingChars(str, pos, dir) { while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) { pos += dir; } return pos } // Returns the value from the range [`from`; `to`] that satisfies // `pred` and is closest to `from`. Assumes that at least `to` // satisfies `pred`. Supports `from` being greater than `to`. function findFirst(pred, from, to) { // At any point we are certain `to` satisfies `pred`, don't know // whether `from` does. var dir = from > to ? -1 : 1; for (;;) { if (from == to) { return from } var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF); if (mid == from) { return pred(mid) ? from : to } if (pred(mid)) { to = mid; } else { from = mid + dir; } } } // BIDI HELPERS function iterateBidiSections(order, from, to, f) { if (!order) { return f(from, to, "ltr", 0) } var found = false; for (var i = 0; i < order.length; ++i) { var part = order[i]; if (part.from < to && part.to > from || from == to && part.to == from) { f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr", i); found = true; } } if (!found) { f(from, to, "ltr"); } } var bidiOther = null; function getBidiPartAt(order, ch, sticky) { var found; bidiOther = null; for (var i = 0; i < order.length; ++i) { var cur = order[i]; if (cur.from < ch && cur.to > ch) { return i } if (cur.to == ch) { if (cur.from != cur.to && sticky == "before") { found = i; } else { bidiOther = i; } } if (cur.from == ch) { if (cur.from != cur.to && sticky != "before") { found = i; } else { bidiOther = i; } } } return found != null ? found : bidiOther } // Bidirectional ordering algorithm // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm // that this (partially) implements. // One-char codes used for character types: // L (L): Left-to-Right // R (R): Right-to-Left // r (AL): Right-to-Left Arabic // 1 (EN): European Number // + (ES): European Number Separator // % (ET): European Number Terminator // n (AN): Arabic Number // , (CS): Common Number Separator // m (NSM): Non-Spacing Mark // b (BN): Boundary Neutral // s (B): Paragraph Separator // t (S): Segment Separator // w (WS): Whitespace // N (ON): Other Neutrals // Returns null if characters are ordered as they appear // (left-to-right), or an array of sections ({from, to, level} // objects) in the order in which they occur visually. var bidiOrdering = (function() { // Character types for codepoints 0 to 0xff var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN"; // Character types for codepoints 0x600 to 0x6f9 var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111"; function charType(code) { if (code <= 0xf7) { return lowTypes.charAt(code) } else if (0x590 <= code && code <= 0x5f4) { return "R" } else if (0x600 <= code && code <= 0x6f9) { return arabicTypes.charAt(code - 0x600) } else if (0x6ee <= code && code <= 0x8ac) { return "r" } else if (0x2000 <= code && code <= 0x200b) { return "w" } else if (code == 0x200c) { return "b" } else { return "L" } } var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/; function BidiSpan(level, from, to) { this.level = level; this.from = from; this.to = to; } return function(str, direction) { var outerType = direction == "ltr" ? "L" : "R"; if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) { return false } var len = str.length, types = []; for (var i = 0; i < len; ++i) { types.push(charType(str.charCodeAt(i))); } // W1. Examine each non-spacing mark (NSM) in the level run, and // change the type of the NSM to the type of the previous // character. If the NSM is at the start of the level run, it will // get the type of sor. for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) { var type = types[i$1]; if (type == "m") { types[i$1] = prev; } else { prev = type; } } // W2. Search backwards from each instance of a European number // until the first strong type (R, L, AL, or sor) is found. If an // AL is found, change the type of the European number to Arabic // number. // W3. Change all ALs to R. for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) { var type$1 = types[i$2]; if (type$1 == "1" && cur == "r") { types[i$2] = "n"; } else if (isStrong.test(type$1)) { cur = type$1; if (type$1 == "r") { types[i$2] = "R"; } } } // W4. A single European separator between two European numbers // changes to a European number. A single common separator between // two numbers of the same type changes to that type. for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) { var type$2 = types[i$3]; if (type$2 == "+" && prev$1 == "1" && types[i$3+1] == "1") { types[i$3] = "1"; } else if (type$2 == "," && prev$1 == types[i$3+1] && (prev$1 == "1" || prev$1 == "n")) { types[i$3] = prev$1; } prev$1 = type$2; } // W5. A sequence of European terminators adjacent to European // numbers changes to all European numbers. // W6. Otherwise, separators and terminators change to Other // Neutral. for (var i$4 = 0; i$4 < len; ++i$4) { var type$3 = types[i$4]; if (type$3 == ",") { types[i$4] = "N"; } else if (type$3 == "%") { var end = (void 0); for (end = i$4 + 1; end < len && types[end] == "%"; ++end) {} var replace = (i$4 && types[i$4-1] == "!") || (end < len && types[end] == "1") ? "1" : "N"; for (var j = i$4; j < end; ++j) { types[j] = replace; } i$4 = end - 1; } } // W7. Search backwards from each instance of a European number // until the first strong type (R, L, or sor) is found. If an L is // found, then change the type of the European number to L. for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) { var type$4 = types[i$5]; if (cur$1 == "L" && type$4 == "1") { types[i$5] = "L"; } else if (isStrong.test(type$4)) { cur$1 = type$4; } } // N1. A sequence of neutrals takes the direction of the // surrounding strong text if the text on both sides has the same // direction. European and Arabic numbers act as if they were R in // terms of their influence on neutrals. Start-of-level-run (sor) // and end-of-level-run (eor) are used at level run boundaries. // N2. Any remaining neutrals take the embedding direction. for (var i$6 = 0; i$6 < len; ++i$6) { if (isNeutral.test(types[i$6])) { var end$1 = (void 0); for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {} var before = (i$6 ? types[i$6-1] : outerType) == "L"; var after = (end$1 < len ? types[end$1] : outerType) == "L"; var replace$1 = before == after ? (before ? "L" : "R") : outerType; for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1; } i$6 = end$1 - 1; } } // Here we depart from the documented algorithm, in order to avoid // building up an actual levels array. Since there are only three // levels (0, 1, 2) in an implementation that doesn't take // explicit embedding into account, we can build up the order on // the fly, without following the level-based algorithm. var order = [], m; for (var i$7 = 0; i$7 < len;) { if (countsAsLeft.test(types[i$7])) { var start = i$7; for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {} order.push(new BidiSpan(0, start, i$7)); } else { var pos = i$7, at = order.length, isRTL = direction == "rtl" ? 1 : 0; for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {} for (var j$2 = pos; j$2 < i$7;) { if (countsAsNum.test(types[j$2])) { if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); at += isRTL; } var nstart = j$2; for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {} order.splice(at, 0, new BidiSpan(2, nstart, j$2)); at += isRTL; pos = j$2; } else { ++j$2; } } if (pos < i$7) { order.splice(at, 0, new BidiSpan(1, pos, i$7)); } } } if (direction == "ltr") { if (order[0].level == 1 && (m = str.match(/^\s+/))) { order[0].from = m[0].length; order.unshift(new BidiSpan(0, 0, m[0].length)); } if (lst(order).level == 1 && (m = str.match(/\s+$/))) { lst(order).to -= m[0].length; order.push(new BidiSpan(0, len - m[0].length, len)); } } return direction == "rtl" ? order.reverse() : order } })(); // Get the bidi ordering for the given line (and cache it). Returns // false for lines that are fully left-to-right, and an array of // BidiSpan objects otherwise. function getOrder(line, direction) { var order = line.order; if (order == null) { order = line.order = bidiOrdering(line.text, direction); } return order } // EVENT HANDLING // Lightweight event framework. on/off also work on DOM nodes, // registering native DOM handlers. var noHandlers = []; var on = function(emitter, type, f) { if (emitter.addEventListener) { emitter.addEventListener(type, f, false); } else if (emitter.attachEvent) { emitter.attachEvent("on" + type, f); } else { var map = emitter._handlers || (emitter._handlers = {}); map[type] = (map[type] || noHandlers).concat(f); } }; function getHandlers(emitter, type) { return emitter._handlers && emitter._handlers[type] || noHandlers } function off(emitter, type, f) { if (emitter.removeEventListener) { emitter.removeEventListener(type, f, false); } else if (emitter.detachEvent) { emitter.detachEvent("on" + type, f); } else { var map = emitter._handlers, arr = map && map[type]; if (arr) { var index = indexOf(arr, f); if (index > -1) { map[type] = arr.slice(0, index).concat(arr.slice(index + 1)); } } } } function signal(emitter, type /*, values...*/) { var handlers = getHandlers(emitter, type); if (!handlers.length) { return } var args = Array.prototype.slice.call(arguments, 2); for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args); } } // The DOM events that CodeMirror handles can be overridden by // registering a (non-DOM) handler on the editor for the event name, // and preventDefault-ing the event in that handler. function signalDOMEvent(cm, e, override) { if (typeof e == "string") { e = {type: e, preventDefault: function() { this.defaultPrevented = true; }}; } signal(cm, override || e.type, cm, e); return e_defaultPrevented(e) || e.codemirrorIgnore } function signalCursorActivity(cm) { var arr = cm._handlers && cm._handlers.cursorActivity; if (!arr) { return } var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []); for (var i = 0; i < arr.length; ++i) { if (indexOf(set, arr[i]) == -1) { set.push(arr[i]); } } } function hasHandler(emitter, type) { return getHandlers(emitter, type).length > 0 } // Add on and off methods to a constructor's prototype, to make // registering events on such objects more convenient. function eventMixin(ctor) { ctor.prototype.on = function(type, f) {on(this, type, f);}; ctor.prototype.off = function(type, f) {off(this, type, f);}; } // Due to the fact that we still support jurassic IE versions, some // compatibility wrappers are needed. function e_preventDefault(e) { if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } } function e_stopPropagation(e) { if (e.stopPropagation) { e.stopPropagation(); } else { e.cancelBubble = true; } } function e_defaultPrevented(e) { return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false } function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);} function e_target(e) {return e.target || e.srcElement} function e_button(e) { var b = e.which; if (b == null) { if (e.button & 1) { b = 1; } else if (e.button & 2) { b = 3; } else if (e.button & 4) { b = 2; } } if (mac && e.ctrlKey && b == 1) { b = 3; } return b } // Detect drag-and-drop var dragAndDrop = function() { // There is *some* kind of drag-and-drop support in IE6-8, but I // couldn't get it to work yet. if (ie && ie_version < 9) { return false } var div = elt('div'); return "draggable" in div || "dragDrop" in div }(); var zwspSupported; function zeroWidthElement(measure) { if (zwspSupported == null) { var test = elt("span", "\u200b"); removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")])); if (measure.firstChild.offsetHeight != 0) { zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8); } } var node = zwspSupported ? elt("span", "\u200b") : elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px"); node.setAttribute("cm-text", ""); return node } // Feature-detect IE's crummy client rect reporting for bidi text var badBidiRects; function hasBadBidiRects(measure) { if (badBidiRects != null) { return badBidiRects } var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA")); var r0 = range(txt, 0, 1).getBoundingClientRect(); var r1 = range(txt, 1, 2).getBoundingClientRect(); removeChildren(measure); if (!r0 || r0.left == r0.right) { return false } // Safari returns null in some cases (#2780) return badBidiRects = (r1.right - r0.right < 3) } // See if "".split is the broken IE version, if so, provide an // alternative way to split lines. var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function (string) { var pos = 0, result = [], l = string.length; while (pos <= l) { var nl = string.indexOf("\n", pos); if (nl == -1) { nl = string.length; } var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl); var rt = line.indexOf("\r"); if (rt != -1) { result.push(line.slice(0, rt)); pos += rt + 1; } else { result.push(line); pos = nl + 1; } } return result } : function (string) { return string.split(/\r\n?|\n/); }; var hasSelection = window.getSelection ? function (te) { try { return te.selectionStart != te.selectionEnd } catch(e) { return false } } : function (te) { var range; try {range = te.ownerDocument.selection.createRange();} catch(e) {} if (!range || range.parentElement() != te) { return false } return range.compareEndPoints("StartToEnd", range) != 0 }; var hasCopyEvent = (function () { var e = elt("div"); if ("oncopy" in e) { return true } e.setAttribute("oncopy", "return;"); return typeof e.oncopy == "function" })(); var badZoomedRects = null; function hasBadZoomedRects(measure) { if (badZoomedRects != null) { return badZoomedRects } var node = removeChildrenAndAdd(measure, elt("span", "x")); var normal = node.getBoundingClientRect(); var fromRange = range(node, 0, 1).getBoundingClientRect(); return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1 } // Known modes, by name and by MIME var modes = {}, mimeModes = {}; // Extra arguments are stored as the mode's dependencies, which is // used by (legacy) mechanisms like loadmode.js to automatically // load a mode. (Preferred mechanism is the require/define calls.) function defineMode(name, mode) { if (arguments.length > 2) { mode.dependencies = Array.prototype.slice.call(arguments, 2); } modes[name] = mode; } function defineMIME(mime, spec) { mimeModes[mime] = spec; } // Given a MIME type, a {name, ...options} config object, or a name // string, return a mode config object. function resolveMode(spec) { if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) { spec = mimeModes[spec]; } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) { var found = mimeModes[spec.name]; if (typeof found == "string") { found = {name: found}; } spec = createObj(found, spec); spec.name = found.name; } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) { return resolveMode("application/xml") } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) { return resolveMode("application/json") } if (typeof spec == "string") { return {name: spec} } else { return spec || {name: "null"} } } // Given a mode spec (anything that resolveMode accepts), find and // initialize an actual mode object. function getMode(options, spec) { spec = resolveMode(spec); var mfactory = modes[spec.name]; if (!mfactory) { return getMode(options, "text/plain") } var modeObj = mfactory(options, spec); if (modeExtensions.hasOwnProperty(spec.name)) { var exts = modeExtensions[spec.name]; for (var prop in exts) { if (!exts.hasOwnProperty(prop)) { continue } if (modeObj.hasOwnProperty(prop)) { modeObj["_" + prop] = modeObj[prop]; } modeObj[prop] = exts[prop]; } } modeObj.name = spec.name; if (spec.helperType) { modeObj.helperType = spec.helperType; } if (spec.modeProps) { for (var prop$1 in spec.modeProps) { modeObj[prop$1] = spec.modeProps[prop$1]; } } return modeObj } // This can be used to attach properties to mode objects from // outside the actual mode definition. var modeExtensions = {}; function extendMode(mode, properties) { var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {}); copyObj(properties, exts); } function copyState(mode, state) { if (state === true) { return state } if (mode.copyState) { return mode.copyState(state) } var nstate = {}; for (var n in state) { var val = state[n]; if (val instanceof Array) { val = val.concat([]); } nstate[n] = val; } return nstate } // Given a mode and a state (for that mode), find the inner mode and // state at the position that the state refers to. function innerMode(mode, state) { var info; while (mode.innerMode) { info = mode.innerMode(state); if (!info || info.mode == mode) { break } state = info.state; mode = info.mode; } return info || {mode: mode, state: state} } function startState(mode, a1, a2) { return mode.startState ? mode.startState(a1, a2) : true } // STRING STREAM // Fed to the mode parsers, provides helper functions to make // parsers more succinct. var StringStream = function(string, tabSize, lineOracle) { this.pos = this.start = 0; this.string = string; this.tabSize = tabSize || 8; this.lastColumnPos = this.lastColumnValue = 0; this.lineStart = 0; this.lineOracle = lineOracle; }; StringStream.prototype.eol = function () {return this.pos >= this.string.length}; StringStream.prototype.sol = function () {return this.pos == this.lineStart}; StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined}; StringStream.prototype.next = function () { if (this.pos < this.string.length) { return this.string.charAt(this.pos++) } }; StringStream.prototype.eat = function (match) { var ch = this.string.charAt(this.pos); var ok; if (typeof match == "string") { ok = ch == match; } else { ok = ch && (match.test ? match.test(ch) : match(ch)); } if (ok) {++this.pos; return ch} }; StringStream.prototype.eatWhile = function (match) { var start = this.pos; while (this.eat(match)){} return this.pos > start }; StringStream.prototype.eatSpace = function () { var start = this.pos; while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this.pos; } return this.pos > start }; StringStream.prototype.skipToEnd = function () {this.pos = this.string.length;}; StringStream.prototype.skipTo = function (ch) { var found = this.string.indexOf(ch, this.pos); if (found > -1) {this.pos = found; return true} }; StringStream.prototype.backUp = function (n) {this.pos -= n;}; StringStream.prototype.column = function () { if (this.lastColumnPos < this.start) { this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue); this.lastColumnPos = this.start; } return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0) }; StringStream.prototype.indentation = function () { return countColumn(this.string, null, this.tabSize) - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0) }; StringStream.prototype.match = function (pattern, consume, caseInsensitive) { if (typeof pattern == "string") { var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; }; var substr = this.string.substr(this.pos, pattern.length); if (cased(substr) == cased(pattern)) { if (consume !== false) { this.pos += pattern.length; } return true } } else { var match = this.string.slice(this.pos).match(pattern); if (match && match.index > 0) { return null } if (match && consume !== false) { this.pos += match[0].length; } return match } }; StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)}; StringStream.prototype.hideFirstChars = function (n, inner) { this.lineStart += n; try { return inner() } finally { this.lineStart -= n; } }; StringStream.prototype.lookAhead = function (n) { var oracle = this.lineOracle; return oracle && oracle.lookAhead(n) }; StringStream.prototype.baseToken = function () { var oracle = this.lineOracle; return oracle && oracle.baseToken(this.pos) }; // Find the line object corresponding to the given line number. function getLine(doc, n) { n -= doc.first; if (n < 0 || n >= doc.size) { throw new Error("There is no line " + (n + doc.first) + " in the document.") } var chunk = doc; while (!chunk.lines) { for (var i = 0;; ++i) { var child = chunk.children[i], sz = child.chunkSize(); if (n < sz) { chunk = child; break } n -= sz; } } return chunk.lines[n] } // Get the part of a document between two positions, as an array of // strings. function getBetween(doc, start, end) { var out = [], n = start.line; doc.iter(start.line, end.line + 1, function (line) { var text = line.text; if (n == end.line) { text = text.slice(0, end.ch); } if (n == start.line) { text = text.slice(start.ch); } out.push(text); ++n; }); return out } // Get the lines between from and to, as array of strings. function getLines(doc, from, to) { var out = []; doc.iter(from, to, function (line) { out.push(line.text); }); // iter aborts when callback returns truthy value return out } // Update the height of a line, propagating the height change // upwards to parent nodes. function updateLineHeight(line, height) { var diff = height - line.height; if (diff) { for (var n = line; n; n = n.parent) { n.height += diff; } } } // Given a line object, find its line number by walking up through // its parent links. function lineNo(line) { if (line.parent == null) { return null } var cur = line.parent, no = indexOf(cur.lines, line); for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) { for (var i = 0;; ++i) { if (chunk.children[i] == cur) { break } no += chunk.children[i].chunkSize(); } } return no + cur.first } // Find the line at the given vertical position, using the height // information in the document tree. function lineAtHeight(chunk, h) { var n = chunk.first; outer: do { for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) { var child = chunk.children[i$1], ch = child.height; if (h < ch) { chunk = child; continue outer } h -= ch; n += child.chunkSize(); } return n } while (!chunk.lines) var i = 0; for (; i < chunk.lines.length; ++i) { var line = chunk.lines[i], lh = line.height; if (h < lh) { break } h -= lh; } return n + i } function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size} function lineNumberFor(options, i) { return String(options.lineNumberFormatter(i + options.firstLineNumber)) } // A Pos instance represents a position within the text. function Pos(line, ch, sticky) { if ( sticky === void 0 ) sticky = null; if (!(this instanceof Pos)) { return new Pos(line, ch, sticky) } this.line = line; this.ch = ch; this.sticky = sticky; } // Compare two positions, return 0 if they are the same, a negative // number when a is less, and a positive number otherwise. function cmp(a, b) { return a.line - b.line || a.ch - b.ch } function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0 } function copyPos(x) {return Pos(x.line, x.ch)} function maxPos(a, b) { return cmp(a, b) < 0 ? b : a } function minPos(a, b) { return cmp(a, b) < 0 ? a : b } // Most of the external API clips given positions to make sure they // actually exist within the document. function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))} function clipPos(doc, pos) { if (pos.line < doc.first) { return Pos(doc.first, 0) } var last = doc.first + doc.size - 1; if (pos.line > last) { return Pos(last, getLine(doc, last).text.length) } return clipToLen(pos, getLine(doc, pos.line).text.length) } function clipToLen(pos, linelen) { var ch = pos.ch; if (ch == null || ch > linelen) { return Pos(pos.line, linelen) } else if (ch < 0) { return Pos(pos.line, 0) } else { return pos } } function clipPosArray(doc, array) { var out = []; for (var i = 0; i < array.length; i++) { out[i] = clipPos(doc, array[i]); } return out } var SavedContext = function(state, lookAhead) { this.state = state; this.lookAhead = lookAhead; }; var Context = function(doc, state, line, lookAhead) { this.state = state; this.doc = doc; this.line = line; this.maxLookAhead = lookAhead || 0; this.baseTokens = null; this.baseTokenPos = 1; }; Context.prototype.lookAhead = function (n) { var line = this.doc.getLine(this.line + n); if (line != null && n > this.maxLookAhead) { this.maxLookAhead = n; } return line }; Context.prototype.baseToken = function (n) { if (!this.baseTokens) { return null } while (this.baseTokens[this.baseTokenPos] <= n) { this.baseTokenPos += 2; } var type = this.baseTokens[this.baseTokenPos + 1]; return {type: type && type.replace(/( |^)overlay .*/, ""), size: this.baseTokens[this.baseTokenPos] - n} }; Context.prototype.nextLine = function () { this.line++; if (this.maxLookAhead > 0) { this.maxLookAhead--; } }; Context.fromSaved = function (doc, saved, line) { if (saved instanceof SavedContext) { return new Context(doc, copyState(doc.mode, saved.state), line, saved.lookAhead) } else { return new Context(doc, copyState(doc.mode, saved), line) } }; Context.prototype.save = function (copy) { var state = copy !== false ? copyState(this.doc.mode, this.state) : this.state; return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state }; // Compute a style array (an array starting with a mode generation // -- for invalidation -- followed by pairs of end positions and // style strings), which is used to highlight the tokens on the // line. function highlightLine(cm, line, context, forceToEnd) { // A styles array always starts with a number identifying the // mode/overlays that it is based on (for easy invalidation). var st = [cm.state.modeGen], lineClasses = {}; // Compute the base array of styles runMode(cm, line.text, cm.doc.mode, context, function (end, style) { return st.push(end, style); }, lineClasses, forceToEnd); var state = context.state; // Run overlays, adjust style array. var loop = function ( o ) { context.baseTokens = st; var overlay = cm.state.overlays[o], i = 1, at = 0; context.state = true; runMode(cm, line.text, overlay.mode, context, function (end, style) { var start = i; // Ensure there's a token end at the current position, and that i points at it while (at < end) { var i_end = st[i]; if (i_end > end) { st.splice(i, 1, end, st[i+1], i_end); } i += 2; at = Math.min(end, i_end); } if (!style) { return } if (overlay.opaque) { st.splice(start, i - start, end, "overlay " + style); i = start + 2; } else { for (; start < i; start += 2) { var cur = st[start+1]; st[start+1] = (cur ? cur + " " : "") + "overlay " + style; } } }, lineClasses); context.state = state; context.baseTokens = null; context.baseTokenPos = 1; }; for (var o = 0; o < cm.state.overlays.length; ++o) loop( o ); return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null} } function getLineStyles(cm, line, updateFrontier) { if (!line.styles || line.styles[0] != cm.state.modeGen) { var context = getContextBefore(cm, lineNo(line)); var resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state); var result = highlightLine(cm, line, context); if (resetState) { context.state = resetState; } line.stateAfter = context.save(!resetState); line.styles = result.styles; if (result.classes) { line.styleClasses = result.classes; } else if (line.styleClasses) { line.styleClasses = null; } if (updateFrontier === cm.doc.highlightFrontier) { cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier); } } return line.styles } function getContextBefore(cm, n, precise) { var doc = cm.doc, display = cm.display; if (!doc.mode.startState) { return new Context(doc, true, n) } var start = findStartLine(cm, n, precise); var saved = start > doc.first && getLine(doc, start - 1).stateAfter; var context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start); doc.iter(start, n, function (line) { processLine(cm, line.text, context); var pos = context.line; line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null; context.nextLine(); }); if (precise) { doc.modeFrontier = context.line; } return context } // Lightweight form of highlight -- proceed over this line and // update state, but don't save a style array. Used for lines that // aren't currently visible. function processLine(cm, text, context, startAt) { var mode = cm.doc.mode; var stream = new StringStream(text, cm.options.tabSize, context); stream.start = stream.pos = startAt || 0; if (text == "") { callBlankLine(mode, context.state); } while (!stream.eol()) { readToken(mode, stream, context.state); stream.start = stream.pos; } } function callBlankLine(mode, state) { if (mode.blankLine) { return mode.blankLine(state) } if (!mode.innerMode) { return } var inner = innerMode(mode, state); if (inner.mode.blankLine) { return inner.mode.blankLine(inner.state) } } function readToken(mode, stream, state, inner) { for (var i = 0; i < 10; i++) { if (inner) { inner[0] = innerMode(mode, state).mode; } var style = mode.token(stream, state); if (stream.pos > stream.start) { return style } } throw new Error("Mode " + mode.name + " failed to advance stream.") } var Token = function(stream, type, state) { this.start = stream.start; this.end = stream.pos; this.string = stream.current(); this.type = type || null; this.state = state; }; // Utility for getTokenAt and getLineTokens function takeToken(cm, pos, precise, asArray) { var doc = cm.doc, mode = doc.mode, style; pos = clipPos(doc, pos); var line = getLine(doc, pos.line), context = getContextBefore(cm, pos.line, precise); var stream = new StringStream(line.text, cm.options.tabSize, context), tokens; if (asArray) { tokens = []; } while ((asArray || stream.pos < pos.ch) && !stream.eol()) { stream.start = stream.pos; style = readToken(mode, stream, context.state); if (asArray) { tokens.push(new Token(stream, style, copyState(doc.mode, context.state))); } } return asArray ? tokens : new Token(stream, style, context.state) } function extractLineClasses(type, output) { if (type) { for (;;) { var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/); if (!lineClass) { break } type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length); var prop = lineClass[1] ? "bgClass" : "textClass"; if (output[prop] == null) { output[prop] = lineClass[2]; } else if (!(new RegExp("(?:^|\\s)" + lineClass[2] + "(?:$|\\s)")).test(output[prop])) { output[prop] += " " + lineClass[2]; } } } return type } // Run the given mode's parser over a line, calling f for each token. function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) { var flattenSpans = mode.flattenSpans; if (flattenSpans == null) { flattenSpans = cm.options.flattenSpans; } var curStart = 0, curStyle = null; var stream = new StringStream(text, cm.options.tabSize, context), style; var inner = cm.options.addModeClass && [null]; if (text == "") { extractLineClasses(callBlankLine(mode, context.state), lineClasses); } while (!stream.eol()) { if (stream.pos > cm.options.maxHighlightLength) { flattenSpans = false; if (forceToEnd) { processLine(cm, text, context, stream.pos); } stream.pos = text.length; style = null; } else { style = extractLineClasses(readToken(mode, stream, context.state, inner), lineClasses); } if (inner) { var mName = inner[0].name; if (mName) { style = "m-" + (style ? mName + " " + style : mName); } } if (!flattenSpans || curStyle != style) { while (curStart < stream.start) { curStart = Math.min(stream.start, curStart + 5000); f(curStart, curStyle); } curStyle = style; } stream.start = stream.pos; } while (curStart < stream.pos) { // Webkit seems to refuse to render text nodes longer than 57444 // characters, and returns inaccurate measurements in nodes // starting around 5000 chars. var pos = Math.min(stream.pos, curStart + 5000); f(pos, curStyle); curStart = pos; } } // Finds the line to start with when starting a parse. Tries to // find a line with a stateAfter, so that it can start with a // valid state. If that fails, it returns the line with the // smallest indentation, which tends to need the least context to // parse correctly. function findStartLine(cm, n, precise) { var minindent, minline, doc = cm.doc; var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100); for (var search = n; search > lim; --search) { if (search <= doc.first) { return doc.first } var line = getLine(doc, search - 1), after = line.stateAfter; if (after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc.modeFrontier)) { return search } var indented = countColumn(line.text, null, cm.options.tabSize); if (minline == null || minindent > indented) { minline = search - 1; minindent = indented; } } return minline } function retreatFrontier(doc, n) { doc.modeFrontier = Math.min(doc.modeFrontier, n); if (doc.highlightFrontier < n - 10) { return } var start = doc.first; for (var line = n - 1; line > start; line--) { var saved = getLine(doc, line).stateAfter; // change is on 3 // state on line 1 looked ahead 2 -- so saw 3 // test 1 + 2 < 3 should cover this if (saved && (!(saved instanceof SavedContext) || line + saved.lookAhead < n)) { start = line + 1; break } } doc.highlightFrontier = Math.min(doc.highlightFrontier, start); } // Optimize some code when these features are not used. var sawReadOnlySpans = false, sawCollapsedSpans = false; function seeReadOnlySpans() { sawReadOnlySpans = true; } function seeCollapsedSpans() { sawCollapsedSpans = true; } // TEXTMARKER SPANS function MarkedSpan(marker, from, to) { this.marker = marker; this.from = from; this.to = to; } // Search an array of spans for a span matching the given marker. function getMarkedSpanFor(spans, marker) { if (spans) { for (var i = 0; i < spans.length; ++i) { var span = spans[i]; if (span.marker == marker) { return span } } } } // Remove a span from an array, returning undefined if no spans are // left (we don't store arrays for lines without spans). function removeMarkedSpan(spans, span) { var r; for (var i = 0; i < spans.length; ++i) { if (spans[i] != span) { (r || (r = [])).push(spans[i]); } } return r } // Add a span to a line. function addMarkedSpan(line, span) { line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]; span.marker.attachLine(line); } // Used for the algorithm that adjusts markers for a change in the // document. These functions cut an array of spans at a given // character position, returning an array of remaining chunks (or // undefined if nothing remains). function markedSpansBefore(old, startCh, isInsert) { var nw; if (old) { for (var i = 0; i < old.length; ++i) { var span = old[i], marker = span.marker; var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh); if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) { var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh) ;(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to)); } } } return nw } function markedSpansAfter(old, endCh, isInsert) { var nw; if (old) { for (var i = 0; i < old.length; ++i) { var span = old[i], marker = span.marker; var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh); if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) { var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh) ;(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh, span.to == null ? null : span.to - endCh)); } } } return nw } // Given a change object, compute the new set of marker spans that // cover the line in which the change took place. Removes spans // entirely within the change, reconnects spans belonging to the // same marker that appear on both sides of the change, and cuts off // spans partially within the change. Returns an array of span // arrays with one element for each line in (after) the change. function stretchSpansOverChange(doc, change) { if (change.full) { return null } var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans; var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans; if (!oldFirst && !oldLast) { return null } var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0; // Get the spans that 'stick out' on both sides var first = markedSpansBefore(oldFirst, startCh, isInsert); var last = markedSpansAfter(oldLast, endCh, isInsert); // Next, merge those two ends var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0); if (first) { // Fix up .to properties of first for (var i = 0; i < first.length; ++i) { var span = first[i]; if (span.to == null) { var found = getMarkedSpanFor(last, span.marker); if (!found) { span.to = startCh; } else if (sameLine) { span.to = found.to == null ? null : found.to + offset; } } } } if (last) { // Fix up .from in last (or move them into first in case of sameLine) for (var i$1 = 0; i$1 < last.length; ++i$1) { var span$1 = last[i$1]; if (span$1.to != null) { span$1.to += offset; } if (span$1.from == null) { var found$1 = getMarkedSpanFor(first, span$1.marker); if (!found$1) { span$1.from = offset; if (sameLine) { (first || (first = [])).push(span$1); } } } else { span$1.from += offset; if (sameLine) { (first || (first = [])).push(span$1); } } } } // Make sure we didn't create any zero-length spans if (first) { first = clearEmptySpans(first); } if (last && last != first) { last = clearEmptySpans(last); } var newMarkers = [first]; if (!sameLine) { // Fill gap with whole-line-spans var gap = change.text.length - 2, gapMarkers; if (gap > 0 && first) { for (var i$2 = 0; i$2 < first.length; ++i$2) { if (first[i$2].to == null) { (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null)); } } } for (var i$3 = 0; i$3 < gap; ++i$3) { newMarkers.push(gapMarkers); } newMarkers.push(last); } return newMarkers } // Remove spans that are empty and don't have a clearWhenEmpty // option of false. function clearEmptySpans(spans) { for (var i = 0; i < spans.length; ++i) { var span = spans[i]; if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false) { spans.splice(i--, 1); } } if (!spans.length) { return null } return spans } // Used to 'clip' out readOnly ranges when making a change. function removeReadOnlyRanges(doc, from, to) { var markers = null; doc.iter(from.line, to.line + 1, function (line) { if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) { var mark = line.markedSpans[i].marker; if (mark.readOnly && (!markers || indexOf(markers, mark) == -1)) { (markers || (markers = [])).push(mark); } } } }); if (!markers) { return null } var parts = [{from: from, to: to}]; for (var i = 0; i < markers.length; ++i) { var mk = markers[i], m = mk.find(0); for (var j = 0; j < parts.length; ++j) { var p = parts[j]; if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) { continue } var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to); if (dfrom < 0 || !mk.inclusiveLeft && !dfrom) { newParts.push({from: p.from, to: m.from}); } if (dto > 0 || !mk.inclusiveRight && !dto) { newParts.push({from: m.to, to: p.to}); } parts.splice.apply(parts, newParts); j += newParts.length - 3; } } return parts } // Connect or disconnect spans from a line. function detachMarkedSpans(line) { var spans = line.markedSpans; if (!spans) { return } for (var i = 0; i < spans.length; ++i) { spans[i].marker.detachLine(line); } line.markedSpans = null; } function attachMarkedSpans(line, spans) { if (!spans) { return } for (var i = 0; i < spans.length; ++i) { spans[i].marker.attachLine(line); } line.markedSpans = spans; } // Helpers used when computing which overlapping collapsed span // counts as the larger one. function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0 } function extraRight(marker) { return marker.inclusiveRight ? 1 : 0 } // Returns a number indicating which of two overlapping collapsed // spans is larger (and thus includes the other). Falls back to // comparing ids when the spans cover exactly the same range. function compareCollapsedMarkers(a, b) { var lenDiff = a.lines.length - b.lines.length; if (lenDiff != 0) { return lenDiff } var aPos = a.find(), bPos = b.find(); var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b); if (fromCmp) { return -fromCmp } var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b); if (toCmp) { return toCmp } return b.id - a.id } // Find out whether a line ends or starts in a collapsed span. If // so, return the marker for that span. function collapsedSpanAtSide(line, start) { var sps = sawCollapsedSpans && line.markedSpans, found; if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) { sp = sps[i]; if (sp.marker.collapsed && (start ? sp.from : sp.to) == null && (!found || compareCollapsedMarkers(found, sp.marker) < 0)) { found = sp.marker; } } } return found } function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) } function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) } function collapsedSpanAround(line, ch) { var sps = sawCollapsedSpans && line.markedSpans, found; if (sps) { for (var i = 0; i < sps.length; ++i) { var sp = sps[i]; if (sp.marker.collapsed && (sp.from == null || sp.from < ch) && (sp.to == null || sp.to > ch) && (!found || compareCollapsedMarkers(found, sp.marker) < 0)) { found = sp.marker; } } } return found } // Test whether there exists a collapsed span that partially // overlaps (covers the start or end, but not both) of a new span. // Such overlap is not allowed. function conflictingCollapsedRange(doc, lineNo, from, to, marker) { var line = getLine(doc, lineNo); var sps = sawCollapsedSpans && line.markedSpans; if (sps) { for (var i = 0; i < sps.length; ++i) { var sp = sps[i]; if (!sp.marker.collapsed) { continue } var found = sp.marker.find(0); var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker); var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker); if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) { continue } if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) || fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0)) { return true } } } } // A visual line is a line as drawn on the screen. Folding, for // example, can cause multiple logical lines to appear on the same // visual line. This finds the start of the visual line that the // given line is part of (usually that is the line itself). function visualLine(line) { var merged; while (merged = collapsedSpanAtStart(line)) { line = merged.find(-1, true).line; } return line } function visualLineEnd(line) { var merged; while (merged = collapsedSpanAtEnd(line)) { line = merged.find(1, true).line; } return line } // Returns an array of logical lines that continue the visual line // started by the argument, or undefined if there are no such lines. function visualLineContinued(line) { var merged, lines; while (merged = collapsedSpanAtEnd(line)) { line = merged.find(1, true).line ;(lines || (lines = [])).push(line); } return lines } // Get the line number of the start of the visual line that the // given line number is part of. function visualLineNo(doc, lineN) { var line = getLine(doc, lineN), vis = visualLine(line); if (line == vis) { return lineN } return lineNo(vis) } // Get the line number of the start of the next visual line after // the given line. function visualLineEndNo(doc, lineN) { if (lineN > doc.lastLine()) { return lineN } var line = getLine(doc, lineN), merged; if (!lineIsHidden(doc, line)) { return lineN } while (merged = collapsedSpanAtEnd(line)) { line = merged.find(1, true).line; } return lineNo(line) + 1 } // Compute whether a line is hidden. Lines count as hidden when they // are part of a visual line that starts with another line, or when // they are entirely covered by collapsed, non-widget span. function lineIsHidden(doc, line) { var sps = sawCollapsedSpans && line.markedSpans; if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) { sp = sps[i]; if (!sp.marker.collapsed) { continue } if (sp.from == null) { return true } if (sp.marker.widgetNode) { continue } if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp)) { return true } } } } function lineIsHiddenInner(doc, line, span) { if (span.to == null) { var end = span.marker.find(1, true); return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker)) } if (span.marker.inclusiveRight && span.to == line.text.length) { return true } for (var sp = (void 0), i = 0; i < line.markedSpans.length; ++i) { sp = line.markedSpans[i]; if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to && (sp.to == null || sp.to != span.from) && (sp.marker.inclusiveLeft || span.marker.inclusiveRight) && lineIsHiddenInner(doc, line, sp)) { return true } } } // Find the height above the given line. function heightAtLine(lineObj) { lineObj = visualLine(lineObj); var h = 0, chunk = lineObj.parent; for (var i = 0; i < chunk.lines.length; ++i) { var line = chunk.lines[i]; if (line == lineObj) { break } else { h += line.height; } } for (var p = chunk.parent; p; chunk = p, p = chunk.parent) { for (var i$1 = 0; i$1 < p.children.length; ++i$1) { var cur = p.children[i$1]; if (cur == chunk) { break } else { h += cur.height; } } } return h } // Compute the character length of a line, taking into account // collapsed ranges (see markText) that might hide parts, and join // other lines onto it. function lineLength(line) { if (line.height == 0) { return 0 } var len = line.text.length, merged, cur = line; while (merged = collapsedSpanAtStart(cur)) { var found = merged.find(0, true); cur = found.from.line; len += found.from.ch - found.to.ch; } cur = line; while (merged = collapsedSpanAtEnd(cur)) { var found$1 = merged.find(0, true); len -= cur.text.length - found$1.from.ch; cur = found$1.to.line; len += cur.text.length - found$1.to.ch; } return len } // Find the longest line in the document. function findMaxLine(cm) { var d = cm.display, doc = cm.doc; d.maxLine = getLine(doc, doc.first); d.maxLineLength = lineLength(d.maxLine); d.maxLineChanged = true; doc.iter(function (line) { var len = lineLength(line); if (len > d.maxLineLength) { d.maxLineLength = len; d.maxLine = line; } }); } // LINE DATA STRUCTURE // Line objects. These hold state related to a line, including // highlighting info (the styles array). var Line = function(text, markedSpans, estimateHeight) { this.text = text; attachMarkedSpans(this, markedSpans); this.height = estimateHeight ? estimateHeight(this) : 1; }; Line.prototype.lineNo = function () { return lineNo(this) }; eventMixin(Line); // Change the content (text, markers) of a line. Automatically // invalidates cached information and tries to re-estimate the // line's height. function updateLine(line, text, markedSpans, estimateHeight) { line.text = text; if (line.stateAfter) { line.stateAfter = null; } if (line.styles) { line.styles = null; } if (line.order != null) { line.order = null; } detachMarkedSpans(line); attachMarkedSpans(line, markedSpans); var estHeight = estimateHeight ? estimateHeight(line) : 1; if (estHeight != line.height) { updateLineHeight(line, estHeight); } } // Detach a line from the document tree and its markers. function cleanUpLine(line) { line.parent = null; detachMarkedSpans(line); } // Convert a style as returned by a mode (either null, or a string // containing one or more styles) to a CSS style. This is cached, // and also looks for line-wide styles. var styleToClassCache = {}, styleToClassCacheWithMode = {}; function interpretTokenStyle(style, options) { if (!style || /^\s*$/.test(style)) { return null } var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache; return cache[style] || (cache[style] = style.replace(/\S+/g, "cm-$&")) } // Render the DOM representation of the text of a line. Also builds // up a 'line map', which points at the DOM nodes that represent // specific stretches of text, and is used by the measuring code. // The returned object contains the DOM node, this map, and // information about line-wide styles that were set by the mode. function buildLineContent(cm, lineView) { // The padding-right forces the element to have a 'border', which // is needed on Webkit to be able to get line-level bounding // rectangles for it (in measureChar). var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null); var builder = {pre: eltP("pre", [content], "CodeMirror-line"), content: content, col: 0, pos: 0, cm: cm, trailingSpace: false, splitSpaces: cm.getOption("lineWrapping")}; lineView.measure = {}; // Iterate over the logical lines that make up this visual line. for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) { var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0); builder.pos = 0; builder.addToken = buildToken; // Optionally wire in some hacks into the token-rendering // algorithm, to deal with browser quirks. if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction))) { builder.addToken = buildTokenBadBidi(builder.addToken, order); } builder.map = []; var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line); insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate)); if (line.styleClasses) { if (line.styleClasses.bgClass) { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); } if (line.styleClasses.textClass) { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); } } // Ensure at least a single node is present, for measuring. if (builder.map.length == 0) { builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); } // Store the map and a cache object for the current logical line if (i == 0) { lineView.measure.map = builder.map; lineView.measure.cache = {}; } else { (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map) ;(lineView.measure.caches || (lineView.measure.caches = [])).push({}); } } // See issue #2901 if (webkit) { var last = builder.content.lastChild; if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab"))) { builder.content.className = "cm-tab-wrap-hack"; } } signal(cm, "renderLine", cm, lineView.line, builder.pre); if (builder.pre.className) { builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); } return builder } function defaultSpecialCharPlaceholder(ch) { var token = elt("span", "\u2022", "cm-invalidchar"); token.title = "\\u" + ch.charCodeAt(0).toString(16); token.setAttribute("aria-label", token.title); return token } // Build up the DOM representation for a single token, and add it to // the line map. Takes care to render special characters separately. function buildToken(builder, text, style, startStyle, endStyle, css, attributes) { if (!text) { return } var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text; var special = builder.cm.state.specialChars, mustWrap = false; var content; if (!special.test(text)) { builder.col += text.length; content = document.createTextNode(displayText); builder.map.push(builder.pos, builder.pos + text.length, content); if (ie && ie_version < 9) { mustWrap = true; } builder.pos += text.length; } else { content = document.createDocumentFragment(); var pos = 0; while (true) { special.lastIndex = pos; var m = special.exec(text); var skipped = m ? m.index - pos : text.length - pos; if (skipped) { var txt = document.createTextNode(displayText.slice(pos, pos + skipped)); if (ie && ie_version < 9) { content.appendChild(elt("span", [txt])); } else { content.appendChild(txt); } builder.map.push(builder.pos, builder.pos + skipped, txt); builder.col += skipped; builder.pos += skipped; } if (!m) { break } pos += skipped + 1; var txt$1 = (void 0); if (m[0] == "\t") { var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize; txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab")); txt$1.setAttribute("role", "presentation"); txt$1.setAttribute("cm-text", "\t"); builder.col += tabWidth; } else if (m[0] == "\r" || m[0] == "\n") { txt$1 = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar")); txt$1.setAttribute("cm-text", m[0]); builder.col += 1; } else { txt$1 = builder.cm.options.specialCharPlaceholder(m[0]); txt$1.setAttribute("cm-text", m[0]); if (ie && ie_version < 9) { content.appendChild(elt("span", [txt$1])); } else { content.appendChild(txt$1); } builder.col += 1; } builder.map.push(builder.pos, builder.pos + 1, txt$1); builder.pos++; } } builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32; if (style || startStyle || endStyle || mustWrap || css) { var fullStyle = style || ""; if (startStyle) { fullStyle += startStyle; } if (endStyle) { fullStyle += endStyle; } var token = elt("span", [content], fullStyle, css); if (attributes) { for (var attr in attributes) { if (attributes.hasOwnProperty(attr) && attr != "style" && attr != "class") { token.setAttribute(attr, attributes[attr]); } } } return builder.content.appendChild(token) } builder.content.appendChild(content); } // Change some spaces to NBSP to prevent the browser from collapsing // trailing spaces at the end of a line when rendering text (issue #1362). function splitSpaces(text, trailingBefore) { if (text.length > 1 && !/ /.test(text)) { return text } var spaceBefore = trailingBefore, result = ""; for (var i = 0; i < text.length; i++) { var ch = text.charAt(i); if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32)) { ch = "\u00a0"; } result += ch; spaceBefore = ch == " "; } return result } // Work around nonsense dimensions being reported for stretches of // right-to-left text. function buildTokenBadBidi(inner, order) { return function (builder, text, style, startStyle, endStyle, css, attributes) { style = style ? style + " cm-force-border" : "cm-force-border"; var start = builder.pos, end = start + text.length; for (;;) { // Find the part that overlaps with the start of this text var part = (void 0); for (var i = 0; i < order.length; i++) { part = order[i]; if (part.to > start && part.from <= start) { break } } if (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, css, attributes) } inner(builder, text.slice(0, part.to - start), style, startStyle, null, css, attributes); startStyle = null; text = text.slice(part.to - start); start = part.to; } } } function buildCollapsedSpan(builder, size, marker, ignoreWidget) { var widget = !ignoreWidget && marker.widgetNode; if (widget) { builder.map.push(builder.pos, builder.pos + size, widget); } if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) { if (!widget) { widget = builder.content.appendChild(document.createElement("span")); } widget.setAttribute("cm-marker", marker.id); } if (widget) { builder.cm.display.input.setUneditable(widget); builder.content.appendChild(widget); } builder.pos += size; builder.trailingSpace = false; } // Outputs a number of spans to make up a line, taking highlighting // and marked text into account. function insertLineContent(line, builder, styles) { var spans = line.markedSpans, allText = line.text, at = 0; if (!spans) { for (var i$1 = 1; i$1 < styles.length; i$1+=2) { builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)); } return } var len = allText.length, pos = 0, i = 1, text = "", style, css; var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, collapsed, attributes; for (;;) { if (nextChange == pos) { // Update current marker set spanStyle = spanEndStyle = spanStartStyle = css = ""; attributes = null; collapsed = null; nextChange = Infinity; var foundBookmarks = [], endStyles = (void 0); for (var j = 0; j < spans.length; ++j) { var sp = spans[j], m = sp.marker; if (m.type == "bookmark" && sp.from == pos && m.widgetNode) { foundBookmarks.push(m); } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) { if (sp.to != null && sp.to != pos && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; } if (m.className) { spanStyle += " " + m.className; } if (m.css) { css = (css ? css + ";" : "") + m.css; } if (m.startStyle && sp.from == pos) { spanStartStyle += " " + m.startStyle; } if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to); } // support for the old title property // https://github.com/codemirror/CodeMirror/pull/5673 if (m.title) { (attributes || (attributes = {})).title = m.title; } if (m.attributes) { for (var attr in m.attributes) { (attributes || (attributes = {}))[attr] = m.attributes[attr]; } } if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0)) { collapsed = sp; } } else if (sp.from > pos && nextChange > sp.from) { nextChange = sp.from; } } if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2) { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += " " + endStyles[j$1]; } } } if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2) { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]); } } if (collapsed && (collapsed.from || 0) == pos) { buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, collapsed.marker, collapsed.from == null); if (collapsed.to == null) { return } if (collapsed.to == pos) { collapsed = false; } } } if (pos >= len) { break } var upto = Math.min(len, nextChange); while (true) { if (text) { var end = pos + text.length; if (!collapsed) { var tokenText = end > upto ? text.slice(0, upto - pos) : text; builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle, spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", css, attributes); } if (end >= upto) {text = text.slice(upto - pos); pos = upto; break} pos = end; spanStartStyle = ""; } text = allText.slice(at, at = styles[i++]); style = interpretTokenStyle(styles[i++], builder.cm.options); } } } // These objects are used to represent the visible (currently drawn) // part of the document. A LineView may correspond to multiple // logical lines, if those are connected by collapsed ranges. function LineView(doc, line, lineN) { // The starting line this.line = line; // Continuing lines, if any this.rest = visualLineContinued(line); // Number of logical lines in this visual line this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1; this.node = this.text = null; this.hidden = lineIsHidden(doc, line); } // Create a range of LineView objects for the given lines. function buildViewArray(cm, from, to) { var array = [], nextPos; for (var pos = from; pos < to; pos = nextPos) { var view = new LineView(cm.doc, getLine(cm.doc, pos), pos); nextPos = pos + view.size; array.push(view); } return array } var operationGroup = null; function pushOperation(op) { if (operationGroup) { operationGroup.ops.push(op); } else { op.ownsGroup = operationGroup = { ops: [op], delayedCallbacks: [] }; } } function fireCallbacksForOps(group) { // Calls delayed callbacks and cursorActivity handlers until no // new ones appear var callbacks = group.delayedCallbacks, i = 0; do { for (; i < callbacks.length; i++) { callbacks[i].call(null); } for (var j = 0; j < group.ops.length; j++) { var op = group.ops[j]; if (op.cursorActivityHandlers) { while (op.cursorActivityCalled < op.cursorActivityHandlers.length) { op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm); } } } } while (i < callbacks.length) } function finishOperation(op, endCb) { var group = op.ownsGroup; if (!group) { return } try { fireCallbacksForOps(group); } finally { operationGroup = null; endCb(group); } } var orphanDelayedCallbacks = null; // Often, we want to signal events at a point where we are in the // middle of some work, but don't want the handler to start calling // other methods on the editor, which might be in an inconsistent // state or simply not expect any other events to happen. // signalLater looks whether there are any handlers, and schedules // them to be executed when the last operation ends, or, if no // operation is active, when a timeout fires. function signalLater(emitter, type /*, values...*/) { var arr = getHandlers(emitter, type); if (!arr.length) { return } var args = Array.prototype.slice.call(arguments, 2), list; if (operationGroup) { list = operationGroup.delayedCallbacks; } else if (orphanDelayedCallbacks) { list = orphanDelayedCallbacks; } else { list = orphanDelayedCallbacks = []; setTimeout(fireOrphanDelayed, 0); } var loop = function ( i ) { list.push(function () { return arr[i].apply(null, args); }); }; for (var i = 0; i < arr.length; ++i) loop( i ); } function fireOrphanDelayed() { var delayed = orphanDelayedCallbacks; orphanDelayedCallbacks = null; for (var i = 0; i < delayed.length; ++i) { delayed[i](); } } // When an aspect of a line changes, a string is added to // lineView.changes. This updates the relevant part of the line's // DOM structure. function updateLineForChanges(cm, lineView, lineN, dims) { for (var j = 0; j < lineView.changes.length; j++) { var type = lineView.changes[j]; if (type == "text") { updateLineText(cm, lineView); } else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims); } else if (type == "class") { updateLineClasses(cm, lineView); } else if (type == "widget") { updateLineWidgets(cm, lineView, dims); } } lineView.changes = null; } // Lines with gutter elements, widgets or a background class need to // be wrapped, and have the extra elements added to the wrapper div function ensureLineWrapped(lineView) { if (lineView.node == lineView.text) { lineView.node = elt("div", null, null, "position: relative"); if (lineView.text.parentNode) { lineView.text.parentNode.replaceChild(lineView.node, lineView.text); } lineView.node.appendChild(lineView.text); if (ie && ie_version < 8) { lineView.node.style.zIndex = 2; } } return lineView.node } function updateLineBackground(cm, lineView) { var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass; if (cls) { cls += " CodeMirror-linebackground"; } if (lineView.background) { if (cls) { lineView.background.className = cls; } else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; } } else if (cls) { var wrap = ensureLineWrapped(lineView); lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild); cm.display.input.setUneditable(lineView.background); } } // Wrapper around buildLineContent which will reuse the structure // in display.externalMeasured when possible. function getLineContent(cm, lineView) { var ext = cm.display.externalMeasured; if (ext && ext.line == lineView.line) { cm.display.externalMeasured = null; lineView.measure = ext.measure; return ext.built } return buildLineContent(cm, lineView) } // Redraw the line's text. Interacts with the background and text // classes because the mode may output tokens that influence these // classes. function updateLineText(cm, lineView) { var cls = lineView.text.className; var built = getLineContent(cm, lineView); if (lineView.text == lineView.node) { lineView.node = built.pre; } lineView.text.parentNode.replaceChild(built.pre, lineView.text); lineView.text = built.pre; if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) { lineView.bgClass = built.bgClass; lineView.textClass = built.textClass; updateLineClasses(cm, lineView); } else if (cls) { lineView.text.className = cls; } } function updateLineClasses(cm, lineView) { updateLineBackground(cm, lineView); if (lineView.line.wrapClass) { ensureLineWrapped(lineView).className = lineView.line.wrapClass; } else if (lineView.node != lineView.text) { lineView.node.className = ""; } var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass; lineView.text.className = textClass || ""; } function updateLineGutter(cm, lineView, lineN, dims) { if (lineView.gutter) { lineView.node.removeChild(lineView.gutter); lineView.gutter = null; } if (lineView.gutterBackground) { lineView.node.removeChild(lineView.gutterBackground); lineView.gutterBackground = null; } if (lineView.line.gutterClass) { var wrap = ensureLineWrapped(lineView); lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass, ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + (dims.gutterTotalWidth) + "px")); cm.display.input.setUneditable(lineView.gutterBackground); wrap.insertBefore(lineView.gutterBackground, lineView.text); } var markers = lineView.line.gutterMarkers; if (cm.options.lineNumbers || markers) { var wrap$1 = ensureLineWrapped(lineView); var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px")); cm.display.input.setUneditable(gutterWrap); wrap$1.insertBefore(gutterWrap, lineView.text); if (lineView.line.gutterClass) { gutterWrap.className += " " + lineView.line.gutterClass; } if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"])) { lineView.lineNumber = gutterWrap.appendChild( elt("div", lineNumberFor(cm.options, lineN), "CodeMirror-linenumber CodeMirror-gutter-elt", ("left: " + (dims.gutterLeft["CodeMirror-linenumbers"]) + "px; width: " + (cm.display.lineNumInnerWidth) + "px"))); } if (markers) { for (var k = 0; k < cm.display.gutterSpecs.length; ++k) { var id = cm.display.gutterSpecs[k].className, found = markers.hasOwnProperty(id) && markers[id]; if (found) { gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", ("left: " + (dims.gutterLeft[id]) + "px; width: " + (dims.gutterWidth[id]) + "px"))); } } } } } function updateLineWidgets(cm, lineView, dims) { if (lineView.alignable) { lineView.alignable = null; } var isWidget = classTest("CodeMirror-linewidget"); for (var node = lineView.node.firstChild, next = (void 0); node; node = next) { next = node.nextSibling; if (isWidget.test(node.className)) { lineView.node.removeChild(node); } } insertLineWidgets(cm, lineView, dims); } // Build a line's DOM representation from scratch function buildLineElement(cm, lineView, lineN, dims) { var built = getLineContent(cm, lineView); lineView.text = lineView.node = built.pre; if (built.bgClass) { lineView.bgClass = built.bgClass; } if (built.textClass) { lineView.textClass = built.textClass; } updateLineClasses(cm, lineView); updateLineGutter(cm, lineView, lineN, dims); insertLineWidgets(cm, lineView, dims); return lineView.node } // A lineView may contain multiple logical lines (when merged by // collapsed spans). The widgets for all of them need to be drawn. function insertLineWidgets(cm, lineView, dims) { insertLineWidgetsFor(cm, lineView.line, lineView, dims, true); if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++) { insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false); } } } function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) { if (!line.widgets) { return } var wrap = ensureLineWrapped(lineView); for (var i = 0, ws = line.widgets; i < ws.length; ++i) { var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget" + (widget.className ? " " + widget.className : "")); if (!widget.handleMouseEvents) { node.setAttribute("cm-ignore-events", "true"); } positionLineWidget(widget, node, lineView, dims); cm.display.input.setUneditable(node); if (allowAbove && widget.above) { wrap.insertBefore(node, lineView.gutter || lineView.text); } else { wrap.appendChild(node); } signalLater(widget, "redraw"); } } function positionLineWidget(widget, node, lineView, dims) { if (widget.noHScroll) { (lineView.alignable || (lineView.alignable = [])).push(node); var width = dims.wrapperWidth; node.style.left = dims.fixedPos + "px"; if (!widget.coverGutter) { width -= dims.gutterTotalWidth; node.style.paddingLeft = dims.gutterTotalWidth + "px"; } node.style.width = width + "px"; } if (widget.coverGutter) { node.style.zIndex = 5; node.style.position = "relative"; if (!widget.noHScroll) { node.style.marginLeft = -dims.gutterTotalWidth + "px"; } } } function widgetHeight(widget) { if (widget.height != null) { return widget.height } var cm = widget.doc.cm; if (!cm) { return 0 } if (!contains(document.body, widget.node)) { var parentStyle = "position: relative;"; if (widget.coverGutter) { parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"; } if (widget.noHScroll) { parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"; } removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle)); } return widget.height = widget.node.parentNode.offsetHeight } // Return true when the given mouse event happened in a widget function eventInWidget(display, e) { for (var n = e_target(e); n != display.wrapper; n = n.parentNode) { if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") || (n.parentNode == display.sizer && n != display.mover)) { return true } } } // POSITION MEASUREMENT function paddingTop(display) {return display.lineSpace.offsetTop} function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight} function paddingH(display) { if (display.cachedPaddingH) { return display.cachedPaddingH } var e = removeChildrenAndAdd(display.measure, elt("pre", "x", "CodeMirror-line-like")); var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle; var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)}; if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data; } return data } function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth } function displayWidth(cm) { return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth } function displayHeight(cm) { return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight } // Ensure the lineView.wrapping.heights array is populated. This is // an array of bottom offsets for the lines that make up a drawn // line. When lineWrapping is on, there might be more than one // height. function ensureLineHeights(cm, lineView, rect) { var wrapping = cm.options.lineWrapping; var curWidth = wrapping && displayWidth(cm); if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) { var heights = lineView.measure.heights = []; if (wrapping) { lineView.measure.width = curWidth; var rects = lineView.text.firstChild.getClientRects(); for (var i = 0; i < rects.length - 1; i++) { var cur = rects[i], next = rects[i + 1]; if (Math.abs(cur.bottom - next.bottom) > 2) { heights.push((cur.bottom + next.top) / 2 - rect.top); } } } heights.push(rect.bottom - rect.top); } } // Find a line map (mapping character offsets to text nodes) and a // measurement cache for the given line number. (A line view might // contain multiple lines when collapsed ranges are present.) function mapFromLineView(lineView, line, lineN) { if (lineView.line == line) { return {map: lineView.measure.map, cache: lineView.measure.cache} } for (var i = 0; i < lineView.rest.length; i++) { if (lineView.rest[i] == line) { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } } for (var i$1 = 0; i$1 < lineView.rest.length; i$1++) { if (lineNo(lineView.rest[i$1]) > lineN) { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } } } // Render a line into the hidden node display.externalMeasured. Used // when measurement is needed for a line that's not in the viewport. function updateExternalMeasurement(cm, line) { line = visualLine(line); var lineN = lineNo(line); var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN); view.lineN = lineN; var built = view.built = buildLineContent(cm, view); view.text = built.pre; removeChildrenAndAdd(cm.display.lineMeasure, built.pre); return view } // Get a {top, bottom, left, right} box (in line-local coordinates) // for a given character. function measureChar(cm, line, ch, bias) { return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias) } // Find a line view that corresponds to the given line number. function findViewForLine(cm, lineN) { if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo) { return cm.display.view[findViewIndex(cm, lineN)] } var ext = cm.display.externalMeasured; if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size) { return ext } } // Measurement can be split in two steps, the set-up work that // applies to the whole line, and the measurement of the actual // character. Functions like coordsChar, that need to do a lot of // measurements in a row, can thus ensure that the set-up work is // only done once. function prepareMeasureForLine(cm, line) { var lineN = lineNo(line); var view = findViewForLine(cm, lineN); if (view && !view.text) { view = null; } else if (view && view.changes) { updateLineForChanges(cm, view, lineN, getDimensions(cm)); cm.curOp.forceUpdate = true; } if (!view) { view = updateExternalMeasurement(cm, line); } var info = mapFromLineView(view, line, lineN); return { line: line, view: view, rect: null, map: info.map, cache: info.cache, before: info.before, hasHeights: false } } // Given a prepared measurement object, measures the position of an // actual character (or fetches it from the cache). function measureCharPrepared(cm, prepared, ch, bias, varHeight) { if (prepared.before) { ch = -1; } var key = ch + (bias || ""), found; if (prepared.cache.hasOwnProperty(key)) { found = prepared.cache[key]; } else { if (!prepared.rect) { prepared.rect = prepared.view.text.getBoundingClientRect(); } if (!prepared.hasHeights) { ensureLineHeights(cm, prepared.view, prepared.rect); prepared.hasHeights = true; } found = measureCharInner(cm, prepared, ch, bias); if (!found.bogus) { prepared.cache[key] = found; } } return {left: found.left, right: found.right, top: varHeight ? found.rtop : found.top, bottom: varHeight ? found.rbottom : found.bottom} } var nullRect = {left: 0, right: 0, top: 0, bottom: 0}; function nodeAndOffsetInLineMap(map, ch, bias) { var node, start, end, collapse, mStart, mEnd; // First, search the line map for the text node corresponding to, // or closest to, the target character. for (var i = 0; i < map.length; i += 3) { mStart = map[i]; mEnd = map[i + 1]; if (ch < mStart) { start = 0; end = 1; collapse = "left"; } else if (ch < mEnd) { start = ch - mStart; end = start + 1; } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) { end = mEnd - mStart; start = end - 1; if (ch >= mEnd) { collapse = "right"; } } if (start != null) { node = map[i + 2]; if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right")) { collapse = bias; } if (bias == "left" && start == 0) { while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) { node = map[(i -= 3) + 2]; collapse = "left"; } } if (bias == "right" && start == mEnd - mStart) { while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) { node = map[(i += 3) + 2]; collapse = "right"; } } break } } return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd} } function getUsefulRect(rects, bias) { var rect = nullRect; if (bias == "left") { for (var i = 0; i < rects.length; i++) { if ((rect = rects[i]).left != rect.right) { break } } } else { for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) { if ((rect = rects[i$1]).left != rect.right) { break } } } return rect } function measureCharInner(cm, prepared, ch, bias) { var place = nodeAndOffsetInLineMap(prepared.map, ch, bias); var node = place.node, start = place.start, end = place.end, collapse = place.collapse; var rect; if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates. for (var i$1 = 0; i$1 < 4; i$1++) { // Retry a maximum of 4 times when nonsense rectangles are returned while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) { --start; } while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) { ++end; } if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) { rect = node.parentNode.getBoundingClientRect(); } else { rect = getUsefulRect(range(node, start, end).getClientRects(), bias); } if (rect.left || rect.right || start == 0) { break } end = start; start = start - 1; collapse = "right"; } if (ie && ie_version < 11) { rect = maybeUpdateRectForZooming(cm.display.measure, rect); } } else { // If it is a widget, simply get the box for the whole widget. if (start > 0) { collapse = bias = "right"; } var rects; if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1) { rect = rects[bias == "right" ? rects.length - 1 : 0]; } else { rect = node.getBoundingClientRect(); } } if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) { var rSpan = node.parentNode.getClientRects()[0]; if (rSpan) { rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom}; } else { rect = nullRect; } } var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top; var mid = (rtop + rbot) / 2; var heights = prepared.view.measure.heights; var i = 0; for (; i < heights.length - 1; i++) { if (mid < heights[i]) { break } } var top = i ? heights[i - 1] : 0, bot = heights[i]; var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left, right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left, top: top, bottom: bot}; if (!rect.left && !rect.right) { result.bogus = true; } if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; } return result } // Work around problem with bounding client rects on ranges being // returned incorrectly when zoomed on IE10 and below. function maybeUpdateRectForZooming(measure, rect) { if (!window.screen || screen.logicalXDPI == null || screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure)) { return rect } var scaleX = screen.logicalXDPI / screen.deviceXDPI; var scaleY = screen.logicalYDPI / screen.deviceYDPI; return {left: rect.left * scaleX, right: rect.right * scaleX, top: rect.top * scaleY, bottom: rect.bottom * scaleY} } function clearLineMeasurementCacheFor(lineView) { if (lineView.measure) { lineView.measure.cache = {}; lineView.measure.heights = null; if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++) { lineView.measure.caches[i] = {}; } } } } function clearLineMeasurementCache(cm) { cm.display.externalMeasure = null; removeChildren(cm.display.lineMeasure); for (var i = 0; i < cm.display.view.length; i++) { clearLineMeasurementCacheFor(cm.display.view[i]); } } function clearCaches(cm) { clearLineMeasurementCache(cm); cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null; if (!cm.options.lineWrapping) { cm.display.maxLineChanged = true; } cm.display.lineNumChars = null; } function pageScrollX() { // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206 // which causes page_Offset and bounding client rects to use // different reference viewports and invalidate our calculations. if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) } return window.pageXOffset || (document.documentElement || document.body).scrollLeft } function pageScrollY() { if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) } return window.pageYOffset || (document.documentElement || document.body).scrollTop } function widgetTopHeight(lineObj) { var height = 0; if (lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above) { height += widgetHeight(lineObj.widgets[i]); } } } return height } // Converts a {top, bottom, left, right} box from line-local // coordinates into another coordinate system. Context may be one of // "line", "div" (display.lineDiv), "local"./null (editor), "window", // or "page". function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) { if (!includeWidgets) { var height = widgetTopHeight(lineObj); rect.top += height; rect.bottom += height; } if (context == "line") { return rect } if (!context) { context = "local"; } var yOff = heightAtLine(lineObj); if (context == "local") { yOff += paddingTop(cm.display); } else { yOff -= cm.display.viewOffset; } if (context == "page" || context == "window") { var lOff = cm.display.lineSpace.getBoundingClientRect(); yOff += lOff.top + (context == "window" ? 0 : pageScrollY()); var xOff = lOff.left + (context == "window" ? 0 : pageScrollX()); rect.left += xOff; rect.right += xOff; } rect.top += yOff; rect.bottom += yOff; return rect } // Coverts a box from "div" coords to another coordinate system. // Context may be "window", "page", "div", or "local"./null. function fromCoordSystem(cm, coords, context) { if (context == "div") { return coords } var left = coords.left, top = coords.top; // First move into "page" coordinate system if (context == "page") { left -= pageScrollX(); top -= pageScrollY(); } else if (context == "local" || !context) { var localBox = cm.display.sizer.getBoundingClientRect(); left += localBox.left; top += localBox.top; } var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect(); return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top} } function charCoords(cm, pos, context, lineObj, bias) { if (!lineObj) { lineObj = getLine(cm.doc, pos.line); } return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context) } // Returns a box for a given cursor position, which may have an // 'other' property containing the position of the secondary cursor // on a bidi boundary. // A cursor Pos(line, char, "before") is on the same visual line as `char - 1` // and after `char - 1` in writing order of `char - 1` // A cursor Pos(line, char, "after") is on the same visual line as `char` // and before `char` in writing order of `char` // Examples (upper-case letters are RTL, lower-case are LTR): // Pos(0, 1, ...) // before after // ab a|b a|b // aB a|B aB| // Ab |Ab A|b // AB B|A B|A // Every position after the last character on a line is considered to stick // to the last character on the line. function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) { lineObj = lineObj || getLine(cm.doc, pos.line); if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); } function get(ch, right) { var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight); if (right) { m.left = m.right; } else { m.right = m.left; } return intoCoordSystem(cm, lineObj, m, context) } var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky; if (ch >= lineObj.text.length) { ch = lineObj.text.length; sticky = "before"; } else if (ch <= 0) { ch = 0; sticky = "after"; } if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") } function getBidi(ch, partPos, invert) { var part = order[partPos], right = part.level == 1; return get(invert ? ch - 1 : ch, right != invert) } var partPos = getBidiPartAt(order, ch, sticky); var other = bidiOther; var val = getBidi(ch, partPos, sticky == "before"); if (other != null) { val.other = getBidi(ch, other, sticky != "before"); } return val } // Used to cheaply estimate the coordinates for a position. Used for // intermediate scroll updates. function estimateCoords(cm, pos) { var left = 0; pos = clipPos(cm.doc, pos); if (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch; } var lineObj = getLine(cm.doc, pos.line); var top = heightAtLine(lineObj) + paddingTop(cm.display); return {left: left, right: left, top: top, bottom: top + lineObj.height} } // Positions returned by coordsChar contain some extra information. // xRel is the relative x position of the input coordinates compared // to the found position (so xRel > 0 means the coordinates are to // the right of the character position, for example). When outside // is true, that means the coordinates lie outside the line's // vertical range. function PosWithInfo(line, ch, sticky, outside, xRel) { var pos = Pos(line, ch, sticky); pos.xRel = xRel; if (outside) { pos.outside = outside; } return pos } // Compute the character position closest to the given coordinates. // Input must be lineSpace-local ("div" coordinate system). function coordsChar(cm, x, y) { var doc = cm.doc; y += cm.display.viewOffset; if (y < 0) { return PosWithInfo(doc.first, 0, null, -1, -1) } var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1; if (lineN > last) { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, 1, 1) } if (x < 0) { x = 0; } var lineObj = getLine(doc, lineN); for (;;) { var found = coordsCharInner(cm, lineObj, lineN, x, y); var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 || found.outside > 0 ? 1 : 0)); if (!collapsed) { return found } var rangeEnd = collapsed.find(1); if (rangeEnd.line == lineN) { return rangeEnd } lineObj = getLine(doc, lineN = rangeEnd.line); } } function wrappedLineExtent(cm, lineObj, preparedMeasure, y) { y -= widgetTopHeight(lineObj); var end = lineObj.text.length; var begin = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch - 1).bottom <= y; }, end, 0); end = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch).top > y; }, begin, end); return {begin: begin, end: end} } function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) { if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); } var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top; return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop) } // Returns true if the given side of a box is after the given // coordinates, in top-to-bottom, left-to-right order. function boxIsAfter(box, x, y, left) { return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x } function coordsCharInner(cm, lineObj, lineNo, x, y) { // Move y into line-local coordinate space y -= heightAtLine(lineObj); var preparedMeasure = prepareMeasureForLine(cm, lineObj); // When directly calling `measureCharPrepared`, we have to adjust // for the widgets at this line. var widgetHeight = widgetTopHeight(lineObj); var begin = 0, end = lineObj.text.length, ltr = true; var order = getOrder(lineObj, cm.doc.direction); // If the line isn't plain left-to-right text, first figure out // which bidi section the coordinates fall into. if (order) { var part = (cm.options.lineWrapping ? coordsBidiPartWrapped : coordsBidiPart) (cm, lineObj, lineNo, preparedMeasure, order, x, y); ltr = part.level != 1; // The awkward -1 offsets are needed because findFirst (called // on these below) will treat its first bound as inclusive, // second as exclusive, but we want to actually address the // characters in the part's range begin = ltr ? part.from : part.to - 1; end = ltr ? part.to : part.from - 1; } // A binary search to find the first character whose bounding box // starts after the coordinates. If we run across any whose box wrap // the coordinates, store that. var chAround = null, boxAround = null; var ch = findFirst(function (ch) { var box = measureCharPrepared(cm, preparedMeasure, ch); box.top += widgetHeight; box.bottom += widgetHeight; if (!boxIsAfter(box, x, y, false)) { return false } if (box.top <= y && box.left <= x) { chAround = ch; boxAround = box; } return true }, begin, end); var baseX, sticky, outside = false; // If a box around the coordinates was found, use that if (boxAround) { // Distinguish coordinates nearer to the left or right side of the box var atLeft = x - boxAround.left < boxAround.right - x, atStart = atLeft == ltr; ch = chAround + (atStart ? 0 : 1); sticky = atStart ? "after" : "before"; baseX = atLeft ? boxAround.left : boxAround.right; } else { // (Adjust for extended bound, if necessary.) if (!ltr && (ch == end || ch == begin)) { ch++; } // To determine which side to associate with, get the box to the // left of the character and compare it's vertical position to the // coordinates sticky = ch == 0 ? "after" : ch == lineObj.text.length ? "before" : (measureCharPrepared(cm, preparedMeasure, ch - (ltr ? 1 : 0)).bottom + widgetHeight <= y) == ltr ? "after" : "before"; // Now get accurate coordinates for this place, in order to get a // base X position var coords = cursorCoords(cm, Pos(lineNo, ch, sticky), "line", lineObj, preparedMeasure); baseX = coords.left; outside = y < coords.top ? -1 : y >= coords.bottom ? 1 : 0; } ch = skipExtendingChars(lineObj.text, ch, 1); return PosWithInfo(lineNo, ch, sticky, outside, x - baseX) } function coordsBidiPart(cm, lineObj, lineNo, preparedMeasure, order, x, y) { // Bidi parts are sorted left-to-right, and in a non-line-wrapping // situation, we can take this ordering to correspond to the visual // ordering. This finds the first part whose end is after the given // coordinates. var index = findFirst(function (i) { var part = order[i], ltr = part.level != 1; return boxIsAfter(cursorCoords(cm, Pos(lineNo, ltr ? part.to : part.from, ltr ? "before" : "after"), "line", lineObj, preparedMeasure), x, y, true) }, 0, order.length - 1); var part = order[index]; // If this isn't the first part, the part's start is also after // the coordinates, and the coordinates aren't on the same line as // that start, move one part back. if (index > 0) { var ltr = part.level != 1; var start = cursorCoords(cm, Pos(lineNo, ltr ? part.from : part.to, ltr ? "after" : "before"), "line", lineObj, preparedMeasure); if (boxIsAfter(start, x, y, true) && start.top > y) { part = order[index - 1]; } } return part } function coordsBidiPartWrapped(cm, lineObj, _lineNo, preparedMeasure, order, x, y) { // In a wrapped line, rtl text on wrapping boundaries can do things // that don't correspond to the ordering in our `order` array at // all, so a binary search doesn't work, and we want to return a // part that only spans one line so that the binary search in // coordsCharInner is safe. As such, we first find the extent of the // wrapped line, and then do a flat search in which we discard any // spans that aren't on the line. var ref = wrappedLineExtent(cm, lineObj, preparedMeasure, y); var begin = ref.begin; var end = ref.end; if (/\s/.test(lineObj.text.charAt(end - 1))) { end--; } var part = null, closestDist = null; for (var i = 0; i < order.length; i++) { var p = order[i]; if (p.from >= end || p.to <= begin) { continue } var ltr = p.level != 1; var endX = measureCharPrepared(cm, preparedMeasure, ltr ? Math.min(end, p.to) - 1 : Math.max(begin, p.from)).right; // Weigh against spans ending before this, so that they are only // picked if nothing ends after var dist = endX < x ? x - endX + 1e9 : endX - x; if (!part || closestDist > dist) { part = p; closestDist = dist; } } if (!part) { part = order[order.length - 1]; } // Clip the part to the wrapped line. if (part.from < begin) { part = {from: begin, to: part.to, level: part.level}; } if (part.to > end) { part = {from: part.from, to: end, level: part.level}; } return part } var measureText; // Compute the default text height. function textHeight(display) { if (display.cachedTextHeight != null) { return display.cachedTextHeight } if (measureText == null) { measureText = elt("pre", null, "CodeMirror-line-like"); // Measure a bunch of lines, for browsers that compute // fractional heights. for (var i = 0; i < 49; ++i) { measureText.appendChild(document.createTextNode("x")); measureText.appendChild(elt("br")); } measureText.appendChild(document.createTextNode("x")); } removeChildrenAndAdd(display.measure, measureText); var height = measureText.offsetHeight / 50; if (height > 3) { display.cachedTextHeight = height; } removeChildren(display.measure); return height || 1 } // Compute the default character width. function charWidth(display) { if (display.cachedCharWidth != null) { return display.cachedCharWidth } var anchor = elt("span", "xxxxxxxxxx"); var pre = elt("pre", [anchor], "CodeMirror-line-like"); removeChildrenAndAdd(display.measure, pre); var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10; if (width > 2) { display.cachedCharWidth = width; } return width || 10 } // Do a bulk-read of the DOM positions and sizes needed to draw the // view, so that we don't interleave reading and writing to the DOM. function getDimensions(cm) { var d = cm.display, left = {}, width = {}; var gutterLeft = d.gutters.clientLeft; for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) { var id = cm.display.gutterSpecs[i].className; left[id] = n.offsetLeft + n.clientLeft + gutterLeft; width[id] = n.clientWidth; } return {fixedPos: compensateForHScroll(d), gutterTotalWidth: d.gutters.offsetWidth, gutterLeft: left, gutterWidth: width, wrapperWidth: d.wrapper.clientWidth} } // Computes display.scroller.scrollLeft + display.gutters.offsetWidth, // but using getBoundingClientRect to get a sub-pixel-accurate // result. function compensateForHScroll(display) { return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left } // Returns a function that estimates the height of a line, to use as // first approximation until the line becomes visible (and is thus // properly measurable). function estimateHeight(cm) { var th = textHeight(cm.display), wrapping = cm.options.lineWrapping; var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3); return function (line) { if (lineIsHidden(cm.doc, line)) { return 0 } var widgetsHeight = 0; if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) { if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height; } } } if (wrapping) { return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th } else { return widgetsHeight + th } } } function estimateLineHeights(cm) { var doc = cm.doc, est = estimateHeight(cm); doc.iter(function (line) { var estHeight = est(line); if (estHeight != line.height) { updateLineHeight(line, estHeight); } }); } // Given a mouse event, find the corresponding position. If liberal // is false, it checks whether a gutter or scrollbar was clicked, // and returns null if it was. forRect is used by rectangular // selections, and tries to estimate a character position even for // coordinates beyond the right of the text. function posFromMouse(cm, e, liberal, forRect) { var display = cm.display; if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { return null } var x, y, space = display.lineSpace.getBoundingClientRect(); // Fails unpredictably on IE[67] when mouse is dragged around quickly. try { x = e.clientX - space.left; y = e.clientY - space.top; } catch (e$1) { return null } var coords = coordsChar(cm, x, y), line; if (forRect && coords.xRel > 0 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); } return coords } // Find the view element corresponding to a given line. Return null // when the line isn't visible. function findViewIndex(cm, n) { if (n >= cm.display.viewTo) { return null } n -= cm.display.viewFrom; if (n < 0) { return null } var view = cm.display.view; for (var i = 0; i < view.length; i++) { n -= view[i].size; if (n < 0) { return i } } } // Updates the display.view data structure for a given change to the // document. From and to are in pre-change coordinates. Lendiff is // the amount of lines added or subtracted by the change. This is // used for changes that span multiple lines, or change the way // lines are divided into visual lines. regLineChange (below) // registers single-line changes. function regChange(cm, from, to, lendiff) { if (from == null) { from = cm.doc.first; } if (to == null) { to = cm.doc.first + cm.doc.size; } if (!lendiff) { lendiff = 0; } var display = cm.display; if (lendiff && to < display.viewTo && (display.updateLineNumbers == null || display.updateLineNumbers > from)) { display.updateLineNumbers = from; } cm.curOp.viewChanged = true; if (from >= display.viewTo) { // Change after if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo) { resetView(cm); } } else if (to <= display.viewFrom) { // Change before if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) { resetView(cm); } else { display.viewFrom += lendiff; display.viewTo += lendiff; } } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap resetView(cm); } else if (from <= display.viewFrom) { // Top overlap var cut = viewCuttingPoint(cm, to, to + lendiff, 1); if (cut) { display.view = display.view.slice(cut.index); display.viewFrom = cut.lineN; display.viewTo += lendiff; } else { resetView(cm); } } else if (to >= display.viewTo) { // Bottom overlap var cut$1 = viewCuttingPoint(cm, from, from, -1); if (cut$1) { display.view = display.view.slice(0, cut$1.index); display.viewTo = cut$1.lineN; } else { resetView(cm); } } else { // Gap in the middle var cutTop = viewCuttingPoint(cm, from, from, -1); var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1); if (cutTop && cutBot) { display.view = display.view.slice(0, cutTop.index) .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN)) .concat(display.view.slice(cutBot.index)); display.viewTo += lendiff; } else { resetView(cm); } } var ext = display.externalMeasured; if (ext) { if (to < ext.lineN) { ext.lineN += lendiff; } else if (from < ext.lineN + ext.size) { display.externalMeasured = null; } } } // Register a change to a single line. Type must be one of "text", // "gutter", "class", "widget" function regLineChange(cm, line, type) { cm.curOp.viewChanged = true; var display = cm.display, ext = cm.display.externalMeasured; if (ext && line >= ext.lineN && line < ext.lineN + ext.size) { display.externalMeasured = null; } if (line < display.viewFrom || line >= display.viewTo) { return } var lineView = display.view[findViewIndex(cm, line)]; if (lineView.node == null) { return } var arr = lineView.changes || (lineView.changes = []); if (indexOf(arr, type) == -1) { arr.push(type); } } // Clear the view. function resetView(cm) { cm.display.viewFrom = cm.display.viewTo = cm.doc.first; cm.display.view = []; cm.display.viewOffset = 0; } function viewCuttingPoint(cm, oldN, newN, dir) { var index = findViewIndex(cm, oldN), diff, view = cm.display.view; if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size) { return {index: index, lineN: newN} } var n = cm.display.viewFrom; for (var i = 0; i < index; i++) { n += view[i].size; } if (n != oldN) { if (dir > 0) { if (index == view.length - 1) { return null } diff = (n + view[index].size) - oldN; index++; } else { diff = n - oldN; } oldN += diff; newN += diff; } while (visualLineNo(cm.doc, newN) != newN) { if (index == (dir < 0 ? 0 : view.length - 1)) { return null } newN += dir * view[index - (dir < 0 ? 1 : 0)].size; index += dir; } return {index: index, lineN: newN} } // Force the view to cover a given range, adding empty view element // or clipping off existing ones as needed. function adjustView(cm, from, to) { var display = cm.display, view = display.view; if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) { display.view = buildViewArray(cm, from, to); display.viewFrom = from; } else { if (display.viewFrom > from) { display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); } else if (display.viewFrom < from) { display.view = display.view.slice(findViewIndex(cm, from)); } display.viewFrom = from; if (display.viewTo < to) { display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); } else if (display.viewTo > to) { display.view = display.view.slice(0, findViewIndex(cm, to)); } } display.viewTo = to; } // Count the number of lines in the view whose DOM representation is // out of date (or nonexistent). function countDirtyView(cm) { var view = cm.display.view, dirty = 0; for (var i = 0; i < view.length; i++) { var lineView = view[i]; if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty; } } return dirty } function updateSelection(cm) { cm.display.input.showSelection(cm.display.input.prepareSelection()); } function prepareSelection(cm, primary) { if ( primary === void 0 ) primary = true; var doc = cm.doc, result = {}; var curFragment = result.cursors = document.createDocumentFragment(); var selFragment = result.selection = document.createDocumentFragment(); for (var i = 0; i < doc.sel.ranges.length; i++) { if (!primary && i == doc.sel.primIndex) { continue } var range = doc.sel.ranges[i]; if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) { continue } var collapsed = range.empty(); if (collapsed || cm.options.showCursorWhenSelecting) { drawSelectionCursor(cm, range.head, curFragment); } if (!collapsed) { drawSelectionRange(cm, range, selFragment); } } return result } // Draws a cursor for the given range function drawSelectionCursor(cm, head, output) { var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine); var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor")); cursor.style.left = pos.left + "px"; cursor.style.top = pos.top + "px"; cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"; if (pos.other) { // Secondary cursor, shown when on a 'jump' in bi-directional text var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor")); otherCursor.style.display = ""; otherCursor.style.left = pos.other.left + "px"; otherCursor.style.top = pos.other.top + "px"; otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px"; } } function cmpCoords(a, b) { return a.top - b.top || a.left - b.left } // Draws the given range as a highlighted selection function drawSelectionRange(cm, range, output) { var display = cm.display, doc = cm.doc; var fragment = document.createDocumentFragment(); var padding = paddingH(cm.display), leftSide = padding.left; var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right; var docLTR = doc.direction == "ltr"; function add(left, top, width, bottom) { if (top < 0) { top = 0; } top = Math.round(top); bottom = Math.round(bottom); fragment.appendChild(elt("div", null, "CodeMirror-selected", ("position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (width == null ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px"))); } function drawForLine(line, fromArg, toArg) { var lineObj = getLine(doc, line); var lineLen = lineObj.text.length; var start, end; function coords(ch, bias) { return charCoords(cm, Pos(line, ch), "div", lineObj, bias) } function wrapX(pos, dir, side) { var extent = wrappedLineExtentChar(cm, lineObj, null, pos); var prop = (dir == "ltr") == (side == "after") ? "left" : "right"; var ch = side == "after" ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1); return coords(ch, prop)[prop] } var order = getOrder(lineObj, doc.direction); iterateBidiSections(order, fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir, i) { var ltr = dir == "ltr"; var fromPos = coords(from, ltr ? "left" : "right"); var toPos = coords(to - 1, ltr ? "right" : "left"); var openStart = fromArg == null && from == 0, openEnd = toArg == null && to == lineLen; var first = i == 0, last = !order || i == order.length - 1; if (toPos.top - fromPos.top <= 3) { // Single line var openLeft = (docLTR ? openStart : openEnd) && first; var openRight = (docLTR ? openEnd : openStart) && last; var left = openLeft ? leftSide : (ltr ? fromPos : toPos).left; var right = openRight ? rightSide : (ltr ? toPos : fromPos).right; add(left, fromPos.top, right - left, fromPos.bottom); } else { // Multiple lines var topLeft, topRight, botLeft, botRight; if (ltr) { topLeft = docLTR && openStart && first ? leftSide : fromPos.left; topRight = docLTR ? rightSide : wrapX(from, dir, "before"); botLeft = docLTR ? leftSide : wrapX(to, dir, "after"); botRight = docLTR && openEnd && last ? rightSide : toPos.right; } else { topLeft = !docLTR ? leftSide : wrapX(from, dir, "before"); topRight = !docLTR && openStart && first ? rightSide : fromPos.right; botLeft = !docLTR && openEnd && last ? leftSide : toPos.left; botRight = !docLTR ? rightSide : wrapX(to, dir, "after"); } add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom); if (fromPos.bottom < toPos.top) { add(leftSide, fromPos.bottom, null, toPos.top); } add(botLeft, toPos.top, botRight - botLeft, toPos.bottom); } if (!start || cmpCoords(fromPos, start) < 0) { start = fromPos; } if (cmpCoords(toPos, start) < 0) { start = toPos; } if (!end || cmpCoords(fromPos, end) < 0) { end = fromPos; } if (cmpCoords(toPos, end) < 0) { end = toPos; } }); return {start: start, end: end} } var sFrom = range.from(), sTo = range.to(); if (sFrom.line == sTo.line) { drawForLine(sFrom.line, sFrom.ch, sTo.ch); } else { var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line); var singleVLine = visualLine(fromLine) == visualLine(toLine); var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end; var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start; if (singleVLine) { if (leftEnd.top < rightStart.top - 2) { add(leftEnd.right, leftEnd.top, null, leftEnd.bottom); add(leftSide, rightStart.top, rightStart.left, rightStart.bottom); } else { add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom); } } if (leftEnd.bottom < rightStart.top) { add(leftSide, leftEnd.bottom, null, rightStart.top); } } output.appendChild(fragment); } // Cursor-blinking function restartBlink(cm) { if (!cm.state.focused) { return } var display = cm.display; clearInterval(display.blinker); var on = true; display.cursorDiv.style.visibility = ""; if (cm.options.cursorBlinkRate > 0) { display.blinker = setInterval(function () { return display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; }, cm.options.cursorBlinkRate); } else if (cm.options.cursorBlinkRate < 0) { display.cursorDiv.style.visibility = "hidden"; } } function ensureFocus(cm) { if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); } } function delayBlurEvent(cm) { cm.state.delayingBlurEvent = true; setTimeout(function () { if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; onBlur(cm); } }, 100); } function onFocus(cm, e) { if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; } if (cm.options.readOnly == "nocursor") { return } if (!cm.state.focused) { signal(cm, "focus", cm, e); cm.state.focused = true; addClass(cm.display.wrapper, "CodeMirror-focused"); // This test prevents this from firing when a context // menu is closed (since the input reset would kill the // select-all detection hack) if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) { cm.display.input.reset(); if (webkit) { setTimeout(function () { return cm.display.input.reset(true); }, 20); } // Issue #1730 } cm.display.input.receivedFocus(); } restartBlink(cm); } function onBlur(cm, e) { if (cm.state.delayingBlurEvent) { return } if (cm.state.focused) { signal(cm, "blur", cm, e); cm.state.focused = false; rmClass(cm.display.wrapper, "CodeMirror-focused"); } clearInterval(cm.display.blinker); setTimeout(function () { if (!cm.state.focused) { cm.display.shift = false; } }, 150); } // Read the actual heights of the rendered lines, and update their // stored heights to match. function updateHeightsInViewport(cm) { var display = cm.display; var prevBottom = display.lineDiv.offsetTop; for (var i = 0; i < display.view.length; i++) { var cur = display.view[i], wrapping = cm.options.lineWrapping; var height = (void 0), width = 0; if (cur.hidden) { continue } if (ie && ie_version < 8) { var bot = cur.node.offsetTop + cur.node.offsetHeight; height = bot - prevBottom; prevBottom = bot; } else { var box = cur.node.getBoundingClientRect(); height = box.bottom - box.top; // Check that lines don't extend past the right of the current // editor width if (!wrapping && cur.text.firstChild) { width = cur.text.firstChild.getBoundingClientRect().right - box.left - 1; } } var diff = cur.line.height - height; if (diff > .005 || diff < -.005) { updateLineHeight(cur.line, height); updateWidgetHeight(cur.line); if (cur.rest) { for (var j = 0; j < cur.rest.length; j++) { updateWidgetHeight(cur.rest[j]); } } } if (width > cm.display.sizerWidth) { var chWidth = Math.ceil(width / charWidth(cm.display)); if (chWidth > cm.display.maxLineLength) { cm.display.maxLineLength = chWidth; cm.display.maxLine = cur.line; cm.display.maxLineChanged = true; } } } } // Read and store the height of line widgets associated with the // given line. function updateWidgetHeight(line) { if (line.widgets) { for (var i = 0; i < line.widgets.length; ++i) { var w = line.widgets[i], parent = w.node.parentNode; if (parent) { w.height = parent.offsetHeight; } } } } // Compute the lines that are visible in a given viewport (defaults // the the current scroll position). viewport may contain top, // height, and ensure (see op.scrollToPos) properties. function visibleLines(display, doc, viewport) { var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop; top = Math.floor(top - paddingTop(display)); var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight; var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom); // Ensure is a {from: {line, ch}, to: {line, ch}} object, and // forces those lines into the viewport (if possible). if (viewport && viewport.ensure) { var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line; if (ensureFrom < from) { from = ensureFrom; to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight); } else if (Math.min(ensureTo, doc.lastLine()) >= to) { from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight); to = ensureTo; } } return {from: from, to: Math.max(to, from + 1)} } // SCROLLING THINGS INTO VIEW // If an editor sits on the top or bottom of the window, partially // scrolled out of view, this ensures that the cursor is visible. function maybeScrollWindow(cm, rect) { if (signalDOMEvent(cm, "scrollCursorIntoView")) { return } var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; if (rect.top + box.top < 0) { doScroll = true; } else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; } if (doScroll != null && !phantom) { var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;")); cm.display.lineSpace.appendChild(scrollNode); scrollNode.scrollIntoView(doScroll); cm.display.lineSpace.removeChild(scrollNode); } } // Scroll a given position into view (immediately), verifying that // it actually became visible (as line heights are accurately // measured, the position of something may 'drift' during drawing). function scrollPosIntoView(cm, pos, end, margin) { if (margin == null) { margin = 0; } var rect; if (!cm.options.lineWrapping && pos == end) { // Set pos and end to the cursor positions around the character pos sticks to // If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch // If pos == Pos(_, 0, "before"), pos and end are unchanged pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos; end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos; } for (var limit = 0; limit < 5; limit++) { var changed = false; var coords = cursorCoords(cm, pos); var endCoords = !end || end == pos ? coords : cursorCoords(cm, end); rect = {left: Math.min(coords.left, endCoords.left), top: Math.min(coords.top, endCoords.top) - margin, right: Math.max(coords.left, endCoords.left), bottom: Math.max(coords.bottom, endCoords.bottom) + margin}; var scrollPos = calculateScrollPos(cm, rect); var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft; if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); if (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true; } } if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true; } } if (!changed) { break } } return rect } // Scroll a given set of coordinates into view (immediately). function scrollIntoView(cm, rect) { var scrollPos = calculateScrollPos(cm, rect); if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); } if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); } } // Calculate a new scroll position needed to scroll the given // rectangle into view. Returns an object with scrollTop and // scrollLeft properties. When these are undefined, the // vertical/horizontal position does not need to be adjusted. function calculateScrollPos(cm, rect) { var display = cm.display, snapMargin = textHeight(cm.display); if (rect.top < 0) { rect.top = 0; } var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop; var screen = displayHeight(cm), result = {}; if (rect.bottom - rect.top > screen) { rect.bottom = rect.top + screen; } var docBottom = cm.doc.height + paddingVert(display); var atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin; if (rect.top < screentop) { result.scrollTop = atTop ? 0 : rect.top; } else if (rect.bottom > screentop + screen) { var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen); if (newTop != screentop) { result.scrollTop = newTop; } } var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft; var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0); var tooWide = rect.right - rect.left > screenw; if (tooWide) { rect.right = rect.left + screenw; } if (rect.left < 10) { result.scrollLeft = 0; } else if (rect.left < screenleft) { result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)); } else if (rect.right > screenw + screenleft - 3) { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; } return result } // Store a relative adjustment to the scroll position in the current // operation (to be applied when the operation finishes). function addToScrollTop(cm, top) { if (top == null) { return } resolveScrollToPos(cm); cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top; } // Make sure that at the end of the operation the current cursor is // shown. function ensureCursorVisible(cm) { resolveScrollToPos(cm); var cur = cm.getCursor(); cm.curOp.scrollToPos = {from: cur, to: cur, margin: cm.options.cursorScrollMargin}; } function scrollToCoords(cm, x, y) { if (x != null || y != null) { resolveScrollToPos(cm); } if (x != null) { cm.curOp.scrollLeft = x; } if (y != null) { cm.curOp.scrollTop = y; } } function scrollToRange(cm, range) { resolveScrollToPos(cm); cm.curOp.scrollToPos = range; } // When an operation has its scrollToPos property set, and another // scroll action is applied before the end of the operation, this // 'simulates' scrolling that position into view in a cheap way, so // that the effect of intermediate scroll commands is not ignored. function resolveScrollToPos(cm) { var range = cm.curOp.scrollToPos; if (range) { cm.curOp.scrollToPos = null; var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to); scrollToCoordsRange(cm, from, to, range.margin); } } function scrollToCoordsRange(cm, from, to, margin) { var sPos = calculateScrollPos(cm, { left: Math.min(from.left, to.left), top: Math.min(from.top, to.top) - margin, right: Math.max(from.right, to.right), bottom: Math.max(from.bottom, to.bottom) + margin }); scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop); } // Sync the scrollable area and scrollbars, ensure the viewport // covers the visible area. function updateScrollTop(cm, val) { if (Math.abs(cm.doc.scrollTop - val) < 2) { return } if (!gecko) { updateDisplaySimple(cm, {top: val}); } setScrollTop(cm, val, true); if (gecko) { updateDisplaySimple(cm); } startWorker(cm, 100); } function setScrollTop(cm, val, forceScroll) { val = Math.max(0, Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val)); if (cm.display.scroller.scrollTop == val && !forceScroll) { return } cm.doc.scrollTop = val; cm.display.scrollbars.setScrollTop(val); if (cm.display.scroller.scrollTop != val) { cm.display.scroller.scrollTop = val; } } // Sync scroller and scrollbar, ensure the gutter elements are // aligned. function setScrollLeft(cm, val, isScroller, forceScroll) { val = Math.max(0, Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth)); if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) { return } cm.doc.scrollLeft = val; alignHorizontally(cm); if (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val; } cm.display.scrollbars.setScrollLeft(val); } // SCROLLBARS // Prepare DOM reads needed to update the scrollbars. Done in one // shot to minimize update/measure roundtrips. function measureForScrollbars(cm) { var d = cm.display, gutterW = d.gutters.offsetWidth; var docH = Math.round(cm.doc.height + paddingVert(cm.display)); return { clientHeight: d.scroller.clientHeight, viewHeight: d.wrapper.clientHeight, scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth, viewWidth: d.wrapper.clientWidth, barLeft: cm.options.fixedGutter ? gutterW : 0, docHeight: docH, scrollHeight: docH + scrollGap(cm) + d.barHeight, nativeBarWidth: d.nativeBarWidth, gutterWidth: gutterW } } var NativeScrollbars = function(place, scroll, cm) { this.cm = cm; var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar"); var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar"); vert.tabIndex = horiz.tabIndex = -1; place(vert); place(horiz); on(vert, "scroll", function () { if (vert.clientHeight) { scroll(vert.scrollTop, "vertical"); } }); on(horiz, "scroll", function () { if (horiz.clientWidth) { scroll(horiz.scrollLeft, "horizontal"); } }); this.checkedZeroWidth = false; // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8). if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = "18px"; } }; NativeScrollbars.prototype.update = function (measure) { var needsH = measure.scrollWidth > measure.clientWidth + 1; var needsV = measure.scrollHeight > measure.clientHeight + 1; var sWidth = measure.nativeBarWidth; if (needsV) { this.vert.style.display = "block"; this.vert.style.bottom = needsH ? sWidth + "px" : "0"; var totalHeight = measure.viewHeight - (needsH ? sWidth : 0); // A bug in IE8 can cause this value to be negative, so guard it. this.vert.firstChild.style.height = Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px"; } else { this.vert.style.display = ""; this.vert.firstChild.style.height = "0"; } if (needsH) { this.horiz.style.display = "block"; this.horiz.style.right = needsV ? sWidth + "px" : "0"; this.horiz.style.left = measure.barLeft + "px"; var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0); this.horiz.firstChild.style.width = Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px"; } else { this.horiz.style.display = ""; this.horiz.firstChild.style.width = "0"; } if (!this.checkedZeroWidth && measure.clientHeight > 0) { if (sWidth == 0) { this.zeroWidthHack(); } this.checkedZeroWidth = true; } return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0} }; NativeScrollbars.prototype.setScrollLeft = function (pos) { if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos; } if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz"); } }; NativeScrollbars.prototype.setScrollTop = function (pos) { if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos; } if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert, "vert"); } }; NativeScrollbars.prototype.zeroWidthHack = function () { var w = mac && !mac_geMountainLion ? "12px" : "18px"; this.horiz.style.height = this.vert.style.width = w; this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none"; this.disableHoriz = new Delayed; this.disableVert = new Delayed; }; NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) { bar.style.pointerEvents = "auto"; function maybeDisable() { // To find out whether the scrollbar is still visible, we // check whether the element under the pixel in the bottom // right corner of the scrollbar box is the scrollbar box // itself (when the bar is still visible) or its filler child // (when the bar is hidden). If it is still visible, we keep // it enabled, if it's hidden, we disable pointer events. var box = bar.getBoundingClientRect(); var elt = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2) : document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1); if (elt != bar) { bar.style.pointerEvents = "none"; } else { delay.set(1000, maybeDisable); } } delay.set(1000, maybeDisable); }; NativeScrollbars.prototype.clear = function () { var parent = this.horiz.parentNode; parent.removeChild(this.horiz); parent.removeChild(this.vert); }; var NullScrollbars = function () {}; NullScrollbars.prototype.update = function () { return {bottom: 0, right: 0} }; NullScrollbars.prototype.setScrollLeft = function () {}; NullScrollbars.prototype.setScrollTop = function () {}; NullScrollbars.prototype.clear = function () {}; function updateScrollbars(cm, measure) { if (!measure) { measure = measureForScrollbars(cm); } var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight; updateScrollbarsInner(cm, measure); for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) { if (startWidth != cm.display.barWidth && cm.options.lineWrapping) { updateHeightsInViewport(cm); } updateScrollbarsInner(cm, measureForScrollbars(cm)); startWidth = cm.display.barWidth; startHeight = cm.display.barHeight; } } // Re-synchronize the fake scrollbars with the actual size of the // content. function updateScrollbarsInner(cm, measure) { var d = cm.display; var sizes = d.scrollbars.update(measure); d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px"; d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px"; d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"; if (sizes.right && sizes.bottom) { d.scrollbarFiller.style.display = "block"; d.scrollbarFiller.style.height = sizes.bottom + "px"; d.scrollbarFiller.style.width = sizes.right + "px"; } else { d.scrollbarFiller.style.display = ""; } if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) { d.gutterFiller.style.display = "block"; d.gutterFiller.style.height = sizes.bottom + "px"; d.gutterFiller.style.width = measure.gutterWidth + "px"; } else { d.gutterFiller.style.display = ""; } } var scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars}; function initScrollbars(cm) { if (cm.display.scrollbars) { cm.display.scrollbars.clear(); if (cm.display.scrollbars.addClass) { rmClass(cm.display.wrapper, cm.display.scrollbars.addClass); } } cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function (node) { cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller); // Prevent clicks in the scrollbars from killing focus on(node, "mousedown", function () { if (cm.state.focused) { setTimeout(function () { return cm.display.input.focus(); }, 0); } }); node.setAttribute("cm-not-content", "true"); }, function (pos, axis) { if (axis == "horizontal") { setScrollLeft(cm, pos); } else { updateScrollTop(cm, pos); } }, cm); if (cm.display.scrollbars.addClass) { addClass(cm.display.wrapper, cm.display.scrollbars.addClass); } } // Operations are used to wrap a series of changes to the editor // state in such a way that each change won't have to update the // cursor and display (which would be awkward, slow, and // error-prone). Instead, display updates are batched and then all // combined and executed at once. var nextOpId = 0; // Start a new operation. function startOperation(cm) { cm.curOp = { cm: cm, viewChanged: false, // Flag that indicates that lines might need to be redrawn startHeight: cm.doc.height, // Used to detect need to update scrollbar forceUpdate: false, // Used to force a redraw updateInput: 0, // Whether to reset the input textarea typing: false, // Whether this reset should be careful to leave existing text (for compositing) changeObjs: null, // Accumulated changes, for firing change events cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already selectionChanged: false, // Whether the selection needs to be redrawn updateMaxLine: false, // Set when the widest line needs to be determined anew scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet scrollToPos: null, // Used to scroll to a specific position focus: false, id: ++nextOpId // Unique ID }; pushOperation(cm.curOp); } // Finish an operation, updating the display and signalling delayed events function endOperation(cm) { var op = cm.curOp; if (op) { finishOperation(op, function (group) { for (var i = 0; i < group.ops.length; i++) { group.ops[i].cm.curOp = null; } endOperations(group); }); } } // The DOM updates done when an operation finishes are batched so // that the minimum number of relayouts are required. function endOperations(group) { var ops = group.ops; for (var i = 0; i < ops.length; i++) // Read DOM { endOperation_R1(ops[i]); } for (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe) { endOperation_W1(ops[i$1]); } for (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM { endOperation_R2(ops[i$2]); } for (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe) { endOperation_W2(ops[i$3]); } for (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM { endOperation_finish(ops[i$4]); } } function endOperation_R1(op) { var cm = op.cm, display = cm.display; maybeClipScrollbars(cm); if (op.updateMaxLine) { findMaxLine(cm); } op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null || op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom || op.scrollToPos.to.line >= display.viewTo) || display.maxLineChanged && cm.options.lineWrapping; op.update = op.mustUpdate && new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate); } function endOperation_W1(op) { op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update); } function endOperation_R2(op) { var cm = op.cm, display = cm.display; if (op.updatedDisplay) { updateHeightsInViewport(cm); } op.barMeasure = measureForScrollbars(cm); // If the max line changed since it was last measured, measure it, // and ensure the document's width matches it. // updateDisplay_W2 will use these properties to do the actual resizing if (display.maxLineChanged && !cm.options.lineWrapping) { op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3; cm.display.sizerWidth = op.adjustWidthTo; op.barMeasure.scrollWidth = Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth); op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm)); } if (op.updatedDisplay || op.selectionChanged) { op.preparedSelection = display.input.prepareSelection(); } } function endOperation_W2(op) { var cm = op.cm; if (op.adjustWidthTo != null) { cm.display.sizer.style.minWidth = op.adjustWidthTo + "px"; if (op.maxScrollLeft < cm.doc.scrollLeft) { setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true); } cm.display.maxLineChanged = false; } var takeFocus = op.focus && op.focus == activeElt(); if (op.preparedSelection) { cm.display.input.showSelection(op.preparedSelection, takeFocus); } if (op.updatedDisplay || op.startHeight != cm.doc.height) { updateScrollbars(cm, op.barMeasure); } if (op.updatedDisplay) { setDocumentHeight(cm, op.barMeasure); } if (op.selectionChanged) { restartBlink(cm); } if (cm.state.focused && op.updateInput) { cm.display.input.reset(op.typing); } if (takeFocus) { ensureFocus(op.cm); } } function endOperation_finish(op) { var cm = op.cm, display = cm.display, doc = cm.doc; if (op.updatedDisplay) { postUpdateDisplay(cm, op.update); } // Abort mouse wheel delta measurement, when scrolling explicitly if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos)) { display.wheelStartX = display.wheelStartY = null; } // Propagate the scroll position to the actual DOM scroller if (op.scrollTop != null) { setScrollTop(cm, op.scrollTop, op.forceScroll); } if (op.scrollLeft != null) { setScrollLeft(cm, op.scrollLeft, true, true); } // If we need to scroll a specific position into view, do so. if (op.scrollToPos) { var rect = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from), clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin); maybeScrollWindow(cm, rect); } // Fire events for markers that are hidden/unidden by editing or // undoing var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers; if (hidden) { for (var i = 0; i < hidden.length; ++i) { if (!hidden[i].lines.length) { signal(hidden[i], "hide"); } } } if (unhidden) { for (var i$1 = 0; i$1 < unhidden.length; ++i$1) { if (unhidden[i$1].lines.length) { signal(unhidden[i$1], "unhide"); } } } if (display.wrapper.offsetHeight) { doc.scrollTop = cm.display.scroller.scrollTop; } // Fire change events, and delayed event handlers if (op.changeObjs) { signal(cm, "changes", cm, op.changeObjs); } if (op.update) { op.update.finish(); } } // Run the given function in an operation function runInOp(cm, f) { if (cm.curOp) { return f() } startOperation(cm); try { return f() } finally { endOperation(cm); } } // Wraps a function in an operation. Returns the wrapped function. function operation(cm, f) { return function() { if (cm.curOp) { return f.apply(cm, arguments) } startOperation(cm); try { return f.apply(cm, arguments) } finally { endOperation(cm); } } } // Used to add methods to editor and doc instances, wrapping them in // operations. function methodOp(f) { return function() { if (this.curOp) { return f.apply(this, arguments) } startOperation(this); try { return f.apply(this, arguments) } finally { endOperation(this); } } } function docMethodOp(f) { return function() { var cm = this.cm; if (!cm || cm.curOp) { return f.apply(this, arguments) } startOperation(cm); try { return f.apply(this, arguments) } finally { endOperation(cm); } } } // HIGHLIGHT WORKER function startWorker(cm, time) { if (cm.doc.highlightFrontier < cm.display.viewTo) { cm.state.highlight.set(time, bind(highlightWorker, cm)); } } function highlightWorker(cm) { var doc = cm.doc; if (doc.highlightFrontier >= cm.display.viewTo) { return } var end = +new Date + cm.options.workTime; var context = getContextBefore(cm, doc.highlightFrontier); var changedLines = []; doc.iter(context.line, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) { if (context.line >= cm.display.viewFrom) { // Visible var oldStyles = line.styles; var resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc.mode, context.state) : null; var highlighted = highlightLine(cm, line, context, true); if (resetState) { context.state = resetState; } line.styles = highlighted.styles; var oldCls = line.styleClasses, newCls = highlighted.classes; if (newCls) { line.styleClasses = newCls; } else if (oldCls) { line.styleClasses = null; } var ischange = !oldStyles || oldStyles.length != line.styles.length || oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass); for (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i]; } if (ischange) { changedLines.push(context.line); } line.stateAfter = context.save(); context.nextLine(); } else { if (line.text.length <= cm.options.maxHighlightLength) { processLine(cm, line.text, context); } line.stateAfter = context.line % 5 == 0 ? context.save() : null; context.nextLine(); } if (+new Date > end) { startWorker(cm, cm.options.workDelay); return true } }); doc.highlightFrontier = context.line; doc.modeFrontier = Math.max(doc.modeFrontier, context.line); if (changedLines.length) { runInOp(cm, function () { for (var i = 0; i < changedLines.length; i++) { regLineChange(cm, changedLines[i], "text"); } }); } } // DISPLAY DRAWING var DisplayUpdate = function(cm, viewport, force) { var display = cm.display; this.viewport = viewport; // Store some values that we'll need later (but don't want to force a relayout for) this.visible = visibleLines(display, cm.doc, viewport); this.editorIsHidden = !display.wrapper.offsetWidth; this.wrapperHeight = display.wrapper.clientHeight; this.wrapperWidth = display.wrapper.clientWidth; this.oldDisplayWidth = displayWidth(cm); this.force = force; this.dims = getDimensions(cm); this.events = []; }; DisplayUpdate.prototype.signal = function (emitter, type) { if (hasHandler(emitter, type)) { this.events.push(arguments); } }; DisplayUpdate.prototype.finish = function () { for (var i = 0; i < this.events.length; i++) { signal.apply(null, this.events[i]); } }; function maybeClipScrollbars(cm) { var display = cm.display; if (!display.scrollbarsClipped && display.scroller.offsetWidth) { display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth; display.heightForcer.style.height = scrollGap(cm) + "px"; display.sizer.style.marginBottom = -display.nativeBarWidth + "px"; display.sizer.style.borderRightWidth = scrollGap(cm) + "px"; display.scrollbarsClipped = true; } } function selectionSnapshot(cm) { if (cm.hasFocus()) { return null } var active = activeElt(); if (!active || !contains(cm.display.lineDiv, active)) { return null } var result = {activeElt: active}; if (window.getSelection) { var sel = window.getSelection(); if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) { result.anchorNode = sel.anchorNode; result.anchorOffset = sel.anchorOffset; result.focusNode = sel.focusNode; result.focusOffset = sel.focusOffset; } } return result } function restoreSelection(snapshot) { if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return } snapshot.activeElt.focus(); if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) && snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) { var sel = window.getSelection(), range = document.createRange(); range.setEnd(snapshot.anchorNode, snapshot.anchorOffset); range.collapse(false); sel.removeAllRanges(); sel.addRange(range); sel.extend(snapshot.focusNode, snapshot.focusOffset); } } // Does the actual updating of the line display. Bails out // (returning false) when there is nothing to be done and forced is // false. function updateDisplayIfNeeded(cm, update) { var display = cm.display, doc = cm.doc; if (update.editorIsHidden) { resetView(cm); return false } // Bail out if the visible area is already rendered and nothing changed. if (!update.force && update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo && (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) && display.renderedView == display.view && countDirtyView(cm) == 0) { return false } if (maybeUpdateLineNumberWidth(cm)) { resetView(cm); update.dims = getDimensions(cm); } // Compute a suitable new viewport (from & to) var end = doc.first + doc.size; var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first); var to = Math.min(end, update.visible.to + cm.options.viewportMargin); if (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom); } if (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo); } if (sawCollapsedSpans) { from = visualLineNo(cm.doc, from); to = visualLineEndNo(cm.doc, to); } var different = from != display.viewFrom || to != display.viewTo || display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth; adjustView(cm, from, to); display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom)); // Position the mover div to align with the current scroll position cm.display.mover.style.top = display.viewOffset + "px"; var toUpdate = countDirtyView(cm); if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view && (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo)) { return false } // For big changes, we hide the enclosing element during the // update, since that speeds up the operations on most browsers. var selSnapshot = selectionSnapshot(cm); if (toUpdate > 4) { display.lineDiv.style.display = "none"; } patchDisplay(cm, display.updateLineNumbers, update.dims); if (toUpdate > 4) { display.lineDiv.style.display = ""; } display.renderedView = display.view; // There might have been a widget with a focused element that got // hidden or updated, if so re-focus it. restoreSelection(selSnapshot); // Prevent selection and cursors from interfering with the scroll // width and height. removeChildren(display.cursorDiv); removeChildren(display.selectionDiv); display.gutters.style.height = display.sizer.style.minHeight = 0; if (different) { display.lastWrapHeight = update.wrapperHeight; display.lastWrapWidth = update.wrapperWidth; startWorker(cm, 400); } display.updateLineNumbers = null; return true } function postUpdateDisplay(cm, update) { var viewport = update.viewport; for (var first = true;; first = false) { if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) { // Clip forced viewport to actual scrollable area. if (viewport && viewport.top != null) { viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)}; } // Updated line heights might result in the drawn area not // actually covering the viewport. Keep looping until it does. update.visible = visibleLines(cm.display, cm.doc, viewport); if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo) { break } } else if (first) { update.visible = visibleLines(cm.display, cm.doc, viewport); } if (!updateDisplayIfNeeded(cm, update)) { break } updateHeightsInViewport(cm); var barMeasure = measureForScrollbars(cm); updateSelection(cm); updateScrollbars(cm, barMeasure); setDocumentHeight(cm, barMeasure); update.force = false; } update.signal(cm, "update", cm); if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) { update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo); cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo; } } function updateDisplaySimple(cm, viewport) { var update = new DisplayUpdate(cm, viewport); if (updateDisplayIfNeeded(cm, update)) { updateHeightsInViewport(cm); postUpdateDisplay(cm, update); var barMeasure = measureForScrollbars(cm); updateSelection(cm); updateScrollbars(cm, barMeasure); setDocumentHeight(cm, barMeasure); update.finish(); } } // Sync the actual display DOM structure with display.view, removing // nodes for lines that are no longer in view, and creating the ones // that are not there yet, and updating the ones that are out of // date. function patchDisplay(cm, updateNumbersFrom, dims) { var display = cm.display, lineNumbers = cm.options.lineNumbers; var container = display.lineDiv, cur = container.firstChild; function rm(node) { var next = node.nextSibling; // Works around a throw-scroll bug in OS X Webkit if (webkit && mac && cm.display.currentWheelTarget == node) { node.style.display = "none"; } else { node.parentNode.removeChild(node); } return next } var view = display.view, lineN = display.viewFrom; // Loop over the elements in the view, syncing cur (the DOM nodes // in display.lineDiv) with the view as we go. for (var i = 0; i < view.length; i++) { var lineView = view[i]; if (lineView.hidden) ; else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet var node = buildLineElement(cm, lineView, lineN, dims); container.insertBefore(node, cur); } else { // Already drawn while (cur != lineView.node) { cur = rm(cur); } var updateNumber = lineNumbers && updateNumbersFrom != null && updateNumbersFrom <= lineN && lineView.lineNumber; if (lineView.changes) { if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false; } updateLineForChanges(cm, lineView, lineN, dims); } if (updateNumber) { removeChildren(lineView.lineNumber); lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN))); } cur = lineView.node.nextSibling; } lineN += lineView.size; } while (cur) { cur = rm(cur); } } function updateGutterSpace(display) { var width = display.gutters.offsetWidth; display.sizer.style.marginLeft = width + "px"; } function setDocumentHeight(cm, measure) { cm.display.sizer.style.minHeight = measure.docHeight + "px"; cm.display.heightForcer.style.top = measure.docHeight + "px"; cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px"; } // Re-align line numbers and gutter marks to compensate for // horizontal scrolling. function alignHorizontally(cm) { var display = cm.display, view = display.view; if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) { return } var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft; var gutterW = display.gutters.offsetWidth, left = comp + "px"; for (var i = 0; i < view.length; i++) { if (!view[i].hidden) { if (cm.options.fixedGutter) { if (view[i].gutter) { view[i].gutter.style.left = left; } if (view[i].gutterBackground) { view[i].gutterBackground.style.left = left; } } var align = view[i].alignable; if (align) { for (var j = 0; j < align.length; j++) { align[j].style.left = left; } } } } if (cm.options.fixedGutter) { display.gutters.style.left = (comp + gutterW) + "px"; } } // Used to ensure that the line number gutter is still the right // size for the current document size. Returns true when an update // is needed. function maybeUpdateLineNumberWidth(cm) { if (!cm.options.lineNumbers) { return false } var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display; if (last.length != display.lineNumChars) { var test = display.measure.appendChild(elt("div", [elt("div", last)], "CodeMirror-linenumber CodeMirror-gutter-elt")); var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW; display.lineGutter.style.width = ""; display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1; display.lineNumWidth = display.lineNumInnerWidth + padding; display.lineNumChars = display.lineNumInnerWidth ? last.length : -1; display.lineGutter.style.width = display.lineNumWidth + "px"; updateGutterSpace(cm.display); return true } return false } function getGutters(gutters, lineNumbers) { var result = [], sawLineNumbers = false; for (var i = 0; i < gutters.length; i++) { var name = gutters[i], style = null; if (typeof name != "string") { style = name.style; name = name.className; } if (name == "CodeMirror-linenumbers") { if (!lineNumbers) { continue } else { sawLineNumbers = true; } } result.push({className: name, style: style}); } if (lineNumbers && !sawLineNumbers) { result.push({className: "CodeMirror-linenumbers", style: null}); } return result } // Rebuild the gutter elements, ensure the margin to the left of the // code matches their width. function renderGutters(display) { var gutters = display.gutters, specs = display.gutterSpecs; removeChildren(gutters); display.lineGutter = null; for (var i = 0; i < specs.length; ++i) { var ref = specs[i]; var className = ref.className; var style = ref.style; var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + className)); if (style) { gElt.style.cssText = style; } if (className == "CodeMirror-linenumbers") { display.lineGutter = gElt; gElt.style.width = (display.lineNumWidth || 1) + "px"; } } gutters.style.display = specs.length ? "" : "none"; updateGutterSpace(display); } function updateGutters(cm) { renderGutters(cm.display); regChange(cm); alignHorizontally(cm); } // The display handles the DOM integration, both for input reading // and content drawing. It holds references to DOM nodes and // display-related state. function Display(place, doc, input, options) { var d = this; this.input = input; // Covers bottom-right square when both scrollbars are present. d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler"); d.scrollbarFiller.setAttribute("cm-not-content", "true"); // Covers bottom of gutter when coverGutterNextToScrollbar is on // and h scrollbar is present. d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler"); d.gutterFiller.setAttribute("cm-not-content", "true"); // Will contain the actual code, positioned to cover the viewport. d.lineDiv = eltP("div", null, "CodeMirror-code"); // Elements are added to these to represent selection and cursors. d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1"); d.cursorDiv = elt("div", null, "CodeMirror-cursors"); // A visibility: hidden element used to find the size of things. d.measure = elt("div", null, "CodeMirror-measure"); // When lines outside of the viewport are measured, they are drawn in this. d.lineMeasure = elt("div", null, "CodeMirror-measure"); // Wraps everything that needs to exist inside the vertically-padded coordinate system d.lineSpace = eltP("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv], null, "position: relative; outline: none"); var lines = eltP("div", [d.lineSpace], "CodeMirror-lines"); // Moved around its parent to cover visible view. d.mover = elt("div", [lines], null, "position: relative"); // Set to the height of the document, allowing scrolling. d.sizer = elt("div", [d.mover], "CodeMirror-sizer"); d.sizerWidth = null; // Behavior of elts with overflow: auto and padding is // inconsistent across browsers. This is used to ensure the // scrollable area is big enough. d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;"); // Will contain the gutters, if any. d.gutters = elt("div", null, "CodeMirror-gutters"); d.lineGutter = null; // Actual scrollable element. d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll"); d.scroller.setAttribute("tabIndex", "-1"); // The element in which the editor lives. d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror"); // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported) if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; } if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true; } if (place) { if (place.appendChild) { place.appendChild(d.wrapper); } else { place(d.wrapper); } } // Current rendered range (may be bigger than the view window). d.viewFrom = d.viewTo = doc.first; d.reportedViewFrom = d.reportedViewTo = doc.first; // Information about the rendered lines. d.view = []; d.renderedView = null; // Holds info about a single rendered line when it was rendered // for measurement, while not in view. d.externalMeasured = null; // Empty space (in pixels) above the view d.viewOffset = 0; d.lastWrapHeight = d.lastWrapWidth = 0; d.updateLineNumbers = null; d.nativeBarWidth = d.barHeight = d.barWidth = 0; d.scrollbarsClipped = false; // Used to only resize the line number gutter when necessary (when // the amount of lines crosses a boundary that makes its width change) d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null; // Set to true when a non-horizontal-scrolling line widget is // added. As an optimization, line widget aligning is skipped when // this is false. d.alignWidgets = false; d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; // Tracks the maximum line length so that the horizontal scrollbar // can be kept static when scrolling. d.maxLine = null; d.maxLineLength = 0; d.maxLineChanged = false; // Used for measuring wheel scrolling granularity d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null; // True when shift is held down. d.shift = false; // Used to track whether anything happened since the context menu // was opened. d.selForContextMenu = null; d.activeTouch = null; d.gutterSpecs = getGutters(options.gutters, options.lineNumbers); renderGutters(d); input.init(d); } // Since the delta values reported on mouse wheel events are // unstandardized between browsers and even browser versions, and // generally horribly unpredictable, this code starts by measuring // the scroll effect that the first few mouse wheel events have, // and, from that, detects the way it can convert deltas to pixel // offsets afterwards. // // The reason we want to know the amount a wheel event will scroll // is that it gives us a chance to update the display before the // actual scrolling happens, reducing flickering. var wheelSamples = 0, wheelPixelsPerUnit = null; // Fill in a browser-detected starting value on browsers where we // know one. These don't have to be accurate -- the result of them // being wrong would just be a slight flicker on the first wheel // scroll (if it is large enough). if (ie) { wheelPixelsPerUnit = -.53; } else if (gecko) { wheelPixelsPerUnit = 15; } else if (chrome) { wheelPixelsPerUnit = -.7; } else if (safari) { wheelPixelsPerUnit = -1/3; } function wheelEventDelta(e) { var dx = e.wheelDeltaX, dy = e.wheelDeltaY; if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) { dx = e.detail; } if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) { dy = e.detail; } else if (dy == null) { dy = e.wheelDelta; } return {x: dx, y: dy} } function wheelEventPixels(e) { var delta = wheelEventDelta(e); delta.x *= wheelPixelsPerUnit; delta.y *= wheelPixelsPerUnit; return delta } function onScrollWheel(cm, e) { var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y; var display = cm.display, scroll = display.scroller; // Quit if there's nothing to scroll here var canScrollX = scroll.scrollWidth > scroll.clientWidth; var canScrollY = scroll.scrollHeight > scroll.clientHeight; if (!(dx && canScrollX || dy && canScrollY)) { return } // Webkit browsers on OS X abort momentum scrolls when the target // of the scroll event is removed from the scrollable element. // This hack (see related code in patchDisplay) makes sure the // element is kept around. if (dy && mac && webkit) { outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) { for (var i = 0; i < view.length; i++) { if (view[i].node == cur) { cm.display.currentWheelTarget = cur; break outer } } } } // On some browsers, horizontal scrolling will cause redraws to // happen before the gutter has been realigned, causing it to // wriggle around in a most unseemly way. When we have an // estimated pixels/delta value, we just handle horizontal // scrolling entirely here. It'll be slightly off from native, but // better than glitching out. if (dx && !gecko && !presto && wheelPixelsPerUnit != null) { if (dy && canScrollY) { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit)); } setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit)); // Only prevent default scrolling if vertical scrolling is // actually possible. Otherwise, it causes vertical scroll // jitter on OSX trackpads when deltaX is small and deltaY // is large (issue #3579) if (!dy || (dy && canScrollY)) { e_preventDefault(e); } display.wheelStartX = null; // Abort measurement, if in progress return } // 'Project' the visible viewport to cover the area that is being // scrolled into view (if we know enough to estimate it). if (dy && wheelPixelsPerUnit != null) { var pixels = dy * wheelPixelsPerUnit; var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight; if (pixels < 0) { top = Math.max(0, top + pixels - 50); } else { bot = Math.min(cm.doc.height, bot + pixels + 50); } updateDisplaySimple(cm, {top: top, bottom: bot}); } if (wheelSamples < 20) { if (display.wheelStartX == null) { display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop; display.wheelDX = dx; display.wheelDY = dy; setTimeout(function () { if (display.wheelStartX == null) { return } var movedX = scroll.scrollLeft - display.wheelStartX; var movedY = scroll.scrollTop - display.wheelStartY; var sample = (movedY && display.wheelDY && movedY / display.wheelDY) || (movedX && display.wheelDX && movedX / display.wheelDX); display.wheelStartX = display.wheelStartY = null; if (!sample) { return } wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1); ++wheelSamples; }, 200); } else { display.wheelDX += dx; display.wheelDY += dy; } } } // Selection objects are immutable. A new one is created every time // the selection changes. A selection is one or more non-overlapping // (and non-touching) ranges, sorted, and an integer that indicates // which one is the primary selection (the one that's scrolled into // view, that getCursor returns, etc). var Selection = function(ranges, primIndex) { this.ranges = ranges; this.primIndex = primIndex; }; Selection.prototype.primary = function () { return this.ranges[this.primIndex] }; Selection.prototype.equals = function (other) { if (other == this) { return true } if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false } for (var i = 0; i < this.ranges.length; i++) { var here = this.ranges[i], there = other.ranges[i]; if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) { return false } } return true }; Selection.prototype.deepCopy = function () { var out = []; for (var i = 0; i < this.ranges.length; i++) { out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head)); } return new Selection(out, this.primIndex) }; Selection.prototype.somethingSelected = function () { for (var i = 0; i < this.ranges.length; i++) { if (!this.ranges[i].empty()) { return true } } return false }; Selection.prototype.contains = function (pos, end) { if (!end) { end = pos; } for (var i = 0; i < this.ranges.length; i++) { var range = this.ranges[i]; if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0) { return i } } return -1 }; var Range = function(anchor, head) { this.anchor = anchor; this.head = head; }; Range.prototype.from = function () { return minPos(this.anchor, this.head) }; Range.prototype.to = function () { return maxPos(this.anchor, this.head) }; Range.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch }; // Take an unsorted, potentially overlapping set of ranges, and // build a selection out of it. 'Consumes' ranges array (modifying // it). function normalizeSelection(cm, ranges, primIndex) { var mayTouch = cm && cm.options.selectionsMayTouch; var prim = ranges[primIndex]; ranges.sort(function (a, b) { return cmp(a.from(), b.from()); }); primIndex = indexOf(ranges, prim); for (var i = 1; i < ranges.length; i++) { var cur = ranges[i], prev = ranges[i - 1]; var diff = cmp(prev.to(), cur.from()); if (mayTouch && !cur.empty() ? diff > 0 : diff >= 0) { var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to()); var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head; if (i <= primIndex) { --primIndex; } ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to)); } } return new Selection(ranges, primIndex) } function simpleSelection(anchor, head) { return new Selection([new Range(anchor, head || anchor)], 0) } // Compute the position of the end of a change (its 'to' property // refers to the pre-change end). function changeEnd(change) { if (!change.text) { return change.to } return Pos(change.from.line + change.text.length - 1, lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0)) } // Adjust a position to refer to the post-change position of the // same text, or the end of the change if the change covers it. function adjustForChange(pos, change) { if (cmp(pos, change.from) < 0) { return pos } if (cmp(pos, change.to) <= 0) { return changeEnd(change) } var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch; if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch; } return Pos(line, ch) } function computeSelAfterChange(doc, change) { var out = []; for (var i = 0; i < doc.sel.ranges.length; i++) { var range = doc.sel.ranges[i]; out.push(new Range(adjustForChange(range.anchor, change), adjustForChange(range.head, change))); } return normalizeSelection(doc.cm, out, doc.sel.primIndex) } function offsetPos(pos, old, nw) { if (pos.line == old.line) { return Pos(nw.line, pos.ch - old.ch + nw.ch) } else { return Pos(nw.line + (pos.line - old.line), pos.ch) } } // Used by replaceSelections to allow moving the selection to the // start or around the replaced test. Hint may be "start" or "around". function computeReplacedSel(doc, changes, hint) { var out = []; var oldPrev = Pos(doc.first, 0), newPrev = oldPrev; for (var i = 0; i < changes.length; i++) { var change = changes[i]; var from = offsetPos(change.from, oldPrev, newPrev); var to = offsetPos(changeEnd(change), oldPrev, newPrev); oldPrev = change.to; newPrev = to; if (hint == "around") { var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0; out[i] = new Range(inv ? to : from, inv ? from : to); } else { out[i] = new Range(from, from); } } return new Selection(out, doc.sel.primIndex) } // Used to get the editor into a consistent state again when options change. function loadMode(cm) { cm.doc.mode = getMode(cm.options, cm.doc.modeOption); resetModeState(cm); } function resetModeState(cm) { cm.doc.iter(function (line) { if (line.stateAfter) { line.stateAfter = null; } if (line.styles) { line.styles = null; } }); cm.doc.modeFrontier = cm.doc.highlightFrontier = cm.doc.first; startWorker(cm, 100); cm.state.modeGen++; if (cm.curOp) { regChange(cm); } } // DOCUMENT DATA STRUCTURE // By default, updates that start and end at the beginning of a line // are treated specially, in order to make the association of line // widgets and marker elements with the text behave more intuitive. function isWholeLineUpdate(doc, change) { return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" && (!doc.cm || doc.cm.options.wholeLineUpdateBefore) } // Perform a change on the document data structure. function updateDoc(doc, change, markedSpans, estimateHeight) { function spansFor(n) {return markedSpans ? markedSpans[n] : null} function update(line, text, spans) { updateLine(line, text, spans, estimateHeight); signalLater(line, "change", line, change); } function linesFor(start, end) { var result = []; for (var i = start; i < end; ++i) { result.push(new Line(text[i], spansFor(i), estimateHeight)); } return result } var from = change.from, to = change.to, text = change.text; var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line); var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line; // Adjust the line structure if (change.full) { doc.insert(0, linesFor(0, text.length)); doc.remove(text.length, doc.size - text.length); } else if (isWholeLineUpdate(doc, change)) { // This is a whole-line replace. Treated specially to make // sure line objects move the way they are supposed to. var added = linesFor(0, text.length - 1); update(lastLine, lastLine.text, lastSpans); if (nlines) { doc.remove(from.line, nlines); } if (added.length) { doc.insert(from.line, added); } } else if (firstLine == lastLine) { if (text.length == 1) { update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans); } else { var added$1 = linesFor(1, text.length - 1); added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight)); update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); doc.insert(from.line + 1, added$1); } } else if (text.length == 1) { update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0)); doc.remove(from.line + 1, nlines); } else { update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans); var added$2 = linesFor(1, text.length - 1); if (nlines > 1) { doc.remove(from.line + 1, nlines - 1); } doc.insert(from.line + 1, added$2); } signalLater(doc, "change", doc, change); } // Call f for all linked documents. function linkedDocs(doc, f, sharedHistOnly) { function propagate(doc, skip, sharedHist) { if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) { var rel = doc.linked[i]; if (rel.doc == skip) { continue } var shared = sharedHist && rel.sharedHist; if (sharedHistOnly && !shared) { continue } f(rel.doc, shared); propagate(rel.doc, doc, shared); } } } propagate(doc, null, true); } // Attach a document to an editor. function attachDoc(cm, doc) { if (doc.cm) { throw new Error("This document is already in use.") } cm.doc = doc; doc.cm = cm; estimateLineHeights(cm); loadMode(cm); setDirectionClass(cm); if (!cm.options.lineWrapping) { findMaxLine(cm); } cm.options.mode = doc.modeOption; regChange(cm); } function setDirectionClass(cm) { (cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl"); } function directionChanged(cm) { runInOp(cm, function () { setDirectionClass(cm); regChange(cm); }); } function History(startGen) { // Arrays of change events and selections. Doing something adds an // event to done and clears undo. Undoing moves events from done // to undone, redoing moves them in the other direction. this.done = []; this.undone = []; this.undoDepth = Infinity; // Used to track when changes can be merged into a single undo // event this.lastModTime = this.lastSelTime = 0; this.lastOp = this.lastSelOp = null; this.lastOrigin = this.lastSelOrigin = null; // Used by the isClean() method this.generation = this.maxGeneration = startGen || 1; } // Create a history change event from an updateDoc-style change // object. function historyChangeFromChange(doc, change) { var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)}; attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); linkedDocs(doc, function (doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, true); return histChange } // Pop all selection events off the end of a history array. Stop at // a change event. function clearSelectionEvents(array) { while (array.length) { var last = lst(array); if (last.ranges) { array.pop(); } else { break } } } // Find the top change event in the history. Pop off selection // events that are in the way. function lastChangeEvent(hist, force) { if (force) { clearSelectionEvents(hist.done); return lst(hist.done) } else if (hist.done.length && !lst(hist.done).ranges) { return lst(hist.done) } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) { hist.done.pop(); return lst(hist.done) } } // Register a change in the history. Merges changes that are within // a single operation, or are close together with an origin that // allows merging (starting with "+") into a single event. function addChangeToHistory(doc, change, selAfter, opId) { var hist = doc.history; hist.undone.length = 0; var time = +new Date, cur; var last; if ((hist.lastOp == opId || hist.lastOrigin == change.origin && change.origin && ((change.origin.charAt(0) == "+" && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500)) || change.origin.charAt(0) == "*")) && (cur = lastChangeEvent(hist, hist.lastOp == opId))) { // Merge this change into the last event last = lst(cur.changes); if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) { // Optimized case for simple insertion -- don't want to add // new changesets for every character typed last.to = changeEnd(change); } else { // Add new sub-event cur.changes.push(historyChangeFromChange(doc, change)); } } else { // Can not be merged, start a new event. var before = lst(hist.done); if (!before || !before.ranges) { pushSelectionToHistory(doc.sel, hist.done); } cur = {changes: [historyChangeFromChange(doc, change)], generation: hist.generation}; hist.done.push(cur); while (hist.done.length > hist.undoDepth) { hist.done.shift(); if (!hist.done[0].ranges) { hist.done.shift(); } } } hist.done.push(selAfter); hist.generation = ++hist.maxGeneration; hist.lastModTime = hist.lastSelTime = time; hist.lastOp = hist.lastSelOp = opId; hist.lastOrigin = hist.lastSelOrigin = change.origin; if (!last) { signal(doc, "historyAdded"); } } function selectionEventCanBeMerged(doc, origin, prev, sel) { var ch = origin.charAt(0); return ch == "*" || ch == "+" && prev.ranges.length == sel.ranges.length && prev.somethingSelected() == sel.somethingSelected() && new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500) } // Called whenever the selection changes, sets the new selection as // the pending selection in the history, and pushes the old pending // selection into the 'done' array when it was significantly // different (in number of selected ranges, emptiness, or time). function addSelectionToHistory(doc, sel, opId, options) { var hist = doc.history, origin = options && options.origin; // A new event is started when the previous origin does not match // the current, or the origins don't allow matching. Origins // starting with * are always merged, those starting with + are // merged when similar and close together in time. if (opId == hist.lastSelOp || (origin && hist.lastSelOrigin == origin && (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) { hist.done[hist.done.length - 1] = sel; } else { pushSelectionToHistory(sel, hist.done); } hist.lastSelTime = +new Date; hist.lastSelOrigin = origin; hist.lastSelOp = opId; if (options && options.clearRedo !== false) { clearSelectionEvents(hist.undone); } } function pushSelectionToHistory(sel, dest) { var top = lst(dest); if (!(top && top.ranges && top.equals(sel))) { dest.push(sel); } } // Used to store marked span information in the history. function attachLocalSpans(doc, change, from, to) { var existing = change["spans_" + doc.id], n = 0; doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) { if (line.markedSpans) { (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans; } ++n; }); } // When un/re-doing restores text containing marked spans, those // that have been explicitly cleared should not be restored. function removeClearedSpans(spans) { if (!spans) { return null } var out; for (var i = 0; i < spans.length; ++i) { if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i); } } else if (out) { out.push(spans[i]); } } return !out ? spans : out.length ? out : null } // Retrieve and filter the old marked spans stored in a change event. function getOldSpans(doc, change) { var found = change["spans_" + doc.id]; if (!found) { return null } var nw = []; for (var i = 0; i < change.text.length; ++i) { nw.push(removeClearedSpans(found[i])); } return nw } // Used for un/re-doing changes from the history. Combines the // result of computing the existing spans with the set of spans that // existed in the history (so that deleting around a span and then // undoing brings back the span). function mergeOldSpans(doc, change) { var old = getOldSpans(doc, change); var stretched = stretchSpansOverChange(doc, change); if (!old) { return stretched } if (!stretched) { return old } for (var i = 0; i < old.length; ++i) { var oldCur = old[i], stretchCur = stretched[i]; if (oldCur && stretchCur) { spans: for (var j = 0; j < stretchCur.length; ++j) { var span = stretchCur[j]; for (var k = 0; k < oldCur.length; ++k) { if (oldCur[k].marker == span.marker) { continue spans } } oldCur.push(span); } } else if (stretchCur) { old[i] = stretchCur; } } return old } // Used both to provide a JSON-safe object in .getHistory, and, when // detaching a document, to split the history in two function copyHistoryArray(events, newGroup, instantiateSel) { var copy = []; for (var i = 0; i < events.length; ++i) { var event = events[i]; if (event.ranges) { copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event); continue } var changes = event.changes, newChanges = []; copy.push({changes: newChanges}); for (var j = 0; j < changes.length; ++j) { var change = changes[j], m = (void 0); newChanges.push({from: change.from, to: change.to, text: change.text}); if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) { if (indexOf(newGroup, Number(m[1])) > -1) { lst(newChanges)[prop] = change[prop]; delete change[prop]; } } } } } } return copy } // The 'scroll' parameter given to many of these indicated whether // the new cursor position should be scrolled into view after // modifying the selection. // If shift is held or the extend flag is set, extends a range to // include a given position (and optionally a second position). // Otherwise, simply returns the range between the given positions. // Used for cursor motion and such. function extendRange(range, head, other, extend) { if (extend) { var anchor = range.anchor; if (other) { var posBefore = cmp(head, anchor) < 0; if (posBefore != (cmp(other, anchor) < 0)) { anchor = head; head = other; } else if (posBefore != (cmp(head, other) < 0)) { head = other; } } return new Range(anchor, head) } else { return new Range(other || head, head) } } // Extend the primary selection range, discard the rest. function extendSelection(doc, head, other, options, extend) { if (extend == null) { extend = doc.cm && (doc.cm.display.shift || doc.extend); } setSelection(doc, new Selection([extendRange(doc.sel.primary(), head, other, extend)], 0), options); } // Extend all selections (pos is an array of selections with length // equal the number of selections) function extendSelections(doc, heads, options) { var out = []; var extend = doc.cm && (doc.cm.display.shift || doc.extend); for (var i = 0; i < doc.sel.ranges.length; i++) { out[i] = extendRange(doc.sel.ranges[i], heads[i], null, extend); } var newSel = normalizeSelection(doc.cm, out, doc.sel.primIndex); setSelection(doc, newSel, options); } // Updates a single range in the selection. function replaceOneSelection(doc, i, range, options) { var ranges = doc.sel.ranges.slice(0); ranges[i] = range; setSelection(doc, normalizeSelection(doc.cm, ranges, doc.sel.primIndex), options); } // Reset the selection to a single range. function setSimpleSelection(doc, anchor, head, options) { setSelection(doc, simpleSelection(anchor, head), options); } // Give beforeSelectionChange handlers a change to influence a // selection update. function filterSelectionChange(doc, sel, options) { var obj = { ranges: sel.ranges, update: function(ranges) { this.ranges = []; for (var i = 0; i < ranges.length; i++) { this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor), clipPos(doc, ranges[i].head)); } }, origin: options && options.origin }; signal(doc, "beforeSelectionChange", doc, obj); if (doc.cm) { signal(doc.cm, "beforeSelectionChange", doc.cm, obj); } if (obj.ranges != sel.ranges) { return normalizeSelection(doc.cm, obj.ranges, obj.ranges.length - 1) } else { return sel } } function setSelectionReplaceHistory(doc, sel, options) { var done = doc.history.done, last = lst(done); if (last && last.ranges) { done[done.length - 1] = sel; setSelectionNoUndo(doc, sel, options); } else { setSelection(doc, sel, options); } } // Set a new selection. function setSelection(doc, sel, options) { setSelectionNoUndo(doc, sel, options); addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options); } function setSelectionNoUndo(doc, sel, options) { if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) { sel = filterSelectionChange(doc, sel, options); } var bias = options && options.bias || (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1); setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true)); if (!(options && options.scroll === false) && doc.cm) { ensureCursorVisible(doc.cm); } } function setSelectionInner(doc, sel) { if (sel.equals(doc.sel)) { return } doc.sel = sel; if (doc.cm) { doc.cm.curOp.updateInput = 1; doc.cm.curOp.selectionChanged = true; signalCursorActivity(doc.cm); } signalLater(doc, "cursorActivity", doc); } // Verify that the selection does not partially select any atomic // marked ranges. function reCheckSelection(doc) { setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false)); } // Return a selection that does not partially select any atomic // ranges. function skipAtomicInSelection(doc, sel, bias, mayClear) { var out; for (var i = 0; i < sel.ranges.length; i++) { var range = sel.ranges[i]; var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i]; var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear); var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear); if (out || newAnchor != range.anchor || newHead != range.head) { if (!out) { out = sel.ranges.slice(0, i); } out[i] = new Range(newAnchor, newHead); } } return out ? normalizeSelection(doc.cm, out, sel.primIndex) : sel } function skipAtomicInner(doc, pos, oldPos, dir, mayClear) { var line = getLine(doc, pos.line); if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) { var sp = line.markedSpans[i], m = sp.marker; // Determine if we should prevent the cursor being placed to the left/right of an atomic marker // Historically this was determined using the inclusiveLeft/Right option, but the new way to control it // is with selectLeft/Right var preventCursorLeft = ("selectLeft" in m) ? !m.selectLeft : m.inclusiveLeft; var preventCursorRight = ("selectRight" in m) ? !m.selectRight : m.inclusiveRight; if ((sp.from == null || (preventCursorLeft ? sp.from <= pos.ch : sp.from < pos.ch)) && (sp.to == null || (preventCursorRight ? sp.to >= pos.ch : sp.to > pos.ch))) { if (mayClear) { signal(m, "beforeCursorEnter"); if (m.explicitlyCleared) { if (!line.markedSpans) { break } else {--i; continue} } } if (!m.atomic) { continue } if (oldPos) { var near = m.find(dir < 0 ? 1 : -1), diff = (void 0); if (dir < 0 ? preventCursorRight : preventCursorLeft) { near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null); } if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0)) { return skipAtomicInner(doc, near, pos, dir, mayClear) } } var far = m.find(dir < 0 ? -1 : 1); if (dir < 0 ? preventCursorLeft : preventCursorRight) { far = movePos(doc, far, dir, far.line == pos.line ? line : null); } return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null } } } return pos } // Ensure a given position is not inside an atomic range. function skipAtomic(doc, pos, oldPos, bias, mayClear) { var dir = bias || 1; var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) || (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) || skipAtomicInner(doc, pos, oldPos, -dir, mayClear) || (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true)); if (!found) { doc.cantEdit = true; return Pos(doc.first, 0) } return found } function movePos(doc, pos, dir, line) { if (dir < 0 && pos.ch == 0) { if (pos.line > doc.first) { return clipPos(doc, Pos(pos.line - 1)) } else { return null } } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) { if (pos.line < doc.first + doc.size - 1) { return Pos(pos.line + 1, 0) } else { return null } } else { return new Pos(pos.line, pos.ch + dir) } } function selectAll(cm) { cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll); } // UPDATING // Allow "beforeChange" event handlers to influence a change function filterChange(doc, change, update) { var obj = { canceled: false, from: change.from, to: change.to, text: change.text, origin: change.origin, cancel: function () { return obj.canceled = true; } }; if (update) { obj.update = function (from, to, text, origin) { if (from) { obj.from = clipPos(doc, from); } if (to) { obj.to = clipPos(doc, to); } if (text) { obj.text = text; } if (origin !== undefined) { obj.origin = origin; } }; } signal(doc, "beforeChange", doc, obj); if (doc.cm) { signal(doc.cm, "beforeChange", doc.cm, obj); } if (obj.canceled) { if (doc.cm) { doc.cm.curOp.updateInput = 2; } return null } return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin} } // Apply a change to a document, and add it to the document's // history, and propagating it to all linked documents. function makeChange(doc, change, ignoreReadOnly) { if (doc.cm) { if (!doc.cm.curOp) { return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly) } if (doc.cm.state.suppressEdits) { return } } if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) { change = filterChange(doc, change, true); if (!change) { return } } // Possibly split or suppress the update based on the presence // of read-only spans in its range. var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to); if (split) { for (var i = split.length - 1; i >= 0; --i) { makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin}); } } else { makeChangeInner(doc, change); } } function makeChangeInner(doc, change) { if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) { return } var selAfter = computeSelAfterChange(doc, change); addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN); makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change)); var rebased = []; linkedDocs(doc, function (doc, sharedHist) { if (!sharedHist && indexOf(rebased, doc.history) == -1) { rebaseHist(doc.history, change); rebased.push(doc.history); } makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change)); }); } // Revert a change stored in a document's history. function makeChangeFromHistory(doc, type, allowSelectionOnly) { var suppress = doc.cm && doc.cm.state.suppressEdits; if (suppress && !allowSelectionOnly) { return } var hist = doc.history, event, selAfter = doc.sel; var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done; // Verify that there is a useable event (so that ctrl-z won't // needlessly clear selection events) var i = 0; for (; i < source.length; i++) { event = source[i]; if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges) { break } } if (i == source.length) { return } hist.lastOrigin = hist.lastSelOrigin = null; for (;;) { event = source.pop(); if (event.ranges) { pushSelectionToHistory(event, dest); if (allowSelectionOnly && !event.equals(doc.sel)) { setSelection(doc, event, {clearRedo: false}); return } selAfter = event; } else if (suppress) { source.push(event); return } else { break } } // Build up a reverse change object to add to the opposite history // stack (redo when undoing, and vice versa). var antiChanges = []; pushSelectionToHistory(selAfter, dest); dest.push({changes: antiChanges, generation: hist.generation}); hist.generation = event.generation || ++hist.maxGeneration; var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange"); var loop = function ( i ) { var change = event.changes[i]; change.origin = type; if (filter && !filterChange(doc, change, false)) { source.length = 0; return {} } antiChanges.push(historyChangeFromChange(doc, change)); var after = i ? computeSelAfterChange(doc, change) : lst(source); makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change)); if (!i && doc.cm) { doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}); } var rebased = []; // Propagate to the linked documents linkedDocs(doc, function (doc, sharedHist) { if (!sharedHist && indexOf(rebased, doc.history) == -1) { rebaseHist(doc.history, change); rebased.push(doc.history); } makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change)); }); }; for (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) { var returned = loop( i$1 ); if ( returned ) return returned.v; } } // Sub-views need their line numbers shifted when text is added // above or below them in the parent document. function shiftDoc(doc, distance) { if (distance == 0) { return } doc.first += distance; doc.sel = new Selection(map(doc.sel.ranges, function (range) { return new Range( Pos(range.anchor.line + distance, range.anchor.ch), Pos(range.head.line + distance, range.head.ch) ); }), doc.sel.primIndex); if (doc.cm) { regChange(doc.cm, doc.first, doc.first - distance, distance); for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++) { regLineChange(doc.cm, l, "gutter"); } } } // More lower-level change function, handling only a single document // (not linked ones). function makeChangeSingleDoc(doc, change, selAfter, spans) { if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans) } if (change.to.line < doc.first) { shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line)); return } if (change.from.line > doc.lastLine()) { return } // Clip the change to the size of this doc if (change.from.line < doc.first) { var shift = change.text.length - 1 - (doc.first - change.from.line); shiftDoc(doc, shift); change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch), text: [lst(change.text)], origin: change.origin}; } var last = doc.lastLine(); if (change.to.line > last) { change = {from: change.from, to: Pos(last, getLine(doc, last).text.length), text: [change.text[0]], origin: change.origin}; } change.removed = getBetween(doc, change.from, change.to); if (!selAfter) { selAfter = computeSelAfterChange(doc, change); } if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans); } else { updateDoc(doc, change, spans); } setSelectionNoUndo(doc, selAfter, sel_dontScroll); if (doc.cantEdit && skipAtomic(doc, Pos(doc.firstLine(), 0))) { doc.cantEdit = false; } } // Handle the interaction of a change to a document with the editor // that this document is part of. function makeChangeSingleDocInEditor(cm, change, spans) { var doc = cm.doc, display = cm.display, from = change.from, to = change.to; var recomputeMaxLength = false, checkWidthStart = from.line; if (!cm.options.lineWrapping) { checkWidthStart = lineNo(visualLine(getLine(doc, from.line))); doc.iter(checkWidthStart, to.line + 1, function (line) { if (line == display.maxLine) { recomputeMaxLength = true; return true } }); } if (doc.sel.contains(change.from, change.to) > -1) { signalCursorActivity(cm); } updateDoc(doc, change, spans, estimateHeight(cm)); if (!cm.options.lineWrapping) { doc.iter(checkWidthStart, from.line + change.text.length, function (line) { var len = lineLength(line); if (len > display.maxLineLength) { display.maxLine = line; display.maxLineLength = len; display.maxLineChanged = true; recomputeMaxLength = false; } }); if (recomputeMaxLength) { cm.curOp.updateMaxLine = true; } } retreatFrontier(doc, from.line); startWorker(cm, 400); var lendiff = change.text.length - (to.line - from.line) - 1; // Remember that these lines changed, for updating the display if (change.full) { regChange(cm); } else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change)) { regLineChange(cm, from.line, "text"); } else { regChange(cm, from.line, to.line + 1, lendiff); } var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change"); if (changeHandler || changesHandler) { var obj = { from: from, to: to, text: change.text, removed: change.removed, origin: change.origin }; if (changeHandler) { signalLater(cm, "change", cm, obj); } if (changesHandler) { (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); } } cm.display.selForContextMenu = null; } function replaceRange(doc, code, from, to, origin) { var assign; if (!to) { to = from; } if (cmp(to, from) < 0) { (assign = [to, from], from = assign[0], to = assign[1]); } if (typeof code == "string") { code = doc.splitLines(code); } makeChange(doc, {from: from, to: to, text: code, origin: origin}); } // Rebasing/resetting history to deal with externally-sourced changes function rebaseHistSelSingle(pos, from, to, diff) { if (to < pos.line) { pos.line += diff; } else if (from < pos.line) { pos.line = from; pos.ch = 0; } } // Tries to rebase an array of history events given a change in the // document. If the change touches the same lines as the event, the // event, and everything 'behind' it, is discarded. If the change is // before the event, the event's positions are updated. Uses a // copy-on-write scheme for the positions, to avoid having to // reallocate them all on every rebase, but also avoid problems with // shared position objects being unsafely updated. function rebaseHistArray(array, from, to, diff) { for (var i = 0; i < array.length; ++i) { var sub = array[i], ok = true; if (sub.ranges) { if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; } for (var j = 0; j < sub.ranges.length; j++) { rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff); rebaseHistSelSingle(sub.ranges[j].head, from, to, diff); } continue } for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) { var cur = sub.changes[j$1]; if (to < cur.from.line) { cur.from = Pos(cur.from.line + diff, cur.from.ch); cur.to = Pos(cur.to.line + diff, cur.to.ch); } else if (from <= cur.to.line) { ok = false; break } } if (!ok) { array.splice(0, i + 1); i = 0; } } } function rebaseHist(hist, change) { var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1; rebaseHistArray(hist.done, from, to, diff); rebaseHistArray(hist.undone, from, to, diff); } // Utility for applying a change to a line by handle or number, // returning the number and optionally registering the line as // changed. function changeLine(doc, handle, changeType, op) { var no = handle, line = handle; if (typeof handle == "number") { line = getLine(doc, clipLine(doc, handle)); } else { no = lineNo(handle); } if (no == null) { return null } if (op(line, no) && doc.cm) { regLineChange(doc.cm, no, changeType); } return line } // The document is represented as a BTree consisting of leaves, with // chunk of lines in them, and branches, with up to ten leaves or // other branch nodes below them. The top node is always a branch // node, and is the document object itself (meaning it has // additional methods and properties). // // All nodes have parent links. The tree is used both to go from // line numbers to line objects, and to go from objects to numbers. // It also indexes by height, and is used to convert between height // and line object, and to find the total height of the document. // // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html function LeafChunk(lines) { this.lines = lines; this.parent = null; var height = 0; for (var i = 0; i < lines.length; ++i) { lines[i].parent = this; height += lines[i].height; } this.height = height; } LeafChunk.prototype = { chunkSize: function() { return this.lines.length }, // Remove the n lines at offset 'at'. removeInner: function(at, n) { for (var i = at, e = at + n; i < e; ++i) { var line = this.lines[i]; this.height -= line.height; cleanUpLine(line); signalLater(line, "delete"); } this.lines.splice(at, n); }, // Helper used to collapse a small branch into a single leaf. collapse: function(lines) { lines.push.apply(lines, this.lines); }, // Insert the given array of lines at offset 'at', count them as // having the given height. insertInner: function(at, lines, height) { this.height += height; this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at)); for (var i = 0; i < lines.length; ++i) { lines[i].parent = this; } }, // Used to iterate over a part of the tree. iterN: function(at, n, op) { for (var e = at + n; at < e; ++at) { if (op(this.lines[at])) { return true } } } }; function BranchChunk(children) { this.children = children; var size = 0, height = 0; for (var i = 0; i < children.length; ++i) { var ch = children[i]; size += ch.chunkSize(); height += ch.height; ch.parent = this; } this.size = size; this.height = height; this.parent = null; } BranchChunk.prototype = { chunkSize: function() { return this.size }, removeInner: function(at, n) { this.size -= n; for (var i = 0; i < this.children.length; ++i) { var child = this.children[i], sz = child.chunkSize(); if (at < sz) { var rm = Math.min(n, sz - at), oldHeight = child.height; child.removeInner(at, rm); this.height -= oldHeight - child.height; if (sz == rm) { this.children.splice(i--, 1); child.parent = null; } if ((n -= rm) == 0) { break } at = 0; } else { at -= sz; } } // If the result is smaller than 25 lines, ensure that it is a // single leaf node. if (this.size - n < 25 && (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) { var lines = []; this.collapse(lines); this.children = [new LeafChunk(lines)]; this.children[0].parent = this; } }, collapse: function(lines) { for (var i = 0; i < this.children.length; ++i) { this.children[i].collapse(lines); } }, insertInner: function(at, lines, height) { this.size += lines.length; this.height += height; for (var i = 0; i < this.children.length; ++i) { var child = this.children[i], sz = child.chunkSize(); if (at <= sz) { child.insertInner(at, lines, height); if (child.lines && child.lines.length > 50) { // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced. // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest. var remaining = child.lines.length % 25 + 25; for (var pos = remaining; pos < child.lines.length;) { var leaf = new LeafChunk(child.lines.slice(pos, pos += 25)); child.height -= leaf.height; this.children.splice(++i, 0, leaf); leaf.parent = this; } child.lines = child.lines.slice(0, remaining); this.maybeSpill(); } break } at -= sz; } }, // When a node has grown, check whether it should be split. maybeSpill: function() { if (this.children.length <= 10) { return } var me = this; do { var spilled = me.children.splice(me.children.length - 5, 5); var sibling = new BranchChunk(spilled); if (!me.parent) { // Become the parent node var copy = new BranchChunk(me.children); copy.parent = me; me.children = [copy, sibling]; me = copy; } else { me.size -= sibling.size; me.height -= sibling.height; var myIndex = indexOf(me.parent.children, me); me.parent.children.splice(myIndex + 1, 0, sibling); } sibling.parent = me.parent; } while (me.children.length > 10) me.parent.maybeSpill(); }, iterN: function(at, n, op) { for (var i = 0; i < this.children.length; ++i) { var child = this.children[i], sz = child.chunkSize(); if (at < sz) { var used = Math.min(n, sz - at); if (child.iterN(at, used, op)) { return true } if ((n -= used) == 0) { break } at = 0; } else { at -= sz; } } } }; // Line widgets are block elements displayed above or below a line. var LineWidget = function(doc, node, options) { if (options) { for (var opt in options) { if (options.hasOwnProperty(opt)) { this[opt] = options[opt]; } } } this.doc = doc; this.node = node; }; LineWidget.prototype.clear = function () { var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line); if (no == null || !ws) { return } for (var i = 0; i < ws.length; ++i) { if (ws[i] == this) { ws.splice(i--, 1); } } if (!ws.length) { line.widgets = null; } var height = widgetHeight(this); updateLineHeight(line, Math.max(0, line.height - height)); if (cm) { runInOp(cm, function () { adjustScrollWhenAboveVisible(cm, line, -height); regLineChange(cm, no, "widget"); }); signalLater(cm, "lineWidgetCleared", cm, this, no); } }; LineWidget.prototype.changed = function () { var this$1 = this; var oldH = this.height, cm = this.doc.cm, line = this.line; this.height = null; var diff = widgetHeight(this) - oldH; if (!diff) { return } if (!lineIsHidden(this.doc, line)) { updateLineHeight(line, line.height + diff); } if (cm) { runInOp(cm, function () { cm.curOp.forceUpdate = true; adjustScrollWhenAboveVisible(cm, line, diff); signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line)); }); } }; eventMixin(LineWidget); function adjustScrollWhenAboveVisible(cm, line, diff) { if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop)) { addToScrollTop(cm, diff); } } function addLineWidget(doc, handle, node, options) { var widget = new LineWidget(doc, node, options); var cm = doc.cm; if (cm && widget.noHScroll) { cm.display.alignWidgets = true; } changeLine(doc, handle, "widget", function (line) { var widgets = line.widgets || (line.widgets = []); if (widget.insertAt == null) { widgets.push(widget); } else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); } widget.line = line; if (cm && !lineIsHidden(doc, line)) { var aboveVisible = heightAtLine(line) < doc.scrollTop; updateLineHeight(line, line.height + widgetHeight(widget)); if (aboveVisible) { addToScrollTop(cm, widget.height); } cm.curOp.forceUpdate = true; } return true }); if (cm) { signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle)); } return widget } // TEXTMARKERS // Created with markText and setBookmark methods. A TextMarker is a // handle that can be used to clear or find a marked position in the // document. Line objects hold arrays (markedSpans) containing // {from, to, marker} object pointing to such marker objects, and // indicating that such a marker is present on that line. Multiple // lines may point to the same marker when it spans across lines. // The spans will have null for their from/to properties when the // marker continues beyond the start/end of the line. Markers have // links back to the lines they currently touch. // Collapsed markers have unique ids, in order to be able to order // them, which is needed for uniquely determining an outer marker // when they overlap (they may nest, but not partially overlap). var nextMarkerId = 0; var TextMarker = function(doc, type) { this.lines = []; this.type = type; this.doc = doc; this.id = ++nextMarkerId; }; // Clear the marker. TextMarker.prototype.clear = function () { if (this.explicitlyCleared) { return } var cm = this.doc.cm, withOp = cm && !cm.curOp; if (withOp) { startOperation(cm); } if (hasHandler(this, "clear")) { var found = this.find(); if (found) { signalLater(this, "clear", found.from, found.to); } } var min = null, max = null; for (var i = 0; i < this.lines.length; ++i) { var line = this.lines[i]; var span = getMarkedSpanFor(line.markedSpans, this); if (cm && !this.collapsed) { regLineChange(cm, lineNo(line), "text"); } else if (cm) { if (span.to != null) { max = lineNo(line); } if (span.from != null) { min = lineNo(line); } } line.markedSpans = removeMarkedSpan(line.markedSpans, span); if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm) { updateLineHeight(line, textHeight(cm.display)); } } if (cm && this.collapsed && !cm.options.lineWrapping) { for (var i$1 = 0; i$1 < this.lines.length; ++i$1) { var visual = visualLine(this.lines[i$1]), len = lineLength(visual); if (len > cm.display.maxLineLength) { cm.display.maxLine = visual; cm.display.maxLineLength = len; cm.display.maxLineChanged = true; } } } if (min != null && cm && this.collapsed) { regChange(cm, min, max + 1); } this.lines.length = 0; this.explicitlyCleared = true; if (this.atomic && this.doc.cantEdit) { this.doc.cantEdit = false; if (cm) { reCheckSelection(cm.doc); } } if (cm) { signalLater(cm, "markerCleared", cm, this, min, max); } if (withOp) { endOperation(cm); } if (this.parent) { this.parent.clear(); } }; // Find the position of the marker in the document. Returns a {from, // to} object by default. Side can be passed to get a specific side // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the // Pos objects returned contain a line object, rather than a line // number (used to prevent looking up the same line twice). TextMarker.prototype.find = function (side, lineObj) { if (side == null && this.type == "bookmark") { side = 1; } var from, to; for (var i = 0; i < this.lines.length; ++i) { var line = this.lines[i]; var span = getMarkedSpanFor(line.markedSpans, this); if (span.from != null) { from = Pos(lineObj ? line : lineNo(line), span.from); if (side == -1) { return from } } if (span.to != null) { to = Pos(lineObj ? line : lineNo(line), span.to); if (side == 1) { return to } } } return from && {from: from, to: to} }; // Signals that the marker's widget changed, and surrounding layout // should be recomputed. TextMarker.prototype.changed = function () { var this$1 = this; var pos = this.find(-1, true), widget = this, cm = this.doc.cm; if (!pos || !cm) { return } runInOp(cm, function () { var line = pos.line, lineN = lineNo(pos.line); var view = findViewForLine(cm, lineN); if (view) { clearLineMeasurementCacheFor(view); cm.curOp.selectionChanged = cm.curOp.forceUpdate = true; } cm.curOp.updateMaxLine = true; if (!lineIsHidden(widget.doc, line) && widget.height != null) { var oldHeight = widget.height; widget.height = null; var dHeight = widgetHeight(widget) - oldHeight; if (dHeight) { updateLineHeight(line, line.height + dHeight); } } signalLater(cm, "markerChanged", cm, this$1); }); }; TextMarker.prototype.attachLine = function (line) { if (!this.lines.length && this.doc.cm) { var op = this.doc.cm.curOp; if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1) { (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this); } } this.lines.push(line); }; TextMarker.prototype.detachLine = function (line) { this.lines.splice(indexOf(this.lines, line), 1); if (!this.lines.length && this.doc.cm) { var op = this.doc.cm.curOp ;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this); } }; eventMixin(TextMarker); // Create a marker, wire it up to the right lines, and function markText(doc, from, to, options, type) { // Shared markers (across linked documents) are handled separately // (markTextShared will call out to this again, once per // document). if (options && options.shared) { return markTextShared(doc, from, to, options, type) } // Ensure we are in an operation. if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, markText)(doc, from, to, options, type) } var marker = new TextMarker(doc, type), diff = cmp(from, to); if (options) { copyObj(options, marker, false); } // Don't connect empty markers unless clearWhenEmpty is false if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false) { return marker } if (marker.replacedWith) { // Showing up as a widget implies collapsed (widget replaces text) marker.collapsed = true; marker.widgetNode = eltP("span", [marker.replacedWith], "CodeMirror-widget"); if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true"); } if (options.insertLeft) { marker.widgetNode.insertLeft = true; } } if (marker.collapsed) { if (conflictingCollapsedRange(doc, from.line, from, to, marker) || from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker)) { throw new Error("Inserting collapsed marker partially overlapping an existing one") } seeCollapsedSpans(); } if (marker.addToHistory) { addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN); } var curLine = from.line, cm = doc.cm, updateMaxLine; doc.iter(curLine, to.line + 1, function (line) { if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine) { updateMaxLine = true; } if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0); } addMarkedSpan(line, new MarkedSpan(marker, curLine == from.line ? from.ch : null, curLine == to.line ? to.ch : null)); ++curLine; }); // lineIsHidden depends on the presence of the spans, so needs a second pass if (marker.collapsed) { doc.iter(from.line, to.line + 1, function (line) { if (lineIsHidden(doc, line)) { updateLineHeight(line, 0); } }); } if (marker.clearOnEnter) { on(marker, "beforeCursorEnter", function () { return marker.clear(); }); } if (marker.readOnly) { seeReadOnlySpans(); if (doc.history.done.length || doc.history.undone.length) { doc.clearHistory(); } } if (marker.collapsed) { marker.id = ++nextMarkerId; marker.atomic = true; } if (cm) { // Sync editor state if (updateMaxLine) { cm.curOp.updateMaxLine = true; } if (marker.collapsed) { regChange(cm, from.line, to.line + 1); } else if (marker.className || marker.startStyle || marker.endStyle || marker.css || marker.attributes || marker.title) { for (var i = from.line; i <= to.line; i++) { regLineChange(cm, i, "text"); } } if (marker.atomic) { reCheckSelection(cm.doc); } signalLater(cm, "markerAdded", cm, marker); } return marker } // SHARED TEXTMARKERS // A shared marker spans multiple linked documents. It is // implemented as a meta-marker-object controlling multiple normal // markers. var SharedTextMarker = function(markers, primary) { this.markers = markers; this.primary = primary; for (var i = 0; i < markers.length; ++i) { markers[i].parent = this; } }; SharedTextMarker.prototype.clear = function () { if (this.explicitlyCleared) { return } this.explicitlyCleared = true; for (var i = 0; i < this.markers.length; ++i) { this.markers[i].clear(); } signalLater(this, "clear"); }; SharedTextMarker.prototype.find = function (side, lineObj) { return this.primary.find(side, lineObj) }; eventMixin(SharedTextMarker); function markTextShared(doc, from, to, options, type) { options = copyObj(options); options.shared = false; var markers = [markText(doc, from, to, options, type)], primary = markers[0]; var widget = options.widgetNode; linkedDocs(doc, function (doc) { if (widget) { options.widgetNode = widget.cloneNode(true); } markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type)); for (var i = 0; i < doc.linked.length; ++i) { if (doc.linked[i].isParent) { return } } primary = lst(markers); }); return new SharedTextMarker(markers, primary) } function findSharedMarkers(doc) { return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) { return m.parent; }) } function copySharedMarkers(doc, markers) { for (var i = 0; i < markers.length; i++) { var marker = markers[i], pos = marker.find(); var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to); if (cmp(mFrom, mTo)) { var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type); marker.markers.push(subMark); subMark.parent = marker; } } } function detachSharedMarkers(markers) { var loop = function ( i ) { var marker = markers[i], linked = [marker.primary.doc]; linkedDocs(marker.primary.doc, function (d) { return linked.push(d); }); for (var j = 0; j < marker.markers.length; j++) { var subMarker = marker.markers[j]; if (indexOf(linked, subMarker.doc) == -1) { subMarker.parent = null; marker.markers.splice(j--, 1); } } }; for (var i = 0; i < markers.length; i++) loop( i ); } var nextDocId = 0; var Doc = function(text, mode, firstLine, lineSep, direction) { if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep, direction) } if (firstLine == null) { firstLine = 0; } BranchChunk.call(this, [new LeafChunk([new Line("", null)])]); this.first = firstLine; this.scrollTop = this.scrollLeft = 0; this.cantEdit = false; this.cleanGeneration = 1; this.modeFrontier = this.highlightFrontier = firstLine; var start = Pos(firstLine, 0); this.sel = simpleSelection(start); this.history = new History(null); this.id = ++nextDocId; this.modeOption = mode; this.lineSep = lineSep; this.direction = (direction == "rtl") ? "rtl" : "ltr"; this.extend = false; if (typeof text == "string") { text = this.splitLines(text); } updateDoc(this, {from: start, to: start, text: text}); setSelection(this, simpleSelection(start), sel_dontScroll); }; Doc.prototype = createObj(BranchChunk.prototype, { constructor: Doc, // Iterate over the document. Supports two forms -- with only one // argument, it calls that for each line in the document. With // three, it iterates over the range given by the first two (with // the second being non-inclusive). iter: function(from, to, op) { if (op) { this.iterN(from - this.first, to - from, op); } else { this.iterN(this.first, this.first + this.size, from); } }, // Non-public interface for adding and removing lines. insert: function(at, lines) { var height = 0; for (var i = 0; i < lines.length; ++i) { height += lines[i].height; } this.insertInner(at - this.first, lines, height); }, remove: function(at, n) { this.removeInner(at - this.first, n); }, // From here, the methods are part of the public interface. Most // are also available from CodeMirror (editor) instances. getValue: function(lineSep) { var lines = getLines(this, this.first, this.first + this.size); if (lineSep === false) { return lines } return lines.join(lineSep || this.lineSeparator()) }, setValue: docMethodOp(function(code) { var top = Pos(this.first, 0), last = this.first + this.size - 1; makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length), text: this.splitLines(code), origin: "setValue", full: true}, true); if (this.cm) { scrollToCoords(this.cm, 0, 0); } setSelection(this, simpleSelection(top), sel_dontScroll); }), replaceRange: function(code, from, to, origin) { from = clipPos(this, from); to = to ? clipPos(this, to) : from; replaceRange(this, code, from, to, origin); }, getRange: function(from, to, lineSep) { var lines = getBetween(this, clipPos(this, from), clipPos(this, to)); if (lineSep === false) { return lines } return lines.join(lineSep || this.lineSeparator()) }, getLine: function(line) {var l = this.getLineHandle(line); return l && l.text}, getLineHandle: function(line) {if (isLine(this, line)) { return getLine(this, line) }}, getLineNumber: function(line) {return lineNo(line)}, getLineHandleVisualStart: function(line) { if (typeof line == "number") { line = getLine(this, line); } return visualLine(line) }, lineCount: function() {return this.size}, firstLine: function() {return this.first}, lastLine: function() {return this.first + this.size - 1}, clipPos: function(pos) {return clipPos(this, pos)}, getCursor: function(start) { var range = this.sel.primary(), pos; if (start == null || start == "head") { pos = range.head; } else if (start == "anchor") { pos = range.anchor; } else if (start == "end" || start == "to" || start === false) { pos = range.to(); } else { pos = range.from(); } return pos }, listSelections: function() { return this.sel.ranges }, somethingSelected: function() {return this.sel.somethingSelected()}, setCursor: docMethodOp(function(line, ch, options) { setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options); }), setSelection: docMethodOp(function(anchor, head, options) { setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options); }), extendSelection: docMethodOp(function(head, other, options) { extendSelection(this, clipPos(this, head), other && clipPos(this, other), options); }), extendSelections: docMethodOp(function(heads, options) { extendSelections(this, clipPosArray(this, heads), options); }), extendSelectionsBy: docMethodOp(function(f, options) { var heads = map(this.sel.ranges, f); extendSelections(this, clipPosArray(this, heads), options); }), setSelections: docMethodOp(function(ranges, primary, options) { if (!ranges.length) { return } var out = []; for (var i = 0; i < ranges.length; i++) { out[i] = new Range(clipPos(this, ranges[i].anchor), clipPos(this, ranges[i].head)); } if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex); } setSelection(this, normalizeSelection(this.cm, out, primary), options); }), addSelection: docMethodOp(function(anchor, head, options) { var ranges = this.sel.ranges.slice(0); ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor))); setSelection(this, normalizeSelection(this.cm, ranges, ranges.length - 1), options); }), getSelection: function(lineSep) { var ranges = this.sel.ranges, lines; for (var i = 0; i < ranges.length; i++) { var sel = getBetween(this, ranges[i].from(), ranges[i].to()); lines = lines ? lines.concat(sel) : sel; } if (lineSep === false) { return lines } else { return lines.join(lineSep || this.lineSeparator()) } }, getSelections: function(lineSep) { var parts = [], ranges = this.sel.ranges; for (var i = 0; i < ranges.length; i++) { var sel = getBetween(this, ranges[i].from(), ranges[i].to()); if (lineSep !== false) { sel = sel.join(lineSep || this.lineSeparator()); } parts[i] = sel; } return parts }, replaceSelection: function(code, collapse, origin) { var dup = []; for (var i = 0; i < this.sel.ranges.length; i++) { dup[i] = code; } this.replaceSelections(dup, collapse, origin || "+input"); }, replaceSelections: docMethodOp(function(code, collapse, origin) { var changes = [], sel = this.sel; for (var i = 0; i < sel.ranges.length; i++) { var range = sel.ranges[i]; changes[i] = {from: range.from(), to: range.to(), text: this.splitLines(code[i]), origin: origin}; } var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse); for (var i$1 = changes.length - 1; i$1 >= 0; i$1--) { makeChange(this, changes[i$1]); } if (newSel) { setSelectionReplaceHistory(this, newSel); } else if (this.cm) { ensureCursorVisible(this.cm); } }), undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}), redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}), undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}), redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}), setExtending: function(val) {this.extend = val;}, getExtending: function() {return this.extend}, historySize: function() { var hist = this.history, done = 0, undone = 0; for (var i = 0; i < hist.done.length; i++) { if (!hist.done[i].ranges) { ++done; } } for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone; } } return {undo: done, redo: undone} }, clearHistory: function() { var this$1 = this; this.history = new History(this.history.maxGeneration); linkedDocs(this, function (doc) { return doc.history = this$1.history; }, true); }, markClean: function() { this.cleanGeneration = this.changeGeneration(true); }, changeGeneration: function(forceSplit) { if (forceSplit) { this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null; } return this.history.generation }, isClean: function (gen) { return this.history.generation == (gen || this.cleanGeneration) }, getHistory: function() { return {done: copyHistoryArray(this.history.done), undone: copyHistoryArray(this.history.undone)} }, setHistory: function(histData) { var hist = this.history = new History(this.history.maxGeneration); hist.done = copyHistoryArray(histData.done.slice(0), null, true); hist.undone = copyHistoryArray(histData.undone.slice(0), null, true); }, setGutterMarker: docMethodOp(function(line, gutterID, value) { return changeLine(this, line, "gutter", function (line) { var markers = line.gutterMarkers || (line.gutterMarkers = {}); markers[gutterID] = value; if (!value && isEmpty(markers)) { line.gutterMarkers = null; } return true }) }), clearGutter: docMethodOp(function(gutterID) { var this$1 = this; this.iter(function (line) { if (line.gutterMarkers && line.gutterMarkers[gutterID]) { changeLine(this$1, line, "gutter", function () { line.gutterMarkers[gutterID] = null; if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null; } return true }); } }); }), lineInfo: function(line) { var n; if (typeof line == "number") { if (!isLine(this, line)) { return null } n = line; line = getLine(this, line); if (!line) { return null } } else { n = lineNo(line); if (n == null) { return null } } return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers, textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass, widgets: line.widgets} }, addLineClass: docMethodOp(function(handle, where, cls) { return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) { var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : where == "gutter" ? "gutterClass" : "wrapClass"; if (!line[prop]) { line[prop] = cls; } else if (classTest(cls).test(line[prop])) { return false } else { line[prop] += " " + cls; } return true }) }), removeLineClass: docMethodOp(function(handle, where, cls) { return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) { var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : where == "gutter" ? "gutterClass" : "wrapClass"; var cur = line[prop]; if (!cur) { return false } else if (cls == null) { line[prop] = null; } else { var found = cur.match(classTest(cls)); if (!found) { return false } var end = found.index + found[0].length; line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null; } return true }) }), addLineWidget: docMethodOp(function(handle, node, options) { return addLineWidget(this, handle, node, options) }), removeLineWidget: function(widget) { widget.clear(); }, markText: function(from, to, options) { return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range") }, setBookmark: function(pos, options) { var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options), insertLeft: options && options.insertLeft, clearWhenEmpty: false, shared: options && options.shared, handleMouseEvents: options && options.handleMouseEvents}; pos = clipPos(this, pos); return markText(this, pos, pos, realOpts, "bookmark") }, findMarksAt: function(pos) { pos = clipPos(this, pos); var markers = [], spans = getLine(this, pos.line).markedSpans; if (spans) { for (var i = 0; i < spans.length; ++i) { var span = spans[i]; if ((span.from == null || span.from <= pos.ch) && (span.to == null || span.to >= pos.ch)) { markers.push(span.marker.parent || span.marker); } } } return markers }, findMarks: function(from, to, filter) { from = clipPos(this, from); to = clipPos(this, to); var found = [], lineNo = from.line; this.iter(from.line, to.line + 1, function (line) { var spans = line.markedSpans; if (spans) { for (var i = 0; i < spans.length; i++) { var span = spans[i]; if (!(span.to != null && lineNo == from.line && from.ch >= span.to || span.from == null && lineNo != from.line || span.from != null && lineNo == to.line && span.from >= to.ch) && (!filter || filter(span.marker))) { found.push(span.marker.parent || span.marker); } } } ++lineNo; }); return found }, getAllMarks: function() { var markers = []; this.iter(function (line) { var sps = line.markedSpans; if (sps) { for (var i = 0; i < sps.length; ++i) { if (sps[i].from != null) { markers.push(sps[i].marker); } } } }); return markers }, posFromIndex: function(off) { var ch, lineNo = this.first, sepSize = this.lineSeparator().length; this.iter(function (line) { var sz = line.text.length + sepSize; if (sz > off) { ch = off; return true } off -= sz; ++lineNo; }); return clipPos(this, Pos(lineNo, ch)) }, indexFromPos: function (coords) { coords = clipPos(this, coords); var index = coords.ch; if (coords.line < this.first || coords.ch < 0) { return 0 } var sepSize = this.lineSeparator().length; this.iter(this.first, coords.line, function (line) { // iter aborts when callback returns a truthy value index += line.text.length + sepSize; }); return index }, copy: function(copyHistory) { var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first, this.lineSep, this.direction); doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft; doc.sel = this.sel; doc.extend = false; if (copyHistory) { doc.history.undoDepth = this.history.undoDepth; doc.setHistory(this.getHistory()); } return doc }, linkedDoc: function(options) { if (!options) { options = {}; } var from = this.first, to = this.first + this.size; if (options.from != null && options.from > from) { from = options.from; } if (options.to != null && options.to < to) { to = options.to; } var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction); if (options.sharedHist) { copy.history = this.history ; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist}); copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}]; copySharedMarkers(copy, findSharedMarkers(this)); return copy }, unlinkDoc: function(other) { if (other instanceof CodeMirror) { other = other.doc; } if (this.linked) { for (var i = 0; i < this.linked.length; ++i) { var link = this.linked[i]; if (link.doc != other) { continue } this.linked.splice(i, 1); other.unlinkDoc(this); detachSharedMarkers(findSharedMarkers(this)); break } } // If the histories were shared, split them again if (other.history == this.history) { var splitIds = [other.id]; linkedDocs(other, function (doc) { return splitIds.push(doc.id); }, true); other.history = new History(null); other.history.done = copyHistoryArray(this.history.done, splitIds); other.history.undone = copyHistoryArray(this.history.undone, splitIds); } }, iterLinkedDocs: function(f) {linkedDocs(this, f);}, getMode: function() {return this.mode}, getEditor: function() {return this.cm}, splitLines: function(str) { if (this.lineSep) { return str.split(this.lineSep) } return splitLinesAuto(str) }, lineSeparator: function() { return this.lineSep || "\n" }, setDirection: docMethodOp(function (dir) { if (dir != "rtl") { dir = "ltr"; } if (dir == this.direction) { return } this.direction = dir; this.iter(function (line) { return line.order = null; }); if (this.cm) { directionChanged(this.cm); } }) }); // Public alias. Doc.prototype.eachLine = Doc.prototype.iter; // Kludge to work around strange IE behavior where it'll sometimes // re-fire a series of drag-related events right after the drop (#1551) var lastDrop = 0; function onDrop(e) { var cm = this; clearDragCursor(cm); if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return } e_preventDefault(e); if (ie) { lastDrop = +new Date; } var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files; if (!pos || cm.isReadOnly()) { return } // Might be a file drop, in which case we simply extract the text // and insert it. if (files && files.length && window.FileReader && window.File) { var n = files.length, text = Array(n), read = 0; var markAsReadAndPasteIfAllFilesAreRead = function () { if (++read == n) { operation(cm, function () { pos = clipPos(cm.doc, pos); var change = {from: pos, to: pos, text: cm.doc.splitLines( text.filter(function (t) { return t != null; }).join(cm.doc.lineSeparator())), origin: "paste"}; makeChange(cm.doc, change); setSelectionReplaceHistory(cm.doc, simpleSelection(clipPos(cm.doc, pos), clipPos(cm.doc, changeEnd(change)))); })(); } }; var readTextFromFile = function (file, i) { if (cm.options.allowDropFileTypes && indexOf(cm.options.allowDropFileTypes, file.type) == -1) { markAsReadAndPasteIfAllFilesAreRead(); return } var reader = new FileReader; reader.onerror = function () { return markAsReadAndPasteIfAllFilesAreRead(); }; reader.onload = function () { var content = reader.result; if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { markAsReadAndPasteIfAllFilesAreRead(); return } text[i] = content; markAsReadAndPasteIfAllFilesAreRead(); }; reader.readAsText(file); }; for (var i = 0; i < files.length; i++) { readTextFromFile(files[i], i); } } else { // Normal drop // Don't do a replace if the drop happened inside of the selected text. if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) { cm.state.draggingText(e); // Ensure the editor is re-focused setTimeout(function () { return cm.display.input.focus(); }, 20); return } try { var text$1 = e.dataTransfer.getData("Text"); if (text$1) { var selected; if (cm.state.draggingText && !cm.state.draggingText.copy) { selected = cm.listSelections(); } setSelectionNoUndo(cm.doc, simpleSelection(pos, pos)); if (selected) { for (var i$1 = 0; i$1 < selected.length; ++i$1) { replaceRange(cm.doc, "", selected[i$1].anchor, selected[i$1].head, "drag"); } } cm.replaceSelection(text$1, "around", "paste"); cm.display.input.focus(); } } catch(e$1){} } } function onDragStart(cm, e) { if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return } if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return } e.dataTransfer.setData("Text", cm.getSelection()); e.dataTransfer.effectAllowed = "copyMove"; // Use dummy image instead of default browsers image. // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there. if (e.dataTransfer.setDragImage && !safari) { var img = elt("img", null, null, "position: fixed; left: 0; top: 0;"); img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; if (presto) { img.width = img.height = 1; cm.display.wrapper.appendChild(img); // Force a relayout, or Opera won't use our image for some obscure reason img._top = img.offsetTop; } e.dataTransfer.setDragImage(img, 0, 0); if (presto) { img.parentNode.removeChild(img); } } } function onDragOver(cm, e) { var pos = posFromMouse(cm, e); if (!pos) { return } var frag = document.createDocumentFragment(); drawSelectionCursor(cm, pos, frag); if (!cm.display.dragCursor) { cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors"); cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv); } removeChildrenAndAdd(cm.display.dragCursor, frag); } function clearDragCursor(cm) { if (cm.display.dragCursor) { cm.display.lineSpace.removeChild(cm.display.dragCursor); cm.display.dragCursor = null; } } // These must be handled carefully, because naively registering a // handler for each editor will cause the editors to never be // garbage collected. function forEachCodeMirror(f) { if (!document.getElementsByClassName) { return } var byClass = document.getElementsByClassName("CodeMirror"), editors = []; for (var i = 0; i < byClass.length; i++) { var cm = byClass[i].CodeMirror; if (cm) { editors.push(cm); } } if (editors.length) { editors[0].operation(function () { for (var i = 0; i < editors.length; i++) { f(editors[i]); } }); } } var globalsRegistered = false; function ensureGlobalHandlers() { if (globalsRegistered) { return } registerGlobalHandlers(); globalsRegistered = true; } function registerGlobalHandlers() { // When the window resizes, we need to refresh active editors. var resizeTimer; on(window, "resize", function () { if (resizeTimer == null) { resizeTimer = setTimeout(function () { resizeTimer = null; forEachCodeMirror(onResize); }, 100); } }); // When the window loses focus, we want to show the editor as blurred on(window, "blur", function () { return forEachCodeMirror(onBlur); }); } // Called when the window resizes function onResize(cm) { var d = cm.display; // Might be a text scaling operation, clear size caches. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; d.scrollbarsClipped = false; cm.setSize(); } var keyNames = { 3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 145: "ScrollLock", 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete", 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert" }; // Number keys for (var i = 0; i < 10; i++) { keyNames[i + 48] = keyNames[i + 96] = String(i); } // Alphabetic keys for (var i$1 = 65; i$1 <= 90; i$1++) { keyNames[i$1] = String.fromCharCode(i$1); } // Function keys for (var i$2 = 1; i$2 <= 12; i$2++) { keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2; } var keyMap = {}; keyMap.basic = { "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown", "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown", "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore", "Tab": "defaultTab", "Shift-Tab": "indentAuto", "Enter": "newlineAndIndent", "Insert": "toggleOverwrite", "Esc": "singleSelection" }; // Note that the save and find-related commands aren't defined by // default. User code or addons can define them. Unknown commands // are simply ignored. keyMap.pcDefault = { "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo", "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown", "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd", "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find", "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll", "Ctrl-[": "indentLess", "Ctrl-]": "indentMore", "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection", "fallthrough": "basic" }; // Very basic readline/emacs-style bindings, which are standard on Mac. keyMap.emacsy = { "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown", "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars", "Ctrl-O": "openLine" }; keyMap.macDefault = { "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo", "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft", "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore", "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find", "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll", "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight", "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd", "fallthrough": ["basic", "emacsy"] }; keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault; // KEYMAP DISPATCH function normalizeKeyName(name) { var parts = name.split(/-(?!$)/); name = parts[parts.length - 1]; var alt, ctrl, shift, cmd; for (var i = 0; i < parts.length - 1; i++) { var mod = parts[i]; if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true; } else if (/^a(lt)?$/i.test(mod)) { alt = true; } else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true; } else if (/^s(hift)?$/i.test(mod)) { shift = true; } else { throw new Error("Unrecognized modifier name: " + mod) } } if (alt) { name = "Alt-" + name; } if (ctrl) { name = "Ctrl-" + name; } if (cmd) { name = "Cmd-" + name; } if (shift) { name = "Shift-" + name; } return name } // This is a kludge to keep keymaps mostly working as raw objects // (backwards compatibility) while at the same time support features // like normalization and multi-stroke key bindings. It compiles a // new normalized keymap, and then updates the old object to reflect // this. function normalizeKeyMap(keymap) { var copy = {}; for (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) { var value = keymap[keyname]; if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue } if (value == "...") { delete keymap[keyname]; continue } var keys = map(keyname.split(" "), normalizeKeyName); for (var i = 0; i < keys.length; i++) { var val = (void 0), name = (void 0); if (i == keys.length - 1) { name = keys.join(" "); val = value; } else { name = keys.slice(0, i + 1).join(" "); val = "..."; } var prev = copy[name]; if (!prev) { copy[name] = val; } else if (prev != val) { throw new Error("Inconsistent bindings for " + name) } } delete keymap[keyname]; } } for (var prop in copy) { keymap[prop] = copy[prop]; } return keymap } function lookupKey(key, map, handle, context) { map = getKeyMap(map); var found = map.call ? map.call(key, context) : map[key]; if (found === false) { return "nothing" } if (found === "...") { return "multi" } if (found != null && handle(found)) { return "handled" } if (map.fallthrough) { if (Object.prototype.toString.call(map.fallthrough) != "[object Array]") { return lookupKey(key, map.fallthrough, handle, context) } for (var i = 0; i < map.fallthrough.length; i++) { var result = lookupKey(key, map.fallthrough[i], handle, context); if (result) { return result } } } } // Modifier key presses don't count as 'real' key presses for the // purpose of keymap fallthrough. function isModifierKey(value) { var name = typeof value == "string" ? value : keyNames[value.keyCode]; return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod" } function addModifierNames(name, event, noShift) { var base = name; if (event.altKey && base != "Alt") { name = "Alt-" + name; } if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") { name = "Ctrl-" + name; } if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") { name = "Cmd-" + name; } if (!noShift && event.shiftKey && base != "Shift") { name = "Shift-" + name; } return name } // Look up the name of a key as indicated by an event object. function keyName(event, noShift) { if (presto && event.keyCode == 34 && event["char"]) { return false } var name = keyNames[event.keyCode]; if (name == null || event.altGraphKey) { return false } // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause, // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+) if (event.keyCode == 3 && event.code) { name = event.code; } return addModifierNames(name, event, noShift) } function getKeyMap(val) { return typeof val == "string" ? keyMap[val] : val } // Helper for deleting text near the selection(s), used to implement // backspace, delete, and similar functionality. function deleteNearSelection(cm, compute) { var ranges = cm.doc.sel.ranges, kill = []; // Build up a set of ranges to kill first, merging overlapping // ranges. for (var i = 0; i < ranges.length; i++) { var toKill = compute(ranges[i]); while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) { var replaced = kill.pop(); if (cmp(replaced.from, toKill.from) < 0) { toKill.from = replaced.from; break } } kill.push(toKill); } // Next, remove those actual ranges. runInOp(cm, function () { for (var i = kill.length - 1; i >= 0; i--) { replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); } ensureCursorVisible(cm); }); } function moveCharLogically(line, ch, dir) { var target = skipExtendingChars(line.text, ch + dir, dir); return target < 0 || target > line.text.length ? null : target } function moveLogically(line, start, dir) { var ch = moveCharLogically(line, start.ch, dir); return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before") } function endOfLine(visually, cm, lineObj, lineNo, dir) { if (visually) { if (cm.doc.direction == "rtl") { dir = -dir; } var order = getOrder(lineObj, cm.doc.direction); if (order) { var part = dir < 0 ? lst(order) : order[0]; var moveInStorageOrder = (dir < 0) == (part.level == 1); var sticky = moveInStorageOrder ? "after" : "before"; var ch; // With a wrapped rtl chunk (possibly spanning multiple bidi parts), // it could be that the last bidi part is not on the last visual line, // since visual lines contain content order-consecutive chunks. // Thus, in rtl, we are looking for the first (content-order) character // in the rtl chunk that is on the last line (that is, the same line // as the last (content-order) character). if (part.level > 0 || cm.doc.direction == "rtl") { var prep = prepareMeasureForLine(cm, lineObj); ch = dir < 0 ? lineObj.text.length - 1 : 0; var targetTop = measureCharPrepared(cm, prep, ch).top; ch = findFirst(function (ch) { return measureCharPrepared(cm, prep, ch).top == targetTop; }, (dir < 0) == (part.level == 1) ? part.from : part.to - 1, ch); if (sticky == "before") { ch = moveCharLogically(lineObj, ch, 1); } } else { ch = dir < 0 ? part.to : part.from; } return new Pos(lineNo, ch, sticky) } } return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after") } function moveVisually(cm, line, start, dir) { var bidi = getOrder(line, cm.doc.direction); if (!bidi) { return moveLogically(line, start, dir) } if (start.ch >= line.text.length) { start.ch = line.text.length; start.sticky = "before"; } else if (start.ch <= 0) { start.ch = 0; start.sticky = "after"; } var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos]; if (cm.doc.direction == "ltr" && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) { // Case 1: We move within an ltr part in an ltr editor. Even with wrapped lines, // nothing interesting happens. return moveLogically(line, start, dir) } var mv = function (pos, dir) { return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir); }; var prep; var getWrappedLineExtent = function (ch) { if (!cm.options.lineWrapping) { return {begin: 0, end: line.text.length} } prep = prep || prepareMeasureForLine(cm, line); return wrappedLineExtentChar(cm, line, prep, ch) }; var wrappedLineExtent = getWrappedLineExtent(start.sticky == "before" ? mv(start, -1) : start.ch); if (cm.doc.direction == "rtl" || part.level == 1) { var moveInStorageOrder = (part.level == 1) == (dir < 0); var ch = mv(start, moveInStorageOrder ? 1 : -1); if (ch != null && (!moveInStorageOrder ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end)) { // Case 2: We move within an rtl part or in an rtl editor on the same visual line var sticky = moveInStorageOrder ? "before" : "after"; return new Pos(start.line, ch, sticky) } } // Case 3: Could not move within this bidi part in this visual line, so leave // the current bidi part var searchInVisualLine = function (partPos, dir, wrappedLineExtent) { var getRes = function (ch, moveInStorageOrder) { return moveInStorageOrder ? new Pos(start.line, mv(ch, 1), "before") : new Pos(start.line, ch, "after"); }; for (; partPos >= 0 && partPos < bidi.length; partPos += dir) { var part = bidi[partPos]; var moveInStorageOrder = (dir > 0) == (part.level != 1); var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1); if (part.from <= ch && ch < part.to) { return getRes(ch, moveInStorageOrder) } ch = moveInStorageOrder ? part.from : mv(part.to, -1); if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) { return getRes(ch, moveInStorageOrder) } } }; // Case 3a: Look for other bidi parts on the same visual line var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent); if (res) { return res } // Case 3b: Look for other bidi parts on the next visual line var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1); if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) { res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh)); if (res) { return res } } // Case 4: Nowhere to move return null } // Commands are parameter-less actions that can be performed on an // editor, mostly used for keybindings. var commands = { selectAll: selectAll, singleSelection: function (cm) { return cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); }, killLine: function (cm) { return deleteNearSelection(cm, function (range) { if (range.empty()) { var len = getLine(cm.doc, range.head.line).text.length; if (range.head.ch == len && range.head.line < cm.lastLine()) { return {from: range.head, to: Pos(range.head.line + 1, 0)} } else { return {from: range.head, to: Pos(range.head.line, len)} } } else { return {from: range.from(), to: range.to()} } }); }, deleteLine: function (cm) { return deleteNearSelection(cm, function (range) { return ({ from: Pos(range.from().line, 0), to: clipPos(cm.doc, Pos(range.to().line + 1, 0)) }); }); }, delLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { return ({ from: Pos(range.from().line, 0), to: range.from() }); }); }, delWrappedLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { var top = cm.charCoords(range.head, "div").top + 5; var leftPos = cm.coordsChar({left: 0, top: top}, "div"); return {from: leftPos, to: range.from()} }); }, delWrappedLineRight: function (cm) { return deleteNearSelection(cm, function (range) { var top = cm.charCoords(range.head, "div").top + 5; var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div"); return {from: range.from(), to: rightPos } }); }, undo: function (cm) { return cm.undo(); }, redo: function (cm) { return cm.redo(); }, undoSelection: function (cm) { return cm.undoSelection(); }, redoSelection: function (cm) { return cm.redoSelection(); }, goDocStart: function (cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); }, goDocEnd: function (cm) { return cm.extendSelection(Pos(cm.lastLine())); }, goLineStart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStart(cm, range.head.line); }, {origin: "+move", bias: 1} ); }, goLineStartSmart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStartSmart(cm, range.head); }, {origin: "+move", bias: 1} ); }, goLineEnd: function (cm) { return cm.extendSelectionsBy(function (range) { return lineEnd(cm, range.head.line); }, {origin: "+move", bias: -1} ); }, goLineRight: function (cm) { return cm.extendSelectionsBy(function (range) { var top = cm.cursorCoords(range.head, "div").top + 5; return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div") }, sel_move); }, goLineLeft: function (cm) { return cm.extendSelectionsBy(function (range) { var top = cm.cursorCoords(range.head, "div").top + 5; return cm.coordsChar({left: 0, top: top}, "div") }, sel_move); }, goLineLeftSmart: function (cm) { return cm.extendSelectionsBy(function (range) { var top = cm.cursorCoords(range.head, "div").top + 5; var pos = cm.coordsChar({left: 0, top: top}, "div"); if (pos.ch < cm.getLine(pos.line).search(/\S/)) { return lineStartSmart(cm, range.head) } return pos }, sel_move); }, goLineUp: function (cm) { return cm.moveV(-1, "line"); }, goLineDown: function (cm) { return cm.moveV(1, "line"); }, goPageUp: function (cm) { return cm.moveV(-1, "page"); }, goPageDown: function (cm) { return cm.moveV(1, "page"); }, goCharLeft: function (cm) { return cm.moveH(-1, "char"); }, goCharRight: function (cm) { return cm.moveH(1, "char"); }, goColumnLeft: function (cm) { return cm.moveH(-1, "column"); }, goColumnRight: function (cm) { return cm.moveH(1, "column"); }, goWordLeft: function (cm) { return cm.moveH(-1, "word"); }, goGroupRight: function (cm) { return cm.moveH(1, "group"); }, goGroupLeft: function (cm) { return cm.moveH(-1, "group"); }, goWordRight: function (cm) { return cm.moveH(1, "word"); }, delCharBefore: function (cm) { return cm.deleteH(-1, "char"); }, delCharAfter: function (cm) { return cm.deleteH(1, "char"); }, delWordBefore: function (cm) { return cm.deleteH(-1, "word"); }, delWordAfter: function (cm) { return cm.deleteH(1, "word"); }, delGroupBefore: function (cm) { return cm.deleteH(-1, "group"); }, delGroupAfter: function (cm) { return cm.deleteH(1, "group"); }, indentAuto: function (cm) { return cm.indentSelection("smart"); }, indentMore: function (cm) { return cm.indentSelection("add"); }, indentLess: function (cm) { return cm.indentSelection("subtract"); }, insertTab: function (cm) { return cm.replaceSelection("\t"); }, insertSoftTab: function (cm) { var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize; for (var i = 0; i < ranges.length; i++) { var pos = ranges[i].from(); var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize); spaces.push(spaceStr(tabSize - col % tabSize)); } cm.replaceSelections(spaces); }, defaultTab: function (cm) { if (cm.somethingSelected()) { cm.indentSelection("add"); } else { cm.execCommand("insertTab"); } }, // Swap the two chars left and right of each selection's head. // Move cursor behind the two swapped characters afterwards. // // Doesn't consider line feeds a character. // Doesn't scan more than one line above to find a character. // Doesn't do anything on an empty line. // Doesn't do anything with non-empty selections. transposeChars: function (cm) { return runInOp(cm, function () { var ranges = cm.listSelections(), newSel = []; for (var i = 0; i < ranges.length; i++) { if (!ranges[i].empty()) { continue } var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text; if (line) { if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1); } if (cur.ch > 0) { cur = new Pos(cur.line, cur.ch + 1); cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2), Pos(cur.line, cur.ch - 2), cur, "+transpose"); } else if (cur.line > cm.doc.first) { var prev = getLine(cm.doc, cur.line - 1).text; if (prev) { cur = new Pos(cur.line, 1); cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() + prev.charAt(prev.length - 1), Pos(cur.line - 1, prev.length - 1), cur, "+transpose"); } } } newSel.push(new Range(cur, cur)); } cm.setSelections(newSel); }); }, newlineAndIndent: function (cm) { return runInOp(cm, function () { var sels = cm.listSelections(); for (var i = sels.length - 1; i >= 0; i--) { cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input"); } sels = cm.listSelections(); for (var i$1 = 0; i$1 < sels.length; i$1++) { cm.indentLine(sels[i$1].from().line, null, true); } ensureCursorVisible(cm); }); }, openLine: function (cm) { return cm.replaceSelection("\n", "start"); }, toggleOverwrite: function (cm) { return cm.toggleOverwrite(); } }; function lineStart(cm, lineN) { var line = getLine(cm.doc, lineN); var visual = visualLine(line); if (visual != line) { lineN = lineNo(visual); } return endOfLine(true, cm, visual, lineN, 1) } function lineEnd(cm, lineN) { var line = getLine(cm.doc, lineN); var visual = visualLineEnd(line); if (visual != line) { lineN = lineNo(visual); } return endOfLine(true, cm, line, lineN, -1) } function lineStartSmart(cm, pos) { var start = lineStart(cm, pos.line); var line = getLine(cm.doc, start.line); var order = getOrder(line, cm.doc.direction); if (!order || order[0].level == 0) { var firstNonWS = Math.max(start.ch, line.text.search(/\S/)); var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch; return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky) } return start } // Run a handler that was bound to a key. function doHandleBinding(cm, bound, dropShift) { if (typeof bound == "string") { bound = commands[bound]; if (!bound) { return false } } // Ensure previous input has been read, so that the handler sees a // consistent view of the document cm.display.input.ensurePolled(); var prevShift = cm.display.shift, done = false; try { if (cm.isReadOnly()) { cm.state.suppressEdits = true; } if (dropShift) { cm.display.shift = false; } done = bound(cm) != Pass; } finally { cm.display.shift = prevShift; cm.state.suppressEdits = false; } return done } function lookupKeyForEditor(cm, name, handle) { for (var i = 0; i < cm.state.keyMaps.length; i++) { var result = lookupKey(name, cm.state.keyMaps[i], handle, cm); if (result) { return result } } return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm)) || lookupKey(name, cm.options.keyMap, handle, cm) } // Note that, despite the name, this function is also used to check // for bound mouse clicks. var stopSeq = new Delayed; function dispatchKey(cm, name, e, handle) { var seq = cm.state.keySeq; if (seq) { if (isModifierKey(name)) { return "handled" } if (/\'$/.test(name)) { cm.state.keySeq = null; } else { stopSeq.set(50, function () { if (cm.state.keySeq == seq) { cm.state.keySeq = null; cm.display.input.reset(); } }); } if (dispatchKeyInner(cm, seq + " " + name, e, handle)) { return true } } return dispatchKeyInner(cm, name, e, handle) } function dispatchKeyInner(cm, name, e, handle) { var result = lookupKeyForEditor(cm, name, handle); if (result == "multi") { cm.state.keySeq = name; } if (result == "handled") { signalLater(cm, "keyHandled", cm, name, e); } if (result == "handled" || result == "multi") { e_preventDefault(e); restartBlink(cm); } return !!result } // Handle a key from the keydown event. function handleKeyBinding(cm, e) { var name = keyName(e, true); if (!name) { return false } if (e.shiftKey && !cm.state.keySeq) { // First try to resolve full name (including 'Shift-'). Failing // that, see if there is a cursor-motion command (starting with // 'go') bound to the keyname without 'Shift-'. return dispatchKey(cm, "Shift-" + name, e, function (b) { return doHandleBinding(cm, b, true); }) || dispatchKey(cm, name, e, function (b) { if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion) { return doHandleBinding(cm, b) } }) } else { return dispatchKey(cm, name, e, function (b) { return doHandleBinding(cm, b); }) } } // Handle a key from the keypress event function handleCharBinding(cm, e, ch) { return dispatchKey(cm, "'" + ch + "'", e, function (b) { return doHandleBinding(cm, b, true); }) } var lastStoppedKey = null; function onKeyDown(e) { var cm = this; if (e.target && e.target != cm.display.input.getField()) { return } cm.curOp.focus = activeElt(); if (signalDOMEvent(cm, e)) { return } // IE does strange things with escape. if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; } var code = e.keyCode; cm.display.shift = code == 16 || e.shiftKey; var handled = handleKeyBinding(cm, e); if (presto) { lastStoppedKey = handled ? code : null; // Opera has no cut event... we try to at least catch the key combo if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey)) { cm.replaceSelection("", null, "cut"); } } if (gecko && !mac && !handled && code == 46 && e.shiftKey && !e.ctrlKey && document.execCommand) { document.execCommand("cut"); } // Turn mouse into crosshair when Alt is held on Mac. if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className)) { showCrossHair(cm); } } function showCrossHair(cm) { var lineDiv = cm.display.lineDiv; addClass(lineDiv, "CodeMirror-crosshair"); function up(e) { if (e.keyCode == 18 || !e.altKey) { rmClass(lineDiv, "CodeMirror-crosshair"); off(document, "keyup", up); off(document, "mouseover", up); } } on(document, "keyup", up); on(document, "mouseover", up); } function onKeyUp(e) { if (e.keyCode == 16) { this.doc.sel.shift = false; } signalDOMEvent(this, e); } function onKeyPress(e) { var cm = this; if (e.target && e.target != cm.display.input.getField()) { return } if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return } var keyCode = e.keyCode, charCode = e.charCode; if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return} if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) { return } var ch = String.fromCharCode(charCode == null ? keyCode : charCode); // Some browsers fire keypress events for backspace if (ch == "\x08") { return } if (handleCharBinding(cm, e, ch)) { return } cm.display.input.onKeyPress(e); } var DOUBLECLICK_DELAY = 400; var PastClick = function(time, pos, button) { this.time = time; this.pos = pos; this.button = button; }; PastClick.prototype.compare = function (time, pos, button) { return this.time + DOUBLECLICK_DELAY > time && cmp(pos, this.pos) == 0 && button == this.button }; var lastClick, lastDoubleClick; function clickRepeat(pos, button) { var now = +new Date; if (lastDoubleClick && lastDoubleClick.compare(now, pos, button)) { lastClick = lastDoubleClick = null; return "triple" } else if (lastClick && lastClick.compare(now, pos, button)) { lastDoubleClick = new PastClick(now, pos, button); lastClick = null; return "double" } else { lastClick = new PastClick(now, pos, button); lastDoubleClick = null; return "single" } } // A mouse down can be a single click, double click, triple click, // start of selection drag, start of text drag, new cursor // (ctrl-click), rectangle drag (alt-drag), or xwin // middle-click-paste. Or it might be a click on something we should // not interfere with, such as a scrollbar or widget. function onMouseDown(e) { var cm = this, display = cm.display; if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return } display.input.ensurePolled(); display.shift = e.shiftKey; if (eventInWidget(display, e)) { if (!webkit) { // Briefly turn off draggability, to allow widgets to do // normal dragging things. display.scroller.draggable = false; setTimeout(function () { return display.scroller.draggable = true; }, 100); } return } if (clickInGutter(cm, e)) { return } var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single"; window.focus(); // #3261: make sure, that we're not starting a second selection if (button == 1 && cm.state.selectingText) { cm.state.selectingText(e); } if (pos && handleMappedButton(cm, button, pos, repeat, e)) { return } if (button == 1) { if (pos) { leftButtonDown(cm, pos, repeat, e); } else if (e_target(e) == display.scroller) { e_preventDefault(e); } } else if (button == 2) { if (pos) { extendSelection(cm.doc, pos); } setTimeout(function () { return display.input.focus(); }, 20); } else if (button == 3) { if (captureRightClick) { cm.display.input.onContextMenu(e); } else { delayBlurEvent(cm); } } } function handleMappedButton(cm, button, pos, repeat, event) { var name = "Click"; if (repeat == "double") { name = "Double" + name; } else if (repeat == "triple") { name = "Triple" + name; } name = (button == 1 ? "Left" : button == 2 ? "Middle" : "Right") + name; return dispatchKey(cm, addModifierNames(name, event), event, function (bound) { if (typeof bound == "string") { bound = commands[bound]; } if (!bound) { return false } var done = false; try { if (cm.isReadOnly()) { cm.state.suppressEdits = true; } done = bound(cm, pos) != Pass; } finally { cm.state.suppressEdits = false; } return done }) } function configureMouse(cm, repeat, event) { var option = cm.getOption("configureMouse"); var value = option ? option(cm, repeat, event) : {}; if (value.unit == null) { var rect = chromeOS ? event.shiftKey && event.metaKey : event.altKey; value.unit = rect ? "rectangle" : repeat == "single" ? "char" : repeat == "double" ? "word" : "line"; } if (value.extend == null || cm.doc.extend) { value.extend = cm.doc.extend || event.shiftKey; } if (value.addNew == null) { value.addNew = mac ? event.metaKey : event.ctrlKey; } if (value.moveOnDrag == null) { value.moveOnDrag = !(mac ? event.altKey : event.ctrlKey); } return value } function leftButtonDown(cm, pos, repeat, event) { if (ie) { setTimeout(bind(ensureFocus, cm), 0); } else { cm.curOp.focus = activeElt(); } var behavior = configureMouse(cm, repeat, event); var sel = cm.doc.sel, contained; if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() && repeat == "single" && (contained = sel.contains(pos)) > -1 && (cmp((contained = sel.ranges[contained]).from(), pos) < 0 || pos.xRel > 0) && (cmp(contained.to(), pos) > 0 || pos.xRel < 0)) { leftButtonStartDrag(cm, event, pos, behavior); } else { leftButtonSelect(cm, event, pos, behavior); } } // Start a text drag. When it ends, see if any dragging actually // happen, and treat as a click if it didn't. function leftButtonStartDrag(cm, event, pos, behavior) { var display = cm.display, moved = false; var dragEnd = operation(cm, function (e) { if (webkit) { display.scroller.draggable = false; } cm.state.draggingText = false; off(display.wrapper.ownerDocument, "mouseup", dragEnd); off(display.wrapper.ownerDocument, "mousemove", mouseMove); off(display.scroller, "dragstart", dragStart); off(display.scroller, "drop", dragEnd); if (!moved) { e_preventDefault(e); if (!behavior.addNew) { extendSelection(cm.doc, pos, null, null, behavior.extend); } // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081) if ((webkit && !safari) || ie && ie_version == 9) { setTimeout(function () {display.wrapper.ownerDocument.body.focus({preventScroll: true}); display.input.focus();}, 20); } else { display.input.focus(); } } }); var mouseMove = function(e2) { moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clientY - e2.clientY) >= 10; }; var dragStart = function () { return moved = true; }; // Let the drag handler handle this. if (webkit) { display.scroller.draggable = true; } cm.state.draggingText = dragEnd; dragEnd.copy = !behavior.moveOnDrag; // IE's approach to draggable if (display.scroller.dragDrop) { display.scroller.dragDrop(); } on(display.wrapper.ownerDocument, "mouseup", dragEnd); on(display.wrapper.ownerDocument, "mousemove", mouseMove); on(display.scroller, "dragstart", dragStart); on(display.scroller, "drop", dragEnd); delayBlurEvent(cm); setTimeout(function () { return display.input.focus(); }, 20); } function rangeForUnit(cm, pos, unit) { if (unit == "char") { return new Range(pos, pos) } if (unit == "word") { return cm.findWordAt(pos) } if (unit == "line") { return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))) } var result = unit(cm, pos); return new Range(result.from, result.to) } // Normal selection, as opposed to text dragging. function leftButtonSelect(cm, event, start, behavior) { var display = cm.display, doc = cm.doc; e_preventDefault(event); var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges; if (behavior.addNew && !behavior.extend) { ourIndex = doc.sel.contains(start); if (ourIndex > -1) { ourRange = ranges[ourIndex]; } else { ourRange = new Range(start, start); } } else { ourRange = doc.sel.primary(); ourIndex = doc.sel.primIndex; } if (behavior.unit == "rectangle") { if (!behavior.addNew) { ourRange = new Range(start, start); } start = posFromMouse(cm, event, true, true); ourIndex = -1; } else { var range = rangeForUnit(cm, start, behavior.unit); if (behavior.extend) { ourRange = extendRange(ourRange, range.anchor, range.head, behavior.extend); } else { ourRange = range; } } if (!behavior.addNew) { ourIndex = 0; setSelection(doc, new Selection([ourRange], 0), sel_mouse); startSel = doc.sel; } else if (ourIndex == -1) { ourIndex = ranges.length; setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex), {scroll: false, origin: "*mouse"}); } else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) { setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0), {scroll: false, origin: "*mouse"}); startSel = doc.sel; } else { replaceOneSelection(doc, ourIndex, ourRange, sel_mouse); } var lastPos = start; function extendTo(pos) { if (cmp(lastPos, pos) == 0) { return } lastPos = pos; if (behavior.unit == "rectangle") { var ranges = [], tabSize = cm.options.tabSize; var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize); var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize); var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol); for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); line <= end; line++) { var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize); if (left == right) { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); } else if (text.length > leftPos) { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); } } if (!ranges.length) { ranges.push(new Range(start, start)); } setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), {origin: "*mouse", scroll: false}); cm.scrollIntoView(pos); } else { var oldRange = ourRange; var range = rangeForUnit(cm, pos, behavior.unit); var anchor = oldRange.anchor, head; if (cmp(range.anchor, anchor) > 0) { head = range.head; anchor = minPos(oldRange.from(), range.anchor); } else { head = range.anchor; anchor = maxPos(oldRange.to(), range.head); } var ranges$1 = startSel.ranges.slice(0); ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head)); setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse); } } var editorSize = display.wrapper.getBoundingClientRect(); // Used to ensure timeout re-tries don't fire when another extend // happened in the meantime (clearTimeout isn't reliable -- at // least on Chrome, the timeouts still happen even when cleared, // if the clear happens after their scheduled firing time). var counter = 0; function extend(e) { var curCount = ++counter; var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle"); if (!cur) { return } if (cmp(cur, lastPos) != 0) { cm.curOp.focus = activeElt(); extendTo(cur); var visible = visibleLines(display, doc); if (cur.line >= visible.to || cur.line < visible.from) { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); } } else { var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0; if (outside) { setTimeout(operation(cm, function () { if (counter != curCount) { return } display.scroller.scrollTop += outside; extend(e); }), 50); } } } function done(e) { cm.state.selectingText = false; counter = Infinity; // If e is null or undefined we interpret this as someone trying // to explicitly cancel the selection rather than the user // letting go of the mouse button. if (e) { e_preventDefault(e); display.input.focus(); } off(display.wrapper.ownerDocument, "mousemove", move); off(display.wrapper.ownerDocument, "mouseup", up); doc.history.lastSelOrigin = null; } var move = operation(cm, function (e) { if (e.buttons === 0 || !e_button(e)) { done(e); } else { extend(e); } }); var up = operation(cm, done); cm.state.selectingText = up; on(display.wrapper.ownerDocument, "mousemove", move); on(display.wrapper.ownerDocument, "mouseup", up); } // Used when mouse-selecting to adjust the anchor to the proper side // of a bidi jump depending on the visual position of the head. function bidiSimplify(cm, range) { var anchor = range.anchor; var head = range.head; var anchorLine = getLine(cm.doc, anchor.line); if (cmp(anchor, head) == 0 && anchor.sticky == head.sticky) { return range } var order = getOrder(anchorLine); if (!order) { return range } var index = getBidiPartAt(order, anchor.ch, anchor.sticky), part = order[index]; if (part.from != anchor.ch && part.to != anchor.ch) { return range } var boundary = index + ((part.from == anchor.ch) == (part.level != 1) ? 0 : 1); if (boundary == 0 || boundary == order.length) { return range } // Compute the relative visual position of the head compared to the // anchor (<0 is to the left, >0 to the right) var leftSide; if (head.line != anchor.line) { leftSide = (head.line - anchor.line) * (cm.doc.direction == "ltr" ? 1 : -1) > 0; } else { var headIndex = getBidiPartAt(order, head.ch, head.sticky); var dir = headIndex - index || (head.ch - anchor.ch) * (part.level == 1 ? -1 : 1); if (headIndex == boundary - 1 || headIndex == boundary) { leftSide = dir < 0; } else { leftSide = dir > 0; } } var usePart = order[boundary + (leftSide ? -1 : 0)]; var from = leftSide == (usePart.level == 1); var ch = from ? usePart.from : usePart.to, sticky = from ? "after" : "before"; return anchor.ch == ch && anchor.sticky == sticky ? range : new Range(new Pos(anchor.line, ch, sticky), head) } // Determines whether an event happened in the gutter, and fires the // handlers for the corresponding event. function gutterEvent(cm, e, type, prevent) { var mX, mY; if (e.touches) { mX = e.touches[0].clientX; mY = e.touches[0].clientY; } else { try { mX = e.clientX; mY = e.clientY; } catch(e$1) { return false } } if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false } if (prevent) { e_preventDefault(e); } var display = cm.display; var lineBox = display.lineDiv.getBoundingClientRect(); if (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e) } mY -= lineBox.top - display.viewOffset; for (var i = 0; i < cm.display.gutterSpecs.length; ++i) { var g = display.gutters.childNodes[i]; if (g && g.getBoundingClientRect().right >= mX) { var line = lineAtHeight(cm.doc, mY); var gutter = cm.display.gutterSpecs[i]; signal(cm, type, cm, line, gutter.className, e); return e_defaultPrevented(e) } } } function clickInGutter(cm, e) { return gutterEvent(cm, e, "gutterClick", true) } // CONTEXT MENU HANDLING // To make the context menu work, we need to briefly unhide the // textarea (making it as unobtrusive as possible) to let the // right-click take effect on it. function onContextMenu(cm, e) { if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) { return } if (signalDOMEvent(cm, e, "contextmenu")) { return } if (!captureRightClick) { cm.display.input.onContextMenu(e); } } function contextMenuInGutter(cm, e) { if (!hasHandler(cm, "gutterContextMenu")) { return false } return gutterEvent(cm, e, "gutterContextMenu", false) } function themeChanged(cm) { cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-"); clearCaches(cm); } var Init = {toString: function(){return "CodeMirror.Init"}}; var defaults = {}; var optionHandlers = {}; function defineOptions(CodeMirror) { var optionHandlers = CodeMirror.optionHandlers; function option(name, deflt, handle, notOnInit) { CodeMirror.defaults[name] = deflt; if (handle) { optionHandlers[name] = notOnInit ? function (cm, val, old) {if (old != Init) { handle(cm, val, old); }} : handle; } } CodeMirror.defineOption = option; // Passed to option handlers when there is no old value. CodeMirror.Init = Init; // These two are, on init, called from the constructor because they // have to be initialized before the editor can start at all. option("value", "", function (cm, val) { return cm.setValue(val); }, true); option("mode", null, function (cm, val) { cm.doc.modeOption = val; loadMode(cm); }, true); option("indentUnit", 2, loadMode, true); option("indentWithTabs", false); option("smartIndent", true); option("tabSize", 4, function (cm) { resetModeState(cm); clearCaches(cm); regChange(cm); }, true); option("lineSeparator", null, function (cm, val) { cm.doc.lineSep = val; if (!val) { return } var newBreaks = [], lineNo = cm.doc.first; cm.doc.iter(function (line) { for (var pos = 0;;) { var found = line.text.indexOf(val, pos); if (found == -1) { break } pos = found + val.length; newBreaks.push(Pos(lineNo, found)); } lineNo++; }); for (var i = newBreaks.length - 1; i >= 0; i--) { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); } }); option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) { cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g"); if (old != Init) { cm.refresh(); } }); option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true); option("electricChars", true); option("inputStyle", mobile ? "contenteditable" : "textarea", function () { throw new Error("inputStyle can not (yet) be changed in a running editor") // FIXME }, true); option("spellcheck", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true); option("autocorrect", false, function (cm, val) { return cm.getInputField().autocorrect = val; }, true); option("autocapitalize", false, function (cm, val) { return cm.getInputField().autocapitalize = val; }, true); option("rtlMoveVisually", !windows); option("wholeLineUpdateBefore", true); option("theme", "default", function (cm) { themeChanged(cm); updateGutters(cm); }, true); option("keyMap", "default", function (cm, val, old) { var next = getKeyMap(val); var prev = old != Init && getKeyMap(old); if (prev && prev.detach) { prev.detach(cm, next); } if (next.attach) { next.attach(cm, prev || null); } }); option("extraKeys", null); option("configureMouse", null); option("lineWrapping", false, wrappingChanged, true); option("gutters", [], function (cm, val) { cm.display.gutterSpecs = getGutters(val, cm.options.lineNumbers); updateGutters(cm); }, true); option("fixedGutter", true, function (cm, val) { cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0"; cm.refresh(); }, true); option("coverGutterNextToScrollbar", false, function (cm) { return updateScrollbars(cm); }, true); option("scrollbarStyle", "native", function (cm) { initScrollbars(cm); updateScrollbars(cm); cm.display.scrollbars.setScrollTop(cm.doc.scrollTop); cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft); }, true); option("lineNumbers", false, function (cm, val) { cm.display.gutterSpecs = getGutters(cm.options.gutters, val); updateGutters(cm); }, true); option("firstLineNumber", 1, updateGutters, true); option("lineNumberFormatter", function (integer) { return integer; }, updateGutters, true); option("showCursorWhenSelecting", false, updateSelection, true); option("resetSelectionOnContextMenu", true); option("lineWiseCopyCut", true); option("pasteLinesPerSelection", true); option("selectionsMayTouch", false); option("readOnly", false, function (cm, val) { if (val == "nocursor") { onBlur(cm); cm.display.input.blur(); } cm.display.input.readOnlyChanged(val); }); option("screenReaderLabel", null, function (cm, val) { val = (val === '') ? null : val; cm.display.input.screenReaderLabelChanged(val); }); option("disableInput", false, function (cm, val) {if (!val) { cm.display.input.reset(); }}, true); option("dragDrop", true, dragDropChanged); option("allowDropFileTypes", null); option("cursorBlinkRate", 530); option("cursorScrollMargin", 0); option("cursorHeight", 1, updateSelection, true); option("singleCursorHeightPerLine", true, updateSelection, true); option("workTime", 100); option("workDelay", 100); option("flattenSpans", true, resetModeState, true); option("addModeClass", false, resetModeState, true); option("pollInterval", 100); option("undoDepth", 200, function (cm, val) { return cm.doc.history.undoDepth = val; }); option("historyEventDelay", 1250); option("viewportMargin", 10, function (cm) { return cm.refresh(); }, true); option("maxHighlightLength", 10000, resetModeState, true); option("moveInputWithCursor", true, function (cm, val) { if (!val) { cm.display.input.resetPosition(); } }); option("tabindex", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || ""; }); option("autofocus", null); option("direction", "ltr", function (cm, val) { return cm.doc.setDirection(val); }, true); option("phrases", null); } function dragDropChanged(cm, value, old) { var wasOn = old && old != Init; if (!value != !wasOn) { var funcs = cm.display.dragFunctions; var toggle = value ? on : off; toggle(cm.display.scroller, "dragstart", funcs.start); toggle(cm.display.scroller, "dragenter", funcs.enter); toggle(cm.display.scroller, "dragover", funcs.over); toggle(cm.display.scroller, "dragleave", funcs.leave); toggle(cm.display.scroller, "drop", funcs.drop); } } function wrappingChanged(cm) { if (cm.options.lineWrapping) { addClass(cm.display.wrapper, "CodeMirror-wrap"); cm.display.sizer.style.minWidth = ""; cm.display.sizerWidth = null; } else { rmClass(cm.display.wrapper, "CodeMirror-wrap"); findMaxLine(cm); } estimateLineHeights(cm); regChange(cm); clearCaches(cm); setTimeout(function () { return updateScrollbars(cm); }, 100); } // A CodeMirror instance represents an editor. This is the object // that user code is usually dealing with. function CodeMirror(place, options) { var this$1 = this; if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) } this.options = options = options ? copyObj(options) : {}; // Determine effective options based on given values and defaults. copyObj(defaults, options, false); var doc = options.value; if (typeof doc == "string") { doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction); } else if (options.mode) { doc.modeOption = options.mode; } this.doc = doc; var input = new CodeMirror.inputStyles[options.inputStyle](this); var display = this.display = new Display(place, doc, input, options); display.wrapper.CodeMirror = this; themeChanged(this); if (options.lineWrapping) { this.display.wrapper.className += " CodeMirror-wrap"; } initScrollbars(this); this.state = { keyMaps: [], // stores maps added by addKeyMap overlays: [], // highlighting overlays, as added by addOverlay modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info overwrite: false, delayingBlurEvent: false, focused: false, suppressEdits: false, // used to disable editing during key handlers when in readOnly mode pasteIncoming: -1, cutIncoming: -1, // help recognize paste/cut edits in input.poll selectingText: false, draggingText: false, highlight: new Delayed(), // stores highlight worker timeout keySeq: null, // Unfinished key sequence specialChars: null }; if (options.autofocus && !mobile) { display.input.focus(); } // Override magic textarea content restore that IE sometimes does // on our hidden textarea on reload if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20); } registerEventHandlers(this); ensureGlobalHandlers(); startOperation(this); this.curOp.forceUpdate = true; attachDoc(this, doc); if ((options.autofocus && !mobile) || this.hasFocus()) { setTimeout(bind(onFocus, this), 20); } else { onBlur(this); } for (var opt in optionHandlers) { if (optionHandlers.hasOwnProperty(opt)) { optionHandlers[opt](this, options[opt], Init); } } maybeUpdateLineNumberWidth(this); if (options.finishInit) { options.finishInit(this); } for (var i = 0; i < initHooks.length; ++i) { initHooks[i](this); } endOperation(this); // Suppress optimizelegibility in Webkit, since it breaks text // measuring on line wrapping boundaries. if (webkit && options.lineWrapping && getComputedStyle(display.lineDiv).textRendering == "optimizelegibility") { display.lineDiv.style.textRendering = "auto"; } } // The default configuration options. CodeMirror.defaults = defaults; // Functions to run when options are changed. CodeMirror.optionHandlers = optionHandlers; // Attach the necessary event handlers when initializing the editor function registerEventHandlers(cm) { var d = cm.display; on(d.scroller, "mousedown", operation(cm, onMouseDown)); // Older IE's will not fire a second mousedown for a double click if (ie && ie_version < 11) { on(d.scroller, "dblclick", operation(cm, function (e) { if (signalDOMEvent(cm, e)) { return } var pos = posFromMouse(cm, e); if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) { return } e_preventDefault(e); var word = cm.findWordAt(pos); extendSelection(cm.doc, word.anchor, word.head); })); } else { on(d.scroller, "dblclick", function (e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }); } // Some browsers fire contextmenu *after* opening the menu, at // which point we can't mess with it anymore. Context menu is // handled in onMouseDown for these browsers. on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); }); on(d.input.getField(), "contextmenu", function (e) { if (!d.scroller.contains(e.target)) { onContextMenu(cm, e); } }); // Used to suppress mouse event handling when a touch happens var touchFinished, prevTouch = {end: 0}; function finishTouch() { if (d.activeTouch) { touchFinished = setTimeout(function () { return d.activeTouch = null; }, 1000); prevTouch = d.activeTouch; prevTouch.end = +new Date; } } function isMouseLikeTouchEvent(e) { if (e.touches.length != 1) { return false } var touch = e.touches[0]; return touch.radiusX <= 1 && touch.radiusY <= 1 } function farAway(touch, other) { if (other.left == null) { return true } var dx = other.left - touch.left, dy = other.top - touch.top; return dx * dx + dy * dy > 20 * 20 } on(d.scroller, "touchstart", function (e) { if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e)) { d.input.ensurePolled(); clearTimeout(touchFinished); var now = +new Date; d.activeTouch = {start: now, moved: false, prev: now - prevTouch.end <= 300 ? prevTouch : null}; if (e.touches.length == 1) { d.activeTouch.left = e.touches[0].pageX; d.activeTouch.top = e.touches[0].pageY; } } }); on(d.scroller, "touchmove", function () { if (d.activeTouch) { d.activeTouch.moved = true; } }); on(d.scroller, "touchend", function (e) { var touch = d.activeTouch; if (touch && !eventInWidget(d, e) && touch.left != null && !touch.moved && new Date - touch.start < 300) { var pos = cm.coordsChar(d.activeTouch, "page"), range; if (!touch.prev || farAway(touch, touch.prev)) // Single tap { range = new Range(pos, pos); } else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap { range = cm.findWordAt(pos); } else // Triple tap { range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))); } cm.setSelection(range.anchor, range.head); cm.focus(); e_preventDefault(e); } finishTouch(); }); on(d.scroller, "touchcancel", finishTouch); // Sync scrolling between fake scrollbars and real scrollable // area, ensure viewport is updated when scrolling. on(d.scroller, "scroll", function () { if (d.scroller.clientHeight) { updateScrollTop(cm, d.scroller.scrollTop); setScrollLeft(cm, d.scroller.scrollLeft, true); signal(cm, "scroll", cm); } }); // Listen to wheel events in order to try and update the viewport on time. on(d.scroller, "mousewheel", function (e) { return onScrollWheel(cm, e); }); on(d.scroller, "DOMMouseScroll", function (e) { return onScrollWheel(cm, e); }); // Prevent wrapper from ever scrolling on(d.wrapper, "scroll", function () { return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; }); d.dragFunctions = { enter: function (e) {if (!signalDOMEvent(cm, e)) { e_stop(e); }}, over: function (e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }}, start: function (e) { return onDragStart(cm, e); }, drop: operation(cm, onDrop), leave: function (e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }} }; var inp = d.input.getField(); on(inp, "keyup", function (e) { return onKeyUp.call(cm, e); }); on(inp, "keydown", operation(cm, onKeyDown)); on(inp, "keypress", operation(cm, onKeyPress)); on(inp, "focus", function (e) { return onFocus(cm, e); }); on(inp, "blur", function (e) { return onBlur(cm, e); }); } var initHooks = []; CodeMirror.defineInitHook = function (f) { return initHooks.push(f); }; // Indent the given line. The how parameter can be "smart", // "add"/null, "subtract", or "prev". When aggressive is false // (typically set to true for forced single-line indents), empty // lines are not indented, and places where the mode returns Pass // are left alone. function indentLine(cm, n, how, aggressive) { var doc = cm.doc, state; if (how == null) { how = "add"; } if (how == "smart") { // Fall back to "prev" when the mode doesn't have an indentation // method. if (!doc.mode.indent) { how = "prev"; } else { state = getContextBefore(cm, n).state; } } var tabSize = cm.options.tabSize; var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize); if (line.stateAfter) { line.stateAfter = null; } var curSpaceString = line.text.match(/^\s*/)[0], indentation; if (!aggressive && !/\S/.test(line.text)) { indentation = 0; how = "not"; } else if (how == "smart") { indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text); if (indentation == Pass || indentation > 150) { if (!aggressive) { return } how = "prev"; } } if (how == "prev") { if (n > doc.first) { indentation = countColumn(getLine(doc, n-1).text, null, tabSize); } else { indentation = 0; } } else if (how == "add") { indentation = curSpace + cm.options.indentUnit; } else if (how == "subtract") { indentation = curSpace - cm.options.indentUnit; } else if (typeof how == "number") { indentation = curSpace + how; } indentation = Math.max(0, indentation); var indentString = "", pos = 0; if (cm.options.indentWithTabs) { for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";} } if (pos < indentation) { indentString += spaceStr(indentation - pos); } if (indentString != curSpaceString) { replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input"); line.stateAfter = null; return true } else { // Ensure that, if the cursor was in the whitespace at the start // of the line, it is moved to the end of that space. for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) { var range = doc.sel.ranges[i$1]; if (range.head.line == n && range.head.ch < curSpaceString.length) { var pos$1 = Pos(n, curSpaceString.length); replaceOneSelection(doc, i$1, new Range(pos$1, pos$1)); break } } } } // This will be set to a {lineWise: bool, text: [string]} object, so // that, when pasting, we know what kind of selections the copied // text was made out of. var lastCopied = null; function setLastCopied(newLastCopied) { lastCopied = newLastCopied; } function applyTextInput(cm, inserted, deleted, sel, origin) { var doc = cm.doc; cm.display.shift = false; if (!sel) { sel = doc.sel; } var recent = +new Date - 200; var paste = origin == "paste" || cm.state.pasteIncoming > recent; var textLines = splitLinesAuto(inserted), multiPaste = null; // When pasting N lines into N selections, insert one line per selection if (paste && sel.ranges.length > 1) { if (lastCopied && lastCopied.text.join("\n") == inserted) { if (sel.ranges.length % lastCopied.text.length == 0) { multiPaste = []; for (var i = 0; i < lastCopied.text.length; i++) { multiPaste.push(doc.splitLines(lastCopied.text[i])); } } } else if (textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection) { multiPaste = map(textLines, function (l) { return [l]; }); } } var updateInput = cm.curOp.updateInput; // Normal behavior is to insert the new text into every selection for (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) { var range = sel.ranges[i$1]; var from = range.from(), to = range.to(); if (range.empty()) { if (deleted && deleted > 0) // Handle deletion { from = Pos(from.line, from.ch - deleted); } else if (cm.state.overwrite && !paste) // Handle overwrite { to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); } else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == textLines.join("\n")) { from = to = Pos(from.line, 0); } } var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines, origin: origin || (paste ? "paste" : cm.state.cutIncoming > recent ? "cut" : "+input")}; makeChange(cm.doc, changeEvent); signalLater(cm, "inputRead", cm, changeEvent); } if (inserted && !paste) { triggerElectric(cm, inserted); } ensureCursorVisible(cm); if (cm.curOp.updateInput < 2) { cm.curOp.updateInput = updateInput; } cm.curOp.typing = true; cm.state.pasteIncoming = cm.state.cutIncoming = -1; } function handlePaste(e, cm) { var pasted = e.clipboardData && e.clipboardData.getData("Text"); if (pasted) { e.preventDefault(); if (!cm.isReadOnly() && !cm.options.disableInput) { runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }); } return true } } function triggerElectric(cm, inserted) { // When an 'electric' character is inserted, immediately trigger a reindent if (!cm.options.electricChars || !cm.options.smartIndent) { return } var sel = cm.doc.sel; for (var i = sel.ranges.length - 1; i >= 0; i--) { var range = sel.ranges[i]; if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) { continue } var mode = cm.getModeAt(range.head); var indented = false; if (mode.electricChars) { for (var j = 0; j < mode.electricChars.length; j++) { if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) { indented = indentLine(cm, range.head.line, "smart"); break } } } else if (mode.electricInput) { if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch))) { indented = indentLine(cm, range.head.line, "smart"); } } if (indented) { signalLater(cm, "electricInput", cm, range.head.line); } } } function copyableRanges(cm) { var text = [], ranges = []; for (var i = 0; i < cm.doc.sel.ranges.length; i++) { var line = cm.doc.sel.ranges[i].head.line; var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)}; ranges.push(lineRange); text.push(cm.getRange(lineRange.anchor, lineRange.head)); } return {text: text, ranges: ranges} } function disableBrowserMagic(field, spellcheck, autocorrect, autocapitalize) { field.setAttribute("autocorrect", autocorrect ? "" : "off"); field.setAttribute("autocapitalize", autocapitalize ? "" : "off"); field.setAttribute("spellcheck", !!spellcheck); } function hiddenTextarea() { var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"); var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); // The textarea is kept positioned near the cursor to prevent the // fact that it'll be scrolled into view on input from scrolling // our fake cursor out of view. On webkit, when wrap=off, paste is // very slow. So make the area wide instead. if (webkit) { te.style.width = "1000px"; } else { te.setAttribute("wrap", "off"); } // If border: 0; -- iOS fails to open keyboard (issue #1287) if (ios) { te.style.border = "1px solid black"; } disableBrowserMagic(te); return div } // The publicly visible API. Note that methodOp(f) means // 'wrap f in an operation, performed on its `this` parameter'. // This is not the complete set of editor methods. Most of the // methods defined on the Doc type are also injected into // CodeMirror.prototype, for backwards compatibility and // convenience. function addEditorMethods(CodeMirror) { var optionHandlers = CodeMirror.optionHandlers; var helpers = CodeMirror.helpers = {}; CodeMirror.prototype = { constructor: CodeMirror, focus: function(){window.focus(); this.display.input.focus();}, setOption: function(option, value) { var options = this.options, old = options[option]; if (options[option] == value && option != "mode") { return } options[option] = value; if (optionHandlers.hasOwnProperty(option)) { operation(this, optionHandlers[option])(this, value, old); } signal(this, "optionChange", this, option); }, getOption: function(option) {return this.options[option]}, getDoc: function() {return this.doc}, addKeyMap: function(map, bottom) { this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map)); }, removeKeyMap: function(map) { var maps = this.state.keyMaps; for (var i = 0; i < maps.length; ++i) { if (maps[i] == map || maps[i].name == map) { maps.splice(i, 1); return true } } }, addOverlay: methodOp(function(spec, options) { var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec); if (mode.startState) { throw new Error("Overlays may not be stateful.") } insertSorted(this.state.overlays, {mode: mode, modeSpec: spec, opaque: options && options.opaque, priority: (options && options.priority) || 0}, function (overlay) { return overlay.priority; }); this.state.modeGen++; regChange(this); }), removeOverlay: methodOp(function(spec) { var overlays = this.state.overlays; for (var i = 0; i < overlays.length; ++i) { var cur = overlays[i].modeSpec; if (cur == spec || typeof spec == "string" && cur.name == spec) { overlays.splice(i, 1); this.state.modeGen++; regChange(this); return } } }), indentLine: methodOp(function(n, dir, aggressive) { if (typeof dir != "string" && typeof dir != "number") { if (dir == null) { dir = this.options.smartIndent ? "smart" : "prev"; } else { dir = dir ? "add" : "subtract"; } } if (isLine(this.doc, n)) { indentLine(this, n, dir, aggressive); } }), indentSelection: methodOp(function(how) { var ranges = this.doc.sel.ranges, end = -1; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; if (!range.empty()) { var from = range.from(), to = range.to(); var start = Math.max(end, from.line); end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1; for (var j = start; j < end; ++j) { indentLine(this, j, how); } var newRanges = this.doc.sel.ranges; if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0) { replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll); } } else if (range.head.line > end) { indentLine(this, range.head.line, how, true); end = range.head.line; if (i == this.doc.sel.primIndex) { ensureCursorVisible(this); } } } }), // Fetch the parser token for a given character. Useful for hacks // that want to inspect the mode state (say, for completion). getTokenAt: function(pos, precise) { return takeToken(this, pos, precise) }, getLineTokens: function(line, precise) { return takeToken(this, Pos(line), precise, true) }, getTokenTypeAt: function(pos) { pos = clipPos(this.doc, pos); var styles = getLineStyles(this, getLine(this.doc, pos.line)); var before = 0, after = (styles.length - 1) / 2, ch = pos.ch; var type; if (ch == 0) { type = styles[2]; } else { for (;;) { var mid = (before + after) >> 1; if ((mid ? styles[mid * 2 - 1] : 0) >= ch) { after = mid; } else if (styles[mid * 2 + 1] < ch) { before = mid + 1; } else { type = styles[mid * 2 + 2]; break } } } var cut = type ? type.indexOf("overlay ") : -1; return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1) }, getModeAt: function(pos) { var mode = this.doc.mode; if (!mode.innerMode) { return mode } return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode }, getHelper: function(pos, type) { return this.getHelpers(pos, type)[0] }, getHelpers: function(pos, type) { var found = []; if (!helpers.hasOwnProperty(type)) { return found } var help = helpers[type], mode = this.getModeAt(pos); if (typeof mode[type] == "string") { if (help[mode[type]]) { found.push(help[mode[type]]); } } else if (mode[type]) { for (var i = 0; i < mode[type].length; i++) { var val = help[mode[type][i]]; if (val) { found.push(val); } } } else if (mode.helperType && help[mode.helperType]) { found.push(help[mode.helperType]); } else if (help[mode.name]) { found.push(help[mode.name]); } for (var i$1 = 0; i$1 < help._global.length; i$1++) { var cur = help._global[i$1]; if (cur.pred(mode, this) && indexOf(found, cur.val) == -1) { found.push(cur.val); } } return found }, getStateAfter: function(line, precise) { var doc = this.doc; line = clipLine(doc, line == null ? doc.first + doc.size - 1: line); return getContextBefore(this, line + 1, precise).state }, cursorCoords: function(start, mode) { var pos, range = this.doc.sel.primary(); if (start == null) { pos = range.head; } else if (typeof start == "object") { pos = clipPos(this.doc, start); } else { pos = start ? range.from() : range.to(); } return cursorCoords(this, pos, mode || "page") }, charCoords: function(pos, mode) { return charCoords(this, clipPos(this.doc, pos), mode || "page") }, coordsChar: function(coords, mode) { coords = fromCoordSystem(this, coords, mode || "page"); return coordsChar(this, coords.left, coords.top) }, lineAtHeight: function(height, mode) { height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top; return lineAtHeight(this.doc, height + this.display.viewOffset) }, heightAtLine: function(line, mode, includeWidgets) { var end = false, lineObj; if (typeof line == "number") { var last = this.doc.first + this.doc.size - 1; if (line < this.doc.first) { line = this.doc.first; } else if (line > last) { line = last; end = true; } lineObj = getLine(this.doc, line); } else { lineObj = line; } return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets || end).top + (end ? this.doc.height - heightAtLine(lineObj) : 0) }, defaultTextHeight: function() { return textHeight(this.display) }, defaultCharWidth: function() { return charWidth(this.display) }, getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}}, addWidget: function(pos, node, scroll, vert, horiz) { var display = this.display; pos = cursorCoords(this, clipPos(this.doc, pos)); var top = pos.bottom, left = pos.left; node.style.position = "absolute"; node.setAttribute("cm-ignore-events", "true"); this.display.input.setUneditable(node); display.sizer.appendChild(node); if (vert == "over") { top = pos.top; } else if (vert == "above" || vert == "near") { var vspace = Math.max(display.wrapper.clientHeight, this.doc.height), hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth); // Default to positioning above (if specified and possible); otherwise default to positioning below if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight) { top = pos.top - node.offsetHeight; } else if (pos.bottom + node.offsetHeight <= vspace) { top = pos.bottom; } if (left + node.offsetWidth > hspace) { left = hspace - node.offsetWidth; } } node.style.top = top + "px"; node.style.left = node.style.right = ""; if (horiz == "right") { left = display.sizer.clientWidth - node.offsetWidth; node.style.right = "0px"; } else { if (horiz == "left") { left = 0; } else if (horiz == "middle") { left = (display.sizer.clientWidth - node.offsetWidth) / 2; } node.style.left = left + "px"; } if (scroll) { scrollIntoView(this, {left: left, top: top, right: left + node.offsetWidth, bottom: top + node.offsetHeight}); } }, triggerOnKeyDown: methodOp(onKeyDown), triggerOnKeyPress: methodOp(onKeyPress), triggerOnKeyUp: onKeyUp, triggerOnMouseDown: methodOp(onMouseDown), execCommand: function(cmd) { if (commands.hasOwnProperty(cmd)) { return commands[cmd].call(null, this) } }, triggerElectric: methodOp(function(text) { triggerElectric(this, text); }), findPosH: function(from, amount, unit, visually) { var dir = 1; if (amount < 0) { dir = -1; amount = -amount; } var cur = clipPos(this.doc, from); for (var i = 0; i < amount; ++i) { cur = findPosH(this.doc, cur, dir, unit, visually); if (cur.hitSide) { break } } return cur }, moveH: methodOp(function(dir, unit) { var this$1 = this; this.extendSelectionsBy(function (range) { if (this$1.display.shift || this$1.doc.extend || range.empty()) { return findPosH(this$1.doc, range.head, dir, unit, this$1.options.rtlMoveVisually) } else { return dir < 0 ? range.from() : range.to() } }, sel_move); }), deleteH: methodOp(function(dir, unit) { var sel = this.doc.sel, doc = this.doc; if (sel.somethingSelected()) { doc.replaceSelection("", null, "+delete"); } else { deleteNearSelection(this, function (range) { var other = findPosH(doc, range.head, dir, unit, false); return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other} }); } }), findPosV: function(from, amount, unit, goalColumn) { var dir = 1, x = goalColumn; if (amount < 0) { dir = -1; amount = -amount; } var cur = clipPos(this.doc, from); for (var i = 0; i < amount; ++i) { var coords = cursorCoords(this, cur, "div"); if (x == null) { x = coords.left; } else { coords.left = x; } cur = findPosV(this, coords, dir, unit); if (cur.hitSide) { break } } return cur }, moveV: methodOp(function(dir, unit) { var this$1 = this; var doc = this.doc, goals = []; var collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected(); doc.extendSelectionsBy(function (range) { if (collapse) { return dir < 0 ? range.from() : range.to() } var headPos = cursorCoords(this$1, range.head, "div"); if (range.goalColumn != null) { headPos.left = range.goalColumn; } goals.push(headPos.left); var pos = findPosV(this$1, headPos, dir, unit); if (unit == "page" && range == doc.sel.primary()) { addToScrollTop(this$1, charCoords(this$1, pos, "div").top - headPos.top); } return pos }, sel_move); if (goals.length) { for (var i = 0; i < doc.sel.ranges.length; i++) { doc.sel.ranges[i].goalColumn = goals[i]; } } }), // Find the word at the given position (as returned by coordsChar). findWordAt: function(pos) { var doc = this.doc, line = getLine(doc, pos.line).text; var start = pos.ch, end = pos.ch; if (line) { var helper = this.getHelper(pos, "wordChars"); if ((pos.sticky == "before" || end == line.length) && start) { --start; } else { ++end; } var startChar = line.charAt(start); var check = isWordChar(startChar, helper) ? function (ch) { return isWordChar(ch, helper); } : /\s/.test(startChar) ? function (ch) { return /\s/.test(ch); } : function (ch) { return (!/\s/.test(ch) && !isWordChar(ch)); }; while (start > 0 && check(line.charAt(start - 1))) { --start; } while (end < line.length && check(line.charAt(end))) { ++end; } } return new Range(Pos(pos.line, start), Pos(pos.line, end)) }, toggleOverwrite: function(value) { if (value != null && value == this.state.overwrite) { return } if (this.state.overwrite = !this.state.overwrite) { addClass(this.display.cursorDiv, "CodeMirror-overwrite"); } else { rmClass(this.display.cursorDiv, "CodeMirror-overwrite"); } signal(this, "overwriteToggle", this, this.state.overwrite); }, hasFocus: function() { return this.display.input.getField() == activeElt() }, isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) }, scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }), getScrollInfo: function() { var scroller = this.display.scroller; return {left: scroller.scrollLeft, top: scroller.scrollTop, height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight, width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth, clientHeight: displayHeight(this), clientWidth: displayWidth(this)} }, scrollIntoView: methodOp(function(range, margin) { if (range == null) { range = {from: this.doc.sel.primary().head, to: null}; if (margin == null) { margin = this.options.cursorScrollMargin; } } else if (typeof range == "number") { range = {from: Pos(range, 0), to: null}; } else if (range.from == null) { range = {from: range, to: null}; } if (!range.to) { range.to = range.from; } range.margin = margin || 0; if (range.from.line != null) { scrollToRange(this, range); } else { scrollToCoordsRange(this, range.from, range.to, range.margin); } }), setSize: methodOp(function(width, height) { var this$1 = this; var interpret = function (val) { return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; }; if (width != null) { this.display.wrapper.style.width = interpret(width); } if (height != null) { this.display.wrapper.style.height = interpret(height); } if (this.options.lineWrapping) { clearLineMeasurementCache(this); } var lineNo = this.display.viewFrom; this.doc.iter(lineNo, this.display.viewTo, function (line) { if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) { if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo, "widget"); break } } } ++lineNo; }); this.curOp.forceUpdate = true; signal(this, "refresh", this); }), operation: function(f){return runInOp(this, f)}, startOperation: function(){return startOperation(this)}, endOperation: function(){return endOperation(this)}, refresh: methodOp(function() { var oldHeight = this.display.cachedTextHeight; regChange(this); this.curOp.forceUpdate = true; clearCaches(this); scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop); updateGutterSpace(this.display); if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5 || this.options.lineWrapping) { estimateLineHeights(this); } signal(this, "refresh", this); }), swapDoc: methodOp(function(doc) { var old = this.doc; old.cm = null; // Cancel the current text selection if any (#5821) if (this.state.selectingText) { this.state.selectingText(); } attachDoc(this, doc); clearCaches(this); this.display.input.reset(); scrollToCoords(this, doc.scrollLeft, doc.scrollTop); this.curOp.forceScroll = true; signalLater(this, "swapDoc", this, old); return old }), phrase: function(phraseText) { var phrases = this.options.phrases; return phrases && Object.prototype.hasOwnProperty.call(phrases, phraseText) ? phrases[phraseText] : phraseText }, getInputField: function(){return this.display.input.getField()}, getWrapperElement: function(){return this.display.wrapper}, getScrollerElement: function(){return this.display.scroller}, getGutterElement: function(){return this.display.gutters} }; eventMixin(CodeMirror); CodeMirror.registerHelper = function(type, name, value) { if (!helpers.hasOwnProperty(type)) { helpers[type] = CodeMirror[type] = {_global: []}; } helpers[type][name] = value; }; CodeMirror.registerGlobalHelper = function(type, name, predicate, value) { CodeMirror.registerHelper(type, name, value); helpers[type]._global.push({pred: predicate, val: value}); }; } // Used for horizontal relative motion. Dir is -1 or 1 (left or // right), unit can be "char", "column" (like char, but doesn't // cross line boundaries), "word" (across next word), or "group" (to // the start of next group of word or non-word-non-whitespace // chars). The visually param controls whether, in right-to-left // text, direction 1 means to move towards the next index in the // string, or towards the character to the right of the current // position. The resulting position will have a hitSide=true // property if it reached the end of the document. function findPosH(doc, pos, dir, unit, visually) { var oldPos = pos; var origDir = dir; var lineObj = getLine(doc, pos.line); var lineDir = visually && doc.direction == "rtl" ? -dir : dir; function findNextLine() { var l = pos.line + lineDir; if (l < doc.first || l >= doc.first + doc.size) { return false } pos = new Pos(l, pos.ch, pos.sticky); return lineObj = getLine(doc, l) } function moveOnce(boundToLine) { var next; if (visually) { next = moveVisually(doc.cm, lineObj, pos, dir); } else { next = moveLogically(lineObj, pos, dir); } if (next == null) { if (!boundToLine && findNextLine()) { pos = endOfLine(visually, doc.cm, lineObj, pos.line, lineDir); } else { return false } } else { pos = next; } return true } if (unit == "char") { moveOnce(); } else if (unit == "column") { moveOnce(true); } else if (unit == "word" || unit == "group") { var sawType = null, group = unit == "group"; var helper = doc.cm && doc.cm.getHelper(pos, "wordChars"); for (var first = true;; first = false) { if (dir < 0 && !moveOnce(!first)) { break } var cur = lineObj.text.charAt(pos.ch) || "\n"; var type = isWordChar(cur, helper) ? "w" : group && cur == "\n" ? "n" : !group || /\s/.test(cur) ? null : "p"; if (group && !first && !type) { type = "s"; } if (sawType && sawType != type) { if (dir < 0) {dir = 1; moveOnce(); pos.sticky = "after";} break } if (type) { sawType = type; } if (dir > 0 && !moveOnce(!first)) { break } } } var result = skipAtomic(doc, pos, oldPos, origDir, true); if (equalCursorPos(oldPos, result)) { result.hitSide = true; } return result } // For relative vertical movement. Dir may be -1 or 1. Unit can be // "page" or "line". The resulting position will have a hitSide=true // property if it reached the end of the document. function findPosV(cm, pos, dir, unit) { var doc = cm.doc, x = pos.left, y; if (unit == "page") { var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight); var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3); y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount; } else if (unit == "line") { y = dir > 0 ? pos.bottom + 3 : pos.top - 3; } var target; for (;;) { target = coordsChar(cm, x, y); if (!target.outside) { break } if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break } y += dir * 5; } return target } // CONTENTEDITABLE INPUT STYLE var ContentEditableInput = function(cm) { this.cm = cm; this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null; this.polling = new Delayed(); this.composing = null; this.gracePeriod = false; this.readDOMTimeout = null; }; ContentEditableInput.prototype.init = function (display) { var this$1 = this; var input = this, cm = input.cm; var div = input.div = display.lineDiv; disableBrowserMagic(div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize); function belongsToInput(e) { for (var t = e.target; t; t = t.parentNode) { if (t == div) { return true } if (/\bCodeMirror-(?:line)?widget\b/.test(t.className)) { break } } return false } on(div, "paste", function (e) { if (!belongsToInput(e) || signalDOMEvent(cm, e) || handlePaste(e, cm)) { return } // IE doesn't fire input events, so we schedule a read for the pasted content in this way if (ie_version <= 11) { setTimeout(operation(cm, function () { return this$1.updateFromDOM(); }), 20); } }); on(div, "compositionstart", function (e) { this$1.composing = {data: e.data, done: false}; }); on(div, "compositionupdate", function (e) { if (!this$1.composing) { this$1.composing = {data: e.data, done: false}; } }); on(div, "compositionend", function (e) { if (this$1.composing) { if (e.data != this$1.composing.data) { this$1.readFromDOMSoon(); } this$1.composing.done = true; } }); on(div, "touchstart", function () { return input.forceCompositionEnd(); }); on(div, "input", function () { if (!this$1.composing) { this$1.readFromDOMSoon(); } }); function onCopyCut(e) { if (!belongsToInput(e) || signalDOMEvent(cm, e)) { return } if (cm.somethingSelected()) { setLastCopied({lineWise: false, text: cm.getSelections()}); if (e.type == "cut") { cm.replaceSelection("", null, "cut"); } } else if (!cm.options.lineWiseCopyCut) { return } else { var ranges = copyableRanges(cm); setLastCopied({lineWise: true, text: ranges.text}); if (e.type == "cut") { cm.operation(function () { cm.setSelections(ranges.ranges, 0, sel_dontScroll); cm.replaceSelection("", null, "cut"); }); } } if (e.clipboardData) { e.clipboardData.clearData(); var content = lastCopied.text.join("\n"); // iOS exposes the clipboard API, but seems to discard content inserted into it e.clipboardData.setData("Text", content); if (e.clipboardData.getData("Text") == content) { e.preventDefault(); return } } // Old-fashioned briefly-focus-a-textarea hack var kludge = hiddenTextarea(), te = kludge.firstChild; cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild); te.value = lastCopied.text.join("\n"); var hadFocus = document.activeElement; selectInput(te); setTimeout(function () { cm.display.lineSpace.removeChild(kludge); hadFocus.focus(); if (hadFocus == div) { input.showPrimarySelection(); } }, 50); } on(div, "copy", onCopyCut); on(div, "cut", onCopyCut); }; ContentEditableInput.prototype.screenReaderLabelChanged = function (label) { // Label for screenreaders, accessibility if(label) { this.div.setAttribute('aria-label', label); } else { this.div.removeAttribute('aria-label'); } }; ContentEditableInput.prototype.prepareSelection = function () { var result = prepareSelection(this.cm, false); result.focus = document.activeElement == this.div; return result }; ContentEditableInput.prototype.showSelection = function (info, takeFocus) { if (!info || !this.cm.display.view.length) { return } if (info.focus || takeFocus) { this.showPrimarySelection(); } this.showMultipleSelections(info); }; ContentEditableInput.prototype.getSelection = function () { return this.cm.display.wrapper.ownerDocument.getSelection() }; ContentEditableInput.prototype.showPrimarySelection = function () { var sel = this.getSelection(), cm = this.cm, prim = cm.doc.sel.primary(); var from = prim.from(), to = prim.to(); if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) { sel.removeAllRanges(); return } var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset); var curFocus = domToPos(cm, sel.focusNode, sel.focusOffset); if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad && cmp(minPos(curAnchor, curFocus), from) == 0 && cmp(maxPos(curAnchor, curFocus), to) == 0) { return } var view = cm.display.view; var start = (from.line >= cm.display.viewFrom && posToDOM(cm, from)) || {node: view[0].measure.map[2], offset: 0}; var end = to.line < cm.display.viewTo && posToDOM(cm, to); if (!end) { var measure = view[view.length - 1].measure; var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map; end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]}; } if (!start || !end) { sel.removeAllRanges(); return } var old = sel.rangeCount && sel.getRangeAt(0), rng; try { rng = range(start.node, start.offset, end.offset, end.node); } catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible if (rng) { if (!gecko && cm.state.focused) { sel.collapse(start.node, start.offset); if (!rng.collapsed) { sel.removeAllRanges(); sel.addRange(rng); } } else { sel.removeAllRanges(); sel.addRange(rng); } if (old && sel.anchorNode == null) { sel.addRange(old); } else if (gecko) { this.startGracePeriod(); } } this.rememberSelection(); }; ContentEditableInput.prototype.startGracePeriod = function () { var this$1 = this; clearTimeout(this.gracePeriod); this.gracePeriod = setTimeout(function () { this$1.gracePeriod = false; if (this$1.selectionChanged()) { this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }); } }, 20); }; ContentEditableInput.prototype.showMultipleSelections = function (info) { removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors); removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection); }; ContentEditableInput.prototype.rememberSelection = function () { var sel = this.getSelection(); this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset; this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset; }; ContentEditableInput.prototype.selectionInEditor = function () { var sel = this.getSelection(); if (!sel.rangeCount) { return false } var node = sel.getRangeAt(0).commonAncestorContainer; return contains(this.div, node) }; ContentEditableInput.prototype.focus = function () { if (this.cm.options.readOnly != "nocursor") { if (!this.selectionInEditor() || document.activeElement != this.div) { this.showSelection(this.prepareSelection(), true); } this.div.focus(); } }; ContentEditableInput.prototype.blur = function () { this.div.blur(); }; ContentEditableInput.prototype.getField = function () { return this.div }; ContentEditableInput.prototype.supportsTouch = function () { return true }; ContentEditableInput.prototype.receivedFocus = function () { var input = this; if (this.selectionInEditor()) { this.pollSelection(); } else { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }); } function poll() { if (input.cm.state.focused) { input.pollSelection(); input.polling.set(input.cm.options.pollInterval, poll); } } this.polling.set(this.cm.options.pollInterval, poll); }; ContentEditableInput.prototype.selectionChanged = function () { var sel = this.getSelection(); return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset }; ContentEditableInput.prototype.pollSelection = function () { if (this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged()) { return } var sel = this.getSelection(), cm = this.cm; // On Android Chrome (version 56, at least), backspacing into an // uneditable block element will put the cursor in that element, // and then, because it's not editable, hide the virtual keyboard. // Because Android doesn't allow us to actually detect backspace // presses in a sane way, this code checks for when that happens // and simulates a backspace press in this case. if (android && chrome && this.cm.display.gutterSpecs.length && isInGutter(sel.anchorNode)) { this.cm.triggerOnKeyDown({type: "keydown", keyCode: 8, preventDefault: Math.abs}); this.blur(); this.focus(); return } if (this.composing) { return } this.rememberSelection(); var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset); var head = domToPos(cm, sel.focusNode, sel.focusOffset); if (anchor && head) { runInOp(cm, function () { setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll); if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true; } }); } }; ContentEditableInput.prototype.pollContent = function () { if (this.readDOMTimeout != null) { clearTimeout(this.readDOMTimeout); this.readDOMTimeout = null; } var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary(); var from = sel.from(), to = sel.to(); if (from.ch == 0 && from.line > cm.firstLine()) { from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length); } if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine()) { to = Pos(to.line + 1, 0); } if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false } var fromIndex, fromLine, fromNode; if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) { fromLine = lineNo(display.view[0].line); fromNode = display.view[0].node; } else { fromLine = lineNo(display.view[fromIndex].line); fromNode = display.view[fromIndex - 1].node.nextSibling; } var toIndex = findViewIndex(cm, to.line); var toLine, toNode; if (toIndex == display.view.length - 1) { toLine = display.viewTo - 1; toNode = display.lineDiv.lastChild; } else { toLine = lineNo(display.view[toIndex + 1].line) - 1; toNode = display.view[toIndex + 1].node.previousSibling; } if (!fromNode) { return false } var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine)); var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length)); while (newText.length > 1 && oldText.length > 1) { if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; } else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; } else { break } } var cutFront = 0, cutEnd = 0; var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length); while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront)) { ++cutFront; } var newBot = lst(newText), oldBot = lst(oldText); var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0), oldBot.length - (oldText.length == 1 ? cutFront : 0)); while (cutEnd < maxCutEnd && newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) { ++cutEnd; } // Try to move start of change to start of selection if ambiguous if (newText.length == 1 && oldText.length == 1 && fromLine == from.line) { while (cutFront && cutFront > from.ch && newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) { cutFront--; cutEnd++; } } newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, ""); newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, ""); var chFrom = Pos(fromLine, cutFront); var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0); if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) { replaceRange(cm.doc, newText, chFrom, chTo, "+input"); return true } }; ContentEditableInput.prototype.ensurePolled = function () { this.forceCompositionEnd(); }; ContentEditableInput.prototype.reset = function () { this.forceCompositionEnd(); }; ContentEditableInput.prototype.forceCompositionEnd = function () { if (!this.composing) { return } clearTimeout(this.readDOMTimeout); this.composing = null; this.updateFromDOM(); this.div.blur(); this.div.focus(); }; ContentEditableInput.prototype.readFromDOMSoon = function () { var this$1 = this; if (this.readDOMTimeout != null) { return } this.readDOMTimeout = setTimeout(function () { this$1.readDOMTimeout = null; if (this$1.composing) { if (this$1.composing.done) { this$1.composing = null; } else { return } } this$1.updateFromDOM(); }, 80); }; ContentEditableInput.prototype.updateFromDOM = function () { var this$1 = this; if (this.cm.isReadOnly() || !this.pollContent()) { runInOp(this.cm, function () { return regChange(this$1.cm); }); } }; ContentEditableInput.prototype.setUneditable = function (node) { node.contentEditable = "false"; }; ContentEditableInput.prototype.onKeyPress = function (e) { if (e.charCode == 0 || this.composing) { return } e.preventDefault(); if (!this.cm.isReadOnly()) { operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0); } }; ContentEditableInput.prototype.readOnlyChanged = function (val) { this.div.contentEditable = String(val != "nocursor"); }; ContentEditableInput.prototype.onContextMenu = function () {}; ContentEditableInput.prototype.resetPosition = function () {}; ContentEditableInput.prototype.needsContentAttribute = true; function posToDOM(cm, pos) { var view = findViewForLine(cm, pos.line); if (!view || view.hidden) { return null } var line = getLine(cm.doc, pos.line); var info = mapFromLineView(view, line, pos.line); var order = getOrder(line, cm.doc.direction), side = "left"; if (order) { var partPos = getBidiPartAt(order, pos.ch); side = partPos % 2 ? "right" : "left"; } var result = nodeAndOffsetInLineMap(info.map, pos.ch, side); result.offset = result.collapse == "right" ? result.end : result.start; return result } function isInGutter(node) { for (var scan = node; scan; scan = scan.parentNode) { if (/CodeMirror-gutter-wrapper/.test(scan.className)) { return true } } return false } function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos } function domTextBetween(cm, from, to, fromLine, toLine) { var text = "", closing = false, lineSep = cm.doc.lineSeparator(), extraLinebreak = false; function recognizeMarker(id) { return function (marker) { return marker.id == id; } } function close() { if (closing) { text += lineSep; if (extraLinebreak) { text += lineSep; } closing = extraLinebreak = false; } } function addText(str) { if (str) { close(); text += str; } } function walk(node) { if (node.nodeType == 1) { var cmText = node.getAttribute("cm-text"); if (cmText) { addText(cmText); return } var markerID = node.getAttribute("cm-marker"), range; if (markerID) { var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID)); if (found.length && (range = found[0].find(0))) { addText(getBetween(cm.doc, range.from, range.to).join(lineSep)); } return } if (node.getAttribute("contenteditable") == "false") { return } var isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName); if (!/^br$/i.test(node.nodeName) && node.textContent.length == 0) { return } if (isBlock) { close(); } for (var i = 0; i < node.childNodes.length; i++) { walk(node.childNodes[i]); } if (/^(pre|p)$/i.test(node.nodeName)) { extraLinebreak = true; } if (isBlock) { closing = true; } } else if (node.nodeType == 3) { addText(node.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " ")); } } for (;;) { walk(from); if (from == to) { break } from = from.nextSibling; extraLinebreak = false; } return text } function domToPos(cm, node, offset) { var lineNode; if (node == cm.display.lineDiv) { lineNode = cm.display.lineDiv.childNodes[offset]; if (!lineNode) { return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true) } node = null; offset = 0; } else { for (lineNode = node;; lineNode = lineNode.parentNode) { if (!lineNode || lineNode == cm.display.lineDiv) { return null } if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) { break } } } for (var i = 0; i < cm.display.view.length; i++) { var lineView = cm.display.view[i]; if (lineView.node == lineNode) { return locateNodeInLineView(lineView, node, offset) } } } function locateNodeInLineView(lineView, node, offset) { var wrapper = lineView.text.firstChild, bad = false; if (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true) } if (node == wrapper) { bad = true; node = wrapper.childNodes[offset]; offset = 0; if (!node) { var line = lineView.rest ? lst(lineView.rest) : lineView.line; return badPos(Pos(lineNo(line), line.text.length), bad) } } var textNode = node.nodeType == 3 ? node : null, topNode = node; if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) { textNode = node.firstChild; if (offset) { offset = textNode.nodeValue.length; } } while (topNode.parentNode != wrapper) { topNode = topNode.parentNode; } var measure = lineView.measure, maps = measure.maps; function find(textNode, topNode, offset) { for (var i = -1; i < (maps ? maps.length : 0); i++) { var map = i < 0 ? measure.map : maps[i]; for (var j = 0; j < map.length; j += 3) { var curNode = map[j + 2]; if (curNode == textNode || curNode == topNode) { var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]); var ch = map[j] + offset; if (offset < 0 || curNode != textNode) { ch = map[j + (offset ? 1 : 0)]; } return Pos(line, ch) } } } } var found = find(textNode, topNode, offset); if (found) { return badPos(found, bad) } // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) { found = find(after, after.firstChild, 0); if (found) { return badPos(Pos(found.line, found.ch - dist), bad) } else { dist += after.textContent.length; } } for (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) { found = find(before, before.firstChild, -1); if (found) { return badPos(Pos(found.line, found.ch + dist$1), bad) } else { dist$1 += before.textContent.length; } } } // TEXTAREA INPUT STYLE var TextareaInput = function(cm) { this.cm = cm; // See input.poll and input.reset this.prevInput = ""; // Flag that indicates whether we expect input to appear real soon // now (after some event like 'keypress' or 'input') and are // polling intensively. this.pollingFast = false; // Self-resetting timeout for the poller this.polling = new Delayed(); // Used to work around IE issue with selection being forgotten when focus moves away from textarea this.hasSelection = false; this.composing = null; }; TextareaInput.prototype.init = function (display) { var this$1 = this; var input = this, cm = this.cm; this.createField(display); var te = this.textarea; display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild); // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore) if (ios) { te.style.width = "0px"; } on(te, "input", function () { if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null; } input.poll(); }); on(te, "paste", function (e) { if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return } cm.state.pasteIncoming = +new Date; input.fastPoll(); }); function prepareCopyCut(e) { if (signalDOMEvent(cm, e)) { return } if (cm.somethingSelected()) { setLastCopied({lineWise: false, text: cm.getSelections()}); } else if (!cm.options.lineWiseCopyCut) { return } else { var ranges = copyableRanges(cm); setLastCopied({lineWise: true, text: ranges.text}); if (e.type == "cut") { cm.setSelections(ranges.ranges, null, sel_dontScroll); } else { input.prevInput = ""; te.value = ranges.text.join("\n"); selectInput(te); } } if (e.type == "cut") { cm.state.cutIncoming = +new Date; } } on(te, "cut", prepareCopyCut); on(te, "copy", prepareCopyCut); on(display.scroller, "paste", function (e) { if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return } if (!te.dispatchEvent) { cm.state.pasteIncoming = +new Date; input.focus(); return } // Pass the `paste` event to the textarea so it's handled by its event listener. var event = new Event("paste"); event.clipboardData = e.clipboardData; te.dispatchEvent(event); }); // Prevent normal selection in the editor (we handle our own) on(display.lineSpace, "selectstart", function (e) { if (!eventInWidget(display, e)) { e_preventDefault(e); } }); on(te, "compositionstart", function () { var start = cm.getCursor("from"); if (input.composing) { input.composing.range.clear(); } input.composing = { start: start, range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"}) }; }); on(te, "compositionend", function () { if (input.composing) { input.poll(); input.composing.range.clear(); input.composing = null; } }); }; TextareaInput.prototype.createField = function (_display) { // Wraps and hides input textarea this.wrapper = hiddenTextarea(); // The semihidden textarea that is focused when the editor is // focused, and receives input. this.textarea = this.wrapper.firstChild; }; TextareaInput.prototype.screenReaderLabelChanged = function (label) { // Label for screenreaders, accessibility if(label) { this.textarea.setAttribute('aria-label', label); } else { this.textarea.removeAttribute('aria-label'); } }; TextareaInput.prototype.prepareSelection = function () { // Redraw the selection and/or cursor var cm = this.cm, display = cm.display, doc = cm.doc; var result = prepareSelection(cm); // Move the hidden textarea near the cursor to prevent scrolling artifacts if (cm.options.moveInputWithCursor) { var headPos = cursorCoords(cm, doc.sel.primary().head, "div"); var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect(); result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10, headPos.top + lineOff.top - wrapOff.top)); result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10, headPos.left + lineOff.left - wrapOff.left)); } return result }; TextareaInput.prototype.showSelection = function (drawn) { var cm = this.cm, display = cm.display; removeChildrenAndAdd(display.cursorDiv, drawn.cursors); removeChildrenAndAdd(display.selectionDiv, drawn.selection); if (drawn.teTop != null) { this.wrapper.style.top = drawn.teTop + "px"; this.wrapper.style.left = drawn.teLeft + "px"; } }; // Reset the input to correspond to the selection (or to be empty, // when not typing and nothing is selected) TextareaInput.prototype.reset = function (typing) { if (this.contextMenuPending || this.composing) { return } var cm = this.cm; if (cm.somethingSelected()) { this.prevInput = ""; var content = cm.getSelection(); this.textarea.value = content; if (cm.state.focused) { selectInput(this.textarea); } if (ie && ie_version >= 9) { this.hasSelection = content; } } else if (!typing) { this.prevInput = this.textarea.value = ""; if (ie && ie_version >= 9) { this.hasSelection = null; } } }; TextareaInput.prototype.getField = function () { return this.textarea }; TextareaInput.prototype.supportsTouch = function () { return false }; TextareaInput.prototype.focus = function () { if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) { try { this.textarea.focus(); } catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM } }; TextareaInput.prototype.blur = function () { this.textarea.blur(); }; TextareaInput.prototype.resetPosition = function () { this.wrapper.style.top = this.wrapper.style.left = 0; }; TextareaInput.prototype.receivedFocus = function () { this.slowPoll(); }; // Poll for input changes, using the normal rate of polling. This // runs as long as the editor is focused. TextareaInput.prototype.slowPoll = function () { var this$1 = this; if (this.pollingFast) { return } this.polling.set(this.cm.options.pollInterval, function () { this$1.poll(); if (this$1.cm.state.focused) { this$1.slowPoll(); } }); }; // When an event has just come in that is likely to add or change // something in the input textarea, we poll faster, to ensure that // the change appears on the screen quickly. TextareaInput.prototype.fastPoll = function () { var missed = false, input = this; input.pollingFast = true; function p() { var changed = input.poll(); if (!changed && !missed) {missed = true; input.polling.set(60, p);} else {input.pollingFast = false; input.slowPoll();} } input.polling.set(20, p); }; // Read input from the textarea, and update the document to match. // When something is selected, it is present in the textarea, and // selected (unless it is huge, in which case a placeholder is // used). When nothing is selected, the cursor sits after previously // seen text (can be empty), which is stored in prevInput (we must // not reset the textarea when typing, because that breaks IME). TextareaInput.prototype.poll = function () { var this$1 = this; var cm = this.cm, input = this.textarea, prevInput = this.prevInput; // Since this is called a *lot*, try to bail out as cheaply as // possible when it is clear that nothing happened. hasSelection // will be the case when there is a lot of text in the textarea, // in which case reading its value would be expensive. if (this.contextMenuPending || !cm.state.focused || (hasSelection(input) && !prevInput && !this.composing) || cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq) { return false } var text = input.value; // If nothing changed, bail. if (text == prevInput && !cm.somethingSelected()) { return false } // Work around nonsensical selection resetting in IE9/10, and // inexplicable appearance of private area unicode characters on // some key combos in Mac (#2689). if (ie && ie_version >= 9 && this.hasSelection === text || mac && /[\uf700-\uf7ff]/.test(text)) { cm.display.input.reset(); return false } if (cm.doc.sel == cm.display.selForContextMenu) { var first = text.charCodeAt(0); if (first == 0x200b && !prevInput) { prevInput = "\u200b"; } if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo") } } // Find the part of the input that is actually new var same = 0, l = Math.min(prevInput.length, text.length); while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same; } runInOp(cm, function () { applyTextInput(cm, text.slice(same), prevInput.length - same, null, this$1.composing ? "*compose" : null); // Don't leave long text in the textarea, since it makes further polling slow if (text.length > 1000 || text.indexOf("\n") > -1) { input.value = this$1.prevInput = ""; } else { this$1.prevInput = text; } if (this$1.composing) { this$1.composing.range.clear(); this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"), {className: "CodeMirror-composing"}); } }); return true }; TextareaInput.prototype.ensurePolled = function () { if (this.pollingFast && this.poll()) { this.pollingFast = false; } }; TextareaInput.prototype.onKeyPress = function () { if (ie && ie_version >= 9) { this.hasSelection = null; } this.fastPoll(); }; TextareaInput.prototype.onContextMenu = function (e) { var input = this, cm = input.cm, display = cm.display, te = input.textarea; if (input.contextMenuPending) { input.contextMenuPending(); } var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop; if (!pos || presto) { return } // Opera is difficult. // Reset the current text selection only if the click is done outside of the selection // and 'resetSelectionOnContextMenu' option is true. var reset = cm.options.resetSelectionOnContextMenu; if (reset && cm.doc.sel.contains(pos) == -1) { operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); } var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText; var wrapperBox = input.wrapper.offsetParent.getBoundingClientRect(); input.wrapper.style.cssText = "position: static"; te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"; var oldScrollY; if (webkit) { oldScrollY = window.scrollY; } // Work around Chrome issue (#2712) display.input.focus(); if (webkit) { window.scrollTo(null, oldScrollY); } display.input.reset(); // Adds "Select all" to context menu in FF if (!cm.somethingSelected()) { te.value = input.prevInput = " "; } input.contextMenuPending = rehide; display.selForContextMenu = cm.doc.sel; clearTimeout(display.detectingSelectAll); // Select-all will be greyed out if there's nothing to select, so // this adds a zero-width space so that we can later check whether // it got selected. function prepareSelectAllHack() { if (te.selectionStart != null) { var selected = cm.somethingSelected(); var extval = "\u200b" + (selected ? te.value : ""); te.value = "\u21da"; // Used to catch context-menu undo te.value = extval; input.prevInput = selected ? "" : "\u200b"; te.selectionStart = 1; te.selectionEnd = extval.length; // Re-set this, in case some other handler touched the // selection in the meantime. display.selForContextMenu = cm.doc.sel; } } function rehide() { if (input.contextMenuPending != rehide) { return } input.contextMenuPending = false; input.wrapper.style.cssText = oldWrapperCSS; te.style.cssText = oldCSS; if (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos); } // Try to detect the user choosing select-all if (te.selectionStart != null) { if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack(); } var i = 0, poll = function () { if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 && te.selectionEnd > 0 && input.prevInput == "\u200b") { operation(cm, selectAll)(cm); } else if (i++ < 10) { display.detectingSelectAll = setTimeout(poll, 500); } else { display.selForContextMenu = null; display.input.reset(); } }; display.detectingSelectAll = setTimeout(poll, 200); } } if (ie && ie_version >= 9) { prepareSelectAllHack(); } if (captureRightClick) { e_stop(e); var mouseup = function () { off(window, "mouseup", mouseup); setTimeout(rehide, 20); }; on(window, "mouseup", mouseup); } else { setTimeout(rehide, 50); } }; TextareaInput.prototype.readOnlyChanged = function (val) { if (!val) { this.reset(); } this.textarea.disabled = val == "nocursor"; }; TextareaInput.prototype.setUneditable = function () {}; TextareaInput.prototype.needsContentAttribute = false; function fromTextArea(textarea, options) { options = options ? copyObj(options) : {}; options.value = textarea.value; if (!options.tabindex && textarea.tabIndex) { options.tabindex = textarea.tabIndex; } if (!options.placeholder && textarea.placeholder) { options.placeholder = textarea.placeholder; } // Set autofocus to true if this textarea is focused, or if it has // autofocus and no other element is focused. if (options.autofocus == null) { var hasFocus = activeElt(); options.autofocus = hasFocus == textarea || textarea.getAttribute("autofocus") != null && hasFocus == document.body; } function save() {textarea.value = cm.getValue();} var realSubmit; if (textarea.form) { on(textarea.form, "submit", save); // Deplorable hack to make the submit method do the right thing. if (!options.leaveSubmitMethodAlone) { var form = textarea.form; realSubmit = form.submit; try { var wrappedSubmit = form.submit = function () { save(); form.submit = realSubmit; form.submit(); form.submit = wrappedSubmit; }; } catch(e) {} } } options.finishInit = function (cm) { cm.save = save; cm.getTextArea = function () { return textarea; }; cm.toTextArea = function () { cm.toTextArea = isNaN; // Prevent this from being ran twice save(); textarea.parentNode.removeChild(cm.getWrapperElement()); textarea.style.display = ""; if (textarea.form) { off(textarea.form, "submit", save); if (!options.leaveSubmitMethodAlone && typeof textarea.form.submit == "function") { textarea.form.submit = realSubmit; } } }; }; textarea.style.display = "none"; var cm = CodeMirror(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); }, options); return cm } function addLegacyProps(CodeMirror) { CodeMirror.off = off; CodeMirror.on = on; CodeMirror.wheelEventPixels = wheelEventPixels; CodeMirror.Doc = Doc; CodeMirror.splitLines = splitLinesAuto; CodeMirror.countColumn = countColumn; CodeMirror.findColumn = findColumn; CodeMirror.isWordChar = isWordCharBasic; CodeMirror.Pass = Pass; CodeMirror.signal = signal; CodeMirror.Line = Line; CodeMirror.changeEnd = changeEnd; CodeMirror.scrollbarModel = scrollbarModel; CodeMirror.Pos = Pos; CodeMirror.cmpPos = cmp; CodeMirror.modes = modes; CodeMirror.mimeModes = mimeModes; CodeMirror.resolveMode = resolveMode; CodeMirror.getMode = getMode; CodeMirror.modeExtensions = modeExtensions; CodeMirror.extendMode = extendMode; CodeMirror.copyState = copyState; CodeMirror.startState = startState; CodeMirror.innerMode = innerMode; CodeMirror.commands = commands; CodeMirror.keyMap = keyMap; CodeMirror.keyName = keyName; CodeMirror.isModifierKey = isModifierKey; CodeMirror.lookupKey = lookupKey; CodeMirror.normalizeKeyMap = normalizeKeyMap; CodeMirror.StringStream = StringStream; CodeMirror.SharedTextMarker = SharedTextMarker; CodeMirror.TextMarker = TextMarker; CodeMirror.LineWidget = LineWidget; CodeMirror.e_preventDefault = e_preventDefault; CodeMirror.e_stopPropagation = e_stopPropagation; CodeMirror.e_stop = e_stop; CodeMirror.addClass = addClass; CodeMirror.contains = contains; CodeMirror.rmClass = rmClass; CodeMirror.keyNames = keyNames; } // EDITOR CONSTRUCTOR defineOptions(CodeMirror); addEditorMethods(CodeMirror); // Set up methods on CodeMirror's prototype to redirect to the editor's document. var dontDelegate = "iter insert remove copy getEditor constructor".split(" "); for (var prop in Doc.prototype) { if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0) { CodeMirror.prototype[prop] = (function(method) { return function() {return method.apply(this.doc, arguments)} })(Doc.prototype[prop]); } } eventMixin(Doc); CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput}; // Extra arguments are stored as the mode's dependencies, which is // used by (legacy) mechanisms like loadmode.js to automatically // load a mode. (Preferred mechanism is the require/define calls.) CodeMirror.defineMode = function(name/*, mode, …*/) { if (!CodeMirror.defaults.mode && name != "null") { CodeMirror.defaults.mode = name; } defineMode.apply(this, arguments); }; CodeMirror.defineMIME = defineMIME; // Minimal default mode. CodeMirror.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); }); CodeMirror.defineMIME("text/plain", "null"); // EXTENSIONS CodeMirror.defineExtension = function (name, func) { CodeMirror.prototype[name] = func; }; CodeMirror.defineDocExtension = function (name, func) { Doc.prototype[name] = func; }; CodeMirror.fromTextArea = fromTextArea; addLegacyProps(CodeMirror); CodeMirror.version = "5.56.0"; return CodeMirror; }))); /* ---- extension/simple.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineSimpleMode = function(name, states) { CodeMirror.defineMode(name, function(config) { return CodeMirror.simpleMode(config, states); }); }; CodeMirror.simpleMode = function(config, states) { ensureState(states, "start"); var states_ = {}, meta = states.meta || {}, hasIndentation = false; for (var state in states) if (state != meta && states.hasOwnProperty(state)) { var list = states_[state] = [], orig = states[state]; for (var i = 0; i < orig.length; i++) { var data = orig[i]; list.push(new Rule(data, states)); if (data.indent || data.dedent) hasIndentation = true; } } var mode = { startState: function() { return {state: "start", pending: null, local: null, localState: null, indent: hasIndentation ? [] : null}; }, copyState: function(state) { var s = {state: state.state, pending: state.pending, local: state.local, localState: null, indent: state.indent && state.indent.slice(0)}; if (state.localState) s.localState = CodeMirror.copyState(state.local.mode, state.localState); if (state.stack) s.stack = state.stack.slice(0); for (var pers = state.persistentStates; pers; pers = pers.next) s.persistentStates = {mode: pers.mode, spec: pers.spec, state: pers.state == state.localState ? s.localState : CodeMirror.copyState(pers.mode, pers.state), next: s.persistentStates}; return s; }, token: tokenFunction(states_, config), innerMode: function(state) { return state.local && {mode: state.local.mode, state: state.localState}; }, indent: indentFunction(states_, meta) }; if (meta) for (var prop in meta) if (meta.hasOwnProperty(prop)) mode[prop] = meta[prop]; return mode; }; function ensureState(states, name) { if (!states.hasOwnProperty(name)) throw new Error("Undefined state " + name + " in simple mode"); } function toRegex(val, caret) { if (!val) return /(?:)/; var flags = ""; if (val instanceof RegExp) { if (val.ignoreCase) flags = "i"; val = val.source; } else { val = String(val); } return new RegExp((caret === false ? "" : "^") + "(?:" + val + ")", flags); } function asToken(val) { if (!val) return null; if (val.apply) return val if (typeof val == "string") return val.replace(/\./g, " "); var result = []; for (var i = 0; i < val.length; i++) result.push(val[i] && val[i].replace(/\./g, " ")); return result; } function Rule(data, states) { if (data.next || data.push) ensureState(states, data.next || data.push); this.regex = toRegex(data.regex); this.token = asToken(data.token); this.data = data; } function tokenFunction(states, config) { return function(stream, state) { if (state.pending) { var pend = state.pending.shift(); if (state.pending.length == 0) state.pending = null; stream.pos += pend.text.length; return pend.token; } if (state.local) { if (state.local.end && stream.match(state.local.end)) { var tok = state.local.endToken || null; state.local = state.localState = null; return tok; } else { var tok = state.local.mode.token(stream, state.localState), m; if (state.local.endScan && (m = state.local.endScan.exec(stream.current()))) stream.pos = stream.start + m.index; return tok; } } var curState = states[state.state]; for (var i = 0; i < curState.length; i++) { var rule = curState[i]; var matches = (!rule.data.sol || stream.sol()) && stream.match(rule.regex); if (matches) { if (rule.data.next) { state.state = rule.data.next; } else if (rule.data.push) { (state.stack || (state.stack = [])).push(state.state); state.state = rule.data.push; } else if (rule.data.pop && state.stack && state.stack.length) { state.state = state.stack.pop(); } if (rule.data.mode) enterLocalMode(config, state, rule.data.mode, rule.token); if (rule.data.indent) state.indent.push(stream.indentation() + config.indentUnit); if (rule.data.dedent) state.indent.pop(); var token = rule.token if (token && token.apply) token = token(matches) if (matches.length > 2 && rule.token && typeof rule.token != "string") { state.pending = []; for (var j = 2; j < matches.length; j++) if (matches[j]) state.pending.push({text: matches[j], token: rule.token[j - 1]}); stream.backUp(matches[0].length - (matches[1] ? matches[1].length : 0)); return token[0]; } else if (token && token.join) { return token[0]; } else { return token; } } } stream.next(); return null; }; } function cmp(a, b) { if (a === b) return true; if (!a || typeof a != "object" || !b || typeof b != "object") return false; var props = 0; for (var prop in a) if (a.hasOwnProperty(prop)) { if (!b.hasOwnProperty(prop) || !cmp(a[prop], b[prop])) return false; props++; } for (var prop in b) if (b.hasOwnProperty(prop)) props--; return props == 0; } function enterLocalMode(config, state, spec, token) { var pers; if (spec.persistent) for (var p = state.persistentStates; p && !pers; p = p.next) if (spec.spec ? cmp(spec.spec, p.spec) : spec.mode == p.mode) pers = p; var mode = pers ? pers.mode : spec.mode || CodeMirror.getMode(config, spec.spec); var lState = pers ? pers.state : CodeMirror.startState(mode); if (spec.persistent && !pers) state.persistentStates = {mode: mode, spec: spec.spec, state: lState, next: state.persistentStates}; state.localState = lState; state.local = {mode: mode, end: spec.end && toRegex(spec.end), endScan: spec.end && spec.forceEnd !== false && toRegex(spec.end, false), endToken: token && token.join ? token[token.length - 1] : token}; } function indexOf(val, arr) { for (var i = 0; i < arr.length; i++) if (arr[i] === val) return true; } function indentFunction(states, meta) { return function(state, textAfter, line) { if (state.local && state.local.mode.indent) return state.local.mode.indent(state.localState, textAfter, line); if (state.indent == null || state.local || meta.dontIndentStates && indexOf(state.state, meta.dontIndentStates) > -1) return CodeMirror.Pass; var pos = state.indent.length - 1, rules = states[state.state]; scan: for (;;) { for (var i = 0; i < rules.length; i++) { var rule = rules[i]; if (rule.data.dedent && rule.data.dedentIfLineStart !== false) { var m = rule.regex.exec(textAfter); if (m && m[0]) { pos--; if (rule.next || rule.push) rules = states[rule.next || rule.push]; textAfter = textAfter.slice(m[0].length); continue scan; } } } break; } return pos < 0 ? 0 : state.indent[pos]; }; } }); /* ---- extension/sublime.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // A rough approximation of Sublime Text's keybindings // Depends on addon/search/searchcursor.js and optionally addon/dialog/dialogs.js (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../lib/codemirror"), require("../addon/search/searchcursor"), require("../addon/edit/matchbrackets")); else if (typeof define == "function" && define.amd) // AMD define(["../lib/codemirror", "../addon/search/searchcursor", "../addon/edit/matchbrackets"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var cmds = CodeMirror.commands; var Pos = CodeMirror.Pos; // This is not exactly Sublime's algorithm. I couldn't make heads or tails of that. function findPosSubword(doc, start, dir) { if (dir < 0 && start.ch == 0) return doc.clipPos(Pos(start.line - 1)); var line = doc.getLine(start.line); if (dir > 0 && start.ch >= line.length) return doc.clipPos(Pos(start.line + 1, 0)); var state = "start", type, startPos = start.ch; for (var pos = startPos, e = dir < 0 ? 0 : line.length, i = 0; pos != e; pos += dir, i++) { var next = line.charAt(dir < 0 ? pos - 1 : pos); var cat = next != "_" && CodeMirror.isWordChar(next) ? "w" : "o"; if (cat == "w" && next.toUpperCase() == next) cat = "W"; if (state == "start") { if (cat != "o") { state = "in"; type = cat; } else startPos = pos + dir } else if (state == "in") { if (type != cat) { if (type == "w" && cat == "W" && dir < 0) pos--; if (type == "W" && cat == "w" && dir > 0) { // From uppercase to lowercase if (pos == startPos + 1) { type = "w"; continue; } else pos--; } break; } } } return Pos(start.line, pos); } function moveSubword(cm, dir) { cm.extendSelectionsBy(function(range) { if (cm.display.shift || cm.doc.extend || range.empty()) return findPosSubword(cm.doc, range.head, dir); else return dir < 0 ? range.from() : range.to(); }); } cmds.goSubwordLeft = function(cm) { moveSubword(cm, -1); }; cmds.goSubwordRight = function(cm) { moveSubword(cm, 1); }; cmds.scrollLineUp = function(cm) { var info = cm.getScrollInfo(); if (!cm.somethingSelected()) { var visibleBottomLine = cm.lineAtHeight(info.top + info.clientHeight, "local"); if (cm.getCursor().line >= visibleBottomLine) cm.execCommand("goLineUp"); } cm.scrollTo(null, info.top - cm.defaultTextHeight()); }; cmds.scrollLineDown = function(cm) { var info = cm.getScrollInfo(); if (!cm.somethingSelected()) { var visibleTopLine = cm.lineAtHeight(info.top, "local")+1; if (cm.getCursor().line <= visibleTopLine) cm.execCommand("goLineDown"); } cm.scrollTo(null, info.top + cm.defaultTextHeight()); }; cmds.splitSelectionByLine = function(cm) { var ranges = cm.listSelections(), lineRanges = []; for (var i = 0; i < ranges.length; i++) { var from = ranges[i].from(), to = ranges[i].to(); for (var line = from.line; line <= to.line; ++line) if (!(to.line > from.line && line == to.line && to.ch == 0)) lineRanges.push({anchor: line == from.line ? from : Pos(line, 0), head: line == to.line ? to : Pos(line)}); } cm.setSelections(lineRanges, 0); }; cmds.singleSelectionTop = function(cm) { var range = cm.listSelections()[0]; cm.setSelection(range.anchor, range.head, {scroll: false}); }; cmds.selectLine = function(cm) { var ranges = cm.listSelections(), extended = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; extended.push({anchor: Pos(range.from().line, 0), head: Pos(range.to().line + 1, 0)}); } cm.setSelections(extended); }; function insertLine(cm, above) { if (cm.isReadOnly()) return CodeMirror.Pass cm.operation(function() { var len = cm.listSelections().length, newSelection = [], last = -1; for (var i = 0; i < len; i++) { var head = cm.listSelections()[i].head; if (head.line <= last) continue; var at = Pos(head.line + (above ? 0 : 1), 0); cm.replaceRange("\n", at, null, "+insertLine"); cm.indentLine(at.line, null, true); newSelection.push({head: at, anchor: at}); last = head.line + 1; } cm.setSelections(newSelection); }); cm.execCommand("indentAuto"); } cmds.insertLineAfter = function(cm) { return insertLine(cm, false); }; cmds.insertLineBefore = function(cm) { return insertLine(cm, true); }; function wordAt(cm, pos) { var start = pos.ch, end = start, line = cm.getLine(pos.line); while (start && CodeMirror.isWordChar(line.charAt(start - 1))) --start; while (end < line.length && CodeMirror.isWordChar(line.charAt(end))) ++end; return {from: Pos(pos.line, start), to: Pos(pos.line, end), word: line.slice(start, end)}; } cmds.selectNextOccurrence = function(cm) { var from = cm.getCursor("from"), to = cm.getCursor("to"); var fullWord = cm.state.sublimeFindFullWord == cm.doc.sel; if (CodeMirror.cmpPos(from, to) == 0) { var word = wordAt(cm, from); if (!word.word) return; cm.setSelection(word.from, word.to); fullWord = true; } else { var text = cm.getRange(from, to); var query = fullWord ? new RegExp("\\b" + text + "\\b") : text; var cur = cm.getSearchCursor(query, to); var found = cur.findNext(); if (!found) { cur = cm.getSearchCursor(query, Pos(cm.firstLine(), 0)); found = cur.findNext(); } if (!found || isSelectedRange(cm.listSelections(), cur.from(), cur.to())) return cm.addSelection(cur.from(), cur.to()); } if (fullWord) cm.state.sublimeFindFullWord = cm.doc.sel; }; cmds.skipAndSelectNextOccurrence = function(cm) { var prevAnchor = cm.getCursor("anchor"), prevHead = cm.getCursor("head"); cmds.selectNextOccurrence(cm); if (CodeMirror.cmpPos(prevAnchor, prevHead) != 0) { cm.doc.setSelections(cm.doc.listSelections() .filter(function (sel) { return sel.anchor != prevAnchor || sel.head != prevHead; })); } } function addCursorToSelection(cm, dir) { var ranges = cm.listSelections(), newRanges = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; var newAnchor = cm.findPosV( range.anchor, dir, "line", range.anchor.goalColumn); var newHead = cm.findPosV( range.head, dir, "line", range.head.goalColumn); newAnchor.goalColumn = range.anchor.goalColumn != null ? range.anchor.goalColumn : cm.cursorCoords(range.anchor, "div").left; newHead.goalColumn = range.head.goalColumn != null ? range.head.goalColumn : cm.cursorCoords(range.head, "div").left; var newRange = {anchor: newAnchor, head: newHead}; newRanges.push(range); newRanges.push(newRange); } cm.setSelections(newRanges); } cmds.addCursorToPrevLine = function(cm) { addCursorToSelection(cm, -1); }; cmds.addCursorToNextLine = function(cm) { addCursorToSelection(cm, 1); }; function isSelectedRange(ranges, from, to) { for (var i = 0; i < ranges.length; i++) if (CodeMirror.cmpPos(ranges[i].from(), from) == 0 && CodeMirror.cmpPos(ranges[i].to(), to) == 0) return true return false } var mirror = "(){}[]"; function selectBetweenBrackets(cm) { var ranges = cm.listSelections(), newRanges = [] for (var i = 0; i < ranges.length; i++) { var range = ranges[i], pos = range.head, opening = cm.scanForBracket(pos, -1); if (!opening) return false; for (;;) { var closing = cm.scanForBracket(pos, 1); if (!closing) return false; if (closing.ch == mirror.charAt(mirror.indexOf(opening.ch) + 1)) { var startPos = Pos(opening.pos.line, opening.pos.ch + 1); if (CodeMirror.cmpPos(startPos, range.from()) == 0 && CodeMirror.cmpPos(closing.pos, range.to()) == 0) { opening = cm.scanForBracket(opening.pos, -1); if (!opening) return false; } else { newRanges.push({anchor: startPos, head: closing.pos}); break; } } pos = Pos(closing.pos.line, closing.pos.ch + 1); } } cm.setSelections(newRanges); return true; } cmds.selectScope = function(cm) { selectBetweenBrackets(cm) || cm.execCommand("selectAll"); }; cmds.selectBetweenBrackets = function(cm) { if (!selectBetweenBrackets(cm)) return CodeMirror.Pass; }; function puncType(type) { return !type ? null : /\bpunctuation\b/.test(type) ? type : undefined } cmds.goToBracket = function(cm) { cm.extendSelectionsBy(function(range) { var next = cm.scanForBracket(range.head, 1, puncType(cm.getTokenTypeAt(range.head))); if (next && CodeMirror.cmpPos(next.pos, range.head) != 0) return next.pos; var prev = cm.scanForBracket(range.head, -1, puncType(cm.getTokenTypeAt(Pos(range.head.line, range.head.ch + 1)))); return prev && Pos(prev.pos.line, prev.pos.ch + 1) || range.head; }); }; cmds.swapLineUp = function(cm) { if (cm.isReadOnly()) return CodeMirror.Pass var ranges = cm.listSelections(), linesToMove = [], at = cm.firstLine() - 1, newSels = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i], from = range.from().line - 1, to = range.to().line; newSels.push({anchor: Pos(range.anchor.line - 1, range.anchor.ch), head: Pos(range.head.line - 1, range.head.ch)}); if (range.to().ch == 0 && !range.empty()) --to; if (from > at) linesToMove.push(from, to); else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to; at = to; } cm.operation(function() { for (var i = 0; i < linesToMove.length; i += 2) { var from = linesToMove[i], to = linesToMove[i + 1]; var line = cm.getLine(from); cm.replaceRange("", Pos(from, 0), Pos(from + 1, 0), "+swapLine"); if (to > cm.lastLine()) cm.replaceRange("\n" + line, Pos(cm.lastLine()), null, "+swapLine"); else cm.replaceRange(line + "\n", Pos(to, 0), null, "+swapLine"); } cm.setSelections(newSels); cm.scrollIntoView(); }); }; cmds.swapLineDown = function(cm) { if (cm.isReadOnly()) return CodeMirror.Pass var ranges = cm.listSelections(), linesToMove = [], at = cm.lastLine() + 1; for (var i = ranges.length - 1; i >= 0; i--) { var range = ranges[i], from = range.to().line + 1, to = range.from().line; if (range.to().ch == 0 && !range.empty()) from--; if (from < at) linesToMove.push(from, to); else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to; at = to; } cm.operation(function() { for (var i = linesToMove.length - 2; i >= 0; i -= 2) { var from = linesToMove[i], to = linesToMove[i + 1]; var line = cm.getLine(from); if (from == cm.lastLine()) cm.replaceRange("", Pos(from - 1), Pos(from), "+swapLine"); else cm.replaceRange("", Pos(from, 0), Pos(from + 1, 0), "+swapLine"); cm.replaceRange(line + "\n", Pos(to, 0), null, "+swapLine"); } cm.scrollIntoView(); }); }; cmds.toggleCommentIndented = function(cm) { cm.toggleComment({ indent: true }); } cmds.joinLines = function(cm) { var ranges = cm.listSelections(), joined = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i], from = range.from(); var start = from.line, end = range.to().line; while (i < ranges.length - 1 && ranges[i + 1].from().line == end) end = ranges[++i].to().line; joined.push({start: start, end: end, anchor: !range.empty() && from}); } cm.operation(function() { var offset = 0, ranges = []; for (var i = 0; i < joined.length; i++) { var obj = joined[i]; var anchor = obj.anchor && Pos(obj.anchor.line - offset, obj.anchor.ch), head; for (var line = obj.start; line <= obj.end; line++) { var actual = line - offset; if (line == obj.end) head = Pos(actual, cm.getLine(actual).length + 1); if (actual < cm.lastLine()) { cm.replaceRange(" ", Pos(actual), Pos(actual + 1, /^\s*/.exec(cm.getLine(actual + 1))[0].length)); ++offset; } } ranges.push({anchor: anchor || head, head: head}); } cm.setSelections(ranges, 0); }); }; cmds.duplicateLine = function(cm) { cm.operation(function() { var rangeCount = cm.listSelections().length; for (var i = 0; i < rangeCount; i++) { var range = cm.listSelections()[i]; if (range.empty()) cm.replaceRange(cm.getLine(range.head.line) + "\n", Pos(range.head.line, 0)); else cm.replaceRange(cm.getRange(range.from(), range.to()), range.from()); } cm.scrollIntoView(); }); }; function sortLines(cm, caseSensitive) { if (cm.isReadOnly()) return CodeMirror.Pass var ranges = cm.listSelections(), toSort = [], selected; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; if (range.empty()) continue; var from = range.from().line, to = range.to().line; while (i < ranges.length - 1 && ranges[i + 1].from().line == to) to = ranges[++i].to().line; if (!ranges[i].to().ch) to--; toSort.push(from, to); } if (toSort.length) selected = true; else toSort.push(cm.firstLine(), cm.lastLine()); cm.operation(function() { var ranges = []; for (var i = 0; i < toSort.length; i += 2) { var from = toSort[i], to = toSort[i + 1]; var start = Pos(from, 0), end = Pos(to); var lines = cm.getRange(start, end, false); if (caseSensitive) lines.sort(); else lines.sort(function(a, b) { var au = a.toUpperCase(), bu = b.toUpperCase(); if (au != bu) { a = au; b = bu; } return a < b ? -1 : a == b ? 0 : 1; }); cm.replaceRange(lines, start, end); if (selected) ranges.push({anchor: start, head: Pos(to + 1, 0)}); } if (selected) cm.setSelections(ranges, 0); }); } cmds.sortLines = function(cm) { sortLines(cm, true); }; cmds.sortLinesInsensitive = function(cm) { sortLines(cm, false); }; cmds.nextBookmark = function(cm) { var marks = cm.state.sublimeBookmarks; if (marks) while (marks.length) { var current = marks.shift(); var found = current.find(); if (found) { marks.push(current); return cm.setSelection(found.from, found.to); } } }; cmds.prevBookmark = function(cm) { var marks = cm.state.sublimeBookmarks; if (marks) while (marks.length) { marks.unshift(marks.pop()); var found = marks[marks.length - 1].find(); if (!found) marks.pop(); else return cm.setSelection(found.from, found.to); } }; cmds.toggleBookmark = function(cm) { var ranges = cm.listSelections(); var marks = cm.state.sublimeBookmarks || (cm.state.sublimeBookmarks = []); for (var i = 0; i < ranges.length; i++) { var from = ranges[i].from(), to = ranges[i].to(); var found = ranges[i].empty() ? cm.findMarksAt(from) : cm.findMarks(from, to); for (var j = 0; j < found.length; j++) { if (found[j].sublimeBookmark) { found[j].clear(); for (var k = 0; k < marks.length; k++) if (marks[k] == found[j]) marks.splice(k--, 1); break; } } if (j == found.length) marks.push(cm.markText(from, to, {sublimeBookmark: true, clearWhenEmpty: false})); } }; cmds.clearBookmarks = function(cm) { var marks = cm.state.sublimeBookmarks; if (marks) for (var i = 0; i < marks.length; i++) marks[i].clear(); marks.length = 0; }; cmds.selectBookmarks = function(cm) { var marks = cm.state.sublimeBookmarks, ranges = []; if (marks) for (var i = 0; i < marks.length; i++) { var found = marks[i].find(); if (!found) marks.splice(i--, 0); else ranges.push({anchor: found.from, head: found.to}); } if (ranges.length) cm.setSelections(ranges, 0); }; function modifyWordOrSelection(cm, mod) { cm.operation(function() { var ranges = cm.listSelections(), indices = [], replacements = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; if (range.empty()) { indices.push(i); replacements.push(""); } else replacements.push(mod(cm.getRange(range.from(), range.to()))); } cm.replaceSelections(replacements, "around", "case"); for (var i = indices.length - 1, at; i >= 0; i--) { var range = ranges[indices[i]]; if (at && CodeMirror.cmpPos(range.head, at) > 0) continue; var word = wordAt(cm, range.head); at = word.from; cm.replaceRange(mod(word.word), word.from, word.to); } }); } cmds.smartBackspace = function(cm) { if (cm.somethingSelected()) return CodeMirror.Pass; cm.operation(function() { var cursors = cm.listSelections(); var indentUnit = cm.getOption("indentUnit"); for (var i = cursors.length - 1; i >= 0; i--) { var cursor = cursors[i].head; var toStartOfLine = cm.getRange({line: cursor.line, ch: 0}, cursor); var column = CodeMirror.countColumn(toStartOfLine, null, cm.getOption("tabSize")); // Delete by one character by default var deletePos = cm.findPosH(cursor, -1, "char", false); if (toStartOfLine && !/\S/.test(toStartOfLine) && column % indentUnit == 0) { var prevIndent = new Pos(cursor.line, CodeMirror.findColumn(toStartOfLine, column - indentUnit, indentUnit)); // Smart delete only if we found a valid prevIndent location if (prevIndent.ch != cursor.ch) deletePos = prevIndent; } cm.replaceRange("", deletePos, cursor, "+delete"); } }); }; cmds.delLineRight = function(cm) { cm.operation(function() { var ranges = cm.listSelections(); for (var i = ranges.length - 1; i >= 0; i--) cm.replaceRange("", ranges[i].anchor, Pos(ranges[i].to().line), "+delete"); cm.scrollIntoView(); }); }; cmds.upcaseAtCursor = function(cm) { modifyWordOrSelection(cm, function(str) { return str.toUpperCase(); }); }; cmds.downcaseAtCursor = function(cm) { modifyWordOrSelection(cm, function(str) { return str.toLowerCase(); }); }; cmds.setSublimeMark = function(cm) { if (cm.state.sublimeMark) cm.state.sublimeMark.clear(); cm.state.sublimeMark = cm.setBookmark(cm.getCursor()); }; cmds.selectToSublimeMark = function(cm) { var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); if (found) cm.setSelection(cm.getCursor(), found); }; cmds.deleteToSublimeMark = function(cm) { var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); if (found) { var from = cm.getCursor(), to = found; if (CodeMirror.cmpPos(from, to) > 0) { var tmp = to; to = from; from = tmp; } cm.state.sublimeKilled = cm.getRange(from, to); cm.replaceRange("", from, to); } }; cmds.swapWithSublimeMark = function(cm) { var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); if (found) { cm.state.sublimeMark.clear(); cm.state.sublimeMark = cm.setBookmark(cm.getCursor()); cm.setCursor(found); } }; cmds.sublimeYank = function(cm) { if (cm.state.sublimeKilled != null) cm.replaceSelection(cm.state.sublimeKilled, null, "paste"); }; cmds.showInCenter = function(cm) { var pos = cm.cursorCoords(null, "local"); cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2); }; function getTarget(cm) { var from = cm.getCursor("from"), to = cm.getCursor("to"); if (CodeMirror.cmpPos(from, to) == 0) { var word = wordAt(cm, from); if (!word.word) return; from = word.from; to = word.to; } return {from: from, to: to, query: cm.getRange(from, to), word: word}; } function findAndGoTo(cm, forward) { var target = getTarget(cm); if (!target) return; var query = target.query; var cur = cm.getSearchCursor(query, forward ? target.to : target.from); if (forward ? cur.findNext() : cur.findPrevious()) { cm.setSelection(cur.from(), cur.to()); } else { cur = cm.getSearchCursor(query, forward ? Pos(cm.firstLine(), 0) : cm.clipPos(Pos(cm.lastLine()))); if (forward ? cur.findNext() : cur.findPrevious()) cm.setSelection(cur.from(), cur.to()); else if (target.word) cm.setSelection(target.from, target.to); } }; cmds.findUnder = function(cm) { findAndGoTo(cm, true); }; cmds.findUnderPrevious = function(cm) { findAndGoTo(cm,false); }; cmds.findAllUnder = function(cm) { var target = getTarget(cm); if (!target) return; var cur = cm.getSearchCursor(target.query); var matches = []; var primaryIndex = -1; while (cur.findNext()) { matches.push({anchor: cur.from(), head: cur.to()}); if (cur.from().line <= target.from.line && cur.from().ch <= target.from.ch) primaryIndex++; } cm.setSelections(matches, primaryIndex); }; var keyMap = CodeMirror.keyMap; keyMap.macSublime = { "Cmd-Left": "goLineStartSmart", "Shift-Tab": "indentLess", "Shift-Ctrl-K": "deleteLine", "Alt-Q": "wrapLines", "Ctrl-Left": "goSubwordLeft", "Ctrl-Right": "goSubwordRight", "Ctrl-Alt-Up": "scrollLineUp", "Ctrl-Alt-Down": "scrollLineDown", "Cmd-L": "selectLine", "Shift-Cmd-L": "splitSelectionByLine", "Esc": "singleSelectionTop", "Cmd-Enter": "insertLineAfter", "Shift-Cmd-Enter": "insertLineBefore", "Cmd-D": "selectNextOccurrence", "Shift-Cmd-Space": "selectScope", "Shift-Cmd-M": "selectBetweenBrackets", "Cmd-M": "goToBracket", "Cmd-Ctrl-Up": "swapLineUp", "Cmd-Ctrl-Down": "swapLineDown", "Cmd-/": "toggleCommentIndented", "Cmd-J": "joinLines", "Shift-Cmd-D": "duplicateLine", "F5": "sortLines", "Cmd-F5": "sortLinesInsensitive", "F2": "nextBookmark", "Shift-F2": "prevBookmark", "Cmd-F2": "toggleBookmark", "Shift-Cmd-F2": "clearBookmarks", "Alt-F2": "selectBookmarks", "Backspace": "smartBackspace", "Cmd-K Cmd-D": "skipAndSelectNextOccurrence", "Cmd-K Cmd-K": "delLineRight", "Cmd-K Cmd-U": "upcaseAtCursor", "Cmd-K Cmd-L": "downcaseAtCursor", "Cmd-K Cmd-Space": "setSublimeMark", "Cmd-K Cmd-A": "selectToSublimeMark", "Cmd-K Cmd-W": "deleteToSublimeMark", "Cmd-K Cmd-X": "swapWithSublimeMark", "Cmd-K Cmd-Y": "sublimeYank", "Cmd-K Cmd-C": "showInCenter", "Cmd-K Cmd-G": "clearBookmarks", "Cmd-K Cmd-Backspace": "delLineLeft", "Cmd-K Cmd-1": "foldAll", "Cmd-K Cmd-0": "unfoldAll", "Cmd-K Cmd-J": "unfoldAll", "Ctrl-Shift-Up": "addCursorToPrevLine", "Ctrl-Shift-Down": "addCursorToNextLine", "Cmd-F3": "findUnder", "Shift-Cmd-F3": "findUnderPrevious", "Alt-F3": "findAllUnder", "Shift-Cmd-[": "fold", "Shift-Cmd-]": "unfold", "Cmd-I": "findIncremental", "Shift-Cmd-I": "findIncrementalReverse", "Cmd-H": "replace", "F3": "findNext", "Shift-F3": "findPrev", "fallthrough": "macDefault" }; CodeMirror.normalizeKeyMap(keyMap.macSublime); keyMap.pcSublime = { "Shift-Tab": "indentLess", "Shift-Ctrl-K": "deleteLine", "Alt-Q": "wrapLines", "Ctrl-T": "transposeChars", "Alt-Left": "goSubwordLeft", "Alt-Right": "goSubwordRight", "Ctrl-Up": "scrollLineUp", "Ctrl-Down": "scrollLineDown", "Ctrl-L": "selectLine", "Shift-Ctrl-L": "splitSelectionByLine", "Esc": "singleSelectionTop", "Ctrl-Enter": "insertLineAfter", "Shift-Ctrl-Enter": "insertLineBefore", "Ctrl-D": "selectNextOccurrence", "Shift-Ctrl-Space": "selectScope", "Shift-Ctrl-M": "selectBetweenBrackets", "Ctrl-M": "goToBracket", "Shift-Ctrl-Up": "swapLineUp", "Shift-Ctrl-Down": "swapLineDown", "Ctrl-/": "toggleCommentIndented", "Ctrl-J": "joinLines", "Shift-Ctrl-D": "duplicateLine", "F9": "sortLines", "Ctrl-F9": "sortLinesInsensitive", "F2": "nextBookmark", "Shift-F2": "prevBookmark", "Ctrl-F2": "toggleBookmark", "Shift-Ctrl-F2": "clearBookmarks", "Alt-F2": "selectBookmarks", "Backspace": "smartBackspace", "Ctrl-K Ctrl-D": "skipAndSelectNextOccurrence", "Ctrl-K Ctrl-K": "delLineRight", "Ctrl-K Ctrl-U": "upcaseAtCursor", "Ctrl-K Ctrl-L": "downcaseAtCursor", "Ctrl-K Ctrl-Space": "setSublimeMark", "Ctrl-K Ctrl-A": "selectToSublimeMark", "Ctrl-K Ctrl-W": "deleteToSublimeMark", "Ctrl-K Ctrl-X": "swapWithSublimeMark", "Ctrl-K Ctrl-Y": "sublimeYank", "Ctrl-K Ctrl-C": "showInCenter", "Ctrl-K Ctrl-G": "clearBookmarks", "Ctrl-K Ctrl-Backspace": "delLineLeft", "Ctrl-K Ctrl-1": "foldAll", "Ctrl-K Ctrl-0": "unfoldAll", "Ctrl-K Ctrl-J": "unfoldAll", "Ctrl-Alt-Up": "addCursorToPrevLine", "Ctrl-Alt-Down": "addCursorToNextLine", "Ctrl-F3": "findUnder", "Shift-Ctrl-F3": "findUnderPrevious", "Alt-F3": "findAllUnder", "Shift-Ctrl-[": "fold", "Shift-Ctrl-]": "unfold", "Ctrl-I": "findIncremental", "Shift-Ctrl-I": "findIncrementalReverse", "Ctrl-H": "replace", "F3": "findNext", "Shift-F3": "findPrev", "fallthrough": "pcDefault" }; CodeMirror.normalizeKeyMap(keyMap.pcSublime); var mac = keyMap.default == keyMap.macDefault; keyMap.sublime = mac ? keyMap.macSublime : keyMap.pcSublime; }); /* ---- extension/dialog/dialog.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // Open simple dialogs on top of an editor. Relies on dialog.css. (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { function dialogDiv(cm, template, bottom) { var wrap = cm.getWrapperElement(); var dialog; dialog = wrap.appendChild(document.createElement("div")); if (bottom) dialog.className = "CodeMirror-dialog CodeMirror-dialog-bottom"; else dialog.className = "CodeMirror-dialog CodeMirror-dialog-top"; if (typeof template == "string") { dialog.innerHTML = template; } else { // Assuming it's a detached DOM element. dialog.appendChild(template); } CodeMirror.addClass(wrap, 'dialog-opened'); return dialog; } function closeNotification(cm, newVal) { if (cm.state.currentNotificationClose) cm.state.currentNotificationClose(); cm.state.currentNotificationClose = newVal; } CodeMirror.defineExtension("openDialog", function(template, callback, options) { if (!options) options = {}; closeNotification(this, null); var dialog = dialogDiv(this, template, options.bottom); var closed = false, me = this; function close(newVal) { if (typeof newVal == 'string') { inp.value = newVal; } else { if (closed) return; closed = true; CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); dialog.parentNode.removeChild(dialog); me.focus(); if (options.onClose) options.onClose(dialog); } } var inp = dialog.getElementsByTagName("input")[0], button; if (inp) { inp.focus(); if (options.value) { inp.value = options.value; if (options.selectValueOnOpen !== false) { inp.select(); } } if (options.onInput) CodeMirror.on(inp, "input", function(e) { options.onInput(e, inp.value, close);}); if (options.onKeyUp) CodeMirror.on(inp, "keyup", function(e) {options.onKeyUp(e, inp.value, close);}); CodeMirror.on(inp, "keydown", function(e) { if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; } if (e.keyCode == 27 || (options.closeOnEnter !== false && e.keyCode == 13)) { inp.blur(); CodeMirror.e_stop(e); close(); } if (e.keyCode == 13) callback(inp.value, e); }); if (options.closeOnBlur !== false) CodeMirror.on(dialog, "focusout", function (evt) { if (evt.relatedTarget !== null) close(); }); } else if (button = dialog.getElementsByTagName("button")[0]) { CodeMirror.on(button, "click", function() { close(); me.focus(); }); if (options.closeOnBlur !== false) CodeMirror.on(button, "blur", close); button.focus(); } return close; }); CodeMirror.defineExtension("openConfirm", function(template, callbacks, options) { closeNotification(this, null); var dialog = dialogDiv(this, template, options && options.bottom); var buttons = dialog.getElementsByTagName("button"); var closed = false, me = this, blurring = 1; function close() { if (closed) return; closed = true; CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); dialog.parentNode.removeChild(dialog); me.focus(); } buttons[0].focus(); for (var i = 0; i < buttons.length; ++i) { var b = buttons[i]; (function(callback) { CodeMirror.on(b, "click", function(e) { CodeMirror.e_preventDefault(e); close(); if (callback) callback(me); }); })(callbacks[i]); CodeMirror.on(b, "blur", function() { --blurring; setTimeout(function() { if (blurring <= 0) close(); }, 200); }); CodeMirror.on(b, "focus", function() { ++blurring; }); } }); /* * openNotification * Opens a notification, that can be closed with an optional timer * (default 5000ms timer) and always closes on click. * * If a notification is opened while another is opened, it will close the * currently opened one and open the new one immediately. */ CodeMirror.defineExtension("openNotification", function(template, options) { closeNotification(this, close); var dialog = dialogDiv(this, template, options && options.bottom); var closed = false, doneTimer; var duration = options && typeof options.duration !== "undefined" ? options.duration : 5000; function close() { if (closed) return; closed = true; clearTimeout(doneTimer); CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); dialog.parentNode.removeChild(dialog); } CodeMirror.on(dialog, 'click', function(e) { CodeMirror.e_preventDefault(e); close(); }); if (duration) doneTimer = setTimeout(close, duration); return close; }); }); /* ---- extension/edit/closebrackets.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { var defaults = { pairs: "()[]{}''\"\"", closeBefore: ")]}'\":;>", triples: "", explode: "[]{}" }; var Pos = CodeMirror.Pos; CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { cm.removeKeyMap(keyMap); cm.state.closeBrackets = null; } if (val) { ensureBound(getOption(val, "pairs")) cm.state.closeBrackets = val; cm.addKeyMap(keyMap); } }); function getOption(conf, name) { if (name == "pairs" && typeof conf == "string") return conf; if (typeof conf == "object" && conf[name] != null) return conf[name]; return defaults[name]; } var keyMap = {Backspace: handleBackspace, Enter: handleEnter}; function ensureBound(chars) { for (var i = 0; i < chars.length; i++) { var ch = chars.charAt(i), key = "'" + ch + "'" if (!keyMap[key]) keyMap[key] = handler(ch) } } ensureBound(defaults.pairs + "`") function handler(ch) { return function(cm) { return handleChar(cm, ch); }; } function getConfig(cm) { var deflt = cm.state.closeBrackets; if (!deflt || deflt.override) return deflt; var mode = cm.getModeAt(cm.getCursor()); return mode.closeBrackets || deflt; } function handleBackspace(cm) { var conf = getConfig(cm); if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass; var pairs = getOption(conf, "pairs"); var ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) { if (!ranges[i].empty()) return CodeMirror.Pass; var around = charsAround(cm, ranges[i].head); if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass; } for (var i = ranges.length - 1; i >= 0; i--) { var cur = ranges[i].head; cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1), "+delete"); } } function handleEnter(cm) { var conf = getConfig(cm); var explode = conf && getOption(conf, "explode"); if (!explode || cm.getOption("disableInput")) return CodeMirror.Pass; var ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) { if (!ranges[i].empty()) return CodeMirror.Pass; var around = charsAround(cm, ranges[i].head); if (!around || explode.indexOf(around) % 2 != 0) return CodeMirror.Pass; } cm.operation(function() { var linesep = cm.lineSeparator() || "\n"; cm.replaceSelection(linesep + linesep, null); cm.execCommand("goCharLeft"); ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) { var line = ranges[i].head.line; cm.indentLine(line, null, true); cm.indentLine(line + 1, null, true); } }); } function contractSelection(sel) { var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0; return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)), head: new Pos(sel.head.line, sel.head.ch + (inverted ? 1 : -1))}; } function handleChar(cm, ch) { var conf = getConfig(cm); if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass; var pairs = getOption(conf, "pairs"); var pos = pairs.indexOf(ch); if (pos == -1) return CodeMirror.Pass; var closeBefore = getOption(conf,"closeBefore"); var triples = getOption(conf, "triples"); var identical = pairs.charAt(pos + 1) == ch; var ranges = cm.listSelections(); var opening = pos % 2 == 0; var type; for (var i = 0; i < ranges.length; i++) { var range = ranges[i], cur = range.head, curType; var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1)); if (opening && !range.empty()) { curType = "surround"; } else if ((identical || !opening) && next == ch) { if (identical && stringStartsAfter(cm, cur)) curType = "both"; else if (triples.indexOf(ch) >= 0 && cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == ch + ch + ch) curType = "skipThree"; else curType = "skip"; } else if (identical && cur.ch > 1 && triples.indexOf(ch) >= 0 && cm.getRange(Pos(cur.line, cur.ch - 2), cur) == ch + ch) { if (cur.ch > 2 && /\bstring/.test(cm.getTokenTypeAt(Pos(cur.line, cur.ch - 2)))) return CodeMirror.Pass; curType = "addFour"; } else if (identical) { var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur) if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both"; else return CodeMirror.Pass; } else if (opening && (next.length === 0 || /\s/.test(next) || closeBefore.indexOf(next) > -1)) { curType = "both"; } else { return CodeMirror.Pass; } if (!type) type = curType; else if (type != curType) return CodeMirror.Pass; } var left = pos % 2 ? pairs.charAt(pos - 1) : ch; var right = pos % 2 ? ch : pairs.charAt(pos + 1); cm.operation(function() { if (type == "skip") { cm.execCommand("goCharRight"); } else if (type == "skipThree") { for (var i = 0; i < 3; i++) cm.execCommand("goCharRight"); } else if (type == "surround") { var sels = cm.getSelections(); for (var i = 0; i < sels.length; i++) sels[i] = left + sels[i] + right; cm.replaceSelections(sels, "around"); sels = cm.listSelections().slice(); for (var i = 0; i < sels.length; i++) sels[i] = contractSelection(sels[i]); cm.setSelections(sels); } else if (type == "both") { cm.replaceSelection(left + right, null); cm.triggerElectric(left + right); cm.execCommand("goCharLeft"); } else if (type == "addFour") { cm.replaceSelection(left + left + left + left, "before"); cm.execCommand("goCharRight"); } }); } function charsAround(cm, pos) { var str = cm.getRange(Pos(pos.line, pos.ch - 1), Pos(pos.line, pos.ch + 1)); return str.length == 2 ? str : null; } function stringStartsAfter(cm, pos) { var token = cm.getTokenAt(Pos(pos.line, pos.ch + 1)) return /\bstring/.test(token.type) && token.start == pos.ch && (pos.ch == 0 || !/\bstring/.test(cm.getTokenTypeAt(pos))) } }); /* ---- extension/edit/closetag.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE /** * Tag-closer extension for CodeMirror. * * This extension adds an "autoCloseTags" option that can be set to * either true to get the default behavior, or an object to further * configure its behavior. * * These are supported options: * * `whenClosing` (default true) * Whether to autoclose when the '/' of a closing tag is typed. * `whenOpening` (default true) * Whether to autoclose the tag when the final '>' of an opening * tag is typed. * `dontCloseTags` (default is empty tags for HTML, none for XML) * An array of tag names that should not be autoclosed. * `indentTags` (default is block tags for HTML, none for XML) * An array of tag names that should, when opened, cause a * blank line to be added inside the tag, and the blank line and * closing line to be indented. * `emptyTags` (default is none) * An array of XML tag names that should be autoclosed with '/>'. * * See demos/closetag.html for a usage example. */ (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../fold/xml-fold")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../fold/xml-fold"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { CodeMirror.defineOption("autoCloseTags", false, function(cm, val, old) { if (old != CodeMirror.Init && old) cm.removeKeyMap("autoCloseTags"); if (!val) return; var map = {name: "autoCloseTags"}; if (typeof val != "object" || val.whenClosing !== false) map["'/'"] = function(cm) { return autoCloseSlash(cm); }; if (typeof val != "object" || val.whenOpening !== false) map["'>'"] = function(cm) { return autoCloseGT(cm); }; cm.addKeyMap(map); }); var htmlDontClose = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]; var htmlIndent = ["applet", "blockquote", "body", "button", "div", "dl", "fieldset", "form", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head", "html", "iframe", "layer", "legend", "object", "ol", "p", "select", "table", "ul"]; function autoCloseGT(cm) { if (cm.getOption("disableInput")) return CodeMirror.Pass; var ranges = cm.listSelections(), replacements = []; var opt = cm.getOption("autoCloseTags"); for (var i = 0; i < ranges.length; i++) { if (!ranges[i].empty()) return CodeMirror.Pass; var pos = ranges[i].head, tok = cm.getTokenAt(pos); var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state; var tagInfo = inner.mode.xmlCurrentTag && inner.mode.xmlCurrentTag(state) var tagName = tagInfo && tagInfo.name if (!tagName) return CodeMirror.Pass var html = inner.mode.configuration == "html"; var dontCloseTags = (typeof opt == "object" && opt.dontCloseTags) || (html && htmlDontClose); var indentTags = (typeof opt == "object" && opt.indentTags) || (html && htmlIndent); if (tok.end > pos.ch) tagName = tagName.slice(0, tagName.length - tok.end + pos.ch); var lowerTagName = tagName.toLowerCase(); // Don't process the '>' at the end of an end-tag or self-closing tag if (!tagName || tok.type == "string" && (tok.end != pos.ch || !/[\"\']/.test(tok.string.charAt(tok.string.length - 1)) || tok.string.length == 1) || tok.type == "tag" && tagInfo.close || tok.string.indexOf("/") == (pos.ch - tok.start - 1) || // match something like dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1 || closingTagExists(cm, inner.mode.xmlCurrentContext && inner.mode.xmlCurrentContext(state) || [], tagName, pos, true)) return CodeMirror.Pass; var emptyTags = typeof opt == "object" && opt.emptyTags; if (emptyTags && indexOf(emptyTags, tagName) > -1) { replacements[i] = { text: "/>", newPos: CodeMirror.Pos(pos.line, pos.ch + 2) }; continue; } var indent = indentTags && indexOf(indentTags, lowerTagName) > -1; replacements[i] = {indent: indent, text: ">" + (indent ? "\n\n" : "") + "", newPos: indent ? CodeMirror.Pos(pos.line + 1, 0) : CodeMirror.Pos(pos.line, pos.ch + 1)}; } var dontIndentOnAutoClose = (typeof opt == "object" && opt.dontIndentOnAutoClose); for (var i = ranges.length - 1; i >= 0; i--) { var info = replacements[i]; cm.replaceRange(info.text, ranges[i].head, ranges[i].anchor, "+insert"); var sel = cm.listSelections().slice(0); sel[i] = {head: info.newPos, anchor: info.newPos}; cm.setSelections(sel); if (!dontIndentOnAutoClose && info.indent) { cm.indentLine(info.newPos.line, null, true); cm.indentLine(info.newPos.line + 1, null, true); } } } function autoCloseCurrent(cm, typingSlash) { var ranges = cm.listSelections(), replacements = []; var head = typingSlash ? "/" : "") replacement += ">"; replacements[i] = replacement; } cm.replaceSelections(replacements); ranges = cm.listSelections(); if (!dontIndentOnAutoClose) { for (var i = 0; i < ranges.length; i++) if (i == ranges.length - 1 || ranges[i].head.line < ranges[i + 1].head.line) cm.indentLine(ranges[i].head.line); } } function autoCloseSlash(cm) { if (cm.getOption("disableInput")) return CodeMirror.Pass; return autoCloseCurrent(cm, true); } CodeMirror.commands.closeTag = function(cm) { return autoCloseCurrent(cm); }; function indexOf(collection, elt) { if (collection.indexOf) return collection.indexOf(elt); for (var i = 0, e = collection.length; i < e; ++i) if (collection[i] == elt) return i; return -1; } // If xml-fold is loaded, we use its functionality to try and verify // whether a given tag is actually unclosed. function closingTagExists(cm, context, tagName, pos, newTag) { if (!CodeMirror.scanForClosingTag) return false; var end = Math.min(cm.lastLine() + 1, pos.line + 500); var nextClose = CodeMirror.scanForClosingTag(cm, pos, null, end); if (!nextClose || nextClose.tag != tagName) return false; // If the immediate wrapping context contains onCx instances of // the same tag, a closing tag only exists if there are at least // that many closing tags of that type following. var onCx = newTag ? 1 : 0 for (var i = context.length - 1; i >= 0; i--) { if (context[i] == tagName) ++onCx else break } pos = nextClose.to; for (var i = 1; i < onCx; i++) { var next = CodeMirror.scanForClosingTag(cm, pos, null, end); if (!next || next.tag != tagName) return false; pos = next.to; } return true; } }); /* ---- extension/edit/continuelist.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/, emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/, unorderedListRE = /[*+-]\s/; CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) { if (cm.getOption("disableInput")) return CodeMirror.Pass; var ranges = cm.listSelections(), replacements = []; for (var i = 0; i < ranges.length; i++) { var pos = ranges[i].head; // If we're not in Markdown mode, fall back to normal newlineAndIndent var eolState = cm.getStateAfter(pos.line); var inner = CodeMirror.innerMode(cm.getMode(), eolState); if (inner.mode.name !== "markdown") { cm.execCommand("newlineAndIndent"); return; } else { eolState = inner.state; } var inList = eolState.list !== false; var inQuote = eolState.quote !== 0; var line = cm.getLine(pos.line), match = listRE.exec(line); var cursorBeforeBullet = /^\s*$/.test(line.slice(0, pos.ch)); if (!ranges[i].empty() || (!inList && !inQuote) || !match || cursorBeforeBullet) { cm.execCommand("newlineAndIndent"); return; } if (emptyListRE.test(line)) { var endOfQuote = inQuote && />\s*$/.test(line) var endOfList = !/>\s*$/.test(line) if (endOfQuote || endOfList) cm.replaceRange("", { line: pos.line, ch: 0 }, { line: pos.line, ch: pos.ch + 1 }); replacements[i] = "\n"; } else { var indent = match[1], after = match[5]; var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0); var bullet = numbered ? (parseInt(match[3], 10) + 1) + match[4] : match[2].replace("x", " "); replacements[i] = "\n" + indent + bullet + after; if (numbered) incrementRemainingMarkdownListNumbers(cm, pos); } } cm.replaceSelections(replacements); }; // Auto-updating Markdown list numbers when a new item is added to the // middle of a list function incrementRemainingMarkdownListNumbers(cm, pos) { var startLine = pos.line, lookAhead = 0, skipCount = 0; var startItem = listRE.exec(cm.getLine(startLine)), startIndent = startItem[1]; do { lookAhead += 1; var nextLineNumber = startLine + lookAhead; var nextLine = cm.getLine(nextLineNumber), nextItem = listRE.exec(nextLine); if (nextItem) { var nextIndent = nextItem[1]; var newNumber = (parseInt(startItem[3], 10) + lookAhead - skipCount); var nextNumber = (parseInt(nextItem[3], 10)), itemNumber = nextNumber; if (startIndent === nextIndent && !isNaN(nextNumber)) { if (newNumber === nextNumber) itemNumber = nextNumber + 1; if (newNumber > nextNumber) itemNumber = newNumber + 1; cm.replaceRange( nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]), { line: nextLineNumber, ch: 0 }, { line: nextLineNumber, ch: nextLine.length }); } else { if (startIndent.length > nextIndent.length) return; // This doesn't run if the next line immediatley indents, as it is // not clear of the users intention (new indented item or same level) if ((startIndent.length < nextIndent.length) && (lookAhead === 1)) return; skipCount += 1; } } } while (nextItem); } }); /* ---- extension/edit/matchbrackets.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { var ie_lt8 = /MSIE \d/.test(navigator.userAgent) && (document.documentMode == null || document.documentMode < 8); var Pos = CodeMirror.Pos; var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<", "<": ">>", ">": "<<"}; function bracketRegex(config) { return config && config.bracketRegex || /[(){}[\]]/ } function findMatchingBracket(cm, where, config) { var line = cm.getLineHandle(where.line), pos = where.ch - 1; var afterCursor = config && config.afterCursor if (afterCursor == null) afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className) var re = bracketRegex(config) // A cursor is defined as between two characters, but in in vim command mode // (i.e. not insert mode), the cursor is visually represented as a // highlighted box on top of the 2nd character. Otherwise, we allow matches // from before or after the cursor. var match = (!afterCursor && pos >= 0 && re.test(line.text.charAt(pos)) && matching[line.text.charAt(pos)]) || re.test(line.text.charAt(pos + 1)) && matching[line.text.charAt(++pos)]; if (!match) return null; var dir = match.charAt(1) == ">" ? 1 : -1; if (config && config.strict && (dir > 0) != (pos == where.ch)) return null; var style = cm.getTokenTypeAt(Pos(where.line, pos + 1)); var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config); if (found == null) return null; return {from: Pos(where.line, pos), to: found && found.pos, match: found && found.ch == match.charAt(0), forward: dir > 0}; } // bracketRegex is used to specify which type of bracket to scan // should be a regexp, e.g. /[[\]]/ // // Note: If "where" is on an open bracket, then this bracket is ignored. // // Returns false when no bracket was found, null when it reached // maxScanLines and gave up function scanForBracket(cm, where, dir, style, config) { var maxScanLen = (config && config.maxScanLineLength) || 10000; var maxScanLines = (config && config.maxScanLines) || 1000; var stack = []; var re = bracketRegex(config) var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1) : Math.max(cm.firstLine() - 1, where.line - maxScanLines); for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) { var line = cm.getLine(lineNo); if (!line) continue; var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1; if (line.length > maxScanLen) continue; if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0); for (; pos != end; pos += dir) { var ch = line.charAt(pos); if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) { var match = matching[ch]; if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch); else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch}; else stack.pop(); } } } return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null; } function matchBrackets(cm, autoclear, config) { // Disable brace matching in long lines, since it'll cause hugely slow updates var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000; var marks = [], ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) { var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config); if (match && cm.getLine(match.from.line).length <= maxHighlightLen) { var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket"; marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style})); if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen) marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style})); } } if (marks.length) { // Kludge to work around the IE bug from issue #1193, where text // input stops going to the textare whever this fires. if (ie_lt8 && cm.state.focused) cm.focus(); var clear = function() { cm.operation(function() { for (var i = 0; i < marks.length; i++) marks[i].clear(); }); }; if (autoclear) setTimeout(clear, 800); else return clear; } } function doMatchBrackets(cm) { cm.operation(function() { if (cm.state.matchBrackets.currentlyHighlighted) { cm.state.matchBrackets.currentlyHighlighted(); cm.state.matchBrackets.currentlyHighlighted = null; } cm.state.matchBrackets.currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets); }); } CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { function clear(cm) { if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) { cm.state.matchBrackets.currentlyHighlighted(); cm.state.matchBrackets.currentlyHighlighted = null; } } if (old && old != CodeMirror.Init) { cm.off("cursorActivity", doMatchBrackets); cm.off("focus", doMatchBrackets) cm.off("blur", clear) clear(cm); } if (val) { cm.state.matchBrackets = typeof val == "object" ? val : {}; cm.on("cursorActivity", doMatchBrackets); cm.on("focus", doMatchBrackets) cm.on("blur", clear) } }); CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);}); CodeMirror.defineExtension("findMatchingBracket", function(pos, config, oldConfig){ // Backwards-compatibility kludge if (oldConfig || typeof config == "boolean") { if (!oldConfig) { config = config ? {strict: true} : null } else { oldConfig.strict = config config = oldConfig } } return findMatchingBracket(this, pos, config) }); CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){ return scanForBracket(this, pos, dir, style, config); }); }); /* ---- extension/edit/matchtags.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../fold/xml-fold")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../fold/xml-fold"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineOption("matchTags", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { cm.off("cursorActivity", doMatchTags); cm.off("viewportChange", maybeUpdateMatch); clear(cm); } if (val) { cm.state.matchBothTags = typeof val == "object" && val.bothTags; cm.on("cursorActivity", doMatchTags); cm.on("viewportChange", maybeUpdateMatch); doMatchTags(cm); } }); function clear(cm) { if (cm.state.tagHit) cm.state.tagHit.clear(); if (cm.state.tagOther) cm.state.tagOther.clear(); cm.state.tagHit = cm.state.tagOther = null; } function doMatchTags(cm) { cm.state.failedTagMatch = false; cm.operation(function() { clear(cm); if (cm.somethingSelected()) return; var cur = cm.getCursor(), range = cm.getViewport(); range.from = Math.min(range.from, cur.line); range.to = Math.max(cur.line + 1, range.to); var match = CodeMirror.findMatchingTag(cm, cur, range); if (!match) return; if (cm.state.matchBothTags) { var hit = match.at == "open" ? match.open : match.close; if (hit) cm.state.tagHit = cm.markText(hit.from, hit.to, {className: "CodeMirror-matchingtag"}); } var other = match.at == "close" ? match.open : match.close; if (other) cm.state.tagOther = cm.markText(other.from, other.to, {className: "CodeMirror-matchingtag"}); else cm.state.failedTagMatch = true; }); } function maybeUpdateMatch(cm) { if (cm.state.failedTagMatch) doMatchTags(cm); } CodeMirror.commands.toMatchingTag = function(cm) { var found = CodeMirror.findMatchingTag(cm, cm.getCursor()); if (found) { var other = found.at == "close" ? found.open : found.close; if (other) cm.extendSelection(other.to, other.from); } }; }); /* ---- extension/edit/trailingspace.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) { if (prev == CodeMirror.Init) prev = false; if (prev && !val) cm.removeOverlay("trailingspace"); else if (!prev && val) cm.addOverlay({ token: function(stream) { for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {} if (i > stream.pos) { stream.pos = i; return null; } stream.pos = l; return "trailingspace"; }, name: "trailingspace" }); }); }); /* ---- extension/fold/brace-fold.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.registerHelper("fold", "brace", function(cm, start) { var line = start.line, lineText = cm.getLine(line); var tokenType; function findOpening(openCh) { for (var at = start.ch, pass = 0;;) { var found = at <= 0 ? -1 : lineText.lastIndexOf(openCh, at - 1); if (found == -1) { if (pass == 1) break; pass = 1; at = lineText.length; continue; } if (pass == 1 && found < start.ch) break; tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)); if (!/^(comment|string)/.test(tokenType)) return found + 1; at = found - 1; } } var startToken = "{", endToken = "}", startCh = findOpening("{"); if (startCh == null) { startToken = "[", endToken = "]"; startCh = findOpening("["); } if (startCh == null) return; var count = 1, lastLine = cm.lastLine(), end, endCh; outer: for (var i = line; i <= lastLine; ++i) { var text = cm.getLine(i), pos = i == line ? startCh : 0; for (;;) { var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos); if (nextOpen < 0) nextOpen = text.length; if (nextClose < 0) nextClose = text.length; pos = Math.min(nextOpen, nextClose); if (pos == text.length) break; if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == tokenType) { if (pos == nextOpen) ++count; else if (!--count) { end = i; endCh = pos; break outer; } } ++pos; } } if (end == null || line == end) return; return {from: CodeMirror.Pos(line, startCh), to: CodeMirror.Pos(end, endCh)}; }); CodeMirror.registerHelper("fold", "import", function(cm, start) { function hasImport(line) { if (line < cm.firstLine() || line > cm.lastLine()) return null; var start = cm.getTokenAt(CodeMirror.Pos(line, 1)); if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1)); if (start.type != "keyword" || start.string != "import") return null; // Now find closing semicolon, return its position for (var i = line, e = Math.min(cm.lastLine(), line + 10); i <= e; ++i) { var text = cm.getLine(i), semi = text.indexOf(";"); if (semi != -1) return {startCh: start.end, end: CodeMirror.Pos(i, semi)}; } } var startLine = start.line, has = hasImport(startLine), prev; if (!has || hasImport(startLine - 1) || ((prev = hasImport(startLine - 2)) && prev.end.line == startLine - 1)) return null; for (var end = has.end;;) { var next = hasImport(end.line + 1); if (next == null) break; end = next.end; } return {from: cm.clipPos(CodeMirror.Pos(startLine, has.startCh + 1)), to: end}; }); CodeMirror.registerHelper("fold", "include", function(cm, start) { function hasInclude(line) { if (line < cm.firstLine() || line > cm.lastLine()) return null; var start = cm.getTokenAt(CodeMirror.Pos(line, 1)); if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1)); if (start.type == "meta" && start.string.slice(0, 8) == "#include") return start.start + 8; } var startLine = start.line, has = hasInclude(startLine); if (has == null || hasInclude(startLine - 1) != null) return null; for (var end = startLine;;) { var next = hasInclude(end + 1); if (next == null) break; ++end; } return {from: CodeMirror.Pos(startLine, has + 1), to: cm.clipPos(CodeMirror.Pos(end))}; }); }); /* ---- extension/fold/comment-fold.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.registerGlobalHelper("fold", "comment", function(mode) { return mode.blockCommentStart && mode.blockCommentEnd; }, function(cm, start) { var mode = cm.getModeAt(start), startToken = mode.blockCommentStart, endToken = mode.blockCommentEnd; if (!startToken || !endToken) return; var line = start.line, lineText = cm.getLine(line); var startCh; for (var at = start.ch, pass = 0;;) { var found = at <= 0 ? -1 : lineText.lastIndexOf(startToken, at - 1); if (found == -1) { if (pass == 1) return; pass = 1; at = lineText.length; continue; } if (pass == 1 && found < start.ch) return; if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1))) && (found == 0 || lineText.slice(found - endToken.length, found) == endToken || !/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found))))) { startCh = found + startToken.length; break; } at = found - 1; } var depth = 1, lastLine = cm.lastLine(), end, endCh; outer: for (var i = line; i <= lastLine; ++i) { var text = cm.getLine(i), pos = i == line ? startCh : 0; for (;;) { var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos); if (nextOpen < 0) nextOpen = text.length; if (nextClose < 0) nextClose = text.length; pos = Math.min(nextOpen, nextClose); if (pos == text.length) break; if (pos == nextOpen) ++depth; else if (!--depth) { end = i; endCh = pos; break outer; } ++pos; } } if (end == null || line == end && endCh == startCh) return; return {from: CodeMirror.Pos(line, startCh), to: CodeMirror.Pos(end, endCh)}; }); }); /* ---- extension/fold/foldcode.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; function doFold(cm, pos, options, force) { if (options && options.call) { var finder = options; options = null; } else { var finder = getOption(cm, options, "rangeFinder"); } if (typeof pos == "number") pos = CodeMirror.Pos(pos, 0); var minSize = getOption(cm, options, "minFoldSize"); function getRange(allowFolded) { var range = finder(cm, pos); if (!range || range.to.line - range.from.line < minSize) return null; var marks = cm.findMarksAt(range.from); for (var i = 0; i < marks.length; ++i) { if (marks[i].__isFold && force !== "fold") { if (!allowFolded) return null; range.cleared = true; marks[i].clear(); } } return range; } var range = getRange(true); if (getOption(cm, options, "scanUp")) while (!range && pos.line > cm.firstLine()) { pos = CodeMirror.Pos(pos.line - 1, 0); range = getRange(false); } if (!range || range.cleared || force === "unfold") return; var myWidget = makeWidget(cm, options, range); CodeMirror.on(myWidget, "mousedown", function(e) { myRange.clear(); CodeMirror.e_preventDefault(e); }); var myRange = cm.markText(range.from, range.to, { replacedWith: myWidget, clearOnEnter: getOption(cm, options, "clearOnEnter"), __isFold: true }); myRange.on("clear", function(from, to) { CodeMirror.signal(cm, "unfold", cm, from, to); }); CodeMirror.signal(cm, "fold", cm, range.from, range.to); } function makeWidget(cm, options, range) { var widget = getOption(cm, options, "widget"); if (typeof widget == "function") { widget = widget(range.from, range.to); } if (typeof widget == "string") { var text = document.createTextNode(widget); widget = document.createElement("span"); widget.appendChild(text); widget.className = "CodeMirror-foldmarker"; } else if (widget) { widget = widget.cloneNode(true) } return widget; } // Clumsy backwards-compatible interface CodeMirror.newFoldFunction = function(rangeFinder, widget) { return function(cm, pos) { doFold(cm, pos, {rangeFinder: rangeFinder, widget: widget}); }; }; // New-style interface CodeMirror.defineExtension("foldCode", function(pos, options, force) { doFold(this, pos, options, force); }); CodeMirror.defineExtension("isFolded", function(pos) { var marks = this.findMarksAt(pos); for (var i = 0; i < marks.length; ++i) if (marks[i].__isFold) return true; }); CodeMirror.commands.toggleFold = function(cm) { cm.foldCode(cm.getCursor()); }; CodeMirror.commands.fold = function(cm) { cm.foldCode(cm.getCursor(), null, "fold"); }; CodeMirror.commands.unfold = function(cm) { cm.foldCode(cm.getCursor(), null, "unfold"); }; CodeMirror.commands.foldAll = function(cm) { cm.operation(function() { for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++) cm.foldCode(CodeMirror.Pos(i, 0), null, "fold"); }); }; CodeMirror.commands.unfoldAll = function(cm) { cm.operation(function() { for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++) cm.foldCode(CodeMirror.Pos(i, 0), null, "unfold"); }); }; CodeMirror.registerHelper("fold", "combine", function() { var funcs = Array.prototype.slice.call(arguments, 0); return function(cm, start) { for (var i = 0; i < funcs.length; ++i) { var found = funcs[i](cm, start); if (found) return found; } }; }); CodeMirror.registerHelper("fold", "auto", function(cm, start) { var helpers = cm.getHelpers(start, "fold"); for (var i = 0; i < helpers.length; i++) { var cur = helpers[i](cm, start); if (cur) return cur; } }); var defaultOptions = { rangeFinder: CodeMirror.fold.auto, widget: "\u2194", minFoldSize: 0, scanUp: false, clearOnEnter: true }; CodeMirror.defineOption("foldOptions", null); function getOption(cm, options, name) { if (options && options[name] !== undefined) return options[name]; var editorOptions = cm.options.foldOptions; if (editorOptions && editorOptions[name] !== undefined) return editorOptions[name]; return defaultOptions[name]; } CodeMirror.defineExtension("foldOption", function(options, name) { return getOption(this, options, name); }); }); /* ---- extension/fold/foldgutter.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("./foldcode")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "./foldcode"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineOption("foldGutter", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { cm.clearGutter(cm.state.foldGutter.options.gutter); cm.state.foldGutter = null; cm.off("gutterClick", onGutterClick); cm.off("changes", onChange); cm.off("viewportChange", onViewportChange); cm.off("fold", onFold); cm.off("unfold", onFold); cm.off("swapDoc", onChange); } if (val) { cm.state.foldGutter = new State(parseOptions(val)); updateInViewport(cm); cm.on("gutterClick", onGutterClick); cm.on("changes", onChange); cm.on("viewportChange", onViewportChange); cm.on("fold", onFold); cm.on("unfold", onFold); cm.on("swapDoc", onChange); } }); var Pos = CodeMirror.Pos; function State(options) { this.options = options; this.from = this.to = 0; } function parseOptions(opts) { if (opts === true) opts = {}; if (opts.gutter == null) opts.gutter = "CodeMirror-foldgutter"; if (opts.indicatorOpen == null) opts.indicatorOpen = "CodeMirror-foldgutter-open"; if (opts.indicatorFolded == null) opts.indicatorFolded = "CodeMirror-foldgutter-folded"; return opts; } function isFolded(cm, line) { var marks = cm.findMarks(Pos(line, 0), Pos(line + 1, 0)); for (var i = 0; i < marks.length; ++i) { if (marks[i].__isFold) { var fromPos = marks[i].find(-1); if (fromPos && fromPos.line === line) return marks[i]; } } } function marker(spec) { if (typeof spec == "string") { var elt = document.createElement("div"); elt.className = spec + " CodeMirror-guttermarker-subtle"; return elt; } else { return spec.cloneNode(true); } } function updateFoldInfo(cm, from, to) { var opts = cm.state.foldGutter.options, cur = from - 1; var minSize = cm.foldOption(opts, "minFoldSize"); var func = cm.foldOption(opts, "rangeFinder"); // we can reuse the built-in indicator element if its className matches the new state var clsFolded = typeof opts.indicatorFolded == "string" && classTest(opts.indicatorFolded); var clsOpen = typeof opts.indicatorOpen == "string" && classTest(opts.indicatorOpen); cm.eachLine(from, to, function(line) { ++cur; var mark = null; var old = line.gutterMarkers; if (old) old = old[opts.gutter]; if (isFolded(cm, cur)) { if (clsFolded && old && clsFolded.test(old.className)) return; mark = marker(opts.indicatorFolded); } else { var pos = Pos(cur, 0); var range = func && func(cm, pos); if (range && range.to.line - range.from.line >= minSize) { if (clsOpen && old && clsOpen.test(old.className)) return; mark = marker(opts.indicatorOpen); } } if (!mark && !old) return; cm.setGutterMarker(line, opts.gutter, mark); }); } // copied from CodeMirror/src/util/dom.js function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") } function updateInViewport(cm) { var vp = cm.getViewport(), state = cm.state.foldGutter; if (!state) return; cm.operation(function() { updateFoldInfo(cm, vp.from, vp.to); }); state.from = vp.from; state.to = vp.to; } function onGutterClick(cm, line, gutter) { var state = cm.state.foldGutter; if (!state) return; var opts = state.options; if (gutter != opts.gutter) return; var folded = isFolded(cm, line); if (folded) folded.clear(); else cm.foldCode(Pos(line, 0), opts); } function onChange(cm) { var state = cm.state.foldGutter; if (!state) return; var opts = state.options; state.from = state.to = 0; clearTimeout(state.changeUpdate); state.changeUpdate = setTimeout(function() { updateInViewport(cm); }, opts.foldOnChangeTimeSpan || 600); } function onViewportChange(cm) { var state = cm.state.foldGutter; if (!state) return; var opts = state.options; clearTimeout(state.changeUpdate); state.changeUpdate = setTimeout(function() { var vp = cm.getViewport(); if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) { updateInViewport(cm); } else { cm.operation(function() { if (vp.from < state.from) { updateFoldInfo(cm, vp.from, state.from); state.from = vp.from; } if (vp.to > state.to) { updateFoldInfo(cm, state.to, vp.to); state.to = vp.to; } }); } }, opts.updateViewportTimeSpan || 400); } function onFold(cm, from) { var state = cm.state.foldGutter; if (!state) return; var line = from.line; if (line >= state.from && line < state.to) updateFoldInfo(cm, line, line + 1); } }); /* ---- extension/fold/indent-fold.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; function lineIndent(cm, lineNo) { var text = cm.getLine(lineNo) var spaceTo = text.search(/\S/) if (spaceTo == -1 || /\bcomment\b/.test(cm.getTokenTypeAt(CodeMirror.Pos(lineNo, spaceTo + 1)))) return -1 return CodeMirror.countColumn(text, null, cm.getOption("tabSize")) } CodeMirror.registerHelper("fold", "indent", function(cm, start) { var myIndent = lineIndent(cm, start.line) if (myIndent < 0) return var lastLineInFold = null // Go through lines until we find a line that definitely doesn't belong in // the block we're folding, or to the end. for (var i = start.line + 1, end = cm.lastLine(); i <= end; ++i) { var indent = lineIndent(cm, i) if (indent == -1) { } else if (indent > myIndent) { // Lines with a greater indent are considered part of the block. lastLineInFold = i; } else { // If this line has non-space, non-comment content, and is // indented less or equal to the start line, it is the start of // another block. break; } } if (lastLineInFold) return { from: CodeMirror.Pos(start.line, cm.getLine(start.line).length), to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length) }; }); }); /* ---- extension/fold/markdown-fold.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.registerHelper("fold", "markdown", function(cm, start) { var maxDepth = 100; function isHeader(lineNo) { var tokentype = cm.getTokenTypeAt(CodeMirror.Pos(lineNo, 0)); return tokentype && /\bheader\b/.test(tokentype); } function headerLevel(lineNo, line, nextLine) { var match = line && line.match(/^#+/); if (match && isHeader(lineNo)) return match[0].length; match = nextLine && nextLine.match(/^[=\-]+\s*$/); if (match && isHeader(lineNo + 1)) return nextLine[0] == "=" ? 1 : 2; return maxDepth; } var firstLine = cm.getLine(start.line), nextLine = cm.getLine(start.line + 1); var level = headerLevel(start.line, firstLine, nextLine); if (level === maxDepth) return undefined; var lastLineNo = cm.lastLine(); var end = start.line, nextNextLine = cm.getLine(end + 2); while (end < lastLineNo) { if (headerLevel(end + 1, nextLine, nextNextLine) <= level) break; ++end; nextLine = nextNextLine; nextNextLine = cm.getLine(end + 2); } return { from: CodeMirror.Pos(start.line, firstLine.length), to: CodeMirror.Pos(end, cm.getLine(end).length) }; }); }); /* ---- extension/fold/xml-fold.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var Pos = CodeMirror.Pos; function cmp(a, b) { return a.line - b.line || a.ch - b.ch; } var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"; var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; var xmlTagStart = new RegExp("<(/?)([" + nameStartChar + "][" + nameChar + "]*)", "g"); function Iter(cm, line, ch, range) { this.line = line; this.ch = ch; this.cm = cm; this.text = cm.getLine(line); this.min = range ? Math.max(range.from, cm.firstLine()) : cm.firstLine(); this.max = range ? Math.min(range.to - 1, cm.lastLine()) : cm.lastLine(); } function tagAt(iter, ch) { var type = iter.cm.getTokenTypeAt(Pos(iter.line, ch)); return type && /\btag\b/.test(type); } function nextLine(iter) { if (iter.line >= iter.max) return; iter.ch = 0; iter.text = iter.cm.getLine(++iter.line); return true; } function prevLine(iter) { if (iter.line <= iter.min) return; iter.text = iter.cm.getLine(--iter.line); iter.ch = iter.text.length; return true; } function toTagEnd(iter) { for (;;) { var gt = iter.text.indexOf(">", iter.ch); if (gt == -1) { if (nextLine(iter)) continue; else return; } if (!tagAt(iter, gt + 1)) { iter.ch = gt + 1; continue; } var lastSlash = iter.text.lastIndexOf("/", gt); var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt)); iter.ch = gt + 1; return selfClose ? "selfClose" : "regular"; } } function toTagStart(iter) { for (;;) { var lt = iter.ch ? iter.text.lastIndexOf("<", iter.ch - 1) : -1; if (lt == -1) { if (prevLine(iter)) continue; else return; } if (!tagAt(iter, lt + 1)) { iter.ch = lt; continue; } xmlTagStart.lastIndex = lt; iter.ch = lt; var match = xmlTagStart.exec(iter.text); if (match && match.index == lt) return match; } } function toNextTag(iter) { for (;;) { xmlTagStart.lastIndex = iter.ch; var found = xmlTagStart.exec(iter.text); if (!found) { if (nextLine(iter)) continue; else return; } if (!tagAt(iter, found.index + 1)) { iter.ch = found.index + 1; continue; } iter.ch = found.index + found[0].length; return found; } } function toPrevTag(iter) { for (;;) { var gt = iter.ch ? iter.text.lastIndexOf(">", iter.ch - 1) : -1; if (gt == -1) { if (prevLine(iter)) continue; else return; } if (!tagAt(iter, gt + 1)) { iter.ch = gt; continue; } var lastSlash = iter.text.lastIndexOf("/", gt); var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt)); iter.ch = gt + 1; return selfClose ? "selfClose" : "regular"; } } function findMatchingClose(iter, tag) { var stack = []; for (;;) { var next = toNextTag(iter), end, startLine = iter.line, startCh = iter.ch - (next ? next[0].length : 0); if (!next || !(end = toTagEnd(iter))) return; if (end == "selfClose") continue; if (next[1]) { // closing tag for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == next[2]) { stack.length = i; break; } if (i < 0 && (!tag || tag == next[2])) return { tag: next[2], from: Pos(startLine, startCh), to: Pos(iter.line, iter.ch) }; } else { // opening tag stack.push(next[2]); } } } function findMatchingOpen(iter, tag) { var stack = []; for (;;) { var prev = toPrevTag(iter); if (!prev) return; if (prev == "selfClose") { toTagStart(iter); continue; } var endLine = iter.line, endCh = iter.ch; var start = toTagStart(iter); if (!start) return; if (start[1]) { // closing tag stack.push(start[2]); } else { // opening tag for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == start[2]) { stack.length = i; break; } if (i < 0 && (!tag || tag == start[2])) return { tag: start[2], from: Pos(iter.line, iter.ch), to: Pos(endLine, endCh) }; } } } CodeMirror.registerHelper("fold", "xml", function(cm, start) { var iter = new Iter(cm, start.line, 0); for (;;) { var openTag = toNextTag(iter) if (!openTag || iter.line != start.line) return var end = toTagEnd(iter) if (!end) return if (!openTag[1] && end != "selfClose") { var startPos = Pos(iter.line, iter.ch); var endPos = findMatchingClose(iter, openTag[2]); return endPos && cmp(endPos.from, startPos) > 0 ? {from: startPos, to: endPos.from} : null } } }); CodeMirror.findMatchingTag = function(cm, pos, range) { var iter = new Iter(cm, pos.line, pos.ch, range); if (iter.text.indexOf(">") == -1 && iter.text.indexOf("<") == -1) return; var end = toTagEnd(iter), to = end && Pos(iter.line, iter.ch); var start = end && toTagStart(iter); if (!end || !start || cmp(iter, pos) > 0) return; var here = {from: Pos(iter.line, iter.ch), to: to, tag: start[2]}; if (end == "selfClose") return {open: here, close: null, at: "open"}; if (start[1]) { // closing tag return {open: findMatchingOpen(iter, start[2]), close: here, at: "close"}; } else { // opening tag iter = new Iter(cm, to.line, to.ch, range); return {open: here, close: findMatchingClose(iter, start[2]), at: "open"}; } }; CodeMirror.findEnclosingTag = function(cm, pos, range, tag) { var iter = new Iter(cm, pos.line, pos.ch, range); for (;;) { var open = findMatchingOpen(iter, tag); if (!open) break; var forward = new Iter(cm, pos.line, pos.ch, range); var close = findMatchingClose(forward, open.tag); if (close) return {open: open, close: close}; } }; // Used by addon/edit/closetag.js CodeMirror.scanForClosingTag = function(cm, pos, name, end) { var iter = new Iter(cm, pos.line, pos.ch, end ? {from: 0, to: end} : null); return findMatchingClose(iter, name); }; }); /* ---- extension/hint/anyword-hint.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var WORD = /[\w$]+/, RANGE = 500; CodeMirror.registerHelper("hint", "anyword", function(editor, options) { var word = options && options.word || WORD; var range = options && options.range || RANGE; var cur = editor.getCursor(), curLine = editor.getLine(cur.line); var end = cur.ch, start = end; while (start && word.test(curLine.charAt(start - 1))) --start; var curWord = start != end && curLine.slice(start, end); var list = options && options.list || [], seen = {}; var re = new RegExp(word.source, "g"); for (var dir = -1; dir <= 1; dir += 2) { var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir; for (; line != endLine; line += dir) { var text = editor.getLine(line), m; while (m = re.exec(text)) { if (line == cur.line && m[0] === curWord) continue; if ((!curWord || m[0].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[0])) { seen[m[0]] = true; list.push(m[0]); } } } } return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)}; }); }); /* ---- extension/hint/html-hint.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("./xml-hint")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "./xml-hint"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var langs = "ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" "); var targets = ["_blank", "_self", "_top", "_parent"]; var charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"]; var methods = ["get", "post", "put", "delete"]; var encs = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]; var media = ["all", "screen", "print", "embossed", "braille", "handheld", "print", "projection", "screen", "tty", "tv", "speech", "3d-glasses", "resolution [>][<][=] [X]", "device-aspect-ratio: X/Y", "orientation:portrait", "orientation:landscape", "device-height: [X]", "device-width: [X]"]; var s = { attrs: {} }; // Simple tag, reused for a whole lot of tags var data = { a: { attrs: { href: null, ping: null, type: null, media: media, target: targets, hreflang: langs } }, abbr: s, acronym: s, address: s, applet: s, area: { attrs: { alt: null, coords: null, href: null, target: null, ping: null, media: media, hreflang: langs, type: null, shape: ["default", "rect", "circle", "poly"] } }, article: s, aside: s, audio: { attrs: { src: null, mediagroup: null, crossorigin: ["anonymous", "use-credentials"], preload: ["none", "metadata", "auto"], autoplay: ["", "autoplay"], loop: ["", "loop"], controls: ["", "controls"] } }, b: s, base: { attrs: { href: null, target: targets } }, basefont: s, bdi: s, bdo: s, big: s, blockquote: { attrs: { cite: null } }, body: s, br: s, button: { attrs: { form: null, formaction: null, name: null, value: null, autofocus: ["", "autofocus"], disabled: ["", "autofocus"], formenctype: encs, formmethod: methods, formnovalidate: ["", "novalidate"], formtarget: targets, type: ["submit", "reset", "button"] } }, canvas: { attrs: { width: null, height: null } }, caption: s, center: s, cite: s, code: s, col: { attrs: { span: null } }, colgroup: { attrs: { span: null } }, command: { attrs: { type: ["command", "checkbox", "radio"], label: null, icon: null, radiogroup: null, command: null, title: null, disabled: ["", "disabled"], checked: ["", "checked"] } }, data: { attrs: { value: null } }, datagrid: { attrs: { disabled: ["", "disabled"], multiple: ["", "multiple"] } }, datalist: { attrs: { data: null } }, dd: s, del: { attrs: { cite: null, datetime: null } }, details: { attrs: { open: ["", "open"] } }, dfn: s, dir: s, div: s, dl: s, dt: s, em: s, embed: { attrs: { src: null, type: null, width: null, height: null } }, eventsource: { attrs: { src: null } }, fieldset: { attrs: { disabled: ["", "disabled"], form: null, name: null } }, figcaption: s, figure: s, font: s, footer: s, form: { attrs: { action: null, name: null, "accept-charset": charsets, autocomplete: ["on", "off"], enctype: encs, method: methods, novalidate: ["", "novalidate"], target: targets } }, frame: s, frameset: s, h1: s, h2: s, h3: s, h4: s, h5: s, h6: s, head: { attrs: {}, children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"] }, header: s, hgroup: s, hr: s, html: { attrs: { manifest: null }, children: ["head", "body"] }, i: s, iframe: { attrs: { src: null, srcdoc: null, name: null, width: null, height: null, sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"], seamless: ["", "seamless"] } }, img: { attrs: { alt: null, src: null, ismap: null, usemap: null, width: null, height: null, crossorigin: ["anonymous", "use-credentials"] } }, input: { attrs: { alt: null, dirname: null, form: null, formaction: null, height: null, list: null, max: null, maxlength: null, min: null, name: null, pattern: null, placeholder: null, size: null, src: null, step: null, value: null, width: null, accept: ["audio/*", "video/*", "image/*"], autocomplete: ["on", "off"], autofocus: ["", "autofocus"], checked: ["", "checked"], disabled: ["", "disabled"], formenctype: encs, formmethod: methods, formnovalidate: ["", "novalidate"], formtarget: targets, multiple: ["", "multiple"], readonly: ["", "readonly"], required: ["", "required"], type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month", "week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio", "file", "submit", "image", "reset", "button"] } }, ins: { attrs: { cite: null, datetime: null } }, kbd: s, keygen: { attrs: { challenge: null, form: null, name: null, autofocus: ["", "autofocus"], disabled: ["", "disabled"], keytype: ["RSA"] } }, label: { attrs: { "for": null, form: null } }, legend: s, li: { attrs: { value: null } }, link: { attrs: { href: null, type: null, hreflang: langs, media: media, sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"] } }, map: { attrs: { name: null } }, mark: s, menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } }, meta: { attrs: { content: null, charset: charsets, name: ["viewport", "application-name", "author", "description", "generator", "keywords"], "http-equiv": ["content-language", "content-type", "default-style", "refresh"] } }, meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } }, nav: s, noframes: s, noscript: s, object: { attrs: { data: null, type: null, name: null, usemap: null, form: null, width: null, height: null, typemustmatch: ["", "typemustmatch"] } }, ol: { attrs: { reversed: ["", "reversed"], start: null, type: ["1", "a", "A", "i", "I"] } }, optgroup: { attrs: { disabled: ["", "disabled"], label: null } }, option: { attrs: { disabled: ["", "disabled"], label: null, selected: ["", "selected"], value: null } }, output: { attrs: { "for": null, form: null, name: null } }, p: s, param: { attrs: { name: null, value: null } }, pre: s, progress: { attrs: { value: null, max: null } }, q: { attrs: { cite: null } }, rp: s, rt: s, ruby: s, s: s, samp: s, script: { attrs: { type: ["text/javascript"], src: null, async: ["", "async"], defer: ["", "defer"], charset: charsets } }, section: s, select: { attrs: { form: null, name: null, size: null, autofocus: ["", "autofocus"], disabled: ["", "disabled"], multiple: ["", "multiple"] } }, small: s, source: { attrs: { src: null, type: null, media: null } }, span: s, strike: s, strong: s, style: { attrs: { type: ["text/css"], media: media, scoped: null } }, sub: s, summary: s, sup: s, table: s, tbody: s, td: { attrs: { colspan: null, rowspan: null, headers: null } }, textarea: { attrs: { dirname: null, form: null, maxlength: null, name: null, placeholder: null, rows: null, cols: null, autofocus: ["", "autofocus"], disabled: ["", "disabled"], readonly: ["", "readonly"], required: ["", "required"], wrap: ["soft", "hard"] } }, tfoot: s, th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } }, thead: s, time: { attrs: { datetime: null } }, title: s, tr: s, track: { attrs: { src: null, label: null, "default": null, kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"], srclang: langs } }, tt: s, u: s, ul: s, "var": s, video: { attrs: { src: null, poster: null, width: null, height: null, crossorigin: ["anonymous", "use-credentials"], preload: ["auto", "metadata", "none"], autoplay: ["", "autoplay"], mediagroup: ["movie"], muted: ["", "muted"], controls: ["", "controls"] } }, wbr: s }; var globalAttrs = { accesskey: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], "class": null, contenteditable: ["true", "false"], contextmenu: null, dir: ["ltr", "rtl", "auto"], draggable: ["true", "false", "auto"], dropzone: ["copy", "move", "link", "string:", "file:"], hidden: ["hidden"], id: null, inert: ["inert"], itemid: null, itemprop: null, itemref: null, itemscope: ["itemscope"], itemtype: null, lang: ["en", "es"], spellcheck: ["true", "false"], autocorrect: ["true", "false"], autocapitalize: ["true", "false"], style: null, tabindex: ["1", "2", "3", "4", "5", "6", "7", "8", "9"], title: null, translate: ["yes", "no"], onclick: null, rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"] }; function populate(obj) { for (var attr in globalAttrs) if (globalAttrs.hasOwnProperty(attr)) obj.attrs[attr] = globalAttrs[attr]; } populate(s); for (var tag in data) if (data.hasOwnProperty(tag) && data[tag] != s) populate(data[tag]); CodeMirror.htmlSchema = data; function htmlHint(cm, options) { var local = {schemaInfo: data}; if (options) for (var opt in options) local[opt] = options[opt]; return CodeMirror.hint.xml(cm, local); } CodeMirror.registerHelper("hint", "html", htmlHint); }); /* ---- extension/hint/show-hint.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var HINT_ELEMENT_CLASS = "CodeMirror-hint"; var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active"; // This is the old interface, kept around for now to stay // backwards-compatible. CodeMirror.showHint = function(cm, getHints, options) { if (!getHints) return cm.showHint(options); if (options && options.async) getHints.async = true; var newOpts = {hint: getHints}; if (options) for (var prop in options) newOpts[prop] = options[prop]; return cm.showHint(newOpts); }; CodeMirror.defineExtension("showHint", function(options) { options = parseOptions(this, this.getCursor("start"), options); var selections = this.listSelections() if (selections.length > 1) return; // By default, don't allow completion when something is selected. // A hint function can have a `supportsSelection` property to // indicate that it can handle selections. if (this.somethingSelected()) { if (!options.hint.supportsSelection) return; // Don't try with cross-line selections for (var i = 0; i < selections.length; i++) if (selections[i].head.line != selections[i].anchor.line) return; } if (this.state.completionActive) this.state.completionActive.close(); var completion = this.state.completionActive = new Completion(this, options); if (!completion.options.hint) return; CodeMirror.signal(this, "startCompletion", this); completion.update(true); }); CodeMirror.defineExtension("closeHint", function() { if (this.state.completionActive) this.state.completionActive.close() }) function Completion(cm, options) { this.cm = cm; this.options = options; this.widget = null; this.debounce = 0; this.tick = 0; this.startPos = this.cm.getCursor("start"); this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length; var self = this; cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); }); } var requestAnimationFrame = window.requestAnimationFrame || function(fn) { return setTimeout(fn, 1000/60); }; var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout; Completion.prototype = { close: function() { if (!this.active()) return; this.cm.state.completionActive = null; this.tick = null; this.cm.off("cursorActivity", this.activityFunc); if (this.widget && this.data) CodeMirror.signal(this.data, "close"); if (this.widget) this.widget.close(); CodeMirror.signal(this.cm, "endCompletion", this.cm); }, active: function() { return this.cm.state.completionActive == this; }, pick: function(data, i) { var completion = data.list[i], self = this; this.cm.operation(function() { if (completion.hint) completion.hint(self.cm, data, completion); else self.cm.replaceRange(getText(completion), completion.from || data.from, completion.to || data.to, "complete"); CodeMirror.signal(data, "pick", completion); self.cm.scrollIntoView(); }) this.close(); }, cursorActivity: function() { if (this.debounce) { cancelAnimationFrame(this.debounce); this.debounce = 0; } var identStart = this.startPos; if(this.data) { identStart = this.data.from; } var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line); if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch || pos.ch < identStart.ch || this.cm.somethingSelected() || (!pos.ch || this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) { this.close(); } else { var self = this; this.debounce = requestAnimationFrame(function() {self.update();}); if (this.widget) this.widget.disable(); } }, update: function(first) { if (this.tick == null) return var self = this, myTick = ++this.tick fetchHints(this.options.hint, this.cm, this.options, function(data) { if (self.tick == myTick) self.finishUpdate(data, first) }) }, finishUpdate: function(data, first) { if (this.data) CodeMirror.signal(this.data, "update"); var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle); if (this.widget) this.widget.close(); this.data = data; if (data && data.list.length) { if (picked && data.list.length == 1) { this.pick(data, 0); } else { this.widget = new Widget(this, data); CodeMirror.signal(data, "shown"); } } } }; function parseOptions(cm, pos, options) { var editor = cm.options.hintOptions; var out = {}; for (var prop in defaultOptions) out[prop] = defaultOptions[prop]; if (editor) for (var prop in editor) if (editor[prop] !== undefined) out[prop] = editor[prop]; if (options) for (var prop in options) if (options[prop] !== undefined) out[prop] = options[prop]; if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos) return out; } function getText(completion) { if (typeof completion == "string") return completion; else return completion.text; } function buildKeyMap(completion, handle) { var baseMap = { Up: function() {handle.moveFocus(-1);}, Down: function() {handle.moveFocus(1);}, PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);}, PageDown: function() {handle.moveFocus(handle.menuSize() - 1, true);}, Home: function() {handle.setFocus(0);}, End: function() {handle.setFocus(handle.length - 1);}, Enter: handle.pick, Tab: handle.pick, Esc: handle.close }; var mac = /Mac/.test(navigator.platform); if (mac) { baseMap["Ctrl-P"] = function() {handle.moveFocus(-1);}; baseMap["Ctrl-N"] = function() {handle.moveFocus(1);}; } var custom = completion.options.customKeys; var ourMap = custom ? {} : baseMap; function addBinding(key, val) { var bound; if (typeof val != "string") bound = function(cm) { return val(cm, handle); }; // This mechanism is deprecated else if (baseMap.hasOwnProperty(val)) bound = baseMap[val]; else bound = val; ourMap[key] = bound; } if (custom) for (var key in custom) if (custom.hasOwnProperty(key)) addBinding(key, custom[key]); var extra = completion.options.extraKeys; if (extra) for (var key in extra) if (extra.hasOwnProperty(key)) addBinding(key, extra[key]); return ourMap; } function getHintElement(hintsElement, el) { while (el && el != hintsElement) { if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement) return el; el = el.parentNode; } } function Widget(completion, data) { this.completion = completion; this.data = data; this.picked = false; var widget = this, cm = completion.cm; var ownerDocument = cm.getInputField().ownerDocument; var parentWindow = ownerDocument.defaultView || ownerDocument.parentWindow; var hints = this.hints = ownerDocument.createElement("ul"); var theme = completion.cm.options.theme; hints.className = "CodeMirror-hints " + theme; this.selectedHint = data.selectedHint || 0; var completions = data.list; for (var i = 0; i < completions.length; ++i) { var elt = hints.appendChild(ownerDocument.createElement("li")), cur = completions[i]; var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS); if (cur.className != null) className = cur.className + " " + className; elt.className = className; if (cur.render) cur.render(elt, data, cur); else elt.appendChild(ownerDocument.createTextNode(cur.displayText || getText(cur))); elt.hintId = i; } var container = completion.options.container || ownerDocument.body; var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null); var left = pos.left, top = pos.bottom, below = true; var offsetLeft = 0, offsetTop = 0; if (container !== ownerDocument.body) { // We offset the cursor position because left and top are relative to the offsetParent's top left corner. var isContainerPositioned = ['absolute', 'relative', 'fixed'].indexOf(parentWindow.getComputedStyle(container).position) !== -1; var offsetParent = isContainerPositioned ? container : container.offsetParent; var offsetParentPosition = offsetParent.getBoundingClientRect(); var bodyPosition = ownerDocument.body.getBoundingClientRect(); offsetLeft = (offsetParentPosition.left - bodyPosition.left - offsetParent.scrollLeft); offsetTop = (offsetParentPosition.top - bodyPosition.top - offsetParent.scrollTop); } hints.style.left = (left - offsetLeft) + "px"; hints.style.top = (top - offsetTop) + "px"; // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor. var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth); var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight); container.appendChild(hints); var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH; var scrolls = hints.scrollHeight > hints.clientHeight + 1 var startScroll = cm.getScrollInfo(); if (overlapY > 0) { var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top); if (curTop - height > 0) { // Fits above cursor hints.style.top = (top = pos.top - height - offsetTop) + "px"; below = false; } else if (height > winH) { hints.style.height = (winH - 5) + "px"; hints.style.top = (top = pos.bottom - box.top - offsetTop) + "px"; var cursor = cm.getCursor(); if (data.from.ch != cursor.ch) { pos = cm.cursorCoords(cursor); hints.style.left = (left = pos.left - offsetLeft) + "px"; box = hints.getBoundingClientRect(); } } } var overlapX = box.right - winW; if (overlapX > 0) { if (box.right - box.left > winW) { hints.style.width = (winW - 5) + "px"; overlapX -= (box.right - box.left) - winW; } hints.style.left = (left = pos.left - overlapX - offsetLeft) + "px"; } if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling) node.style.paddingRight = cm.display.nativeBarWidth + "px" cm.addKeyMap(this.keyMap = buildKeyMap(completion, { moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); }, setFocus: function(n) { widget.changeActive(n); }, menuSize: function() { return widget.screenAmount(); }, length: completions.length, close: function() { completion.close(); }, pick: function() { widget.pick(); }, data: data })); if (completion.options.closeOnUnfocus) { var closingOnBlur; cm.on("blur", this.onBlur = function() { closingOnBlur = setTimeout(function() { completion.close(); }, 100); }); cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); }); } cm.on("scroll", this.onScroll = function() { var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect(); var newTop = top + startScroll.top - curScroll.top; var point = newTop - (parentWindow.pageYOffset || (ownerDocument.documentElement || ownerDocument.body).scrollTop); if (!below) point += hints.offsetHeight; if (point <= editor.top || point >= editor.bottom) return completion.close(); hints.style.top = newTop + "px"; hints.style.left = (left + startScroll.left - curScroll.left) + "px"; }); CodeMirror.on(hints, "dblclick", function(e) { var t = getHintElement(hints, e.target || e.srcElement); if (t && t.hintId != null) {widget.changeActive(t.hintId); widget.pick();} }); CodeMirror.on(hints, "click", function(e) { var t = getHintElement(hints, e.target || e.srcElement); if (t && t.hintId != null) { widget.changeActive(t.hintId); if (completion.options.completeOnSingleClick) widget.pick(); } }); CodeMirror.on(hints, "mousedown", function() { setTimeout(function(){cm.focus();}, 20); }); this.scrollToActive() CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]); return true; } Widget.prototype = { close: function() { if (this.completion.widget != this) return; this.completion.widget = null; this.hints.parentNode.removeChild(this.hints); this.completion.cm.removeKeyMap(this.keyMap); var cm = this.completion.cm; if (this.completion.options.closeOnUnfocus) { cm.off("blur", this.onBlur); cm.off("focus", this.onFocus); } cm.off("scroll", this.onScroll); }, disable: function() { this.completion.cm.removeKeyMap(this.keyMap); var widget = this; this.keyMap = {Enter: function() { widget.picked = true; }}; this.completion.cm.addKeyMap(this.keyMap); }, pick: function() { this.completion.pick(this.data, this.selectedHint); }, changeActive: function(i, avoidWrap) { if (i >= this.data.list.length) i = avoidWrap ? this.data.list.length - 1 : 0; else if (i < 0) i = avoidWrap ? 0 : this.data.list.length - 1; if (this.selectedHint == i) return; var node = this.hints.childNodes[this.selectedHint]; if (node) node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, ""); node = this.hints.childNodes[this.selectedHint = i]; node.className += " " + ACTIVE_HINT_ELEMENT_CLASS; this.scrollToActive() CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node); }, scrollToActive: function() { var margin = this.completion.options.scrollMargin || 0; var node1 = this.hints.childNodes[Math.max(0, this.selectedHint - margin)]; var node2 = this.hints.childNodes[Math.min(this.data.list.length - 1, this.selectedHint + margin)]; var firstNode = this.hints.firstChild; if (node1.offsetTop < this.hints.scrollTop) this.hints.scrollTop = node1.offsetTop - firstNode.offsetTop; else if (node2.offsetTop + node2.offsetHeight > this.hints.scrollTop + this.hints.clientHeight) this.hints.scrollTop = node2.offsetTop + node2.offsetHeight - this.hints.clientHeight + firstNode.offsetTop; }, screenAmount: function() { return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1; } }; function applicableHelpers(cm, helpers) { if (!cm.somethingSelected()) return helpers var result = [] for (var i = 0; i < helpers.length; i++) if (helpers[i].supportsSelection) result.push(helpers[i]) return result } function fetchHints(hint, cm, options, callback) { if (hint.async) { hint(cm, callback, options) } else { var result = hint(cm, options) if (result && result.then) result.then(callback) else callback(result) } } function resolveAutoHints(cm, pos) { var helpers = cm.getHelpers(pos, "hint"), words if (helpers.length) { var resolved = function(cm, callback, options) { var app = applicableHelpers(cm, helpers); function run(i) { if (i == app.length) return callback(null) fetchHints(app[i], cm, options, function(result) { if (result && result.list.length > 0) callback(result) else run(i + 1) }) } run(0) } resolved.async = true resolved.supportsSelection = true return resolved } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) { return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) } } else if (CodeMirror.hint.anyword) { return function(cm, options) { return CodeMirror.hint.anyword(cm, options) } } else { return function() {} } } CodeMirror.registerHelper("hint", "auto", { resolve: resolveAutoHints }); CodeMirror.registerHelper("hint", "fromList", function(cm, options) { var cur = cm.getCursor(), token = cm.getTokenAt(cur) var term, from = CodeMirror.Pos(cur.line, token.start), to = cur if (token.start < cur.ch && /\w/.test(token.string.charAt(cur.ch - token.start - 1))) { term = token.string.substr(0, cur.ch - token.start) } else { term = "" from = cur } var found = []; for (var i = 0; i < options.words.length; i++) { var word = options.words[i]; if (word.slice(0, term.length) == term) found.push(word); } if (found.length) return {list: found, from: from, to: to}; }); CodeMirror.commands.autocomplete = CodeMirror.showHint; var defaultOptions = { hint: CodeMirror.hint.auto, completeSingle: true, alignWithWord: true, closeCharacters: /[\s()\[\]{};:>,]/, closeOnUnfocus: true, completeOnSingleClick: true, container: null, customKeys: null, extraKeys: null }; CodeMirror.defineOption("hintOptions", null); }); /* ---- extension/hint/sql-hint.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../../mode/sql/sql")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../../mode/sql/sql"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var tables; var defaultTable; var keywords; var identifierQuote; var CONS = { QUERY_DIV: ";", ALIAS_KEYWORD: "AS" }; var Pos = CodeMirror.Pos, cmpPos = CodeMirror.cmpPos; function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" } function getKeywords(editor) { var mode = editor.doc.modeOption; if (mode === "sql") mode = "text/x-sql"; return CodeMirror.resolveMode(mode).keywords; } function getIdentifierQuote(editor) { var mode = editor.doc.modeOption; if (mode === "sql") mode = "text/x-sql"; return CodeMirror.resolveMode(mode).identifierQuote || "`"; } function getText(item) { return typeof item == "string" ? item : item.text; } function wrapTable(name, value) { if (isArray(value)) value = {columns: value} if (!value.text) value.text = name return value } function parseTables(input) { var result = {} if (isArray(input)) { for (var i = input.length - 1; i >= 0; i--) { var item = input[i] result[getText(item).toUpperCase()] = wrapTable(getText(item), item) } } else if (input) { for (var name in input) result[name.toUpperCase()] = wrapTable(name, input[name]) } return result } function getTable(name) { return tables[name.toUpperCase()] } function shallowClone(object) { var result = {}; for (var key in object) if (object.hasOwnProperty(key)) result[key] = object[key]; return result; } function match(string, word) { var len = string.length; var sub = getText(word).substr(0, len); return string.toUpperCase() === sub.toUpperCase(); } function addMatches(result, search, wordlist, formatter) { if (isArray(wordlist)) { for (var i = 0; i < wordlist.length; i++) if (match(search, wordlist[i])) result.push(formatter(wordlist[i])) } else { for (var word in wordlist) if (wordlist.hasOwnProperty(word)) { var val = wordlist[word] if (!val || val === true) val = word else val = val.displayText ? {text: val.text, displayText: val.displayText} : val.text if (match(search, val)) result.push(formatter(val)) } } } function cleanName(name) { // Get rid name from identifierQuote and preceding dot(.) if (name.charAt(0) == ".") { name = name.substr(1); } // replace doublicated identifierQuotes with single identifierQuotes // and remove single identifierQuotes var nameParts = name.split(identifierQuote+identifierQuote); for (var i = 0; i < nameParts.length; i++) nameParts[i] = nameParts[i].replace(new RegExp(identifierQuote,"g"), ""); return nameParts.join(identifierQuote); } function insertIdentifierQuotes(name) { var nameParts = getText(name).split("."); for (var i = 0; i < nameParts.length; i++) nameParts[i] = identifierQuote + // doublicate identifierQuotes nameParts[i].replace(new RegExp(identifierQuote,"g"), identifierQuote+identifierQuote) + identifierQuote; var escaped = nameParts.join("."); if (typeof name == "string") return escaped; name = shallowClone(name); name.text = escaped; return name; } function nameCompletion(cur, token, result, editor) { // Try to complete table, column names and return start position of completion var useIdentifierQuotes = false; var nameParts = []; var start = token.start; var cont = true; while (cont) { cont = (token.string.charAt(0) == "."); useIdentifierQuotes = useIdentifierQuotes || (token.string.charAt(0) == identifierQuote); start = token.start; nameParts.unshift(cleanName(token.string)); token = editor.getTokenAt(Pos(cur.line, token.start)); if (token.string == ".") { cont = true; token = editor.getTokenAt(Pos(cur.line, token.start)); } } // Try to complete table names var string = nameParts.join("."); addMatches(result, string, tables, function(w) { return useIdentifierQuotes ? insertIdentifierQuotes(w) : w; }); // Try to complete columns from defaultTable addMatches(result, string, defaultTable, function(w) { return useIdentifierQuotes ? insertIdentifierQuotes(w) : w; }); // Try to complete columns string = nameParts.pop(); var table = nameParts.join("."); var alias = false; var aliasTable = table; // Check if table is available. If not, find table by Alias if (!getTable(table)) { var oldTable = table; table = findTableByAlias(table, editor); if (table !== oldTable) alias = true; } var columns = getTable(table); if (columns && columns.columns) columns = columns.columns; if (columns) { addMatches(result, string, columns, function(w) { var tableInsert = table; if (alias == true) tableInsert = aliasTable; if (typeof w == "string") { w = tableInsert + "." + w; } else { w = shallowClone(w); w.text = tableInsert + "." + w.text; } return useIdentifierQuotes ? insertIdentifierQuotes(w) : w; }); } return start; } function eachWord(lineText, f) { var words = lineText.split(/\s+/) for (var i = 0; i < words.length; i++) if (words[i]) f(words[i].replace(/[,;]/g, '')) } function findTableByAlias(alias, editor) { var doc = editor.doc; var fullQuery = doc.getValue(); var aliasUpperCase = alias.toUpperCase(); var previousWord = ""; var table = ""; var separator = []; var validRange = { start: Pos(0, 0), end: Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).length) }; //add separator var indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV); while(indexOfSeparator != -1) { separator.push(doc.posFromIndex(indexOfSeparator)); indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV, indexOfSeparator+1); } separator.unshift(Pos(0, 0)); separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length)); //find valid range var prevItem = null; var current = editor.getCursor() for (var i = 0; i < separator.length; i++) { if ((prevItem == null || cmpPos(current, prevItem) > 0) && cmpPos(current, separator[i]) <= 0) { validRange = {start: prevItem, end: separator[i]}; break; } prevItem = separator[i]; } if (validRange.start) { var query = doc.getRange(validRange.start, validRange.end, false); for (var i = 0; i < query.length; i++) { var lineText = query[i]; eachWord(lineText, function(word) { var wordUpperCase = word.toUpperCase(); if (wordUpperCase === aliasUpperCase && getTable(previousWord)) table = previousWord; if (wordUpperCase !== CONS.ALIAS_KEYWORD) previousWord = word; }); if (table) break; } } return table; } CodeMirror.registerHelper("hint", "sql", function(editor, options) { tables = parseTables(options && options.tables) var defaultTableName = options && options.defaultTable; var disableKeywords = options && options.disableKeywords; defaultTable = defaultTableName && getTable(defaultTableName); keywords = getKeywords(editor); identifierQuote = getIdentifierQuote(editor); if (defaultTableName && !defaultTable) defaultTable = findTableByAlias(defaultTableName, editor); defaultTable = defaultTable || []; if (defaultTable.columns) defaultTable = defaultTable.columns; var cur = editor.getCursor(); var result = []; var token = editor.getTokenAt(cur), start, end, search; if (token.end > cur.ch) { token.end = cur.ch; token.string = token.string.slice(0, cur.ch - token.start); } if (token.string.match(/^[.`"'\w@][\w$#]*$/g)) { search = token.string; start = token.start; end = token.end; } else { start = end = cur.ch; search = ""; } if (search.charAt(0) == "." || search.charAt(0) == identifierQuote) { start = nameCompletion(cur, token, result, editor); } else { var objectOrClass = function(w, className) { if (typeof w === "object") { w.className = className; } else { w = { text: w, className: className }; } return w; }; addMatches(result, search, defaultTable, function(w) { return objectOrClass(w, "CodeMirror-hint-table CodeMirror-hint-default-table"); }); addMatches( result, search, tables, function(w) { return objectOrClass(w, "CodeMirror-hint-table"); } ); if (!disableKeywords) addMatches(result, search, keywords, function(w) { return objectOrClass(w.toUpperCase(), "CodeMirror-hint-keyword"); }); } return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)}; }); }); /* ---- extension/hint/xml-hint.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var Pos = CodeMirror.Pos; function matches(hint, typed, matchInMiddle) { if (matchInMiddle) return hint.indexOf(typed) >= 0; else return hint.lastIndexOf(typed, 0) == 0; } function getHints(cm, options) { var tags = options && options.schemaInfo; var quote = (options && options.quoteChar) || '"'; var matchInMiddle = options && options.matchInMiddle; if (!tags) return; var cur = cm.getCursor(), token = cm.getTokenAt(cur); if (token.end > cur.ch) { token.end = cur.ch; token.string = token.string.slice(0, cur.ch - token.start); } var inner = CodeMirror.innerMode(cm.getMode(), token.state); if (!inner.mode.xmlCurrentTag) return var result = [], replaceToken = false, prefix; var tag = /\btag\b/.test(token.type) && !/>$/.test(token.string); var tagName = tag && /^\w/.test(token.string), tagStart; if (tagName) { var before = cm.getLine(cur.line).slice(Math.max(0, token.start - 2), token.start); var tagType = /<\/$/.test(before) ? "close" : /<$/.test(before) ? "open" : null; if (tagType) tagStart = token.start - (tagType == "close" ? 2 : 1); } else if (tag && token.string == "<") { tagType = "open"; } else if (tag && token.string == ""); } else { // Attribute completion var curTag = tagInfo && tags[tagInfo.name], attrs = curTag && curTag.attrs; var globalAttrs = tags["!attrs"]; if (!attrs && !globalAttrs) return; if (!attrs) { attrs = globalAttrs; } else if (globalAttrs) { // Combine tag-local and global attributes var set = {}; for (var nm in globalAttrs) if (globalAttrs.hasOwnProperty(nm)) set[nm] = globalAttrs[nm]; for (var nm in attrs) if (attrs.hasOwnProperty(nm)) set[nm] = attrs[nm]; attrs = set; } if (token.type == "string" || token.string == "=") { // A value var before = cm.getRange(Pos(cur.line, Math.max(0, cur.ch - 60)), Pos(cur.line, token.type == "string" ? token.start : token.end)); var atName = before.match(/([^\s\u00a0=<>\"\']+)=$/), atValues; if (!atName || !attrs.hasOwnProperty(atName[1]) || !(atValues = attrs[atName[1]])) return; if (typeof atValues == 'function') atValues = atValues.call(this, cm); // Functions can be used to supply values for autocomplete widget if (token.type == "string") { prefix = token.string; var n = 0; if (/['"]/.test(token.string.charAt(0))) { quote = token.string.charAt(0); prefix = token.string.slice(1); n++; } var len = token.string.length; if (/['"]/.test(token.string.charAt(len - 1))) { quote = token.string.charAt(len - 1); prefix = token.string.substr(n, len - 2); } if (n) { // an opening quote var line = cm.getLine(cur.line); if (line.length > token.end && line.charAt(token.end) == quote) token.end++; // include a closing quote } replaceToken = true; } for (var i = 0; i < atValues.length; ++i) if (!prefix || matches(atValues[i], prefix, matchInMiddle)) result.push(quote + atValues[i] + quote); } else { // An attribute name if (token.type == "attribute") { prefix = token.string; replaceToken = true; } for (var attr in attrs) if (attrs.hasOwnProperty(attr) && (!prefix || matches(attr, prefix, matchInMiddle))) result.push(attr); } } return { list: result, from: replaceToken ? Pos(cur.line, tagStart == null ? token.start : tagStart) : cur, to: replaceToken ? Pos(cur.line, token.end) : cur }; } CodeMirror.registerHelper("hint", "xml", getHints); }); /* ---- extension/lint/json-lint.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // Depends on jsonlint.js from https://github.com/zaach/jsonlint // declare global: jsonlint (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.registerHelper("lint", "json", function(text) { var found = []; if (!window.jsonlint) { if (window.console) { window.console.error("Error: window.jsonlint not defined, CodeMirror JSON linting cannot run."); } return found; } // for jsonlint's web dist jsonlint is exported as an object with a single property parser, of which parseError // is a subproperty var jsonlint = window.jsonlint.parser || window.jsonlint jsonlint.parseError = function(str, hash) { var loc = hash.loc; found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column), to: CodeMirror.Pos(loc.last_line - 1, loc.last_column), message: str}); }; try { jsonlint.parse(text); } catch(e) {} return found; }); }); /* ---- extension/lint/jsonlint.js ---- */ var jsonlint=function(){var a=!0,b=!1,c={},d=function(){var a={trace:function(){},yy:{},symbols_:{error:2,JSONString:3,STRING:4,JSONNumber:5,NUMBER:6,JSONNullLiteral:7,NULL:8,JSONBooleanLiteral:9,TRUE:10,FALSE:11,JSONText:12,JSONValue:13,EOF:14,JSONObject:15,JSONArray:16,"{":17,"}":18,JSONMemberList:19,JSONMember:20,":":21,",":22,"[":23,"]":24,JSONElementList:25,$accept:0,$end:1},terminals_:{2:"error",4:"STRING",6:"NUMBER",8:"NULL",10:"TRUE",11:"FALSE",14:"EOF",17:"{",18:"}",21:":",22:",",23:"[",24:"]"},productions_:[0,[3,1],[5,1],[7,1],[9,1],[9,1],[12,2],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[15,2],[15,3],[20,3],[19,1],[19,3],[16,2],[16,3],[25,1],[25,3]],performAction:function(b,c,d,e,f,g,h){var i=g.length-1;switch(f){case 1:this.$=b.replace(/\\(\\|")/g,"$1").replace(/\\n/g,"\n").replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\v/g," ").replace(/\\f/g,"\f").replace(/\\b/g,"\b");break;case 2:this.$=Number(b);break;case 3:this.$=null;break;case 4:this.$=!0;break;case 5:this.$=!1;break;case 6:return this.$=g[i-1];case 13:this.$={};break;case 14:this.$=g[i-1];break;case 15:this.$=[g[i-2],g[i]];break;case 16:this.$={},this.$[g[i][0]]=g[i][1];break;case 17:this.$=g[i-2],g[i-2][g[i][0]]=g[i][1];break;case 18:this.$=[];break;case 19:this.$=g[i-1];break;case 20:this.$=[g[i]];break;case 21:this.$=g[i-2],g[i-2].push(g[i])}},table:[{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],12:1,13:2,15:7,16:8,17:[1,14],23:[1,15]},{1:[3]},{14:[1,16]},{14:[2,7],18:[2,7],22:[2,7],24:[2,7]},{14:[2,8],18:[2,8],22:[2,8],24:[2,8]},{14:[2,9],18:[2,9],22:[2,9],24:[2,9]},{14:[2,10],18:[2,10],22:[2,10],24:[2,10]},{14:[2,11],18:[2,11],22:[2,11],24:[2,11]},{14:[2,12],18:[2,12],22:[2,12],24:[2,12]},{14:[2,3],18:[2,3],22:[2,3],24:[2,3]},{14:[2,4],18:[2,4],22:[2,4],24:[2,4]},{14:[2,5],18:[2,5],22:[2,5],24:[2,5]},{14:[2,1],18:[2,1],21:[2,1],22:[2,1],24:[2,1]},{14:[2,2],18:[2,2],22:[2,2],24:[2,2]},{3:20,4:[1,12],18:[1,17],19:18,20:19},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:23,15:7,16:8,17:[1,14],23:[1,15],24:[1,21],25:22},{1:[2,6]},{14:[2,13],18:[2,13],22:[2,13],24:[2,13]},{18:[1,24],22:[1,25]},{18:[2,16],22:[2,16]},{21:[1,26]},{14:[2,18],18:[2,18],22:[2,18],24:[2,18]},{22:[1,28],24:[1,27]},{22:[2,20],24:[2,20]},{14:[2,14],18:[2,14],22:[2,14],24:[2,14]},{3:20,4:[1,12],20:29},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:30,15:7,16:8,17:[1,14],23:[1,15]},{14:[2,19],18:[2,19],22:[2,19],24:[2,19]},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:31,15:7,16:8,17:[1,14],23:[1,15]},{18:[2,17],22:[2,17]},{18:[2,15],22:[2,15]},{22:[2,21],24:[2,21]}],defaultActions:{16:[2,6]},parseError:function(b,c){throw new Error(b)},parse:function(b){function o(a){d.length=d.length-2*a,e.length=e.length-a,f.length=f.length-a}function p(){var a;return a=c.lexer.lex()||1,typeof a!="number"&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(b),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,typeof this.lexer.yylloc=="undefined"&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n),typeof this.yy.parseError=="function"&&(this.parseError=this.yy.parseError);var q,r,s,t,u,v,w={},x,y,z,A;for(;;){s=d[d.length-1],this.defaultActions[s]?t=this.defaultActions[s]:(q==null&&(q=p()),t=g[s]&&g[s][q]);if(typeof t=="undefined"||!t.length||!t[0]){if(!k){A=[];for(x in g[s])this.terminals_[x]&&x>2&&A.push("'"+this.terminals_[x]+"'");var B="";this.lexer.showPosition?B="Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+A.join(", ")+", got '"+this.terminals_[q]+"'":B="Parse error on line "+(i+1)+": Unexpected "+(q==1?"end of input":"'"+(this.terminals_[q]||q)+"'"),this.parseError(B,{text:this.lexer.match,token:this.terminals_[q]||q,line:this.lexer.yylineno,loc:n,expected:A})}if(k==3){if(q==m)throw new Error(B||"Parsing halted.");j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,q=p()}for(;;){if(l.toString()in g[s])break;if(s==0)throw new Error(B||"Parsing halted.");o(1),s=d[d.length-1]}r=q,q=l,s=d[d.length-1],t=g[s]&&g[s][l],k=3}if(t[0]instanceof Array&&t.length>1)throw new Error("Parse Error: multiple actions possible at state: "+s+", token: "+q);switch(t[0]){case 1:d.push(q),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(t[1]),q=null,r?(q=r,r=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:y=this.productions_[t[1]][1],w.$=e[e.length-y],w._$={first_line:f[f.length-(y||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(y||1)].first_column,last_column:f[f.length-1].last_column},v=this.performAction.call(w,h,j,i,this.yy,t[1],e,f);if(typeof v!="undefined")return v;y&&(d=d.slice(0,-1*y*2),e=e.slice(0,-1*y),f=f.slice(0,-1*y)),d.push(this.productions_[t[1]][0]),e.push(w.$),f.push(w._$),z=g[d[d.length-2]][d[d.length-1]],d.push(z);break;case 3:return!0}}return!0}},b=function(){var a={EOF:1,parseError:function(b,c){if(!this.yy.parseError)throw new Error(b);this.yy.parseError(b,c)},setInput:function(a){return this._input=a,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.match+=a,this.matched+=a;var b=a.match(/\n/);return b&&this.yylineno++,this._input=this._input.slice(1),a},unput:function(a){return this._input=a+this._input,this},more:function(){return this._more=!0,this},less:function(a){this._input=this.match.slice(a)+this._input},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=(new Array(a.length+1)).join("-");return a+this.upcomingInput()+"\n"+b+"^"},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d,e,f;this._more||(this.yytext="",this.match="");var g=this._currentRules();for(var h=0;hb[0].length)){b=c,d=h;if(!this.options.flex)break}}if(b){f=b[0].match(/\n.*/g),f&&(this.yylineno+=f.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:f?f[f.length-1].length-1:this.yylloc.last_column+b[0].length},this.yytext+=b[0],this.match+=b[0],this.yyleng=this.yytext.length,this._more=!1,this._input=this._input.slice(b[0].length),this.matched+=b[0],a=this.performAction.call(this,this.yy,this,g[d],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1);if(a)return a;return}if(this._input==="")return this.EOF;this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var b=this.next();return typeof b!="undefined"?b:this.lex()},begin:function(b){this.conditionStack.push(b)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(b){this.begin(b)}};return a.options={},a.performAction=function(b,c,d,e){var f=e;switch(d){case 0:break;case 1:return 6;case 2:return c.yytext=c.yytext.substr(1,c.yyleng-2),4;case 3:return 17;case 4:return 18;case 5:return 23;case 6:return 24;case 7:return 22;case 8:return 21;case 9:return 10;case 10:return 11;case 11:return 8;case 12:return 14;case 13:return"INVALID"}},a.rules=[/^(?:\s+)/,/^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,/^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,/^(?:\{)/,/^(?:\})/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?::)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:null\b)/,/^(?:$)/,/^(?:.)/],a.conditions={INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13],inclusive:!0}},a}();return a.lexer=b,a}();return typeof a!="undefined"&&typeof c!="undefined"&&(c.parser=d,c.parse=function(){return d.parse.apply(d,arguments)},c.main=function(d){if(!d[1])throw new Error("Usage: "+d[0]+" FILE");if(typeof process!="undefined")var e=a("fs").readFileSync(a("path").join(process.cwd(),d[1]),"utf8");else var f=a("file").path(a("file").cwd()),e=f.join(d[1]).read({charset:"utf-8"});return c.parser.parse(e)},typeof b!="undefined"&&a.main===b&&c.main(typeof process!="undefined"?process.argv.slice(1):a("system").args)),c}(); /* ---- extension/lint/lint.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var GUTTER_ID = "CodeMirror-lint-markers"; function showTooltip(cm, e, content) { var tt = document.createElement("div"); tt.className = "CodeMirror-lint-tooltip cm-s-" + cm.options.theme; tt.appendChild(content.cloneNode(true)); if (cm.state.lint.options.selfContain) cm.getWrapperElement().appendChild(tt); else document.body.appendChild(tt); function position(e) { if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position); tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px"; tt.style.left = (e.clientX + 5) + "px"; } CodeMirror.on(document, "mousemove", position); position(e); if (tt.style.opacity != null) tt.style.opacity = 1; return tt; } function rm(elt) { if (elt.parentNode) elt.parentNode.removeChild(elt); } function hideTooltip(tt) { if (!tt.parentNode) return; if (tt.style.opacity == null) rm(tt); tt.style.opacity = 0; setTimeout(function() { rm(tt); }, 600); } function showTooltipFor(cm, e, content, node) { var tooltip = showTooltip(cm, e, content); function hide() { CodeMirror.off(node, "mouseout", hide); if (tooltip) { hideTooltip(tooltip); tooltip = null; } } var poll = setInterval(function() { if (tooltip) for (var n = node;; n = n.parentNode) { if (n && n.nodeType == 11) n = n.host; if (n == document.body) return; if (!n) { hide(); break; } } if (!tooltip) return clearInterval(poll); }, 400); CodeMirror.on(node, "mouseout", hide); } function LintState(cm, options, hasGutter) { this.marked = []; this.options = options; this.timeout = null; this.hasGutter = hasGutter; this.onMouseOver = function(e) { onMouseOver(cm, e); }; this.waitingFor = 0 } function parseOptions(_cm, options) { if (options instanceof Function) return {getAnnotations: options}; if (!options || options === true) options = {}; return options; } function clearMarks(cm) { var state = cm.state.lint; if (state.hasGutter) cm.clearGutter(GUTTER_ID); for (var i = 0; i < state.marked.length; ++i) state.marked[i].clear(); state.marked.length = 0; } function makeMarker(cm, labels, severity, multiple, tooltips) { var marker = document.createElement("div"), inner = marker; marker.className = "CodeMirror-lint-marker-" + severity; if (multiple) { inner = marker.appendChild(document.createElement("div")); inner.className = "CodeMirror-lint-marker-multiple"; } if (tooltips != false) CodeMirror.on(inner, "mouseover", function(e) { showTooltipFor(cm, e, labels, inner); }); return marker; } function getMaxSeverity(a, b) { if (a == "error") return a; else return b; } function groupByLine(annotations) { var lines = []; for (var i = 0; i < annotations.length; ++i) { var ann = annotations[i], line = ann.from.line; (lines[line] || (lines[line] = [])).push(ann); } return lines; } function annotationTooltip(ann) { var severity = ann.severity; if (!severity) severity = "error"; var tip = document.createElement("div"); tip.className = "CodeMirror-lint-message-" + severity; if (typeof ann.messageHTML != 'undefined') { tip.innerHTML = ann.messageHTML; } else { tip.appendChild(document.createTextNode(ann.message)); } return tip; } function lintAsync(cm, getAnnotations, passOptions) { var state = cm.state.lint var id = ++state.waitingFor function abort() { id = -1 cm.off("change", abort) } cm.on("change", abort) getAnnotations(cm.getValue(), function(annotations, arg2) { cm.off("change", abort) if (state.waitingFor != id) return if (arg2 && annotations instanceof CodeMirror) annotations = arg2 cm.operation(function() {updateLinting(cm, annotations)}) }, passOptions, cm); } function startLinting(cm) { var state = cm.state.lint, options = state.options; /* * Passing rules in `options` property prevents JSHint (and other linters) from complaining * about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc. */ var passOptions = options.options || options; var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint"); if (!getAnnotations) return; if (options.async || getAnnotations.async) { lintAsync(cm, getAnnotations, passOptions) } else { var annotations = getAnnotations(cm.getValue(), passOptions, cm); if (!annotations) return; if (annotations.then) annotations.then(function(issues) { cm.operation(function() {updateLinting(cm, issues)}) }); else cm.operation(function() {updateLinting(cm, annotations)}) } } function updateLinting(cm, annotationsNotSorted) { clearMarks(cm); var state = cm.state.lint, options = state.options; var annotations = groupByLine(annotationsNotSorted); for (var line = 0; line < annotations.length; ++line) { var anns = annotations[line]; if (!anns) continue; var maxSeverity = null; var tipLabel = state.hasGutter && document.createDocumentFragment(); for (var i = 0; i < anns.length; ++i) { var ann = anns[i]; var severity = ann.severity; if (!severity) severity = "error"; maxSeverity = getMaxSeverity(maxSeverity, severity); if (options.formatAnnotation) ann = options.formatAnnotation(ann); if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann)); if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, { className: "CodeMirror-lint-mark-" + severity, __annotation: ann })); } if (state.hasGutter) cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, anns.length > 1, state.options.tooltips)); } if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm); } function onChange(cm) { var state = cm.state.lint; if (!state) return; clearTimeout(state.timeout); state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500); } function popupTooltips(cm, annotations, e) { var target = e.target || e.srcElement; var tooltip = document.createDocumentFragment(); for (var i = 0; i < annotations.length; i++) { var ann = annotations[i]; tooltip.appendChild(annotationTooltip(ann)); } showTooltipFor(cm, e, tooltip, target); } function onMouseOver(cm, e) { var target = e.target || e.srcElement; if (!/\bCodeMirror-lint-mark-/.test(target.className)) return; var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2; var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client")); var annotations = []; for (var i = 0; i < spans.length; ++i) { var ann = spans[i].__annotation; if (ann) annotations.push(ann); } if (annotations.length) popupTooltips(cm, annotations, e); } CodeMirror.defineOption("lint", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { clearMarks(cm); if (cm.state.lint.options.lintOnChange !== false) cm.off("change", onChange); CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver); clearTimeout(cm.state.lint.timeout); delete cm.state.lint; } if (val) { var gutters = cm.getOption("gutters"), hasLintGutter = false; for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true; var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter); if (state.options.lintOnChange !== false) cm.on("change", onChange); if (state.options.tooltips != false && state.options.tooltips != "gutter") CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver); startLinting(cm); } }); CodeMirror.defineExtension("performLint", function() { if (this.state.lint) startLinting(this); }); }); /* ---- extension/scroll/annotatescrollbar.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineExtension("annotateScrollbar", function(options) { if (typeof options == "string") options = {className: options}; return new Annotation(this, options); }); CodeMirror.defineOption("scrollButtonHeight", 0); function Annotation(cm, options) { this.cm = cm; this.options = options; this.buttonHeight = options.scrollButtonHeight || cm.getOption("scrollButtonHeight"); this.annotations = []; this.doRedraw = this.doUpdate = null; this.div = cm.getWrapperElement().appendChild(document.createElement("div")); this.div.style.cssText = "position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none"; this.computeScale(); function scheduleRedraw(delay) { clearTimeout(self.doRedraw); self.doRedraw = setTimeout(function() { self.redraw(); }, delay); } var self = this; cm.on("refresh", this.resizeHandler = function() { clearTimeout(self.doUpdate); self.doUpdate = setTimeout(function() { if (self.computeScale()) scheduleRedraw(20); }, 100); }); cm.on("markerAdded", this.resizeHandler); cm.on("markerCleared", this.resizeHandler); if (options.listenForChanges !== false) cm.on("changes", this.changeHandler = function() { scheduleRedraw(250); }); } Annotation.prototype.computeScale = function() { var cm = this.cm; var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight - this.buttonHeight * 2) / cm.getScrollerElement().scrollHeight if (hScale != this.hScale) { this.hScale = hScale; return true; } }; Annotation.prototype.update = function(annotations) { this.annotations = annotations; this.redraw(); }; Annotation.prototype.redraw = function(compute) { if (compute !== false) this.computeScale(); var cm = this.cm, hScale = this.hScale; var frag = document.createDocumentFragment(), anns = this.annotations; var wrapping = cm.getOption("lineWrapping"); var singleLineH = wrapping && cm.defaultTextHeight() * 1.5; var curLine = null, curLineObj = null; function getY(pos, top) { if (curLine != pos.line) { curLine = pos.line; curLineObj = cm.getLineHandle(curLine); } if ((curLineObj.widgets && curLineObj.widgets.length) || (wrapping && curLineObj.height > singleLineH)) return cm.charCoords(pos, "local")[top ? "top" : "bottom"]; var topY = cm.heightAtLine(curLineObj, "local"); return topY + (top ? 0 : curLineObj.height); } var lastLine = cm.lastLine() if (cm.display.barWidth) for (var i = 0, nextTop; i < anns.length; i++) { var ann = anns[i]; if (ann.to.line > lastLine) continue; var top = nextTop || getY(ann.from, true) * hScale; var bottom = getY(ann.to, false) * hScale; while (i < anns.length - 1) { if (anns[i + 1].to.line > lastLine) break; nextTop = getY(anns[i + 1].from, true) * hScale; if (nextTop > bottom + .9) break; ann = anns[++i]; bottom = getY(ann.to, false) * hScale; } if (bottom == top) continue; var height = Math.max(bottom - top, 3); var elt = frag.appendChild(document.createElement("div")); elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth - 1, 2) + "px; top: " + (top + this.buttonHeight) + "px; height: " + height + "px"; elt.className = this.options.className; if (ann.id) { elt.setAttribute("annotation-id", ann.id); } } this.div.textContent = ""; this.div.appendChild(frag); }; Annotation.prototype.clear = function() { this.cm.off("refresh", this.resizeHandler); this.cm.off("markerAdded", this.resizeHandler); this.cm.off("markerCleared", this.resizeHandler); if (this.changeHandler) this.cm.off("changes", this.changeHandler); this.div.parentNode.removeChild(this.div); }; }); /* ---- extension/scroll/scrollpastend.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineOption("scrollPastEnd", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { cm.off("change", onChange); cm.off("refresh", updateBottomMargin); cm.display.lineSpace.parentNode.style.paddingBottom = ""; cm.state.scrollPastEndPadding = null; } if (val) { cm.on("change", onChange); cm.on("refresh", updateBottomMargin); updateBottomMargin(cm); } }); function onChange(cm, change) { if (CodeMirror.changeEnd(change).line == cm.lastLine()) updateBottomMargin(cm); } function updateBottomMargin(cm) { var padding = ""; if (cm.lineCount() > 1) { var totalH = cm.display.scroller.clientHeight - 30, lastLineH = cm.getLineHandle(cm.lastLine()).height; padding = (totalH - lastLineH) + "px"; } if (cm.state.scrollPastEndPadding != padding) { cm.state.scrollPastEndPadding = padding; cm.display.lineSpace.parentNode.style.paddingBottom = padding; cm.off("refresh", updateBottomMargin); cm.setSize(); cm.on("refresh", updateBottomMargin); } } }); /* ---- extension/scroll/simplescrollbars.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; function Bar(cls, orientation, scroll) { this.orientation = orientation; this.scroll = scroll; this.screen = this.total = this.size = 1; this.pos = 0; this.node = document.createElement("div"); this.node.className = cls + "-" + orientation; this.inner = this.node.appendChild(document.createElement("div")); var self = this; CodeMirror.on(this.inner, "mousedown", function(e) { if (e.which != 1) return; CodeMirror.e_preventDefault(e); var axis = self.orientation == "horizontal" ? "pageX" : "pageY"; var start = e[axis], startpos = self.pos; function done() { CodeMirror.off(document, "mousemove", move); CodeMirror.off(document, "mouseup", done); } function move(e) { if (e.which != 1) return done(); self.moveTo(startpos + (e[axis] - start) * (self.total / self.size)); } CodeMirror.on(document, "mousemove", move); CodeMirror.on(document, "mouseup", done); }); CodeMirror.on(this.node, "click", function(e) { CodeMirror.e_preventDefault(e); var innerBox = self.inner.getBoundingClientRect(), where; if (self.orientation == "horizontal") where = e.clientX < innerBox.left ? -1 : e.clientX > innerBox.right ? 1 : 0; else where = e.clientY < innerBox.top ? -1 : e.clientY > innerBox.bottom ? 1 : 0; self.moveTo(self.pos + where * self.screen); }); function onWheel(e) { var moved = CodeMirror.wheelEventPixels(e)[self.orientation == "horizontal" ? "x" : "y"]; var oldPos = self.pos; self.moveTo(self.pos + moved); if (self.pos != oldPos) CodeMirror.e_preventDefault(e); } CodeMirror.on(this.node, "mousewheel", onWheel); CodeMirror.on(this.node, "DOMMouseScroll", onWheel); } Bar.prototype.setPos = function(pos, force) { if (pos < 0) pos = 0; if (pos > this.total - this.screen) pos = this.total - this.screen; if (!force && pos == this.pos) return false; this.pos = pos; this.inner.style[this.orientation == "horizontal" ? "left" : "top"] = (pos * (this.size / this.total)) + "px"; return true }; Bar.prototype.moveTo = function(pos) { if (this.setPos(pos)) this.scroll(pos, this.orientation); } var minButtonSize = 10; Bar.prototype.update = function(scrollSize, clientSize, barSize) { var sizeChanged = this.screen != clientSize || this.total != scrollSize || this.size != barSize if (sizeChanged) { this.screen = clientSize; this.total = scrollSize; this.size = barSize; } var buttonSize = this.screen * (this.size / this.total); if (buttonSize < minButtonSize) { this.size -= minButtonSize - buttonSize; buttonSize = minButtonSize; } this.inner.style[this.orientation == "horizontal" ? "width" : "height"] = buttonSize + "px"; this.setPos(this.pos, sizeChanged); }; function SimpleScrollbars(cls, place, scroll) { this.addClass = cls; this.horiz = new Bar(cls, "horizontal", scroll); place(this.horiz.node); this.vert = new Bar(cls, "vertical", scroll); place(this.vert.node); this.width = null; } SimpleScrollbars.prototype.update = function(measure) { if (this.width == null) { var style = window.getComputedStyle ? window.getComputedStyle(this.horiz.node) : this.horiz.node.currentStyle; if (style) this.width = parseInt(style.height); } var width = this.width || 0; var needsH = measure.scrollWidth > measure.clientWidth + 1; var needsV = measure.scrollHeight > measure.clientHeight + 1; this.vert.node.style.display = needsV ? "block" : "none"; this.horiz.node.style.display = needsH ? "block" : "none"; if (needsV) { this.vert.update(measure.scrollHeight, measure.clientHeight, measure.viewHeight - (needsH ? width : 0)); this.vert.node.style.bottom = needsH ? width + "px" : "0"; } if (needsH) { this.horiz.update(measure.scrollWidth, measure.clientWidth, measure.viewWidth - (needsV ? width : 0) - measure.barLeft); this.horiz.node.style.right = needsV ? width + "px" : "0"; this.horiz.node.style.left = measure.barLeft + "px"; } return {right: needsV ? width : 0, bottom: needsH ? width : 0}; }; SimpleScrollbars.prototype.setScrollTop = function(pos) { this.vert.setPos(pos); }; SimpleScrollbars.prototype.setScrollLeft = function(pos) { this.horiz.setPos(pos); }; SimpleScrollbars.prototype.clear = function() { var parent = this.horiz.node.parentNode; parent.removeChild(this.horiz.node); parent.removeChild(this.vert.node); }; CodeMirror.scrollbarModel.simple = function(place, scroll) { return new SimpleScrollbars("CodeMirror-simplescroll", place, scroll); }; CodeMirror.scrollbarModel.overlay = function(place, scroll) { return new SimpleScrollbars("CodeMirror-overlayscroll", place, scroll); }; }); /* ---- extension/search/jump-to-line.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // Defines jumpToLine command. Uses dialog.js if present. (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../dialog/dialog")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../dialog/dialog"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; function dialog(cm, text, shortText, deflt, f) { if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true}); else f(prompt(shortText, deflt)); } function getJumpDialog(cm) { return cm.phrase("Jump to line:") + ' ' + cm.phrase("(Use line:column or scroll% syntax)") + ''; } function interpretLine(cm, string) { var num = Number(string) if (/^[-+]/.test(string)) return cm.getCursor().line + num else return num - 1 } CodeMirror.commands.jumpToLine = function(cm) { var cur = cm.getCursor(); dialog(cm, getJumpDialog(cm), cm.phrase("Jump to line:"), (cur.line + 1) + ":" + cur.ch, function(posStr) { if (!posStr) return; var match; if (match = /^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(posStr)) { cm.setCursor(interpretLine(cm, match[1]), Number(match[2])) } else if (match = /^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(posStr)) { var line = Math.round(cm.lineCount() * Number(match[1]) / 100); if (/^[-+]/.test(match[1])) line = cur.line + line + 1; cm.setCursor(line - 1, cur.ch); } else if (match = /^\s*\:?\s*([\+\-]?\d+)\s*/.exec(posStr)) { cm.setCursor(interpretLine(cm, match[1]), cur.ch); } }); }; CodeMirror.keyMap["default"]["Alt-G"] = "jumpToLine"; }); /* ---- extension/search/match-highlighter.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // Highlighting text that matches the selection // // Defines an option highlightSelectionMatches, which, when enabled, // will style strings that match the selection throughout the // document. // // The option can be set to true to simply enable it, or to a // {minChars, style, wordsOnly, showToken, delay} object to explicitly // configure it. minChars is the minimum amount of characters that should be // selected for the behavior to occur, and style is the token style to // apply to the matches. This will be prefixed by "cm-" to create an // actual CSS class name. If wordsOnly is enabled, the matches will be // highlighted only if the selected text is a word. showToken, when enabled, // will cause the current token to be highlighted when nothing is selected. // delay is used to specify how much time to wait, in milliseconds, before // highlighting the matches. If annotateScrollbar is enabled, the occurences // will be highlighted on the scrollbar via the matchesonscrollbar addon. (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("./matchesonscrollbar")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "./matchesonscrollbar"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var defaults = { style: "matchhighlight", minChars: 2, delay: 100, wordsOnly: false, annotateScrollbar: false, showToken: false, trim: true } function State(options) { this.options = {} for (var name in defaults) this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name] this.overlay = this.timeout = null; this.matchesonscroll = null; this.active = false; } CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { removeOverlay(cm); clearTimeout(cm.state.matchHighlighter.timeout); cm.state.matchHighlighter = null; cm.off("cursorActivity", cursorActivity); cm.off("focus", onFocus) } if (val) { var state = cm.state.matchHighlighter = new State(val); if (cm.hasFocus()) { state.active = true highlightMatches(cm) } else { cm.on("focus", onFocus) } cm.on("cursorActivity", cursorActivity); } }); function cursorActivity(cm) { var state = cm.state.matchHighlighter; if (state.active || cm.hasFocus()) scheduleHighlight(cm, state) } function onFocus(cm) { var state = cm.state.matchHighlighter if (!state.active) { state.active = true scheduleHighlight(cm, state) } } function scheduleHighlight(cm, state) { clearTimeout(state.timeout); state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay); } function addOverlay(cm, query, hasBoundary, style) { var state = cm.state.matchHighlighter; cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style)); if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) { var searchFor = hasBoundary ? new RegExp((/\w/.test(query.charAt(0)) ? "\\b" : "") + query.replace(/[\\\[.+*?(){|^$]/g, "\\$&") + (/\w/.test(query.charAt(query.length - 1)) ? "\\b" : "")) : query; state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, false, {className: "CodeMirror-selection-highlight-scrollbar"}); } } function removeOverlay(cm) { var state = cm.state.matchHighlighter; if (state.overlay) { cm.removeOverlay(state.overlay); state.overlay = null; if (state.matchesonscroll) { state.matchesonscroll.clear(); state.matchesonscroll = null; } } } function highlightMatches(cm) { cm.operation(function() { var state = cm.state.matchHighlighter; removeOverlay(cm); if (!cm.somethingSelected() && state.options.showToken) { var re = state.options.showToken === true ? /[\w$]/ : state.options.showToken; var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start; while (start && re.test(line.charAt(start - 1))) --start; while (end < line.length && re.test(line.charAt(end))) ++end; if (start < end) addOverlay(cm, line.slice(start, end), re, state.options.style); return; } var from = cm.getCursor("from"), to = cm.getCursor("to"); if (from.line != to.line) return; if (state.options.wordsOnly && !isWord(cm, from, to)) return; var selection = cm.getRange(from, to) if (state.options.trim) selection = selection.replace(/^\s+|\s+$/g, "") if (selection.length >= state.options.minChars) addOverlay(cm, selection, false, state.options.style); }); } function isWord(cm, from, to) { var str = cm.getRange(from, to); if (str.match(/^\w+$/) !== null) { if (from.ch > 0) { var pos = {line: from.line, ch: from.ch - 1}; var chr = cm.getRange(pos, from); if (chr.match(/\W/) === null) return false; } if (to.ch < cm.getLine(from.line).length) { var pos = {line: to.line, ch: to.ch + 1}; var chr = cm.getRange(to, pos); if (chr.match(/\W/) === null) return false; } return true; } else return false; } function boundariesAround(stream, re) { return (!stream.start || !re.test(stream.string.charAt(stream.start - 1))) && (stream.pos == stream.string.length || !re.test(stream.string.charAt(stream.pos))); } function makeOverlay(query, hasBoundary, style) { return {token: function(stream) { if (stream.match(query) && (!hasBoundary || boundariesAround(stream, hasBoundary))) return style; stream.next(); stream.skipTo(query.charAt(0)) || stream.skipToEnd(); }}; } }); /* ---- extension/search/matchesonscrollbar.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("./searchcursor"), require("../scroll/annotatescrollbar")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "./searchcursor", "../scroll/annotatescrollbar"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineExtension("showMatchesOnScrollbar", function(query, caseFold, options) { if (typeof options == "string") options = {className: options}; if (!options) options = {}; return new SearchAnnotation(this, query, caseFold, options); }); function SearchAnnotation(cm, query, caseFold, options) { this.cm = cm; this.options = options; var annotateOptions = {listenForChanges: false}; for (var prop in options) annotateOptions[prop] = options[prop]; if (!annotateOptions.className) annotateOptions.className = "CodeMirror-search-match"; this.annotation = cm.annotateScrollbar(annotateOptions); this.query = query; this.caseFold = caseFold; this.gap = {from: cm.firstLine(), to: cm.lastLine() + 1}; this.matches = []; this.update = null; this.findMatches(); this.annotation.update(this.matches); var self = this; cm.on("change", this.changeHandler = function(_cm, change) { self.onChange(change); }); } var MAX_MATCHES = 1000; SearchAnnotation.prototype.findMatches = function() { if (!this.gap) return; for (var i = 0; i < this.matches.length; i++) { var match = this.matches[i]; if (match.from.line >= this.gap.to) break; if (match.to.line >= this.gap.from) this.matches.splice(i--, 1); } var cursor = this.cm.getSearchCursor(this.query, CodeMirror.Pos(this.gap.from, 0), {caseFold: this.caseFold, multiline: this.options.multiline}); var maxMatches = this.options && this.options.maxMatches || MAX_MATCHES; while (cursor.findNext()) { var match = {from: cursor.from(), to: cursor.to()}; if (match.from.line >= this.gap.to) break; this.matches.splice(i++, 0, match); if (this.matches.length > maxMatches) break; } this.gap = null; }; function offsetLine(line, changeStart, sizeChange) { if (line <= changeStart) return line; return Math.max(changeStart, line + sizeChange); } SearchAnnotation.prototype.onChange = function(change) { var startLine = change.from.line; var endLine = CodeMirror.changeEnd(change).line; var sizeChange = endLine - change.to.line; if (this.gap) { this.gap.from = Math.min(offsetLine(this.gap.from, startLine, sizeChange), change.from.line); this.gap.to = Math.max(offsetLine(this.gap.to, startLine, sizeChange), change.from.line); } else { this.gap = {from: change.from.line, to: endLine + 1}; } if (sizeChange) for (var i = 0; i < this.matches.length; i++) { var match = this.matches[i]; var newFrom = offsetLine(match.from.line, startLine, sizeChange); if (newFrom != match.from.line) match.from = CodeMirror.Pos(newFrom, match.from.ch); var newTo = offsetLine(match.to.line, startLine, sizeChange); if (newTo != match.to.line) match.to = CodeMirror.Pos(newTo, match.to.ch); } clearTimeout(this.update); var self = this; this.update = setTimeout(function() { self.updateAfterChange(); }, 250); }; SearchAnnotation.prototype.updateAfterChange = function() { this.findMatches(); this.annotation.update(this.matches); }; SearchAnnotation.prototype.clear = function() { this.cm.off("change", this.changeHandler); this.annotation.clear(); }; }); /* ---- extension/search/search.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // Define search commands. Depends on dialog.js or another // implementation of the openDialog method. // Replace works a little oddly -- it will do the replace on the next // Ctrl-G (or whatever is bound to findNext) press. You prevent a // replace by making sure the match is no longer selected when hitting // Ctrl-G. (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("./searchcursor"), require("../dialog/dialog")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "./searchcursor", "../dialog/dialog"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; function searchOverlay(query, caseInsensitive) { if (typeof query == "string") query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g"); else if (!query.global) query = new RegExp(query.source, query.ignoreCase ? "gi" : "g"); return {token: function(stream) { query.lastIndex = stream.pos; var match = query.exec(stream.string); if (match && match.index == stream.pos) { stream.pos += match[0].length || 1; return "searching"; } else if (match) { stream.pos = match.index; } else { stream.skipToEnd(); } }}; } function SearchState() { this.posFrom = this.posTo = this.lastQuery = this.query = null; this.overlay = null; } function getSearchState(cm) { return cm.state.search || (cm.state.search = new SearchState()); } function queryCaseInsensitive(query) { return typeof query == "string" && query == query.toLowerCase(); } function getSearchCursor(cm, query, pos) { // Heuristic: if the query string is all lowercase, do a case insensitive search. return cm.getSearchCursor(query, pos, {caseFold: queryCaseInsensitive(query), multiline: true}); } function persistentDialog(cm, text, deflt, onEnter, onKeyDown) { cm.openDialog(text, onEnter, { value: deflt, selectValueOnOpen: true, closeOnEnter: false, onClose: function() { clearSearch(cm); }, onKeyDown: onKeyDown }); } function dialog(cm, text, shortText, deflt, f) { if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true}); else f(prompt(shortText, deflt)); } function confirmDialog(cm, text, shortText, fs) { if (cm.openConfirm) cm.openConfirm(text, fs); else if (confirm(shortText)) fs[0](); } function parseString(string) { return string.replace(/\\([nrt\\])/g, function(match, ch) { if (ch == "n") return "\n" if (ch == "r") return "\r" if (ch == "t") return "\t" if (ch == "\\") return "\\" return match }) } function parseQuery(query) { var isRE = query.match(/^\/(.*)\/([a-z]*)$/); if (isRE) { try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); } catch(e) {} // Not a regular expression after all, do a string search } else { query = parseString(query) } if (typeof query == "string" ? query == "" : query.test("")) query = /x^/; return query; } function startSearch(cm, state, query) { state.queryText = query; state.query = parseQuery(query); cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query)); state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query)); cm.addOverlay(state.overlay); if (cm.showMatchesOnScrollbar) { if (state.annotate) { state.annotate.clear(); state.annotate = null; } state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query)); } } function doSearch(cm, rev, persistent, immediate) { var state = getSearchState(cm); if (state.query) return findNext(cm, rev); var q = cm.getSelection() || state.lastQuery; if (q instanceof RegExp && q.source == "x^") q = null if (persistent && cm.openDialog) { var hiding = null var searchNext = function(query, event) { CodeMirror.e_stop(event); if (!query) return; if (query != state.queryText) { startSearch(cm, state, query); state.posFrom = state.posTo = cm.getCursor(); } if (hiding) hiding.style.opacity = 1 findNext(cm, event.shiftKey, function(_, to) { var dialog if (to.line < 3 && document.querySelector && (dialog = cm.display.wrapper.querySelector(".CodeMirror-dialog")) && dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top) (hiding = dialog).style.opacity = .4 }) }; persistentDialog(cm, getQueryDialog(cm), q, searchNext, function(event, query) { var keyName = CodeMirror.keyName(event) var extra = cm.getOption('extraKeys'), cmd = (extra && extra[keyName]) || CodeMirror.keyMap[cm.getOption("keyMap")][keyName] if (cmd == "findNext" || cmd == "findPrev" || cmd == "findPersistentNext" || cmd == "findPersistentPrev") { CodeMirror.e_stop(event); startSearch(cm, getSearchState(cm), query); cm.execCommand(cmd); } else if (cmd == "find" || cmd == "findPersistent") { CodeMirror.e_stop(event); searchNext(query, event); } }); if (immediate && q) { startSearch(cm, state, q); findNext(cm, rev); } } else { dialog(cm, getQueryDialog(cm), "Search for:", q, function(query) { if (query && !state.query) cm.operation(function() { startSearch(cm, state, query); state.posFrom = state.posTo = cm.getCursor(); findNext(cm, rev); }); }); } } function findNext(cm, rev, callback) {cm.operation(function() { var state = getSearchState(cm); var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo); if (!cursor.find(rev)) { cursor = getSearchCursor(cm, state.query, rev ? CodeMirror.Pos(cm.lastLine()) : CodeMirror.Pos(cm.firstLine(), 0)); if (!cursor.find(rev)) return; } cm.setSelection(cursor.from(), cursor.to()); cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20); state.posFrom = cursor.from(); state.posTo = cursor.to(); if (callback) callback(cursor.from(), cursor.to()) });} function clearSearch(cm) {cm.operation(function() { var state = getSearchState(cm); state.lastQuery = state.query; if (!state.query) return; state.query = state.queryText = null; cm.removeOverlay(state.overlay); if (state.annotate) { state.annotate.clear(); state.annotate = null; } });} function getQueryDialog(cm) { return '' + cm.phrase("Search:") + ' ' + cm.phrase("(Use /re/ syntax for regexp search)") + ''; } function getReplaceQueryDialog(cm) { return ' ' + cm.phrase("(Use /re/ syntax for regexp search)") + ''; } function getReplacementQueryDialog(cm) { return '' + cm.phrase("With:") + ' '; } function getDoReplaceConfirm(cm) { return '' + cm.phrase("Replace?") + ' '; } function replaceAll(cm, query, text) { cm.operation(function() { for (var cursor = getSearchCursor(cm, query); cursor.findNext();) { if (typeof query != "string") { var match = cm.getRange(cursor.from(), cursor.to()).match(query); cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];})); } else cursor.replace(text); } }); } function replace(cm, all) { if (cm.getOption("readOnly")) return; var query = cm.getSelection() || getSearchState(cm).lastQuery; var dialogText = '' + (all ? cm.phrase("Replace all:") : cm.phrase("Replace:")) + ''; dialog(cm, dialogText + getReplaceQueryDialog(cm), dialogText, query, function(query) { if (!query) return; query = parseQuery(query); dialog(cm, getReplacementQueryDialog(cm), cm.phrase("Replace with:"), "", function(text) { text = parseString(text) if (all) { replaceAll(cm, query, text) } else { clearSearch(cm); var cursor = getSearchCursor(cm, query, cm.getCursor("from")); var advance = function() { var start = cursor.from(), match; if (!(match = cursor.findNext())) { cursor = getSearchCursor(cm, query); if (!(match = cursor.findNext()) || (start && cursor.from().line == start.line && cursor.from().ch == start.ch)) return; } cm.setSelection(cursor.from(), cursor.to()); cm.scrollIntoView({from: cursor.from(), to: cursor.to()}); confirmDialog(cm, getDoReplaceConfirm(cm), cm.phrase("Replace?"), [function() {doReplace(match);}, advance, function() {replaceAll(cm, query, text)}]); }; var doReplace = function(match) { cursor.replace(typeof query == "string" ? text : text.replace(/\$(\d)/g, function(_, i) {return match[i];})); advance(); }; advance(); } }); }); } CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);}; CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);}; CodeMirror.commands.findPersistentNext = function(cm) {doSearch(cm, false, true, true);}; CodeMirror.commands.findPersistentPrev = function(cm) {doSearch(cm, true, true, true);}; CodeMirror.commands.findNext = doSearch; CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);}; CodeMirror.commands.clearSearch = clearSearch; CodeMirror.commands.replace = replace; CodeMirror.commands.replaceAll = function(cm) {replace(cm, true);}; }); /* ---- extension/search/searchcursor.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")) else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod) else // Plain browser env mod(CodeMirror) })(function(CodeMirror) { "use strict" var Pos = CodeMirror.Pos function regexpFlags(regexp) { var flags = regexp.flags return flags != null ? flags : (regexp.ignoreCase ? "i" : "") + (regexp.global ? "g" : "") + (regexp.multiline ? "m" : "") } function ensureFlags(regexp, flags) { var current = regexpFlags(regexp), target = current for (var i = 0; i < flags.length; i++) if (target.indexOf(flags.charAt(i)) == -1) target += flags.charAt(i) return current == target ? regexp : new RegExp(regexp.source, target) } function maybeMultiline(regexp) { return /\\s|\\n|\n|\\W|\\D|\[\^/.test(regexp.source) } function searchRegexpForward(doc, regexp, start) { regexp = ensureFlags(regexp, "g") for (var line = start.line, ch = start.ch, last = doc.lastLine(); line <= last; line++, ch = 0) { regexp.lastIndex = ch var string = doc.getLine(line), match = regexp.exec(string) if (match) return {from: Pos(line, match.index), to: Pos(line, match.index + match[0].length), match: match} } } function searchRegexpForwardMultiline(doc, regexp, start) { if (!maybeMultiline(regexp)) return searchRegexpForward(doc, regexp, start) regexp = ensureFlags(regexp, "gm") var string, chunk = 1 for (var line = start.line, last = doc.lastLine(); line <= last;) { // This grows the search buffer in exponentially-sized chunks // between matches, so that nearby matches are fast and don't // require concatenating the whole document (in case we're // searching for something that has tons of matches), but at the // same time, the amount of retries is limited. for (var i = 0; i < chunk; i++) { if (line > last) break var curLine = doc.getLine(line++) string = string == null ? curLine : string + "\n" + curLine } chunk = chunk * 2 regexp.lastIndex = start.ch var match = regexp.exec(string) if (match) { var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n") var startLine = start.line + before.length - 1, startCh = before[before.length - 1].length return {from: Pos(startLine, startCh), to: Pos(startLine + inside.length - 1, inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length), match: match} } } } function lastMatchIn(string, regexp, endMargin) { var match, from = 0 while (from <= string.length) { regexp.lastIndex = from var newMatch = regexp.exec(string) if (!newMatch) break var end = newMatch.index + newMatch[0].length if (end > string.length - endMargin) break if (!match || end > match.index + match[0].length) match = newMatch from = newMatch.index + 1 } return match } function searchRegexpBackward(doc, regexp, start) { regexp = ensureFlags(regexp, "g") for (var line = start.line, ch = start.ch, first = doc.firstLine(); line >= first; line--, ch = -1) { var string = doc.getLine(line) var match = lastMatchIn(string, regexp, ch < 0 ? 0 : string.length - ch) if (match) return {from: Pos(line, match.index), to: Pos(line, match.index + match[0].length), match: match} } } function searchRegexpBackwardMultiline(doc, regexp, start) { if (!maybeMultiline(regexp)) return searchRegexpBackward(doc, regexp, start) regexp = ensureFlags(regexp, "gm") var string, chunkSize = 1, endMargin = doc.getLine(start.line).length - start.ch for (var line = start.line, first = doc.firstLine(); line >= first;) { for (var i = 0; i < chunkSize && line >= first; i++) { var curLine = doc.getLine(line--) string = string == null ? curLine : curLine + "\n" + string } chunkSize *= 2 var match = lastMatchIn(string, regexp, endMargin) if (match) { var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n") var startLine = line + before.length, startCh = before[before.length - 1].length return {from: Pos(startLine, startCh), to: Pos(startLine + inside.length - 1, inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length), match: match} } } } var doFold, noFold if (String.prototype.normalize) { doFold = function(str) { return str.normalize("NFD").toLowerCase() } noFold = function(str) { return str.normalize("NFD") } } else { doFold = function(str) { return str.toLowerCase() } noFold = function(str) { return str } } // Maps a position in a case-folded line back to a position in the original line // (compensating for codepoints increasing in number during folding) function adjustPos(orig, folded, pos, foldFunc) { if (orig.length == folded.length) return pos for (var min = 0, max = pos + Math.max(0, orig.length - folded.length);;) { if (min == max) return min var mid = (min + max) >> 1 var len = foldFunc(orig.slice(0, mid)).length if (len == pos) return mid else if (len > pos) max = mid else min = mid + 1 } } function searchStringForward(doc, query, start, caseFold) { // Empty string would match anything and never progress, so we // define it to match nothing instead. if (!query.length) return null var fold = caseFold ? doFold : noFold var lines = fold(query).split(/\r|\n\r?/) search: for (var line = start.line, ch = start.ch, last = doc.lastLine() + 1 - lines.length; line <= last; line++, ch = 0) { var orig = doc.getLine(line).slice(ch), string = fold(orig) if (lines.length == 1) { var found = string.indexOf(lines[0]) if (found == -1) continue search var start = adjustPos(orig, string, found, fold) + ch return {from: Pos(line, adjustPos(orig, string, found, fold) + ch), to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold) + ch)} } else { var cutFrom = string.length - lines[0].length if (string.slice(cutFrom) != lines[0]) continue search for (var i = 1; i < lines.length - 1; i++) if (fold(doc.getLine(line + i)) != lines[i]) continue search var end = doc.getLine(line + lines.length - 1), endString = fold(end), lastLine = lines[lines.length - 1] if (endString.slice(0, lastLine.length) != lastLine) continue search return {from: Pos(line, adjustPos(orig, string, cutFrom, fold) + ch), to: Pos(line + lines.length - 1, adjustPos(end, endString, lastLine.length, fold))} } } } function searchStringBackward(doc, query, start, caseFold) { if (!query.length) return null var fold = caseFold ? doFold : noFold var lines = fold(query).split(/\r|\n\r?/) search: for (var line = start.line, ch = start.ch, first = doc.firstLine() - 1 + lines.length; line >= first; line--, ch = -1) { var orig = doc.getLine(line) if (ch > -1) orig = orig.slice(0, ch) var string = fold(orig) if (lines.length == 1) { var found = string.lastIndexOf(lines[0]) if (found == -1) continue search return {from: Pos(line, adjustPos(orig, string, found, fold)), to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold))} } else { var lastLine = lines[lines.length - 1] if (string.slice(0, lastLine.length) != lastLine) continue search for (var i = 1, start = line - lines.length + 1; i < lines.length - 1; i++) if (fold(doc.getLine(start + i)) != lines[i]) continue search var top = doc.getLine(line + 1 - lines.length), topString = fold(top) if (topString.slice(topString.length - lines[0].length) != lines[0]) continue search return {from: Pos(line + 1 - lines.length, adjustPos(top, topString, top.length - lines[0].length, fold)), to: Pos(line, adjustPos(orig, string, lastLine.length, fold))} } } } function SearchCursor(doc, query, pos, options) { this.atOccurrence = false this.doc = doc pos = pos ? doc.clipPos(pos) : Pos(0, 0) this.pos = {from: pos, to: pos} var caseFold if (typeof options == "object") { caseFold = options.caseFold } else { // Backwards compat for when caseFold was the 4th argument caseFold = options options = null } if (typeof query == "string") { if (caseFold == null) caseFold = false this.matches = function(reverse, pos) { return (reverse ? searchStringBackward : searchStringForward)(doc, query, pos, caseFold) } } else { query = ensureFlags(query, "gm") if (!options || options.multiline !== false) this.matches = function(reverse, pos) { return (reverse ? searchRegexpBackwardMultiline : searchRegexpForwardMultiline)(doc, query, pos) } else this.matches = function(reverse, pos) { return (reverse ? searchRegexpBackward : searchRegexpForward)(doc, query, pos) } } } SearchCursor.prototype = { findNext: function() {return this.find(false)}, findPrevious: function() {return this.find(true)}, find: function(reverse) { var result = this.matches(reverse, this.doc.clipPos(reverse ? this.pos.from : this.pos.to)) // Implements weird auto-growing behavior on null-matches for // backwards-compatibility with the vim code (unfortunately) while (result && CodeMirror.cmpPos(result.from, result.to) == 0) { if (reverse) { if (result.from.ch) result.from = Pos(result.from.line, result.from.ch - 1) else if (result.from.line == this.doc.firstLine()) result = null else result = this.matches(reverse, this.doc.clipPos(Pos(result.from.line - 1))) } else { if (result.to.ch < this.doc.getLine(result.to.line).length) result.to = Pos(result.to.line, result.to.ch + 1) else if (result.to.line == this.doc.lastLine()) result = null else result = this.matches(reverse, Pos(result.to.line + 1, 0)) } } if (result) { this.pos = result this.atOccurrence = true return this.pos.match || true } else { var end = Pos(reverse ? this.doc.firstLine() : this.doc.lastLine() + 1, 0) this.pos = {from: end, to: end} return this.atOccurrence = false } }, from: function() {if (this.atOccurrence) return this.pos.from}, to: function() {if (this.atOccurrence) return this.pos.to}, replace: function(newText, origin) { if (!this.atOccurrence) return var lines = CodeMirror.splitLines(newText) this.doc.replaceRange(lines, this.pos.from, this.pos.to, origin) this.pos.to = Pos(this.pos.from.line + lines.length - 1, lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0)) } } CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) { return new SearchCursor(this.doc, query, pos, caseFold) }) CodeMirror.defineDocExtension("getSearchCursor", function(query, pos, caseFold) { return new SearchCursor(this, query, pos, caseFold) }) CodeMirror.defineExtension("selectMatches", function(query, caseFold) { var ranges = [] var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold) while (cur.findNext()) { if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break ranges.push({anchor: cur.from(), head: cur.to()}) } if (ranges.length) this.setSelections(ranges, 0) }) }); /* ---- extension/selection/active-line.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var WRAP_CLASS = "CodeMirror-activeline"; var BACK_CLASS = "CodeMirror-activeline-background"; var GUTT_CLASS = "CodeMirror-activeline-gutter"; CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) { var prev = old == CodeMirror.Init ? false : old; if (val == prev) return if (prev) { cm.off("beforeSelectionChange", selectionChange); clearActiveLines(cm); delete cm.state.activeLines; } if (val) { cm.state.activeLines = []; updateActiveLines(cm, cm.listSelections()); cm.on("beforeSelectionChange", selectionChange); } }); function clearActiveLines(cm) { for (var i = 0; i < cm.state.activeLines.length; i++) { cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS); cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS); cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS); } } function sameArray(a, b) { if (a.length != b.length) return false; for (var i = 0; i < a.length; i++) if (a[i] != b[i]) return false; return true; } function updateActiveLines(cm, ranges) { var active = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; var option = cm.getOption("styleActiveLine"); if (typeof option == "object" && option.nonEmpty ? range.anchor.line != range.head.line : !range.empty()) continue var line = cm.getLineHandleVisualStart(range.head.line); if (active[active.length - 1] != line) active.push(line); } if (sameArray(cm.state.activeLines, active)) return; cm.operation(function() { clearActiveLines(cm); for (var i = 0; i < active.length; i++) { cm.addLineClass(active[i], "wrap", WRAP_CLASS); cm.addLineClass(active[i], "background", BACK_CLASS); cm.addLineClass(active[i], "gutter", GUTT_CLASS); } cm.state.activeLines = active; }); } function selectionChange(cm, sel) { updateActiveLines(cm, sel.ranges); } }); /* ---- extension/selection/mark-selection.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // Because sometimes you need to mark the selected *text*. // // Adds an option 'styleSelectedText' which, when enabled, gives // selected text the CSS class given as option value, or // "CodeMirror-selectedtext" when the value is not a string. (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) { var prev = old && old != CodeMirror.Init; if (val && !prev) { cm.state.markedSelection = []; cm.state.markedSelectionStyle = typeof val == "string" ? val : "CodeMirror-selectedtext"; reset(cm); cm.on("cursorActivity", onCursorActivity); cm.on("change", onChange); } else if (!val && prev) { cm.off("cursorActivity", onCursorActivity); cm.off("change", onChange); clear(cm); cm.state.markedSelection = cm.state.markedSelectionStyle = null; } }); function onCursorActivity(cm) { if (cm.state.markedSelection) cm.operation(function() { update(cm); }); } function onChange(cm) { if (cm.state.markedSelection && cm.state.markedSelection.length) cm.operation(function() { clear(cm); }); } var CHUNK_SIZE = 8; var Pos = CodeMirror.Pos; var cmp = CodeMirror.cmpPos; function coverRange(cm, from, to, addAt) { if (cmp(from, to) == 0) return; var array = cm.state.markedSelection; var cls = cm.state.markedSelectionStyle; for (var line = from.line;;) { var start = line == from.line ? from : Pos(line, 0); var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line; var end = atEnd ? to : Pos(endLine, 0); var mark = cm.markText(start, end, {className: cls}); if (addAt == null) array.push(mark); else array.splice(addAt++, 0, mark); if (atEnd) break; line = endLine; } } function clear(cm) { var array = cm.state.markedSelection; for (var i = 0; i < array.length; ++i) array[i].clear(); array.length = 0; } function reset(cm) { clear(cm); var ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) coverRange(cm, ranges[i].from(), ranges[i].to()); } function update(cm) { if (!cm.somethingSelected()) return clear(cm); if (cm.listSelections().length > 1) return reset(cm); var from = cm.getCursor("start"), to = cm.getCursor("end"); var array = cm.state.markedSelection; if (!array.length) return coverRange(cm, from, to); var coverStart = array[0].find(), coverEnd = array[array.length - 1].find(); if (!coverStart || !coverEnd || to.line - from.line <= CHUNK_SIZE || cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0) return reset(cm); while (cmp(from, coverStart.from) > 0) { array.shift().clear(); coverStart = array[0].find(); } if (cmp(from, coverStart.from) < 0) { if (coverStart.to.line - from.line < CHUNK_SIZE) { array.shift().clear(); coverRange(cm, from, coverStart.to, 0); } else { coverRange(cm, from, coverStart.from, 0); } } while (cmp(to, coverEnd.to) < 0) { array.pop().clear(); coverEnd = array[array.length - 1].find(); } if (cmp(to, coverEnd.to) > 0) { if (to.line - coverEnd.from.line < CHUNK_SIZE) { array.pop().clear(); coverRange(cm, coverEnd.from, to); } else { coverRange(cm, coverEnd.to, to); } } } }); /* ---- extension/selection/selection-pointer.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineOption("selectionPointer", false, function(cm, val) { var data = cm.state.selectionPointer; if (data) { CodeMirror.off(cm.getWrapperElement(), "mousemove", data.mousemove); CodeMirror.off(cm.getWrapperElement(), "mouseout", data.mouseout); CodeMirror.off(window, "scroll", data.windowScroll); cm.off("cursorActivity", reset); cm.off("scroll", reset); cm.state.selectionPointer = null; cm.display.lineDiv.style.cursor = ""; } if (val) { data = cm.state.selectionPointer = { value: typeof val == "string" ? val : "default", mousemove: function(event) { mousemove(cm, event); }, mouseout: function(event) { mouseout(cm, event); }, windowScroll: function() { reset(cm); }, rects: null, mouseX: null, mouseY: null, willUpdate: false }; CodeMirror.on(cm.getWrapperElement(), "mousemove", data.mousemove); CodeMirror.on(cm.getWrapperElement(), "mouseout", data.mouseout); CodeMirror.on(window, "scroll", data.windowScroll); cm.on("cursorActivity", reset); cm.on("scroll", reset); } }); function mousemove(cm, event) { var data = cm.state.selectionPointer; if (event.buttons == null ? event.which : event.buttons) { data.mouseX = data.mouseY = null; } else { data.mouseX = event.clientX; data.mouseY = event.clientY; } scheduleUpdate(cm); } function mouseout(cm, event) { if (!cm.getWrapperElement().contains(event.relatedTarget)) { var data = cm.state.selectionPointer; data.mouseX = data.mouseY = null; scheduleUpdate(cm); } } function reset(cm) { cm.state.selectionPointer.rects = null; scheduleUpdate(cm); } function scheduleUpdate(cm) { if (!cm.state.selectionPointer.willUpdate) { cm.state.selectionPointer.willUpdate = true; setTimeout(function() { update(cm); cm.state.selectionPointer.willUpdate = false; }, 50); } } function update(cm) { var data = cm.state.selectionPointer; if (!data) return; if (data.rects == null && data.mouseX != null) { data.rects = []; if (cm.somethingSelected()) { for (var sel = cm.display.selectionDiv.firstChild; sel; sel = sel.nextSibling) data.rects.push(sel.getBoundingClientRect()); } } var inside = false; if (data.mouseX != null) for (var i = 0; i < data.rects.length; i++) { var rect = data.rects[i]; if (rect.left <= data.mouseX && rect.right >= data.mouseX && rect.top <= data.mouseY && rect.bottom >= data.mouseY) inside = true; } var cursor = inside ? data.value : ""; if (cm.display.lineDiv.style.cursor != cursor) cm.display.lineDiv.style.cursor = cursor; } }); /* ---- mode/coffeescript.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE /** * Link to the project's GitHub page: * https://github.com/pickhardt/coffeescript-codemirror-mode */ (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("coffeescript", function(conf, parserConf) { var ERRORCLASS = "error"; function wordRegexp(words) { return new RegExp("^((" + words.join(")|(") + "))\\b"); } var operators = /^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>>?=?|%=?|&=?|\|=?|\^=?|\~|!|\?|(or|and|\|\||&&|\?)=)/; var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/; var identifiers = /^[_A-Za-z$][_A-Za-z$0-9]*/; var atProp = /^@[_A-Za-z$][_A-Za-z$0-9]*/; var wordOperators = wordRegexp(["and", "or", "not", "is", "isnt", "in", "instanceof", "typeof"]); var indentKeywords = ["for", "while", "loop", "if", "unless", "else", "switch", "try", "catch", "finally", "class"]; var commonKeywords = ["break", "by", "continue", "debugger", "delete", "do", "in", "of", "new", "return", "then", "this", "@", "throw", "when", "until", "extends"]; var keywords = wordRegexp(indentKeywords.concat(commonKeywords)); indentKeywords = wordRegexp(indentKeywords); var stringPrefixes = /^('{3}|\"{3}|['\"])/; var regexPrefixes = /^(\/{3}|\/)/; var commonConstants = ["Infinity", "NaN", "undefined", "null", "true", "false", "on", "off", "yes", "no"]; var constants = wordRegexp(commonConstants); // Tokenizers function tokenBase(stream, state) { // Handle scope changes if (stream.sol()) { if (state.scope.align === null) state.scope.align = false; var scopeOffset = state.scope.offset; if (stream.eatSpace()) { var lineOffset = stream.indentation(); if (lineOffset > scopeOffset && state.scope.type == "coffee") { return "indent"; } else if (lineOffset < scopeOffset) { return "dedent"; } return null; } else { if (scopeOffset > 0) { dedent(stream, state); } } } if (stream.eatSpace()) { return null; } var ch = stream.peek(); // Handle docco title comment (single line) if (stream.match("####")) { stream.skipToEnd(); return "comment"; } // Handle multi line comments if (stream.match("###")) { state.tokenize = longComment; return state.tokenize(stream, state); } // Single line comment if (ch === "#") { stream.skipToEnd(); return "comment"; } // Handle number literals if (stream.match(/^-?[0-9\.]/, false)) { var floatLiteral = false; // Floats if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; } if (stream.match(/^-?\d+\.\d*/)) { floatLiteral = true; } if (stream.match(/^-?\.\d+/)) { floatLiteral = true; } if (floatLiteral) { // prevent from getting extra . on 1.. if (stream.peek() == "."){ stream.backUp(1); } return "number"; } // Integers var intLiteral = false; // Hex if (stream.match(/^-?0x[0-9a-f]+/i)) { intLiteral = true; } // Decimal if (stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)) { intLiteral = true; } // Zero by itself with no other piece of number. if (stream.match(/^-?0(?![\dx])/i)) { intLiteral = true; } if (intLiteral) { return "number"; } } // Handle strings if (stream.match(stringPrefixes)) { state.tokenize = tokenFactory(stream.current(), false, "string"); return state.tokenize(stream, state); } // Handle regex literals if (stream.match(regexPrefixes)) { if (stream.current() != "/" || stream.match(/^.*\//, false)) { // prevent highlight of division state.tokenize = tokenFactory(stream.current(), true, "string-2"); return state.tokenize(stream, state); } else { stream.backUp(1); } } // Handle operators and delimiters if (stream.match(operators) || stream.match(wordOperators)) { return "operator"; } if (stream.match(delimiters)) { return "punctuation"; } if (stream.match(constants)) { return "atom"; } if (stream.match(atProp) || state.prop && stream.match(identifiers)) { return "property"; } if (stream.match(keywords)) { return "keyword"; } if (stream.match(identifiers)) { return "variable"; } // Handle non-detected items stream.next(); return ERRORCLASS; } function tokenFactory(delimiter, singleline, outclass) { return function(stream, state) { while (!stream.eol()) { stream.eatWhile(/[^'"\/\\]/); if (stream.eat("\\")) { stream.next(); if (singleline && stream.eol()) { return outclass; } } else if (stream.match(delimiter)) { state.tokenize = tokenBase; return outclass; } else { stream.eat(/['"\/]/); } } if (singleline) { if (parserConf.singleLineStringErrors) { outclass = ERRORCLASS; } else { state.tokenize = tokenBase; } } return outclass; }; } function longComment(stream, state) { while (!stream.eol()) { stream.eatWhile(/[^#]/); if (stream.match("###")) { state.tokenize = tokenBase; break; } stream.eatWhile("#"); } return "comment"; } function indent(stream, state, type) { type = type || "coffee"; var offset = 0, align = false, alignOffset = null; for (var scope = state.scope; scope; scope = scope.prev) { if (scope.type === "coffee" || scope.type == "}") { offset = scope.offset + conf.indentUnit; break; } } if (type !== "coffee") { align = null; alignOffset = stream.column() + stream.current().length; } else if (state.scope.align) { state.scope.align = false; } state.scope = { offset: offset, type: type, prev: state.scope, align: align, alignOffset: alignOffset }; } function dedent(stream, state) { if (!state.scope.prev) return; if (state.scope.type === "coffee") { var _indent = stream.indentation(); var matched = false; for (var scope = state.scope; scope; scope = scope.prev) { if (_indent === scope.offset) { matched = true; break; } } if (!matched) { return true; } while (state.scope.prev && state.scope.offset !== _indent) { state.scope = state.scope.prev; } return false; } else { state.scope = state.scope.prev; return false; } } function tokenLexer(stream, state) { var style = state.tokenize(stream, state); var current = stream.current(); // Handle scope changes. if (current === "return") { state.dedent = true; } if (((current === "->" || current === "=>") && stream.eol()) || style === "indent") { indent(stream, state); } var delimiter_index = "[({".indexOf(current); if (delimiter_index !== -1) { indent(stream, state, "])}".slice(delimiter_index, delimiter_index+1)); } if (indentKeywords.exec(current)){ indent(stream, state); } if (current == "then"){ dedent(stream, state); } if (style === "dedent") { if (dedent(stream, state)) { return ERRORCLASS; } } delimiter_index = "])}".indexOf(current); if (delimiter_index !== -1) { while (state.scope.type == "coffee" && state.scope.prev) state.scope = state.scope.prev; if (state.scope.type == current) state.scope = state.scope.prev; } if (state.dedent && stream.eol()) { if (state.scope.type == "coffee" && state.scope.prev) state.scope = state.scope.prev; state.dedent = false; } return style; } var external = { startState: function(basecolumn) { return { tokenize: tokenBase, scope: {offset:basecolumn || 0, type:"coffee", prev: null, align: false}, prop: false, dedent: 0 }; }, token: function(stream, state) { var fillAlign = state.scope.align === null && state.scope; if (fillAlign && stream.sol()) fillAlign.align = false; var style = tokenLexer(stream, state); if (style && style != "comment") { if (fillAlign) fillAlign.align = true; state.prop = style == "punctuation" && stream.current() == "." } return style; }, indent: function(state, text) { if (state.tokenize != tokenBase) return 0; var scope = state.scope; var closer = text && "])}".indexOf(text.charAt(0)) > -1; if (closer) while (scope.type == "coffee" && scope.prev) scope = scope.prev; var closes = closer && scope.type === text.charAt(0); if (scope.align) return scope.alignOffset - (closes ? 1 : 0); else return (closes ? scope.prev : scope).offset; }, lineComment: "#", fold: "indent" }; return external; }); // IANA registered media type // https://www.iana.org/assignments/media-types/ CodeMirror.defineMIME("application/vnd.coffeescript", "coffeescript"); CodeMirror.defineMIME("text/x-coffeescript", "coffeescript"); CodeMirror.defineMIME("text/coffeescript", "coffeescript"); }); /* ---- mode/css.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("css", function(config, parserConfig) { var inline = parserConfig.inline if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css"); var indentUnit = config.indentUnit, tokenHooks = parserConfig.tokenHooks, documentTypes = parserConfig.documentTypes || {}, mediaTypes = parserConfig.mediaTypes || {}, mediaFeatures = parserConfig.mediaFeatures || {}, mediaValueKeywords = parserConfig.mediaValueKeywords || {}, propertyKeywords = parserConfig.propertyKeywords || {}, nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {}, fontProperties = parserConfig.fontProperties || {}, counterDescriptors = parserConfig.counterDescriptors || {}, colorKeywords = parserConfig.colorKeywords || {}, valueKeywords = parserConfig.valueKeywords || {}, allowNested = parserConfig.allowNested, lineComment = parserConfig.lineComment, supportsAtComponent = parserConfig.supportsAtComponent === true; var type, override; function ret(style, tp) { type = tp; return style; } // Tokenizers function tokenBase(stream, state) { var ch = stream.next(); if (tokenHooks[ch]) { var result = tokenHooks[ch](stream, state); if (result !== false) return result; } if (ch == "@") { stream.eatWhile(/[\w\\\-]/); return ret("def", stream.current()); } else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) { return ret(null, "compare"); } else if (ch == "\"" || ch == "'") { state.tokenize = tokenString(ch); return state.tokenize(stream, state); } else if (ch == "#") { stream.eatWhile(/[\w\\\-]/); return ret("atom", "hash"); } else if (ch == "!") { stream.match(/^\s*\w*/); return ret("keyword", "important"); } else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) { stream.eatWhile(/[\w.%]/); return ret("number", "unit"); } else if (ch === "-") { if (/[\d.]/.test(stream.peek())) { stream.eatWhile(/[\w.%]/); return ret("number", "unit"); } else if (stream.match(/^-[\w\\\-]*/)) { stream.eatWhile(/[\w\\\-]/); if (stream.match(/^\s*:/, false)) return ret("variable-2", "variable-definition"); return ret("variable-2", "variable"); } else if (stream.match(/^\w+-/)) { return ret("meta", "meta"); } } else if (/[,+>*\/]/.test(ch)) { return ret(null, "select-op"); } else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) { return ret("qualifier", "qualifier"); } else if (/[:;{}\[\]\(\)]/.test(ch)) { return ret(null, ch); } else if (stream.match(/[\w-.]+(?=\()/)) { if (/^(url(-prefix)?|domain|regexp)$/.test(stream.current().toLowerCase())) { state.tokenize = tokenParenthesized; } return ret("variable callee", "variable"); } else if (/[\w\\\-]/.test(ch)) { stream.eatWhile(/[\w\\\-]/); return ret("property", "word"); } else { return ret(null, null); } } function tokenString(quote) { return function(stream, state) { var escaped = false, ch; while ((ch = stream.next()) != null) { if (ch == quote && !escaped) { if (quote == ")") stream.backUp(1); break; } escaped = !escaped && ch == "\\"; } if (ch == quote || !escaped && quote != ")") state.tokenize = null; return ret("string", "string"); }; } function tokenParenthesized(stream, state) { stream.next(); // Must be '(' if (!stream.match(/\s*[\"\')]/, false)) state.tokenize = tokenString(")"); else state.tokenize = null; return ret(null, "("); } // Context management function Context(type, indent, prev) { this.type = type; this.indent = indent; this.prev = prev; } function pushContext(state, stream, type, indent) { state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context); return type; } function popContext(state) { if (state.context.prev) state.context = state.context.prev; return state.context.type; } function pass(type, stream, state) { return states[state.context.type](type, stream, state); } function popAndPass(type, stream, state, n) { for (var i = n || 1; i > 0; i--) state.context = state.context.prev; return pass(type, stream, state); } // Parser function wordAsValue(stream) { var word = stream.current().toLowerCase(); if (valueKeywords.hasOwnProperty(word)) override = "atom"; else if (colorKeywords.hasOwnProperty(word)) override = "keyword"; else override = "variable"; } var states = {}; states.top = function(type, stream, state) { if (type == "{") { return pushContext(state, stream, "block"); } else if (type == "}" && state.context.prev) { return popContext(state); } else if (supportsAtComponent && /@component/i.test(type)) { return pushContext(state, stream, "atComponentBlock"); } else if (/^@(-moz-)?document$/i.test(type)) { return pushContext(state, stream, "documentTypes"); } else if (/^@(media|supports|(-moz-)?document|import)$/i.test(type)) { return pushContext(state, stream, "atBlock"); } else if (/^@(font-face|counter-style)/i.test(type)) { state.stateArg = type; return "restricted_atBlock_before"; } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(type)) { return "keyframes"; } else if (type && type.charAt(0) == "@") { return pushContext(state, stream, "at"); } else if (type == "hash") { override = "builtin"; } else if (type == "word") { override = "tag"; } else if (type == "variable-definition") { return "maybeprop"; } else if (type == "interpolation") { return pushContext(state, stream, "interpolation"); } else if (type == ":") { return "pseudo"; } else if (allowNested && type == "(") { return pushContext(state, stream, "parens"); } return state.context.type; }; states.block = function(type, stream, state) { if (type == "word") { var word = stream.current().toLowerCase(); if (propertyKeywords.hasOwnProperty(word)) { override = "property"; return "maybeprop"; } else if (nonStandardPropertyKeywords.hasOwnProperty(word)) { override = "string-2"; return "maybeprop"; } else if (allowNested) { override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag"; return "block"; } else { override += " error"; return "maybeprop"; } } else if (type == "meta") { return "block"; } else if (!allowNested && (type == "hash" || type == "qualifier")) { override = "error"; return "block"; } else { return states.top(type, stream, state); } }; states.maybeprop = function(type, stream, state) { if (type == ":") return pushContext(state, stream, "prop"); return pass(type, stream, state); }; states.prop = function(type, stream, state) { if (type == ";") return popContext(state); if (type == "{" && allowNested) return pushContext(state, stream, "propBlock"); if (type == "}" || type == "{") return popAndPass(type, stream, state); if (type == "(") return pushContext(state, stream, "parens"); if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) { override += " error"; } else if (type == "word") { wordAsValue(stream); } else if (type == "interpolation") { return pushContext(state, stream, "interpolation"); } return "prop"; }; states.propBlock = function(type, _stream, state) { if (type == "}") return popContext(state); if (type == "word") { override = "property"; return "maybeprop"; } return state.context.type; }; states.parens = function(type, stream, state) { if (type == "{" || type == "}") return popAndPass(type, stream, state); if (type == ")") return popContext(state); if (type == "(") return pushContext(state, stream, "parens"); if (type == "interpolation") return pushContext(state, stream, "interpolation"); if (type == "word") wordAsValue(stream); return "parens"; }; states.pseudo = function(type, stream, state) { if (type == "meta") return "pseudo"; if (type == "word") { override = "variable-3"; return state.context.type; } return pass(type, stream, state); }; states.documentTypes = function(type, stream, state) { if (type == "word" && documentTypes.hasOwnProperty(stream.current())) { override = "tag"; return state.context.type; } else { return states.atBlock(type, stream, state); } }; states.atBlock = function(type, stream, state) { if (type == "(") return pushContext(state, stream, "atBlock_parens"); if (type == "}" || type == ";") return popAndPass(type, stream, state); if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top"); if (type == "interpolation") return pushContext(state, stream, "interpolation"); if (type == "word") { var word = stream.current().toLowerCase(); if (word == "only" || word == "not" || word == "and" || word == "or") override = "keyword"; else if (mediaTypes.hasOwnProperty(word)) override = "attribute"; else if (mediaFeatures.hasOwnProperty(word)) override = "property"; else if (mediaValueKeywords.hasOwnProperty(word)) override = "keyword"; else if (propertyKeywords.hasOwnProperty(word)) override = "property"; else if (nonStandardPropertyKeywords.hasOwnProperty(word)) override = "string-2"; else if (valueKeywords.hasOwnProperty(word)) override = "atom"; else if (colorKeywords.hasOwnProperty(word)) override = "keyword"; else override = "error"; } return state.context.type; }; states.atComponentBlock = function(type, stream, state) { if (type == "}") return popAndPass(type, stream, state); if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false); if (type == "word") override = "error"; return state.context.type; }; states.atBlock_parens = function(type, stream, state) { if (type == ")") return popContext(state); if (type == "{" || type == "}") return popAndPass(type, stream, state, 2); return states.atBlock(type, stream, state); }; states.restricted_atBlock_before = function(type, stream, state) { if (type == "{") return pushContext(state, stream, "restricted_atBlock"); if (type == "word" && state.stateArg == "@counter-style") { override = "variable"; return "restricted_atBlock_before"; } return pass(type, stream, state); }; states.restricted_atBlock = function(type, stream, state) { if (type == "}") { state.stateArg = null; return popContext(state); } if (type == "word") { if ((state.stateArg == "@font-face" && !fontProperties.hasOwnProperty(stream.current().toLowerCase())) || (state.stateArg == "@counter-style" && !counterDescriptors.hasOwnProperty(stream.current().toLowerCase()))) override = "error"; else override = "property"; return "maybeprop"; } return "restricted_atBlock"; }; states.keyframes = function(type, stream, state) { if (type == "word") { override = "variable"; return "keyframes"; } if (type == "{") return pushContext(state, stream, "top"); return pass(type, stream, state); }; states.at = function(type, stream, state) { if (type == ";") return popContext(state); if (type == "{" || type == "}") return popAndPass(type, stream, state); if (type == "word") override = "tag"; else if (type == "hash") override = "builtin"; return "at"; }; states.interpolation = function(type, stream, state) { if (type == "}") return popContext(state); if (type == "{" || type == ";") return popAndPass(type, stream, state); if (type == "word") override = "variable"; else if (type != "variable" && type != "(" && type != ")") override = "error"; return "interpolation"; }; return { startState: function(base) { return {tokenize: null, state: inline ? "block" : "top", stateArg: null, context: new Context(inline ? "block" : "top", base || 0, null)}; }, token: function(stream, state) { if (!state.tokenize && stream.eatSpace()) return null; var style = (state.tokenize || tokenBase)(stream, state); if (style && typeof style == "object") { type = style[1]; style = style[0]; } override = style; if (type != "comment") state.state = states[state.state](type, stream, state); return override; }, indent: function(state, textAfter) { var cx = state.context, ch = textAfter && textAfter.charAt(0); var indent = cx.indent; if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev; if (cx.prev) { if (ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "restricted_atBlock")) { // Resume indentation from parent context. cx = cx.prev; indent = cx.indent; } else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") || ch == "{" && (cx.type == "at" || cx.type == "atBlock")) { // Dedent relative to current context. indent = Math.max(0, cx.indent - indentUnit); } } return indent; }, electricChars: "}", blockCommentStart: "/*", blockCommentEnd: "*/", blockCommentContinue: " * ", lineComment: lineComment, fold: "brace" }; }); function keySet(array) { var keys = {}; for (var i = 0; i < array.length; ++i) { keys[array[i].toLowerCase()] = true; } return keys; } var documentTypes_ = [ "domain", "regexp", "url", "url-prefix" ], documentTypes = keySet(documentTypes_); var mediaTypes_ = [ "all", "aural", "braille", "handheld", "print", "projection", "screen", "tty", "tv", "embossed" ], mediaTypes = keySet(mediaTypes_); var mediaFeatures_ = [ "width", "min-width", "max-width", "height", "min-height", "max-height", "device-width", "min-device-width", "max-device-width", "device-height", "min-device-height", "max-device-height", "aspect-ratio", "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio", "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color", "max-color", "color-index", "min-color-index", "max-color-index", "monochrome", "min-monochrome", "max-monochrome", "resolution", "min-resolution", "max-resolution", "scan", "grid", "orientation", "device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio", "pointer", "any-pointer", "hover", "any-hover" ], mediaFeatures = keySet(mediaFeatures_); var mediaValueKeywords_ = [ "landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover", "interlace", "progressive" ], mediaValueKeywords = keySet(mediaValueKeywords_); var propertyKeywords_ = [ "align-content", "align-items", "align-self", "alignment-adjust", "alignment-baseline", "anchor-point", "animation", "animation-delay", "animation-direction", "animation-duration", "animation-fill-mode", "animation-iteration-count", "animation-name", "animation-play-state", "animation-timing-function", "appearance", "azimuth", "backdrop-filter", "backface-visibility", "background", "background-attachment", "background-blend-mode", "background-clip", "background-color", "background-image", "background-origin", "background-position", "background-position-x", "background-position-y", "background-repeat", "background-size", "baseline-shift", "binding", "bleed", "block-size", "bookmark-label", "bookmark-level", "bookmark-state", "bookmark-target", "border", "border-bottom", "border-bottom-color", "border-bottom-left-radius", "border-bottom-right-radius", "border-bottom-style", "border-bottom-width", "border-collapse", "border-color", "border-image", "border-image-outset", "border-image-repeat", "border-image-slice", "border-image-source", "border-image-width", "border-left", "border-left-color", "border-left-style", "border-left-width", "border-radius", "border-right", "border-right-color", "border-right-style", "border-right-width", "border-spacing", "border-style", "border-top", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-top-style", "border-top-width", "border-width", "bottom", "box-decoration-break", "box-shadow", "box-sizing", "break-after", "break-before", "break-inside", "caption-side", "caret-color", "clear", "clip", "color", "color-profile", "column-count", "column-fill", "column-gap", "column-rule", "column-rule-color", "column-rule-style", "column-rule-width", "column-span", "column-width", "columns", "contain", "content", "counter-increment", "counter-reset", "crop", "cue", "cue-after", "cue-before", "cursor", "direction", "display", "dominant-baseline", "drop-initial-after-adjust", "drop-initial-after-align", "drop-initial-before-adjust", "drop-initial-before-align", "drop-initial-size", "drop-initial-value", "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis", "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap", "float", "float-offset", "flow-from", "flow-into", "font", "font-family", "font-feature-settings", "font-kerning", "font-language-override", "font-optical-sizing", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-synthesis", "font-variant", "font-variant-alternates", "font-variant-caps", "font-variant-east-asian", "font-variant-ligatures", "font-variant-numeric", "font-variant-position", "font-variation-settings", "font-weight", "gap", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow", "grid-auto-rows", "grid-column", "grid-column-end", "grid-column-gap", "grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap", "grid-row-start", "grid-template", "grid-template-areas", "grid-template-columns", "grid-template-rows", "hanging-punctuation", "height", "hyphens", "icon", "image-orientation", "image-rendering", "image-resolution", "inline-box-align", "inset", "inset-block", "inset-block-end", "inset-block-start", "inset-inline", "inset-inline-end", "inset-inline-start", "isolation", "justify-content", "justify-items", "justify-self", "left", "letter-spacing", "line-break", "line-height", "line-height-step", "line-stacking", "line-stacking-ruby", "line-stacking-shift", "line-stacking-strategy", "list-style", "list-style-image", "list-style-position", "list-style-type", "margin", "margin-bottom", "margin-left", "margin-right", "margin-top", "marks", "marquee-direction", "marquee-loop", "marquee-play-count", "marquee-speed", "marquee-style", "max-block-size", "max-height", "max-inline-size", "max-width", "min-block-size", "min-height", "min-inline-size", "min-width", "mix-blend-mode", "move-to", "nav-down", "nav-index", "nav-left", "nav-right", "nav-up", "object-fit", "object-position", "offset", "offset-anchor", "offset-distance", "offset-path", "offset-position", "offset-rotate", "opacity", "order", "orphans", "outline", "outline-color", "outline-offset", "outline-style", "outline-width", "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y", "padding", "padding-bottom", "padding-left", "padding-right", "padding-top", "page", "page-break-after", "page-break-before", "page-break-inside", "page-policy", "pause", "pause-after", "pause-before", "perspective", "perspective-origin", "pitch", "pitch-range", "place-content", "place-items", "place-self", "play-during", "position", "presentation-level", "punctuation-trim", "quotes", "region-break-after", "region-break-before", "region-break-inside", "region-fragment", "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness", "right", "rotate", "rotation", "rotation-point", "row-gap", "ruby-align", "ruby-overhang", "ruby-position", "ruby-span", "scale", "scroll-behavior", "scroll-margin", "scroll-margin-block", "scroll-margin-block-end", "scroll-margin-block-start", "scroll-margin-bottom", "scroll-margin-inline", "scroll-margin-inline-end", "scroll-margin-inline-start", "scroll-margin-left", "scroll-margin-right", "scroll-margin-top", "scroll-padding", "scroll-padding-block", "scroll-padding-block-end", "scroll-padding-block-start", "scroll-padding-bottom", "scroll-padding-inline", "scroll-padding-inline-end", "scroll-padding-inline-start", "scroll-padding-left", "scroll-padding-right", "scroll-padding-top", "scroll-snap-align", "scroll-snap-type", "shape-image-threshold", "shape-inside", "shape-margin", "shape-outside", "size", "speak", "speak-as", "speak-header", "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set", "tab-size", "table-layout", "target", "target-name", "target-new", "target-position", "text-align", "text-align-last", "text-combine-upright", "text-decoration", "text-decoration-color", "text-decoration-line", "text-decoration-skip", "text-decoration-skip-ink", "text-decoration-style", "text-emphasis", "text-emphasis-color", "text-emphasis-position", "text-emphasis-style", "text-height", "text-indent", "text-justify", "text-orientation", "text-outline", "text-overflow", "text-rendering", "text-shadow", "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position", "text-wrap", "top", "transform", "transform-origin", "transform-style", "transition", "transition-delay", "transition-duration", "transition-property", "transition-timing-function", "translate", "unicode-bidi", "user-select", "vertical-align", "visibility", "voice-balance", "voice-duration", "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress", "voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break", "word-spacing", "word-wrap", "writing-mode", "z-index", // SVG-specific "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color", "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events", "color-interpolation", "color-interpolation-filters", "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering", "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering", "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal", "glyph-orientation-vertical", "text-anchor", "writing-mode" ], propertyKeywords = keySet(propertyKeywords_); var nonStandardPropertyKeywords_ = [ "border-block", "border-block-color", "border-block-end", "border-block-end-color", "border-block-end-style", "border-block-end-width", "border-block-start", "border-block-start-color", "border-block-start-style", "border-block-start-width", "border-block-style", "border-block-width", "border-inline", "border-inline-color", "border-inline-end", "border-inline-end-color", "border-inline-end-style", "border-inline-end-width", "border-inline-start", "border-inline-start-color", "border-inline-start-style", "border-inline-start-width", "border-inline-style", "border-inline-width", "margin-block", "margin-block-end", "margin-block-start", "margin-inline", "margin-inline-end", "margin-inline-start", "padding-block", "padding-block-end", "padding-block-start", "padding-inline", "padding-inline-end", "padding-inline-start", "scroll-snap-stop", "scrollbar-3d-light-color", "scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color", "scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color", "scrollbar-track-color", "searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button", "searchfield-results-decoration", "shape-inside", "zoom" ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_); var fontProperties_ = [ "font-display", "font-family", "src", "unicode-range", "font-variant", "font-feature-settings", "font-stretch", "font-weight", "font-style" ], fontProperties = keySet(fontProperties_); var counterDescriptors_ = [ "additive-symbols", "fallback", "negative", "pad", "prefix", "range", "speak-as", "suffix", "symbols", "system" ], counterDescriptors = keySet(counterDescriptors_); var colorKeywords_ = [ "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", "whitesmoke", "yellow", "yellowgreen" ], colorKeywords = keySet(colorKeywords_); var valueKeywords_ = [ "above", "absolute", "activeborder", "additive", "activecaption", "afar", "after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", "always", "amharic", "amharic-abegede", "antialiased", "appworkspace", "arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page", "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary", "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box", "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel", "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian", "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret", "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch", "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote", "col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse", "compact", "condensed", "contain", "content", "contents", "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop", "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal", "decimal-leading-zero", "default", "default-button", "dense", "destination-atop", "destination-in", "destination-out", "destination-over", "devanagari", "difference", "disc", "discard", "disclosure-closed", "disclosure-open", "document", "dot-dash", "dot-dot-dash", "dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out", "element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede", "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er", "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er", "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et", "ethiopic-halehame-gez", "ethiopic-halehame-om-et", "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et", "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig", "ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed", "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", "forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove", "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew", "help", "hidden", "hide", "higher", "highlight", "highlighttext", "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore", "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis", "inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert", "italic", "japanese-formal", "japanese-informal", "justify", "kannada", "katakana", "katakana-iroha", "keep-all", "khmer", "korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal", "landscape", "lao", "large", "larger", "left", "level", "lighter", "lighten", "line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian", "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian", "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d", "media-controls-background", "media-current-time-display", "media-fullscreen-button", "media-mute-button", "media-play-button", "media-return-to-realtime-button", "media-rewind-button", "media-seek-back-button", "media-seek-forward-button", "media-slider", "media-sliderthumb", "media-time-remaining-display", "media-volume-slider", "media-volume-slider-container", "media-volume-sliderthumb", "medium", "menu", "menulist", "menulist-button", "menulist-text", "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic", "mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize", "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap", "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote", "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset", "outside", "outside-shape", "overlay", "overline", "padding", "padding-box", "painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter", "pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", "radial-gradient", "radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", "relative", "repeat", "repeating-linear-gradient", "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY", "rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running", "s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen", "scroll", "scrollbar", "scroll-position", "se-resize", "searchfield", "searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button", "searchfield-results-decoration", "self-start", "self-end", "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama", "simp-chinese-formal", "simp-chinese-informal", "single", "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal", "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", "small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali", "source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square", "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub", "subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table", "table-caption", "table-cell", "table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row", "table-row-group", "tamil", "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai", "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er", "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top", "trad-chinese-formal", "trad-chinese-informal", "transform", "translate", "translate3d", "translateX", "translateY", "translateZ", "transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up", "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal", "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url", "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", "window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor", "xx-large", "xx-small" ], valueKeywords = keySet(valueKeywords_); var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_) .concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_) .concat(valueKeywords_); CodeMirror.registerHelper("hintWords", "css", allWords); function tokenCComment(stream, state) { var maybeEnd = false, ch; while ((ch = stream.next()) != null) { if (maybeEnd && ch == "/") { state.tokenize = null; break; } maybeEnd = (ch == "*"); } return ["comment", "comment"]; } CodeMirror.defineMIME("text/css", { documentTypes: documentTypes, mediaTypes: mediaTypes, mediaFeatures: mediaFeatures, mediaValueKeywords: mediaValueKeywords, propertyKeywords: propertyKeywords, nonStandardPropertyKeywords: nonStandardPropertyKeywords, fontProperties: fontProperties, counterDescriptors: counterDescriptors, colorKeywords: colorKeywords, valueKeywords: valueKeywords, tokenHooks: { "/": function(stream, state) { if (!stream.eat("*")) return false; state.tokenize = tokenCComment; return tokenCComment(stream, state); } }, name: "css" }); CodeMirror.defineMIME("text/x-scss", { mediaTypes: mediaTypes, mediaFeatures: mediaFeatures, mediaValueKeywords: mediaValueKeywords, propertyKeywords: propertyKeywords, nonStandardPropertyKeywords: nonStandardPropertyKeywords, colorKeywords: colorKeywords, valueKeywords: valueKeywords, fontProperties: fontProperties, allowNested: true, lineComment: "//", tokenHooks: { "/": function(stream, state) { if (stream.eat("/")) { stream.skipToEnd(); return ["comment", "comment"]; } else if (stream.eat("*")) { state.tokenize = tokenCComment; return tokenCComment(stream, state); } else { return ["operator", "operator"]; } }, ":": function(stream) { if (stream.match(/\s*\{/, false)) return [null, null] return false; }, "$": function(stream) { stream.match(/^[\w-]+/); if (stream.match(/^\s*:/, false)) return ["variable-2", "variable-definition"]; return ["variable-2", "variable"]; }, "#": function(stream) { if (!stream.eat("{")) return false; return [null, "interpolation"]; } }, name: "css", helperType: "scss" }); CodeMirror.defineMIME("text/x-less", { mediaTypes: mediaTypes, mediaFeatures: mediaFeatures, mediaValueKeywords: mediaValueKeywords, propertyKeywords: propertyKeywords, nonStandardPropertyKeywords: nonStandardPropertyKeywords, colorKeywords: colorKeywords, valueKeywords: valueKeywords, fontProperties: fontProperties, allowNested: true, lineComment: "//", tokenHooks: { "/": function(stream, state) { if (stream.eat("/")) { stream.skipToEnd(); return ["comment", "comment"]; } else if (stream.eat("*")) { state.tokenize = tokenCComment; return tokenCComment(stream, state); } else { return ["operator", "operator"]; } }, "@": function(stream) { if (stream.eat("{")) return [null, "interpolation"]; if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i, false)) return false; stream.eatWhile(/[\w\\\-]/); if (stream.match(/^\s*:/, false)) return ["variable-2", "variable-definition"]; return ["variable-2", "variable"]; }, "&": function() { return ["atom", "atom"]; } }, name: "css", helperType: "less" }); CodeMirror.defineMIME("text/x-gss", { documentTypes: documentTypes, mediaTypes: mediaTypes, mediaFeatures: mediaFeatures, propertyKeywords: propertyKeywords, nonStandardPropertyKeywords: nonStandardPropertyKeywords, fontProperties: fontProperties, counterDescriptors: counterDescriptors, colorKeywords: colorKeywords, valueKeywords: valueKeywords, supportsAtComponent: true, tokenHooks: { "/": function(stream, state) { if (!stream.eat("*")) return false; state.tokenize = tokenCComment; return tokenCComment(stream, state); } }, name: "css", helperType: "gss" }); }); /* ---- mode/go.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("go", function(config) { var indentUnit = config.indentUnit; var keywords = { "break":true, "case":true, "chan":true, "const":true, "continue":true, "default":true, "defer":true, "else":true, "fallthrough":true, "for":true, "func":true, "go":true, "goto":true, "if":true, "import":true, "interface":true, "map":true, "package":true, "range":true, "return":true, "select":true, "struct":true, "switch":true, "type":true, "var":true, "bool":true, "byte":true, "complex64":true, "complex128":true, "float32":true, "float64":true, "int8":true, "int16":true, "int32":true, "int64":true, "string":true, "uint8":true, "uint16":true, "uint32":true, "uint64":true, "int":true, "uint":true, "uintptr":true, "error": true, "rune":true }; var atoms = { "true":true, "false":true, "iota":true, "nil":true, "append":true, "cap":true, "close":true, "complex":true, "copy":true, "delete":true, "imag":true, "len":true, "make":true, "new":true, "panic":true, "print":true, "println":true, "real":true, "recover":true }; var isOperatorChar = /[+\-*&^%:=<>!|\/]/; var curPunc; function tokenBase(stream, state) { var ch = stream.next(); if (ch == '"' || ch == "'" || ch == "`") { state.tokenize = tokenString(ch); return state.tokenize(stream, state); } if (/[\d\.]/.test(ch)) { if (ch == ".") { stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/); } else if (ch == "0") { stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/); } else { stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/); } return "number"; } if (/[\[\]{}\(\),;\:\.]/.test(ch)) { curPunc = ch; return null; } if (ch == "/") { if (stream.eat("*")) { state.tokenize = tokenComment; return tokenComment(stream, state); } if (stream.eat("/")) { stream.skipToEnd(); return "comment"; } } if (isOperatorChar.test(ch)) { stream.eatWhile(isOperatorChar); return "operator"; } stream.eatWhile(/[\w\$_\xa1-\uffff]/); var cur = stream.current(); if (keywords.propertyIsEnumerable(cur)) { if (cur == "case" || cur == "default") curPunc = "case"; return "keyword"; } if (atoms.propertyIsEnumerable(cur)) return "atom"; return "variable"; } function tokenString(quote) { return function(stream, state) { var escaped = false, next, end = false; while ((next = stream.next()) != null) { if (next == quote && !escaped) {end = true; break;} escaped = !escaped && quote != "`" && next == "\\"; } if (end || !(escaped || quote == "`")) state.tokenize = tokenBase; return "string"; }; } function tokenComment(stream, state) { var maybeEnd = false, ch; while (ch = stream.next()) { if (ch == "/" && maybeEnd) { state.tokenize = tokenBase; break; } maybeEnd = (ch == "*"); } return "comment"; } function Context(indented, column, type, align, prev) { this.indented = indented; this.column = column; this.type = type; this.align = align; this.prev = prev; } function pushContext(state, col, type) { return state.context = new Context(state.indented, col, type, null, state.context); } function popContext(state) { if (!state.context.prev) return; var t = state.context.type; if (t == ")" || t == "]" || t == "}") state.indented = state.context.indented; return state.context = state.context.prev; } // Interface return { startState: function(basecolumn) { return { tokenize: null, context: new Context((basecolumn || 0) - indentUnit, 0, "top", false), indented: 0, startOfLine: true }; }, token: function(stream, state) { var ctx = state.context; if (stream.sol()) { if (ctx.align == null) ctx.align = false; state.indented = stream.indentation(); state.startOfLine = true; if (ctx.type == "case") ctx.type = "}"; } if (stream.eatSpace()) return null; curPunc = null; var style = (state.tokenize || tokenBase)(stream, state); if (style == "comment") return style; if (ctx.align == null) ctx.align = true; if (curPunc == "{") pushContext(state, stream.column(), "}"); else if (curPunc == "[") pushContext(state, stream.column(), "]"); else if (curPunc == "(") pushContext(state, stream.column(), ")"); else if (curPunc == "case") ctx.type = "case"; else if (curPunc == "}" && ctx.type == "}") popContext(state); else if (curPunc == ctx.type) popContext(state); state.startOfLine = false; return style; }, indent: function(state, textAfter) { if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass; var ctx = state.context, firstChar = textAfter && textAfter.charAt(0); if (ctx.type == "case" && /^(?:case|default)\b/.test(textAfter)) { state.context.type = "}"; return ctx.indented; } var closing = firstChar == ctx.type; if (ctx.align) return ctx.column + (closing ? 0 : 1); else return ctx.indented + (closing ? 0 : indentUnit); }, electricChars: "{}):", closeBrackets: "()[]{}''\"\"``", fold: "brace", blockCommentStart: "/*", blockCommentEnd: "*/", lineComment: "//" }; }); CodeMirror.defineMIME("text/x-go", "go"); }); /* ---- mode/htmlembedded.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), require("../../addon/mode/multiplex")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../../addon/mode/multiplex"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("htmlembedded", function(config, parserConfig) { var closeComment = parserConfig.closeComment || "--%>" return CodeMirror.multiplexingMode(CodeMirror.getMode(config, "htmlmixed"), { open: parserConfig.openComment || "<%--", close: closeComment, delimStyle: "comment", mode: {token: function(stream) { stream.skipTo(closeComment) || stream.skipToEnd() return "comment" }} }, { open: parserConfig.open || parserConfig.scriptStartRegex || "<%", close: parserConfig.close || parserConfig.scriptEndRegex || "%>", mode: CodeMirror.getMode(config, parserConfig.scriptingModeSpec) }); }, "htmlmixed"); CodeMirror.defineMIME("application/x-ejs", {name: "htmlembedded", scriptingModeSpec:"javascript"}); CodeMirror.defineMIME("application/x-aspx", {name: "htmlembedded", scriptingModeSpec:"text/x-csharp"}); CodeMirror.defineMIME("application/x-jsp", {name: "htmlembedded", scriptingModeSpec:"text/x-java"}); CodeMirror.defineMIME("application/x-erb", {name: "htmlembedded", scriptingModeSpec:"ruby"}); }); /* ---- mode/htmlmixed.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"), require("../css/css")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var defaultTags = { script: [ ["lang", /(javascript|babel)/i, "javascript"], ["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i, "javascript"], ["type", /./, "text/plain"], [null, null, "javascript"] ], style: [ ["lang", /^css$/i, "css"], ["type", /^(text\/)?(x-)?(stylesheet|css)$/i, "css"], ["type", /./, "text/plain"], [null, null, "css"] ] }; function maybeBackup(stream, pat, style) { var cur = stream.current(), close = cur.search(pat); if (close > -1) { stream.backUp(cur.length - close); } else if (cur.match(/<\/?$/)) { stream.backUp(cur.length); if (!stream.match(pat, false)) stream.match(cur); } return style; } var attrRegexpCache = {}; function getAttrRegexp(attr) { var regexp = attrRegexpCache[attr]; if (regexp) return regexp; return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*"); } function getAttrValue(text, attr) { var match = text.match(getAttrRegexp(attr)) return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : "" } function getTagRegexp(tagName, anchored) { return new RegExp((anchored ? "^" : "") + "<\/\s*" + tagName + "\s*>", "i"); } function addTags(from, to) { for (var tag in from) { var dest = to[tag] || (to[tag] = []); var source = from[tag]; for (var i = source.length - 1; i >= 0; i--) dest.unshift(source[i]) } } function findMatchingMode(tagInfo, tagText) { for (var i = 0; i < tagInfo.length; i++) { var spec = tagInfo[i]; if (!spec[0] || spec[1].test(getAttrValue(tagText, spec[0]))) return spec[2]; } } CodeMirror.defineMode("htmlmixed", function (config, parserConfig) { var htmlMode = CodeMirror.getMode(config, { name: "xml", htmlMode: true, multilineTagIndentFactor: parserConfig.multilineTagIndentFactor, multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag }); var tags = {}; var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes; addTags(defaultTags, tags); if (configTags) addTags(configTags, tags); if (configScript) for (var i = configScript.length - 1; i >= 0; i--) tags.script.unshift(["type", configScript[i].matches, configScript[i].mode]) function html(stream, state) { var style = htmlMode.token(stream, state.htmlState), tag = /\btag\b/.test(style), tagName if (tag && !/[<>\s\/]/.test(stream.current()) && (tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase()) && tags.hasOwnProperty(tagName)) { state.inTag = tagName + " " } else if (state.inTag && tag && />$/.test(stream.current())) { var inTag = /^([\S]+) (.*)/.exec(state.inTag) state.inTag = null var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2]) var mode = CodeMirror.getMode(config, modeSpec) var endTagA = getTagRegexp(inTag[1], true), endTag = getTagRegexp(inTag[1], false); state.token = function (stream, state) { if (stream.match(endTagA, false)) { state.token = html; state.localState = state.localMode = null; return null; } return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState)); }; state.localMode = mode; state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, "", "")); } else if (state.inTag) { state.inTag += stream.current() if (stream.eol()) state.inTag += " " } return style; }; return { startState: function () { var state = CodeMirror.startState(htmlMode); return {token: html, inTag: null, localMode: null, localState: null, htmlState: state}; }, copyState: function (state) { var local; if (state.localState) { local = CodeMirror.copyState(state.localMode, state.localState); } return {token: state.token, inTag: state.inTag, localMode: state.localMode, localState: local, htmlState: CodeMirror.copyState(htmlMode, state.htmlState)}; }, token: function (stream, state) { return state.token(stream, state); }, indent: function (state, textAfter, line) { if (!state.localMode || /^\s*<\//.test(textAfter)) return htmlMode.indent(state.htmlState, textAfter, line); else if (state.localMode.indent) return state.localMode.indent(state.localState, textAfter, line); else return CodeMirror.Pass; }, innerMode: function (state) { return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode}; } }; }, "xml", "javascript", "css"); CodeMirror.defineMIME("text/html", "htmlmixed"); }); /* ---- mode/javascript.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("javascript", function(config, parserConfig) { var indentUnit = config.indentUnit; var statementIndent = parserConfig.statementIndent; var jsonldMode = parserConfig.jsonld; var jsonMode = parserConfig.json || jsonldMode; var isTS = parserConfig.typescript; var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/; // Tokenizer var keywords = function(){ function kw(type) {return {type: type, style: "keyword"};} var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d"); var operator = kw("operator"), atom = {type: "atom", style: "atom"}; return { "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B, "return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C, "debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"), "function": kw("function"), "catch": kw("catch"), "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"), "in": operator, "typeof": operator, "instanceof": operator, "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom, "this": kw("this"), "class": kw("class"), "super": kw("atom"), "yield": C, "export": kw("export"), "import": kw("import"), "extends": C, "await": C }; }(); var isOperatorChar = /[+\-*&%=<>!?|~^@]/; var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/; function readRegexp(stream) { var escaped = false, next, inSet = false; while ((next = stream.next()) != null) { if (!escaped) { if (next == "/" && !inSet) return; if (next == "[") inSet = true; else if (inSet && next == "]") inSet = false; } escaped = !escaped && next == "\\"; } } // Used as scratch variables to communicate multiple values without // consing up tons of objects. var type, content; function ret(tp, style, cont) { type = tp; content = cont; return style; } function tokenBase(stream, state) { var ch = stream.next(); if (ch == '"' || ch == "'") { state.tokenize = tokenString(ch); return state.tokenize(stream, state); } else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) { return ret("number", "number"); } else if (ch == "." && stream.match("..")) { return ret("spread", "meta"); } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) { return ret(ch); } else if (ch == "=" && stream.eat(">")) { return ret("=>", "operator"); } else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) { return ret("number", "number"); } else if (/\d/.test(ch)) { stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/); return ret("number", "number"); } else if (ch == "/") { if (stream.eat("*")) { state.tokenize = tokenComment; return tokenComment(stream, state); } else if (stream.eat("/")) { stream.skipToEnd(); return ret("comment", "comment"); } else if (expressionAllowed(stream, state, 1)) { readRegexp(stream); stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/); return ret("regexp", "string-2"); } else { stream.eat("="); return ret("operator", "operator", stream.current()); } } else if (ch == "`") { state.tokenize = tokenQuasi; return tokenQuasi(stream, state); } else if (ch == "#" && stream.peek() == "!") { stream.skipToEnd(); return ret("meta", "meta"); } else if (ch == "#" && stream.eatWhile(wordRE)) { return ret("variable", "property") } else if (ch == "<" && stream.match("!--") || (ch == "-" && stream.match("->") && !/\S/.test(stream.string.slice(0, stream.start)))) { stream.skipToEnd() return ret("comment", "comment") } else if (isOperatorChar.test(ch)) { if (ch != ">" || !state.lexical || state.lexical.type != ">") { if (stream.eat("=")) { if (ch == "!" || ch == "=") stream.eat("=") } else if (/[<>*+\-]/.test(ch)) { stream.eat(ch) if (ch == ">") stream.eat(ch) } } if (ch == "?" && stream.eat(".")) return ret(".") return ret("operator", "operator", stream.current()); } else if (wordRE.test(ch)) { stream.eatWhile(wordRE); var word = stream.current() if (state.lastType != ".") { if (keywords.propertyIsEnumerable(word)) { var kw = keywords[word] return ret(kw.type, kw.style, word) } if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false)) return ret("async", "keyword", word) } return ret("variable", "variable", word) } } function tokenString(quote) { return function(stream, state) { var escaped = false, next; if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){ state.tokenize = tokenBase; return ret("jsonld-keyword", "meta"); } while ((next = stream.next()) != null) { if (next == quote && !escaped) break; escaped = !escaped && next == "\\"; } if (!escaped) state.tokenize = tokenBase; return ret("string", "string"); }; } function tokenComment(stream, state) { var maybeEnd = false, ch; while (ch = stream.next()) { if (ch == "/" && maybeEnd) { state.tokenize = tokenBase; break; } maybeEnd = (ch == "*"); } return ret("comment", "comment"); } function tokenQuasi(stream, state) { var escaped = false, next; while ((next = stream.next()) != null) { if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) { state.tokenize = tokenBase; break; } escaped = !escaped && next == "\\"; } return ret("quasi", "string-2", stream.current()); } var brackets = "([{}])"; // This is a crude lookahead trick to try and notice that we're // parsing the argument patterns for a fat-arrow function before we // actually hit the arrow token. It only works if the arrow is on // the same line as the arguments and there's no strange noise // (comments) in between. Fallback is to only notice when we hit the // arrow, and not declare the arguments as locals for the arrow // body. function findFatArrow(stream, state) { if (state.fatArrowAt) state.fatArrowAt = null; var arrow = stream.string.indexOf("=>", stream.start); if (arrow < 0) return; if (isTS) { // Try to skip TypeScript return type declarations after the arguments var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow)) if (m) arrow = m.index } var depth = 0, sawSomething = false; for (var pos = arrow - 1; pos >= 0; --pos) { var ch = stream.string.charAt(pos); var bracket = brackets.indexOf(ch); if (bracket >= 0 && bracket < 3) { if (!depth) { ++pos; break; } if (--depth == 0) { if (ch == "(") sawSomething = true; break; } } else if (bracket >= 3 && bracket < 6) { ++depth; } else if (wordRE.test(ch)) { sawSomething = true; } else if (/["'\/`]/.test(ch)) { for (;; --pos) { if (pos == 0) return var next = stream.string.charAt(pos - 1) if (next == ch && stream.string.charAt(pos - 2) != "\\") { pos--; break } } } else if (sawSomething && !depth) { ++pos; break; } } if (sawSomething && !depth) state.fatArrowAt = pos; } // Parser var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true}; function JSLexical(indented, column, type, align, prev, info) { this.indented = indented; this.column = column; this.type = type; this.prev = prev; this.info = info; if (align != null) this.align = align; } function inScope(state, varname) { for (var v = state.localVars; v; v = v.next) if (v.name == varname) return true; for (var cx = state.context; cx; cx = cx.prev) { for (var v = cx.vars; v; v = v.next) if (v.name == varname) return true; } } function parseJS(state, style, type, content, stream) { var cc = state.cc; // Communicate our context to the combinators. // (Less wasteful than consing up a hundred closures on every call.) cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style; if (!state.lexical.hasOwnProperty("align")) state.lexical.align = true; while(true) { var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement; if (combinator(type, content)) { while(cc.length && cc[cc.length - 1].lex) cc.pop()(); if (cx.marked) return cx.marked; if (type == "variable" && inScope(state, content)) return "variable-2"; return style; } } } // Combinator utils var cx = {state: null, column: null, marked: null, cc: null}; function pass() { for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]); } function cont() { pass.apply(null, arguments); return true; } function inList(name, list) { for (var v = list; v; v = v.next) if (v.name == name) return true return false; } function register(varname) { var state = cx.state; cx.marked = "def"; if (state.context) { if (state.lexical.info == "var" && state.context && state.context.block) { // FIXME function decls are also not block scoped var newContext = registerVarScoped(varname, state.context) if (newContext != null) { state.context = newContext return } } else if (!inList(varname, state.localVars)) { state.localVars = new Var(varname, state.localVars) return } } // Fall through means this is global if (parserConfig.globalVars && !inList(varname, state.globalVars)) state.globalVars = new Var(varname, state.globalVars) } function registerVarScoped(varname, context) { if (!context) { return null } else if (context.block) { var inner = registerVarScoped(varname, context.prev) if (!inner) return null if (inner == context.prev) return context return new Context(inner, context.vars, true) } else if (inList(varname, context.vars)) { return context } else { return new Context(context.prev, new Var(varname, context.vars), false) } } function isModifier(name) { return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly" } // Combinators function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block } function Var(name, next) { this.name = name; this.next = next } var defaultVars = new Var("this", new Var("arguments", null)) function pushcontext() { cx.state.context = new Context(cx.state.context, cx.state.localVars, false) cx.state.localVars = defaultVars } function pushblockcontext() { cx.state.context = new Context(cx.state.context, cx.state.localVars, true) cx.state.localVars = null } function popcontext() { cx.state.localVars = cx.state.context.vars cx.state.context = cx.state.context.prev } popcontext.lex = true function pushlex(type, info) { var result = function() { var state = cx.state, indent = state.indented; if (state.lexical.type == "stat") indent = state.lexical.indented; else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev) indent = outer.indented; state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info); }; result.lex = true; return result; } function poplex() { var state = cx.state; if (state.lexical.prev) { if (state.lexical.type == ")") state.indented = state.lexical.indented; state.lexical = state.lexical.prev; } } poplex.lex = true; function expect(wanted) { function exp(type) { if (type == wanted) return cont(); else if (wanted == ";" || type == "}" || type == ")" || type == "]") return pass(); else return cont(exp); }; return exp; } function statement(type, value) { if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex); if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex); if (type == "keyword b") return cont(pushlex("form"), statement, poplex); if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex); if (type == "debugger") return cont(expect(";")); if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext); if (type == ";") return cont(); if (type == "if") { if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex) cx.state.cc.pop()(); return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse); } if (type == "function") return cont(functiondef); if (type == "for") return cont(pushlex("form"), forspec, statement, poplex); if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword" return cont(pushlex("form", type == "class" ? type : value), className, poplex) } if (type == "variable") { if (isTS && value == "declare") { cx.marked = "keyword" return cont(statement) } else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) { cx.marked = "keyword" if (value == "enum") return cont(enumdef); else if (value == "type") return cont(typename, expect("operator"), typeexpr, expect(";")); else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex) } else if (isTS && value == "namespace") { cx.marked = "keyword" return cont(pushlex("form"), expression, statement, poplex) } else if (isTS && value == "abstract") { cx.marked = "keyword" return cont(statement) } else { return cont(pushlex("stat"), maybelabel); } } if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext, block, poplex, poplex, popcontext); if (type == "case") return cont(expression, expect(":")); if (type == "default") return cont(expect(":")); if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext); if (type == "export") return cont(pushlex("stat"), afterExport, poplex); if (type == "import") return cont(pushlex("stat"), afterImport, poplex); if (type == "async") return cont(statement) if (value == "@") return cont(expression, statement) return pass(pushlex("stat"), expression, expect(";"), poplex); } function maybeCatchBinding(type) { if (type == "(") return cont(funarg, expect(")")) } function expression(type, value) { return expressionInner(type, value, false); } function expressionNoComma(type, value) { return expressionInner(type, value, true); } function parenExpr(type) { if (type != "(") return pass() return cont(pushlex(")"), maybeexpression, expect(")"), poplex) } function expressionInner(type, value, noComma) { if (cx.state.fatArrowAt == cx.stream.start) { var body = noComma ? arrowBodyNoComma : arrowBody; if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext); else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext); } var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma; if (atomicTypes.hasOwnProperty(type)) return cont(maybeop); if (type == "function") return cont(functiondef, maybeop); if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); } if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression); if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop); if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression); if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop); if (type == "{") return contCommasep(objprop, "}", null, maybeop); if (type == "quasi") return pass(quasi, maybeop); if (type == "new") return cont(maybeTarget(noComma)); if (type == "import") return cont(expression); return cont(); } function maybeexpression(type) { if (type.match(/[;\}\)\],]/)) return pass(); return pass(expression); } function maybeoperatorComma(type, value) { if (type == ",") return cont(maybeexpression); return maybeoperatorNoComma(type, value, false); } function maybeoperatorNoComma(type, value, noComma) { var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma; var expr = noComma == false ? expression : expressionNoComma; if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext); if (type == "operator") { if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me); if (isTS && value == "<" && cx.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/, false)) return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me); if (value == "?") return cont(expression, expect(":"), expr); return cont(expr); } if (type == "quasi") { return pass(quasi, me); } if (type == ";") return; if (type == "(") return contCommasep(expressionNoComma, ")", "call", me); if (type == ".") return cont(property, me); if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me); if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) } if (type == "regexp") { cx.state.lastType = cx.marked = "operator" cx.stream.backUp(cx.stream.pos - cx.stream.start - 1) return cont(expr) } } function quasi(type, value) { if (type != "quasi") return pass(); if (value.slice(value.length - 2) != "${") return cont(quasi); return cont(expression, continueQuasi); } function continueQuasi(type) { if (type == "}") { cx.marked = "string-2"; cx.state.tokenize = tokenQuasi; return cont(quasi); } } function arrowBody(type) { findFatArrow(cx.stream, cx.state); return pass(type == "{" ? statement : expression); } function arrowBodyNoComma(type) { findFatArrow(cx.stream, cx.state); return pass(type == "{" ? statement : expressionNoComma); } function maybeTarget(noComma) { return function(type) { if (type == ".") return cont(noComma ? targetNoComma : target); else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma) else return pass(noComma ? expressionNoComma : expression); }; } function target(_, value) { if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); } } function targetNoComma(_, value) { if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); } } function maybelabel(type) { if (type == ":") return cont(poplex, statement); return pass(maybeoperatorComma, expect(";"), poplex); } function property(type) { if (type == "variable") {cx.marked = "property"; return cont();} } function objprop(type, value) { if (type == "async") { cx.marked = "property"; return cont(objprop); } else if (type == "variable" || cx.style == "keyword") { cx.marked = "property"; if (value == "get" || value == "set") return cont(getterSetter); var m // Work around fat-arrow-detection complication for detecting typescript typed arrow params if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false))) cx.state.fatArrowAt = cx.stream.pos + m[0].length return cont(afterprop); } else if (type == "number" || type == "string") { cx.marked = jsonldMode ? "property" : (cx.style + " property"); return cont(afterprop); } else if (type == "jsonld-keyword") { return cont(afterprop); } else if (isTS && isModifier(value)) { cx.marked = "keyword" return cont(objprop) } else if (type == "[") { return cont(expression, maybetype, expect("]"), afterprop); } else if (type == "spread") { return cont(expressionNoComma, afterprop); } else if (value == "*") { cx.marked = "keyword"; return cont(objprop); } else if (type == ":") { return pass(afterprop) } } function getterSetter(type) { if (type != "variable") return pass(afterprop); cx.marked = "property"; return cont(functiondef); } function afterprop(type) { if (type == ":") return cont(expressionNoComma); if (type == "(") return pass(functiondef); } function commasep(what, end, sep) { function proceed(type, value) { if (sep ? sep.indexOf(type) > -1 : type == ",") { var lex = cx.state.lexical; if (lex.info == "call") lex.pos = (lex.pos || 0) + 1; return cont(function(type, value) { if (type == end || value == end) return pass() return pass(what) }, proceed); } if (type == end || value == end) return cont(); if (sep && sep.indexOf(";") > -1) return pass(what) return cont(expect(end)); } return function(type, value) { if (type == end || value == end) return cont(); return pass(what, proceed); }; } function contCommasep(what, end, info) { for (var i = 3; i < arguments.length; i++) cx.cc.push(arguments[i]); return cont(pushlex(end, info), commasep(what, end), poplex); } function block(type) { if (type == "}") return cont(); return pass(statement, block); } function maybetype(type, value) { if (isTS) { if (type == ":") return cont(typeexpr); if (value == "?") return cont(maybetype); } } function maybetypeOrIn(type, value) { if (isTS && (type == ":" || value == "in")) return cont(typeexpr) } function mayberettype(type) { if (isTS && type == ":") { if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr) else return cont(typeexpr) } } function isKW(_, value) { if (value == "is") { cx.marked = "keyword" return cont() } } function typeexpr(type, value) { if (value == "keyof" || value == "typeof" || value == "infer") { cx.marked = "keyword" return cont(value == "typeof" ? expressionNoComma : typeexpr) } if (type == "variable" || value == "void") { cx.marked = "type" return cont(afterType) } if (value == "|" || value == "&") return cont(typeexpr) if (type == "string" || type == "number" || type == "atom") return cont(afterType); if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType) if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType) if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType) if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr) } function maybeReturnType(type) { if (type == "=>") return cont(typeexpr) } function typeprop(type, value) { if (type == "variable" || cx.style == "keyword") { cx.marked = "property" return cont(typeprop) } else if (value == "?" || type == "number" || type == "string") { return cont(typeprop) } else if (type == ":") { return cont(typeexpr) } else if (type == "[") { return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop) } else if (type == "(") { return pass(functiondecl, typeprop) } } function typearg(type, value) { if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg) if (type == ":") return cont(typeexpr) if (type == "spread") return cont(typearg) return pass(typeexpr) } function afterType(type, value) { if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) if (value == "|" || type == "." || value == "&") return cont(typeexpr) if (type == "[") return cont(typeexpr, expect("]"), afterType) if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) } if (value == "?") return cont(typeexpr, expect(":"), typeexpr) } function maybeTypeArgs(_, value) { if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) } function typeparam() { return pass(typeexpr, maybeTypeDefault) } function maybeTypeDefault(_, value) { if (value == "=") return cont(typeexpr) } function vardef(_, value) { if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)} return pass(pattern, maybetype, maybeAssign, vardefCont); } function pattern(type, value) { if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) } if (type == "variable") { register(value); return cont(); } if (type == "spread") return cont(pattern); if (type == "[") return contCommasep(eltpattern, "]"); if (type == "{") return contCommasep(proppattern, "}"); } function proppattern(type, value) { if (type == "variable" && !cx.stream.match(/^\s*:/, false)) { register(value); return cont(maybeAssign); } if (type == "variable") cx.marked = "property"; if (type == "spread") return cont(pattern); if (type == "}") return pass(); if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern); return cont(expect(":"), pattern, maybeAssign); } function eltpattern() { return pass(pattern, maybeAssign) } function maybeAssign(_type, value) { if (value == "=") return cont(expressionNoComma); } function vardefCont(type) { if (type == ",") return cont(vardef); } function maybeelse(type, value) { if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex); } function forspec(type, value) { if (value == "await") return cont(forspec); if (type == "(") return cont(pushlex(")"), forspec1, poplex); } function forspec1(type) { if (type == "var") return cont(vardef, forspec2); if (type == "variable") return cont(forspec2); return pass(forspec2) } function forspec2(type, value) { if (type == ")") return cont() if (type == ";") return cont(forspec2) if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression, forspec2) } return pass(expression, forspec2) } function functiondef(type, value) { if (value == "*") {cx.marked = "keyword"; return cont(functiondef);} if (type == "variable") {register(value); return cont(functiondef);} if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext); if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef) } function functiondecl(type, value) { if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);} if (type == "variable") {register(value); return cont(functiondecl);} if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext); if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl) } function typename(type, value) { if (type == "keyword" || type == "variable") { cx.marked = "type" return cont(typename) } else if (value == "<") { return cont(pushlex(">"), commasep(typeparam, ">"), poplex) } } function funarg(type, value) { if (value == "@") cont(expression, funarg) if (type == "spread") return cont(funarg); if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); } if (isTS && type == "this") return cont(maybetype, maybeAssign) return pass(pattern, maybetype, maybeAssign); } function classExpression(type, value) { // Class expressions may have an optional name. if (type == "variable") return className(type, value); return classNameAfter(type, value); } function className(type, value) { if (type == "variable") {register(value); return cont(classNameAfter);} } function classNameAfter(type, value) { if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter) if (value == "extends" || value == "implements" || (isTS && type == ",")) { if (value == "implements") cx.marked = "keyword"; return cont(isTS ? typeexpr : expression, classNameAfter); } if (type == "{") return cont(pushlex("}"), classBody, poplex); } function classBody(type, value) { if (type == "async" || (type == "variable" && (value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) && cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) { cx.marked = "keyword"; return cont(classBody); } if (type == "variable" || cx.style == "keyword") { cx.marked = "property"; return cont(classfield, classBody); } if (type == "number" || type == "string") return cont(classfield, classBody); if (type == "[") return cont(expression, maybetype, expect("]"), classfield, classBody) if (value == "*") { cx.marked = "keyword"; return cont(classBody); } if (isTS && type == "(") return pass(functiondecl, classBody) if (type == ";" || type == ",") return cont(classBody); if (type == "}") return cont(); if (value == "@") return cont(expression, classBody) } function classfield(type, value) { if (value == "?") return cont(classfield) if (type == ":") return cont(typeexpr, maybeAssign) if (value == "=") return cont(expressionNoComma) var context = cx.state.lexical.prev, isInterface = context && context.info == "interface" return pass(isInterface ? functiondecl : functiondef) } function afterExport(type, value) { if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); } if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); } if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";")); return pass(statement); } function exportField(type, value) { if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); } if (type == "variable") return pass(expressionNoComma, exportField); } function afterImport(type) { if (type == "string") return cont(); if (type == "(") return pass(expression); return pass(importSpec, maybeMoreImports, maybeFrom); } function importSpec(type, value) { if (type == "{") return contCommasep(importSpec, "}"); if (type == "variable") register(value); if (value == "*") cx.marked = "keyword"; return cont(maybeAs); } function maybeMoreImports(type) { if (type == ",") return cont(importSpec, maybeMoreImports) } function maybeAs(_type, value) { if (value == "as") { cx.marked = "keyword"; return cont(importSpec); } } function maybeFrom(_type, value) { if (value == "from") { cx.marked = "keyword"; return cont(expression); } } function arrayLiteral(type) { if (type == "]") return cont(); return pass(commasep(expressionNoComma, "]")); } function enumdef() { return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex) } function enummember() { return pass(pattern, maybeAssign); } function isContinuedStatement(state, textAfter) { return state.lastType == "operator" || state.lastType == "," || isOperatorChar.test(textAfter.charAt(0)) || /[,.]/.test(textAfter.charAt(0)); } function expressionAllowed(stream, state, backUp) { return state.tokenize == tokenBase && /^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) || (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0)))) } // Interface return { startState: function(basecolumn) { var state = { tokenize: tokenBase, lastType: "sof", cc: [], lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false), localVars: parserConfig.localVars, context: parserConfig.localVars && new Context(null, null, false), indented: basecolumn || 0 }; if (parserConfig.globalVars && typeof parserConfig.globalVars == "object") state.globalVars = parserConfig.globalVars; return state; }, token: function(stream, state) { if (stream.sol()) { if (!state.lexical.hasOwnProperty("align")) state.lexical.align = false; state.indented = stream.indentation(); findFatArrow(stream, state); } if (state.tokenize != tokenComment && stream.eatSpace()) return null; var style = state.tokenize(stream, state); if (type == "comment") return style; state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type; return parseJS(state, style, type, content, stream); }, indent: function(state, textAfter) { if (state.tokenize == tokenComment) return CodeMirror.Pass; if (state.tokenize != tokenBase) return 0; var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top // Kludge to prevent 'maybelse' from blocking lexical scope pops if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) { var c = state.cc[i]; if (c == poplex) lexical = lexical.prev; else if (c != maybeelse) break; } while ((lexical.type == "stat" || lexical.type == "form") && (firstChar == "}" || ((top = state.cc[state.cc.length - 1]) && (top == maybeoperatorComma || top == maybeoperatorNoComma) && !/^[,\.=+\-*:?[\(]/.test(textAfter)))) lexical = lexical.prev; if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat") lexical = lexical.prev; var type = lexical.type, closing = firstChar == type; if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0); else if (type == "form" && firstChar == "{") return lexical.indented; else if (type == "form") return lexical.indented + indentUnit; else if (type == "stat") return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0); else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false) return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit); else if (lexical.align) return lexical.column + (closing ? 0 : 1); else return lexical.indented + (closing ? 0 : indentUnit); }, electricInput: /^\s*(?:case .*?:|default:|\{|\})$/, blockCommentStart: jsonMode ? null : "/*", blockCommentEnd: jsonMode ? null : "*/", blockCommentContinue: jsonMode ? null : " * ", lineComment: jsonMode ? null : "//", fold: "brace", closeBrackets: "()[]{}''\"\"``", helperType: jsonMode ? "json" : "javascript", jsonldMode: jsonldMode, jsonMode: jsonMode, expressionAllowed: expressionAllowed, skipExpression: function(state) { var top = state.cc[state.cc.length - 1] if (top == expression || top == expressionNoComma) state.cc.pop() } }; }); CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/); CodeMirror.defineMIME("text/javascript", "javascript"); CodeMirror.defineMIME("text/ecmascript", "javascript"); CodeMirror.defineMIME("application/javascript", "javascript"); CodeMirror.defineMIME("application/x-javascript", "javascript"); CodeMirror.defineMIME("application/ecmascript", "javascript"); CodeMirror.defineMIME("application/json", {name: "javascript", json: true}); CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true}); CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true}); CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true }); CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true }); }); /* ---- mode/markdown.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../xml/xml"), require("../meta")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../xml/xml", "../meta"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { var htmlMode = CodeMirror.getMode(cmCfg, "text/html"); var htmlModeMissing = htmlMode.name == "null" function getMode(name) { if (CodeMirror.findModeByName) { var found = CodeMirror.findModeByName(name); if (found) name = found.mime || found.mimes[0]; } var mode = CodeMirror.getMode(cmCfg, name); return mode.name == "null" ? null : mode; } // Should characters that affect highlighting be highlighted separate? // Does not include characters that will be output (such as `1.` and `-` for lists) if (modeCfg.highlightFormatting === undefined) modeCfg.highlightFormatting = false; // Maximum number of nested blockquotes. Set to 0 for infinite nesting. // Excess `>` will emit `error` token. if (modeCfg.maxBlockquoteDepth === undefined) modeCfg.maxBlockquoteDepth = 0; // Turn on task lists? ("- [ ] " and "- [x] ") if (modeCfg.taskLists === undefined) modeCfg.taskLists = false; // Turn on strikethrough syntax if (modeCfg.strikethrough === undefined) modeCfg.strikethrough = false; if (modeCfg.emoji === undefined) modeCfg.emoji = false; if (modeCfg.fencedCodeBlockHighlighting === undefined) modeCfg.fencedCodeBlockHighlighting = true; if (modeCfg.fencedCodeBlockDefaultMode === undefined) modeCfg.fencedCodeBlockDefaultMode = 'text/plain'; if (modeCfg.xml === undefined) modeCfg.xml = true; // Allow token types to be overridden by user-provided token types. if (modeCfg.tokenTypeOverrides === undefined) modeCfg.tokenTypeOverrides = {}; var tokenTypes = { header: "header", code: "comment", quote: "quote", list1: "variable-2", list2: "variable-3", list3: "keyword", hr: "hr", image: "image", imageAltText: "image-alt-text", imageMarker: "image-marker", formatting: "formatting", linkInline: "link", linkEmail: "link", linkText: "link", linkHref: "string", em: "em", strong: "strong", strikethrough: "strikethrough", emoji: "builtin" }; for (var tokenType in tokenTypes) { if (tokenTypes.hasOwnProperty(tokenType) && modeCfg.tokenTypeOverrides[tokenType]) { tokenTypes[tokenType] = modeCfg.tokenTypeOverrides[tokenType]; } } var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/ , listRE = /^(?:[*\-+]|^[0-9]+([.)]))\s+/ , taskListRE = /^\[(x| )\](?=\s)/i // Must follow listRE , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/ , setextHeaderRE = /^ {0,3}(?:\={1,}|-{2,})\s*$/ , textRE = /^[^#!\[\]*_\\<>` "'(~:]+/ , fencedCodeRE = /^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/ , linkDefRE = /^\s*\[[^\]]+?\]:.*$/ // naive link-definition , punctuation = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/ , expandedTab = " " // CommonMark specifies tab as 4 spaces function switchInline(stream, state, f) { state.f = state.inline = f; return f(stream, state); } function switchBlock(stream, state, f) { state.f = state.block = f; return f(stream, state); } function lineIsEmpty(line) { return !line || !/\S/.test(line.string) } // Blocks function blankLine(state) { // Reset linkTitle state state.linkTitle = false; state.linkHref = false; state.linkText = false; // Reset EM state state.em = false; // Reset STRONG state state.strong = false; // Reset strikethrough state state.strikethrough = false; // Reset state.quote state.quote = 0; // Reset state.indentedCode state.indentedCode = false; if (state.f == htmlBlock) { var exit = htmlModeMissing if (!exit) { var inner = CodeMirror.innerMode(htmlMode, state.htmlState) exit = inner.mode.name == "xml" && inner.state.tagStart === null && (!inner.state.context && inner.state.tokenize.isInText) } if (exit) { state.f = inlineNormal; state.block = blockNormal; state.htmlState = null; } } // Reset state.trailingSpace state.trailingSpace = 0; state.trailingSpaceNewLine = false; // Mark this line as blank state.prevLine = state.thisLine state.thisLine = {stream: null} return null; } function blockNormal(stream, state) { var firstTokenOnLine = stream.column() === state.indentation; var prevLineLineIsEmpty = lineIsEmpty(state.prevLine.stream); var prevLineIsIndentedCode = state.indentedCode; var prevLineIsHr = state.prevLine.hr; var prevLineIsList = state.list !== false; var maxNonCodeIndentation = (state.listStack[state.listStack.length - 1] || 0) + 3; state.indentedCode = false; var lineIndentation = state.indentation; // compute once per line (on first token) if (state.indentationDiff === null) { state.indentationDiff = state.indentation; if (prevLineIsList) { state.list = null; // While this list item's marker's indentation is less than the deepest // list item's content's indentation,pop the deepest list item // indentation off the stack, and update block indentation state while (lineIndentation < state.listStack[state.listStack.length - 1]) { state.listStack.pop(); if (state.listStack.length) { state.indentation = state.listStack[state.listStack.length - 1]; // less than the first list's indent -> the line is no longer a list } else { state.list = false; } } if (state.list !== false) { state.indentationDiff = lineIndentation - state.listStack[state.listStack.length - 1] } } } // not comprehensive (currently only for setext detection purposes) var allowsInlineContinuation = ( !prevLineLineIsEmpty && !prevLineIsHr && !state.prevLine.header && (!prevLineIsList || !prevLineIsIndentedCode) && !state.prevLine.fencedCodeEnd ); var isHr = (state.list === false || prevLineIsHr || prevLineLineIsEmpty) && state.indentation <= maxNonCodeIndentation && stream.match(hrRE); var match = null; if (state.indentationDiff >= 4 && (prevLineIsIndentedCode || state.prevLine.fencedCodeEnd || state.prevLine.header || prevLineLineIsEmpty)) { stream.skipToEnd(); state.indentedCode = true; return tokenTypes.code; } else if (stream.eatSpace()) { return null; } else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(atxHeaderRE)) && match[1].length <= 6) { state.quote = 0; state.header = match[1].length; state.thisLine.header = true; if (modeCfg.highlightFormatting) state.formatting = "header"; state.f = state.inline; return getType(state); } else if (state.indentation <= maxNonCodeIndentation && stream.eat('>')) { state.quote = firstTokenOnLine ? 1 : state.quote + 1; if (modeCfg.highlightFormatting) state.formatting = "quote"; stream.eatSpace(); return getType(state); } else if (!isHr && !state.setext && firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(listRE))) { var listType = match[1] ? "ol" : "ul"; state.indentation = lineIndentation + stream.current().length; state.list = true; state.quote = 0; // Add this list item's content's indentation to the stack state.listStack.push(state.indentation); // Reset inline styles which shouldn't propagate aross list items state.em = false; state.strong = false; state.code = false; state.strikethrough = false; if (modeCfg.taskLists && stream.match(taskListRE, false)) { state.taskList = true; } state.f = state.inline; if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType]; return getType(state); } else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(fencedCodeRE, true))) { state.quote = 0; state.fencedEndRE = new RegExp(match[1] + "+ *$"); // try switching mode state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2] || modeCfg.fencedCodeBlockDefaultMode ); if (state.localMode) state.localState = CodeMirror.startState(state.localMode); state.f = state.block = local; if (modeCfg.highlightFormatting) state.formatting = "code-block"; state.code = -1 return getType(state); // SETEXT has lowest block-scope precedence after HR, so check it after // the others (code, blockquote, list...) } else if ( // if setext set, indicates line after ---/=== state.setext || ( // line before ---/=== (!allowsInlineContinuation || !prevLineIsList) && !state.quote && state.list === false && !state.code && !isHr && !linkDefRE.test(stream.string) && (match = stream.lookAhead(1)) && (match = match.match(setextHeaderRE)) ) ) { if ( !state.setext ) { state.header = match[0].charAt(0) == '=' ? 1 : 2; state.setext = state.header; } else { state.header = state.setext; // has no effect on type so we can reset it now state.setext = 0; stream.skipToEnd(); if (modeCfg.highlightFormatting) state.formatting = "header"; } state.thisLine.header = true; state.f = state.inline; return getType(state); } else if (isHr) { stream.skipToEnd(); state.hr = true; state.thisLine.hr = true; return tokenTypes.hr; } else if (stream.peek() === '[') { return switchInline(stream, state, footnoteLink); } return switchInline(stream, state, state.inline); } function htmlBlock(stream, state) { var style = htmlMode.token(stream, state.htmlState); if (!htmlModeMissing) { var inner = CodeMirror.innerMode(htmlMode, state.htmlState) if ((inner.mode.name == "xml" && inner.state.tagStart === null && (!inner.state.context && inner.state.tokenize.isInText)) || (state.md_inside && stream.current().indexOf(">") > -1)) { state.f = inlineNormal; state.block = blockNormal; state.htmlState = null; } } return style; } function local(stream, state) { var currListInd = state.listStack[state.listStack.length - 1] || 0; var hasExitedList = state.indentation < currListInd; var maxFencedEndInd = currListInd + 3; if (state.fencedEndRE && state.indentation <= maxFencedEndInd && (hasExitedList || stream.match(state.fencedEndRE))) { if (modeCfg.highlightFormatting) state.formatting = "code-block"; var returnType; if (!hasExitedList) returnType = getType(state) state.localMode = state.localState = null; state.block = blockNormal; state.f = inlineNormal; state.fencedEndRE = null; state.code = 0 state.thisLine.fencedCodeEnd = true; if (hasExitedList) return switchBlock(stream, state, state.block); return returnType; } else if (state.localMode) { return state.localMode.token(stream, state.localState); } else { stream.skipToEnd(); return tokenTypes.code; } } // Inline function getType(state) { var styles = []; if (state.formatting) { styles.push(tokenTypes.formatting); if (typeof state.formatting === "string") state.formatting = [state.formatting]; for (var i = 0; i < state.formatting.length; i++) { styles.push(tokenTypes.formatting + "-" + state.formatting[i]); if (state.formatting[i] === "header") { styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.header); } // Add `formatting-quote` and `formatting-quote-#` for blockquotes // Add `error` instead if the maximum blockquote nesting depth is passed if (state.formatting[i] === "quote") { if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) { styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.quote); } else { styles.push("error"); } } } } if (state.taskOpen) { styles.push("meta"); return styles.length ? styles.join(' ') : null; } if (state.taskClosed) { styles.push("property"); return styles.length ? styles.join(' ') : null; } if (state.linkHref) { styles.push(tokenTypes.linkHref, "url"); } else { // Only apply inline styles to non-url text if (state.strong) { styles.push(tokenTypes.strong); } if (state.em) { styles.push(tokenTypes.em); } if (state.strikethrough) { styles.push(tokenTypes.strikethrough); } if (state.emoji) { styles.push(tokenTypes.emoji); } if (state.linkText) { styles.push(tokenTypes.linkText); } if (state.code) { styles.push(tokenTypes.code); } if (state.image) { styles.push(tokenTypes.image); } if (state.imageAltText) { styles.push(tokenTypes.imageAltText, "link"); } if (state.imageMarker) { styles.push(tokenTypes.imageMarker); } } if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); } if (state.quote) { styles.push(tokenTypes.quote); // Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) { styles.push(tokenTypes.quote + "-" + state.quote); } else { styles.push(tokenTypes.quote + "-" + modeCfg.maxBlockquoteDepth); } } if (state.list !== false) { var listMod = (state.listStack.length - 1) % 3; if (!listMod) { styles.push(tokenTypes.list1); } else if (listMod === 1) { styles.push(tokenTypes.list2); } else { styles.push(tokenTypes.list3); } } if (state.trailingSpaceNewLine) { styles.push("trailing-space-new-line"); } else if (state.trailingSpace) { styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b")); } return styles.length ? styles.join(' ') : null; } function handleText(stream, state) { if (stream.match(textRE, true)) { return getType(state); } return undefined; } function inlineNormal(stream, state) { var style = state.text(stream, state); if (typeof style !== 'undefined') return style; if (state.list) { // List marker (*, +, -, 1., etc) state.list = null; return getType(state); } if (state.taskList) { var taskOpen = stream.match(taskListRE, true)[1] === " "; if (taskOpen) state.taskOpen = true; else state.taskClosed = true; if (modeCfg.highlightFormatting) state.formatting = "task"; state.taskList = false; return getType(state); } state.taskOpen = false; state.taskClosed = false; if (state.header && stream.match(/^#+$/, true)) { if (modeCfg.highlightFormatting) state.formatting = "header"; return getType(state); } var ch = stream.next(); // Matches link titles present on next line if (state.linkTitle) { state.linkTitle = false; var matchCh = ch; if (ch === '(') { matchCh = ')'; } matchCh = (matchCh+'').replace(/([.?*+^\[\]\\(){}|-])/g, "\\$1"); var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh; if (stream.match(new RegExp(regex), true)) { return tokenTypes.linkHref; } } // If this block is changed, it may need to be updated in GFM mode if (ch === '`') { var previousFormatting = state.formatting; if (modeCfg.highlightFormatting) state.formatting = "code"; stream.eatWhile('`'); var count = stream.current().length if (state.code == 0 && (!state.quote || count == 1)) { state.code = count return getType(state) } else if (count == state.code) { // Must be exact var t = getType(state) state.code = 0 return t } else { state.formatting = previousFormatting return getType(state) } } else if (state.code) { return getType(state); } if (ch === '\\') { stream.next(); if (modeCfg.highlightFormatting) { var type = getType(state); var formattingEscape = tokenTypes.formatting + "-escape"; return type ? type + " " + formattingEscape : formattingEscape; } } if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) { state.imageMarker = true; state.image = true; if (modeCfg.highlightFormatting) state.formatting = "image"; return getType(state); } if (ch === '[' && state.imageMarker && stream.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/, false)) { state.imageMarker = false; state.imageAltText = true if (modeCfg.highlightFormatting) state.formatting = "image"; return getType(state); } if (ch === ']' && state.imageAltText) { if (modeCfg.highlightFormatting) state.formatting = "image"; var type = getType(state); state.imageAltText = false; state.image = false; state.inline = state.f = linkHref; return type; } if (ch === '[' && !state.image) { if (state.linkText && stream.match(/^.*?\]/)) return getType(state) state.linkText = true; if (modeCfg.highlightFormatting) state.formatting = "link"; return getType(state); } if (ch === ']' && state.linkText) { if (modeCfg.highlightFormatting) state.formatting = "link"; var type = getType(state); state.linkText = false; state.inline = state.f = stream.match(/\(.*?\)| ?\[.*?\]/, false) ? linkHref : inlineNormal return type; } if (ch === '<' && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, false)) { state.f = state.inline = linkInline; if (modeCfg.highlightFormatting) state.formatting = "link"; var type = getType(state); if (type){ type += " "; } else { type = ""; } return type + tokenTypes.linkInline; } if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) { state.f = state.inline = linkInline; if (modeCfg.highlightFormatting) state.formatting = "link"; var type = getType(state); if (type){ type += " "; } else { type = ""; } return type + tokenTypes.linkEmail; } if (modeCfg.xml && ch === '<' && stream.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i, false)) { var end = stream.string.indexOf(">", stream.pos); if (end != -1) { var atts = stream.string.substring(stream.start, end); if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) state.md_inside = true; } stream.backUp(1); state.htmlState = CodeMirror.startState(htmlMode); return switchBlock(stream, state, htmlBlock); } if (modeCfg.xml && ch === '<' && stream.match(/^\/\w*?>/)) { state.md_inside = false; return "tag"; } else if (ch === "*" || ch === "_") { var len = 1, before = stream.pos == 1 ? " " : stream.string.charAt(stream.pos - 2) while (len < 3 && stream.eat(ch)) len++ var after = stream.peek() || " " // See http://spec.commonmark.org/0.27/#emphasis-and-strong-emphasis var leftFlanking = !/\s/.test(after) && (!punctuation.test(after) || /\s/.test(before) || punctuation.test(before)) var rightFlanking = !/\s/.test(before) && (!punctuation.test(before) || /\s/.test(after) || punctuation.test(after)) var setEm = null, setStrong = null if (len % 2) { // Em if (!state.em && leftFlanking && (ch === "*" || !rightFlanking || punctuation.test(before))) setEm = true else if (state.em == ch && rightFlanking && (ch === "*" || !leftFlanking || punctuation.test(after))) setEm = false } if (len > 1) { // Strong if (!state.strong && leftFlanking && (ch === "*" || !rightFlanking || punctuation.test(before))) setStrong = true else if (state.strong == ch && rightFlanking && (ch === "*" || !leftFlanking || punctuation.test(after))) setStrong = false } if (setStrong != null || setEm != null) { if (modeCfg.highlightFormatting) state.formatting = setEm == null ? "strong" : setStrong == null ? "em" : "strong em" if (setEm === true) state.em = ch if (setStrong === true) state.strong = ch var t = getType(state) if (setEm === false) state.em = false if (setStrong === false) state.strong = false return t } } else if (ch === ' ') { if (stream.eat('*') || stream.eat('_')) { // Probably surrounded by spaces if (stream.peek() === ' ') { // Surrounded by spaces, ignore return getType(state); } else { // Not surrounded by spaces, back up pointer stream.backUp(1); } } } if (modeCfg.strikethrough) { if (ch === '~' && stream.eatWhile(ch)) { if (state.strikethrough) {// Remove strikethrough if (modeCfg.highlightFormatting) state.formatting = "strikethrough"; var t = getType(state); state.strikethrough = false; return t; } else if (stream.match(/^[^\s]/, false)) {// Add strikethrough state.strikethrough = true; if (modeCfg.highlightFormatting) state.formatting = "strikethrough"; return getType(state); } } else if (ch === ' ') { if (stream.match(/^~~/, true)) { // Probably surrounded by space if (stream.peek() === ' ') { // Surrounded by spaces, ignore return getType(state); } else { // Not surrounded by spaces, back up pointer stream.backUp(2); } } } } if (modeCfg.emoji && ch === ":" && stream.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)) { state.emoji = true; if (modeCfg.highlightFormatting) state.formatting = "emoji"; var retType = getType(state); state.emoji = false; return retType; } if (ch === ' ') { if (stream.match(/^ +$/, false)) { state.trailingSpace++; } else if (state.trailingSpace) { state.trailingSpaceNewLine = true; } } return getType(state); } function linkInline(stream, state) { var ch = stream.next(); if (ch === ">") { state.f = state.inline = inlineNormal; if (modeCfg.highlightFormatting) state.formatting = "link"; var type = getType(state); if (type){ type += " "; } else { type = ""; } return type + tokenTypes.linkInline; } stream.match(/^[^>]+/, true); return tokenTypes.linkInline; } function linkHref(stream, state) { // Check if space, and return NULL if so (to avoid marking the space) if(stream.eatSpace()){ return null; } var ch = stream.next(); if (ch === '(' || ch === '[') { state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]"); if (modeCfg.highlightFormatting) state.formatting = "link-string"; state.linkHref = true; return getType(state); } return 'error'; } var linkRE = { ")": /^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/, "]": /^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/ } function getLinkHrefInside(endChar) { return function(stream, state) { var ch = stream.next(); if (ch === endChar) { state.f = state.inline = inlineNormal; if (modeCfg.highlightFormatting) state.formatting = "link-string"; var returnState = getType(state); state.linkHref = false; return returnState; } stream.match(linkRE[endChar]) state.linkHref = true; return getType(state); }; } function footnoteLink(stream, state) { if (stream.match(/^([^\]\\]|\\.)*\]:/, false)) { state.f = footnoteLinkInside; stream.next(); // Consume [ if (modeCfg.highlightFormatting) state.formatting = "link"; state.linkText = true; return getType(state); } return switchInline(stream, state, inlineNormal); } function footnoteLinkInside(stream, state) { if (stream.match(/^\]:/, true)) { state.f = state.inline = footnoteUrl; if (modeCfg.highlightFormatting) state.formatting = "link"; var returnType = getType(state); state.linkText = false; return returnType; } stream.match(/^([^\]\\]|\\.)+/, true); return tokenTypes.linkText; } function footnoteUrl(stream, state) { // Check if space, and return NULL if so (to avoid marking the space) if(stream.eatSpace()){ return null; } // Match URL stream.match(/^[^\s]+/, true); // Check for link title if (stream.peek() === undefined) { // End of line, set flag to check next line state.linkTitle = true; } else { // More content on line, check if link title stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true); } state.f = state.inline = inlineNormal; return tokenTypes.linkHref + " url"; } var mode = { startState: function() { return { f: blockNormal, prevLine: {stream: null}, thisLine: {stream: null}, block: blockNormal, htmlState: null, indentation: 0, inline: inlineNormal, text: handleText, formatting: false, linkText: false, linkHref: false, linkTitle: false, code: 0, em: false, strong: false, header: 0, setext: 0, hr: false, taskList: false, list: false, listStack: [], quote: 0, trailingSpace: 0, trailingSpaceNewLine: false, strikethrough: false, emoji: false, fencedEndRE: null }; }, copyState: function(s) { return { f: s.f, prevLine: s.prevLine, thisLine: s.thisLine, block: s.block, htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState), indentation: s.indentation, localMode: s.localMode, localState: s.localMode ? CodeMirror.copyState(s.localMode, s.localState) : null, inline: s.inline, text: s.text, formatting: false, linkText: s.linkText, linkTitle: s.linkTitle, linkHref: s.linkHref, code: s.code, em: s.em, strong: s.strong, strikethrough: s.strikethrough, emoji: s.emoji, header: s.header, setext: s.setext, hr: s.hr, taskList: s.taskList, list: s.list, listStack: s.listStack.slice(0), quote: s.quote, indentedCode: s.indentedCode, trailingSpace: s.trailingSpace, trailingSpaceNewLine: s.trailingSpaceNewLine, md_inside: s.md_inside, fencedEndRE: s.fencedEndRE }; }, token: function(stream, state) { // Reset state.formatting state.formatting = false; if (stream != state.thisLine.stream) { state.header = 0; state.hr = false; if (stream.match(/^\s*$/, true)) { blankLine(state); return null; } state.prevLine = state.thisLine state.thisLine = {stream: stream} // Reset state.taskList state.taskList = false; // Reset state.trailingSpace state.trailingSpace = 0; state.trailingSpaceNewLine = false; if (!state.localState) { state.f = state.block; if (state.f != htmlBlock) { var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, expandedTab).length; state.indentation = indentation; state.indentationDiff = null; if (indentation > 0) return null; } } } return state.f(stream, state); }, innerMode: function(state) { if (state.block == htmlBlock) return {state: state.htmlState, mode: htmlMode}; if (state.localState) return {state: state.localState, mode: state.localMode}; return {state: state, mode: mode}; }, indent: function(state, textAfter, line) { if (state.block == htmlBlock && htmlMode.indent) return htmlMode.indent(state.htmlState, textAfter, line) if (state.localState && state.localMode.indent) return state.localMode.indent(state.localState, textAfter, line) return CodeMirror.Pass }, blankLine: blankLine, getType: getType, blockCommentStart: "", closeBrackets: "()[]{}''\"\"``", fold: "markdown" }; return mode; }, "xml"); CodeMirror.defineMIME("text/markdown", "markdown"); CodeMirror.defineMIME("text/x-markdown", "markdown"); }); /* ---- mode/python.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; function wordRegexp(words) { return new RegExp("^((" + words.join(")|(") + "))\\b"); } var wordOperators = wordRegexp(["and", "or", "not", "is"]); var commonKeywords = ["as", "assert", "break", "class", "continue", "def", "del", "elif", "else", "except", "finally", "for", "from", "global", "if", "import", "lambda", "pass", "raise", "return", "try", "while", "with", "yield", "in"]; var commonBuiltins = ["abs", "all", "any", "bin", "bool", "bytearray", "callable", "chr", "classmethod", "compile", "complex", "delattr", "dict", "dir", "divmod", "enumerate", "eval", "filter", "float", "format", "frozenset", "getattr", "globals", "hasattr", "hash", "help", "hex", "id", "input", "int", "isinstance", "issubclass", "iter", "len", "list", "locals", "map", "max", "memoryview", "min", "next", "object", "oct", "open", "ord", "pow", "property", "range", "repr", "reversed", "round", "set", "setattr", "slice", "sorted", "staticmethod", "str", "sum", "super", "tuple", "type", "vars", "zip", "__import__", "NotImplemented", "Ellipsis", "__debug__"]; CodeMirror.registerHelper("hintWords", "python", commonKeywords.concat(commonBuiltins)); function top(state) { return state.scopes[state.scopes.length - 1]; } CodeMirror.defineMode("python", function(conf, parserConf) { var ERRORCLASS = "error"; var delimiters = parserConf.delimiters || parserConf.singleDelimiters || /^[\(\)\[\]\{\}@,:`=;\.\\]/; // (Backwards-compatibility with old, cumbersome config system) var operators = [parserConf.singleOperators, parserConf.doubleOperators, parserConf.doubleDelimiters, parserConf.tripleDelimiters, parserConf.operators || /^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@]|\.\.\.)/] for (var i = 0; i < operators.length; i++) if (!operators[i]) operators.splice(i--, 1) var hangingIndent = parserConf.hangingIndent || conf.indentUnit; var myKeywords = commonKeywords, myBuiltins = commonBuiltins; if (parserConf.extra_keywords != undefined) myKeywords = myKeywords.concat(parserConf.extra_keywords); if (parserConf.extra_builtins != undefined) myBuiltins = myBuiltins.concat(parserConf.extra_builtins); var py3 = !(parserConf.version && Number(parserConf.version) < 3) if (py3) { // since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/; myKeywords = myKeywords.concat(["nonlocal", "False", "True", "None", "async", "await"]); myBuiltins = myBuiltins.concat(["ascii", "bytes", "exec", "print"]); var stringPrefixes = new RegExp("^(([rbuf]|(br)|(fr))?('{3}|\"{3}|['\"]))", "i"); } else { var identifiers = parserConf.identifiers|| /^[_A-Za-z][_A-Za-z0-9]*/; myKeywords = myKeywords.concat(["exec", "print"]); myBuiltins = myBuiltins.concat(["apply", "basestring", "buffer", "cmp", "coerce", "execfile", "file", "intern", "long", "raw_input", "reduce", "reload", "unichr", "unicode", "xrange", "False", "True", "None"]); var stringPrefixes = new RegExp("^(([rubf]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i"); } var keywords = wordRegexp(myKeywords); var builtins = wordRegexp(myBuiltins); // tokenizers function tokenBase(stream, state) { var sol = stream.sol() && state.lastToken != "\\" if (sol) state.indent = stream.indentation() // Handle scope changes if (sol && top(state).type == "py") { var scopeOffset = top(state).offset; if (stream.eatSpace()) { var lineOffset = stream.indentation(); if (lineOffset > scopeOffset) pushPyScope(state); else if (lineOffset < scopeOffset && dedent(stream, state) && stream.peek() != "#") state.errorToken = true; return null; } else { var style = tokenBaseInner(stream, state); if (scopeOffset > 0 && dedent(stream, state)) style += " " + ERRORCLASS; return style; } } return tokenBaseInner(stream, state); } function tokenBaseInner(stream, state, inFormat) { if (stream.eatSpace()) return null; // Handle Comments if (!inFormat && stream.match(/^#.*/)) return "comment"; // Handle Number Literals if (stream.match(/^[0-9\.]/, false)) { var floatLiteral = false; // Floats if (stream.match(/^[\d_]*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; } if (stream.match(/^[\d_]+\.\d*/)) { floatLiteral = true; } if (stream.match(/^\.\d+/)) { floatLiteral = true; } if (floatLiteral) { // Float literals may be "imaginary" stream.eat(/J/i); return "number"; } // Integers var intLiteral = false; // Hex if (stream.match(/^0x[0-9a-f_]+/i)) intLiteral = true; // Binary if (stream.match(/^0b[01_]+/i)) intLiteral = true; // Octal if (stream.match(/^0o[0-7_]+/i)) intLiteral = true; // Decimal if (stream.match(/^[1-9][\d_]*(e[\+\-]?[\d_]+)?/)) { // Decimal literals may be "imaginary" stream.eat(/J/i); // TODO - Can you have imaginary longs? intLiteral = true; } // Zero by itself with no other piece of number. if (stream.match(/^0(?![\dx])/i)) intLiteral = true; if (intLiteral) { // Integer literals may be "long" stream.eat(/L/i); return "number"; } } // Handle Strings if (stream.match(stringPrefixes)) { var isFmtString = stream.current().toLowerCase().indexOf('f') !== -1; if (!isFmtString) { state.tokenize = tokenStringFactory(stream.current(), state.tokenize); return state.tokenize(stream, state); } else { state.tokenize = formatStringFactory(stream.current(), state.tokenize); return state.tokenize(stream, state); } } for (var i = 0; i < operators.length; i++) if (stream.match(operators[i])) return "operator" if (stream.match(delimiters)) return "punctuation"; if (state.lastToken == "." && stream.match(identifiers)) return "property"; if (stream.match(keywords) || stream.match(wordOperators)) return "keyword"; if (stream.match(builtins)) return "builtin"; if (stream.match(/^(self|cls)\b/)) return "variable-2"; if (stream.match(identifiers)) { if (state.lastToken == "def" || state.lastToken == "class") return "def"; return "variable"; } // Handle non-detected items stream.next(); return inFormat ? null :ERRORCLASS; } function formatStringFactory(delimiter, tokenOuter) { while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0) delimiter = delimiter.substr(1); var singleline = delimiter.length == 1; var OUTCLASS = "string"; function tokenNestedExpr(depth) { return function(stream, state) { var inner = tokenBaseInner(stream, state, true) if (inner == "punctuation") { if (stream.current() == "{") { state.tokenize = tokenNestedExpr(depth + 1) } else if (stream.current() == "}") { if (depth > 1) state.tokenize = tokenNestedExpr(depth - 1) else state.tokenize = tokenString } } return inner } } function tokenString(stream, state) { while (!stream.eol()) { stream.eatWhile(/[^'"\{\}\\]/); if (stream.eat("\\")) { stream.next(); if (singleline && stream.eol()) return OUTCLASS; } else if (stream.match(delimiter)) { state.tokenize = tokenOuter; return OUTCLASS; } else if (stream.match('{{')) { // ignore {{ in f-str return OUTCLASS; } else if (stream.match('{', false)) { // switch to nested mode state.tokenize = tokenNestedExpr(0) if (stream.current()) return OUTCLASS; else return state.tokenize(stream, state) } else if (stream.match('}}')) { return OUTCLASS; } else if (stream.match('}')) { // single } in f-string is an error return ERRORCLASS; } else { stream.eat(/['"]/); } } if (singleline) { if (parserConf.singleLineStringErrors) return ERRORCLASS; else state.tokenize = tokenOuter; } return OUTCLASS; } tokenString.isString = true; return tokenString; } function tokenStringFactory(delimiter, tokenOuter) { while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0) delimiter = delimiter.substr(1); var singleline = delimiter.length == 1; var OUTCLASS = "string"; function tokenString(stream, state) { while (!stream.eol()) { stream.eatWhile(/[^'"\\]/); if (stream.eat("\\")) { stream.next(); if (singleline && stream.eol()) return OUTCLASS; } else if (stream.match(delimiter)) { state.tokenize = tokenOuter; return OUTCLASS; } else { stream.eat(/['"]/); } } if (singleline) { if (parserConf.singleLineStringErrors) return ERRORCLASS; else state.tokenize = tokenOuter; } return OUTCLASS; } tokenString.isString = true; return tokenString; } function pushPyScope(state) { while (top(state).type != "py") state.scopes.pop() state.scopes.push({offset: top(state).offset + conf.indentUnit, type: "py", align: null}) } function pushBracketScope(stream, state, type) { var align = stream.match(/^([\s\[\{\(]|#.*)*$/, false) ? null : stream.column() + 1 state.scopes.push({offset: state.indent + hangingIndent, type: type, align: align}) } function dedent(stream, state) { var indented = stream.indentation(); while (state.scopes.length > 1 && top(state).offset > indented) { if (top(state).type != "py") return true; state.scopes.pop(); } return top(state).offset != indented; } function tokenLexer(stream, state) { if (stream.sol()) state.beginningOfLine = true; var style = state.tokenize(stream, state); var current = stream.current(); // Handle decorators if (state.beginningOfLine && current == "@") return stream.match(identifiers, false) ? "meta" : py3 ? "operator" : ERRORCLASS; if (/\S/.test(current)) state.beginningOfLine = false; if ((style == "variable" || style == "builtin") && state.lastToken == "meta") style = "meta"; // Handle scope changes. if (current == "pass" || current == "return") state.dedent += 1; if (current == "lambda") state.lambda = true; if (current == ":" && !state.lambda && top(state).type == "py") pushPyScope(state); if (current.length == 1 && !/string|comment/.test(style)) { var delimiter_index = "[({".indexOf(current); if (delimiter_index != -1) pushBracketScope(stream, state, "])}".slice(delimiter_index, delimiter_index+1)); delimiter_index = "])}".indexOf(current); if (delimiter_index != -1) { if (top(state).type == current) state.indent = state.scopes.pop().offset - hangingIndent else return ERRORCLASS; } } if (state.dedent > 0 && stream.eol() && top(state).type == "py") { if (state.scopes.length > 1) state.scopes.pop(); state.dedent -= 1; } return style; } var external = { startState: function(basecolumn) { return { tokenize: tokenBase, scopes: [{offset: basecolumn || 0, type: "py", align: null}], indent: basecolumn || 0, lastToken: null, lambda: false, dedent: 0 }; }, token: function(stream, state) { var addErr = state.errorToken; if (addErr) state.errorToken = false; var style = tokenLexer(stream, state); if (style && style != "comment") state.lastToken = (style == "keyword" || style == "punctuation") ? stream.current() : style; if (style == "punctuation") style = null; if (stream.eol() && state.lambda) state.lambda = false; return addErr ? style + " " + ERRORCLASS : style; }, indent: function(state, textAfter) { if (state.tokenize != tokenBase) return state.tokenize.isString ? CodeMirror.Pass : 0; var scope = top(state), closing = scope.type == textAfter.charAt(0) if (scope.align != null) return scope.align - (closing ? 1 : 0) else return scope.offset - (closing ? hangingIndent : 0) }, electricInput: /^\s*[\}\]\)]$/, closeBrackets: {triples: "'\""}, lineComment: "#", fold: "indent" }; return external; }); CodeMirror.defineMIME("text/x-python", "python"); var words = function(str) { return str.split(" "); }; CodeMirror.defineMIME("text/x-cython", { name: "python", extra_keywords: words("by cdef cimport cpdef ctypedef enum except "+ "extern gil include nogil property public "+ "readonly struct union DEF IF ELIF ELSE") }); }); /* ---- mode/rust.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../../addon/mode/simple")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../../addon/mode/simple"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineSimpleMode("rust",{ start: [ // string and byte string {regex: /b?"/, token: "string", next: "string"}, // raw string and raw byte string {regex: /b?r"/, token: "string", next: "string_raw"}, {regex: /b?r#+"/, token: "string", next: "string_raw_hash"}, // character {regex: /'(?:[^'\\]|\\(?:[nrt0'"]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\}))'/, token: "string-2"}, // byte {regex: /b'(?:[^']|\\(?:['\\nrt0]|x[\da-fA-F]{2}))'/, token: "string-2"}, {regex: /(?:(?:[0-9][0-9_]*)(?:(?:[Ee][+-]?[0-9_]+)|\.[0-9_]+(?:[Ee][+-]?[0-9_]+)?)(?:f32|f64)?)|(?:0(?:b[01_]+|(?:o[0-7_]+)|(?:x[0-9a-fA-F_]+))|(?:[0-9][0-9_]*))(?:u8|u16|u32|u64|i8|i16|i32|i64|isize|usize)?/, token: "number"}, {regex: /(let(?:\s+mut)?|fn|enum|mod|struct|type|union)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/, token: ["keyword", null, "def"]}, {regex: /(?:abstract|alignof|as|async|await|box|break|continue|const|crate|do|dyn|else|enum|extern|fn|for|final|if|impl|in|loop|macro|match|mod|move|offsetof|override|priv|proc|pub|pure|ref|return|self|sizeof|static|struct|super|trait|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/, token: "keyword"}, {regex: /\b(?:Self|isize|usize|char|bool|u8|u16|u32|u64|f16|f32|f64|i8|i16|i32|i64|str|Option)\b/, token: "atom"}, {regex: /\b(?:true|false|Some|None|Ok|Err)\b/, token: "builtin"}, {regex: /\b(fn)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/, token: ["keyword", null ,"def"]}, {regex: /#!?\[.*\]/, token: "meta"}, {regex: /\/\/.*/, token: "comment"}, {regex: /\/\*/, token: "comment", next: "comment"}, {regex: /[-+\/*=<>!]+/, token: "operator"}, {regex: /[a-zA-Z_]\w*!/,token: "variable-3"}, {regex: /[a-zA-Z_]\w*/, token: "variable"}, {regex: /[\{\[\(]/, indent: true}, {regex: /[\}\]\)]/, dedent: true} ], string: [ {regex: /"/, token: "string", next: "start"}, {regex: /(?:[^\\"]|\\(?:.|$))*/, token: "string"} ], string_raw: [ {regex: /"/, token: "string", next: "start"}, {regex: /[^"]*/, token: "string"} ], string_raw_hash: [ {regex: /"#+/, token: "string", next: "start"}, {regex: /(?:[^"]|"(?!#))*/, token: "string"} ], comment: [ {regex: /.*?\*\//, token: "comment", next: "start"}, {regex: /.*/, token: "comment"} ], meta: { dontIndentStates: ["comment"], electricInput: /^\s*\}$/, blockCommentStart: "/*", blockCommentEnd: "*/", lineComment: "//", fold: "brace" } }); CodeMirror.defineMIME("text/x-rustsrc", "rust"); CodeMirror.defineMIME("text/rust", "rust"); }); /* ---- mode/xml.js ---- */ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var htmlConfig = { autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true, 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true, 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true, 'track': true, 'wbr': true, 'menuitem': true}, implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true, 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true, 'th': true, 'tr': true}, contextGrabbers: { 'dd': {'dd': true, 'dt': true}, 'dt': {'dd': true, 'dt': true}, 'li': {'li': true}, 'option': {'option': true, 'optgroup': true}, 'optgroup': {'optgroup': true}, 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true, 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true, 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true, 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true, 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true}, 'rp': {'rp': true, 'rt': true}, 'rt': {'rp': true, 'rt': true}, 'tbody': {'tbody': true, 'tfoot': true}, 'td': {'td': true, 'th': true}, 'tfoot': {'tbody': true}, 'th': {'td': true, 'th': true}, 'thead': {'tbody': true, 'tfoot': true}, 'tr': {'tr': true} }, doNotIndent: {"pre": true}, allowUnquoted: true, allowMissing: true, caseFold: true } var xmlConfig = { autoSelfClosers: {}, implicitlyClosed: {}, contextGrabbers: {}, doNotIndent: {}, allowUnquoted: false, allowMissing: false, allowMissingTagName: false, caseFold: false } CodeMirror.defineMode("xml", function(editorConf, config_) { var indentUnit = editorConf.indentUnit var config = {} var defaults = config_.htmlMode ? htmlConfig : xmlConfig for (var prop in defaults) config[prop] = defaults[prop] for (var prop in config_) config[prop] = config_[prop] // Return variables for tokenizers var type, setStyle; function inText(stream, state) { function chain(parser) { state.tokenize = parser; return parser(stream, state); } var ch = stream.next(); if (ch == "<") { if (stream.eat("!")) { if (stream.eat("[")) { if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>")); else return null; } else if (stream.match("--")) { return chain(inBlock("comment", "-->")); } else if (stream.match("DOCTYPE", true, true)) { stream.eatWhile(/[\w\._\-]/); return chain(doctype(1)); } else { return null; } } else if (stream.eat("?")) { stream.eatWhile(/[\w\._\-]/); state.tokenize = inBlock("meta", "?>"); return "meta"; } else { type = stream.eat("/") ? "closeTag" : "openTag"; state.tokenize = inTag; return "tag bracket"; } } else if (ch == "&") { var ok; if (stream.eat("#")) { if (stream.eat("x")) { ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";"); } else { ok = stream.eatWhile(/[\d]/) && stream.eat(";"); } } else { ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";"); } return ok ? "atom" : "error"; } else { stream.eatWhile(/[^&<]/); return null; } } inText.isInText = true; function inTag(stream, state) { var ch = stream.next(); if (ch == ">" || (ch == "/" && stream.eat(">"))) { state.tokenize = inText; type = ch == ">" ? "endTag" : "selfcloseTag"; return "tag bracket"; } else if (ch == "=") { type = "equals"; return null; } else if (ch == "<") { state.tokenize = inText; state.state = baseState; state.tagName = state.tagStart = null; var next = state.tokenize(stream, state); return next ? next + " tag error" : "tag error"; } else if (/[\'\"]/.test(ch)) { state.tokenize = inAttribute(ch); state.stringStartCol = stream.column(); return state.tokenize(stream, state); } else { stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/); return "word"; } } function inAttribute(quote) { var closure = function(stream, state) { while (!stream.eol()) { if (stream.next() == quote) { state.tokenize = inTag; break; } } return "string"; }; closure.isInAttribute = true; return closure; } function inBlock(style, terminator) { return function(stream, state) { while (!stream.eol()) { if (stream.match(terminator)) { state.tokenize = inText; break; } stream.next(); } return style; } } function doctype(depth) { return function(stream, state) { var ch; while ((ch = stream.next()) != null) { if (ch == "<") { state.tokenize = doctype(depth + 1); return state.tokenize(stream, state); } else if (ch == ">") { if (depth == 1) { state.tokenize = inText; break; } else { state.tokenize = doctype(depth - 1); return state.tokenize(stream, state); } } } return "meta"; }; } function Context(state, tagName, startOfLine) { this.prev = state.context; this.tagName = tagName; this.indent = state.indented; this.startOfLine = startOfLine; if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent)) this.noIndent = true; } function popContext(state) { if (state.context) state.context = state.context.prev; } function maybePopContext(state, nextTagName) { var parentTagName; while (true) { if (!state.context) { return; } parentTagName = state.context.tagName; if (!config.contextGrabbers.hasOwnProperty(parentTagName) || !config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) { return; } popContext(state); } } function baseState(type, stream, state) { if (type == "openTag") { state.tagStart = stream.column(); return tagNameState; } else if (type == "closeTag") { return closeTagNameState; } else { return baseState; } } function tagNameState(type, stream, state) { if (type == "word") { state.tagName = stream.current(); setStyle = "tag"; return attrState; } else if (config.allowMissingTagName && type == "endTag") { setStyle = "tag bracket"; return attrState(type, stream, state); } else { setStyle = "error"; return tagNameState; } } function closeTagNameState(type, stream, state) { if (type == "word") { var tagName = stream.current(); if (state.context && state.context.tagName != tagName && config.implicitlyClosed.hasOwnProperty(state.context.tagName)) popContext(state); if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) { setStyle = "tag"; return closeState; } else { setStyle = "tag error"; return closeStateErr; } } else if (config.allowMissingTagName && type == "endTag") { setStyle = "tag bracket"; return closeState(type, stream, state); } else { setStyle = "error"; return closeStateErr; } } function closeState(type, _stream, state) { if (type != "endTag") { setStyle = "error"; return closeState; } popContext(state); return baseState; } function closeStateErr(type, stream, state) { setStyle = "error"; return closeState(type, stream, state); } function attrState(type, _stream, state) { if (type == "word") { setStyle = "attribute"; return attrEqState; } else if (type == "endTag" || type == "selfcloseTag") { var tagName = state.tagName, tagStart = state.tagStart; state.tagName = state.tagStart = null; if (type == "selfcloseTag" || config.autoSelfClosers.hasOwnProperty(tagName)) { maybePopContext(state, tagName); } else { maybePopContext(state, tagName); state.context = new Context(state, tagName, tagStart == state.indented); } return baseState; } setStyle = "error"; return attrState; } function attrEqState(type, stream, state) { if (type == "equals") return attrValueState; if (!config.allowMissing) setStyle = "error"; return attrState(type, stream, state); } function attrValueState(type, stream, state) { if (type == "string") return attrContinuedState; if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;} setStyle = "error"; return attrState(type, stream, state); } function attrContinuedState(type, stream, state) { if (type == "string") return attrContinuedState; return attrState(type, stream, state); } return { startState: function(baseIndent) { var state = {tokenize: inText, state: baseState, indented: baseIndent || 0, tagName: null, tagStart: null, context: null} if (baseIndent != null) state.baseIndent = baseIndent return state }, token: function(stream, state) { if (!state.tagName && stream.sol()) state.indented = stream.indentation(); if (stream.eatSpace()) return null; type = null; var style = state.tokenize(stream, state); if ((style || type) && style != "comment") { setStyle = null; state.state = state.state(type || style, stream, state); if (setStyle) style = setStyle == "error" ? style + " error" : setStyle; } return style; }, indent: function(state, textAfter, fullLine) { var context = state.context; // Indent multi-line strings (e.g. css). if (state.tokenize.isInAttribute) { if (state.tagStart == state.indented) return state.stringStartCol + 1; else return state.indented + indentUnit; } if (context && context.noIndent) return CodeMirror.Pass; if (state.tokenize != inTag && state.tokenize != inText) return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0; // Indent the starts of attribute names. if (state.tagName) { if (config.multilineTagIndentPastTag !== false) return state.tagStart + state.tagName.length + 2; else return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1); } if (config.alignCDATA && /$/, blockCommentStart: "", configuration: config.htmlMode ? "html" : "xml", helperType: config.htmlMode ? "html" : "xml", skipAttribute: function(state) { if (state.state == attrValueState) state.state = attrState }, xmlCurrentTag: function(state) { return state.tagName ? {name: state.tagName, close: state.type == "closeTag"} : null }, xmlCurrentContext: function(state) { var context = [] for (var cx = state.context; cx; cx = cx.prev) if (cx.tagName) context.push(cx.tagName) return context.reverse() } }; }); CodeMirror.defineMIME("text/xml", "xml"); CodeMirror.defineMIME("application/xml", "xml"); if (!CodeMirror.mimeModes.hasOwnProperty("text/html")) CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true}); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/base/codemirror.css ================================================ /* BASICS */ .CodeMirror { /* Set height, width, borders, and global font properties here */ font-family: monospace; height: 300px; color: black; direction: ltr; } /* PADDING */ .CodeMirror-lines { padding: 4px 0; /* Vertical padding around content */ } .CodeMirror pre.CodeMirror-line, .CodeMirror pre.CodeMirror-line-like { padding: 0 4px; /* Horizontal padding of content */ } .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { background-color: white; /* The little square between H and V scrollbars */ } /* GUTTER */ .CodeMirror-gutters { border-right: 1px solid #ddd; background-color: #f7f7f7; white-space: nowrap; } .CodeMirror-linenumbers {} .CodeMirror-linenumber { padding: 0 3px 0 5px; min-width: 20px; text-align: right; color: #999; white-space: nowrap; } .CodeMirror-guttermarker { color: black; } .CodeMirror-guttermarker-subtle { color: #999; } /* CURSOR */ .CodeMirror-cursor { border-left: 1px solid black; border-right: none; width: 0; } /* Shown when moving in bi-directional text */ .CodeMirror div.CodeMirror-secondarycursor { border-left: 1px solid silver; } .cm-fat-cursor .CodeMirror-cursor { width: auto; border: 0 !important; background: #7e7; } .cm-fat-cursor div.CodeMirror-cursors { z-index: 1; } .cm-fat-cursor-mark { background-color: rgba(20, 255, 20, 0.5); -webkit-animation: blink 1.06s steps(1) infinite; -moz-animation: blink 1.06s steps(1) infinite; animation: blink 1.06s steps(1) infinite; } .cm-animate-fat-cursor { width: auto; border: 0; -webkit-animation: blink 1.06s steps(1) infinite; -moz-animation: blink 1.06s steps(1) infinite; animation: blink 1.06s steps(1) infinite; background-color: #7e7; } @-moz-keyframes blink { 0% {} 50% { background-color: transparent; } 100% {} } @-webkit-keyframes blink { 0% {} 50% { background-color: transparent; } 100% {} } @keyframes blink { 0% {} 50% { background-color: transparent; } 100% {} } /* Can style cursor different in overwrite (non-insert) mode */ .CodeMirror-overwrite .CodeMirror-cursor {} .cm-tab { display: inline-block; text-decoration: inherit; } .CodeMirror-rulers { position: absolute; left: 0; right: 0; top: -50px; bottom: 0; overflow: hidden; } .CodeMirror-ruler { border-left: 1px solid #ccc; top: 0; bottom: 0; position: absolute; } /* DEFAULT THEME */ .cm-s-default .cm-header {color: blue;} .cm-s-default .cm-quote {color: #090;} .cm-negative {color: #d44;} .cm-positive {color: #292;} .cm-header, .cm-strong {font-weight: bold;} .cm-em {font-style: italic;} .cm-link {text-decoration: underline;} .cm-strikethrough {text-decoration: line-through;} .cm-s-default .cm-keyword {color: #708;} .cm-s-default .cm-atom {color: #219;} .cm-s-default .cm-number {color: #164;} .cm-s-default .cm-def {color: #00f;} .cm-s-default .cm-variable, .cm-s-default .cm-punctuation, .cm-s-default .cm-property, .cm-s-default .cm-operator {} .cm-s-default .cm-variable-2 {color: #05a;} .cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;} .cm-s-default .cm-comment {color: #a50;} .cm-s-default .cm-string {color: #a11;} .cm-s-default .cm-string-2 {color: #f50;} .cm-s-default .cm-meta {color: #555;} .cm-s-default .cm-qualifier {color: #555;} .cm-s-default .cm-builtin {color: #30a;} .cm-s-default .cm-bracket {color: #997;} .cm-s-default .cm-tag {color: #170;} .cm-s-default .cm-attribute {color: #00c;} .cm-s-default .cm-hr {color: #999;} .cm-s-default .cm-link {color: #00c;} .cm-s-default .cm-error {color: #f00;} .cm-invalidchar {color: #f00;} .CodeMirror-composing { border-bottom: 2px solid; } /* Default styles for common addons */ div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;} div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;} .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); } .CodeMirror-activeline-background {background: #e8f2ff;} /* STOP */ /* The rest of this file contains styles related to the mechanics of the editor. You probably shouldn't touch them. */ .CodeMirror { position: relative; overflow: hidden; background: white; } .CodeMirror-scroll { overflow: scroll !important; /* Things will break if this is overridden */ /* 50px is the magic margin used to hide the element's real scrollbars */ /* See overflow: hidden in .CodeMirror */ margin-bottom: -50px; margin-right: -50px; padding-bottom: 50px; height: 100%; outline: none; /* Prevent dragging from highlighting the element */ position: relative; } .CodeMirror-sizer { position: relative; border-right: 50px solid transparent; } /* The fake, visible scrollbars. Used to force redraw during scrolling before actual scrolling happens, thus preventing shaking and flickering artifacts. */ .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { position: absolute; z-index: 6; display: none; } .CodeMirror-vscrollbar { right: 0; top: 0; overflow-x: hidden; overflow-y: scroll; } .CodeMirror-hscrollbar { bottom: 0; left: 0; overflow-y: hidden; overflow-x: scroll; } .CodeMirror-scrollbar-filler { right: 0; bottom: 0; } .CodeMirror-gutter-filler { left: 0; bottom: 0; } .CodeMirror-gutters { position: absolute; left: 0; top: 0; min-height: 100%; z-index: 3; } .CodeMirror-gutter { white-space: normal; height: 100%; display: inline-block; vertical-align: top; margin-bottom: -50px; } .CodeMirror-gutter-wrapper { position: absolute; z-index: 4; background: none !important; border: none !important; } .CodeMirror-gutter-background { position: absolute; top: 0; bottom: 0; z-index: 4; } .CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; } .CodeMirror-gutter-wrapper ::selection { background-color: transparent } .CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent } .CodeMirror-lines { cursor: text; min-height: 1px; /* prevents collapsing before first draw */ } .CodeMirror pre.CodeMirror-line, .CodeMirror pre.CodeMirror-line-like { /* Reset some styles that the rest of the page might have set */ -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; border-width: 0; background: transparent; font-family: inherit; font-size: inherit; margin: 0; white-space: pre; word-wrap: normal; line-height: inherit; color: inherit; z-index: 2; position: relative; overflow: visible; -webkit-tap-highlight-color: transparent; -webkit-font-variant-ligatures: contextual; font-variant-ligatures: contextual; } .CodeMirror-wrap pre.CodeMirror-line, .CodeMirror-wrap pre.CodeMirror-line-like { word-wrap: break-word; white-space: pre-wrap; word-break: normal; } .CodeMirror-linebackground { position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: 0; } .CodeMirror-linewidget { position: relative; z-index: 2; padding: 0.1px; /* Force widget margins to stay inside of the container */ } .CodeMirror-widget {} .CodeMirror-rtl pre { direction: rtl; } .CodeMirror-code { outline: none; } /* Force content-box sizing for the elements where we expect it */ .CodeMirror-scroll, .CodeMirror-sizer, .CodeMirror-gutter, .CodeMirror-gutters, .CodeMirror-linenumber { -moz-box-sizing: content-box; box-sizing: content-box; } .CodeMirror-measure { position: absolute; width: 100%; height: 0; overflow: hidden; visibility: hidden; } .CodeMirror-cursor { position: absolute; pointer-events: none; } .CodeMirror-measure pre { position: static; } div.CodeMirror-cursors { visibility: hidden; position: relative; z-index: 3; } div.CodeMirror-dragcursors { visibility: visible; } .CodeMirror-focused div.CodeMirror-cursors { visibility: visible; } .CodeMirror-selected { background: #d9d9d9; } .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } .CodeMirror-crosshair { cursor: crosshair; } .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; } .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; } .cm-searching { background-color: #ffa; background-color: rgba(255, 255, 0, .4); } /* Used to force a border model for a node */ .cm-force-border { padding-right: .1px; } @media print { /* Hide the cursor when printing */ .CodeMirror div.CodeMirror-cursors { visibility: hidden; } } /* See issue #2901 */ .cm-tab-wrap-hack:after { content: ''; } /* Help users use markselection to safely style text background */ span.CodeMirror-selectedtext { background: none; } ================================================ FILE: plugins/UiFileManager/media/codemirror/base/codemirror.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // This is CodeMirror (https://codemirror.net), a code editor // implemented in JavaScript on top of the browser's DOM. // // You can find some technical background for some of the code below // at http://marijnhaverbeke.nl/blog/#cm-internals . (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = global || self, global.CodeMirror = factory()); }(this, (function () { 'use strict'; // Kludges for bugs and behavior differences that can't be feature // detected are enabled based on userAgent etc sniffing. var userAgent = navigator.userAgent; var platform = navigator.platform; var gecko = /gecko\/\d/i.test(userAgent); var ie_upto10 = /MSIE \d/.test(userAgent); var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent); var edge = /Edge\/(\d+)/.exec(userAgent); var ie = ie_upto10 || ie_11up || edge; var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]); var webkit = !edge && /WebKit\//.test(userAgent); var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent); var chrome = !edge && /Chrome\//.test(userAgent); var presto = /Opera\//.test(userAgent); var safari = /Apple Computer/.test(navigator.vendor); var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent); var phantom = /PhantomJS/.test(userAgent); var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent); var android = /Android/.test(userAgent); // This is woefully incomplete. Suggestions for alternative methods welcome. var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent); var mac = ios || /Mac/.test(platform); var chromeOS = /\bCrOS\b/.test(userAgent); var windows = /win/i.test(platform); var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/); if (presto_version) { presto_version = Number(presto_version[1]); } if (presto_version && presto_version >= 15) { presto = false; webkit = true; } // Some browsers use the wrong event properties to signal cmd/ctrl on OS X var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11)); var captureRightClick = gecko || (ie && ie_version >= 9); function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") } var rmClass = function(node, cls) { var current = node.className; var match = classTest(cls).exec(current); if (match) { var after = current.slice(match.index + match[0].length); node.className = current.slice(0, match.index) + (after ? match[1] + after : ""); } }; function removeChildren(e) { for (var count = e.childNodes.length; count > 0; --count) { e.removeChild(e.firstChild); } return e } function removeChildrenAndAdd(parent, e) { return removeChildren(parent).appendChild(e) } function elt(tag, content, className, style) { var e = document.createElement(tag); if (className) { e.className = className; } if (style) { e.style.cssText = style; } if (typeof content == "string") { e.appendChild(document.createTextNode(content)); } else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]); } } return e } // wrapper for elt, which removes the elt from the accessibility tree function eltP(tag, content, className, style) { var e = elt(tag, content, className, style); e.setAttribute("role", "presentation"); return e } var range; if (document.createRange) { range = function(node, start, end, endNode) { var r = document.createRange(); r.setEnd(endNode || node, end); r.setStart(node, start); return r }; } else { range = function(node, start, end) { var r = document.body.createTextRange(); try { r.moveToElementText(node.parentNode); } catch(e) { return r } r.collapse(true); r.moveEnd("character", end); r.moveStart("character", start); return r }; } function contains(parent, child) { if (child.nodeType == 3) // Android browser always returns false when child is a textnode { child = child.parentNode; } if (parent.contains) { return parent.contains(child) } do { if (child.nodeType == 11) { child = child.host; } if (child == parent) { return true } } while (child = child.parentNode) } function activeElt() { // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement. // IE < 10 will throw when accessed while the page is loading or in an iframe. // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable. var activeElement; try { activeElement = document.activeElement; } catch(e) { activeElement = document.body || null; } while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement) { activeElement = activeElement.shadowRoot.activeElement; } return activeElement } function addClass(node, cls) { var current = node.className; if (!classTest(cls).test(current)) { node.className += (current ? " " : "") + cls; } } function joinClasses(a, b) { var as = a.split(" "); for (var i = 0; i < as.length; i++) { if (as[i] && !classTest(as[i]).test(b)) { b += " " + as[i]; } } return b } var selectInput = function(node) { node.select(); }; if (ios) // Mobile Safari apparently has a bug where select() is broken. { selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; }; } else if (ie) // Suppress mysterious IE10 errors { selectInput = function(node) { try { node.select(); } catch(_e) {} }; } function bind(f) { var args = Array.prototype.slice.call(arguments, 1); return function(){return f.apply(null, args)} } function copyObj(obj, target, overwrite) { if (!target) { target = {}; } for (var prop in obj) { if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop))) { target[prop] = obj[prop]; } } return target } // Counts the column offset in a string, taking tabs into account. // Used mostly to find indentation. function countColumn(string, end, tabSize, startIndex, startValue) { if (end == null) { end = string.search(/[^\s\u00a0]/); if (end == -1) { end = string.length; } } for (var i = startIndex || 0, n = startValue || 0;;) { var nextTab = string.indexOf("\t", i); if (nextTab < 0 || nextTab >= end) { return n + (end - i) } n += nextTab - i; n += tabSize - (n % tabSize); i = nextTab + 1; } } var Delayed = function() { this.id = null; this.f = null; this.time = 0; this.handler = bind(this.onTimeout, this); }; Delayed.prototype.onTimeout = function (self) { self.id = 0; if (self.time <= +new Date) { self.f(); } else { setTimeout(self.handler, self.time - +new Date); } }; Delayed.prototype.set = function (ms, f) { this.f = f; var time = +new Date + ms; if (!this.id || time < this.time) { clearTimeout(this.id); this.id = setTimeout(this.handler, ms); this.time = time; } }; function indexOf(array, elt) { for (var i = 0; i < array.length; ++i) { if (array[i] == elt) { return i } } return -1 } // Number of pixels added to scroller and sizer to hide scrollbar var scrollerGap = 50; // Returned or thrown by various protocols to signal 'I'm not // handling this'. var Pass = {toString: function(){return "CodeMirror.Pass"}}; // Reused option objects for setSelection & friends var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"}; // The inverse of countColumn -- find the offset that corresponds to // a particular column. function findColumn(string, goal, tabSize) { for (var pos = 0, col = 0;;) { var nextTab = string.indexOf("\t", pos); if (nextTab == -1) { nextTab = string.length; } var skipped = nextTab - pos; if (nextTab == string.length || col + skipped >= goal) { return pos + Math.min(skipped, goal - col) } col += nextTab - pos; col += tabSize - (col % tabSize); pos = nextTab + 1; if (col >= goal) { return pos } } } var spaceStrs = [""]; function spaceStr(n) { while (spaceStrs.length <= n) { spaceStrs.push(lst(spaceStrs) + " "); } return spaceStrs[n] } function lst(arr) { return arr[arr.length-1] } function map(array, f) { var out = []; for (var i = 0; i < array.length; i++) { out[i] = f(array[i], i); } return out } function insertSorted(array, value, score) { var pos = 0, priority = score(value); while (pos < array.length && score(array[pos]) <= priority) { pos++; } array.splice(pos, 0, value); } function nothing() {} function createObj(base, props) { var inst; if (Object.create) { inst = Object.create(base); } else { nothing.prototype = base; inst = new nothing(); } if (props) { copyObj(props, inst); } return inst } var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/; function isWordCharBasic(ch) { return /\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)) } function isWordChar(ch, helper) { if (!helper) { return isWordCharBasic(ch) } if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) { return true } return helper.test(ch) } function isEmpty(obj) { for (var n in obj) { if (obj.hasOwnProperty(n) && obj[n]) { return false } } return true } // Extending unicode characters. A series of a non-extending char + // any number of extending chars is treated as a single unit as far // as editing and measuring is concerned. This is not fully correct, // since some scripts/fonts/browsers also treat other configurations // of code points as a group. var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/; function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) } // Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range. function skipExtendingChars(str, pos, dir) { while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) { pos += dir; } return pos } // Returns the value from the range [`from`; `to`] that satisfies // `pred` and is closest to `from`. Assumes that at least `to` // satisfies `pred`. Supports `from` being greater than `to`. function findFirst(pred, from, to) { // At any point we are certain `to` satisfies `pred`, don't know // whether `from` does. var dir = from > to ? -1 : 1; for (;;) { if (from == to) { return from } var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF); if (mid == from) { return pred(mid) ? from : to } if (pred(mid)) { to = mid; } else { from = mid + dir; } } } // BIDI HELPERS function iterateBidiSections(order, from, to, f) { if (!order) { return f(from, to, "ltr", 0) } var found = false; for (var i = 0; i < order.length; ++i) { var part = order[i]; if (part.from < to && part.to > from || from == to && part.to == from) { f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr", i); found = true; } } if (!found) { f(from, to, "ltr"); } } var bidiOther = null; function getBidiPartAt(order, ch, sticky) { var found; bidiOther = null; for (var i = 0; i < order.length; ++i) { var cur = order[i]; if (cur.from < ch && cur.to > ch) { return i } if (cur.to == ch) { if (cur.from != cur.to && sticky == "before") { found = i; } else { bidiOther = i; } } if (cur.from == ch) { if (cur.from != cur.to && sticky != "before") { found = i; } else { bidiOther = i; } } } return found != null ? found : bidiOther } // Bidirectional ordering algorithm // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm // that this (partially) implements. // One-char codes used for character types: // L (L): Left-to-Right // R (R): Right-to-Left // r (AL): Right-to-Left Arabic // 1 (EN): European Number // + (ES): European Number Separator // % (ET): European Number Terminator // n (AN): Arabic Number // , (CS): Common Number Separator // m (NSM): Non-Spacing Mark // b (BN): Boundary Neutral // s (B): Paragraph Separator // t (S): Segment Separator // w (WS): Whitespace // N (ON): Other Neutrals // Returns null if characters are ordered as they appear // (left-to-right), or an array of sections ({from, to, level} // objects) in the order in which they occur visually. var bidiOrdering = (function() { // Character types for codepoints 0 to 0xff var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN"; // Character types for codepoints 0x600 to 0x6f9 var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111"; function charType(code) { if (code <= 0xf7) { return lowTypes.charAt(code) } else if (0x590 <= code && code <= 0x5f4) { return "R" } else if (0x600 <= code && code <= 0x6f9) { return arabicTypes.charAt(code - 0x600) } else if (0x6ee <= code && code <= 0x8ac) { return "r" } else if (0x2000 <= code && code <= 0x200b) { return "w" } else if (code == 0x200c) { return "b" } else { return "L" } } var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/; function BidiSpan(level, from, to) { this.level = level; this.from = from; this.to = to; } return function(str, direction) { var outerType = direction == "ltr" ? "L" : "R"; if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) { return false } var len = str.length, types = []; for (var i = 0; i < len; ++i) { types.push(charType(str.charCodeAt(i))); } // W1. Examine each non-spacing mark (NSM) in the level run, and // change the type of the NSM to the type of the previous // character. If the NSM is at the start of the level run, it will // get the type of sor. for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) { var type = types[i$1]; if (type == "m") { types[i$1] = prev; } else { prev = type; } } // W2. Search backwards from each instance of a European number // until the first strong type (R, L, AL, or sor) is found. If an // AL is found, change the type of the European number to Arabic // number. // W3. Change all ALs to R. for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) { var type$1 = types[i$2]; if (type$1 == "1" && cur == "r") { types[i$2] = "n"; } else if (isStrong.test(type$1)) { cur = type$1; if (type$1 == "r") { types[i$2] = "R"; } } } // W4. A single European separator between two European numbers // changes to a European number. A single common separator between // two numbers of the same type changes to that type. for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) { var type$2 = types[i$3]; if (type$2 == "+" && prev$1 == "1" && types[i$3+1] == "1") { types[i$3] = "1"; } else if (type$2 == "," && prev$1 == types[i$3+1] && (prev$1 == "1" || prev$1 == "n")) { types[i$3] = prev$1; } prev$1 = type$2; } // W5. A sequence of European terminators adjacent to European // numbers changes to all European numbers. // W6. Otherwise, separators and terminators change to Other // Neutral. for (var i$4 = 0; i$4 < len; ++i$4) { var type$3 = types[i$4]; if (type$3 == ",") { types[i$4] = "N"; } else if (type$3 == "%") { var end = (void 0); for (end = i$4 + 1; end < len && types[end] == "%"; ++end) {} var replace = (i$4 && types[i$4-1] == "!") || (end < len && types[end] == "1") ? "1" : "N"; for (var j = i$4; j < end; ++j) { types[j] = replace; } i$4 = end - 1; } } // W7. Search backwards from each instance of a European number // until the first strong type (R, L, or sor) is found. If an L is // found, then change the type of the European number to L. for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) { var type$4 = types[i$5]; if (cur$1 == "L" && type$4 == "1") { types[i$5] = "L"; } else if (isStrong.test(type$4)) { cur$1 = type$4; } } // N1. A sequence of neutrals takes the direction of the // surrounding strong text if the text on both sides has the same // direction. European and Arabic numbers act as if they were R in // terms of their influence on neutrals. Start-of-level-run (sor) // and end-of-level-run (eor) are used at level run boundaries. // N2. Any remaining neutrals take the embedding direction. for (var i$6 = 0; i$6 < len; ++i$6) { if (isNeutral.test(types[i$6])) { var end$1 = (void 0); for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {} var before = (i$6 ? types[i$6-1] : outerType) == "L"; var after = (end$1 < len ? types[end$1] : outerType) == "L"; var replace$1 = before == after ? (before ? "L" : "R") : outerType; for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1; } i$6 = end$1 - 1; } } // Here we depart from the documented algorithm, in order to avoid // building up an actual levels array. Since there are only three // levels (0, 1, 2) in an implementation that doesn't take // explicit embedding into account, we can build up the order on // the fly, without following the level-based algorithm. var order = [], m; for (var i$7 = 0; i$7 < len;) { if (countsAsLeft.test(types[i$7])) { var start = i$7; for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {} order.push(new BidiSpan(0, start, i$7)); } else { var pos = i$7, at = order.length, isRTL = direction == "rtl" ? 1 : 0; for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {} for (var j$2 = pos; j$2 < i$7;) { if (countsAsNum.test(types[j$2])) { if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); at += isRTL; } var nstart = j$2; for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {} order.splice(at, 0, new BidiSpan(2, nstart, j$2)); at += isRTL; pos = j$2; } else { ++j$2; } } if (pos < i$7) { order.splice(at, 0, new BidiSpan(1, pos, i$7)); } } } if (direction == "ltr") { if (order[0].level == 1 && (m = str.match(/^\s+/))) { order[0].from = m[0].length; order.unshift(new BidiSpan(0, 0, m[0].length)); } if (lst(order).level == 1 && (m = str.match(/\s+$/))) { lst(order).to -= m[0].length; order.push(new BidiSpan(0, len - m[0].length, len)); } } return direction == "rtl" ? order.reverse() : order } })(); // Get the bidi ordering for the given line (and cache it). Returns // false for lines that are fully left-to-right, and an array of // BidiSpan objects otherwise. function getOrder(line, direction) { var order = line.order; if (order == null) { order = line.order = bidiOrdering(line.text, direction); } return order } // EVENT HANDLING // Lightweight event framework. on/off also work on DOM nodes, // registering native DOM handlers. var noHandlers = []; var on = function(emitter, type, f) { if (emitter.addEventListener) { emitter.addEventListener(type, f, false); } else if (emitter.attachEvent) { emitter.attachEvent("on" + type, f); } else { var map = emitter._handlers || (emitter._handlers = {}); map[type] = (map[type] || noHandlers).concat(f); } }; function getHandlers(emitter, type) { return emitter._handlers && emitter._handlers[type] || noHandlers } function off(emitter, type, f) { if (emitter.removeEventListener) { emitter.removeEventListener(type, f, false); } else if (emitter.detachEvent) { emitter.detachEvent("on" + type, f); } else { var map = emitter._handlers, arr = map && map[type]; if (arr) { var index = indexOf(arr, f); if (index > -1) { map[type] = arr.slice(0, index).concat(arr.slice(index + 1)); } } } } function signal(emitter, type /*, values...*/) { var handlers = getHandlers(emitter, type); if (!handlers.length) { return } var args = Array.prototype.slice.call(arguments, 2); for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args); } } // The DOM events that CodeMirror handles can be overridden by // registering a (non-DOM) handler on the editor for the event name, // and preventDefault-ing the event in that handler. function signalDOMEvent(cm, e, override) { if (typeof e == "string") { e = {type: e, preventDefault: function() { this.defaultPrevented = true; }}; } signal(cm, override || e.type, cm, e); return e_defaultPrevented(e) || e.codemirrorIgnore } function signalCursorActivity(cm) { var arr = cm._handlers && cm._handlers.cursorActivity; if (!arr) { return } var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []); for (var i = 0; i < arr.length; ++i) { if (indexOf(set, arr[i]) == -1) { set.push(arr[i]); } } } function hasHandler(emitter, type) { return getHandlers(emitter, type).length > 0 } // Add on and off methods to a constructor's prototype, to make // registering events on such objects more convenient. function eventMixin(ctor) { ctor.prototype.on = function(type, f) {on(this, type, f);}; ctor.prototype.off = function(type, f) {off(this, type, f);}; } // Due to the fact that we still support jurassic IE versions, some // compatibility wrappers are needed. function e_preventDefault(e) { if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } } function e_stopPropagation(e) { if (e.stopPropagation) { e.stopPropagation(); } else { e.cancelBubble = true; } } function e_defaultPrevented(e) { return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false } function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);} function e_target(e) {return e.target || e.srcElement} function e_button(e) { var b = e.which; if (b == null) { if (e.button & 1) { b = 1; } else if (e.button & 2) { b = 3; } else if (e.button & 4) { b = 2; } } if (mac && e.ctrlKey && b == 1) { b = 3; } return b } // Detect drag-and-drop var dragAndDrop = function() { // There is *some* kind of drag-and-drop support in IE6-8, but I // couldn't get it to work yet. if (ie && ie_version < 9) { return false } var div = elt('div'); return "draggable" in div || "dragDrop" in div }(); var zwspSupported; function zeroWidthElement(measure) { if (zwspSupported == null) { var test = elt("span", "\u200b"); removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")])); if (measure.firstChild.offsetHeight != 0) { zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8); } } var node = zwspSupported ? elt("span", "\u200b") : elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px"); node.setAttribute("cm-text", ""); return node } // Feature-detect IE's crummy client rect reporting for bidi text var badBidiRects; function hasBadBidiRects(measure) { if (badBidiRects != null) { return badBidiRects } var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA")); var r0 = range(txt, 0, 1).getBoundingClientRect(); var r1 = range(txt, 1, 2).getBoundingClientRect(); removeChildren(measure); if (!r0 || r0.left == r0.right) { return false } // Safari returns null in some cases (#2780) return badBidiRects = (r1.right - r0.right < 3) } // See if "".split is the broken IE version, if so, provide an // alternative way to split lines. var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function (string) { var pos = 0, result = [], l = string.length; while (pos <= l) { var nl = string.indexOf("\n", pos); if (nl == -1) { nl = string.length; } var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl); var rt = line.indexOf("\r"); if (rt != -1) { result.push(line.slice(0, rt)); pos += rt + 1; } else { result.push(line); pos = nl + 1; } } return result } : function (string) { return string.split(/\r\n?|\n/); }; var hasSelection = window.getSelection ? function (te) { try { return te.selectionStart != te.selectionEnd } catch(e) { return false } } : function (te) { var range; try {range = te.ownerDocument.selection.createRange();} catch(e) {} if (!range || range.parentElement() != te) { return false } return range.compareEndPoints("StartToEnd", range) != 0 }; var hasCopyEvent = (function () { var e = elt("div"); if ("oncopy" in e) { return true } e.setAttribute("oncopy", "return;"); return typeof e.oncopy == "function" })(); var badZoomedRects = null; function hasBadZoomedRects(measure) { if (badZoomedRects != null) { return badZoomedRects } var node = removeChildrenAndAdd(measure, elt("span", "x")); var normal = node.getBoundingClientRect(); var fromRange = range(node, 0, 1).getBoundingClientRect(); return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1 } // Known modes, by name and by MIME var modes = {}, mimeModes = {}; // Extra arguments are stored as the mode's dependencies, which is // used by (legacy) mechanisms like loadmode.js to automatically // load a mode. (Preferred mechanism is the require/define calls.) function defineMode(name, mode) { if (arguments.length > 2) { mode.dependencies = Array.prototype.slice.call(arguments, 2); } modes[name] = mode; } function defineMIME(mime, spec) { mimeModes[mime] = spec; } // Given a MIME type, a {name, ...options} config object, or a name // string, return a mode config object. function resolveMode(spec) { if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) { spec = mimeModes[spec]; } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) { var found = mimeModes[spec.name]; if (typeof found == "string") { found = {name: found}; } spec = createObj(found, spec); spec.name = found.name; } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) { return resolveMode("application/xml") } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) { return resolveMode("application/json") } if (typeof spec == "string") { return {name: spec} } else { return spec || {name: "null"} } } // Given a mode spec (anything that resolveMode accepts), find and // initialize an actual mode object. function getMode(options, spec) { spec = resolveMode(spec); var mfactory = modes[spec.name]; if (!mfactory) { return getMode(options, "text/plain") } var modeObj = mfactory(options, spec); if (modeExtensions.hasOwnProperty(spec.name)) { var exts = modeExtensions[spec.name]; for (var prop in exts) { if (!exts.hasOwnProperty(prop)) { continue } if (modeObj.hasOwnProperty(prop)) { modeObj["_" + prop] = modeObj[prop]; } modeObj[prop] = exts[prop]; } } modeObj.name = spec.name; if (spec.helperType) { modeObj.helperType = spec.helperType; } if (spec.modeProps) { for (var prop$1 in spec.modeProps) { modeObj[prop$1] = spec.modeProps[prop$1]; } } return modeObj } // This can be used to attach properties to mode objects from // outside the actual mode definition. var modeExtensions = {}; function extendMode(mode, properties) { var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {}); copyObj(properties, exts); } function copyState(mode, state) { if (state === true) { return state } if (mode.copyState) { return mode.copyState(state) } var nstate = {}; for (var n in state) { var val = state[n]; if (val instanceof Array) { val = val.concat([]); } nstate[n] = val; } return nstate } // Given a mode and a state (for that mode), find the inner mode and // state at the position that the state refers to. function innerMode(mode, state) { var info; while (mode.innerMode) { info = mode.innerMode(state); if (!info || info.mode == mode) { break } state = info.state; mode = info.mode; } return info || {mode: mode, state: state} } function startState(mode, a1, a2) { return mode.startState ? mode.startState(a1, a2) : true } // STRING STREAM // Fed to the mode parsers, provides helper functions to make // parsers more succinct. var StringStream = function(string, tabSize, lineOracle) { this.pos = this.start = 0; this.string = string; this.tabSize = tabSize || 8; this.lastColumnPos = this.lastColumnValue = 0; this.lineStart = 0; this.lineOracle = lineOracle; }; StringStream.prototype.eol = function () {return this.pos >= this.string.length}; StringStream.prototype.sol = function () {return this.pos == this.lineStart}; StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined}; StringStream.prototype.next = function () { if (this.pos < this.string.length) { return this.string.charAt(this.pos++) } }; StringStream.prototype.eat = function (match) { var ch = this.string.charAt(this.pos); var ok; if (typeof match == "string") { ok = ch == match; } else { ok = ch && (match.test ? match.test(ch) : match(ch)); } if (ok) {++this.pos; return ch} }; StringStream.prototype.eatWhile = function (match) { var start = this.pos; while (this.eat(match)){} return this.pos > start }; StringStream.prototype.eatSpace = function () { var start = this.pos; while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this.pos; } return this.pos > start }; StringStream.prototype.skipToEnd = function () {this.pos = this.string.length;}; StringStream.prototype.skipTo = function (ch) { var found = this.string.indexOf(ch, this.pos); if (found > -1) {this.pos = found; return true} }; StringStream.prototype.backUp = function (n) {this.pos -= n;}; StringStream.prototype.column = function () { if (this.lastColumnPos < this.start) { this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue); this.lastColumnPos = this.start; } return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0) }; StringStream.prototype.indentation = function () { return countColumn(this.string, null, this.tabSize) - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0) }; StringStream.prototype.match = function (pattern, consume, caseInsensitive) { if (typeof pattern == "string") { var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; }; var substr = this.string.substr(this.pos, pattern.length); if (cased(substr) == cased(pattern)) { if (consume !== false) { this.pos += pattern.length; } return true } } else { var match = this.string.slice(this.pos).match(pattern); if (match && match.index > 0) { return null } if (match && consume !== false) { this.pos += match[0].length; } return match } }; StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)}; StringStream.prototype.hideFirstChars = function (n, inner) { this.lineStart += n; try { return inner() } finally { this.lineStart -= n; } }; StringStream.prototype.lookAhead = function (n) { var oracle = this.lineOracle; return oracle && oracle.lookAhead(n) }; StringStream.prototype.baseToken = function () { var oracle = this.lineOracle; return oracle && oracle.baseToken(this.pos) }; // Find the line object corresponding to the given line number. function getLine(doc, n) { n -= doc.first; if (n < 0 || n >= doc.size) { throw new Error("There is no line " + (n + doc.first) + " in the document.") } var chunk = doc; while (!chunk.lines) { for (var i = 0;; ++i) { var child = chunk.children[i], sz = child.chunkSize(); if (n < sz) { chunk = child; break } n -= sz; } } return chunk.lines[n] } // Get the part of a document between two positions, as an array of // strings. function getBetween(doc, start, end) { var out = [], n = start.line; doc.iter(start.line, end.line + 1, function (line) { var text = line.text; if (n == end.line) { text = text.slice(0, end.ch); } if (n == start.line) { text = text.slice(start.ch); } out.push(text); ++n; }); return out } // Get the lines between from and to, as array of strings. function getLines(doc, from, to) { var out = []; doc.iter(from, to, function (line) { out.push(line.text); }); // iter aborts when callback returns truthy value return out } // Update the height of a line, propagating the height change // upwards to parent nodes. function updateLineHeight(line, height) { var diff = height - line.height; if (diff) { for (var n = line; n; n = n.parent) { n.height += diff; } } } // Given a line object, find its line number by walking up through // its parent links. function lineNo(line) { if (line.parent == null) { return null } var cur = line.parent, no = indexOf(cur.lines, line); for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) { for (var i = 0;; ++i) { if (chunk.children[i] == cur) { break } no += chunk.children[i].chunkSize(); } } return no + cur.first } // Find the line at the given vertical position, using the height // information in the document tree. function lineAtHeight(chunk, h) { var n = chunk.first; outer: do { for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) { var child = chunk.children[i$1], ch = child.height; if (h < ch) { chunk = child; continue outer } h -= ch; n += child.chunkSize(); } return n } while (!chunk.lines) var i = 0; for (; i < chunk.lines.length; ++i) { var line = chunk.lines[i], lh = line.height; if (h < lh) { break } h -= lh; } return n + i } function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size} function lineNumberFor(options, i) { return String(options.lineNumberFormatter(i + options.firstLineNumber)) } // A Pos instance represents a position within the text. function Pos(line, ch, sticky) { if ( sticky === void 0 ) sticky = null; if (!(this instanceof Pos)) { return new Pos(line, ch, sticky) } this.line = line; this.ch = ch; this.sticky = sticky; } // Compare two positions, return 0 if they are the same, a negative // number when a is less, and a positive number otherwise. function cmp(a, b) { return a.line - b.line || a.ch - b.ch } function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0 } function copyPos(x) {return Pos(x.line, x.ch)} function maxPos(a, b) { return cmp(a, b) < 0 ? b : a } function minPos(a, b) { return cmp(a, b) < 0 ? a : b } // Most of the external API clips given positions to make sure they // actually exist within the document. function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))} function clipPos(doc, pos) { if (pos.line < doc.first) { return Pos(doc.first, 0) } var last = doc.first + doc.size - 1; if (pos.line > last) { return Pos(last, getLine(doc, last).text.length) } return clipToLen(pos, getLine(doc, pos.line).text.length) } function clipToLen(pos, linelen) { var ch = pos.ch; if (ch == null || ch > linelen) { return Pos(pos.line, linelen) } else if (ch < 0) { return Pos(pos.line, 0) } else { return pos } } function clipPosArray(doc, array) { var out = []; for (var i = 0; i < array.length; i++) { out[i] = clipPos(doc, array[i]); } return out } var SavedContext = function(state, lookAhead) { this.state = state; this.lookAhead = lookAhead; }; var Context = function(doc, state, line, lookAhead) { this.state = state; this.doc = doc; this.line = line; this.maxLookAhead = lookAhead || 0; this.baseTokens = null; this.baseTokenPos = 1; }; Context.prototype.lookAhead = function (n) { var line = this.doc.getLine(this.line + n); if (line != null && n > this.maxLookAhead) { this.maxLookAhead = n; } return line }; Context.prototype.baseToken = function (n) { if (!this.baseTokens) { return null } while (this.baseTokens[this.baseTokenPos] <= n) { this.baseTokenPos += 2; } var type = this.baseTokens[this.baseTokenPos + 1]; return {type: type && type.replace(/( |^)overlay .*/, ""), size: this.baseTokens[this.baseTokenPos] - n} }; Context.prototype.nextLine = function () { this.line++; if (this.maxLookAhead > 0) { this.maxLookAhead--; } }; Context.fromSaved = function (doc, saved, line) { if (saved instanceof SavedContext) { return new Context(doc, copyState(doc.mode, saved.state), line, saved.lookAhead) } else { return new Context(doc, copyState(doc.mode, saved), line) } }; Context.prototype.save = function (copy) { var state = copy !== false ? copyState(this.doc.mode, this.state) : this.state; return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state }; // Compute a style array (an array starting with a mode generation // -- for invalidation -- followed by pairs of end positions and // style strings), which is used to highlight the tokens on the // line. function highlightLine(cm, line, context, forceToEnd) { // A styles array always starts with a number identifying the // mode/overlays that it is based on (for easy invalidation). var st = [cm.state.modeGen], lineClasses = {}; // Compute the base array of styles runMode(cm, line.text, cm.doc.mode, context, function (end, style) { return st.push(end, style); }, lineClasses, forceToEnd); var state = context.state; // Run overlays, adjust style array. var loop = function ( o ) { context.baseTokens = st; var overlay = cm.state.overlays[o], i = 1, at = 0; context.state = true; runMode(cm, line.text, overlay.mode, context, function (end, style) { var start = i; // Ensure there's a token end at the current position, and that i points at it while (at < end) { var i_end = st[i]; if (i_end > end) { st.splice(i, 1, end, st[i+1], i_end); } i += 2; at = Math.min(end, i_end); } if (!style) { return } if (overlay.opaque) { st.splice(start, i - start, end, "overlay " + style); i = start + 2; } else { for (; start < i; start += 2) { var cur = st[start+1]; st[start+1] = (cur ? cur + " " : "") + "overlay " + style; } } }, lineClasses); context.state = state; context.baseTokens = null; context.baseTokenPos = 1; }; for (var o = 0; o < cm.state.overlays.length; ++o) loop( o ); return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null} } function getLineStyles(cm, line, updateFrontier) { if (!line.styles || line.styles[0] != cm.state.modeGen) { var context = getContextBefore(cm, lineNo(line)); var resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state); var result = highlightLine(cm, line, context); if (resetState) { context.state = resetState; } line.stateAfter = context.save(!resetState); line.styles = result.styles; if (result.classes) { line.styleClasses = result.classes; } else if (line.styleClasses) { line.styleClasses = null; } if (updateFrontier === cm.doc.highlightFrontier) { cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier); } } return line.styles } function getContextBefore(cm, n, precise) { var doc = cm.doc, display = cm.display; if (!doc.mode.startState) { return new Context(doc, true, n) } var start = findStartLine(cm, n, precise); var saved = start > doc.first && getLine(doc, start - 1).stateAfter; var context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start); doc.iter(start, n, function (line) { processLine(cm, line.text, context); var pos = context.line; line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null; context.nextLine(); }); if (precise) { doc.modeFrontier = context.line; } return context } // Lightweight form of highlight -- proceed over this line and // update state, but don't save a style array. Used for lines that // aren't currently visible. function processLine(cm, text, context, startAt) { var mode = cm.doc.mode; var stream = new StringStream(text, cm.options.tabSize, context); stream.start = stream.pos = startAt || 0; if (text == "") { callBlankLine(mode, context.state); } while (!stream.eol()) { readToken(mode, stream, context.state); stream.start = stream.pos; } } function callBlankLine(mode, state) { if (mode.blankLine) { return mode.blankLine(state) } if (!mode.innerMode) { return } var inner = innerMode(mode, state); if (inner.mode.blankLine) { return inner.mode.blankLine(inner.state) } } function readToken(mode, stream, state, inner) { for (var i = 0; i < 10; i++) { if (inner) { inner[0] = innerMode(mode, state).mode; } var style = mode.token(stream, state); if (stream.pos > stream.start) { return style } } throw new Error("Mode " + mode.name + " failed to advance stream.") } var Token = function(stream, type, state) { this.start = stream.start; this.end = stream.pos; this.string = stream.current(); this.type = type || null; this.state = state; }; // Utility for getTokenAt and getLineTokens function takeToken(cm, pos, precise, asArray) { var doc = cm.doc, mode = doc.mode, style; pos = clipPos(doc, pos); var line = getLine(doc, pos.line), context = getContextBefore(cm, pos.line, precise); var stream = new StringStream(line.text, cm.options.tabSize, context), tokens; if (asArray) { tokens = []; } while ((asArray || stream.pos < pos.ch) && !stream.eol()) { stream.start = stream.pos; style = readToken(mode, stream, context.state); if (asArray) { tokens.push(new Token(stream, style, copyState(doc.mode, context.state))); } } return asArray ? tokens : new Token(stream, style, context.state) } function extractLineClasses(type, output) { if (type) { for (;;) { var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/); if (!lineClass) { break } type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length); var prop = lineClass[1] ? "bgClass" : "textClass"; if (output[prop] == null) { output[prop] = lineClass[2]; } else if (!(new RegExp("(?:^|\\s)" + lineClass[2] + "(?:$|\\s)")).test(output[prop])) { output[prop] += " " + lineClass[2]; } } } return type } // Run the given mode's parser over a line, calling f for each token. function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) { var flattenSpans = mode.flattenSpans; if (flattenSpans == null) { flattenSpans = cm.options.flattenSpans; } var curStart = 0, curStyle = null; var stream = new StringStream(text, cm.options.tabSize, context), style; var inner = cm.options.addModeClass && [null]; if (text == "") { extractLineClasses(callBlankLine(mode, context.state), lineClasses); } while (!stream.eol()) { if (stream.pos > cm.options.maxHighlightLength) { flattenSpans = false; if (forceToEnd) { processLine(cm, text, context, stream.pos); } stream.pos = text.length; style = null; } else { style = extractLineClasses(readToken(mode, stream, context.state, inner), lineClasses); } if (inner) { var mName = inner[0].name; if (mName) { style = "m-" + (style ? mName + " " + style : mName); } } if (!flattenSpans || curStyle != style) { while (curStart < stream.start) { curStart = Math.min(stream.start, curStart + 5000); f(curStart, curStyle); } curStyle = style; } stream.start = stream.pos; } while (curStart < stream.pos) { // Webkit seems to refuse to render text nodes longer than 57444 // characters, and returns inaccurate measurements in nodes // starting around 5000 chars. var pos = Math.min(stream.pos, curStart + 5000); f(pos, curStyle); curStart = pos; } } // Finds the line to start with when starting a parse. Tries to // find a line with a stateAfter, so that it can start with a // valid state. If that fails, it returns the line with the // smallest indentation, which tends to need the least context to // parse correctly. function findStartLine(cm, n, precise) { var minindent, minline, doc = cm.doc; var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100); for (var search = n; search > lim; --search) { if (search <= doc.first) { return doc.first } var line = getLine(doc, search - 1), after = line.stateAfter; if (after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc.modeFrontier)) { return search } var indented = countColumn(line.text, null, cm.options.tabSize); if (minline == null || minindent > indented) { minline = search - 1; minindent = indented; } } return minline } function retreatFrontier(doc, n) { doc.modeFrontier = Math.min(doc.modeFrontier, n); if (doc.highlightFrontier < n - 10) { return } var start = doc.first; for (var line = n - 1; line > start; line--) { var saved = getLine(doc, line).stateAfter; // change is on 3 // state on line 1 looked ahead 2 -- so saw 3 // test 1 + 2 < 3 should cover this if (saved && (!(saved instanceof SavedContext) || line + saved.lookAhead < n)) { start = line + 1; break } } doc.highlightFrontier = Math.min(doc.highlightFrontier, start); } // Optimize some code when these features are not used. var sawReadOnlySpans = false, sawCollapsedSpans = false; function seeReadOnlySpans() { sawReadOnlySpans = true; } function seeCollapsedSpans() { sawCollapsedSpans = true; } // TEXTMARKER SPANS function MarkedSpan(marker, from, to) { this.marker = marker; this.from = from; this.to = to; } // Search an array of spans for a span matching the given marker. function getMarkedSpanFor(spans, marker) { if (spans) { for (var i = 0; i < spans.length; ++i) { var span = spans[i]; if (span.marker == marker) { return span } } } } // Remove a span from an array, returning undefined if no spans are // left (we don't store arrays for lines without spans). function removeMarkedSpan(spans, span) { var r; for (var i = 0; i < spans.length; ++i) { if (spans[i] != span) { (r || (r = [])).push(spans[i]); } } return r } // Add a span to a line. function addMarkedSpan(line, span) { line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]; span.marker.attachLine(line); } // Used for the algorithm that adjusts markers for a change in the // document. These functions cut an array of spans at a given // character position, returning an array of remaining chunks (or // undefined if nothing remains). function markedSpansBefore(old, startCh, isInsert) { var nw; if (old) { for (var i = 0; i < old.length; ++i) { var span = old[i], marker = span.marker; var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh); if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) { var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh) ;(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to)); } } } return nw } function markedSpansAfter(old, endCh, isInsert) { var nw; if (old) { for (var i = 0; i < old.length; ++i) { var span = old[i], marker = span.marker; var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh); if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) { var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh) ;(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh, span.to == null ? null : span.to - endCh)); } } } return nw } // Given a change object, compute the new set of marker spans that // cover the line in which the change took place. Removes spans // entirely within the change, reconnects spans belonging to the // same marker that appear on both sides of the change, and cuts off // spans partially within the change. Returns an array of span // arrays with one element for each line in (after) the change. function stretchSpansOverChange(doc, change) { if (change.full) { return null } var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans; var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans; if (!oldFirst && !oldLast) { return null } var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0; // Get the spans that 'stick out' on both sides var first = markedSpansBefore(oldFirst, startCh, isInsert); var last = markedSpansAfter(oldLast, endCh, isInsert); // Next, merge those two ends var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0); if (first) { // Fix up .to properties of first for (var i = 0; i < first.length; ++i) { var span = first[i]; if (span.to == null) { var found = getMarkedSpanFor(last, span.marker); if (!found) { span.to = startCh; } else if (sameLine) { span.to = found.to == null ? null : found.to + offset; } } } } if (last) { // Fix up .from in last (or move them into first in case of sameLine) for (var i$1 = 0; i$1 < last.length; ++i$1) { var span$1 = last[i$1]; if (span$1.to != null) { span$1.to += offset; } if (span$1.from == null) { var found$1 = getMarkedSpanFor(first, span$1.marker); if (!found$1) { span$1.from = offset; if (sameLine) { (first || (first = [])).push(span$1); } } } else { span$1.from += offset; if (sameLine) { (first || (first = [])).push(span$1); } } } } // Make sure we didn't create any zero-length spans if (first) { first = clearEmptySpans(first); } if (last && last != first) { last = clearEmptySpans(last); } var newMarkers = [first]; if (!sameLine) { // Fill gap with whole-line-spans var gap = change.text.length - 2, gapMarkers; if (gap > 0 && first) { for (var i$2 = 0; i$2 < first.length; ++i$2) { if (first[i$2].to == null) { (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null)); } } } for (var i$3 = 0; i$3 < gap; ++i$3) { newMarkers.push(gapMarkers); } newMarkers.push(last); } return newMarkers } // Remove spans that are empty and don't have a clearWhenEmpty // option of false. function clearEmptySpans(spans) { for (var i = 0; i < spans.length; ++i) { var span = spans[i]; if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false) { spans.splice(i--, 1); } } if (!spans.length) { return null } return spans } // Used to 'clip' out readOnly ranges when making a change. function removeReadOnlyRanges(doc, from, to) { var markers = null; doc.iter(from.line, to.line + 1, function (line) { if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) { var mark = line.markedSpans[i].marker; if (mark.readOnly && (!markers || indexOf(markers, mark) == -1)) { (markers || (markers = [])).push(mark); } } } }); if (!markers) { return null } var parts = [{from: from, to: to}]; for (var i = 0; i < markers.length; ++i) { var mk = markers[i], m = mk.find(0); for (var j = 0; j < parts.length; ++j) { var p = parts[j]; if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) { continue } var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to); if (dfrom < 0 || !mk.inclusiveLeft && !dfrom) { newParts.push({from: p.from, to: m.from}); } if (dto > 0 || !mk.inclusiveRight && !dto) { newParts.push({from: m.to, to: p.to}); } parts.splice.apply(parts, newParts); j += newParts.length - 3; } } return parts } // Connect or disconnect spans from a line. function detachMarkedSpans(line) { var spans = line.markedSpans; if (!spans) { return } for (var i = 0; i < spans.length; ++i) { spans[i].marker.detachLine(line); } line.markedSpans = null; } function attachMarkedSpans(line, spans) { if (!spans) { return } for (var i = 0; i < spans.length; ++i) { spans[i].marker.attachLine(line); } line.markedSpans = spans; } // Helpers used when computing which overlapping collapsed span // counts as the larger one. function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0 } function extraRight(marker) { return marker.inclusiveRight ? 1 : 0 } // Returns a number indicating which of two overlapping collapsed // spans is larger (and thus includes the other). Falls back to // comparing ids when the spans cover exactly the same range. function compareCollapsedMarkers(a, b) { var lenDiff = a.lines.length - b.lines.length; if (lenDiff != 0) { return lenDiff } var aPos = a.find(), bPos = b.find(); var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b); if (fromCmp) { return -fromCmp } var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b); if (toCmp) { return toCmp } return b.id - a.id } // Find out whether a line ends or starts in a collapsed span. If // so, return the marker for that span. function collapsedSpanAtSide(line, start) { var sps = sawCollapsedSpans && line.markedSpans, found; if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) { sp = sps[i]; if (sp.marker.collapsed && (start ? sp.from : sp.to) == null && (!found || compareCollapsedMarkers(found, sp.marker) < 0)) { found = sp.marker; } } } return found } function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) } function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) } function collapsedSpanAround(line, ch) { var sps = sawCollapsedSpans && line.markedSpans, found; if (sps) { for (var i = 0; i < sps.length; ++i) { var sp = sps[i]; if (sp.marker.collapsed && (sp.from == null || sp.from < ch) && (sp.to == null || sp.to > ch) && (!found || compareCollapsedMarkers(found, sp.marker) < 0)) { found = sp.marker; } } } return found } // Test whether there exists a collapsed span that partially // overlaps (covers the start or end, but not both) of a new span. // Such overlap is not allowed. function conflictingCollapsedRange(doc, lineNo, from, to, marker) { var line = getLine(doc, lineNo); var sps = sawCollapsedSpans && line.markedSpans; if (sps) { for (var i = 0; i < sps.length; ++i) { var sp = sps[i]; if (!sp.marker.collapsed) { continue } var found = sp.marker.find(0); var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker); var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker); if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) { continue } if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) || fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0)) { return true } } } } // A visual line is a line as drawn on the screen. Folding, for // example, can cause multiple logical lines to appear on the same // visual line. This finds the start of the visual line that the // given line is part of (usually that is the line itself). function visualLine(line) { var merged; while (merged = collapsedSpanAtStart(line)) { line = merged.find(-1, true).line; } return line } function visualLineEnd(line) { var merged; while (merged = collapsedSpanAtEnd(line)) { line = merged.find(1, true).line; } return line } // Returns an array of logical lines that continue the visual line // started by the argument, or undefined if there are no such lines. function visualLineContinued(line) { var merged, lines; while (merged = collapsedSpanAtEnd(line)) { line = merged.find(1, true).line ;(lines || (lines = [])).push(line); } return lines } // Get the line number of the start of the visual line that the // given line number is part of. function visualLineNo(doc, lineN) { var line = getLine(doc, lineN), vis = visualLine(line); if (line == vis) { return lineN } return lineNo(vis) } // Get the line number of the start of the next visual line after // the given line. function visualLineEndNo(doc, lineN) { if (lineN > doc.lastLine()) { return lineN } var line = getLine(doc, lineN), merged; if (!lineIsHidden(doc, line)) { return lineN } while (merged = collapsedSpanAtEnd(line)) { line = merged.find(1, true).line; } return lineNo(line) + 1 } // Compute whether a line is hidden. Lines count as hidden when they // are part of a visual line that starts with another line, or when // they are entirely covered by collapsed, non-widget span. function lineIsHidden(doc, line) { var sps = sawCollapsedSpans && line.markedSpans; if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) { sp = sps[i]; if (!sp.marker.collapsed) { continue } if (sp.from == null) { return true } if (sp.marker.widgetNode) { continue } if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp)) { return true } } } } function lineIsHiddenInner(doc, line, span) { if (span.to == null) { var end = span.marker.find(1, true); return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker)) } if (span.marker.inclusiveRight && span.to == line.text.length) { return true } for (var sp = (void 0), i = 0; i < line.markedSpans.length; ++i) { sp = line.markedSpans[i]; if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to && (sp.to == null || sp.to != span.from) && (sp.marker.inclusiveLeft || span.marker.inclusiveRight) && lineIsHiddenInner(doc, line, sp)) { return true } } } // Find the height above the given line. function heightAtLine(lineObj) { lineObj = visualLine(lineObj); var h = 0, chunk = lineObj.parent; for (var i = 0; i < chunk.lines.length; ++i) { var line = chunk.lines[i]; if (line == lineObj) { break } else { h += line.height; } } for (var p = chunk.parent; p; chunk = p, p = chunk.parent) { for (var i$1 = 0; i$1 < p.children.length; ++i$1) { var cur = p.children[i$1]; if (cur == chunk) { break } else { h += cur.height; } } } return h } // Compute the character length of a line, taking into account // collapsed ranges (see markText) that might hide parts, and join // other lines onto it. function lineLength(line) { if (line.height == 0) { return 0 } var len = line.text.length, merged, cur = line; while (merged = collapsedSpanAtStart(cur)) { var found = merged.find(0, true); cur = found.from.line; len += found.from.ch - found.to.ch; } cur = line; while (merged = collapsedSpanAtEnd(cur)) { var found$1 = merged.find(0, true); len -= cur.text.length - found$1.from.ch; cur = found$1.to.line; len += cur.text.length - found$1.to.ch; } return len } // Find the longest line in the document. function findMaxLine(cm) { var d = cm.display, doc = cm.doc; d.maxLine = getLine(doc, doc.first); d.maxLineLength = lineLength(d.maxLine); d.maxLineChanged = true; doc.iter(function (line) { var len = lineLength(line); if (len > d.maxLineLength) { d.maxLineLength = len; d.maxLine = line; } }); } // LINE DATA STRUCTURE // Line objects. These hold state related to a line, including // highlighting info (the styles array). var Line = function(text, markedSpans, estimateHeight) { this.text = text; attachMarkedSpans(this, markedSpans); this.height = estimateHeight ? estimateHeight(this) : 1; }; Line.prototype.lineNo = function () { return lineNo(this) }; eventMixin(Line); // Change the content (text, markers) of a line. Automatically // invalidates cached information and tries to re-estimate the // line's height. function updateLine(line, text, markedSpans, estimateHeight) { line.text = text; if (line.stateAfter) { line.stateAfter = null; } if (line.styles) { line.styles = null; } if (line.order != null) { line.order = null; } detachMarkedSpans(line); attachMarkedSpans(line, markedSpans); var estHeight = estimateHeight ? estimateHeight(line) : 1; if (estHeight != line.height) { updateLineHeight(line, estHeight); } } // Detach a line from the document tree and its markers. function cleanUpLine(line) { line.parent = null; detachMarkedSpans(line); } // Convert a style as returned by a mode (either null, or a string // containing one or more styles) to a CSS style. This is cached, // and also looks for line-wide styles. var styleToClassCache = {}, styleToClassCacheWithMode = {}; function interpretTokenStyle(style, options) { if (!style || /^\s*$/.test(style)) { return null } var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache; return cache[style] || (cache[style] = style.replace(/\S+/g, "cm-$&")) } // Render the DOM representation of the text of a line. Also builds // up a 'line map', which points at the DOM nodes that represent // specific stretches of text, and is used by the measuring code. // The returned object contains the DOM node, this map, and // information about line-wide styles that were set by the mode. function buildLineContent(cm, lineView) { // The padding-right forces the element to have a 'border', which // is needed on Webkit to be able to get line-level bounding // rectangles for it (in measureChar). var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null); var builder = {pre: eltP("pre", [content], "CodeMirror-line"), content: content, col: 0, pos: 0, cm: cm, trailingSpace: false, splitSpaces: cm.getOption("lineWrapping")}; lineView.measure = {}; // Iterate over the logical lines that make up this visual line. for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) { var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0); builder.pos = 0; builder.addToken = buildToken; // Optionally wire in some hacks into the token-rendering // algorithm, to deal with browser quirks. if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction))) { builder.addToken = buildTokenBadBidi(builder.addToken, order); } builder.map = []; var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line); insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate)); if (line.styleClasses) { if (line.styleClasses.bgClass) { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); } if (line.styleClasses.textClass) { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); } } // Ensure at least a single node is present, for measuring. if (builder.map.length == 0) { builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); } // Store the map and a cache object for the current logical line if (i == 0) { lineView.measure.map = builder.map; lineView.measure.cache = {}; } else { (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map) ;(lineView.measure.caches || (lineView.measure.caches = [])).push({}); } } // See issue #2901 if (webkit) { var last = builder.content.lastChild; if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab"))) { builder.content.className = "cm-tab-wrap-hack"; } } signal(cm, "renderLine", cm, lineView.line, builder.pre); if (builder.pre.className) { builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); } return builder } function defaultSpecialCharPlaceholder(ch) { var token = elt("span", "\u2022", "cm-invalidchar"); token.title = "\\u" + ch.charCodeAt(0).toString(16); token.setAttribute("aria-label", token.title); return token } // Build up the DOM representation for a single token, and add it to // the line map. Takes care to render special characters separately. function buildToken(builder, text, style, startStyle, endStyle, css, attributes) { if (!text) { return } var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text; var special = builder.cm.state.specialChars, mustWrap = false; var content; if (!special.test(text)) { builder.col += text.length; content = document.createTextNode(displayText); builder.map.push(builder.pos, builder.pos + text.length, content); if (ie && ie_version < 9) { mustWrap = true; } builder.pos += text.length; } else { content = document.createDocumentFragment(); var pos = 0; while (true) { special.lastIndex = pos; var m = special.exec(text); var skipped = m ? m.index - pos : text.length - pos; if (skipped) { var txt = document.createTextNode(displayText.slice(pos, pos + skipped)); if (ie && ie_version < 9) { content.appendChild(elt("span", [txt])); } else { content.appendChild(txt); } builder.map.push(builder.pos, builder.pos + skipped, txt); builder.col += skipped; builder.pos += skipped; } if (!m) { break } pos += skipped + 1; var txt$1 = (void 0); if (m[0] == "\t") { var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize; txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab")); txt$1.setAttribute("role", "presentation"); txt$1.setAttribute("cm-text", "\t"); builder.col += tabWidth; } else if (m[0] == "\r" || m[0] == "\n") { txt$1 = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar")); txt$1.setAttribute("cm-text", m[0]); builder.col += 1; } else { txt$1 = builder.cm.options.specialCharPlaceholder(m[0]); txt$1.setAttribute("cm-text", m[0]); if (ie && ie_version < 9) { content.appendChild(elt("span", [txt$1])); } else { content.appendChild(txt$1); } builder.col += 1; } builder.map.push(builder.pos, builder.pos + 1, txt$1); builder.pos++; } } builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32; if (style || startStyle || endStyle || mustWrap || css) { var fullStyle = style || ""; if (startStyle) { fullStyle += startStyle; } if (endStyle) { fullStyle += endStyle; } var token = elt("span", [content], fullStyle, css); if (attributes) { for (var attr in attributes) { if (attributes.hasOwnProperty(attr) && attr != "style" && attr != "class") { token.setAttribute(attr, attributes[attr]); } } } return builder.content.appendChild(token) } builder.content.appendChild(content); } // Change some spaces to NBSP to prevent the browser from collapsing // trailing spaces at the end of a line when rendering text (issue #1362). function splitSpaces(text, trailingBefore) { if (text.length > 1 && !/ /.test(text)) { return text } var spaceBefore = trailingBefore, result = ""; for (var i = 0; i < text.length; i++) { var ch = text.charAt(i); if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32)) { ch = "\u00a0"; } result += ch; spaceBefore = ch == " "; } return result } // Work around nonsense dimensions being reported for stretches of // right-to-left text. function buildTokenBadBidi(inner, order) { return function (builder, text, style, startStyle, endStyle, css, attributes) { style = style ? style + " cm-force-border" : "cm-force-border"; var start = builder.pos, end = start + text.length; for (;;) { // Find the part that overlaps with the start of this text var part = (void 0); for (var i = 0; i < order.length; i++) { part = order[i]; if (part.to > start && part.from <= start) { break } } if (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, css, attributes) } inner(builder, text.slice(0, part.to - start), style, startStyle, null, css, attributes); startStyle = null; text = text.slice(part.to - start); start = part.to; } } } function buildCollapsedSpan(builder, size, marker, ignoreWidget) { var widget = !ignoreWidget && marker.widgetNode; if (widget) { builder.map.push(builder.pos, builder.pos + size, widget); } if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) { if (!widget) { widget = builder.content.appendChild(document.createElement("span")); } widget.setAttribute("cm-marker", marker.id); } if (widget) { builder.cm.display.input.setUneditable(widget); builder.content.appendChild(widget); } builder.pos += size; builder.trailingSpace = false; } // Outputs a number of spans to make up a line, taking highlighting // and marked text into account. function insertLineContent(line, builder, styles) { var spans = line.markedSpans, allText = line.text, at = 0; if (!spans) { for (var i$1 = 1; i$1 < styles.length; i$1+=2) { builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)); } return } var len = allText.length, pos = 0, i = 1, text = "", style, css; var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, collapsed, attributes; for (;;) { if (nextChange == pos) { // Update current marker set spanStyle = spanEndStyle = spanStartStyle = css = ""; attributes = null; collapsed = null; nextChange = Infinity; var foundBookmarks = [], endStyles = (void 0); for (var j = 0; j < spans.length; ++j) { var sp = spans[j], m = sp.marker; if (m.type == "bookmark" && sp.from == pos && m.widgetNode) { foundBookmarks.push(m); } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) { if (sp.to != null && sp.to != pos && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; } if (m.className) { spanStyle += " " + m.className; } if (m.css) { css = (css ? css + ";" : "") + m.css; } if (m.startStyle && sp.from == pos) { spanStartStyle += " " + m.startStyle; } if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to); } // support for the old title property // https://github.com/codemirror/CodeMirror/pull/5673 if (m.title) { (attributes || (attributes = {})).title = m.title; } if (m.attributes) { for (var attr in m.attributes) { (attributes || (attributes = {}))[attr] = m.attributes[attr]; } } if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0)) { collapsed = sp; } } else if (sp.from > pos && nextChange > sp.from) { nextChange = sp.from; } } if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2) { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += " " + endStyles[j$1]; } } } if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2) { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]); } } if (collapsed && (collapsed.from || 0) == pos) { buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, collapsed.marker, collapsed.from == null); if (collapsed.to == null) { return } if (collapsed.to == pos) { collapsed = false; } } } if (pos >= len) { break } var upto = Math.min(len, nextChange); while (true) { if (text) { var end = pos + text.length; if (!collapsed) { var tokenText = end > upto ? text.slice(0, upto - pos) : text; builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle, spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", css, attributes); } if (end >= upto) {text = text.slice(upto - pos); pos = upto; break} pos = end; spanStartStyle = ""; } text = allText.slice(at, at = styles[i++]); style = interpretTokenStyle(styles[i++], builder.cm.options); } } } // These objects are used to represent the visible (currently drawn) // part of the document. A LineView may correspond to multiple // logical lines, if those are connected by collapsed ranges. function LineView(doc, line, lineN) { // The starting line this.line = line; // Continuing lines, if any this.rest = visualLineContinued(line); // Number of logical lines in this visual line this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1; this.node = this.text = null; this.hidden = lineIsHidden(doc, line); } // Create a range of LineView objects for the given lines. function buildViewArray(cm, from, to) { var array = [], nextPos; for (var pos = from; pos < to; pos = nextPos) { var view = new LineView(cm.doc, getLine(cm.doc, pos), pos); nextPos = pos + view.size; array.push(view); } return array } var operationGroup = null; function pushOperation(op) { if (operationGroup) { operationGroup.ops.push(op); } else { op.ownsGroup = operationGroup = { ops: [op], delayedCallbacks: [] }; } } function fireCallbacksForOps(group) { // Calls delayed callbacks and cursorActivity handlers until no // new ones appear var callbacks = group.delayedCallbacks, i = 0; do { for (; i < callbacks.length; i++) { callbacks[i].call(null); } for (var j = 0; j < group.ops.length; j++) { var op = group.ops[j]; if (op.cursorActivityHandlers) { while (op.cursorActivityCalled < op.cursorActivityHandlers.length) { op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm); } } } } while (i < callbacks.length) } function finishOperation(op, endCb) { var group = op.ownsGroup; if (!group) { return } try { fireCallbacksForOps(group); } finally { operationGroup = null; endCb(group); } } var orphanDelayedCallbacks = null; // Often, we want to signal events at a point where we are in the // middle of some work, but don't want the handler to start calling // other methods on the editor, which might be in an inconsistent // state or simply not expect any other events to happen. // signalLater looks whether there are any handlers, and schedules // them to be executed when the last operation ends, or, if no // operation is active, when a timeout fires. function signalLater(emitter, type /*, values...*/) { var arr = getHandlers(emitter, type); if (!arr.length) { return } var args = Array.prototype.slice.call(arguments, 2), list; if (operationGroup) { list = operationGroup.delayedCallbacks; } else if (orphanDelayedCallbacks) { list = orphanDelayedCallbacks; } else { list = orphanDelayedCallbacks = []; setTimeout(fireOrphanDelayed, 0); } var loop = function ( i ) { list.push(function () { return arr[i].apply(null, args); }); }; for (var i = 0; i < arr.length; ++i) loop( i ); } function fireOrphanDelayed() { var delayed = orphanDelayedCallbacks; orphanDelayedCallbacks = null; for (var i = 0; i < delayed.length; ++i) { delayed[i](); } } // When an aspect of a line changes, a string is added to // lineView.changes. This updates the relevant part of the line's // DOM structure. function updateLineForChanges(cm, lineView, lineN, dims) { for (var j = 0; j < lineView.changes.length; j++) { var type = lineView.changes[j]; if (type == "text") { updateLineText(cm, lineView); } else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims); } else if (type == "class") { updateLineClasses(cm, lineView); } else if (type == "widget") { updateLineWidgets(cm, lineView, dims); } } lineView.changes = null; } // Lines with gutter elements, widgets or a background class need to // be wrapped, and have the extra elements added to the wrapper div function ensureLineWrapped(lineView) { if (lineView.node == lineView.text) { lineView.node = elt("div", null, null, "position: relative"); if (lineView.text.parentNode) { lineView.text.parentNode.replaceChild(lineView.node, lineView.text); } lineView.node.appendChild(lineView.text); if (ie && ie_version < 8) { lineView.node.style.zIndex = 2; } } return lineView.node } function updateLineBackground(cm, lineView) { var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass; if (cls) { cls += " CodeMirror-linebackground"; } if (lineView.background) { if (cls) { lineView.background.className = cls; } else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; } } else if (cls) { var wrap = ensureLineWrapped(lineView); lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild); cm.display.input.setUneditable(lineView.background); } } // Wrapper around buildLineContent which will reuse the structure // in display.externalMeasured when possible. function getLineContent(cm, lineView) { var ext = cm.display.externalMeasured; if (ext && ext.line == lineView.line) { cm.display.externalMeasured = null; lineView.measure = ext.measure; return ext.built } return buildLineContent(cm, lineView) } // Redraw the line's text. Interacts with the background and text // classes because the mode may output tokens that influence these // classes. function updateLineText(cm, lineView) { var cls = lineView.text.className; var built = getLineContent(cm, lineView); if (lineView.text == lineView.node) { lineView.node = built.pre; } lineView.text.parentNode.replaceChild(built.pre, lineView.text); lineView.text = built.pre; if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) { lineView.bgClass = built.bgClass; lineView.textClass = built.textClass; updateLineClasses(cm, lineView); } else if (cls) { lineView.text.className = cls; } } function updateLineClasses(cm, lineView) { updateLineBackground(cm, lineView); if (lineView.line.wrapClass) { ensureLineWrapped(lineView).className = lineView.line.wrapClass; } else if (lineView.node != lineView.text) { lineView.node.className = ""; } var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass; lineView.text.className = textClass || ""; } function updateLineGutter(cm, lineView, lineN, dims) { if (lineView.gutter) { lineView.node.removeChild(lineView.gutter); lineView.gutter = null; } if (lineView.gutterBackground) { lineView.node.removeChild(lineView.gutterBackground); lineView.gutterBackground = null; } if (lineView.line.gutterClass) { var wrap = ensureLineWrapped(lineView); lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass, ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + (dims.gutterTotalWidth) + "px")); cm.display.input.setUneditable(lineView.gutterBackground); wrap.insertBefore(lineView.gutterBackground, lineView.text); } var markers = lineView.line.gutterMarkers; if (cm.options.lineNumbers || markers) { var wrap$1 = ensureLineWrapped(lineView); var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px")); cm.display.input.setUneditable(gutterWrap); wrap$1.insertBefore(gutterWrap, lineView.text); if (lineView.line.gutterClass) { gutterWrap.className += " " + lineView.line.gutterClass; } if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"])) { lineView.lineNumber = gutterWrap.appendChild( elt("div", lineNumberFor(cm.options, lineN), "CodeMirror-linenumber CodeMirror-gutter-elt", ("left: " + (dims.gutterLeft["CodeMirror-linenumbers"]) + "px; width: " + (cm.display.lineNumInnerWidth) + "px"))); } if (markers) { for (var k = 0; k < cm.display.gutterSpecs.length; ++k) { var id = cm.display.gutterSpecs[k].className, found = markers.hasOwnProperty(id) && markers[id]; if (found) { gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", ("left: " + (dims.gutterLeft[id]) + "px; width: " + (dims.gutterWidth[id]) + "px"))); } } } } } function updateLineWidgets(cm, lineView, dims) { if (lineView.alignable) { lineView.alignable = null; } var isWidget = classTest("CodeMirror-linewidget"); for (var node = lineView.node.firstChild, next = (void 0); node; node = next) { next = node.nextSibling; if (isWidget.test(node.className)) { lineView.node.removeChild(node); } } insertLineWidgets(cm, lineView, dims); } // Build a line's DOM representation from scratch function buildLineElement(cm, lineView, lineN, dims) { var built = getLineContent(cm, lineView); lineView.text = lineView.node = built.pre; if (built.bgClass) { lineView.bgClass = built.bgClass; } if (built.textClass) { lineView.textClass = built.textClass; } updateLineClasses(cm, lineView); updateLineGutter(cm, lineView, lineN, dims); insertLineWidgets(cm, lineView, dims); return lineView.node } // A lineView may contain multiple logical lines (when merged by // collapsed spans). The widgets for all of them need to be drawn. function insertLineWidgets(cm, lineView, dims) { insertLineWidgetsFor(cm, lineView.line, lineView, dims, true); if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++) { insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false); } } } function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) { if (!line.widgets) { return } var wrap = ensureLineWrapped(lineView); for (var i = 0, ws = line.widgets; i < ws.length; ++i) { var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget" + (widget.className ? " " + widget.className : "")); if (!widget.handleMouseEvents) { node.setAttribute("cm-ignore-events", "true"); } positionLineWidget(widget, node, lineView, dims); cm.display.input.setUneditable(node); if (allowAbove && widget.above) { wrap.insertBefore(node, lineView.gutter || lineView.text); } else { wrap.appendChild(node); } signalLater(widget, "redraw"); } } function positionLineWidget(widget, node, lineView, dims) { if (widget.noHScroll) { (lineView.alignable || (lineView.alignable = [])).push(node); var width = dims.wrapperWidth; node.style.left = dims.fixedPos + "px"; if (!widget.coverGutter) { width -= dims.gutterTotalWidth; node.style.paddingLeft = dims.gutterTotalWidth + "px"; } node.style.width = width + "px"; } if (widget.coverGutter) { node.style.zIndex = 5; node.style.position = "relative"; if (!widget.noHScroll) { node.style.marginLeft = -dims.gutterTotalWidth + "px"; } } } function widgetHeight(widget) { if (widget.height != null) { return widget.height } var cm = widget.doc.cm; if (!cm) { return 0 } if (!contains(document.body, widget.node)) { var parentStyle = "position: relative;"; if (widget.coverGutter) { parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"; } if (widget.noHScroll) { parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"; } removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle)); } return widget.height = widget.node.parentNode.offsetHeight } // Return true when the given mouse event happened in a widget function eventInWidget(display, e) { for (var n = e_target(e); n != display.wrapper; n = n.parentNode) { if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") || (n.parentNode == display.sizer && n != display.mover)) { return true } } } // POSITION MEASUREMENT function paddingTop(display) {return display.lineSpace.offsetTop} function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight} function paddingH(display) { if (display.cachedPaddingH) { return display.cachedPaddingH } var e = removeChildrenAndAdd(display.measure, elt("pre", "x", "CodeMirror-line-like")); var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle; var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)}; if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data; } return data } function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth } function displayWidth(cm) { return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth } function displayHeight(cm) { return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight } // Ensure the lineView.wrapping.heights array is populated. This is // an array of bottom offsets for the lines that make up a drawn // line. When lineWrapping is on, there might be more than one // height. function ensureLineHeights(cm, lineView, rect) { var wrapping = cm.options.lineWrapping; var curWidth = wrapping && displayWidth(cm); if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) { var heights = lineView.measure.heights = []; if (wrapping) { lineView.measure.width = curWidth; var rects = lineView.text.firstChild.getClientRects(); for (var i = 0; i < rects.length - 1; i++) { var cur = rects[i], next = rects[i + 1]; if (Math.abs(cur.bottom - next.bottom) > 2) { heights.push((cur.bottom + next.top) / 2 - rect.top); } } } heights.push(rect.bottom - rect.top); } } // Find a line map (mapping character offsets to text nodes) and a // measurement cache for the given line number. (A line view might // contain multiple lines when collapsed ranges are present.) function mapFromLineView(lineView, line, lineN) { if (lineView.line == line) { return {map: lineView.measure.map, cache: lineView.measure.cache} } for (var i = 0; i < lineView.rest.length; i++) { if (lineView.rest[i] == line) { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } } for (var i$1 = 0; i$1 < lineView.rest.length; i$1++) { if (lineNo(lineView.rest[i$1]) > lineN) { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } } } // Render a line into the hidden node display.externalMeasured. Used // when measurement is needed for a line that's not in the viewport. function updateExternalMeasurement(cm, line) { line = visualLine(line); var lineN = lineNo(line); var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN); view.lineN = lineN; var built = view.built = buildLineContent(cm, view); view.text = built.pre; removeChildrenAndAdd(cm.display.lineMeasure, built.pre); return view } // Get a {top, bottom, left, right} box (in line-local coordinates) // for a given character. function measureChar(cm, line, ch, bias) { return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias) } // Find a line view that corresponds to the given line number. function findViewForLine(cm, lineN) { if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo) { return cm.display.view[findViewIndex(cm, lineN)] } var ext = cm.display.externalMeasured; if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size) { return ext } } // Measurement can be split in two steps, the set-up work that // applies to the whole line, and the measurement of the actual // character. Functions like coordsChar, that need to do a lot of // measurements in a row, can thus ensure that the set-up work is // only done once. function prepareMeasureForLine(cm, line) { var lineN = lineNo(line); var view = findViewForLine(cm, lineN); if (view && !view.text) { view = null; } else if (view && view.changes) { updateLineForChanges(cm, view, lineN, getDimensions(cm)); cm.curOp.forceUpdate = true; } if (!view) { view = updateExternalMeasurement(cm, line); } var info = mapFromLineView(view, line, lineN); return { line: line, view: view, rect: null, map: info.map, cache: info.cache, before: info.before, hasHeights: false } } // Given a prepared measurement object, measures the position of an // actual character (or fetches it from the cache). function measureCharPrepared(cm, prepared, ch, bias, varHeight) { if (prepared.before) { ch = -1; } var key = ch + (bias || ""), found; if (prepared.cache.hasOwnProperty(key)) { found = prepared.cache[key]; } else { if (!prepared.rect) { prepared.rect = prepared.view.text.getBoundingClientRect(); } if (!prepared.hasHeights) { ensureLineHeights(cm, prepared.view, prepared.rect); prepared.hasHeights = true; } found = measureCharInner(cm, prepared, ch, bias); if (!found.bogus) { prepared.cache[key] = found; } } return {left: found.left, right: found.right, top: varHeight ? found.rtop : found.top, bottom: varHeight ? found.rbottom : found.bottom} } var nullRect = {left: 0, right: 0, top: 0, bottom: 0}; function nodeAndOffsetInLineMap(map, ch, bias) { var node, start, end, collapse, mStart, mEnd; // First, search the line map for the text node corresponding to, // or closest to, the target character. for (var i = 0; i < map.length; i += 3) { mStart = map[i]; mEnd = map[i + 1]; if (ch < mStart) { start = 0; end = 1; collapse = "left"; } else if (ch < mEnd) { start = ch - mStart; end = start + 1; } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) { end = mEnd - mStart; start = end - 1; if (ch >= mEnd) { collapse = "right"; } } if (start != null) { node = map[i + 2]; if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right")) { collapse = bias; } if (bias == "left" && start == 0) { while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) { node = map[(i -= 3) + 2]; collapse = "left"; } } if (bias == "right" && start == mEnd - mStart) { while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) { node = map[(i += 3) + 2]; collapse = "right"; } } break } } return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd} } function getUsefulRect(rects, bias) { var rect = nullRect; if (bias == "left") { for (var i = 0; i < rects.length; i++) { if ((rect = rects[i]).left != rect.right) { break } } } else { for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) { if ((rect = rects[i$1]).left != rect.right) { break } } } return rect } function measureCharInner(cm, prepared, ch, bias) { var place = nodeAndOffsetInLineMap(prepared.map, ch, bias); var node = place.node, start = place.start, end = place.end, collapse = place.collapse; var rect; if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates. for (var i$1 = 0; i$1 < 4; i$1++) { // Retry a maximum of 4 times when nonsense rectangles are returned while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) { --start; } while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) { ++end; } if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) { rect = node.parentNode.getBoundingClientRect(); } else { rect = getUsefulRect(range(node, start, end).getClientRects(), bias); } if (rect.left || rect.right || start == 0) { break } end = start; start = start - 1; collapse = "right"; } if (ie && ie_version < 11) { rect = maybeUpdateRectForZooming(cm.display.measure, rect); } } else { // If it is a widget, simply get the box for the whole widget. if (start > 0) { collapse = bias = "right"; } var rects; if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1) { rect = rects[bias == "right" ? rects.length - 1 : 0]; } else { rect = node.getBoundingClientRect(); } } if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) { var rSpan = node.parentNode.getClientRects()[0]; if (rSpan) { rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom}; } else { rect = nullRect; } } var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top; var mid = (rtop + rbot) / 2; var heights = prepared.view.measure.heights; var i = 0; for (; i < heights.length - 1; i++) { if (mid < heights[i]) { break } } var top = i ? heights[i - 1] : 0, bot = heights[i]; var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left, right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left, top: top, bottom: bot}; if (!rect.left && !rect.right) { result.bogus = true; } if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; } return result } // Work around problem with bounding client rects on ranges being // returned incorrectly when zoomed on IE10 and below. function maybeUpdateRectForZooming(measure, rect) { if (!window.screen || screen.logicalXDPI == null || screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure)) { return rect } var scaleX = screen.logicalXDPI / screen.deviceXDPI; var scaleY = screen.logicalYDPI / screen.deviceYDPI; return {left: rect.left * scaleX, right: rect.right * scaleX, top: rect.top * scaleY, bottom: rect.bottom * scaleY} } function clearLineMeasurementCacheFor(lineView) { if (lineView.measure) { lineView.measure.cache = {}; lineView.measure.heights = null; if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++) { lineView.measure.caches[i] = {}; } } } } function clearLineMeasurementCache(cm) { cm.display.externalMeasure = null; removeChildren(cm.display.lineMeasure); for (var i = 0; i < cm.display.view.length; i++) { clearLineMeasurementCacheFor(cm.display.view[i]); } } function clearCaches(cm) { clearLineMeasurementCache(cm); cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null; if (!cm.options.lineWrapping) { cm.display.maxLineChanged = true; } cm.display.lineNumChars = null; } function pageScrollX() { // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206 // which causes page_Offset and bounding client rects to use // different reference viewports and invalidate our calculations. if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) } return window.pageXOffset || (document.documentElement || document.body).scrollLeft } function pageScrollY() { if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) } return window.pageYOffset || (document.documentElement || document.body).scrollTop } function widgetTopHeight(lineObj) { var height = 0; if (lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above) { height += widgetHeight(lineObj.widgets[i]); } } } return height } // Converts a {top, bottom, left, right} box from line-local // coordinates into another coordinate system. Context may be one of // "line", "div" (display.lineDiv), "local"./null (editor), "window", // or "page". function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) { if (!includeWidgets) { var height = widgetTopHeight(lineObj); rect.top += height; rect.bottom += height; } if (context == "line") { return rect } if (!context) { context = "local"; } var yOff = heightAtLine(lineObj); if (context == "local") { yOff += paddingTop(cm.display); } else { yOff -= cm.display.viewOffset; } if (context == "page" || context == "window") { var lOff = cm.display.lineSpace.getBoundingClientRect(); yOff += lOff.top + (context == "window" ? 0 : pageScrollY()); var xOff = lOff.left + (context == "window" ? 0 : pageScrollX()); rect.left += xOff; rect.right += xOff; } rect.top += yOff; rect.bottom += yOff; return rect } // Coverts a box from "div" coords to another coordinate system. // Context may be "window", "page", "div", or "local"./null. function fromCoordSystem(cm, coords, context) { if (context == "div") { return coords } var left = coords.left, top = coords.top; // First move into "page" coordinate system if (context == "page") { left -= pageScrollX(); top -= pageScrollY(); } else if (context == "local" || !context) { var localBox = cm.display.sizer.getBoundingClientRect(); left += localBox.left; top += localBox.top; } var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect(); return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top} } function charCoords(cm, pos, context, lineObj, bias) { if (!lineObj) { lineObj = getLine(cm.doc, pos.line); } return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context) } // Returns a box for a given cursor position, which may have an // 'other' property containing the position of the secondary cursor // on a bidi boundary. // A cursor Pos(line, char, "before") is on the same visual line as `char - 1` // and after `char - 1` in writing order of `char - 1` // A cursor Pos(line, char, "after") is on the same visual line as `char` // and before `char` in writing order of `char` // Examples (upper-case letters are RTL, lower-case are LTR): // Pos(0, 1, ...) // before after // ab a|b a|b // aB a|B aB| // Ab |Ab A|b // AB B|A B|A // Every position after the last character on a line is considered to stick // to the last character on the line. function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) { lineObj = lineObj || getLine(cm.doc, pos.line); if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); } function get(ch, right) { var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight); if (right) { m.left = m.right; } else { m.right = m.left; } return intoCoordSystem(cm, lineObj, m, context) } var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky; if (ch >= lineObj.text.length) { ch = lineObj.text.length; sticky = "before"; } else if (ch <= 0) { ch = 0; sticky = "after"; } if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") } function getBidi(ch, partPos, invert) { var part = order[partPos], right = part.level == 1; return get(invert ? ch - 1 : ch, right != invert) } var partPos = getBidiPartAt(order, ch, sticky); var other = bidiOther; var val = getBidi(ch, partPos, sticky == "before"); if (other != null) { val.other = getBidi(ch, other, sticky != "before"); } return val } // Used to cheaply estimate the coordinates for a position. Used for // intermediate scroll updates. function estimateCoords(cm, pos) { var left = 0; pos = clipPos(cm.doc, pos); if (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch; } var lineObj = getLine(cm.doc, pos.line); var top = heightAtLine(lineObj) + paddingTop(cm.display); return {left: left, right: left, top: top, bottom: top + lineObj.height} } // Positions returned by coordsChar contain some extra information. // xRel is the relative x position of the input coordinates compared // to the found position (so xRel > 0 means the coordinates are to // the right of the character position, for example). When outside // is true, that means the coordinates lie outside the line's // vertical range. function PosWithInfo(line, ch, sticky, outside, xRel) { var pos = Pos(line, ch, sticky); pos.xRel = xRel; if (outside) { pos.outside = outside; } return pos } // Compute the character position closest to the given coordinates. // Input must be lineSpace-local ("div" coordinate system). function coordsChar(cm, x, y) { var doc = cm.doc; y += cm.display.viewOffset; if (y < 0) { return PosWithInfo(doc.first, 0, null, -1, -1) } var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1; if (lineN > last) { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, 1, 1) } if (x < 0) { x = 0; } var lineObj = getLine(doc, lineN); for (;;) { var found = coordsCharInner(cm, lineObj, lineN, x, y); var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 || found.outside > 0 ? 1 : 0)); if (!collapsed) { return found } var rangeEnd = collapsed.find(1); if (rangeEnd.line == lineN) { return rangeEnd } lineObj = getLine(doc, lineN = rangeEnd.line); } } function wrappedLineExtent(cm, lineObj, preparedMeasure, y) { y -= widgetTopHeight(lineObj); var end = lineObj.text.length; var begin = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch - 1).bottom <= y; }, end, 0); end = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch).top > y; }, begin, end); return {begin: begin, end: end} } function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) { if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); } var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top; return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop) } // Returns true if the given side of a box is after the given // coordinates, in top-to-bottom, left-to-right order. function boxIsAfter(box, x, y, left) { return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x } function coordsCharInner(cm, lineObj, lineNo, x, y) { // Move y into line-local coordinate space y -= heightAtLine(lineObj); var preparedMeasure = prepareMeasureForLine(cm, lineObj); // When directly calling `measureCharPrepared`, we have to adjust // for the widgets at this line. var widgetHeight = widgetTopHeight(lineObj); var begin = 0, end = lineObj.text.length, ltr = true; var order = getOrder(lineObj, cm.doc.direction); // If the line isn't plain left-to-right text, first figure out // which bidi section the coordinates fall into. if (order) { var part = (cm.options.lineWrapping ? coordsBidiPartWrapped : coordsBidiPart) (cm, lineObj, lineNo, preparedMeasure, order, x, y); ltr = part.level != 1; // The awkward -1 offsets are needed because findFirst (called // on these below) will treat its first bound as inclusive, // second as exclusive, but we want to actually address the // characters in the part's range begin = ltr ? part.from : part.to - 1; end = ltr ? part.to : part.from - 1; } // A binary search to find the first character whose bounding box // starts after the coordinates. If we run across any whose box wrap // the coordinates, store that. var chAround = null, boxAround = null; var ch = findFirst(function (ch) { var box = measureCharPrepared(cm, preparedMeasure, ch); box.top += widgetHeight; box.bottom += widgetHeight; if (!boxIsAfter(box, x, y, false)) { return false } if (box.top <= y && box.left <= x) { chAround = ch; boxAround = box; } return true }, begin, end); var baseX, sticky, outside = false; // If a box around the coordinates was found, use that if (boxAround) { // Distinguish coordinates nearer to the left or right side of the box var atLeft = x - boxAround.left < boxAround.right - x, atStart = atLeft == ltr; ch = chAround + (atStart ? 0 : 1); sticky = atStart ? "after" : "before"; baseX = atLeft ? boxAround.left : boxAround.right; } else { // (Adjust for extended bound, if necessary.) if (!ltr && (ch == end || ch == begin)) { ch++; } // To determine which side to associate with, get the box to the // left of the character and compare it's vertical position to the // coordinates sticky = ch == 0 ? "after" : ch == lineObj.text.length ? "before" : (measureCharPrepared(cm, preparedMeasure, ch - (ltr ? 1 : 0)).bottom + widgetHeight <= y) == ltr ? "after" : "before"; // Now get accurate coordinates for this place, in order to get a // base X position var coords = cursorCoords(cm, Pos(lineNo, ch, sticky), "line", lineObj, preparedMeasure); baseX = coords.left; outside = y < coords.top ? -1 : y >= coords.bottom ? 1 : 0; } ch = skipExtendingChars(lineObj.text, ch, 1); return PosWithInfo(lineNo, ch, sticky, outside, x - baseX) } function coordsBidiPart(cm, lineObj, lineNo, preparedMeasure, order, x, y) { // Bidi parts are sorted left-to-right, and in a non-line-wrapping // situation, we can take this ordering to correspond to the visual // ordering. This finds the first part whose end is after the given // coordinates. var index = findFirst(function (i) { var part = order[i], ltr = part.level != 1; return boxIsAfter(cursorCoords(cm, Pos(lineNo, ltr ? part.to : part.from, ltr ? "before" : "after"), "line", lineObj, preparedMeasure), x, y, true) }, 0, order.length - 1); var part = order[index]; // If this isn't the first part, the part's start is also after // the coordinates, and the coordinates aren't on the same line as // that start, move one part back. if (index > 0) { var ltr = part.level != 1; var start = cursorCoords(cm, Pos(lineNo, ltr ? part.from : part.to, ltr ? "after" : "before"), "line", lineObj, preparedMeasure); if (boxIsAfter(start, x, y, true) && start.top > y) { part = order[index - 1]; } } return part } function coordsBidiPartWrapped(cm, lineObj, _lineNo, preparedMeasure, order, x, y) { // In a wrapped line, rtl text on wrapping boundaries can do things // that don't correspond to the ordering in our `order` array at // all, so a binary search doesn't work, and we want to return a // part that only spans one line so that the binary search in // coordsCharInner is safe. As such, we first find the extent of the // wrapped line, and then do a flat search in which we discard any // spans that aren't on the line. var ref = wrappedLineExtent(cm, lineObj, preparedMeasure, y); var begin = ref.begin; var end = ref.end; if (/\s/.test(lineObj.text.charAt(end - 1))) { end--; } var part = null, closestDist = null; for (var i = 0; i < order.length; i++) { var p = order[i]; if (p.from >= end || p.to <= begin) { continue } var ltr = p.level != 1; var endX = measureCharPrepared(cm, preparedMeasure, ltr ? Math.min(end, p.to) - 1 : Math.max(begin, p.from)).right; // Weigh against spans ending before this, so that they are only // picked if nothing ends after var dist = endX < x ? x - endX + 1e9 : endX - x; if (!part || closestDist > dist) { part = p; closestDist = dist; } } if (!part) { part = order[order.length - 1]; } // Clip the part to the wrapped line. if (part.from < begin) { part = {from: begin, to: part.to, level: part.level}; } if (part.to > end) { part = {from: part.from, to: end, level: part.level}; } return part } var measureText; // Compute the default text height. function textHeight(display) { if (display.cachedTextHeight != null) { return display.cachedTextHeight } if (measureText == null) { measureText = elt("pre", null, "CodeMirror-line-like"); // Measure a bunch of lines, for browsers that compute // fractional heights. for (var i = 0; i < 49; ++i) { measureText.appendChild(document.createTextNode("x")); measureText.appendChild(elt("br")); } measureText.appendChild(document.createTextNode("x")); } removeChildrenAndAdd(display.measure, measureText); var height = measureText.offsetHeight / 50; if (height > 3) { display.cachedTextHeight = height; } removeChildren(display.measure); return height || 1 } // Compute the default character width. function charWidth(display) { if (display.cachedCharWidth != null) { return display.cachedCharWidth } var anchor = elt("span", "xxxxxxxxxx"); var pre = elt("pre", [anchor], "CodeMirror-line-like"); removeChildrenAndAdd(display.measure, pre); var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10; if (width > 2) { display.cachedCharWidth = width; } return width || 10 } // Do a bulk-read of the DOM positions and sizes needed to draw the // view, so that we don't interleave reading and writing to the DOM. function getDimensions(cm) { var d = cm.display, left = {}, width = {}; var gutterLeft = d.gutters.clientLeft; for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) { var id = cm.display.gutterSpecs[i].className; left[id] = n.offsetLeft + n.clientLeft + gutterLeft; width[id] = n.clientWidth; } return {fixedPos: compensateForHScroll(d), gutterTotalWidth: d.gutters.offsetWidth, gutterLeft: left, gutterWidth: width, wrapperWidth: d.wrapper.clientWidth} } // Computes display.scroller.scrollLeft + display.gutters.offsetWidth, // but using getBoundingClientRect to get a sub-pixel-accurate // result. function compensateForHScroll(display) { return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left } // Returns a function that estimates the height of a line, to use as // first approximation until the line becomes visible (and is thus // properly measurable). function estimateHeight(cm) { var th = textHeight(cm.display), wrapping = cm.options.lineWrapping; var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3); return function (line) { if (lineIsHidden(cm.doc, line)) { return 0 } var widgetsHeight = 0; if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) { if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height; } } } if (wrapping) { return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th } else { return widgetsHeight + th } } } function estimateLineHeights(cm) { var doc = cm.doc, est = estimateHeight(cm); doc.iter(function (line) { var estHeight = est(line); if (estHeight != line.height) { updateLineHeight(line, estHeight); } }); } // Given a mouse event, find the corresponding position. If liberal // is false, it checks whether a gutter or scrollbar was clicked, // and returns null if it was. forRect is used by rectangular // selections, and tries to estimate a character position even for // coordinates beyond the right of the text. function posFromMouse(cm, e, liberal, forRect) { var display = cm.display; if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { return null } var x, y, space = display.lineSpace.getBoundingClientRect(); // Fails unpredictably on IE[67] when mouse is dragged around quickly. try { x = e.clientX - space.left; y = e.clientY - space.top; } catch (e$1) { return null } var coords = coordsChar(cm, x, y), line; if (forRect && coords.xRel > 0 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); } return coords } // Find the view element corresponding to a given line. Return null // when the line isn't visible. function findViewIndex(cm, n) { if (n >= cm.display.viewTo) { return null } n -= cm.display.viewFrom; if (n < 0) { return null } var view = cm.display.view; for (var i = 0; i < view.length; i++) { n -= view[i].size; if (n < 0) { return i } } } // Updates the display.view data structure for a given change to the // document. From and to are in pre-change coordinates. Lendiff is // the amount of lines added or subtracted by the change. This is // used for changes that span multiple lines, or change the way // lines are divided into visual lines. regLineChange (below) // registers single-line changes. function regChange(cm, from, to, lendiff) { if (from == null) { from = cm.doc.first; } if (to == null) { to = cm.doc.first + cm.doc.size; } if (!lendiff) { lendiff = 0; } var display = cm.display; if (lendiff && to < display.viewTo && (display.updateLineNumbers == null || display.updateLineNumbers > from)) { display.updateLineNumbers = from; } cm.curOp.viewChanged = true; if (from >= display.viewTo) { // Change after if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo) { resetView(cm); } } else if (to <= display.viewFrom) { // Change before if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) { resetView(cm); } else { display.viewFrom += lendiff; display.viewTo += lendiff; } } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap resetView(cm); } else if (from <= display.viewFrom) { // Top overlap var cut = viewCuttingPoint(cm, to, to + lendiff, 1); if (cut) { display.view = display.view.slice(cut.index); display.viewFrom = cut.lineN; display.viewTo += lendiff; } else { resetView(cm); } } else if (to >= display.viewTo) { // Bottom overlap var cut$1 = viewCuttingPoint(cm, from, from, -1); if (cut$1) { display.view = display.view.slice(0, cut$1.index); display.viewTo = cut$1.lineN; } else { resetView(cm); } } else { // Gap in the middle var cutTop = viewCuttingPoint(cm, from, from, -1); var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1); if (cutTop && cutBot) { display.view = display.view.slice(0, cutTop.index) .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN)) .concat(display.view.slice(cutBot.index)); display.viewTo += lendiff; } else { resetView(cm); } } var ext = display.externalMeasured; if (ext) { if (to < ext.lineN) { ext.lineN += lendiff; } else if (from < ext.lineN + ext.size) { display.externalMeasured = null; } } } // Register a change to a single line. Type must be one of "text", // "gutter", "class", "widget" function regLineChange(cm, line, type) { cm.curOp.viewChanged = true; var display = cm.display, ext = cm.display.externalMeasured; if (ext && line >= ext.lineN && line < ext.lineN + ext.size) { display.externalMeasured = null; } if (line < display.viewFrom || line >= display.viewTo) { return } var lineView = display.view[findViewIndex(cm, line)]; if (lineView.node == null) { return } var arr = lineView.changes || (lineView.changes = []); if (indexOf(arr, type) == -1) { arr.push(type); } } // Clear the view. function resetView(cm) { cm.display.viewFrom = cm.display.viewTo = cm.doc.first; cm.display.view = []; cm.display.viewOffset = 0; } function viewCuttingPoint(cm, oldN, newN, dir) { var index = findViewIndex(cm, oldN), diff, view = cm.display.view; if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size) { return {index: index, lineN: newN} } var n = cm.display.viewFrom; for (var i = 0; i < index; i++) { n += view[i].size; } if (n != oldN) { if (dir > 0) { if (index == view.length - 1) { return null } diff = (n + view[index].size) - oldN; index++; } else { diff = n - oldN; } oldN += diff; newN += diff; } while (visualLineNo(cm.doc, newN) != newN) { if (index == (dir < 0 ? 0 : view.length - 1)) { return null } newN += dir * view[index - (dir < 0 ? 1 : 0)].size; index += dir; } return {index: index, lineN: newN} } // Force the view to cover a given range, adding empty view element // or clipping off existing ones as needed. function adjustView(cm, from, to) { var display = cm.display, view = display.view; if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) { display.view = buildViewArray(cm, from, to); display.viewFrom = from; } else { if (display.viewFrom > from) { display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); } else if (display.viewFrom < from) { display.view = display.view.slice(findViewIndex(cm, from)); } display.viewFrom = from; if (display.viewTo < to) { display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); } else if (display.viewTo > to) { display.view = display.view.slice(0, findViewIndex(cm, to)); } } display.viewTo = to; } // Count the number of lines in the view whose DOM representation is // out of date (or nonexistent). function countDirtyView(cm) { var view = cm.display.view, dirty = 0; for (var i = 0; i < view.length; i++) { var lineView = view[i]; if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty; } } return dirty } function updateSelection(cm) { cm.display.input.showSelection(cm.display.input.prepareSelection()); } function prepareSelection(cm, primary) { if ( primary === void 0 ) primary = true; var doc = cm.doc, result = {}; var curFragment = result.cursors = document.createDocumentFragment(); var selFragment = result.selection = document.createDocumentFragment(); for (var i = 0; i < doc.sel.ranges.length; i++) { if (!primary && i == doc.sel.primIndex) { continue } var range = doc.sel.ranges[i]; if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) { continue } var collapsed = range.empty(); if (collapsed || cm.options.showCursorWhenSelecting) { drawSelectionCursor(cm, range.head, curFragment); } if (!collapsed) { drawSelectionRange(cm, range, selFragment); } } return result } // Draws a cursor for the given range function drawSelectionCursor(cm, head, output) { var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine); var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor")); cursor.style.left = pos.left + "px"; cursor.style.top = pos.top + "px"; cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"; if (pos.other) { // Secondary cursor, shown when on a 'jump' in bi-directional text var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor")); otherCursor.style.display = ""; otherCursor.style.left = pos.other.left + "px"; otherCursor.style.top = pos.other.top + "px"; otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px"; } } function cmpCoords(a, b) { return a.top - b.top || a.left - b.left } // Draws the given range as a highlighted selection function drawSelectionRange(cm, range, output) { var display = cm.display, doc = cm.doc; var fragment = document.createDocumentFragment(); var padding = paddingH(cm.display), leftSide = padding.left; var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right; var docLTR = doc.direction == "ltr"; function add(left, top, width, bottom) { if (top < 0) { top = 0; } top = Math.round(top); bottom = Math.round(bottom); fragment.appendChild(elt("div", null, "CodeMirror-selected", ("position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (width == null ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px"))); } function drawForLine(line, fromArg, toArg) { var lineObj = getLine(doc, line); var lineLen = lineObj.text.length; var start, end; function coords(ch, bias) { return charCoords(cm, Pos(line, ch), "div", lineObj, bias) } function wrapX(pos, dir, side) { var extent = wrappedLineExtentChar(cm, lineObj, null, pos); var prop = (dir == "ltr") == (side == "after") ? "left" : "right"; var ch = side == "after" ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1); return coords(ch, prop)[prop] } var order = getOrder(lineObj, doc.direction); iterateBidiSections(order, fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir, i) { var ltr = dir == "ltr"; var fromPos = coords(from, ltr ? "left" : "right"); var toPos = coords(to - 1, ltr ? "right" : "left"); var openStart = fromArg == null && from == 0, openEnd = toArg == null && to == lineLen; var first = i == 0, last = !order || i == order.length - 1; if (toPos.top - fromPos.top <= 3) { // Single line var openLeft = (docLTR ? openStart : openEnd) && first; var openRight = (docLTR ? openEnd : openStart) && last; var left = openLeft ? leftSide : (ltr ? fromPos : toPos).left; var right = openRight ? rightSide : (ltr ? toPos : fromPos).right; add(left, fromPos.top, right - left, fromPos.bottom); } else { // Multiple lines var topLeft, topRight, botLeft, botRight; if (ltr) { topLeft = docLTR && openStart && first ? leftSide : fromPos.left; topRight = docLTR ? rightSide : wrapX(from, dir, "before"); botLeft = docLTR ? leftSide : wrapX(to, dir, "after"); botRight = docLTR && openEnd && last ? rightSide : toPos.right; } else { topLeft = !docLTR ? leftSide : wrapX(from, dir, "before"); topRight = !docLTR && openStart && first ? rightSide : fromPos.right; botLeft = !docLTR && openEnd && last ? leftSide : toPos.left; botRight = !docLTR ? rightSide : wrapX(to, dir, "after"); } add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom); if (fromPos.bottom < toPos.top) { add(leftSide, fromPos.bottom, null, toPos.top); } add(botLeft, toPos.top, botRight - botLeft, toPos.bottom); } if (!start || cmpCoords(fromPos, start) < 0) { start = fromPos; } if (cmpCoords(toPos, start) < 0) { start = toPos; } if (!end || cmpCoords(fromPos, end) < 0) { end = fromPos; } if (cmpCoords(toPos, end) < 0) { end = toPos; } }); return {start: start, end: end} } var sFrom = range.from(), sTo = range.to(); if (sFrom.line == sTo.line) { drawForLine(sFrom.line, sFrom.ch, sTo.ch); } else { var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line); var singleVLine = visualLine(fromLine) == visualLine(toLine); var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end; var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start; if (singleVLine) { if (leftEnd.top < rightStart.top - 2) { add(leftEnd.right, leftEnd.top, null, leftEnd.bottom); add(leftSide, rightStart.top, rightStart.left, rightStart.bottom); } else { add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom); } } if (leftEnd.bottom < rightStart.top) { add(leftSide, leftEnd.bottom, null, rightStart.top); } } output.appendChild(fragment); } // Cursor-blinking function restartBlink(cm) { if (!cm.state.focused) { return } var display = cm.display; clearInterval(display.blinker); var on = true; display.cursorDiv.style.visibility = ""; if (cm.options.cursorBlinkRate > 0) { display.blinker = setInterval(function () { return display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; }, cm.options.cursorBlinkRate); } else if (cm.options.cursorBlinkRate < 0) { display.cursorDiv.style.visibility = "hidden"; } } function ensureFocus(cm) { if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); } } function delayBlurEvent(cm) { cm.state.delayingBlurEvent = true; setTimeout(function () { if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; onBlur(cm); } }, 100); } function onFocus(cm, e) { if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; } if (cm.options.readOnly == "nocursor") { return } if (!cm.state.focused) { signal(cm, "focus", cm, e); cm.state.focused = true; addClass(cm.display.wrapper, "CodeMirror-focused"); // This test prevents this from firing when a context // menu is closed (since the input reset would kill the // select-all detection hack) if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) { cm.display.input.reset(); if (webkit) { setTimeout(function () { return cm.display.input.reset(true); }, 20); } // Issue #1730 } cm.display.input.receivedFocus(); } restartBlink(cm); } function onBlur(cm, e) { if (cm.state.delayingBlurEvent) { return } if (cm.state.focused) { signal(cm, "blur", cm, e); cm.state.focused = false; rmClass(cm.display.wrapper, "CodeMirror-focused"); } clearInterval(cm.display.blinker); setTimeout(function () { if (!cm.state.focused) { cm.display.shift = false; } }, 150); } // Read the actual heights of the rendered lines, and update their // stored heights to match. function updateHeightsInViewport(cm) { var display = cm.display; var prevBottom = display.lineDiv.offsetTop; for (var i = 0; i < display.view.length; i++) { var cur = display.view[i], wrapping = cm.options.lineWrapping; var height = (void 0), width = 0; if (cur.hidden) { continue } if (ie && ie_version < 8) { var bot = cur.node.offsetTop + cur.node.offsetHeight; height = bot - prevBottom; prevBottom = bot; } else { var box = cur.node.getBoundingClientRect(); height = box.bottom - box.top; // Check that lines don't extend past the right of the current // editor width if (!wrapping && cur.text.firstChild) { width = cur.text.firstChild.getBoundingClientRect().right - box.left - 1; } } var diff = cur.line.height - height; if (diff > .005 || diff < -.005) { updateLineHeight(cur.line, height); updateWidgetHeight(cur.line); if (cur.rest) { for (var j = 0; j < cur.rest.length; j++) { updateWidgetHeight(cur.rest[j]); } } } if (width > cm.display.sizerWidth) { var chWidth = Math.ceil(width / charWidth(cm.display)); if (chWidth > cm.display.maxLineLength) { cm.display.maxLineLength = chWidth; cm.display.maxLine = cur.line; cm.display.maxLineChanged = true; } } } } // Read and store the height of line widgets associated with the // given line. function updateWidgetHeight(line) { if (line.widgets) { for (var i = 0; i < line.widgets.length; ++i) { var w = line.widgets[i], parent = w.node.parentNode; if (parent) { w.height = parent.offsetHeight; } } } } // Compute the lines that are visible in a given viewport (defaults // the the current scroll position). viewport may contain top, // height, and ensure (see op.scrollToPos) properties. function visibleLines(display, doc, viewport) { var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop; top = Math.floor(top - paddingTop(display)); var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight; var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom); // Ensure is a {from: {line, ch}, to: {line, ch}} object, and // forces those lines into the viewport (if possible). if (viewport && viewport.ensure) { var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line; if (ensureFrom < from) { from = ensureFrom; to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight); } else if (Math.min(ensureTo, doc.lastLine()) >= to) { from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight); to = ensureTo; } } return {from: from, to: Math.max(to, from + 1)} } // SCROLLING THINGS INTO VIEW // If an editor sits on the top or bottom of the window, partially // scrolled out of view, this ensures that the cursor is visible. function maybeScrollWindow(cm, rect) { if (signalDOMEvent(cm, "scrollCursorIntoView")) { return } var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; if (rect.top + box.top < 0) { doScroll = true; } else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; } if (doScroll != null && !phantom) { var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;")); cm.display.lineSpace.appendChild(scrollNode); scrollNode.scrollIntoView(doScroll); cm.display.lineSpace.removeChild(scrollNode); } } // Scroll a given position into view (immediately), verifying that // it actually became visible (as line heights are accurately // measured, the position of something may 'drift' during drawing). function scrollPosIntoView(cm, pos, end, margin) { if (margin == null) { margin = 0; } var rect; if (!cm.options.lineWrapping && pos == end) { // Set pos and end to the cursor positions around the character pos sticks to // If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch // If pos == Pos(_, 0, "before"), pos and end are unchanged pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos; end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos; } for (var limit = 0; limit < 5; limit++) { var changed = false; var coords = cursorCoords(cm, pos); var endCoords = !end || end == pos ? coords : cursorCoords(cm, end); rect = {left: Math.min(coords.left, endCoords.left), top: Math.min(coords.top, endCoords.top) - margin, right: Math.max(coords.left, endCoords.left), bottom: Math.max(coords.bottom, endCoords.bottom) + margin}; var scrollPos = calculateScrollPos(cm, rect); var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft; if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); if (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true; } } if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true; } } if (!changed) { break } } return rect } // Scroll a given set of coordinates into view (immediately). function scrollIntoView(cm, rect) { var scrollPos = calculateScrollPos(cm, rect); if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); } if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); } } // Calculate a new scroll position needed to scroll the given // rectangle into view. Returns an object with scrollTop and // scrollLeft properties. When these are undefined, the // vertical/horizontal position does not need to be adjusted. function calculateScrollPos(cm, rect) { var display = cm.display, snapMargin = textHeight(cm.display); if (rect.top < 0) { rect.top = 0; } var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop; var screen = displayHeight(cm), result = {}; if (rect.bottom - rect.top > screen) { rect.bottom = rect.top + screen; } var docBottom = cm.doc.height + paddingVert(display); var atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin; if (rect.top < screentop) { result.scrollTop = atTop ? 0 : rect.top; } else if (rect.bottom > screentop + screen) { var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen); if (newTop != screentop) { result.scrollTop = newTop; } } var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft; var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0); var tooWide = rect.right - rect.left > screenw; if (tooWide) { rect.right = rect.left + screenw; } if (rect.left < 10) { result.scrollLeft = 0; } else if (rect.left < screenleft) { result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)); } else if (rect.right > screenw + screenleft - 3) { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; } return result } // Store a relative adjustment to the scroll position in the current // operation (to be applied when the operation finishes). function addToScrollTop(cm, top) { if (top == null) { return } resolveScrollToPos(cm); cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top; } // Make sure that at the end of the operation the current cursor is // shown. function ensureCursorVisible(cm) { resolveScrollToPos(cm); var cur = cm.getCursor(); cm.curOp.scrollToPos = {from: cur, to: cur, margin: cm.options.cursorScrollMargin}; } function scrollToCoords(cm, x, y) { if (x != null || y != null) { resolveScrollToPos(cm); } if (x != null) { cm.curOp.scrollLeft = x; } if (y != null) { cm.curOp.scrollTop = y; } } function scrollToRange(cm, range) { resolveScrollToPos(cm); cm.curOp.scrollToPos = range; } // When an operation has its scrollToPos property set, and another // scroll action is applied before the end of the operation, this // 'simulates' scrolling that position into view in a cheap way, so // that the effect of intermediate scroll commands is not ignored. function resolveScrollToPos(cm) { var range = cm.curOp.scrollToPos; if (range) { cm.curOp.scrollToPos = null; var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to); scrollToCoordsRange(cm, from, to, range.margin); } } function scrollToCoordsRange(cm, from, to, margin) { var sPos = calculateScrollPos(cm, { left: Math.min(from.left, to.left), top: Math.min(from.top, to.top) - margin, right: Math.max(from.right, to.right), bottom: Math.max(from.bottom, to.bottom) + margin }); scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop); } // Sync the scrollable area and scrollbars, ensure the viewport // covers the visible area. function updateScrollTop(cm, val) { if (Math.abs(cm.doc.scrollTop - val) < 2) { return } if (!gecko) { updateDisplaySimple(cm, {top: val}); } setScrollTop(cm, val, true); if (gecko) { updateDisplaySimple(cm); } startWorker(cm, 100); } function setScrollTop(cm, val, forceScroll) { val = Math.max(0, Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val)); if (cm.display.scroller.scrollTop == val && !forceScroll) { return } cm.doc.scrollTop = val; cm.display.scrollbars.setScrollTop(val); if (cm.display.scroller.scrollTop != val) { cm.display.scroller.scrollTop = val; } } // Sync scroller and scrollbar, ensure the gutter elements are // aligned. function setScrollLeft(cm, val, isScroller, forceScroll) { val = Math.max(0, Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth)); if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) { return } cm.doc.scrollLeft = val; alignHorizontally(cm); if (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val; } cm.display.scrollbars.setScrollLeft(val); } // SCROLLBARS // Prepare DOM reads needed to update the scrollbars. Done in one // shot to minimize update/measure roundtrips. function measureForScrollbars(cm) { var d = cm.display, gutterW = d.gutters.offsetWidth; var docH = Math.round(cm.doc.height + paddingVert(cm.display)); return { clientHeight: d.scroller.clientHeight, viewHeight: d.wrapper.clientHeight, scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth, viewWidth: d.wrapper.clientWidth, barLeft: cm.options.fixedGutter ? gutterW : 0, docHeight: docH, scrollHeight: docH + scrollGap(cm) + d.barHeight, nativeBarWidth: d.nativeBarWidth, gutterWidth: gutterW } } var NativeScrollbars = function(place, scroll, cm) { this.cm = cm; var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar"); var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar"); vert.tabIndex = horiz.tabIndex = -1; place(vert); place(horiz); on(vert, "scroll", function () { if (vert.clientHeight) { scroll(vert.scrollTop, "vertical"); } }); on(horiz, "scroll", function () { if (horiz.clientWidth) { scroll(horiz.scrollLeft, "horizontal"); } }); this.checkedZeroWidth = false; // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8). if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = "18px"; } }; NativeScrollbars.prototype.update = function (measure) { var needsH = measure.scrollWidth > measure.clientWidth + 1; var needsV = measure.scrollHeight > measure.clientHeight + 1; var sWidth = measure.nativeBarWidth; if (needsV) { this.vert.style.display = "block"; this.vert.style.bottom = needsH ? sWidth + "px" : "0"; var totalHeight = measure.viewHeight - (needsH ? sWidth : 0); // A bug in IE8 can cause this value to be negative, so guard it. this.vert.firstChild.style.height = Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px"; } else { this.vert.style.display = ""; this.vert.firstChild.style.height = "0"; } if (needsH) { this.horiz.style.display = "block"; this.horiz.style.right = needsV ? sWidth + "px" : "0"; this.horiz.style.left = measure.barLeft + "px"; var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0); this.horiz.firstChild.style.width = Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px"; } else { this.horiz.style.display = ""; this.horiz.firstChild.style.width = "0"; } if (!this.checkedZeroWidth && measure.clientHeight > 0) { if (sWidth == 0) { this.zeroWidthHack(); } this.checkedZeroWidth = true; } return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0} }; NativeScrollbars.prototype.setScrollLeft = function (pos) { if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos; } if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz"); } }; NativeScrollbars.prototype.setScrollTop = function (pos) { if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos; } if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert, "vert"); } }; NativeScrollbars.prototype.zeroWidthHack = function () { var w = mac && !mac_geMountainLion ? "12px" : "18px"; this.horiz.style.height = this.vert.style.width = w; this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none"; this.disableHoriz = new Delayed; this.disableVert = new Delayed; }; NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) { bar.style.pointerEvents = "auto"; function maybeDisable() { // To find out whether the scrollbar is still visible, we // check whether the element under the pixel in the bottom // right corner of the scrollbar box is the scrollbar box // itself (when the bar is still visible) or its filler child // (when the bar is hidden). If it is still visible, we keep // it enabled, if it's hidden, we disable pointer events. var box = bar.getBoundingClientRect(); var elt = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2) : document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1); if (elt != bar) { bar.style.pointerEvents = "none"; } else { delay.set(1000, maybeDisable); } } delay.set(1000, maybeDisable); }; NativeScrollbars.prototype.clear = function () { var parent = this.horiz.parentNode; parent.removeChild(this.horiz); parent.removeChild(this.vert); }; var NullScrollbars = function () {}; NullScrollbars.prototype.update = function () { return {bottom: 0, right: 0} }; NullScrollbars.prototype.setScrollLeft = function () {}; NullScrollbars.prototype.setScrollTop = function () {}; NullScrollbars.prototype.clear = function () {}; function updateScrollbars(cm, measure) { if (!measure) { measure = measureForScrollbars(cm); } var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight; updateScrollbarsInner(cm, measure); for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) { if (startWidth != cm.display.barWidth && cm.options.lineWrapping) { updateHeightsInViewport(cm); } updateScrollbarsInner(cm, measureForScrollbars(cm)); startWidth = cm.display.barWidth; startHeight = cm.display.barHeight; } } // Re-synchronize the fake scrollbars with the actual size of the // content. function updateScrollbarsInner(cm, measure) { var d = cm.display; var sizes = d.scrollbars.update(measure); d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px"; d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px"; d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"; if (sizes.right && sizes.bottom) { d.scrollbarFiller.style.display = "block"; d.scrollbarFiller.style.height = sizes.bottom + "px"; d.scrollbarFiller.style.width = sizes.right + "px"; } else { d.scrollbarFiller.style.display = ""; } if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) { d.gutterFiller.style.display = "block"; d.gutterFiller.style.height = sizes.bottom + "px"; d.gutterFiller.style.width = measure.gutterWidth + "px"; } else { d.gutterFiller.style.display = ""; } } var scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars}; function initScrollbars(cm) { if (cm.display.scrollbars) { cm.display.scrollbars.clear(); if (cm.display.scrollbars.addClass) { rmClass(cm.display.wrapper, cm.display.scrollbars.addClass); } } cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function (node) { cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller); // Prevent clicks in the scrollbars from killing focus on(node, "mousedown", function () { if (cm.state.focused) { setTimeout(function () { return cm.display.input.focus(); }, 0); } }); node.setAttribute("cm-not-content", "true"); }, function (pos, axis) { if (axis == "horizontal") { setScrollLeft(cm, pos); } else { updateScrollTop(cm, pos); } }, cm); if (cm.display.scrollbars.addClass) { addClass(cm.display.wrapper, cm.display.scrollbars.addClass); } } // Operations are used to wrap a series of changes to the editor // state in such a way that each change won't have to update the // cursor and display (which would be awkward, slow, and // error-prone). Instead, display updates are batched and then all // combined and executed at once. var nextOpId = 0; // Start a new operation. function startOperation(cm) { cm.curOp = { cm: cm, viewChanged: false, // Flag that indicates that lines might need to be redrawn startHeight: cm.doc.height, // Used to detect need to update scrollbar forceUpdate: false, // Used to force a redraw updateInput: 0, // Whether to reset the input textarea typing: false, // Whether this reset should be careful to leave existing text (for compositing) changeObjs: null, // Accumulated changes, for firing change events cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already selectionChanged: false, // Whether the selection needs to be redrawn updateMaxLine: false, // Set when the widest line needs to be determined anew scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet scrollToPos: null, // Used to scroll to a specific position focus: false, id: ++nextOpId // Unique ID }; pushOperation(cm.curOp); } // Finish an operation, updating the display and signalling delayed events function endOperation(cm) { var op = cm.curOp; if (op) { finishOperation(op, function (group) { for (var i = 0; i < group.ops.length; i++) { group.ops[i].cm.curOp = null; } endOperations(group); }); } } // The DOM updates done when an operation finishes are batched so // that the minimum number of relayouts are required. function endOperations(group) { var ops = group.ops; for (var i = 0; i < ops.length; i++) // Read DOM { endOperation_R1(ops[i]); } for (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe) { endOperation_W1(ops[i$1]); } for (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM { endOperation_R2(ops[i$2]); } for (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe) { endOperation_W2(ops[i$3]); } for (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM { endOperation_finish(ops[i$4]); } } function endOperation_R1(op) { var cm = op.cm, display = cm.display; maybeClipScrollbars(cm); if (op.updateMaxLine) { findMaxLine(cm); } op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null || op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom || op.scrollToPos.to.line >= display.viewTo) || display.maxLineChanged && cm.options.lineWrapping; op.update = op.mustUpdate && new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate); } function endOperation_W1(op) { op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update); } function endOperation_R2(op) { var cm = op.cm, display = cm.display; if (op.updatedDisplay) { updateHeightsInViewport(cm); } op.barMeasure = measureForScrollbars(cm); // If the max line changed since it was last measured, measure it, // and ensure the document's width matches it. // updateDisplay_W2 will use these properties to do the actual resizing if (display.maxLineChanged && !cm.options.lineWrapping) { op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3; cm.display.sizerWidth = op.adjustWidthTo; op.barMeasure.scrollWidth = Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth); op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm)); } if (op.updatedDisplay || op.selectionChanged) { op.preparedSelection = display.input.prepareSelection(); } } function endOperation_W2(op) { var cm = op.cm; if (op.adjustWidthTo != null) { cm.display.sizer.style.minWidth = op.adjustWidthTo + "px"; if (op.maxScrollLeft < cm.doc.scrollLeft) { setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true); } cm.display.maxLineChanged = false; } var takeFocus = op.focus && op.focus == activeElt(); if (op.preparedSelection) { cm.display.input.showSelection(op.preparedSelection, takeFocus); } if (op.updatedDisplay || op.startHeight != cm.doc.height) { updateScrollbars(cm, op.barMeasure); } if (op.updatedDisplay) { setDocumentHeight(cm, op.barMeasure); } if (op.selectionChanged) { restartBlink(cm); } if (cm.state.focused && op.updateInput) { cm.display.input.reset(op.typing); } if (takeFocus) { ensureFocus(op.cm); } } function endOperation_finish(op) { var cm = op.cm, display = cm.display, doc = cm.doc; if (op.updatedDisplay) { postUpdateDisplay(cm, op.update); } // Abort mouse wheel delta measurement, when scrolling explicitly if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos)) { display.wheelStartX = display.wheelStartY = null; } // Propagate the scroll position to the actual DOM scroller if (op.scrollTop != null) { setScrollTop(cm, op.scrollTop, op.forceScroll); } if (op.scrollLeft != null) { setScrollLeft(cm, op.scrollLeft, true, true); } // If we need to scroll a specific position into view, do so. if (op.scrollToPos) { var rect = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from), clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin); maybeScrollWindow(cm, rect); } // Fire events for markers that are hidden/unidden by editing or // undoing var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers; if (hidden) { for (var i = 0; i < hidden.length; ++i) { if (!hidden[i].lines.length) { signal(hidden[i], "hide"); } } } if (unhidden) { for (var i$1 = 0; i$1 < unhidden.length; ++i$1) { if (unhidden[i$1].lines.length) { signal(unhidden[i$1], "unhide"); } } } if (display.wrapper.offsetHeight) { doc.scrollTop = cm.display.scroller.scrollTop; } // Fire change events, and delayed event handlers if (op.changeObjs) { signal(cm, "changes", cm, op.changeObjs); } if (op.update) { op.update.finish(); } } // Run the given function in an operation function runInOp(cm, f) { if (cm.curOp) { return f() } startOperation(cm); try { return f() } finally { endOperation(cm); } } // Wraps a function in an operation. Returns the wrapped function. function operation(cm, f) { return function() { if (cm.curOp) { return f.apply(cm, arguments) } startOperation(cm); try { return f.apply(cm, arguments) } finally { endOperation(cm); } } } // Used to add methods to editor and doc instances, wrapping them in // operations. function methodOp(f) { return function() { if (this.curOp) { return f.apply(this, arguments) } startOperation(this); try { return f.apply(this, arguments) } finally { endOperation(this); } } } function docMethodOp(f) { return function() { var cm = this.cm; if (!cm || cm.curOp) { return f.apply(this, arguments) } startOperation(cm); try { return f.apply(this, arguments) } finally { endOperation(cm); } } } // HIGHLIGHT WORKER function startWorker(cm, time) { if (cm.doc.highlightFrontier < cm.display.viewTo) { cm.state.highlight.set(time, bind(highlightWorker, cm)); } } function highlightWorker(cm) { var doc = cm.doc; if (doc.highlightFrontier >= cm.display.viewTo) { return } var end = +new Date + cm.options.workTime; var context = getContextBefore(cm, doc.highlightFrontier); var changedLines = []; doc.iter(context.line, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) { if (context.line >= cm.display.viewFrom) { // Visible var oldStyles = line.styles; var resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc.mode, context.state) : null; var highlighted = highlightLine(cm, line, context, true); if (resetState) { context.state = resetState; } line.styles = highlighted.styles; var oldCls = line.styleClasses, newCls = highlighted.classes; if (newCls) { line.styleClasses = newCls; } else if (oldCls) { line.styleClasses = null; } var ischange = !oldStyles || oldStyles.length != line.styles.length || oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass); for (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i]; } if (ischange) { changedLines.push(context.line); } line.stateAfter = context.save(); context.nextLine(); } else { if (line.text.length <= cm.options.maxHighlightLength) { processLine(cm, line.text, context); } line.stateAfter = context.line % 5 == 0 ? context.save() : null; context.nextLine(); } if (+new Date > end) { startWorker(cm, cm.options.workDelay); return true } }); doc.highlightFrontier = context.line; doc.modeFrontier = Math.max(doc.modeFrontier, context.line); if (changedLines.length) { runInOp(cm, function () { for (var i = 0; i < changedLines.length; i++) { regLineChange(cm, changedLines[i], "text"); } }); } } // DISPLAY DRAWING var DisplayUpdate = function(cm, viewport, force) { var display = cm.display; this.viewport = viewport; // Store some values that we'll need later (but don't want to force a relayout for) this.visible = visibleLines(display, cm.doc, viewport); this.editorIsHidden = !display.wrapper.offsetWidth; this.wrapperHeight = display.wrapper.clientHeight; this.wrapperWidth = display.wrapper.clientWidth; this.oldDisplayWidth = displayWidth(cm); this.force = force; this.dims = getDimensions(cm); this.events = []; }; DisplayUpdate.prototype.signal = function (emitter, type) { if (hasHandler(emitter, type)) { this.events.push(arguments); } }; DisplayUpdate.prototype.finish = function () { for (var i = 0; i < this.events.length; i++) { signal.apply(null, this.events[i]); } }; function maybeClipScrollbars(cm) { var display = cm.display; if (!display.scrollbarsClipped && display.scroller.offsetWidth) { display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth; display.heightForcer.style.height = scrollGap(cm) + "px"; display.sizer.style.marginBottom = -display.nativeBarWidth + "px"; display.sizer.style.borderRightWidth = scrollGap(cm) + "px"; display.scrollbarsClipped = true; } } function selectionSnapshot(cm) { if (cm.hasFocus()) { return null } var active = activeElt(); if (!active || !contains(cm.display.lineDiv, active)) { return null } var result = {activeElt: active}; if (window.getSelection) { var sel = window.getSelection(); if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) { result.anchorNode = sel.anchorNode; result.anchorOffset = sel.anchorOffset; result.focusNode = sel.focusNode; result.focusOffset = sel.focusOffset; } } return result } function restoreSelection(snapshot) { if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return } snapshot.activeElt.focus(); if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) && snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) { var sel = window.getSelection(), range = document.createRange(); range.setEnd(snapshot.anchorNode, snapshot.anchorOffset); range.collapse(false); sel.removeAllRanges(); sel.addRange(range); sel.extend(snapshot.focusNode, snapshot.focusOffset); } } // Does the actual updating of the line display. Bails out // (returning false) when there is nothing to be done and forced is // false. function updateDisplayIfNeeded(cm, update) { var display = cm.display, doc = cm.doc; if (update.editorIsHidden) { resetView(cm); return false } // Bail out if the visible area is already rendered and nothing changed. if (!update.force && update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo && (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) && display.renderedView == display.view && countDirtyView(cm) == 0) { return false } if (maybeUpdateLineNumberWidth(cm)) { resetView(cm); update.dims = getDimensions(cm); } // Compute a suitable new viewport (from & to) var end = doc.first + doc.size; var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first); var to = Math.min(end, update.visible.to + cm.options.viewportMargin); if (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom); } if (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo); } if (sawCollapsedSpans) { from = visualLineNo(cm.doc, from); to = visualLineEndNo(cm.doc, to); } var different = from != display.viewFrom || to != display.viewTo || display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth; adjustView(cm, from, to); display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom)); // Position the mover div to align with the current scroll position cm.display.mover.style.top = display.viewOffset + "px"; var toUpdate = countDirtyView(cm); if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view && (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo)) { return false } // For big changes, we hide the enclosing element during the // update, since that speeds up the operations on most browsers. var selSnapshot = selectionSnapshot(cm); if (toUpdate > 4) { display.lineDiv.style.display = "none"; } patchDisplay(cm, display.updateLineNumbers, update.dims); if (toUpdate > 4) { display.lineDiv.style.display = ""; } display.renderedView = display.view; // There might have been a widget with a focused element that got // hidden or updated, if so re-focus it. restoreSelection(selSnapshot); // Prevent selection and cursors from interfering with the scroll // width and height. removeChildren(display.cursorDiv); removeChildren(display.selectionDiv); display.gutters.style.height = display.sizer.style.minHeight = 0; if (different) { display.lastWrapHeight = update.wrapperHeight; display.lastWrapWidth = update.wrapperWidth; startWorker(cm, 400); } display.updateLineNumbers = null; return true } function postUpdateDisplay(cm, update) { var viewport = update.viewport; for (var first = true;; first = false) { if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) { // Clip forced viewport to actual scrollable area. if (viewport && viewport.top != null) { viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)}; } // Updated line heights might result in the drawn area not // actually covering the viewport. Keep looping until it does. update.visible = visibleLines(cm.display, cm.doc, viewport); if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo) { break } } else if (first) { update.visible = visibleLines(cm.display, cm.doc, viewport); } if (!updateDisplayIfNeeded(cm, update)) { break } updateHeightsInViewport(cm); var barMeasure = measureForScrollbars(cm); updateSelection(cm); updateScrollbars(cm, barMeasure); setDocumentHeight(cm, barMeasure); update.force = false; } update.signal(cm, "update", cm); if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) { update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo); cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo; } } function updateDisplaySimple(cm, viewport) { var update = new DisplayUpdate(cm, viewport); if (updateDisplayIfNeeded(cm, update)) { updateHeightsInViewport(cm); postUpdateDisplay(cm, update); var barMeasure = measureForScrollbars(cm); updateSelection(cm); updateScrollbars(cm, barMeasure); setDocumentHeight(cm, barMeasure); update.finish(); } } // Sync the actual display DOM structure with display.view, removing // nodes for lines that are no longer in view, and creating the ones // that are not there yet, and updating the ones that are out of // date. function patchDisplay(cm, updateNumbersFrom, dims) { var display = cm.display, lineNumbers = cm.options.lineNumbers; var container = display.lineDiv, cur = container.firstChild; function rm(node) { var next = node.nextSibling; // Works around a throw-scroll bug in OS X Webkit if (webkit && mac && cm.display.currentWheelTarget == node) { node.style.display = "none"; } else { node.parentNode.removeChild(node); } return next } var view = display.view, lineN = display.viewFrom; // Loop over the elements in the view, syncing cur (the DOM nodes // in display.lineDiv) with the view as we go. for (var i = 0; i < view.length; i++) { var lineView = view[i]; if (lineView.hidden) ; else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet var node = buildLineElement(cm, lineView, lineN, dims); container.insertBefore(node, cur); } else { // Already drawn while (cur != lineView.node) { cur = rm(cur); } var updateNumber = lineNumbers && updateNumbersFrom != null && updateNumbersFrom <= lineN && lineView.lineNumber; if (lineView.changes) { if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false; } updateLineForChanges(cm, lineView, lineN, dims); } if (updateNumber) { removeChildren(lineView.lineNumber); lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN))); } cur = lineView.node.nextSibling; } lineN += lineView.size; } while (cur) { cur = rm(cur); } } function updateGutterSpace(display) { var width = display.gutters.offsetWidth; display.sizer.style.marginLeft = width + "px"; } function setDocumentHeight(cm, measure) { cm.display.sizer.style.minHeight = measure.docHeight + "px"; cm.display.heightForcer.style.top = measure.docHeight + "px"; cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px"; } // Re-align line numbers and gutter marks to compensate for // horizontal scrolling. function alignHorizontally(cm) { var display = cm.display, view = display.view; if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) { return } var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft; var gutterW = display.gutters.offsetWidth, left = comp + "px"; for (var i = 0; i < view.length; i++) { if (!view[i].hidden) { if (cm.options.fixedGutter) { if (view[i].gutter) { view[i].gutter.style.left = left; } if (view[i].gutterBackground) { view[i].gutterBackground.style.left = left; } } var align = view[i].alignable; if (align) { for (var j = 0; j < align.length; j++) { align[j].style.left = left; } } } } if (cm.options.fixedGutter) { display.gutters.style.left = (comp + gutterW) + "px"; } } // Used to ensure that the line number gutter is still the right // size for the current document size. Returns true when an update // is needed. function maybeUpdateLineNumberWidth(cm) { if (!cm.options.lineNumbers) { return false } var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display; if (last.length != display.lineNumChars) { var test = display.measure.appendChild(elt("div", [elt("div", last)], "CodeMirror-linenumber CodeMirror-gutter-elt")); var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW; display.lineGutter.style.width = ""; display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1; display.lineNumWidth = display.lineNumInnerWidth + padding; display.lineNumChars = display.lineNumInnerWidth ? last.length : -1; display.lineGutter.style.width = display.lineNumWidth + "px"; updateGutterSpace(cm.display); return true } return false } function getGutters(gutters, lineNumbers) { var result = [], sawLineNumbers = false; for (var i = 0; i < gutters.length; i++) { var name = gutters[i], style = null; if (typeof name != "string") { style = name.style; name = name.className; } if (name == "CodeMirror-linenumbers") { if (!lineNumbers) { continue } else { sawLineNumbers = true; } } result.push({className: name, style: style}); } if (lineNumbers && !sawLineNumbers) { result.push({className: "CodeMirror-linenumbers", style: null}); } return result } // Rebuild the gutter elements, ensure the margin to the left of the // code matches their width. function renderGutters(display) { var gutters = display.gutters, specs = display.gutterSpecs; removeChildren(gutters); display.lineGutter = null; for (var i = 0; i < specs.length; ++i) { var ref = specs[i]; var className = ref.className; var style = ref.style; var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + className)); if (style) { gElt.style.cssText = style; } if (className == "CodeMirror-linenumbers") { display.lineGutter = gElt; gElt.style.width = (display.lineNumWidth || 1) + "px"; } } gutters.style.display = specs.length ? "" : "none"; updateGutterSpace(display); } function updateGutters(cm) { renderGutters(cm.display); regChange(cm); alignHorizontally(cm); } // The display handles the DOM integration, both for input reading // and content drawing. It holds references to DOM nodes and // display-related state. function Display(place, doc, input, options) { var d = this; this.input = input; // Covers bottom-right square when both scrollbars are present. d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler"); d.scrollbarFiller.setAttribute("cm-not-content", "true"); // Covers bottom of gutter when coverGutterNextToScrollbar is on // and h scrollbar is present. d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler"); d.gutterFiller.setAttribute("cm-not-content", "true"); // Will contain the actual code, positioned to cover the viewport. d.lineDiv = eltP("div", null, "CodeMirror-code"); // Elements are added to these to represent selection and cursors. d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1"); d.cursorDiv = elt("div", null, "CodeMirror-cursors"); // A visibility: hidden element used to find the size of things. d.measure = elt("div", null, "CodeMirror-measure"); // When lines outside of the viewport are measured, they are drawn in this. d.lineMeasure = elt("div", null, "CodeMirror-measure"); // Wraps everything that needs to exist inside the vertically-padded coordinate system d.lineSpace = eltP("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv], null, "position: relative; outline: none"); var lines = eltP("div", [d.lineSpace], "CodeMirror-lines"); // Moved around its parent to cover visible view. d.mover = elt("div", [lines], null, "position: relative"); // Set to the height of the document, allowing scrolling. d.sizer = elt("div", [d.mover], "CodeMirror-sizer"); d.sizerWidth = null; // Behavior of elts with overflow: auto and padding is // inconsistent across browsers. This is used to ensure the // scrollable area is big enough. d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;"); // Will contain the gutters, if any. d.gutters = elt("div", null, "CodeMirror-gutters"); d.lineGutter = null; // Actual scrollable element. d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll"); d.scroller.setAttribute("tabIndex", "-1"); // The element in which the editor lives. d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror"); // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported) if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; } if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true; } if (place) { if (place.appendChild) { place.appendChild(d.wrapper); } else { place(d.wrapper); } } // Current rendered range (may be bigger than the view window). d.viewFrom = d.viewTo = doc.first; d.reportedViewFrom = d.reportedViewTo = doc.first; // Information about the rendered lines. d.view = []; d.renderedView = null; // Holds info about a single rendered line when it was rendered // for measurement, while not in view. d.externalMeasured = null; // Empty space (in pixels) above the view d.viewOffset = 0; d.lastWrapHeight = d.lastWrapWidth = 0; d.updateLineNumbers = null; d.nativeBarWidth = d.barHeight = d.barWidth = 0; d.scrollbarsClipped = false; // Used to only resize the line number gutter when necessary (when // the amount of lines crosses a boundary that makes its width change) d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null; // Set to true when a non-horizontal-scrolling line widget is // added. As an optimization, line widget aligning is skipped when // this is false. d.alignWidgets = false; d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; // Tracks the maximum line length so that the horizontal scrollbar // can be kept static when scrolling. d.maxLine = null; d.maxLineLength = 0; d.maxLineChanged = false; // Used for measuring wheel scrolling granularity d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null; // True when shift is held down. d.shift = false; // Used to track whether anything happened since the context menu // was opened. d.selForContextMenu = null; d.activeTouch = null; d.gutterSpecs = getGutters(options.gutters, options.lineNumbers); renderGutters(d); input.init(d); } // Since the delta values reported on mouse wheel events are // unstandardized between browsers and even browser versions, and // generally horribly unpredictable, this code starts by measuring // the scroll effect that the first few mouse wheel events have, // and, from that, detects the way it can convert deltas to pixel // offsets afterwards. // // The reason we want to know the amount a wheel event will scroll // is that it gives us a chance to update the display before the // actual scrolling happens, reducing flickering. var wheelSamples = 0, wheelPixelsPerUnit = null; // Fill in a browser-detected starting value on browsers where we // know one. These don't have to be accurate -- the result of them // being wrong would just be a slight flicker on the first wheel // scroll (if it is large enough). if (ie) { wheelPixelsPerUnit = -.53; } else if (gecko) { wheelPixelsPerUnit = 15; } else if (chrome) { wheelPixelsPerUnit = -.7; } else if (safari) { wheelPixelsPerUnit = -1/3; } function wheelEventDelta(e) { var dx = e.wheelDeltaX, dy = e.wheelDeltaY; if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) { dx = e.detail; } if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) { dy = e.detail; } else if (dy == null) { dy = e.wheelDelta; } return {x: dx, y: dy} } function wheelEventPixels(e) { var delta = wheelEventDelta(e); delta.x *= wheelPixelsPerUnit; delta.y *= wheelPixelsPerUnit; return delta } function onScrollWheel(cm, e) { var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y; var display = cm.display, scroll = display.scroller; // Quit if there's nothing to scroll here var canScrollX = scroll.scrollWidth > scroll.clientWidth; var canScrollY = scroll.scrollHeight > scroll.clientHeight; if (!(dx && canScrollX || dy && canScrollY)) { return } // Webkit browsers on OS X abort momentum scrolls when the target // of the scroll event is removed from the scrollable element. // This hack (see related code in patchDisplay) makes sure the // element is kept around. if (dy && mac && webkit) { outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) { for (var i = 0; i < view.length; i++) { if (view[i].node == cur) { cm.display.currentWheelTarget = cur; break outer } } } } // On some browsers, horizontal scrolling will cause redraws to // happen before the gutter has been realigned, causing it to // wriggle around in a most unseemly way. When we have an // estimated pixels/delta value, we just handle horizontal // scrolling entirely here. It'll be slightly off from native, but // better than glitching out. if (dx && !gecko && !presto && wheelPixelsPerUnit != null) { if (dy && canScrollY) { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit)); } setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit)); // Only prevent default scrolling if vertical scrolling is // actually possible. Otherwise, it causes vertical scroll // jitter on OSX trackpads when deltaX is small and deltaY // is large (issue #3579) if (!dy || (dy && canScrollY)) { e_preventDefault(e); } display.wheelStartX = null; // Abort measurement, if in progress return } // 'Project' the visible viewport to cover the area that is being // scrolled into view (if we know enough to estimate it). if (dy && wheelPixelsPerUnit != null) { var pixels = dy * wheelPixelsPerUnit; var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight; if (pixels < 0) { top = Math.max(0, top + pixels - 50); } else { bot = Math.min(cm.doc.height, bot + pixels + 50); } updateDisplaySimple(cm, {top: top, bottom: bot}); } if (wheelSamples < 20) { if (display.wheelStartX == null) { display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop; display.wheelDX = dx; display.wheelDY = dy; setTimeout(function () { if (display.wheelStartX == null) { return } var movedX = scroll.scrollLeft - display.wheelStartX; var movedY = scroll.scrollTop - display.wheelStartY; var sample = (movedY && display.wheelDY && movedY / display.wheelDY) || (movedX && display.wheelDX && movedX / display.wheelDX); display.wheelStartX = display.wheelStartY = null; if (!sample) { return } wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1); ++wheelSamples; }, 200); } else { display.wheelDX += dx; display.wheelDY += dy; } } } // Selection objects are immutable. A new one is created every time // the selection changes. A selection is one or more non-overlapping // (and non-touching) ranges, sorted, and an integer that indicates // which one is the primary selection (the one that's scrolled into // view, that getCursor returns, etc). var Selection = function(ranges, primIndex) { this.ranges = ranges; this.primIndex = primIndex; }; Selection.prototype.primary = function () { return this.ranges[this.primIndex] }; Selection.prototype.equals = function (other) { if (other == this) { return true } if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false } for (var i = 0; i < this.ranges.length; i++) { var here = this.ranges[i], there = other.ranges[i]; if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) { return false } } return true }; Selection.prototype.deepCopy = function () { var out = []; for (var i = 0; i < this.ranges.length; i++) { out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head)); } return new Selection(out, this.primIndex) }; Selection.prototype.somethingSelected = function () { for (var i = 0; i < this.ranges.length; i++) { if (!this.ranges[i].empty()) { return true } } return false }; Selection.prototype.contains = function (pos, end) { if (!end) { end = pos; } for (var i = 0; i < this.ranges.length; i++) { var range = this.ranges[i]; if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0) { return i } } return -1 }; var Range = function(anchor, head) { this.anchor = anchor; this.head = head; }; Range.prototype.from = function () { return minPos(this.anchor, this.head) }; Range.prototype.to = function () { return maxPos(this.anchor, this.head) }; Range.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch }; // Take an unsorted, potentially overlapping set of ranges, and // build a selection out of it. 'Consumes' ranges array (modifying // it). function normalizeSelection(cm, ranges, primIndex) { var mayTouch = cm && cm.options.selectionsMayTouch; var prim = ranges[primIndex]; ranges.sort(function (a, b) { return cmp(a.from(), b.from()); }); primIndex = indexOf(ranges, prim); for (var i = 1; i < ranges.length; i++) { var cur = ranges[i], prev = ranges[i - 1]; var diff = cmp(prev.to(), cur.from()); if (mayTouch && !cur.empty() ? diff > 0 : diff >= 0) { var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to()); var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head; if (i <= primIndex) { --primIndex; } ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to)); } } return new Selection(ranges, primIndex) } function simpleSelection(anchor, head) { return new Selection([new Range(anchor, head || anchor)], 0) } // Compute the position of the end of a change (its 'to' property // refers to the pre-change end). function changeEnd(change) { if (!change.text) { return change.to } return Pos(change.from.line + change.text.length - 1, lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0)) } // Adjust a position to refer to the post-change position of the // same text, or the end of the change if the change covers it. function adjustForChange(pos, change) { if (cmp(pos, change.from) < 0) { return pos } if (cmp(pos, change.to) <= 0) { return changeEnd(change) } var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch; if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch; } return Pos(line, ch) } function computeSelAfterChange(doc, change) { var out = []; for (var i = 0; i < doc.sel.ranges.length; i++) { var range = doc.sel.ranges[i]; out.push(new Range(adjustForChange(range.anchor, change), adjustForChange(range.head, change))); } return normalizeSelection(doc.cm, out, doc.sel.primIndex) } function offsetPos(pos, old, nw) { if (pos.line == old.line) { return Pos(nw.line, pos.ch - old.ch + nw.ch) } else { return Pos(nw.line + (pos.line - old.line), pos.ch) } } // Used by replaceSelections to allow moving the selection to the // start or around the replaced test. Hint may be "start" or "around". function computeReplacedSel(doc, changes, hint) { var out = []; var oldPrev = Pos(doc.first, 0), newPrev = oldPrev; for (var i = 0; i < changes.length; i++) { var change = changes[i]; var from = offsetPos(change.from, oldPrev, newPrev); var to = offsetPos(changeEnd(change), oldPrev, newPrev); oldPrev = change.to; newPrev = to; if (hint == "around") { var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0; out[i] = new Range(inv ? to : from, inv ? from : to); } else { out[i] = new Range(from, from); } } return new Selection(out, doc.sel.primIndex) } // Used to get the editor into a consistent state again when options change. function loadMode(cm) { cm.doc.mode = getMode(cm.options, cm.doc.modeOption); resetModeState(cm); } function resetModeState(cm) { cm.doc.iter(function (line) { if (line.stateAfter) { line.stateAfter = null; } if (line.styles) { line.styles = null; } }); cm.doc.modeFrontier = cm.doc.highlightFrontier = cm.doc.first; startWorker(cm, 100); cm.state.modeGen++; if (cm.curOp) { regChange(cm); } } // DOCUMENT DATA STRUCTURE // By default, updates that start and end at the beginning of a line // are treated specially, in order to make the association of line // widgets and marker elements with the text behave more intuitive. function isWholeLineUpdate(doc, change) { return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" && (!doc.cm || doc.cm.options.wholeLineUpdateBefore) } // Perform a change on the document data structure. function updateDoc(doc, change, markedSpans, estimateHeight) { function spansFor(n) {return markedSpans ? markedSpans[n] : null} function update(line, text, spans) { updateLine(line, text, spans, estimateHeight); signalLater(line, "change", line, change); } function linesFor(start, end) { var result = []; for (var i = start; i < end; ++i) { result.push(new Line(text[i], spansFor(i), estimateHeight)); } return result } var from = change.from, to = change.to, text = change.text; var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line); var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line; // Adjust the line structure if (change.full) { doc.insert(0, linesFor(0, text.length)); doc.remove(text.length, doc.size - text.length); } else if (isWholeLineUpdate(doc, change)) { // This is a whole-line replace. Treated specially to make // sure line objects move the way they are supposed to. var added = linesFor(0, text.length - 1); update(lastLine, lastLine.text, lastSpans); if (nlines) { doc.remove(from.line, nlines); } if (added.length) { doc.insert(from.line, added); } } else if (firstLine == lastLine) { if (text.length == 1) { update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans); } else { var added$1 = linesFor(1, text.length - 1); added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight)); update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); doc.insert(from.line + 1, added$1); } } else if (text.length == 1) { update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0)); doc.remove(from.line + 1, nlines); } else { update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans); var added$2 = linesFor(1, text.length - 1); if (nlines > 1) { doc.remove(from.line + 1, nlines - 1); } doc.insert(from.line + 1, added$2); } signalLater(doc, "change", doc, change); } // Call f for all linked documents. function linkedDocs(doc, f, sharedHistOnly) { function propagate(doc, skip, sharedHist) { if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) { var rel = doc.linked[i]; if (rel.doc == skip) { continue } var shared = sharedHist && rel.sharedHist; if (sharedHistOnly && !shared) { continue } f(rel.doc, shared); propagate(rel.doc, doc, shared); } } } propagate(doc, null, true); } // Attach a document to an editor. function attachDoc(cm, doc) { if (doc.cm) { throw new Error("This document is already in use.") } cm.doc = doc; doc.cm = cm; estimateLineHeights(cm); loadMode(cm); setDirectionClass(cm); if (!cm.options.lineWrapping) { findMaxLine(cm); } cm.options.mode = doc.modeOption; regChange(cm); } function setDirectionClass(cm) { (cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl"); } function directionChanged(cm) { runInOp(cm, function () { setDirectionClass(cm); regChange(cm); }); } function History(startGen) { // Arrays of change events and selections. Doing something adds an // event to done and clears undo. Undoing moves events from done // to undone, redoing moves them in the other direction. this.done = []; this.undone = []; this.undoDepth = Infinity; // Used to track when changes can be merged into a single undo // event this.lastModTime = this.lastSelTime = 0; this.lastOp = this.lastSelOp = null; this.lastOrigin = this.lastSelOrigin = null; // Used by the isClean() method this.generation = this.maxGeneration = startGen || 1; } // Create a history change event from an updateDoc-style change // object. function historyChangeFromChange(doc, change) { var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)}; attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); linkedDocs(doc, function (doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, true); return histChange } // Pop all selection events off the end of a history array. Stop at // a change event. function clearSelectionEvents(array) { while (array.length) { var last = lst(array); if (last.ranges) { array.pop(); } else { break } } } // Find the top change event in the history. Pop off selection // events that are in the way. function lastChangeEvent(hist, force) { if (force) { clearSelectionEvents(hist.done); return lst(hist.done) } else if (hist.done.length && !lst(hist.done).ranges) { return lst(hist.done) } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) { hist.done.pop(); return lst(hist.done) } } // Register a change in the history. Merges changes that are within // a single operation, or are close together with an origin that // allows merging (starting with "+") into a single event. function addChangeToHistory(doc, change, selAfter, opId) { var hist = doc.history; hist.undone.length = 0; var time = +new Date, cur; var last; if ((hist.lastOp == opId || hist.lastOrigin == change.origin && change.origin && ((change.origin.charAt(0) == "+" && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500)) || change.origin.charAt(0) == "*")) && (cur = lastChangeEvent(hist, hist.lastOp == opId))) { // Merge this change into the last event last = lst(cur.changes); if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) { // Optimized case for simple insertion -- don't want to add // new changesets for every character typed last.to = changeEnd(change); } else { // Add new sub-event cur.changes.push(historyChangeFromChange(doc, change)); } } else { // Can not be merged, start a new event. var before = lst(hist.done); if (!before || !before.ranges) { pushSelectionToHistory(doc.sel, hist.done); } cur = {changes: [historyChangeFromChange(doc, change)], generation: hist.generation}; hist.done.push(cur); while (hist.done.length > hist.undoDepth) { hist.done.shift(); if (!hist.done[0].ranges) { hist.done.shift(); } } } hist.done.push(selAfter); hist.generation = ++hist.maxGeneration; hist.lastModTime = hist.lastSelTime = time; hist.lastOp = hist.lastSelOp = opId; hist.lastOrigin = hist.lastSelOrigin = change.origin; if (!last) { signal(doc, "historyAdded"); } } function selectionEventCanBeMerged(doc, origin, prev, sel) { var ch = origin.charAt(0); return ch == "*" || ch == "+" && prev.ranges.length == sel.ranges.length && prev.somethingSelected() == sel.somethingSelected() && new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500) } // Called whenever the selection changes, sets the new selection as // the pending selection in the history, and pushes the old pending // selection into the 'done' array when it was significantly // different (in number of selected ranges, emptiness, or time). function addSelectionToHistory(doc, sel, opId, options) { var hist = doc.history, origin = options && options.origin; // A new event is started when the previous origin does not match // the current, or the origins don't allow matching. Origins // starting with * are always merged, those starting with + are // merged when similar and close together in time. if (opId == hist.lastSelOp || (origin && hist.lastSelOrigin == origin && (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) { hist.done[hist.done.length - 1] = sel; } else { pushSelectionToHistory(sel, hist.done); } hist.lastSelTime = +new Date; hist.lastSelOrigin = origin; hist.lastSelOp = opId; if (options && options.clearRedo !== false) { clearSelectionEvents(hist.undone); } } function pushSelectionToHistory(sel, dest) { var top = lst(dest); if (!(top && top.ranges && top.equals(sel))) { dest.push(sel); } } // Used to store marked span information in the history. function attachLocalSpans(doc, change, from, to) { var existing = change["spans_" + doc.id], n = 0; doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) { if (line.markedSpans) { (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans; } ++n; }); } // When un/re-doing restores text containing marked spans, those // that have been explicitly cleared should not be restored. function removeClearedSpans(spans) { if (!spans) { return null } var out; for (var i = 0; i < spans.length; ++i) { if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i); } } else if (out) { out.push(spans[i]); } } return !out ? spans : out.length ? out : null } // Retrieve and filter the old marked spans stored in a change event. function getOldSpans(doc, change) { var found = change["spans_" + doc.id]; if (!found) { return null } var nw = []; for (var i = 0; i < change.text.length; ++i) { nw.push(removeClearedSpans(found[i])); } return nw } // Used for un/re-doing changes from the history. Combines the // result of computing the existing spans with the set of spans that // existed in the history (so that deleting around a span and then // undoing brings back the span). function mergeOldSpans(doc, change) { var old = getOldSpans(doc, change); var stretched = stretchSpansOverChange(doc, change); if (!old) { return stretched } if (!stretched) { return old } for (var i = 0; i < old.length; ++i) { var oldCur = old[i], stretchCur = stretched[i]; if (oldCur && stretchCur) { spans: for (var j = 0; j < stretchCur.length; ++j) { var span = stretchCur[j]; for (var k = 0; k < oldCur.length; ++k) { if (oldCur[k].marker == span.marker) { continue spans } } oldCur.push(span); } } else if (stretchCur) { old[i] = stretchCur; } } return old } // Used both to provide a JSON-safe object in .getHistory, and, when // detaching a document, to split the history in two function copyHistoryArray(events, newGroup, instantiateSel) { var copy = []; for (var i = 0; i < events.length; ++i) { var event = events[i]; if (event.ranges) { copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event); continue } var changes = event.changes, newChanges = []; copy.push({changes: newChanges}); for (var j = 0; j < changes.length; ++j) { var change = changes[j], m = (void 0); newChanges.push({from: change.from, to: change.to, text: change.text}); if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) { if (indexOf(newGroup, Number(m[1])) > -1) { lst(newChanges)[prop] = change[prop]; delete change[prop]; } } } } } } return copy } // The 'scroll' parameter given to many of these indicated whether // the new cursor position should be scrolled into view after // modifying the selection. // If shift is held or the extend flag is set, extends a range to // include a given position (and optionally a second position). // Otherwise, simply returns the range between the given positions. // Used for cursor motion and such. function extendRange(range, head, other, extend) { if (extend) { var anchor = range.anchor; if (other) { var posBefore = cmp(head, anchor) < 0; if (posBefore != (cmp(other, anchor) < 0)) { anchor = head; head = other; } else if (posBefore != (cmp(head, other) < 0)) { head = other; } } return new Range(anchor, head) } else { return new Range(other || head, head) } } // Extend the primary selection range, discard the rest. function extendSelection(doc, head, other, options, extend) { if (extend == null) { extend = doc.cm && (doc.cm.display.shift || doc.extend); } setSelection(doc, new Selection([extendRange(doc.sel.primary(), head, other, extend)], 0), options); } // Extend all selections (pos is an array of selections with length // equal the number of selections) function extendSelections(doc, heads, options) { var out = []; var extend = doc.cm && (doc.cm.display.shift || doc.extend); for (var i = 0; i < doc.sel.ranges.length; i++) { out[i] = extendRange(doc.sel.ranges[i], heads[i], null, extend); } var newSel = normalizeSelection(doc.cm, out, doc.sel.primIndex); setSelection(doc, newSel, options); } // Updates a single range in the selection. function replaceOneSelection(doc, i, range, options) { var ranges = doc.sel.ranges.slice(0); ranges[i] = range; setSelection(doc, normalizeSelection(doc.cm, ranges, doc.sel.primIndex), options); } // Reset the selection to a single range. function setSimpleSelection(doc, anchor, head, options) { setSelection(doc, simpleSelection(anchor, head), options); } // Give beforeSelectionChange handlers a change to influence a // selection update. function filterSelectionChange(doc, sel, options) { var obj = { ranges: sel.ranges, update: function(ranges) { this.ranges = []; for (var i = 0; i < ranges.length; i++) { this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor), clipPos(doc, ranges[i].head)); } }, origin: options && options.origin }; signal(doc, "beforeSelectionChange", doc, obj); if (doc.cm) { signal(doc.cm, "beforeSelectionChange", doc.cm, obj); } if (obj.ranges != sel.ranges) { return normalizeSelection(doc.cm, obj.ranges, obj.ranges.length - 1) } else { return sel } } function setSelectionReplaceHistory(doc, sel, options) { var done = doc.history.done, last = lst(done); if (last && last.ranges) { done[done.length - 1] = sel; setSelectionNoUndo(doc, sel, options); } else { setSelection(doc, sel, options); } } // Set a new selection. function setSelection(doc, sel, options) { setSelectionNoUndo(doc, sel, options); addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options); } function setSelectionNoUndo(doc, sel, options) { if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) { sel = filterSelectionChange(doc, sel, options); } var bias = options && options.bias || (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1); setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true)); if (!(options && options.scroll === false) && doc.cm) { ensureCursorVisible(doc.cm); } } function setSelectionInner(doc, sel) { if (sel.equals(doc.sel)) { return } doc.sel = sel; if (doc.cm) { doc.cm.curOp.updateInput = 1; doc.cm.curOp.selectionChanged = true; signalCursorActivity(doc.cm); } signalLater(doc, "cursorActivity", doc); } // Verify that the selection does not partially select any atomic // marked ranges. function reCheckSelection(doc) { setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false)); } // Return a selection that does not partially select any atomic // ranges. function skipAtomicInSelection(doc, sel, bias, mayClear) { var out; for (var i = 0; i < sel.ranges.length; i++) { var range = sel.ranges[i]; var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i]; var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear); var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear); if (out || newAnchor != range.anchor || newHead != range.head) { if (!out) { out = sel.ranges.slice(0, i); } out[i] = new Range(newAnchor, newHead); } } return out ? normalizeSelection(doc.cm, out, sel.primIndex) : sel } function skipAtomicInner(doc, pos, oldPos, dir, mayClear) { var line = getLine(doc, pos.line); if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) { var sp = line.markedSpans[i], m = sp.marker; // Determine if we should prevent the cursor being placed to the left/right of an atomic marker // Historically this was determined using the inclusiveLeft/Right option, but the new way to control it // is with selectLeft/Right var preventCursorLeft = ("selectLeft" in m) ? !m.selectLeft : m.inclusiveLeft; var preventCursorRight = ("selectRight" in m) ? !m.selectRight : m.inclusiveRight; if ((sp.from == null || (preventCursorLeft ? sp.from <= pos.ch : sp.from < pos.ch)) && (sp.to == null || (preventCursorRight ? sp.to >= pos.ch : sp.to > pos.ch))) { if (mayClear) { signal(m, "beforeCursorEnter"); if (m.explicitlyCleared) { if (!line.markedSpans) { break } else {--i; continue} } } if (!m.atomic) { continue } if (oldPos) { var near = m.find(dir < 0 ? 1 : -1), diff = (void 0); if (dir < 0 ? preventCursorRight : preventCursorLeft) { near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null); } if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0)) { return skipAtomicInner(doc, near, pos, dir, mayClear) } } var far = m.find(dir < 0 ? -1 : 1); if (dir < 0 ? preventCursorLeft : preventCursorRight) { far = movePos(doc, far, dir, far.line == pos.line ? line : null); } return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null } } } return pos } // Ensure a given position is not inside an atomic range. function skipAtomic(doc, pos, oldPos, bias, mayClear) { var dir = bias || 1; var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) || (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) || skipAtomicInner(doc, pos, oldPos, -dir, mayClear) || (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true)); if (!found) { doc.cantEdit = true; return Pos(doc.first, 0) } return found } function movePos(doc, pos, dir, line) { if (dir < 0 && pos.ch == 0) { if (pos.line > doc.first) { return clipPos(doc, Pos(pos.line - 1)) } else { return null } } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) { if (pos.line < doc.first + doc.size - 1) { return Pos(pos.line + 1, 0) } else { return null } } else { return new Pos(pos.line, pos.ch + dir) } } function selectAll(cm) { cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll); } // UPDATING // Allow "beforeChange" event handlers to influence a change function filterChange(doc, change, update) { var obj = { canceled: false, from: change.from, to: change.to, text: change.text, origin: change.origin, cancel: function () { return obj.canceled = true; } }; if (update) { obj.update = function (from, to, text, origin) { if (from) { obj.from = clipPos(doc, from); } if (to) { obj.to = clipPos(doc, to); } if (text) { obj.text = text; } if (origin !== undefined) { obj.origin = origin; } }; } signal(doc, "beforeChange", doc, obj); if (doc.cm) { signal(doc.cm, "beforeChange", doc.cm, obj); } if (obj.canceled) { if (doc.cm) { doc.cm.curOp.updateInput = 2; } return null } return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin} } // Apply a change to a document, and add it to the document's // history, and propagating it to all linked documents. function makeChange(doc, change, ignoreReadOnly) { if (doc.cm) { if (!doc.cm.curOp) { return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly) } if (doc.cm.state.suppressEdits) { return } } if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) { change = filterChange(doc, change, true); if (!change) { return } } // Possibly split or suppress the update based on the presence // of read-only spans in its range. var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to); if (split) { for (var i = split.length - 1; i >= 0; --i) { makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin}); } } else { makeChangeInner(doc, change); } } function makeChangeInner(doc, change) { if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) { return } var selAfter = computeSelAfterChange(doc, change); addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN); makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change)); var rebased = []; linkedDocs(doc, function (doc, sharedHist) { if (!sharedHist && indexOf(rebased, doc.history) == -1) { rebaseHist(doc.history, change); rebased.push(doc.history); } makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change)); }); } // Revert a change stored in a document's history. function makeChangeFromHistory(doc, type, allowSelectionOnly) { var suppress = doc.cm && doc.cm.state.suppressEdits; if (suppress && !allowSelectionOnly) { return } var hist = doc.history, event, selAfter = doc.sel; var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done; // Verify that there is a useable event (so that ctrl-z won't // needlessly clear selection events) var i = 0; for (; i < source.length; i++) { event = source[i]; if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges) { break } } if (i == source.length) { return } hist.lastOrigin = hist.lastSelOrigin = null; for (;;) { event = source.pop(); if (event.ranges) { pushSelectionToHistory(event, dest); if (allowSelectionOnly && !event.equals(doc.sel)) { setSelection(doc, event, {clearRedo: false}); return } selAfter = event; } else if (suppress) { source.push(event); return } else { break } } // Build up a reverse change object to add to the opposite history // stack (redo when undoing, and vice versa). var antiChanges = []; pushSelectionToHistory(selAfter, dest); dest.push({changes: antiChanges, generation: hist.generation}); hist.generation = event.generation || ++hist.maxGeneration; var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange"); var loop = function ( i ) { var change = event.changes[i]; change.origin = type; if (filter && !filterChange(doc, change, false)) { source.length = 0; return {} } antiChanges.push(historyChangeFromChange(doc, change)); var after = i ? computeSelAfterChange(doc, change) : lst(source); makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change)); if (!i && doc.cm) { doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}); } var rebased = []; // Propagate to the linked documents linkedDocs(doc, function (doc, sharedHist) { if (!sharedHist && indexOf(rebased, doc.history) == -1) { rebaseHist(doc.history, change); rebased.push(doc.history); } makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change)); }); }; for (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) { var returned = loop( i$1 ); if ( returned ) return returned.v; } } // Sub-views need their line numbers shifted when text is added // above or below them in the parent document. function shiftDoc(doc, distance) { if (distance == 0) { return } doc.first += distance; doc.sel = new Selection(map(doc.sel.ranges, function (range) { return new Range( Pos(range.anchor.line + distance, range.anchor.ch), Pos(range.head.line + distance, range.head.ch) ); }), doc.sel.primIndex); if (doc.cm) { regChange(doc.cm, doc.first, doc.first - distance, distance); for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++) { regLineChange(doc.cm, l, "gutter"); } } } // More lower-level change function, handling only a single document // (not linked ones). function makeChangeSingleDoc(doc, change, selAfter, spans) { if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans) } if (change.to.line < doc.first) { shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line)); return } if (change.from.line > doc.lastLine()) { return } // Clip the change to the size of this doc if (change.from.line < doc.first) { var shift = change.text.length - 1 - (doc.first - change.from.line); shiftDoc(doc, shift); change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch), text: [lst(change.text)], origin: change.origin}; } var last = doc.lastLine(); if (change.to.line > last) { change = {from: change.from, to: Pos(last, getLine(doc, last).text.length), text: [change.text[0]], origin: change.origin}; } change.removed = getBetween(doc, change.from, change.to); if (!selAfter) { selAfter = computeSelAfterChange(doc, change); } if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans); } else { updateDoc(doc, change, spans); } setSelectionNoUndo(doc, selAfter, sel_dontScroll); if (doc.cantEdit && skipAtomic(doc, Pos(doc.firstLine(), 0))) { doc.cantEdit = false; } } // Handle the interaction of a change to a document with the editor // that this document is part of. function makeChangeSingleDocInEditor(cm, change, spans) { var doc = cm.doc, display = cm.display, from = change.from, to = change.to; var recomputeMaxLength = false, checkWidthStart = from.line; if (!cm.options.lineWrapping) { checkWidthStart = lineNo(visualLine(getLine(doc, from.line))); doc.iter(checkWidthStart, to.line + 1, function (line) { if (line == display.maxLine) { recomputeMaxLength = true; return true } }); } if (doc.sel.contains(change.from, change.to) > -1) { signalCursorActivity(cm); } updateDoc(doc, change, spans, estimateHeight(cm)); if (!cm.options.lineWrapping) { doc.iter(checkWidthStart, from.line + change.text.length, function (line) { var len = lineLength(line); if (len > display.maxLineLength) { display.maxLine = line; display.maxLineLength = len; display.maxLineChanged = true; recomputeMaxLength = false; } }); if (recomputeMaxLength) { cm.curOp.updateMaxLine = true; } } retreatFrontier(doc, from.line); startWorker(cm, 400); var lendiff = change.text.length - (to.line - from.line) - 1; // Remember that these lines changed, for updating the display if (change.full) { regChange(cm); } else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change)) { regLineChange(cm, from.line, "text"); } else { regChange(cm, from.line, to.line + 1, lendiff); } var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change"); if (changeHandler || changesHandler) { var obj = { from: from, to: to, text: change.text, removed: change.removed, origin: change.origin }; if (changeHandler) { signalLater(cm, "change", cm, obj); } if (changesHandler) { (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); } } cm.display.selForContextMenu = null; } function replaceRange(doc, code, from, to, origin) { var assign; if (!to) { to = from; } if (cmp(to, from) < 0) { (assign = [to, from], from = assign[0], to = assign[1]); } if (typeof code == "string") { code = doc.splitLines(code); } makeChange(doc, {from: from, to: to, text: code, origin: origin}); } // Rebasing/resetting history to deal with externally-sourced changes function rebaseHistSelSingle(pos, from, to, diff) { if (to < pos.line) { pos.line += diff; } else if (from < pos.line) { pos.line = from; pos.ch = 0; } } // Tries to rebase an array of history events given a change in the // document. If the change touches the same lines as the event, the // event, and everything 'behind' it, is discarded. If the change is // before the event, the event's positions are updated. Uses a // copy-on-write scheme for the positions, to avoid having to // reallocate them all on every rebase, but also avoid problems with // shared position objects being unsafely updated. function rebaseHistArray(array, from, to, diff) { for (var i = 0; i < array.length; ++i) { var sub = array[i], ok = true; if (sub.ranges) { if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; } for (var j = 0; j < sub.ranges.length; j++) { rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff); rebaseHistSelSingle(sub.ranges[j].head, from, to, diff); } continue } for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) { var cur = sub.changes[j$1]; if (to < cur.from.line) { cur.from = Pos(cur.from.line + diff, cur.from.ch); cur.to = Pos(cur.to.line + diff, cur.to.ch); } else if (from <= cur.to.line) { ok = false; break } } if (!ok) { array.splice(0, i + 1); i = 0; } } } function rebaseHist(hist, change) { var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1; rebaseHistArray(hist.done, from, to, diff); rebaseHistArray(hist.undone, from, to, diff); } // Utility for applying a change to a line by handle or number, // returning the number and optionally registering the line as // changed. function changeLine(doc, handle, changeType, op) { var no = handle, line = handle; if (typeof handle == "number") { line = getLine(doc, clipLine(doc, handle)); } else { no = lineNo(handle); } if (no == null) { return null } if (op(line, no) && doc.cm) { regLineChange(doc.cm, no, changeType); } return line } // The document is represented as a BTree consisting of leaves, with // chunk of lines in them, and branches, with up to ten leaves or // other branch nodes below them. The top node is always a branch // node, and is the document object itself (meaning it has // additional methods and properties). // // All nodes have parent links. The tree is used both to go from // line numbers to line objects, and to go from objects to numbers. // It also indexes by height, and is used to convert between height // and line object, and to find the total height of the document. // // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html function LeafChunk(lines) { this.lines = lines; this.parent = null; var height = 0; for (var i = 0; i < lines.length; ++i) { lines[i].parent = this; height += lines[i].height; } this.height = height; } LeafChunk.prototype = { chunkSize: function() { return this.lines.length }, // Remove the n lines at offset 'at'. removeInner: function(at, n) { for (var i = at, e = at + n; i < e; ++i) { var line = this.lines[i]; this.height -= line.height; cleanUpLine(line); signalLater(line, "delete"); } this.lines.splice(at, n); }, // Helper used to collapse a small branch into a single leaf. collapse: function(lines) { lines.push.apply(lines, this.lines); }, // Insert the given array of lines at offset 'at', count them as // having the given height. insertInner: function(at, lines, height) { this.height += height; this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at)); for (var i = 0; i < lines.length; ++i) { lines[i].parent = this; } }, // Used to iterate over a part of the tree. iterN: function(at, n, op) { for (var e = at + n; at < e; ++at) { if (op(this.lines[at])) { return true } } } }; function BranchChunk(children) { this.children = children; var size = 0, height = 0; for (var i = 0; i < children.length; ++i) { var ch = children[i]; size += ch.chunkSize(); height += ch.height; ch.parent = this; } this.size = size; this.height = height; this.parent = null; } BranchChunk.prototype = { chunkSize: function() { return this.size }, removeInner: function(at, n) { this.size -= n; for (var i = 0; i < this.children.length; ++i) { var child = this.children[i], sz = child.chunkSize(); if (at < sz) { var rm = Math.min(n, sz - at), oldHeight = child.height; child.removeInner(at, rm); this.height -= oldHeight - child.height; if (sz == rm) { this.children.splice(i--, 1); child.parent = null; } if ((n -= rm) == 0) { break } at = 0; } else { at -= sz; } } // If the result is smaller than 25 lines, ensure that it is a // single leaf node. if (this.size - n < 25 && (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) { var lines = []; this.collapse(lines); this.children = [new LeafChunk(lines)]; this.children[0].parent = this; } }, collapse: function(lines) { for (var i = 0; i < this.children.length; ++i) { this.children[i].collapse(lines); } }, insertInner: function(at, lines, height) { this.size += lines.length; this.height += height; for (var i = 0; i < this.children.length; ++i) { var child = this.children[i], sz = child.chunkSize(); if (at <= sz) { child.insertInner(at, lines, height); if (child.lines && child.lines.length > 50) { // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced. // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest. var remaining = child.lines.length % 25 + 25; for (var pos = remaining; pos < child.lines.length;) { var leaf = new LeafChunk(child.lines.slice(pos, pos += 25)); child.height -= leaf.height; this.children.splice(++i, 0, leaf); leaf.parent = this; } child.lines = child.lines.slice(0, remaining); this.maybeSpill(); } break } at -= sz; } }, // When a node has grown, check whether it should be split. maybeSpill: function() { if (this.children.length <= 10) { return } var me = this; do { var spilled = me.children.splice(me.children.length - 5, 5); var sibling = new BranchChunk(spilled); if (!me.parent) { // Become the parent node var copy = new BranchChunk(me.children); copy.parent = me; me.children = [copy, sibling]; me = copy; } else { me.size -= sibling.size; me.height -= sibling.height; var myIndex = indexOf(me.parent.children, me); me.parent.children.splice(myIndex + 1, 0, sibling); } sibling.parent = me.parent; } while (me.children.length > 10) me.parent.maybeSpill(); }, iterN: function(at, n, op) { for (var i = 0; i < this.children.length; ++i) { var child = this.children[i], sz = child.chunkSize(); if (at < sz) { var used = Math.min(n, sz - at); if (child.iterN(at, used, op)) { return true } if ((n -= used) == 0) { break } at = 0; } else { at -= sz; } } } }; // Line widgets are block elements displayed above or below a line. var LineWidget = function(doc, node, options) { if (options) { for (var opt in options) { if (options.hasOwnProperty(opt)) { this[opt] = options[opt]; } } } this.doc = doc; this.node = node; }; LineWidget.prototype.clear = function () { var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line); if (no == null || !ws) { return } for (var i = 0; i < ws.length; ++i) { if (ws[i] == this) { ws.splice(i--, 1); } } if (!ws.length) { line.widgets = null; } var height = widgetHeight(this); updateLineHeight(line, Math.max(0, line.height - height)); if (cm) { runInOp(cm, function () { adjustScrollWhenAboveVisible(cm, line, -height); regLineChange(cm, no, "widget"); }); signalLater(cm, "lineWidgetCleared", cm, this, no); } }; LineWidget.prototype.changed = function () { var this$1 = this; var oldH = this.height, cm = this.doc.cm, line = this.line; this.height = null; var diff = widgetHeight(this) - oldH; if (!diff) { return } if (!lineIsHidden(this.doc, line)) { updateLineHeight(line, line.height + diff); } if (cm) { runInOp(cm, function () { cm.curOp.forceUpdate = true; adjustScrollWhenAboveVisible(cm, line, diff); signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line)); }); } }; eventMixin(LineWidget); function adjustScrollWhenAboveVisible(cm, line, diff) { if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop)) { addToScrollTop(cm, diff); } } function addLineWidget(doc, handle, node, options) { var widget = new LineWidget(doc, node, options); var cm = doc.cm; if (cm && widget.noHScroll) { cm.display.alignWidgets = true; } changeLine(doc, handle, "widget", function (line) { var widgets = line.widgets || (line.widgets = []); if (widget.insertAt == null) { widgets.push(widget); } else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); } widget.line = line; if (cm && !lineIsHidden(doc, line)) { var aboveVisible = heightAtLine(line) < doc.scrollTop; updateLineHeight(line, line.height + widgetHeight(widget)); if (aboveVisible) { addToScrollTop(cm, widget.height); } cm.curOp.forceUpdate = true; } return true }); if (cm) { signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle)); } return widget } // TEXTMARKERS // Created with markText and setBookmark methods. A TextMarker is a // handle that can be used to clear or find a marked position in the // document. Line objects hold arrays (markedSpans) containing // {from, to, marker} object pointing to such marker objects, and // indicating that such a marker is present on that line. Multiple // lines may point to the same marker when it spans across lines. // The spans will have null for their from/to properties when the // marker continues beyond the start/end of the line. Markers have // links back to the lines they currently touch. // Collapsed markers have unique ids, in order to be able to order // them, which is needed for uniquely determining an outer marker // when they overlap (they may nest, but not partially overlap). var nextMarkerId = 0; var TextMarker = function(doc, type) { this.lines = []; this.type = type; this.doc = doc; this.id = ++nextMarkerId; }; // Clear the marker. TextMarker.prototype.clear = function () { if (this.explicitlyCleared) { return } var cm = this.doc.cm, withOp = cm && !cm.curOp; if (withOp) { startOperation(cm); } if (hasHandler(this, "clear")) { var found = this.find(); if (found) { signalLater(this, "clear", found.from, found.to); } } var min = null, max = null; for (var i = 0; i < this.lines.length; ++i) { var line = this.lines[i]; var span = getMarkedSpanFor(line.markedSpans, this); if (cm && !this.collapsed) { regLineChange(cm, lineNo(line), "text"); } else if (cm) { if (span.to != null) { max = lineNo(line); } if (span.from != null) { min = lineNo(line); } } line.markedSpans = removeMarkedSpan(line.markedSpans, span); if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm) { updateLineHeight(line, textHeight(cm.display)); } } if (cm && this.collapsed && !cm.options.lineWrapping) { for (var i$1 = 0; i$1 < this.lines.length; ++i$1) { var visual = visualLine(this.lines[i$1]), len = lineLength(visual); if (len > cm.display.maxLineLength) { cm.display.maxLine = visual; cm.display.maxLineLength = len; cm.display.maxLineChanged = true; } } } if (min != null && cm && this.collapsed) { regChange(cm, min, max + 1); } this.lines.length = 0; this.explicitlyCleared = true; if (this.atomic && this.doc.cantEdit) { this.doc.cantEdit = false; if (cm) { reCheckSelection(cm.doc); } } if (cm) { signalLater(cm, "markerCleared", cm, this, min, max); } if (withOp) { endOperation(cm); } if (this.parent) { this.parent.clear(); } }; // Find the position of the marker in the document. Returns a {from, // to} object by default. Side can be passed to get a specific side // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the // Pos objects returned contain a line object, rather than a line // number (used to prevent looking up the same line twice). TextMarker.prototype.find = function (side, lineObj) { if (side == null && this.type == "bookmark") { side = 1; } var from, to; for (var i = 0; i < this.lines.length; ++i) { var line = this.lines[i]; var span = getMarkedSpanFor(line.markedSpans, this); if (span.from != null) { from = Pos(lineObj ? line : lineNo(line), span.from); if (side == -1) { return from } } if (span.to != null) { to = Pos(lineObj ? line : lineNo(line), span.to); if (side == 1) { return to } } } return from && {from: from, to: to} }; // Signals that the marker's widget changed, and surrounding layout // should be recomputed. TextMarker.prototype.changed = function () { var this$1 = this; var pos = this.find(-1, true), widget = this, cm = this.doc.cm; if (!pos || !cm) { return } runInOp(cm, function () { var line = pos.line, lineN = lineNo(pos.line); var view = findViewForLine(cm, lineN); if (view) { clearLineMeasurementCacheFor(view); cm.curOp.selectionChanged = cm.curOp.forceUpdate = true; } cm.curOp.updateMaxLine = true; if (!lineIsHidden(widget.doc, line) && widget.height != null) { var oldHeight = widget.height; widget.height = null; var dHeight = widgetHeight(widget) - oldHeight; if (dHeight) { updateLineHeight(line, line.height + dHeight); } } signalLater(cm, "markerChanged", cm, this$1); }); }; TextMarker.prototype.attachLine = function (line) { if (!this.lines.length && this.doc.cm) { var op = this.doc.cm.curOp; if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1) { (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this); } } this.lines.push(line); }; TextMarker.prototype.detachLine = function (line) { this.lines.splice(indexOf(this.lines, line), 1); if (!this.lines.length && this.doc.cm) { var op = this.doc.cm.curOp ;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this); } }; eventMixin(TextMarker); // Create a marker, wire it up to the right lines, and function markText(doc, from, to, options, type) { // Shared markers (across linked documents) are handled separately // (markTextShared will call out to this again, once per // document). if (options && options.shared) { return markTextShared(doc, from, to, options, type) } // Ensure we are in an operation. if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, markText)(doc, from, to, options, type) } var marker = new TextMarker(doc, type), diff = cmp(from, to); if (options) { copyObj(options, marker, false); } // Don't connect empty markers unless clearWhenEmpty is false if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false) { return marker } if (marker.replacedWith) { // Showing up as a widget implies collapsed (widget replaces text) marker.collapsed = true; marker.widgetNode = eltP("span", [marker.replacedWith], "CodeMirror-widget"); if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true"); } if (options.insertLeft) { marker.widgetNode.insertLeft = true; } } if (marker.collapsed) { if (conflictingCollapsedRange(doc, from.line, from, to, marker) || from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker)) { throw new Error("Inserting collapsed marker partially overlapping an existing one") } seeCollapsedSpans(); } if (marker.addToHistory) { addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN); } var curLine = from.line, cm = doc.cm, updateMaxLine; doc.iter(curLine, to.line + 1, function (line) { if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine) { updateMaxLine = true; } if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0); } addMarkedSpan(line, new MarkedSpan(marker, curLine == from.line ? from.ch : null, curLine == to.line ? to.ch : null)); ++curLine; }); // lineIsHidden depends on the presence of the spans, so needs a second pass if (marker.collapsed) { doc.iter(from.line, to.line + 1, function (line) { if (lineIsHidden(doc, line)) { updateLineHeight(line, 0); } }); } if (marker.clearOnEnter) { on(marker, "beforeCursorEnter", function () { return marker.clear(); }); } if (marker.readOnly) { seeReadOnlySpans(); if (doc.history.done.length || doc.history.undone.length) { doc.clearHistory(); } } if (marker.collapsed) { marker.id = ++nextMarkerId; marker.atomic = true; } if (cm) { // Sync editor state if (updateMaxLine) { cm.curOp.updateMaxLine = true; } if (marker.collapsed) { regChange(cm, from.line, to.line + 1); } else if (marker.className || marker.startStyle || marker.endStyle || marker.css || marker.attributes || marker.title) { for (var i = from.line; i <= to.line; i++) { regLineChange(cm, i, "text"); } } if (marker.atomic) { reCheckSelection(cm.doc); } signalLater(cm, "markerAdded", cm, marker); } return marker } // SHARED TEXTMARKERS // A shared marker spans multiple linked documents. It is // implemented as a meta-marker-object controlling multiple normal // markers. var SharedTextMarker = function(markers, primary) { this.markers = markers; this.primary = primary; for (var i = 0; i < markers.length; ++i) { markers[i].parent = this; } }; SharedTextMarker.prototype.clear = function () { if (this.explicitlyCleared) { return } this.explicitlyCleared = true; for (var i = 0; i < this.markers.length; ++i) { this.markers[i].clear(); } signalLater(this, "clear"); }; SharedTextMarker.prototype.find = function (side, lineObj) { return this.primary.find(side, lineObj) }; eventMixin(SharedTextMarker); function markTextShared(doc, from, to, options, type) { options = copyObj(options); options.shared = false; var markers = [markText(doc, from, to, options, type)], primary = markers[0]; var widget = options.widgetNode; linkedDocs(doc, function (doc) { if (widget) { options.widgetNode = widget.cloneNode(true); } markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type)); for (var i = 0; i < doc.linked.length; ++i) { if (doc.linked[i].isParent) { return } } primary = lst(markers); }); return new SharedTextMarker(markers, primary) } function findSharedMarkers(doc) { return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) { return m.parent; }) } function copySharedMarkers(doc, markers) { for (var i = 0; i < markers.length; i++) { var marker = markers[i], pos = marker.find(); var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to); if (cmp(mFrom, mTo)) { var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type); marker.markers.push(subMark); subMark.parent = marker; } } } function detachSharedMarkers(markers) { var loop = function ( i ) { var marker = markers[i], linked = [marker.primary.doc]; linkedDocs(marker.primary.doc, function (d) { return linked.push(d); }); for (var j = 0; j < marker.markers.length; j++) { var subMarker = marker.markers[j]; if (indexOf(linked, subMarker.doc) == -1) { subMarker.parent = null; marker.markers.splice(j--, 1); } } }; for (var i = 0; i < markers.length; i++) loop( i ); } var nextDocId = 0; var Doc = function(text, mode, firstLine, lineSep, direction) { if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep, direction) } if (firstLine == null) { firstLine = 0; } BranchChunk.call(this, [new LeafChunk([new Line("", null)])]); this.first = firstLine; this.scrollTop = this.scrollLeft = 0; this.cantEdit = false; this.cleanGeneration = 1; this.modeFrontier = this.highlightFrontier = firstLine; var start = Pos(firstLine, 0); this.sel = simpleSelection(start); this.history = new History(null); this.id = ++nextDocId; this.modeOption = mode; this.lineSep = lineSep; this.direction = (direction == "rtl") ? "rtl" : "ltr"; this.extend = false; if (typeof text == "string") { text = this.splitLines(text); } updateDoc(this, {from: start, to: start, text: text}); setSelection(this, simpleSelection(start), sel_dontScroll); }; Doc.prototype = createObj(BranchChunk.prototype, { constructor: Doc, // Iterate over the document. Supports two forms -- with only one // argument, it calls that for each line in the document. With // three, it iterates over the range given by the first two (with // the second being non-inclusive). iter: function(from, to, op) { if (op) { this.iterN(from - this.first, to - from, op); } else { this.iterN(this.first, this.first + this.size, from); } }, // Non-public interface for adding and removing lines. insert: function(at, lines) { var height = 0; for (var i = 0; i < lines.length; ++i) { height += lines[i].height; } this.insertInner(at - this.first, lines, height); }, remove: function(at, n) { this.removeInner(at - this.first, n); }, // From here, the methods are part of the public interface. Most // are also available from CodeMirror (editor) instances. getValue: function(lineSep) { var lines = getLines(this, this.first, this.first + this.size); if (lineSep === false) { return lines } return lines.join(lineSep || this.lineSeparator()) }, setValue: docMethodOp(function(code) { var top = Pos(this.first, 0), last = this.first + this.size - 1; makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length), text: this.splitLines(code), origin: "setValue", full: true}, true); if (this.cm) { scrollToCoords(this.cm, 0, 0); } setSelection(this, simpleSelection(top), sel_dontScroll); }), replaceRange: function(code, from, to, origin) { from = clipPos(this, from); to = to ? clipPos(this, to) : from; replaceRange(this, code, from, to, origin); }, getRange: function(from, to, lineSep) { var lines = getBetween(this, clipPos(this, from), clipPos(this, to)); if (lineSep === false) { return lines } return lines.join(lineSep || this.lineSeparator()) }, getLine: function(line) {var l = this.getLineHandle(line); return l && l.text}, getLineHandle: function(line) {if (isLine(this, line)) { return getLine(this, line) }}, getLineNumber: function(line) {return lineNo(line)}, getLineHandleVisualStart: function(line) { if (typeof line == "number") { line = getLine(this, line); } return visualLine(line) }, lineCount: function() {return this.size}, firstLine: function() {return this.first}, lastLine: function() {return this.first + this.size - 1}, clipPos: function(pos) {return clipPos(this, pos)}, getCursor: function(start) { var range = this.sel.primary(), pos; if (start == null || start == "head") { pos = range.head; } else if (start == "anchor") { pos = range.anchor; } else if (start == "end" || start == "to" || start === false) { pos = range.to(); } else { pos = range.from(); } return pos }, listSelections: function() { return this.sel.ranges }, somethingSelected: function() {return this.sel.somethingSelected()}, setCursor: docMethodOp(function(line, ch, options) { setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options); }), setSelection: docMethodOp(function(anchor, head, options) { setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options); }), extendSelection: docMethodOp(function(head, other, options) { extendSelection(this, clipPos(this, head), other && clipPos(this, other), options); }), extendSelections: docMethodOp(function(heads, options) { extendSelections(this, clipPosArray(this, heads), options); }), extendSelectionsBy: docMethodOp(function(f, options) { var heads = map(this.sel.ranges, f); extendSelections(this, clipPosArray(this, heads), options); }), setSelections: docMethodOp(function(ranges, primary, options) { if (!ranges.length) { return } var out = []; for (var i = 0; i < ranges.length; i++) { out[i] = new Range(clipPos(this, ranges[i].anchor), clipPos(this, ranges[i].head)); } if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex); } setSelection(this, normalizeSelection(this.cm, out, primary), options); }), addSelection: docMethodOp(function(anchor, head, options) { var ranges = this.sel.ranges.slice(0); ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor))); setSelection(this, normalizeSelection(this.cm, ranges, ranges.length - 1), options); }), getSelection: function(lineSep) { var ranges = this.sel.ranges, lines; for (var i = 0; i < ranges.length; i++) { var sel = getBetween(this, ranges[i].from(), ranges[i].to()); lines = lines ? lines.concat(sel) : sel; } if (lineSep === false) { return lines } else { return lines.join(lineSep || this.lineSeparator()) } }, getSelections: function(lineSep) { var parts = [], ranges = this.sel.ranges; for (var i = 0; i < ranges.length; i++) { var sel = getBetween(this, ranges[i].from(), ranges[i].to()); if (lineSep !== false) { sel = sel.join(lineSep || this.lineSeparator()); } parts[i] = sel; } return parts }, replaceSelection: function(code, collapse, origin) { var dup = []; for (var i = 0; i < this.sel.ranges.length; i++) { dup[i] = code; } this.replaceSelections(dup, collapse, origin || "+input"); }, replaceSelections: docMethodOp(function(code, collapse, origin) { var changes = [], sel = this.sel; for (var i = 0; i < sel.ranges.length; i++) { var range = sel.ranges[i]; changes[i] = {from: range.from(), to: range.to(), text: this.splitLines(code[i]), origin: origin}; } var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse); for (var i$1 = changes.length - 1; i$1 >= 0; i$1--) { makeChange(this, changes[i$1]); } if (newSel) { setSelectionReplaceHistory(this, newSel); } else if (this.cm) { ensureCursorVisible(this.cm); } }), undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}), redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}), undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}), redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}), setExtending: function(val) {this.extend = val;}, getExtending: function() {return this.extend}, historySize: function() { var hist = this.history, done = 0, undone = 0; for (var i = 0; i < hist.done.length; i++) { if (!hist.done[i].ranges) { ++done; } } for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone; } } return {undo: done, redo: undone} }, clearHistory: function() { var this$1 = this; this.history = new History(this.history.maxGeneration); linkedDocs(this, function (doc) { return doc.history = this$1.history; }, true); }, markClean: function() { this.cleanGeneration = this.changeGeneration(true); }, changeGeneration: function(forceSplit) { if (forceSplit) { this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null; } return this.history.generation }, isClean: function (gen) { return this.history.generation == (gen || this.cleanGeneration) }, getHistory: function() { return {done: copyHistoryArray(this.history.done), undone: copyHistoryArray(this.history.undone)} }, setHistory: function(histData) { var hist = this.history = new History(this.history.maxGeneration); hist.done = copyHistoryArray(histData.done.slice(0), null, true); hist.undone = copyHistoryArray(histData.undone.slice(0), null, true); }, setGutterMarker: docMethodOp(function(line, gutterID, value) { return changeLine(this, line, "gutter", function (line) { var markers = line.gutterMarkers || (line.gutterMarkers = {}); markers[gutterID] = value; if (!value && isEmpty(markers)) { line.gutterMarkers = null; } return true }) }), clearGutter: docMethodOp(function(gutterID) { var this$1 = this; this.iter(function (line) { if (line.gutterMarkers && line.gutterMarkers[gutterID]) { changeLine(this$1, line, "gutter", function () { line.gutterMarkers[gutterID] = null; if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null; } return true }); } }); }), lineInfo: function(line) { var n; if (typeof line == "number") { if (!isLine(this, line)) { return null } n = line; line = getLine(this, line); if (!line) { return null } } else { n = lineNo(line); if (n == null) { return null } } return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers, textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass, widgets: line.widgets} }, addLineClass: docMethodOp(function(handle, where, cls) { return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) { var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : where == "gutter" ? "gutterClass" : "wrapClass"; if (!line[prop]) { line[prop] = cls; } else if (classTest(cls).test(line[prop])) { return false } else { line[prop] += " " + cls; } return true }) }), removeLineClass: docMethodOp(function(handle, where, cls) { return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) { var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : where == "gutter" ? "gutterClass" : "wrapClass"; var cur = line[prop]; if (!cur) { return false } else if (cls == null) { line[prop] = null; } else { var found = cur.match(classTest(cls)); if (!found) { return false } var end = found.index + found[0].length; line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null; } return true }) }), addLineWidget: docMethodOp(function(handle, node, options) { return addLineWidget(this, handle, node, options) }), removeLineWidget: function(widget) { widget.clear(); }, markText: function(from, to, options) { return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range") }, setBookmark: function(pos, options) { var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options), insertLeft: options && options.insertLeft, clearWhenEmpty: false, shared: options && options.shared, handleMouseEvents: options && options.handleMouseEvents}; pos = clipPos(this, pos); return markText(this, pos, pos, realOpts, "bookmark") }, findMarksAt: function(pos) { pos = clipPos(this, pos); var markers = [], spans = getLine(this, pos.line).markedSpans; if (spans) { for (var i = 0; i < spans.length; ++i) { var span = spans[i]; if ((span.from == null || span.from <= pos.ch) && (span.to == null || span.to >= pos.ch)) { markers.push(span.marker.parent || span.marker); } } } return markers }, findMarks: function(from, to, filter) { from = clipPos(this, from); to = clipPos(this, to); var found = [], lineNo = from.line; this.iter(from.line, to.line + 1, function (line) { var spans = line.markedSpans; if (spans) { for (var i = 0; i < spans.length; i++) { var span = spans[i]; if (!(span.to != null && lineNo == from.line && from.ch >= span.to || span.from == null && lineNo != from.line || span.from != null && lineNo == to.line && span.from >= to.ch) && (!filter || filter(span.marker))) { found.push(span.marker.parent || span.marker); } } } ++lineNo; }); return found }, getAllMarks: function() { var markers = []; this.iter(function (line) { var sps = line.markedSpans; if (sps) { for (var i = 0; i < sps.length; ++i) { if (sps[i].from != null) { markers.push(sps[i].marker); } } } }); return markers }, posFromIndex: function(off) { var ch, lineNo = this.first, sepSize = this.lineSeparator().length; this.iter(function (line) { var sz = line.text.length + sepSize; if (sz > off) { ch = off; return true } off -= sz; ++lineNo; }); return clipPos(this, Pos(lineNo, ch)) }, indexFromPos: function (coords) { coords = clipPos(this, coords); var index = coords.ch; if (coords.line < this.first || coords.ch < 0) { return 0 } var sepSize = this.lineSeparator().length; this.iter(this.first, coords.line, function (line) { // iter aborts when callback returns a truthy value index += line.text.length + sepSize; }); return index }, copy: function(copyHistory) { var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first, this.lineSep, this.direction); doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft; doc.sel = this.sel; doc.extend = false; if (copyHistory) { doc.history.undoDepth = this.history.undoDepth; doc.setHistory(this.getHistory()); } return doc }, linkedDoc: function(options) { if (!options) { options = {}; } var from = this.first, to = this.first + this.size; if (options.from != null && options.from > from) { from = options.from; } if (options.to != null && options.to < to) { to = options.to; } var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction); if (options.sharedHist) { copy.history = this.history ; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist}); copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}]; copySharedMarkers(copy, findSharedMarkers(this)); return copy }, unlinkDoc: function(other) { if (other instanceof CodeMirror) { other = other.doc; } if (this.linked) { for (var i = 0; i < this.linked.length; ++i) { var link = this.linked[i]; if (link.doc != other) { continue } this.linked.splice(i, 1); other.unlinkDoc(this); detachSharedMarkers(findSharedMarkers(this)); break } } // If the histories were shared, split them again if (other.history == this.history) { var splitIds = [other.id]; linkedDocs(other, function (doc) { return splitIds.push(doc.id); }, true); other.history = new History(null); other.history.done = copyHistoryArray(this.history.done, splitIds); other.history.undone = copyHistoryArray(this.history.undone, splitIds); } }, iterLinkedDocs: function(f) {linkedDocs(this, f);}, getMode: function() {return this.mode}, getEditor: function() {return this.cm}, splitLines: function(str) { if (this.lineSep) { return str.split(this.lineSep) } return splitLinesAuto(str) }, lineSeparator: function() { return this.lineSep || "\n" }, setDirection: docMethodOp(function (dir) { if (dir != "rtl") { dir = "ltr"; } if (dir == this.direction) { return } this.direction = dir; this.iter(function (line) { return line.order = null; }); if (this.cm) { directionChanged(this.cm); } }) }); // Public alias. Doc.prototype.eachLine = Doc.prototype.iter; // Kludge to work around strange IE behavior where it'll sometimes // re-fire a series of drag-related events right after the drop (#1551) var lastDrop = 0; function onDrop(e) { var cm = this; clearDragCursor(cm); if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return } e_preventDefault(e); if (ie) { lastDrop = +new Date; } var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files; if (!pos || cm.isReadOnly()) { return } // Might be a file drop, in which case we simply extract the text // and insert it. if (files && files.length && window.FileReader && window.File) { var n = files.length, text = Array(n), read = 0; var markAsReadAndPasteIfAllFilesAreRead = function () { if (++read == n) { operation(cm, function () { pos = clipPos(cm.doc, pos); var change = {from: pos, to: pos, text: cm.doc.splitLines( text.filter(function (t) { return t != null; }).join(cm.doc.lineSeparator())), origin: "paste"}; makeChange(cm.doc, change); setSelectionReplaceHistory(cm.doc, simpleSelection(clipPos(cm.doc, pos), clipPos(cm.doc, changeEnd(change)))); })(); } }; var readTextFromFile = function (file, i) { if (cm.options.allowDropFileTypes && indexOf(cm.options.allowDropFileTypes, file.type) == -1) { markAsReadAndPasteIfAllFilesAreRead(); return } var reader = new FileReader; reader.onerror = function () { return markAsReadAndPasteIfAllFilesAreRead(); }; reader.onload = function () { var content = reader.result; if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { markAsReadAndPasteIfAllFilesAreRead(); return } text[i] = content; markAsReadAndPasteIfAllFilesAreRead(); }; reader.readAsText(file); }; for (var i = 0; i < files.length; i++) { readTextFromFile(files[i], i); } } else { // Normal drop // Don't do a replace if the drop happened inside of the selected text. if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) { cm.state.draggingText(e); // Ensure the editor is re-focused setTimeout(function () { return cm.display.input.focus(); }, 20); return } try { var text$1 = e.dataTransfer.getData("Text"); if (text$1) { var selected; if (cm.state.draggingText && !cm.state.draggingText.copy) { selected = cm.listSelections(); } setSelectionNoUndo(cm.doc, simpleSelection(pos, pos)); if (selected) { for (var i$1 = 0; i$1 < selected.length; ++i$1) { replaceRange(cm.doc, "", selected[i$1].anchor, selected[i$1].head, "drag"); } } cm.replaceSelection(text$1, "around", "paste"); cm.display.input.focus(); } } catch(e$1){} } } function onDragStart(cm, e) { if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return } if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return } e.dataTransfer.setData("Text", cm.getSelection()); e.dataTransfer.effectAllowed = "copyMove"; // Use dummy image instead of default browsers image. // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there. if (e.dataTransfer.setDragImage && !safari) { var img = elt("img", null, null, "position: fixed; left: 0; top: 0;"); img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; if (presto) { img.width = img.height = 1; cm.display.wrapper.appendChild(img); // Force a relayout, or Opera won't use our image for some obscure reason img._top = img.offsetTop; } e.dataTransfer.setDragImage(img, 0, 0); if (presto) { img.parentNode.removeChild(img); } } } function onDragOver(cm, e) { var pos = posFromMouse(cm, e); if (!pos) { return } var frag = document.createDocumentFragment(); drawSelectionCursor(cm, pos, frag); if (!cm.display.dragCursor) { cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors"); cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv); } removeChildrenAndAdd(cm.display.dragCursor, frag); } function clearDragCursor(cm) { if (cm.display.dragCursor) { cm.display.lineSpace.removeChild(cm.display.dragCursor); cm.display.dragCursor = null; } } // These must be handled carefully, because naively registering a // handler for each editor will cause the editors to never be // garbage collected. function forEachCodeMirror(f) { if (!document.getElementsByClassName) { return } var byClass = document.getElementsByClassName("CodeMirror"), editors = []; for (var i = 0; i < byClass.length; i++) { var cm = byClass[i].CodeMirror; if (cm) { editors.push(cm); } } if (editors.length) { editors[0].operation(function () { for (var i = 0; i < editors.length; i++) { f(editors[i]); } }); } } var globalsRegistered = false; function ensureGlobalHandlers() { if (globalsRegistered) { return } registerGlobalHandlers(); globalsRegistered = true; } function registerGlobalHandlers() { // When the window resizes, we need to refresh active editors. var resizeTimer; on(window, "resize", function () { if (resizeTimer == null) { resizeTimer = setTimeout(function () { resizeTimer = null; forEachCodeMirror(onResize); }, 100); } }); // When the window loses focus, we want to show the editor as blurred on(window, "blur", function () { return forEachCodeMirror(onBlur); }); } // Called when the window resizes function onResize(cm) { var d = cm.display; // Might be a text scaling operation, clear size caches. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; d.scrollbarsClipped = false; cm.setSize(); } var keyNames = { 3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 145: "ScrollLock", 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete", 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert" }; // Number keys for (var i = 0; i < 10; i++) { keyNames[i + 48] = keyNames[i + 96] = String(i); } // Alphabetic keys for (var i$1 = 65; i$1 <= 90; i$1++) { keyNames[i$1] = String.fromCharCode(i$1); } // Function keys for (var i$2 = 1; i$2 <= 12; i$2++) { keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2; } var keyMap = {}; keyMap.basic = { "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown", "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown", "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore", "Tab": "defaultTab", "Shift-Tab": "indentAuto", "Enter": "newlineAndIndent", "Insert": "toggleOverwrite", "Esc": "singleSelection" }; // Note that the save and find-related commands aren't defined by // default. User code or addons can define them. Unknown commands // are simply ignored. keyMap.pcDefault = { "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo", "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown", "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd", "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find", "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll", "Ctrl-[": "indentLess", "Ctrl-]": "indentMore", "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection", "fallthrough": "basic" }; // Very basic readline/emacs-style bindings, which are standard on Mac. keyMap.emacsy = { "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown", "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars", "Ctrl-O": "openLine" }; keyMap.macDefault = { "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo", "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft", "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore", "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find", "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll", "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight", "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd", "fallthrough": ["basic", "emacsy"] }; keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault; // KEYMAP DISPATCH function normalizeKeyName(name) { var parts = name.split(/-(?!$)/); name = parts[parts.length - 1]; var alt, ctrl, shift, cmd; for (var i = 0; i < parts.length - 1; i++) { var mod = parts[i]; if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true; } else if (/^a(lt)?$/i.test(mod)) { alt = true; } else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true; } else if (/^s(hift)?$/i.test(mod)) { shift = true; } else { throw new Error("Unrecognized modifier name: " + mod) } } if (alt) { name = "Alt-" + name; } if (ctrl) { name = "Ctrl-" + name; } if (cmd) { name = "Cmd-" + name; } if (shift) { name = "Shift-" + name; } return name } // This is a kludge to keep keymaps mostly working as raw objects // (backwards compatibility) while at the same time support features // like normalization and multi-stroke key bindings. It compiles a // new normalized keymap, and then updates the old object to reflect // this. function normalizeKeyMap(keymap) { var copy = {}; for (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) { var value = keymap[keyname]; if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue } if (value == "...") { delete keymap[keyname]; continue } var keys = map(keyname.split(" "), normalizeKeyName); for (var i = 0; i < keys.length; i++) { var val = (void 0), name = (void 0); if (i == keys.length - 1) { name = keys.join(" "); val = value; } else { name = keys.slice(0, i + 1).join(" "); val = "..."; } var prev = copy[name]; if (!prev) { copy[name] = val; } else if (prev != val) { throw new Error("Inconsistent bindings for " + name) } } delete keymap[keyname]; } } for (var prop in copy) { keymap[prop] = copy[prop]; } return keymap } function lookupKey(key, map, handle, context) { map = getKeyMap(map); var found = map.call ? map.call(key, context) : map[key]; if (found === false) { return "nothing" } if (found === "...") { return "multi" } if (found != null && handle(found)) { return "handled" } if (map.fallthrough) { if (Object.prototype.toString.call(map.fallthrough) != "[object Array]") { return lookupKey(key, map.fallthrough, handle, context) } for (var i = 0; i < map.fallthrough.length; i++) { var result = lookupKey(key, map.fallthrough[i], handle, context); if (result) { return result } } } } // Modifier key presses don't count as 'real' key presses for the // purpose of keymap fallthrough. function isModifierKey(value) { var name = typeof value == "string" ? value : keyNames[value.keyCode]; return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod" } function addModifierNames(name, event, noShift) { var base = name; if (event.altKey && base != "Alt") { name = "Alt-" + name; } if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") { name = "Ctrl-" + name; } if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") { name = "Cmd-" + name; } if (!noShift && event.shiftKey && base != "Shift") { name = "Shift-" + name; } return name } // Look up the name of a key as indicated by an event object. function keyName(event, noShift) { if (presto && event.keyCode == 34 && event["char"]) { return false } var name = keyNames[event.keyCode]; if (name == null || event.altGraphKey) { return false } // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause, // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+) if (event.keyCode == 3 && event.code) { name = event.code; } return addModifierNames(name, event, noShift) } function getKeyMap(val) { return typeof val == "string" ? keyMap[val] : val } // Helper for deleting text near the selection(s), used to implement // backspace, delete, and similar functionality. function deleteNearSelection(cm, compute) { var ranges = cm.doc.sel.ranges, kill = []; // Build up a set of ranges to kill first, merging overlapping // ranges. for (var i = 0; i < ranges.length; i++) { var toKill = compute(ranges[i]); while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) { var replaced = kill.pop(); if (cmp(replaced.from, toKill.from) < 0) { toKill.from = replaced.from; break } } kill.push(toKill); } // Next, remove those actual ranges. runInOp(cm, function () { for (var i = kill.length - 1; i >= 0; i--) { replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); } ensureCursorVisible(cm); }); } function moveCharLogically(line, ch, dir) { var target = skipExtendingChars(line.text, ch + dir, dir); return target < 0 || target > line.text.length ? null : target } function moveLogically(line, start, dir) { var ch = moveCharLogically(line, start.ch, dir); return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before") } function endOfLine(visually, cm, lineObj, lineNo, dir) { if (visually) { if (cm.doc.direction == "rtl") { dir = -dir; } var order = getOrder(lineObj, cm.doc.direction); if (order) { var part = dir < 0 ? lst(order) : order[0]; var moveInStorageOrder = (dir < 0) == (part.level == 1); var sticky = moveInStorageOrder ? "after" : "before"; var ch; // With a wrapped rtl chunk (possibly spanning multiple bidi parts), // it could be that the last bidi part is not on the last visual line, // since visual lines contain content order-consecutive chunks. // Thus, in rtl, we are looking for the first (content-order) character // in the rtl chunk that is on the last line (that is, the same line // as the last (content-order) character). if (part.level > 0 || cm.doc.direction == "rtl") { var prep = prepareMeasureForLine(cm, lineObj); ch = dir < 0 ? lineObj.text.length - 1 : 0; var targetTop = measureCharPrepared(cm, prep, ch).top; ch = findFirst(function (ch) { return measureCharPrepared(cm, prep, ch).top == targetTop; }, (dir < 0) == (part.level == 1) ? part.from : part.to - 1, ch); if (sticky == "before") { ch = moveCharLogically(lineObj, ch, 1); } } else { ch = dir < 0 ? part.to : part.from; } return new Pos(lineNo, ch, sticky) } } return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after") } function moveVisually(cm, line, start, dir) { var bidi = getOrder(line, cm.doc.direction); if (!bidi) { return moveLogically(line, start, dir) } if (start.ch >= line.text.length) { start.ch = line.text.length; start.sticky = "before"; } else if (start.ch <= 0) { start.ch = 0; start.sticky = "after"; } var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos]; if (cm.doc.direction == "ltr" && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) { // Case 1: We move within an ltr part in an ltr editor. Even with wrapped lines, // nothing interesting happens. return moveLogically(line, start, dir) } var mv = function (pos, dir) { return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir); }; var prep; var getWrappedLineExtent = function (ch) { if (!cm.options.lineWrapping) { return {begin: 0, end: line.text.length} } prep = prep || prepareMeasureForLine(cm, line); return wrappedLineExtentChar(cm, line, prep, ch) }; var wrappedLineExtent = getWrappedLineExtent(start.sticky == "before" ? mv(start, -1) : start.ch); if (cm.doc.direction == "rtl" || part.level == 1) { var moveInStorageOrder = (part.level == 1) == (dir < 0); var ch = mv(start, moveInStorageOrder ? 1 : -1); if (ch != null && (!moveInStorageOrder ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end)) { // Case 2: We move within an rtl part or in an rtl editor on the same visual line var sticky = moveInStorageOrder ? "before" : "after"; return new Pos(start.line, ch, sticky) } } // Case 3: Could not move within this bidi part in this visual line, so leave // the current bidi part var searchInVisualLine = function (partPos, dir, wrappedLineExtent) { var getRes = function (ch, moveInStorageOrder) { return moveInStorageOrder ? new Pos(start.line, mv(ch, 1), "before") : new Pos(start.line, ch, "after"); }; for (; partPos >= 0 && partPos < bidi.length; partPos += dir) { var part = bidi[partPos]; var moveInStorageOrder = (dir > 0) == (part.level != 1); var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1); if (part.from <= ch && ch < part.to) { return getRes(ch, moveInStorageOrder) } ch = moveInStorageOrder ? part.from : mv(part.to, -1); if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) { return getRes(ch, moveInStorageOrder) } } }; // Case 3a: Look for other bidi parts on the same visual line var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent); if (res) { return res } // Case 3b: Look for other bidi parts on the next visual line var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1); if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) { res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh)); if (res) { return res } } // Case 4: Nowhere to move return null } // Commands are parameter-less actions that can be performed on an // editor, mostly used for keybindings. var commands = { selectAll: selectAll, singleSelection: function (cm) { return cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); }, killLine: function (cm) { return deleteNearSelection(cm, function (range) { if (range.empty()) { var len = getLine(cm.doc, range.head.line).text.length; if (range.head.ch == len && range.head.line < cm.lastLine()) { return {from: range.head, to: Pos(range.head.line + 1, 0)} } else { return {from: range.head, to: Pos(range.head.line, len)} } } else { return {from: range.from(), to: range.to()} } }); }, deleteLine: function (cm) { return deleteNearSelection(cm, function (range) { return ({ from: Pos(range.from().line, 0), to: clipPos(cm.doc, Pos(range.to().line + 1, 0)) }); }); }, delLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { return ({ from: Pos(range.from().line, 0), to: range.from() }); }); }, delWrappedLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { var top = cm.charCoords(range.head, "div").top + 5; var leftPos = cm.coordsChar({left: 0, top: top}, "div"); return {from: leftPos, to: range.from()} }); }, delWrappedLineRight: function (cm) { return deleteNearSelection(cm, function (range) { var top = cm.charCoords(range.head, "div").top + 5; var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div"); return {from: range.from(), to: rightPos } }); }, undo: function (cm) { return cm.undo(); }, redo: function (cm) { return cm.redo(); }, undoSelection: function (cm) { return cm.undoSelection(); }, redoSelection: function (cm) { return cm.redoSelection(); }, goDocStart: function (cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); }, goDocEnd: function (cm) { return cm.extendSelection(Pos(cm.lastLine())); }, goLineStart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStart(cm, range.head.line); }, {origin: "+move", bias: 1} ); }, goLineStartSmart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStartSmart(cm, range.head); }, {origin: "+move", bias: 1} ); }, goLineEnd: function (cm) { return cm.extendSelectionsBy(function (range) { return lineEnd(cm, range.head.line); }, {origin: "+move", bias: -1} ); }, goLineRight: function (cm) { return cm.extendSelectionsBy(function (range) { var top = cm.cursorCoords(range.head, "div").top + 5; return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div") }, sel_move); }, goLineLeft: function (cm) { return cm.extendSelectionsBy(function (range) { var top = cm.cursorCoords(range.head, "div").top + 5; return cm.coordsChar({left: 0, top: top}, "div") }, sel_move); }, goLineLeftSmart: function (cm) { return cm.extendSelectionsBy(function (range) { var top = cm.cursorCoords(range.head, "div").top + 5; var pos = cm.coordsChar({left: 0, top: top}, "div"); if (pos.ch < cm.getLine(pos.line).search(/\S/)) { return lineStartSmart(cm, range.head) } return pos }, sel_move); }, goLineUp: function (cm) { return cm.moveV(-1, "line"); }, goLineDown: function (cm) { return cm.moveV(1, "line"); }, goPageUp: function (cm) { return cm.moveV(-1, "page"); }, goPageDown: function (cm) { return cm.moveV(1, "page"); }, goCharLeft: function (cm) { return cm.moveH(-1, "char"); }, goCharRight: function (cm) { return cm.moveH(1, "char"); }, goColumnLeft: function (cm) { return cm.moveH(-1, "column"); }, goColumnRight: function (cm) { return cm.moveH(1, "column"); }, goWordLeft: function (cm) { return cm.moveH(-1, "word"); }, goGroupRight: function (cm) { return cm.moveH(1, "group"); }, goGroupLeft: function (cm) { return cm.moveH(-1, "group"); }, goWordRight: function (cm) { return cm.moveH(1, "word"); }, delCharBefore: function (cm) { return cm.deleteH(-1, "char"); }, delCharAfter: function (cm) { return cm.deleteH(1, "char"); }, delWordBefore: function (cm) { return cm.deleteH(-1, "word"); }, delWordAfter: function (cm) { return cm.deleteH(1, "word"); }, delGroupBefore: function (cm) { return cm.deleteH(-1, "group"); }, delGroupAfter: function (cm) { return cm.deleteH(1, "group"); }, indentAuto: function (cm) { return cm.indentSelection("smart"); }, indentMore: function (cm) { return cm.indentSelection("add"); }, indentLess: function (cm) { return cm.indentSelection("subtract"); }, insertTab: function (cm) { return cm.replaceSelection("\t"); }, insertSoftTab: function (cm) { var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize; for (var i = 0; i < ranges.length; i++) { var pos = ranges[i].from(); var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize); spaces.push(spaceStr(tabSize - col % tabSize)); } cm.replaceSelections(spaces); }, defaultTab: function (cm) { if (cm.somethingSelected()) { cm.indentSelection("add"); } else { cm.execCommand("insertTab"); } }, // Swap the two chars left and right of each selection's head. // Move cursor behind the two swapped characters afterwards. // // Doesn't consider line feeds a character. // Doesn't scan more than one line above to find a character. // Doesn't do anything on an empty line. // Doesn't do anything with non-empty selections. transposeChars: function (cm) { return runInOp(cm, function () { var ranges = cm.listSelections(), newSel = []; for (var i = 0; i < ranges.length; i++) { if (!ranges[i].empty()) { continue } var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text; if (line) { if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1); } if (cur.ch > 0) { cur = new Pos(cur.line, cur.ch + 1); cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2), Pos(cur.line, cur.ch - 2), cur, "+transpose"); } else if (cur.line > cm.doc.first) { var prev = getLine(cm.doc, cur.line - 1).text; if (prev) { cur = new Pos(cur.line, 1); cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() + prev.charAt(prev.length - 1), Pos(cur.line - 1, prev.length - 1), cur, "+transpose"); } } } newSel.push(new Range(cur, cur)); } cm.setSelections(newSel); }); }, newlineAndIndent: function (cm) { return runInOp(cm, function () { var sels = cm.listSelections(); for (var i = sels.length - 1; i >= 0; i--) { cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input"); } sels = cm.listSelections(); for (var i$1 = 0; i$1 < sels.length; i$1++) { cm.indentLine(sels[i$1].from().line, null, true); } ensureCursorVisible(cm); }); }, openLine: function (cm) { return cm.replaceSelection("\n", "start"); }, toggleOverwrite: function (cm) { return cm.toggleOverwrite(); } }; function lineStart(cm, lineN) { var line = getLine(cm.doc, lineN); var visual = visualLine(line); if (visual != line) { lineN = lineNo(visual); } return endOfLine(true, cm, visual, lineN, 1) } function lineEnd(cm, lineN) { var line = getLine(cm.doc, lineN); var visual = visualLineEnd(line); if (visual != line) { lineN = lineNo(visual); } return endOfLine(true, cm, line, lineN, -1) } function lineStartSmart(cm, pos) { var start = lineStart(cm, pos.line); var line = getLine(cm.doc, start.line); var order = getOrder(line, cm.doc.direction); if (!order || order[0].level == 0) { var firstNonWS = Math.max(start.ch, line.text.search(/\S/)); var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch; return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky) } return start } // Run a handler that was bound to a key. function doHandleBinding(cm, bound, dropShift) { if (typeof bound == "string") { bound = commands[bound]; if (!bound) { return false } } // Ensure previous input has been read, so that the handler sees a // consistent view of the document cm.display.input.ensurePolled(); var prevShift = cm.display.shift, done = false; try { if (cm.isReadOnly()) { cm.state.suppressEdits = true; } if (dropShift) { cm.display.shift = false; } done = bound(cm) != Pass; } finally { cm.display.shift = prevShift; cm.state.suppressEdits = false; } return done } function lookupKeyForEditor(cm, name, handle) { for (var i = 0; i < cm.state.keyMaps.length; i++) { var result = lookupKey(name, cm.state.keyMaps[i], handle, cm); if (result) { return result } } return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm)) || lookupKey(name, cm.options.keyMap, handle, cm) } // Note that, despite the name, this function is also used to check // for bound mouse clicks. var stopSeq = new Delayed; function dispatchKey(cm, name, e, handle) { var seq = cm.state.keySeq; if (seq) { if (isModifierKey(name)) { return "handled" } if (/\'$/.test(name)) { cm.state.keySeq = null; } else { stopSeq.set(50, function () { if (cm.state.keySeq == seq) { cm.state.keySeq = null; cm.display.input.reset(); } }); } if (dispatchKeyInner(cm, seq + " " + name, e, handle)) { return true } } return dispatchKeyInner(cm, name, e, handle) } function dispatchKeyInner(cm, name, e, handle) { var result = lookupKeyForEditor(cm, name, handle); if (result == "multi") { cm.state.keySeq = name; } if (result == "handled") { signalLater(cm, "keyHandled", cm, name, e); } if (result == "handled" || result == "multi") { e_preventDefault(e); restartBlink(cm); } return !!result } // Handle a key from the keydown event. function handleKeyBinding(cm, e) { var name = keyName(e, true); if (!name) { return false } if (e.shiftKey && !cm.state.keySeq) { // First try to resolve full name (including 'Shift-'). Failing // that, see if there is a cursor-motion command (starting with // 'go') bound to the keyname without 'Shift-'. return dispatchKey(cm, "Shift-" + name, e, function (b) { return doHandleBinding(cm, b, true); }) || dispatchKey(cm, name, e, function (b) { if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion) { return doHandleBinding(cm, b) } }) } else { return dispatchKey(cm, name, e, function (b) { return doHandleBinding(cm, b); }) } } // Handle a key from the keypress event function handleCharBinding(cm, e, ch) { return dispatchKey(cm, "'" + ch + "'", e, function (b) { return doHandleBinding(cm, b, true); }) } var lastStoppedKey = null; function onKeyDown(e) { var cm = this; if (e.target && e.target != cm.display.input.getField()) { return } cm.curOp.focus = activeElt(); if (signalDOMEvent(cm, e)) { return } // IE does strange things with escape. if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; } var code = e.keyCode; cm.display.shift = code == 16 || e.shiftKey; var handled = handleKeyBinding(cm, e); if (presto) { lastStoppedKey = handled ? code : null; // Opera has no cut event... we try to at least catch the key combo if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey)) { cm.replaceSelection("", null, "cut"); } } if (gecko && !mac && !handled && code == 46 && e.shiftKey && !e.ctrlKey && document.execCommand) { document.execCommand("cut"); } // Turn mouse into crosshair when Alt is held on Mac. if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className)) { showCrossHair(cm); } } function showCrossHair(cm) { var lineDiv = cm.display.lineDiv; addClass(lineDiv, "CodeMirror-crosshair"); function up(e) { if (e.keyCode == 18 || !e.altKey) { rmClass(lineDiv, "CodeMirror-crosshair"); off(document, "keyup", up); off(document, "mouseover", up); } } on(document, "keyup", up); on(document, "mouseover", up); } function onKeyUp(e) { if (e.keyCode == 16) { this.doc.sel.shift = false; } signalDOMEvent(this, e); } function onKeyPress(e) { var cm = this; if (e.target && e.target != cm.display.input.getField()) { return } if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return } var keyCode = e.keyCode, charCode = e.charCode; if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return} if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) { return } var ch = String.fromCharCode(charCode == null ? keyCode : charCode); // Some browsers fire keypress events for backspace if (ch == "\x08") { return } if (handleCharBinding(cm, e, ch)) { return } cm.display.input.onKeyPress(e); } var DOUBLECLICK_DELAY = 400; var PastClick = function(time, pos, button) { this.time = time; this.pos = pos; this.button = button; }; PastClick.prototype.compare = function (time, pos, button) { return this.time + DOUBLECLICK_DELAY > time && cmp(pos, this.pos) == 0 && button == this.button }; var lastClick, lastDoubleClick; function clickRepeat(pos, button) { var now = +new Date; if (lastDoubleClick && lastDoubleClick.compare(now, pos, button)) { lastClick = lastDoubleClick = null; return "triple" } else if (lastClick && lastClick.compare(now, pos, button)) { lastDoubleClick = new PastClick(now, pos, button); lastClick = null; return "double" } else { lastClick = new PastClick(now, pos, button); lastDoubleClick = null; return "single" } } // A mouse down can be a single click, double click, triple click, // start of selection drag, start of text drag, new cursor // (ctrl-click), rectangle drag (alt-drag), or xwin // middle-click-paste. Or it might be a click on something we should // not interfere with, such as a scrollbar or widget. function onMouseDown(e) { var cm = this, display = cm.display; if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return } display.input.ensurePolled(); display.shift = e.shiftKey; if (eventInWidget(display, e)) { if (!webkit) { // Briefly turn off draggability, to allow widgets to do // normal dragging things. display.scroller.draggable = false; setTimeout(function () { return display.scroller.draggable = true; }, 100); } return } if (clickInGutter(cm, e)) { return } var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single"; window.focus(); // #3261: make sure, that we're not starting a second selection if (button == 1 && cm.state.selectingText) { cm.state.selectingText(e); } if (pos && handleMappedButton(cm, button, pos, repeat, e)) { return } if (button == 1) { if (pos) { leftButtonDown(cm, pos, repeat, e); } else if (e_target(e) == display.scroller) { e_preventDefault(e); } } else if (button == 2) { if (pos) { extendSelection(cm.doc, pos); } setTimeout(function () { return display.input.focus(); }, 20); } else if (button == 3) { if (captureRightClick) { cm.display.input.onContextMenu(e); } else { delayBlurEvent(cm); } } } function handleMappedButton(cm, button, pos, repeat, event) { var name = "Click"; if (repeat == "double") { name = "Double" + name; } else if (repeat == "triple") { name = "Triple" + name; } name = (button == 1 ? "Left" : button == 2 ? "Middle" : "Right") + name; return dispatchKey(cm, addModifierNames(name, event), event, function (bound) { if (typeof bound == "string") { bound = commands[bound]; } if (!bound) { return false } var done = false; try { if (cm.isReadOnly()) { cm.state.suppressEdits = true; } done = bound(cm, pos) != Pass; } finally { cm.state.suppressEdits = false; } return done }) } function configureMouse(cm, repeat, event) { var option = cm.getOption("configureMouse"); var value = option ? option(cm, repeat, event) : {}; if (value.unit == null) { var rect = chromeOS ? event.shiftKey && event.metaKey : event.altKey; value.unit = rect ? "rectangle" : repeat == "single" ? "char" : repeat == "double" ? "word" : "line"; } if (value.extend == null || cm.doc.extend) { value.extend = cm.doc.extend || event.shiftKey; } if (value.addNew == null) { value.addNew = mac ? event.metaKey : event.ctrlKey; } if (value.moveOnDrag == null) { value.moveOnDrag = !(mac ? event.altKey : event.ctrlKey); } return value } function leftButtonDown(cm, pos, repeat, event) { if (ie) { setTimeout(bind(ensureFocus, cm), 0); } else { cm.curOp.focus = activeElt(); } var behavior = configureMouse(cm, repeat, event); var sel = cm.doc.sel, contained; if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() && repeat == "single" && (contained = sel.contains(pos)) > -1 && (cmp((contained = sel.ranges[contained]).from(), pos) < 0 || pos.xRel > 0) && (cmp(contained.to(), pos) > 0 || pos.xRel < 0)) { leftButtonStartDrag(cm, event, pos, behavior); } else { leftButtonSelect(cm, event, pos, behavior); } } // Start a text drag. When it ends, see if any dragging actually // happen, and treat as a click if it didn't. function leftButtonStartDrag(cm, event, pos, behavior) { var display = cm.display, moved = false; var dragEnd = operation(cm, function (e) { if (webkit) { display.scroller.draggable = false; } cm.state.draggingText = false; off(display.wrapper.ownerDocument, "mouseup", dragEnd); off(display.wrapper.ownerDocument, "mousemove", mouseMove); off(display.scroller, "dragstart", dragStart); off(display.scroller, "drop", dragEnd); if (!moved) { e_preventDefault(e); if (!behavior.addNew) { extendSelection(cm.doc, pos, null, null, behavior.extend); } // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081) if ((webkit && !safari) || ie && ie_version == 9) { setTimeout(function () {display.wrapper.ownerDocument.body.focus({preventScroll: true}); display.input.focus();}, 20); } else { display.input.focus(); } } }); var mouseMove = function(e2) { moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clientY - e2.clientY) >= 10; }; var dragStart = function () { return moved = true; }; // Let the drag handler handle this. if (webkit) { display.scroller.draggable = true; } cm.state.draggingText = dragEnd; dragEnd.copy = !behavior.moveOnDrag; // IE's approach to draggable if (display.scroller.dragDrop) { display.scroller.dragDrop(); } on(display.wrapper.ownerDocument, "mouseup", dragEnd); on(display.wrapper.ownerDocument, "mousemove", mouseMove); on(display.scroller, "dragstart", dragStart); on(display.scroller, "drop", dragEnd); delayBlurEvent(cm); setTimeout(function () { return display.input.focus(); }, 20); } function rangeForUnit(cm, pos, unit) { if (unit == "char") { return new Range(pos, pos) } if (unit == "word") { return cm.findWordAt(pos) } if (unit == "line") { return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))) } var result = unit(cm, pos); return new Range(result.from, result.to) } // Normal selection, as opposed to text dragging. function leftButtonSelect(cm, event, start, behavior) { var display = cm.display, doc = cm.doc; e_preventDefault(event); var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges; if (behavior.addNew && !behavior.extend) { ourIndex = doc.sel.contains(start); if (ourIndex > -1) { ourRange = ranges[ourIndex]; } else { ourRange = new Range(start, start); } } else { ourRange = doc.sel.primary(); ourIndex = doc.sel.primIndex; } if (behavior.unit == "rectangle") { if (!behavior.addNew) { ourRange = new Range(start, start); } start = posFromMouse(cm, event, true, true); ourIndex = -1; } else { var range = rangeForUnit(cm, start, behavior.unit); if (behavior.extend) { ourRange = extendRange(ourRange, range.anchor, range.head, behavior.extend); } else { ourRange = range; } } if (!behavior.addNew) { ourIndex = 0; setSelection(doc, new Selection([ourRange], 0), sel_mouse); startSel = doc.sel; } else if (ourIndex == -1) { ourIndex = ranges.length; setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex), {scroll: false, origin: "*mouse"}); } else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) { setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0), {scroll: false, origin: "*mouse"}); startSel = doc.sel; } else { replaceOneSelection(doc, ourIndex, ourRange, sel_mouse); } var lastPos = start; function extendTo(pos) { if (cmp(lastPos, pos) == 0) { return } lastPos = pos; if (behavior.unit == "rectangle") { var ranges = [], tabSize = cm.options.tabSize; var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize); var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize); var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol); for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); line <= end; line++) { var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize); if (left == right) { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); } else if (text.length > leftPos) { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); } } if (!ranges.length) { ranges.push(new Range(start, start)); } setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), {origin: "*mouse", scroll: false}); cm.scrollIntoView(pos); } else { var oldRange = ourRange; var range = rangeForUnit(cm, pos, behavior.unit); var anchor = oldRange.anchor, head; if (cmp(range.anchor, anchor) > 0) { head = range.head; anchor = minPos(oldRange.from(), range.anchor); } else { head = range.anchor; anchor = maxPos(oldRange.to(), range.head); } var ranges$1 = startSel.ranges.slice(0); ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head)); setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse); } } var editorSize = display.wrapper.getBoundingClientRect(); // Used to ensure timeout re-tries don't fire when another extend // happened in the meantime (clearTimeout isn't reliable -- at // least on Chrome, the timeouts still happen even when cleared, // if the clear happens after their scheduled firing time). var counter = 0; function extend(e) { var curCount = ++counter; var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle"); if (!cur) { return } if (cmp(cur, lastPos) != 0) { cm.curOp.focus = activeElt(); extendTo(cur); var visible = visibleLines(display, doc); if (cur.line >= visible.to || cur.line < visible.from) { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); } } else { var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0; if (outside) { setTimeout(operation(cm, function () { if (counter != curCount) { return } display.scroller.scrollTop += outside; extend(e); }), 50); } } } function done(e) { cm.state.selectingText = false; counter = Infinity; // If e is null or undefined we interpret this as someone trying // to explicitly cancel the selection rather than the user // letting go of the mouse button. if (e) { e_preventDefault(e); display.input.focus(); } off(display.wrapper.ownerDocument, "mousemove", move); off(display.wrapper.ownerDocument, "mouseup", up); doc.history.lastSelOrigin = null; } var move = operation(cm, function (e) { if (e.buttons === 0 || !e_button(e)) { done(e); } else { extend(e); } }); var up = operation(cm, done); cm.state.selectingText = up; on(display.wrapper.ownerDocument, "mousemove", move); on(display.wrapper.ownerDocument, "mouseup", up); } // Used when mouse-selecting to adjust the anchor to the proper side // of a bidi jump depending on the visual position of the head. function bidiSimplify(cm, range) { var anchor = range.anchor; var head = range.head; var anchorLine = getLine(cm.doc, anchor.line); if (cmp(anchor, head) == 0 && anchor.sticky == head.sticky) { return range } var order = getOrder(anchorLine); if (!order) { return range } var index = getBidiPartAt(order, anchor.ch, anchor.sticky), part = order[index]; if (part.from != anchor.ch && part.to != anchor.ch) { return range } var boundary = index + ((part.from == anchor.ch) == (part.level != 1) ? 0 : 1); if (boundary == 0 || boundary == order.length) { return range } // Compute the relative visual position of the head compared to the // anchor (<0 is to the left, >0 to the right) var leftSide; if (head.line != anchor.line) { leftSide = (head.line - anchor.line) * (cm.doc.direction == "ltr" ? 1 : -1) > 0; } else { var headIndex = getBidiPartAt(order, head.ch, head.sticky); var dir = headIndex - index || (head.ch - anchor.ch) * (part.level == 1 ? -1 : 1); if (headIndex == boundary - 1 || headIndex == boundary) { leftSide = dir < 0; } else { leftSide = dir > 0; } } var usePart = order[boundary + (leftSide ? -1 : 0)]; var from = leftSide == (usePart.level == 1); var ch = from ? usePart.from : usePart.to, sticky = from ? "after" : "before"; return anchor.ch == ch && anchor.sticky == sticky ? range : new Range(new Pos(anchor.line, ch, sticky), head) } // Determines whether an event happened in the gutter, and fires the // handlers for the corresponding event. function gutterEvent(cm, e, type, prevent) { var mX, mY; if (e.touches) { mX = e.touches[0].clientX; mY = e.touches[0].clientY; } else { try { mX = e.clientX; mY = e.clientY; } catch(e$1) { return false } } if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false } if (prevent) { e_preventDefault(e); } var display = cm.display; var lineBox = display.lineDiv.getBoundingClientRect(); if (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e) } mY -= lineBox.top - display.viewOffset; for (var i = 0; i < cm.display.gutterSpecs.length; ++i) { var g = display.gutters.childNodes[i]; if (g && g.getBoundingClientRect().right >= mX) { var line = lineAtHeight(cm.doc, mY); var gutter = cm.display.gutterSpecs[i]; signal(cm, type, cm, line, gutter.className, e); return e_defaultPrevented(e) } } } function clickInGutter(cm, e) { return gutterEvent(cm, e, "gutterClick", true) } // CONTEXT MENU HANDLING // To make the context menu work, we need to briefly unhide the // textarea (making it as unobtrusive as possible) to let the // right-click take effect on it. function onContextMenu(cm, e) { if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) { return } if (signalDOMEvent(cm, e, "contextmenu")) { return } if (!captureRightClick) { cm.display.input.onContextMenu(e); } } function contextMenuInGutter(cm, e) { if (!hasHandler(cm, "gutterContextMenu")) { return false } return gutterEvent(cm, e, "gutterContextMenu", false) } function themeChanged(cm) { cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-"); clearCaches(cm); } var Init = {toString: function(){return "CodeMirror.Init"}}; var defaults = {}; var optionHandlers = {}; function defineOptions(CodeMirror) { var optionHandlers = CodeMirror.optionHandlers; function option(name, deflt, handle, notOnInit) { CodeMirror.defaults[name] = deflt; if (handle) { optionHandlers[name] = notOnInit ? function (cm, val, old) {if (old != Init) { handle(cm, val, old); }} : handle; } } CodeMirror.defineOption = option; // Passed to option handlers when there is no old value. CodeMirror.Init = Init; // These two are, on init, called from the constructor because they // have to be initialized before the editor can start at all. option("value", "", function (cm, val) { return cm.setValue(val); }, true); option("mode", null, function (cm, val) { cm.doc.modeOption = val; loadMode(cm); }, true); option("indentUnit", 2, loadMode, true); option("indentWithTabs", false); option("smartIndent", true); option("tabSize", 4, function (cm) { resetModeState(cm); clearCaches(cm); regChange(cm); }, true); option("lineSeparator", null, function (cm, val) { cm.doc.lineSep = val; if (!val) { return } var newBreaks = [], lineNo = cm.doc.first; cm.doc.iter(function (line) { for (var pos = 0;;) { var found = line.text.indexOf(val, pos); if (found == -1) { break } pos = found + val.length; newBreaks.push(Pos(lineNo, found)); } lineNo++; }); for (var i = newBreaks.length - 1; i >= 0; i--) { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); } }); option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) { cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g"); if (old != Init) { cm.refresh(); } }); option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true); option("electricChars", true); option("inputStyle", mobile ? "contenteditable" : "textarea", function () { throw new Error("inputStyle can not (yet) be changed in a running editor") // FIXME }, true); option("spellcheck", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true); option("autocorrect", false, function (cm, val) { return cm.getInputField().autocorrect = val; }, true); option("autocapitalize", false, function (cm, val) { return cm.getInputField().autocapitalize = val; }, true); option("rtlMoveVisually", !windows); option("wholeLineUpdateBefore", true); option("theme", "default", function (cm) { themeChanged(cm); updateGutters(cm); }, true); option("keyMap", "default", function (cm, val, old) { var next = getKeyMap(val); var prev = old != Init && getKeyMap(old); if (prev && prev.detach) { prev.detach(cm, next); } if (next.attach) { next.attach(cm, prev || null); } }); option("extraKeys", null); option("configureMouse", null); option("lineWrapping", false, wrappingChanged, true); option("gutters", [], function (cm, val) { cm.display.gutterSpecs = getGutters(val, cm.options.lineNumbers); updateGutters(cm); }, true); option("fixedGutter", true, function (cm, val) { cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0"; cm.refresh(); }, true); option("coverGutterNextToScrollbar", false, function (cm) { return updateScrollbars(cm); }, true); option("scrollbarStyle", "native", function (cm) { initScrollbars(cm); updateScrollbars(cm); cm.display.scrollbars.setScrollTop(cm.doc.scrollTop); cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft); }, true); option("lineNumbers", false, function (cm, val) { cm.display.gutterSpecs = getGutters(cm.options.gutters, val); updateGutters(cm); }, true); option("firstLineNumber", 1, updateGutters, true); option("lineNumberFormatter", function (integer) { return integer; }, updateGutters, true); option("showCursorWhenSelecting", false, updateSelection, true); option("resetSelectionOnContextMenu", true); option("lineWiseCopyCut", true); option("pasteLinesPerSelection", true); option("selectionsMayTouch", false); option("readOnly", false, function (cm, val) { if (val == "nocursor") { onBlur(cm); cm.display.input.blur(); } cm.display.input.readOnlyChanged(val); }); option("screenReaderLabel", null, function (cm, val) { val = (val === '') ? null : val; cm.display.input.screenReaderLabelChanged(val); }); option("disableInput", false, function (cm, val) {if (!val) { cm.display.input.reset(); }}, true); option("dragDrop", true, dragDropChanged); option("allowDropFileTypes", null); option("cursorBlinkRate", 530); option("cursorScrollMargin", 0); option("cursorHeight", 1, updateSelection, true); option("singleCursorHeightPerLine", true, updateSelection, true); option("workTime", 100); option("workDelay", 100); option("flattenSpans", true, resetModeState, true); option("addModeClass", false, resetModeState, true); option("pollInterval", 100); option("undoDepth", 200, function (cm, val) { return cm.doc.history.undoDepth = val; }); option("historyEventDelay", 1250); option("viewportMargin", 10, function (cm) { return cm.refresh(); }, true); option("maxHighlightLength", 10000, resetModeState, true); option("moveInputWithCursor", true, function (cm, val) { if (!val) { cm.display.input.resetPosition(); } }); option("tabindex", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || ""; }); option("autofocus", null); option("direction", "ltr", function (cm, val) { return cm.doc.setDirection(val); }, true); option("phrases", null); } function dragDropChanged(cm, value, old) { var wasOn = old && old != Init; if (!value != !wasOn) { var funcs = cm.display.dragFunctions; var toggle = value ? on : off; toggle(cm.display.scroller, "dragstart", funcs.start); toggle(cm.display.scroller, "dragenter", funcs.enter); toggle(cm.display.scroller, "dragover", funcs.over); toggle(cm.display.scroller, "dragleave", funcs.leave); toggle(cm.display.scroller, "drop", funcs.drop); } } function wrappingChanged(cm) { if (cm.options.lineWrapping) { addClass(cm.display.wrapper, "CodeMirror-wrap"); cm.display.sizer.style.minWidth = ""; cm.display.sizerWidth = null; } else { rmClass(cm.display.wrapper, "CodeMirror-wrap"); findMaxLine(cm); } estimateLineHeights(cm); regChange(cm); clearCaches(cm); setTimeout(function () { return updateScrollbars(cm); }, 100); } // A CodeMirror instance represents an editor. This is the object // that user code is usually dealing with. function CodeMirror(place, options) { var this$1 = this; if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) } this.options = options = options ? copyObj(options) : {}; // Determine effective options based on given values and defaults. copyObj(defaults, options, false); var doc = options.value; if (typeof doc == "string") { doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction); } else if (options.mode) { doc.modeOption = options.mode; } this.doc = doc; var input = new CodeMirror.inputStyles[options.inputStyle](this); var display = this.display = new Display(place, doc, input, options); display.wrapper.CodeMirror = this; themeChanged(this); if (options.lineWrapping) { this.display.wrapper.className += " CodeMirror-wrap"; } initScrollbars(this); this.state = { keyMaps: [], // stores maps added by addKeyMap overlays: [], // highlighting overlays, as added by addOverlay modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info overwrite: false, delayingBlurEvent: false, focused: false, suppressEdits: false, // used to disable editing during key handlers when in readOnly mode pasteIncoming: -1, cutIncoming: -1, // help recognize paste/cut edits in input.poll selectingText: false, draggingText: false, highlight: new Delayed(), // stores highlight worker timeout keySeq: null, // Unfinished key sequence specialChars: null }; if (options.autofocus && !mobile) { display.input.focus(); } // Override magic textarea content restore that IE sometimes does // on our hidden textarea on reload if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20); } registerEventHandlers(this); ensureGlobalHandlers(); startOperation(this); this.curOp.forceUpdate = true; attachDoc(this, doc); if ((options.autofocus && !mobile) || this.hasFocus()) { setTimeout(bind(onFocus, this), 20); } else { onBlur(this); } for (var opt in optionHandlers) { if (optionHandlers.hasOwnProperty(opt)) { optionHandlers[opt](this, options[opt], Init); } } maybeUpdateLineNumberWidth(this); if (options.finishInit) { options.finishInit(this); } for (var i = 0; i < initHooks.length; ++i) { initHooks[i](this); } endOperation(this); // Suppress optimizelegibility in Webkit, since it breaks text // measuring on line wrapping boundaries. if (webkit && options.lineWrapping && getComputedStyle(display.lineDiv).textRendering == "optimizelegibility") { display.lineDiv.style.textRendering = "auto"; } } // The default configuration options. CodeMirror.defaults = defaults; // Functions to run when options are changed. CodeMirror.optionHandlers = optionHandlers; // Attach the necessary event handlers when initializing the editor function registerEventHandlers(cm) { var d = cm.display; on(d.scroller, "mousedown", operation(cm, onMouseDown)); // Older IE's will not fire a second mousedown for a double click if (ie && ie_version < 11) { on(d.scroller, "dblclick", operation(cm, function (e) { if (signalDOMEvent(cm, e)) { return } var pos = posFromMouse(cm, e); if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) { return } e_preventDefault(e); var word = cm.findWordAt(pos); extendSelection(cm.doc, word.anchor, word.head); })); } else { on(d.scroller, "dblclick", function (e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }); } // Some browsers fire contextmenu *after* opening the menu, at // which point we can't mess with it anymore. Context menu is // handled in onMouseDown for these browsers. on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); }); on(d.input.getField(), "contextmenu", function (e) { if (!d.scroller.contains(e.target)) { onContextMenu(cm, e); } }); // Used to suppress mouse event handling when a touch happens var touchFinished, prevTouch = {end: 0}; function finishTouch() { if (d.activeTouch) { touchFinished = setTimeout(function () { return d.activeTouch = null; }, 1000); prevTouch = d.activeTouch; prevTouch.end = +new Date; } } function isMouseLikeTouchEvent(e) { if (e.touches.length != 1) { return false } var touch = e.touches[0]; return touch.radiusX <= 1 && touch.radiusY <= 1 } function farAway(touch, other) { if (other.left == null) { return true } var dx = other.left - touch.left, dy = other.top - touch.top; return dx * dx + dy * dy > 20 * 20 } on(d.scroller, "touchstart", function (e) { if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e)) { d.input.ensurePolled(); clearTimeout(touchFinished); var now = +new Date; d.activeTouch = {start: now, moved: false, prev: now - prevTouch.end <= 300 ? prevTouch : null}; if (e.touches.length == 1) { d.activeTouch.left = e.touches[0].pageX; d.activeTouch.top = e.touches[0].pageY; } } }); on(d.scroller, "touchmove", function () { if (d.activeTouch) { d.activeTouch.moved = true; } }); on(d.scroller, "touchend", function (e) { var touch = d.activeTouch; if (touch && !eventInWidget(d, e) && touch.left != null && !touch.moved && new Date - touch.start < 300) { var pos = cm.coordsChar(d.activeTouch, "page"), range; if (!touch.prev || farAway(touch, touch.prev)) // Single tap { range = new Range(pos, pos); } else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap { range = cm.findWordAt(pos); } else // Triple tap { range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))); } cm.setSelection(range.anchor, range.head); cm.focus(); e_preventDefault(e); } finishTouch(); }); on(d.scroller, "touchcancel", finishTouch); // Sync scrolling between fake scrollbars and real scrollable // area, ensure viewport is updated when scrolling. on(d.scroller, "scroll", function () { if (d.scroller.clientHeight) { updateScrollTop(cm, d.scroller.scrollTop); setScrollLeft(cm, d.scroller.scrollLeft, true); signal(cm, "scroll", cm); } }); // Listen to wheel events in order to try and update the viewport on time. on(d.scroller, "mousewheel", function (e) { return onScrollWheel(cm, e); }); on(d.scroller, "DOMMouseScroll", function (e) { return onScrollWheel(cm, e); }); // Prevent wrapper from ever scrolling on(d.wrapper, "scroll", function () { return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; }); d.dragFunctions = { enter: function (e) {if (!signalDOMEvent(cm, e)) { e_stop(e); }}, over: function (e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }}, start: function (e) { return onDragStart(cm, e); }, drop: operation(cm, onDrop), leave: function (e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }} }; var inp = d.input.getField(); on(inp, "keyup", function (e) { return onKeyUp.call(cm, e); }); on(inp, "keydown", operation(cm, onKeyDown)); on(inp, "keypress", operation(cm, onKeyPress)); on(inp, "focus", function (e) { return onFocus(cm, e); }); on(inp, "blur", function (e) { return onBlur(cm, e); }); } var initHooks = []; CodeMirror.defineInitHook = function (f) { return initHooks.push(f); }; // Indent the given line. The how parameter can be "smart", // "add"/null, "subtract", or "prev". When aggressive is false // (typically set to true for forced single-line indents), empty // lines are not indented, and places where the mode returns Pass // are left alone. function indentLine(cm, n, how, aggressive) { var doc = cm.doc, state; if (how == null) { how = "add"; } if (how == "smart") { // Fall back to "prev" when the mode doesn't have an indentation // method. if (!doc.mode.indent) { how = "prev"; } else { state = getContextBefore(cm, n).state; } } var tabSize = cm.options.tabSize; var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize); if (line.stateAfter) { line.stateAfter = null; } var curSpaceString = line.text.match(/^\s*/)[0], indentation; if (!aggressive && !/\S/.test(line.text)) { indentation = 0; how = "not"; } else if (how == "smart") { indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text); if (indentation == Pass || indentation > 150) { if (!aggressive) { return } how = "prev"; } } if (how == "prev") { if (n > doc.first) { indentation = countColumn(getLine(doc, n-1).text, null, tabSize); } else { indentation = 0; } } else if (how == "add") { indentation = curSpace + cm.options.indentUnit; } else if (how == "subtract") { indentation = curSpace - cm.options.indentUnit; } else if (typeof how == "number") { indentation = curSpace + how; } indentation = Math.max(0, indentation); var indentString = "", pos = 0; if (cm.options.indentWithTabs) { for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";} } if (pos < indentation) { indentString += spaceStr(indentation - pos); } if (indentString != curSpaceString) { replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input"); line.stateAfter = null; return true } else { // Ensure that, if the cursor was in the whitespace at the start // of the line, it is moved to the end of that space. for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) { var range = doc.sel.ranges[i$1]; if (range.head.line == n && range.head.ch < curSpaceString.length) { var pos$1 = Pos(n, curSpaceString.length); replaceOneSelection(doc, i$1, new Range(pos$1, pos$1)); break } } } } // This will be set to a {lineWise: bool, text: [string]} object, so // that, when pasting, we know what kind of selections the copied // text was made out of. var lastCopied = null; function setLastCopied(newLastCopied) { lastCopied = newLastCopied; } function applyTextInput(cm, inserted, deleted, sel, origin) { var doc = cm.doc; cm.display.shift = false; if (!sel) { sel = doc.sel; } var recent = +new Date - 200; var paste = origin == "paste" || cm.state.pasteIncoming > recent; var textLines = splitLinesAuto(inserted), multiPaste = null; // When pasting N lines into N selections, insert one line per selection if (paste && sel.ranges.length > 1) { if (lastCopied && lastCopied.text.join("\n") == inserted) { if (sel.ranges.length % lastCopied.text.length == 0) { multiPaste = []; for (var i = 0; i < lastCopied.text.length; i++) { multiPaste.push(doc.splitLines(lastCopied.text[i])); } } } else if (textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection) { multiPaste = map(textLines, function (l) { return [l]; }); } } var updateInput = cm.curOp.updateInput; // Normal behavior is to insert the new text into every selection for (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) { var range = sel.ranges[i$1]; var from = range.from(), to = range.to(); if (range.empty()) { if (deleted && deleted > 0) // Handle deletion { from = Pos(from.line, from.ch - deleted); } else if (cm.state.overwrite && !paste) // Handle overwrite { to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); } else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == textLines.join("\n")) { from = to = Pos(from.line, 0); } } var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines, origin: origin || (paste ? "paste" : cm.state.cutIncoming > recent ? "cut" : "+input")}; makeChange(cm.doc, changeEvent); signalLater(cm, "inputRead", cm, changeEvent); } if (inserted && !paste) { triggerElectric(cm, inserted); } ensureCursorVisible(cm); if (cm.curOp.updateInput < 2) { cm.curOp.updateInput = updateInput; } cm.curOp.typing = true; cm.state.pasteIncoming = cm.state.cutIncoming = -1; } function handlePaste(e, cm) { var pasted = e.clipboardData && e.clipboardData.getData("Text"); if (pasted) { e.preventDefault(); if (!cm.isReadOnly() && !cm.options.disableInput) { runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }); } return true } } function triggerElectric(cm, inserted) { // When an 'electric' character is inserted, immediately trigger a reindent if (!cm.options.electricChars || !cm.options.smartIndent) { return } var sel = cm.doc.sel; for (var i = sel.ranges.length - 1; i >= 0; i--) { var range = sel.ranges[i]; if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) { continue } var mode = cm.getModeAt(range.head); var indented = false; if (mode.electricChars) { for (var j = 0; j < mode.electricChars.length; j++) { if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) { indented = indentLine(cm, range.head.line, "smart"); break } } } else if (mode.electricInput) { if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch))) { indented = indentLine(cm, range.head.line, "smart"); } } if (indented) { signalLater(cm, "electricInput", cm, range.head.line); } } } function copyableRanges(cm) { var text = [], ranges = []; for (var i = 0; i < cm.doc.sel.ranges.length; i++) { var line = cm.doc.sel.ranges[i].head.line; var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)}; ranges.push(lineRange); text.push(cm.getRange(lineRange.anchor, lineRange.head)); } return {text: text, ranges: ranges} } function disableBrowserMagic(field, spellcheck, autocorrect, autocapitalize) { field.setAttribute("autocorrect", autocorrect ? "" : "off"); field.setAttribute("autocapitalize", autocapitalize ? "" : "off"); field.setAttribute("spellcheck", !!spellcheck); } function hiddenTextarea() { var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"); var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); // The textarea is kept positioned near the cursor to prevent the // fact that it'll be scrolled into view on input from scrolling // our fake cursor out of view. On webkit, when wrap=off, paste is // very slow. So make the area wide instead. if (webkit) { te.style.width = "1000px"; } else { te.setAttribute("wrap", "off"); } // If border: 0; -- iOS fails to open keyboard (issue #1287) if (ios) { te.style.border = "1px solid black"; } disableBrowserMagic(te); return div } // The publicly visible API. Note that methodOp(f) means // 'wrap f in an operation, performed on its `this` parameter'. // This is not the complete set of editor methods. Most of the // methods defined on the Doc type are also injected into // CodeMirror.prototype, for backwards compatibility and // convenience. function addEditorMethods(CodeMirror) { var optionHandlers = CodeMirror.optionHandlers; var helpers = CodeMirror.helpers = {}; CodeMirror.prototype = { constructor: CodeMirror, focus: function(){window.focus(); this.display.input.focus();}, setOption: function(option, value) { var options = this.options, old = options[option]; if (options[option] == value && option != "mode") { return } options[option] = value; if (optionHandlers.hasOwnProperty(option)) { operation(this, optionHandlers[option])(this, value, old); } signal(this, "optionChange", this, option); }, getOption: function(option) {return this.options[option]}, getDoc: function() {return this.doc}, addKeyMap: function(map, bottom) { this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map)); }, removeKeyMap: function(map) { var maps = this.state.keyMaps; for (var i = 0; i < maps.length; ++i) { if (maps[i] == map || maps[i].name == map) { maps.splice(i, 1); return true } } }, addOverlay: methodOp(function(spec, options) { var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec); if (mode.startState) { throw new Error("Overlays may not be stateful.") } insertSorted(this.state.overlays, {mode: mode, modeSpec: spec, opaque: options && options.opaque, priority: (options && options.priority) || 0}, function (overlay) { return overlay.priority; }); this.state.modeGen++; regChange(this); }), removeOverlay: methodOp(function(spec) { var overlays = this.state.overlays; for (var i = 0; i < overlays.length; ++i) { var cur = overlays[i].modeSpec; if (cur == spec || typeof spec == "string" && cur.name == spec) { overlays.splice(i, 1); this.state.modeGen++; regChange(this); return } } }), indentLine: methodOp(function(n, dir, aggressive) { if (typeof dir != "string" && typeof dir != "number") { if (dir == null) { dir = this.options.smartIndent ? "smart" : "prev"; } else { dir = dir ? "add" : "subtract"; } } if (isLine(this.doc, n)) { indentLine(this, n, dir, aggressive); } }), indentSelection: methodOp(function(how) { var ranges = this.doc.sel.ranges, end = -1; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; if (!range.empty()) { var from = range.from(), to = range.to(); var start = Math.max(end, from.line); end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1; for (var j = start; j < end; ++j) { indentLine(this, j, how); } var newRanges = this.doc.sel.ranges; if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0) { replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll); } } else if (range.head.line > end) { indentLine(this, range.head.line, how, true); end = range.head.line; if (i == this.doc.sel.primIndex) { ensureCursorVisible(this); } } } }), // Fetch the parser token for a given character. Useful for hacks // that want to inspect the mode state (say, for completion). getTokenAt: function(pos, precise) { return takeToken(this, pos, precise) }, getLineTokens: function(line, precise) { return takeToken(this, Pos(line), precise, true) }, getTokenTypeAt: function(pos) { pos = clipPos(this.doc, pos); var styles = getLineStyles(this, getLine(this.doc, pos.line)); var before = 0, after = (styles.length - 1) / 2, ch = pos.ch; var type; if (ch == 0) { type = styles[2]; } else { for (;;) { var mid = (before + after) >> 1; if ((mid ? styles[mid * 2 - 1] : 0) >= ch) { after = mid; } else if (styles[mid * 2 + 1] < ch) { before = mid + 1; } else { type = styles[mid * 2 + 2]; break } } } var cut = type ? type.indexOf("overlay ") : -1; return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1) }, getModeAt: function(pos) { var mode = this.doc.mode; if (!mode.innerMode) { return mode } return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode }, getHelper: function(pos, type) { return this.getHelpers(pos, type)[0] }, getHelpers: function(pos, type) { var found = []; if (!helpers.hasOwnProperty(type)) { return found } var help = helpers[type], mode = this.getModeAt(pos); if (typeof mode[type] == "string") { if (help[mode[type]]) { found.push(help[mode[type]]); } } else if (mode[type]) { for (var i = 0; i < mode[type].length; i++) { var val = help[mode[type][i]]; if (val) { found.push(val); } } } else if (mode.helperType && help[mode.helperType]) { found.push(help[mode.helperType]); } else if (help[mode.name]) { found.push(help[mode.name]); } for (var i$1 = 0; i$1 < help._global.length; i$1++) { var cur = help._global[i$1]; if (cur.pred(mode, this) && indexOf(found, cur.val) == -1) { found.push(cur.val); } } return found }, getStateAfter: function(line, precise) { var doc = this.doc; line = clipLine(doc, line == null ? doc.first + doc.size - 1: line); return getContextBefore(this, line + 1, precise).state }, cursorCoords: function(start, mode) { var pos, range = this.doc.sel.primary(); if (start == null) { pos = range.head; } else if (typeof start == "object") { pos = clipPos(this.doc, start); } else { pos = start ? range.from() : range.to(); } return cursorCoords(this, pos, mode || "page") }, charCoords: function(pos, mode) { return charCoords(this, clipPos(this.doc, pos), mode || "page") }, coordsChar: function(coords, mode) { coords = fromCoordSystem(this, coords, mode || "page"); return coordsChar(this, coords.left, coords.top) }, lineAtHeight: function(height, mode) { height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top; return lineAtHeight(this.doc, height + this.display.viewOffset) }, heightAtLine: function(line, mode, includeWidgets) { var end = false, lineObj; if (typeof line == "number") { var last = this.doc.first + this.doc.size - 1; if (line < this.doc.first) { line = this.doc.first; } else if (line > last) { line = last; end = true; } lineObj = getLine(this.doc, line); } else { lineObj = line; } return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets || end).top + (end ? this.doc.height - heightAtLine(lineObj) : 0) }, defaultTextHeight: function() { return textHeight(this.display) }, defaultCharWidth: function() { return charWidth(this.display) }, getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}}, addWidget: function(pos, node, scroll, vert, horiz) { var display = this.display; pos = cursorCoords(this, clipPos(this.doc, pos)); var top = pos.bottom, left = pos.left; node.style.position = "absolute"; node.setAttribute("cm-ignore-events", "true"); this.display.input.setUneditable(node); display.sizer.appendChild(node); if (vert == "over") { top = pos.top; } else if (vert == "above" || vert == "near") { var vspace = Math.max(display.wrapper.clientHeight, this.doc.height), hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth); // Default to positioning above (if specified and possible); otherwise default to positioning below if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight) { top = pos.top - node.offsetHeight; } else if (pos.bottom + node.offsetHeight <= vspace) { top = pos.bottom; } if (left + node.offsetWidth > hspace) { left = hspace - node.offsetWidth; } } node.style.top = top + "px"; node.style.left = node.style.right = ""; if (horiz == "right") { left = display.sizer.clientWidth - node.offsetWidth; node.style.right = "0px"; } else { if (horiz == "left") { left = 0; } else if (horiz == "middle") { left = (display.sizer.clientWidth - node.offsetWidth) / 2; } node.style.left = left + "px"; } if (scroll) { scrollIntoView(this, {left: left, top: top, right: left + node.offsetWidth, bottom: top + node.offsetHeight}); } }, triggerOnKeyDown: methodOp(onKeyDown), triggerOnKeyPress: methodOp(onKeyPress), triggerOnKeyUp: onKeyUp, triggerOnMouseDown: methodOp(onMouseDown), execCommand: function(cmd) { if (commands.hasOwnProperty(cmd)) { return commands[cmd].call(null, this) } }, triggerElectric: methodOp(function(text) { triggerElectric(this, text); }), findPosH: function(from, amount, unit, visually) { var dir = 1; if (amount < 0) { dir = -1; amount = -amount; } var cur = clipPos(this.doc, from); for (var i = 0; i < amount; ++i) { cur = findPosH(this.doc, cur, dir, unit, visually); if (cur.hitSide) { break } } return cur }, moveH: methodOp(function(dir, unit) { var this$1 = this; this.extendSelectionsBy(function (range) { if (this$1.display.shift || this$1.doc.extend || range.empty()) { return findPosH(this$1.doc, range.head, dir, unit, this$1.options.rtlMoveVisually) } else { return dir < 0 ? range.from() : range.to() } }, sel_move); }), deleteH: methodOp(function(dir, unit) { var sel = this.doc.sel, doc = this.doc; if (sel.somethingSelected()) { doc.replaceSelection("", null, "+delete"); } else { deleteNearSelection(this, function (range) { var other = findPosH(doc, range.head, dir, unit, false); return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other} }); } }), findPosV: function(from, amount, unit, goalColumn) { var dir = 1, x = goalColumn; if (amount < 0) { dir = -1; amount = -amount; } var cur = clipPos(this.doc, from); for (var i = 0; i < amount; ++i) { var coords = cursorCoords(this, cur, "div"); if (x == null) { x = coords.left; } else { coords.left = x; } cur = findPosV(this, coords, dir, unit); if (cur.hitSide) { break } } return cur }, moveV: methodOp(function(dir, unit) { var this$1 = this; var doc = this.doc, goals = []; var collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected(); doc.extendSelectionsBy(function (range) { if (collapse) { return dir < 0 ? range.from() : range.to() } var headPos = cursorCoords(this$1, range.head, "div"); if (range.goalColumn != null) { headPos.left = range.goalColumn; } goals.push(headPos.left); var pos = findPosV(this$1, headPos, dir, unit); if (unit == "page" && range == doc.sel.primary()) { addToScrollTop(this$1, charCoords(this$1, pos, "div").top - headPos.top); } return pos }, sel_move); if (goals.length) { for (var i = 0; i < doc.sel.ranges.length; i++) { doc.sel.ranges[i].goalColumn = goals[i]; } } }), // Find the word at the given position (as returned by coordsChar). findWordAt: function(pos) { var doc = this.doc, line = getLine(doc, pos.line).text; var start = pos.ch, end = pos.ch; if (line) { var helper = this.getHelper(pos, "wordChars"); if ((pos.sticky == "before" || end == line.length) && start) { --start; } else { ++end; } var startChar = line.charAt(start); var check = isWordChar(startChar, helper) ? function (ch) { return isWordChar(ch, helper); } : /\s/.test(startChar) ? function (ch) { return /\s/.test(ch); } : function (ch) { return (!/\s/.test(ch) && !isWordChar(ch)); }; while (start > 0 && check(line.charAt(start - 1))) { --start; } while (end < line.length && check(line.charAt(end))) { ++end; } } return new Range(Pos(pos.line, start), Pos(pos.line, end)) }, toggleOverwrite: function(value) { if (value != null && value == this.state.overwrite) { return } if (this.state.overwrite = !this.state.overwrite) { addClass(this.display.cursorDiv, "CodeMirror-overwrite"); } else { rmClass(this.display.cursorDiv, "CodeMirror-overwrite"); } signal(this, "overwriteToggle", this, this.state.overwrite); }, hasFocus: function() { return this.display.input.getField() == activeElt() }, isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) }, scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }), getScrollInfo: function() { var scroller = this.display.scroller; return {left: scroller.scrollLeft, top: scroller.scrollTop, height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight, width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth, clientHeight: displayHeight(this), clientWidth: displayWidth(this)} }, scrollIntoView: methodOp(function(range, margin) { if (range == null) { range = {from: this.doc.sel.primary().head, to: null}; if (margin == null) { margin = this.options.cursorScrollMargin; } } else if (typeof range == "number") { range = {from: Pos(range, 0), to: null}; } else if (range.from == null) { range = {from: range, to: null}; } if (!range.to) { range.to = range.from; } range.margin = margin || 0; if (range.from.line != null) { scrollToRange(this, range); } else { scrollToCoordsRange(this, range.from, range.to, range.margin); } }), setSize: methodOp(function(width, height) { var this$1 = this; var interpret = function (val) { return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; }; if (width != null) { this.display.wrapper.style.width = interpret(width); } if (height != null) { this.display.wrapper.style.height = interpret(height); } if (this.options.lineWrapping) { clearLineMeasurementCache(this); } var lineNo = this.display.viewFrom; this.doc.iter(lineNo, this.display.viewTo, function (line) { if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) { if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo, "widget"); break } } } ++lineNo; }); this.curOp.forceUpdate = true; signal(this, "refresh", this); }), operation: function(f){return runInOp(this, f)}, startOperation: function(){return startOperation(this)}, endOperation: function(){return endOperation(this)}, refresh: methodOp(function() { var oldHeight = this.display.cachedTextHeight; regChange(this); this.curOp.forceUpdate = true; clearCaches(this); scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop); updateGutterSpace(this.display); if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5 || this.options.lineWrapping) { estimateLineHeights(this); } signal(this, "refresh", this); }), swapDoc: methodOp(function(doc) { var old = this.doc; old.cm = null; // Cancel the current text selection if any (#5821) if (this.state.selectingText) { this.state.selectingText(); } attachDoc(this, doc); clearCaches(this); this.display.input.reset(); scrollToCoords(this, doc.scrollLeft, doc.scrollTop); this.curOp.forceScroll = true; signalLater(this, "swapDoc", this, old); return old }), phrase: function(phraseText) { var phrases = this.options.phrases; return phrases && Object.prototype.hasOwnProperty.call(phrases, phraseText) ? phrases[phraseText] : phraseText }, getInputField: function(){return this.display.input.getField()}, getWrapperElement: function(){return this.display.wrapper}, getScrollerElement: function(){return this.display.scroller}, getGutterElement: function(){return this.display.gutters} }; eventMixin(CodeMirror); CodeMirror.registerHelper = function(type, name, value) { if (!helpers.hasOwnProperty(type)) { helpers[type] = CodeMirror[type] = {_global: []}; } helpers[type][name] = value; }; CodeMirror.registerGlobalHelper = function(type, name, predicate, value) { CodeMirror.registerHelper(type, name, value); helpers[type]._global.push({pred: predicate, val: value}); }; } // Used for horizontal relative motion. Dir is -1 or 1 (left or // right), unit can be "char", "column" (like char, but doesn't // cross line boundaries), "word" (across next word), or "group" (to // the start of next group of word or non-word-non-whitespace // chars). The visually param controls whether, in right-to-left // text, direction 1 means to move towards the next index in the // string, or towards the character to the right of the current // position. The resulting position will have a hitSide=true // property if it reached the end of the document. function findPosH(doc, pos, dir, unit, visually) { var oldPos = pos; var origDir = dir; var lineObj = getLine(doc, pos.line); var lineDir = visually && doc.direction == "rtl" ? -dir : dir; function findNextLine() { var l = pos.line + lineDir; if (l < doc.first || l >= doc.first + doc.size) { return false } pos = new Pos(l, pos.ch, pos.sticky); return lineObj = getLine(doc, l) } function moveOnce(boundToLine) { var next; if (visually) { next = moveVisually(doc.cm, lineObj, pos, dir); } else { next = moveLogically(lineObj, pos, dir); } if (next == null) { if (!boundToLine && findNextLine()) { pos = endOfLine(visually, doc.cm, lineObj, pos.line, lineDir); } else { return false } } else { pos = next; } return true } if (unit == "char") { moveOnce(); } else if (unit == "column") { moveOnce(true); } else if (unit == "word" || unit == "group") { var sawType = null, group = unit == "group"; var helper = doc.cm && doc.cm.getHelper(pos, "wordChars"); for (var first = true;; first = false) { if (dir < 0 && !moveOnce(!first)) { break } var cur = lineObj.text.charAt(pos.ch) || "\n"; var type = isWordChar(cur, helper) ? "w" : group && cur == "\n" ? "n" : !group || /\s/.test(cur) ? null : "p"; if (group && !first && !type) { type = "s"; } if (sawType && sawType != type) { if (dir < 0) {dir = 1; moveOnce(); pos.sticky = "after";} break } if (type) { sawType = type; } if (dir > 0 && !moveOnce(!first)) { break } } } var result = skipAtomic(doc, pos, oldPos, origDir, true); if (equalCursorPos(oldPos, result)) { result.hitSide = true; } return result } // For relative vertical movement. Dir may be -1 or 1. Unit can be // "page" or "line". The resulting position will have a hitSide=true // property if it reached the end of the document. function findPosV(cm, pos, dir, unit) { var doc = cm.doc, x = pos.left, y; if (unit == "page") { var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight); var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3); y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount; } else if (unit == "line") { y = dir > 0 ? pos.bottom + 3 : pos.top - 3; } var target; for (;;) { target = coordsChar(cm, x, y); if (!target.outside) { break } if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break } y += dir * 5; } return target } // CONTENTEDITABLE INPUT STYLE var ContentEditableInput = function(cm) { this.cm = cm; this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null; this.polling = new Delayed(); this.composing = null; this.gracePeriod = false; this.readDOMTimeout = null; }; ContentEditableInput.prototype.init = function (display) { var this$1 = this; var input = this, cm = input.cm; var div = input.div = display.lineDiv; disableBrowserMagic(div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize); function belongsToInput(e) { for (var t = e.target; t; t = t.parentNode) { if (t == div) { return true } if (/\bCodeMirror-(?:line)?widget\b/.test(t.className)) { break } } return false } on(div, "paste", function (e) { if (!belongsToInput(e) || signalDOMEvent(cm, e) || handlePaste(e, cm)) { return } // IE doesn't fire input events, so we schedule a read for the pasted content in this way if (ie_version <= 11) { setTimeout(operation(cm, function () { return this$1.updateFromDOM(); }), 20); } }); on(div, "compositionstart", function (e) { this$1.composing = {data: e.data, done: false}; }); on(div, "compositionupdate", function (e) { if (!this$1.composing) { this$1.composing = {data: e.data, done: false}; } }); on(div, "compositionend", function (e) { if (this$1.composing) { if (e.data != this$1.composing.data) { this$1.readFromDOMSoon(); } this$1.composing.done = true; } }); on(div, "touchstart", function () { return input.forceCompositionEnd(); }); on(div, "input", function () { if (!this$1.composing) { this$1.readFromDOMSoon(); } }); function onCopyCut(e) { if (!belongsToInput(e) || signalDOMEvent(cm, e)) { return } if (cm.somethingSelected()) { setLastCopied({lineWise: false, text: cm.getSelections()}); if (e.type == "cut") { cm.replaceSelection("", null, "cut"); } } else if (!cm.options.lineWiseCopyCut) { return } else { var ranges = copyableRanges(cm); setLastCopied({lineWise: true, text: ranges.text}); if (e.type == "cut") { cm.operation(function () { cm.setSelections(ranges.ranges, 0, sel_dontScroll); cm.replaceSelection("", null, "cut"); }); } } if (e.clipboardData) { e.clipboardData.clearData(); var content = lastCopied.text.join("\n"); // iOS exposes the clipboard API, but seems to discard content inserted into it e.clipboardData.setData("Text", content); if (e.clipboardData.getData("Text") == content) { e.preventDefault(); return } } // Old-fashioned briefly-focus-a-textarea hack var kludge = hiddenTextarea(), te = kludge.firstChild; cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild); te.value = lastCopied.text.join("\n"); var hadFocus = document.activeElement; selectInput(te); setTimeout(function () { cm.display.lineSpace.removeChild(kludge); hadFocus.focus(); if (hadFocus == div) { input.showPrimarySelection(); } }, 50); } on(div, "copy", onCopyCut); on(div, "cut", onCopyCut); }; ContentEditableInput.prototype.screenReaderLabelChanged = function (label) { // Label for screenreaders, accessibility if(label) { this.div.setAttribute('aria-label', label); } else { this.div.removeAttribute('aria-label'); } }; ContentEditableInput.prototype.prepareSelection = function () { var result = prepareSelection(this.cm, false); result.focus = document.activeElement == this.div; return result }; ContentEditableInput.prototype.showSelection = function (info, takeFocus) { if (!info || !this.cm.display.view.length) { return } if (info.focus || takeFocus) { this.showPrimarySelection(); } this.showMultipleSelections(info); }; ContentEditableInput.prototype.getSelection = function () { return this.cm.display.wrapper.ownerDocument.getSelection() }; ContentEditableInput.prototype.showPrimarySelection = function () { var sel = this.getSelection(), cm = this.cm, prim = cm.doc.sel.primary(); var from = prim.from(), to = prim.to(); if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) { sel.removeAllRanges(); return } var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset); var curFocus = domToPos(cm, sel.focusNode, sel.focusOffset); if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad && cmp(minPos(curAnchor, curFocus), from) == 0 && cmp(maxPos(curAnchor, curFocus), to) == 0) { return } var view = cm.display.view; var start = (from.line >= cm.display.viewFrom && posToDOM(cm, from)) || {node: view[0].measure.map[2], offset: 0}; var end = to.line < cm.display.viewTo && posToDOM(cm, to); if (!end) { var measure = view[view.length - 1].measure; var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map; end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]}; } if (!start || !end) { sel.removeAllRanges(); return } var old = sel.rangeCount && sel.getRangeAt(0), rng; try { rng = range(start.node, start.offset, end.offset, end.node); } catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible if (rng) { if (!gecko && cm.state.focused) { sel.collapse(start.node, start.offset); if (!rng.collapsed) { sel.removeAllRanges(); sel.addRange(rng); } } else { sel.removeAllRanges(); sel.addRange(rng); } if (old && sel.anchorNode == null) { sel.addRange(old); } else if (gecko) { this.startGracePeriod(); } } this.rememberSelection(); }; ContentEditableInput.prototype.startGracePeriod = function () { var this$1 = this; clearTimeout(this.gracePeriod); this.gracePeriod = setTimeout(function () { this$1.gracePeriod = false; if (this$1.selectionChanged()) { this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }); } }, 20); }; ContentEditableInput.prototype.showMultipleSelections = function (info) { removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors); removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection); }; ContentEditableInput.prototype.rememberSelection = function () { var sel = this.getSelection(); this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset; this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset; }; ContentEditableInput.prototype.selectionInEditor = function () { var sel = this.getSelection(); if (!sel.rangeCount) { return false } var node = sel.getRangeAt(0).commonAncestorContainer; return contains(this.div, node) }; ContentEditableInput.prototype.focus = function () { if (this.cm.options.readOnly != "nocursor") { if (!this.selectionInEditor() || document.activeElement != this.div) { this.showSelection(this.prepareSelection(), true); } this.div.focus(); } }; ContentEditableInput.prototype.blur = function () { this.div.blur(); }; ContentEditableInput.prototype.getField = function () { return this.div }; ContentEditableInput.prototype.supportsTouch = function () { return true }; ContentEditableInput.prototype.receivedFocus = function () { var input = this; if (this.selectionInEditor()) { this.pollSelection(); } else { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }); } function poll() { if (input.cm.state.focused) { input.pollSelection(); input.polling.set(input.cm.options.pollInterval, poll); } } this.polling.set(this.cm.options.pollInterval, poll); }; ContentEditableInput.prototype.selectionChanged = function () { var sel = this.getSelection(); return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset }; ContentEditableInput.prototype.pollSelection = function () { if (this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged()) { return } var sel = this.getSelection(), cm = this.cm; // On Android Chrome (version 56, at least), backspacing into an // uneditable block element will put the cursor in that element, // and then, because it's not editable, hide the virtual keyboard. // Because Android doesn't allow us to actually detect backspace // presses in a sane way, this code checks for when that happens // and simulates a backspace press in this case. if (android && chrome && this.cm.display.gutterSpecs.length && isInGutter(sel.anchorNode)) { this.cm.triggerOnKeyDown({type: "keydown", keyCode: 8, preventDefault: Math.abs}); this.blur(); this.focus(); return } if (this.composing) { return } this.rememberSelection(); var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset); var head = domToPos(cm, sel.focusNode, sel.focusOffset); if (anchor && head) { runInOp(cm, function () { setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll); if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true; } }); } }; ContentEditableInput.prototype.pollContent = function () { if (this.readDOMTimeout != null) { clearTimeout(this.readDOMTimeout); this.readDOMTimeout = null; } var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary(); var from = sel.from(), to = sel.to(); if (from.ch == 0 && from.line > cm.firstLine()) { from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length); } if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine()) { to = Pos(to.line + 1, 0); } if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false } var fromIndex, fromLine, fromNode; if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) { fromLine = lineNo(display.view[0].line); fromNode = display.view[0].node; } else { fromLine = lineNo(display.view[fromIndex].line); fromNode = display.view[fromIndex - 1].node.nextSibling; } var toIndex = findViewIndex(cm, to.line); var toLine, toNode; if (toIndex == display.view.length - 1) { toLine = display.viewTo - 1; toNode = display.lineDiv.lastChild; } else { toLine = lineNo(display.view[toIndex + 1].line) - 1; toNode = display.view[toIndex + 1].node.previousSibling; } if (!fromNode) { return false } var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine)); var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length)); while (newText.length > 1 && oldText.length > 1) { if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; } else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; } else { break } } var cutFront = 0, cutEnd = 0; var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length); while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront)) { ++cutFront; } var newBot = lst(newText), oldBot = lst(oldText); var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0), oldBot.length - (oldText.length == 1 ? cutFront : 0)); while (cutEnd < maxCutEnd && newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) { ++cutEnd; } // Try to move start of change to start of selection if ambiguous if (newText.length == 1 && oldText.length == 1 && fromLine == from.line) { while (cutFront && cutFront > from.ch && newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) { cutFront--; cutEnd++; } } newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, ""); newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, ""); var chFrom = Pos(fromLine, cutFront); var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0); if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) { replaceRange(cm.doc, newText, chFrom, chTo, "+input"); return true } }; ContentEditableInput.prototype.ensurePolled = function () { this.forceCompositionEnd(); }; ContentEditableInput.prototype.reset = function () { this.forceCompositionEnd(); }; ContentEditableInput.prototype.forceCompositionEnd = function () { if (!this.composing) { return } clearTimeout(this.readDOMTimeout); this.composing = null; this.updateFromDOM(); this.div.blur(); this.div.focus(); }; ContentEditableInput.prototype.readFromDOMSoon = function () { var this$1 = this; if (this.readDOMTimeout != null) { return } this.readDOMTimeout = setTimeout(function () { this$1.readDOMTimeout = null; if (this$1.composing) { if (this$1.composing.done) { this$1.composing = null; } else { return } } this$1.updateFromDOM(); }, 80); }; ContentEditableInput.prototype.updateFromDOM = function () { var this$1 = this; if (this.cm.isReadOnly() || !this.pollContent()) { runInOp(this.cm, function () { return regChange(this$1.cm); }); } }; ContentEditableInput.prototype.setUneditable = function (node) { node.contentEditable = "false"; }; ContentEditableInput.prototype.onKeyPress = function (e) { if (e.charCode == 0 || this.composing) { return } e.preventDefault(); if (!this.cm.isReadOnly()) { operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0); } }; ContentEditableInput.prototype.readOnlyChanged = function (val) { this.div.contentEditable = String(val != "nocursor"); }; ContentEditableInput.prototype.onContextMenu = function () {}; ContentEditableInput.prototype.resetPosition = function () {}; ContentEditableInput.prototype.needsContentAttribute = true; function posToDOM(cm, pos) { var view = findViewForLine(cm, pos.line); if (!view || view.hidden) { return null } var line = getLine(cm.doc, pos.line); var info = mapFromLineView(view, line, pos.line); var order = getOrder(line, cm.doc.direction), side = "left"; if (order) { var partPos = getBidiPartAt(order, pos.ch); side = partPos % 2 ? "right" : "left"; } var result = nodeAndOffsetInLineMap(info.map, pos.ch, side); result.offset = result.collapse == "right" ? result.end : result.start; return result } function isInGutter(node) { for (var scan = node; scan; scan = scan.parentNode) { if (/CodeMirror-gutter-wrapper/.test(scan.className)) { return true } } return false } function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos } function domTextBetween(cm, from, to, fromLine, toLine) { var text = "", closing = false, lineSep = cm.doc.lineSeparator(), extraLinebreak = false; function recognizeMarker(id) { return function (marker) { return marker.id == id; } } function close() { if (closing) { text += lineSep; if (extraLinebreak) { text += lineSep; } closing = extraLinebreak = false; } } function addText(str) { if (str) { close(); text += str; } } function walk(node) { if (node.nodeType == 1) { var cmText = node.getAttribute("cm-text"); if (cmText) { addText(cmText); return } var markerID = node.getAttribute("cm-marker"), range; if (markerID) { var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID)); if (found.length && (range = found[0].find(0))) { addText(getBetween(cm.doc, range.from, range.to).join(lineSep)); } return } if (node.getAttribute("contenteditable") == "false") { return } var isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName); if (!/^br$/i.test(node.nodeName) && node.textContent.length == 0) { return } if (isBlock) { close(); } for (var i = 0; i < node.childNodes.length; i++) { walk(node.childNodes[i]); } if (/^(pre|p)$/i.test(node.nodeName)) { extraLinebreak = true; } if (isBlock) { closing = true; } } else if (node.nodeType == 3) { addText(node.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " ")); } } for (;;) { walk(from); if (from == to) { break } from = from.nextSibling; extraLinebreak = false; } return text } function domToPos(cm, node, offset) { var lineNode; if (node == cm.display.lineDiv) { lineNode = cm.display.lineDiv.childNodes[offset]; if (!lineNode) { return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true) } node = null; offset = 0; } else { for (lineNode = node;; lineNode = lineNode.parentNode) { if (!lineNode || lineNode == cm.display.lineDiv) { return null } if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) { break } } } for (var i = 0; i < cm.display.view.length; i++) { var lineView = cm.display.view[i]; if (lineView.node == lineNode) { return locateNodeInLineView(lineView, node, offset) } } } function locateNodeInLineView(lineView, node, offset) { var wrapper = lineView.text.firstChild, bad = false; if (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true) } if (node == wrapper) { bad = true; node = wrapper.childNodes[offset]; offset = 0; if (!node) { var line = lineView.rest ? lst(lineView.rest) : lineView.line; return badPos(Pos(lineNo(line), line.text.length), bad) } } var textNode = node.nodeType == 3 ? node : null, topNode = node; if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) { textNode = node.firstChild; if (offset) { offset = textNode.nodeValue.length; } } while (topNode.parentNode != wrapper) { topNode = topNode.parentNode; } var measure = lineView.measure, maps = measure.maps; function find(textNode, topNode, offset) { for (var i = -1; i < (maps ? maps.length : 0); i++) { var map = i < 0 ? measure.map : maps[i]; for (var j = 0; j < map.length; j += 3) { var curNode = map[j + 2]; if (curNode == textNode || curNode == topNode) { var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]); var ch = map[j] + offset; if (offset < 0 || curNode != textNode) { ch = map[j + (offset ? 1 : 0)]; } return Pos(line, ch) } } } } var found = find(textNode, topNode, offset); if (found) { return badPos(found, bad) } // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) { found = find(after, after.firstChild, 0); if (found) { return badPos(Pos(found.line, found.ch - dist), bad) } else { dist += after.textContent.length; } } for (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) { found = find(before, before.firstChild, -1); if (found) { return badPos(Pos(found.line, found.ch + dist$1), bad) } else { dist$1 += before.textContent.length; } } } // TEXTAREA INPUT STYLE var TextareaInput = function(cm) { this.cm = cm; // See input.poll and input.reset this.prevInput = ""; // Flag that indicates whether we expect input to appear real soon // now (after some event like 'keypress' or 'input') and are // polling intensively. this.pollingFast = false; // Self-resetting timeout for the poller this.polling = new Delayed(); // Used to work around IE issue with selection being forgotten when focus moves away from textarea this.hasSelection = false; this.composing = null; }; TextareaInput.prototype.init = function (display) { var this$1 = this; var input = this, cm = this.cm; this.createField(display); var te = this.textarea; display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild); // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore) if (ios) { te.style.width = "0px"; } on(te, "input", function () { if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null; } input.poll(); }); on(te, "paste", function (e) { if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return } cm.state.pasteIncoming = +new Date; input.fastPoll(); }); function prepareCopyCut(e) { if (signalDOMEvent(cm, e)) { return } if (cm.somethingSelected()) { setLastCopied({lineWise: false, text: cm.getSelections()}); } else if (!cm.options.lineWiseCopyCut) { return } else { var ranges = copyableRanges(cm); setLastCopied({lineWise: true, text: ranges.text}); if (e.type == "cut") { cm.setSelections(ranges.ranges, null, sel_dontScroll); } else { input.prevInput = ""; te.value = ranges.text.join("\n"); selectInput(te); } } if (e.type == "cut") { cm.state.cutIncoming = +new Date; } } on(te, "cut", prepareCopyCut); on(te, "copy", prepareCopyCut); on(display.scroller, "paste", function (e) { if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return } if (!te.dispatchEvent) { cm.state.pasteIncoming = +new Date; input.focus(); return } // Pass the `paste` event to the textarea so it's handled by its event listener. var event = new Event("paste"); event.clipboardData = e.clipboardData; te.dispatchEvent(event); }); // Prevent normal selection in the editor (we handle our own) on(display.lineSpace, "selectstart", function (e) { if (!eventInWidget(display, e)) { e_preventDefault(e); } }); on(te, "compositionstart", function () { var start = cm.getCursor("from"); if (input.composing) { input.composing.range.clear(); } input.composing = { start: start, range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"}) }; }); on(te, "compositionend", function () { if (input.composing) { input.poll(); input.composing.range.clear(); input.composing = null; } }); }; TextareaInput.prototype.createField = function (_display) { // Wraps and hides input textarea this.wrapper = hiddenTextarea(); // The semihidden textarea that is focused when the editor is // focused, and receives input. this.textarea = this.wrapper.firstChild; }; TextareaInput.prototype.screenReaderLabelChanged = function (label) { // Label for screenreaders, accessibility if(label) { this.textarea.setAttribute('aria-label', label); } else { this.textarea.removeAttribute('aria-label'); } }; TextareaInput.prototype.prepareSelection = function () { // Redraw the selection and/or cursor var cm = this.cm, display = cm.display, doc = cm.doc; var result = prepareSelection(cm); // Move the hidden textarea near the cursor to prevent scrolling artifacts if (cm.options.moveInputWithCursor) { var headPos = cursorCoords(cm, doc.sel.primary().head, "div"); var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect(); result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10, headPos.top + lineOff.top - wrapOff.top)); result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10, headPos.left + lineOff.left - wrapOff.left)); } return result }; TextareaInput.prototype.showSelection = function (drawn) { var cm = this.cm, display = cm.display; removeChildrenAndAdd(display.cursorDiv, drawn.cursors); removeChildrenAndAdd(display.selectionDiv, drawn.selection); if (drawn.teTop != null) { this.wrapper.style.top = drawn.teTop + "px"; this.wrapper.style.left = drawn.teLeft + "px"; } }; // Reset the input to correspond to the selection (or to be empty, // when not typing and nothing is selected) TextareaInput.prototype.reset = function (typing) { if (this.contextMenuPending || this.composing) { return } var cm = this.cm; if (cm.somethingSelected()) { this.prevInput = ""; var content = cm.getSelection(); this.textarea.value = content; if (cm.state.focused) { selectInput(this.textarea); } if (ie && ie_version >= 9) { this.hasSelection = content; } } else if (!typing) { this.prevInput = this.textarea.value = ""; if (ie && ie_version >= 9) { this.hasSelection = null; } } }; TextareaInput.prototype.getField = function () { return this.textarea }; TextareaInput.prototype.supportsTouch = function () { return false }; TextareaInput.prototype.focus = function () { if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) { try { this.textarea.focus(); } catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM } }; TextareaInput.prototype.blur = function () { this.textarea.blur(); }; TextareaInput.prototype.resetPosition = function () { this.wrapper.style.top = this.wrapper.style.left = 0; }; TextareaInput.prototype.receivedFocus = function () { this.slowPoll(); }; // Poll for input changes, using the normal rate of polling. This // runs as long as the editor is focused. TextareaInput.prototype.slowPoll = function () { var this$1 = this; if (this.pollingFast) { return } this.polling.set(this.cm.options.pollInterval, function () { this$1.poll(); if (this$1.cm.state.focused) { this$1.slowPoll(); } }); }; // When an event has just come in that is likely to add or change // something in the input textarea, we poll faster, to ensure that // the change appears on the screen quickly. TextareaInput.prototype.fastPoll = function () { var missed = false, input = this; input.pollingFast = true; function p() { var changed = input.poll(); if (!changed && !missed) {missed = true; input.polling.set(60, p);} else {input.pollingFast = false; input.slowPoll();} } input.polling.set(20, p); }; // Read input from the textarea, and update the document to match. // When something is selected, it is present in the textarea, and // selected (unless it is huge, in which case a placeholder is // used). When nothing is selected, the cursor sits after previously // seen text (can be empty), which is stored in prevInput (we must // not reset the textarea when typing, because that breaks IME). TextareaInput.prototype.poll = function () { var this$1 = this; var cm = this.cm, input = this.textarea, prevInput = this.prevInput; // Since this is called a *lot*, try to bail out as cheaply as // possible when it is clear that nothing happened. hasSelection // will be the case when there is a lot of text in the textarea, // in which case reading its value would be expensive. if (this.contextMenuPending || !cm.state.focused || (hasSelection(input) && !prevInput && !this.composing) || cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq) { return false } var text = input.value; // If nothing changed, bail. if (text == prevInput && !cm.somethingSelected()) { return false } // Work around nonsensical selection resetting in IE9/10, and // inexplicable appearance of private area unicode characters on // some key combos in Mac (#2689). if (ie && ie_version >= 9 && this.hasSelection === text || mac && /[\uf700-\uf7ff]/.test(text)) { cm.display.input.reset(); return false } if (cm.doc.sel == cm.display.selForContextMenu) { var first = text.charCodeAt(0); if (first == 0x200b && !prevInput) { prevInput = "\u200b"; } if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo") } } // Find the part of the input that is actually new var same = 0, l = Math.min(prevInput.length, text.length); while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same; } runInOp(cm, function () { applyTextInput(cm, text.slice(same), prevInput.length - same, null, this$1.composing ? "*compose" : null); // Don't leave long text in the textarea, since it makes further polling slow if (text.length > 1000 || text.indexOf("\n") > -1) { input.value = this$1.prevInput = ""; } else { this$1.prevInput = text; } if (this$1.composing) { this$1.composing.range.clear(); this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"), {className: "CodeMirror-composing"}); } }); return true }; TextareaInput.prototype.ensurePolled = function () { if (this.pollingFast && this.poll()) { this.pollingFast = false; } }; TextareaInput.prototype.onKeyPress = function () { if (ie && ie_version >= 9) { this.hasSelection = null; } this.fastPoll(); }; TextareaInput.prototype.onContextMenu = function (e) { var input = this, cm = input.cm, display = cm.display, te = input.textarea; if (input.contextMenuPending) { input.contextMenuPending(); } var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop; if (!pos || presto) { return } // Opera is difficult. // Reset the current text selection only if the click is done outside of the selection // and 'resetSelectionOnContextMenu' option is true. var reset = cm.options.resetSelectionOnContextMenu; if (reset && cm.doc.sel.contains(pos) == -1) { operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); } var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText; var wrapperBox = input.wrapper.offsetParent.getBoundingClientRect(); input.wrapper.style.cssText = "position: static"; te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"; var oldScrollY; if (webkit) { oldScrollY = window.scrollY; } // Work around Chrome issue (#2712) display.input.focus(); if (webkit) { window.scrollTo(null, oldScrollY); } display.input.reset(); // Adds "Select all" to context menu in FF if (!cm.somethingSelected()) { te.value = input.prevInput = " "; } input.contextMenuPending = rehide; display.selForContextMenu = cm.doc.sel; clearTimeout(display.detectingSelectAll); // Select-all will be greyed out if there's nothing to select, so // this adds a zero-width space so that we can later check whether // it got selected. function prepareSelectAllHack() { if (te.selectionStart != null) { var selected = cm.somethingSelected(); var extval = "\u200b" + (selected ? te.value : ""); te.value = "\u21da"; // Used to catch context-menu undo te.value = extval; input.prevInput = selected ? "" : "\u200b"; te.selectionStart = 1; te.selectionEnd = extval.length; // Re-set this, in case some other handler touched the // selection in the meantime. display.selForContextMenu = cm.doc.sel; } } function rehide() { if (input.contextMenuPending != rehide) { return } input.contextMenuPending = false; input.wrapper.style.cssText = oldWrapperCSS; te.style.cssText = oldCSS; if (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos); } // Try to detect the user choosing select-all if (te.selectionStart != null) { if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack(); } var i = 0, poll = function () { if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 && te.selectionEnd > 0 && input.prevInput == "\u200b") { operation(cm, selectAll)(cm); } else if (i++ < 10) { display.detectingSelectAll = setTimeout(poll, 500); } else { display.selForContextMenu = null; display.input.reset(); } }; display.detectingSelectAll = setTimeout(poll, 200); } } if (ie && ie_version >= 9) { prepareSelectAllHack(); } if (captureRightClick) { e_stop(e); var mouseup = function () { off(window, "mouseup", mouseup); setTimeout(rehide, 20); }; on(window, "mouseup", mouseup); } else { setTimeout(rehide, 50); } }; TextareaInput.prototype.readOnlyChanged = function (val) { if (!val) { this.reset(); } this.textarea.disabled = val == "nocursor"; }; TextareaInput.prototype.setUneditable = function () {}; TextareaInput.prototype.needsContentAttribute = false; function fromTextArea(textarea, options) { options = options ? copyObj(options) : {}; options.value = textarea.value; if (!options.tabindex && textarea.tabIndex) { options.tabindex = textarea.tabIndex; } if (!options.placeholder && textarea.placeholder) { options.placeholder = textarea.placeholder; } // Set autofocus to true if this textarea is focused, or if it has // autofocus and no other element is focused. if (options.autofocus == null) { var hasFocus = activeElt(); options.autofocus = hasFocus == textarea || textarea.getAttribute("autofocus") != null && hasFocus == document.body; } function save() {textarea.value = cm.getValue();} var realSubmit; if (textarea.form) { on(textarea.form, "submit", save); // Deplorable hack to make the submit method do the right thing. if (!options.leaveSubmitMethodAlone) { var form = textarea.form; realSubmit = form.submit; try { var wrappedSubmit = form.submit = function () { save(); form.submit = realSubmit; form.submit(); form.submit = wrappedSubmit; }; } catch(e) {} } } options.finishInit = function (cm) { cm.save = save; cm.getTextArea = function () { return textarea; }; cm.toTextArea = function () { cm.toTextArea = isNaN; // Prevent this from being ran twice save(); textarea.parentNode.removeChild(cm.getWrapperElement()); textarea.style.display = ""; if (textarea.form) { off(textarea.form, "submit", save); if (!options.leaveSubmitMethodAlone && typeof textarea.form.submit == "function") { textarea.form.submit = realSubmit; } } }; }; textarea.style.display = "none"; var cm = CodeMirror(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); }, options); return cm } function addLegacyProps(CodeMirror) { CodeMirror.off = off; CodeMirror.on = on; CodeMirror.wheelEventPixels = wheelEventPixels; CodeMirror.Doc = Doc; CodeMirror.splitLines = splitLinesAuto; CodeMirror.countColumn = countColumn; CodeMirror.findColumn = findColumn; CodeMirror.isWordChar = isWordCharBasic; CodeMirror.Pass = Pass; CodeMirror.signal = signal; CodeMirror.Line = Line; CodeMirror.changeEnd = changeEnd; CodeMirror.scrollbarModel = scrollbarModel; CodeMirror.Pos = Pos; CodeMirror.cmpPos = cmp; CodeMirror.modes = modes; CodeMirror.mimeModes = mimeModes; CodeMirror.resolveMode = resolveMode; CodeMirror.getMode = getMode; CodeMirror.modeExtensions = modeExtensions; CodeMirror.extendMode = extendMode; CodeMirror.copyState = copyState; CodeMirror.startState = startState; CodeMirror.innerMode = innerMode; CodeMirror.commands = commands; CodeMirror.keyMap = keyMap; CodeMirror.keyName = keyName; CodeMirror.isModifierKey = isModifierKey; CodeMirror.lookupKey = lookupKey; CodeMirror.normalizeKeyMap = normalizeKeyMap; CodeMirror.StringStream = StringStream; CodeMirror.SharedTextMarker = SharedTextMarker; CodeMirror.TextMarker = TextMarker; CodeMirror.LineWidget = LineWidget; CodeMirror.e_preventDefault = e_preventDefault; CodeMirror.e_stopPropagation = e_stopPropagation; CodeMirror.e_stop = e_stop; CodeMirror.addClass = addClass; CodeMirror.contains = contains; CodeMirror.rmClass = rmClass; CodeMirror.keyNames = keyNames; } // EDITOR CONSTRUCTOR defineOptions(CodeMirror); addEditorMethods(CodeMirror); // Set up methods on CodeMirror's prototype to redirect to the editor's document. var dontDelegate = "iter insert remove copy getEditor constructor".split(" "); for (var prop in Doc.prototype) { if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0) { CodeMirror.prototype[prop] = (function(method) { return function() {return method.apply(this.doc, arguments)} })(Doc.prototype[prop]); } } eventMixin(Doc); CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput}; // Extra arguments are stored as the mode's dependencies, which is // used by (legacy) mechanisms like loadmode.js to automatically // load a mode. (Preferred mechanism is the require/define calls.) CodeMirror.defineMode = function(name/*, mode, …*/) { if (!CodeMirror.defaults.mode && name != "null") { CodeMirror.defaults.mode = name; } defineMode.apply(this, arguments); }; CodeMirror.defineMIME = defineMIME; // Minimal default mode. CodeMirror.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); }); CodeMirror.defineMIME("text/plain", "null"); // EXTENSIONS CodeMirror.defineExtension = function (name, func) { CodeMirror.prototype[name] = func; }; CodeMirror.defineDocExtension = function (name, func) { Doc.prototype[name] = func; }; CodeMirror.fromTextArea = fromTextArea; addLegacyProps(CodeMirror); CodeMirror.version = "5.56.0"; return CodeMirror; }))); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/dialog/dialog.css ================================================ .CodeMirror-dialog { position: absolute; left: 0; right: 0; background: inherit; z-index: 15; padding: .1em .8em; overflow: hidden; color: inherit; } .CodeMirror-dialog-top { border-bottom: 1px solid #eee; top: 0; } .CodeMirror-dialog-bottom { border-top: 1px solid #eee; bottom: 0; } .CodeMirror-dialog input { border: none; outline: none; background: transparent; width: 20em; color: inherit; font-family: monospace; } .CodeMirror-dialog button { font-size: 70%; } ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/dialog/dialog.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // Open simple dialogs on top of an editor. Relies on dialog.css. (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { function dialogDiv(cm, template, bottom) { var wrap = cm.getWrapperElement(); var dialog; dialog = wrap.appendChild(document.createElement("div")); if (bottom) dialog.className = "CodeMirror-dialog CodeMirror-dialog-bottom"; else dialog.className = "CodeMirror-dialog CodeMirror-dialog-top"; if (typeof template == "string") { dialog.innerHTML = template; } else { // Assuming it's a detached DOM element. dialog.appendChild(template); } CodeMirror.addClass(wrap, 'dialog-opened'); return dialog; } function closeNotification(cm, newVal) { if (cm.state.currentNotificationClose) cm.state.currentNotificationClose(); cm.state.currentNotificationClose = newVal; } CodeMirror.defineExtension("openDialog", function(template, callback, options) { if (!options) options = {}; closeNotification(this, null); var dialog = dialogDiv(this, template, options.bottom); var closed = false, me = this; function close(newVal) { if (typeof newVal == 'string') { inp.value = newVal; } else { if (closed) return; closed = true; CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); dialog.parentNode.removeChild(dialog); me.focus(); if (options.onClose) options.onClose(dialog); } } var inp = dialog.getElementsByTagName("input")[0], button; if (inp) { inp.focus(); if (options.value) { inp.value = options.value; if (options.selectValueOnOpen !== false) { inp.select(); } } if (options.onInput) CodeMirror.on(inp, "input", function(e) { options.onInput(e, inp.value, close);}); if (options.onKeyUp) CodeMirror.on(inp, "keyup", function(e) {options.onKeyUp(e, inp.value, close);}); CodeMirror.on(inp, "keydown", function(e) { if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; } if (e.keyCode == 27 || (options.closeOnEnter !== false && e.keyCode == 13)) { inp.blur(); CodeMirror.e_stop(e); close(); } if (e.keyCode == 13) callback(inp.value, e); }); if (options.closeOnBlur !== false) CodeMirror.on(dialog, "focusout", function (evt) { if (evt.relatedTarget !== null) close(); }); } else if (button = dialog.getElementsByTagName("button")[0]) { CodeMirror.on(button, "click", function() { close(); me.focus(); }); if (options.closeOnBlur !== false) CodeMirror.on(button, "blur", close); button.focus(); } return close; }); CodeMirror.defineExtension("openConfirm", function(template, callbacks, options) { closeNotification(this, null); var dialog = dialogDiv(this, template, options && options.bottom); var buttons = dialog.getElementsByTagName("button"); var closed = false, me = this, blurring = 1; function close() { if (closed) return; closed = true; CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); dialog.parentNode.removeChild(dialog); me.focus(); } buttons[0].focus(); for (var i = 0; i < buttons.length; ++i) { var b = buttons[i]; (function(callback) { CodeMirror.on(b, "click", function(e) { CodeMirror.e_preventDefault(e); close(); if (callback) callback(me); }); })(callbacks[i]); CodeMirror.on(b, "blur", function() { --blurring; setTimeout(function() { if (blurring <= 0) close(); }, 200); }); CodeMirror.on(b, "focus", function() { ++blurring; }); } }); /* * openNotification * Opens a notification, that can be closed with an optional timer * (default 5000ms timer) and always closes on click. * * If a notification is opened while another is opened, it will close the * currently opened one and open the new one immediately. */ CodeMirror.defineExtension("openNotification", function(template, options) { closeNotification(this, close); var dialog = dialogDiv(this, template, options && options.bottom); var closed = false, doneTimer; var duration = options && typeof options.duration !== "undefined" ? options.duration : 5000; function close() { if (closed) return; closed = true; clearTimeout(doneTimer); CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); dialog.parentNode.removeChild(dialog); } CodeMirror.on(dialog, 'click', function(e) { CodeMirror.e_preventDefault(e); close(); }); if (duration) doneTimer = setTimeout(close, duration); return close; }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/edit/closebrackets.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { var defaults = { pairs: "()[]{}''\"\"", closeBefore: ")]}'\":;>", triples: "", explode: "[]{}" }; var Pos = CodeMirror.Pos; CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { cm.removeKeyMap(keyMap); cm.state.closeBrackets = null; } if (val) { ensureBound(getOption(val, "pairs")) cm.state.closeBrackets = val; cm.addKeyMap(keyMap); } }); function getOption(conf, name) { if (name == "pairs" && typeof conf == "string") return conf; if (typeof conf == "object" && conf[name] != null) return conf[name]; return defaults[name]; } var keyMap = {Backspace: handleBackspace, Enter: handleEnter}; function ensureBound(chars) { for (var i = 0; i < chars.length; i++) { var ch = chars.charAt(i), key = "'" + ch + "'" if (!keyMap[key]) keyMap[key] = handler(ch) } } ensureBound(defaults.pairs + "`") function handler(ch) { return function(cm) { return handleChar(cm, ch); }; } function getConfig(cm) { var deflt = cm.state.closeBrackets; if (!deflt || deflt.override) return deflt; var mode = cm.getModeAt(cm.getCursor()); return mode.closeBrackets || deflt; } function handleBackspace(cm) { var conf = getConfig(cm); if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass; var pairs = getOption(conf, "pairs"); var ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) { if (!ranges[i].empty()) return CodeMirror.Pass; var around = charsAround(cm, ranges[i].head); if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass; } for (var i = ranges.length - 1; i >= 0; i--) { var cur = ranges[i].head; cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1), "+delete"); } } function handleEnter(cm) { var conf = getConfig(cm); var explode = conf && getOption(conf, "explode"); if (!explode || cm.getOption("disableInput")) return CodeMirror.Pass; var ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) { if (!ranges[i].empty()) return CodeMirror.Pass; var around = charsAround(cm, ranges[i].head); if (!around || explode.indexOf(around) % 2 != 0) return CodeMirror.Pass; } cm.operation(function() { var linesep = cm.lineSeparator() || "\n"; cm.replaceSelection(linesep + linesep, null); cm.execCommand("goCharLeft"); ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) { var line = ranges[i].head.line; cm.indentLine(line, null, true); cm.indentLine(line + 1, null, true); } }); } function contractSelection(sel) { var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0; return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)), head: new Pos(sel.head.line, sel.head.ch + (inverted ? 1 : -1))}; } function handleChar(cm, ch) { var conf = getConfig(cm); if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass; var pairs = getOption(conf, "pairs"); var pos = pairs.indexOf(ch); if (pos == -1) return CodeMirror.Pass; var closeBefore = getOption(conf,"closeBefore"); var triples = getOption(conf, "triples"); var identical = pairs.charAt(pos + 1) == ch; var ranges = cm.listSelections(); var opening = pos % 2 == 0; var type; for (var i = 0; i < ranges.length; i++) { var range = ranges[i], cur = range.head, curType; var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1)); if (opening && !range.empty()) { curType = "surround"; } else if ((identical || !opening) && next == ch) { if (identical && stringStartsAfter(cm, cur)) curType = "both"; else if (triples.indexOf(ch) >= 0 && cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == ch + ch + ch) curType = "skipThree"; else curType = "skip"; } else if (identical && cur.ch > 1 && triples.indexOf(ch) >= 0 && cm.getRange(Pos(cur.line, cur.ch - 2), cur) == ch + ch) { if (cur.ch > 2 && /\bstring/.test(cm.getTokenTypeAt(Pos(cur.line, cur.ch - 2)))) return CodeMirror.Pass; curType = "addFour"; } else if (identical) { var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur) if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both"; else return CodeMirror.Pass; } else if (opening && (next.length === 0 || /\s/.test(next) || closeBefore.indexOf(next) > -1)) { curType = "both"; } else { return CodeMirror.Pass; } if (!type) type = curType; else if (type != curType) return CodeMirror.Pass; } var left = pos % 2 ? pairs.charAt(pos - 1) : ch; var right = pos % 2 ? ch : pairs.charAt(pos + 1); cm.operation(function() { if (type == "skip") { cm.execCommand("goCharRight"); } else if (type == "skipThree") { for (var i = 0; i < 3; i++) cm.execCommand("goCharRight"); } else if (type == "surround") { var sels = cm.getSelections(); for (var i = 0; i < sels.length; i++) sels[i] = left + sels[i] + right; cm.replaceSelections(sels, "around"); sels = cm.listSelections().slice(); for (var i = 0; i < sels.length; i++) sels[i] = contractSelection(sels[i]); cm.setSelections(sels); } else if (type == "both") { cm.replaceSelection(left + right, null); cm.triggerElectric(left + right); cm.execCommand("goCharLeft"); } else if (type == "addFour") { cm.replaceSelection(left + left + left + left, "before"); cm.execCommand("goCharRight"); } }); } function charsAround(cm, pos) { var str = cm.getRange(Pos(pos.line, pos.ch - 1), Pos(pos.line, pos.ch + 1)); return str.length == 2 ? str : null; } function stringStartsAfter(cm, pos) { var token = cm.getTokenAt(Pos(pos.line, pos.ch + 1)) return /\bstring/.test(token.type) && token.start == pos.ch && (pos.ch == 0 || !/\bstring/.test(cm.getTokenTypeAt(pos))) } }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/edit/closetag.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE /** * Tag-closer extension for CodeMirror. * * This extension adds an "autoCloseTags" option that can be set to * either true to get the default behavior, or an object to further * configure its behavior. * * These are supported options: * * `whenClosing` (default true) * Whether to autoclose when the '/' of a closing tag is typed. * `whenOpening` (default true) * Whether to autoclose the tag when the final '>' of an opening * tag is typed. * `dontCloseTags` (default is empty tags for HTML, none for XML) * An array of tag names that should not be autoclosed. * `indentTags` (default is block tags for HTML, none for XML) * An array of tag names that should, when opened, cause a * blank line to be added inside the tag, and the blank line and * closing line to be indented. * `emptyTags` (default is none) * An array of XML tag names that should be autoclosed with '/>'. * * See demos/closetag.html for a usage example. */ (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../fold/xml-fold")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../fold/xml-fold"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { CodeMirror.defineOption("autoCloseTags", false, function(cm, val, old) { if (old != CodeMirror.Init && old) cm.removeKeyMap("autoCloseTags"); if (!val) return; var map = {name: "autoCloseTags"}; if (typeof val != "object" || val.whenClosing !== false) map["'/'"] = function(cm) { return autoCloseSlash(cm); }; if (typeof val != "object" || val.whenOpening !== false) map["'>'"] = function(cm) { return autoCloseGT(cm); }; cm.addKeyMap(map); }); var htmlDontClose = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]; var htmlIndent = ["applet", "blockquote", "body", "button", "div", "dl", "fieldset", "form", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head", "html", "iframe", "layer", "legend", "object", "ol", "p", "select", "table", "ul"]; function autoCloseGT(cm) { if (cm.getOption("disableInput")) return CodeMirror.Pass; var ranges = cm.listSelections(), replacements = []; var opt = cm.getOption("autoCloseTags"); for (var i = 0; i < ranges.length; i++) { if (!ranges[i].empty()) return CodeMirror.Pass; var pos = ranges[i].head, tok = cm.getTokenAt(pos); var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state; var tagInfo = inner.mode.xmlCurrentTag && inner.mode.xmlCurrentTag(state) var tagName = tagInfo && tagInfo.name if (!tagName) return CodeMirror.Pass var html = inner.mode.configuration == "html"; var dontCloseTags = (typeof opt == "object" && opt.dontCloseTags) || (html && htmlDontClose); var indentTags = (typeof opt == "object" && opt.indentTags) || (html && htmlIndent); if (tok.end > pos.ch) tagName = tagName.slice(0, tagName.length - tok.end + pos.ch); var lowerTagName = tagName.toLowerCase(); // Don't process the '>' at the end of an end-tag or self-closing tag if (!tagName || tok.type == "string" && (tok.end != pos.ch || !/[\"\']/.test(tok.string.charAt(tok.string.length - 1)) || tok.string.length == 1) || tok.type == "tag" && tagInfo.close || tok.string.indexOf("/") == (pos.ch - tok.start - 1) || // match something like dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1 || closingTagExists(cm, inner.mode.xmlCurrentContext && inner.mode.xmlCurrentContext(state) || [], tagName, pos, true)) return CodeMirror.Pass; var emptyTags = typeof opt == "object" && opt.emptyTags; if (emptyTags && indexOf(emptyTags, tagName) > -1) { replacements[i] = { text: "/>", newPos: CodeMirror.Pos(pos.line, pos.ch + 2) }; continue; } var indent = indentTags && indexOf(indentTags, lowerTagName) > -1; replacements[i] = {indent: indent, text: ">" + (indent ? "\n\n" : "") + "", newPos: indent ? CodeMirror.Pos(pos.line + 1, 0) : CodeMirror.Pos(pos.line, pos.ch + 1)}; } var dontIndentOnAutoClose = (typeof opt == "object" && opt.dontIndentOnAutoClose); for (var i = ranges.length - 1; i >= 0; i--) { var info = replacements[i]; cm.replaceRange(info.text, ranges[i].head, ranges[i].anchor, "+insert"); var sel = cm.listSelections().slice(0); sel[i] = {head: info.newPos, anchor: info.newPos}; cm.setSelections(sel); if (!dontIndentOnAutoClose && info.indent) { cm.indentLine(info.newPos.line, null, true); cm.indentLine(info.newPos.line + 1, null, true); } } } function autoCloseCurrent(cm, typingSlash) { var ranges = cm.listSelections(), replacements = []; var head = typingSlash ? "/" : "") replacement += ">"; replacements[i] = replacement; } cm.replaceSelections(replacements); ranges = cm.listSelections(); if (!dontIndentOnAutoClose) { for (var i = 0; i < ranges.length; i++) if (i == ranges.length - 1 || ranges[i].head.line < ranges[i + 1].head.line) cm.indentLine(ranges[i].head.line); } } function autoCloseSlash(cm) { if (cm.getOption("disableInput")) return CodeMirror.Pass; return autoCloseCurrent(cm, true); } CodeMirror.commands.closeTag = function(cm) { return autoCloseCurrent(cm); }; function indexOf(collection, elt) { if (collection.indexOf) return collection.indexOf(elt); for (var i = 0, e = collection.length; i < e; ++i) if (collection[i] == elt) return i; return -1; } // If xml-fold is loaded, we use its functionality to try and verify // whether a given tag is actually unclosed. function closingTagExists(cm, context, tagName, pos, newTag) { if (!CodeMirror.scanForClosingTag) return false; var end = Math.min(cm.lastLine() + 1, pos.line + 500); var nextClose = CodeMirror.scanForClosingTag(cm, pos, null, end); if (!nextClose || nextClose.tag != tagName) return false; // If the immediate wrapping context contains onCx instances of // the same tag, a closing tag only exists if there are at least // that many closing tags of that type following. var onCx = newTag ? 1 : 0 for (var i = context.length - 1; i >= 0; i--) { if (context[i] == tagName) ++onCx else break } pos = nextClose.to; for (var i = 1; i < onCx; i++) { var next = CodeMirror.scanForClosingTag(cm, pos, null, end); if (!next || next.tag != tagName) return false; pos = next.to; } return true; } }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/edit/continuelist.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/, emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/, unorderedListRE = /[*+-]\s/; CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) { if (cm.getOption("disableInput")) return CodeMirror.Pass; var ranges = cm.listSelections(), replacements = []; for (var i = 0; i < ranges.length; i++) { var pos = ranges[i].head; // If we're not in Markdown mode, fall back to normal newlineAndIndent var eolState = cm.getStateAfter(pos.line); var inner = CodeMirror.innerMode(cm.getMode(), eolState); if (inner.mode.name !== "markdown") { cm.execCommand("newlineAndIndent"); return; } else { eolState = inner.state; } var inList = eolState.list !== false; var inQuote = eolState.quote !== 0; var line = cm.getLine(pos.line), match = listRE.exec(line); var cursorBeforeBullet = /^\s*$/.test(line.slice(0, pos.ch)); if (!ranges[i].empty() || (!inList && !inQuote) || !match || cursorBeforeBullet) { cm.execCommand("newlineAndIndent"); return; } if (emptyListRE.test(line)) { var endOfQuote = inQuote && />\s*$/.test(line) var endOfList = !/>\s*$/.test(line) if (endOfQuote || endOfList) cm.replaceRange("", { line: pos.line, ch: 0 }, { line: pos.line, ch: pos.ch + 1 }); replacements[i] = "\n"; } else { var indent = match[1], after = match[5]; var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0); var bullet = numbered ? (parseInt(match[3], 10) + 1) + match[4] : match[2].replace("x", " "); replacements[i] = "\n" + indent + bullet + after; if (numbered) incrementRemainingMarkdownListNumbers(cm, pos); } } cm.replaceSelections(replacements); }; // Auto-updating Markdown list numbers when a new item is added to the // middle of a list function incrementRemainingMarkdownListNumbers(cm, pos) { var startLine = pos.line, lookAhead = 0, skipCount = 0; var startItem = listRE.exec(cm.getLine(startLine)), startIndent = startItem[1]; do { lookAhead += 1; var nextLineNumber = startLine + lookAhead; var nextLine = cm.getLine(nextLineNumber), nextItem = listRE.exec(nextLine); if (nextItem) { var nextIndent = nextItem[1]; var newNumber = (parseInt(startItem[3], 10) + lookAhead - skipCount); var nextNumber = (parseInt(nextItem[3], 10)), itemNumber = nextNumber; if (startIndent === nextIndent && !isNaN(nextNumber)) { if (newNumber === nextNumber) itemNumber = nextNumber + 1; if (newNumber > nextNumber) itemNumber = newNumber + 1; cm.replaceRange( nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]), { line: nextLineNumber, ch: 0 }, { line: nextLineNumber, ch: nextLine.length }); } else { if (startIndent.length > nextIndent.length) return; // This doesn't run if the next line immediatley indents, as it is // not clear of the users intention (new indented item or same level) if ((startIndent.length < nextIndent.length) && (lookAhead === 1)) return; skipCount += 1; } } } while (nextItem); } }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/edit/matchbrackets.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { var ie_lt8 = /MSIE \d/.test(navigator.userAgent) && (document.documentMode == null || document.documentMode < 8); var Pos = CodeMirror.Pos; var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<", "<": ">>", ">": "<<"}; function bracketRegex(config) { return config && config.bracketRegex || /[(){}[\]]/ } function findMatchingBracket(cm, where, config) { var line = cm.getLineHandle(where.line), pos = where.ch - 1; var afterCursor = config && config.afterCursor if (afterCursor == null) afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className) var re = bracketRegex(config) // A cursor is defined as between two characters, but in in vim command mode // (i.e. not insert mode), the cursor is visually represented as a // highlighted box on top of the 2nd character. Otherwise, we allow matches // from before or after the cursor. var match = (!afterCursor && pos >= 0 && re.test(line.text.charAt(pos)) && matching[line.text.charAt(pos)]) || re.test(line.text.charAt(pos + 1)) && matching[line.text.charAt(++pos)]; if (!match) return null; var dir = match.charAt(1) == ">" ? 1 : -1; if (config && config.strict && (dir > 0) != (pos == where.ch)) return null; var style = cm.getTokenTypeAt(Pos(where.line, pos + 1)); var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config); if (found == null) return null; return {from: Pos(where.line, pos), to: found && found.pos, match: found && found.ch == match.charAt(0), forward: dir > 0}; } // bracketRegex is used to specify which type of bracket to scan // should be a regexp, e.g. /[[\]]/ // // Note: If "where" is on an open bracket, then this bracket is ignored. // // Returns false when no bracket was found, null when it reached // maxScanLines and gave up function scanForBracket(cm, where, dir, style, config) { var maxScanLen = (config && config.maxScanLineLength) || 10000; var maxScanLines = (config && config.maxScanLines) || 1000; var stack = []; var re = bracketRegex(config) var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1) : Math.max(cm.firstLine() - 1, where.line - maxScanLines); for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) { var line = cm.getLine(lineNo); if (!line) continue; var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1; if (line.length > maxScanLen) continue; if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0); for (; pos != end; pos += dir) { var ch = line.charAt(pos); if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) { var match = matching[ch]; if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch); else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch}; else stack.pop(); } } } return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null; } function matchBrackets(cm, autoclear, config) { // Disable brace matching in long lines, since it'll cause hugely slow updates var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000; var marks = [], ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) { var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config); if (match && cm.getLine(match.from.line).length <= maxHighlightLen) { var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket"; marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style})); if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen) marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style})); } } if (marks.length) { // Kludge to work around the IE bug from issue #1193, where text // input stops going to the textare whever this fires. if (ie_lt8 && cm.state.focused) cm.focus(); var clear = function() { cm.operation(function() { for (var i = 0; i < marks.length; i++) marks[i].clear(); }); }; if (autoclear) setTimeout(clear, 800); else return clear; } } function doMatchBrackets(cm) { cm.operation(function() { if (cm.state.matchBrackets.currentlyHighlighted) { cm.state.matchBrackets.currentlyHighlighted(); cm.state.matchBrackets.currentlyHighlighted = null; } cm.state.matchBrackets.currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets); }); } CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { function clear(cm) { if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) { cm.state.matchBrackets.currentlyHighlighted(); cm.state.matchBrackets.currentlyHighlighted = null; } } if (old && old != CodeMirror.Init) { cm.off("cursorActivity", doMatchBrackets); cm.off("focus", doMatchBrackets) cm.off("blur", clear) clear(cm); } if (val) { cm.state.matchBrackets = typeof val == "object" ? val : {}; cm.on("cursorActivity", doMatchBrackets); cm.on("focus", doMatchBrackets) cm.on("blur", clear) } }); CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);}); CodeMirror.defineExtension("findMatchingBracket", function(pos, config, oldConfig){ // Backwards-compatibility kludge if (oldConfig || typeof config == "boolean") { if (!oldConfig) { config = config ? {strict: true} : null } else { oldConfig.strict = config config = oldConfig } } return findMatchingBracket(this, pos, config) }); CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){ return scanForBracket(this, pos, dir, style, config); }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/edit/matchtags.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../fold/xml-fold")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../fold/xml-fold"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineOption("matchTags", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { cm.off("cursorActivity", doMatchTags); cm.off("viewportChange", maybeUpdateMatch); clear(cm); } if (val) { cm.state.matchBothTags = typeof val == "object" && val.bothTags; cm.on("cursorActivity", doMatchTags); cm.on("viewportChange", maybeUpdateMatch); doMatchTags(cm); } }); function clear(cm) { if (cm.state.tagHit) cm.state.tagHit.clear(); if (cm.state.tagOther) cm.state.tagOther.clear(); cm.state.tagHit = cm.state.tagOther = null; } function doMatchTags(cm) { cm.state.failedTagMatch = false; cm.operation(function() { clear(cm); if (cm.somethingSelected()) return; var cur = cm.getCursor(), range = cm.getViewport(); range.from = Math.min(range.from, cur.line); range.to = Math.max(cur.line + 1, range.to); var match = CodeMirror.findMatchingTag(cm, cur, range); if (!match) return; if (cm.state.matchBothTags) { var hit = match.at == "open" ? match.open : match.close; if (hit) cm.state.tagHit = cm.markText(hit.from, hit.to, {className: "CodeMirror-matchingtag"}); } var other = match.at == "close" ? match.open : match.close; if (other) cm.state.tagOther = cm.markText(other.from, other.to, {className: "CodeMirror-matchingtag"}); else cm.state.failedTagMatch = true; }); } function maybeUpdateMatch(cm) { if (cm.state.failedTagMatch) doMatchTags(cm); } CodeMirror.commands.toMatchingTag = function(cm) { var found = CodeMirror.findMatchingTag(cm, cm.getCursor()); if (found) { var other = found.at == "close" ? found.open : found.close; if (other) cm.extendSelection(other.to, other.from); } }; }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/edit/trailingspace.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) { if (prev == CodeMirror.Init) prev = false; if (prev && !val) cm.removeOverlay("trailingspace"); else if (!prev && val) cm.addOverlay({ token: function(stream) { for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {} if (i > stream.pos) { stream.pos = i; return null; } stream.pos = l; return "trailingspace"; }, name: "trailingspace" }); }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/fold/brace-fold.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.registerHelper("fold", "brace", function(cm, start) { var line = start.line, lineText = cm.getLine(line); var tokenType; function findOpening(openCh) { for (var at = start.ch, pass = 0;;) { var found = at <= 0 ? -1 : lineText.lastIndexOf(openCh, at - 1); if (found == -1) { if (pass == 1) break; pass = 1; at = lineText.length; continue; } if (pass == 1 && found < start.ch) break; tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)); if (!/^(comment|string)/.test(tokenType)) return found + 1; at = found - 1; } } var startToken = "{", endToken = "}", startCh = findOpening("{"); if (startCh == null) { startToken = "[", endToken = "]"; startCh = findOpening("["); } if (startCh == null) return; var count = 1, lastLine = cm.lastLine(), end, endCh; outer: for (var i = line; i <= lastLine; ++i) { var text = cm.getLine(i), pos = i == line ? startCh : 0; for (;;) { var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos); if (nextOpen < 0) nextOpen = text.length; if (nextClose < 0) nextClose = text.length; pos = Math.min(nextOpen, nextClose); if (pos == text.length) break; if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == tokenType) { if (pos == nextOpen) ++count; else if (!--count) { end = i; endCh = pos; break outer; } } ++pos; } } if (end == null || line == end) return; return {from: CodeMirror.Pos(line, startCh), to: CodeMirror.Pos(end, endCh)}; }); CodeMirror.registerHelper("fold", "import", function(cm, start) { function hasImport(line) { if (line < cm.firstLine() || line > cm.lastLine()) return null; var start = cm.getTokenAt(CodeMirror.Pos(line, 1)); if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1)); if (start.type != "keyword" || start.string != "import") return null; // Now find closing semicolon, return its position for (var i = line, e = Math.min(cm.lastLine(), line + 10); i <= e; ++i) { var text = cm.getLine(i), semi = text.indexOf(";"); if (semi != -1) return {startCh: start.end, end: CodeMirror.Pos(i, semi)}; } } var startLine = start.line, has = hasImport(startLine), prev; if (!has || hasImport(startLine - 1) || ((prev = hasImport(startLine - 2)) && prev.end.line == startLine - 1)) return null; for (var end = has.end;;) { var next = hasImport(end.line + 1); if (next == null) break; end = next.end; } return {from: cm.clipPos(CodeMirror.Pos(startLine, has.startCh + 1)), to: end}; }); CodeMirror.registerHelper("fold", "include", function(cm, start) { function hasInclude(line) { if (line < cm.firstLine() || line > cm.lastLine()) return null; var start = cm.getTokenAt(CodeMirror.Pos(line, 1)); if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1)); if (start.type == "meta" && start.string.slice(0, 8) == "#include") return start.start + 8; } var startLine = start.line, has = hasInclude(startLine); if (has == null || hasInclude(startLine - 1) != null) return null; for (var end = startLine;;) { var next = hasInclude(end + 1); if (next == null) break; ++end; } return {from: CodeMirror.Pos(startLine, has + 1), to: cm.clipPos(CodeMirror.Pos(end))}; }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/fold/comment-fold.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.registerGlobalHelper("fold", "comment", function(mode) { return mode.blockCommentStart && mode.blockCommentEnd; }, function(cm, start) { var mode = cm.getModeAt(start), startToken = mode.blockCommentStart, endToken = mode.blockCommentEnd; if (!startToken || !endToken) return; var line = start.line, lineText = cm.getLine(line); var startCh; for (var at = start.ch, pass = 0;;) { var found = at <= 0 ? -1 : lineText.lastIndexOf(startToken, at - 1); if (found == -1) { if (pass == 1) return; pass = 1; at = lineText.length; continue; } if (pass == 1 && found < start.ch) return; if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1))) && (found == 0 || lineText.slice(found - endToken.length, found) == endToken || !/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found))))) { startCh = found + startToken.length; break; } at = found - 1; } var depth = 1, lastLine = cm.lastLine(), end, endCh; outer: for (var i = line; i <= lastLine; ++i) { var text = cm.getLine(i), pos = i == line ? startCh : 0; for (;;) { var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos); if (nextOpen < 0) nextOpen = text.length; if (nextClose < 0) nextClose = text.length; pos = Math.min(nextOpen, nextClose); if (pos == text.length) break; if (pos == nextOpen) ++depth; else if (!--depth) { end = i; endCh = pos; break outer; } ++pos; } } if (end == null || line == end && endCh == startCh) return; return {from: CodeMirror.Pos(line, startCh), to: CodeMirror.Pos(end, endCh)}; }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/fold/foldcode.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; function doFold(cm, pos, options, force) { if (options && options.call) { var finder = options; options = null; } else { var finder = getOption(cm, options, "rangeFinder"); } if (typeof pos == "number") pos = CodeMirror.Pos(pos, 0); var minSize = getOption(cm, options, "minFoldSize"); function getRange(allowFolded) { var range = finder(cm, pos); if (!range || range.to.line - range.from.line < minSize) return null; var marks = cm.findMarksAt(range.from); for (var i = 0; i < marks.length; ++i) { if (marks[i].__isFold && force !== "fold") { if (!allowFolded) return null; range.cleared = true; marks[i].clear(); } } return range; } var range = getRange(true); if (getOption(cm, options, "scanUp")) while (!range && pos.line > cm.firstLine()) { pos = CodeMirror.Pos(pos.line - 1, 0); range = getRange(false); } if (!range || range.cleared || force === "unfold") return; var myWidget = makeWidget(cm, options, range); CodeMirror.on(myWidget, "mousedown", function(e) { myRange.clear(); CodeMirror.e_preventDefault(e); }); var myRange = cm.markText(range.from, range.to, { replacedWith: myWidget, clearOnEnter: getOption(cm, options, "clearOnEnter"), __isFold: true }); myRange.on("clear", function(from, to) { CodeMirror.signal(cm, "unfold", cm, from, to); }); CodeMirror.signal(cm, "fold", cm, range.from, range.to); } function makeWidget(cm, options, range) { var widget = getOption(cm, options, "widget"); if (typeof widget == "function") { widget = widget(range.from, range.to); } if (typeof widget == "string") { var text = document.createTextNode(widget); widget = document.createElement("span"); widget.appendChild(text); widget.className = "CodeMirror-foldmarker"; } else if (widget) { widget = widget.cloneNode(true) } return widget; } // Clumsy backwards-compatible interface CodeMirror.newFoldFunction = function(rangeFinder, widget) { return function(cm, pos) { doFold(cm, pos, {rangeFinder: rangeFinder, widget: widget}); }; }; // New-style interface CodeMirror.defineExtension("foldCode", function(pos, options, force) { doFold(this, pos, options, force); }); CodeMirror.defineExtension("isFolded", function(pos) { var marks = this.findMarksAt(pos); for (var i = 0; i < marks.length; ++i) if (marks[i].__isFold) return true; }); CodeMirror.commands.toggleFold = function(cm) { cm.foldCode(cm.getCursor()); }; CodeMirror.commands.fold = function(cm) { cm.foldCode(cm.getCursor(), null, "fold"); }; CodeMirror.commands.unfold = function(cm) { cm.foldCode(cm.getCursor(), null, "unfold"); }; CodeMirror.commands.foldAll = function(cm) { cm.operation(function() { for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++) cm.foldCode(CodeMirror.Pos(i, 0), null, "fold"); }); }; CodeMirror.commands.unfoldAll = function(cm) { cm.operation(function() { for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++) cm.foldCode(CodeMirror.Pos(i, 0), null, "unfold"); }); }; CodeMirror.registerHelper("fold", "combine", function() { var funcs = Array.prototype.slice.call(arguments, 0); return function(cm, start) { for (var i = 0; i < funcs.length; ++i) { var found = funcs[i](cm, start); if (found) return found; } }; }); CodeMirror.registerHelper("fold", "auto", function(cm, start) { var helpers = cm.getHelpers(start, "fold"); for (var i = 0; i < helpers.length; i++) { var cur = helpers[i](cm, start); if (cur) return cur; } }); var defaultOptions = { rangeFinder: CodeMirror.fold.auto, widget: "\u2194", minFoldSize: 0, scanUp: false, clearOnEnter: true }; CodeMirror.defineOption("foldOptions", null); function getOption(cm, options, name) { if (options && options[name] !== undefined) return options[name]; var editorOptions = cm.options.foldOptions; if (editorOptions && editorOptions[name] !== undefined) return editorOptions[name]; return defaultOptions[name]; } CodeMirror.defineExtension("foldOption", function(options, name) { return getOption(this, options, name); }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/fold/foldgutter.css ================================================ .CodeMirror-foldmarker { color: blue; text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px; font-family: arial; line-height: .3; cursor: pointer; } .CodeMirror-foldgutter { width: .7em; } .CodeMirror-foldgutter-open, .CodeMirror-foldgutter-folded { cursor: pointer; } .CodeMirror-foldgutter-open:after { content: "\25BE"; } .CodeMirror-foldgutter-folded:after { content: "\25B8"; } ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/fold/foldgutter.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("./foldcode")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "./foldcode"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineOption("foldGutter", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { cm.clearGutter(cm.state.foldGutter.options.gutter); cm.state.foldGutter = null; cm.off("gutterClick", onGutterClick); cm.off("changes", onChange); cm.off("viewportChange", onViewportChange); cm.off("fold", onFold); cm.off("unfold", onFold); cm.off("swapDoc", onChange); } if (val) { cm.state.foldGutter = new State(parseOptions(val)); updateInViewport(cm); cm.on("gutterClick", onGutterClick); cm.on("changes", onChange); cm.on("viewportChange", onViewportChange); cm.on("fold", onFold); cm.on("unfold", onFold); cm.on("swapDoc", onChange); } }); var Pos = CodeMirror.Pos; function State(options) { this.options = options; this.from = this.to = 0; } function parseOptions(opts) { if (opts === true) opts = {}; if (opts.gutter == null) opts.gutter = "CodeMirror-foldgutter"; if (opts.indicatorOpen == null) opts.indicatorOpen = "CodeMirror-foldgutter-open"; if (opts.indicatorFolded == null) opts.indicatorFolded = "CodeMirror-foldgutter-folded"; return opts; } function isFolded(cm, line) { var marks = cm.findMarks(Pos(line, 0), Pos(line + 1, 0)); for (var i = 0; i < marks.length; ++i) { if (marks[i].__isFold) { var fromPos = marks[i].find(-1); if (fromPos && fromPos.line === line) return marks[i]; } } } function marker(spec) { if (typeof spec == "string") { var elt = document.createElement("div"); elt.className = spec + " CodeMirror-guttermarker-subtle"; return elt; } else { return spec.cloneNode(true); } } function updateFoldInfo(cm, from, to) { var opts = cm.state.foldGutter.options, cur = from - 1; var minSize = cm.foldOption(opts, "minFoldSize"); var func = cm.foldOption(opts, "rangeFinder"); // we can reuse the built-in indicator element if its className matches the new state var clsFolded = typeof opts.indicatorFolded == "string" && classTest(opts.indicatorFolded); var clsOpen = typeof opts.indicatorOpen == "string" && classTest(opts.indicatorOpen); cm.eachLine(from, to, function(line) { ++cur; var mark = null; var old = line.gutterMarkers; if (old) old = old[opts.gutter]; if (isFolded(cm, cur)) { if (clsFolded && old && clsFolded.test(old.className)) return; mark = marker(opts.indicatorFolded); } else { var pos = Pos(cur, 0); var range = func && func(cm, pos); if (range && range.to.line - range.from.line >= minSize) { if (clsOpen && old && clsOpen.test(old.className)) return; mark = marker(opts.indicatorOpen); } } if (!mark && !old) return; cm.setGutterMarker(line, opts.gutter, mark); }); } // copied from CodeMirror/src/util/dom.js function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") } function updateInViewport(cm) { var vp = cm.getViewport(), state = cm.state.foldGutter; if (!state) return; cm.operation(function() { updateFoldInfo(cm, vp.from, vp.to); }); state.from = vp.from; state.to = vp.to; } function onGutterClick(cm, line, gutter) { var state = cm.state.foldGutter; if (!state) return; var opts = state.options; if (gutter != opts.gutter) return; var folded = isFolded(cm, line); if (folded) folded.clear(); else cm.foldCode(Pos(line, 0), opts); } function onChange(cm) { var state = cm.state.foldGutter; if (!state) return; var opts = state.options; state.from = state.to = 0; clearTimeout(state.changeUpdate); state.changeUpdate = setTimeout(function() { updateInViewport(cm); }, opts.foldOnChangeTimeSpan || 600); } function onViewportChange(cm) { var state = cm.state.foldGutter; if (!state) return; var opts = state.options; clearTimeout(state.changeUpdate); state.changeUpdate = setTimeout(function() { var vp = cm.getViewport(); if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) { updateInViewport(cm); } else { cm.operation(function() { if (vp.from < state.from) { updateFoldInfo(cm, vp.from, state.from); state.from = vp.from; } if (vp.to > state.to) { updateFoldInfo(cm, state.to, vp.to); state.to = vp.to; } }); } }, opts.updateViewportTimeSpan || 400); } function onFold(cm, from) { var state = cm.state.foldGutter; if (!state) return; var line = from.line; if (line >= state.from && line < state.to) updateFoldInfo(cm, line, line + 1); } }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/fold/indent-fold.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; function lineIndent(cm, lineNo) { var text = cm.getLine(lineNo) var spaceTo = text.search(/\S/) if (spaceTo == -1 || /\bcomment\b/.test(cm.getTokenTypeAt(CodeMirror.Pos(lineNo, spaceTo + 1)))) return -1 return CodeMirror.countColumn(text, null, cm.getOption("tabSize")) } CodeMirror.registerHelper("fold", "indent", function(cm, start) { var myIndent = lineIndent(cm, start.line) if (myIndent < 0) return var lastLineInFold = null // Go through lines until we find a line that definitely doesn't belong in // the block we're folding, or to the end. for (var i = start.line + 1, end = cm.lastLine(); i <= end; ++i) { var indent = lineIndent(cm, i) if (indent == -1) { } else if (indent > myIndent) { // Lines with a greater indent are considered part of the block. lastLineInFold = i; } else { // If this line has non-space, non-comment content, and is // indented less or equal to the start line, it is the start of // another block. break; } } if (lastLineInFold) return { from: CodeMirror.Pos(start.line, cm.getLine(start.line).length), to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length) }; }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/fold/markdown-fold.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.registerHelper("fold", "markdown", function(cm, start) { var maxDepth = 100; function isHeader(lineNo) { var tokentype = cm.getTokenTypeAt(CodeMirror.Pos(lineNo, 0)); return tokentype && /\bheader\b/.test(tokentype); } function headerLevel(lineNo, line, nextLine) { var match = line && line.match(/^#+/); if (match && isHeader(lineNo)) return match[0].length; match = nextLine && nextLine.match(/^[=\-]+\s*$/); if (match && isHeader(lineNo + 1)) return nextLine[0] == "=" ? 1 : 2; return maxDepth; } var firstLine = cm.getLine(start.line), nextLine = cm.getLine(start.line + 1); var level = headerLevel(start.line, firstLine, nextLine); if (level === maxDepth) return undefined; var lastLineNo = cm.lastLine(); var end = start.line, nextNextLine = cm.getLine(end + 2); while (end < lastLineNo) { if (headerLevel(end + 1, nextLine, nextNextLine) <= level) break; ++end; nextLine = nextNextLine; nextNextLine = cm.getLine(end + 2); } return { from: CodeMirror.Pos(start.line, firstLine.length), to: CodeMirror.Pos(end, cm.getLine(end).length) }; }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/fold/xml-fold.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var Pos = CodeMirror.Pos; function cmp(a, b) { return a.line - b.line || a.ch - b.ch; } var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"; var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; var xmlTagStart = new RegExp("<(/?)([" + nameStartChar + "][" + nameChar + "]*)", "g"); function Iter(cm, line, ch, range) { this.line = line; this.ch = ch; this.cm = cm; this.text = cm.getLine(line); this.min = range ? Math.max(range.from, cm.firstLine()) : cm.firstLine(); this.max = range ? Math.min(range.to - 1, cm.lastLine()) : cm.lastLine(); } function tagAt(iter, ch) { var type = iter.cm.getTokenTypeAt(Pos(iter.line, ch)); return type && /\btag\b/.test(type); } function nextLine(iter) { if (iter.line >= iter.max) return; iter.ch = 0; iter.text = iter.cm.getLine(++iter.line); return true; } function prevLine(iter) { if (iter.line <= iter.min) return; iter.text = iter.cm.getLine(--iter.line); iter.ch = iter.text.length; return true; } function toTagEnd(iter) { for (;;) { var gt = iter.text.indexOf(">", iter.ch); if (gt == -1) { if (nextLine(iter)) continue; else return; } if (!tagAt(iter, gt + 1)) { iter.ch = gt + 1; continue; } var lastSlash = iter.text.lastIndexOf("/", gt); var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt)); iter.ch = gt + 1; return selfClose ? "selfClose" : "regular"; } } function toTagStart(iter) { for (;;) { var lt = iter.ch ? iter.text.lastIndexOf("<", iter.ch - 1) : -1; if (lt == -1) { if (prevLine(iter)) continue; else return; } if (!tagAt(iter, lt + 1)) { iter.ch = lt; continue; } xmlTagStart.lastIndex = lt; iter.ch = lt; var match = xmlTagStart.exec(iter.text); if (match && match.index == lt) return match; } } function toNextTag(iter) { for (;;) { xmlTagStart.lastIndex = iter.ch; var found = xmlTagStart.exec(iter.text); if (!found) { if (nextLine(iter)) continue; else return; } if (!tagAt(iter, found.index + 1)) { iter.ch = found.index + 1; continue; } iter.ch = found.index + found[0].length; return found; } } function toPrevTag(iter) { for (;;) { var gt = iter.ch ? iter.text.lastIndexOf(">", iter.ch - 1) : -1; if (gt == -1) { if (prevLine(iter)) continue; else return; } if (!tagAt(iter, gt + 1)) { iter.ch = gt; continue; } var lastSlash = iter.text.lastIndexOf("/", gt); var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt)); iter.ch = gt + 1; return selfClose ? "selfClose" : "regular"; } } function findMatchingClose(iter, tag) { var stack = []; for (;;) { var next = toNextTag(iter), end, startLine = iter.line, startCh = iter.ch - (next ? next[0].length : 0); if (!next || !(end = toTagEnd(iter))) return; if (end == "selfClose") continue; if (next[1]) { // closing tag for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == next[2]) { stack.length = i; break; } if (i < 0 && (!tag || tag == next[2])) return { tag: next[2], from: Pos(startLine, startCh), to: Pos(iter.line, iter.ch) }; } else { // opening tag stack.push(next[2]); } } } function findMatchingOpen(iter, tag) { var stack = []; for (;;) { var prev = toPrevTag(iter); if (!prev) return; if (prev == "selfClose") { toTagStart(iter); continue; } var endLine = iter.line, endCh = iter.ch; var start = toTagStart(iter); if (!start) return; if (start[1]) { // closing tag stack.push(start[2]); } else { // opening tag for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == start[2]) { stack.length = i; break; } if (i < 0 && (!tag || tag == start[2])) return { tag: start[2], from: Pos(iter.line, iter.ch), to: Pos(endLine, endCh) }; } } } CodeMirror.registerHelper("fold", "xml", function(cm, start) { var iter = new Iter(cm, start.line, 0); for (;;) { var openTag = toNextTag(iter) if (!openTag || iter.line != start.line) return var end = toTagEnd(iter) if (!end) return if (!openTag[1] && end != "selfClose") { var startPos = Pos(iter.line, iter.ch); var endPos = findMatchingClose(iter, openTag[2]); return endPos && cmp(endPos.from, startPos) > 0 ? {from: startPos, to: endPos.from} : null } } }); CodeMirror.findMatchingTag = function(cm, pos, range) { var iter = new Iter(cm, pos.line, pos.ch, range); if (iter.text.indexOf(">") == -1 && iter.text.indexOf("<") == -1) return; var end = toTagEnd(iter), to = end && Pos(iter.line, iter.ch); var start = end && toTagStart(iter); if (!end || !start || cmp(iter, pos) > 0) return; var here = {from: Pos(iter.line, iter.ch), to: to, tag: start[2]}; if (end == "selfClose") return {open: here, close: null, at: "open"}; if (start[1]) { // closing tag return {open: findMatchingOpen(iter, start[2]), close: here, at: "close"}; } else { // opening tag iter = new Iter(cm, to.line, to.ch, range); return {open: here, close: findMatchingClose(iter, start[2]), at: "open"}; } }; CodeMirror.findEnclosingTag = function(cm, pos, range, tag) { var iter = new Iter(cm, pos.line, pos.ch, range); for (;;) { var open = findMatchingOpen(iter, tag); if (!open) break; var forward = new Iter(cm, pos.line, pos.ch, range); var close = findMatchingClose(forward, open.tag); if (close) return {open: open, close: close}; } }; // Used by addon/edit/closetag.js CodeMirror.scanForClosingTag = function(cm, pos, name, end) { var iter = new Iter(cm, pos.line, pos.ch, end ? {from: 0, to: end} : null); return findMatchingClose(iter, name); }; }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/hint/anyword-hint.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var WORD = /[\w$]+/, RANGE = 500; CodeMirror.registerHelper("hint", "anyword", function(editor, options) { var word = options && options.word || WORD; var range = options && options.range || RANGE; var cur = editor.getCursor(), curLine = editor.getLine(cur.line); var end = cur.ch, start = end; while (start && word.test(curLine.charAt(start - 1))) --start; var curWord = start != end && curLine.slice(start, end); var list = options && options.list || [], seen = {}; var re = new RegExp(word.source, "g"); for (var dir = -1; dir <= 1; dir += 2) { var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir; for (; line != endLine; line += dir) { var text = editor.getLine(line), m; while (m = re.exec(text)) { if (line == cur.line && m[0] === curWord) continue; if ((!curWord || m[0].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[0])) { seen[m[0]] = true; list.push(m[0]); } } } } return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)}; }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/hint/html-hint.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("./xml-hint")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "./xml-hint"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var langs = "ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" "); var targets = ["_blank", "_self", "_top", "_parent"]; var charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"]; var methods = ["get", "post", "put", "delete"]; var encs = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]; var media = ["all", "screen", "print", "embossed", "braille", "handheld", "print", "projection", "screen", "tty", "tv", "speech", "3d-glasses", "resolution [>][<][=] [X]", "device-aspect-ratio: X/Y", "orientation:portrait", "orientation:landscape", "device-height: [X]", "device-width: [X]"]; var s = { attrs: {} }; // Simple tag, reused for a whole lot of tags var data = { a: { attrs: { href: null, ping: null, type: null, media: media, target: targets, hreflang: langs } }, abbr: s, acronym: s, address: s, applet: s, area: { attrs: { alt: null, coords: null, href: null, target: null, ping: null, media: media, hreflang: langs, type: null, shape: ["default", "rect", "circle", "poly"] } }, article: s, aside: s, audio: { attrs: { src: null, mediagroup: null, crossorigin: ["anonymous", "use-credentials"], preload: ["none", "metadata", "auto"], autoplay: ["", "autoplay"], loop: ["", "loop"], controls: ["", "controls"] } }, b: s, base: { attrs: { href: null, target: targets } }, basefont: s, bdi: s, bdo: s, big: s, blockquote: { attrs: { cite: null } }, body: s, br: s, button: { attrs: { form: null, formaction: null, name: null, value: null, autofocus: ["", "autofocus"], disabled: ["", "autofocus"], formenctype: encs, formmethod: methods, formnovalidate: ["", "novalidate"], formtarget: targets, type: ["submit", "reset", "button"] } }, canvas: { attrs: { width: null, height: null } }, caption: s, center: s, cite: s, code: s, col: { attrs: { span: null } }, colgroup: { attrs: { span: null } }, command: { attrs: { type: ["command", "checkbox", "radio"], label: null, icon: null, radiogroup: null, command: null, title: null, disabled: ["", "disabled"], checked: ["", "checked"] } }, data: { attrs: { value: null } }, datagrid: { attrs: { disabled: ["", "disabled"], multiple: ["", "multiple"] } }, datalist: { attrs: { data: null } }, dd: s, del: { attrs: { cite: null, datetime: null } }, details: { attrs: { open: ["", "open"] } }, dfn: s, dir: s, div: s, dl: s, dt: s, em: s, embed: { attrs: { src: null, type: null, width: null, height: null } }, eventsource: { attrs: { src: null } }, fieldset: { attrs: { disabled: ["", "disabled"], form: null, name: null } }, figcaption: s, figure: s, font: s, footer: s, form: { attrs: { action: null, name: null, "accept-charset": charsets, autocomplete: ["on", "off"], enctype: encs, method: methods, novalidate: ["", "novalidate"], target: targets } }, frame: s, frameset: s, h1: s, h2: s, h3: s, h4: s, h5: s, h6: s, head: { attrs: {}, children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"] }, header: s, hgroup: s, hr: s, html: { attrs: { manifest: null }, children: ["head", "body"] }, i: s, iframe: { attrs: { src: null, srcdoc: null, name: null, width: null, height: null, sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"], seamless: ["", "seamless"] } }, img: { attrs: { alt: null, src: null, ismap: null, usemap: null, width: null, height: null, crossorigin: ["anonymous", "use-credentials"] } }, input: { attrs: { alt: null, dirname: null, form: null, formaction: null, height: null, list: null, max: null, maxlength: null, min: null, name: null, pattern: null, placeholder: null, size: null, src: null, step: null, value: null, width: null, accept: ["audio/*", "video/*", "image/*"], autocomplete: ["on", "off"], autofocus: ["", "autofocus"], checked: ["", "checked"], disabled: ["", "disabled"], formenctype: encs, formmethod: methods, formnovalidate: ["", "novalidate"], formtarget: targets, multiple: ["", "multiple"], readonly: ["", "readonly"], required: ["", "required"], type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month", "week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio", "file", "submit", "image", "reset", "button"] } }, ins: { attrs: { cite: null, datetime: null } }, kbd: s, keygen: { attrs: { challenge: null, form: null, name: null, autofocus: ["", "autofocus"], disabled: ["", "disabled"], keytype: ["RSA"] } }, label: { attrs: { "for": null, form: null } }, legend: s, li: { attrs: { value: null } }, link: { attrs: { href: null, type: null, hreflang: langs, media: media, sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"] } }, map: { attrs: { name: null } }, mark: s, menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } }, meta: { attrs: { content: null, charset: charsets, name: ["viewport", "application-name", "author", "description", "generator", "keywords"], "http-equiv": ["content-language", "content-type", "default-style", "refresh"] } }, meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } }, nav: s, noframes: s, noscript: s, object: { attrs: { data: null, type: null, name: null, usemap: null, form: null, width: null, height: null, typemustmatch: ["", "typemustmatch"] } }, ol: { attrs: { reversed: ["", "reversed"], start: null, type: ["1", "a", "A", "i", "I"] } }, optgroup: { attrs: { disabled: ["", "disabled"], label: null } }, option: { attrs: { disabled: ["", "disabled"], label: null, selected: ["", "selected"], value: null } }, output: { attrs: { "for": null, form: null, name: null } }, p: s, param: { attrs: { name: null, value: null } }, pre: s, progress: { attrs: { value: null, max: null } }, q: { attrs: { cite: null } }, rp: s, rt: s, ruby: s, s: s, samp: s, script: { attrs: { type: ["text/javascript"], src: null, async: ["", "async"], defer: ["", "defer"], charset: charsets } }, section: s, select: { attrs: { form: null, name: null, size: null, autofocus: ["", "autofocus"], disabled: ["", "disabled"], multiple: ["", "multiple"] } }, small: s, source: { attrs: { src: null, type: null, media: null } }, span: s, strike: s, strong: s, style: { attrs: { type: ["text/css"], media: media, scoped: null } }, sub: s, summary: s, sup: s, table: s, tbody: s, td: { attrs: { colspan: null, rowspan: null, headers: null } }, textarea: { attrs: { dirname: null, form: null, maxlength: null, name: null, placeholder: null, rows: null, cols: null, autofocus: ["", "autofocus"], disabled: ["", "disabled"], readonly: ["", "readonly"], required: ["", "required"], wrap: ["soft", "hard"] } }, tfoot: s, th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } }, thead: s, time: { attrs: { datetime: null } }, title: s, tr: s, track: { attrs: { src: null, label: null, "default": null, kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"], srclang: langs } }, tt: s, u: s, ul: s, "var": s, video: { attrs: { src: null, poster: null, width: null, height: null, crossorigin: ["anonymous", "use-credentials"], preload: ["auto", "metadata", "none"], autoplay: ["", "autoplay"], mediagroup: ["movie"], muted: ["", "muted"], controls: ["", "controls"] } }, wbr: s }; var globalAttrs = { accesskey: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], "class": null, contenteditable: ["true", "false"], contextmenu: null, dir: ["ltr", "rtl", "auto"], draggable: ["true", "false", "auto"], dropzone: ["copy", "move", "link", "string:", "file:"], hidden: ["hidden"], id: null, inert: ["inert"], itemid: null, itemprop: null, itemref: null, itemscope: ["itemscope"], itemtype: null, lang: ["en", "es"], spellcheck: ["true", "false"], autocorrect: ["true", "false"], autocapitalize: ["true", "false"], style: null, tabindex: ["1", "2", "3", "4", "5", "6", "7", "8", "9"], title: null, translate: ["yes", "no"], onclick: null, rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"] }; function populate(obj) { for (var attr in globalAttrs) if (globalAttrs.hasOwnProperty(attr)) obj.attrs[attr] = globalAttrs[attr]; } populate(s); for (var tag in data) if (data.hasOwnProperty(tag) && data[tag] != s) populate(data[tag]); CodeMirror.htmlSchema = data; function htmlHint(cm, options) { var local = {schemaInfo: data}; if (options) for (var opt in options) local[opt] = options[opt]; return CodeMirror.hint.xml(cm, local); } CodeMirror.registerHelper("hint", "html", htmlHint); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/hint/show-hint.css ================================================ .CodeMirror-hints { position: absolute; z-index: 10; overflow: hidden; list-style: none; margin: 0; padding: 2px; -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2); -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2); box-shadow: 2px 3px 5px rgba(0,0,0,.2); border-radius: 3px; border: 1px solid silver; background: white; font-size: 90%; font-family: monospace; max-height: 20em; overflow-y: auto; } .CodeMirror-hint { margin: 0; padding: 0 4px; border-radius: 2px; white-space: pre; color: black; cursor: pointer; } li.CodeMirror-hint-active { background: #08f; color: white; } ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/hint/show-hint.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var HINT_ELEMENT_CLASS = "CodeMirror-hint"; var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active"; // This is the old interface, kept around for now to stay // backwards-compatible. CodeMirror.showHint = function(cm, getHints, options) { if (!getHints) return cm.showHint(options); if (options && options.async) getHints.async = true; var newOpts = {hint: getHints}; if (options) for (var prop in options) newOpts[prop] = options[prop]; return cm.showHint(newOpts); }; CodeMirror.defineExtension("showHint", function(options) { options = parseOptions(this, this.getCursor("start"), options); var selections = this.listSelections() if (selections.length > 1) return; // By default, don't allow completion when something is selected. // A hint function can have a `supportsSelection` property to // indicate that it can handle selections. if (this.somethingSelected()) { if (!options.hint.supportsSelection) return; // Don't try with cross-line selections for (var i = 0; i < selections.length; i++) if (selections[i].head.line != selections[i].anchor.line) return; } if (this.state.completionActive) this.state.completionActive.close(); var completion = this.state.completionActive = new Completion(this, options); if (!completion.options.hint) return; CodeMirror.signal(this, "startCompletion", this); completion.update(true); }); CodeMirror.defineExtension("closeHint", function() { if (this.state.completionActive) this.state.completionActive.close() }) function Completion(cm, options) { this.cm = cm; this.options = options; this.widget = null; this.debounce = 0; this.tick = 0; this.startPos = this.cm.getCursor("start"); this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length; var self = this; cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); }); } var requestAnimationFrame = window.requestAnimationFrame || function(fn) { return setTimeout(fn, 1000/60); }; var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout; Completion.prototype = { close: function() { if (!this.active()) return; this.cm.state.completionActive = null; this.tick = null; this.cm.off("cursorActivity", this.activityFunc); if (this.widget && this.data) CodeMirror.signal(this.data, "close"); if (this.widget) this.widget.close(); CodeMirror.signal(this.cm, "endCompletion", this.cm); }, active: function() { return this.cm.state.completionActive == this; }, pick: function(data, i) { var completion = data.list[i], self = this; this.cm.operation(function() { if (completion.hint) completion.hint(self.cm, data, completion); else self.cm.replaceRange(getText(completion), completion.from || data.from, completion.to || data.to, "complete"); CodeMirror.signal(data, "pick", completion); self.cm.scrollIntoView(); }) this.close(); }, cursorActivity: function() { if (this.debounce) { cancelAnimationFrame(this.debounce); this.debounce = 0; } var identStart = this.startPos; if(this.data) { identStart = this.data.from; } var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line); if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch || pos.ch < identStart.ch || this.cm.somethingSelected() || (!pos.ch || this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) { this.close(); } else { var self = this; this.debounce = requestAnimationFrame(function() {self.update();}); if (this.widget) this.widget.disable(); } }, update: function(first) { if (this.tick == null) return var self = this, myTick = ++this.tick fetchHints(this.options.hint, this.cm, this.options, function(data) { if (self.tick == myTick) self.finishUpdate(data, first) }) }, finishUpdate: function(data, first) { if (this.data) CodeMirror.signal(this.data, "update"); var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle); if (this.widget) this.widget.close(); this.data = data; if (data && data.list.length) { if (picked && data.list.length == 1) { this.pick(data, 0); } else { this.widget = new Widget(this, data); CodeMirror.signal(data, "shown"); } } } }; function parseOptions(cm, pos, options) { var editor = cm.options.hintOptions; var out = {}; for (var prop in defaultOptions) out[prop] = defaultOptions[prop]; if (editor) for (var prop in editor) if (editor[prop] !== undefined) out[prop] = editor[prop]; if (options) for (var prop in options) if (options[prop] !== undefined) out[prop] = options[prop]; if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos) return out; } function getText(completion) { if (typeof completion == "string") return completion; else return completion.text; } function buildKeyMap(completion, handle) { var baseMap = { Up: function() {handle.moveFocus(-1);}, Down: function() {handle.moveFocus(1);}, PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);}, PageDown: function() {handle.moveFocus(handle.menuSize() - 1, true);}, Home: function() {handle.setFocus(0);}, End: function() {handle.setFocus(handle.length - 1);}, Enter: handle.pick, Tab: handle.pick, Esc: handle.close }; var mac = /Mac/.test(navigator.platform); if (mac) { baseMap["Ctrl-P"] = function() {handle.moveFocus(-1);}; baseMap["Ctrl-N"] = function() {handle.moveFocus(1);}; } var custom = completion.options.customKeys; var ourMap = custom ? {} : baseMap; function addBinding(key, val) { var bound; if (typeof val != "string") bound = function(cm) { return val(cm, handle); }; // This mechanism is deprecated else if (baseMap.hasOwnProperty(val)) bound = baseMap[val]; else bound = val; ourMap[key] = bound; } if (custom) for (var key in custom) if (custom.hasOwnProperty(key)) addBinding(key, custom[key]); var extra = completion.options.extraKeys; if (extra) for (var key in extra) if (extra.hasOwnProperty(key)) addBinding(key, extra[key]); return ourMap; } function getHintElement(hintsElement, el) { while (el && el != hintsElement) { if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement) return el; el = el.parentNode; } } function Widget(completion, data) { this.completion = completion; this.data = data; this.picked = false; var widget = this, cm = completion.cm; var ownerDocument = cm.getInputField().ownerDocument; var parentWindow = ownerDocument.defaultView || ownerDocument.parentWindow; var hints = this.hints = ownerDocument.createElement("ul"); var theme = completion.cm.options.theme; hints.className = "CodeMirror-hints " + theme; this.selectedHint = data.selectedHint || 0; var completions = data.list; for (var i = 0; i < completions.length; ++i) { var elt = hints.appendChild(ownerDocument.createElement("li")), cur = completions[i]; var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS); if (cur.className != null) className = cur.className + " " + className; elt.className = className; if (cur.render) cur.render(elt, data, cur); else elt.appendChild(ownerDocument.createTextNode(cur.displayText || getText(cur))); elt.hintId = i; } var container = completion.options.container || ownerDocument.body; var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null); var left = pos.left, top = pos.bottom, below = true; var offsetLeft = 0, offsetTop = 0; if (container !== ownerDocument.body) { // We offset the cursor position because left and top are relative to the offsetParent's top left corner. var isContainerPositioned = ['absolute', 'relative', 'fixed'].indexOf(parentWindow.getComputedStyle(container).position) !== -1; var offsetParent = isContainerPositioned ? container : container.offsetParent; var offsetParentPosition = offsetParent.getBoundingClientRect(); var bodyPosition = ownerDocument.body.getBoundingClientRect(); offsetLeft = (offsetParentPosition.left - bodyPosition.left - offsetParent.scrollLeft); offsetTop = (offsetParentPosition.top - bodyPosition.top - offsetParent.scrollTop); } hints.style.left = (left - offsetLeft) + "px"; hints.style.top = (top - offsetTop) + "px"; // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor. var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth); var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight); container.appendChild(hints); var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH; var scrolls = hints.scrollHeight > hints.clientHeight + 1 var startScroll = cm.getScrollInfo(); if (overlapY > 0) { var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top); if (curTop - height > 0) { // Fits above cursor hints.style.top = (top = pos.top - height - offsetTop) + "px"; below = false; } else if (height > winH) { hints.style.height = (winH - 5) + "px"; hints.style.top = (top = pos.bottom - box.top - offsetTop) + "px"; var cursor = cm.getCursor(); if (data.from.ch != cursor.ch) { pos = cm.cursorCoords(cursor); hints.style.left = (left = pos.left - offsetLeft) + "px"; box = hints.getBoundingClientRect(); } } } var overlapX = box.right - winW; if (overlapX > 0) { if (box.right - box.left > winW) { hints.style.width = (winW - 5) + "px"; overlapX -= (box.right - box.left) - winW; } hints.style.left = (left = pos.left - overlapX - offsetLeft) + "px"; } if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling) node.style.paddingRight = cm.display.nativeBarWidth + "px" cm.addKeyMap(this.keyMap = buildKeyMap(completion, { moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); }, setFocus: function(n) { widget.changeActive(n); }, menuSize: function() { return widget.screenAmount(); }, length: completions.length, close: function() { completion.close(); }, pick: function() { widget.pick(); }, data: data })); if (completion.options.closeOnUnfocus) { var closingOnBlur; cm.on("blur", this.onBlur = function() { closingOnBlur = setTimeout(function() { completion.close(); }, 100); }); cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); }); } cm.on("scroll", this.onScroll = function() { var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect(); var newTop = top + startScroll.top - curScroll.top; var point = newTop - (parentWindow.pageYOffset || (ownerDocument.documentElement || ownerDocument.body).scrollTop); if (!below) point += hints.offsetHeight; if (point <= editor.top || point >= editor.bottom) return completion.close(); hints.style.top = newTop + "px"; hints.style.left = (left + startScroll.left - curScroll.left) + "px"; }); CodeMirror.on(hints, "dblclick", function(e) { var t = getHintElement(hints, e.target || e.srcElement); if (t && t.hintId != null) {widget.changeActive(t.hintId); widget.pick();} }); CodeMirror.on(hints, "click", function(e) { var t = getHintElement(hints, e.target || e.srcElement); if (t && t.hintId != null) { widget.changeActive(t.hintId); if (completion.options.completeOnSingleClick) widget.pick(); } }); CodeMirror.on(hints, "mousedown", function() { setTimeout(function(){cm.focus();}, 20); }); this.scrollToActive() CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]); return true; } Widget.prototype = { close: function() { if (this.completion.widget != this) return; this.completion.widget = null; this.hints.parentNode.removeChild(this.hints); this.completion.cm.removeKeyMap(this.keyMap); var cm = this.completion.cm; if (this.completion.options.closeOnUnfocus) { cm.off("blur", this.onBlur); cm.off("focus", this.onFocus); } cm.off("scroll", this.onScroll); }, disable: function() { this.completion.cm.removeKeyMap(this.keyMap); var widget = this; this.keyMap = {Enter: function() { widget.picked = true; }}; this.completion.cm.addKeyMap(this.keyMap); }, pick: function() { this.completion.pick(this.data, this.selectedHint); }, changeActive: function(i, avoidWrap) { if (i >= this.data.list.length) i = avoidWrap ? this.data.list.length - 1 : 0; else if (i < 0) i = avoidWrap ? 0 : this.data.list.length - 1; if (this.selectedHint == i) return; var node = this.hints.childNodes[this.selectedHint]; if (node) node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, ""); node = this.hints.childNodes[this.selectedHint = i]; node.className += " " + ACTIVE_HINT_ELEMENT_CLASS; this.scrollToActive() CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node); }, scrollToActive: function() { var margin = this.completion.options.scrollMargin || 0; var node1 = this.hints.childNodes[Math.max(0, this.selectedHint - margin)]; var node2 = this.hints.childNodes[Math.min(this.data.list.length - 1, this.selectedHint + margin)]; var firstNode = this.hints.firstChild; if (node1.offsetTop < this.hints.scrollTop) this.hints.scrollTop = node1.offsetTop - firstNode.offsetTop; else if (node2.offsetTop + node2.offsetHeight > this.hints.scrollTop + this.hints.clientHeight) this.hints.scrollTop = node2.offsetTop + node2.offsetHeight - this.hints.clientHeight + firstNode.offsetTop; }, screenAmount: function() { return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1; } }; function applicableHelpers(cm, helpers) { if (!cm.somethingSelected()) return helpers var result = [] for (var i = 0; i < helpers.length; i++) if (helpers[i].supportsSelection) result.push(helpers[i]) return result } function fetchHints(hint, cm, options, callback) { if (hint.async) { hint(cm, callback, options) } else { var result = hint(cm, options) if (result && result.then) result.then(callback) else callback(result) } } function resolveAutoHints(cm, pos) { var helpers = cm.getHelpers(pos, "hint"), words if (helpers.length) { var resolved = function(cm, callback, options) { var app = applicableHelpers(cm, helpers); function run(i) { if (i == app.length) return callback(null) fetchHints(app[i], cm, options, function(result) { if (result && result.list.length > 0) callback(result) else run(i + 1) }) } run(0) } resolved.async = true resolved.supportsSelection = true return resolved } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) { return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) } } else if (CodeMirror.hint.anyword) { return function(cm, options) { return CodeMirror.hint.anyword(cm, options) } } else { return function() {} } } CodeMirror.registerHelper("hint", "auto", { resolve: resolveAutoHints }); CodeMirror.registerHelper("hint", "fromList", function(cm, options) { var cur = cm.getCursor(), token = cm.getTokenAt(cur) var term, from = CodeMirror.Pos(cur.line, token.start), to = cur if (token.start < cur.ch && /\w/.test(token.string.charAt(cur.ch - token.start - 1))) { term = token.string.substr(0, cur.ch - token.start) } else { term = "" from = cur } var found = []; for (var i = 0; i < options.words.length; i++) { var word = options.words[i]; if (word.slice(0, term.length) == term) found.push(word); } if (found.length) return {list: found, from: from, to: to}; }); CodeMirror.commands.autocomplete = CodeMirror.showHint; var defaultOptions = { hint: CodeMirror.hint.auto, completeSingle: true, alignWithWord: true, closeCharacters: /[\s()\[\]{};:>,]/, closeOnUnfocus: true, completeOnSingleClick: true, container: null, customKeys: null, extraKeys: null }; CodeMirror.defineOption("hintOptions", null); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/hint/sql-hint.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../../mode/sql/sql")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../../mode/sql/sql"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var tables; var defaultTable; var keywords; var identifierQuote; var CONS = { QUERY_DIV: ";", ALIAS_KEYWORD: "AS" }; var Pos = CodeMirror.Pos, cmpPos = CodeMirror.cmpPos; function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" } function getKeywords(editor) { var mode = editor.doc.modeOption; if (mode === "sql") mode = "text/x-sql"; return CodeMirror.resolveMode(mode).keywords; } function getIdentifierQuote(editor) { var mode = editor.doc.modeOption; if (mode === "sql") mode = "text/x-sql"; return CodeMirror.resolveMode(mode).identifierQuote || "`"; } function getText(item) { return typeof item == "string" ? item : item.text; } function wrapTable(name, value) { if (isArray(value)) value = {columns: value} if (!value.text) value.text = name return value } function parseTables(input) { var result = {} if (isArray(input)) { for (var i = input.length - 1; i >= 0; i--) { var item = input[i] result[getText(item).toUpperCase()] = wrapTable(getText(item), item) } } else if (input) { for (var name in input) result[name.toUpperCase()] = wrapTable(name, input[name]) } return result } function getTable(name) { return tables[name.toUpperCase()] } function shallowClone(object) { var result = {}; for (var key in object) if (object.hasOwnProperty(key)) result[key] = object[key]; return result; } function match(string, word) { var len = string.length; var sub = getText(word).substr(0, len); return string.toUpperCase() === sub.toUpperCase(); } function addMatches(result, search, wordlist, formatter) { if (isArray(wordlist)) { for (var i = 0; i < wordlist.length; i++) if (match(search, wordlist[i])) result.push(formatter(wordlist[i])) } else { for (var word in wordlist) if (wordlist.hasOwnProperty(word)) { var val = wordlist[word] if (!val || val === true) val = word else val = val.displayText ? {text: val.text, displayText: val.displayText} : val.text if (match(search, val)) result.push(formatter(val)) } } } function cleanName(name) { // Get rid name from identifierQuote and preceding dot(.) if (name.charAt(0) == ".") { name = name.substr(1); } // replace doublicated identifierQuotes with single identifierQuotes // and remove single identifierQuotes var nameParts = name.split(identifierQuote+identifierQuote); for (var i = 0; i < nameParts.length; i++) nameParts[i] = nameParts[i].replace(new RegExp(identifierQuote,"g"), ""); return nameParts.join(identifierQuote); } function insertIdentifierQuotes(name) { var nameParts = getText(name).split("."); for (var i = 0; i < nameParts.length; i++) nameParts[i] = identifierQuote + // doublicate identifierQuotes nameParts[i].replace(new RegExp(identifierQuote,"g"), identifierQuote+identifierQuote) + identifierQuote; var escaped = nameParts.join("."); if (typeof name == "string") return escaped; name = shallowClone(name); name.text = escaped; return name; } function nameCompletion(cur, token, result, editor) { // Try to complete table, column names and return start position of completion var useIdentifierQuotes = false; var nameParts = []; var start = token.start; var cont = true; while (cont) { cont = (token.string.charAt(0) == "."); useIdentifierQuotes = useIdentifierQuotes || (token.string.charAt(0) == identifierQuote); start = token.start; nameParts.unshift(cleanName(token.string)); token = editor.getTokenAt(Pos(cur.line, token.start)); if (token.string == ".") { cont = true; token = editor.getTokenAt(Pos(cur.line, token.start)); } } // Try to complete table names var string = nameParts.join("."); addMatches(result, string, tables, function(w) { return useIdentifierQuotes ? insertIdentifierQuotes(w) : w; }); // Try to complete columns from defaultTable addMatches(result, string, defaultTable, function(w) { return useIdentifierQuotes ? insertIdentifierQuotes(w) : w; }); // Try to complete columns string = nameParts.pop(); var table = nameParts.join("."); var alias = false; var aliasTable = table; // Check if table is available. If not, find table by Alias if (!getTable(table)) { var oldTable = table; table = findTableByAlias(table, editor); if (table !== oldTable) alias = true; } var columns = getTable(table); if (columns && columns.columns) columns = columns.columns; if (columns) { addMatches(result, string, columns, function(w) { var tableInsert = table; if (alias == true) tableInsert = aliasTable; if (typeof w == "string") { w = tableInsert + "." + w; } else { w = shallowClone(w); w.text = tableInsert + "." + w.text; } return useIdentifierQuotes ? insertIdentifierQuotes(w) : w; }); } return start; } function eachWord(lineText, f) { var words = lineText.split(/\s+/) for (var i = 0; i < words.length; i++) if (words[i]) f(words[i].replace(/[,;]/g, '')) } function findTableByAlias(alias, editor) { var doc = editor.doc; var fullQuery = doc.getValue(); var aliasUpperCase = alias.toUpperCase(); var previousWord = ""; var table = ""; var separator = []; var validRange = { start: Pos(0, 0), end: Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).length) }; //add separator var indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV); while(indexOfSeparator != -1) { separator.push(doc.posFromIndex(indexOfSeparator)); indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV, indexOfSeparator+1); } separator.unshift(Pos(0, 0)); separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length)); //find valid range var prevItem = null; var current = editor.getCursor() for (var i = 0; i < separator.length; i++) { if ((prevItem == null || cmpPos(current, prevItem) > 0) && cmpPos(current, separator[i]) <= 0) { validRange = {start: prevItem, end: separator[i]}; break; } prevItem = separator[i]; } if (validRange.start) { var query = doc.getRange(validRange.start, validRange.end, false); for (var i = 0; i < query.length; i++) { var lineText = query[i]; eachWord(lineText, function(word) { var wordUpperCase = word.toUpperCase(); if (wordUpperCase === aliasUpperCase && getTable(previousWord)) table = previousWord; if (wordUpperCase !== CONS.ALIAS_KEYWORD) previousWord = word; }); if (table) break; } } return table; } CodeMirror.registerHelper("hint", "sql", function(editor, options) { tables = parseTables(options && options.tables) var defaultTableName = options && options.defaultTable; var disableKeywords = options && options.disableKeywords; defaultTable = defaultTableName && getTable(defaultTableName); keywords = getKeywords(editor); identifierQuote = getIdentifierQuote(editor); if (defaultTableName && !defaultTable) defaultTable = findTableByAlias(defaultTableName, editor); defaultTable = defaultTable || []; if (defaultTable.columns) defaultTable = defaultTable.columns; var cur = editor.getCursor(); var result = []; var token = editor.getTokenAt(cur), start, end, search; if (token.end > cur.ch) { token.end = cur.ch; token.string = token.string.slice(0, cur.ch - token.start); } if (token.string.match(/^[.`"'\w@][\w$#]*$/g)) { search = token.string; start = token.start; end = token.end; } else { start = end = cur.ch; search = ""; } if (search.charAt(0) == "." || search.charAt(0) == identifierQuote) { start = nameCompletion(cur, token, result, editor); } else { var objectOrClass = function(w, className) { if (typeof w === "object") { w.className = className; } else { w = { text: w, className: className }; } return w; }; addMatches(result, search, defaultTable, function(w) { return objectOrClass(w, "CodeMirror-hint-table CodeMirror-hint-default-table"); }); addMatches( result, search, tables, function(w) { return objectOrClass(w, "CodeMirror-hint-table"); } ); if (!disableKeywords) addMatches(result, search, keywords, function(w) { return objectOrClass(w.toUpperCase(), "CodeMirror-hint-keyword"); }); } return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)}; }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/hint/xml-hint.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var Pos = CodeMirror.Pos; function matches(hint, typed, matchInMiddle) { if (matchInMiddle) return hint.indexOf(typed) >= 0; else return hint.lastIndexOf(typed, 0) == 0; } function getHints(cm, options) { var tags = options && options.schemaInfo; var quote = (options && options.quoteChar) || '"'; var matchInMiddle = options && options.matchInMiddle; if (!tags) return; var cur = cm.getCursor(), token = cm.getTokenAt(cur); if (token.end > cur.ch) { token.end = cur.ch; token.string = token.string.slice(0, cur.ch - token.start); } var inner = CodeMirror.innerMode(cm.getMode(), token.state); if (!inner.mode.xmlCurrentTag) return var result = [], replaceToken = false, prefix; var tag = /\btag\b/.test(token.type) && !/>$/.test(token.string); var tagName = tag && /^\w/.test(token.string), tagStart; if (tagName) { var before = cm.getLine(cur.line).slice(Math.max(0, token.start - 2), token.start); var tagType = /<\/$/.test(before) ? "close" : /<$/.test(before) ? "open" : null; if (tagType) tagStart = token.start - (tagType == "close" ? 2 : 1); } else if (tag && token.string == "<") { tagType = "open"; } else if (tag && token.string == ""); } else { // Attribute completion var curTag = tagInfo && tags[tagInfo.name], attrs = curTag && curTag.attrs; var globalAttrs = tags["!attrs"]; if (!attrs && !globalAttrs) return; if (!attrs) { attrs = globalAttrs; } else if (globalAttrs) { // Combine tag-local and global attributes var set = {}; for (var nm in globalAttrs) if (globalAttrs.hasOwnProperty(nm)) set[nm] = globalAttrs[nm]; for (var nm in attrs) if (attrs.hasOwnProperty(nm)) set[nm] = attrs[nm]; attrs = set; } if (token.type == "string" || token.string == "=") { // A value var before = cm.getRange(Pos(cur.line, Math.max(0, cur.ch - 60)), Pos(cur.line, token.type == "string" ? token.start : token.end)); var atName = before.match(/([^\s\u00a0=<>\"\']+)=$/), atValues; if (!atName || !attrs.hasOwnProperty(atName[1]) || !(atValues = attrs[atName[1]])) return; if (typeof atValues == 'function') atValues = atValues.call(this, cm); // Functions can be used to supply values for autocomplete widget if (token.type == "string") { prefix = token.string; var n = 0; if (/['"]/.test(token.string.charAt(0))) { quote = token.string.charAt(0); prefix = token.string.slice(1); n++; } var len = token.string.length; if (/['"]/.test(token.string.charAt(len - 1))) { quote = token.string.charAt(len - 1); prefix = token.string.substr(n, len - 2); } if (n) { // an opening quote var line = cm.getLine(cur.line); if (line.length > token.end && line.charAt(token.end) == quote) token.end++; // include a closing quote } replaceToken = true; } for (var i = 0; i < atValues.length; ++i) if (!prefix || matches(atValues[i], prefix, matchInMiddle)) result.push(quote + atValues[i] + quote); } else { // An attribute name if (token.type == "attribute") { prefix = token.string; replaceToken = true; } for (var attr in attrs) if (attrs.hasOwnProperty(attr) && (!prefix || matches(attr, prefix, matchInMiddle))) result.push(attr); } } return { list: result, from: replaceToken ? Pos(cur.line, tagStart == null ? token.start : tagStart) : cur, to: replaceToken ? Pos(cur.line, token.end) : cur }; } CodeMirror.registerHelper("hint", "xml", getHints); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/lint/json-lint.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // Depends on jsonlint.js from https://github.com/zaach/jsonlint // declare global: jsonlint (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.registerHelper("lint", "json", function(text) { var found = []; if (!window.jsonlint) { if (window.console) { window.console.error("Error: window.jsonlint not defined, CodeMirror JSON linting cannot run."); } return found; } // for jsonlint's web dist jsonlint is exported as an object with a single property parser, of which parseError // is a subproperty var jsonlint = window.jsonlint.parser || window.jsonlint jsonlint.parseError = function(str, hash) { var loc = hash.loc; found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column), to: CodeMirror.Pos(loc.last_line - 1, loc.last_column), message: str}); }; try { jsonlint.parse(text); } catch(e) {} return found; }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/lint/jsonlint.js ================================================ var jsonlint=function(){var a=!0,b=!1,c={},d=function(){var a={trace:function(){},yy:{},symbols_:{error:2,JSONString:3,STRING:4,JSONNumber:5,NUMBER:6,JSONNullLiteral:7,NULL:8,JSONBooleanLiteral:9,TRUE:10,FALSE:11,JSONText:12,JSONValue:13,EOF:14,JSONObject:15,JSONArray:16,"{":17,"}":18,JSONMemberList:19,JSONMember:20,":":21,",":22,"[":23,"]":24,JSONElementList:25,$accept:0,$end:1},terminals_:{2:"error",4:"STRING",6:"NUMBER",8:"NULL",10:"TRUE",11:"FALSE",14:"EOF",17:"{",18:"}",21:":",22:",",23:"[",24:"]"},productions_:[0,[3,1],[5,1],[7,1],[9,1],[9,1],[12,2],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[15,2],[15,3],[20,3],[19,1],[19,3],[16,2],[16,3],[25,1],[25,3]],performAction:function(b,c,d,e,f,g,h){var i=g.length-1;switch(f){case 1:this.$=b.replace(/\\(\\|")/g,"$1").replace(/\\n/g,"\n").replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\v/g," ").replace(/\\f/g,"\f").replace(/\\b/g,"\b");break;case 2:this.$=Number(b);break;case 3:this.$=null;break;case 4:this.$=!0;break;case 5:this.$=!1;break;case 6:return this.$=g[i-1];case 13:this.$={};break;case 14:this.$=g[i-1];break;case 15:this.$=[g[i-2],g[i]];break;case 16:this.$={},this.$[g[i][0]]=g[i][1];break;case 17:this.$=g[i-2],g[i-2][g[i][0]]=g[i][1];break;case 18:this.$=[];break;case 19:this.$=g[i-1];break;case 20:this.$=[g[i]];break;case 21:this.$=g[i-2],g[i-2].push(g[i])}},table:[{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],12:1,13:2,15:7,16:8,17:[1,14],23:[1,15]},{1:[3]},{14:[1,16]},{14:[2,7],18:[2,7],22:[2,7],24:[2,7]},{14:[2,8],18:[2,8],22:[2,8],24:[2,8]},{14:[2,9],18:[2,9],22:[2,9],24:[2,9]},{14:[2,10],18:[2,10],22:[2,10],24:[2,10]},{14:[2,11],18:[2,11],22:[2,11],24:[2,11]},{14:[2,12],18:[2,12],22:[2,12],24:[2,12]},{14:[2,3],18:[2,3],22:[2,3],24:[2,3]},{14:[2,4],18:[2,4],22:[2,4],24:[2,4]},{14:[2,5],18:[2,5],22:[2,5],24:[2,5]},{14:[2,1],18:[2,1],21:[2,1],22:[2,1],24:[2,1]},{14:[2,2],18:[2,2],22:[2,2],24:[2,2]},{3:20,4:[1,12],18:[1,17],19:18,20:19},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:23,15:7,16:8,17:[1,14],23:[1,15],24:[1,21],25:22},{1:[2,6]},{14:[2,13],18:[2,13],22:[2,13],24:[2,13]},{18:[1,24],22:[1,25]},{18:[2,16],22:[2,16]},{21:[1,26]},{14:[2,18],18:[2,18],22:[2,18],24:[2,18]},{22:[1,28],24:[1,27]},{22:[2,20],24:[2,20]},{14:[2,14],18:[2,14],22:[2,14],24:[2,14]},{3:20,4:[1,12],20:29},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:30,15:7,16:8,17:[1,14],23:[1,15]},{14:[2,19],18:[2,19],22:[2,19],24:[2,19]},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:31,15:7,16:8,17:[1,14],23:[1,15]},{18:[2,17],22:[2,17]},{18:[2,15],22:[2,15]},{22:[2,21],24:[2,21]}],defaultActions:{16:[2,6]},parseError:function(b,c){throw new Error(b)},parse:function(b){function o(a){d.length=d.length-2*a,e.length=e.length-a,f.length=f.length-a}function p(){var a;return a=c.lexer.lex()||1,typeof a!="number"&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(b),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,typeof this.lexer.yylloc=="undefined"&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n),typeof this.yy.parseError=="function"&&(this.parseError=this.yy.parseError);var q,r,s,t,u,v,w={},x,y,z,A;for(;;){s=d[d.length-1],this.defaultActions[s]?t=this.defaultActions[s]:(q==null&&(q=p()),t=g[s]&&g[s][q]);if(typeof t=="undefined"||!t.length||!t[0]){if(!k){A=[];for(x in g[s])this.terminals_[x]&&x>2&&A.push("'"+this.terminals_[x]+"'");var B="";this.lexer.showPosition?B="Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+A.join(", ")+", got '"+this.terminals_[q]+"'":B="Parse error on line "+(i+1)+": Unexpected "+(q==1?"end of input":"'"+(this.terminals_[q]||q)+"'"),this.parseError(B,{text:this.lexer.match,token:this.terminals_[q]||q,line:this.lexer.yylineno,loc:n,expected:A})}if(k==3){if(q==m)throw new Error(B||"Parsing halted.");j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,q=p()}for(;;){if(l.toString()in g[s])break;if(s==0)throw new Error(B||"Parsing halted.");o(1),s=d[d.length-1]}r=q,q=l,s=d[d.length-1],t=g[s]&&g[s][l],k=3}if(t[0]instanceof Array&&t.length>1)throw new Error("Parse Error: multiple actions possible at state: "+s+", token: "+q);switch(t[0]){case 1:d.push(q),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(t[1]),q=null,r?(q=r,r=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:y=this.productions_[t[1]][1],w.$=e[e.length-y],w._$={first_line:f[f.length-(y||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(y||1)].first_column,last_column:f[f.length-1].last_column},v=this.performAction.call(w,h,j,i,this.yy,t[1],e,f);if(typeof v!="undefined")return v;y&&(d=d.slice(0,-1*y*2),e=e.slice(0,-1*y),f=f.slice(0,-1*y)),d.push(this.productions_[t[1]][0]),e.push(w.$),f.push(w._$),z=g[d[d.length-2]][d[d.length-1]],d.push(z);break;case 3:return!0}}return!0}},b=function(){var a={EOF:1,parseError:function(b,c){if(!this.yy.parseError)throw new Error(b);this.yy.parseError(b,c)},setInput:function(a){return this._input=a,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.match+=a,this.matched+=a;var b=a.match(/\n/);return b&&this.yylineno++,this._input=this._input.slice(1),a},unput:function(a){return this._input=a+this._input,this},more:function(){return this._more=!0,this},less:function(a){this._input=this.match.slice(a)+this._input},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=(new Array(a.length+1)).join("-");return a+this.upcomingInput()+"\n"+b+"^"},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d,e,f;this._more||(this.yytext="",this.match="");var g=this._currentRules();for(var h=0;hb[0].length)){b=c,d=h;if(!this.options.flex)break}}if(b){f=b[0].match(/\n.*/g),f&&(this.yylineno+=f.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:f?f[f.length-1].length-1:this.yylloc.last_column+b[0].length},this.yytext+=b[0],this.match+=b[0],this.yyleng=this.yytext.length,this._more=!1,this._input=this._input.slice(b[0].length),this.matched+=b[0],a=this.performAction.call(this,this.yy,this,g[d],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1);if(a)return a;return}if(this._input==="")return this.EOF;this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var b=this.next();return typeof b!="undefined"?b:this.lex()},begin:function(b){this.conditionStack.push(b)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(b){this.begin(b)}};return a.options={},a.performAction=function(b,c,d,e){var f=e;switch(d){case 0:break;case 1:return 6;case 2:return c.yytext=c.yytext.substr(1,c.yyleng-2),4;case 3:return 17;case 4:return 18;case 5:return 23;case 6:return 24;case 7:return 22;case 8:return 21;case 9:return 10;case 10:return 11;case 11:return 8;case 12:return 14;case 13:return"INVALID"}},a.rules=[/^(?:\s+)/,/^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,/^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,/^(?:\{)/,/^(?:\})/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?::)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:null\b)/,/^(?:$)/,/^(?:.)/],a.conditions={INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13],inclusive:!0}},a}();return a.lexer=b,a}();return typeof a!="undefined"&&typeof c!="undefined"&&(c.parser=d,c.parse=function(){return d.parse.apply(d,arguments)},c.main=function(d){if(!d[1])throw new Error("Usage: "+d[0]+" FILE");if(typeof process!="undefined")var e=a("fs").readFileSync(a("path").join(process.cwd(),d[1]),"utf8");else var f=a("file").path(a("file").cwd()),e=f.join(d[1]).read({charset:"utf-8"});return c.parser.parse(e)},typeof b!="undefined"&&a.main===b&&c.main(typeof process!="undefined"?process.argv.slice(1):a("system").args)),c}(); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/lint/lint.css ================================================ /* The lint marker gutter */ .CodeMirror-lint-markers { width: 16px; } .CodeMirror-lint-tooltip { background-color: #ffd; border: 1px solid black; border-radius: 4px 4px 4px 4px; color: black; font-family: monospace; font-size: 10pt; overflow: hidden; padding: 2px 5px; position: fixed; white-space: pre; white-space: pre-wrap; z-index: 100; max-width: 600px; opacity: 0; transition: opacity .4s; -moz-transition: opacity .4s; -webkit-transition: opacity .4s; -o-transition: opacity .4s; -ms-transition: opacity .4s; } .CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning { background-position: left bottom; background-repeat: repeat-x; } .CodeMirror-lint-mark-error { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==") ; } .CodeMirror-lint-mark-warning { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII="); } .CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning { background-position: center center; background-repeat: no-repeat; cursor: pointer; display: inline-block; height: 16px; width: 16px; vertical-align: middle; position: relative; } .CodeMirror-lint-message-error, .CodeMirror-lint-message-warning { padding-left: 18px; background-position: top left; background-repeat: no-repeat; } .CodeMirror-lint-marker-error, .CodeMirror-lint-message-error { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII="); } .CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII="); } .CodeMirror-lint-marker-multiple { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC"); background-repeat: no-repeat; background-position: right bottom; width: 100%; height: 100%; } ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/lint/lint.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var GUTTER_ID = "CodeMirror-lint-markers"; function showTooltip(cm, e, content) { var tt = document.createElement("div"); tt.className = "CodeMirror-lint-tooltip cm-s-" + cm.options.theme; tt.appendChild(content.cloneNode(true)); if (cm.state.lint.options.selfContain) cm.getWrapperElement().appendChild(tt); else document.body.appendChild(tt); function position(e) { if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position); tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px"; tt.style.left = (e.clientX + 5) + "px"; } CodeMirror.on(document, "mousemove", position); position(e); if (tt.style.opacity != null) tt.style.opacity = 1; return tt; } function rm(elt) { if (elt.parentNode) elt.parentNode.removeChild(elt); } function hideTooltip(tt) { if (!tt.parentNode) return; if (tt.style.opacity == null) rm(tt); tt.style.opacity = 0; setTimeout(function() { rm(tt); }, 600); } function showTooltipFor(cm, e, content, node) { var tooltip = showTooltip(cm, e, content); function hide() { CodeMirror.off(node, "mouseout", hide); if (tooltip) { hideTooltip(tooltip); tooltip = null; } } var poll = setInterval(function() { if (tooltip) for (var n = node;; n = n.parentNode) { if (n && n.nodeType == 11) n = n.host; if (n == document.body) return; if (!n) { hide(); break; } } if (!tooltip) return clearInterval(poll); }, 400); CodeMirror.on(node, "mouseout", hide); } function LintState(cm, options, hasGutter) { this.marked = []; this.options = options; this.timeout = null; this.hasGutter = hasGutter; this.onMouseOver = function(e) { onMouseOver(cm, e); }; this.waitingFor = 0 } function parseOptions(_cm, options) { if (options instanceof Function) return {getAnnotations: options}; if (!options || options === true) options = {}; return options; } function clearMarks(cm) { var state = cm.state.lint; if (state.hasGutter) cm.clearGutter(GUTTER_ID); for (var i = 0; i < state.marked.length; ++i) state.marked[i].clear(); state.marked.length = 0; } function makeMarker(cm, labels, severity, multiple, tooltips) { var marker = document.createElement("div"), inner = marker; marker.className = "CodeMirror-lint-marker-" + severity; if (multiple) { inner = marker.appendChild(document.createElement("div")); inner.className = "CodeMirror-lint-marker-multiple"; } if (tooltips != false) CodeMirror.on(inner, "mouseover", function(e) { showTooltipFor(cm, e, labels, inner); }); return marker; } function getMaxSeverity(a, b) { if (a == "error") return a; else return b; } function groupByLine(annotations) { var lines = []; for (var i = 0; i < annotations.length; ++i) { var ann = annotations[i], line = ann.from.line; (lines[line] || (lines[line] = [])).push(ann); } return lines; } function annotationTooltip(ann) { var severity = ann.severity; if (!severity) severity = "error"; var tip = document.createElement("div"); tip.className = "CodeMirror-lint-message-" + severity; if (typeof ann.messageHTML != 'undefined') { tip.innerHTML = ann.messageHTML; } else { tip.appendChild(document.createTextNode(ann.message)); } return tip; } function lintAsync(cm, getAnnotations, passOptions) { var state = cm.state.lint var id = ++state.waitingFor function abort() { id = -1 cm.off("change", abort) } cm.on("change", abort) getAnnotations(cm.getValue(), function(annotations, arg2) { cm.off("change", abort) if (state.waitingFor != id) return if (arg2 && annotations instanceof CodeMirror) annotations = arg2 cm.operation(function() {updateLinting(cm, annotations)}) }, passOptions, cm); } function startLinting(cm) { var state = cm.state.lint, options = state.options; /* * Passing rules in `options` property prevents JSHint (and other linters) from complaining * about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc. */ var passOptions = options.options || options; var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint"); if (!getAnnotations) return; if (options.async || getAnnotations.async) { lintAsync(cm, getAnnotations, passOptions) } else { var annotations = getAnnotations(cm.getValue(), passOptions, cm); if (!annotations) return; if (annotations.then) annotations.then(function(issues) { cm.operation(function() {updateLinting(cm, issues)}) }); else cm.operation(function() {updateLinting(cm, annotations)}) } } function updateLinting(cm, annotationsNotSorted) { clearMarks(cm); var state = cm.state.lint, options = state.options; var annotations = groupByLine(annotationsNotSorted); for (var line = 0; line < annotations.length; ++line) { var anns = annotations[line]; if (!anns) continue; var maxSeverity = null; var tipLabel = state.hasGutter && document.createDocumentFragment(); for (var i = 0; i < anns.length; ++i) { var ann = anns[i]; var severity = ann.severity; if (!severity) severity = "error"; maxSeverity = getMaxSeverity(maxSeverity, severity); if (options.formatAnnotation) ann = options.formatAnnotation(ann); if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann)); if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, { className: "CodeMirror-lint-mark-" + severity, __annotation: ann })); } if (state.hasGutter) cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, anns.length > 1, state.options.tooltips)); } if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm); } function onChange(cm) { var state = cm.state.lint; if (!state) return; clearTimeout(state.timeout); state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500); } function popupTooltips(cm, annotations, e) { var target = e.target || e.srcElement; var tooltip = document.createDocumentFragment(); for (var i = 0; i < annotations.length; i++) { var ann = annotations[i]; tooltip.appendChild(annotationTooltip(ann)); } showTooltipFor(cm, e, tooltip, target); } function onMouseOver(cm, e) { var target = e.target || e.srcElement; if (!/\bCodeMirror-lint-mark-/.test(target.className)) return; var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2; var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client")); var annotations = []; for (var i = 0; i < spans.length; ++i) { var ann = spans[i].__annotation; if (ann) annotations.push(ann); } if (annotations.length) popupTooltips(cm, annotations, e); } CodeMirror.defineOption("lint", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { clearMarks(cm); if (cm.state.lint.options.lintOnChange !== false) cm.off("change", onChange); CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver); clearTimeout(cm.state.lint.timeout); delete cm.state.lint; } if (val) { var gutters = cm.getOption("gutters"), hasLintGutter = false; for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true; var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter); if (state.options.lintOnChange !== false) cm.on("change", onChange); if (state.options.tooltips != false && state.options.tooltips != "gutter") CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver); startLinting(cm); } }); CodeMirror.defineExtension("performLint", function() { if (this.state.lint) startLinting(this); }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/mdn-like-custom.css ================================================ /* MDN-LIKE Theme - Mozilla Ported to CodeMirror by Peter Kroon Report bugs/issues here: https://github.com/codemirror/CodeMirror/issues GitHub: @peterkroon The mdn-like theme is inspired on the displayed code examples at: https://developer.mozilla.org/en-US/docs/Web/CSS/animation */ .cm-s-mdn-like.CodeMirror { color: #666; background-color: #fff; } .cm-s-mdn-like div.CodeMirror-selected { background: #fefdb5; } .cm-s-mdn-like .CodeMirror-line::selection, .cm-s-mdn-like .CodeMirror-line > span::selection, .cm-s-mdn-like .CodeMirror-line > span > span::selection { background: #fefdb5; } .cm-s-mdn-like .CodeMirror-line::-moz-selection, .cm-s-mdn-like .CodeMirror-line > span::-moz-selection, .cm-s-mdn-like .CodeMirror-line > span > span::-moz-selection { background: #fefdb5; } .cm-s-mdn-like .CodeMirror-gutters { background: #f8f8f8; color: #333; } .cm-s-mdn-like .CodeMirror-linenumber { color: #aaa; padding-left: 8px; } .cm-s-mdn-like .CodeMirror-cursor { border-left: 2px solid #222; } .cm-s-mdn-like .cm-keyword { color: #6262FF; } .cm-s-mdn-like .cm-atom { color: #F90; } .cm-s-mdn-like .cm-number { color: #ca7841; } .cm-s-mdn-like .cm-def { color: #8DA6CE; } .cm-s-mdn-like span.cm-variable-2, .cm-s-mdn-like span.cm-tag { color: #690; } .cm-s-mdn-like span.cm-variable-3, .cm-s-mdn-like span.cm-def, .cm-s-mdn-like span.cm-type { color: #07a; } .cm-s-mdn-like .cm-variable { color: #07a; } .cm-s-mdn-like .cm-property { color: #905; } .cm-s-mdn-like .cm-qualifier { color: #690; } .cm-s-mdn-like .cm-operator { color: #cda869; } .cm-s-mdn-like .cm-comment { color:#777; font-weight:normal; } .cm-s-mdn-like .cm-string { color:#07a; } .cm-s-mdn-like .cm-string-2 { color:#bd6b18; } /*?*/ .cm-s-mdn-like .cm-meta { color: #000; } /*?*/ .cm-s-mdn-like .cm-builtin { color: #9B7536; } /*?*/ .cm-s-mdn-like .cm-tag { color: #997643; } .cm-s-mdn-like .cm-attribute { color: #d6bb6d; } /*?*/ .cm-s-mdn-like .cm-header { color: #FF6400; } .cm-s-mdn-like .cm-hr { color: #AEAEAE; } .cm-s-mdn-like .cm-link { color:#ad9361; font-style:italic; text-decoration:none; } .cm-s-mdn-like .cm-error { border-bottom: 1px solid red; } div.cm-s-mdn-like .CodeMirror-activeline-background { background: #efefff; } div.cm-s-mdn-like span.CodeMirror-matchingbracket { outline:1px solid grey; color: inherit; } ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/scroll/annotatescrollbar.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineExtension("annotateScrollbar", function(options) { if (typeof options == "string") options = {className: options}; return new Annotation(this, options); }); CodeMirror.defineOption("scrollButtonHeight", 0); function Annotation(cm, options) { this.cm = cm; this.options = options; this.buttonHeight = options.scrollButtonHeight || cm.getOption("scrollButtonHeight"); this.annotations = []; this.doRedraw = this.doUpdate = null; this.div = cm.getWrapperElement().appendChild(document.createElement("div")); this.div.style.cssText = "position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none"; this.computeScale(); function scheduleRedraw(delay) { clearTimeout(self.doRedraw); self.doRedraw = setTimeout(function() { self.redraw(); }, delay); } var self = this; cm.on("refresh", this.resizeHandler = function() { clearTimeout(self.doUpdate); self.doUpdate = setTimeout(function() { if (self.computeScale()) scheduleRedraw(20); }, 100); }); cm.on("markerAdded", this.resizeHandler); cm.on("markerCleared", this.resizeHandler); if (options.listenForChanges !== false) cm.on("changes", this.changeHandler = function() { scheduleRedraw(250); }); } Annotation.prototype.computeScale = function() { var cm = this.cm; var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight - this.buttonHeight * 2) / cm.getScrollerElement().scrollHeight if (hScale != this.hScale) { this.hScale = hScale; return true; } }; Annotation.prototype.update = function(annotations) { this.annotations = annotations; this.redraw(); }; Annotation.prototype.redraw = function(compute) { if (compute !== false) this.computeScale(); var cm = this.cm, hScale = this.hScale; var frag = document.createDocumentFragment(), anns = this.annotations; var wrapping = cm.getOption("lineWrapping"); var singleLineH = wrapping && cm.defaultTextHeight() * 1.5; var curLine = null, curLineObj = null; function getY(pos, top) { if (curLine != pos.line) { curLine = pos.line; curLineObj = cm.getLineHandle(curLine); } if ((curLineObj.widgets && curLineObj.widgets.length) || (wrapping && curLineObj.height > singleLineH)) return cm.charCoords(pos, "local")[top ? "top" : "bottom"]; var topY = cm.heightAtLine(curLineObj, "local"); return topY + (top ? 0 : curLineObj.height); } var lastLine = cm.lastLine() if (cm.display.barWidth) for (var i = 0, nextTop; i < anns.length; i++) { var ann = anns[i]; if (ann.to.line > lastLine) continue; var top = nextTop || getY(ann.from, true) * hScale; var bottom = getY(ann.to, false) * hScale; while (i < anns.length - 1) { if (anns[i + 1].to.line > lastLine) break; nextTop = getY(anns[i + 1].from, true) * hScale; if (nextTop > bottom + .9) break; ann = anns[++i]; bottom = getY(ann.to, false) * hScale; } if (bottom == top) continue; var height = Math.max(bottom - top, 3); var elt = frag.appendChild(document.createElement("div")); elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth - 1, 2) + "px; top: " + (top + this.buttonHeight) + "px; height: " + height + "px"; elt.className = this.options.className; if (ann.id) { elt.setAttribute("annotation-id", ann.id); } } this.div.textContent = ""; this.div.appendChild(frag); }; Annotation.prototype.clear = function() { this.cm.off("refresh", this.resizeHandler); this.cm.off("markerAdded", this.resizeHandler); this.cm.off("markerCleared", this.resizeHandler); if (this.changeHandler) this.cm.off("changes", this.changeHandler); this.div.parentNode.removeChild(this.div); }; }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/scroll/scrollpastend.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineOption("scrollPastEnd", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { cm.off("change", onChange); cm.off("refresh", updateBottomMargin); cm.display.lineSpace.parentNode.style.paddingBottom = ""; cm.state.scrollPastEndPadding = null; } if (val) { cm.on("change", onChange); cm.on("refresh", updateBottomMargin); updateBottomMargin(cm); } }); function onChange(cm, change) { if (CodeMirror.changeEnd(change).line == cm.lastLine()) updateBottomMargin(cm); } function updateBottomMargin(cm) { var padding = ""; if (cm.lineCount() > 1) { var totalH = cm.display.scroller.clientHeight - 30, lastLineH = cm.getLineHandle(cm.lastLine()).height; padding = (totalH - lastLineH) + "px"; } if (cm.state.scrollPastEndPadding != padding) { cm.state.scrollPastEndPadding = padding; cm.display.lineSpace.parentNode.style.paddingBottom = padding; cm.off("refresh", updateBottomMargin); cm.setSize(); cm.on("refresh", updateBottomMargin); } } }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/scroll/simplescrollbars.css ================================================ .CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div { position: absolute; background: #ccc; -moz-box-sizing: border-box; box-sizing: border-box; border: 1px solid #bbb; border-radius: 2px; } .CodeMirror-simplescroll-horizontal, .CodeMirror-simplescroll-vertical { position: absolute; z-index: 6; background: #eee; } .CodeMirror-simplescroll-horizontal { bottom: 0; left: 0; height: 8px; } .CodeMirror-simplescroll-horizontal div { bottom: 0; height: 100%; } .CodeMirror-simplescroll-vertical { right: 0; top: 0; width: 8px; } .CodeMirror-simplescroll-vertical div { right: 0; width: 100%; } .CodeMirror-overlayscroll .CodeMirror-scrollbar-filler, .CodeMirror-overlayscroll .CodeMirror-gutter-filler { display: none; } .CodeMirror-overlayscroll-horizontal div, .CodeMirror-overlayscroll-vertical div { position: absolute; background: #bcd; border-radius: 3px; } .CodeMirror-overlayscroll-horizontal, .CodeMirror-overlayscroll-vertical { position: absolute; z-index: 6; } .CodeMirror-overlayscroll-horizontal { bottom: 0; left: 0; height: 6px; } .CodeMirror-overlayscroll-horizontal div { bottom: 0; height: 100%; } .CodeMirror-overlayscroll-vertical { right: 0; top: 0; width: 6px; } .CodeMirror-overlayscroll-vertical div { right: 0; width: 100%; } ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/scroll/simplescrollbars.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; function Bar(cls, orientation, scroll) { this.orientation = orientation; this.scroll = scroll; this.screen = this.total = this.size = 1; this.pos = 0; this.node = document.createElement("div"); this.node.className = cls + "-" + orientation; this.inner = this.node.appendChild(document.createElement("div")); var self = this; CodeMirror.on(this.inner, "mousedown", function(e) { if (e.which != 1) return; CodeMirror.e_preventDefault(e); var axis = self.orientation == "horizontal" ? "pageX" : "pageY"; var start = e[axis], startpos = self.pos; function done() { CodeMirror.off(document, "mousemove", move); CodeMirror.off(document, "mouseup", done); } function move(e) { if (e.which != 1) return done(); self.moveTo(startpos + (e[axis] - start) * (self.total / self.size)); } CodeMirror.on(document, "mousemove", move); CodeMirror.on(document, "mouseup", done); }); CodeMirror.on(this.node, "click", function(e) { CodeMirror.e_preventDefault(e); var innerBox = self.inner.getBoundingClientRect(), where; if (self.orientation == "horizontal") where = e.clientX < innerBox.left ? -1 : e.clientX > innerBox.right ? 1 : 0; else where = e.clientY < innerBox.top ? -1 : e.clientY > innerBox.bottom ? 1 : 0; self.moveTo(self.pos + where * self.screen); }); function onWheel(e) { var moved = CodeMirror.wheelEventPixels(e)[self.orientation == "horizontal" ? "x" : "y"]; var oldPos = self.pos; self.moveTo(self.pos + moved); if (self.pos != oldPos) CodeMirror.e_preventDefault(e); } CodeMirror.on(this.node, "mousewheel", onWheel); CodeMirror.on(this.node, "DOMMouseScroll", onWheel); } Bar.prototype.setPos = function(pos, force) { if (pos < 0) pos = 0; if (pos > this.total - this.screen) pos = this.total - this.screen; if (!force && pos == this.pos) return false; this.pos = pos; this.inner.style[this.orientation == "horizontal" ? "left" : "top"] = (pos * (this.size / this.total)) + "px"; return true }; Bar.prototype.moveTo = function(pos) { if (this.setPos(pos)) this.scroll(pos, this.orientation); } var minButtonSize = 10; Bar.prototype.update = function(scrollSize, clientSize, barSize) { var sizeChanged = this.screen != clientSize || this.total != scrollSize || this.size != barSize if (sizeChanged) { this.screen = clientSize; this.total = scrollSize; this.size = barSize; } var buttonSize = this.screen * (this.size / this.total); if (buttonSize < minButtonSize) { this.size -= minButtonSize - buttonSize; buttonSize = minButtonSize; } this.inner.style[this.orientation == "horizontal" ? "width" : "height"] = buttonSize + "px"; this.setPos(this.pos, sizeChanged); }; function SimpleScrollbars(cls, place, scroll) { this.addClass = cls; this.horiz = new Bar(cls, "horizontal", scroll); place(this.horiz.node); this.vert = new Bar(cls, "vertical", scroll); place(this.vert.node); this.width = null; } SimpleScrollbars.prototype.update = function(measure) { if (this.width == null) { var style = window.getComputedStyle ? window.getComputedStyle(this.horiz.node) : this.horiz.node.currentStyle; if (style) this.width = parseInt(style.height); } var width = this.width || 0; var needsH = measure.scrollWidth > measure.clientWidth + 1; var needsV = measure.scrollHeight > measure.clientHeight + 1; this.vert.node.style.display = needsV ? "block" : "none"; this.horiz.node.style.display = needsH ? "block" : "none"; if (needsV) { this.vert.update(measure.scrollHeight, measure.clientHeight, measure.viewHeight - (needsH ? width : 0)); this.vert.node.style.bottom = needsH ? width + "px" : "0"; } if (needsH) { this.horiz.update(measure.scrollWidth, measure.clientWidth, measure.viewWidth - (needsV ? width : 0) - measure.barLeft); this.horiz.node.style.right = needsV ? width + "px" : "0"; this.horiz.node.style.left = measure.barLeft + "px"; } return {right: needsV ? width : 0, bottom: needsH ? width : 0}; }; SimpleScrollbars.prototype.setScrollTop = function(pos) { this.vert.setPos(pos); }; SimpleScrollbars.prototype.setScrollLeft = function(pos) { this.horiz.setPos(pos); }; SimpleScrollbars.prototype.clear = function() { var parent = this.horiz.node.parentNode; parent.removeChild(this.horiz.node); parent.removeChild(this.vert.node); }; CodeMirror.scrollbarModel.simple = function(place, scroll) { return new SimpleScrollbars("CodeMirror-simplescroll", place, scroll); }; CodeMirror.scrollbarModel.overlay = function(place, scroll) { return new SimpleScrollbars("CodeMirror-overlayscroll", place, scroll); }; }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/search/jump-to-line.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // Defines jumpToLine command. Uses dialog.js if present. (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../dialog/dialog")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../dialog/dialog"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; function dialog(cm, text, shortText, deflt, f) { if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true}); else f(prompt(shortText, deflt)); } function getJumpDialog(cm) { return cm.phrase("Jump to line:") + ' ' + cm.phrase("(Use line:column or scroll% syntax)") + ''; } function interpretLine(cm, string) { var num = Number(string) if (/^[-+]/.test(string)) return cm.getCursor().line + num else return num - 1 } CodeMirror.commands.jumpToLine = function(cm) { var cur = cm.getCursor(); dialog(cm, getJumpDialog(cm), cm.phrase("Jump to line:"), (cur.line + 1) + ":" + cur.ch, function(posStr) { if (!posStr) return; var match; if (match = /^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(posStr)) { cm.setCursor(interpretLine(cm, match[1]), Number(match[2])) } else if (match = /^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(posStr)) { var line = Math.round(cm.lineCount() * Number(match[1]) / 100); if (/^[-+]/.test(match[1])) line = cur.line + line + 1; cm.setCursor(line - 1, cur.ch); } else if (match = /^\s*\:?\s*([\+\-]?\d+)\s*/.exec(posStr)) { cm.setCursor(interpretLine(cm, match[1]), cur.ch); } }); }; CodeMirror.keyMap["default"]["Alt-G"] = "jumpToLine"; }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/search/match-highlighter.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // Highlighting text that matches the selection // // Defines an option highlightSelectionMatches, which, when enabled, // will style strings that match the selection throughout the // document. // // The option can be set to true to simply enable it, or to a // {minChars, style, wordsOnly, showToken, delay} object to explicitly // configure it. minChars is the minimum amount of characters that should be // selected for the behavior to occur, and style is the token style to // apply to the matches. This will be prefixed by "cm-" to create an // actual CSS class name. If wordsOnly is enabled, the matches will be // highlighted only if the selected text is a word. showToken, when enabled, // will cause the current token to be highlighted when nothing is selected. // delay is used to specify how much time to wait, in milliseconds, before // highlighting the matches. If annotateScrollbar is enabled, the occurences // will be highlighted on the scrollbar via the matchesonscrollbar addon. (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("./matchesonscrollbar")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "./matchesonscrollbar"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var defaults = { style: "matchhighlight", minChars: 2, delay: 100, wordsOnly: false, annotateScrollbar: false, showToken: false, trim: true } function State(options) { this.options = {} for (var name in defaults) this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name] this.overlay = this.timeout = null; this.matchesonscroll = null; this.active = false; } CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { removeOverlay(cm); clearTimeout(cm.state.matchHighlighter.timeout); cm.state.matchHighlighter = null; cm.off("cursorActivity", cursorActivity); cm.off("focus", onFocus) } if (val) { var state = cm.state.matchHighlighter = new State(val); if (cm.hasFocus()) { state.active = true highlightMatches(cm) } else { cm.on("focus", onFocus) } cm.on("cursorActivity", cursorActivity); } }); function cursorActivity(cm) { var state = cm.state.matchHighlighter; if (state.active || cm.hasFocus()) scheduleHighlight(cm, state) } function onFocus(cm) { var state = cm.state.matchHighlighter if (!state.active) { state.active = true scheduleHighlight(cm, state) } } function scheduleHighlight(cm, state) { clearTimeout(state.timeout); state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay); } function addOverlay(cm, query, hasBoundary, style) { var state = cm.state.matchHighlighter; cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style)); if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) { var searchFor = hasBoundary ? new RegExp((/\w/.test(query.charAt(0)) ? "\\b" : "") + query.replace(/[\\\[.+*?(){|^$]/g, "\\$&") + (/\w/.test(query.charAt(query.length - 1)) ? "\\b" : "")) : query; state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, false, {className: "CodeMirror-selection-highlight-scrollbar"}); } } function removeOverlay(cm) { var state = cm.state.matchHighlighter; if (state.overlay) { cm.removeOverlay(state.overlay); state.overlay = null; if (state.matchesonscroll) { state.matchesonscroll.clear(); state.matchesonscroll = null; } } } function highlightMatches(cm) { cm.operation(function() { var state = cm.state.matchHighlighter; removeOverlay(cm); if (!cm.somethingSelected() && state.options.showToken) { var re = state.options.showToken === true ? /[\w$]/ : state.options.showToken; var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start; while (start && re.test(line.charAt(start - 1))) --start; while (end < line.length && re.test(line.charAt(end))) ++end; if (start < end) addOverlay(cm, line.slice(start, end), re, state.options.style); return; } var from = cm.getCursor("from"), to = cm.getCursor("to"); if (from.line != to.line) return; if (state.options.wordsOnly && !isWord(cm, from, to)) return; var selection = cm.getRange(from, to) if (state.options.trim) selection = selection.replace(/^\s+|\s+$/g, "") if (selection.length >= state.options.minChars) addOverlay(cm, selection, false, state.options.style); }); } function isWord(cm, from, to) { var str = cm.getRange(from, to); if (str.match(/^\w+$/) !== null) { if (from.ch > 0) { var pos = {line: from.line, ch: from.ch - 1}; var chr = cm.getRange(pos, from); if (chr.match(/\W/) === null) return false; } if (to.ch < cm.getLine(from.line).length) { var pos = {line: to.line, ch: to.ch + 1}; var chr = cm.getRange(to, pos); if (chr.match(/\W/) === null) return false; } return true; } else return false; } function boundariesAround(stream, re) { return (!stream.start || !re.test(stream.string.charAt(stream.start - 1))) && (stream.pos == stream.string.length || !re.test(stream.string.charAt(stream.pos))); } function makeOverlay(query, hasBoundary, style) { return {token: function(stream) { if (stream.match(query) && (!hasBoundary || boundariesAround(stream, hasBoundary))) return style; stream.next(); stream.skipTo(query.charAt(0)) || stream.skipToEnd(); }}; } }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/search/matchesonscrollbar.css ================================================ .CodeMirror-search-match { background: gold; border-top: 1px solid orange; border-bottom: 1px solid orange; -moz-box-sizing: border-box; box-sizing: border-box; opacity: .5; } ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/search/matchesonscrollbar.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("./searchcursor"), require("../scroll/annotatescrollbar")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "./searchcursor", "../scroll/annotatescrollbar"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineExtension("showMatchesOnScrollbar", function(query, caseFold, options) { if (typeof options == "string") options = {className: options}; if (!options) options = {}; return new SearchAnnotation(this, query, caseFold, options); }); function SearchAnnotation(cm, query, caseFold, options) { this.cm = cm; this.options = options; var annotateOptions = {listenForChanges: false}; for (var prop in options) annotateOptions[prop] = options[prop]; if (!annotateOptions.className) annotateOptions.className = "CodeMirror-search-match"; this.annotation = cm.annotateScrollbar(annotateOptions); this.query = query; this.caseFold = caseFold; this.gap = {from: cm.firstLine(), to: cm.lastLine() + 1}; this.matches = []; this.update = null; this.findMatches(); this.annotation.update(this.matches); var self = this; cm.on("change", this.changeHandler = function(_cm, change) { self.onChange(change); }); } var MAX_MATCHES = 1000; SearchAnnotation.prototype.findMatches = function() { if (!this.gap) return; for (var i = 0; i < this.matches.length; i++) { var match = this.matches[i]; if (match.from.line >= this.gap.to) break; if (match.to.line >= this.gap.from) this.matches.splice(i--, 1); } var cursor = this.cm.getSearchCursor(this.query, CodeMirror.Pos(this.gap.from, 0), {caseFold: this.caseFold, multiline: this.options.multiline}); var maxMatches = this.options && this.options.maxMatches || MAX_MATCHES; while (cursor.findNext()) { var match = {from: cursor.from(), to: cursor.to()}; if (match.from.line >= this.gap.to) break; this.matches.splice(i++, 0, match); if (this.matches.length > maxMatches) break; } this.gap = null; }; function offsetLine(line, changeStart, sizeChange) { if (line <= changeStart) return line; return Math.max(changeStart, line + sizeChange); } SearchAnnotation.prototype.onChange = function(change) { var startLine = change.from.line; var endLine = CodeMirror.changeEnd(change).line; var sizeChange = endLine - change.to.line; if (this.gap) { this.gap.from = Math.min(offsetLine(this.gap.from, startLine, sizeChange), change.from.line); this.gap.to = Math.max(offsetLine(this.gap.to, startLine, sizeChange), change.from.line); } else { this.gap = {from: change.from.line, to: endLine + 1}; } if (sizeChange) for (var i = 0; i < this.matches.length; i++) { var match = this.matches[i]; var newFrom = offsetLine(match.from.line, startLine, sizeChange); if (newFrom != match.from.line) match.from = CodeMirror.Pos(newFrom, match.from.ch); var newTo = offsetLine(match.to.line, startLine, sizeChange); if (newTo != match.to.line) match.to = CodeMirror.Pos(newTo, match.to.ch); } clearTimeout(this.update); var self = this; this.update = setTimeout(function() { self.updateAfterChange(); }, 250); }; SearchAnnotation.prototype.updateAfterChange = function() { this.findMatches(); this.annotation.update(this.matches); }; SearchAnnotation.prototype.clear = function() { this.cm.off("change", this.changeHandler); this.annotation.clear(); }; }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/search/search.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // Define search commands. Depends on dialog.js or another // implementation of the openDialog method. // Replace works a little oddly -- it will do the replace on the next // Ctrl-G (or whatever is bound to findNext) press. You prevent a // replace by making sure the match is no longer selected when hitting // Ctrl-G. (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("./searchcursor"), require("../dialog/dialog")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "./searchcursor", "../dialog/dialog"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; function searchOverlay(query, caseInsensitive) { if (typeof query == "string") query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g"); else if (!query.global) query = new RegExp(query.source, query.ignoreCase ? "gi" : "g"); return {token: function(stream) { query.lastIndex = stream.pos; var match = query.exec(stream.string); if (match && match.index == stream.pos) { stream.pos += match[0].length || 1; return "searching"; } else if (match) { stream.pos = match.index; } else { stream.skipToEnd(); } }}; } function SearchState() { this.posFrom = this.posTo = this.lastQuery = this.query = null; this.overlay = null; } function getSearchState(cm) { return cm.state.search || (cm.state.search = new SearchState()); } function queryCaseInsensitive(query) { return typeof query == "string" && query == query.toLowerCase(); } function getSearchCursor(cm, query, pos) { // Heuristic: if the query string is all lowercase, do a case insensitive search. return cm.getSearchCursor(query, pos, {caseFold: queryCaseInsensitive(query), multiline: true}); } function persistentDialog(cm, text, deflt, onEnter, onKeyDown) { cm.openDialog(text, onEnter, { value: deflt, selectValueOnOpen: true, closeOnEnter: false, onClose: function() { clearSearch(cm); }, onKeyDown: onKeyDown }); } function dialog(cm, text, shortText, deflt, f) { if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true}); else f(prompt(shortText, deflt)); } function confirmDialog(cm, text, shortText, fs) { if (cm.openConfirm) cm.openConfirm(text, fs); else if (confirm(shortText)) fs[0](); } function parseString(string) { return string.replace(/\\([nrt\\])/g, function(match, ch) { if (ch == "n") return "\n" if (ch == "r") return "\r" if (ch == "t") return "\t" if (ch == "\\") return "\\" return match }) } function parseQuery(query) { var isRE = query.match(/^\/(.*)\/([a-z]*)$/); if (isRE) { try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); } catch(e) {} // Not a regular expression after all, do a string search } else { query = parseString(query) } if (typeof query == "string" ? query == "" : query.test("")) query = /x^/; return query; } function startSearch(cm, state, query) { state.queryText = query; state.query = parseQuery(query); cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query)); state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query)); cm.addOverlay(state.overlay); if (cm.showMatchesOnScrollbar) { if (state.annotate) { state.annotate.clear(); state.annotate = null; } state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query)); } } function doSearch(cm, rev, persistent, immediate) { var state = getSearchState(cm); if (state.query) return findNext(cm, rev); var q = cm.getSelection() || state.lastQuery; if (q instanceof RegExp && q.source == "x^") q = null if (persistent && cm.openDialog) { var hiding = null var searchNext = function(query, event) { CodeMirror.e_stop(event); if (!query) return; if (query != state.queryText) { startSearch(cm, state, query); state.posFrom = state.posTo = cm.getCursor(); } if (hiding) hiding.style.opacity = 1 findNext(cm, event.shiftKey, function(_, to) { var dialog if (to.line < 3 && document.querySelector && (dialog = cm.display.wrapper.querySelector(".CodeMirror-dialog")) && dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top) (hiding = dialog).style.opacity = .4 }) }; persistentDialog(cm, getQueryDialog(cm), q, searchNext, function(event, query) { var keyName = CodeMirror.keyName(event) var extra = cm.getOption('extraKeys'), cmd = (extra && extra[keyName]) || CodeMirror.keyMap[cm.getOption("keyMap")][keyName] if (cmd == "findNext" || cmd == "findPrev" || cmd == "findPersistentNext" || cmd == "findPersistentPrev") { CodeMirror.e_stop(event); startSearch(cm, getSearchState(cm), query); cm.execCommand(cmd); } else if (cmd == "find" || cmd == "findPersistent") { CodeMirror.e_stop(event); searchNext(query, event); } }); if (immediate && q) { startSearch(cm, state, q); findNext(cm, rev); } } else { dialog(cm, getQueryDialog(cm), "Search for:", q, function(query) { if (query && !state.query) cm.operation(function() { startSearch(cm, state, query); state.posFrom = state.posTo = cm.getCursor(); findNext(cm, rev); }); }); } } function findNext(cm, rev, callback) {cm.operation(function() { var state = getSearchState(cm); var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo); if (!cursor.find(rev)) { cursor = getSearchCursor(cm, state.query, rev ? CodeMirror.Pos(cm.lastLine()) : CodeMirror.Pos(cm.firstLine(), 0)); if (!cursor.find(rev)) return; } cm.setSelection(cursor.from(), cursor.to()); cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20); state.posFrom = cursor.from(); state.posTo = cursor.to(); if (callback) callback(cursor.from(), cursor.to()) });} function clearSearch(cm) {cm.operation(function() { var state = getSearchState(cm); state.lastQuery = state.query; if (!state.query) return; state.query = state.queryText = null; cm.removeOverlay(state.overlay); if (state.annotate) { state.annotate.clear(); state.annotate = null; } });} function getQueryDialog(cm) { return '' + cm.phrase("Search:") + ' ' + cm.phrase("(Use /re/ syntax for regexp search)") + ''; } function getReplaceQueryDialog(cm) { return ' ' + cm.phrase("(Use /re/ syntax for regexp search)") + ''; } function getReplacementQueryDialog(cm) { return '' + cm.phrase("With:") + ' '; } function getDoReplaceConfirm(cm) { return '' + cm.phrase("Replace?") + ' '; } function replaceAll(cm, query, text) { cm.operation(function() { for (var cursor = getSearchCursor(cm, query); cursor.findNext();) { if (typeof query != "string") { var match = cm.getRange(cursor.from(), cursor.to()).match(query); cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];})); } else cursor.replace(text); } }); } function replace(cm, all) { if (cm.getOption("readOnly")) return; var query = cm.getSelection() || getSearchState(cm).lastQuery; var dialogText = '' + (all ? cm.phrase("Replace all:") : cm.phrase("Replace:")) + ''; dialog(cm, dialogText + getReplaceQueryDialog(cm), dialogText, query, function(query) { if (!query) return; query = parseQuery(query); dialog(cm, getReplacementQueryDialog(cm), cm.phrase("Replace with:"), "", function(text) { text = parseString(text) if (all) { replaceAll(cm, query, text) } else { clearSearch(cm); var cursor = getSearchCursor(cm, query, cm.getCursor("from")); var advance = function() { var start = cursor.from(), match; if (!(match = cursor.findNext())) { cursor = getSearchCursor(cm, query); if (!(match = cursor.findNext()) || (start && cursor.from().line == start.line && cursor.from().ch == start.ch)) return; } cm.setSelection(cursor.from(), cursor.to()); cm.scrollIntoView({from: cursor.from(), to: cursor.to()}); confirmDialog(cm, getDoReplaceConfirm(cm), cm.phrase("Replace?"), [function() {doReplace(match);}, advance, function() {replaceAll(cm, query, text)}]); }; var doReplace = function(match) { cursor.replace(typeof query == "string" ? text : text.replace(/\$(\d)/g, function(_, i) {return match[i];})); advance(); }; advance(); } }); }); } CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);}; CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);}; CodeMirror.commands.findPersistentNext = function(cm) {doSearch(cm, false, true, true);}; CodeMirror.commands.findPersistentPrev = function(cm) {doSearch(cm, true, true, true);}; CodeMirror.commands.findNext = doSearch; CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);}; CodeMirror.commands.clearSearch = clearSearch; CodeMirror.commands.replace = replace; CodeMirror.commands.replaceAll = function(cm) {replace(cm, true);}; }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/search/searchcursor.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")) else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod) else // Plain browser env mod(CodeMirror) })(function(CodeMirror) { "use strict" var Pos = CodeMirror.Pos function regexpFlags(regexp) { var flags = regexp.flags return flags != null ? flags : (regexp.ignoreCase ? "i" : "") + (regexp.global ? "g" : "") + (regexp.multiline ? "m" : "") } function ensureFlags(regexp, flags) { var current = regexpFlags(regexp), target = current for (var i = 0; i < flags.length; i++) if (target.indexOf(flags.charAt(i)) == -1) target += flags.charAt(i) return current == target ? regexp : new RegExp(regexp.source, target) } function maybeMultiline(regexp) { return /\\s|\\n|\n|\\W|\\D|\[\^/.test(regexp.source) } function searchRegexpForward(doc, regexp, start) { regexp = ensureFlags(regexp, "g") for (var line = start.line, ch = start.ch, last = doc.lastLine(); line <= last; line++, ch = 0) { regexp.lastIndex = ch var string = doc.getLine(line), match = regexp.exec(string) if (match) return {from: Pos(line, match.index), to: Pos(line, match.index + match[0].length), match: match} } } function searchRegexpForwardMultiline(doc, regexp, start) { if (!maybeMultiline(regexp)) return searchRegexpForward(doc, regexp, start) regexp = ensureFlags(regexp, "gm") var string, chunk = 1 for (var line = start.line, last = doc.lastLine(); line <= last;) { // This grows the search buffer in exponentially-sized chunks // between matches, so that nearby matches are fast and don't // require concatenating the whole document (in case we're // searching for something that has tons of matches), but at the // same time, the amount of retries is limited. for (var i = 0; i < chunk; i++) { if (line > last) break var curLine = doc.getLine(line++) string = string == null ? curLine : string + "\n" + curLine } chunk = chunk * 2 regexp.lastIndex = start.ch var match = regexp.exec(string) if (match) { var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n") var startLine = start.line + before.length - 1, startCh = before[before.length - 1].length return {from: Pos(startLine, startCh), to: Pos(startLine + inside.length - 1, inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length), match: match} } } } function lastMatchIn(string, regexp, endMargin) { var match, from = 0 while (from <= string.length) { regexp.lastIndex = from var newMatch = regexp.exec(string) if (!newMatch) break var end = newMatch.index + newMatch[0].length if (end > string.length - endMargin) break if (!match || end > match.index + match[0].length) match = newMatch from = newMatch.index + 1 } return match } function searchRegexpBackward(doc, regexp, start) { regexp = ensureFlags(regexp, "g") for (var line = start.line, ch = start.ch, first = doc.firstLine(); line >= first; line--, ch = -1) { var string = doc.getLine(line) var match = lastMatchIn(string, regexp, ch < 0 ? 0 : string.length - ch) if (match) return {from: Pos(line, match.index), to: Pos(line, match.index + match[0].length), match: match} } } function searchRegexpBackwardMultiline(doc, regexp, start) { if (!maybeMultiline(regexp)) return searchRegexpBackward(doc, regexp, start) regexp = ensureFlags(regexp, "gm") var string, chunkSize = 1, endMargin = doc.getLine(start.line).length - start.ch for (var line = start.line, first = doc.firstLine(); line >= first;) { for (var i = 0; i < chunkSize && line >= first; i++) { var curLine = doc.getLine(line--) string = string == null ? curLine : curLine + "\n" + string } chunkSize *= 2 var match = lastMatchIn(string, regexp, endMargin) if (match) { var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n") var startLine = line + before.length, startCh = before[before.length - 1].length return {from: Pos(startLine, startCh), to: Pos(startLine + inside.length - 1, inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length), match: match} } } } var doFold, noFold if (String.prototype.normalize) { doFold = function(str) { return str.normalize("NFD").toLowerCase() } noFold = function(str) { return str.normalize("NFD") } } else { doFold = function(str) { return str.toLowerCase() } noFold = function(str) { return str } } // Maps a position in a case-folded line back to a position in the original line // (compensating for codepoints increasing in number during folding) function adjustPos(orig, folded, pos, foldFunc) { if (orig.length == folded.length) return pos for (var min = 0, max = pos + Math.max(0, orig.length - folded.length);;) { if (min == max) return min var mid = (min + max) >> 1 var len = foldFunc(orig.slice(0, mid)).length if (len == pos) return mid else if (len > pos) max = mid else min = mid + 1 } } function searchStringForward(doc, query, start, caseFold) { // Empty string would match anything and never progress, so we // define it to match nothing instead. if (!query.length) return null var fold = caseFold ? doFold : noFold var lines = fold(query).split(/\r|\n\r?/) search: for (var line = start.line, ch = start.ch, last = doc.lastLine() + 1 - lines.length; line <= last; line++, ch = 0) { var orig = doc.getLine(line).slice(ch), string = fold(orig) if (lines.length == 1) { var found = string.indexOf(lines[0]) if (found == -1) continue search var start = adjustPos(orig, string, found, fold) + ch return {from: Pos(line, adjustPos(orig, string, found, fold) + ch), to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold) + ch)} } else { var cutFrom = string.length - lines[0].length if (string.slice(cutFrom) != lines[0]) continue search for (var i = 1; i < lines.length - 1; i++) if (fold(doc.getLine(line + i)) != lines[i]) continue search var end = doc.getLine(line + lines.length - 1), endString = fold(end), lastLine = lines[lines.length - 1] if (endString.slice(0, lastLine.length) != lastLine) continue search return {from: Pos(line, adjustPos(orig, string, cutFrom, fold) + ch), to: Pos(line + lines.length - 1, adjustPos(end, endString, lastLine.length, fold))} } } } function searchStringBackward(doc, query, start, caseFold) { if (!query.length) return null var fold = caseFold ? doFold : noFold var lines = fold(query).split(/\r|\n\r?/) search: for (var line = start.line, ch = start.ch, first = doc.firstLine() - 1 + lines.length; line >= first; line--, ch = -1) { var orig = doc.getLine(line) if (ch > -1) orig = orig.slice(0, ch) var string = fold(orig) if (lines.length == 1) { var found = string.lastIndexOf(lines[0]) if (found == -1) continue search return {from: Pos(line, adjustPos(orig, string, found, fold)), to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold))} } else { var lastLine = lines[lines.length - 1] if (string.slice(0, lastLine.length) != lastLine) continue search for (var i = 1, start = line - lines.length + 1; i < lines.length - 1; i++) if (fold(doc.getLine(start + i)) != lines[i]) continue search var top = doc.getLine(line + 1 - lines.length), topString = fold(top) if (topString.slice(topString.length - lines[0].length) != lines[0]) continue search return {from: Pos(line + 1 - lines.length, adjustPos(top, topString, top.length - lines[0].length, fold)), to: Pos(line, adjustPos(orig, string, lastLine.length, fold))} } } } function SearchCursor(doc, query, pos, options) { this.atOccurrence = false this.doc = doc pos = pos ? doc.clipPos(pos) : Pos(0, 0) this.pos = {from: pos, to: pos} var caseFold if (typeof options == "object") { caseFold = options.caseFold } else { // Backwards compat for when caseFold was the 4th argument caseFold = options options = null } if (typeof query == "string") { if (caseFold == null) caseFold = false this.matches = function(reverse, pos) { return (reverse ? searchStringBackward : searchStringForward)(doc, query, pos, caseFold) } } else { query = ensureFlags(query, "gm") if (!options || options.multiline !== false) this.matches = function(reverse, pos) { return (reverse ? searchRegexpBackwardMultiline : searchRegexpForwardMultiline)(doc, query, pos) } else this.matches = function(reverse, pos) { return (reverse ? searchRegexpBackward : searchRegexpForward)(doc, query, pos) } } } SearchCursor.prototype = { findNext: function() {return this.find(false)}, findPrevious: function() {return this.find(true)}, find: function(reverse) { var result = this.matches(reverse, this.doc.clipPos(reverse ? this.pos.from : this.pos.to)) // Implements weird auto-growing behavior on null-matches for // backwards-compatibility with the vim code (unfortunately) while (result && CodeMirror.cmpPos(result.from, result.to) == 0) { if (reverse) { if (result.from.ch) result.from = Pos(result.from.line, result.from.ch - 1) else if (result.from.line == this.doc.firstLine()) result = null else result = this.matches(reverse, this.doc.clipPos(Pos(result.from.line - 1))) } else { if (result.to.ch < this.doc.getLine(result.to.line).length) result.to = Pos(result.to.line, result.to.ch + 1) else if (result.to.line == this.doc.lastLine()) result = null else result = this.matches(reverse, Pos(result.to.line + 1, 0)) } } if (result) { this.pos = result this.atOccurrence = true return this.pos.match || true } else { var end = Pos(reverse ? this.doc.firstLine() : this.doc.lastLine() + 1, 0) this.pos = {from: end, to: end} return this.atOccurrence = false } }, from: function() {if (this.atOccurrence) return this.pos.from}, to: function() {if (this.atOccurrence) return this.pos.to}, replace: function(newText, origin) { if (!this.atOccurrence) return var lines = CodeMirror.splitLines(newText) this.doc.replaceRange(lines, this.pos.from, this.pos.to, origin) this.pos.to = Pos(this.pos.from.line + lines.length - 1, lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0)) } } CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) { return new SearchCursor(this.doc, query, pos, caseFold) }) CodeMirror.defineDocExtension("getSearchCursor", function(query, pos, caseFold) { return new SearchCursor(this, query, pos, caseFold) }) CodeMirror.defineExtension("selectMatches", function(query, caseFold) { var ranges = [] var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold) while (cur.findNext()) { if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break ranges.push({anchor: cur.from(), head: cur.to()}) } if (ranges.length) this.setSelections(ranges, 0) }) }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/selection/active-line.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var WRAP_CLASS = "CodeMirror-activeline"; var BACK_CLASS = "CodeMirror-activeline-background"; var GUTT_CLASS = "CodeMirror-activeline-gutter"; CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) { var prev = old == CodeMirror.Init ? false : old; if (val == prev) return if (prev) { cm.off("beforeSelectionChange", selectionChange); clearActiveLines(cm); delete cm.state.activeLines; } if (val) { cm.state.activeLines = []; updateActiveLines(cm, cm.listSelections()); cm.on("beforeSelectionChange", selectionChange); } }); function clearActiveLines(cm) { for (var i = 0; i < cm.state.activeLines.length; i++) { cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS); cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS); cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS); } } function sameArray(a, b) { if (a.length != b.length) return false; for (var i = 0; i < a.length; i++) if (a[i] != b[i]) return false; return true; } function updateActiveLines(cm, ranges) { var active = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; var option = cm.getOption("styleActiveLine"); if (typeof option == "object" && option.nonEmpty ? range.anchor.line != range.head.line : !range.empty()) continue var line = cm.getLineHandleVisualStart(range.head.line); if (active[active.length - 1] != line) active.push(line); } if (sameArray(cm.state.activeLines, active)) return; cm.operation(function() { clearActiveLines(cm); for (var i = 0; i < active.length; i++) { cm.addLineClass(active[i], "wrap", WRAP_CLASS); cm.addLineClass(active[i], "background", BACK_CLASS); cm.addLineClass(active[i], "gutter", GUTT_CLASS); } cm.state.activeLines = active; }); } function selectionChange(cm, sel) { updateActiveLines(cm, sel.ranges); } }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/selection/mark-selection.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // Because sometimes you need to mark the selected *text*. // // Adds an option 'styleSelectedText' which, when enabled, gives // selected text the CSS class given as option value, or // "CodeMirror-selectedtext" when the value is not a string. (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) { var prev = old && old != CodeMirror.Init; if (val && !prev) { cm.state.markedSelection = []; cm.state.markedSelectionStyle = typeof val == "string" ? val : "CodeMirror-selectedtext"; reset(cm); cm.on("cursorActivity", onCursorActivity); cm.on("change", onChange); } else if (!val && prev) { cm.off("cursorActivity", onCursorActivity); cm.off("change", onChange); clear(cm); cm.state.markedSelection = cm.state.markedSelectionStyle = null; } }); function onCursorActivity(cm) { if (cm.state.markedSelection) cm.operation(function() { update(cm); }); } function onChange(cm) { if (cm.state.markedSelection && cm.state.markedSelection.length) cm.operation(function() { clear(cm); }); } var CHUNK_SIZE = 8; var Pos = CodeMirror.Pos; var cmp = CodeMirror.cmpPos; function coverRange(cm, from, to, addAt) { if (cmp(from, to) == 0) return; var array = cm.state.markedSelection; var cls = cm.state.markedSelectionStyle; for (var line = from.line;;) { var start = line == from.line ? from : Pos(line, 0); var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line; var end = atEnd ? to : Pos(endLine, 0); var mark = cm.markText(start, end, {className: cls}); if (addAt == null) array.push(mark); else array.splice(addAt++, 0, mark); if (atEnd) break; line = endLine; } } function clear(cm) { var array = cm.state.markedSelection; for (var i = 0; i < array.length; ++i) array[i].clear(); array.length = 0; } function reset(cm) { clear(cm); var ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) coverRange(cm, ranges[i].from(), ranges[i].to()); } function update(cm) { if (!cm.somethingSelected()) return clear(cm); if (cm.listSelections().length > 1) return reset(cm); var from = cm.getCursor("start"), to = cm.getCursor("end"); var array = cm.state.markedSelection; if (!array.length) return coverRange(cm, from, to); var coverStart = array[0].find(), coverEnd = array[array.length - 1].find(); if (!coverStart || !coverEnd || to.line - from.line <= CHUNK_SIZE || cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0) return reset(cm); while (cmp(from, coverStart.from) > 0) { array.shift().clear(); coverStart = array[0].find(); } if (cmp(from, coverStart.from) < 0) { if (coverStart.to.line - from.line < CHUNK_SIZE) { array.shift().clear(); coverRange(cm, from, coverStart.to, 0); } else { coverRange(cm, from, coverStart.from, 0); } } while (cmp(to, coverEnd.to) < 0) { array.pop().clear(); coverEnd = array[array.length - 1].find(); } if (cmp(to, coverEnd.to) > 0) { if (to.line - coverEnd.from.line < CHUNK_SIZE) { array.pop().clear(); coverRange(cm, coverEnd.from, to); } else { coverRange(cm, coverEnd.to, to); } } } }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/selection/selection-pointer.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineOption("selectionPointer", false, function(cm, val) { var data = cm.state.selectionPointer; if (data) { CodeMirror.off(cm.getWrapperElement(), "mousemove", data.mousemove); CodeMirror.off(cm.getWrapperElement(), "mouseout", data.mouseout); CodeMirror.off(window, "scroll", data.windowScroll); cm.off("cursorActivity", reset); cm.off("scroll", reset); cm.state.selectionPointer = null; cm.display.lineDiv.style.cursor = ""; } if (val) { data = cm.state.selectionPointer = { value: typeof val == "string" ? val : "default", mousemove: function(event) { mousemove(cm, event); }, mouseout: function(event) { mouseout(cm, event); }, windowScroll: function() { reset(cm); }, rects: null, mouseX: null, mouseY: null, willUpdate: false }; CodeMirror.on(cm.getWrapperElement(), "mousemove", data.mousemove); CodeMirror.on(cm.getWrapperElement(), "mouseout", data.mouseout); CodeMirror.on(window, "scroll", data.windowScroll); cm.on("cursorActivity", reset); cm.on("scroll", reset); } }); function mousemove(cm, event) { var data = cm.state.selectionPointer; if (event.buttons == null ? event.which : event.buttons) { data.mouseX = data.mouseY = null; } else { data.mouseX = event.clientX; data.mouseY = event.clientY; } scheduleUpdate(cm); } function mouseout(cm, event) { if (!cm.getWrapperElement().contains(event.relatedTarget)) { var data = cm.state.selectionPointer; data.mouseX = data.mouseY = null; scheduleUpdate(cm); } } function reset(cm) { cm.state.selectionPointer.rects = null; scheduleUpdate(cm); } function scheduleUpdate(cm) { if (!cm.state.selectionPointer.willUpdate) { cm.state.selectionPointer.willUpdate = true; setTimeout(function() { update(cm); cm.state.selectionPointer.willUpdate = false; }, 50); } } function update(cm) { var data = cm.state.selectionPointer; if (!data) return; if (data.rects == null && data.mouseX != null) { data.rects = []; if (cm.somethingSelected()) { for (var sel = cm.display.selectionDiv.firstChild; sel; sel = sel.nextSibling) data.rects.push(sel.getBoundingClientRect()); } } var inside = false; if (data.mouseX != null) for (var i = 0; i < data.rects.length; i++) { var rect = data.rects[i]; if (rect.left <= data.mouseX && rect.right >= data.mouseX && rect.top <= data.mouseY && rect.bottom >= data.mouseY) inside = true; } var cursor = inside ? data.value : ""; if (cm.display.lineDiv.style.cursor != cursor) cm.display.lineDiv.style.cursor = cursor; } }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/simple.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineSimpleMode = function(name, states) { CodeMirror.defineMode(name, function(config) { return CodeMirror.simpleMode(config, states); }); }; CodeMirror.simpleMode = function(config, states) { ensureState(states, "start"); var states_ = {}, meta = states.meta || {}, hasIndentation = false; for (var state in states) if (state != meta && states.hasOwnProperty(state)) { var list = states_[state] = [], orig = states[state]; for (var i = 0; i < orig.length; i++) { var data = orig[i]; list.push(new Rule(data, states)); if (data.indent || data.dedent) hasIndentation = true; } } var mode = { startState: function() { return {state: "start", pending: null, local: null, localState: null, indent: hasIndentation ? [] : null}; }, copyState: function(state) { var s = {state: state.state, pending: state.pending, local: state.local, localState: null, indent: state.indent && state.indent.slice(0)}; if (state.localState) s.localState = CodeMirror.copyState(state.local.mode, state.localState); if (state.stack) s.stack = state.stack.slice(0); for (var pers = state.persistentStates; pers; pers = pers.next) s.persistentStates = {mode: pers.mode, spec: pers.spec, state: pers.state == state.localState ? s.localState : CodeMirror.copyState(pers.mode, pers.state), next: s.persistentStates}; return s; }, token: tokenFunction(states_, config), innerMode: function(state) { return state.local && {mode: state.local.mode, state: state.localState}; }, indent: indentFunction(states_, meta) }; if (meta) for (var prop in meta) if (meta.hasOwnProperty(prop)) mode[prop] = meta[prop]; return mode; }; function ensureState(states, name) { if (!states.hasOwnProperty(name)) throw new Error("Undefined state " + name + " in simple mode"); } function toRegex(val, caret) { if (!val) return /(?:)/; var flags = ""; if (val instanceof RegExp) { if (val.ignoreCase) flags = "i"; val = val.source; } else { val = String(val); } return new RegExp((caret === false ? "" : "^") + "(?:" + val + ")", flags); } function asToken(val) { if (!val) return null; if (val.apply) return val if (typeof val == "string") return val.replace(/\./g, " "); var result = []; for (var i = 0; i < val.length; i++) result.push(val[i] && val[i].replace(/\./g, " ")); return result; } function Rule(data, states) { if (data.next || data.push) ensureState(states, data.next || data.push); this.regex = toRegex(data.regex); this.token = asToken(data.token); this.data = data; } function tokenFunction(states, config) { return function(stream, state) { if (state.pending) { var pend = state.pending.shift(); if (state.pending.length == 0) state.pending = null; stream.pos += pend.text.length; return pend.token; } if (state.local) { if (state.local.end && stream.match(state.local.end)) { var tok = state.local.endToken || null; state.local = state.localState = null; return tok; } else { var tok = state.local.mode.token(stream, state.localState), m; if (state.local.endScan && (m = state.local.endScan.exec(stream.current()))) stream.pos = stream.start + m.index; return tok; } } var curState = states[state.state]; for (var i = 0; i < curState.length; i++) { var rule = curState[i]; var matches = (!rule.data.sol || stream.sol()) && stream.match(rule.regex); if (matches) { if (rule.data.next) { state.state = rule.data.next; } else if (rule.data.push) { (state.stack || (state.stack = [])).push(state.state); state.state = rule.data.push; } else if (rule.data.pop && state.stack && state.stack.length) { state.state = state.stack.pop(); } if (rule.data.mode) enterLocalMode(config, state, rule.data.mode, rule.token); if (rule.data.indent) state.indent.push(stream.indentation() + config.indentUnit); if (rule.data.dedent) state.indent.pop(); var token = rule.token if (token && token.apply) token = token(matches) if (matches.length > 2 && rule.token && typeof rule.token != "string") { state.pending = []; for (var j = 2; j < matches.length; j++) if (matches[j]) state.pending.push({text: matches[j], token: rule.token[j - 1]}); stream.backUp(matches[0].length - (matches[1] ? matches[1].length : 0)); return token[0]; } else if (token && token.join) { return token[0]; } else { return token; } } } stream.next(); return null; }; } function cmp(a, b) { if (a === b) return true; if (!a || typeof a != "object" || !b || typeof b != "object") return false; var props = 0; for (var prop in a) if (a.hasOwnProperty(prop)) { if (!b.hasOwnProperty(prop) || !cmp(a[prop], b[prop])) return false; props++; } for (var prop in b) if (b.hasOwnProperty(prop)) props--; return props == 0; } function enterLocalMode(config, state, spec, token) { var pers; if (spec.persistent) for (var p = state.persistentStates; p && !pers; p = p.next) if (spec.spec ? cmp(spec.spec, p.spec) : spec.mode == p.mode) pers = p; var mode = pers ? pers.mode : spec.mode || CodeMirror.getMode(config, spec.spec); var lState = pers ? pers.state : CodeMirror.startState(mode); if (spec.persistent && !pers) state.persistentStates = {mode: mode, spec: spec.spec, state: lState, next: state.persistentStates}; state.localState = lState; state.local = {mode: mode, end: spec.end && toRegex(spec.end), endScan: spec.end && spec.forceEnd !== false && toRegex(spec.end, false), endToken: token && token.join ? token[token.length - 1] : token}; } function indexOf(val, arr) { for (var i = 0; i < arr.length; i++) if (arr[i] === val) return true; } function indentFunction(states, meta) { return function(state, textAfter, line) { if (state.local && state.local.mode.indent) return state.local.mode.indent(state.localState, textAfter, line); if (state.indent == null || state.local || meta.dontIndentStates && indexOf(state.state, meta.dontIndentStates) > -1) return CodeMirror.Pass; var pos = state.indent.length - 1, rules = states[state.state]; scan: for (;;) { for (var i = 0; i < rules.length; i++) { var rule = rules[i]; if (rule.data.dedent && rule.data.dedentIfLineStart !== false) { var m = rule.regex.exec(textAfter); if (m && m[0]) { pos--; if (rule.next || rule.push) rules = states[rule.next || rule.push]; textAfter = textAfter.slice(m[0].length); continue scan; } } } break; } return pos < 0 ? 0 : state.indent[pos]; }; } }); ================================================ FILE: plugins/UiFileManager/media/codemirror/extension/sublime.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // A rough approximation of Sublime Text's keybindings // Depends on addon/search/searchcursor.js and optionally addon/dialog/dialogs.js (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../lib/codemirror"), require("../addon/search/searchcursor"), require("../addon/edit/matchbrackets")); else if (typeof define == "function" && define.amd) // AMD define(["../lib/codemirror", "../addon/search/searchcursor", "../addon/edit/matchbrackets"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var cmds = CodeMirror.commands; var Pos = CodeMirror.Pos; // This is not exactly Sublime's algorithm. I couldn't make heads or tails of that. function findPosSubword(doc, start, dir) { if (dir < 0 && start.ch == 0) return doc.clipPos(Pos(start.line - 1)); var line = doc.getLine(start.line); if (dir > 0 && start.ch >= line.length) return doc.clipPos(Pos(start.line + 1, 0)); var state = "start", type, startPos = start.ch; for (var pos = startPos, e = dir < 0 ? 0 : line.length, i = 0; pos != e; pos += dir, i++) { var next = line.charAt(dir < 0 ? pos - 1 : pos); var cat = next != "_" && CodeMirror.isWordChar(next) ? "w" : "o"; if (cat == "w" && next.toUpperCase() == next) cat = "W"; if (state == "start") { if (cat != "o") { state = "in"; type = cat; } else startPos = pos + dir } else if (state == "in") { if (type != cat) { if (type == "w" && cat == "W" && dir < 0) pos--; if (type == "W" && cat == "w" && dir > 0) { // From uppercase to lowercase if (pos == startPos + 1) { type = "w"; continue; } else pos--; } break; } } } return Pos(start.line, pos); } function moveSubword(cm, dir) { cm.extendSelectionsBy(function(range) { if (cm.display.shift || cm.doc.extend || range.empty()) return findPosSubword(cm.doc, range.head, dir); else return dir < 0 ? range.from() : range.to(); }); } cmds.goSubwordLeft = function(cm) { moveSubword(cm, -1); }; cmds.goSubwordRight = function(cm) { moveSubword(cm, 1); }; cmds.scrollLineUp = function(cm) { var info = cm.getScrollInfo(); if (!cm.somethingSelected()) { var visibleBottomLine = cm.lineAtHeight(info.top + info.clientHeight, "local"); if (cm.getCursor().line >= visibleBottomLine) cm.execCommand("goLineUp"); } cm.scrollTo(null, info.top - cm.defaultTextHeight()); }; cmds.scrollLineDown = function(cm) { var info = cm.getScrollInfo(); if (!cm.somethingSelected()) { var visibleTopLine = cm.lineAtHeight(info.top, "local")+1; if (cm.getCursor().line <= visibleTopLine) cm.execCommand("goLineDown"); } cm.scrollTo(null, info.top + cm.defaultTextHeight()); }; cmds.splitSelectionByLine = function(cm) { var ranges = cm.listSelections(), lineRanges = []; for (var i = 0; i < ranges.length; i++) { var from = ranges[i].from(), to = ranges[i].to(); for (var line = from.line; line <= to.line; ++line) if (!(to.line > from.line && line == to.line && to.ch == 0)) lineRanges.push({anchor: line == from.line ? from : Pos(line, 0), head: line == to.line ? to : Pos(line)}); } cm.setSelections(lineRanges, 0); }; cmds.singleSelectionTop = function(cm) { var range = cm.listSelections()[0]; cm.setSelection(range.anchor, range.head, {scroll: false}); }; cmds.selectLine = function(cm) { var ranges = cm.listSelections(), extended = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; extended.push({anchor: Pos(range.from().line, 0), head: Pos(range.to().line + 1, 0)}); } cm.setSelections(extended); }; function insertLine(cm, above) { if (cm.isReadOnly()) return CodeMirror.Pass cm.operation(function() { var len = cm.listSelections().length, newSelection = [], last = -1; for (var i = 0; i < len; i++) { var head = cm.listSelections()[i].head; if (head.line <= last) continue; var at = Pos(head.line + (above ? 0 : 1), 0); cm.replaceRange("\n", at, null, "+insertLine"); cm.indentLine(at.line, null, true); newSelection.push({head: at, anchor: at}); last = head.line + 1; } cm.setSelections(newSelection); }); cm.execCommand("indentAuto"); } cmds.insertLineAfter = function(cm) { return insertLine(cm, false); }; cmds.insertLineBefore = function(cm) { return insertLine(cm, true); }; function wordAt(cm, pos) { var start = pos.ch, end = start, line = cm.getLine(pos.line); while (start && CodeMirror.isWordChar(line.charAt(start - 1))) --start; while (end < line.length && CodeMirror.isWordChar(line.charAt(end))) ++end; return {from: Pos(pos.line, start), to: Pos(pos.line, end), word: line.slice(start, end)}; } cmds.selectNextOccurrence = function(cm) { var from = cm.getCursor("from"), to = cm.getCursor("to"); var fullWord = cm.state.sublimeFindFullWord == cm.doc.sel; if (CodeMirror.cmpPos(from, to) == 0) { var word = wordAt(cm, from); if (!word.word) return; cm.setSelection(word.from, word.to); fullWord = true; } else { var text = cm.getRange(from, to); var query = fullWord ? new RegExp("\\b" + text + "\\b") : text; var cur = cm.getSearchCursor(query, to); var found = cur.findNext(); if (!found) { cur = cm.getSearchCursor(query, Pos(cm.firstLine(), 0)); found = cur.findNext(); } if (!found || isSelectedRange(cm.listSelections(), cur.from(), cur.to())) return cm.addSelection(cur.from(), cur.to()); } if (fullWord) cm.state.sublimeFindFullWord = cm.doc.sel; }; cmds.skipAndSelectNextOccurrence = function(cm) { var prevAnchor = cm.getCursor("anchor"), prevHead = cm.getCursor("head"); cmds.selectNextOccurrence(cm); if (CodeMirror.cmpPos(prevAnchor, prevHead) != 0) { cm.doc.setSelections(cm.doc.listSelections() .filter(function (sel) { return sel.anchor != prevAnchor || sel.head != prevHead; })); } } function addCursorToSelection(cm, dir) { var ranges = cm.listSelections(), newRanges = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; var newAnchor = cm.findPosV( range.anchor, dir, "line", range.anchor.goalColumn); var newHead = cm.findPosV( range.head, dir, "line", range.head.goalColumn); newAnchor.goalColumn = range.anchor.goalColumn != null ? range.anchor.goalColumn : cm.cursorCoords(range.anchor, "div").left; newHead.goalColumn = range.head.goalColumn != null ? range.head.goalColumn : cm.cursorCoords(range.head, "div").left; var newRange = {anchor: newAnchor, head: newHead}; newRanges.push(range); newRanges.push(newRange); } cm.setSelections(newRanges); } cmds.addCursorToPrevLine = function(cm) { addCursorToSelection(cm, -1); }; cmds.addCursorToNextLine = function(cm) { addCursorToSelection(cm, 1); }; function isSelectedRange(ranges, from, to) { for (var i = 0; i < ranges.length; i++) if (CodeMirror.cmpPos(ranges[i].from(), from) == 0 && CodeMirror.cmpPos(ranges[i].to(), to) == 0) return true return false } var mirror = "(){}[]"; function selectBetweenBrackets(cm) { var ranges = cm.listSelections(), newRanges = [] for (var i = 0; i < ranges.length; i++) { var range = ranges[i], pos = range.head, opening = cm.scanForBracket(pos, -1); if (!opening) return false; for (;;) { var closing = cm.scanForBracket(pos, 1); if (!closing) return false; if (closing.ch == mirror.charAt(mirror.indexOf(opening.ch) + 1)) { var startPos = Pos(opening.pos.line, opening.pos.ch + 1); if (CodeMirror.cmpPos(startPos, range.from()) == 0 && CodeMirror.cmpPos(closing.pos, range.to()) == 0) { opening = cm.scanForBracket(opening.pos, -1); if (!opening) return false; } else { newRanges.push({anchor: startPos, head: closing.pos}); break; } } pos = Pos(closing.pos.line, closing.pos.ch + 1); } } cm.setSelections(newRanges); return true; } cmds.selectScope = function(cm) { selectBetweenBrackets(cm) || cm.execCommand("selectAll"); }; cmds.selectBetweenBrackets = function(cm) { if (!selectBetweenBrackets(cm)) return CodeMirror.Pass; }; function puncType(type) { return !type ? null : /\bpunctuation\b/.test(type) ? type : undefined } cmds.goToBracket = function(cm) { cm.extendSelectionsBy(function(range) { var next = cm.scanForBracket(range.head, 1, puncType(cm.getTokenTypeAt(range.head))); if (next && CodeMirror.cmpPos(next.pos, range.head) != 0) return next.pos; var prev = cm.scanForBracket(range.head, -1, puncType(cm.getTokenTypeAt(Pos(range.head.line, range.head.ch + 1)))); return prev && Pos(prev.pos.line, prev.pos.ch + 1) || range.head; }); }; cmds.swapLineUp = function(cm) { if (cm.isReadOnly()) return CodeMirror.Pass var ranges = cm.listSelections(), linesToMove = [], at = cm.firstLine() - 1, newSels = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i], from = range.from().line - 1, to = range.to().line; newSels.push({anchor: Pos(range.anchor.line - 1, range.anchor.ch), head: Pos(range.head.line - 1, range.head.ch)}); if (range.to().ch == 0 && !range.empty()) --to; if (from > at) linesToMove.push(from, to); else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to; at = to; } cm.operation(function() { for (var i = 0; i < linesToMove.length; i += 2) { var from = linesToMove[i], to = linesToMove[i + 1]; var line = cm.getLine(from); cm.replaceRange("", Pos(from, 0), Pos(from + 1, 0), "+swapLine"); if (to > cm.lastLine()) cm.replaceRange("\n" + line, Pos(cm.lastLine()), null, "+swapLine"); else cm.replaceRange(line + "\n", Pos(to, 0), null, "+swapLine"); } cm.setSelections(newSels); cm.scrollIntoView(); }); }; cmds.swapLineDown = function(cm) { if (cm.isReadOnly()) return CodeMirror.Pass var ranges = cm.listSelections(), linesToMove = [], at = cm.lastLine() + 1; for (var i = ranges.length - 1; i >= 0; i--) { var range = ranges[i], from = range.to().line + 1, to = range.from().line; if (range.to().ch == 0 && !range.empty()) from--; if (from < at) linesToMove.push(from, to); else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to; at = to; } cm.operation(function() { for (var i = linesToMove.length - 2; i >= 0; i -= 2) { var from = linesToMove[i], to = linesToMove[i + 1]; var line = cm.getLine(from); if (from == cm.lastLine()) cm.replaceRange("", Pos(from - 1), Pos(from), "+swapLine"); else cm.replaceRange("", Pos(from, 0), Pos(from + 1, 0), "+swapLine"); cm.replaceRange(line + "\n", Pos(to, 0), null, "+swapLine"); } cm.scrollIntoView(); }); }; cmds.toggleCommentIndented = function(cm) { cm.toggleComment({ indent: true }); } cmds.joinLines = function(cm) { var ranges = cm.listSelections(), joined = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i], from = range.from(); var start = from.line, end = range.to().line; while (i < ranges.length - 1 && ranges[i + 1].from().line == end) end = ranges[++i].to().line; joined.push({start: start, end: end, anchor: !range.empty() && from}); } cm.operation(function() { var offset = 0, ranges = []; for (var i = 0; i < joined.length; i++) { var obj = joined[i]; var anchor = obj.anchor && Pos(obj.anchor.line - offset, obj.anchor.ch), head; for (var line = obj.start; line <= obj.end; line++) { var actual = line - offset; if (line == obj.end) head = Pos(actual, cm.getLine(actual).length + 1); if (actual < cm.lastLine()) { cm.replaceRange(" ", Pos(actual), Pos(actual + 1, /^\s*/.exec(cm.getLine(actual + 1))[0].length)); ++offset; } } ranges.push({anchor: anchor || head, head: head}); } cm.setSelections(ranges, 0); }); }; cmds.duplicateLine = function(cm) { cm.operation(function() { var rangeCount = cm.listSelections().length; for (var i = 0; i < rangeCount; i++) { var range = cm.listSelections()[i]; if (range.empty()) cm.replaceRange(cm.getLine(range.head.line) + "\n", Pos(range.head.line, 0)); else cm.replaceRange(cm.getRange(range.from(), range.to()), range.from()); } cm.scrollIntoView(); }); }; function sortLines(cm, caseSensitive) { if (cm.isReadOnly()) return CodeMirror.Pass var ranges = cm.listSelections(), toSort = [], selected; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; if (range.empty()) continue; var from = range.from().line, to = range.to().line; while (i < ranges.length - 1 && ranges[i + 1].from().line == to) to = ranges[++i].to().line; if (!ranges[i].to().ch) to--; toSort.push(from, to); } if (toSort.length) selected = true; else toSort.push(cm.firstLine(), cm.lastLine()); cm.operation(function() { var ranges = []; for (var i = 0; i < toSort.length; i += 2) { var from = toSort[i], to = toSort[i + 1]; var start = Pos(from, 0), end = Pos(to); var lines = cm.getRange(start, end, false); if (caseSensitive) lines.sort(); else lines.sort(function(a, b) { var au = a.toUpperCase(), bu = b.toUpperCase(); if (au != bu) { a = au; b = bu; } return a < b ? -1 : a == b ? 0 : 1; }); cm.replaceRange(lines, start, end); if (selected) ranges.push({anchor: start, head: Pos(to + 1, 0)}); } if (selected) cm.setSelections(ranges, 0); }); } cmds.sortLines = function(cm) { sortLines(cm, true); }; cmds.sortLinesInsensitive = function(cm) { sortLines(cm, false); }; cmds.nextBookmark = function(cm) { var marks = cm.state.sublimeBookmarks; if (marks) while (marks.length) { var current = marks.shift(); var found = current.find(); if (found) { marks.push(current); return cm.setSelection(found.from, found.to); } } }; cmds.prevBookmark = function(cm) { var marks = cm.state.sublimeBookmarks; if (marks) while (marks.length) { marks.unshift(marks.pop()); var found = marks[marks.length - 1].find(); if (!found) marks.pop(); else return cm.setSelection(found.from, found.to); } }; cmds.toggleBookmark = function(cm) { var ranges = cm.listSelections(); var marks = cm.state.sublimeBookmarks || (cm.state.sublimeBookmarks = []); for (var i = 0; i < ranges.length; i++) { var from = ranges[i].from(), to = ranges[i].to(); var found = ranges[i].empty() ? cm.findMarksAt(from) : cm.findMarks(from, to); for (var j = 0; j < found.length; j++) { if (found[j].sublimeBookmark) { found[j].clear(); for (var k = 0; k < marks.length; k++) if (marks[k] == found[j]) marks.splice(k--, 1); break; } } if (j == found.length) marks.push(cm.markText(from, to, {sublimeBookmark: true, clearWhenEmpty: false})); } }; cmds.clearBookmarks = function(cm) { var marks = cm.state.sublimeBookmarks; if (marks) for (var i = 0; i < marks.length; i++) marks[i].clear(); marks.length = 0; }; cmds.selectBookmarks = function(cm) { var marks = cm.state.sublimeBookmarks, ranges = []; if (marks) for (var i = 0; i < marks.length; i++) { var found = marks[i].find(); if (!found) marks.splice(i--, 0); else ranges.push({anchor: found.from, head: found.to}); } if (ranges.length) cm.setSelections(ranges, 0); }; function modifyWordOrSelection(cm, mod) { cm.operation(function() { var ranges = cm.listSelections(), indices = [], replacements = []; for (var i = 0; i < ranges.length; i++) { var range = ranges[i]; if (range.empty()) { indices.push(i); replacements.push(""); } else replacements.push(mod(cm.getRange(range.from(), range.to()))); } cm.replaceSelections(replacements, "around", "case"); for (var i = indices.length - 1, at; i >= 0; i--) { var range = ranges[indices[i]]; if (at && CodeMirror.cmpPos(range.head, at) > 0) continue; var word = wordAt(cm, range.head); at = word.from; cm.replaceRange(mod(word.word), word.from, word.to); } }); } cmds.smartBackspace = function(cm) { if (cm.somethingSelected()) return CodeMirror.Pass; cm.operation(function() { var cursors = cm.listSelections(); var indentUnit = cm.getOption("indentUnit"); for (var i = cursors.length - 1; i >= 0; i--) { var cursor = cursors[i].head; var toStartOfLine = cm.getRange({line: cursor.line, ch: 0}, cursor); var column = CodeMirror.countColumn(toStartOfLine, null, cm.getOption("tabSize")); // Delete by one character by default var deletePos = cm.findPosH(cursor, -1, "char", false); if (toStartOfLine && !/\S/.test(toStartOfLine) && column % indentUnit == 0) { var prevIndent = new Pos(cursor.line, CodeMirror.findColumn(toStartOfLine, column - indentUnit, indentUnit)); // Smart delete only if we found a valid prevIndent location if (prevIndent.ch != cursor.ch) deletePos = prevIndent; } cm.replaceRange("", deletePos, cursor, "+delete"); } }); }; cmds.delLineRight = function(cm) { cm.operation(function() { var ranges = cm.listSelections(); for (var i = ranges.length - 1; i >= 0; i--) cm.replaceRange("", ranges[i].anchor, Pos(ranges[i].to().line), "+delete"); cm.scrollIntoView(); }); }; cmds.upcaseAtCursor = function(cm) { modifyWordOrSelection(cm, function(str) { return str.toUpperCase(); }); }; cmds.downcaseAtCursor = function(cm) { modifyWordOrSelection(cm, function(str) { return str.toLowerCase(); }); }; cmds.setSublimeMark = function(cm) { if (cm.state.sublimeMark) cm.state.sublimeMark.clear(); cm.state.sublimeMark = cm.setBookmark(cm.getCursor()); }; cmds.selectToSublimeMark = function(cm) { var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); if (found) cm.setSelection(cm.getCursor(), found); }; cmds.deleteToSublimeMark = function(cm) { var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); if (found) { var from = cm.getCursor(), to = found; if (CodeMirror.cmpPos(from, to) > 0) { var tmp = to; to = from; from = tmp; } cm.state.sublimeKilled = cm.getRange(from, to); cm.replaceRange("", from, to); } }; cmds.swapWithSublimeMark = function(cm) { var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); if (found) { cm.state.sublimeMark.clear(); cm.state.sublimeMark = cm.setBookmark(cm.getCursor()); cm.setCursor(found); } }; cmds.sublimeYank = function(cm) { if (cm.state.sublimeKilled != null) cm.replaceSelection(cm.state.sublimeKilled, null, "paste"); }; cmds.showInCenter = function(cm) { var pos = cm.cursorCoords(null, "local"); cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2); }; function getTarget(cm) { var from = cm.getCursor("from"), to = cm.getCursor("to"); if (CodeMirror.cmpPos(from, to) == 0) { var word = wordAt(cm, from); if (!word.word) return; from = word.from; to = word.to; } return {from: from, to: to, query: cm.getRange(from, to), word: word}; } function findAndGoTo(cm, forward) { var target = getTarget(cm); if (!target) return; var query = target.query; var cur = cm.getSearchCursor(query, forward ? target.to : target.from); if (forward ? cur.findNext() : cur.findPrevious()) { cm.setSelection(cur.from(), cur.to()); } else { cur = cm.getSearchCursor(query, forward ? Pos(cm.firstLine(), 0) : cm.clipPos(Pos(cm.lastLine()))); if (forward ? cur.findNext() : cur.findPrevious()) cm.setSelection(cur.from(), cur.to()); else if (target.word) cm.setSelection(target.from, target.to); } }; cmds.findUnder = function(cm) { findAndGoTo(cm, true); }; cmds.findUnderPrevious = function(cm) { findAndGoTo(cm,false); }; cmds.findAllUnder = function(cm) { var target = getTarget(cm); if (!target) return; var cur = cm.getSearchCursor(target.query); var matches = []; var primaryIndex = -1; while (cur.findNext()) { matches.push({anchor: cur.from(), head: cur.to()}); if (cur.from().line <= target.from.line && cur.from().ch <= target.from.ch) primaryIndex++; } cm.setSelections(matches, primaryIndex); }; var keyMap = CodeMirror.keyMap; keyMap.macSublime = { "Cmd-Left": "goLineStartSmart", "Shift-Tab": "indentLess", "Shift-Ctrl-K": "deleteLine", "Alt-Q": "wrapLines", "Ctrl-Left": "goSubwordLeft", "Ctrl-Right": "goSubwordRight", "Ctrl-Alt-Up": "scrollLineUp", "Ctrl-Alt-Down": "scrollLineDown", "Cmd-L": "selectLine", "Shift-Cmd-L": "splitSelectionByLine", "Esc": "singleSelectionTop", "Cmd-Enter": "insertLineAfter", "Shift-Cmd-Enter": "insertLineBefore", "Cmd-D": "selectNextOccurrence", "Shift-Cmd-Space": "selectScope", "Shift-Cmd-M": "selectBetweenBrackets", "Cmd-M": "goToBracket", "Cmd-Ctrl-Up": "swapLineUp", "Cmd-Ctrl-Down": "swapLineDown", "Cmd-/": "toggleCommentIndented", "Cmd-J": "joinLines", "Shift-Cmd-D": "duplicateLine", "F5": "sortLines", "Cmd-F5": "sortLinesInsensitive", "F2": "nextBookmark", "Shift-F2": "prevBookmark", "Cmd-F2": "toggleBookmark", "Shift-Cmd-F2": "clearBookmarks", "Alt-F2": "selectBookmarks", "Backspace": "smartBackspace", "Cmd-K Cmd-D": "skipAndSelectNextOccurrence", "Cmd-K Cmd-K": "delLineRight", "Cmd-K Cmd-U": "upcaseAtCursor", "Cmd-K Cmd-L": "downcaseAtCursor", "Cmd-K Cmd-Space": "setSublimeMark", "Cmd-K Cmd-A": "selectToSublimeMark", "Cmd-K Cmd-W": "deleteToSublimeMark", "Cmd-K Cmd-X": "swapWithSublimeMark", "Cmd-K Cmd-Y": "sublimeYank", "Cmd-K Cmd-C": "showInCenter", "Cmd-K Cmd-G": "clearBookmarks", "Cmd-K Cmd-Backspace": "delLineLeft", "Cmd-K Cmd-1": "foldAll", "Cmd-K Cmd-0": "unfoldAll", "Cmd-K Cmd-J": "unfoldAll", "Ctrl-Shift-Up": "addCursorToPrevLine", "Ctrl-Shift-Down": "addCursorToNextLine", "Cmd-F3": "findUnder", "Shift-Cmd-F3": "findUnderPrevious", "Alt-F3": "findAllUnder", "Shift-Cmd-[": "fold", "Shift-Cmd-]": "unfold", "Cmd-I": "findIncremental", "Shift-Cmd-I": "findIncrementalReverse", "Cmd-H": "replace", "F3": "findNext", "Shift-F3": "findPrev", "fallthrough": "macDefault" }; CodeMirror.normalizeKeyMap(keyMap.macSublime); keyMap.pcSublime = { "Shift-Tab": "indentLess", "Shift-Ctrl-K": "deleteLine", "Alt-Q": "wrapLines", "Ctrl-T": "transposeChars", "Alt-Left": "goSubwordLeft", "Alt-Right": "goSubwordRight", "Ctrl-Up": "scrollLineUp", "Ctrl-Down": "scrollLineDown", "Ctrl-L": "selectLine", "Shift-Ctrl-L": "splitSelectionByLine", "Esc": "singleSelectionTop", "Ctrl-Enter": "insertLineAfter", "Shift-Ctrl-Enter": "insertLineBefore", "Ctrl-D": "selectNextOccurrence", "Shift-Ctrl-Space": "selectScope", "Shift-Ctrl-M": "selectBetweenBrackets", "Ctrl-M": "goToBracket", "Shift-Ctrl-Up": "swapLineUp", "Shift-Ctrl-Down": "swapLineDown", "Ctrl-/": "toggleCommentIndented", "Ctrl-J": "joinLines", "Shift-Ctrl-D": "duplicateLine", "F9": "sortLines", "Ctrl-F9": "sortLinesInsensitive", "F2": "nextBookmark", "Shift-F2": "prevBookmark", "Ctrl-F2": "toggleBookmark", "Shift-Ctrl-F2": "clearBookmarks", "Alt-F2": "selectBookmarks", "Backspace": "smartBackspace", "Ctrl-K Ctrl-D": "skipAndSelectNextOccurrence", "Ctrl-K Ctrl-K": "delLineRight", "Ctrl-K Ctrl-U": "upcaseAtCursor", "Ctrl-K Ctrl-L": "downcaseAtCursor", "Ctrl-K Ctrl-Space": "setSublimeMark", "Ctrl-K Ctrl-A": "selectToSublimeMark", "Ctrl-K Ctrl-W": "deleteToSublimeMark", "Ctrl-K Ctrl-X": "swapWithSublimeMark", "Ctrl-K Ctrl-Y": "sublimeYank", "Ctrl-K Ctrl-C": "showInCenter", "Ctrl-K Ctrl-G": "clearBookmarks", "Ctrl-K Ctrl-Backspace": "delLineLeft", "Ctrl-K Ctrl-1": "foldAll", "Ctrl-K Ctrl-0": "unfoldAll", "Ctrl-K Ctrl-J": "unfoldAll", "Ctrl-Alt-Up": "addCursorToPrevLine", "Ctrl-Alt-Down": "addCursorToNextLine", "Ctrl-F3": "findUnder", "Shift-Ctrl-F3": "findUnderPrevious", "Alt-F3": "findAllUnder", "Shift-Ctrl-[": "fold", "Shift-Ctrl-]": "unfold", "Ctrl-I": "findIncremental", "Shift-Ctrl-I": "findIncrementalReverse", "Ctrl-H": "replace", "F3": "findNext", "Shift-F3": "findPrev", "fallthrough": "pcDefault" }; CodeMirror.normalizeKeyMap(keyMap.pcSublime); var mac = keyMap.default == keyMap.macDefault; keyMap.sublime = mac ? keyMap.macSublime : keyMap.pcSublime; }); ================================================ FILE: plugins/UiFileManager/media/codemirror/mode/coffeescript.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE /** * Link to the project's GitHub page: * https://github.com/pickhardt/coffeescript-codemirror-mode */ (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("coffeescript", function(conf, parserConf) { var ERRORCLASS = "error"; function wordRegexp(words) { return new RegExp("^((" + words.join(")|(") + "))\\b"); } var operators = /^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>>?=?|%=?|&=?|\|=?|\^=?|\~|!|\?|(or|and|\|\||&&|\?)=)/; var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/; var identifiers = /^[_A-Za-z$][_A-Za-z$0-9]*/; var atProp = /^@[_A-Za-z$][_A-Za-z$0-9]*/; var wordOperators = wordRegexp(["and", "or", "not", "is", "isnt", "in", "instanceof", "typeof"]); var indentKeywords = ["for", "while", "loop", "if", "unless", "else", "switch", "try", "catch", "finally", "class"]; var commonKeywords = ["break", "by", "continue", "debugger", "delete", "do", "in", "of", "new", "return", "then", "this", "@", "throw", "when", "until", "extends"]; var keywords = wordRegexp(indentKeywords.concat(commonKeywords)); indentKeywords = wordRegexp(indentKeywords); var stringPrefixes = /^('{3}|\"{3}|['\"])/; var regexPrefixes = /^(\/{3}|\/)/; var commonConstants = ["Infinity", "NaN", "undefined", "null", "true", "false", "on", "off", "yes", "no"]; var constants = wordRegexp(commonConstants); // Tokenizers function tokenBase(stream, state) { // Handle scope changes if (stream.sol()) { if (state.scope.align === null) state.scope.align = false; var scopeOffset = state.scope.offset; if (stream.eatSpace()) { var lineOffset = stream.indentation(); if (lineOffset > scopeOffset && state.scope.type == "coffee") { return "indent"; } else if (lineOffset < scopeOffset) { return "dedent"; } return null; } else { if (scopeOffset > 0) { dedent(stream, state); } } } if (stream.eatSpace()) { return null; } var ch = stream.peek(); // Handle docco title comment (single line) if (stream.match("####")) { stream.skipToEnd(); return "comment"; } // Handle multi line comments if (stream.match("###")) { state.tokenize = longComment; return state.tokenize(stream, state); } // Single line comment if (ch === "#") { stream.skipToEnd(); return "comment"; } // Handle number literals if (stream.match(/^-?[0-9\.]/, false)) { var floatLiteral = false; // Floats if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; } if (stream.match(/^-?\d+\.\d*/)) { floatLiteral = true; } if (stream.match(/^-?\.\d+/)) { floatLiteral = true; } if (floatLiteral) { // prevent from getting extra . on 1.. if (stream.peek() == "."){ stream.backUp(1); } return "number"; } // Integers var intLiteral = false; // Hex if (stream.match(/^-?0x[0-9a-f]+/i)) { intLiteral = true; } // Decimal if (stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)) { intLiteral = true; } // Zero by itself with no other piece of number. if (stream.match(/^-?0(?![\dx])/i)) { intLiteral = true; } if (intLiteral) { return "number"; } } // Handle strings if (stream.match(stringPrefixes)) { state.tokenize = tokenFactory(stream.current(), false, "string"); return state.tokenize(stream, state); } // Handle regex literals if (stream.match(regexPrefixes)) { if (stream.current() != "/" || stream.match(/^.*\//, false)) { // prevent highlight of division state.tokenize = tokenFactory(stream.current(), true, "string-2"); return state.tokenize(stream, state); } else { stream.backUp(1); } } // Handle operators and delimiters if (stream.match(operators) || stream.match(wordOperators)) { return "operator"; } if (stream.match(delimiters)) { return "punctuation"; } if (stream.match(constants)) { return "atom"; } if (stream.match(atProp) || state.prop && stream.match(identifiers)) { return "property"; } if (stream.match(keywords)) { return "keyword"; } if (stream.match(identifiers)) { return "variable"; } // Handle non-detected items stream.next(); return ERRORCLASS; } function tokenFactory(delimiter, singleline, outclass) { return function(stream, state) { while (!stream.eol()) { stream.eatWhile(/[^'"\/\\]/); if (stream.eat("\\")) { stream.next(); if (singleline && stream.eol()) { return outclass; } } else if (stream.match(delimiter)) { state.tokenize = tokenBase; return outclass; } else { stream.eat(/['"\/]/); } } if (singleline) { if (parserConf.singleLineStringErrors) { outclass = ERRORCLASS; } else { state.tokenize = tokenBase; } } return outclass; }; } function longComment(stream, state) { while (!stream.eol()) { stream.eatWhile(/[^#]/); if (stream.match("###")) { state.tokenize = tokenBase; break; } stream.eatWhile("#"); } return "comment"; } function indent(stream, state, type) { type = type || "coffee"; var offset = 0, align = false, alignOffset = null; for (var scope = state.scope; scope; scope = scope.prev) { if (scope.type === "coffee" || scope.type == "}") { offset = scope.offset + conf.indentUnit; break; } } if (type !== "coffee") { align = null; alignOffset = stream.column() + stream.current().length; } else if (state.scope.align) { state.scope.align = false; } state.scope = { offset: offset, type: type, prev: state.scope, align: align, alignOffset: alignOffset }; } function dedent(stream, state) { if (!state.scope.prev) return; if (state.scope.type === "coffee") { var _indent = stream.indentation(); var matched = false; for (var scope = state.scope; scope; scope = scope.prev) { if (_indent === scope.offset) { matched = true; break; } } if (!matched) { return true; } while (state.scope.prev && state.scope.offset !== _indent) { state.scope = state.scope.prev; } return false; } else { state.scope = state.scope.prev; return false; } } function tokenLexer(stream, state) { var style = state.tokenize(stream, state); var current = stream.current(); // Handle scope changes. if (current === "return") { state.dedent = true; } if (((current === "->" || current === "=>") && stream.eol()) || style === "indent") { indent(stream, state); } var delimiter_index = "[({".indexOf(current); if (delimiter_index !== -1) { indent(stream, state, "])}".slice(delimiter_index, delimiter_index+1)); } if (indentKeywords.exec(current)){ indent(stream, state); } if (current == "then"){ dedent(stream, state); } if (style === "dedent") { if (dedent(stream, state)) { return ERRORCLASS; } } delimiter_index = "])}".indexOf(current); if (delimiter_index !== -1) { while (state.scope.type == "coffee" && state.scope.prev) state.scope = state.scope.prev; if (state.scope.type == current) state.scope = state.scope.prev; } if (state.dedent && stream.eol()) { if (state.scope.type == "coffee" && state.scope.prev) state.scope = state.scope.prev; state.dedent = false; } return style; } var external = { startState: function(basecolumn) { return { tokenize: tokenBase, scope: {offset:basecolumn || 0, type:"coffee", prev: null, align: false}, prop: false, dedent: 0 }; }, token: function(stream, state) { var fillAlign = state.scope.align === null && state.scope; if (fillAlign && stream.sol()) fillAlign.align = false; var style = tokenLexer(stream, state); if (style && style != "comment") { if (fillAlign) fillAlign.align = true; state.prop = style == "punctuation" && stream.current() == "." } return style; }, indent: function(state, text) { if (state.tokenize != tokenBase) return 0; var scope = state.scope; var closer = text && "])}".indexOf(text.charAt(0)) > -1; if (closer) while (scope.type == "coffee" && scope.prev) scope = scope.prev; var closes = closer && scope.type === text.charAt(0); if (scope.align) return scope.alignOffset - (closes ? 1 : 0); else return (closes ? scope.prev : scope).offset; }, lineComment: "#", fold: "indent" }; return external; }); // IANA registered media type // https://www.iana.org/assignments/media-types/ CodeMirror.defineMIME("application/vnd.coffeescript", "coffeescript"); CodeMirror.defineMIME("text/x-coffeescript", "coffeescript"); CodeMirror.defineMIME("text/coffeescript", "coffeescript"); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/mode/css.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("css", function(config, parserConfig) { var inline = parserConfig.inline if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css"); var indentUnit = config.indentUnit, tokenHooks = parserConfig.tokenHooks, documentTypes = parserConfig.documentTypes || {}, mediaTypes = parserConfig.mediaTypes || {}, mediaFeatures = parserConfig.mediaFeatures || {}, mediaValueKeywords = parserConfig.mediaValueKeywords || {}, propertyKeywords = parserConfig.propertyKeywords || {}, nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {}, fontProperties = parserConfig.fontProperties || {}, counterDescriptors = parserConfig.counterDescriptors || {}, colorKeywords = parserConfig.colorKeywords || {}, valueKeywords = parserConfig.valueKeywords || {}, allowNested = parserConfig.allowNested, lineComment = parserConfig.lineComment, supportsAtComponent = parserConfig.supportsAtComponent === true; var type, override; function ret(style, tp) { type = tp; return style; } // Tokenizers function tokenBase(stream, state) { var ch = stream.next(); if (tokenHooks[ch]) { var result = tokenHooks[ch](stream, state); if (result !== false) return result; } if (ch == "@") { stream.eatWhile(/[\w\\\-]/); return ret("def", stream.current()); } else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) { return ret(null, "compare"); } else if (ch == "\"" || ch == "'") { state.tokenize = tokenString(ch); return state.tokenize(stream, state); } else if (ch == "#") { stream.eatWhile(/[\w\\\-]/); return ret("atom", "hash"); } else if (ch == "!") { stream.match(/^\s*\w*/); return ret("keyword", "important"); } else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) { stream.eatWhile(/[\w.%]/); return ret("number", "unit"); } else if (ch === "-") { if (/[\d.]/.test(stream.peek())) { stream.eatWhile(/[\w.%]/); return ret("number", "unit"); } else if (stream.match(/^-[\w\\\-]*/)) { stream.eatWhile(/[\w\\\-]/); if (stream.match(/^\s*:/, false)) return ret("variable-2", "variable-definition"); return ret("variable-2", "variable"); } else if (stream.match(/^\w+-/)) { return ret("meta", "meta"); } } else if (/[,+>*\/]/.test(ch)) { return ret(null, "select-op"); } else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) { return ret("qualifier", "qualifier"); } else if (/[:;{}\[\]\(\)]/.test(ch)) { return ret(null, ch); } else if (stream.match(/[\w-.]+(?=\()/)) { if (/^(url(-prefix)?|domain|regexp)$/.test(stream.current().toLowerCase())) { state.tokenize = tokenParenthesized; } return ret("variable callee", "variable"); } else if (/[\w\\\-]/.test(ch)) { stream.eatWhile(/[\w\\\-]/); return ret("property", "word"); } else { return ret(null, null); } } function tokenString(quote) { return function(stream, state) { var escaped = false, ch; while ((ch = stream.next()) != null) { if (ch == quote && !escaped) { if (quote == ")") stream.backUp(1); break; } escaped = !escaped && ch == "\\"; } if (ch == quote || !escaped && quote != ")") state.tokenize = null; return ret("string", "string"); }; } function tokenParenthesized(stream, state) { stream.next(); // Must be '(' if (!stream.match(/\s*[\"\')]/, false)) state.tokenize = tokenString(")"); else state.tokenize = null; return ret(null, "("); } // Context management function Context(type, indent, prev) { this.type = type; this.indent = indent; this.prev = prev; } function pushContext(state, stream, type, indent) { state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context); return type; } function popContext(state) { if (state.context.prev) state.context = state.context.prev; return state.context.type; } function pass(type, stream, state) { return states[state.context.type](type, stream, state); } function popAndPass(type, stream, state, n) { for (var i = n || 1; i > 0; i--) state.context = state.context.prev; return pass(type, stream, state); } // Parser function wordAsValue(stream) { var word = stream.current().toLowerCase(); if (valueKeywords.hasOwnProperty(word)) override = "atom"; else if (colorKeywords.hasOwnProperty(word)) override = "keyword"; else override = "variable"; } var states = {}; states.top = function(type, stream, state) { if (type == "{") { return pushContext(state, stream, "block"); } else if (type == "}" && state.context.prev) { return popContext(state); } else if (supportsAtComponent && /@component/i.test(type)) { return pushContext(state, stream, "atComponentBlock"); } else if (/^@(-moz-)?document$/i.test(type)) { return pushContext(state, stream, "documentTypes"); } else if (/^@(media|supports|(-moz-)?document|import)$/i.test(type)) { return pushContext(state, stream, "atBlock"); } else if (/^@(font-face|counter-style)/i.test(type)) { state.stateArg = type; return "restricted_atBlock_before"; } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(type)) { return "keyframes"; } else if (type && type.charAt(0) == "@") { return pushContext(state, stream, "at"); } else if (type == "hash") { override = "builtin"; } else if (type == "word") { override = "tag"; } else if (type == "variable-definition") { return "maybeprop"; } else if (type == "interpolation") { return pushContext(state, stream, "interpolation"); } else if (type == ":") { return "pseudo"; } else if (allowNested && type == "(") { return pushContext(state, stream, "parens"); } return state.context.type; }; states.block = function(type, stream, state) { if (type == "word") { var word = stream.current().toLowerCase(); if (propertyKeywords.hasOwnProperty(word)) { override = "property"; return "maybeprop"; } else if (nonStandardPropertyKeywords.hasOwnProperty(word)) { override = "string-2"; return "maybeprop"; } else if (allowNested) { override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag"; return "block"; } else { override += " error"; return "maybeprop"; } } else if (type == "meta") { return "block"; } else if (!allowNested && (type == "hash" || type == "qualifier")) { override = "error"; return "block"; } else { return states.top(type, stream, state); } }; states.maybeprop = function(type, stream, state) { if (type == ":") return pushContext(state, stream, "prop"); return pass(type, stream, state); }; states.prop = function(type, stream, state) { if (type == ";") return popContext(state); if (type == "{" && allowNested) return pushContext(state, stream, "propBlock"); if (type == "}" || type == "{") return popAndPass(type, stream, state); if (type == "(") return pushContext(state, stream, "parens"); if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) { override += " error"; } else if (type == "word") { wordAsValue(stream); } else if (type == "interpolation") { return pushContext(state, stream, "interpolation"); } return "prop"; }; states.propBlock = function(type, _stream, state) { if (type == "}") return popContext(state); if (type == "word") { override = "property"; return "maybeprop"; } return state.context.type; }; states.parens = function(type, stream, state) { if (type == "{" || type == "}") return popAndPass(type, stream, state); if (type == ")") return popContext(state); if (type == "(") return pushContext(state, stream, "parens"); if (type == "interpolation") return pushContext(state, stream, "interpolation"); if (type == "word") wordAsValue(stream); return "parens"; }; states.pseudo = function(type, stream, state) { if (type == "meta") return "pseudo"; if (type == "word") { override = "variable-3"; return state.context.type; } return pass(type, stream, state); }; states.documentTypes = function(type, stream, state) { if (type == "word" && documentTypes.hasOwnProperty(stream.current())) { override = "tag"; return state.context.type; } else { return states.atBlock(type, stream, state); } }; states.atBlock = function(type, stream, state) { if (type == "(") return pushContext(state, stream, "atBlock_parens"); if (type == "}" || type == ";") return popAndPass(type, stream, state); if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top"); if (type == "interpolation") return pushContext(state, stream, "interpolation"); if (type == "word") { var word = stream.current().toLowerCase(); if (word == "only" || word == "not" || word == "and" || word == "or") override = "keyword"; else if (mediaTypes.hasOwnProperty(word)) override = "attribute"; else if (mediaFeatures.hasOwnProperty(word)) override = "property"; else if (mediaValueKeywords.hasOwnProperty(word)) override = "keyword"; else if (propertyKeywords.hasOwnProperty(word)) override = "property"; else if (nonStandardPropertyKeywords.hasOwnProperty(word)) override = "string-2"; else if (valueKeywords.hasOwnProperty(word)) override = "atom"; else if (colorKeywords.hasOwnProperty(word)) override = "keyword"; else override = "error"; } return state.context.type; }; states.atComponentBlock = function(type, stream, state) { if (type == "}") return popAndPass(type, stream, state); if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false); if (type == "word") override = "error"; return state.context.type; }; states.atBlock_parens = function(type, stream, state) { if (type == ")") return popContext(state); if (type == "{" || type == "}") return popAndPass(type, stream, state, 2); return states.atBlock(type, stream, state); }; states.restricted_atBlock_before = function(type, stream, state) { if (type == "{") return pushContext(state, stream, "restricted_atBlock"); if (type == "word" && state.stateArg == "@counter-style") { override = "variable"; return "restricted_atBlock_before"; } return pass(type, stream, state); }; states.restricted_atBlock = function(type, stream, state) { if (type == "}") { state.stateArg = null; return popContext(state); } if (type == "word") { if ((state.stateArg == "@font-face" && !fontProperties.hasOwnProperty(stream.current().toLowerCase())) || (state.stateArg == "@counter-style" && !counterDescriptors.hasOwnProperty(stream.current().toLowerCase()))) override = "error"; else override = "property"; return "maybeprop"; } return "restricted_atBlock"; }; states.keyframes = function(type, stream, state) { if (type == "word") { override = "variable"; return "keyframes"; } if (type == "{") return pushContext(state, stream, "top"); return pass(type, stream, state); }; states.at = function(type, stream, state) { if (type == ";") return popContext(state); if (type == "{" || type == "}") return popAndPass(type, stream, state); if (type == "word") override = "tag"; else if (type == "hash") override = "builtin"; return "at"; }; states.interpolation = function(type, stream, state) { if (type == "}") return popContext(state); if (type == "{" || type == ";") return popAndPass(type, stream, state); if (type == "word") override = "variable"; else if (type != "variable" && type != "(" && type != ")") override = "error"; return "interpolation"; }; return { startState: function(base) { return {tokenize: null, state: inline ? "block" : "top", stateArg: null, context: new Context(inline ? "block" : "top", base || 0, null)}; }, token: function(stream, state) { if (!state.tokenize && stream.eatSpace()) return null; var style = (state.tokenize || tokenBase)(stream, state); if (style && typeof style == "object") { type = style[1]; style = style[0]; } override = style; if (type != "comment") state.state = states[state.state](type, stream, state); return override; }, indent: function(state, textAfter) { var cx = state.context, ch = textAfter && textAfter.charAt(0); var indent = cx.indent; if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev; if (cx.prev) { if (ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "restricted_atBlock")) { // Resume indentation from parent context. cx = cx.prev; indent = cx.indent; } else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") || ch == "{" && (cx.type == "at" || cx.type == "atBlock")) { // Dedent relative to current context. indent = Math.max(0, cx.indent - indentUnit); } } return indent; }, electricChars: "}", blockCommentStart: "/*", blockCommentEnd: "*/", blockCommentContinue: " * ", lineComment: lineComment, fold: "brace" }; }); function keySet(array) { var keys = {}; for (var i = 0; i < array.length; ++i) { keys[array[i].toLowerCase()] = true; } return keys; } var documentTypes_ = [ "domain", "regexp", "url", "url-prefix" ], documentTypes = keySet(documentTypes_); var mediaTypes_ = [ "all", "aural", "braille", "handheld", "print", "projection", "screen", "tty", "tv", "embossed" ], mediaTypes = keySet(mediaTypes_); var mediaFeatures_ = [ "width", "min-width", "max-width", "height", "min-height", "max-height", "device-width", "min-device-width", "max-device-width", "device-height", "min-device-height", "max-device-height", "aspect-ratio", "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio", "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color", "max-color", "color-index", "min-color-index", "max-color-index", "monochrome", "min-monochrome", "max-monochrome", "resolution", "min-resolution", "max-resolution", "scan", "grid", "orientation", "device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio", "pointer", "any-pointer", "hover", "any-hover" ], mediaFeatures = keySet(mediaFeatures_); var mediaValueKeywords_ = [ "landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover", "interlace", "progressive" ], mediaValueKeywords = keySet(mediaValueKeywords_); var propertyKeywords_ = [ "align-content", "align-items", "align-self", "alignment-adjust", "alignment-baseline", "anchor-point", "animation", "animation-delay", "animation-direction", "animation-duration", "animation-fill-mode", "animation-iteration-count", "animation-name", "animation-play-state", "animation-timing-function", "appearance", "azimuth", "backdrop-filter", "backface-visibility", "background", "background-attachment", "background-blend-mode", "background-clip", "background-color", "background-image", "background-origin", "background-position", "background-position-x", "background-position-y", "background-repeat", "background-size", "baseline-shift", "binding", "bleed", "block-size", "bookmark-label", "bookmark-level", "bookmark-state", "bookmark-target", "border", "border-bottom", "border-bottom-color", "border-bottom-left-radius", "border-bottom-right-radius", "border-bottom-style", "border-bottom-width", "border-collapse", "border-color", "border-image", "border-image-outset", "border-image-repeat", "border-image-slice", "border-image-source", "border-image-width", "border-left", "border-left-color", "border-left-style", "border-left-width", "border-radius", "border-right", "border-right-color", "border-right-style", "border-right-width", "border-spacing", "border-style", "border-top", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-top-style", "border-top-width", "border-width", "bottom", "box-decoration-break", "box-shadow", "box-sizing", "break-after", "break-before", "break-inside", "caption-side", "caret-color", "clear", "clip", "color", "color-profile", "column-count", "column-fill", "column-gap", "column-rule", "column-rule-color", "column-rule-style", "column-rule-width", "column-span", "column-width", "columns", "contain", "content", "counter-increment", "counter-reset", "crop", "cue", "cue-after", "cue-before", "cursor", "direction", "display", "dominant-baseline", "drop-initial-after-adjust", "drop-initial-after-align", "drop-initial-before-adjust", "drop-initial-before-align", "drop-initial-size", "drop-initial-value", "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis", "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap", "float", "float-offset", "flow-from", "flow-into", "font", "font-family", "font-feature-settings", "font-kerning", "font-language-override", "font-optical-sizing", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-synthesis", "font-variant", "font-variant-alternates", "font-variant-caps", "font-variant-east-asian", "font-variant-ligatures", "font-variant-numeric", "font-variant-position", "font-variation-settings", "font-weight", "gap", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow", "grid-auto-rows", "grid-column", "grid-column-end", "grid-column-gap", "grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap", "grid-row-start", "grid-template", "grid-template-areas", "grid-template-columns", "grid-template-rows", "hanging-punctuation", "height", "hyphens", "icon", "image-orientation", "image-rendering", "image-resolution", "inline-box-align", "inset", "inset-block", "inset-block-end", "inset-block-start", "inset-inline", "inset-inline-end", "inset-inline-start", "isolation", "justify-content", "justify-items", "justify-self", "left", "letter-spacing", "line-break", "line-height", "line-height-step", "line-stacking", "line-stacking-ruby", "line-stacking-shift", "line-stacking-strategy", "list-style", "list-style-image", "list-style-position", "list-style-type", "margin", "margin-bottom", "margin-left", "margin-right", "margin-top", "marks", "marquee-direction", "marquee-loop", "marquee-play-count", "marquee-speed", "marquee-style", "max-block-size", "max-height", "max-inline-size", "max-width", "min-block-size", "min-height", "min-inline-size", "min-width", "mix-blend-mode", "move-to", "nav-down", "nav-index", "nav-left", "nav-right", "nav-up", "object-fit", "object-position", "offset", "offset-anchor", "offset-distance", "offset-path", "offset-position", "offset-rotate", "opacity", "order", "orphans", "outline", "outline-color", "outline-offset", "outline-style", "outline-width", "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y", "padding", "padding-bottom", "padding-left", "padding-right", "padding-top", "page", "page-break-after", "page-break-before", "page-break-inside", "page-policy", "pause", "pause-after", "pause-before", "perspective", "perspective-origin", "pitch", "pitch-range", "place-content", "place-items", "place-self", "play-during", "position", "presentation-level", "punctuation-trim", "quotes", "region-break-after", "region-break-before", "region-break-inside", "region-fragment", "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness", "right", "rotate", "rotation", "rotation-point", "row-gap", "ruby-align", "ruby-overhang", "ruby-position", "ruby-span", "scale", "scroll-behavior", "scroll-margin", "scroll-margin-block", "scroll-margin-block-end", "scroll-margin-block-start", "scroll-margin-bottom", "scroll-margin-inline", "scroll-margin-inline-end", "scroll-margin-inline-start", "scroll-margin-left", "scroll-margin-right", "scroll-margin-top", "scroll-padding", "scroll-padding-block", "scroll-padding-block-end", "scroll-padding-block-start", "scroll-padding-bottom", "scroll-padding-inline", "scroll-padding-inline-end", "scroll-padding-inline-start", "scroll-padding-left", "scroll-padding-right", "scroll-padding-top", "scroll-snap-align", "scroll-snap-type", "shape-image-threshold", "shape-inside", "shape-margin", "shape-outside", "size", "speak", "speak-as", "speak-header", "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set", "tab-size", "table-layout", "target", "target-name", "target-new", "target-position", "text-align", "text-align-last", "text-combine-upright", "text-decoration", "text-decoration-color", "text-decoration-line", "text-decoration-skip", "text-decoration-skip-ink", "text-decoration-style", "text-emphasis", "text-emphasis-color", "text-emphasis-position", "text-emphasis-style", "text-height", "text-indent", "text-justify", "text-orientation", "text-outline", "text-overflow", "text-rendering", "text-shadow", "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position", "text-wrap", "top", "transform", "transform-origin", "transform-style", "transition", "transition-delay", "transition-duration", "transition-property", "transition-timing-function", "translate", "unicode-bidi", "user-select", "vertical-align", "visibility", "voice-balance", "voice-duration", "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress", "voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break", "word-spacing", "word-wrap", "writing-mode", "z-index", // SVG-specific "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color", "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events", "color-interpolation", "color-interpolation-filters", "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering", "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering", "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal", "glyph-orientation-vertical", "text-anchor", "writing-mode" ], propertyKeywords = keySet(propertyKeywords_); var nonStandardPropertyKeywords_ = [ "border-block", "border-block-color", "border-block-end", "border-block-end-color", "border-block-end-style", "border-block-end-width", "border-block-start", "border-block-start-color", "border-block-start-style", "border-block-start-width", "border-block-style", "border-block-width", "border-inline", "border-inline-color", "border-inline-end", "border-inline-end-color", "border-inline-end-style", "border-inline-end-width", "border-inline-start", "border-inline-start-color", "border-inline-start-style", "border-inline-start-width", "border-inline-style", "border-inline-width", "margin-block", "margin-block-end", "margin-block-start", "margin-inline", "margin-inline-end", "margin-inline-start", "padding-block", "padding-block-end", "padding-block-start", "padding-inline", "padding-inline-end", "padding-inline-start", "scroll-snap-stop", "scrollbar-3d-light-color", "scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color", "scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color", "scrollbar-track-color", "searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button", "searchfield-results-decoration", "shape-inside", "zoom" ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_); var fontProperties_ = [ "font-display", "font-family", "src", "unicode-range", "font-variant", "font-feature-settings", "font-stretch", "font-weight", "font-style" ], fontProperties = keySet(fontProperties_); var counterDescriptors_ = [ "additive-symbols", "fallback", "negative", "pad", "prefix", "range", "speak-as", "suffix", "symbols", "system" ], counterDescriptors = keySet(counterDescriptors_); var colorKeywords_ = [ "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", "whitesmoke", "yellow", "yellowgreen" ], colorKeywords = keySet(colorKeywords_); var valueKeywords_ = [ "above", "absolute", "activeborder", "additive", "activecaption", "afar", "after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", "always", "amharic", "amharic-abegede", "antialiased", "appworkspace", "arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page", "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary", "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box", "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel", "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian", "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret", "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch", "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote", "col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse", "compact", "condensed", "contain", "content", "contents", "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop", "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal", "decimal-leading-zero", "default", "default-button", "dense", "destination-atop", "destination-in", "destination-out", "destination-over", "devanagari", "difference", "disc", "discard", "disclosure-closed", "disclosure-open", "document", "dot-dash", "dot-dot-dash", "dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out", "element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede", "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er", "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er", "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et", "ethiopic-halehame-gez", "ethiopic-halehame-om-et", "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et", "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig", "ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed", "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", "forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove", "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew", "help", "hidden", "hide", "higher", "highlight", "highlighttext", "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore", "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis", "inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert", "italic", "japanese-formal", "japanese-informal", "justify", "kannada", "katakana", "katakana-iroha", "keep-all", "khmer", "korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal", "landscape", "lao", "large", "larger", "left", "level", "lighter", "lighten", "line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian", "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian", "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d", "media-controls-background", "media-current-time-display", "media-fullscreen-button", "media-mute-button", "media-play-button", "media-return-to-realtime-button", "media-rewind-button", "media-seek-back-button", "media-seek-forward-button", "media-slider", "media-sliderthumb", "media-time-remaining-display", "media-volume-slider", "media-volume-slider-container", "media-volume-sliderthumb", "medium", "menu", "menulist", "menulist-button", "menulist-text", "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic", "mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize", "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap", "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote", "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset", "outside", "outside-shape", "overlay", "overline", "padding", "padding-box", "painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter", "pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", "radial-gradient", "radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", "relative", "repeat", "repeating-linear-gradient", "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY", "rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running", "s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen", "scroll", "scrollbar", "scroll-position", "se-resize", "searchfield", "searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button", "searchfield-results-decoration", "self-start", "self-end", "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama", "simp-chinese-formal", "simp-chinese-informal", "single", "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal", "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", "small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali", "source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square", "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub", "subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table", "table-caption", "table-cell", "table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row", "table-row-group", "tamil", "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai", "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er", "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top", "trad-chinese-formal", "trad-chinese-informal", "transform", "translate", "translate3d", "translateX", "translateY", "translateZ", "transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up", "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal", "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url", "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", "window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor", "xx-large", "xx-small" ], valueKeywords = keySet(valueKeywords_); var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_) .concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_) .concat(valueKeywords_); CodeMirror.registerHelper("hintWords", "css", allWords); function tokenCComment(stream, state) { var maybeEnd = false, ch; while ((ch = stream.next()) != null) { if (maybeEnd && ch == "/") { state.tokenize = null; break; } maybeEnd = (ch == "*"); } return ["comment", "comment"]; } CodeMirror.defineMIME("text/css", { documentTypes: documentTypes, mediaTypes: mediaTypes, mediaFeatures: mediaFeatures, mediaValueKeywords: mediaValueKeywords, propertyKeywords: propertyKeywords, nonStandardPropertyKeywords: nonStandardPropertyKeywords, fontProperties: fontProperties, counterDescriptors: counterDescriptors, colorKeywords: colorKeywords, valueKeywords: valueKeywords, tokenHooks: { "/": function(stream, state) { if (!stream.eat("*")) return false; state.tokenize = tokenCComment; return tokenCComment(stream, state); } }, name: "css" }); CodeMirror.defineMIME("text/x-scss", { mediaTypes: mediaTypes, mediaFeatures: mediaFeatures, mediaValueKeywords: mediaValueKeywords, propertyKeywords: propertyKeywords, nonStandardPropertyKeywords: nonStandardPropertyKeywords, colorKeywords: colorKeywords, valueKeywords: valueKeywords, fontProperties: fontProperties, allowNested: true, lineComment: "//", tokenHooks: { "/": function(stream, state) { if (stream.eat("/")) { stream.skipToEnd(); return ["comment", "comment"]; } else if (stream.eat("*")) { state.tokenize = tokenCComment; return tokenCComment(stream, state); } else { return ["operator", "operator"]; } }, ":": function(stream) { if (stream.match(/\s*\{/, false)) return [null, null] return false; }, "$": function(stream) { stream.match(/^[\w-]+/); if (stream.match(/^\s*:/, false)) return ["variable-2", "variable-definition"]; return ["variable-2", "variable"]; }, "#": function(stream) { if (!stream.eat("{")) return false; return [null, "interpolation"]; } }, name: "css", helperType: "scss" }); CodeMirror.defineMIME("text/x-less", { mediaTypes: mediaTypes, mediaFeatures: mediaFeatures, mediaValueKeywords: mediaValueKeywords, propertyKeywords: propertyKeywords, nonStandardPropertyKeywords: nonStandardPropertyKeywords, colorKeywords: colorKeywords, valueKeywords: valueKeywords, fontProperties: fontProperties, allowNested: true, lineComment: "//", tokenHooks: { "/": function(stream, state) { if (stream.eat("/")) { stream.skipToEnd(); return ["comment", "comment"]; } else if (stream.eat("*")) { state.tokenize = tokenCComment; return tokenCComment(stream, state); } else { return ["operator", "operator"]; } }, "@": function(stream) { if (stream.eat("{")) return [null, "interpolation"]; if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i, false)) return false; stream.eatWhile(/[\w\\\-]/); if (stream.match(/^\s*:/, false)) return ["variable-2", "variable-definition"]; return ["variable-2", "variable"]; }, "&": function() { return ["atom", "atom"]; } }, name: "css", helperType: "less" }); CodeMirror.defineMIME("text/x-gss", { documentTypes: documentTypes, mediaTypes: mediaTypes, mediaFeatures: mediaFeatures, propertyKeywords: propertyKeywords, nonStandardPropertyKeywords: nonStandardPropertyKeywords, fontProperties: fontProperties, counterDescriptors: counterDescriptors, colorKeywords: colorKeywords, valueKeywords: valueKeywords, supportsAtComponent: true, tokenHooks: { "/": function(stream, state) { if (!stream.eat("*")) return false; state.tokenize = tokenCComment; return tokenCComment(stream, state); } }, name: "css", helperType: "gss" }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/mode/go.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("go", function(config) { var indentUnit = config.indentUnit; var keywords = { "break":true, "case":true, "chan":true, "const":true, "continue":true, "default":true, "defer":true, "else":true, "fallthrough":true, "for":true, "func":true, "go":true, "goto":true, "if":true, "import":true, "interface":true, "map":true, "package":true, "range":true, "return":true, "select":true, "struct":true, "switch":true, "type":true, "var":true, "bool":true, "byte":true, "complex64":true, "complex128":true, "float32":true, "float64":true, "int8":true, "int16":true, "int32":true, "int64":true, "string":true, "uint8":true, "uint16":true, "uint32":true, "uint64":true, "int":true, "uint":true, "uintptr":true, "error": true, "rune":true }; var atoms = { "true":true, "false":true, "iota":true, "nil":true, "append":true, "cap":true, "close":true, "complex":true, "copy":true, "delete":true, "imag":true, "len":true, "make":true, "new":true, "panic":true, "print":true, "println":true, "real":true, "recover":true }; var isOperatorChar = /[+\-*&^%:=<>!|\/]/; var curPunc; function tokenBase(stream, state) { var ch = stream.next(); if (ch == '"' || ch == "'" || ch == "`") { state.tokenize = tokenString(ch); return state.tokenize(stream, state); } if (/[\d\.]/.test(ch)) { if (ch == ".") { stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/); } else if (ch == "0") { stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/); } else { stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/); } return "number"; } if (/[\[\]{}\(\),;\:\.]/.test(ch)) { curPunc = ch; return null; } if (ch == "/") { if (stream.eat("*")) { state.tokenize = tokenComment; return tokenComment(stream, state); } if (stream.eat("/")) { stream.skipToEnd(); return "comment"; } } if (isOperatorChar.test(ch)) { stream.eatWhile(isOperatorChar); return "operator"; } stream.eatWhile(/[\w\$_\xa1-\uffff]/); var cur = stream.current(); if (keywords.propertyIsEnumerable(cur)) { if (cur == "case" || cur == "default") curPunc = "case"; return "keyword"; } if (atoms.propertyIsEnumerable(cur)) return "atom"; return "variable"; } function tokenString(quote) { return function(stream, state) { var escaped = false, next, end = false; while ((next = stream.next()) != null) { if (next == quote && !escaped) {end = true; break;} escaped = !escaped && quote != "`" && next == "\\"; } if (end || !(escaped || quote == "`")) state.tokenize = tokenBase; return "string"; }; } function tokenComment(stream, state) { var maybeEnd = false, ch; while (ch = stream.next()) { if (ch == "/" && maybeEnd) { state.tokenize = tokenBase; break; } maybeEnd = (ch == "*"); } return "comment"; } function Context(indented, column, type, align, prev) { this.indented = indented; this.column = column; this.type = type; this.align = align; this.prev = prev; } function pushContext(state, col, type) { return state.context = new Context(state.indented, col, type, null, state.context); } function popContext(state) { if (!state.context.prev) return; var t = state.context.type; if (t == ")" || t == "]" || t == "}") state.indented = state.context.indented; return state.context = state.context.prev; } // Interface return { startState: function(basecolumn) { return { tokenize: null, context: new Context((basecolumn || 0) - indentUnit, 0, "top", false), indented: 0, startOfLine: true }; }, token: function(stream, state) { var ctx = state.context; if (stream.sol()) { if (ctx.align == null) ctx.align = false; state.indented = stream.indentation(); state.startOfLine = true; if (ctx.type == "case") ctx.type = "}"; } if (stream.eatSpace()) return null; curPunc = null; var style = (state.tokenize || tokenBase)(stream, state); if (style == "comment") return style; if (ctx.align == null) ctx.align = true; if (curPunc == "{") pushContext(state, stream.column(), "}"); else if (curPunc == "[") pushContext(state, stream.column(), "]"); else if (curPunc == "(") pushContext(state, stream.column(), ")"); else if (curPunc == "case") ctx.type = "case"; else if (curPunc == "}" && ctx.type == "}") popContext(state); else if (curPunc == ctx.type) popContext(state); state.startOfLine = false; return style; }, indent: function(state, textAfter) { if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass; var ctx = state.context, firstChar = textAfter && textAfter.charAt(0); if (ctx.type == "case" && /^(?:case|default)\b/.test(textAfter)) { state.context.type = "}"; return ctx.indented; } var closing = firstChar == ctx.type; if (ctx.align) return ctx.column + (closing ? 0 : 1); else return ctx.indented + (closing ? 0 : indentUnit); }, electricChars: "{}):", closeBrackets: "()[]{}''\"\"``", fold: "brace", blockCommentStart: "/*", blockCommentEnd: "*/", lineComment: "//" }; }); CodeMirror.defineMIME("text/x-go", "go"); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/mode/htmlembedded.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), require("../../addon/mode/multiplex")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../../addon/mode/multiplex"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("htmlembedded", function(config, parserConfig) { var closeComment = parserConfig.closeComment || "--%>" return CodeMirror.multiplexingMode(CodeMirror.getMode(config, "htmlmixed"), { open: parserConfig.openComment || "<%--", close: closeComment, delimStyle: "comment", mode: {token: function(stream) { stream.skipTo(closeComment) || stream.skipToEnd() return "comment" }} }, { open: parserConfig.open || parserConfig.scriptStartRegex || "<%", close: parserConfig.close || parserConfig.scriptEndRegex || "%>", mode: CodeMirror.getMode(config, parserConfig.scriptingModeSpec) }); }, "htmlmixed"); CodeMirror.defineMIME("application/x-ejs", {name: "htmlembedded", scriptingModeSpec:"javascript"}); CodeMirror.defineMIME("application/x-aspx", {name: "htmlembedded", scriptingModeSpec:"text/x-csharp"}); CodeMirror.defineMIME("application/x-jsp", {name: "htmlembedded", scriptingModeSpec:"text/x-java"}); CodeMirror.defineMIME("application/x-erb", {name: "htmlembedded", scriptingModeSpec:"ruby"}); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/mode/htmlmixed.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"), require("../css/css")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var defaultTags = { script: [ ["lang", /(javascript|babel)/i, "javascript"], ["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i, "javascript"], ["type", /./, "text/plain"], [null, null, "javascript"] ], style: [ ["lang", /^css$/i, "css"], ["type", /^(text\/)?(x-)?(stylesheet|css)$/i, "css"], ["type", /./, "text/plain"], [null, null, "css"] ] }; function maybeBackup(stream, pat, style) { var cur = stream.current(), close = cur.search(pat); if (close > -1) { stream.backUp(cur.length - close); } else if (cur.match(/<\/?$/)) { stream.backUp(cur.length); if (!stream.match(pat, false)) stream.match(cur); } return style; } var attrRegexpCache = {}; function getAttrRegexp(attr) { var regexp = attrRegexpCache[attr]; if (regexp) return regexp; return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*"); } function getAttrValue(text, attr) { var match = text.match(getAttrRegexp(attr)) return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : "" } function getTagRegexp(tagName, anchored) { return new RegExp((anchored ? "^" : "") + "<\/\s*" + tagName + "\s*>", "i"); } function addTags(from, to) { for (var tag in from) { var dest = to[tag] || (to[tag] = []); var source = from[tag]; for (var i = source.length - 1; i >= 0; i--) dest.unshift(source[i]) } } function findMatchingMode(tagInfo, tagText) { for (var i = 0; i < tagInfo.length; i++) { var spec = tagInfo[i]; if (!spec[0] || spec[1].test(getAttrValue(tagText, spec[0]))) return spec[2]; } } CodeMirror.defineMode("htmlmixed", function (config, parserConfig) { var htmlMode = CodeMirror.getMode(config, { name: "xml", htmlMode: true, multilineTagIndentFactor: parserConfig.multilineTagIndentFactor, multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag }); var tags = {}; var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes; addTags(defaultTags, tags); if (configTags) addTags(configTags, tags); if (configScript) for (var i = configScript.length - 1; i >= 0; i--) tags.script.unshift(["type", configScript[i].matches, configScript[i].mode]) function html(stream, state) { var style = htmlMode.token(stream, state.htmlState), tag = /\btag\b/.test(style), tagName if (tag && !/[<>\s\/]/.test(stream.current()) && (tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase()) && tags.hasOwnProperty(tagName)) { state.inTag = tagName + " " } else if (state.inTag && tag && />$/.test(stream.current())) { var inTag = /^([\S]+) (.*)/.exec(state.inTag) state.inTag = null var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2]) var mode = CodeMirror.getMode(config, modeSpec) var endTagA = getTagRegexp(inTag[1], true), endTag = getTagRegexp(inTag[1], false); state.token = function (stream, state) { if (stream.match(endTagA, false)) { state.token = html; state.localState = state.localMode = null; return null; } return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState)); }; state.localMode = mode; state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, "", "")); } else if (state.inTag) { state.inTag += stream.current() if (stream.eol()) state.inTag += " " } return style; }; return { startState: function () { var state = CodeMirror.startState(htmlMode); return {token: html, inTag: null, localMode: null, localState: null, htmlState: state}; }, copyState: function (state) { var local; if (state.localState) { local = CodeMirror.copyState(state.localMode, state.localState); } return {token: state.token, inTag: state.inTag, localMode: state.localMode, localState: local, htmlState: CodeMirror.copyState(htmlMode, state.htmlState)}; }, token: function (stream, state) { return state.token(stream, state); }, indent: function (state, textAfter, line) { if (!state.localMode || /^\s*<\//.test(textAfter)) return htmlMode.indent(state.htmlState, textAfter, line); else if (state.localMode.indent) return state.localMode.indent(state.localState, textAfter, line); else return CodeMirror.Pass; }, innerMode: function (state) { return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode}; } }; }, "xml", "javascript", "css"); CodeMirror.defineMIME("text/html", "htmlmixed"); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/mode/javascript.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("javascript", function(config, parserConfig) { var indentUnit = config.indentUnit; var statementIndent = parserConfig.statementIndent; var jsonldMode = parserConfig.jsonld; var jsonMode = parserConfig.json || jsonldMode; var isTS = parserConfig.typescript; var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/; // Tokenizer var keywords = function(){ function kw(type) {return {type: type, style: "keyword"};} var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d"); var operator = kw("operator"), atom = {type: "atom", style: "atom"}; return { "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B, "return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C, "debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"), "function": kw("function"), "catch": kw("catch"), "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"), "in": operator, "typeof": operator, "instanceof": operator, "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom, "this": kw("this"), "class": kw("class"), "super": kw("atom"), "yield": C, "export": kw("export"), "import": kw("import"), "extends": C, "await": C }; }(); var isOperatorChar = /[+\-*&%=<>!?|~^@]/; var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/; function readRegexp(stream) { var escaped = false, next, inSet = false; while ((next = stream.next()) != null) { if (!escaped) { if (next == "/" && !inSet) return; if (next == "[") inSet = true; else if (inSet && next == "]") inSet = false; } escaped = !escaped && next == "\\"; } } // Used as scratch variables to communicate multiple values without // consing up tons of objects. var type, content; function ret(tp, style, cont) { type = tp; content = cont; return style; } function tokenBase(stream, state) { var ch = stream.next(); if (ch == '"' || ch == "'") { state.tokenize = tokenString(ch); return state.tokenize(stream, state); } else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) { return ret("number", "number"); } else if (ch == "." && stream.match("..")) { return ret("spread", "meta"); } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) { return ret(ch); } else if (ch == "=" && stream.eat(">")) { return ret("=>", "operator"); } else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) { return ret("number", "number"); } else if (/\d/.test(ch)) { stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/); return ret("number", "number"); } else if (ch == "/") { if (stream.eat("*")) { state.tokenize = tokenComment; return tokenComment(stream, state); } else if (stream.eat("/")) { stream.skipToEnd(); return ret("comment", "comment"); } else if (expressionAllowed(stream, state, 1)) { readRegexp(stream); stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/); return ret("regexp", "string-2"); } else { stream.eat("="); return ret("operator", "operator", stream.current()); } } else if (ch == "`") { state.tokenize = tokenQuasi; return tokenQuasi(stream, state); } else if (ch == "#" && stream.peek() == "!") { stream.skipToEnd(); return ret("meta", "meta"); } else if (ch == "#" && stream.eatWhile(wordRE)) { return ret("variable", "property") } else if (ch == "<" && stream.match("!--") || (ch == "-" && stream.match("->") && !/\S/.test(stream.string.slice(0, stream.start)))) { stream.skipToEnd() return ret("comment", "comment") } else if (isOperatorChar.test(ch)) { if (ch != ">" || !state.lexical || state.lexical.type != ">") { if (stream.eat("=")) { if (ch == "!" || ch == "=") stream.eat("=") } else if (/[<>*+\-]/.test(ch)) { stream.eat(ch) if (ch == ">") stream.eat(ch) } } if (ch == "?" && stream.eat(".")) return ret(".") return ret("operator", "operator", stream.current()); } else if (wordRE.test(ch)) { stream.eatWhile(wordRE); var word = stream.current() if (state.lastType != ".") { if (keywords.propertyIsEnumerable(word)) { var kw = keywords[word] return ret(kw.type, kw.style, word) } if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false)) return ret("async", "keyword", word) } return ret("variable", "variable", word) } } function tokenString(quote) { return function(stream, state) { var escaped = false, next; if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){ state.tokenize = tokenBase; return ret("jsonld-keyword", "meta"); } while ((next = stream.next()) != null) { if (next == quote && !escaped) break; escaped = !escaped && next == "\\"; } if (!escaped) state.tokenize = tokenBase; return ret("string", "string"); }; } function tokenComment(stream, state) { var maybeEnd = false, ch; while (ch = stream.next()) { if (ch == "/" && maybeEnd) { state.tokenize = tokenBase; break; } maybeEnd = (ch == "*"); } return ret("comment", "comment"); } function tokenQuasi(stream, state) { var escaped = false, next; while ((next = stream.next()) != null) { if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) { state.tokenize = tokenBase; break; } escaped = !escaped && next == "\\"; } return ret("quasi", "string-2", stream.current()); } var brackets = "([{}])"; // This is a crude lookahead trick to try and notice that we're // parsing the argument patterns for a fat-arrow function before we // actually hit the arrow token. It only works if the arrow is on // the same line as the arguments and there's no strange noise // (comments) in between. Fallback is to only notice when we hit the // arrow, and not declare the arguments as locals for the arrow // body. function findFatArrow(stream, state) { if (state.fatArrowAt) state.fatArrowAt = null; var arrow = stream.string.indexOf("=>", stream.start); if (arrow < 0) return; if (isTS) { // Try to skip TypeScript return type declarations after the arguments var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow)) if (m) arrow = m.index } var depth = 0, sawSomething = false; for (var pos = arrow - 1; pos >= 0; --pos) { var ch = stream.string.charAt(pos); var bracket = brackets.indexOf(ch); if (bracket >= 0 && bracket < 3) { if (!depth) { ++pos; break; } if (--depth == 0) { if (ch == "(") sawSomething = true; break; } } else if (bracket >= 3 && bracket < 6) { ++depth; } else if (wordRE.test(ch)) { sawSomething = true; } else if (/["'\/`]/.test(ch)) { for (;; --pos) { if (pos == 0) return var next = stream.string.charAt(pos - 1) if (next == ch && stream.string.charAt(pos - 2) != "\\") { pos--; break } } } else if (sawSomething && !depth) { ++pos; break; } } if (sawSomething && !depth) state.fatArrowAt = pos; } // Parser var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true}; function JSLexical(indented, column, type, align, prev, info) { this.indented = indented; this.column = column; this.type = type; this.prev = prev; this.info = info; if (align != null) this.align = align; } function inScope(state, varname) { for (var v = state.localVars; v; v = v.next) if (v.name == varname) return true; for (var cx = state.context; cx; cx = cx.prev) { for (var v = cx.vars; v; v = v.next) if (v.name == varname) return true; } } function parseJS(state, style, type, content, stream) { var cc = state.cc; // Communicate our context to the combinators. // (Less wasteful than consing up a hundred closures on every call.) cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style; if (!state.lexical.hasOwnProperty("align")) state.lexical.align = true; while(true) { var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement; if (combinator(type, content)) { while(cc.length && cc[cc.length - 1].lex) cc.pop()(); if (cx.marked) return cx.marked; if (type == "variable" && inScope(state, content)) return "variable-2"; return style; } } } // Combinator utils var cx = {state: null, column: null, marked: null, cc: null}; function pass() { for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]); } function cont() { pass.apply(null, arguments); return true; } function inList(name, list) { for (var v = list; v; v = v.next) if (v.name == name) return true return false; } function register(varname) { var state = cx.state; cx.marked = "def"; if (state.context) { if (state.lexical.info == "var" && state.context && state.context.block) { // FIXME function decls are also not block scoped var newContext = registerVarScoped(varname, state.context) if (newContext != null) { state.context = newContext return } } else if (!inList(varname, state.localVars)) { state.localVars = new Var(varname, state.localVars) return } } // Fall through means this is global if (parserConfig.globalVars && !inList(varname, state.globalVars)) state.globalVars = new Var(varname, state.globalVars) } function registerVarScoped(varname, context) { if (!context) { return null } else if (context.block) { var inner = registerVarScoped(varname, context.prev) if (!inner) return null if (inner == context.prev) return context return new Context(inner, context.vars, true) } else if (inList(varname, context.vars)) { return context } else { return new Context(context.prev, new Var(varname, context.vars), false) } } function isModifier(name) { return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly" } // Combinators function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block } function Var(name, next) { this.name = name; this.next = next } var defaultVars = new Var("this", new Var("arguments", null)) function pushcontext() { cx.state.context = new Context(cx.state.context, cx.state.localVars, false) cx.state.localVars = defaultVars } function pushblockcontext() { cx.state.context = new Context(cx.state.context, cx.state.localVars, true) cx.state.localVars = null } function popcontext() { cx.state.localVars = cx.state.context.vars cx.state.context = cx.state.context.prev } popcontext.lex = true function pushlex(type, info) { var result = function() { var state = cx.state, indent = state.indented; if (state.lexical.type == "stat") indent = state.lexical.indented; else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev) indent = outer.indented; state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info); }; result.lex = true; return result; } function poplex() { var state = cx.state; if (state.lexical.prev) { if (state.lexical.type == ")") state.indented = state.lexical.indented; state.lexical = state.lexical.prev; } } poplex.lex = true; function expect(wanted) { function exp(type) { if (type == wanted) return cont(); else if (wanted == ";" || type == "}" || type == ")" || type == "]") return pass(); else return cont(exp); }; return exp; } function statement(type, value) { if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex); if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex); if (type == "keyword b") return cont(pushlex("form"), statement, poplex); if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex); if (type == "debugger") return cont(expect(";")); if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext); if (type == ";") return cont(); if (type == "if") { if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex) cx.state.cc.pop()(); return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse); } if (type == "function") return cont(functiondef); if (type == "for") return cont(pushlex("form"), forspec, statement, poplex); if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword" return cont(pushlex("form", type == "class" ? type : value), className, poplex) } if (type == "variable") { if (isTS && value == "declare") { cx.marked = "keyword" return cont(statement) } else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) { cx.marked = "keyword" if (value == "enum") return cont(enumdef); else if (value == "type") return cont(typename, expect("operator"), typeexpr, expect(";")); else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex) } else if (isTS && value == "namespace") { cx.marked = "keyword" return cont(pushlex("form"), expression, statement, poplex) } else if (isTS && value == "abstract") { cx.marked = "keyword" return cont(statement) } else { return cont(pushlex("stat"), maybelabel); } } if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext, block, poplex, poplex, popcontext); if (type == "case") return cont(expression, expect(":")); if (type == "default") return cont(expect(":")); if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext); if (type == "export") return cont(pushlex("stat"), afterExport, poplex); if (type == "import") return cont(pushlex("stat"), afterImport, poplex); if (type == "async") return cont(statement) if (value == "@") return cont(expression, statement) return pass(pushlex("stat"), expression, expect(";"), poplex); } function maybeCatchBinding(type) { if (type == "(") return cont(funarg, expect(")")) } function expression(type, value) { return expressionInner(type, value, false); } function expressionNoComma(type, value) { return expressionInner(type, value, true); } function parenExpr(type) { if (type != "(") return pass() return cont(pushlex(")"), maybeexpression, expect(")"), poplex) } function expressionInner(type, value, noComma) { if (cx.state.fatArrowAt == cx.stream.start) { var body = noComma ? arrowBodyNoComma : arrowBody; if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext); else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext); } var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma; if (atomicTypes.hasOwnProperty(type)) return cont(maybeop); if (type == "function") return cont(functiondef, maybeop); if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); } if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression); if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop); if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression); if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop); if (type == "{") return contCommasep(objprop, "}", null, maybeop); if (type == "quasi") return pass(quasi, maybeop); if (type == "new") return cont(maybeTarget(noComma)); if (type == "import") return cont(expression); return cont(); } function maybeexpression(type) { if (type.match(/[;\}\)\],]/)) return pass(); return pass(expression); } function maybeoperatorComma(type, value) { if (type == ",") return cont(maybeexpression); return maybeoperatorNoComma(type, value, false); } function maybeoperatorNoComma(type, value, noComma) { var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma; var expr = noComma == false ? expression : expressionNoComma; if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext); if (type == "operator") { if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me); if (isTS && value == "<" && cx.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/, false)) return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me); if (value == "?") return cont(expression, expect(":"), expr); return cont(expr); } if (type == "quasi") { return pass(quasi, me); } if (type == ";") return; if (type == "(") return contCommasep(expressionNoComma, ")", "call", me); if (type == ".") return cont(property, me); if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me); if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) } if (type == "regexp") { cx.state.lastType = cx.marked = "operator" cx.stream.backUp(cx.stream.pos - cx.stream.start - 1) return cont(expr) } } function quasi(type, value) { if (type != "quasi") return pass(); if (value.slice(value.length - 2) != "${") return cont(quasi); return cont(expression, continueQuasi); } function continueQuasi(type) { if (type == "}") { cx.marked = "string-2"; cx.state.tokenize = tokenQuasi; return cont(quasi); } } function arrowBody(type) { findFatArrow(cx.stream, cx.state); return pass(type == "{" ? statement : expression); } function arrowBodyNoComma(type) { findFatArrow(cx.stream, cx.state); return pass(type == "{" ? statement : expressionNoComma); } function maybeTarget(noComma) { return function(type) { if (type == ".") return cont(noComma ? targetNoComma : target); else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma) else return pass(noComma ? expressionNoComma : expression); }; } function target(_, value) { if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); } } function targetNoComma(_, value) { if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); } } function maybelabel(type) { if (type == ":") return cont(poplex, statement); return pass(maybeoperatorComma, expect(";"), poplex); } function property(type) { if (type == "variable") {cx.marked = "property"; return cont();} } function objprop(type, value) { if (type == "async") { cx.marked = "property"; return cont(objprop); } else if (type == "variable" || cx.style == "keyword") { cx.marked = "property"; if (value == "get" || value == "set") return cont(getterSetter); var m // Work around fat-arrow-detection complication for detecting typescript typed arrow params if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false))) cx.state.fatArrowAt = cx.stream.pos + m[0].length return cont(afterprop); } else if (type == "number" || type == "string") { cx.marked = jsonldMode ? "property" : (cx.style + " property"); return cont(afterprop); } else if (type == "jsonld-keyword") { return cont(afterprop); } else if (isTS && isModifier(value)) { cx.marked = "keyword" return cont(objprop) } else if (type == "[") { return cont(expression, maybetype, expect("]"), afterprop); } else if (type == "spread") { return cont(expressionNoComma, afterprop); } else if (value == "*") { cx.marked = "keyword"; return cont(objprop); } else if (type == ":") { return pass(afterprop) } } function getterSetter(type) { if (type != "variable") return pass(afterprop); cx.marked = "property"; return cont(functiondef); } function afterprop(type) { if (type == ":") return cont(expressionNoComma); if (type == "(") return pass(functiondef); } function commasep(what, end, sep) { function proceed(type, value) { if (sep ? sep.indexOf(type) > -1 : type == ",") { var lex = cx.state.lexical; if (lex.info == "call") lex.pos = (lex.pos || 0) + 1; return cont(function(type, value) { if (type == end || value == end) return pass() return pass(what) }, proceed); } if (type == end || value == end) return cont(); if (sep && sep.indexOf(";") > -1) return pass(what) return cont(expect(end)); } return function(type, value) { if (type == end || value == end) return cont(); return pass(what, proceed); }; } function contCommasep(what, end, info) { for (var i = 3; i < arguments.length; i++) cx.cc.push(arguments[i]); return cont(pushlex(end, info), commasep(what, end), poplex); } function block(type) { if (type == "}") return cont(); return pass(statement, block); } function maybetype(type, value) { if (isTS) { if (type == ":") return cont(typeexpr); if (value == "?") return cont(maybetype); } } function maybetypeOrIn(type, value) { if (isTS && (type == ":" || value == "in")) return cont(typeexpr) } function mayberettype(type) { if (isTS && type == ":") { if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr) else return cont(typeexpr) } } function isKW(_, value) { if (value == "is") { cx.marked = "keyword" return cont() } } function typeexpr(type, value) { if (value == "keyof" || value == "typeof" || value == "infer") { cx.marked = "keyword" return cont(value == "typeof" ? expressionNoComma : typeexpr) } if (type == "variable" || value == "void") { cx.marked = "type" return cont(afterType) } if (value == "|" || value == "&") return cont(typeexpr) if (type == "string" || type == "number" || type == "atom") return cont(afterType); if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType) if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType) if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType) if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr) } function maybeReturnType(type) { if (type == "=>") return cont(typeexpr) } function typeprop(type, value) { if (type == "variable" || cx.style == "keyword") { cx.marked = "property" return cont(typeprop) } else if (value == "?" || type == "number" || type == "string") { return cont(typeprop) } else if (type == ":") { return cont(typeexpr) } else if (type == "[") { return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop) } else if (type == "(") { return pass(functiondecl, typeprop) } } function typearg(type, value) { if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg) if (type == ":") return cont(typeexpr) if (type == "spread") return cont(typearg) return pass(typeexpr) } function afterType(type, value) { if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) if (value == "|" || type == "." || value == "&") return cont(typeexpr) if (type == "[") return cont(typeexpr, expect("]"), afterType) if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) } if (value == "?") return cont(typeexpr, expect(":"), typeexpr) } function maybeTypeArgs(_, value) { if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) } function typeparam() { return pass(typeexpr, maybeTypeDefault) } function maybeTypeDefault(_, value) { if (value == "=") return cont(typeexpr) } function vardef(_, value) { if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)} return pass(pattern, maybetype, maybeAssign, vardefCont); } function pattern(type, value) { if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) } if (type == "variable") { register(value); return cont(); } if (type == "spread") return cont(pattern); if (type == "[") return contCommasep(eltpattern, "]"); if (type == "{") return contCommasep(proppattern, "}"); } function proppattern(type, value) { if (type == "variable" && !cx.stream.match(/^\s*:/, false)) { register(value); return cont(maybeAssign); } if (type == "variable") cx.marked = "property"; if (type == "spread") return cont(pattern); if (type == "}") return pass(); if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern); return cont(expect(":"), pattern, maybeAssign); } function eltpattern() { return pass(pattern, maybeAssign) } function maybeAssign(_type, value) { if (value == "=") return cont(expressionNoComma); } function vardefCont(type) { if (type == ",") return cont(vardef); } function maybeelse(type, value) { if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex); } function forspec(type, value) { if (value == "await") return cont(forspec); if (type == "(") return cont(pushlex(")"), forspec1, poplex); } function forspec1(type) { if (type == "var") return cont(vardef, forspec2); if (type == "variable") return cont(forspec2); return pass(forspec2) } function forspec2(type, value) { if (type == ")") return cont() if (type == ";") return cont(forspec2) if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression, forspec2) } return pass(expression, forspec2) } function functiondef(type, value) { if (value == "*") {cx.marked = "keyword"; return cont(functiondef);} if (type == "variable") {register(value); return cont(functiondef);} if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext); if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef) } function functiondecl(type, value) { if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);} if (type == "variable") {register(value); return cont(functiondecl);} if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext); if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl) } function typename(type, value) { if (type == "keyword" || type == "variable") { cx.marked = "type" return cont(typename) } else if (value == "<") { return cont(pushlex(">"), commasep(typeparam, ">"), poplex) } } function funarg(type, value) { if (value == "@") cont(expression, funarg) if (type == "spread") return cont(funarg); if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); } if (isTS && type == "this") return cont(maybetype, maybeAssign) return pass(pattern, maybetype, maybeAssign); } function classExpression(type, value) { // Class expressions may have an optional name. if (type == "variable") return className(type, value); return classNameAfter(type, value); } function className(type, value) { if (type == "variable") {register(value); return cont(classNameAfter);} } function classNameAfter(type, value) { if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter) if (value == "extends" || value == "implements" || (isTS && type == ",")) { if (value == "implements") cx.marked = "keyword"; return cont(isTS ? typeexpr : expression, classNameAfter); } if (type == "{") return cont(pushlex("}"), classBody, poplex); } function classBody(type, value) { if (type == "async" || (type == "variable" && (value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) && cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) { cx.marked = "keyword"; return cont(classBody); } if (type == "variable" || cx.style == "keyword") { cx.marked = "property"; return cont(classfield, classBody); } if (type == "number" || type == "string") return cont(classfield, classBody); if (type == "[") return cont(expression, maybetype, expect("]"), classfield, classBody) if (value == "*") { cx.marked = "keyword"; return cont(classBody); } if (isTS && type == "(") return pass(functiondecl, classBody) if (type == ";" || type == ",") return cont(classBody); if (type == "}") return cont(); if (value == "@") return cont(expression, classBody) } function classfield(type, value) { if (value == "?") return cont(classfield) if (type == ":") return cont(typeexpr, maybeAssign) if (value == "=") return cont(expressionNoComma) var context = cx.state.lexical.prev, isInterface = context && context.info == "interface" return pass(isInterface ? functiondecl : functiondef) } function afterExport(type, value) { if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); } if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); } if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";")); return pass(statement); } function exportField(type, value) { if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); } if (type == "variable") return pass(expressionNoComma, exportField); } function afterImport(type) { if (type == "string") return cont(); if (type == "(") return pass(expression); return pass(importSpec, maybeMoreImports, maybeFrom); } function importSpec(type, value) { if (type == "{") return contCommasep(importSpec, "}"); if (type == "variable") register(value); if (value == "*") cx.marked = "keyword"; return cont(maybeAs); } function maybeMoreImports(type) { if (type == ",") return cont(importSpec, maybeMoreImports) } function maybeAs(_type, value) { if (value == "as") { cx.marked = "keyword"; return cont(importSpec); } } function maybeFrom(_type, value) { if (value == "from") { cx.marked = "keyword"; return cont(expression); } } function arrayLiteral(type) { if (type == "]") return cont(); return pass(commasep(expressionNoComma, "]")); } function enumdef() { return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex) } function enummember() { return pass(pattern, maybeAssign); } function isContinuedStatement(state, textAfter) { return state.lastType == "operator" || state.lastType == "," || isOperatorChar.test(textAfter.charAt(0)) || /[,.]/.test(textAfter.charAt(0)); } function expressionAllowed(stream, state, backUp) { return state.tokenize == tokenBase && /^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) || (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0)))) } // Interface return { startState: function(basecolumn) { var state = { tokenize: tokenBase, lastType: "sof", cc: [], lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false), localVars: parserConfig.localVars, context: parserConfig.localVars && new Context(null, null, false), indented: basecolumn || 0 }; if (parserConfig.globalVars && typeof parserConfig.globalVars == "object") state.globalVars = parserConfig.globalVars; return state; }, token: function(stream, state) { if (stream.sol()) { if (!state.lexical.hasOwnProperty("align")) state.lexical.align = false; state.indented = stream.indentation(); findFatArrow(stream, state); } if (state.tokenize != tokenComment && stream.eatSpace()) return null; var style = state.tokenize(stream, state); if (type == "comment") return style; state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type; return parseJS(state, style, type, content, stream); }, indent: function(state, textAfter) { if (state.tokenize == tokenComment) return CodeMirror.Pass; if (state.tokenize != tokenBase) return 0; var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top // Kludge to prevent 'maybelse' from blocking lexical scope pops if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) { var c = state.cc[i]; if (c == poplex) lexical = lexical.prev; else if (c != maybeelse) break; } while ((lexical.type == "stat" || lexical.type == "form") && (firstChar == "}" || ((top = state.cc[state.cc.length - 1]) && (top == maybeoperatorComma || top == maybeoperatorNoComma) && !/^[,\.=+\-*:?[\(]/.test(textAfter)))) lexical = lexical.prev; if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat") lexical = lexical.prev; var type = lexical.type, closing = firstChar == type; if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0); else if (type == "form" && firstChar == "{") return lexical.indented; else if (type == "form") return lexical.indented + indentUnit; else if (type == "stat") return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0); else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false) return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit); else if (lexical.align) return lexical.column + (closing ? 0 : 1); else return lexical.indented + (closing ? 0 : indentUnit); }, electricInput: /^\s*(?:case .*?:|default:|\{|\})$/, blockCommentStart: jsonMode ? null : "/*", blockCommentEnd: jsonMode ? null : "*/", blockCommentContinue: jsonMode ? null : " * ", lineComment: jsonMode ? null : "//", fold: "brace", closeBrackets: "()[]{}''\"\"``", helperType: jsonMode ? "json" : "javascript", jsonldMode: jsonldMode, jsonMode: jsonMode, expressionAllowed: expressionAllowed, skipExpression: function(state) { var top = state.cc[state.cc.length - 1] if (top == expression || top == expressionNoComma) state.cc.pop() } }; }); CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/); CodeMirror.defineMIME("text/javascript", "javascript"); CodeMirror.defineMIME("text/ecmascript", "javascript"); CodeMirror.defineMIME("application/javascript", "javascript"); CodeMirror.defineMIME("application/x-javascript", "javascript"); CodeMirror.defineMIME("application/ecmascript", "javascript"); CodeMirror.defineMIME("application/json", {name: "javascript", json: true}); CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true}); CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true}); CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true }); CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/mode/markdown.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../xml/xml"), require("../meta")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../xml/xml", "../meta"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { var htmlMode = CodeMirror.getMode(cmCfg, "text/html"); var htmlModeMissing = htmlMode.name == "null" function getMode(name) { if (CodeMirror.findModeByName) { var found = CodeMirror.findModeByName(name); if (found) name = found.mime || found.mimes[0]; } var mode = CodeMirror.getMode(cmCfg, name); return mode.name == "null" ? null : mode; } // Should characters that affect highlighting be highlighted separate? // Does not include characters that will be output (such as `1.` and `-` for lists) if (modeCfg.highlightFormatting === undefined) modeCfg.highlightFormatting = false; // Maximum number of nested blockquotes. Set to 0 for infinite nesting. // Excess `>` will emit `error` token. if (modeCfg.maxBlockquoteDepth === undefined) modeCfg.maxBlockquoteDepth = 0; // Turn on task lists? ("- [ ] " and "- [x] ") if (modeCfg.taskLists === undefined) modeCfg.taskLists = false; // Turn on strikethrough syntax if (modeCfg.strikethrough === undefined) modeCfg.strikethrough = false; if (modeCfg.emoji === undefined) modeCfg.emoji = false; if (modeCfg.fencedCodeBlockHighlighting === undefined) modeCfg.fencedCodeBlockHighlighting = true; if (modeCfg.fencedCodeBlockDefaultMode === undefined) modeCfg.fencedCodeBlockDefaultMode = 'text/plain'; if (modeCfg.xml === undefined) modeCfg.xml = true; // Allow token types to be overridden by user-provided token types. if (modeCfg.tokenTypeOverrides === undefined) modeCfg.tokenTypeOverrides = {}; var tokenTypes = { header: "header", code: "comment", quote: "quote", list1: "variable-2", list2: "variable-3", list3: "keyword", hr: "hr", image: "image", imageAltText: "image-alt-text", imageMarker: "image-marker", formatting: "formatting", linkInline: "link", linkEmail: "link", linkText: "link", linkHref: "string", em: "em", strong: "strong", strikethrough: "strikethrough", emoji: "builtin" }; for (var tokenType in tokenTypes) { if (tokenTypes.hasOwnProperty(tokenType) && modeCfg.tokenTypeOverrides[tokenType]) { tokenTypes[tokenType] = modeCfg.tokenTypeOverrides[tokenType]; } } var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/ , listRE = /^(?:[*\-+]|^[0-9]+([.)]))\s+/ , taskListRE = /^\[(x| )\](?=\s)/i // Must follow listRE , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/ , setextHeaderRE = /^ {0,3}(?:\={1,}|-{2,})\s*$/ , textRE = /^[^#!\[\]*_\\<>` "'(~:]+/ , fencedCodeRE = /^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/ , linkDefRE = /^\s*\[[^\]]+?\]:.*$/ // naive link-definition , punctuation = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/ , expandedTab = " " // CommonMark specifies tab as 4 spaces function switchInline(stream, state, f) { state.f = state.inline = f; return f(stream, state); } function switchBlock(stream, state, f) { state.f = state.block = f; return f(stream, state); } function lineIsEmpty(line) { return !line || !/\S/.test(line.string) } // Blocks function blankLine(state) { // Reset linkTitle state state.linkTitle = false; state.linkHref = false; state.linkText = false; // Reset EM state state.em = false; // Reset STRONG state state.strong = false; // Reset strikethrough state state.strikethrough = false; // Reset state.quote state.quote = 0; // Reset state.indentedCode state.indentedCode = false; if (state.f == htmlBlock) { var exit = htmlModeMissing if (!exit) { var inner = CodeMirror.innerMode(htmlMode, state.htmlState) exit = inner.mode.name == "xml" && inner.state.tagStart === null && (!inner.state.context && inner.state.tokenize.isInText) } if (exit) { state.f = inlineNormal; state.block = blockNormal; state.htmlState = null; } } // Reset state.trailingSpace state.trailingSpace = 0; state.trailingSpaceNewLine = false; // Mark this line as blank state.prevLine = state.thisLine state.thisLine = {stream: null} return null; } function blockNormal(stream, state) { var firstTokenOnLine = stream.column() === state.indentation; var prevLineLineIsEmpty = lineIsEmpty(state.prevLine.stream); var prevLineIsIndentedCode = state.indentedCode; var prevLineIsHr = state.prevLine.hr; var prevLineIsList = state.list !== false; var maxNonCodeIndentation = (state.listStack[state.listStack.length - 1] || 0) + 3; state.indentedCode = false; var lineIndentation = state.indentation; // compute once per line (on first token) if (state.indentationDiff === null) { state.indentationDiff = state.indentation; if (prevLineIsList) { state.list = null; // While this list item's marker's indentation is less than the deepest // list item's content's indentation,pop the deepest list item // indentation off the stack, and update block indentation state while (lineIndentation < state.listStack[state.listStack.length - 1]) { state.listStack.pop(); if (state.listStack.length) { state.indentation = state.listStack[state.listStack.length - 1]; // less than the first list's indent -> the line is no longer a list } else { state.list = false; } } if (state.list !== false) { state.indentationDiff = lineIndentation - state.listStack[state.listStack.length - 1] } } } // not comprehensive (currently only for setext detection purposes) var allowsInlineContinuation = ( !prevLineLineIsEmpty && !prevLineIsHr && !state.prevLine.header && (!prevLineIsList || !prevLineIsIndentedCode) && !state.prevLine.fencedCodeEnd ); var isHr = (state.list === false || prevLineIsHr || prevLineLineIsEmpty) && state.indentation <= maxNonCodeIndentation && stream.match(hrRE); var match = null; if (state.indentationDiff >= 4 && (prevLineIsIndentedCode || state.prevLine.fencedCodeEnd || state.prevLine.header || prevLineLineIsEmpty)) { stream.skipToEnd(); state.indentedCode = true; return tokenTypes.code; } else if (stream.eatSpace()) { return null; } else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(atxHeaderRE)) && match[1].length <= 6) { state.quote = 0; state.header = match[1].length; state.thisLine.header = true; if (modeCfg.highlightFormatting) state.formatting = "header"; state.f = state.inline; return getType(state); } else if (state.indentation <= maxNonCodeIndentation && stream.eat('>')) { state.quote = firstTokenOnLine ? 1 : state.quote + 1; if (modeCfg.highlightFormatting) state.formatting = "quote"; stream.eatSpace(); return getType(state); } else if (!isHr && !state.setext && firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(listRE))) { var listType = match[1] ? "ol" : "ul"; state.indentation = lineIndentation + stream.current().length; state.list = true; state.quote = 0; // Add this list item's content's indentation to the stack state.listStack.push(state.indentation); // Reset inline styles which shouldn't propagate aross list items state.em = false; state.strong = false; state.code = false; state.strikethrough = false; if (modeCfg.taskLists && stream.match(taskListRE, false)) { state.taskList = true; } state.f = state.inline; if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType]; return getType(state); } else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(fencedCodeRE, true))) { state.quote = 0; state.fencedEndRE = new RegExp(match[1] + "+ *$"); // try switching mode state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2] || modeCfg.fencedCodeBlockDefaultMode ); if (state.localMode) state.localState = CodeMirror.startState(state.localMode); state.f = state.block = local; if (modeCfg.highlightFormatting) state.formatting = "code-block"; state.code = -1 return getType(state); // SETEXT has lowest block-scope precedence after HR, so check it after // the others (code, blockquote, list...) } else if ( // if setext set, indicates line after ---/=== state.setext || ( // line before ---/=== (!allowsInlineContinuation || !prevLineIsList) && !state.quote && state.list === false && !state.code && !isHr && !linkDefRE.test(stream.string) && (match = stream.lookAhead(1)) && (match = match.match(setextHeaderRE)) ) ) { if ( !state.setext ) { state.header = match[0].charAt(0) == '=' ? 1 : 2; state.setext = state.header; } else { state.header = state.setext; // has no effect on type so we can reset it now state.setext = 0; stream.skipToEnd(); if (modeCfg.highlightFormatting) state.formatting = "header"; } state.thisLine.header = true; state.f = state.inline; return getType(state); } else if (isHr) { stream.skipToEnd(); state.hr = true; state.thisLine.hr = true; return tokenTypes.hr; } else if (stream.peek() === '[') { return switchInline(stream, state, footnoteLink); } return switchInline(stream, state, state.inline); } function htmlBlock(stream, state) { var style = htmlMode.token(stream, state.htmlState); if (!htmlModeMissing) { var inner = CodeMirror.innerMode(htmlMode, state.htmlState) if ((inner.mode.name == "xml" && inner.state.tagStart === null && (!inner.state.context && inner.state.tokenize.isInText)) || (state.md_inside && stream.current().indexOf(">") > -1)) { state.f = inlineNormal; state.block = blockNormal; state.htmlState = null; } } return style; } function local(stream, state) { var currListInd = state.listStack[state.listStack.length - 1] || 0; var hasExitedList = state.indentation < currListInd; var maxFencedEndInd = currListInd + 3; if (state.fencedEndRE && state.indentation <= maxFencedEndInd && (hasExitedList || stream.match(state.fencedEndRE))) { if (modeCfg.highlightFormatting) state.formatting = "code-block"; var returnType; if (!hasExitedList) returnType = getType(state) state.localMode = state.localState = null; state.block = blockNormal; state.f = inlineNormal; state.fencedEndRE = null; state.code = 0 state.thisLine.fencedCodeEnd = true; if (hasExitedList) return switchBlock(stream, state, state.block); return returnType; } else if (state.localMode) { return state.localMode.token(stream, state.localState); } else { stream.skipToEnd(); return tokenTypes.code; } } // Inline function getType(state) { var styles = []; if (state.formatting) { styles.push(tokenTypes.formatting); if (typeof state.formatting === "string") state.formatting = [state.formatting]; for (var i = 0; i < state.formatting.length; i++) { styles.push(tokenTypes.formatting + "-" + state.formatting[i]); if (state.formatting[i] === "header") { styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.header); } // Add `formatting-quote` and `formatting-quote-#` for blockquotes // Add `error` instead if the maximum blockquote nesting depth is passed if (state.formatting[i] === "quote") { if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) { styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.quote); } else { styles.push("error"); } } } } if (state.taskOpen) { styles.push("meta"); return styles.length ? styles.join(' ') : null; } if (state.taskClosed) { styles.push("property"); return styles.length ? styles.join(' ') : null; } if (state.linkHref) { styles.push(tokenTypes.linkHref, "url"); } else { // Only apply inline styles to non-url text if (state.strong) { styles.push(tokenTypes.strong); } if (state.em) { styles.push(tokenTypes.em); } if (state.strikethrough) { styles.push(tokenTypes.strikethrough); } if (state.emoji) { styles.push(tokenTypes.emoji); } if (state.linkText) { styles.push(tokenTypes.linkText); } if (state.code) { styles.push(tokenTypes.code); } if (state.image) { styles.push(tokenTypes.image); } if (state.imageAltText) { styles.push(tokenTypes.imageAltText, "link"); } if (state.imageMarker) { styles.push(tokenTypes.imageMarker); } } if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); } if (state.quote) { styles.push(tokenTypes.quote); // Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) { styles.push(tokenTypes.quote + "-" + state.quote); } else { styles.push(tokenTypes.quote + "-" + modeCfg.maxBlockquoteDepth); } } if (state.list !== false) { var listMod = (state.listStack.length - 1) % 3; if (!listMod) { styles.push(tokenTypes.list1); } else if (listMod === 1) { styles.push(tokenTypes.list2); } else { styles.push(tokenTypes.list3); } } if (state.trailingSpaceNewLine) { styles.push("trailing-space-new-line"); } else if (state.trailingSpace) { styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b")); } return styles.length ? styles.join(' ') : null; } function handleText(stream, state) { if (stream.match(textRE, true)) { return getType(state); } return undefined; } function inlineNormal(stream, state) { var style = state.text(stream, state); if (typeof style !== 'undefined') return style; if (state.list) { // List marker (*, +, -, 1., etc) state.list = null; return getType(state); } if (state.taskList) { var taskOpen = stream.match(taskListRE, true)[1] === " "; if (taskOpen) state.taskOpen = true; else state.taskClosed = true; if (modeCfg.highlightFormatting) state.formatting = "task"; state.taskList = false; return getType(state); } state.taskOpen = false; state.taskClosed = false; if (state.header && stream.match(/^#+$/, true)) { if (modeCfg.highlightFormatting) state.formatting = "header"; return getType(state); } var ch = stream.next(); // Matches link titles present on next line if (state.linkTitle) { state.linkTitle = false; var matchCh = ch; if (ch === '(') { matchCh = ')'; } matchCh = (matchCh+'').replace(/([.?*+^\[\]\\(){}|-])/g, "\\$1"); var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh; if (stream.match(new RegExp(regex), true)) { return tokenTypes.linkHref; } } // If this block is changed, it may need to be updated in GFM mode if (ch === '`') { var previousFormatting = state.formatting; if (modeCfg.highlightFormatting) state.formatting = "code"; stream.eatWhile('`'); var count = stream.current().length if (state.code == 0 && (!state.quote || count == 1)) { state.code = count return getType(state) } else if (count == state.code) { // Must be exact var t = getType(state) state.code = 0 return t } else { state.formatting = previousFormatting return getType(state) } } else if (state.code) { return getType(state); } if (ch === '\\') { stream.next(); if (modeCfg.highlightFormatting) { var type = getType(state); var formattingEscape = tokenTypes.formatting + "-escape"; return type ? type + " " + formattingEscape : formattingEscape; } } if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) { state.imageMarker = true; state.image = true; if (modeCfg.highlightFormatting) state.formatting = "image"; return getType(state); } if (ch === '[' && state.imageMarker && stream.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/, false)) { state.imageMarker = false; state.imageAltText = true if (modeCfg.highlightFormatting) state.formatting = "image"; return getType(state); } if (ch === ']' && state.imageAltText) { if (modeCfg.highlightFormatting) state.formatting = "image"; var type = getType(state); state.imageAltText = false; state.image = false; state.inline = state.f = linkHref; return type; } if (ch === '[' && !state.image) { if (state.linkText && stream.match(/^.*?\]/)) return getType(state) state.linkText = true; if (modeCfg.highlightFormatting) state.formatting = "link"; return getType(state); } if (ch === ']' && state.linkText) { if (modeCfg.highlightFormatting) state.formatting = "link"; var type = getType(state); state.linkText = false; state.inline = state.f = stream.match(/\(.*?\)| ?\[.*?\]/, false) ? linkHref : inlineNormal return type; } if (ch === '<' && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, false)) { state.f = state.inline = linkInline; if (modeCfg.highlightFormatting) state.formatting = "link"; var type = getType(state); if (type){ type += " "; } else { type = ""; } return type + tokenTypes.linkInline; } if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) { state.f = state.inline = linkInline; if (modeCfg.highlightFormatting) state.formatting = "link"; var type = getType(state); if (type){ type += " "; } else { type = ""; } return type + tokenTypes.linkEmail; } if (modeCfg.xml && ch === '<' && stream.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i, false)) { var end = stream.string.indexOf(">", stream.pos); if (end != -1) { var atts = stream.string.substring(stream.start, end); if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) state.md_inside = true; } stream.backUp(1); state.htmlState = CodeMirror.startState(htmlMode); return switchBlock(stream, state, htmlBlock); } if (modeCfg.xml && ch === '<' && stream.match(/^\/\w*?>/)) { state.md_inside = false; return "tag"; } else if (ch === "*" || ch === "_") { var len = 1, before = stream.pos == 1 ? " " : stream.string.charAt(stream.pos - 2) while (len < 3 && stream.eat(ch)) len++ var after = stream.peek() || " " // See http://spec.commonmark.org/0.27/#emphasis-and-strong-emphasis var leftFlanking = !/\s/.test(after) && (!punctuation.test(after) || /\s/.test(before) || punctuation.test(before)) var rightFlanking = !/\s/.test(before) && (!punctuation.test(before) || /\s/.test(after) || punctuation.test(after)) var setEm = null, setStrong = null if (len % 2) { // Em if (!state.em && leftFlanking && (ch === "*" || !rightFlanking || punctuation.test(before))) setEm = true else if (state.em == ch && rightFlanking && (ch === "*" || !leftFlanking || punctuation.test(after))) setEm = false } if (len > 1) { // Strong if (!state.strong && leftFlanking && (ch === "*" || !rightFlanking || punctuation.test(before))) setStrong = true else if (state.strong == ch && rightFlanking && (ch === "*" || !leftFlanking || punctuation.test(after))) setStrong = false } if (setStrong != null || setEm != null) { if (modeCfg.highlightFormatting) state.formatting = setEm == null ? "strong" : setStrong == null ? "em" : "strong em" if (setEm === true) state.em = ch if (setStrong === true) state.strong = ch var t = getType(state) if (setEm === false) state.em = false if (setStrong === false) state.strong = false return t } } else if (ch === ' ') { if (stream.eat('*') || stream.eat('_')) { // Probably surrounded by spaces if (stream.peek() === ' ') { // Surrounded by spaces, ignore return getType(state); } else { // Not surrounded by spaces, back up pointer stream.backUp(1); } } } if (modeCfg.strikethrough) { if (ch === '~' && stream.eatWhile(ch)) { if (state.strikethrough) {// Remove strikethrough if (modeCfg.highlightFormatting) state.formatting = "strikethrough"; var t = getType(state); state.strikethrough = false; return t; } else if (stream.match(/^[^\s]/, false)) {// Add strikethrough state.strikethrough = true; if (modeCfg.highlightFormatting) state.formatting = "strikethrough"; return getType(state); } } else if (ch === ' ') { if (stream.match(/^~~/, true)) { // Probably surrounded by space if (stream.peek() === ' ') { // Surrounded by spaces, ignore return getType(state); } else { // Not surrounded by spaces, back up pointer stream.backUp(2); } } } } if (modeCfg.emoji && ch === ":" && stream.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)) { state.emoji = true; if (modeCfg.highlightFormatting) state.formatting = "emoji"; var retType = getType(state); state.emoji = false; return retType; } if (ch === ' ') { if (stream.match(/^ +$/, false)) { state.trailingSpace++; } else if (state.trailingSpace) { state.trailingSpaceNewLine = true; } } return getType(state); } function linkInline(stream, state) { var ch = stream.next(); if (ch === ">") { state.f = state.inline = inlineNormal; if (modeCfg.highlightFormatting) state.formatting = "link"; var type = getType(state); if (type){ type += " "; } else { type = ""; } return type + tokenTypes.linkInline; } stream.match(/^[^>]+/, true); return tokenTypes.linkInline; } function linkHref(stream, state) { // Check if space, and return NULL if so (to avoid marking the space) if(stream.eatSpace()){ return null; } var ch = stream.next(); if (ch === '(' || ch === '[') { state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]"); if (modeCfg.highlightFormatting) state.formatting = "link-string"; state.linkHref = true; return getType(state); } return 'error'; } var linkRE = { ")": /^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/, "]": /^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/ } function getLinkHrefInside(endChar) { return function(stream, state) { var ch = stream.next(); if (ch === endChar) { state.f = state.inline = inlineNormal; if (modeCfg.highlightFormatting) state.formatting = "link-string"; var returnState = getType(state); state.linkHref = false; return returnState; } stream.match(linkRE[endChar]) state.linkHref = true; return getType(state); }; } function footnoteLink(stream, state) { if (stream.match(/^([^\]\\]|\\.)*\]:/, false)) { state.f = footnoteLinkInside; stream.next(); // Consume [ if (modeCfg.highlightFormatting) state.formatting = "link"; state.linkText = true; return getType(state); } return switchInline(stream, state, inlineNormal); } function footnoteLinkInside(stream, state) { if (stream.match(/^\]:/, true)) { state.f = state.inline = footnoteUrl; if (modeCfg.highlightFormatting) state.formatting = "link"; var returnType = getType(state); state.linkText = false; return returnType; } stream.match(/^([^\]\\]|\\.)+/, true); return tokenTypes.linkText; } function footnoteUrl(stream, state) { // Check if space, and return NULL if so (to avoid marking the space) if(stream.eatSpace()){ return null; } // Match URL stream.match(/^[^\s]+/, true); // Check for link title if (stream.peek() === undefined) { // End of line, set flag to check next line state.linkTitle = true; } else { // More content on line, check if link title stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true); } state.f = state.inline = inlineNormal; return tokenTypes.linkHref + " url"; } var mode = { startState: function() { return { f: blockNormal, prevLine: {stream: null}, thisLine: {stream: null}, block: blockNormal, htmlState: null, indentation: 0, inline: inlineNormal, text: handleText, formatting: false, linkText: false, linkHref: false, linkTitle: false, code: 0, em: false, strong: false, header: 0, setext: 0, hr: false, taskList: false, list: false, listStack: [], quote: 0, trailingSpace: 0, trailingSpaceNewLine: false, strikethrough: false, emoji: false, fencedEndRE: null }; }, copyState: function(s) { return { f: s.f, prevLine: s.prevLine, thisLine: s.thisLine, block: s.block, htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState), indentation: s.indentation, localMode: s.localMode, localState: s.localMode ? CodeMirror.copyState(s.localMode, s.localState) : null, inline: s.inline, text: s.text, formatting: false, linkText: s.linkText, linkTitle: s.linkTitle, linkHref: s.linkHref, code: s.code, em: s.em, strong: s.strong, strikethrough: s.strikethrough, emoji: s.emoji, header: s.header, setext: s.setext, hr: s.hr, taskList: s.taskList, list: s.list, listStack: s.listStack.slice(0), quote: s.quote, indentedCode: s.indentedCode, trailingSpace: s.trailingSpace, trailingSpaceNewLine: s.trailingSpaceNewLine, md_inside: s.md_inside, fencedEndRE: s.fencedEndRE }; }, token: function(stream, state) { // Reset state.formatting state.formatting = false; if (stream != state.thisLine.stream) { state.header = 0; state.hr = false; if (stream.match(/^\s*$/, true)) { blankLine(state); return null; } state.prevLine = state.thisLine state.thisLine = {stream: stream} // Reset state.taskList state.taskList = false; // Reset state.trailingSpace state.trailingSpace = 0; state.trailingSpaceNewLine = false; if (!state.localState) { state.f = state.block; if (state.f != htmlBlock) { var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, expandedTab).length; state.indentation = indentation; state.indentationDiff = null; if (indentation > 0) return null; } } } return state.f(stream, state); }, innerMode: function(state) { if (state.block == htmlBlock) return {state: state.htmlState, mode: htmlMode}; if (state.localState) return {state: state.localState, mode: state.localMode}; return {state: state, mode: mode}; }, indent: function(state, textAfter, line) { if (state.block == htmlBlock && htmlMode.indent) return htmlMode.indent(state.htmlState, textAfter, line) if (state.localState && state.localMode.indent) return state.localMode.indent(state.localState, textAfter, line) return CodeMirror.Pass }, blankLine: blankLine, getType: getType, blockCommentStart: "", closeBrackets: "()[]{}''\"\"``", fold: "markdown" }; return mode; }, "xml"); CodeMirror.defineMIME("text/markdown", "markdown"); CodeMirror.defineMIME("text/x-markdown", "markdown"); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/mode/python.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; function wordRegexp(words) { return new RegExp("^((" + words.join(")|(") + "))\\b"); } var wordOperators = wordRegexp(["and", "or", "not", "is"]); var commonKeywords = ["as", "assert", "break", "class", "continue", "def", "del", "elif", "else", "except", "finally", "for", "from", "global", "if", "import", "lambda", "pass", "raise", "return", "try", "while", "with", "yield", "in"]; var commonBuiltins = ["abs", "all", "any", "bin", "bool", "bytearray", "callable", "chr", "classmethod", "compile", "complex", "delattr", "dict", "dir", "divmod", "enumerate", "eval", "filter", "float", "format", "frozenset", "getattr", "globals", "hasattr", "hash", "help", "hex", "id", "input", "int", "isinstance", "issubclass", "iter", "len", "list", "locals", "map", "max", "memoryview", "min", "next", "object", "oct", "open", "ord", "pow", "property", "range", "repr", "reversed", "round", "set", "setattr", "slice", "sorted", "staticmethod", "str", "sum", "super", "tuple", "type", "vars", "zip", "__import__", "NotImplemented", "Ellipsis", "__debug__"]; CodeMirror.registerHelper("hintWords", "python", commonKeywords.concat(commonBuiltins)); function top(state) { return state.scopes[state.scopes.length - 1]; } CodeMirror.defineMode("python", function(conf, parserConf) { var ERRORCLASS = "error"; var delimiters = parserConf.delimiters || parserConf.singleDelimiters || /^[\(\)\[\]\{\}@,:`=;\.\\]/; // (Backwards-compatibility with old, cumbersome config system) var operators = [parserConf.singleOperators, parserConf.doubleOperators, parserConf.doubleDelimiters, parserConf.tripleDelimiters, parserConf.operators || /^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@]|\.\.\.)/] for (var i = 0; i < operators.length; i++) if (!operators[i]) operators.splice(i--, 1) var hangingIndent = parserConf.hangingIndent || conf.indentUnit; var myKeywords = commonKeywords, myBuiltins = commonBuiltins; if (parserConf.extra_keywords != undefined) myKeywords = myKeywords.concat(parserConf.extra_keywords); if (parserConf.extra_builtins != undefined) myBuiltins = myBuiltins.concat(parserConf.extra_builtins); var py3 = !(parserConf.version && Number(parserConf.version) < 3) if (py3) { // since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/; myKeywords = myKeywords.concat(["nonlocal", "False", "True", "None", "async", "await"]); myBuiltins = myBuiltins.concat(["ascii", "bytes", "exec", "print"]); var stringPrefixes = new RegExp("^(([rbuf]|(br)|(fr))?('{3}|\"{3}|['\"]))", "i"); } else { var identifiers = parserConf.identifiers|| /^[_A-Za-z][_A-Za-z0-9]*/; myKeywords = myKeywords.concat(["exec", "print"]); myBuiltins = myBuiltins.concat(["apply", "basestring", "buffer", "cmp", "coerce", "execfile", "file", "intern", "long", "raw_input", "reduce", "reload", "unichr", "unicode", "xrange", "False", "True", "None"]); var stringPrefixes = new RegExp("^(([rubf]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i"); } var keywords = wordRegexp(myKeywords); var builtins = wordRegexp(myBuiltins); // tokenizers function tokenBase(stream, state) { var sol = stream.sol() && state.lastToken != "\\" if (sol) state.indent = stream.indentation() // Handle scope changes if (sol && top(state).type == "py") { var scopeOffset = top(state).offset; if (stream.eatSpace()) { var lineOffset = stream.indentation(); if (lineOffset > scopeOffset) pushPyScope(state); else if (lineOffset < scopeOffset && dedent(stream, state) && stream.peek() != "#") state.errorToken = true; return null; } else { var style = tokenBaseInner(stream, state); if (scopeOffset > 0 && dedent(stream, state)) style += " " + ERRORCLASS; return style; } } return tokenBaseInner(stream, state); } function tokenBaseInner(stream, state, inFormat) { if (stream.eatSpace()) return null; // Handle Comments if (!inFormat && stream.match(/^#.*/)) return "comment"; // Handle Number Literals if (stream.match(/^[0-9\.]/, false)) { var floatLiteral = false; // Floats if (stream.match(/^[\d_]*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; } if (stream.match(/^[\d_]+\.\d*/)) { floatLiteral = true; } if (stream.match(/^\.\d+/)) { floatLiteral = true; } if (floatLiteral) { // Float literals may be "imaginary" stream.eat(/J/i); return "number"; } // Integers var intLiteral = false; // Hex if (stream.match(/^0x[0-9a-f_]+/i)) intLiteral = true; // Binary if (stream.match(/^0b[01_]+/i)) intLiteral = true; // Octal if (stream.match(/^0o[0-7_]+/i)) intLiteral = true; // Decimal if (stream.match(/^[1-9][\d_]*(e[\+\-]?[\d_]+)?/)) { // Decimal literals may be "imaginary" stream.eat(/J/i); // TODO - Can you have imaginary longs? intLiteral = true; } // Zero by itself with no other piece of number. if (stream.match(/^0(?![\dx])/i)) intLiteral = true; if (intLiteral) { // Integer literals may be "long" stream.eat(/L/i); return "number"; } } // Handle Strings if (stream.match(stringPrefixes)) { var isFmtString = stream.current().toLowerCase().indexOf('f') !== -1; if (!isFmtString) { state.tokenize = tokenStringFactory(stream.current(), state.tokenize); return state.tokenize(stream, state); } else { state.tokenize = formatStringFactory(stream.current(), state.tokenize); return state.tokenize(stream, state); } } for (var i = 0; i < operators.length; i++) if (stream.match(operators[i])) return "operator" if (stream.match(delimiters)) return "punctuation"; if (state.lastToken == "." && stream.match(identifiers)) return "property"; if (stream.match(keywords) || stream.match(wordOperators)) return "keyword"; if (stream.match(builtins)) return "builtin"; if (stream.match(/^(self|cls)\b/)) return "variable-2"; if (stream.match(identifiers)) { if (state.lastToken == "def" || state.lastToken == "class") return "def"; return "variable"; } // Handle non-detected items stream.next(); return inFormat ? null :ERRORCLASS; } function formatStringFactory(delimiter, tokenOuter) { while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0) delimiter = delimiter.substr(1); var singleline = delimiter.length == 1; var OUTCLASS = "string"; function tokenNestedExpr(depth) { return function(stream, state) { var inner = tokenBaseInner(stream, state, true) if (inner == "punctuation") { if (stream.current() == "{") { state.tokenize = tokenNestedExpr(depth + 1) } else if (stream.current() == "}") { if (depth > 1) state.tokenize = tokenNestedExpr(depth - 1) else state.tokenize = tokenString } } return inner } } function tokenString(stream, state) { while (!stream.eol()) { stream.eatWhile(/[^'"\{\}\\]/); if (stream.eat("\\")) { stream.next(); if (singleline && stream.eol()) return OUTCLASS; } else if (stream.match(delimiter)) { state.tokenize = tokenOuter; return OUTCLASS; } else if (stream.match('{{')) { // ignore {{ in f-str return OUTCLASS; } else if (stream.match('{', false)) { // switch to nested mode state.tokenize = tokenNestedExpr(0) if (stream.current()) return OUTCLASS; else return state.tokenize(stream, state) } else if (stream.match('}}')) { return OUTCLASS; } else if (stream.match('}')) { // single } in f-string is an error return ERRORCLASS; } else { stream.eat(/['"]/); } } if (singleline) { if (parserConf.singleLineStringErrors) return ERRORCLASS; else state.tokenize = tokenOuter; } return OUTCLASS; } tokenString.isString = true; return tokenString; } function tokenStringFactory(delimiter, tokenOuter) { while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0) delimiter = delimiter.substr(1); var singleline = delimiter.length == 1; var OUTCLASS = "string"; function tokenString(stream, state) { while (!stream.eol()) { stream.eatWhile(/[^'"\\]/); if (stream.eat("\\")) { stream.next(); if (singleline && stream.eol()) return OUTCLASS; } else if (stream.match(delimiter)) { state.tokenize = tokenOuter; return OUTCLASS; } else { stream.eat(/['"]/); } } if (singleline) { if (parserConf.singleLineStringErrors) return ERRORCLASS; else state.tokenize = tokenOuter; } return OUTCLASS; } tokenString.isString = true; return tokenString; } function pushPyScope(state) { while (top(state).type != "py") state.scopes.pop() state.scopes.push({offset: top(state).offset + conf.indentUnit, type: "py", align: null}) } function pushBracketScope(stream, state, type) { var align = stream.match(/^([\s\[\{\(]|#.*)*$/, false) ? null : stream.column() + 1 state.scopes.push({offset: state.indent + hangingIndent, type: type, align: align}) } function dedent(stream, state) { var indented = stream.indentation(); while (state.scopes.length > 1 && top(state).offset > indented) { if (top(state).type != "py") return true; state.scopes.pop(); } return top(state).offset != indented; } function tokenLexer(stream, state) { if (stream.sol()) state.beginningOfLine = true; var style = state.tokenize(stream, state); var current = stream.current(); // Handle decorators if (state.beginningOfLine && current == "@") return stream.match(identifiers, false) ? "meta" : py3 ? "operator" : ERRORCLASS; if (/\S/.test(current)) state.beginningOfLine = false; if ((style == "variable" || style == "builtin") && state.lastToken == "meta") style = "meta"; // Handle scope changes. if (current == "pass" || current == "return") state.dedent += 1; if (current == "lambda") state.lambda = true; if (current == ":" && !state.lambda && top(state).type == "py") pushPyScope(state); if (current.length == 1 && !/string|comment/.test(style)) { var delimiter_index = "[({".indexOf(current); if (delimiter_index != -1) pushBracketScope(stream, state, "])}".slice(delimiter_index, delimiter_index+1)); delimiter_index = "])}".indexOf(current); if (delimiter_index != -1) { if (top(state).type == current) state.indent = state.scopes.pop().offset - hangingIndent else return ERRORCLASS; } } if (state.dedent > 0 && stream.eol() && top(state).type == "py") { if (state.scopes.length > 1) state.scopes.pop(); state.dedent -= 1; } return style; } var external = { startState: function(basecolumn) { return { tokenize: tokenBase, scopes: [{offset: basecolumn || 0, type: "py", align: null}], indent: basecolumn || 0, lastToken: null, lambda: false, dedent: 0 }; }, token: function(stream, state) { var addErr = state.errorToken; if (addErr) state.errorToken = false; var style = tokenLexer(stream, state); if (style && style != "comment") state.lastToken = (style == "keyword" || style == "punctuation") ? stream.current() : style; if (style == "punctuation") style = null; if (stream.eol() && state.lambda) state.lambda = false; return addErr ? style + " " + ERRORCLASS : style; }, indent: function(state, textAfter) { if (state.tokenize != tokenBase) return state.tokenize.isString ? CodeMirror.Pass : 0; var scope = top(state), closing = scope.type == textAfter.charAt(0) if (scope.align != null) return scope.align - (closing ? 1 : 0) else return scope.offset - (closing ? hangingIndent : 0) }, electricInput: /^\s*[\}\]\)]$/, closeBrackets: {triples: "'\""}, lineComment: "#", fold: "indent" }; return external; }); CodeMirror.defineMIME("text/x-python", "python"); var words = function(str) { return str.split(" "); }; CodeMirror.defineMIME("text/x-cython", { name: "python", extra_keywords: words("by cdef cimport cpdef ctypedef enum except "+ "extern gil include nogil property public "+ "readonly struct union DEF IF ELIF ELSE") }); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/mode/rust.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../../addon/mode/simple")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../../addon/mode/simple"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineSimpleMode("rust",{ start: [ // string and byte string {regex: /b?"/, token: "string", next: "string"}, // raw string and raw byte string {regex: /b?r"/, token: "string", next: "string_raw"}, {regex: /b?r#+"/, token: "string", next: "string_raw_hash"}, // character {regex: /'(?:[^'\\]|\\(?:[nrt0'"]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\}))'/, token: "string-2"}, // byte {regex: /b'(?:[^']|\\(?:['\\nrt0]|x[\da-fA-F]{2}))'/, token: "string-2"}, {regex: /(?:(?:[0-9][0-9_]*)(?:(?:[Ee][+-]?[0-9_]+)|\.[0-9_]+(?:[Ee][+-]?[0-9_]+)?)(?:f32|f64)?)|(?:0(?:b[01_]+|(?:o[0-7_]+)|(?:x[0-9a-fA-F_]+))|(?:[0-9][0-9_]*))(?:u8|u16|u32|u64|i8|i16|i32|i64|isize|usize)?/, token: "number"}, {regex: /(let(?:\s+mut)?|fn|enum|mod|struct|type|union)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/, token: ["keyword", null, "def"]}, {regex: /(?:abstract|alignof|as|async|await|box|break|continue|const|crate|do|dyn|else|enum|extern|fn|for|final|if|impl|in|loop|macro|match|mod|move|offsetof|override|priv|proc|pub|pure|ref|return|self|sizeof|static|struct|super|trait|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/, token: "keyword"}, {regex: /\b(?:Self|isize|usize|char|bool|u8|u16|u32|u64|f16|f32|f64|i8|i16|i32|i64|str|Option)\b/, token: "atom"}, {regex: /\b(?:true|false|Some|None|Ok|Err)\b/, token: "builtin"}, {regex: /\b(fn)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/, token: ["keyword", null ,"def"]}, {regex: /#!?\[.*\]/, token: "meta"}, {regex: /\/\/.*/, token: "comment"}, {regex: /\/\*/, token: "comment", next: "comment"}, {regex: /[-+\/*=<>!]+/, token: "operator"}, {regex: /[a-zA-Z_]\w*!/,token: "variable-3"}, {regex: /[a-zA-Z_]\w*/, token: "variable"}, {regex: /[\{\[\(]/, indent: true}, {regex: /[\}\]\)]/, dedent: true} ], string: [ {regex: /"/, token: "string", next: "start"}, {regex: /(?:[^\\"]|\\(?:.|$))*/, token: "string"} ], string_raw: [ {regex: /"/, token: "string", next: "start"}, {regex: /[^"]*/, token: "string"} ], string_raw_hash: [ {regex: /"#+/, token: "string", next: "start"}, {regex: /(?:[^"]|"(?!#))*/, token: "string"} ], comment: [ {regex: /.*?\*\//, token: "comment", next: "start"}, {regex: /.*/, token: "comment"} ], meta: { dontIndentStates: ["comment"], electricInput: /^\s*\}$/, blockCommentStart: "/*", blockCommentEnd: "*/", lineComment: "//", fold: "brace" } }); CodeMirror.defineMIME("text/x-rustsrc", "rust"); CodeMirror.defineMIME("text/rust", "rust"); }); ================================================ FILE: plugins/UiFileManager/media/codemirror/mode/xml.js ================================================ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; var htmlConfig = { autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true, 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true, 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true, 'track': true, 'wbr': true, 'menuitem': true}, implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true, 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true, 'th': true, 'tr': true}, contextGrabbers: { 'dd': {'dd': true, 'dt': true}, 'dt': {'dd': true, 'dt': true}, 'li': {'li': true}, 'option': {'option': true, 'optgroup': true}, 'optgroup': {'optgroup': true}, 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true, 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true, 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true, 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true, 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true}, 'rp': {'rp': true, 'rt': true}, 'rt': {'rp': true, 'rt': true}, 'tbody': {'tbody': true, 'tfoot': true}, 'td': {'td': true, 'th': true}, 'tfoot': {'tbody': true}, 'th': {'td': true, 'th': true}, 'thead': {'tbody': true, 'tfoot': true}, 'tr': {'tr': true} }, doNotIndent: {"pre": true}, allowUnquoted: true, allowMissing: true, caseFold: true } var xmlConfig = { autoSelfClosers: {}, implicitlyClosed: {}, contextGrabbers: {}, doNotIndent: {}, allowUnquoted: false, allowMissing: false, allowMissingTagName: false, caseFold: false } CodeMirror.defineMode("xml", function(editorConf, config_) { var indentUnit = editorConf.indentUnit var config = {} var defaults = config_.htmlMode ? htmlConfig : xmlConfig for (var prop in defaults) config[prop] = defaults[prop] for (var prop in config_) config[prop] = config_[prop] // Return variables for tokenizers var type, setStyle; function inText(stream, state) { function chain(parser) { state.tokenize = parser; return parser(stream, state); } var ch = stream.next(); if (ch == "<") { if (stream.eat("!")) { if (stream.eat("[")) { if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>")); else return null; } else if (stream.match("--")) { return chain(inBlock("comment", "-->")); } else if (stream.match("DOCTYPE", true, true)) { stream.eatWhile(/[\w\._\-]/); return chain(doctype(1)); } else { return null; } } else if (stream.eat("?")) { stream.eatWhile(/[\w\._\-]/); state.tokenize = inBlock("meta", "?>"); return "meta"; } else { type = stream.eat("/") ? "closeTag" : "openTag"; state.tokenize = inTag; return "tag bracket"; } } else if (ch == "&") { var ok; if (stream.eat("#")) { if (stream.eat("x")) { ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";"); } else { ok = stream.eatWhile(/[\d]/) && stream.eat(";"); } } else { ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";"); } return ok ? "atom" : "error"; } else { stream.eatWhile(/[^&<]/); return null; } } inText.isInText = true; function inTag(stream, state) { var ch = stream.next(); if (ch == ">" || (ch == "/" && stream.eat(">"))) { state.tokenize = inText; type = ch == ">" ? "endTag" : "selfcloseTag"; return "tag bracket"; } else if (ch == "=") { type = "equals"; return null; } else if (ch == "<") { state.tokenize = inText; state.state = baseState; state.tagName = state.tagStart = null; var next = state.tokenize(stream, state); return next ? next + " tag error" : "tag error"; } else if (/[\'\"]/.test(ch)) { state.tokenize = inAttribute(ch); state.stringStartCol = stream.column(); return state.tokenize(stream, state); } else { stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/); return "word"; } } function inAttribute(quote) { var closure = function(stream, state) { while (!stream.eol()) { if (stream.next() == quote) { state.tokenize = inTag; break; } } return "string"; }; closure.isInAttribute = true; return closure; } function inBlock(style, terminator) { return function(stream, state) { while (!stream.eol()) { if (stream.match(terminator)) { state.tokenize = inText; break; } stream.next(); } return style; } } function doctype(depth) { return function(stream, state) { var ch; while ((ch = stream.next()) != null) { if (ch == "<") { state.tokenize = doctype(depth + 1); return state.tokenize(stream, state); } else if (ch == ">") { if (depth == 1) { state.tokenize = inText; break; } else { state.tokenize = doctype(depth - 1); return state.tokenize(stream, state); } } } return "meta"; }; } function Context(state, tagName, startOfLine) { this.prev = state.context; this.tagName = tagName; this.indent = state.indented; this.startOfLine = startOfLine; if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent)) this.noIndent = true; } function popContext(state) { if (state.context) state.context = state.context.prev; } function maybePopContext(state, nextTagName) { var parentTagName; while (true) { if (!state.context) { return; } parentTagName = state.context.tagName; if (!config.contextGrabbers.hasOwnProperty(parentTagName) || !config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) { return; } popContext(state); } } function baseState(type, stream, state) { if (type == "openTag") { state.tagStart = stream.column(); return tagNameState; } else if (type == "closeTag") { return closeTagNameState; } else { return baseState; } } function tagNameState(type, stream, state) { if (type == "word") { state.tagName = stream.current(); setStyle = "tag"; return attrState; } else if (config.allowMissingTagName && type == "endTag") { setStyle = "tag bracket"; return attrState(type, stream, state); } else { setStyle = "error"; return tagNameState; } } function closeTagNameState(type, stream, state) { if (type == "word") { var tagName = stream.current(); if (state.context && state.context.tagName != tagName && config.implicitlyClosed.hasOwnProperty(state.context.tagName)) popContext(state); if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) { setStyle = "tag"; return closeState; } else { setStyle = "tag error"; return closeStateErr; } } else if (config.allowMissingTagName && type == "endTag") { setStyle = "tag bracket"; return closeState(type, stream, state); } else { setStyle = "error"; return closeStateErr; } } function closeState(type, _stream, state) { if (type != "endTag") { setStyle = "error"; return closeState; } popContext(state); return baseState; } function closeStateErr(type, stream, state) { setStyle = "error"; return closeState(type, stream, state); } function attrState(type, _stream, state) { if (type == "word") { setStyle = "attribute"; return attrEqState; } else if (type == "endTag" || type == "selfcloseTag") { var tagName = state.tagName, tagStart = state.tagStart; state.tagName = state.tagStart = null; if (type == "selfcloseTag" || config.autoSelfClosers.hasOwnProperty(tagName)) { maybePopContext(state, tagName); } else { maybePopContext(state, tagName); state.context = new Context(state, tagName, tagStart == state.indented); } return baseState; } setStyle = "error"; return attrState; } function attrEqState(type, stream, state) { if (type == "equals") return attrValueState; if (!config.allowMissing) setStyle = "error"; return attrState(type, stream, state); } function attrValueState(type, stream, state) { if (type == "string") return attrContinuedState; if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;} setStyle = "error"; return attrState(type, stream, state); } function attrContinuedState(type, stream, state) { if (type == "string") return attrContinuedState; return attrState(type, stream, state); } return { startState: function(baseIndent) { var state = {tokenize: inText, state: baseState, indented: baseIndent || 0, tagName: null, tagStart: null, context: null} if (baseIndent != null) state.baseIndent = baseIndent return state }, token: function(stream, state) { if (!state.tagName && stream.sol()) state.indented = stream.indentation(); if (stream.eatSpace()) return null; type = null; var style = state.tokenize(stream, state); if ((style || type) && style != "comment") { setStyle = null; state.state = state.state(type || style, stream, state); if (setStyle) style = setStyle == "error" ? style + " error" : setStyle; } return style; }, indent: function(state, textAfter, fullLine) { var context = state.context; // Indent multi-line strings (e.g. css). if (state.tokenize.isInAttribute) { if (state.tagStart == state.indented) return state.stringStartCol + 1; else return state.indented + indentUnit; } if (context && context.noIndent) return CodeMirror.Pass; if (state.tokenize != inTag && state.tokenize != inText) return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0; // Indent the starts of attribute names. if (state.tagName) { if (config.multilineTagIndentPastTag !== false) return state.tagStart + state.tagName.length + 2; else return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1); } if (config.alignCDATA && /$/, blockCommentStart: "", configuration: config.htmlMode ? "html" : "xml", helperType: config.htmlMode ? "html" : "xml", skipAttribute: function(state) { if (state.state == attrValueState) state.state = attrState }, xmlCurrentTag: function(state) { return state.tagName ? {name: state.tagName, close: state.type == "closeTag"} : null }, xmlCurrentContext: function(state) { var context = [] for (var cx = state.context; cx; cx = cx.prev) if (cx.tagName) context.push(cx.tagName) return context.reverse() } }; }); CodeMirror.defineMIME("text/xml", "xml"); CodeMirror.defineMIME("application/xml", "xml"); if (!CodeMirror.mimeModes.hasOwnProperty("text/html")) CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true}); }); ================================================ FILE: plugins/UiFileManager/media/css/Menu.css ================================================ .menu { background-color: white; padding: 10px 0px; position: absolute; top: 0px; max-height: 0px; overflow: hidden; transform: translate(-100%, -30px); pointer-events: none; box-shadow: 0px 2px 8px rgba(0,0,0,0.3); border-radius: 2px; opacity: 0; transition: opacity 0.2s ease-out, transform 1s ease-out, max-height 0.2s ease-in-out; z-index: 99; display: inline-block; z-index: 999; transform-style: preserve-3d; } .menu.menu-left { transform: translate(0%, -30px); } .menu.menu-left.visible { transform: translate(0%, 0px); } .menu.visible { opacity: 1; transform: translate(-100%, 0px); pointer-events: all; transition: opacity 0.1s ease-out, transform 0.3s ease-out, max-height 0.3s cubic-bezier(0.86, 0, 0.07, 1); } .menu-item { display: block; text-decoration: none; color: black; padding: 6px 24px; transition: all 0.2s; border-bottom: none; font-weight: normal; max-height: 150px; overflow: hidden; text-overflow: ellipsis; -webkit-line-clamp: 6; -webkit-box-orient: vertical; display: -webkit-box; } .menu-item-separator { margin-top: 3px; margin-bottom: 3px; border-top: 1px solid #eee } .menu-item.noaction { cursor: default } .menu-item:hover:not(.noaction) { background-color: #F6F6F6; transition: none; color: inherit; cursor: pointer; color: black } .menu-item:active:not(.noaction), .menu-item:focus:not(.noaction) { background-color: #AF3BFF !important; color: white !important; transition: none } .menu-item.selected:before { content: "L"; display: inline-block; transform: rotateZ(45deg) scaleX(-1); font-weight: bold; position: absolute; margin-left: -14px; font-size: 12px; margin-top: 2px; } .menu-radio { white-space: normal; line-height: 26px } .menu-radio a { background-color: #EEE; width: 18.5%;; text-align: center; margin-top: 2px; margin-bottom: 2px; color: #666; font-weight: bold; text-decoration: none; font-size: 13px; transition: all 0.3s; text-transform: uppercase; display: inline-block; } .menu-radio a:hover, .menu-radio a.selected { transition: none; background-color: #AF3BFF !important; color: white !important } .menu-radio a.long { font-size: 10px; vertical-align: -1px; } ================================================ FILE: plugins/UiFileManager/media/css/Selectbar.css ================================================ .selectbar.visible { margin-top: 0px; visibility: visible } .selectbar { position: fixed; top: 0; left: 0; background-color: white; box-shadow: 0px 0px 25px rgba(22, 39, 97, 0.2); margin-top: -75px; transition: all 0.3s; visibility: hidden; z-index: 9999; color: black; border-left: 5px solid #ede1f582; width: 100%; padding: 13px; font-size: 13px; font-weight: lighter; backface-visibility: hidden; } .selectbar .num { margin-left: 15px; min-width: 30px; text-align: right; display: inline-block; } .selectbar .size { margin-left: 10px; color: #9f9ba2; min-width: 75px; display: inline-block; } .selectbar .actions { display: inline-block; margin-left: 20px; font-size: 13px; text-transform: uppercase; line-height: 20px; } .selectbar .action { padding: 5px 20px; border: 1px solid #edd4ff; margin-left: 10px; border-radius: 30px; color: #af3bff; text-decoration: none; transition: all 0.3s } .selectbar .action:hover { border-color: #c788f3; transition: none; color: #9700ff } .selectbar .delete { color: #AAA; border-color: #DDD; } .selectbar .delete:hover { color: #333; border-color: #AAA } .selectbar .action:active { background-color: #af3bff; color: white; border-color: #af3bff; transition: none } .selectbar .cancel { margin: 20px; font-size: 10px; text-decoration: none; color: #999; text-transform: uppercase; } .selectbar .cancel:hover { color: #333; transition: none } ================================================ FILE: plugins/UiFileManager/media/css/UiFileManager.css ================================================ body { background-color: #EEEEF5; font-family: "Segoe UI", Helvetica, Arial; height: 95000px; overflow: hidden; } body.loaded { height: auto; overflow: auto } h1 { font-weight: lighter; } a { color: #333 } a:hover { text-decoration: none } input::placeholder { color: rgba(255, 255, 255, 0.3) } h2 { font-weight: lighter; } .link { background-color: transparent; outline: 5px solid transparent; transition: all 0.3s } .link:active { background-color: #fbf5ff; outline: 5px solid #fbf5ff; transition: none } .manager.editing .files { float: left; width: 280px; } .sidebar-button { display: inline-block; padding: 25px 19px; text-decoration: none; position: absolute; border-right: 1px solid #EEE; line-height: 10px; color: #7801F5; transition: all 0.3s } .sidebar-button:active { background-color: #f5e7ff; transition: none } /*.sidebar-button:hover { background-color: #fbf5ff; }*/ .sidebar-button span { transition: 1s all; transform-origin: 2.5px 7px; display: inline-block; } .manager.sidebar_closed .sidebar-button span { transform: rotateZ(180deg); } .manager.sidebar_closed .files { margin-left: -300px; } .manager.sidebar_closed .editor { width: 100%; } .button { padding: 5px 10px; margin-left: 10px; background-color: #752ff2; border-bottom: 2px solid #caadff; background-position: -50px center; border-radius: 2px; text-decoration: none; transition: all 0.5s ease-out; display: inline-block; color: #333; font-size: 12px; vertical-align: 2px; text-transform: uppercase; color: white; max-width: 100px; } .button:hover { background-color: #9e71ed; transition: none; } .button:active { position: relative; top: 1px } .button.loading, .button.disabled { color: rgba(255,255,255,0.7);; pointer-events: none; border-bottom: 2px solid #666; background-color: #999; } .button.loading { background: #999 url(../img/loading.gif) no-repeat center center; transition: all 0.5s ease-out; color: rgba(0,0,0,0); } .button.done { background-color: #4dc758; transition: all 0.3s; border-color: #4dc758; pointer-events: none; } .button.hidden { max-width: 0px; display: inline-block; padding-left: 0px; padding-right: 0px; margin: 0px; } /* List */ .files { width: 97%; box-sizing: border-box; color: #555; position: relative; z-index: 1; transition: all 0.6s; font-size: 14px; box-shadow: 0px 9px 20px -15px #a5cbec; max-width: 400px; border: 1px solid #EEEEF5; } .files .tr { white-space: nowrap } .files .td { display: inline-block; width: 60px } .files .tbody .td { line-height: 18px; vertical-align: bottom; } .files .td.name { min-width: 100px } .files .td.size { width: 60px; text-align: right; padding-left: 5px; } .files .td.status { text-align: right; } .files .td.peer { width: 60px } .files .td.uploaded { width: 130px; text-align: right; } .files .td.added { width: 90px } .files .orderby { color: inherit; text-decoration: none; transition: all 0.3s; outline: 5px solid transparent; } .files .orderby:hover { text-decoration: underline; } .files .orderby .icon-arrow-down { opacity: 0; transition: all 0.3s ease-in-out; } .files .orderby.selected .icon-arrow-down { opacity: 0.3; } .files .orderby:active { background-color: rgba(133, 239, 255, 0.09); outline: 5px solid rgba(133, 239, 255, 0.09); transition: none; } .files .orderby:hover .icon-arrow-down { opacity: 0.5; } .files .orderby:not(.desc) .icon-arrow-down { transform: rotateZ(180deg); } .files .tr.editing .td { background-color: #ede1f582; border-top-color: #ece9ef; } .files .thead { /*background: linear-gradient(358deg, #e7f1f7, #e9f2f72e);*/ } .files .thead .td { border-top: none; color: #8984c2; background-color: #f7f7fc; font-size: 12px; /*text-transform: uppercase; background-color: transparent; font-weight: bold;*/ } .files .thead .td a:last-of-type { font-weight: bold; } .files .thead .td a { text-decoration: none; } .files .thead .td a:hover { text-decoration: underline; } .files .tbody { max-height: calc(100vh - 95px); overflow-y: auto; overflow-x: hidden; } .files .tr { background-color: white; } .files .td { padding: 10px 20px; border-top: 1px solid #EEE; font-size: 13px; white-space: nowrap; } .files .td.full { width: 100%; box-sizing: border-box; white-space: pre-line; } .files .td.pre { width: 0px; color: transparent; padding-left: 0px; border-left: 2px solid transparent; } .files .tbody .td { height: 18px; } .files .tbody .td.full { height: auto; } .files .td.pre .checkbox-outer { opacity: 0.6; margin-left: -11px; margin-top: -15px; width: 18px; height: 12px; display: inline-block; } .files .tr.modified .td.pre { border-left-color: #7801F5 } .files .tr.added .td.pre { border-left-color: #00ec93 } .files .tr.ignored .td.pre { border-left-color: #999; } .files .tr.ignored { opacity: 0.5; } .files .tr.optional { background: linear-gradient(90deg, #fff6dd, 30%, white, 10%, white); } .files .tr.optional_empty { color: #999; font-style: italic; } .files .td.error { background-color: #F44336; color: white; } .files .td.site { width: 70px } .files .td.site .link { color: inherit; text-decoration: none } .files .td.status .percent { transition: all 1s ease-in-out; display: inline-block; width: 80px; background-color: #EEE; font-size: 10px; height: 15px; line-height: 15px; text-align: center; margin-right: 20px; } .files .td.name { padding-left: 10px; width: calc(100% - 167px); max-height: 18px; padding-right: 10px; } .files .tr.nobuttons .td.name { width: calc(100% - 127px); } .files .tr.nobuttons .td.buttons { width: 0px; } .files .td.name .title { color: inherit; text-decoration: none } .files .td.name .link { display: inline-block; overflow: hidden; text-overflow: ellipsis; vertical-align: -4px; max-width: 100%; } .files .pinned .td.name .link { max-width: calc(100% - 40px); } .files .thead .td.uploaded { text-align: left } .files .thead .td.uploaded .title { padding-left: 7px; } .files .peer .icon-profile { background: currentColor; color: #47d094; font-size: 10px; top: 1px; margin-right: 13px } .files .peer .icon-profile:before { background: currentColor } .files .peer .num { color: #969696; } .files .uploaded .uploaded-text { display: inline-block; text-align: right; } .files .uploaded .dots-container { display: inline-block; width: 0px; padding-right: 65px;; } .files .td.buttons { width: 40px; padding-left: 0px; padding-right: 0px; } .files .td.buttons .edit { background-color: #2196f336; border-radius: 15px; padding: 1px 9px; font-size: 80%; text-decoration: none; color: #1976D2; } .files .checkbox-outer { padding: 15px; padding-left: 20px; padding-right: 0px; } .files .checkbox { display: inline-block; width: 12px; height: 12px; border: 2px solid #00000014; border-radius: 3px; vertical-align: -3px; margin-right: 10px; } .files .selected .checkbox { border-color: #dedede } .files .selected .checkbox:after { background-color: #dedede; content: ""; text-decoration: none; display: block; width: 10px; height: 10px; margin-left: 1px; margin-top: 1px; } .files .tbody .td.size { font-size: 13px } .files .tbody .td.added, #PageFiles .files .td.access { font-size: 12px; color: #999 } .files .tr.type-dir .name { font-weight: bold; } .files .tr.type-parent .name .link { display: inline-block; width: 100%; padding: 5px; margin-top: -5px; } .files .foot .td { color: #a4a4a4; background-color: #f7f7fc; } .files .foot .create { float: right; text-decoration: none; position: relative; } .files .foot .create .link { color: #8c42ed; text-decoration: none; } .files .foot .create .link:active { background-color: #8c42ed3b; outline: 5px solid #8c42ed3b; } .files .foot .create .menu { top: 40px; } /* Editor */ .editor { background-color: #F7F7FC; float: left; width: calc(100% - 280px); box-sizing: border-box; transition: all 0.6s; } .editor .CodeMirror { height: calc(100vh - 79px); visibility: hidden; } .editor textarea { width: 100%; height: 800px; white-space: pre; } .editor .title { margin-left: 20px; } .editor .editor-head { padding: 15px 20px; padding-left: 45px; font-size: 18px; font-weight: lighter; border: 1px solid #EEEEF5; white-space: nowrap; overflow: hidden; } .editor.loaded .CodeMirror { visibility: inherit; } .editor.error .CodeMirror { display: none; } .editor .button.save { min-width: 30px; text-align: center; transition: all 0.3s; } .editor .button.save.done { min-width: 80px; } .editor .error-message { text-align: center; padding: 50px; } .editor .CodeMirror-foldmarker { line-height: .3; cursor: pointer; background-color: #ffeb3b61; text-shadow: none; font-family: inherit; color: #050505; border: 1px solid #ffdf7f; padding: 0px 5px; } .editor .CodeMirror-activeline-background { background-color: #F6F6F6 !important; } ================================================ FILE: plugins/UiFileManager/media/css/all.css ================================================ /* ---- Menu.css ---- */ .menu { background-color: white; padding: 10px 0px; position: absolute; top: 0px; max-height: 0px; overflow: hidden; -webkit-transform: translate(-100%, -30px); -moz-transform: translate(-100%, -30px); -o-transform: translate(-100%, -30px); -ms-transform: translate(-100%, -30px); transform: translate(-100%, -30px) ; pointer-events: none; -webkit-box-shadow: 0px 2px 8px rgba(0,0,0,0.3); -moz-box-shadow: 0px 2px 8px rgba(0,0,0,0.3); -o-box-shadow: 0px 2px 8px rgba(0,0,0,0.3); -ms-box-shadow: 0px 2px 8px rgba(0,0,0,0.3); box-shadow: 0px 2px 8px rgba(0,0,0,0.3) ; -webkit-border-radius: 2px; -moz-border-radius: 2px; -o-border-radius: 2px; -ms-border-radius: 2px; border-radius: 2px ; opacity: 0; -webkit-transition: opacity 0.2s ease-out, transform 1s ease-out, max-height 0.2s ease-in-out; -moz-transition: opacity 0.2s ease-out, transform 1s ease-out, max-height 0.2s ease-in-out; -o-transition: opacity 0.2s ease-out, transform 1s ease-out, max-height 0.2s ease-in-out; -ms-transition: opacity 0.2s ease-out, transform 1s ease-out, max-height 0.2s ease-in-out; transition: opacity 0.2s ease-out, transform 1s ease-out, max-height 0.2s ease-in-out ; z-index: 99; display: inline-block; z-index: 999; transform-style: preserve-3d; } .menu.menu-left { -webkit-transform: translate(0%, -30px); -moz-transform: translate(0%, -30px); -o-transform: translate(0%, -30px); -ms-transform: translate(0%, -30px); transform: translate(0%, -30px) ; } .menu.menu-left.visible { -webkit-transform: translate(0%, 0px); -moz-transform: translate(0%, 0px); -o-transform: translate(0%, 0px); -ms-transform: translate(0%, 0px); transform: translate(0%, 0px) ; } .menu.visible { opacity: 1; -webkit-transform: translate(-100%, 0px); -moz-transform: translate(-100%, 0px); -o-transform: translate(-100%, 0px); -ms-transform: translate(-100%, 0px); transform: translate(-100%, 0px) ; pointer-events: all; -webkit-transition: opacity 0.1s ease-out, transform 0.3s ease-out, max-height 0.3s cubic-bezier(0.86, 0, 0.07, 1); -moz-transition: opacity 0.1s ease-out, transform 0.3s ease-out, max-height 0.3s cubic-bezier(0.86, 0, 0.07, 1); -o-transition: opacity 0.1s ease-out, transform 0.3s ease-out, max-height 0.3s cubic-bezier(0.86, 0, 0.07, 1); -ms-transition: opacity 0.1s ease-out, transform 0.3s ease-out, max-height 0.3s cubic-bezier(0.86, 0, 0.07, 1); transition: opacity 0.1s ease-out, transform 0.3s ease-out, max-height 0.3s cubic-bezier(0.86, 0, 0.07, 1) ; } .menu-item { display: block; text-decoration: none; color: black; padding: 6px 24px; -webkit-transition: all 0.2s; -moz-transition: all 0.2s; -o-transition: all 0.2s; -ms-transition: all 0.2s; transition: all 0.2s ; border-bottom: none; font-weight: normal; max-height: 150px; overflow: hidden; text-overflow: ellipsis; -webkit-line-clamp: 6; -webkit-box-orient: vertical; display: -webkit-box; } .menu-item-separator { margin-top: 3px; margin-bottom: 3px; border-top: 1px solid #eee } .menu-item.noaction { cursor: default } .menu-item:hover:not(.noaction) { background-color: #F6F6F6; -webkit-transition: none; -moz-transition: none; -o-transition: none; -ms-transition: none; transition: none ; color: inherit; cursor: pointer; color: black } .menu-item:active:not(.noaction), .menu-item:focus:not(.noaction) { background-color: #AF3BFF !important; color: white !important; -webkit-transition: none ; -moz-transition: none ; -o-transition: none ; -ms-transition: none ; transition: none } .menu-item.selected:before { content: "L"; display: inline-block; -webkit-transform: rotateZ(45deg) scaleX(-1); -moz-transform: rotateZ(45deg) scaleX(-1); -o-transform: rotateZ(45deg) scaleX(-1); -ms-transform: rotateZ(45deg) scaleX(-1); transform: rotateZ(45deg) scaleX(-1) ; font-weight: bold; position: absolute; margin-left: -14px; font-size: 12px; margin-top: 2px; } .menu-radio { white-space: normal; line-height: 26px } .menu-radio a { background-color: #EEE; width: 18.5%;; text-align: center; margin-top: 2px; margin-bottom: 2px; color: #666; font-weight: bold; text-decoration: none; font-size: 13px; -webkit-transition: all 0.3s; -moz-transition: all 0.3s; -o-transition: all 0.3s; -ms-transition: all 0.3s; transition: all 0.3s ; text-transform: uppercase; display: inline-block; } .menu-radio a:hover, .menu-radio a.selected { -webkit-transition: none; -moz-transition: none; -o-transition: none; -ms-transition: none; transition: none ; background-color: #AF3BFF !important; color: white !important } .menu-radio a.long { font-size: 10px; vertical-align: -1px; } /* ---- Selectbar.css ---- */ .selectbar.visible { margin-top: 0px; visibility: visible } .selectbar { position: fixed; top: 0; left: 0; background-color: white; -webkit-box-shadow: 0px 0px 25px rgba(22, 39, 97, 0.2); -moz-box-shadow: 0px 0px 25px rgba(22, 39, 97, 0.2); -o-box-shadow: 0px 0px 25px rgba(22, 39, 97, 0.2); -ms-box-shadow: 0px 0px 25px rgba(22, 39, 97, 0.2); box-shadow: 0px 0px 25px rgba(22, 39, 97, 0.2) ; margin-top: -75px; -webkit-transition: all 0.3s; -moz-transition: all 0.3s; -o-transition: all 0.3s; -ms-transition: all 0.3s; transition: all 0.3s ; visibility: hidden; z-index: 9999; color: black; border-left: 5px solid #ede1f582; width: 100%; padding: 13px; font-size: 13px; font-weight: lighter; -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; -o-backface-visibility: hidden; -ms-backface-visibility: hidden; backface-visibility: hidden ; } .selectbar .num { margin-left: 15px; min-width: 30px; text-align: right; display: inline-block; } .selectbar .size { margin-left: 10px; color: #9f9ba2; min-width: 75px; display: inline-block; } .selectbar .actions { display: inline-block; margin-left: 20px; font-size: 13px; text-transform: uppercase; line-height: 20px; } .selectbar .action { padding: 5px 20px; border: 1px solid #edd4ff; margin-left: 10px; -webkit-border-radius: 30px; -moz-border-radius: 30px; -o-border-radius: 30px; -ms-border-radius: 30px; border-radius: 30px ; color: #af3bff; text-decoration: none; -webkit-transition: all 0.3s ; -moz-transition: all 0.3s ; -o-transition: all 0.3s ; -ms-transition: all 0.3s ; transition: all 0.3s } .selectbar .action:hover { border-color: #c788f3; -webkit-transition: none; -moz-transition: none; -o-transition: none; -ms-transition: none; transition: none ; color: #9700ff } .selectbar .delete { color: #AAA; border-color: #DDD; } .selectbar .delete:hover { color: #333; border-color: #AAA } .selectbar .action:active { background-color: #af3bff; color: white; border-color: #af3bff; -webkit-transition: none ; -moz-transition: none ; -o-transition: none ; -ms-transition: none ; transition: none } .selectbar .cancel { margin: 20px; font-size: 10px; text-decoration: none; color: #999; text-transform: uppercase; } .selectbar .cancel:hover { color: #333; -webkit-transition: none ; -moz-transition: none ; -o-transition: none ; -ms-transition: none ; transition: none } /* ---- UiFileManager.css ---- */ body { background-color: #EEEEF5; font-family: "Segoe UI", Helvetica, Arial; height: 95000px; overflow: hidden; } body.loaded { height: auto; overflow: auto } h1 { font-weight: lighter; } a { color: #333 } a:hover { text-decoration: none } input::placeholder { color: rgba(255, 255, 255, 0.3) } h2 { font-weight: lighter; } .link { background-color: transparent; outline: 5px solid transparent; -webkit-transition: all 0.3s ; -moz-transition: all 0.3s ; -o-transition: all 0.3s ; -ms-transition: all 0.3s ; transition: all 0.3s } .link:active { background-color: #fbf5ff; outline: 5px solid #fbf5ff; -webkit-transition: none ; -moz-transition: none ; -o-transition: none ; -ms-transition: none ; transition: none } .manager.editing .files { float: left; width: 280px; } .sidebar-button { display: inline-block; padding: 25px 19px; text-decoration: none; position: absolute; border-right: 1px solid #EEE; line-height: 10px; color: #7801F5; transition: all 0.3s } .sidebar-button:active { background-color: #f5e7ff; -webkit-transition: none ; -moz-transition: none ; -o-transition: none ; -ms-transition: none ; transition: none } /*.sidebar-button:hover { background-color: #fbf5ff; }*/ .sidebar-button span { -webkit-transition: 1s all; -moz-transition: 1s all; -o-transition: 1s all; -ms-transition: 1s all; transition: 1s all ; transform-origin: 2.5px 7px; display: inline-block; } .manager.sidebar_closed .sidebar-button span { -webkit-transform: rotateZ(180deg); -moz-transform: rotateZ(180deg); -o-transform: rotateZ(180deg); -ms-transform: rotateZ(180deg); transform: rotateZ(180deg) ; } .manager.sidebar_closed .files { margin-left: -300px; } .manager.sidebar_closed .editor { width: 100%; } .button { padding: 5px 10px; margin-left: 10px; background-color: #752ff2; border-bottom: 2px solid #caadff; background-position: -50px center; -webkit-border-radius: 2px; -moz-border-radius: 2px; -o-border-radius: 2px; -ms-border-radius: 2px; border-radius: 2px ; text-decoration: none; -webkit-transition: all 0.5s ease-out; -moz-transition: all 0.5s ease-out; -o-transition: all 0.5s ease-out; -ms-transition: all 0.5s ease-out; transition: all 0.5s ease-out ; display: inline-block; color: #333; font-size: 12px; vertical-align: 2px; text-transform: uppercase; color: white; max-width: 100px; } .button:hover { background-color: #9e71ed; -webkit-transition: none; -moz-transition: none; -o-transition: none; -ms-transition: none; transition: none ; } .button:active { position: relative; top: 1px } .button.loading, .button.disabled { color: rgba(255,255,255,0.7);; pointer-events: none; border-bottom: 2px solid #666; background-color: #999; } .button.loading { background: #999 url(../img/loading.gif) no-repeat center center; -webkit-transition: all 0.5s ease-out; -moz-transition: all 0.5s ease-out; -o-transition: all 0.5s ease-out; -ms-transition: all 0.5s ease-out; transition: all 0.5s ease-out ; color: rgba(0,0,0,0); } .button.done { background-color: #4dc758; -webkit-transition: all 0.3s; -moz-transition: all 0.3s; -o-transition: all 0.3s; -ms-transition: all 0.3s; transition: all 0.3s ; border-color: #4dc758; pointer-events: none; } .button.hidden { max-width: 0px; display: inline-block; padding-left: 0px; padding-right: 0px; margin: 0px; } /* List */ .files { width: 97%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; color: #555; position: relative; z-index: 1; -webkit-transition: all 0.6s; -moz-transition: all 0.6s; -o-transition: all 0.6s; -ms-transition: all 0.6s; transition: all 0.6s ; font-size: 14px; -webkit-box-shadow: 0px 9px 20px -15px #a5cbec; -moz-box-shadow: 0px 9px 20px -15px #a5cbec; -o-box-shadow: 0px 9px 20px -15px #a5cbec; -ms-box-shadow: 0px 9px 20px -15px #a5cbec; box-shadow: 0px 9px 20px -15px #a5cbec ; max-width: 400px; border: 1px solid #EEEEF5; } .files .tr { white-space: nowrap } .files .td { display: inline-block; width: 60px } .files .tbody .td { line-height: 18px; vertical-align: bottom; } .files .td.name { min-width: 100px } .files .td.size { width: 60px; text-align: right; padding-left: 5px; } .files .td.status { text-align: right; } .files .td.peer { width: 60px } .files .td.uploaded { width: 130px; text-align: right; } .files .td.added { width: 90px } .files .orderby { color: inherit; text-decoration: none; -webkit-transition: all 0.3s; -moz-transition: all 0.3s; -o-transition: all 0.3s; -ms-transition: all 0.3s; transition: all 0.3s ; outline: 5px solid transparent; } .files .orderby:hover { text-decoration: underline; } .files .orderby .icon-arrow-down { opacity: 0; -webkit-transition: all 0.3s ease-in-out; -moz-transition: all 0.3s ease-in-out; -o-transition: all 0.3s ease-in-out; -ms-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out ; } .files .orderby.selected .icon-arrow-down { opacity: 0.3; } .files .orderby:active { background-color: rgba(133, 239, 255, 0.09); outline: 5px solid rgba(133, 239, 255, 0.09); -webkit-transition: none; -moz-transition: none; -o-transition: none; -ms-transition: none; transition: none ; } .files .orderby:hover .icon-arrow-down { opacity: 0.5; } .files .orderby:not(.desc) .icon-arrow-down { -webkit-transform: rotateZ(180deg); -moz-transform: rotateZ(180deg); -o-transform: rotateZ(180deg); -ms-transform: rotateZ(180deg); transform: rotateZ(180deg) ; } .files .tr.editing .td { background-color: #ede1f582; border-top-color: #ece9ef; } .files .thead { /*background: -webkit-linear-gradient(358deg, #e7f1f7, #e9f2f72e);background: -moz-linear-gradient(358deg, #e7f1f7, #e9f2f72e);background: -o-linear-gradient(358deg, #e7f1f7, #e9f2f72e);background: -ms-linear-gradient(358deg, #e7f1f7, #e9f2f72e);background: linear-gradient(358deg, #e7f1f7, #e9f2f72e);*/ } .files .thead .td { border-top: none; color: #8984c2; background-color: #f7f7fc; font-size: 12px; /*text-transform: uppercase; background-color: transparent; font-weight: bold;*/ } .files .thead .td a:last-of-type { font-weight: bold; } .files .thead .td a { text-decoration: none; } .files .thead .td a:hover { text-decoration: underline; } .files .tbody { max-height: calc(100vh - 95px); overflow-y: auto; overflow-x: hidden; } .files .tr { background-color: white; } .files .td { padding: 10px 20px; border-top: 1px solid #EEE; font-size: 13px; white-space: nowrap; } .files .td.full { width: 100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; white-space: pre-line; } .files .td.pre { width: 0px; color: transparent; padding-left: 0px; border-left: 2px solid transparent; } .files .tbody .td { height: 18px; } .files .tbody .td.full { height: auto; } .files .td.pre .checkbox-outer { opacity: 0.6; margin-left: -11px; margin-top: -15px; width: 18px; height: 12px; display: inline-block; } .files .tr.modified .td.pre { border-left-color: #7801F5 } .files .tr.added .td.pre { border-left-color: #00ec93 } .files .tr.ignored .td.pre { border-left-color: #999; } .files .tr.ignored { opacity: 0.5; } .files .tr.optional { background: -webkit-linear-gradient(90deg, #fff6dd, 30%, white, 10%, white);background: -moz-linear-gradient(90deg, #fff6dd, 30%, white, 10%, white);background: -o-linear-gradient(90deg, #fff6dd, 30%, white, 10%, white);background: -ms-linear-gradient(90deg, #fff6dd, 30%, white, 10%, white);background: linear-gradient(90deg, #fff6dd, 30%, white, 10%, white); } .files .tr.optional_empty { color: #999; font-style: italic; } .files .td.error { background-color: #F44336; color: white; } .files .td.site { width: 70px } .files .td.site .link { color: inherit; text-decoration: none } .files .td.status .percent { -webkit-transition: all 1s ease-in-out; -moz-transition: all 1s ease-in-out; -o-transition: all 1s ease-in-out; -ms-transition: all 1s ease-in-out; transition: all 1s ease-in-out ; display: inline-block; width: 80px; background-color: #EEE; font-size: 10px; height: 15px; line-height: 15px; text-align: center; margin-right: 20px; } .files .td.name { padding-left: 10px; width: calc(100% - 167px); max-height: 18px; padding-right: 10px; } .files .tr.nobuttons .td.name { width: calc(100% - 127px); } .files .tr.nobuttons .td.buttons { width: 0px; } .files .td.name .title { color: inherit; text-decoration: none } .files .td.name .link { display: inline-block; overflow: hidden; text-overflow: ellipsis; vertical-align: -4px; max-width: 100%; } .files .pinned .td.name .link { max-width: calc(100% - 40px); } .files .thead .td.uploaded { text-align: left } .files .thead .td.uploaded .title { padding-left: 7px; } .files .peer .icon-profile { background: currentColor; color: #47d094; font-size: 10px; top: 1px; margin-right: 13px } .files .peer .icon-profile:before { background: currentColor } .files .peer .num { color: #969696; } .files .uploaded .uploaded-text { display: inline-block; text-align: right; } .files .uploaded .dots-container { display: inline-block; width: 0px; padding-right: 65px;; } .files .td.buttons { width: 40px; padding-left: 0px; padding-right: 0px; } .files .td.buttons .edit { background-color: #2196f336; -webkit-border-radius: 15px; -moz-border-radius: 15px; -o-border-radius: 15px; -ms-border-radius: 15px; border-radius: 15px ; padding: 1px 9px; font-size: 80%; text-decoration: none; color: #1976D2; } .files .checkbox-outer { padding: 15px; padding-left: 20px; padding-right: 0px; } .files .checkbox { display: inline-block; width: 12px; height: 12px; border: 2px solid #00000014; -webkit-border-radius: 3px; -moz-border-radius: 3px; -o-border-radius: 3px; -ms-border-radius: 3px; border-radius: 3px ; vertical-align: -3px; margin-right: 10px; } .files .selected .checkbox { border-color: #dedede } .files .selected .checkbox:after { background-color: #dedede; content: ""; text-decoration: none; display: block; width: 10px; height: 10px; margin-left: 1px; margin-top: 1px; } .files .tbody .td.size { font-size: 13px } .files .tbody .td.added, #PageFiles .files .td.access { font-size: 12px; color: #999 } .files .tr.type-dir .name { font-weight: bold; } .files .tr.type-parent .name .link { display: inline-block; width: 100%; padding: 5px; margin-top: -5px; } .files .foot .td { color: #a4a4a4; background-color: #f7f7fc; } .files .foot .create { float: right; text-decoration: none; position: relative; } .files .foot .create .link { color: #8c42ed; text-decoration: none; } .files .foot .create .link:active { background-color: #8c42ed3b; outline: 5px solid #8c42ed3b; } .files .foot .create .menu { top: 40px; } /* Editor */ .editor { background-color: #F7F7FC; float: left; width: calc(100% - 280px); -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; -webkit-transition: all 0.6s; -moz-transition: all 0.6s; -o-transition: all 0.6s; -ms-transition: all 0.6s; transition: all 0.6s ; } .editor .CodeMirror { height: calc(100vh - 79px); visibility: hidden; } .editor textarea { width: 100%; height: 800px; white-space: pre; } .editor .title { margin-left: 20px; } .editor .editor-head { padding: 15px 20px; padding-left: 45px; font-size: 18px; font-weight: lighter; border: 1px solid #EEEEF5; white-space: nowrap; overflow: hidden; } .editor.loaded .CodeMirror { visibility: inherit; } .editor.error .CodeMirror { display: none; } .editor .button.save { min-width: 30px; text-align: center; -webkit-transition: all 0.3s; -moz-transition: all 0.3s; -o-transition: all 0.3s; -ms-transition: all 0.3s; transition: all 0.3s ; } .editor .button.save.done { min-width: 80px; } .editor .error-message { text-align: center; padding: 50px; } .editor .CodeMirror-foldmarker { line-height: .3; cursor: pointer; background-color: #ffeb3b61; text-shadow: none; font-family: inherit; color: #050505; border: 1px solid #ffdf7f; padding: 0px 5px; } .editor .CodeMirror-activeline-background { background-color: #F6F6F6 !important; } ================================================ FILE: plugins/UiFileManager/media/js/Config.coffee ================================================ window.BINARY_EXTENSIONS = [ "3dm", "3ds", "3g2", "3gp", "7z", "a", "aac", "adp", "ai", "aif", "aiff", "alz", "ape", "apk", "appimage", "ar", "arj", "asc", "asf", "au", "avi", "bak", "baml", "bh", "bin", "bk", "bmp", "btif", "bz2", "bzip2", "cab", "caf", "cgm", "class", "cmx", "cpio", "cr2", "cur", "dat", "dcm", "deb", "dex", "djvu", "dll", "dmg", "dng", "doc", "docm", "docx", "dot", "dotm", "dra", "DS_Store", "dsk", "dts", "dtshd", "dvb", "dwg", "dxf", "ecelp4800", "ecelp7470", "ecelp9600", "egg", "eol", "eot", "epub", "exe", "f4v", "fbs", "fh", "fla", "flac", "flatpak", "fli", "flv", "fpx", "fst", "fvt", "g3", "gh", "gif", "gpg", "graffle", "gz", "gzip", "h261", "h263", "h264", "icns", "ico", "ief", "img", "ipa", "iso", "jar", "jpeg", "jpg", "jpgv", "jpm", "jxr", "key", "ktx", "lha", "lib", "lvp", "lz", "lzh", "lzma", "lzo", "m3u", "m4a", "m4v", "mar", "mdi", "mht", "mid", "midi", "mj2", "mka", "mkv", "mmr", "mng", "mobi", "mov", "movie", "mp3", "mp4", "mp4a", "mpeg", "mpg", "mpga", "msgpack", "mxu", "nef", "npx", "numbers", "nupkg", "o", "oga", "ogg", "ogv", "otf", "pages", "pbm", "pcx", "pdb", "pdf", "pea", "pgm", "pic", "png", "pnm", "pot", "potm", "potx", "ppa", "ppam", "ppm", "pps", "ppsm", "ppsx", "ppt", "pptm", "pptx", "psd", "pya", "pyc", "pyo", "pyv", "qt", "rar", "ras", "raw", "resources", "rgb", "rip", "rlc", "rmf", "rmvb", "rpm", "rtf", "rz", "s3m", "s7z", "scpt", "sgi", "shar", "sig", "sil", "sketch", "slk", "smv", "snap", "snk", "so", "stl", "sub", "suo", "swf", "tar", "tbz2", "tbz", "tga", "tgz", "thmx", "tif", "tiff", "tlz", "ttc", "ttf", "txz", "udf", "uvh", "uvi", "uvm", "uvp", "uvs", "uvu", "viv", "vob", "war", "wav", "wax", "wbmp", "wdp", "weba", "webm", "webp", "whl", "wim", "wm", "wma", "wmv", "wmx", "woff2", "woff", "wrm", "wvx", "xbm", "xif", "xla", "xlam", "xls", "xlsb", "xlsm", "xlsx", "xlt", "xltm", "xltx", "xm", "xmind", "xpi", "xpm", "xwd", "xz", "z", "zip", "zipx" ] ================================================ FILE: plugins/UiFileManager/media/js/FileEditor.coffee ================================================ class FileEditor extends Class constructor: (@inner_path) -> @need_update = true @on_loaded = new Promise() @is_loading = false @content = "" @node_cm = null @cm = null @error = null @is_loaded = false @is_modified = false @is_saving = false @mode = "Loading" update: -> is_required = Page.url_params.get("edit_mode") != "new" Page.cmd "fileGet", {inner_path: @inner_path, required: is_required}, (res) => if res?.error @error = res.error @content = res.error @log "Error loading: #{@error}" else if res @content = res else @content = "" @mode = "Create" if not @content @cm.getDoc().clearHistory() @cm.setValue(@content) if not @error @is_loaded = true Page.projector.scheduleRender() isModified: => return @content != @cm.getValue() storeCmNode: (node) => @node_cm = node getMode: (inner_path) -> ext = inner_path.split(".").pop() types = { "py": "python", "json": "application/json", "js": "javascript", "coffee": "coffeescript", "html": "htmlmixed", "htm": "htmlmixed", "php": "htmlmixed", "rs": "rust", "css": "css", "md": "markdown", "xml": "xml", "svg": "xml" } return types[ext] foldJson: (from, to) => @log "foldJson", from, to # Get open / close token startToken = '{' endToken = '}' prevLine = @cm.getLine(from.line) if prevLine.lastIndexOf('[') > prevLine.lastIndexOf('{') startToken = '[' endToken = ']' # Get json content internal = @cm.getRange(from, to) toParse = startToken + internal + endToken #Get key count try parsed = JSON.parse(toParse) count = Object.keys(parsed).length catch e null return if count then "\u21A4#{count}\u21A6" else "\u2194" createCodeMirror: -> mode = @getMode(@inner_path) @log "Creating CodeMirror", @inner_path, mode options = { value: "Loading...", mode: mode, lineNumbers: true, styleActiveLine: true, matchBrackets: true, keyMap: "sublime", theme: "mdn-like", extraKeys: {"Ctrl-Space": "autocomplete"}, foldGutter: true, gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"] } if mode == "application/json" options.gutters.unshift("CodeMirror-lint-markers") options.lint = true options.foldOptions = { widget: @foldJson } @cm = CodeMirror(@node_cm, options) @cm.on "changes", (changes) => if @is_loaded and not @is_modified @is_modified = true Page.projector.scheduleRender() loadEditor: -> if not @is_loading document.getElementsByTagName("head")[0].insertAdjacentHTML( "beforeend", """""" ) script = document.createElement('script') script.src = "codemirror/all.js" script.onload = => @createCodeMirror() @on_loaded.resolve() document.head.appendChild(script) return @on_loaded handleSidebarButtonClick: => Page.is_sidebar_closed = not Page.is_sidebar_closed return false handleSaveClick: => num_errors = (mark for mark in Page.file_editor.cm.getAllMarks() when mark.className == "CodeMirror-lint-mark-error").length if num_errors > 0 Page.cmd "wrapperConfirm", ["Warning: The file looks invalid.", "Save anyway"], @save else @save() return false save: => Page.projector.scheduleRender() @is_saving = true Page.cmd "fileWrite", [@inner_path, Text.fileEncode(@cm.getValue())], (res) => @is_saving = false if res.error Page.cmd "wrapperNotification", ["error", "Error saving #{res.error}"] else @is_save_done = true setTimeout (() => @is_save_done = false Page.projector.scheduleRender() ), 2000 @content = @cm.getValue() @is_modified = false if @mode == "Create" @mode = "Edit" Page.file_list.need_update = true Page.projector.scheduleRender() render: -> if @need_update @loadEditor().then => @update() @need_update = false h("div.editor", {afterCreate: @storeCmNode, classes: {error: @error, loaded: @is_loaded}}, [ h("a.sidebar-button", {href: "#Sidebar", onclick: @handleSidebarButtonClick}, h("span", "\u2039")), h("div.editor-head", [ if @mode in ["Edit", "Create"] h("a.save.button", {href: "#Save", classes: {loading: @is_saving, done: @is_save_done, disabled: not @is_modified}, onclick: @handleSaveClick}, if @is_save_done then "Save: done!" else "Save" ) h("span.title", @mode, ": ", @inner_path) ]), if @error h("div.error-message", h("h2", "Unable to load the file: #{@error}") h("a", {href: Page.file_list.getHref(@inner_path)}, "View in browser") ) ]) window.FileEditor = FileEditor ================================================ FILE: plugins/UiFileManager/media/js/FileItemList.coffee ================================================ class FileItemList extends Class constructor: (@inner_path) -> @items = [] @updating = false @files_modified = {} @dirs_modified = {} @files_added = {} @dirs_added = {} @files_optional = {} @items_by_name = {} # Update item list update: (cb) -> @updating = true @logStart("Updating dirlist") Page.cmd "dirList", {inner_path: @inner_path, stats: true}, (res) => if res.error @error = res.error else @error = null pattern_ignore = RegExp("^" + Page.site_info.content?.ignore) @items.splice(0, @items.length) # Remove all items @items_by_name = {} for row in res row.type = @getFileType(row) row.inner_path = @inner_path + row.name if Page.site_info.content?.ignore and row.inner_path.match(pattern_ignore) row.ignored = true @items.push(row) @items_by_name[row.name] = row @sort() if Page.site_info?.settings?.own @updateAddedFiles() @updateOptionalFiles => @updating = false cb?() @logEnd("Updating dirlist", @inner_path) Page.projector.scheduleRender() @updateModifiedFiles => Page.projector.scheduleRender() updateModifiedFiles: (cb) => # Add modified attribute to changed files Page.cmd "siteListModifiedFiles", [], (res) => @files_modified = {} @dirs_modified = {} for inner_path in res.modified_files @files_modified[inner_path] = true dir_inner_path = "" dir_parts = inner_path.split("/") for dir_part in dir_parts[..-2] if dir_inner_path dir_inner_path += "/#{dir_part}" else dir_inner_path = dir_part @dirs_modified[dir_inner_path] = true cb?() # Update newly added items list since last sign updateAddedFiles: => Page.cmd "fileGet", "content.json", (res) => if not res return false content = JSON.parse(res) # Check new files if not content.files? return false @files_added = {} for file in @items if file.name == "content.json" or file.is_dir continue if not content.files[@inner_path + file.name] @files_added[@inner_path + file.name] = true # Check new dirs @dirs_added = {} dirs_content = {} for file_name of Object.assign({}, content.files, content.files_optional) if not file_name.startsWith(@inner_path) continue pattern = new RegExp("#{@inner_path}(.*?)/") match = file_name.match(pattern) if not match continue dirs_content[match[1]] = true for file in @items if not file.is_dir continue if not dirs_content[file.name] @dirs_added[@inner_path + file.name] = true # Update optional files list updateOptionalFiles: (cb) => Page.cmd "optionalFileList", {filter: ""}, (res) => @files_optional = {} for optional_file in res @files_optional[optional_file.inner_path] = optional_file @addOptionalFilesToItems() cb?() # Add optional files to item list addOptionalFilesToItems: => is_added = false for inner_path, optional_file of @files_optional if optional_file.inner_path.startsWith(@inner_path) if @getDirectory(optional_file.inner_path) == @inner_path # Add optional file to list file_name = @getFileName(optional_file.inner_path) if not @items_by_name[file_name] row = { "name": file_name, "type": "file", "optional_empty": true, "size": optional_file.size, "is_dir": false, "inner_path": optional_file.inner_path } @items.push(row) @items_by_name[file_name] = row is_added = true else # Add optional dir to list dir_name = optional_file.inner_path.replace(@inner_path, "").match(/(.*?)\//, "")?[1] if dir_name and not @items_by_name[dir_name] row = { "name": dir_name, "type": "dir", "optional_empty": true, "size": 0, "is_dir": true, "inner_path": optional_file.inner_path } @items.push(row) @items_by_name[dir_name] = row is_added = true if is_added @sort() getFileType: (file) => if file.is_dir return "dir" else return "unknown" getDirectory: (inner_path) -> if inner_path.indexOf("/") != -1 return inner_path.replace(/^(.*\/)(.*?)$/, "$1") else return "" getFileName: (inner_path) -> return inner_path.replace(/^(.*\/)(.*?)$/, "$2") isModified: (inner_path) => return @files_modified[inner_path] or @dirs_modified[inner_path] isAdded: (inner_path) => return @files_added[inner_path] or @dirs_added[inner_path] hasPermissionDelete: (file) => if file.type in ["dir", "parent"] return false if file.inner_path == "content.json" return false optional_info = @getOptionalInfo(file.inner_path) if optional_info and optional_info.downloaded_percent > 0 return true else return Page.site_info?.settings?.own getOptionalInfo: (inner_path) => return @files_optional[inner_path] sort: => @items.sort (a, b) -> return (b.is_dir - a.is_dir) || a.name.localeCompare(b.name) window.FileItemList = FileItemList ================================================ FILE: plugins/UiFileManager/media/js/FileList.coffee ================================================ class FileList extends Class constructor: (@site, @inner_path, @is_owner=false) -> @need_update = true @error = null @url_root = "/list/" + @site + "/" if @inner_path @inner_path += "/" @url_root += @inner_path @log("inited", @url_root) @item_list = new FileItemList(@inner_path) @item_list.items = @item_list.items @menu_create = new Menu() @select_action = null @selected = {} @selected_items_num = 0 @selected_items_size = 0 @selected_optional_empty_num = 0 isSelectedAll: -> false update: => @item_list.update => document.body.classList.add("loaded") getHref: (inner_path) => return "/" + @site + "/" + inner_path getListHref: (inner_path) => return "/list/" + @site + "/" + inner_path getEditHref: (inner_path, mode=null) => href = @url_root + "?file=" + inner_path if mode href += "&edit_mode=#{mode}" return href checkSelectedItems: => @selected_items_num = 0 @selected_items_size = 0 @selected_optional_empty_num = 0 for item in @item_list.items if @selected[item.inner_path] @selected_items_num += 1 @selected_items_size += item.size optional_info = @item_list.getOptionalInfo(item.inner_path) if optional_info and not optional_info.downloaded_percent > 0 @selected_optional_empty_num += 1 handleMenuCreateClick: => @menu_create.items = [] @menu_create.items.push ["File", @handleNewFileClick] @menu_create.items.push ["Directory", @handleNewDirectoryClick] @menu_create.toggle() return false handleNewFileClick: => Page.cmd "wrapperPrompt", "New file name:", (file_name) => window.top.location.href = @getEditHref(@inner_path + file_name, "new") return false handleNewDirectoryClick: => Page.cmd "wrapperPrompt", "New directory name:", (res) => alert("directory name #{res}") return false handleSelectClick: (e) => return false handleSelectEnd: (e) => document.body.removeEventListener('mouseup', @handleSelectEnd) @select_action = null handleSelectMousedown: (e) => inner_path = e.currentTarget.attributes.inner_path.value if @selected[inner_path] delete @selected[inner_path] @select_action = "deselect" else @selected[inner_path] = true @select_action = "select" @checkSelectedItems() document.body.addEventListener('mouseup', @handleSelectEnd) e.stopPropagation() Page.projector.scheduleRender() return false handleRowMouseenter: (e) => if e.buttons and @select_action inner_path = e.target.attributes.inner_path.value if @select_action == "select" @selected[inner_path] = true else delete @selected[inner_path] @checkSelectedItems() Page.projector.scheduleRender() return false handleSelectbarCancel: => @selected = {} @checkSelectedItems() Page.projector.scheduleRender() return false handleSelectbarDelete: (e, remove_optional=false) => for inner_path of @selected optional_info = @item_list.getOptionalInfo(inner_path) delete @selected[inner_path] if optional_info and not remove_optional Page.cmd "optionalFileDelete", inner_path else Page.cmd "fileDelete", inner_path @need_update = true Page.projector.scheduleRender() @checkSelectedItems() return false handleSelectbarRemoveOptional: (e) => return @handleSelectbarDelete(e, true) renderSelectbar: => h("div.selectbar", {classes: {visible: @selected_items_num > 0}}, [ "Selected:", h("span.info", [ h("span.num", "#{@selected_items_num} files"), h("span.size", "(#{Text.formatSize(@selected_items_size)})"), ]) h("div.actions", [ if @selected_optional_empty_num > 0 h("a.action.delete.remove_optional", {href: "#", onclick: @handleSelectbarRemoveOptional}, "Delete and remove optional") else h("a.action.delete", {href: "#", onclick: @handleSelectbarDelete}, "Delete") ]) h("a.cancel.link", {href: "#", onclick: @handleSelectbarCancel}, "Cancel") ]) renderHead: => parent_links = [] inner_path_parent = "" for parent_dir in @inner_path.split("/") if not parent_dir continue if inner_path_parent inner_path_parent += "/" inner_path_parent += "#{parent_dir}" parent_links.push( [" / ", h("a", {href: @getListHref(inner_path_parent)}, parent_dir)] ) return h("div.tr.thead", h("div.td.full", h("a", {href: @getListHref("")}, "root"), parent_links )) renderItemCheckbox: (item) => if not @item_list.hasPermissionDelete(item) return [" "] return h("a.checkbox-outer", { href: "#Select", onmousedown: @handleSelectMousedown, onclick: @handleSelectClick, inner_path: item.inner_path }, h("span.checkbox")) renderItem: (item) => if item.type == "parent" href = @url_root.replace(/^(.*)\/.{2,255}?$/, "$1/") else if item.type == "dir" href = @url_root + item.name else href = @url_root.replace(/^\/list\//, "/") + item.name inner_path = @inner_path + item.name href_edit = @getEditHref(inner_path) is_dir = item.type in ["dir", "parent"] ext = item.name.split(".").pop() is_editing = inner_path == Page.file_editor?.inner_path is_editable = not is_dir and item.size < 1024 * 1024 and ext not in window.BINARY_EXTENSIONS is_modified = @item_list.isModified(inner_path) is_added = @item_list.isAdded(inner_path) optional_info = @item_list.getOptionalInfo(inner_path) style = "" title = "" if optional_info downloaded_percent = optional_info.downloaded_percent if not downloaded_percent downloaded_percent = 0 style += "background: linear-gradient(90deg, #fff6dd, #{downloaded_percent}%, white, #{downloaded_percent}%, white);" is_added = false if item.ignored is_added = false if is_modified then title += " (modified)" if is_added then title += " (new)" if optional_info or item.optional_empty then title += " (optional)" if item.ignored then title += " (ignored from content.json)" classes = { "type-#{item.type}": true, editing: is_editing, nobuttons: not is_editable, selected: @selected[inner_path], modified: is_modified, added: is_added, ignored: item.ignored, optional: optional_info, optional_empty: item.optional_empty } h("div.tr", {key: item.name, classes: classes, style: style, onmouseenter: @handleRowMouseenter, inner_path: inner_path}, [ h("div.td.pre", {title: title}, @renderItemCheckbox(item) ), h("div.td.name", h("a.link", {href: href}, item.name)) h("div.td.buttons", if is_editable then h("a.edit", {href: href_edit}, if Page.site_info.settings.own then "Edit" else "View")) h("div.td.size", if is_dir then "[DIR]" else Text.formatSize(item.size)) ]) renderItems: => return [ if @item_list.error and not @item_list.items.length and not @item_list.updating then [ h("div.tr", {key: "error"}, h("div.td.full.error", @item_list.error)) ], if @inner_path then @renderItem({"name": "..", type: "parent", size: 0}) @item_list.items.map @renderItem ] renderFoot: => files = (item for item in @item_list.items when item.type not in ["parent", "dir"]) dirs = (item for item in @item_list.items when item.type == "dir") if files.length total_size = (item.size for file in files).reduce (a, b) -> a + b else total_size = 0 foot_text = "Total: " foot_text += "#{dirs.length} dir, #{files.length} file in #{Text.formatSize(total_size)}" return [ if dirs.length or files.length or Page.site_info?.settings?.own h("div.tr.foot-info.foot", h("div.td.full", [ if @item_list.updating "Updating file list..." else if dirs.length or files.length then foot_text if Page.site_info?.settings?.own h("div.create", [ h("a.link", {href: "#Create+new+file", onclick: @handleNewFileClick}, "+ New") @menu_create.render() ]) ])) ] render: => if @need_update @update() @need_update = false if not @item_list.items return [] return h("div.files", [ @renderSelectbar(), @renderHead(), h("div.tbody", @renderItems()), @renderFoot() ]) window.FileList = FileList ================================================ FILE: plugins/UiFileManager/media/js/UiFileManager.coffee ================================================ window.h = maquette.h class UiFileManager extends ZeroFrame init: -> @url_params = new URLSearchParams(window.location.search) @list_site = @url_params.get("site") @list_address = @url_params.get("address") @list_inner_path = @url_params.get("inner_path") @editor_inner_path = @url_params.get("file") @file_list = new FileList(@list_site, @list_inner_path) @site_info = null @server_info = null @is_sidebar_closed = false if @editor_inner_path @file_editor = new FileEditor(@editor_inner_path) window.onbeforeunload = => if @file_editor?.isModified() return true else return null window.onresize = => @checkBodyWidth() @checkBodyWidth() @cmd("wrapperSetViewport", "width=device-width, initial-scale=0.8") @cmd "serverInfo", {}, (server_info) => @server_info = server_info @cmd "siteInfo", {}, (site_info) => @cmd("wrapperSetTitle", "List: /#{@list_inner_path} - #{site_info.content.title} - ZeroNet") @site_info = site_info if @file_editor then @file_editor.on_loaded.then => @file_editor.cm.setOption("readOnly", not site_info.settings.own) @file_editor.mode = if site_info.settings.own then "Edit" else "View" @projector.scheduleRender() checkBodyWidth: => if not @file_editor return false if document.body.offsetWidth < 960 and not @is_sidebar_closed @is_sidebar_closed = true @projector?.scheduleRender() else if document.body.offsetWidth > 960 and @is_sidebar_closed @is_sidebar_closed = false @projector?.scheduleRender() onRequest: (cmd, message) => if cmd == "setSiteInfo" @site_info = message RateLimitCb 1000, (cb_done) => @file_list.update(cb_done) @projector.scheduleRender() else if cmd == "setServerInfo" @server_info = message @projector.scheduleRender() else @log "Unknown incoming message:", cmd createProjector: => @projector = maquette.createProjector() @projector.replace($("#content"), @render) render: => return h("div.content#content", [ h("div.manager", {classes: {editing: @file_editor, sidebar_closed: @is_sidebar_closed}}, [ @file_list.render(), if @file_editor then @file_editor.render() ]) ]) window.Page = new UiFileManager() window.Page.createProjector() ================================================ FILE: plugins/UiFileManager/media/js/all.js ================================================ /* ---- lib/Animation.coffee ---- */ (function() { var Animation; Animation = (function() { function Animation() {} Animation.prototype.slideDown = function(elem, props) { var cstyle, h, margin_bottom, margin_top, padding_bottom, padding_top, transition; if (elem.offsetTop > 2000) { return; } h = elem.offsetHeight; cstyle = window.getComputedStyle(elem); margin_top = cstyle.marginTop; margin_bottom = cstyle.marginBottom; padding_top = cstyle.paddingTop; padding_bottom = cstyle.paddingBottom; transition = cstyle.transition; elem.style.boxSizing = "border-box"; elem.style.overflow = "hidden"; elem.style.transform = "scale(0.6)"; elem.style.opacity = "0"; elem.style.height = "0px"; elem.style.marginTop = "0px"; elem.style.marginBottom = "0px"; elem.style.paddingTop = "0px"; elem.style.paddingBottom = "0px"; elem.style.transition = "none"; setTimeout((function() { elem.className += " animate-inout"; elem.style.height = h + "px"; elem.style.transform = "scale(1)"; elem.style.opacity = "1"; elem.style.marginTop = margin_top; elem.style.marginBottom = margin_bottom; elem.style.paddingTop = padding_top; return elem.style.paddingBottom = padding_bottom; }), 1); return elem.addEventListener("transitionend", function() { elem.classList.remove("animate-inout"); elem.style.transition = elem.style.transform = elem.style.opacity = elem.style.height = null; elem.style.boxSizing = elem.style.marginTop = elem.style.marginBottom = null; elem.style.paddingTop = elem.style.paddingBottom = elem.style.overflow = null; return elem.removeEventListener("transitionend", arguments.callee, false); }); }; Animation.prototype.slideUp = function(elem, remove_func, props) { if (elem.offsetTop > 1000) { return remove_func(); } elem.className += " animate-back"; elem.style.boxSizing = "border-box"; elem.style.height = elem.offsetHeight + "px"; elem.style.overflow = "hidden"; elem.style.transform = "scale(1)"; elem.style.opacity = "1"; elem.style.pointerEvents = "none"; setTimeout((function() { elem.style.height = "0px"; elem.style.marginTop = "0px"; elem.style.marginBottom = "0px"; elem.style.paddingTop = "0px"; elem.style.paddingBottom = "0px"; elem.style.transform = "scale(0.8)"; elem.style.borderTopWidth = "0px"; elem.style.borderBottomWidth = "0px"; return elem.style.opacity = "0"; }), 1); return elem.addEventListener("transitionend", function(e) { if (e.propertyName === "opacity" || e.elapsedTime >= 0.6) { elem.removeEventListener("transitionend", arguments.callee, false); return remove_func(); } }); }; Animation.prototype.slideUpInout = function(elem, remove_func, props) { elem.className += " animate-inout"; elem.style.boxSizing = "border-box"; elem.style.height = elem.offsetHeight + "px"; elem.style.overflow = "hidden"; elem.style.transform = "scale(1)"; elem.style.opacity = "1"; elem.style.pointerEvents = "none"; setTimeout((function() { elem.style.height = "0px"; elem.style.marginTop = "0px"; elem.style.marginBottom = "0px"; elem.style.paddingTop = "0px"; elem.style.paddingBottom = "0px"; elem.style.transform = "scale(0.8)"; elem.style.borderTopWidth = "0px"; elem.style.borderBottomWidth = "0px"; return elem.style.opacity = "0"; }), 1); return elem.addEventListener("transitionend", function(e) { if (e.propertyName === "opacity" || e.elapsedTime >= 0.6) { elem.removeEventListener("transitionend", arguments.callee, false); return remove_func(); } }); }; Animation.prototype.showRight = function(elem, props) { elem.className += " animate"; elem.style.opacity = 0; elem.style.transform = "TranslateX(-20px) Scale(1.01)"; setTimeout((function() { elem.style.opacity = 1; return elem.style.transform = "TranslateX(0px) Scale(1)"; }), 1); return elem.addEventListener("transitionend", function() { elem.classList.remove("animate"); return elem.style.transform = elem.style.opacity = null; }); }; Animation.prototype.show = function(elem, props) { var delay, ref; delay = ((ref = arguments[arguments.length - 2]) != null ? ref.delay : void 0) * 1000 || 1; elem.style.opacity = 0; setTimeout((function() { return elem.className += " animate"; }), 1); setTimeout((function() { return elem.style.opacity = 1; }), delay); return elem.addEventListener("transitionend", function() { elem.classList.remove("animate"); elem.style.opacity = null; return elem.removeEventListener("transitionend", arguments.callee, false); }); }; Animation.prototype.hide = function(elem, remove_func, props) { var delay, ref; delay = ((ref = arguments[arguments.length - 2]) != null ? ref.delay : void 0) * 1000 || 1; elem.className += " animate"; setTimeout((function() { return elem.style.opacity = 0; }), delay); return elem.addEventListener("transitionend", function(e) { if (e.propertyName === "opacity") { return remove_func(); } }); }; Animation.prototype.addVisibleClass = function(elem, props) { return setTimeout(function() { return elem.classList.add("visible"); }); }; return Animation; })(); window.Animation = new Animation(); }).call(this); /* ---- lib/Class.coffee ---- */ (function() { var Class, slice = [].slice; Class = (function() { function Class() {} Class.prototype.trace = true; Class.prototype.log = function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; if (!this.trace) { return; } if (typeof console === 'undefined') { return; } args.unshift("[" + this.constructor.name + "]"); console.log.apply(console, args); return this; }; Class.prototype.logStart = function() { var args, name; name = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; if (!this.trace) { return; } this.logtimers || (this.logtimers = {}); this.logtimers[name] = +(new Date); if (args.length > 0) { this.log.apply(this, ["" + name].concat(slice.call(args), ["(started)"])); } return this; }; Class.prototype.logEnd = function() { var args, ms, name; name = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; ms = +(new Date) - this.logtimers[name]; this.log.apply(this, ["" + name].concat(slice.call(args), ["(Done in " + ms + "ms)"])); return this; }; return Class; })(); window.Class = Class; }).call(this); /* ---- lib/Dollar.coffee ---- */ (function() { window.$ = function(selector) { if (selector.startsWith("#")) { return document.getElementById(selector.replace("#", "")); } }; }).call(this); /* ---- lib/ItemList.coffee ---- */ (function() { var ItemList; ItemList = (function() { function ItemList(item_class1, key1) { this.item_class = item_class1; this.key = key1; this.items = []; this.items_bykey = {}; } ItemList.prototype.sync = function(rows, item_class, key) { var current_obj, i, item, len, results, row; this.items.splice(0, this.items.length); results = []; for (i = 0, len = rows.length; i < len; i++) { row = rows[i]; current_obj = this.items_bykey[row[this.key]]; if (current_obj) { current_obj.row = row; results.push(this.items.push(current_obj)); } else { item = new this.item_class(row, this); this.items_bykey[row[this.key]] = item; results.push(this.items.push(item)); } } return results; }; ItemList.prototype.deleteItem = function(item) { var index; index = this.items.indexOf(item); if (index > -1) { this.items.splice(index, 1); } else { console.log("Can't delete item", item); } return delete this.items_bykey[item.row[this.key]]; }; return ItemList; })(); window.ItemList = ItemList; }).call(this); /* ---- lib/Menu.coffee ---- */ (function() { var Menu, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; Menu = (function() { function Menu() { this.render = bind(this.render, this); this.getStyle = bind(this.getStyle, this); this.renderItem = bind(this.renderItem, this); this.handleClick = bind(this.handleClick, this); this.getDirection = bind(this.getDirection, this); this.storeNode = bind(this.storeNode, this); this.toggle = bind(this.toggle, this); this.hide = bind(this.hide, this); this.show = bind(this.show, this); this.visible = false; this.items = []; this.node = null; this.height = 0; this.direction = "bottom"; } Menu.prototype.show = function() { var ref; if ((ref = window.visible_menu) != null) { ref.hide(); } this.visible = true; window.visible_menu = this; return this.direction = this.getDirection(); }; Menu.prototype.hide = function() { return this.visible = false; }; Menu.prototype.toggle = function() { if (this.visible) { this.hide(); } else { this.show(); } return Page.projector.scheduleRender(); }; Menu.prototype.addItem = function(title, cb, selected) { if (selected == null) { selected = false; } return this.items.push([title, cb, selected]); }; Menu.prototype.storeNode = function(node) { this.node = node; if (this.visible) { node.className = node.className.replace("visible", ""); setTimeout(((function(_this) { return function() { node.className += " visible"; return node.attributes.style.value = _this.getStyle(); }; })(this)), 20); node.style.maxHeight = "none"; this.height = node.offsetHeight; node.style.maxHeight = "0px"; return this.direction = this.getDirection(); } }; Menu.prototype.getDirection = function() { if (this.node && this.node.parentNode.getBoundingClientRect().top + this.height + 60 > document.body.clientHeight && this.node.parentNode.getBoundingClientRect().top - this.height > 0) { return "top"; } else { return "bottom"; } }; Menu.prototype.handleClick = function(e) { var cb, i, item, keep_menu, len, ref, selected, title; keep_menu = false; ref = this.items; for (i = 0, len = ref.length; i < len; i++) { item = ref[i]; title = item[0], cb = item[1], selected = item[2]; if (title === e.currentTarget.textContent || e.currentTarget["data-title"] === title) { keep_menu = typeof cb === "function" ? cb(item) : void 0; break; } } if (keep_menu !== true && cb !== null) { this.hide(); } return false; }; Menu.prototype.renderItem = function(item) { var cb, classes, href, onclick, selected, title; title = item[0], cb = item[1], selected = item[2]; if (typeof selected === "function") { selected = selected(); } if (title === "---") { return h("div.menu-item-separator", { key: Time.timestamp() }); } else { if (cb === null) { href = void 0; onclick = this.handleClick; } else if (typeof cb === "string") { href = cb; onclick = true; } else { href = "#" + title; onclick = this.handleClick; } classes = { "selected": selected, "noaction": cb === null }; return h("a.menu-item", { href: href, onclick: onclick, "data-title": title, key: title, classes: classes }, title); } }; Menu.prototype.getStyle = function() { var max_height, style; if (this.visible) { max_height = this.height; } else { max_height = 0; } style = "max-height: " + max_height + "px"; if (this.direction === "top") { style += ";margin-top: " + (0 - this.height - 50) + "px"; } else { style += ";margin-top: 0px"; } return style; }; Menu.prototype.render = function(class_name) { if (class_name == null) { class_name = ""; } if (this.visible || this.node) { return h("div.menu" + class_name, { classes: { "visible": this.visible }, style: this.getStyle(), afterCreate: this.storeNode }, this.items.map(this.renderItem)); } }; return Menu; })(); window.Menu = Menu; document.body.addEventListener("mouseup", function(e) { var menu_node, menu_parents, ref, ref1; if (!window.visible_menu || !window.visible_menu.node) { return false; } menu_node = window.visible_menu.node; menu_parents = [menu_node, menu_node.parentNode]; if ((ref = e.target.parentNode, indexOf.call(menu_parents, ref) < 0) && (ref1 = e.target.parentNode.parentNode, indexOf.call(menu_parents, ref1) < 0)) { window.visible_menu.hide(); return Page.projector.scheduleRender(); } }); }).call(this); /* ---- lib/Promise.coffee ---- */ (function() { var Promise, slice = [].slice; Promise = (function() { Promise.when = function() { var args, fn, i, len, num_uncompleted, promise, task, task_id, tasks; tasks = 1 <= arguments.length ? slice.call(arguments, 0) : []; num_uncompleted = tasks.length; args = new Array(num_uncompleted); promise = new Promise(); fn = function(task_id) { return task.then(function() { args[task_id] = Array.prototype.slice.call(arguments); num_uncompleted--; if (num_uncompleted === 0) { return promise.complete.apply(promise, args); } }); }; for (task_id = i = 0, len = tasks.length; i < len; task_id = ++i) { task = tasks[task_id]; fn(task_id); } return promise; }; function Promise() { this.resolved = false; this.end_promise = null; this.result = null; this.callbacks = []; } Promise.prototype.resolve = function() { var back, callback, i, len, ref; if (this.resolved) { return false; } this.resolved = true; this.data = arguments; if (!arguments.length) { this.data = [true]; } this.result = this.data[0]; ref = this.callbacks; for (i = 0, len = ref.length; i < len; i++) { callback = ref[i]; back = callback.apply(callback, this.data); } if (this.end_promise) { return this.end_promise.resolve(back); } }; Promise.prototype.fail = function() { return this.resolve(false); }; Promise.prototype.then = function(callback) { if (this.resolved === true) { callback.apply(callback, this.data); return; } this.callbacks.push(callback); return this.end_promise = new Promise(); }; return Promise; })(); window.Promise = Promise; /* s = Date.now() log = (text) -> console.log Date.now()-s, Array.prototype.slice.call(arguments).join(", ") log "Started" cmd = (query) -> p = new Promise() setTimeout ( -> p.resolve query+" Result" ), 100 return p back = cmd("SELECT * FROM message").then (res) -> log res return "Return from query" .then (res) -> log "Back then", res log "Query started", back */ }).call(this); /* ---- lib/Prototypes.coffee ---- */ (function() { String.prototype.startsWith = function(s) { return this.slice(0, s.length) === s; }; String.prototype.endsWith = function(s) { return s === '' || this.slice(-s.length) === s; }; String.prototype.repeat = function(count) { return new Array(count + 1).join(this); }; window.isEmpty = function(obj) { var key; for (key in obj) { return false; } return true; }; }).call(this); /* ---- lib/RateLimitCb.coffee ---- */ (function() { var call_after_interval, calling, calling_iterval, last_time, slice = [].slice; last_time = {}; calling = {}; calling_iterval = {}; call_after_interval = {}; window.RateLimitCb = function(interval, fn, args) { var cb; if (args == null) { args = []; } cb = function() { var left; left = interval - (Date.now() - last_time[fn]); if (left <= 0) { delete last_time[fn]; if (calling[fn]) { RateLimitCb(interval, fn, calling[fn]); } return delete calling[fn]; } else { return setTimeout((function() { delete last_time[fn]; if (calling[fn]) { RateLimitCb(interval, fn, calling[fn]); } return delete calling[fn]; }), left); } }; if (last_time[fn]) { return calling[fn] = args; } else { last_time[fn] = Date.now(); return fn.apply(this, [cb].concat(slice.call(args))); } }; window.RateLimit = function(interval, fn) { if (calling_iterval[fn] > interval) { clearInterval(calling[fn]); delete calling[fn]; } if (!calling[fn]) { call_after_interval[fn] = false; fn(); calling_iterval[fn] = interval; return calling[fn] = setTimeout((function() { if (call_after_interval[fn]) { fn(); } delete calling[fn]; return delete call_after_interval[fn]; }), interval); } else { return call_after_interval[fn] = true; } }; /* window.s = Date.now() window.load = (done, num) -> console.log "Loading #{num}...", Date.now()-window.s setTimeout (-> done()), 1000 RateLimit 500, window.load, [0] # Called instantly RateLimit 500, window.load, [1] setTimeout (-> RateLimit 500, window.load, [300]), 300 setTimeout (-> RateLimit 500, window.load, [600]), 600 # Called after 1000ms setTimeout (-> RateLimit 500, window.load, [1000]), 1000 setTimeout (-> RateLimit 500, window.load, [1200]), 1200 # Called after 2000ms setTimeout (-> RateLimit 500, window.load, [3000]), 3000 # Called after 3000ms */ }).call(this); /* ---- lib/Text.coffee ---- */ (function() { var Text, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; Text = (function() { function Text() {} Text.prototype.toColor = function(text, saturation, lightness) { var hash, i, j, ref; if (saturation == null) { saturation = 30; } if (lightness == null) { lightness = 50; } hash = 0; for (i = j = 0, ref = text.length - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { hash += text.charCodeAt(i) * i; hash = hash % 1777; } return "hsl(" + (hash % 360) + ("," + saturation + "%," + lightness + "%)"); }; Text.prototype.renderMarked = function(text, options) { if (options == null) { options = {}; } options["gfm"] = true; options["breaks"] = true; options["sanitize"] = true; options["renderer"] = marked_renderer; text = marked(text, options); return this.fixHtmlLinks(text); }; Text.prototype.emailLinks = function(text) { return text.replace(/([a-zA-Z0-9]+)@zeroid.bit/g, "$1@zeroid.bit"); }; Text.prototype.fixHtmlLinks = function(text) { if (window.is_proxy) { return text.replace(/href="http:\/\/(127.0.0.1|localhost):43110/g, 'href="http://zero'); } else { return text.replace(/href="http:\/\/(127.0.0.1|localhost):43110/g, 'href="'); } }; Text.prototype.fixLink = function(link) { var back; if (window.is_proxy) { back = link.replace(/http:\/\/(127.0.0.1|localhost):43110/, 'http://zero'); return back.replace(/http:\/\/zero\/([^\/]+\.bit)/, "http://$1"); } else { return link.replace(/http:\/\/(127.0.0.1|localhost):43110/, ''); } }; Text.prototype.toUrl = function(text) { return text.replace(/[^A-Za-z0-9]/g, "+").replace(/[+]+/g, "+").replace(/[+]+$/, ""); }; Text.prototype.getSiteUrl = function(address) { if (window.is_proxy) { if (indexOf.call(address, ".") >= 0) { return "http://" + address + "/"; } else { return "http://zero/" + address + "/"; } } else { return "/" + address + "/"; } }; Text.prototype.fixReply = function(text) { return text.replace(/(>.*\n)([^\n>])/gm, "$1\n$2"); }; Text.prototype.toBitcoinAddress = function(text) { return text.replace(/[^A-Za-z0-9]/g, ""); }; Text.prototype.jsonEncode = function(obj) { return unescape(encodeURIComponent(JSON.stringify(obj))); }; Text.prototype.jsonDecode = function(obj) { return JSON.parse(decodeURIComponent(escape(obj))); }; Text.prototype.fileEncode = function(obj) { if (typeof obj === "string") { return btoa(unescape(encodeURIComponent(obj))); } else { return btoa(unescape(encodeURIComponent(JSON.stringify(obj, void 0, '\t')))); } }; Text.prototype.utf8Encode = function(s) { return unescape(encodeURIComponent(s)); }; Text.prototype.utf8Decode = function(s) { return decodeURIComponent(escape(s)); }; Text.prototype.distance = function(s1, s2) { var char, extra_parts, j, key, len, match, next_find, next_find_i, val; s1 = s1.toLocaleLowerCase(); s2 = s2.toLocaleLowerCase(); next_find_i = 0; next_find = s2[0]; match = true; extra_parts = {}; for (j = 0, len = s1.length; j < len; j++) { char = s1[j]; if (char !== next_find) { if (extra_parts[next_find_i]) { extra_parts[next_find_i] += char; } else { extra_parts[next_find_i] = char; } } else { next_find_i++; next_find = s2[next_find_i]; } } if (extra_parts[next_find_i]) { extra_parts[next_find_i] = ""; } extra_parts = (function() { var results; results = []; for (key in extra_parts) { val = extra_parts[key]; results.push(val); } return results; })(); if (next_find_i >= s2.length) { return extra_parts.length + extra_parts.join("").length; } else { return false; } }; Text.prototype.parseQuery = function(query) { var j, key, len, params, part, parts, ref, val; params = {}; parts = query.split('&'); for (j = 0, len = parts.length; j < len; j++) { part = parts[j]; ref = part.split("="), key = ref[0], val = ref[1]; if (val) { params[decodeURIComponent(key)] = decodeURIComponent(val); } else { params["url"] = decodeURIComponent(key); } } return params; }; Text.prototype.encodeQuery = function(params) { var back, key, val; back = []; if (params.url) { back.push(params.url); } for (key in params) { val = params[key]; if (!val || key === "url") { continue; } back.push((encodeURIComponent(key)) + "=" + (encodeURIComponent(val))); } return back.join("&"); }; Text.prototype.highlight = function(text, search) { var back, i, j, len, part, parts; if (!text) { return [""]; } parts = text.split(RegExp(search, "i")); back = []; for (i = j = 0, len = parts.length; j < len; i = ++j) { part = parts[i]; back.push(part); if (i < parts.length - 1) { back.push(h("span.highlight", { key: i }, search)); } } return back; }; Text.prototype.formatSize = function(size) { var size_mb; if (isNaN(parseInt(size))) { return ""; } size_mb = size / 1024 / 1024; if (size_mb >= 1000) { return (size_mb / 1024).toFixed(1) + " GB"; } else if (size_mb >= 100) { return size_mb.toFixed(0) + " MB"; } else if (size / 1024 >= 1000) { return size_mb.toFixed(2) + " MB"; } else { return (parseInt(size) / 1024).toFixed(2) + " KB"; } }; return Text; })(); window.is_proxy = document.location.host === "zero" || window.location.pathname === "/"; window.Text = new Text(); }).call(this); /* ---- lib/Time.coffee ---- */ (function() { var Time; Time = (function() { function Time() {} Time.prototype.since = function(timestamp) { var back, minutes, now, secs; now = +(new Date) / 1000; if (timestamp > 1000000000000) { timestamp = timestamp / 1000; } secs = now - timestamp; if (secs < 60) { back = "Just now"; } else if (secs < 60 * 60) { minutes = Math.round(secs / 60); back = "" + minutes + " minutes ago"; } else if (secs < 60 * 60 * 24) { back = (Math.round(secs / 60 / 60)) + " hours ago"; } else if (secs < 60 * 60 * 24 * 3) { back = (Math.round(secs / 60 / 60 / 24)) + " days ago"; } else { back = "on " + this.date(timestamp); } back = back.replace(/^1 ([a-z]+)s/, "1 $1"); return back; }; Time.prototype.dateIso = function(timestamp) { var tzoffset; if (timestamp == null) { timestamp = null; } if (!timestamp) { timestamp = window.Time.timestamp(); } if (timestamp > 1000000000000) { timestamp = timestamp / 1000; } tzoffset = (new Date()).getTimezoneOffset() * 60; return (new Date((timestamp - tzoffset) * 1000)).toISOString().split("T")[0]; }; Time.prototype.date = function(timestamp, format) { var display, parts; if (timestamp == null) { timestamp = null; } if (format == null) { format = "short"; } if (!timestamp) { timestamp = window.Time.timestamp(); } if (timestamp > 1000000000000) { timestamp = timestamp / 1000; } parts = (new Date(timestamp * 1000)).toString().split(" "); if (format === "short") { display = parts.slice(1, 4); } else if (format === "day") { display = parts.slice(1, 3); } else if (format === "month") { display = [parts[1], parts[3]]; } else if (format === "long") { display = parts.slice(1, 5); } return display.join(" ").replace(/( [0-9]{4})/, ",$1"); }; Time.prototype.weekDay = function(timestamp) { if (timestamp > 1000000000000) { timestamp = timestamp / 1000; } return ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][(new Date(timestamp * 1000)).getDay()]; }; Time.prototype.timestamp = function(date) { if (date == null) { date = ""; } if (date === "now" || date === "") { return parseInt(+(new Date) / 1000); } else { return parseInt(Date.parse(date) / 1000); } }; return Time; })(); window.Time = new Time; }).call(this); /* ---- lib/ZeroFrame.coffee ---- */ (function() { var ZeroFrame, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; ZeroFrame = (function(superClass) { extend(ZeroFrame, superClass); function ZeroFrame(url) { this.onCloseWebsocket = bind(this.onCloseWebsocket, this); this.onOpenWebsocket = bind(this.onOpenWebsocket, this); this.onRequest = bind(this.onRequest, this); this.onMessage = bind(this.onMessage, this); this.url = url; this.waiting_cb = {}; this.wrapper_nonce = document.location.href.replace(/.*wrapper_nonce=([A-Za-z0-9]+).*/, "$1"); this.connect(); this.next_message_id = 1; this.history_state = {}; this.init(); } ZeroFrame.prototype.init = function() { return this; }; ZeroFrame.prototype.connect = function() { this.target = window.parent; window.addEventListener("message", this.onMessage, false); this.cmd("innerReady"); window.addEventListener("beforeunload", (function(_this) { return function(e) { _this.log("save scrollTop", window.pageYOffset); _this.history_state["scrollTop"] = window.pageYOffset; return _this.cmd("wrapperReplaceState", [_this.history_state, null]); }; })(this)); return this.cmd("wrapperGetState", [], (function(_this) { return function(state) { if (state != null) { _this.history_state = state; } _this.log("restore scrollTop", state, window.pageYOffset); if (window.pageYOffset === 0 && state) { return window.scroll(window.pageXOffset, state.scrollTop); } }; })(this)); }; ZeroFrame.prototype.onMessage = function(e) { var cmd, message; message = e.data; cmd = message.cmd; if (cmd === "response") { if (this.waiting_cb[message.to] != null) { return this.waiting_cb[message.to](message.result); } else { return this.log("Websocket callback not found:", message); } } else if (cmd === "wrapperReady") { return this.cmd("innerReady"); } else if (cmd === "ping") { return this.response(message.id, "pong"); } else if (cmd === "wrapperOpenedWebsocket") { return this.onOpenWebsocket(); } else if (cmd === "wrapperClosedWebsocket") { return this.onCloseWebsocket(); } else { return this.onRequest(cmd, message.params); } }; ZeroFrame.prototype.onRequest = function(cmd, message) { return this.log("Unknown request", message); }; ZeroFrame.prototype.response = function(to, result) { return this.send({ "cmd": "response", "to": to, "result": result }); }; ZeroFrame.prototype.cmd = function(cmd, params, cb) { if (params == null) { params = {}; } if (cb == null) { cb = null; } return this.send({ "cmd": cmd, "params": params }, cb); }; ZeroFrame.prototype.send = function(message, cb) { if (cb == null) { cb = null; } message.wrapper_nonce = this.wrapper_nonce; message.id = this.next_message_id; this.next_message_id += 1; this.target.postMessage(message, "*"); if (cb) { return this.waiting_cb[message.id] = cb; } }; ZeroFrame.prototype.onOpenWebsocket = function() { return this.log("Websocket open"); }; ZeroFrame.prototype.onCloseWebsocket = function() { return this.log("Websocket close"); }; return ZeroFrame; })(Class); window.ZeroFrame = ZeroFrame; }).call(this); /* ---- lib/maquette.js ---- */ (function (root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['exports'], factory); } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') { // CommonJS factory(exports); } else { // Browser globals factory(root.maquette = {}); } }(this, function (exports) { 'use strict'; ; ; ; ; var NAMESPACE_W3 = 'http://www.w3.org/'; var NAMESPACE_SVG = NAMESPACE_W3 + '2000/svg'; var NAMESPACE_XLINK = NAMESPACE_W3 + '1999/xlink'; // Utilities var emptyArray = []; var extend = function (base, overrides) { var result = {}; Object.keys(base).forEach(function (key) { result[key] = base[key]; }); if (overrides) { Object.keys(overrides).forEach(function (key) { result[key] = overrides[key]; }); } return result; }; // Hyperscript helper functions var same = function (vnode1, vnode2) { if (vnode1.vnodeSelector !== vnode2.vnodeSelector) { return false; } if (vnode1.properties && vnode2.properties) { if (vnode1.properties.key !== vnode2.properties.key) { return false; } return vnode1.properties.bind === vnode2.properties.bind; } return !vnode1.properties && !vnode2.properties; }; var toTextVNode = function (data) { return { vnodeSelector: '', properties: undefined, children: undefined, text: data.toString(), domNode: null }; }; var appendChildren = function (parentSelector, insertions, main) { for (var i = 0; i < insertions.length; i++) { var item = insertions[i]; if (Array.isArray(item)) { appendChildren(parentSelector, item, main); } else { if (item !== null && item !== undefined) { if (!item.hasOwnProperty('vnodeSelector')) { item = toTextVNode(item); } main.push(item); } } } }; // Render helper functions var missingTransition = function () { throw new Error('Provide a transitions object to the projectionOptions to do animations'); }; var DEFAULT_PROJECTION_OPTIONS = { namespace: undefined, eventHandlerInterceptor: undefined, styleApplyer: function (domNode, styleName, value) { // Provides a hook to add vendor prefixes for browsers that still need it. domNode.style[styleName] = value; }, transitions: { enter: missingTransition, exit: missingTransition } }; var applyDefaultProjectionOptions = function (projectorOptions) { return extend(DEFAULT_PROJECTION_OPTIONS, projectorOptions); }; var checkStyleValue = function (styleValue) { if (typeof styleValue !== 'string') { throw new Error('Style values must be strings'); } }; var setProperties = function (domNode, properties, projectionOptions) { if (!properties) { return; } var eventHandlerInterceptor = projectionOptions.eventHandlerInterceptor; var propNames = Object.keys(properties); var propCount = propNames.length; for (var i = 0; i < propCount; i++) { var propName = propNames[i]; /* tslint:disable:no-var-keyword: edge case */ var propValue = properties[propName]; /* tslint:enable:no-var-keyword */ if (propName === 'className') { throw new Error('Property "className" is not supported, use "class".'); } else if (propName === 'class') { if (domNode.className) { // May happen if classes is specified before class domNode.className += ' ' + propValue; } else { domNode.className = propValue; } } else if (propName === 'classes') { // object with string keys and boolean values var classNames = Object.keys(propValue); var classNameCount = classNames.length; for (var j = 0; j < classNameCount; j++) { var className = classNames[j]; if (propValue[className]) { domNode.classList.add(className); } } } else if (propName === 'styles') { // object with string keys and string (!) values var styleNames = Object.keys(propValue); var styleCount = styleNames.length; for (var j = 0; j < styleCount; j++) { var styleName = styleNames[j]; var styleValue = propValue[styleName]; if (styleValue) { checkStyleValue(styleValue); projectionOptions.styleApplyer(domNode, styleName, styleValue); } } } else if (propName === 'key') { continue; } else if (propValue === null || propValue === undefined) { continue; } else { var type = typeof propValue; if (type === 'function') { if (propName.lastIndexOf('on', 0) === 0) { if (eventHandlerInterceptor) { propValue = eventHandlerInterceptor(propName, propValue, domNode, properties); // intercept eventhandlers } if (propName === 'oninput') { (function () { // record the evt.target.value, because IE and Edge sometimes do a requestAnimationFrame between changing value and running oninput var oldPropValue = propValue; propValue = function (evt) { evt.target['oninput-value'] = evt.target.value; // may be HTMLTextAreaElement as well oldPropValue.apply(this, [evt]); }; }()); } domNode[propName] = propValue; } } else if (type === 'string' && propName !== 'value' && propName !== 'innerHTML') { if (projectionOptions.namespace === NAMESPACE_SVG && propName === 'href') { domNode.setAttributeNS(NAMESPACE_XLINK, propName, propValue); } else { domNode.setAttribute(propName, propValue); } } else { domNode[propName] = propValue; } } } }; var updateProperties = function (domNode, previousProperties, properties, projectionOptions) { if (!properties) { return; } var propertiesUpdated = false; var propNames = Object.keys(properties); var propCount = propNames.length; for (var i = 0; i < propCount; i++) { var propName = propNames[i]; // assuming that properties will be nullified instead of missing is by design var propValue = properties[propName]; var previousValue = previousProperties[propName]; if (propName === 'class') { if (previousValue !== propValue) { throw new Error('"class" property may not be updated. Use the "classes" property for conditional css classes.'); } } else if (propName === 'classes') { var classList = domNode.classList; var classNames = Object.keys(propValue); var classNameCount = classNames.length; for (var j = 0; j < classNameCount; j++) { var className = classNames[j]; var on = !!propValue[className]; var previousOn = !!previousValue[className]; if (on === previousOn) { continue; } propertiesUpdated = true; if (on) { classList.add(className); } else { classList.remove(className); } } } else if (propName === 'styles') { var styleNames = Object.keys(propValue); var styleCount = styleNames.length; for (var j = 0; j < styleCount; j++) { var styleName = styleNames[j]; var newStyleValue = propValue[styleName]; var oldStyleValue = previousValue[styleName]; if (newStyleValue === oldStyleValue) { continue; } propertiesUpdated = true; if (newStyleValue) { checkStyleValue(newStyleValue); projectionOptions.styleApplyer(domNode, styleName, newStyleValue); } else { projectionOptions.styleApplyer(domNode, styleName, ''); } } } else { if (!propValue && typeof previousValue === 'string') { propValue = ''; } if (propName === 'value') { if (domNode[propName] !== propValue && domNode['oninput-value'] !== propValue) { domNode[propName] = propValue; // Reset the value, even if the virtual DOM did not change domNode['oninput-value'] = undefined; } // else do not update the domNode, otherwise the cursor position would be changed if (propValue !== previousValue) { propertiesUpdated = true; } } else if (propValue !== previousValue) { var type = typeof propValue; if (type === 'function') { throw new Error('Functions may not be updated on subsequent renders (property: ' + propName + '). Hint: declare event handler functions outside the render() function.'); } if (type === 'string' && propName !== 'innerHTML') { if (projectionOptions.namespace === NAMESPACE_SVG && propName === 'href') { domNode.setAttributeNS(NAMESPACE_XLINK, propName, propValue); } else { domNode.setAttribute(propName, propValue); } } else { if (domNode[propName] !== propValue) { domNode[propName] = propValue; } } propertiesUpdated = true; } } } return propertiesUpdated; }; var findIndexOfChild = function (children, sameAs, start) { if (sameAs.vnodeSelector !== '') { // Never scan for text-nodes for (var i = start; i < children.length; i++) { if (same(children[i], sameAs)) { return i; } } } return -1; }; var nodeAdded = function (vNode, transitions) { if (vNode.properties) { var enterAnimation = vNode.properties.enterAnimation; if (enterAnimation) { if (typeof enterAnimation === 'function') { enterAnimation(vNode.domNode, vNode.properties); } else { transitions.enter(vNode.domNode, vNode.properties, enterAnimation); } } } }; var nodeToRemove = function (vNode, transitions) { var domNode = vNode.domNode; if (vNode.properties) { var exitAnimation = vNode.properties.exitAnimation; if (exitAnimation) { domNode.style.pointerEvents = 'none'; var removeDomNode = function () { if (domNode.parentNode) { domNode.parentNode.removeChild(domNode); } }; if (typeof exitAnimation === 'function') { exitAnimation(domNode, removeDomNode, vNode.properties); return; } else { transitions.exit(vNode.domNode, vNode.properties, exitAnimation, removeDomNode); return; } } } if (domNode.parentNode) { domNode.parentNode.removeChild(domNode); } }; var checkDistinguishable = function (childNodes, indexToCheck, parentVNode, operation) { var childNode = childNodes[indexToCheck]; if (childNode.vnodeSelector === '') { return; // Text nodes need not be distinguishable } var properties = childNode.properties; var key = properties ? properties.key === undefined ? properties.bind : properties.key : undefined; if (!key) { for (var i = 0; i < childNodes.length; i++) { if (i !== indexToCheck) { var node = childNodes[i]; if (same(node, childNode)) { if (operation === 'added') { throw new Error(parentVNode.vnodeSelector + ' had a ' + childNode.vnodeSelector + ' child ' + 'added, but there is now more than one. You must add unique key properties to make them distinguishable.'); } else { throw new Error(parentVNode.vnodeSelector + ' had a ' + childNode.vnodeSelector + ' child ' + 'removed, but there were more than one. You must add unique key properties to make them distinguishable.'); } } } } } }; var createDom; var updateDom; var updateChildren = function (vnode, domNode, oldChildren, newChildren, projectionOptions) { if (oldChildren === newChildren) { return false; } oldChildren = oldChildren || emptyArray; newChildren = newChildren || emptyArray; var oldChildrenLength = oldChildren.length; var newChildrenLength = newChildren.length; var transitions = projectionOptions.transitions; var oldIndex = 0; var newIndex = 0; var i; var textUpdated = false; while (newIndex < newChildrenLength) { var oldChild = oldIndex < oldChildrenLength ? oldChildren[oldIndex] : undefined; var newChild = newChildren[newIndex]; if (oldChild !== undefined && same(oldChild, newChild)) { textUpdated = updateDom(oldChild, newChild, projectionOptions) || textUpdated; oldIndex++; } else { var findOldIndex = findIndexOfChild(oldChildren, newChild, oldIndex + 1); if (findOldIndex >= 0) { // Remove preceding missing children for (i = oldIndex; i < findOldIndex; i++) { nodeToRemove(oldChildren[i], transitions); checkDistinguishable(oldChildren, i, vnode, 'removed'); } textUpdated = updateDom(oldChildren[findOldIndex], newChild, projectionOptions) || textUpdated; oldIndex = findOldIndex + 1; } else { // New child createDom(newChild, domNode, oldIndex < oldChildrenLength ? oldChildren[oldIndex].domNode : undefined, projectionOptions); nodeAdded(newChild, transitions); checkDistinguishable(newChildren, newIndex, vnode, 'added'); } } newIndex++; } if (oldChildrenLength > oldIndex) { // Remove child fragments for (i = oldIndex; i < oldChildrenLength; i++) { nodeToRemove(oldChildren[i], transitions); checkDistinguishable(oldChildren, i, vnode, 'removed'); } } return textUpdated; }; var addChildren = function (domNode, children, projectionOptions) { if (!children) { return; } for (var i = 0; i < children.length; i++) { createDom(children[i], domNode, undefined, projectionOptions); } }; var initPropertiesAndChildren = function (domNode, vnode, projectionOptions) { addChildren(domNode, vnode.children, projectionOptions); // children before properties, needed for value property of . if (vnode.text) { domNode.textContent = vnode.text; } setProperties(domNode, vnode.properties, projectionOptions); if (vnode.properties && vnode.properties.afterCreate) { vnode.properties.afterCreate(domNode, projectionOptions, vnode.vnodeSelector, vnode.properties, vnode.children); } }; createDom = function (vnode, parentNode, insertBefore, projectionOptions) { var domNode, i, c, start = 0, type, found; var vnodeSelector = vnode.vnodeSelector; if (vnodeSelector === '') { domNode = vnode.domNode = document.createTextNode(vnode.text); if (insertBefore !== undefined) { parentNode.insertBefore(domNode, insertBefore); } else { parentNode.appendChild(domNode); } } else { for (i = 0; i <= vnodeSelector.length; ++i) { c = vnodeSelector.charAt(i); if (i === vnodeSelector.length || c === '.' || c === '#') { type = vnodeSelector.charAt(start - 1); found = vnodeSelector.slice(start, i); if (type === '.') { domNode.classList.add(found); } else if (type === '#') { domNode.id = found; } else { if (found === 'svg') { projectionOptions = extend(projectionOptions, { namespace: NAMESPACE_SVG }); } if (projectionOptions.namespace !== undefined) { domNode = vnode.domNode = document.createElementNS(projectionOptions.namespace, found); } else { domNode = vnode.domNode = document.createElement(found); } if (insertBefore !== undefined) { parentNode.insertBefore(domNode, insertBefore); } else { parentNode.appendChild(domNode); } } start = i + 1; } } initPropertiesAndChildren(domNode, vnode, projectionOptions); } }; updateDom = function (previous, vnode, projectionOptions) { var domNode = previous.domNode; var textUpdated = false; if (previous === vnode) { return false; // By contract, VNode objects may not be modified anymore after passing them to maquette } var updated = false; if (vnode.vnodeSelector === '') { if (vnode.text !== previous.text) { var newVNode = document.createTextNode(vnode.text); domNode.parentNode.replaceChild(newVNode, domNode); vnode.domNode = newVNode; textUpdated = true; return textUpdated; } } else { if (vnode.vnodeSelector.lastIndexOf('svg', 0) === 0) { projectionOptions = extend(projectionOptions, { namespace: NAMESPACE_SVG }); } if (previous.text !== vnode.text) { updated = true; if (vnode.text === undefined) { domNode.removeChild(domNode.firstChild); // the only textnode presumably } else { domNode.textContent = vnode.text; } } updated = updateChildren(vnode, domNode, previous.children, vnode.children, projectionOptions) || updated; updated = updateProperties(domNode, previous.properties, vnode.properties, projectionOptions) || updated; if (vnode.properties && vnode.properties.afterUpdate) { vnode.properties.afterUpdate(domNode, projectionOptions, vnode.vnodeSelector, vnode.properties, vnode.children); } } if (updated && vnode.properties && vnode.properties.updateAnimation) { vnode.properties.updateAnimation(domNode, vnode.properties, previous.properties); } vnode.domNode = previous.domNode; return textUpdated; }; var createProjection = function (vnode, projectionOptions) { return { update: function (updatedVnode) { if (vnode.vnodeSelector !== updatedVnode.vnodeSelector) { throw new Error('The selector for the root VNode may not be changed. (consider using dom.merge and add one extra level to the virtual DOM)'); } updateDom(vnode, updatedVnode, projectionOptions); vnode = updatedVnode; }, domNode: vnode.domNode }; }; ; // The other two parameters are not added here, because the Typescript compiler creates surrogate code for desctructuring 'children'. exports.h = function (selector) { var properties = arguments[1]; if (typeof selector !== 'string') { throw new Error(); } var childIndex = 1; if (properties && !properties.hasOwnProperty('vnodeSelector') && !Array.isArray(properties) && typeof properties === 'object') { childIndex = 2; } else { // Optional properties argument was omitted properties = undefined; } var text = undefined; var children = undefined; var argsLength = arguments.length; // Recognize a common special case where there is only a single text node if (argsLength === childIndex + 1) { var onlyChild = arguments[childIndex]; if (typeof onlyChild === 'string') { text = onlyChild; } else if (onlyChild !== undefined && onlyChild.length === 1 && typeof onlyChild[0] === 'string') { text = onlyChild[0]; } } if (text === undefined) { children = []; for (; childIndex < arguments.length; childIndex++) { var child = arguments[childIndex]; if (child === null || child === undefined) { continue; } else if (Array.isArray(child)) { appendChildren(selector, child, children); } else if (child.hasOwnProperty('vnodeSelector')) { children.push(child); } else { children.push(toTextVNode(child)); } } } return { vnodeSelector: selector, properties: properties, children: children, text: text === '' ? undefined : text, domNode: null }; }; /** * Contains simple low-level utility functions to manipulate the real DOM. */ exports.dom = { /** * Creates a real DOM tree from `vnode`. The [[Projection]] object returned will contain the resulting DOM Node in * its [[Projection.domNode|domNode]] property. * This is a low-level method. Users wil typically use a [[Projector]] instead. * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] * objects may only be rendered once. * @param projectionOptions - Options to be used to create and update the projection. * @returns The [[Projection]] which also contains the DOM Node that was created. */ create: function (vnode, projectionOptions) { projectionOptions = applyDefaultProjectionOptions(projectionOptions); createDom(vnode, document.createElement('div'), undefined, projectionOptions); return createProjection(vnode, projectionOptions); }, /** * Appends a new childnode to the DOM which is generated from a [[VNode]]. * This is a low-level method. Users wil typically use a [[Projector]] instead. * @param parentNode - The parent node for the new childNode. * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] * objects may only be rendered once. * @param projectionOptions - Options to be used to create and update the [[Projection]]. * @returns The [[Projection]] that was created. */ append: function (parentNode, vnode, projectionOptions) { projectionOptions = applyDefaultProjectionOptions(projectionOptions); createDom(vnode, parentNode, undefined, projectionOptions); return createProjection(vnode, projectionOptions); }, /** * Inserts a new DOM node which is generated from a [[VNode]]. * This is a low-level method. Users wil typically use a [[Projector]] instead. * @param beforeNode - The node that the DOM Node is inserted before. * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. * NOTE: [[VNode]] objects may only be rendered once. * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]]. * @returns The [[Projection]] that was created. */ insertBefore: function (beforeNode, vnode, projectionOptions) { projectionOptions = applyDefaultProjectionOptions(projectionOptions); createDom(vnode, beforeNode.parentNode, beforeNode, projectionOptions); return createProjection(vnode, projectionOptions); }, /** * Merges a new DOM node which is generated from a [[VNode]] with an existing DOM Node. * This means that the virtual DOM and the real DOM will have one overlapping element. * Therefore the selector for the root [[VNode]] will be ignored, but its properties and children will be applied to the Element provided. * This is a low-level method. Users wil typically use a [[Projector]] instead. * @param domNode - The existing element to adopt as the root of the new virtual DOM. Existing attributes and childnodes are preserved. * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] objects * may only be rendered once. * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]]. * @returns The [[Projection]] that was created. */ merge: function (element, vnode, projectionOptions) { projectionOptions = applyDefaultProjectionOptions(projectionOptions); vnode.domNode = element; initPropertiesAndChildren(element, vnode, projectionOptions); return createProjection(vnode, projectionOptions); } }; /** * Creates a [[CalculationCache]] object, useful for caching [[VNode]] trees. * In practice, caching of [[VNode]] trees is not needed, because achieving 60 frames per second is almost never a problem. * For more information, see [[CalculationCache]]. * * @param The type of the value that is cached. */ exports.createCache = function () { var cachedInputs = undefined; var cachedOutcome = undefined; var result = { invalidate: function () { cachedOutcome = undefined; cachedInputs = undefined; }, result: function (inputs, calculation) { if (cachedInputs) { for (var i = 0; i < inputs.length; i++) { if (cachedInputs[i] !== inputs[i]) { cachedOutcome = undefined; } } } if (!cachedOutcome) { cachedOutcome = calculation(); cachedInputs = inputs; } return cachedOutcome; } }; return result; }; /** * Creates a {@link Mapping} instance that keeps an array of result objects synchronized with an array of source objects. * See {@link http://maquettejs.org/docs/arrays.html|Working with arrays}. * * @param The type of source items. A database-record for instance. * @param The type of target items. A [[Component]] for instance. * @param getSourceKey `function(source)` that must return a key to identify each source object. The result must either be a string or a number. * @param createResult `function(source, index)` that must create a new result object from a given source. This function is identical * to the `callback` argument in `Array.map(callback)`. * @param updateResult `function(source, target, index)` that updates a result to an updated source. */ exports.createMapping = function (getSourceKey, createResult, updateResult) { var keys = []; var results = []; return { results: results, map: function (newSources) { var newKeys = newSources.map(getSourceKey); var oldTargets = results.slice(); var oldIndex = 0; for (var i = 0; i < newSources.length; i++) { var source = newSources[i]; var sourceKey = newKeys[i]; if (sourceKey === keys[oldIndex]) { results[i] = oldTargets[oldIndex]; updateResult(source, oldTargets[oldIndex], i); oldIndex++; } else { var found = false; for (var j = 1; j < keys.length; j++) { var searchIndex = (oldIndex + j) % keys.length; if (keys[searchIndex] === sourceKey) { results[i] = oldTargets[searchIndex]; updateResult(newSources[i], oldTargets[searchIndex], i); oldIndex = searchIndex + 1; found = true; break; } } if (!found) { results[i] = createResult(source, i); } } } results.length = newSources.length; keys = newKeys; } }; }; /** * Creates a [[Projector]] instance using the provided projectionOptions. * * For more information, see [[Projector]]. * * @param projectionOptions Options that influence how the DOM is rendered and updated. */ exports.createProjector = function (projectorOptions) { var projector; var projectionOptions = applyDefaultProjectionOptions(projectorOptions); projectionOptions.eventHandlerInterceptor = function (propertyName, eventHandler, domNode, properties) { return function () { // intercept function calls (event handlers) to do a render afterwards. projector.scheduleRender(); return eventHandler.apply(properties.bind || this, arguments); }; }; var renderCompleted = true; var scheduled; var stopped = false; var projections = []; var renderFunctions = []; // matches the projections array var doRender = function () { scheduled = undefined; if (!renderCompleted) { return; // The last render threw an error, it should be logged in the browser console. } renderCompleted = false; for (var i = 0; i < projections.length; i++) { var updatedVnode = renderFunctions[i](); projections[i].update(updatedVnode); } renderCompleted = true; }; projector = { scheduleRender: function () { if (!scheduled && !stopped) { scheduled = requestAnimationFrame(doRender); } }, stop: function () { if (scheduled) { cancelAnimationFrame(scheduled); scheduled = undefined; } stopped = true; }, resume: function () { stopped = false; renderCompleted = true; projector.scheduleRender(); }, append: function (parentNode, renderMaquetteFunction) { projections.push(exports.dom.append(parentNode, renderMaquetteFunction(), projectionOptions)); renderFunctions.push(renderMaquetteFunction); }, insertBefore: function (beforeNode, renderMaquetteFunction) { projections.push(exports.dom.insertBefore(beforeNode, renderMaquetteFunction(), projectionOptions)); renderFunctions.push(renderMaquetteFunction); }, merge: function (domNode, renderMaquetteFunction) { projections.push(exports.dom.merge(domNode, renderMaquetteFunction(), projectionOptions)); renderFunctions.push(renderMaquetteFunction); }, replace: function (domNode, renderMaquetteFunction) { var vnode = renderMaquetteFunction(); createDom(vnode, domNode.parentNode, domNode, projectionOptions); domNode.parentNode.removeChild(domNode); projections.push(createProjection(vnode, projectionOptions)); renderFunctions.push(renderMaquetteFunction); }, detach: function (renderMaquetteFunction) { for (var i = 0; i < renderFunctions.length; i++) { if (renderFunctions[i] === renderMaquetteFunction) { renderFunctions.splice(i, 1); return projections.splice(i, 1)[0]; } } throw new Error('renderMaquetteFunction was not found'); } }; return projector; }; })); ================================================ FILE: plugins/UiFileManager/media/list.html ================================================ List - ZeroNet
    ================================================ FILE: plugins/UiPluginManager/UiPluginManagerPlugin.py ================================================ import io import os import json import shutil import time from Plugin import PluginManager from Config import config from Debug import Debug from Translate import Translate from util.Flag import flag plugin_dir = os.path.dirname(__file__) if "_" not in locals(): _ = Translate(plugin_dir + "/languages/") # Convert non-str,int,float values to str in a dict def restrictDictValues(input_dict): allowed_types = (int, str, float) return { key: val if type(val) in allowed_types else str(val) for key, val in input_dict.items() } @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object): def actionWrapper(self, path, extra_headers=None): if path.strip("/") != "Plugins": return super(UiRequestPlugin, self).actionWrapper(path, extra_headers) if not extra_headers: extra_headers = {} script_nonce = self.getScriptNonce() self.sendHeader(extra_headers=extra_headers, script_nonce=script_nonce) site = self.server.site_manager.get(config.homepage) return iter([super(UiRequestPlugin, self).renderWrapper( site, path, "uimedia/plugins/plugin_manager/plugin_manager.html", "Plugin Manager", extra_headers, show_loadingscreen=False, script_nonce=script_nonce )]) def actionUiMedia(self, path, *args, **kwargs): if path.startswith("/uimedia/plugins/plugin_manager/"): file_path = path.replace("/uimedia/plugins/plugin_manager/", plugin_dir + "/media/") if config.debug and (file_path.endswith("all.js") or file_path.endswith("all.css")): # If debugging merge *.css to all.css and *.js to all.js from Debug import DebugMedia DebugMedia.merge(file_path) if file_path.endswith("js"): data = _.translateData(open(file_path).read(), mode="js").encode("utf8") elif file_path.endswith("html"): data = _.translateData(open(file_path).read(), mode="html").encode("utf8") else: data = open(file_path, "rb").read() return self.actionFile(file_path, file_obj=io.BytesIO(data), file_size=len(data)) else: return super(UiRequestPlugin, self).actionUiMedia(path) @PluginManager.registerTo("UiWebsocket") class UiWebsocketPlugin(object): @flag.admin def actionPluginList(self, to): plugins = [] for plugin in PluginManager.plugin_manager.listPlugins(list_disabled=True): plugin_info_path = plugin["dir_path"] + "/plugin_info.json" plugin_info = {} if os.path.isfile(plugin_info_path): try: plugin_info = json.load(open(plugin_info_path)) except Exception as err: self.log.error( "Error loading plugin info for %s: %s" % (plugin["name"], Debug.formatException(err)) ) if plugin_info: plugin_info = restrictDictValues(plugin_info) # For security reasons don't allow complex values plugin["info"] = plugin_info if plugin["source"] != "builtin": plugin_site = self.server.sites.get(plugin["source"]) if plugin_site: try: plugin_site_info = plugin_site.storage.loadJson(plugin["inner_path"] + "/plugin_info.json") plugin_site_info = restrictDictValues(plugin_site_info) plugin["site_info"] = plugin_site_info plugin["site_title"] = plugin_site.content_manager.contents["content.json"].get("title") plugin_key = "%s/%s" % (plugin["source"], plugin["inner_path"]) plugin["updated"] = plugin_key in PluginManager.plugin_manager.plugins_updated except Exception: pass plugins.append(plugin) return {"plugins": plugins} @flag.admin @flag.no_multiuser def actionPluginConfigSet(self, to, source, inner_path, key, value): plugin_manager = PluginManager.plugin_manager plugins = plugin_manager.listPlugins(list_disabled=True) plugin = None for item in plugins: if item["source"] == source and item["inner_path"] in (inner_path, "disabled-" + inner_path): plugin = item break if not plugin: return {"error": "Plugin not found"} config_source = plugin_manager.config.setdefault(source, {}) config_plugin = config_source.setdefault(inner_path, {}) if key in config_plugin and value is None: del config_plugin[key] else: config_plugin[key] = value plugin_manager.saveConfig() return "ok" def pluginAction(self, action, address, inner_path): site = self.server.sites.get(address) plugin_manager = PluginManager.plugin_manager # Install/update path should exists if action in ("add", "update", "add_request"): if not site: raise Exception("Site not found") if not site.storage.isDir(inner_path): raise Exception("Directory not found on the site") try: plugin_info = site.storage.loadJson(inner_path + "/plugin_info.json") plugin_data = (plugin_info["rev"], plugin_info["description"], plugin_info["name"]) except Exception as err: raise Exception("Invalid plugin_info.json: %s" % Debug.formatExceptionMessage(err)) source_path = site.storage.getPath(inner_path) target_path = plugin_manager.path_installed_plugins + "/" + address + "/" + inner_path plugin_config = plugin_manager.config.setdefault(site.address, {}).setdefault(inner_path, {}) # Make sure plugin (not)installed if action in ("add", "add_request") and os.path.isdir(target_path): raise Exception("Plugin already installed") if action in ("update", "remove") and not os.path.isdir(target_path): raise Exception("Plugin not installed") # Do actions if action == "add": shutil.copytree(source_path, target_path) plugin_config["date_added"] = int(time.time()) plugin_config["rev"] = plugin_info["rev"] plugin_config["enabled"] = True if action == "update": shutil.rmtree(target_path) shutil.copytree(source_path, target_path) plugin_config["rev"] = plugin_info["rev"] plugin_config["date_updated"] = time.time() if action == "remove": del plugin_manager.config[address][inner_path] shutil.rmtree(target_path) def doPluginAdd(self, to, inner_path, res): if not res: return None self.pluginAction("add", self.site.address, inner_path) PluginManager.plugin_manager.saveConfig() self.cmd( "confirm", ["Plugin installed!
    You have to restart the client to load the plugin", "Restart"], lambda res: self.actionServerShutdown(to, restart=True) ) self.response(to, "ok") @flag.no_multiuser def actionPluginAddRequest(self, to, inner_path): self.pluginAction("add_request", self.site.address, inner_path) plugin_info = self.site.storage.loadJson(inner_path + "/plugin_info.json") warning = "Warning!
    Plugins has the same permissions as the ZeroNet client.
    " warning += "Do not install it if you don't trust the developer.
    " self.cmd( "confirm", ["Install new plugin: %s?
    %s" % (plugin_info["name"], warning), "Trust & Install"], lambda res: self.doPluginAdd(to, inner_path, res) ) @flag.admin @flag.no_multiuser def actionPluginRemove(self, to, address, inner_path): self.pluginAction("remove", address, inner_path) PluginManager.plugin_manager.saveConfig() return "ok" @flag.admin @flag.no_multiuser def actionPluginUpdate(self, to, address, inner_path): self.pluginAction("update", address, inner_path) PluginManager.plugin_manager.saveConfig() PluginManager.plugin_manager.plugins_updated["%s/%s" % (address, inner_path)] = True return "ok" ================================================ FILE: plugins/UiPluginManager/__init__.py ================================================ from . import UiPluginManagerPlugin ================================================ FILE: plugins/UiPluginManager/media/css/PluginManager.css ================================================ body { background-color: #EDF2F5; font-family: Roboto, 'Segoe UI', Arial, 'Helvetica Neue'; margin: 0px; padding: 0px; backface-visibility: hidden; } h1, h2, h3, h4 { font-family: 'Roboto', Arial, sans-serif; font-weight: 200; font-size: 30px; margin: 0px; padding: 0px } h1 { background: linear-gradient(33deg,#af3bff,#0d99c9); color: white; padding: 16px 30px; } h2 { margin-top: 10px; } h3 { font-weight: normal } h4 { font-size: 19px; font-weight: lighter; margin-right: 100px; margin-top: 30px; } a { color: #9760F9 } a:hover { text-decoration: none } .link { background-color: transparent; outline: 5px solid transparent; transition: all 0.3s } .link:active { background-color: #EFEFEF; outline: 5px solid #EFEFEF; transition: none } .content { max-width: 800px; margin: auto; background-color: white; padding: 60px 20px; box-sizing: border-box; padding-bottom: 150px; } .section { margin: 0px 10%; } .plugins { font-size: 19px; margin-top: 25px; margin-bottom: 75px; } .plugin { transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); position: relative; padding-bottom: 20px; padding-top: 10px; } .plugin.hidden { opacity: 0; height: 0px; padding: 0px; } .plugin .title { display: inline-block; line-height: 36px; } .plugin .title h3 { font-size: 20px; font-weight: lighter; margin-right: 100px; } .plugin .title .version { font-size: 70%; margin-left: 5px; } .plugin .title .version .version-latest { color: #2ecc71; font-weight: normal; } .plugin .title .version .version-missing { color: #ffa200; font-weight: normal; } .plugin .title .version .version-update { padding: 0px 15px; margin-left: 5px; line-height: 28px; } .plugin .description { font-size: 14px; color: #666; line-height: 24px; } .plugin .description .source { color: #999; font-size: 90%; } .plugin .description .source a { color: #666; } .plugin .value { display: inline-block; white-space: nowrap; } .plugin .value-right { right: 0px; position: absolute; } .plugin .value-fullwidth { width: 100% } .plugin .marker { font-weight: bold; text-decoration: none; font-size: 25px; position: absolute; padding: 2px 15px; line-height: 32px; opacity: 0; pointer-events: none; transition: all 0.6s; transform: scale(2); color: #9760F9; } .plugin .marker.visible { opacity: 1; pointer-events: all; transform: scale(1); } .plugin .marker.changed { color: #2ecc71; } .plugin .marker.pending { color: #ffa200; } .input-text, .input-select { padding: 8px 18px; border: 1px solid #CCC; border-radius: 3px; font-size: 17px; box-sizing: border-box; } .input-text:focus, .input-select:focus { border: 1px solid #3396ff; outline: none; } .input-textarea { overflow-x: auto; overflow-y: hidden; white-space: pre; line-height: 22px; } .input-select { width: initial; font-size: 14px; padding-right: 10px; padding-left: 10px; } .value-right .input-text { text-align: right; width: 100px; } .value-fullwidth .input-text { width: 100%; font-size: 14px; font-family: 'Segoe UI', Arial, 'Helvetica Neue'; } .value-fullwidth { margin-top: 10px; } /* Checkbox */ .checkbox-skin { background-color: #CCC; width: 50px; height: 24px; border-radius: 15px; transition: all 0.3s ease-in-out; display: inline-block; } .checkbox-skin:before { content: ""; position: relative; width: 20px; background-color: white; height: 20px; display: block; border-radius: 100%; margin-top: 2px; margin-left: 2px; transition: all 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86); } .checkbox { font-size: 14px; font-weight: normal; display: inline-block; cursor: pointer; margin-top: 5px; } .checkbox .title { display: inline; line-height: 30px; vertical-align: 4px; margin-left: 11px } .checkbox.checked .checkbox-skin:before { margin-left: 27px; } .checkbox.checked .checkbox-skin { background-color: #2ECC71 } /* Bottom */ .bottom { width: 100%; text-align: center; background-color: #ffffffde; padding: 25px; bottom: -120px; -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); position: fixed; backface-visibility: hidden; box-sizing: border-box; } .bottom-content { max-width: 750px; width: 100%; margin: 0px auto; } .bottom .button { float: right; } .bottom.visible { bottom: 0px; box-shadow: 0px 0px 35px #dcdcdc; } .bottom .title { padding: 10px 10px; color: #363636; float: left; text-transform: uppercase; letter-spacing: 1px; } .bottom .title:before { content: "•"; display: inline-block; color: #2ecc71; font-size: 31px; vertical-align: -7px; margin-right: 8px; line-height: 25px; } .bottom-restart .title:before { color: #ffa200; } .animate { transition: all 0.3s ease-out !important; } .animate-back { transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important; } .animate-inout { transition: all 0.6s cubic-bezier(0.77, 0, 0.175, 1) !important; } ================================================ FILE: plugins/UiPluginManager/media/css/all.css ================================================ /* ---- PluginManager.css ---- */ body { background-color: #EDF2F5; font-family: Roboto, 'Segoe UI', Arial, 'Helvetica Neue'; margin: 0px; padding: 0px; -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; -o-backface-visibility: hidden; -ms-backface-visibility: hidden; backface-visibility: hidden ; } h1, h2, h3, h4 { font-family: 'Roboto', Arial, sans-serif; font-weight: 200; font-size: 30px; margin: 0px; padding: 0px } h1 { background: -webkit-linear-gradient(33deg,#af3bff,#0d99c9);background: -moz-linear-gradient(33deg,#af3bff,#0d99c9);background: -o-linear-gradient(33deg,#af3bff,#0d99c9);background: -ms-linear-gradient(33deg,#af3bff,#0d99c9);background: linear-gradient(33deg,#af3bff,#0d99c9); color: white; padding: 16px 30px; } h2 { margin-top: 10px; } h3 { font-weight: normal } h4 { font-size: 19px; font-weight: lighter; margin-right: 100px; margin-top: 30px; } a { color: #9760F9 } a:hover { text-decoration: none } .link { background-color: transparent; outline: 5px solid transparent; -webkit-transition: all 0.3s ; -moz-transition: all 0.3s ; -o-transition: all 0.3s ; -ms-transition: all 0.3s ; transition: all 0.3s } .link:active { background-color: #EFEFEF; outline: 5px solid #EFEFEF; -webkit-transition: none ; -moz-transition: none ; -o-transition: none ; -ms-transition: none ; transition: none } .content { max-width: 800px; margin: auto; background-color: white; padding: 60px 20px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; padding-bottom: 150px; } .section { margin: 0px 10%; } .plugins { font-size: 19px; margin-top: 25px; margin-bottom: 75px; } .plugin { -webkit-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); -moz-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); -o-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); -ms-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1) ; position: relative; padding-bottom: 20px; padding-top: 10px; } .plugin.hidden { opacity: 0; height: 0px; padding: 0px; } .plugin .title { display: inline-block; line-height: 36px; } .plugin .title h3 { font-size: 20px; font-weight: lighter; margin-right: 100px; } .plugin .title .version { font-size: 70%; margin-left: 5px; } .plugin .title .version .version-latest { color: #2ecc71; font-weight: normal; } .plugin .title .version .version-missing { color: #ffa200; font-weight: normal; } .plugin .title .version .version-update { padding: 0px 15px; margin-left: 5px; line-height: 28px; } .plugin .description { font-size: 14px; color: #666; line-height: 24px; } .plugin .description .source { color: #999; font-size: 90%; } .plugin .description .source a { color: #666; } .plugin .value { display: inline-block; white-space: nowrap; } .plugin .value-right { right: 0px; position: absolute; } .plugin .value-fullwidth { width: 100% } .plugin .marker { font-weight: bold; text-decoration: none; font-size: 25px; position: absolute; padding: 2px 15px; line-height: 32px; opacity: 0; pointer-events: none; -webkit-transition: all 0.6s; -moz-transition: all 0.6s; -o-transition: all 0.6s; -ms-transition: all 0.6s; transition: all 0.6s ; -webkit-transform: scale(2); -moz-transform: scale(2); -o-transform: scale(2); -ms-transform: scale(2); transform: scale(2) ; color: #9760F9; } .plugin .marker.visible { opacity: 1; pointer-events: all; -webkit-transform: scale(1); -moz-transform: scale(1); -o-transform: scale(1); -ms-transform: scale(1); transform: scale(1) ; } .plugin .marker.changed { color: #2ecc71; } .plugin .marker.pending { color: #ffa200; } .input-text, .input-select { padding: 8px 18px; border: 1px solid #CCC; -webkit-border-radius: 3px; -moz-border-radius: 3px; -o-border-radius: 3px; -ms-border-radius: 3px; border-radius: 3px ; font-size: 17px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; } .input-text:focus, .input-select:focus { border: 1px solid #3396ff; outline: none; } .input-textarea { overflow-x: auto; overflow-y: hidden; white-space: pre; line-height: 22px; } .input-select { width: initial; font-size: 14px; padding-right: 10px; padding-left: 10px; } .value-right .input-text { text-align: right; width: 100px; } .value-fullwidth .input-text { width: 100%; font-size: 14px; font-family: 'Segoe UI', Arial, 'Helvetica Neue'; } .value-fullwidth { margin-top: 10px; } /* Checkbox */ .checkbox-skin { background-color: #CCC; width: 50px; height: 24px; -webkit-border-radius: 15px; -moz-border-radius: 15px; -o-border-radius: 15px; -ms-border-radius: 15px; border-radius: 15px ; -webkit-transition: all 0.3s ease-in-out; -moz-transition: all 0.3s ease-in-out; -o-transition: all 0.3s ease-in-out; -ms-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out ; display: inline-block; } .checkbox-skin:before { content: ""; position: relative; width: 20px; background-color: white; height: 20px; display: block; -webkit-border-radius: 100%; -moz-border-radius: 100%; -o-border-radius: 100%; -ms-border-radius: 100%; border-radius: 100% ; margin-top: 2px; margin-left: 2px; -webkit-transition: all 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86); -moz-transition: all 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86); -o-transition: all 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86); -ms-transition: all 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86); transition: all 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86) ; } .checkbox { font-size: 14px; font-weight: normal; display: inline-block; cursor: pointer; margin-top: 5px; } .checkbox .title { display: inline; line-height: 30px; vertical-align: 4px; margin-left: 11px } .checkbox.checked .checkbox-skin:before { margin-left: 27px; } .checkbox.checked .checkbox-skin { background-color: #2ECC71 } /* Bottom */ .bottom { width: 100%; text-align: center; background-color: #ffffffde; padding: 25px; bottom: -120px; -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); -webkit-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); -moz-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); -o-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); -ms-transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1); transition: all 0.8s cubic-bezier(0.86, 0, 0.07, 1) ; position: fixed; -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; -o-backface-visibility: hidden; -ms-backface-visibility: hidden; backface-visibility: hidden ; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; } .bottom-content { max-width: 750px; width: 100%; margin: 0px auto; } .bottom .button { float: right; } .bottom.visible { bottom: 0px; -webkit-box-shadow: 0px 0px 35px #dcdcdc; -moz-box-shadow: 0px 0px 35px #dcdcdc; -o-box-shadow: 0px 0px 35px #dcdcdc; -ms-box-shadow: 0px 0px 35px #dcdcdc; box-shadow: 0px 0px 35px #dcdcdc ; } .bottom .title { padding: 10px 10px; color: #363636; float: left; text-transform: uppercase; letter-spacing: 1px; } .bottom .title:before { content: "•"; display: inline-block; color: #2ecc71; font-size: 31px; vertical-align: -7px; margin-right: 8px; line-height: 25px; } .bottom-restart .title:before { color: #ffa200; } .animate { -webkit-transition: all 0.3s ease-out !important; -moz-transition: all 0.3s ease-out !important; -o-transition: all 0.3s ease-out !important; -ms-transition: all 0.3s ease-out !important; transition: all 0.3s ease-out !important ; } .animate-back { -webkit-transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important; -moz-transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important; -o-transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important; -ms-transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important; transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important ; } .animate-inout { -webkit-transition: all 0.6s cubic-bezier(0.77, 0, 0.175, 1) !important; -moz-transition: all 0.6s cubic-bezier(0.77, 0, 0.175, 1) !important; -o-transition: all 0.6s cubic-bezier(0.77, 0, 0.175, 1) !important; -ms-transition: all 0.6s cubic-bezier(0.77, 0, 0.175, 1) !important; transition: all 0.6s cubic-bezier(0.77, 0, 0.175, 1) !important ; } /* ---- button.css ---- */ /* Button */ .button { background-color: #FFDC00; color: black; padding: 10px 20px; display: inline-block; background-position: left center; -webkit-border-radius: 2px; -moz-border-radius: 2px; -o-border-radius: 2px; -ms-border-radius: 2px; border-radius: 2px ; border-bottom: 2px solid #E8BE29; -webkit-transition: all 0.5s ease-out; -moz-transition: all 0.5s ease-out; -o-transition: all 0.5s ease-out; -ms-transition: all 0.5s ease-out; transition: all 0.5s ease-out ; text-decoration: none; } .button:hover { border-color: white; border-bottom: 2px solid #BD960C; -webkit-transition: none ; -moz-transition: none ; -o-transition: none ; -ms-transition: none ; transition: none ; background-color: #FDEB07 } .button:active { position: relative; top: 1px } .button.loading { color: rgba(0,0,0,0); background: #999 url(../img/loading.gif) no-repeat center center; -webkit-transition: all 0.5s ease-out ; -moz-transition: all 0.5s ease-out ; -o-transition: all 0.5s ease-out ; -ms-transition: all 0.5s ease-out ; transition: all 0.5s ease-out ; pointer-events: none; border-bottom: 2px solid #666 } .button.disabled { color: #DDD; background-color: #999; pointer-events: none; border-bottom: 2px solid #666 } /* ---- fonts.css ---- */ /* Base64 encoder: http://www.motobit.com/util/base64-decoder-encoder.asp */ /* Generated by Font Squirrel (http://www.fontsquirrel.com) on January 21, 2015 */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; src: local('Roboto'), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAGfcABIAAAAAx5wAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABHREVGAAABlAAAAEcAAABYB30Hd0dQT1MAAAHcAAAH8AAAFLywggk9R1NVQgAACcwAAACmAAABFMK7zVBPUy8yAAAKdAAAAFYAAABgoKexpmNtYXAAAArMAAADZAAABnjIFMucY3Z0IAAADjAAAABMAAAATCRBBuVmcGdtAAAOfAAAATsAAAG8Z/Rcq2dhc3AAAA+4AAAADAAAAAwACAATZ2x5ZgAAD8QAAE7fAACZfgdaOmpoZG14AABepAAAAJoAAAGo8AnZfGhlYWQAAF9AAAAANgAAADb4RqsOaGhlYQAAX3gAAAAgAAAAJAq6BzxobXR4AABfmAAAA4cAAAZwzpCM0GxvY2EAAGMgAAADKQAAAzowggjbbWF4cAAAZkwAAAAgAAAAIAPMAvluYW1lAABmbAAAAJkAAAEQEG8sqXBvc3QAAGcIAAAAEwAAACD/bQBkcHJlcAAAZxwAAAC9AAAA23Sgj+x4AQXBsQFBMQAFwHvRZg0bgEpnDXukA4AWYBvqv9O/E1RAUQ3NxcJSNM3A2lpsbcXBQZydxdVdPH3Fz1/RZSyZ5Ss9lqEL+AB4AWSOA4ydQRgAZ7a2bdu2bdu2bduI07hubF2s2gxqxbX+p7anzO5nIZCfkawkZ8/eA0dSfsa65QupPWf5rAU0Xzht5WI6kxMgihAy2GawQwY7BzkXzFq+mPLZJSAkO0NyVuEchXPXzjMfTU3eEJqGpv4IV0LrMD70DITBYWTcyh0Wh6LhdEgLR8O5UD3+U0wNP+I0/cv4OIvjvRlpHZ+SYvx/0uKd2YlP+t+TJHnBuWz/XPKmJP97x2f4U5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) format('woff'); } @font-face { font-family: 'Roboto'; font-style: normal; font-weight: bold; src: local('Roboto Medium'), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAEbcABAAAAAAfQwAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABHUE9TAAABbAAABOQAAAv2MtQEeUdTVUIAAAZQAAAAQQAAAFCyIrRQT1MvMgAABpQAAABXAAAAYLorAUBjbWFwAAAG7AAAAI8AAADEj/6wZGN2dCAAAAd8AAAAMAAAADAX3wLxZnBnbQAAB6wAAAE/AAABvC/mTqtnYXNwAAAI7AAAAAwAAAAMAAgAE2dseWYAAAj4AAA2eQAAYlxNsqlBaGVhZAAAP3QAAAA0AAAANve2KKdoaGVhAAA/qAAAAB8AAAAkDRcHFmhtdHgAAD/IAAACPAAAA3CPSUvWbG9jYQAAQgQAAAG6AAABusPVqwRtYXhwAABDwAAAACAAAAAgAwkC3m5hbWUAAEPgAAAAtAAAAU4XNjG1cG9zdAAARJQAAAF3AAACF7VLITZwcmVwAABGDAAAAM8AAAEuQJ9pDngBpJUDrCVbE0ZX9znX1ti2bdu2bU/w89nm1di2bdu2jXjqfWO7V1ajUru2Otk4QCD5qIRbqUqtRoT2aj+oDynwApjhwNN34fbsPKAPobrrDjggvbggAz21cOiHFyjoKeIpwkH3sHvRve4pxWVnojPdve7MdZY7e53zrq+bzL3r5nDzuTXcfm6iJ587Wa5U/lMuekp5hHv9Ge568okijyiFQ0F8CCSITGQhK9nITh7yUkDxQhSmKMUpQSlKU4bq1KExzWlBK9rwCZ/yGZ/zBV/yNd/wLd/xM7/yG7/zB3+SyFKWs4GNbGYLh/BSnBhKkI5SJCVR5iXs3j4iZGqZyX6nKNFUsq1UsSNUldVkDdnADtNIz8Z2mmZ2geZ2llbyE7X5VH4mP5dfyC/lCNUYKUfJ0XKMHCvHq8YEOVFOkpPlLNWeLefIuXKeXKg+FsnFcolcqr6Wy1XK36SxbpUOLWzxg/tsXJoSxlcWgw9FlVPcTlLCLlHKtpAovYruU/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Z3po3Y86yBYuWHHtvzYpVzT64kmnTug0fnTqX6LNPvvjmq+9K/PDLT7/98c9f/wU4EShYkBBhQvUoFSFcpChnLvTZ0qLVtgM72rTr0m1Ch06T4g0ZNvDk+ZMXLo08efk4RnZGDkZOhlQWv1AfH/bSvEwDA0cXEG1kYG7C4lpalM+Rll9apFdcWsBZklGUmgpisZeU54Pp/DwwHwBPQXTqAHgBLc4lXMVQFIDxe5+/Ke4uCXd3KLhLWsWdhvWynugFl7ieRu+dnsb5flD+V44+W03Pqkm96nSsSX3pwfbG8hyVafqKLY53NhRyi8/1/P8l1md6//6SRzsznWXcUiuTXQ3F3NJTfU3V3NRrJp2WrjUzN3sl06/thr54PYV7+IYaQ1++jlly8+AO2iz5W4IT8OEJIqi29NXrGHhwB65DLfxAtSN5HvgQQgRjjiSfQJDDoBz5e4AA3BwJtOVAHgtBBGGeRNsK5DYGd8IvM61XFAA=) format('woff'), } @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 200; src: local('Roboto Light'), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAEScABMAAAAAdFQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABqAAAABwAAAAcXzC5yUdERUYAAAHEAAAAHgAAACAAzgAER1BPUwAAAeQAAAVxAAANIkezYOlHU1VCAAAHWAAAACwAAAAwuP+4/k9TLzIAAAeEAAAAVgAAAGC3ouDrY21hcAAAB9wAAAG+AAACioYHy/VjdnQgAAAJnAAAADQAAAA0CnAOGGZwZ20AAAnQAAABsQAAAmVTtC+nZ2FzcAAAC4QAAAAIAAAACAAAABBnbHlmAAALjAAAMaIAAFTUMXgLR2hlYWQAAD0wAAAAMQAAADYBsFYkaGhlYQAAPWQAAAAfAAAAJA7cBhlobXR4AAA9hAAAAeEAAAKEbjk+b2xvY2EAAD9oAAABNgAAAUQwY0cibWF4cAAAQKAAAAAgAAAAIAG+AZluYW1lAABAwAAAAZAAAANoT6qDDHBvc3QAAEJQAAABjAAAAkto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GvIVHod2ApZaNwyELEGoBRiyvItipL4wEcaUYMnyyUy+ZWQbn9ab4CDsF8FFODeCh3CvBB/hnQgBwq8IISL4V40RofyBQ0TTUkwj7OhEtUMmyHSjGSOTuWY2rI32PdNJPiQZL3TSQq4+STRSagAAAAFR3VVMAAA=) format('woff'); } ================================================ FILE: plugins/UiPluginManager/media/css/button.css ================================================ /* Button */ .button { background-color: #FFDC00; color: black; padding: 10px 20px; display: inline-block; background-position: left center; border-radius: 2px; border-bottom: 2px solid #E8BE29; transition: all 0.5s ease-out; text-decoration: none; } .button:hover { border-color: white; border-bottom: 2px solid #BD960C; transition: none ; background-color: #FDEB07 } .button:active { position: relative; top: 1px } .button.loading { color: rgba(0,0,0,0); background: #999 url(../img/loading.gif) no-repeat center center; transition: all 0.5s ease-out ; pointer-events: none; border-bottom: 2px solid #666 } .button.disabled { color: #DDD; background-color: #999; pointer-events: none; border-bottom: 2px solid #666 } ================================================ FILE: plugins/UiPluginManager/media/css/fonts.css ================================================ /* Base64 encoder: http://www.motobit.com/util/base64-decoder-encoder.asp */ /* Generated by Font Squirrel (http://www.fontsquirrel.com) on January 21, 2015 */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; src: local('Roboto'), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAGfcABIAAAAAx5wAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABHREVGAAABlAAAAEcAAABYB30Hd0dQT1MAAAHcAAAH8AAAFLywggk9R1NVQgAACcwAAACmAAABFMK7zVBPUy8yAAAKdAAAAFYAAABgoKexpmNtYXAAAArMAAADZAAABnjIFMucY3Z0IAAADjAAAABMAAAATCRBBuVmcGdtAAAOfAAAATsAAAG8Z/Rcq2dhc3AAAA+4AAAADAAAAAwACAATZ2x5ZgAAD8QAAE7fAACZfgdaOmpoZG14AABepAAAAJoAAAGo8AnZfGhlYWQAAF9AAAAANgAAADb4RqsOaGhlYQAAX3gAAAAgAAAAJAq6BzxobXR4AABfmAAAA4cAA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4AAAIAAhQABgABeAFdjjN7AwAYhN/a3evuZTAlW2x7im3+/VyM5zPvgCtynHFyfsMJ97DOT3lUtcrP9vrne/kF3zyv80teca3zRxIUidGT7zGWxahQY0KbAkNSVORHNDTp8omRX/4lBok8VtRbZuaDLz9Hf+qMJX0s/ElmS/nVpC8raVpR1WNITdM2DfUqdBlRkf0RwIsdJyHi8j8rFnNKFSE1AAAAeAFjYGYAg/9ZDCkMWAAAKh8B0QB4AdvAo72BQZthEyMfkzbjJn5GILmd38pAVVqAgUObYTujh7WeogiQuZ0pwsNCA8xiDnI2URUDsVjifG20JUEsVjMdJUl+EIutMNbNSBrEYp9YHmOlDGJx1KUHWEqBWJwhrmZq4iAWV1mCt5ksiMXdnOIHUcdzc1NXsg2IxSsiyMvJBmLx2RipywiCHLNJgIsd6FgF19pMCZdNBkKMxZs2iACJABHGkk0NIKJAhLF0E78MUCxfhrEUAOkaMm8AAAA=) format('woff'); } @font-face { font-family: 'Roboto'; font-style: normal; font-weight: bold; src: local('Roboto Medium'), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAEbcABAAAAAAfQwAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABHUE9TAAABbAAABOQAAAv2MtQEeUdTVUIAAAZQAAAAQQAAAFCyIrRQT1MvMgAABpQAAABXAAAAYLorAUBjbWFwAAAG7AAAAI8AAADEj/6wZGN2dCAAAAd8AAAAMAAAADAX3wLxZnBnbQAAB6wAAAE/AAABvC/mTqtnYXNwAAAI7AAAAAwAAAAMAAgAE2dseWYAAAj4AAA2eQAAYlxNsqlBaGVhZAAAP3QAAAA0AAAANve2KKdoaGVhAAA/qAAAAB8AAAAkDRcHFmhtdHgAAD/IAAACPAAAA3CPSUvWbG9jYQAAQgQAAAG6AAABusPVqwRtYXhwAABDwAAAACAAAAAgAwkC3m5hbWUAAEPgAAAAtAAAAU4XNjG1cG9zdAAARJQAAAF3AAACF7VLITZwcmVwAABGDAAAAM8AAAEuQJ9pDngBpJUDrCVb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YBuBnt+YBMsqwjkfpsLY9qmL7Bj1Hb1pbP7+X6HOmy7/uAf8EeJn/GxV4mbvEjL/M3R88Pabfsr0Cbl7mUQdu7am4VNFUEbQp5VpOS8melIyWogt1yyoqMopSkn+kkmIiouKOpNQ15FSUBUWFREWe1ISoWcE378e+mU99WU1NVUlhYZ2nHXKh6sKVrJSQirqMsKKcKyllDSkNYRtWzVu0Zd+iGTEhkXtU0y0IeAFswQOWQgEAAMDZv7Zt27ZtZddTZ+4udYFmBEC5qKCaEjWBQK069Ro0atKsRas27Tp06tKtR68+/QYMGjJsxKgx4yZMmjJtxqw58xYsWrJsxao16zZs2rJtx649+w4cOnLsxKkz5y5cunLtxq079x48evLsxas37z58+vLtx68//0LCIqJi4hKSUtIyshWC4GErEAAAAOAs/3NtI+tluy7Ztm3zZZ6z69yMBuVixBqU50icNMkK1ap48kySXdGy3biVKl+CcYeuFalz786DMo1mTWvy2hsZ3po3Y86yBYuWHHtvzYpVzT64kmnTug0fnTqX6LNPvvjmq+9K/PDLT7/98c9f/wU4EShYkBBhQvUoFSFcpChnLvTZ0qLVtgM72rTr0m1Ch06T4g0ZNvDk+ZMXLo08efk4RnZGDkZOhlQWv1AfH/bSvEwDA0cXEG1kYG7C4lpalM+Rll9apFdcWsBZklGUmgpisZeU54Pp/DwwHwBPQXTqAHgBLc4lXMVQFIDxe5+/Ke4uCXd3KLhLWsWdhvWynugFl7ieRu+dnsb5flD+V44+W03Pqkm96nSsSX3pwfbG8hyVafqKLY53NhRyi8/1/P8l1md6//6SRzsznWXcUiuTXQ3F3NJTfU3V3NRrJp2WrjUzN3sl06/thr54PYV7+IYaQ1++jlly8+AO2iz5W4IT8OEJIqi29NXrGHhwB65DLfxAtSN5HvgQQgRjjiSfQJDDoBz5e4AA3BwJtOVAHgtBBGGeRNsK5DYGd8IvM61XFAA=) format('woff'), } @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 200; src: local('Roboto Light'), url(data:application/x-font-woff;charset=utf-8;base64,d09G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rFgxYYdBxVU4qSKamqoxUUdbjzU46WBRprwcYzjnKCZk5yihdOcoZWztHGO81ygnQ4u0sklNHT8dBEgSDcheujlMn1c4SrX6GeAMNe5QYQoMQa5yS1uc4e7DHGPYUYYZYz7PCDOOA+ZYJIpHvGYJ0wzwywJMfOK16zxjlXeSzkrvOUvH/jBHD/5RYrfpMmQY5kCz3nBS7GIVWxiZ4c/7IpDKqRSnFIl1VIjteKSOnGLR+rFyyc2+MIW3/jMJt/5KA1s81UapYk34rOk5gu5tG41FjOapkVKhjVlxDmcNhZTibyxMJ8wlp3ZQy1+qBkHW3Hfv3dQqSv9yi5lQBlUditDyh5lrzJcUld3dd3xNJMy8nPJxFK6NPLHSgZj5qiRzxZLdO+P/+/adfZ42j3OKRLCQBAF0Bkm+0JWE0Ex6LkCksTEUKikiuIGWCwYcHABOEQHReE5BYcJHWjG9fst/n/w/gj8zGpwlk3H+aXtKks1M4jbGvIVHod2ApZaNwyELEGoBRiyvItipL4wEcaUYMnyyUy+ZWQbn9ab4CDsF8FFODeCh3CvBB/hnQgBwq8IISL4V40RofyBQ0TTUkwj7OhEtUMmyHSjGSOTuWY2rI32PdNJPiQZL3TSQq4+STRSagAAAAFR3VVMAAA=) format('woff'); } ================================================ FILE: plugins/UiPluginManager/media/js/PluginList.coffee ================================================ class PluginList extends Class constructor: (plugins) -> @plugins = plugins savePluginStatus: (plugin, is_enabled) => Page.cmd "pluginConfigSet", [plugin.source, plugin.inner_path, "enabled", is_enabled], (res) => if res == "ok" Page.updatePlugins() else Page.cmd "wrapperNotification", ["error", res.error] Page.projector.scheduleRender() handleCheckboxChange: (e) => node = e.currentTarget plugin = node["data-plugin"] node.classList.toggle("checked") value = node.classList.contains("checked") @savePluginStatus(plugin, value) handleResetClick: (e) => node = e.currentTarget plugin = node["data-plugin"] @savePluginStatus(plugin, null) handleUpdateClick: (e) => node = e.currentTarget plugin = node["data-plugin"] node.classList.add("loading") Page.cmd "pluginUpdate", [plugin.source, plugin.inner_path], (res) => if res == "ok" Page.cmd "wrapperNotification", ["done", "Plugin #{plugin.name} updated to latest version"] Page.updatePlugins() else Page.cmd "wrapperNotification", ["error", res.error] node.classList.remove("loading") return false handleDeleteClick: (e) => node = e.currentTarget plugin = node["data-plugin"] if plugin.loaded Page.cmd "wrapperNotification", ["info", "You can only delete plugin that are not currently active"] return false node.classList.add("loading") Page.cmd "wrapperConfirm", ["Delete #{plugin.name} plugin?", "Delete"], (res) => if not res node.classList.remove("loading") return false Page.cmd "pluginRemove", [plugin.source, plugin.inner_path], (res) => if res == "ok" Page.cmd "wrapperNotification", ["done", "Plugin #{plugin.name} deleted"] Page.updatePlugins() else Page.cmd "wrapperNotification", ["error", res.error] node.classList.remove("loading") return false render: -> h("div.plugins", @plugins.map (plugin) => if not plugin.info return descr = plugin.info.description plugin.info.default ?= "enabled" if plugin.info.default descr += " (default: #{plugin.info.default})" tag_version = "" tag_source = "" tag_delete = "" if plugin.source != "builtin" tag_update = "" if plugin.site_info?.rev if plugin.site_info.rev > plugin.info.rev tag_update = h("a.version-update.button", {href: "#Update+plugin", onclick: @handleUpdateClick, "data-plugin": plugin}, "Update to rev#{plugin.site_info.rev}" ) else tag_update = h("span.version-missing", "(unable to get latest vesion: update site missing)") tag_version = h("span.version",[ "rev#{plugin.info.rev} ", tag_update, ]) tag_source = h("div.source",[ "Source: ", h("a", {"href": "/#{plugin.source}", "target": "_top"}, if plugin.site_title then plugin.site_title else plugin.source), " /" + plugin.inner_path ]) tag_delete = h("a.delete", {"href": "#Delete+plugin", onclick: @handleDeleteClick, "data-plugin": plugin}, "Delete plugin") enabled_default = plugin.info.default == "enabled" if plugin.enabled != plugin.loaded or plugin.updated marker_title = "Change pending" is_pending = true else marker_title = "Changed from default status (click to reset to #{plugin.info.default})" is_pending = false is_changed = plugin.enabled != enabled_default and plugin.owner == "builtin" h("div.plugin", {key: plugin.name}, [ h("div.title", [ h("h3", [plugin.name, tag_version]), h("div.description", [descr, tag_source, tag_delete]), ]) h("div.value.value-right", h("div.checkbox", {onclick: @handleCheckboxChange, "data-plugin": plugin, classes: {checked: plugin.enabled}}, h("div.checkbox-skin")) h("a.marker", { href: "#Reset", title: marker_title, onclick: @handleResetClick, "data-plugin": plugin, classes: {visible: is_pending or is_changed, pending: is_pending} }, "\u2022") ) ]) ) window.PluginList = PluginList ================================================ FILE: plugins/UiPluginManager/media/js/UiPluginManager.coffee ================================================ window.h = maquette.h class UiPluginManager extends ZeroFrame init: -> @plugin_list_builtin = new PluginList() @plugin_list_custom = new PluginList() @plugins_changed = null @need_restart = null @ onOpenWebsocket: => @cmd("wrapperSetTitle", "Plugin manager - ZeroNet") @cmd "serverInfo", {}, (server_info) => @server_info = server_info @updatePlugins() updatePlugins: (cb) => @cmd "pluginList", [], (res) => @plugins_changed = (item for item in res.plugins when item.enabled != item.loaded or item.updated) plugins_builtin = (item for item in res.plugins when item.source == "builtin") @plugin_list_builtin.plugins = plugins_builtin.sort (a, b) -> return a.name.localeCompare(b.name) plugins_custom = (item for item in res.plugins when item.source != "builtin") @plugin_list_custom.plugins = plugins_custom.sort (a, b) -> return a.name.localeCompare(b.name) @projector.scheduleRender() cb?() createProjector: => @projector = maquette.createProjector() @projector.replace($("#content"), @render) @projector.replace($("#bottom-restart"), @renderBottomRestart) render: => if not @plugin_list_builtin.plugins return h("div.content") h("div.content", [ h("div.section", [ if @plugin_list_custom.plugins?.length [ h("h2", "Installed third-party plugins"), @plugin_list_custom.render() ] h("h2", "Built-in plugins") @plugin_list_builtin.render() ]) ]) handleRestartClick: => @restart_loading = true setTimeout ( => Page.cmd("serverShutdown", {restart: true}) ), 300 Page.projector.scheduleRender() return false renderBottomRestart: => h("div.bottom.bottom-restart", {classes: {visible: @plugins_changed?.length}}, h("div.bottom-content", [ h("div.title", "Some plugins status has been changed"), h("a.button.button-submit.button-restart", {href: "#Restart", classes: {loading: @restart_loading}, onclick: @handleRestartClick}, "Restart ZeroNet client" ) ])) window.Page = new UiPluginManager() window.Page.createProjector() ================================================ FILE: plugins/UiPluginManager/media/js/all.js ================================================ /* ---- lib/Class.coffee ---- */ (function() { var Class, slice = [].slice; Class = (function() { function Class() {} Class.prototype.trace = true; Class.prototype.log = function() { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; if (!this.trace) { return; } if (typeof console === 'undefined') { return; } args.unshift("[" + this.constructor.name + "]"); console.log.apply(console, args); return this; }; Class.prototype.logStart = function() { var args, name; name = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; if (!this.trace) { return; } this.logtimers || (this.logtimers = {}); this.logtimers[name] = +(new Date); if (args.length > 0) { this.log.apply(this, ["" + name].concat(slice.call(args), ["(started)"])); } return this; }; Class.prototype.logEnd = function() { var args, ms, name; name = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; ms = +(new Date) - this.logtimers[name]; this.log.apply(this, ["" + name].concat(slice.call(args), ["(Done in " + ms + "ms)"])); return this; }; return Class; })(); window.Class = Class; }).call(this); /* ---- lib/Promise.coffee ---- */ (function() { var Promise, slice = [].slice; Promise = (function() { Promise.when = function() { var args, fn, i, len, num_uncompleted, promise, task, task_id, tasks; tasks = 1 <= arguments.length ? slice.call(arguments, 0) : []; num_uncompleted = tasks.length; args = new Array(num_uncompleted); promise = new Promise(); fn = function(task_id) { return task.then(function() { args[task_id] = Array.prototype.slice.call(arguments); num_uncompleted--; if (num_uncompleted === 0) { return promise.complete.apply(promise, args); } }); }; for (task_id = i = 0, len = tasks.length; i < len; task_id = ++i) { task = tasks[task_id]; fn(task_id); } return promise; }; function Promise() { this.resolved = false; this.end_promise = null; this.result = null; this.callbacks = []; } Promise.prototype.resolve = function() { var back, callback, i, len, ref; if (this.resolved) { return false; } this.resolved = true; this.data = arguments; if (!arguments.length) { this.data = [true]; } this.result = this.data[0]; ref = this.callbacks; for (i = 0, len = ref.length; i < len; i++) { callback = ref[i]; back = callback.apply(callback, this.data); } if (this.end_promise) { return this.end_promise.resolve(back); } }; Promise.prototype.fail = function() { return this.resolve(false); }; Promise.prototype.then = function(callback) { if (this.resolved === true) { callback.apply(callback, this.data); return; } this.callbacks.push(callback); return this.end_promise = new Promise(); }; return Promise; })(); window.Promise = Promise; /* s = Date.now() log = (text) -> console.log Date.now()-s, Array.prototype.slice.call(arguments).join(", ") log "Started" cmd = (query) -> p = new Promise() setTimeout ( -> p.resolve query+" Result" ), 100 return p back = cmd("SELECT * FROM message").then (res) -> log res return "Return from query" .then (res) -> log "Back then", res log "Query started", back */ }).call(this); /* ---- lib/Prototypes.coffee ---- */ (function() { String.prototype.startsWith = function(s) { return this.slice(0, s.length) === s; }; String.prototype.endsWith = function(s) { return s === '' || this.slice(-s.length) === s; }; String.prototype.repeat = function(count) { return new Array(count + 1).join(this); }; window.isEmpty = function(obj) { var key; for (key in obj) { return false; } return true; }; }).call(this); /* ---- lib/maquette.js ---- */ (function (root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['exports'], factory); } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') { // CommonJS factory(exports); } else { // Browser globals factory(root.maquette = {}); } }(this, function (exports) { 'use strict'; ; ; ; ; var NAMESPACE_W3 = 'http://www.w3.org/'; var NAMESPACE_SVG = NAMESPACE_W3 + '2000/svg'; var NAMESPACE_XLINK = NAMESPACE_W3 + '1999/xlink'; // Utilities var emptyArray = []; var extend = function (base, overrides) { var result = {}; Object.keys(base).forEach(function (key) { result[key] = base[key]; }); if (overrides) { Object.keys(overrides).forEach(function (key) { result[key] = overrides[key]; }); } return result; }; // Hyperscript helper functions var same = function (vnode1, vnode2) { if (vnode1.vnodeSelector !== vnode2.vnodeSelector) { return false; } if (vnode1.properties && vnode2.properties) { if (vnode1.properties.key !== vnode2.properties.key) { return false; } return vnode1.properties.bind === vnode2.properties.bind; } return !vnode1.properties && !vnode2.properties; }; var toTextVNode = function (data) { return { vnodeSelector: '', properties: undefined, children: undefined, text: data.toString(), domNode: null }; }; var appendChildren = function (parentSelector, insertions, main) { for (var i = 0; i < insertions.length; i++) { var item = insertions[i]; if (Array.isArray(item)) { appendChildren(parentSelector, item, main); } else { if (item !== null && item !== undefined) { if (!item.hasOwnProperty('vnodeSelector')) { item = toTextVNode(item); } main.push(item); } } } }; // Render helper functions var missingTransition = function () { throw new Error('Provide a transitions object to the projectionOptions to do animations'); }; var DEFAULT_PROJECTION_OPTIONS = { namespace: undefined, eventHandlerInterceptor: undefined, styleApplyer: function (domNode, styleName, value) { // Provides a hook to add vendor prefixes for browsers that still need it. domNode.style[styleName] = value; }, transitions: { enter: missingTransition, exit: missingTransition } }; var applyDefaultProjectionOptions = function (projectorOptions) { return extend(DEFAULT_PROJECTION_OPTIONS, projectorOptions); }; var checkStyleValue = function (styleValue) { if (typeof styleValue !== 'string') { throw new Error('Style values must be strings'); } }; var setProperties = function (domNode, properties, projectionOptions) { if (!properties) { return; } var eventHandlerInterceptor = projectionOptions.eventHandlerInterceptor; var propNames = Object.keys(properties); var propCount = propNames.length; for (var i = 0; i < propCount; i++) { var propName = propNames[i]; /* tslint:disable:no-var-keyword: edge case */ var propValue = properties[propName]; /* tslint:enable:no-var-keyword */ if (propName === 'className') { throw new Error('Property "className" is not supported, use "class".'); } else if (propName === 'class') { if (domNode.className) { // May happen if classes is specified before class domNode.className += ' ' + propValue; } else { domNode.className = propValue; } } else if (propName === 'classes') { // object with string keys and boolean values var classNames = Object.keys(propValue); var classNameCount = classNames.length; for (var j = 0; j < classNameCount; j++) { var className = classNames[j]; if (propValue[className]) { domNode.classList.add(className); } } } else if (propName === 'styles') { // object with string keys and string (!) values var styleNames = Object.keys(propValue); var styleCount = styleNames.length; for (var j = 0; j < styleCount; j++) { var styleName = styleNames[j]; var styleValue = propValue[styleName]; if (styleValue) { checkStyleValue(styleValue); projectionOptions.styleApplyer(domNode, styleName, styleValue); } } } else if (propName === 'key') { continue; } else if (propValue === null || propValue === undefined) { continue; } else { var type = typeof propValue; if (type === 'function') { if (propName.lastIndexOf('on', 0) === 0) { if (eventHandlerInterceptor) { propValue = eventHandlerInterceptor(propName, propValue, domNode, properties); // intercept eventhandlers } if (propName === 'oninput') { (function () { // record the evt.target.value, because IE and Edge sometimes do a requestAnimationFrame between changing value and running oninput var oldPropValue = propValue; propValue = function (evt) { evt.target['oninput-value'] = evt.target.value; // may be HTMLTextAreaElement as well oldPropValue.apply(this, [evt]); }; }()); } domNode[propName] = propValue; } } else if (type === 'string' && propName !== 'value' && propName !== 'innerHTML') { if (projectionOptions.namespace === NAMESPACE_SVG && propName === 'href') { domNode.setAttributeNS(NAMESPACE_XLINK, propName, propValue); } else { domNode.setAttribute(propName, propValue); } } else { domNode[propName] = propValue; } } } }; var updateProperties = function (domNode, previousProperties, properties, projectionOptions) { if (!properties) { return; } var propertiesUpdated = false; var propNames = Object.keys(properties); var propCount = propNames.length; for (var i = 0; i < propCount; i++) { var propName = propNames[i]; // assuming that properties will be nullified instead of missing is by design var propValue = properties[propName]; var previousValue = previousProperties[propName]; if (propName === 'class') { if (previousValue !== propValue) { throw new Error('"class" property may not be updated. Use the "classes" property for conditional css classes.'); } } else if (propName === 'classes') { var classList = domNode.classList; var classNames = Object.keys(propValue); var classNameCount = classNames.length; for (var j = 0; j < classNameCount; j++) { var className = classNames[j]; var on = !!propValue[className]; var previousOn = !!previousValue[className]; if (on === previousOn) { continue; } propertiesUpdated = true; if (on) { classList.add(className); } else { classList.remove(className); } } } else if (propName === 'styles') { var styleNames = Object.keys(propValue); var styleCount = styleNames.length; for (var j = 0; j < styleCount; j++) { var styleName = styleNames[j]; var newStyleValue = propValue[styleName]; var oldStyleValue = previousValue[styleName]; if (newStyleValue === oldStyleValue) { continue; } propertiesUpdated = true; if (newStyleValue) { checkStyleValue(newStyleValue); projectionOptions.styleApplyer(domNode, styleName, newStyleValue); } else { projectionOptions.styleApplyer(domNode, styleName, ''); } } } else { if (!propValue && typeof previousValue === 'string') { propValue = ''; } if (propName === 'value') { if (domNode[propName] !== propValue && domNode['oninput-value'] !== propValue) { domNode[propName] = propValue; // Reset the value, even if the virtual DOM did not change domNode['oninput-value'] = undefined; } // else do not update the domNode, otherwise the cursor position would be changed if (propValue !== previousValue) { propertiesUpdated = true; } } else if (propValue !== previousValue) { var type = typeof propValue; if (type === 'function') { throw new Error('Functions may not be updated on subsequent renders (property: ' + propName + '). Hint: declare event handler functions outside the render() function.'); } if (type === 'string' && propName !== 'innerHTML') { if (projectionOptions.namespace === NAMESPACE_SVG && propName === 'href') { domNode.setAttributeNS(NAMESPACE_XLINK, propName, propValue); } else { domNode.setAttribute(propName, propValue); } } else { if (domNode[propName] !== propValue) { domNode[propName] = propValue; } } propertiesUpdated = true; } } } return propertiesUpdated; }; var findIndexOfChild = function (children, sameAs, start) { if (sameAs.vnodeSelector !== '') { // Never scan for text-nodes for (var i = start; i < children.length; i++) { if (same(children[i], sameAs)) { return i; } } } return -1; }; var nodeAdded = function (vNode, transitions) { if (vNode.properties) { var enterAnimation = vNode.properties.enterAnimation; if (enterAnimation) { if (typeof enterAnimation === 'function') { enterAnimation(vNode.domNode, vNode.properties); } else { transitions.enter(vNode.domNode, vNode.properties, enterAnimation); } } } }; var nodeToRemove = function (vNode, transitions) { var domNode = vNode.domNode; if (vNode.properties) { var exitAnimation = vNode.properties.exitAnimation; if (exitAnimation) { domNode.style.pointerEvents = 'none'; var removeDomNode = function () { if (domNode.parentNode) { domNode.parentNode.removeChild(domNode); } }; if (typeof exitAnimation === 'function') { exitAnimation(domNode, removeDomNode, vNode.properties); return; } else { transitions.exit(vNode.domNode, vNode.properties, exitAnimation, removeDomNode); return; } } } if (domNode.parentNode) { domNode.parentNode.removeChild(domNode); } }; var checkDistinguishable = function (childNodes, indexToCheck, parentVNode, operation) { var childNode = childNodes[indexToCheck]; if (childNode.vnodeSelector === '') { return; // Text nodes need not be distinguishable } var properties = childNode.properties; var key = properties ? properties.key === undefined ? properties.bind : properties.key : undefined; if (!key) { for (var i = 0; i < childNodes.length; i++) { if (i !== indexToCheck) { var node = childNodes[i]; if (same(node, childNode)) { if (operation === 'added') { throw new Error(parentVNode.vnodeSelector + ' had a ' + childNode.vnodeSelector + ' child ' + 'added, but there is now more than one. You must add unique key properties to make them distinguishable.'); } else { throw new Error(parentVNode.vnodeSelector + ' had a ' + childNode.vnodeSelector + ' child ' + 'removed, but there were more than one. You must add unique key properties to make them distinguishable.'); } } } } } }; var createDom; var updateDom; var updateChildren = function (vnode, domNode, oldChildren, newChildren, projectionOptions) { if (oldChildren === newChildren) { return false; } oldChildren = oldChildren || emptyArray; newChildren = newChildren || emptyArray; var oldChildrenLength = oldChildren.length; var newChildrenLength = newChildren.length; var transitions = projectionOptions.transitions; var oldIndex = 0; var newIndex = 0; var i; var textUpdated = false; while (newIndex < newChildrenLength) { var oldChild = oldIndex < oldChildrenLength ? oldChildren[oldIndex] : undefined; var newChild = newChildren[newIndex]; if (oldChild !== undefined && same(oldChild, newChild)) { textUpdated = updateDom(oldChild, newChild, projectionOptions) || textUpdated; oldIndex++; } else { var findOldIndex = findIndexOfChild(oldChildren, newChild, oldIndex + 1); if (findOldIndex >= 0) { // Remove preceding missing children for (i = oldIndex; i < findOldIndex; i++) { nodeToRemove(oldChildren[i], transitions); checkDistinguishable(oldChildren, i, vnode, 'removed'); } textUpdated = updateDom(oldChildren[findOldIndex], newChild, projectionOptions) || textUpdated; oldIndex = findOldIndex + 1; } else { // New child createDom(newChild, domNode, oldIndex < oldChildrenLength ? oldChildren[oldIndex].domNode : undefined, projectionOptions); nodeAdded(newChild, transitions); checkDistinguishable(newChildren, newIndex, vnode, 'added'); } } newIndex++; } if (oldChildrenLength > oldIndex) { // Remove child fragments for (i = oldIndex; i < oldChildrenLength; i++) { nodeToRemove(oldChildren[i], transitions); checkDistinguishable(oldChildren, i, vnode, 'removed'); } } return textUpdated; }; var addChildren = function (domNode, children, projectionOptions) { if (!children) { return; } for (var i = 0; i < children.length; i++) { createDom(children[i], domNode, undefined, projectionOptions); } }; var initPropertiesAndChildren = function (domNode, vnode, projectionOptions) { addChildren(domNode, vnode.children, projectionOptions); // children before properties, needed for value property of . if (vnode.text) { domNode.textContent = vnode.text; } setProperties(domNode, vnode.properties, projectionOptions); if (vnode.properties && vnode.properties.afterCreate) { vnode.properties.afterCreate(domNode, projectionOptions, vnode.vnodeSelector, vnode.properties, vnode.children); } }; createDom = function (vnode, parentNode, insertBefore, projectionOptions) { var domNode, i, c, start = 0, type, found; var vnodeSelector = vnode.vnodeSelector; if (vnodeSelector === '') { domNode = vnode.domNode = document.createTextNode(vnode.text); if (insertBefore !== undefined) { parentNode.insertBefore(domNode, insertBefore); } else { parentNode.appendChild(domNode); } } else { for (i = 0; i <= vnodeSelector.length; ++i) { c = vnodeSelector.charAt(i); if (i === vnodeSelector.length || c === '.' || c === '#') { type = vnodeSelector.charAt(start - 1); found = vnodeSelector.slice(start, i); if (type === '.') { domNode.classList.add(found); } else if (type === '#') { domNode.id = found; } else { if (found === 'svg') { projectionOptions = extend(projectionOptions, { namespace: NAMESPACE_SVG }); } if (projectionOptions.namespace !== undefined) { domNode = vnode.domNode = document.createElementNS(projectionOptions.namespace, found); } else { domNode = vnode.domNode = document.createElement(found); } if (insertBefore !== undefined) { parentNode.insertBefore(domNode, insertBefore); } else { parentNode.appendChild(domNode); } } start = i + 1; } } initPropertiesAndChildren(domNode, vnode, projectionOptions); } }; updateDom = function (previous, vnode, projectionOptions) { var domNode = previous.domNode; var textUpdated = false; if (previous === vnode) { return false; // By contract, VNode objects may not be modified anymore after passing them to maquette } var updated = false; if (vnode.vnodeSelector === '') { if (vnode.text !== previous.text) { var newVNode = document.createTextNode(vnode.text); domNode.parentNode.replaceChild(newVNode, domNode); vnode.domNode = newVNode; textUpdated = true; return textUpdated; } } else { if (vnode.vnodeSelector.lastIndexOf('svg', 0) === 0) { projectionOptions = extend(projectionOptions, { namespace: NAMESPACE_SVG }); } if (previous.text !== vnode.text) { updated = true; if (vnode.text === undefined) { domNode.removeChild(domNode.firstChild); // the only textnode presumably } else { domNode.textContent = vnode.text; } } updated = updateChildren(vnode, domNode, previous.children, vnode.children, projectionOptions) || updated; updated = updateProperties(domNode, previous.properties, vnode.properties, projectionOptions) || updated; if (vnode.properties && vnode.properties.afterUpdate) { vnode.properties.afterUpdate(domNode, projectionOptions, vnode.vnodeSelector, vnode.properties, vnode.children); } } if (updated && vnode.properties && vnode.properties.updateAnimation) { vnode.properties.updateAnimation(domNode, vnode.properties, previous.properties); } vnode.domNode = previous.domNode; return textUpdated; }; var createProjection = function (vnode, projectionOptions) { return { update: function (updatedVnode) { if (vnode.vnodeSelector !== updatedVnode.vnodeSelector) { throw new Error('The selector for the root VNode may not be changed. (consider using dom.merge and add one extra level to the virtual DOM)'); } updateDom(vnode, updatedVnode, projectionOptions); vnode = updatedVnode; }, domNode: vnode.domNode }; }; ; // The other two parameters are not added here, because the Typescript compiler creates surrogate code for desctructuring 'children'. exports.h = function (selector) { var properties = arguments[1]; if (typeof selector !== 'string') { throw new Error(); } var childIndex = 1; if (properties && !properties.hasOwnProperty('vnodeSelector') && !Array.isArray(properties) && typeof properties === 'object') { childIndex = 2; } else { // Optional properties argument was omitted properties = undefined; } var text = undefined; var children = undefined; var argsLength = arguments.length; // Recognize a common special case where there is only a single text node if (argsLength === childIndex + 1) { var onlyChild = arguments[childIndex]; if (typeof onlyChild === 'string') { text = onlyChild; } else if (onlyChild !== undefined && onlyChild.length === 1 && typeof onlyChild[0] === 'string') { text = onlyChild[0]; } } if (text === undefined) { children = []; for (; childIndex < arguments.length; childIndex++) { var child = arguments[childIndex]; if (child === null || child === undefined) { continue; } else if (Array.isArray(child)) { appendChildren(selector, child, children); } else if (child.hasOwnProperty('vnodeSelector')) { children.push(child); } else { children.push(toTextVNode(child)); } } } return { vnodeSelector: selector, properties: properties, children: children, text: text === '' ? undefined : text, domNode: null }; }; /** * Contains simple low-level utility functions to manipulate the real DOM. */ exports.dom = { /** * Creates a real DOM tree from `vnode`. The [[Projection]] object returned will contain the resulting DOM Node in * its [[Projection.domNode|domNode]] property. * This is a low-level method. Users wil typically use a [[Projector]] instead. * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] * objects may only be rendered once. * @param projectionOptions - Options to be used to create and update the projection. * @returns The [[Projection]] which also contains the DOM Node that was created. */ create: function (vnode, projectionOptions) { projectionOptions = applyDefaultProjectionOptions(projectionOptions); createDom(vnode, document.createElement('div'), undefined, projectionOptions); return createProjection(vnode, projectionOptions); }, /** * Appends a new childnode to the DOM which is generated from a [[VNode]]. * This is a low-level method. Users wil typically use a [[Projector]] instead. * @param parentNode - The parent node for the new childNode. * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] * objects may only be rendered once. * @param projectionOptions - Options to be used to create and update the [[Projection]]. * @returns The [[Projection]] that was created. */ append: function (parentNode, vnode, projectionOptions) { projectionOptions = applyDefaultProjectionOptions(projectionOptions); createDom(vnode, parentNode, undefined, projectionOptions); return createProjection(vnode, projectionOptions); }, /** * Inserts a new DOM node which is generated from a [[VNode]]. * This is a low-level method. Users wil typically use a [[Projector]] instead. * @param beforeNode - The node that the DOM Node is inserted before. * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. * NOTE: [[VNode]] objects may only be rendered once. * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]]. * @returns The [[Projection]] that was created. */ insertBefore: function (beforeNode, vnode, projectionOptions) { projectionOptions = applyDefaultProjectionOptions(projectionOptions); createDom(vnode, beforeNode.parentNode, beforeNode, projectionOptions); return createProjection(vnode, projectionOptions); }, /** * Merges a new DOM node which is generated from a [[VNode]] with an existing DOM Node. * This means that the virtual DOM and the real DOM will have one overlapping element. * Therefore the selector for the root [[VNode]] will be ignored, but its properties and children will be applied to the Element provided. * This is a low-level method. Users wil typically use a [[Projector]] instead. * @param domNode - The existing element to adopt as the root of the new virtual DOM. Existing attributes and childnodes are preserved. * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] objects * may only be rendered once. * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]]. * @returns The [[Projection]] that was created. */ merge: function (element, vnode, projectionOptions) { projectionOptions = applyDefaultProjectionOptions(projectionOptions); vnode.domNode = element; initPropertiesAndChildren(element, vnode, projectionOptions); return createProjection(vnode, projectionOptions); } }; /** * Creates a [[CalculationCache]] object, useful for caching [[VNode]] trees. * In practice, caching of [[VNode]] trees is not needed, because achieving 60 frames per second is almost never a problem. * For more information, see [[CalculationCache]]. * * @param The type of the value that is cached. */ exports.createCache = function () { var cachedInputs = undefined; var cachedOutcome = undefined; var result = { invalidate: function () { cachedOutcome = undefined; cachedInputs = undefined; }, result: function (inputs, calculation) { if (cachedInputs) { for (var i = 0; i < inputs.length; i++) { if (cachedInputs[i] !== inputs[i]) { cachedOutcome = undefined; } } } if (!cachedOutcome) { cachedOutcome = calculation(); cachedInputs = inputs; } return cachedOutcome; } }; return result; }; /** * Creates a {@link Mapping} instance that keeps an array of result objects synchronized with an array of source objects. * See {@link http://maquettejs.org/docs/arrays.html|Working with arrays}. * * @param The type of source items. A database-record for instance. * @param The type of target items. A [[Component]] for instance. * @param getSourceKey `function(source)` that must return a key to identify each source object. The result must either be a string or a number. * @param createResult `function(source, index)` that must create a new result object from a given source. This function is identical * to the `callback` argument in `Array.map(callback)`. * @param updateResult `function(source, target, index)` that updates a result to an updated source. */ exports.createMapping = function (getSourceKey, createResult, updateResult) { var keys = []; var results = []; return { results: results, map: function (newSources) { var newKeys = newSources.map(getSourceKey); var oldTargets = results.slice(); var oldIndex = 0; for (var i = 0; i < newSources.length; i++) { var source = newSources[i]; var sourceKey = newKeys[i]; if (sourceKey === keys[oldIndex]) { results[i] = oldTargets[oldIndex]; updateResult(source, oldTargets[oldIndex], i); oldIndex++; } else { var found = false; for (var j = 1; j < keys.length; j++) { var searchIndex = (oldIndex + j) % keys.length; if (keys[searchIndex] === sourceKey) { results[i] = oldTargets[searchIndex]; updateResult(newSources[i], oldTargets[searchIndex], i); oldIndex = searchIndex + 1; found = true; break; } } if (!found) { results[i] = createResult(source, i); } } } results.length = newSources.length; keys = newKeys; } }; }; /** * Creates a [[Projector]] instance using the provided projectionOptions. * * For more information, see [[Projector]]. * * @param projectionOptions Options that influence how the DOM is rendered and updated. */ exports.createProjector = function (projectorOptions) { var projector; var projectionOptions = applyDefaultProjectionOptions(projectorOptions); projectionOptions.eventHandlerInterceptor = function (propertyName, eventHandler, domNode, properties) { return function () { // intercept function calls (event handlers) to do a render afterwards. projector.scheduleRender(); return eventHandler.apply(properties.bind || this, arguments); }; }; var renderCompleted = true; var scheduled; var stopped = false; var projections = []; var renderFunctions = []; // matches the projections array var doRender = function () { scheduled = undefined; if (!renderCompleted) { return; // The last render threw an error, it should be logged in the browser console. } renderCompleted = false; for (var i = 0; i < projections.length; i++) { var updatedVnode = renderFunctions[i](); projections[i].update(updatedVnode); } renderCompleted = true; }; projector = { scheduleRender: function () { if (!scheduled && !stopped) { scheduled = requestAnimationFrame(doRender); } }, stop: function () { if (scheduled) { cancelAnimationFrame(scheduled); scheduled = undefined; } stopped = true; }, resume: function () { stopped = false; renderCompleted = true; projector.scheduleRender(); }, append: function (parentNode, renderMaquetteFunction) { projections.push(exports.dom.append(parentNode, renderMaquetteFunction(), projectionOptions)); renderFunctions.push(renderMaquetteFunction); }, insertBefore: function (beforeNode, renderMaquetteFunction) { projections.push(exports.dom.insertBefore(beforeNode, renderMaquetteFunction(), projectionOptions)); renderFunctions.push(renderMaquetteFunction); }, merge: function (domNode, renderMaquetteFunction) { projections.push(exports.dom.merge(domNode, renderMaquetteFunction(), projectionOptions)); renderFunctions.push(renderMaquetteFunction); }, replace: function (domNode, renderMaquetteFunction) { var vnode = renderMaquetteFunction(); createDom(vnode, domNode.parentNode, domNode, projectionOptions); domNode.parentNode.removeChild(domNode); projections.push(createProjection(vnode, projectionOptions)); renderFunctions.push(renderMaquetteFunction); }, detach: function (renderMaquetteFunction) { for (var i = 0; i < renderFunctions.length; i++) { if (renderFunctions[i] === renderMaquetteFunction) { renderFunctions.splice(i, 1); return projections.splice(i, 1)[0]; } } throw new Error('renderMaquetteFunction was not found'); } }; return projector; }; })); ================================================ FILE: plugins/UiPluginManager/media/js/utils/Animation.coffee ================================================ class Animation slideDown: (elem, props) -> if elem.offsetTop > 2000 return h = elem.offsetHeight cstyle = window.getComputedStyle(elem) margin_top = cstyle.marginTop margin_bottom = cstyle.marginBottom padding_top = cstyle.paddingTop padding_bottom = cstyle.paddingBottom transition = cstyle.transition elem.style.boxSizing = "border-box" elem.style.overflow = "hidden" elem.style.transform = "scale(0.6)" elem.style.opacity = "0" elem.style.height = "0px" elem.style.marginTop = "0px" elem.style.marginBottom = "0px" elem.style.paddingTop = "0px" elem.style.paddingBottom = "0px" elem.style.transition = "none" setTimeout (-> elem.className += " animate-inout" elem.style.height = h+"px" elem.style.transform = "scale(1)" elem.style.opacity = "1" elem.style.marginTop = margin_top elem.style.marginBottom = margin_bottom elem.style.paddingTop = padding_top elem.style.paddingBottom = padding_bottom ), 1 elem.addEventListener "transitionend", -> elem.classList.remove("animate-inout") elem.style.transition = elem.style.transform = elem.style.opacity = elem.style.height = null elem.style.boxSizing = elem.style.marginTop = elem.style.marginBottom = null elem.style.paddingTop = elem.style.paddingBottom = elem.style.overflow = null elem.removeEventListener "transitionend", arguments.callee, false slideUp: (elem, remove_func, props) -> if elem.offsetTop > 1000 return remove_func() elem.className += " animate-back" elem.style.boxSizing = "border-box" elem.style.height = elem.offsetHeight+"px" elem.style.overflow = "hidden" elem.style.transform = "scale(1)" elem.style.opacity = "1" elem.style.pointerEvents = "none" setTimeout (-> elem.style.height = "0px" elem.style.marginTop = "0px" elem.style.marginBottom = "0px" elem.style.paddingTop = "0px" elem.style.paddingBottom = "0px" elem.style.transform = "scale(0.8)" elem.style.borderTopWidth = "0px" elem.style.borderBottomWidth = "0px" elem.style.opacity = "0" ), 1 elem.addEventListener "transitionend", (e) -> if e.propertyName == "opacity" or e.elapsedTime >= 0.6 elem.removeEventListener "transitionend", arguments.callee, false remove_func() slideUpInout: (elem, remove_func, props) -> elem.className += " animate-inout" elem.style.boxSizing = "border-box" elem.style.height = elem.offsetHeight+"px" elem.style.overflow = "hidden" elem.style.transform = "scale(1)" elem.style.opacity = "1" elem.style.pointerEvents = "none" setTimeout (-> elem.style.height = "0px" elem.style.marginTop = "0px" elem.style.marginBottom = "0px" elem.style.paddingTop = "0px" elem.style.paddingBottom = "0px" elem.style.transform = "scale(0.8)" elem.style.borderTopWidth = "0px" elem.style.borderBottomWidth = "0px" elem.style.opacity = "0" ), 1 elem.addEventListener "transitionend", (e) -> if e.propertyName == "opacity" or e.elapsedTime >= 0.6 elem.removeEventListener "transitionend", arguments.callee, false remove_func() showRight: (elem, props) -> elem.className += " animate" elem.style.opacity = 0 elem.style.transform = "TranslateX(-20px) Scale(1.01)" setTimeout (-> elem.style.opacity = 1 elem.style.transform = "TranslateX(0px) Scale(1)" ), 1 elem.addEventListener "transitionend", -> elem.classList.remove("animate") elem.style.transform = elem.style.opacity = null show: (elem, props) -> delay = arguments[arguments.length-2]?.delay*1000 or 1 elem.style.opacity = 0 setTimeout (-> elem.className += " animate" ), 1 setTimeout (-> elem.style.opacity = 1 ), delay elem.addEventListener "transitionend", -> elem.classList.remove("animate") elem.style.opacity = null elem.removeEventListener "transitionend", arguments.callee, false hide: (elem, remove_func, props) -> delay = arguments[arguments.length-2]?.delay*1000 or 1 elem.className += " animate" setTimeout (-> elem.style.opacity = 0 ), delay elem.addEventListener "transitionend", (e) -> if e.propertyName == "opacity" remove_func() addVisibleClass: (elem, props) -> setTimeout -> elem.classList.add("visible") window.Animation = new Animation() ================================================ FILE: plugins/UiPluginManager/media/js/utils/Dollar.coffee ================================================ window.$ = (selector) -> if selector.startsWith("#") return document.getElementById(selector.replace("#", "")) ================================================ FILE: plugins/UiPluginManager/media/js/utils/ZeroFrame.coffee ================================================ class ZeroFrame extends Class constructor: (url) -> @url = url @waiting_cb = {} @wrapper_nonce = document.location.href.replace(/.*wrapper_nonce=([A-Za-z0-9]+).*/, "$1") @connect() @next_message_id = 1 @history_state = {} @init() init: -> @ connect: -> @target = window.parent window.addEventListener("message", @onMessage, false) @cmd("innerReady") # Save scrollTop window.addEventListener "beforeunload", (e) => @log "save scrollTop", window.pageYOffset @history_state["scrollTop"] = window.pageYOffset @cmd "wrapperReplaceState", [@history_state, null] # Restore scrollTop @cmd "wrapperGetState", [], (state) => @history_state = state if state? @log "restore scrollTop", state, window.pageYOffset if window.pageYOffset == 0 and state window.scroll(window.pageXOffset, state.scrollTop) onMessage: (e) => message = e.data cmd = message.cmd if cmd == "response" if @waiting_cb[message.to]? @waiting_cb[message.to](message.result) else @log "Websocket callback not found:", message else if cmd == "wrapperReady" # Wrapper inited later @cmd("innerReady") else if cmd == "ping" @response message.id, "pong" else if cmd == "wrapperOpenedWebsocket" @onOpenWebsocket() else if cmd == "wrapperClosedWebsocket" @onCloseWebsocket() else @onRequest cmd, message.params onRequest: (cmd, message) => @log "Unknown request", message response: (to, result) -> @send {"cmd": "response", "to": to, "result": result} cmd: (cmd, params={}, cb=null) -> @send {"cmd": cmd, "params": params}, cb send: (message, cb=null) -> message.wrapper_nonce = @wrapper_nonce message.id = @next_message_id @next_message_id += 1 @target.postMessage(message, "*") if cb @waiting_cb[message.id] = cb onOpenWebsocket: => @log "Websocket open" onCloseWebsocket: => @log "Websocket close" window.ZeroFrame = ZeroFrame ================================================ FILE: plugins/UiPluginManager/media/plugin_manager.html ================================================ Settings - ZeroNet

    ZeroNet plugin manager

    ================================================ FILE: plugins/Zeroname/README.md ================================================ # ZeroName Zeroname plugin to connect Namecoin and register all the .bit domain name. ## Start You can create your own Zeroname. ### Namecoin node You need to run a namecoin node. [Namecoin](https://namecoin.org/download/) You will need to start it as a RPC server. Example of `~/.namecoin/namecoin.conf` minimal setup: ``` daemon=1 rpcuser=your-name rpcpassword=your-password rpcport=8336 server=1 txindex=1 valueencoding=utf8 ``` Don't forget to change the `rpcuser` value and `rpcpassword` value! You can start your node : `./namecoind` ### Create a Zeroname site You will also need to create a site `python zeronet.py createSite` and regitser the info. In the site you will need to create a file `./data//data/names.json` with this is it: ``` {} ``` ### `zeroname_config.json` file In `~/.namecoin/zeroname_config.json` ``` { "lastprocessed": 223910, "zeronet_path": "/root/ZeroNet", # Update with your path "privatekey": "", # Update with your private key of your site "site": "" # Update with the address of your site } ``` ### Run updater You can now run the script : `updater/zeroname_updater.py` and wait until it is fully sync (it might take a while). ================================================ FILE: plugins/Zeroname/SiteManagerPlugin.py ================================================ import logging import re import time from Config import config from Plugin import PluginManager allow_reload = False # No reload supported log = logging.getLogger("ZeronamePlugin") @PluginManager.registerTo("SiteManager") class SiteManagerPlugin(object): site_zeroname = None db_domains = {} db_domains_modified = None def load(self, *args, **kwargs): super(SiteManagerPlugin, self).load(*args, **kwargs) if not self.get(config.bit_resolver): self.need(config.bit_resolver) # Need ZeroName site # Return: True if the address is .bit domain def isBitDomain(self, address): return re.match(r"(.*?)([A-Za-z0-9_-]+\.bit)$", address) # Resolve domain # Return: The address or None def resolveBitDomain(self, domain): domain = domain.lower() if not self.site_zeroname: self.site_zeroname = self.need(config.bit_resolver) site_zeroname_modified = self.site_zeroname.content_manager.contents.get("content.json", {}).get("modified", 0) if not self.db_domains or self.db_domains_modified != site_zeroname_modified: self.site_zeroname.needFile("data/names.json", priority=10) s = time.time() try: self.db_domains = self.site_zeroname.storage.loadJson("data/names.json") except Exception as err: log.error("Error loading names.json: %s" % err) log.debug( "Domain db with %s entries loaded in %.3fs (modification: %s -> %s)" % (len(self.db_domains), time.time() - s, self.db_domains_modified, site_zeroname_modified) ) self.db_domains_modified = site_zeroname_modified return self.db_domains.get(domain) # Turn domain into address def resolveDomain(self, domain): return self.resolveBitDomain(domain) or super(SiteManagerPlugin, self).resolveDomain(domain) # Return: True if the address is domain def isDomain(self, address): return self.isBitDomain(address) or super(SiteManagerPlugin, self).isDomain(address) @PluginManager.registerTo("ConfigPlugin") class ConfigPlugin(object): def createArguments(self): group = self.parser.add_argument_group("Zeroname plugin") group.add_argument( "--bit_resolver", help="ZeroNet site to resolve .bit domains", default="1Name2NXVi1RDPDgf5617UoW7xA6YrhM9F", metavar="address" ) return super(ConfigPlugin, self).createArguments() ================================================ FILE: plugins/Zeroname/__init__.py ================================================ from . import SiteManagerPlugin ================================================ FILE: plugins/Zeroname/updater/zeroname_updater.py ================================================ from __future__ import print_function import time import json import os import sys import re import socket from six import string_types from subprocess import call from bitcoinrpc.authproxy import AuthServiceProxy def publish(): print("* Signing and Publishing...") call(" ".join(command_sign_publish), shell=True) def processNameOp(domain, value, test=False): if not value.strip().startswith("{"): return False try: data = json.loads(value) except Exception as err: print("Json load error: %s" % err) return False if "zeronet" not in data and "map" not in data: # Namecoin standard use {"map": { "blog": {"zeronet": "1D..."} }} print("No zeronet and no map in ", data.keys()) return False if "map" in data: # If subdomains using the Namecoin standard is present, just re-write in the Zeronet way # and call the function again data_map = data["map"] new_value = {} for subdomain in data_map: if "zeronet" in data_map[subdomain]: new_value[subdomain] = data_map[subdomain]["zeronet"] if "zeronet" in data and isinstance(data["zeronet"], string_types): # { # "zeronet":"19rXKeKptSdQ9qt7omwN82smehzTuuq6S9", # .... # } new_value[""] = data["zeronet"] if len(new_value) > 0: return processNameOp(domain, json.dumps({"zeronet": new_value}), test) else: return False if "zeronet" in data and isinstance(data["zeronet"], string_types): # { # "zeronet":"19rXKeKptSdQ9qt7omwN82smehzTuuq6S9" # } is valid return processNameOp(domain, json.dumps({"zeronet": { "": data["zeronet"]}}), test) if not isinstance(data["zeronet"], dict): print("Not dict: ", data["zeronet"]) return False if not re.match("^[a-z0-9]([a-z0-9-]{0,62}[a-z0-9])?$", domain): print("Invalid domain: ", domain) return False if test: return True if "slave" in sys.argv: print("Waiting for master update arrive") time.sleep(30) # Wait 30 sec to allow master updater # Note: Requires the file data/names.json to exist and contain "{}" to work names_raw = open(names_path, "rb").read() names = json.loads(names_raw) for subdomain, address in data["zeronet"].items(): subdomain = subdomain.lower() address = re.sub("[^A-Za-z0-9]", "", address) print(subdomain, domain, "->", address) if subdomain: if re.match("^[a-z0-9]([a-z0-9-]{0,62}[a-z0-9])?$", subdomain): names["%s.%s.bit" % (subdomain, domain)] = address else: print("Invalid subdomain:", domain, subdomain) else: names["%s.bit" % domain] = address new_names_raw = json.dumps(names, indent=2, sort_keys=True) if new_names_raw != names_raw: open(names_path, "wb").write(new_names_raw) print("-", domain, "Changed") return True else: print("-", domain, "Not changed") return False def processBlock(block_id, test=False): print("Processing block #%s..." % block_id) s = time.time() block_hash = rpc.getblockhash(block_id) block = rpc.getblock(block_hash) print("Checking %s tx" % len(block["tx"])) updated = 0 for tx in block["tx"]: try: transaction = rpc.getrawtransaction(tx, 1) for vout in transaction.get("vout", []): if "scriptPubKey" in vout and "nameOp" in vout["scriptPubKey"] and "name" in vout["scriptPubKey"]["nameOp"]: name_op = vout["scriptPubKey"]["nameOp"] updated += processNameOp(name_op["name"].replace("d/", ""), name_op["value"], test) except Exception as err: print("Error processing tx #%s %s" % (tx, err)) print("Done in %.3fs (updated %s)." % (time.time() - s, updated)) return updated # Connecting to RPC def initRpc(config): """Initialize Namecoin RPC""" rpc_data = { 'connect': '127.0.0.1', 'port': '8336', 'user': 'PLACEHOLDER', 'password': 'PLACEHOLDER', 'clienttimeout': '900' } try: fptr = open(config, 'r') lines = fptr.readlines() fptr.close() except: return None # Or take some other appropriate action for line in lines: if not line.startswith('rpc'): continue key_val = line.split(None, 1)[0] (key, val) = key_val.split('=', 1) if not key or not val: continue rpc_data[key[3:]] = val url = 'http://%(user)s:%(password)s@%(connect)s:%(port)s' % rpc_data return url, int(rpc_data['clienttimeout']) # Loading config... # Check whether platform is on windows or linux # On linux namecoin is installed under ~/.namecoin, while on on windows it is in %appdata%/Namecoin if sys.platform == "win32": namecoin_location = os.getenv('APPDATA') + "/Namecoin/" else: namecoin_location = os.path.expanduser("~/.namecoin/") config_path = namecoin_location + 'zeroname_config.json' if not os.path.isfile(config_path): # Create sample config open(config_path, "w").write( json.dumps({'site': 'site', 'zeronet_path': '/home/zeronet', 'privatekey': '', 'lastprocessed': 223910}, indent=2) ) print("* Example config written to %s" % config_path) sys.exit(0) config = json.load(open(config_path)) names_path = "%s/data/%s/data/names.json" % (config["zeronet_path"], config["site"]) os.chdir(config["zeronet_path"]) # Change working dir - tells script where Zeronet install is. # Parameters to sign and publish command_sign_publish = [sys.executable, "zeronet.py", "siteSign", config["site"], config["privatekey"], "--publish"] if sys.platform == 'win32': command_sign_publish = ['"%s"' % param for param in command_sign_publish] # Initialize rpc connection rpc_auth, rpc_timeout = initRpc(namecoin_location + "namecoin.conf") rpc = AuthServiceProxy(rpc_auth, timeout=rpc_timeout) node_version = rpc.getnetworkinfo()['version'] while 1: try: time.sleep(1) if node_version < 160000 : last_block = int(rpc.getinfo()["blocks"]) else: last_block = int(rpc.getblockchaininfo()["blocks"]) break # Connection succeeded except socket.timeout: # Timeout print(".", end=' ') sys.stdout.flush() except Exception as err: print("Exception", err.__class__, err) time.sleep(5) rpc = AuthServiceProxy(rpc_auth, timeout=rpc_timeout) if not config["lastprocessed"]: # First startup: Start processing from last block config["lastprocessed"] = last_block print("- Testing domain parsing...") assert processBlock(223911, test=True) # Testing zeronetwork.bit assert processBlock(227052, test=True) # Testing brainwallets.bit assert not processBlock(236824, test=True) # Utf8 domain name (invalid should skip) assert not processBlock(236752, test=True) # Uppercase domain (invalid should skip) assert processBlock(236870, test=True) # Encoded domain (should pass) assert processBlock(438317, test=True) # Testing namecoin standard artifaxradio.bit (should pass) # sys.exit(0) print("- Parsing skipped blocks...") should_publish = False for block_id in range(config["lastprocessed"], last_block + 1): if processBlock(block_id): should_publish = True config["lastprocessed"] = last_block if should_publish: publish() while 1: print("- Waiting for new block") sys.stdout.flush() while 1: try: time.sleep(1) if node_version < 160000 : rpc.waitforblock() else: rpc.waitfornewblock() print("Found") break # Block found except socket.timeout: # Timeout print(".", end=' ') sys.stdout.flush() except Exception as err: print("Exception", err.__class__, err) time.sleep(5) rpc = AuthServiceProxy(rpc_auth, timeout=rpc_timeout) if node_version < 160000 : last_block = int(rpc.getinfo()["blocks"]) else: last_block = int(rpc.getblockchaininfo()["blocks"]) should_publish = False for block_id in range(config["lastprocessed"] + 1, last_block + 1): if processBlock(block_id): should_publish = True config["lastprocessed"] = last_block open(config_path, "w").write(json.dumps(config, indent=2)) if should_publish: publish() ================================================ FILE: plugins/__init__.py ================================================ ================================================ FILE: plugins/disabled-Bootstrapper/BootstrapperDb.py ================================================ import time import re import gevent from Config import config from Db import Db from util import helper class BootstrapperDb(Db.Db): def __init__(self): self.version = 7 self.hash_ids = {} # hash -> id cache super(BootstrapperDb, self).__init__({"db_name": "Bootstrapper"}, "%s/bootstrapper.db" % config.data_dir) self.foreign_keys = True self.checkTables() self.updateHashCache() gevent.spawn(self.cleanup) def cleanup(self): while 1: time.sleep(4 * 60) timeout = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time() - 60 * 40)) self.execute("DELETE FROM peer WHERE date_announced < ?", [timeout]) def updateHashCache(self): res = self.execute("SELECT * FROM hash") self.hash_ids = {row["hash"]: row["hash_id"] for row in res} self.log.debug("Loaded %s hash_ids" % len(self.hash_ids)) def checkTables(self): version = int(self.execute("PRAGMA user_version").fetchone()[0]) self.log.debug("Db version: %s, needed: %s" % (version, self.version)) if version < self.version: self.createTables() else: self.execute("VACUUM") def createTables(self): # Delete all tables self.execute("PRAGMA writable_schema = 1") self.execute("DELETE FROM sqlite_master WHERE type IN ('table', 'index', 'trigger')") self.execute("PRAGMA writable_schema = 0") self.execute("VACUUM") self.execute("PRAGMA INTEGRITY_CHECK") # Create new tables self.execute(""" CREATE TABLE peer ( peer_id INTEGER PRIMARY KEY ASC AUTOINCREMENT NOT NULL UNIQUE, type TEXT, address TEXT, port INTEGER NOT NULL, date_added DATETIME DEFAULT (CURRENT_TIMESTAMP), date_announced DATETIME DEFAULT (CURRENT_TIMESTAMP) ); """) self.execute("CREATE UNIQUE INDEX peer_key ON peer (address, port);") self.execute(""" CREATE TABLE peer_to_hash ( peer_to_hash_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL, peer_id INTEGER REFERENCES peer (peer_id) ON DELETE CASCADE, hash_id INTEGER REFERENCES hash (hash_id) ); """) self.execute("CREATE INDEX peer_id ON peer_to_hash (peer_id);") self.execute("CREATE INDEX hash_id ON peer_to_hash (hash_id);") self.execute(""" CREATE TABLE hash ( hash_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL, hash BLOB UNIQUE NOT NULL, date_added DATETIME DEFAULT (CURRENT_TIMESTAMP) ); """) self.execute("PRAGMA user_version = %s" % self.version) def getHashId(self, hash): if hash not in self.hash_ids: self.log.debug("New hash: %s" % repr(hash)) res = self.execute("INSERT OR IGNORE INTO hash ?", {"hash": hash}) self.hash_ids[hash] = res.lastrowid return self.hash_ids[hash] def peerAnnounce(self, ip_type, address, port=None, hashes=[], onion_signed=False, delete_missing_hashes=False): hashes_ids_announced = [] for hash in hashes: hashes_ids_announced.append(self.getHashId(hash)) # Check user res = self.execute("SELECT peer_id FROM peer WHERE ? LIMIT 1", {"address": address, "port": port}) user_row = res.fetchone() now = time.strftime("%Y-%m-%d %H:%M:%S") if user_row: peer_id = user_row["peer_id"] self.execute("UPDATE peer SET date_announced = ? WHERE peer_id = ?", (now, peer_id)) else: self.log.debug("New peer: %s signed: %s" % (address, onion_signed)) if ip_type == "onion" and not onion_signed: return len(hashes) res = self.execute("INSERT INTO peer ?", {"type": ip_type, "address": address, "port": port, "date_announced": now}) peer_id = res.lastrowid # Check user's hashes res = self.execute("SELECT * FROM peer_to_hash WHERE ?", {"peer_id": peer_id}) hash_ids_db = [row["hash_id"] for row in res] if hash_ids_db != hashes_ids_announced: hash_ids_added = set(hashes_ids_announced) - set(hash_ids_db) hash_ids_removed = set(hash_ids_db) - set(hashes_ids_announced) if ip_type != "onion" or onion_signed: for hash_id in hash_ids_added: self.execute("INSERT INTO peer_to_hash ?", {"peer_id": peer_id, "hash_id": hash_id}) if hash_ids_removed and delete_missing_hashes: self.execute("DELETE FROM peer_to_hash WHERE ?", {"peer_id": peer_id, "hash_id": list(hash_ids_removed)}) return len(hash_ids_added) + len(hash_ids_removed) else: return 0 def peerList(self, hash, address=None, onions=[], port=None, limit=30, need_types=["ipv4", "onion"], order=True): back = {"ipv4": [], "ipv6": [], "onion": []} if limit == 0: return back hashid = self.getHashId(hash) if order: order_sql = "ORDER BY date_announced DESC" else: order_sql = "" where_sql = "hash_id = :hashid" if onions: onions_escaped = ["'%s'" % re.sub("[^a-z0-9,]", "", onion) for onion in onions if type(onion) is str] where_sql += " AND address NOT IN (%s)" % ",".join(onions_escaped) elif address: where_sql += " AND NOT (address = :address AND port = :port)" query = """ SELECT type, address, port FROM peer_to_hash LEFT JOIN peer USING (peer_id) WHERE %s %s LIMIT :limit """ % (where_sql, order_sql) res = self.execute(query, {"hashid": hashid, "address": address, "port": port, "limit": limit}) for row in res: if row["type"] in need_types: if row["type"] == "onion": packed = helper.packOnionAddress(row["address"], row["port"]) else: packed = helper.packAddress(str(row["address"]), row["port"]) back[row["type"]].append(packed) return back ================================================ FILE: plugins/disabled-Bootstrapper/BootstrapperPlugin.py ================================================ import time from util import helper from Plugin import PluginManager from .BootstrapperDb import BootstrapperDb from Crypt import CryptRsa from Config import config if "db" not in locals().keys(): # Share during reloads db = BootstrapperDb() @PluginManager.registerTo("FileRequest") class FileRequestPlugin(object): def checkOnionSigns(self, onions, onion_signs, onion_sign_this): if not onion_signs or len(onion_signs) != len(set(onions)): return False if time.time() - float(onion_sign_this) > 3 * 60: return False # Signed out of allowed 3 minutes onions_signed = [] # Check onion signs for onion_publickey, onion_sign in onion_signs.items(): if CryptRsa.verify(onion_sign_this.encode(), onion_publickey, onion_sign): onions_signed.append(CryptRsa.publickeyToOnion(onion_publickey)) else: break # Check if the same onion addresses signed as the announced onces if sorted(onions_signed) == sorted(set(onions)): return True else: return False def actionAnnounce(self, params): time_started = time.time() s = time.time() # Backward compatibility if "ip4" in params["add"]: params["add"].append("ipv4") if "ip4" in params["need_types"]: params["need_types"].append("ipv4") hashes = params["hashes"] all_onions_signed = self.checkOnionSigns(params.get("onions", []), params.get("onion_signs"), params.get("onion_sign_this")) time_onion_check = time.time() - s ip_type = helper.getIpType(self.connection.ip) if ip_type == "onion" or self.connection.ip in config.ip_local: is_port_open = False elif ip_type in params["add"]: is_port_open = True else: is_port_open = False s = time.time() # Separatley add onions to sites or at once if no onions present i = 0 onion_to_hash = {} for onion in params.get("onions", []): if onion not in onion_to_hash: onion_to_hash[onion] = [] onion_to_hash[onion].append(hashes[i]) i += 1 hashes_changed = 0 for onion, onion_hashes in onion_to_hash.items(): hashes_changed += db.peerAnnounce( ip_type="onion", address=onion, port=params["port"], hashes=onion_hashes, onion_signed=all_onions_signed ) time_db_onion = time.time() - s s = time.time() if is_port_open: hashes_changed += db.peerAnnounce( ip_type=ip_type, address=self.connection.ip, port=params["port"], hashes=hashes, delete_missing_hashes=params.get("delete") ) time_db_ip = time.time() - s s = time.time() # Query sites back = {} peers = [] if params.get("onions") and not all_onions_signed and hashes_changed: back["onion_sign_this"] = "%.0f" % time.time() # Send back nonce for signing if len(hashes) > 500 or not hashes_changed: limit = 5 order = False else: limit = 30 order = True for hash in hashes: if time.time() - time_started > 1: # 1 sec limit on request self.connection.log("Announce time limit exceeded after %s/%s sites" % (len(peers), len(hashes))) break hash_peers = db.peerList( hash, address=self.connection.ip, onions=list(onion_to_hash.keys()), port=params["port"], limit=min(limit, params["need_num"]), need_types=params["need_types"], order=order ) if "ip4" in params["need_types"]: # Backward compatibility hash_peers["ip4"] = hash_peers["ipv4"] del(hash_peers["ipv4"]) peers.append(hash_peers) time_peerlist = time.time() - s back["peers"] = peers self.connection.log( "Announce %s sites (onions: %s, onion_check: %.3fs, db_onion: %.3fs, db_ip: %.3fs, peerlist: %.3fs, limit: %s)" % (len(hashes), len(onion_to_hash), time_onion_check, time_db_onion, time_db_ip, time_peerlist, limit) ) self.response(back) @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object): @helper.encodeResponse def actionStatsBootstrapper(self): self.sendHeader() # Style yield """ """ hash_rows = db.execute("SELECT * FROM hash").fetchall() for hash_row in hash_rows: peer_rows = db.execute( "SELECT * FROM peer LEFT JOIN peer_to_hash USING (peer_id) WHERE hash_id = :hash_id", {"hash_id": hash_row["hash_id"]} ).fetchall() yield "
    %s (added: %s, peers: %s)
    " % ( str(hash_row["hash"]).encode().hex(), hash_row["date_added"], len(peer_rows) ) for peer_row in peer_rows: yield " - {type} {address}:{port} added: {date_added}, announced: {date_announced}
    ".format(**dict(peer_row)) ================================================ FILE: plugins/disabled-Bootstrapper/Test/TestBootstrapper.py ================================================ import hashlib import os import pytest from Bootstrapper import BootstrapperPlugin from Bootstrapper.BootstrapperDb import BootstrapperDb from Peer import Peer from Crypt import CryptRsa from util import helper @pytest.fixture() def bootstrapper_db(request): BootstrapperPlugin.db.close() BootstrapperPlugin.db = BootstrapperDb() BootstrapperPlugin.db.createTables() # Reset db BootstrapperPlugin.db.cur.logging = True def cleanup(): BootstrapperPlugin.db.close() os.unlink(BootstrapperPlugin.db.db_path) request.addfinalizer(cleanup) return BootstrapperPlugin.db @pytest.mark.usefixtures("resetSettings") class TestBootstrapper: def testHashCache(self, file_server, bootstrapper_db): ip_type = helper.getIpType(file_server.ip) peer = Peer(file_server.ip, 1544, connection_server=file_server) hash1 = hashlib.sha256(b"site1").digest() hash2 = hashlib.sha256(b"site2").digest() hash3 = hashlib.sha256(b"site3").digest() # Verify empty result res = peer.request("announce", { "hashes": [hash1, hash2], "port": 15441, "need_types": [ip_type], "need_num": 10, "add": [ip_type] }) assert len(res["peers"][0][ip_type]) == 0 # Empty result hash_ids_before = bootstrapper_db.hash_ids.copy() bootstrapper_db.updateHashCache() assert hash_ids_before == bootstrapper_db.hash_ids def testBootstrapperDb(self, file_server, bootstrapper_db): ip_type = helper.getIpType(file_server.ip) peer = Peer(file_server.ip, 1544, connection_server=file_server) hash1 = hashlib.sha256(b"site1").digest() hash2 = hashlib.sha256(b"site2").digest() hash3 = hashlib.sha256(b"site3").digest() # Verify empty result res = peer.request("announce", { "hashes": [hash1, hash2], "port": 15441, "need_types": [ip_type], "need_num": 10, "add": [ip_type] }) assert len(res["peers"][0][ip_type]) == 0 # Empty result # Verify added peer on previous request bootstrapper_db.peerAnnounce(ip_type, file_server.ip_external, port=15441, hashes=[hash1, hash2], delete_missing_hashes=True) res = peer.request("announce", { "hashes": [hash1, hash2], "port": 15441, "need_types": [ip_type], "need_num": 10, "add": [ip_type] }) assert len(res["peers"][0][ip_type]) == 1 assert len(res["peers"][1][ip_type]) == 1 # hash2 deleted from 1.2.3.4 bootstrapper_db.peerAnnounce(ip_type, file_server.ip_external, port=15441, hashes=[hash1], delete_missing_hashes=True) res = peer.request("announce", { "hashes": [hash1, hash2], "port": 15441, "need_types": [ip_type], "need_num": 10, "add": [ip_type] }) assert len(res["peers"][0][ip_type]) == 1 assert len(res["peers"][1][ip_type]) == 0 # Announce 3 hash again bootstrapper_db.peerAnnounce(ip_type, file_server.ip_external, port=15441, hashes=[hash1, hash2, hash3], delete_missing_hashes=True) res = peer.request("announce", { "hashes": [hash1, hash2, hash3], "port": 15441, "need_types": [ip_type], "need_num": 10, "add": [ip_type] }) assert len(res["peers"][0][ip_type]) == 1 assert len(res["peers"][1][ip_type]) == 1 assert len(res["peers"][2][ip_type]) == 1 # Single hash announce res = peer.request("announce", { "hashes": [hash1], "port": 15441, "need_types": [ip_type], "need_num": 10, "add": [ip_type] }) assert len(res["peers"][0][ip_type]) == 1 # Test DB cleanup assert [row[0] for row in bootstrapper_db.execute("SELECT address FROM peer").fetchall()] == [file_server.ip_external] # 127.0.0.1 never get added to db # Delete peers bootstrapper_db.execute("DELETE FROM peer WHERE address = ?", [file_server.ip_external]) assert bootstrapper_db.execute("SELECT COUNT(*) AS num FROM peer_to_hash").fetchone()["num"] == 0 assert bootstrapper_db.execute("SELECT COUNT(*) AS num FROM hash").fetchone()["num"] == 3 # 3 sites assert bootstrapper_db.execute("SELECT COUNT(*) AS num FROM peer").fetchone()["num"] == 0 # 0 peer def testPassive(self, file_server, bootstrapper_db): peer = Peer(file_server.ip, 1544, connection_server=file_server) ip_type = helper.getIpType(file_server.ip) hash1 = hashlib.sha256(b"hash1").digest() bootstrapper_db.peerAnnounce(ip_type, address=None, port=15441, hashes=[hash1]) res = peer.request("announce", { "hashes": [hash1], "port": 15441, "need_types": [ip_type], "need_num": 10, "add": [] }) assert len(res["peers"][0]["ipv4"]) == 0 # Empty result def testAddOnion(self, file_server, site, bootstrapper_db, tor_manager): onion1 = tor_manager.addOnion() onion2 = tor_manager.addOnion() peer = Peer(file_server.ip, 1544, connection_server=file_server) hash1 = hashlib.sha256(b"site1").digest() hash2 = hashlib.sha256(b"site2").digest() hash3 = hashlib.sha256(b"site3").digest() bootstrapper_db.peerAnnounce(ip_type="ipv4", address="1.2.3.4", port=1234, hashes=[hash1, hash2, hash3]) res = peer.request("announce", { "onions": [onion1, onion1, onion2], "hashes": [hash1, hash2, hash3], "port": 15441, "need_types": ["ipv4", "onion"], "need_num": 10, "add": ["onion"] }) assert len(res["peers"][0]["ipv4"]) == 1 # Onion address not added yet site_peers = bootstrapper_db.peerList(address="1.2.3.4", port=1234, hash=hash1) assert len(site_peers["onion"]) == 0 assert "onion_sign_this" in res # Sign the nonces sign1 = CryptRsa.sign(res["onion_sign_this"].encode(), tor_manager.getPrivatekey(onion1)) sign2 = CryptRsa.sign(res["onion_sign_this"].encode(), tor_manager.getPrivatekey(onion2)) # Bad sign (different address) res = peer.request("announce", { "onions": [onion1], "onion_sign_this": res["onion_sign_this"], "onion_signs": {tor_manager.getPublickey(onion2): sign2}, "hashes": [hash1], "port": 15441, "need_types": ["ipv4", "onion"], "need_num": 10, "add": ["onion"] }) assert "onion_sign_this" in res site_peers1 = bootstrapper_db.peerList(address="1.2.3.4", port=1234, hash=hash1) assert len(site_peers1["onion"]) == 0 # Not added # Bad sign (missing one) res = peer.request("announce", { "onions": [onion1, onion1, onion2], "onion_sign_this": res["onion_sign_this"], "onion_signs": {tor_manager.getPublickey(onion1): sign1}, "hashes": [hash1, hash2, hash3], "port": 15441, "need_types": ["ipv4", "onion"], "need_num": 10, "add": ["onion"] }) assert "onion_sign_this" in res site_peers1 = bootstrapper_db.peerList(address="1.2.3.4", port=1234, hash=hash1) assert len(site_peers1["onion"]) == 0 # Not added # Good sign res = peer.request("announce", { "onions": [onion1, onion1, onion2], "onion_sign_this": res["onion_sign_this"], "onion_signs": {tor_manager.getPublickey(onion1): sign1, tor_manager.getPublickey(onion2): sign2}, "hashes": [hash1, hash2, hash3], "port": 15441, "need_types": ["ipv4", "onion"], "need_num": 10, "add": ["onion"] }) assert "onion_sign_this" not in res # Onion addresses added site_peers1 = bootstrapper_db.peerList(address="1.2.3.4", port=1234, hash=hash1) assert len(site_peers1["onion"]) == 1 site_peers2 = bootstrapper_db.peerList(address="1.2.3.4", port=1234, hash=hash2) assert len(site_peers2["onion"]) == 1 site_peers3 = bootstrapper_db.peerList(address="1.2.3.4", port=1234, hash=hash3) assert len(site_peers3["onion"]) == 1 assert site_peers1["onion"][0] == site_peers2["onion"][0] assert site_peers2["onion"][0] != site_peers3["onion"][0] assert helper.unpackOnionAddress(site_peers1["onion"][0])[0] == onion1 + ".onion" assert helper.unpackOnionAddress(site_peers2["onion"][0])[0] == onion1 + ".onion" assert helper.unpackOnionAddress(site_peers3["onion"][0])[0] == onion2 + ".onion" tor_manager.delOnion(onion1) tor_manager.delOnion(onion2) def testRequestPeers(self, file_server, site, bootstrapper_db, tor_manager): site.connection_server = file_server file_server.tor_manager = tor_manager hash = hashlib.sha256(site.address.encode()).digest() # Request peers from tracker assert len(site.peers) == 0 bootstrapper_db.peerAnnounce(ip_type="ipv4", address="1.2.3.4", port=1234, hashes=[hash]) site.announcer.announceTracker("zero://%s:%s" % (file_server.ip, file_server.port)) assert len(site.peers) == 1 # Test onion address store bootstrapper_db.peerAnnounce(ip_type="onion", address="bka4ht2bzxchy44r", port=1234, hashes=[hash], onion_signed=True) site.announcer.announceTracker("zero://%s:%s" % (file_server.ip, file_server.port)) assert len(site.peers) == 2 assert "bka4ht2bzxchy44r.onion:1234" in site.peers @pytest.mark.slow def testAnnounce(self, file_server, tor_manager): file_server.tor_manager = tor_manager hash1 = hashlib.sha256(b"1Nekos4fiBqfcazyG1bAxdBT5oBvA76Z").digest() hash2 = hashlib.sha256(b"1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr").digest() peer = Peer("zero.booth.moe", 443, connection_server=file_server) assert peer.request("ping") peer = Peer("boot3rdez4rzn36x.onion", 15441, connection_server=file_server) assert peer.request("ping") res = peer.request("announce", { "hashes": [hash1, hash2], "port": 15441, "need_types": ["ip4", "onion"], "need_num": 100, "add": [""] }) assert res def testBackwardCompatibility(self, file_server, bootstrapper_db): peer = Peer(file_server.ip, 1544, connection_server=file_server) hash1 = hashlib.sha256(b"site1").digest() bootstrapper_db.peerAnnounce("ipv4", file_server.ip_external, port=15441, hashes=[hash1], delete_missing_hashes=True) # Test with ipv4 need type res = peer.request("announce", { "hashes": [hash1], "port": 15441, "need_types": ["ipv4"], "need_num": 10, "add": [] }) assert len(res["peers"][0]["ipv4"]) == 1 # Test with ip4 need type res = peer.request("announce", { "hashes": [hash1], "port": 15441, "need_types": ["ip4"], "need_num": 10, "add": [] }) assert len(res["peers"][0]["ip4"]) == 1 ================================================ FILE: plugins/disabled-Bootstrapper/Test/conftest.py ================================================ from src.Test.conftest import * ================================================ FILE: plugins/disabled-Bootstrapper/Test/pytest.ini ================================================ [pytest] python_files = Test*.py addopts = -rsxX -v --durations=6 markers = slow: mark a tests as slow. webtest: mark a test as a webtest. ================================================ FILE: plugins/disabled-Bootstrapper/__init__.py ================================================ from . import BootstrapperPlugin ================================================ FILE: plugins/disabled-Bootstrapper/plugin_info.json ================================================ { "name": "Bootstrapper", "description": "Add BitTorrent tracker server like features to your ZeroNet client.", "default": "disabled" } ================================================ FILE: plugins/disabled-Dnschain/SiteManagerPlugin.py ================================================ import logging, json, os, re, sys, time import gevent from Plugin import PluginManager from Config import config from util import Http from Debug import Debug allow_reload = False # No reload supported log = logging.getLogger("DnschainPlugin") @PluginManager.registerTo("SiteManager") class SiteManagerPlugin(object): dns_cache_path = "%s/dns_cache.json" % config.data_dir dns_cache = None # Checks if its a valid address def isAddress(self, address): if self.isDomain(address): return True else: return super(SiteManagerPlugin, self).isAddress(address) # Return: True if the address is domain def isDomain(self, address): return re.match(r"(.*?)([A-Za-z0-9_-]+\.[A-Za-z0-9]+)$", address) # Load dns entries from data/dns_cache.json def loadDnsCache(self): if os.path.isfile(self.dns_cache_path): self.dns_cache = json.load(open(self.dns_cache_path)) else: self.dns_cache = {} log.debug("Loaded dns cache, entries: %s" % len(self.dns_cache)) # Save dns entries to data/dns_cache.json def saveDnsCache(self): json.dump(self.dns_cache, open(self.dns_cache_path, "wb"), indent=2) # Resolve domain using dnschain.net # Return: The address or None def resolveDomainDnschainNet(self, domain): try: match = self.isDomain(domain) sub_domain = match.group(1).strip(".") top_domain = match.group(2) if not sub_domain: sub_domain = "@" address = None with gevent.Timeout(5, Exception("Timeout: 5s")): res = Http.get("https://api.dnschain.net/v1/namecoin/key/%s" % top_domain).read() data = json.loads(res)["data"]["value"] if "zeronet" in data: for key, val in data["zeronet"].items(): self.dns_cache[key+"."+top_domain] = [val, time.time()+60*60*5] # Cache for 5 hours self.saveDnsCache() return data["zeronet"].get(sub_domain) # Not found return address except Exception as err: log.debug("Dnschain.net %s resolve error: %s" % (domain, Debug.formatException(err))) # Resolve domain using dnschain.info # Return: The address or None def resolveDomainDnschainInfo(self, domain): try: match = self.isDomain(domain) sub_domain = match.group(1).strip(".") top_domain = match.group(2) if not sub_domain: sub_domain = "@" address = None with gevent.Timeout(5, Exception("Timeout: 5s")): res = Http.get("https://dnschain.info/bit/d/%s" % re.sub(r"\.bit$", "", top_domain)).read() data = json.loads(res)["value"] for key, val in data["zeronet"].items(): self.dns_cache[key+"."+top_domain] = [val, time.time()+60*60*5] # Cache for 5 hours self.saveDnsCache() return data["zeronet"].get(sub_domain) # Not found return address except Exception as err: log.debug("Dnschain.info %s resolve error: %s" % (domain, Debug.formatException(err))) # Resolve domain # Return: The address or None def resolveDomain(self, domain): domain = domain.lower() if self.dns_cache == None: self.loadDnsCache() if domain.count(".") < 2: # Its a topleved request, prepend @. to it domain = "@."+domain domain_details = self.dns_cache.get(domain) if domain_details and time.time() < domain_details[1]: # Found in cache and its not expired return domain_details[0] else: # Resovle dns using dnschain thread_dnschain_info = gevent.spawn(self.resolveDomainDnschainInfo, domain) thread_dnschain_net = gevent.spawn(self.resolveDomainDnschainNet, domain) gevent.joinall([thread_dnschain_net, thread_dnschain_info]) # Wait for finish if thread_dnschain_info.value and thread_dnschain_net.value: # Booth successfull if thread_dnschain_info.value == thread_dnschain_net.value: # Same returned value return thread_dnschain_info.value else: log.error("Dns %s missmatch: %s != %s" % (domain, thread_dnschain_info.value, thread_dnschain_net.value)) # Problem during resolve if domain_details: # Resolve failed, but we have it in the cache domain_details[1] = time.time()+60*60 # Dont try again for 1 hour return domain_details[0] else: # Not found in cache self.dns_cache[domain] = [None, time.time()+60] # Don't check again for 1 min return None # Return or create site and start download site files # Return: Site or None if dns resolve failed def need(self, address, all_file=True): if self.isDomain(address): # Its looks like a domain address_resolved = self.resolveDomain(address) if address_resolved: address = address_resolved else: return None return super(SiteManagerPlugin, self).need(address, all_file) # Return: Site object or None if not found def get(self, address): if self.sites == None: # Not loaded yet self.load() if self.isDomain(address): # Its looks like a domain address_resolved = self.resolveDomain(address) if address_resolved: # Domain found site = self.sites.get(address_resolved) if site: site_domain = site.settings.get("domain") if site_domain != address: site.settings["domain"] = address else: # Domain not found site = self.sites.get(address) else: # Access by site address site = self.sites.get(address) return site ================================================ FILE: plugins/disabled-Dnschain/UiRequestPlugin.py ================================================ import re from Plugin import PluginManager @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object): def __init__(self, server = None): from Site import SiteManager self.site_manager = SiteManager.site_manager super(UiRequestPlugin, self).__init__(server) # Media request def actionSiteMedia(self, path): match = re.match(r"/media/(?P
    [A-Za-z0-9-]+\.[A-Za-z0-9\.-]+)(?P/.*|$)", path) if match: # Its a valid domain, resolve first domain = match.group("address") address = self.site_manager.resolveDomain(domain) if address: path = "/media/"+address+match.group("inner_path") return super(UiRequestPlugin, self).actionSiteMedia(path) # Get the wrapper frame output # Is mediarequest allowed from that referer def isMediaRequestAllowed(self, site_address, referer): referer_path = re.sub("http[s]{0,1}://.*?/", "/", referer).replace("/media", "") # Remove site address referer_site_address = re.match(r"/(?P
    [A-Za-z0-9\.-]+)(?P/.*|$)", referer_path).group("address") if referer_site_address == site_address: # Referer site address as simple address return True elif self.site_manager.resolveDomain(referer_site_address) == site_address: # Referer site address as dns return True else: # Invalid referer return False ================================================ FILE: plugins/disabled-Dnschain/__init__.py ================================================ # This plugin is experimental, if you really want to enable uncomment the following lines: # import DnschainPlugin # import SiteManagerPlugin ================================================ FILE: plugins/disabled-DonationMessage/DonationMessagePlugin.py ================================================ import re from Plugin import PluginManager # Warning: If you modify the donation address then renmae the plugin's directory to "MyDonationMessage" to prevent the update script overwrite @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object): # Inject a donation message to every page top right corner def renderWrapper(self, *args, **kwargs): body = super(UiRequestPlugin, self).renderWrapper(*args, **kwargs) # Get the wrapper frame output inject_html = """ Please donate to help to keep this ZeroProxy alive """ return re.sub(r"\s*\s*$", inject_html, body) ================================================ FILE: plugins/disabled-DonationMessage/__init__.py ================================================ from . import DonationMessagePlugin ================================================ FILE: plugins/disabled-Multiuser/MultiuserPlugin.py ================================================ import re import sys import json from Config import config from Plugin import PluginManager from Crypt import CryptBitcoin from . import UserPlugin from util.Flag import flag from Translate import translate as _ # We can only import plugin host clases after the plugins are loaded @PluginManager.afterLoad def importPluginnedClasses(): global UserManager from User import UserManager try: local_master_addresses = set(json.load(open("%s/users.json" % config.data_dir)).keys()) # Users in users.json except Exception as err: local_master_addresses = set() @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object): def __init__(self, *args, **kwargs): self.user_manager = UserManager.user_manager super(UiRequestPlugin, self).__init__(*args, **kwargs) # Create new user and inject user welcome message if necessary # Return: Html body also containing the injection def actionWrapper(self, path, extra_headers=None): match = re.match("/(?P
    [A-Za-z0-9\._-]+)(?P/.*|$)", path) if not match: return False inner_path = match.group("inner_path").lstrip("/") html_request = "." not in inner_path or inner_path.endswith(".html") # Only inject html to html requests user_created = False if html_request: user = self.getCurrentUser() # Get user from cookie if not user: # No user found by cookie user = self.user_manager.create() user_created = True else: user = None # Disable new site creation if --multiuser_no_new_sites enabled if config.multiuser_no_new_sites: path_parts = self.parsePath(path) if not self.server.site_manager.get(match.group("address")) and (not user or user.master_address not in local_master_addresses): self.sendHeader(404) return self.formatError("Not Found", "Adding new sites disabled on this proxy", details=False) if user_created: if not extra_headers: extra_headers = {} extra_headers['Set-Cookie'] = "master_address=%s;path=/;max-age=2592000;" % user.master_address # = 30 days loggedin = self.get.get("login") == "done" back_generator = super(UiRequestPlugin, self).actionWrapper(path, extra_headers) # Get the wrapper frame output if not back_generator: # Wrapper error or not string returned, injection not possible return False elif loggedin: back = next(back_generator) inject_html = """ """.replace("\t", "") if user.master_address in local_master_addresses: message = "Hello master!" else: message = "Hello again!" inject_html = inject_html.replace("{message}", message) inject_html = inject_html.replace("{script_nonce}", self.getScriptNonce()) return iter([re.sub(b"\s*\s*$", inject_html.encode(), back)]) # Replace the tags with the injection else: # No injection necessary return back_generator # Get the current user based on request's cookies # Return: User object or None if no match def getCurrentUser(self): cookies = self.getCookies() user = None if "master_address" in cookies: users = self.user_manager.list() user = users.get(cookies["master_address"]) return user @PluginManager.registerTo("UiWebsocket") class UiWebsocketPlugin(object): def __init__(self, *args, **kwargs): if config.multiuser_no_new_sites: flag.no_multiuser(self.actionMergerSiteAdd) super(UiWebsocketPlugin, self).__init__(*args, **kwargs) # Let the page know we running in multiuser mode def formatServerInfo(self): server_info = super(UiWebsocketPlugin, self).formatServerInfo() server_info["multiuser"] = True if "ADMIN" in self.site.settings["permissions"]: server_info["master_address"] = self.user.master_address is_multiuser_admin = config.multiuser_local or self.user.master_address in local_master_addresses server_info["multiuser_admin"] = is_multiuser_admin return server_info # Show current user's master seed @flag.admin def actionUserShowMasterSeed(self, to): message = "Your unique private key:" message += "
    %s
    " % self.user.master_seed message += "(Save it, you can access your account using this information)" self.cmd("notification", ["info", message]) # Logout user @flag.admin def actionUserLogout(self, to): message = "You have been logged out. Login to another account" self.cmd("notification", ["done", message, 1000000]) # 1000000 = Show ~forever :) script = "document.cookie = 'master_address=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/';" script += "$('#button_notification').on('click', function() { zeroframe.cmd(\"userLoginForm\", []); });" self.cmd("injectScript", script) # Delete from user_manager user_manager = UserManager.user_manager if self.user.master_address in user_manager.users: if not config.multiuser_local: del user_manager.users[self.user.master_address] self.response(to, "Successful logout") else: self.response(to, "User not found") @flag.admin def actionUserSet(self, to, master_address): user_manager = UserManager.user_manager user = user_manager.get(master_address) if not user: raise Exception("No user found") script = "document.cookie = 'master_address=%s;path=/;max-age=2592000;';" % master_address script += "zeroframe.cmd('wrapperReload', ['login=done']);" self.cmd("notification", ["done", "Successful login, reloading page..."]) self.cmd("injectScript", script) self.response(to, "ok") @flag.admin def actionUserSelectForm(self, to): if not config.multiuser_local: raise Exception("Only allowed in multiuser local mode") user_manager = UserManager.user_manager body = "" + "Change account:" + "" for master_address, user in user_manager.list().items(): is_active = self.user.master_address == master_address if user.certs: first_cert = next(iter(user.certs.keys())) title = "%s@%s" % (user.certs[first_cert]["auth_user_name"], first_cert) else: title = user.master_address if len(user.sites) < 2 and not is_active: # Avoid listing ad-hoc created users continue if is_active: css_class = "active" else: css_class = "noclass" body += "%s" % (css_class, user.master_address, title) script = """ $(".notification .select.user").on("click", function() { $(".notification .select").removeClass('active') zeroframe.response(%s, this.title) return false }) """ % self.next_message_id self.cmd("notification", ["ask", body], lambda master_address: self.actionUserSet(to, master_address)) self.cmd("injectScript", script) # Show login form def actionUserLoginForm(self, to): self.cmd("prompt", ["Login
    Your private key:", "password", "Login"], self.responseUserLogin) # Login form submit def responseUserLogin(self, master_seed): user_manager = UserManager.user_manager user = user_manager.get(CryptBitcoin.privatekeyToAddress(master_seed)) if not user: user = user_manager.create(master_seed=master_seed) if user.master_address: script = "document.cookie = 'master_address=%s;path=/;max-age=2592000;';" % user.master_address script += "zeroframe.cmd('wrapperReload', ['login=done']);" self.cmd("notification", ["done", "Successful login, reloading page..."]) self.cmd("injectScript", script) else: self.cmd("notification", ["error", "Error: Invalid master seed"]) self.actionUserLoginForm(0) def hasCmdPermission(self, cmd): flags = flag.db.get(self.getCmdFuncName(cmd), ()) is_public_proxy_user = not config.multiuser_local and self.user.master_address not in local_master_addresses if is_public_proxy_user and "no_multiuser" in flags: self.cmd("notification", ["info", _("This function ({cmd}) is disabled on this proxy!")]) return False else: return super(UiWebsocketPlugin, self).hasCmdPermission(cmd) def actionCertAdd(self, *args, **kwargs): super(UiWebsocketPlugin, self).actionCertAdd(*args, **kwargs) master_seed = self.user.master_seed message = """ Hello, welcome to ZeroProxy!
    A new, unique account created for you:
    This is your private key, save it, so you can login next time.
    Warning: Without this key, your account will be lost forever!

    Ok, Saved it!

    This site allows you to browse ZeroNet content, but if you want to secure your account
    and help to keep the network alive, then please run your own ZeroNet client.
    """ self.cmd("notification", ["info", message]) script = """ $("#button_notification_masterseed").on("click", function() { this.value = "{master_seed}"; this.setSelectionRange(0,100); }) $("#button_notification_download").on("mousedown", function() { this.href = window.URL.createObjectURL(new Blob(["ZeroNet user master seed:\\r\\n{master_seed}"])) }) """.replace("{master_seed}", master_seed) self.cmd("injectScript", script) def actionPermissionAdd(self, to, permission): is_public_proxy_user = not config.multiuser_local and self.user.master_address not in local_master_addresses if permission == "NOSANDBOX" and is_public_proxy_user: self.cmd("notification", ["info", "You can't disable sandbox on this proxy!"]) self.response(to, {"error": "Denied by proxy"}) return False else: return super(UiWebsocketPlugin, self).actionPermissionAdd(to, permission) @PluginManager.registerTo("ConfigPlugin") class ConfigPlugin(object): def createArguments(self): group = self.parser.add_argument_group("Multiuser plugin") group.add_argument('--multiuser_local', help="Enable unsafe Ui functions and write users to disk", action='store_true') group.add_argument('--multiuser_no_new_sites', help="Denies adding new sites by normal users", action='store_true') return super(ConfigPlugin, self).createArguments() ================================================ FILE: plugins/disabled-Multiuser/Test/TestMultiuser.py ================================================ import pytest import json from Config import config from User import UserManager @pytest.mark.usefixtures("resetSettings") @pytest.mark.usefixtures("resetTempSettings") class TestMultiuser: def testMemorySave(self, user): # It should not write users to disk users_before = open("%s/users.json" % config.data_dir).read() user = UserManager.user_manager.create() user.save() assert open("%s/users.json" % config.data_dir).read() == users_before ================================================ FILE: plugins/disabled-Multiuser/Test/conftest.py ================================================ from src.Test.conftest import * ================================================ FILE: plugins/disabled-Multiuser/Test/pytest.ini ================================================ [pytest] python_files = Test*.py addopts = -rsxX -v --durations=6 markers = webtest: mark a test as a webtest. ================================================ FILE: plugins/disabled-Multiuser/UserPlugin.py ================================================ from Config import config from Plugin import PluginManager allow_reload = False @PluginManager.registerTo("UserManager") class UserManagerPlugin(object): def load(self): if not config.multiuser_local: # In multiuser mode do not load the users if not self.users: self.users = {} return self.users else: return super(UserManagerPlugin, self).load() # Find user by master address # Return: User or None def get(self, master_address=None): users = self.list() if master_address in users: user = users[master_address] else: user = None return user @PluginManager.registerTo("User") class UserPlugin(object): # In multiuser mode users data only exits in memory, dont write to data/user.json def save(self): if not config.multiuser_local: return False else: return super(UserPlugin, self).save() ================================================ FILE: plugins/disabled-Multiuser/__init__.py ================================================ from . import MultiuserPlugin ================================================ FILE: plugins/disabled-Multiuser/plugin_info.json ================================================ { "name": "MultiUser", "description": "Cookie based multi-users support on your ZeroNet web interface.", "default": "disabled" } ================================================ FILE: plugins/disabled-StemPort/StemPortPlugin.py ================================================ import logging import traceback import socket import stem from stem import Signal from stem.control import Controller from stem.socket import ControlPort from Plugin import PluginManager from Config import config from Debug import Debug if config.tor != "disable": from gevent import monkey monkey.patch_time() monkey.patch_socket(dns=False) monkey.patch_thread() print("Stem Port Plugin: modules are patched.") else: print("Stem Port Plugin: Tor mode disabled. Module patching skipped.") class PatchedControlPort(ControlPort): def _make_socket(self): try: if "socket_noproxy" in dir(socket): # Socket proxy-patched, use non-proxy one control_socket = socket.socket_noproxy(socket.AF_INET, socket.SOCK_STREAM) else: control_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # TODO: repeated code - consider making a separate method control_socket.connect((self._control_addr, self._control_port)) return control_socket except socket.error as exc: raise stem.SocketError(exc) def from_port(address = '127.0.0.1', port = 'default'): import stem.connection if not stem.util.connection.is_valid_ipv4_address(address): raise ValueError('Invalid IP address: %s' % address) elif port != 'default' and not stem.util.connection.is_valid_port(port): raise ValueError('Invalid port: %s' % port) if port == 'default': raise ValueError('Must specify a port') else: control_port = PatchedControlPort(address, port) return Controller(control_port) @PluginManager.registerTo("TorManager") class TorManagerPlugin(object): def connectController(self): self.log.info("Authenticate using Stem... %s:%s" % (self.ip, self.port)) try: with self.lock: if config.tor_password: controller = from_port(port=self.port, password=config.tor_password) else: controller = from_port(port=self.port) controller.authenticate() self.controller = controller self.status = "Connected (via Stem)" except Exception as err: print("\n") traceback.print_exc() print("\n") self.controller = None self.status = "Error (%s)" % err self.log.error("Tor stem connect error: %s" % Debug.formatException(err)) return self.controller def disconnect(self): self.controller.close() self.controller = None def resetCircuits(self): try: self.controller.signal(Signal.NEWNYM) except Exception as err: self.status = "Stem reset circuits error (%s)" % err self.log.error("Stem reset circuits error: %s" % err) def makeOnionAndKey(self): try: service = self.controller.create_ephemeral_hidden_service( {self.fileserver_port: self.fileserver_port}, await_publication = False ) if service.private_key_type != "RSA1024": raise Exception("ZeroNet doesn't support crypto " + service.private_key_type) self.log.debug("Stem created %s.onion (async descriptor publication)" % service.service_id) return (service.service_id, service.private_key) except Exception as err: self.status = "AddOnion error (Stem: %s)" % err self.log.error("Failed to create hidden service with Stem: " + err) return False def delOnion(self, address): try: self.controller.remove_ephemeral_hidden_service(address) return True except Exception as err: self.status = "DelOnion error (Stem: %s)" % err self.log.error("Stem failed to delete %s.onion: %s" % (address, err)) self.disconnect() # Why? return False def request(self, cmd): with self.lock: if not self.enabled: return False else: self.log.error("[WARNING] StemPort self.request should not be called") return "" def send(self, cmd, conn=None): self.log.error("[WARNING] StemPort self.send should not be called") return "" ================================================ FILE: plugins/disabled-StemPort/__init__.py ================================================ try: from stem.control import Controller stem_found = True except Exception as err: print(("STEM NOT FOUND! %s" % err)) stem_found = False if stem_found: print("Starting Stem plugin...") from . import StemPortPlugin ================================================ FILE: plugins/disabled-UiPassword/UiPasswordPlugin.py ================================================ import string import random import time import json import re import os from Config import config from Plugin import PluginManager from util import helper plugin_dir = os.path.dirname(__file__) if "sessions" not in locals().keys(): # To keep sessions between module reloads sessions = {} whitelisted_client_ids = {} def showPasswordAdvice(password): error_msgs = [] if not password or not isinstance(password, str): error_msgs.append("You have enabled UiPassword plugin, but you forgot to set a password!") elif len(password) < 8: error_msgs.append("You are using a very short UI password!") return error_msgs @PluginManager.registerTo("UiRequest") class UiRequestPlugin(object): sessions = sessions whitelisted_client_ids = whitelisted_client_ids last_cleanup = time.time() def getClientId(self): return self.env["REMOTE_ADDR"] + " - " + self.env["HTTP_USER_AGENT"] def whitelistClientId(self, session_id=None): if not session_id: session_id = self.getCookies().get("session_id") client_id = self.getClientId() if client_id in self.whitelisted_client_ids: self.whitelisted_client_ids[client_id]["updated"] = time.time() return False self.whitelisted_client_ids[client_id] = { "added": time.time(), "updated": time.time(), "session_id": session_id } def route(self, path): # Restict Ui access by ip if config.ui_restrict and self.env['REMOTE_ADDR'] not in config.ui_restrict: return self.error403(details=False) if path.endswith("favicon.ico"): return self.actionFile("src/Ui/media/img/favicon.ico") else: if config.ui_password: if time.time() - self.last_cleanup > 60 * 60: # Cleanup expired sessions every hour self.sessionCleanup() # Validate session session_id = self.getCookies().get("session_id") if session_id not in self.sessions and self.getClientId() not in self.whitelisted_client_ids: # Invalid session id and not whitelisted ip: display login return self.actionLogin() return super(UiRequestPlugin, self).route(path) def actionWrapper(self, path, *args, **kwargs): if config.ui_password and self.isWrapperNecessary(path): session_id = self.getCookies().get("session_id") if session_id not in self.sessions: # We only accept cookie based auth on wrapper return self.actionLogin() else: self.whitelistClientId() return super().actionWrapper(path, *args, **kwargs) # Action: Login @helper.encodeResponse def actionLogin(self): template = open(plugin_dir + "/login.html").read() self.sendHeader() posted = self.getPosted() if posted: # Validate http posted data if self.sessionCheckPassword(posted.get("password")): # Valid password, create session session_id = self.randomString(26) self.sessions[session_id] = { "added": time.time(), "keep": posted.get("keep") } self.whitelistClientId(session_id) # Redirect to homepage or referer url = self.env.get("HTTP_REFERER", "") if not url or re.sub(r"\?.*", "", url).endswith("/Login"): url = "/" + config.homepage cookie_header = ('Set-Cookie', "session_id=%s;path=/;max-age=2592000;" % session_id) # Max age = 30 days self.start_response('301 Redirect', [('Location', url), cookie_header]) yield "Redirecting..." else: # Invalid password, show login form again template = template.replace("{result}", "bad_password") yield template def randomString(self, nchars): return ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(nchars)) def sessionCheckPassword(self, password): return password == config.ui_password def sessionDelete(self, session_id): del self.sessions[session_id] for client_id in list(self.whitelisted_client_ids): if self.whitelisted_client_ids[client_id]["session_id"] == session_id: del self.whitelisted_client_ids[client_id] def sessionCleanup(self): self.last_cleanup = time.time() for session_id, session in list(self.sessions.items()): if session["keep"] and time.time() - session["added"] > 60 * 60 * 24 * 60: # Max 60days for keep sessions self.sessionDelete(session_id) elif not session["keep"] and time.time() - session["added"] > 60 * 60 * 24: # Max 24h for non-keep sessions self.sessionDelete(session_id) # Action: Display sessions @helper.encodeResponse def actionSessions(self): self.sendHeader() yield "
    "
            yield json.dumps(self.sessions, indent=4)
            yield "\r\n"
            yield json.dumps(self.whitelisted_client_ids, indent=4)
    
        # Action: Logout
        @helper.encodeResponse
        def actionLogout(self):
            # Session id has to passed as get parameter or called without referer to avoid remote logout
            session_id = self.getCookies().get("session_id")
            if not self.env.get("HTTP_REFERER") or session_id == self.get.get("session_id"):
                if session_id in self.sessions:
                    self.sessionDelete(session_id)
    
                self.start_response('301 Redirect', [
                    ('Location', "/"),
                    ('Set-Cookie', "session_id=deleted; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT")
                ])
                yield "Redirecting..."
            else:
                self.sendHeader()
                yield "Error: Invalid session id"
    
    
    @PluginManager.registerTo("ConfigPlugin")
    class ConfigPlugin(object):
        def createArguments(self):
            group = self.parser.add_argument_group("UiPassword plugin")
            group.add_argument('--ui_password', help='Password to access UiServer', default=None, metavar="password")
    
            return super(ConfigPlugin, self).createArguments()
    
    
    from Translate import translate as lang
    @PluginManager.registerTo("UiWebsocket")
    class UiWebsocketPlugin(object):
        def actionUiLogout(self, to):
            permissions = self.getPermissions(to)
            if "ADMIN" not in permissions:
                return self.response(to, "You don't have permission to run this command")
    
            session_id = self.request.getCookies().get("session_id", "")
            self.cmd("redirect", '/Logout?session_id=%s' % session_id)
    
        def addHomepageNotifications(self):
            error_msgs = showPasswordAdvice(config.ui_password)
            for msg in error_msgs:
                self.site.notifications.append(["error", lang[msg]])
    
            return super(UiWebsocketPlugin, self).addHomepageNotifications()
    
    
    ================================================
    FILE: plugins/disabled-UiPassword/__init__.py
    ================================================
    from . import UiPasswordPlugin
    
    ================================================
    FILE: plugins/disabled-UiPassword/login.html
    ================================================
    
    
     Log In
     
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ================================================
    FILE: plugins/disabled-UiPassword/plugin_info.json
    ================================================
    {
    	"name": "UiPassword",
    	"description": "Password based autentication on the web interface.",
    	"default": "disabled"
    }
    
    ================================================
    FILE: plugins/disabled-ZeronameLocal/SiteManagerPlugin.py
    ================================================
    import logging, json, os, re, sys, time, socket
    from Plugin import PluginManager
    from Config import config
    from Debug import Debug
    from http.client import HTTPSConnection, HTTPConnection, HTTPException
    from base64 import b64encode
    
    allow_reload = False # No reload supported
    
    @PluginManager.registerTo("SiteManager")
    class SiteManagerPlugin(object):
        def load(self, *args, **kwargs):
            super(SiteManagerPlugin, self).load(*args, **kwargs)
            self.log = logging.getLogger("ZeronetLocal Plugin")
            self.error_message = None
            if not config.namecoin_host or not config.namecoin_rpcport or not config.namecoin_rpcuser or not config.namecoin_rpcpassword:
                self.error_message = "Missing parameters"
                self.log.error("Missing parameters to connect to namecoin node. Please check all the arguments needed with '--help'. Zeronet will continue working without it.")
                return
    
            url = "%(host)s:%(port)s" % {"host": config.namecoin_host, "port": config.namecoin_rpcport}
            self.c = HTTPConnection(url, timeout=3)
            user_pass = "%(user)s:%(password)s" % {"user": config.namecoin_rpcuser, "password": config.namecoin_rpcpassword}
            userAndPass = b64encode(bytes(user_pass, "utf-8")).decode("ascii")
            self.headers = {"Authorization" : "Basic %s" %  userAndPass, "Content-Type": " application/json " }
    
            payload = json.dumps({
                "jsonrpc": "2.0",
                "id": "zeronet",
                "method": "ping",
                "params": []
            })
    
            try:
                self.c.request("POST", "/", payload, headers=self.headers)
                response = self.c.getresponse()
                data = response.read()
                self.c.close()
                if response.status == 200:
                    result = json.loads(data.decode())["result"]
                else:
                    raise Exception(response.reason)
            except Exception as err:
                self.log.error("The Namecoin node is unreachable. Please check the configuration value are correct. Zeronet will continue working without it.")
                self.error_message = err
            self.cache = dict()
    
        # Checks if it's a valid address
        def isAddress(self, address):
            return self.isBitDomain(address) or super(SiteManagerPlugin, self).isAddress(address)
    
        # Return: True if the address is domain
        def isDomain(self, address):
            return self.isBitDomain(address) or super(SiteManagerPlugin, self).isDomain(address)
    
        # Return: True if the address is .bit domain
        def isBitDomain(self, address):
            return re.match(r"(.*?)([A-Za-z0-9_-]+\.bit)$", address)
    
        # Return: Site object or None if not found
        def get(self, address):
            if self.isBitDomain(address):  # Its looks like a domain
                address_resolved = self.resolveDomain(address)
                if address_resolved:  # Domain found
                    site = self.sites.get(address_resolved)
                    if site:
                        site_domain = site.settings.get("domain")
                        if site_domain != address:
                            site.settings["domain"] = address
                else:  # Domain not found
                    site = self.sites.get(address)
    
            else:  # Access by site address
                site = super(SiteManagerPlugin, self).get(address)
            return site
    
        # Return or create site and start download site files
        # Return: Site or None if dns resolve failed
        def need(self, address, *args, **kwargs):
            if self.isBitDomain(address):  # Its looks like a domain
                address_resolved = self.resolveDomain(address)
                if address_resolved:
                    address = address_resolved
                else:
                    return None
    
            return super(SiteManagerPlugin, self).need(address, *args, **kwargs)
    
        # Resolve domain
        # Return: The address or None
        def resolveDomain(self, domain):
            domain = domain.lower()
    
            #remove .bit on end
            if domain[-4:] == ".bit":
                domain = domain[0:-4]
    
            domain_array = domain.split(".")
    
            if self.error_message:
                self.log.error("Not able to connect to Namecoin node : {!s}".format(self.error_message))
                return None
    
            if len(domain_array) > 2:
                self.log.error("Too many subdomains! Can only handle one level (eg. staging.mixtape.bit)")
                return None
    
            subdomain = ""
            if len(domain_array) == 1:
                domain = domain_array[0]
            else:
                subdomain = domain_array[0]
                domain = domain_array[1]
    
            if domain in self.cache:
                delta = time.time() - self.cache[domain]["time"]
                if delta < 3600:
                    # Must have been less than 1hour
                    return self.cache[domain]["addresses_resolved"][subdomain]
    
            payload = json.dumps({
                "jsonrpc": "2.0",
                "id": "zeronet",
                "method": "name_show",
                "params": ["d/"+domain]
            })
    
            try:
                self.c.request("POST", "/", payload, headers=self.headers)
                response = self.c.getresponse()
                data = response.read()
                self.c.close()
                domain_object = json.loads(data.decode())["result"]
            except Exception as err:
                #domain doesn't exist
                return None
    
            if "zeronet" in domain_object["value"]:
                zeronet_domains = json.loads(domain_object["value"])["zeronet"]
    
                if isinstance(zeronet_domains, str):
                    # {
                    #    "zeronet":"19rXKeKptSdQ9qt7omwN82smehzTuuq6S9"
                    # } is valid
                    zeronet_domains = {"": zeronet_domains}
    
                self.cache[domain] = {"addresses_resolved": zeronet_domains, "time": time.time()}
    
            elif "map" in domain_object["value"]:
                # Namecoin standard use {"map": { "blog": {"zeronet": "1D..."} }}
                data_map = json.loads(domain_object["value"])["map"]
    
                zeronet_domains = dict()
                for subdomain in data_map:
                    if "zeronet" in data_map[subdomain]:
                        zeronet_domains[subdomain] = data_map[subdomain]["zeronet"]
                if "zeronet" in data_map and isinstance(data_map["zeronet"], str):
                    # {"map":{
                    #    "zeronet":"19rXKeKptSdQ9qt7omwN82smehzTuuq6S9",
                    # }}
                    zeronet_domains[""] = data_map["zeronet"]
    
                self.cache[domain] = {"addresses_resolved": zeronet_domains, "time": time.time()}
    
            else:
                # No Zeronet address registered
                return None
    
            return self.cache[domain]["addresses_resolved"][subdomain]
    
    @PluginManager.registerTo("ConfigPlugin")
    class ConfigPlugin(object):
        def createArguments(self):
            group = self.parser.add_argument_group("Zeroname Local plugin")
            group.add_argument('--namecoin_host', help="Host to namecoin node (eg. 127.0.0.1)")
            group.add_argument('--namecoin_rpcport', help="Port to connect (eg. 8336)")
            group.add_argument('--namecoin_rpcuser', help="RPC user to connect to the namecoin node (eg. nofish)")
            group.add_argument('--namecoin_rpcpassword', help="RPC password to connect to namecoin node")
    
            return super(ConfigPlugin, self).createArguments()
    
    
    ================================================
    FILE: plugins/disabled-ZeronameLocal/UiRequestPlugin.py
    ================================================
    import re
    from Plugin import PluginManager
    
    @PluginManager.registerTo("UiRequest")
    class UiRequestPlugin(object):
        def __init__(self, *args, **kwargs):
            from Site import SiteManager
            self.site_manager = SiteManager.site_manager
            super(UiRequestPlugin, self).__init__(*args, **kwargs)
    
    
        # Media request
        def actionSiteMedia(self, path):
            match = re.match(r"/media/(?P
    [A-Za-z0-9-]+\.[A-Za-z0-9\.-]+)(?P/.*|$)", path) if match: # Its a valid domain, resolve first domain = match.group("address") address = self.site_manager.resolveDomain(domain) if address: path = "/media/"+address+match.group("inner_path") return super(UiRequestPlugin, self).actionSiteMedia(path) # Get the wrapper frame output # Is mediarequest allowed from that referer def isMediaRequestAllowed(self, site_address, referer): referer_path = re.sub("http[s]{0,1}://.*?/", "/", referer).replace("/media", "") # Remove site address referer_path = re.sub(r"\?.*", "", referer_path) # Remove http params if self.isProxyRequest(): # Match to site domain referer = re.sub("^http://zero[/]+", "http://", referer) # Allow /zero access referer_site_address = re.match("http[s]{0,1}://(.*?)(/|$)", referer).group(1) else: # Match to request path referer_site_address = re.match(r"/(?P
    [A-Za-z0-9\.-]+)(?P/.*|$)", referer_path).group("address") if referer_site_address == site_address: # Referer site address as simple address return True elif self.site_manager.resolveDomain(referer_site_address) == site_address: # Referer site address as dns return True else: # Invalid referer return False ================================================ FILE: plugins/disabled-ZeronameLocal/__init__.py ================================================ from . import UiRequestPlugin from . import SiteManagerPlugin ================================================ FILE: requirements.txt ================================================ gevent==1.4.0; python_version <= "3.6" greenlet==0.4.16; python_version <= "3.6" gevent>=20.9.0; python_version >= "3.7" msgpack>=0.4.4 base58 merkletools rsa PySocks>=1.6.8 pyasn1 websocket_client gevent-ws coincurve maxminddb ================================================ FILE: src/Config.py ================================================ import argparse import sys import os import locale import re import configparser import logging import logging.handlers import stat import time class Config(object): def __init__(self, argv): self.version = "0.7.2" self.rev = 4555 self.argv = argv self.action = None self.test_parser = None self.pending_changes = {} self.need_restart = False self.keys_api_change_allowed = set([ "tor", "fileserver_port", "language", "tor_use_bridges", "trackers_proxy", "trackers", "trackers_file", "open_browser", "log_level", "fileserver_ip_type", "ip_external", "offline", "threads_fs_read", "threads_fs_write", "threads_crypt", "threads_db" ]) self.keys_restart_need = set([ "tor", "fileserver_port", "fileserver_ip_type", "threads_fs_read", "threads_fs_write", "threads_crypt", "threads_db" ]) self.start_dir = self.getStartDir() self.config_file = self.start_dir + "/zeronet.conf" self.data_dir = self.start_dir + "/data" self.log_dir = self.start_dir + "/log" self.openssl_lib_file = None self.openssl_bin_file = None self.trackers_file = False self.createParser() self.createArguments() def createParser(self): # Create parser self.parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) self.parser.register('type', 'bool', self.strToBool) self.subparsers = self.parser.add_subparsers(title="Action to perform", dest="action") def __str__(self): return str(self.arguments).replace("Namespace", "Config") # Using argparse str output # Convert string to bool def strToBool(self, v): return v.lower() in ("yes", "true", "t", "1") def getStartDir(self): this_file = os.path.abspath(__file__).replace("\\", "/").rstrip("cd") if "--start_dir" in self.argv: start_dir = self.argv[self.argv.index("--start_dir") + 1] elif this_file.endswith("/Contents/Resources/core/src/Config.py"): # Running as ZeroNet.app if this_file.startswith("/Application") or this_file.startswith("/private") or this_file.startswith(os.path.expanduser("~/Library")): # Runnig from non-writeable directory, put data to Application Support start_dir = os.path.expanduser("~/Library/Application Support/ZeroNet") else: # Running from writeable directory put data next to .app start_dir = re.sub("/[^/]+/Contents/Resources/core/src/Config.py", "", this_file) elif this_file.endswith("/core/src/Config.py"): # Running as exe or source is at Application Support directory, put var files to outside of core dir start_dir = this_file.replace("/core/src/Config.py", "") elif this_file.endswith("usr/share/zeronet/src/Config.py"): # Running from non-writeable location, e.g., AppImage start_dir = os.path.expanduser("~/ZeroNet") else: start_dir = "." return start_dir # Create command line arguments def createArguments(self): trackers = [ "zero://boot3rdez4rzn36x.onion:15441", "zero://zero.booth.moe#f36ca555bee6ba216b14d10f38c16f7769ff064e0e37d887603548cc2e64191d:443", # US/NY "udp://tracker.coppersurfer.tk:6969", # DE "udp://104.238.198.186:8000", # US/LA "udp://retracker.akado-ural.ru:80", # RU "http://h4.trakx.nibba.trade:80/announce", # US/VA "http://open.acgnxtracker.com:80/announce", # DE "http://tracker.bt4g.com:2095/announce", # Cloudflare "zero://2602:ffc5::c5b2:5360:26312" # US/ATL ] # Platform specific if sys.platform.startswith("win"): coffeescript = "type %s | tools\\coffee\\coffee.cmd" else: coffeescript = None try: language, enc = locale.getdefaultlocale() language = language.lower().replace("_", "-") if language not in ["pt-br", "zh-tw"]: language = language.split("-")[0] except Exception: language = "en" use_openssl = True if repr(1483108852.565) != "1483108852.565": # Fix for weird Android issue fix_float_decimals = True else: fix_float_decimals = False config_file = self.start_dir + "/zeronet.conf" data_dir = self.start_dir + "/data" log_dir = self.start_dir + "/log" ip_local = ["127.0.0.1", "::1"] # Main action = self.subparsers.add_parser("main", help='Start UiServer and FileServer (default)') # SiteCreate action = self.subparsers.add_parser("siteCreate", help='Create a new site') action.register('type', 'bool', self.strToBool) action.add_argument('--use_master_seed', help="Allow created site's private key to be recovered using the master seed in users.json (default: True)", type="bool", choices=[True, False], default=True) # SiteNeedFile action = self.subparsers.add_parser("siteNeedFile", help='Get a file from site') action.add_argument('address', help='Site address') action.add_argument('inner_path', help='File inner path') # SiteDownload action = self.subparsers.add_parser("siteDownload", help='Download a new site') action.add_argument('address', help='Site address') # SiteSign action = self.subparsers.add_parser("siteSign", help='Update and sign content.json: address [privatekey]') action.add_argument('address', help='Site to sign') action.add_argument('privatekey', help='Private key (default: ask on execute)', nargs='?') action.add_argument('--inner_path', help='File you want to sign (default: content.json)', default="content.json", metavar="inner_path") action.add_argument('--remove_missing_optional', help='Remove optional files that is not present in the directory', action='store_true') action.add_argument('--publish', help='Publish site after the signing', action='store_true') # SitePublish action = self.subparsers.add_parser("sitePublish", help='Publish site to other peers: address') action.add_argument('address', help='Site to publish') action.add_argument('peer_ip', help='Peer ip to publish (default: random peers ip from tracker)', default=None, nargs='?') action.add_argument('peer_port', help='Peer port to publish (default: random peer port from tracker)', default=15441, nargs='?') action.add_argument('--inner_path', help='Content.json you want to publish (default: content.json)', default="content.json", metavar="inner_path") # SiteVerify action = self.subparsers.add_parser("siteVerify", help='Verify site files using sha512: address') action.add_argument('address', help='Site to verify') # SiteCmd action = self.subparsers.add_parser("siteCmd", help='Execute a ZeroFrame API command on a site') action.add_argument('address', help='Site address') action.add_argument('cmd', help='API command name') action.add_argument('parameters', help='Parameters of the command', nargs='?') # dbRebuild action = self.subparsers.add_parser("dbRebuild", help='Rebuild site database cache') action.add_argument('address', help='Site to rebuild') # dbQuery action = self.subparsers.add_parser("dbQuery", help='Query site sql cache') action.add_argument('address', help='Site to query') action.add_argument('query', help='Sql query') # PeerPing action = self.subparsers.add_parser("peerPing", help='Send Ping command to peer') action.add_argument('peer_ip', help='Peer ip') action.add_argument('peer_port', help='Peer port', nargs='?') # PeerGetFile action = self.subparsers.add_parser("peerGetFile", help='Request and print a file content from peer') action.add_argument('peer_ip', help='Peer ip') action.add_argument('peer_port', help='Peer port') action.add_argument('site', help='Site address') action.add_argument('filename', help='File name to request') action.add_argument('--benchmark', help='Request file 10x then displays the total time', action='store_true') # PeerCmd action = self.subparsers.add_parser("peerCmd", help='Request and print a file content from peer') action.add_argument('peer_ip', help='Peer ip') action.add_argument('peer_port', help='Peer port') action.add_argument('cmd', help='Command to execute') action.add_argument('parameters', help='Parameters to command', nargs='?') # CryptSign action = self.subparsers.add_parser("cryptSign", help='Sign message using Bitcoin private key') action.add_argument('message', help='Message to sign') action.add_argument('privatekey', help='Private key') # Crypt Verify action = self.subparsers.add_parser("cryptVerify", help='Verify message using Bitcoin public address') action.add_argument('message', help='Message to verify') action.add_argument('sign', help='Signiture for message') action.add_argument('address', help='Signer\'s address') # Crypt GetPrivatekey action = self.subparsers.add_parser("cryptGetPrivatekey", help='Generate a privatekey from master seed') action.add_argument('master_seed', help='Source master seed') action.add_argument('site_address_index', help='Site address index', type=int) action = self.subparsers.add_parser("getConfig", help='Return json-encoded info') action = self.subparsers.add_parser("testConnection", help='Testing') action = self.subparsers.add_parser("testAnnounce", help='Testing') self.test_parser = self.subparsers.add_parser("test", help='Run a test') self.test_parser.add_argument('test_name', help='Test name', nargs="?") # self.test_parser.add_argument('--benchmark', help='Run the tests multiple times to measure the performance', action='store_true') # Config parameters self.parser.add_argument('--verbose', help='More detailed logging', action='store_true') self.parser.add_argument('--debug', help='Debug mode', action='store_true') self.parser.add_argument('--silent', help='Only log errors to terminal output', action='store_true') self.parser.add_argument('--debug_socket', help='Debug socket connections', action='store_true') self.parser.add_argument('--merge_media', help='Merge all.js and all.css', action='store_true') self.parser.add_argument('--batch', help="Batch mode (No interactive input for commands)", action='store_true') self.parser.add_argument('--start_dir', help='Path of working dir for variable content (data, log, .conf)', default=self.start_dir, metavar="path") self.parser.add_argument('--config_file', help='Path of config file', default=config_file, metavar="path") self.parser.add_argument('--data_dir', help='Path of data directory', default=data_dir, metavar="path") self.parser.add_argument('--console_log_level', help='Level of logging to console', default="default", choices=["default", "DEBUG", "INFO", "ERROR", "off"]) self.parser.add_argument('--log_dir', help='Path of logging directory', default=log_dir, metavar="path") self.parser.add_argument('--log_level', help='Level of logging to file', default="DEBUG", choices=["DEBUG", "INFO", "ERROR", "off"]) self.parser.add_argument('--log_rotate', help='Log rotate interval', default="daily", choices=["hourly", "daily", "weekly", "off"]) self.parser.add_argument('--log_rotate_backup_count', help='Log rotate backup count', default=5, type=int) self.parser.add_argument('--language', help='Web interface language', default=language, metavar='language') self.parser.add_argument('--ui_ip', help='Web interface bind address', default="127.0.0.1", metavar='ip') self.parser.add_argument('--ui_port', help='Web interface bind port', default=43110, type=int, metavar='port') self.parser.add_argument('--ui_restrict', help='Restrict web access', default=False, metavar='ip', nargs='*') self.parser.add_argument('--ui_host', help='Allow access using this hosts', metavar='host', nargs='*') self.parser.add_argument('--ui_trans_proxy', help='Allow access using a transparent proxy', action='store_true') self.parser.add_argument('--open_browser', help='Open homepage in web browser automatically', nargs='?', const="default_browser", metavar='browser_name') self.parser.add_argument('--homepage', help='Web interface Homepage', default='1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D', metavar='address') self.parser.add_argument('--updatesite', help='Source code update site', default='1uPDaT3uSyWAPdCv1WkMb5hBQjWSNNACf', metavar='address') self.parser.add_argument('--dist_type', help='Type of installed distribution', default='source') self.parser.add_argument('--size_limit', help='Default site size limit in MB', default=10, type=int, metavar='limit') self.parser.add_argument('--file_size_limit', help='Maximum per file size limit in MB', default=10, type=int, metavar='limit') self.parser.add_argument('--connected_limit', help='Max connected peer per site', default=8, type=int, metavar='connected_limit') self.parser.add_argument('--global_connected_limit', help='Max connections', default=512, type=int, metavar='global_connected_limit') self.parser.add_argument('--workers', help='Download workers per site', default=5, type=int, metavar='workers') self.parser.add_argument('--fileserver_ip', help='FileServer bind address', default="*", metavar='ip') self.parser.add_argument('--fileserver_port', help='FileServer bind port (0: randomize)', default=0, type=int, metavar='port') self.parser.add_argument('--fileserver_port_range', help='FileServer randomization range', default="10000-40000", metavar='port') self.parser.add_argument('--fileserver_ip_type', help='FileServer ip type', default="dual", choices=["ipv4", "ipv6", "dual"]) self.parser.add_argument('--ip_local', help='My local ips', default=ip_local, type=int, metavar='ip', nargs='*') self.parser.add_argument('--ip_external', help='Set reported external ip (tested on start if None)', metavar='ip', nargs='*') self.parser.add_argument('--offline', help='Disable network communication', action='store_true') self.parser.add_argument('--disable_udp', help='Disable UDP connections', action='store_true') self.parser.add_argument('--proxy', help='Socks proxy address', metavar='ip:port') self.parser.add_argument('--bind', help='Bind outgoing sockets to this address', metavar='ip') self.parser.add_argument('--trackers', help='Bootstraping torrent trackers', default=trackers, metavar='protocol://address', nargs='*') self.parser.add_argument('--trackers_file', help='Load torrent trackers dynamically from a file', metavar='path', nargs='*') self.parser.add_argument('--trackers_proxy', help='Force use proxy to connect to trackers (disable, tor, ip:port)', default="disable") self.parser.add_argument('--use_libsecp256k1', help='Use Libsecp256k1 liblary for speedup', type='bool', choices=[True, False], default=True) self.parser.add_argument('--use_openssl', help='Use OpenSSL liblary for speedup', type='bool', choices=[True, False], default=True) self.parser.add_argument('--openssl_lib_file', help='Path for OpenSSL library file (default: detect)', default=argparse.SUPPRESS, metavar="path") self.parser.add_argument('--openssl_bin_file', help='Path for OpenSSL binary file (default: detect)', default=argparse.SUPPRESS, metavar="path") self.parser.add_argument('--disable_db', help='Disable database updating', action='store_true') self.parser.add_argument('--disable_encryption', help='Disable connection encryption', action='store_true') self.parser.add_argument('--force_encryption', help="Enforce encryption to all peer connections", action='store_true') self.parser.add_argument('--disable_sslcompression', help='Disable SSL compression to save memory', type='bool', choices=[True, False], default=True) self.parser.add_argument('--keep_ssl_cert', help='Disable new SSL cert generation on startup', action='store_true') self.parser.add_argument('--max_files_opened', help='Change maximum opened files allowed by OS to this value on startup', default=2048, type=int, metavar='limit') self.parser.add_argument('--stack_size', help='Change thread stack size', default=None, type=int, metavar='thread_stack_size') self.parser.add_argument('--use_tempfiles', help='Use temporary files when downloading (experimental)', type='bool', choices=[True, False], default=False) self.parser.add_argument('--stream_downloads', help='Stream download directly to files (experimental)', type='bool', choices=[True, False], default=False) self.parser.add_argument("--msgpack_purepython", help='Use less memory, but a bit more CPU power', type='bool', choices=[True, False], default=False) self.parser.add_argument("--fix_float_decimals", help='Fix content.json modification date float precision on verification', type='bool', choices=[True, False], default=fix_float_decimals) self.parser.add_argument("--db_mode", choices=["speed", "security"], default="speed") self.parser.add_argument('--threads_fs_read', help='Number of threads for file read operations', default=1, type=int) self.parser.add_argument('--threads_fs_write', help='Number of threads for file write operations', default=1, type=int) self.parser.add_argument('--threads_crypt', help='Number of threads for cryptographic operations', default=2, type=int) self.parser.add_argument('--threads_db', help='Number of threads for database operations', default=1, type=int) self.parser.add_argument("--download_optional", choices=["manual", "auto"], default="manual") self.parser.add_argument('--coffeescript_compiler', help='Coffeescript compiler for developing', default=coffeescript, metavar='executable_path') self.parser.add_argument('--tor', help='enable: Use only for Tor peers, always: Use Tor for every connection', choices=["disable", "enable", "always"], default='enable') self.parser.add_argument('--tor_controller', help='Tor controller address', metavar='ip:port', default='127.0.0.1:9051') self.parser.add_argument('--tor_proxy', help='Tor proxy address', metavar='ip:port', default='127.0.0.1:9050') self.parser.add_argument('--tor_password', help='Tor controller password', metavar='password') self.parser.add_argument('--tor_use_bridges', help='Use obfuscated bridge relays to avoid Tor block', action='store_true') self.parser.add_argument('--tor_hs_limit', help='Maximum number of hidden services in Tor always mode', metavar='limit', type=int, default=10) self.parser.add_argument('--tor_hs_port', help='Hidden service port in Tor always mode', metavar='limit', type=int, default=15441) self.parser.add_argument('--version', action='version', version='ZeroNet %s r%s' % (self.version, self.rev)) self.parser.add_argument('--end', help='Stop multi value argument parsing', action='store_true') return self.parser def loadTrackersFile(self): if not self.trackers_file: return None self.trackers = self.arguments.trackers[:] for trackers_file in self.trackers_file: try: if trackers_file.startswith("/"): # Absolute trackers_file_path = trackers_file elif trackers_file.startswith("{data_dir}"): # Relative to data_dir trackers_file_path = trackers_file.replace("{data_dir}", self.data_dir) else: # Relative to zeronet.py trackers_file_path = self.start_dir + "/" + trackers_file for line in open(trackers_file_path): tracker = line.strip() if "://" in tracker and tracker not in self.trackers: self.trackers.append(tracker) except Exception as err: print("Error loading trackers file: %s" % err) # Find arguments specified for current action def getActionArguments(self): back = {} arguments = self.parser._subparsers._group_actions[0].choices[self.action]._actions[1:] # First is --version for argument in arguments: back[argument.dest] = getattr(self, argument.dest) return back # Try to find action from argv def getAction(self, argv): actions = [list(action.choices.keys()) for action in self.parser._actions if action.dest == "action"][0] # Valid actions found_action = False for action in actions: # See if any in argv if action in argv: found_action = action break return found_action # Move plugin parameters to end of argument list def moveUnknownToEnd(self, argv, default_action): valid_actions = sum([action.option_strings for action in self.parser._actions], []) valid_parameters = [] plugin_parameters = [] plugin = False for arg in argv: if arg.startswith("--"): if arg not in valid_actions: plugin = True else: plugin = False elif arg == default_action: plugin = False if plugin: plugin_parameters.append(arg) else: valid_parameters.append(arg) return valid_parameters + plugin_parameters def getParser(self, argv): action = self.getAction(argv) if not action: return self.parser else: return self.subparsers.choices[action] # Parse arguments from config file and command line def parse(self, silent=False, parse_config=True): argv = self.argv[:] # Copy command line arguments current_parser = self.getParser(argv) if silent: # Don't display messages or quit on unknown parameter original_print_message = self.parser._print_message original_exit = self.parser.exit def silencer(parser, function_name): parser.exited = True return None current_parser.exited = False current_parser._print_message = lambda *args, **kwargs: silencer(current_parser, "_print_message") current_parser.exit = lambda *args, **kwargs: silencer(current_parser, "exit") self.parseCommandline(argv, silent) # Parse argv self.setAttributes() if parse_config: argv = self.parseConfig(argv) # Add arguments from config file self.parseCommandline(argv, silent) # Parse argv self.setAttributes() if not silent: if self.fileserver_ip != "*" and self.fileserver_ip not in self.ip_local: self.ip_local.append(self.fileserver_ip) if silent: # Restore original functions if current_parser.exited and self.action == "main": # Argument parsing halted, don't start ZeroNet with main action self.action = None current_parser._print_message = original_print_message current_parser.exit = original_exit self.loadTrackersFile() # Parse command line arguments def parseCommandline(self, argv, silent=False): # Find out if action is specificed on start action = self.getAction(argv) if not action: argv.append("--end") argv.append("main") action = "main" argv = self.moveUnknownToEnd(argv, action) if silent: res = self.parser.parse_known_args(argv[1:]) if res: self.arguments = res[0] else: self.arguments = {} else: self.arguments = self.parser.parse_args(argv[1:]) # Parse config file def parseConfig(self, argv): # Find config file path from parameters if "--config_file" in argv: self.config_file = argv[argv.index("--config_file") + 1] # Load config file if os.path.isfile(self.config_file): config = configparser.RawConfigParser(allow_no_value=True, strict=False) config.read(self.config_file) for section in config.sections(): for key, val in config.items(section): if val == "True": val = None if section != "global": # If not global prefix key with section key = section + "_" + key if key == "open_browser": # Prefer config file value over cli argument while "--%s" % key in argv: pos = argv.index("--open_browser") del argv[pos:pos + 2] argv_extend = ["--%s" % key] if val: for line in val.strip().split("\n"): # Allow multi-line values argv_extend.append(line) if "\n" in val: argv_extend.append("--end") argv = argv[:1] + argv_extend + argv[1:] return argv # Return command line value of given argument def getCmdlineValue(self, key): if key not in self.argv: return None argv_index = self.argv.index(key) if argv_index == len(self.argv) - 1: # last arg, test not specified return None return self.argv[argv_index + 1] # Expose arguments as class attributes def setAttributes(self): # Set attributes from arguments if self.arguments: args = vars(self.arguments) for key, val in args.items(): if type(val) is list: val = val[:] if key in ("data_dir", "log_dir", "start_dir", "openssl_bin_file", "openssl_lib_file"): if val: val = val.replace("\\", "/") setattr(self, key, val) def loadPlugins(self): from Plugin import PluginManager @PluginManager.acceptPlugins class ConfigPlugin(object): def __init__(self, config): self.argv = config.argv self.parser = config.parser self.subparsers = config.subparsers self.test_parser = config.test_parser self.getCmdlineValue = config.getCmdlineValue self.createArguments() def createArguments(self): pass ConfigPlugin(self) def saveValue(self, key, value): if not os.path.isfile(self.config_file): content = "" else: content = open(self.config_file).read() lines = content.splitlines() global_line_i = None key_line_i = None i = 0 for line in lines: if line.strip() == "[global]": global_line_i = i if line.startswith(key + " =") or line == key: key_line_i = i i += 1 if key_line_i and len(lines) > key_line_i + 1: while True: # Delete previous multiline values is_value_line = lines[key_line_i + 1].startswith(" ") or lines[key_line_i + 1].startswith("\t") if not is_value_line: break del lines[key_line_i + 1] if value is None: # Delete line if key_line_i: del lines[key_line_i] else: # Add / update if type(value) is list: value_lines = [""] + [str(line).replace("\n", "").replace("\r", "") for line in value] else: value_lines = [str(value).replace("\n", "").replace("\r", "")] new_line = "%s = %s" % (key, "\n ".join(value_lines)) if key_line_i: # Already in the config, change the line lines[key_line_i] = new_line elif global_line_i is None: # No global section yet, append to end of file lines.append("[global]") lines.append(new_line) else: # Has global section, append the line after it lines.insert(global_line_i + 1, new_line) open(self.config_file, "w").write("\n".join(lines)) def getServerInfo(self): from Plugin import PluginManager import main info = { "platform": sys.platform, "fileserver_ip": self.fileserver_ip, "fileserver_port": self.fileserver_port, "ui_ip": self.ui_ip, "ui_port": self.ui_port, "version": self.version, "rev": self.rev, "language": self.language, "debug": self.debug, "plugins": PluginManager.plugin_manager.plugin_names, "log_dir": os.path.abspath(self.log_dir), "data_dir": os.path.abspath(self.data_dir), "src_dir": os.path.dirname(os.path.abspath(__file__)) } try: info["ip_external"] = main.file_server.port_opened info["tor_enabled"] = main.file_server.tor_manager.enabled info["tor_status"] = main.file_server.tor_manager.status except Exception: pass return info def initConsoleLogger(self): if self.action == "main": format = '[%(asctime)s] %(name)s %(message)s' else: format = '%(name)s %(message)s' if self.console_log_level == "default": if self.silent: level = logging.ERROR elif self.debug: level = logging.DEBUG else: level = logging.INFO else: level = logging.getLevelName(self.console_log_level) console_logger = logging.StreamHandler() console_logger.setFormatter(logging.Formatter(format, "%H:%M:%S")) console_logger.setLevel(level) logging.getLogger('').addHandler(console_logger) def initFileLogger(self): if self.action == "main": log_file_path = "%s/debug.log" % self.log_dir else: log_file_path = "%s/cmd.log" % self.log_dir if self.log_rotate == "off": file_logger = logging.FileHandler(log_file_path, "w", "utf-8") else: when_names = {"weekly": "w", "daily": "d", "hourly": "h"} file_logger = logging.handlers.TimedRotatingFileHandler( log_file_path, when=when_names[self.log_rotate], interval=1, backupCount=self.log_rotate_backup_count, encoding="utf8" ) if os.path.isfile(log_file_path): file_logger.doRollover() # Always start with empty log file file_logger.setFormatter(logging.Formatter('[%(asctime)s] %(levelname)-8s %(name)s %(message)s')) file_logger.setLevel(logging.getLevelName(self.log_level)) logging.getLogger('').setLevel(logging.getLevelName(self.log_level)) logging.getLogger('').addHandler(file_logger) def initLogging(self, console_logging=None, file_logging=None): if console_logging == None: console_logging = self.console_log_level != "off" if file_logging == None: file_logging = self.log_level != "off" # Create necessary files and dirs if not os.path.isdir(self.log_dir): os.mkdir(self.log_dir) try: os.chmod(self.log_dir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) except Exception as err: print("Can't change permission of %s: %s" % (self.log_dir, err)) # Make warning hidden from console logging.WARNING = 15 # Don't display warnings if not in debug mode logging.addLevelName(15, "WARNING") logging.getLogger('').name = "-" # Remove root prefix self.error_logger = ErrorLogHandler() self.error_logger.setLevel(logging.getLevelName("ERROR")) logging.getLogger('').addHandler(self.error_logger) if console_logging: self.initConsoleLogger() if file_logging: self.initFileLogger() class ErrorLogHandler(logging.StreamHandler): def __init__(self): self.lines = [] return super().__init__() def emit(self, record): self.lines.append([time.time(), record.levelname, self.format(record)]) def onNewRecord(self, record): pass config = Config(sys.argv) ================================================ FILE: src/Connection/Connection.py ================================================ import socket import time import gevent try: from gevent.coros import RLock except: from gevent.lock import RLock from Config import config from Debug import Debug from util import Msgpack from Crypt import CryptConnection from util import helper class Connection(object): __slots__ = ( "sock", "sock_wrapped", "ip", "port", "cert_pin", "target_onion", "id", "protocol", "type", "server", "unpacker", "unpacker_bytes", "req_id", "ip_type", "handshake", "crypt", "connected", "event_connected", "closed", "start_time", "handshake_time", "last_recv_time", "is_private_ip", "is_tracker_connection", "last_message_time", "last_send_time", "last_sent_time", "incomplete_buff_recv", "bytes_recv", "bytes_sent", "cpu_time", "send_lock", "last_ping_delay", "last_req_time", "last_cmd_sent", "last_cmd_recv", "bad_actions", "sites", "name", "waiting_requests", "waiting_streams" ) def __init__(self, server, ip, port, sock=None, target_onion=None, is_tracker_connection=False): self.sock = sock self.cert_pin = None if "#" in ip: ip, self.cert_pin = ip.split("#") self.target_onion = target_onion # Requested onion adress self.id = server.last_connection_id server.last_connection_id += 1 self.protocol = "?" self.type = "?" self.ip_type = "?" self.port = int(port) self.setIp(ip) if helper.isPrivateIp(self.ip) and self.ip not in config.ip_local: self.is_private_ip = True else: self.is_private_ip = False self.is_tracker_connection = is_tracker_connection self.server = server self.unpacker = None # Stream incoming socket messages here self.unpacker_bytes = 0 # How many bytes the unpacker received self.req_id = 0 # Last request id self.handshake = {} # Handshake info got from peer self.crypt = None # Connection encryption method self.sock_wrapped = False # Socket wrapped to encryption self.connected = False self.event_connected = gevent.event.AsyncResult() # Solves on handshake received self.closed = False # Stats self.start_time = time.time() self.handshake_time = 0 self.last_recv_time = 0 self.last_message_time = 0 self.last_send_time = 0 self.last_sent_time = 0 self.incomplete_buff_recv = 0 self.bytes_recv = 0 self.bytes_sent = 0 self.last_ping_delay = None self.last_req_time = 0 self.last_cmd_sent = None self.last_cmd_recv = None self.bad_actions = 0 self.sites = 0 self.cpu_time = 0.0 self.send_lock = RLock() self.name = None self.updateName() self.waiting_requests = {} # Waiting sent requests self.waiting_streams = {} # Waiting response file streams def setIp(self, ip): self.ip = ip self.ip_type = helper.getIpType(ip) self.updateName() def createSocket(self): if helper.getIpType(self.ip) == "ipv6" and not hasattr(socket, "socket_noproxy"): # Create IPv6 connection as IPv4 when using proxy return socket.socket(socket.AF_INET6, socket.SOCK_STREAM) else: return socket.socket(socket.AF_INET, socket.SOCK_STREAM) def updateName(self): self.name = "Conn#%2s %-12s [%s]" % (self.id, self.ip, self.protocol) def __str__(self): return self.name def __repr__(self): return "<%s>" % self.__str__() def log(self, text): self.server.log.debug("%s > %s" % (self.name, text)) def getValidSites(self): return [key for key, val in self.server.tor_manager.site_onions.items() if val == self.target_onion] def badAction(self, weight=1): self.bad_actions += weight if self.bad_actions > 40: self.close("Too many bad actions") elif self.bad_actions > 20: time.sleep(5) def goodAction(self): self.bad_actions = 0 # Open connection to peer and wait for handshake def connect(self): self.type = "out" if self.ip_type == "onion": if not self.server.tor_manager or not self.server.tor_manager.enabled: raise Exception("Can't connect to onion addresses, no Tor controller present") self.sock = self.server.tor_manager.createSocket(self.ip, self.port) elif config.tor == "always" and helper.isPrivateIp(self.ip) and self.ip not in config.ip_local: raise Exception("Can't connect to local IPs in Tor: always mode") elif config.trackers_proxy != "disable" and config.tor != "always" and self.is_tracker_connection: if config.trackers_proxy == "tor": self.sock = self.server.tor_manager.createSocket(self.ip, self.port) else: import socks self.sock = socks.socksocket() proxy_ip, proxy_port = config.trackers_proxy.split(":") self.sock.set_proxy(socks.PROXY_TYPE_SOCKS5, proxy_ip, int(proxy_port)) else: self.sock = self.createSocket() if "TCP_NODELAY" in dir(socket): self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) timeout_before = self.sock.gettimeout() self.sock.settimeout(30) if self.ip_type == "ipv6" and not hasattr(self.sock, "proxy"): sock_address = (self.ip, self.port, 1, 1) else: sock_address = (self.ip, self.port) self.sock.connect(sock_address) # Implicit SSL should_encrypt = not self.ip_type == "onion" and self.ip not in self.server.broken_ssl_ips and self.ip not in config.ip_local if self.cert_pin: self.sock = CryptConnection.manager.wrapSocket(self.sock, "tls-rsa", cert_pin=self.cert_pin) self.sock.do_handshake() self.crypt = "tls-rsa" self.sock_wrapped = True elif should_encrypt and "tls-rsa" in CryptConnection.manager.crypt_supported: try: self.sock = CryptConnection.manager.wrapSocket(self.sock, "tls-rsa") self.sock.do_handshake() self.crypt = "tls-rsa" self.sock_wrapped = True except Exception as err: if not config.force_encryption: self.log("Crypt connection error, adding %s:%s as broken ssl. %s" % (self.ip, self.port, Debug.formatException(err))) self.server.broken_ssl_ips[self.ip] = True self.sock.close() self.crypt = None self.sock = self.createSocket() self.sock.settimeout(30) self.sock.connect(sock_address) # Detect protocol self.send({"cmd": "handshake", "req_id": 0, "params": self.getHandshakeInfo()}) event_connected = self.event_connected gevent.spawn(self.messageLoop) connect_res = event_connected.get() # Wait for handshake self.sock.settimeout(timeout_before) return connect_res # Handle incoming connection def handleIncomingConnection(self, sock): self.log("Incoming connection...") if "TCP_NODELAY" in dir(socket): sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) self.type = "in" if self.ip not in config.ip_local: # Clearnet: Check implicit SSL try: first_byte = sock.recv(1, gevent.socket.MSG_PEEK) if first_byte == b"\x16": self.log("Crypt in connection using implicit SSL") self.sock = CryptConnection.manager.wrapSocket(self.sock, "tls-rsa", True) self.sock_wrapped = True self.crypt = "tls-rsa" except Exception as err: self.log("Socket peek error: %s" % Debug.formatException(err)) self.messageLoop() def getMsgpackUnpacker(self): if self.handshake and self.handshake.get("use_bin_type"): return Msgpack.getUnpacker(fallback=True, decode=False) else: # Backward compatibility for <0.7.0 return Msgpack.getUnpacker(fallback=True, decode=True) # Message loop for connection def messageLoop(self): if not self.sock: self.log("Socket error: No socket found") return False self.protocol = "v2" self.updateName() self.connected = True buff_len = 0 req_len = 0 self.unpacker_bytes = 0 try: while not self.closed: buff = self.sock.recv(64 * 1024) if not buff: break # Connection closed buff_len = len(buff) # Statistics self.last_recv_time = time.time() self.incomplete_buff_recv += 1 self.bytes_recv += buff_len self.server.bytes_recv += buff_len req_len += buff_len if not self.unpacker: self.unpacker = self.getMsgpackUnpacker() self.unpacker_bytes = 0 self.unpacker.feed(buff) self.unpacker_bytes += buff_len while True: try: message = next(self.unpacker) except StopIteration: break if not type(message) is dict: if config.debug_socket: self.log("Invalid message type: %s, content: %r, buffer: %r" % (type(message), message, buff[0:16])) raise Exception("Invalid message type: %s" % type(message)) # Stats self.incomplete_buff_recv = 0 stat_key = message.get("cmd", "unknown") if stat_key == "response" and "to" in message: cmd_sent = self.waiting_requests.get(message["to"], {"cmd": "unknown"})["cmd"] stat_key = "response: %s" % cmd_sent if stat_key == "update": stat_key = "update: %s" % message["params"]["site"] self.server.stat_recv[stat_key]["bytes"] += req_len self.server.stat_recv[stat_key]["num"] += 1 if "stream_bytes" in message: self.server.stat_recv[stat_key]["bytes"] += message["stream_bytes"] req_len = 0 # Handle message if "stream_bytes" in message: buff_left = self.handleStream(message, buff) self.unpacker = self.getMsgpackUnpacker() self.unpacker.feed(buff_left) self.unpacker_bytes = len(buff_left) if config.debug_socket: self.log("Start new unpacker with buff_left: %r" % buff_left) else: self.handleMessage(message) message = None except Exception as err: if not self.closed: self.log("Socket error: %s" % Debug.formatException(err)) self.server.stat_recv["error: %s" % err]["bytes"] += req_len self.server.stat_recv["error: %s" % err]["num"] += 1 self.close("MessageLoop ended (closed: %s)" % self.closed) # MessageLoop ended, close connection def getUnpackerUnprocessedBytesNum(self): if "tell" in dir(self.unpacker): bytes_num = self.unpacker_bytes - self.unpacker.tell() else: bytes_num = self.unpacker._fb_buf_n - self.unpacker._fb_buf_o return bytes_num # Stream socket directly to a file def handleStream(self, message, buff): stream_bytes_left = message["stream_bytes"] file = self.waiting_streams[message["to"]] unprocessed_bytes_num = self.getUnpackerUnprocessedBytesNum() if unprocessed_bytes_num: # Found stream bytes in unpacker unpacker_stream_bytes = min(unprocessed_bytes_num, stream_bytes_left) buff_stream_start = len(buff) - unprocessed_bytes_num file.write(buff[buff_stream_start:buff_stream_start + unpacker_stream_bytes]) stream_bytes_left -= unpacker_stream_bytes else: unpacker_stream_bytes = 0 if config.debug_socket: self.log( "Starting stream %s: %s bytes (%s from unpacker, buff size: %s, unprocessed: %s)" % (message["to"], message["stream_bytes"], unpacker_stream_bytes, len(buff), unprocessed_bytes_num) ) try: while 1: if stream_bytes_left <= 0: break stream_buff = self.sock.recv(min(64 * 1024, stream_bytes_left)) if not stream_buff: break buff_len = len(stream_buff) stream_bytes_left -= buff_len file.write(stream_buff) # Statistics self.last_recv_time = time.time() self.incomplete_buff_recv += 1 self.bytes_recv += buff_len self.server.bytes_recv += buff_len except Exception as err: self.log("Stream read error: %s" % Debug.formatException(err)) if config.debug_socket: self.log("End stream %s, file pos: %s" % (message["to"], file.tell())) self.incomplete_buff_recv = 0 self.waiting_requests[message["to"]]["evt"].set(message) # Set the response to event del self.waiting_streams[message["to"]] del self.waiting_requests[message["to"]] if unpacker_stream_bytes: return buff[buff_stream_start + unpacker_stream_bytes:] else: return b"" # My handshake info def getHandshakeInfo(self): # No TLS for onion connections if self.ip_type == "onion": crypt_supported = [] elif self.ip in self.server.broken_ssl_ips: crypt_supported = [] else: crypt_supported = CryptConnection.manager.crypt_supported # No peer id for onion connections if self.ip_type == "onion" or self.ip in config.ip_local: peer_id = "" else: peer_id = self.server.peer_id # Setup peer lock from requested onion address if self.handshake and self.handshake.get("target_ip", "").endswith(".onion") and self.server.tor_manager.start_onions: self.target_onion = self.handshake.get("target_ip").replace(".onion", "") # My onion address if not self.server.tor_manager.site_onions.values(): self.server.log.warning("Unknown target onion address: %s" % self.target_onion) handshake = { "version": config.version, "protocol": "v2", "use_bin_type": True, "peer_id": peer_id, "fileserver_port": self.server.port, "port_opened": self.server.port_opened.get(self.ip_type, None), "target_ip": self.ip, "rev": config.rev, "crypt_supported": crypt_supported, "crypt": self.crypt, "time": int(time.time()) } if self.target_onion: handshake["onion"] = self.target_onion elif self.ip_type == "onion": handshake["onion"] = self.server.tor_manager.getOnion("global") if self.is_tracker_connection: handshake["tracker_connection"] = True if config.debug_socket: self.log("My Handshake: %s" % handshake) return handshake def setHandshake(self, handshake): if config.debug_socket: self.log("Remote Handshake: %s" % handshake) if handshake.get("peer_id") == self.server.peer_id and not handshake.get("tracker_connection") and not self.is_tracker_connection: self.close("Same peer id, can't connect to myself") self.server.peer_blacklist.append((handshake["target_ip"], handshake["fileserver_port"])) return False self.handshake = handshake if handshake.get("port_opened", None) is False and "onion" not in handshake and not self.is_private_ip: # Not connectable self.port = 0 else: self.port = int(handshake["fileserver_port"]) # Set peer fileserver port if handshake.get("use_bin_type") and self.unpacker: unprocessed_bytes_num = self.getUnpackerUnprocessedBytesNum() self.log("Changing unpacker to bin type (unprocessed bytes: %s)" % unprocessed_bytes_num) unprocessed_bytes = self.unpacker.read_bytes(unprocessed_bytes_num) self.unpacker = self.getMsgpackUnpacker() # Create new unpacker for different msgpack type self.unpacker_bytes = 0 if unprocessed_bytes: self.unpacker.feed(unprocessed_bytes) # Check if we can encrypt the connection if handshake.get("crypt_supported") and self.ip not in self.server.broken_ssl_ips: if type(handshake["crypt_supported"][0]) is bytes: handshake["crypt_supported"] = [item.decode() for item in handshake["crypt_supported"]] # Backward compatibility if self.ip_type == "onion" or self.ip in config.ip_local: crypt = None elif handshake.get("crypt"): # Recommended crypt by server crypt = handshake["crypt"] else: # Select the best supported on both sides crypt = CryptConnection.manager.selectCrypt(handshake["crypt_supported"]) if crypt: self.crypt = crypt if self.type == "in" and handshake.get("onion") and not self.ip_type == "onion": # Set incoming connection's onion address if self.server.ips.get(self.ip) == self: del self.server.ips[self.ip] self.setIp(handshake["onion"] + ".onion") self.log("Changing ip to %s" % self.ip) self.server.ips[self.ip] = self self.updateName() self.event_connected.set(True) # Mark handshake as done self.event_connected = None self.handshake_time = time.time() # Handle incoming message def handleMessage(self, message): cmd = message["cmd"] self.last_message_time = time.time() self.last_cmd_recv = cmd if cmd == "response": # New style response if message["to"] in self.waiting_requests: if self.last_send_time and len(self.waiting_requests) == 1: ping = time.time() - self.last_send_time self.last_ping_delay = ping self.waiting_requests[message["to"]]["evt"].set(message) # Set the response to event del self.waiting_requests[message["to"]] elif message["to"] == 0: # Other peers handshake ping = time.time() - self.start_time if config.debug_socket: self.log("Handshake response: %s, ping: %s" % (message, ping)) self.last_ping_delay = ping # Server switched to crypt, lets do it also if not crypted already if message.get("crypt") and not self.sock_wrapped: self.crypt = message["crypt"] server = (self.type == "in") self.log("Crypt out connection using: %s (server side: %s, ping: %.3fs)..." % (self.crypt, server, ping)) self.sock = CryptConnection.manager.wrapSocket(self.sock, self.crypt, server, cert_pin=self.cert_pin) self.sock.do_handshake() self.sock_wrapped = True if not self.sock_wrapped and self.cert_pin: self.close("Crypt connection error: Socket not encrypted, but certificate pin present") return self.setHandshake(message) else: self.log("Unknown response: %s" % message) elif cmd: self.server.num_recv += 1 if cmd == "handshake": self.handleHandshake(message) else: self.server.handleRequest(self, message) # Incoming handshake set request def handleHandshake(self, message): self.setHandshake(message["params"]) data = self.getHandshakeInfo() data["cmd"] = "response" data["to"] = message["req_id"] self.send(data) # Send response to handshake # Sent crypt request to client if self.crypt and not self.sock_wrapped: server = (self.type == "in") self.log("Crypt in connection using: %s (server side: %s)..." % (self.crypt, server)) try: self.sock = CryptConnection.manager.wrapSocket(self.sock, self.crypt, server, cert_pin=self.cert_pin) self.sock_wrapped = True except Exception as err: if not config.force_encryption: self.log("Crypt connection error, adding %s:%s as broken ssl. %s" % (self.ip, self.port, Debug.formatException(err))) self.server.broken_ssl_ips[self.ip] = True self.close("Broken ssl") if not self.sock_wrapped and self.cert_pin: self.close("Crypt connection error: Socket not encrypted, but certificate pin present") # Send data to connection def send(self, message, streaming=False): self.last_send_time = time.time() if config.debug_socket: self.log("Send: %s, to: %s, streaming: %s, site: %s, inner_path: %s, req_id: %s" % ( message.get("cmd"), message.get("to"), streaming, message.get("params", {}).get("site"), message.get("params", {}).get("inner_path"), message.get("req_id")) ) if not self.sock: self.log("Send error: missing socket") return False if not self.connected and message.get("cmd") != "handshake": self.log("Wait for handshake before send request") self.event_connected.get() try: stat_key = message.get("cmd", "unknown") if stat_key == "response": stat_key = "response: %s" % self.last_cmd_recv else: self.server.num_sent += 1 self.server.stat_sent[stat_key]["num"] += 1 if streaming: with self.send_lock: bytes_sent = Msgpack.stream(message, self.sock.sendall) self.bytes_sent += bytes_sent self.server.bytes_sent += bytes_sent self.server.stat_sent[stat_key]["bytes"] += bytes_sent message = None else: data = Msgpack.pack(message) self.bytes_sent += len(data) self.server.bytes_sent += len(data) self.server.stat_sent[stat_key]["bytes"] += len(data) message = None with self.send_lock: self.sock.sendall(data) except Exception as err: self.close("Send error: %s (cmd: %s)" % (err, stat_key)) return False self.last_sent_time = time.time() return True # Stream file to connection without msgpacking def sendRawfile(self, file, read_bytes): buff = 64 * 1024 bytes_left = read_bytes bytes_sent = 0 while True: self.last_send_time = time.time() data = file.read(min(bytes_left, buff)) bytes_sent += len(data) with self.send_lock: self.sock.sendall(data) bytes_left -= buff if bytes_left <= 0: break self.bytes_sent += bytes_sent self.server.bytes_sent += bytes_sent self.server.stat_sent["raw_file"]["num"] += 1 self.server.stat_sent["raw_file"]["bytes"] += bytes_sent return True # Create and send a request to peer def request(self, cmd, params={}, stream_to=None): # Last command sent more than 10 sec ago, timeout if self.waiting_requests and self.protocol == "v2" and time.time() - max(self.last_req_time, self.last_recv_time) > 10: self.close("Request %s timeout: %.3fs" % (self.last_cmd_sent, time.time() - self.last_send_time)) return False self.last_req_time = time.time() self.last_cmd_sent = cmd self.req_id += 1 data = {"cmd": cmd, "req_id": self.req_id, "params": params} event = gevent.event.AsyncResult() # Create new event for response self.waiting_requests[self.req_id] = {"evt": event, "cmd": cmd} if stream_to: self.waiting_streams[self.req_id] = stream_to self.send(data) # Send request res = event.get() # Wait until event solves return res def ping(self): s = time.time() response = None with gevent.Timeout(10.0, False): try: response = self.request("ping") except Exception as err: self.log("Ping error: %s" % Debug.formatException(err)) if response and "body" in response and response["body"] == b"Pong!": self.last_ping_delay = time.time() - s return True else: return False # Close connection def close(self, reason="Unknown"): if self.closed: return False # Already closed self.closed = True self.connected = False if self.event_connected: self.event_connected.set(False) self.log( "Closing connection: %s, waiting_requests: %s, sites: %s, buff: %s..." % (reason, len(self.waiting_requests), self.sites, self.incomplete_buff_recv) ) for request in self.waiting_requests.values(): # Mark pending requests failed request["evt"].set(False) self.waiting_requests = {} self.waiting_streams = {} self.sites = 0 self.server.removeConnection(self) # Remove connection from server registry try: if self.sock: self.sock.shutdown(gevent.socket.SHUT_WR) self.sock.close() except Exception as err: if config.debug_socket: self.log("Close error: %s" % err) # Little cleanup self.sock = None self.unpacker = None self.event_connected = None ================================================ FILE: src/Connection/ConnectionServer.py ================================================ import logging import time import sys import socket from collections import defaultdict import gevent import msgpack from gevent.server import StreamServer from gevent.pool import Pool import util from util import helper from Debug import Debug from .Connection import Connection from Config import config from Crypt import CryptConnection from Crypt import CryptHash from Tor import TorManager from Site import SiteManager class ConnectionServer(object): def __init__(self, ip=None, port=None, request_handler=None): if not ip: if config.fileserver_ip_type == "ipv6": ip = "::1" else: ip = "127.0.0.1" port = 15441 self.ip = ip self.port = port self.last_connection_id = 1 # Connection id incrementer self.log = logging.getLogger("ConnServer") self.port_opened = {} self.peer_blacklist = SiteManager.peer_blacklist self.tor_manager = TorManager(self.ip, self.port) self.connections = [] # Connections self.whitelist = config.ip_local # No flood protection on this ips self.ip_incoming = {} # Incoming connections from ip in the last minute to avoid connection flood self.broken_ssl_ips = {} # Peerids of broken ssl connections self.ips = {} # Connection by ip self.has_internet = True # Internet outage detection self.stream_server = None self.stream_server_proxy = None self.running = False self.stopping = False self.thread_checker = None self.stat_recv = defaultdict(lambda: defaultdict(int)) self.stat_sent = defaultdict(lambda: defaultdict(int)) self.bytes_recv = 0 self.bytes_sent = 0 self.num_recv = 0 self.num_sent = 0 self.num_incoming = 0 self.num_outgoing = 0 self.had_external_incoming = False self.timecorrection = 0.0 self.pool = Pool(500) # do not accept more than 500 connections # Bittorrent style peerid self.peer_id = "-UT3530-%s" % CryptHash.random(12, "base64") # Check msgpack version if msgpack.version[0] == 0 and msgpack.version[1] < 4: self.log.error( "Error: Unsupported msgpack version: %s (<0.4.0), please run `sudo apt-get install python-pip; sudo pip install msgpack --upgrade`" % str(msgpack.version) ) sys.exit(0) if request_handler: self.handleRequest = request_handler def start(self, check_connections=True): if self.stopping: return False self.running = True if check_connections: self.thread_checker = gevent.spawn(self.checkConnections) CryptConnection.manager.loadCerts() if config.tor != "disable": self.tor_manager.start() if not self.port: self.log.info("No port found, not binding") return False self.log.debug("Binding to: %s:%s, (msgpack: %s), supported crypt: %s" % ( self.ip, self.port, ".".join(map(str, msgpack.version)), CryptConnection.manager.crypt_supported )) try: self.stream_server = StreamServer( (self.ip, self.port), self.handleIncomingConnection, spawn=self.pool, backlog=100 ) except Exception as err: self.log.info("StreamServer create error: %s" % Debug.formatException(err)) def listen(self): if not self.running: return None if self.stream_server_proxy: gevent.spawn(self.listenProxy) try: self.stream_server.serve_forever() except Exception as err: self.log.info("StreamServer listen error: %s" % err) return False self.log.debug("Stopped.") def stop(self): self.log.debug("Stopping %s" % self.stream_server) self.stopping = True self.running = False if self.thread_checker: gevent.kill(self.thread_checker) if self.stream_server: self.stream_server.stop() def closeConnections(self): self.log.debug("Closing all connection: %s" % len(self.connections)) for connection in self.connections[:]: connection.close("Close all connections") def handleIncomingConnection(self, sock, addr): if config.offline: sock.close() return False ip, port = addr[0:2] ip = ip.lower() if ip.startswith("::ffff:"): # IPv6 to IPv4 mapping ip = ip.replace("::ffff:", "", 1) self.num_incoming += 1 if not self.had_external_incoming and not helper.isPrivateIp(ip): self.had_external_incoming = True # Connection flood protection if ip in self.ip_incoming and ip not in self.whitelist: self.ip_incoming[ip] += 1 if self.ip_incoming[ip] > 6: # Allow 6 in 1 minute from same ip self.log.debug("Connection flood detected from %s" % ip) time.sleep(30) sock.close() return False else: self.ip_incoming[ip] = 1 connection = Connection(self, ip, port, sock) self.connections.append(connection) if ip not in config.ip_local: self.ips[ip] = connection connection.handleIncomingConnection(sock) def handleMessage(self, *args, **kwargs): pass def getConnection(self, ip=None, port=None, peer_id=None, create=True, site=None, is_tracker_connection=False): ip_type = helper.getIpType(ip) has_per_site_onion = (ip.endswith(".onion") or self.port_opened.get(ip_type, None) == False) and self.tor_manager.start_onions and site if has_per_site_onion: # Site-unique connection for Tor if ip.endswith(".onion"): site_onion = self.tor_manager.getOnion(site.address) else: site_onion = self.tor_manager.getOnion("global") key = ip + site_onion else: key = ip # Find connection by ip if key in self.ips: connection = self.ips[key] if not peer_id or connection.handshake.get("peer_id") == peer_id: # Filter by peer_id if not connection.connected and create: succ = connection.event_connected.get() # Wait for connection if not succ: raise Exception("Connection event return error") return connection # Recover from connection pool for connection in self.connections: if connection.ip == ip: if peer_id and connection.handshake.get("peer_id") != peer_id: # Does not match continue if ip.endswith(".onion") and self.tor_manager.start_onions and ip.replace(".onion", "") != connection.target_onion: # For different site continue if not connection.connected and create: succ = connection.event_connected.get() # Wait for connection if not succ: raise Exception("Connection event return error") return connection # No connection found if create and not config.offline: # Allow to create new connection if not found if port == 0: raise Exception("This peer is not connectable") if (ip, port) in self.peer_blacklist and not is_tracker_connection: raise Exception("This peer is blacklisted") try: if has_per_site_onion: # Lock connection to site connection = Connection(self, ip, port, target_onion=site_onion, is_tracker_connection=is_tracker_connection) else: connection = Connection(self, ip, port, is_tracker_connection=is_tracker_connection) self.num_outgoing += 1 self.ips[key] = connection self.connections.append(connection) connection.log("Connecting... (site: %s)" % site) succ = connection.connect() if not succ: connection.close("Connection event return error") raise Exception("Connection event return error") except Exception as err: connection.close("%s Connect error: %s" % (ip, Debug.formatException(err))) raise err if len(self.connections) > config.global_connected_limit: gevent.spawn(self.checkMaxConnections) return connection else: return None def removeConnection(self, connection): # Delete if same as in registry if self.ips.get(connection.ip) == connection: del self.ips[connection.ip] # Site locked connection if connection.target_onion: if self.ips.get(connection.ip + connection.target_onion) == connection: del self.ips[connection.ip + connection.target_onion] # Cert pinned connection if connection.cert_pin and self.ips.get(connection.ip + "#" + connection.cert_pin) == connection: del self.ips[connection.ip + "#" + connection.cert_pin] if connection in self.connections: self.connections.remove(connection) def checkConnections(self): run_i = 0 time.sleep(15) while self.running: run_i += 1 self.ip_incoming = {} # Reset connected ips counter last_message_time = 0 s = time.time() for connection in self.connections[:]: # Make a copy if connection.ip.endswith(".onion") or config.tor == "always": timeout_multipler = 2 else: timeout_multipler = 1 idle = time.time() - max(connection.last_recv_time, connection.start_time, connection.last_message_time) if connection.last_message_time > last_message_time and not connection.is_private_ip: # Message from local IPs does not means internet connection last_message_time = connection.last_message_time if connection.unpacker and idle > 30: # Delete the unpacker if not needed del connection.unpacker connection.unpacker = None elif connection.last_cmd_sent == "announce" and idle > 20: # Bootstrapper connection close after 20 sec connection.close("[Cleanup] Tracker connection, idle: %.3fs" % idle) if idle > 60 * 60: # Wake up after 1h connection.close("[Cleanup] After wakeup, idle: %.3fs" % idle) elif idle > 20 * 60 and connection.last_send_time < time.time() - 10: # Idle more than 20 min and we have not sent request in last 10 sec if not connection.ping(): connection.close("[Cleanup] Ping timeout") elif idle > 10 * timeout_multipler and connection.incomplete_buff_recv > 0: # Incomplete data with more than 10 sec idle connection.close("[Cleanup] Connection buff stalled") elif idle > 10 * timeout_multipler and connection.protocol == "?": # No connection after 10 sec connection.close( "[Cleanup] Connect timeout: %.3fs" % idle ) elif idle > 10 * timeout_multipler and connection.waiting_requests and time.time() - connection.last_send_time > 10 * timeout_multipler: # Sent command and no response in 10 sec connection.close( "[Cleanup] Command %s timeout: %.3fs" % (connection.last_cmd_sent, time.time() - connection.last_send_time) ) elif idle < 60 and connection.bad_actions > 40: connection.close( "[Cleanup] Too many bad actions: %s" % connection.bad_actions ) elif idle > 5 * 60 and connection.sites == 0: connection.close( "[Cleanup] No site for connection" ) elif run_i % 90 == 0: # Reset bad action counter every 30 min connection.bad_actions = 0 # Internet outage detection if time.time() - last_message_time > max(60, 60 * 10 / max(1, float(len(self.connections)) / 50)): # Offline: Last message more than 60-600sec depending on connection number if self.has_internet and last_message_time: self.has_internet = False self.onInternetOffline() else: # Online if not self.has_internet: self.has_internet = True self.onInternetOnline() self.timecorrection = self.getTimecorrection() if time.time() - s > 0.01: self.log.debug("Connection cleanup in %.3fs" % (time.time() - s)) time.sleep(15) self.log.debug("Checkconnections ended") @util.Noparallel(blocking=False) def checkMaxConnections(self): if len(self.connections) < config.global_connected_limit: return 0 s = time.time() num_connected_before = len(self.connections) self.connections.sort(key=lambda connection: connection.sites) num_closed = 0 for connection in self.connections: idle = time.time() - max(connection.last_recv_time, connection.start_time, connection.last_message_time) if idle > 60: connection.close("Connection limit reached") num_closed += 1 if num_closed > config.global_connected_limit * 0.1: break self.log.debug("Closed %s connections of %s after reached limit %s in %.3fs" % ( num_closed, num_connected_before, config.global_connected_limit, time.time() - s )) return num_closed def onInternetOnline(self): self.log.info("Internet online") def onInternetOffline(self): self.had_external_incoming = False self.log.info("Internet offline") def getTimecorrection(self): corrections = sorted([ connection.handshake.get("time") - connection.handshake_time + connection.last_ping_delay for connection in self.connections if connection.handshake.get("time") and connection.last_ping_delay ]) if len(corrections) < 9: return 0.0 mid = int(len(corrections) / 2 - 1) median = (corrections[mid - 1] + corrections[mid] + corrections[mid + 1]) / 3 return median ================================================ FILE: src/Connection/__init__.py ================================================ from .ConnectionServer import ConnectionServer from .Connection import Connection ================================================ FILE: src/Content/ContentDb.py ================================================ import os from Db.Db import Db, DbTableError from Config import config from Plugin import PluginManager from Debug import Debug @PluginManager.acceptPlugins class ContentDb(Db): def __init__(self, path): Db.__init__(self, {"db_name": "ContentDb", "tables": {}}, path) self.foreign_keys = True def init(self): try: self.schema = self.getSchema() try: self.checkTables() except DbTableError: pass self.log.debug("Checking foreign keys...") foreign_key_error = self.execute("PRAGMA foreign_key_check").fetchone() if foreign_key_error: raise Exception("Database foreign key error: %s" % foreign_key_error) except Exception as err: self.log.error("Error loading content.db: %s, rebuilding..." % Debug.formatException(err)) self.close() os.unlink(self.db_path) # Remove and try again Db.__init__(self, {"db_name": "ContentDb", "tables": {}}, self.db_path) self.foreign_keys = True self.schema = self.getSchema() try: self.checkTables() except DbTableError: pass self.site_ids = {} self.sites = {} def getSchema(self): schema = {} schema["db_name"] = "ContentDb" schema["version"] = 3 schema["tables"] = {} if not self.getTableVersion("site"): self.log.debug("Migrating from table version-less content.db") version = int(self.execute("PRAGMA user_version").fetchone()[0]) if version > 0: self.checkTables() self.execute("INSERT INTO keyvalue ?", {"json_id": 0, "key": "table.site.version", "value": 1}) self.execute("INSERT INTO keyvalue ?", {"json_id": 0, "key": "table.content.version", "value": 1}) schema["tables"]["site"] = { "cols": [ ["site_id", "INTEGER PRIMARY KEY ASC NOT NULL UNIQUE"], ["address", "TEXT NOT NULL"] ], "indexes": [ "CREATE UNIQUE INDEX site_address ON site (address)" ], "schema_changed": 1 } schema["tables"]["content"] = { "cols": [ ["content_id", "INTEGER PRIMARY KEY UNIQUE NOT NULL"], ["site_id", "INTEGER REFERENCES site (site_id) ON DELETE CASCADE"], ["inner_path", "TEXT"], ["size", "INTEGER"], ["size_files", "INTEGER"], ["size_files_optional", "INTEGER"], ["modified", "INTEGER"] ], "indexes": [ "CREATE UNIQUE INDEX content_key ON content (site_id, inner_path)", "CREATE INDEX content_modified ON content (site_id, modified)" ], "schema_changed": 1 } return schema def initSite(self, site): self.sites[site.address] = site def needSite(self, site): if site.address not in self.site_ids: self.execute("INSERT OR IGNORE INTO site ?", {"address": site.address}) self.site_ids = {} for row in self.execute("SELECT * FROM site"): self.site_ids[row["address"]] = row["site_id"] return self.site_ids[site.address] def deleteSite(self, site): site_id = self.site_ids.get(site.address, 0) if site_id: self.execute("DELETE FROM site WHERE site_id = :site_id", {"site_id": site_id}) del self.site_ids[site.address] del self.sites[site.address] def setContent(self, site, inner_path, content, size=0): self.insertOrUpdate("content", { "size": size, "size_files": sum([val["size"] for key, val in content.get("files", {}).items()]), "size_files_optional": sum([val["size"] for key, val in content.get("files_optional", {}).items()]), "modified": int(content.get("modified", 0)) }, { "site_id": self.site_ids.get(site.address, 0), "inner_path": inner_path }) def deleteContent(self, site, inner_path): self.execute("DELETE FROM content WHERE ?", {"site_id": self.site_ids.get(site.address, 0), "inner_path": inner_path}) def loadDbDict(self, site): res = self.execute( "SELECT GROUP_CONCAT(inner_path, '|') AS inner_paths FROM content WHERE ?", {"site_id": self.site_ids.get(site.address, 0)} ) row = res.fetchone() if row and row["inner_paths"]: inner_paths = row["inner_paths"].split("|") return dict.fromkeys(inner_paths, False) else: return {} def getTotalSize(self, site, ignore=None): params = {"site_id": self.site_ids.get(site.address, 0)} if ignore: params["not__inner_path"] = ignore res = self.execute("SELECT SUM(size) + SUM(size_files) AS size, SUM(size_files_optional) AS size_optional FROM content WHERE ?", params) row = dict(res.fetchone()) if not row["size"]: row["size"] = 0 if not row["size_optional"]: row["size_optional"] = 0 return row["size"], row["size_optional"] def listModified(self, site, after=None, before=None): params = {"site_id": self.site_ids.get(site.address, 0)} if after: params["modified>"] = after if before: params["modified<"] = before res = self.execute("SELECT inner_path, modified FROM content WHERE ?", params) return {row["inner_path"]: row["modified"] for row in res} content_dbs = {} def getContentDb(path=None): if not path: path = "%s/content.db" % config.data_dir if path not in content_dbs: content_dbs[path] = ContentDb(path) content_dbs[path].init() return content_dbs[path] getContentDb() # Pre-connect to default one ================================================ FILE: src/Content/ContentDbDict.py ================================================ import time import os from . import ContentDb from Debug import Debug from Config import config class ContentDbDict(dict): def __init__(self, site, *args, **kwargs): s = time.time() self.site = site self.cached_keys = [] self.log = self.site.log self.db = ContentDb.getContentDb() self.db_id = self.db.needSite(site) self.num_loaded = 0 super(ContentDbDict, self).__init__(self.db.loadDbDict(site)) # Load keys from database self.log.debug("ContentDb init: %.3fs, found files: %s, sites: %s" % (time.time() - s, len(self), len(self.db.site_ids))) def loadItem(self, key): try: self.num_loaded += 1 if self.num_loaded % 100 == 0: if config.verbose: self.log.debug("Loaded json: %s (latest: %s) called by: %s" % (self.num_loaded, key, Debug.formatStack())) else: self.log.debug("Loaded json: %s (latest: %s)" % (self.num_loaded, key)) content = self.site.storage.loadJson(key) dict.__setitem__(self, key, content) except IOError: if dict.get(self, key): self.__delitem__(key) # File not exists anymore raise KeyError(key) self.addCachedKey(key) self.checkLimit() return content def getItemSize(self, key): return self.site.storage.getSize(key) # Only keep last 10 accessed json in memory def checkLimit(self): if len(self.cached_keys) > 10: key_deleted = self.cached_keys.pop(0) dict.__setitem__(self, key_deleted, False) def addCachedKey(self, key): if key not in self.cached_keys and key != "content.json" and len(key) > 40: # Always keep keys smaller than 40 char self.cached_keys.append(key) def __getitem__(self, key): val = dict.get(self, key) if val: # Already loaded return val elif val is None: # Unknown key raise KeyError(key) elif val is False: # Loaded before, but purged from cache return self.loadItem(key) def __setitem__(self, key, val): self.addCachedKey(key) self.checkLimit() size = self.getItemSize(key) self.db.setContent(self.site, key, val, size) dict.__setitem__(self, key, val) def __delitem__(self, key): self.db.deleteContent(self.site, key) dict.__delitem__(self, key) try: self.cached_keys.remove(key) except ValueError: pass def iteritems(self): for key in dict.keys(self): try: val = self[key] except Exception as err: self.log.warning("Error loading %s: %s" % (key, err)) continue yield key, val def items(self): back = [] for key in dict.keys(self): try: val = self[key] except Exception as err: self.log.warning("Error loading %s: %s" % (key, err)) continue back.append((key, val)) return back def values(self): back = [] for key, val in dict.iteritems(self): if not val: try: val = self.loadItem(key) except Exception: continue back.append(val) return back def get(self, key, default=None): try: return self.__getitem__(key) except KeyError: return default except Exception as err: self.site.bad_files[key] = self.site.bad_files.get(key, 1) dict.__delitem__(self, key) self.log.warning("Error loading %s: %s" % (key, err)) return default def execute(self, query, params={}): params["site_id"] = self.db_id return self.db.execute(query, params) if __name__ == "__main__": import psutil process = psutil.Process(os.getpid()) s_mem = process.memory_info()[0] / float(2 ** 20) root = "data-live/1MaiL5gfBM1cyb4a8e3iiL8L5gXmoAJu27" contents = ContentDbDict("1MaiL5gfBM1cyb4a8e3iiL8L5gXmoAJu27", root) print("Init len", len(contents)) s = time.time() for dir_name in os.listdir(root + "/data/users/")[0:8000]: contents["data/users/%s/content.json" % dir_name] print("Load: %.3fs" % (time.time() - s)) s = time.time() found = 0 for key, val in contents.items(): found += 1 assert key assert val print("Found:", found) print("Iteritem: %.3fs" % (time.time() - s)) s = time.time() found = 0 for key in list(contents.keys()): found += 1 assert key in contents print("In: %.3fs" % (time.time() - s)) print("Len:", len(list(contents.values())), len(list(contents.keys()))) print("Mem: +", process.memory_info()[0] / float(2 ** 20) - s_mem) ================================================ FILE: src/Content/ContentManager.py ================================================ import json import time import re import os import copy import base64 import sys import gevent from Debug import Debug from Crypt import CryptHash from Config import config from util import helper from util import Diff from util import SafeRe from Peer import PeerHashfield from .ContentDbDict import ContentDbDict from Plugin import PluginManager class VerifyError(Exception): pass class SignError(Exception): pass @PluginManager.acceptPlugins class ContentManager(object): def __init__(self, site): self.site = site self.log = self.site.log self.contents = ContentDbDict(site) self.hashfield = PeerHashfield() self.has_optional_files = False # Load all content.json files def loadContents(self): if len(self.contents) == 0: self.log.info("ContentDb not initialized, load files from filesystem...") self.loadContent(add_bad_files=False, delete_removed_files=False) self.site.settings["size"], self.site.settings["size_optional"] = self.getTotalSize() # Load hashfield cache if "hashfield" in self.site.settings.get("cache", {}): self.hashfield.frombytes(base64.b64decode(self.site.settings["cache"]["hashfield"])) del self.site.settings["cache"]["hashfield"] elif self.contents.get("content.json") and self.site.settings["size_optional"] > 0: self.site.storage.updateBadFiles() # No hashfield cache created yet self.has_optional_files = bool(self.hashfield) self.contents.db.initSite(self.site) def getFileChanges(self, old_files, new_files): deleted = {key: val for key, val in old_files.items() if key not in new_files} deleted_hashes = {val.get("sha512"): key for key, val in old_files.items() if key not in new_files} added = {key: val for key, val in new_files.items() if key not in old_files} renamed = {} for relative_path, node in added.items(): hash = node.get("sha512") if hash in deleted_hashes: relative_path_old = deleted_hashes[hash] renamed[relative_path_old] = relative_path del(deleted[relative_path_old]) return list(deleted), renamed # Load content.json to self.content # Return: Changed files ["index.html", "data/messages.json"], Deleted files ["old.jpg"] def loadContent(self, content_inner_path="content.json", add_bad_files=True, delete_removed_files=True, load_includes=True, force=False): content_inner_path = content_inner_path.strip("/") # Remove / from beginning old_content = self.contents.get(content_inner_path) content_path = self.site.storage.getPath(content_inner_path) content_dir = helper.getDirname(self.site.storage.getPath(content_inner_path)) content_inner_dir = helper.getDirname(content_inner_path) if os.path.isfile(content_path): try: # Check if file is newer than what we have if not force and old_content and not self.site.settings.get("own"): for line in open(content_path): if '"modified"' not in line: continue match = re.search(r"([0-9\.]+),$", line.strip(" \r\n")) if match and float(match.group(1)) <= old_content.get("modified", 0): self.log.debug("%s loadContent same json file, skipping" % content_inner_path) return [], [] new_content = self.site.storage.loadJson(content_inner_path) except Exception as err: self.log.warning("%s load error: %s" % (content_path, Debug.formatException(err))) return [], [] else: self.log.debug("Content.json not exist: %s" % content_path) return [], [] # Content.json not exist try: # Get the files where the sha512 changed changed = [] deleted = [] # Check changed for relative_path, info in new_content.get("files", {}).items(): if "sha512" in info: hash_type = "sha512" else: # Backward compatibility hash_type = "sha1" new_hash = info[hash_type] if old_content and old_content["files"].get(relative_path): # We have the file in the old content old_hash = old_content["files"][relative_path].get(hash_type) else: # The file is not in the old content old_hash = None if old_hash != new_hash: changed.append(content_inner_dir + relative_path) # Check changed optional files for relative_path, info in new_content.get("files_optional", {}).items(): file_inner_path = content_inner_dir + relative_path new_hash = info["sha512"] if old_content and old_content.get("files_optional", {}).get(relative_path): # We have the file in the old content old_hash = old_content["files_optional"][relative_path].get("sha512") if old_hash != new_hash and self.site.isDownloadable(file_inner_path): changed.append(file_inner_path) # Download new file elif old_hash != new_hash and self.hashfield.hasHash(old_hash) and not self.site.settings.get("own"): try: old_hash_id = self.hashfield.getHashId(old_hash) self.optionalRemoved(file_inner_path, old_hash_id, old_content["files_optional"][relative_path]["size"]) self.optionalDelete(file_inner_path) self.log.debug("Deleted changed optional file: %s" % file_inner_path) except Exception as err: self.log.warning("Error deleting file %s: %s" % (file_inner_path, Debug.formatException(err))) else: # The file is not in the old content if self.site.isDownloadable(file_inner_path): changed.append(file_inner_path) # Download new file # Check deleted if old_content: old_files = dict( old_content.get("files", {}), **old_content.get("files_optional", {}) ) new_files = dict( new_content.get("files", {}), **new_content.get("files_optional", {}) ) deleted, renamed = self.getFileChanges(old_files, new_files) for relative_path_old, relative_path_new in renamed.items(): self.log.debug("Renaming: %s -> %s" % (relative_path_old, relative_path_new)) if relative_path_new in new_content.get("files_optional", {}): self.optionalRenamed(content_inner_dir + relative_path_old, content_inner_dir + relative_path_new) if self.site.storage.isFile(relative_path_old): try: self.site.storage.rename(relative_path_old, relative_path_new) if relative_path_new in changed: changed.remove(relative_path_new) self.log.debug("Renamed: %s -> %s" % (relative_path_old, relative_path_new)) except Exception as err: self.log.warning("Error renaming file: %s -> %s %s" % (relative_path_old, relative_path_new, err)) if deleted and not self.site.settings.get("own"): # Deleting files that no longer in content.json for file_relative_path in deleted: file_inner_path = content_inner_dir + file_relative_path try: # Check if the deleted file is optional if old_content.get("files_optional") and old_content["files_optional"].get(file_relative_path): self.optionalDelete(file_inner_path) old_hash = old_content["files_optional"][file_relative_path].get("sha512") if self.hashfield.hasHash(old_hash): old_hash_id = self.hashfield.getHashId(old_hash) self.optionalRemoved(file_inner_path, old_hash_id, old_content["files_optional"][file_relative_path]["size"]) else: self.site.storage.delete(file_inner_path) self.log.debug("Deleted file: %s" % file_inner_path) except Exception as err: self.log.debug("Error deleting file %s: %s" % (file_inner_path, Debug.formatException(err))) # Cleanup empty dirs tree = {root: [dirs, files] for root, dirs, files in os.walk(self.site.storage.getPath(content_inner_dir))} for root in sorted(tree, key=len, reverse=True): dirs, files = tree[root] if dirs == [] and files == []: root_inner_path = self.site.storage.getInnerPath(root.replace("\\", "/")) self.log.debug("Empty directory: %s, cleaning up." % root_inner_path) try: self.site.storage.deleteDir(root_inner_path) # Remove from tree dict to reflect changed state tree[os.path.dirname(root)][0].remove(os.path.basename(root)) except Exception as err: self.log.debug("Error deleting empty directory %s: %s" % (root_inner_path, err)) # Check archived if old_content and "user_contents" in new_content and "archived" in new_content["user_contents"]: old_archived = old_content.get("user_contents", {}).get("archived", {}) new_archived = new_content.get("user_contents", {}).get("archived", {}) self.log.debug("old archived: %s, new archived: %s" % (len(old_archived), len(new_archived))) archived_changed = { key: date_archived for key, date_archived in new_archived.items() if old_archived.get(key) != new_archived[key] } if archived_changed: self.log.debug("Archived changed: %s" % archived_changed) for archived_dirname, date_archived in archived_changed.items(): archived_inner_path = content_inner_dir + archived_dirname + "/content.json" if self.contents.get(archived_inner_path, {}).get("modified", 0) < date_archived: self.removeContent(archived_inner_path) deleted += archived_inner_path self.site.settings["size"], self.site.settings["size_optional"] = self.getTotalSize() # Check archived before if old_content and "user_contents" in new_content and "archived_before" in new_content["user_contents"]: old_archived_before = old_content.get("user_contents", {}).get("archived_before", 0) new_archived_before = new_content.get("user_contents", {}).get("archived_before", 0) if old_archived_before != new_archived_before: self.log.debug("Archived before changed: %s -> %s" % (old_archived_before, new_archived_before)) # Remove downloaded archived files num_removed_contents = 0 for archived_inner_path in self.listModified(before=new_archived_before): if archived_inner_path.startswith(content_inner_dir) and archived_inner_path != content_inner_path: self.removeContent(archived_inner_path) num_removed_contents += 1 self.site.settings["size"], self.site.settings["size_optional"] = self.getTotalSize() # Remove archived files from download queue num_removed_bad_files = 0 for bad_file in list(self.site.bad_files.keys()): if bad_file.endswith("content.json"): del self.site.bad_files[bad_file] num_removed_bad_files += 1 if num_removed_bad_files > 0: self.site.worker_manager.removeSolvedFileTasks(mark_as_good=False) gevent.spawn(self.site.update, since=0) self.log.debug("Archived removed contents: %s, removed bad files: %s" % (num_removed_contents, num_removed_bad_files)) # Load includes if load_includes and "includes" in new_content: for relative_path, info in list(new_content["includes"].items()): include_inner_path = content_inner_dir + relative_path if self.site.storage.isFile(include_inner_path): # Content.json exists, load it include_changed, include_deleted = self.loadContent( include_inner_path, add_bad_files=add_bad_files, delete_removed_files=delete_removed_files ) if include_changed: changed += include_changed # Add changed files if include_deleted: deleted += include_deleted # Add changed files else: # Content.json not exist, add to changed files self.log.debug("Missing include: %s" % include_inner_path) changed += [include_inner_path] # Load blind user includes (all subdir) if load_includes and "user_contents" in new_content: for relative_dir in os.listdir(content_dir): include_inner_path = content_inner_dir + relative_dir + "/content.json" if not self.site.storage.isFile(include_inner_path): continue # Content.json not exist include_changed, include_deleted = self.loadContent( include_inner_path, add_bad_files=add_bad_files, delete_removed_files=delete_removed_files, load_includes=False ) if include_changed: changed += include_changed # Add changed files if include_deleted: deleted += include_deleted # Add changed files # Save some memory new_content["signs"] = None if "cert_sign" in new_content: new_content["cert_sign"] = None if new_content.get("files_optional"): self.has_optional_files = True # Update the content self.contents[content_inner_path] = new_content except Exception as err: self.log.warning("%s parse error: %s" % (content_inner_path, Debug.formatException(err))) return [], [] # Content.json parse error # Add changed files to bad files if add_bad_files: for inner_path in changed: self.site.bad_files[inner_path] = self.site.bad_files.get(inner_path, 0) + 1 for inner_path in deleted: if inner_path in self.site.bad_files: del self.site.bad_files[inner_path] self.site.worker_manager.removeSolvedFileTasks() if new_content.get("modified", 0) > self.site.settings.get("modified", 0): # Dont store modifications in the far future (more than 10 minute) self.site.settings["modified"] = min(time.time() + 60 * 10, new_content["modified"]) return changed, deleted def removeContent(self, inner_path): inner_dir = helper.getDirname(inner_path) try: content = self.contents[inner_path] files = dict( content.get("files", {}), **content.get("files_optional", {}) ) except Exception as err: self.log.debug("Error loading %s for removeContent: %s" % (inner_path, Debug.formatException(err))) files = {} files["content.json"] = True # Deleting files that no longer in content.json for file_relative_path in files: file_inner_path = inner_dir + file_relative_path try: self.site.storage.delete(file_inner_path) self.log.debug("Deleted file: %s" % file_inner_path) except Exception as err: self.log.debug("Error deleting file %s: %s" % (file_inner_path, err)) try: self.site.storage.deleteDir(inner_dir) except Exception as err: self.log.debug("Error deleting dir %s: %s" % (inner_dir, err)) try: del self.contents[inner_path] except Exception as err: self.log.debug("Error key from contents: %s" % inner_path) # Get total size of site # Return: 32819 (size of files in kb) def getTotalSize(self, ignore=None): return self.contents.db.getTotalSize(self.site, ignore) def listModified(self, after=None, before=None): return self.contents.db.listModified(self.site, after=after, before=before) def listContents(self, inner_path="content.json", user_files=False): if inner_path not in self.contents: return [] back = [inner_path] content_inner_dir = helper.getDirname(inner_path) for relative_path in list(self.contents[inner_path].get("includes", {}).keys()): include_inner_path = content_inner_dir + relative_path back += self.listContents(include_inner_path) return back # Returns if file with the given modification date is archived or not def isArchived(self, inner_path, modified): match = re.match(r"(.*)/(.*?)/", inner_path) if not match: return False user_contents_inner_path = match.group(1) + "/content.json" relative_directory = match.group(2) file_info = self.getFileInfo(user_contents_inner_path) if file_info: time_archived_before = file_info.get("archived_before", 0) time_directory_archived = file_info.get("archived", {}).get(relative_directory, 0) if modified <= time_archived_before or modified <= time_directory_archived: return True else: return False else: return False def isDownloaded(self, inner_path, hash_id=None): if not hash_id: file_info = self.getFileInfo(inner_path) if not file_info or "sha512" not in file_info: return False hash_id = self.hashfield.getHashId(file_info["sha512"]) return hash_id in self.hashfield # Is modified since signing def isModified(self, inner_path): s = time.time() if inner_path.endswith("content.json"): try: is_valid = self.verifyFile(inner_path, self.site.storage.open(inner_path), ignore_same=False) if is_valid: is_modified = False else: is_modified = True except VerifyError: is_modified = True else: try: self.verifyFile(inner_path, self.site.storage.open(inner_path), ignore_same=False) is_modified = False except VerifyError: is_modified = True return is_modified # Find the file info line from self.contents # Return: { "sha512": "c29d73d...21f518", "size": 41 , "content_inner_path": "content.json"} def getFileInfo(self, inner_path, new_file=False): dirs = inner_path.split("/") # Parent dirs of content.json inner_path_parts = [dirs.pop()] # Filename relative to content.json while True: content_inner_path = "%s/content.json" % "/".join(dirs) content_inner_path = content_inner_path.strip("/") content = self.contents.get(content_inner_path) # Check in files if content and "files" in content: back = content["files"].get("/".join(inner_path_parts)) if back: back["content_inner_path"] = content_inner_path back["optional"] = False back["relative_path"] = "/".join(inner_path_parts) return back # Check in optional files if content and "files_optional" in content: # Check if file in this content.json back = content["files_optional"].get("/".join(inner_path_parts)) if back: back["content_inner_path"] = content_inner_path back["optional"] = True back["relative_path"] = "/".join(inner_path_parts) return back # Return the rules if user dir if content and "user_contents" in content: back = content["user_contents"] content_inner_path_dir = helper.getDirname(content_inner_path) relative_content_path = inner_path[len(content_inner_path_dir):] user_auth_address_match = re.match(r"([A-Za-z0-9]+)/.*", relative_content_path) if user_auth_address_match: user_auth_address = user_auth_address_match.group(1) back["content_inner_path"] = "%s%s/content.json" % (content_inner_path_dir, user_auth_address) else: back["content_inner_path"] = content_inner_path_dir + "content.json" back["optional"] = None back["relative_path"] = "/".join(inner_path_parts) return back if new_file and content: back = {} back["content_inner_path"] = content_inner_path back["relative_path"] = "/".join(inner_path_parts) back["optional"] = None return back # No inner path in this dir, lets try the parent dir if dirs: inner_path_parts.insert(0, dirs.pop()) else: # No more parent dirs break # Not found return False # Get rules for the file # Return: The rules for the file or False if not allowed def getRules(self, inner_path, content=None): if not inner_path.endswith("content.json"): # Find the files content.json first file_info = self.getFileInfo(inner_path) if not file_info: return False # File not found inner_path = file_info["content_inner_path"] if inner_path == "content.json": # Root content.json rules = {} rules["signers"] = self.getValidSigners(inner_path, content) return rules dirs = inner_path.split("/") # Parent dirs of content.json inner_path_parts = [dirs.pop()] # Filename relative to content.json inner_path_parts.insert(0, dirs.pop()) # Dont check in self dir while True: content_inner_path = "%s/content.json" % "/".join(dirs) parent_content = self.contents.get(content_inner_path.strip("/")) if parent_content and "includes" in parent_content: return parent_content["includes"].get("/".join(inner_path_parts)) elif parent_content and "user_contents" in parent_content: return self.getUserContentRules(parent_content, inner_path, content) else: # No inner path in this dir, lets try the parent dir if dirs: inner_path_parts.insert(0, dirs.pop()) else: # No more parent dirs break return False # Get rules for a user file # Return: The rules of the file or False if not allowed def getUserContentRules(self, parent_content, inner_path, content): user_contents = parent_content["user_contents"] # Delivered for directory if "inner_path" in parent_content: parent_content_dir = helper.getDirname(parent_content["inner_path"]) user_address = re.match(r"([A-Za-z0-9]*?)/", inner_path[len(parent_content_dir):]).group(1) else: user_address = re.match(r".*/([A-Za-z0-9]*?)/.*?$", inner_path).group(1) try: if not content: content = self.site.storage.loadJson(inner_path) # Read the file if no content specified user_urn = "%s/%s" % (content["cert_auth_type"], content["cert_user_id"]) # web/nofish@zeroid.bit cert_user_id = content["cert_user_id"] except Exception: # Content.json not exist user_urn = "n-a/n-a" cert_user_id = "n-a" if user_address in user_contents["permissions"]: rules = copy.copy(user_contents["permissions"].get(user_address, {})) # Default rules based on address else: rules = copy.copy(user_contents["permissions"].get(cert_user_id, {})) # Default rules based on username if rules is False: banned = True rules = {} else: banned = False if "signers" in rules: rules["signers"] = rules["signers"][:] # Make copy of the signers for permission_pattern, permission_rules in list(user_contents["permission_rules"].items()): # Regexp rules if not SafeRe.match(permission_pattern, user_urn): continue # Rule is not valid for user # Update rules if its better than current recorded ones for key, val in permission_rules.items(): if key not in rules: if type(val) is list: rules[key] = val[:] # Make copy else: rules[key] = val elif type(val) is int: # Int, update if larger if val > rules[key]: rules[key] = val elif hasattr(val, "startswith"): # String, update if longer if len(val) > len(rules[key]): rules[key] = val elif type(val) is list: # List, append rules[key] += val # Accepted cert signers rules["cert_signers"] = user_contents.get("cert_signers", {}) rules["cert_signers_pattern"] = user_contents.get("cert_signers_pattern") if "signers" not in rules: rules["signers"] = [] if not banned: rules["signers"].append(user_address) # Add user as valid signer rules["user_address"] = user_address rules["includes_allowed"] = False return rules # Get diffs for changed files def getDiffs(self, inner_path, limit=30 * 1024, update_files=True): if inner_path not in self.contents: return {} diffs = {} content_inner_path_dir = helper.getDirname(inner_path) for file_relative_path in self.contents[inner_path].get("files", {}): file_inner_path = content_inner_path_dir + file_relative_path if self.site.storage.isFile(file_inner_path + "-new"): # New version present diffs[file_relative_path] = Diff.diff( list(self.site.storage.open(file_inner_path)), list(self.site.storage.open(file_inner_path + "-new")), limit=limit ) if update_files: self.site.storage.delete(file_inner_path) self.site.storage.rename(file_inner_path + "-new", file_inner_path) if self.site.storage.isFile(file_inner_path + "-old"): # Old version present diffs[file_relative_path] = Diff.diff( list(self.site.storage.open(file_inner_path + "-old")), list(self.site.storage.open(file_inner_path)), limit=limit ) if update_files: self.site.storage.delete(file_inner_path + "-old") return diffs def hashFile(self, dir_inner_path, file_relative_path, optional=False): back = {} file_inner_path = dir_inner_path + "/" + file_relative_path file_path = self.site.storage.getPath(file_inner_path) file_size = os.path.getsize(file_path) sha512sum = CryptHash.sha512sum(file_path) # Calculate sha512 sum of file if optional and not self.hashfield.hasHash(sha512sum): self.optionalDownloaded(file_inner_path, self.hashfield.getHashId(sha512sum), file_size, own=True) back[file_relative_path] = {"sha512": sha512sum, "size": os.path.getsize(file_path)} return back def isValidRelativePath(self, relative_path): if ".." in relative_path.replace("\\", "/").split("/"): return False elif len(relative_path) > 255: return False elif relative_path[0] in ("/", "\\"): # Starts with return False elif relative_path[-1] in (".", " "): # Ends with return False elif re.match(r".*(^|/)(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9]|CONOUT\$|CONIN\$)(\.|/|$)", relative_path, re.IGNORECASE): # Protected on Windows return False else: return re.match(r"^[^\x00-\x1F\"*:<>?\\|]+$", relative_path) def sanitizePath(self, inner_path): return re.sub("[\x00-\x1F\"*:<>?\\|]", "", inner_path) # Hash files in directory def hashFiles(self, dir_inner_path, ignore_pattern=None, optional_pattern=None): files_node = {} files_optional_node = {} db_inner_path = self.site.storage.getDbFile() if dir_inner_path and not self.isValidRelativePath(dir_inner_path): ignored = True self.log.error("- [ERROR] Only ascii encoded directories allowed: %s" % dir_inner_path) for file_relative_path in self.site.storage.walk(dir_inner_path, ignore_pattern): file_name = helper.getFilename(file_relative_path) ignored = optional = False if file_name == "content.json": ignored = True elif file_name.startswith(".") or file_name.endswith("-old") or file_name.endswith("-new"): ignored = True elif not self.isValidRelativePath(file_relative_path): ignored = True self.log.error("- [ERROR] Invalid filename: %s" % file_relative_path) elif dir_inner_path == "" and db_inner_path and file_relative_path.startswith(db_inner_path): ignored = True elif optional_pattern and SafeRe.match(optional_pattern, file_relative_path): optional = True if ignored: # Ignore content.json, defined regexp and files starting with . self.log.info("- [SKIPPED] %s" % file_relative_path) else: if optional: self.log.info("- [OPTIONAL] %s" % file_relative_path) files_optional_node.update( self.hashFile(dir_inner_path, file_relative_path, optional=True) ) else: self.log.info("- %s" % file_relative_path) files_node.update( self.hashFile(dir_inner_path, file_relative_path) ) return files_node, files_optional_node # Create and sign a content.json # Return: The new content if filewrite = False def sign(self, inner_path="content.json", privatekey=None, filewrite=True, update_changed_files=False, extend=None, remove_missing_optional=False): if not inner_path.endswith("content.json"): raise SignError("Invalid file name, you can only sign content.json files") if inner_path in self.contents: content = self.contents.get(inner_path) if content and content.get("cert_sign", False) is None and self.site.storage.isFile(inner_path): # Recover cert_sign from file content["cert_sign"] = self.site.storage.loadJson(inner_path).get("cert_sign") else: content = None if not content: # Content not exist yet, load default one self.log.info("File %s not exist yet, loading default values..." % inner_path) if self.site.storage.isFile(inner_path): content = self.site.storage.loadJson(inner_path) if "files" not in content: content["files"] = {} if "signs" not in content: content["signs"] = {} else: content = {"files": {}, "signs": {}} # Default content.json if inner_path == "content.json": # It's the root content.json, add some more fields content["title"] = "%s - ZeroNet_" % self.site.address content["description"] = "" content["signs_required"] = 1 content["ignore"] = "" if extend: # Add extend keys if not exists for key, val in list(extend.items()): if not content.get(key): content[key] = val self.log.info("Extending content.json with: %s" % key) directory = helper.getDirname(self.site.storage.getPath(inner_path)) inner_directory = helper.getDirname(inner_path) self.log.info("Opening site data directory: %s..." % directory) changed_files = [inner_path] files_node, files_optional_node = self.hashFiles( helper.getDirname(inner_path), content.get("ignore"), content.get("optional") ) if not remove_missing_optional: for file_inner_path, file_details in content.get("files_optional", {}).items(): if file_inner_path not in files_optional_node: files_optional_node[file_inner_path] = file_details # Find changed files files_merged = files_node.copy() files_merged.update(files_optional_node) for file_relative_path, file_details in files_merged.items(): old_hash = content.get("files", {}).get(file_relative_path, {}).get("sha512") new_hash = files_merged[file_relative_path]["sha512"] if old_hash != new_hash: changed_files.append(inner_directory + file_relative_path) self.log.debug("Changed files: %s" % changed_files) if update_changed_files: for file_path in changed_files: self.site.storage.onUpdated(file_path) # Generate new content.json self.log.info("Adding timestamp and sha512sums to new content.json...") new_content = content.copy() # Create a copy of current content.json new_content["files"] = files_node # Add files sha512 hash if files_optional_node: new_content["files_optional"] = files_optional_node elif "files_optional" in new_content: del new_content["files_optional"] new_content["modified"] = int(time.time()) # Add timestamp if inner_path == "content.json": new_content["zeronet_version"] = config.version new_content["signs_required"] = content.get("signs_required", 1) new_content["address"] = self.site.address new_content["inner_path"] = inner_path # Verify private key from Crypt import CryptBitcoin self.log.info("Verifying private key...") privatekey_address = CryptBitcoin.privatekeyToAddress(privatekey) valid_signers = self.getValidSigners(inner_path, new_content) if privatekey_address not in valid_signers: raise SignError( "Private key invalid! Valid signers: %s, Private key address: %s" % (valid_signers, privatekey_address) ) self.log.info("Correct %s in valid signers: %s" % (privatekey_address, valid_signers)) if inner_path == "content.json" and privatekey_address == self.site.address: # If signing using the root key, then sign the valid signers signers_data = "%s:%s" % (new_content["signs_required"], ",".join(valid_signers)) new_content["signers_sign"] = CryptBitcoin.sign(str(signers_data), privatekey) if not new_content["signers_sign"]: self.log.info("Old style address, signers_sign is none") self.log.info("Signing %s..." % inner_path) if "signs" in new_content: del(new_content["signs"]) # Delete old signs if "sign" in new_content: del(new_content["sign"]) # Delete old sign (backward compatibility) sign_content = json.dumps(new_content, sort_keys=True) sign = CryptBitcoin.sign(sign_content, privatekey) # new_content["signs"] = content.get("signs", {}) # TODO: Multisig if sign: # If signing is successful (not an old address) new_content["signs"] = {} new_content["signs"][privatekey_address] = sign self.verifyContent(inner_path, new_content) if filewrite: self.log.info("Saving to %s..." % inner_path) self.site.storage.writeJson(inner_path, new_content) self.contents[inner_path] = new_content self.log.info("File %s signed!" % inner_path) if filewrite: # Written to file return True else: # Return the new content return new_content # The valid signers of content.json file # Return: ["1KRxE1s3oDyNDawuYWpzbLUwNm8oDbeEp6", "13ReyhCsjhpuCVahn1DHdf6eMqqEVev162"] def getValidSigners(self, inner_path, content=None): valid_signers = [] if inner_path == "content.json": # Root content.json if "content.json" in self.contents and "signers" in self.contents["content.json"]: valid_signers += self.contents["content.json"]["signers"][:] else: rules = self.getRules(inner_path, content) if rules and "signers" in rules: valid_signers += rules["signers"] if self.site.address not in valid_signers: valid_signers.append(self.site.address) # Site address always valid return valid_signers # Return: The required number of valid signs for the content.json def getSignsRequired(self, inner_path, content=None): return 1 # Todo: Multisig def verifyCertSign(self, user_address, user_auth_type, user_name, issuer_address, sign): from Crypt import CryptBitcoin cert_subject = "%s#%s/%s" % (user_address, user_auth_type, user_name) return CryptBitcoin.verify(cert_subject, issuer_address, sign) def verifyCert(self, inner_path, content): rules = self.getRules(inner_path, content) if not rules: raise VerifyError("No rules for this file") if not rules.get("cert_signers") and not rules.get("cert_signers_pattern"): return True # Does not need cert if "cert_user_id" not in content: raise VerifyError("Missing cert_user_id") if content["cert_user_id"].count("@") != 1: raise VerifyError("Invalid domain in cert_user_id") name, domain = content["cert_user_id"].rsplit("@", 1) cert_address = rules["cert_signers"].get(domain) if not cert_address: # Unknown Cert signer if rules.get("cert_signers_pattern") and SafeRe.match(rules["cert_signers_pattern"], domain): cert_address = domain else: raise VerifyError("Invalid cert signer: %s" % domain) return self.verifyCertSign(rules["user_address"], content["cert_auth_type"], name, cert_address, content["cert_sign"]) # Checks if the content.json content is valid # Return: True or False def verifyContent(self, inner_path, content): content_size = len(json.dumps(content, indent=1)) + sum([file["size"] for file in list(content["files"].values()) if file["size"] >= 0]) # Size of new content # Calculate old content size old_content = self.contents.get(inner_path) if old_content: old_content_size = len(json.dumps(old_content, indent=1)) + sum([file["size"] for file in list(old_content.get("files", {}).values())]) old_content_size_optional = sum([file["size"] for file in list(old_content.get("files_optional", {}).values())]) else: old_content_size = 0 old_content_size_optional = 0 # Reset site site on first content.json if not old_content and inner_path == "content.json": self.site.settings["size"] = 0 content_size_optional = sum([file["size"] for file in list(content.get("files_optional", {}).values()) if file["size"] >= 0]) site_size = self.site.settings["size"] - old_content_size + content_size # Site size without old content plus the new site_size_optional = self.site.settings["size_optional"] - old_content_size_optional + content_size_optional # Site size without old content plus the new site_size_limit = self.site.getSizeLimit() * 1024 * 1024 # Check site address if content.get("address") and content["address"] != self.site.address: raise VerifyError("Wrong site address: %s != %s" % (content["address"], self.site.address)) # Check file inner path if content.get("inner_path") and content["inner_path"] != inner_path: raise VerifyError("Wrong inner_path: %s" % content["inner_path"]) # If our content.json file bigger than the size limit throw error if inner_path == "content.json": content_size_file = len(json.dumps(content, indent=1)) if content_size_file > site_size_limit: # Save site size to display warning self.site.settings["size"] = site_size task = self.site.worker_manager.tasks.findTask(inner_path) if task: # Dont try to download from other peers self.site.worker_manager.failTask(task) raise VerifyError("Content too large %s B > %s B, aborting task..." % (site_size, site_size_limit)) # Verify valid filenames for file_relative_path in list(content.get("files", {}).keys()) + list(content.get("files_optional", {}).keys()): if not self.isValidRelativePath(file_relative_path): raise VerifyError("Invalid relative path: %s" % file_relative_path) if inner_path == "content.json": self.site.settings["size"] = site_size self.site.settings["size_optional"] = site_size_optional return True # Root content.json is passed else: if self.verifyContentInclude(inner_path, content, content_size, content_size_optional): self.site.settings["size"] = site_size self.site.settings["size_optional"] = site_size_optional return True else: raise VerifyError("Content verify error") def verifyContentInclude(self, inner_path, content, content_size, content_size_optional): # Load include details rules = self.getRules(inner_path, content) if not rules: raise VerifyError("No rules") # Check include size limit if rules.get("max_size") is not None: # Include size limit if content_size > rules["max_size"]: raise VerifyError("Include too large %sB > %sB" % (content_size, rules["max_size"])) if rules.get("max_size_optional") is not None: # Include optional files limit if content_size_optional > rules["max_size_optional"]: raise VerifyError("Include optional files too large %sB > %sB" % ( content_size_optional, rules["max_size_optional"]) ) # Filename limit if rules.get("files_allowed"): for file_inner_path in list(content["files"].keys()): if not SafeRe.match(r"^%s$" % rules["files_allowed"], file_inner_path): raise VerifyError("File not allowed: %s" % file_inner_path) if rules.get("files_allowed_optional"): for file_inner_path in list(content.get("files_optional", {}).keys()): if not SafeRe.match(r"^%s$" % rules["files_allowed_optional"], file_inner_path): raise VerifyError("Optional file not allowed: %s" % file_inner_path) # Check if content includes allowed if rules.get("includes_allowed") is False and content.get("includes"): raise VerifyError("Includes not allowed") return True # All good # Verify file validity # Return: None = Same as before, False = Invalid, True = Valid def verifyFile(self, inner_path, file, ignore_same=True): if inner_path.endswith("content.json"): # content.json: Check using sign from Crypt import CryptBitcoin try: if type(file) is dict: new_content = file else: try: if sys.version_info.major == 3 and sys.version_info.minor < 6: new_content = json.loads(file.read().decode("utf8")) else: new_content = json.load(file) except Exception as err: raise VerifyError("Invalid json file: %s" % err) if inner_path in self.contents: old_content = self.contents.get(inner_path, {"modified": 0}) # Checks if its newer the ours if old_content["modified"] == new_content["modified"] and ignore_same: # Ignore, have the same content.json return None elif old_content["modified"] > new_content["modified"]: # We have newer raise VerifyError( "We have newer (Our: %s, Sent: %s)" % (old_content["modified"], new_content["modified"]) ) if new_content["modified"] > time.time() + 60 * 60 * 24: # Content modified in the far future (allow 1 day+) raise VerifyError("Modify timestamp is in the far future!") if self.isArchived(inner_path, new_content["modified"]): if inner_path in self.site.bad_files: del self.site.bad_files[inner_path] raise VerifyError("This file is archived!") # Check sign sign = new_content.get("sign") signs = new_content.get("signs", {}) if "sign" in new_content: del(new_content["sign"]) # The file signed without the sign if "signs" in new_content: del(new_content["signs"]) # The file signed without the signs sign_content = json.dumps(new_content, sort_keys=True) # Dump the json to string to remove whitepsace # Fix float representation error on Android modified = new_content["modified"] if config.fix_float_decimals and type(modified) is float and not str(modified).endswith(".0"): modified_fixed = "{:.6f}".format(modified).strip("0.") sign_content = sign_content.replace( '"modified": %s' % repr(modified), '"modified": %s' % modified_fixed ) if signs: # New style signing valid_signers = self.getValidSigners(inner_path, new_content) signs_required = self.getSignsRequired(inner_path, new_content) if inner_path == "content.json" and len(valid_signers) > 1: # Check signers_sign on root content.json signers_data = "%s:%s" % (signs_required, ",".join(valid_signers)) if not CryptBitcoin.verify(signers_data, self.site.address, new_content["signers_sign"]): raise VerifyError("Invalid signers_sign!") if inner_path != "content.json" and not self.verifyCert(inner_path, new_content): # Check if cert valid raise VerifyError("Invalid cert!") valid_signs = 0 for address in valid_signers: if address in signs: valid_signs += CryptBitcoin.verify(sign_content, address, signs[address]) if valid_signs >= signs_required: break # Break if we has enough signs if valid_signs < signs_required: raise VerifyError("Valid signs: %s/%s" % (valid_signs, signs_required)) else: return self.verifyContent(inner_path, new_content) else: # Old style signing raise VerifyError("Invalid old-style sign") except Exception as err: self.log.warning("%s: verify sign error: %s" % (inner_path, Debug.formatException(err))) raise err else: # Check using sha512 hash file_info = self.getFileInfo(inner_path) if file_info: if CryptHash.sha512sum(file) != file_info.get("sha512", ""): raise VerifyError("Invalid hash") if file_info.get("size", 0) != file.tell(): raise VerifyError( "File size does not match %s <> %s" % (inner_path, file.tell(), file_info.get("size", 0)) ) return True else: # File not in content.json raise VerifyError("File not in content.json") def optionalDelete(self, inner_path): self.site.storage.delete(inner_path) def optionalDownloaded(self, inner_path, hash_id, size=None, own=False): if size is None: size = self.site.storage.getSize(inner_path) done = self.hashfield.appendHashId(hash_id) self.site.settings["optional_downloaded"] += size return done def optionalRemoved(self, inner_path, hash_id, size=None): if size is None: size = self.site.storage.getSize(inner_path) done = self.hashfield.removeHashId(hash_id) self.site.settings["optional_downloaded"] -= size return done def optionalRenamed(self, inner_path_old, inner_path_new): return True ================================================ FILE: src/Content/__init__.py ================================================ from .ContentManager import ContentManager ================================================ FILE: src/Crypt/Crypt.py ================================================ from Config import config from util import ThreadPool thread_pool_crypt = ThreadPool.ThreadPool(config.threads_crypt) ================================================ FILE: src/Crypt/CryptBitcoin.py ================================================ import logging import base64 import binascii import time import hashlib from util.Electrum import dbl_format from Config import config import util.OpensslFindPatch lib_verify_best = "sslcrypto" from lib import sslcrypto sslcurve_native = sslcrypto.ecc.get_curve("secp256k1") sslcurve_fallback = sslcrypto.fallback.ecc.get_curve("secp256k1") sslcurve = sslcurve_native def loadLib(lib_name, silent=False): global sslcurve, libsecp256k1message, lib_verify_best if lib_name == "libsecp256k1": s = time.time() from lib import libsecp256k1message import coincurve lib_verify_best = "libsecp256k1" if not silent: logging.info( "Libsecpk256k1 loaded: %s in %.3fs" % (type(coincurve._libsecp256k1.lib).__name__, time.time() - s) ) elif lib_name == "sslcrypto": sslcurve = sslcurve_native if sslcurve_native == sslcurve_fallback: logging.warning("SSLCurve fallback loaded instead of native") elif lib_name == "sslcrypto_fallback": sslcurve = sslcurve_fallback try: if not config.use_libsecp256k1: raise Exception("Disabled by config") loadLib("libsecp256k1") lib_verify_best = "libsecp256k1" except Exception as err: logging.info("Libsecp256k1 load failed: %s" % err) def newPrivatekey(): # Return new private key return sslcurve.private_to_wif(sslcurve.new_private_key()).decode() def newSeed(): return binascii.hexlify(sslcurve.new_private_key()).decode() def hdPrivatekey(seed, child): # Too large child id could cause problems privatekey_bin = sslcurve.derive_child(seed.encode(), child % 100000000) return sslcurve.private_to_wif(privatekey_bin).decode() def privatekeyToAddress(privatekey): # Return address from private key try: if len(privatekey) == 64: privatekey_bin = bytes.fromhex(privatekey) else: privatekey_bin = sslcurve.wif_to_private(privatekey.encode()) return sslcurve.private_to_address(privatekey_bin).decode() except Exception: # Invalid privatekey return False def sign(data, privatekey): # Return sign to data using private key if privatekey.startswith("23") and len(privatekey) > 52: return None # Old style private key not supported return base64.b64encode(sslcurve.sign( data.encode(), sslcurve.wif_to_private(privatekey.encode()), recoverable=True, hash=dbl_format )).decode() def verify(data, valid_address, sign, lib_verify=None): # Verify data using address and sign if not lib_verify: lib_verify = lib_verify_best if not sign: return False if lib_verify == "libsecp256k1": sign_address = libsecp256k1message.recover_address(data.encode("utf8"), sign).decode("utf8") elif lib_verify in ("sslcrypto", "sslcrypto_fallback"): publickey = sslcurve.recover(base64.b64decode(sign), data.encode(), hash=dbl_format) sign_address = sslcurve.public_to_address(publickey).decode() else: raise Exception("No library enabled for signature verification") if type(valid_address) is list: # Any address in the list return sign_address in valid_address else: # One possible address return sign_address == valid_address ================================================ FILE: src/Crypt/CryptConnection.py ================================================ import sys import logging import os import ssl import hashlib import random from Config import config from util import helper class CryptConnectionManager: def __init__(self): if config.openssl_bin_file: self.openssl_bin = config.openssl_bin_file elif sys.platform.startswith("win"): self.openssl_bin = "tools\\openssl\\openssl.exe" elif config.dist_type.startswith("bundle_linux"): self.openssl_bin = "../runtime/bin/openssl" else: self.openssl_bin = "openssl" self.context_client = None self.context_server = None self.openssl_conf_template = "src/lib/openssl/openssl.cnf" self.openssl_conf = config.data_dir + "/openssl.cnf" self.openssl_env = { "OPENSSL_CONF": self.openssl_conf, "RANDFILE": config.data_dir + "/openssl-rand.tmp" } self.crypt_supported = [] # Supported cryptos self.cacert_pem = config.data_dir + "/cacert-rsa.pem" self.cakey_pem = config.data_dir + "/cakey-rsa.pem" self.cert_pem = config.data_dir + "/cert-rsa.pem" self.cert_csr = config.data_dir + "/cert-rsa.csr" self.key_pem = config.data_dir + "/key-rsa.pem" self.log = logging.getLogger("CryptConnectionManager") self.log.debug("Version: %s" % ssl.OPENSSL_VERSION) self.fakedomains = [ "yahoo.com", "amazon.com", "live.com", "microsoft.com", "mail.ru", "csdn.net", "bing.com", "amazon.co.jp", "office.com", "imdb.com", "msn.com", "samsung.com", "huawei.com", "ztedevices.com", "godaddy.com", "w3.org", "gravatar.com", "creativecommons.org", "hatena.ne.jp", "adobe.com", "opera.com", "apache.org", "rambler.ru", "one.com", "nationalgeographic.com", "networksolutions.com", "php.net", "python.org", "phoca.cz", "debian.org", "ubuntu.com", "nazwa.pl", "symantec.com" ] def createSslContexts(self): if self.context_server and self.context_client: return False ciphers = "ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256:AES128-SHA256:AES256-SHA:" ciphers += "!aNULL:!eNULL:!EXPORT:!DSS:!DES:!RC4:!3DES:!MD5:!PSK" if hasattr(ssl, "PROTOCOL_TLS"): protocol = ssl.PROTOCOL_TLS else: protocol = ssl.PROTOCOL_TLSv1_2 self.context_client = ssl.SSLContext(protocol) self.context_client.check_hostname = False self.context_client.verify_mode = ssl.CERT_NONE self.context_server = ssl.SSLContext(protocol) self.context_server.load_cert_chain(self.cert_pem, self.key_pem) for ctx in (self.context_client, self.context_server): ctx.set_ciphers(ciphers) ctx.options |= ssl.OP_NO_COMPRESSION try: ctx.set_alpn_protocols(["h2", "http/1.1"]) ctx.set_npn_protocols(["h2", "http/1.1"]) except Exception: pass # Select crypt that supported by both sides # Return: Name of the crypto def selectCrypt(self, client_supported): for crypt in self.crypt_supported: if crypt in client_supported: return crypt return False # Wrap socket for crypt # Return: wrapped socket def wrapSocket(self, sock, crypt, server=False, cert_pin=None): if crypt == "tls-rsa": if server: sock_wrapped = self.context_server.wrap_socket(sock, server_side=True) else: sock_wrapped = self.context_client.wrap_socket(sock, server_hostname=random.choice(self.fakedomains)) if cert_pin: cert_hash = hashlib.sha256(sock_wrapped.getpeercert(True)).hexdigest() if cert_hash != cert_pin: raise Exception("Socket certificate does not match (%s != %s)" % (cert_hash, cert_pin)) return sock_wrapped else: return sock def removeCerts(self): if config.keep_ssl_cert: return False for file_name in ["cert-rsa.pem", "key-rsa.pem", "cacert-rsa.pem", "cakey-rsa.pem", "cacert-rsa.srl", "cert-rsa.csr", "openssl-rand.tmp"]: file_path = "%s/%s" % (config.data_dir, file_name) if os.path.isfile(file_path): os.unlink(file_path) # Load and create cert files is necessary def loadCerts(self): if config.disable_encryption: return False if self.createSslRsaCert() and "tls-rsa" not in self.crypt_supported: self.crypt_supported.append("tls-rsa") # Try to create RSA server cert + sign for connection encryption # Return: True on success def createSslRsaCert(self): casubjects = [ "/C=US/O=Amazon/OU=Server CA 1B/CN=Amazon", "/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3", "/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 High Assurance Server CA", "/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA" ] self.openssl_env['CN'] = random.choice(self.fakedomains) if os.path.isfile(self.cert_pem) and os.path.isfile(self.key_pem): self.createSslContexts() return True # Files already exits import subprocess # Replace variables in config template conf_template = open(self.openssl_conf_template).read() conf_template = conf_template.replace("$ENV::CN", self.openssl_env['CN']) open(self.openssl_conf, "w").write(conf_template) # Generate CAcert and CAkey cmd_params = helper.shellquote( self.openssl_bin, self.openssl_conf, random.choice(casubjects), self.cakey_pem, self.cacert_pem ) cmd = "%s req -new -newkey rsa:2048 -days 3650 -nodes -x509 -config %s -subj %s -keyout %s -out %s -batch" % cmd_params self.log.debug("Generating RSA CAcert and CAkey PEM files...") self.log.debug("Running: %s" % cmd) proc = subprocess.Popen( cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, env=self.openssl_env ) back = proc.stdout.read().strip().decode(errors="replace").replace("\r", "") proc.wait() if not (os.path.isfile(self.cacert_pem) and os.path.isfile(self.cakey_pem)): self.log.error("RSA ECC SSL CAcert generation failed, CAcert or CAkey files not exist. (%s)" % back) return False else: self.log.debug("Result: %s" % back) # Generate certificate key and signing request cmd_params = helper.shellquote( self.openssl_bin, self.key_pem, self.cert_csr, "/CN=" + self.openssl_env['CN'], self.openssl_conf, ) cmd = "%s req -new -newkey rsa:2048 -keyout %s -out %s -subj %s -sha256 -nodes -batch -config %s" % cmd_params self.log.debug("Generating certificate key and signing request...") proc = subprocess.Popen( cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, env=self.openssl_env ) back = proc.stdout.read().strip().decode(errors="replace").replace("\r", "") proc.wait() self.log.debug("Running: %s\n%s" % (cmd, back)) # Sign request and generate certificate cmd_params = helper.shellquote( self.openssl_bin, self.cert_csr, self.cacert_pem, self.cakey_pem, self.cert_pem, self.openssl_conf ) cmd = "%s x509 -req -in %s -CA %s -CAkey %s -set_serial 01 -out %s -days 730 -sha256 -extensions x509_ext -extfile %s" % cmd_params self.log.debug("Generating RSA cert...") proc = subprocess.Popen( cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, env=self.openssl_env ) back = proc.stdout.read().strip().decode(errors="replace").replace("\r", "") proc.wait() self.log.debug("Running: %s\n%s" % (cmd, back)) if os.path.isfile(self.cert_pem) and os.path.isfile(self.key_pem): self.createSslContexts() # Remove no longer necessary files os.unlink(self.openssl_conf) os.unlink(self.cacert_pem) os.unlink(self.cakey_pem) os.unlink(self.cert_csr) return True else: self.log.error("RSA ECC SSL cert generation failed, cert or key files not exist.") manager = CryptConnectionManager() ================================================ FILE: src/Crypt/CryptHash.py ================================================ import hashlib import os import base64 def sha512sum(file, blocksize=65536, format="hexdigest"): if type(file) is str: # Filename specified file = open(file, "rb") hash = hashlib.sha512() for block in iter(lambda: file.read(blocksize), b""): hash.update(block) # Truncate to 256bits is good enough if format == "hexdigest": return hash.hexdigest()[0:64] else: return hash.digest()[0:32] def sha256sum(file, blocksize=65536): if type(file) is str: # Filename specified file = open(file, "rb") hash = hashlib.sha256() for block in iter(lambda: file.read(blocksize), b""): hash.update(block) return hash.hexdigest() def random(length=64, encoding="hex"): if encoding == "base64": # Characters: A-Za-z0-9 hash = hashlib.sha512(os.urandom(256)).digest() return base64.b64encode(hash).decode("ascii").replace("+", "").replace("/", "").replace("=", "")[0:length] else: # Characters: a-f0-9 (faster) return hashlib.sha512(os.urandom(256)).hexdigest()[0:length] # Sha512 truncated to 256bits class Sha512t: def __init__(self, data): if data: self.sha512 = hashlib.sha512(data) else: self.sha512 = hashlib.sha512() def hexdigest(self): return self.sha512.hexdigest()[0:64] def digest(self): return self.sha512.digest()[0:32] def update(self, data): return self.sha512.update(data) def sha512t(data=None): return Sha512t(data) ================================================ FILE: src/Crypt/CryptRsa.py ================================================ import base64 import hashlib def sign(data, privatekey): import rsa from rsa import pkcs1 if "BEGIN RSA PRIVATE KEY" not in privatekey: privatekey = "-----BEGIN RSA PRIVATE KEY-----\n%s\n-----END RSA PRIVATE KEY-----" % privatekey priv = rsa.PrivateKey.load_pkcs1(privatekey) sign = rsa.pkcs1.sign(data, priv, 'SHA-256') return sign def verify(data, publickey, sign): import rsa from rsa import pkcs1 pub = rsa.PublicKey.load_pkcs1(publickey, format="DER") try: valid = rsa.pkcs1.verify(data, sign, pub) except pkcs1.VerificationError: valid = False return valid def privatekeyToPublickey(privatekey): import rsa from rsa import pkcs1 if "BEGIN RSA PRIVATE KEY" not in privatekey: privatekey = "-----BEGIN RSA PRIVATE KEY-----\n%s\n-----END RSA PRIVATE KEY-----" % privatekey priv = rsa.PrivateKey.load_pkcs1(privatekey) pub = rsa.PublicKey(priv.n, priv.e) return pub.save_pkcs1("DER") def publickeyToOnion(publickey): return base64.b32encode(hashlib.sha1(publickey).digest()[:10]).lower().decode("ascii") ================================================ FILE: src/Crypt/__init__.py ================================================ ================================================ FILE: src/Db/Db.py ================================================ import sqlite3 import json import time import logging import re import os import atexit import threading import sys import weakref import errno import gevent from Debug import Debug from .DbCursor import DbCursor from util import SafeRe from util import helper from util import ThreadPool from Config import config thread_pool_db = ThreadPool.ThreadPool(config.threads_db) next_db_id = 0 opened_dbs = [] # Close idle databases to save some memory def dbCleanup(): while 1: time.sleep(60 * 5) for db in opened_dbs[:]: idle = time.time() - db.last_query_time if idle > 60 * 5 and db.close_idle: db.close("Cleanup") def dbCommitCheck(): while 1: time.sleep(5) for db in opened_dbs[:]: if not db.need_commit: continue success = db.commit("Interval") if success: db.need_commit = False time.sleep(0.1) def dbCloseAll(): for db in opened_dbs[:]: db.close("Close all") gevent.spawn(dbCleanup) gevent.spawn(dbCommitCheck) atexit.register(dbCloseAll) class DbTableError(Exception): def __init__(self, message, table): super().__init__(message) self.table = table class Db(object): def __init__(self, schema, db_path, close_idle=False): global next_db_id self.db_path = db_path self.db_dir = os.path.dirname(db_path) + "/" self.schema = schema self.schema["version"] = self.schema.get("version", 1) self.conn = None self.cur = None self.cursors = weakref.WeakSet() self.id = next_db_id next_db_id += 1 self.progress_sleeping = False self.commiting = False self.log = logging.getLogger("Db#%s:%s" % (self.id, schema["db_name"])) self.table_names = None self.collect_stats = False self.foreign_keys = False self.need_commit = False self.query_stats = {} self.db_keyvalues = {} self.delayed_queue = [] self.delayed_queue_thread = None self.close_idle = close_idle self.last_query_time = time.time() self.last_sleep_time = time.time() self.num_execute_since_sleep = 0 self.lock = ThreadPool.Lock() self.connect_lock = ThreadPool.Lock() def __repr__(self): return "" % (id(self), self.db_path, self.close_idle) def connect(self): self.connect_lock.acquire(True) try: if self.conn: self.log.debug("Already connected, connection ignored") return if self not in opened_dbs: opened_dbs.append(self) s = time.time() try: # Directory not exist yet os.makedirs(self.db_dir) self.log.debug("Created Db path: %s" % self.db_dir) except OSError as err: if err.errno != errno.EEXIST: raise err if not os.path.isfile(self.db_path): self.log.debug("Db file not exist yet: %s" % self.db_path) self.conn = sqlite3.connect(self.db_path, isolation_level="DEFERRED", check_same_thread=False) self.conn.row_factory = sqlite3.Row self.conn.set_progress_handler(self.progress, 5000000) self.conn.execute('PRAGMA journal_mode=WAL') if self.foreign_keys: self.conn.execute("PRAGMA foreign_keys = ON") self.cur = self.getCursor() self.log.debug( "Connected to %s in %.3fs (opened: %s, sqlite version: %s)..." % (self.db_path, time.time() - s, len(opened_dbs), sqlite3.version) ) self.log.debug("Connect by thread: %s" % threading.current_thread().ident) self.log.debug("Connect called by %s" % Debug.formatStack()) finally: self.connect_lock.release() def getConn(self): if not self.conn: self.connect() return self.conn def progress(self, *args, **kwargs): self.progress_sleeping = True time.sleep(0.001) self.progress_sleeping = False # Execute query using dbcursor def execute(self, query, params=None): if not self.conn: self.connect() return self.cur.execute(query, params) @thread_pool_db.wrap def commit(self, reason="Unknown"): if self.progress_sleeping: self.log.debug("Commit ignored: Progress sleeping") return False if not self.conn: self.log.debug("Commit ignored: No connection") return False if self.commiting: self.log.debug("Commit ignored: Already commiting") return False try: s = time.time() self.commiting = True self.conn.commit() self.log.debug("Commited in %.3fs (reason: %s)" % (time.time() - s, reason)) return True except Exception as err: if "SQL statements in progress" in str(err): self.log.warning("Commit delayed: %s (reason: %s)" % (Debug.formatException(err), reason)) else: self.log.error("Commit error: %s (reason: %s)" % (Debug.formatException(err), reason)) return False finally: self.commiting = False def insertOrUpdate(self, *args, **kwargs): if not self.conn: self.connect() return self.cur.insertOrUpdate(*args, **kwargs) def executeDelayed(self, *args, **kwargs): if not self.delayed_queue_thread: self.delayed_queue_thread = gevent.spawn_later(1, self.processDelayed) self.delayed_queue.append(("execute", (args, kwargs))) def insertOrUpdateDelayed(self, *args, **kwargs): if not self.delayed_queue: gevent.spawn_later(1, self.processDelayed) self.delayed_queue.append(("insertOrUpdate", (args, kwargs))) def processDelayed(self): if not self.delayed_queue: self.log.debug("processDelayed aborted") return if not self.conn: self.connect() s = time.time() cur = self.getCursor() for command, params in self.delayed_queue: if command == "insertOrUpdate": cur.insertOrUpdate(*params[0], **params[1]) else: cur.execute(*params[0], **params[1]) if len(self.delayed_queue) > 10: self.log.debug("Processed %s delayed queue in %.3fs" % (len(self.delayed_queue), time.time() - s)) self.delayed_queue = [] self.delayed_queue_thread = None def close(self, reason="Unknown"): if not self.conn: return False self.connect_lock.acquire() s = time.time() if self.delayed_queue: self.processDelayed() if self in opened_dbs: opened_dbs.remove(self) self.need_commit = False self.commit("Closing: %s" % reason) self.log.debug("Close called by %s" % Debug.formatStack()) for i in range(5): if len(self.cursors) == 0: break self.log.debug("Pending cursors: %s" % len(self.cursors)) time.sleep(0.1 * i) if len(self.cursors): self.log.debug("Killing cursors: %s" % len(self.cursors)) self.conn.interrupt() if self.cur: self.cur.close() if self.conn: ThreadPool.main_loop.call(self.conn.close) self.conn = None self.cur = None self.log.debug("%s closed (reason: %s) in %.3fs, opened: %s" % (self.db_path, reason, time.time() - s, len(opened_dbs))) self.connect_lock.release() return True # Gets a cursor object to database # Return: Cursor class def getCursor(self): if not self.conn: self.connect() cur = DbCursor(self) return cur def getSharedCursor(self): if not self.conn: self.connect() return self.cur # Get the table version # Return: Table version or None if not exist def getTableVersion(self, table_name): if not self.db_keyvalues: # Get db keyvalues try: res = self.execute("SELECT * FROM keyvalue WHERE json_id=0") # json_id = 0 is internal keyvalues except sqlite3.OperationalError as err: # Table not exist self.log.debug("Query table version error: %s" % err) return False for row in res: self.db_keyvalues[row["key"]] = row["value"] return self.db_keyvalues.get("table.%s.version" % table_name, 0) # Check Db tables # Return: Changed table names def checkTables(self): s = time.time() changed_tables = [] cur = self.getSharedCursor() # Check internal tables # Check keyvalue table changed = cur.needTable("keyvalue", [ ["keyvalue_id", "INTEGER PRIMARY KEY AUTOINCREMENT"], ["key", "TEXT"], ["value", "INTEGER"], ["json_id", "INTEGER"], ], [ "CREATE UNIQUE INDEX key_id ON keyvalue(json_id, key)" ], version=self.schema["version"]) if changed: changed_tables.append("keyvalue") # Create json table if no custom one defined if "json" not in self.schema.get("tables", {}): if self.schema["version"] == 1: changed = cur.needTable("json", [ ["json_id", "INTEGER PRIMARY KEY AUTOINCREMENT"], ["path", "VARCHAR(255)"] ], [ "CREATE UNIQUE INDEX path ON json(path)" ], version=self.schema["version"]) elif self.schema["version"] == 2: changed = cur.needTable("json", [ ["json_id", "INTEGER PRIMARY KEY AUTOINCREMENT"], ["directory", "VARCHAR(255)"], ["file_name", "VARCHAR(255)"] ], [ "CREATE UNIQUE INDEX path ON json(directory, file_name)" ], version=self.schema["version"]) elif self.schema["version"] == 3: changed = cur.needTable("json", [ ["json_id", "INTEGER PRIMARY KEY AUTOINCREMENT"], ["site", "VARCHAR(255)"], ["directory", "VARCHAR(255)"], ["file_name", "VARCHAR(255)"] ], [ "CREATE UNIQUE INDEX path ON json(directory, site, file_name)" ], version=self.schema["version"]) if changed: changed_tables.append("json") # Check schema tables for table_name, table_settings in self.schema.get("tables", {}).items(): try: indexes = table_settings.get("indexes", []) version = table_settings.get("schema_changed", 0) changed = cur.needTable( table_name, table_settings["cols"], indexes, version=version ) if changed: changed_tables.append(table_name) except Exception as err: self.log.error("Error creating table %s: %s" % (table_name, Debug.formatException(err))) raise DbTableError(err, table_name) self.log.debug("Db check done in %.3fs, changed tables: %s" % (time.time() - s, changed_tables)) if changed_tables: self.db_keyvalues = {} # Refresh table version cache return changed_tables # Update json file to db # Return: True if matched def updateJson(self, file_path, file=None, cur=None): if not file_path.startswith(self.db_dir): return False # Not from the db dir: Skipping relative_path = file_path[len(self.db_dir):] # File path realative to db file # Check if filename matches any of mappings in schema matched_maps = [] for match, map_settings in self.schema["maps"].items(): try: if SafeRe.match(match, relative_path): matched_maps.append(map_settings) except SafeRe.UnsafePatternError as err: self.log.error(err) # No match found for the file if not matched_maps: return False # Load the json file try: if file is None: # Open file is not file object passed file = open(file_path, "rb") if file is False: # File deleted data = {} else: if file_path.endswith("json.gz"): file = helper.limitedGzipFile(fileobj=file) if sys.version_info.major == 3 and sys.version_info.minor < 6: data = json.loads(file.read().decode("utf8")) else: data = json.load(file) except Exception as err: self.log.debug("Json file %s load error: %s" % (file_path, err)) data = {} # No cursor specificed if not cur: cur = self.getSharedCursor() cur.logging = False # Row for current json file if required if not data or [dbmap for dbmap in matched_maps if "to_keyvalue" in dbmap or "to_table" in dbmap]: json_row = cur.getJsonRow(relative_path) # Check matched mappings in schema for dbmap in matched_maps: # Insert non-relational key values if dbmap.get("to_keyvalue"): # Get current values res = cur.execute("SELECT * FROM keyvalue WHERE json_id = ?", (json_row["json_id"],)) current_keyvalue = {} current_keyvalue_id = {} for row in res: current_keyvalue[row["key"]] = row["value"] current_keyvalue_id[row["key"]] = row["keyvalue_id"] for key in dbmap["to_keyvalue"]: if key not in current_keyvalue: # Keyvalue not exist yet in the db cur.execute( "INSERT INTO keyvalue ?", {"key": key, "value": data.get(key), "json_id": json_row["json_id"]} ) elif data.get(key) != current_keyvalue[key]: # Keyvalue different value cur.execute( "UPDATE keyvalue SET value = ? WHERE keyvalue_id = ?", (data.get(key), current_keyvalue_id[key]) ) # Insert data to json table for easier joins if dbmap.get("to_json_table"): directory, file_name = re.match("^(.*?)/*([^/]*)$", relative_path).groups() data_json_row = dict(cur.getJsonRow(directory + "/" + dbmap.get("file_name", file_name))) changed = False for key in dbmap["to_json_table"]: if data.get(key) != data_json_row.get(key): changed = True if changed: # Add the custom col values data_json_row.update({key: val for key, val in data.items() if key in dbmap["to_json_table"]}) cur.execute("INSERT OR REPLACE INTO json ?", data_json_row) # Insert data to tables for table_settings in dbmap.get("to_table", []): if isinstance(table_settings, dict): # Custom settings table_name = table_settings["table"] # Table name to insert datas node = table_settings.get("node", table_name) # Node keyname in data json file key_col = table_settings.get("key_col") # Map dict key as this col val_col = table_settings.get("val_col") # Map dict value as this col import_cols = table_settings.get("import_cols") replaces = table_settings.get("replaces") else: # Simple settings table_name = table_settings node = table_settings key_col = None val_col = None import_cols = None replaces = None # Fill import cols from table cols if not import_cols: import_cols = set([item[0] for item in self.schema["tables"][table_name]["cols"]]) cur.execute("DELETE FROM %s WHERE json_id = ?" % table_name, (json_row["json_id"],)) if node not in data: continue if key_col: # Map as dict for key, val in data[node].items(): if val_col: # Single value cur.execute( "INSERT OR REPLACE INTO %s ?" % table_name, {key_col: key, val_col: val, "json_id": json_row["json_id"]} ) else: # Multi value if type(val) is dict: # Single row row = val if import_cols: row = {key: row[key] for key in row if key in import_cols} # Filter row by import_cols row[key_col] = key # Replace in value if necessary if replaces: for replace_key, replace in replaces.items(): if replace_key in row: for replace_from, replace_to in replace.items(): row[replace_key] = row[replace_key].replace(replace_from, replace_to) row["json_id"] = json_row["json_id"] cur.execute("INSERT OR REPLACE INTO %s ?" % table_name, row) elif type(val) is list: # Multi row for row in val: row[key_col] = key row["json_id"] = json_row["json_id"] cur.execute("INSERT OR REPLACE INTO %s ?" % table_name, row) else: # Map as list for row in data[node]: row["json_id"] = json_row["json_id"] if import_cols: row = {key: row[key] for key in row if key in import_cols} # Filter row by import_cols cur.execute("INSERT OR REPLACE INTO %s ?" % table_name, row) # Cleanup json row if not data: self.log.debug("Cleanup json row for %s" % file_path) cur.execute("DELETE FROM json WHERE json_id = %s" % json_row["json_id"]) return True if __name__ == "__main__": s = time.time() console_log = logging.StreamHandler() logging.getLogger('').setLevel(logging.DEBUG) logging.getLogger('').addHandler(console_log) console_log.setLevel(logging.DEBUG) dbjson = Db(json.load(open("zerotalk.schema.json")), "data/users/zerotalk.db") dbjson.collect_stats = True dbjson.checkTables() cur = dbjson.getCursor() cur.logging = False dbjson.updateJson("data/users/content.json", cur=cur) for user_dir in os.listdir("data/users"): if os.path.isdir("data/users/%s" % user_dir): dbjson.updateJson("data/users/%s/data.json" % user_dir, cur=cur) # print ".", cur.logging = True print("Done in %.3fs" % (time.time() - s)) for query, stats in sorted(dbjson.query_stats.items()): print("-", query, stats) ================================================ FILE: src/Db/DbCursor.py ================================================ import time import re from util import helper # Special sqlite cursor class DbCursor: def __init__(self, db): self.db = db self.logging = False def quoteValue(self, value): if type(value) is int: return str(value) else: return "'%s'" % value.replace("'", "''") def parseQuery(self, query, params): query_type = query.split(" ", 1)[0].upper() if isinstance(params, dict) and "?" in query: # Make easier select and insert by allowing dict params if query_type in ("SELECT", "DELETE", "UPDATE"): # Convert param dict to SELECT * FROM table WHERE key = ? AND key2 = ? format query_wheres = [] values = [] for key, value in params.items(): if type(value) is list: if key.startswith("not__"): field = key.replace("not__", "") operator = "NOT IN" else: field = key operator = "IN" if len(value) > 100: # Embed values in query to avoid "too many SQL variables" error query_values = ",".join(map(helper.sqlquote, value)) else: query_values = ",".join(["?"] * len(value)) values += value query_wheres.append( "%s %s (%s)" % (field, operator, query_values) ) else: if key.startswith("not__"): query_wheres.append(key.replace("not__", "") + " != ?") elif key.endswith("__like"): query_wheres.append(key.replace("__like", "") + " LIKE ?") elif key.endswith(">"): query_wheres.append(key.replace(">", "") + " > ?") elif key.endswith("<"): query_wheres.append(key.replace("<", "") + " < ?") else: query_wheres.append(key + " = ?") values.append(value) wheres = " AND ".join(query_wheres) if wheres == "": wheres = "1" query = re.sub("(.*)[?]", "\\1 %s" % wheres, query) # Replace the last ? params = values else: # Convert param dict to INSERT INTO table (key, key2) VALUES (?, ?) format keys = ", ".join(params.keys()) values = ", ".join(['?' for key in params.keys()]) keysvalues = "(%s) VALUES (%s)" % (keys, values) query = re.sub("(.*)[?]", "\\1%s" % keysvalues, query) # Replace the last ? params = tuple(params.values()) elif isinstance(params, dict) and ":" in query: new_params = dict() values = [] for key, value in params.items(): if type(value) is list: for idx, val in enumerate(value): new_params[key + "__" + str(idx)] = val new_names = [":" + key + "__" + str(idx) for idx in range(len(value))] query = re.sub(r":" + re.escape(key) + r"([)\s]|$)", "(%s)%s" % (", ".join(new_names), r"\1"), query) else: new_params[key] = value params = new_params return query, params def execute(self, query, params=None): query = query.strip() while self.db.progress_sleeping or self.db.commiting: time.sleep(0.1) self.db.last_query_time = time.time() query, params = self.parseQuery(query, params) cursor = self.db.getConn().cursor() self.db.cursors.add(cursor) if self.db.lock.locked(): self.db.log.debug("Locked for %.3fs" % (time.time() - self.db.lock.time_lock)) try: s = time.time() self.db.lock.acquire(True) if query.upper().strip("; ") == "VACUUM": self.db.commit("vacuum called") if params: res = cursor.execute(query, params) else: res = cursor.execute(query) finally: self.db.lock.release() taken_query = time.time() - s if self.logging or taken_query > 1: if params: # Query has parameters self.db.log.debug("Query: " + query + " " + str(params) + " (Done in %.4f)" % (time.time() - s)) else: self.db.log.debug("Query: " + query + " (Done in %.4f)" % (time.time() - s)) # Log query stats if self.db.collect_stats: if query not in self.db.query_stats: self.db.query_stats[query] = {"call": 0, "time": 0.0} self.db.query_stats[query]["call"] += 1 self.db.query_stats[query]["time"] += time.time() - s query_type = query.split(" ", 1)[0].upper() is_update_query = query_type in ["UPDATE", "DELETE", "INSERT", "CREATE"] if not self.db.need_commit and is_update_query: self.db.need_commit = True if is_update_query: return cursor else: return res def executemany(self, query, params): while self.db.progress_sleeping or self.db.commiting: time.sleep(0.1) self.db.last_query_time = time.time() s = time.time() cursor = self.db.getConn().cursor() self.db.cursors.add(cursor) try: self.db.lock.acquire(True) cursor.executemany(query, params) finally: self.db.lock.release() taken_query = time.time() - s if self.logging or taken_query > 0.1: self.db.log.debug("Execute many: %s (Done in %.4f)" % (query, taken_query)) self.db.need_commit = True return cursor # Creates on updates a database row without incrementing the rowid def insertOrUpdate(self, table, query_sets, query_wheres, oninsert={}): sql_sets = ["%s = :%s" % (key, key) for key in query_sets.keys()] sql_wheres = ["%s = :%s" % (key, key) for key in query_wheres.keys()] params = query_sets params.update(query_wheres) res = self.execute( "UPDATE %s SET %s WHERE %s" % (table, ", ".join(sql_sets), " AND ".join(sql_wheres)), params ) if res.rowcount == 0: params.update(oninsert) # Add insert-only fields self.execute("INSERT INTO %s ?" % table, params) # Create new table # Return: True on success def createTable(self, table, cols): # TODO: Check current structure self.execute("DROP TABLE IF EXISTS %s" % table) col_definitions = [] for col_name, col_type in cols: col_definitions.append("%s %s" % (col_name, col_type)) self.execute("CREATE TABLE %s (%s)" % (table, ",".join(col_definitions))) return True # Create indexes on table # Return: True on success def createIndexes(self, table, indexes): for index in indexes: if not index.strip().upper().startswith("CREATE"): self.db.log.error("Index command should start with CREATE: %s" % index) continue self.execute(index) # Create table if not exist # Return: True if updated def needTable(self, table, cols, indexes=None, version=1): current_version = self.db.getTableVersion(table) if int(current_version) < int(version): # Table need update or not extis self.db.log.debug("Table %s outdated...version: %s need: %s, rebuilding..." % (table, current_version, version)) self.createTable(table, cols) if indexes: self.createIndexes(table, indexes) self.execute( "INSERT OR REPLACE INTO keyvalue ?", {"json_id": 0, "key": "table.%s.version" % table, "value": version} ) return True else: # Not changed return False # Get or create a row for json file # Return: The database row def getJsonRow(self, file_path): directory, file_name = re.match("^(.*?)/*([^/]*)$", file_path).groups() if self.db.schema["version"] == 1: # One path field res = self.execute("SELECT * FROM json WHERE ? LIMIT 1", {"path": file_path}) row = res.fetchone() if not row: # No row yet, create it self.execute("INSERT INTO json ?", {"path": file_path}) res = self.execute("SELECT * FROM json WHERE ? LIMIT 1", {"path": file_path}) row = res.fetchone() elif self.db.schema["version"] == 2: # Separate directory, file_name (easier join) res = self.execute("SELECT * FROM json WHERE ? LIMIT 1", {"directory": directory, "file_name": file_name}) row = res.fetchone() if not row: # No row yet, create it self.execute("INSERT INTO json ?", {"directory": directory, "file_name": file_name}) res = self.execute("SELECT * FROM json WHERE ? LIMIT 1", {"directory": directory, "file_name": file_name}) row = res.fetchone() elif self.db.schema["version"] == 3: # Separate site, directory, file_name (for merger sites) site_address, directory = re.match("^([^/]*)/(.*)$", directory).groups() res = self.execute("SELECT * FROM json WHERE ? LIMIT 1", {"site": site_address, "directory": directory, "file_name": file_name}) row = res.fetchone() if not row: # No row yet, create it self.execute("INSERT INTO json ?", {"site": site_address, "directory": directory, "file_name": file_name}) res = self.execute("SELECT * FROM json WHERE ? LIMIT 1", {"site": site_address, "directory": directory, "file_name": file_name}) row = res.fetchone() else: raise Exception("Dbschema version %s not supported" % self.db.schema.get("version")) return row def close(self): pass ================================================ FILE: src/Db/DbQuery.py ================================================ import re # Parse and modify sql queries class DbQuery: def __init__(self, query): self.setQuery(query.strip()) # Split main parts of query def parseParts(self, query): parts = re.split("(SELECT|FROM|WHERE|ORDER BY|LIMIT)", query) parts = [_f for _f in parts if _f] # Remove empty parts parts = [s.strip() for s in parts] # Remove whitespace return dict(list(zip(parts[0::2], parts[1::2]))) # Parse selected fields SELECT ... FROM def parseFields(self, query_select): fields = re.findall("([^,]+) AS ([^,]+)", query_select) return {key: val.strip() for val, key in fields} # Parse query conditions WHERE ... def parseWheres(self, query_where): if " AND " in query_where: return query_where.split(" AND ") elif query_where: return [query_where] else: return [] # Set the query def setQuery(self, query): self.parts = self.parseParts(query) self.fields = self.parseFields(self.parts["SELECT"]) self.wheres = self.parseWheres(self.parts.get("WHERE", "")) # Convert query back to string def __str__(self): query_parts = [] for part_name in ["SELECT", "FROM", "WHERE", "ORDER BY", "LIMIT"]: if part_name == "WHERE" and self.wheres: query_parts.append("WHERE") query_parts.append(" AND ".join(self.wheres)) elif part_name in self.parts: query_parts.append(part_name) query_parts.append(self.parts[part_name]) return "\n".join(query_parts) ================================================ FILE: src/Db/__init__.py ================================================ ================================================ FILE: src/Debug/Debug.py ================================================ import sys import os import re from Config import config # Non fatal exception class Notify(Exception): def __init__(self, message=None): if message: self.message = message def __str__(self): return self.message # Gevent greenlet.kill accept Exception type def createNotifyType(message): return type("Notify", (Notify, ), {"message": message}) def formatExceptionMessage(err): err_type = err.__class__.__name__ if err.args: err_message = err.args[-1] else: err_message = err.__str__() return "%s: %s" % (err_type, err_message) python_lib_dirs = [path.replace("\\", "/") for path in sys.path if re.sub(r".*[\\/]", "", path) in ("site-packages", "dist-packages")] python_lib_dirs.append(os.path.dirname(os.__file__).replace("\\", "/")) # TODO: check if returns the correct path for PyPy root_dir = os.path.realpath(os.path.dirname(__file__) + "/../../") root_dir = root_dir.replace("\\", "/") def formatTraceback(items, limit=None, fold_builtin=True): back = [] i = 0 prev_file_title = "" is_prev_builtin = False for path, line in items: i += 1 is_last = i == len(items) path = path.replace("\\", "/") if path.startswith("src/gevent/"): file_title = "/" + path[len("src/gevent/"):] is_builtin = True is_skippable_builtin = False elif path in ("", ""): file_title = "(importlib)" is_builtin = True is_skippable_builtin = True else: is_skippable_builtin = False for base in python_lib_dirs: if path.startswith(base + "/"): file_title = path[len(base + "/"):] module_name, *tail = file_title.split("/") if module_name.endswith(".py"): module_name = module_name[:-3] file_title = "/".join(["<%s>" % module_name] + tail) is_builtin = True break else: is_builtin = False for base in (root_dir + "/src", root_dir + "/plugins", root_dir): if path.startswith(base + "/"): file_title = path[len(base + "/"):] break else: # For unknown paths, do our best to hide absolute path file_title = path for needle in ("/zeronet/", "/core/"): if needle in file_title.lower(): file_title = "?/" + file_title[file_title.lower().rindex(needle) + len(needle):] # Path compression: A/AB/ABC/X/Y.py -> ABC/X/Y.py # E.g.: in 'Db/DbCursor.py' the directory part is unnecessary if not file_title.startswith("/"): prev_part = "" for i, part in enumerate(file_title.split("/") + [""]): if not part.startswith(prev_part): break prev_part = part file_title = "/".join(file_title.split("/")[i - 1:]) if is_skippable_builtin and fold_builtin: pass elif is_builtin and is_prev_builtin and not is_last and fold_builtin: if back[-1] != "...": back.append("...") else: if file_title == prev_file_title: back.append("%s" % line) else: back.append("%s line %s" % (file_title, line)) prev_file_title = file_title is_prev_builtin = is_builtin if limit and i >= limit: back.append("...") break return back def formatException(err=None, format="text"): import traceback if type(err) == Notify: return err elif type(err) == tuple and err and err[0] is not None: # Passed trackeback info exc_type, exc_obj, exc_tb = err err = None else: # No trackeback info passed, get latest exc_type, exc_obj, exc_tb = sys.exc_info() if not err: if hasattr(err, "message"): err = exc_obj.message else: err = exc_obj tb = formatTraceback([[frame[0], frame[1]] for frame in traceback.extract_tb(exc_tb)]) if format == "html": return "%s: %s
    %s" % (repr(err), err, " > ".join(tb)) else: return "%s: %s in %s" % (exc_type.__name__, err, " > ".join(tb)) def formatStack(limit=None): import inspect tb = formatTraceback([[frame[1], frame[2]] for frame in inspect.stack()[1:]], limit=limit) return " > ".join(tb) # Test if gevent eventloop blocks import logging import gevent import time num_block = 0 def testBlock(): global num_block logging.debug("Gevent block checker started") last_time = time.time() while 1: time.sleep(1) if time.time() - last_time > 1.1: logging.debug("Gevent block detected: %.3fs" % (time.time() - last_time - 1)) num_block += 1 last_time = time.time() gevent.spawn(testBlock) if __name__ == "__main__": try: print(1 / 0) except Exception as err: print(type(err).__name__) print("1/0 error: %s" % formatException(err)) def loadJson(): json.loads("Errr") import json try: loadJson() except Exception as err: print(err) print("Json load error: %s" % formatException(err)) try: raise Notify("nothing...") except Exception as err: print("Notify: %s" % formatException(err)) loadJson() ================================================ FILE: src/Debug/DebugHook.py ================================================ import sys import logging import signal import importlib import gevent import gevent.hub from Config import config from . import Debug last_error = None def shutdown(reason="Unknown"): logging.info("Shutting down (reason: %s)..." % reason) import main if "file_server" in dir(main): try: gevent.spawn(main.file_server.stop) if "ui_server" in dir(main): gevent.spawn(main.ui_server.stop) except Exception as err: print("Proper shutdown error: %s" % err) sys.exit(0) else: sys.exit(0) # Store last error, ignore notify, allow manual error logging def handleError(*args, **kwargs): global last_error if not args: # Manual called args = sys.exc_info() silent = True else: silent = False if args[0].__name__ != "Notify": last_error = args if args[0].__name__ == "KeyboardInterrupt": shutdown("Keyboard interrupt") elif not silent and args[0].__name__ != "Notify": logging.exception("Unhandled exception") if "greenlet.py" not in args[2].tb_frame.f_code.co_filename: # Don't display error twice sys.__excepthook__(*args, **kwargs) # Ignore notify errors def handleErrorNotify(*args, **kwargs): err = args[0] if err.__name__ == "KeyboardInterrupt": shutdown("Keyboard interrupt") elif err.__name__ != "Notify": logging.error("Unhandled exception: %s" % Debug.formatException(args)) sys.__excepthook__(*args, **kwargs) if config.debug: # Keep last error for /Debug sys.excepthook = handleError else: sys.excepthook = handleErrorNotify # Override default error handler to allow silent killing / custom logging if "handle_error" in dir(gevent.hub.Hub): gevent.hub.Hub._original_handle_error = gevent.hub.Hub.handle_error else: logging.debug("gevent.hub.Hub.handle_error not found using old gevent hooks") OriginalGreenlet = gevent.Greenlet class ErrorhookedGreenlet(OriginalGreenlet): def _report_error(self, exc_info): sys.excepthook(exc_info[0], exc_info[1], exc_info[2]) gevent.Greenlet = gevent.greenlet.Greenlet = ErrorhookedGreenlet importlib.reload(gevent) def handleGreenletError(context, type, value, tb): if context.__class__ is tuple and context[0].__class__.__name__ == "ThreadPool": # Exceptions in ThreadPool will be handled in the main Thread return None if isinstance(value, str): # Cython can raise errors where the value is a plain string # e.g., AttributeError, "_semaphore.Semaphore has no attr", value = type(value) if not issubclass(type, gevent.get_hub().NOT_ERROR): sys.excepthook(type, value, tb) gevent.get_hub().handle_error = handleGreenletError try: signal.signal(signal.SIGTERM, lambda signum, stack_frame: shutdown("SIGTERM")) except Exception as err: logging.debug("Error setting up SIGTERM watcher: %s" % err) if __name__ == "__main__": import time from gevent import monkey monkey.patch_all(thread=False, ssl=False) from . import Debug def sleeper(num): print("started", num) time.sleep(3) raise Exception("Error") print("stopped", num) thread1 = gevent.spawn(sleeper, 1) thread2 = gevent.spawn(sleeper, 2) time.sleep(1) print("killing...") thread1.kill(exception=Debug.Notify("Worker stopped")) #thread2.throw(Debug.Notify("Throw")) print("killed") gevent.joinall([thread1,thread2]) ================================================ FILE: src/Debug/DebugLock.py ================================================ import time import logging import gevent.lock from Debug import Debug class DebugLock: def __init__(self, log_after=0.01, name="Lock"): self.name = name self.log_after = log_after self.lock = gevent.lock.Semaphore(1) self.release = self.lock.release def acquire(self, *args, **kwargs): s = time.time() res = self.lock.acquire(*args, **kwargs) time_taken = time.time() - s if time_taken >= self.log_after: logging.debug("%s: Waited %.3fs after called by %s" % (self.name, time_taken, Debug.formatStack()) ) return res ================================================ FILE: src/Debug/DebugMedia.py ================================================ import os import subprocess import re import logging import time import functools from Config import config from util import helper # Find files with extension in path def findfiles(path, find_ext): def sorter(f1, f2): f1 = f1[0].replace(path, "") f2 = f2[0].replace(path, "") if f1 == "": return 1 elif f2 == "": return -1 else: return helper.cmp(f1.lower(), f2.lower()) for root, dirs, files in sorted(os.walk(path, topdown=False), key=functools.cmp_to_key(sorter)): for file in sorted(files): file_path = root + "/" + file file_ext = file.split(".")[-1] if file_ext in find_ext and not file.startswith("all."): yield file_path.replace("\\", "/") # Try to find coffeescript compiler in path def findCoffeescriptCompiler(): coffeescript_compiler = None try: import distutils.spawn coffeescript_compiler = helper.shellquote(distutils.spawn.find_executable("coffee")) + " --no-header -p" except: pass if coffeescript_compiler: return coffeescript_compiler else: return False # Generates: all.js: merge *.js, compile coffeescript, all.css: merge *.css, vendor prefix features def merge(merged_path): merged_path = merged_path.replace("\\", "/") merge_dir = os.path.dirname(merged_path) s = time.time() ext = merged_path.split(".")[-1] if ext == "js": # If merging .js find .coffee too find_ext = ["js", "coffee"] else: find_ext = [ext] # If exist check the other files modification date if os.path.isfile(merged_path): merged_mtime = os.path.getmtime(merged_path) else: merged_mtime = 0 changed = {} for file_path in findfiles(merge_dir, find_ext): if os.path.getmtime(file_path) > merged_mtime + 1: changed[file_path] = True if not changed: return # Assets not changed, nothing to do old_parts = {} if os.path.isfile(merged_path): # Find old parts to avoid unncessary recompile merged_old = open(merged_path, "rb").read() for match in re.findall(rb"(/\* ---- (.*?) ---- \*/(.*?)(?=/\* ----|$))", merged_old, re.DOTALL): old_parts[match[1].decode()] = match[2].strip(b"\n\r") logging.debug("Merging %s (changed: %s, old parts: %s)" % (merged_path, changed, len(old_parts))) # Merge files parts = [] s_total = time.time() for file_path in findfiles(merge_dir, find_ext): file_relative_path = file_path.replace(merge_dir + "/", "") parts.append(b"\n/* ---- %s ---- */\n\n" % file_relative_path.encode("utf8")) if file_path.endswith(".coffee"): # Compile coffee script if file_path in changed or file_relative_path not in old_parts: # Only recompile if changed or its not compiled before if config.coffeescript_compiler is None: config.coffeescript_compiler = findCoffeescriptCompiler() if not config.coffeescript_compiler: logging.error("No coffeescript compiler defined, skipping compiling %s" % merged_path) return False # No coffeescript compiler, skip this file # Replace / with os separators and escape it file_path_escaped = helper.shellquote(file_path.replace("/", os.path.sep)) if "%s" in config.coffeescript_compiler: # Replace %s with coffeescript file command = config.coffeescript_compiler.replace("%s", file_path_escaped) else: # Put coffeescript file to end command = config.coffeescript_compiler + " " + file_path_escaped # Start compiling s = time.time() compiler = subprocess.Popen(command, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) out = compiler.stdout.read() compiler.wait() logging.debug("Running: %s (Done in %.2fs)" % (command, time.time() - s)) # Check errors if out and out.startswith(b"("): # No error found parts.append(out) else: # Put error message in place of source code error = out logging.error("%s Compile error: %s" % (file_relative_path, error)) error_escaped = re.escape(error).replace(b"\n", b"\\n").replace(br"\\n", br"\n") parts.append( b"alert('%s compile error: %s');" % (file_relative_path.encode(), error_escaped) ) else: # Not changed use the old_part parts.append(old_parts[file_relative_path]) else: # Add to parts parts.append(open(file_path, "rb").read()) merged = b"\n".join(parts) if ext == "css": # Vendor prefix css from lib.cssvendor import cssvendor merged = cssvendor.prefix(merged) merged = merged.replace(b"\r", b"") open(merged_path, "wb").write(merged) logging.debug("Merged %s (%.2fs)" % (merged_path, time.time() - s_total)) if __name__ == "__main__": logging.getLogger().setLevel(logging.DEBUG) os.chdir("..") config.coffeescript_compiler = r'type "%s" | tools\coffee-node\bin\node.exe tools\coffee-node\bin\coffee --no-header -s -p' merge("data/12Hw8rTgzrNo4DSh2AkqwPRqDyTticwJyH/js/all.js") ================================================ FILE: src/Debug/DebugReloader.py ================================================ import logging import time import os from Config import config if config.debug and config.action == "main": try: import watchdog import watchdog.observers import watchdog.events logging.debug("Watchdog fs listener detected, source code autoreload enabled") enabled = True except Exception as err: logging.debug("Watchdog fs listener could not be loaded: %s" % err) enabled = False else: enabled = False class DebugReloader: def __init__(self, paths=None): if not paths: paths = ["src", "plugins", config.data_dir + "/__plugins__"] self.log = logging.getLogger("DebugReloader") self.last_chaged = 0 self.callbacks = [] if enabled: self.observer = watchdog.observers.Observer() event_handler = watchdog.events.FileSystemEventHandler() event_handler.on_modified = event_handler.on_deleted = self.onChanged event_handler.on_created = event_handler.on_moved = self.onChanged for path in paths: if not os.path.isdir(path): continue self.log.debug("Adding autoreload: %s" % path) self.observer.schedule(event_handler, path, recursive=True) self.observer.start() def addCallback(self, f): self.callbacks.append(f) def onChanged(self, evt): path = evt.src_path ext = path.rsplit(".", 1)[-1] if ext not in ["py", "json"] or "Test" in path or time.time() - self.last_chaged < 1.0: return False self.last_chaged = time.time() if os.path.isfile(path): time_modified = os.path.getmtime(path) else: time_modified = 0 self.log.debug("File changed: %s reloading source code (modified %.3fs ago)" % (evt, time.time() - time_modified)) if time.time() - time_modified > 5: # Probably it's just an attribute change, ignore it return False time.sleep(0.1) # Wait for lock release for callback in self.callbacks: try: callback() except Exception as err: self.log.exception(err) def stop(self): if enabled: self.observer.stop() self.log.debug("Stopped autoreload observer") watcher = DebugReloader() ================================================ FILE: src/Debug/__init__.py ================================================ ================================================ FILE: src/File/FileRequest.py ================================================ # Included modules import os import time import json import collections import itertools # Third party modules import gevent from Debug import Debug from Config import config from util import RateLimit from util import Msgpack from util import helper from Plugin import PluginManager from contextlib import closing FILE_BUFF = 1024 * 512 class RequestError(Exception): pass # Incoming requests @PluginManager.acceptPlugins class FileRequest(object): __slots__ = ("server", "connection", "req_id", "sites", "log", "responded") def __init__(self, server, connection): self.server = server self.connection = connection self.req_id = None self.sites = self.server.sites self.log = server.log self.responded = False # Responded to the request def send(self, msg, streaming=False): if not self.connection.closed: self.connection.send(msg, streaming) def sendRawfile(self, file, read_bytes): if not self.connection.closed: self.connection.sendRawfile(file, read_bytes) def response(self, msg, streaming=False): if self.responded: if config.verbose: self.log.debug("Req id %s already responded" % self.req_id) return if not isinstance(msg, dict): # If msg not a dict create a {"body": msg} msg = {"body": msg} msg["cmd"] = "response" msg["to"] = self.req_id self.responded = True self.send(msg, streaming=streaming) # Route file requests def route(self, cmd, req_id, params): self.req_id = req_id # Don't allow other sites than locked if "site" in params and self.connection.target_onion: valid_sites = self.connection.getValidSites() if params["site"] not in valid_sites and valid_sites != ["global"]: self.response({"error": "Invalid site"}) self.connection.log( "Site lock violation: %s not in %s, target onion: %s" % (params["site"], valid_sites, self.connection.target_onion) ) self.connection.badAction(5) return False if cmd == "update": event = "%s update %s %s" % (self.connection.id, params["site"], params["inner_path"]) # If called more than once within 15 sec only keep the last update RateLimit.callAsync(event, max(self.connection.bad_actions, 15), self.actionUpdate, params) else: func_name = "action" + cmd[0].upper() + cmd[1:] func = getattr(self, func_name, None) if cmd not in ["getFile", "streamFile"]: # Skip IO bound functions if self.connection.cpu_time > 0.5: self.log.debug( "Delay %s %s, cpu_time used by connection: %.3fs" % (self.connection.ip, cmd, self.connection.cpu_time) ) time.sleep(self.connection.cpu_time) if self.connection.cpu_time > 5: self.connection.close("Cpu time: %.3fs" % self.connection.cpu_time) s = time.time() if func: func(params) else: self.actionUnknown(cmd, params) if cmd not in ["getFile", "streamFile"]: taken = time.time() - s taken_sent = self.connection.last_sent_time - self.connection.last_send_time self.connection.cpu_time += taken - taken_sent # Update a site file request def actionUpdate(self, params): site = self.sites.get(params["site"]) if not site or not site.isServing(): # Site unknown or not serving self.response({"error": "Unknown site"}) self.connection.badAction(1) self.connection.badAction(5) return False inner_path = params.get("inner_path", "") current_content_modified = site.content_manager.contents.get(inner_path, {}).get("modified", 0) body = params["body"] if not inner_path.endswith("content.json"): self.response({"error": "Only content.json update allowed"}) self.connection.badAction(5) return should_validate_content = True if "modified" in params and params["modified"] <= current_content_modified: should_validate_content = False valid = None # Same or earlier content as we have elif not body: # No body sent, we have to download it first site.log.debug("Missing body from update for file %s, downloading ..." % inner_path) peer = site.addPeer(self.connection.ip, self.connection.port, return_peer=True, source="update") # Add or get peer try: body = peer.getFile(site.address, inner_path).read() except Exception as err: site.log.debug("Can't download updated file %s: %s" % (inner_path, err)) self.response({"error": "File invalid update: Can't download updaed file"}) self.connection.badAction(5) return if should_validate_content: try: content = json.loads(body.decode()) except Exception as err: site.log.debug("Update for %s is invalid JSON: %s" % (inner_path, err)) self.response({"error": "File invalid JSON"}) self.connection.badAction(5) return file_uri = "%s/%s:%s" % (site.address, inner_path, content["modified"]) if self.server.files_parsing.get(file_uri): # Check if we already working on it valid = None # Same file else: try: valid = site.content_manager.verifyFile(inner_path, content) except Exception as err: site.log.debug("Update for %s is invalid: %s" % (inner_path, err)) error = err valid = False if valid is True: # Valid and changed site.log.info("Update for %s looks valid, saving..." % inner_path) self.server.files_parsing[file_uri] = True site.storage.write(inner_path, body) del params["body"] site.onFileDone(inner_path) # Trigger filedone if inner_path.endswith("content.json"): # Download every changed file from peer peer = site.addPeer(self.connection.ip, self.connection.port, return_peer=True, source="update") # Add or get peer # On complete publish to other peers diffs = params.get("diffs", {}) site.onComplete.once(lambda: site.publish(inner_path=inner_path, diffs=diffs, limit=3), "publish_%s" % inner_path) # Load new content file and download changed files in new thread def downloader(): site.downloadContent(inner_path, peer=peer, diffs=params.get("diffs", {})) del self.server.files_parsing[file_uri] gevent.spawn(downloader) else: del self.server.files_parsing[file_uri] self.response({"ok": "Thanks, file %s updated!" % inner_path}) self.connection.goodAction() elif valid is None: # Not changed peer = site.addPeer(self.connection.ip, self.connection.port, return_peer=True, source="update old") # Add or get peer if peer: if not peer.connection: peer.connect(self.connection) # Assign current connection to peer if inner_path in site.content_manager.contents: peer.last_content_json_update = site.content_manager.contents[inner_path]["modified"] if config.verbose: site.log.debug( "Same version, adding new peer for locked files: %s, tasks: %s" % (peer.key, len(site.worker_manager.tasks)) ) for task in site.worker_manager.tasks: # New peer add to every ongoing task if task["peers"] and not task["optional_hash_id"]: # Download file from this peer too if its peer locked site.needFile(task["inner_path"], peer=peer, update=True, blocking=False) self.response({"ok": "File not changed"}) self.connection.badAction() else: # Invalid sign or sha hash self.response({"error": "File %s invalid: %s" % (inner_path, error)}) self.connection.badAction(5) def isReadable(self, site, inner_path, file, pos): return True # Send file content request def handleGetFile(self, params, streaming=False): site = self.sites.get(params["site"]) if not site or not site.isServing(): # Site unknown or not serving self.response({"error": "Unknown site"}) self.connection.badAction(5) return False try: file_path = site.storage.getPath(params["inner_path"]) if streaming: file_obj = site.storage.open(params["inner_path"]) else: file_obj = Msgpack.FilePart(file_path, "rb") with file_obj as file: file.seek(params["location"]) read_bytes = params.get("read_bytes", FILE_BUFF) file_size = os.fstat(file.fileno()).st_size if file_size > read_bytes: # Check if file is readable at current position (for big files) if not self.isReadable(site, params["inner_path"], file, params["location"]): raise RequestError("File not readable at position: %s" % params["location"]) else: if params.get("file_size") and params["file_size"] != file_size: self.connection.badAction(2) raise RequestError("File size does not match: %sB != %sB" % (params["file_size"], file_size)) if not streaming: file.read_bytes = read_bytes if params["location"] > file_size: self.connection.badAction(5) raise RequestError("Bad file location") if streaming: back = { "size": file_size, "location": min(file.tell() + read_bytes, file_size), "stream_bytes": min(read_bytes, file_size - params["location"]) } self.response(back) self.sendRawfile(file, read_bytes=read_bytes) else: back = { "body": file, "size": file_size, "location": min(file.tell() + file.read_bytes, file_size) } self.response(back, streaming=True) bytes_sent = min(read_bytes, file_size - params["location"]) # Number of bytes we going to send site.settings["bytes_sent"] = site.settings.get("bytes_sent", 0) + bytes_sent if config.debug_socket: self.log.debug("File %s at position %s sent %s bytes" % (file_path, params["location"], bytes_sent)) # Add peer to site if not added before connected_peer = site.addPeer(self.connection.ip, self.connection.port, source="request") if connected_peer: # Just added connected_peer.connect(self.connection) # Assign current connection to peer return {"bytes_sent": bytes_sent, "file_size": file_size, "location": params["location"]} except RequestError as err: self.log.debug("GetFile %s %s %s request error: %s" % (self.connection, params["site"], params["inner_path"], Debug.formatException(err))) self.response({"error": "File read error: %s" % err}) except OSError as err: if config.verbose: self.log.debug("GetFile read error: %s" % Debug.formatException(err)) self.response({"error": "File read error"}) return False except Exception as err: self.log.error("GetFile exception: %s" % Debug.formatException(err)) self.response({"error": "File read exception"}) return False def actionGetFile(self, params): return self.handleGetFile(params) def actionStreamFile(self, params): return self.handleGetFile(params, streaming=True) # Peer exchange request def actionPex(self, params): site = self.sites.get(params["site"]) if not site or not site.isServing(): # Site unknown or not serving self.response({"error": "Unknown site"}) self.connection.badAction(5) return False got_peer_keys = [] added = 0 # Add requester peer to site connected_peer = site.addPeer(self.connection.ip, self.connection.port, source="request") if connected_peer: # It was not registered before added += 1 connected_peer.connect(self.connection) # Assign current connection to peer # Add sent peers to site for packed_address in itertools.chain(params.get("peers", []), params.get("peers_ipv6", [])): address = helper.unpackAddress(packed_address) got_peer_keys.append("%s:%s" % address) if site.addPeer(*address, source="pex"): added += 1 # Add sent onion peers to site for packed_address in params.get("peers_onion", []): address = helper.unpackOnionAddress(packed_address) got_peer_keys.append("%s:%s" % address) if site.addPeer(*address, source="pex"): added += 1 # Send back peers that is not in the sent list and connectable (not port 0) packed_peers = helper.packPeers(site.getConnectablePeers(params["need"], ignore=got_peer_keys, allow_private=False)) if added: site.worker_manager.onPeers() if config.verbose: self.log.debug( "Added %s peers to %s using pex, sending back %s" % (added, site, {key: len(val) for key, val in packed_peers.items()}) ) back = { "peers": packed_peers["ipv4"], "peers_ipv6": packed_peers["ipv6"], "peers_onion": packed_peers["onion"] } self.response(back) # Get modified content.json files since def actionListModified(self, params): site = self.sites.get(params["site"]) if not site or not site.isServing(): # Site unknown or not serving self.response({"error": "Unknown site"}) self.connection.badAction(5) return False modified_files = site.content_manager.listModified(params["since"]) # Add peer to site if not added before connected_peer = site.addPeer(self.connection.ip, self.connection.port, source="request") if connected_peer: # Just added connected_peer.connect(self.connection) # Assign current connection to peer self.response({"modified_files": modified_files}) def actionGetHashfield(self, params): site = self.sites.get(params["site"]) if not site or not site.isServing(): # Site unknown or not serving self.response({"error": "Unknown site"}) self.connection.badAction(5) return False # Add peer to site if not added before peer = site.addPeer(self.connection.ip, self.connection.port, return_peer=True, source="request") if not peer.connection: # Just added peer.connect(self.connection) # Assign current connection to peer peer.time_my_hashfield_sent = time.time() # Don't send again if not changed self.response({"hashfield_raw": site.content_manager.hashfield.tobytes()}) def findHashIds(self, site, hash_ids, limit=100): back = collections.defaultdict(lambda: collections.defaultdict(list)) found = site.worker_manager.findOptionalHashIds(hash_ids, limit=limit) for hash_id, peers in found.items(): for peer in peers: ip_type = helper.getIpType(peer.ip) if len(back[ip_type][hash_id]) < 20: back[ip_type][hash_id].append(peer.packMyAddress()) return back def actionFindHashIds(self, params): site = self.sites.get(params["site"]) s = time.time() if not site or not site.isServing(): # Site unknown or not serving self.response({"error": "Unknown site"}) self.connection.badAction(5) return False event_key = "%s_findHashIds_%s_%s" % (self.connection.ip, params["site"], len(params["hash_ids"])) if self.connection.cpu_time > 0.5 or not RateLimit.isAllowed(event_key, 60 * 5): time.sleep(0.1) back = self.findHashIds(site, params["hash_ids"], limit=10) else: back = self.findHashIds(site, params["hash_ids"]) RateLimit.called(event_key) my_hashes = [] my_hashfield_set = set(site.content_manager.hashfield) for hash_id in params["hash_ids"]: if hash_id in my_hashfield_set: my_hashes.append(hash_id) if config.verbose: self.log.debug( "Found: %s for %s hashids in %.3fs" % ({key: len(val) for key, val in back.items()}, len(params["hash_ids"]), time.time() - s) ) self.response({"peers": back["ipv4"], "peers_onion": back["onion"], "peers_ipv6": back["ipv6"], "my": my_hashes}) def actionSetHashfield(self, params): site = self.sites.get(params["site"]) if not site or not site.isServing(): # Site unknown or not serving self.response({"error": "Unknown site"}) self.connection.badAction(5) return False # Add or get peer peer = site.addPeer(self.connection.ip, self.connection.port, return_peer=True, connection=self.connection, source="request") if not peer.connection: peer.connect(self.connection) peer.hashfield.replaceFromBytes(params["hashfield_raw"]) self.response({"ok": "Updated"}) # Send a simple Pong! answer def actionPing(self, params): self.response(b"Pong!") # Check requested port of the other peer def actionCheckport(self, params): if helper.getIpType(self.connection.ip) == "ipv6": sock_address = (self.connection.ip, params["port"], 0, 0) else: sock_address = (self.connection.ip, params["port"]) with closing(helper.createSocket(self.connection.ip)) as sock: sock.settimeout(5) if sock.connect_ex(sock_address) == 0: self.response({"status": "open", "ip_external": self.connection.ip}) else: self.response({"status": "closed", "ip_external": self.connection.ip}) # Unknown command def actionUnknown(self, cmd, params): self.response({"error": "Unknown command: %s" % cmd}) self.connection.badAction(5) ================================================ FILE: src/File/FileServer.py ================================================ import logging import time import random import socket import sys import gevent import gevent.pool from gevent.server import StreamServer import util from util import helper from Config import config from .FileRequest import FileRequest from Peer import PeerPortchecker from Site import SiteManager from Connection import ConnectionServer from Plugin import PluginManager from Debug import Debug @PluginManager.acceptPlugins class FileServer(ConnectionServer): def __init__(self, ip=config.fileserver_ip, port=config.fileserver_port, ip_type=config.fileserver_ip_type): self.site_manager = SiteManager.site_manager self.portchecker = PeerPortchecker.PeerPortchecker(self) self.log = logging.getLogger("FileServer") self.ip_type = ip_type self.ip_external_list = [] self.supported_ip_types = ["ipv4"] # Outgoing ip_type support if helper.getIpType(ip) == "ipv6" or self.isIpv6Supported(): self.supported_ip_types.append("ipv6") if ip_type == "ipv6" or (ip_type == "dual" and "ipv6" in self.supported_ip_types): ip = ip.replace("*", "::") else: ip = ip.replace("*", "0.0.0.0") if config.tor == "always": port = config.tor_hs_port config.fileserver_port = port elif port == 0: # Use random port port_range_from, port_range_to = list(map(int, config.fileserver_port_range.split("-"))) port = self.getRandomPort(ip, port_range_from, port_range_to) config.fileserver_port = port if not port: raise Exception("Can't find bindable port") if not config.tor == "always": config.saveValue("fileserver_port", port) # Save random port value for next restart config.arguments.fileserver_port = port ConnectionServer.__init__(self, ip, port, self.handleRequest) self.log.debug("Supported IP types: %s" % self.supported_ip_types) if ip_type == "dual" and ip == "::": # Also bind to ipv4 addres in dual mode try: self.log.debug("Binding proxy to %s:%s" % ("::", self.port)) self.stream_server_proxy = StreamServer( ("0.0.0.0", self.port), self.handleIncomingConnection, spawn=self.pool, backlog=100 ) except Exception as err: self.log.info("StreamServer proxy create error: %s" % Debug.formatException(err)) self.port_opened = {} self.sites = self.site_manager.sites self.last_request = time.time() self.files_parsing = {} self.ui_server = None def getRandomPort(self, ip, port_range_from, port_range_to): self.log.info("Getting random port in range %s-%s..." % (port_range_from, port_range_to)) tried = [] for bind_retry in range(100): port = random.randint(port_range_from, port_range_to) if port in tried: continue tried.append(port) sock = helper.createSocket(ip) try: sock.bind((ip, port)) success = True except Exception as err: self.log.warning("Error binding to port %s: %s" % (port, err)) success = False sock.close() if success: self.log.info("Found unused random port: %s" % port) return port else: time.sleep(0.1) return False def isIpv6Supported(self): if config.tor == "always": return True # Test if we can connect to ipv6 address ipv6_testip = "fcec:ae97:8902:d810:6c92:ec67:efb2:3ec5" try: sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) sock.connect((ipv6_testip, 80)) local_ipv6 = sock.getsockname()[0] if local_ipv6 == "::1": self.log.debug("IPv6 not supported, no local IPv6 address") return False else: self.log.debug("IPv6 supported on IP %s" % local_ipv6) return True except socket.error as err: self.log.warning("IPv6 not supported: %s" % err) return False except Exception as err: self.log.error("IPv6 check error: %s" % err) return False def listenProxy(self): try: self.stream_server_proxy.serve_forever() except Exception as err: if err.errno == 98: # Address already in use error self.log.debug("StreamServer proxy listen error: %s" % err) else: self.log.info("StreamServer proxy listen error: %s" % err) # Handle request to fileserver def handleRequest(self, connection, message): if config.verbose: if "params" in message: self.log.debug( "FileRequest: %s %s %s %s" % (str(connection), message["cmd"], message["params"].get("site"), message["params"].get("inner_path")) ) else: self.log.debug("FileRequest: %s %s" % (str(connection), message["cmd"])) req = FileRequest(self, connection) req.route(message["cmd"], message.get("req_id"), message.get("params")) if not self.has_internet and not connection.is_private_ip: self.has_internet = True self.onInternetOnline() def onInternetOnline(self): self.log.info("Internet online") gevent.spawn(self.checkSites, check_files=False, force_port_check=True) # Reload the FileRequest class to prevent restarts in debug mode def reload(self): global FileRequest import imp FileRequest = imp.load_source("FileRequest", "src/File/FileRequest.py").FileRequest def portCheck(self): if config.offline: self.log.info("Offline mode: port check disabled") res = {"ipv4": None, "ipv6": None} self.port_opened = res return res if config.ip_external: for ip_external in config.ip_external: SiteManager.peer_blacklist.append((ip_external, self.port)) # Add myself to peer blacklist ip_external_types = set([helper.getIpType(ip) for ip in config.ip_external]) res = { "ipv4": "ipv4" in ip_external_types, "ipv6": "ipv6" in ip_external_types } self.ip_external_list = config.ip_external self.port_opened.update(res) self.log.info("Server port opened based on configuration ipv4: %s, ipv6: %s" % (res["ipv4"], res["ipv6"])) return res self.port_opened = {} if self.ui_server: self.ui_server.updateWebsocket() if "ipv6" in self.supported_ip_types: res_ipv6_thread = gevent.spawn(self.portchecker.portCheck, self.port, "ipv6") else: res_ipv6_thread = None res_ipv4 = self.portchecker.portCheck(self.port, "ipv4") if not res_ipv4["opened"] and config.tor != "always": if self.portchecker.portOpen(self.port): res_ipv4 = self.portchecker.portCheck(self.port, "ipv4") if res_ipv6_thread is None: res_ipv6 = {"ip": None, "opened": None} else: res_ipv6 = res_ipv6_thread.get() if res_ipv6["opened"] and not helper.getIpType(res_ipv6["ip"]) == "ipv6": self.log.info("Invalid IPv6 address from port check: %s" % res_ipv6["ip"]) res_ipv6["opened"] = False self.ip_external_list = [] for res_ip in [res_ipv4, res_ipv6]: if res_ip["ip"] and res_ip["ip"] not in self.ip_external_list: self.ip_external_list.append(res_ip["ip"]) SiteManager.peer_blacklist.append((res_ip["ip"], self.port)) self.log.info("Server port opened ipv4: %s, ipv6: %s" % (res_ipv4["opened"], res_ipv6["opened"])) res = {"ipv4": res_ipv4["opened"], "ipv6": res_ipv6["opened"]} # Add external IPs from local interfaces interface_ips = helper.getInterfaceIps("ipv4") if "ipv6" in self.supported_ip_types: interface_ips += helper.getInterfaceIps("ipv6") for ip in interface_ips: if not helper.isPrivateIp(ip) and ip not in self.ip_external_list: self.ip_external_list.append(ip) res[helper.getIpType(ip)] = True # We have opened port if we have external ip SiteManager.peer_blacklist.append((ip, self.port)) self.log.debug("External ip found on interfaces: %s" % ip) self.port_opened.update(res) if self.ui_server: self.ui_server.updateWebsocket() return res # Check site file integrity def checkSite(self, site, check_files=False): if site.isServing(): site.announce(mode="startup") # Announce site to tracker site.update(check_files=check_files) # Update site's content.json and download changed files site.sendMyHashfield() site.updateHashfield() # Check sites integrity @util.Noparallel() def checkSites(self, check_files=False, force_port_check=False): self.log.debug("Checking sites...") s = time.time() sites_checking = False if not self.port_opened or force_port_check: # Test and open port if not tested yet if len(self.sites) <= 2: # Don't wait port opening on first startup sites_checking = True for address, site in list(self.sites.items()): gevent.spawn(self.checkSite, site, check_files) self.portCheck() if not self.port_opened["ipv4"]: self.tor_manager.startOnions() if not sites_checking: check_pool = gevent.pool.Pool(5) # Check sites integrity for site in sorted(list(self.sites.values()), key=lambda site: site.settings.get("modified", 0), reverse=True): if not site.isServing(): continue check_thread = check_pool.spawn(self.checkSite, site, check_files) # Check in new thread time.sleep(2) if site.settings.get("modified", 0) < time.time() - 60 * 60 * 24: # Not so active site, wait some sec to finish check_thread.join(timeout=5) self.log.debug("Checksites done in %.3fs" % (time.time() - s)) def cleanupSites(self): import gc startup = True time.sleep(5 * 60) # Sites already cleaned up on startup peers_protected = set([]) while 1: # Sites health care every 20 min self.log.debug( "Running site cleanup, connections: %s, internet: %s, protected peers: %s" % (len(self.connections), self.has_internet, len(peers_protected)) ) for address, site in list(self.sites.items()): if not site.isServing(): continue if not startup: site.cleanupPeers(peers_protected) time.sleep(1) # Prevent too quick request peers_protected = set([]) for address, site in list(self.sites.items()): if not site.isServing(): continue if site.peers: with gevent.Timeout(10, exception=False): site.announcer.announcePex() # Last check modification failed if site.content_updated is False: site.update() elif site.bad_files: site.retryBadFiles() if time.time() - site.settings.get("modified", 0) < 60 * 60 * 24 * 7: # Keep active connections if site has been modified witin 7 days connected_num = site.needConnections(check_site_on_reconnect=True) if connected_num < config.connected_limit: # This site has small amount of peers, protect them from closing peers_protected.update([peer.key for peer in site.getConnectedPeers()]) time.sleep(1) # Prevent too quick request site = None gc.collect() # Implicit garbage collection startup = False time.sleep(60 * 20) def announceSite(self, site): site.announce(mode="update", pex=False) active_site = time.time() - site.settings.get("modified", 0) < 24 * 60 * 60 if site.settings["own"] or active_site: # Check connections more frequently on own and active sites to speed-up first connections site.needConnections(check_site_on_reconnect=True) site.sendMyHashfield(3) site.updateHashfield(3) # Announce sites every 20 min def announceSites(self): time.sleep(5 * 60) # Sites already announced on startup while 1: config.loadTrackersFile() s = time.time() for address, site in list(self.sites.items()): if not site.isServing(): continue gevent.spawn(self.announceSite, site).join(timeout=10) time.sleep(1) taken = time.time() - s # Query all trackers one-by-one in 20 minutes evenly distributed sleep = max(0, 60 * 20 / len(config.trackers) - taken) self.log.debug("Site announce tracker done in %.3fs, sleeping for %.3fs..." % (taken, sleep)) time.sleep(sleep) # Detects if computer back from wakeup def wakeupWatcher(self): last_time = time.time() last_my_ips = socket.gethostbyname_ex('')[2] while 1: time.sleep(30) is_time_changed = time.time() - max(self.last_request, last_time) > 60 * 3 if is_time_changed: # If taken more than 3 minute then the computer was in sleep mode self.log.info( "Wakeup detected: time warp from %0.f to %0.f (%0.f sleep seconds), acting like startup..." % (last_time, time.time(), time.time() - last_time) ) my_ips = socket.gethostbyname_ex('')[2] is_ip_changed = my_ips != last_my_ips if is_ip_changed: self.log.info("IP change detected from %s to %s" % (last_my_ips, my_ips)) if is_time_changed or is_ip_changed: self.checkSites(check_files=False, force_port_check=True) last_time = time.time() last_my_ips = my_ips # Bind and start serving sites def start(self, check_sites=True): if self.stopping: return False ConnectionServer.start(self) try: self.stream_server.start() except Exception as err: self.log.error("Error listening on: %s:%s: %s" % (self.ip, self.port, err)) self.sites = self.site_manager.list() if config.debug: # Auto reload FileRequest on change from Debug import DebugReloader DebugReloader.watcher.addCallback(self.reload) if check_sites: # Open port, Update sites, Check files integrity gevent.spawn(self.checkSites) thread_announce_sites = gevent.spawn(self.announceSites) thread_cleanup_sites = gevent.spawn(self.cleanupSites) thread_wakeup_watcher = gevent.spawn(self.wakeupWatcher) ConnectionServer.listen(self) self.log.debug("Stopped.") def stop(self): if self.running and self.portchecker.upnp_port_opened: self.log.debug('Closing port %d' % self.port) try: self.portchecker.portClose(self.port) self.log.info('Closed port via upnp.') except Exception as err: self.log.info("Failed at attempt to use upnp to close port: %s" % err) return ConnectionServer.stop(self) ================================================ FILE: src/File/__init__.py ================================================ from .FileServer import FileServer from .FileRequest import FileRequest ================================================ FILE: src/Peer/Peer.py ================================================ import logging import time import sys import itertools import collections import gevent import io from Debug import Debug from Config import config from util import helper from .PeerHashfield import PeerHashfield from Plugin import PluginManager if config.use_tempfiles: import tempfile # Communicate remote peers @PluginManager.acceptPlugins class Peer(object): __slots__ = ( "ip", "port", "site", "key", "connection", "connection_server", "time_found", "time_response", "time_hashfield", "time_added", "has_hashfield", "is_tracker_connection", "time_my_hashfield_sent", "last_ping", "reputation", "last_content_json_update", "hashfield", "connection_error", "hash_failed", "download_bytes", "download_time" ) def __init__(self, ip, port, site=None, connection_server=None): self.ip = ip self.port = port self.site = site self.key = "%s:%s" % (ip, port) self.connection = None self.connection_server = connection_server self.has_hashfield = False # Lazy hashfield object not created yet self.time_hashfield = None # Last time peer's hashfiled downloaded self.time_my_hashfield_sent = None # Last time my hashfield sent to peer self.time_found = time.time() # Time of last found in the torrent tracker self.time_response = None # Time of last successful response from peer self.time_added = time.time() self.last_ping = None # Last response time for ping self.is_tracker_connection = False # Tracker connection instead of normal peer self.reputation = 0 # More likely to connect if larger self.last_content_json_update = 0.0 # Modify date of last received content.json self.connection_error = 0 # Series of connection error self.hash_failed = 0 # Number of bad files from peer self.download_bytes = 0 # Bytes downloaded self.download_time = 0 # Time spent to download def __getattr__(self, key): if key == "hashfield": self.has_hashfield = True self.hashfield = PeerHashfield() return self.hashfield else: return getattr(self, key) def log(self, text): if not config.verbose: return # Only log if we are in debug mode if self.site: self.site.log.debug("%s:%s %s" % (self.ip, self.port, text)) else: logging.debug("%s:%s %s" % (self.ip, self.port, text)) # Connect to host def connect(self, connection=None): if self.reputation < -10: self.reputation = -10 if self.reputation > 10: self.reputation = 10 if self.connection: self.log("Getting connection (Closing %s)..." % self.connection) self.connection.close("Connection change") else: self.log("Getting connection (reputation: %s)..." % self.reputation) if connection: # Connection specified self.log("Assigning connection %s" % connection) self.connection = connection self.connection.sites += 1 else: # Try to find from connection pool or create new connection self.connection = None try: if self.connection_server: connection_server = self.connection_server elif self.site: connection_server = self.site.connection_server else: import main connection_server = main.file_server self.connection = connection_server.getConnection(self.ip, self.port, site=self.site, is_tracker_connection=self.is_tracker_connection) self.reputation += 1 self.connection.sites += 1 except Exception as err: self.onConnectionError("Getting connection error") self.log("Getting connection error: %s (connection_error: %s, hash_failed: %s)" % (Debug.formatException(err), self.connection_error, self.hash_failed)) self.connection = None return self.connection # Check if we have connection to peer def findConnection(self): if self.connection and self.connection.connected: # We have connection to peer return self.connection else: # Try to find from other sites connections self.connection = self.site.connection_server.getConnection(self.ip, self.port, create=False, site=self.site) if self.connection: self.connection.sites += 1 return self.connection def __str__(self): if self.site: return "Peer:%-12s of %s" % (self.ip, self.site.address_short) else: return "Peer:%-12s" % self.ip def __repr__(self): return "<%s>" % self.__str__() def packMyAddress(self): if self.ip.endswith(".onion"): return helper.packOnionAddress(self.ip, self.port) else: return helper.packAddress(self.ip, self.port) # Found a peer from a source def found(self, source="other"): if self.reputation < 5: if source == "tracker": if self.ip.endswith(".onion"): self.reputation += 1 else: self.reputation += 2 elif source == "local": self.reputation += 20 if source in ("tracker", "local"): self.site.peers_recent.appendleft(self) self.time_found = time.time() # Send a command to peer and return response value def request(self, cmd, params={}, stream_to=None): if not self.connection or self.connection.closed: self.connect() if not self.connection: self.onConnectionError("Reconnect error") return None # Connection failed self.log("Send request: %s %s %s %s" % (params.get("site", ""), cmd, params.get("inner_path", ""), params.get("location", ""))) for retry in range(1, 4): # Retry 3 times try: if not self.connection: raise Exception("No connection found") res = self.connection.request(cmd, params, stream_to) if not res: raise Exception("Send error") if "error" in res: self.log("%s error: %s" % (cmd, res["error"])) self.onConnectionError("Response error") break else: # Successful request, reset connection error num self.connection_error = 0 self.time_response = time.time() if res: return res else: raise Exception("Invalid response: %s" % res) except Exception as err: if type(err).__name__ == "Notify": # Greenlet killed by worker self.log("Peer worker got killed: %s, aborting cmd: %s" % (err.message, cmd)) break else: self.onConnectionError("Request error") self.log( "%s (connection_error: %s, hash_failed: %s, retry: %s)" % (Debug.formatException(err), self.connection_error, self.hash_failed, retry) ) time.sleep(1 * retry) self.connect() return None # Failed after 4 retry # Get a file content from peer def getFile(self, site, inner_path, file_size=None, pos_from=0, pos_to=None, streaming=False): if file_size and file_size > 5 * 1024 * 1024: max_read_size = 1024 * 1024 else: max_read_size = 512 * 1024 if pos_to: read_bytes = min(max_read_size, pos_to - pos_from) else: read_bytes = max_read_size location = pos_from if config.use_tempfiles: buff = tempfile.SpooledTemporaryFile(max_size=16 * 1024, mode='w+b') else: buff = io.BytesIO() s = time.time() while True: # Read in smaller parts if config.stream_downloads or read_bytes > 256 * 1024 or streaming: res = self.request("streamFile", {"site": site, "inner_path": inner_path, "location": location, "read_bytes": read_bytes, "file_size": file_size}, stream_to=buff) if not res or "location" not in res: # Error return False else: self.log("Send: %s" % inner_path) res = self.request("getFile", {"site": site, "inner_path": inner_path, "location": location, "read_bytes": read_bytes, "file_size": file_size}) if not res or "location" not in res: # Error return False self.log("Recv: %s" % inner_path) buff.write(res["body"]) res["body"] = None # Save memory if res["location"] == res["size"] or res["location"] == pos_to: # End of file break else: location = res["location"] if pos_to: read_bytes = min(max_read_size, pos_to - location) if pos_to: recv = pos_to - pos_from else: recv = res["location"] self.download_bytes += recv self.download_time += (time.time() - s) if self.site: self.site.settings["bytes_recv"] = self.site.settings.get("bytes_recv", 0) + recv self.log("Downloaded: %s, pos: %s, read_bytes: %s" % (inner_path, buff.tell(), read_bytes)) buff.seek(0) return buff # Send a ping request def ping(self): response_time = None for retry in range(1, 3): # Retry 3 times s = time.time() with gevent.Timeout(10.0, False): # 10 sec timeout, don't raise exception res = self.request("ping") if res and "body" in res and res["body"] == b"Pong!": response_time = time.time() - s break # All fine, exit from for loop # Timeout reached or bad response self.onConnectionError("Ping timeout") self.connect() time.sleep(1) if response_time: self.log("Ping: %.3f" % response_time) else: self.log("Ping failed") self.last_ping = response_time return response_time # Request peer exchange from peer def pex(self, site=None, need_num=5): if not site: site = self.site # If no site defined request peers for this site # give back 5 connectible peers packed_peers = helper.packPeers(self.site.getConnectablePeers(5, allow_private=False)) request = {"site": site.address, "peers": packed_peers["ipv4"], "need": need_num} if packed_peers["onion"]: request["peers_onion"] = packed_peers["onion"] if packed_peers["ipv6"]: request["peers_ipv6"] = packed_peers["ipv6"] res = self.request("pex", request) if not res or "error" in res: return False added = 0 # Remove unsupported peer types if "peers_ipv6" in res and self.connection and "ipv6" not in self.connection.server.supported_ip_types: del res["peers_ipv6"] if "peers_onion" in res and self.connection and "onion" not in self.connection.server.supported_ip_types: del res["peers_onion"] # Add IPv4 + IPv6 for peer in itertools.chain(res.get("peers", []), res.get("peers_ipv6", [])): address = helper.unpackAddress(peer) if site.addPeer(*address, source="pex"): added += 1 # Add Onion for peer in res.get("peers_onion", []): address = helper.unpackOnionAddress(peer) if site.addPeer(*address, source="pex"): added += 1 if added: self.log("Added peers using pex: %s" % added) return added # List modified files since the date # Return: {inner_path: modification date,...} def listModified(self, since): return self.request("listModified", {"since": since, "site": self.site.address}) def updateHashfield(self, force=False): # Don't update hashfield again in 5 min if self.time_hashfield and time.time() - self.time_hashfield < 5 * 60 and not force: return False self.time_hashfield = time.time() res = self.request("getHashfield", {"site": self.site.address}) if not res or "error" in res or "hashfield_raw" not in res: return False self.hashfield.replaceFromBytes(res["hashfield_raw"]) return self.hashfield # Find peers for hashids # Return: {hash1: ["ip:port", "ip:port",...],...} def findHashIds(self, hash_ids): res = self.request("findHashIds", {"site": self.site.address, "hash_ids": hash_ids}) if not res or "error" in res or type(res) is not dict: return False back = collections.defaultdict(list) for ip_type in ["ipv4", "ipv6", "onion"]: if ip_type == "ipv4": key = "peers" else: key = "peers_%s" % ip_type for hash, peers in list(res.get(key, {}).items())[0:30]: if ip_type == "onion": unpacker_func = helper.unpackOnionAddress else: unpacker_func = helper.unpackAddress back[hash] += list(map(unpacker_func, peers)) for hash in res.get("my", []): if self.connection: back[hash].append((self.connection.ip, self.connection.port)) else: back[hash].append((self.ip, self.port)) return back # Send my hashfield to peer # Return: True if sent def sendMyHashfield(self): if self.connection and self.connection.handshake.get("rev", 0) < 510: return False # Not supported if self.time_my_hashfield_sent and self.site.content_manager.hashfield.time_changed <= self.time_my_hashfield_sent: return False # Peer already has the latest hashfield res = self.request("setHashfield", {"site": self.site.address, "hashfield_raw": self.site.content_manager.hashfield.tobytes()}) if not res or "error" in res: return False else: self.time_my_hashfield_sent = time.time() return True def publish(self, address, inner_path, body, modified, diffs=[]): if len(body) > 10 * 1024 and self.connection and self.connection.handshake.get("rev", 0) >= 4095: # To save bw we don't push big content.json to peers body = b"" return self.request("update", { "site": address, "inner_path": inner_path, "body": body, "modified": modified, "diffs": diffs }) # Stop and remove from site def remove(self, reason="Removing"): self.log("Removing peer...Connection error: %s, Hash failed: %s" % (self.connection_error, self.hash_failed)) if self.site and self.key in self.site.peers: del(self.site.peers[self.key]) if self.site and self in self.site.peers_recent: self.site.peers_recent.remove(self) if self.connection: self.connection.close(reason) # - EVENTS - # On connection error def onConnectionError(self, reason="Unknown"): self.connection_error += 1 if self.site and len(self.site.peers) > 200: limit = 3 else: limit = 6 self.reputation -= 1 if self.connection_error >= limit: # Dead peer self.remove("Peer connection: %s" % reason) # Done working with peer def onWorkerDone(self): pass ================================================ FILE: src/Peer/PeerHashfield.py ================================================ import array import time class PeerHashfield(object): __slots__ = ("storage", "time_changed", "append", "remove", "tobytes", "frombytes", "__len__", "__iter__") def __init__(self): self.storage = self.createStorage() self.time_changed = time.time() def createStorage(self): storage = array.array("H") self.append = storage.append self.remove = storage.remove self.tobytes = storage.tobytes self.frombytes = storage.frombytes self.__len__ = storage.__len__ self.__iter__ = storage.__iter__ return storage def appendHash(self, hash): hash_id = int(hash[0:4], 16) if hash_id not in self.storage: self.storage.append(hash_id) self.time_changed = time.time() return True else: return False def appendHashId(self, hash_id): if hash_id not in self.storage: self.storage.append(hash_id) self.time_changed = time.time() return True else: return False def removeHash(self, hash): hash_id = int(hash[0:4], 16) if hash_id in self.storage: self.storage.remove(hash_id) self.time_changed = time.time() return True else: return False def removeHashId(self, hash_id): if hash_id in self.storage: self.storage.remove(hash_id) self.time_changed = time.time() return True else: return False def getHashId(self, hash): return int(hash[0:4], 16) def hasHash(self, hash): return int(hash[0:4], 16) in self.storage def replaceFromBytes(self, hashfield_raw): self.storage = self.createStorage() self.storage.frombytes(hashfield_raw) self.time_changed = time.time() if __name__ == "__main__": field = PeerHashfield() s = time.time() for i in range(10000): field.appendHashId(i) print(time.time()-s) s = time.time() for i in range(10000): field.hasHash("AABB") print(time.time()-s) ================================================ FILE: src/Peer/PeerPortchecker.py ================================================ import logging import urllib.request import urllib.parse import re import time from Debug import Debug from util import UpnpPunch class PeerPortchecker(object): checker_functions = { "ipv4": ["checkIpfingerprints", "checkCanyouseeme"], "ipv6": ["checkMyaddr", "checkIpv6scanner"] } def __init__(self, file_server): self.log = logging.getLogger("PeerPortchecker") self.upnp_port_opened = False self.file_server = file_server def requestUrl(self, url, post_data=None): if type(post_data) is dict: post_data = urllib.parse.urlencode(post_data).encode("utf8") req = urllib.request.Request(url, post_data) req.add_header("Referer", url) req.add_header("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11") req.add_header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") return urllib.request.urlopen(req, timeout=20.0) def portOpen(self, port): self.log.info("Trying to open port using UpnpPunch...") try: UpnpPunch.ask_to_open_port(port, 'ZeroNet', retries=3, protos=["TCP"]) self.upnp_port_opened = True except Exception as err: self.log.warning("UpnpPunch run error: %s" % Debug.formatException(err)) return False return True def portClose(self, port): return UpnpPunch.ask_to_close_port(port, protos=["TCP"]) def portCheck(self, port, ip_type="ipv4"): checker_functions = self.checker_functions[ip_type] for func_name in checker_functions: func = getattr(self, func_name) s = time.time() try: res = func(port) if res: self.log.info( "Checked port %s (%s) using %s result: %s in %.3fs" % (port, ip_type, func_name, res, time.time() - s) ) time.sleep(0.1) if res["opened"] and not self.file_server.had_external_incoming: res["opened"] = False self.log.warning("Port %s:%s looks opened, but no incoming connection" % (res["ip"], port)) break except Exception as err: self.log.warning( "%s check error: %s in %.3fs" % (func_name, Debug.formatException(err), time.time() - s) ) res = {"ip": None, "opened": False} return res def checkCanyouseeme(self, port): data = urllib.request.urlopen("https://www.canyouseeme.org/", b"ip=1.1.1.1&port=%s" % str(port).encode("ascii"), timeout=20.0).read().decode("utf8") message = re.match(r'.*

    (.*?)

    ', data, re.DOTALL).group(1) message = re.sub(r"<.*?>", "", message.replace("
    ", " ").replace(" ", " ")) # Strip http tags match = re.match(r".*service on (.*?) on", message) if match: ip = match.group(1) else: raise Exception("Invalid response: %s" % message) if "Success" in message: return {"ip": ip, "opened": True} elif "Error" in message: return {"ip": ip, "opened": False} else: raise Exception("Invalid response: %s" % message) def checkIpfingerprints(self, port): data = self.requestUrl("https://www.ipfingerprints.com/portscan.php").read().decode("utf8") ip = re.match(r'.*name="remoteHost".*?value="(.*?)"', data, re.DOTALL).group(1) post_data = { "remoteHost": ip, "start_port": port, "end_port": port, "normalScan": "Yes", "scan_type": "connect2", "ping_type": "none" } message = self.requestUrl("https://www.ipfingerprints.com/scripts/getPortsInfo.php", post_data).read().decode("utf8") if "open" in message: return {"ip": ip, "opened": True} elif "filtered" in message or "closed" in message: return {"ip": ip, "opened": False} else: raise Exception("Invalid response: %s" % message) def checkMyaddr(self, port): url = "http://ipv6.my-addr.com/online-ipv6-port-scan.php" data = self.requestUrl(url).read().decode("utf8") ip = re.match(r'.*Your IP address is:[ ]*([0-9\.:a-z]+)', data.replace(" ", ""), re.DOTALL).group(1) post_data = {"addr": ip, "ports_selected": "", "ports_list": port} data = self.requestUrl(url, post_data).read().decode("utf8") message = re.match(r".*(.*?)
    ", data, re.DOTALL).group(1) if "ok.png" in message: return {"ip": ip, "opened": True} elif "fail.png" in message: return {"ip": ip, "opened": False} else: raise Exception("Invalid response: %s" % message) def checkIpv6scanner(self, port): url = "http://www.ipv6scanner.com/cgi-bin/main.py" data = self.requestUrl(url).read().decode("utf8") ip = re.match(r'.*Your IP address is[ ]*([0-9\.:a-z]+)', data.replace(" ", ""), re.DOTALL).group(1) post_data = {"host": ip, "scanType": "1", "port": port, "protocol": "tcp", "authorized": "yes"} data = self.requestUrl(url, post_data).read().decode("utf8") message = re.match(r".*(.*?)
    ", data, re.DOTALL).group(1) message_text = re.sub("<.*?>", " ", message.replace("
    ", " ").replace(" ", " ").strip()) # Strip http tags if "OPEN" in message_text: return {"ip": ip, "opened": True} elif "CLOSED" in message_text or "FILTERED" in message_text: return {"ip": ip, "opened": False} else: raise Exception("Invalid response: %s" % message_text) def checkPortchecker(self, port): # Not working: Forbidden data = self.requestUrl("https://portchecker.co").read().decode("utf8") csrf = re.match(r'.*name="_csrf" value="(.*?)"', data, re.DOTALL).group(1) data = self.requestUrl("https://portchecker.co", {"port": port, "_csrf": csrf}).read().decode("utf8") message = re.match(r'.*
    (.*?)
    ', data, re.DOTALL).group(1) message = re.sub(r"<.*?>", "", message.replace("
    ", " ").replace(" ", " ").strip()) # Strip http tags match = re.match(r".*targetIP.*?value=\"(.*?)\"", data, re.DOTALL) if match: ip = match.group(1) else: raise Exception("Invalid response: %s" % message) if "open" in message: return {"ip": ip, "opened": True} elif "closed" in message: return {"ip": ip, "opened": False} else: raise Exception("Invalid response: %s" % message) def checkSubnetonline(self, port): # Not working: Invalid response url = "https://www.subnetonline.com/pages/ipv6-network-tools/online-ipv6-port-scanner.php" data = self.requestUrl(url).read().decode("utf8") ip = re.match(r'.*Your IP is.*?name="host".*?value="(.*?)"', data, re.DOTALL).group(1) token = re.match(r'.*name="token".*?value="(.*?)"', data, re.DOTALL).group(1) post_data = {"host": ip, "port": port, "allow": "on", "token": token, "submit": "Scanning.."} data = self.requestUrl(url, post_data).read().decode("utf8") print(post_data, data) message = re.match(r".*
    (.*?)
    ", data, re.DOTALL).group(1) message = re.sub(r"<.*?>", "", message.replace("
    ", " ").replace(" ", " ").strip()) # Strip http tags if "online" in message: return {"ip": ip, "opened": True} elif "closed" in message: return {"ip": ip, "opened": False} else: raise Exception("Invalid response: %s" % message) ================================================ FILE: src/Peer/__init__.py ================================================ from .Peer import Peer from .PeerHashfield import PeerHashfield ================================================ FILE: src/Plugin/PluginManager.py ================================================ import logging import os import sys import shutil import time from collections import defaultdict import importlib import json from Debug import Debug from Config import config import plugins class PluginManager: def __init__(self): self.log = logging.getLogger("PluginManager") self.path_plugins = os.path.abspath(os.path.dirname(plugins.__file__)) self.path_installed_plugins = config.data_dir + "/__plugins__" self.plugins = defaultdict(list) # Registered plugins (key: class name, value: list of plugins for class) self.subclass_order = {} # Record the load order of the plugins, to keep it after reload self.pluggable = {} self.plugin_names = [] # Loaded plugin names self.plugins_updated = {} # List of updated plugins since restart self.plugins_rev = {} # Installed plugins revision numbers self.after_load = [] # Execute functions after loaded plugins self.function_flags = {} # Flag function for permissions self.reloading = False self.config_path = config.data_dir + "/plugins.json" self.loadConfig() self.config.setdefault("builtin", {}) sys.path.append(os.path.join(os.getcwd(), self.path_plugins)) self.migratePlugins() if config.debug: # Auto reload Plugins on file change from Debug import DebugReloader DebugReloader.watcher.addCallback(self.reloadPlugins) def loadConfig(self): if os.path.isfile(self.config_path): try: self.config = json.load(open(self.config_path, encoding="utf8")) except Exception as err: self.log.error("Error loading %s: %s" % (self.config_path, err)) self.config = {} else: self.config = {} def saveConfig(self): f = open(self.config_path, "w", encoding="utf8") json.dump(self.config, f, ensure_ascii=False, sort_keys=True, indent=2) def migratePlugins(self): for dir_name in os.listdir(self.path_plugins): if dir_name == "Mute": self.log.info("Deleting deprecated/renamed plugin: %s" % dir_name) shutil.rmtree("%s/%s" % (self.path_plugins, dir_name)) # -- Load / Unload -- def listPlugins(self, list_disabled=False): plugins = [] for dir_name in sorted(os.listdir(self.path_plugins)): dir_path = os.path.join(self.path_plugins, dir_name) plugin_name = dir_name.replace("disabled-", "") if dir_name.startswith("disabled"): is_enabled = False else: is_enabled = True plugin_config = self.config["builtin"].get(plugin_name, {}) if "enabled" in plugin_config: is_enabled = plugin_config["enabled"] if dir_name == "__pycache__" or not os.path.isdir(dir_path): continue # skip if dir_name.startswith("Debug") and not config.debug: continue # Only load in debug mode if module name starts with Debug if not is_enabled and not list_disabled: continue # Dont load if disabled plugin = {} plugin["source"] = "builtin" plugin["name"] = plugin_name plugin["dir_name"] = dir_name plugin["dir_path"] = dir_path plugin["inner_path"] = plugin_name plugin["enabled"] = is_enabled plugin["rev"] = config.rev plugin["loaded"] = plugin_name in self.plugin_names plugins.append(plugin) plugins += self.listInstalledPlugins(list_disabled) return plugins def listInstalledPlugins(self, list_disabled=False): plugins = [] for address, site_plugins in sorted(self.config.items()): if address == "builtin": continue for plugin_inner_path, plugin_config in sorted(site_plugins.items()): is_enabled = plugin_config.get("enabled", False) if not is_enabled and not list_disabled: continue plugin_name = os.path.basename(plugin_inner_path) dir_path = "%s/%s/%s" % (self.path_installed_plugins, address, plugin_inner_path) plugin = {} plugin["source"] = address plugin["name"] = plugin_name plugin["dir_name"] = plugin_name plugin["dir_path"] = dir_path plugin["inner_path"] = plugin_inner_path plugin["enabled"] = is_enabled plugin["rev"] = plugin_config.get("rev", 0) plugin["loaded"] = plugin_name in self.plugin_names plugins.append(plugin) return plugins # Load all plugin def loadPlugins(self): all_loaded = True s = time.time() for plugin in self.listPlugins(): self.log.debug("Loading plugin: %s (%s)" % (plugin["name"], plugin["source"])) if plugin["source"] != "builtin": self.plugins_rev[plugin["name"]] = plugin["rev"] site_plugin_dir = os.path.dirname(plugin["dir_path"]) if site_plugin_dir not in sys.path: sys.path.append(site_plugin_dir) try: sys.modules[plugin["name"]] = __import__(plugin["dir_name"]) except Exception as err: self.log.error("Plugin %s load error: %s" % (plugin["name"], Debug.formatException(err))) all_loaded = False if plugin["name"] not in self.plugin_names: self.plugin_names.append(plugin["name"]) self.log.debug("Plugins loaded in %.3fs" % (time.time() - s)) for func in self.after_load: func() return all_loaded # Reload all plugins def reloadPlugins(self): self.reloading = True self.after_load = [] self.plugins_before = self.plugins self.plugins = defaultdict(list) # Reset registered plugins for module_name, module in list(sys.modules.items()): if not module or not getattr(module, "__file__", None): continue if self.path_plugins not in module.__file__ and self.path_installed_plugins not in module.__file__: continue if "allow_reload" in dir(module) and not module.allow_reload: # Reload disabled # Re-add non-reloadable plugins for class_name, classes in self.plugins_before.items(): for c in classes: if c.__module__ != module.__name__: continue self.plugins[class_name].append(c) else: try: importlib.reload(module) except Exception as err: self.log.error("Plugin %s reload error: %s" % (module_name, Debug.formatException(err))) self.loadPlugins() # Load new plugins # Change current classes in memory import gc patched = {} for class_name, classes in self.plugins.items(): classes = classes[:] # Copy the current plugins classes.reverse() base_class = self.pluggable[class_name] # Original class classes.append(base_class) # Add the class itself to end of inherience line plugined_class = type(class_name, tuple(classes), dict()) # Create the plugined class for obj in gc.get_objects(): if type(obj).__name__ == class_name: obj.__class__ = plugined_class patched[class_name] = patched.get(class_name, 0) + 1 self.log.debug("Patched objects: %s" % patched) # Change classes in modules patched = {} for class_name, classes in self.plugins.items(): for module_name, module in list(sys.modules.items()): if class_name in dir(module): if "__class__" not in dir(getattr(module, class_name)): # Not a class continue base_class = self.pluggable[class_name] classes = self.plugins[class_name][:] classes.reverse() classes.append(base_class) plugined_class = type(class_name, tuple(classes), dict()) setattr(module, class_name, plugined_class) patched[class_name] = patched.get(class_name, 0) + 1 self.log.debug("Patched modules: %s" % patched) self.reloading = False plugin_manager = PluginManager() # Singletone # -- Decorators -- # Accept plugin to class decorator def acceptPlugins(base_class): class_name = base_class.__name__ plugin_manager.pluggable[class_name] = base_class if class_name in plugin_manager.plugins: # Has plugins classes = plugin_manager.plugins[class_name][:] # Copy the current plugins # Restore the subclass order after reload if class_name in plugin_manager.subclass_order: classes = sorted( classes, key=lambda key: plugin_manager.subclass_order[class_name].index(str(key)) if str(key) in plugin_manager.subclass_order[class_name] else 9999 ) plugin_manager.subclass_order[class_name] = list(map(str, classes)) classes.reverse() classes.append(base_class) # Add the class itself to end of inherience line plugined_class = type(class_name, tuple(classes), dict()) # Create the plugined class plugin_manager.log.debug("New class accepts plugins: %s (Loaded plugins: %s)" % (class_name, classes)) else: # No plugins just use the original plugined_class = base_class return plugined_class # Register plugin to class name decorator def registerTo(class_name): if config.debug and not plugin_manager.reloading: import gc for obj in gc.get_objects(): if type(obj).__name__ == class_name: raise Exception("Class %s instances already present in memory" % class_name) break plugin_manager.log.debug("New plugin registered to: %s" % class_name) if class_name not in plugin_manager.plugins: plugin_manager.plugins[class_name] = [] def classDecorator(self): plugin_manager.plugins[class_name].append(self) return self return classDecorator def afterLoad(func): plugin_manager.after_load.append(func) return func # - Example usage - if __name__ == "__main__": @registerTo("Request") class RequestPlugin(object): def actionMainPage(self, path): return "Hello MainPage!" @acceptPlugins class Request(object): def route(self, path): func = getattr(self, "action" + path, None) if func: return func(path) else: return "Can't route to", path print(Request().route("MainPage")) ================================================ FILE: src/Plugin/__init__.py ================================================ ================================================ FILE: src/Site/Site.py ================================================ import os import json import logging import re import time import random import sys import hashlib import collections import base64 import gevent import gevent.pool import util from Config import config from Peer import Peer from Worker import WorkerManager from Debug import Debug from Content import ContentManager from .SiteStorage import SiteStorage from Crypt import CryptHash from util import helper from util import Diff from util import GreenletManager from Plugin import PluginManager from File import FileServer from .SiteAnnouncer import SiteAnnouncer from . import SiteManager @PluginManager.acceptPlugins class Site(object): def __init__(self, address, allow_create=True, settings=None): self.address = str(re.sub("[^A-Za-z0-9]", "", address)) # Make sure its correct address self.address_hash = hashlib.sha256(self.address.encode("ascii")).digest() self.address_sha1 = hashlib.sha1(self.address.encode("ascii")).digest() self.address_short = "%s..%s" % (self.address[:6], self.address[-4:]) # Short address for logging self.log = logging.getLogger("Site:%s" % self.address_short) self.addEventListeners() self.content = None # Load content.json self.peers = {} # Key: ip:port, Value: Peer.Peer self.peers_recent = collections.deque(maxlen=150) self.peer_blacklist = SiteManager.peer_blacklist # Ignore this peers (eg. myself) self.greenlet_manager = GreenletManager.GreenletManager() # Running greenlets self.worker_manager = WorkerManager(self) # Handle site download from other peers self.bad_files = {} # SHA check failed files, need to redownload {"inner.content": 1} (key: file, value: failed accept) self.content_updated = None # Content.js update time self.notifications = [] # Pending notifications displayed once on page load [error|ok|info, message, timeout] self.page_requested = False # Page viewed in browser self.websockets = [] # Active site websocket connections self.connection_server = None self.loadSettings(settings) # Load settings from sites.json self.storage = SiteStorage(self, allow_create=allow_create) # Save and load site files self.content_manager = ContentManager(self) self.content_manager.loadContents() # Load content.json files if "main" in sys.modules: # import main has side-effects, breaks tests import main if "file_server" in dir(main): # Use global file server by default if possible self.connection_server = main.file_server else: main.file_server = FileServer() self.connection_server = main.file_server else: self.connection_server = FileServer() self.announcer = SiteAnnouncer(self) # Announce and get peer list from other nodes if not self.settings.get("wrapper_key"): # To auth websocket permissions self.settings["wrapper_key"] = CryptHash.random() self.log.debug("New wrapper key: %s" % self.settings["wrapper_key"]) if not self.settings.get("ajax_key"): # To auth websocket permissions self.settings["ajax_key"] = CryptHash.random() self.log.debug("New ajax key: %s" % self.settings["ajax_key"]) def __str__(self): return "Site %s" % self.address_short def __repr__(self): return "<%s>" % self.__str__() # Load site settings from data/sites.json def loadSettings(self, settings=None): if not settings: settings = json.load(open("%s/sites.json" % config.data_dir)).get(self.address) if settings: self.settings = settings if "cache" not in settings: settings["cache"] = {} if "size_files_optional" not in settings: settings["size_optional"] = 0 if "optional_downloaded" not in settings: settings["optional_downloaded"] = 0 if "downloaded" not in settings: settings["downloaded"] = settings.get("added") self.bad_files = settings["cache"].get("bad_files", {}) settings["cache"]["bad_files"] = {} # Give it minimum 10 tries after restart for inner_path in self.bad_files: self.bad_files[inner_path] = min(self.bad_files[inner_path], 20) else: self.settings = { "own": False, "serving": True, "permissions": [], "cache": {"bad_files": {}}, "size_files_optional": 0, "added": int(time.time()), "downloaded": None, "optional_downloaded": 0, "size_optional": 0 } # Default if config.download_optional == "auto": self.settings["autodownloadoptional"] = True # Add admin permissions to homepage if self.address in (config.homepage, config.updatesite) and "ADMIN" not in self.settings["permissions"]: self.settings["permissions"].append("ADMIN") return # Save site settings to data/sites.json def saveSettings(self): if not SiteManager.site_manager.sites: SiteManager.site_manager.sites = {} if not SiteManager.site_manager.sites.get(self.address): SiteManager.site_manager.sites[self.address] = self SiteManager.site_manager.load(False) SiteManager.site_manager.saveDelayed() def isServing(self): if config.offline: return False else: return self.settings["serving"] def getSettingsCache(self): back = {} back["bad_files"] = self.bad_files back["hashfield"] = base64.b64encode(self.content_manager.hashfield.tobytes()).decode("ascii") return back # Max site size in MB def getSizeLimit(self): return self.settings.get("size_limit", int(config.size_limit)) # Next size limit based on current size def getNextSizeLimit(self): size_limits = [10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000] size = self.settings.get("size", 0) for size_limit in size_limits: if size * 1.2 < size_limit * 1024 * 1024: return size_limit return 999999 def isAddedRecently(self): return time.time() - self.settings.get("added", 0) < 60 * 60 * 24 # Download all file from content.json def downloadContent(self, inner_path, download_files=True, peer=None, check_modifications=False, diffs={}): s = time.time() if config.verbose: self.log.debug( "DownloadContent %s: Started. (download_files: %s, check_modifications: %s, diffs: %s)..." % (inner_path, download_files, check_modifications, diffs.keys()) ) if not inner_path.endswith("content.json"): return False found = self.needFile(inner_path, update=self.bad_files.get(inner_path)) content_inner_dir = helper.getDirname(inner_path) if not found: self.log.debug("DownloadContent %s: Download failed, check_modifications: %s" % (inner_path, check_modifications)) if check_modifications: # Download failed, but check modifications if its succed later self.onFileDone.once(lambda file_name: self.checkModifications(0), "check_modifications") return False # Could not download content.json if config.verbose: self.log.debug("DownloadContent got %s" % inner_path) sub_s = time.time() changed, deleted = self.content_manager.loadContent(inner_path, load_includes=False) if config.verbose: self.log.debug("DownloadContent %s: loadContent done in %.3fs" % (inner_path, time.time() - sub_s)) if inner_path == "content.json": self.saveSettings() if peer: # Update last received update from peer to prevent re-sending the same update to it peer.last_content_json_update = self.content_manager.contents[inner_path]["modified"] # Verify size limit if inner_path == "content.json": site_size_limit = self.getSizeLimit() * 1024 * 1024 content_size = len(json.dumps(self.content_manager.contents[inner_path], indent=1)) + sum([file["size"] for file in list(self.content_manager.contents[inner_path].get("files", {}).values()) if file["size"] >= 0]) # Size of new content if site_size_limit < content_size: # Not enought don't download anything self.log.debug("DownloadContent Size limit reached (site too big please increase limit): %.2f MB > %.2f MB" % (content_size / 1024 / 1024, site_size_limit / 1024 / 1024)) return False # Start download files file_threads = [] if download_files: for file_relative_path in list(self.content_manager.contents[inner_path].get("files", {}).keys()): file_inner_path = content_inner_dir + file_relative_path # Try to diff first diff_success = False diff_actions = diffs.get(file_relative_path) if diff_actions and self.bad_files.get(file_inner_path): try: s = time.time() new_file = Diff.patch(self.storage.open(file_inner_path, "rb"), diff_actions) new_file.seek(0) time_diff = time.time() - s s = time.time() diff_success = self.content_manager.verifyFile(file_inner_path, new_file) time_verify = time.time() - s if diff_success: s = time.time() new_file.seek(0) self.storage.write(file_inner_path, new_file) time_write = time.time() - s s = time.time() self.onFileDone(file_inner_path) time_on_done = time.time() - s self.log.debug( "DownloadContent Patched successfully: %s (diff: %.3fs, verify: %.3fs, write: %.3fs, on_done: %.3fs)" % (file_inner_path, time_diff, time_verify, time_write, time_on_done) ) except Exception as err: self.log.debug("DownloadContent Failed to patch %s: %s" % (file_inner_path, err)) diff_success = False if not diff_success: # Start download and dont wait for finish, return the event res = self.needFile(file_inner_path, blocking=False, update=self.bad_files.get(file_inner_path), peer=peer) if res is not True and res is not False: # Need downloading and file is allowed file_threads.append(res) # Append evt # Optionals files if inner_path == "content.json": gevent.spawn(self.updateHashfield) for file_relative_path in list(self.content_manager.contents[inner_path].get("files_optional", {}).keys()): file_inner_path = content_inner_dir + file_relative_path if file_inner_path not in changed and not self.bad_files.get(file_inner_path): continue if not self.isDownloadable(file_inner_path): continue # Start download and dont wait for finish, return the event res = self.pooledNeedFile( file_inner_path, blocking=False, update=self.bad_files.get(file_inner_path), peer=peer ) if res is not True and res is not False: # Need downloading and file is allowed file_threads.append(res) # Append evt # Wait for includes download include_threads = [] for file_relative_path in list(self.content_manager.contents[inner_path].get("includes", {}).keys()): file_inner_path = content_inner_dir + file_relative_path include_thread = gevent.spawn(self.downloadContent, file_inner_path, download_files=download_files, peer=peer) include_threads.append(include_thread) if config.verbose: self.log.debug("DownloadContent %s: Downloading %s includes..." % (inner_path, len(include_threads))) gevent.joinall(include_threads) if config.verbose: self.log.debug("DownloadContent %s: Includes download ended" % inner_path) if check_modifications: # Check if every file is up-to-date self.checkModifications(0) if config.verbose: self.log.debug("DownloadContent %s: Downloading %s files, changed: %s..." % (inner_path, len(file_threads), len(changed))) gevent.joinall(file_threads) if config.verbose: self.log.debug("DownloadContent %s: ended in %.3fs (tasks left: %s)" % ( inner_path, time.time() - s, len(self.worker_manager.tasks) )) return True # Return bad files with less than 3 retry def getReachableBadFiles(self): if not self.bad_files: return False return [bad_file for bad_file, retry in self.bad_files.items() if retry < 3] # Retry download bad files def retryBadFiles(self, force=False): self.checkBadFiles() self.log.debug("Retry %s bad files" % len(self.bad_files)) content_inner_paths = [] file_inner_paths = [] for bad_file, tries in list(self.bad_files.items()): if force or random.randint(0, min(40, tries)) < 4: # Larger number tries = less likely to check every 15min if bad_file.endswith("content.json"): content_inner_paths.append(bad_file) else: file_inner_paths.append(bad_file) if content_inner_paths: self.pooledDownloadContent(content_inner_paths, only_if_bad=True) if file_inner_paths: self.pooledDownloadFile(file_inner_paths, only_if_bad=True) def checkBadFiles(self): for bad_file in list(self.bad_files.keys()): file_info = self.content_manager.getFileInfo(bad_file) if bad_file.endswith("content.json"): if file_info is False and bad_file != "content.json": del self.bad_files[bad_file] self.log.debug("No info for file: %s, removing from bad_files" % bad_file) else: if file_info is False or not file_info.get("size"): del self.bad_files[bad_file] self.log.debug("No info or size for file: %s, removing from bad_files" % bad_file) # Download all files of the site @util.Noparallel(blocking=False) def download(self, check_size=False, blind_includes=False, retry_bad_files=True): if not self.connection_server: self.log.debug("No connection server found, skipping download") return False s = time.time() self.log.debug( "Start downloading, bad_files: %s, check_size: %s, blind_includes: %s, isAddedRecently: %s" % (self.bad_files, check_size, blind_includes, self.isAddedRecently()) ) if self.isAddedRecently(): gevent.spawn(self.announce, mode="start", force=True) else: gevent.spawn(self.announce, mode="update") if check_size: # Check the size first valid = self.downloadContent("content.json", download_files=False) # Just download content.json files if not valid: return False # Cant download content.jsons or size is not fits # Download everything valid = self.downloadContent("content.json", check_modifications=blind_includes) if retry_bad_files: self.onComplete.once(lambda: self.retryBadFiles(force=True)) self.log.debug("Download done in %.3fs" % (time.time() - s)) return valid def pooledDownloadContent(self, inner_paths, pool_size=100, only_if_bad=False): self.log.debug("New downloadContent pool: len: %s, only if bad: %s" % (len(inner_paths), only_if_bad)) self.worker_manager.started_task_num += len(inner_paths) pool = gevent.pool.Pool(pool_size) num_skipped = 0 site_size_limit = self.getSizeLimit() * 1024 * 1024 for inner_path in inner_paths: if not only_if_bad or inner_path in self.bad_files: pool.spawn(self.downloadContent, inner_path) else: num_skipped += 1 self.worker_manager.started_task_num -= 1 if self.settings["size"] > site_size_limit * 0.95: self.log.warning("Site size limit almost reached, aborting downloadContent pool") for aborted_inner_path in inner_paths: if aborted_inner_path in self.bad_files: del self.bad_files[aborted_inner_path] self.worker_manager.removeSolvedFileTasks(mark_as_good=False) break pool.join() self.log.debug("Ended downloadContent pool len: %s, skipped: %s" % (len(inner_paths), num_skipped)) def pooledDownloadFile(self, inner_paths, pool_size=100, only_if_bad=False): self.log.debug("New downloadFile pool: len: %s, only if bad: %s" % (len(inner_paths), only_if_bad)) self.worker_manager.started_task_num += len(inner_paths) pool = gevent.pool.Pool(pool_size) num_skipped = 0 for inner_path in inner_paths: if not only_if_bad or inner_path in self.bad_files: pool.spawn(self.needFile, inner_path, update=True) else: num_skipped += 1 self.worker_manager.started_task_num -= 1 self.log.debug("Ended downloadFile pool len: %s, skipped: %s" % (len(inner_paths), num_skipped)) # Update worker, try to find client that supports listModifications command def updater(self, peers_try, queried, since): threads = [] while 1: if not peers_try or len(queried) >= 3: # Stop after 3 successful query break peer = peers_try.pop(0) if config.verbose: self.log.debug("CheckModifications: Try to get updates from: %s Left: %s" % (peer, peers_try)) res = None with gevent.Timeout(20, exception=False): res = peer.listModified(since) if not res or "modified_files" not in res: continue # Failed query queried.append(peer) modified_contents = [] my_modified = self.content_manager.listModified(since) num_old_files = 0 for inner_path, modified in res["modified_files"].items(): # Check if the peer has newer files than we has_newer = int(modified) > my_modified.get(inner_path, 0) has_older = int(modified) < my_modified.get(inner_path, 0) if inner_path not in self.bad_files and not self.content_manager.isArchived(inner_path, modified): if has_newer: # We dont have this file or we have older modified_contents.append(inner_path) self.bad_files[inner_path] = self.bad_files.get(inner_path, 0) + 1 if has_older and num_old_files < 5: num_old_files += 1 self.log.debug("CheckModifications: %s client has older version of %s, publishing there (%s/5)..." % (peer, inner_path, num_old_files)) gevent.spawn(self.publisher, inner_path, [peer], [], 1) if modified_contents: self.log.debug("CheckModifications: %s new modified file from %s" % (len(modified_contents), peer)) modified_contents.sort(key=lambda inner_path: 0 - res["modified_files"][inner_path]) # Download newest first t = gevent.spawn(self.pooledDownloadContent, modified_contents, only_if_bad=True) threads.append(t) if config.verbose: self.log.debug("CheckModifications: Waiting for %s pooledDownloadContent" % len(threads)) gevent.joinall(threads) # Check modified content.json files from peers and add modified files to bad_files # Return: Successfully queried peers [Peer, Peer...] def checkModifications(self, since=None): s = time.time() peers_try = [] # Try these peers queried = [] # Successfully queried from these peers limit = 5 # Wait for peers if not self.peers: self.announce(mode="update") for wait in range(10): time.sleep(5 + wait) self.log.debug("CheckModifications: Waiting for peers...") if self.peers: break peers_try = self.getConnectedPeers() peers_connected_num = len(peers_try) if peers_connected_num < limit * 2: # Add more, non-connected peers if necessary peers_try += self.getRecentPeers(limit * 5) if since is None: # No since defined, download from last modification time-1day since = self.settings.get("modified", 60 * 60 * 24) - 60 * 60 * 24 if config.verbose: self.log.debug( "CheckModifications: Try to get listModifications from peers: %s, connected: %s, since: %s" % (peers_try, peers_connected_num, since) ) updaters = [] for i in range(3): updaters.append(gevent.spawn(self.updater, peers_try, queried, since)) gevent.joinall(updaters, timeout=10) # Wait 10 sec to workers done query modifications if not queried: # Start another 3 thread if first 3 is stuck peers_try[0:0] = [peer for peer in self.getConnectedPeers() if peer.connection.connected] # Add connected peers for _ in range(10): gevent.joinall(updaters, timeout=10) # Wait another 10 sec if none of updaters finished if queried: break self.log.debug("CheckModifications: Queried listModifications from: %s in %.3fs since %s" % (queried, time.time() - s, since)) time.sleep(0.1) return queried # Update content.json from peers and download changed files # Return: None @util.Noparallel() def update(self, announce=False, check_files=False, since=None): self.content_manager.loadContent("content.json", load_includes=False) # Reload content.json self.content_updated = None # Reset content updated time if check_files: self.storage.updateBadFiles(quick_check=True) # Quick check and mark bad files based on file size if not self.isServing(): return False self.updateWebsocket(updating=True) # Remove files that no longer in content.json self.checkBadFiles() if announce: self.announce(mode="update", force=True) # Full update, we can reset bad files if check_files and since == 0: self.bad_files = {} queried = self.checkModifications(since) changed, deleted = self.content_manager.loadContent("content.json", load_includes=False) if self.bad_files: self.log.debug("Bad files: %s" % self.bad_files) gevent.spawn(self.retryBadFiles, force=True) if len(queried) == 0: # Failed to query modifications self.content_updated = False else: self.content_updated = time.time() self.updateWebsocket(updated=True) # Update site by redownload all content.json def redownloadContents(self): # Download all content.json again content_threads = [] for inner_path in list(self.content_manager.contents.keys()): content_threads.append(self.needFile(inner_path, update=True, blocking=False)) self.log.debug("Waiting %s content.json to finish..." % len(content_threads)) gevent.joinall(content_threads) # Publish worker def publisher(self, inner_path, peers, published, limit, diffs={}, event_done=None, cb_progress=None): file_size = self.storage.getSize(inner_path) content_json_modified = self.content_manager.contents[inner_path]["modified"] body = self.storage.read(inner_path) while 1: if not peers or len(published) >= limit: if event_done: event_done.set(True) break # All peers done, or published engouht peer = peers.pop() if peer in published: continue if peer.last_content_json_update == content_json_modified: self.log.debug("%s already received this update for %s, skipping" % (peer, inner_path)) continue if peer.connection and peer.connection.last_ping_delay: # Peer connected # Timeout: 5sec + size in kb + last_ping timeout = 5 + int(file_size / 1024) + peer.connection.last_ping_delay else: # Peer not connected # Timeout: 10sec + size in kb timeout = 10 + int(file_size / 1024) result = {"exception": "Timeout"} for retry in range(2): try: with gevent.Timeout(timeout, False): result = peer.publish(self.address, inner_path, body, content_json_modified, diffs) if result: break except Exception as err: self.log.error("Publish error: %s" % Debug.formatException(err)) result = {"exception": Debug.formatException(err)} if result and "ok" in result: published.append(peer) if cb_progress and len(published) <= limit: cb_progress(len(published), limit) self.log.info("[OK] %s: %s %s/%s" % (peer.key, result["ok"], len(published), limit)) else: if result == {"exception": "Timeout"}: peer.onConnectionError("Publish timeout") self.log.info("[FAILED] %s: %s" % (peer.key, result)) time.sleep(0.01) # Update content.json on peers @util.Noparallel() def publish(self, limit="default", inner_path="content.json", diffs={}, cb_progress=None): published = [] # Successfully published (Peer) publishers = [] # Publisher threads if not self.peers: self.announce(mode="more") if limit == "default": limit = 5 threads = limit peers = self.getConnectedPeers() num_connected_peers = len(peers) random.shuffle(peers) peers = sorted(peers, key=lambda peer: peer.connection.handshake.get("rev", 0) < config.rev - 100) # Prefer newer clients if len(peers) < limit * 2 and len(self.peers) > len(peers): # Add more, non-connected peers if necessary peers += self.getRecentPeers(limit * 2) peers = set(peers) self.log.info("Publishing %s to %s/%s peers (connected: %s) diffs: %s (%.2fk)..." % ( inner_path, limit, len(self.peers), num_connected_peers, list(diffs.keys()), float(len(str(diffs))) / 1024 )) if not peers: return 0 # No peers found event_done = gevent.event.AsyncResult() for i in range(min(len(peers), limit, threads)): publisher = gevent.spawn(self.publisher, inner_path, peers, published, limit, diffs, event_done, cb_progress) publishers.append(publisher) event_done.get() # Wait for done if len(published) < min(len(self.peers), limit): time.sleep(0.2) # If less than we need sleep a bit if len(published) == 0: gevent.joinall(publishers) # No successful publish, wait for all publisher # Publish more peers in the backgroup self.log.info( "Published %s to %s peers, publishing to %s more peers in the background" % (inner_path, len(published), limit) ) for thread in range(2): gevent.spawn(self.publisher, inner_path, peers, published, limit=limit * 2, diffs=diffs) # Send my hashfield to every connected peer if changed gevent.spawn(self.sendMyHashfield, 100) return len(published) # Copy this site @util.Noparallel() def clone(self, address, privatekey=None, address_index=None, root_inner_path="", overwrite=False): import shutil new_site = SiteManager.site_manager.need(address, all_file=False) default_dirs = [] # Dont copy these directories (has -default version) for dir_name in os.listdir(self.storage.directory): if "-default" in dir_name: default_dirs.append(dir_name.replace("-default", "")) self.log.debug("Cloning to %s, ignore dirs: %s, root: %s" % (address, default_dirs, root_inner_path)) # Copy root content.json if not new_site.storage.isFile("content.json") and not overwrite: # New site: Content.json not exist yet, create a new one from source site if "size_limit" in self.settings: new_site.settings["size_limit"] = self.settings["size_limit"] # Use content.json-default is specified if self.storage.isFile(root_inner_path + "/content.json-default"): content_json = self.storage.loadJson(root_inner_path + "/content.json-default") else: content_json = self.storage.loadJson("content.json") if "domain" in content_json: del content_json["domain"] content_json["title"] = "my" + content_json["title"] content_json["cloned_from"] = self.address content_json["clone_root"] = root_inner_path content_json["files"] = {} if address_index: content_json["address_index"] = address_index # Site owner's BIP32 index new_site.storage.writeJson("content.json", content_json) new_site.content_manager.loadContent( "content.json", add_bad_files=False, delete_removed_files=False, load_includes=False ) # Copy files for content_inner_path, content in list(self.content_manager.contents.items()): file_relative_paths = list(content.get("files", {}).keys()) # Sign content.json at the end to make sure every file is included file_relative_paths.sort() file_relative_paths.sort(key=lambda key: key.replace("-default", "").endswith("content.json")) for file_relative_path in file_relative_paths: file_inner_path = helper.getDirname(content_inner_path) + file_relative_path # Relative to content.json file_inner_path = file_inner_path.strip("/") # Strip leading / if not file_inner_path.startswith(root_inner_path): self.log.debug("[SKIP] %s (not in clone root)" % file_inner_path) continue if file_inner_path.split("/")[0] in default_dirs: # Dont copy directories that has -default postfixed alternative self.log.debug("[SKIP] %s (has default alternative)" % file_inner_path) continue file_path = self.storage.getPath(file_inner_path) # Copy the file normally to keep the -default postfixed dir and file to allow cloning later if root_inner_path: file_inner_path_dest = re.sub("^%s/" % re.escape(root_inner_path), "", file_inner_path) file_path_dest = new_site.storage.getPath(file_inner_path_dest) else: file_inner_path_dest = file_inner_path file_path_dest = new_site.storage.getPath(file_inner_path) self.log.debug("[COPY] %s to %s..." % (file_inner_path, file_path_dest)) dest_dir = os.path.dirname(file_path_dest) if not os.path.isdir(dest_dir): os.makedirs(dest_dir) if file_inner_path_dest.replace("-default", "") == "content.json": # Don't copy root content.json-default continue shutil.copy(file_path, file_path_dest) # If -default in path, create a -default less copy of the file if "-default" in file_inner_path_dest: file_path_dest = new_site.storage.getPath(file_inner_path_dest.replace("-default", "")) if new_site.storage.isFile(file_inner_path_dest.replace("-default", "")) and not overwrite: # Don't overwrite site files with default ones self.log.debug("[SKIP] Default file: %s (already exist)" % file_inner_path) continue self.log.debug("[COPY] Default file: %s to %s..." % (file_inner_path, file_path_dest)) dest_dir = os.path.dirname(file_path_dest) if not os.path.isdir(dest_dir): os.makedirs(dest_dir) shutil.copy(file_path, file_path_dest) # Sign if content json if file_path_dest.endswith("/content.json"): new_site.storage.onUpdated(file_inner_path_dest.replace("-default", "")) new_site.content_manager.loadContent( file_inner_path_dest.replace("-default", ""), add_bad_files=False, delete_removed_files=False, load_includes=False ) if privatekey: new_site.content_manager.sign(file_inner_path_dest.replace("-default", ""), privatekey, remove_missing_optional=True) new_site.content_manager.loadContent( file_inner_path_dest, add_bad_files=False, delete_removed_files=False, load_includes=False ) if privatekey: new_site.content_manager.sign("content.json", privatekey, remove_missing_optional=True) new_site.content_manager.loadContent( "content.json", add_bad_files=False, delete_removed_files=False, load_includes=False ) # Rebuild DB if new_site.storage.isFile("dbschema.json"): new_site.storage.closeDb() try: new_site.storage.rebuildDb() except Exception as err: self.log.error(err) return new_site @util.Pooled(100) def pooledNeedFile(self, *args, **kwargs): return self.needFile(*args, **kwargs) def isFileDownloadAllowed(self, inner_path, file_info): # Verify space for all site if self.settings["size"] > self.getSizeLimit() * 1024 * 1024: return False # Verify space for file if file_info.get("size", 0) > config.file_size_limit * 1024 * 1024: self.log.debug( "File size %s too large: %sMB > %sMB, skipping..." % (inner_path, file_info.get("size", 0) / 1024 / 1024, config.file_size_limit) ) return False else: return True def needFileInfo(self, inner_path): file_info = self.content_manager.getFileInfo(inner_path) if not file_info: # No info for file, download all content.json first self.log.debug("No info for %s, waiting for all content.json" % inner_path) success = self.downloadContent("content.json", download_files=False) if not success: return False file_info = self.content_manager.getFileInfo(inner_path) return file_info # Check and download if file not exist def needFile(self, inner_path, update=False, blocking=True, peer=None, priority=0): if self.worker_manager.tasks.findTask(inner_path): task = self.worker_manager.addTask(inner_path, peer, priority=priority) if blocking: return task["evt"].get() else: return task["evt"] elif self.storage.isFile(inner_path) and not update: # File exist, no need to do anything return True elif not self.isServing(): # Site not serving return False else: # Wait until file downloaded if not self.content_manager.contents.get("content.json"): # No content.json, download it first! self.log.debug("Need content.json first (inner_path: %s, priority: %s)" % (inner_path, priority)) if priority > 0: gevent.spawn(self.announce) if inner_path != "content.json": # Prevent double download task = self.worker_manager.addTask("content.json", peer) task["evt"].get() self.content_manager.loadContent() if not self.content_manager.contents.get("content.json"): return False # Content.json download failed file_info = None if not inner_path.endswith("content.json"): file_info = self.needFileInfo(inner_path) if not file_info: return False if "cert_signers" in file_info and not file_info["content_inner_path"] in self.content_manager.contents: self.log.debug("Missing content.json for requested user file: %s" % inner_path) if self.bad_files.get(file_info["content_inner_path"], 0) > 5: self.log.debug("File %s not reachable: retry %s" % ( inner_path, self.bad_files.get(file_info["content_inner_path"], 0) )) return False self.downloadContent(file_info["content_inner_path"]) if not self.isFileDownloadAllowed(inner_path, file_info): self.log.debug("%s: Download not allowed" % inner_path) return False self.bad_files[inner_path] = self.bad_files.get(inner_path, 0) + 1 # Mark as bad file task = self.worker_manager.addTask(inner_path, peer, priority=priority, file_info=file_info) if blocking: return task["evt"].get() else: return task["evt"] # Add or update a peer to site # return_peer: Always return the peer even if it was already present def addPeer(self, ip, port, return_peer=False, connection=None, source="other"): if not ip or ip == "0.0.0.0": return False key = "%s:%s" % (ip, port) peer = self.peers.get(key) if peer: # Already has this ip peer.found(source) if return_peer: # Always return peer return peer else: return False else: # New peer if (ip, port) in self.peer_blacklist: return False # Ignore blacklist (eg. myself) peer = Peer(ip, port, self) self.peers[key] = peer peer.found(source) return peer def announce(self, *args, **kwargs): if self.isServing(): self.announcer.announce(*args, **kwargs) # Keep connections to get the updates def needConnections(self, num=None, check_site_on_reconnect=False): if num is None: if len(self.peers) < 50: num = 3 else: num = 6 need = min(len(self.peers), num, config.connected_limit) # Need 5 peer, but max total peers connected = len(self.getConnectedPeers()) connected_before = connected self.log.debug("Need connections: %s, Current: %s, Total: %s" % (need, connected, len(self.peers))) if connected < need: # Need more than we have for peer in self.getRecentPeers(30): if not peer.connection or not peer.connection.connected: # No peer connection or disconnected peer.pex() # Initiate peer exchange if peer.connection and peer.connection.connected: connected += 1 # Successfully connected if connected >= need: break self.log.debug( "Connected before: %s, after: %s. Check site: %s." % (connected_before, connected, check_site_on_reconnect) ) if check_site_on_reconnect and connected_before == 0 and connected > 0 and self.connection_server.has_internet: gevent.spawn(self.update, check_files=False) return connected # Return: Probably peers verified to be connectable recently def getConnectablePeers(self, need_num=5, ignore=[], allow_private=True): peers = list(self.peers.values()) found = [] for peer in peers: if peer.key.endswith(":0"): continue # Not connectable if not peer.connection: continue # No connection if peer.ip.endswith(".onion") and not self.connection_server.tor_manager.enabled: continue # Onion not supported if peer.key in ignore: continue # The requester has this peer if time.time() - peer.connection.last_recv_time > 60 * 60 * 2: # Last message more than 2 hours ago peer.connection = None # Cleanup: Dead connection continue if not allow_private and helper.isPrivateIp(peer.ip): continue found.append(peer) if len(found) >= need_num: break # Found requested number of peers if len(found) < need_num: # Return not that good peers found += [ peer for peer in peers if not peer.key.endswith(":0") and peer.key not in ignore and (allow_private or not helper.isPrivateIp(peer.ip)) ][0:need_num - len(found)] return found # Return: Recently found peers def getRecentPeers(self, need_num): found = list(set(self.peers_recent)) self.log.debug( "Recent peers %s of %s (need: %s)" % (len(found), len(self.peers), need_num) ) if len(found) >= need_num or len(found) >= len(self.peers): return sorted( found, key=lambda peer: peer.reputation, reverse=True )[0:need_num] # Add random peers need_more = need_num - len(found) if not self.connection_server.tor_manager.enabled: peers = [peer for peer in self.peers.values() if not peer.ip.endswith(".onion")] else: peers = list(self.peers.values()) found_more = sorted( peers[0:need_more * 50], key=lambda peer: peer.reputation, reverse=True )[0:need_more * 2] found += found_more return found[0:need_num] def getConnectedPeers(self): back = [] if not self.connection_server: return [] tor_manager = self.connection_server.tor_manager for connection in self.connection_server.connections: if not connection.connected and time.time() - connection.start_time > 20: # Still not connected after 20s continue peer = self.peers.get("%s:%s" % (connection.ip, connection.port)) if peer: if connection.ip.endswith(".onion") and connection.target_onion and tor_manager.start_onions: # Check if the connection is made with the onion address created for the site valid_target_onions = (tor_manager.getOnion(self.address), tor_manager.getOnion("global")) if connection.target_onion not in valid_target_onions: continue if not peer.connection: peer.connect(connection) back.append(peer) return back # Cleanup probably dead peers and close connection if too much def cleanupPeers(self, peers_protected=[]): peers = list(self.peers.values()) if len(peers) > 20: # Cleanup old peers removed = 0 if len(peers) > 1000: ttl = 60 * 60 * 1 else: ttl = 60 * 60 * 4 for peer in peers: if peer.connection and peer.connection.connected: continue if peer.connection and not peer.connection.connected: peer.connection = None # Dead connection if time.time() - peer.time_found > ttl: # Not found on tracker or via pex in last 4 hour peer.remove("Time found expired") removed += 1 if removed > len(peers) * 0.1: # Don't remove too much at once break if removed: self.log.debug("Cleanup peers result: Removed %s, left: %s" % (removed, len(self.peers))) # Close peers over the limit closed = 0 connected_peers = [peer for peer in self.getConnectedPeers() if peer.connection.connected] # Only fully connected peers need_to_close = len(connected_peers) - config.connected_limit if closed < need_to_close: # Try to keep connections with more sites for peer in sorted(connected_peers, key=lambda peer: min(peer.connection.sites, 5)): if not peer.connection: continue if peer.key in peers_protected: continue if peer.connection.sites > 5: break peer.connection.close("Cleanup peers") peer.connection = None closed += 1 if closed >= need_to_close: break if need_to_close > 0: self.log.debug("Connected: %s, Need to close: %s, Closed: %s" % (len(connected_peers), need_to_close, closed)) # Send hashfield to peers def sendMyHashfield(self, limit=5): if not self.content_manager.hashfield: # No optional files return False sent = 0 connected_peers = self.getConnectedPeers() for peer in connected_peers: if peer.sendMyHashfield(): sent += 1 if sent >= limit: break if sent: my_hashfield_changed = self.content_manager.hashfield.time_changed self.log.debug("Sent my hashfield (chaged %.3fs ago) to %s peers" % (time.time() - my_hashfield_changed, sent)) return sent # Update hashfield def updateHashfield(self, limit=5): # Return if no optional files if not self.content_manager.hashfield and not self.content_manager.has_optional_files: return False s = time.time() queried = 0 connected_peers = self.getConnectedPeers() for peer in connected_peers: if peer.time_hashfield: continue if peer.updateHashfield(): queried += 1 if queried >= limit: break if queried: self.log.debug("Queried hashfield from %s peers in %.3fs" % (queried, time.time() - s)) return queried # Returns if the optional file is need to be downloaded or not def isDownloadable(self, inner_path): return self.settings.get("autodownloadoptional") def delete(self): self.log.info("Deleting site...") s = time.time() self.settings["serving"] = False self.settings["deleting"] = True self.saveSettings() num_greenlets = self.greenlet_manager.stopGreenlets("Site %s deleted" % self.address) self.worker_manager.running = False num_workers = self.worker_manager.stopWorkers() SiteManager.site_manager.delete(self.address) self.content_manager.contents.db.deleteSite(self) self.updateWebsocket(deleted=True) self.storage.deleteFiles() self.log.info( "Deleted site in %.3fs (greenlets: %s, workers: %s)" % (time.time() - s, num_greenlets, num_workers) ) # - Events - # Add event listeners def addEventListeners(self): self.onFileStart = util.Event() # If WorkerManager added new task self.onFileDone = util.Event() # If WorkerManager successfully downloaded a file self.onFileFail = util.Event() # If WorkerManager failed to download a file self.onComplete = util.Event() # All file finished self.onFileStart.append(lambda inner_path: self.fileStarted()) # No parameters to make Noparallel batching working self.onFileDone.append(lambda inner_path: self.fileDone(inner_path)) self.onFileFail.append(lambda inner_path: self.fileFailed(inner_path)) # Send site status update to websocket clients def updateWebsocket(self, **kwargs): if kwargs: param = {"event": list(kwargs.items())[0]} else: param = None for ws in self.websockets: ws.event("siteChanged", self, param) def messageWebsocket(self, message, type="info", progress=None): for ws in self.websockets: if progress is None: ws.cmd("notification", [type, message]) else: ws.cmd("progress", [type, message, progress]) # File download started @util.Noparallel(blocking=False) def fileStarted(self): time.sleep(0.001) # Wait for other files adds self.updateWebsocket(file_started=True) # File downloaded successful def fileDone(self, inner_path): # File downloaded, remove it from bad files if inner_path in self.bad_files: if config.verbose: self.log.debug("Bad file solved: %s" % inner_path) del(self.bad_files[inner_path]) # Update content.json last downlad time if inner_path == "content.json": if not self.settings.get("downloaded"): self.settings["downloaded"] = int(time.time()) self.content_updated = time.time() self.updateWebsocket(file_done=inner_path) # File download failed def fileFailed(self, inner_path): if inner_path == "content.json": self.content_updated = False self.log.debug("Can't update content.json") if inner_path in self.bad_files and self.connection_server.has_internet: self.bad_files[inner_path] = self.bad_files.get(inner_path, 0) + 1 self.updateWebsocket(file_failed=inner_path) if self.bad_files.get(inner_path, 0) > 30: self.fileForgot(inner_path) def fileForgot(self, inner_path): self.log.debug("Giving up on %s" % inner_path) del self.bad_files[inner_path] # Give up after 30 tries ================================================ FILE: src/Site/SiteAnnouncer.py ================================================ import random import time import hashlib import re import collections import gevent from Plugin import PluginManager from Config import config from Debug import Debug from util import helper from greenlet import GreenletExit import util class AnnounceError(Exception): pass global_stats = collections.defaultdict(lambda: collections.defaultdict(int)) @PluginManager.acceptPlugins class SiteAnnouncer(object): def __init__(self, site): self.site = site self.stats = {} self.fileserver_port = config.fileserver_port self.peer_id = self.site.connection_server.peer_id self.last_tracker_id = random.randint(0, 10) self.time_last_announce = 0 def getTrackers(self): return config.trackers def getSupportedTrackers(self): trackers = self.getTrackers() if not self.site.connection_server.tor_manager.enabled: trackers = [tracker for tracker in trackers if ".onion" not in tracker] trackers = [tracker for tracker in trackers if self.getAddressParts(tracker)] # Remove trackers with unknown address if "ipv6" not in self.site.connection_server.supported_ip_types: trackers = [tracker for tracker in trackers if helper.getIpType(self.getAddressParts(tracker)["ip"]) != "ipv6"] return trackers def getAnnouncingTrackers(self, mode): trackers = self.getSupportedTrackers() if trackers and (mode == "update" or mode == "more"): # Only announce on one tracker, increment the queried tracker id self.last_tracker_id += 1 self.last_tracker_id = self.last_tracker_id % len(trackers) trackers_announcing = [trackers[self.last_tracker_id]] # We only going to use this one else: trackers_announcing = trackers return trackers_announcing def getOpenedServiceTypes(self): back = [] # Type of addresses they can reach me if config.trackers_proxy == "disable" and config.tor != "always": for ip_type, opened in list(self.site.connection_server.port_opened.items()): if opened: back.append(ip_type) if self.site.connection_server.tor_manager.start_onions: back.append("onion") return back @util.Noparallel(blocking=False) def announce(self, force=False, mode="start", pex=True): if time.time() - self.time_last_announce < 30 and not force: return # No reannouncing within 30 secs if force: self.site.log.debug("Force reannounce in mode %s" % mode) self.fileserver_port = config.fileserver_port self.time_last_announce = time.time() trackers = self.getAnnouncingTrackers(mode) if config.verbose: self.site.log.debug("Tracker announcing, trackers: %s" % trackers) errors = [] slow = [] s = time.time() threads = [] num_announced = 0 for tracker in trackers: # Start announce threads tracker_stats = global_stats[tracker] # Reduce the announce time for trackers that looks unreliable time_announce_allowed = time.time() - 60 * min(30, tracker_stats["num_error"]) if tracker_stats["num_error"] > 5 and tracker_stats["time_request"] > time_announce_allowed and not force: if config.verbose: self.site.log.debug("Tracker %s looks unreliable, announce skipped (error: %s)" % (tracker, tracker_stats["num_error"])) continue thread = self.site.greenlet_manager.spawn(self.announceTracker, tracker, mode=mode) threads.append(thread) thread.tracker = tracker time.sleep(0.01) self.updateWebsocket(trackers="announcing") gevent.joinall(threads, timeout=20) # Wait for announce finish for thread in threads: if thread.value is None: continue if thread.value is not False: if thread.value > 1.0: # Takes more than 1 second to announce slow.append("%.2fs %s" % (thread.value, thread.tracker)) num_announced += 1 else: if thread.ready(): errors.append(thread.tracker) else: # Still running slow.append("30s+ %s" % thread.tracker) # Save peers num self.site.settings["peers"] = len(self.site.peers) if len(errors) < len(threads): # At least one tracker finished if len(trackers) == 1: announced_to = trackers[0] else: announced_to = "%s/%s trackers" % (num_announced, len(threads)) if mode != "update" or config.verbose: self.site.log.debug( "Announced in mode %s to %s in %.3fs, errors: %s, slow: %s" % (mode, announced_to, time.time() - s, errors, slow) ) else: if len(threads) > 1: self.site.log.error("Announce to %s trackers in %.3fs, failed" % (len(threads), time.time() - s)) if len(threads) == 1 and mode != "start": # Move to next tracker self.site.log.debug("Tracker failed, skipping to next one...") self.site.greenlet_manager.spawnLater(1.0, self.announce, force=force, mode=mode, pex=pex) self.updateWebsocket(trackers="announced") if pex: self.updateWebsocket(pex="announcing") if mode == "more": # Need more peers self.announcePex(need_num=10) else: self.announcePex() self.updateWebsocket(pex="announced") def getTrackerHandler(self, protocol): return None def getAddressParts(self, tracker): if "://" not in tracker or not re.match("^[A-Za-z0-9:/\\.#-]+$", tracker): return None protocol, address = tracker.split("://", 1) if ":" in address: ip, port = address.rsplit(":", 1) else: ip = address if protocol.startswith("https"): port = 443 else: port = 80 back = {} back["protocol"] = protocol back["address"] = address back["ip"] = ip back["port"] = port return back def announceTracker(self, tracker, mode="start", num_want=10): s = time.time() address_parts = self.getAddressParts(tracker) if not address_parts: self.site.log.warning("Tracker %s error: Invalid address" % tracker) return False if tracker not in self.stats: self.stats[tracker] = {"status": "", "num_request": 0, "num_success": 0, "num_error": 0, "time_request": 0, "time_last_error": 0} last_status = self.stats[tracker]["status"] self.stats[tracker]["status"] = "announcing" self.stats[tracker]["time_request"] = time.time() global_stats[tracker]["time_request"] = time.time() if config.verbose: self.site.log.debug("Tracker announcing to %s (mode: %s)" % (tracker, mode)) if mode == "update": num_want = 10 else: num_want = 30 handler = self.getTrackerHandler(address_parts["protocol"]) error = None try: if handler: peers = handler(address_parts["address"], mode=mode, num_want=num_want) else: raise AnnounceError("Unknown protocol: %s" % address_parts["protocol"]) except Exception as err: self.site.log.warning("Tracker %s announce failed: %s in mode %s" % (tracker, Debug.formatException(err), mode)) error = err if error: self.stats[tracker]["status"] = "error" self.stats[tracker]["time_status"] = time.time() self.stats[tracker]["last_error"] = str(error) self.stats[tracker]["time_last_error"] = time.time() if self.site.connection_server.has_internet: self.stats[tracker]["num_error"] += 1 self.stats[tracker]["num_request"] += 1 global_stats[tracker]["num_request"] += 1 if self.site.connection_server.has_internet: global_stats[tracker]["num_error"] += 1 self.updateWebsocket(tracker="error") return False if peers is None: # Announce skipped self.stats[tracker]["time_status"] = time.time() self.stats[tracker]["status"] = last_status return None self.stats[tracker]["status"] = "announced" self.stats[tracker]["time_status"] = time.time() self.stats[tracker]["num_success"] += 1 self.stats[tracker]["num_request"] += 1 global_stats[tracker]["num_request"] += 1 global_stats[tracker]["num_error"] = 0 if peers is True: # Announce success, but no peers returned return time.time() - s # Adding peers added = 0 for peer in peers: if peer["port"] == 1: # Some trackers does not accept port 0, so we send port 1 as not-connectable peer["port"] = 0 if not peer["port"]: continue # Dont add peers with port 0 if self.site.addPeer(peer["addr"], peer["port"], source="tracker"): added += 1 if added: self.site.worker_manager.onPeers() self.site.updateWebsocket(peers_added=added) if config.verbose: self.site.log.debug( "Tracker result: %s://%s (found %s peers, new: %s, total: %s)" % (address_parts["protocol"], address_parts["address"], len(peers), added, len(self.site.peers)) ) return time.time() - s @util.Noparallel(blocking=False) def announcePex(self, query_num=2, need_num=5): peers = self.site.getConnectedPeers() if len(peers) == 0: # Wait 3s for connections time.sleep(3) peers = self.site.getConnectedPeers() if len(peers) == 0: # Small number of connected peers for this site, connect to any peers = list(self.site.getRecentPeers(20)) need_num = 10 random.shuffle(peers) done = 0 total_added = 0 for peer in peers: num_added = peer.pex(need_num=need_num) if num_added is not False: done += 1 total_added += num_added if num_added: self.site.worker_manager.onPeers() self.site.updateWebsocket(peers_added=num_added) else: time.sleep(0.1) if done == query_num: break self.site.log.debug("Pex result: from %s peers got %s new peers." % (done, total_added)) def updateWebsocket(self, **kwargs): if kwargs: param = {"event": list(kwargs.items())[0]} else: param = None for ws in self.site.websockets: ws.event("announcerChanged", self.site, param) ================================================ FILE: src/Site/SiteManager.py ================================================ import json import logging import re import os import time import atexit import gevent import util from Plugin import PluginManager from Content import ContentDb from Config import config from util import helper from util import RateLimit from util import Cached @PluginManager.acceptPlugins class SiteManager(object): def __init__(self): self.log = logging.getLogger("SiteManager") self.log.debug("SiteManager created.") self.sites = {} self.sites_changed = int(time.time()) self.loaded = False gevent.spawn(self.saveTimer) atexit.register(lambda: self.save(recalculate_size=True)) # Load all sites from data/sites.json @util.Noparallel() def load(self, cleanup=True, startup=False): from Debug import Debug self.log.info("Loading sites... (cleanup: %s, startup: %s)" % (cleanup, startup)) self.loaded = False from .Site import Site address_found = [] added = 0 load_s = time.time() # Load new adresses try: json_path = "%s/sites.json" % config.data_dir data = json.load(open(json_path)) except Exception as err: raise Exception("Unable to load %s: %s" % (json_path, err)) sites_need = [] for address, settings in data.items(): if address not in self.sites: if os.path.isfile("%s/%s/content.json" % (config.data_dir, address)): # Root content.json exists, try load site s = time.time() try: site = Site(address, settings=settings) site.content_manager.contents.get("content.json") except Exception as err: self.log.debug("Error loading site %s: %s" % (address, err)) continue self.sites[address] = site self.log.debug("Loaded site %s in %.3fs" % (address, time.time() - s)) added += 1 elif startup: # No site directory, start download self.log.debug("Found new site in sites.json: %s" % address) sites_need.append([address, settings]) added += 1 address_found.append(address) # Remove deleted adresses if cleanup: for address in list(self.sites.keys()): if address not in address_found: del(self.sites[address]) self.log.debug("Removed site: %s" % address) # Remove orpan sites from contentdb content_db = ContentDb.getContentDb() for row in content_db.execute("SELECT * FROM site").fetchall(): address = row["address"] if address not in self.sites and address not in address_found: self.log.info("Deleting orphan site from content.db: %s" % address) try: content_db.execute("DELETE FROM site WHERE ?", {"address": address}) except Exception as err: self.log.error("Can't delete site %s from content_db: %s" % (address, err)) if address in content_db.site_ids: del content_db.site_ids[address] if address in content_db.sites: del content_db.sites[address] self.loaded = True for address, settings in sites_need: gevent.spawn(self.need, address, settings=settings) if added: self.log.info("Added %s sites in %.3fs" % (added, time.time() - load_s)) def saveDelayed(self): RateLimit.callAsync("Save sites.json", allowed_again=5, func=self.save) def save(self, recalculate_size=False): if not self.sites: self.log.debug("Save skipped: No sites found") return if not self.loaded: self.log.debug("Save skipped: Not loaded") return s = time.time() data = {} # Generate data file s = time.time() for address, site in list(self.list().items()): if recalculate_size: site.settings["size"], site.settings["size_optional"] = site.content_manager.getTotalSize() # Update site size data[address] = site.settings data[address]["cache"] = site.getSettingsCache() time_generate = time.time() - s s = time.time() if data: helper.atomicWrite("%s/sites.json" % config.data_dir, helper.jsonDumps(data).encode("utf8")) else: self.log.debug("Save error: No data") time_write = time.time() - s # Remove cache from site settings for address, site in self.list().items(): site.settings["cache"] = {} self.log.debug("Saved sites in %.2fs (generate: %.2fs, write: %.2fs)" % (time.time() - s, time_generate, time_write)) def saveTimer(self): while 1: time.sleep(60 * 10) self.save(recalculate_size=True) # Checks if its a valid address def isAddress(self, address): return re.match("^[A-Za-z0-9]{26,35}$", address) def isDomain(self, address): return False @Cached(timeout=10) def isDomainCached(self, address): return self.isDomain(address) def resolveDomain(self, domain): return False @Cached(timeout=10) def resolveDomainCached(self, domain): return self.resolveDomain(domain) # Return: Site object or None if not found def get(self, address): if self.isDomainCached(address): address_resolved = self.resolveDomainCached(address) if address_resolved: address = address_resolved if not self.loaded: # Not loaded yet self.log.debug("Loading site: %s)..." % address) self.load() site = self.sites.get(address) return site def add(self, address, all_file=True, settings=None, **kwargs): from .Site import Site self.sites_changed = int(time.time()) # Try to find site with differect case for recover_address, recover_site in list(self.sites.items()): if recover_address.lower() == address.lower(): return recover_site if not self.isAddress(address): return False # Not address: %s % address self.log.debug("Added new site: %s" % address) config.loadTrackersFile() site = Site(address, settings=settings) self.sites[address] = site if not site.settings["serving"]: # Maybe it was deleted before site.settings["serving"] = True site.saveSettings() if all_file: # Also download user files on first sync site.download(check_size=True, blind_includes=True) return site # Return or create site and start download site files def need(self, address, *args, **kwargs): if self.isDomainCached(address): address_resolved = self.resolveDomainCached(address) if address_resolved: address = address_resolved site = self.get(address) if not site: # Site not exist yet site = self.add(address, *args, **kwargs) return site def delete(self, address): self.sites_changed = int(time.time()) self.log.debug("Deleted site: %s" % address) del(self.sites[address]) # Delete from sites.json self.save() # Lazy load sites def list(self): if not self.loaded: # Not loaded yet self.log.debug("Sites not loaded yet...") self.load(startup=True) return self.sites site_manager = SiteManager() # Singletone if config.action == "main": # Don't connect / add myself to peerlist peer_blacklist = [("127.0.0.1", config.fileserver_port), ("::1", config.fileserver_port)] else: peer_blacklist = [] ================================================ FILE: src/Site/SiteStorage.py ================================================ import os import re import shutil import json import time import errno from collections import defaultdict import sqlite3 import gevent.event import util from util import SafeRe from Db.Db import Db from Debug import Debug from Config import config from util import helper from util import ThreadPool from Plugin import PluginManager from Translate import translate as _ thread_pool_fs_read = ThreadPool.ThreadPool(config.threads_fs_read, name="FS read") thread_pool_fs_write = ThreadPool.ThreadPool(config.threads_fs_write, name="FS write") thread_pool_fs_batch = ThreadPool.ThreadPool(1, name="FS batch") @PluginManager.acceptPlugins class SiteStorage(object): def __init__(self, site, allow_create=True): self.site = site self.directory = "%s/%s" % (config.data_dir, self.site.address) # Site data diretory self.allowed_dir = os.path.abspath(self.directory) # Only serve file within this dir self.log = site.log self.db = None # Db class self.db_checked = False # Checked db tables since startup self.event_db_busy = None # Gevent AsyncResult if db is working on rebuild self.has_db = self.isFile("dbschema.json") # The site has schema if not os.path.isdir(self.directory): if allow_create: os.mkdir(self.directory) # Create directory if not found else: raise Exception("Directory not exists: %s" % self.directory) def getDbFile(self): if self.db: return self.db.schema["db_file"] else: if self.isFile("dbschema.json"): schema = self.loadJson("dbschema.json") return schema["db_file"] else: return False # Create new databaseobject with the site's schema def openDb(self, close_idle=False): schema = self.getDbSchema() db_path = self.getPath(schema["db_file"]) return Db(schema, db_path, close_idle=close_idle) def closeDb(self, reason="Unknown (SiteStorage)"): if self.db: self.db.close(reason) self.event_db_busy = None self.db = None def getDbSchema(self): try: self.site.needFile("dbschema.json") schema = self.loadJson("dbschema.json") except Exception as err: raise Exception("dbschema.json is not a valid JSON: %s" % err) return schema def loadDb(self): self.log.debug("No database, waiting for dbschema.json...") self.site.needFile("dbschema.json", priority=3) self.log.debug("Got dbschema.json") self.has_db = self.isFile("dbschema.json") # Recheck if dbschema exist if self.has_db: schema = self.getDbSchema() db_path = self.getPath(schema["db_file"]) if not os.path.isfile(db_path) or os.path.getsize(db_path) == 0: try: self.rebuildDb(reason="Missing database") except Exception as err: self.log.error(err) pass if self.db: self.db.close("Gettig new db for SiteStorage") self.db = self.openDb(close_idle=True) try: changed_tables = self.db.checkTables() if changed_tables: self.rebuildDb(delete_db=False, reason="Changed tables") # TODO: only update the changed table datas except sqlite3.OperationalError: pass # Return db class @util.Noparallel() def getDb(self): if self.event_db_busy: # Db not ready for queries self.log.debug("Wating for db...") self.event_db_busy.get() # Wait for event if not self.db: self.loadDb() return self.db def updateDbFile(self, inner_path, file=None, cur=None): path = self.getPath(inner_path) if cur: db = cur.db else: db = self.getDb() return db.updateJson(path, file, cur) # Return possible db files for the site @thread_pool_fs_read.wrap def getDbFiles(self): found = 0 for content_inner_path, content in self.site.content_manager.contents.items(): # content.json file itself if self.isFile(content_inner_path): yield content_inner_path, self.getPath(content_inner_path) else: self.log.debug("[MISSING] %s" % content_inner_path) # Data files in content.json content_inner_path_dir = helper.getDirname(content_inner_path) # Content.json dir relative to site for file_relative_path in list(content.get("files", {}).keys()) + list(content.get("files_optional", {}).keys()): if not file_relative_path.endswith(".json") and not file_relative_path.endswith("json.gz"): continue # We only interesed in json files file_inner_path = content_inner_path_dir + file_relative_path # File Relative to site dir file_inner_path = file_inner_path.strip("/") # Strip leading / if self.isFile(file_inner_path): yield file_inner_path, self.getPath(file_inner_path) else: self.log.debug("[MISSING] %s" % file_inner_path) found += 1 if found % 100 == 0: time.sleep(0.001) # Context switch to avoid UI block # Rebuild sql cache @util.Noparallel() @thread_pool_fs_batch.wrap def rebuildDb(self, delete_db=True, reason="Unknown"): self.log.info("Rebuilding db (reason: %s)..." % reason) self.has_db = self.isFile("dbschema.json") if not self.has_db: return False schema = self.loadJson("dbschema.json") db_path = self.getPath(schema["db_file"]) if os.path.isfile(db_path) and delete_db: if self.db: self.closeDb("rebuilding") # Close db if open time.sleep(0.5) self.log.info("Deleting %s" % db_path) try: os.unlink(db_path) except Exception as err: self.log.error("Delete error: %s" % err) if not self.db: self.db = self.openDb() self.event_db_busy = gevent.event.AsyncResult() self.log.info("Rebuild: Creating tables...") # raise DbTableError if not valid self.db.checkTables() cur = self.db.getCursor() cur.logging = False s = time.time() self.log.info("Rebuild: Getting db files...") db_files = list(self.getDbFiles()) num_imported = 0 num_total = len(db_files) num_error = 0 self.log.info("Rebuild: Importing data...") try: if num_total > 100: self.site.messageWebsocket( _["Database rebuilding...
    Imported {0} of {1} files (error: {2})..."].format( "0000", num_total, num_error ), "rebuild", 0 ) for file_inner_path, file_path in db_files: try: if self.updateDbFile(file_inner_path, file=open(file_path, "rb"), cur=cur): num_imported += 1 except Exception as err: self.log.error("Error importing %s: %s" % (file_inner_path, Debug.formatException(err))) num_error += 1 if num_imported and num_imported % 100 == 0: self.site.messageWebsocket( _["Database rebuilding...
    Imported {0} of {1} files (error: {2})..."].format( num_imported, num_total, num_error ), "rebuild", int(float(num_imported) / num_total * 100) ) time.sleep(0.001) # Context switch to avoid UI block finally: cur.close() if num_total > 100: self.site.messageWebsocket( _["Database rebuilding...
    Imported {0} of {1} files (error: {2})..."].format( num_imported, num_total, num_error ), "rebuild", 100 ) self.log.info("Rebuild: Imported %s data file in %.3fs" % (num_imported, time.time() - s)) self.event_db_busy.set(True) # Event done, notify waiters self.event_db_busy = None # Clear event self.db.commit("Rebuilt") return True # Execute sql query or rebuild on dberror def query(self, query, params=None): if not query.strip().upper().startswith("SELECT"): raise Exception("Only SELECT query supported") try: res = self.getDb().execute(query, params) except sqlite3.DatabaseError as err: if err.__class__.__name__ == "DatabaseError": self.log.error("Database error: %s, query: %s, try to rebuilding it..." % (err, query)) try: self.rebuildDb(reason="Query error") except sqlite3.OperationalError: pass res = self.db.cur.execute(query, params) else: raise err return res def ensureDir(self, inner_path): try: os.makedirs(self.getPath(inner_path)) except OSError as err: if err.errno == errno.EEXIST: return False else: raise err return True # Open file object def open(self, inner_path, mode="rb", create_dirs=False, **kwargs): file_path = self.getPath(inner_path) if create_dirs: file_inner_dir = os.path.dirname(inner_path) self.ensureDir(file_inner_dir) return open(file_path, mode, **kwargs) # Open file object @thread_pool_fs_read.wrap def read(self, inner_path, mode="rb"): return open(self.getPath(inner_path), mode).read() @thread_pool_fs_write.wrap def writeThread(self, inner_path, content): file_path = self.getPath(inner_path) # Create dir if not exist self.ensureDir(os.path.dirname(inner_path)) # Write file if hasattr(content, 'read'): # File-like object with open(file_path, "wb") as file: shutil.copyfileobj(content, file) # Write buff to disk else: # Simple string if inner_path == "content.json" and os.path.isfile(file_path): helper.atomicWrite(file_path, content) else: with open(file_path, "wb") as file: file.write(content) # Write content to file def write(self, inner_path, content): self.writeThread(inner_path, content) self.onUpdated(inner_path) # Remove file from filesystem def delete(self, inner_path): file_path = self.getPath(inner_path) os.unlink(file_path) self.onUpdated(inner_path, file=False) def deleteDir(self, inner_path): dir_path = self.getPath(inner_path) os.rmdir(dir_path) def rename(self, inner_path_before, inner_path_after): for retry in range(3): rename_err = None # To workaround "The process cannot access the file beacause it is being used by another process." error try: os.rename(self.getPath(inner_path_before), self.getPath(inner_path_after)) break except Exception as err: rename_err = err self.log.error("%s rename error: %s (retry #%s)" % (inner_path_before, err, retry)) time.sleep(0.1 + retry) if rename_err: raise rename_err # List files from a directory @thread_pool_fs_read.wrap def walk(self, dir_inner_path, ignore=None): directory = self.getPath(dir_inner_path) for root, dirs, files in os.walk(directory): root = root.replace("\\", "/") root_relative_path = re.sub("^%s" % re.escape(directory), "", root).lstrip("/") for file_name in files: if root_relative_path: # Not root dir file_relative_path = root_relative_path + "/" + file_name else: file_relative_path = file_name if ignore and SafeRe.match(ignore, file_relative_path): continue yield file_relative_path # Don't scan directory that is in the ignore pattern if ignore: dirs_filtered = [] for dir_name in dirs: if root_relative_path: dir_relative_path = root_relative_path + "/" + dir_name else: dir_relative_path = dir_name if ignore == ".*" or re.match(".*([|(]|^)%s([|)]|$)" % re.escape(dir_relative_path + "/.*"), ignore): continue dirs_filtered.append(dir_name) dirs[:] = dirs_filtered # list directories in a directory @thread_pool_fs_read.wrap def list(self, dir_inner_path): directory = self.getPath(dir_inner_path) return os.listdir(directory) # Site content updated def onUpdated(self, inner_path, file=None): # Update Sql cache should_load_to_db = inner_path.endswith(".json") or inner_path.endswith(".json.gz") if inner_path == "dbschema.json": self.has_db = self.isFile("dbschema.json") # Reopen DB to check changes if self.has_db: self.closeDb("New dbschema") gevent.spawn(self.getDb) elif not config.disable_db and should_load_to_db and self.has_db: # Load json file to db if config.verbose: self.log.debug("Loading json file to db: %s (file: %s)" % (inner_path, file)) try: self.updateDbFile(inner_path, file) except Exception as err: self.log.error("Json %s load error: %s" % (inner_path, Debug.formatException(err))) self.closeDb("Json load error") # Load and parse json file @thread_pool_fs_read.wrap def loadJson(self, inner_path): with self.open(inner_path, "r", encoding="utf8") as file: return json.load(file) # Write formatted json file def writeJson(self, inner_path, data): # Write to disk self.write(inner_path, helper.jsonDumps(data).encode("utf8")) # Get file size def getSize(self, inner_path): path = self.getPath(inner_path) try: return os.path.getsize(path) except Exception: return 0 # File exist def isFile(self, inner_path): return os.path.isfile(self.getPath(inner_path)) # File or directory exist def isExists(self, inner_path): return os.path.exists(self.getPath(inner_path)) # Dir exist def isDir(self, inner_path): return os.path.isdir(self.getPath(inner_path)) # Security check and return path of site's file def getPath(self, inner_path): inner_path = inner_path.replace("\\", "/") # Windows separator fix if not inner_path: return self.directory if "../" in inner_path: raise Exception("File not allowed: %s" % inner_path) return "%s/%s" % (self.directory, inner_path) # Get site dir relative path def getInnerPath(self, path): if path == self.directory: inner_path = "" else: if path.startswith(self.directory): inner_path = path[len(self.directory) + 1:] else: raise Exception("File not allowed: %s" % path) return inner_path # Verify all files sha512sum using content.json def verifyFiles(self, quick_check=False, add_optional=False, add_changed=True): bad_files = [] back = defaultdict(int) back["bad_files"] = bad_files i = 0 self.log.debug("Verifing files...") if not self.site.content_manager.contents.get("content.json"): # No content.json, download it first self.log.debug("VerifyFile content.json not exists") self.site.needFile("content.json", update=True) # Force update to fix corrupt file self.site.content_manager.loadContent() # Reload content.json for content_inner_path, content in list(self.site.content_manager.contents.items()): back["num_content"] += 1 i += 1 if i % 50 == 0: time.sleep(0.001) # Context switch to avoid gevent hangs if not os.path.isfile(self.getPath(content_inner_path)): # Missing content.json file back["num_content_missing"] += 1 self.log.debug("[MISSING] %s" % content_inner_path) bad_files.append(content_inner_path) for file_relative_path in list(content.get("files", {}).keys()): back["num_file"] += 1 file_inner_path = helper.getDirname(content_inner_path) + file_relative_path # Relative to site dir file_inner_path = file_inner_path.strip("/") # Strip leading / file_path = self.getPath(file_inner_path) if not os.path.isfile(file_path): back["num_file_missing"] += 1 self.log.debug("[MISSING] %s" % file_inner_path) bad_files.append(file_inner_path) continue if quick_check: ok = os.path.getsize(file_path) == content["files"][file_relative_path]["size"] if not ok: err = "Invalid size" else: try: ok = self.site.content_manager.verifyFile(file_inner_path, open(file_path, "rb")) except Exception as err: ok = False if not ok: back["num_file_invalid"] += 1 self.log.debug("[INVALID] %s: %s" % (file_inner_path, err)) if add_changed or content.get("cert_user_id"): # If updating own site only add changed user files bad_files.append(file_inner_path) # Optional files optional_added = 0 optional_removed = 0 for file_relative_path in list(content.get("files_optional", {}).keys()): back["num_optional"] += 1 file_node = content["files_optional"][file_relative_path] file_inner_path = helper.getDirname(content_inner_path) + file_relative_path # Relative to site dir file_inner_path = file_inner_path.strip("/") # Strip leading / file_path = self.getPath(file_inner_path) hash_id = self.site.content_manager.hashfield.getHashId(file_node["sha512"]) if not os.path.isfile(file_path): if self.site.content_manager.isDownloaded(file_inner_path, hash_id): back["num_optional_removed"] += 1 self.log.debug("[OPTIONAL MISSING] %s" % file_inner_path) self.site.content_manager.optionalRemoved(file_inner_path, hash_id, file_node["size"]) if add_optional and self.site.isDownloadable(file_inner_path): self.log.debug("[OPTIONAL ADDING] %s" % file_inner_path) bad_files.append(file_inner_path) continue if quick_check: ok = os.path.getsize(file_path) == content["files_optional"][file_relative_path]["size"] else: try: ok = self.site.content_manager.verifyFile(file_inner_path, open(file_path, "rb")) except Exception as err: ok = False if ok: if not self.site.content_manager.isDownloaded(file_inner_path, hash_id): back["num_optional_added"] += 1 self.site.content_manager.optionalDownloaded(file_inner_path, hash_id, file_node["size"]) optional_added += 1 self.log.debug("[OPTIONAL FOUND] %s" % file_inner_path) else: if self.site.content_manager.isDownloaded(file_inner_path, hash_id): back["num_optional_removed"] += 1 self.site.content_manager.optionalRemoved(file_inner_path, hash_id, file_node["size"]) optional_removed += 1 bad_files.append(file_inner_path) self.log.debug("[OPTIONAL CHANGED] %s" % file_inner_path) if config.verbose: self.log.debug( "%s verified: %s, quick: %s, optionals: +%s -%s" % (content_inner_path, len(content["files"]), quick_check, optional_added, optional_removed) ) self.site.content_manager.contents.db.processDelayed() time.sleep(0.001) # Context switch to avoid gevent hangs return back # Check and try to fix site files integrity def updateBadFiles(self, quick_check=True): s = time.time() res = self.verifyFiles( quick_check, add_optional=True, add_changed=not self.site.settings.get("own") # Don't overwrite changed files if site owned ) bad_files = res["bad_files"] self.site.bad_files = {} if bad_files: for bad_file in bad_files: self.site.bad_files[bad_file] = 1 self.log.debug("Checked files in %.2fs... Found bad files: %s, Quick:%s" % (time.time() - s, len(bad_files), quick_check)) # Delete site's all file @thread_pool_fs_batch.wrap def deleteFiles(self): site_title = self.site.content_manager.contents.get("content.json", {}).get("title", self.site.address) message_id = "delete-%s" % self.site.address self.log.debug("Deleting files from content.json (title: %s)..." % site_title) files = [] # Get filenames content_inner_paths = list(self.site.content_manager.contents.keys()) for i, content_inner_path in enumerate(content_inner_paths): content = self.site.content_manager.contents.get(content_inner_path, {}) files.append(content_inner_path) # Add normal files for file_relative_path in list(content.get("files", {}).keys()): file_inner_path = helper.getDirname(content_inner_path) + file_relative_path # Relative to site dir files.append(file_inner_path) # Add optional files for file_relative_path in list(content.get("files_optional", {}).keys()): file_inner_path = helper.getDirname(content_inner_path) + file_relative_path # Relative to site dir files.append(file_inner_path) if i % 100 == 0: num_files = len(files) self.site.messageWebsocket( _("Deleting site {site_title}...
    Collected {num_files} files"), message_id, (i / len(content_inner_paths)) * 25 ) if self.isFile("dbschema.json"): self.log.debug("Deleting db file...") self.closeDb("Deleting site") self.has_db = False try: schema = self.loadJson("dbschema.json") db_path = self.getPath(schema["db_file"]) if os.path.isfile(db_path): os.unlink(db_path) except Exception as err: self.log.error("Db file delete error: %s" % err) num_files = len(files) for i, inner_path in enumerate(files): path = self.getPath(inner_path) if os.path.isfile(path): for retry in range(5): try: os.unlink(path) break except Exception as err: self.log.error("Error removing %s: %s, try #%s" % (inner_path, err, retry)) time.sleep(float(retry) / 10) if i % 100 == 0: self.site.messageWebsocket( _("Deleting site {site_title}...
    Deleting file {i}/{num_files}"), message_id, 25 + (i / num_files) * 50 ) self.onUpdated(inner_path, False) self.log.debug("Deleting empty dirs...") i = 0 for root, dirs, files in os.walk(self.directory, topdown=False): for dir in dirs: path = os.path.join(root, dir) if os.path.isdir(path): try: i += 1 if i % 100 == 0: self.site.messageWebsocket( _("Deleting site {site_title}...
    Deleting empty directories {i}"), message_id, 85 ) os.rmdir(path) except OSError: # Not empty pass if os.path.isdir(self.directory) and os.listdir(self.directory) == []: os.rmdir(self.directory) # Remove sites directory if empty if os.path.isdir(self.directory): self.log.debug("Some unknown file remained in site data dir: %s..." % self.directory) self.site.messageWebsocket( _("Deleting site {site_title}...
    Site deleted, but some unknown files left in the directory"), message_id, 100 ) return False # Some files not deleted else: self.log.debug("Site %s data directory deleted: %s..." % (site_title, self.directory)) self.site.messageWebsocket( _("Deleting site {site_title}...
    All files deleted successfully"), message_id, 100 ) return True # All clean ================================================ FILE: src/Site/__init__.py ================================================ ================================================ FILE: src/Test/BenchmarkSsl.py ================================================ #!/usr/bin/python2 from gevent import monkey monkey.patch_all() import os import time import sys import socket import ssl sys.path.append(os.path.abspath("..")) # Imports relative to src dir import io as StringIO import gevent from gevent.server import StreamServer from gevent.pool import Pool from Config import config config.parse() from util import SslPatch # Server socks = [] data = os.urandom(1024 * 100) data += "\n" def handle(sock_raw, addr): socks.append(sock_raw) sock = sock_raw # sock = ctx.wrap_socket(sock, server_side=True) # if sock_raw.recv( 1, gevent.socket.MSG_PEEK ) == "\x16": # sock = gevent.ssl.wrap_socket(sock_raw, server_side=True, keyfile='key-cz.pem', # certfile='cert-cz.pem', ciphers=ciphers, ssl_version=ssl.PROTOCOL_TLSv1) # fp = os.fdopen(sock.fileno(), 'rb', 1024*512) try: while True: line = sock.recv(16 * 1024) if not line: break if line == "bye\n": break elif line == "gotssl\n": sock.sendall("yes\n") sock = gevent.ssl.wrap_socket( sock_raw, server_side=True, keyfile='../../data/key-rsa.pem', certfile='../../data/cert-rsa.pem', ciphers=ciphers, ssl_version=ssl.PROTOCOL_TLSv1 ) else: sock.sendall(data) except Exception as err: print(err) try: sock.shutdown(gevent.socket.SHUT_WR) sock.close() except: pass socks.remove(sock_raw) pool = Pool(1000) # do not accept more than 10000 connections server = StreamServer(('127.0.0.1', 1234), handle) server.start() # Client total_num = 0 total_bytes = 0 clipher = None ciphers = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDH+AES128:ECDHE-RSA-AES128-GCM-SHA256:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:HIGH:" + \ "!aNULL:!eNULL:!EXPORT:!DSS:!DES:!RC4:!3DES:!MD5:!PSK" # ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) def getData(): global total_num, total_bytes, clipher data = None sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # sock = socket.ssl(s) # sock = ssl.wrap_socket(sock) sock.connect(("127.0.0.1", 1234)) # sock.do_handshake() # clipher = sock.cipher() sock.send("gotssl\n") if sock.recv(128) == "yes\n": sock = ssl.wrap_socket(sock, ciphers=ciphers, ssl_version=ssl.PROTOCOL_TLSv1) sock.do_handshake() clipher = sock.cipher() for req in range(20): sock.sendall("req\n") buff = StringIO.StringIO() data = sock.recv(16 * 1024) buff.write(data) if not data: break while not data.endswith("\n"): data = sock.recv(16 * 1024) if not data: break buff.write(data) total_num += 1 total_bytes += buff.tell() if not data: print("No data") sock.shutdown(gevent.socket.SHUT_WR) sock.close() s = time.time() def info(): import psutil import os process = psutil.Process(os.getpid()) if "memory_info" in dir(process): memory_info = process.memory_info else: memory_info = process.get_memory_info while 1: print(total_num, "req", (total_bytes / 1024), "kbytes", "transfered in", time.time() - s, end=' ') print("using", clipher, "Mem:", memory_info()[0] / float(2 ** 20)) time.sleep(1) gevent.spawn(info) for test in range(1): clients = [] for i in range(500): # Thread clients.append(gevent.spawn(getData)) gevent.joinall(clients) print(total_num, "req", (total_bytes / 1024), "kbytes", "transfered in", time.time() - s) # Separate client/server process: # 10*10*100: # Raw: 10000 req 1000009 kbytes transfered in 5.39999985695 # RSA 2048: 10000 req 1000009 kbytes transfered in 27.7890000343 using ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256) # ECC: 10000 req 1000009 kbytes transfered in 26.1959998608 using ('ECDHE-ECDSA-AES256-SHA', 'TLSv1/SSLv3', 256) # ECC: 10000 req 1000009 kbytes transfered in 28.2410001755 using ('ECDHE-ECDSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256) Mem: 13.3828125 # # 10*100*10: # Raw: 10000 req 1000009 kbytes transfered in 7.02700018883 Mem: 14.328125 # RSA 2048: 10000 req 1000009 kbytes transfered in 44.8860001564 using ('ECDHE-RSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256) Mem: 20.078125 # ECC: 10000 req 1000009 kbytes transfered in 37.9430000782 using ('ECDHE-ECDSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256) Mem: 20.0234375 # # 1*100*100: # Raw: 10000 req 1000009 kbytes transfered in 4.64400005341 Mem: 14.06640625 # RSA: 10000 req 1000009 kbytes transfered in 24.2300000191 using ('ECDHE-RSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256) Mem: 19.7734375 # ECC: 10000 req 1000009 kbytes transfered in 22.8849999905 using ('ECDHE-ECDSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256) Mem: 17.8125 # AES128: 10000 req 1000009 kbytes transfered in 21.2839999199 using ('AES128-GCM-SHA256', 'TLSv1/SSLv3', 128) Mem: 14.1328125 # ECC+128: 10000 req 1000009 kbytes transfered in 20.496999979 using ('ECDHE-ECDSA-AES128-GCM-SHA256', 'TLSv1/SSLv3', 128) Mem: 14.40234375 # # # Single process: # 1*100*100 # RSA: 10000 req 1000009 kbytes transfered in 41.7899999619 using ('ECDHE-RSA-AES128-GCM-SHA256', 'TLSv1/SSLv3', 128) Mem: 26.91015625 # # 10*10*100 # RSA: 10000 req 1000009 kbytes transfered in 40.1640000343 using ('ECDHE-RSA-AES128-GCM-SHA256', 'TLSv1/SSLv3', 128) Mem: 14.94921875 ================================================ FILE: src/Test/Spy.py ================================================ import logging class Spy: def __init__(self, obj, func_name): self.obj = obj self.__name__ = func_name self.func_original = getattr(self.obj, func_name) self.calls = [] def __enter__(self, *args, **kwargs): logging.debug("Spy started") def loggedFunc(cls, *args, **kwargs): call = dict(enumerate(args, 1)) call[0] = cls call.update(kwargs) logging.debug("Spy call: %s" % call) self.calls.append(call) return self.func_original(cls, *args, **kwargs) setattr(self.obj, self.__name__, loggedFunc) return self.calls def __exit__(self, *args, **kwargs): setattr(self.obj, self.__name__, self.func_original) ================================================ FILE: src/Test/TestCached.py ================================================ import time from util import Cached class CachedObject: def __init__(self): self.num_called_add = 0 self.num_called_multiply = 0 self.num_called_none = 0 @Cached(timeout=1) def calcAdd(self, a, b): self.num_called_add += 1 return a + b @Cached(timeout=1) def calcMultiply(self, a, b): self.num_called_multiply += 1 return a * b @Cached(timeout=1) def none(self): self.num_called_none += 1 return None class TestCached: def testNoneValue(self): cached_object = CachedObject() assert cached_object.none() is None assert cached_object.none() is None assert cached_object.num_called_none == 1 time.sleep(2) assert cached_object.none() is None assert cached_object.num_called_none == 2 def testCall(self): cached_object = CachedObject() assert cached_object.calcAdd(1, 2) == 3 assert cached_object.calcAdd(1, 2) == 3 assert cached_object.calcMultiply(1, 2) == 2 assert cached_object.calcMultiply(1, 2) == 2 assert cached_object.num_called_add == 1 assert cached_object.num_called_multiply == 1 assert cached_object.calcAdd(2, 3) == 5 assert cached_object.calcAdd(2, 3) == 5 assert cached_object.num_called_add == 2 assert cached_object.calcAdd(1, 2) == 3 assert cached_object.calcMultiply(2, 3) == 6 assert cached_object.num_called_add == 2 assert cached_object.num_called_multiply == 2 time.sleep(2) assert cached_object.calcAdd(1, 2) == 3 assert cached_object.num_called_add == 3 ================================================ FILE: src/Test/TestConfig.py ================================================ import pytest import Config @pytest.mark.usefixtures("resetSettings") class TestConfig: def testParse(self): # Defaults config_test = Config.Config("zeronet.py".split(" ")) config_test.parse(silent=True, parse_config=False) assert not config_test.debug assert not config_test.debug_socket # Test parse command line with unknown parameters (ui_password) config_test = Config.Config("zeronet.py --debug --debug_socket --ui_password hello".split(" ")) config_test.parse(silent=True, parse_config=False) assert config_test.debug assert config_test.debug_socket with pytest.raises(AttributeError): config_test.ui_password # More complex test args = "zeronet.py --unknown_arg --debug --debug_socket --ui_restrict 127.0.0.1 1.2.3.4 " args += "--another_unknown argument --use_openssl False siteSign address privatekey --inner_path users/content.json" config_test = Config.Config(args.split(" ")) config_test.parse(silent=True, parse_config=False) assert config_test.debug assert "1.2.3.4" in config_test.ui_restrict assert not config_test.use_openssl assert config_test.inner_path == "users/content.json" ================================================ FILE: src/Test/TestConnectionServer.py ================================================ import time import socket import gevent import pytest import mock from Crypt import CryptConnection from Connection import ConnectionServer from Config import config @pytest.mark.usefixtures("resetSettings") class TestConnection: def testIpv6(self, file_server6): assert ":" in file_server6.ip client = ConnectionServer(file_server6.ip, 1545) connection = client.getConnection(file_server6.ip, 1544) assert connection.ping() # Close connection connection.close() client.stop() time.sleep(0.01) assert len(file_server6.connections) == 0 # Should not able to reach on ipv4 ip with pytest.raises(socket.error) as err: client = ConnectionServer("127.0.0.1", 1545) connection = client.getConnection("127.0.0.1", 1544) def testSslConnection(self, file_server): client = ConnectionServer(file_server.ip, 1545) assert file_server != client # Connect to myself with mock.patch('Config.config.ip_local', return_value=[]): # SSL not used for local ips connection = client.getConnection(file_server.ip, 1544) assert len(file_server.connections) == 1 assert connection.handshake assert connection.crypt # Close connection connection.close("Test ended") client.stop() time.sleep(0.1) assert len(file_server.connections) == 0 assert file_server.num_incoming == 2 # One for file_server fixture, one for the test def testRawConnection(self, file_server): client = ConnectionServer(file_server.ip, 1545) assert file_server != client # Remove all supported crypto crypt_supported_bk = CryptConnection.manager.crypt_supported CryptConnection.manager.crypt_supported = [] with mock.patch('Config.config.ip_local', return_value=[]): # SSL not used for local ips connection = client.getConnection(file_server.ip, 1544) assert len(file_server.connections) == 1 assert not connection.crypt # Close connection connection.close() client.stop() time.sleep(0.01) assert len(file_server.connections) == 0 # Reset supported crypts CryptConnection.manager.crypt_supported = crypt_supported_bk def testPing(self, file_server, site): client = ConnectionServer(file_server.ip, 1545) connection = client.getConnection(file_server.ip, 1544) assert connection.ping() connection.close() client.stop() def testGetConnection(self, file_server): client = ConnectionServer(file_server.ip, 1545) connection = client.getConnection(file_server.ip, 1544) # Get connection by ip/port connection2 = client.getConnection(file_server.ip, 1544) assert connection == connection2 # Get connection by peerid assert not client.getConnection(file_server.ip, 1544, peer_id="notexists", create=False) connection2 = client.getConnection(file_server.ip, 1544, peer_id=connection.handshake["peer_id"], create=False) assert connection2 == connection connection.close() client.stop() def testFloodProtection(self, file_server): whitelist = file_server.whitelist # Save for reset file_server.whitelist = [] # Disable 127.0.0.1 whitelist client = ConnectionServer(file_server.ip, 1545) # Only allow 6 connection in 1 minute for reconnect in range(6): connection = client.getConnection(file_server.ip, 1544) assert connection.handshake connection.close() # The 7. one will timeout with pytest.raises(gevent.Timeout): with gevent.Timeout(0.1): connection = client.getConnection(file_server.ip, 1544) # Reset whitelist file_server.whitelist = whitelist ================================================ FILE: src/Test/TestContent.py ================================================ import json import time import io import pytest from Crypt import CryptBitcoin from Content.ContentManager import VerifyError, SignError from util.SafeRe import UnsafePatternError @pytest.mark.usefixtures("resetSettings") class TestContent: privatekey = "5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv" def testInclude(self, site): # Rules defined in parent content.json rules = site.content_manager.getRules("data/test_include/content.json") assert rules["signers"] == ["15ik6LeBWnACWfaika1xqGapRZ1zh3JpCo"] # Valid signer assert rules["user_name"] == "test" # Extra data assert rules["max_size"] == 20000 # Max size of files assert not rules["includes_allowed"] # Don't allow more includes assert rules["files_allowed"] == "data.json" # Allowed file pattern # Valid signers for "data/test_include/content.json" valid_signers = site.content_manager.getValidSigners("data/test_include/content.json") assert "15ik6LeBWnACWfaika1xqGapRZ1zh3JpCo" in valid_signers # Extra valid signer defined in parent content.json assert "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT" in valid_signers # The site itself assert len(valid_signers) == 2 # No more # Valid signers for "data/users/content.json" valid_signers = site.content_manager.getValidSigners("data/users/content.json") assert "1LSxsKfC9S9TVXGGNSM3vPHjyW82jgCX5f" in valid_signers # Extra valid signer defined in parent content.json assert "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT" in valid_signers # The site itself assert len(valid_signers) == 2 # Valid signers for root content.json assert site.content_manager.getValidSigners("content.json") == ["1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT"] def testInlcudeLimits(self, site, crypt_bitcoin_lib): # Data validation res = [] data_dict = { "files": { "data.json": { "sha512": "369d4e780cc80504285f13774ca327fe725eed2d813aad229e62356b07365906", "size": 505 } }, "modified": time.time() } # Normal data data_dict["signs"] = {"1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), self.privatekey)} data_json = json.dumps(data_dict).encode() data = io.BytesIO(data_json) assert site.content_manager.verifyFile("data/test_include/content.json", data, ignore_same=False) # Reset del data_dict["signs"] # Too large data_dict["files"]["data.json"]["size"] = 200000 # Emulate 2MB sized data.json data_dict["signs"] = {"1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), self.privatekey)} data = io.BytesIO(json.dumps(data_dict).encode()) with pytest.raises(VerifyError) as err: site.content_manager.verifyFile("data/test_include/content.json", data, ignore_same=False) assert "Include too large" in str(err.value) # Reset data_dict["files"]["data.json"]["size"] = 505 del data_dict["signs"] # Not allowed file data_dict["files"]["notallowed.exe"] = data_dict["files"]["data.json"] data_dict["signs"] = {"1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), self.privatekey)} data = io.BytesIO(json.dumps(data_dict).encode()) with pytest.raises(VerifyError) as err: site.content_manager.verifyFile("data/test_include/content.json", data, ignore_same=False) assert "File not allowed" in str(err.value) # Reset del data_dict["files"]["notallowed.exe"] del data_dict["signs"] # Should work again data_dict["signs"] = {"1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), self.privatekey)} data = io.BytesIO(json.dumps(data_dict).encode()) assert site.content_manager.verifyFile("data/test_include/content.json", data, ignore_same=False) @pytest.mark.parametrize("inner_path", ["content.json", "data/test_include/content.json", "data/users/content.json"]) def testSign(self, site, inner_path): # Bad privatekey with pytest.raises(SignError) as err: site.content_manager.sign(inner_path, privatekey="5aaa3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMnaa", filewrite=False) assert "Private key invalid" in str(err.value) # Good privatekey content = site.content_manager.sign(inner_path, privatekey=self.privatekey, filewrite=False) content_old = site.content_manager.contents[inner_path] # Content before the sign assert not content_old == content # Timestamp changed assert site.address in content["signs"] # Used the site's private key to sign if inner_path == "content.json": assert len(content["files"]) == 17 elif inner_path == "data/test-include/content.json": assert len(content["files"]) == 1 elif inner_path == "data/users/content.json": assert len(content["files"]) == 0 # Everything should be same as before except the modified timestamp and the signs assert ( {key: val for key, val in content_old.items() if key not in ["modified", "signs", "sign", "zeronet_version"]} == {key: val for key, val in content.items() if key not in ["modified", "signs", "sign", "zeronet_version"]} ) def testSignOptionalFiles(self, site): for hash in list(site.content_manager.hashfield): site.content_manager.hashfield.remove(hash) assert len(site.content_manager.hashfield) == 0 site.content_manager.contents["content.json"]["optional"] = "((data/img/zero.*))" content_optional = site.content_manager.sign(privatekey=self.privatekey, filewrite=False, remove_missing_optional=True) del site.content_manager.contents["content.json"]["optional"] content_nooptional = site.content_manager.sign(privatekey=self.privatekey, filewrite=False, remove_missing_optional=True) assert len(content_nooptional.get("files_optional", {})) == 0 # No optional files if no pattern assert len(content_optional["files_optional"]) > 0 assert len(site.content_manager.hashfield) == len(content_optional["files_optional"]) # Hashed optional files should be added to hashfield assert len(content_nooptional["files"]) > len(content_optional["files"]) def testFileInfo(self, site): assert "sha512" in site.content_manager.getFileInfo("index.html") assert site.content_manager.getFileInfo("data/img/domain.png")["content_inner_path"] == "content.json" assert site.content_manager.getFileInfo("data/users/hello.png")["content_inner_path"] == "data/users/content.json" assert site.content_manager.getFileInfo("data/users/content.json")["content_inner_path"] == "data/users/content.json" assert not site.content_manager.getFileInfo("notexist") # Optional file file_info_optional = site.content_manager.getFileInfo("data/optional.txt") assert "sha512" in file_info_optional assert file_info_optional["optional"] is True # Not exists yet user content.json assert "cert_signers" in site.content_manager.getFileInfo("data/users/unknown/content.json") # Optional user file file_info_optional = site.content_manager.getFileInfo("data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/peanut-butter-jelly-time.gif") assert "sha512" in file_info_optional assert file_info_optional["optional"] is True def testVerify(self, site, crypt_bitcoin_lib): inner_path = "data/test_include/content.json" data_dict = site.storage.loadJson(inner_path) data = io.BytesIO(json.dumps(data_dict).encode("utf8")) # Re-sign data_dict["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), self.privatekey) } assert site.content_manager.verifyFile(inner_path, data, ignore_same=False) # Wrong address data_dict["address"] = "Othersite" del data_dict["signs"] data_dict["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), self.privatekey) } data = io.BytesIO(json.dumps(data_dict).encode()) with pytest.raises(VerifyError) as err: site.content_manager.verifyFile(inner_path, data, ignore_same=False) assert "Wrong site address" in str(err.value) # Wrong inner_path data_dict["address"] = "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT" data_dict["inner_path"] = "content.json" del data_dict["signs"] data_dict["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), self.privatekey) } data = io.BytesIO(json.dumps(data_dict).encode()) with pytest.raises(VerifyError) as err: site.content_manager.verifyFile(inner_path, data, ignore_same=False) assert "Wrong inner_path" in str(err.value) # Everything right again data_dict["address"] = "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT" data_dict["inner_path"] = inner_path del data_dict["signs"] data_dict["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), self.privatekey) } data = io.BytesIO(json.dumps(data_dict).encode()) assert site.content_manager.verifyFile(inner_path, data, ignore_same=False) def testVerifyInnerPath(self, site, crypt_bitcoin_lib): inner_path = "content.json" data_dict = site.storage.loadJson(inner_path) for good_relative_path in ["data.json", "out/data.json", "Any File [by none] (1).jpg", "árvzítűrő/tükörfúrógép.txt"]: data_dict["files"] = {good_relative_path: {"sha512": "369d4e780cc80504285f13774ca327fe725eed2d813aad229e62356b07365906", "size": 505}} if "sign" in data_dict: del data_dict["sign"] del data_dict["signs"] data_dict["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), self.privatekey) } data = io.BytesIO(json.dumps(data_dict).encode()) assert site.content_manager.verifyFile(inner_path, data, ignore_same=False) for bad_relative_path in ["../data.json", "data/" * 100, "invalid|file.jpg", "con.txt", "any/con.txt"]: data_dict["files"] = {bad_relative_path: {"sha512": "369d4e780cc80504285f13774ca327fe725eed2d813aad229e62356b07365906", "size": 505}} if "sign" in data_dict: del data_dict["sign"] del data_dict["signs"] data_dict["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), self.privatekey) } data = io.BytesIO(json.dumps(data_dict).encode()) with pytest.raises(VerifyError) as err: site.content_manager.verifyFile(inner_path, data, ignore_same=False) assert "Invalid relative path" in str(err.value) @pytest.mark.parametrize("key", ["ignore", "optional"]) def testSignUnsafePattern(self, site, key): site.content_manager.contents["content.json"][key] = "([a-zA-Z]+)*" with pytest.raises(UnsafePatternError) as err: site.content_manager.sign("content.json", privatekey=self.privatekey, filewrite=False) assert "Potentially unsafe" in str(err.value) def testVerifyUnsafePattern(self, site, crypt_bitcoin_lib): site.content_manager.contents["content.json"]["includes"]["data/test_include/content.json"]["files_allowed"] = "([a-zA-Z]+)*" with pytest.raises(UnsafePatternError) as err: with site.storage.open("data/test_include/content.json") as data: site.content_manager.verifyFile("data/test_include/content.json", data, ignore_same=False) assert "Potentially unsafe" in str(err.value) site.content_manager.contents["data/users/content.json"]["user_contents"]["permission_rules"]["([a-zA-Z]+)*"] = {"max_size": 0} with pytest.raises(UnsafePatternError) as err: with site.storage.open("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json") as data: site.content_manager.verifyFile("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json", data, ignore_same=False) assert "Potentially unsafe" in str(err.value) def testPathValidation(self, site): assert site.content_manager.isValidRelativePath("test.txt") assert site.content_manager.isValidRelativePath("test/!@#$%^&().txt") assert site.content_manager.isValidRelativePath("ÜøßÂŒƂÆÇ.txt") assert site.content_manager.isValidRelativePath("тест.текст") assert site.content_manager.isValidRelativePath("𝐮𝐧𝐢𝐜𝐨𝐝𝐞𝑖𝑠𝒂𝒘𝒆𝒔𝒐𝒎𝒆") # Test rules based on https://stackoverflow.com/questions/1976007/what-characters-are-forbidden-in-windows-and-linux-directory-names assert not site.content_manager.isValidRelativePath("any\\hello.txt") # \ not allowed assert not site.content_manager.isValidRelativePath("/hello.txt") # Cannot start with / assert not site.content_manager.isValidRelativePath("\\hello.txt") # Cannot start with \ assert not site.content_manager.isValidRelativePath("../hello.txt") # Not allowed .. in path assert not site.content_manager.isValidRelativePath("\0hello.txt") # NULL character assert not site.content_manager.isValidRelativePath("\31hello.txt") # 0-31 (ASCII control characters) assert not site.content_manager.isValidRelativePath("any/hello.txt ") # Cannot end with space assert not site.content_manager.isValidRelativePath("any/hello.txt.") # Cannot end with dot assert site.content_manager.isValidRelativePath(".hello.txt") # Allow start with dot assert not site.content_manager.isValidRelativePath("any/CON") # Protected names on Windows assert not site.content_manager.isValidRelativePath("CON/any.txt") assert not site.content_manager.isValidRelativePath("any/lpt1.txt") assert site.content_manager.isValidRelativePath("any/CONAN") assert not site.content_manager.isValidRelativePath("any/CONOUT$") assert not site.content_manager.isValidRelativePath("a" * 256) # Max 255 characters allowed ================================================ FILE: src/Test/TestContentUser.py ================================================ import json import io import pytest from Crypt import CryptBitcoin from Content.ContentManager import VerifyError, SignError @pytest.mark.usefixtures("resetSettings") class TestContentUser: def testSigners(self, site): # File info for not existing user file file_info = site.content_manager.getFileInfo("data/users/notexist/data.json") assert file_info["content_inner_path"] == "data/users/notexist/content.json" file_info = site.content_manager.getFileInfo("data/users/notexist/a/b/data.json") assert file_info["content_inner_path"] == "data/users/notexist/content.json" valid_signers = site.content_manager.getValidSigners("data/users/notexist/content.json") assert valid_signers == ["14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet", "notexist", "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT"] # File info for exsitsing user file valid_signers = site.content_manager.getValidSigners("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json") assert '1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT' in valid_signers # The site address assert '14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet' in valid_signers # Admin user defined in data/users/content.json assert '1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C' in valid_signers # The user itself assert len(valid_signers) == 3 # No more valid signers # Valid signer for banned user user_content = site.storage.loadJson("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json") user_content["cert_user_id"] = "bad@zeroid.bit" valid_signers = site.content_manager.getValidSigners("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content) assert '1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT' in valid_signers # The site address assert '14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet' in valid_signers # Admin user defined in data/users/content.json assert '1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C' not in valid_signers # The user itself def testRules(self, site): # We going to manipulate it this test rules based on data/users/content.json user_content = site.storage.loadJson("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json") # Known user user_content["cert_auth_type"] = "web" user_content["cert_user_id"] = "nofish@zeroid.bit" rules = site.content_manager.getRules("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content) assert rules["max_size"] == 100000 assert "1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C" in rules["signers"] # Unknown user user_content["cert_auth_type"] = "web" user_content["cert_user_id"] = "noone@zeroid.bit" rules = site.content_manager.getRules("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content) assert rules["max_size"] == 10000 assert "1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C" in rules["signers"] # User with more size limit based on auth type user_content["cert_auth_type"] = "bitmsg" user_content["cert_user_id"] = "noone@zeroid.bit" rules = site.content_manager.getRules("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content) assert rules["max_size"] == 15000 assert "1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C" in rules["signers"] # Banned user user_content["cert_auth_type"] = "web" user_content["cert_user_id"] = "bad@zeroid.bit" rules = site.content_manager.getRules("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content) assert "1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C" not in rules["signers"] def testRulesAddress(self, site): user_inner_path = "data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/content.json" user_content = site.storage.loadJson(user_inner_path) rules = site.content_manager.getRules(user_inner_path, user_content) assert rules["max_size"] == 10000 assert "1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9" in rules["signers"] users_content = site.content_manager.contents["data/users/content.json"] # Ban user based on address users_content["user_contents"]["permissions"]["1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9"] = False rules = site.content_manager.getRules(user_inner_path, user_content) assert "1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9" not in rules["signers"] # Change max allowed size users_content["user_contents"]["permissions"]["1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9"] = {"max_size": 20000} rules = site.content_manager.getRules(user_inner_path, user_content) assert rules["max_size"] == 20000 def testVerifyAddress(self, site): privatekey = "5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv" # For 1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT user_inner_path = "data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/content.json" data_dict = site.storage.loadJson(user_inner_path) users_content = site.content_manager.contents["data/users/content.json"] data = io.BytesIO(json.dumps(data_dict).encode()) assert site.content_manager.verifyFile(user_inner_path, data, ignore_same=False) # Test error on 15k data.json data_dict["files"]["data.json"]["size"] = 1024 * 15 del data_dict["signs"] # Remove signs before signing data_dict["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), privatekey) } data = io.BytesIO(json.dumps(data_dict).encode()) with pytest.raises(VerifyError) as err: site.content_manager.verifyFile(user_inner_path, data, ignore_same=False) assert "Include too large" in str(err.value) # Give more space based on address users_content["user_contents"]["permissions"]["1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9"] = {"max_size": 20000} del data_dict["signs"] # Remove signs before signing data_dict["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), privatekey) } data = io.BytesIO(json.dumps(data_dict).encode()) assert site.content_manager.verifyFile(user_inner_path, data, ignore_same=False) def testVerify(self, site): privatekey = "5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv" # For 1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT user_inner_path = "data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/content.json" data_dict = site.storage.loadJson(user_inner_path) users_content = site.content_manager.contents["data/users/content.json"] data = io.BytesIO(json.dumps(data_dict).encode()) assert site.content_manager.verifyFile(user_inner_path, data, ignore_same=False) # Test max size exception by setting allowed to 0 rules = site.content_manager.getRules(user_inner_path, data_dict) assert rules["max_size"] == 10000 assert users_content["user_contents"]["permission_rules"][".*"]["max_size"] == 10000 users_content["user_contents"]["permission_rules"][".*"]["max_size"] = 0 rules = site.content_manager.getRules(user_inner_path, data_dict) assert rules["max_size"] == 0 data = io.BytesIO(json.dumps(data_dict).encode()) with pytest.raises(VerifyError) as err: site.content_manager.verifyFile(user_inner_path, data, ignore_same=False) assert "Include too large" in str(err.value) users_content["user_contents"]["permission_rules"][".*"]["max_size"] = 10000 # Reset # Test max optional size exception # 1 MB gif = Allowed data_dict["files_optional"]["peanut-butter-jelly-time.gif"]["size"] = 1024 * 1024 del data_dict["signs"] # Remove signs before signing data_dict["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), privatekey) } data = io.BytesIO(json.dumps(data_dict).encode()) assert site.content_manager.verifyFile(user_inner_path, data, ignore_same=False) # 100 MB gif = Not allowed data_dict["files_optional"]["peanut-butter-jelly-time.gif"]["size"] = 100 * 1024 * 1024 del data_dict["signs"] # Remove signs before signing data_dict["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), privatekey) } data = io.BytesIO(json.dumps(data_dict).encode()) with pytest.raises(VerifyError) as err: site.content_manager.verifyFile(user_inner_path, data, ignore_same=False) assert "Include optional files too large" in str(err.value) data_dict["files_optional"]["peanut-butter-jelly-time.gif"]["size"] = 1024 * 1024 # Reset # hello.exe = Not allowed data_dict["files_optional"]["hello.exe"] = data_dict["files_optional"]["peanut-butter-jelly-time.gif"] del data_dict["signs"] # Remove signs before signing data_dict["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), privatekey) } data = io.BytesIO(json.dumps(data_dict).encode()) with pytest.raises(VerifyError) as err: site.content_manager.verifyFile(user_inner_path, data, ignore_same=False) assert "Optional file not allowed" in str(err.value) del data_dict["files_optional"]["hello.exe"] # Reset # Includes not allowed in user content data_dict["includes"] = {"other.json": {}} del data_dict["signs"] # Remove signs before signing data_dict["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), privatekey) } data = io.BytesIO(json.dumps(data_dict).encode()) with pytest.raises(VerifyError) as err: site.content_manager.verifyFile(user_inner_path, data, ignore_same=False) assert "Includes not allowed" in str(err.value) def testCert(self, site): # user_addr = "1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C" user_priv = "5Kk7FSA63FC2ViKmKLuBxk9gQkaQ5713hKq8LmFAf4cVeXh6K6A" # cert_addr = "14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet" cert_priv = "5JusJDSjHaMHwUjDT3o6eQ54pA6poo8La5fAgn1wNc3iK59jxjA" # Check if the user file is loaded assert "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json" in site.content_manager.contents user_content = site.content_manager.contents["data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json"] rules_content = site.content_manager.contents["data/users/content.json"] # Override valid cert signers for the test rules_content["user_contents"]["cert_signers"]["zeroid.bit"] = [ "14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet", "1iD5ZQJMNXu43w1qLB8sfdHVKppVMduGz" ] # Check valid cert signers rules = site.content_manager.getRules("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content) assert rules["cert_signers"] == {"zeroid.bit": [ "14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet", "1iD5ZQJMNXu43w1qLB8sfdHVKppVMduGz" ]} # Sign a valid cert user_content["cert_sign"] = CryptBitcoin.sign("1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C#%s/%s" % ( user_content["cert_auth_type"], user_content["cert_user_id"].split("@")[0] ), cert_priv) # Verify cert assert site.content_manager.verifyCert("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content) # Verify if the cert is valid for other address assert not site.content_manager.verifyCert("data/users/badaddress/content.json", user_content) # Sign user content signed_content = site.content_manager.sign( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_priv, filewrite=False ) # Test user cert assert site.content_manager.verifyFile( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", io.BytesIO(json.dumps(signed_content).encode()), ignore_same=False ) # Test banned user cert_user_id = user_content["cert_user_id"] # My username site.content_manager.contents["data/users/content.json"]["user_contents"]["permissions"][cert_user_id] = False with pytest.raises(VerifyError) as err: site.content_manager.verifyFile( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", io.BytesIO(json.dumps(signed_content).encode()), ignore_same=False ) assert "Valid signs: 0/1" in str(err.value) del site.content_manager.contents["data/users/content.json"]["user_contents"]["permissions"][cert_user_id] # Reset # Test invalid cert user_content["cert_sign"] = CryptBitcoin.sign( "badaddress#%s/%s" % (user_content["cert_auth_type"], user_content["cert_user_id"]), cert_priv ) signed_content = site.content_manager.sign( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_priv, filewrite=False ) with pytest.raises(VerifyError) as err: site.content_manager.verifyFile( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", io.BytesIO(json.dumps(signed_content).encode()), ignore_same=False ) assert "Invalid cert" in str(err.value) # Test banned user, signed by the site owner user_content["cert_sign"] = CryptBitcoin.sign("1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C#%s/%s" % ( user_content["cert_auth_type"], user_content["cert_user_id"].split("@")[0] ), cert_priv) cert_user_id = user_content["cert_user_id"] # My username site.content_manager.contents["data/users/content.json"]["user_contents"]["permissions"][cert_user_id] = False site_privatekey = "5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv" # For 1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT del user_content["signs"] # Remove signs before signing user_content["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(user_content, sort_keys=True), site_privatekey) } assert site.content_manager.verifyFile( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", io.BytesIO(json.dumps(user_content).encode()), ignore_same=False ) def testMissingCert(self, site): user_priv = "5Kk7FSA63FC2ViKmKLuBxk9gQkaQ5713hKq8LmFAf4cVeXh6K6A" cert_priv = "5JusJDSjHaMHwUjDT3o6eQ54pA6poo8La5fAgn1wNc3iK59jxjA" user_content = site.content_manager.contents["data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json"] rules_content = site.content_manager.contents["data/users/content.json"] # Override valid cert signers for the test rules_content["user_contents"]["cert_signers"]["zeroid.bit"] = [ "14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet", "1iD5ZQJMNXu43w1qLB8sfdHVKppVMduGz" ] # Sign a valid cert user_content["cert_sign"] = CryptBitcoin.sign("1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C#%s/%s" % ( user_content["cert_auth_type"], user_content["cert_user_id"].split("@")[0] ), cert_priv) signed_content = site.content_manager.sign( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_priv, filewrite=False ) assert site.content_manager.verifyFile( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", io.BytesIO(json.dumps(signed_content).encode()), ignore_same=False ) # Test invalid cert_user_id user_content["cert_user_id"] = "nodomain" user_content["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(user_content, sort_keys=True), user_priv) } signed_content = site.content_manager.sign( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_priv, filewrite=False ) with pytest.raises(VerifyError) as err: site.content_manager.verifyFile( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", io.BytesIO(json.dumps(signed_content).encode()), ignore_same=False ) assert "Invalid domain in cert_user_id" in str(err.value) # Test removed cert del user_content["cert_user_id"] del user_content["cert_auth_type"] del user_content["signs"] # Remove signs before signing user_content["signs"] = { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(user_content, sort_keys=True), user_priv) } signed_content = site.content_manager.sign( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_priv, filewrite=False ) with pytest.raises(VerifyError) as err: site.content_manager.verifyFile( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", io.BytesIO(json.dumps(signed_content).encode()), ignore_same=False ) assert "Missing cert_user_id" in str(err.value) def testCertSignersPattern(self, site): user_priv = "5Kk7FSA63FC2ViKmKLuBxk9gQkaQ5713hKq8LmFAf4cVeXh6K6A" cert_priv = "5JusJDSjHaMHwUjDT3o6eQ54pA6poo8La5fAgn1wNc3iK59jxjA" # For 14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet user_content = site.content_manager.contents["data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json"] rules_content = site.content_manager.contents["data/users/content.json"] # Override valid cert signers for the test rules_content["user_contents"]["cert_signers_pattern"] = "14wgQ[0-9][A-Z]" # Sign a valid cert user_content["cert_user_id"] = "certuser@14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet" user_content["cert_sign"] = CryptBitcoin.sign("1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C#%s/%s" % ( user_content["cert_auth_type"], "certuser" ), cert_priv) signed_content = site.content_manager.sign( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_priv, filewrite=False ) assert site.content_manager.verifyFile( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", io.BytesIO(json.dumps(signed_content).encode()), ignore_same=False ) # Cert does not matches the pattern rules_content["user_contents"]["cert_signers_pattern"] = "14wgX[0-9][A-Z]" with pytest.raises(VerifyError) as err: site.content_manager.verifyFile( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", io.BytesIO(json.dumps(signed_content).encode()), ignore_same=False ) assert "Invalid cert signer: 14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet" in str(err.value) # Removed cert_signers_pattern del rules_content["user_contents"]["cert_signers_pattern"] with pytest.raises(VerifyError) as err: site.content_manager.verifyFile( "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", io.BytesIO(json.dumps(signed_content).encode()), ignore_same=False ) assert "Invalid cert signer: 14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet" in str(err.value) def testNewFile(self, site): privatekey = "5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv" # For 1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT inner_path = "data/users/1NEWrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json" site.storage.writeJson(inner_path, {"test": "data"}) site.content_manager.sign(inner_path, privatekey) assert "test" in site.storage.loadJson(inner_path) site.storage.delete(inner_path) ================================================ FILE: src/Test/TestCryptBitcoin.py ================================================ from Crypt import CryptBitcoin class TestCryptBitcoin: def testSign(self, crypt_bitcoin_lib): privatekey = "5K9S6dVpufGnroRgFrT6wsKiz2mJRYsC73eWDmajaHserAp3F1C" privatekey_bad = "5Jbm9rrusXyApAoM8YoM4Rja337zMMoBUMRJ1uijiguU2aZRnwC" # Get address by privatekey address = crypt_bitcoin_lib.privatekeyToAddress(privatekey) assert address == "1MpDMxFeDUkiHohxx9tbGLeEGEuR4ZNsJz" address_bad = crypt_bitcoin_lib.privatekeyToAddress(privatekey_bad) assert address_bad != "1MpDMxFeDUkiHohxx9tbGLeEGEuR4ZNsJz" # Text signing data_len_list = list(range(0, 300, 10)) data_len_list += [1024, 2048, 1024 * 128, 1024 * 1024, 1024 * 2048] for data_len in data_len_list: data = data_len * "!" sign = crypt_bitcoin_lib.sign(data, privatekey) assert crypt_bitcoin_lib.verify(data, address, sign) assert not crypt_bitcoin_lib.verify("invalid" + data, address, sign) # Signed by bad privatekey sign_bad = crypt_bitcoin_lib.sign("hello", privatekey_bad) assert not crypt_bitcoin_lib.verify("hello", address, sign_bad) def testVerify(self, crypt_bitcoin_lib): sign_uncompressed = b'G6YkcFTuwKMVMHI2yycGQIFGbCZVNsZEZvSlOhKpHUt/BlADY94egmDAWdlrbbFrP9wH4aKcEfbLO8sa6f63VU0=' assert crypt_bitcoin_lib.verify("1NQUem2M4cAqWua6BVFBADtcSP55P4QobM#web/gitcenter", "19Bir5zRm1yo4pw9uuxQL8xwf9b7jqMpR", sign_uncompressed) sign_compressed = b'H6YkcFTuwKMVMHI2yycGQIFGbCZVNsZEZvSlOhKpHUt/BlADY94egmDAWdlrbbFrP9wH4aKcEfbLO8sa6f63VU0=' assert crypt_bitcoin_lib.verify("1NQUem2M4cAqWua6BVFBADtcSP55P4QobM#web/gitcenter", "1KH5BdNnqxh2KRWMMT8wUXzUgz4vVQ4S8p", sign_compressed) def testNewPrivatekey(self): assert CryptBitcoin.newPrivatekey() != CryptBitcoin.newPrivatekey() assert CryptBitcoin.privatekeyToAddress(CryptBitcoin.newPrivatekey()) def testNewSeed(self): assert CryptBitcoin.newSeed() != CryptBitcoin.newSeed() assert CryptBitcoin.privatekeyToAddress( CryptBitcoin.hdPrivatekey(CryptBitcoin.newSeed(), 0) ) assert CryptBitcoin.privatekeyToAddress( CryptBitcoin.hdPrivatekey(CryptBitcoin.newSeed(), 2**256) ) ================================================ FILE: src/Test/TestCryptConnection.py ================================================ import os from Config import config from Crypt import CryptConnection class TestCryptConnection: def testSslCert(self): # Remove old certs if os.path.isfile("%s/cert-rsa.pem" % config.data_dir): os.unlink("%s/cert-rsa.pem" % config.data_dir) if os.path.isfile("%s/key-rsa.pem" % config.data_dir): os.unlink("%s/key-rsa.pem" % config.data_dir) # Generate certs CryptConnection.manager.loadCerts() assert "tls-rsa" in CryptConnection.manager.crypt_supported assert CryptConnection.manager.selectCrypt(["tls-rsa", "unknown"]) == "tls-rsa" # It should choose the known crypt # Check openssl cert generation assert os.path.isfile("%s/cert-rsa.pem" % config.data_dir) assert os.path.isfile("%s/key-rsa.pem" % config.data_dir) ================================================ FILE: src/Test/TestCryptHash.py ================================================ import base64 from Crypt import CryptHash sha512t_sum_hex = "2e9466d8aa1f340c91203b4ddbe9b6669879616a1b8e9571058a74195937598d" sha512t_sum_bin = b".\x94f\xd8\xaa\x1f4\x0c\x91 ;M\xdb\xe9\xb6f\x98yaj\x1b\x8e\x95q\x05\x8at\x19Y7Y\x8d" sha256_sum_hex = "340cd04be7f530e3a7c1bc7b24f225ba5762ec7063a56e1ae01a30d56722e5c3" class TestCryptBitcoin: def testSha(self, site): file_path = site.storage.getPath("dbschema.json") assert CryptHash.sha512sum(file_path) == sha512t_sum_hex assert CryptHash.sha512sum(open(file_path, "rb")) == sha512t_sum_hex assert CryptHash.sha512sum(open(file_path, "rb"), format="digest") == sha512t_sum_bin assert CryptHash.sha256sum(file_path) == sha256_sum_hex assert CryptHash.sha256sum(open(file_path, "rb")) == sha256_sum_hex with open(file_path, "rb") as f: hash = CryptHash.Sha512t(f.read(100)) hash.hexdigest() != sha512t_sum_hex hash.update(f.read(1024 * 1024)) assert hash.hexdigest() == sha512t_sum_hex def testRandom(self): assert len(CryptHash.random(64)) == 64 assert CryptHash.random() != CryptHash.random() assert bytes.fromhex(CryptHash.random(encoding="hex")) assert base64.b64decode(CryptHash.random(encoding="base64")) ================================================ FILE: src/Test/TestDb.py ================================================ import io class TestDb: def testCheckTables(self, db): tables = [row["name"] for row in db.execute("SELECT name FROM sqlite_master WHERE type='table'")] assert "keyvalue" in tables # To store simple key -> value assert "json" in tables # Json file path registry assert "test" in tables # The table defined in dbschema.json # Verify test table cols = [col["name"] for col in db.execute("PRAGMA table_info(test)")] assert "test_id" in cols assert "title" in cols # Add new table assert "newtest" not in tables db.schema["tables"]["newtest"] = { "cols": [ ["newtest_id", "INTEGER"], ["newtitle", "TEXT"], ], "indexes": ["CREATE UNIQUE INDEX newtest_id ON newtest(newtest_id)"], "schema_changed": 1426195822 } db.checkTables() tables = [row["name"] for row in db.execute("SELECT name FROM sqlite_master WHERE type='table'")] assert "test" in tables assert "newtest" in tables def testQueries(self, db): # Test insert for i in range(100): db.execute("INSERT INTO test ?", {"test_id": i, "title": "Test #%s" % i}) assert db.execute("SELECT COUNT(*) AS num FROM test").fetchone()["num"] == 100 # Test single select assert db.execute("SELECT COUNT(*) AS num FROM test WHERE ?", {"test_id": 1}).fetchone()["num"] == 1 # Test multiple select assert db.execute("SELECT COUNT(*) AS num FROM test WHERE ?", {"test_id": [1, 2, 3]}).fetchone()["num"] == 3 assert db.execute( "SELECT COUNT(*) AS num FROM test WHERE ?", {"test_id": [1, 2, 3], "title": "Test #2"} ).fetchone()["num"] == 1 assert db.execute( "SELECT COUNT(*) AS num FROM test WHERE ?", {"test_id": [1, 2, 3], "title": ["Test #2", "Test #3", "Test #4"]} ).fetchone()["num"] == 2 # Test multiple select using named params assert db.execute("SELECT COUNT(*) AS num FROM test WHERE test_id IN :test_id", {"test_id": [1, 2, 3]}).fetchone()["num"] == 3 assert db.execute( "SELECT COUNT(*) AS num FROM test WHERE test_id IN :test_id AND title = :title", {"test_id": [1, 2, 3], "title": "Test #2"} ).fetchone()["num"] == 1 assert db.execute( "SELECT COUNT(*) AS num FROM test WHERE test_id IN :test_id AND title IN :title", {"test_id": [1, 2, 3], "title": ["Test #2", "Test #3", "Test #4"]} ).fetchone()["num"] == 2 # Large ammount of IN values assert db.execute( "SELECT COUNT(*) AS num FROM test WHERE ?", {"not__test_id": list(range(2, 3000))} ).fetchone()["num"] == 2 assert db.execute( "SELECT COUNT(*) AS num FROM test WHERE ?", {"test_id": list(range(50, 3000))} ).fetchone()["num"] == 50 assert db.execute( "SELECT COUNT(*) AS num FROM test WHERE ?", {"not__title": ["Test #%s" % i for i in range(50, 3000)]} ).fetchone()["num"] == 50 assert db.execute( "SELECT COUNT(*) AS num FROM test WHERE ?", {"title__like": "%20%"} ).fetchone()["num"] == 1 # Test named parameter escaping assert db.execute( "SELECT COUNT(*) AS num FROM test WHERE test_id = :test_id AND title LIKE :titlelike", {"test_id": 1, "titlelike": "Test%"} ).fetchone()["num"] == 1 def testEscaping(self, db): # Test insert for i in range(100): db.execute("INSERT INTO test ?", {"test_id": i, "title": "Test '\" #%s" % i}) assert db.execute( "SELECT COUNT(*) AS num FROM test WHERE ?", {"title": "Test '\" #1"} ).fetchone()["num"] == 1 assert db.execute( "SELECT COUNT(*) AS num FROM test WHERE ?", {"title": ["Test '\" #%s" % i for i in range(0, 50)]} ).fetchone()["num"] == 50 assert db.execute( "SELECT COUNT(*) AS num FROM test WHERE ?", {"not__title": ["Test '\" #%s" % i for i in range(50, 3000)]} ).fetchone()["num"] == 50 def testUpdateJson(self, db): f = io.BytesIO() f.write(""" { "test": [ {"test_id": 1, "title": "Test 1 title", "extra col": "Ignore it"} ] } """.encode()) f.seek(0) assert db.updateJson(db.db_dir + "data.json", f) is True assert db.execute("SELECT COUNT(*) AS num FROM test_importfilter").fetchone()["num"] == 1 assert db.execute("SELECT COUNT(*) AS num FROM test").fetchone()["num"] == 1 def testUnsafePattern(self, db): db.schema["maps"] = {"[A-Za-z.]*": db.schema["maps"]["data.json"]} # Only repetition of . supported f = io.StringIO() f.write(""" { "test": [ {"test_id": 1, "title": "Test 1 title", "extra col": "Ignore it"} ] } """) f.seek(0) assert db.updateJson(db.db_dir + "data.json", f) is False assert db.execute("SELECT COUNT(*) AS num FROM test_importfilter").fetchone()["num"] == 0 assert db.execute("SELECT COUNT(*) AS num FROM test").fetchone()["num"] == 0 ================================================ FILE: src/Test/TestDbQuery.py ================================================ import re from Db.DbQuery import DbQuery class TestDbQuery: def testParse(self): query_text = """ SELECT 'comment' AS type, date_added, post.title AS title, keyvalue.value || ': ' || comment.body AS body, '?Post:' || comment.post_id || '#Comments' AS url FROM comment LEFT JOIN json USING (json_id) LEFT JOIN json AS json_content ON (json_content.directory = json.directory AND json_content.file_name='content.json') LEFT JOIN keyvalue ON (keyvalue.json_id = json_content.json_id AND key = 'cert_user_id') LEFT JOIN post ON (comment.post_id = post.post_id) WHERE post.date_added > 123 ORDER BY date_added DESC LIMIT 20 """ query = DbQuery(query_text) assert query.parts["LIMIT"] == "20" assert query.fields["body"] == "keyvalue.value || ': ' || comment.body" assert re.sub("[ \r\n]", "", str(query)) == re.sub("[ \r\n]", "", query_text) query.wheres.append("body LIKE '%hello%'") assert "body LIKE '%hello%'" in str(query) ================================================ FILE: src/Test/TestDebug.py ================================================ from Debug import Debug import gevent import os import re import pytest class TestDebug: @pytest.mark.parametrize("items,expected", [ (["@/src/A/B/C.py:17"], ["A/B/C.py line 17"]), # basic test (["@/src/Db/Db.py:17"], ["Db.py line 17"]), # path compression (["%s:1" % __file__], ["TestDebug.py line 1"]), (["@/plugins/Chart/ChartDb.py:100"], ["ChartDb.py line 100"]), # plugins (["@/main.py:17"], ["main.py line 17"]), # root (["@\\src\\Db\\__init__.py:17"], ["Db/__init__.py line 17"]), # Windows paths ([":1"], []), # importlib builtins ([":1"], []), # importlib builtins (["/home/ivanq/ZeroNet/src/main.py:13"], ["?/src/main.py line 13"]), # best-effort anonymization (["C:\\ZeroNet\\core\\src\\main.py:13"], ["?/src/main.py line 13"]), (["/root/main.py:17"], ["/root/main.py line 17"]), (["{gevent}:13"], ["/__init__.py line 13"]), # modules (["{os}:13"], [" line 13"]), # python builtin modules (["src/gevent/event.py:17"], ["/event.py line 17"]), # gevent-overriden __file__ (["@/src/Db/Db.py:17", "@/src/Db/DbQuery.py:1"], ["Db.py line 17", "DbQuery.py line 1"]), # mutliple args (["@/src/Db/Db.py:17", "@/src/Db/Db.py:1"], ["Db.py line 17", "1"]), # same file (["{os}:1", "@/src/Db/Db.py:17"], [" line 1", "Db.py line 17"]), # builtins (["{gevent}:1"] + ["{os}:3"] * 4 + ["@/src/Db/Db.py:17"], ["/__init__.py line 1", "...", "Db.py line 17"]) ]) def testFormatTraceback(self, items, expected): q_items = [] for item in items: file, line = item.rsplit(":", 1) if file.startswith("@"): file = Debug.root_dir + file[1:] file = file.replace("{os}", os.__file__) file = file.replace("{gevent}", gevent.__file__) q_items.append((file, int(line))) assert Debug.formatTraceback(q_items) == expected def testFormatException(self): try: raise ValueError("Test exception") except Exception: assert re.match(r"ValueError: Test exception in TestDebug.py line [0-9]+", Debug.formatException()) try: os.path.abspath(1) except Exception: assert re.search(r"in TestDebug.py line [0-9]+ > <(posixpath|ntpath)> line ", Debug.formatException()) def testFormatStack(self): assert re.match(r"TestDebug.py line [0-9]+ > <_pytest>/python.py line [0-9]+", Debug.formatStack()) ================================================ FILE: src/Test/TestDiff.py ================================================ import io from util import Diff class TestDiff: def testDiff(self): assert Diff.diff( [], ["one", "two", "three"] ) == [("+", ["one", "two","three"])] assert Diff.diff( ["one", "two", "three"], ["one", "two", "three", "four", "five"] ) == [("=", 11), ("+", ["four", "five"])] assert Diff.diff( ["one", "two", "three", "six"], ["one", "two", "three", "four", "five", "six"] ) == [("=", 11), ("+", ["four", "five"]), ("=", 3)] assert Diff.diff( ["one", "two", "three", "hmm", "six"], ["one", "two", "three", "four", "five", "six"] ) == [("=", 11), ("-", 3), ("+", ["four", "five"]), ("=", 3)] assert Diff.diff( ["one", "two", "three"], [] ) == [("-", 11)] def testUtf8(self): assert Diff.diff( ["one", "\xe5\xad\xa6\xe4\xb9\xa0\xe4\xb8\x8b", "two", "three"], ["one", "\xe5\xad\xa6\xe4\xb9\xa0\xe4\xb8\x8b", "two", "three", "four", "five"] ) == [("=", 20), ("+", ["four", "five"])] def testDiffLimit(self): old_f = io.BytesIO(b"one\ntwo\nthree\nhmm\nsix") new_f = io.BytesIO(b"one\ntwo\nthree\nfour\nfive\nsix") actions = Diff.diff(list(old_f), list(new_f), limit=1024) assert actions old_f = io.BytesIO(b"one\ntwo\nthree\nhmm\nsix") new_f = io.BytesIO(b"one\ntwo\nthree\nfour\nfive\nsix"*1024) actions = Diff.diff(list(old_f), list(new_f), limit=1024) assert actions is False def testPatch(self): old_f = io.BytesIO(b"one\ntwo\nthree\nhmm\nsix") new_f = io.BytesIO(b"one\ntwo\nthree\nfour\nfive\nsix") actions = Diff.diff( list(old_f), list(new_f) ) old_f.seek(0) assert Diff.patch(old_f, actions).getvalue() == new_f.getvalue() ================================================ FILE: src/Test/TestEvent.py ================================================ import util class ExampleClass(object): def __init__(self): self.called = [] self.onChanged = util.Event() def increment(self, title): self.called.append(title) class TestEvent: def testEvent(self): test_obj = ExampleClass() test_obj.onChanged.append(lambda: test_obj.increment("Called #1")) test_obj.onChanged.append(lambda: test_obj.increment("Called #2")) test_obj.onChanged.once(lambda: test_obj.increment("Once")) assert test_obj.called == [] test_obj.onChanged() assert test_obj.called == ["Called #1", "Called #2", "Once"] test_obj.onChanged() test_obj.onChanged() assert test_obj.called == ["Called #1", "Called #2", "Once", "Called #1", "Called #2", "Called #1", "Called #2"] def testOnce(self): test_obj = ExampleClass() test_obj.onChanged.once(lambda: test_obj.increment("Once test #1")) # It should be called only once assert test_obj.called == [] test_obj.onChanged() assert test_obj.called == ["Once test #1"] test_obj.onChanged() test_obj.onChanged() assert test_obj.called == ["Once test #1"] def testOnceMultiple(self): test_obj = ExampleClass() # Allow queue more than once test_obj.onChanged.once(lambda: test_obj.increment("Once test #1")) test_obj.onChanged.once(lambda: test_obj.increment("Once test #2")) test_obj.onChanged.once(lambda: test_obj.increment("Once test #3")) assert test_obj.called == [] test_obj.onChanged() assert test_obj.called == ["Once test #1", "Once test #2", "Once test #3"] test_obj.onChanged() test_obj.onChanged() assert test_obj.called == ["Once test #1", "Once test #2", "Once test #3"] def testOnceNamed(self): test_obj = ExampleClass() # Dont store more that one from same type test_obj.onChanged.once(lambda: test_obj.increment("Once test #1/1"), "type 1") test_obj.onChanged.once(lambda: test_obj.increment("Once test #1/2"), "type 1") test_obj.onChanged.once(lambda: test_obj.increment("Once test #2"), "type 2") assert test_obj.called == [] test_obj.onChanged() assert test_obj.called == ["Once test #1/1", "Once test #2"] test_obj.onChanged() test_obj.onChanged() assert test_obj.called == ["Once test #1/1", "Once test #2"] ================================================ FILE: src/Test/TestFileRequest.py ================================================ import io import pytest import time from Connection import ConnectionServer from Connection import Connection from File import FileServer @pytest.mark.usefixtures("resetSettings") @pytest.mark.usefixtures("resetTempSettings") class TestFileRequest: def testGetFile(self, file_server, site): file_server.ip_incoming = {} # Reset flood protection client = ConnectionServer(file_server.ip, 1545) connection = client.getConnection(file_server.ip, 1544) file_server.sites[site.address] = site # Normal request response = connection.request("getFile", {"site": site.address, "inner_path": "content.json", "location": 0}) assert b"sign" in response["body"] response = connection.request("getFile", {"site": site.address, "inner_path": "content.json", "location": 0, "file_size": site.storage.getSize("content.json")}) assert b"sign" in response["body"] # Invalid file response = connection.request("getFile", {"site": site.address, "inner_path": "invalid.file", "location": 0}) assert "File read error" in response["error"] # Location over size response = connection.request("getFile", {"site": site.address, "inner_path": "content.json", "location": 1024 * 1024}) assert "File read error" in response["error"] # Stream from parent dir response = connection.request("getFile", {"site": site.address, "inner_path": "../users.json", "location": 0}) assert "File read exception" in response["error"] # Invalid site response = connection.request("getFile", {"site": "", "inner_path": "users.json", "location": 0}) assert "Unknown site" in response["error"] response = connection.request("getFile", {"site": ".", "inner_path": "users.json", "location": 0}) assert "Unknown site" in response["error"] # Invalid size response = connection.request("getFile", {"site": site.address, "inner_path": "content.json", "location": 0, "file_size": 1234}) assert "File size does not match" in response["error"] # Invalid path for path in ["../users.json", "./../users.json", "data/../content.json", ".../users.json"]: for sep in ["/", "\\"]: response = connection.request("getFile", {"site": site.address, "inner_path": path.replace("/", sep), "location": 0}) assert response["error"] == 'File read exception' connection.close() client.stop() def testStreamFile(self, file_server, site): file_server.ip_incoming = {} # Reset flood protection client = ConnectionServer(file_server.ip, 1545) connection = client.getConnection(file_server.ip, 1544) file_server.sites[site.address] = site buff = io.BytesIO() response = connection.request("streamFile", {"site": site.address, "inner_path": "content.json", "location": 0}, buff) assert "stream_bytes" in response assert b"sign" in buff.getvalue() # Invalid file buff = io.BytesIO() response = connection.request("streamFile", {"site": site.address, "inner_path": "invalid.file", "location": 0}, buff) assert "File read error" in response["error"] # Location over size buff = io.BytesIO() response = connection.request( "streamFile", {"site": site.address, "inner_path": "content.json", "location": 1024 * 1024}, buff ) assert "File read error" in response["error"] # Stream from parent dir buff = io.BytesIO() response = connection.request("streamFile", {"site": site.address, "inner_path": "../users.json", "location": 0}, buff) assert "File read exception" in response["error"] connection.close() client.stop() def testPex(self, file_server, site, site_temp): file_server.sites[site.address] = site client = FileServer(file_server.ip, 1545) client.sites = {site_temp.address: site_temp} site_temp.connection_server = client connection = client.getConnection(file_server.ip, 1544) # Add new fake peer to site fake_peer = site.addPeer(file_server.ip_external, 11337, return_peer=True) # Add fake connection to it fake_peer.connection = Connection(file_server, file_server.ip_external, 11337) fake_peer.connection.last_recv_time = time.time() assert fake_peer in site.getConnectablePeers() # Add file_server as peer to client peer_file_server = site_temp.addPeer(file_server.ip, 1544) assert "%s:11337" % file_server.ip_external not in site_temp.peers assert peer_file_server.pex() assert "%s:11337" % file_server.ip_external in site_temp.peers # Should not exchange private peers from local network fake_peer_private = site.addPeer("192.168.0.1", 11337, return_peer=True) assert fake_peer_private not in site.getConnectablePeers(allow_private=False) fake_peer_private.connection = Connection(file_server, "192.168.0.1", 11337) fake_peer_private.connection.last_recv_time = time.time() assert "192.168.0.1:11337" not in site_temp.peers assert not peer_file_server.pex() assert "192.168.0.1:11337" not in site_temp.peers connection.close() client.stop() ================================================ FILE: src/Test/TestFlag.py ================================================ import os import pytest from util.Flag import Flag class TestFlag: def testFlagging(self): flag = Flag() @flag.admin @flag.no_multiuser def testFn(anything): return anything assert "admin" in flag.db["testFn"] assert "no_multiuser" in flag.db["testFn"] def testSubclassedFlagging(self): flag = Flag() class Test: @flag.admin @flag.no_multiuser def testFn(anything): return anything class SubTest(Test): pass assert "admin" in flag.db["testFn"] assert "no_multiuser" in flag.db["testFn"] def testInvalidFlag(self): flag = Flag() with pytest.raises(Exception) as err: @flag.no_multiuser @flag.unknown_flag def testFn(anything): return anything assert "Invalid flag" in str(err.value) ================================================ FILE: src/Test/TestHelper.py ================================================ import socket import struct import os import pytest from util import helper from Config import config @pytest.mark.usefixtures("resetSettings") class TestHelper: def testShellquote(self): assert helper.shellquote("hel'lo") == "\"hel'lo\"" # Allow ' assert helper.shellquote('hel"lo') == '"hello"' # Remove " assert helper.shellquote("hel'lo", 'hel"lo') == ('"hel\'lo"', '"hello"') def testPackAddress(self): for port in [1, 1000, 65535]: for ip in ["1.1.1.1", "127.0.0.1", "0.0.0.0", "255.255.255.255", "192.168.1.1"]: assert len(helper.packAddress(ip, port)) == 6 assert helper.unpackAddress(helper.packAddress(ip, port)) == (ip, port) for ip in ["1:2:3:4:5:6:7:8", "::1", "2001:19f0:6c01:e76:5400:1ff:fed6:3eca", "2001:4860:4860::8888"]: assert len(helper.packAddress(ip, port)) == 18 assert helper.unpackAddress(helper.packAddress(ip, port)) == (ip, port) assert len(helper.packOnionAddress("boot3rdez4rzn36x.onion", port)) == 12 assert helper.unpackOnionAddress(helper.packOnionAddress("boot3rdez4rzn36x.onion", port)) == ("boot3rdez4rzn36x.onion", port) with pytest.raises(struct.error): helper.packAddress("1.1.1.1", 100000) with pytest.raises(socket.error): helper.packAddress("999.1.1.1", 1) with pytest.raises(Exception): helper.unpackAddress("X") def testGetDirname(self): assert helper.getDirname("data/users/content.json") == "data/users/" assert helper.getDirname("data/users") == "data/" assert helper.getDirname("") == "" assert helper.getDirname("content.json") == "" assert helper.getDirname("data/users/") == "data/users/" assert helper.getDirname("/data/users/content.json") == "data/users/" def testGetFilename(self): assert helper.getFilename("data/users/content.json") == "content.json" assert helper.getFilename("data/users") == "users" assert helper.getFilename("") == "" assert helper.getFilename("content.json") == "content.json" assert helper.getFilename("data/users/") == "" assert helper.getFilename("/data/users/content.json") == "content.json" def testIsIp(self): assert helper.isIp("1.2.3.4") assert helper.isIp("255.255.255.255") assert not helper.isIp("any.host") assert not helper.isIp("1.2.3.4.com") assert not helper.isIp("1.2.3.4.any.host") def testIsPrivateIp(self): assert helper.isPrivateIp("192.168.1.1") assert not helper.isPrivateIp("1.1.1.1") assert helper.isPrivateIp("fe80::44f0:3d0:4e6:637c") assert not helper.isPrivateIp("fca5:95d6:bfde:d902:8951:276e:1111:a22c") # cjdns def testOpenLocked(self): locked_f = helper.openLocked(config.data_dir + "/locked.file") assert locked_f with pytest.raises(BlockingIOError): locked_f_again = helper.openLocked(config.data_dir + "/locked.file") locked_f_different = helper.openLocked(config.data_dir + "/locked_different.file") locked_f.close() locked_f_different.close() os.unlink(locked_f.name) os.unlink(locked_f_different.name) ================================================ FILE: src/Test/TestMsgpack.py ================================================ import io import os import msgpack import pytest from Config import config from util import Msgpack from collections import OrderedDict class TestMsgpack: test_data = OrderedDict( sorted({"cmd": "fileGet", "bin": b'p\x81zDhL\xf0O\xd0\xaf', "params": {"site": "1Site"}, "utf8": b'\xc3\xa1rv\xc3\xadzt\xc5\xb1r\xc5\x91'.decode("utf8"), "list": [b'p\x81zDhL\xf0O\xd0\xaf', b'p\x81zDhL\xf0O\xd0\xaf']}.items()) ) def testPacking(self): assert Msgpack.pack(self.test_data) == b'\x85\xa3bin\xc4\np\x81zDhL\xf0O\xd0\xaf\xa3cmd\xa7fileGet\xa4list\x92\xc4\np\x81zDhL\xf0O\xd0\xaf\xc4\np\x81zDhL\xf0O\xd0\xaf\xa6params\x81\xa4site\xa51Site\xa4utf8\xad\xc3\xa1rv\xc3\xadzt\xc5\xb1r\xc5\x91' assert Msgpack.pack(self.test_data, use_bin_type=False) == b'\x85\xa3bin\xaap\x81zDhL\xf0O\xd0\xaf\xa3cmd\xa7fileGet\xa4list\x92\xaap\x81zDhL\xf0O\xd0\xaf\xaap\x81zDhL\xf0O\xd0\xaf\xa6params\x81\xa4site\xa51Site\xa4utf8\xad\xc3\xa1rv\xc3\xadzt\xc5\xb1r\xc5\x91' def testUnpackinkg(self): assert Msgpack.unpack(Msgpack.pack(self.test_data)) == self.test_data @pytest.mark.parametrize("unpacker_class", [msgpack.Unpacker, msgpack.fallback.Unpacker]) def testUnpacker(self, unpacker_class): unpacker = unpacker_class(raw=False) data = msgpack.packb(self.test_data, use_bin_type=True) data += msgpack.packb(self.test_data, use_bin_type=True) messages = [] for char in data: unpacker.feed(bytes([char])) for message in unpacker: messages.append(message) assert len(messages) == 2 assert messages[0] == self.test_data assert messages[0] == messages[1] def testStreaming(self): bin_data = os.urandom(20) f = Msgpack.FilePart("%s/users.json" % config.data_dir, "rb") f.read_bytes = 30 data = {"cmd": "response", "body": f, "bin": bin_data} out_buff = io.BytesIO() Msgpack.stream(data, out_buff.write) out_buff.seek(0) data_packb = { "cmd": "response", "body": open("%s/users.json" % config.data_dir, "rb").read(30), "bin": bin_data } out_buff.seek(0) data_unpacked = Msgpack.unpack(out_buff.read()) assert data_unpacked == data_packb assert data_unpacked["cmd"] == "response" assert type(data_unpacked["body"]) == bytes def testBackwardCompatibility(self): packed = {} packed["py3"] = Msgpack.pack(self.test_data, use_bin_type=False) packed["py3_bin"] = Msgpack.pack(self.test_data, use_bin_type=True) for key, val in packed.items(): unpacked = Msgpack.unpack(val) type(unpacked["utf8"]) == str type(unpacked["bin"]) == bytes # Packed with use_bin_type=False (pre-ZeroNet 0.7.0) unpacked = Msgpack.unpack(packed["py3"], decode=True) type(unpacked["utf8"]) == str type(unpacked["bin"]) == bytes assert len(unpacked["utf8"]) == 9 assert len(unpacked["bin"]) == 10 with pytest.raises(UnicodeDecodeError) as err: # Try to decode binary as utf-8 unpacked = Msgpack.unpack(packed["py3"], decode=False) # Packed with use_bin_type=True unpacked = Msgpack.unpack(packed["py3_bin"], decode=False) type(unpacked["utf8"]) == str type(unpacked["bin"]) == bytes assert len(unpacked["utf8"]) == 9 assert len(unpacked["bin"]) == 10 ================================================ FILE: src/Test/TestNoparallel.py ================================================ import time import gevent import pytest import util from util import ThreadPool @pytest.fixture(params=['gevent.spawn', 'thread_pool.spawn']) def queue_spawn(request): thread_pool = ThreadPool.ThreadPool(10) if request.param == "gevent.spawn": return gevent.spawn else: return thread_pool.spawn class ExampleClass(object): def __init__(self): self.counted = 0 @util.Noparallel() def countBlocking(self, num=5): for i in range(1, num + 1): time.sleep(0.1) self.counted += 1 return "counted:%s" % i @util.Noparallel(queue=True, ignore_class=True) def countQueue(self, num=5): for i in range(1, num + 1): time.sleep(0.1) self.counted += 1 return "counted:%s" % i @util.Noparallel(blocking=False) def countNoblocking(self, num=5): for i in range(1, num + 1): time.sleep(0.01) self.counted += 1 return "counted:%s" % i class TestNoparallel: def testBlocking(self, queue_spawn): obj1 = ExampleClass() obj2 = ExampleClass() # Dont allow to call again until its running and wait until its running threads = [ queue_spawn(obj1.countBlocking), queue_spawn(obj1.countBlocking), queue_spawn(obj1.countBlocking), queue_spawn(obj2.countBlocking) ] assert obj2.countBlocking() == "counted:5" # The call is ignored as obj2.countBlocking already counting, but block until its finishes gevent.joinall(threads) assert [thread.value for thread in threads] == ["counted:5", "counted:5", "counted:5", "counted:5"] obj2.countBlocking() # Allow to call again as obj2.countBlocking finished assert obj1.counted == 5 assert obj2.counted == 10 def testNoblocking(self): obj1 = ExampleClass() thread1 = obj1.countNoblocking() thread2 = obj1.countNoblocking() # Ignored assert obj1.counted == 0 time.sleep(0.1) assert thread1.value == "counted:5" assert thread2.value == "counted:5" assert obj1.counted == 5 obj1.countNoblocking().join() # Allow again and wait until finishes assert obj1.counted == 10 def testQueue(self, queue_spawn): obj1 = ExampleClass() queue_spawn(obj1.countQueue, num=1) queue_spawn(obj1.countQueue, num=1) queue_spawn(obj1.countQueue, num=1) time.sleep(0.3) assert obj1.counted == 2 # No multi-queue supported obj2 = ExampleClass() queue_spawn(obj2.countQueue, num=10) queue_spawn(obj2.countQueue, num=10) time.sleep(1.5) # Call 1 finished, call 2 still working assert 10 < obj2.counted < 20 queue_spawn(obj2.countQueue, num=10) time.sleep(2.0) assert obj2.counted == 30 def testQueueOverload(self): obj1 = ExampleClass() threads = [] for i in range(1000): thread = gevent.spawn(obj1.countQueue, num=5) threads.append(thread) gevent.joinall(threads) assert obj1.counted == 5 * 2 # Only called twice (no multi-queue allowed) def testIgnoreClass(self, queue_spawn): obj1 = ExampleClass() obj2 = ExampleClass() threads = [ queue_spawn(obj1.countQueue), queue_spawn(obj1.countQueue), queue_spawn(obj1.countQueue), queue_spawn(obj2.countQueue), queue_spawn(obj2.countQueue) ] s = time.time() time.sleep(0.001) gevent.joinall(threads) # Queue limited to 2 calls (every call takes counts to 5 and takes 0.05 sec) assert obj1.counted + obj2.counted == 10 taken = time.time() - s assert 1.2 > taken >= 1.0 # 2 * 0.5s count = ~1s def testException(self, queue_spawn): class MyException(Exception): pass @util.Noparallel() def raiseException(): raise MyException("Test error!") with pytest.raises(MyException) as err: raiseException() assert str(err.value) == "Test error!" with pytest.raises(MyException) as err: queue_spawn(raiseException).get() assert str(err.value) == "Test error!" def testMultithreadMix(self, queue_spawn): obj1 = ExampleClass() with ThreadPool.ThreadPool(10) as thread_pool: s = time.time() t1 = queue_spawn(obj1.countBlocking, 5) time.sleep(0.01) t2 = thread_pool.spawn(obj1.countBlocking, 5) time.sleep(0.01) t3 = thread_pool.spawn(obj1.countBlocking, 5) time.sleep(0.3) t4 = gevent.spawn(obj1.countBlocking, 5) threads = [t1, t2, t3, t4] for thread in threads: assert thread.get() == "counted:5" time_taken = time.time() - s assert obj1.counted == 5 assert 0.5 < time_taken < 0.7 ================================================ FILE: src/Test/TestPeer.py ================================================ import time import io import pytest from File import FileServer from File import FileRequest from Crypt import CryptHash from . import Spy @pytest.mark.usefixtures("resetSettings") @pytest.mark.usefixtures("resetTempSettings") class TestPeer: def testPing(self, file_server, site, site_temp): file_server.sites[site.address] = site client = FileServer(file_server.ip, 1545) client.sites = {site_temp.address: site_temp} site_temp.connection_server = client connection = client.getConnection(file_server.ip, 1544) # Add file_server as peer to client peer_file_server = site_temp.addPeer(file_server.ip, 1544) assert peer_file_server.ping() is not None assert peer_file_server in site_temp.peers.values() peer_file_server.remove() assert peer_file_server not in site_temp.peers.values() connection.close() client.stop() def testDownloadFile(self, file_server, site, site_temp): file_server.sites[site.address] = site client = FileServer(file_server.ip, 1545) client.sites = {site_temp.address: site_temp} site_temp.connection_server = client connection = client.getConnection(file_server.ip, 1544) # Add file_server as peer to client peer_file_server = site_temp.addPeer(file_server.ip, 1544) # Testing streamFile buff = peer_file_server.getFile(site_temp.address, "content.json", streaming=True) assert b"sign" in buff.getvalue() # Testing getFile buff = peer_file_server.getFile(site_temp.address, "content.json") assert b"sign" in buff.getvalue() connection.close() client.stop() def testHashfield(self, site): sample_hash = list(site.content_manager.contents["content.json"]["files_optional"].values())[0]["sha512"] site.storage.verifyFiles(quick_check=True) # Find what optional files we have # Check if hashfield has any files assert site.content_manager.hashfield assert len(site.content_manager.hashfield) > 0 # Check exsist hash assert site.content_manager.hashfield.getHashId(sample_hash) in site.content_manager.hashfield # Add new hash new_hash = CryptHash.sha512sum(io.BytesIO(b"hello")) assert site.content_manager.hashfield.getHashId(new_hash) not in site.content_manager.hashfield assert site.content_manager.hashfield.appendHash(new_hash) assert not site.content_manager.hashfield.appendHash(new_hash) # Don't add second time assert site.content_manager.hashfield.getHashId(new_hash) in site.content_manager.hashfield # Remove new hash assert site.content_manager.hashfield.removeHash(new_hash) assert site.content_manager.hashfield.getHashId(new_hash) not in site.content_manager.hashfield def testHashfieldExchange(self, file_server, site, site_temp): server1 = file_server server1.sites[site.address] = site site.connection_server = server1 server2 = FileServer(file_server.ip, 1545) server2.sites[site_temp.address] = site_temp site_temp.connection_server = server2 site.storage.verifyFiles(quick_check=True) # Find what optional files we have # Add file_server as peer to client server2_peer1 = site_temp.addPeer(file_server.ip, 1544) # Check if hashfield has any files assert len(site.content_manager.hashfield) > 0 # Testing hashfield sync assert len(server2_peer1.hashfield) == 0 assert server2_peer1.updateHashfield() # Query hashfield from peer assert len(server2_peer1.hashfield) > 0 # Test force push new hashfield site_temp.content_manager.hashfield.appendHash("AABB") server1_peer2 = site.addPeer(file_server.ip, 1545, return_peer=True) with Spy.Spy(FileRequest, "route") as requests: assert len(server1_peer2.hashfield) == 0 server2_peer1.sendMyHashfield() assert len(server1_peer2.hashfield) == 1 server2_peer1.sendMyHashfield() # Hashfield not changed, should be ignored assert len(requests) == 1 time.sleep(0.01) # To make hashfield change date different site_temp.content_manager.hashfield.appendHash("AACC") server2_peer1.sendMyHashfield() # Push hashfield assert len(server1_peer2.hashfield) == 2 assert len(requests) == 2 site_temp.content_manager.hashfield.appendHash("AADD") assert server1_peer2.updateHashfield(force=True) # Request hashfield assert len(server1_peer2.hashfield) == 3 assert len(requests) == 3 assert not server2_peer1.sendMyHashfield() # Not changed, should be ignored assert len(requests) == 3 server2.stop() def testFindHash(self, file_server, site, site_temp): file_server.sites[site.address] = site client = FileServer(file_server.ip, 1545) client.sites = {site_temp.address: site_temp} site_temp.connection_server = client # Add file_server as peer to client peer_file_server = site_temp.addPeer(file_server.ip, 1544) assert peer_file_server.findHashIds([1234]) == {} # Add fake peer with requred hash fake_peer_1 = site.addPeer(file_server.ip_external, 1544) fake_peer_1.hashfield.append(1234) fake_peer_2 = site.addPeer("1.2.3.5", 1545) fake_peer_2.hashfield.append(1234) fake_peer_2.hashfield.append(1235) fake_peer_3 = site.addPeer("1.2.3.6", 1546) fake_peer_3.hashfield.append(1235) fake_peer_3.hashfield.append(1236) res = peer_file_server.findHashIds([1234, 1235]) assert sorted(res[1234]) == sorted([(file_server.ip_external, 1544), ("1.2.3.5", 1545)]) assert sorted(res[1235]) == sorted([("1.2.3.5", 1545), ("1.2.3.6", 1546)]) # Test my address adding site.content_manager.hashfield.append(1234) res = peer_file_server.findHashIds([1234, 1235]) assert sorted(res[1234]) == sorted([(file_server.ip_external, 1544), ("1.2.3.5", 1545), (file_server.ip, 1544)]) assert sorted(res[1235]) == sorted([("1.2.3.5", 1545), ("1.2.3.6", 1546)]) ================================================ FILE: src/Test/TestRateLimit.py ================================================ import time import gevent from util import RateLimit # Time is around limit +/- 0.05 sec def around(t, limit): return t >= limit - 0.05 and t <= limit + 0.05 class ExampleClass(object): def __init__(self): self.counted = 0 self.last_called = None def count(self, back="counted"): self.counted += 1 self.last_called = back return back class TestRateLimit: def testCall(self): obj1 = ExampleClass() obj2 = ExampleClass() s = time.time() assert RateLimit.call("counting", allowed_again=0.1, func=obj1.count) == "counted" assert around(time.time() - s, 0.0) # First allow to call instantly assert obj1.counted == 1 # Call again assert not RateLimit.isAllowed("counting", 0.1) assert RateLimit.isAllowed("something else", 0.1) assert RateLimit.call("counting", allowed_again=0.1, func=obj1.count) == "counted" assert around(time.time() - s, 0.1) # Delays second call within interval assert obj1.counted == 2 time.sleep(0.1) # Wait the cooldown time # Call 3 times async s = time.time() assert obj2.counted == 0 threads = [ gevent.spawn(lambda: RateLimit.call("counting", allowed_again=0.1, func=obj2.count)), # Instant gevent.spawn(lambda: RateLimit.call("counting", allowed_again=0.1, func=obj2.count)), # 0.1s delay gevent.spawn(lambda: RateLimit.call("counting", allowed_again=0.1, func=obj2.count)) # 0.2s delay ] gevent.joinall(threads) assert [thread.value for thread in threads] == ["counted", "counted", "counted"] assert around(time.time() - s, 0.2) # Wait 0.1s cooldown assert not RateLimit.isAllowed("counting", 0.1) time.sleep(0.11) assert RateLimit.isAllowed("counting", 0.1) # No queue = instant again s = time.time() assert RateLimit.isAllowed("counting", 0.1) assert RateLimit.call("counting", allowed_again=0.1, func=obj2.count) == "counted" assert around(time.time() - s, 0.0) assert obj2.counted == 4 def testCallAsync(self): obj1 = ExampleClass() obj2 = ExampleClass() s = time.time() RateLimit.callAsync("counting async", allowed_again=0.1, func=obj1.count, back="call #1").join() assert obj1.counted == 1 # First instant assert around(time.time() - s, 0.0) # After that the calls delayed s = time.time() t1 = RateLimit.callAsync("counting async", allowed_again=0.1, func=obj1.count, back="call #2") # Dumped by the next call time.sleep(0.03) t2 = RateLimit.callAsync("counting async", allowed_again=0.1, func=obj1.count, back="call #3") # Dumped by the next call time.sleep(0.03) t3 = RateLimit.callAsync("counting async", allowed_again=0.1, func=obj1.count, back="call #4") # Will be called assert obj1.counted == 1 # Delay still in progress: Not called yet t3.join() assert t3.value == "call #4" assert around(time.time() - s, 0.1) # Only the last one called assert obj1.counted == 2 assert obj1.last_called == "call #4" # Just called, not allowed again assert not RateLimit.isAllowed("counting async", 0.1) s = time.time() t4 = RateLimit.callAsync("counting async", allowed_again=0.1, func=obj1.count, back="call #5").join() assert obj1.counted == 3 assert around(time.time() - s, 0.1) assert not RateLimit.isAllowed("counting async", 0.1) time.sleep(0.11) assert RateLimit.isAllowed("counting async", 0.1) ================================================ FILE: src/Test/TestSafeRe.py ================================================ from util import SafeRe import pytest class TestSafeRe: def testSafeMatch(self): assert SafeRe.match( "((js|css)/(?!all.(js|css))|data/users/.*db|data/users/.*/.*|data/archived|.*.py)", "js/ZeroTalk.coffee" ) assert SafeRe.match(".+/data.json", "data/users/1J3rJ8ecnwH2EPYa6MrgZttBNc61ACFiCj/data.json") @pytest.mark.parametrize("pattern", ["([a-zA-Z]+)*", "(a|aa)+*", "(a|a?)+", "(.*a){10}", "((?!json).)*$", r"(\w+\d+)+C"]) def testUnsafeMatch(self, pattern): with pytest.raises(SafeRe.UnsafePatternError) as err: SafeRe.match(pattern, "aaaaaaaaaaaaaaaaaaaaaaaa!") assert "Potentially unsafe" in str(err.value) @pytest.mark.parametrize("pattern", ["^(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)$"]) def testUnsafeRepetition(self, pattern): with pytest.raises(SafeRe.UnsafePatternError) as err: SafeRe.match(pattern, "aaaaaaaaaaaaaaaaaaaaaaaa!") assert "More than" in str(err.value) ================================================ FILE: src/Test/TestSite.py ================================================ import shutil import os import pytest from Site import SiteManager TEST_DATA_PATH = "src/Test/testdata" @pytest.mark.usefixtures("resetSettings") class TestSite: def testClone(self, site): assert site.storage.directory == TEST_DATA_PATH + "/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT" # Remove old files if os.path.isdir(TEST_DATA_PATH + "/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL"): shutil.rmtree(TEST_DATA_PATH + "/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL") assert not os.path.isfile(TEST_DATA_PATH + "/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL/content.json") # Clone 1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT to 15E5rhcAUD69WbiYsYARh4YHJ4sLm2JEyc new_site = site.clone( "159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL", "5JU2p5h3R7B1WrbaEdEDNZR7YHqRLGcjNcqwqVQzX2H4SuNe2ee", address_index=1 ) # Check if clone was successful assert new_site.address == "159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL" assert new_site.storage.isFile("content.json") assert new_site.storage.isFile("index.html") assert new_site.storage.isFile("data/users/content.json") assert new_site.storage.isFile("data/zeroblog.db") assert new_site.storage.verifyFiles()["bad_files"] == [] # No bad files allowed assert new_site.storage.query("SELECT * FROM keyvalue WHERE key = 'title'").fetchone()["value"] == "MyZeroBlog" # Optional files should be removed assert len(new_site.storage.loadJson("content.json").get("files_optional", {})) == 0 # Test re-cloning (updating) # Changes in non-data files should be overwritten new_site.storage.write("index.html", b"this will be overwritten") assert new_site.storage.read("index.html") == b"this will be overwritten" # Changes in data file should be kept after re-cloning changed_contentjson = new_site.storage.loadJson("content.json") changed_contentjson["description"] = "Update Description Test" new_site.storage.writeJson("content.json", changed_contentjson) changed_data = new_site.storage.loadJson("data/data.json") changed_data["title"] = "UpdateTest" new_site.storage.writeJson("data/data.json", changed_data) # The update should be reflected to database assert new_site.storage.query("SELECT * FROM keyvalue WHERE key = 'title'").fetchone()["value"] == "UpdateTest" # Re-clone the site site.log.debug("Re-cloning") site.clone("159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL") assert new_site.storage.loadJson("data/data.json")["title"] == "UpdateTest" assert new_site.storage.loadJson("content.json")["description"] == "Update Description Test" assert new_site.storage.read("index.html") != "this will be overwritten" # Delete created files new_site.storage.deleteFiles() assert not os.path.isdir(TEST_DATA_PATH + "/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL") # Delete from site registry assert new_site.address in SiteManager.site_manager.sites SiteManager.site_manager.delete(new_site.address) assert new_site.address not in SiteManager.site_manager.sites ================================================ FILE: src/Test/TestSiteDownload.py ================================================ import time import pytest import mock import gevent import gevent.event import os from Connection import ConnectionServer from Config import config from File import FileRequest from File import FileServer from Site.Site import Site from . import Spy @pytest.mark.usefixtures("resetTempSettings") @pytest.mark.usefixtures("resetSettings") class TestSiteDownload: def testRename(self, file_server, site, site_temp): assert site.storage.directory == config.data_dir + "/" + site.address assert site_temp.storage.directory == config.data_dir + "-temp/" + site.address # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server client = FileServer(file_server.ip, 1545) client.sites = {site_temp.address: site_temp} site_temp.connection_server = client site_temp.announce = mock.MagicMock(return_value=True) # Don't try to find peers from the net site_temp.addPeer(file_server.ip, 1544) assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) assert site_temp.storage.isFile("content.json") # Rename non-optional file os.rename(site.storage.getPath("data/img/domain.png"), site.storage.getPath("data/img/domain-new.png")) site.content_manager.sign("content.json", privatekey="5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv") content = site.storage.loadJson("content.json") assert "data/img/domain-new.png" in content["files"] assert "data/img/domain.png" not in content["files"] assert not site_temp.storage.isFile("data/img/domain-new.png") assert site_temp.storage.isFile("data/img/domain.png") settings_before = site_temp.settings with Spy.Spy(FileRequest, "route") as requests: site.publish() time.sleep(0.1) assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) # Wait for download assert "streamFile" not in [req[1] for req in requests] content = site_temp.storage.loadJson("content.json") assert "data/img/domain-new.png" in content["files"] assert "data/img/domain.png" not in content["files"] assert site_temp.storage.isFile("data/img/domain-new.png") assert not site_temp.storage.isFile("data/img/domain.png") assert site_temp.settings["size"] == settings_before["size"] assert site_temp.settings["size_optional"] == settings_before["size_optional"] assert site_temp.storage.deleteFiles() [connection.close() for connection in file_server.connections] def testRenameOptional(self, file_server, site, site_temp): assert site.storage.directory == config.data_dir + "/" + site.address assert site_temp.storage.directory == config.data_dir + "-temp/" + site.address # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server client = FileServer(file_server.ip, 1545) client.sites = {site_temp.address: site_temp} site_temp.connection_server = client site_temp.announce = mock.MagicMock(return_value=True) # Don't try to find peers from the net site_temp.addPeer(file_server.ip, 1544) assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) assert site_temp.settings["optional_downloaded"] == 0 site_temp.needFile("data/optional.txt") assert site_temp.settings["optional_downloaded"] > 0 settings_before = site_temp.settings hashfield_before = site_temp.content_manager.hashfield.tobytes() # Rename optional file os.rename(site.storage.getPath("data/optional.txt"), site.storage.getPath("data/optional-new.txt")) site.content_manager.sign("content.json", privatekey="5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv", remove_missing_optional=True) content = site.storage.loadJson("content.json") assert "data/optional-new.txt" in content["files_optional"] assert "data/optional.txt" not in content["files_optional"] assert not site_temp.storage.isFile("data/optional-new.txt") assert site_temp.storage.isFile("data/optional.txt") with Spy.Spy(FileRequest, "route") as requests: site.publish() time.sleep(0.1) assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) # Wait for download assert "streamFile" not in [req[1] for req in requests] content = site_temp.storage.loadJson("content.json") assert "data/optional-new.txt" in content["files_optional"] assert "data/optional.txt" not in content["files_optional"] assert site_temp.storage.isFile("data/optional-new.txt") assert not site_temp.storage.isFile("data/optional.txt") assert site_temp.settings["size"] == settings_before["size"] assert site_temp.settings["size_optional"] == settings_before["size_optional"] assert site_temp.settings["optional_downloaded"] == settings_before["optional_downloaded"] assert site_temp.content_manager.hashfield.tobytes() == hashfield_before assert site_temp.storage.deleteFiles() [connection.close() for connection in file_server.connections] def testArchivedDownload(self, file_server, site, site_temp): # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server client = FileServer(file_server.ip, 1545) client.sites = {site_temp.address: site_temp} site_temp.connection_server = client # Download normally site_temp.addPeer(file_server.ip, 1544) assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) bad_files = site_temp.storage.verifyFiles(quick_check=True)["bad_files"] assert not bad_files assert "data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json" in site_temp.content_manager.contents assert site_temp.storage.isFile("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json") assert len(list(site_temp.storage.query("SELECT * FROM comment"))) == 2 # Add archived data assert "archived" not in site.content_manager.contents["data/users/content.json"]["user_contents"] assert not site.content_manager.isArchived("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json", time.time()-1) site.content_manager.contents["data/users/content.json"]["user_contents"]["archived"] = {"1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q": time.time()} site.content_manager.sign("data/users/content.json", privatekey="5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv") date_archived = site.content_manager.contents["data/users/content.json"]["user_contents"]["archived"]["1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q"] assert site.content_manager.isArchived("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json", date_archived-1) assert site.content_manager.isArchived("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json", date_archived) assert not site.content_manager.isArchived("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json", date_archived+1) # Allow user to update archived data later # Push archived update assert not "archived" in site_temp.content_manager.contents["data/users/content.json"]["user_contents"] site.publish() time.sleep(0.1) assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) # Wait for download # The archived content should disappear from remote client assert "archived" in site_temp.content_manager.contents["data/users/content.json"]["user_contents"] assert "data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json" not in site_temp.content_manager.contents assert not site_temp.storage.isDir("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q") assert len(list(site_temp.storage.query("SELECT * FROM comment"))) == 1 assert len(list(site_temp.storage.query("SELECT * FROM json WHERE directory LIKE '%1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q%'"))) == 0 assert site_temp.storage.deleteFiles() [connection.close() for connection in file_server.connections] def testArchivedBeforeDownload(self, file_server, site, site_temp): # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server client = FileServer(file_server.ip, 1545) client.sites = {site_temp.address: site_temp} site_temp.connection_server = client # Download normally site_temp.addPeer(file_server.ip, 1544) assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) bad_files = site_temp.storage.verifyFiles(quick_check=True)["bad_files"] assert not bad_files assert "data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json" in site_temp.content_manager.contents assert site_temp.storage.isFile("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json") assert len(list(site_temp.storage.query("SELECT * FROM comment"))) == 2 # Add archived data assert not "archived_before" in site.content_manager.contents["data/users/content.json"]["user_contents"] assert not site.content_manager.isArchived("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json", time.time()-1) content_modification_time = site.content_manager.contents["data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json"]["modified"] site.content_manager.contents["data/users/content.json"]["user_contents"]["archived_before"] = content_modification_time site.content_manager.sign("data/users/content.json", privatekey="5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv") date_archived = site.content_manager.contents["data/users/content.json"]["user_contents"]["archived_before"] assert site.content_manager.isArchived("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json", date_archived-1) assert site.content_manager.isArchived("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json", date_archived) assert not site.content_manager.isArchived("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json", date_archived+1) # Allow user to update archived data later # Push archived update assert not "archived_before" in site_temp.content_manager.contents["data/users/content.json"]["user_contents"] site.publish() time.sleep(0.1) assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) # Wait for download # The archived content should disappear from remote client assert "archived_before" in site_temp.content_manager.contents["data/users/content.json"]["user_contents"] assert "data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json" not in site_temp.content_manager.contents assert not site_temp.storage.isDir("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q") assert len(list(site_temp.storage.query("SELECT * FROM comment"))) == 1 assert len(list(site_temp.storage.query("SELECT * FROM json WHERE directory LIKE '%1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q%'"))) == 0 assert site_temp.storage.deleteFiles() [connection.close() for connection in file_server.connections] # Test when connected peer has the optional file def testOptionalDownload(self, file_server, site, site_temp): # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server client = ConnectionServer(file_server.ip, 1545) site_temp.connection_server = client site_temp.announce = mock.MagicMock(return_value=True) # Don't try to find peers from the net site_temp.addPeer(file_server.ip, 1544) # Download site assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) # Download optional data/optional.txt site.storage.verifyFiles(quick_check=True) # Find what optional files we have optional_file_info = site_temp.content_manager.getFileInfo("data/optional.txt") assert site.content_manager.hashfield.hasHash(optional_file_info["sha512"]) assert not site_temp.content_manager.hashfield.hasHash(optional_file_info["sha512"]) assert not site_temp.storage.isFile("data/optional.txt") assert site.storage.isFile("data/optional.txt") site_temp.needFile("data/optional.txt") assert site_temp.storage.isFile("data/optional.txt") # Optional user file assert not site_temp.storage.isFile("data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/peanut-butter-jelly-time.gif") optional_file_info = site_temp.content_manager.getFileInfo( "data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/peanut-butter-jelly-time.gif" ) assert site.content_manager.hashfield.hasHash(optional_file_info["sha512"]) assert not site_temp.content_manager.hashfield.hasHash(optional_file_info["sha512"]) site_temp.needFile("data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/peanut-butter-jelly-time.gif") assert site_temp.storage.isFile("data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/peanut-butter-jelly-time.gif") assert site_temp.content_manager.hashfield.hasHash(optional_file_info["sha512"]) assert site_temp.storage.deleteFiles() [connection.close() for connection in file_server.connections] # Test when connected peer does not has the file, so ask him if he know someone who has it def testFindOptional(self, file_server, site, site_temp): # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init full source server (has optional files) site_full = Site("1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT") file_server_full = FileServer(file_server.ip, 1546) site_full.connection_server = file_server_full def listen(): ConnectionServer.start(file_server_full) ConnectionServer.listen(file_server_full) gevent.spawn(listen) time.sleep(0.001) # Port opening file_server_full.sites[site_full.address] = site_full # Add site site_full.storage.verifyFiles(quick_check=True) # Check optional files site_full_peer = site.addPeer(file_server.ip, 1546) # Add it to source server hashfield = site_full_peer.updateHashfield() # Update hashfield assert len(site_full.content_manager.hashfield) == 8 assert hashfield assert site_full.storage.isFile("data/optional.txt") assert site_full.storage.isFile("data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/peanut-butter-jelly-time.gif") assert len(site_full_peer.hashfield) == 8 # Remove hashes from source server for hash in list(site.content_manager.hashfield): site.content_manager.hashfield.remove(hash) # Init client server site_temp.connection_server = ConnectionServer(file_server.ip, 1545) site_temp.addPeer(file_server.ip, 1544) # Add source server # Download normal files site_temp.log.info("Start Downloading site") assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) # Download optional data/optional.txt optional_file_info = site_temp.content_manager.getFileInfo("data/optional.txt") optional_file_info2 = site_temp.content_manager.getFileInfo("data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/peanut-butter-jelly-time.gif") assert not site_temp.storage.isFile("data/optional.txt") assert not site_temp.storage.isFile("data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/peanut-butter-jelly-time.gif") assert not site.content_manager.hashfield.hasHash(optional_file_info["sha512"]) # Source server don't know he has the file assert not site.content_manager.hashfield.hasHash(optional_file_info2["sha512"]) # Source server don't know he has the file assert site_full_peer.hashfield.hasHash(optional_file_info["sha512"]) # Source full peer on source server has the file assert site_full_peer.hashfield.hasHash(optional_file_info2["sha512"]) # Source full peer on source server has the file assert site_full.content_manager.hashfield.hasHash(optional_file_info["sha512"]) # Source full server he has the file assert site_full.content_manager.hashfield.hasHash(optional_file_info2["sha512"]) # Source full server he has the file site_temp.log.info("Request optional files") with Spy.Spy(FileRequest, "route") as requests: # Request 2 file same time threads = [] threads.append(site_temp.needFile("data/optional.txt", blocking=False)) threads.append(site_temp.needFile("data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/peanut-butter-jelly-time.gif", blocking=False)) gevent.joinall(threads) assert len([request for request in requests if request[1] == "findHashIds"]) == 1 # findHashids should call only once assert site_temp.storage.isFile("data/optional.txt") assert site_temp.storage.isFile("data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/peanut-butter-jelly-time.gif") assert site_temp.storage.deleteFiles() file_server_full.stop() [connection.close() for connection in file_server.connections] site_full.content_manager.contents.db.close("FindOptional test end") def testUpdate(self, file_server, site, site_temp): assert site.storage.directory == config.data_dir + "/" + site.address assert site_temp.storage.directory == config.data_dir + "-temp/" + site.address # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server client = FileServer(file_server.ip, 1545) client.sites = {site_temp.address: site_temp} site_temp.connection_server = client # Don't try to find peers from the net site.announce = mock.MagicMock(return_value=True) site_temp.announce = mock.MagicMock(return_value=True) # Connect peers site_temp.addPeer(file_server.ip, 1544) # Download site from site to site_temp assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) assert len(site_temp.bad_files) == 1 # Update file data_original = site.storage.open("data/data.json").read() data_new = data_original.replace(b'"ZeroBlog"', b'"UpdatedZeroBlog"') assert data_original != data_new site.storage.open("data/data.json", "wb").write(data_new) assert site.storage.open("data/data.json").read() == data_new assert site_temp.storage.open("data/data.json").read() == data_original site.log.info("Publish new data.json without patch") # Publish without patch with Spy.Spy(FileRequest, "route") as requests: site.content_manager.sign("content.json", privatekey="5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv") site.publish() time.sleep(0.1) site.log.info("Downloading site") assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) assert len([request for request in requests if request[1] in ("getFile", "streamFile")]) == 1 assert site_temp.storage.open("data/data.json").read() == data_new # Close connection to avoid update spam limit list(site.peers.values())[0].remove() site.addPeer(file_server.ip, 1545) list(site_temp.peers.values())[0].ping() # Connect back time.sleep(0.1) # Update with patch data_new = data_original.replace(b'"ZeroBlog"', b'"PatchedZeroBlog"') assert data_original != data_new site.storage.open("data/data.json-new", "wb").write(data_new) assert site.storage.open("data/data.json-new").read() == data_new assert site_temp.storage.open("data/data.json").read() != data_new # Generate diff diffs = site.content_manager.getDiffs("content.json") assert not site.storage.isFile("data/data.json-new") # New data file removed assert site.storage.open("data/data.json").read() == data_new # -new postfix removed assert "data/data.json" in diffs assert diffs["data/data.json"] == [('=', 2), ('-', 29), ('+', [b'\t"title": "PatchedZeroBlog",\n']), ('=', 31102)] # Publish with patch site.log.info("Publish new data.json with patch") with Spy.Spy(FileRequest, "route") as requests: site.content_manager.sign("content.json", privatekey="5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv") event_done = gevent.event.AsyncResult() site.publish(diffs=diffs) time.sleep(0.1) assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) assert [request for request in requests if request[1] in ("getFile", "streamFile")] == [] assert site_temp.storage.open("data/data.json").read() == data_new assert site_temp.storage.deleteFiles() [connection.close() for connection in file_server.connections] def testBigUpdate(self, file_server, site, site_temp): # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server client = FileServer(file_server.ip, 1545) client.sites = {site_temp.address: site_temp} site_temp.connection_server = client # Connect peers site_temp.addPeer(file_server.ip, 1544) # Download site from site to site_temp assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) assert list(site_temp.bad_files.keys()) == ["data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json"] # Update file data_original = site.storage.open("data/data.json").read() data_new = data_original.replace(b'"ZeroBlog"', b'"PatchedZeroBlog"') assert data_original != data_new site.storage.open("data/data.json-new", "wb").write(data_new) assert site.storage.open("data/data.json-new").read() == data_new assert site_temp.storage.open("data/data.json").read() != data_new # Generate diff diffs = site.content_manager.getDiffs("content.json") assert not site.storage.isFile("data/data.json-new") # New data file removed assert site.storage.open("data/data.json").read() == data_new # -new postfix removed assert "data/data.json" in diffs content_json = site.storage.loadJson("content.json") content_json["description"] = "BigZeroBlog" * 1024 * 10 site.storage.writeJson("content.json", content_json) site.content_manager.loadContent("content.json", force=True) # Publish with patch site.log.info("Publish new data.json with patch") with Spy.Spy(FileRequest, "route") as requests: site.content_manager.sign("content.json", privatekey="5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv") assert site.storage.getSize("content.json") > 10 * 1024 # Make it a big content.json site.publish(diffs=diffs) time.sleep(0.1) assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) file_requests = [request for request in requests if request[1] in ("getFile", "streamFile")] assert len(file_requests) == 1 assert site_temp.storage.open("data/data.json").read() == data_new assert site_temp.storage.open("content.json").read() == site.storage.open("content.json").read() # Test what happened if the content.json of the site is bigger than the site limit def testHugeContentSiteUpdate(self, file_server, site, site_temp): # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server client = FileServer(file_server.ip, 1545) client.sites = {site_temp.address: site_temp} site_temp.connection_server = client # Connect peers site_temp.addPeer(file_server.ip, 1544) # Download site from site to site_temp assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) site_temp.settings["size_limit"] = int(20 * 1024 *1024) site_temp.saveSettings() # Raise limit size to 20MB on site so it can be signed site.settings["size_limit"] = int(20 * 1024 *1024) site.saveSettings() content_json = site.storage.loadJson("content.json") content_json["description"] = "PartirUnJour" * 1024 * 1024 site.storage.writeJson("content.json", content_json) changed, deleted = site.content_manager.loadContent("content.json", force=True) # Make sure we have 2 differents content.json assert site_temp.storage.open("content.json").read() != site.storage.open("content.json").read() # Generate diff diffs = site.content_manager.getDiffs("content.json") # Publish with patch site.log.info("Publish new content.json bigger than 10MB") with Spy.Spy(FileRequest, "route") as requests: site.content_manager.sign("content.json", privatekey="5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv") assert site.storage.getSize("content.json") > 10 * 1024 * 1024 # verify it over 10MB time.sleep(0.1) site.publish(diffs=diffs) assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) assert site_temp.storage.getSize("content.json") < site_temp.getSizeLimit() * 1024 * 1024 assert site_temp.storage.open("content.json").read() == site.storage.open("content.json").read() def testUnicodeFilename(self, file_server, site, site_temp): assert site.storage.directory == config.data_dir + "/" + site.address assert site_temp.storage.directory == config.data_dir + "-temp/" + site.address # Init source server site.connection_server = file_server file_server.sites[site.address] = site # Init client server client = FileServer(file_server.ip, 1545) client.sites = {site_temp.address: site_temp} site_temp.connection_server = client site_temp.announce = mock.MagicMock(return_value=True) # Don't try to find peers from the net site_temp.addPeer(file_server.ip, 1544) assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) site.storage.write("data/img/árvíztűrő.png", b"test") site.content_manager.sign("content.json", privatekey="5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv") content = site.storage.loadJson("content.json") assert "data/img/árvíztűrő.png" in content["files"] assert not site_temp.storage.isFile("data/img/árvíztűrő.png") settings_before = site_temp.settings with Spy.Spy(FileRequest, "route") as requests: site.publish() time.sleep(0.1) assert site_temp.download(blind_includes=True, retry_bad_files=False).get(timeout=10) # Wait for download assert len([req[1] for req in requests if req[1] == "streamFile"]) == 1 content = site_temp.storage.loadJson("content.json") assert "data/img/árvíztűrő.png" in content["files"] assert site_temp.storage.isFile("data/img/árvíztűrő.png") assert site_temp.settings["size"] == settings_before["size"] assert site_temp.settings["size_optional"] == settings_before["size_optional"] assert site_temp.storage.deleteFiles() [connection.close() for connection in file_server.connections] ================================================ FILE: src/Test/TestSiteStorage.py ================================================ import pytest @pytest.mark.usefixtures("resetSettings") class TestSiteStorage: def testWalk(self, site): # Rootdir walk_root = list(site.storage.walk("")) assert "content.json" in walk_root assert "css/all.css" in walk_root # Subdir assert list(site.storage.walk("data-default")) == ["data.json", "users/content-default.json"] def testList(self, site): # Rootdir list_root = list(site.storage.list("")) assert "content.json" in list_root assert "css/all.css" not in list_root # Subdir assert set(site.storage.list("data-default")) == set(["data.json", "users"]) def testDbRebuild(self, site): assert site.storage.rebuildDb() ================================================ FILE: src/Test/TestThreadPool.py ================================================ import time import threading import gevent import pytest from util import ThreadPool class TestThreadPool: def testExecutionOrder(self): with ThreadPool.ThreadPool(4) as pool: events = [] @pool.wrap def blocker(): events.append("S") out = 0 for i in range(10000000): if i == 3000000: events.append("M") out += 1 events.append("D") return out threads = [] for i in range(3): threads.append(gevent.spawn(blocker)) gevent.joinall(threads) assert events == ["S"] * 3 + ["M"] * 3 + ["D"] * 3 res = blocker() assert res == 10000000 def testLockBlockingSameThread(self): lock = ThreadPool.Lock() s = time.time() def unlocker(): time.sleep(1) lock.release() gevent.spawn(unlocker) lock.acquire(True) lock.acquire(True, timeout=2) unlock_taken = time.time() - s assert 1.0 < unlock_taken < 1.5 def testLockBlockingDifferentThread(self): lock = ThreadPool.Lock() def locker(): lock.acquire(True) time.sleep(0.5) lock.release() with ThreadPool.ThreadPool(10) as pool: threads = [ pool.spawn(locker), pool.spawn(locker), gevent.spawn(locker), pool.spawn(locker) ] time.sleep(0.1) s = time.time() lock.acquire(True, 5.0) unlock_taken = time.time() - s assert 1.8 < unlock_taken < 2.2 gevent.joinall(threads) def testMainLoopCallerThreadId(self): main_thread_id = threading.current_thread().ident with ThreadPool.ThreadPool(5) as pool: def getThreadId(*args, **kwargs): return threading.current_thread().ident t = pool.spawn(getThreadId) assert t.get() != main_thread_id t = pool.spawn(lambda: ThreadPool.main_loop.call(getThreadId)) assert t.get() == main_thread_id def testMainLoopCallerGeventSpawn(self): main_thread_id = threading.current_thread().ident with ThreadPool.ThreadPool(5) as pool: def waiter(): time.sleep(1) return threading.current_thread().ident def geventSpawner(): event = ThreadPool.main_loop.call(gevent.spawn, waiter) with pytest.raises(Exception) as greenlet_err: event.get() assert str(greenlet_err.value) == "cannot switch to a different thread" waiter_thread_id = ThreadPool.main_loop.call(event.get) return waiter_thread_id s = time.time() waiter_thread_id = pool.apply(geventSpawner) assert main_thread_id == waiter_thread_id time_taken = time.time() - s assert 0.9 < time_taken < 1.2 def testEvent(self): with ThreadPool.ThreadPool(5) as pool: event = ThreadPool.Event() def setter(): time.sleep(1) event.set("done!") def getter(): return event.get() pool.spawn(setter) t_gevent = gevent.spawn(getter) t_pool = pool.spawn(getter) s = time.time() assert event.get() == "done!" time_taken = time.time() - s gevent.joinall([t_gevent, t_pool]) assert t_gevent.get() == "done!" assert t_pool.get() == "done!" assert 0.9 < time_taken < 1.2 with pytest.raises(Exception) as err: event.set("another result") assert "Event already has value" in str(err.value) def testMemoryLeak(self): import gc thread_objs_before = [id(obj) for obj in gc.get_objects() if "threadpool" in str(type(obj))] def worker(): time.sleep(0.1) return "ok" def poolTest(): with ThreadPool.ThreadPool(5) as pool: for i in range(20): pool.spawn(worker) for i in range(5): poolTest() new_thread_objs = [obj for obj in gc.get_objects() if "threadpool" in str(type(obj)) and id(obj) not in thread_objs_before] #print("New objs:", new_thread_objs, "run:", num_run) # Make sure no threadpool object left behind assert not new_thread_objs ================================================ FILE: src/Test/TestTor.py ================================================ import time import pytest import mock from File import FileServer from Crypt import CryptRsa from Config import config @pytest.mark.usefixtures("resetSettings") @pytest.mark.usefixtures("resetTempSettings") class TestTor: def testDownload(self, tor_manager): for retry in range(15): time.sleep(1) if tor_manager.enabled and tor_manager.conn: break assert tor_manager.enabled def testManagerConnection(self, tor_manager): assert "250-version" in tor_manager.request("GETINFO version") def testAddOnion(self, tor_manager): # Add address = tor_manager.addOnion() assert address assert address in tor_manager.privatekeys # Delete assert tor_manager.delOnion(address) assert address not in tor_manager.privatekeys def testSignOnion(self, tor_manager): address = tor_manager.addOnion() # Sign sign = CryptRsa.sign(b"hello", tor_manager.getPrivatekey(address)) assert len(sign) == 128 # Verify publickey = CryptRsa.privatekeyToPublickey(tor_manager.getPrivatekey(address)) assert len(publickey) == 140 assert CryptRsa.verify(b"hello", publickey, sign) assert not CryptRsa.verify(b"not hello", publickey, sign) # Pub to address assert CryptRsa.publickeyToOnion(publickey) == address # Delete tor_manager.delOnion(address) @pytest.mark.slow def testConnection(self, tor_manager, file_server, site, site_temp): file_server.tor_manager.start_onions = True address = file_server.tor_manager.getOnion(site.address) assert address print("Connecting to", address) for retry in range(5): # Wait for hidden service creation time.sleep(10) try: connection = file_server.getConnection(address + ".onion", 1544) if connection: break except Exception as err: continue assert connection.handshake assert not connection.handshake["peer_id"] # No peer_id for Tor connections # Return the same connection without site specified assert file_server.getConnection(address + ".onion", 1544) == connection # No reuse for different site assert file_server.getConnection(address + ".onion", 1544, site=site) != connection assert file_server.getConnection(address + ".onion", 1544, site=site) == file_server.getConnection(address + ".onion", 1544, site=site) site_temp.address = "1OTHERSITE" assert file_server.getConnection(address + ".onion", 1544, site=site) != file_server.getConnection(address + ".onion", 1544, site=site_temp) # Only allow to query from the locked site file_server.sites[site.address] = site connection_locked = file_server.getConnection(address + ".onion", 1544, site=site) assert "body" in connection_locked.request("getFile", {"site": site.address, "inner_path": "content.json", "location": 0}) assert connection_locked.request("getFile", {"site": "1OTHERSITE", "inner_path": "content.json", "location": 0})["error"] == "Invalid site" def testPex(self, file_server, site, site_temp): # Register site to currently running fileserver site.connection_server = file_server file_server.sites[site.address] = site # Create a new file server to emulate new peer connecting to our peer file_server_temp = FileServer(file_server.ip, 1545) site_temp.connection_server = file_server_temp file_server_temp.sites[site_temp.address] = site_temp # We will request peers from this peer_source = site_temp.addPeer(file_server.ip, 1544) # Get ip4 peers from source site site.addPeer("1.2.3.4", 1555) # Add peer to source site assert peer_source.pex(need_num=10) == 1 assert len(site_temp.peers) == 2 assert "1.2.3.4:1555" in site_temp.peers # Get onion peers from source site site.addPeer("bka4ht2bzxchy44r.onion", 1555) assert "bka4ht2bzxchy44r.onion:1555" not in site_temp.peers # Don't add onion peers if not supported assert "onion" not in file_server_temp.supported_ip_types assert peer_source.pex(need_num=10) == 0 file_server_temp.supported_ip_types.append("onion") assert peer_source.pex(need_num=10) == 1 assert "bka4ht2bzxchy44r.onion:1555" in site_temp.peers def testFindHash(self, tor_manager, file_server, site, site_temp): file_server.ip_incoming = {} # Reset flood protection file_server.sites[site.address] = site file_server.tor_manager = tor_manager client = FileServer(file_server.ip, 1545) client.sites = {site_temp.address: site_temp} site_temp.connection_server = client # Add file_server as peer to client peer_file_server = site_temp.addPeer(file_server.ip, 1544) assert peer_file_server.findHashIds([1234]) == {} # Add fake peer with requred hash fake_peer_1 = site.addPeer("bka4ht2bzxchy44r.onion", 1544) fake_peer_1.hashfield.append(1234) fake_peer_2 = site.addPeer("1.2.3.5", 1545) fake_peer_2.hashfield.append(1234) fake_peer_2.hashfield.append(1235) fake_peer_3 = site.addPeer("1.2.3.6", 1546) fake_peer_3.hashfield.append(1235) fake_peer_3.hashfield.append(1236) res = peer_file_server.findHashIds([1234, 1235]) assert sorted(res[1234]) == [('1.2.3.5', 1545), ("bka4ht2bzxchy44r.onion", 1544)] assert sorted(res[1235]) == [('1.2.3.5', 1545), ('1.2.3.6', 1546)] # Test my address adding site.content_manager.hashfield.append(1234) res = peer_file_server.findHashIds([1234, 1235]) assert sorted(res[1234]) == [('1.2.3.5', 1545), (file_server.ip, 1544), ("bka4ht2bzxchy44r.onion", 1544)] assert sorted(res[1235]) == [('1.2.3.5', 1545), ('1.2.3.6', 1546)] def testSiteOnion(self, tor_manager): with mock.patch.object(config, "tor", "always"): assert tor_manager.getOnion("address1") != tor_manager.getOnion("address2") assert tor_manager.getOnion("address1") == tor_manager.getOnion("address1") ================================================ FILE: src/Test/TestTranslate.py ================================================ from Translate import Translate class TestTranslate: def testTranslateStrict(self): translate = Translate() data = """ translated = _("original") not_translated = "original" """ data_translated = translate.translateData(data, {"_(original)": "translated"}) assert 'translated = _("translated")' in data_translated assert 'not_translated = "original"' in data_translated def testTranslateStrictNamed(self): translate = Translate() data = """ translated = _("original", "original named") translated_other = _("original", "original other named") not_translated = "original" """ data_translated = translate.translateData(data, {"_(original, original named)": "translated"}) assert 'translated = _("translated")' in data_translated assert 'not_translated = "original"' in data_translated def testTranslateUtf8(self): translate = Translate() data = """ greeting = "Hi again árvztűrőtökörfúrógép!" """ data_translated = translate.translateData(data, {"Hi again árvztűrőtökörfúrógép!": "Üdv újra árvztűrőtökörfúrógép!"}) assert data_translated == """ greeting = "Üdv újra árvztűrőtökörfúrógép!" """ def testTranslateEscape(self): _ = Translate() _["Hello"] = "Szia" # Simple escaping data = "{_[Hello]} {username}!" username = "Hacker" data_translated = _(data) assert 'Szia' in data_translated assert '<' not in data_translated assert data_translated == "Szia Hacker<script>alert('boom')</script>!" # Escaping dicts user = {"username": "Hacker"} data = "{_[Hello]} {user[username]}!" data_translated = _(data) assert 'Szia' in data_translated assert '<' not in data_translated assert data_translated == "Szia Hacker<script>alert('boom')</script>!" # Escaping lists users = [{"username": "Hacker"}] data = "{_[Hello]} {users[0][username]}!" data_translated = _(data) assert 'Szia' in data_translated assert '<' not in data_translated assert data_translated == "Szia Hacker<script>alert('boom')</script>!" ================================================ FILE: src/Test/TestUiWebsocket.py ================================================ import sys import pytest @pytest.mark.usefixtures("resetSettings") class TestUiWebsocket: def testPermission(self, ui_websocket): res = ui_websocket.testAction("ping") assert res == "pong" res = ui_websocket.testAction("certList") assert "You don't have permission" in res["error"] ================================================ FILE: src/Test/TestUpnpPunch.py ================================================ import socket from urllib.parse import urlparse import pytest import mock from util import UpnpPunch as upnp @pytest.fixture def mock_socket(): mock_socket = mock.MagicMock() mock_socket.recv = mock.MagicMock(return_value=b'Hello') mock_socket.bind = mock.MagicMock() mock_socket.send_to = mock.MagicMock() return mock_socket @pytest.fixture def url_obj(): return urlparse('http://192.168.1.1/ctrlPoint.xml') @pytest.fixture(params=['WANPPPConnection', 'WANIPConnection']) def igd_profile(request): return """ urn:schemas-upnp-org:service:{}:1 urn:upnp-org:serviceId:wanpppc:pppoa /upnp/control/wanpppcpppoa /upnp/event/wanpppcpppoa /WANPPPConnection.xml """.format(request.param) @pytest.fixture def httplib_response(): class FakeResponse(object): def __init__(self, status=200, body='OK'): self.status = status self.body = body def read(self): return self.body return FakeResponse class TestUpnpPunch(object): def test_perform_m_search(self, mock_socket): local_ip = '127.0.0.1' with mock.patch('util.UpnpPunch.socket.socket', return_value=mock_socket): result = upnp.perform_m_search(local_ip) assert result == 'Hello' assert local_ip == mock_socket.bind.call_args_list[0][0][0][0] assert ('239.255.255.250', 1900) == mock_socket.sendto.call_args_list[0][0][1] def test_perform_m_search_socket_error(self, mock_socket): mock_socket.recv.side_effect = socket.error('Timeout error') with mock.patch('util.UpnpPunch.socket.socket', return_value=mock_socket): with pytest.raises(upnp.UpnpError): upnp.perform_m_search('127.0.0.1') def test_retrieve_location_from_ssdp(self, url_obj): ctrl_location = url_obj.geturl() parsed_location = urlparse(ctrl_location) rsp = ('auth: gibberish\r\nlocation: {0}\r\n' 'Content-Type: text/html\r\n\r\n').format(ctrl_location) result = upnp._retrieve_location_from_ssdp(rsp) assert result == parsed_location def test_retrieve_location_from_ssdp_no_header(self): rsp = 'auth: gibberish\r\nContent-Type: application/json\r\n\r\n' with pytest.raises(upnp.IGDError): upnp._retrieve_location_from_ssdp(rsp) def test_retrieve_igd_profile(self, url_obj): with mock.patch('urllib.request.urlopen') as mock_urlopen: upnp._retrieve_igd_profile(url_obj) mock_urlopen.assert_called_with(url_obj.geturl(), timeout=5) def test_retrieve_igd_profile_timeout(self, url_obj): with mock.patch('urllib.request.urlopen') as mock_urlopen: mock_urlopen.side_effect = socket.error('Timeout error') with pytest.raises(upnp.IGDError): upnp._retrieve_igd_profile(url_obj) def test_parse_igd_profile_service_type(self, igd_profile): control_path, upnp_schema = upnp._parse_igd_profile(igd_profile) assert control_path == '/upnp/control/wanpppcpppoa' assert upnp_schema in ('WANPPPConnection', 'WANIPConnection',) def test_parse_igd_profile_no_ctrlurl(self, igd_profile): igd_profile = igd_profile.replace('controlURL', 'nope') with pytest.raises(upnp.IGDError): control_path, upnp_schema = upnp._parse_igd_profile(igd_profile) def test_parse_igd_profile_no_schema(self, igd_profile): igd_profile = igd_profile.replace('Connection', 'nope') with pytest.raises(upnp.IGDError): control_path, upnp_schema = upnp._parse_igd_profile(igd_profile) def test_create_open_message_parsable(self): from xml.parsers.expat import ExpatError msg, _ = upnp._create_open_message('127.0.0.1', 8888) try: upnp.parseString(msg) except ExpatError as e: pytest.fail('Incorrect XML message: {}'.format(e)) def test_create_open_message_contains_right_stuff(self): settings = {'description': 'test desc', 'protocol': 'test proto', 'upnp_schema': 'test schema'} msg, fn_name = upnp._create_open_message('127.0.0.1', 8888, **settings) assert fn_name == 'AddPortMapping' assert '127.0.0.1' in msg assert '8888' in msg assert settings['description'] in msg assert settings['protocol'] in msg assert settings['upnp_schema'] in msg def test_parse_for_errors_bad_rsp(self, httplib_response): rsp = httplib_response(status=500) with pytest.raises(upnp.IGDError) as err: upnp._parse_for_errors(rsp) assert 'Unable to parse' in str(err.value) def test_parse_for_errors_error(self, httplib_response): soap_error = ('' '500' 'Bad request' '') rsp = httplib_response(status=500, body=soap_error) with pytest.raises(upnp.IGDError) as err: upnp._parse_for_errors(rsp) assert 'SOAP request error' in str(err.value) def test_parse_for_errors_good_rsp(self, httplib_response): rsp = httplib_response(status=200) assert rsp == upnp._parse_for_errors(rsp) def test_send_requests_success(self): with mock.patch( 'util.UpnpPunch._send_soap_request') as mock_send_request: mock_send_request.return_value = mock.MagicMock(status=200) upnp._send_requests(['msg'], None, None, None) assert mock_send_request.called def test_send_requests_failed(self): with mock.patch( 'util.UpnpPunch._send_soap_request') as mock_send_request: mock_send_request.return_value = mock.MagicMock(status=500) with pytest.raises(upnp.UpnpError): upnp._send_requests(['msg'], None, None, None) assert mock_send_request.called def test_collect_idg_data(self): pass @mock.patch('util.UpnpPunch._get_local_ips') @mock.patch('util.UpnpPunch._collect_idg_data') @mock.patch('util.UpnpPunch._send_requests') def test_ask_to_open_port_success(self, mock_send_requests, mock_collect_idg, mock_local_ips): mock_collect_idg.return_value = {'upnp_schema': 'schema-yo'} mock_local_ips.return_value = ['192.168.0.12'] result = upnp.ask_to_open_port(retries=5) soap_msg = mock_send_requests.call_args[0][0][0][0] assert result is True assert mock_collect_idg.called assert '192.168.0.12' in soap_msg assert '15441' in soap_msg assert 'schema-yo' in soap_msg @mock.patch('util.UpnpPunch._get_local_ips') @mock.patch('util.UpnpPunch._collect_idg_data') @mock.patch('util.UpnpPunch._send_requests') def test_ask_to_open_port_failure(self, mock_send_requests, mock_collect_idg, mock_local_ips): mock_local_ips.return_value = ['192.168.0.12'] mock_collect_idg.return_value = {'upnp_schema': 'schema-yo'} mock_send_requests.side_effect = upnp.UpnpError() with pytest.raises(upnp.UpnpError): upnp.ask_to_open_port() @mock.patch('util.UpnpPunch._collect_idg_data') @mock.patch('util.UpnpPunch._send_requests') def test_orchestrate_soap_request(self, mock_send_requests, mock_collect_idg): soap_mock = mock.MagicMock() args = ['127.0.0.1', 31337, soap_mock, 'upnp-test', {'upnp_schema': 'schema-yo'}] mock_collect_idg.return_value = args[-1] upnp._orchestrate_soap_request(*args[:-1]) assert mock_collect_idg.called soap_mock.assert_called_with( *args[:2] + ['upnp-test', 'UDP', 'schema-yo']) assert mock_send_requests.called @mock.patch('util.UpnpPunch._collect_idg_data') @mock.patch('util.UpnpPunch._send_requests') def test_orchestrate_soap_request_without_desc(self, mock_send_requests, mock_collect_idg): soap_mock = mock.MagicMock() args = ['127.0.0.1', 31337, soap_mock, {'upnp_schema': 'schema-yo'}] mock_collect_idg.return_value = args[-1] upnp._orchestrate_soap_request(*args[:-1]) assert mock_collect_idg.called soap_mock.assert_called_with(*args[:2] + [None, 'UDP', 'schema-yo']) assert mock_send_requests.called def test_create_close_message_parsable(self): from xml.parsers.expat import ExpatError msg, _ = upnp._create_close_message('127.0.0.1', 8888) try: upnp.parseString(msg) except ExpatError as e: pytest.fail('Incorrect XML message: {}'.format(e)) def test_create_close_message_contains_right_stuff(self): settings = {'protocol': 'test proto', 'upnp_schema': 'test schema'} msg, fn_name = upnp._create_close_message('127.0.0.1', 8888, ** settings) assert fn_name == 'DeletePortMapping' assert '8888' in msg assert settings['protocol'] in msg assert settings['upnp_schema'] in msg @mock.patch('util.UpnpPunch._get_local_ips') @mock.patch('util.UpnpPunch._orchestrate_soap_request') def test_communicate_with_igd_success(self, mock_orchestrate, mock_get_local_ips): mock_get_local_ips.return_value = ['192.168.0.12'] upnp._communicate_with_igd() assert mock_get_local_ips.called assert mock_orchestrate.called @mock.patch('util.UpnpPunch._get_local_ips') @mock.patch('util.UpnpPunch._orchestrate_soap_request') def test_communicate_with_igd_succeed_despite_single_failure( self, mock_orchestrate, mock_get_local_ips): mock_get_local_ips.return_value = ['192.168.0.12'] mock_orchestrate.side_effect = [upnp.UpnpError, None] upnp._communicate_with_igd(retries=2) assert mock_get_local_ips.called assert mock_orchestrate.called @mock.patch('util.UpnpPunch._get_local_ips') @mock.patch('util.UpnpPunch._orchestrate_soap_request') def test_communicate_with_igd_total_failure(self, mock_orchestrate, mock_get_local_ips): mock_get_local_ips.return_value = ['192.168.0.12'] mock_orchestrate.side_effect = [upnp.UpnpError, upnp.IGDError] with pytest.raises(upnp.UpnpError): upnp._communicate_with_igd(retries=2) assert mock_get_local_ips.called assert mock_orchestrate.called ================================================ FILE: src/Test/TestUser.py ================================================ import pytest from Crypt import CryptBitcoin @pytest.mark.usefixtures("resetSettings") class TestUser: def testAddress(self, user): assert user.master_address == "15E5rhcAUD69WbiYsYARh4YHJ4sLm2JEyc" address_index = 1458664252141532163166741013621928587528255888800826689784628722366466547364755811 assert user.getAddressAuthIndex("15E5rhcAUD69WbiYsYARh4YHJ4sLm2JEyc") == address_index # Re-generate privatekey based on address_index def testNewSite(self, user): address, address_index, site_data = user.getNewSiteData() # Create a new random site assert CryptBitcoin.hdPrivatekey(user.master_seed, address_index) == site_data["privatekey"] user.sites = {} # Reset user data # Site address and auth address is different assert user.getSiteData(address)["auth_address"] != address # Re-generate auth_privatekey for site assert user.getSiteData(address)["auth_privatekey"] == site_data["auth_privatekey"] def testAuthAddress(self, user): # Auth address without Cert auth_address = user.getAuthAddress("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr") assert auth_address == "1MyJgYQjeEkR9QD66nkfJc9zqi9uUy5Lr2" auth_privatekey = user.getAuthPrivatekey("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr") assert CryptBitcoin.privatekeyToAddress(auth_privatekey) == auth_address def testCert(self, user): cert_auth_address = user.getAuthAddress("1iD5ZQJMNXu43w1qLB8sfdHVKppVMduGz") # Add site to user's registry # Add cert user.addCert(cert_auth_address, "zeroid.bit", "faketype", "fakeuser", "fakesign") user.setCert("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr", "zeroid.bit") # By using certificate the auth address should be same as the certificate provider assert user.getAuthAddress("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr") == cert_auth_address auth_privatekey = user.getAuthPrivatekey("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr") assert CryptBitcoin.privatekeyToAddress(auth_privatekey) == cert_auth_address # Test delete site data assert "1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr" in user.sites user.deleteSiteData("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr") assert "1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr" not in user.sites # Re-create add site should generate normal, unique auth_address assert not user.getAuthAddress("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr") == cert_auth_address assert user.getAuthAddress("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr") == "1MyJgYQjeEkR9QD66nkfJc9zqi9uUy5Lr2" ================================================ FILE: src/Test/TestWeb.py ================================================ import urllib.request import pytest try: from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support.expected_conditions import staleness_of, title_is from selenium.common.exceptions import NoSuchElementException except: pass class WaitForPageLoad(object): def __init__(self, browser): self.browser = browser def __enter__(self): self.old_page = self.browser.find_element_by_tag_name('html') def __exit__(self, *args): WebDriverWait(self.browser, 10).until(staleness_of(self.old_page)) def getContextUrl(browser): return browser.execute_script("return window.location.toString()") def getUrl(url): content = urllib.request.urlopen(url).read() assert "server error" not in content.lower(), "Got a server error! " + repr(url) return content @pytest.mark.usefixtures("resetSettings") @pytest.mark.webtest class TestWeb: def testFileSecurity(self, site_url): assert "Not Found" in getUrl("%s/media/sites.json" % site_url) assert "Forbidden" in getUrl("%s/media/./sites.json" % site_url) assert "Forbidden" in getUrl("%s/media/../config.py" % site_url) assert "Forbidden" in getUrl("%s/media/1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr/../sites.json" % site_url) assert "Forbidden" in getUrl("%s/media/1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr/..//sites.json" % site_url) assert "Forbidden" in getUrl("%s/media/1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr/../../zeronet.py" % site_url) assert "Not Found" in getUrl("%s/raw/sites.json" % site_url) assert "Forbidden" in getUrl("%s/raw/./sites.json" % site_url) assert "Forbidden" in getUrl("%s/raw/../config.py" % site_url) assert "Forbidden" in getUrl("%s/raw/1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr/../sites.json" % site_url) assert "Forbidden" in getUrl("%s/raw/1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr/..//sites.json" % site_url) assert "Forbidden" in getUrl("%s/raw/1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr/../../zeronet.py" % site_url) assert "Forbidden" in getUrl("%s/1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr/../sites.json" % site_url) assert "Forbidden" in getUrl("%s/1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr/..//sites.json" % site_url) assert "Forbidden" in getUrl("%s/1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr/../../zeronet.py" % site_url) assert "Forbidden" in getUrl("%s/content.db" % site_url) assert "Forbidden" in getUrl("%s/./users.json" % site_url) assert "Forbidden" in getUrl("%s/./key-rsa.pem" % site_url) assert "Forbidden" in getUrl("%s/././././././././././//////sites.json" % site_url) def testLinkSecurity(self, browser, site_url): browser.get("%s/1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr/test/security.html" % site_url) WebDriverWait(browser, 10).until(title_is("ZeroHello - ZeroNet")) assert getContextUrl(browser) == "%s/1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr/test/security.html" % site_url # Switch to inner frame browser.switch_to.frame(browser.find_element_by_id("inner-iframe")) assert "wrapper_nonce" in getContextUrl(browser) assert browser.find_element_by_id("script_output").text == "Result: Works" browser.switch_to.default_content() # Clicking on links without target browser.switch_to.frame(browser.find_element_by_id("inner-iframe")) with WaitForPageLoad(browser): browser.find_element_by_id("link_to_current").click() assert "wrapper_nonce" not in getContextUrl(browser) # The browser object back to default content assert "Forbidden" not in browser.page_source # Check if we have frame inside frame browser.switch_to.frame(browser.find_element_by_id("inner-iframe")) with pytest.raises(NoSuchElementException): assert not browser.find_element_by_id("inner-iframe") browser.switch_to.default_content() # Clicking on link with target=_top browser.switch_to.frame(browser.find_element_by_id("inner-iframe")) with WaitForPageLoad(browser): browser.find_element_by_id("link_to_top").click() assert "wrapper_nonce" not in getContextUrl(browser) # The browser object back to default content assert "Forbidden" not in browser.page_source browser.switch_to.default_content() # Try to escape from inner_frame browser.switch_to.frame(browser.find_element_by_id("inner-iframe")) assert "wrapper_nonce" in getContextUrl(browser) # Make sure we are inside of the inner-iframe with WaitForPageLoad(browser): browser.execute_script("window.top.location = window.location") assert "wrapper_nonce" in getContextUrl(browser) # We try to use nonce-ed html without iframe assert " 0.1: line_marker = "!" elif since_last > 0.02: line_marker = "*" elif since_last > 0.01: line_marker = "-" else: line_marker = " " since_start = time.time() - time_start record.since_start = "%s%.3fs" % (line_marker, since_start) self.time_last = time.time() return True log = logging.getLogger() fmt = logging.Formatter(fmt='%(since_start)s %(thread_marker)s %(levelname)-8s %(name)s %(message)s %(thread_title)s') [hndl.addFilter(TimeFilter()) for hndl in log.handlers] [hndl.setFormatter(fmt) for hndl in log.handlers] from Site.Site import Site from Site import SiteManager from User import UserManager from File import FileServer from Connection import ConnectionServer from Crypt import CryptConnection from Crypt import CryptBitcoin from Ui import UiWebsocket from Tor import TorManager from Content import ContentDb from util import RateLimit from Db import Db from Debug import Debug gevent.get_hub().NOT_ERROR += (Debug.Notify,) def cleanup(): Db.dbCloseAll() for dir_path in [config.data_dir, config.data_dir + "-temp"]: if os.path.isdir(dir_path): for file_name in os.listdir(dir_path): ext = file_name.rsplit(".", 1)[-1] if ext not in ["csr", "pem", "srl", "db", "json", "tmp"]: continue file_path = dir_path + "/" + file_name if os.path.isfile(file_path): os.unlink(file_path) atexit_register(cleanup) @pytest.fixture(scope="session") def resetSettings(request): open("%s/sites.json" % config.data_dir, "w").write("{}") open("%s/filters.json" % config.data_dir, "w").write("{}") open("%s/users.json" % config.data_dir, "w").write(""" { "15E5rhcAUD69WbiYsYARh4YHJ4sLm2JEyc": { "certs": {}, "master_seed": "024bceac1105483d66585d8a60eaf20aa8c3254b0f266e0d626ddb6114e2949a", "sites": {} } } """) @pytest.fixture(scope="session") def resetTempSettings(request): data_dir_temp = config.data_dir + "-temp" if not os.path.isdir(data_dir_temp): os.mkdir(data_dir_temp) open("%s/sites.json" % data_dir_temp, "w").write("{}") open("%s/filters.json" % data_dir_temp, "w").write("{}") open("%s/users.json" % data_dir_temp, "w").write(""" { "15E5rhcAUD69WbiYsYARh4YHJ4sLm2JEyc": { "certs": {}, "master_seed": "024bceac1105483d66585d8a60eaf20aa8c3254b0f266e0d626ddb6114e2949a", "sites": {} } } """) def cleanup(): os.unlink("%s/sites.json" % data_dir_temp) os.unlink("%s/users.json" % data_dir_temp) os.unlink("%s/filters.json" % data_dir_temp) request.addfinalizer(cleanup) @pytest.fixture() def site(request): threads_before = [obj for obj in gc.get_objects() if isinstance(obj, gevent.Greenlet)] # Reset ratelimit RateLimit.queue_db = {} RateLimit.called_db = {} site = Site("1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT") # Always use original data assert "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT" in site.storage.getPath("") # Make sure we dont delete everything shutil.rmtree(site.storage.getPath(""), True) shutil.copytree(site.storage.getPath("") + "-original", site.storage.getPath("")) # Add to site manager SiteManager.site_manager.get("1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT") site.announce = mock.MagicMock(return_value=True) # Don't try to find peers from the net def cleanup(): site.delete() site.content_manager.contents.db.close("Test cleanup") site.content_manager.contents.db.timer_check_optional.kill() SiteManager.site_manager.sites.clear() db_path = "%s/content.db" % config.data_dir os.unlink(db_path) del ContentDb.content_dbs[db_path] gevent.killall([obj for obj in gc.get_objects() if isinstance(obj, gevent.Greenlet) and obj not in threads_before]) request.addfinalizer(cleanup) site.greenlet_manager.stopGreenlets() site = Site("1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT") # Create new Site object to load content.json files if not SiteManager.site_manager.sites: SiteManager.site_manager.sites = {} SiteManager.site_manager.sites["1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT"] = site site.settings["serving"] = True return site @pytest.fixture() def site_temp(request): threads_before = [obj for obj in gc.get_objects() if isinstance(obj, gevent.Greenlet)] with mock.patch("Config.config.data_dir", config.data_dir + "-temp"): site_temp = Site("1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT") site_temp.settings["serving"] = True site_temp.announce = mock.MagicMock(return_value=True) # Don't try to find peers from the net def cleanup(): site_temp.delete() site_temp.content_manager.contents.db.close("Test cleanup") site_temp.content_manager.contents.db.timer_check_optional.kill() db_path = "%s-temp/content.db" % config.data_dir os.unlink(db_path) del ContentDb.content_dbs[db_path] gevent.killall([obj for obj in gc.get_objects() if isinstance(obj, gevent.Greenlet) and obj not in threads_before]) request.addfinalizer(cleanup) site_temp.log = logging.getLogger("Temp:%s" % site_temp.address_short) return site_temp @pytest.fixture(scope="session") def user(): user = UserManager.user_manager.get() if not user: user = UserManager.user_manager.create() user.sites = {} # Reset user data return user @pytest.fixture(scope="session") def browser(request): try: from selenium import webdriver print("Starting chromedriver...") options = webdriver.chrome.options.Options() options.add_argument("--headless") options.add_argument("--window-size=1920x1080") options.add_argument("--log-level=1") browser = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, service_log_path=os.path.devnull, options=options) def quit(): browser.quit() request.addfinalizer(quit) except Exception as err: raise pytest.skip("Test requires selenium + chromedriver: %s" % err) return browser @pytest.fixture(scope="session") def site_url(): try: urllib.request.urlopen(SITE_URL).read() except Exception as err: raise pytest.skip("Test requires zeronet client running: %s" % err) return SITE_URL @pytest.fixture(params=['ipv4', 'ipv6']) def file_server(request): if request.param == "ipv4": return request.getfixturevalue("file_server4") else: return request.getfixturevalue("file_server6") @pytest.fixture def file_server4(request): time.sleep(0.1) file_server = FileServer("127.0.0.1", 1544) file_server.ip_external = "1.2.3.4" # Fake external ip def listen(): ConnectionServer.start(file_server) ConnectionServer.listen(file_server) gevent.spawn(listen) # Wait for port opening for retry in range(10): time.sleep(0.1) # Port opening try: conn = file_server.getConnection("127.0.0.1", 1544) conn.close() break except Exception as err: print("FileServer6 startup error", Debug.formatException(err)) assert file_server.running file_server.ip_incoming = {} # Reset flood protection def stop(): file_server.stop() request.addfinalizer(stop) return file_server @pytest.fixture def file_server6(request): try: sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) sock.connect(("::1", 80, 1, 1)) has_ipv6 = True except OSError: has_ipv6 = False if not has_ipv6: pytest.skip("Ipv6 not supported") time.sleep(0.1) file_server6 = FileServer("::1", 1544) file_server6.ip_external = 'fca5:95d6:bfde:d902:8951:276e:1111:a22c' # Fake external ip def listen(): ConnectionServer.start(file_server6) ConnectionServer.listen(file_server6) gevent.spawn(listen) # Wait for port opening for retry in range(10): time.sleep(0.1) # Port opening try: conn = file_server6.getConnection("::1", 1544) conn.close() break except Exception as err: print("FileServer6 startup error", Debug.formatException(err)) assert file_server6.running file_server6.ip_incoming = {} # Reset flood protection def stop(): file_server6.stop() request.addfinalizer(stop) return file_server6 @pytest.fixture() def ui_websocket(site, user): class WsMock: def __init__(self): self.result = gevent.event.AsyncResult() def send(self, data): logging.debug("WsMock: Set result (data: %s) called by %s" % (data, Debug.formatStack())) self.result.set(json.loads(data)["result"]) def getResult(self): logging.debug("WsMock: Get result") back = self.result.get() logging.debug("WsMock: Got result (data: %s)" % back) self.result = gevent.event.AsyncResult() return back ws_mock = WsMock() ui_websocket = UiWebsocket(ws_mock, site, None, user, None) def testAction(action, *args, **kwargs): ui_websocket.handleRequest({"id": 0, "cmd": action, "params": list(args) if args else kwargs}) return ui_websocket.ws.getResult() ui_websocket.testAction = testAction return ui_websocket @pytest.fixture(scope="session") def tor_manager(): try: tor_manager = TorManager(fileserver_port=1544) tor_manager.start() assert tor_manager.conn is not None tor_manager.startOnions() except Exception as err: raise pytest.skip("Test requires Tor with ControlPort: %s, %s" % (config.tor_controller, err)) return tor_manager @pytest.fixture() def db(request): db_path = "%s/zeronet.db" % config.data_dir schema = { "db_name": "TestDb", "db_file": "%s/zeronet.db" % config.data_dir, "maps": { "data.json": { "to_table": [ "test", {"node": "test", "table": "test_importfilter", "import_cols": ["test_id", "title"]} ] } }, "tables": { "test": { "cols": [ ["test_id", "INTEGER"], ["title", "TEXT"], ["json_id", "INTEGER REFERENCES json (json_id)"] ], "indexes": ["CREATE UNIQUE INDEX test_id ON test(test_id)"], "schema_changed": 1426195822 }, "test_importfilter": { "cols": [ ["test_id", "INTEGER"], ["title", "TEXT"], ["json_id", "INTEGER REFERENCES json (json_id)"] ], "indexes": ["CREATE UNIQUE INDEX test_importfilter_id ON test_importfilter(test_id)"], "schema_changed": 1426195822 } } } if os.path.isfile(db_path): os.unlink(db_path) db = Db.Db(schema, db_path) db.checkTables() def stop(): db.close("Test db cleanup") os.unlink(db_path) request.addfinalizer(stop) return db @pytest.fixture(params=["sslcrypto", "sslcrypto_fallback", "libsecp256k1"]) def crypt_bitcoin_lib(request, monkeypatch): monkeypatch.setattr(CryptBitcoin, "lib_verify_best", request.param) CryptBitcoin.loadLib(request.param) return CryptBitcoin @pytest.fixture(scope='function', autouse=True) def logCaseStart(request): global time_start time_start = time.time() logging.debug("---- Start test case: %s ----" % request._pyfuncitem) yield None # Wait until all test done # Workaround for pytest bug when logging in atexit/post-fixture handlers (I/O operation on closed file) def workaroundPytestLogError(): import _pytest.capture write_original = _pytest.capture.EncodedFile.write def write_patched(obj, *args, **kwargs): try: write_original(obj, *args, **kwargs) except ValueError as err: if str(err) == "I/O operation on closed file": pass else: raise err def flush_patched(obj, *args, **kwargs): try: obj.buffer.flush(*args, **kwargs) except ValueError as err: if str(err).startswith("I/O operation on closed file"): pass else: raise err _pytest.capture.EncodedFile.write = write_patched _pytest.capture.EncodedFile.flush = flush_patched workaroundPytestLogError() @pytest.fixture(scope='session', autouse=True) def disableLog(): yield None # Wait until all test done logging.getLogger('').setLevel(logging.getLevelName(logging.CRITICAL)) ================================================ FILE: src/Test/coverage.ini ================================================ [run] branch = True concurrency = gevent omit = src/lib/* src/Test/* [report] exclude_lines = pragma: no cover if __name__ == .__main__.: if config.debug: if config.debug_socket: if self.logging: def __repr__ ================================================ FILE: src/Test/pytest.ini ================================================ [pytest] python_files = Test*.py addopts = -rsxX -v --durations=6 --no-print-logs --capture=fd markers = slow: mark a tests as slow. webtest: mark a test as a webtest. ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/content.json ================================================ { "address": "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT", "background-color": "white", "description": "Blogging platform Demo", "domain": "Blog.ZeroNetwork.bit", "files": { "css/all.css": { "sha512": "65ddd3a2071a0f48c34783aa3b1bde4424bdea344630af05a237557a62bd55dc", "size": 112710 }, "data-default/data.json": { "sha512": "3f5c5a220bde41b464ab116cce0bd670dd0b4ff5fe4a73d1dffc4719140038f2", "size": 196 }, "data-default/users/content-default.json": { "sha512": "0603ce08f7abb92b3840ad0cf40e95ea0b3ed3511b31524d4d70e88adba83daa", "size": 679 }, "data/data.json": { "sha512": "0f2321c905b761a05c360a389e1de149d952b16097c4ccf8310158356e85fb52", "size": 31126 }, "data/img/autoupdate.png": { "sha512": "d2b4dc8e0da2861ea051c0c13490a4eccf8933d77383a5b43de447c49d816e71", "size": 24460 }, "data/img/direct_domains.png": { "sha512": "5f14b30c1852735ab329b22496b1e2ea751cb04704789443ad73a70587c59719", "size": 16185 }, "data/img/domain.png": { "sha512": "ce87e0831f4d1e95a95d7120ca4d33f8273c6fce9f5bbedf7209396ea0b57b6a", "size": 11881 }, "data/img/memory.png": { "sha512": "dd56515085b4a79b5809716f76f267ec3a204be3ee0d215591a77bf0f390fa4e", "size": 12775 }, "data/img/multiuser.png": { "sha512": "88e3f795f9b86583640867897de6efc14e1aa42f93e848ed1645213e6cc210c6", "size": 29480 }, "data/img/progressbar.png": { "sha512": "23d592ae386ce14158cec34d32a3556771725e331c14d5a4905c59e0fe980ebf", "size": 13294 }, "data/img/slides.png": { "sha512": "1933db3b90ab93465befa1bd0843babe38173975e306286e08151be9992f767e", "size": 14439 }, "data/img/slots_memory.png": { "sha512": "82a250e6da909d7f66341e5b5c443353958f86728cd3f06e988b6441e6847c29", "size": 9488 }, "data/img/trayicon.png": { "sha512": "e7ae65bf280f13fb7175c1293dad7d18f1fcb186ebc9e1e33850cdaccb897b8f", "size": 19040 }, "dbschema.json": { "sha512": "2e9466d8aa1f340c91203b4ddbe9b6669879616a1b8e9571058a74195937598d", "size": 1527 }, "img/loading.gif": { "sha512": "8a42b98962faea74618113166886be488c09dad10ca47fe97005edc5fb40cc00", "size": 723 }, "index.html": { "sha512": "c4039ebfc4cb6f116cac05e803a18644ed70404474a572f0d8473f4572f05df3", "size": 4667 }, "js/all.js": { "sha512": "034c97535f3c9b3fbebf2dcf61a38711dae762acf1a99168ae7ddc7e265f582c", "size": 201178 } }, "files_optional": { "data/img/zeroblog-comments.png": { "sha512": "efe4e815a260e555303e5c49e550a689d27a8361f64667bd4a91dbcccb83d2b4", "size": 24001 }, "data/img/zeroid.png": { "sha512": "b46d541a9e51ba2ddc8a49955b7debbc3b45fd13467d3c20ef104e9d938d052b", "size": 18875 }, "data/img/zeroname.png": { "sha512": "bab45a1bb2087b64e4f69f756b2ffa5ad39b7fdc48c83609cdde44028a7a155d", "size": 36031 }, "data/img/zerotalk-mark.png": { "sha512": "a335b2fedeb8d291ca68d3091f567c180628e80f41de4331a5feb19601d078af", "size": 44862 }, "data/img/zerotalk-upvote.png": { "sha512": "b1ffd7f948b4f99248dde7efe256c2efdfd997f7e876fb9734f986ef2b561732", "size": 41092 }, "data/img/zerotalk.png": { "sha512": "54d10497a1ffca9a4780092fd1bd158c15f639856d654d2eb33a42f9d8e33cd8", "size": 26606 }, "data/optional.txt": { "sha512": "c6f81db0e9f8206c971c9e5826e3ba823ffbb1a3a900f8047652a8bf78ea98fd", "size": 6 } }, "ignore": "((js|css)/(?!all.(js|css))|data/.*db|data/users/.*/.*|data/test_include/.*)", "includes": { "data/test_include/content.json": { "added": 1424976057, "files_allowed": "data.json", "includes_allowed": false, "max_size": 20000, "signers": ["15ik6LeBWnACWfaika1xqGapRZ1zh3JpCo"], "signers_required": 1, "user_id": 47, "user_name": "test" }, "data/users/content.json": { "signers": ["1LSxsKfC9S9TVXGGNSM3vPHjyW82jgCX5f"], "signers_required": 1 } }, "inner_path": "content.json", "modified": 1503257990, "optional": "(data/img/zero.*|data/optional.*)", "signers_sign": "HDNmWJHM2diYln4pkdL+qYOvgE7MdwayzeG+xEUZBgp1HtOjBJS+knDEVQsBkjcOPicDG2it1r6R1eQrmogqSP0=", "signs": { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": "G4Uq365UBliQG66ygip1jNGYqW6Eh9Mm7nLguDFqAgk/Hksq/ruqMf9rXv78mgUfPBvL2+XgDKYvFDtlykPFZxk=" }, "signs_required": 1, "title": "ZeroBlog", "zeronet_version": "0.5.7" } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/css/all.css ================================================ /* ---- data/1Hb9rY98TNnA6TYeozJv4w36bqEiBn6x8Y/css/Comments.css ---- */ .comments { margin-bottom: 60px } .comment { background-color: white; padding: 25px 0px; margin: 1px; border-top: 1px solid #EEE } .comment .user_name { font-size: 14px; font-weight: bold } .comment .added { color: #AAA } .comment .reply { color: #CCC; opacity: 0; -webkit-transition: opacity 0.3s; -moz-transition: opacity 0.3s; -o-transition: opacity 0.3s; -ms-transition: opacity 0.3s; transition: opacity 0.3s ; border: none } .comment:hover .reply { opacity: 1 } .comment .reply .icon { opacity: 0.3 } .comment .reply:hover { border-bottom: none; color: #666 } .comment .reply:hover .icon { opacity: 1 } .comment .info { font-size: 12px; color: #AAA; margin-bottom: 7px } .comment .info .score { margin-left: 5px } .comment .comment-body { line-height: 1.5em; margin-top: 0.5em; margin-bottom: 0.5em } .comment .comment-body p { margin-bottom: 0px; margin-top: 0.5em; } .comment .comment-body p:first-child { margin: 0px; margin-top: 0px; } .comment .comment-body.editor { margin-top: 0.5em !important; margin-bottom: 0.5em !important } .comment .comment-body h1, .comment .body h2, .comment .body h3 { font-size: 110% } .comment .comment-body blockquote { padding: 1px 15px; border-left: 2px solid #E7E7E7; margin: 0px; margin-top: 30px } .comment .comment-body blockquote:first-child { margin-top: 0px } .comment .comment-body blockquote p { margin: 0px; color: #999; font-size: 90% } .comment .comment-body blockquote a { color: #333; font-weight: normal; border-bottom: 0px } .comment .comment-body blockquote a:hover { border-bottom: 1px solid #999 } .comment .editable-edit { margin-top: -5px } .comment-new { margin-bottom: 5px; border-top: 0px } .comment-new .button-submit { margin: 0px; font-weight: normal; padding: 5px 15px; display: inline-block; background-color: #FFF85F; border-bottom: 2px solid #CDBD1E; font-size: 15px; line-height: 30px } .comment-new h2 { margin-bottom: 25px } /* Input */ .comment-new textarea { line-height: 1.5em; width: 100%; padding: 10px; font-family: 'Roboto', sans-serif; font-size: 16px; -webkit-transition: border 0.3s; -moz-transition: border 0.3s; -o-transition: border 0.3s; -ms-transition: border 0.3s; transition: border 0.3s ; border: 2px solid #eee; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; overflow-y: auto } input.text:focus, textarea:focus { border-color: #5FC0EA; outline: none; background-color: white } .comment-nocert textarea { opacity: 0.5; pointer-events: none } .comment-nocert .info { opacity: 0.1; pointer-events: none } .comment-nocert .button-submit-comment { opacity: 0.1; pointer-events: none } .comment-nocert .button.button-certselect { display: inherit } .button.button-certselect { position: absolute; left: 50%; white-space: nowrap; -webkit-transform: translateX(-50%); -moz-transform: translateX(-50%); -o-transform: translateX(-50%); -ms-transform: translateX(-50%); transform: translateX(-50%) ; z-index: 99; margin-top: 13px; background-color: #007AFF; color: white; border-bottom-color: #3543F9; display: none } .button.button-certselect:hover { background-color: #3396FF; color: white; border-bottom-color: #5D68FF; } .button.button-certselect:active { position: absolute; -webkit-transform: translateX(-50%) translateY(1px); -moz-transform: translateX(-50%) translateY(1px); -o-transform: translateX(-50%) translateY(1px); -ms-transform: translateX(-50%) translateY(1px); transform: translateX(-50%) translateY(1px) ; top: auto; } .user-size { font-size: 11px; margin-top: 6px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; text-transform: uppercase; display: inline-block; color: #AAA } .user-size-used { position: absolute; color: #B10DC9; overflow: hidden; width: 40px; white-space: nowrap } /* ---- data/1Hb9rY98TNnA6TYeozJv4w36bqEiBn6x8Y/css/ZeroBlog.css ---- */ /* Design based on medium */ body { background-color: white; color: #333332; margin: 10px; padding: 0px; font-family: 'Roboto', sans-serif; height: 15000px; overflow: hidden } body.loaded { height: auto; overflow: auto } h1, h2, h3, h4 { font-family: 'Roboto', sans-serif; font-weight: normal; margin: 0px; padding: 0px } h1 { font-size: 32px; line-height: 1.2em; font-weight: bold; letter-spacing: -0.5px; margin-bottom: 5px } h2 { margin-top: 3em } h3 { font-size: 24px; margin-top: 2em } h1 + h2, h2 + h3 { margin-top: inherit } p { margin-top: 0.9em; margin-bottom: 0.9em } hr { margin: 20px 0px; border: none; border-bottom: 1px solid #eee; margin-left: auto; margin-right: auto; width: 120px; } small { font-size: 80%; color: #999; } a { border-bottom: 1px solid #3498db; text-decoration: none; color: black; font-weight: bold } a.nolink { border-bottom: none } a:hover { color: #3498db } .button { padding: 5px 10px; margin-left: 10px; background-color: #DDE0E0; border-bottom: 2px solid #999998; background-position: left center; -webkit-border-radius: 2px; -moz-border-radius: 2px; -o-border-radius: 2px; -ms-border-radius: 2px; border-radius: 2px ; text-decoration: none; -webkit-transition: all 0.5s ease-out; -moz-transition: all 0.5s ease-out; -o-transition: all 0.5s ease-out; -ms-transition: all 0.5s ease-out; transition: all 0.5s ease-out ; color: #333 } .button:hover { background-color: #FFF400; border-color: white; border-bottom: 2px solid #4D4D4C; -webkit-transition: none; -moz-transition: none; -o-transition: none; -ms-transition: none; transition: none ; color: inherit } .button:active { position: relative; top: 1px } /*.button-delete { background-color: #e74c3c; border-bottom-color: #A83F34; color: white }*/ .button-outline { background-color: white; color: #DDD; border: 1px solid #eee } .button-delete:hover { background-color: #FF5442; border: 1px solid #FF5442; color: white } .button-ok:hover { background-color: #27AE60; border: 1px solid #27AE60; color: white } .button.loading { color: rgba(0,0,0,0); background: #999 url(../img/loading.gif) no-repeat center center; -webkit-transition: all 0.5s ease-out; -moz-transition: all 0.5s ease-out; -o-transition: all 0.5s ease-out; -ms-transition: all 0.5s ease-out; transition: all 0.5s ease-out ; pointer-events: none; border-bottom: 2px solid #666 } .cancel { margin-left: 10px; font-size: 80%; color: #999; } .template { display: none } /* Editable */ .editable { outline: none } .editable-edit:hover { opacity: 1; border: none; color: #333 } .editable-edit { opacity: 0; float: left; margin-top: 0px; margin-left: -40px; padding: 8px 20px; -webkit-transition: all 0.3s; -moz-transition: all 0.3s; -o-transition: all 0.3s; -ms-transition: all 0.3s; transition: all 0.3s ; width: 0px; display: inline-block; padding-right: 0px; color: rgba(100,100,100,0.5); text-decoration: none; font-size: 18px; font-weight: normal; border: none; } /*.editing { white-space: pre-wrap; z-index: 1; position: relative; outline: 10000px solid rgba(255,255,255,0.9) !important; } .editing p { margin: 0px; padding: 0px }*/ /* IE FIX */ .editor { width: 100%; display: block; overflow :hidden; resize: none; border: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; z-index: 900; position: relative } .editor:focus { border: 0px; outline-offset: 0px } /* -- Editbar -- */ .bottombar { display: none; position: fixed; padding: 10px 20px; opacity: 0; background-color: rgba(255,255,255,0.9); right: 30px; bottom: 0px; z-index: 999; -webkit-transition: all 0.3s; -moz-transition: all 0.3s; -o-transition: all 0.3s; -ms-transition: all 0.3s; transition: all 0.3s ; transform: translateY(50px) } .bottombar.visible { -webkit-transform: translateY(0px); -moz-transform: translateY(0px); -o-transform: translateY(0px); -ms-transform: translateY(0px); transform: translateY(0px) ; opacity: 1 } .publishbar { z-index: 990} .publishbar.visible { display: inline-block; } .editbar { -webkit-perspective: 900px ; -moz-perspective: 900px ; -o-perspective: 900px ; -ms-perspective: 900px ; perspective: 900px } .markdown-help { position: absolute; bottom: 30px; -webkit-transform: translateX(0px) rotateY(-40deg); -moz-transform: translateX(0px) rotateY(-40deg); -o-transform: translateX(0px) rotateY(-40deg); -ms-transform: translateX(0px) rotateY(-40deg); transform: translateX(0px) rotateY(-40deg) ; transform-origin: right; right: 0px; list-style-type: none; background-color: rgba(255,255,255,0.9); padding: 10px; opacity: 0; -webkit-transition: all 0.6s; -moz-transition: all 0.6s; -o-transition: all 0.6s; -ms-transition: all 0.6s; transition: all 0.6s ; display: none } .markdown-help.visible { -webkit-transform: none; -moz-transform: none; -o-transform: none; -ms-transform: none; transform: none ; opacity: 1 } .markdown-help li { margin: 10px 0px } .markdown-help code { font-size: 100% } .icon-help { border: 1px solid #EEE; padding: 2px; display: inline-block; width: 17px; text-align: center; font-size: 13px; margin-right: 6px; vertical-align: 1px } .icon-help.active { background-color: #EEE } /* -- Left -- */ .left { float: left; position: absolute; width: 170px; padding-left: 60px; padding-right: 20px; margin-top: 60px; text-align: right } .right { float: left; padding-left: 60px; margin-left: 240px; max-width: 650px; padding-right: 60px; padding-top: 60px } .left .avatar { background-color: #F0F0F0; width: 60px; height: 60px; -webkit-border-radius: 100%; -moz-border-radius: 100%; -o-border-radius: 100%; -ms-border-radius: 100%; border-radius: 100% ; margin-bottom: 10px; background-position: center center; background-size: 70%; display: inline-block; } .left h1 a.nolink { font-family: Tinos; display: inline-block; padding: 1px } .left h1 a.editable-edit { float: none } .left h2 { font-size: 15px; font-family: Tinos; line-height: 1.6em; color: #AAA; margin-top: 14px; letter-spacing: 0.2px } .left ul, .left li { padding: 0px; margin: 0px; list-style-type: none; line-height: 2em } .left hr { margin-left: 100px; margin-right: 0px; width: auto } .left .links { width: 230px; margin-left: -60px } .left .links.editor { text-align: left !important } /* -- Post -- */ .posts .new { display: none; position: absolute; top: -50px; margin-left: 0px; left: 50%; -webkit-transform: translateX(-50%) ; -moz-transform: translateX(-50%) ; -o-transform: translateX(-50%) ; -ms-transform: translateX(-50%) ; transform: translateX(-50%) } .posts, .post-full { display: none; position: relative; } .page-main .posts { display: block } .page-post.loaded .post-full { display: block; border-bottom: none } .post { margin-bottom: 50px; padding-bottom: 50px; border-bottom: 1px solid #eee; min-width: 500px } .post .title a { text-decoration: none; color: inherit; display: inline-block; border-bottom: none; font-weight: inherit } .posts .title a:visited { color: #666969 } .post .details { color: #BBB; margin-top: 5px; margin-bottom: 20px } .post .details .comments-num { border: none; color: #BBB; font-weight: normal; } .post .details .comments-num .num { border-bottom: 1px solid #eee; color: #000; } .post .details .comments-num:hover .num { border-bottom: 1px solid #D6A1DE; } .post .body { font-size: 21.5px; line-height: 1.6; font-family: Tinos; margin-top: 20px } .post .body h1 { text-align: center; margin-top: 50px } .post .body h1:before { content: " "; border-top: 1px solid #EEE; width: 120px; display: block; margin-left: auto; margin-right: auto; margin-bottom: 50px; } .post .body p + ul { margin-top: -0.5em } .post .body li { margin-top: 0.5em; margin-bottom: 0.5em } .post .body hr:first-of-type { display: none } .post .body a img { margin-bottom: -8px } .post .body img { max-width: 100% } code { background-color: #f5f5f5; border: 1px solid #ccc; padding: 0px 5px; overflow: auto; -webkit-border-radius: 2px; -moz-border-radius: 2px; -o-border-radius: 2px; -ms-border-radius: 2px; border-radius: 2px ; display: inline-block; color: #444; font-weight: normal; font-size: 60%; vertical-align: text-bottom; border-bottom-width: 2px; } .post .body pre { table-layout: fixed; width: auto; display: table; white-space: normal; } .post .body pre code { padding: 10px 20px; white-space: pre; max-width: 850px } blockquote { border-left: 3px solid #333; margin-left: 0px; padding-left: 1em } /*.post .more { display: inline-block; border: 1px solid #eee; padding: 10px 25px; -webkit-border-radius: 26px; -moz-border-radius: 26px; -o-border-radius: 26px; -ms-border-radius: 26px; border-radius: 26px ; font-size: 11px; color: #AAA; font-weight: normal; left: 50%; position: relative; -webkit-transform: translateX(-50%); -moz-transform: translateX(-50%); -o-transform: translateX(-50%); -ms-transform: translateX(-50%); transform: translateX(-50%) ; }*/ .post .more { border: 2px solid #333; padding: 10px 20px; font-size: 15px; margin-top: 30px; display: none; -webkit-transition: all 0.3s ; -moz-transition: all 0.3s ; -o-transition: all 0.3s ; -ms-transition: all 0.3s ; transition: all 0.3s } .post .more .readmore { } .post .more:hover { color: white; -webkit-box-shadow: inset 150px 0px 0px 0px #333; -moz-box-shadow: inset 150px 0px 0px 0px #333; -o-box-shadow: inset 150px 0px 0px 0px #333; -ms-box-shadow: inset 150px 0px 0px 0px #333; box-shadow: inset 150px 0px 0px 0px #333 ; } .post .more:active { color: white; -webkit-box-shadow: inset 150px 0px 0px 0px #AF3BFF; -moz-box-shadow: inset 150px 0px 0px 0px #AF3BFF; -o-box-shadow: inset 150px 0px 0px 0px #AF3BFF; -ms-box-shadow: inset 150px 0px 0px 0px #AF3BFF; box-shadow: inset 150px 0px 0px 0px #AF3BFF ; -webkit-transition: none; -moz-transition: none; -o-transition: none; -ms-transition: none; transition: none ; border-color: #AF3BFF } /* ---- data/1Hb9rY98TNnA6TYeozJv4w36bqEiBn6x8Y/css/fonts.css ---- */ /* Base64 encoder: http://www.motobit.com/util/base64-decoder-encoder.asp */ /* Generated by Font Squirrel (http://www.fontsquirrel.com) on January 21, 2015 */ @font-face { font-family: 'Tinos'; src: url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAIfEABMAAAABK6AAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABqAAAABwAAAAcafTEEEdERUYAAAHEAAAAJAAAACYAJwFhR1BPUwAAAegAAAJ1AAAHzLT7y6ZHU1VCAAAEYAAAAIIAAADSeGF8IE9TLzIAAATkAAAAYAAAAGD/Bgk2Y21hcAAABUQAAAJGAAADdg18Ei5jdnQgAAAHjAAAADIAAAAyDwsIvWZwZ20AAAfAAAABsQAAAmVTtC+nZ2FzcAAACXQAAAAIAAAACAAAABBnbHlmAAAJfAAAceQAAQSsvLBIQGhlYWQAAHtgAAAAMwAAADYI0lERaGhlYQAAe5QAAAAhAAAAJA+wBn9obXR4AAB7uAAAAioAAATsC2JNKGxvY2EAAH3kAAACcAAAAnjTQBTGbWF4cAAAgFQAAAAgAAAAIAJYAbZuYW1lAACAdAAAAxwAAAd009XuX3Bvc3QAAIOQAAADlQAABiya+85BcHJlcAAAhygAAACUAAAAz1AoMgx3ZWJmAACHvAAAAAYAAAAGNWtUwAAAAAEAAAAA0MoNVwAAAADIRNDOAAAAANDl5ep42mNgZGBg4AFiMQY5BiYGRgZGRisgyQIUYQJiRggGAAysAIp42uVUv2tTURg9372vbSqaHyWUUkymh6i0Kg1SE4o4XEpaMsVGk/AGqwSDqcUGEbSlgyCIy4MiIuLgX5BBMjg4iDg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VwXUTswOTNpjDAuSwqkM5bCCZ/VAOO5DDVgTlcAA57NYQDuMGTqhJXEBRTmEm7Y3MbmVALreC6y4Gzvr/DHARHqAC7gA4lxfI5dGGc/mAXF45GDdyg4g2ABjbO40AAVTANWoAAA==) format('woff'); font-weight: normal; font-style: normal; } @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 300; src: local('Roboto Light'), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAEScABMAAAAAdFQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABqAAAABwAAAAcXzC5yUdERUYAAAHEAAAAHgAAACAAzgAER1BPUwAAAeQAAAVxAAANIkezYOlHU1VCAAAHWAAAACwAAAAwuP+4/k9TLzIAAAeEAAAAVgAAAGC3ouDrY21hcAAAB9wAAAG+AAACioYHy/VjdnQgAAAJnAAAADQAAAA0CnAOGGZwZ20AAAnQAAABsQAAAmVTtC+nZ2FzcAAAC4QAAAAIAAAACAAAABBnbHlmAAALjAAAMaIAAFTUMXgLR2hlYWQAAD0wAAAAMQAAADYBsFYkaGhlYQAAPWQAAAAfAAAAJA7cBhlobXR4AAA9hAAAAeEAAAKEbjk+b2xvY2EAAD9oAAABNgAAAUQwY0cibWF4cAAAQKAAAAAgAAAAIAG+AZluYW1lAABAwAAAAZAAAANoT6qDDHBvc3QAAEJQAAABjAAAAktoPRGfcHJlcAAAQ9wAAAC2AAABI0qzIoZ3ZWJmAABElAAAAAYAAAAGVU1R3QAAAAEAAAAAzD2izwAAAADE8BEuAAAAAM4DBct42mNgZGBg4ANiCQYQYGJgBMIFQMwC5jEAAAsqANMAAHjapZZ5bNRFFMff79dtd7u03UNsORWwKYhWGwFLsRBiGuSKkdIDsBg0kRCVGq6GcpSEFINKghzlMDFBVBITNRpDJEGCBlBBRSEQIQYJyLHd/pA78a99fn6zy3ZbykJxXr7zm3nz5s2b7xy/EUtE/FIiY8SuGDe5SvLeeHlhvfQRD3pRFbc9tWy9/ur8evG5JQOP2Hxt8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RxHmWqsFWXPr90UOTzoh6LPL9cFvM96i5SeZRzwkgNl+zhDFe4oS0I5997/W9PDXI1ObvZn1RSHA3ptMpeBypq0wb7drivfdoy8XyDP0JQfA542m3Ou0+TcRTG8e+hpTcol9JSoCqKIiqI71taCqJCtS3ekIsWARVoUmxrgDaFd2hiTEx0AXVkZ1Q3Edlw0cHEwcEBBv1XlNLfAAnP8slzknNyKGM//56R5Kisg5SJCRNmyrFgxYYdBxVU4qSKamqoxUUdbjzU46WBRprwcYzjnKCZk5yihdOcoZWztHGO81ygnQ4u0sklNHT8dBEgSDcheujlMn1c4SrX6GeAMNe5QYQoMQa5yS1uc4e7DHGPYUYYZYz7PCDOOA+ZYJIpHvGYJ0wzwywJMfOK16zxjlXeSzkrvOUvH/jBHD/5RYrfpMmQY5kCz3nBS7GIVWxiZ4c/7IpDKqRSnFIl1VIjteKSOnGLR+rFyyc2+MIW3/jMJt/5KA1s81UapYk34rOk5gu5tG41FjOapkVKhjVlxDmcNhZTibyxMJ8wlp3ZQy1+qBkHW3Hfv3dQqSv9yi5lQBlUditDyh5lrzJcUld3dd3xNJMy8nPJxFK6NPLHSgZj5qiRzxZLdO+P/+/adfZ42j3OKRLCQBAF0Bkm+0JWE0Ex6LkCksTEUKikiuIGWCwYcHABOEQHReE5BYcJHWjG9fst/n/w/gj8zGpwlk3H+aXtKks1M4jbGvIVHod2ApZaNwyELEGoBRiyvItipL4wEcaUYMnyyUy+ZWQbn9ab4CDsF8FFODeCh3CvBB/hnQgBwq8IISL4V40RofyBQ0TTUkwj7OhEtUMmyHSjGSOTuWY2rI32PdNJPiQZL3TSQq4+STRSagAAAAFR3VVMAAA=) format('woff'), url('../font/Roboto-Light.woff') format('woff'); } @font-face { font-family: 'Roboto'; font-style: normal; font-weight: bold; src: local('Roboto Medium'), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAEbcABAAAAAAfQwAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABHUE9TAAABbAAABOQAAAv2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cXEG1kYG7C4lpalM+Rll9apFdcWsBZklGUmgpisZeU54Pp/DwwHwBPQXTqAHgBLc4lXMVQFIDxe5+/Ke4uCXd3KLhLWsWdhvWynugFl7ieRu+dnsb5flD+V44+W03Pqkm96nSsSX3pwfbG8hyVafqKLY53NhRyi8/1/P8l1md6//6SRzsznWXcUiuTXQ3F3NJTfU3V3NRrJp2WrjUzN3sl06/thr54PYV7+IYaQ1++jlly8+AO2iz5W4IT8OEJIqi29NXrGHhwB65DLfxAtSN5HvgQQgRjjiSfQJDDoBz5e4AA3BwJtOVAHgtBBGGeRNsK5DYGd8IvM61XFAA=) format('woff'), url(../font/Roboto-Medium.woff) format('woff'); } /* ---- data/1Hb9rY98TNnA6TYeozJv4w36bqEiBn6x8Y/css/github.css ---- */ /* github.com style (c) Vasily Polovnyov */ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; -webkit-text-size-adjust: none; } .hljs-comment, .diff .hljs-header, .hljs-javadoc { color: #998; font-style: italic; } .hljs-keyword, .css .rule .hljs-keyword, .hljs-winutils, .nginx .hljs-title, .hljs-subst, .hljs-request, .hljs-status { color: #333; font-weight: bold; } .hljs-number, .hljs-hexcolor, .ruby .hljs-constant { color: #008080; } .hljs-string, .hljs-tag .hljs-value, .hljs-phpdoc, .hljs-dartdoc, .tex .hljs-formula { color: #d14; } .hljs-title, .hljs-id, .scss .hljs-preprocessor { color: #900; font-weight: bold; } .hljs-list .hljs-keyword, .hljs-subst { font-weight: normal; } .hljs-class .hljs-title, .hljs-type, .vhdl .hljs-literal, .tex .hljs-command { color: #458; font-weight: bold; } .hljs-tag, .hljs-tag .hljs-title, .hljs-rules .hljs-property, .django .hljs-tag .hljs-keyword { color: #000080; font-weight: normal; } .hljs-attribute, .hljs-variable, .lisp .hljs-body { color: #008080; } .hljs-regexp { color: #009926; } .hljs-symbol, .ruby .hljs-symbol .hljs-string, .lisp .hljs-keyword, .clojure .hljs-keyword, .scheme .hljs-keyword, .tex .hljs-special, .hljs-prompt { color: #990073; } .hljs-built_in { color: #0086b3; } .hljs-preprocessor, .hljs-pragma, .hljs-pi, .hljs-doctype, .hljs-shebang, .hljs-cdata { color: #999; font-weight: bold; } .hljs-deletion { background: #fdd; } .hljs-addition { background: #dfd; } .diff .hljs-change { background: #0086b3; } .hljs-chunk { color: #aaa; } /* ---- data/1Hb9rY98TNnA6TYeozJv4w36bqEiBn6x8Y/css/icons.css ---- */ .icon { display: inline-block; vertical-align: text-bottom; background-repeat: no-repeat; } .icon-profile { font-size: 6px; top: 0em; -webkit-border-radius: 0.7em 0.7em 0 0; -moz-border-radius: 0.7em 0.7em 0 0; -o-border-radius: 0.7em 0.7em 0 0; -ms-border-radius: 0.7em 0.7em 0 0; border-radius: 0.7em 0.7em 0 0 ; background: #FFFFFF; width: 1.5em; height: 0.7em; position: relative; display: inline-block; margin-right: 4px } .icon-profile:before { position: absolute; content: ""; top: -1em; left: 0.38em; width: 0.8em; height: 0.85em; -webkit-border-radius: 50%; -moz-border-radius: 50%; -o-border-radius: 50%; -ms-border-radius: 50%; border-radius: 50% ; background: #FFFFFF; } .icon-comment { width: 16px; height: 10px; -webkit-border-radius: 2px; -moz-border-radius: 2px; -o-border-radius: 2px; -ms-border-radius: 2px; border-radius: 2px ; background: #B10DC9; margin-top: 0px; display: inline-block; position: relative; top: -2px; } .icon-comment:after { left: 9px; border: 2px solid transparent; border-top-color: #B10DC9; border-left-color: #B10DC9; background: transparent; content: ""; display: block; margin-top: 10px; width: 0px; margin-left: 7px; } .icon-edit { width: 16px; height: 16px; background-repeat: no-repeat; background-position: 20px center; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAOVBMVEUAAAC9w8e9w8e9w8e9w8e/xMi9w8e9w8e+w8e9w8e9w8e9w8e9w8e9w8e9w8e+w8e/xMi9w8e9w8fvY4+KAAAAEnRSTlMASPv3WQbwOTCkt4/psX4YDMWr+RRCAAAAUUlEQVQY06XLORKAMAxDUTs7kA3d/7AYGju0UfffjIgoHkxm0vB5bZyxKHx9eX0FJw0Y4bcXKQ4/CTtS5yqp5GFFOjGpVGl00k1pNDIb3Nv9AHC7BOZC4ZjvAAAAAElFTkSuQmCC+d0ckOwyAMRVGHUOO0gUyd+P8f7WApz4Iki9wFmyOEATrXLZcFp5LrGogPOxKp6zfFf9fZ1/I/cY7YZSS3U6S3XFZJmGBwL+FuJX/F1K0wUUlZyZGlXgXESthTEs4B8fh7xoVUDPGYJnsfkCRarKAgz8cAKbpD6pqDPz3XB8K6HdUEeN9NAAAAAElFTkSuQmCC); } .icon-reply { width: 16px; height: 16px; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAIVBMVEUAAABmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmYs5FxxAAAAC3RSTlMAgBFwYExAMHgoCDJmUTYAAAA3SURBVAjXY8APGGEMQZgAjCEoKBwEEQCCAoiIh6AQVM1kMaguJhGYOSJQjexiUMbiAChDCclCAOHqBBdHpwQTAAAAAElFTkSuQmCC); } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/data/data.json ================================================ { "title": "ZeroBlog", "description": "Demo for decentralized, self publishing blogging platform.", "links": "- [Source code](https://github.com/HelloZeroNet)\n- [Create new blog](?Post:3:How+to+have+a+blog+like+this)", "next_post_id": 42, "demo": false, "modified": 1433033806, "post": [ { "post_id": 41, "title": "Changelog: May 31, 2015", "date_published": 1433033779.604, "body": " - rev194\n - Ugly OpenSSL memory leak fix\n - Added Docker and Vargant files (thanks to n3r0-ch)\n\nZeroBlog\n - Comment editing, Deleting, Replying added\n\nNew official site: http://zeronet.io/" }, { "post_id": 40, "title": "Trusted authorization providers", "date_published": 1432549828.319, "body": "What is it good for?\n\n - It allows you to have multi-user sites without need of a bot that listen to new user registration requests.\n - You can use the same username across sites\n - The site owner can give you (or revoke) permissions based on your ZeroID username\n\nHow does it works?\n\n - You visit an authorization provider site (eg zeroid.bit)\n - You enter the username you want to register and sent the request to the authorization provider site owner (zeroid supports bitmessage and simple http request).\n - The authorization provider process your request and it he finds everything all right (unique username, other anti-spam methods) he sends you a certificate for the username registration.\n - If a site trust your authorization provider you can post your own content (comments, topics, upvotes, etc.) using this certificate without ever contacting the site owner.\n\nWhat sites currently supports ZeroID?\n\n - You can post comments to ZeroBlog using your ZeroID\n - Later, if everyone is updated to 0.3.0 a new ZeroTalk is also planned that supports ZeroID certificates\n\nWhy is it necessary?\n\n - To have some kind of control over the users of your site. (eg. remove misbehaving users)\n\nOther info\n\n - ZeroID is a standard site, anyone can clone it and have his/her own one\n - You can stop seeding ZeroID site after you got your cert" }, { "post_id": 39, "title": "Changelog: May 25, 2015", "date_published": 1432511642.167, "body": "- Version 0.3.0, rev187\n- Trusted authorization provider support: Easier multi-user sites by allowing site owners to define tusted third-party user certificate signers. (more info about it in the next days)\n- `--publish` option to siteSign to publish automatically after the new files signed.\n- `cryptSign` command line command to sign message using private key.\n- New, more stable OpenSSL layer that also works on OSX.\n- New json table format support.\n- DbCursor SELECT parameters bugfix.\n- Faster multi-threaded peer discovery from trackers.\n- New http trackers added.\n- Wait for dbschema.json file to execute query.\n- Handle json import errors.\n- More compact json writeJson storage command output.\n- Workaround to make non target=_top links work.\n- Cleaner UiWebsocket command router.\n- Notify other local users on local file changes.\n- Option to wait file download before execute query.\n- fileRules, certAdd, certSelect, certSet websocket API commands.\n- Allow more file errors on big sites.\n- On stucked downloads skip worker's current file instead of stopping it.\n- NoParallel parameter bugfix.\n- RateLimit interval bugfix.\n- Updater skips non-writeable files.\n- Try to close OpenSSL dll before update.\n\nZeroBlog:\n- Rewritten to use SQL database\n- Commenting on posts (**Please note: The comment publishing and distribution can be slow until most of the clients is not updated to version 0.3.0**)\n\n![comments](data/img/zeroblog-comments.png)\n\nZeroID\n- Sample Trusted authorization provider site with Bitmessage registration support\n\n![comments](data/img/zeroid.png)" }, { "post_id": 38, "title": "Status report: Trusted authorization providers", "date_published": 1431286381.226, "body": "Currently working on a new feature that allows to create multi-user sites more easily. For example it will allows us to have comments on ZeroBlog (without contacting the site owner).\n\nCurrent status:\n\n - Sign/verification process: 90%\n - Sample trusted authorization provider site: 70%\n - ZeroBlog modifications: 30%\n - Authorization UI enhacements: 10%\n - Total progress: 60%\n \nEta.: 1-2weeks\n\n### Update: May 18, 2015:\n\nThings left:\n - More ZeroBlog modifications on commenting interface\n - Bitmessage support in Sample trusted authorization provider site\n - Test everything on multiple platform/browser and machine\n - Total progress: 80%\n\nIf no major flaw discovered it should be out this week." }, { "post_id": 37, "title": "Changelog: May 3, 2015", "date_published": 1430652299.794, "body": " - rev134\n - Removed ZeroMQ dependencies and support (if you are on pre 0.2.0 version please, upgrade)\n - Save CPU and memory on file requests by streaming content directly to socket without loading to memory and encoding with msgpack.\n - Sites updates without re-download all content.json by querying the modified files from peers.\n - Fix urllib memory leak\n - SiteManager testsuite\n - Fix UiServer security testsuite\n - Announce to tracker on site resume\n\nZeroBoard:\n\n - Only last 100 messages loaded by default\n - Typo fix" }, { "post_id": 36, "title": "Changelog: Apr 29, 2015", "date_published": 1430388168.315, "body": " - rev126\n - You can install the \"127.0.0.1:43110-less\" extension from [Chrome Web Store](https://chrome.google.com/webstore/detail/zeronet-protocol/cpkpdcdljfbnepgfejplkhdnopniieop). (thanks to g0ld3nrati0!)\n - You can disable the use of openssl using `--use_openssl False`\n - OpenSSL disabled on OSX because of possible segfault. You can enable it again using `zeronet.py --use_openssl True`,
    please [give your feedback](https://github.com/HelloZeroNet/ZeroNet/issues/94)!\n - Update on non existent file bugfix\n - Save 20% memory using Python slots\n\n![Memory save](data/img/slots_memory.png)" }, { "post_id": 35, "title": "Changelog: Apr 27, 2015", "date_published": 1430180561.716, "body": " - Revision 122\n - 40x faster signature verification by using OpenSSL if available\n - Added OpenSSL benchmark: beat my CPU at http://127.0.0.1:43110/Benchmark :)\n - Fixed UiServer socket memory leak" }, { "post_id": 34, "title": "Slides about ZeroNet", "date_published": 1430081791.43, "body": "Topics:\n - ZeroNet cryptography\n - How site downloading works\n - Site updates\n - Multi-user sites\n - Current status of the project / Future plans\n\n\n\n[Any feedback is welcome!](http://127.0.0.1:43110/Talk.ZeroNetwork.bit/?Topic:18@2/Presentation+about+how+ZeroNet+works) \n\nThanks! :)" }, { "post_id": 33, "title": "Changelog: Apr 24, 2014", "date_published": 1429873756.187, "body": " - Revision 120\n - Batched publishing to avoid update flood: Only send one update in every 7 seconds\n - Protection against update flood by adding update queue: Only allows 1 update in every 10 second for the same file\n - Fix stucked notification icon\n - Fix websocket error when writing to not-owned sites" }, { "post_id": 32, "title": "Changelog: Apr 20, 2014", "date_published": 1429572874, "body": " - Revision 115\n - For faster pageload times allow browser cache on css/js/font files\n - Support for experimental chrome extension that allows to browse zeronet sites using `http://talk.zeronetwork.bit` and/or `http://zero/1Name2NXVi1RDPDgf5617UoW7xA6YrhM9F`\n - Allow to browse memory content in /Stats\n - Peers uses Site's logger to save some memory\n - Give not-that-good peers on initial PEX if required\n - Allows more than one `--ui_restrict` ip address\n - Disable ssl monkey patching to avoid ssl error in Debian Jessie\n - Fixed websocket error when writing not-allowed files\n - Fixed bigsite file not found error\n - Fixed loading screen stays on screen even after index.html loaded\n\nZeroHello:\n\n - Site links converted to 127.0.0.1:43110 -less if using chrome extension\n\n![direct domains](data/img/direct_domains.png)" }, { "post_id": 31, "title": "Changelog: Apr 17, 2014", "date_published": 1429319617.201, "body": " - Revision 101\n - Revision numbering between version\n - Allow passive publishing\n - Start Zeronet when Windows starts option to system tray icon\n - Add peer ping time to publish timeout\n - Passive connected peers always get the updates\n - Pex count bugfix\n - Changed the topright button hamburger utf8 character to more supported one and removed click anim\n - Passive peers only need 3 connection\n - Passive connection store on tracker bugfix\n - Not exits file bugfix\n - You can compare your computer speed (bitcoin crypto, sha512, sqlite access) to mine: http://127.0.0.1:43110/Benchmark :)\n\nZeroTalk:\n\n - Only quote the last message\n - Message height bugfix\n\nZeroHello:\n\n - Changed the burger icon to more supported one\n - Added revision display" }, { "post_id": 30, "title": "Changelog: Apr 16, 2015", "date_published": 1429135541.581, "body": "Apr 15:\n\n - Version 0.2.9\n - To get rid of dead ips only send peers over pex that messaged within 2 hour\n - Only ask peers from 2 sources using pex every 20 min\n - Fixed mysterious notification icon disappearings\n - Mark peers as bad if publish is timed out (5s+)" }, { "post_id": 29, "title": "Changelog: Apr 15, 2015", "date_published": 1429060414.445, "body": " - Sexy system tray icon with statistics instead of ugly console. (sorry, Windows only yet)\n - Total sent/received bytes stats\n - Faster connections and publishing by don't send passive peers using PEX and don't store them on trackers\n\n![Tray icon](data/img/trayicon.png)" }, { "post_id": 28, "title": "Changelog: Apr 14, 2015", "date_published": 1428973199.042, "body": " - Experimental socks proxy support (Tested using Tor)\n - Tracker-less peer exchange between peers\n - Http bittorrent tracker support\n - Option to disable udp connections (udp tracker)\n - Other stability/security fixes\n\nTo use ZeroNet over Tor network start it with `zeronet.py --proxy 127.0.0.1:9050 --disable_udp`\n\nIt's still an experimental feature, there is lot work/fine tuning needed to make it work better and more secure (eg. by supporting hidden service peer addresses to allow connection between Tor clients). \nIn this mode you can only access to sites where there is at least one peer with peer exchange support. (client updated to latest commit)\n\nIf no more bug found i'm going to tag it as 0.2.9 in the next days." }, { "post_id": 27, "title": "Changelog: Apr 9, 2015", "date_published": 1428626164.266, "body": " - Packaged windows dependencies for windows to make it easier to install: [ZeroBundle](https://github.com/HelloZeroNet/ZeroBundle)\n - ZeroName site downloaded at startup, so first .bit domain access is faster.\n - Fixed updater bug. (argh)" }, { "post_id": 26, "title": "Changelog: Apr 7, 2015", "date_published": 1428454413.286, "body": " - Fix for big sites confirmation display\n - Total objects in memory stat\n - Memory optimizations\n - Retry bad files in every 20min\n - Load files to db when executing external siteSign command\n - Fix for endless reconnect bug\n \nZeroTalk:\n \n - Added experimental P2P new bot\n - Bumped size limit to 20k for every user :)\n - Reply button\n\nExperimenting/researching possibilities of i2p/tor support (probably using DHT)\n\nAny help/suggestion/idea greatly welcomed: [github issue](https://github.com/HelloZeroNet/ZeroNet/issues/60)" }, { "post_id": 25, "title": "Changelog: Apr 2, 2015", "date_published": 1428022346.555, "body": " - Better passive mode by making sure to keep 5 active connections\n - Site connection and msgpack unpacker stats\n - No more sha1 hash added to content.json (it was only for backward compatibility with old clients)\n - Keep connection logger object to prevent some exception\n - Retry upnp port opening 3 times\n - Publish received content updates to more peers to make sure the better distribution\n\nZeroTalk: \n\n - Changed edit icon to more clear pencil\n - Single line breaks also breaks the line" }, { "post_id": 24, "title": "Changelog: Mar 29, 2015", "date_published": 1427758356.109, "body": " - Version 0.2.8\n - Namecoin (.bit) domain support!\n - Possible to disable backward compatibility with old version to save some memory\n - Faster content publishing (commenting, posting etc.)\n - Display error on internal server errors\n - Better progress bar\n - Crash and bugfixes\n - Removed coppersurfer tracker (its down atm), added eddie4\n - Sorry, the auto updater broken for this version: please overwrite your current `update.py` file with the [latest one from github](https://raw.githubusercontent.com/HelloZeroNet/ZeroNet/master/update.py), run it and restart ZeroNet.\n - Fixed updater\n\n![domain](data/img/domain.png)\n\nZeroName\n\n - New site for resolving namecoin domains and display registered ones\n\n![ZeroName](data/img/zeroname.png)\nZeroHello\n\n - Automatically links to site's domain names if its specificed in content.json `domain` field\n\n" }, { "post_id": 22, "title": "Changelog: Mar 23, 2015", "date_published": 1427159576.994, "body": " - Version 0.2.7\n - Plugin system: Allows extend ZeroNet without modify the core source\n - Comes with 3 plugin:\n - Multiuser: User login/logout based on BIP32 master seed, generate new master seed on visit (disabled by default to enable it just remove the disabled- from the directory name)\n - Stats: /Stats url moved to separate plugin for demonstration reasons\n - DonationMessage: Puts a little donation link to the bottom of every page (disabled by default)\n - Reworked module import system\n - Lazy user auth_address generatation\n - Allow to send prompt dialog to user from server-side\n - Update script remembers plugins enabled/disabled status\n - Multiline notifications\n - Cookie parser\n\nZeroHello in multiuser mode:\n\n - Logout button\n - Identicon generated based on logined user xpub address\n\n![Multiuser](data/img/multiuser.png)" }, { "post_id": 21, "title": "Changelog: Mar 19, 2015", "date_published": 1426818095.915, "body": " - Version 0.2.6\n - SQL database support that allows easier site development and faster page load times\n - Updated [ZeroFrame API Reference](http://zeronet.readthedocs.org/en/latest/site_development/zeroframe_api_reference/)\n - Added description of new [dbschema.json](http://zeronet.readthedocs.org/en/latest/site_development/dbschema_json/) file\n - SiteStorage class for file operations\n - Incoming connection firstchar errorfix\n - dbRebuild and dbQuery commandline actions\n - [Goals donation page](http://zeronet.readthedocs.org/en/latest/zeronet_development/donate/)\n\nZeroTalk\n\n - Rewritten to use SQL queries (falls back nicely to use json files on older version)" }, { "post_id": 20, "title": "Changelog: Mar 14, 2015", "date_published": 1426386779.836, "body": "\n - Save significant amount of memory by remove unused msgpack unpackers\n - Log unhandled exceptions\n - Connection checker error bugfix\n - Working on database support, you can follow the progress on [reddit](http://www.reddit.com/r/zeronet/comments/2yq7e8/a_json_caching_layer_for_quicker_development_and/)\n\n![memory usage](data/img/memory.png)" }, { "post_id": 19, "title": "Changelog: Mar 10, 2015", "date_published": 1426041044.008, "body": " - Fixed ZeroBoard and ZeroTalk registration: It was down last days, sorry, I haven't tested it after recent modifications, but I promise I will from now :)\n - Working hard on documentations, after trying some possibilities, I chosen readthedocs.org: http://zeronet.readthedocs.org\n - The API reference is now up-to-date, documented demo sites working method and also updated other parts\n\n[Please, tell me what you want to see in the docs, Thanks!](/1TaLk3zM7ZRskJvrh3ZNCDVGXvkJusPKQ/?Topic:14@2/New+ZeroNet+documentation)" }, { "post_id": 18, "title": "Changelog: Mar 8, 2015", "date_published": 1425865493.306, "body": " - [Better uPnp Puncher](https://github.com/HelloZeroNet/ZeroNet/blob/master/src/util/UpnpPunch.py), if you have problems with port opening please try this.\n\nZeroTalk: \n - Comment upvoting\n - Topic groups, if you know any other article about ZeroNet please, post [here](/1TaLk3zM7ZRskJvrh3ZNCDVGXvkJusPKQ/?Topics:8@2/Articles+about+ZeroNet)" }, { "post_id": 17, "title": "Changelog: Mar 5, 2015", "date_published": 1425606285.111, "body": " - Connection pinging and timeout\n - Request timeout\n - Verify content at signing (size, allowed files)\n - Smarter coffeescript recompile\n - More detailed stats\n\nZeroTalk: \n - Topic upvote\n - Even more source code realign\n\n![ZeroTalk upvote](data/img/zerotalk-upvote.png)" }, { "post_id": 16, "title": "Changelog: Mar 1, 2015", "date_published": 1425259087.503, "body": "ZeroTalk: \n - Reordered source code to allow more more feature in the future\n - Links starting with http://127.0.0.1:43110/ automatically converted to relative links (proxy support)\n - Comment reply (by clicking on comment's creation date)" }, { "post_id": 15, "title": "Changelog: Feb 25, 2015", "date_published": 1424913197.035, "body": " - Version 0.2.5\n - Pure-python upnp port opener (Thanks to sirMackk!)\n - Site download progress bar\n - We are also on [Gitter chat](https://gitter.im/HelloZeroNet/ZeroNet)\n - More detailed connection statistics (ping, buff, idle, delay, sent, received)\n - First char failed bugfix\n - Webebsocket disconnect on slow connection bugfix\n - Faster site update\n\n![Progressbar](data/img/progressbar.png)\n\nZeroTalk: \n\n - Sort after 100ms idle\n - Colored usernames\n - Limit reload rate to 500ms\n\nZeroHello\n\n - [iframe render fps test](/1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr/test/render.html) ([more details on ZeroTalk](/1TaLk3zM7ZRskJvrh3ZNCDVGXvkJusPKQ/?Topic:7@2/Slow+rendering+in+Chrome))\n" }, { "post_id": 14, "title": "Changelog: Feb 24, 2015", "date_published": 1424734437.473, "body": " - Version 0.2.4\n - New, experimental network code and protocol\n - peerPing and peerGetFile commands\n - Connection share and reuse between sites\n - Don't retry bad file more than 3 times in 20 min\n - Multi-threaded include file download\n - Really shuffle peers before publish\n - Simple internal stats page: http://127.0.0.1:43110/Stats\n - Publish bugfix for sites with more then 10 peers\n\n_If someone on very limited resources its recommended to wait some time until most of the peers is updates to new network code, because the backward compatibility is a little bit tricky and using more memory._" }, { "post_id": 13, "title": "Changelog: Feb 19, 2015", "date_published": 1424394659.345, "body": " - Version 0.2.3\n - One click source code download from github, auto unpack and restart \n - Randomize peers before publish and work start\n - Switched to upnpc-shared.exe it has better virustotal reputation (4/53 vs 19/57)\n\n![Autoupdate](data/img/autoupdate.png)\n\nZeroTalk:\n\n - Topics also sorted by topic creation date\n\n_New content and file changes propagation is a bit broken yet. Already working on better network code that also allows passive content publishing. It will be out in 1-2 weeks._" }, { "post_id": 12, "title": "Changelog: Feb 16, 2015", "date_published": 1424134864.167, "body": "Feb 16: \n - Version 0.2.2\n - LocalStorage support using WrapperAPI\n - Bugfix in user management\n\nZeroTalk: \n - Topics ordered by date of last post\n - Mark updated topics since your last visit\n\n![Mark](data/img/zerotalk-mark.png)" }, { "post_id": 11, "title": "Changelog: Feb 14, 2015", "date_published": 1423922572.778, "body": " - Version 0.2.1\n - Site size limit: Default 10MB, asks permission to store more, test it here: [ZeroNet windows requirement](/1ZeroPYmW4BGwmT6Z54jwPgTWpbKXtTra)\n - Browser open wait until UiServer started\n - Peer numbers stored in sites.json for faster warmup\n - Silent WSGIHandler error\n - siteSetLimit WrapperAPI command\n - Grand ADMIN permission to wrapperframe\n\nZeroHello: \n\n - Site modify time also include sub-file changes (ZeroTalk last comment)\n - Better changetime date format" }, { "post_id": 10, "title": "Changelog: Feb 11, 2015", "date_published": 1423701015.643, "body": "ZeroTalk:\n - Link-type posts\n - You can Edit or Delete your previous Comments and Topics\n - [Uploaded source code to github](https://github.com/HelloZeroNet/ZeroTalk)" }, { "post_id": 9, "title": "Changelog: Feb 10, 2015", "date_published": 1423532194.094, "body": " - Progressive publish timeout based on file size\n - Better tracker error log\n - Viewport support in content.json and ZeroFrame API to allow better mobile device layout\n - Escape ZeroFrame notification messages to avoid js injection\n - Allow select all data in QueryJson\n\nZeroTalk:\n - Display topic's comment number and last comment time (requires ZeroNet today's commits from github)\n - Mobile device optimized layout" }, { "post_id": 8, "title": "Changelog: Feb 9, 2015", "date_published": 1423522387.728, "body": " - Version 0.2.0\n - New bitcoin ECC lib (pybitcointools)\n - Hide notify errors\n - Include support for content.json\n - File permissions (signer address, filesize, allowed filenames)\n - Multisig ready, new, Bitcoincore compatible sign format\n - Faster, multi threaded content publishing\n - Multiuser, ready, BIP32 based site auth using bitcoin address/privatekey\n - Simple json file query language\n - Websocket api fileGet support\n\nZeroTalk: \n - [Decentralized forum demo](/1TaLk3zM7ZRskJvrh3ZNCDVGXvkJusPKQ/?Home)\n - Permission request/username registration\n - Everyone has an own file that he able to modify, sign and publish decentralized way, without contacting the site owner\n - Topic creation\n - Per topic commenting\n\n![ZeroTalk screenshot](data/img/zerotalk.png)" }, { "post_id": 7, "title": "Changelog: Jan 29, 2015", "date_published": 1422664081.662, "body": "The default tracker (tracker.pomf.se) is down since yesterday and its resulting some warning messages. To make it disappear please update to latest version from [GitHub](https://github.com/HelloZeroNet/ZeroNet).\n\nZeroNet:\n- Added better tracker error handling\n- Updated alive [trackers list](https://github.com/HelloZeroNet/ZeroNet/blob/master/src/Site/SiteManager.py) (if anyone have more, please [let us know](http://www.reddit.com/r/zeronet/comments/2sgjsp/changelog/co5y07h))\n\nIf you want to stay updated about the project status:
    \nWe have created a [@HelloZeronet](https://twitter.com/HelloZeroNet) Twitter account" }, { "post_id": 6, "title": "Changelog: Jan 27, 2015", "date_published": 1422394676.432, "body": "ZeroNet\n* You can use `start.py` to start zeronet and open in browser automatically\n* Send timeout 50sec (workaround for some strange problems until we rewrite the network code without zeromq)\n* Reworked Websocket API to make it unified and allow named and unnamed parameters\n* Reload `content.json` when changed using fileWrite API command\n* Some typo fix\n\nZeroBlog\n* Allow edit post on mainpage\n* Also change blog title in `content.json` when modified using inline editor\n\nZeroHello\n* Update failed warning changed to No peers found when seeding own site." }, { "post_id": 4, "title": "Changelog: Jan 25, 2015", "date_published": 1422224700.583, "body": "ZeroNet\n- Utf-8 site titles fixed\n- Changes in DebugMedia merger to allow faster, node.js based coffeescript compiler\n\nZeroBlog\n- Inline editor rewritten to simple textarea, so copy/paste, undo/redo now working correctly\n- Read more button to folded posts with `---`\n- ZeroBlog running in demo mode, so anyone can try the editing tools\n- Base html tag fixed\n- Markdown cheat-sheet\n- Confirmation if you want to close the browser tab while editing\n\nHow to update your running blog?\n- Backup your `content.json` and `data.json` files\n- Copy the files in the `data/1BLogC9LN4oPDcruNz3qo1ysa133E9AGg8` directory to your site.\n" }, { "post_id": 3, "title": "How to have a blog like this", "date_published": 1422140400, "body": "* Stop ZeroNet\n* Create a new site using `python zeronet.py siteCreate` command\n* Copy all file from **data/1BLogC9LN4oPDcruNz3qo1ysa133E9AGg8** to **data/[Your new site address displayed when executed siteCreate]** directory\n* Delete **data** directory and rename **data-default** to **data** to get a clean, empty site\n* Rename **data/users/content-default.json** file to **data/users/content.json**\n* Execute `zeronet.py siteSign [yoursiteaddress] --inner_path data/users/content.json` to sign commenting rules\n* Start ZeroNet\n* Add/Modify content\n* Click on the `Sign & Publish new content` button\n* Congratulations! Your site is ready to access.\n\n_Note: You have to start commands with `..\\python\\python zeronet.py...` if you downloaded ZeroBundle package_" }, { "post_id": 2, "title": "Changelog: Jan 24, 2015", "date_published": 1422105774.057, "body": "* Version 0.1.6\n* Only serve .html files with wrapper frame\n* Http parameter support in url\n* Customizable background-color for wrapper in content.json\n* New Websocket API commands (only allowed on own sites):\n - fileWrite: Modify site's files in hdd from javascript\n - sitePublish: Sign new content and Publish to peers\n* Prompt value support in ZeroFrame (used for prompting privatekey for publishing in ZeroBlog)\n\n---\n\n## Previous changes:\n\n### Jan 20, 2014\n- Version 0.1.5\n- Detect computer wakeup from sleep and acts as startup (check open port, site changes)\n- Announce interval changed from 10min to 20min\n- Delete site files command support\n- Stop unfinished downloads on pause, delete\n- Confirm dialog support to WrapperApi\n\nZeroHello\n- Site Delete menuitem\n- Browser back button doesn't jumps to top\n\n### Jan 19, 2014:\n- Version 0.1.4\n- WIF compatible new private addresses\n- Proper bitcoin address verification, vanity address support: http://127.0.0.1:43110/1ZEro9ZwiZeEveFhcnubFLiN3v7tDL4bz\n- No hash error on worker kill\n- Have you secured your private key? confirmation\n\n### Jan 18, 2014:\n- Version 0.1.3\n- content.json hashing changed from sha1 to sha512 (trimmed to 256bits) for better security, keep hasing to sha1 for backward compatiblility yet\n- Fixed fileserver_port argument parsing\n- Try to ping peer before asking any command if no communication for 20min\n- Ping timeout / retry\n- Reduce websocket bw usage\n- Separate wrapper_key for websocket auth and auth_key to identify user\n- Removed unnecessary from wrapper iframe url\n\nZeroHello:\n- Compatiblilty with 0.1.3 websocket changes while maintaining backward compatibility\n- Better error report on file update fail\n\nZeroBoard:\n- Support for sha512 hashed auth_key, but keeping md5 key support for older versions yet\n\n### Jan 17, 2014:\n- Version 0.1.2\n- Better error message logging\n- Kill workers on download done\n- Retry on socket error\n- Timestamping console messages\n\n### Jan 16:\n- Version to 0.1.1\n- Version info to websocket api\n- Add publisher's zeronet version to content.json\n- Still chasing network publish problems, added more debug info\n\nZeroHello:\n- Your and the latest ZeroNet version added to top right corner (please update if you dont see it)\n" }, { "post_id": 1, "title": "ZeroBlog features", "date_published": 1422105061, "body": "Initial version (Jan 24, 2014):\n\n* Site avatar generated by site address\n* Distraction-free inline edit: Post title, date, body, Site title, description, links\n* Post format using [markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)\n* Code block [syntax highlight](#code-highlight-demos) using [highlight.js](https://highlightjs.org/)\n* Create & Delete post\n* Sign & Publish from web\n* Fold blog post: Content after first `---` won't appear at listing\n* Shareable, friendly post urls\n\n\nTodo:\n\n* ~~Better content editor (contenteditable seemed like a good idea, but tricky support of copy/paste makes it more pain than gain)~~\n* Image upload to post & blog avatar\n* Paging\n* Searching\n* ~~Quick cheat-sheet using markdown~~\n\n---\n\n## Code highlight demos\n### Server-side site publishing (UiWebsocket.py):\n```py\ndef actionSitePublish(self, to, params):\n\tsite = self.site\n\tif not site.settings[\"own\"]: return self.response(to, \"Forbidden, you can only modify your own sites\")\n\n\t# Signing\n\tsite.loadContent(True) # Reload content.json, ignore errors to make it up-to-date\n\tsigned = site.signContent(params[0]) # Sign using private key sent by user\n\tif signed:\n\t\tself.cmd(\"notification\", [\"done\", \"Private key correct, site signed!\", 5000]) # Display message for 5 sec\n\telse:\n\t\tself.cmd(\"notification\", [\"error\", \"Site sign failed: invalid private key.\"])\n\t\tself.response(to, \"Site sign failed\")\n\t\treturn\n\tsite.loadContent(True) # Load new content.json, ignore errors\n\n\t# Publishing\n\tif not site.settings[\"serving\"]: # Enable site if paused\n\t\tsite.settings[\"serving\"] = True\n\t\tsite.saveSettings()\n\t\tsite.announce()\n\n\tpublished = site.publish(5) # Publish to 5 peer\n\n\tif published>0: # Successfuly published\n\t\tself.cmd(\"notification\", [\"done\", \"Site published to %s peers.\" % published, 5000])\n\t\tself.response(to, \"ok\")\n\t\tsite.updateWebsocket() # Send updated site data to local websocket clients\n\telse:\n\t\tif len(site.peers) == 0:\n\t\t\tself.cmd(\"notification\", [\"info\", \"No peers found, but your site is ready to access.\"])\n\t\t\tself.response(to, \"No peers found, but your site is ready to access.\")\n\t\telse:\n\t\t\tself.cmd(\"notification\", [\"error\", \"Site publish failed.\"])\n\t\t\tself.response(to, \"Site publish failed.\")\n```\n\n\n### Client-side site publish (ZeroBlog.coffee)\n```coffee\n# Sign and Publish site\npublish: =>\n\tif not @server_info.ip_external # No port open\n\t\t@cmd \"wrapperNotification\", [\"error\", \"To publish the site please open port #{@server_info.fileserver_port} on your router\"]\n\t\treturn false\n\t@cmd \"wrapperPrompt\", [\"Enter your private key:\", \"password\"], (privatekey) => # Prompt the private key\n\t\t$(\".publishbar .button\").addClass(\"loading\")\n\t\t@cmd \"sitePublish\", [privatekey], (res) =>\n\t\t\t$(\".publishbar .button\").removeClass(\"loading\")\n\t\t\t@log \"Publish result:\", res\n\n\treturn false # Ignore link default event\n```\n\n" } ] } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/data/optional.txt ================================================ hello! ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/data/test_include/content.json ================================================ { "address": "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT", "files": { "data.json": { "sha512": "369d4e780cc80504285f13774ca327fe725eed2d813aad229e62356b07365906", "size": 505 } }, "inner_path": "data/test_include/content.json", "modified": 1470340816.513, "signs": { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": "GxF2ZD0DaMx+CuxafnnRx+IkWTrXubcmTHaJIPyemFpzCvbSo6DyjstN8T3qngFhYIZI/MkcG4ogStG0PLv6p3w=" } } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/data/test_include/data.json ================================================ { "next_topic_id": 1, "topics": [], "next_message_id": 5, "comments": { "1@2": [ { "comment_id": 1, "body": "New user test!", "added": 1423442049 }, { "comment_id": 2, "body": "test 321", "added": 1423531445 }, { "comment_id": 3, "body": "0.2.4 test.", "added": 1424133003 } ] }, "topic_votes": { "1@2": 1, "1@6": 1, "1@69": 1, "607@69": 1 }, "comment_votes": { "35@2": 1, "7@64": 1, "8@64": 1, "50@2": 1, "13@77": 1 } } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json ================================================ { "cert_auth_type": "web", "cert_sign": "G4YB7y749GI6mJboyI7cNNfyMwOS0rcVXLmgq8qmCC4TCaRqup3TGWm8hzeru7+B5iXhq19Ruz286bNVKgNbnwU=", "cert_user_id": "newzeroid@zeroid.bit", "files": { "data.json": { "sha512": "2378ef20379f1db0c3e2a803bfbfda2b68515968b7e311ccc604406168969d34", "size": 161 } }, "modified": 1432554679.913, "signs": { "1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q": "GzX/Ht6ms1dOnqB3kVENvDnxpH+mqA0Zlg3hWy0iwgxpyxWcA4zgmwxcEH41BN9RrvCaxgSd2m1SG1/8qbQPzDY=" } } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/data.json ================================================ { "next_comment_id": 2, "comment": [ { "comment_id": 1, "body": "Test me!", "post_id": 40, "date_added": 1432554679 } ], "comment_vote": {} } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/content.json ================================================ { "address": "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT", "cert_auth_type": "web", "cert_sign": "HBsTrjTmv+zD1iY93tSci8n9DqdEtYwzxJmRppn4/b+RYktcANGm5tXPOb+Duw3AJcgWDcGUvQVgN1D9QAwIlCw=", "cert_user_id": "toruser@zeroid.bit", "files": { "data.json": { "sha512": "4868b5e6d70a55d137db71c2e276bda80437e0235ac670962acc238071296b45", "size": 168 } }, "files_optional": { "peanut-butter-jelly-time.gif": { "sha512": "a238fd27bda2a06f07f9f246954b34dcf82e6472aebdecc2c5dc1f01a50721ef", "size": 1606 } }, "inner_path": "data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/content.json", "modified": 1470340817.676, "optional": ".*\\.(jpg|png|gif)", "signs": { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": "G6UOG3ne1hVe3mDGXHnWX8A1vKzH0XHD6LGMsshvNFVXGn003IFNLUL9dlb3XXJf3tyJGZncvGobzNpwBib08QY=" } } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/data.json ================================================ { "next_comment_id": 2, "comment": [ { "comment_id": 1, "body": "hello from Tor!", "post_id": 38, "date_added": 1432491109 } ], "comment_vote": {} } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json ================================================ { "address": "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT", "cert_auth_type": "web", "cert_sign": "HBsTrjTmv+zD1iY93tSci8n9DqdEtYwzxJmRppn4/b+RYktcANGm5tXPOb+Duw3AJcgWDcGUvQVgN1D9QAwIlCw=", "cert_user_id": "toruser@zeroid.bit", "files": { "data.json": { "sha512": "4868b5e6d70a55d137db71c2e276bda80437e0235ac670962acc238071296b45", "size": 168 } }, "inner_path": "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", "modified": 1470340818.389, "signs": { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": "G6oCzql6KWKAq2aSmZ1pm4SqvwL3e3LRdWxsvILrDc6VWpGZmVgbNn5qW18bA7fewhtA/oKc5+yYjGlTLLOWrB4=" } } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/data.json ================================================ { "next_comment_id": 2, "comment": [ { "comment_id": 1, "body": "hello from Tor!", "post_id": 38, "date_added": 1432491109 } ], "comment_vote": {} } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/data/users/content.json ================================================ { "address": "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT", "files": {}, "ignore": ".*", "inner_path": "data/users/content.json", "modified": 1470340815.228, "signs": { "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": "G25hsrlyTOy8PHKuovKDRC7puoBj/OLIZ3U4OJ01izkhE1BBQ+TOgxX96+HXoZGme2/P4IdEnYjc1rqIZ6O+nFk=" }, "user_contents": { "cert_signers": { "zeroid.bit": [ "1iD5ZQJMNXu43w1qLB8sfdHVKppVMduGz" ] }, "permission_rules": { ".*": { "files_allowed": "data.json", "files_allowed_optional": ".*\\.(png|jpg|gif)", "max_size": 10000, "max_size_optional": 10000000, "signers": [ "14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet" ] }, "bitid/.*@zeroid.bit": { "max_size": 40000 }, "bitmsg/.*@zeroid.bit": { "max_size": 15000 } }, "permissions": { "bad@zeroid.bit": false, "nofish@zeroid.bit": { "max_size": 100000 } } } } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/data-default/data.json ================================================ { "title": "MyZeroBlog", "description": "My ZeroBlog.", "links": "- [Source code](https://github.com/HelloZeroNet)", "next_post_id": 1, "demo": false, "modified": 1432515193, "post": [ ] } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/data-default/users/content-default.json ================================================ { "files": {}, "ignore": ".*", "modified": 1432466966.003, "signs": { "1BLogC9LN4oPDcruNz3qo1ysa133E9AGg8": "HChU28lG4MCnAiui6wDAaVCD4QUrgSy4zZ67+MMHidcUJRkLGnO3j4Eb1N0AWQ86nhSBwoOQf08Rha7gRyTDlAk=" }, "user_contents": { "cert_signers": { "zeroid.bit": [ "1iD5ZQJMNXu43w1qLB8sfdHVKppVMduGz" ] }, "permission_rules": { ".*": { "files_allowed": "data.json", "max_size": 10000 }, "bitid/.*@zeroid.bit": { "max_size": 40000 }, "bitmsg/.*@zeroid.bit": { "max_size": 15000 } }, "permissions": { "banexample@zeroid.bit": false, "nofish@zeroid.bit": { "max_size": 20000 } } } } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/dbschema.json ================================================ { "db_name": "ZeroBlog", "db_file": "data/zeroblog.db", "version": 2, "maps": { "users/.+/data.json": { "to_table": [ "comment", {"node": "comment_vote", "table": "comment_vote", "key_col": "comment_uri", "val_col": "vote"} ] }, "users/.+/content.json": { "to_keyvalue": [ "cert_user_id" ] }, "data.json": { "to_table": [ "post" ], "to_keyvalue": [ "title", "description", "links", "next_post_id", "demo", "modified" ] } }, "tables": { "comment": { "cols": [ ["comment_id", "INTEGER"], ["post_id", "INTEGER"], ["body", "TEXT"], ["date_added", "INTEGER"], ["json_id", "INTEGER REFERENCES json (json_id)"] ], "indexes": ["CREATE UNIQUE INDEX comment_key ON comment(json_id, comment_id)", "CREATE INDEX comment_post_id ON comment(post_id)"], "schema_changed": 1426195823 }, "comment_vote": { "cols": [ ["comment_uri", "TEXT"], ["vote", "INTEGER"], ["json_id", "INTEGER REFERENCES json (json_id)"] ], "indexes": ["CREATE INDEX comment_vote_comment_uri ON comment_vote(comment_uri)", "CREATE INDEX comment_vote_json_id ON comment_vote(json_id)"], "schema_changed": 1426195822 }, "post": { "cols": [ ["post_id", "INTEGER"], ["title", "TEXT"], ["body", "TEXT"], ["date_published", "INTEGER"], ["json_id", "INTEGER REFERENCES json (json_id)"] ], "indexes": ["CREATE UNIQUE INDEX post_uri ON post(json_id, post_id)", "CREATE INDEX post_id ON post(post_id)"], "schema_changed": 1426195823 } } } ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/index.html ================================================ ZeroBlog Demo
    • # H1
    • ## H2
    • ### H3
    • _italic_
    • **bold**
    • ~~strikethrough~~
    • - Lists
    • 1. Numbered lists
    • [Links](http://www.zeronet.io)
    • [References][1]
      [1]: Can be used
    • ![image alt](img/logo.png)
    • Inline `code`
    • ```python
      print "Code block"
      ```
    • > Quotes
    • --- Horizontal rule
    ? Editing: Post:21.body Save Delete Cancel
    Content changed Sign & Publish new content
    Add new post

    Title

    21 hours ago · 2 min read ·
    3 comments
    Body
    Read more

    Title

    21 hours ago · 2 min read

    0 Comments:

    user_name 1 day ago
    Reply
    Body
    ================================================ FILE: src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT-original/js/all.js ================================================ /* ---- data/1BLogC9LN4oPDcruNz3qo1ysa133E9AGg8/js/lib/00-jquery.min.js ---- */ /*! jQuery v2.1.3 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.3",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=hb(),z=hb(),A=hb(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},eb=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fb){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function gb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+rb(o[l]);w=ab.test(a)&&pb(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function hb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ib(a){return a[u]=!0,a}function jb(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function kb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function lb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function nb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function ob(a){return ib(function(b){return b=+b,ib(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pb(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=gb.support={},f=gb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=gb.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",eb,!1):e.attachEvent&&e.attachEvent("onunload",eb)),p=!f(g),c.attributes=jb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=jb(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=jb(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(jb(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),jb(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&jb(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return lb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?lb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},gb.matches=function(a,b){return gb(a,null,null,b)},gb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return gb(b,n,null,[a]).length>0},gb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},gb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},gb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},gb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=gb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=gb.selectors={cacheLength:50,createPseudo:ib,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||gb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&gb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=gb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||gb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ib(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ib(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ib(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ib(function(a){return function(b){return gb(a,b).length>0}}),contains:ib(function(a){return a=a.replace(cb,db),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ib(function(a){return W.test(a||"")||gb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:ob(function(){return[0]}),last:ob(function(a,b){return[b-1]}),eq:ob(function(a,b,c){return[0>c?c+b:c]}),even:ob(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:ob(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:ob(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:ob(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function sb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function tb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ub(a,b,c){for(var d=0,e=b.length;e>d;d++)gb(a,b[d],c);return c}function vb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wb(a,b,c,d,e,f){return d&&!d[u]&&(d=wb(d)),e&&!e[u]&&(e=wb(e,f)),ib(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ub(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:vb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=vb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=vb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sb(function(a){return a===b},h,!0),l=sb(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sb(tb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wb(i>1&&tb(m),i>1&&rb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xb(a.slice(i,e)),f>e&&xb(a=a.slice(e)),f>e&&rb(a))}m.push(c)}return tb(m)}function yb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=vb(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&gb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ib(f):f}return h=gb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,yb(e,d)),f.selector=a}return f},i=gb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&pb(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&rb(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&pb(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=jb(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),jb(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||kb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&jb(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||kb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),jb(function(a){return null==a.getAttribute("disabled")})||kb(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),gb}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+K.uid++}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c) },removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthx",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*\s*$/g,ib={option:[1,""],thead:[1,"","
    "],col:[2,"","
    "],tr:[2,"","
    "],td:[3,"","
    "],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(ob(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(ob(c,"script"),kb),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(hb,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function tb(a){var b=l,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||n(" ================================================ FILE: src/User/User.py ================================================ import logging import json import time import binascii import gevent import util from Crypt import CryptBitcoin from Plugin import PluginManager from Config import config from util import helper from Debug import Debug @PluginManager.acceptPlugins class User(object): def __init__(self, master_address=None, master_seed=None, data={}): if master_seed: self.master_seed = master_seed self.master_address = CryptBitcoin.privatekeyToAddress(self.master_seed) elif master_address: self.master_address = master_address self.master_seed = data.get("master_seed") else: self.master_seed = CryptBitcoin.newSeed() self.master_address = CryptBitcoin.privatekeyToAddress(self.master_seed) self.sites = data.get("sites", {}) self.certs = data.get("certs", {}) self.settings = data.get("settings", {}) self.delayed_save_thread = None self.log = logging.getLogger("User:%s" % self.master_address) # Save to data/users.json @util.Noparallel(queue=True, ignore_class=True) def save(self): s = time.time() users = json.load(open("%s/users.json" % config.data_dir)) if self.master_address not in users: users[self.master_address] = {} # Create if not exist user_data = users[self.master_address] if self.master_seed: user_data["master_seed"] = self.master_seed user_data["sites"] = self.sites user_data["certs"] = self.certs user_data["settings"] = self.settings helper.atomicWrite("%s/users.json" % config.data_dir, helper.jsonDumps(users).encode("utf8")) self.log.debug("Saved in %.3fs" % (time.time() - s)) self.delayed_save_thread = None def saveDelayed(self): if not self.delayed_save_thread: self.delayed_save_thread = gevent.spawn_later(5, self.save) def getAddressAuthIndex(self, address): return int(binascii.hexlify(address.encode()), 16) @util.Noparallel() def generateAuthAddress(self, address): s = time.time() address_id = self.getAddressAuthIndex(address) # Convert site address to int auth_privatekey = CryptBitcoin.hdPrivatekey(self.master_seed, address_id) self.sites[address] = { "auth_address": CryptBitcoin.privatekeyToAddress(auth_privatekey), "auth_privatekey": auth_privatekey } self.saveDelayed() self.log.debug("Added new site: %s in %.3fs" % (address, time.time() - s)) return self.sites[address] # Get user site data # Return: {"auth_address": "xxx", "auth_privatekey": "xxx"} def getSiteData(self, address, create=True): if address not in self.sites: # Generate new BIP32 child key based on site address if not create: return {"auth_address": None, "auth_privatekey": None} # Dont create user yet self.generateAuthAddress(address) return self.sites[address] def deleteSiteData(self, address): if address in self.sites: del(self.sites[address]) self.saveDelayed() self.log.debug("Deleted site: %s" % address) def setSiteSettings(self, address, settings): site_data = self.getSiteData(address) site_data["settings"] = settings self.saveDelayed() return site_data # Get data for a new, unique site # Return: [site_address, bip32_index, {"auth_address": "xxx", "auth_privatekey": "xxx", "privatekey": "xxx"}] def getNewSiteData(self): import random bip32_index = random.randrange(2 ** 256) % 100000000 site_privatekey = CryptBitcoin.hdPrivatekey(self.master_seed, bip32_index) site_address = CryptBitcoin.privatekeyToAddress(site_privatekey) if site_address in self.sites: raise Exception("Random error: site exist!") # Save to sites self.getSiteData(site_address) self.sites[site_address]["privatekey"] = site_privatekey self.save() return site_address, bip32_index, self.sites[site_address] # Get BIP32 address from site address # Return: BIP32 auth address def getAuthAddress(self, address, create=True): cert = self.getCert(address) if cert: return cert["auth_address"] else: return self.getSiteData(address, create)["auth_address"] def getAuthPrivatekey(self, address, create=True): cert = self.getCert(address) if cert: return cert["auth_privatekey"] else: return self.getSiteData(address, create)["auth_privatekey"] # Add cert for the user def addCert(self, auth_address, domain, auth_type, auth_user_name, cert_sign): # Find privatekey by auth address auth_privatekey = [site["auth_privatekey"] for site in list(self.sites.values()) if site["auth_address"] == auth_address][0] cert_node = { "auth_address": auth_address, "auth_privatekey": auth_privatekey, "auth_type": auth_type, "auth_user_name": auth_user_name, "cert_sign": cert_sign } # Check if we have already cert for that domain and its not the same if self.certs.get(domain) and self.certs[domain] != cert_node: return False elif self.certs.get(domain) == cert_node: # Same, not updated return None else: # Not exist yet, add self.certs[domain] = cert_node self.save() return True # Remove cert from user def deleteCert(self, domain): del self.certs[domain] # Set active cert for a site def setCert(self, address, domain): site_data = self.getSiteData(address) if domain: site_data["cert"] = domain else: if "cert" in site_data: del site_data["cert"] self.saveDelayed() return site_data # Get cert for the site address # Return: { "auth_address":.., "auth_privatekey":.., "auth_type": "web", "auth_user_name": "nofish", "cert_sign":.. } or None def getCert(self, address): site_data = self.getSiteData(address, create=False) if not site_data or "cert" not in site_data: return None # Site dont have cert return self.certs.get(site_data["cert"]) # Get cert user name for the site address # Return: user@certprovider.bit or None def getCertUserId(self, address): site_data = self.getSiteData(address, create=False) if not site_data or "cert" not in site_data: return None # Site dont have cert cert = self.certs.get(site_data["cert"]) if cert: return cert["auth_user_name"] + "@" + site_data["cert"] ================================================ FILE: src/User/UserManager.py ================================================ # Included modules import json import logging import time # ZeroNet Modules from .User import User from Plugin import PluginManager from Config import config @PluginManager.acceptPlugins class UserManager(object): def __init__(self): self.users = {} self.log = logging.getLogger("UserManager") # Load all user from data/users.json def load(self): if not self.users: self.users = {} user_found = [] added = 0 s = time.time() # Load new users try: json_path = "%s/users.json" % config.data_dir data = json.load(open(json_path)) except Exception as err: raise Exception("Unable to load %s: %s" % (json_path, err)) for master_address, data in list(data.items()): if master_address not in self.users: user = User(master_address, data=data) self.users[master_address] = user added += 1 user_found.append(master_address) # Remove deleted adresses for master_address in list(self.users.keys()): if master_address not in user_found: del(self.users[master_address]) self.log.debug("Removed user: %s" % master_address) if added: self.log.debug("Added %s users in %.3fs" % (added, time.time() - s)) # Create new user # Return: User def create(self, master_address=None, master_seed=None): self.list() # Load the users if it's not loaded yet user = User(master_address, master_seed) self.log.debug("Created user: %s" % user.master_address) if user.master_address: # If successfully created self.users[user.master_address] = user user.saveDelayed() return user # List all users from data/users.json # Return: {"usermasteraddr": User} def list(self): if self.users == {}: # Not loaded yet self.load() return self.users # Get user based on master_address # Return: User or None def get(self, master_address=None): users = self.list() if users: return list(users.values())[0] # Single user mode, always return the first else: return None user_manager = UserManager() # Singleton ================================================ FILE: src/User/__init__.py ================================================ from .User import User ================================================ FILE: src/Worker/Worker.py ================================================ import time import gevent import gevent.lock from Debug import Debug from Config import config from Content.ContentManager import VerifyError class WorkerDownloadError(Exception): pass class WorkerIOError(Exception): pass class WorkerStop(Exception): pass class Worker(object): def __init__(self, manager, peer): self.manager = manager self.peer = peer self.task = None self.key = None self.running = False self.thread = None self.num_downloaded = 0 self.num_failed = 0 def __str__(self): return "Worker %s %s" % (self.manager.site.address_short, self.key) def __repr__(self): return "<%s>" % self.__str__() def waitForTask(self, task, timeout): # Wait for other workers to finish the task for sleep_i in range(1, timeout * 10): time.sleep(0.1) if task["done"] or task["workers_num"] == 0: if config.verbose: self.manager.log.debug("%s: %s, picked task free after %ss sleep. (done: %s)" % ( self.key, task["inner_path"], 0.1 * sleep_i, task["done"] )) break if sleep_i % 10 == 0: workers = self.manager.findWorkers(task) if not workers or not workers[0].peer.connection: break worker_idle = time.time() - workers[0].peer.connection.last_recv_time if worker_idle > 1: if config.verbose: self.manager.log.debug("%s: %s, worker %s seems idle, picked up task after %ss sleep. (done: %s)" % ( self.key, task["inner_path"], workers[0].key, 0.1 * sleep_i, task["done"] )) break return True def pickTask(self): # Find and select a new task for the worker task = self.manager.getTask(self.peer) if not task: # No more task time.sleep(0.1) # Wait a bit for new tasks task = self.manager.getTask(self.peer) if not task: # Still no task, stop it stats = "downloaded files: %s, failed: %s" % (self.num_downloaded, self.num_failed) self.manager.log.debug("%s: No task found, stopping (%s)" % (self.key, stats)) return False if not task["time_started"]: task["time_started"] = time.time() # Task started now if task["workers_num"] > 0: # Wait a bit if someone already working on it if task["peers"]: # It's an update timeout = 3 else: timeout = 1 if task["size"] > 100 * 1024 * 1024: timeout = timeout * 2 if config.verbose: self.manager.log.debug("%s: Someone already working on %s (pri: %s), sleeping %s sec..." % ( self.key, task["inner_path"], task["priority"], timeout )) self.waitForTask(task, timeout) return task def downloadTask(self, task): try: buff = self.peer.getFile(task["site"].address, task["inner_path"], task["size"]) except Exception as err: self.manager.log.debug("%s: getFile error: %s" % (self.key, err)) raise WorkerDownloadError(str(err)) if not buff: raise WorkerDownloadError("No response") return buff def getTaskLock(self, task): if task["lock"] is None: task["lock"] = gevent.lock.Semaphore() return task["lock"] def writeTask(self, task, buff): buff.seek(0) try: task["site"].storage.write(task["inner_path"], buff) except Exception as err: if type(err) == Debug.Notify: self.manager.log.debug("%s: Write aborted: %s (%s: %s)" % (self.key, task["inner_path"], type(err), err)) else: self.manager.log.error("%s: Error writing: %s (%s: %s)" % (self.key, task["inner_path"], type(err), err)) raise WorkerIOError(str(err)) def onTaskVerifyFail(self, task, error_message): self.num_failed += 1 if self.manager.started_task_num < 50 or config.verbose: self.manager.log.debug( "%s: Verify failed: %s, error: %s, failed peers: %s, workers: %s" % (self.key, task["inner_path"], error_message, len(task["failed"]), task["workers_num"]) ) task["failed"].append(self.peer) self.peer.hash_failed += 1 if self.peer.hash_failed >= max(len(self.manager.tasks), 3) or self.peer.connection_error > 10: # Broken peer: More fails than tasks number but atleast 3 raise WorkerStop( "Too many errors (hash failed: %s, connection error: %s)" % (self.peer.hash_failed, self.peer.connection_error) ) def handleTask(self, task): download_err = write_err = False write_lock = None try: buff = self.downloadTask(task) if task["done"] is True: # Task done, try to find new one return None if self.running is False: # Worker no longer needed or got killed self.manager.log.debug("%s: No longer needed, returning: %s" % (self.key, task["inner_path"])) raise WorkerStop("Running got disabled") write_lock = self.getTaskLock(task) write_lock.acquire() if task["site"].content_manager.verifyFile(task["inner_path"], buff) is None: is_same = True else: is_same = False is_valid = True except (WorkerDownloadError, VerifyError) as err: download_err = err is_valid = False is_same = False if is_valid and not is_same: if self.manager.started_task_num < 50 or task["priority"] > 10 or config.verbose: self.manager.log.debug("%s: Verify correct: %s" % (self.key, task["inner_path"])) try: self.writeTask(task, buff) except WorkerIOError as err: write_err = err if not task["done"]: if write_err: self.manager.failTask(task, reason="Write error") self.num_failed += 1 self.manager.log.error("%s: Error writing %s: %s" % (self.key, task["inner_path"], write_err)) elif is_valid: self.manager.doneTask(task) self.num_downloaded += 1 if write_lock is not None and write_lock.locked(): write_lock.release() if not is_valid: self.onTaskVerifyFail(task, download_err) time.sleep(1) return False return True def downloader(self): self.peer.hash_failed = 0 # Reset hash error counter while self.running: # Try to pickup free file download task task = self.pickTask() if not task: break if task["done"]: continue self.task = task self.manager.addTaskWorker(task, self) try: success = self.handleTask(task) except WorkerStop as err: self.manager.log.debug("%s: Worker stopped: %s" % (self.key, err)) self.manager.removeTaskWorker(task, self) break self.manager.removeTaskWorker(task, self) self.peer.onWorkerDone() self.running = False self.manager.removeWorker(self) # Start the worker def start(self): self.running = True self.thread = gevent.spawn(self.downloader) # Skip current task def skip(self, reason="Unknown"): self.manager.log.debug("%s: Force skipping (reason: %s)" % (self.key, reason)) if self.thread: self.thread.kill(exception=Debug.createNotifyType("Worker skipping (reason: %s)" % reason)) self.start() # Force stop the worker def stop(self, reason="Unknown"): self.manager.log.debug("%s: Force stopping (reason: %s)" % (self.key, reason)) self.running = False if self.thread: self.thread.kill(exception=Debug.createNotifyType("Worker stopped (reason: %s)" % reason)) del self.thread self.manager.removeWorker(self) ================================================ FILE: src/Worker/WorkerManager.py ================================================ import time import logging import collections import gevent from .Worker import Worker from .WorkerTaskManager import WorkerTaskManager from Config import config from util import helper from Plugin import PluginManager from Debug.DebugLock import DebugLock import util @PluginManager.acceptPlugins class WorkerManager(object): def __init__(self, site): self.site = site self.workers = {} # Key: ip:port, Value: Worker.Worker self.tasks = WorkerTaskManager() self.next_task_id = 1 self.lock_add_task = DebugLock(name="Lock AddTask:%s" % self.site.address_short) # {"id": 1, "evt": evt, "workers_num": 0, "site": self.site, "inner_path": inner_path, "done": False, "optional_hash_id": None, # "time_started": None, "time_added": time.time(), "peers": peers, "priority": 0, "failed": peer_ids, "lock": None or gevent.lock.RLock} self.started_task_num = 0 # Last added task num self.asked_peers = [] self.running = True self.time_task_added = 0 self.log = logging.getLogger("WorkerManager:%s" % self.site.address_short) self.site.greenlet_manager.spawn(self.checkTasks) def __str__(self): return "WorkerManager %s" % self.site.address_short def __repr__(self): return "<%s>" % self.__str__() # Check expired tasks def checkTasks(self): while self.running: tasks = task = worker = workers = None # Cleanup local variables announced = False time.sleep(15) # Check every 15 sec # Clean up workers for worker in list(self.workers.values()): if worker.task and worker.task["done"]: worker.skip(reason="Task done") # Stop workers with task done if not self.tasks: continue tasks = self.tasks[:] # Copy it so removing elements wont cause any problem num_tasks_started = len([task for task in tasks if task["time_started"]]) self.log.debug( "Tasks: %s, started: %s, bad files: %s, total started: %s" % (len(tasks), num_tasks_started, len(self.site.bad_files), self.started_task_num) ) for task in tasks: if task["time_started"] and time.time() >= task["time_started"] + 60: self.log.debug("Timeout, Skipping: %s" % task) # Task taking too long time, skip it # Skip to next file workers workers = self.findWorkers(task) if workers: for worker in workers: worker.skip(reason="Task timeout") else: self.failTask(task, reason="No workers") elif time.time() >= task["time_added"] + 60 and not self.workers: # No workers left self.failTask(task, reason="Timeout") elif (task["time_started"] and time.time() >= task["time_started"] + 15) or not self.workers: # Find more workers: Task started more than 15 sec ago or no workers workers = self.findWorkers(task) self.log.debug( "Slow task: %s, (workers: %s, optional_hash_id: %s, peers: %s, failed: %s, asked: %s)" % ( task["inner_path"], len(workers), task["optional_hash_id"], len(task["peers"] or []), len(task["failed"]), len(self.asked_peers) ) ) if not announced and task["site"].isAddedRecently(): task["site"].announce(mode="more") # Find more peers announced = True if task["optional_hash_id"]: if self.workers: if not task["time_started"]: ask_limit = 20 else: ask_limit = max(10, time.time() - task["time_started"]) if len(self.asked_peers) < ask_limit and len(task["peers"] or []) <= len(task["failed"]) * 2: # Re-search for high priority self.startFindOptional(find_more=True) if task["peers"]: peers_try = [peer for peer in task["peers"] if peer not in task["failed"] and peer not in workers] if peers_try: self.startWorkers(peers_try, force_num=5, reason="Task checker (optional, has peers)") else: self.startFindOptional(find_more=True) else: self.startFindOptional(find_more=True) else: if task["peers"]: # Release the peer lock self.log.debug("Task peer lock release: %s" % task["inner_path"]) task["peers"] = [] self.startWorkers(reason="Task checker") if len(self.tasks) > len(self.workers) * 2 and len(self.workers) < self.getMaxWorkers(): self.startWorkers(reason="Task checker (need more workers)") self.log.debug("checkTasks stopped running") # Returns the next free or less worked task def getTask(self, peer): for task in self.tasks: # Find a task if task["peers"] and peer not in task["peers"]: continue # This peer not allowed to pick this task if peer in task["failed"]: continue # Peer already tried to solve this, but failed if task["optional_hash_id"] and task["peers"] is None: continue # No peers found yet for the optional task if task["done"]: continue return task def removeSolvedFileTasks(self, mark_as_good=True): for task in self.tasks[:]: if task["inner_path"] not in self.site.bad_files: self.log.debug("No longer in bad_files, marking as %s: %s" % (mark_as_good, task["inner_path"])) task["done"] = True task["evt"].set(mark_as_good) self.tasks.remove(task) if not self.tasks: self.started_task_num = 0 self.site.updateWebsocket() # New peers added to site def onPeers(self): self.startWorkers(reason="More peers found") def getMaxWorkers(self): if len(self.tasks) > 50: return config.workers * 3 else: return config.workers # Add new worker def addWorker(self, peer, multiplexing=False, force=False): key = peer.key if len(self.workers) > self.getMaxWorkers() and not force: return False if multiplexing: # Add even if we already have worker for this peer key = "%s/%s" % (key, len(self.workers)) if key not in self.workers: # We dont have worker for that peer and workers num less than max task = self.getTask(peer) if task: worker = Worker(self, peer) self.workers[key] = worker worker.key = key worker.start() return worker else: return False else: # We have worker for this peer or its over the limit return False def taskAddPeer(self, task, peer): if task["peers"] is None: task["peers"] = [] if peer in task["failed"]: return False if peer not in task["peers"]: task["peers"].append(peer) return True # Start workers to process tasks def startWorkers(self, peers=None, force_num=0, reason="Unknown"): if not self.tasks: return False # No task for workers max_workers = min(self.getMaxWorkers(), len(self.site.peers)) if len(self.workers) >= max_workers and not peers: return False # Workers number already maxed and no starting peers defined self.log.debug( "Starting workers (%s), tasks: %s, peers: %s, workers: %s" % (reason, len(self.tasks), len(peers or []), len(self.workers)) ) if not peers: peers = self.site.getConnectedPeers() if len(peers) < max_workers: peers += self.site.getRecentPeers(max_workers * 2) if type(peers) is set: peers = list(peers) # Sort by ping peers.sort(key=lambda peer: peer.connection.last_ping_delay if peer.connection and peer.connection.last_ping_delay and len(peer.connection.waiting_requests) == 0 and peer.connection.connected else 9999) for peer in peers: # One worker for every peer if peers and peer not in peers: continue # If peers defined and peer not valid if force_num: worker = self.addWorker(peer, force=True) force_num -= 1 else: worker = self.addWorker(peer) if worker: self.log.debug("Added worker: %s (rep: %s), workers: %s/%s" % (peer.key, peer.reputation, len(self.workers), max_workers)) # Find peers for optional hash in local hash tables and add to task peers def findOptionalTasks(self, optional_tasks, reset_task=False): found = collections.defaultdict(list) # { found_hash: [peer1, peer2...], ...} for peer in list(self.site.peers.values()): if not peer.has_hashfield: continue hashfield_set = set(peer.hashfield) # Finding in set is much faster for task in optional_tasks: optional_hash_id = task["optional_hash_id"] if optional_hash_id in hashfield_set: if reset_task and len(task["failed"]) > 0: task["failed"] = [] if peer in task["failed"]: continue if self.taskAddPeer(task, peer): found[optional_hash_id].append(peer) return found # Find peers for optional hash ids in local hash tables def findOptionalHashIds(self, optional_hash_ids, limit=0): found = collections.defaultdict(list) # { found_hash_id: [peer1, peer2...], ...} for peer in list(self.site.peers.values()): if not peer.has_hashfield: continue hashfield_set = set(peer.hashfield) # Finding in set is much faster for optional_hash_id in optional_hash_ids: if optional_hash_id in hashfield_set: found[optional_hash_id].append(peer) if limit and len(found[optional_hash_id]) >= limit: optional_hash_ids.remove(optional_hash_id) return found # Add peers to tasks from found result def addOptionalPeers(self, found_ips): found = collections.defaultdict(list) for hash_id, peer_ips in found_ips.items(): task = [task for task in self.tasks if task["optional_hash_id"] == hash_id] if task: # Found task, lets take the first task = task[0] else: continue for peer_ip in peer_ips: peer = self.site.addPeer(peer_ip[0], peer_ip[1], return_peer=True, source="optional") if not peer: continue if self.taskAddPeer(task, peer): found[hash_id].append(peer) if peer.hashfield.appendHashId(hash_id): # Peer has this file peer.time_hashfield = None # Peer hashfield probably outdated return found # Start find peers for optional files @util.Noparallel(blocking=False, ignore_args=True) def startFindOptional(self, reset_task=False, find_more=False, high_priority=False): # Wait for more file requests if len(self.tasks) < 20 or high_priority: time.sleep(0.01) elif len(self.tasks) > 90: time.sleep(5) else: time.sleep(0.5) optional_tasks = [task for task in self.tasks if task["optional_hash_id"]] if not optional_tasks: return False optional_hash_ids = set([task["optional_hash_id"] for task in optional_tasks]) time_tasks = self.time_task_added self.log.debug( "Finding peers for optional files: %s (reset_task: %s, find_more: %s)" % (optional_hash_ids, reset_task, find_more) ) found = self.findOptionalTasks(optional_tasks, reset_task=reset_task) if found: found_peers = set([peer for peers in list(found.values()) for peer in peers]) self.startWorkers(found_peers, force_num=3, reason="Optional found in local peers") if len(found) < len(optional_hash_ids) or find_more or (high_priority and any(len(peers) < 10 for peers in found.values())): self.log.debug("No local result for optional files: %s" % (optional_hash_ids - set(found))) # Query hashfield from connected peers threads = [] peers = self.site.getConnectedPeers() if not peers: peers = self.site.getConnectablePeers() for peer in peers: threads.append(self.site.greenlet_manager.spawn(peer.updateHashfield, force=find_more)) gevent.joinall(threads, timeout=5) if time_tasks != self.time_task_added: # New task added since start optional_tasks = [task for task in self.tasks if task["optional_hash_id"]] optional_hash_ids = set([task["optional_hash_id"] for task in optional_tasks]) found = self.findOptionalTasks(optional_tasks) self.log.debug("Found optional files after query hashtable connected peers: %s/%s" % ( len(found), len(optional_hash_ids) )) if found: found_peers = set([peer for hash_id_peers in list(found.values()) for peer in hash_id_peers]) self.startWorkers(found_peers, force_num=3, reason="Optional found in connected peers") if len(found) < len(optional_hash_ids) or find_more: self.log.debug( "No connected hashtable result for optional files: %s (asked: %s)" % (optional_hash_ids - set(found), len(self.asked_peers)) ) if not self.tasks: self.log.debug("No tasks, stopping finding optional peers") return # Try to query connected peers threads = [] peers = [peer for peer in self.site.getConnectedPeers() if peer.key not in self.asked_peers][0:10] if not peers: peers = self.site.getConnectablePeers(ignore=self.asked_peers) for peer in peers: threads.append(self.site.greenlet_manager.spawn(peer.findHashIds, list(optional_hash_ids))) self.asked_peers.append(peer.key) for i in range(5): time.sleep(1) thread_values = [thread.value for thread in threads if thread.value] if not thread_values: continue found_ips = helper.mergeDicts(thread_values) found = self.addOptionalPeers(found_ips) self.log.debug("Found optional files after findhash connected peers: %s/%s (asked: %s)" % ( len(found), len(optional_hash_ids), len(threads) )) if found: found_peers = set([peer for hash_id_peers in list(found.values()) for peer in hash_id_peers]) self.startWorkers(found_peers, force_num=3, reason="Optional found by findhash connected peers") if len(thread_values) == len(threads): # Got result from all started thread break if len(found) < len(optional_hash_ids): self.log.debug( "No findHash result, try random peers: %s (asked: %s)" % (optional_hash_ids - set(found), len(self.asked_peers)) ) # Try to query random peers if time_tasks != self.time_task_added: # New task added since start optional_tasks = [task for task in self.tasks if task["optional_hash_id"]] optional_hash_ids = set([task["optional_hash_id"] for task in optional_tasks]) threads = [] peers = self.site.getConnectablePeers(ignore=self.asked_peers) for peer in peers: threads.append(self.site.greenlet_manager.spawn(peer.findHashIds, list(optional_hash_ids))) self.asked_peers.append(peer.key) gevent.joinall(threads, timeout=15) found_ips = helper.mergeDicts([thread.value for thread in threads if thread.value]) found = self.addOptionalPeers(found_ips) self.log.debug("Found optional files after findhash random peers: %s/%s" % (len(found), len(optional_hash_ids))) if found: found_peers = set([peer for hash_id_peers in list(found.values()) for peer in hash_id_peers]) self.startWorkers(found_peers, force_num=3, reason="Option found using findhash random peers") if len(found) < len(optional_hash_ids): self.log.debug("No findhash result for optional files: %s" % (optional_hash_ids - set(found))) if time_tasks != self.time_task_added: # New task added since start self.log.debug("New task since start, restarting...") self.site.greenlet_manager.spawnLater(0.1, self.startFindOptional) else: self.log.debug("startFindOptional ended") # Stop all worker def stopWorkers(self): num = 0 for worker in list(self.workers.values()): worker.stop(reason="Stopping all workers") num += 1 tasks = self.tasks[:] # Copy for task in tasks: # Mark all current task as failed self.failTask(task, reason="Stopping all workers") return num # Find workers by task def findWorkers(self, task): workers = [] for worker in list(self.workers.values()): if worker.task == task: workers.append(worker) return workers # Ends and remove a worker def removeWorker(self, worker): worker.running = False if worker.key in self.workers: del(self.workers[worker.key]) self.log.debug("Removed worker, workers: %s/%s" % (len(self.workers), self.getMaxWorkers())) if len(self.workers) <= self.getMaxWorkers() / 3 and len(self.asked_peers) < 10: optional_task = next((task for task in self.tasks if task["optional_hash_id"]), None) if optional_task: if len(self.workers) == 0: self.startFindOptional(find_more=True) else: self.startFindOptional() elif self.tasks and not self.workers and worker.task and len(worker.task["failed"]) < 20: self.log.debug("Starting new workers... (tasks: %s)" % len(self.tasks)) self.startWorkers(reason="Removed worker") # Tasks sorted by this def getPriorityBoost(self, inner_path): if inner_path == "content.json": return 9999 # Content.json always priority if inner_path == "index.html": return 9998 # index.html also important if "-default" in inner_path: return -4 # Default files are cloning not important elif inner_path.endswith("all.css"): return 14 # boost css files priority elif inner_path.endswith("all.js"): return 13 # boost js files priority elif inner_path.endswith("dbschema.json"): return 12 # boost database specification elif inner_path.endswith("content.json"): return 1 # boost included content.json files priority a bit elif inner_path.endswith(".json"): if len(inner_path) < 50: # Boost non-user json files return 11 else: return 2 return 0 def addTaskUpdate(self, task, peer, priority=0): if priority > task["priority"]: self.tasks.updateItem(task, "priority", priority) if peer and task["peers"]: # This peer also has new version, add it to task possible peers task["peers"].append(peer) self.log.debug("Added peer %s to %s" % (peer.key, task["inner_path"])) self.startWorkers([peer], reason="Added new task (update received by peer)") elif peer and peer in task["failed"]: task["failed"].remove(peer) # New update arrived, remove the peer from failed peers self.log.debug("Removed peer %s from failed %s" % (peer.key, task["inner_path"])) self.startWorkers([peer], reason="Added new task (peer failed before)") def addTaskCreate(self, inner_path, peer, priority=0, file_info=None): evt = gevent.event.AsyncResult() if peer: peers = [peer] # Only download from this peer else: peers = None if not file_info: file_info = self.site.content_manager.getFileInfo(inner_path) if file_info and file_info["optional"]: optional_hash_id = helper.toHashId(file_info["sha512"]) else: optional_hash_id = None if file_info: size = file_info.get("size", 0) else: size = 0 self.lock_add_task.acquire() # Check again if we have task for this file task = self.tasks.findTask(inner_path) if task: self.addTaskUpdate(task, peer, priority) return task priority += self.getPriorityBoost(inner_path) if self.started_task_num == 0: # Boost priority for first requested file priority += 1 task = { "id": self.next_task_id, "evt": evt, "workers_num": 0, "site": self.site, "inner_path": inner_path, "done": False, "optional_hash_id": optional_hash_id, "time_added": time.time(), "time_started": None, "lock": None, "time_action": None, "peers": peers, "priority": priority, "failed": [], "size": size } self.tasks.append(task) self.lock_add_task.release() self.next_task_id += 1 self.started_task_num += 1 if config.verbose: self.log.debug( "New task: %s, peer lock: %s, priority: %s, optional_hash_id: %s, tasks started: %s" % (task["inner_path"], peers, priority, optional_hash_id, self.started_task_num) ) self.time_task_added = time.time() if optional_hash_id: if self.asked_peers: del self.asked_peers[:] # Reset asked peers self.startFindOptional(high_priority=priority > 0) if peers: self.startWorkers(peers, reason="Added new optional task") else: self.startWorkers(peers, reason="Added new task") return task # Create new task and return asyncresult def addTask(self, inner_path, peer=None, priority=0, file_info=None): self.site.onFileStart(inner_path) # First task, trigger site download started task = self.tasks.findTask(inner_path) if task: # Already has task for that file self.addTaskUpdate(task, peer, priority) else: # No task for that file yet task = self.addTaskCreate(inner_path, peer, priority, file_info) return task def addTaskWorker(self, task, worker): try: self.tasks.updateItem(task, "workers_num", task["workers_num"] + 1) except ValueError: task["workers_num"] += 1 def removeTaskWorker(self, task, worker): try: self.tasks.updateItem(task, "workers_num", task["workers_num"] - 1) except ValueError: task["workers_num"] -= 1 if len(task["failed"]) >= len(self.workers): fail_reason = "Too many fails: %s (workers: %s)" % (len(task["failed"]), len(self.workers)) self.failTask(task, reason=fail_reason) # Wait for other tasks def checkComplete(self): time.sleep(0.1) if not self.tasks: self.log.debug("Check complete: No tasks") self.onComplete() def onComplete(self): self.started_task_num = 0 del self.asked_peers[:] self.site.onComplete() # No more task trigger site complete # Mark a task done def doneTask(self, task): task["done"] = True self.tasks.remove(task) # Remove from queue if task["optional_hash_id"]: self.log.debug( "Downloaded optional file in %.3fs, adding to hashfield: %s" % (time.time() - task["time_started"], task["inner_path"]) ) self.site.content_manager.optionalDownloaded(task["inner_path"], task["optional_hash_id"], task["size"]) self.site.onFileDone(task["inner_path"]) task["evt"].set(True) if not self.tasks: self.site.greenlet_manager.spawn(self.checkComplete) # Mark a task failed def failTask(self, task, reason="Unknown"): try: self.tasks.remove(task) # Remove from queue except ValueError as err: return False self.log.debug("Task %s failed (Reason: %s)" % (task["inner_path"], reason)) task["done"] = True self.site.onFileFail(task["inner_path"]) task["evt"].set(False) if not self.tasks: self.site.greenlet_manager.spawn(self.checkComplete) ================================================ FILE: src/Worker/WorkerTaskManager.py ================================================ import bisect from collections.abc import MutableSequence class CustomSortedList(MutableSequence): def __init__(self): super().__init__() self.items = [] # (priority, added index, actual value) self.logging = False def __repr__(self): return "<{0} {1}>".format(self.__class__.__name__, self.items) def __len__(self): return len(self.items) def __getitem__(self, index): if type(index) is int: return self.items[index][2] else: return [item[2] for item in self.items[index]] def __delitem__(self, index): del self.items[index] def __setitem__(self, index, value): self.items[index] = self.valueToItem(value) def __str__(self): return str(self[:]) def insert(self, index, value): self.append(value) def append(self, value): bisect.insort(self.items, self.valueToItem(value)) def updateItem(self, value, update_key=None, update_value=None): self.remove(value) if update_key is not None: value[update_key] = update_value self.append(value) def sort(self, *args, **kwargs): raise Exception("Sorted list can't be sorted") def valueToItem(self, value): return (self.getPriority(value), self.getId(value), value) def getPriority(self, value): return value def getId(self, value): return id(value) def indexSlow(self, value): for pos, item in enumerate(self.items): if item[2] == value: return pos return None def index(self, value): item = (self.getPriority(value), self.getId(value), value) bisect_pos = bisect.bisect(self.items, item) - 1 if bisect_pos >= 0 and self.items[bisect_pos][2] == value: return bisect_pos # Item probably changed since added, switch to slow iteration pos = self.indexSlow(value) if self.logging: print("Slow index for %s in pos %s bisect: %s" % (item[2], pos, bisect_pos)) if pos is None: raise ValueError("%r not in list" % value) else: return pos def __contains__(self, value): try: self.index(value) return True except ValueError: return False class WorkerTaskManager(CustomSortedList): def __init__(self): super().__init__() self.inner_paths = {} def getPriority(self, value): return 0 - (value["priority"] - value["workers_num"] * 10) def getId(self, value): return value["id"] def __contains__(self, value): return value["inner_path"] in self.inner_paths def __delitem__(self, index): # Remove from inner path cache del self.inner_paths[self.items[index][2]["inner_path"]] super().__delitem__(index) # Fast task search by inner_path def append(self, task): if task["inner_path"] in self.inner_paths: raise ValueError("File %s already has a task" % task["inner_path"]) super().append(task) # Create inner path cache for faster lookup by filename self.inner_paths[task["inner_path"]] = task def remove(self, task): if task not in self: raise ValueError("%r not in list" % task) else: super().remove(task) def findTask(self, inner_path): return self.inner_paths.get(inner_path, None) ================================================ FILE: src/Worker/__init__.py ================================================ from .Worker import Worker from .WorkerManager import WorkerManager ================================================ FILE: src/__init__.py ================================================ ================================================ FILE: src/lib/__init__.py ================================================ ================================================ FILE: src/lib/bencode_open/LICENSE ================================================ MIT License Copyright (c) 2019 Ivan Machugovskiy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: src/lib/bencode_open/__init__.py ================================================ def loads(data): if not isinstance(data, bytes): raise TypeError("Expected 'bytes' object, got {}".format(type(data))) offset = 0 def parseInteger(): nonlocal offset offset += 1 had_digit = False abs_value = 0 sign = 1 if data[offset] == ord("-"): sign = -1 offset += 1 while offset < len(data): if data[offset] == ord("e"): # End of string offset += 1 if not had_digit: raise ValueError("Integer without value") break if ord("0") <= data[offset] <= ord("9"): abs_value = abs_value * 10 + int(chr(data[offset])) had_digit = True offset += 1 else: raise ValueError("Invalid integer") else: raise ValueError("Unexpected EOF, expected integer") if not had_digit: raise ValueError("Empty integer") return sign * abs_value def parseString(): nonlocal offset length = int(chr(data[offset])) offset += 1 while offset < len(data): if data[offset] == ord(":"): offset += 1 break if ord("0") <= data[offset] <= ord("9"): length = length * 10 + int(chr(data[offset])) offset += 1 else: raise ValueError("Invalid string length") else: raise ValueError("Unexpected EOF, expected string contents") if offset + length > len(data): raise ValueError("Unexpected EOF, expected string contents") offset += length return data[offset - length:offset] def parseList(): nonlocal offset offset += 1 values = [] while offset < len(data): if data[offset] == ord("e"): # End of list offset += 1 return values else: values.append(parse()) raise ValueError("Unexpected EOF, expected list contents") def parseDict(): nonlocal offset offset += 1 items = {} while offset < len(data): if data[offset] == ord("e"): # End of list offset += 1 return items else: key, value = parse(), parse() if not isinstance(key, bytes): raise ValueError("A dict key must be a byte string") if key in items: raise ValueError("Duplicate dict key: {}".format(key)) items[key] = value raise ValueError("Unexpected EOF, expected dict contents") def parse(): nonlocal offset if data[offset] == ord("i"): return parseInteger() elif data[offset] == ord("l"): return parseList() elif data[offset] == ord("d"): return parseDict() elif ord("0") <= data[offset] <= ord("9"): return parseString() raise ValueError("Unknown type specifier: '{}'".format(chr(data[offset]))) result = parse() if offset != len(data): raise ValueError("Expected EOF, got {} bytes left".format(len(data) - offset)) return result def dumps(data): result = bytearray() def convert(data): nonlocal result if isinstance(data, str): raise ValueError("bencode only supports bytes, not str. Use encode") if isinstance(data, bytes): result += str(len(data)).encode() + b":" + data elif isinstance(data, int): result += b"i" + str(data).encode() + b"e" elif isinstance(data, list): result += b"l" for val in data: convert(val) result += b"e" elif isinstance(data, dict): result += b"d" for key in sorted(data.keys()): if not isinstance(key, bytes): raise ValueError("Dict key can only be bytes, not {}".format(type(key))) convert(key) convert(data[key]) result += b"e" else: raise ValueError("bencode only supports bytes, int, list and dict") convert(data) return bytes(result) ================================================ FILE: src/lib/cssvendor/__init__.py ================================================ ================================================ FILE: src/lib/cssvendor/cssvendor.py ================================================ import re def prefix(content): content = re.sub( b"@keyframes (.*? {.*?}\s*})", b"@keyframes \\1\n@-webkit-keyframes \\1\n@-moz-keyframes \\1\n", content, flags=re.DOTALL ) content = re.sub( b'([^-\*])(border-radius|box-shadow|appearance|transition|animation|box-sizing|' + b'backface-visibility|transform|filter|perspective|animation-[a-z-]+): (.*?)([;}])', b'\\1-webkit-\\2: \\3; -moz-\\2: \\3; -o-\\2: \\3; -ms-\\2: \\3; \\2: \\3 \\4', content ) content = re.sub( b'(?<=[^a-zA-Z0-9-])([a-zA-Z0-9-]+): {0,1}(linear-gradient)\((.*?)(\)[;\n])', b'\\1: -webkit-\\2(\\3);' + b'\\1: -moz-\\2(\\3);' + b'\\1: -o-\\2(\\3);' + b'\\1: -ms-\\2(\\3);' + b'\\1: \\2(\\3);', content ) return content if __name__ == "__main__": print(prefix(b""" .test { border-radius: 5px; background: linear-gradient(red, blue); } @keyframes flip { 0% { transform: perspective(120px) rotateX(0deg) rotateY(0deg); } 50% { transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg) } 100% { transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg); } } """).decode("utf8")) ================================================ FILE: src/lib/gevent_ws/__init__.py ================================================ from gevent.pywsgi import WSGIHandler, _InvalidClientInput from gevent.queue import Queue import gevent import hashlib import base64 import struct import socket import time import sys SEND_PACKET_SIZE = 1300 OPCODE_TEXT = 1 OPCODE_BINARY = 2 OPCODE_CLOSE = 8 OPCODE_PING = 9 OPCODE_PONG = 10 STATUS_OK = 1000 STATUS_PROTOCOL_ERROR = 1002 STATUS_DATA_ERROR = 1007 STATUS_POLICY_VIOLATION = 1008 STATUS_TOO_LONG = 1009 class WebSocket: def __init__(self, socket): self.socket = socket self.closed = False self.status = None self._receive_error = None self._queue = Queue() self.max_length = 10 * 1024 * 1024 gevent.spawn(self._listen) def set_max_message_length(self, length): self.max_length = length def _listen(self): try: while True: fin = False message = bytearray() is_first_message = True start_opcode = None while not fin: payload, opcode, fin = self._get_frame(max_length=self.max_length - len(message)) # Make sure continuation frames have correct information if not is_first_message and opcode != 0: self._error(STATUS_PROTOCOL_ERROR) if is_first_message: if opcode not in (OPCODE_TEXT, OPCODE_BINARY): self._error(STATUS_PROTOCOL_ERROR) # Save opcode start_opcode = opcode message += payload is_first_message = False message = bytes(message) if start_opcode == OPCODE_TEXT: # UTF-8 text try: message = message.decode() except UnicodeDecodeError: self._error(STATUS_DATA_ERROR) self._queue.put(message) except Exception as e: self.closed = True self._receive_error = e self._queue.put(None) # To make sure the error is read def receive(self): if not self._queue.empty(): return self.receive_nowait() if isinstance(self._receive_error, EOFError): return None if self._receive_error: raise self._receive_error self._queue.peek() return self.receive_nowait() def receive_nowait(self): ret = self._queue.get_nowait() if self._receive_error and not isinstance(self._receive_error, EOFError): raise self._receive_error return ret def send(self, data): if self.closed: raise EOFError() if isinstance(data, str): self._send_frame(OPCODE_TEXT, data.encode()) elif isinstance(data, bytes): self._send_frame(OPCODE_BINARY, data) else: raise TypeError("Expected str or bytes, got " + repr(type(data))) # Reads a frame from the socket. Pings, pongs and close packets are handled # automatically def _get_frame(self, max_length): while True: payload, opcode, fin = self._read_frame(max_length=max_length) if opcode == OPCODE_PING: self._send_frame(OPCODE_PONG, payload) elif opcode == OPCODE_PONG: pass elif opcode == OPCODE_CLOSE: if len(payload) >= 2: self.status = struct.unpack("!H", payload[:2])[0] was_closed = self.closed self.closed = True if not was_closed: # Send a close frame in response self.close(STATUS_OK) raise EOFError() else: return payload, opcode, fin # Low-level function, use _get_frame instead def _read_frame(self, max_length): header = self._recv_exactly(2) if not (header[1] & 0x80): self._error(STATUS_POLICY_VIOLATION) opcode = header[0] & 0xf fin = bool(header[0] & 0x80) payload_length = header[1] & 0x7f if payload_length == 126: payload_length = struct.unpack("!H", self._recv_exactly(2))[0] elif payload_length == 127: payload_length = struct.unpack("!Q", self._recv_exactly(8))[0] # Control frames are handled in a special way if opcode in (OPCODE_PING, OPCODE_PONG): max_length = 125 if payload_length > max_length: self._error(STATUS_TOO_LONG) mask = self._recv_exactly(4) payload = self._recv_exactly(payload_length) payload = self._unmask(payload, mask) return payload, opcode, fin def _recv_exactly(self, length): buf = bytearray() while len(buf) < length: block = self.socket.recv(min(4096, length - len(buf))) if block == b"": raise EOFError() buf += block return bytes(buf) def _unmask(self, payload, mask): def gen(c): return bytes([x ^ c for x in range(256)]) payload = bytearray(payload) payload[0::4] = payload[0::4].translate(gen(mask[0])) payload[1::4] = payload[1::4].translate(gen(mask[1])) payload[2::4] = payload[2::4].translate(gen(mask[2])) payload[3::4] = payload[3::4].translate(gen(mask[3])) return bytes(payload) def _send_frame(self, opcode, data): for i in range(0, len(data), SEND_PACKET_SIZE): part = data[i:i + SEND_PACKET_SIZE] fin = int(i == (len(data) - 1) // SEND_PACKET_SIZE * SEND_PACKET_SIZE) header = bytes( [ (opcode if i == 0 else 0) | (fin << 7), min(len(part), 126) ] ) if len(part) >= 126: header += struct.pack("!H", len(part)) self.socket.sendall(header + part) def _error(self, status): self.close(status) raise EOFError() def close(self, status=STATUS_OK): self.closed = True try: self._send_frame(OPCODE_CLOSE, struct.pack("!H", status)) except (BrokenPipeError, ConnectionResetError): pass self.socket.close() class WebSocketHandler(WSGIHandler): def handle_one_response(self): self.time_start = time.time() self.status = None self.headers_sent = False self.result = None self.response_use_chunked = False self.response_length = 0 http_connection = [s.strip().lower() for s in self.environ.get("HTTP_CONNECTION", "").split(",")] if "upgrade" not in http_connection or self.environ.get("HTTP_UPGRADE", "").lower() != "websocket": # Not my problem return super(WebSocketHandler, self).handle_one_response() if "HTTP_SEC_WEBSOCKET_KEY" not in self.environ: self.start_response("400 Bad Request", []) return # Generate Sec-Websocket-Accept header accept = self.environ["HTTP_SEC_WEBSOCKET_KEY"].encode() accept += b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11" accept = base64.b64encode(hashlib.sha1(accept).digest()).decode() # Accept self.start_response("101 Switching Protocols", [ ("Upgrade", "websocket"), ("Connection", "Upgrade"), ("Sec-Websocket-Accept", accept) ])(b"") self.environ["wsgi.websocket"] = WebSocket(self.socket) # Can't call super because it sets invalid flags like "status" try: try: self.run_application() finally: try: self.wsgi_input._discard() except (socket.error, IOError): pass except _InvalidClientInput: self._send_error_response_if_possible(400) except socket.error as ex: if ex.args[0] in self.ignored_socket_errors: self.close_connection = True else: self.handle_error(*sys.exc_info()) except: # pylint:disable=bare-except self.handle_error(*sys.exc_info()) finally: self.time_finish = time.time() self.log_request() self.close_connection = True def process_result(self): if "wsgi.websocket" in self.environ: if self.result is None: return # Flushing result is required for werkzeug compatibility for elem in self.result: pass else: super(WebSocketHandler, self).process_result() @property def version(self): if not self.environ: return None return self.environ.get('HTTP_SEC_WEBSOCKET_VERSION') ================================================ FILE: src/lib/libsecp256k1message/__init__.py ================================================ from .libsecp256k1message import * ================================================ FILE: src/lib/libsecp256k1message/libsecp256k1message.py ================================================ import hashlib import base64 from coincurve import PrivateKey, PublicKey from base58 import b58encode_check, b58decode_check from hmac import compare_digest from util.Electrum import format as zero_format RECID_MIN = 0 RECID_MAX = 3 RECID_UNCOMPR = 27 LEN_COMPACT_SIG = 65 class SignatureError(ValueError): pass def bitcoin_address(): """Generate a public address and a secret address.""" publickey, secretkey = key_pair() public_address = compute_public_address(publickey) secret_address = compute_secret_address(secretkey) return (public_address, secret_address) def key_pair(): """Generate a public key and a secret key.""" secretkey = PrivateKey() publickey = PublicKey.from_secret(secretkey.secret) return (publickey, secretkey) def compute_public_address(publickey, compressed=False): """Convert a public key to a public Bitcoin address.""" public_plain = b'\x00' + public_digest(publickey, compressed=compressed) return b58encode_check(public_plain) def compute_secret_address(secretkey): """Convert a secret key to a secret Bitcoin address.""" secret_plain = b'\x80' + secretkey.secret return b58encode_check(secret_plain) def public_digest(publickey, compressed=False): """Convert a public key to ripemd160(sha256()) digest.""" publickey_hex = publickey.format(compressed=compressed) return hashlib.new('ripemd160', hashlib.sha256(publickey_hex).digest()).digest() def address_public_digest(address): """Convert a public Bitcoin address to ripemd160(sha256()) digest.""" public_plain = b58decode_check(address) if not public_plain.startswith(b'\x00') or len(public_plain) != 21: raise ValueError('Invalid public key digest') return public_plain[1:] def _decode_bitcoin_secret(address): secret_plain = b58decode_check(address) if not secret_plain.startswith(b'\x80') or len(secret_plain) != 33: raise ValueError('Invalid secret key. Uncompressed keys only.') return secret_plain[1:] def recover_public_key(signature, message): """Recover public key from signature and message. Recovered public key guarantees a correct signature""" return PublicKey.from_signature_and_message(signature, message) def decode_secret_key(address): """Convert a secret Bitcoin address to a secret key.""" return PrivateKey(_decode_bitcoin_secret(address)) def coincurve_sig(electrum_signature): # coincurve := r + s + recovery_id # where (0 <= recovery_id <= 3) # https://github.com/bitcoin-core/secp256k1/blob/0b7024185045a49a1a6a4c5615bf31c94f63d9c4/src/modules/recovery/main_impl.h#L35 if len(electrum_signature) != LEN_COMPACT_SIG: raise ValueError('Not a 65-byte compact signature.') # Compute coincurve recid recid = (electrum_signature[0] - 27) & 3 if not (RECID_MIN <= recid <= RECID_MAX): raise ValueError('Recovery ID %d is not supported.' % recid) recid_byte = int.to_bytes(recid, length=1, byteorder='big') return electrum_signature[1:] + recid_byte def electrum_sig(coincurve_signature): # electrum := recovery_id + r + s # where (27 <= recovery_id <= 30) # https://github.com/scintill/bitcoin-signature-tools/blob/ed3f5be5045af74a54c92d3648de98c329d9b4f7/key.cpp#L285 if len(coincurve_signature) != LEN_COMPACT_SIG: raise ValueError('Not a 65-byte compact signature.') # Compute Electrum recid recid = coincurve_signature[-1] + RECID_UNCOMPR if not (RECID_UNCOMPR + RECID_MIN <= recid <= RECID_UNCOMPR + RECID_MAX): raise ValueError('Recovery ID %d is not supported.' % recid) recid_byte = int.to_bytes(recid, length=1, byteorder='big') return recid_byte + coincurve_signature[0:-1] def sign_data(secretkey, byte_string): """Sign [byte_string] with [secretkey]. Return serialized signature compatible with Electrum (ZeroNet).""" # encode the message encoded = zero_format(byte_string) # sign the message and get a coincurve signature signature = secretkey.sign_recoverable(encoded) # reserialize signature and return it return electrum_sig(signature) def verify_data(key_digest, electrum_signature, byte_string): """Verify if [electrum_signature] of [byte_string] is correctly signed and is signed with the secret counterpart of [key_digest]. Raise SignatureError if the signature is forged or otherwise problematic.""" # reserialize signature signature = coincurve_sig(electrum_signature) # encode the message encoded = zero_format(byte_string) # recover full public key from signature # "which guarantees a correct signature" publickey = recover_public_key(signature, encoded) # verify that the message is correctly signed by the public key # correct_sig = verify_sig(publickey, signature, encoded) # verify that the public key is what we expect correct_key = verify_key(publickey, key_digest) if not correct_key: raise SignatureError('Signature is forged!') def verify_sig(publickey, signature, byte_string): return publickey.verify(signature, byte_string) def verify_key(publickey, key_digest): return compare_digest(key_digest, public_digest(publickey)) def recover_address(data, sign): sign_bytes = base64.b64decode(sign) is_compressed = ((sign_bytes[0] - 27) & 4) != 0 publickey = recover_public_key(coincurve_sig(sign_bytes), zero_format(data)) return compute_public_address(publickey, compressed=is_compressed) __all__ = [ 'SignatureError', 'key_pair', 'compute_public_address', 'compute_secret_address', 'public_digest', 'address_public_digest', 'recover_public_key', 'decode_secret_key', 'sign_data', 'verify_data', "recover_address" ] if __name__ == "__main__": import base64, time, multiprocessing s = time.time() privatekey = decode_secret_key(b"5JsunC55XGVqFQj5kPGK4MWgTL26jKbnPhjnmchSNPo75XXCwtk") threads = [] for i in range(1000): data = bytes("hello", "utf8") address = recover_address(data, "HGbib2kv9gm9IJjDt1FXbXFczZi35u0rZR3iPUIt5GglDDCeIQ7v8eYXVNIaLoJRI4URGZrhwmsYQ9aVtRTnTfQ=") print("- Verify x10000: %.3fs %s" % (time.time() - s, address)) s = time.time() for i in range(1000): privatekey = decode_secret_key(b"5JsunC55XGVqFQj5kPGK4MWgTL26jKbnPhjnmchSNPo75XXCwtk") sign = sign_data(privatekey, b"hello") sign_b64 = base64.b64encode(sign) print("- Sign x1000: %.3fs" % (time.time() - s)) ================================================ FILE: src/lib/openssl/openssl.cnf ================================================ [ req ] default_bits = 2048 default_keyfile = server-key.pem distinguished_name = subject req_extensions = req_ext x509_extensions = x509_ext string_mask = utf8only # The Subject DN can be formed using X501 or RFC 4514 (see RFC 4519 for a description). # Its sort of a mashup. For example, RFC 4514 does not provide emailAddress. [ subject ] countryName = US stateOrProvinceName = NY localityName = New York organizationName = Example, LLC # Use a friendly name here because its presented to the user. The server's DNS # names are placed in Subject Alternate Names. Plus, DNS names here is deprecated # by both IETF and CA/Browser Forums. If you place a DNS name here, then you # must include the DNS name in the SAN too (otherwise, Chrome and others that # strictly follow the CA/Browser Baseline Requirements will fail). commonName = Example Company emailAddress = test@example.com # Section x509_ext is used when generating a self-signed certificate. I.e., openssl req -x509 ... [ x509_ext ] subjectKeyIdentifier = hash authorityKeyIdentifier = keyid,issuer basicConstraints = CA:FALSE keyUsage = digitalSignature, keyEncipherment extendedKeyUsage = clientAuth, serverAuth subjectAltName = @alternate_names # RFC 5280, Section 4.2.1.12 makes EKU optional # CA/Browser Baseline Requirements, Appendix (B)(3)(G) makes me confused # extendedKeyUsage = serverAuth, clientAuth # Section req_ext is used when generating a certificate signing request. I.e., openssl req ... [ req_ext ] subjectKeyIdentifier = hash basicConstraints = CA:FALSE keyUsage = digitalSignature, keyEncipherment extendedKeyUsage = clientAuth, serverAuth subjectAltName = @alternate_names # RFC 5280, Section 4.2.1.12 makes EKU optional # CA/Browser Baseline Requirements, Appendix (B)(3)(G) makes me confused # extendedKeyUsage = serverAuth, clientAuth [ alternate_names ] DNS.1 = $ENV::CN DNS.2 = www.$ENV::CN ================================================ FILE: src/lib/pyaes/LICENSE.txt ================================================ The MIT License (MIT) Copyright (c) 2014 Richard Moore Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: src/lib/pyaes/README.md ================================================ pyaes ===== A pure-Python implementation of the AES block cipher algorithm and the common modes of operation (CBC, CFB, CTR, ECB and OFB). Features -------- * Supports all AES key sizes * Supports all AES common modes * Pure-Python (no external dependencies) * BlockFeeder API allows streams to easily be encrypted and decrypted * Python 2.x and 3.x support (make sure you pass in bytes(), not strings for Python 3) API --- All keys may be 128 bits (16 bytes), 192 bits (24 bytes) or 256 bits (32 bytes) long. To generate a random key use: ```python import os # 128 bit, 192 bit and 256 bit keys key_128 = os.urandom(16) key_192 = os.urandom(24) key_256 = os.urandom(32) ``` To generate keys from simple-to-remember passwords, consider using a _password-based key-derivation function_ such as [scrypt](https://github.com/ricmoo/pyscrypt). ### Common Modes of Operation There are many modes of operations, each with various pros and cons. In general though, the **CBC** and **CTR** modes are recommended. The **ECB is NOT recommended.**, and is included primarily for completeness. Each of the following examples assumes the following key: ```python import pyaes # A 256 bit (32 byte) key key = "This_key_for_demo_purposes_only!" # For some modes of operation we need a random initialization vector # of 16 bytes iv = "InitializationVe" ``` #### Counter Mode of Operation (recommended) ```python aes = pyaes.AESModeOfOperationCTR(key) plaintext = "Text may be any length you wish, no padding is required" ciphertext = aes.encrypt(plaintext) # '''\xb6\x99\x10=\xa4\x96\x88\xd1\x89\x1co\xe6\x1d\xef;\x11\x03\xe3\xee # \xa9V?wY\xbfe\xcdO\xe3\xdf\x9dV\x19\xe5\x8dk\x9fh\xb87>\xdb\xa3\xd6 # \x86\xf4\xbd\xb0\x97\xf1\t\x02\xe9 \xed''' print repr(ciphertext) # The counter mode of operation maintains state, so decryption requires # a new instance be created aes = pyaes.AESModeOfOperationCTR(key) decrypted = aes.decrypt(ciphertext) # True print decrypted == plaintext # To use a custom initial value counter = pyaes.Counter(initial_value = 100) aes = pyaes.AESModeOfOperationCTR(key, counter = counter) ciphertext = aes.encrypt(plaintext) # '''WZ\x844\x02\xbfoY\x1f\x12\xa6\xce\x03\x82Ei)\xf6\x97mX\x86\xe3\x9d # _1\xdd\xbd\x87\xb5\xccEM_4\x01$\xa6\x81\x0b\xd5\x04\xd7Al\x07\xe5 # \xb2\x0e\\\x0f\x00\x13,\x07''' print repr(ciphertext) ``` #### Cipher-Block Chaining (recommended) ```python aes = pyaes.AESModeOfOperationCBC(key, iv = iv) plaintext = "TextMustBe16Byte" ciphertext = aes.encrypt(plaintext) # '\xd6:\x18\xe6\xb1\xb3\xc3\xdc\x87\xdf\xa7|\x08{k\xb6' print repr(ciphertext) # The cipher-block chaining mode of operation maintains state, so # decryption requires a new instance be created aes = pyaes.AESModeOfOperationCBC(key, iv = iv) decrypted = aes.decrypt(ciphertext) # True print decrypted == plaintext ``` #### Cipher Feedback ```python # Each block into the mode of operation must be a multiple of the segment # size. For this example we choose 8 bytes. aes = pyaes.AESModeOfOperationCFB(key, iv = iv, segment_size = 8) plaintext = "TextMustBeAMultipleOfSegmentSize" ciphertext = aes.encrypt(plaintext) # '''v\xa9\xc1w"\x8aL\x93\xcb\xdf\xa0/\xf8Y\x0b\x8d\x88i\xcb\x85rmp # \x85\xfe\xafM\x0c)\xd5\xeb\xaf''' print repr(ciphertext) # The cipher-block chaining mode of operation maintains state, so # decryption requires a new instance be created aes = pyaes.AESModeOfOperationCFB(key, iv = iv, segment_size = 8) decrypted = aes.decrypt(ciphertext) # True print decrypted == plaintext ``` #### Output Feedback Mode of Operation ```python aes = pyaes.AESModeOfOperationOFB(key, iv = iv) plaintext = "Text may be any length you wish, no padding is required" ciphertext = aes.encrypt(plaintext) # '''v\xa9\xc1wO\x92^\x9e\rR\x1e\xf7\xb1\xa2\x9d"l1\xc7\xe7\x9d\x87(\xc26s # \xdd8\xc8@\xb6\xd9!\xf5\x0cM\xaa\x9b\xc4\xedLD\xe4\xb9\xd8\xdf\x9e\xac # \xa1\xb8\xea\x0f\x8ev\xb5''' print repr(ciphertext) # The counter mode of operation maintains state, so decryption requires # a new instance be created aes = pyaes.AESModeOfOperationOFB(key, iv = iv) decrypted = aes.decrypt(ciphertext) # True print decrypted == plaintext ``` #### Electronic Codebook (NOT recommended) ```python aes = pyaes.AESModeOfOperationECB(key) plaintext = "TextMustBe16Byte" ciphertext = aes.encrypt(plaintext) # 'L6\x95\x85\xe4\xd9\xf1\x8a\xfb\xe5\x94X\x80|\x19\xc3' print repr(ciphertext) # Since there is no state stored in this mode of operation, it # is not necessary to create a new aes object for decryption. #aes = pyaes.AESModeOfOperationECB(key) decrypted = aes.decrypt(ciphertext) # True print decrypted == plaintext ``` ### BlockFeeder Since most of the modes of operations require data in specific block-sized or segment-sized blocks, it can be difficult when working with large arbitrary streams or strings of data. The BlockFeeder class is meant to make life easier for you, by buffering bytes across multiple calls and returning bytes as they are available, as well as padding or stripping the output when finished, if necessary. ```python import pyaes # Any mode of operation can be used; for this example CBC key = "This_key_for_demo_purposes_only!" iv = "InitializationVe" ciphertext = '' # We can encrypt one line at a time, regardles of length encrypter = pyaes.Encrypter(pyaes.AESModeOfOperationCBC(key, iv)) for line in file('/etc/passwd'): ciphertext += encrypter.feed(line) # Make a final call to flush any remaining bytes and add paddin ciphertext += encrypter.feed() # We can decrypt the cipher text in chunks (here we split it in half) decrypter = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(key, iv)) decrypted = decrypter.feed(ciphertext[:len(ciphertext) / 2]) decrypted += decrypter.feed(ciphertext[len(ciphertext) / 2:]) # Again, make a final call to flush any remaining bytes and strip padding decrypted += decrypter.feed() print file('/etc/passwd').read() == decrypted ``` ### Stream Feeder This is meant to make it even easier to encrypt and decrypt streams and large files. ```python import pyaes # Any mode of operation can be used; for this example CTR key = "This_key_for_demo_purposes_only!" # Create the mode of operation to encrypt with mode = pyaes.AESModeOfOperationCTR(key) # The input and output files file_in = file('/etc/passwd') file_out = file('/tmp/encrypted.bin', 'wb') # Encrypt the data as a stream, the file is read in 8kb chunks, be default pyaes.encrypt_stream(mode, file_in, file_out) # Close the files file_in.close() file_out.close() ``` Decrypting is identical, except you would use `pyaes.decrypt_stream`, and the encrypted file would be the `file_in` and target for decryption the `file_out`. ### AES block cipher Generally you should use one of the modes of operation above. This may however be useful for experimenting with a custom mode of operation or dealing with encrypted blocks. The block cipher requires exactly one block of data to encrypt or decrypt, and each block should be an array with each element an integer representation of a byte. ```python import pyaes # 16 byte block of plain text plaintext = "Hello World!!!!!" plaintext_bytes = [ ord(c) for c in plaintext ] # 32 byte key (256 bit) key = "This_key_for_demo_purposes_only!" # Our AES instance aes = pyaes.AES(key) # Encrypt! ciphertext = aes.encrypt(plaintext_bytes) # [55, 250, 182, 25, 185, 208, 186, 95, 206, 115, 50, 115, 108, 58, 174, 115] print repr(ciphertext) # Decrypt! decrypted = aes.decrypt(ciphertext) # True print decrypted == plaintext_bytes ``` What is a key? -------------- This seems to be a point of confusion for many people new to using encryption. You can think of the key as the *"password"*. However, these algorithms require the *"password"* to be a specific length. With AES, there are three possible key lengths, 16-bytes, 24-bytes or 32-bytes. When you create an AES object, the key size is automatically detected, so it is important to pass in a key of the correct length. Often, you wish to provide a password of arbitrary length, for example, something easy to remember or write down. In these cases, you must come up with a way to transform the password into a key, of a specific length. A **Password-Based Key Derivation Function** (PBKDF) is an algorithm designed for this exact purpose. Here is an example, using the popular (possibly obsolete?) *crypt* PBKDF: ``` # See: https://www.dlitz.net/software/python-pbkdf2/ import pbkdf2 password = "HelloWorld" # The crypt PBKDF returns a 48-byte string key = pbkdf2.crypt(password) # A 16-byte, 24-byte and 32-byte key, respectively key_16 = key[:16] key_24 = key[:24] key_32 = key[:32] ``` The [scrypt](https://github.com/ricmoo/pyscrypt) PBKDF is intentionally slow, to make it more difficult to brute-force guess a password: ``` # See: https://github.com/ricmoo/pyscrypt import pyscrypt password = "HelloWorld" # Salt is required, and prevents Rainbow Table attacks salt = "SeaSalt" # N, r, and p are parameters to specify how difficult it should be to # generate a key; bigger numbers take longer and more memory N = 1024 r = 1 p = 1 # A 16-byte, 24-byte and 32-byte key, respectively; the scrypt algorithm takes # a 6-th parameter, indicating key length key_16 = pyscrypt.hash(password, salt, N, r, p, 16) key_24 = pyscrypt.hash(password, salt, N, r, p, 24) key_32 = pyscrypt.hash(password, salt, N, r, p, 32) ``` Another possibility, is to use a hashing function, such as SHA256 to hash the password, but this method may be vulnerable to [Rainbow Attacks](http://en.wikipedia.org/wiki/Rainbow_table), unless you use a [salt](http://en.wikipedia.org/wiki/Salt_(cryptography)). ```python import hashlib password = "HelloWorld" # The SHA256 hash algorithm returns a 32-byte string hashed = hashlib.sha256(password).digest() # A 16-byte, 24-byte and 32-byte key, respectively key_16 = hashed[:16] key_24 = hashed[:24] key_32 = hashed ``` Performance ----------- There is a test case provided in _/tests/test-aes.py_ which does some basic performance testing (its primary purpose is moreso as a regression test). Based on that test, in **CPython**, this library is about 30x slower than [PyCrypto](https://www.dlitz.net/software/pycrypto/) for CBC, ECB and OFB; about 80x slower for CFB; and 300x slower for CTR. Based on that same test, in **Pypy**, this library is about 4x slower than [PyCrypto](https://www.dlitz.net/software/pycrypto/) for CBC, ECB and OFB; about 12x slower for CFB; and 19x slower for CTR. The PyCrypto documentation makes reference to the counter call being responsible for the speed problems of the counter (CTR) mode of operation, which is why they use a specially optimized counter. I will investigate this problem further in the future. FAQ --- #### Why do this? The short answer, *why not?* The longer answer, is for my [pyscrypt](https://github.com/ricmoo/pyscrypt) library. I required a pure-Python AES implementation that supported 256-bit keys with the counter (CTR) mode of operation. After searching, I found several implementations, but all were missing CTR or only supported 128 bit keys. After all the work of learning AES inside and out to implement the library, it was only a marginal amount of extra work to library-ify a more general solution. So, *why not?* #### How do I get a question I have added? E-mail me at pyaes@ricmoo.com with any questions, suggestions, comments, et cetera. #### Can I give you my money? Umm... Ok? :-) _Bitcoin_ - `18UDs4qV1shu2CgTS2tKojhCtM69kpnWg9` ================================================ FILE: src/lib/pyaes/__init__.py ================================================ # The MIT License (MIT) # # Copyright (c) 2014 Richard Moore # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # This is a pure-Python implementation of the AES algorithm and AES common # modes of operation. # See: https://en.wikipedia.org/wiki/Advanced_Encryption_Standard # See: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation # Supported key sizes: # 128-bit # 192-bit # 256-bit # Supported modes of operation: # ECB - Electronic Codebook # CBC - Cipher-Block Chaining # CFB - Cipher Feedback # OFB - Output Feedback # CTR - Counter # See the README.md for API details and general information. # Also useful, PyCrypto, a crypto library implemented in C with Python bindings: # https://www.dlitz.net/software/pycrypto/ VERSION = [1, 3, 0] from .aes import AES, AESModeOfOperationCTR, AESModeOfOperationCBC, AESModeOfOperationCFB, AESModeOfOperationECB, AESModeOfOperationOFB, AESModesOfOperation, Counter from .blockfeeder import decrypt_stream, Decrypter, encrypt_stream, Encrypter from .blockfeeder import PADDING_NONE, PADDING_DEFAULT ================================================ FILE: src/lib/pyaes/aes.py ================================================ # The MIT License (MIT) # # Copyright (c) 2014 Richard Moore # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # This is a pure-Python implementation of the AES algorithm and AES common # modes of operation. # See: https://en.wikipedia.org/wiki/Advanced_Encryption_Standard # Honestly, the best description of the modes of operations are the wonderful # diagrams on Wikipedia. They explain in moments what my words could never # achieve. Hence the inline documentation here is sparer than I'd prefer. # See: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation # Also useful, PyCrypto, a crypto library implemented in C with Python bindings: # https://www.dlitz.net/software/pycrypto/ # Supported key sizes: # 128-bit # 192-bit # 256-bit # Supported modes of operation: # ECB - Electronic Codebook # CBC - Cipher-Block Chaining # CFB - Cipher Feedback # OFB - Output Feedback # CTR - Counter # See the README.md for API details and general information. import copy import struct __all__ = ["AES", "AESModeOfOperationCTR", "AESModeOfOperationCBC", "AESModeOfOperationCFB", "AESModeOfOperationECB", "AESModeOfOperationOFB", "AESModesOfOperation", "Counter"] def _compact_word(word): return (word[0] << 24) | (word[1] << 16) | (word[2] << 8) | word[3] def _string_to_bytes(text): return list(ord(c) for c in text) def _bytes_to_string(binary): return "".join(chr(b) for b in binary) def _concat_list(a, b): return a + b # Python 3 compatibility try: xrange except Exception: xrange = range # Python 3 supports bytes, which is already an array of integers def _string_to_bytes(text): if isinstance(text, bytes): return text return [ord(c) for c in text] # In Python 3, we return bytes def _bytes_to_string(binary): return bytes(binary) # Python 3 cannot concatenate a list onto a bytes, so we bytes-ify it first def _concat_list(a, b): return a + bytes(b) # Based *largely* on the Rijndael implementation # See: http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf class AES(object): '''Encapsulates the AES block cipher. You generally should not need this. Use the AESModeOfOperation classes below instead.''' # Number of rounds by keysize number_of_rounds = {16: 10, 24: 12, 32: 14} # Round constant words rcon = [ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91 ] # S-box and Inverse S-box (S is for Substitution) S = [ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84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f4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d ] # Transformations for encryption T1 = [ 0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554, 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a, 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b, 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b, 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a, 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f, 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108, 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f, 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e, 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5, 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d, 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f, 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e, 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb, 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce, 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497, 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c, 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed, 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b, 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a, 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16, 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594, 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81, 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3, 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a, 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504, 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163, 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d, 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f, 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739, 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47, 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395, 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f, 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883, 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c, 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76, 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e, 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4, 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6, 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b, 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7, 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0, 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25, 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818, 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72, 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651, 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21, 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85, 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa, 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12, 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0, 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9, 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133, 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7, 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920, 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a, 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17, 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8, 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a ] T2 = [ 0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b, 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5, 0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b, 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676, 0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d, 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0, 0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf, 0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0, 0xc275b7b7, 0x1ce1fdfd, 0xae3d9393, 0x6a4c2626, 0x5a6c3636, 0x417e3f3f, 0x02f5f7f7, 0x4f83cccc, 0x5c683434, 0xf451a5a5, 0x34d1e5e5, 0x08f9f1f1, 0x93e27171, 0x73abd8d8, 0x53623131, 0x3f2a1515, 0x0c080404, 0x5295c7c7, 0x65462323, 0x5e9dc3c3, 0x28301818, 0xa1379696, 0x0f0a0505, 0xb52f9a9a, 0x090e0707, 0x36241212, 0x9b1b8080, 0x3ddfe2e2, 0x26cdebeb, 0x694e2727, 0xcd7fb2b2, 0x9fea7575, 0x1b120909, 0x9e1d8383, 0x74582c2c, 0x2e341a1a, 0x2d361b1b, 0xb2dc6e6e, 0xeeb45a5a, 0xfb5ba0a0, 0xf6a45252, 0x4d763b3b, 0x61b7d6d6, 0xce7db3b3, 0x7b522929, 0x3edde3e3, 0x715e2f2f, 0x97138484, 0xf5a65353, 0x68b9d1d1, 0x00000000, 0x2cc1eded, 0x60402020, 0x1fe3fcfc, 0xc879b1b1, 0xedb65b5b, 0xbed46a6a, 0x468dcbcb, 0xd967bebe, 0x4b723939, 0xde944a4a, 0xd4984c4c, 0xe8b05858, 0x4a85cfcf, 0x6bbbd0d0, 0x2ac5efef, 0xe54faaaa, 0x16edfbfb, 0xc5864343, 0xd79a4d4d, 0x55663333, 0x94118585, 0xcf8a4545, 0x10e9f9f9, 0x06040202, 0x81fe7f7f, 0xf0a05050, 0x44783c3c, 0xba259f9f, 0xe34ba8a8, 0xf3a25151, 0xfe5da3a3, 0xc0804040, 0x8a058f8f, 0xad3f9292, 0xbc219d9d, 0x48703838, 0x04f1f5f5, 0xdf63bcbc, 0xc177b6b6, 0x75afdada, 0x63422121, 0x30201010, 0x1ae5ffff, 0x0efdf3f3, 0x6dbfd2d2, 0x4c81cdcd, 0x14180c0c, 0x35261313, 0x2fc3ecec, 0xe1be5f5f, 0xa2359797, 0xcc884444, 0x392e1717, 0x5793c4c4, 0xf255a7a7, 0x82fc7e7e, 0x477a3d3d, 0xacc86464, 0xe7ba5d5d, 0x2b321919, 0x95e67373, 0xa0c06060, 0x98198181, 0xd19e4f4f, 0x7fa3dcdc, 0x66442222, 0x7e542a2a, 0xab3b9090, 0x830b8888, 0xca8c4646, 0x29c7eeee, 0xd36bb8b8, 0x3c281414, 0x79a7dede, 0xe2bc5e5e, 0x1d160b0b, 0x76addbdb, 0x3bdbe0e0, 0x56643232, 0x4e743a3a, 0x1e140a0a, 0xdb924949, 0x0a0c0606, 0x6c482424, 0xe4b85c5c, 0x5d9fc2c2, 0x6ebdd3d3, 0xef43acac, 0xa6c46262, 0xa8399191, 0xa4319595, 0x37d3e4e4, 0x8bf27979, 0x32d5e7e7, 0x438bc8c8, 0x596e3737, 0xb7da6d6d, 0x8c018d8d, 0x64b1d5d5, 0xd29c4e4e, 0xe049a9a9, 0xb4d86c6c, 0xfaac5656, 0x07f3f4f4, 0x25cfeaea, 0xafca6565, 0x8ef47a7a, 0xe947aeae, 0x18100808, 0xd56fbaba, 0x88f07878, 0x6f4a2525, 0x725c2e2e, 0x24381c1c, 0xf157a6a6, 0xc773b4b4, 0x5197c6c6, 0x23cbe8e8, 0x7ca1dddd, 0x9ce87474, 0x213e1f1f, 0xdd964b4b, 0xdc61bdbd, 0x860d8b8b, 0x850f8a8a, 0x90e07070, 0x427c3e3e, 0xc471b5b5, 0xaacc6666, 0xd8904848, 0x05060303, 0x01f7f6f6, 0x121c0e0e, 0xa3c26161, 0x5f6a3535, 0xf9ae5757, 0xd069b9b9, 0x91178686, 0x5899c1c1, 0x273a1d1d, 0xb9279e9e, 0x38d9e1e1, 0x13ebf8f8, 0xb32b9898, 0x33221111, 0xbbd26969, 0x70a9d9d9, 0x89078e8e, 0xa7339494, 0xb62d9b9b, 0x223c1e1e, 0x92158787, 0x20c9e9e9, 0x4987cece, 0xffaa5555, 0x78502828, 0x7aa5dfdf, 0x8f038c8c, 0xf859a1a1, 0x80098989, 0x171a0d0d, 0xda65bfbf, 0x31d7e6e6, 0xc6844242, 0xb8d06868, 0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f, 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616 ] T3 = [ 0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b, 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5, 0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b, 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76, 0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d, 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0, 0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af, 0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0, 0xb7c275b7, 0xfd1ce1fd, 0x93ae3d93, 0x266a4c26, 0x365a6c36, 0x3f417e3f, 0xf702f5f7, 0xcc4f83cc, 0x345c6834, 0xa5f451a5, 0xe534d1e5, 0xf108f9f1, 0x7193e271, 0xd873abd8, 0x31536231, 0x153f2a15, 0x040c0804, 0xc75295c7, 0x23654623, 0xc35e9dc3, 0x18283018, 0x96a13796, 0x050f0a05, 0x9ab52f9a, 0x07090e07, 0x12362412, 0x809b1b80, 0xe23ddfe2, 0xeb26cdeb, 0x27694e27, 0xb2cd7fb2, 0x759fea75, 0x091b1209, 0x839e1d83, 0x2c74582c, 0x1a2e341a, 0x1b2d361b, 0x6eb2dc6e, 0x5aeeb45a, 0xa0fb5ba0, 0x52f6a452, 0x3b4d763b, 0xd661b7d6, 0xb3ce7db3, 0x297b5229, 0xe33edde3, 0x2f715e2f, 0x84971384, 0x53f5a653, 0xd168b9d1, 0x00000000, 0xed2cc1ed, 0x20604020, 0xfc1fe3fc, 0xb1c879b1, 0x5bedb65b, 0x6abed46a, 0xcb468dcb, 0xbed967be, 0x394b7239, 0x4ade944a, 0x4cd4984c, 0x58e8b058, 0xcf4a85cf, 0xd06bbbd0, 0xef2ac5ef, 0xaae54faa, 0xfb16edfb, 0x43c58643, 0x4dd79a4d, 0x33556633, 0x85941185, 0x45cf8a45, 0xf910e9f9, 0x02060402, 0x7f81fe7f, 0x50f0a050, 0x3c44783c, 0x9fba259f, 0xa8e34ba8, 0x51f3a251, 0xa3fe5da3, 0x40c08040, 0x8f8a058f, 0x92ad3f92, 0x9dbc219d, 0x38487038, 0xf504f1f5, 0xbcdf63bc, 0xb6c177b6, 0xda75afda, 0x21634221, 0x10302010, 0xff1ae5ff, 0xf30efdf3, 0xd26dbfd2, 0xcd4c81cd, 0x0c14180c, 0x13352613, 0xec2fc3ec, 0x5fe1be5f, 0x97a23597, 0x44cc8844, 0x17392e17, 0xc45793c4, 0xa7f255a7, 0x7e82fc7e, 0x3d477a3d, 0x64acc864, 0x5de7ba5d, 0x192b3219, 0x7395e673, 0x60a0c060, 0x81981981, 0x4fd19e4f, 0xdc7fa3dc, 0x22664422, 0x2a7e542a, 0x90ab3b90, 0x88830b88, 0x46ca8c46, 0xee29c7ee, 0xb8d36bb8, 0x143c2814, 0xde79a7de, 0x5ee2bc5e, 0x0b1d160b, 0xdb76addb, 0xe03bdbe0, 0x32566432, 0x3a4e743a, 0x0a1e140a, 0x49db9249, 0x060a0c06, 0x246c4824, 0x5ce4b85c, 0xc25d9fc2, 0xd36ebdd3, 0xacef43ac, 0x62a6c462, 0x91a83991, 0x95a43195, 0xe437d3e4, 0x798bf279, 0xe732d5e7, 0xc8438bc8, 0x37596e37, 0x6db7da6d, 0x8d8c018d, 0xd564b1d5, 0x4ed29c4e, 0xa9e049a9, 0x6cb4d86c, 0x56faac56, 0xf407f3f4, 0xea25cfea, 0x65afca65, 0x7a8ef47a, 0xaee947ae, 0x08181008, 0xbad56fba, 0x7888f078, 0x256f4a25, 0x2e725c2e, 0x1c24381c, 0xa6f157a6, 0xb4c773b4, 0xc65197c6, 0xe823cbe8, 0xdd7ca1dd, 0x749ce874, 0x1f213e1f, 0x4bdd964b, 0xbddc61bd, 0x8b860d8b, 0x8a850f8a, 0x7090e070, 0x3e427c3e, 0xb5c471b5, 0x66aacc66, 0x48d89048, 0x03050603, 0xf601f7f6, 0x0e121c0e, 0x61a3c261, 0x355f6a35, 0x57f9ae57, 0xb9d069b9, 0x86911786, 0xc15899c1, 0x1d273a1d, 0x9eb9279e, 0xe138d9e1, 0xf813ebf8, 0x98b32b98, 0x11332211, 0x69bbd269, 0xd970a9d9, 0x8e89078e, 0x94a73394, 0x9bb62d9b, 0x1e223c1e, 0x87921587, 0xe920c9e9, 0xce4987ce, 0x55ffaa55, 0x28785028, 0xdf7aa5df, 0x8c8f038c, 0xa1f859a1, 0x89800989, 0x0d171a0d, 0xbfda65bf, 0xe631d7e6, 0x42c68442, 0x68b8d068, 0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f, 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16 ] T4 = [ 0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491, 0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56, 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec, 0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa, 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb, 0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45, 0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b, 0xb7b7c275, 0xfdfd1ce1, 0x9393ae3d, 0x26266a4c, 0x36365a6c, 0x3f3f417e, 0xf7f702f5, 0xcccc4f83, 0x34345c68, 0xa5a5f451, 0xe5e534d1, 0xf1f108f9, 0x717193e2, 0xd8d873ab, 0x31315362, 0x15153f2a, 0x04040c08, 0xc7c75295, 0x23236546, 0xc3c35e9d, 0x18182830, 0x9696a137, 0x05050f0a, 0x9a9ab52f, 0x0707090e, 0x12123624, 0x80809b1b, 0xe2e23ddf, 0xebeb26cd, 0x2727694e, 0xb2b2cd7f, 0x75759fea, 0x09091b12, 0x83839e1d, 0x2c2c7458, 0x1a1a2e34, 0x1b1b2d36, 0x6e6eb2dc, 0x5a5aeeb4, 0xa0a0fb5b, 0x5252f6a4, 0x3b3b4d76, 0xd6d661b7, 0xb3b3ce7d, 0x29297b52, 0xe3e33edd, 0x2f2f715e, 0x84849713, 0x5353f5a6, 0xd1d168b9, 0x00000000, 0xeded2cc1, 0x20206040, 0xfcfc1fe3, 0xb1b1c879, 0x5b5bedb6, 0x6a6abed4, 0xcbcb468d, 0xbebed967, 0x39394b72, 0x4a4ade94, 0x4c4cd498, 0x5858e8b0, 0xcfcf4a85, 0xd0d06bbb, 0xefef2ac5, 0xaaaae54f, 0xfbfb16ed, 0x4343c586, 0x4d4dd79a, 0x33335566, 0x85859411, 0x4545cf8a, 0xf9f910e9, 0x02020604, 0x7f7f81fe, 0x5050f0a0, 0x3c3c4478, 0x9f9fba25, 0xa8a8e34b, 0x5151f3a2, 0xa3a3fe5d, 0x4040c080, 0x8f8f8a05, 0x9292ad3f, 0x9d9dbc21, 0x38384870, 0xf5f504f1, 0xbcbcdf63, 0xb6b6c177, 0xdada75af, 0x21216342, 0x10103020, 0xffff1ae5, 0xf3f30efd, 0xd2d26dbf, 0xcdcd4c81, 0x0c0c1418, 0x13133526, 0xecec2fc3, 0x5f5fe1be, 0x9797a235, 0x4444cc88, 0x1717392e, 0xc4c45793, 0xa7a7f255, 0x7e7e82fc, 0x3d3d477a, 0x6464acc8, 0x5d5de7ba, 0x19192b32, 0x737395e6, 0x6060a0c0, 0x81819819, 0x4f4fd19e, 0xdcdc7fa3, 0x22226644, 0x2a2a7e54, 0x9090ab3b, 0x8888830b, 0x4646ca8c, 0xeeee29c7, 0xb8b8d36b, 0x14143c28, 0xdede79a7, 0x5e5ee2bc, 0x0b0b1d16, 0xdbdb76ad, 0xe0e03bdb, 0x32325664, 0x3a3a4e74, 0x0a0a1e14, 0x4949db92, 0x06060a0c, 0x24246c48, 0x5c5ce4b8, 0xc2c25d9f, 0xd3d36ebd, 0xacacef43, 0x6262a6c4, 0x9191a839, 0x9595a431, 0xe4e437d3, 0x79798bf2, 0xe7e732d5, 0xc8c8438b, 0x3737596e, 0x6d6db7da, 0x8d8d8c01, 0xd5d564b1, 0x4e4ed29c, 0xa9a9e049, 0x6c6cb4d8, 0x5656faac, 0xf4f407f3, 0xeaea25cf, 0x6565afca, 0x7a7a8ef4, 0xaeaee947, 0x08081810, 0xbabad56f, 0x787888f0, 0x25256f4a, 0x2e2e725c, 0x1c1c2438, 0xa6a6f157, 0xb4b4c773, 0xc6c65197, 0xe8e823cb, 0xdddd7ca1, 0x74749ce8, 0x1f1f213e, 0x4b4bdd96, 0xbdbddc61, 0x8b8b860d, 0x8a8a850f, 0x707090e0, 0x3e3e427c, 0xb5b5c471, 0x6666aacc, 0x4848d890, 0x03030506, 0xf6f601f7, 0x0e0e121c, 0x6161a3c2, 0x35355f6a, 0x5757f9ae, 0xb9b9d069, 0x86869117, 0xc1c15899, 0x1d1d273a, 0x9e9eb927, 0xe1e138d9, 0xf8f813eb, 0x9898b32b, 0x11113322, 0x6969bbd2, 0xd9d970a9, 0x8e8e8907, 0x9494a733, 0x9b9bb62d, 0x1e1e223c, 0x87879215, 0xe9e920c9, 0xcece4987, 0x5555ffaa, 0x28287850, 0xdfdf7aa5, 0x8c8c8f03, 0xa1a1f859, 0x89898009, 0x0d0d171a, 0xbfbfda65, 0xe6e631d7, 0x4242c684, 0x6868b8d0, 0x4141c382, 0x9999b029, 0x2d2d775a, 0x0f0f111e, 0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c ] # Transformations for decryption T5 = [ 0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393, 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f, 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6, 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844, 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd, 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4, 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45, 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94, 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7, 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a, 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5, 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c, 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1, 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a, 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75, 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051, 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46, 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff, 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77, 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb, 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000, 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e, 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927, 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a, 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e, 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16, 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d, 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8, 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd, 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34, 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163, 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120, 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d, 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0, 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422, 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef, 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36, 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4, 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662, 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5, 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3, 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b, 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8, 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6, 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6, 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0, 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815, 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f, 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df, 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f, 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e, 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713, 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89, 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c, 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf, 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86, 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f, 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541, 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742 ] T6 = [ 0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e, 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303, 0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c, 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3, 0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0, 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9, 0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259, 0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8, 0x6a75c289, 0x78f48e79, 0x6b99583e, 0xdd27b971, 0xb6bee14f, 0x17f088ad, 0x66c920ac, 0xb47dce3a, 0x1863df4a, 0x82e51a31, 0x60975133, 0x4562537f, 0xe0b16477, 0x84bb6bae, 0x1cfe81a0, 0x94f9082b, 0x58704868, 0x198f45fd, 0x8794de6c, 0xb7527bf8, 0x23ab73d3, 0xe2724b02, 0x57e31f8f, 0x2a6655ab, 0x07b2eb28, 0x032fb5c2, 0x9a86c57b, 0xa5d33708, 0xf2302887, 0xb223bfa5, 0xba02036a, 0x5ced1682, 0x2b8acf1c, 0x92a779b4, 0xf0f307f2, 0xa14e69e2, 0xcd65daf4, 0xd50605be, 0x1fd13462, 0x8ac4a6fe, 0x9d342e53, 0xa0a2f355, 0x32058ae1, 0x75a4f6eb, 0x390b83ec, 0xaa4060ef, 0x065e719f, 0x51bd6e10, 0xf93e218a, 0x3d96dd06, 0xaedd3e05, 0x464de6bd, 0xb591548d, 0x0571c45d, 0x6f0406d4, 0xff605015, 0x241998fb, 0x97d6bde9, 0xcc894043, 0x7767d99e, 0xbdb0e842, 0x8807898b, 0x38e7195b, 0xdb79c8ee, 0x47a17c0a, 0xe97c420f, 0xc9f8841e, 0x00000000, 0x83098086, 0x48322bed, 0xac1e1170, 0x4e6c5a72, 0xfbfd0eff, 0x560f8538, 0x1e3daed5, 0x27362d39, 0x640a0fd9, 0x21685ca6, 0xd19b5b54, 0x3a24362e, 0xb10c0a67, 0x0f9357e7, 0xd2b4ee96, 0x9e1b9b91, 0x4f80c0c5, 0xa261dc20, 0x695a774b, 0x161c121a, 0x0ae293ba, 0xe5c0a02a, 0x433c22e0, 0x1d121b17, 0x0b0e090d, 0xadf28bc7, 0xb92db6a8, 0xc8141ea9, 0x8557f119, 0x4caf7507, 0xbbee99dd, 0xfda37f60, 0x9ff70126, 0xbc5c72f5, 0xc544663b, 0x345bfb7e, 0x768b4329, 0xdccb23c6, 0x68b6edfc, 0x63b8e4f1, 0xcad731dc, 0x10426385, 0x40139722, 0x2084c611, 0x7d854a24, 0xf8d2bb3d, 0x11aef932, 0x6dc729a1, 0x4b1d9e2f, 0xf3dcb230, 0xec0d8652, 0xd077c1e3, 0x6c2bb316, 0x99a970b9, 0xfa119448, 0x2247e964, 0xc4a8fc8c, 0x1aa0f03f, 0xd8567d2c, 0xef223390, 0xc787494e, 0xc1d938d1, 0xfe8ccaa2, 0x3698d40b, 0xcfa6f581, 0x28a57ade, 0x26dab78e, 0xa43fadbf, 0xe42c3a9d, 0x0d507892, 0x9b6a5fcc, 0x62547e46, 0xc2f68d13, 0xe890d8b8, 0x5e2e39f7, 0xf582c3af, 0xbe9f5d80, 0x7c69d093, 0xa96fd52d, 0xb3cf2512, 0x3bc8ac99, 0xa710187d, 0x6ee89c63, 0x7bdb3bbb, 0x09cd2678, 0xf46e5918, 0x01ec9ab7, 0xa8834f9a, 0x65e6956e, 0x7eaaffe6, 0x0821bccf, 0xe6ef15e8, 0xd9bae79b, 0xce4a6f36, 0xd4ea9f09, 0xd629b07c, 0xaf31a4b2, 0x312a3f23, 0x30c6a594, 0xc035a266, 0x37744ebc, 0xa6fc82ca, 0xb0e090d0, 0x1533a7d8, 0x4af10498, 0xf741ecda, 0x0e7fcd50, 0x2f1791f6, 0x8d764dd6, 0x4d43efb0, 0x54ccaa4d, 0xdfe49604, 0xe39ed1b5, 0x1b4c6a88, 0xb8c12c1f, 0x7f466551, 0x049d5eea, 0x5d018c35, 0x73fa8774, 0x2efb0b41, 0x5ab3671d, 0x5292dbd2, 0x33e91056, 0x136dd647, 0x8c9ad761, 0x7a37a10c, 0x8e59f814, 0x89eb133c, 0xeecea927, 0x35b761c9, 0xede11ce5, 0x3c7a47b1, 0x599cd2df, 0x3f55f273, 0x791814ce, 0xbf73c737, 0xea53f7cd, 0x5b5ffdaa, 0x14df3d6f, 0x867844db, 0x81caaff3, 0x3eb968c4, 0x2c382434, 0x5fc2a340, 0x72161dc3, 0x0cbce225, 0x8b283c49, 0x41ff0d95, 0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1, 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857 ] T7 = [ 0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27, 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3, 0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502, 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562, 0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe, 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3, 0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552, 0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9, 0x896a75c2, 0x7978f48e, 0x3e6b9958, 0x71dd27b9, 0x4fb6bee1, 0xad17f088, 0xac66c920, 0x3ab47dce, 0x4a1863df, 0x3182e51a, 0x33609751, 0x7f456253, 0x77e0b164, 0xae84bb6b, 0xa01cfe81, 0x2b94f908, 0x68587048, 0xfd198f45, 0x6c8794de, 0xf8b7527b, 0xd323ab73, 0x02e2724b, 0x8f57e31f, 0xab2a6655, 0x2807b2eb, 0xc2032fb5, 0x7b9a86c5, 0x08a5d337, 0x87f23028, 0xa5b223bf, 0x6aba0203, 0x825ced16, 0x1c2b8acf, 0xb492a779, 0xf2f0f307, 0xe2a14e69, 0xf4cd65da, 0xbed50605, 0x621fd134, 0xfe8ac4a6, 0x539d342e, 0x55a0a2f3, 0xe132058a, 0xeb75a4f6, 0xec390b83, 0xefaa4060, 0x9f065e71, 0x1051bd6e, 0x8af93e21, 0x063d96dd, 0x05aedd3e, 0xbd464de6, 0x8db59154, 0x5d0571c4, 0xd46f0406, 0x15ff6050, 0xfb241998, 0xe997d6bd, 0x43cc8940, 0x9e7767d9, 0x42bdb0e8, 0x8b880789, 0x5b38e719, 0xeedb79c8, 0x0a47a17c, 0x0fe97c42, 0x1ec9f884, 0x00000000, 0x86830980, 0xed48322b, 0x70ac1e11, 0x724e6c5a, 0xfffbfd0e, 0x38560f85, 0xd51e3dae, 0x3927362d, 0xd9640a0f, 0xa621685c, 0x54d19b5b, 0x2e3a2436, 0x67b10c0a, 0xe70f9357, 0x96d2b4ee, 0x919e1b9b, 0xc54f80c0, 0x20a261dc, 0x4b695a77, 0x1a161c12, 0xba0ae293, 0x2ae5c0a0, 0xe0433c22, 0x171d121b, 0x0d0b0e09, 0xc7adf28b, 0xa8b92db6, 0xa9c8141e, 0x198557f1, 0x074caf75, 0xddbbee99, 0x60fda37f, 0x269ff701, 0xf5bc5c72, 0x3bc54466, 0x7e345bfb, 0x29768b43, 0xc6dccb23, 0xfc68b6ed, 0xf163b8e4, 0xdccad731, 0x85104263, 0x22401397, 0x112084c6, 0x247d854a, 0x3df8d2bb, 0x3211aef9, 0xa16dc729, 0x2f4b1d9e, 0x30f3dcb2, 0x52ec0d86, 0xe3d077c1, 0x166c2bb3, 0xb999a970, 0x48fa1194, 0x642247e9, 0x8cc4a8fc, 0x3f1aa0f0, 0x2cd8567d, 0x90ef2233, 0x4ec78749, 0xd1c1d938, 0xa2fe8cca, 0x0b3698d4, 0x81cfa6f5, 0xde28a57a, 0x8e26dab7, 0xbfa43fad, 0x9de42c3a, 0x920d5078, 0xcc9b6a5f, 0x4662547e, 0x13c2f68d, 0xb8e890d8, 0xf75e2e39, 0xaff582c3, 0x80be9f5d, 0x937c69d0, 0x2da96fd5, 0x12b3cf25, 0x993bc8ac, 0x7da71018, 0x636ee89c, 0xbb7bdb3b, 0x7809cd26, 0x18f46e59, 0xb701ec9a, 0x9aa8834f, 0x6e65e695, 0xe67eaaff, 0xcf0821bc, 0xe8e6ef15, 0x9bd9bae7, 0x36ce4a6f, 0x09d4ea9f, 0x7cd629b0, 0xb2af31a4, 0x23312a3f, 0x9430c6a5, 0x66c035a2, 0xbc37744e, 0xcaa6fc82, 0xd0b0e090, 0xd81533a7, 0x984af104, 0xdaf741ec, 0x500e7fcd, 0xf62f1791, 0xd68d764d, 0xb04d43ef, 0x4d54ccaa, 0x04dfe496, 0xb5e39ed1, 0x881b4c6a, 0x1fb8c12c, 0x517f4665, 0xea049d5e, 0x355d018c, 0x7473fa87, 0x412efb0b, 0x1d5ab367, 0xd25292db, 0x5633e910, 0x47136dd6, 0x618c9ad7, 0x0c7a37a1, 0x148e59f8, 0x3c89eb13, 0x27eecea9, 0xc935b761, 0xe5ede11c, 0xb13c7a47, 0xdf599cd2, 0x733f55f2, 0xce791814, 0x37bf73c7, 0xcdea53f7, 0xaa5b5ffd, 0x6f14df3d, 0xdb867844, 0xf381caaf, 0xc43eb968, 0x342c3824, 0x405fc2a3, 0xc372161d, 0x250cbce2, 0x498b283c, 0x9541ff0d, 0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456, 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8 ] T8 = [ 0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a, 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b, 0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5, 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5, 0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d, 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b, 0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95, 0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e, 0xc2896a75, 0x8e7978f4, 0x583e6b99, 0xb971dd27, 0xe14fb6be, 0x88ad17f0, 0x20ac66c9, 0xce3ab47d, 0xdf4a1863, 0x1a3182e5, 0x51336097, 0x537f4562, 0x6477e0b1, 0x6bae84bb, 0x81a01cfe, 0x082b94f9, 0x48685870, 0x45fd198f, 0xde6c8794, 0x7bf8b752, 0x73d323ab, 0x4b02e272, 0x1f8f57e3, 0x55ab2a66, 0xeb2807b2, 0xb5c2032f, 0xc57b9a86, 0x3708a5d3, 0x2887f230, 0xbfa5b223, 0x036aba02, 0x16825ced, 0xcf1c2b8a, 0x79b492a7, 0x07f2f0f3, 0x69e2a14e, 0xdaf4cd65, 0x05bed506, 0x34621fd1, 0xa6fe8ac4, 0x2e539d34, 0xf355a0a2, 0x8ae13205, 0xf6eb75a4, 0x83ec390b, 0x60efaa40, 0x719f065e, 0x6e1051bd, 0x218af93e, 0xdd063d96, 0x3e05aedd, 0xe6bd464d, 0x548db591, 0xc45d0571, 0x06d46f04, 0x5015ff60, 0x98fb2419, 0xbde997d6, 0x4043cc89, 0xd99e7767, 0xe842bdb0, 0x898b8807, 0x195b38e7, 0xc8eedb79, 0x7c0a47a1, 0x420fe97c, 0x841ec9f8, 0x00000000, 0x80868309, 0x2bed4832, 0x1170ac1e, 0x5a724e6c, 0x0efffbfd, 0x8538560f, 0xaed51e3d, 0x2d392736, 0x0fd9640a, 0x5ca62168, 0x5b54d19b, 0x362e3a24, 0x0a67b10c, 0x57e70f93, 0xee96d2b4, 0x9b919e1b, 0xc0c54f80, 0xdc20a261, 0x774b695a, 0x121a161c, 0x93ba0ae2, 0xa02ae5c0, 0x22e0433c, 0x1b171d12, 0x090d0b0e, 0x8bc7adf2, 0xb6a8b92d, 0x1ea9c814, 0xf1198557, 0x75074caf, 0x99ddbbee, 0x7f60fda3, 0x01269ff7, 0x72f5bc5c, 0x663bc544, 0xfb7e345b, 0x4329768b, 0x23c6dccb, 0xedfc68b6, 0xe4f163b8, 0x31dccad7, 0x63851042, 0x97224013, 0xc6112084, 0x4a247d85, 0xbb3df8d2, 0xf93211ae, 0x29a16dc7, 0x9e2f4b1d, 0xb230f3dc, 0x8652ec0d, 0xc1e3d077, 0xb3166c2b, 0x70b999a9, 0x9448fa11, 0xe9642247, 0xfc8cc4a8, 0xf03f1aa0, 0x7d2cd856, 0x3390ef22, 0x494ec787, 0x38d1c1d9, 0xcaa2fe8c, 0xd40b3698, 0xf581cfa6, 0x7ade28a5, 0xb78e26da, 0xadbfa43f, 0x3a9de42c, 0x78920d50, 0x5fcc9b6a, 0x7e466254, 0x8d13c2f6, 0xd8b8e890, 0x39f75e2e, 0xc3aff582, 0x5d80be9f, 0xd0937c69, 0xd52da96f, 0x2512b3cf, 0xac993bc8, 0x187da710, 0x9c636ee8, 0x3bbb7bdb, 0x267809cd, 0x5918f46e, 0x9ab701ec, 0x4f9aa883, 0x956e65e6, 0xffe67eaa, 0xbccf0821, 0x15e8e6ef, 0xe79bd9ba, 0x6f36ce4a, 0x9f09d4ea, 0xb07cd629, 0xa4b2af31, 0x3f23312a, 0xa59430c6, 0xa266c035, 0x4ebc3774, 0x82caa6fc, 0x90d0b0e0, 0xa7d81533, 0x04984af1, 0xecdaf741, 0xcd500e7f, 0x91f62f17, 0x4dd68d76, 0xefb04d43, 0xaa4d54cc, 0x9604dfe4, 0xd1b5e39e, 0x6a881b4c, 0x2c1fb8c1, 0x65517f46, 0x5eea049d, 0x8c355d01, 0x877473fa, 0x0b412efb, 0x671d5ab3, 0xdbd25292, 0x105633e9, 0xd647136d, 0xd7618c9a, 0xa10c7a37, 0xf8148e59, 0x133c89eb, 0xa927eece, 0x61c935b7, 0x1ce5ede1, 0x47b13c7a, 0xd2df599c, 0xf2733f55, 0x14ce7918, 0xc737bf73, 0xf7cdea53, 0xfdaa5b5f, 0x3d6f14df, 0x44db8678, 0xaff381ca, 0x68c43eb9, 0x24342c38, 0xa3405fc2, 0x1dc37216, 0xe2250cbc, 0x3c498b28, 0x0d9541ff, 0xa8017139, 0x0cb3de08, 0xb4e49cd8, 0x56c19064, 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0 ] # Transformations for decryption key expansion U1 = [ 0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3 ] U2 = [ 0x00000000, 0x0b0e090d, 0x161c121a, 0x1d121b17, 0x2c382434, 0x27362d39, 0x3a24362e, 0x312a3f23, 0x58704868, 0x537e4165, 0x4e6c5a72, 0x4562537f, 0x74486c5c, 0x7f466551, 0x62547e46, 0x695a774b, 0xb0e090d0, 0xbbee99dd, 0xa6fc82ca, 0xadf28bc7, 0x9cd8b4e4, 0x97d6bde9, 0x8ac4a6fe, 0x81caaff3, 0xe890d8b8, 0xe39ed1b5, 0xfe8ccaa2, 0xf582c3af, 0xc4a8fc8c, 0xcfa6f581, 0xd2b4ee96, 0xd9bae79b, 0x7bdb3bbb, 0x70d532b6, 0x6dc729a1, 0x66c920ac, 0x57e31f8f, 0x5ced1682, 0x41ff0d95, 0x4af10498, 0x23ab73d3, 0x28a57ade, 0x35b761c9, 0x3eb968c4, 0x0f9357e7, 0x049d5eea, 0x198f45fd, 0x12814cf0, 0xcb3bab6b, 0xc035a266, 0xdd27b971, 0xd629b07c, 0xe7038f5f, 0xec0d8652, 0xf11f9d45, 0xfa119448, 0x934be303, 0x9845ea0e, 0x8557f119, 0x8e59f814, 0xbf73c737, 0xb47dce3a, 0xa96fd52d, 0xa261dc20, 0xf6ad766d, 0xfda37f60, 0xe0b16477, 0xebbf6d7a, 0xda955259, 0xd19b5b54, 0xcc894043, 0xc787494e, 0xaedd3e05, 0xa5d33708, 0xb8c12c1f, 0xb3cf2512, 0x82e51a31, 0x89eb133c, 0x94f9082b, 0x9ff70126, 0x464de6bd, 0x4d43efb0, 0x5051f4a7, 0x5b5ffdaa, 0x6a75c289, 0x617bcb84, 0x7c69d093, 0x7767d99e, 0x1e3daed5, 0x1533a7d8, 0x0821bccf, 0x032fb5c2, 0x32058ae1, 0x390b83ec, 0x241998fb, 0x2f1791f6, 0x8d764dd6, 0x867844db, 0x9b6a5fcc, 0x906456c1, 0xa14e69e2, 0xaa4060ef, 0xb7527bf8, 0xbc5c72f5, 0xd50605be, 0xde080cb3, 0xc31a17a4, 0xc8141ea9, 0xf93e218a, 0xf2302887, 0xef223390, 0xe42c3a9d, 0x3d96dd06, 0x3698d40b, 0x2b8acf1c, 0x2084c611, 0x11aef932, 0x1aa0f03f, 0x07b2eb28, 0x0cbce225, 0x65e6956e, 0x6ee89c63, 0x73fa8774, 0x78f48e79, 0x49deb15a, 0x42d0b857, 0x5fc2a340, 0x54ccaa4d, 0xf741ecda, 0xfc4fe5d7, 0xe15dfec0, 0xea53f7cd, 0xdb79c8ee, 0xd077c1e3, 0xcd65daf4, 0xc66bd3f9, 0xaf31a4b2, 0xa43fadbf, 0xb92db6a8, 0xb223bfa5, 0x83098086, 0x8807898b, 0x9515929c, 0x9e1b9b91, 0x47a17c0a, 0x4caf7507, 0x51bd6e10, 0x5ab3671d, 0x6b99583e, 0x60975133, 0x7d854a24, 0x768b4329, 0x1fd13462, 0x14df3d6f, 0x09cd2678, 0x02c32f75, 0x33e91056, 0x38e7195b, 0x25f5024c, 0x2efb0b41, 0x8c9ad761, 0x8794de6c, 0x9a86c57b, 0x9188cc76, 0xa0a2f355, 0xabacfa58, 0xb6bee14f, 0xbdb0e842, 0xd4ea9f09, 0xdfe49604, 0xc2f68d13, 0xc9f8841e, 0xf8d2bb3d, 0xf3dcb230, 0xeecea927, 0xe5c0a02a, 0x3c7a47b1, 0x37744ebc, 0x2a6655ab, 0x21685ca6, 0x10426385, 0x1b4c6a88, 0x065e719f, 0x0d507892, 0x640a0fd9, 0x6f0406d4, 0x72161dc3, 0x791814ce, 0x48322bed, 0x433c22e0, 0x5e2e39f7, 0x552030fa, 0x01ec9ab7, 0x0ae293ba, 0x17f088ad, 0x1cfe81a0, 0x2dd4be83, 0x26dab78e, 0x3bc8ac99, 0x30c6a594, 0x599cd2df, 0x5292dbd2, 0x4f80c0c5, 0x448ec9c8, 0x75a4f6eb, 0x7eaaffe6, 0x63b8e4f1, 0x68b6edfc, 0xb10c0a67, 0xba02036a, 0xa710187d, 0xac1e1170, 0x9d342e53, 0x963a275e, 0x8b283c49, 0x80263544, 0xe97c420f, 0xe2724b02, 0xff605015, 0xf46e5918, 0xc544663b, 0xce4a6f36, 0xd3587421, 0xd8567d2c, 0x7a37a10c, 0x7139a801, 0x6c2bb316, 0x6725ba1b, 0x560f8538, 0x5d018c35, 0x40139722, 0x4b1d9e2f, 0x2247e964, 0x2949e069, 0x345bfb7e, 0x3f55f273, 0x0e7fcd50, 0x0571c45d, 0x1863df4a, 0x136dd647, 0xcad731dc, 0xc1d938d1, 0xdccb23c6, 0xd7c52acb, 0xe6ef15e8, 0xede11ce5, 0xf0f307f2, 0xfbfd0eff, 0x92a779b4, 0x99a970b9, 0x84bb6bae, 0x8fb562a3, 0xbe9f5d80, 0xb591548d, 0xa8834f9a, 0xa38d4697 ] U3 = [ 0x00000000, 0x0d0b0e09, 0x1a161c12, 0x171d121b, 0x342c3824, 0x3927362d, 0x2e3a2436, 0x23312a3f, 0x68587048, 0x65537e41, 0x724e6c5a, 0x7f456253, 0x5c74486c, 0x517f4665, 0x4662547e, 0x4b695a77, 0xd0b0e090, 0xddbbee99, 0xcaa6fc82, 0xc7adf28b, 0xe49cd8b4, 0xe997d6bd, 0xfe8ac4a6, 0xf381caaf, 0xb8e890d8, 0xb5e39ed1, 0xa2fe8cca, 0xaff582c3, 0x8cc4a8fc, 0x81cfa6f5, 0x96d2b4ee, 0x9bd9bae7, 0xbb7bdb3b, 0xb670d532, 0xa16dc729, 0xac66c920, 0x8f57e31f, 0x825ced16, 0x9541ff0d, 0x984af104, 0xd323ab73, 0xde28a57a, 0xc935b761, 0xc43eb968, 0xe70f9357, 0xea049d5e, 0xfd198f45, 0xf012814c, 0x6bcb3bab, 0x66c035a2, 0x71dd27b9, 0x7cd629b0, 0x5fe7038f, 0x52ec0d86, 0x45f11f9d, 0x48fa1194, 0x03934be3, 0x0e9845ea, 0x198557f1, 0x148e59f8, 0x37bf73c7, 0x3ab47dce, 0x2da96fd5, 0x20a261dc, 0x6df6ad76, 0x60fda37f, 0x77e0b164, 0x7aebbf6d, 0x59da9552, 0x54d19b5b, 0x43cc8940, 0x4ec78749, 0x05aedd3e, 0x08a5d337, 0x1fb8c12c, 0x12b3cf25, 0x3182e51a, 0x3c89eb13, 0x2b94f908, 0x269ff701, 0xbd464de6, 0xb04d43ef, 0xa75051f4, 0xaa5b5ffd, 0x896a75c2, 0x84617bcb, 0x937c69d0, 0x9e7767d9, 0xd51e3dae, 0xd81533a7, 0xcf0821bc, 0xc2032fb5, 0xe132058a, 0xec390b83, 0xfb241998, 0xf62f1791, 0xd68d764d, 0xdb867844, 0xcc9b6a5f, 0xc1906456, 0xe2a14e69, 0xefaa4060, 0xf8b7527b, 0xf5bc5c72, 0xbed50605, 0xb3de080c, 0xa4c31a17, 0xa9c8141e, 0x8af93e21, 0x87f23028, 0x90ef2233, 0x9de42c3a, 0x063d96dd, 0x0b3698d4, 0x1c2b8acf, 0x112084c6, 0x3211aef9, 0x3f1aa0f0, 0x2807b2eb, 0x250cbce2, 0x6e65e695, 0x636ee89c, 0x7473fa87, 0x7978f48e, 0x5a49deb1, 0x5742d0b8, 0x405fc2a3, 0x4d54ccaa, 0xdaf741ec, 0xd7fc4fe5, 0xc0e15dfe, 0xcdea53f7, 0xeedb79c8, 0xe3d077c1, 0xf4cd65da, 0xf9c66bd3, 0xb2af31a4, 0xbfa43fad, 0xa8b92db6, 0xa5b223bf, 0x86830980, 0x8b880789, 0x9c951592, 0x919e1b9b, 0x0a47a17c, 0x074caf75, 0x1051bd6e, 0x1d5ab367, 0x3e6b9958, 0x33609751, 0x247d854a, 0x29768b43, 0x621fd134, 0x6f14df3d, 0x7809cd26, 0x7502c32f, 0x5633e910, 0x5b38e719, 0x4c25f502, 0x412efb0b, 0x618c9ad7, 0x6c8794de, 0x7b9a86c5, 0x769188cc, 0x55a0a2f3, 0x58abacfa, 0x4fb6bee1, 0x42bdb0e8, 0x09d4ea9f, 0x04dfe496, 0x13c2f68d, 0x1ec9f884, 0x3df8d2bb, 0x30f3dcb2, 0x27eecea9, 0x2ae5c0a0, 0xb13c7a47, 0xbc37744e, 0xab2a6655, 0xa621685c, 0x85104263, 0x881b4c6a, 0x9f065e71, 0x920d5078, 0xd9640a0f, 0xd46f0406, 0xc372161d, 0xce791814, 0xed48322b, 0xe0433c22, 0xf75e2e39, 0xfa552030, 0xb701ec9a, 0xba0ae293, 0xad17f088, 0xa01cfe81, 0x832dd4be, 0x8e26dab7, 0x993bc8ac, 0x9430c6a5, 0xdf599cd2, 0xd25292db, 0xc54f80c0, 0xc8448ec9, 0xeb75a4f6, 0xe67eaaff, 0xf163b8e4, 0xfc68b6ed, 0x67b10c0a, 0x6aba0203, 0x7da71018, 0x70ac1e11, 0x539d342e, 0x5e963a27, 0x498b283c, 0x44802635, 0x0fe97c42, 0x02e2724b, 0x15ff6050, 0x18f46e59, 0x3bc54466, 0x36ce4a6f, 0x21d35874, 0x2cd8567d, 0x0c7a37a1, 0x017139a8, 0x166c2bb3, 0x1b6725ba, 0x38560f85, 0x355d018c, 0x22401397, 0x2f4b1d9e, 0x642247e9, 0x692949e0, 0x7e345bfb, 0x733f55f2, 0x500e7fcd, 0x5d0571c4, 0x4a1863df, 0x47136dd6, 0xdccad731, 0xd1c1d938, 0xc6dccb23, 0xcbd7c52a, 0xe8e6ef15, 0xe5ede11c, 0xf2f0f307, 0xfffbfd0e, 0xb492a779, 0xb999a970, 0xae84bb6b, 0xa38fb562, 0x80be9f5d, 0x8db59154, 0x9aa8834f, 0x97a38d46 ] U4 = [ 0x00000000, 0x090d0b0e, 0x121a161c, 0x1b171d12, 0x24342c38, 0x2d392736, 0x362e3a24, 0x3f23312a, 0x48685870, 0x4165537e, 0x5a724e6c, 0x537f4562, 0x6c5c7448, 0x65517f46, 0x7e466254, 0x774b695a, 0x90d0b0e0, 0x99ddbbee, 0x82caa6fc, 0x8bc7adf2, 0xb4e49cd8, 0xbde997d6, 0xa6fe8ac4, 0xaff381ca, 0xd8b8e890, 0xd1b5e39e, 0xcaa2fe8c, 0xc3aff582, 0xfc8cc4a8, 0xf581cfa6, 0xee96d2b4, 0xe79bd9ba, 0x3bbb7bdb, 0x32b670d5, 0x29a16dc7, 0x20ac66c9, 0x1f8f57e3, 0x16825ced, 0x0d9541ff, 0x04984af1, 0x73d323ab, 0x7ade28a5, 0x61c935b7, 0x68c43eb9, 0x57e70f93, 0x5eea049d, 0x45fd198f, 0x4cf01281, 0xab6bcb3b, 0xa266c035, 0xb971dd27, 0xb07cd629, 0x8f5fe703, 0x8652ec0d, 0x9d45f11f, 0x9448fa11, 0xe303934b, 0xea0e9845, 0xf1198557, 0xf8148e59, 0xc737bf73, 0xce3ab47d, 0xd52da96f, 0xdc20a261, 0x766df6ad, 0x7f60fda3, 0x6477e0b1, 0x6d7aebbf, 0x5259da95, 0x5b54d19b, 0x4043cc89, 0x494ec787, 0x3e05aedd, 0x3708a5d3, 0x2c1fb8c1, 0x2512b3cf, 0x1a3182e5, 0x133c89eb, 0x082b94f9, 0x01269ff7, 0xe6bd464d, 0xefb04d43, 0xf4a75051, 0xfdaa5b5f, 0xc2896a75, 0xcb84617b, 0xd0937c69, 0xd99e7767, 0xaed51e3d, 0xa7d81533, 0xbccf0821, 0xb5c2032f, 0x8ae13205, 0x83ec390b, 0x98fb2419, 0x91f62f17, 0x4dd68d76, 0x44db8678, 0x5fcc9b6a, 0x56c19064, 0x69e2a14e, 0x60efaa40, 0x7bf8b752, 0x72f5bc5c, 0x05bed506, 0x0cb3de08, 0x17a4c31a, 0x1ea9c814, 0x218af93e, 0x2887f230, 0x3390ef22, 0x3a9de42c, 0xdd063d96, 0xd40b3698, 0xcf1c2b8a, 0xc6112084, 0xf93211ae, 0xf03f1aa0, 0xeb2807b2, 0xe2250cbc, 0x956e65e6, 0x9c636ee8, 0x877473fa, 0x8e7978f4, 0xb15a49de, 0xb85742d0, 0xa3405fc2, 0xaa4d54cc, 0xecdaf741, 0xe5d7fc4f, 0xfec0e15d, 0xf7cdea53, 0xc8eedb79, 0xc1e3d077, 0xdaf4cd65, 0xd3f9c66b, 0xa4b2af31, 0xadbfa43f, 0xb6a8b92d, 0xbfa5b223, 0x80868309, 0x898b8807, 0x929c9515, 0x9b919e1b, 0x7c0a47a1, 0x75074caf, 0x6e1051bd, 0x671d5ab3, 0x583e6b99, 0x51336097, 0x4a247d85, 0x4329768b, 0x34621fd1, 0x3d6f14df, 0x267809cd, 0x2f7502c3, 0x105633e9, 0x195b38e7, 0x024c25f5, 0x0b412efb, 0xd7618c9a, 0xde6c8794, 0xc57b9a86, 0xcc769188, 0xf355a0a2, 0xfa58abac, 0xe14fb6be, 0xe842bdb0, 0x9f09d4ea, 0x9604dfe4, 0x8d13c2f6, 0x841ec9f8, 0xbb3df8d2, 0xb230f3dc, 0xa927eece, 0xa02ae5c0, 0x47b13c7a, 0x4ebc3774, 0x55ab2a66, 0x5ca62168, 0x63851042, 0x6a881b4c, 0x719f065e, 0x78920d50, 0x0fd9640a, 0x06d46f04, 0x1dc37216, 0x14ce7918, 0x2bed4832, 0x22e0433c, 0x39f75e2e, 0x30fa5520, 0x9ab701ec, 0x93ba0ae2, 0x88ad17f0, 0x81a01cfe, 0xbe832dd4, 0xb78e26da, 0xac993bc8, 0xa59430c6, 0xd2df599c, 0xdbd25292, 0xc0c54f80, 0xc9c8448e, 0xf6eb75a4, 0xffe67eaa, 0xe4f163b8, 0xedfc68b6, 0x0a67b10c, 0x036aba02, 0x187da710, 0x1170ac1e, 0x2e539d34, 0x275e963a, 0x3c498b28, 0x35448026, 0x420fe97c, 0x4b02e272, 0x5015ff60, 0x5918f46e, 0x663bc544, 0x6f36ce4a, 0x7421d358, 0x7d2cd856, 0xa10c7a37, 0xa8017139, 0xb3166c2b, 0xba1b6725, 0x8538560f, 0x8c355d01, 0x97224013, 0x9e2f4b1d, 0xe9642247, 0xe0692949, 0xfb7e345b, 0xf2733f55, 0xcd500e7f, 0xc45d0571, 0xdf4a1863, 0xd647136d, 0x31dccad7, 0x38d1c1d9, 0x23c6dccb, 0x2acbd7c5, 0x15e8e6ef, 0x1ce5ede1, 0x07f2f0f3, 0x0efffbfd, 0x79b492a7, 0x70b999a9, 0x6bae84bb, 0x62a38fb5, 0x5d80be9f, 0x548db591, 0x4f9aa883, 0x4697a38d ] def __init__(self, key): if len(key) not in (16, 24, 32): raise ValueError('Invalid key size') rounds = self.number_of_rounds[len(key)] # Encryption round keys self._Ke = [[0] * 4 for i in xrange(rounds + 1)] # Decryption round keys self._Kd = [[0] * 4 for i in xrange(rounds + 1)] round_key_count = (rounds + 1) * 4 KC = len(key) // 4 # Convert the key into ints tk = [ struct.unpack('>i', key[i:i + 4])[0] for i in xrange(0, len(key), 4) ] # Copy values into round key arrays for i in xrange(0, KC): self._Ke[i // 4][i % 4] = tk[i] self._Kd[rounds - (i // 4)][i % 4] = tk[i] # Key expansion (fips-197 section 5.2) rconpointer = 0 t = KC while t < round_key_count: tt = tk[KC - 1] tk[0] ^= ((self.S[(tt >> 16) & 0xFF] << 24) ^ (self.S[(tt >> 8) & 0xFF] << 16) ^ (self.S[ tt & 0xFF] << 8) ^ self.S[(tt >> 24) & 0xFF] ^ (self.rcon[rconpointer] << 24)) rconpointer += 1 if KC != 8: for i in xrange(1, KC): tk[i] ^= tk[i - 1] # Key expansion for 256-bit keys is "slightly different" (fips-197) else: for i in xrange(1, KC // 2): tk[i] ^= tk[i - 1] tt = tk[KC // 2 - 1] tk[KC // 2] ^= (self.S[ tt & 0xFF] ^ (self.S[(tt >> 8) & 0xFF] << 8) ^ (self.S[(tt >> 16) & 0xFF] << 16) ^ (self.S[(tt >> 24) & 0xFF] << 24)) for i in xrange(KC // 2 + 1, KC): tk[i] ^= tk[i - 1] # Copy values into round key arrays j = 0 while j < KC and t < round_key_count: self._Ke[t // 4][t % 4] = tk[j] self._Kd[rounds - (t // 4)][t % 4] = tk[j] j += 1 t += 1 # Inverse-Cipher-ify the decryption round key (fips-197 section 5.3) for r in xrange(1, rounds): for j in xrange(0, 4): tt = self._Kd[r][j] self._Kd[r][j] = (self.U1[(tt >> 24) & 0xFF] ^ self.U2[(tt >> 16) & 0xFF] ^ self.U3[(tt >> 8) & 0xFF] ^ self.U4[ tt & 0xFF]) def encrypt(self, plaintext): 'Encrypt a block of plain text using the AES block cipher.' if len(plaintext) != 16: raise ValueError('wrong block length') rounds = len(self._Ke) - 1 (s1, s2, s3) = [1, 2, 3] a = [0, 0, 0, 0] # Convert plaintext to (ints ^ key) t = [(_compact_word(plaintext[4 * i:4 * i + 4]) ^ self._Ke[0][i]) for i in xrange(0, 4)] # Apply round transforms for r in xrange(1, rounds): for i in xrange(0, 4): a[i] = (self.T1[(t[ i ] >> 24) & 0xFF] ^ self.T2[(t[(i + s1) % 4] >> 16) & 0xFF] ^ self.T3[(t[(i + s2) % 4] >> 8) & 0xFF] ^ self.T4[ t[(i + s3) % 4] & 0xFF] ^ self._Ke[r][i]) t = copy.copy(a) # The last round is special result = [ ] for i in xrange(0, 4): tt = self._Ke[rounds][i] result.append((self.S[(t[ i ] >> 24) & 0xFF] ^ (tt >> 24)) & 0xFF) result.append((self.S[(t[(i + s1) % 4] >> 16) & 0xFF] ^ (tt >> 16)) & 0xFF) result.append((self.S[(t[(i + s2) % 4] >> 8) & 0xFF] ^ (tt >> 8)) & 0xFF) result.append((self.S[ t[(i + s3) % 4] & 0xFF] ^ tt ) & 0xFF) return result def decrypt(self, ciphertext): 'Decrypt a block of cipher text using the AES block cipher.' if len(ciphertext) != 16: raise ValueError('wrong block length') rounds = len(self._Kd) - 1 (s1, s2, s3) = [3, 2, 1] a = [0, 0, 0, 0] # Convert ciphertext to (ints ^ key) t = [(_compact_word(ciphertext[4 * i:4 * i + 4]) ^ self._Kd[0][i]) for i in xrange(0, 4)] # Apply round transforms for r in xrange(1, rounds): for i in xrange(0, 4): a[i] = (self.T5[(t[ i ] >> 24) & 0xFF] ^ self.T6[(t[(i + s1) % 4] >> 16) & 0xFF] ^ self.T7[(t[(i + s2) % 4] >> 8) & 0xFF] ^ self.T8[ t[(i + s3) % 4] & 0xFF] ^ self._Kd[r][i]) t = copy.copy(a) # The last round is special result = [ ] for i in xrange(0, 4): tt = self._Kd[rounds][i] result.append((self.Si[(t[ i ] >> 24) & 0xFF] ^ (tt >> 24)) & 0xFF) result.append((self.Si[(t[(i + s1) % 4] >> 16) & 0xFF] ^ (tt >> 16)) & 0xFF) result.append((self.Si[(t[(i + s2) % 4] >> 8) & 0xFF] ^ (tt >> 8)) & 0xFF) result.append((self.Si[ t[(i + s3) % 4] & 0xFF] ^ tt ) & 0xFF) return result class Counter(object): '''A counter object for the Counter (CTR) mode of operation. To create a custom counter, you can usually just override the increment method.''' def __init__(self, initial_value = 1): # Convert the value into an array of bytes long self._counter = [ ((initial_value >> i) % 256) for i in xrange(128 - 8, -1, -8) ] value = property(lambda s: s._counter) def increment(self): '''Increment the counter (overflow rolls back to 0).''' for i in xrange(len(self._counter) - 1, -1, -1): self._counter[i] += 1 if self._counter[i] < 256: break # Carry the one self._counter[i] = 0 # Overflow else: self._counter = [ 0 ] * len(self._counter) class AESBlockModeOfOperation(object): '''Super-class for AES modes of operation that require blocks.''' def __init__(self, key): self._aes = AES(key) def decrypt(self, ciphertext): raise Exception('not implemented') def encrypt(self, plaintext): raise Exception('not implemented') class AESStreamModeOfOperation(AESBlockModeOfOperation): '''Super-class for AES modes of operation that are stream-ciphers.''' class AESSegmentModeOfOperation(AESStreamModeOfOperation): '''Super-class for AES modes of operation that segment data.''' segment_bytes = 16 class AESModeOfOperationECB(AESBlockModeOfOperation): '''AES Electronic Codebook Mode of Operation. o Block-cipher, so data must be padded to 16 byte boundaries Security Notes: o This mode is not recommended o Any two identical blocks produce identical encrypted values, exposing data patterns. (See the image of Tux on wikipedia) Also see: o https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Electronic_codebook_.28ECB.29 o See NIST SP800-38A (http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf); section 6.1''' name = "Electronic Codebook (ECB)" def encrypt(self, plaintext): if len(plaintext) != 16: raise ValueError('plaintext block must be 16 bytes') plaintext = _string_to_bytes(plaintext) return _bytes_to_string(self._aes.encrypt(plaintext)) def decrypt(self, ciphertext): if len(ciphertext) != 16: raise ValueError('ciphertext block must be 16 bytes') ciphertext = _string_to_bytes(ciphertext) return _bytes_to_string(self._aes.decrypt(ciphertext)) class AESModeOfOperationCBC(AESBlockModeOfOperation): '''AES Cipher-Block Chaining Mode of Operation. o The Initialization Vector (IV) o Block-cipher, so data must be padded to 16 byte boundaries o An incorrect initialization vector will only cause the first block to be corrupt; all other blocks will be intact o A corrupt bit in the cipher text will cause a block to be corrupted, and the next block to be inverted, but all other blocks will be intact. Security Notes: o This method (and CTR) ARE recommended. Also see: o https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher-block_chaining_.28CBC.29 o See NIST SP800-38A (http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf); section 6.2''' name = "Cipher-Block Chaining (CBC)" def __init__(self, key, iv = None): if iv is None: self._last_cipherblock = [ 0 ] * 16 elif len(iv) != 16: raise ValueError('initialization vector must be 16 bytes') else: self._last_cipherblock = _string_to_bytes(iv) AESBlockModeOfOperation.__init__(self, key) def encrypt(self, plaintext): if len(plaintext) != 16: raise ValueError('plaintext block must be 16 bytes') plaintext = _string_to_bytes(plaintext) precipherblock = [ (p ^ l) for (p, l) in zip(plaintext, self._last_cipherblock) ] self._last_cipherblock = self._aes.encrypt(precipherblock) return _bytes_to_string(self._last_cipherblock) def decrypt(self, ciphertext): if len(ciphertext) != 16: raise ValueError('ciphertext block must be 16 bytes') cipherblock = _string_to_bytes(ciphertext) plaintext = [ (p ^ l) for (p, l) in zip(self._aes.decrypt(cipherblock), self._last_cipherblock) ] self._last_cipherblock = cipherblock return _bytes_to_string(plaintext) class AESModeOfOperationCFB(AESSegmentModeOfOperation): '''AES Cipher Feedback Mode of Operation. o A stream-cipher, so input does not need to be padded to blocks, but does need to be padded to segment_size Also see: o https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_feedback_.28CFB.29 o See NIST SP800-38A (http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf); section 6.3''' name = "Cipher Feedback (CFB)" def __init__(self, key, iv, segment_size = 1): if segment_size == 0: segment_size = 1 if iv is None: self._shift_register = [ 0 ] * 16 elif len(iv) != 16: raise ValueError('initialization vector must be 16 bytes') else: self._shift_register = _string_to_bytes(iv) self._segment_bytes = segment_size AESBlockModeOfOperation.__init__(self, key) segment_bytes = property(lambda s: s._segment_bytes) def encrypt(self, plaintext): if len(plaintext) % self._segment_bytes != 0: raise ValueError('plaintext block must be a multiple of segment_size') plaintext = _string_to_bytes(plaintext) # Break block into segments encrypted = [ ] for i in xrange(0, len(plaintext), self._segment_bytes): plaintext_segment = plaintext[i: i + self._segment_bytes] xor_segment = self._aes.encrypt(self._shift_register)[:len(plaintext_segment)] cipher_segment = [ (p ^ x) for (p, x) in zip(plaintext_segment, xor_segment) ] # Shift the top bits out and the ciphertext in self._shift_register = _concat_list(self._shift_register[len(cipher_segment):], cipher_segment) encrypted.extend(cipher_segment) return _bytes_to_string(encrypted) def decrypt(self, ciphertext): if len(ciphertext) % self._segment_bytes != 0: raise ValueError('ciphertext block must be a multiple of segment_size') ciphertext = _string_to_bytes(ciphertext) # Break block into segments decrypted = [ ] for i in xrange(0, len(ciphertext), self._segment_bytes): cipher_segment = ciphertext[i: i + self._segment_bytes] xor_segment = self._aes.encrypt(self._shift_register)[:len(cipher_segment)] plaintext_segment = [ (p ^ x) for (p, x) in zip(cipher_segment, xor_segment) ] # Shift the top bits out and the ciphertext in self._shift_register = _concat_list(self._shift_register[len(cipher_segment):], cipher_segment) decrypted.extend(plaintext_segment) return _bytes_to_string(decrypted) class AESModeOfOperationOFB(AESStreamModeOfOperation): '''AES Output Feedback Mode of Operation. o A stream-cipher, so input does not need to be padded to blocks, allowing arbitrary length data. o A bit twiddled in the cipher text, twiddles the same bit in the same bit in the plain text, which can be useful for error correction techniques. Also see: o https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Output_feedback_.28OFB.29 o See NIST SP800-38A (http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf); section 6.4''' name = "Output Feedback (OFB)" def __init__(self, key, iv = None): if iv is None: self._last_precipherblock = [ 0 ] * 16 elif len(iv) != 16: raise ValueError('initialization vector must be 16 bytes') else: self._last_precipherblock = _string_to_bytes(iv) self._remaining_block = [ ] AESBlockModeOfOperation.__init__(self, key) def encrypt(self, plaintext): encrypted = [ ] for p in _string_to_bytes(plaintext): if len(self._remaining_block) == 0: self._remaining_block = self._aes.encrypt(self._last_precipherblock) self._last_precipherblock = [ ] precipherbyte = self._remaining_block.pop(0) self._last_precipherblock.append(precipherbyte) cipherbyte = p ^ precipherbyte encrypted.append(cipherbyte) return _bytes_to_string(encrypted) def decrypt(self, ciphertext): # AES-OFB is symetric return self.encrypt(ciphertext) class AESModeOfOperationCTR(AESStreamModeOfOperation): '''AES Counter Mode of Operation. o A stream-cipher, so input does not need to be padded to blocks, allowing arbitrary length data. o The counter must be the same size as the key size (ie. len(key)) o Each block independant of the other, so a corrupt byte will not damage future blocks. o Each block has a uniue counter value associated with it, which contributes to the encrypted value, so no data patterns are leaked. o Also known as: Counter Mode (CM), Integer Counter Mode (ICM) and Segmented Integer Counter (SIC Security Notes: o This method (and CBC) ARE recommended. o Each message block is associated with a counter value which must be unique for ALL messages with the same key. Otherwise security may be compromised. Also see: o https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Counter_.28CTR.29 o See NIST SP800-38A (http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf); section 6.5 and Appendix B for managing the initial counter''' name = "Counter (CTR)" def __init__(self, key, counter = None): AESBlockModeOfOperation.__init__(self, key) if counter is None: counter = Counter() self._counter = counter self._remaining_counter = [ ] def encrypt(self, plaintext): while len(self._remaining_counter) < len(plaintext): self._remaining_counter += self._aes.encrypt(self._counter.value) self._counter.increment() plaintext = _string_to_bytes(plaintext) encrypted = [ (p ^ c) for (p, c) in zip(plaintext, self._remaining_counter) ] self._remaining_counter = self._remaining_counter[len(encrypted):] return _bytes_to_string(encrypted) def decrypt(self, crypttext): # AES-CTR is symetric return self.encrypt(crypttext) # Simple lookup table for each mode AESModesOfOperation = dict( ctr = AESModeOfOperationCTR, cbc = AESModeOfOperationCBC, cfb = AESModeOfOperationCFB, ecb = AESModeOfOperationECB, ofb = AESModeOfOperationOFB, ) ================================================ FILE: src/lib/pyaes/blockfeeder.py ================================================ # The MIT License (MIT) # # Copyright (c) 2014 Richard Moore # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. from .aes import AESBlockModeOfOperation, AESSegmentModeOfOperation, AESStreamModeOfOperation from .util import append_PKCS7_padding, strip_PKCS7_padding, to_bufferable # First we inject three functions to each of the modes of operations # # _can_consume(size) # - Given a size, determine how many bytes could be consumed in # a single call to either the decrypt or encrypt method # # _final_encrypt(data, padding = PADDING_DEFAULT) # - call and return encrypt on this (last) chunk of data, # padding as necessary; this will always be at least 16 # bytes unless the total incoming input was less than 16 # bytes # # _final_decrypt(data, padding = PADDING_DEFAULT) # - same as _final_encrypt except for decrypt, for # stripping off padding # PADDING_NONE = 'none' PADDING_DEFAULT = 'default' # @TODO: Ciphertext stealing and explicit PKCS#7 # PADDING_CIPHERTEXT_STEALING # PADDING_PKCS7 # ECB and CBC are block-only ciphers def _block_can_consume(self, size): if size >= 16: return 16 return 0 # After padding, we may have more than one block def _block_final_encrypt(self, data, padding = PADDING_DEFAULT): if padding == PADDING_DEFAULT: data = append_PKCS7_padding(data) elif padding == PADDING_NONE: if len(data) != 16: raise Exception('invalid data length for final block') else: raise Exception('invalid padding option') if len(data) == 32: return self.encrypt(data[:16]) + self.encrypt(data[16:]) return self.encrypt(data) def _block_final_decrypt(self, data, padding = PADDING_DEFAULT): if padding == PADDING_DEFAULT: return strip_PKCS7_padding(self.decrypt(data)) if padding == PADDING_NONE: if len(data) != 16: raise Exception('invalid data length for final block') return self.decrypt(data) raise Exception('invalid padding option') AESBlockModeOfOperation._can_consume = _block_can_consume AESBlockModeOfOperation._final_encrypt = _block_final_encrypt AESBlockModeOfOperation._final_decrypt = _block_final_decrypt # CFB is a segment cipher def _segment_can_consume(self, size): return self.segment_bytes * int(size // self.segment_bytes) # CFB can handle a non-segment-sized block at the end using the remaining cipherblock def _segment_final_encrypt(self, data, padding = PADDING_DEFAULT): if padding != PADDING_DEFAULT: raise Exception('invalid padding option') faux_padding = (chr(0) * (self.segment_bytes - (len(data) % self.segment_bytes))) padded = data + to_bufferable(faux_padding) return self.encrypt(padded)[:len(data)] # CFB can handle a non-segment-sized block at the end using the remaining cipherblock def _segment_final_decrypt(self, data, padding = PADDING_DEFAULT): if padding != PADDING_DEFAULT: raise Exception('invalid padding option') faux_padding = (chr(0) * (self.segment_bytes - (len(data) % self.segment_bytes))) padded = data + to_bufferable(faux_padding) return self.decrypt(padded)[:len(data)] AESSegmentModeOfOperation._can_consume = _segment_can_consume AESSegmentModeOfOperation._final_encrypt = _segment_final_encrypt AESSegmentModeOfOperation._final_decrypt = _segment_final_decrypt # OFB and CTR are stream ciphers def _stream_can_consume(self, size): return size def _stream_final_encrypt(self, data, padding = PADDING_DEFAULT): if padding not in [PADDING_NONE, PADDING_DEFAULT]: raise Exception('invalid padding option') return self.encrypt(data) def _stream_final_decrypt(self, data, padding = PADDING_DEFAULT): if padding not in [PADDING_NONE, PADDING_DEFAULT]: raise Exception('invalid padding option') return self.decrypt(data) AESStreamModeOfOperation._can_consume = _stream_can_consume AESStreamModeOfOperation._final_encrypt = _stream_final_encrypt AESStreamModeOfOperation._final_decrypt = _stream_final_decrypt class BlockFeeder(object): '''The super-class for objects to handle chunking a stream of bytes into the appropriate block size for the underlying mode of operation and applying (or stripping) padding, as necessary.''' def __init__(self, mode, feed, final, padding = PADDING_DEFAULT): self._mode = mode self._feed = feed self._final = final self._buffer = to_bufferable("") self._padding = padding def feed(self, data = None): '''Provide bytes to encrypt (or decrypt), returning any bytes possible from this or any previous calls to feed. Call with None or an empty string to flush the mode of operation and return any final bytes; no further calls to feed may be made.''' if self._buffer is None: raise ValueError('already finished feeder') # Finalize; process the spare bytes we were keeping if data is None: result = self._final(self._buffer, self._padding) self._buffer = None return result self._buffer += to_bufferable(data) # We keep 16 bytes around so we can determine padding result = to_bufferable('') while len(self._buffer) > 16: can_consume = self._mode._can_consume(len(self._buffer) - 16) if can_consume == 0: break result += self._feed(self._buffer[:can_consume]) self._buffer = self._buffer[can_consume:] return result class Encrypter(BlockFeeder): 'Accepts bytes of plaintext and returns encrypted ciphertext.' def __init__(self, mode, padding = PADDING_DEFAULT): BlockFeeder.__init__(self, mode, mode.encrypt, mode._final_encrypt, padding) class Decrypter(BlockFeeder): 'Accepts bytes of ciphertext and returns decrypted plaintext.' def __init__(self, mode, padding = PADDING_DEFAULT): BlockFeeder.__init__(self, mode, mode.decrypt, mode._final_decrypt, padding) # 8kb blocks BLOCK_SIZE = (1 << 13) def _feed_stream(feeder, in_stream, out_stream, block_size = BLOCK_SIZE): 'Uses feeder to read and convert from in_stream and write to out_stream.' while True: chunk = in_stream.read(block_size) if not chunk: break converted = feeder.feed(chunk) out_stream.write(converted) converted = feeder.feed() out_stream.write(converted) def encrypt_stream(mode, in_stream, out_stream, block_size = BLOCK_SIZE, padding = PADDING_DEFAULT): 'Encrypts a stream of bytes from in_stream to out_stream using mode.' encrypter = Encrypter(mode, padding = padding) _feed_stream(encrypter, in_stream, out_stream, block_size) def decrypt_stream(mode, in_stream, out_stream, block_size = BLOCK_SIZE, padding = PADDING_DEFAULT): 'Decrypts a stream of bytes from in_stream to out_stream using mode.' decrypter = Decrypter(mode, padding = padding) _feed_stream(decrypter, in_stream, out_stream, block_size) ================================================ FILE: src/lib/pyaes/util.py ================================================ # The MIT License (MIT) # # Copyright (c) 2014 Richard Moore # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # Why to_bufferable? # Python 3 is very different from Python 2.x when it comes to strings of text # and strings of bytes; in Python 3, strings of bytes do not exist, instead to # represent arbitrary binary data, we must use the "bytes" object. This method # ensures the object behaves as we need it to. def to_bufferable(binary): return binary def _get_byte(c): return ord(c) try: xrange except: def to_bufferable(binary): if isinstance(binary, bytes): return binary return bytes(ord(b) for b in binary) def _get_byte(c): return c def append_PKCS7_padding(data): pad = 16 - (len(data) % 16) return data + to_bufferable(chr(pad) * pad) def strip_PKCS7_padding(data): if len(data) % 16 != 0: raise ValueError("invalid length") pad = _get_byte(data[-1]) if pad > 16: raise ValueError("invalid padding byte") return data[:-pad] ================================================ FILE: src/lib/sslcrypto/LICENSE ================================================ MIT License Copyright (c) 2019 Ivan Machugovskiy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Additionally, the following licenses must be preserved: - ripemd implementation is licensed under BSD-3 by Markus Friedl, see `_ripemd.py`; - jacobian curve implementation is dual-licensed under MIT or public domain license, see `_jacobian.py`. ================================================ FILE: src/lib/sslcrypto/__init__.py ================================================ __all__ = ["aes", "ecc", "rsa"] try: from .openssl import aes, ecc, rsa except OSError: from .fallback import aes, ecc, rsa ================================================ FILE: src/lib/sslcrypto/_aes.py ================================================ # pylint: disable=import-outside-toplevel class AES: def __init__(self, backend, fallback=None): self._backend = backend self._fallback = fallback def get_algo_key_length(self, algo): if algo.count("-") != 2: raise ValueError("Invalid algorithm name") try: return int(algo.split("-")[1]) // 8 except ValueError: raise ValueError("Invalid algorithm name") from None def new_key(self, algo="aes-256-cbc"): if not self._backend.is_algo_supported(algo): if self._fallback is None: raise ValueError("This algorithm is not supported") return self._fallback.new_key(algo) return self._backend.random(self.get_algo_key_length(algo)) def encrypt(self, data, key, algo="aes-256-cbc"): if not self._backend.is_algo_supported(algo): if self._fallback is None: raise ValueError("This algorithm is not supported") return self._fallback.encrypt(data, key, algo) key_length = self.get_algo_key_length(algo) if len(key) != key_length: raise ValueError("Expected key to be {} bytes, got {} bytes".format(key_length, len(key))) return self._backend.encrypt(data, key, algo) def decrypt(self, ciphertext, iv, key, algo="aes-256-cbc"): if not self._backend.is_algo_supported(algo): if self._fallback is None: raise ValueError("This algorithm is not supported") return self._fallback.decrypt(ciphertext, iv, key, algo) key_length = self.get_algo_key_length(algo) if len(key) != key_length: raise ValueError("Expected key to be {} bytes, got {} bytes".format(key_length, len(key))) return self._backend.decrypt(ciphertext, iv, key, algo) def get_backend(self): return self._backend.get_backend() ================================================ FILE: src/lib/sslcrypto/_ecc.py ================================================ import hashlib import struct import hmac import base58 try: hashlib.new("ripemd160") except ValueError: # No native implementation from . import _ripemd def ripemd160(*args): return _ripemd.new(*args) else: # Use OpenSSL def ripemd160(*args): return hashlib.new("ripemd160", *args) class ECC: # pylint: disable=line-too-long # name: (nid, p, n, a, b, (Gx, Gy)), CURVES = { "secp112r1": ( 704, 0xDB7C2ABF62E35E668076BEAD208B, 0xDB7C2ABF62E35E7628DFAC6561C5, 0xDB7C2ABF62E35E668076BEAD2088, 0x659EF8BA043916EEDE8911702B22, ( 0x09487239995A5EE76B55F9C2F098, 0xA89CE5AF8724C0A23E0E0FF77500 ) ), "secp112r2": ( 705, 0xDB7C2ABF62E35E668076BEAD208B, 0x36DF0AAFD8B8D7597CA10520D04B, 0x6127C24C05F38A0AAAF65C0EF02C, 0x51DEF1815DB5ED74FCC34C85D709, ( 0x4BA30AB5E892B4E1649DD0928643, 0xADCD46F5882E3747DEF36E956E97 ) ), "secp128r1": ( 706, 0xFFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF, 0xFFFFFFFE0000000075A30D1B9038A115, 0xFFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC, 0xE87579C11079F43DD824993C2CEE5ED3, ( 0x161FF7528B899B2D0C28607CA52C5B86, 0xCF5AC8395BAFEB13C02DA292DDED7A83 ) ), "secp128r2": ( 707, 0xFFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF, 0x3FFFFFFF7FFFFFFFBE0024720613B5A3, 0xD6031998D1B3BBFEBF59CC9BBFF9AEE1, 0x5EEEFCA380D02919DC2C6558BB6D8A5D, ( 0x7B6AA5D85E572983E6FB32A7CDEBC140, 0x27B6916A894D3AEE7106FE805FC34B44 ) ), "secp160k1": ( 708, 0x00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73, 0x0100000000000000000001B8FA16DFAB9ACA16B6B3, 0, 7, ( 0x3B4C382CE37AA192A4019E763036F4F5DD4D7EBB, 0x938CF935318FDCED6BC28286531733C3F03C4FEE ) ), "secp160r1": ( 709, 0x00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF, 0x0100000000000000000001F4C8F927AED3CA752257, 0x00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC, 0x001C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45, ( 0x4A96B5688EF573284664698968C38BB913CBFC82, 0x23A628553168947D59DCC912042351377AC5FB32 ) ), "secp160r2": ( 710, 0x00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73, 0x0100000000000000000000351EE786A818F3A1A16B, 0x00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC70, 0x00B4E134D3FB59EB8BAB57274904664D5AF50388BA, ( 0x52DCB034293A117E1F4FF11B30F7199D3144CE6D, 0xFEAFFEF2E331F296E071FA0DF9982CFEA7D43F2E ) ), "secp192k1": ( 711, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37, 0xFFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D, 0, 3, ( 0xDB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D, 0x9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D ) ), "prime192v1": ( 409, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC, 0x64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1, ( 0x188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012, 0x07192B95FFC8DA78631011ED6B24CDD573F977A11E794811 ) ), "secp224k1": ( 712, 0x00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFE56D, 0x010000000000000000000000000001DCE8D2EC6184CAF0A971769FB1F7, 0, 5, ( 0xA1455B334DF099DF30FC28A169A467E9E47075A90F7E650EB6B7A45C, 0x7E089FED7FBA344282CAFBD6F7E319F7C0B0BD59E2CA4BDB556D61A5 ) ), "secp224r1": ( 713, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE, 0xB4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4, ( 0xB70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21, 0xBD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34 ) ), "secp256k1": ( 714, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141, 0, 7, ( 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798, 0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8 ) ), "prime256v1": ( 715, 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF, 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551, 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC, 0x5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B, ( 0x6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296, 0x4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5 ) ), "secp384r1": ( 716, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC, 0xB3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF, ( 0xAA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7, 0x3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F ) ), "secp521r1": ( 717, 0x01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, 0x01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409, 0x01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC, 0x0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00, ( 0x00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66, 0x011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650 ) ) } # pylint: enable=line-too-long def __init__(self, backend, aes): self._backend = backend self._aes = aes def get_curve(self, name): if name not in self.CURVES: raise ValueError("Unknown curve {}".format(name)) nid, p, n, a, b, g = self.CURVES[name] return EllipticCurve(self._backend(p, n, a, b, g), self._aes, nid) def get_backend(self): return self._backend.get_backend() class EllipticCurve: def __init__(self, backend, aes, nid): self._backend = backend self._aes = aes self.nid = nid def _encode_public_key(self, x, y, is_compressed=True, raw=True): if raw: if is_compressed: return bytes([0x02 + (y[-1] % 2)]) + x else: return bytes([0x04]) + x + y else: return struct.pack("!HH", self.nid, len(x)) + x + struct.pack("!H", len(y)) + y def _decode_public_key(self, public_key, partial=False): if not public_key: raise ValueError("No public key") if public_key[0] == 0x04: # Uncompressed expected_length = 1 + 2 * self._backend.public_key_length if partial: if len(public_key) < expected_length: raise ValueError("Invalid uncompressed public key length") else: if len(public_key) != expected_length: raise ValueError("Invalid uncompressed public key length") x = public_key[1:1 + self._backend.public_key_length] y = public_key[1 + self._backend.public_key_length:expected_length] if partial: return (x, y), expected_length else: return x, y elif public_key[0] in (0x02, 0x03): # Compressed expected_length = 1 + self._backend.public_key_length if partial: if len(public_key) < expected_length: raise ValueError("Invalid compressed public key length") else: if len(public_key) != expected_length: raise ValueError("Invalid compressed public key length") x, y = self._backend.decompress_point(public_key[:expected_length]) # Sanity check if x != public_key[1:expected_length]: raise ValueError("Incorrect compressed public key") if partial: return (x, y), expected_length else: return x, y else: raise ValueError("Invalid public key prefix") def _decode_public_key_openssl(self, public_key, partial=False): if not public_key: raise ValueError("No public key") i = 0 nid, = struct.unpack("!H", public_key[i:i + 2]) i += 2 if nid != self.nid: raise ValueError("Wrong curve") xlen, = struct.unpack("!H", public_key[i:i + 2]) i += 2 if len(public_key) - i < xlen: raise ValueError("Too short public key") x = public_key[i:i + xlen] i += xlen ylen, = struct.unpack("!H", public_key[i:i + 2]) i += 2 if len(public_key) - i < ylen: raise ValueError("Too short public key") y = public_key[i:i + ylen] i += ylen if partial: return (x, y), i else: if i < len(public_key): raise ValueError("Too long public key") return x, y def new_private_key(self, is_compressed=False): return self._backend.new_private_key() + (b"\x01" if is_compressed else b"") def private_to_public(self, private_key): if len(private_key) == self._backend.public_key_length: is_compressed = False elif len(private_key) == self._backend.public_key_length + 1 and private_key[-1] == 1: is_compressed = True private_key = private_key[:-1] else: raise ValueError("Private key has invalid length") x, y = self._backend.private_to_public(private_key) return self._encode_public_key(x, y, is_compressed=is_compressed) def private_to_wif(self, private_key): return base58.b58encode_check(b"\x80" + private_key) def wif_to_private(self, wif): dec = base58.b58decode_check(wif) if dec[0] != 0x80: raise ValueError("Invalid network (expected mainnet)") return dec[1:] def public_to_address(self, public_key): h = hashlib.sha256(public_key).digest() hash160 = ripemd160(h).digest() return base58.b58encode_check(b"\x00" + hash160) def private_to_address(self, private_key): # Kinda useless but left for quick migration from pybitcointools return self.public_to_address(self.private_to_public(private_key)) def derive(self, private_key, public_key): if len(private_key) == self._backend.public_key_length + 1 and private_key[-1] == 1: private_key = private_key[:-1] if len(private_key) != self._backend.public_key_length: raise ValueError("Private key has invalid length") if not isinstance(public_key, tuple): public_key = self._decode_public_key(public_key) return self._backend.ecdh(private_key, public_key) def _digest(self, data, hash): if hash is None: return data elif callable(hash): return hash(data) elif hash == "sha1": return hashlib.sha1(data).digest() elif hash == "sha256": return hashlib.sha256(data).digest() elif hash == "sha512": return hashlib.sha512(data).digest() else: raise ValueError("Unknown hash/derivation method") # High-level functions def encrypt(self, data, public_key, algo="aes-256-cbc", derivation="sha256", mac="hmac-sha256", return_aes_key=False): # Generate ephemeral private key private_key = self.new_private_key() # Derive key ecdh = self.derive(private_key, public_key) key = self._digest(ecdh, derivation) k_enc_len = self._aes.get_algo_key_length(algo) if len(key) < k_enc_len: raise ValueError("Too short digest") k_enc, k_mac = key[:k_enc_len], key[k_enc_len:] # Encrypt ciphertext, iv = self._aes.encrypt(data, k_enc, algo=algo) ephem_public_key = self.private_to_public(private_key) ephem_public_key = self._decode_public_key(ephem_public_key) ephem_public_key = self._encode_public_key(*ephem_public_key, raw=False) ciphertext = iv + ephem_public_key + ciphertext # Add MAC tag if callable(mac): tag = mac(k_mac, ciphertext) elif mac == "hmac-sha256": h = hmac.new(k_mac, digestmod="sha256") h.update(ciphertext) tag = h.digest() elif mac == "hmac-sha512": h = hmac.new(k_mac, digestmod="sha512") h.update(ciphertext) tag = h.digest() elif mac is None: tag = b"" else: raise ValueError("Unsupported MAC") if return_aes_key: return ciphertext + tag, k_enc else: return ciphertext + tag def decrypt(self, ciphertext, private_key, algo="aes-256-cbc", derivation="sha256", mac="hmac-sha256"): # Get MAC tag if callable(mac): tag_length = mac.digest_size elif mac == "hmac-sha256": tag_length = hmac.new(b"", digestmod="sha256").digest_size elif mac == "hmac-sha512": tag_length = hmac.new(b"", digestmod="sha512").digest_size elif mac is None: tag_length = 0 else: raise ValueError("Unsupported MAC") if len(ciphertext) < tag_length: raise ValueError("Ciphertext is too small to contain MAC tag") if tag_length == 0: tag = b"" else: ciphertext, tag = ciphertext[:-tag_length], ciphertext[-tag_length:] orig_ciphertext = ciphertext if len(ciphertext) < 16: raise ValueError("Ciphertext is too small to contain IV") iv, ciphertext = ciphertext[:16], ciphertext[16:] public_key, pos = self._decode_public_key_openssl(ciphertext, partial=True) ciphertext = ciphertext[pos:] # Derive key ecdh = self.derive(private_key, public_key) key = self._digest(ecdh, derivation) k_enc_len = self._aes.get_algo_key_length(algo) if len(key) < k_enc_len: raise ValueError("Too short digest") k_enc, k_mac = key[:k_enc_len], key[k_enc_len:] # Verify MAC tag if callable(mac): expected_tag = mac(k_mac, orig_ciphertext) elif mac == "hmac-sha256": h = hmac.new(k_mac, digestmod="sha256") h.update(orig_ciphertext) expected_tag = h.digest() elif mac == "hmac-sha512": h = hmac.new(k_mac, digestmod="sha512") h.update(orig_ciphertext) expected_tag = h.digest() elif mac is None: expected_tag = b"" if not hmac.compare_digest(tag, expected_tag): raise ValueError("Invalid MAC tag") return self._aes.decrypt(ciphertext, iv, k_enc, algo=algo) def sign(self, data, private_key, hash="sha256", recoverable=False, entropy=None): if len(private_key) == self._backend.public_key_length: is_compressed = False elif len(private_key) == self._backend.public_key_length + 1 and private_key[-1] == 1: is_compressed = True private_key = private_key[:-1] else: raise ValueError("Private key has invalid length") data = self._digest(data, hash) if not entropy: v = b"\x01" * len(data) k = b"\x00" * len(data) k = hmac.new(k, v + b"\x00" + private_key + data, "sha256").digest() v = hmac.new(k, v, "sha256").digest() k = hmac.new(k, v + b"\x01" + private_key + data, "sha256").digest() v = hmac.new(k, v, "sha256").digest() entropy = hmac.new(k, v, "sha256").digest() return self._backend.sign(data, private_key, recoverable, is_compressed, entropy=entropy) def recover(self, signature, data, hash="sha256"): # Sanity check: is this signature recoverable? if len(signature) != 1 + 2 * self._backend.public_key_length: raise ValueError("Cannot recover an unrecoverable signature") x, y = self._backend.recover(signature, self._digest(data, hash)) is_compressed = signature[0] >= 31 return self._encode_public_key(x, y, is_compressed=is_compressed) def verify(self, signature, data, public_key, hash="sha256"): if len(signature) == 1 + 2 * self._backend.public_key_length: # Recoverable signature signature = signature[1:] if len(signature) != 2 * self._backend.public_key_length: raise ValueError("Invalid signature format") if not isinstance(public_key, tuple): public_key = self._decode_public_key(public_key) return self._backend.verify(signature, self._digest(data, hash), public_key) def derive_child(self, seed, child): # Based on BIP32 if not 0 <= child < 2 ** 31: raise ValueError("Invalid child index") return self._backend.derive_child(seed, child) ================================================ FILE: src/lib/sslcrypto/_ripemd.py ================================================ # Copyright (c) 2001 Markus Friedl. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # pylint: skip-file import sys digest_size = 20 digestsize = 20 class RIPEMD160: """ Return a new RIPEMD160 object. An optional string argument may be provided; if present, this string will be automatically hashed. """ def __init__(self, arg=None): self.ctx = RMDContext() if arg: self.update(arg) self.dig = None def update(self, arg): RMD160Update(self.ctx, arg, len(arg)) self.dig = None def digest(self): if self.dig: return self.dig ctx = self.ctx.copy() self.dig = RMD160Final(self.ctx) self.ctx = ctx return self.dig def hexdigest(self): dig = self.digest() hex_digest = "" for d in dig: hex_digest += "%02x" % d return hex_digest def copy(self): import copy return copy.deepcopy(self) def new(arg=None): """ Return a new RIPEMD160 object. An optional string argument may be provided; if present, this string will be automatically hashed. """ return RIPEMD160(arg) # # Private. # class RMDContext: def __init__(self): self.state = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0] # uint32 self.count = 0 # uint64 self.buffer = [0] * 64 # uchar def copy(self): ctx = RMDContext() ctx.state = self.state[:] ctx.count = self.count ctx.buffer = self.buffer[:] return ctx K0 = 0x00000000 K1 = 0x5A827999 K2 = 0x6ED9EBA1 K3 = 0x8F1BBCDC K4 = 0xA953FD4E KK0 = 0x50A28BE6 KK1 = 0x5C4DD124 KK2 = 0x6D703EF3 KK3 = 0x7A6D76E9 KK4 = 0x00000000 def ROL(n, x): return ((x << n) & 0xffffffff) | (x >> (32 - n)) def F0(x, y, z): return x ^ y ^ z def F1(x, y, z): return (x & y) | (((~x) % 0x100000000) & z) def F2(x, y, z): return (x | ((~y) % 0x100000000)) ^ z def F3(x, y, z): return (x & z) | (((~z) % 0x100000000) & y) def F4(x, y, z): return x ^ (y | ((~z) % 0x100000000)) def R(a, b, c, d, e, Fj, Kj, sj, rj, X): a = ROL(sj, (a + Fj(b, c, d) + X[rj] + Kj) % 0x100000000) + e c = ROL(10, c) return a % 0x100000000, c PADDING = [0x80] + [0] * 63 import sys import struct def RMD160Transform(state, block): # uint32 state[5], uchar block[64] x = [0] * 16 if sys.byteorder == "little": x = struct.unpack("<16L", bytes(block[0:64])) else: raise ValueError("Big-endian platforms are not supported") a = state[0] b = state[1] c = state[2] d = state[3] e = state[4] # Round 1 a, c = R(a, b, c, d, e, F0, K0, 11, 0, x) e, b = R(e, a, b, c, d, F0, K0, 14, 1, x) d, a = R(d, e, a, b, c, F0, K0, 15, 2, x) c, e = R(c, d, e, a, b, F0, K0, 12, 3, x) b, d = R(b, c, d, e, a, F0, K0, 5, 4, x) a, c = R(a, b, c, d, e, F0, K0, 8, 5, x) e, b = R(e, a, b, c, d, F0, K0, 7, 6, x) d, a = R(d, e, a, b, c, F0, K0, 9, 7, x) c, e = R(c, d, e, a, b, F0, K0, 11, 8, x) b, d = R(b, c, d, e, a, F0, K0, 13, 9, x) a, c = R(a, b, c, d, e, F0, K0, 14, 10, x) e, b = R(e, a, b, c, d, F0, K0, 15, 11, x) d, a = R(d, e, a, b, c, F0, K0, 6, 12, x) c, e = R(c, d, e, a, b, F0, K0, 7, 13, x) b, d = R(b, c, d, e, a, F0, K0, 9, 14, x) a, c = R(a, b, c, d, e, F0, K0, 8, 15, x) # #15 # Round 2 e, b = R(e, a, b, c, d, F1, K1, 7, 7, x) d, a = R(d, e, a, b, c, F1, K1, 6, 4, x) c, e = R(c, d, e, a, b, F1, K1, 8, 13, x) b, d = R(b, c, d, e, a, F1, K1, 13, 1, x) a, c = R(a, b, c, d, e, F1, K1, 11, 10, x) e, b = R(e, a, b, c, d, F1, K1, 9, 6, x) d, a = R(d, e, a, b, c, F1, K1, 7, 15, x) c, e = R(c, d, e, a, b, F1, K1, 15, 3, x) b, d = R(b, c, d, e, a, F1, K1, 7, 12, x) a, c = R(a, b, c, d, e, F1, K1, 12, 0, x) e, b = R(e, a, b, c, d, F1, K1, 15, 9, x) d, a = R(d, e, a, b, c, F1, K1, 9, 5, x) c, e = R(c, d, e, a, b, F1, K1, 11, 2, x) b, d = R(b, c, d, e, a, F1, K1, 7, 14, x) a, c = R(a, b, c, d, e, F1, K1, 13, 11, x) e, b = R(e, a, b, c, d, F1, K1, 12, 8, x) # #31 # Round 3 d, a = R(d, e, a, b, c, F2, K2, 11, 3, x) c, e = R(c, d, e, a, b, F2, K2, 13, 10, x) b, d = R(b, c, d, e, a, F2, K2, 6, 14, x) a, c = R(a, b, c, d, e, F2, K2, 7, 4, x) e, b = R(e, a, b, c, d, F2, K2, 14, 9, x) d, a = R(d, e, a, b, c, F2, K2, 9, 15, x) c, e = R(c, d, e, a, b, F2, K2, 13, 8, x) b, d = R(b, c, d, e, a, F2, K2, 15, 1, x) a, c = R(a, b, c, d, e, F2, K2, 14, 2, x) e, b = R(e, a, b, c, d, F2, K2, 8, 7, x) d, a = R(d, e, a, b, c, F2, K2, 13, 0, x) c, e = R(c, d, e, a, b, F2, K2, 6, 6, x) b, d = R(b, c, d, e, a, F2, K2, 5, 13, x) a, c = R(a, b, c, d, e, F2, K2, 12, 11, x) e, b = R(e, a, b, c, d, F2, K2, 7, 5, x) d, a = R(d, e, a, b, c, F2, K2, 5, 12, x) # #47 # Round 4 c, e = R(c, d, e, a, b, F3, K3, 11, 1, x) b, d = R(b, c, d, e, a, F3, K3, 12, 9, x) a, c = R(a, b, c, d, e, F3, K3, 14, 11, x) e, b = R(e, a, b, c, d, F3, K3, 15, 10, x) d, a = R(d, e, a, b, c, F3, K3, 14, 0, x) c, e = R(c, d, e, a, b, F3, K3, 15, 8, x) b, d = R(b, c, d, e, a, F3, K3, 9, 12, x) a, c = R(a, b, c, d, e, F3, K3, 8, 4, x) e, b = R(e, a, b, c, d, F3, K3, 9, 13, x) d, a = R(d, e, a, b, c, F3, K3, 14, 3, x) c, e = R(c, d, e, a, b, F3, K3, 5, 7, x) b, d = R(b, c, d, e, a, F3, K3, 6, 15, x) a, c = R(a, b, c, d, e, F3, K3, 8, 14, x) e, b = R(e, a, b, c, d, F3, K3, 6, 5, x) d, a = R(d, e, a, b, c, F3, K3, 5, 6, x) c, e = R(c, d, e, a, b, F3, K3, 12, 2, x) # #63 # Round 5 b, d = R(b, c, d, e, a, F4, K4, 9, 4, x) a, c = R(a, b, c, d, e, F4, K4, 15, 0, x) e, b = R(e, a, b, c, d, F4, K4, 5, 5, x) d, a = R(d, e, a, b, c, F4, K4, 11, 9, x) c, e = R(c, d, e, a, b, F4, K4, 6, 7, x) b, d = R(b, c, d, e, a, F4, K4, 8, 12, x) a, c = R(a, b, c, d, e, F4, K4, 13, 2, x) e, b = R(e, a, b, c, d, F4, K4, 12, 10, x) d, a = R(d, e, a, b, c, F4, K4, 5, 14, x) c, e = R(c, d, e, a, b, F4, K4, 12, 1, x) b, d = R(b, c, d, e, a, F4, K4, 13, 3, x) a, c = R(a, b, c, d, e, F4, K4, 14, 8, x) e, b = R(e, a, b, c, d, F4, K4, 11, 11, x) d, a = R(d, e, a, b, c, F4, K4, 8, 6, x) c, e = R(c, d, e, a, b, F4, K4, 5, 15, x) b, d = R(b, c, d, e, a, F4, K4, 6, 13, x) # #79 aa = a bb = b cc = c dd = d ee = e a = state[0] b = state[1] c = state[2] d = state[3] e = state[4] # Parallel round 1 a, c = R(a, b, c, d, e, F4, KK0, 8, 5, x) e, b = R(e, a, b, c, d, F4, KK0, 9, 14, x) d, a = R(d, e, a, b, c, F4, KK0, 9, 7, x) c, e = R(c, d, e, a, b, F4, KK0, 11, 0, x) b, d = R(b, c, d, e, a, F4, KK0, 13, 9, x) a, c = R(a, b, c, d, e, F4, KK0, 15, 2, x) e, b = R(e, a, b, c, d, F4, KK0, 15, 11, x) d, a = R(d, e, a, b, c, F4, KK0, 5, 4, x) c, e = R(c, d, e, a, b, F4, KK0, 7, 13, x) b, d = R(b, c, d, e, a, F4, KK0, 7, 6, x) a, c = R(a, b, c, d, e, F4, KK0, 8, 15, x) e, b = R(e, a, b, c, d, F4, KK0, 11, 8, x) d, a = R(d, e, a, b, c, F4, KK0, 14, 1, x) c, e = R(c, d, e, a, b, F4, KK0, 14, 10, x) b, d = R(b, c, d, e, a, F4, KK0, 12, 3, x) a, c = R(a, b, c, d, e, F4, KK0, 6, 12, x) # #15 # Parallel round 2 e, b = R(e, a, b, c, d, F3, KK1, 9, 6, x) d, a = R(d, e, a, b, c, F3, KK1, 13, 11, x) c, e = R(c, d, e, a, b, F3, KK1, 15, 3, x) b, d = R(b, c, d, e, a, F3, KK1, 7, 7, x) a, c = R(a, b, c, d, e, F3, KK1, 12, 0, x) e, b = R(e, a, b, c, d, F3, KK1, 8, 13, x) d, a = R(d, e, a, b, c, F3, KK1, 9, 5, x) c, e = R(c, d, e, a, b, F3, KK1, 11, 10, x) b, d = R(b, c, d, e, a, F3, KK1, 7, 14, x) a, c = R(a, b, c, d, e, F3, KK1, 7, 15, x) e, b = R(e, a, b, c, d, F3, KK1, 12, 8, x) d, a = R(d, e, a, b, c, F3, KK1, 7, 12, x) c, e = R(c, d, e, a, b, F3, KK1, 6, 4, x) b, d = R(b, c, d, e, a, F3, KK1, 15, 9, x) a, c = R(a, b, c, d, e, F3, KK1, 13, 1, x) e, b = R(e, a, b, c, d, F3, KK1, 11, 2, x) # #31 # Parallel round 3 d, a = R(d, e, a, b, c, F2, KK2, 9, 15, x) c, e = R(c, d, e, a, b, F2, KK2, 7, 5, x) b, d = R(b, c, d, e, a, F2, KK2, 15, 1, x) a, c = R(a, b, c, d, e, F2, KK2, 11, 3, x) e, b = R(e, a, b, c, d, F2, KK2, 8, 7, x) d, a = R(d, e, a, b, c, F2, KK2, 6, 14, x) c, e = R(c, d, e, a, b, F2, KK2, 6, 6, x) b, d = R(b, c, d, e, a, F2, KK2, 14, 9, x) a, c = R(a, b, c, d, e, F2, KK2, 12, 11, x) e, b = R(e, a, b, c, d, F2, KK2, 13, 8, x) d, a = R(d, e, a, b, c, F2, KK2, 5, 12, x) c, e = R(c, d, e, a, b, F2, KK2, 14, 2, x) b, d = R(b, c, d, e, a, F2, KK2, 13, 10, x) a, c = R(a, b, c, d, e, F2, KK2, 13, 0, x) e, b = R(e, a, b, c, d, F2, KK2, 7, 4, x) d, a = R(d, e, a, b, c, F2, KK2, 5, 13, x) # #47 # Parallel round 4 c, e = R(c, d, e, a, b, F1, KK3, 15, 8, x) b, d = R(b, c, d, e, a, F1, KK3, 5, 6, x) a, c = R(a, b, c, d, e, F1, KK3, 8, 4, x) e, b = R(e, a, b, c, d, F1, KK3, 11, 1, x) d, a = R(d, e, a, b, c, F1, KK3, 14, 3, x) c, e = R(c, d, e, a, b, F1, KK3, 14, 11, x) b, d = R(b, c, d, e, a, F1, KK3, 6, 15, x) a, c = R(a, b, c, d, e, F1, KK3, 14, 0, x) e, b = R(e, a, b, c, d, F1, KK3, 6, 5, x) d, a = R(d, e, a, b, c, F1, KK3, 9, 12, x) c, e = R(c, d, e, a, b, F1, KK3, 12, 2, x) b, d = R(b, c, d, e, a, F1, KK3, 9, 13, x) a, c = R(a, b, c, d, e, F1, KK3, 12, 9, x) e, b = R(e, a, b, c, d, F1, KK3, 5, 7, x) d, a = R(d, e, a, b, c, F1, KK3, 15, 10, x) c, e = R(c, d, e, a, b, F1, KK3, 8, 14, x) # #63 # Parallel round 5 b, d = R(b, c, d, e, a, F0, KK4, 8, 12, x) a, c = R(a, b, c, d, e, F0, KK4, 5, 15, x) e, b = R(e, a, b, c, d, F0, KK4, 12, 10, x) d, a = R(d, e, a, b, c, F0, KK4, 9, 4, x) c, e = R(c, d, e, a, b, F0, KK4, 12, 1, x) b, d = R(b, c, d, e, a, F0, KK4, 5, 5, x) a, c = R(a, b, c, d, e, F0, KK4, 14, 8, x) e, b = R(e, a, b, c, d, F0, KK4, 6, 7, x) d, a = R(d, e, a, b, c, F0, KK4, 8, 6, x) c, e = R(c, d, e, a, b, F0, KK4, 13, 2, x) b, d = R(b, c, d, e, a, F0, KK4, 6, 13, x) a, c = R(a, b, c, d, e, F0, KK4, 5, 14, x) e, b = R(e, a, b, c, d, F0, KK4, 15, 0, x) d, a = R(d, e, a, b, c, F0, KK4, 13, 3, x) c, e = R(c, d, e, a, b, F0, KK4, 11, 9, x) b, d = R(b, c, d, e, a, F0, KK4, 11, 11, x) # #79 t = (state[1] + cc + d) % 0x100000000 state[1] = (state[2] + dd + e) % 0x100000000 state[2] = (state[3] + ee + a) % 0x100000000 state[3] = (state[4] + aa + b) % 0x100000000 state[4] = (state[0] + bb + c) % 0x100000000 state[0] = t % 0x100000000 def RMD160Update(ctx, inp, inplen): if type(inp) == str: inp = [ord(i)&0xff for i in inp] have = int((ctx.count // 8) % 64) inplen = int(inplen) need = 64 - have ctx.count += 8 * inplen off = 0 if inplen >= need: if have: for i in range(need): ctx.buffer[have + i] = inp[i] RMD160Transform(ctx.state, ctx.buffer) off = need have = 0 while off + 64 <= inplen: RMD160Transform(ctx.state, inp[off:]) #<--- off += 64 if off < inplen: # memcpy(ctx->buffer + have, input+off, len-off) for i in range(inplen - off): ctx.buffer[have + i] = inp[off + i] def RMD160Final(ctx): size = struct.pack("= self.n: return self.jacobian_multiply(a, n % self.n, secret) half = self.jacobian_multiply(a, n // 2, secret) half_sq = self.jacobian_double(half) if secret: # A constant-time implementation half_sq_a = self.jacobian_add(half_sq, a) if n % 2 == 0: result = half_sq if n % 2 == 1: result = half_sq_a return result else: if n % 2 == 0: return half_sq return self.jacobian_add(half_sq, a) def jacobian_shamir(self, a, n, b, m): ab = self.jacobian_add(a, b) if n < 0 or n >= self.n: n %= self.n if m < 0 or m >= self.n: m %= self.n res = 0, 0, 1 # point on infinity for i in range(self.n_length - 1, -1, -1): res = self.jacobian_double(res) has_n = n & (1 << i) has_m = m & (1 << i) if has_n: if has_m == 0: res = self.jacobian_add(res, a) if has_m != 0: res = self.jacobian_add(res, ab) else: if has_m == 0: res = self.jacobian_add(res, (0, 0, 1)) # Try not to leak if has_m != 0: res = self.jacobian_add(res, b) return res def fast_multiply(self, a, n, secret=False): return self.from_jacobian(self.jacobian_multiply(self.to_jacobian(a), n, secret)) def fast_add(self, a, b): return self.from_jacobian(self.jacobian_add(self.to_jacobian(a), self.to_jacobian(b))) def fast_shamir(self, a, n, b, m): return self.from_jacobian(self.jacobian_shamir(self.to_jacobian(a), n, self.to_jacobian(b), m)) def is_on_curve(self, a): x, y = a # Simple arithmetic check if (pow(x, 3, self.p) + self.a * x + self.b) % self.p != y * y % self.p: return False # nP = point-at-infinity return self.isinf(self.jacobian_multiply(self.to_jacobian(a), self.n)) ================================================ FILE: src/lib/sslcrypto/fallback/_util.py ================================================ def int_to_bytes(raw, length): data = [] for _ in range(length): data.append(raw % 256) raw //= 256 return bytes(data[::-1]) def bytes_to_int(data): raw = 0 for byte in data: raw = raw * 256 + byte return raw def legendre(a, p): res = pow(a, (p - 1) // 2, p) if res == p - 1: return -1 else: return res def inverse(a, n): if a == 0: return 0 lm, hm = 1, 0 low, high = a % n, n while low > 1: r = high // low nm, new = hm - lm * r, high - low * r lm, low, hm, high = nm, new, lm, low return lm % n def square_root_mod_prime(n, p): if n == 0: return 0 if p == 2: return n # We should never get here but it might be useful if legendre(n, p) != 1: raise ValueError("No square root") # Optimizations if p % 4 == 3: return pow(n, (p + 1) // 4, p) # 1. By factoring out powers of 2, find Q and S such that p - 1 = # Q * 2 ** S with Q odd q = p - 1 s = 0 while q % 2 == 0: q //= 2 s += 1 # 2. Search for z in Z/pZ which is a quadratic non-residue z = 1 while legendre(z, p) != -1: z += 1 m, c, t, r = s, pow(z, q, p), pow(n, q, p), pow(n, (q + 1) // 2, p) while True: if t == 0: return 0 elif t == 1: return r # Use repeated squaring to find the least i, 0 < i < M, such # that t ** (2 ** i) = 1 t_sq = t i = 0 for i in range(1, m): t_sq = t_sq * t_sq % p if t_sq == 1: break else: raise ValueError("Should never get here") # Let b = c ** (2 ** (m - i - 1)) b = pow(c, 2 ** (m - i - 1), p) m = i c = b * b % p t = t * b * b % p r = r * b % p return r ================================================ FILE: src/lib/sslcrypto/fallback/aes.py ================================================ import os import pyaes from .._aes import AES __all__ = ["aes"] class AESBackend: def _get_algo_cipher_type(self, algo): if not algo.startswith("aes-") or algo.count("-") != 2: raise ValueError("Unknown cipher algorithm {}".format(algo)) key_length, cipher_type = algo[4:].split("-") if key_length not in ("128", "192", "256"): raise ValueError("Unknown cipher algorithm {}".format(algo)) if cipher_type not in ("cbc", "ctr", "cfb", "ofb"): raise ValueError("Unknown cipher algorithm {}".format(algo)) return cipher_type def is_algo_supported(self, algo): try: self._get_algo_cipher_type(algo) return True except ValueError: return False def random(self, length): return os.urandom(length) def encrypt(self, data, key, algo="aes-256-cbc"): cipher_type = self._get_algo_cipher_type(algo) # Generate random IV iv = os.urandom(16) if cipher_type == "cbc": cipher = pyaes.AESModeOfOperationCBC(key, iv=iv) elif cipher_type == "ctr": # The IV is actually a counter, not an IV but it does almost the # same. Notice: pyaes always uses 1 as initial counter! Make sure # not to call pyaes directly. # We kinda do two conversions here: from byte array to int here, and # from int to byte array in pyaes internals. It's possible to fix that # but I didn't notice any performance changes so I'm keeping clean code. iv_int = 0 for byte in iv: iv_int = (iv_int * 256) + byte counter = pyaes.Counter(iv_int) cipher = pyaes.AESModeOfOperationCTR(key, counter=counter) elif cipher_type == "cfb": # Change segment size from default 8 bytes to 16 bytes for OpenSSL # compatibility cipher = pyaes.AESModeOfOperationCFB(key, iv, segment_size=16) elif cipher_type == "ofb": cipher = pyaes.AESModeOfOperationOFB(key, iv) encrypter = pyaes.Encrypter(cipher) ciphertext = encrypter.feed(data) ciphertext += encrypter.feed() return ciphertext, iv def decrypt(self, ciphertext, iv, key, algo="aes-256-cbc"): cipher_type = self._get_algo_cipher_type(algo) if cipher_type == "cbc": cipher = pyaes.AESModeOfOperationCBC(key, iv=iv) elif cipher_type == "ctr": # The IV is actually a counter, not an IV but it does almost the # same. Notice: pyaes always uses 1 as initial counter! Make sure # not to call pyaes directly. # We kinda do two conversions here: from byte array to int here, and # from int to byte array in pyaes internals. It's possible to fix that # but I didn't notice any performance changes so I'm keeping clean code. iv_int = 0 for byte in iv: iv_int = (iv_int * 256) + byte counter = pyaes.Counter(iv_int) cipher = pyaes.AESModeOfOperationCTR(key, counter=counter) elif cipher_type == "cfb": # Change segment size from default 8 bytes to 16 bytes for OpenSSL # compatibility cipher = pyaes.AESModeOfOperationCFB(key, iv, segment_size=16) elif cipher_type == "ofb": cipher = pyaes.AESModeOfOperationOFB(key, iv) decrypter = pyaes.Decrypter(cipher) data = decrypter.feed(ciphertext) data += decrypter.feed() return data def get_backend(self): return "fallback" aes = AES(AESBackend()) ================================================ FILE: src/lib/sslcrypto/fallback/ecc.py ================================================ import hmac import os from ._jacobian import JacobianCurve from .._ecc import ECC from .aes import aes from ._util import int_to_bytes, bytes_to_int, inverse, square_root_mod_prime class EllipticCurveBackend: def __init__(self, p, n, a, b, g): self.p, self.n, self.a, self.b, self.g = p, n, a, b, g self.jacobian = JacobianCurve(p, n, a, b, g) self.public_key_length = (len(bin(p).replace("0b", "")) + 7) // 8 self.order_bitlength = len(bin(n).replace("0b", "")) def _int_to_bytes(self, raw, len=None): return int_to_bytes(raw, len or self.public_key_length) def decompress_point(self, public_key): # Parse & load data x = bytes_to_int(public_key[1:]) # Calculate Y y_square = (pow(x, 3, self.p) + self.a * x + self.b) % self.p try: y = square_root_mod_prime(y_square, self.p) except Exception: raise ValueError("Invalid public key") from None if y % 2 != public_key[0] - 0x02: y = self.p - y return self._int_to_bytes(x), self._int_to_bytes(y) def new_private_key(self): while True: private_key = os.urandom(self.public_key_length) if bytes_to_int(private_key) >= self.n: continue return private_key def private_to_public(self, private_key): raw = bytes_to_int(private_key) x, y = self.jacobian.fast_multiply(self.g, raw) return self._int_to_bytes(x), self._int_to_bytes(y) def ecdh(self, private_key, public_key): x, y = public_key x, y = bytes_to_int(x), bytes_to_int(y) private_key = bytes_to_int(private_key) x, _ = self.jacobian.fast_multiply((x, y), private_key, secret=True) return self._int_to_bytes(x) def _subject_to_int(self, subject): return bytes_to_int(subject[:(self.order_bitlength + 7) // 8]) def sign(self, subject, raw_private_key, recoverable, is_compressed, entropy): z = self._subject_to_int(subject) private_key = bytes_to_int(raw_private_key) k = bytes_to_int(entropy) # Fix k length to prevent Minerva. Increasing multiplier by a # multiple of order doesn't break anything. This fix was ported # from python-ecdsa ks = k + self.n kt = ks + self.n ks_len = len(bin(ks).replace("0b", "")) // 8 kt_len = len(bin(kt).replace("0b", "")) // 8 if ks_len == kt_len: k = kt else: k = ks px, py = self.jacobian.fast_multiply(self.g, k, secret=True) r = px % self.n if r == 0: # Invalid k raise ValueError("Invalid k") s = (inverse(k, self.n) * (z + (private_key * r))) % self.n if s == 0: # Invalid k raise ValueError("Invalid k") inverted = False if s * 2 >= self.n: s = self.n - s inverted = True rs_buf = self._int_to_bytes(r) + self._int_to_bytes(s) if recoverable: recid = (py % 2) ^ inverted recid += 2 * int(px // self.n) if is_compressed: return bytes([31 + recid]) + rs_buf else: if recid >= 4: raise ValueError("Too big recovery ID, use compressed address instead") return bytes([27 + recid]) + rs_buf else: return rs_buf def recover(self, signature, subject): z = self._subject_to_int(subject) recid = signature[0] - 27 if signature[0] < 31 else signature[0] - 31 r = bytes_to_int(signature[1:self.public_key_length + 1]) s = bytes_to_int(signature[self.public_key_length + 1:]) # Verify bounds if not 0 <= recid < 2 * (self.p // self.n + 1): raise ValueError("Invalid recovery ID") if r >= self.n: raise ValueError("r is out of bounds") if s >= self.n: raise ValueError("s is out of bounds") rinv = inverse(r, self.n) u1 = (-z * rinv) % self.n u2 = (s * rinv) % self.n # Recover R rx = r + (recid // 2) * self.n if rx >= self.p: raise ValueError("Rx is out of bounds") # Almost copied from decompress_point ry_square = (pow(rx, 3, self.p) + self.a * rx + self.b) % self.p try: ry = square_root_mod_prime(ry_square, self.p) except Exception: raise ValueError("Invalid recovered public key") from None # Ensure the point is correct if ry % 2 != recid % 2: # Fix Ry sign ry = self.p - ry x, y = self.jacobian.fast_shamir(self.g, u1, (rx, ry), u2) return self._int_to_bytes(x), self._int_to_bytes(y) def verify(self, signature, subject, public_key): z = self._subject_to_int(subject) r = bytes_to_int(signature[:self.public_key_length]) s = bytes_to_int(signature[self.public_key_length:]) # Verify bounds if r >= self.n: raise ValueError("r is out of bounds") if s >= self.n: raise ValueError("s is out of bounds") public_key = [bytes_to_int(c) for c in public_key] # Ensure that the public key is correct if not self.jacobian.is_on_curve(public_key): raise ValueError("Public key is not on curve") sinv = inverse(s, self.n) u1 = (z * sinv) % self.n u2 = (r * sinv) % self.n x1, _ = self.jacobian.fast_shamir(self.g, u1, public_key, u2) if r != x1 % self.n: raise ValueError("Invalid signature") return True def derive_child(self, seed, child): # Round 1 h = hmac.new(key=b"Bitcoin seed", msg=seed, digestmod="sha512").digest() private_key1 = h[:32] x, y = self.private_to_public(private_key1) public_key1 = bytes([0x02 + (y[-1] % 2)]) + x private_key1 = bytes_to_int(private_key1) # Round 2 msg = public_key1 + self._int_to_bytes(child, 4) h = hmac.new(key=h[32:], msg=msg, digestmod="sha512").digest() private_key2 = bytes_to_int(h[:32]) return self._int_to_bytes((private_key1 + private_key2) % self.n) @classmethod def get_backend(cls): return "fallback" ecc = ECC(EllipticCurveBackend, aes) ================================================ FILE: src/lib/sslcrypto/fallback/rsa.py ================================================ # pylint: disable=too-few-public-methods class RSA: def get_backend(self): return "fallback" rsa = RSA() ================================================ FILE: src/lib/sslcrypto/openssl/__init__.py ================================================ from .aes import aes from .ecc import ecc from .rsa import rsa ================================================ FILE: src/lib/sslcrypto/openssl/aes.py ================================================ import ctypes import threading from .._aes import AES from ..fallback.aes import aes as fallback_aes from .library import lib, openssl_backend # Initialize functions try: lib.EVP_CIPHER_CTX_new.restype = ctypes.POINTER(ctypes.c_char) except AttributeError: pass lib.EVP_get_cipherbyname.restype = ctypes.POINTER(ctypes.c_char) thread_local = threading.local() class Context: def __init__(self, ptr, do_free): self.lib = lib self.ptr = ptr self.do_free = do_free def __del__(self): if self.do_free: self.lib.EVP_CIPHER_CTX_free(self.ptr) class AESBackend: ALGOS = ( "aes-128-cbc", "aes-192-cbc", "aes-256-cbc", "aes-128-ctr", "aes-192-ctr", "aes-256-ctr", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "aes-128-ofb", "aes-192-ofb", "aes-256-ofb" ) def __init__(self): self.is_supported_ctx_new = hasattr(lib, "EVP_CIPHER_CTX_new") self.is_supported_ctx_reset = hasattr(lib, "EVP_CIPHER_CTX_reset") def _get_ctx(self): if not hasattr(thread_local, "ctx"): if self.is_supported_ctx_new: thread_local.ctx = Context(lib.EVP_CIPHER_CTX_new(), True) else: # 1 KiB ought to be enough for everybody. We don't know the real # size of the context buffer because we are unsure about padding and # pointer size thread_local.ctx = Context(ctypes.create_string_buffer(1024), False) return thread_local.ctx.ptr def get_backend(self): return openssl_backend def _get_cipher(self, algo): if algo not in self.ALGOS: raise ValueError("Unknown cipher algorithm {}".format(algo)) cipher = lib.EVP_get_cipherbyname(algo.encode()) if not cipher: raise ValueError("Unknown cipher algorithm {}".format(algo)) return cipher def is_algo_supported(self, algo): try: self._get_cipher(algo) return True except ValueError: return False def random(self, length): entropy = ctypes.create_string_buffer(length) lib.RAND_bytes(entropy, length) return bytes(entropy) def encrypt(self, data, key, algo="aes-256-cbc"): # Initialize context ctx = self._get_ctx() if not self.is_supported_ctx_new: lib.EVP_CIPHER_CTX_init(ctx) try: lib.EVP_EncryptInit_ex(ctx, self._get_cipher(algo), None, None, None) # Generate random IV iv_length = 16 iv = self.random(iv_length) # Set key and IV lib.EVP_EncryptInit_ex(ctx, None, None, key, iv) # Actually encrypt block_size = 16 output = ctypes.create_string_buffer((len(data) // block_size + 1) * block_size) output_len = ctypes.c_int() if not lib.EVP_CipherUpdate(ctx, output, ctypes.byref(output_len), data, len(data)): raise ValueError("Could not feed cipher with data") new_output = ctypes.byref(output, output_len.value) output_len2 = ctypes.c_int() if not lib.EVP_CipherFinal_ex(ctx, new_output, ctypes.byref(output_len2)): raise ValueError("Could not finalize cipher") ciphertext = output[:output_len.value + output_len2.value] return ciphertext, iv finally: if self.is_supported_ctx_reset: lib.EVP_CIPHER_CTX_reset(ctx) else: lib.EVP_CIPHER_CTX_cleanup(ctx) def decrypt(self, ciphertext, iv, key, algo="aes-256-cbc"): # Initialize context ctx = self._get_ctx() if not self.is_supported_ctx_new: lib.EVP_CIPHER_CTX_init(ctx) try: lib.EVP_DecryptInit_ex(ctx, self._get_cipher(algo), None, None, None) # Make sure IV length is correct iv_length = 16 if len(iv) != iv_length: raise ValueError("Expected IV to be {} bytes, got {} bytes".format(iv_length, len(iv))) # Set key and IV lib.EVP_DecryptInit_ex(ctx, None, None, key, iv) # Actually decrypt output = ctypes.create_string_buffer(len(ciphertext)) output_len = ctypes.c_int() if not lib.EVP_DecryptUpdate(ctx, output, ctypes.byref(output_len), ciphertext, len(ciphertext)): raise ValueError("Could not feed decipher with ciphertext") new_output = ctypes.byref(output, output_len.value) output_len2 = ctypes.c_int() if not lib.EVP_DecryptFinal_ex(ctx, new_output, ctypes.byref(output_len2)): raise ValueError("Could not finalize decipher") return output[:output_len.value + output_len2.value] finally: if self.is_supported_ctx_reset: lib.EVP_CIPHER_CTX_reset(ctx) else: lib.EVP_CIPHER_CTX_cleanup(ctx) aes = AES(AESBackend(), fallback_aes) ================================================ FILE: src/lib/sslcrypto/openssl/discovery.py ================================================ # Can be redefined by user def discover(): pass ================================================ FILE: src/lib/sslcrypto/openssl/ecc.py ================================================ import ctypes import hmac import threading from .._ecc import ECC from .aes import aes from .library import lib, openssl_backend # Initialize functions lib.BN_new.restype = ctypes.POINTER(ctypes.c_char) lib.BN_bin2bn.restype = ctypes.POINTER(ctypes.c_char) lib.BN_CTX_new.restype = ctypes.POINTER(ctypes.c_char) lib.EC_GROUP_new_curve_GFp.restype = ctypes.POINTER(ctypes.c_char) lib.EC_KEY_new.restype = ctypes.POINTER(ctypes.c_char) lib.EC_POINT_new.restype = ctypes.POINTER(ctypes.c_char) lib.EC_KEY_get0_private_key.restype = ctypes.POINTER(ctypes.c_char) lib.EVP_PKEY_new.restype = ctypes.POINTER(ctypes.c_char) try: lib.EVP_PKEY_CTX_new.restype = ctypes.POINTER(ctypes.c_char) except AttributeError: pass thread_local = threading.local() # This lock is required to keep ECC thread-safe. Old OpenSSL versions (before # 1.1.0) use global objects so they aren't thread safe. Fortunately we can check # the code to find out which functions are thread safe. # # For example, EC_GROUP_new_curve_GFp checks global error code to initialize # the group, so if two errors happen at once or two threads read the error code, # or the codes are read in the wrong order, the group is initialized in a wrong # way. # # EC_KEY_new_by_curve_name calls EC_GROUP_new_curve_GFp so it's not thread # safe. We can't use the lock because it would be too slow; instead, we use # EC_KEY_new and then EC_KEY_set_group which calls EC_GROUP_copy instead which # is thread safe. lock = threading.Lock() class BN: # BN_CTX class Context: def __init__(self): self.ptr = lib.BN_CTX_new() self.lib = lib # For finalizer def __del__(self): self.lib.BN_CTX_free(self.ptr) @classmethod def get(cls): # Get thread-safe contexf if not hasattr(thread_local, "bn_ctx"): thread_local.bn_ctx = cls() return thread_local.bn_ctx.ptr def __init__(self, value=None, link_only=False): if link_only: self.bn = value self._free = False else: if value is None: self.bn = lib.BN_new() self._free = True elif isinstance(value, int) and value < 256: self.bn = lib.BN_new() lib.BN_clear(self.bn) lib.BN_add_word(self.bn, value) self._free = True else: if isinstance(value, int): value = value.to_bytes(128, "big") self.bn = lib.BN_bin2bn(value, len(value), None) self._free = True def __del__(self): if self._free: lib.BN_free(self.bn) def bytes(self, length=None): buf = ctypes.create_string_buffer((len(self) + 7) // 8) lib.BN_bn2bin(self.bn, buf) buf = bytes(buf) if length is None: return buf else: if length < len(buf): raise ValueError("Too little space for BN") return b"\x00" * (length - len(buf)) + buf def __int__(self): value = 0 for byte in self.bytes(): value = value * 256 + byte return value def __len__(self): return lib.BN_num_bits(self.bn) def inverse(self, modulo): result = BN() if not lib.BN_mod_inverse(result.bn, self.bn, modulo.bn, BN.Context.get()): raise ValueError("Could not compute inverse") return result def __floordiv__(self, other): if not isinstance(other, BN): raise TypeError("Can only divide BN by BN, not {}".format(other)) result = BN() if not lib.BN_div(result.bn, None, self.bn, other.bn, BN.Context.get()): raise ZeroDivisionError("Division by zero") return result def __mod__(self, other): if not isinstance(other, BN): raise TypeError("Can only divide BN by BN, not {}".format(other)) result = BN() if not lib.BN_div(None, result.bn, self.bn, other.bn, BN.Context.get()): raise ZeroDivisionError("Division by zero") return result def __add__(self, other): if not isinstance(other, BN): raise TypeError("Can only sum BN's, not BN and {}".format(other)) result = BN() if not lib.BN_add(result.bn, self.bn, other.bn): raise ValueError("Could not sum two BN's") return result def __sub__(self, other): if not isinstance(other, BN): raise TypeError("Can only subtract BN's, not BN and {}".format(other)) result = BN() if not lib.BN_sub(result.bn, self.bn, other.bn): raise ValueError("Could not subtract BN from BN") return result def __mul__(self, other): if not isinstance(other, BN): raise TypeError("Can only multiply BN by BN, not {}".format(other)) result = BN() if not lib.BN_mul(result.bn, self.bn, other.bn, BN.Context.get()): raise ValueError("Could not multiply two BN's") return result def __neg__(self): return BN(0) - self # A dirty but nice way to update current BN and free old BN at the same time def __imod__(self, other): res = self % other self.bn, res.bn = res.bn, self.bn return self def __iadd__(self, other): res = self + other self.bn, res.bn = res.bn, self.bn return self def __isub__(self, other): res = self - other self.bn, res.bn = res.bn, self.bn return self def __imul__(self, other): res = self * other self.bn, res.bn = res.bn, self.bn return self def cmp(self, other): if not isinstance(other, BN): raise TypeError("Can only compare BN with BN, not {}".format(other)) return lib.BN_cmp(self.bn, other.bn) def __eq__(self, other): return self.cmp(other) == 0 def __lt__(self, other): return self.cmp(other) < 0 def __gt__(self, other): return self.cmp(other) > 0 def __ne__(self, other): return self.cmp(other) != 0 def __le__(self, other): return self.cmp(other) <= 0 def __ge__(self, other): return self.cmp(other) >= 0 def __repr__(self): return "".format(int(self)) def __str__(self): return str(int(self)) class EllipticCurveBackend: def __init__(self, p, n, a, b, g): bn_ctx = BN.Context.get() self.lib = lib # For finalizer self.p = BN(p) self.order = BN(n) self.a = BN(a) self.b = BN(b) self.h = BN((p + n // 2) // n) with lock: # Thread-safety self.group = lib.EC_GROUP_new_curve_GFp(self.p.bn, self.a.bn, self.b.bn, bn_ctx) if not self.group: raise ValueError("Could not create group object") generator = self._public_key_to_point(g) lib.EC_GROUP_set_generator(self.group, generator, self.order.bn, self.h.bn) if not self.group: raise ValueError("The curve is not supported by OpenSSL") self.public_key_length = (len(self.p) + 7) // 8 self.is_supported_evp_pkey_ctx = hasattr(lib, "EVP_PKEY_CTX_new") def __del__(self): self.lib.EC_GROUP_free(self.group) def _private_key_to_ec_key(self, private_key): # Thread-safety eckey = lib.EC_KEY_new() lib.EC_KEY_set_group(eckey, self.group) if not eckey: raise ValueError("Failed to allocate EC_KEY") private_key = BN(private_key) if not lib.EC_KEY_set_private_key(eckey, private_key.bn): lib.EC_KEY_free(eckey) raise ValueError("Invalid private key") return eckey, private_key def _public_key_to_point(self, public_key): x = BN(public_key[0]) y = BN(public_key[1]) # EC_KEY_set_public_key_affine_coordinates is not supported by # OpenSSL 1.0.0 so we can't use it point = lib.EC_POINT_new(self.group) if not lib.EC_POINT_set_affine_coordinates_GFp(self.group, point, x.bn, y.bn, BN.Context.get()): raise ValueError("Could not set public key affine coordinates") return point def _public_key_to_ec_key(self, public_key): # Thread-safety eckey = lib.EC_KEY_new() lib.EC_KEY_set_group(eckey, self.group) if not eckey: raise ValueError("Failed to allocate EC_KEY") try: # EC_KEY_set_public_key_affine_coordinates is not supported by # OpenSSL 1.0.0 so we can't use it point = self._public_key_to_point(public_key) if not lib.EC_KEY_set_public_key(eckey, point): raise ValueError("Could not set point") lib.EC_POINT_free(point) return eckey except Exception as e: lib.EC_KEY_free(eckey) raise e from None def _point_to_affine(self, point): # Convert to affine coordinates x = BN() y = BN() if lib.EC_POINT_get_affine_coordinates_GFp(self.group, point, x.bn, y.bn, BN.Context.get()) != 1: raise ValueError("Failed to convert public key to affine coordinates") # Convert to binary if (len(x) + 7) // 8 > self.public_key_length: raise ValueError("Public key X coordinate is too large") if (len(y) + 7) // 8 > self.public_key_length: raise ValueError("Public key Y coordinate is too large") return x.bytes(self.public_key_length), y.bytes(self.public_key_length) def decompress_point(self, public_key): point = lib.EC_POINT_new(self.group) if not point: raise ValueError("Could not create point") try: if not lib.EC_POINT_oct2point(self.group, point, public_key, len(public_key), BN.Context.get()): raise ValueError("Invalid compressed public key") return self._point_to_affine(point) finally: lib.EC_POINT_free(point) def new_private_key(self): # Create random key # Thread-safety eckey = lib.EC_KEY_new() lib.EC_KEY_set_group(eckey, self.group) lib.EC_KEY_generate_key(eckey) # To big integer private_key = BN(lib.EC_KEY_get0_private_key(eckey), link_only=True) # To binary private_key_buf = private_key.bytes(self.public_key_length) # Cleanup lib.EC_KEY_free(eckey) return private_key_buf def private_to_public(self, private_key): eckey, private_key = self._private_key_to_ec_key(private_key) try: # Derive public key point = lib.EC_POINT_new(self.group) try: if not lib.EC_POINT_mul(self.group, point, private_key.bn, None, None, BN.Context.get()): raise ValueError("Failed to derive public key") return self._point_to_affine(point) finally: lib.EC_POINT_free(point) finally: lib.EC_KEY_free(eckey) def ecdh(self, private_key, public_key): if not self.is_supported_evp_pkey_ctx: # Use ECDH_compute_key instead # Create EC_KEY from private key eckey, _ = self._private_key_to_ec_key(private_key) try: # Create EC_POINT from public key point = self._public_key_to_point(public_key) try: key = ctypes.create_string_buffer(self.public_key_length) if lib.ECDH_compute_key(key, self.public_key_length, point, eckey, None) == -1: raise ValueError("Could not compute shared secret") return bytes(key) finally: lib.EC_POINT_free(point) finally: lib.EC_KEY_free(eckey) # Private key: # Create EC_KEY eckey, _ = self._private_key_to_ec_key(private_key) try: # Convert to EVP_PKEY pkey = lib.EVP_PKEY_new() if not pkey: raise ValueError("Could not create private key object") try: lib.EVP_PKEY_set1_EC_KEY(pkey, eckey) # Public key: # Create EC_KEY peer_eckey = self._public_key_to_ec_key(public_key) try: # Convert to EVP_PKEY peer_pkey = lib.EVP_PKEY_new() if not peer_pkey: raise ValueError("Could not create public key object") try: lib.EVP_PKEY_set1_EC_KEY(peer_pkey, peer_eckey) # Create context ctx = lib.EVP_PKEY_CTX_new(pkey, None) if not ctx: raise ValueError("Could not create EVP context") try: if lib.EVP_PKEY_derive_init(ctx) != 1: raise ValueError("Could not initialize key derivation") if not lib.EVP_PKEY_derive_set_peer(ctx, peer_pkey): raise ValueError("Could not set peer") # Actually derive key_len = ctypes.c_int(0) lib.EVP_PKEY_derive(ctx, None, ctypes.byref(key_len)) key = ctypes.create_string_buffer(key_len.value) lib.EVP_PKEY_derive(ctx, key, ctypes.byref(key_len)) return bytes(key) finally: lib.EVP_PKEY_CTX_free(ctx) finally: lib.EVP_PKEY_free(peer_pkey) finally: lib.EC_KEY_free(peer_eckey) finally: lib.EVP_PKEY_free(pkey) finally: lib.EC_KEY_free(eckey) def _subject_to_bn(self, subject): return BN(subject[:(len(self.order) + 7) // 8]) def sign(self, subject, private_key, recoverable, is_compressed, entropy): z = self._subject_to_bn(subject) private_key = BN(private_key) k = BN(entropy) rp = lib.EC_POINT_new(self.group) bn_ctx = BN.Context.get() try: # Fix Minerva k1 = k + self.order k2 = k1 + self.order if len(k1) == len(k2): k = k2 else: k = k1 if not lib.EC_POINT_mul(self.group, rp, k.bn, None, None, bn_ctx): raise ValueError("Could not generate R") # Convert to affine coordinates rx = BN() ry = BN() if lib.EC_POINT_get_affine_coordinates_GFp(self.group, rp, rx.bn, ry.bn, bn_ctx) != 1: raise ValueError("Failed to convert R to affine coordinates") r = rx % self.order if r == BN(0): raise ValueError("Invalid k") # Calculate s = k^-1 * (z + r * private_key) mod n s = (k.inverse(self.order) * (z + r * private_key)) % self.order if s == BN(0): raise ValueError("Invalid k") inverted = False if s * BN(2) >= self.order: s = self.order - s inverted = True r_buf = r.bytes(self.public_key_length) s_buf = s.bytes(self.public_key_length) if recoverable: # Generate recid recid = int(ry % BN(2)) ^ inverted # The line below is highly unlikely to matter in case of # secp256k1 but might make sense for other curves recid += 2 * int(rx // self.order) if is_compressed: return bytes([31 + recid]) + r_buf + s_buf else: if recid >= 4: raise ValueError("Too big recovery ID, use compressed address instead") return bytes([27 + recid]) + r_buf + s_buf else: return r_buf + s_buf finally: lib.EC_POINT_free(rp) def recover(self, signature, subject): recid = signature[0] - 27 if signature[0] < 31 else signature[0] - 31 r = BN(signature[1:self.public_key_length + 1]) s = BN(signature[self.public_key_length + 1:]) # Verify bounds if r >= self.order: raise ValueError("r is out of bounds") if s >= self.order: raise ValueError("s is out of bounds") bn_ctx = BN.Context.get() z = self._subject_to_bn(subject) rinv = r.inverse(self.order) u1 = (-z * rinv) % self.order u2 = (s * rinv) % self.order # Recover R rx = r + BN(recid // 2) * self.order if rx >= self.p: raise ValueError("Rx is out of bounds") rp = lib.EC_POINT_new(self.group) if not rp: raise ValueError("Could not create R") try: init_buf = b"\x02" + rx.bytes(self.public_key_length) if not lib.EC_POINT_oct2point(self.group, rp, init_buf, len(init_buf), bn_ctx): raise ValueError("Could not use Rx to initialize point") ry = BN() if lib.EC_POINT_get_affine_coordinates_GFp(self.group, rp, None, ry.bn, bn_ctx) != 1: raise ValueError("Failed to convert R to affine coordinates") if int(ry % BN(2)) != recid % 2: # Fix Ry sign ry = self.p - ry if lib.EC_POINT_set_affine_coordinates_GFp(self.group, rp, rx.bn, ry.bn, bn_ctx) != 1: raise ValueError("Failed to update R coordinates") # Recover public key result = lib.EC_POINT_new(self.group) if not result: raise ValueError("Could not create point") try: if not lib.EC_POINT_mul(self.group, result, u1.bn, rp, u2.bn, bn_ctx): raise ValueError("Could not recover public key") return self._point_to_affine(result) finally: lib.EC_POINT_free(result) finally: lib.EC_POINT_free(rp) def verify(self, signature, subject, public_key): r_raw = signature[:self.public_key_length] r = BN(r_raw) s = BN(signature[self.public_key_length:]) if r >= self.order: raise ValueError("r is out of bounds") if s >= self.order: raise ValueError("s is out of bounds") bn_ctx = BN.Context.get() z = self._subject_to_bn(subject) pub_p = lib.EC_POINT_new(self.group) if not pub_p: raise ValueError("Could not create public key point") try: init_buf = b"\x04" + public_key[0] + public_key[1] if not lib.EC_POINT_oct2point(self.group, pub_p, init_buf, len(init_buf), bn_ctx): raise ValueError("Could initialize point") sinv = s.inverse(self.order) u1 = (z * sinv) % self.order u2 = (r * sinv) % self.order # Recover public key result = lib.EC_POINT_new(self.group) if not result: raise ValueError("Could not create point") try: if not lib.EC_POINT_mul(self.group, result, u1.bn, pub_p, u2.bn, bn_ctx): raise ValueError("Could not recover public key") if BN(self._point_to_affine(result)[0]) % self.order != r: raise ValueError("Invalid signature") return True finally: lib.EC_POINT_free(result) finally: lib.EC_POINT_free(pub_p) def derive_child(self, seed, child): # Round 1 h = hmac.new(key=b"Bitcoin seed", msg=seed, digestmod="sha512").digest() private_key1 = h[:32] x, y = self.private_to_public(private_key1) public_key1 = bytes([0x02 + (y[-1] % 2)]) + x private_key1 = BN(private_key1) # Round 2 child_bytes = [] for _ in range(4): child_bytes.append(child & 255) child >>= 8 child_bytes = bytes(child_bytes[::-1]) msg = public_key1 + child_bytes h = hmac.new(key=h[32:], msg=msg, digestmod="sha512").digest() private_key2 = BN(h[:32]) return ((private_key1 + private_key2) % self.order).bytes(self.public_key_length) @classmethod def get_backend(cls): return openssl_backend ecc = ECC(EllipticCurveBackend, aes) ================================================ FILE: src/lib/sslcrypto/openssl/library.py ================================================ import os import sys import ctypes import ctypes.util from .discovery import discover as user_discover # Disable false-positive _MEIPASS # pylint: disable=no-member,protected-access # Discover OpenSSL library def discover_paths(): # Search local files first if "win" in sys.platform: # Windows names = [ "libeay32.dll" ] openssl_paths = [os.path.abspath(path) for path in names] if hasattr(sys, "_MEIPASS"): openssl_paths += [os.path.join(sys._MEIPASS, path) for path in openssl_paths] openssl_paths.append(ctypes.util.find_library("libeay32")) elif "darwin" in sys.platform: # Mac OS names = [ "libcrypto.dylib", "libcrypto.1.1.0.dylib", "libcrypto.1.0.2.dylib", "libcrypto.1.0.1.dylib", "libcrypto.1.0.0.dylib", "libcrypto.0.9.8.dylib" ] openssl_paths = [os.path.abspath(path) for path in names] openssl_paths += names openssl_paths += [ "/usr/local/opt/openssl/lib/libcrypto.dylib" ] if hasattr(sys, "_MEIPASS") and "RESOURCEPATH" in os.environ: openssl_paths += [ os.path.join(os.environ["RESOURCEPATH"], "..", "Frameworks", name) for name in names ] openssl_paths.append(ctypes.util.find_library("ssl")) else: # Linux, BSD and such names = [ "libcrypto.so", "libssl.so", "libcrypto.so.1.1.0", "libssl.so.1.1.0", "libcrypto.so.1.0.2", "libssl.so.1.0.2", "libcrypto.so.1.0.1", "libssl.so.1.0.1", "libcrypto.so.1.0.0", "libssl.so.1.0.0", "libcrypto.so.0.9.8", "libssl.so.0.9.8" ] openssl_paths = [os.path.abspath(path) for path in names] openssl_paths += names if hasattr(sys, "_MEIPASS"): openssl_paths += [os.path.join(sys._MEIPASS, path) for path in names] openssl_paths.append(ctypes.util.find_library("ssl")) lst = user_discover() if isinstance(lst, str): lst = [lst] elif not lst: lst = [] return lst + openssl_paths def discover_library(): for path in discover_paths(): if path: try: return ctypes.CDLL(path) except OSError: pass raise OSError("OpenSSL is unavailable") lib = discover_library() # Initialize internal state try: lib.OPENSSL_add_all_algorithms_conf() except AttributeError: pass try: lib.OpenSSL_version.restype = ctypes.c_char_p openssl_backend = lib.OpenSSL_version(0).decode() except AttributeError: lib.SSLeay_version.restype = ctypes.c_char_p openssl_backend = lib.SSLeay_version(0).decode() openssl_backend += " at " + lib._name ================================================ FILE: src/lib/sslcrypto/openssl/rsa.py ================================================ # pylint: disable=too-few-public-methods from .library import openssl_backend class RSA: def get_backend(self): return openssl_backend rsa = RSA() ================================================ FILE: src/lib/subtl/LICENCE ================================================ Copyright (c) 2012, Packetloop. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Packetloop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: src/lib/subtl/README.md ================================================ # subtl ## Overview SUBTL is a **s**imple **U**DP **B**itTorrent **t**racker **l**ibrary for Python, licenced under the modified BSD license. ## Example This short example will list a few IP Addresses from a certain hash: from subtl import UdpTrackerClient utc = UdpTrackerClient('tracker.openbittorrent.com', 80) utc.connect() if not utc.poll_once(): raise Exception('Could not connect') print('Success!') utc.announce(info_hash='089184ED52AA37F71801391C451C5D5ADD0D9501') data = utc.poll_once() if not data: raise Exception('Could not announce') for a in data['response']['peers']: print(a) ## Caveats * There is no automatic retrying of sending packets yet. * This library won't download torrent files--it is simply a tracker client. ================================================ FILE: src/lib/subtl/__init__.py ================================================ ================================================ FILE: src/lib/subtl/subtl.py ================================================ ''' Based on the specification at http://bittorrent.org/beps/bep_0015.html ''' import binascii import random import struct import time import socket from collections import defaultdict __version__ = '0.0.1' CONNECT = 0 ANNOUNCE = 1 SCRAPE = 2 ERROR = 3 class UdpTrackerClientException(Exception): pass class UdpTrackerClient: def __init__(self, host, port): self.host = host self.port = port self.peer_port = 6881 self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.conn_id = 0x41727101980 self.transactions = {} self.peer_id = self._generate_peer_id() self.timeout = 9 def connect(self): return self._send(CONNECT) def announce(self, **kwargs): if not kwargs: raise UdpTrackerClientException('arguments missing') args = { 'peer_id': self.peer_id, 'downloaded': 0, 'left': 0, 'uploaded': 0, 'event': 0, 'key': 0, 'num_want': 10, 'ip_address': 0, 'port': self.peer_port, } args.update(kwargs) fields = 'info_hash peer_id downloaded left uploaded event ' \ 'ip_address key num_want port' # Check and raise if missing fields self._check_fields(args, fields) # Humans tend to use hex representations of the hash. Wasteful humans. args['info_hash'] = args['info_hash'] values = [args[a] for a in fields.split()] values[1] = values[1].encode("utf8") payload = struct.pack('!20s20sQQQLLLLH', *values) return self._send(ANNOUNCE, payload) def scrape(self, info_hash_list): if len(info_hash_list) > 74: raise UdpTrackerClientException('Max info_hashes is 74') payload = '' for info_hash in info_hash_list: payload += info_hash trans = self._send(SCRAPE, payload) trans['sent_hashes'] = info_hash_list return trans def poll_once(self): self.sock.settimeout(self.timeout) try: response = self.sock.recv(10240) except socket.timeout: return header = response[:8] payload = response[8:] action, trans_id = struct.unpack('!LL', header) try: trans = self.transactions[trans_id] except KeyError: self.error('transaction_id not found') return trans['response'] = self._process_response(action, payload, trans) trans['completed'] = True del self.transactions[trans_id] return trans def error(self, message): raise Exception('error: {}'.format(message)) def _send(self, action, payload=None): if not payload: payload = b'' trans_id, header = self._request_header(action) self.transactions[trans_id] = trans = { 'action': action, 'time': time.time(), 'payload': payload, 'completed': False, } self.sock.connect((self.host, self.port)) self.sock.send(header + payload) return trans def _request_header(self, action): trans_id = random.randint(0, (1 << 32) - 1) return trans_id, struct.pack('!QLL', self.conn_id, action, trans_id) def _process_response(self, action, payload, trans): if action == CONNECT: return self._process_connect(payload, trans) elif action == ANNOUNCE: return self._process_announce(payload, trans) elif action == SCRAPE: return self._process_scrape(payload, trans) elif action == ERROR: return self._process_error(payload, trans) else: raise UdpTrackerClientException( 'Unknown action response: {}'.format(action)) def _process_connect(self, payload, trans): self.conn_id = struct.unpack('!Q', payload)[0] return self.conn_id def _process_announce(self, payload, trans): response = {} info_struct = '!LLL' info_size = struct.calcsize(info_struct) info = payload[:info_size] interval, leechers, seeders = struct.unpack(info_struct, info) peer_data = payload[info_size:] peer_struct = '!LH' peer_size = struct.calcsize(peer_struct) peer_count = int(len(peer_data) / peer_size) peers = [] for peer_offset in range(peer_count): off = peer_size * peer_offset peer = peer_data[off:off + peer_size] addr, port = struct.unpack(peer_struct, peer) peers.append({ 'addr': socket.inet_ntoa(struct.pack('!L', addr)), 'port': port, }) return { 'interval': interval, 'leechers': leechers, 'seeders': seeders, 'peers': peers, } def _process_scrape(self, payload, trans): info_struct = '!LLL' info_size = struct.calcsize(info_struct) info_count = len(payload) / info_size hashes = trans['sent_hashes'] response = {} for info_offset in range(info_count): off = info_size * info_offset info = payload[off:off + info_size] seeders, completed, leechers = struct.unpack(info_struct, info) response[hashes[info_offset]] = { 'seeders': seeders, 'completed': completed, 'leechers': leechers, } return response def _process_error(self, payload, trans): ''' I haven't seen this action type be sent from a tracker, but I've left it here for the possibility. ''' self.error(payload) return False def _generate_peer_id(self): '''http://www.bittorrent.org/beps/bep_0020.html''' peer_id = '-PU' + __version__.replace('.', '-') + '-' remaining = 20 - len(peer_id) numbers = [str(random.randint(0, 9)) for _ in range(remaining)] peer_id += ''.join(numbers) assert(len(peer_id) == 20) return peer_id def _check_fields(self, args, fields): for f in fields: try: args.get(f) except KeyError: raise UdpTrackerClientException('field missing: {}'.format(f)) ================================================ FILE: src/main.py ================================================ # Included modules import os import sys import stat import time import logging startup_errors = [] def startupError(msg): startup_errors.append(msg) print("Startup error: %s" % msg) # Third party modules import gevent if gevent.version_info.major <= 1: # Workaround for random crash when libuv used with threads try: if "libev" not in str(gevent.config.loop): gevent.config.loop = "libev-cext" except Exception as err: startupError("Unable to switch gevent loop to libev: %s" % err) import gevent.monkey gevent.monkey.patch_all(thread=False, subprocess=False) update_after_shutdown = False # If set True then update and restart zeronet after main loop ended restart_after_shutdown = False # If set True then restart zeronet after main loop ended # Load config from Config import config config.parse(silent=True) # Plugins need to access the configuration if not config.arguments: # Config parse failed, show the help screen and exit config.parse() if not os.path.isdir(config.data_dir): os.mkdir(config.data_dir) try: os.chmod(config.data_dir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) except Exception as err: startupError("Can't change permission of %s: %s" % (config.data_dir, err)) if not os.path.isfile("%s/sites.json" % config.data_dir): open("%s/sites.json" % config.data_dir, "w").write("{}") if not os.path.isfile("%s/users.json" % config.data_dir): open("%s/users.json" % config.data_dir, "w").write("{}") if config.action == "main": from util import helper try: lock = helper.openLocked("%s/lock.pid" % config.data_dir, "w") lock.write("%s" % os.getpid()) except BlockingIOError as err: startupError("Can't open lock file, your ZeroNet client is probably already running, exiting... (%s)" % err) if config.open_browser and config.open_browser != "False": print("Opening browser: %s...", config.open_browser) import webbrowser try: if config.open_browser == "default_browser": browser = webbrowser.get() else: browser = webbrowser.get(config.open_browser) browser.open("http://%s:%s/%s" % ( config.ui_ip if config.ui_ip != "*" else "127.0.0.1", config.ui_port, config.homepage ), new=2) except Exception as err: startupError("Error starting browser: %s" % err) sys.exit() config.initLogging() # Debug dependent configuration from Debug import DebugHook # Load plugins from Plugin import PluginManager PluginManager.plugin_manager.loadPlugins() config.loadPlugins() config.parse() # Parse again to add plugin configuration options # Log current config logging.debug("Config: %s" % config) # Modify stack size on special hardwares if config.stack_size: import threading threading.stack_size(config.stack_size) # Use pure-python implementation of msgpack to save CPU if config.msgpack_purepython: os.environ["MSGPACK_PUREPYTHON"] = "True" # Fix console encoding on Windows if sys.platform.startswith("win"): import subprocess try: chcp_res = subprocess.check_output("chcp 65001", shell=True).decode(errors="ignore").strip() logging.debug("Changed console encoding to utf8: %s" % chcp_res) except Exception as err: logging.error("Error changing console encoding to utf8: %s" % err) # Socket monkey patch if config.proxy: from util import SocksProxy import urllib.request logging.info("Patching sockets to socks proxy: %s" % config.proxy) if config.fileserver_ip == "*": config.fileserver_ip = '127.0.0.1' # Do not accept connections anywhere but localhost config.disable_udp = True # UDP not supported currently with proxy SocksProxy.monkeyPatch(*config.proxy.split(":")) elif config.tor == "always": from util import SocksProxy import urllib.request logging.info("Patching sockets to tor socks proxy: %s" % config.tor_proxy) if config.fileserver_ip == "*": config.fileserver_ip = '127.0.0.1' # Do not accept connections anywhere but localhost SocksProxy.monkeyPatch(*config.tor_proxy.split(":")) config.disable_udp = True elif config.bind: bind = config.bind if ":" not in config.bind: bind += ":0" from util import helper helper.socketBindMonkeyPatch(*bind.split(":")) # -- Actions -- @PluginManager.acceptPlugins class Actions(object): def call(self, function_name, kwargs): logging.info("Version: %s r%s, Python %s, Gevent: %s" % (config.version, config.rev, sys.version, gevent.__version__)) func = getattr(self, function_name, None) back = func(**kwargs) if back: print(back) # Default action: Start serving UiServer and FileServer def main(self): global ui_server, file_server from File import FileServer from Ui import UiServer logging.info("Creating FileServer....") file_server = FileServer() logging.info("Creating UiServer....") ui_server = UiServer() file_server.ui_server = ui_server for startup_error in startup_errors: logging.error("Startup error: %s" % startup_error) logging.info("Removing old SSL certs...") from Crypt import CryptConnection CryptConnection.manager.removeCerts() logging.info("Starting servers....") gevent.joinall([gevent.spawn(ui_server.start), gevent.spawn(file_server.start)]) logging.info("All server stopped") # Site commands def siteCreate(self, use_master_seed=True): logging.info("Generating new privatekey (use_master_seed: %s)..." % config.use_master_seed) from Crypt import CryptBitcoin if use_master_seed: from User import UserManager user = UserManager.user_manager.get() if not user: user = UserManager.user_manager.create() address, address_index, site_data = user.getNewSiteData() privatekey = site_data["privatekey"] logging.info("Generated using master seed from users.json, site index: %s" % address_index) else: privatekey = CryptBitcoin.newPrivatekey() address = CryptBitcoin.privatekeyToAddress(privatekey) logging.info("----------------------------------------------------------------------") logging.info("Site private key: %s" % privatekey) logging.info(" !!! ^ Save it now, required to modify the site ^ !!!") logging.info("Site address: %s" % address) logging.info("----------------------------------------------------------------------") while True and not config.batch and not use_master_seed: if input("? Have you secured your private key? (yes, no) > ").lower() == "yes": break else: logging.info("Please, secure it now, you going to need it to modify your site!") logging.info("Creating directory structure...") from Site.Site import Site from Site import SiteManager SiteManager.site_manager.load() os.mkdir("%s/%s" % (config.data_dir, address)) open("%s/%s/index.html" % (config.data_dir, address), "w").write("Hello %s!" % address) logging.info("Creating content.json...") site = Site(address) extend = {"postmessage_nonce_security": True} if use_master_seed: extend["address_index"] = address_index site.content_manager.sign(privatekey=privatekey, extend=extend) site.settings["own"] = True site.saveSettings() logging.info("Site created!") def siteSign(self, address, privatekey=None, inner_path="content.json", publish=False, remove_missing_optional=False): from Site.Site import Site from Site import SiteManager from Debug import Debug SiteManager.site_manager.load() logging.info("Signing site: %s..." % address) site = Site(address, allow_create=False) if not privatekey: # If no privatekey defined from User import UserManager user = UserManager.user_manager.get() if user: site_data = user.getSiteData(address) privatekey = site_data.get("privatekey") else: privatekey = None if not privatekey: # Not found in users.json, ask from console import getpass privatekey = getpass.getpass("Private key (input hidden):") try: succ = site.content_manager.sign( inner_path=inner_path, privatekey=privatekey, update_changed_files=True, remove_missing_optional=remove_missing_optional ) except Exception as err: logging.error("Sign error: %s" % Debug.formatException(err)) succ = False if succ and publish: self.sitePublish(address, inner_path=inner_path) def siteVerify(self, address): import time from Site.Site import Site from Site import SiteManager SiteManager.site_manager.load() s = time.time() logging.info("Verifing site: %s..." % address) site = Site(address) bad_files = [] for content_inner_path in site.content_manager.contents: s = time.time() logging.info("Verifing %s signature..." % content_inner_path) err = None try: file_correct = site.content_manager.verifyFile( content_inner_path, site.storage.open(content_inner_path, "rb"), ignore_same=False ) except Exception as err: file_correct = False if file_correct is True: logging.info("[OK] %s (Done in %.3fs)" % (content_inner_path, time.time() - s)) else: logging.error("[ERROR] %s: invalid file: %s!" % (content_inner_path, err)) input("Continue?") bad_files += content_inner_path logging.info("Verifying site files...") bad_files += site.storage.verifyFiles()["bad_files"] if not bad_files: logging.info("[OK] All file sha512sum matches! (%.3fs)" % (time.time() - s)) else: logging.error("[ERROR] Error during verifying site files!") def dbRebuild(self, address): from Site.Site import Site from Site import SiteManager SiteManager.site_manager.load() logging.info("Rebuilding site sql cache: %s..." % address) site = SiteManager.site_manager.get(address) s = time.time() try: site.storage.rebuildDb() logging.info("Done in %.3fs" % (time.time() - s)) except Exception as err: logging.error(err) def dbQuery(self, address, query): from Site.Site import Site from Site import SiteManager SiteManager.site_manager.load() import json site = Site(address) result = [] for row in site.storage.query(query): result.append(dict(row)) print(json.dumps(result, indent=4)) def siteAnnounce(self, address): from Site.Site import Site from Site import SiteManager SiteManager.site_manager.load() logging.info("Opening a simple connection server") global file_server from File import FileServer file_server = FileServer("127.0.0.1", 1234) file_server.start() logging.info("Announcing site %s to tracker..." % address) site = Site(address) s = time.time() site.announce() print("Response time: %.3fs" % (time.time() - s)) print(site.peers) def siteDownload(self, address): from Site.Site import Site from Site import SiteManager SiteManager.site_manager.load() logging.info("Opening a simple connection server") global file_server from File import FileServer file_server = FileServer("127.0.0.1", 1234) file_server_thread = gevent.spawn(file_server.start, check_sites=False) site = Site(address) on_completed = gevent.event.AsyncResult() def onComplete(evt): evt.set(True) site.onComplete.once(lambda: onComplete(on_completed)) print("Announcing...") site.announce() s = time.time() print("Downloading...") site.downloadContent("content.json", check_modifications=True) print("Downloaded in %.3fs" % (time.time()-s)) def siteNeedFile(self, address, inner_path): from Site.Site import Site from Site import SiteManager SiteManager.site_manager.load() def checker(): while 1: s = time.time() time.sleep(1) print("Switch time:", time.time() - s) gevent.spawn(checker) logging.info("Opening a simple connection server") global file_server from File import FileServer file_server = FileServer("127.0.0.1", 1234) file_server_thread = gevent.spawn(file_server.start, check_sites=False) site = Site(address) site.announce() print(site.needFile(inner_path, update=True)) def siteCmd(self, address, cmd, parameters): import json from Site import SiteManager site = SiteManager.site_manager.get(address) if not site: logging.error("Site not found: %s" % address) return None ws = self.getWebsocket(site) ws.send(json.dumps({"cmd": cmd, "params": parameters, "id": 1})) res_raw = ws.recv() try: res = json.loads(res_raw) except Exception as err: return {"error": "Invalid result: %s" % err, "res_raw": res_raw} if "result" in res: return res["result"] else: return res def getWebsocket(self, site): import websocket ws_address = "ws://%s:%s/Websocket?wrapper_key=%s" % (config.ui_ip, config.ui_port, site.settings["wrapper_key"]) logging.info("Connecting to %s" % ws_address) ws = websocket.create_connection(ws_address) return ws def sitePublish(self, address, peer_ip=None, peer_port=15441, inner_path="content.json"): global file_server from Site.Site import Site from Site import SiteManager from File import FileServer # We need fileserver to handle incoming file requests from Peer import Peer file_server = FileServer() site = SiteManager.site_manager.get(address) logging.info("Loading site...") site.settings["serving"] = True # Serving the site even if its disabled try: ws = self.getWebsocket(site) logging.info("Sending siteReload") self.siteCmd(address, "siteReload", inner_path) logging.info("Sending sitePublish") self.siteCmd(address, "sitePublish", {"inner_path": inner_path, "sign": False}) logging.info("Done.") except Exception as err: logging.info("Can't connect to local websocket client: %s" % err) logging.info("Creating FileServer....") file_server_thread = gevent.spawn(file_server.start, check_sites=False) # Dont check every site integrity time.sleep(0.001) # Started fileserver file_server.portCheck() if peer_ip: # Announce ip specificed site.addPeer(peer_ip, peer_port) else: # Just ask the tracker logging.info("Gathering peers from tracker") site.announce() # Gather peers published = site.publish(5, inner_path) # Push to peers if published > 0: time.sleep(3) logging.info("Serving files (max 60s)...") gevent.joinall([file_server_thread], timeout=60) logging.info("Done.") else: logging.info("No peers found, sitePublish command only works if you already have visitors serving your site") # Crypto commands def cryptPrivatekeyToAddress(self, privatekey=None): from Crypt import CryptBitcoin if not privatekey: # If no privatekey in args then ask it now import getpass privatekey = getpass.getpass("Private key (input hidden):") print(CryptBitcoin.privatekeyToAddress(privatekey)) def cryptSign(self, message, privatekey): from Crypt import CryptBitcoin print(CryptBitcoin.sign(message, privatekey)) def cryptVerify(self, message, sign, address): from Crypt import CryptBitcoin print(CryptBitcoin.verify(message, address, sign)) def cryptGetPrivatekey(self, master_seed, site_address_index=None): from Crypt import CryptBitcoin if len(master_seed) != 64: logging.error("Error: Invalid master seed length: %s (required: 64)" % len(master_seed)) return False privatekey = CryptBitcoin.hdPrivatekey(master_seed, site_address_index) print("Requested private key: %s" % privatekey) # Peer def peerPing(self, peer_ip, peer_port=None): if not peer_port: peer_port = 15441 logging.info("Opening a simple connection server") global file_server from Connection import ConnectionServer file_server = ConnectionServer("127.0.0.1", 1234) file_server.start(check_connections=False) from Crypt import CryptConnection CryptConnection.manager.loadCerts() from Peer import Peer logging.info("Pinging 5 times peer: %s:%s..." % (peer_ip, int(peer_port))) s = time.time() peer = Peer(peer_ip, peer_port) peer.connect() if not peer.connection: print("Error: Can't connect to peer (connection error: %s)" % peer.connection_error) return False if "shared_ciphers" in dir(peer.connection.sock): print("Shared ciphers:", peer.connection.sock.shared_ciphers()) if "cipher" in dir(peer.connection.sock): print("Cipher:", peer.connection.sock.cipher()[0]) if "version" in dir(peer.connection.sock): print("TLS version:", peer.connection.sock.version()) print("Connection time: %.3fs (connection error: %s)" % (time.time() - s, peer.connection_error)) for i in range(5): ping_delay = peer.ping() print("Response time: %.3fs" % ping_delay) time.sleep(1) peer.remove() print("Reconnect test...") peer = Peer(peer_ip, peer_port) for i in range(5): ping_delay = peer.ping() print("Response time: %.3fs" % ping_delay) time.sleep(1) def peerGetFile(self, peer_ip, peer_port, site, filename, benchmark=False): logging.info("Opening a simple connection server") global file_server from Connection import ConnectionServer file_server = ConnectionServer("127.0.0.1", 1234) file_server.start(check_connections=False) from Crypt import CryptConnection CryptConnection.manager.loadCerts() from Peer import Peer logging.info("Getting %s/%s from peer: %s:%s..." % (site, filename, peer_ip, peer_port)) peer = Peer(peer_ip, peer_port) s = time.time() if benchmark: for i in range(10): peer.getFile(site, filename), print("Response time: %.3fs" % (time.time() - s)) input("Check memory") else: print(peer.getFile(site, filename).read()) def peerCmd(self, peer_ip, peer_port, cmd, parameters): logging.info("Opening a simple connection server") global file_server from Connection import ConnectionServer file_server = ConnectionServer() file_server.start(check_connections=False) from Crypt import CryptConnection CryptConnection.manager.loadCerts() from Peer import Peer peer = Peer(peer_ip, peer_port) import json if parameters: parameters = json.loads(parameters.replace("'", '"')) else: parameters = {} try: res = peer.request(cmd, parameters) print(json.dumps(res, indent=2, ensure_ascii=False)) except Exception as err: print("Unknown response (%s): %s" % (err, res)) def getConfig(self): import json print(json.dumps(config.getServerInfo(), indent=2, ensure_ascii=False)) def test(self, test_name, *args, **kwargs): import types def funcToName(func_name): test_name = func_name.replace("test", "") return test_name[0].lower() + test_name[1:] test_names = [funcToName(name) for name in dir(self) if name.startswith("test") and name != "test"] if not test_name: # No test specificed, list tests print("\nNo test specified, possible tests:") for test_name in test_names: func_name = "test" + test_name[0].upper() + test_name[1:] func = getattr(self, func_name) if func.__doc__: print("- %s: %s" % (test_name, func.__doc__.strip())) else: print("- %s" % test_name) return None # Run tests func_name = "test" + test_name[0].upper() + test_name[1:] if hasattr(self, func_name): func = getattr(self, func_name) print("- Running test: %s" % test_name, end="") s = time.time() ret = func(*args, **kwargs) if type(ret) is types.GeneratorType: for progress in ret: print(progress, end="") sys.stdout.flush() print("\n* Test %s done in %.3fs" % (test_name, time.time() - s)) else: print("Unknown test: %r (choose from: %s)" % ( test_name, test_names )) actions = Actions() # Starts here when running zeronet.py def start(): # Call function action_kwargs = config.getActionArguments() actions.call(config.action, action_kwargs) ================================================ FILE: src/util/Cached.py ================================================ import time class Cached(object): def __init__(self, timeout): self.cache_db = {} self.timeout = timeout def __call__(self, func): def wrapper(*args, **kwargs): key = "%s %s" % (args, kwargs) cached_value = None cache_hit = False if key in self.cache_db: cache_hit = True cached_value, time_cached_end = self.cache_db[key] if time.time() > time_cached_end: self.cleanupExpired() cached_value = None cache_hit = False if cache_hit: return cached_value else: cached_value = func(*args, **kwargs) time_cached_end = time.time() + self.timeout self.cache_db[key] = (cached_value, time_cached_end) return cached_value wrapper.emptyCache = self.emptyCache return wrapper def cleanupExpired(self): for key in list(self.cache_db.keys()): cached_value, time_cached_end = self.cache_db[key] if time.time() > time_cached_end: del(self.cache_db[key]) def emptyCache(self): num = len(self.cache_db) self.cache_db.clear() return num if __name__ == "__main__": from gevent import monkey monkey.patch_all() @Cached(timeout=2) def calcAdd(a, b): print("CalcAdd", a, b) return a + b @Cached(timeout=1) def calcMultiply(a, b): print("calcMultiply", a, b) return a * b for i in range(5): print("---") print("Emptied", calcAdd.emptyCache()) assert calcAdd(1, 2) == 3 print("Emptied", calcAdd.emptyCache()) assert calcAdd(1, 2) == 3 assert calcAdd(2, 3) == 5 assert calcMultiply(2, 3) == 6 time.sleep(1) ================================================ FILE: src/util/Diff.py ================================================ import io import difflib def sumLen(lines): return sum(map(len, lines)) def diff(old, new, limit=False): matcher = difflib.SequenceMatcher(None, old, new) actions = [] size = 0 for tag, old_from, old_to, new_from, new_to in matcher.get_opcodes(): if tag == "insert": new_line = new[new_from:new_to] actions.append(("+", new_line)) size += sum(map(len, new_line)) elif tag == "equal": actions.append(("=", sumLen(old[old_from:old_to]))) elif tag == "delete": actions.append(("-", sumLen(old[old_from:old_to]))) elif tag == "replace": actions.append(("-", sumLen(old[old_from:old_to]))) new_lines = new[new_from:new_to] actions.append(("+", new_lines)) size += sumLen(new_lines) if limit and size > limit: return False return actions def patch(old_f, actions): new_f = io.BytesIO() for action, param in actions: if type(action) is bytes: action = action.decode() if action == "=": # Same lines new_f.write(old_f.read(param)) elif action == "-": # Delete lines old_f.seek(param, 1) # Seek from current position continue elif action == "+": # Add lines for add_line in param: new_f.write(add_line) else: raise "Unknown action: %s" % action return new_f ================================================ FILE: src/util/Electrum.py ================================================ import hashlib import struct # Electrum, the heck?! def bchr(i): return struct.pack("B", i) def encode(val, base, minlen=0): base, minlen = int(base), int(minlen) code_string = b"".join([bchr(x) for x in range(256)]) result = b"" while val > 0: index = val % base result = code_string[index:index + 1] + result val //= base return code_string[0:1] * max(minlen - len(result), 0) + result def insane_int(x): x = int(x) if x < 253: return bchr(x) elif x < 65536: return bchr(253) + encode(x, 256, 2)[::-1] elif x < 4294967296: return bchr(254) + encode(x, 256, 4)[::-1] else: return bchr(255) + encode(x, 256, 8)[::-1] def magic(message): return b"\x18Bitcoin Signed Message:\n" + insane_int(len(message)) + message def format(message): return hashlib.sha256(magic(message)).digest() def dbl_format(message): return hashlib.sha256(format(message)).digest() ================================================ FILE: src/util/Event.py ================================================ # Based on http://stackoverflow.com/a/2022629 class Event(list): def __call__(self, *args, **kwargs): for f in self[:]: if "once" in dir(f) and f in self: self.remove(f) f(*args, **kwargs) def __repr__(self): return "Event(%s)" % list.__repr__(self) def once(self, func, name=None): func.once = True func.name = None if name: # Dont function with same name twice names = [f.name for f in self if "once" in dir(f)] if name not in names: func.name = name self.append(func) else: self.append(func) return self if __name__ == "__main__": def testBenchmark(): def say(pre, text): print("%s Say: %s" % (pre, text)) import time s = time.time() on_changed = Event() for i in range(1000): on_changed.once(lambda pre: say(pre, "once"), "once") print("Created 1000 once in %.3fs" % (time.time() - s)) on_changed("#1") def testUsage(): def say(pre, text): print("%s Say: %s" % (pre, text)) on_changed = Event() on_changed.once(lambda pre: say(pre, "once")) on_changed.once(lambda pre: say(pre, "once")) on_changed.once(lambda pre: say(pre, "namedonce"), "namedonce") on_changed.once(lambda pre: say(pre, "namedonce"), "namedonce") on_changed.append(lambda pre: say(pre, "always")) on_changed("#1") on_changed("#2") on_changed("#3") testBenchmark() ================================================ FILE: src/util/Flag.py ================================================ from collections import defaultdict class Flag(object): def __init__(self): self.valid_flags = set([ "admin", # Only allowed to run sites with ADMIN permission "async_run", # Action will be ran async with gevent.spawn "no_multiuser" # Action disabled if Multiuser plugin running in open proxy mode ]) self.db = defaultdict(set) def __getattr__(self, key): def func(f): if key not in self.valid_flags: raise Exception("Invalid flag: %s (valid: %s)" % (key, self.valid_flags)) self.db[f.__name__].add(key) return f return func flag = Flag() ================================================ FILE: src/util/GreenletManager.py ================================================ import gevent from Debug import Debug class GreenletManager: def __init__(self): self.greenlets = set() def spawnLater(self, *args, **kwargs): greenlet = gevent.spawn_later(*args, **kwargs) greenlet.link(lambda greenlet: self.greenlets.remove(greenlet)) self.greenlets.add(greenlet) return greenlet def spawn(self, *args, **kwargs): greenlet = gevent.spawn(*args, **kwargs) greenlet.link(lambda greenlet: self.greenlets.remove(greenlet)) self.greenlets.add(greenlet) return greenlet def stopGreenlets(self, reason="Stopping all greenlets"): num = len(self.greenlets) gevent.killall(list(self.greenlets), Debug.createNotifyType(reason), block=False) return num ================================================ FILE: src/util/Msgpack.py ================================================ import os import struct import io import msgpack import msgpack.fallback def msgpackHeader(size): if size <= 2 ** 8 - 1: return b"\xc4" + struct.pack("B", size) elif size <= 2 ** 16 - 1: return b"\xc5" + struct.pack(">H", size) elif size <= 2 ** 32 - 1: return b"\xc6" + struct.pack(">I", size) else: raise Exception("huge binary string") def stream(data, writer): packer = msgpack.Packer(use_bin_type=True) writer(packer.pack_map_header(len(data))) for key, val in data.items(): writer(packer.pack(key)) if isinstance(val, io.IOBase): # File obj max_size = os.fstat(val.fileno()).st_size - val.tell() size = min(max_size, val.read_bytes) bytes_left = size writer(msgpackHeader(size)) buff = 1024 * 64 while 1: writer(val.read(min(bytes_left, buff))) bytes_left = bytes_left - buff if bytes_left <= 0: break else: # Simple writer(packer.pack(val)) return size class FilePart(object): __slots__ = ("file", "read_bytes", "__class__") def __init__(self, *args, **kwargs): self.file = open(*args, **kwargs) self.__enter__ == self.file.__enter__ def __getattr__(self, attr): return getattr(self.file, attr) def __enter__(self, *args, **kwargs): return self.file.__enter__(*args, **kwargs) def __exit__(self, *args, **kwargs): return self.file.__exit__(*args, **kwargs) # Don't try to decode the value of these fields as utf8 bin_value_keys = ("hashfield_raw", "peers", "peers_ipv6", "peers_onion", "body", "sites", "bin") def objectDecoderHook(obj): global bin_value_keys back = {} for key, val in obj: if type(key) is bytes: key = key.decode("utf8") if key in bin_value_keys or type(val) is not bytes or len(key) >= 64: back[key] = val else: back[key] = val.decode("utf8") return back def getUnpacker(fallback=False, decode=True): if fallback: # Pure Python unpacker = msgpack.fallback.Unpacker else: unpacker = msgpack.Unpacker extra_kwargs = {"max_buffer_size": 5 * 1024 * 1024} if msgpack.version[0] >= 1: extra_kwargs["strict_map_key"] = False if decode: # Workaround for backward compatibility: Try to decode bin to str unpacker = unpacker(raw=True, object_pairs_hook=objectDecoderHook, **extra_kwargs) else: unpacker = unpacker(raw=False, **extra_kwargs) return unpacker def pack(data, use_bin_type=True): return msgpack.packb(data, use_bin_type=use_bin_type) def unpack(data, decode=True): unpacker = getUnpacker(decode=decode) unpacker.feed(data) return next(unpacker) ================================================ FILE: src/util/Noparallel.py ================================================ import gevent import time from gevent.event import AsyncResult from . import ThreadPool class Noparallel: # Only allow function running once in same time def __init__(self, blocking=True, ignore_args=False, ignore_class=False, queue=False): self.threads = {} self.blocking = blocking # Blocking: Acts like normal function else thread returned self.queue = queue # Execute again when blocking is done self.queued = False self.ignore_args = ignore_args # Block does not depend on function call arguments self.ignore_class = ignore_class # Block does not depeds on class instance def __call__(self, func): def wrapper(*args, **kwargs): if not ThreadPool.isMainThread(): return ThreadPool.main_loop.call(wrapper, *args, **kwargs) if self.ignore_class: key = func # Unique key only by function and class object elif self.ignore_args: key = (func, args[0]) # Unique key only by function and class object else: key = (func, tuple(args), str(kwargs)) # Unique key for function including parameters if key in self.threads: # Thread already running (if using blocking mode) if self.queue: self.queued = True thread = self.threads[key] if self.blocking: if self.queued: res = thread.get() # Blocking until its finished if key in self.threads: return self.threads[key].get() # Queue finished since started running self.queued = False return wrapper(*args, **kwargs) # Run again after the end else: return thread.get() # Return the value else: # No blocking if thread.ready(): # Its finished, create a new thread = gevent.spawn(func, *args, **kwargs) self.threads[key] = thread return thread else: # Still running return thread else: # Thread not running if self.blocking: # Wait for finish asyncres = AsyncResult() self.threads[key] = asyncres try: res = func(*args, **kwargs) asyncres.set(res) self.cleanup(key, asyncres) return res except Exception as err: asyncres.set_exception(err) self.cleanup(key, asyncres) raise(err) else: # No blocking just return the thread thread = gevent.spawn(func, *args, **kwargs) # Spawning new thread thread.link(lambda thread: self.cleanup(key, thread)) self.threads[key] = thread return thread wrapper.__name__ = func.__name__ return wrapper # Cleanup finished threads def cleanup(self, key, thread): if key in self.threads: del(self.threads[key]) if __name__ == "__main__": class Test(): @Noparallel() def count(self, num=5): for i in range(num): print(self, i) time.sleep(1) return "%s return:%s" % (self, i) class TestNoblock(): @Noparallel(blocking=False) def count(self, num=5): for i in range(num): print(self, i) time.sleep(1) return "%s return:%s" % (self, i) def testBlocking(): test = Test() test2 = Test() print("Counting...") print("Creating class1/thread1") thread1 = gevent.spawn(test.count) print("Creating class1/thread2 (ignored)") thread2 = gevent.spawn(test.count) print("Creating class2/thread3") thread3 = gevent.spawn(test2.count) print("Joining class1/thread1") thread1.join() print("Joining class1/thread2") thread2.join() print("Joining class2/thread3") thread3.join() print("Creating class1/thread4 (its finished, allowed again)") thread4 = gevent.spawn(test.count) print("Joining thread4") thread4.join() print(thread1.value, thread2.value, thread3.value, thread4.value) print("Done.") def testNoblocking(): test = TestNoblock() test2 = TestNoblock() print("Creating class1/thread1") thread1 = test.count() print("Creating class1/thread2 (ignored)") thread2 = test.count() print("Creating class2/thread3") thread3 = test2.count() print("Joining class1/thread1") thread1.join() print("Joining class1/thread2") thread2.join() print("Joining class2/thread3") thread3.join() print("Creating class1/thread4 (its finished, allowed again)") thread4 = test.count() print("Joining thread4") thread4.join() print(thread1.value, thread2.value, thread3.value, thread4.value) print("Done.") def testBenchmark(): import time def printThreadNum(): import gc from greenlet import greenlet objs = [obj for obj in gc.get_objects() if isinstance(obj, greenlet)] print("Greenlets: %s" % len(objs)) printThreadNum() test = TestNoblock() s = time.time() for i in range(3): gevent.spawn(test.count, i + 1) print("Created in %.3fs" % (time.time() - s)) printThreadNum() time.sleep(5) def testException(): import time @Noparallel(blocking=True, queue=True) def count(self, num=5): s = time.time() # raise Exception("err") for i in range(num): print(self, i) time.sleep(1) return "%s return:%s" % (s, i) def caller(): try: print("Ret:", count(5)) except Exception as err: print("Raised:", repr(err)) gevent.joinall([ gevent.spawn(caller), gevent.spawn(caller), gevent.spawn(caller), gevent.spawn(caller) ]) from gevent import monkey monkey.patch_all() testException() """ testBenchmark() print("Testing blocking mode...") testBlocking() print("Testing noblocking mode...") testNoblocking() """ ================================================ FILE: src/util/OpensslFindPatch.py ================================================ import logging import os import sys import ctypes.util from Config import config find_library_original = ctypes.util.find_library def getOpensslPath(): if config.openssl_lib_file: return config.openssl_lib_file if sys.platform.startswith("win"): lib_paths = [ os.path.join(os.getcwd(), "tools/openssl/libeay32.dll"), # ZeroBundle Windows os.path.join(os.path.dirname(sys.executable), "DLLs/libcrypto-1_1-x64.dll"), os.path.join(os.path.dirname(sys.executable), "DLLs/libcrypto-1_1.dll") ] elif sys.platform == "cygwin": lib_paths = ["/bin/cygcrypto-1.0.0.dll"] else: lib_paths = [ "../runtime/lib/libcrypto.so.1.1", # ZeroBundle Linux "../../Frameworks/libcrypto.1.1.dylib", # ZeroBundle macOS "/opt/lib/libcrypto.so.1.0.0", # For optware and entware "/usr/local/ssl/lib/libcrypto.so" ] for lib_path in lib_paths: if os.path.isfile(lib_path): return lib_path if "ANDROID_APP_PATH" in os.environ: try: lib_dir = os.environ["ANDROID_APP_PATH"] + "/../../lib" return [lib for lib in os.listdir(lib_dir) if "crypto" in lib][0] except Exception as err: logging.debug("OpenSSL lib not found in: %s (%s)" % (lib_dir, err)) if "LD_LIBRARY_PATH" in os.environ: lib_dir_paths = os.environ["LD_LIBRARY_PATH"].split(":") for path in lib_dir_paths: try: return [lib for lib in os.listdir(path) if "libcrypto.so" in lib][0] except Exception as err: logging.debug("OpenSSL lib not found in: %s (%s)" % (path, err)) lib_path = ( find_library_original('ssl.so') or find_library_original('ssl') or find_library_original('crypto') or find_library_original('libcrypto') or 'libeay32' ) return lib_path def patchCtypesOpensslFindLibrary(): def findLibraryPatched(name): if name in ("ssl", "crypto", "libeay32"): lib_path = getOpensslPath() return lib_path else: return find_library_original(name) ctypes.util.find_library = findLibraryPatched patchCtypesOpensslFindLibrary() ================================================ FILE: src/util/Platform.py ================================================ import sys import logging def setMaxfilesopened(limit): try: if sys.platform == "win32": import ctypes dll = None last_err = None for dll_name in ["msvcr100", "msvcr110", "msvcr120"]: try: dll = getattr(ctypes.cdll, dll_name) break except OSError as err: last_err = err if not dll: raise last_err maxstdio = dll._getmaxstdio() if maxstdio < limit: logging.debug("%s: Current maxstdio: %s, changing to %s..." % (dll, maxstdio, limit)) dll._setmaxstdio(limit) return True else: import resource soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) if soft < limit: logging.debug("Current RLIMIT_NOFILE: %s (max: %s), changing to %s..." % (soft, hard, limit)) resource.setrlimit(resource.RLIMIT_NOFILE, (limit, hard)) return True except Exception as err: logging.error("Failed to modify max files open limit: %s" % err) return False ================================================ FILE: src/util/Pooled.py ================================================ import gevent.pool class Pooled(object): def __init__(self, size=100): self.pool = gevent.pool.Pool(size) self.pooler_running = False self.queue = [] self.func = None def waiter(self, evt, args, kwargs): res = self.func(*args, **kwargs) if type(res) == gevent.event.AsyncResult: evt.set(res.get()) else: evt.set(res) def pooler(self): while self.queue: evt, args, kwargs = self.queue.pop(0) self.pool.spawn(self.waiter, evt, args, kwargs) self.pooler_running = False def __call__(self, func): def wrapper(*args, **kwargs): evt = gevent.event.AsyncResult() self.queue.append((evt, args, kwargs)) if not self.pooler_running: self.pooler_running = True gevent.spawn(self.pooler) return evt wrapper.__name__ = func.__name__ self.func = func return wrapper if __name__ == "__main__": import gevent import gevent.pool import gevent.queue import gevent.event import gevent.monkey import time gevent.monkey.patch_all() def addTask(inner_path): evt = gevent.event.AsyncResult() gevent.spawn_later(1, lambda: evt.set(True)) return evt def needFile(inner_path): return addTask(inner_path) @Pooled(10) def pooledNeedFile(inner_path): return needFile(inner_path) threads = [] for i in range(100): threads.append(pooledNeedFile(i)) s = time.time() gevent.joinall(threads) # Should take 10 second print(time.time() - s) ================================================ FILE: src/util/QueryJson.py ================================================ import json import re import os def queryFile(file_path, filter_path, filter_key=None, filter_val=None): back = [] data = json.load(open(file_path)) if filter_path == ['']: return [data] for key in filter_path: # Get to the point data = data.get(key) if not data: return if type(data) == list: for row in data: if filter_val: # Filter by value if row[filter_key] == filter_val: back.append(row) else: back.append(row) else: back.append({"value": data}) return back # Find in json files # Return: [{u'body': u'Hello Topic 1!!', 'inner_path': '1KRxE1...beEp6', u'added': 1422740732, u'message_id': 1},...] def query(path_pattern, filter): if "=" in filter: # Filter by value filter_path, filter_val = filter.split("=") filter_path = filter_path.split(".") filter_key = filter_path.pop() # Last element is the key filter_val = int(filter_val) else: # No filter filter_path = filter filter_path = filter_path.split(".") filter_key = None filter_val = None if "/*/" in path_pattern: # Wildcard search root_dir, file_pattern = path_pattern.replace("\\", "/").split("/*/") else: # No wildcard root_dir, file_pattern = re.match("(.*)/(.*?)$", path_pattern.replace("\\", "/")).groups() for root, dirs, files in os.walk(root_dir, topdown=False): root = root.replace("\\", "/") inner_path = root.replace(root_dir, "").strip("/") for file_name in files: if file_pattern != file_name: continue try: res = queryFile(root + "/" + file_name, filter_path, filter_key, filter_val) if not res: continue except Exception: # Json load error continue for row in res: row["inner_path"] = inner_path yield row if __name__ == "__main__": for row in list(query("../../data/12Hw8rTgzrNo4DSh2AkqwPRqDyTticwJyH/data/users/*/data.json", "")): print(row) ================================================ FILE: src/util/RateLimit.py ================================================ import time import gevent import logging log = logging.getLogger("RateLimit") called_db = {} # Holds events last call time queue_db = {} # Commands queued to run # Register event as called # Return: None def called(event, penalty=0): called_db[event] = time.time() + penalty # Check if calling event is allowed # Return: True if allowed False if not def isAllowed(event, allowed_again=10): last_called = called_db.get(event) if not last_called: # Its not called before return True elif time.time() - last_called >= allowed_again: del called_db[event] # Delete last call time to save memory return True else: return False def delayLeft(event, allowed_again=10): last_called = called_db.get(event) if not last_called: # Its not called before return 0 else: return allowed_again - (time.time() - last_called) def callQueue(event): func, args, kwargs, thread = queue_db[event] log.debug("Calling: %s" % event) called(event) del queue_db[event] return func(*args, **kwargs) # Rate limit and delay function call if necessary # If the function called again within the rate limit interval then previous queued call will be dropped # Return: Immediately gevent thread def callAsync(event, allowed_again=10, func=None, *args, **kwargs): if isAllowed(event, allowed_again): # Not called recently, call it now called(event) # print "Calling now" return gevent.spawn(func, *args, **kwargs) else: # Called recently, schedule it for later time_left = allowed_again - max(0, time.time() - called_db[event]) log.debug("Added to queue (%.2fs left): %s " % (time_left, event)) if not queue_db.get(event): # Function call not queued yet thread = gevent.spawn_later(time_left, lambda: callQueue(event)) # Call this function later queue_db[event] = (func, args, kwargs, thread) return thread else: # Function call already queued, just update the parameters thread = queue_db[event][3] queue_db[event] = (func, args, kwargs, thread) return thread # Rate limit and delay function call if needed # Return: Wait for execution/delay then return value def call(event, allowed_again=10, func=None, *args, **kwargs): if isAllowed(event): # Not called recently, call it now called(event) # print "Calling now", allowed_again return func(*args, **kwargs) else: # Called recently, schedule it for later time_left = max(0, allowed_again - (time.time() - called_db[event])) # print "Time left: %s" % time_left, args, kwargs log.debug("Calling sync (%.2fs left): %s" % (time_left, event)) called(event, time_left) time.sleep(time_left) back = func(*args, **kwargs) called(event) return back # Cleanup expired events every 3 minutes def rateLimitCleanup(): while 1: expired = time.time() - 60 * 2 # Cleanup if older than 2 minutes for event in list(called_db.keys()): if called_db[event] < expired: del called_db[event] time.sleep(60 * 3) # Every 3 minutes gevent.spawn(rateLimitCleanup) if __name__ == "__main__": from gevent import monkey monkey.patch_all() import random def publish(inner_path): print("Publishing %s..." % inner_path) return 1 def cb(thread): print("Value:", thread.value) print("Testing async spam requests rate limit to 1/sec...") for i in range(3000): thread = callAsync("publish content.json", 1, publish, "content.json %s" % i) time.sleep(float(random.randint(1, 20)) / 100000) print(thread.link(cb)) print("Done") time.sleep(2) print("Testing sync spam requests rate limit to 1/sec...") for i in range(5): call("publish data.json", 1, publish, "data.json %s" % i) time.sleep(float(random.randint(1, 100)) / 100) print("Done") print("Testing cleanup") thread = callAsync("publish content.json single", 1, publish, "content.json single") print("Needs to cleanup:", called_db, queue_db) print("Waiting 3min for cleanup process...") time.sleep(60 * 3) print("Cleaned up:", called_db, queue_db) ================================================ FILE: src/util/SafeRe.py ================================================ import re class UnsafePatternError(Exception): pass cached_patterns = {} def isSafePattern(pattern): if len(pattern) > 255: raise UnsafePatternError("Pattern too long: %s characters in %s" % (len(pattern), pattern)) unsafe_pattern_match = re.search(r"[^\.][\*\{\+]", pattern) # Always should be "." before "*{+" characters to avoid ReDoS if unsafe_pattern_match: raise UnsafePatternError("Potentially unsafe part of the pattern: %s in %s" % (unsafe_pattern_match.group(0), pattern)) repetitions = re.findall(r"\.[\*\{\+]", pattern) if len(repetitions) >= 10: raise UnsafePatternError("More than 10 repetitions of %s in %s" % (repetitions[0], pattern)) return True def match(pattern, *args, **kwargs): cached_pattern = cached_patterns.get(pattern) if cached_pattern: return cached_pattern.match(*args, **kwargs) else: if isSafePattern(pattern): cached_patterns[pattern] = re.compile(pattern) return cached_patterns[pattern].match(*args, **kwargs) ================================================ FILE: src/util/SocksProxy.py ================================================ import socket import socks from Config import config def create_connection(address, timeout=None, source_address=None): if address in config.ip_local: sock = socket.socket_noproxy(socket.AF_INET, socket.SOCK_STREAM) sock.connect(address) else: sock = socks.socksocket() sock.connect(address) return sock # Dns queries using the proxy def getaddrinfo(*args): return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))] def monkeyPatch(proxy_ip, proxy_port): socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, proxy_ip, int(proxy_port)) socket.socket_noproxy = socket.socket socket.socket = socks.socksocket socket.create_connection = create_connection socket.getaddrinfo = getaddrinfo ================================================ FILE: src/util/ThreadPool.py ================================================ import threading import time import queue import gevent import gevent.monkey import gevent.threadpool import gevent._threading class ThreadPool: def __init__(self, max_size, name=None): self.setMaxSize(max_size) if name: self.name = name else: self.name = "ThreadPool#%s" % id(self) def setMaxSize(self, max_size): self.max_size = max_size if max_size > 0: self.pool = gevent.threadpool.ThreadPool(max_size) else: self.pool = None def wrap(self, func): if self.pool is None: return func def wrapper(*args, **kwargs): if not isMainThread(): # Call directly if not in main thread return func(*args, **kwargs) res = self.apply(func, args, kwargs) return res return wrapper def spawn(self, *args, **kwargs): if not isMainThread() and not self.pool._semaphore.ready(): # Avoid semaphore error when spawning from other thread and the pool is full return main_loop.call(self.spawn, *args, **kwargs) res = self.pool.spawn(*args, **kwargs) return res def apply(self, func, args=(), kwargs={}): t = self.spawn(func, *args, **kwargs) if self.pool._apply_immediately(): return main_loop.call(t.get) else: return t.get() def kill(self): if self.pool is not None and self.pool.size > 0 and main_loop: main_loop.call(lambda: gevent.spawn(self.pool.kill).join(timeout=1)) del self.pool self.pool = None def __enter__(self): return self def __exit__(self, *args): self.kill() lock_pool = gevent.threadpool.ThreadPool(50) main_thread_id = threading.current_thread().ident def isMainThread(): return threading.current_thread().ident == main_thread_id class Lock: def __init__(self): self.lock = gevent._threading.Lock() self.locked = self.lock.locked self.release = self.lock.release self.time_lock = 0 def acquire(self, *args, **kwargs): self.time_lock = time.time() if self.locked() and isMainThread(): # Start in new thread to avoid blocking gevent loop return lock_pool.apply(self.lock.acquire, args, kwargs) else: return self.lock.acquire(*args, **kwargs) def __del__(self): while self.locked(): self.release() class Event: def __init__(self): self.get_lock = Lock() self.res = None self.get_lock.acquire(False) self.done = False def set(self, res): if self.done: raise Exception("Event already has value") self.res = res self.get_lock.release() self.done = True def get(self): if not self.done: self.get_lock.acquire(True) if self.get_lock.locked(): self.get_lock.release() back = self.res return back def __del__(self): self.res = None while self.get_lock.locked(): self.get_lock.release() # Execute function calls in main loop from other threads class MainLoopCaller(): def __init__(self): self.queue_call = queue.Queue() self.pool = gevent.threadpool.ThreadPool(1) self.num_direct = 0 self.running = True def caller(self, func, args, kwargs, event_done): try: res = func(*args, **kwargs) event_done.set((True, res)) except Exception as err: event_done.set((False, err)) def start(self): gevent.spawn(self.run) time.sleep(0.001) def run(self): while self.running: if self.queue_call.qsize() == 0: # Get queue in new thread to avoid gevent blocking func, args, kwargs, event_done = self.pool.apply(self.queue_call.get) else: func, args, kwargs, event_done = self.queue_call.get() gevent.spawn(self.caller, func, args, kwargs, event_done) del func, args, kwargs, event_done self.running = False def call(self, func, *args, **kwargs): if threading.current_thread().ident == main_thread_id: return func(*args, **kwargs) else: event_done = Event() self.queue_call.put((func, args, kwargs, event_done)) success, res = event_done.get() del event_done self.queue_call.task_done() if success: return res else: raise res def patchSleep(): # Fix memory leak by using real sleep in threads real_sleep = gevent.monkey.get_original("time", "sleep") def patched_sleep(seconds): if isMainThread(): gevent.sleep(seconds) else: real_sleep(seconds) time.sleep = patched_sleep main_loop = MainLoopCaller() main_loop.start() patchSleep() ================================================ FILE: src/util/UpnpPunch.py ================================================ import re import urllib.request import http.client import logging from urllib.parse import urlparse from xml.dom.minidom import parseString from xml.parsers.expat import ExpatError from gevent import socket import gevent # Relevant UPnP spec: # http://www.upnp.org/specs/gw/UPnP-gw-WANIPConnection-v1-Service.pdf # General TODOs: # Handle 0 or >1 IGDs logger = logging.getLogger("Upnp") class UpnpError(Exception): pass class IGDError(UpnpError): """ Signifies a problem with the IGD. """ pass REMOVE_WHITESPACE = re.compile(r'>\s*<') def perform_m_search(local_ip): """ Broadcast a UDP SSDP M-SEARCH packet and return response. """ search_target = "urn:schemas-upnp-org:device:InternetGatewayDevice:1" ssdp_request = ''.join( ['M-SEARCH * HTTP/1.1\r\n', 'HOST: 239.255.255.250:1900\r\n', 'MAN: "ssdp:discover"\r\n', 'MX: 2\r\n', 'ST: {0}\r\n'.format(search_target), '\r\n'] ).encode("utf8") sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind((local_ip, 0)) sock.sendto(ssdp_request, ('239.255.255.250', 1900)) if local_ip == "127.0.0.1": sock.settimeout(1) else: sock.settimeout(5) try: return sock.recv(2048).decode("utf8") except socket.error: raise UpnpError("No reply from IGD using {} as IP".format(local_ip)) finally: sock.close() def _retrieve_location_from_ssdp(response): """ Parse raw HTTP response to retrieve the UPnP location header and return a ParseResult object. """ parsed_headers = re.findall(r'(?P.*?): (?P.*?)\r\n', response) header_locations = [header[1] for header in parsed_headers if header[0].lower() == 'location'] if len(header_locations) < 1: raise IGDError('IGD response does not contain a "location" header.') return urlparse(header_locations[0]) def _retrieve_igd_profile(url): """ Retrieve the device's UPnP profile. """ try: return urllib.request.urlopen(url.geturl(), timeout=5).read().decode('utf-8') except socket.error: raise IGDError('IGD profile query timed out') def _get_first_child_data(node): """ Get the text value of the first child text node of a node. """ return node.childNodes[0].data def _parse_igd_profile(profile_xml): """ Traverse the profile xml DOM looking for either WANIPConnection or WANPPPConnection and return the 'controlURL' and the service xml schema. """ try: dom = parseString(profile_xml) except ExpatError as e: raise IGDError( 'Unable to parse IGD reply: {0} \n\n\n {1}'.format(profile_xml, e)) service_types = dom.getElementsByTagName('serviceType') for service in service_types: if _get_first_child_data(service).find('WANIPConnection') > 0 or \ _get_first_child_data(service).find('WANPPPConnection') > 0: try: control_url = _get_first_child_data( service.parentNode.getElementsByTagName('controlURL')[0]) upnp_schema = _get_first_child_data(service).split(':')[-2] return control_url, upnp_schema except IndexError: # Pass the error because any error here should raise the # that's specified outside the for loop. pass raise IGDError( 'Could not find a control url or UPNP schema in IGD response.') # add description def _get_local_ips(): def method1(): try: # get local ip using UDP and a broadcast address s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) # Not using because gevents getaddrinfo doesn't like that # using port 1 as per hobbldygoop's comment about port 0 not working on osx: # https://github.com/sirMackk/ZeroNet/commit/fdcd15cf8df0008a2070647d4d28ffedb503fba2#commitcomment-9863928 s.connect(('239.255.255.250', 1)) return [s.getsockname()[0]] except: pass def method2(): # Get ip by using UDP and a normal address (google dns ip) try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(('8.8.8.8', 0)) return [s.getsockname()[0]] except: pass def method3(): # Get ip by '' hostname . Not supported on all platforms. try: return socket.gethostbyname_ex('')[2] except: pass threads = [ gevent.spawn(method1), gevent.spawn(method2), gevent.spawn(method3) ] gevent.joinall(threads, timeout=5) local_ips = [] for thread in threads: if thread.value: local_ips += thread.value # Delete duplicates local_ips = list(set(local_ips)) # Probably we looking for an ip starting with 192 local_ips = sorted(local_ips, key=lambda a: a.startswith("192"), reverse=True) return local_ips def _create_open_message(local_ip, port, description="UPnPPunch", protocol="TCP", upnp_schema='WANIPConnection'): """ Build a SOAP AddPortMapping message. """ soap_message = """ {port} {protocol} {port} {host_ip} 1 {description} 0 """.format(port=port, protocol=protocol, host_ip=local_ip, description=description, upnp_schema=upnp_schema) return (REMOVE_WHITESPACE.sub('><', soap_message), 'AddPortMapping') def _create_close_message(local_ip, port, description=None, protocol='TCP', upnp_schema='WANIPConnection'): soap_message = """ {port} {protocol} """.format(port=port, protocol=protocol, upnp_schema=upnp_schema) return (REMOVE_WHITESPACE.sub('><', soap_message), 'DeletePortMapping') def _parse_for_errors(soap_response): logger.debug(soap_response.status) if soap_response.status >= 400: response_data = soap_response.read() logger.debug(response_data) try: err_dom = parseString(response_data) err_code = _get_first_child_data(err_dom.getElementsByTagName( 'errorCode')[0]) err_msg = _get_first_child_data( err_dom.getElementsByTagName('errorDescription')[0] ) except Exception as err: raise IGDError( 'Unable to parse SOAP error: {0}. Got: "{1}"'.format( err, response_data)) raise IGDError( 'SOAP request error: {0} - {1}'.format(err_code, err_msg) ) return soap_response def _send_soap_request(location, upnp_schema, control_path, soap_fn, soap_message): """ Send out SOAP request to UPnP device and return a response. """ headers = { 'SOAPAction': ( '"urn:schemas-upnp-org:service:{schema}:' '1#{fn_name}"'.format(schema=upnp_schema, fn_name=soap_fn) ), 'Content-Type': 'text/xml' } logger.debug("Sending UPnP request to {0}:{1}...".format( location.hostname, location.port)) conn = http.client.HTTPConnection(location.hostname, location.port) conn.request('POST', control_path, soap_message, headers) response = conn.getresponse() conn.close() return _parse_for_errors(response) def _collect_idg_data(ip_addr): idg_data = {} idg_response = perform_m_search(ip_addr) idg_data['location'] = _retrieve_location_from_ssdp(idg_response) idg_data['control_path'], idg_data['upnp_schema'] = _parse_igd_profile( _retrieve_igd_profile(idg_data['location'])) return idg_data def _send_requests(messages, location, upnp_schema, control_path): responses = [_send_soap_request(location, upnp_schema, control_path, message_tup[1], message_tup[0]) for message_tup in messages] if all(rsp.status == 200 for rsp in responses): return raise UpnpError('Sending requests using UPnP failed.') def _orchestrate_soap_request(ip, port, msg_fn, desc=None, protos=("TCP", "UDP")): logger.debug("Trying using local ip: %s" % ip) idg_data = _collect_idg_data(ip) soap_messages = [ msg_fn(ip, port, desc, proto, idg_data['upnp_schema']) for proto in protos ] _send_requests(soap_messages, **idg_data) def _communicate_with_igd(port=15441, desc="UpnpPunch", retries=3, fn=_create_open_message, protos=("TCP", "UDP")): """ Manage sending a message generated by 'fn'. """ local_ips = _get_local_ips() success = False def job(local_ip): for retry in range(retries): try: _orchestrate_soap_request(local_ip, port, fn, desc, protos) return True except Exception as e: logger.debug('Upnp request using "{0}" failed: {1}'.format(local_ip, e)) gevent.sleep(1) return False threads = [] for local_ip in local_ips: job_thread = gevent.spawn(job, local_ip) threads.append(job_thread) gevent.sleep(0.1) if any([thread.value for thread in threads]): success = True break # Wait another 10sec for competition or any positive result for _ in range(10): all_done = all([thread.value is not None for thread in threads]) any_succeed = any([thread.value for thread in threads]) if all_done or any_succeed: break gevent.sleep(1) if any([thread.value for thread in threads]): success = True if not success: raise UpnpError( 'Failed to communicate with igd using port {0} on local machine after {1} tries.'.format( port, retries)) return success def ask_to_open_port(port=15441, desc="UpnpPunch", retries=3, protos=("TCP", "UDP")): logger.debug("Trying to open port %d." % port) return _communicate_with_igd(port=port, desc=desc, retries=retries, fn=_create_open_message, protos=protos) def ask_to_close_port(port=15441, desc="UpnpPunch", retries=3, protos=("TCP", "UDP")): logger.debug("Trying to close port %d." % port) # retries=1 because multiple successes cause 500 response and failure return _communicate_with_igd(port=port, desc=desc, retries=retries, fn=_create_close_message, protos=protos) if __name__ == "__main__": from gevent import monkey monkey.patch_all() logging.basicConfig(level=logging.DEBUG) import time s = time.time() print("Opening port...") print("Success:", ask_to_open_port(15443, "ZeroNet", protos=["TCP"])) print("Done in", time.time() - s) print("Closing port...") print("Success:", ask_to_close_port(15443, "ZeroNet", protos=["TCP"])) print("Done in", time.time() - s) ================================================ FILE: src/util/__init__.py ================================================ from .Cached import Cached from .Event import Event from .Noparallel import Noparallel from .Pooled import Pooled ================================================ FILE: src/util/helper.py ================================================ import os import stat import socket import struct import re import collections import time import logging import base64 import json import gevent from Config import config def atomicWrite(dest, content, mode="wb"): try: with open(dest + "-tmpnew", mode) as f: f.write(content) f.flush() os.fsync(f.fileno()) if os.path.isfile(dest + "-tmpold"): # Previous incomplete write os.rename(dest + "-tmpold", dest + "-tmpold-%s" % time.time()) if os.path.isfile(dest): # Rename old file to -tmpold os.rename(dest, dest + "-tmpold") os.rename(dest + "-tmpnew", dest) if os.path.isfile(dest + "-tmpold"): os.unlink(dest + "-tmpold") # Remove old file return True except Exception as err: from Debug import Debug logging.error( "File %s write failed: %s, (%s) reverting..." % (dest, Debug.formatException(err), Debug.formatStack()) ) if os.path.isfile(dest + "-tmpold") and not os.path.isfile(dest): os.rename(dest + "-tmpold", dest) return False def jsonDumps(data): content = json.dumps(data, indent=1, sort_keys=True) # Make it a little more compact by removing unnecessary white space def compact_dict(match): if "\n" in match.group(0): return match.group(0).replace(match.group(1), match.group(1).strip()) else: return match.group(0) content = re.sub(r"\{(\n[^,\[\{]{10,100000}?)\}[, ]{0,2}\n", compact_dict, content, flags=re.DOTALL) def compact_list(match): if "\n" in match.group(0): stripped_lines = re.sub("\n[ ]*", "", match.group(1)) return match.group(0).replace(match.group(1), stripped_lines) else: return match.group(0) content = re.sub(r"\[([^\[\{]{2,100000}?)\][, ]{0,2}\n", compact_list, content, flags=re.DOTALL) # Remove end of line whitespace content = re.sub(r"(?m)[ ]+$", "", content) return content def openLocked(path, mode="wb"): try: if os.name == "posix": import fcntl f = open(path, mode) fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB) elif os.name == "nt": import msvcrt f = open(path, mode) msvcrt.locking(f.fileno(), msvcrt.LK_NBLCK, 1) else: f = open(path, mode) except (IOError, PermissionError, BlockingIOError) as err: raise BlockingIOError("Unable to lock file: %s" % err) return f def getFreeSpace(): free_space = -1 if "statvfs" in dir(os): # Unix statvfs = os.statvfs(config.data_dir.encode("utf8")) free_space = statvfs.f_frsize * statvfs.f_bavail else: # Windows try: import ctypes free_space_pointer = ctypes.c_ulonglong(0) ctypes.windll.kernel32.GetDiskFreeSpaceExW( ctypes.c_wchar_p(config.data_dir), None, None, ctypes.pointer(free_space_pointer) ) free_space = free_space_pointer.value except Exception as err: logging.error("GetFreeSpace error: %s" % err) return free_space def sqlquote(value): if type(value) is int: return str(value) else: return "'%s'" % value.replace("'", "''") def shellquote(*args): if len(args) == 1: return '"%s"' % args[0].replace('"', "") else: return tuple(['"%s"' % arg.replace('"', "") for arg in args]) def packPeers(peers): packed_peers = {"ipv4": [], "ipv6": [], "onion": []} for peer in peers: try: ip_type = getIpType(peer.ip) if ip_type in packed_peers: packed_peers[ip_type].append(peer.packMyAddress()) except Exception: logging.debug("Error packing peer address: %s" % peer) return packed_peers # ip, port to packed 6byte or 18byte format def packAddress(ip, port): if ":" in ip: return socket.inet_pton(socket.AF_INET6, ip) + struct.pack("H", port) else: return socket.inet_aton(ip) + struct.pack("H", port) # From 6byte or 18byte format to ip, port def unpackAddress(packed): if len(packed) == 18: return socket.inet_ntop(socket.AF_INET6, packed[0:16]), struct.unpack_from("H", packed, 16)[0] else: if len(packed) != 6: raise Exception("Invalid length ip4 packed address: %s" % len(packed)) return socket.inet_ntoa(packed[0:4]), struct.unpack_from("H", packed, 4)[0] # onion, port to packed 12byte format def packOnionAddress(onion, port): onion = onion.replace(".onion", "") return base64.b32decode(onion.upper()) + struct.pack("H", port) # From 12byte format to ip, port def unpackOnionAddress(packed): return base64.b32encode(packed[0:-2]).lower().decode() + ".onion", struct.unpack("H", packed[-2:])[0] # Get dir from file # Return: data/site/content.json -> data/site/ def getDirname(path): if "/" in path: return path[:path.rfind("/") + 1].lstrip("/") else: return "" # Get dir from file # Return: data/site/content.json -> content.json def getFilename(path): return path[path.rfind("/") + 1:] def getFilesize(path): try: s = os.stat(path) except Exception: return None if stat.S_ISREG(s.st_mode): # Test if it's file return s.st_size else: return None # Convert hash to hashid for hashfield def toHashId(hash): return int(hash[0:4], 16) # Merge dict values def mergeDicts(dicts): back = collections.defaultdict(set) for d in dicts: for key, val in d.items(): back[key].update(val) return dict(back) # Request https url using gevent SSL error workaround def httpRequest(url, as_file=False): if url.startswith("http://"): import urllib.request response = urllib.request.urlopen(url) else: # Hack to avoid Python gevent ssl errors import socket import http.client import ssl host, request = re.match("https://(.*?)(/.*?)$", url).groups() conn = http.client.HTTPSConnection(host) sock = socket.create_connection((conn.host, conn.port), conn.timeout, conn.source_address) conn.sock = ssl.wrap_socket(sock, conn.key_file, conn.cert_file) conn.request("GET", request) response = conn.getresponse() if response.status in [301, 302, 303, 307, 308]: logging.info("Redirect to: %s" % response.getheader('Location')) response = httpRequest(response.getheader('Location')) if as_file: import io data = io.BytesIO() while True: buff = response.read(1024 * 16) if not buff: break data.write(buff) return data else: return response def timerCaller(secs, func, *args, **kwargs): gevent.spawn_later(secs, timerCaller, secs, func, *args, **kwargs) func(*args, **kwargs) def timer(secs, func, *args, **kwargs): return gevent.spawn_later(secs, timerCaller, secs, func, *args, **kwargs) def create_connection(address, timeout=None, source_address=None): if address in config.ip_local: sock = socket.create_connection_original(address, timeout, source_address) else: sock = socket.create_connection_original(address, timeout, socket.bind_addr) return sock def socketBindMonkeyPatch(bind_ip, bind_port): import socket logging.info("Monkey patching socket to bind to: %s:%s" % (bind_ip, bind_port)) socket.bind_addr = (bind_ip, int(bind_port)) socket.create_connection_original = socket.create_connection socket.create_connection = create_connection def limitedGzipFile(*args, **kwargs): import gzip class LimitedGzipFile(gzip.GzipFile): def read(self, size=-1): return super(LimitedGzipFile, self).read(1024 * 1024 * 25) return LimitedGzipFile(*args, **kwargs) def avg(items): if len(items) > 0: return sum(items) / len(items) else: return 0 def isIp(ip): if ":" in ip: # IPv6 try: socket.inet_pton(socket.AF_INET6, ip) return True except Exception: return False else: # IPv4 try: socket.inet_aton(ip) return True except Exception: return False local_ip_pattern = re.compile(r"^127\.|192\.168\.|10\.|172\.1[6-9]\.|172\.2[0-9]\.|172\.3[0-1]\.|169\.254\.|::1$|fe80") def isPrivateIp(ip): return local_ip_pattern.match(ip) def getIpType(ip): if ip.endswith(".onion"): return "onion" elif ":" in ip: return "ipv6" elif re.match(r"[0-9\.]+$", ip): return "ipv4" else: return "unknown" def createSocket(ip, sock_type=socket.SOCK_STREAM): ip_type = getIpType(ip) if ip_type == "ipv6": return socket.socket(socket.AF_INET6, sock_type) else: return socket.socket(socket.AF_INET, sock_type) def getInterfaceIps(ip_type="ipv4"): res = [] if ip_type == "ipv6": test_ips = ["ff0e::c", "2606:4700:4700::1111"] else: test_ips = ['239.255.255.250', "8.8.8.8"] for test_ip in test_ips: try: s = createSocket(test_ip, sock_type=socket.SOCK_DGRAM) s.connect((test_ip, 1)) res.append(s.getsockname()[0]) except Exception: pass try: res += [ip[4][0] for ip in socket.getaddrinfo(socket.gethostname(), 1)] except Exception: pass res = [re.sub("%.*", "", ip) for ip in res if getIpType(ip) == ip_type and isIp(ip)] return list(set(res)) def cmp(a, b): return (a > b) - (a < b) def encodeResponse(func): # Encode returned data from utf8 to bytes def wrapper(*args, **kwargs): back = func(*args, **kwargs) if "__next__" in dir(back): for part in back: if type(part) == bytes: yield part else: yield part.encode() else: if type(back) == bytes: yield back else: yield back.encode() return wrapper ================================================ FILE: start.py ================================================ #!/usr/bin/env python3 # Included modules import sys # ZeroNet Modules import zeronet def main(): if "--open_browser" not in sys.argv: sys.argv = [sys.argv[0]] + ["--open_browser", "default_browser"] + sys.argv[1:] zeronet.start() if __name__ == '__main__': main() ================================================ FILE: tools/coffee/README.md ================================================ # CoffeeScript compiler for Windows A simple command-line utilty for Windows that will compile `*.coffee` files to JavaScript `*.js` files using [CoffeeScript](http://jashkenas.github.com/coffee-script/) and the venerable Windows Script Host, ubiquitous on Windows since the 90s. ## Usage To use it, invoke `coffee.cmd` like so: coffee input.coffee output.js If an output is not specified, it is written to `stdout`. In neither an input or output are specified then data is assumed to be on `stdin`. For example: type input.coffee | coffee > output.js Errors are written to `stderr`. In the `test` directory there's a version of the standard CoffeeScript tests which can be kicked off using `test.cmd`. The test just attempts to compile the *.coffee files but doesn't execute them. To upgrade to the latest CoffeeScript simply replace `coffee-script.js` from the upstream https://github.com/jashkenas/coffee-script/blob/master/extras/coffee-script.js (the tests will likely need updating as well, if you want to run them). ================================================ FILE: tools/coffee/coffee-script.js ================================================ /** * CoffeeScript Compiler v1.12.6 * http://coffeescript.org * * Copyright 2011, Jeremy Ashkenas * Released under the MIT License */ var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.checkStringArgs=function(u,xa,va){if(null==u)throw new TypeError("The 'this' value for String.prototype."+va+" must not be null or undefined");if(xa instanceof RegExp)throw new TypeError("First argument to String.prototype."+va+" must not be a regular expression");return u+""}; $jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(u,xa,va){if(va.get||va.set)throw new TypeError("ES3 does not support getters and setters.");u!=Array.prototype&&u!=Object.prototype&&(u[xa]=va.value)};$jscomp.getGlobal=function(u){return"undefined"!=typeof window&&window===u?u:"undefined"!=typeof global&&null!=global?global:u};$jscomp.global=$jscomp.getGlobal(this); $jscomp.polyfill=function(u,xa,va,f){if(xa){va=$jscomp.global;u=u.split(".");for(f=0;fu||1342177279>>=1)va+=va;return f}},"es6-impl","es3");$jscomp.findInternal=function(u,xa,va){u instanceof String&&(u=String(u));for(var f=u.length,qa=0;qa>>=1,a+=a;return g};f.compact=function(a){var g,b;var n=[];var y=0;for(b=a.length;yc)return m.call(this,L,a-1);(w=L[0],0<=y.call(g,w))?c+=1:(l=L[0],0<=y.call(h,l))&&--c;a+=1}return a-1};l.prototype.removeLeadingNewlines=function(){var a,b;var m=this.tokens;var k=a=0;for(b=m.length;ag;f=0<=g?++b:--b){for(;"HERECOMMENT"===this.tag(l+f+c);)c+=2;if(null!=h[f]&&("string"===typeof h[f]&&(h[f]=[h[f]]),k=this.tag(l+f+c),0>y.call(h[f],k)))return-1}return l+f+c-1};l.prototype.looksObjectish=function(a){if(-1y.call(b,w))&&((f=this.tag(a),0>y.call(g,f))||this.tokens[a].generated)&&(n=this.tag(a),0>y.call(R,n)));)(k=this.tag(a),0<=y.call(h,k))&&c.push(this.tag(a)),(l=this.tag(a),0<=y.call(g, l))&&c.length&&c.pop(),--a;return x=this.tag(a),0<=y.call(b,x)};l.prototype.addImplicitBracesAndParens=function(){var a=[];var l=null;return this.scanTokens(function(c,k,f){var m,w,n,r;var G=c[0];var K=(m=0y.call(h,a):return l[1];case "@"!==this.tag(k-2):return k-2;default:return k-1}}.call(this);"HERECOMMENT"===this.tag(q-2);)q-=2;this.insideForDeclaration="FOR"===u;m=0===q||(r=this.tag(q-1),0<=y.call(R,r))||f[q-1].newLine;if(B()&&(T=B(),r=T[0],v=T[1],("{"===r||"INDENT"===r&&"{"===this.tag(v-1))&&(m||","===this.tag(q-1)||"{"===this.tag(q-1))))return A(1);M(q,!!m);return A(2)}if(0<=y.call(R,G))for(M=a.length-1;0<=M;M+=-1)r=a[M],E(r)&&(r[2].sameLine= !1);M="OUTDENT"===K||m.newLine;if(0<=y.call(x,G)||0<=y.call(z,G)&&M)for(;O();)if(M=B(),r=M[0],v=M[1],m=M[2],M=m.sameLine,m=m.startsLine,C()&&","!==K)S();else if(T()&&!this.insideForDeclaration&&M&&"TERMINATOR"!==G&&":"!==K)q();else if(!T()||"TERMINATOR"!==G||","===K||m&&this.looksObjectish(k+1))break;else{if("HERECOMMENT"===u)return A(1);q()}if(!(","!==G||this.looksObjectish(k+1)||!T()||this.insideForDeclaration||"TERMINATOR"===u&&this.looksObjectish(k+2)))for(u="OUTDENT"===u?1:0;T();)q(k+u);return A(1)})}; l.prototype.addLocationDataToGeneratedTokens=function(){return this.scanTokens(function(a,b,g){var c,l;if(a[2]||!a.generated&&!a.explicit)return 1;if("{"===a[0]&&(c=null!=(l=g[b+1])?l[2]:void 0)){var m=c.first_line;c=c.first_column}else(c=null!=(m=g[b-1])?m[2]:void 0)?(m=c.last_line,c=c.last_column):m=c=0;a[2]={first_line:m,first_column:c,last_line:m,last_column:c};return 1})};l.prototype.fixOutdentLocationData=function(){return this.scanTokens(function(a,b,g){if(!("OUTDENT"===a[0]||a.generated&& "CALL_END"===a[0]||a.generated&&"}"===a[0]))return 1;b=g[b-1][2];a[2]={first_line:b.last_line,first_column:b.last_column,last_line:b.last_line,last_column:b.last_column};return 1})};l.prototype.normalizeLines=function(){var b,g;var l=b=g=null;var k=function(a,b){var c,g,k,f;return";"!==a[1]&&(c=a[0],0<=y.call(O,c))&&!("TERMINATOR"===a[0]&&(g=this.tag(b+1),0<=y.call(H,g)))&&!("ELSE"===a[0]&&"THEN"!==l)&&!!("CATCH"!==(k=a[0])&&"FINALLY"!==k||"-\x3e"!==l&&"\x3d\x3e"!==l)||(f=a[0],0<=y.call(z,f))&&(this.tokens[b- 1].newLine||"OUTDENT"===this.tokens[b-1][0])};var f=function(a,b){return this.tokens.splice(","===this.tag(b-1)?b-1:b,0,g)};return this.scanTokens(function(c,m,h){var w,n,r;c=c[0];if("TERMINATOR"===c){if("ELSE"===this.tag(m+1)&&"OUTDENT"!==this.tag(m-1))return h.splice.apply(h,[m,1].concat(a.call(this.indentation()))),1;if(w=this.tag(m+1),0<=y.call(H,w))return h.splice(m,1),0}if("CATCH"===c)for(w=n=1;2>=n;w=++n)if("OUTDENT"===(r=this.tag(m+w))||"TERMINATOR"===r||"FINALLY"===r)return h.splice.apply(h, [m+w,0].concat(a.call(this.indentation()))),2+w;0<=y.call(J,c)&&"INDENT"!==this.tag(m+1)&&("ELSE"!==c||"IF"!==this.tag(m+1))&&(l=c,r=this.indentation(h[m]),b=r[0],g=r[1],"THEN"===l&&(b.fromThen=!0),h.splice(m+1,0,b),this.detectEnd(m+2,k,f),"THEN"===c&&h.splice(m,1));return 1})};l.prototype.tagPostfixConditionals=function(){var a=null;var b=function(a,b){a=a[0];b=this.tokens[b-1][0];return"TERMINATOR"===a||"INDENT"===a&&0>y.call(J,b)};var g=function(b,c){if("INDENT"!==b[0]||b.generated&&!b.fromThen)return a[0]= "POST_"+a[0]};return this.scanTokens(function(c,l){if("IF"!==c[0])return 1;a=c;this.detectEnd(l+1,b,g);return 1})};l.prototype.indentation=function(a){var b=["INDENT",2];var c=["OUTDENT",2];a?(b.generated=c.generated=!0,b.origin=c.origin=a):b.explicit=c.explicit=!0;return[b,c]};l.prototype.generate=b;l.prototype.tag=function(a){var b;return null!=(b=this.tokens[a])?b[0]:void 0};return l}();var ya=[["(",")"],["[","]"],["{","}"],["INDENT","OUTDENT"],["CALL_START","CALL_END"],["PARAM_START","PARAM_END"], ["INDEX_START","INDEX_END"],["STRING_START","STRING_END"],["REGEX_START","REGEX_END"]];f.INVERSES=u={};var g=[];var h=[];var r=0;for(q=ya.length;rthis.indent){if(c||"RETURN"===this.tag())return this.indebt=b-this.indent,this.suppressNewlines(),a.length;if(!this.tokens.length)return this.baseIndent= this.indent=b,a.length;c=b-this.indent+this.outdebt;this.token("INDENT",c,a.length-b,b);this.indents.push(c);this.ends.push({tag:"OUTDENT"});this.outdebt=this.indebt=0;this.indent=b}else bl&&(m=this.token("+","+"),m[2]={first_line:w[2].first_line,first_column:w[2].first_column,last_line:w[2].first_line,last_column:w[2].first_column});(f=this.tokens).push.apply(f,r)}if(k)return a=a[a.length-1],k.origin=["STRING",null,{first_line:k[2].first_line,first_column:k[2].first_column,last_line:a[2].last_line,last_column:a[2].last_column}],k=this.token("STRING_END",")"),k[2]={first_line:a[2].last_line,first_column:a[2].last_column, last_line:a[2].last_line,last_column:a[2].last_column}};a.prototype.pair=function(a){var b=this.ends;b=b[b.length-1];return a!==(b=null!=b?b.tag:void 0)?("OUTDENT"!==b&&this.error("unmatched "+a),b=this.indents,b=b[b.length-1],this.outdentToken(b,!0),this.pair(a)):this.ends.pop()};a.prototype.getLineAndColumnFromChunk=function(a){if(0===a)return[this.chunkLine,this.chunkColumn];var b=a>=this.chunk.length?this.chunk:this.chunk.slice(0,+(a-1)+1||9E9);a=g(b,"\n");var c=this.chunkColumn;0a)return b(a);var c=Math.floor((a-65536)/1024)+55296;a=(a-65536)%1024+56320;return""+b(c)+b(a)};a.prototype.replaceUnicodeCodePointEscapes= function(a,b){return a.replace(sa,function(a){return function(c,g,k,h){if(g)return g;c=parseInt(k,16);1114111q.call(y.call(I).concat(y.call(F)),a):return"keyword '"+b+"' can't be assigned";case 0>q.call(O, a):return"'"+b+"' can't be assigned";case 0>q.call(J,a):return"reserved word '"+b+"' can't be assigned";default:return!1}};f.isUnassignable=B;var H=function(a){var b;return"IDENTIFIER"===a[0]?("from"===a[1]&&(a[1][0]="IDENTIFIER",!0),!0):"FOR"===a[0]?!1:"{"===(b=a[1])||"["===b||","===b||":"===b?!1:!0};var I="true false null this new delete typeof in instanceof return throw break continue debugger yield if else switch for while do try catch finally class extends super import export default".split(" "); var F="undefined Infinity NaN then unless until loop of by when".split(" ");var Q={and:"\x26\x26",or:"||",is:"\x3d\x3d",isnt:"!\x3d",not:"!",yes:"true",no:"false",on:"true",off:"false"};var x=function(){var a=[];for(qa in Q)a.push(qa);return a}();F=F.concat(x);var J="case function var void with const let enum native implements interface package private protected public static".split(" ");var O=["arguments","eval"];f.JS_FORBIDDEN=I.concat(J).concat(O);var R=65279;var z=/^(?!\d)((?:(?!\s)[$\w\x7f-\uffff])+)([^\n\S]*:(?!:))?/; var l=/^0b[01]+|^0o[0-7]+|^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i;var c=/^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>*\/%])\2=?|\?(\.|::)|\.{2,3})/;var w=/^[^\n\S]+/;var m=/^###([^#][\s\S]*?)(?:###[^\n\S]*|###$)|^(?:\s*#(?!##[^#]).*)+/;var k=/^[-=]>/;var K=/^(?:\n[^\n\S]*)+/;var P=/^`(?!``)((?:[^`\\]|\\[\s\S])*)`/;var L=/^```((?:[^`\\]|\\[\s\S]|`(?!``))*)```/;var V=/^(?:'''|"""|'|")/;var X=/^(?:[^\\']|\\[\s\S])*/;var G=/^(?:[^\\"#]|\\[\s\S]|\#(?!\{))*/;var aa=/^(?:[^\\']|\\[\s\S]|'(?!''))*/; var U=/^(?:[^\\"#]|\\[\s\S]|"(?!"")|\#(?!\{))*/;var W=/((?:\\\\)+)|\\[^\S\n]*\n\s*/g;var D=/\s*\n\s*/g;var A=/\n+([^\n\S]*)(?=\S)/g;var fc=/^\/(?!\/)((?:[^[\/\n\\]|\\[^\n]|\[(?:\\[^\n]|[^\]\n\\])*\])*)(\/)?/;var E=/^\w*/;var ba=/^(?!.*(.).*\1)[imguy]*$/;var ca=/^(?:[^\\\/#]|\\[\s\S]|\/(?!\/\/)|\#(?!\{))*/;var C=/((?:\\\\)+)|\\(\s)|\s+(?:#.*)?/g;var T=/^(\/|\/{3}\s*)(\*)/;var v=/^\/=?\s/;var Y=/\*\//;var S=/^\s*(?:,|\??\.(?![.\d])|::)/;var M=/((?:^|[^\\])(?:\\\\)*)\\(?:(0[0-7]|[1-7])|(x(?![\da-fA-F]{2}).{0,2})|(u\{(?![\da-fA-F]{1,}\})[^}]*\}?)|(u(?!\{|[\da-fA-F]{4}).{0,4}))/; var va=/((?:^|[^\\])(?:\\\\)*)\\(?:(0[0-7])|(x(?![\da-fA-F]{2}).{0,2})|(u\{(?![\da-fA-F]{1,}\})[^}]*\}?)|(u(?!\{|[\da-fA-F]{4}).{0,4}))/;var sa=/(\\\\)|\\u\{([\da-fA-F]+)\}/g;var za=/^[^\n\S]*\n/;var ma=/\n[^\n\S]*$/;var Z=/\s+$/;var fa="-\x3d +\x3d /\x3d *\x3d %\x3d ||\x3d \x26\x26\x3d ?\x3d \x3c\x3c\x3d \x3e\x3e\x3d \x3e\x3e\x3e\x3d \x26\x3d ^\x3d |\x3d **\x3d //\x3d %%\x3d".split(" ");var ia=["NEW","TYPEOF","DELETE","DO"];var ga=["!","~"];var ja=["\x3c\x3c","\x3e\x3e","\x3e\x3e\x3e"];var la="\x3d\x3d !\x3d \x3c \x3e \x3c\x3d \x3e\x3d".split(" "); var oa=["*","/","%","//","%%"];var pa=["IN","OF","INSTANCEOF"];var ha="IDENTIFIER PROPERTY ) ] ? @ THIS SUPER".split(" ");var ka=ha.concat("NUMBER INFINITY NAN STRING STRING_END REGEX REGEX_END BOOL NULL UNDEFINED } ::".split(" "));var na=ka.concat(["++","--"]);var ra=["INDENT","OUTDENT","TERMINATOR"];var da=[")","}","]"]}).call(this);return f}();u["./parser"]=function(){var f={},qa={exports:f},q=function(){function f(){this.yy={}}var a=function(a,p,t,d){t=t||{};for(d=a.length;d--;t[a[d]]=p);return t}, b=[1,22],u=[1,25],g=[1,83],h=[1,79],r=[1,84],n=[1,85],B=[1,81],H=[1,82],I=[1,56],F=[1,58],Q=[1,59],x=[1,60],J=[1,61],O=[1,62],R=[1,49],z=[1,50],l=[1,32],c=[1,68],w=[1,69],m=[1,78],k=[1,47],K=[1,51],P=[1,52],L=[1,67],V=[1,65],X=[1,66],G=[1,64],aa=[1,42],U=[1,48],W=[1,63],D=[1,73],A=[1,74],q=[1,75],E=[1,76],ba=[1,46],ca=[1,72],C=[1,34],T=[1,35],v=[1,36],Y=[1,37],S=[1,38],M=[1,39],qa=[1,86],sa=[1,6,32,42,131],za=[1,101],ma=[1,89],Z=[1,88],fa=[1,87],ia=[1,90],ga=[1,91],ja=[1,92],la=[1,93],oa=[1,94],pa= [1,95],ha=[1,96],ka=[1,97],na=[1,98],ra=[1,99],da=[1,100],va=[1,104],N=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],xa=[2,166],ta=[1,110],Na=[1,111],Fa=[1,112],Ga=[1,113],Ca=[1,115],Pa=[1,116],Ia=[1,109],Ea=[1,6,32,42,131,133,135,139,156],Va=[2,27],ea=[1,123],Ya=[1,121],Ba=[1,6,31,32,40,41,42,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172, 173,174],Ha=[2,94],t=[1,6,31,32,42,46,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],p=[2,73],d=[1,128],wa=[1,133],e=[1,134],Da=[1,136],Ta=[1,6,31,32,40,41,42,55,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],ua=[2,91],Eb=[1,6,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168, 169,170,171,172,173,174],Za=[2,63],Fb=[1,166],$a=[1,178],Ua=[1,180],Gb=[1,175],Oa=[1,182],sb=[1,184],La=[1,6,31,32,40,41,42,55,65,70,73,82,83,84,85,87,89,90,94,96,113,114,115,120,122,131,133,134,135,139,140,156,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175],Hb=[2,110],Ib=[1,6,31,32,40,41,42,58,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],Jb=[1,6,31,32,40,41,42,46,58,65,70,73,82,83,84, 85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],Kb=[40,41,114],Lb=[1,241],tb=[1,240],Ma=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156],Ja=[2,71],Mb=[1,250],Sa=[6,31,32,65,70],fb=[6,31,32,55,65,70,73],ab=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,159,160,164,166,167,168,169,170,171,172,173,174],Nb=[40,41,82,83,84,85,87,90,113,114],gb=[1,269],bb=[2,62],hb=[1,279],Wa=[1,281],ub=[1, 286],cb=[1,288],Ob=[2,187],vb=[1,6,31,32,40,41,42,55,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,146,147,148,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],ib=[1,297],Qa=[6,31,32,70,115,120],Pb=[1,6,31,32,40,41,42,55,58,65,70,73,82,83,84,85,87,89,90,94,96,113,114,115,120,122,131,133,134,135,139,140,146,147,148,156,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175],Qb=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,140,156],Xa=[1,6,31,32, 42,65,70,73,89,94,115,120,122,131,134,140,156],jb=[146,147,148],kb=[70,146,147,148],lb=[6,31,94],Rb=[1,311],Aa=[6,31,32,70,94],Sb=[6,31,32,58,70,94],wb=[6,31,32,55,58,70,94],Tb=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,159,160,166,167,168,169,170,171,172,173,174],Ub=[12,28,34,38,40,41,44,45,48,49,50,51,52,53,61,62,63,67,68,89,92,95,97,105,112,117,118,119,125,129,130,133,135,137,139,149,155,157,158,159,160,161,162],Vb=[2,176],Ra=[6,31,32],db=[2,72],Wb=[1,323],Xb=[1,324], Yb=[1,6,31,32,42,65,70,73,89,94,115,120,122,127,128,131,133,134,135,139,140,151,153,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],mb=[32,151,153],Zb=[1,6,32,42,65,70,73,89,94,115,120,122,131,134,140,156],nb=[1,350],xb=[1,356],yb=[1,6,32,42,131,156],eb=[2,86],ob=[1,367],pb=[1,368],$b=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,151,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],zb=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,135,139,140,156],ac= [1,381],bc=[1,382],Ab=[6,31,32,94],cc=[6,31,32,70],Bb=[1,6,31,32,42,65,70,73,89,94,115,120,122,127,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],dc=[31,70],qb=[1,408],rb=[1,409],Cb=[1,415],Db=[1,416],ec={trace:function(){},yy:{},symbols_:{error:2,Root:3,Body:4,Line:5,TERMINATOR:6,Expression:7,Statement:8,YieldReturn:9,Return:10,Comment:11,STATEMENT:12,Import:13,Export:14,Value:15,Invocation:16,Code:17,Operation:18,Assign:19,If:20,Try:21,While:22,For:23,Switch:24, Class:25,Throw:26,Yield:27,YIELD:28,FROM:29,Block:30,INDENT:31,OUTDENT:32,Identifier:33,IDENTIFIER:34,Property:35,PROPERTY:36,AlphaNumeric:37,NUMBER:38,String:39,STRING:40,STRING_START:41,STRING_END:42,Regex:43,REGEX:44,REGEX_START:45,REGEX_END:46,Literal:47,JS:48,UNDEFINED:49,NULL:50,BOOL:51,INFINITY:52,NAN:53,Assignable:54,"\x3d":55,AssignObj:56,ObjAssignable:57,":":58,SimpleObjAssignable:59,ThisProperty:60,RETURN:61,HERECOMMENT:62,PARAM_START:63,ParamList:64,PARAM_END:65,FuncGlyph:66,"-\x3e":67, "\x3d\x3e":68,OptComma:69,",":70,Param:71,ParamVar:72,"...":73,Array:74,Object:75,Splat:76,SimpleAssignable:77,Accessor:78,Parenthetical:79,Range:80,This:81,".":82,"?.":83,"::":84,"?::":85,Index:86,INDEX_START:87,IndexValue:88,INDEX_END:89,INDEX_SOAK:90,Slice:91,"{":92,AssignList:93,"}":94,CLASS:95,EXTENDS:96,IMPORT:97,ImportDefaultSpecifier:98,ImportNamespaceSpecifier:99,ImportSpecifierList:100,ImportSpecifier:101,AS:102,DEFAULT:103,IMPORT_ALL:104,EXPORT:105,ExportSpecifierList:106,EXPORT_ALL:107, ExportSpecifier:108,OptFuncExist:109,Arguments:110,Super:111,SUPER:112,FUNC_EXIST:113,CALL_START:114,CALL_END:115,ArgList:116,THIS:117,"@":118,"[":119,"]":120,RangeDots:121,"..":122,Arg:123,SimpleArgs:124,TRY:125,Catch:126,FINALLY:127,CATCH:128,THROW:129,"(":130,")":131,WhileSource:132,WHILE:133,WHEN:134,UNTIL:135,Loop:136,LOOP:137,ForBody:138,FOR:139,BY:140,ForStart:141,ForSource:142,ForVariables:143,OWN:144,ForValue:145,FORIN:146,FOROF:147,FORFROM:148,SWITCH:149,Whens:150,ELSE:151,When:152,LEADING_WHEN:153, IfBlock:154,IF:155,POST_IF:156,UNARY:157,UNARY_MATH:158,"-":159,"+":160,"--":161,"++":162,"?":163,MATH:164,"**":165,SHIFT:166,COMPARE:167,"\x26":168,"^":169,"|":170,"\x26\x26":171,"||":172,"BIN?":173,RELATION:174,COMPOUND_ASSIGN:175,$accept:0,$end:1},terminals_:{2:"error",6:"TERMINATOR",12:"STATEMENT",28:"YIELD",29:"FROM",31:"INDENT",32:"OUTDENT",34:"IDENTIFIER",36:"PROPERTY",38:"NUMBER",40:"STRING",41:"STRING_START",42:"STRING_END",44:"REGEX",45:"REGEX_START",46:"REGEX_END",48:"JS",49:"UNDEFINED", 50:"NULL",51:"BOOL",52:"INFINITY",53:"NAN",55:"\x3d",58:":",61:"RETURN",62:"HERECOMMENT",63:"PARAM_START",65:"PARAM_END",67:"-\x3e",68:"\x3d\x3e",70:",",73:"...",82:".",83:"?.",84:"::",85:"?::",87:"INDEX_START",89:"INDEX_END",90:"INDEX_SOAK",92:"{",94:"}",95:"CLASS",96:"EXTENDS",97:"IMPORT",102:"AS",103:"DEFAULT",104:"IMPORT_ALL",105:"EXPORT",107:"EXPORT_ALL",112:"SUPER",113:"FUNC_EXIST",114:"CALL_START",115:"CALL_END",117:"THIS",118:"@",119:"[",120:"]",122:"..",125:"TRY",127:"FINALLY",128:"CATCH", 129:"THROW",130:"(",131:")",133:"WHILE",134:"WHEN",135:"UNTIL",137:"LOOP",139:"FOR",140:"BY",144:"OWN",146:"FORIN",147:"FOROF",148:"FORFROM",149:"SWITCH",151:"ELSE",153:"LEADING_WHEN",155:"IF",156:"POST_IF",157:"UNARY",158:"UNARY_MATH",159:"-",160:"+",161:"--",162:"++",163:"?",164:"MATH",165:"**",166:"SHIFT",167:"COMPARE",168:"\x26",169:"^",170:"|",171:"\x26\x26",172:"||",173:"BIN?",174:"RELATION",175:"COMPOUND_ASSIGN"},productions_:[0,[3,0],[3,1],[4,1],[4,3],[4,2],[5,1],[5,1],[5,1],[8,1],[8,1],[8, 1],[8,1],[8,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[27,1],[27,2],[27,3],[30,2],[30,3],[33,1],[35,1],[37,1],[37,1],[39,1],[39,3],[43,1],[43,3],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[19,3],[19,4],[19,5],[56,1],[56,3],[56,5],[56,3],[56,5],[56,1],[59,1],[59,1],[59,1],[57,1],[57,1],[10,2],[10,1],[9,3],[9,2],[11,1],[17,5],[17,2],[66,1],[66,1],[69,0],[69,1],[64,0],[64,1],[64,3],[64,4],[64,6],[71,1],[71,2],[71,3],[71,1],[72,1],[72,1],[72,1],[72, 1],[76,2],[77,1],[77,2],[77,2],[77,1],[54,1],[54,1],[54,1],[15,1],[15,1],[15,1],[15,1],[15,1],[78,2],[78,2],[78,2],[78,2],[78,1],[78,1],[86,3],[86,2],[88,1],[88,1],[75,4],[93,0],[93,1],[93,3],[93,4],[93,6],[25,1],[25,2],[25,3],[25,4],[25,2],[25,3],[25,4],[25,5],[13,2],[13,4],[13,4],[13,5],[13,7],[13,6],[13,9],[100,1],[100,3],[100,4],[100,4],[100,6],[101,1],[101,3],[101,1],[101,3],[98,1],[99,3],[14,3],[14,5],[14,2],[14,4],[14,5],[14,6],[14,3],[14,4],[14,7],[106,1],[106,3],[106,4],[106,4],[106,6],[108, 1],[108,3],[108,3],[108,1],[108,3],[16,3],[16,3],[16,3],[16,1],[111,1],[111,2],[109,0],[109,1],[110,2],[110,4],[81,1],[81,1],[60,2],[74,2],[74,4],[121,1],[121,1],[80,5],[91,3],[91,2],[91,2],[91,1],[116,1],[116,3],[116,4],[116,4],[116,6],[123,1],[123,1],[123,1],[124,1],[124,3],[21,2],[21,3],[21,4],[21,5],[126,3],[126,3],[126,2],[26,2],[79,3],[79,5],[132,2],[132,4],[132,2],[132,4],[22,2],[22,2],[22,2],[22,1],[136,2],[136,2],[23,2],[23,2],[23,2],[138,2],[138,4],[138,2],[141,2],[141,3],[145,1],[145,1], [145,1],[145,1],[143,1],[143,3],[142,2],[142,2],[142,4],[142,4],[142,4],[142,6],[142,6],[142,2],[142,4],[24,5],[24,7],[24,4],[24,6],[150,1],[150,2],[152,3],[152,4],[154,3],[154,5],[20,1],[20,3],[20,3],[20,3],[18,2],[18,2],[18,2],[18,2],[18,2],[18,2],[18,2],[18,2],[18,2],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,5],[18,4],[18,3]],performAction:function(a,p,t,d,wa,b,e){a=b.length-1;switch(wa){case 1:return this.$=d.addLocationDataFn(e[a],e[a])(new d.Block); case 2:return this.$=b[a];case 3:this.$=d.addLocationDataFn(e[a],e[a])(d.Block.wrap([b[a]]));break;case 4:this.$=d.addLocationDataFn(e[a-2],e[a])(b[a-2].push(b[a]));break;case 5:this.$=b[a-1];break;case 6:case 7:case 8:case 9:case 10:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 35:case 40:case 42:case 56:case 57:case 58:case 59:case 60:case 61:case 71:case 72:case 82:case 83:case 84:case 85:case 90:case 91:case 94:case 98:case 104:case 163:case 187:case 188:case 190:case 220:case 221:case 239:case 245:this.$= b[a];break;case 11:this.$=d.addLocationDataFn(e[a],e[a])(new d.StatementLiteral(b[a]));break;case 27:this.$=d.addLocationDataFn(e[a],e[a])(new d.Op(b[a],new d.Value(new d.Literal(""))));break;case 28:case 249:case 250:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Op(b[a-1],b[a]));break;case 29:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Op(b[a-2].concat(b[a-1]),b[a]));break;case 30:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Block);break;case 31:case 105:this.$=d.addLocationDataFn(e[a-2],e[a])(b[a- 1]);break;case 32:this.$=d.addLocationDataFn(e[a],e[a])(new d.IdentifierLiteral(b[a]));break;case 33:this.$=d.addLocationDataFn(e[a],e[a])(new d.PropertyName(b[a]));break;case 34:this.$=d.addLocationDataFn(e[a],e[a])(new d.NumberLiteral(b[a]));break;case 36:this.$=d.addLocationDataFn(e[a],e[a])(new d.StringLiteral(b[a]));break;case 37:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.StringWithInterpolations(b[a-1]));break;case 38:this.$=d.addLocationDataFn(e[a],e[a])(new d.RegexLiteral(b[a]));break; case 39:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.RegexWithInterpolations(b[a-1].args));break;case 41:this.$=d.addLocationDataFn(e[a],e[a])(new d.PassthroughLiteral(b[a]));break;case 43:this.$=d.addLocationDataFn(e[a],e[a])(new d.UndefinedLiteral);break;case 44:this.$=d.addLocationDataFn(e[a],e[a])(new d.NullLiteral);break;case 45:this.$=d.addLocationDataFn(e[a],e[a])(new d.BooleanLiteral(b[a]));break;case 46:this.$=d.addLocationDataFn(e[a],e[a])(new d.InfinityLiteral(b[a]));break;case 47:this.$= d.addLocationDataFn(e[a],e[a])(new d.NaNLiteral);break;case 48:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Assign(b[a-2],b[a]));break;case 49:this.$=d.addLocationDataFn(e[a-3],e[a])(new d.Assign(b[a-3],b[a]));break;case 50:this.$=d.addLocationDataFn(e[a-4],e[a])(new d.Assign(b[a-4],b[a-1]));break;case 51:case 87:case 92:case 93:case 95:case 96:case 97:case 222:case 223:this.$=d.addLocationDataFn(e[a],e[a])(new d.Value(b[a]));break;case 52:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Assign(d.addLocationDataFn(e[a- 2])(new d.Value(b[a-2])),b[a],"object",{operatorToken:d.addLocationDataFn(e[a-1])(new d.Literal(b[a-1]))}));break;case 53:this.$=d.addLocationDataFn(e[a-4],e[a])(new d.Assign(d.addLocationDataFn(e[a-4])(new d.Value(b[a-4])),b[a-1],"object",{operatorToken:d.addLocationDataFn(e[a-3])(new d.Literal(b[a-3]))}));break;case 54:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Assign(d.addLocationDataFn(e[a-2])(new d.Value(b[a-2])),b[a],null,{operatorToken:d.addLocationDataFn(e[a-1])(new d.Literal(b[a-1]))})); break;case 55:this.$=d.addLocationDataFn(e[a-4],e[a])(new d.Assign(d.addLocationDataFn(e[a-4])(new d.Value(b[a-4])),b[a-1],null,{operatorToken:d.addLocationDataFn(e[a-3])(new d.Literal(b[a-3]))}));break;case 62:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Return(b[a]));break;case 63:this.$=d.addLocationDataFn(e[a],e[a])(new d.Return);break;case 64:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.YieldReturn(b[a]));break;case 65:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.YieldReturn);break;case 66:this.$= d.addLocationDataFn(e[a],e[a])(new d.Comment(b[a]));break;case 67:this.$=d.addLocationDataFn(e[a-4],e[a])(new d.Code(b[a-3],b[a],b[a-1]));break;case 68:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Code([],b[a],b[a-1]));break;case 69:this.$=d.addLocationDataFn(e[a],e[a])("func");break;case 70:this.$=d.addLocationDataFn(e[a],e[a])("boundfunc");break;case 73:case 110:this.$=d.addLocationDataFn(e[a],e[a])([]);break;case 74:case 111:case 130:case 150:case 182:case 224:this.$=d.addLocationDataFn(e[a], e[a])([b[a]]);break;case 75:case 112:case 131:case 151:case 183:this.$=d.addLocationDataFn(e[a-2],e[a])(b[a-2].concat(b[a]));break;case 76:case 113:case 132:case 152:case 184:this.$=d.addLocationDataFn(e[a-3],e[a])(b[a-3].concat(b[a]));break;case 77:case 114:case 134:case 154:case 186:this.$=d.addLocationDataFn(e[a-5],e[a])(b[a-5].concat(b[a-2]));break;case 78:this.$=d.addLocationDataFn(e[a],e[a])(new d.Param(b[a]));break;case 79:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Param(b[a-1],null,!0)); break;case 80:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Param(b[a-2],b[a]));break;case 81:case 189:this.$=d.addLocationDataFn(e[a],e[a])(new d.Expansion);break;case 86:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Splat(b[a-1]));break;case 88:this.$=d.addLocationDataFn(e[a-1],e[a])(b[a-1].add(b[a]));break;case 89:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Value(b[a-1],[].concat(b[a])));break;case 99:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Access(b[a]));break;case 100:this.$=d.addLocationDataFn(e[a- 1],e[a])(new d.Access(b[a],"soak"));break;case 101:this.$=d.addLocationDataFn(e[a-1],e[a])([d.addLocationDataFn(e[a-1])(new d.Access(new d.PropertyName("prototype"))),d.addLocationDataFn(e[a])(new d.Access(b[a]))]);break;case 102:this.$=d.addLocationDataFn(e[a-1],e[a])([d.addLocationDataFn(e[a-1])(new d.Access(new d.PropertyName("prototype"),"soak")),d.addLocationDataFn(e[a])(new d.Access(b[a]))]);break;case 103:this.$=d.addLocationDataFn(e[a],e[a])(new d.Access(new d.PropertyName("prototype"))); break;case 106:this.$=d.addLocationDataFn(e[a-1],e[a])(d.extend(b[a],{soak:!0}));break;case 107:this.$=d.addLocationDataFn(e[a],e[a])(new d.Index(b[a]));break;case 108:this.$=d.addLocationDataFn(e[a],e[a])(new d.Slice(b[a]));break;case 109:this.$=d.addLocationDataFn(e[a-3],e[a])(new d.Obj(b[a-2],b[a-3].generated));break;case 115:this.$=d.addLocationDataFn(e[a],e[a])(new d.Class);break;case 116:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Class(null,null,b[a]));break;case 117:this.$=d.addLocationDataFn(e[a- 2],e[a])(new d.Class(null,b[a]));break;case 118:this.$=d.addLocationDataFn(e[a-3],e[a])(new d.Class(null,b[a-1],b[a]));break;case 119:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Class(b[a]));break;case 120:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Class(b[a-1],null,b[a]));break;case 121:this.$=d.addLocationDataFn(e[a-3],e[a])(new d.Class(b[a-2],b[a]));break;case 122:this.$=d.addLocationDataFn(e[a-4],e[a])(new d.Class(b[a-3],b[a-1],b[a]));break;case 123:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.ImportDeclaration(null, b[a]));break;case 124:this.$=d.addLocationDataFn(e[a-3],e[a])(new d.ImportDeclaration(new d.ImportClause(b[a-2],null),b[a]));break;case 125:this.$=d.addLocationDataFn(e[a-3],e[a])(new d.ImportDeclaration(new d.ImportClause(null,b[a-2]),b[a]));break;case 126:this.$=d.addLocationDataFn(e[a-4],e[a])(new d.ImportDeclaration(new d.ImportClause(null,new d.ImportSpecifierList([])),b[a]));break;case 127:this.$=d.addLocationDataFn(e[a-6],e[a])(new d.ImportDeclaration(new d.ImportClause(null,new d.ImportSpecifierList(b[a- 4])),b[a]));break;case 128:this.$=d.addLocationDataFn(e[a-5],e[a])(new d.ImportDeclaration(new d.ImportClause(b[a-4],b[a-2]),b[a]));break;case 129:this.$=d.addLocationDataFn(e[a-8],e[a])(new d.ImportDeclaration(new d.ImportClause(b[a-7],new d.ImportSpecifierList(b[a-4])),b[a]));break;case 133:case 153:case 169:case 185:this.$=d.addLocationDataFn(e[a-3],e[a])(b[a-2]);break;case 135:this.$=d.addLocationDataFn(e[a],e[a])(new d.ImportSpecifier(b[a]));break;case 136:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.ImportSpecifier(b[a- 2],b[a]));break;case 137:this.$=d.addLocationDataFn(e[a],e[a])(new d.ImportSpecifier(new d.Literal(b[a])));break;case 138:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.ImportSpecifier(new d.Literal(b[a-2]),b[a]));break;case 139:this.$=d.addLocationDataFn(e[a],e[a])(new d.ImportDefaultSpecifier(b[a]));break;case 140:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.ImportNamespaceSpecifier(new d.Literal(b[a-2]),b[a]));break;case 141:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.ExportNamedDeclaration(new d.ExportSpecifierList([]))); break;case 142:this.$=d.addLocationDataFn(e[a-4],e[a])(new d.ExportNamedDeclaration(new d.ExportSpecifierList(b[a-2])));break;case 143:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.ExportNamedDeclaration(b[a]));break;case 144:this.$=d.addLocationDataFn(e[a-3],e[a])(new d.ExportNamedDeclaration(new d.Assign(b[a-2],b[a],null,{moduleDeclaration:"export"})));break;case 145:this.$=d.addLocationDataFn(e[a-4],e[a])(new d.ExportNamedDeclaration(new d.Assign(b[a-3],b[a],null,{moduleDeclaration:"export"}))); break;case 146:this.$=d.addLocationDataFn(e[a-5],e[a])(new d.ExportNamedDeclaration(new d.Assign(b[a-4],b[a-1],null,{moduleDeclaration:"export"})));break;case 147:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.ExportDefaultDeclaration(b[a]));break;case 148:this.$=d.addLocationDataFn(e[a-3],e[a])(new d.ExportAllDeclaration(new d.Literal(b[a-2]),b[a]));break;case 149:this.$=d.addLocationDataFn(e[a-6],e[a])(new d.ExportNamedDeclaration(new d.ExportSpecifierList(b[a-4]),b[a]));break;case 155:this.$=d.addLocationDataFn(e[a], e[a])(new d.ExportSpecifier(b[a]));break;case 156:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.ExportSpecifier(b[a-2],b[a]));break;case 157:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.ExportSpecifier(b[a-2],new d.Literal(b[a])));break;case 158:this.$=d.addLocationDataFn(e[a],e[a])(new d.ExportSpecifier(new d.Literal(b[a])));break;case 159:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.ExportSpecifier(new d.Literal(b[a-2]),b[a]));break;case 160:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.TaggedTemplateCall(b[a- 2],b[a],b[a-1]));break;case 161:case 162:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Call(b[a-2],b[a],b[a-1]));break;case 164:this.$=d.addLocationDataFn(e[a],e[a])(new d.SuperCall);break;case 165:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.SuperCall(b[a]));break;case 166:this.$=d.addLocationDataFn(e[a],e[a])(!1);break;case 167:this.$=d.addLocationDataFn(e[a],e[a])(!0);break;case 168:this.$=d.addLocationDataFn(e[a-1],e[a])([]);break;case 170:case 171:this.$=d.addLocationDataFn(e[a],e[a])(new d.Value(new d.ThisLiteral)); break;case 172:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Value(d.addLocationDataFn(e[a-1])(new d.ThisLiteral),[d.addLocationDataFn(e[a])(new d.Access(b[a]))],"this"));break;case 173:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Arr([]));break;case 174:this.$=d.addLocationDataFn(e[a-3],e[a])(new d.Arr(b[a-2]));break;case 175:this.$=d.addLocationDataFn(e[a],e[a])("inclusive");break;case 176:this.$=d.addLocationDataFn(e[a],e[a])("exclusive");break;case 177:this.$=d.addLocationDataFn(e[a-4],e[a])(new d.Range(b[a- 3],b[a-1],b[a-2]));break;case 178:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Range(b[a-2],b[a],b[a-1]));break;case 179:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Range(b[a-1],null,b[a]));break;case 180:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Range(null,b[a],b[a-1]));break;case 181:this.$=d.addLocationDataFn(e[a],e[a])(new d.Range(null,null,b[a]));break;case 191:this.$=d.addLocationDataFn(e[a-2],e[a])([].concat(b[a-2],b[a]));break;case 192:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Try(b[a])); break;case 193:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Try(b[a-1],b[a][0],b[a][1]));break;case 194:this.$=d.addLocationDataFn(e[a-3],e[a])(new d.Try(b[a-2],null,null,b[a]));break;case 195:this.$=d.addLocationDataFn(e[a-4],e[a])(new d.Try(b[a-3],b[a-2][0],b[a-2][1],b[a]));break;case 196:this.$=d.addLocationDataFn(e[a-2],e[a])([b[a-1],b[a]]);break;case 197:this.$=d.addLocationDataFn(e[a-2],e[a])([d.addLocationDataFn(e[a-1])(new d.Value(b[a-1])),b[a]]);break;case 198:this.$=d.addLocationDataFn(e[a- 1],e[a])([null,b[a]]);break;case 199:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Throw(b[a]));break;case 200:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Parens(b[a-1]));break;case 201:this.$=d.addLocationDataFn(e[a-4],e[a])(new d.Parens(b[a-2]));break;case 202:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.While(b[a]));break;case 203:this.$=d.addLocationDataFn(e[a-3],e[a])(new d.While(b[a-2],{guard:b[a]}));break;case 204:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.While(b[a],{invert:!0}));break; case 205:this.$=d.addLocationDataFn(e[a-3],e[a])(new d.While(b[a-2],{invert:!0,guard:b[a]}));break;case 206:this.$=d.addLocationDataFn(e[a-1],e[a])(b[a-1].addBody(b[a]));break;case 207:case 208:this.$=d.addLocationDataFn(e[a-1],e[a])(b[a].addBody(d.addLocationDataFn(e[a-1])(d.Block.wrap([b[a-1]]))));break;case 209:this.$=d.addLocationDataFn(e[a],e[a])(b[a]);break;case 210:this.$=d.addLocationDataFn(e[a-1],e[a])((new d.While(d.addLocationDataFn(e[a-1])(new d.BooleanLiteral("true")))).addBody(b[a])); break;case 211:this.$=d.addLocationDataFn(e[a-1],e[a])((new d.While(d.addLocationDataFn(e[a-1])(new d.BooleanLiteral("true")))).addBody(d.addLocationDataFn(e[a])(d.Block.wrap([b[a]]))));break;case 212:case 213:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.For(b[a-1],b[a]));break;case 214:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.For(b[a],b[a-1]));break;case 215:this.$=d.addLocationDataFn(e[a-1],e[a])({source:d.addLocationDataFn(e[a])(new d.Value(b[a]))});break;case 216:this.$=d.addLocationDataFn(e[a- 3],e[a])({source:d.addLocationDataFn(e[a-2])(new d.Value(b[a-2])),step:b[a]});break;case 217:d=d.addLocationDataFn(e[a-1],e[a]);b[a].own=b[a-1].own;b[a].ownTag=b[a-1].ownTag;b[a].name=b[a-1][0];b[a].index=b[a-1][1];this.$=d(b[a]);break;case 218:this.$=d.addLocationDataFn(e[a-1],e[a])(b[a]);break;case 219:wa=d.addLocationDataFn(e[a-2],e[a]);b[a].own=!0;b[a].ownTag=d.addLocationDataFn(e[a-1])(new d.Literal(b[a-1]));this.$=wa(b[a]);break;case 225:this.$=d.addLocationDataFn(e[a-2],e[a])([b[a-2],b[a]]); break;case 226:this.$=d.addLocationDataFn(e[a-1],e[a])({source:b[a]});break;case 227:this.$=d.addLocationDataFn(e[a-1],e[a])({source:b[a],object:!0});break;case 228:this.$=d.addLocationDataFn(e[a-3],e[a])({source:b[a-2],guard:b[a]});break;case 229:this.$=d.addLocationDataFn(e[a-3],e[a])({source:b[a-2],guard:b[a],object:!0});break;case 230:this.$=d.addLocationDataFn(e[a-3],e[a])({source:b[a-2],step:b[a]});break;case 231:this.$=d.addLocationDataFn(e[a-5],e[a])({source:b[a-4],guard:b[a-2],step:b[a]}); break;case 232:this.$=d.addLocationDataFn(e[a-5],e[a])({source:b[a-4],step:b[a-2],guard:b[a]});break;case 233:this.$=d.addLocationDataFn(e[a-1],e[a])({source:b[a],from:!0});break;case 234:this.$=d.addLocationDataFn(e[a-3],e[a])({source:b[a-2],guard:b[a],from:!0});break;case 235:this.$=d.addLocationDataFn(e[a-4],e[a])(new d.Switch(b[a-3],b[a-1]));break;case 236:this.$=d.addLocationDataFn(e[a-6],e[a])(new d.Switch(b[a-5],b[a-3],b[a-1]));break;case 237:this.$=d.addLocationDataFn(e[a-3],e[a])(new d.Switch(null, b[a-1]));break;case 238:this.$=d.addLocationDataFn(e[a-5],e[a])(new d.Switch(null,b[a-3],b[a-1]));break;case 240:this.$=d.addLocationDataFn(e[a-1],e[a])(b[a-1].concat(b[a]));break;case 241:this.$=d.addLocationDataFn(e[a-2],e[a])([[b[a-1],b[a]]]);break;case 242:this.$=d.addLocationDataFn(e[a-3],e[a])([[b[a-2],b[a-1]]]);break;case 243:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.If(b[a-1],b[a],{type:b[a-2]}));break;case 244:this.$=d.addLocationDataFn(e[a-4],e[a])(b[a-4].addElse(d.addLocationDataFn(e[a- 2],e[a])(new d.If(b[a-1],b[a],{type:b[a-2]}))));break;case 246:this.$=d.addLocationDataFn(e[a-2],e[a])(b[a-2].addElse(b[a]));break;case 247:case 248:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.If(b[a],d.addLocationDataFn(e[a-2])(d.Block.wrap([b[a-2]])),{type:b[a-1],statement:!0}));break;case 251:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Op("-",b[a]));break;case 252:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Op("+",b[a]));break;case 253:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Op("--", b[a]));break;case 254:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Op("++",b[a]));break;case 255:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Op("--",b[a-1],null,!0));break;case 256:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Op("++",b[a-1],null,!0));break;case 257:this.$=d.addLocationDataFn(e[a-1],e[a])(new d.Existence(b[a-1]));break;case 258:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Op("+",b[a-2],b[a]));break;case 259:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Op("-",b[a-2],b[a]));break; case 260:case 261:case 262:case 263:case 264:case 265:case 266:case 267:case 268:case 269:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Op(b[a-1],b[a-2],b[a]));break;case 270:e=d.addLocationDataFn(e[a-2],e[a]);b="!"===b[a-1].charAt(0)?(new d.Op(b[a-1].slice(1),b[a-2],b[a])).invert():new d.Op(b[a-1],b[a-2],b[a]);this.$=e(b);break;case 271:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Assign(b[a-2],b[a],b[a-1]));break;case 272:this.$=d.addLocationDataFn(e[a-4],e[a])(new d.Assign(b[a-4],b[a-1],b[a-3])); break;case 273:this.$=d.addLocationDataFn(e[a-3],e[a])(new d.Assign(b[a-3],b[a],b[a-2]));break;case 274:this.$=d.addLocationDataFn(e[a-2],e[a])(new d.Extends(b[a-2],b[a]))}},table:[{1:[2,1],3:1,4:2,5:3,7:4,8:5,9:6,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:u,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k, 97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{1:[3]},{1:[2,2],6:qa},a(sa,[2,3]),a(sa,[2,6],{141:77,132:102,138:103,133:D,135:A,139:E,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(sa,[2,7],{141:77,132:105,138:106,133:D,135:A,139:E,156:va}),a(sa,[2,8]),a(N,[2,14],{109:107,78:108,86:114,40:xa,41:xa,114:xa,82:ta,83:Na, 84:Fa,85:Ga,87:Ca,90:Pa,113:Ia}),a(N,[2,15],{86:114,109:117,78:118,82:ta,83:Na,84:Fa,85:Ga,87:Ca,90:Pa,113:Ia,114:xa}),a(N,[2,16]),a(N,[2,17]),a(N,[2,18]),a(N,[2,19]),a(N,[2,20]),a(N,[2,21]),a(N,[2,22]),a(N,[2,23]),a(N,[2,24]),a(N,[2,25]),a(N,[2,26]),a(Ea,[2,9]),a(Ea,[2,10]),a(Ea,[2,11]),a(Ea,[2,12]),a(Ea,[2,13]),a([1,6,32,42,131,133,135,139,156,163,164,165,166,167,168,169,170,171,172,173,174],Va,{15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26, 47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,7:120,8:122,12:b,28:ea,29:Ya,34:g,38:h,40:r,41:n,44:B,45:H,48:I,49:F,50:Q,51:x,52:J,53:O,61:[1,119],62:z,63:l,67:c,68:w,92:m,95:k,97:K,105:P,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,137:q,149:ba,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M}),a(Ba,Ha,{55:[1,124]}),a(Ba,[2,95]),a(Ba,[2,96]),a(Ba,[2,97]),a(Ba,[2,98]),a(t,[2,163]),a([6,31,65,70],p,{64:125,71:126,72:127,33:129,60:130, 74:131,75:132,34:g,73:d,92:m,118:wa,119:e}),{30:135,31:Da},{7:137,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C, 158:T,159:v,160:Y,161:S,162:M},{7:138,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M}, {7:139,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:140,8:122,10:20,11:21,12:b, 13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{15:142,16:143,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57, 44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:144,60:71,74:53,75:54,77:141,79:28,80:29,81:30,92:m,111:31,112:L,117:V,118:X,119:G,130:W},{15:142,16:143,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:144,60:71,74:53,75:54,77:145,79:28,80:29,81:30,92:m,111:31,112:L,117:V,118:X,119:G,130:W},a(Ta,ua,{96:[1,149],161:[1,146],162:[1,147],175:[1,148]}),a(N,[2,245],{151:[1,150]}),{30:151,31:Da},{30:152,31:Da},a(N,[2,209]),{30:153,31:Da},{7:154,8:122,10:20,11:21, 12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:[1,155],33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(Eb,[2,115],{47:27,79:28,80:29,81:30,111:31, 74:53,75:54,37:55,43:57,33:70,60:71,39:80,15:142,16:143,54:144,30:156,77:158,31:Da,34:g,38:h,40:r,41:n,44:B,45:H,48:I,49:F,50:Q,51:x,52:J,53:O,92:m,96:[1,157],112:L,117:V,118:X,119:G,130:W}),{7:159,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P, 111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(Ea,Za,{15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,8:122,7:160,12:b,28:ea,34:g,38:h,40:r,41:n,44:B,45:H,48:I,49:F,50:Q,51:x,52:J,53:O,61:R,62:z,63:l,67:c,68:w, 92:m,95:k,97:K,105:P,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,137:q,149:ba,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M}),a([1,6,31,32,42,70,94,131,133,135,139,156],[2,66]),{33:165,34:g,39:161,40:r,41:n,92:[1,164],98:162,99:163,104:Fb},{25:168,33:169,34:g,92:[1,167],95:k,103:[1,170],107:[1,171]},a(Ta,[2,92]),a(Ta,[2,93]),a(Ba,[2,40]),a(Ba,[2,41]),a(Ba,[2,42]),a(Ba,[2,43]),a(Ba,[2,44]),a(Ba,[2,45]),a(Ba,[2,46]),a(Ba,[2,47]),{4:172,5:3,7:4,8:5,9:6,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11, 20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:u,31:[1,173],33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:174,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14, 23:15,24:16,25:17,26:18,27:19,28:ea,31:$a,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,73:Ua,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,116:176,117:V,118:X,119:G,120:Gb,123:177,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(Ba,[2,170]),a(Ba,[2,171],{35:181,36:Oa}),a([1,6,31,32,42,46,65,70,73,82, 83,84,85,87,89,90,94,113,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],[2,164],{110:183,114:sb}),{31:[2,69]},{31:[2,70]},a(La,[2,87]),a(La,[2,90]),{7:185,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K, 105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:186,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X, 119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:187,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43, 133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:189,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,30:188,31:Da,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44, 137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{33:194,34:g,60:195,74:196,75:197,80:190,92:m,118:wa,119:G,143:191,144:[1,192],145:193},{142:198,146:[1,199],147:[1,200],148:[1,201]},a([6,31,70,94],Hb,{39:80,93:202,56:203,57:204,59:205,11:206,37:207,33:208,35:209,60:210,34:g,36:Oa,38:h,40:r,41:n,62:z,118:wa}),a(Ib,[2,34]),a(Ib,[2,35]),a(Ba,[2,38]),{15:142,16:211,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:144,60:71, 74:53,75:54,77:212,79:28,80:29,81:30,92:m,111:31,112:L,117:V,118:X,119:G,130:W},a([1,6,29,31,32,40,41,42,55,58,65,70,73,82,83,84,85,87,89,90,94,96,102,113,114,115,120,122,131,133,134,135,139,140,146,147,148,156,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175],[2,32]),a(Jb,[2,36]),{4:213,5:3,7:4,8:5,9:6,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:u,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F, 50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(sa,[2,5],{7:4,8:5,9:6,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,138:45,74:53,75:54,37:55,43:57, 33:70,60:71,141:77,39:80,5:214,12:b,28:u,34:g,38:h,40:r,41:n,44:B,45:H,48:I,49:F,50:Q,51:x,52:J,53:O,61:R,62:z,63:l,67:c,68:w,92:m,95:k,97:K,105:P,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,133:D,135:A,137:q,139:E,149:ba,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M}),a(N,[2,257]),{7:215,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71, 61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:216,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w, 74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:217,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29, 81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:218,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31, 112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:219,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa, 129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:220,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A, 136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:221,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77, 149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:222,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T, 159:v,160:Y,161:S,162:M},{7:223,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:224, 8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:225,8:122,10:20,11:21,12:b,13:23, 14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:226,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11, 20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:227,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16, 25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:228,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70, 34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(N,[2,208]),a(N,[2,213]),{7:229,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g, 37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(N,[2,207]),a(N,[2,212]),{39:230,40:r,41:n,110:231,114:sb},a(La,[2,88]),a(Kb,[2,167]),{35:232,36:Oa},{35:233,36:Oa},a(La,[2,103],{35:234,36:Oa}),{35:235,36:Oa},a(La, [2,104]),{7:237,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,73:Lb,74:53,75:54,77:40,79:28,80:29,81:30,88:236,91:238,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,121:239,122:tb,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y, 161:S,162:M},{86:242,87:Ca,90:Pa},{110:243,114:sb},a(La,[2,89]),a(sa,[2,65],{15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,8:122,7:244,12:b,28:ea,34:g,38:h,40:r,41:n,44:B,45:H,48:I,49:F,50:Q,51:x,52:J,53:O,61:R,62:z,63:l,67:c,68:w,92:m,95:k,97:K,105:P,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,133:Za,135:Za,139:Za,156:Za, 137:q,149:ba,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M}),a(Ma,[2,28],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),{7:245,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P, 111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{132:105,133:D,135:A,138:106,139:E,141:77,156:va},a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,163,164,165,166,167,168,169,170,171,172,173,174],Va,{15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44, 138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,7:120,8:122,12:b,28:ea,29:Ya,34:g,38:h,40:r,41:n,44:B,45:H,48:I,49:F,50:Q,51:x,52:J,53:O,61:R,62:z,63:l,67:c,68:w,92:m,95:k,97:K,105:P,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,137:q,149:ba,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M}),{6:[1,247],7:246,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:[1,248],33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I, 49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a([6,31],Ja,{69:251,65:[1,249],70:Mb}),a(Sa,[2,74]),a(Sa,[2,78],{55:[1,253],73:[1,252]}),a(Sa,[2,81]),a(fb,[2,82]),a(fb,[2,83]),a(fb,[2,84]),a(fb,[2,85]),{35:181,36:Oa},{7:254,8:122,10:20,11:21,12:b,13:23,14:24,15:7, 16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:$a,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,73:Ua,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,116:176,117:V,118:X,119:G,120:Gb,123:177,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(N,[2,68]),{4:256,5:3,7:4,8:5,9:6, 10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:u,32:[1,255],33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a([1,6,31,32,42,65,70,73,89,94, 115,120,122,131,133,134,135,139,140,156,159,160,164,165,166,167,168,169,170,171,172,173,174],[2,249],{141:77,132:102,138:103,163:fa}),a(ab,[2,250],{141:77,132:102,138:103,163:fa,165:ga}),a(ab,[2,251],{141:77,132:102,138:103,163:fa,165:ga}),a(ab,[2,252],{141:77,132:102,138:103,163:fa,165:ga}),a(N,[2,253],{40:ua,41:ua,82:ua,83:ua,84:ua,85:ua,87:ua,90:ua,113:ua,114:ua}),a(Kb,xa,{109:107,78:108,86:114,82:ta,83:Na,84:Fa,85:Ga,87:Ca,90:Pa,113:Ia}),{78:118,82:ta,83:Na,84:Fa,85:Ga,86:114,87:Ca,90:Pa,109:117, 113:Ia,114:xa},a(Nb,Ha),a(N,[2,254],{40:ua,41:ua,82:ua,83:ua,84:ua,85:ua,87:ua,90:ua,113:ua,114:ua}),a(N,[2,255]),a(N,[2,256]),{6:[1,259],7:257,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:[1,258],33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U, 130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:260,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44, 137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{30:261,31:Da,155:[1,262]},a(N,[2,192],{126:263,127:[1,264],128:[1,265]}),a(N,[2,206]),a(N,[2,214]),{31:[1,266],132:102,133:D,135:A,138:103,139:E,141:77,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da},{150:267,152:268,153:gb},a(N,[2,116]),{7:270,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea, 33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(Eb,[2,119],{30:271,31:Da,40:ua,41:ua,82:ua,83:ua,84:ua,85:ua,87:ua,90:ua,113:ua,114:ua,96:[1,272]}),a(Ma,[2,199],{141:77,132:102,138:103,159:ma,160:Z, 163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Ea,bb,{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Ea,[2,123]),{29:[1,273],70:[1,274]},{29:[1,275]},{31:hb,33:280,34:g,94:[1,276],100:277,101:278,103:Wa},a([29,70],[2,139]),{102:[1,282]},{31:ub,33:287,34:g,94:[1,283],103:cb,106:284,108:285},a(Ea,[2,143]),{55:[1,289]},{7:290,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11, 20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{29:[1,291]},{6:qa,131:[1,292]},{4:293,5:3,7:4,8:5,9:6,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9, 18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:u,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a([6,31,70,120],Ob,{141:77,132:102,138:103,121:294,73:[1,295],122:tb,133:D,135:A,139:E, 156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(vb,[2,173]),a([6,31,120],Ja,{69:296,70:ib}),a(Qa,[2,182]),{7:254,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:$a,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,73:Ua,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31, 112:L,116:298,117:V,118:X,119:G,123:177,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(Qa,[2,188]),a(Qa,[2,189]),a(Pb,[2,172]),a(Pb,[2,33]),a(t,[2,165]),{7:254,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:$a,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,73:Ua, 74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,115:[1,299],116:300,117:V,118:X,119:G,123:177,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{30:301,31:Da,132:102,133:D,135:A,138:103,139:E,141:77,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da},a(Qb,[2,202],{141:77,132:102,138:103,133:D,134:[1,302],135:A,139:E,159:ma,160:Z,163:fa,164:ia, 165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Qb,[2,204],{141:77,132:102,138:103,133:D,134:[1,303],135:A,139:E,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(N,[2,210]),a(Xa,[2,211],{141:77,132:102,138:103,133:D,135:A,139:E,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,156,159,160,163,164,165,166,167,168, 169,170,171,172,173,174],[2,215],{140:[1,304]}),a(jb,[2,218]),{33:194,34:g,60:195,74:196,75:197,92:m,118:wa,119:e,143:305,145:193},a(jb,[2,224],{70:[1,306]}),a(kb,[2,220]),a(kb,[2,221]),a(kb,[2,222]),a(kb,[2,223]),a(N,[2,217]),{7:307,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40, 79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:308,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k, 97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:309,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V, 118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(lb,Ja,{69:310,70:Rb}),a(Aa,[2,111]),a(Aa,[2,51],{58:[1,312]}),a(Sb,[2,60],{55:[1,313]}),a(Aa,[2,56]),a(Sb,[2,61]),a(wb,[2,57]),a(wb,[2,58]),a(wb,[2,59]),{46:[1,314],78:118,82:ta,83:Na,84:Fa,85:Ga,86:114,87:Ca,90:Pa,109:117,113:Ia,114:xa},a(Nb,ua),{6:qa,42:[1,315]},a(sa,[2,4]),a(Tb,[2,258],{141:77,132:102,138:103,163:fa,164:ia,165:ga}),a(Tb,[2,259],{141:77, 132:102,138:103,163:fa,164:ia,165:ga}),a(ab,[2,260],{141:77,132:102,138:103,163:fa,165:ga}),a(ab,[2,261],{141:77,132:102,138:103,163:fa,165:ga}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,166,167,168,169,170,171,172,173,174],[2,262],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,167,168,169,170,171,172,173],[2,263],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,174:da}), a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,168,169,170,171,172,173],[2,264],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,174:da}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,169,170,171,172,173],[2,265],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,174:da}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,170,171,172,173],[2,266],{141:77,132:102,138:103,159:ma,160:Z, 163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,174:da}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,171,172,173],[2,267],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,174:da}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,172,173],[2,268],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,174:da}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134, 135,139,140,156,173],[2,269],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,174:da}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,167,168,169,170,171,172,173,174],[2,270],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja}),a(Xa,[2,248],{141:77,132:102,138:103,133:D,135:A,139:E,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Xa,[2,247],{141:77,132:102, 138:103,133:D,135:A,139:E,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(t,[2,160]),a(t,[2,161]),a(La,[2,99]),a(La,[2,100]),a(La,[2,101]),a(La,[2,102]),{89:[1,316]},{73:Lb,89:[2,107],121:317,122:tb,132:102,133:D,135:A,138:103,139:E,141:77,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da},{89:[2,108]},{7:318,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15, 24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,89:[2,181],92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(Ub,[2,175]),a(Ub,Vb),a(La,[2,106]),a(t,[2,162]),a(sa,[2,64],{141:77,132:102,138:103,133:bb,135:bb,139:bb,156:bb, 159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Ma,[2,29],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Ma,[2,48],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),{7:319,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g, 37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:320,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57, 44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{66:321,67:c,68:w},a(Ra,db,{72:127,33:129,60:130,74:131,75:132,71:322,34:g,73:d,92:m,118:wa,119:e}),{6:Wb,31:Xb},a(Sa,[2,79]),{7:325,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11, 20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(Qa,Ob,{141:77,132:102,138:103,73:[1,326],133:D,135:A,139:E,156:za,159:ma,160:Z,163:fa,164:ia,165:ga, 166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Yb,[2,30]),{6:qa,32:[1,327]},a(Ma,[2,271],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),{7:328,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40, 79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:329,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k, 97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(Ma,[2,274],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(N,[2,246]),{7:330,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27, 48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(N,[2,193],{127:[1,331]}),{30:332,31:Da},{30:335,31:Da,33:333,34:g,75:334,92:m},{150:336,152:268,153:gb},{32:[1,337],151:[1,338],152:339,153:gb},a(mb,[2,239]),{7:341,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8, 17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,124:340,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(Zb,[2,117],{141:77,132:102,138:103,30:342,31:Da,133:D,135:A,139:E,159:ma, 160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(N,[2,120]),{7:343,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45, 139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{39:344,40:r,41:n},{92:[1,346],99:345,104:Fb},{39:347,40:r,41:n},{29:[1,348]},a(lb,Ja,{69:349,70:nb}),a(Aa,[2,130]),{31:hb,33:280,34:g,100:351,101:278,103:Wa},a(Aa,[2,135],{102:[1,352]}),a(Aa,[2,137],{102:[1,353]}),{33:354,34:g},a(Ea,[2,141]),a(lb,Ja,{69:355,70:xb}),a(Aa,[2,150]),{31:ub,33:287,34:g,103:cb,106:357,108:285},a(Aa,[2,155],{102:[1,358]}),a(Aa,[2,158],{102:[1,359]}),{6:[1,361],7:360,8:122,10:20,11:21,12:b,13:23,14:24, 15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:[1,362],33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(yb,[2,147],{141:77,132:102,138:103,133:D,135:A,139:E,159:ma, 160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),{39:363,40:r,41:n},a(Ba,[2,200]),{6:qa,32:[1,364]},{7:365,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W, 132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a([12,28,34,38,40,41,44,45,48,49,50,51,52,53,61,62,63,67,68,92,95,97,105,112,117,118,119,125,129,130,133,135,137,139,149,155,157,158,159,160,161,162],Vb,{6:eb,31:eb,70:eb,120:eb}),{6:ob,31:pb,120:[1,366]},a([6,31,32,115,120],db,{15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43, 136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,8:122,76:179,7:254,123:369,12:b,28:ea,34:g,38:h,40:r,41:n,44:B,45:H,48:I,49:F,50:Q,51:x,52:J,53:O,61:R,62:z,63:l,67:c,68:w,73:Ua,92:m,95:k,97:K,105:P,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,133:D,135:A,137:q,139:E,149:ba,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M}),a(Ra,Ja,{69:370,70:ib}),a(t,[2,168]),a([6,31,115],Ja,{69:371,70:ib}),a($b,[2,243]),{7:372,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14, 23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:373,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19, 28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:374,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h, 39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(jb,[2,219]),{33:194,34:g,60:195,74:196,75:197,92:m,118:wa,119:e,145:375},a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,135,139,156],[2,226],{141:77,132:102,138:103,134:[1, 376],140:[1,377],159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(zb,[2,227],{141:77,132:102,138:103,134:[1,378],159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(zb,[2,233],{141:77,132:102,138:103,134:[1,379],159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),{6:ac,31:bc,94:[1,380]},a(Ab,db,{39:80,57:204,59:205,11:206,37:207,33:208,35:209,60:210,56:383, 34:g,36:Oa,38:h,40:r,41:n,62:z,118:wa}),{7:384,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:[1,385],33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v, 160:Y,161:S,162:M},{7:386,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:[1,387],33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M}, a(Ba,[2,39]),a(Jb,[2,37]),a(La,[2,105]),{7:388,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,89:[2,179],92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v, 160:Y,161:S,162:M},{89:[2,180],132:102,133:D,135:A,138:103,139:E,141:77,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da},a(Ma,[2,49],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),{32:[1,389],132:102,133:D,135:A,138:103,139:E,141:77,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da},{30:390,31:Da},a(Sa,[2,75]),{33:129, 34:g,60:130,71:391,72:127,73:d,74:131,75:132,92:m,118:wa,119:e},a(cc,p,{71:126,72:127,33:129,60:130,74:131,75:132,64:392,34:g,73:d,92:m,118:wa,119:e}),a(Sa,[2,80],{141:77,132:102,138:103,133:D,135:A,139:E,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Qa,eb),a(Yb,[2,31]),{32:[1,393],132:102,133:D,135:A,138:103,139:E,141:77,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da},a(Ma,[2,273], {141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),{30:394,31:Da,132:102,133:D,135:A,138:103,139:E,141:77,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da},{30:395,31:Da},a(N,[2,194]),{30:396,31:Da},{30:397,31:Da},a(Bb,[2,198]),{32:[1,398],151:[1,399],152:339,153:gb},a(N,[2,237]),{30:400,31:Da},a(mb,[2,240]),{30:401,31:Da,70:[1,402]},a(dc,[2,190],{141:77,132:102,138:103,133:D, 135:A,139:E,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(N,[2,118]),a(Zb,[2,121],{141:77,132:102,138:103,30:403,31:Da,133:D,135:A,139:E,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Ea,[2,124]),{29:[1,404]},{31:hb,33:280,34:g,100:405,101:278,103:Wa},a(Ea,[2,125]),{39:406,40:r,41:n},{6:qb,31:rb,94:[1,407]},a(Ab,db,{33:280,101:410,34:g,103:Wa}),a(Ra,Ja,{69:411,70:nb}),{33:412,34:g}, {33:413,34:g},{29:[2,140]},{6:Cb,31:Db,94:[1,414]},a(Ab,db,{33:287,108:417,34:g,103:cb}),a(Ra,Ja,{69:418,70:xb}),{33:419,34:g,103:[1,420]},{33:421,34:g},a(yb,[2,144],{141:77,132:102,138:103,133:D,135:A,139:E,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),{7:422,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q, 51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:423,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R, 62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(Ea,[2,148]),{131:[1,424]},{120:[1,425],132:102,133:D,135:A,138:103,139:E,141:77,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da},a(vb,[2,174]),{7:254,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9, 18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,73:Ua,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,123:426,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:254,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11, 20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:$a,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,73:Ua,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,116:427,117:V,118:X,119:G,123:177,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(Qa,[2,183]),{6:ob,31:pb,32:[1,428]},{6:ob,31:pb,115:[1,429]}, a(Xa,[2,203],{141:77,132:102,138:103,133:D,135:A,139:E,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Xa,[2,205],{141:77,132:102,138:103,133:D,135:A,139:E,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Xa,[2,216],{141:77,132:102,138:103,133:D,135:A,139:E,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(jb,[2,225]),{7:430,8:122,10:20,11:21, 12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:431,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9, 18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:432,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14, 23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:433,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19, 28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(vb,[2,109]),{11:206,33:208,34:g,35:209,36:Oa,37:207,38:h,39:80,40:r,41:n,56:434,57:204,59:205,60:210,62:z,118:wa},a(cc,Hb,{39:80,56:203,57:204, 59:205,11:206,37:207,33:208,35:209,60:210,93:435,34:g,36:Oa,38:h,40:r,41:n,62:z,118:wa}),a(Aa,[2,112]),a(Aa,[2,52],{141:77,132:102,138:103,133:D,135:A,139:E,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),{7:436,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l, 66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(Aa,[2,54],{141:77,132:102,138:103,133:D,135:A,139:E,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),{7:437,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18, 27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{89:[2,178],132:102,133:D,135:A,138:103,139:E,141:77,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na, 173:ra,174:da},a(N,[2,50]),a(N,[2,67]),a(Sa,[2,76]),a(Ra,Ja,{69:438,70:Mb}),a(N,[2,272]),a($b,[2,244]),a(N,[2,195]),a(Bb,[2,196]),a(Bb,[2,197]),a(N,[2,235]),{30:439,31:Da},{32:[1,440]},a(mb,[2,241],{6:[1,441]}),{7:442,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30, 92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},a(N,[2,122]),{39:443,40:r,41:n},a(lb,Ja,{69:444,70:nb}),a(Ea,[2,126]),{29:[1,445]},{33:280,34:g,101:446,103:Wa},{31:hb,33:280,34:g,100:447,101:278,103:Wa},a(Aa,[2,131]),{6:qb,31:rb,32:[1,448]},a(Aa,[2,136]),a(Aa,[2,138]),a(Ea,[2,142],{29:[1,449]}),{33:287,34:g,103:cb,108:450},{31:ub,33:287,34:g,103:cb,106:451,108:285}, a(Aa,[2,151]),{6:Cb,31:Db,32:[1,452]},a(Aa,[2,156]),a(Aa,[2,157]),a(Aa,[2,159]),a(yb,[2,145],{141:77,132:102,138:103,133:D,135:A,139:E,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),{32:[1,453],132:102,133:D,135:A,138:103,139:E,141:77,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da},a(Ba,[2,201]),a(Ba,[2,177]),a(Qa,[2,184]),a(Ra,Ja,{69:454,70:ib}),a(Qa,[2,185]),a(t,[2,169]),a([1,6,31,32,42, 65,70,73,89,94,115,120,122,131,133,134,135,139,156],[2,228],{141:77,132:102,138:103,140:[1,455],159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(zb,[2,230],{141:77,132:102,138:103,134:[1,456],159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Ma,[2,229],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Ma,[2,234],{141:77,132:102, 138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Aa,[2,113]),a(Ra,Ja,{69:457,70:Rb}),{32:[1,458],132:102,133:D,135:A,138:103,139:E,141:77,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da},{32:[1,459],132:102,133:D,135:A,138:103,139:E,141:77,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da},{6:Wb,31:Xb,32:[1,460]},{32:[1,461]},a(N, [2,238]),a(mb,[2,242]),a(dc,[2,191],{141:77,132:102,138:103,133:D,135:A,139:E,156:za,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Ea,[2,128]),{6:qb,31:rb,94:[1,462]},{39:463,40:r,41:n},a(Aa,[2,132]),a(Ra,Ja,{69:464,70:nb}),a(Aa,[2,133]),{39:465,40:r,41:n},a(Aa,[2,152]),a(Ra,Ja,{69:466,70:xb}),a(Aa,[2,153]),a(Ea,[2,146]),{6:ob,31:pb,32:[1,467]},{7:468,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16, 25:17,26:18,27:19,28:ea,33:70,34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{7:469,8:122,10:20,11:21,12:b,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70, 34:g,37:55,38:h,39:80,40:r,41:n,43:57,44:B,45:H,47:27,48:I,49:F,50:Q,51:x,52:J,53:O,54:26,60:71,61:R,62:z,63:l,66:33,67:c,68:w,74:53,75:54,77:40,79:28,80:29,81:30,92:m,95:k,97:K,105:P,111:31,112:L,117:V,118:X,119:G,125:aa,129:U,130:W,132:43,133:D,135:A,136:44,137:q,138:45,139:E,141:77,149:ba,154:41,155:ca,157:C,158:T,159:v,160:Y,161:S,162:M},{6:ac,31:bc,32:[1,470]},a(Aa,[2,53]),a(Aa,[2,55]),a(Sa,[2,77]),a(N,[2,236]),{29:[1,471]},a(Ea,[2,127]),{6:qb,31:rb,32:[1,472]},a(Ea,[2,149]),{6:Cb,31:Db,32:[1, 473]},a(Qa,[2,186]),a(Ma,[2,231],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Ma,[2,232],{141:77,132:102,138:103,159:ma,160:Z,163:fa,164:ia,165:ga,166:ja,167:la,168:oa,169:pa,170:ha,171:ka,172:na,173:ra,174:da}),a(Aa,[2,114]),{39:474,40:r,41:n},a(Aa,[2,134]),a(Aa,[2,154]),a(Ea,[2,129])],defaultActions:{68:[2,69],69:[2,70],238:[2,108],354:[2,140]},parseError:function(a,d){if(d.recoverable)this.trace(a);else{var e=function(a, d){this.message=a;this.hash=d};e.prototype=Error;throw new e(a,d);}},parse:function(a){var d=[0],e=[null],b=[],p=this.table,t="",wa=0,c=0,g=0,Da=b.slice.call(arguments,1),k=Object.create(this.lexer),h={};for(f in this.yy)Object.prototype.hasOwnProperty.call(this.yy,f)&&(h[f]=this.yy[f]);k.setInput(a,h);h.lexer=k;h.parser=this;"undefined"==typeof k.yylloc&&(k.yylloc={});var f=k.yylloc;b.push(f);var l=k.options&&k.options.ranges;this.parseError="function"===typeof h.parseError?h.parseError:Object.getPrototypeOf(this).parseError; for(var m,Ta,Ha,n,ua={},y,w;;){Ha=d[d.length-1];if(this.defaultActions[Ha])n=this.defaultActions[Ha];else{if(null===m||"undefined"==typeof m)m=k.lex()||1,"number"!==typeof m&&(m=this.symbols_[m]||m);n=p[Ha]&&p[Ha][m]}if("undefined"===typeof n||!n.length||!n[0]){w=[];for(y in p[Ha])this.terminals_[y]&&2=ta?this.wrapInBraces(d):d};b.prototype.compileRoot=function(a){var d,b;a.indent=a.bare?"":Ca;a.level=N;this.spaced=!0;a.scope=new xa(null,this,null,null!=(b=a.referencedVars)?b:[]);var e=a.locals||[];b=0;for(d=e.length;b=Fa?this.wrapInBraces(d): d};return b}(w);f.StringLiteral=D=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}v(b,a);return b}(z);f.RegexLiteral=X=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}v(b,a);return b}(z);f.PassthroughLiteral=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}v(b,a);return b}(z);f.IdentifierLiteral=x=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}v(b,a);b.prototype.isAssignable=ha; return b}(z);f.PropertyName=L=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}v(b,a);b.prototype.isAssignable=ha;return b}(z);f.StatementLiteral=W=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}v(b,a);b.prototype.isStatement=ha;b.prototype.makeReturn=na;b.prototype.jumps=function(a){if("break"===this.value&&!(null!=a&&a.loop||null!=a&&a.block)||"continue"===this.value&&(null==a||!a.loop))return this};b.prototype.compileNode=function(a){return[this.makeCode(""+ this.tab+this.value+";")]};return b}(z);f.ThisLiteral=E=function(a){function b(){b.__super__.constructor.call(this,"this")}v(b,a);b.prototype.compileNode=function(a){var d;a=null!=(d=a.scope.method)&&d.bound?a.scope.method.context:this.value;return[this.makeCode(a)]};return b}(z);f.UndefinedLiteral=ca=function(a){function b(){b.__super__.constructor.call(this,"undefined")}v(b,a);b.prototype.compileNode=function(a){return[this.makeCode(a.level>=Ga?"(void 0)":"void 0")]};return b}(z);f.NullLiteral= c=function(a){function b(){b.__super__.constructor.call(this,"null")}v(b,a);return b}(z);f.BooleanLiteral=b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}v(b,a);return b}(z);f.Return=G=function(a){function b(a){this.expression=a}v(b,a);b.prototype.children=["expression"];b.prototype.isStatement=ha;b.prototype.makeReturn=na;b.prototype.jumps=na;b.prototype.compileToFragments=function(a,d){var p;var e=null!=(p=this.expression)?p.makeReturn():void 0;return!e||e instanceof b?b.__super__.compileToFragments.call(this,a,d):e.compileToFragments(a,d)};b.prototype.compileNode=function(a){var b=[];b.push(this.makeCode(this.tab+("return"+(this.expression?" ":""))));this.expression&&(b=b.concat(this.expression.compileToFragments(a,Ka)));b.push(this.makeCode(";"));return b};return b}(sa);f.YieldReturn=T=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}v(b,a);b.prototype.compileNode=function(a){null==a.scope.parent&&this.error("yield can only occur inside functions"); return b.__super__.compileNode.apply(this,arguments)};return b}(G);f.Value=C=function(a){function t(a,b,wa){if(!b&&a instanceof t)return a;this.base=a;this.properties=b||[];wa&&(this[wa]=!0);return this}v(t,a);t.prototype.children=["base","properties"];t.prototype.add=function(a){this.properties=this.properties.concat(a);return this};t.prototype.hasProperties=function(){return!!this.properties.length};t.prototype.bareLiteral=function(a){return!this.properties.length&&this.base instanceof a};t.prototype.isArray= function(){return this.bareLiteral(q)};t.prototype.isRange=function(){return this.bareLiteral(V)};t.prototype.isComplex=function(){return this.hasProperties()||this.base.isComplex()};t.prototype.isAssignable=function(){return this.hasProperties()||this.base.isAssignable()};t.prototype.isNumber=function(){return this.bareLiteral(w)};t.prototype.isString=function(){return this.bareLiteral(D)};t.prototype.isRegex=function(){return this.bareLiteral(X)};t.prototype.isUndefined=function(){return this.bareLiteral(ca)}; t.prototype.isNull=function(){return this.bareLiteral(c)};t.prototype.isBoolean=function(){return this.bareLiteral(b)};t.prototype.isAtomic=function(){var a;var b=this.properties.concat(this.base);var wa=0;for(a=b.length;wathis.properties.length&&!this.base.isComplex()&&(null==p||!p.isComplex()))return[this,this];b=new t(this.base,this.properties.slice(0,-1));if(b.isComplex()){var e=new x(a.scope.freeVariable("base"));b=new t(new P(new y(e, b)))}if(!p)return[b,e];if(p.isComplex()){var c=new x(a.scope.freeVariable("name"));p=new R(new y(c,p.index));c=new R(c)}return[b.add(p),new t(e||b.base,[c||p])]};t.prototype.compileNode=function(a){var b;this.base.front=this.front;var p=this.properties;var e=this.base.compileToFragments(a,p.length?Ga:null);p.length&&Pa.test(da(e))&&e.push(this.makeCode("."));var t=0;for(b=p.length;t=Math.abs(this.fromNum-this.toNum)){var c=function(){e=[];for(var a=p=this.fromNum,b=this.toNum;p<=b?a<=b:a>=b;p<=b?a++:a--)e.push(a);return e}.apply(this);this.exclusive&&c.pop();return[this.makeCode("["+c.join(", ")+"]")]}var t=this.tab+Ca;var f=a.scope.freeVariable("i",{single:!0});var g=a.scope.freeVariable("results");var k="\n"+t+g+" \x3d [];";if(b)a.index=f,b=da(this.compileNode(a));else{var h= f+" \x3d "+this.fromC+(this.toC!==this.toVar?", "+this.toC:"");b=this.fromVar+" \x3c\x3d "+this.toVar;b="var "+h+"; "+b+" ? "+f+" \x3c"+this.equals+" "+this.toVar+" : "+f+" \x3e"+this.equals+" "+this.toVar+"; "+b+" ? "+f+"++ : "+f+"--"}f="{ "+g+".push("+f+"); }\n"+t+"return "+g+";\n"+a.indent;a=function(a){return null!=a?a.contains(Va):void 0};if(a(this.from)||a(this.to))c=", arguments";return[this.makeCode("(function() {"+k+"\n"+t+"for ("+b+")"+f+"}).apply(this"+(null!=c?c:"")+")")]};return b}(sa); f.Slice=aa=function(a){function b(a){this.range=a;b.__super__.constructor.call(this)}v(b,a);b.prototype.children=["range"];b.prototype.compileNode=function(a){var b=this.range;var p=b.to;var e=(b=b.from)&&b.compileToFragments(a,Ka)||[this.makeCode("0")];if(p){b=p.compileToFragments(a,Ka);var c=da(b);if(this.range.exclusive||-1!==+c)var t=", "+(this.range.exclusive?c:p.isNumber()?""+(+c+1):(b=p.compileToFragments(a,Ga),"+"+da(b)+" + 1 || 9e9"))}return[this.makeCode(".slice("+da(e)+(t||"")+")")]};return b}(sa); f.Obj=m=function(a){function b(a,b){this.generated=null!=b?b:!1;this.objects=this.properties=a||[]}v(b,a);b.prototype.children=["properties"];b.prototype.compileNode=function(a){var b,p,e;var c=this.properties;if(this.generated){var t=0;for(b=c.length;t= Fa?this.wrapInBraces(t):t}var h=g[0];1===e&&h instanceof H&&h.error("Destructuring assignment has no target");var m=this.variable.isObject();if(p&&1===e&&!(h instanceof U)){var l=null;if(h instanceof b&&"object"===h.context){t=h;var n=t.variable;var q=n.base;h=t.value;h instanceof b&&(l=h.value,h=h.variable)}else h instanceof b&&(l=h.value,h=h.variable),q=m?h["this"]?h.properties[0].name:new L(h.unwrap().value):new w(0);var r=q.unwrap()instanceof L;f=new C(f);f.properties.push(new (r?qa:R)(q));(c= za(h.unwrap().value))&&h.error(c);l&&(f=new k("?",f,l));return(new b(h,f,null,{param:this.param})).compileToFragments(a,N)}var v=f.compileToFragments(a,ta);var y=da(v);t=[];n=!1;f.unwrap()instanceof x&&!this.variable.assigns(y)||(t.push([this.makeCode((l=a.scope.freeVariable("ref"))+" \x3d ")].concat(M.call(v))),v=[this.makeCode(l)],y=l);l=f=0;for(d=g.length;fN?this.wrapInBraces(e):e};return b}(sa);f.Code=h=function(b){function c(b,d,c){this.params=b||[];this.body=d||new a;this.bound="boundfunc"===c;this.isGenerator=!!this.body.contains(function(a){return a instanceof k&&a.isYield()|| a instanceof T})}v(c,b);c.prototype.children=["params","body"];c.prototype.isStatement=function(){return!!this.ctor};c.prototype.jumps=ka;c.prototype.makeScope=function(a){return new xa(a,this.body,this)};c.prototype.compileNode=function(b){var d,f,e,g;this.bound&&null!=(d=b.scope.method)&&d.bound&&(this.context=b.scope.method.context);if(this.bound&&!this.context)return this.context="_this",d=new c([new K(new x(this.context))],new a([this])),d=new ya(d,[new E]),d.updateLocationDataIfMissing(this.locationData), d.compileNode(b);b.scope=la(b,"classScope")||this.makeScope(b.scope);b.scope.shared=la(b,"sharedScope");b.indent+=Ca;delete b.bare;delete b.isExistentialEquals;d=[];var p=[];var h=this.params;var t=0;for(e=h.length;t=Ga?this.wrapInBraces(p):p};c.prototype.eachParamName=function(a){var b;var c=this.params;var e=[];var f=0;for(b=c.length;f=d.length)return[];if(1===d.length)return e=d[0],d=e.compileToFragments(a,ta),c?d:[].concat(e.makeCode(Ia("slice",a)+".call("),d,e.makeCode(")"));c=d.slice(f);var h=g=0;for(p=c.length;g< p;h=++g){e=c[h];var k=e.compileToFragments(a,ta);c[h]=e instanceof b?[].concat(e.makeCode(Ia("slice",a)+".call("),k,e.makeCode(")")):[].concat(e.makeCode("["),k,e.makeCode("]"))}if(0===f)return e=d[0],a=e.joinFragmentArrays(c.slice(1),", "),c[0].concat(e.makeCode(".concat("),a,e.makeCode(")"));g=d.slice(0,f);p=[];k=0;for(h=g.length;k=Ga)return(new P(this)).compileToFragments(a);var f="+"===c||"-"===c;("new"===c||"typeof"===c||"delete"===c||f&&this.first instanceof b&&this.first.operator===c)&&d.push([this.makeCode(" ")]);if(f&&this.first instanceof b||"new"===c&&this.first.isStatement(a))this.first=new P(this.first);d.push(this.first.compileToFragments(a,Fa));this.flip&&d.reverse();return this.joinFragmentArrays(d,"")};b.prototype.compileYield=function(a){var b; var d=[];var c=this.operator;null==a.scope.parent&&this.error("yield can only occur inside functions");0<=S.call(Object.keys(this.first),"expression")&&!(this.first instanceof ba)?null!=this.first.expression&&d.push(this.first.expression.compileToFragments(a,Fa)):(a.level>=Ka&&d.push([this.makeCode("(")]),d.push([this.makeCode(c)]),""!==(null!=(b=this.first.base)?b.value:void 0)&&d.push([this.makeCode(" ")]),d.push(this.first.compileToFragments(a,Fa)),a.level>=Ka&&d.push([this.makeCode(")")]));return this.joinFragmentArrays(d, "")};b.prototype.compilePower=function(a){var b=new C(new x("Math"),[new qa(new L("pow"))]);return(new ya(b,[this.first,this.second])).compileToFragments(a)};b.prototype.compileFloorDivision=function(a){var d=new C(new x("Math"),[new qa(new L("floor"))]);var c=this.second.isComplex()?new P(this.second):this.second;c=new b("/",this.first,c);return(new ya(d,[c])).compileToFragments(a)};b.prototype.compileModulo=function(a){var b=new C(new z(Ia("modulo",a)));return(new ya(b,[this.first,this.second])).compileToFragments(a)}; b.prototype.toString=function(a){return b.__super__.toString.call(this,a,this.constructor.name+" "+this.operator)};return b}(sa);f.In=O=function(a){function b(a,b){this.object=a;this.array=b}v(b,a);b.prototype.children=["object","array"];b.prototype.invert=ra;b.prototype.compileNode=function(a){var b;if(this.array instanceof C&&this.array.isArray()&&this.array.base.objects.length){var c=this.array.base.objects;var e=0;for(b=c.length;e=c.length)?c:this.wrapInBraces(c)};return b}(sa); f.StringWithInterpolations=A=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}v(b,a);b.prototype.compileNode=function(a){var d;if(!a.inTaggedTemplateCall)return b.__super__.compileNode.apply(this,arguments);var c=this.body.unwrap();var e=[];c.traverseChildren(!1,function(a){if(a instanceof D)e.push(a);else if(a instanceof P)return e.push(a),!1;return!0});c=[];c.push(this.makeCode("`"));var f=0;for(d=e.length;fh,this.step&&null!=h&&e||(d=n.freeVariable("len")),K=""+t+f+" \x3d 0, "+d+" \x3d "+A+".length",w=""+t+f+" \x3d "+A+".length - 1",d=f+" \x3c "+d,n=f+" \x3e\x3d 0",this.step?(null!=h?e&&(d= n,K=w):(d=r+" \x3e 0 ? "+d+" : "+n,K="("+r+" \x3e 0 ? ("+K+") : "+w+")"),f=f+" +\x3d "+r):f=""+(q!==f?"++"+f:f+"++"),K=[this.makeCode(K+"; "+d+"; "+t+f)])}if(this.returns){var B=""+this.tab+c+" \x3d [];\n";var V="\n"+this.tab+"return "+c+";";l.makeReturn(c)}this.guard&&(1=Na?this.wrapInBraces(e):e};c.prototype.unfoldSoak=function(){return this.soak&&this};return c}(sa);var gc={extend:function(a){return"function(child, parent) { for (var key in parent) { if ("+Ia("hasProp",a)+".call(parent, key)) child[key] \x3d parent[key]; } function ctor() { this.constructor \x3d child; } ctor.prototype \x3d parent.prototype; child.prototype \x3d new ctor(); child.__super__ \x3d parent.prototype; return child; }"},bind:function(){return"function(fn, me){ return function(){ return fn.apply(me, arguments); }; }"}, indexOf:function(){return"[].indexOf || function(item) { for (var i \x3d 0, l \x3d this.length; i \x3c l; i++) { if (i in this \x26\x26 this[i] \x3d\x3d\x3d item) return i; } return -1; }"},modulo:function(){return"function(a, b) { return (+a % (b \x3d +b) + b) % b; }"},hasProp:function(){return"{}.hasOwnProperty"},slice:function(){return"[].slice"}};var N=1;var Ka=2;var ta=3;var Na=4;var Fa=5;var Ga=6;var Ca=" ";var Pa=/^[+-]?\d+$/;var Ia=function(a,b){var c=b.scope.root;if(a in c.utilities)return c.utilities[a]; var d=c.freeVariable(a);c.assign(d,gc[a](b));return c.utilities[a]=d};var Ea=function(a,b){a=a.replace(/\n/g,"$\x26"+b);return a.replace(/\s+$/,"")};var Va=function(a){return a instanceof x&&"arguments"===a.value};var ea=function(a){return a instanceof E||a instanceof h&&a.bound||a instanceof va};var Ya=function(a){return a.isComplex()||("function"===typeof a.isAssignable?a.isAssignable():void 0)};var Ba=function(a,b,c){if(a=b[c].unfoldSoak(a))return b[c]=a.body,a.body=new C(b),a}}).call(this);return f}(); u["./sourcemap"]=function(){var f={};(function(){var u=function(){function f(f){this.line=f;this.columns=[]}f.prototype.add=function(f,a,b){var q=a[0];a=a[1];null==b&&(b={});if(!this.columns[f]||!b.noReplace)return this.columns[f]={line:this.line,column:f,sourceLine:q,sourceColumn:a}};f.prototype.sourceLocation=function(f){for(var a;!((a=this.columns[f])||0>=f);)f--;return a&&[a.sourceLine,a.sourceColumn]};return f}();f=function(){function f(){this.lines=[]}f.prototype.add=function(f,a,b){var q;null== b&&(b={});var g=a[0];a=a[1];return((q=this.lines)[g]||(q[g]=new u(g))).add(a,f,b)};f.prototype.sourceLocation=function(f){var a;var b=f[0];for(f=f[1];!((a=this.lines[b])||0>=b);)b--;return a&&a.sourceLocation(f)};f.prototype.generate=function(f,a){var b,q,g,h,r,n,u;null==f&&(f={});null==a&&(a=null);var y=g=q=u=0;var I=!1;var F="";var Q=this.lines;var x=b=0;for(h=Q.length;bf?1:0);a||!b;)f=a&31,(a>>=5)&&(f|=32),b+=this.encodeBase64(f);return b};f.prototype.encodeBase64=function(f){var a;if(!(a= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[f]))throw Error("Cannot Base64 encode value: "+f);return a};return f}()}).call(this);return f}();u["./coffee-script"]=function(){var f={};(function(){var qa,q,y={}.hasOwnProperty;var a=u("fs");var b=u("vm");var ya=u("path");var g=u("./lexer").Lexer;var h=u("./parser").parser;var r=u("./helpers");var n=u("./sourcemap");var B=u("../../package.json");f.VERSION=B.version;f.FILE_EXTENSIONS=[".coffee",".litcoffee",".coffee.md"];f.helpers= r;var H=function(a){switch(!1){case "function"!==typeof Buffer:return(new Buffer(a)).toString("base64");case "function"!==typeof btoa:return btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,function(a,b){return String.fromCharCode("0x"+b)}));default:throw Error("Unable to base64 encode inline sourcemap.");}};B=function(a){return function(b,f){null==f&&(f={});try{return a.call(this,b,f)}catch(m){if("string"!==typeof b)throw m;throw r.updateSyntaxError(m,b,f.filename);}}};var I={};var F={};f.compile= qa=B(function(a,b){var c,f,g,l;var q=r.extend;b=q({},b);var u=b.sourceMap||b.inlineMap||null==b.filename;q=b.filename||"\x3canonymous\x3e";I[q]=a;u&&(g=new n);var x=O.tokenize(a,b);var y=b;var G=[];var z=0;for(c=x.length;z ================================================ FILE: update.py ================================================ import os import sys import json import re import shutil def update(): from Config import config config.parse(silent=True) if getattr(sys, 'source_update_dir', False): if not os.path.isdir(sys.source_update_dir): os.makedirs(sys.source_update_dir) source_path = sys.source_update_dir.rstrip("/") else: source_path = os.getcwd().rstrip("/") if config.dist_type.startswith("bundle_linux"): runtime_path = os.path.normpath(os.path.dirname(sys.executable) + "/../..") else: runtime_path = os.path.dirname(sys.executable) updatesite_path = config.data_dir + "/" + config.updatesite sites_json = json.load(open(config.data_dir + "/sites.json")) updatesite_bad_files = sites_json.get(config.updatesite, {}).get("cache", {}).get("bad_files", {}) print( "Update site path: %s, bad_files: %s, source path: %s, runtime path: %s, dist type: %s" % (updatesite_path, len(updatesite_bad_files), source_path, runtime_path, config.dist_type) ) updatesite_content_json = json.load(open(updatesite_path + "/content.json")) inner_paths = list(updatesite_content_json.get("files", {}).keys()) inner_paths += list(updatesite_content_json.get("files_optional", {}).keys()) # Keep file only in ZeroNet directory inner_paths = [inner_path for inner_path in inner_paths if re.match("^(core|bundle)", inner_path)] # Checking plugins plugins_enabled = [] plugins_disabled = [] if os.path.isdir("%s/plugins" % source_path): for dir in os.listdir("%s/plugins" % source_path): if dir.startswith("disabled-"): plugins_disabled.append(dir.replace("disabled-", "")) else: plugins_enabled.append(dir) print("Plugins enabled:", plugins_enabled, "disabled:", plugins_disabled) update_paths = {} for inner_path in inner_paths: if ".." in inner_path: continue inner_path = inner_path.replace("\\", "/").strip("/") # Make sure we have unix path print(".", end=" ") if inner_path.startswith("core"): dest_path = source_path + "/" + re.sub("^core/", "", inner_path) elif inner_path.startswith(config.dist_type): dest_path = runtime_path + "/" + re.sub("^bundle[^/]+/", "", inner_path) else: continue if not dest_path: continue # Keep plugin disabled/enabled status match = re.match(re.escape(source_path) + "/plugins/([^/]+)", dest_path) if match: plugin_name = match.group(1).replace("disabled-", "") if plugin_name in plugins_enabled: # Plugin was enabled dest_path = dest_path.replace("plugins/disabled-" + plugin_name, "plugins/" + plugin_name) elif plugin_name in plugins_disabled: # Plugin was disabled dest_path = dest_path.replace("plugins/" + plugin_name, "plugins/disabled-" + plugin_name) print("P", end=" ") dest_dir = os.path.dirname(dest_path) if dest_dir and not os.path.isdir(dest_dir): os.makedirs(dest_dir) if dest_dir != dest_path.strip("/"): update_paths[updatesite_path + "/" + inner_path] = dest_path num_ok = 0 num_rename = 0 num_error = 0 for path_from, path_to in update_paths.items(): print("-", path_from, "->", path_to) if not os.path.isfile(path_from): print("Missing file") continue data = open(path_from, "rb").read() try: open(path_to, 'wb').write(data) num_ok += 1 except Exception as err: try: print("Error writing: %s. Renaming old file as workaround..." % err) path_to_tmp = path_to + "-old" if os.path.isfile(path_to_tmp): os.unlink(path_to_tmp) os.rename(path_to, path_to_tmp) num_rename += 1 open(path_to, 'wb').write(data) shutil.copymode(path_to_tmp, path_to) # Copy permissions print("Write done after rename!") num_ok += 1 except Exception as err: print("Write error after rename: %s" % err) num_error += 1 print("* Updated files: %s, renamed: %s, error: %s" % (num_ok, num_rename, num_error)) if __name__ == "__main__": sys.path.insert(0, os.path.join(os.path.dirname(__file__), "src")) # Imports relative to src update() ================================================ FILE: zeronet.py ================================================ #!/usr/bin/env python3 import os import sys def main(): if sys.version_info.major < 3: print("Error: Python 3.x is required") sys.exit(0) if "--silent" not in sys.argv: print("- Starting ZeroNet...") main = None try: import main main.start() except Exception as err: # Prevent closing import traceback try: import logging logging.exception("Unhandled exception: %s" % err) except Exception as log_err: print("Failed to log error:", log_err) traceback.print_exc() from Config import config error_log_path = config.log_dir + "/error.log" traceback.print_exc(file=open(error_log_path, "w")) print("---") print("Please report it: https://github.com/HelloZeroNet/ZeroNet/issues/new?assignees=&labels=&template=bug-report.md") if sys.platform.startswith("win") and "python.exe" not in sys.executable: displayErrorMessage(err, error_log_path) if main and (main.update_after_shutdown or main.restart_after_shutdown): # Updater if main.update_after_shutdown: print("Shutting down...") prepareShutdown() import update print("Updating...") update.update() if main.restart_after_shutdown: print("Restarting...") restart() else: print("Shutting down...") prepareShutdown() print("Restarting...") restart() def displayErrorMessage(err, error_log_path): import ctypes import urllib.parse import subprocess MB_YESNOCANCEL = 0x3 MB_ICONEXCLAIMATION = 0x30 ID_YES = 0x6 ID_NO = 0x7 ID_CANCEL = 0x2 err_message = "%s: %s" % (type(err).__name__, err) err_title = "Unhandled exception: %s\nReport error?" % err_message res = ctypes.windll.user32.MessageBoxW(0, err_title, "ZeroNet error", MB_YESNOCANCEL | MB_ICONEXCLAIMATION) if res == ID_YES: import webbrowser report_url = "https://github.com/HelloZeroNet/ZeroNet/issues/new?assignees=&labels=&template=bug-report.md&title=%s" webbrowser.open(report_url % urllib.parse.quote("Unhandled exception: %s" % err_message)) if res in [ID_YES, ID_NO]: subprocess.Popen(['notepad.exe', error_log_path]) def prepareShutdown(): import atexit atexit._run_exitfuncs() # Close log files if "main" in sys.modules: logger = sys.modules["main"].logging.getLogger() for handler in logger.handlers[:]: handler.flush() handler.close() logger.removeHandler(handler) import time time.sleep(1) # Wait for files to close def restart(): args = sys.argv[:] sys.executable = sys.executable.replace(".pkg", "") # Frozen mac fix if not getattr(sys, 'frozen', False): args.insert(0, sys.executable) # Don't open browser after restart if "--open_browser" in args: del args[args.index("--open_browser") + 1] # argument value del args[args.index("--open_browser")] # argument key if getattr(sys, 'frozen', False): pos_first_arg = 1 # Only the executable else: pos_first_arg = 2 # Interpter, .py file path args.insert(pos_first_arg, "--open_browser") args.insert(pos_first_arg + 1, "False") if sys.platform == 'win32': args = ['"%s"' % arg for arg in args] try: print("Executing %s %s" % (sys.executable, args)) os.execv(sys.executable, args) except Exception as err: print("Execv error: %s" % err) print("Bye.") def start(): app_dir = os.path.dirname(os.path.abspath(__file__)) os.chdir(app_dir) # Change working dir to zeronet.py dir sys.path.insert(0, os.path.join(app_dir, "src/lib")) # External liblary directory sys.path.insert(0, os.path.join(app_dir, "src")) # Imports relative to src if "--update" in sys.argv: sys.argv.remove("--update") print("Updating...") import update update.update() else: main() if __name__ == '__main__': start()