cyberia 3.2.5 → 3.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/engine-cyberia.cd.yml +8 -2
- package/.github/workflows/npmpkg.ci.yml +1 -0
- package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
- package/.github/workflows/release.cd.yml +2 -2
- package/.vscode/extensions.json +9 -9
- package/.vscode/settings.json +20 -4
- package/CHANGELOG.md +563 -1
- package/CLI-HELP.md +130 -34
- package/Dockerfile +0 -4
- package/README.md +194 -607
- package/bin/build.js +42 -12
- package/bin/build.template.js +187 -0
- package/bin/cyberia.js +1367 -281
- package/bin/deploy.js +582 -3
- package/bin/index.js +1367 -281
- package/bump.config.js +26 -0
- package/conf.js +195 -111
- package/deployment.yaml +6 -222
- package/hardhat/package-lock.json +118 -149
- package/hardhat/package.json +5 -4
- package/jsconfig.json +1 -1
- package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +2 -2
- package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +2 -2
- package/manifests/deployment/dd-cyberia-development/deployment.yaml +6 -222
- package/manifests/deployment/dd-cyberia-development/proxy.yaml +10 -118
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -6
- package/manifests/deployment/dd-test-development/deployment.yaml +138 -66
- package/manifests/deployment/dd-test-development/proxy.yaml +41 -5
- package/manifests/kind-config-dev.yaml +8 -0
- package/manifests/lxd/lxd-admin-profile.yaml +12 -3
- package/manifests/mongodb/pv-pvc.yaml +44 -8
- package/manifests/mongodb/statefulset.yaml +55 -68
- package/manifests/mongodb-4.4/headless-service.yaml +10 -0
- package/manifests/mongodb-4.4/kustomization.yaml +3 -1
- package/manifests/mongodb-4.4/mongodb-nodeport.yaml +17 -0
- package/manifests/mongodb-4.4/pv-pvc.yaml +10 -14
- package/manifests/mongodb-4.4/statefulset.yaml +79 -0
- package/manifests/mongodb-4.4/storage-class.yaml +9 -0
- package/manifests/valkey/statefulset.yaml +1 -1
- package/manifests/valkey/valkey-nodeport.yaml +17 -0
- package/package.json +45 -24
- package/proxy.yaml +10 -118
- package/scripts/ipxe-setup.sh +52 -49
- package/scripts/k3s-node-setup.sh +83 -48
- package/scripts/lxd-vm-setup.sh +193 -8
- package/scripts/maas-nat-firewalld.sh +145 -0
- package/scripts/nat-iptables.sh +103 -18
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.controller.js +18 -18
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.model.js +7 -14
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.router.js +38 -33
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.service.js +91 -36
- package/src/api/core/core.controller.js +10 -10
- package/src/api/core/core.router.js +19 -14
- package/src/api/core/core.service.js +15 -15
- package/src/api/crypto/crypto.controller.js +8 -8
- package/src/api/crypto/crypto.router.js +18 -12
- package/src/api/crypto/crypto.service.js +11 -11
- package/src/api/cyberia-action/cyberia-action.controller.js +74 -0
- package/src/api/cyberia-action/cyberia-action.model.js +87 -0
- package/src/api/cyberia-action/cyberia-action.router.js +31 -0
- package/src/api/cyberia-action/cyberia-action.service.js +42 -0
- package/src/api/cyberia-client-hints/cyberia-client-hints.controller.js +74 -0
- package/src/api/cyberia-client-hints/cyberia-client-hints.model.js +99 -0
- package/src/api/cyberia-client-hints/cyberia-client-hints.router.js +98 -0
- package/src/api/cyberia-client-hints/cyberia-client-hints.service.js +152 -0
- package/src/api/cyberia-dialogue/cyberia-dialogue.controller.js +13 -13
- package/src/api/cyberia-dialogue/cyberia-dialogue.model.js +11 -11
- package/src/api/cyberia-dialogue/cyberia-dialogue.router.js +25 -20
- package/src/api/cyberia-dialogue/cyberia-dialogue.service.js +22 -22
- package/src/api/cyberia-entity/cyberia-entity.controller.js +10 -10
- package/src/api/cyberia-entity/cyberia-entity.router.js +22 -18
- package/src/api/cyberia-entity/cyberia-entity.service.js +15 -15
- package/src/api/cyberia-instance/cyberia-fallback-world.js +83 -198
- package/src/api/cyberia-instance/cyberia-instance.controller.js +14 -14
- package/src/api/cyberia-instance/cyberia-instance.model.js +3 -0
- package/src/api/cyberia-instance/cyberia-instance.router.js +57 -52
- package/src/api/cyberia-instance/cyberia-instance.service.js +32 -67
- package/src/api/cyberia-instance/cyberia-portal-connector.js +20 -246
- package/src/api/cyberia-instance/cyberia-world-generator.js +505 -0
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.controller.js +10 -10
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.model.js +18 -49
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.router.js +22 -18
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.service.js +19 -15
- package/src/api/cyberia-map/cyberia-map.controller.js +10 -10
- package/src/api/cyberia-map/cyberia-map.router.js +35 -30
- package/src/api/cyberia-map/cyberia-map.service.js +17 -17
- package/src/api/cyberia-quest/cyberia-quest.controller.js +74 -0
- package/src/api/cyberia-quest/cyberia-quest.model.js +67 -0
- package/src/api/cyberia-quest/cyberia-quest.router.js +31 -0
- package/src/api/cyberia-quest/cyberia-quest.service.js +42 -0
- package/src/api/cyberia-quest-progress/cyberia-quest-progress.controller.js +74 -0
- package/src/api/cyberia-quest-progress/cyberia-quest-progress.model.js +49 -0
- package/src/api/cyberia-quest-progress/cyberia-quest-progress.router.js +31 -0
- package/src/api/cyberia-quest-progress/cyberia-quest-progress.service.js +42 -0
- package/src/api/cyberia-server-defaults/cyberia-server-defaults.js +451 -0
- package/src/api/default/default.controller.js +10 -10
- package/src/api/default/default.router.js +22 -18
- package/src/api/default/default.service.js +15 -15
- package/src/api/document/document.controller.js +12 -12
- package/src/api/document/document.model.js +10 -16
- package/src/api/document/document.router.js +28 -23
- package/src/api/document/document.service.js +100 -23
- package/src/api/file/file.controller.js +8 -8
- package/src/api/file/file.model.js +10 -10
- package/src/api/file/file.router.js +19 -13
- package/src/api/file/file.service.js +45 -43
- package/src/api/instance/instance.controller.js +10 -10
- package/src/api/instance/instance.model.js +4 -10
- package/src/api/instance/instance.router.js +29 -24
- package/src/api/instance/instance.service.js +16 -16
- package/src/api/ipfs/ipfs.controller.js +12 -12
- package/src/api/ipfs/ipfs.model.js +4 -13
- package/src/api/ipfs/ipfs.router.js +21 -16
- package/src/api/ipfs/ipfs.service.js +22 -36
- package/src/api/object-layer/object-layer.controller.js +12 -12
- package/src/api/object-layer/object-layer.model.js +4 -17
- package/src/api/object-layer/object-layer.router.js +512 -507
- package/src/api/object-layer/object-layer.service.js +29 -26
- package/src/api/object-layer-render-frames/object-layer-render-frames.controller.js +10 -10
- package/src/api/object-layer-render-frames/object-layer-render-frames.model.js +6 -16
- package/src/api/object-layer-render-frames/object-layer-render-frames.router.js +22 -18
- package/src/api/object-layer-render-frames/object-layer-render-frames.service.js +19 -15
- package/src/api/test/test.controller.js +8 -8
- package/src/api/test/test.router.js +17 -12
- package/src/api/test/test.service.js +8 -8
- package/src/api/types.js +24 -0
- package/src/api/user/guest.service.js +100 -0
- package/src/api/user/user.controller.js +6 -6
- package/src/api/user/user.model.js +8 -13
- package/src/api/user/user.router.js +297 -288
- package/src/api/user/user.service.js +103 -55
- package/src/cli/baremetal.js +132 -101
- package/src/cli/cluster.js +732 -217
- package/src/cli/db.js +106 -62
- package/src/cli/deploy.js +260 -149
- package/src/cli/fs.js +90 -9
- package/src/cli/image.js +43 -1
- package/src/cli/index.js +106 -16
- package/src/cli/ipfs.js +4 -6
- package/src/cli/kubectl.js +4 -1
- package/src/cli/lxd.js +1099 -223
- package/src/cli/monitor.js +9 -3
- package/src/cli/release.js +336 -86
- package/src/cli/repository.js +136 -53
- package/src/cli/run.js +599 -76
- package/src/cli/secrets.js +11 -2
- package/src/cli/ssh.js +1 -1
- package/src/cli/static.js +43 -115
- package/src/cli/test.js +9 -3
- package/src/client/Cryptokoyn.index.js +18 -21
- package/src/client/CyberiaPortal.index.js +19 -23
- package/src/client/Default.index.js +30 -36
- package/src/client/Itemledger.index.js +20 -26
- package/src/client/Underpost.index.js +19 -23
- package/src/client/components/core/404.js +4 -4
- package/src/client/components/core/500.js +4 -4
- package/src/client/components/core/Account.js +73 -60
- package/src/client/components/core/AgGrid.js +23 -33
- package/src/client/components/core/Alert.js +12 -13
- package/src/client/components/core/AppStore.js +1 -1
- package/src/client/components/core/Auth.js +40 -37
- package/src/client/components/core/Badge.js +7 -13
- package/src/client/components/core/BtnIcon.js +15 -17
- package/src/client/components/core/CalendarCore.js +42 -63
- package/src/client/components/core/Chat.js +13 -15
- package/src/client/components/core/ClientEvents.js +163 -0
- package/src/client/components/core/ColorPaletteElement.js +309 -0
- package/src/client/components/core/Content.js +17 -14
- package/src/client/components/core/Css.js +15 -71
- package/src/client/components/core/CssCore.js +12 -16
- package/src/client/components/core/D3Chart.js +4 -4
- package/src/client/components/core/Docs.js +64 -91
- package/src/client/components/core/DropDown.js +69 -91
- package/src/client/components/core/EventBus.js +96 -0
- package/src/client/components/core/EventsUI.js +14 -17
- package/src/client/components/core/FileExplorer.js +96 -228
- package/src/client/components/core/FullScreen.js +47 -75
- package/src/client/components/core/Input.js +24 -69
- package/src/client/components/core/Keyboard.js +25 -18
- package/src/client/components/core/KeyboardAvoidance.js +145 -0
- package/src/client/components/core/LoadingAnimation.js +25 -31
- package/src/client/components/core/LogIn.js +41 -41
- package/src/client/components/core/LogOut.js +23 -14
- package/src/client/components/core/Modal.js +544 -219
- package/src/client/components/core/NotificationManager.js +14 -18
- package/src/client/components/core/Panel.js +54 -50
- package/src/client/components/core/PanelForm.js +81 -177
- package/src/client/components/core/Polyhedron.js +110 -214
- package/src/client/components/core/PublicProfile.js +39 -32
- package/src/client/components/core/Recover.js +48 -44
- package/src/client/components/core/Responsive.js +88 -32
- package/src/client/components/core/RichText.js +9 -18
- package/src/client/components/core/Router.js +24 -3
- package/src/client/components/core/SearchBox.js +37 -37
- package/src/client/components/core/SignUp.js +39 -30
- package/src/client/components/core/SocketIo.js +31 -2
- package/src/client/components/core/SocketIoHandler.js +6 -6
- package/src/client/components/core/ToggleSwitch.js +8 -20
- package/src/client/components/core/ToolTip.js +5 -17
- package/src/client/components/core/Translate.js +56 -59
- package/src/client/components/core/Validator.js +26 -16
- package/src/client/components/core/Wallet.js +15 -26
- package/src/client/components/core/Worker.js +211 -276
- package/src/client/components/core/windowGetDimensions.js +7 -7
- package/src/client/components/cryptokoyn/{MenuCryptokoyn.js → AppShellCryptokoyn.js} +57 -57
- package/src/client/components/cryptokoyn/CssCryptokoyn.js +15 -15
- package/src/client/components/cryptokoyn/LogInCryptokoyn.js +6 -4
- package/src/client/components/cryptokoyn/LogOutCryptokoyn.js +6 -4
- package/src/client/components/cryptokoyn/RouterCryptokoyn.js +37 -0
- package/src/client/components/cryptokoyn/SettingsCryptokoyn.js +4 -4
- package/src/client/components/cryptokoyn/SignUpCryptokoyn.js +6 -4
- package/src/client/components/cyberia/InstanceEngineCyberia.js +141 -60
- package/src/client/components/cyberia/MapEngineCyberia.js +691 -214
- package/src/client/components/cyberia/ObjectLayerEngine.js +19 -0
- package/src/client/components/cyberia/ObjectLayerEngineModal.js +1204 -94
- package/src/client/components/cyberia/ObjectLayerEngineViewer.js +196 -298
- package/src/client/components/cyberia/SharedDefaultsCyberia.js +330 -0
- package/src/client/components/cyberia-portal/{MenuCyberiaPortal.js → AppShellCyberiaPortal.js} +102 -102
- package/src/client/components/cyberia-portal/CssCyberiaPortal.js +15 -15
- package/src/client/components/cyberia-portal/LogInCyberiaPortal.js +6 -4
- package/src/client/components/cyberia-portal/LogOutCyberiaPortal.js +6 -4
- package/src/client/components/cyberia-portal/MainBodyCyberiaPortal.js +4 -4
- package/src/client/components/cyberia-portal/RouterCyberiaPortal.js +60 -0
- package/src/client/components/cyberia-portal/SettingsCyberiaPortal.js +4 -4
- package/src/client/components/cyberia-portal/SignUpCyberiaPortal.js +6 -4
- package/src/client/components/cyberia-portal/TranslateCyberiaPortal.js +4 -4
- package/src/client/components/default/{MenuDefault.js → AppShellDefault.js} +87 -87
- package/src/client/components/default/CssDefault.js +12 -12
- package/src/client/components/default/LogInDefault.js +6 -4
- package/src/client/components/default/LogOutDefault.js +6 -4
- package/src/client/components/default/RouterDefault.js +47 -0
- package/src/client/components/default/SettingsDefault.js +4 -4
- package/src/client/components/default/SignUpDefault.js +6 -4
- package/src/client/components/default/TranslateDefault.js +3 -3
- package/src/client/components/itemledger/{MenuItemledger.js → AppShellItemledger.js} +57 -57
- package/src/client/components/itemledger/CssItemledger.js +15 -15
- package/src/client/components/itemledger/LogInItemledger.js +6 -4
- package/src/client/components/itemledger/LogOutItemledger.js +6 -4
- package/src/client/components/itemledger/RouterItemledger.js +38 -0
- package/src/client/components/itemledger/SettingsItemledger.js +4 -4
- package/src/client/components/itemledger/SignUpItemledger.js +6 -4
- package/src/client/components/itemledger/TranslateItemledger.js +3 -3
- package/src/client/components/underpost/{MenuUnderpost.js → AppShellUnderpost.js} +88 -88
- package/src/client/components/underpost/CssUnderpost.js +14 -14
- package/src/client/components/underpost/CyberpunkBloggerUnderpost.js +4 -4
- package/src/client/components/underpost/DocumentSearchProvider.js +1 -1
- package/src/client/components/underpost/LabGalleryUnderpost.js +12 -15
- package/src/client/components/underpost/LogInUnderpost.js +6 -4
- package/src/client/components/underpost/LogOutUnderpost.js +6 -4
- package/src/client/components/underpost/RouterUnderpost.js +45 -0
- package/src/client/components/underpost/SettingsUnderpost.js +4 -4
- package/src/client/components/underpost/SignUpUnderpost.js +6 -4
- package/src/client/components/underpost/TranslateUnderpost.js +4 -4
- package/src/client/public/cyberia-docs/ACTION-SYSTEM.md +235 -0
- package/src/client/public/cyberia-docs/ARCHITECTURE.md +83 -0
- package/src/client/public/cyberia-docs/CYBERIA-CLI.md +204 -0
- package/src/client/public/cyberia-docs/CYBERIA-CLIENT.md +291 -0
- package/src/client/public/cyberia-docs/CYBERIA-SERVER.md +278 -0
- package/src/client/public/cyberia-docs/CYBERIA.md +259 -0
- package/src/client/public/cyberia-docs/ENTITY-PROFILE.md +241 -0
- package/src/client/public/cyberia-docs/HARDHAT-MODULE.md +300 -0
- package/src/client/public/cyberia-docs/OFF-CHAIN-ECONOMY.md +279 -0
- package/src/client/public/cyberia-docs/QUEST-SYSTEM.md +206 -0
- package/src/client/public/cyberia-docs/ROADMAP.md +240 -0
- package/src/client/public/cyberia-docs/UNDERPOST-PLATFORM.md +106 -0
- package/src/client/public/cyberia-docs/WHITE-PAPER.md +732 -0
- package/src/client/services/atlas-sprite-sheet/atlas-sprite-sheet.service.js +14 -20
- package/src/client/services/core/core.service.js +17 -49
- package/src/client/services/crypto/crypto.service.js +8 -13
- package/src/client/services/cyberia-action/cyberia-action.service.js +99 -0
- package/src/client/services/cyberia-client-hints/cyberia-client-hints.service.js +99 -0
- package/src/client/services/cyberia-dialogue/cyberia-dialogue.service.js +10 -16
- package/src/client/services/cyberia-entity/cyberia-entity.management.js +5 -5
- package/src/client/services/cyberia-entity/cyberia-entity.service.js +10 -16
- package/src/client/services/cyberia-instance/cyberia-instance.management.js +6 -6
- package/src/client/services/cyberia-instance/cyberia-instance.service.js +12 -18
- package/src/client/services/cyberia-instance-conf/cyberia-instance-conf.service.js +10 -16
- package/src/client/services/cyberia-map/cyberia-map.management.js +6 -6
- package/src/client/services/cyberia-map/cyberia-map.service.js +12 -18
- package/src/client/services/cyberia-quest/cyberia-quest.service.js +99 -0
- package/src/client/services/cyberia-quest-progress/cyberia-quest-progress.service.js +99 -0
- package/src/client/services/default/default.management.js +159 -267
- package/src/client/services/default/default.service.js +10 -16
- package/src/client/services/document/document.service.js +14 -19
- package/src/client/services/file/file.service.js +8 -13
- package/src/client/services/instance/instance.management.js +5 -5
- package/src/client/services/instance/instance.service.js +10 -15
- package/src/client/services/ipfs/ipfs.service.js +12 -18
- package/src/client/services/object-layer/object-layer.management.js +12 -12
- package/src/client/services/object-layer/object-layer.service.js +20 -26
- package/src/client/services/object-layer-render-frames/object-layer-render-frames.service.js +10 -16
- package/src/client/services/test/test.service.js +8 -13
- package/src/client/services/user/guest.service.js +86 -0
- package/src/client/services/user/user.management.js +5 -5
- package/src/client/services/user/user.service.js +14 -20
- package/src/client/ssr/body/404.js +3 -3
- package/src/client/ssr/body/500.js +3 -3
- package/src/client/ssr/body/CacheControl.js +5 -2
- package/src/client/ssr/body/DefaultSplashScreen.js +19 -12
- package/src/client/ssr/body/UnderpostDefaultSplashScreen.js +13 -6
- package/src/client/ssr/head/PwaItemledger.js +197 -60
- package/src/client/ssr/mailer/DefaultRecoverEmail.js +19 -20
- package/src/client/ssr/mailer/DefaultVerifyEmail.js +15 -16
- package/src/client/ssr/views/CyberiaServerMetrics.js +982 -0
- package/src/client/ssr/{offline → views}/Maintenance.js +12 -11
- package/src/client/ssr/{offline → views}/NoNetworkConnection.js +3 -3
- package/src/client/ssr/{pages → views}/Test.js +2 -2
- package/src/client/sw/core.sw.js +274 -0
- package/src/db/DataBaseProvider.js +115 -15
- package/src/db/mariadb/MariaDB.js +2 -1
- package/src/db/mongo/MongoBootstrap.js +657 -0
- package/src/db/mongo/MongooseDB.js +129 -21
- package/src/grpc/cyberia/grpc-server.js +185 -105
- package/src/index.js +1 -1
- package/src/runtime/cyberia-client/Dockerfile +101 -0
- package/src/runtime/cyberia-client/Dockerfile.dev +82 -0
- package/src/runtime/cyberia-server/Dockerfile +62 -0
- package/src/runtime/cyberia-server/Dockerfile.dev +71 -0
- package/src/runtime/express/Dockerfile +4 -4
- package/src/runtime/express/Express.js +2 -2
- package/src/runtime/lampp/Dockerfile +8 -7
- package/src/runtime/wp/Dockerfile +11 -17
- package/src/runtime/wp/Wp.js +8 -5
- package/src/server/atlas-sprite-sheet-generator.js +4 -2
- package/src/server/auth.js +2 -2
- package/src/server/client-build-docs.js +46 -47
- package/src/server/client-build.js +371 -132
- package/src/server/client-formatted.js +47 -16
- package/src/server/conf.js +91 -87
- package/src/server/data-query.js +32 -20
- package/src/server/dns.js +22 -0
- package/src/server/ipfs-client.js +232 -91
- package/src/server/object-layer.js +1 -6
- package/src/server/process.js +192 -45
- package/src/server/proxy.js +9 -2
- package/src/server/runtime.js +1 -1
- package/src/server/semantic-layer-generator-floor.js +11 -51
- package/src/server/semantic-layer-generator-resource.js +259 -0
- package/src/server/semantic-layer-generator-skin.js +41 -171
- package/src/server/semantic-layer-generator.js +122 -14
- package/src/server/shape-generator.js +108 -0
- package/src/server/start.js +34 -8
- package/src/server/valkey.js +143 -235
- package/src/ws/IoInterface.js +16 -16
- package/src/ws/core/channels/core.ws.chat.js +11 -11
- package/src/ws/core/channels/core.ws.mailer.js +29 -29
- package/src/ws/core/channels/core.ws.stream.js +19 -19
- package/src/ws/core/core.ws.connection.js +8 -8
- package/src/ws/core/core.ws.server.js +6 -5
- package/src/ws/default/channels/default.ws.main.js +10 -10
- package/src/ws/default/default.ws.connection.js +4 -4
- package/src/ws/default/default.ws.server.js +4 -3
- package/tsconfig.docs.json +15 -0
- package/typedoc.dd-cyberia.json +29 -0
- package/typedoc.json +29 -0
- package/WHITE-PAPER.md +0 -1540
- package/bin/file.js +0 -196
- package/bin/vs.js +0 -74
- package/bin/zed.js +0 -84
- package/hardhat/README.md +0 -531
- package/hardhat/WHITE-PAPER.md +0 -1540
- package/jsdoc.dd-cyberia.json +0 -68
- package/jsdoc.json +0 -68
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.defaults.js +0 -413
- package/src/api/object-layer/README.md +0 -672
- package/src/client/components/core/ColorPalette.js +0 -5267
- package/src/client/components/core/JoyStick.js +0 -80
- package/src/client/components/cryptokoyn/RoutesCryptokoyn.js +0 -39
- package/src/client/components/cyberia-portal/CommonCyberiaPortal.js +0 -223
- package/src/client/components/cyberia-portal/RoutesCyberiaPortal.js +0 -62
- package/src/client/components/cyberia-portal/ServerCyberiaPortal.js +0 -136
- package/src/client/components/default/RoutesDefault.js +0 -49
- package/src/client/components/itemledger/RoutesItemledger.js +0 -40
- package/src/client/components/underpost/RoutesUnderpost.js +0 -47
- package/src/client/ssr/email/DefaultRecoverEmail.js +0 -21
- package/src/client/ssr/email/DefaultVerifyEmail.js +0 -17
- package/src/client/ssr/pages/CyberiaServerMetrics.js +0 -461
- package/src/client/sw/default.sw.js +0 -127
- package/src/client/sw/template.sw.js +0 -84
- package/src/grpc/cyberia/OFF_CHAIN_ECONOMY.md +0 -305
- package/src/grpc/cyberia/README.md +0 -326
|
@@ -14,16 +14,12 @@ import { Scroll } from './Scroll.js';
|
|
|
14
14
|
import { LoadingAnimation } from './LoadingAnimation.js';
|
|
15
15
|
import { loggerFactory } from './Logger.js';
|
|
16
16
|
import { getApiBaseUrl } from '../../services/core/core.service.js';
|
|
17
|
-
|
|
18
17
|
const logger = loggerFactory(import.meta, { trace: true });
|
|
19
|
-
|
|
20
18
|
function sanitizeFilename(title, options = {}) {
|
|
21
19
|
const { replacement = '-', maxLength = 255, preserveExtension = true } = options;
|
|
22
|
-
|
|
23
20
|
if (typeof title !== 'string' || title.trim() === '') {
|
|
24
21
|
return 'untitled';
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
// 1) Extract extension (optional)
|
|
28
24
|
let name = title;
|
|
29
25
|
let ext = '';
|
|
@@ -34,43 +30,32 @@ function sanitizeFilename(title, options = {}) {
|
|
|
34
30
|
name = title.slice(0, -ext.length);
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
|
-
|
|
38
33
|
// 2) Normalize Unicode and remove diacritics
|
|
39
34
|
name = name.normalize('NFKD').replace(/[\u0300-\u036f]/g, '');
|
|
40
|
-
|
|
41
35
|
// 3) Remove control characters and null bytes
|
|
42
36
|
name = name.replace(/[\x00-\x1f\x7f]/g, '');
|
|
43
|
-
|
|
44
37
|
// 4) Remove forbidden filename characters (Windows / POSIX)
|
|
45
38
|
name = name.replace(/[<>:"/\\|?*\u0000]/g, '');
|
|
46
|
-
|
|
47
39
|
// 5) Collapse whitespace and replace with separator
|
|
48
40
|
name = name.replace(/\s+/g, replacement);
|
|
49
|
-
|
|
50
41
|
// 6) Collapse multiple separators
|
|
51
42
|
const escaped = replacement.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
52
43
|
name = name.replace(new RegExp(`${escaped}{2,}`, 'g'), replacement);
|
|
53
|
-
|
|
54
44
|
// 7) Trim dots and separators from edges
|
|
55
45
|
name = name.replace(new RegExp(`^[\\.${escaped}]+|[\\.${escaped}]+$`, 'g'), '');
|
|
56
|
-
|
|
57
46
|
// 8) Protect against Windows reserved names
|
|
58
47
|
if (/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(name)) {
|
|
59
48
|
name = '_' + name;
|
|
60
49
|
}
|
|
61
|
-
|
|
62
50
|
// 9) Enforce max length
|
|
63
51
|
const maxNameLength = Math.max(1, maxLength - ext.length);
|
|
64
52
|
if (name.length > maxNameLength) {
|
|
65
53
|
name = name.slice(0, maxNameLength);
|
|
66
54
|
}
|
|
67
|
-
|
|
68
55
|
// 10) Fallback
|
|
69
56
|
if (!name) name = 'untitled';
|
|
70
|
-
|
|
71
57
|
return name + ext;
|
|
72
58
|
}
|
|
73
|
-
|
|
74
59
|
const userInfoFactory = (userDoc) => ({
|
|
75
60
|
username: userDoc.userId.username,
|
|
76
61
|
email: userDoc.userId.email,
|
|
@@ -78,10 +63,9 @@ const userInfoFactory = (userDoc) => ({
|
|
|
78
63
|
profileImageId: userDoc.userId.profileImageId,
|
|
79
64
|
briefDescription: userDoc.userId.briefDescription,
|
|
80
65
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
instance: async function (
|
|
66
|
+
class PanelForm {
|
|
67
|
+
static Data = {};
|
|
68
|
+
static async instance(
|
|
85
69
|
options = {
|
|
86
70
|
idPanel: '',
|
|
87
71
|
defaultUrlImage: '',
|
|
@@ -89,7 +73,7 @@ const PanelForm = {
|
|
|
89
73
|
parentIdModal: undefined,
|
|
90
74
|
route: 'home',
|
|
91
75
|
htmlFormHeader: async () => '',
|
|
92
|
-
firsUpdateEvent: async () => {},
|
|
76
|
+
firsUpdateEvent: async () => { },
|
|
93
77
|
share: {
|
|
94
78
|
copyLink: false,
|
|
95
79
|
copySourceMd: false,
|
|
@@ -98,11 +82,10 @@ const PanelForm = {
|
|
|
98
82
|
},
|
|
99
83
|
) {
|
|
100
84
|
const { idPanel, defaultUrlImage, appStore } = options;
|
|
101
|
-
|
|
102
85
|
// Authenticated users don't need 'public' tag - they see all their own posts
|
|
103
86
|
// Only include 'public' for unauthenticated users (handled by backend)
|
|
104
87
|
let prefixTags = [idPanel];
|
|
105
|
-
|
|
88
|
+
PanelForm.Data[idPanel] = {
|
|
106
89
|
originData: [],
|
|
107
90
|
data: [],
|
|
108
91
|
filesData: [],
|
|
@@ -112,7 +95,6 @@ const PanelForm = {
|
|
|
112
95
|
loading: false,
|
|
113
96
|
lasIdAvailable: null,
|
|
114
97
|
};
|
|
115
|
-
|
|
116
98
|
const formData = [
|
|
117
99
|
{
|
|
118
100
|
id: 'panel-title',
|
|
@@ -163,10 +145,9 @@ const PanelForm = {
|
|
|
163
145
|
},
|
|
164
146
|
},
|
|
165
147
|
];
|
|
166
|
-
|
|
167
148
|
const titleIcon = html`<i class="fa-solid fa-quote-left title-icon-${idPanel}"></i>`;
|
|
168
149
|
const panelRender = async ({ data }) =>
|
|
169
|
-
await Panel.
|
|
150
|
+
await Panel.instance({
|
|
170
151
|
idPanel,
|
|
171
152
|
formData,
|
|
172
153
|
data,
|
|
@@ -193,10 +174,8 @@ const PanelForm = {
|
|
|
193
174
|
render: imageShimmer(),
|
|
194
175
|
});
|
|
195
176
|
}
|
|
196
|
-
|
|
197
177
|
// Get the filesData for this item
|
|
198
178
|
const filesDataItem = PanelForm.Data[idPanel].filesData.find((f) => f._id === options.data._id);
|
|
199
|
-
|
|
200
179
|
// Priority 1: Check if there's an actual file (not markdown content)
|
|
201
180
|
// fileId array defaults to [null] for batch upload logic
|
|
202
181
|
const fileBlob = filesDataItem?.fileId?.fileBlob;
|
|
@@ -210,7 +189,6 @@ const PanelForm = {
|
|
|
210
189
|
},
|
|
211
190
|
});
|
|
212
191
|
}
|
|
213
|
-
|
|
214
192
|
// Priority 2: If no actual file, show default image
|
|
215
193
|
// (Don't show markdown content in file area - mdFileId stays in content area)
|
|
216
194
|
return await options.htmlRender({
|
|
@@ -218,12 +196,12 @@ const PanelForm = {
|
|
|
218
196
|
<img
|
|
219
197
|
class="abs center"
|
|
220
198
|
style="${renderCssAttr({
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
199
|
+
style: {
|
|
200
|
+
width: '100px',
|
|
201
|
+
height: '100px',
|
|
202
|
+
opacity: 0.2,
|
|
203
|
+
},
|
|
204
|
+
})}"
|
|
227
205
|
src="${defaultUrlImage}"
|
|
228
206
|
/>
|
|
229
207
|
`,
|
|
@@ -236,7 +214,7 @@ const PanelForm = {
|
|
|
236
214
|
html: async () => {
|
|
237
215
|
return html`
|
|
238
216
|
<div class="in section-mp" style="text-align: center">
|
|
239
|
-
${Translate.
|
|
217
|
+
${Translate.instance('confirm-delete-item')}
|
|
240
218
|
<br />
|
|
241
219
|
"${data.title}"
|
|
242
220
|
</div>
|
|
@@ -252,29 +230,23 @@ const PanelForm = {
|
|
|
252
230
|
html: status,
|
|
253
231
|
status,
|
|
254
232
|
});
|
|
255
|
-
|
|
256
233
|
// Handle cid query param update (supports comma-separated list)
|
|
257
234
|
if (status === 'success') {
|
|
258
235
|
const currentCid = getQueryParams().cid;
|
|
259
|
-
|
|
260
236
|
if (currentCid) {
|
|
261
237
|
// Parse cid as comma-separated list
|
|
262
238
|
const cidList = currentCid
|
|
263
239
|
.split(',')
|
|
264
240
|
.map((id) => id.trim())
|
|
265
241
|
.filter((id) => id);
|
|
266
|
-
|
|
267
242
|
// Remove the deleted panel's id from the list
|
|
268
243
|
const updatedCidList = cidList.filter((id) => id !== data.id);
|
|
269
|
-
|
|
270
244
|
if (updatedCidList.length !== cidList.length) {
|
|
271
245
|
// Wait for DOM cleanup before updating query
|
|
272
|
-
|
|
273
246
|
if (updatedCidList.length === 0) {
|
|
274
247
|
// No cids remain, clear query and reload panels with limit
|
|
275
248
|
logger.warn('All cids removed, clearing query');
|
|
276
249
|
setQueryPath({ path: options.route, queryPath: '' });
|
|
277
|
-
|
|
278
250
|
if (options.parentIdModal) Modal.Data[options.parentIdModal].query = window.location.search;
|
|
279
251
|
if (PanelForm.Data[idPanel].updatePanel) await PanelForm.Data[idPanel].updatePanel();
|
|
280
252
|
} else {
|
|
@@ -285,41 +257,32 @@ const PanelForm = {
|
|
|
285
257
|
if (options.parentIdModal) Modal.Data[options.parentIdModal].query = actualQuery;
|
|
286
258
|
}
|
|
287
259
|
}
|
|
288
|
-
|
|
289
260
|
// Return early to skip smart deletion logic when cid is present
|
|
290
261
|
return { status };
|
|
291
262
|
}
|
|
292
263
|
}
|
|
293
|
-
|
|
294
264
|
// Smart deletion: remove from arrays and intelligently load more if needed
|
|
295
265
|
if (status === 'success') {
|
|
296
266
|
const panelData = PanelForm.Data[idPanel];
|
|
297
|
-
|
|
298
267
|
// Remove the deleted item from all data arrays
|
|
299
268
|
const indexInOrigin = panelData.originData.findIndex((d) => d._id === data._id);
|
|
300
269
|
const indexInData = panelData.data.findIndex((d) => d._id === data._id);
|
|
301
270
|
const indexInFiles = panelData.filesData.findIndex((d) => d._id === data._id);
|
|
302
|
-
|
|
303
271
|
if (indexInOrigin > -1) panelData.originData.splice(indexInOrigin, 1);
|
|
304
272
|
if (indexInData > -1) panelData.data.splice(indexInData, 1);
|
|
305
273
|
if (indexInFiles > -1) panelData.filesData.splice(indexInFiles, 1);
|
|
306
|
-
|
|
307
274
|
// Adjust skip count since we removed an item
|
|
308
275
|
if (panelData.skip > 0) panelData.skip--;
|
|
309
|
-
|
|
310
276
|
// If panels are below limit and there might be more, load them
|
|
311
277
|
if (panelData.data.length < panelData.limit && panelData.hasMore && !panelData.loading) {
|
|
312
278
|
const oldDataCount = panelData.data.length;
|
|
313
279
|
const needed = panelData.limit - panelData.data.length; // Calculate exact number needed
|
|
314
280
|
const originalLimit = panelData.limit;
|
|
315
|
-
|
|
316
281
|
// Temporarily set limit to only fetch what's needed (1-to-1 replacement)
|
|
317
282
|
panelData.limit = needed;
|
|
318
283
|
await getPanelData(true); // Load only the needed items
|
|
319
284
|
panelData.limit = originalLimit; // Restore original limit
|
|
320
|
-
|
|
321
285
|
const newItems = panelData.data.slice(oldDataCount);
|
|
322
|
-
|
|
323
286
|
if (oldDataCount === 0) {
|
|
324
287
|
// List was empty, render all panels
|
|
325
288
|
if (panelData.data.length > 0) {
|
|
@@ -331,7 +294,6 @@ const PanelForm = {
|
|
|
331
294
|
<div class="in panel-placeholder-bottom panel-placeholder-bottom-${idPanel}"></div>
|
|
332
295
|
`,
|
|
333
296
|
);
|
|
334
|
-
|
|
335
297
|
// Show spinner if there's potentially more data
|
|
336
298
|
const lastOriginItem = panelData.originData[panelData.originData.length - 1];
|
|
337
299
|
if (
|
|
@@ -360,7 +322,6 @@ const PanelForm = {
|
|
|
360
322
|
}
|
|
361
323
|
}
|
|
362
324
|
}
|
|
363
|
-
|
|
364
325
|
return { status };
|
|
365
326
|
}
|
|
366
327
|
return { status: 'error' };
|
|
@@ -371,16 +332,10 @@ const PanelForm = {
|
|
|
371
332
|
}, 50);
|
|
372
333
|
},
|
|
373
334
|
initEdit: async function ({ data }) {
|
|
374
|
-
//
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
s(`.${fileFormData.id}`).inputFiles = null;
|
|
379
|
-
htmls(
|
|
380
|
-
`.file-name-render-${fileFormData.id}`,
|
|
381
|
-
`<div class="abs center"><i style="font-size: 25px" class="fa-solid fa-cloud"></i></div>`,
|
|
382
|
-
);
|
|
383
|
-
}
|
|
335
|
+
// Do NOT clear the file input here - the file should remain as-is when entering edit mode.
|
|
336
|
+
// If user wants to remove the file, they use the "clean file" button.
|
|
337
|
+
// If user wants to replace the file, they select a new file.
|
|
338
|
+
// Unconditionally clearing the file here would cause the server to receive fileId: null on save.
|
|
384
339
|
setTimeout(() => {
|
|
385
340
|
s(`.modal-${options.route}`).scrollTo({ top: 0, behavior: 'smooth' });
|
|
386
341
|
}, 50);
|
|
@@ -392,33 +347,27 @@ const PanelForm = {
|
|
|
392
347
|
// Validate that either mdFileId has content OR fileId has files
|
|
393
348
|
const hasMdContent = data.mdFileId && data.mdFileId.trim().length > 0;
|
|
394
349
|
const hasFiles = data.fileId && data.fileId.length > 0;
|
|
395
|
-
|
|
396
350
|
if (!data.title || (!hasMdContent && !hasFiles)) {
|
|
397
351
|
NotificationManager.Push({
|
|
398
|
-
html: Translate.
|
|
352
|
+
html: Translate.instance('require-title-and-content-or-file'),
|
|
399
353
|
status: 'error',
|
|
400
354
|
});
|
|
401
355
|
return { data: [], status: 'error', message: 'Must provide either content or attach a file' };
|
|
402
356
|
}
|
|
403
|
-
|
|
404
357
|
// Sanitize title for filename - normalize UTF-8 string
|
|
405
358
|
// In browser, strings are already UTF-16, just ensure valid characters
|
|
406
359
|
const sanitizedTitle = sanitizeFilename(data.title);
|
|
407
|
-
|
|
408
360
|
let mdFileId;
|
|
409
361
|
const mdFileName = `${getCapVariableName(sanitizedTitle)}.md`;
|
|
410
362
|
const location = `${prefixTags.join('/')}`;
|
|
411
|
-
|
|
412
363
|
// Only create markdown file if there's actual content
|
|
413
364
|
let md = null;
|
|
414
365
|
let mdBlob = null;
|
|
415
366
|
let mdPlain = null;
|
|
416
|
-
|
|
417
367
|
if (hasMdContent) {
|
|
418
368
|
// Markdown content is already UTF-16 in browser, use as-is
|
|
419
369
|
const blob = new Blob([data.mdFileId], { type: 'text/markdown' });
|
|
420
370
|
md = new File([blob], mdFileName, { type: 'text/markdown' });
|
|
421
|
-
|
|
422
371
|
mdBlob = {
|
|
423
372
|
data: {
|
|
424
373
|
data: await getDataFromInputFile(md),
|
|
@@ -428,21 +377,20 @@ const PanelForm = {
|
|
|
428
377
|
};
|
|
429
378
|
mdPlain = await getRawContentFile(getBlobFromUint8ArrayFile(mdBlob.data.data, mdBlob.mimetype));
|
|
430
379
|
}
|
|
431
|
-
|
|
432
380
|
// Parse and normalize tags
|
|
433
381
|
// Note: 'public' tag is automatically extracted by the backend and converted to isPublic field
|
|
434
382
|
// It will be filtered from the tags array to keep visibility control separate from content tags
|
|
435
383
|
const tags = data.tags
|
|
436
384
|
? uniqueArray(
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
385
|
+
data.tags
|
|
386
|
+
.replaceAll('/', ',')
|
|
387
|
+
.replaceAll('-', ',')
|
|
388
|
+
.replaceAll(' ', ',')
|
|
389
|
+
.split(',')
|
|
390
|
+
.map((t) => t.trim())
|
|
391
|
+
.filter((t) => t)
|
|
392
|
+
.concat(prefixTags),
|
|
393
|
+
)
|
|
446
394
|
: prefixTags;
|
|
447
395
|
let originObj, originFileObj, indexOriginObj;
|
|
448
396
|
if (editId) {
|
|
@@ -452,14 +400,12 @@ const PanelForm = {
|
|
|
452
400
|
originFileObj = PanelForm.Data[idPanel].filesData.find((d) => d._id === editId);
|
|
453
401
|
}
|
|
454
402
|
}
|
|
455
|
-
|
|
456
403
|
const baseNewDoc = newInstance(data);
|
|
457
404
|
baseNewDoc.tags = tags.filter((t) => !prefixTags.includes(t));
|
|
458
405
|
baseNewDoc.mdFileId = hasMdContent
|
|
459
406
|
? `<div class="markdown-content">${marked.parse(data.mdFileId)}</div>`
|
|
460
407
|
: null;
|
|
461
408
|
baseNewDoc.userId = appStore.Data.user?.main?.model?.user?._id;
|
|
462
|
-
|
|
463
409
|
// Ensure profileImageId is properly formatted as object with _id property
|
|
464
410
|
const profileImageIdValue = appStore.Data.user?.main?.model?.user?.profileImageId;
|
|
465
411
|
const formattedProfileImageId = profileImageIdValue
|
|
@@ -467,7 +413,6 @@ const PanelForm = {
|
|
|
467
413
|
? { _id: profileImageIdValue }
|
|
468
414
|
: profileImageIdValue
|
|
469
415
|
: null;
|
|
470
|
-
|
|
471
416
|
baseNewDoc.userInfo = {
|
|
472
417
|
username: appStore.Data.user?.main?.model?.user?.username,
|
|
473
418
|
email: appStore.Data.user?.main?.model?.user?.email,
|
|
@@ -475,19 +420,25 @@ const PanelForm = {
|
|
|
475
420
|
profileImageId: formattedProfileImageId,
|
|
476
421
|
};
|
|
477
422
|
baseNewDoc.tools = true;
|
|
478
|
-
|
|
479
423
|
const documents = [];
|
|
480
424
|
let message = '';
|
|
481
425
|
let status = 'success';
|
|
482
426
|
let indexFormDoc = -1;
|
|
483
|
-
|
|
484
427
|
const inputFiles = data.fileId ? data.fileId : [null];
|
|
485
|
-
|
|
486
428
|
for (const file of inputFiles) {
|
|
487
429
|
indexFormDoc++;
|
|
488
430
|
let fileId = undefined; // Reset for each iteration - only set if user uploaded a file
|
|
489
|
-
|
|
431
|
+
// Track whether the file input was explicitly cleared (null) vs never had a file (undefined)
|
|
432
|
+
// In edit mode, null means user cleared the file - we need to tell server to remove it
|
|
433
|
+
const isFileCleared = data.fileId === null && editId;
|
|
490
434
|
await (async () => {
|
|
435
|
+
// When file is null and not the first iteration or not in edit mode, skip upload
|
|
436
|
+
if (!file && !isFileCleared) return;
|
|
437
|
+
// When user cleared file in edit mode, set fileId=null so server removes the reference
|
|
438
|
+
if (isFileCleared) {
|
|
439
|
+
fileId = null;
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
491
442
|
const body = new FormData();
|
|
492
443
|
// Only append md file if it was created (has content)
|
|
493
444
|
if (md) body.append('md', md);
|
|
@@ -495,7 +446,7 @@ const PanelForm = {
|
|
|
495
446
|
const { status, data: uploadedFiles } = await FileService.post({ body });
|
|
496
447
|
// await timer(3000);
|
|
497
448
|
NotificationManager.Push({
|
|
498
|
-
html: Translate.
|
|
449
|
+
html: Translate.instance(`${status}-upload-file`),
|
|
499
450
|
status,
|
|
500
451
|
});
|
|
501
452
|
if (status === 'success' && uploadedFiles && Array.isArray(uploadedFiles)) {
|
|
@@ -506,7 +457,6 @@ const PanelForm = {
|
|
|
506
457
|
// Both can be markdown files, but we must distinguish:
|
|
507
458
|
// Rich text editor content → mdFileId
|
|
508
459
|
// User-uploaded file → fileId
|
|
509
|
-
|
|
510
460
|
for (const uploadedFile of uploadedFiles) {
|
|
511
461
|
if (hasMdContent && uploadedFile.name === mdFileName) {
|
|
512
462
|
// This is the markdown file created FROM rich text editor
|
|
@@ -518,7 +468,6 @@ const PanelForm = {
|
|
|
518
468
|
logger.info(`Assigned user-uploaded file to fileId: ${uploadedFile.name}`);
|
|
519
469
|
}
|
|
520
470
|
}
|
|
521
|
-
|
|
522
471
|
// Validation: mdFileId should exist only if rich text content was provided
|
|
523
472
|
if (hasMdContent && !mdFileId) {
|
|
524
473
|
logger.error(
|
|
@@ -540,11 +489,10 @@ const PanelForm = {
|
|
|
540
489
|
message: documentMessage,
|
|
541
490
|
data: documentData,
|
|
542
491
|
} = originObj && indexFormDoc === 0
|
|
543
|
-
|
|
544
|
-
|
|
492
|
+
? await DocumentService.put({ id: originObj._id, body })
|
|
493
|
+
: await DocumentService.post({
|
|
545
494
|
body,
|
|
546
495
|
});
|
|
547
|
-
|
|
548
496
|
const newDoc = {
|
|
549
497
|
...baseNewDoc,
|
|
550
498
|
fileId: file ? URL.createObjectURL(file) : undefined,
|
|
@@ -561,10 +509,8 @@ const PanelForm = {
|
|
|
561
509
|
? userInfoFactory(documentData)
|
|
562
510
|
: null),
|
|
563
511
|
};
|
|
564
|
-
|
|
565
512
|
if (documentStatus === 'error') status = 'error';
|
|
566
513
|
if (message) message += `${indexFormDoc === 0 ? '' : ', '}${documentMessage}`;
|
|
567
|
-
|
|
568
514
|
const filesData = {
|
|
569
515
|
id: documentData._id,
|
|
570
516
|
_id: documentData._id,
|
|
@@ -572,17 +518,16 @@ const PanelForm = {
|
|
|
572
518
|
fileId: {
|
|
573
519
|
fileBlob: file
|
|
574
520
|
? {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
521
|
+
data: {
|
|
522
|
+
data: await getDataFromInputFile(file),
|
|
523
|
+
},
|
|
524
|
+
mimetype: file.type,
|
|
525
|
+
name: file.name,
|
|
526
|
+
}
|
|
581
527
|
: undefined,
|
|
582
528
|
filePlain: undefined,
|
|
583
529
|
},
|
|
584
530
|
};
|
|
585
|
-
|
|
586
531
|
if (originObj && indexFormDoc === 0) {
|
|
587
532
|
PanelForm.Data[idPanel].originData[indexOriginObj] = documentData;
|
|
588
533
|
PanelForm.Data[idPanel].data[indexOriginObj] = newDoc;
|
|
@@ -594,31 +539,26 @@ const PanelForm = {
|
|
|
594
539
|
}
|
|
595
540
|
documents.push(newDoc);
|
|
596
541
|
}
|
|
597
|
-
|
|
598
542
|
NotificationManager.Push({
|
|
599
543
|
html:
|
|
600
544
|
status === 'success'
|
|
601
545
|
? originObj
|
|
602
|
-
? Translate.
|
|
603
|
-
: Translate.
|
|
546
|
+
? Translate.instance('success-edit-post')
|
|
547
|
+
: Translate.instance('success-add-post')
|
|
604
548
|
: message,
|
|
605
549
|
status: status,
|
|
606
550
|
});
|
|
607
|
-
|
|
608
551
|
setQueryPath({ path: options.route, queryPath: documents.map((d) => d._id).join(',') });
|
|
609
552
|
if (options.parentIdModal) Modal.Data[options.parentIdModal].query = `${window.location.search}`;
|
|
610
|
-
|
|
611
553
|
return { data: documents, status, message };
|
|
612
554
|
},
|
|
613
555
|
},
|
|
614
556
|
});
|
|
615
|
-
|
|
616
557
|
const getPanelData = async (isLoadMore = false) => {
|
|
617
558
|
const panelData = PanelForm.Data[idPanel];
|
|
618
559
|
logger.warn('getPanelData called, isLoadMore:', isLoadMore);
|
|
619
560
|
try {
|
|
620
561
|
const cidQuery = getQueryParams().cid;
|
|
621
|
-
|
|
622
562
|
// When cid query exists, bypass pagination and loading checks
|
|
623
563
|
if (!cidQuery) {
|
|
624
564
|
if (panelData.loading || !panelData.hasMore) {
|
|
@@ -626,48 +566,39 @@ const PanelForm = {
|
|
|
626
566
|
return;
|
|
627
567
|
}
|
|
628
568
|
}
|
|
629
|
-
|
|
630
569
|
panelData.loading = true;
|
|
631
|
-
|
|
632
570
|
if (!isLoadMore) {
|
|
633
571
|
// Reset for a fresh load
|
|
634
572
|
panelData.skip = 0;
|
|
635
573
|
panelData.hasMore = true;
|
|
636
574
|
}
|
|
637
|
-
|
|
638
575
|
// When cid query exists, don't apply skip/limit pagination
|
|
639
576
|
const params = {
|
|
640
577
|
tags: prefixTags.join(','),
|
|
641
578
|
...(cidQuery && { cid: cidQuery }),
|
|
642
579
|
};
|
|
643
|
-
|
|
644
580
|
// Only apply pagination when there's no cid query
|
|
645
581
|
if (!cidQuery) {
|
|
646
582
|
params.skip = panelData.skip;
|
|
647
583
|
params.limit = panelData.limit;
|
|
648
584
|
}
|
|
649
|
-
|
|
650
585
|
const result = await DocumentService.get({
|
|
651
586
|
params,
|
|
652
587
|
id: 'public/',
|
|
653
588
|
});
|
|
654
|
-
|
|
655
589
|
if (result.status === 'success') {
|
|
656
590
|
if (!isLoadMore) {
|
|
657
591
|
panelData.originData = [];
|
|
658
592
|
panelData.filesData = [];
|
|
659
593
|
panelData.data = [];
|
|
660
594
|
}
|
|
661
|
-
|
|
662
595
|
panelData.originData.push(...newInstance(result.data.data));
|
|
663
596
|
panelData.lasIdAvailable = result.data.lastId;
|
|
664
|
-
|
|
665
597
|
for (const documentObject of result.data.data) {
|
|
666
598
|
let mdFileId, fileId;
|
|
667
599
|
let mdBlob, fileBlob;
|
|
668
600
|
let mdPlain, filePlain;
|
|
669
601
|
let parsedMarkdown = '';
|
|
670
|
-
|
|
671
602
|
try {
|
|
672
603
|
// Fetch markdown content if mdFileId exists
|
|
673
604
|
if (documentObject.mdFileId) {
|
|
@@ -693,7 +624,6 @@ const PanelForm = {
|
|
|
693
624
|
parsedMarkdown = '';
|
|
694
625
|
}
|
|
695
626
|
}
|
|
696
|
-
|
|
697
627
|
// Handle optional fileId
|
|
698
628
|
if (documentObject.fileId) {
|
|
699
629
|
const fileIdValue = documentObject.fileId._id || documentObject.fileId;
|
|
@@ -708,7 +638,6 @@ const PanelForm = {
|
|
|
708
638
|
logger.error('Error fetching file metadata:', fileIdValue, fetchError);
|
|
709
639
|
}
|
|
710
640
|
}
|
|
711
|
-
|
|
712
641
|
// Store file metadata and references
|
|
713
642
|
panelData.filesData.push({
|
|
714
643
|
id: documentObject._id,
|
|
@@ -716,7 +645,6 @@ const PanelForm = {
|
|
|
716
645
|
mdFileId: { mdBlob, mdPlain },
|
|
717
646
|
fileId: { fileBlob, filePlain },
|
|
718
647
|
});
|
|
719
|
-
|
|
720
648
|
// Add to data array for display - use pre-parsed markdown
|
|
721
649
|
panelData.data.push({
|
|
722
650
|
id: documentObject._id,
|
|
@@ -753,7 +681,6 @@ const PanelForm = {
|
|
|
753
681
|
mdFileId: { mdBlob: null, mdPlain: '' },
|
|
754
682
|
fileId: { fileBlob: null, filePlain: undefined },
|
|
755
683
|
});
|
|
756
|
-
|
|
757
684
|
panelData.data.push({
|
|
758
685
|
id: documentObject._id,
|
|
759
686
|
title: documentObject.title,
|
|
@@ -780,7 +707,6 @@ const PanelForm = {
|
|
|
780
707
|
});
|
|
781
708
|
}
|
|
782
709
|
}
|
|
783
|
-
|
|
784
710
|
// Only update pagination when not using cid query
|
|
785
711
|
if (!cidQuery) {
|
|
786
712
|
panelData.skip += result.data.data.length;
|
|
@@ -789,7 +715,6 @@ const PanelForm = {
|
|
|
789
715
|
// When cid query is used, disable infinite scroll
|
|
790
716
|
panelData.hasMore = false;
|
|
791
717
|
}
|
|
792
|
-
|
|
793
718
|
const lastItem = result.data.data[result.data.data.length - 1];
|
|
794
719
|
if (result.data.data.length === 0 || (lastItem && lastItem._id === panelData.lasIdAvailable)) {
|
|
795
720
|
LoadingAnimation.spinner.stop(`.panel-placeholder-bottom-${idPanel}`);
|
|
@@ -805,7 +730,6 @@ const PanelForm = {
|
|
|
805
730
|
} catch (error) {
|
|
806
731
|
logger.error(error);
|
|
807
732
|
}
|
|
808
|
-
|
|
809
733
|
await timer(250);
|
|
810
734
|
panelData.loading = false;
|
|
811
735
|
LoadingAnimation.spinner.stop(`.panel-placeholder-bottom-${idPanel}`);
|
|
@@ -818,36 +742,36 @@ const PanelForm = {
|
|
|
818
742
|
<div
|
|
819
743
|
class="in fll ssr-shimmer-search-box"
|
|
820
744
|
style="${renderCssAttr({
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
745
|
+
style: {
|
|
746
|
+
width: '80%',
|
|
747
|
+
height: '30px',
|
|
748
|
+
top: '-13px',
|
|
749
|
+
left: '10px',
|
|
750
|
+
},
|
|
751
|
+
})}"
|
|
828
752
|
></div>
|
|
829
753
|
</div>`,
|
|
830
754
|
createdAt: html`<div class="fl">
|
|
831
755
|
<div
|
|
832
756
|
class="in fll ssr-shimmer-search-box"
|
|
833
757
|
style="${renderCssAttr({
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
758
|
+
style: {
|
|
759
|
+
width: '50%',
|
|
760
|
+
height: '30px',
|
|
761
|
+
left: '-5px',
|
|
762
|
+
},
|
|
763
|
+
})}"
|
|
840
764
|
></div>
|
|
841
765
|
</div>`,
|
|
842
766
|
mdFileId: html`<div class="fl section-mp">
|
|
843
767
|
<div
|
|
844
768
|
class="in fll ssr-shimmer-search-box"
|
|
845
769
|
style="${renderCssAttr({
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
770
|
+
style: {
|
|
771
|
+
width: '80%',
|
|
772
|
+
height: '30px',
|
|
773
|
+
},
|
|
774
|
+
})}"
|
|
851
775
|
></div>
|
|
852
776
|
</div>`.repeat(random(2, 4)),
|
|
853
777
|
ssr: true,
|
|
@@ -859,10 +783,10 @@ const PanelForm = {
|
|
|
859
783
|
let loadingGetData = false;
|
|
860
784
|
closeModalRouteChangeEvents[idPanel] = () => {
|
|
861
785
|
setTimeout(() => {
|
|
862
|
-
|
|
786
|
+
PanelForm.Data[idPanel].updatePanel();
|
|
863
787
|
});
|
|
864
788
|
};
|
|
865
|
-
|
|
789
|
+
PanelForm.Data[idPanel].updatePanel = async (...args) => {
|
|
866
790
|
const _updatePanel = async (...args) => {
|
|
867
791
|
try {
|
|
868
792
|
const cid = getQueryParams().cid ? getQueryParams().cid : '';
|
|
@@ -871,7 +795,6 @@ const PanelForm = {
|
|
|
871
795
|
appStore.Data.user.main.model.user &&
|
|
872
796
|
appStore.Data.user.main.model.user._id &&
|
|
873
797
|
lastUserId !== appStore.Data.user.main.model.user._id;
|
|
874
|
-
|
|
875
798
|
logger.warn(
|
|
876
799
|
{
|
|
877
800
|
idPanel,
|
|
@@ -882,22 +805,18 @@ const PanelForm = {
|
|
|
882
805
|
? JSON.stringify(appStore.Data.user.main.model.user, null, 4)
|
|
883
806
|
: 'No user data',
|
|
884
807
|
);
|
|
885
|
-
|
|
886
808
|
// Normalize empty values for comparison (undefined, null, '' should all be treated as empty)
|
|
887
809
|
const normalizedCid = cid || '';
|
|
888
810
|
const normalizedLastCid = lastCid || '';
|
|
889
|
-
|
|
890
811
|
if (loadingGetData || (normalizedLastCid === normalizedCid && !forceUpdate)) return;
|
|
891
812
|
loadingGetData = true;
|
|
892
813
|
lastUserId = appStore.Data.user?.main?.model?.user?._id
|
|
893
814
|
? newInstance(appStore.Data.user.main.model.user._id)
|
|
894
815
|
: null;
|
|
895
816
|
lastCid = cid;
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
this.Data[idPanel] = {
|
|
900
|
-
...this.Data[idPanel],
|
|
817
|
+
logger.warn('instance render panel data');
|
|
818
|
+
PanelForm.Data[idPanel] = {
|
|
819
|
+
...PanelForm.Data[idPanel],
|
|
901
820
|
originData: [],
|
|
902
821
|
data: [],
|
|
903
822
|
filesData: [],
|
|
@@ -905,47 +824,37 @@ const PanelForm = {
|
|
|
905
824
|
hasMore: true,
|
|
906
825
|
loading: false,
|
|
907
826
|
};
|
|
908
|
-
|
|
909
827
|
// Always reset skip to 0 when reloading (whether cid exists or not)
|
|
910
|
-
|
|
911
|
-
|
|
828
|
+
PanelForm.Data[idPanel].skip = 0;
|
|
912
829
|
const containerSelector = `.${options.parentIdModal ? 'html-' + options.parentIdModal : 'main-body'}`;
|
|
913
830
|
htmls(containerSelector, await renderSrrPanelData());
|
|
914
|
-
|
|
915
831
|
await getPanelData();
|
|
916
|
-
|
|
917
832
|
htmls(
|
|
918
833
|
containerSelector,
|
|
919
834
|
html`
|
|
920
|
-
<div class="in">${await panelRender({ data:
|
|
835
|
+
<div class="in">${await panelRender({ data: PanelForm.Data[idPanel].data })}</div>
|
|
921
836
|
<div class="in panel-placeholder-bottom panel-placeholder-bottom-${idPanel}"></div>
|
|
922
837
|
`,
|
|
923
838
|
);
|
|
924
|
-
|
|
925
|
-
const lastOriginItem = this.Data[idPanel].originData[this.Data[idPanel].originData.length - 1];
|
|
839
|
+
const lastOriginItem = PanelForm.Data[idPanel].originData[PanelForm.Data[idPanel].originData.length - 1];
|
|
926
840
|
if (
|
|
927
|
-
!
|
|
841
|
+
!PanelForm.Data[idPanel].lasIdAvailable ||
|
|
928
842
|
!lastOriginItem ||
|
|
929
|
-
|
|
843
|
+
PanelForm.Data[idPanel].lasIdAvailable !== lastOriginItem._id
|
|
930
844
|
)
|
|
931
845
|
LoadingAnimation.spinner.play(`.panel-placeholder-bottom-${idPanel}`, 'dual-ring-mini');
|
|
932
|
-
|
|
933
846
|
const scrollContainerSelector = `.modal-${options.route}`;
|
|
934
|
-
|
|
935
847
|
// Always remove old scroll event before setting new one
|
|
936
|
-
if (
|
|
937
|
-
|
|
848
|
+
if (PanelForm.Data[idPanel].removeScrollEvent) {
|
|
849
|
+
PanelForm.Data[idPanel].removeScrollEvent();
|
|
938
850
|
}
|
|
939
|
-
|
|
940
851
|
if (cid) {
|
|
941
852
|
LoadingAnimation.spinner.stop(`.panel-placeholder-bottom-${idPanel}`);
|
|
942
853
|
return;
|
|
943
854
|
}
|
|
944
|
-
|
|
945
855
|
const { removeEvent } = Scroll.setEvent(scrollContainerSelector, async (payload) => {
|
|
946
856
|
const panelData = PanelForm.Data[idPanel];
|
|
947
857
|
if (!panelData) return;
|
|
948
|
-
|
|
949
858
|
// Infinite scroll: load more items at bottom
|
|
950
859
|
if (payload.atBottom && panelData.hasMore && !panelData.loading) {
|
|
951
860
|
const oldDataCount = panelData.data.length;
|
|
@@ -957,8 +866,7 @@ const PanelForm = {
|
|
|
957
866
|
}
|
|
958
867
|
}
|
|
959
868
|
});
|
|
960
|
-
|
|
961
|
-
|
|
869
|
+
PanelForm.Data[idPanel].removeScrollEvent = removeEvent;
|
|
962
870
|
if (!firsUpdateEvent && options.firsUpdateEvent) {
|
|
963
871
|
firsUpdateEvent = true;
|
|
964
872
|
await options.firsUpdateEvent();
|
|
@@ -967,7 +875,6 @@ const PanelForm = {
|
|
|
967
875
|
logger.error(error);
|
|
968
876
|
}
|
|
969
877
|
};
|
|
970
|
-
|
|
971
878
|
await _updatePanel(...args);
|
|
972
879
|
loadingGetData = false;
|
|
973
880
|
};
|
|
@@ -998,14 +905,11 @@ const PanelForm = {
|
|
|
998
905
|
await PanelForm.Data[idPanel].updatePanel();
|
|
999
906
|
};
|
|
1000
907
|
}
|
|
1001
|
-
|
|
1002
908
|
if (options.parentIdModal) {
|
|
1003
909
|
htmls(`.html-${options.parentIdModal}`, await renderSrrPanelData());
|
|
1004
910
|
return '';
|
|
1005
911
|
}
|
|
1006
|
-
|
|
1007
912
|
return await renderSrrPanelData();
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
|
|
913
|
+
}
|
|
914
|
+
}
|
|
1011
915
|
export { PanelForm };
|