From 17d1247744cd3ec65e56e7d0e8b4a61ae867789a Mon Sep 17 00:00:00 2001 From: Cromefire_ Date: Sun, 21 Jul 2024 17:29:43 +0200 Subject: [PATCH] Made some initial steps towards jvm compatibility --- buildSrc/src/main/kotlin/Shared.kt | 30 +++- .../src/webMain/kotlin/example/main.kt | 2 +- .../playground/src/commonMain/kotlin/main.kt | 32 ++--- .../kotlin/io/realworld/ConduitManager.kt | 11 +- .../kotlin/io/realworld/externals/Date.kt | 2 +- .../io/realworld/layout/users/Editor.kt | 3 +- .../kotlin/io/realworld/layout/users/Login.kt | 3 +- .../io/realworld/layout/users/Register.kt | 3 +- .../io/realworld/layout/users/Settings.kt | 3 +- .../src/commonMain/kotlin/TodoApp.kt | 11 +- .../src/commonMain/kotlin/TodoModule.kt | 2 +- .../kotlin/TodoSavedStateAdapter.kt | 4 +- .../todomvc/src/commonMain/kotlin/TodoApp.kt | 11 +- .../src/commonMain/kotlin/TodoViewModel.kt | 4 +- gradle/libs.versions.toml | 2 +- kilua/build.gradle.kts | 30 ++-- .../kotlin/dev/kilua/Application.kt | 2 +- .../commonMain/kotlin/dev/kilua/Coroutines.kt | 20 --- .../dev/kilua/compose/NonDisposableRoot.kt | 8 +- .../dev/kilua/compose/PromiseDispatcher.kt | 2 +- .../kotlin/dev/kilua/compose/Root.kt | 4 +- .../kotlin/dev/kilua/core/ComponentBase.kt | 10 +- .../kotlin/dev/kilua/core/SafeDomFactory.kt | 8 +- .../kotlin/dev/kilua/externals/Array.kt | 8 +- .../kotlin/dev/kilua/externals/Console.kt | 2 +- .../kotlin/dev/kilua/externals/Event.kt | 6 +- .../kotlin/dev/kilua/externals/Intl.kt | 2 +- .../kotlin/dev/kilua/externals/JSON.kt | 2 +- .../kotlin/dev/kilua/externals/NodeJsDom.kt | 6 +- .../kotlin/dev/kilua/externals/Object.kt | 2 +- .../commonMain/kotlin/dev/kilua/form/Form.kt | 10 +- .../commonMain/kotlin/dev/kilua/form/Input.kt | 5 +- .../commonMain/kotlin/dev/kilua/form/Mask.kt | 2 +- .../dev/kilua/form/check/AbstractCheck.kt | 7 +- .../dev/kilua/form/check/TriStateCheckBox.kt | 5 +- .../kotlin/dev/kilua/form/number/Numeric.kt | 3 +- .../kotlin/dev/kilua/form/select/Select.kt | 2 +- .../kotlin/dev/kilua/form/text/TextArea.kt | 2 +- .../kotlin/dev/kilua/form/upload/Upload.kt | 6 +- .../kotlin/dev/kilua/html/Button.kt | 5 +- .../kotlin/dev/kilua/html/Canvas.kt | 4 +- .../kotlin/dev/kilua/html/CommentNode.kt | 2 +- .../kotlin/dev/kilua/html/HtmlTags.kt | 2 +- .../kotlin/dev/kilua/html/Iframe.kt | 2 +- .../commonMain/kotlin/dev/kilua/html/Img.kt | 2 +- .../commonMain/kotlin/dev/kilua/html/Label.kt | 2 +- .../commonMain/kotlin/dev/kilua/html/Link.kt | 2 +- .../commonMain/kotlin/dev/kilua/html/Ol.kt | 2 +- .../kotlin/dev/kilua/html/Optgroup.kt | 2 +- .../kotlin/dev/kilua/html/Option.kt | 2 +- .../commonMain/kotlin/dev/kilua/html/Tag.kt | 2 +- .../commonMain/kotlin/dev/kilua/html/Td.kt | 2 +- .../kotlin/dev/kilua/html/TextNode.kt | 2 +- .../commonMain/kotlin/dev/kilua/html/Th.kt | 2 +- .../kotlin/dev/kilua/html/helpers/TagAttrs.kt | 2 +- .../kilua/html/helpers/TagAttrsDelegate.kt | 2 +- .../dev/kilua/html/helpers/TagAttrsFun.kt | 2 +- .../kotlin/dev/kilua/html/helpers/TagDnd.kt | 4 +- .../dev/kilua/html/helpers/TagDndDelegate.kt | 4 +- .../dev/kilua/html/helpers/TagEvents.kt | 51 ++++--- .../kilua/html/helpers/TagEventsDelegate.kt | 61 ++++---- .../kilua/html/helpers/TagEventsSuspending.kt | 21 ++- .../kotlin/dev/kilua/html/helpers/TagStyle.kt | 2 +- .../kilua/html/helpers/TagStyleDelegate.kt | 2 +- .../dev/kilua/html/helpers/TagStyleFun.kt | 2 +- .../kotlin/dev/kilua/html/style/CssStyle.kt | 2 +- .../kotlin/dev/kilua/html/style/Style.kt | 2 +- .../kotlin/dev/kilua/i18n/DefaultLocale.kt | 2 +- .../commonMain/kotlin/dev/kilua/utils/File.kt | 4 +- .../kotlin/dev/kilua/utils/JavaScript.kt | 33 +++-- .../kotlin/dev/kilua/utils/Serialization.kt | 2 +- .../dev/kilua/compose/ComponentApplierSpec.kt | 4 +- .../kotlin/dev/kilua/html/CanvasSpec.kt | 5 +- .../jsMain/kotlin/dev/kilua/Coroutines.js.kt | 6 +- .../kotlin/dev/kilua/externals/Array.js.kt | 5 +- .../kotlin/dev/kilua/externals/Event.js.kt | 6 +- .../dev/kilua/externals/NodeJsDom.js.kt | 6 +- .../kotlin/dev/kilua/externals/Object.js.kt | 2 +- .../kotlin/dev/kilua/utils/JavaScript.js.kt | 2 +- .../kotlin/dev/kilua/compose/Root.jvm.kt | 5 + .../kotlin/dev/kilua/Coroutines.wasmJs.kt | 4 +- .../dev/kilua/externals/Array.wasmJs.kt | 4 +- .../dev/kilua/externals/Event.wasmJs.kt | 6 +- .../dev/kilua/externals/NodeJsDom.wasmJs.kt | 6 +- .../dev/kilua/externals/Object.wasmJs.kt | 2 +- .../kotlin/dev/kilua/Coroutines.web.kt | 22 +++ .../kotlin/dev/kilua/HMR.kt | 2 +- .../kotlin/dev/kilua/BootstrapIconsModule.kt | 2 +- .../kotlin/dev/kilua/BootstrapCssModule.kt | 2 +- .../kotlin/dev/kilua/BootstrapModule.kt | 2 +- .../kotlin/dev/kilua/externals/Bootstrap.kt | 4 +- .../kotlin/dev/kilua/modal/Alert.kt | 5 +- .../kotlin/dev/kilua/modal/Confirm.kt | 5 +- .../kotlin/dev/kilua/modal/Modal.kt | 5 +- .../kotlin/dev/kilua/panel/Accordion.kt | 2 +- .../kotlin/dev/kilua/panel/Carousel.kt | 2 +- .../kotlin/dev/kilua/panel/Offcanvas.kt | 5 +- .../kotlin/dev/kilua/panel/TabPanel.kt | 4 +- .../kotlin/dev/kilua/theme/ThemeManager.kt | 8 +- .../kotlin/dev/kilua/toast/Toast.kt | 3 +- .../kotlin/dev/kilua/modal/ModalSpec.kt | 2 +- modules/kilua-core-modules/build.gradle.kts | 29 +++- .../commonMain/kotlin/dev/kilua/AppContext.kt | 14 ++ .../commonMain/kotlin/dev/kilua/CoreModule.kt | 13 +- .../kotlin/dev/kilua/CssRegister.kt | 15 +- .../kotlin/dev/kilua/CoreModule.jsCommon.kt | 16 +++ .../kotlin/dev/kilua/CssRegister.jsCommon.kt | 18 +++ .../kotlin/dev/kilua/CoreModule.jvm.kt | 8 ++ .../kotlin/dev/kilua/CssRegister.jvm.kt | 26 ++++ modules/kilua-dom-core/build.gradle.kts | 57 ++++++++ .../kotlin/dev/kilua/dom/core}/JsAny.kt | 6 +- .../kotlin/dev/kilua/dom/core}/JsArray.kt | 5 +- .../kotlin/dev/kilua/dom/core}/JsBoolean.kt | 7 +- .../kotlin/dev/kilua/dom/core}/JsNumber.kt | 7 +- .../kotlin/dev/kilua/dom/core}/JsString.kt | 5 +- .../kotlin/dev/kilua/dom/core/Promise.kt | 20 +++ .../kotlin/dev/kilua/dom/core}/RegExp.kt | 5 +- .../kotlin/dev/kilua/dom/core/JsAny.kt | 3 + .../kotlin/dev/kilua/dom/core}/JsArray.js.kt | 4 +- .../dev/kilua/dom/core}/JsBoolean.js.kt | 2 +- .../kotlin/dev/kilua/dom/core}/JsNumber.js.kt | 2 +- .../kotlin/dev/kilua/dom/core}/JsString.js.kt | 2 +- .../kotlin/dev/kilua/dom/core}/Promise.js.kt | 19 +-- .../kotlin/dev/kilua/dom/core}/RegExp.js.kt | 2 +- .../kotlin/dev/kilua/dom/core/JsAny.jvm.kt | 3 + .../kotlin/dev/kilua/dom/core/JsArray.jvm.kt | 17 +++ .../dev/kilua/dom/core/JsBoolean.jvm.kt | 7 + .../kotlin/dev/kilua/dom/core/JsNumber.jvm.kt | 11 ++ .../kotlin/dev/kilua/dom/core/JsString.jvm.kt | 5 + .../kotlin/dev/kilua/dom/core/Promise.jvm.kt | 130 ++++++++++++++++++ .../kotlin/dev/kilua/dom/core/RegExp.jvm.kt | 8 ++ .../dev/kilua/dom/core}/JsArray.wasmJs.kt | 2 +- .../dev/kilua/dom/core}/JsBoolean.wasmJs.kt | 2 +- .../dev/kilua/dom/core}/JsNumber.wasmJs.kt | 27 ++-- .../dev/kilua/dom/core}/JsString.wasmJs.kt | 2 +- .../dev/kilua/dom/core}/Promise.wasmJs.kt | 19 ++- .../dev/kilua/dom/core}/RegExp.wasmJs.kt | 4 +- modules/kilua-dom/build.gradle.kts | 8 +- .../src/commonMain/kotlin/web/Promise.kt | 26 ---- .../kotlin/dev/kilua/dom}/Mutations.kt | 6 +- .../kotlin/dev/kilua/dom/api}/Dom.kt | 51 ++++--- .../dev/kilua/dom/api}/ItemArrayLike.kt | 4 +- .../dev/kilua/dom/api}/clipboard/Clipboard.kt | 16 +-- .../kotlin/dev/kilua/dom/api}/css/Css.kt | 10 +- .../dom/api}/encryptedmedia/Encryptedmedia.kt | 22 +-- .../dev/kilua/dom/api}/events/Events.kt | 12 +- .../dom/api}/mediacapture/Mediacapture.kt | 22 +-- .../kilua/dom/api}/mediasource/Mediasource.kt | 18 +-- .../api}/observers/IntersectionObserver.kt | 12 +- .../observers/IntersectionObserverCallback.kt | 4 +- .../observers/IntersectionObserverEntry.kt | 10 +- .../IntersectionObserverEntryInit.kt | 10 +- .../observers/IntersectionObserverInit.kt | 10 +- .../dev/kilua/dom/api}/parsing/Parsing.kt | 10 +- .../dom/api}/pointerevents/Pointerevents.kt | 8 +- .../kotlin/dev/kilua/dom/api}/svg/Svg.kt | 12 +- .../kotlin/dev/kilua/dom/api}/url/Url.kt | 14 +- .../dev/kilua/dom}/css/masking/Masking.kt | 16 +-- .../kotlin/dev/kilua/dom/dom.kt} | 6 +- .../kotlin/dev/kilua/dom}/fetch/Fetch.kt | 6 +- .../kotlin/dev/kilua/dom}/files/Files.kt | 22 +-- .../kilua/dom}/notifications/Notifications.kt | 22 +-- .../dev/kilua/dom}/performance/Performance.kt | 10 +- .../kotlin/dev/kilua/dom}/webgl/Webgl.kt | 20 +-- .../kotlin/dev/kilua/dom}/workers/Workers.kt | 38 ++--- .../kotlin/dev/kilua/dom}/xhr/Xhr.kt | 24 ++-- .../src/jsMain/kotlin/web/JsAny.js.kt | 25 ---- .../src/wasmJsMain/kotlin/web/JsAny.wasmJs.kt | 25 ---- .../kotlin/dev/kilua/FontAwesomeModule.kt | 2 +- .../commonMain/kotlin/dev/kilua/i18n/I18n.kt | 2 +- .../kotlin/dev/kilua/externals/ImaskJs.kt | 13 +- .../kotlin/dev/kilua/form/ImaskFactory.kt | 2 +- .../kotlin/dev/kilua/form/ImaskOptions.kt | 10 +- .../kotlin/dev/kilua/form/Number.kt | 2 +- .../jsMain/kotlin/dev/kilua/form/Number.js.kt | 2 +- .../kotlin/dev/kilua/form/Number.wasmJs.kt | 2 +- .../dev/kilua/panel/VisibilityDetector.kt | 3 +- .../kotlin/dev/kilua/externals/MarkedJs.kt | 2 +- .../kotlin/dev/kilua/marked/Marked.kt | 2 +- .../commonMain/kotlin/dev/kilua/rest/Fetch.kt | 6 +- .../kotlin/dev/kilua/rest/RestClient.kt | 14 +- .../softwork/routingcompose/BrowserRouter.kt | 4 +- .../app/softwork/routingcompose/HashRouter.kt | 2 +- .../dev/kilua/externals/RsupProgress.kt | 4 +- .../kotlin/dev/kilua/progress/Progress.kt | 4 +- .../dev/kilua/externals/SanitizeHtmlJs.kt | 15 +- .../kotlin/dev/kilua/sanitize/SanitizeHtml.kt | 8 +- .../dev/kilua/form/select/SelectRemote.kt | 2 +- .../dev/kilua/form/select/SelectRemote.js.kt | 2 +- .../kilua/form/select/SelectRemote.wasmJs.kt | 4 +- .../kotlin/dev/kilua/SplitjsModule.kt | 2 +- .../kotlin/dev/kilua/externals/SplitJs.kt | 4 +- .../kotlin/dev/kilua/panel/SplitPanel.kt | 2 +- .../kotlin/dev/kilua/externals/SplitJs.js.kt | 4 +- .../kotlin/dev/kilua/externals/SplitJs.kt | 2 +- .../dev/kilua/externals/SplitJs.wasmJs.kt | 2 +- .../kotlin/dev/kilua/ssr/NodeHttp.kt | 2 +- .../kotlin/dev/kilua/ssr/NodeProcess.kt | 7 +- .../kotlin/dev/kilua/ssr/SsrRouter.kt | 4 +- .../kotlin/dev/kilua/ssr/SsrState.kt | 2 +- .../kotlin/dev/kilua/svg/ISvgTag.kt | 2 +- .../commonMain/kotlin/dev/kilua/svg/SvgTag.kt | 2 +- .../dev/kilua/tabulator/TabulatorRemote.kt | 7 +- .../dev/kilua/tabulator/TabulatorRemote.js.kt | 7 +- .../kilua/tabulator/TabulatorRemote.wasmJs.kt | 8 +- .../kotlin/dev/kilua/TabulatorBulmaModule.kt | 2 +- .../dev/kilua/TabulatorDefaultModule.kt | 2 +- .../dev/kilua/TabulatorMaterializeModule.kt | 2 +- .../dev/kilua/TabulatorMidnightModule.kt | 2 +- .../kotlin/dev/kilua/TabulatorModernModule.kt | 2 +- .../kotlin/dev/kilua/TabulatorModule.kt | 2 +- .../dev/kilua/TabulatorSemanticUIModule.kt | 2 +- .../kotlin/dev/kilua/TabulatorSimpleModule.kt | 2 +- .../dev/kilua/TabulatorSiteDarkModule.kt | 2 +- .../dev/kilua/externals/CellComponentBase.kt | 4 +- .../kotlin/dev/kilua/externals/Interop.kt | 14 +- .../kotlin/dev/kilua/externals/TabulatorJs.kt | 58 ++++---- .../dev/kilua/externals/TabulatorMenuItem.kt | 7 +- .../dev/kilua/externals/TabulatorTablesJs.kt | 4 +- .../kotlin/dev/kilua/tabulator/Options.kt | 39 +++--- .../kotlin/dev/kilua/tabulator/Tabulator.kt | 19 ++- .../kotlin/dev/kilua/externals/Interop.js.kt | 14 +- .../dev/kilua/externals/Interop.wasmJs.kt | 11 +- .../kotlin/dev/kilua/TailwindcssModule.kt | 2 +- .../kotlin/dev/kilua/theme/ThemeManager.kt | 8 +- .../kotlin/dev/kilua/TempusDominusModule.kt | 2 +- .../kotlin/dev/kilua/externals/Date.kt | 8 +- .../kotlin/dev/kilua/externals/Locales.kt | 2 +- .../dev/kilua/externals/TempusDominus.kt | 13 +- .../kilua/form/time/AbstractRichDateTime.kt | 10 +- .../kotlin/dev/kilua/form/time/RichDate.kt | 5 +- .../dev/kilua/form/time/RichDateTime.kt | 5 +- .../kotlin/dev/kilua/form/time/RichTime.kt | 5 +- modules/kilua-testutils/build.gradle.kts | 17 ++- .../kotlin/dev/kilua/test/HtmlDiffer.kt | 2 +- .../kotlin/dev/kilua/test/TestUtil.kt | 6 +- .../kotlin/dev/kilua/ToastifyModule.kt | 2 +- .../kotlin/dev/kilua/externals/Toastify.kt | 2 +- .../dev/kilua/form/select/TomSelectRemote.kt | 9 +- .../dev/kilua/form/text/TomTypeaheadRemote.kt | 11 +- .../kilua/form/select/TomSelectRemote.js.kt | 2 +- .../kilua/form/text/TomTypeaheadRemote.js.kt | 2 +- .../form/select/TomSelectRemote.wasmJs.kt | 4 +- .../form/text/TomTypeaheadRemote.wasmJs.kt | 4 +- .../dev/kilua/TomSelectDefaultModule.kt | 2 +- .../kotlin/dev/kilua/TomSelectMinModule.kt | 2 +- .../kotlin/dev/kilua/TomSelectModule.kt | 2 +- .../kotlin/dev/kilua/externals/TomSelectJs.kt | 17 ++- .../kotlin/dev/kilua/form/select/TomSelect.kt | 17 ++- .../kilua/form/select/TomSelectCallbacks.kt | 5 +- .../dev/kilua/form/select/TomSelectOptions.kt | 8 +- .../dev/kilua/form/select/TomSelectRenders.kt | 2 +- .../dev/kilua/form/text/TomTypeahead.kt | 13 +- .../commonMain/kotlin/dev/kilua/TrixModule.kt | 2 +- .../kotlin/dev/kilua/externals/Editor.kt | 4 +- .../kotlin/dev/kilua/externals/TrixLocale.kt | 2 +- .../kotlin/dev/kilua/form/text/RichText.kt | 17 ++- .../kotlin/dev/kilua/externals/Editor.js.kt | 2 +- .../kotlin/dev/kilua/externals/Trix.js.kt | 2 +- .../dev/kilua/externals/Editor.wasmJs.kt | 2 +- .../kotlin/dev/kilua/externals/Trix.wasmJs.kt | 2 +- .../kotlin/dev/kilua/ksp/KiluaProcessor.kt | 2 +- settings.gradle.kts | 1 + 263 files changed, 1248 insertions(+), 998 deletions(-) create mode 100644 kilua/src/jvmMain/kotlin/dev/kilua/compose/Root.jvm.kt create mode 100644 kilua/src/webMain/kotlin/dev/kilua/Coroutines.web.kt rename kilua/src/{commonMain => webMain}/kotlin/dev/kilua/HMR.kt (98%) create mode 100644 modules/kilua-core-modules/src/commonMain/kotlin/dev/kilua/AppContext.kt create mode 100644 modules/kilua-core-modules/src/jsCommonMain/kotlin/dev/kilua/CoreModule.jsCommon.kt create mode 100644 modules/kilua-core-modules/src/jsCommonMain/kotlin/dev/kilua/CssRegister.jsCommon.kt create mode 100644 modules/kilua-core-modules/src/jvmMain/kotlin/dev/kilua/CoreModule.jvm.kt create mode 100644 modules/kilua-core-modules/src/jvmMain/kotlin/dev/kilua/CssRegister.jvm.kt create mode 100644 modules/kilua-dom-core/build.gradle.kts rename modules/{kilua-dom/src/commonMain/kotlin/web => kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core}/JsAny.kt (68%) rename modules/{kilua-dom/src/commonMain/kotlin/web => kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core}/JsArray.kt (77%) rename modules/{kilua-dom/src/commonMain/kotlin/web => kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core}/JsBoolean.kt (74%) rename modules/{kilua-dom/src/commonMain/kotlin/web => kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core}/JsNumber.kt (78%) rename modules/{kilua-dom/src/commonMain/kotlin/web => kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core}/JsString.kt (72%) create mode 100644 modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/Promise.kt rename modules/{kilua-dom/src/commonMain/kotlin/web => kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core}/RegExp.kt (89%) create mode 100644 modules/kilua-dom-core/src/jsCommonMain/kotlin/dev/kilua/dom/core/JsAny.kt rename modules/{kilua-dom/src/jsMain/kotlin/web => kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core}/JsArray.js.kt (93%) rename modules/{kilua-dom/src/jsMain/kotlin/web => kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core}/JsBoolean.js.kt (98%) rename modules/{kilua-dom/src/jsMain/kotlin/web => kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core}/JsNumber.js.kt (98%) rename modules/{kilua-dom/src/jsMain/kotlin/web => kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core}/JsString.js.kt (97%) rename modules/{kilua-dom/src/jsMain/kotlin/web => kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core}/Promise.js.kt (64%) rename modules/{kilua-dom/src/jsMain/kotlin/web => kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core}/RegExp.js.kt (97%) create mode 100644 modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsAny.jvm.kt create mode 100644 modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsArray.jvm.kt create mode 100644 modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsBoolean.jvm.kt create mode 100644 modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsNumber.jvm.kt create mode 100644 modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsString.jvm.kt create mode 100644 modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/Promise.jvm.kt create mode 100644 modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/RegExp.jvm.kt rename modules/{kilua-dom/src/wasmJsMain/kotlin/web => kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core}/JsArray.wasmJs.kt (98%) rename modules/{kilua-dom/src/wasmJsMain/kotlin/web => kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core}/JsBoolean.wasmJs.kt (98%) rename modules/{kilua-dom/src/wasmJsMain/kotlin/web => kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core}/JsNumber.wasmJs.kt (58%) rename modules/{kilua-dom/src/wasmJsMain/kotlin/web => kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core}/JsString.wasmJs.kt (97%) rename modules/{kilua-dom/src/wasmJsMain/kotlin/web => kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core}/Promise.wasmJs.kt (64%) rename modules/{kilua-dom/src/wasmJsMain/kotlin/web => kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core}/RegExp.wasmJs.kt (94%) delete mode 100644 modules/kilua-dom/src/commonMain/kotlin/web/Promise.kt rename modules/kilua-dom/src/{commonMain/kotlin/web => jsCommonMain/kotlin/dev/kilua/dom}/Mutations.kt (87%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/Dom.kt (99%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/ItemArrayLike.kt (93%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/clipboard/Clipboard.kt (85%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/css/Css.kt (98%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/encryptedmedia/Encryptedmedia.kt (93%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/events/Events.kt (98%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/mediacapture/Mediacapture.kt (96%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/mediasource/Mediasource.kt (89%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/observers/IntersectionObserver.kt (92%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/observers/IntersectionObserverCallback.kt (95%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/observers/IntersectionObserverEntry.kt (94%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/observers/IntersectionObserverEntryInit.kt (90%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/observers/IntersectionObserverInit.kt (90%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/parsing/Parsing.kt (87%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/pointerevents/Pointerevents.kt (90%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/svg/Svg.kt (99%) rename modules/kilua-dom/src/{commonMain/kotlin/web/dom => jsCommonMain/kotlin/dev/kilua/dom/api}/url/Url.kt (89%) rename modules/kilua-dom/src/{commonMain/kotlin/web => jsCommonMain/kotlin/dev/kilua/dom}/css/masking/Masking.kt (91%) rename modules/kilua-dom/src/{commonMain/kotlin/web/web.kt => jsCommonMain/kotlin/dev/kilua/dom/dom.kt} (75%) rename modules/kilua-dom/src/{commonMain/kotlin/web => jsCommonMain/kotlin/dev/kilua/dom}/fetch/Fetch.kt (98%) rename modules/kilua-dom/src/{commonMain/kotlin/web => jsCommonMain/kotlin/dev/kilua/dom}/files/Files.kt (87%) rename modules/kilua-dom/src/{commonMain/kotlin/web => jsCommonMain/kotlin/dev/kilua/dom}/notifications/Notifications.kt (90%) rename modules/kilua-dom/src/{commonMain/kotlin/web => jsCommonMain/kotlin/dev/kilua/dom}/performance/Performance.kt (94%) rename modules/kilua-dom/src/{commonMain/kotlin/web => jsCommonMain/kotlin/dev/kilua/dom}/webgl/Webgl.kt (99%) rename modules/kilua-dom/src/{commonMain/kotlin/web => jsCommonMain/kotlin/dev/kilua/dom}/workers/Workers.kt (94%) rename modules/kilua-dom/src/{commonMain/kotlin/web => jsCommonMain/kotlin/dev/kilua/dom}/xhr/Xhr.kt (90%) delete mode 100644 modules/kilua-dom/src/jsMain/kotlin/web/JsAny.js.kt delete mode 100644 modules/kilua-dom/src/wasmJsMain/kotlin/web/JsAny.wasmJs.kt rename modules/kilua-testutils/src/{commonMain => webMain}/kotlin/dev/kilua/test/HtmlDiffer.kt (98%) rename modules/kilua-testutils/src/{commonMain => webMain}/kotlin/dev/kilua/test/TestUtil.kt (98%) diff --git a/buildSrc/src/main/kotlin/Shared.kt b/buildSrc/src/main/kotlin/Shared.kt index 2074e13b2..1876caf53 100644 --- a/buildSrc/src/main/kotlin/Shared.kt +++ b/buildSrc/src/main/kotlin/Shared.kt @@ -1,3 +1,5 @@ +import org.gradle.api.NamedDomainObjectContainer +import org.gradle.api.NamedDomainObjectProvider import org.gradle.api.Project import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPom @@ -11,9 +13,12 @@ import org.gradle.kotlin.dsl.project import org.gradle.kotlin.dsl.withType import org.gradle.plugins.signing.Sign import org.gradle.plugins.signing.SigningExtension +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.kotlinExtension +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask @@ -71,7 +76,9 @@ fun KotlinMultiplatformExtension.kotlinWasmTargets(withNode: Boolean = true) { } } -fun KotlinMultiplatformExtension.kotlinJvmTargets(target: String = "17") { +private const val kotlinVersion = "21" + +fun KotlinMultiplatformExtension.kotlinJvmTargets(target: String = kotlinVersion) { jvmToolchain { languageVersion.set(JavaLanguageVersion.of(target)) } @@ -86,12 +93,31 @@ fun KotlinMultiplatformExtension.kotlinJvmTargets(target: String = "17") { } } -fun KotlinJvmProjectExtension.kotlinJvmTargets(target: String = "17") { +fun KotlinJvmProjectExtension.kotlinJvmTargets(target: String = kotlinVersion) { jvmToolchain { languageVersion.set(JavaLanguageVersion.of(target)) } } +@OptIn(ExperimentalKotlinGradlePluginApi::class) +fun KotlinMultiplatformExtension.kotlinJsCommonTargets() { + applyDefaultHierarchyTemplate { + sourceSetTrees(KotlinSourceSetTree.main, KotlinSourceSetTree.test) + + common { + group("jsCommon") { + withJs() + withWasmJs() + } + } + } +} + +val NamedDomainObjectContainer.jsCommonMain: NamedDomainObjectProvider + get() = named("jsCommonMain") +val NamedDomainObjectContainer.jsCommonTest: NamedDomainObjectProvider + get() = named("jsCommonTest") + fun Project.setupKsp() { dependencies { add("kspCommonMainMetadata", project(":plugins:kilua-ksp-processor")) diff --git a/examples/fullstack-ktor-koin/src/webMain/kotlin/example/main.kt b/examples/fullstack-ktor-koin/src/webMain/kotlin/example/main.kt index 7966218c2..fb1c63c1b 100644 --- a/examples/fullstack-ktor-koin/src/webMain/kotlin/example/main.kt +++ b/examples/fullstack-ktor-koin/src/webMain/kotlin/example/main.kt @@ -58,7 +58,7 @@ import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime import kotlinx.serialization.serializer -import web.toJsString +import dev.kilua.dom.toJsString class App : Application() { diff --git a/examples/playground/src/commonMain/kotlin/main.kt b/examples/playground/src/commonMain/kotlin/main.kt index 0b5c22638..d07575b9c 100644 --- a/examples/playground/src/commonMain/kotlin/main.kt +++ b/examples/playground/src/commonMain/kotlin/main.kt @@ -49,20 +49,16 @@ import dev.kilua.form.fieldWithLabel import dev.kilua.form.form import dev.kilua.form.number.imaskNumeric import dev.kilua.form.number.numeric -import dev.kilua.form.number.range import dev.kilua.form.number.rangeRef import dev.kilua.form.select.TomSelectCallbacks import dev.kilua.form.select.TomSelectRenders import dev.kilua.form.select.tomSelect import dev.kilua.form.select.tomSelectRef -import dev.kilua.form.text.richText import dev.kilua.form.text.richTextRef import dev.kilua.form.text.text import dev.kilua.form.text.textRef -import dev.kilua.form.text.tomTypeahead import dev.kilua.form.text.tomTypeaheadRef import dev.kilua.form.time.richDate -import dev.kilua.form.time.richDateTime import dev.kilua.form.time.richDateTimeRef import dev.kilua.form.time.richTime import dev.kilua.html.* @@ -74,14 +70,12 @@ import dev.kilua.i18n.SimpleLocale import dev.kilua.modal.FullscreenMode import dev.kilua.modal.ModalSize import dev.kilua.modal.confirm -import dev.kilua.modal.modal import dev.kilua.modal.modalRef import dev.kilua.panel.OffPlacement import dev.kilua.panel.TabPosition import dev.kilua.panel.accordion import dev.kilua.panel.carousel import dev.kilua.panel.lazyColumn -import dev.kilua.panel.offcanvas import dev.kilua.panel.offcanvasRef import dev.kilua.panel.splitPanel import dev.kilua.panel.tabPanel @@ -129,17 +123,15 @@ import dev.kilua.useModule import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.serialization.Serializable -import web.JsAny -import web.JsArray -import web.Promise -import web.RegExp -import web.dom.CustomEvent -import web.dom.HTMLElement -import web.dom.Text -import web.dom.events.Event -import web.toJsNumber -import web.toJsString -import web.window +import dev.kilua.dom.Promise +import dev.kilua.dom.RegExp +import dev.kilua.dom.api.CustomEvent +import dev.kilua.dom.api.HTMLElement +import dev.kilua.dom.api.Text +import dev.kilua.dom.core.JsAny +import dev.kilua.dom.core.toJsNumber +import dev.kilua.dom.core.toJsString +import dev.kilua.dom.window import kotlin.random.Random import kotlin.random.nextInt import kotlin.random.nextUInt @@ -581,7 +573,7 @@ class App : Application() { null } result?.let { items: JsAny -> - callback(items.unsafeCast>().toList().map { item -> + callback(items.unsafeCast>().toList().map { item -> jsObjectOf( "value" to item["id"]!!, "text" to item["name"]!!, @@ -1335,7 +1327,7 @@ class App : Application() { button { +"click" DisposableEffect("button") { - val f = { _: Event -> + val f = { _: dev.kilua.dom.api.events.Event -> console.log("click $name of ${list.size}") } element.addEventListener("click", f) @@ -1425,7 +1417,7 @@ class App : Application() { size++ } DisposableEffect("button2") { - val f = { _: Event -> + val f = { _: dev.kilua.dom.api.events.Event -> console.log("button2 click") } element.addEventListener("click", f) diff --git a/examples/realworld/src/webMain/kotlin/io/realworld/ConduitManager.kt b/examples/realworld/src/webMain/kotlin/io/realworld/ConduitManager.kt index 6a40dc25d..d5aca1f96 100644 --- a/examples/realworld/src/webMain/kotlin/io/realworld/ConduitManager.kt +++ b/examples/realworld/src/webMain/kotlin/io/realworld/ConduitManager.kt @@ -50,11 +50,10 @@ import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import web.JsAny -import web.JsArray -import web.JsString -import web.localStorage -import web.toJsString +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsString +import dev.kilua.dom.localStorage +import dev.kilua.dom.toJsString const val JWT_TOKEN = "jwtToken" @@ -423,7 +422,7 @@ class ConduitManager : TokenProvider { val json = JSON.parse(it) val errors = json["errors"]!! for (key in keys(errors)) { - val tab: JsArray = errors[key]!!.unsafeCast() + val tab: dev.kilua.dom.JsArray = errors[key]!!.unsafeCast() result.addAll(tab.toList().map { "$key $it" }) } result diff --git a/examples/realworld/src/webMain/kotlin/io/realworld/externals/Date.kt b/examples/realworld/src/webMain/kotlin/io/realworld/externals/Date.kt index c4d4478f2..c59042c88 100644 --- a/examples/realworld/src/webMain/kotlin/io/realworld/externals/Date.kt +++ b/examples/realworld/src/webMain/kotlin/io/realworld/externals/Date.kt @@ -24,7 +24,7 @@ package io.realworld.externals import dev.kilua.externals.Intl import dev.kilua.utils.jsObjectOf -import web.JsAny +import dev.kilua.dom.JsAny external class Date() : JsAny { constructor(value: String?) diff --git a/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Editor.kt b/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Editor.kt index 98e9724bf..1d876c52f 100644 --- a/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Editor.kt +++ b/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Editor.kt @@ -38,7 +38,6 @@ import dev.kilua.html.ul import io.realworld.ConduitManager import io.realworld.ConduitState import io.realworld.View -import web.dom.events.Event @Composable fun IComponent.editorPage(state: ConduitState, conduitManager: ConduitManager) { @@ -103,7 +102,7 @@ fun IComponent.editorPage(state: ConduitState, conduitManager: ConduitManager) { className = "btn btn-primary btn-lg pull-xs-right" ) } - onEvent("submit") { ev -> + onEvent("submit") { ev -> ev.preventDefault() if (isNewArticle) { conduitManager.createArticle( diff --git a/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Login.kt b/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Login.kt index 055d5f056..5dbb50d7a 100644 --- a/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Login.kt +++ b/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Login.kt @@ -40,7 +40,6 @@ import dev.kilua.html.ul import io.realworld.ConduitManager import io.realworld.ConduitState import io.realworld.View -import web.dom.events.Event @Composable fun IComponent.loginPage(state: ConduitState, conduitManager: ConduitManager) { @@ -81,7 +80,7 @@ fun IComponent.loginPage(state: ConduitState, conduitManager: ConduitManager) { type = ButtonType.Submit, className = "btn btn-primary btn-lg pull-xs-right" ) - onEvent("submit") { ev -> + onEvent("submit") { ev -> ev.preventDefault() conduitManager.login(emailInput.value, passwordInput.value) } diff --git a/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Register.kt b/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Register.kt index e33d0c0d4..2391d403f 100644 --- a/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Register.kt +++ b/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Register.kt @@ -40,7 +40,6 @@ import dev.kilua.html.ul import io.realworld.ConduitManager import io.realworld.ConduitState import io.realworld.View -import web.dom.events.Event @Composable fun IComponent.registerPage(state: ConduitState, conduitManager: ConduitManager) { @@ -92,7 +91,7 @@ fun IComponent.registerPage(state: ConduitState, conduitManager: ConduitManager) type = ButtonType.Submit, className = "btn btn-primary btn-lg pull-xs-right" ) - onEvent("submit") { ev -> + onEvent("submit") { ev -> ev.preventDefault() conduitManager.register(usernameInput.value, emailInput.value, passwordInput.value) } diff --git a/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Settings.kt b/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Settings.kt index cb23f133f..98f1bc6bb 100644 --- a/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Settings.kt +++ b/examples/realworld/src/webMain/kotlin/io/realworld/layout/users/Settings.kt @@ -40,7 +40,6 @@ import dev.kilua.html.li import dev.kilua.html.ul import io.realworld.ConduitManager import io.realworld.ConduitState -import web.dom.events.Event @Composable fun IComponent.settingsPage(state: ConduitState, conduitManager: ConduitManager) { @@ -108,7 +107,7 @@ fun IComponent.settingsPage(state: ConduitState, conduitManager: ConduitManager) className = "btn btn-primary btn-lg pull-xs-right" ) } - onEvent("submit") { ev -> + onEvent("submit") { ev -> ev.preventDefault() conduitManager.settings( imageInput.value, diff --git a/examples/todomvc-ballast/src/commonMain/kotlin/TodoApp.kt b/examples/todomvc-ballast/src/commonMain/kotlin/TodoApp.kt index ae50bfaa3..af0f8f406 100644 --- a/examples/todomvc-ballast/src/commonMain/kotlin/TodoApp.kt +++ b/examples/todomvc-ballast/src/commonMain/kotlin/TodoApp.kt @@ -47,9 +47,6 @@ import dev.kilua.startApplication import org.koin.core.component.KoinComponent import org.koin.core.component.inject import org.koin.core.context.startKoin -import web.dom.events.FocusEvent -import web.dom.events.KeyboardEvent -import web.dom.events.MouseEvent const val ENTER_KEY = 13 const val ESC_KEY = 27 @@ -83,7 +80,7 @@ class App : Application(), KoinComponent { h1 { +"todos" } text(placeholder = "What needs to be done?", className = "new-todo") { autofocus(true) - onEvent("keydown") { e -> + onEvent("keydown") { e -> if (e.keyCode == ENTER_KEY) { todoViewModel.addTodo(this.value) this.value = null @@ -118,7 +115,7 @@ class App : Application(), KoinComponent { } label { +todo.title - onEvent("dblclick") { + onEvent("dblclick") { this@li.element.classList.add("editing") edit.value = todo.title edit.focus() @@ -131,13 +128,13 @@ class App : Application(), KoinComponent { } } edit = textRef(className = "edit") { - onEvent("blur") { + onEvent("blur") { if (this@li.element.classList.contains("editing")) { this@li.element.classList.remove("editing") todoViewModel.editTodo(index, this.value) } } - onEvent("keydown") { e -> + onEvent("keydown") { e -> if (e.keyCode == ENTER_KEY) { todoViewModel.editTodo(index, this.value) this@li.element.classList.remove("editing") diff --git a/examples/todomvc-ballast/src/commonMain/kotlin/TodoModule.kt b/examples/todomvc-ballast/src/commonMain/kotlin/TodoModule.kt index c1ddde5f4..a123ab88e 100644 --- a/examples/todomvc-ballast/src/commonMain/kotlin/TodoModule.kt +++ b/examples/todomvc-ballast/src/commonMain/kotlin/TodoModule.kt @@ -1,4 +1,4 @@ -import web.localStorage +import dev.kilua.dom.localStorage import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob diff --git a/examples/todomvc-ballast/src/commonMain/kotlin/TodoSavedStateAdapter.kt b/examples/todomvc-ballast/src/commonMain/kotlin/TodoSavedStateAdapter.kt index 6c829ba55..a3cb44be1 100644 --- a/examples/todomvc-ballast/src/commonMain/kotlin/TodoSavedStateAdapter.kt +++ b/examples/todomvc-ballast/src/commonMain/kotlin/TodoSavedStateAdapter.kt @@ -6,8 +6,8 @@ import dev.kilua.externals.get import dev.kilua.externals.set import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.json.Json -import web.dom.Storage -import web.toJsString +import dev.kilua.dom.api.Storage +import dev.kilua.dom.core.toJsString class TodoSavedStateAdapter(private val json: Json, private val storage: Storage) : SavedStateAdapter< diff --git a/examples/todomvc/src/commonMain/kotlin/TodoApp.kt b/examples/todomvc/src/commonMain/kotlin/TodoApp.kt index f47dd9058..2d8fa6408 100644 --- a/examples/todomvc/src/commonMain/kotlin/TodoApp.kt +++ b/examples/todomvc/src/commonMain/kotlin/TodoApp.kt @@ -44,9 +44,6 @@ import dev.kilua.html.span import dev.kilua.html.strong import dev.kilua.html.ul import dev.kilua.startApplication -import web.dom.events.FocusEvent -import web.dom.events.KeyboardEvent -import web.dom.events.MouseEvent const val ENTER_KEY = 13 const val ESC_KEY = 27 @@ -79,7 +76,7 @@ class App : Application() { h1 { +"todos" } text(placeholder = "What needs to be done?", className = "new-todo") { autofocus(true) - onEvent("keydown") { e -> + onEvent("keydown") { e -> if (e.keyCode == ENTER_KEY) { viewModel.addTodo(this.value) this.value = null @@ -114,7 +111,7 @@ class App : Application() { } label { +todo.title - onEvent("dblclick") { + onEvent("dblclick") { this@li.element.classList.add("editing") edit.value = todo.title edit.focus() @@ -127,13 +124,13 @@ class App : Application() { } } edit = textRef(className = "edit") { - onEvent("blur") { + onEvent("blur") { if (this@li.element.classList.contains("editing")) { this@li.element.classList.remove("editing") viewModel.editTodo(index, this.value) } } - onEvent("keydown") { e -> + onEvent("keydown") { e -> if (e.keyCode == ENTER_KEY) { viewModel.editTodo(index, this.value) this@li.element.classList.remove("editing") diff --git a/examples/todomvc/src/commonMain/kotlin/TodoViewModel.kt b/examples/todomvc/src/commonMain/kotlin/TodoViewModel.kt index ccc33384c..e3240c095 100644 --- a/examples/todomvc/src/commonMain/kotlin/TodoViewModel.kt +++ b/examples/todomvc/src/commonMain/kotlin/TodoViewModel.kt @@ -20,6 +20,7 @@ * SOFTWARE. */ +import dev.kilua.dom.core.toJsString import dev.kilua.externals.get import dev.kilua.externals.set import kotlinx.coroutines.CoroutineScope @@ -32,8 +33,7 @@ import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.update import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.json.Json -import web.localStorage -import web.toJsString +import dev.kilua.dom.localStorage class ViewModel { private val appScope: CoroutineScope = CoroutineScope(Dispatchers.Default + SupervisorJob()) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 94a9c9e4d..760ff469f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,7 @@ kilua-published = "0.0.8" kotlin = "2.0.0" compose = "1.6.11" dokka = "1.9.20" -nmcp = "0.0.8" +nmcp = "0.0.9" ksp = "2.0.0-1.0.22" detekt = "1.23.6" npm-publish = "3.4.2" diff --git a/kilua/build.gradle.kts b/kilua/build.gradle.kts index c47ce7f7e..809e6527a 100644 --- a/kilua/build.gradle.kts +++ b/kilua/build.gradle.kts @@ -1,3 +1,7 @@ +@file:OptIn(ExperimentalWasmDsl::class) + +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl + plugins { kotlin("multiplatform") alias(libs.plugins.kotlinx.serialization) @@ -22,8 +26,10 @@ kotlin { compilerOptions() kotlinJsTargets() kotlinWasmTargets() + kotlinJvmTargets() + kotlinJsCommonTargets() sourceSets { - val commonMain by getting { + commonMain { dependencies { api(compose.runtime) api(libs.kotlinx.atomicfu) @@ -31,16 +37,11 @@ kotlin { api(libs.kotlinx.serialization.json) api(project(":modules:kilua-annotations")) api(project(":modules:kilua-common-types")) - api(project(":modules:kilua-dom")) + api(project(":modules:kilua-dom-core")) api(project(":modules:kilua-core-modules")) -// implementation(npm("aaa-kilua-assets", "http://localhost:8001/aaa-kilua-assets-0.0.9-SNAPSHOT.tgz")) - implementation(npm("aaa-kilua-assets", libs.versions.npm.kilua.assets.get())) - implementation(npm("css-loader", libs.versions.css.loader.get())) - implementation(npm("style-loader", libs.versions.style.loader.get())) - implementation(npm("imports-loader", libs.versions.imports.loader.get())) } } - val commonTest by getting { + commonTest { dependencies { implementation(kotlin("test")) implementation(kotlin("test-common")) @@ -48,11 +49,20 @@ kotlin { implementation(project(":modules:kilua-testutils")) } } - val jsMain by getting { + jsCommonMain { + dependencies { + // implementation(npm("aaa-kilua-assets", "http://localhost:8001/aaa-kilua-assets-0.0.9-SNAPSHOT.tgz")) + implementation(npm("aaa-kilua-assets", libs.versions.npm.kilua.assets.get())) + implementation(npm("css-loader", libs.versions.css.loader.get())) + implementation(npm("style-loader", libs.versions.style.loader.get())) + implementation(npm("imports-loader", libs.versions.imports.loader.get())) + } + } + jsMain { dependencies { } } - val wasmJsMain by getting { + wasmJsMain { dependencies { } } diff --git a/kilua/src/commonMain/kotlin/dev/kilua/Application.kt b/kilua/src/commonMain/kotlin/dev/kilua/Application.kt index e398cb7e3..783989858 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/Application.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/Application.kt @@ -25,7 +25,7 @@ import dev.kilua.compose.Root import dev.kilua.html.style.StyleParams import dev.kilua.i18n.DefaultLocale import dev.kilua.utils.isDom -import web.document +import dev.kilua.dom.document /** * Base class for Kilua applications. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/Coroutines.kt b/kilua/src/commonMain/kotlin/dev/kilua/Coroutines.kt index 5ae5db1be..8c4c3d32b 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/Coroutines.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/Coroutines.kt @@ -22,31 +22,11 @@ package dev.kilua -import dev.kilua.utils.cast import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Deferred import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob -import kotlinx.coroutines.async -import web.JsAny -import web.Promise /** * Kilua coroutine scope. */ public val KiluaScope: CoroutineScope = CoroutineScope(Dispatchers.Default + SupervisorJob()) - -/** - * Convert Deferred to a JS Promise. - */ -public expect fun Deferred.asPromise(): Promise - -/** - * Convert JS Promise to a Deferred. - */ -public expect fun Promise.asDeferred(): Deferred - -/** - * Create a JS Promise from a suspending block. - */ -public fun promise(block: suspend () -> T): Promise = KiluaScope.async { block() }.asPromise().cast() diff --git a/kilua/src/commonMain/kotlin/dev/kilua/compose/NonDisposableRoot.kt b/kilua/src/commonMain/kotlin/dev/kilua/compose/NonDisposableRoot.kt index 6fa6b0cdc..cf3c83446 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/compose/NonDisposableRoot.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/compose/NonDisposableRoot.kt @@ -26,7 +26,7 @@ import androidx.compose.runtime.Composable import dev.kilua.core.ComponentBase import dev.kilua.core.IComponent import dev.kilua.core.RenderConfig -import web.dom.Element +import dev.kilua.dom.api.Element /** * A root component which is not disposed. @@ -37,7 +37,7 @@ import web.dom.Element internal class NonDisposableRoot( val element: Element, renderConfig: RenderConfig = RenderConfig.Default, - content: @Composable IComponent.() -> Unit = {} + content: @Composable IComponent.() -> Unit = {}, ) : ComponentBase(element, renderConfig) { // Not used @@ -54,7 +54,5 @@ internal class NonDisposableRoot( rootComposable(this, defaultMonotonicFrameClock, content) } - override fun renderToStringBuilder(builder: StringBuilder) { - } - + override fun renderToStringBuilder(builder: StringBuilder) {} } diff --git a/kilua/src/commonMain/kotlin/dev/kilua/compose/PromiseDispatcher.kt b/kilua/src/commonMain/kotlin/dev/kilua/compose/PromiseDispatcher.kt index c69fcda74..1d75b9625 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/compose/PromiseDispatcher.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/compose/PromiseDispatcher.kt @@ -26,7 +26,7 @@ import dev.kilua.externals.obj import dev.kilua.utils.cast import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Runnable -import web.Promise +import dev.kilua.dom.Promise import kotlin.coroutines.CoroutineContext /** diff --git a/kilua/src/commonMain/kotlin/dev/kilua/compose/Root.kt b/kilua/src/commonMain/kotlin/dev/kilua/compose/Root.kt index 9f7e76efd..c0ad5e705 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/compose/Root.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/compose/Root.kt @@ -36,8 +36,8 @@ import dev.kilua.utils.nativeListOf import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.launch -import web.clear -import web.dom.Element +import dev.kilua.dom.clear +import dev.kilua.dom.api.Element internal expect val defaultMonotonicFrameClock: MonotonicFrameClock diff --git a/kilua/src/commonMain/kotlin/dev/kilua/core/ComponentBase.kt b/kilua/src/commonMain/kotlin/dev/kilua/core/ComponentBase.kt index a3a1355c3..8dd67d16a 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/core/ComponentBase.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/core/ComponentBase.kt @@ -24,11 +24,11 @@ package dev.kilua.core import dev.kilua.utils.isDom import dev.kilua.utils.nativeListOf -import web.clear -import web.dom.CustomEvent -import web.dom.CustomEventInit -import web.dom.Node -import web.dom.get +import dev.kilua.dom.clear +import dev.kilua.dom.api.CustomEvent +import dev.kilua.dom.api.CustomEventInit +import dev.kilua.dom.api.Node +import dev.kilua.dom.api.get /** * Base class for all components. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/core/SafeDomFactory.kt b/kilua/src/commonMain/kotlin/dev/kilua/core/SafeDomFactory.kt index e61156538..2ae1f96f2 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/core/SafeDomFactory.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/core/SafeDomFactory.kt @@ -26,10 +26,10 @@ import dev.kilua.externals.nodeJsCreateComment import dev.kilua.externals.nodeJsCreateElement import dev.kilua.externals.nodeJsCreateText import dev.kilua.utils.isDom -import web.document -import web.dom.Comment -import web.dom.Element -import web.dom.Text +import dev.kilua.dom.document +import dev.kilua.dom.api.Comment +import dev.kilua.dom.api.Element +import dev.kilua.dom.api.Text /** * Helper factory to safely call methods on the document object. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/externals/Array.kt b/kilua/src/commonMain/kotlin/dev/kilua/externals/Array.kt index 61f1b4ef2..93b30f5c2 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/externals/Array.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/externals/Array.kt @@ -22,8 +22,7 @@ package dev.kilua.externals -import web.JsAny -import web.JsArray +import dev.kilua.dom.JsAny /** * Returns whether the given value is an array @@ -34,4 +33,7 @@ public expect fun isArray(o: JsAny?): Boolean * Merge two arrays. * Returns a new array containing the contents of both given arrays. */ -public expect fun concat(array1: JsArray, array2: JsArray): JsArray +public expect fun concat( + array1: dev.kilua.dom.JsArray, + array2: dev.kilua.dom.JsArray, +): dev.kilua.dom.JsArray diff --git a/kilua/src/commonMain/kotlin/dev/kilua/externals/Console.kt b/kilua/src/commonMain/kotlin/dev/kilua/externals/Console.kt index ebeb54a8a..58bd73202 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/externals/Console.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/externals/Console.kt @@ -23,7 +23,7 @@ package dev.kilua.externals -import web.JsAny +import dev.kilua.dom.JsAny /** * JavaScript console class diff --git a/kilua/src/commonMain/kotlin/dev/kilua/externals/Event.kt b/kilua/src/commonMain/kotlin/dev/kilua/externals/Event.kt index 1c5df12f9..31f66610f 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/externals/Event.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/externals/Event.kt @@ -23,9 +23,9 @@ package dev.kilua.externals -import web.JsAny -import web.dom.AddEventListenerOptions -import web.dom.CustomEventInit +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.AddEventListenerOptions +import dev.kilua.dom.api.CustomEventInit /** * JavaScript AbortSignal class diff --git a/kilua/src/commonMain/kotlin/dev/kilua/externals/Intl.kt b/kilua/src/commonMain/kotlin/dev/kilua/externals/Intl.kt index b657e8160..6fa7bc55b 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/externals/Intl.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/externals/Intl.kt @@ -23,7 +23,7 @@ package dev.kilua.externals -import web.JsAny +import dev.kilua.dom.JsAny /** * I18n API diff --git a/kilua/src/commonMain/kotlin/dev/kilua/externals/JSON.kt b/kilua/src/commonMain/kotlin/dev/kilua/externals/JSON.kt index a166ea255..dbf456541 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/externals/JSON.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/externals/JSON.kt @@ -23,7 +23,7 @@ package dev.kilua.externals -import web.JsAny +import dev.kilua.dom.JsAny /** * JavaScript JSON object. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/externals/NodeJsDom.kt b/kilua/src/commonMain/kotlin/dev/kilua/externals/NodeJsDom.kt index cf137e417..7bc2ea1e3 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/externals/NodeJsDom.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/externals/NodeJsDom.kt @@ -22,9 +22,9 @@ package dev.kilua.externals -import web.dom.Comment -import web.dom.Element -import web.dom.Text +import dev.kilua.dom.api.Comment +import dev.kilua.dom.api.Element +import dev.kilua.dom.api.Text /** * Create a fake DOM Element on Node.js. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/externals/Object.kt b/kilua/src/commonMain/kotlin/dev/kilua/externals/Object.kt index 7b57bc39d..bb1a4ffaa 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/externals/Object.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/externals/Object.kt @@ -23,7 +23,7 @@ package dev.kilua.externals import dev.kilua.utils.unsafeCast -import web.JsAny +import dev.kilua.dom.JsAny /** * Return empty JS Object diff --git a/kilua/src/commonMain/kotlin/dev/kilua/form/Form.kt b/kilua/src/commonMain/kotlin/dev/kilua/form/Form.kt index 4a0cfc77c..1eed42d0f 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/form/Form.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/form/Form.kt @@ -58,11 +58,11 @@ import kotlinx.serialization.json.Json import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.modules.overwriteWith import kotlinx.serialization.serializer -import web.JsAny -import web.dom.HTMLFormElement -import web.toJsBoolean -import web.toJsNumber -import web.toJsString +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.HTMLFormElement +import dev.kilua.dom.toJsBoolean +import dev.kilua.dom.toJsNumber +import dev.kilua.dom.toJsString import kotlin.reflect.KClass import kotlin.reflect.KProperty1 diff --git a/kilua/src/commonMain/kotlin/dev/kilua/form/Input.kt b/kilua/src/commonMain/kotlin/dev/kilua/form/Input.kt index 4e8eb9d7e..5f95bc72a 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/form/Input.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/form/Input.kt @@ -30,8 +30,7 @@ import dev.kilua.html.helpers.PropertyListBuilder import dev.kilua.state.WithStateFlow import dev.kilua.state.WithStateFlowDelegate import dev.kilua.state.WithStateFlowDelegateImpl -import web.dom.HTMLInputElement -import web.dom.events.Event +import dev.kilua.dom.api.HTMLInputElement /** * Base interface form HTML input components. @@ -451,7 +450,7 @@ public abstract class Input( element.required = required } @Suppress("LeakingThis") - onEventDirect("input") { + onEventDirect("input") { if (mask == null) setInternalValueFromString(element.value) } } diff --git a/kilua/src/commonMain/kotlin/dev/kilua/form/Mask.kt b/kilua/src/commonMain/kotlin/dev/kilua/form/Mask.kt index d2563e12e..7d6b5f75a 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/form/Mask.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/form/Mask.kt @@ -22,7 +22,7 @@ package dev.kilua.form -import web.dom.HTMLElement +import dev.kilua.dom.api.HTMLElement /** * Generic input mask controller. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/form/check/AbstractCheck.kt b/kilua/src/commonMain/kotlin/dev/kilua/form/check/AbstractCheck.kt index 0731bcec2..7a814a0f6 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/form/check/AbstractCheck.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/form/check/AbstractCheck.kt @@ -32,8 +32,7 @@ import dev.kilua.state.WithStateFlow import dev.kilua.state.WithStateFlowDelegate import dev.kilua.state.WithStateFlowDelegateImpl import dev.kilua.utils.toKebabCase -import web.dom.HTMLInputElement -import web.dom.events.Event +import dev.kilua.dom.api.HTMLInputElement /** * Type of the check input control (checkbox or radiobutton). @@ -254,11 +253,11 @@ public abstract class AbstractCheck( element.required = required } @Suppress("LeakingThis") - onEventDirect("click") { + onEventDirect("click") { setInternalValueFromBoolean(element.checked) } @Suppress("LeakingThis") - onEventDirect("change") { + onEventDirect("change") { setInternalValueFromBoolean(element.checked) } } diff --git a/kilua/src/commonMain/kotlin/dev/kilua/form/check/TriStateCheckBox.kt b/kilua/src/commonMain/kotlin/dev/kilua/form/check/TriStateCheckBox.kt index e1ad25b59..4680ad8b6 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/form/check/TriStateCheckBox.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/form/check/TriStateCheckBox.kt @@ -35,8 +35,7 @@ import dev.kilua.html.helpers.PropertyListBuilder import dev.kilua.state.WithStateFlow import dev.kilua.state.WithStateFlowDelegate import dev.kilua.state.WithStateFlowDelegateImpl -import web.dom.HTMLInputElement -import web.dom.events.Event +import dev.kilua.dom.api.HTMLInputElement /** * Tri-state CheckBox input component. @@ -258,7 +257,7 @@ public open class TriStateCheckBox( @Suppress("LeakingThis") setAttribute("type", "checkbox") @Suppress("LeakingThis") - onEventDirect("click") { + onEventDirect("click") { cycleValue() } } diff --git a/kilua/src/commonMain/kotlin/dev/kilua/form/number/Numeric.kt b/kilua/src/commonMain/kotlin/dev/kilua/form/number/Numeric.kt index 1aaecb501..8fbe10314 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/form/number/Numeric.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/form/number/Numeric.kt @@ -35,7 +35,6 @@ import dev.kilua.i18n.Locale import dev.kilua.i18n.LocaleManager import dev.kilua.utils.toFixedNoRound import dev.kilua.utils.toLocaleString -import web.dom.events.Event /** * The default number of decimal digits. @@ -192,7 +191,7 @@ public open class Numeric( } } @Suppress("LeakingThis") - onEventDirect("change") { + onEventDirect("change") { formatElement() } } diff --git a/kilua/src/commonMain/kotlin/dev/kilua/form/select/Select.kt b/kilua/src/commonMain/kotlin/dev/kilua/form/select/Select.kt index 937e2d10b..6e54421c1 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/form/select/Select.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/form/select/Select.kt @@ -40,7 +40,7 @@ import dev.kilua.state.WithStateFlowDelegate import dev.kilua.state.WithStateFlowDelegateImpl import dev.kilua.utils.StringPair import dev.kilua.utils.nativeListOf -import web.dom.HTMLSelectElement +import dev.kilua.dom.api.HTMLSelectElement /** * The special value for an empty option. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/form/text/TextArea.kt b/kilua/src/commonMain/kotlin/dev/kilua/form/text/TextArea.kt index 50ac1c569..62fb6f1cd 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/form/text/TextArea.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/form/text/TextArea.kt @@ -35,7 +35,7 @@ import dev.kilua.state.WithStateFlow import dev.kilua.state.WithStateFlowDelegate import dev.kilua.state.WithStateFlowDelegateImpl import dev.kilua.utils.toKebabCase -import web.dom.HTMLTextAreaElement +import dev.kilua.dom.api.HTMLTextAreaElement /** * Textarea wrap types. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/form/upload/Upload.kt b/kilua/src/commonMain/kotlin/dev/kilua/form/upload/Upload.kt index 11160c29e..c002312ab 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/form/upload/Upload.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/form/upload/Upload.kt @@ -35,9 +35,9 @@ import dev.kilua.html.helpers.PropertyListBuilder import dev.kilua.types.KFile import dev.kilua.utils.getContent import dev.kilua.utils.toKebabCase -import web.dom.asList -import web.files.File -import web.toInt +import dev.kilua.dom.api.asList +import dev.kilua.dom.files.File +import dev.kilua.dom.toInt /** * File upload input capture mode values diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/Button.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/Button.kt index 043a5c679..bc9314002 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/Button.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/Button.kt @@ -30,8 +30,7 @@ import dev.kilua.core.RenderConfig import dev.kilua.html.helpers.PropertyListBuilder import dev.kilua.utils.rem import dev.kilua.utils.toKebabCase -import web.dom.HTMLButtonElement -import web.dom.events.MouseEvent +import dev.kilua.dom.api.HTMLButtonElement /** * Button types. @@ -144,7 +143,7 @@ public open class Button( element.click() } else { tagEvents.eventsMap["click"]?.forEach { - it.value(MouseEvent("click")) + it.value(dev.kilua.dom.api.events.MouseEvent("click")) } } } diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/Canvas.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/Canvas.kt index dd59d5713..fa1e104d9 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/Canvas.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/Canvas.kt @@ -29,8 +29,8 @@ import dev.kilua.core.IComponent import dev.kilua.core.RenderConfig import dev.kilua.html.helpers.PropertyListBuilder import dev.kilua.utils.cast -import web.dom.CanvasRenderingContext2D -import web.dom.HTMLCanvasElement +import dev.kilua.dom.api.CanvasRenderingContext2D +import dev.kilua.dom.api.HTMLCanvasElement /** * HTML Canvas component. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/CommentNode.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/CommentNode.kt index 7d796973c..769332379 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/CommentNode.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/CommentNode.kt @@ -30,7 +30,7 @@ import dev.kilua.core.IComponent import dev.kilua.core.RenderConfig import dev.kilua.core.SafeDomFactory import dev.kilua.utils.unsafeCast -import web.dom.Comment +import dev.kilua.dom.api.Comment /** * HTML comment node component. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/HtmlTags.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/HtmlTags.kt index ffe1c9ff3..6a2bd87bd 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/HtmlTags.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/HtmlTags.kt @@ -23,7 +23,7 @@ package dev.kilua.html import dev.kilua.annotations.SimpleHtmlComponent -import web.dom.* +import dev.kilua.dom.api.* /** * HTML Abbr component. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/Iframe.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/Iframe.kt index b1662ff25..05f4f257d 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/Iframe.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/Iframe.kt @@ -29,7 +29,7 @@ import dev.kilua.core.IComponent import dev.kilua.core.RenderConfig import dev.kilua.html.helpers.PropertyListBuilder import dev.kilua.utils.toKebabCase -import web.dom.HTMLIFrameElement +import dev.kilua.dom.api.HTMLIFrameElement /** * Iframe sandbox options. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/Img.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/Img.kt index d73e7c646..954dbc19a 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/Img.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/Img.kt @@ -28,7 +28,7 @@ import dev.kilua.compose.ComponentNode import dev.kilua.core.IComponent import dev.kilua.core.RenderConfig import dev.kilua.html.helpers.PropertyListBuilder -import web.dom.HTMLImageElement +import dev.kilua.dom.api.HTMLImageElement /** * HTML Img component. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/Label.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/Label.kt index 327bb6d50..9ecb500d4 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/Label.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/Label.kt @@ -28,7 +28,7 @@ import dev.kilua.compose.ComponentNode import dev.kilua.core.IComponent import dev.kilua.core.RenderConfig import dev.kilua.html.helpers.PropertyListBuilder -import web.dom.HTMLLabelElement +import dev.kilua.dom.api.HTMLLabelElement /** * HTML Label component. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/Link.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/Link.kt index 33ebd7f4e..3619b8842 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/Link.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/Link.kt @@ -29,7 +29,7 @@ import dev.kilua.core.IComponent import dev.kilua.core.RenderConfig import dev.kilua.html.helpers.PropertyListBuilder import dev.kilua.utils.rem -import web.dom.HTMLAnchorElement +import dev.kilua.dom.api.HTMLAnchorElement /** * HTML A component. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/Ol.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/Ol.kt index 4c15e788a..7e7c339aa 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/Ol.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/Ol.kt @@ -28,7 +28,7 @@ import dev.kilua.compose.ComponentNode import dev.kilua.core.IComponent import dev.kilua.core.RenderConfig import dev.kilua.html.helpers.PropertyListBuilder -import web.dom.HTMLOListElement +import dev.kilua.dom.api.HTMLOListElement /** * Numbered list types. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/Optgroup.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/Optgroup.kt index a1eedec63..ad2cfa26a 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/Optgroup.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/Optgroup.kt @@ -28,7 +28,7 @@ import dev.kilua.compose.ComponentNode import dev.kilua.core.IComponent import dev.kilua.core.RenderConfig import dev.kilua.html.helpers.PropertyListBuilder -import web.dom.HTMLOptGroupElement +import dev.kilua.dom.api.HTMLOptGroupElement /** * HTML Optgroup component. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/Option.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/Option.kt index a3d79bbfa..ca28f8fa5 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/Option.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/Option.kt @@ -28,7 +28,7 @@ import dev.kilua.compose.ComponentNode import dev.kilua.core.IComponent import dev.kilua.core.RenderConfig import dev.kilua.html.helpers.PropertyListBuilder -import web.dom.HTMLOptionElement +import dev.kilua.dom.api.HTMLOptionElement /** * HTML Option component. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/Tag.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/Tag.kt index 94aefac26..bd9b0f501 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/Tag.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/Tag.kt @@ -37,7 +37,7 @@ import dev.kilua.utils.nativeListOf import dev.kilua.utils.renderAsCssStyle import dev.kilua.utils.renderAsHtmlAttributes import dev.kilua.utils.unsafeCast -import web.dom.HTMLElement +import dev.kilua.dom.api.HTMLElement /** * Base interface for all HTML tags components. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/Td.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/Td.kt index f0732ff35..997db3dad 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/Td.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/Td.kt @@ -28,7 +28,7 @@ import dev.kilua.compose.ComponentNode import dev.kilua.core.IComponent import dev.kilua.core.RenderConfig import dev.kilua.html.helpers.PropertyListBuilder -import web.dom.HTMLTableCellElement +import dev.kilua.dom.api.HTMLTableCellElement /** * HTML Td component. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/TextNode.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/TextNode.kt index 2f3b1555e..e9a0a309e 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/TextNode.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/TextNode.kt @@ -30,7 +30,7 @@ import dev.kilua.core.IComponent import dev.kilua.core.RenderConfig import dev.kilua.core.SafeDomFactory import dev.kilua.utils.unsafeCast -import web.dom.Text +import dev.kilua.dom.api.Text /** * HTML text node component. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/Th.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/Th.kt index d84c29c99..0ba6bbb40 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/Th.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/Th.kt @@ -29,7 +29,7 @@ import dev.kilua.core.IComponent import dev.kilua.core.RenderConfig import dev.kilua.html.helpers.PropertyListBuilder import dev.kilua.utils.toKebabCase -import web.dom.HTMLTableCellElement +import dev.kilua.dom.api.HTMLTableCellElement /** * Table header scopes. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagAttrs.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagAttrs.kt index 11b6685f7..cb9cdb3d2 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagAttrs.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagAttrs.kt @@ -22,7 +22,7 @@ package dev.kilua.html.helpers -import web.dom.HTMLElement +import dev.kilua.dom.api.HTMLElement /** * Common tag attributes. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagAttrsDelegate.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagAttrsDelegate.kt index 124ba98d1..94da38fd4 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagAttrsDelegate.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagAttrsDelegate.kt @@ -24,7 +24,7 @@ package dev.kilua.html.helpers import androidx.compose.runtime.Composable import dev.kilua.core.PropertyDelegate -import web.dom.HTMLElement +import dev.kilua.dom.api.HTMLElement import kotlin.collections.set /** diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagAttrsFun.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagAttrsFun.kt index c43c24d82..6538af3da 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagAttrsFun.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagAttrsFun.kt @@ -23,7 +23,7 @@ package dev.kilua.html.helpers import androidx.compose.runtime.Composable -import web.dom.HTMLElement +import dev.kilua.dom.api.HTMLElement /** * Common tag attributes. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagDnd.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagDnd.kt index 87d75d6bf..05badc016 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagDnd.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagDnd.kt @@ -23,8 +23,8 @@ package dev.kilua.html.helpers import androidx.compose.runtime.Composable -import web.dom.DragEvent -import web.dom.HTMLElement +import dev.kilua.dom.api.DragEvent +import dev.kilua.dom.api.HTMLElement /** * Common drag and drop methods. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagDndDelegate.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagDndDelegate.kt index 099231eda..43ab2c15f 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagDndDelegate.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagDndDelegate.kt @@ -25,8 +25,8 @@ package dev.kilua.html.helpers import androidx.compose.runtime.Composable import dev.kilua.html.Tag import dev.kilua.utils.toList -import web.dom.DragEvent -import web.dom.HTMLElement +import dev.kilua.dom.api.DragEvent +import dev.kilua.dom.api.HTMLElement /** * Common drag and drop methods delegate. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagEvents.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagEvents.kt index 2141df920..f8339c239 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagEvents.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagEvents.kt @@ -23,12 +23,7 @@ package dev.kilua.html.helpers import androidx.compose.runtime.Composable -import web.dom.HTMLElement -import web.dom.events.Event -import web.dom.events.FocusEvent -import web.dom.events.InputEvent -import web.dom.events.KeyboardEvent -import web.dom.events.MouseEvent +import dev.kilua.dom.api.HTMLElement /** * Common tag events. @@ -39,122 +34,122 @@ public interface TagEvents { * Add click event listener (composable). */ @Composable - public fun onClick(listener: (MouseEvent) -> Unit): Int + public fun onClick(listener: (dev.kilua.dom.api.events.MouseEvent) -> Unit): Int /** * Add click event listener (not composable). */ - public fun onClickDirect(listener: (MouseEvent) -> Unit): Int + public fun onClickDirect(listener: (dev.kilua.dom.api.events.MouseEvent) -> Unit): Int /** * Add context menu event listener (composable). */ @Composable - public fun onContextmenu(listener: (MouseEvent) -> Unit): Int + public fun onContextmenu(listener: (dev.kilua.dom.api.events.MouseEvent) -> Unit): Int /** * Add context menu event listener (not composable). */ - public fun onContextmenuDirect(listener: (MouseEvent) -> Unit): Int + public fun onContextmenuDirect(listener: (dev.kilua.dom.api.events.MouseEvent) -> Unit): Int /** * Add double click event listener (composable). */ @Composable - public fun onDblclick(listener: (MouseEvent) -> Unit): Int + public fun onDblclick(listener: (dev.kilua.dom.api.events.MouseEvent) -> Unit): Int /** * Add double click event listener (not composable). */ - public fun onDblclickDirect(listener: (MouseEvent) -> Unit): Int + public fun onDblclickDirect(listener: (dev.kilua.dom.api.events.MouseEvent) -> Unit): Int /** * Add change event listener (composable). */ @Composable - public fun onChange(listener: (Event) -> Unit): Int + public fun onChange(listener: (dev.kilua.dom.api.events.Event) -> Unit): Int /** * Add change event listener (not composable). */ - public fun onChangeDirect(listener: (Event) -> Unit): Int + public fun onChangeDirect(listener: (dev.kilua.dom.api.events.Event) -> Unit): Int /** * Add input event listener (composable). */ @Composable - public fun onInput(listener: (InputEvent) -> Unit): Int + public fun onInput(listener: (dev.kilua.dom.api.events.InputEvent) -> Unit): Int /** * Add input event listener (not composable). */ - public fun onInputDirect(listener: (InputEvent) -> Unit): Int + public fun onInputDirect(listener: (dev.kilua.dom.api.events.InputEvent) -> Unit): Int /** * Add focus event listener (composable). */ @Composable - public fun onFocus(listener: (FocusEvent) -> Unit): Int + public fun onFocus(listener: (dev.kilua.dom.api.events.FocusEvent) -> Unit): Int /** * Add focus event listener (not composable). */ - public fun onFocusDirect(listener: (FocusEvent) -> Unit): Int + public fun onFocusDirect(listener: (dev.kilua.dom.api.events.FocusEvent) -> Unit): Int /** * Add blur event listener (composable). */ @Composable - public fun onBlur(listener: (FocusEvent) -> Unit): Int + public fun onBlur(listener: (dev.kilua.dom.api.events.FocusEvent) -> Unit): Int /** * Add blur event listener (not composable). */ - public fun onBlurDirect(listener: (FocusEvent) -> Unit): Int + public fun onBlurDirect(listener: (dev.kilua.dom.api.events.FocusEvent) -> Unit): Int /** * Add key down event listener (composable). */ @Composable - public fun onKeydown(listener: (KeyboardEvent) -> Unit): Int + public fun onKeydown(listener: (dev.kilua.dom.api.events.KeyboardEvent) -> Unit): Int /** * Add key down event listener (not composable). */ - public fun onKeydownDirect(listener: (KeyboardEvent) -> Unit): Int + public fun onKeydownDirect(listener: (dev.kilua.dom.api.events.KeyboardEvent) -> Unit): Int /** * Add key up event listener (composable). */ @Composable - public fun onKeyup(listener: (KeyboardEvent) -> Unit): Int + public fun onKeyup(listener: (dev.kilua.dom.api.events.KeyboardEvent) -> Unit): Int /** * Add key up event listener (not composable). */ - public fun onKeyupDirect(listener: (KeyboardEvent) -> Unit): Int + public fun onKeyupDirect(listener: (dev.kilua.dom.api.events.KeyboardEvent) -> Unit): Int /** * Add key press event listener (composable). */ @Composable - public fun onKeypress(listener: (KeyboardEvent) -> Unit): Int + public fun onKeypress(listener: (dev.kilua.dom.api.events.KeyboardEvent) -> Unit): Int /** * Add key press event listener (not composable). */ - public fun onKeypressDirect(listener: (KeyboardEvent) -> Unit): Int + public fun onKeypressDirect(listener: (dev.kilua.dom.api.events.KeyboardEvent) -> Unit): Int /** * Add event listener by event name (composable). */ @Composable - public fun onEvent(name: String, listener: (EV) -> Unit): Int + public fun onEvent(name: String, listener: (EV) -> Unit): Int /** * Add event listener by event name (not composable). */ - public fun onEventDirect(name: String, listener: (EV) -> Unit): Int + public fun onEventDirect(name: String, listener: (EV) -> Unit): Int /** * Remove event listener by event name and ID. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagEventsDelegate.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagEventsDelegate.kt index 73526f8da..f0ebecda3 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagEventsDelegate.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagEventsDelegate.kt @@ -29,12 +29,7 @@ import dev.kilua.externals.AbortController import dev.kilua.externals.buildAddEventListenerOptions import dev.kilua.utils.cast import dev.kilua.utils.nativeMapOf -import web.dom.HTMLElement -import web.dom.events.Event -import web.dom.events.FocusEvent -import web.dom.events.InputEvent -import web.dom.events.KeyboardEvent -import web.dom.events.MouseEvent +import dev.kilua.dom.api.HTMLElement import kotlin.collections.component1 import kotlin.collections.component2 import kotlin.collections.set @@ -46,7 +41,7 @@ public interface TagEventsDelegate : TagEvents { /** * The map of events. */ - public val eventsMap: Map Unit>> + public val eventsMap: Map Unit>> /** * Connects the delegate with the given element. @@ -62,9 +57,9 @@ public open class TagEventsDelegateImpl( protected val skipUpdates: Boolean, ) : TagEventsDelegate { - protected val events: MutableMap Unit>> by lazy { nativeMapOf() } + protected val events: MutableMap Unit>> by lazy { nativeMapOf() } - public override val eventsMap: Map Unit>> by lazy { events } + public override val eventsMap: Map Unit>> by lazy { events } protected val eventsAbortControllers: MutableMap by lazy { nativeMapOf() } @@ -79,97 +74,97 @@ public open class TagEventsDelegateImpl( } @Composable - override fun onClick(listener: (MouseEvent) -> Unit): Int { + override fun onClick(listener: (dev.kilua.dom.api.events.MouseEvent) -> Unit): Int { return onEvent("click", listener) } - override fun onClickDirect(listener: (MouseEvent) -> Unit): Int { + override fun onClickDirect(listener: (dev.kilua.dom.api.events.MouseEvent) -> Unit): Int { return onEventDirect("click", listener) } @Composable - override fun onContextmenu(listener: (MouseEvent) -> Unit): Int { + override fun onContextmenu(listener: (dev.kilua.dom.api.events.MouseEvent) -> Unit): Int { return onEvent("contextmenu", listener) } - override fun onContextmenuDirect(listener: (MouseEvent) -> Unit): Int { + override fun onContextmenuDirect(listener: (dev.kilua.dom.api.events.MouseEvent) -> Unit): Int { return onEventDirect("contextmenu", listener) } @Composable - override fun onDblclick(listener: (MouseEvent) -> Unit): Int { + override fun onDblclick(listener: (dev.kilua.dom.api.events.MouseEvent) -> Unit): Int { return onEvent("dblclick", listener) } - override fun onDblclickDirect(listener: (MouseEvent) -> Unit): Int { + override fun onDblclickDirect(listener: (dev.kilua.dom.api.events.MouseEvent) -> Unit): Int { return onEventDirect("dblclick", listener) } @Composable - override fun onChange(listener: (Event) -> Unit): Int { + override fun onChange(listener: (dev.kilua.dom.api.events.Event) -> Unit): Int { return onEvent("change", listener) } - override fun onChangeDirect(listener: (Event) -> Unit): Int { + override fun onChangeDirect(listener: (dev.kilua.dom.api.events.Event) -> Unit): Int { return onEventDirect("change", listener) } @Composable - override fun onInput(listener: (InputEvent) -> Unit): Int { + override fun onInput(listener: (dev.kilua.dom.api.events.InputEvent) -> Unit): Int { return onEvent("input", listener) } - override fun onInputDirect(listener: (InputEvent) -> Unit): Int { + override fun onInputDirect(listener: (dev.kilua.dom.api.events.InputEvent) -> Unit): Int { return onEventDirect("input", listener) } @Composable - override fun onFocus(listener: (FocusEvent) -> Unit): Int { + override fun onFocus(listener: (dev.kilua.dom.api.events.FocusEvent) -> Unit): Int { return onEvent("focus", listener) } - override fun onFocusDirect(listener: (FocusEvent) -> Unit): Int { + override fun onFocusDirect(listener: (dev.kilua.dom.api.events.FocusEvent) -> Unit): Int { return onEventDirect("focus", listener) } @Composable - override fun onBlur(listener: (FocusEvent) -> Unit): Int { + override fun onBlur(listener: (dev.kilua.dom.api.events.FocusEvent) -> Unit): Int { return onEvent("blur", listener) } - override fun onBlurDirect(listener: (FocusEvent) -> Unit): Int { + override fun onBlurDirect(listener: (dev.kilua.dom.api.events.FocusEvent) -> Unit): Int { return onEventDirect("blur", listener) } @Composable - override fun onKeydown(listener: (KeyboardEvent) -> Unit): Int { + override fun onKeydown(listener: (dev.kilua.dom.api.events.KeyboardEvent) -> Unit): Int { return onEvent("keydown", listener) } - override fun onKeydownDirect(listener: (KeyboardEvent) -> Unit): Int { + override fun onKeydownDirect(listener: (dev.kilua.dom.api.events.KeyboardEvent) -> Unit): Int { return onEventDirect("keydown", listener) } @Composable - override fun onKeyup(listener: (KeyboardEvent) -> Unit): Int { + override fun onKeyup(listener: (dev.kilua.dom.api.events.KeyboardEvent) -> Unit): Int { return onEvent("keyup", listener) } - override fun onKeyupDirect(listener: (KeyboardEvent) -> Unit): Int { + override fun onKeyupDirect(listener: (dev.kilua.dom.api.events.KeyboardEvent) -> Unit): Int { return onEventDirect("keyup", listener) } @Composable - override fun onKeypress(listener: (KeyboardEvent) -> Unit): Int { + override fun onKeypress(listener: (dev.kilua.dom.api.events.KeyboardEvent) -> Unit): Int { return onEvent("keypress", listener) } - override fun onKeypressDirect(listener: (KeyboardEvent) -> Unit): Int { + override fun onKeypressDirect(listener: (dev.kilua.dom.api.events.KeyboardEvent) -> Unit): Int { return onEventDirect("keypress", listener) } @Composable - override fun onEvent(name: String, listener: (E) -> Unit): Int { + override fun onEvent(name: String, listener: (E) -> Unit): Int { val id = remember { counter++ } onEventInternal(id, name, listener) DisposableEffect(id) { @@ -180,18 +175,18 @@ public open class TagEventsDelegateImpl( return id } - override fun onEventDirect(name: String, listener: (E) -> Unit): Int { + override fun onEventDirect(name: String, listener: (E) -> Unit): Int { val id = counter++ onEventInternal(id, name, listener) return id } - protected fun onEventInternal( + protected fun onEventInternal( id: Int, name: String, listener: (E) -> Unit ) { - val listeners = events[name] ?: nativeMapOf<(Event) -> Unit>().also { events[name] = it } + val listeners = events[name] ?: nativeMapOf<(dev.kilua.dom.api.events.Event) -> Unit>().also { events[name] = it } listeners["$id"] = listener.cast() if (skipUpdates || elementNullable == null) return eventsAbortControllers[name]?.abort() diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagEventsSuspending.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagEventsSuspending.kt index 10faf157b..c4a2971a2 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagEventsSuspending.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagEventsSuspending.kt @@ -26,10 +26,7 @@ import androidx.compose.runtime.Composable import dev.kilua.KiluaScope import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch -import web.dom.HTMLElement -import web.dom.events.Event -import web.dom.events.InputEvent -import web.dom.events.MouseEvent +import dev.kilua.dom.api.HTMLElement /** * An extension function for defining on click suspending event handlers (composable). @@ -37,7 +34,7 @@ import web.dom.events.MouseEvent @Composable public fun > C.onClickLaunch( coroutineScope: CoroutineScope = KiluaScope, - listener: suspend (MouseEvent) -> Unit + listener: suspend (dev.kilua.dom.api.events.MouseEvent) -> Unit ): Int { return onClick { coroutineScope.launch { @@ -51,7 +48,7 @@ public fun > C.onClickLaunch( */ public fun > C.onClickDirectLaunch( coroutineScope: CoroutineScope = KiluaScope, - listener: suspend (MouseEvent) -> Unit + listener: suspend (dev.kilua.dom.api.events.MouseEvent) -> Unit ): Int { return onClickDirect { coroutineScope.launch { @@ -66,7 +63,7 @@ public fun > C.onClickDirectLaunch( @Composable public fun > C.onInputLaunch( coroutineScope: CoroutineScope = KiluaScope, - listener: suspend (InputEvent) -> Unit + listener: suspend (dev.kilua.dom.api.events.InputEvent) -> Unit ): Int { return onInput { coroutineScope.launch { @@ -80,7 +77,7 @@ public fun > C.onInputLaunch( */ public fun > C.onInputDirectLaunch( coroutineScope: CoroutineScope = KiluaScope, - listener: suspend (InputEvent) -> Unit + listener: suspend (dev.kilua.dom.api.events.InputEvent) -> Unit ): Int { return onInputDirect { coroutineScope.launch { @@ -95,7 +92,7 @@ public fun > C.onInputDirectLaunch( @Composable public fun > C.onChangeLaunch( coroutineScope: CoroutineScope = KiluaScope, - listener: suspend (Event) -> Unit + listener: suspend (dev.kilua.dom.api.events.Event) -> Unit ): Int { return onChange { coroutineScope.launch { @@ -109,7 +106,7 @@ public fun > C.onChangeLaunch( */ public fun > C.onChangeDirectLaunch( coroutineScope: CoroutineScope = KiluaScope, - listener: suspend (Event) -> Unit + listener: suspend (dev.kilua.dom.api.events.Event) -> Unit ): Int { return onChangeDirect { coroutineScope.launch { @@ -122,7 +119,7 @@ public fun > C.onChangeDirectLaunch( * An extension function for defining on change suspending event handlers (composable). */ @Composable -public fun > C.onEventLaunch( +public fun > C.onEventLaunch( name: String, coroutineScope: CoroutineScope = KiluaScope, listener: suspend (EV) -> Unit @@ -137,7 +134,7 @@ public fun > C.onEventLaunch( /** * An extension function for defining on change suspending event handlers (not composable). */ -public fun > C.onEventDirectLaunch( +public fun > C.onEventDirectLaunch( name: String, coroutineScope: CoroutineScope = KiluaScope, listener: suspend (EV) -> Unit diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagStyle.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagStyle.kt index 51c9e8792..6a18f93b3 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagStyle.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagStyle.kt @@ -24,7 +24,7 @@ package dev.kilua.html.helpers import dev.kilua.html.* -import web.dom.HTMLElement +import dev.kilua.dom.api.HTMLElement /** * Common tag CSS styles. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagStyleDelegate.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagStyleDelegate.kt index 1d2bed374..38a3615c0 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagStyleDelegate.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagStyleDelegate.kt @@ -27,7 +27,7 @@ import androidx.compose.runtime.Composable import dev.kilua.core.PropertyDelegate import dev.kilua.html.* import dev.kilua.utils.cast -import web.dom.HTMLElement +import dev.kilua.dom.api.HTMLElement public interface TagStyleDelegate : TagStyle { /** diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagStyleFun.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagStyleFun.kt index 56fe8a86f..b72381e3d 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagStyleFun.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/helpers/TagStyleFun.kt @@ -25,7 +25,7 @@ package dev.kilua.html.helpers import androidx.compose.runtime.Composable import dev.kilua.html.* -import web.dom.HTMLElement +import dev.kilua.dom.api.HTMLElement /** * Common tag CSS styles. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/style/CssStyle.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/style/CssStyle.kt index 529922758..3ff099603 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/style/CssStyle.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/style/CssStyle.kt @@ -27,7 +27,7 @@ import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.remember import dev.kilua.html.helpers.TagStyle import dev.kilua.html.helpers.TagStyleDelegateImpl -import web.dom.HTMLStyleElement +import dev.kilua.dom.api.HTMLStyleElement /** * An object with CSS properties. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/html/style/Style.kt b/kilua/src/commonMain/kotlin/dev/kilua/html/style/Style.kt index 2a88e128c..ac33cba30 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/html/style/Style.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/html/style/Style.kt @@ -28,7 +28,7 @@ import dev.kilua.compose.ComponentNode import dev.kilua.core.IComponent import dev.kilua.core.RenderConfig import dev.kilua.html.Tag -import web.dom.HTMLStyleElement +import dev.kilua.dom.api.HTMLStyleElement /** * Internal HTML Style component. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/i18n/DefaultLocale.kt b/kilua/src/commonMain/kotlin/dev/kilua/i18n/DefaultLocale.kt index ce23cbbec..f0022221b 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/i18n/DefaultLocale.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/i18n/DefaultLocale.kt @@ -24,7 +24,7 @@ package dev.kilua.i18n import dev.kilua.externals.Intl import dev.kilua.utils.isDom -import web.window +import dev.kilua.dom.window /** * Auto-detected default system locale. diff --git a/kilua/src/commonMain/kotlin/dev/kilua/utils/File.kt b/kilua/src/commonMain/kotlin/dev/kilua/utils/File.kt index 32f193bad..adf58064c 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/utils/File.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/utils/File.kt @@ -23,8 +23,8 @@ package dev.kilua.utils import kotlinx.coroutines.suspendCancellableCoroutine -import web.files.File -import web.files.FileReader +import dev.kilua.dom.files.File +import dev.kilua.dom.files.FileReader import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException diff --git a/kilua/src/commonMain/kotlin/dev/kilua/utils/JavaScript.kt b/kilua/src/commonMain/kotlin/dev/kilua/utils/JavaScript.kt index 3b66041a2..d1c090cc9 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/utils/JavaScript.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/utils/JavaScript.kt @@ -31,13 +31,12 @@ import dev.kilua.externals.keys import dev.kilua.externals.obj import dev.kilua.externals.set import dev.kilua.externals.undefined -import web.JsAny -import web.JsArray -import web.get -import web.set -import web.toJsBoolean -import web.toJsNumber -import web.toJsString +import dev.kilua.dom.JsAny +import dev.kilua.dom.get +import dev.kilua.dom.set +import dev.kilua.dom.toJsBoolean +import dev.kilua.dom.toJsNumber +import dev.kilua.dom.toJsString /** * JavaScript encodeURIComponent function @@ -62,29 +61,29 @@ public expect inline fun JsAny.unsafeCast(): T /** * Convert JsArray to Kotlin Array. */ -public inline fun JsArray.toArray(): Array { +public inline fun dev.kilua.dom.JsArray.toArray(): Array { return Array(length) { get(it)!! } } /** * Convert Kotlin Array to JsArray. */ -public fun Array.toJsArray(): JsArray { +public fun Array.toJsArray(): dev.kilua.dom.JsArray { return jsArrayOf(*this) } /** * Convert JsArray to Kotlin List. */ -public fun JsArray.toList(): List { +public fun dev.kilua.dom.JsArray.toList(): List { return List(length) { get(it)!! } } /** * Convert Kotlin List to JsArray. */ -public fun List.toJsArray(): JsArray { - val array = JsArray() +public fun List.toJsArray(): dev.kilua.dom.JsArray { + val array = dev.kilua.dom.JsArray() for (i in this.indices) { array[i] = this[i] } @@ -94,8 +93,8 @@ public fun List.toJsArray(): JsArray { /** * Create a JsArray object. */ -public fun jsArrayOf(vararg elements: T): JsArray { - val array = JsArray() +public fun jsArrayOf(vararg elements: T): dev.kilua.dom.JsArray { + val array = dev.kilua.dom.JsArray() for (i in elements.indices) { array[i] = elements[i] } @@ -113,7 +112,7 @@ public fun T.toJsAny(): JsAny? { is Double -> this.toJsNumber() is Boolean -> this.toJsBoolean() is Array<*> -> { - val array = JsArray() + val array = dev.kilua.dom.JsArray() for (index in this.indices) { array[index] = this[index].toJsAny() } @@ -121,7 +120,7 @@ public fun T.toJsAny(): JsAny? { } is List<*> -> { - val array = JsArray() + val array = dev.kilua.dom.JsArray() for (index in this.indices) { array[index] = this[index].toJsAny() } @@ -168,7 +167,7 @@ public fun deepMerge(target: JsAny, source: JsAny): JsAny { val targetValue = target[key] val sourceValue = source[key] if (isArray(targetValue) && isArray(sourceValue)) { - target[key] = concat(targetValue!!.unsafeCast>(), sourceValue.cast()) + target[key] = concat(targetValue!!.unsafeCast>(), sourceValue.cast()) } else if (isObject(targetValue) && isObject(sourceValue)) { val newObj = obj() assign(newObj, targetValue!!) diff --git a/kilua/src/commonMain/kotlin/dev/kilua/utils/Serialization.kt b/kilua/src/commonMain/kotlin/dev/kilua/utils/Serialization.kt index 2598b431d..f7ab616e2 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/utils/Serialization.kt +++ b/kilua/src/commonMain/kotlin/dev/kilua/utils/Serialization.kt @@ -25,7 +25,7 @@ import dev.kilua.externals.JSON import kotlinx.serialization.SerializationStrategy import kotlinx.serialization.json.Json import kotlinx.serialization.serializer -import web.JsAny +import dev.kilua.dom.JsAny /** * JSON serialization utility functions diff --git a/kilua/src/commonTest/kotlin/dev/kilua/compose/ComponentApplierSpec.kt b/kilua/src/commonTest/kotlin/dev/kilua/compose/ComponentApplierSpec.kt index 1a57da0bc..decc08427 100644 --- a/kilua/src/commonTest/kotlin/dev/kilua/compose/ComponentApplierSpec.kt +++ b/kilua/src/commonTest/kotlin/dev/kilua/compose/ComponentApplierSpec.kt @@ -32,7 +32,7 @@ import dev.kilua.core.Component import dev.kilua.core.StringRenderConfig import dev.kilua.core.SafeDomFactory import dev.kilua.html.Tag -import web.dom.HTMLElement +import dev.kilua.dom.api.HTMLElement import kotlin.test.Test import kotlin.test.assertEquals @@ -230,4 +230,4 @@ class ComponentApplierSpec : SimpleSpec { private fun assertChildren(vararg nodes: Component) { assertEquals(nodes.toList(), root.children.toList()) } -} \ No newline at end of file +} diff --git a/kilua/src/commonTest/kotlin/dev/kilua/html/CanvasSpec.kt b/kilua/src/commonTest/kotlin/dev/kilua/html/CanvasSpec.kt index 34e594d4b..88f5ee658 100644 --- a/kilua/src/commonTest/kotlin/dev/kilua/html/CanvasSpec.kt +++ b/kilua/src/commonTest/kotlin/dev/kilua/html/CanvasSpec.kt @@ -24,9 +24,8 @@ package dev.kilua.html import dev.kilua.compose.root import dev.kilua.test.DomSpec -import dev.kilua.test.normalizeHtml -import web.dom.ImageData -import web.toJsString +import dev.kilua.dom.api.ImageData +import dev.kilua.dom.toJsString import kotlin.test.Test import kotlin.test.assertEquals diff --git a/kilua/src/jsMain/kotlin/dev/kilua/Coroutines.js.kt b/kilua/src/jsMain/kotlin/dev/kilua/Coroutines.js.kt index 64bea94d0..83fa095b6 100644 --- a/kilua/src/jsMain/kotlin/dev/kilua/Coroutines.js.kt +++ b/kilua/src/jsMain/kotlin/dev/kilua/Coroutines.js.kt @@ -23,8 +23,8 @@ package dev.kilua import kotlinx.coroutines.Deferred -import web.JsAny -import web.Promise +import dev.kilua.dom.JsAny +import dev.kilua.dom.Promise import kotlinx.coroutines.asDeferred as asDeferredCrt import kotlinx.coroutines.asPromise as asPromiseCrt import kotlin.js.Promise as PromiseJs @@ -35,4 +35,4 @@ public actual fun Deferred.asPromise(): Promise { public actual fun Promise.asDeferred(): Deferred { return this.unsafeCast>().asDeferredCrt() -} \ No newline at end of file +} diff --git a/kilua/src/jsMain/kotlin/dev/kilua/externals/Array.js.kt b/kilua/src/jsMain/kotlin/dev/kilua/externals/Array.js.kt index cfd194443..21b8435ea 100644 --- a/kilua/src/jsMain/kotlin/dev/kilua/externals/Array.js.kt +++ b/kilua/src/jsMain/kotlin/dev/kilua/externals/Array.js.kt @@ -23,8 +23,7 @@ package dev.kilua.externals -import web.JsAny -import web.JsArray +import dev.kilua.dom.JsAny /** * Returns whether the given value is an array @@ -37,5 +36,5 @@ public actual fun isArray(o: JsAny?): Boolean = js("Array").isArray(o) * Returns a new array containing the contents of both given arrays. */ @Suppress("UnsafeCastFromDynamic") -public actual fun concat(array1: JsArray, array2: JsArray): JsArray = +public actual fun concat(array1: dev.kilua.dom.JsArray, array2: dev.kilua.dom.JsArray): dev.kilua.dom.JsArray = array1.asDynamic().concat(array2) diff --git a/kilua/src/jsMain/kotlin/dev/kilua/externals/Event.js.kt b/kilua/src/jsMain/kotlin/dev/kilua/externals/Event.js.kt index a68865f7f..5e2c6eebc 100644 --- a/kilua/src/jsMain/kotlin/dev/kilua/externals/Event.js.kt +++ b/kilua/src/jsMain/kotlin/dev/kilua/externals/Event.js.kt @@ -22,9 +22,9 @@ package dev.kilua.externals -import web.JsAny -import web.dom.AddEventListenerOptions -import web.dom.CustomEventInit +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.AddEventListenerOptions +import dev.kilua.dom.api.CustomEventInit public actual fun buildAddEventListenerOptions(signal: AbortSignal): AddEventListenerOptions { return obj { diff --git a/kilua/src/jsMain/kotlin/dev/kilua/externals/NodeJsDom.js.kt b/kilua/src/jsMain/kotlin/dev/kilua/externals/NodeJsDom.js.kt index bd5accff0..830a3e0b9 100644 --- a/kilua/src/jsMain/kotlin/dev/kilua/externals/NodeJsDom.js.kt +++ b/kilua/src/jsMain/kotlin/dev/kilua/externals/NodeJsDom.js.kt @@ -23,9 +23,9 @@ package dev.kilua.externals -import web.dom.Comment -import web.dom.Element -import web.dom.Text +import dev.kilua.dom.api.Comment +import dev.kilua.dom.api.Element +import dev.kilua.dom.api.Text internal actual external fun nodeJsCreateElement(): Element internal actual external fun nodeJsCreateText(): Text diff --git a/kilua/src/jsMain/kotlin/dev/kilua/externals/Object.js.kt b/kilua/src/jsMain/kotlin/dev/kilua/externals/Object.js.kt index 77437534d..d3073fc68 100644 --- a/kilua/src/jsMain/kotlin/dev/kilua/externals/Object.js.kt +++ b/kilua/src/jsMain/kotlin/dev/kilua/externals/Object.js.kt @@ -23,7 +23,7 @@ package dev.kilua.externals -import web.JsAny +import dev.kilua.dom.JsAny @Suppress("NOTHING_TO_INLINE", "UnsafeCastFromDynamic") public actual inline fun obj(): JsAny { diff --git a/kilua/src/jsMain/kotlin/dev/kilua/utils/JavaScript.js.kt b/kilua/src/jsMain/kotlin/dev/kilua/utils/JavaScript.js.kt index 2d18a6d9c..bd7272251 100644 --- a/kilua/src/jsMain/kotlin/dev/kilua/utils/JavaScript.js.kt +++ b/kilua/src/jsMain/kotlin/dev/kilua/utils/JavaScript.js.kt @@ -22,7 +22,7 @@ package dev.kilua.utils -import web.JsAny +import dev.kilua.dom.JsAny import kotlin.js.unsafeCast as unsafeCastJs @Suppress("NOTHING_TO_INLINE") diff --git a/kilua/src/jvmMain/kotlin/dev/kilua/compose/Root.jvm.kt b/kilua/src/jvmMain/kotlin/dev/kilua/compose/Root.jvm.kt new file mode 100644 index 000000000..c9ce195f8 --- /dev/null +++ b/kilua/src/jvmMain/kotlin/dev/kilua/compose/Root.jvm.kt @@ -0,0 +1,5 @@ +package dev.kilua.compose + +import androidx.compose.runtime.MonotonicFrameClock + +internal actual val defaultMonotonicFrameClock: MonotonicFrameClock = NoDomMonotonicClockImpl() diff --git a/kilua/src/wasmJsMain/kotlin/dev/kilua/Coroutines.wasmJs.kt b/kilua/src/wasmJsMain/kotlin/dev/kilua/Coroutines.wasmJs.kt index 651ea5f8b..949d016c2 100644 --- a/kilua/src/wasmJsMain/kotlin/dev/kilua/Coroutines.wasmJs.kt +++ b/kilua/src/wasmJsMain/kotlin/dev/kilua/Coroutines.wasmJs.kt @@ -24,8 +24,8 @@ package dev.kilua import dev.kilua.utils.cast import kotlinx.coroutines.Deferred -import web.JsAny -import web.Promise +import dev.kilua.dom.JsAny +import dev.kilua.dom.Promise import kotlinx.coroutines.asDeferred as asDeferredCrt import kotlinx.coroutines.asPromise as asPromiseCrt import kotlin.js.Promise as PromiseJs diff --git a/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/Array.wasmJs.kt b/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/Array.wasmJs.kt index 0496b677d..e09989ab0 100644 --- a/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/Array.wasmJs.kt +++ b/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/Array.wasmJs.kt @@ -23,8 +23,8 @@ package dev.kilua.externals -import web.JsAny -import web.JsArray +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray /** * Returns whether the given value is an array diff --git a/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/Event.wasmJs.kt b/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/Event.wasmJs.kt index 488d88800..48eb797af 100644 --- a/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/Event.wasmJs.kt +++ b/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/Event.wasmJs.kt @@ -22,9 +22,9 @@ package dev.kilua.externals -import web.JsAny -import web.dom.AddEventListenerOptions -import web.dom.CustomEventInit +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.AddEventListenerOptions +import dev.kilua.dom.api.CustomEventInit public actual fun buildAddEventListenerOptions(signal: AbortSignal): AddEventListenerOptions { return buildAddEventListenerOptionsInternal(signal) diff --git a/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/NodeJsDom.wasmJs.kt b/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/NodeJsDom.wasmJs.kt index 984bf2cfc..1394c3213 100644 --- a/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/NodeJsDom.wasmJs.kt +++ b/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/NodeJsDom.wasmJs.kt @@ -24,9 +24,9 @@ package dev.kilua.externals -import web.dom.Comment -import web.dom.Element -import web.dom.Text +import dev.kilua.dom.api.Comment +import dev.kilua.dom.api.Element +import dev.kilua.dom.api.Text internal actual external fun nodeJsCreateElement(): Element diff --git a/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/Object.wasmJs.kt b/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/Object.wasmJs.kt index 1fb9a7379..b423005e7 100644 --- a/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/Object.wasmJs.kt +++ b/kilua/src/wasmJsMain/kotlin/dev/kilua/externals/Object.wasmJs.kt @@ -24,7 +24,7 @@ package dev.kilua.externals import dev.kilua.utils.toArray -import web.JsAny +import dev.kilua.dom.JsAny public actual fun obj(): JsAny = js("({})") diff --git a/kilua/src/webMain/kotlin/dev/kilua/Coroutines.web.kt b/kilua/src/webMain/kotlin/dev/kilua/Coroutines.web.kt new file mode 100644 index 000000000..35970d481 --- /dev/null +++ b/kilua/src/webMain/kotlin/dev/kilua/Coroutines.web.kt @@ -0,0 +1,22 @@ +package dev.kilua + +import dev.kilua.dom.JsAny +import dev.kilua.dom.Promise +import dev.kilua.utils.cast +import kotlinx.coroutines.Deferred +import kotlinx.coroutines.async + +/** + * Convert Deferred to a JS Promise. + */ +public expect fun Deferred.asPromise(): Promise + +/** + * Convert JS Promise to a Deferred. + */ +public expect fun Promise.asDeferred(): Deferred + +/** + * Create a JS Promise from a suspending block. + */ +public fun promise(block: suspend () -> T): Promise = KiluaScope.async { block() }.asPromise().cast() diff --git a/kilua/src/commonMain/kotlin/dev/kilua/HMR.kt b/kilua/src/webMain/kotlin/dev/kilua/HMR.kt similarity index 98% rename from kilua/src/commonMain/kotlin/dev/kilua/HMR.kt rename to kilua/src/webMain/kotlin/dev/kilua/HMR.kt index aaaced477..4951546c6 100644 --- a/kilua/src/commonMain/kotlin/dev/kilua/HMR.kt +++ b/kilua/src/webMain/kotlin/dev/kilua/HMR.kt @@ -22,7 +22,7 @@ */ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny /** * Helper interface for Hot Module Replacement (HMR). diff --git a/modules/kilua-bootstrap-icons/src/commonMain/kotlin/dev/kilua/BootstrapIconsModule.kt b/modules/kilua-bootstrap-icons/src/commonMain/kotlin/dev/kilua/BootstrapIconsModule.kt index e9775bbeb..20c7662e0 100644 --- a/modules/kilua-bootstrap-icons/src/commonMain/kotlin/dev/kilua/BootstrapIconsModule.kt +++ b/modules/kilua-bootstrap-icons/src/commonMain/kotlin/dev/kilua/BootstrapIconsModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("bootstrap-icons/font/bootstrap-icons.min.css") internal external object BootstrapIconsCss : JsAny diff --git a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/BootstrapCssModule.kt b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/BootstrapCssModule.kt index 6c94c0cef..1111dec57 100644 --- a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/BootstrapCssModule.kt +++ b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/BootstrapCssModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("bootstrap/dist/css/bootstrap.min.css") internal external object BootstrapCss : JsAny diff --git a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/BootstrapModule.kt b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/BootstrapModule.kt index e5fcc2e10..a4ad6a50d 100644 --- a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/BootstrapModule.kt +++ b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/BootstrapModule.kt @@ -26,7 +26,7 @@ import dev.kilua.compose.Root import dev.kilua.modal.modals import dev.kilua.toast.toasts import dev.kilua.utils.isDom -import web.document +import dev.kilua.dom.document /** * Initializes Bootstrap module. diff --git a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/externals/Bootstrap.kt b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/externals/Bootstrap.kt index 17cd0dff8..dbb39a9a5 100644 --- a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/externals/Bootstrap.kt +++ b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/externals/Bootstrap.kt @@ -24,8 +24,8 @@ package dev.kilua.externals import dev.kilua.JsModule -import web.JsAny -import web.dom.HTMLElement +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.HTMLElement /** * External Bootstrap object. diff --git a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/modal/Alert.kt b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/modal/Alert.kt index f0aa47000..762f949ce 100644 --- a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/modal/Alert.kt +++ b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/modal/Alert.kt @@ -27,7 +27,6 @@ import dev.kilua.core.IComponent import dev.kilua.html.Button import dev.kilua.html.buttonRef import dev.kilua.html.div -import web.dom.events.Event /** @@ -75,11 +74,11 @@ public fun alert( } } } - onEvent("hidden.bs.modal") { + onEvent("hidden.bs.modal") { callback?.invoke() Modal.modalStateMap.remove(modalId) } - onEvent("shown.bs.modal") { + onEvent("shown.bs.modal") { button.focus() } show() diff --git a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/modal/Confirm.kt b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/modal/Confirm.kt index faeb291dc..cae112629 100644 --- a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/modal/Confirm.kt +++ b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/modal/Confirm.kt @@ -28,7 +28,6 @@ import dev.kilua.html.Button import dev.kilua.html.button import dev.kilua.html.buttonRef import dev.kilua.html.div -import web.dom.events.Event /** @@ -100,10 +99,10 @@ public fun confirm( } } } - onEvent("hidden.bs.modal") { + onEvent("hidden.bs.modal") { Modal.modalStateMap.remove(modalId) } - onEvent("shown.bs.modal") { + onEvent("shown.bs.modal") { yesButton.focus() } show() diff --git a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/modal/Modal.kt b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/modal/Modal.kt index 9e0c4a813..0cf803d90 100644 --- a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/modal/Modal.kt +++ b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/modal/Modal.kt @@ -40,8 +40,7 @@ import dev.kilua.html.h5t import dev.kilua.utils.cast import dev.kilua.utils.rem import dev.kilua.utils.toKebabCase -import web.dom.HTMLDivElement -import web.dom.events.Event +import dev.kilua.dom.api.HTMLDivElement /** * Modal window sizes. @@ -329,7 +328,7 @@ private fun IModal.setupModal( component.onRemove() } } - onEvent("hidden.bs.modal") { + onEvent("hidden.bs.modal") { component.hide() } } diff --git a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/Accordion.kt b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/Accordion.kt index 674e9bc5e..ed74ae281 100644 --- a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/Accordion.kt +++ b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/Accordion.kt @@ -43,7 +43,7 @@ import dev.kilua.html.h2 import dev.kilua.panel.Accordion.Companion.idCounter import dev.kilua.utils.cast import dev.kilua.utils.rem -import web.dom.HTMLDivElement +import dev.kilua.dom.api.HTMLDivElement internal data class AccordionItem( val label: String? = null, diff --git a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/Carousel.kt b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/Carousel.kt index 50602af6d..6176a77c9 100644 --- a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/Carousel.kt +++ b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/Carousel.kt @@ -46,7 +46,7 @@ import dev.kilua.html.span import dev.kilua.panel.Carousel.Companion.idCounter import dev.kilua.utils.cast import dev.kilua.utils.rem -import web.dom.HTMLDivElement +import dev.kilua.dom.api.HTMLDivElement internal data class CarouselItem( val caption: String? = null, diff --git a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/Offcanvas.kt b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/Offcanvas.kt index 1b3a8e16a..3c7b3f9dc 100644 --- a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/Offcanvas.kt +++ b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/Offcanvas.kt @@ -38,8 +38,7 @@ import dev.kilua.html.h5t import dev.kilua.utils.cast import dev.kilua.utils.rem import dev.kilua.utils.toKebabCase -import web.dom.HTMLDivElement -import web.dom.events.Event +import dev.kilua.dom.api.HTMLDivElement /** * The offcanvas placement. @@ -300,7 +299,7 @@ private fun IOffcanvas.setupOffcanvas( component.onRemove() } } - onEvent("hidden.bs.offcanvas") { + onEvent("hidden.bs.offcanvas") { component.hide() } } diff --git a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/TabPanel.kt b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/TabPanel.kt index 08aaf286d..981f406ba 100644 --- a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/TabPanel.kt +++ b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/panel/TabPanel.kt @@ -44,8 +44,8 @@ import dev.kilua.html.li import dev.kilua.html.ul import dev.kilua.utils.cast import dev.kilua.utils.rem -import web.dom.HTMLDivElement -import web.toJsString +import dev.kilua.dom.api.HTMLDivElement +import dev.kilua.dom.toJsString /** * Tab position. diff --git a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/theme/ThemeManager.kt b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/theme/ThemeManager.kt index 1caf9db86..07dda5c5e 100644 --- a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/theme/ThemeManager.kt +++ b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/theme/ThemeManager.kt @@ -25,10 +25,10 @@ package dev.kilua.theme import dev.kilua.externals.buildCustomEventInit import dev.kilua.utils.isDom import dev.kilua.utils.toKebabCase -import web.document -import web.dom.CustomEvent -import web.localStorage -import web.window +import dev.kilua.dom.document +import dev.kilua.dom.api.CustomEvent +import dev.kilua.dom.localStorage +import dev.kilua.dom.window /** * Bootstrap color themes. diff --git a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/toast/Toast.kt b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/toast/Toast.kt index 55d37b47c..fd89c7560 100644 --- a/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/toast/Toast.kt +++ b/modules/kilua-bootstrap/src/commonMain/kotlin/dev/kilua/toast/Toast.kt @@ -35,7 +35,6 @@ import dev.kilua.html.button import dev.kilua.html.div import dev.kilua.html.strongt import dev.kilua.utils.rem -import web.dom.events.Event import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds @@ -124,7 +123,7 @@ internal fun IComponent.toasts() { bsToast.dispose() } } - onEvent("hidden.bs.toast") { + onEvent("hidden.bs.toast") { val newToasts = Toast.toastsMap[position]?.filterKeys { it != toastId } if (newToasts.isNullOrEmpty()) { Toast.toastsMap.remove(position) diff --git a/modules/kilua-bootstrap/src/commonTest/kotlin/dev/kilua/modal/ModalSpec.kt b/modules/kilua-bootstrap/src/commonTest/kotlin/dev/kilua/modal/ModalSpec.kt index aea36eb66..3b1e1611e 100644 --- a/modules/kilua-bootstrap/src/commonTest/kotlin/dev/kilua/modal/ModalSpec.kt +++ b/modules/kilua-bootstrap/src/commonTest/kotlin/dev/kilua/modal/ModalSpec.kt @@ -27,7 +27,7 @@ import dev.kilua.html.button import dev.kilua.html.pt import dev.kilua.test.DomSpec import kotlinx.coroutines.delay -import web.document +import dev.kilua.dom.document import kotlin.test.Test class ModalSpec : DomSpec { diff --git a/modules/kilua-core-modules/build.gradle.kts b/modules/kilua-core-modules/build.gradle.kts index 1fa3e3701..e0147ada6 100644 --- a/modules/kilua-core-modules/build.gradle.kts +++ b/modules/kilua-core-modules/build.gradle.kts @@ -1,3 +1,7 @@ +@file:OptIn(ExperimentalWasmDsl::class) + +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl + plugins { kotlin("multiplatform") alias(libs.plugins.detekt) @@ -18,15 +22,15 @@ kotlin { compilerOptions() kotlinJsTargets() kotlinWasmTargets() + kotlinJvmTargets() + kotlinJsCommonTargets() sourceSets { - val commonMain by getting { + commonMain { dependencies { - api(project(":modules:kilua-dom")) -// implementation(npm("zzz-kilua-assets", "http://localhost:8001/zzz-kilua-assets-0.0.9-SNAPSHOT.tgz")) - implementation(npm("zzz-kilua-assets", libs.versions.npm.kilua.assets.get())) + api(project(":modules:kilua-dom-core")) } } - val commonTest by getting { + commonTest { dependencies { implementation(kotlin("test")) implementation(kotlin("test-common")) @@ -34,12 +38,23 @@ kotlin { implementation(project(":modules:kilua-testutils")) } } - val jsMain by getting { + jsCommonMain { + dependencies { + // implementation(npm("zzz-kilua-assets", "http://localhost:8001/zzz-kilua-assets-0.0.9-SNAPSHOT.tgz")) + implementation(npm("zzz-kilua-assets", libs.versions.npm.kilua.assets.get())) + } + } + jsMain { + dependencies { + } + } + wasmJsMain { dependencies { } } - val wasmJsMain by getting { + jvmMain { dependencies { + implementation(libs.kotlinx.coroutines) } } } diff --git a/modules/kilua-core-modules/src/commonMain/kotlin/dev/kilua/AppContext.kt b/modules/kilua-core-modules/src/commonMain/kotlin/dev/kilua/AppContext.kt new file mode 100644 index 000000000..664bd9bd3 --- /dev/null +++ b/modules/kilua-core-modules/src/commonMain/kotlin/dev/kilua/AppContext.kt @@ -0,0 +1,14 @@ +package dev.kilua + +import kotlin.coroutines.CoroutineContext + +public class AppContext : CoroutineContext.Element { + override val key: CoroutineContext.Key<*> = Key + private val cssFiles = mutableListOf() + + public fun registerCssFile(cssFile: String) { + cssFiles.add(cssFile) + } + + public companion object Key : CoroutineContext.Key +} diff --git a/modules/kilua-core-modules/src/commonMain/kotlin/dev/kilua/CoreModule.kt b/modules/kilua-core-modules/src/commonMain/kotlin/dev/kilua/CoreModule.kt index 9e092cb9e..6157ad33b 100644 --- a/modules/kilua-core-modules/src/commonMain/kotlin/dev/kilua/CoreModule.kt +++ b/modules/kilua-core-modules/src/commonMain/kotlin/dev/kilua/CoreModule.kt @@ -23,18 +23,9 @@ package dev.kilua -import web.JsAny - -@JsModule("zzz-kilua-assets/k-style.css") -internal external object CoreCss : JsAny - /** * Initializer for Kilua core module. */ -public object CoreModule : ModuleInitializer { - - override fun initialize() { - useModule(CoreCss) - CssRegister.register("zzz-kilua-assets/k-style.css") - } +public expect object CoreModule : ModuleInitializer { + override fun initialize() } diff --git a/modules/kilua-core-modules/src/commonMain/kotlin/dev/kilua/CssRegister.kt b/modules/kilua-core-modules/src/commonMain/kotlin/dev/kilua/CssRegister.kt index b238a6052..689085d4a 100644 --- a/modules/kilua-core-modules/src/commonMain/kotlin/dev/kilua/CssRegister.kt +++ b/modules/kilua-core-modules/src/commonMain/kotlin/dev/kilua/CssRegister.kt @@ -22,17 +22,4 @@ package dev.kilua -/** - * Kilua CSS register. - */ -public object CssRegister { - - public val cssFiles: MutableList = mutableListOf() - - /** - * Register CSS file used by the Kilua Modules. - */ - public fun register(cssFile: String) { - cssFiles.add(cssFile) - } -} +public expect fun registerCssModule(cssFile: String) diff --git a/modules/kilua-core-modules/src/jsCommonMain/kotlin/dev/kilua/CoreModule.jsCommon.kt b/modules/kilua-core-modules/src/jsCommonMain/kotlin/dev/kilua/CoreModule.jsCommon.kt new file mode 100644 index 000000000..225da6623 --- /dev/null +++ b/modules/kilua-core-modules/src/jsCommonMain/kotlin/dev/kilua/CoreModule.jsCommon.kt @@ -0,0 +1,16 @@ +package dev.kilua + +import dev.kilua.dom.core.JsAny + +@JsModule("zzz-kilua-assets/k-style.css") +internal external object CoreCss : JsAny + +/** + * Initializer for Kilua core module. + */ +public actual object CoreModule : ModuleInitializer { + actual override fun initialize() { + useModule(CoreCss) + CssRegister.register("zzz-kilua-assets/k-style.css") + } +} diff --git a/modules/kilua-core-modules/src/jsCommonMain/kotlin/dev/kilua/CssRegister.jsCommon.kt b/modules/kilua-core-modules/src/jsCommonMain/kotlin/dev/kilua/CssRegister.jsCommon.kt new file mode 100644 index 000000000..4041934e4 --- /dev/null +++ b/modules/kilua-core-modules/src/jsCommonMain/kotlin/dev/kilua/CssRegister.jsCommon.kt @@ -0,0 +1,18 @@ +package dev.kilua + +public actual fun registerCssModule(cssFile: String): Unit = CssRegister.register(cssFile) + +/** + * Kilua CSS register. + */ +public object CssRegister { + + public val cssFiles: MutableList = mutableListOf() + + /** + * Register CSS file used by the Kilua Modules. + */ + public fun register(cssFile: String) { + cssFiles.add(cssFile) + } +} diff --git a/modules/kilua-core-modules/src/jvmMain/kotlin/dev/kilua/CoreModule.jvm.kt b/modules/kilua-core-modules/src/jvmMain/kotlin/dev/kilua/CoreModule.jvm.kt new file mode 100644 index 000000000..26a690919 --- /dev/null +++ b/modules/kilua-core-modules/src/jvmMain/kotlin/dev/kilua/CoreModule.jvm.kt @@ -0,0 +1,8 @@ +package dev.kilua + +/** + * Initializer for Kilua core module. + */ +public actual object CoreModule : ModuleInitializer { + actual override fun initialize() {} +} diff --git a/modules/kilua-core-modules/src/jvmMain/kotlin/dev/kilua/CssRegister.jvm.kt b/modules/kilua-core-modules/src/jvmMain/kotlin/dev/kilua/CssRegister.jvm.kt new file mode 100644 index 000000000..ea2f19e74 --- /dev/null +++ b/modules/kilua-core-modules/src/jvmMain/kotlin/dev/kilua/CssRegister.jvm.kt @@ -0,0 +1,26 @@ +package dev.kilua + +import kotlinx.coroutines.currentCoroutineContext +import kotlinx.coroutines.runBlocking + +public actual fun registerCssModule(cssFile: String) { + val coroutineContext = runBlocking { currentCoroutineContext() } + val appContext = coroutineContext[AppContext] + ?: throw IllegalStateException("Not the app context") + appContext.registerCssFile(cssFile) +} + +/** + * Kilua CSS register. + */ +public class CssRegister { + + public val cssFiles: MutableList = mutableListOf() + + /** + * Register CSS file used by the Kilua Modules. + */ + public fun register(cssFile: String) { + cssFiles.add(cssFile) + } +} diff --git a/modules/kilua-dom-core/build.gradle.kts b/modules/kilua-dom-core/build.gradle.kts new file mode 100644 index 000000000..fe8672e36 --- /dev/null +++ b/modules/kilua-dom-core/build.gradle.kts @@ -0,0 +1,57 @@ +@file:OptIn(ExperimentalWasmDsl::class) + +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl + +plugins { + kotlin("multiplatform") + alias(libs.plugins.detekt) + alias(libs.plugins.dokka) + alias(libs.plugins.nmcp) + id("maven-publish") + id("signing") +} + +detekt { + toolVersion = libs.versions.detekt.get() + config.setFrom("../../detekt-config.yml") + buildUponDefaultConfig = true +} + +kotlin { + explicitApi() + compilerOptions() + kotlinJsTargets() + kotlinWasmTargets() + kotlinJvmTargets() + kotlinJsCommonTargets() + sourceSets { + commonMain { + dependencies { + } + } + jsMain { + dependencies { + } + } + wasmJsMain { + dependencies { + } + } + jvmMain { + dependencies { + } + } + } +} + +tasks.register("javadocJar") { + dependsOn(tasks.dokkaHtml) + from(tasks.dokkaHtml.flatMap { it.outputDirectory }) + archiveClassifier.set("javadoc") +} + +setupPublishing() + +nmcp { + publishAllPublications {} +} diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/JsAny.kt b/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsAny.kt similarity index 68% rename from modules/kilua-dom/src/commonMain/kotlin/web/JsAny.kt rename to modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsAny.kt index 8d325e480..1b8e23dbb 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/JsAny.kt +++ b/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsAny.kt @@ -2,8 +2,6 @@ * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ +package dev.kilua.dom.core -package web - -@Suppress("EXPECTED_EXTERNAL_DECLARATION") -public expect external interface JsAny +public expect interface JsAny diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/JsArray.kt b/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsArray.kt similarity index 77% rename from modules/kilua-dom/src/commonMain/kotlin/web/JsArray.kt rename to modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsArray.kt index d058b9672..44bd8fbc6 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/JsArray.kt +++ b/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsArray.kt @@ -3,10 +3,9 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package web +package dev.kilua.dom.core -@Suppress("EXPECTED_EXTERNAL_DECLARATION") -public expect external class JsArray() : JsAny { +public expect class JsArray() : JsAny { public val length: Int } diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/JsBoolean.kt b/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsBoolean.kt similarity index 74% rename from modules/kilua-dom/src/commonMain/kotlin/web/JsBoolean.kt rename to modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsBoolean.kt index b836bed49..baadffd56 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/JsBoolean.kt +++ b/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsBoolean.kt @@ -1,12 +1,9 @@ -/* +package dev.kilua.dom.core/* * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package web - -@Suppress("EXPECTED_EXTERNAL_DECLARATION") -public expect external class JsBoolean : JsAny +public expect class JsBoolean : JsAny public expect fun JsBoolean.toBoolean(): Boolean diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/JsNumber.kt b/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsNumber.kt similarity index 78% rename from modules/kilua-dom/src/commonMain/kotlin/web/JsNumber.kt rename to modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsNumber.kt index d068372a0..c8481d98c 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/JsNumber.kt +++ b/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsNumber.kt @@ -1,12 +1,9 @@ -/* +package dev.kilua.dom.core/* * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package web - -@Suppress("EXPECTED_EXTERNAL_DECLARATION") -public expect external class JsNumber: JsAny +public expect class JsNumber: JsAny public expect fun JsNumber.toDouble(): Double diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/JsString.kt b/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsString.kt similarity index 72% rename from modules/kilua-dom/src/commonMain/kotlin/web/JsString.kt rename to modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsString.kt index d93946d5a..8743a67be 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/JsString.kt +++ b/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/JsString.kt @@ -3,9 +3,8 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package web +package dev.kilua.dom.core -@Suppress("EXPECTED_EXTERNAL_DECLARATION") -public expect external class JsString : JsAny +public expect class JsString : JsAny public expect fun String.toJsString(): JsString diff --git a/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/Promise.kt b/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/Promise.kt new file mode 100644 index 000000000..33d4e816b --- /dev/null +++ b/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/Promise.kt @@ -0,0 +1,20 @@ +package dev.kilua.dom.core + +public expect class Promise(executor: (resolve: (T) -> Unit, reject: (JsAny?) -> Unit) -> Unit) : + JsAny { + public fun then(onFulfilled: ((T) -> S)?): Promise + + public fun then(onFulfilled: (T) -> S, onRejected: ((JsAny?) -> S)?): Promise + + public fun catch(onRejected: ((JsAny?) -> T)?): Promise + public fun finally(onFinally: () -> Unit): Promise + + public companion object { + public fun all(promises: JsArray>): Promise> + public fun race(promises: JsArray>): Promise + public fun reject(e: JsAny?): Promise + public fun resolve(r: S): Promise + public fun resolve(p: Promise): Promise + } + +} diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/RegExp.kt b/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/RegExp.kt similarity index 89% rename from modules/kilua-dom/src/commonMain/kotlin/web/RegExp.kt rename to modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/RegExp.kt index 734899045..3dfbefaae 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/RegExp.kt +++ b/modules/kilua-dom-core/src/commonMain/kotlin/dev/kilua/dom/core/RegExp.kt @@ -20,12 +20,11 @@ * SOFTWARE. */ -package web +package dev.kilua.dom.core /** * JavaScript RegExp class. */ -@Suppress("EXPECTED_EXTERNAL_DECLARATION") -public expect external class RegExp(pattern: String, flags: String?) : JsAny { +public expect class RegExp(pattern: String, flags: String?) : JsAny { public constructor(pattern: String) } diff --git a/modules/kilua-dom-core/src/jsCommonMain/kotlin/dev/kilua/dom/core/JsAny.kt b/modules/kilua-dom-core/src/jsCommonMain/kotlin/dev/kilua/dom/core/JsAny.kt new file mode 100644 index 000000000..1bd2223fd --- /dev/null +++ b/modules/kilua-dom-core/src/jsCommonMain/kotlin/dev/kilua/dom/core/JsAny.kt @@ -0,0 +1,3 @@ +package dev.kilua.dom.core + +public actual external interface JsAny diff --git a/modules/kilua-dom/src/jsMain/kotlin/web/JsArray.js.kt b/modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/JsArray.js.kt similarity index 93% rename from modules/kilua-dom/src/jsMain/kotlin/web/JsArray.js.kt rename to modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/JsArray.js.kt index 961041556..25fa38bc3 100644 --- a/modules/kilua-dom/src/jsMain/kotlin/web/JsArray.js.kt +++ b/modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/JsArray.js.kt @@ -20,10 +20,10 @@ * SOFTWARE. */ -package web +package dev.kilua.dom.core @JsName("Array") -public actual external class JsArray actual constructor() : JsAny { +public actual external class JsArray public actual constructor() : JsAny { public actual val length: Int } diff --git a/modules/kilua-dom/src/jsMain/kotlin/web/JsBoolean.js.kt b/modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/JsBoolean.js.kt similarity index 98% rename from modules/kilua-dom/src/jsMain/kotlin/web/JsBoolean.js.kt rename to modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/JsBoolean.js.kt index b4ac04b21..35005d006 100644 --- a/modules/kilua-dom/src/jsMain/kotlin/web/JsBoolean.js.kt +++ b/modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/JsBoolean.js.kt @@ -20,7 +20,7 @@ * SOFTWARE. */ -package web +package dev.kilua.dom.core @JsName("boolean") public actual external class JsBoolean : JsAny diff --git a/modules/kilua-dom/src/jsMain/kotlin/web/JsNumber.js.kt b/modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/JsNumber.js.kt similarity index 98% rename from modules/kilua-dom/src/jsMain/kotlin/web/JsNumber.js.kt rename to modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/JsNumber.js.kt index abf58e3dd..fce67403c 100644 --- a/modules/kilua-dom/src/jsMain/kotlin/web/JsNumber.js.kt +++ b/modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/JsNumber.js.kt @@ -20,7 +20,7 @@ * SOFTWARE. */ -package web +package dev.kilua.dom.core @JsName("Number") public actual external class JsNumber : JsAny diff --git a/modules/kilua-dom/src/jsMain/kotlin/web/JsString.js.kt b/modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/JsString.js.kt similarity index 97% rename from modules/kilua-dom/src/jsMain/kotlin/web/JsString.js.kt rename to modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/JsString.js.kt index 631eb7444..5c729aeeb 100644 --- a/modules/kilua-dom/src/jsMain/kotlin/web/JsString.js.kt +++ b/modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/JsString.js.kt @@ -20,7 +20,7 @@ * SOFTWARE. */ -package web +package dev.kilua.dom.core @JsName("String") public actual external class JsString : JsAny diff --git a/modules/kilua-dom/src/jsMain/kotlin/web/Promise.js.kt b/modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/Promise.js.kt similarity index 64% rename from modules/kilua-dom/src/jsMain/kotlin/web/Promise.js.kt rename to modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/Promise.js.kt index bc3a748ec..11366f5f2 100644 --- a/modules/kilua-dom/src/jsMain/kotlin/web/Promise.js.kt +++ b/modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/Promise.js.kt @@ -20,27 +20,28 @@ * SOFTWARE. */ -package web +package dev.kilua.dom.core -public actual external class Promise actual constructor(executor: (resolve: (T) -> Unit, reject: (JsAny) -> Unit) -> Unit) : +public actual external class Promise +public actual constructor(executor: (resolve: (T) -> Unit, reject: (JsAny?) -> Unit) -> Unit) : JsAny { public actual fun then(onFulfilled: ((T) -> S)?): Promise - public actual fun then(onFulfilled: ((T) -> S)?, onRejected: ((JsAny) -> S)?): Promise + public actual fun then(onFulfilled: ((T) -> S), onRejected: ((JsAny?) -> S)?): Promise - public actual fun catch(onRejected: (JsAny) -> S): Promise + public actual fun catch(onRejected: ((JsAny?) -> T)?): Promise public actual fun finally(onFinally: () -> Unit): Promise public actual companion object { - public actual fun all(promise: JsArray>): Promise> + public actual fun all(promises: JsArray>): Promise> - public actual fun race(promise: JsArray>): Promise + public actual fun race(promises: JsArray>): Promise - public actual fun reject(e: JsAny): Promise + public actual fun reject(e: JsAny?): Promise - public actual fun resolve(e: S): Promise + public actual fun resolve(r: S): Promise - public actual fun resolve(e: Promise): Promise + public actual fun resolve(p: Promise): Promise } } diff --git a/modules/kilua-dom/src/jsMain/kotlin/web/RegExp.js.kt b/modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/RegExp.js.kt similarity index 97% rename from modules/kilua-dom/src/jsMain/kotlin/web/RegExp.js.kt rename to modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/RegExp.js.kt index fb2be8dc9..ceedf6922 100644 --- a/modules/kilua-dom/src/jsMain/kotlin/web/RegExp.js.kt +++ b/modules/kilua-dom-core/src/jsMain/kotlin/dev/kilua/dom/core/RegExp.js.kt @@ -20,7 +20,7 @@ * SOFTWARE. */ -package web +package dev.kilua.dom.core public actual external class RegExp actual constructor(pattern: String, flags: String?) : JsAny { public actual constructor(pattern: String) diff --git a/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsAny.jvm.kt b/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsAny.jvm.kt new file mode 100644 index 000000000..ad5adee5e --- /dev/null +++ b/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsAny.jvm.kt @@ -0,0 +1,3 @@ +package dev.kilua.dom.core + +public actual interface JsAny diff --git a/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsArray.jvm.kt b/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsArray.jvm.kt new file mode 100644 index 000000000..01e3935bd --- /dev/null +++ b/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsArray.jvm.kt @@ -0,0 +1,17 @@ +package dev.kilua.dom.core + +public actual class JsArray(internal val list: MutableList) : JsAny { + public actual constructor() : this(mutableListOf()) + + public actual val length: Int + get() = list.size + + public fun toMutableList(): MutableList = list +} + +public fun List.toJsArray(): JsArray = JsArray(toMutableList()) + +public actual operator fun JsArray.get(index: Int): T? = list.getOrNull(index) +public actual operator fun JsArray.set(index: Int, value: T) { + list[index] = value +} diff --git a/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsBoolean.jvm.kt b/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsBoolean.jvm.kt new file mode 100644 index 000000000..83f3e625d --- /dev/null +++ b/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsBoolean.jvm.kt @@ -0,0 +1,7 @@ +package dev.kilua.dom.core + +public actual class JsBoolean internal constructor(internal val value: Boolean) : JsAny + +public actual fun JsBoolean.toBoolean(): Boolean = value + +public actual fun Boolean.toJsBoolean(): JsBoolean = JsBoolean(this) diff --git a/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsNumber.jvm.kt b/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsNumber.jvm.kt new file mode 100644 index 000000000..ccf4efb59 --- /dev/null +++ b/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsNumber.jvm.kt @@ -0,0 +1,11 @@ +package dev.kilua.dom.core + +public actual class JsNumber internal constructor(internal val value: Double) : JsAny + +public actual fun JsNumber.toDouble(): Double = value + +public actual fun Double.toJsNumber(): JsNumber = JsNumber(this) + +public actual fun JsNumber.toInt(): Int = value.toInt() + +public actual fun Int.toJsNumber(): JsNumber = JsNumber(toDouble()) diff --git a/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsString.jvm.kt b/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsString.jvm.kt new file mode 100644 index 000000000..27ff3cd8e --- /dev/null +++ b/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/JsString.jvm.kt @@ -0,0 +1,5 @@ +package dev.kilua.dom.core + +public actual class JsString internal constructor(internal val value: String): JsAny + +public actual fun String.toJsString(): JsString = JsString(this) diff --git a/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/Promise.jvm.kt b/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/Promise.jvm.kt new file mode 100644 index 000000000..352b8f779 --- /dev/null +++ b/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/Promise.jvm.kt @@ -0,0 +1,130 @@ +package dev.kilua.dom.core + +import java.util.concurrent.CompletableFuture + +// TODO: Error handling is't there yet in then and catch +public actual class Promise +internal constructor(internal val completableFuture: CompletableFuture>) : + JsAny { + public actual constructor(executor: (resolve: (T) -> Unit, reject: (JsAny?) -> Unit) -> Unit) : this( + CompletableFuture>() + ) { + executor( + { completableFuture.complete(PromiseResult.Success(it)) }, + { completableFuture.complete(PromiseResult.Failure(it)) } + ) + } + + public actual fun then(onFulfilled: ((T) -> S)?): Promise { + if (onFulfilled != null) { + val newFuture = completableFuture.thenApply { + when (it) { + is PromiseResult.Success -> { + PromiseResult.Success(onFulfilled(it.value)) + } + + is PromiseResult.Failure -> { + PromiseResult.Failure(it.error) + } + } + } + return Promise(newFuture) + } + + TODO("Nullable option not yet implemented") + } + + public actual fun then( + onFulfilled: (T) -> S, + onRejected: ((JsAny?) -> S)?, + ): Promise { + if (onRejected != null) { + val newFuture = completableFuture.thenApply> { + when (it) { + is PromiseResult.Success -> { + PromiseResult.Success(onFulfilled(it.value)) + } + + is PromiseResult.Failure -> { + PromiseResult.Success(onRejected(it.error)) + } + } + } + return Promise(newFuture) + } + + return then(onFulfilled) + } + + public actual fun catch(onRejected: ((JsAny?) -> T)?): Promise { + if (onRejected != null) { + val newFuture = completableFuture.thenApply { + when (it) { + is PromiseResult.Success -> { + PromiseResult.Success(it.value) + } + + is PromiseResult.Failure -> { + PromiseResult.Failure(onRejected(it.error)) + } + } + } + return Promise(newFuture) + } + + return this + } + + public actual fun finally(onFinally: () -> Unit): Promise { + completableFuture.handle { _, _ -> onFinally() } + return this + } + + public actual companion object { + public actual fun all(promises: JsArray>): Promise> { + @Suppress("performance:SpreadOperator") + val all = CompletableFuture.allOf(*promises.list.map { it.completableFuture }.toTypedArray()).thenApply { + val list: List> = promises.list.map { it.completableFuture.resultNow() } + // TODO: Correct? + if (list.any { it is PromiseResult.Failure }) { + val errors: JsArray = + list.map { if (it is PromiseResult.Failure) it.error else null }.toJsArray() + PromiseResult.Failure(errors) + } else { + val results: JsArray = list.map { (it as PromiseResult.Success).value }.toJsArray() + PromiseResult.Success(results) + } + } + return Promise(all) + } + + public actual fun race(promises: JsArray>): Promise { + @Suppress("performance:SpreadOperator") + val first = CompletableFuture.anyOf(*promises.list.map { it.completableFuture }.toTypedArray()).thenApply { + promises.list.first { it.completableFuture.isDone }.completableFuture.resultNow() + } + return Promise(first) + } + + public actual fun reject(e: JsAny?): Promise { + val future: CompletableFuture> = + CompletableFuture.completedFuture(PromiseResult.Failure(e)) + return Promise(future) + } + + public actual fun resolve(r: S): Promise { + val future: CompletableFuture> = + CompletableFuture.completedFuture(PromiseResult.Success(r)) + return Promise(future) + } + + public actual fun resolve(p: Promise): Promise { + return p + } + } +} + +internal sealed interface PromiseResult { + class Success(val value: T) : PromiseResult + class Failure(val error: JsAny?) : PromiseResult +} diff --git a/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/RegExp.jvm.kt b/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/RegExp.jvm.kt new file mode 100644 index 000000000..6c8337cbc --- /dev/null +++ b/modules/kilua-dom-core/src/jvmMain/kotlin/dev/kilua/dom/core/RegExp.jvm.kt @@ -0,0 +1,8 @@ +package dev.kilua.dom.core + +/** + * JavaScript RegExp class. + */ +public actual class RegExp actual constructor(pattern: String, flags: String?) : JsAny { + public actual constructor(pattern: String) : this(pattern, null) +} diff --git a/modules/kilua-dom/src/wasmJsMain/kotlin/web/JsArray.wasmJs.kt b/modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/JsArray.wasmJs.kt similarity index 98% rename from modules/kilua-dom/src/wasmJsMain/kotlin/web/JsArray.wasmJs.kt rename to modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/JsArray.wasmJs.kt index 4dd12ad4e..7bbf9b55d 100644 --- a/modules/kilua-dom/src/wasmJsMain/kotlin/web/JsArray.wasmJs.kt +++ b/modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/JsArray.wasmJs.kt @@ -20,7 +20,7 @@ * SOFTWARE. */ -package web +package dev.kilua.dom.core import kotlin.js.get as jsGet import kotlin.js.set as jsSet diff --git a/modules/kilua-dom/src/wasmJsMain/kotlin/web/JsBoolean.wasmJs.kt b/modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/JsBoolean.wasmJs.kt similarity index 98% rename from modules/kilua-dom/src/wasmJsMain/kotlin/web/JsBoolean.wasmJs.kt rename to modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/JsBoolean.wasmJs.kt index a8b1c2754..d809831a9 100644 --- a/modules/kilua-dom/src/wasmJsMain/kotlin/web/JsBoolean.wasmJs.kt +++ b/modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/JsBoolean.wasmJs.kt @@ -20,7 +20,7 @@ * SOFTWARE. */ -package web +package dev.kilua.dom.core import kotlin.js.toBoolean as jsToBoolean import kotlin.js.toJsBoolean as jsToJsBoolean diff --git a/modules/kilua-dom/src/wasmJsMain/kotlin/web/JsNumber.wasmJs.kt b/modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/JsNumber.wasmJs.kt similarity index 58% rename from modules/kilua-dom/src/wasmJsMain/kotlin/web/JsNumber.wasmJs.kt rename to modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/JsNumber.wasmJs.kt index dc071197e..697973fa4 100644 --- a/modules/kilua-dom/src/wasmJsMain/kotlin/web/JsNumber.wasmJs.kt +++ b/modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/JsNumber.wasmJs.kt @@ -20,15 +20,24 @@ * SOFTWARE. */ -package web +package dev.kilua.dom.core -import kotlin.js.toDouble as jsToDouble -import kotlin.js.toInt as jsToInt -import kotlin.js.toJsNumber as jsToJsNumber +import kotlin.js.JsAny -public actual typealias JsNumber = kotlin.js.JsNumber +public external class JsNumber internal constructor() : JsAny -public actual fun JsNumber.toDouble(): Double = this.jsToDouble() -public actual fun Double.toJsNumber(): JsNumber = this.jsToJsNumber() -public actual fun JsNumber.toInt(): Int = this.jsToInt() -public actual fun Int.toJsNumber(): JsNumber = this.jsToJsNumber() +public actual fun JsNumber.toDouble(): Double = jsNumberToDouble(this) +@Suppress("UNUSED_PARAMETER") +private fun jsNumberToDouble(number: JsNumber): Double = js("Number(number)") + +public actual fun Double.toJsNumber(): JsNumber = doubleToJsNumber(this) +@Suppress("UNUSED_PARAMETER") +private fun doubleToJsNumber(double: Double): JsNumber = js("Number(double)") + +public actual fun JsNumber.toInt(): Int = jsNumberToInt(this) +@Suppress("UNUSED_PARAMETER") +private fun jsNumberToInt(number: JsNumber): Int = js("Number(number)") + +public actual fun Int.toJsNumber(): JsNumber = intToJsNumber(this) +@Suppress("UNUSED_PARAMETER") +private fun intToJsNumber(int: Int): JsNumber = js("int") diff --git a/modules/kilua-dom/src/wasmJsMain/kotlin/web/JsString.wasmJs.kt b/modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/JsString.wasmJs.kt similarity index 97% rename from modules/kilua-dom/src/wasmJsMain/kotlin/web/JsString.wasmJs.kt rename to modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/JsString.wasmJs.kt index 2df86eef1..e8ce53e5b 100644 --- a/modules/kilua-dom/src/wasmJsMain/kotlin/web/JsString.wasmJs.kt +++ b/modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/JsString.wasmJs.kt @@ -20,7 +20,7 @@ * SOFTWARE. */ -package web +package dev.kilua.dom.core import kotlin.js.toJsString as jsToJsString diff --git a/modules/kilua-dom/src/wasmJsMain/kotlin/web/Promise.wasmJs.kt b/modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/Promise.wasmJs.kt similarity index 64% rename from modules/kilua-dom/src/wasmJsMain/kotlin/web/Promise.wasmJs.kt rename to modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/Promise.wasmJs.kt index d6796d0a4..48351c5cf 100644 --- a/modules/kilua-dom/src/wasmJsMain/kotlin/web/Promise.wasmJs.kt +++ b/modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/Promise.wasmJs.kt @@ -20,27 +20,26 @@ * SOFTWARE. */ -package web +package dev.kilua.dom.core -public actual external class Promise actual constructor(executor: (resolve: (T) -> Unit, reject: (JsAny) -> Unit) -> Unit) : - kotlin.js.JsAny { +public actual external class Promise public actual constructor(executor: (resolve: (T) -> Unit, reject: (JsAny?) -> Unit) -> Unit) : JsAny { public actual fun then(onFulfilled: ((T) -> S)?): Promise - public actual fun then(onFulfilled: ((T) -> S)?, onRejected: ((JsAny) -> S)?): Promise + public actual fun then(onFulfilled: (T) -> S, onRejected: ((JsAny?) -> S)?): Promise - public actual fun catch(onRejected: (JsAny) -> S): Promise + public actual fun catch(onRejected: ((JsAny?) -> T)?): Promise public actual fun finally(onFinally: () -> Unit): Promise public actual companion object { - public actual fun all(promise: JsArray>): Promise> + public actual fun all(promises: JsArray>): Promise> - public actual fun race(promise: JsArray>): Promise + public actual fun race(promises: JsArray>): Promise - public actual fun reject(e: JsAny): Promise + public actual fun reject(e: JsAny?): Promise - public actual fun resolve(e: S): Promise + public actual fun resolve(r: S): Promise - public actual fun resolve(e: Promise): Promise + public actual fun resolve(p: Promise): Promise } } diff --git a/modules/kilua-dom/src/wasmJsMain/kotlin/web/RegExp.wasmJs.kt b/modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/RegExp.wasmJs.kt similarity index 94% rename from modules/kilua-dom/src/wasmJsMain/kotlin/web/RegExp.wasmJs.kt rename to modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/RegExp.wasmJs.kt index d8ce61eca..3745f3151 100644 --- a/modules/kilua-dom/src/wasmJsMain/kotlin/web/RegExp.wasmJs.kt +++ b/modules/kilua-dom-core/src/wasmJsMain/kotlin/dev/kilua/dom/core/RegExp.wasmJs.kt @@ -1,4 +1,3 @@ -@file:Suppress("EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE") /* * Copyright (c) 2024 Robert Jaros * @@ -21,8 +20,9 @@ * SOFTWARE. */ -package web +package dev.kilua.dom.core +@Suppress("style:UnusedPrivateProperty") public actual external class RegExp actual constructor(pattern: String, flags: String?) : JsAny { public actual constructor(pattern: String) } diff --git a/modules/kilua-dom/build.gradle.kts b/modules/kilua-dom/build.gradle.kts index 39945301e..6f1e0887c 100644 --- a/modules/kilua-dom/build.gradle.kts +++ b/modules/kilua-dom/build.gradle.kts @@ -18,16 +18,18 @@ kotlin { compilerOptions() kotlinJsTargets() kotlinWasmTargets() + kotlinJsCommonTargets() sourceSets { - val commonMain by getting { + commonMain { dependencies { + api(project(":modules:kilua-dom-core")) } } - val jsMain by getting { + jsMain { dependencies { } } - val wasmJsMain by getting { + wasmJsMain { dependencies { } } diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/Promise.kt b/modules/kilua-dom/src/commonMain/kotlin/web/Promise.kt deleted file mode 100644 index 2d6c2a03d..000000000 --- a/modules/kilua-dom/src/commonMain/kotlin/web/Promise.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package web - -@Suppress("EXPECTED_EXTERNAL_DECLARATION") -public expect external class Promise(executor: (resolve: (T) -> Unit, reject: (JsAny) -> Unit) -> Unit) : - JsAny { - public fun then(onFulfilled: ((T) -> S)?): Promise - - public fun then(onFulfilled: ((T) -> S)?, onRejected: ((JsAny) -> S)?): Promise - - public fun catch(onRejected: (JsAny) -> S): Promise - public fun finally(onFinally: () -> Unit): Promise - - public companion object { - public fun all(promise: JsArray>): Promise> - public fun race(promise: JsArray>): Promise - public fun reject(e: JsAny): Promise - public fun resolve(e: S): Promise - public fun resolve(e: Promise): Promise - } - -} diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/Mutations.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/Mutations.kt similarity index 87% rename from modules/kilua-dom/src/commonMain/kotlin/web/Mutations.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/Mutations.kt index c7fe6c6aa..fa5876a5e 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/Mutations.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/Mutations.kt @@ -3,10 +3,10 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package web +package dev.kilua.dom -import web.dom.Element -import web.dom.Node +import dev.kilua.dom.api.Element +import dev.kilua.dom.api.Node /** Removes all the children from this node. */ diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/Dom.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/Dom.kt similarity index 99% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/Dom.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/Dom.kt index 8a9ebeb7b..73b524310 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/Dom.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/Dom.kt @@ -11,27 +11,36 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.dom - -import web.JsAny -import web.JsArray -import web.JsNumber -import web.JsString -import web.webgl.* -import web.dom.clipboard.* -import web.dom.css.* -import web.dom.encryptedmedia.* -import web.dom.events.* -import web.dom.mediacapture.* -import web.dom.mediasource.* -import web.dom.pointerevents.* -import web.dom.svg.* -import web.fetch.* -import web.files.* -import web.performance.* -import web.workers.* -import web.xhr.* -import web.Promise +package dev.kilua.dom.api + +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray +import dev.kilua.dom.JsNumber +import dev.kilua.dom.JsString +import dev.kilua.dom.core.Promise +import dev.kilua.dom.api.clipboard.Clipboard +import dev.kilua.dom.api.clipboard.ClipboardEvent +import dev.kilua.dom.api.css.* +import dev.kilua.dom.api.encryptedmedia.MediaKeySystemConfiguration +import dev.kilua.dom.api.encryptedmedia.MediaKeys +import dev.kilua.dom.api.events.* +import dev.kilua.dom.api.mediacapture.MediaDevices +import dev.kilua.dom.api.mediacapture.MediaStream +import dev.kilua.dom.api.mediacapture.MediaStreamConstraints +import dev.kilua.dom.api.mediasource.SourceBuffer +import dev.kilua.dom.api.pointerevents.PointerEvent +import dev.kilua.dom.api.svg.SVGSVGElement +import dev.kilua.dom.fetch.* +import dev.kilua.dom.files.Blob +import dev.kilua.dom.files.File +import dev.kilua.dom.files.FileList +import dev.kilua.dom.performance.GlobalPerformance +import dev.kilua.dom.webgl.* +import dev.kilua.dom.workers.CacheStorage +import dev.kilua.dom.workers.ServiceWorkerContainer +import dev.kilua.dom.workers.UnionClientOrMessagePortOrServiceWorker +import dev.kilua.dom.workers.UnionMessagePortOrServiceWorker +import dev.kilua.dom.xhr.ProgressEvent public abstract external class HTMLAllCollection : JsAny { open val length: Int diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/ItemArrayLike.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/ItemArrayLike.kt similarity index 93% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/ItemArrayLike.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/ItemArrayLike.kt index 0646b1e99..476eb255f 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/ItemArrayLike.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/ItemArrayLike.kt @@ -4,9 +4,9 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package web.dom +package dev.kilua.dom.api -import web.JsAny +import dev.kilua.dom.JsAny public external interface ItemArrayLike : JsAny { public val length: Int diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/clipboard/Clipboard.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/clipboard/Clipboard.kt similarity index 85% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/clipboard/Clipboard.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/clipboard/Clipboard.kt index e48dde676..20d3adf58 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/clipboard/Clipboard.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/clipboard/Clipboard.kt @@ -11,14 +11,14 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.dom.clipboard - -import web.JsAny -import web.dom.DataTransfer -import web.dom.EventInit -import web.dom.events.Event -import web.dom.events.EventTarget -import web.Promise +package dev.kilua.dom.api.clipboard + +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.DataTransfer +import dev.kilua.dom.api.EventInit +import dev.kilua.dom.api.events.Event +import dev.kilua.dom.api.events.EventTarget +import dev.kilua.dom.core.Promise public external interface ClipboardEventInit : EventInit, JsAny { var clipboardData: DataTransfer? /* = null */ diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/css/Css.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/css/Css.kt similarity index 98% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/css/Css.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/css/Css.kt index f9e1e827d..ee3aab42c 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/css/Css.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/css/Css.kt @@ -11,11 +11,11 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.dom.css +package dev.kilua.dom.api.css -import web.JsAny -import web.JsString -import web.dom.ItemArrayLike +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsString +import dev.kilua.dom.api.ItemArrayLike public abstract external class MediaList : ItemArrayLike, JsAny { open var mediaText: String @@ -473,4 +473,4 @@ public abstract external class CSS : JsAny { } } -public external interface UnionElementOrProcessingInstruction \ No newline at end of file +public external interface UnionElementOrProcessingInstruction diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/encryptedmedia/Encryptedmedia.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/encryptedmedia/Encryptedmedia.kt similarity index 93% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/encryptedmedia/Encryptedmedia.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/encryptedmedia/Encryptedmedia.kt index 2252e7de1..6a3177c7c 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/encryptedmedia/Encryptedmedia.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/encryptedmedia/Encryptedmedia.kt @@ -11,17 +11,17 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.dom.encryptedmedia - -import web.JsAny -import web.JsArray -import web.JsString -import web.Promise -import web.dom.EventInit -import web.dom.MessageEvent -import web.dom.events.Event -import web.dom.events.EventTarget -import web.webgl.ArrayBuffer +package dev.kilua.dom.api.encryptedmedia + +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray +import dev.kilua.dom.JsString +import dev.kilua.dom.core.Promise +import dev.kilua.dom.api.EventInit +import dev.kilua.dom.api.MessageEvent +import dev.kilua.dom.api.events.Event +import dev.kilua.dom.api.events.EventTarget +import dev.kilua.dom.webgl.ArrayBuffer /** * Exposes the JavaScript [MediaKeySystemConfiguration](https://developer.mozilla.org/en/docs/Web/API/MediaKeySystemConfiguration) to Kotlin diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/events/Events.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/events/Events.kt similarity index 98% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/events/Events.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/events/Events.kt index 2a5455996..15c7af6b5 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/events/Events.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/events/Events.kt @@ -11,12 +11,12 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.dom.events +package dev.kilua.dom.api.events -import web.JsAny -import web.JsArray -import web.JsNumber -import web.dom.* +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray +import dev.kilua.dom.JsNumber +import dev.kilua.dom.api.* /** * Exposes the JavaScript [UIEvent](https://developer.mozilla.org/en/docs/Web/API/UIEvent) to Kotlin @@ -316,4 +316,4 @@ public abstract external class EventTarget : JsAny { */ public external interface EventListener : JsAny { fun handleEvent(event: Event) -} \ No newline at end of file +} diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/mediacapture/Mediacapture.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/mediacapture/Mediacapture.kt similarity index 96% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/mediacapture/Mediacapture.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/mediacapture/Mediacapture.kt index 0a47b8c9b..bad6dc76f 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/mediacapture/Mediacapture.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/mediacapture/Mediacapture.kt @@ -11,17 +11,17 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.dom.mediacapture - -import web.JsAny -import web.JsArray -import web.JsBoolean -import web.JsString -import web.dom.EventInit -import web.dom.MediaProvider -import web.dom.events.Event -import web.dom.events.EventTarget -import web.Promise +package dev.kilua.dom.api.mediacapture + +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray +import dev.kilua.dom.JsBoolean +import dev.kilua.dom.JsString +import dev.kilua.dom.api.EventInit +import dev.kilua.dom.api.MediaProvider +import dev.kilua.dom.api.events.Event +import dev.kilua.dom.api.events.EventTarget +import dev.kilua.dom.core.Promise /** * Exposes the JavaScript [MediaStream](https://developer.mozilla.org/en/docs/Web/API/MediaStream) to Kotlin diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/mediasource/Mediasource.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/mediasource/Mediasource.kt similarity index 89% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/mediasource/Mediasource.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/mediasource/Mediasource.kt index 1f510e02f..993d1a49e 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/mediasource/Mediasource.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/mediasource/Mediasource.kt @@ -11,16 +11,16 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.dom.mediasource +package dev.kilua.dom.api.mediasource -import web.JsAny -import web.dom.AudioTrackList -import web.dom.MediaProvider -import web.dom.TextTrackList -import web.dom.TimeRanges -import web.dom.VideoTrackList -import web.dom.events.Event -import web.dom.events.EventTarget +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.AudioTrackList +import dev.kilua.dom.api.MediaProvider +import dev.kilua.dom.api.TextTrackList +import dev.kilua.dom.api.TimeRanges +import dev.kilua.dom.api.VideoTrackList +import dev.kilua.dom.api.events.Event +import dev.kilua.dom.api.events.EventTarget /** * Exposes the JavaScript [MediaSource](https://developer.mozilla.org/en/docs/Web/API/MediaSource) to Kotlin diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserver.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserver.kt similarity index 92% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserver.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserver.kt index 98ad3b377..96788f167 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserver.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserver.kt @@ -25,13 +25,13 @@ * SOFTWARE. */ -package web.dom.observers +package dev.kilua.dom.api.observers -import web.JsAny -import web.JsArray -import web.JsNumber -import web.dom.Element -import web.dom.ParentNode +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray +import dev.kilua.dom.JsNumber +import dev.kilua.dom.api.Element +import dev.kilua.dom.api.ParentNode external class IntersectionObserver( callback: IntersectionObserverCallback, diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserverCallback.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserverCallback.kt similarity index 95% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserverCallback.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserverCallback.kt index ae05e10c1..e23dd0f2d 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserverCallback.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserverCallback.kt @@ -25,9 +25,9 @@ * SOFTWARE. */ -package web.dom.observers +package dev.kilua.dom.api.observers -import web.JsArray +import dev.kilua.dom.JsArray typealias IntersectionObserverCallback = ( entries: JsArray, diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserverEntry.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserverEntry.kt similarity index 94% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserverEntry.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserverEntry.kt index 4e3c0fabc..abe1f9386 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserverEntry.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserverEntry.kt @@ -25,12 +25,12 @@ * SOFTWARE. */ -package web.dom.observers +package dev.kilua.dom.api.observers -import web.JsAny -import web.JsNumber -import web.dom.DOMRectReadOnly -import web.dom.Element +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsNumber +import dev.kilua.dom.api.DOMRectReadOnly +import dev.kilua.dom.api.Element /** * This Intersection Observer API interface describes the intersection between the target element and its root container at a specific moment of transition. diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserverEntryInit.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserverEntryInit.kt similarity index 90% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserverEntryInit.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserverEntryInit.kt index 37ba2fce5..1aaf8677a 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserverEntryInit.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserverEntryInit.kt @@ -25,12 +25,12 @@ * SOFTWARE. */ -package web.dom.observers +package dev.kilua.dom.api.observers -import web.JsAny -import web.JsNumber -import web.dom.DOMRectInit -import web.dom.Element +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsNumber +import dev.kilua.dom.api.DOMRectInit +import dev.kilua.dom.api.Element sealed external interface IntersectionObserverEntryInit : JsAny { var boundingClientRect: DOMRectInit diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserverInit.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserverInit.kt similarity index 90% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserverInit.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserverInit.kt index d14498a39..de888be51 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/observers/IntersectionObserverInit.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/observers/IntersectionObserverInit.kt @@ -25,12 +25,12 @@ * SOFTWARE. */ -package web.dom.observers +package dev.kilua.dom.api.observers -import web.JsAny -import web.JsArray -import web.JsNumber -import web.dom.ParentNode +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray +import dev.kilua.dom.JsNumber +import dev.kilua.dom.api.ParentNode sealed external interface IntersectionObserverInit : JsAny { var root: ParentNode /* Element | Document */? diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/parsing/Parsing.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/parsing/Parsing.kt similarity index 87% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/parsing/Parsing.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/parsing/Parsing.kt index 305aed6cc..faac968c7 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/parsing/Parsing.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/parsing/Parsing.kt @@ -11,11 +11,11 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.dom.parsing +package dev.kilua.dom.api.parsing -import web.JsAny -import web.dom.Document -import web.dom.Node +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.Document +import dev.kilua.dom.api.Node /** * Exposes the JavaScript [DOMParser](https://developer.mozilla.org/en/docs/Web/API/DOMParser) to Kotlin @@ -29,4 +29,4 @@ public open external class DOMParser : JsAny { */ public open external class XMLSerializer : JsAny { fun serializeToString(root: Node): String -} \ No newline at end of file +} diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/pointerevents/Pointerevents.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/pointerevents/Pointerevents.kt similarity index 90% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/pointerevents/Pointerevents.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/pointerevents/Pointerevents.kt index 7e55f2eab..8517c661b 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/pointerevents/Pointerevents.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/pointerevents/Pointerevents.kt @@ -11,11 +11,11 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.dom.pointerevents +package dev.kilua.dom.api.pointerevents -import web.JsAny -import web.dom.events.MouseEvent -import web.dom.events.MouseEventInit +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.events.MouseEvent +import dev.kilua.dom.api.events.MouseEventInit public external interface PointerEventInit : MouseEventInit, JsAny { var pointerId: Int? /* = 0 */ diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/svg/Svg.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/svg/Svg.kt similarity index 99% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/svg/Svg.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/svg/Svg.kt index b76657572..6475b074a 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/svg/Svg.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/svg/Svg.kt @@ -11,12 +11,12 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.dom.svg +package dev.kilua.dom.api.svg -import web.JsAny -import web.dom.* -import web.dom.css.ElementCSSInlineStyle -import web.dom.css.LinkStyle +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.* +import dev.kilua.dom.api.css.ElementCSSInlineStyle +import dev.kilua.dom.api.css.LinkStyle /** * Exposes the JavaScript [SVGElement](https://developer.mozilla.org/en/docs/Web/API/SVGElement) to Kotlin @@ -1776,4 +1776,4 @@ public abstract external class SVGViewElement : SVGElement, SVGFitToViewBox, SVG val DOCUMENT_POSITION_CONTAINED_BY: Short val DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: Short } -} \ No newline at end of file +} diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/dom/url/Url.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/url/Url.kt similarity index 89% rename from modules/kilua-dom/src/commonMain/kotlin/web/dom/url/Url.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/url/Url.kt index 4671eece0..4dd30c3b3 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/dom/url/Url.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/api/url/Url.kt @@ -11,13 +11,13 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.dom.url +package dev.kilua.dom.api.url -import web.JsAny -import web.JsArray -import web.JsString -import web.dom.mediasource.* -import web.files.* +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray +import dev.kilua.dom.JsString +import dev.kilua.dom.api.mediasource.MediaSource +import dev.kilua.dom.files.Blob /** * Exposes the JavaScript [URL](https://developer.mozilla.org/en/docs/Web/API/URL) to Kotlin @@ -56,4 +56,4 @@ public open external class URLSearchParams(init: JsAny? /* String|URLSearchParam fun getAll(name: String): JsArray fun has(name: String): Boolean fun set(name: String, value: String) -} \ No newline at end of file +} diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/css/masking/Masking.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/css/masking/Masking.kt similarity index 91% rename from modules/kilua-dom/src/commonMain/kotlin/web/css/masking/Masking.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/css/masking/Masking.kt index 4d2676fe7..c12db95a3 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/css/masking/Masking.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/css/masking/Masking.kt @@ -11,14 +11,14 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.css.masking +package dev.kilua.dom.css.masking -import web.JsAny -import web.dom.svg.SVGAnimatedEnumeration -import web.dom.svg.SVGAnimatedLength -import web.dom.svg.SVGAnimatedTransformList -import web.dom.svg.SVGElement -import web.dom.svg.SVGUnitTypes +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.svg.SVGAnimatedEnumeration +import dev.kilua.dom.api.svg.SVGAnimatedLength +import dev.kilua.dom.api.svg.SVGAnimatedTransformList +import dev.kilua.dom.api.svg.SVGElement +import dev.kilua.dom.api.svg.SVGUnitTypes /** * Exposes the JavaScript [SVGClipPathElement](https://developer.mozilla.org/en/docs/Web/API/SVGClipPathElement) to Kotlin @@ -86,4 +86,4 @@ public abstract external class SVGMaskElement : SVGElement, SVGUnitTypes, JsAny val DOCUMENT_POSITION_CONTAINED_BY: Short val DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: Short } -} \ No newline at end of file +} diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/web.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/dom.kt similarity index 75% rename from modules/kilua-dom/src/commonMain/kotlin/web/web.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/dom.kt index 76bf6ae55..1ecf5d487 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/web.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/dom.kt @@ -3,9 +3,11 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package web +package dev.kilua.dom -import web.dom.* +import dev.kilua.dom.api.Document +import dev.kilua.dom.api.Storage +import dev.kilua.dom.api.Window public external val window: Window diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/fetch/Fetch.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/fetch/Fetch.kt similarity index 98% rename from modules/kilua-dom/src/commonMain/kotlin/web/fetch/Fetch.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/fetch/Fetch.kt index 41ba304d7..cf16e9bed 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/fetch/Fetch.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/fetch/Fetch.kt @@ -11,10 +11,10 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.fetch +package dev.kilua.dom.fetch -import web.JsAny -import web.Promise +import dev.kilua.dom.JsAny +import dev.kilua.dom.core.Promise /** * Exposes the JavaScript [Headers](https://developer.mozilla.org/en/docs/Web/API/Headers) to Kotlin diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/files/Files.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/files/Files.kt similarity index 87% rename from modules/kilua-dom/src/commonMain/kotlin/web/files/Files.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/files/Files.kt index 03c2df5b1..52de028f7 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/files/Files.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/files/Files.kt @@ -11,18 +11,18 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.files +package dev.kilua.dom.files -import web.JsAny -import web.JsArray -import web.JsNumber -import web.dom.ImageBitmapSource -import web.dom.ItemArrayLike -import web.dom.MediaProvider -import web.dom.events.Event -import web.dom.events.EventTarget -import web.webgl.ArrayBuffer -import web.xhr.ProgressEvent +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray +import dev.kilua.dom.JsNumber +import dev.kilua.dom.api.ImageBitmapSource +import dev.kilua.dom.api.ItemArrayLike +import dev.kilua.dom.api.MediaProvider +import dev.kilua.dom.api.events.Event +import dev.kilua.dom.api.events.EventTarget +import dev.kilua.dom.webgl.ArrayBuffer +import dev.kilua.dom.xhr.ProgressEvent /** * Exposes the JavaScript [Blob](https://developer.mozilla.org/en/docs/Web/API/Blob) to Kotlin diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/notifications/Notifications.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/notifications/Notifications.kt similarity index 90% rename from modules/kilua-dom/src/commonMain/kotlin/web/notifications/Notifications.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/notifications/Notifications.kt index 5850c3735..97a77881c 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/notifications/Notifications.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/notifications/Notifications.kt @@ -11,17 +11,17 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.notifications - -import web.JsAny -import web.JsArray -import web.JsNumber -import web.dom.events.Event -import web.dom.events.EventTarget -import web.dom.events.MouseEvent -import web.workers.ExtendableEvent -import web.workers.ExtendableEventInit -import web.Promise +package dev.kilua.dom.notifications + +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray +import dev.kilua.dom.JsNumber +import dev.kilua.dom.api.events.Event +import dev.kilua.dom.api.events.EventTarget +import dev.kilua.dom.api.events.MouseEvent +import dev.kilua.dom.workers.ExtendableEvent +import dev.kilua.dom.workers.ExtendableEventInit +import dev.kilua.dom.core.Promise /** * Exposes the JavaScript [Notification](https://developer.mozilla.org/en/docs/Web/API/Notification) to Kotlin diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/performance/Performance.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/performance/Performance.kt similarity index 94% rename from modules/kilua-dom/src/commonMain/kotlin/web/performance/Performance.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/performance/Performance.kt index a48e07fdd..87ad92e2e 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/performance/Performance.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/performance/Performance.kt @@ -11,11 +11,11 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.performance +package dev.kilua.dom.performance -import web.JsAny -import web.JsNumber -import web.dom.events.EventTarget +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsNumber +import dev.kilua.dom.api.events.EventTarget /** * Exposes the JavaScript [Performance](https://developer.mozilla.org/en/docs/Web/API/Performance) to Kotlin @@ -70,4 +70,4 @@ public abstract external class PerformanceNavigation : JsAny { val TYPE_BACK_FORWARD: Short val TYPE_RESERVED: Short } -} \ No newline at end of file +} diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/webgl/Webgl.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/webgl/Webgl.kt similarity index 99% rename from modules/kilua-dom/src/commonMain/kotlin/web/webgl/Webgl.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/webgl/Webgl.kt index dd567069a..2a8047385 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/webgl/Webgl.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/webgl/Webgl.kt @@ -11,16 +11,16 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.webgl +package dev.kilua.dom.webgl -import web.JsAny -import web.JsArray -import web.JsNumber -import web.JsString -import web.dom.EventInit -import web.dom.HTMLCanvasElement -import web.dom.RenderingContext -import web.dom.events.Event +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray +import dev.kilua.dom.JsNumber +import dev.kilua.dom.JsString +import dev.kilua.dom.api.EventInit +import dev.kilua.dom.api.HTMLCanvasElement +import dev.kilua.dom.api.RenderingContext +import dev.kilua.dom.api.events.Event public external interface WebGLContextAttributes : JsAny { var alpha: Boolean? /* = true */ @@ -1192,4 +1192,4 @@ public open external class DataView( public external interface BufferDataSource -public external interface TexImageSource \ No newline at end of file +public external interface TexImageSource diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/workers/Workers.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/workers/Workers.kt similarity index 94% rename from modules/kilua-dom/src/commonMain/kotlin/web/workers/Workers.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/workers/Workers.kt index 6a2ebfc0a..f38e13043 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/workers/Workers.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/workers/Workers.kt @@ -11,25 +11,25 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.workers - -import web.JsAny -import web.JsArray -import web.JsString -import web.dom.AbstractWorker -import web.dom.EventInit -import web.dom.MessageEvent -import web.dom.MessagePort -import web.dom.WorkerGlobalScope -import web.dom.WorkerType -import web.dom.events.Event -import web.dom.events.EventTarget -import web.fetch.Request -import web.fetch.Response -import web.notifications.GetNotificationOptions -import web.notifications.NotificationEvent -import web.notifications.NotificationOptions -import web.Promise +package dev.kilua.dom.workers + +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray +import dev.kilua.dom.JsString +import dev.kilua.dom.api.AbstractWorker +import dev.kilua.dom.api.EventInit +import dev.kilua.dom.api.MessageEvent +import dev.kilua.dom.api.MessagePort +import dev.kilua.dom.api.WorkerGlobalScope +import dev.kilua.dom.api.WorkerType +import dev.kilua.dom.api.events.Event +import dev.kilua.dom.api.events.EventTarget +import dev.kilua.dom.fetch.Request +import dev.kilua.dom.fetch.Response +import dev.kilua.dom.notifications.GetNotificationOptions +import dev.kilua.dom.notifications.NotificationEvent +import dev.kilua.dom.notifications.NotificationOptions +import dev.kilua.dom.core.Promise /** * Exposes the JavaScript [ServiceWorker](https://developer.mozilla.org/en/docs/Web/API/ServiceWorker) to Kotlin diff --git a/modules/kilua-dom/src/commonMain/kotlin/web/xhr/Xhr.kt b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/xhr/Xhr.kt similarity index 90% rename from modules/kilua-dom/src/commonMain/kotlin/web/xhr/Xhr.kt rename to modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/xhr/Xhr.kt index bf0ed5cc5..278495b26 100644 --- a/modules/kilua-dom/src/commonMain/kotlin/web/xhr/Xhr.kt +++ b/modules/kilua-dom/src/jsCommonMain/kotlin/dev/kilua/dom/xhr/Xhr.kt @@ -11,18 +11,18 @@ // NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! // See github.com/kotlin/dukat for details -package web.xhr - -import web.JsAny -import web.JsArray -import web.JsNumber -import web.dom.Document -import web.dom.EventInit -import web.dom.HTMLFormElement -import web.dom.events.Event -import web.dom.events.EventTarget -import web.dom.url.URLSearchParams -import web.files.Blob +package dev.kilua.dom.xhr + +import dev.kilua.dom.api.Document +import dev.kilua.dom.api.EventInit +import dev.kilua.dom.api.HTMLFormElement +import dev.kilua.dom.api.events.Event +import dev.kilua.dom.api.events.EventTarget +import dev.kilua.dom.api.url.URLSearchParams +import dev.kilua.dom.core.JsAny +import dev.kilua.dom.core.JsArray +import dev.kilua.dom.core.JsNumber +import dev.kilua.dom.files.Blob /** * Exposes the JavaScript [XMLHttpRequestEventTarget](https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequestEventTarget) to Kotlin diff --git a/modules/kilua-dom/src/jsMain/kotlin/web/JsAny.js.kt b/modules/kilua-dom/src/jsMain/kotlin/web/JsAny.js.kt deleted file mode 100644 index 20d20aa43..000000000 --- a/modules/kilua-dom/src/jsMain/kotlin/web/JsAny.js.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Robert Jaros - * - * 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. - */ - -package web - -public actual external interface JsAny diff --git a/modules/kilua-dom/src/wasmJsMain/kotlin/web/JsAny.wasmJs.kt b/modules/kilua-dom/src/wasmJsMain/kotlin/web/JsAny.wasmJs.kt deleted file mode 100644 index 5750860d3..000000000 --- a/modules/kilua-dom/src/wasmJsMain/kotlin/web/JsAny.wasmJs.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Robert Jaros - * - * 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. - */ - -package web - -public actual typealias JsAny = kotlin.js.JsAny diff --git a/modules/kilua-fontawesome/src/commonMain/kotlin/dev/kilua/FontAwesomeModule.kt b/modules/kilua-fontawesome/src/commonMain/kotlin/dev/kilua/FontAwesomeModule.kt index 53ce51cd6..8a994d973 100644 --- a/modules/kilua-fontawesome/src/commonMain/kotlin/dev/kilua/FontAwesomeModule.kt +++ b/modules/kilua-fontawesome/src/commonMain/kotlin/dev/kilua/FontAwesomeModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("@fortawesome/fontawesome-free/css/all.min.css") internal external object FontAwesomeCss : JsAny diff --git a/modules/kilua-i18n/src/commonMain/kotlin/dev/kilua/i18n/I18n.kt b/modules/kilua-i18n/src/commonMain/kotlin/dev/kilua/i18n/I18n.kt index dc5e6c792..631f6e8a9 100644 --- a/modules/kilua-i18n/src/commonMain/kotlin/dev/kilua/i18n/I18n.kt +++ b/modules/kilua-i18n/src/commonMain/kotlin/dev/kilua/i18n/I18n.kt @@ -28,7 +28,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import dev.kilua.externals.get import name.kropp.kotlinx.gettext.Gettext -import web.JsAny +import dev.kilua.dom.JsAny /** * Provides translations by the underlying gettext library. diff --git a/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/externals/ImaskJs.kt b/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/externals/ImaskJs.kt index 78f181662..086de7d0a 100644 --- a/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/externals/ImaskJs.kt +++ b/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/externals/ImaskJs.kt @@ -25,11 +25,10 @@ package dev.kilua.externals import dev.kilua.JsModule import dev.kilua.JsName -import web.JsAny -import web.JsArray -import web.JsNumber -import web.JsString -import web.dom.HTMLElement +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsNumber +import dev.kilua.dom.JsString +import dev.kilua.dom.api.HTMLElement internal external class ImaskJs : JsAny { var unmaskedValue: String? @@ -74,7 +73,7 @@ internal external class RangeMaskOptionsJs : ImaskOptionsJs { internal external class EnumMaskOptionsJs : ImaskOptionsJs { var mask: JsAny - var enum: JsArray + var enum: dev.kilua.dom.JsArray var lazy: Boolean? var eager: Boolean? var placeholderChar: String? @@ -88,7 +87,7 @@ internal external class NumberMaskOptionsJs : ImaskOptionsJs { var padFractionalZeros: Boolean? var normalizeZeros: Boolean? var radix: String? - var mapToRadix: JsArray? + var mapToRadix: dev.kilua.dom.JsArray? var min: JsNumber? var max: JsNumber? } diff --git a/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/form/ImaskFactory.kt b/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/form/ImaskFactory.kt index 9ff508b47..d847b791b 100644 --- a/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/form/ImaskFactory.kt +++ b/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/form/ImaskFactory.kt @@ -24,7 +24,7 @@ package dev.kilua.form import dev.kilua.externals.ImaskObjJs import dev.kilua.utils.cast -import web.dom.HTMLElement +import dev.kilua.dom.api.HTMLElement internal class ImaskFactory : MaskFactory { diff --git a/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/form/ImaskOptions.kt b/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/form/ImaskOptions.kt index 5cd874329..b6e0f7083 100644 --- a/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/form/ImaskOptions.kt +++ b/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/form/ImaskOptions.kt @@ -36,11 +36,11 @@ import dev.kilua.i18n.Locale import dev.kilua.i18n.LocaleManager import dev.kilua.utils.toJsArray import dev.kilua.utils.toKebabCase -import web.JsAny -import web.RegExp -import web.toJsBoolean -import web.toJsNumber -import web.toJsString +import dev.kilua.dom.JsAny +import dev.kilua.dom.RegExp +import dev.kilua.dom.toJsBoolean +import dev.kilua.dom.toJsNumber +import dev.kilua.dom.toJsString /** * Text input mask overwrite modes. diff --git a/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/form/Number.kt b/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/form/Number.kt index d3fc4d246..857bec1d5 100644 --- a/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/form/Number.kt +++ b/modules/kilua-imask/src/commonMain/kotlin/dev/kilua/form/Number.kt @@ -22,6 +22,6 @@ package dev.kilua.form -import web.JsAny +import dev.kilua.dom.JsAny internal expect fun jsNumber(): JsAny diff --git a/modules/kilua-imask/src/jsMain/kotlin/dev/kilua/form/Number.js.kt b/modules/kilua-imask/src/jsMain/kotlin/dev/kilua/form/Number.js.kt index 83369ebf8..c7d4a1b93 100644 --- a/modules/kilua-imask/src/jsMain/kotlin/dev/kilua/form/Number.js.kt +++ b/modules/kilua-imask/src/jsMain/kotlin/dev/kilua/form/Number.js.kt @@ -22,7 +22,7 @@ package dev.kilua.form -import web.JsAny +import dev.kilua.dom.JsAny internal actual fun jsNumber(): JsAny { @Suppress("UnsafeCastFromDynamic") diff --git a/modules/kilua-imask/src/wasmJsMain/kotlin/dev/kilua/form/Number.wasmJs.kt b/modules/kilua-imask/src/wasmJsMain/kotlin/dev/kilua/form/Number.wasmJs.kt index 353d0c23d..217c9803a 100644 --- a/modules/kilua-imask/src/wasmJsMain/kotlin/dev/kilua/form/Number.wasmJs.kt +++ b/modules/kilua-imask/src/wasmJsMain/kotlin/dev/kilua/form/Number.wasmJs.kt @@ -22,6 +22,6 @@ package dev.kilua.form -import web.JsAny +import dev.kilua.dom.JsAny internal actual fun jsNumber(): JsAny = js("Number") diff --git a/modules/kilua-lazy-layouts/src/commonMain/kotlin/dev/kilua/panel/VisibilityDetector.kt b/modules/kilua-lazy-layouts/src/commonMain/kotlin/dev/kilua/panel/VisibilityDetector.kt index 7df6b4252..6050c55b6 100644 --- a/modules/kilua-lazy-layouts/src/commonMain/kotlin/dev/kilua/panel/VisibilityDetector.kt +++ b/modules/kilua-lazy-layouts/src/commonMain/kotlin/dev/kilua/panel/VisibilityDetector.kt @@ -29,8 +29,7 @@ import dev.kilua.externals.console import dev.kilua.externals.obj import dev.kilua.html.div import dev.kilua.utils.toList -import web.document -import web.dom.observers.IntersectionObserver +import dev.kilua.dom.api.observers.IntersectionObserver import kotlin.random.Random import kotlin.random.nextUInt diff --git a/modules/kilua-marked/src/commonMain/kotlin/dev/kilua/externals/MarkedJs.kt b/modules/kilua-marked/src/commonMain/kotlin/dev/kilua/externals/MarkedJs.kt index 8b509c0b8..8c5c94fc3 100644 --- a/modules/kilua-marked/src/commonMain/kotlin/dev/kilua/externals/MarkedJs.kt +++ b/modules/kilua-marked/src/commonMain/kotlin/dev/kilua/externals/MarkedJs.kt @@ -24,7 +24,7 @@ package dev.kilua.externals import dev.kilua.JsModule -import web.JsAny +import dev.kilua.dom.JsAny internal external class MarkedOptionsJs : JsAny { var gfm: Boolean diff --git a/modules/kilua-marked/src/commonMain/kotlin/dev/kilua/marked/Marked.kt b/modules/kilua-marked/src/commonMain/kotlin/dev/kilua/marked/Marked.kt index 18f7af0fb..13a603a05 100644 --- a/modules/kilua-marked/src/commonMain/kotlin/dev/kilua/marked/Marked.kt +++ b/modules/kilua-marked/src/commonMain/kotlin/dev/kilua/marked/Marked.kt @@ -25,7 +25,7 @@ package dev.kilua.marked import dev.kilua.externals.MarkedOptionsJs import dev.kilua.externals.obj import dev.kilua.externals.parse -import web.JsAny +import dev.kilua.dom.JsAny /** * Marked parser options. diff --git a/modules/kilua-rest/src/commonMain/kotlin/dev/kilua/rest/Fetch.kt b/modules/kilua-rest/src/commonMain/kotlin/dev/kilua/rest/Fetch.kt index 6af9657c3..5affe1ffb 100644 --- a/modules/kilua-rest/src/commonMain/kotlin/dev/kilua/rest/Fetch.kt +++ b/modules/kilua-rest/src/commonMain/kotlin/dev/kilua/rest/Fetch.kt @@ -22,9 +22,9 @@ package dev.kilua.rest -import web.Promise -import web.fetch.RequestInit -import web.fetch.Response +import dev.kilua.dom.Promise +import dev.kilua.dom.fetch.RequestInit +import dev.kilua.dom.fetch.Response /** * JavaScript fetch function diff --git a/modules/kilua-rest/src/commonMain/kotlin/dev/kilua/rest/RestClient.kt b/modules/kilua-rest/src/commonMain/kotlin/dev/kilua/rest/RestClient.kt index fd8897b6e..879e71396 100644 --- a/modules/kilua-rest/src/commonMain/kotlin/dev/kilua/rest/RestClient.kt +++ b/modules/kilua-rest/src/commonMain/kotlin/dev/kilua/rest/RestClient.kt @@ -38,12 +38,10 @@ import kotlinx.serialization.json.Json import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.modules.overwriteWith import kotlinx.serialization.serializer -import web.JsAny -import web.dom.url.URLSearchParams -import web.fetch.RequestInit -import web.fetch.Response -import web.toJsString -import web.window +import dev.kilua.dom.JsAny +import dev.kilua.dom.fetch.RequestInit +import dev.kilua.dom.fetch.Response +import dev.kilua.dom.toJsString import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException @@ -281,7 +279,7 @@ public open class RestClient(block: (RestClientConfig.() -> Unit) = {}) { } else { restRequestConfig.data!!.cast() } - URLSearchParams(removeNulls(dataSer)) + dev.kilua.dom.api.url.URLSearchParams(removeNulls(dataSer)) } else -> { @@ -299,7 +297,7 @@ public open class RestClient(block: (RestClientConfig.() -> Unit) = {}) { } else { restRequestConfig.data!!.cast() } - url + "?" + URLSearchParams(removeNulls(dataSer)).toString() + url + "?" + dev.kilua.dom.api.url.URLSearchParams(removeNulls(dataSer)).toString() } else { url } diff --git a/modules/kilua-routing/src/commonMain/kotlin/app/softwork/routingcompose/BrowserRouter.kt b/modules/kilua-routing/src/commonMain/kotlin/app/softwork/routingcompose/BrowserRouter.kt index 372514f2d..8b9a2e17e 100644 --- a/modules/kilua-routing/src/commonMain/kotlin/app/softwork/routingcompose/BrowserRouter.kt +++ b/modules/kilua-routing/src/commonMain/kotlin/app/softwork/routingcompose/BrowserRouter.kt @@ -21,8 +21,8 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState import androidx.compose.runtime.State import androidx.compose.runtime.mutableStateOf -import web.window -import web.dom.Location +import dev.kilua.dom.window +import dev.kilua.dom.api.Location /** * A router leveraging the History API (https://developer.mozilla.org/en-US/docs/Web/API/History). diff --git a/modules/kilua-routing/src/commonMain/kotlin/app/softwork/routingcompose/HashRouter.kt b/modules/kilua-routing/src/commonMain/kotlin/app/softwork/routingcompose/HashRouter.kt index 0bdfc5fd6..3ea709acc 100644 --- a/modules/kilua-routing/src/commonMain/kotlin/app/softwork/routingcompose/HashRouter.kt +++ b/modules/kilua-routing/src/commonMain/kotlin/app/softwork/routingcompose/HashRouter.kt @@ -21,7 +21,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState import androidx.compose.runtime.State import androidx.compose.runtime.mutableStateOf -import web.window +import dev.kilua.dom.window /** * This [Router] implementation uses `/#/path` to persistent the current route in [window.location.hash]. diff --git a/modules/kilua-rsup-progress/src/commonMain/kotlin/dev/kilua/externals/RsupProgress.kt b/modules/kilua-rsup-progress/src/commonMain/kotlin/dev/kilua/externals/RsupProgress.kt index f63e6f2c5..4716dabe0 100644 --- a/modules/kilua-rsup-progress/src/commonMain/kotlin/dev/kilua/externals/RsupProgress.kt +++ b/modules/kilua-rsup-progress/src/commonMain/kotlin/dev/kilua/externals/RsupProgress.kt @@ -26,8 +26,8 @@ package dev.kilua.externals import dev.kilua.JsModule import dev.kilua.JsName -import web.JsAny -import web.Promise +import dev.kilua.dom.JsAny +import dev.kilua.dom.Promise internal external class RsupProgressOptions : JsAny { var height: Int? diff --git a/modules/kilua-rsup-progress/src/commonMain/kotlin/dev/kilua/progress/Progress.kt b/modules/kilua-rsup-progress/src/commonMain/kotlin/dev/kilua/progress/Progress.kt index 27529d5cb..e7bb2e095 100644 --- a/modules/kilua-rsup-progress/src/commonMain/kotlin/dev/kilua/progress/Progress.kt +++ b/modules/kilua-rsup-progress/src/commonMain/kotlin/dev/kilua/progress/Progress.kt @@ -29,8 +29,8 @@ import dev.kilua.externals.obj import dev.kilua.html.Color import dev.kilua.utils.isDom import dev.kilua.utils.toKebabCase -import web.JsAny -import web.Promise +import dev.kilua.dom.JsAny +import dev.kilua.dom.Promise import kotlin.time.Duration /** diff --git a/modules/kilua-sanitize-html/src/commonMain/kotlin/dev/kilua/externals/SanitizeHtmlJs.kt b/modules/kilua-sanitize-html/src/commonMain/kotlin/dev/kilua/externals/SanitizeHtmlJs.kt index 79e643a20..cbff7a5f9 100644 --- a/modules/kilua-sanitize-html/src/commonMain/kotlin/dev/kilua/externals/SanitizeHtmlJs.kt +++ b/modules/kilua-sanitize-html/src/commonMain/kotlin/dev/kilua/externals/SanitizeHtmlJs.kt @@ -25,19 +25,18 @@ package dev.kilua.externals import dev.kilua.JsModule import dev.kilua.JsName -import web.JsAny -import web.JsArray -import web.JsString +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsString internal external class SanitizeHtmlOptionsJs : JsAny { var allowedTags: JsAny - var nonBooleanAttributes: JsArray + var nonBooleanAttributes: dev.kilua.dom.JsArray var allowedAttributes: JsAny var disallowedTagsMode: String - var selfClosing: JsArray - var allowedSchemes: JsArray + var selfClosing: dev.kilua.dom.JsArray + var allowedSchemes: dev.kilua.dom.JsArray var allowedSchemesByTag: JsAny - var allowedSchemesAppliedToAttributes: JsArray + var allowedSchemesAppliedToAttributes: dev.kilua.dom.JsArray var allowProtocolRelative: Boolean var enforceHtmlBoundary: Boolean var parseStyleAttributes: Boolean @@ -45,7 +44,7 @@ internal external class SanitizeHtmlOptionsJs : JsAny { var allowedClasses: JsAny var allowedStyles: JsAny var transformTags: JsAny - var nonTextTags: JsArray + var nonTextTags: dev.kilua.dom.JsArray var nestingLimit: Int } diff --git a/modules/kilua-sanitize-html/src/commonMain/kotlin/dev/kilua/sanitize/SanitizeHtml.kt b/modules/kilua-sanitize-html/src/commonMain/kotlin/dev/kilua/sanitize/SanitizeHtml.kt index 3e83b4240..e250a30e3 100644 --- a/modules/kilua-sanitize-html/src/commonMain/kotlin/dev/kilua/sanitize/SanitizeHtml.kt +++ b/modules/kilua-sanitize-html/src/commonMain/kotlin/dev/kilua/sanitize/SanitizeHtml.kt @@ -26,10 +26,10 @@ import dev.kilua.externals.SanitizeHtmlOptionsJs import dev.kilua.externals.obj import dev.kilua.utils.toJsAny import dev.kilua.utils.toJsArray -import web.JsAny -import web.RegExp -import web.toJsBoolean -import web.toJsString +import dev.kilua.dom.JsAny +import dev.kilua.dom.RegExp +import dev.kilua.dom.toJsBoolean +import dev.kilua.dom.toJsString /** * Disallowed tags modes. diff --git a/modules/kilua-select-remote/src/commonMain/kotlin/dev/kilua/form/select/SelectRemote.kt b/modules/kilua-select-remote/src/commonMain/kotlin/dev/kilua/form/select/SelectRemote.kt index 29f2d39a1..3a5260a0b 100644 --- a/modules/kilua-select-remote/src/commonMain/kotlin/dev/kilua/form/select/SelectRemote.kt +++ b/modules/kilua-select-remote/src/commonMain/kotlin/dev/kilua/form/select/SelectRemote.kt @@ -34,7 +34,7 @@ import dev.kilua.rpc.RpcServiceMgr import dev.kilua.rpc.SimpleRemoteOption import dev.kilua.utils.StringPair import kotlinx.coroutines.launch -import web.fetch.RequestInit +import dev.kilua.dom.fetch.RequestInit /** * Creates [Select] component with a remote data source, returning a reference. diff --git a/modules/kilua-select-remote/src/jsMain/kotlin/dev/kilua/form/select/SelectRemote.js.kt b/modules/kilua-select-remote/src/jsMain/kotlin/dev/kilua/form/select/SelectRemote.js.kt index 21bfc280a..718b363b3 100644 --- a/modules/kilua-select-remote/src/jsMain/kotlin/dev/kilua/form/select/SelectRemote.js.kt +++ b/modules/kilua-select-remote/src/jsMain/kotlin/dev/kilua/form/select/SelectRemote.js.kt @@ -30,7 +30,7 @@ import dev.kilua.rpc.SimpleRemoteOption import dev.kilua.utils.StringPair import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.encodeToString -import web.fetch.RequestInit +import dev.kilua.dom.fetch.RequestInit internal actual suspend fun getOptionsForSelectRemote( serviceManager: RpcServiceMgr, diff --git a/modules/kilua-select-remote/src/wasmJsMain/kotlin/dev/kilua/form/select/SelectRemote.wasmJs.kt b/modules/kilua-select-remote/src/wasmJsMain/kotlin/dev/kilua/form/select/SelectRemote.wasmJs.kt index 1edcbab19..e8ce91d7d 100644 --- a/modules/kilua-select-remote/src/wasmJsMain/kotlin/dev/kilua/form/select/SelectRemote.wasmJs.kt +++ b/modules/kilua-select-remote/src/wasmJsMain/kotlin/dev/kilua/form/select/SelectRemote.wasmJs.kt @@ -33,8 +33,8 @@ import dev.kilua.rpc.SimpleRemoteOption import dev.kilua.utils.StringPair import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.encodeToString -import web.fetch.RequestInit -import web.toJsString +import dev.kilua.dom.fetch.RequestInit +import dev.kilua.dom.toJsString internal actual suspend fun getOptionsForSelectRemote( serviceManager: RpcServiceMgr, diff --git a/modules/kilua-splitjs/src/commonMain/kotlin/dev/kilua/SplitjsModule.kt b/modules/kilua-splitjs/src/commonMain/kotlin/dev/kilua/SplitjsModule.kt index 136bd17c4..36bd4d38a 100644 --- a/modules/kilua-splitjs/src/commonMain/kotlin/dev/kilua/SplitjsModule.kt +++ b/modules/kilua-splitjs/src/commonMain/kotlin/dev/kilua/SplitjsModule.kt @@ -22,7 +22,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("zzz-kilua-assets/k-splitjs.css") internal external object CoreSplitjsCss : JsAny diff --git a/modules/kilua-splitjs/src/commonMain/kotlin/dev/kilua/externals/SplitJs.kt b/modules/kilua-splitjs/src/commonMain/kotlin/dev/kilua/externals/SplitJs.kt index d0503b56d..27a9008db 100644 --- a/modules/kilua-splitjs/src/commonMain/kotlin/dev/kilua/externals/SplitJs.kt +++ b/modules/kilua-splitjs/src/commonMain/kotlin/dev/kilua/externals/SplitJs.kt @@ -25,8 +25,8 @@ package dev.kilua.externals import dev.kilua.panel.Dir import dev.kilua.panel.GutterAlign -import web.JsAny -import web.dom.HTMLElement +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.HTMLElement /** * Split.js native instance. diff --git a/modules/kilua-splitjs/src/commonMain/kotlin/dev/kilua/panel/SplitPanel.kt b/modules/kilua-splitjs/src/commonMain/kotlin/dev/kilua/panel/SplitPanel.kt index 45c91f5f1..33a7a178a 100644 --- a/modules/kilua-splitjs/src/commonMain/kotlin/dev/kilua/panel/SplitPanel.kt +++ b/modules/kilua-splitjs/src/commonMain/kotlin/dev/kilua/panel/SplitPanel.kt @@ -41,7 +41,7 @@ import dev.kilua.html.Tag import dev.kilua.html.div import dev.kilua.utils.cast import dev.kilua.utils.toKebabCase -import web.dom.HTMLDivElement +import dev.kilua.dom.api.HTMLDivElement import kotlin.math.ceil internal const val SPLIT_PANEL_DEFAULT_GUTTER_SIZE = 10 diff --git a/modules/kilua-splitjs/src/jsMain/kotlin/dev/kilua/externals/SplitJs.js.kt b/modules/kilua-splitjs/src/jsMain/kotlin/dev/kilua/externals/SplitJs.js.kt index 04a79de1f..9e9fd1cfe 100644 --- a/modules/kilua-splitjs/src/jsMain/kotlin/dev/kilua/externals/SplitJs.js.kt +++ b/modules/kilua-splitjs/src/jsMain/kotlin/dev/kilua/externals/SplitJs.js.kt @@ -24,8 +24,8 @@ package dev.kilua.externals -import web.JsAny -import web.dom.HTMLElement +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.HTMLElement internal external class SplitJsOptionsExt : JsAny { var sizes: Array diff --git a/modules/kilua-splitjs/src/jsMain/kotlin/dev/kilua/externals/SplitJs.kt b/modules/kilua-splitjs/src/jsMain/kotlin/dev/kilua/externals/SplitJs.kt index 7e70428ff..71c16b8be 100644 --- a/modules/kilua-splitjs/src/jsMain/kotlin/dev/kilua/externals/SplitJs.kt +++ b/modules/kilua-splitjs/src/jsMain/kotlin/dev/kilua/externals/SplitJs.kt @@ -23,7 +23,7 @@ package dev.kilua.externals import dev.kilua.panel.Dir -import web.dom.HTMLElement +import dev.kilua.dom.api.HTMLElement internal actual fun splitJs(elements: List, options: SplitJsOptions): SplitJsInstance { val splitJsDirection = if (options.direction == Dir.Horizontal) "vertical" else "horizontal" diff --git a/modules/kilua-splitjs/src/wasmJsMain/kotlin/dev/kilua/externals/SplitJs.wasmJs.kt b/modules/kilua-splitjs/src/wasmJsMain/kotlin/dev/kilua/externals/SplitJs.wasmJs.kt index 1b052f942..5ce8acfdc 100644 --- a/modules/kilua-splitjs/src/wasmJsMain/kotlin/dev/kilua/externals/SplitJs.wasmJs.kt +++ b/modules/kilua-splitjs/src/wasmJsMain/kotlin/dev/kilua/externals/SplitJs.wasmJs.kt @@ -25,7 +25,7 @@ package dev.kilua.externals import dev.kilua.panel.Dir import dev.kilua.utils.jsArrayOf import dev.kilua.utils.toList -import web.dom.HTMLElement +import dev.kilua.dom.api.HTMLElement internal external class SplitJsOptionsExt : JsAny { var sizes: JsArray diff --git a/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/NodeHttp.kt b/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/NodeHttp.kt index 2eb708e2a..216f074e3 100644 --- a/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/NodeHttp.kt +++ b/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/NodeHttp.kt @@ -23,7 +23,7 @@ package dev.kilua.ssr import dev.kilua.JsModule -import web.JsAny +import dev.kilua.dom.JsAny /** * Node.js HTTP server. diff --git a/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/NodeProcess.kt b/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/NodeProcess.kt index 5bd6cd927..9866c17ad 100644 --- a/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/NodeProcess.kt +++ b/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/NodeProcess.kt @@ -25,9 +25,8 @@ package dev.kilua.ssr import dev.kilua.externals.get import dev.kilua.utils.cast import dev.kilua.utils.toList -import web.JsAny -import web.JsArray -import web.JsString +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsString /** * Node.js process object. @@ -39,7 +38,7 @@ internal external val process: JsAny? */ public fun getCommandLineParameter(name: String): String? { return if (process != null) { - val args = process["argv"].cast>().toList().map { it.toString() }.drop(2) + val args = process["argv"].cast>().toList().map { it.toString() }.drop(2) val index = args.indexOfFirst { it == name } if (index != -1 && index < args.size - 1) { args[index + 1] diff --git a/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/SsrRouter.kt b/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/SsrRouter.kt index 0d9515066..4560048a8 100644 --- a/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/SsrRouter.kt +++ b/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/SsrRouter.kt @@ -53,8 +53,8 @@ import dev.kilua.utils.unsafeCast import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch -import web.JsAny -import web.toJsString +import dev.kilua.dom.JsAny +import dev.kilua.dom.toJsString /** * A router supporting Server-Side Rendering (SSR). diff --git a/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/SsrState.kt b/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/SsrState.kt index 8379708f6..d4479e8bb 100644 --- a/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/SsrState.kt +++ b/modules/kilua-ssr/src/commonMain/kotlin/dev/kilua/ssr/SsrState.kt @@ -25,7 +25,7 @@ package dev.kilua.ssr import dev.kilua.externals.get import dev.kilua.utils.isDom import kotlinx.serialization.json.Json -import web.window +import dev.kilua.dom.window public inline fun getSsrState(json: Json = Json.Default): T? { return if (isDom) { diff --git a/modules/kilua-svg/src/commonMain/kotlin/dev/kilua/svg/ISvgTag.kt b/modules/kilua-svg/src/commonMain/kotlin/dev/kilua/svg/ISvgTag.kt index fea90219e..3fa8b7b8b 100644 --- a/modules/kilua-svg/src/commonMain/kotlin/dev/kilua/svg/ISvgTag.kt +++ b/modules/kilua-svg/src/commonMain/kotlin/dev/kilua/svg/ISvgTag.kt @@ -25,7 +25,7 @@ package dev.kilua.svg import androidx.compose.runtime.Composable import dev.kilua.html.CssSize import dev.kilua.html.ITag -import web.dom.HTMLElement +import dev.kilua.dom.api.HTMLElement /** * Base SVG tag interface. diff --git a/modules/kilua-svg/src/commonMain/kotlin/dev/kilua/svg/SvgTag.kt b/modules/kilua-svg/src/commonMain/kotlin/dev/kilua/svg/SvgTag.kt index cceb0d51e..ceaf4b8c1 100644 --- a/modules/kilua-svg/src/commonMain/kotlin/dev/kilua/svg/SvgTag.kt +++ b/modules/kilua-svg/src/commonMain/kotlin/dev/kilua/svg/SvgTag.kt @@ -27,7 +27,7 @@ import dev.kilua.core.RenderConfig import dev.kilua.html.CssSize import dev.kilua.html.Tag import dev.kilua.html.helpers.PropertyListBuilder -import web.dom.HTMLElement +import dev.kilua.dom.api.HTMLElement /** * The SVG namespace. diff --git a/modules/kilua-tabulator-remote/src/commonMain/kotlin/dev/kilua/tabulator/TabulatorRemote.kt b/modules/kilua-tabulator-remote/src/commonMain/kotlin/dev/kilua/tabulator/TabulatorRemote.kt index b38965254..f9601caf3 100644 --- a/modules/kilua-tabulator-remote/src/commonMain/kotlin/dev/kilua/tabulator/TabulatorRemote.kt +++ b/modules/kilua-tabulator-remote/src/commonMain/kotlin/dev/kilua/tabulator/TabulatorRemote.kt @@ -45,9 +45,8 @@ import kotlinx.serialization.json.Json import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.modules.overwriteWith import kotlinx.serialization.serializer -import web.JsAny -import web.JsArray -import web.fetch.RequestInit +import dev.kilua.dom.JsAny +import dev.kilua.dom.fetch.RequestInit import kotlin.reflect.KClass public open class TabulatorRemote( @@ -304,4 +303,4 @@ public expect suspend fun getDataForTabulatorRemote( size: String?, filters: String?, sorters: String? -): JsArray +): dev.kilua.dom.JsArray diff --git a/modules/kilua-tabulator-remote/src/jsMain/kotlin/dev/kilua/tabulator/TabulatorRemote.js.kt b/modules/kilua-tabulator-remote/src/jsMain/kotlin/dev/kilua/tabulator/TabulatorRemote.js.kt index 91f3110ed..2e6100b20 100644 --- a/modules/kilua-tabulator-remote/src/jsMain/kotlin/dev/kilua/tabulator/TabulatorRemote.js.kt +++ b/modules/kilua-tabulator-remote/src/jsMain/kotlin/dev/kilua/tabulator/TabulatorRemote.js.kt @@ -30,9 +30,8 @@ import dev.kilua.rpc.RemoteSorter import dev.kilua.rpc.RpcServiceMgr import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import web.JsAny -import web.JsArray -import web.fetch.RequestInit +import dev.kilua.dom.JsAny +import dev.kilua.dom.fetch.RequestInit @Suppress("UnsafeCastFromDynamic") public actual suspend fun getDataForTabulatorRemote( @@ -44,7 +43,7 @@ public actual suspend fun getDataForTabulatorRemote( size: String?, filters: String?, sorters: String? -): JsArray { +): dev.kilua.dom.JsArray { val (url, method) = serviceManager.requireCall(function) val callAgent = CallAgent() val state = stateFunction?.invoke()?.let { JSON.stringify(it) } diff --git a/modules/kilua-tabulator-remote/src/wasmJsMain/kotlin/dev/kilua/tabulator/TabulatorRemote.wasmJs.kt b/modules/kilua-tabulator-remote/src/wasmJsMain/kotlin/dev/kilua/tabulator/TabulatorRemote.wasmJs.kt index e8cb1dffa..d0eee4472 100644 --- a/modules/kilua-tabulator-remote/src/wasmJsMain/kotlin/dev/kilua/tabulator/TabulatorRemote.wasmJs.kt +++ b/modules/kilua-tabulator-remote/src/wasmJsMain/kotlin/dev/kilua/tabulator/TabulatorRemote.wasmJs.kt @@ -34,10 +34,10 @@ import dev.kilua.rpc.RpcServiceMgr import dev.kilua.utils.jsArrayOf import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import web.JsAny -import web.JsArray -import web.fetch.RequestInit -import web.toJsString +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray +import dev.kilua.dom.fetch.RequestInit +import dev.kilua.dom.toJsString public actual suspend fun getDataForTabulatorRemote( serviceManager: RpcServiceMgr, diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorBulmaModule.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorBulmaModule.kt index 0d0afff93..8cec46fb0 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorBulmaModule.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorBulmaModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("tabulator-tables/dist/css/tabulator_bulma.min.css") internal external object TabulatorBulmaCss : JsAny diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorDefaultModule.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorDefaultModule.kt index daf785ba1..a70eee85a 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorDefaultModule.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorDefaultModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("tabulator-tables/dist/css/tabulator.min.css") internal external object TabulatorDefaultCss : JsAny diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorMaterializeModule.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorMaterializeModule.kt index dd4ee7b9e..c38d62674 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorMaterializeModule.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorMaterializeModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("tabulator-tables/dist/css/tabulator_materialize.min.css") internal external object TabulatorMaterializeCss : JsAny diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorMidnightModule.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorMidnightModule.kt index f202b0cc9..85b3220d5 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorMidnightModule.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorMidnightModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("tabulator-tables/dist/css/tabulator_midnight.min.css") internal external object TabulatorMidnightCss : JsAny diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorModernModule.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorModernModule.kt index 5ecb3d82c..03a4c4ec5 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorModernModule.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorModernModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("tabulator-tables/dist/css/tabulator_modern.min.css") internal external object TabulatorModernCss : JsAny diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorModule.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorModule.kt index 958863cdf..31f3a59d4 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorModule.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("tabulator-tables/dist/css/tabulator_bootstrap5.min.css") internal external object TabulatorCss : JsAny diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorSemanticUIModule.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorSemanticUIModule.kt index ed6c79399..74de43ba8 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorSemanticUIModule.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorSemanticUIModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("tabulator-tables/dist/css/tabulator_semanticui.min.css") internal external object TabulatorSemanticUICss : JsAny diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorSimpleModule.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorSimpleModule.kt index bd95787dd..3c2279746 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorSimpleModule.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorSimpleModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("tabulator-tables/dist/css/tabulator_simple.min.css") internal external object TabulatorSimpleCss : JsAny diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorSiteDarkModule.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorSiteDarkModule.kt index 6c6a679b7..df6c67e66 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorSiteDarkModule.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/TabulatorSiteDarkModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("tabulator-tables/dist/css/tabulator_site_dark.min.css") internal external object TabulatorSiteDarkCss : JsAny diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/CellComponentBase.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/CellComponentBase.kt index 608e2e0df..079a32fae 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/CellComponentBase.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/CellComponentBase.kt @@ -22,8 +22,8 @@ package dev.kilua.externals -import web.JsAny -import web.dom.HTMLElement +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.HTMLElement /** * JavaScript Tabulator cell component base interface. diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/Interop.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/Interop.kt index e76bf6887..9e3ecf06a 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/Interop.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/Interop.kt @@ -22,12 +22,10 @@ package dev.kilua.externals -import web.JsAny -import web.JsArray -import web.JsNumber -import web.Promise -import web.dom.Element -import web.dom.events.Event +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsNumber +import dev.kilua.dom.Promise +import dev.kilua.dom.api.Element /** * A set of hrlper functions to convert different Kotlin functions to JavaScript functions (JsAny). @@ -75,8 +73,8 @@ internal expect fun toJsAny(f: (String, JsAny) -> Boolean): JsAny internal expect fun toJsAny(f: (String, JsAny, JsAny) -> JsAny): JsAny -internal expect fun toJsAny(f: (JsArray) -> Element): JsAny +internal expect fun toJsAny(f: (dev.kilua.dom.JsArray) -> Element): JsAny internal expect fun toJsAny(f: (JsAny) -> Boolean): JsAny -internal expect fun toJsAny(f: (Event) -> JsArray): JsAny +internal expect fun toJsAny(f: (dev.kilua.dom.api.events.Event) -> dev.kilua.dom.JsArray): JsAny diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/TabulatorJs.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/TabulatorJs.kt index 18adf3177..fccd31191 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/TabulatorJs.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/TabulatorJs.kt @@ -26,10 +26,10 @@ package dev.kilua.externals import dev.kilua.JsModule import dev.kilua.JsName -import web.JsAny -import web.JsArray -import web.Promise -import web.dom.HTMLElement +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray +import dev.kilua.dom.Promise +import dev.kilua.dom.api.HTMLElement /** * JavaScript Tabulator component. @@ -64,26 +64,26 @@ public open external class TabulatorJs(element: HTMLElement, options: JsAny?) : public fun getHistoryUndoSize(): JsAny public fun redo(): Boolean public fun getHistoryRedoSize(): JsAny - public fun getEditedCells(): JsArray + public fun getEditedCells(): dev.kilua.dom.JsArray public fun clearCellEdited(clear: JsAny) public fun destroy() public fun import(importer: JsAny, extensions: String) public fun import(importer: JsAny, extensions: String, type: String) public fun setData(data: JsAny?, params: JsAny?, config: JsAny?): Promise public fun clearData() - public fun getData(activeOnly: String?): JsArray + public fun getData(activeOnly: String?): dev.kilua.dom.JsArray public fun getDataCount(activeOnly: String? /* 'active' | 'visible' */): Int public fun searchRows( field: String, type: String /* '=' | '!=' | 'like' | '<' | '>' | '<=' | '>=' | 'in' | 'regex' | 'starts' | 'ends' */, value: JsAny - ): JsArray + ): dev.kilua.dom.JsArray public fun searchData( field: String, type: String /* '=' | '!=' | 'like' | '<' | '>' | '<=' | '>=' | 'in' | 'regex' | 'starts' | 'ends' */, value: JsAny - ): JsArray + ): dev.kilua.dom.JsArray public fun getHtml( rowRangeLookup: String /* 'visible' | 'active' | 'selected' | 'all' */, @@ -100,14 +100,14 @@ public open external class TabulatorJs(element: HTMLElement, options: JsAny?) : public fun getAjaxUrl(): String public fun replaceData(data: JsAny /* JsArray | String */, params: JsAny?, config: JsAny?): Promise - public fun updateData(data: JsArray): Promise + public fun updateData(data: dev.kilua.dom.JsArray): Promise public fun addData( - data: JsArray, + data: dev.kilua.dom.JsArray, addToTop: Boolean, positionTarget: JsAny /* RowComponent | HTMLElement | String | JsNumber | JsArray | JsArray */ ): Promise - public fun updateOrAddData(data: JsArray): Promise> + public fun updateOrAddData(data: dev.kilua.dom.JsArray): Promise> public fun getRow(row: JsAny /* RowComponent | HTMLElement | String | JsNumber | JsArray | JsArray */): RowComponent public fun getRowFromPosition(position: Int): RowComponent @@ -140,17 +140,17 @@ public open external class TabulatorJs(element: HTMLElement, options: JsAny?) : placeAboveTarget: Boolean ) - public fun getRows(activeOnly: String /* 'active' | 'visible' */): JsArray + public fun getRows(activeOnly: String /* 'active' | 'visible' */): dev.kilua.dom.JsArray public fun getRowPosition( row: JsAny /* RowComponent | HTMLElement | String | JsNumber | JsArray | JsArray */ ): JsAny - public fun setColumns(definitions: JsArray) - public fun getColumns(includeColumnGroups: Boolean): JsArray + public fun setColumns(definitions: dev.kilua.dom.JsArray) + public fun getColumns(includeColumnGroups: Boolean): dev.kilua.dom.JsArray public fun getColumn(column: JsAny /* ColumnComponent | ColumnDefinition | HTMLElement | String */): ColumnComponent - public fun getColumnDefinitions(): JsArray - public fun getColumnLayout(): JsArray + public fun getColumnDefinitions(): dev.kilua.dom.JsArray + public fun getColumnLayout(): dev.kilua.dom.JsArray public fun setColumnLayout(layout: JsAny) public fun showColumn(column: JsAny /* ColumnComponent | ColumnDefinition | HTMLElement | String */) @@ -195,7 +195,7 @@ public open external class TabulatorJs(element: HTMLElement, options: JsAny?) : dir: String /* 'asc' | 'desc' */ ) - public fun getSorters(): JsArray + public fun getSorters(): dev.kilua.dom.JsArray public fun clearSort() public fun setFilter( p1: JsAny /* String | JsArray | JsArray | (data: JsAny, filterParams: JsAny):Boolean */, @@ -205,7 +205,7 @@ public open external class TabulatorJs(element: HTMLElement, options: JsAny?) : ) public fun addFilter(): JsAny - public fun getFilters(includeHeaderFilters: Boolean): JsArray + public fun getFilters(includeHeaderFilters: Boolean): dev.kilua.dom.JsArray public fun setHeaderFilterValue( column: JsAny /* ColumnComponent | ColumnDefinition | HTMLElement | String */, value: String @@ -213,7 +213,7 @@ public open external class TabulatorJs(element: HTMLElement, options: JsAny?) : public fun setHeaderFilterFocus(column: JsAny /* ColumnComponent | ColumnDefinition | HTMLElement | String */) - public fun getHeaderFilters(): JsArray + public fun getHeaderFilters(): dev.kilua.dom.JsArray public fun getHeaderFilterValue(column: JsAny /* ColumnComponent | ColumnDefinition | HTMLElement | String */): String public fun removeFilter(): JsAny @@ -222,8 +222,8 @@ public open external class TabulatorJs(element: HTMLElement, options: JsAny?) : public fun selectRow(lookup: JsAny /* JsArray | JsArray */> | 'all' | 'active' | 'visible' | Boolean */) public fun deselectRow(row: JsAny /* RowComponent | HTMLElement | String | JsNumber | JsArray | JsArray */) public fun toggleSelectRow(row: JsAny /* RowComponent | HTMLElement | String | JsNumber | JsArray | JsArray */) - public fun getSelectedRows(): JsArray - public fun getSelectedData(): JsArray + public fun getSelectedRows(): dev.kilua.dom.JsArray + public fun getSelectedData(): dev.kilua.dom.JsArray public fun setMaxPage(max: Int) public fun setPage(page: JsAny /* JsNumber | 'first' | 'prev' | 'next' | 'last' */): Promise public fun setPageToRow(row: JsAny /* RowComponent | HTMLElement | String | JsNumber | JsArray | JsArray */): Promise @@ -236,7 +236,7 @@ public open external class TabulatorJs(element: HTMLElement, options: JsAny?) : public fun setGroupBy(groups: JsAny /* String | (data: JsAny):JsAny */) public fun setGroupStartOpen(values: JsAny /* Boolean | (value: JsAny, count: JsNumber, data: JsAny, group: Tabulator.GroupComponent):Boolean */) public fun setGroupHeader(values: JsAny /* (value: JsAny, count: JsNumber, data: JsAny, group: Tabulator.GroupComponent):String | JsArray<(value: JsAny, count: JsNumber, data: JsAny):String> */) - public fun getGroups(): JsArray + public fun getGroups(): dev.kilua.dom.JsArray public fun getGroupedData(activeOnly: Boolean): JsAny public fun getCalcResults(): JsAny public fun recalc() @@ -246,7 +246,7 @@ public open external class TabulatorJs(element: HTMLElement, options: JsAny?) : public fun navigateRight() public fun navigateUp() public fun navigateDown() - public fun getInvalidCells(): JsArray + public fun getInvalidCells(): dev.kilua.dom.JsArray public fun clearCellValidation(clearType: JsAny /* Tabulator.CellComponent | JsArray */) public fun validate(): JsAny public fun refreshFilters(): JsAny @@ -288,7 +288,7 @@ public external class RowComponent : JsAny { public fun getData(): JsAny public fun getElement(): HTMLElement public fun getTable(): TabulatorJs - public fun getCells(): JsArray + public fun getCells(): dev.kilua.dom.JsArray public fun getCell(column: JsAny): CellComponent public fun getNextRow(): JsAny public fun getPrevRow(): JsAny @@ -312,7 +312,7 @@ public external class RowComponent : JsAny { public fun treeCollapse() public fun treeToggle() public fun getTreeParent(): JsAny - public fun getTreeChildren(): JsArray + public fun getTreeChildren(): dev.kilua.dom.JsArray public fun addTreeChild(rowData: JsAny, position: Boolean, existingRow: RowComponent) public fun validate(): JsAny public fun isFrozen(): Boolean @@ -327,8 +327,8 @@ public external class GroupComponent : JsAny { public fun getTable(): TabulatorJs public fun getKey(): JsAny public fun getField(): String - public fun getRows(): JsArray - public fun getSubGroups(): JsArray + public fun getRows(): dev.kilua.dom.JsArray + public fun getSubGroups(): dev.kilua.dom.JsArray public fun getParentGroup(): JsAny public fun isVisible(): Boolean public fun show() @@ -344,7 +344,7 @@ public external class ColumnComponent : JsAny { public fun getTable(): TabulatorJs public fun getDefinition(): JsAny public fun getField(): String - public fun getCells(): JsArray + public fun getCells(): dev.kilua.dom.JsArray public fun getNextColumn(): JsAny public fun getPrevColumn(): JsAny public fun move(toColumn: JsAny, after: Boolean) @@ -354,7 +354,7 @@ public external class ColumnComponent : JsAny { public fun toggle() public fun delete(): Promise public fun scrollTo(): Promise - public fun getSubColumns(): JsArray + public fun getSubColumns(): dev.kilua.dom.JsArray public fun getParentColumn(): JsAny public fun headerFilterFocus() public fun setHeaderFilterValue(value: JsAny) diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/TabulatorMenuItem.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/TabulatorMenuItem.kt index 85644f30d..f0ef50ab1 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/TabulatorMenuItem.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/TabulatorMenuItem.kt @@ -22,12 +22,11 @@ package dev.kilua.externals -import web.JsAny -import web.dom.Element -import web.dom.events.Event +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.Element internal external interface TabulatorMenuItem : JsAny { var label: Element - var action: (Event) -> Unit + var action: (dev.kilua.dom.api.events.Event) -> Unit var separator: Boolean } diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/TabulatorTablesJs.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/TabulatorTablesJs.kt index 98dec3968..e2dc6b274 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/TabulatorTablesJs.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/externals/TabulatorTablesJs.kt @@ -25,8 +25,8 @@ package dev.kilua.externals import dev.kilua.JsModule import dev.kilua.JsName -import web.JsAny -import web.dom.HTMLElement +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.HTMLElement /** * Workaround for tabulator-tables TabulatorFull imports problem. diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/tabulator/Options.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/tabulator/Options.kt index 9e0e47162..2778ab06b 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/tabulator/Options.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/tabulator/Options.kt @@ -25,7 +25,6 @@ package dev.kilua.tabulator import androidx.compose.runtime.Composable import dev.kilua.compose.Root import dev.kilua.compose.root -import dev.kilua.core.Component import dev.kilua.core.IComponent import dev.kilua.core.SafeDomFactory import dev.kilua.externals.CellComponent @@ -44,20 +43,18 @@ import dev.kilua.utils.toJsArray import dev.kilua.utils.toKebabCase import dev.kilua.utils.toList import dev.kilua.utils.unsafeCast -import web.JsAny -import web.JsArray -import web.JsNumber -import web.Promise -import web.document -import web.dom.Element -import web.dom.HTMLElement -import web.dom.asList -import web.dom.events.Event -import web.localStorage -import web.toJsBoolean -import web.toJsNumber -import web.toJsString -import web.window +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsNumber +import dev.kilua.dom.Promise +import dev.kilua.dom.document +import dev.kilua.dom.api.Element +import dev.kilua.dom.api.HTMLElement +import dev.kilua.dom.api.asList +import dev.kilua.dom.localStorage +import dev.kilua.dom.toJsBoolean +import dev.kilua.dom.toJsNumber +import dev.kilua.dom.toJsString +import dev.kilua.dom.window import kotlin.reflect.KClass /** @@ -779,7 +776,7 @@ internal fun ColumnDefinition.toJs( } } else editorFunction - val tmpHeaderColumnsMenu: ((Event) -> JsArray)? = if (this.headerColumnsMenu == true) { + val tmpHeaderColumnsMenu: ((dev.kilua.dom.api.events.Event) -> dev.kilua.dom.JsArray)? = if (this.headerColumnsMenu == true) { { _ -> val resetTitle = this.headerColumnsMenuResetTitle ?: "Default columns" fun resetColumns() { @@ -794,7 +791,7 @@ internal fun ColumnDefinition.toJs( }?.map { val responsiveHiddenColumns = (tabulator.tabulatorJs?.modules?.get("responsiveLayout")?.get("hiddenColumns") - ?.unsafeCast>())?.toList()?.map { + ?.unsafeCast>())?.toList()?.map { it.getField() } ?: emptyList() val icon = SafeDomFactory.createElement("i") @@ -807,7 +804,7 @@ internal fun ColumnDefinition.toJs( label.appendChild(title) obj { this.label = label - this.action = { e: Event -> + this.action = { e: dev.kilua.dom.api.events.Event -> e.stopPropagation() if (it.isVisible()) { it.hide() @@ -839,7 +836,7 @@ internal fun ColumnDefinition.toJs( label.appendChild(icon) label.appendChild(title) this.label = label - this.action = { e: Event -> + this.action = { e: dev.kilua.dom.api.events.Event -> e.stopPropagation() resetColumns() } @@ -1056,7 +1053,7 @@ public data class TabulatorOptions( val scrollToRowPosition: RowPosition? = null, val scrollToRowIfVisible: Boolean? = null, val index: String? = null, - val data: JsArray? = null, + val data: dev.kilua.dom.JsArray? = null, val ajaxURL: String? = null, val ajaxParams: JsAny? = null, val ajaxConfig: JsAny? = null, @@ -1150,7 +1147,7 @@ public data class TabulatorOptions( val headerSortClickElement: HeaderSortClickElement? = null, val rowDblClickPopup: JsAny? = null, val rowDblClickMenu: JsAny? = null, - val responsiveLayoutCollapseFormatter: ((data: JsArray) -> Element)? = null, + val responsiveLayoutCollapseFormatter: ((data: dev.kilua.dom.JsArray) -> Element)? = null, val selectableRange: JsAny? = null, val selectableRangeColumns: Boolean? = null, val selectableRangeRows: Boolean? = null, diff --git a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/tabulator/Tabulator.kt b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/tabulator/Tabulator.kt index 6c7853f9d..1766876e3 100644 --- a/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/tabulator/Tabulator.kt +++ b/modules/kilua-tabulator/src/commonMain/kotlin/dev/kilua/tabulator/Tabulator.kt @@ -50,14 +50,13 @@ import kotlinx.serialization.json.Json import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.modules.overwriteWith import kotlinx.serialization.serializer -import web.JsAny -import web.JsArray -import web.JsNumber -import web.dom.HTMLDivElement -import web.toInt -import web.toJsBoolean -import web.toJsNumber -import web.window +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsNumber +import dev.kilua.dom.api.HTMLDivElement +import dev.kilua.dom.toInt +import dev.kilua.dom.toJsBoolean +import dev.kilua.dom.toJsNumber +import dev.kilua.dom.window import kotlin.reflect.KClass /** @@ -159,7 +158,7 @@ public open class Tabulator( /** * The internal data model. */ - protected var internalData: JsArray? = null + protected var internalData: dev.kilua.dom.JsArray? = null /** * The current page size. @@ -323,7 +322,7 @@ public open class Tabulator( /** * Converts a list of Kotlin data models to an internal (dynamic) data model array */ - protected open fun toPlainObjList(data: List): JsArray { + protected open fun toPlainObjList(data: List): dev.kilua.dom.JsArray { return if (kClass != null) { if (jsonHelper == null || serializer == null) { throw IllegalStateException("The data class can't be deserialized. Please provide a serializer when creating the Tabulator component.") diff --git a/modules/kilua-tabulator/src/jsMain/kotlin/dev/kilua/externals/Interop.js.kt b/modules/kilua-tabulator/src/jsMain/kotlin/dev/kilua/externals/Interop.js.kt index f62a3970e..a42d7a9a1 100644 --- a/modules/kilua-tabulator/src/jsMain/kotlin/dev/kilua/externals/Interop.js.kt +++ b/modules/kilua-tabulator/src/jsMain/kotlin/dev/kilua/externals/Interop.js.kt @@ -22,12 +22,10 @@ package dev.kilua.externals -import web.JsAny -import web.JsArray -import web.JsNumber -import web.Promise -import web.dom.Element -import web.dom.events.Event +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsNumber +import dev.kilua.dom.Promise +import dev.kilua.dom.api.Element internal actual fun toJsAny(f: (JsAny, JsAny, RowComponent, RowComponent, ColumnComponent, String, JsAny?) -> JsNumber): JsAny = f.unsafeCast() @@ -68,8 +66,8 @@ internal actual fun toJsAny(f: (String, JsAny) -> Boolean): JsAny = f.unsafeCast internal actual fun toJsAny(f: (String, JsAny, JsAny) -> JsAny): JsAny = f.unsafeCast() -internal actual fun toJsAny(f: (JsArray) -> Element): JsAny = f.unsafeCast() +internal actual fun toJsAny(f: (dev.kilua.dom.JsArray) -> Element): JsAny = f.unsafeCast() internal actual fun toJsAny(f: (JsAny) -> Boolean): JsAny = f.unsafeCast() -internal actual fun toJsAny(f: (Event) -> JsArray): JsAny = f.unsafeCast() +internal actual fun toJsAny(f: (dev.kilua.dom.api.events.Event) -> dev.kilua.dom.JsArray): JsAny = f.unsafeCast() diff --git a/modules/kilua-tabulator/src/wasmJsMain/kotlin/dev/kilua/externals/Interop.wasmJs.kt b/modules/kilua-tabulator/src/wasmJsMain/kotlin/dev/kilua/externals/Interop.wasmJs.kt index ad8938200..c3312daee 100644 --- a/modules/kilua-tabulator/src/wasmJsMain/kotlin/dev/kilua/externals/Interop.wasmJs.kt +++ b/modules/kilua-tabulator/src/wasmJsMain/kotlin/dev/kilua/externals/Interop.wasmJs.kt @@ -22,11 +22,10 @@ package dev.kilua.externals -import web.JsAny -import web.JsArray -import web.Promise -import web.dom.Element -import web.dom.events.Event +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsArray +import dev.kilua.dom.Promise +import dev.kilua.dom.api.Element internal actual fun toJsAny(f: (JsAny, JsAny, RowComponent, RowComponent, ColumnComponent, String, JsAny?) -> JsNumber): JsAny = js("f") @@ -71,4 +70,4 @@ internal actual fun toJsAny(f: (JsArray) -> Element): JsAny = js("f") internal actual fun toJsAny(f: (JsAny) -> Boolean): JsAny = js("f") -internal actual fun toJsAny(f: (Event) -> JsArray): JsAny = js("f") +internal actual fun toJsAny(f: (dev.kilua.dom.api.events.Event) -> JsArray): JsAny = js("f") diff --git a/modules/kilua-tailwindcss/src/commonMain/kotlin/dev/kilua/TailwindcssModule.kt b/modules/kilua-tailwindcss/src/commonMain/kotlin/dev/kilua/TailwindcssModule.kt index 7d22f0239..e9e52ab1b 100644 --- a/modules/kilua-tailwindcss/src/commonMain/kotlin/dev/kilua/TailwindcssModule.kt +++ b/modules/kilua-tailwindcss/src/commonMain/kotlin/dev/kilua/TailwindcssModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("./tailwind/tailwind.twcss") internal external object TailwindcssCss : JsAny diff --git a/modules/kilua-tailwindcss/src/commonMain/kotlin/dev/kilua/theme/ThemeManager.kt b/modules/kilua-tailwindcss/src/commonMain/kotlin/dev/kilua/theme/ThemeManager.kt index 4fb29df74..5a317f7f0 100644 --- a/modules/kilua-tailwindcss/src/commonMain/kotlin/dev/kilua/theme/ThemeManager.kt +++ b/modules/kilua-tailwindcss/src/commonMain/kotlin/dev/kilua/theme/ThemeManager.kt @@ -25,10 +25,10 @@ package dev.kilua.theme import dev.kilua.externals.buildCustomEventInit import dev.kilua.utils.isDom import dev.kilua.utils.toKebabCase -import web.document -import web.dom.CustomEvent -import web.localStorage -import web.window +import dev.kilua.dom.document +import dev.kilua.dom.api.CustomEvent +import dev.kilua.dom.localStorage +import dev.kilua.dom.window /** * Tailwindcss color themes. diff --git a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/TempusDominusModule.kt b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/TempusDominusModule.kt index 949080359..9e9cab214 100644 --- a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/TempusDominusModule.kt +++ b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/TempusDominusModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("@eonasdan/tempus-dominus/dist/css/tempus-dominus.min.css") internal external object TempusDominusCss : JsAny diff --git a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/externals/Date.kt b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/externals/Date.kt index e918b40cd..d7f7afcfc 100644 --- a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/externals/Date.kt +++ b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/externals/Date.kt @@ -33,10 +33,10 @@ import kotlinx.datetime.atDate import kotlinx.datetime.atStartOfDayIn import kotlinx.datetime.toInstant import kotlinx.datetime.toLocalDateTime -import web.JsAny -import web.JsNumber -import web.toDouble -import web.toJsNumber +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsNumber +import dev.kilua.dom.toDouble +import dev.kilua.dom.toJsNumber /** * JavaScript Date class. diff --git a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/externals/Locales.kt b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/externals/Locales.kt index 84f52601d..72bd8b848 100644 --- a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/externals/Locales.kt +++ b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/externals/Locales.kt @@ -25,7 +25,7 @@ package dev.kilua.externals import dev.kilua.JsModule import dev.kilua.utils.nativeMapOf -import web.JsAny +import dev.kilua.dom.JsAny /** * Tempus Dominus Locale. diff --git a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/externals/TempusDominus.kt b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/externals/TempusDominus.kt index e053d05c1..669b23bb3 100644 --- a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/externals/TempusDominus.kt +++ b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/externals/TempusDominus.kt @@ -25,10 +25,9 @@ package dev.kilua.externals import dev.kilua.JsModule -import web.JsAny -import web.JsArray -import web.JsNumber -import web.dom.HTMLElement +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsNumber +import dev.kilua.dom.api.HTMLElement /** * Tempus Dominus restrictions configuration. @@ -36,9 +35,9 @@ import web.dom.HTMLElement public external class TempusDominusRestrictions : JsAny { public var minDate: Date public var maxDate: Date - public var disabledDates: JsArray - public var enabledDates: JsArray - public var daysOfWeekDisabled: JsArray + public var disabledDates: dev.kilua.dom.JsArray + public var enabledDates: dev.kilua.dom.JsArray + public var daysOfWeekDisabled: dev.kilua.dom.JsArray } /** diff --git a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/AbstractRichDateTime.kt b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/AbstractRichDateTime.kt index b0c29fc67..21ca5ce85 100644 --- a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/AbstractRichDateTime.kt +++ b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/AbstractRichDateTime.kt @@ -40,15 +40,13 @@ import dev.kilua.html.i import dev.kilua.html.span import dev.kilua.i18n.Locale import dev.kilua.i18n.LocaleManager -import dev.kilua.utils.isDom import dev.kilua.utils.jsObjectOf import dev.kilua.utils.toJsArray import dev.kilua.utils.toKebabCase import kotlinx.datetime.LocalDate -import web.document -import web.dom.events.Event -import web.toJsNumber -import web.toJsString +import dev.kilua.dom.document +import dev.kilua.dom.toJsNumber +import dev.kilua.dom.toJsString import kotlin.time.Duration /** @@ -593,7 +591,7 @@ public abstract class AbstractRichDateTime( /** * The refresh callback used by the theme change event handler. */ - protected var refreshCallback: (Event) -> Unit = { + protected var refreshCallback: (dev.kilua.dom.api.events.Event) -> Unit = { refresh() } diff --git a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/RichDate.kt b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/RichDate.kt index 0620f5cbb..344251e57 100644 --- a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/RichDate.kt +++ b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/RichDate.kt @@ -42,7 +42,6 @@ import dev.kilua.state.WithStateFlowDelegateImpl import dev.kilua.utils.rem import dev.kilua.utils.unsafeCast import kotlinx.datetime.LocalDate -import web.dom.events.Event /** * Tempus Dominus rich date component. @@ -84,13 +83,13 @@ public open class RichDate( @Suppress("LeakingThis") withStateFlowDelegate.formControl(this) @Suppress("LeakingThis") - onEventDirect("change.td") { + onEventDirect("change.td") { val date = it["detail"]?.get("date")?.unsafeCast() this.value = date?.toLocalDate() dispatchEvent("change", buildCustomEventInit(obj())) } @Suppress("LeakingThis") - onEventDirect("error.td") { + onEventDirect("error.td") { this.value = null dispatchEvent("change", buildCustomEventInit(obj())) } diff --git a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/RichDateTime.kt b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/RichDateTime.kt index 972c43cc9..83cc29c1d 100644 --- a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/RichDateTime.kt +++ b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/RichDateTime.kt @@ -42,7 +42,6 @@ import dev.kilua.state.WithStateFlowDelegateImpl import dev.kilua.utils.rem import dev.kilua.utils.unsafeCast import kotlinx.datetime.LocalDateTime -import web.dom.events.Event /** * Tempus Dominus rich date time component. @@ -85,13 +84,13 @@ public open class RichDateTime( @Suppress("LeakingThis") withStateFlowDelegate.formControl(this) @Suppress("LeakingThis") - onEventDirect("change.td") { + onEventDirect("change.td") { val date = it["detail"]?.get("date")?.unsafeCast() this.value = date?.toLocalDateTime() dispatchEvent("change", buildCustomEventInit(obj())) } @Suppress("LeakingThis") - onEventDirect("error.td") { + onEventDirect("error.td") { this.value = null dispatchEvent("change", buildCustomEventInit(obj())) } diff --git a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/RichTime.kt b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/RichTime.kt index b5bce32b9..7e35698ae 100644 --- a/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/RichTime.kt +++ b/modules/kilua-tempus-dominus/src/commonMain/kotlin/dev/kilua/form/time/RichTime.kt @@ -42,7 +42,6 @@ import dev.kilua.state.WithStateFlowDelegateImpl import dev.kilua.utils.rem import dev.kilua.utils.unsafeCast import kotlinx.datetime.LocalTime -import web.dom.events.Event /** * Tempus Dominus rich time component. @@ -84,13 +83,13 @@ public open class RichTime( @Suppress("LeakingThis") withStateFlowDelegate.formControl(this) @Suppress("LeakingThis") - onEventDirect("change.td") { + onEventDirect("change.td") { val date = it["detail"]?.get("date")?.unsafeCast() this.value = date?.toLocalTime() dispatchEvent("change", buildCustomEventInit(obj())) } @Suppress("LeakingThis") - onEventDirect("error.td") { + onEventDirect("error.td") { this.value = null dispatchEvent("change", buildCustomEventInit(obj())) } diff --git a/modules/kilua-testutils/build.gradle.kts b/modules/kilua-testutils/build.gradle.kts index 513dbf139..c936e410d 100644 --- a/modules/kilua-testutils/build.gradle.kts +++ b/modules/kilua-testutils/build.gradle.kts @@ -1,3 +1,7 @@ +@file:OptIn(ExperimentalWasmDsl::class) + +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl + plugins { kotlin("multiplatform") alias(libs.plugins.detekt) @@ -18,22 +22,29 @@ kotlin { compilerOptions() kotlinJsTargets() kotlinWasmTargets() + kotlinJvmTargets() + kotlinJsCommonTargets() sourceSets { - val commonMain by getting { + commonMain { dependencies { implementation(libs.kotlinx.coroutines) implementation(project(":kilua")) implementation(kotlin("test")) implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) + } + } + jsCommonMain { + dependencies { + implementation(project(":modules:kilua-dom")) implementation(npm("html-differ", libs.versions.html.differ.get())) } } - val jsMain by getting { + jsMain { dependencies { } } - val wasmJsMain by getting { + wasmJsMain { dependencies { } } diff --git a/modules/kilua-testutils/src/commonMain/kotlin/dev/kilua/test/HtmlDiffer.kt b/modules/kilua-testutils/src/webMain/kotlin/dev/kilua/test/HtmlDiffer.kt similarity index 98% rename from modules/kilua-testutils/src/commonMain/kotlin/dev/kilua/test/HtmlDiffer.kt rename to modules/kilua-testutils/src/webMain/kotlin/dev/kilua/test/HtmlDiffer.kt index 44cd2e5b0..d3b090c52 100644 --- a/modules/kilua-testutils/src/commonMain/kotlin/dev/kilua/test/HtmlDiffer.kt +++ b/modules/kilua-testutils/src/webMain/kotlin/dev/kilua/test/HtmlDiffer.kt @@ -25,7 +25,7 @@ package dev.kilua.test import dev.kilua.JsModule -import web.JsAny +import dev.kilua.dom.JsAny @Suppress("UnusedPrivateProperty") public external class HtmlDiffer(preset: String) : JsAny { diff --git a/modules/kilua-testutils/src/commonMain/kotlin/dev/kilua/test/TestUtil.kt b/modules/kilua-testutils/src/webMain/kotlin/dev/kilua/test/TestUtil.kt similarity index 98% rename from modules/kilua-testutils/src/commonMain/kotlin/dev/kilua/test/TestUtil.kt rename to modules/kilua-testutils/src/webMain/kotlin/dev/kilua/test/TestUtil.kt index 428760cc8..7b45687d9 100644 --- a/modules/kilua-testutils/src/commonMain/kotlin/dev/kilua/test/TestUtil.kt +++ b/modules/kilua-testutils/src/webMain/kotlin/dev/kilua/test/TestUtil.kt @@ -30,9 +30,9 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.async -import web.JsAny -import web.Promise -import web.document +import dev.kilua.dom.JsAny +import dev.kilua.dom.Promise +import dev.kilua.dom.document import kotlin.test.DefaultAsserter.assertTrue public val testScope: CoroutineScope = CoroutineScope(Dispatchers.Default + SupervisorJob()) diff --git a/modules/kilua-toastify/src/commonMain/kotlin/dev/kilua/ToastifyModule.kt b/modules/kilua-toastify/src/commonMain/kotlin/dev/kilua/ToastifyModule.kt index 89ef4aa8f..07f96ef5f 100644 --- a/modules/kilua-toastify/src/commonMain/kotlin/dev/kilua/ToastifyModule.kt +++ b/modules/kilua-toastify/src/commonMain/kotlin/dev/kilua/ToastifyModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("toastify-js/src/toastify.css") internal external object ToastifyCss : JsAny diff --git a/modules/kilua-toastify/src/commonMain/kotlin/dev/kilua/externals/Toastify.kt b/modules/kilua-toastify/src/commonMain/kotlin/dev/kilua/externals/Toastify.kt index 48795e257..f7e443d34 100644 --- a/modules/kilua-toastify/src/commonMain/kotlin/dev/kilua/externals/Toastify.kt +++ b/modules/kilua-toastify/src/commonMain/kotlin/dev/kilua/externals/Toastify.kt @@ -24,7 +24,7 @@ package dev.kilua.externals import dev.kilua.JsModule -import web.JsAny +import dev.kilua.dom.JsAny public external class ToastOptions : JsAny { public var text: String? diff --git a/modules/kilua-tom-select-remote/src/commonMain/kotlin/dev/kilua/form/select/TomSelectRemote.kt b/modules/kilua-tom-select-remote/src/commonMain/kotlin/dev/kilua/form/select/TomSelectRemote.kt index 168a764bf..09be1b14b 100644 --- a/modules/kilua-tom-select-remote/src/commonMain/kotlin/dev/kilua/form/select/TomSelectRemote.kt +++ b/modules/kilua-tom-select-remote/src/commonMain/kotlin/dev/kilua/form/select/TomSelectRemote.kt @@ -42,9 +42,8 @@ import dev.kilua.utils.rem import dev.kilua.utils.toJsArray import dev.kilua.utils.unsafeCast import kotlinx.coroutines.launch -import web.JsAny -import web.JsArray -import web.fetch.RequestInit +import dev.kilua.dom.JsAny +import dev.kilua.dom.fetch.RequestInit internal external class RemoteOptionExt : JsAny { var value: String? @@ -373,7 +372,7 @@ public fun IComponent.tomSelectRemoteRef( lateinit var tomSelectRemote: TomSelectRemote val tsCallbacksState: TomSelectCallbacks = remember(tsCallbacks, preload, openOnFocus) { - val loadCallback: ((query: String, callback: (JsArray) -> Unit) -> Unit)? = if (!preload) { + val loadCallback: ((query: String, callback: (dev.kilua.dom.JsArray) -> Unit) -> Unit)? = if (!preload) { { query, callback -> tomSelectRemote.tomSelectInstance?.clearOptions { true } KiluaScope.launch { @@ -496,7 +495,7 @@ public fun IComponent.tomSelectRemote( lateinit var tomSelectRemote: TomSelectRemote val tsCallbacksState: TomSelectCallbacks = remember(tsCallbacks, preload, openOnFocus) { - val loadCallback: ((query: String, callback: (JsArray) -> Unit) -> Unit)? = if (!preload) { + val loadCallback: ((query: String, callback: (dev.kilua.dom.JsArray) -> Unit) -> Unit)? = if (!preload) { { query, callback -> tomSelectRemote.tomSelectInstance?.clearOptions { true } KiluaScope.launch { diff --git a/modules/kilua-tom-select-remote/src/commonMain/kotlin/dev/kilua/form/text/TomTypeaheadRemote.kt b/modules/kilua-tom-select-remote/src/commonMain/kotlin/dev/kilua/form/text/TomTypeaheadRemote.kt index 5b19f09d5..2523b46af 100644 --- a/modules/kilua-tom-select-remote/src/commonMain/kotlin/dev/kilua/form/text/TomTypeaheadRemote.kt +++ b/modules/kilua-tom-select-remote/src/commonMain/kotlin/dev/kilua/form/text/TomTypeaheadRemote.kt @@ -31,10 +31,9 @@ import dev.kilua.form.select.TomSelectCallbacks import dev.kilua.rpc.RpcServiceMgr import dev.kilua.utils.toJsArray import kotlinx.coroutines.launch -import web.JsAny -import web.JsArray -import web.fetch.RequestInit -import web.toJsString +import dev.kilua.dom.JsAny +import dev.kilua.dom.fetch.RequestInit +import dev.kilua.dom.toJsString /** * Creates [TomTypeahead] component with a remote data source, returning a reference. @@ -76,7 +75,7 @@ public fun IComponent.tomTypeaheadRemoteRef( ): TomTypeahead { val tsCallbacksState: TomSelectCallbacks = remember(tsCallbacks) { - val loadCallback: ((query: String, callback: (JsArray) -> Unit) -> Unit) = + val loadCallback: ((query: String, callback: (dev.kilua.dom.JsArray) -> Unit) -> Unit) = { query, callback -> KiluaScope.launch { val result = getOptionsForTomTypeaheadRemote( @@ -145,7 +144,7 @@ public fun IComponent.tomTypeaheadRemote( ) { val tsCallbacksState: TomSelectCallbacks = remember(tsCallbacks) { - val loadCallback: ((query: String, callback: (JsArray) -> Unit) -> Unit) = + val loadCallback: ((query: String, callback: (dev.kilua.dom.JsArray) -> Unit) -> Unit) = { query, callback -> KiluaScope.launch { val result = getOptionsForTomTypeaheadRemote( diff --git a/modules/kilua-tom-select-remote/src/jsMain/kotlin/dev/kilua/form/select/TomSelectRemote.js.kt b/modules/kilua-tom-select-remote/src/jsMain/kotlin/dev/kilua/form/select/TomSelectRemote.js.kt index a001f082e..33859c5fd 100644 --- a/modules/kilua-tom-select-remote/src/jsMain/kotlin/dev/kilua/form/select/TomSelectRemote.js.kt +++ b/modules/kilua-tom-select-remote/src/jsMain/kotlin/dev/kilua/form/select/TomSelectRemote.js.kt @@ -30,7 +30,7 @@ import dev.kilua.rpc.RpcSerialization import dev.kilua.rpc.RpcServiceMgr import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.encodeToString -import web.fetch.RequestInit +import dev.kilua.dom.fetch.RequestInit internal actual suspend fun getOptionsForTomSelectRemote( serviceManager: RpcServiceMgr, diff --git a/modules/kilua-tom-select-remote/src/jsMain/kotlin/dev/kilua/form/text/TomTypeaheadRemote.js.kt b/modules/kilua-tom-select-remote/src/jsMain/kotlin/dev/kilua/form/text/TomTypeaheadRemote.js.kt index bb6a3f057..ab2264e23 100644 --- a/modules/kilua-tom-select-remote/src/jsMain/kotlin/dev/kilua/form/text/TomTypeaheadRemote.js.kt +++ b/modules/kilua-tom-select-remote/src/jsMain/kotlin/dev/kilua/form/text/TomTypeaheadRemote.js.kt @@ -29,7 +29,7 @@ import dev.kilua.rpc.RpcServiceMgr import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.serializer import kotlinx.serialization.encodeToString -import web.fetch.RequestInit +import dev.kilua.dom.fetch.RequestInit internal actual suspend fun getOptionsForTomTypeaheadRemote( serviceManager: RpcServiceMgr, diff --git a/modules/kilua-tom-select-remote/src/wasmJsMain/kotlin/dev/kilua/form/select/TomSelectRemote.wasmJs.kt b/modules/kilua-tom-select-remote/src/wasmJsMain/kotlin/dev/kilua/form/select/TomSelectRemote.wasmJs.kt index a2c6aad93..3a693ce89 100644 --- a/modules/kilua-tom-select-remote/src/wasmJsMain/kotlin/dev/kilua/form/select/TomSelectRemote.wasmJs.kt +++ b/modules/kilua-tom-select-remote/src/wasmJsMain/kotlin/dev/kilua/form/select/TomSelectRemote.wasmJs.kt @@ -34,8 +34,8 @@ import dev.kilua.rpc.RpcSerialization import dev.kilua.rpc.RpcServiceMgr import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.encodeToString -import web.fetch.RequestInit -import web.toJsString +import dev.kilua.dom.fetch.RequestInit +import dev.kilua.dom.toJsString internal actual suspend fun getOptionsForTomSelectRemote( serviceManager: RpcServiceMgr, diff --git a/modules/kilua-tom-select-remote/src/wasmJsMain/kotlin/dev/kilua/form/text/TomTypeaheadRemote.wasmJs.kt b/modules/kilua-tom-select-remote/src/wasmJsMain/kotlin/dev/kilua/form/text/TomTypeaheadRemote.wasmJs.kt index 2414e98f6..26006f31d 100644 --- a/modules/kilua-tom-select-remote/src/wasmJsMain/kotlin/dev/kilua/form/text/TomTypeaheadRemote.wasmJs.kt +++ b/modules/kilua-tom-select-remote/src/wasmJsMain/kotlin/dev/kilua/form/text/TomTypeaheadRemote.wasmJs.kt @@ -32,8 +32,8 @@ import dev.kilua.rpc.RpcServiceMgr import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.serializer import kotlinx.serialization.encodeToString -import web.fetch.RequestInit -import web.toJsString +import dev.kilua.dom.fetch.RequestInit +import dev.kilua.dom.toJsString internal actual suspend fun getOptionsForTomTypeaheadRemote( serviceManager: RpcServiceMgr, diff --git a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/TomSelectDefaultModule.kt b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/TomSelectDefaultModule.kt index 7b00e86cb..7e4dd0b1f 100644 --- a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/TomSelectDefaultModule.kt +++ b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/TomSelectDefaultModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("tom-select/dist/css/tom-select.default.min.css") internal external object TomSelectDefaultCss : JsAny diff --git a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/TomSelectMinModule.kt b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/TomSelectMinModule.kt index 8023b6c81..e30eed58a 100644 --- a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/TomSelectMinModule.kt +++ b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/TomSelectMinModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("tom-select/dist/css/tom-select.min.css") internal external object TomSelectMinCss : JsAny diff --git a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/TomSelectModule.kt b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/TomSelectModule.kt index 438349b84..01e8ec926 100644 --- a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/TomSelectModule.kt +++ b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/TomSelectModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("tom-select/dist/css/tom-select.bootstrap5.min.css") internal external object TomSelectCss : JsAny diff --git a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/externals/TomSelectJs.kt b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/externals/TomSelectJs.kt index db87ed8f7..bf6745011 100644 --- a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/externals/TomSelectJs.kt +++ b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/externals/TomSelectJs.kt @@ -25,10 +25,9 @@ package dev.kilua.externals import dev.kilua.JsModule import dev.kilua.JsName -import web.JsAny -import web.JsArray -import web.JsString -import web.dom.HTMLElement +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsString +import dev.kilua.dom.api.HTMLElement /** * Tom Select renders configuration. @@ -49,7 +48,7 @@ public external class TomSelectRendersJs : JsAny { * Tom Select callbacks configuration. */ public external class TomSelectCallbacksJs : JsAny { - public var load: ((query: String, callback: (JsArray) -> Unit) -> Unit) + public var load: ((query: String, callback: (dev.kilua.dom.JsArray) -> Unit) -> Unit) public var shouldLoad: ((query: String) -> Boolean) public var score: ((search: String) -> (JsAny) -> Int) public var onInitialize: (() -> Unit) @@ -82,10 +81,10 @@ public external class TomSelectOptionsJs : JsAny { public var maxItems: Int? public var maxOptions: Int? public var allowEmptyOption: Boolean - public var options: JsArray + public var options: dev.kilua.dom.JsArray public var controlInput: HTMLElement? public var plugins: JsAny - public var load: ((query: String, callback: (JsArray) -> Unit) -> Unit) + public var load: ((query: String, callback: (dev.kilua.dom.JsArray) -> Unit) -> Unit) public var render: TomSelectRendersJs public var hideSelected: Boolean public var closeAfterSelect: Boolean @@ -111,7 +110,7 @@ public external class TomSelectOptionsJs : JsAny { public var labelField: String public var disabledField: String public var sortField: String - public var searchField: JsArray + public var searchField: dev.kilua.dom.JsArray public var searchConjunction: String public var onOptionAdd: ((value: String, data: JsAny) -> Unit) public var onOptionRemove: ((value: JsAny) -> Unit) @@ -126,7 +125,7 @@ public external class TomSelectOptionsJs : JsAny { @JsName("TomSelect") public external class TomSelectJs(element: HTMLElement, options: TomSelectOptionsJs) : JsAny { public fun addOption(value: JsAny, userCreated: Boolean) - public fun addOptions(value: JsArray, userCreated: Boolean) + public fun addOptions(value: dev.kilua.dom.JsArray, userCreated: Boolean) public fun updateOption(value: String, data: JsAny) public fun removeOption(value: String) public fun getOption(value: String, create: Boolean): JsAny? diff --git a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelect.kt b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelect.kt index 45d51d598..33d3d41ae 100644 --- a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelect.kt +++ b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelect.kt @@ -46,13 +46,12 @@ import dev.kilua.utils.rem import dev.kilua.utils.toJsAny import dev.kilua.utils.toList import dev.kilua.utils.unsafeCast -import web.JsAny -import web.JsArray -import web.JsString -import web.dom.HTMLOptionElement -import web.dom.HTMLSelectElement -import web.dom.asList -import web.toJsString +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsString +import dev.kilua.dom.api.HTMLOptionElement +import dev.kilua.dom.api.HTMLSelectElement +import dev.kilua.dom.api.asList +import dev.kilua.dom.toJsString /** * Tom Select component. @@ -483,7 +482,7 @@ public open class TomSelect( @Suppress("LeakingThis") onChangeDirect { val v = if (this.multiple) { - tomSelectInstance?.getValue()?.unsafeCast>()?.toList()?.joinToString(",") + tomSelectInstance?.getValue()?.unsafeCast>()?.toList()?.joinToString(",") } else { tomSelectInstance?.getValue()?.unsafeCast().toString() } @@ -580,7 +579,7 @@ public open class TomSelect( val callbacksObj = self.tsCallbacks!!.toJs() assign(this, callbacksObj) if (self.tsCallbacks!!.load != null) { - this.load = { query: String, callback: (JsArray) -> Unit -> + this.load = { query: String, callback: (dev.kilua.dom.JsArray) -> Unit -> tsCallbacks!!.load!!(query) { options -> if (emptyOption) { callback( diff --git a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelectCallbacks.kt b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelectCallbacks.kt index b338326c7..a1e9aa6b2 100644 --- a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelectCallbacks.kt +++ b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelectCallbacks.kt @@ -24,14 +24,13 @@ package dev.kilua.form.select import dev.kilua.externals.TomSelectCallbacksJs import dev.kilua.externals.obj -import web.JsAny -import web.JsArray +import dev.kilua.dom.JsAny /** * Tom Select callback functions. */ public data class TomSelectCallbacks( - val load: ((query: String, callback: (JsArray) -> Unit) -> Unit)? = null, + val load: ((query: String, callback: (dev.kilua.dom.JsArray) -> Unit) -> Unit)? = null, val shouldLoad: ((query: String) -> Boolean)? = null, val score: ((search: String) -> (JsAny) -> Int)? = null, val onInitialize: (() -> Unit)? = null, diff --git a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelectOptions.kt b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelectOptions.kt index c9f7066dd..89a9bc4be 100644 --- a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelectOptions.kt +++ b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelectOptions.kt @@ -28,10 +28,10 @@ import dev.kilua.utils.StringPair import dev.kilua.utils.cast import dev.kilua.utils.jsObjectOf import dev.kilua.utils.toJsAny -import web.JsAny -import web.dom.HTMLElement -import web.toJsBoolean -import web.toJsString +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.HTMLElement +import dev.kilua.dom.toJsBoolean +import dev.kilua.dom.toJsString /** * Tom Select options. diff --git a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelectRenders.kt b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelectRenders.kt index 7df5811bb..fe65fd7e9 100644 --- a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelectRenders.kt +++ b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/select/TomSelectRenders.kt @@ -24,7 +24,7 @@ package dev.kilua.form.select import dev.kilua.externals.TomSelectRendersJs import dev.kilua.externals.obj -import web.JsAny +import dev.kilua.dom.JsAny /** * Tom Select rendering options. diff --git a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/text/TomTypeahead.kt b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/text/TomTypeahead.kt index 27a6316d1..e0464c18f 100644 --- a/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/text/TomTypeahead.kt +++ b/modules/kilua-tom-select/src/commonMain/kotlin/dev/kilua/form/text/TomTypeahead.kt @@ -44,12 +44,11 @@ import dev.kilua.utils.toJsAny import dev.kilua.utils.toJsArray import dev.kilua.utils.toList import dev.kilua.utils.unsafeCast -import web.JsAny -import web.JsArray -import web.JsBoolean -import web.JsString -import web.toBoolean -import web.toJsString +import dev.kilua.dom.JsAny +import dev.kilua.dom.JsBoolean +import dev.kilua.dom.JsString +import dev.kilua.dom.toBoolean +import dev.kilua.dom.toJsString /** * Tom Typeahead input component @@ -266,7 +265,7 @@ public open class TomTypeahead( val callbacksObj = self.tsCallbacks!!.toJs() assign(this, callbacksObj) if (self.tsCallbacks!!.load != null) { - this.load = { query: String, callback: (JsArray) -> Unit -> + this.load = { query: String, callback: (dev.kilua.dom.JsArray) -> Unit -> tsCallbacks!!.load!!(query) { options -> callback( options.toList().map { diff --git a/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/TrixModule.kt b/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/TrixModule.kt index d771aab73..714ef143a 100644 --- a/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/TrixModule.kt +++ b/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/TrixModule.kt @@ -23,7 +23,7 @@ package dev.kilua -import web.JsAny +import dev.kilua.dom.JsAny @JsModule("trix/dist/trix.css") internal external object TrixCss : JsAny diff --git a/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/externals/Editor.kt b/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/externals/Editor.kt index a855e503f..d62416517 100644 --- a/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/externals/Editor.kt +++ b/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/externals/Editor.kt @@ -23,8 +23,8 @@ package dev.kilua.externals -import web.JsAny -import web.dom.Element +import dev.kilua.dom.JsAny +import dev.kilua.dom.api.Element /** * Internal Editor class. diff --git a/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/externals/TrixLocale.kt b/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/externals/TrixLocale.kt index 55f41c3e4..d332b2e22 100644 --- a/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/externals/TrixLocale.kt +++ b/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/externals/TrixLocale.kt @@ -23,7 +23,7 @@ package dev.kilua.externals -import web.JsAny +import dev.kilua.dom.JsAny /** * Trix editor locale strings. diff --git a/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/form/text/RichText.kt b/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/form/text/RichText.kt index 5c964b100..824b279fb 100644 --- a/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/form/text/RichText.kt +++ b/modules/kilua-trix/src/commonMain/kotlin/dev/kilua/form/text/RichText.kt @@ -46,12 +46,11 @@ import dev.kilua.state.WithStateFlow import dev.kilua.state.WithStateFlowDelegate import dev.kilua.state.WithStateFlowDelegateImpl import dev.kilua.utils.unsafeCast -import web.clear -import web.dom.HTMLButtonElement -import web.dom.HTMLElement -import web.dom.HTMLInputElement -import web.dom.asList -import web.dom.events.Event +import dev.kilua.dom.clear +import dev.kilua.dom.api.HTMLButtonElement +import dev.kilua.dom.api.HTMLElement +import dev.kilua.dom.api.HTMLInputElement +import dev.kilua.dom.api.asList /** * Trix rich text editor component. @@ -317,14 +316,14 @@ public open class RichText( element.setAttribute("required", "") } @Suppress("LeakingThis") - onEventDirect("trix-initialize") { + onEventDirect("trix-initialize") { if (disabled == true) { element.removeAttribute("contenteditable") toolbarDisable(true) } } @Suppress("LeakingThis") - onEventDirect("trix-change") { + onEventDirect("trix-change") { input?.let { SafeDomFactory.getElementById(it) }?.let { val elementValue = it.unsafeCast().value setInternalValueFromString(elementValue) @@ -332,7 +331,7 @@ public open class RichText( } } @Suppress("LeakingThis") - onEventDirect("trix-file-accept") { e -> if (!allowFileUploads) e.preventDefault() } + onEventDirect("trix-file-accept") { e -> if (!allowFileUploads) e.preventDefault() } } @Suppress("LeakingThis") role = "textbox" diff --git a/modules/kilua-trix/src/jsMain/kotlin/dev/kilua/externals/Editor.js.kt b/modules/kilua-trix/src/jsMain/kotlin/dev/kilua/externals/Editor.js.kt index 4374d7b04..35ad554e3 100644 --- a/modules/kilua-trix/src/jsMain/kotlin/dev/kilua/externals/Editor.js.kt +++ b/modules/kilua-trix/src/jsMain/kotlin/dev/kilua/externals/Editor.js.kt @@ -22,7 +22,7 @@ package dev.kilua.externals -import web.dom.Element +import dev.kilua.dom.api.Element internal actual fun getEditorFromElement(element: Element): Editor? { @Suppress("UnsafeCastFromDynamic") diff --git a/modules/kilua-trix/src/jsMain/kotlin/dev/kilua/externals/Trix.js.kt b/modules/kilua-trix/src/jsMain/kotlin/dev/kilua/externals/Trix.js.kt index f7bb385a0..5a1145fbe 100644 --- a/modules/kilua-trix/src/jsMain/kotlin/dev/kilua/externals/Trix.js.kt +++ b/modules/kilua-trix/src/jsMain/kotlin/dev/kilua/externals/Trix.js.kt @@ -23,7 +23,7 @@ package dev.kilua.externals -import web.JsAny +import dev.kilua.dom.JsAny /** * Native JS Trix toolbar object. diff --git a/modules/kilua-trix/src/wasmJsMain/kotlin/dev/kilua/externals/Editor.wasmJs.kt b/modules/kilua-trix/src/wasmJsMain/kotlin/dev/kilua/externals/Editor.wasmJs.kt index 48dc4aabc..c0be91fae 100644 --- a/modules/kilua-trix/src/wasmJsMain/kotlin/dev/kilua/externals/Editor.wasmJs.kt +++ b/modules/kilua-trix/src/wasmJsMain/kotlin/dev/kilua/externals/Editor.wasmJs.kt @@ -22,7 +22,7 @@ package dev.kilua.externals -import web.dom.Element +import dev.kilua.dom.api.Element /** * Internal Element class with editor property. diff --git a/modules/kilua-trix/src/wasmJsMain/kotlin/dev/kilua/externals/Trix.wasmJs.kt b/modules/kilua-trix/src/wasmJsMain/kotlin/dev/kilua/externals/Trix.wasmJs.kt index faf0072cf..325c9daab 100644 --- a/modules/kilua-trix/src/wasmJsMain/kotlin/dev/kilua/externals/Trix.wasmJs.kt +++ b/modules/kilua-trix/src/wasmJsMain/kotlin/dev/kilua/externals/Trix.wasmJs.kt @@ -24,7 +24,7 @@ package dev.kilua.externals -import web.JsAny +import dev.kilua.dom.JsAny /** * Native JS Trix toolbar object. diff --git a/plugins/kilua-ksp-processor/src/jvmMain/kotlin/dev/kilua/ksp/KiluaProcessor.kt b/plugins/kilua-ksp-processor/src/jvmMain/kotlin/dev/kilua/ksp/KiluaProcessor.kt index f0aae77cb..cc2678c57 100644 --- a/plugins/kilua-ksp-processor/src/jvmMain/kotlin/dev/kilua/ksp/KiluaProcessor.kt +++ b/plugins/kilua-ksp-processor/src/jvmMain/kotlin/dev/kilua/ksp/KiluaProcessor.kt @@ -119,7 +119,7 @@ public class KiluaProcessor( appendLine("import dev.kilua.core.IComponent") appendLine("import dev.kilua.core.RenderConfig") appendLine("import dev.kilua.html.Tag") - appendLine("import web.dom.$typeArgName") + appendLine("import dev.kilua.dom.api.$typeArgName") appendLine() appendLine("/**") appendLine(" * HTML $className component.") diff --git a/settings.gradle.kts b/settings.gradle.kts index 00bdbfa59..60be9600c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -23,6 +23,7 @@ include(":modules:kilua-bootstrap-icons") include(":modules:kilua-common-types") include(":modules:kilua-core-modules") include(":modules:kilua-dom") +include(":modules:kilua-dom-core") include(":modules:kilua-fontawesome") include(":modules:kilua-i18n") include(":modules:kilua-imask")