;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\210\300\305!\210\300\306!\210\300\307\310\311#\204$\312\313!\210\314\315\310\316\317\301\320\321&\210\322\323\324\325\326DD\327\330\331\317\315&\210\322\332\324\325\333DD\334\330\335\317\315&\210\336\337\332\310#\210\340\211\203u\211@\337N\203n\332N\204n\341\332\337N#\210A\266\202\202T\210\342\337\332\343#\210\322\344\324\325\345DD\346\330\347\317\315&\210\322\350\324\325\351DD\352\330\353\317\315&\210\322\354\324\325\355DD\356\330\357\317\315&\210\322\360\324\325\361DD\362\330\363\317\315&\210\322\364\324\325\365DD\366\330\335\317\315&\210\322\367\324\325\370DD\371\330\335\317\315&\210\322\372\324\325\373DD\374\330\335\317\315&\210\322\375\324\325\376DD\377\330\335\317\315&\207" [require lsp-mode grammarly request s ht json keytar nil t warn "`keytar' is required for login into Grammarly account" custom-declare-group lsp-grammarly "Settings for the Grammarly Language Server.\n\nLink: https://github.com/znck/grammarly" :group :link (url-link "https://github.com/emacs-grammarly/lsp-grammarly") custom-declare-variable lsp-grammarly-server-path funcall function #[0 "\300\207" [nil] 1] "Path points for Grammarly LSP.\n\nThis is only for development use." :type string lsp-grammarly-active-modes #[0 "\300\207" [(text-mode latex-mode org-mode markdown-mode)] 1] "List of major mode that work with Grammarly." list defvaralias lsp-grammarly-modes (saved-value saved-variable-comment) put make-obsolete-variable "0.2.1" lsp-grammarly-auto-activate #[0 "\300\207" [t] 1] "Enable Grammarly service when a supported document is opened." boolean lsp-grammarly-audience #[0 "\300\207" [#1="knowledgeable"] 1 #1#] "Sets the default audience for every document." (choice (const "general") (const "knowledgeable") (const "expert")) lsp-grammarly-dialect #[0 "\300\207" [#2="american"] 1 #2#] "Sets the default dialect for every document." (choice (const "american") (const "australian") (const "british") (const "canadian")) lsp-grammarly-domain #[0 "\300\207" [#3="general"] 1 #3#] "Sets the default domain for every document." (choice (const "academic") (const "business") (const "general") (const "technical") (const "casual") (const "creative")) lsp-grammarly-emotions #[0 "\300\207" [nil] 1] "Experimental: How do you want to sound." lsp-grammarly-goals #[0 "\300\207" [nil] 1] "Experimental: What are you trying to do." lsp-grammarly-user-words #[0 "\300\207" [nil] 1] "A list of words as a local dictionary." lsp-grammarly-override #[0 "\300\207" [nil] 1] "Per document override for audience, dialect, domain, emotions and goals."] 8) #@40 Flag to see if we show debug messages. (defvar lsp-grammarly--show-debug-message nil (#$ . 2714)) #@93 Debug message like function `message' with same argument FMT and ARGS. (fn FMT &rest ARGS) (defalias 'lsp-grammarly--message #[385 "\205 \301\302#\207" [lsp-grammarly--show-debug-message apply message] 6 (#$ . 2818)]) #@70 Convert SCORE to the scale of 100 instead of scale of 1. (fn SCORE) (defalias 'lsp-grammarly--scale-100 #[257 "\211\300_\207" [100] 3 (#$ . 3047)]) #@38 Return random bytes up to N. (fn N) (defalias 'lsp-grammarly--random-bytes #[257 "\300\301\302\303\304\"r\211q\210\305\306\"\216\307\211W\203(\310\311!\234c\266\211T\262\202\266\312 *\207" ["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" 62 generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] 0 nil random buffer-string] 10 (#$ . 3202)]) #@75 Wrap function `json-encode' to convert OBJ for keytar password. (fn OBJ) (defalias 'lsp-grammarly--json-encode #[257 "\300\301\302\303!#\207" [s-replace "\"" "\\\"" json-encode] 6 (#$ . 3636)]) #@63 Ensure read JSON STRING avoid bad string format. (fn STRING) (defalias 'lsp-grammarly--json-read #[257 "\3001 \301!0\202\210\202\206\"\3021 \301\303\303Q!0\202\"\210\304\211;\2036\30512\301!0\2024\210\304\262\207" [(error) json-read-from-string (error) "\"" nil (error)] 5 (#$ . 3838)]) #@27 Key to store credentials. (defconst lsp-grammarly--cookie-key "vscode-grammarly-cookie" (#$ . 4147)) #@36 Key that Grammarly LSP default to. (defconst lsp-grammarly--account "default" (#$ . 4254)) #@31 Encrypted password in string. (defvar lsp-grammarly--password-string nil (#$ . 4351)) #@30 Encrypted password in alist. (defvar lsp-grammarly--password nil (#$ . 4443)) #@57 Return non-nil if currently logged in to Grammarly.com. (defalias 'lsp-grammarly-login-p #[0 "\207" [lsp-grammarly--password] 1 (#$ . 4527)]) #@38 Return the currently login username. (defalias 'lsp-grammarly--username #[0 "\205$\3011\302\236A0\202\210\202\206$\3031\"\304\305\306#0\207\210\306\207" [lsp-grammarly--password (error) username (error) gethash "username" nil] 4 (#$ . 4676)]) #@153 Return the credentials from native password manager. For argument CALLBACK, see object `lsp--client' description. (fn WORKSPACE URI CALLBACK &rest _) (defalias 'lsp-grammarly--get-credentials #[899 "\300!\207" [nil] 6 (#$ . 4938)]) #@158 Return the token from variable `lsp-grammarly--password'. For argument CALLBACK, see object `lsp--client' description. (fn WORKSPACE URI CALLBACK &rest _) (defalias 'lsp-grammarly--get-token #[899 "!\207" [lsp-grammarly--password] 6 (#$ . 5180)]) #@59 Save the token once. (fn WORKSPACE URI CALLBACK &rest _) (defalias 'lsp-grammarly--store-token #[899 "\303 \n#\207" [lsp-grammarly--cookie-key lsp-grammarly--account lsp-grammarly--password-string keytar-set-password] 8 (#$ . 5437)]) #@40 Get Grammarly API ready. (fn &rest _) (defalias 'lsp-grammarly--init #[128 "\304 ?\205-\3051\306 \"0\202\210\307\211\203\211\310!\210\304 \203*\311\312\313 \"\207\311\314!\207" [lsp-grammarly--cookie-key lsp-grammarly--account lsp-grammarly--password-string lsp-grammarly--password lsp-grammarly-login-p (error) keytar-get-password nil lsp-grammarly--json-read message "[INFO] Logged in as, %s" lsp-grammarly--username "[INFO] Visited as, anonymous"] 4 (#$ . 5679)]) #@133 Show error from language server. For argument CALLBACK, see object `lsp--client' description. (fn WORKSPACE URI CALLBACK &rest _) (defalias 'lsp-grammarly--show-error #[899 " \207" [] 5 (#$ . 6166)]) #@88 Update the document status from current document. (fn WORKSPACE URI CALLBACK &rest _) (defalias 'lsp-grammarly--update-document-state #[899 "\300\207" ["Update the document status from current document."] 5 (#$ . 6375)]) #@57 Generate startup command for Grammarly language server. (defalias 'lsp-grammarly--server-command #[0 "\203\n\301D\206\302\303!\301D\207" [lsp-grammarly-server-path "--stdio" lsp-package-path grammarly-ls] 2 (#$ . 6603)]) (byte-code "\300\301!\210\302\303\304\305#\210\306\307\310\311\312!\313\314\315\316\317\320\321\303\322\323\324\325\326\327\330\331\"\332\333\334#\210\332\335\336#\210\332\337\340#\210\332\341\342#\210\332\343\344#\210\211\262&!\207" [lsp-register-custom-settings (("grammarly.autoActivate" lsp-grammarly-auto-activate t) ("grammarly.audience" lsp-grammarly-audience) ("grammarly.dialect" lsp-grammarly-dialect) ("grammarly.domain" lsp-grammarly-domain) ("grammarly.emotions" lsp-grammarly-emotions) ("grammarly.goals" lsp-grammarly-goals) ("grammarly.userWords" lsp-grammarly-user-words) ("grammarly.overrides" lsp-grammarly-override)) lsp-dependency grammarly-ls (:system "grammarly-ls") (:npm :package "@emacs-grammarly/unofficial-grammarly-language-server" :path "unofficial-grammarly-language-server") lsp-register-client make-lsp-client :new-connection lsp-stdio-connection lsp-grammarly--server-command :activation-fn #[128 "\301\302\"\207" [lsp-grammarly-active-modes apply derived-mode-p] 4 "\n\n(fn &rest _)"] :priority -1 :add-on\? t :server-id :download-server-fn #[1028 "\300\301#\207" [lsp-package-ensure grammarly-ls] 8 "\n\n(fn CLIENT CALLBACK ERROR-CALLBACK UPDATE\\=\\?)"] :after-open-fn lsp-grammarly--init :async-request-handlers make-hash-table :test equal puthash "$/getCredentials" lsp-grammarly--get-credentials "$/getToken" lsp-grammarly--get-token "$/storeToken" lsp-grammarly--store-token "$/showError" lsp-grammarly--show-error "$/updateDocumentState" lsp-grammarly--update-document-state] 22) #@30 Start the Grammarly checker. (defalias 'lsp-grammarly-check-grammar #[0 "\300\301\302\303 D\304#\207" [lsp-request-async "$/checkGrammar" :uri lsp--buffer-uri #[257 "\300\301!\207" [message "Start Grammarly checker..."] 3 "\n\n(fn _)"]] 4 (#$ . 8367) nil]) #@29 Stop the Grammarly checker. (defalias 'lsp-grammarly-stop #[0 "\300\301\302\303 D\304#\207" [lsp-request-async "$/stop" :uri lsp--buffer-uri #[257 "\300\301!\207" [message "Stop Grammarly checker..."] 3 "\n\n(fn _)"]] 4 (#$ . 8630) nil]) #@24 Return document state. (defalias 'lsp-grammarly-get-document-state #[0 "\300\301\302\303 D\304#\207" [lsp-request-async "$/getDocumentState" :uri lsp--buffer-uri #[257 "\300\301\302#\300\303\302#\302\300\304\302#\210\300\305\302#\300\306\302#\300\307\302#\300\310\302#\300\311\302#\300\312\n\302#\300\313 \302#\300\314\302#\300\315\302#\300\316\302#\300\317\302#\300\320\302#\321\322 \203^\323\202_\324  \325 !\325 !\325 !\325 !\325 !&\f\207" [gethash "user" nil "isPremium" "isAnonymous" "username" "textInfo" "charsCount" "wordsCount" "readabilityScore" "score" "scores" "Clarity" "Tone" "Correctness" "GeneralScore" "Engagement" message "[User] %s (%s)\n[Text-Info] Readability: %s, C: %s, W: %s\n[Text Score] %s out of 100\nClarity: %s, Tone: %s, Correctness: %s, GeneralScore: %s, Engagement: %s" "Premium" "Free" lsp-grammarly--scale-100] 30 "\n\n(fn STATE)"]] 4 (#$ . 8874) nil]) #@35 Login information, code verifier. (defvar lsp-grammarly--code-verifier nil (#$ . 9800)) #@31 Login information, challenge. (defvar lsp-grammarly--challenge nil (#$ . 9894)) #@21 Key for URI scheme. (defconst lsp-grammarly-client-id "extensionVSCode" (#$ . 9980)) #@42 Handle URI for authentication. (fn URI) (defalias 'lsp-grammarly--resolve-uri #[257 "\300\301\302\"\204 \303\304\302\"\207\305\302\306#\262\307!\262\310\311\"A@\207" [nil string-prefix-p "vscode://znck.grammarly/auth/callback?" user-error "[WARNING] An URL should start with prefix: %s" s-replace "" url-parse-query-string assoc "code"] 6 (#$ . 10071)]) #@40 Refresh the Grammarly.com cookie once. (defalias 'lsp-grammarly--update-cookie #[0 "\300 \210\301\302\303!B\304\302\305!B\306\302\307!B\310\302\311!BF\207" [grammarly--form-cookie csrf-token grammarly--get-cookie-by-name "csrf-token" grauth "grauth" gnar-containerId "gnar_containerId" tdi "tdi"] 6 (#$ . 10439)]) #@76 Callback after resolving URI. Argument CODE is the query string from URI. (defalias 'lsp-grammarly--uri-callback #[0 "\301\302!\303!\304C\304C\304C\304C\304C\305\306\307\"\310\311\312\313B\314B\315\316\317&\320\321& \207" [lsp-grammarly-client-id read-string "[Grammarly Authentication] code: " lsp-grammarly--resolve-uri nil request format "https://auth.grammarly.com/v3/user/oranonymous?app=%s" :type "GET" :headers "x-client-type" (("x-client-version" . "0.0.0")) :success make-closure #[128 "\306\307\310\"\210\306\307\311\"\210\301\312 \240\210\302\313\301\242\236A\240\210\303\314\301\242\236A\240\210\304\315\301\242\236A\240\210\316\317\320\321\322\323\324\325%B\326\327\302\242B\330\304\242B\331\332\333\303\242\302\242#B\257\311\334\335%B\336\300B\337&BE!\340\341\342\301\302\303\304\305&\343\344& \207" [V0 V1 V2 V3 V4 V5 nil plist-member :response :data lsp-grammarly--update-cookie csrf-token grauth gnar-containerId request "https://auth.grammarly.com/v3/api/unified-login/code/exchange" :type "POST" :headers ("Accept" . "application/json") ("Content-Type" . "application/json") "x-client-type" ("x-client-version" . "0.0.0") "x-csrf-token" "x-container-id" "cookie" format "grauth=%s; csrf-token=%s" json-encode "client_id" "code" "code_verifier" :success make-closure #[128 "\306\307\310\"\210\307\311\"A@\300\312 \240\210\301\313\300\242\236A\240\210\302\314\300\242\236A\240\210\303\315\300\242\236A\240\210\304\316\300\242\236A\240\210\317!\211@\320\236A\321\230\322\236A\323\236A\324\325\302\242\301\242\304\242$\326\327B\330B\331BF\332  \333!#\210\3341m\335\306!0\210\202n\210\336\337\"\207" [V0 V1 V2 V3 V4 lsp-grammarly--cookie-key nil plist-member :response :data lsp-grammarly--update-cookie csrf-token grauth gnar-containerId tdi lsp-grammarly--json-read type "Premium" name email format "grauth=%s;csrf-token=%s;tdi=%s;" ("isAnonymous" . :json-false) "isPremium" "token" "username" keytar-set-password lsp-grammarly--json-encode (error) lsp-workspace-restart message "[INFO] Logged in as `%s`" lsp-grammarly--account] 15 "\n\n(fn &key RESPONSE DATA &allow-other-keys)"] :error #[128 "\300\301\302\"\210\303\304\"\207" [nil plist-member :error-thrown lsp-grammarly--message "[ERROR] Error while authenticating login: %s"] 5 "\n\n(fn &rest ARGS &key ERROR-THROWN &allow-other-keys)"] lsp-grammarly-client-id lsp-grammarly--code-verifier] 19 "\n\n(fn &key RESPONSE DATA &allow-other-keys)"] :error #[128 "\300\301\302\"\210\303\304\"\207" [nil plist-member :error-thrown lsp-grammarly--message "[ERROR] Error while getting cookie: %s"] 5 "\n\n(fn &rest ARGS &key ERROR-THROWN &allow-other-keys)"]] 22 (#$ . 10759)]) #@25 Login to Grammarly.com. (defalias 'lsp-grammarly-login #[0 "\303 \210\304 \203\305\306\307 \"\207\310\311\312!\313\"\310\314\315\316\211\313%\313\"\317\320\321\n #!\210\322 \207" [lsp-grammarly--code-verifier lsp-grammarly--challenge lsp-grammarly-client-id keytar--check lsp-grammarly-login-p message "[INFO] You are already logged in with `%s`" lsp-grammarly--username base64url-encode-string lsp-grammarly--random-bytes 96 t secure-hash sha256 nil browse-url format "https://grammarly.com/signin/app?client_id=%s&code_challenge=%s" lsp-grammarly--uri-callback] 7 (#$ . 13448) nil]) #@28 Logout from Grammarly.com. (defalias 'lsp-grammarly-logout #[0 "\304 \210\305 \204\f\306\307!\207\310 \"\203(\311\211\3121#\313\311!0\210\202$\210\306\314!\207\306\315!\207" [lsp-grammarly--cookie-key lsp-grammarly--account lsp-grammarly--password lsp-grammarly--password-string keytar--check lsp-grammarly-login-p message "[INFO] You are already logout from Grammarly.com" keytar-delete-password nil (error) lsp-workspace-restart "[INFO] Logged out of Grammarly.com" "[ERROR] Failed to logout from Grammarly.com"] 4 (#$ . 14044) nil]) (provide 'lsp-grammarly)