@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
package/lib/private/paths.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type FileRef from "@rcompat/fs
|
|
2
|
-
import type Dict from "@rcompat/type
|
|
1
|
+
import type { FileRef } from "@rcompat/fs";
|
|
2
|
+
import type { Dict } from "@rcompat/type";
|
|
3
3
|
declare function resolve(root: FileRef, config_paths?: Dict<string[]>): Promise<any>;
|
|
4
4
|
export default resolve;
|
|
5
5
|
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fail from "#fail";
|
|
2
|
-
import
|
|
2
|
+
import assert from "@rcompat/assert";
|
|
3
|
+
import fn from "@rcompat/fn";
|
|
3
4
|
export default class RequestBag {
|
|
4
5
|
#contents;
|
|
5
6
|
#name;
|
|
@@ -12,16 +13,19 @@ export default class RequestBag {
|
|
|
12
13
|
* @param name - Human-readable bag name used in error messages.
|
|
13
14
|
* @param options - Optional `normalize` function and `raw` string.
|
|
14
15
|
*/
|
|
15
|
-
constructor(input, name, options
|
|
16
|
-
|
|
16
|
+
constructor(input, name, options) {
|
|
17
|
+
assert.dict(input);
|
|
18
|
+
assert.string(name);
|
|
19
|
+
assert.maybe.dict(options);
|
|
20
|
+
assert.maybe.function(options?.normalize);
|
|
21
|
+
assert.maybe.string(options?.raw);
|
|
17
22
|
this.#name = name;
|
|
18
|
-
this.#normalize = options
|
|
19
|
-
this.#raw = options
|
|
23
|
+
this.#normalize = options?.normalize ?? fn.identity;
|
|
24
|
+
this.#raw = options?.raw ?? "";
|
|
20
25
|
const contents = Object.create(null);
|
|
21
26
|
for (const key of Object.keys(input)) {
|
|
22
|
-
const normalized = this.#normalize(key);
|
|
23
27
|
// last-wins semantics if only case differs
|
|
24
|
-
contents[
|
|
28
|
+
contents[this.#normalize(key)] = input[key];
|
|
25
29
|
}
|
|
26
30
|
this.#contents = contents;
|
|
27
31
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type Dict from "@rcompat/type
|
|
2
|
-
import type JSONValue from "@rcompat/type/JSONValue";
|
|
3
|
-
import type Schema from "@rcompat/type/Schema";
|
|
1
|
+
import type { Dict, JSONValue, Schema } from "@rcompat/type";
|
|
4
2
|
type Form = Dict<string>;
|
|
5
3
|
type Parsed = {
|
|
6
4
|
type: "binary";
|
|
@@ -26,7 +24,7 @@ export default class RequestBody {
|
|
|
26
24
|
static parse(request: Request, url: URL): Promise<RequestBody>;
|
|
27
25
|
static none(): RequestBody;
|
|
28
26
|
constructor(parsed: Parsed, files?: Dict<File>);
|
|
29
|
-
get type(): "binary" | "
|
|
27
|
+
get type(): "binary" | "json" | "text" | "none" | "form";
|
|
30
28
|
json(): JSONValue;
|
|
31
29
|
json<S extends Schema<unknown>>(schema: S): ParseReturn<S>;
|
|
32
30
|
form(): Form;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import fail from "#fail";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import www_form from "@rcompat/http/mime/application/x-www-form-urlencoded";
|
|
5
|
-
import form_data from "@rcompat/http/mime/multipart/form-data";
|
|
6
|
-
import text from "@rcompat/http/mime/text/plain";
|
|
2
|
+
import MIME from "@rcompat/http/mime";
|
|
3
|
+
import is from "@rcompat/is";
|
|
7
4
|
async function anyform(request) {
|
|
8
5
|
const form = Object.create(null);
|
|
9
6
|
const files = Object.create(null);
|
|
10
7
|
for (const [key, value] of (await request.formData()).entries()) {
|
|
11
|
-
if (
|
|
8
|
+
if (is.string(value)) {
|
|
12
9
|
form[key] = value;
|
|
13
10
|
}
|
|
14
11
|
else {
|
|
@@ -27,16 +24,16 @@ export default class RequestBody {
|
|
|
27
24
|
const path = url.pathname;
|
|
28
25
|
try {
|
|
29
26
|
switch (type) {
|
|
30
|
-
case
|
|
27
|
+
case MIME.APPLICATION_OCTET_STREAM:
|
|
31
28
|
return new RequestBody({ type: "binary", value: await request.blob() });
|
|
32
|
-
case
|
|
33
|
-
case
|
|
29
|
+
case MIME.APPLICATION_X_WWW_FORM_URLENCODED:
|
|
30
|
+
case MIME.MULTIPART_FORM_DATA: {
|
|
34
31
|
const { form, files } = await anyform(request);
|
|
35
32
|
return new RequestBody({ type: "form", value: form }, files);
|
|
36
33
|
}
|
|
37
|
-
case
|
|
34
|
+
case MIME.APPLICATION_JSON:
|
|
38
35
|
return new RequestBody({ type: "json", value: await request.json() });
|
|
39
|
-
case
|
|
36
|
+
case MIME.TEXT_PLAIN:
|
|
40
37
|
return new RequestBody({ type: "text", value: await request.text() });
|
|
41
38
|
case "none":
|
|
42
39
|
return RequestBody.none();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Dict } from "@rcompat/type";
|
|
2
|
+
export default class RequestContext {
|
|
3
|
+
#private;
|
|
4
|
+
set<T>(key: string, value: T): void;
|
|
5
|
+
update<T>(key: string, fn: (prev: T | undefined) => T): void;
|
|
6
|
+
has(key: string): boolean;
|
|
7
|
+
try<T>(key: string): T | undefined;
|
|
8
|
+
get<T>(key: string): T;
|
|
9
|
+
delete(key: string): void;
|
|
10
|
+
toJSON(): Dict;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=RequestContext.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export default class RequestContext {
|
|
2
|
+
#data = new Map();
|
|
3
|
+
set(key, value) {
|
|
4
|
+
this.#data.set(key, value);
|
|
5
|
+
}
|
|
6
|
+
update(key, fn) {
|
|
7
|
+
const prev = this.try(key);
|
|
8
|
+
this.set(key, fn(prev));
|
|
9
|
+
}
|
|
10
|
+
has(key) {
|
|
11
|
+
return this.#data.has(key);
|
|
12
|
+
}
|
|
13
|
+
try(key) {
|
|
14
|
+
return this.#data.get(key);
|
|
15
|
+
}
|
|
16
|
+
get(key) {
|
|
17
|
+
if (!this.#data.has(key))
|
|
18
|
+
throw new Error(`Missing context key: ${key}`);
|
|
19
|
+
return this.#data.get(key);
|
|
20
|
+
}
|
|
21
|
+
delete(key) {
|
|
22
|
+
this.#data.delete(key);
|
|
23
|
+
}
|
|
24
|
+
toJSON() {
|
|
25
|
+
const out = Object.create(null);
|
|
26
|
+
for (const [k, v] of this.#data)
|
|
27
|
+
out[k] = v;
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=RequestContext.js.map
|
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
import type RequestBag from "#request/RequestBag";
|
|
2
2
|
import type RequestBody from "#request/RequestBody";
|
|
3
|
-
import type Dict from "@rcompat/type
|
|
3
|
+
import type { Dict } from "@rcompat/type";
|
|
4
|
+
type RequestView = {
|
|
5
|
+
context: Dict;
|
|
6
|
+
cookies: Dict<string>;
|
|
7
|
+
headers: Dict<string>;
|
|
8
|
+
path: Dict<string>;
|
|
9
|
+
query: Dict<string>;
|
|
10
|
+
url: URL;
|
|
11
|
+
};
|
|
4
12
|
type RequestFacade = {
|
|
5
13
|
body: RequestBody;
|
|
6
|
-
context: Dict;
|
|
7
14
|
cookies: RequestBag;
|
|
8
15
|
forward(to: string, headers?: Dict<string>): Promise<Response>;
|
|
9
16
|
headers: RequestBag;
|
|
10
17
|
original: Request;
|
|
11
18
|
path: RequestBag;
|
|
12
19
|
query: RequestBag;
|
|
13
|
-
/**
|
|
14
|
-
* The request's pathname + querystring.
|
|
15
|
-
*/
|
|
16
20
|
target: string;
|
|
17
21
|
url: URL;
|
|
18
|
-
|
|
22
|
+
has(key: string): boolean;
|
|
23
|
+
try<T>(key: string): T | undefined;
|
|
24
|
+
get<T>(key: string): T;
|
|
25
|
+
set<T>(key: string, value: T | ((prev: T | undefined) => T)): RequestFacade;
|
|
26
|
+
delete(key: string): RequestFacade;
|
|
27
|
+
toJSON(): RequestView;
|
|
28
|
+
};
|
|
19
29
|
export { RequestFacade as default };
|
|
20
30
|
//# sourceMappingURL=RequestFacade.d.ts.map
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import RequestBag from "#request/RequestBag";
|
|
2
2
|
import RequestBody from "#request/RequestBody";
|
|
3
|
+
import RequestContext from "#request/RequestContext";
|
|
4
|
+
import sContext from "#request/sContext";
|
|
5
|
+
import is from "@rcompat/is";
|
|
3
6
|
function decode(s) {
|
|
4
7
|
try {
|
|
5
8
|
return decodeURIComponent(s);
|
|
@@ -9,14 +12,16 @@ function decode(s) {
|
|
|
9
12
|
}
|
|
10
13
|
}
|
|
11
14
|
;
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
function normalize(k) {
|
|
16
|
+
return k.toLowerCase();
|
|
17
|
+
}
|
|
18
|
+
function header_bag(request) {
|
|
14
19
|
const headers = Object.fromEntries([...request.headers].map(([k, v]) => [k.toLowerCase(), v]));
|
|
15
20
|
return new RequestBag(headers, "headers", {
|
|
16
21
|
normalize,
|
|
17
22
|
});
|
|
18
23
|
}
|
|
19
|
-
function
|
|
24
|
+
function cookie_bag(request) {
|
|
20
25
|
const header = request.headers.get("cookie");
|
|
21
26
|
const entries = Object.fromEntries(header
|
|
22
27
|
? header.split(";").map(s => s.trim()).filter(Boolean).map(s => {
|
|
@@ -30,23 +35,20 @@ function bagCookies(request) {
|
|
|
30
35
|
raw: header ?? "",
|
|
31
36
|
});
|
|
32
37
|
}
|
|
33
|
-
function
|
|
38
|
+
function query_bag(url) {
|
|
34
39
|
return new RequestBag(Object.fromEntries(url.searchParams), "query", {
|
|
35
40
|
normalize,
|
|
36
41
|
raw: url.search,
|
|
37
42
|
});
|
|
38
43
|
}
|
|
39
|
-
function
|
|
40
|
-
return new RequestBag(Object.create(null), "path", {
|
|
41
|
-
raw: url.pathname,
|
|
42
|
-
});
|
|
44
|
+
function path_bag(url) {
|
|
45
|
+
return new RequestBag(Object.create(null), "path", { raw: url.pathname });
|
|
43
46
|
}
|
|
44
|
-
|
|
47
|
+
function parse(request) {
|
|
45
48
|
const url = new URL(request.url);
|
|
46
|
-
|
|
49
|
+
const facade = {
|
|
47
50
|
body: RequestBody.none(),
|
|
48
|
-
|
|
49
|
-
cookies: bagCookies(request),
|
|
51
|
+
cookies: cookie_bag(request),
|
|
50
52
|
forward(to, headers) {
|
|
51
53
|
return fetch(to, {
|
|
52
54
|
body: request.body,
|
|
@@ -58,12 +60,48 @@ export default (request) => {
|
|
|
58
60
|
method: request.method,
|
|
59
61
|
});
|
|
60
62
|
},
|
|
61
|
-
headers:
|
|
63
|
+
headers: header_bag(request),
|
|
62
64
|
original: request,
|
|
63
|
-
path:
|
|
64
|
-
query:
|
|
65
|
+
path: path_bag(url),
|
|
66
|
+
query: query_bag(url),
|
|
65
67
|
target: url.pathname + url.search,
|
|
66
68
|
url,
|
|
69
|
+
has(key) {
|
|
70
|
+
return this[sContext].has(key);
|
|
71
|
+
},
|
|
72
|
+
try(key) {
|
|
73
|
+
return this[sContext].try(key);
|
|
74
|
+
},
|
|
75
|
+
get(key) {
|
|
76
|
+
return this[sContext].get(key);
|
|
77
|
+
},
|
|
78
|
+
set(key, value) {
|
|
79
|
+
if (is.function(value)) {
|
|
80
|
+
this[sContext].update(key, value);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this[sContext].set(key, value);
|
|
84
|
+
}
|
|
85
|
+
return this;
|
|
86
|
+
},
|
|
87
|
+
delete(key) {
|
|
88
|
+
this[sContext].delete(key);
|
|
89
|
+
return this;
|
|
90
|
+
},
|
|
91
|
+
toJSON() {
|
|
92
|
+
return {
|
|
93
|
+
context: this[sContext].toJSON(),
|
|
94
|
+
cookies: this.cookies.toJSON(),
|
|
95
|
+
headers: this.headers.toJSON(),
|
|
96
|
+
path: this.path.toJSON(),
|
|
97
|
+
query: this.query.toJSON(),
|
|
98
|
+
url: this.url,
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
[sContext]: new RequestContext(),
|
|
67
102
|
};
|
|
68
|
-
|
|
103
|
+
return facade;
|
|
104
|
+
}
|
|
105
|
+
;
|
|
106
|
+
export default parse;
|
|
69
107
|
//# sourceMappingURL=parse.js.map
|
|
@@ -1,28 +1,44 @@
|
|
|
1
|
+
import fail from "#fail";
|
|
1
2
|
import log from "#log";
|
|
2
3
|
import response_error from "#response/error";
|
|
3
4
|
import response_json from "#response/json";
|
|
4
5
|
import respond from "#response/respond";
|
|
5
|
-
import guard from "#route/guard";
|
|
6
6
|
import Status from "@rcompat/http/Status";
|
|
7
7
|
import ParseError from "pema/ParseError";
|
|
8
|
-
|
|
8
|
+
const result = (request, response) => ({ request, response });
|
|
9
|
+
function wrap_hook(h) {
|
|
10
|
+
return async (request, next) => {
|
|
11
|
+
let downstream;
|
|
12
|
+
let called_next = false;
|
|
13
|
+
const response = await h(request, async (r) => {
|
|
14
|
+
if (called_next)
|
|
15
|
+
throw fail("hook called next() more than once");
|
|
16
|
+
called_next = true;
|
|
17
|
+
downstream = await next(r);
|
|
18
|
+
return downstream.response;
|
|
19
|
+
});
|
|
20
|
+
// hook returned nothing
|
|
21
|
+
if (response === undefined) {
|
|
22
|
+
if (called_next) {
|
|
23
|
+
throw fail("hook called next() but did not return a result; did you forget `return next(request)`?");
|
|
24
|
+
}
|
|
25
|
+
throw fail("hook must return a response-like value or return next(request)");
|
|
26
|
+
}
|
|
27
|
+
// if the hook called next(), we preserve the downstream request (mutations) but
|
|
28
|
+
// allow the hook to override the response by returning something else.
|
|
29
|
+
return downstream !== undefined
|
|
30
|
+
? result(downstream.request, response)
|
|
31
|
+
: result(request, response);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async function run(hooks, request) {
|
|
9
35
|
const [first, ...rest] = hooks;
|
|
36
|
+
if (first === undefined)
|
|
37
|
+
return result(request, new Response());
|
|
10
38
|
if (rest.length === 0)
|
|
11
|
-
return
|
|
12
|
-
return
|
|
39
|
+
return first(request, async (r) => result(r, new Response()));
|
|
40
|
+
return first(request, r => run(rest, r));
|
|
13
41
|
}
|
|
14
|
-
;
|
|
15
|
-
// last, preserve final request form
|
|
16
|
-
function last(handler) {
|
|
17
|
-
return async (request) => {
|
|
18
|
-
const response = await handler(request);
|
|
19
|
-
return {
|
|
20
|
-
request,
|
|
21
|
-
response: response,
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
;
|
|
26
42
|
export default async function (app, partial_request) {
|
|
27
43
|
let errorRoute;
|
|
28
44
|
try {
|
|
@@ -30,12 +46,12 @@ export default async function (app, partial_request) {
|
|
|
30
46
|
if (route === undefined) {
|
|
31
47
|
return response_error()(app, {}, partial_request);
|
|
32
48
|
}
|
|
33
|
-
const { errors,
|
|
49
|
+
const { errors, hooks, layouts, handler } = route;
|
|
34
50
|
errorRoute = errors[0];
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const { request, response } = await
|
|
51
|
+
const module_hooks = app.modules.map(m => wrap_hook(m.route.bind(m)));
|
|
52
|
+
const route_hooks = hooks.map(wrap_hook);
|
|
53
|
+
const last = async (req, _next) => result(req, await handler(req));
|
|
54
|
+
const { request, response } = await run([...module_hooks, ...route_hooks, last], route.request);
|
|
39
55
|
return await respond(response)(app, {
|
|
40
56
|
layouts: await Promise.all(layouts.map(layout => layout(request))),
|
|
41
57
|
}, request);
|
|
@@ -11,7 +11,7 @@ const allowed = {
|
|
|
11
11
|
replacements: ["a-Z", "0-9", "-", "_", "+", "[", "]", "."],
|
|
12
12
|
text: "letters ({1}), digits ({2}), {3}, {4}, {5}, {6}, {7}",
|
|
13
13
|
};
|
|
14
|
-
const specials = ["
|
|
14
|
+
const specials = ["error", "hook", "layout"];
|
|
15
15
|
const _ = allowed.re.source.slice(1, -1);
|
|
16
16
|
const p = /^(?:[^[\]]+|\[(?:\.{3})?[a-zA-Z0-9_]+\]|\[\[(?:\.{3})?[a-zA-Z0-9_]+\]\])$/;
|
|
17
17
|
export default async (directory, extensions) => {
|
|
@@ -21,7 +21,7 @@ export default async (directory, extensions) => {
|
|
|
21
21
|
extensions,
|
|
22
22
|
specials: {
|
|
23
23
|
error: { recursive: false },
|
|
24
|
-
|
|
24
|
+
hook: { recursive: true },
|
|
25
25
|
layout: { recursive: true },
|
|
26
26
|
},
|
|
27
27
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type View from "#frontend/View";
|
|
2
2
|
import type RequestFacade from "#request/RequestFacade";
|
|
3
3
|
import type ServeApp from "#serve/App";
|
|
4
|
-
import type Dict from "@rcompat/type
|
|
5
|
-
import type MaybePromise from "@rcompat/type/MaybePromise";
|
|
4
|
+
import type { Dict, MaybePromise } from "@rcompat/type";
|
|
6
5
|
type ResponseFunction = (app: ServeApp, transfer: Dict, request: RequestFacade) => MaybePromise<View | null | Response | undefined>;
|
|
7
6
|
export { ResponseFunction as default };
|
|
8
7
|
//# sourceMappingURL=ResponseFunction.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type ResponseFunction from "#response/ResponseFunction";
|
|
2
2
|
import type Streamable from "@rcompat/fs/Streamable";
|
|
3
|
-
import type Dict from "@rcompat/type
|
|
3
|
+
import type { Dict } from "@rcompat/type";
|
|
4
4
|
type ResponseLike = string | Dict | Dict[] | URL | Blob | ReadableStream | Streamable | Response | ResponseFunction | null;
|
|
5
5
|
export { ResponseLike as default };
|
|
6
6
|
//# sourceMappingURL=ResponseLike.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Streamable from "@rcompat/fs/Streamable";
|
|
2
|
-
import
|
|
2
|
+
import MIME from "@rcompat/http/mime";
|
|
3
|
+
import is from "@rcompat/is";
|
|
3
4
|
const encodeRFC5987 = (s) => encodeURIComponent(s).replace(/['()*]/g, c => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
4
5
|
/**
|
|
5
6
|
* @security
|
|
@@ -30,11 +31,11 @@ function toContentDisposition(filename) {
|
|
|
30
31
|
*/
|
|
31
32
|
export default function binary(source, init) {
|
|
32
33
|
return (app) => {
|
|
33
|
-
const { headers, ...rest } = app.media(
|
|
34
|
+
const { headers, ...rest } = app.media(MIME.APPLICATION_OCTET_STREAM, init);
|
|
34
35
|
const name = Streamable.named(source) ? source.name : "default.bin";
|
|
35
36
|
const out = new Headers(headers);
|
|
36
37
|
out.set("Content-Disposition", toContentDisposition(name));
|
|
37
|
-
if (source
|
|
38
|
+
if (is.blob(source)) {
|
|
38
39
|
source.type && out.set("Content-Type", source.type);
|
|
39
40
|
out.set("Content-Length", String(source.size));
|
|
40
41
|
}
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* @param options response options
|
|
5
5
|
* @return Response rendering function
|
|
6
6
|
*/
|
|
7
|
-
declare const _default: (body: unknown, init?: ResponseInit) => (app: import("../serve/App.js").default) => import("@rcompat/type
|
|
7
|
+
declare const _default: (body: unknown, init?: ResponseInit) => (app: import("../serve/App.js").default) => import("@rcompat/type").MaybePromise<Response>;
|
|
8
8
|
export default _default;
|
|
9
9
|
//# sourceMappingURL=json.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import response from "#response";
|
|
2
|
-
import
|
|
2
|
+
import MIME from "@rcompat/http/mime";
|
|
3
3
|
/**
|
|
4
4
|
* Issue a JSON response
|
|
5
5
|
* @param body body object
|
|
6
6
|
* @param options response options
|
|
7
7
|
* @return Response rendering function
|
|
8
8
|
*/
|
|
9
|
-
export default response(
|
|
9
|
+
export default response(MIME.APPLICATION_JSON, JSON.stringify);
|
|
10
10
|
//# sourceMappingURL=json.js.map
|
|
@@ -5,25 +5,22 @@ import redirect from "#response/redirect";
|
|
|
5
5
|
import text from "#response/text";
|
|
6
6
|
import Streamable from "@rcompat/fs/Streamable";
|
|
7
7
|
import Status from "@rcompat/http/Status";
|
|
8
|
-
import
|
|
8
|
+
import is from "@rcompat/is";
|
|
9
9
|
function invalid_body(body) {
|
|
10
10
|
throw fail("invalid body {0} returned from route", body);
|
|
11
11
|
}
|
|
12
|
-
const is_instance = (of) => ((value) => value instanceof of);
|
|
13
|
-
const is_response = is_instance(Response);
|
|
14
|
-
const is_url = is_instance(URL);
|
|
15
|
-
const is_null = (value) => value === null;
|
|
16
12
|
function match(m) {
|
|
17
13
|
return m;
|
|
18
14
|
}
|
|
19
15
|
// [if, then]
|
|
20
16
|
const guesses = match([
|
|
21
|
-
[
|
|
22
|
-
[
|
|
17
|
+
[is.null, () => () => new Response(null, { status: Status.NO_CONTENT })],
|
|
18
|
+
[is.url, value => redirect(value.toString())],
|
|
23
19
|
[Streamable.is, value => binary(value)],
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
20
|
+
[is.response, value => _ => value],
|
|
21
|
+
[is.dict, json],
|
|
22
|
+
[is.array, json],
|
|
23
|
+
[is.string, text],
|
|
27
24
|
]);
|
|
28
25
|
const guess = (value) => guesses.find(([_if]) => _if(value))?.[1](value)
|
|
29
26
|
?? invalid_body(`${value}`);
|
|
@@ -10,6 +10,6 @@ type Body = {
|
|
|
10
10
|
* @param options response options
|
|
11
11
|
* @return Response rendering function
|
|
12
12
|
*/
|
|
13
|
-
declare const _default: (body: Body, init?: ResponseInit) => (app: import("../serve/App.js").default) => import("@rcompat/type
|
|
13
|
+
declare const _default: (body: Body, init?: ResponseInit) => (app: import("../serve/App.js").default) => import("@rcompat/type").MaybePromise<Response>;
|
|
14
14
|
export default _default;
|
|
15
15
|
//# sourceMappingURL=sse.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import response from "#response";
|
|
2
|
-
import
|
|
2
|
+
import MIME from "@rcompat/http/mime";
|
|
3
3
|
const encode = (input) => new TextEncoder().encode(input);
|
|
4
4
|
const handle = (body) => new ReadableStream({
|
|
5
5
|
cancel() {
|
|
@@ -21,5 +21,5 @@ const handle = (body) => new ReadableStream({
|
|
|
21
21
|
* @param options response options
|
|
22
22
|
* @return Response rendering function
|
|
23
23
|
*/
|
|
24
|
-
export default response(
|
|
24
|
+
export default response(MIME.TEXT_EVENT_STREAM, handle);
|
|
25
25
|
//# sourceMappingURL=sse.js.map
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* @param options response options
|
|
5
5
|
* @return Response rendering function
|
|
6
6
|
*/
|
|
7
|
-
declare const _default: (body: string, init?: ResponseInit) => (app: import("../serve/App.js").default) => import("@rcompat/type
|
|
7
|
+
declare const _default: (body: string, init?: ResponseInit) => (app: import("../serve/App.js").default) => import("@rcompat/type").MaybePromise<Response>;
|
|
8
8
|
export default _default;
|
|
9
9
|
//# sourceMappingURL=text.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import response from "#response";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import fn from "@rcompat/fn";
|
|
3
|
+
import MIME from "@rcompat/http/mime";
|
|
4
4
|
/**
|
|
5
5
|
* Return a plaintext response
|
|
6
6
|
* @param body plaintext body
|
|
7
7
|
* @param options response options
|
|
8
8
|
* @return Response rendering function
|
|
9
9
|
*/
|
|
10
|
-
export default response(
|
|
10
|
+
export default response(MIME.TEXT_PLAIN, fn.identity);
|
|
11
11
|
//# sourceMappingURL=text.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type ViewOptions from "#frontend/ViewOptions";
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
2
|
+
import type ResponseFunction from "#response/ResponseFunction";
|
|
3
|
+
import type { Dict } from "@rcompat/type";
|
|
4
4
|
declare function view<Props>(component: (props: Props) => any, props: Props, options?: ViewOptions): ResponseFunction;
|
|
5
5
|
declare function view(component: () => any, props?: Dict, options?: ViewOptions): ResponseFunction;
|
|
6
6
|
declare function view(name: string, props?: Dict, options?: ViewOptions): ResponseFunction;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fail from "#fail";
|
|
2
|
-
import
|
|
2
|
+
import fs from "@rcompat/fs";
|
|
3
3
|
const extensions = ["extension", "fullExtension"];
|
|
4
4
|
const backmap = {
|
|
5
5
|
"component.ts": "angular",
|
|
@@ -18,7 +18,7 @@ const backmap = {
|
|
|
18
18
|
jsx: "react",
|
|
19
19
|
};
|
|
20
20
|
function no_frontend(view) {
|
|
21
|
-
const extension =
|
|
21
|
+
const extension = fs.ref(view).fullExtension.slice(1);
|
|
22
22
|
const hasPkg = extension in backmap;
|
|
23
23
|
const error = "No frontend for {0}";
|
|
24
24
|
const fix = hasPkg ? ", did you configure {1}?" : "";
|
|
@@ -36,7 +36,7 @@ function view(name, props, options) {
|
|
|
36
36
|
const _name = name;
|
|
37
37
|
return async (app, transfer, request) => {
|
|
38
38
|
const found_view = extensions
|
|
39
|
-
.map(extension => app.frontends[
|
|
39
|
+
.map(extension => app.frontends[fs.ref(_name)[extension]])
|
|
40
40
|
.find(extension => extension !== undefined)?.(_name, props, options)(app, transfer, request);
|
|
41
41
|
if (found_view !== undefined)
|
|
42
42
|
return found_view;
|