qword 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +10 -0
- package/client/qword.js +28 -0
- package/dist/qword.js +2 -0
- package/dist/qword.js.map +1 -0
- package/dist-dev/qword.js +1 -1
- package/package.json +1 -1
package/dist-dev/qword.js
CHANGED
|
@@ -749,7 +749,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
749
749
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
750
750
|
|
|
751
751
|
"use strict";
|
|
752
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Qword)\n/* harmony export */ });\n/* harmony import */ var _css_qword_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../css/qword.css */ \"./css/qword.css\");\n/* harmony import */ var _codemirror_state__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @codemirror/state */ \"./node_modules/@codemirror/state/dist/index.js\");\n/* harmony import */ var _codemirror_view__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @codemirror/view */ \"./node_modules/@codemirror/view/dist/index.js\");\n/* harmony import */ var _codemirror_commands__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @codemirror/commands */ \"./node_modules/@codemirror/commands/dist/index.js\");\n/* harmony import */ var _codemirror_language__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @codemirror/language */ \"./node_modules/@codemirror/language/dist/index.js\");\n/* harmony import */ var _codemirror_theme_one_dark__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @codemirror/theme-one-dark */ \"./node_modules/@codemirror/theme-one-dark/dist/index.js\");\n/* harmony import */ var _codemirror_lang_javascript__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @codemirror/lang-javascript */ \"./node_modules/@codemirror/lang-javascript/dist/index.js\");\n/* harmony import */ var _codemirror_lang_json__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @codemirror/lang-json */ \"./node_modules/@codemirror/lang-json/dist/index.js\");\n/* harmony import */ var _codemirror_lang_html__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @codemirror/lang-html */ \"./node_modules/@codemirror/lang-html/dist/index.js\");\n/* harmony import */ var emitify__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! emitify */ \"./node_modules/emitify/lib/emitify.js\");\n/* harmony import */ var smalltalk__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! smalltalk */ \"./node_modules/smalltalk/lib/smalltalk.js\");\n/* harmony import */ var jssha__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! jssha */ \"./node_modules/jssha/dist/sha.mjs\");\n/* harmony import */ var load_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n/* harmony import */ var daffy__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! daffy */ \"./node_modules/daffy/lib/daffy.js\");\n/* harmony import */ var restafary_client__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! restafary/client */ \"./node_modules/restafary/client/index.js\");\n/* harmony import */ var try_catch__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! try-catch */ \"./node_modules/try-catch/lib/try-catch.js\");\n/* harmony import */ var _replit_codemirror_vim__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! @replit/codemirror-vim */ \"./node_modules/@replit/codemirror-vim/dist/index.js\");\n/* harmony import */ var _story_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./story.js */ \"./client/story.js\");\n/* harmony import */ var _loadremote_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./loadremote.js */ \"./client/loadremote.js\");\n/* harmony import */ var _clipboard_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./_clipboard.js */ \"./client/_clipboard.js\");\n/* harmony import */ var _save_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./save.js */ \"./client/save.js\");\n/* harmony import */ var _init_socket_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./_init-socket.js */ \"./client/_init-socket.js\");\n/* harmony import */ var _on_save_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./_on-save.js */ \"./client/_on-save.js\");\n/* harmony import */ var _show_message_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./show-message.js */ \"./client/show-message.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst isFn = a => typeof a === 'function';\nconst isString = a => typeof a === 'string';\nfunction Qword(el, options = {}, callback = () => {}) {\n if (!(this instanceof Qword)) return new Qword(el, options, callback);\n if (isFn(options)) {\n callback = options;\n options = {};\n }\n this._DIR = '/modules/';\n this._TITLE = 'Qword';\n this._story = (0,_story_js__WEBPACK_IMPORTED_MODULE_17__[\"default\"])();\n this._Separator = '\\n';\n this._isKey = true;\n this._Element = isString(el) ? document.querySelector(el) : el || document.body;\n if (!this._Element) throw Error('Qword: element not found');\n this._maxSize = options.maxSize || 512_000;\n this._PREFIX = options.prefix || '/qword';\n this._prefixSocket = options.prefixSocket || '/qword';\n this._socketPath = options.socketPath || '';\n this._Emitter = emitify__WEBPACK_IMPORTED_MODULE_9__();\n this._view = null;\n this._pendingValue = null;\n this._modeCompartment = new _codemirror_state__WEBPACK_IMPORTED_MODULE_1__.Compartment();\n this._keymapCompartment = new _codemirror_state__WEBPACK_IMPORTED_MODULE_1__.Compartment();\n this._fontCompartment = new _codemirror_state__WEBPACK_IMPORTED_MODULE_1__.Compartment();\n this._langCompartment = new _codemirror_state__WEBPACK_IMPORTED_MODULE_1__.Compartment();\n\n // ✅ FIX: добавили vim compartment\n this._vimCompartment = new _codemirror_state__WEBPACK_IMPORTED_MODULE_1__.Compartment();\n this._Element.addEventListener('drop', this._onDrop.bind(this));\n this._Element.addEventListener('dragover', this._onDragOver.bind(this));\n this._init().then(() => callback(this));\n this._patch = (path, patch) => {\n this._patchHttp(path, patch);\n };\n this._write = (path, result) => {\n this._writeHttp(path, result);\n };\n}\nQword.prototype._init = async function () {\n const prefix = this._PREFIX;\n await Promise.all([(0,_loadremote_js__WEBPACK_IMPORTED_MODULE_18__.loadOptions)(prefix), (0,_loadremote_js__WEBPACK_IMPORTED_MODULE_18__.loadModules)(prefix)]);\n await (0,_loadremote_js__WEBPACK_IMPORTED_MODULE_18__[\"default\"])('socket', {\n prefix: this._socketPath\n });\n restafary_client__WEBPACK_IMPORTED_MODULE_14__.prefix(`${this._PREFIX}/api/v1/fs`);\n this._initEditor();\n if (this._pendingValue !== null) {\n this.setValue(this._pendingValue);\n this._pendingValue = null;\n }\n this._initSocket();\n return this;\n};\nQword.prototype._initEditor = function () {\n const baseExtensions = () => [(0,_codemirror_view__WEBPACK_IMPORTED_MODULE_2__.lineNumbers)(), (0,_codemirror_commands__WEBPACK_IMPORTED_MODULE_3__.history)(), (0,_codemirror_view__WEBPACK_IMPORTED_MODULE_2__.highlightActiveLine)(), (0,_codemirror_language__WEBPACK_IMPORTED_MODULE_4__.syntaxHighlighting)(_codemirror_language__WEBPACK_IMPORTED_MODULE_4__.defaultHighlightStyle), _codemirror_theme_one_dark__WEBPACK_IMPORTED_MODULE_5__.oneDark, this._langCompartment.of((0,_codemirror_lang_javascript__WEBPACK_IMPORTED_MODULE_6__.javascript)()),\n // ✅ FIX: vim теперь через compartment\n this._vimCompartment.of([]), _codemirror_view__WEBPACK_IMPORTED_MODULE_2__.keymap.of([..._codemirror_commands__WEBPACK_IMPORTED_MODULE_3__.defaultKeymap, ..._codemirror_commands__WEBPACK_IMPORTED_MODULE_3__.historyKeymap, {\n key: 'Mod-s',\n run: () => {\n this.save();\n return true;\n }\n }])];\n this._vimEnabled = false;\n const state = _codemirror_state__WEBPACK_IMPORTED_MODULE_1__.EditorState.create({\n doc: '',\n extensions: baseExtensions()\n });\n this._view = new _codemirror_view__WEBPACK_IMPORTED_MODULE_2__.EditorView({\n state,\n parent: this._Element\n });\n this._baseExtensions = baseExtensions;\n};\nQword.prototype.getValue = function () {\n return this._view.state.doc.toString();\n};\nQword.prototype.setValue = function (value) {\n if (!this._view) {\n this._pendingValue = value;\n return this;\n }\n this._view.dispatch({\n changes: {\n from: 0,\n to: this._view.state.doc.length,\n insert: value\n }\n });\n return this;\n};\nQword.prototype.focus = function () {\n this._view.focus();\n return this;\n};\nQword.prototype.getCursor = function () {\n const pos = this._view.state.selection.main.head;\n const line = this._view.state.doc.lineAt(pos);\n return {\n row: line.number - 1,\n column: pos - line.from\n };\n};\nQword.prototype.moveCursorTo = function (row, column = 0) {\n const line = this._view.state.doc.line(row + 1);\n this._view.dispatch({\n selection: {\n anchor: line.from + column\n },\n scrollIntoView: true\n });\n return this;\n};\nQword.prototype.remove = function (direction) {\n const pos = this._view.state.selection.main.head;\n this._view.dispatch({\n changes: direction === 'right' ? {\n from: pos,\n to: pos + 1\n } : {\n from: pos - 1,\n to: pos\n }\n });\n return this;\n};\nQword.prototype.setModeForPath = function (path) {\n const ext = path.split('.').pop();\n let lang = (0,_codemirror_lang_javascript__WEBPACK_IMPORTED_MODULE_6__.javascript)();\n if (ext === 'json') lang = (0,_codemirror_lang_json__WEBPACK_IMPORTED_MODULE_7__.json)();\n if (ext === 'html') lang = (0,_codemirror_lang_html__WEBPACK_IMPORTED_MODULE_8__.html)();\n this._view.dispatch({\n effects: this._langCompartment.reconfigure(lang)\n });\n return this;\n};\nQword.prototype.setValueFirst = function (name, value) {\n this.setModeForPath(name);\n this.setValue(value);\n this._FileName = name;\n this._Value = value;\n this.moveCursorTo(0, 0);\n return this;\n};\nQword.prototype.addKeyMap = function (map) {\n const bindings = Object.entries(map).map(([key, fn]) => ({\n key,\n run: () => {\n fn.call(this);\n return true;\n }\n }));\n this._view.dispatch({\n effects: this._keymapCompartment.reconfigure(_codemirror_view__WEBPACK_IMPORTED_MODULE_2__.keymap.of(bindings))\n });\n return this;\n};\nQword.prototype.on = function (event, fn) {\n this._Emitter.on(event, fn);\n return this;\n};\nQword.prototype.emit = function (...args) {\n this._Emitter.emit(...args);\n return this;\n};\nQword.prototype.isChanged = function () {\n return this.getValue() !== this._Value;\n};\nQword.prototype._diff = function (newValue) {\n return (0,daffy__WEBPACK_IMPORTED_MODULE_13__.createPatch)(this._Value || '', newValue);\n};\nQword.prototype._patchHttp = function (path, patch) {\n restafary_client__WEBPACK_IMPORTED_MODULE_14__.patch(path, patch, this._onSave.bind(this));\n};\nQword.prototype._writeHttp = function (path, result) {\n restafary_client__WEBPACK_IMPORTED_MODULE_14__.write(path, result, this._onSave.bind(this));\n};\nQword.prototype.evaluate = function () {\n if (!this._FileName?.endsWith('.js')) return smalltalk__WEBPACK_IMPORTED_MODULE_10__.alert(this._TITLE, 'JS only');\n const [e] = (0,try_catch__WEBPACK_IMPORTED_MODULE_15__.tryCatch)(new Function(this.getValue()));\n if (e) smalltalk__WEBPACK_IMPORTED_MODULE_10__.alert(this._TITLE, e.message);\n return this;\n};\nQword.prototype.goToLine = function () {\n const num = Number(prompt('Line number'));\n if (!num) return;\n const line = this._view.state.doc.line(num);\n this._view.dispatch({\n selection: {\n anchor: line.from\n },\n scrollIntoView: true\n });\n this.focus();\n};\nQword.prototype._clipboard = _clipboard_js__WEBPACK_IMPORTED_MODULE_19__[\"default\"];\nQword.prototype.save = _save_js__WEBPACK_IMPORTED_MODULE_20__[\"default\"];\nQword.prototype._onSave = _on_save_js__WEBPACK_IMPORTED_MODULE_22__[\"default\"];\nQword.prototype._initSocket = _init_socket_js__WEBPACK_IMPORTED_MODULE_21__[\"default\"];\nQword.prototype._onDragOver = function (event) {\n event.preventDefault();\n event.dataTransfer.dropEffect = 'copy';\n};\nQword.prototype._onDrop = function (event) {\n event.preventDefault();\n const [file] = event.dataTransfer.files;\n if (!file) return;\n const reader = new FileReader();\n reader.onload = e => {\n this.setValue(e.target.result);\n };\n reader.readAsText(file);\n};\nQword.prototype.sha = function () {\n const shaObj = new jssha__WEBPACK_IMPORTED_MODULE_11__[\"default\"]('SHA-1', 'TEXT');\n shaObj.update(this.getValue());\n return shaObj.getHash('HEX');\n};\nQword.prototype.setOptions = function (options) {\n const theme = _codemirror_view__WEBPACK_IMPORTED_MODULE_2__.EditorView.theme({\n '&': {\n fontSize: options.fontSize,\n fontFamily: options.fontFamily\n }\n });\n this._view.dispatch({\n effects: this._fontCompartment.reconfigure(theme)\n });\n return this;\n};\nQword.prototype.showMessage = _show_message_js__WEBPACK_IMPORTED_MODULE_23__[\"default\"];\nQword.prototype.setKeyMap = function (mode) {\n this._vimEnabled = mode === 'vim';\n this._view.dispatch({\n effects: this._vimCompartment.reconfigure(this._vimEnabled ? (0,_replit_codemirror_vim__WEBPACK_IMPORTED_MODULE_16__.vim)() : [])\n });\n return this;\n};\n\n//# sourceURL=file://qword/client/qword.js\n}");
|
|
752
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Qword)\n/* harmony export */ });\n/* harmony import */ var _css_qword_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../css/qword.css */ \"./css/qword.css\");\n/* harmony import */ var _codemirror_state__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @codemirror/state */ \"./node_modules/@codemirror/state/dist/index.js\");\n/* harmony import */ var _codemirror_view__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @codemirror/view */ \"./node_modules/@codemirror/view/dist/index.js\");\n/* harmony import */ var _codemirror_commands__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @codemirror/commands */ \"./node_modules/@codemirror/commands/dist/index.js\");\n/* harmony import */ var _codemirror_language__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @codemirror/language */ \"./node_modules/@codemirror/language/dist/index.js\");\n/* harmony import */ var _codemirror_theme_one_dark__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @codemirror/theme-one-dark */ \"./node_modules/@codemirror/theme-one-dark/dist/index.js\");\n/* harmony import */ var _codemirror_lang_javascript__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @codemirror/lang-javascript */ \"./node_modules/@codemirror/lang-javascript/dist/index.js\");\n/* harmony import */ var _codemirror_lang_json__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @codemirror/lang-json */ \"./node_modules/@codemirror/lang-json/dist/index.js\");\n/* harmony import */ var _codemirror_lang_html__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @codemirror/lang-html */ \"./node_modules/@codemirror/lang-html/dist/index.js\");\n/* harmony import */ var emitify__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! emitify */ \"./node_modules/emitify/lib/emitify.js\");\n/* harmony import */ var smalltalk__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! smalltalk */ \"./node_modules/smalltalk/lib/smalltalk.js\");\n/* harmony import */ var jssha__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! jssha */ \"./node_modules/jssha/dist/sha.mjs\");\n/* harmony import */ var load_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n/* harmony import */ var daffy__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! daffy */ \"./node_modules/daffy/lib/daffy.js\");\n/* harmony import */ var restafary_client__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! restafary/client */ \"./node_modules/restafary/client/index.js\");\n/* harmony import */ var try_catch__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! try-catch */ \"./node_modules/try-catch/lib/try-catch.js\");\n/* harmony import */ var _replit_codemirror_vim__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! @replit/codemirror-vim */ \"./node_modules/@replit/codemirror-vim/dist/index.js\");\n/* harmony import */ var try_to_catch__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n/* harmony import */ var _story_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./story.js */ \"./client/story.js\");\n/* harmony import */ var _loadremote_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./loadremote.js */ \"./client/loadremote.js\");\n/* harmony import */ var _clipboard_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./_clipboard.js */ \"./client/_clipboard.js\");\n/* harmony import */ var _save_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./save.js */ \"./client/save.js\");\n/* harmony import */ var _init_socket_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./_init-socket.js */ \"./client/_init-socket.js\");\n/* harmony import */ var _on_save_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./_on-save.js */ \"./client/_on-save.js\");\n/* harmony import */ var _show_message_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./show-message.js */ \"./client/show-message.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst noop = () => {};\nconst isFn = a => typeof a === 'function';\nconst isString = a => typeof a === 'string';\nfunction Qword(el, options = {}, callback = noop) {\n if (!(this instanceof Qword)) return new Qword(el, options, callback);\n if (isFn(options)) {\n callback = options;\n options = {};\n }\n this._DIR = '/modules/';\n this._TITLE = 'Qword';\n this._story = (0,_story_js__WEBPACK_IMPORTED_MODULE_18__[\"default\"])();\n this._Separator = '\\n';\n this._isKey = true;\n this._Element = isString(el) ? document.querySelector(el) : el || document.body;\n if (!this._Element) throw Error('Qword: element not found');\n this._maxSize = options.maxSize || 512_000;\n this._PREFIX = options.prefix || '/qword';\n this._prefixSocket = options.prefixSocket || '/qword';\n this._socketPath = options.socketPath || '';\n this._Emitter = emitify__WEBPACK_IMPORTED_MODULE_9__();\n this._view = null;\n this._pendingValue = null;\n this._modeCompartment = new _codemirror_state__WEBPACK_IMPORTED_MODULE_1__.Compartment();\n this._keymapCompartment = new _codemirror_state__WEBPACK_IMPORTED_MODULE_1__.Compartment();\n this._fontCompartment = new _codemirror_state__WEBPACK_IMPORTED_MODULE_1__.Compartment();\n this._langCompartment = new _codemirror_state__WEBPACK_IMPORTED_MODULE_1__.Compartment();\n // ✅ FIX: добавили vim compartment\n this._vimCompartment = new _codemirror_state__WEBPACK_IMPORTED_MODULE_1__.Compartment();\n this._Element.addEventListener('drop', this._onDrop.bind(this));\n this._Element.addEventListener('dragover', this._onDragOver.bind(this));\n this._init().then(() => callback(this));\n this._patch = (path, patch) => {\n this._patchHttp(path, patch);\n };\n this._write = (path, result) => {\n this._writeHttp(path, result);\n };\n}\nQword.prototype._init = async function () {\n const prefix = this._PREFIX;\n const [error, config] = await (0,try_to_catch__WEBPACK_IMPORTED_MODULE_17__.tryToCatch)(load_js__WEBPACK_IMPORTED_MODULE_12__.json, this._PREFIX + '/edit.json');\n if (error) return smalltalk__WEBPACK_IMPORTED_MODULE_10__.alert(this._TITLE, 'Could not load edit.json!');\n this._Config = config;\n await Promise.all([(0,_loadremote_js__WEBPACK_IMPORTED_MODULE_19__.loadOptions)(prefix), (0,_loadremote_js__WEBPACK_IMPORTED_MODULE_19__.loadModules)(prefix)]);\n await (0,_loadremote_js__WEBPACK_IMPORTED_MODULE_19__[\"default\"])('socket', {\n prefix: this._socketPath\n });\n restafary_client__WEBPACK_IMPORTED_MODULE_14__.prefix(`${this._PREFIX}/api/v1/fs`);\n this._initEditor();\n if (this._pendingValue !== null) {\n this.setValue(this._pendingValue);\n this._pendingValue = null;\n }\n this._initSocket();\n return this;\n};\nQword.prototype._initEditor = function () {\n this._Element.style.height = '100vh';\n const baseExtensions = () => [(0,_codemirror_view__WEBPACK_IMPORTED_MODULE_2__.lineNumbers)(), (0,_codemirror_commands__WEBPACK_IMPORTED_MODULE_3__.history)(), (0,_codemirror_view__WEBPACK_IMPORTED_MODULE_2__.highlightActiveLine)(), (0,_codemirror_language__WEBPACK_IMPORTED_MODULE_4__.syntaxHighlighting)(_codemirror_language__WEBPACK_IMPORTED_MODULE_4__.defaultHighlightStyle), _codemirror_theme_one_dark__WEBPACK_IMPORTED_MODULE_5__.oneDark, this._langCompartment.of((0,_codemirror_lang_javascript__WEBPACK_IMPORTED_MODULE_6__.javascript)()),\n // ✅ FIX: vim теперь через compartment\n this._vimCompartment.of([]), _codemirror_view__WEBPACK_IMPORTED_MODULE_2__.keymap.of([..._codemirror_commands__WEBPACK_IMPORTED_MODULE_3__.defaultKeymap, ..._codemirror_commands__WEBPACK_IMPORTED_MODULE_3__.historyKeymap, {\n key: 'Mod-s',\n run: () => {\n this.save();\n return true;\n }\n }])];\n this._vimEnabled = false;\n const state = _codemirror_state__WEBPACK_IMPORTED_MODULE_1__.EditorState.create({\n doc: '',\n extensions: baseExtensions()\n });\n this._view = new _codemirror_view__WEBPACK_IMPORTED_MODULE_2__.EditorView({\n state,\n parent: this._Element\n });\n this._baseExtensions = baseExtensions;\n};\nQword.prototype.getValue = function () {\n return this._view.state.doc.toString();\n};\nQword.prototype.setValue = function (value) {\n if (!this._view) {\n this._pendingValue = value;\n return this;\n }\n this._view.dispatch({\n changes: {\n from: 0,\n to: this._view.state.doc.length,\n insert: value\n }\n });\n return this;\n};\nQword.prototype.focus = function () {\n this._view.focus();\n return this;\n};\nQword.prototype.getCursor = function () {\n const pos = this._view.state.selection.main.head;\n const line = this._view.state.doc.lineAt(pos);\n return {\n row: line.number - 1,\n column: pos - line.from\n };\n};\nQword.prototype.moveCursorTo = function (row, column = 0) {\n const line = this._view.state.doc.line(row + 1);\n this._view.dispatch({\n selection: {\n anchor: line.from + column\n },\n scrollIntoView: true\n });\n return this;\n};\nQword.prototype.remove = function (direction) {\n const pos = this._view.state.selection.main.head;\n this._view.dispatch({\n changes: direction === 'right' ? {\n from: pos,\n to: pos + 1\n } : {\n from: pos - 1,\n to: pos\n }\n });\n return this;\n};\nQword.prototype.setModeForPath = function (path) {\n const ext = path.split('.').pop();\n let lang = (0,_codemirror_lang_javascript__WEBPACK_IMPORTED_MODULE_6__.javascript)();\n if (ext === 'json') lang = (0,_codemirror_lang_json__WEBPACK_IMPORTED_MODULE_7__.json)();\n if (ext === 'html') lang = (0,_codemirror_lang_html__WEBPACK_IMPORTED_MODULE_8__.html)();\n this._view.dispatch({\n effects: this._langCompartment.reconfigure(lang)\n });\n return this;\n};\nQword.prototype.setValueFirst = function (name, value) {\n this.setModeForPath(name);\n this.setValue(value);\n this._FileName = name;\n this._Value = value;\n this.moveCursorTo(0, 0);\n return this;\n};\nQword.prototype.addKeyMap = function (map) {\n const bindings = Object.entries(map).map(([key, fn]) => ({\n key,\n run: () => {\n fn.call(this);\n return true;\n }\n }));\n this._view.dispatch({\n effects: this._keymapCompartment.reconfigure(_codemirror_view__WEBPACK_IMPORTED_MODULE_2__.keymap.of(bindings))\n });\n return this;\n};\nQword.prototype.on = function (event, fn) {\n this._Emitter.on(event, fn);\n return this;\n};\nQword.prototype.emit = function (...args) {\n this._Emitter.emit(...args);\n return this;\n};\nQword.prototype.isChanged = function () {\n return this.getValue() !== this._Value;\n};\nQword.prototype._diff = function (newValue) {\n return (0,daffy__WEBPACK_IMPORTED_MODULE_13__.createPatch)(this._Value || '', newValue);\n};\nQword.prototype._patchHttp = function (path, patch) {\n restafary_client__WEBPACK_IMPORTED_MODULE_14__.patch(path, patch, this._onSave.bind(this));\n};\nQword.prototype._writeHttp = function (path, result) {\n restafary_client__WEBPACK_IMPORTED_MODULE_14__.write(path, result, this._onSave.bind(this));\n};\nQword.prototype.evaluate = function () {\n if (!this._FileName?.endsWith('.js')) return smalltalk__WEBPACK_IMPORTED_MODULE_10__.alert(this._TITLE, 'JS only');\n const [e] = (0,try_catch__WEBPACK_IMPORTED_MODULE_15__.tryCatch)(new Function(this.getValue()));\n if (e) smalltalk__WEBPACK_IMPORTED_MODULE_10__.alert(this._TITLE, e.message);\n return this;\n};\nQword.prototype.goToLine = function () {\n const num = Number(prompt('Line number'));\n if (!num) return;\n const line = this._view.state.doc.line(num);\n this._view.dispatch({\n selection: {\n anchor: line.from\n },\n scrollIntoView: true\n });\n this.focus();\n};\nQword.prototype._clipboard = _clipboard_js__WEBPACK_IMPORTED_MODULE_20__[\"default\"];\nQword.prototype.save = _save_js__WEBPACK_IMPORTED_MODULE_21__[\"default\"];\nQword.prototype._onSave = _on_save_js__WEBPACK_IMPORTED_MODULE_23__[\"default\"];\nQword.prototype._initSocket = _init_socket_js__WEBPACK_IMPORTED_MODULE_22__[\"default\"];\nQword.prototype._onDragOver = function (event) {\n event.preventDefault();\n event.dataTransfer.dropEffect = 'copy';\n};\nQword.prototype._onDrop = function (event) {\n event.preventDefault();\n const [file] = event.dataTransfer.files;\n if (!file) return;\n const reader = new FileReader();\n reader.onload = e => {\n this.setValue(e.target.result);\n };\n reader.readAsText(file);\n};\nQword.prototype.sha = function () {\n const shaObj = new jssha__WEBPACK_IMPORTED_MODULE_11__[\"default\"]('SHA-1', 'TEXT');\n shaObj.update(this.getValue());\n return shaObj.getHash('HEX');\n};\nQword.prototype.setOption = function (name, value) {\n const {\n _Ace\n } = this;\n const preventOverwrite = () => {\n this._Config.options[name] = value;\n };\n preventOverwrite();\n if (name === 'keyMap') this.setKeyMap(value);\n return this;\n};\nQword.prototype.setOptions = function (options) {\n const theme = _codemirror_view__WEBPACK_IMPORTED_MODULE_2__.EditorView.theme({\n '&': {\n fontSize: options.fontSize,\n fontFamily: options.fontFamily\n }\n });\n this._view.dispatch({\n effects: this._fontCompartment.reconfigure(theme)\n });\n return this;\n};\nQword.prototype.showMessage = _show_message_js__WEBPACK_IMPORTED_MODULE_24__[\"default\"];\nQword.prototype.setKeyMap = function (mode) {\n this._vimEnabled = mode === 'vim';\n this._view.dispatch({\n effects: this._vimCompartment.reconfigure(this._vimEnabled ? (0,_replit_codemirror_vim__WEBPACK_IMPORTED_MODULE_16__.vim)() : [])\n });\n return this;\n};\nQword.prototype._loadOptions = async function () {\n const url = this._PREFIX + '/options.json';\n if (this._Options) return this._Options;\n const data = await load_js__WEBPACK_IMPORTED_MODULE_12__.json(url);\n this._Options = data;\n return data;\n};\nQword.prototype.enableKey = function () {\n this._isKey = true;\n return this;\n};\n\n//# sourceURL=file://qword/client/qword.js\n}");
|
|
753
753
|
|
|
754
754
|
/***/ },
|
|
755
755
|
|