cyberia 3.1.3 → 3.2.9
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/.env.example +0 -2
- package/.github/workflows/engine-cyberia.cd.yml +10 -8
- package/.github/workflows/engine-cyberia.ci.yml +12 -29
- package/.github/workflows/ghpkg.ci.yml +4 -4
- package/.github/workflows/npmpkg.ci.yml +28 -11
- package/.github/workflows/publish.ci.yml +21 -2
- package/.github/workflows/pwa-microservices-template-page.cd.yml +4 -5
- package/.github/workflows/pwa-microservices-template-test.ci.yml +3 -3
- package/.github/workflows/release.cd.yml +14 -10
- package/CHANGELOG.md +783 -1
- package/CLI-HELP.md +95 -18
- package/Dockerfile +0 -2
- package/README.md +290 -220
- package/bin/build.js +24 -7
- package/bin/cyberia.js +2838 -252
- package/bin/deploy.js +747 -125
- package/bin/file.js +9 -0
- package/bin/index.js +2838 -252
- package/bin/vs.js +1 -1
- package/conf.js +99 -65
- package/deployment.yaml +18 -164
- package/hardhat/hardhat.config.js +13 -13
- package/hardhat/ignition/modules/ObjectLayerToken.js +1 -1
- package/hardhat/package-lock.json +2559 -5864
- package/hardhat/package.json +14 -23
- package/hardhat/scripts/deployObjectLayerToken.js +1 -1
- package/hardhat/test/ObjectLayerToken.js +4 -2
- package/hardhat/types/ethers-contracts/ObjectLayerToken.ts +690 -0
- package/hardhat/types/ethers-contracts/common.ts +92 -0
- package/hardhat/types/ethers-contracts/factories/ObjectLayerToken__factory.ts +1055 -0
- package/hardhat/types/ethers-contracts/factories/index.ts +4 -0
- package/hardhat/types/ethers-contracts/hardhat.d.ts +47 -0
- package/hardhat/types/ethers-contracts/index.ts +6 -0
- package/jsconfig.json +1 -1
- package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +6 -5
- package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +6 -5
- package/manifests/deployment/dd-cyberia-development/deployment.yaml +18 -164
- package/manifests/deployment/dd-cyberia-development/proxy.yaml +7 -79
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -6
- package/manifests/deployment/dd-test-development/deployment.yaml +112 -28
- package/manifests/deployment/dd-test-development/proxy.yaml +46 -1
- package/manifests/deployment/playwright/deployment.yaml +1 -1
- package/nodemon.json +1 -1
- package/package.json +39 -24
- package/proxy.yaml +7 -79
- package/scripts/k3s-node-setup.sh +2 -2
- package/scripts/nat-iptables.sh +103 -18
- package/scripts/rhel-grpc-setup.sh +56 -0
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.controller.js +58 -14
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.model.js +23 -14
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.router.js +5 -0
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.service.js +148 -20
- package/src/api/core/core.controller.js +10 -10
- package/src/api/core/core.service.js +10 -10
- package/src/api/crypto/crypto.controller.js +8 -8
- package/src/api/crypto/crypto.service.js +8 -8
- 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 +27 -0
- package/src/api/cyberia-action/cyberia-action.service.js +42 -0
- package/src/api/cyberia-dialogue/cyberia-dialogue.controller.js +93 -0
- package/src/api/cyberia-dialogue/cyberia-dialogue.model.js +36 -0
- package/src/api/cyberia-dialogue/cyberia-dialogue.router.js +29 -0
- package/src/api/cyberia-dialogue/cyberia-dialogue.service.js +51 -0
- package/src/api/cyberia-entity/cyberia-entity.controller.js +74 -0
- package/src/api/cyberia-entity/cyberia-entity.model.js +24 -0
- package/src/api/cyberia-entity/cyberia-entity.router.js +27 -0
- package/src/api/cyberia-entity/cyberia-entity.service.js +42 -0
- package/src/api/cyberia-instance/cyberia-fallback-world.js +178 -0
- package/src/api/cyberia-instance/cyberia-instance.controller.js +92 -0
- package/src/api/cyberia-instance/cyberia-instance.model.js +87 -0
- package/src/api/cyberia-instance/cyberia-instance.router.js +63 -0
- package/src/api/cyberia-instance/cyberia-instance.service.js +156 -0
- package/src/api/cyberia-instance/cyberia-portal-connector.js +260 -0
- package/src/api/cyberia-instance/cyberia-world-generator.js +505 -0
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.controller.js +74 -0
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.defaults.js +574 -0
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.model.js +231 -0
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.router.js +27 -0
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.service.js +46 -0
- package/src/api/cyberia-map/cyberia-map.controller.js +79 -0
- package/src/api/cyberia-map/cyberia-map.model.js +30 -0
- package/src/api/cyberia-map/cyberia-map.router.js +40 -0
- package/src/api/cyberia-map/cyberia-map.service.js +74 -0
- 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 +27 -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 +27 -0
- package/src/api/cyberia-quest-progress/cyberia-quest-progress.service.js +42 -0
- package/src/api/default/default.controller.js +10 -10
- package/src/api/default/default.service.js +10 -10
- package/src/api/document/document.controller.js +12 -12
- package/src/api/document/document.model.js +10 -16
- package/src/api/file/file.controller.js +8 -8
- package/src/api/file/file.model.js +10 -10
- package/src/api/file/file.ref.json +18 -0
- package/src/api/file/file.service.js +36 -36
- package/src/api/instance/instance.controller.js +10 -10
- package/src/api/instance/instance.model.js +4 -10
- package/src/api/instance/instance.service.js +10 -10
- package/src/api/ipfs/ipfs.controller.js +15 -36
- package/src/api/ipfs/ipfs.model.js +47 -47
- package/src/api/ipfs/ipfs.router.js +8 -13
- package/src/api/ipfs/ipfs.service.js +67 -129
- 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 +30 -0
- package/src/api/object-layer/object-layer.service.js +126 -43
- 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.service.js +18 -14
- package/src/api/test/test.controller.js +8 -8
- package/src/api/test/test.service.js +8 -8
- package/src/api/user/guest.service.js +99 -0
- package/src/api/user/user.controller.js +6 -6
- package/src/api/user/user.model.js +8 -13
- package/src/api/user/user.service.js +11 -27
- package/src/cli/cluster.js +68 -21
- package/src/cli/db.js +753 -825
- package/src/cli/deploy.js +215 -125
- package/src/cli/env.js +29 -0
- package/src/cli/fs.js +82 -8
- package/src/cli/image.js +43 -1
- package/src/cli/index.js +74 -3
- package/src/cli/kubectl.js +211 -0
- package/src/cli/release.js +340 -0
- package/src/cli/repository.js +475 -74
- package/src/cli/run.js +582 -43
- package/src/cli/secrets.js +73 -0
- package/src/cli/ssh.js +1 -1
- package/src/cli/static.js +43 -115
- package/src/cli/test.js +3 -3
- package/src/client/Cryptokoyn.index.js +18 -22
- package/src/client/CyberiaPortal.index.js +19 -24
- package/src/client/Default.index.js +21 -34
- package/src/client/Itemledger.index.js +20 -27
- package/src/client/Underpost.index.js +19 -24
- 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 +69 -0
- package/src/client/components/core/Auth.js +35 -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 +43 -64
- package/src/client/components/core/Chat.js +13 -15
- package/src/client/components/core/ClientEvents.js +87 -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 +194 -96
- package/src/client/components/core/EventBus.js +92 -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 +26 -19
- 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 +43 -43
- package/src/client/components/core/LogOut.js +25 -16
- package/src/client/components/core/Modal.js +462 -179
- package/src/client/components/core/NotificationManager.js +14 -18
- package/src/client/components/core/Panel.js +54 -51
- package/src/client/components/core/PanelForm.js +44 -144
- 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 +112 -30
- package/src/client/components/core/SocketIoHandler.js +75 -0
- package/src/client/components/core/Stream.js +143 -95
- 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/Webhook.js +40 -7
- package/src/client/components/core/Worker.js +163 -27
- package/src/client/components/core/windowGetDimensions.js +7 -7
- package/src/client/components/cryptokoyn/{MenuCryptokoyn.js → AppShellCryptokoyn.js} +59 -59
- package/src/client/components/cryptokoyn/AppStoreCryptokoyn.js +5 -0
- package/src/client/components/cryptokoyn/CssCryptokoyn.js +15 -15
- package/src/client/components/cryptokoyn/LogInCryptokoyn.js +9 -7
- package/src/client/components/cryptokoyn/LogOutCryptokoyn.js +8 -6
- 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/cryptokoyn/SocketIoCryptokoyn.js +3 -51
- package/src/client/components/cyberia/InstanceEngineCyberia.js +781 -0
- package/src/client/components/cyberia/MapEngineCyberia.js +1836 -2
- package/src/client/components/cyberia/ObjectLayerEngine.js +19 -0
- package/src/client/components/cyberia/ObjectLayerEngineModal.js +1220 -99
- package/src/client/components/cyberia/ObjectLayerEngineViewer.js +252 -316
- package/src/client/components/cyberia-portal/{MenuCyberiaPortal.js → AppShellCyberiaPortal.js} +136 -103
- package/src/client/components/cyberia-portal/AppStoreCyberiaPortal.js +5 -0
- package/src/client/components/cyberia-portal/CommonCyberiaPortal.js +462 -32
- package/src/client/components/cyberia-portal/CssCyberiaPortal.js +15 -15
- package/src/client/components/cyberia-portal/LogInCyberiaPortal.js +9 -7
- package/src/client/components/cyberia-portal/LogOutCyberiaPortal.js +8 -6
- 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/SocketIoCyberiaPortal.js +3 -49
- package/src/client/components/cyberia-portal/TranslateCyberiaPortal.js +8 -4
- package/src/client/components/default/{MenuDefault.js → AppShellDefault.js} +91 -91
- package/src/client/components/default/AppStoreDefault.js +5 -0
- package/src/client/components/default/CssDefault.js +12 -12
- package/src/client/components/default/LogInDefault.js +9 -7
- package/src/client/components/default/LogOutDefault.js +8 -6
- 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/SocketIoDefault.js +3 -51
- package/src/client/components/default/TranslateDefault.js +3 -3
- package/src/client/components/itemledger/{MenuItemledger.js → AppShellItemledger.js} +59 -59
- package/src/client/components/itemledger/AppStoreItemledger.js +5 -0
- package/src/client/components/itemledger/CssItemledger.js +15 -15
- package/src/client/components/itemledger/LogInItemledger.js +9 -7
- package/src/client/components/itemledger/LogOutItemledger.js +8 -6
- 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/SocketIoItemledger.js +3 -51
- package/src/client/components/itemledger/TranslateItemledger.js +3 -3
- package/src/client/components/underpost/{MenuUnderpost.js → AppShellUnderpost.js} +92 -92
- package/src/client/components/underpost/AppStoreUnderpost.js +5 -0
- 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 +9 -7
- package/src/client/components/underpost/LogOutUnderpost.js +8 -6
- 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/SocketIoUnderpost.js +3 -51
- 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 +443 -0
- package/src/client/public/cyberia-docs/CYBERIA-CLI.md +417 -0
- package/src/client/public/cyberia-docs/CYBERIA-CLIENT.md +313 -0
- package/src/client/public/cyberia-docs/CYBERIA-SERVER.md +260 -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/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 +35 -55
- 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-dialogue/cyberia-dialogue.service.js +99 -0
- package/src/client/services/cyberia-entity/cyberia-entity.management.js +57 -0
- package/src/client/services/cyberia-entity/cyberia-entity.service.js +99 -0
- package/src/client/services/cyberia-instance/cyberia-instance.management.js +194 -0
- package/src/client/services/cyberia-instance/cyberia-instance.service.js +116 -0
- package/src/client/services/cyberia-instance-conf/cyberia-instance-conf.service.js +99 -0
- package/src/client/services/cyberia-map/cyberia-map.management.js +193 -0
- package/src/client/services/cyberia-map/cyberia-map.service.js +120 -0
- 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 +6 -6
- package/src/client/services/instance/instance.service.js +10 -15
- package/src/client/services/ipfs/ipfs.service.js +14 -40
- package/src/client/services/object-layer/object-layer.management.js +14 -14
- package/src/client/services/object-layer/object-layer.service.js +39 -24
- 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 +6 -6
- 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/offline/Maintenance.js +12 -11
- package/src/client/ssr/offline/NoNetworkConnection.js +3 -3
- package/src/client/ssr/pages/CyberiaServerMetrics.js +1 -1
- package/src/client/ssr/pages/Test.js +2 -2
- package/src/client/sw/core.sw.js +212 -0
- package/src/grpc/cyberia/grpc-server.js +642 -0
- package/src/index.js +24 -1
- package/src/runtime/cyberia-client/Dockerfile +80 -0
- package/src/runtime/cyberia-server/Dockerfile +37 -0
- package/src/runtime/express/Dockerfile +5 -1
- package/src/runtime/express/Express.js +18 -1
- package/src/runtime/lampp/Dockerfile +17 -5
- package/src/runtime/lampp/Lampp.js +27 -4
- package/src/runtime/wp/Dockerfile +62 -0
- package/src/runtime/wp/Wp.js +639 -0
- package/src/server/atlas-sprite-sheet-generator.js +4 -2
- package/src/server/auth.js +24 -1
- package/src/server/backup.js +37 -9
- package/src/server/client-build-docs.js +52 -46
- package/src/server/client-build.js +356 -82
- package/src/server/client-formatted.js +140 -57
- package/src/server/conf.js +29 -13
- package/src/server/cron.js +25 -23
- package/src/server/data-query.js +32 -20
- package/src/server/dns.js +24 -1
- package/src/server/ipfs-client.js +253 -89
- package/src/server/object-layer.js +150 -114
- package/src/server/peer.js +8 -0
- package/src/server/process.js +13 -27
- package/src/server/runtime.js +25 -1
- package/src/server/semantic-layer-generator-floor.js +319 -0
- package/src/server/semantic-layer-generator-resource.js +259 -0
- package/src/server/semantic-layer-generator-skin.js +1164 -0
- package/src/server/semantic-layer-generator.js +211 -542
- package/src/server/shape-generator.js +108 -0
- package/src/server/start.js +19 -5
- package/src/server/valkey.js +141 -235
- package/src/ws/IoInterface.js +1 -10
- package/src/ws/IoServer.js +14 -33
- package/src/ws/core/channels/core.ws.chat.js +65 -20
- package/src/ws/core/channels/core.ws.mailer.js +113 -32
- package/src/ws/core/channels/core.ws.stream.js +90 -31
- package/src/ws/core/core.ws.connection.js +12 -33
- package/src/ws/core/core.ws.emit.js +10 -26
- package/src/ws/core/core.ws.server.js +25 -58
- package/src/ws/default/channels/default.ws.main.js +53 -12
- package/src/ws/default/default.ws.connection.js +26 -13
- package/src/ws/default/default.ws.server.js +30 -12
- 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/hardhat/README.md +0 -531
- package/hardhat/WHITE-PAPER.md +0 -1540
- package/jsdoc.dd-cyberia.json +0 -59
- package/jsdoc.json +0 -59
- package/src/api/object-layer/README.md +0 -347
- package/src/client/components/core/ColorPalette.js +0 -5267
- package/src/client/components/core/JoyStick.js +0 -80
- package/src/client/components/cryptokoyn/CommonCryptokoyn.js +0 -29
- package/src/client/components/cryptokoyn/ElementsCryptokoyn.js +0 -38
- package/src/client/components/cryptokoyn/RoutesCryptokoyn.js +0 -39
- package/src/client/components/cyberia-portal/ElementsCyberiaPortal.js +0 -38
- package/src/client/components/cyberia-portal/RoutesCyberiaPortal.js +0 -58
- package/src/client/components/cyberia-portal/ServerCyberiaPortal.js +0 -136
- package/src/client/components/default/ElementsDefault.js +0 -38
- package/src/client/components/default/RoutesDefault.js +0 -49
- package/src/client/components/itemledger/CommonItemledger.js +0 -29
- package/src/client/components/itemledger/ElementsItemledger.js +0 -38
- package/src/client/components/itemledger/RoutesItemledger.js +0 -40
- package/src/client/components/underpost/CommonUnderpost.js +0 -29
- package/src/client/components/underpost/ElementsUnderpost.js +0 -38
- package/src/client/components/underpost/RoutesUnderpost.js +0 -47
- package/src/client/sw/default.sw.js +0 -127
- package/src/client/sw/template.sw.js +0 -84
- package/src/ws/core/management/core.ws.chat.js +0 -8
- package/src/ws/core/management/core.ws.mailer.js +0 -16
- package/src/ws/core/management/core.ws.stream.js +0 -8
- package/src/ws/default/management/default.ws.main.js +0 -8
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
9
|
import fs from 'fs-extra';
|
|
10
|
-
import {
|
|
10
|
+
import { transformClientJs, JSONweb } from './client-formatted.js';
|
|
11
11
|
import { loggerFactory } from './logger.js';
|
|
12
12
|
import {
|
|
13
13
|
getCapVariableName,
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
uniqueArray,
|
|
17
17
|
} from '../client/components/core/CommonJs.js';
|
|
18
18
|
import { readConfJson } from './conf.js';
|
|
19
|
-
import UglifyJS from 'uglify-js';
|
|
20
19
|
import { minify } from 'html-minifier-terser';
|
|
21
20
|
import AdmZip from 'adm-zip';
|
|
22
21
|
import * as dir from 'path';
|
|
@@ -39,6 +38,8 @@ import { ssrFactory } from './ssr.js';
|
|
|
39
38
|
* @memberof clientBuild
|
|
40
39
|
*/
|
|
41
40
|
const copyNonExistingFiles = (src, dest) => {
|
|
41
|
+
if (dir.basename(src) === '.git') return;
|
|
42
|
+
|
|
42
43
|
// Ensure source exists
|
|
43
44
|
if (!fs.existsSync(src)) {
|
|
44
45
|
throw new Error(`Source directory does not exist: ${src}`);
|
|
@@ -75,6 +76,224 @@ const copyNonExistingFiles = (src, dest) => {
|
|
|
75
76
|
}
|
|
76
77
|
};
|
|
77
78
|
|
|
79
|
+
const splitFileByMb = ({ filePath, partSizeMb, logger }) => {
|
|
80
|
+
const partSizeBytes = Math.floor(Number(partSizeMb) * 1024 * 1024);
|
|
81
|
+
if (!Number.isFinite(partSizeBytes) || partSizeBytes <= 0) {
|
|
82
|
+
throw new Error(`Invalid --split value: ${partSizeMb}`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Clean ALL stale part files (any naming variant) before writing new ones
|
|
86
|
+
const zipDir = dir.dirname(filePath);
|
|
87
|
+
const zipBase = dir.basename(filePath);
|
|
88
|
+
if (fs.existsSync(zipDir)) {
|
|
89
|
+
fs.readdirSync(zipDir)
|
|
90
|
+
.filter((name) => name.startsWith(`${zipBase}.part`) || name.startsWith(`${zipBase}-part`))
|
|
91
|
+
.forEach((name) => fs.removeSync(dir.join(zipDir, name)));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const fileBuffer = fs.readFileSync(filePath);
|
|
95
|
+
const partPaths = [];
|
|
96
|
+
|
|
97
|
+
for (let offset = 0, partIndex = 0; offset < fileBuffer.length; offset += partSizeBytes, partIndex++) {
|
|
98
|
+
const partBuffer = fileBuffer.subarray(offset, offset + partSizeBytes);
|
|
99
|
+
const partPath = `${filePath}.part${String(partIndex + 1).padStart(3, '0')}`;
|
|
100
|
+
fs.writeFileSync(partPath, partBuffer);
|
|
101
|
+
partPaths.push(partPath);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
logger.warn('split zip', {
|
|
105
|
+
filePath,
|
|
106
|
+
partSizeMb: Number(partSizeMb),
|
|
107
|
+
parts: partPaths.length,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return partPaths;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const getZipPartPaths = (zipPath) => {
|
|
114
|
+
const zipDir = dir.dirname(zipPath);
|
|
115
|
+
const zipBase = dir.basename(zipPath);
|
|
116
|
+
const partPrefixDot = `${zipBase}.part`;
|
|
117
|
+
const partPrefixDash = `${zipBase}-part`;
|
|
118
|
+
|
|
119
|
+
const parsePartIndex = (rawSuffix) => {
|
|
120
|
+
// Strip optional .zip suffix added by pull/download (e.g. '001.zip' → '001')
|
|
121
|
+
const digits = rawSuffix.replace(/\.zip$/i, '');
|
|
122
|
+
return /^\d+$/.test(digits) ? Number(digits) : NaN;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const getPartIndex = (name) => {
|
|
126
|
+
if (name.startsWith(partPrefixDot)) return parsePartIndex(name.slice(partPrefixDot.length));
|
|
127
|
+
if (name.startsWith(partPrefixDash)) return parsePartIndex(name.slice(partPrefixDash.length));
|
|
128
|
+
return NaN;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return fs
|
|
132
|
+
.readdirSync(zipDir)
|
|
133
|
+
.filter((name) => Number.isFinite(getPartIndex(name)))
|
|
134
|
+
.sort((a, b) => getPartIndex(a) - getPartIndex(b))
|
|
135
|
+
.map((name) => dir.join(zipDir, name));
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const resolveClientBuildZip = (buildPrefix) => {
|
|
139
|
+
const normalizedPrefix = buildPrefix.replace(/\.zip(?:[.-]part\d+|[.-]part\*)?$/, '').replace(/[.-]part\*$/, '');
|
|
140
|
+
const candidatePrefixes = uniqueArray([
|
|
141
|
+
normalizedPrefix,
|
|
142
|
+
normalizedPrefix.endsWith('-') ? normalizedPrefix : `${normalizedPrefix}-`,
|
|
143
|
+
]);
|
|
144
|
+
|
|
145
|
+
for (const prefix of candidatePrefixes) {
|
|
146
|
+
const zipPath = `${prefix}.zip`;
|
|
147
|
+
if (fs.existsSync(zipPath)) {
|
|
148
|
+
return {
|
|
149
|
+
buildPrefix: prefix,
|
|
150
|
+
zipPath,
|
|
151
|
+
partPaths: [],
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const partPaths = fs.existsSync(dir.dirname(zipPath)) ? getZipPartPaths(zipPath) : [];
|
|
156
|
+
if (partPaths.length > 0) {
|
|
157
|
+
return {
|
|
158
|
+
buildPrefix: prefix,
|
|
159
|
+
zipPath,
|
|
160
|
+
partPaths,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const searchDir = dir.dirname(normalizedPrefix);
|
|
166
|
+
const prefixBase = dir.basename(normalizedPrefix);
|
|
167
|
+
if (!fs.existsSync(searchDir)) {
|
|
168
|
+
throw new Error(`Build directory not found: ${searchDir}`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const matches = uniqueArray(
|
|
172
|
+
fs
|
|
173
|
+
.readdirSync(searchDir)
|
|
174
|
+
.filter((name) => name.startsWith(prefixBase) && /\.zip(?:[.-]part\d+)?$/.test(name))
|
|
175
|
+
.map((name) => name.replace(/[.-]part\d+$/, '')),
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
if (matches.length === 1) {
|
|
179
|
+
const zipPath = dir.join(searchDir, matches[0]);
|
|
180
|
+
const partPaths = getZipPartPaths(zipPath);
|
|
181
|
+
return {
|
|
182
|
+
buildPrefix: zipPath.replace(/\.zip$/, ''),
|
|
183
|
+
zipPath,
|
|
184
|
+
partPaths,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (matches.length > 1) {
|
|
189
|
+
throw new Error(
|
|
190
|
+
`Multiple build zip matches found for '${buildPrefix}': ${matches.join(', ')}. Use a more specific --unzip path.`,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
throw new Error(`No build zip or split parts found for: ${buildPrefix}`);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Merges split ZIP parts back into a single ZIP file.
|
|
199
|
+
* @param {object} options
|
|
200
|
+
* @param {string} options.buildPrefix - The build prefix path (e.g. build/underpost.net/underpost.net-).
|
|
201
|
+
* @param {object} options.logger - Logger instance.
|
|
202
|
+
* @returns {{ zipPath: string, partPaths: string[], mergedBytes: number }}
|
|
203
|
+
*/
|
|
204
|
+
const mergeClientBuildZip = ({ buildPrefix, logger }) => {
|
|
205
|
+
// Normalize to get the zip path, then look for parts directly (bypassing resolveClientBuildZip
|
|
206
|
+
// which prefers an existing monolithic zip over parts).
|
|
207
|
+
const normalizedPrefix = buildPrefix.replace(/\.zip(?:[.-]part\d+)?$/, '').replace(/[-.]$/, '') + '-';
|
|
208
|
+
const candidatePrefixes = uniqueArray([buildPrefix, buildPrefix.endsWith('-') ? buildPrefix : `${buildPrefix}-`]);
|
|
209
|
+
|
|
210
|
+
let zipPath;
|
|
211
|
+
let partPaths = [];
|
|
212
|
+
|
|
213
|
+
for (const prefix of candidatePrefixes) {
|
|
214
|
+
const candidate = prefix.endsWith('.zip') ? prefix : `${prefix}.zip`;
|
|
215
|
+
const parts = getZipPartPaths(candidate);
|
|
216
|
+
if (parts.length > 0) {
|
|
217
|
+
zipPath = candidate;
|
|
218
|
+
partPaths = parts;
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (partPaths.length === 0) {
|
|
224
|
+
// Fall back to resolveClientBuildZip for the zipPath
|
|
225
|
+
const resolved = resolveClientBuildZip(buildPrefix);
|
|
226
|
+
zipPath = resolved.zipPath;
|
|
227
|
+
logger.warn('merge-zip: no split parts found, nothing to merge', { buildPrefix, zipPath });
|
|
228
|
+
return { zipPath, partPaths, mergedBytes: 0 };
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// For each part, extract raw bytes: if the part file is a Cloudinary wrapper zip
|
|
232
|
+
// (downloaded via pull without --omit-unzip or with --omit-unzip keeping the .zip),
|
|
233
|
+
// extract the inner entry rather than using the wrapper bytes.
|
|
234
|
+
const readPartBytes = (partPath) => {
|
|
235
|
+
const rawBytes = fs.readFileSync(partPath);
|
|
236
|
+
// Check for ZIP magic bytes (PK\x03\x04)
|
|
237
|
+
if (rawBytes[0] === 0x50 && rawBytes[1] === 0x4b && rawBytes[2] === 0x03 && rawBytes[3] === 0x04) {
|
|
238
|
+
try {
|
|
239
|
+
const wrapperZip = new AdmZip(rawBytes);
|
|
240
|
+
const entries = wrapperZip.getEntries();
|
|
241
|
+
// The inner entry is the original part file (without the outer .zip wrapper)
|
|
242
|
+
const partBase = dir.basename(partPath).replace(/\.zip$/i, '');
|
|
243
|
+
const entry = entries.find((e) => e.entryName === partBase || e.entryName.endsWith('/' + partBase));
|
|
244
|
+
if (entry) {
|
|
245
|
+
return entry.getData();
|
|
246
|
+
}
|
|
247
|
+
// Fallback: single-entry archive
|
|
248
|
+
if (entries.length === 1) {
|
|
249
|
+
return entries[0].getData();
|
|
250
|
+
}
|
|
251
|
+
} catch (_) {
|
|
252
|
+
// Not a valid zip or extraction failed — use raw bytes
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return rawBytes;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const mergedBuffer = Buffer.concat(partPaths.map(readPartBytes));
|
|
259
|
+
fs.writeFileSync(zipPath, mergedBuffer);
|
|
260
|
+
|
|
261
|
+
logger.warn('merge-zip: merged split parts into zip', {
|
|
262
|
+
zipPath,
|
|
263
|
+
parts: partPaths.length,
|
|
264
|
+
mergedBytes: mergedBuffer.length,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
return { zipPath, partPaths, mergedBytes: mergedBuffer.length };
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
const unzipClientBuild = ({ buildPrefix, logger }) => {
|
|
271
|
+
const { zipPath, partPaths, buildPrefix: resolvedBuildPrefix } = resolveClientBuildZip(buildPrefix);
|
|
272
|
+
const outputPath = resolvedBuildPrefix.replace(/-$/, '');
|
|
273
|
+
|
|
274
|
+
fs.removeSync(outputPath);
|
|
275
|
+
fs.mkdirSync(outputPath, { recursive: true });
|
|
276
|
+
|
|
277
|
+
const zip =
|
|
278
|
+
partPaths.length > 0
|
|
279
|
+
? new AdmZip(Buffer.concat(partPaths.map((partPath) => fs.readFileSync(partPath))))
|
|
280
|
+
: new AdmZip(zipPath);
|
|
281
|
+
|
|
282
|
+
zip.extractAllTo(outputPath, true);
|
|
283
|
+
|
|
284
|
+
logger.warn('unzip build', {
|
|
285
|
+
source: partPaths.length > 0 ? partPaths : [zipPath],
|
|
286
|
+
outputPath,
|
|
287
|
+
splitParts: partPaths.length,
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
outputPath,
|
|
292
|
+
zipPath,
|
|
293
|
+
partPaths,
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
|
|
78
297
|
/** @type {string} Default XSL sitemap template used when no `sitemap` source file exists in the public directory. */
|
|
79
298
|
const defaultSitemapXsl = `<?xml version="1.0" encoding="UTF-8"?>
|
|
80
299
|
<xsl:stylesheet version="1.0"
|
|
@@ -234,6 +453,7 @@ const defaultSitemapXsl = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
234
453
|
* @param {Array} options.liveClientBuildPaths - List of paths to build incrementally.
|
|
235
454
|
* @param {Array} options.instances - List of instances to build.
|
|
236
455
|
* @param {boolean} options.buildZip - Whether to create zip files of the builds.
|
|
456
|
+
* @param {string|number} options.split - Optional zip split size in MB.
|
|
237
457
|
* @param {boolean} options.fullBuild - Whether to perform a full build.
|
|
238
458
|
* @param {boolean} options.iconsBuild - Whether to build icons.
|
|
239
459
|
* @returns {Promise<void>} - Promise that resolves when the build is complete.
|
|
@@ -246,6 +466,7 @@ const buildClient = async (
|
|
|
246
466
|
liveClientBuildPaths: [],
|
|
247
467
|
instances: [],
|
|
248
468
|
buildZip: false,
|
|
469
|
+
split: '',
|
|
249
470
|
fullBuild: false,
|
|
250
471
|
iconsBuild: false,
|
|
251
472
|
},
|
|
@@ -312,34 +533,18 @@ const buildClient = async (
|
|
|
312
533
|
|
|
313
534
|
buildAcmeChallengePath(acmeChallengeFullPath);
|
|
314
535
|
|
|
315
|
-
if (publicClientId && publicClientId.startsWith('html-website-templates')) {
|
|
316
|
-
if (!fs.existsSync(`/home/dd/html-website-templates/`))
|
|
317
|
-
shellExec(`cd /home/dd && git clone https://github.com/designmodo/html-website-templates.git`);
|
|
318
|
-
if (!fs.existsSync(`${rootClientPath}/index.php`)) {
|
|
319
|
-
fs.copySync(`/home/dd/html-website-templates/${publicClientId.split('-publicClientId-')[1]}`, rootClientPath);
|
|
320
|
-
shellExec(`cd ${rootClientPath} && git init && git add . && git commit -m "Base template implementation"`);
|
|
321
|
-
// git remote add origin git@github.com:<username>/<repo>.git
|
|
322
|
-
fs.writeFileSync(`${rootClientPath}/.git/.htaccess`, `Deny from all`, 'utf8');
|
|
323
|
-
}
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
536
|
fs.removeSync(rootClientPath);
|
|
328
537
|
|
|
329
538
|
if (fs.existsSync(`./src/client/public/${publicClientId}`)) {
|
|
330
539
|
if (iconsBuild === true) await buildIcons({ publicClientId, metadata });
|
|
331
540
|
|
|
332
|
-
fs.copySync(
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
filter: function (name) {
|
|
336
|
-
console.log(name);
|
|
337
|
-
return true;
|
|
338
|
-
},
|
|
339
|
-
} */,
|
|
340
|
-
);
|
|
541
|
+
fs.copySync(`./src/client/public/${publicClientId}`, rootClientPath, {
|
|
542
|
+
filter: (sourcePath) => !sourcePath.split(dir.sep).includes('.git'),
|
|
543
|
+
});
|
|
341
544
|
} else if (fs.existsSync(`./engine-private/src/client/public/${publicClientId}`)) {
|
|
342
|
-
fs.copySync(`./engine-private/src/client/public/${publicClientId}`, rootClientPath
|
|
545
|
+
fs.copySync(`./engine-private/src/client/public/${publicClientId}`, rootClientPath, {
|
|
546
|
+
filter: (sourcePath) => !sourcePath.split(dir.sep).includes('.git'),
|
|
547
|
+
});
|
|
343
548
|
}
|
|
344
549
|
if (dists)
|
|
345
550
|
for (const dist of dists) {
|
|
@@ -447,15 +652,15 @@ const buildClient = async (
|
|
|
447
652
|
|
|
448
653
|
if (enableLiveRebuild && !options.liveClientBuildPaths.find((p) => p.srcBuildPath === jsSrcPath)) continue;
|
|
449
654
|
|
|
450
|
-
const jsSrc =
|
|
451
|
-
await srcFormatted(fs.readFileSync(jsSrcPath, 'utf8')),
|
|
452
|
-
module,
|
|
655
|
+
const jsSrc = await transformClientJs(jsSrcPath, {
|
|
453
656
|
dists,
|
|
454
|
-
path,
|
|
455
|
-
'components',
|
|
657
|
+
proxyPath: path,
|
|
658
|
+
basePath: 'components',
|
|
659
|
+
module,
|
|
456
660
|
baseHost,
|
|
457
|
-
|
|
458
|
-
|
|
661
|
+
minify: minifyBuild,
|
|
662
|
+
});
|
|
663
|
+
fs.writeFileSync(jsPublicPath, jsSrc, 'utf8');
|
|
459
664
|
}
|
|
460
665
|
}
|
|
461
666
|
|
|
@@ -463,39 +668,53 @@ const buildClient = async (
|
|
|
463
668
|
for (const module of services) {
|
|
464
669
|
if (!fs.existsSync(`${rootClientPath}/services/${module}`))
|
|
465
670
|
fs.mkdirSync(`${rootClientPath}/services/${module}`, { recursive: true });
|
|
671
|
+
const moduleDir = `./src/client/services/${module}`;
|
|
672
|
+
if (!fs.existsSync(moduleDir)) continue;
|
|
466
673
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
674
|
+
const serviceFiles = fs
|
|
675
|
+
.readdirSync(moduleDir)
|
|
676
|
+
.filter((name) => name.endsWith('.service.js') || name.endsWith('.management.js'))
|
|
677
|
+
.sort();
|
|
471
678
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
dists,
|
|
476
|
-
path,
|
|
477
|
-
'services',
|
|
478
|
-
baseHost,
|
|
479
|
-
);
|
|
480
|
-
fs.writeFileSync(jsPublicPath, minifyBuild ? UglifyJS.minify(jsSrc).code : jsSrc, 'utf8');
|
|
481
|
-
}
|
|
482
|
-
}
|
|
679
|
+
for (const serviceFile of serviceFiles) {
|
|
680
|
+
const jsSrcPath = `${moduleDir}/${serviceFile}`;
|
|
681
|
+
const jsPublicPath = `${rootClientPath}/services/${module}/${serviceFile}`;
|
|
483
682
|
|
|
484
|
-
for (const module of services) {
|
|
485
|
-
if (fs.existsSync(`./src/client/services/${module}/${module}.management.js`)) {
|
|
486
|
-
const jsSrcPath = `./src/client/services/${module}/${module}.management.js`;
|
|
487
|
-
const jsPublicPath = `${rootClientPath}/services/${module}/${module}.management.js`;
|
|
488
683
|
if (enableLiveRebuild && !options.liveClientBuildPaths.find((p) => p.srcBuildPath === jsSrcPath)) continue;
|
|
489
684
|
|
|
490
|
-
const jsSrc =
|
|
491
|
-
await srcFormatted(fs.readFileSync(jsSrcPath, 'utf8')),
|
|
492
|
-
module,
|
|
685
|
+
const jsSrc = await transformClientJs(jsSrcPath, {
|
|
493
686
|
dists,
|
|
494
|
-
path,
|
|
495
|
-
'services',
|
|
687
|
+
proxyPath: path,
|
|
688
|
+
basePath: 'services',
|
|
689
|
+
module,
|
|
496
690
|
baseHost,
|
|
497
|
-
|
|
498
|
-
|
|
691
|
+
minify: minifyBuild,
|
|
692
|
+
});
|
|
693
|
+
fs.writeFileSync(jsPublicPath, jsSrc, 'utf8');
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// Auto-build guest module files when user module is processed
|
|
697
|
+
if (module === 'user') {
|
|
698
|
+
const guestModuleDir = './src/client/services/user';
|
|
699
|
+
const guestServicePath = `${guestModuleDir}/guest.service.js`;
|
|
700
|
+
if (fs.existsSync(guestServicePath)) {
|
|
701
|
+
if (!fs.existsSync(`${rootClientPath}/services/user`))
|
|
702
|
+
fs.mkdirSync(`${rootClientPath}/services/user`, { recursive: true });
|
|
703
|
+
|
|
704
|
+
const guestJsPublicPath = `${rootClientPath}/services/user/guest.service.js`;
|
|
705
|
+
|
|
706
|
+
if (!enableLiveRebuild || options.liveClientBuildPaths.find((p) => p.srcBuildPath === guestServicePath)) {
|
|
707
|
+
const guestJsSrc = await transformClientJs(guestServicePath, {
|
|
708
|
+
dists,
|
|
709
|
+
proxyPath: path,
|
|
710
|
+
basePath: 'services',
|
|
711
|
+
module: 'user',
|
|
712
|
+
baseHost,
|
|
713
|
+
minify: minifyBuild,
|
|
714
|
+
});
|
|
715
|
+
fs.writeFileSync(guestJsPublicPath, guestJsSrc, 'utf8');
|
|
716
|
+
}
|
|
717
|
+
}
|
|
499
718
|
}
|
|
500
719
|
}
|
|
501
720
|
}
|
|
@@ -506,16 +725,20 @@ const buildClient = async (
|
|
|
506
725
|
const Render = await ssrFactory();
|
|
507
726
|
|
|
508
727
|
if (views) {
|
|
509
|
-
const jsSrcPath =
|
|
510
|
-
? `./src/client/sw/${publicClientId}.sw.js`
|
|
511
|
-
: `./src/client/sw/default.sw.js`;
|
|
728
|
+
const jsSrcPath = `./src/client/sw/core.sw.js`;
|
|
512
729
|
|
|
513
730
|
const jsPublicPath = `${rootClientPath}/sw.js`;
|
|
514
731
|
|
|
515
732
|
if (!(enableLiveRebuild && !options.liveClientBuildPaths.find((p) => p.srcBuildPath === jsSrcPath))) {
|
|
516
|
-
const jsSrc =
|
|
517
|
-
|
|
518
|
-
|
|
733
|
+
const jsSrc = await transformClientJs(jsSrcPath, {
|
|
734
|
+
dists,
|
|
735
|
+
proxyPath: path,
|
|
736
|
+
baseHost,
|
|
737
|
+
minify: minifyBuild,
|
|
738
|
+
externalizeBareImports: false,
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
fs.writeFileSync(jsPublicPath, jsSrc, 'utf8');
|
|
519
742
|
}
|
|
520
743
|
|
|
521
744
|
if (
|
|
@@ -535,14 +758,14 @@ const buildClient = async (
|
|
|
535
758
|
|
|
536
759
|
logger.info('View build', buildPath);
|
|
537
760
|
|
|
538
|
-
const jsSrc =
|
|
539
|
-
await srcFormatted(fs.readFileSync(`./src/client/${view.client}.index.js`, 'utf8')),
|
|
761
|
+
const jsSrc = await transformClientJs(`./src/client/${view.client}.index.js`, {
|
|
540
762
|
dists,
|
|
541
|
-
path,
|
|
763
|
+
proxyPath: path,
|
|
542
764
|
baseHost,
|
|
543
|
-
|
|
765
|
+
minify: minifyBuild,
|
|
766
|
+
});
|
|
544
767
|
|
|
545
|
-
fs.writeFileSync(`${buildPath}${buildId}.js`,
|
|
768
|
+
fs.writeFileSync(`${buildPath}${buildId}.js`, jsSrc, 'utf8');
|
|
546
769
|
const title = metadata.title ? metadata.title : title;
|
|
547
770
|
|
|
548
771
|
const canonicalURL = `https://${host}${path}${
|
|
@@ -746,16 +969,18 @@ Sitemap: ${sitemapBaseUrl}/sitemap.xml`,
|
|
|
746
969
|
if (client) {
|
|
747
970
|
let PRE_CACHED_RESOURCES = [];
|
|
748
971
|
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
972
|
+
const normalizePrecacheRoutePath = (candidatePath) => {
|
|
973
|
+
const routePath =
|
|
974
|
+
typeof candidatePath === 'string' && candidatePath.trim().length > 0 ? candidatePath.trim() : '/offline';
|
|
975
|
+
const withLeadingSlash = routePath.startsWith('/') ? routePath : `/${routePath}`;
|
|
976
|
+
const withoutTrailingSlash = withLeadingSlash.replace(/\/+$/, '');
|
|
977
|
+
return withoutTrailingSlash.length > 0 ? withoutTrailingSlash : '/';
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
const toPrecacheIndexUrl = (routePath) => {
|
|
981
|
+
const normalizedRoutePath = normalizePrecacheRoutePath(routePath);
|
|
982
|
+
return `${path === '/' ? '' : path}${normalizedRoutePath === '/' ? '' : normalizedRoutePath}/index.html`;
|
|
983
|
+
};
|
|
759
984
|
|
|
760
985
|
for (const pageType of ['offline', 'pages']) {
|
|
761
986
|
if (confSSR[getCapVariableName(client)] && confSSR[getCapVariableName(client)][pageType]) {
|
|
@@ -783,7 +1008,11 @@ Sitemap: ${sitemapBaseUrl}/sitemap.xml`,
|
|
|
783
1008
|
rootClientPath[rootClientPath.length - 1] === '/' ? rootClientPath.slice(0, -1) : rootClientPath
|
|
784
1009
|
}${page.path === '/' ? page.path : `${page.path}/`}`;
|
|
785
1010
|
|
|
786
|
-
|
|
1011
|
+
// Install-time precache is intentionally restricted to SSR offline pages.
|
|
1012
|
+
// All other routes/assets are loaded lazily at runtime.
|
|
1013
|
+
if (pageType === 'offline') {
|
|
1014
|
+
PRE_CACHED_RESOURCES.push(toPrecacheIndexUrl(page.path));
|
|
1015
|
+
}
|
|
787
1016
|
|
|
788
1017
|
if (!fs.existsSync(buildPath)) fs.mkdirSync(buildPath, { recursive: true });
|
|
789
1018
|
|
|
@@ -809,13 +1038,47 @@ Sitemap: ${sitemapBaseUrl}/sitemap.xml`,
|
|
|
809
1038
|
}
|
|
810
1039
|
|
|
811
1040
|
{
|
|
1041
|
+
const cacheScope = path === '/' ? 'root' : path.replaceAll('/', '_');
|
|
1042
|
+
const ssrClientConf = confSSR[getCapVariableName(client)] || {};
|
|
1043
|
+
const ssrOfflinePages = Array.isArray(ssrClientConf.offline) ? ssrClientConf.offline : [];
|
|
1044
|
+
const normalizeSsrRoutePath = (candidatePath, fallbackPath) => {
|
|
1045
|
+
const value =
|
|
1046
|
+
typeof candidatePath === 'string' && candidatePath.trim().length > 0
|
|
1047
|
+
? candidatePath.trim()
|
|
1048
|
+
: fallbackPath;
|
|
1049
|
+
const withLeadingSlash = value.startsWith('/') ? value : `/${value}`;
|
|
1050
|
+
const withoutTrailingSlash = withLeadingSlash.replace(/\/+$/, '');
|
|
1051
|
+
return withoutTrailingSlash.length > 0 ? withoutTrailingSlash : '/';
|
|
1052
|
+
};
|
|
1053
|
+
|
|
1054
|
+
const offlineSsrPage =
|
|
1055
|
+
ssrOfflinePages.find(
|
|
1056
|
+
(page) =>
|
|
1057
|
+
page?.client === 'NoNetworkConnection' ||
|
|
1058
|
+
/no\s*network|offline/i.test(`${page?.title || ''} ${page?.client || ''} ${page?.path || ''}`),
|
|
1059
|
+
) || ssrOfflinePages[0];
|
|
1060
|
+
|
|
1061
|
+
const maintenanceSsrPage =
|
|
1062
|
+
ssrOfflinePages.find(
|
|
1063
|
+
(page) =>
|
|
1064
|
+
page?.client === 'Maintenance' ||
|
|
1065
|
+
/maintenance/i.test(`${page?.title || ''} ${page?.client || ''} ${page?.path || ''}`),
|
|
1066
|
+
) || ssrOfflinePages[1];
|
|
1067
|
+
|
|
1068
|
+
const offlinePath = normalizeSsrRoutePath(offlineSsrPage?.path, '/offline');
|
|
1069
|
+
const maintenancePath = normalizeSsrRoutePath(maintenanceSsrPage?.path, '/maintenance');
|
|
1070
|
+
|
|
812
1071
|
const renderPayload = {
|
|
813
1072
|
PRE_CACHED_RESOURCES: uniqueArray(PRE_CACHED_RESOURCES),
|
|
814
1073
|
PROXY_PATH: path,
|
|
1074
|
+
CACHE_PREFIX: `engine-core-v3-${cacheScope}`,
|
|
1075
|
+
OFFLINE_PATH: offlinePath,
|
|
1076
|
+
MAINTENANCE_PATH: maintenancePath,
|
|
815
1077
|
};
|
|
816
1078
|
fs.writeFileSync(
|
|
817
1079
|
`${rootClientPath}/sw.js`,
|
|
818
1080
|
`self.renderPayload = ${JSONweb(renderPayload)};
|
|
1081
|
+
self.__WB_DISABLE_DEV_LOGS = true;
|
|
819
1082
|
${fs.readFileSync(`${rootClientPath}/sw.js`, 'utf8')}`,
|
|
820
1083
|
'utf8',
|
|
821
1084
|
);
|
|
@@ -838,13 +1101,24 @@ ${fs.readFileSync(`${rootClientPath}/sw.js`, 'utf8')}`,
|
|
|
838
1101
|
}
|
|
839
1102
|
|
|
840
1103
|
const buildId = `${host}-${path.replaceAll('/', '')}`;
|
|
1104
|
+
const zipPath = `./build/${buildId}.zip`;
|
|
841
1105
|
|
|
842
|
-
logger.warn('write zip',
|
|
1106
|
+
logger.warn('write zip', zipPath);
|
|
843
1107
|
|
|
844
|
-
zip.writeZip(
|
|
1108
|
+
zip.writeZip(zipPath);
|
|
1109
|
+
|
|
1110
|
+
if (options.split) {
|
|
1111
|
+
splitFileByMb({
|
|
1112
|
+
filePath: zipPath,
|
|
1113
|
+
partSizeMb: options.split,
|
|
1114
|
+
logger,
|
|
1115
|
+
});
|
|
1116
|
+
fs.removeSync(zipPath);
|
|
1117
|
+
logger.warn('removed original zip after split', { zipPath });
|
|
1118
|
+
}
|
|
845
1119
|
}
|
|
846
1120
|
}
|
|
847
1121
|
}
|
|
848
1122
|
};
|
|
849
1123
|
|
|
850
|
-
export { buildClient, copyNonExistingFiles };
|
|
1124
|
+
export { buildClient, copyNonExistingFiles, unzipClientBuild, mergeClientBuildZip };
|