@primate/core 0.4.5 → 0.5.0
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/lib/private/App.d.ts +531 -3
- package/lib/private/App.js +8 -3
- package/lib/private/Binder.d.ts +2 -2
- package/lib/private/Flags.d.ts +3 -3
- package/lib/private/Module.d.ts +5 -5
- package/lib/private/app/Facade.d.ts +566 -0
- package/lib/private/app/Facade.js +33 -0
- package/lib/private/asset/Asset.d.ts +1 -1
- package/lib/private/backend/Module.d.ts +1 -1
- package/lib/private/backend/Module.js +2 -5
- package/lib/private/backend/TAG.d.ts +1 -1
- package/lib/private/backend/TAG.js +1 -1
- package/lib/private/build/App.d.ts +2 -2
- package/lib/private/build/App.js +0 -2
- package/lib/private/build/client/index.js +12 -7
- package/lib/private/build/hook.js +4 -3
- package/lib/private/build/index.js +14 -13
- package/lib/private/build/presets.d.ts +10 -0
- package/lib/private/build/presets.js +39 -0
- package/lib/private/build/server/index.js +5 -7
- package/lib/private/build/server/plugin/assets.js +9 -7
- package/lib/private/build/server/plugin/config.js +11 -4
- package/lib/private/build/server/plugin/db-default.d.ts +4 -0
- package/lib/private/build/server/plugin/db-default.js +45 -0
- package/lib/private/build/server/plugin/frontend.js +4 -2
- package/lib/private/build/server/plugin/live-reload.d.ts +4 -0
- package/lib/private/build/server/plugin/{hot-reload.js → live-reload.js} +4 -4
- package/lib/private/build/server/plugin/native-addons.js +6 -4
- package/lib/private/build/server/plugin/node-imports.js +2 -2
- package/lib/private/build/server/plugin/route.js +2 -2
- package/lib/private/build/server/plugin/store-wrap.js +2 -2
- package/lib/private/build/server/plugin/store.js +6 -6
- package/lib/private/build/server/plugin/stores.js +4 -5
- package/lib/private/build/server/plugin/view.js +4 -4
- package/lib/private/build/server/plugin/views.js +4 -4
- package/lib/private/build/server/plugin/virtual-pages.js +8 -8
- package/lib/private/build/server/plugin/virtual-routes.js +8 -13
- package/lib/private/build/server/plugin/wasm.js +2 -3
- package/lib/private/bye.js +2 -3
- package/lib/private/client/Data.d.ts +1 -1
- package/lib/private/client/ValidateInit.d.ts +1 -3
- package/lib/private/client/ValidationError.d.ts +1 -1
- package/lib/private/client/app.js +2 -1
- package/lib/private/client/create-form.d.ts +31 -0
- package/lib/private/client/create-form.js +124 -0
- package/lib/private/client/extract-issues.d.ts +4 -0
- package/lib/private/client/extract-issues.js +20 -0
- package/lib/private/client/spa/index.d.ts +1 -1
- package/lib/private/client/spa/index.js +4 -5
- package/lib/private/client/{toValidated.d.ts → to-validated.d.ts} +2 -4
- package/lib/private/client/{toValidated.js → to-validated.js} +1 -1
- package/lib/private/client/validate-field.d.ts +3 -0
- package/lib/private/client/validate-field.js +41 -0
- package/lib/private/config/index.d.ts +2 -21
- package/lib/private/config/index.js +3 -1
- package/lib/private/config/schema.d.ts +13 -9
- package/lib/private/config/schema.js +10 -5
- package/lib/private/cookie.d.ts +5 -5
- package/lib/private/cookie.js +10 -14
- package/lib/private/db/As.d.ts +10 -0
- package/lib/private/db/DB.d.ts +33 -0
- package/lib/private/db/DB.js +2 -0
- package/lib/private/db/DataDict.d.ts +5 -0
- package/lib/private/db/DataKey.d.ts +4 -0
- package/lib/private/db/DataValue.d.ts +17 -0
- package/lib/private/db/MemoryDB.d.ts +35 -0
- package/lib/private/db/MemoryDB.js +317 -0
- package/lib/private/db/PK.d.ts +3 -0
- package/lib/private/db/PK.js +2 -0
- package/lib/private/{database → db}/Query.d.ts +2 -2
- package/lib/private/{database → db}/QueryBuilder.d.ts +2 -3
- package/lib/private/db/ReadArgs.d.ts +9 -0
- package/lib/private/db/ReadArgs.js +2 -0
- package/lib/private/db/ReadRelationsArgs.d.ts +6 -0
- package/lib/private/db/ReadRelationsArgs.js +2 -0
- package/lib/private/{database → db}/Schema.d.ts +1 -2
- package/lib/private/db/Sort.d.ts +4 -0
- package/lib/private/{database → db}/TypeMap.d.ts +2 -3
- package/lib/private/{database → db}/Types.d.ts +1 -1
- package/lib/private/db/With.d.ts +16 -0
- package/lib/private/db/With.js +2 -0
- package/lib/private/db/common.d.ts +18 -0
- package/lib/private/db/common.js +36 -0
- package/lib/private/db/error.d.ts +81 -0
- package/lib/private/db/error.js +199 -0
- package/lib/private/db/sql.d.ts +28 -0
- package/lib/private/db/sql.js +177 -0
- package/lib/private/db/storage.d.ts +3 -0
- package/lib/private/db/storage.js +3 -0
- package/lib/private/db/symbol/wrap.js +2 -0
- package/lib/private/db/symbol.js +2 -0
- package/lib/private/db/test.d.ts +4 -0
- package/lib/private/db/test.js +1384 -0
- package/lib/private/frontend/Module.d.ts +6 -6
- package/lib/private/frontend/Module.js +28 -23
- package/lib/private/frontend/Render.d.ts +1 -2
- package/lib/private/frontend/ServerData.d.ts +1 -1
- package/lib/private/frontend/ServerView.d.ts +1 -2
- package/lib/private/frontend/View.d.ts +1 -1
- package/lib/private/frontend/ViewOptions.d.ts +1 -1
- package/lib/private/frontend/ViewResponse.d.ts +1 -1
- package/lib/private/hash.js +0 -1
- package/lib/private/i18n/Catalog.d.ts +5 -2
- package/lib/private/i18n/Formatter.js +20 -8
- package/lib/private/i18n/Module.d.ts +3 -3
- package/lib/private/i18n/Module.js +28 -17
- package/lib/private/i18n/format.d.ts +4 -0
- package/lib/private/i18n/format.js +95 -0
- package/lib/private/i18n/index/client.d.ts +9 -0
- package/lib/private/i18n/index/client.js +152 -0
- package/lib/private/i18n/index/server.d.ts +9 -0
- package/lib/private/i18n/index/server.js +57 -0
- package/lib/private/i18n/index/types.d.ts +33 -0
- package/lib/private/i18n/index/types.js +2 -0
- package/lib/private/i18n/locale.d.ts +9 -3
- package/lib/private/i18n/ordinals.d.ts +1 -1
- package/lib/private/i18n/resolve.d.ts +7 -0
- package/lib/private/i18n/resolve.js +30 -0
- package/lib/private/i18n/schema.d.ts +4 -4
- package/lib/private/i18n/schema.js +6 -10
- package/lib/private/i18n/storage.d.ts +3 -0
- package/lib/private/i18n/storage.js +5 -0
- package/lib/private/i18n/validate.d.ts +2 -0
- package/lib/private/i18n/validate.js +21 -0
- package/lib/private/log.d.ts +1 -0
- package/lib/private/log.js +10 -10
- package/lib/private/module/Hook.d.ts +1 -1
- package/lib/private/module/Next.d.ts +1 -1
- package/lib/private/orm/ForeignKey.d.ts +11 -0
- package/lib/private/orm/ForeignKey.js +22 -0
- package/lib/private/orm/PrimaryKey.d.ts +15 -0
- package/lib/private/orm/PrimaryKey.js +35 -0
- package/lib/private/orm/Set.d.ts +11 -0
- package/lib/private/orm/Set.js +2 -0
- package/lib/private/orm/Store.d.ts +171 -0
- package/lib/private/orm/Store.js +518 -0
- package/lib/private/orm/foreign.d.ts +4 -0
- package/lib/private/orm/foreign.js +5 -0
- package/lib/private/orm/key.d.ts +8 -0
- package/lib/private/orm/key.js +4 -0
- package/lib/private/orm/parse.d.ts +12 -0
- package/lib/private/orm/parse.js +29 -0
- package/lib/private/orm/primary.d.ts +5 -0
- package/lib/private/orm/primary.js +5 -0
- package/lib/private/orm/relation.d.ts +43 -0
- package/lib/private/orm/relation.js +26 -0
- package/lib/private/orm/types.d.ts +18 -0
- package/lib/private/orm/types.js +2 -0
- package/lib/private/orm/wrap.d.ts +5 -0
- package/lib/private/orm/wrap.js +5 -0
- package/lib/private/paths.d.ts +2 -2
- package/lib/private/request/RequestBag.d.ts +1 -1
- package/lib/private/request/RequestBag.js +11 -7
- package/lib/private/request/RequestBody.d.ts +2 -4
- package/lib/private/request/RequestBody.js +8 -11
- package/lib/private/request/RequestContext.d.ts +12 -0
- package/lib/private/request/RequestContext.js +31 -0
- package/lib/private/request/RequestFacade.d.ts +16 -6
- package/lib/private/request/parse.d.ts +2 -2
- package/lib/private/request/parse.js +54 -16
- package/lib/private/request/route.js +37 -21
- package/lib/private/request/router.d.ts +1 -1
- package/lib/private/request/router.js +2 -2
- package/lib/private/request/sContext.d.ts +3 -0
- package/lib/private/request/sContext.js +2 -0
- package/lib/private/response/ResponseFunction.d.ts +1 -2
- package/lib/private/response/ResponseLike.d.ts +1 -1
- package/lib/private/response/binary.d.ts +1 -1
- package/lib/private/response/binary.js +4 -3
- package/lib/private/response/json.d.ts +1 -1
- package/lib/private/response/json.js +2 -2
- package/lib/private/response/redirect.js +1 -1
- package/lib/private/response/respond.js +7 -10
- package/lib/private/response/sse.d.ts +1 -1
- package/lib/private/response/sse.js +2 -2
- package/lib/private/response/text.d.ts +1 -1
- package/lib/private/response/text.js +3 -3
- package/lib/private/response/view.d.ts +2 -2
- package/lib/private/response/view.js +3 -3
- package/lib/private/response.d.ts +1 -1
- package/lib/private/route/Handler.d.ts +1 -1
- package/lib/private/route/hook.d.ts +6 -0
- package/lib/private/route/hook.js +5 -0
- package/lib/private/route/router.d.ts +9 -5
- package/lib/private/route/router.js +34 -17
- package/lib/private/route/wrap.js +2 -2
- package/lib/private/serve/App.d.ts +5 -18
- package/lib/private/serve/App.js +91 -82
- package/lib/private/serve/Init.d.ts +3 -3
- package/lib/private/serve/hook.js +1 -7
- package/lib/private/serve/index.js +6 -2
- package/lib/private/serve/module/Dev.d.ts +1 -1
- package/lib/private/serve/module/Dev.js +9 -5
- package/lib/private/serve/module/Handle.js +2 -2
- package/lib/private/session/Data.d.ts +1 -2
- package/lib/private/session/SessionHandle.d.ts +1 -1
- package/lib/private/session/SessionHandle.js +10 -9
- package/lib/private/session/SessionModule.js +7 -7
- package/lib/private/session/index.d.ts +3 -4
- package/lib/private/session/schema.d.ts +6 -6
- package/lib/private/session/schema.js +5 -4
- package/lib/private/session/storage.d.ts +1 -2
- package/lib/private/session/storage.js +2 -2
- package/lib/private/tags.js +2 -2
- package/lib/private/target/Target.d.ts +1 -1
- package/lib/public/AppFacade.d.ts +2 -0
- package/lib/public/AppFacade.js +2 -0
- package/lib/public/build/presets.d.ts +2 -0
- package/lib/public/build/presets.js +2 -0
- package/lib/public/build/transform.d.ts +2 -0
- package/lib/public/build/transform.js +2 -0
- package/lib/public/client.d.ts +14 -0
- package/lib/public/client.js +10 -0
- package/lib/public/db/MemoryDB.d.ts +2 -0
- package/lib/public/db/MemoryDB.js +2 -0
- package/lib/public/db/error.d.ts +2 -0
- package/lib/public/db/error.js +2 -0
- package/lib/public/db/sql.d.ts +2 -0
- package/lib/public/db/sql.js +2 -0
- package/lib/public/db/test.d.ts +2 -0
- package/lib/public/db/test.js +2 -0
- package/lib/public/db.d.ts +12 -0
- package/lib/public/db.js +2 -0
- package/lib/public/orm/Store.d.ts +2 -0
- package/lib/public/orm/Store.js +2 -0
- package/lib/public/orm/key.d.ts +2 -0
- package/lib/public/orm/key.js +2 -0
- package/lib/public/orm/relation.d.ts +2 -0
- package/lib/public/orm/relation.js +2 -0
- package/lib/public/orm/wrap.d.ts +2 -0
- package/lib/public/orm/wrap.js +2 -0
- package/lib/public/request.d.ts +4 -0
- package/lib/public/request.js +2 -0
- package/lib/public/response.d.ts +22 -0
- package/lib/public/response.js +19 -0
- package/lib/public/route/hook.d.ts +2 -0
- package/lib/public/route/hook.js +2 -0
- package/package.json +28 -23
- package/lib/private/build/client/reload.d.ts +0 -7
- package/lib/private/build/client/reload.js +0 -6
- package/lib/private/build/server/plugin/database-default.d.ts +0 -4
- package/lib/private/build/server/plugin/database-default.js +0 -48
- package/lib/private/build/server/plugin/hot-reload.d.ts +0 -4
- package/lib/private/client/validate.d.ts +0 -3
- package/lib/private/client/validate.js +0 -54
- package/lib/private/database/As.d.ts +0 -7
- package/lib/private/database/Binds.d.ts +0 -4
- package/lib/private/database/Binds.js +0 -2
- package/lib/private/database/Changes.d.ts +0 -11
- package/lib/private/database/Changes.js +0 -2
- package/lib/private/database/ColumnTypes.d.ts +0 -11
- package/lib/private/database/ColumnTypes.js +0 -2
- package/lib/private/database/DataDict.d.ts +0 -5
- package/lib/private/database/DataKey.d.ts +0 -4
- package/lib/private/database/DataValue.d.ts +0 -5
- package/lib/private/database/Database.d.ts +0 -56
- package/lib/private/database/Database.js +0 -153
- package/lib/private/database/InMemoryDatabase.d.ts +0 -37
- package/lib/private/database/InMemoryDatabase.js +0 -181
- package/lib/private/database/Sort.d.ts +0 -4
- package/lib/private/database/Store.d.ts +0 -172
- package/lib/private/database/Store.js +0 -261
- package/lib/private/database/storage.d.ts +0 -4
- package/lib/private/database/storage.js +0 -3
- package/lib/private/database/symbol/wrap.js +0 -2
- package/lib/private/database/symbol.js +0 -2
- package/lib/private/database/test.d.ts +0 -4
- package/lib/private/database/test.js +0 -678
- package/lib/private/database/wrap.d.ts +0 -5
- package/lib/private/database/wrap.js +0 -5
- package/lib/private/i18n/index.d.ts +0 -28
- package/lib/private/i18n/index.js +0 -236
- package/lib/private/route/guard.d.ts +0 -4
- package/lib/private/route/guard.js +0 -22
- package/lib/private/wasm/API.d.ts +0 -7
- package/lib/private/wasm/API.js +0 -2
- package/lib/private/wasm/BufferViewSource.d.ts +0 -4
- package/lib/private/wasm/BufferViewSource.js +0 -2
- package/lib/private/wasm/Exports.d.ts +0 -23
- package/lib/private/wasm/Exports.js +0 -2
- package/lib/private/wasm/I32.d.ts +0 -5
- package/lib/private/wasm/I32.js +0 -2
- package/lib/private/wasm/I32_SIZE.d.ts +0 -3
- package/lib/private/wasm/I32_SIZE.js +0 -2
- package/lib/private/wasm/Instantiation.d.ts +0 -12
- package/lib/private/wasm/Instantiation.js +0 -2
- package/lib/private/wasm/Tagged.d.ts +0 -7
- package/lib/private/wasm/Tagged.js +0 -2
- package/lib/private/wasm/buffersize.d.ts +0 -2
- package/lib/private/wasm/buffersize.js +0 -5
- package/lib/private/wasm/decode-bytes.d.ts +0 -3
- package/lib/private/wasm/decode-bytes.js +0 -5
- package/lib/private/wasm/decode-json.d.ts +0 -7
- package/lib/private/wasm/decode-json.js +0 -11
- package/lib/private/wasm/decode-option.d.ts +0 -5
- package/lib/private/wasm/decode-option.js +0 -10
- package/lib/private/wasm/decode-response.d.ts +0 -19
- package/lib/private/wasm/decode-response.js +0 -90
- package/lib/private/wasm/decode-string.d.ts +0 -3
- package/lib/private/wasm/decode-string.js +0 -5
- package/lib/private/wasm/decode-websocket-close.d.ts +0 -5
- package/lib/private/wasm/decode-websocket-close.js +0 -6
- package/lib/private/wasm/decode-websocket-send.d.ts +0 -6
- package/lib/private/wasm/decode-websocket-send.js +0 -19
- package/lib/private/wasm/encode-buffer.d.ts +0 -3
- package/lib/private/wasm/encode-buffer.js +0 -6
- package/lib/private/wasm/encode-request.d.ts +0 -9
- package/lib/private/wasm/encode-request.js +0 -195
- package/lib/private/wasm/encode-session.d.ts +0 -3
- package/lib/private/wasm/encode-session.js +0 -25
- package/lib/private/wasm/encode-string-map.d.ts +0 -5
- package/lib/private/wasm/encode-string-map.js +0 -14
- package/lib/private/wasm/encode-string.d.ts +0 -13
- package/lib/private/wasm/encode-string.js +0 -17
- package/lib/private/wasm/encode-url.d.ts +0 -11
- package/lib/private/wasm/encode-url.js +0 -14
- package/lib/private/wasm/encode-websocket-close.d.ts +0 -2
- package/lib/private/wasm/encode-websocket-close.js +0 -7
- package/lib/private/wasm/encode-websocket-message.d.ts +0 -4
- package/lib/private/wasm/encode-websocket-message.js +0 -30
- package/lib/private/wasm/encode-websocket-open.d.ts +0 -2
- package/lib/private/wasm/encode-websocket-open.js +0 -7
- package/lib/private/wasm/filesize.d.ts +0 -2
- package/lib/private/wasm/filesize.js +0 -8
- package/lib/private/wasm/instantiate.d.ts +0 -37
- package/lib/private/wasm/instantiate.js +0 -408
- package/lib/private/wasm/open-websocket.d.ts +0 -4
- package/lib/private/wasm/open-websocket.js +0 -26
- package/lib/private/wasm/stringsize.d.ts +0 -3
- package/lib/private/wasm/stringsize.js +0 -5
- package/lib/private/wasm/urlsize.d.ts +0 -2
- package/lib/private/wasm/urlsize.js +0 -5
- package/lib/public/Database.d.ts +0 -2
- package/lib/public/Database.js +0 -2
- package/lib/public/client/ValidateInit.d.ts +0 -2
- package/lib/public/client/ValidateInit.js +0 -2
- package/lib/public/client/ValidateUpdater.d.ts +0 -2
- package/lib/public/client/ValidateUpdater.js +0 -2
- package/lib/public/client/ValidationError.d.ts +0 -2
- package/lib/public/client/ValidationError.js +0 -2
- package/lib/public/client/toValidated.d.ts +0 -2
- package/lib/public/client/toValidated.js +0 -2
- package/lib/public/client/validate.d.ts +0 -2
- package/lib/public/client/validate.js +0 -2
- package/lib/public/database/As.d.ts +0 -2
- package/lib/public/database/As.js +0 -2
- package/lib/public/database/DataDict.d.ts +0 -2
- package/lib/public/database/DataDict.js +0 -2
- package/lib/public/database/InMemoryDatabase.d.ts +0 -2
- package/lib/public/database/InMemoryDatabase.js +0 -2
- package/lib/public/database/Sort.d.ts +0 -2
- package/lib/public/database/Sort.js +0 -2
- package/lib/public/database/Store.d.ts +0 -2
- package/lib/public/database/Store.js +0 -2
- package/lib/public/database/TypeMap.d.ts +0 -2
- package/lib/public/database/TypeMap.js +0 -2
- package/lib/public/database/Types.d.ts +0 -2
- package/lib/public/database/Types.js +0 -2
- package/lib/public/database/test.d.ts +0 -2
- package/lib/public/database/test.js +0 -2
- package/lib/public/database/wrap.d.ts +0 -2
- package/lib/public/database/wrap.js +0 -2
- package/lib/public/request/RequestBody.d.ts +0 -2
- package/lib/public/request/RequestBody.js +0 -2
- package/lib/public/request/RequestFacade.d.ts +0 -2
- package/lib/public/request/RequestFacade.js +0 -2
- package/lib/public/request/Verb.d.ts +0 -2
- package/lib/public/request/Verb.js +0 -2
- package/lib/public/response/ResponseFunction.d.ts +0 -2
- package/lib/public/response/ResponseFunction.js +0 -2
- package/lib/public/response/ResponseLike.d.ts +0 -2
- package/lib/public/response/ResponseLike.js +0 -2
- package/lib/public/response/binary.d.ts +0 -2
- package/lib/public/response/binary.js +0 -2
- package/lib/public/response/error.d.ts +0 -2
- package/lib/public/response/error.js +0 -2
- package/lib/public/response/json.d.ts +0 -2
- package/lib/public/response/json.js +0 -2
- package/lib/public/response/redirect.d.ts +0 -2
- package/lib/public/response/redirect.js +0 -2
- package/lib/public/response/sse.d.ts +0 -2
- package/lib/public/response/sse.js +0 -2
- package/lib/public/response/text.d.ts +0 -2
- package/lib/public/response/text.js +0 -2
- package/lib/public/response/view.d.ts +0 -2
- package/lib/public/response/view.js +0 -2
- package/lib/public/response/ws.d.ts +0 -2
- package/lib/public/response/ws.js +0 -2
- package/lib/public/wasm/decode-json.d.ts +0 -5
- package/lib/public/wasm/decode-json.js +0 -3
- package/lib/public/wasm/decode-response.d.ts +0 -3
- package/lib/public/wasm/decode-response.js +0 -3
- package/lib/public/wasm/encode-request.d.ts +0 -3
- package/lib/public/wasm/encode-request.js +0 -3
- package/lib/public/wasm/encode-session.d.ts +0 -3
- package/lib/public/wasm/encode-session.js +0 -3
- package/lib/public/wasm/instantiate.d.ts +0 -4
- package/lib/public/wasm/instantiate.js +0 -3
- /package/lib/private/{database → db}/As.js +0 -0
- /package/lib/private/{database → db}/DataDict.js +0 -0
- /package/lib/private/{database → db}/DataKey.js +0 -0
- /package/lib/private/{database → db}/DataValue.js +0 -0
- /package/lib/private/{database → db}/Query.js +0 -0
- /package/lib/private/{database → db}/QueryBuilder.js +0 -0
- /package/lib/private/{database → db}/Schema.js +0 -0
- /package/lib/private/{database → db}/Sort.js +0 -0
- /package/lib/private/{database → db}/TypeMap.js +0 -0
- /package/lib/private/{database → db}/Types.js +0 -0
- /package/lib/private/{database → db}/primary.d.ts +0 -0
- /package/lib/private/{database → db}/primary.js +0 -0
- /package/lib/private/{database → db}/symbol/wrap.d.ts +0 -0
- /package/lib/private/{database → db}/symbol.d.ts +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type ServeApp from "#serve/App";
|
|
2
|
-
import type MaybePromise from "@rcompat/type
|
|
2
|
+
import type { MaybePromise } from "@rcompat/type";
|
|
3
3
|
declare const _default: <T>(mime: string, mapper: (input: T) => BodyInit) => (body: T, init?: ResponseInit) => (app: ServeApp) => MaybePromise<Response>;
|
|
4
4
|
export default _default;
|
|
5
5
|
//# sourceMappingURL=response.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type RequestFacade from "#request/RequestFacade";
|
|
2
2
|
import type ResponseLike from "#response/ResponseLike";
|
|
3
|
-
import type MaybePromise from "@rcompat/type
|
|
3
|
+
import type { MaybePromise } from "@rcompat/type";
|
|
4
4
|
type RouteHandler = (request: RequestFacade) => MaybePromise<ResponseLike>;
|
|
5
5
|
export { RouteHandler as default };
|
|
6
6
|
//# sourceMappingURL=Handler.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type NextRoute from "#module/NextRoute";
|
|
2
|
+
import type RequestFacade from "#request/RequestFacade";
|
|
3
|
+
import type ResponseLike from "#response/ResponseLike";
|
|
4
|
+
import type { MaybePromise } from "@rcompat/type";
|
|
5
|
+
export default function hook(fn: (request: RequestFacade, next: NextRoute) => MaybePromise<ResponseLike>): void;
|
|
6
|
+
//# sourceMappingURL=hook.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type RequestHook from "#module/RequestHook";
|
|
1
2
|
import type Verb from "#request/Verb";
|
|
2
3
|
import type RouteHandler from "#route/Handler";
|
|
3
4
|
import type RouteOptions from "#route/Options";
|
|
@@ -8,12 +9,15 @@ declare class Router {
|
|
|
8
9
|
pop(): void;
|
|
9
10
|
get active(): string | undefined;
|
|
10
11
|
add(verb: Verb, handler: RouteHandler, options?: RouteOptions): void;
|
|
12
|
+
addHook(fn: RequestHook): void;
|
|
13
|
+
getHooks(path: string): RequestHook[];
|
|
14
|
+
verifyHook(path: string): void;
|
|
11
15
|
get(path: string): {
|
|
12
|
-
|
|
16
|
+
options?: {
|
|
13
17
|
handler: RouteHandler;
|
|
14
18
|
options: RouteOptions;
|
|
15
19
|
} | undefined;
|
|
16
|
-
|
|
20
|
+
head?: {
|
|
17
21
|
handler: RouteHandler;
|
|
18
22
|
options: RouteOptions;
|
|
19
23
|
} | undefined;
|
|
@@ -21,15 +25,15 @@ declare class Router {
|
|
|
21
25
|
handler: RouteHandler;
|
|
22
26
|
options: RouteOptions;
|
|
23
27
|
} | undefined;
|
|
24
|
-
|
|
28
|
+
delete?: {
|
|
25
29
|
handler: RouteHandler;
|
|
26
30
|
options: RouteOptions;
|
|
27
31
|
} | undefined;
|
|
28
|
-
|
|
32
|
+
post?: {
|
|
29
33
|
handler: RouteHandler;
|
|
30
34
|
options: RouteOptions;
|
|
31
35
|
} | undefined;
|
|
32
|
-
|
|
36
|
+
put?: {
|
|
33
37
|
handler: RouteHandler;
|
|
34
38
|
options: RouteOptions;
|
|
35
39
|
} | undefined;
|
|
@@ -1,29 +1,46 @@
|
|
|
1
|
+
import fail from "#fail";
|
|
1
2
|
import assert from "@rcompat/assert";
|
|
2
|
-
import is from "@rcompat/assert/is";
|
|
3
|
-
import maybe from "@rcompat/assert/maybe";
|
|
4
3
|
const stack = [];
|
|
5
4
|
export const routes = stack;
|
|
5
|
+
function is_hook_file(p) {
|
|
6
|
+
const basename = p.split("/").at(-1) ?? p;
|
|
7
|
+
return basename === "+hook" || basename.startsWith("+hook.");
|
|
8
|
+
}
|
|
6
9
|
class Router {
|
|
7
10
|
#routes = {};
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
#hooks = {};
|
|
12
|
+
push(route) { stack.push(route); }
|
|
13
|
+
pop() { stack.pop(); }
|
|
14
|
+
get active() { return stack.at(-1); }
|
|
15
|
+
add(verb, handler, options) {
|
|
16
|
+
assert.string(verb);
|
|
17
|
+
assert.function(handler);
|
|
18
|
+
assert.maybe.dict(options);
|
|
19
|
+
assert.maybe.boolean(options?.parseBody);
|
|
20
|
+
const active = assert.defined(this.active);
|
|
21
|
+
if (is_hook_file(active)) {
|
|
22
|
+
throw fail("route.{0} may not be used inside {1}; use hook(...) instead", verb, active);
|
|
23
|
+
}
|
|
24
|
+
const _routes = this.#routes;
|
|
25
|
+
if (!(active in _routes))
|
|
26
|
+
_routes[active] = {};
|
|
27
|
+
_routes[active][verb] = { handler, options: options ?? {} };
|
|
10
28
|
}
|
|
11
|
-
|
|
12
|
-
|
|
29
|
+
addHook(fn) {
|
|
30
|
+
assert.function(fn);
|
|
31
|
+
const active = assert.defined(this.active);
|
|
32
|
+
if (!is_hook_file(active)) {
|
|
33
|
+
throw fail("hook(...) may only be used inside +hook files, got {0}", active);
|
|
34
|
+
}
|
|
35
|
+
(this.#hooks[active] ??= []).push(fn);
|
|
13
36
|
}
|
|
14
|
-
|
|
15
|
-
return
|
|
37
|
+
getHooks(path) {
|
|
38
|
+
return [...(this.#hooks[path] ?? [])];
|
|
16
39
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
maybe(options).object();
|
|
21
|
-
const active = this.active;
|
|
22
|
-
const routes = this.#routes;
|
|
23
|
-
if (!(active in routes)) {
|
|
24
|
-
routes[active] = {};
|
|
40
|
+
verifyHook(path) {
|
|
41
|
+
if ((this.#hooks[path] ?? []).length === 0) {
|
|
42
|
+
throw fail("hook file {0} did not register any hooks (call hook(...))", path);
|
|
25
43
|
}
|
|
26
|
-
routes[active][verb] = { handler, options };
|
|
27
44
|
}
|
|
28
45
|
get(path) {
|
|
29
46
|
return { ...this.#routes[path] };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import string from "@rcompat/string";
|
|
2
2
|
export default function wrap(code, path, build_id) {
|
|
3
3
|
const router = `ROUTER_${build_id}`;
|
|
4
|
-
const prelude = dedent `
|
|
4
|
+
const prelude = string.dedent `
|
|
5
5
|
import ${router} from "primate/router";
|
|
6
6
|
${router}.push("${path}");
|
|
7
7
|
`;
|
|
@@ -4,14 +4,12 @@ import type ServerView from "#frontend/ServerView";
|
|
|
4
4
|
import type ViewOptions from "#frontend/ViewOptions";
|
|
5
5
|
import type ViewResponse from "#frontend/ViewResponse";
|
|
6
6
|
import type I18NConfig from "#i18n/Config";
|
|
7
|
-
import RequestBag from "#request/RequestBag";
|
|
8
|
-
import RequestBody from "#request/RequestBody";
|
|
9
7
|
import type RequestFacade from "#request/RequestFacade";
|
|
10
8
|
import type RouteHandler from "#route/Handler";
|
|
11
9
|
import type ServeInit from "#serve/Init";
|
|
12
10
|
import FileRouter from "@rcompat/fs/FileRouter";
|
|
13
11
|
import type Actions from "@rcompat/http/Actions";
|
|
14
|
-
import type Dict from "@rcompat/type
|
|
12
|
+
import type { Dict } from "@rcompat/type";
|
|
15
13
|
interface FullViewOptions extends ViewOptions {
|
|
16
14
|
body: string;
|
|
17
15
|
}
|
|
@@ -47,27 +45,16 @@ export default class ServeApp extends App {
|
|
|
47
45
|
create_csp(): void;
|
|
48
46
|
register(extension: string, viewFunction: ViewResponse): void;
|
|
49
47
|
page(name?: string): string;
|
|
50
|
-
|
|
48
|
+
serve_assets(pathname: string): Promise<Response | undefined>;
|
|
51
49
|
start(): Promise<void>;
|
|
52
50
|
stop(): void;
|
|
53
51
|
upgrade(request: Request, actions: Actions): null;
|
|
54
52
|
route(request: RequestFacade): Promise<{
|
|
55
53
|
errors: RouteHandler[];
|
|
56
|
-
|
|
57
|
-
handler: RouteHandler;
|
|
54
|
+
hooks: import("../module/RequestHook.js").default[];
|
|
58
55
|
layouts: RouteHandler[];
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
path: RequestBag;
|
|
62
|
-
context: Dict;
|
|
63
|
-
cookies: RequestBag;
|
|
64
|
-
forward(to: string, headers?: Dict<string>): Promise<Response>;
|
|
65
|
-
headers: RequestBag;
|
|
66
|
-
original: Request;
|
|
67
|
-
query: RequestBag;
|
|
68
|
-
target: string;
|
|
69
|
-
url: URL;
|
|
70
|
-
};
|
|
56
|
+
handler: RouteHandler;
|
|
57
|
+
request: any;
|
|
71
58
|
} | undefined>;
|
|
72
59
|
}
|
|
73
60
|
export {};
|
package/lib/private/serve/App.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import App from "#App";
|
|
2
|
+
import { s_config } from "#app/Facade";
|
|
2
3
|
import fail from "#fail";
|
|
3
4
|
import hash from "#hash";
|
|
4
5
|
import I18NModule from "#i18n/Module";
|
|
@@ -13,19 +14,15 @@ import DevModule from "#serve/module/Dev";
|
|
|
13
14
|
import HandleModule from "#serve/module/Handle";
|
|
14
15
|
import SessionModule from "#session/SessionModule";
|
|
15
16
|
import tags from "#tags";
|
|
16
|
-
import
|
|
17
|
-
import
|
|
17
|
+
import assert from "@rcompat/assert";
|
|
18
|
+
import fs from "@rcompat/fs";
|
|
18
19
|
import FileRouter from "@rcompat/fs/FileRouter";
|
|
19
|
-
import
|
|
20
|
-
import TEXT_HTML from "@rcompat/http/mime/text/html";
|
|
20
|
+
import MIME from "@rcompat/http/mime";
|
|
21
21
|
import serve from "@rcompat/http/serve";
|
|
22
22
|
import Status from "@rcompat/http/Status";
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import record from "pema/record";
|
|
27
|
-
import string from "pema/string";
|
|
28
|
-
import uint from "pema/uint";
|
|
23
|
+
import is from "@rcompat/is";
|
|
24
|
+
import utf8 from "@rcompat/string/utf8";
|
|
25
|
+
import p from "pema";
|
|
29
26
|
const deroot = (pathname) => pathname.endsWith("/") && pathname !== "/"
|
|
30
27
|
? pathname.slice(0, -1)
|
|
31
28
|
: pathname;
|
|
@@ -67,8 +64,8 @@ export default class ServeApp extends App {
|
|
|
67
64
|
#builtins;
|
|
68
65
|
#i18n_config;
|
|
69
66
|
constructor(rootfile, init) {
|
|
70
|
-
const dir =
|
|
71
|
-
super(dir, init.
|
|
67
|
+
const dir = fs.ref(rootfile).directory;
|
|
68
|
+
super(dir, init.facade[s_config], {
|
|
72
69
|
mode: init.mode,
|
|
73
70
|
target: init.target,
|
|
74
71
|
dir: dir.path,
|
|
@@ -78,7 +75,7 @@ export default class ServeApp extends App {
|
|
|
78
75
|
this.#stores = Object.fromEntries((init.stores?.map(([k, s]) => [k, s.default])) ?? []);
|
|
79
76
|
this.#serve_assets = init.assets;
|
|
80
77
|
this.#pages = init.pages;
|
|
81
|
-
const http = this.#init.
|
|
78
|
+
const http = this.#init.facade[s_config].http;
|
|
82
79
|
this.#i18n_config = init.i18n_config;
|
|
83
80
|
this.set(s_http, {
|
|
84
81
|
host: http.host,
|
|
@@ -92,14 +89,16 @@ export default class ServeApp extends App {
|
|
|
92
89
|
extensions: [".js"],
|
|
93
90
|
specials: {
|
|
94
91
|
error: { recursive: false },
|
|
95
|
-
guard: { recursive: true },
|
|
96
92
|
layout: { recursive: true },
|
|
93
|
+
hook: { recursive: true },
|
|
97
94
|
},
|
|
98
95
|
}, init.routes.map(s => s[0]));
|
|
99
96
|
this.#builtins = {
|
|
100
97
|
dev: init.mode === "development" ? new DevModule(this) : undefined,
|
|
101
98
|
handle: new HandleModule(this),
|
|
102
|
-
session: init.session_config
|
|
99
|
+
session: init.session_config
|
|
100
|
+
? new SessionModule(this.secure, init.session_config)
|
|
101
|
+
: undefined,
|
|
103
102
|
i18n: init.i18n_config ? new I18NModule(init.i18n_config) : undefined,
|
|
104
103
|
};
|
|
105
104
|
}
|
|
@@ -133,7 +132,7 @@ export default class ServeApp extends App {
|
|
|
133
132
|
return this.#i18n_config;
|
|
134
133
|
}
|
|
135
134
|
loadView(name) {
|
|
136
|
-
const f =
|
|
135
|
+
const f = fs.ref(name).path;
|
|
137
136
|
const frontends = Object.keys(this.frontends);
|
|
138
137
|
const extension = frontends.find(frontend => f.endsWith(frontend));
|
|
139
138
|
const base = extension === undefined ? name : f.slice(0, -extension.length);
|
|
@@ -147,18 +146,18 @@ export default class ServeApp extends App {
|
|
|
147
146
|
}
|
|
148
147
|
;
|
|
149
148
|
headers(csp = {}) {
|
|
150
|
-
const
|
|
149
|
+
const base = Object.entries(this.config("http.csp") ?? {});
|
|
151
150
|
return {
|
|
152
151
|
...this.config("http.headers") ?? {},
|
|
153
|
-
...
|
|
154
|
-
"Content-Security-Policy": to_csp(
|
|
152
|
+
...base.length === 0 ? {} : {
|
|
153
|
+
"Content-Security-Policy": to_csp(base, this.#csp, csp),
|
|
155
154
|
},
|
|
156
155
|
};
|
|
157
156
|
}
|
|
158
157
|
;
|
|
159
158
|
render(content) {
|
|
160
159
|
const { body, head, page, partial, placeholders = {} } = content;
|
|
161
|
-
["body", "head"].forEach(key =>
|
|
160
|
+
["body", "head"].forEach(key => assert.undefined(placeholders[key]));
|
|
162
161
|
return partial ? body : Object.entries(placeholders)
|
|
163
162
|
// replace given placeholders, defaulting to ""
|
|
164
163
|
.reduce((rendered, [key, value]) => rendered
|
|
@@ -170,20 +169,22 @@ export default class ServeApp extends App {
|
|
|
170
169
|
.replace("%head%", render_head(this.#assets, head));
|
|
171
170
|
}
|
|
172
171
|
body_length(body) {
|
|
173
|
-
return
|
|
172
|
+
return is.string(body) ? utf8.size(body) : 0;
|
|
174
173
|
}
|
|
175
174
|
respond(body, init) {
|
|
176
|
-
const { headers, status } =
|
|
177
|
-
headers:
|
|
178
|
-
status: uint.values(Status).default(Status.OK),
|
|
175
|
+
const { headers, status } = p({
|
|
176
|
+
headers: p.dict(),
|
|
177
|
+
status: p.uint.values(Status).default(Status.OK),
|
|
179
178
|
}).parse(init);
|
|
180
179
|
const body_length = this.body_length(body);
|
|
181
180
|
return new Response(body, {
|
|
182
181
|
headers: {
|
|
183
|
-
"Content-Type": TEXT_HTML,
|
|
182
|
+
"Content-Type": MIME.TEXT_HTML,
|
|
184
183
|
...this.headers(),
|
|
185
|
-
...body_length ? {
|
|
186
|
-
|
|
184
|
+
...body_length ? {
|
|
185
|
+
...headers, "Content-Length": String(body_length),
|
|
186
|
+
} : headers,
|
|
187
|
+
}, status,
|
|
187
188
|
});
|
|
188
189
|
}
|
|
189
190
|
;
|
|
@@ -206,7 +207,7 @@ export default class ServeApp extends App {
|
|
|
206
207
|
code: inline ? code : "",
|
|
207
208
|
inline,
|
|
208
209
|
integrity: await hash(code),
|
|
209
|
-
src:
|
|
210
|
+
src: fs.join(this.config("http.static.root"), src ?? "").path,
|
|
210
211
|
type,
|
|
211
212
|
});
|
|
212
213
|
}
|
|
@@ -216,7 +217,10 @@ export default class ServeApp extends App {
|
|
|
216
217
|
;
|
|
217
218
|
create_csp() {
|
|
218
219
|
this.#csp = this.#assets.map(({ integrity, type: directive }) => [`${directive === "style" ? "style" : "script"}-src`, integrity])
|
|
219
|
-
.reduce((csp, [directive,
|
|
220
|
+
.reduce((csp, [directive, _hash]) => ({
|
|
221
|
+
...csp,
|
|
222
|
+
[directive]: csp[directive].concat(`'${_hash}'`),
|
|
223
|
+
}), { "script-src": [], "style-src": [] });
|
|
220
224
|
}
|
|
221
225
|
;
|
|
222
226
|
register(extension, viewFunction) {
|
|
@@ -230,18 +234,18 @@ export default class ServeApp extends App {
|
|
|
230
234
|
const page_name = name ?? location.app_html;
|
|
231
235
|
return this.#pages[page_name];
|
|
232
236
|
}
|
|
233
|
-
async #try_serve(
|
|
234
|
-
if (await
|
|
235
|
-
return new Response(
|
|
237
|
+
async #try_serve(ref) {
|
|
238
|
+
if (await ref.exists() && await ref.kind() === "file") {
|
|
239
|
+
return new Response(ref.stream(), {
|
|
236
240
|
headers: {
|
|
237
|
-
"Content-Type": resolve(
|
|
238
|
-
"Content-Length": String(await
|
|
241
|
+
"Content-Type": MIME.resolve(ref.name),
|
|
242
|
+
"Content-Length": String(await ref.size()),
|
|
239
243
|
},
|
|
240
244
|
status: Status.OK,
|
|
241
245
|
});
|
|
242
246
|
}
|
|
243
247
|
}
|
|
244
|
-
async
|
|
248
|
+
async serve_assets(pathname) {
|
|
245
249
|
const static_root = this.config("http.static.root");
|
|
246
250
|
if (!pathname.startsWith(static_root))
|
|
247
251
|
return undefined;
|
|
@@ -256,23 +260,22 @@ export default class ServeApp extends App {
|
|
|
256
260
|
return static_response;
|
|
257
261
|
return undefined;
|
|
258
262
|
}
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
if (asset)
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return new Response(bytes, {
|
|
268
|
-
headers: {
|
|
269
|
-
"Content-Type": asset.mime,
|
|
270
|
-
"Content-Length": String(bytes.length),
|
|
271
|
-
},
|
|
272
|
-
status: Status.OK,
|
|
273
|
-
});
|
|
263
|
+
const assets = this.#serve_assets;
|
|
264
|
+
const asset = assets.client[pathname] ?? assets.static[pathname];
|
|
265
|
+
if (asset === undefined)
|
|
266
|
+
return undefined;
|
|
267
|
+
const binary = atob(asset.data);
|
|
268
|
+
const bytes = new Uint8Array(binary.length);
|
|
269
|
+
for (let i = 0; i < binary.length; i++) {
|
|
270
|
+
bytes[i] = binary.charCodeAt(i);
|
|
274
271
|
}
|
|
275
|
-
return
|
|
272
|
+
return new Response(bytes, {
|
|
273
|
+
headers: {
|
|
274
|
+
"Content-Type": asset.mime,
|
|
275
|
+
"Content-Length": String(bytes.length),
|
|
276
|
+
},
|
|
277
|
+
status: Status.OK,
|
|
278
|
+
});
|
|
276
279
|
}
|
|
277
280
|
async start() {
|
|
278
281
|
if (this.mode === "production") {
|
|
@@ -293,8 +296,10 @@ export default class ServeApp extends App {
|
|
|
293
296
|
else {
|
|
294
297
|
const client_dir = this.root.join(location.client);
|
|
295
298
|
const files = await client_dir.exists()
|
|
296
|
-
? await client_dir.
|
|
297
|
-
|
|
299
|
+
? await client_dir.files({
|
|
300
|
+
recursive: true,
|
|
301
|
+
filter: info => info.extension === ".js" || info.extension === ".css",
|
|
302
|
+
})
|
|
298
303
|
: [];
|
|
299
304
|
this.#assets = await Promise.all(files.map(async (file) => {
|
|
300
305
|
const type = file.extension === ".css" ? "style" : "js";
|
|
@@ -328,9 +333,14 @@ export default class ServeApp extends App {
|
|
|
328
333
|
status: Status.INTERNAL_SERVER_ERROR,
|
|
329
334
|
});
|
|
330
335
|
}
|
|
331
|
-
}, {
|
|
332
|
-
|
|
333
|
-
|
|
336
|
+
}, {
|
|
337
|
+
...this.get(s_http),
|
|
338
|
+
timeout: this.mode === "development" ? 0 : undefined,
|
|
339
|
+
});
|
|
340
|
+
function bright(x) {
|
|
341
|
+
return `\x1b[38;2;0;200;255m${x}\x1b[0m`;
|
|
342
|
+
}
|
|
343
|
+
log.print(`» app url ${bright(this.url)}\n`);
|
|
334
344
|
}
|
|
335
345
|
;
|
|
336
346
|
stop() {
|
|
@@ -350,37 +360,36 @@ export default class ServeApp extends App {
|
|
|
350
360
|
return;
|
|
351
361
|
}
|
|
352
362
|
const verb = original.method.toLowerCase();
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
.map(
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
.
|
|
363
|
+
const specials = route.specials;
|
|
364
|
+
const errors = (specials.error ?? [])
|
|
365
|
+
.map(v => router.get(v)[verb]?.handler)
|
|
366
|
+
.filter(Boolean)
|
|
367
|
+
.toReversed();
|
|
368
|
+
const layouts = (specials.layout ?? [])
|
|
369
|
+
.map(v => router.get(v)[verb]?.handler)
|
|
370
|
+
.filter(Boolean)
|
|
371
|
+
.toReversed();
|
|
372
|
+
const hooks = (specials.hook ?? [])
|
|
373
|
+
.toReversed()
|
|
374
|
+
.flatMap(v => router.getHooks(v));
|
|
361
375
|
const verbs = router.get(route.path);
|
|
362
|
-
const
|
|
363
|
-
if (
|
|
376
|
+
const route_path = verbs[verb];
|
|
377
|
+
if (route_path === undefined) {
|
|
364
378
|
throw fail("route {0} has no {1} verb", route.path, verb);
|
|
365
379
|
}
|
|
366
|
-
const
|
|
367
|
-
const
|
|
380
|
+
const handler = route_path.handler;
|
|
381
|
+
const parse_body = route_path.options.parseBody;
|
|
382
|
+
const body = parse_body ?? this.config("request.body.parse")
|
|
368
383
|
? await RequestBody.parse(original, url)
|
|
369
384
|
: RequestBody.none();
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
path: new RequestBag(route.params, "path", {
|
|
379
|
-
normalize: k => k.toLowerCase(),
|
|
380
|
-
raw: url.pathname,
|
|
381
|
-
}),
|
|
382
|
-
},
|
|
383
|
-
};
|
|
385
|
+
const refined = Object.assign(Object.create(request), {
|
|
386
|
+
body,
|
|
387
|
+
path: new RequestBag(route.params, "path", {
|
|
388
|
+
normalize: k => k.toLowerCase(),
|
|
389
|
+
raw: url.pathname,
|
|
390
|
+
}),
|
|
391
|
+
});
|
|
392
|
+
return { errors, hooks, layouts, handler, request: refined };
|
|
384
393
|
}
|
|
385
394
|
}
|
|
386
395
|
//# sourceMappingURL=App.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type AppFacade from "#app/Facade";
|
|
2
2
|
import type I18NConfig from "#i18n/Config";
|
|
3
3
|
import type Mode from "#Mode";
|
|
4
4
|
import type SessionConfig from "#session/Config";
|
|
5
|
-
import type Dict from "@rcompat/type
|
|
5
|
+
import type { Dict } from "@rcompat/type";
|
|
6
6
|
type Import = {
|
|
7
7
|
default: unknown;
|
|
8
8
|
} & Dict;
|
|
@@ -19,7 +19,7 @@ type ServeInit = {
|
|
|
19
19
|
};
|
|
20
20
|
views?: [string, Import][];
|
|
21
21
|
stores?: [string, Import][];
|
|
22
|
-
|
|
22
|
+
facade: AppFacade;
|
|
23
23
|
routes: [string, {
|
|
24
24
|
default: any;
|
|
25
25
|
}][];
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import log from "#log";
|
|
2
1
|
import reducer from "#reducer";
|
|
3
|
-
function pre(app) {
|
|
4
|
-
log.system("in startup");
|
|
5
|
-
return app;
|
|
6
|
-
}
|
|
7
|
-
;
|
|
8
2
|
async function post(app) {
|
|
9
3
|
await app.start();
|
|
10
4
|
return app;
|
|
11
5
|
}
|
|
12
|
-
export default async (app) => post(await reducer(app.modules,
|
|
6
|
+
export default async (app) => post(await reducer(app.modules, app, "serve"));
|
|
13
7
|
//# sourceMappingURL=hook.js.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { s_attach } from "#app/Facade";
|
|
1
2
|
import ServeApp from "#serve/App";
|
|
2
|
-
import
|
|
3
|
+
import serve_hook from "#serve/hook";
|
|
3
4
|
export default async (root, options) => {
|
|
4
|
-
|
|
5
|
+
const facade = options.facade;
|
|
6
|
+
const app = await new ServeApp(root, options).init();
|
|
7
|
+
facade[s_attach](app);
|
|
8
|
+
return serve_hook(app);
|
|
5
9
|
};
|
|
6
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -6,6 +6,6 @@ export default class DevModule extends Module {
|
|
|
6
6
|
#private;
|
|
7
7
|
name: string;
|
|
8
8
|
constructor(app: ServeApp);
|
|
9
|
-
handle(request: RequestFacade, next: NextHandle): import("@rcompat/type
|
|
9
|
+
handle(request: RequestFacade, next: NextHandle): import("@rcompat/type").MaybePromise<Response>;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=Dev.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import log from "#log";
|
|
2
2
|
import Module from "#Module";
|
|
3
|
+
import c from "@rcompat/cli/color";
|
|
3
4
|
function pass(address, request) {
|
|
4
5
|
return fetch(address, {
|
|
5
6
|
body: request.body,
|
|
@@ -8,20 +9,23 @@ function pass(address, request) {
|
|
|
8
9
|
method: request.method,
|
|
9
10
|
});
|
|
10
11
|
}
|
|
12
|
+
// https://esbuild.github.io/api/#live-reload
|
|
11
13
|
export default class DevModule extends Module {
|
|
12
14
|
name = "builtin/dev";
|
|
13
15
|
#paths;
|
|
14
|
-
#
|
|
16
|
+
#reload;
|
|
15
17
|
constructor(app) {
|
|
16
18
|
super();
|
|
17
19
|
const assets = app.assets.map(asset => asset.src);
|
|
18
|
-
this.#paths =
|
|
19
|
-
|
|
20
|
+
this.#paths = ["/esbuild"].concat(assets);
|
|
21
|
+
const { host, port } = app.livereload;
|
|
22
|
+
this.#reload = `http://${host}:${port}`;
|
|
23
|
+
log.print(`↻ live reload ${c.dim(this.#reload)}\n`);
|
|
20
24
|
}
|
|
21
25
|
handle(request, next) {
|
|
22
26
|
const { pathname } = new URL(request.url);
|
|
23
27
|
return this.#paths.includes(pathname)
|
|
24
|
-
? pass(`${this.#
|
|
28
|
+
? pass(`${this.#reload}${pathname}`, request.original)
|
|
25
29
|
: next(request);
|
|
26
30
|
}
|
|
27
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import route from "#request/route";
|
|
2
1
|
import Module from "#Module";
|
|
2
|
+
import route from "#request/route";
|
|
3
3
|
export default class HandleModule extends Module {
|
|
4
4
|
name = "builtin/handle";
|
|
5
5
|
#app;
|
|
@@ -8,7 +8,7 @@ export default class HandleModule extends Module {
|
|
|
8
8
|
this.#app = app;
|
|
9
9
|
}
|
|
10
10
|
async handle(request) {
|
|
11
|
-
return await this.#app.
|
|
11
|
+
return await this.#app.serve_assets(request.url.pathname)
|
|
12
12
|
?? route(this.#app, request);
|
|
13
13
|
}
|
|
14
14
|
}
|