@primate/core 0.4.6 → 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 +11 -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,195 +0,0 @@
|
|
|
1
|
-
import encodeString from "#wasm/encode-string";
|
|
2
|
-
import encodeStringMap from "#wasm/encode-string-map";
|
|
3
|
-
import encodeURL from "#wasm/encode-url";
|
|
4
|
-
import filesize from "#wasm/filesize";
|
|
5
|
-
import I32_SIZE from "#wasm/I32_SIZE";
|
|
6
|
-
import stringSize from "#wasm/stringsize";
|
|
7
|
-
import urlSize from "#wasm/urlsize";
|
|
8
|
-
import BufferView from "@rcompat/bufferview";
|
|
9
|
-
import encodeBuffer from "./encode-buffer.js";
|
|
10
|
-
const SECTION_HEADER_SIZE = I32_SIZE;
|
|
11
|
-
const URL_SECTION = 0;
|
|
12
|
-
const BODY_SECTION = 1;
|
|
13
|
-
const PATH_SECTION = 2;
|
|
14
|
-
const QUERY_SECTION = 3;
|
|
15
|
-
const HEADERS_SECTION = 4;
|
|
16
|
-
const COOKIES_SECTION = 5;
|
|
17
|
-
const BODY_KIND_NULL = 0;
|
|
18
|
-
const BODY_KIND_TEXT = 1;
|
|
19
|
-
const BODY_KIND_FORM = 2;
|
|
20
|
-
const BODY_KIND_BINARY = 3;
|
|
21
|
-
const BODY_KIND_JSON = 4;
|
|
22
|
-
const BODY_KIND_MAP_VALUE_STRING = 0;
|
|
23
|
-
const BODY_KIND_MAP_VALUE_BLOB = 1;
|
|
24
|
-
const sizeOfUrlSection = (url) => SECTION_HEADER_SIZE + urlSize(url);
|
|
25
|
-
const sizeOfBodySection = (body) => {
|
|
26
|
-
let size = SECTION_HEADER_SIZE + I32_SIZE;
|
|
27
|
-
if (body.type === "none")
|
|
28
|
-
return size; // 0 kind null
|
|
29
|
-
if (body.type === "text")
|
|
30
|
-
return size + stringSize(body.text());
|
|
31
|
-
if (body.type === "form") {
|
|
32
|
-
size += I32_SIZE; // entry count
|
|
33
|
-
for (const [key, value] of Object.entries(body.form())) {
|
|
34
|
-
size += stringSize(key);
|
|
35
|
-
size += I32_SIZE; // value kind
|
|
36
|
-
size += stringSize(value);
|
|
37
|
-
}
|
|
38
|
-
for (const [key, value] of Object.entries(body.files())) {
|
|
39
|
-
size += stringSize(key);
|
|
40
|
-
size += I32_SIZE; // value kind
|
|
41
|
-
size += filesize(value);
|
|
42
|
-
}
|
|
43
|
-
return size;
|
|
44
|
-
}
|
|
45
|
-
if (body.type === "binary") {
|
|
46
|
-
const bin = body.binary();
|
|
47
|
-
size += stringSize(bin.type);
|
|
48
|
-
size += I32_SIZE + bin.size;
|
|
49
|
-
return size;
|
|
50
|
-
}
|
|
51
|
-
const json = body.json();
|
|
52
|
-
size += stringSize(JSON.stringify(json));
|
|
53
|
-
return size;
|
|
54
|
-
throw new Error("Invalid RequestLike body");
|
|
55
|
-
};
|
|
56
|
-
const sizeOfMapSection = (map) => {
|
|
57
|
-
let size = SECTION_HEADER_SIZE + I32_SIZE;
|
|
58
|
-
for (const [key, value] of Object.entries(map)) {
|
|
59
|
-
if (value) {
|
|
60
|
-
size += stringSize(key) + stringSize(value);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return size;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Encode a map of Key Value pairs into a section.
|
|
67
|
-
*
|
|
68
|
-
* - [I32: header]
|
|
69
|
-
* - [I32: count]
|
|
70
|
-
* - Entries[count]:
|
|
71
|
-
* - [String: key]
|
|
72
|
-
* - [String: value]
|
|
73
|
-
*
|
|
74
|
-
* @param header - The header for this section.
|
|
75
|
-
* @param map - The map itself to be encoded.
|
|
76
|
-
* @param offset - The offset to encode the map at.
|
|
77
|
-
* @param view - The buffer view to encode the map into.
|
|
78
|
-
*/
|
|
79
|
-
const encodeMapSection = (header, map, view) => {
|
|
80
|
-
view.writeU32(header);
|
|
81
|
-
return encodeStringMap(map, view);
|
|
82
|
-
};
|
|
83
|
-
const encodeBlob = async (file, view) => {
|
|
84
|
-
const type = file.type;
|
|
85
|
-
const bytes = await file.bytes();
|
|
86
|
-
encodeString(type, view);
|
|
87
|
-
encodeBuffer(bytes, view);
|
|
88
|
-
};
|
|
89
|
-
const encodeFile = async (file, view) => {
|
|
90
|
-
const name = file.name;
|
|
91
|
-
const type = file.type;
|
|
92
|
-
const bytes = await file.bytes();
|
|
93
|
-
encodeString(name, view);
|
|
94
|
-
encodeString(type, view);
|
|
95
|
-
view.writeU32(bytes.byteLength);
|
|
96
|
-
view.writeBytes(bytes);
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* 1. Section 1: URI
|
|
100
|
-
* - [Section Header: 0] 4 bytes
|
|
101
|
-
* - [I32: length] 4 bytes
|
|
102
|
-
* - [...payload] length bytes
|
|
103
|
-
*/
|
|
104
|
-
const encodeSectionUrl = (url, view) => {
|
|
105
|
-
view.writeU32(URL_SECTION);
|
|
106
|
-
encodeURL(url, view);
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* 2. Section 2: Body
|
|
110
|
-
* - [Section Header: 1] 4 bytes
|
|
111
|
-
* - [kind: I32] 4 bytes
|
|
112
|
-
* - 0: Null
|
|
113
|
-
* - [I32: kind = 0] 4 bytes
|
|
114
|
-
* - 1: String
|
|
115
|
-
* - [I32: kind = 1] 4 bytes
|
|
116
|
-
* - [I32: length] 4 bytes
|
|
117
|
-
* - [...payload] length bytes
|
|
118
|
-
* - 2: Map<string, string | file>
|
|
119
|
-
* - [I32: kind = 2] 4 bytes
|
|
120
|
-
* - [I32: count] 4 bytes
|
|
121
|
-
* - [String, String | FileDescriptor]
|
|
122
|
-
* - [I32: key length]
|
|
123
|
-
* - [...key payload]
|
|
124
|
-
* - [I32: value kind] 4 bytes
|
|
125
|
-
* - 0: String
|
|
126
|
-
* - [I32: value kind = 0] 4 bytes
|
|
127
|
-
* - [I32: value length] 4 bytes
|
|
128
|
-
* - [...value payload] value length bytes
|
|
129
|
-
* - 1: File
|
|
130
|
-
* - [I32: value kind = 1] 4 bytes
|
|
131
|
-
* - [I32: file_descriptor] 4 bytes
|
|
132
|
-
*/
|
|
133
|
-
const encodeSectionBody = async (body, view) => {
|
|
134
|
-
view.writeU32(BODY_SECTION);
|
|
135
|
-
if (body.type === "text") {
|
|
136
|
-
const text = body.text();
|
|
137
|
-
view.writeU32(BODY_KIND_TEXT);
|
|
138
|
-
encodeString(text, view);
|
|
139
|
-
}
|
|
140
|
-
else if (body.type === "form") {
|
|
141
|
-
const entries = Object.entries(body.form());
|
|
142
|
-
view.writeU32(BODY_KIND_FORM);
|
|
143
|
-
view.writeU32(entries.length);
|
|
144
|
-
for (const [key, value] of entries) {
|
|
145
|
-
encodeString(key, view);
|
|
146
|
-
view.writeU32(BODY_KIND_MAP_VALUE_STRING);
|
|
147
|
-
encodeString(value, view);
|
|
148
|
-
}
|
|
149
|
-
for (const [key, value] of Object.entries(body.files())) {
|
|
150
|
-
encodeString(key, view);
|
|
151
|
-
view.writeU32(BODY_KIND_MAP_VALUE_BLOB);
|
|
152
|
-
await encodeFile(value, view);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
else if (body.type === "binary") {
|
|
156
|
-
view.writeU32(BODY_KIND_BINARY);
|
|
157
|
-
await encodeBlob(body.binary(), view);
|
|
158
|
-
}
|
|
159
|
-
else if (body.type === "json") {
|
|
160
|
-
view.writeU32(BODY_KIND_JSON);
|
|
161
|
-
const jsonText = JSON.stringify(body.json());
|
|
162
|
-
encodeString(jsonText, view);
|
|
163
|
-
}
|
|
164
|
-
else if (body.type === "none") {
|
|
165
|
-
view.writeU32(BODY_KIND_NULL);
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
throw new Error(`Unsupported body type: ${body?.type ?? typeof body}`);
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
const sizeOfRequest = (request) => sizeOfUrlSection(request.url)
|
|
172
|
-
+ sizeOfBodySection(request.body)
|
|
173
|
-
+ sizeOfMapSection(request.path.toJSON())
|
|
174
|
-
+ sizeOfMapSection(request.query.toJSON())
|
|
175
|
-
+ sizeOfMapSection(request.headers.toJSON())
|
|
176
|
-
+ sizeOfMapSection(request.cookies.toJSON());
|
|
177
|
-
const encodeRequestInto = async (request, view) => {
|
|
178
|
-
encodeSectionUrl(request.url, view);
|
|
179
|
-
await encodeSectionBody(request.body, view);
|
|
180
|
-
encodeMapSection(PATH_SECTION, request.path.toJSON(), view);
|
|
181
|
-
encodeMapSection(QUERY_SECTION, request.query.toJSON(), view);
|
|
182
|
-
encodeMapSection(HEADERS_SECTION, request.headers.toJSON(), view);
|
|
183
|
-
encodeMapSection(COOKIES_SECTION, request.cookies.toJSON(), view);
|
|
184
|
-
};
|
|
185
|
-
const encodeRequest = async (request) => {
|
|
186
|
-
const size = sizeOfRequest(request);
|
|
187
|
-
const output = new Uint8Array(size);
|
|
188
|
-
const bufferView = new BufferView(output);
|
|
189
|
-
await encodeRequestInto(request, bufferView);
|
|
190
|
-
return output;
|
|
191
|
-
};
|
|
192
|
-
encodeRequest.sizeOf = sizeOfRequest;
|
|
193
|
-
encodeRequest.into = encodeRequestInto;
|
|
194
|
-
export default encodeRequest;
|
|
195
|
-
//# sourceMappingURL=encode-request.js.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import encodeString from "#wasm/encode-string";
|
|
2
|
-
import I32_SIZE from "#wasm/I32_SIZE";
|
|
3
|
-
import stringSize from "#wasm/stringsize";
|
|
4
|
-
import BufferView from "@rcompat/bufferview";
|
|
5
|
-
export default function encodeSession(session) {
|
|
6
|
-
if (session.exists) {
|
|
7
|
-
const data = JSON.stringify(session.get());
|
|
8
|
-
const dataSize = stringSize(data);
|
|
9
|
-
const idSize = stringSize(session.id ?? "");
|
|
10
|
-
const size = dataSize // data payload
|
|
11
|
-
+ I32_SIZE // new flat
|
|
12
|
-
+ idSize; // id payload
|
|
13
|
-
const output = new Uint8Array(size);
|
|
14
|
-
const bufferView = new BufferView(output);
|
|
15
|
-
bufferView.writeU32(1);
|
|
16
|
-
encodeString(session.id ?? "", bufferView);
|
|
17
|
-
encodeString(data, bufferView);
|
|
18
|
-
return output;
|
|
19
|
-
}
|
|
20
|
-
// does not exist (only 0s)
|
|
21
|
-
const buffer = new Uint8Array(4);
|
|
22
|
-
return buffer;
|
|
23
|
-
}
|
|
24
|
-
;
|
|
25
|
-
//# sourceMappingURL=encode-session.js.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type BufferView from "@rcompat/bufferview";
|
|
2
|
-
import type PartialDict from "@rcompat/type/PartialDict";
|
|
3
|
-
declare const encodeStringMap: (map: PartialDict<string>, view: BufferView) => void;
|
|
4
|
-
export default encodeStringMap;
|
|
5
|
-
//# sourceMappingURL=encode-string-map.d.ts.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import encodeString from "#wasm/encode-string";
|
|
2
|
-
const encodeStringMap = (map, view) => {
|
|
3
|
-
// only "set" entries are allowed
|
|
4
|
-
const entries = Object.entries(map)
|
|
5
|
-
.filter(([, value]) => value && value.length > 0);
|
|
6
|
-
const count = entries.length;
|
|
7
|
-
view.writeU32(count);
|
|
8
|
-
for (const [key, value] of entries) {
|
|
9
|
-
encodeString(key, view);
|
|
10
|
-
encodeString(value, view);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
export default encodeStringMap;
|
|
14
|
-
//# sourceMappingURL=encode-string-map.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type BufferView from "@rcompat/bufferview";
|
|
2
|
-
/**
|
|
3
|
-
* Encoding a string has the following format:
|
|
4
|
-
* - I32: length
|
|
5
|
-
* - U8[length]: bytes
|
|
6
|
-
*
|
|
7
|
-
* @param string - The string to encode
|
|
8
|
-
* @param offset - The offset to encode the string at.
|
|
9
|
-
* @param view - The buffer view to encode the string into.
|
|
10
|
-
* @returns The next offset.
|
|
11
|
-
*/
|
|
12
|
-
export default function encodeString(string: string, view: BufferView): void;
|
|
13
|
-
//# sourceMappingURL=encode-string.d.ts.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import utf8size from "@rcompat/string/utf8size";
|
|
2
|
-
/**
|
|
3
|
-
* Encoding a string has the following format:
|
|
4
|
-
* - I32: length
|
|
5
|
-
* - U8[length]: bytes
|
|
6
|
-
*
|
|
7
|
-
* @param string - The string to encode
|
|
8
|
-
* @param offset - The offset to encode the string at.
|
|
9
|
-
* @param view - The buffer view to encode the string into.
|
|
10
|
-
* @returns The next offset.
|
|
11
|
-
*/
|
|
12
|
-
export default function encodeString(string, view) {
|
|
13
|
-
view.writeU32(utf8size(string))
|
|
14
|
-
.write(string);
|
|
15
|
-
}
|
|
16
|
-
;
|
|
17
|
-
//# sourceMappingURL=encode-string.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type BufferView from "@rcompat/bufferview";
|
|
2
|
-
/**
|
|
3
|
-
* Encode a url as a string into a bufferView.
|
|
4
|
-
*
|
|
5
|
-
* @param url - The url to encode.
|
|
6
|
-
* @param offset - The offset to encode the url at.
|
|
7
|
-
* @param view - The buffer view to encode the url into.
|
|
8
|
-
* @returns The next offset.
|
|
9
|
-
*/
|
|
10
|
-
export default function encodeURL(url: URL, view: BufferView): void;
|
|
11
|
-
//# sourceMappingURL=encode-url.d.ts.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import encodeString from "#wasm/encode-string";
|
|
2
|
-
/**
|
|
3
|
-
* Encode a url as a string into a bufferView.
|
|
4
|
-
*
|
|
5
|
-
* @param url - The url to encode.
|
|
6
|
-
* @param offset - The offset to encode the url at.
|
|
7
|
-
* @param view - The buffer view to encode the url into.
|
|
8
|
-
* @returns The next offset.
|
|
9
|
-
*/
|
|
10
|
-
export default function encodeURL(url, view) {
|
|
11
|
-
return encodeString(url.toString(), view);
|
|
12
|
-
}
|
|
13
|
-
;
|
|
14
|
-
//# sourceMappingURL=encode-url.js.map
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import buffersize from "#wasm/buffersize";
|
|
2
|
-
import encodeBuffer from "#wasm/encode-buffer";
|
|
3
|
-
import encodeString from "#wasm/encode-string";
|
|
4
|
-
import I32_SIZE from "#wasm/I32_SIZE";
|
|
5
|
-
import stringSize from "#wasm/stringsize";
|
|
6
|
-
import BufferView from "@rcompat/bufferview";
|
|
7
|
-
const SIZE_I64 = BigInt64Array.BYTES_PER_ELEMENT;
|
|
8
|
-
const WEBSOCKET_MESSAGE_KIND_STRING = 0;
|
|
9
|
-
const WEBSOCKET_MESSAGE_KIND_BYTES = 1;
|
|
10
|
-
export default function encodeWebsocketMessage(id, message) {
|
|
11
|
-
const size = SIZE_I64 // WebsocketID
|
|
12
|
-
+ I32_SIZE // Kind
|
|
13
|
-
+ (typeof message === "string"
|
|
14
|
-
? stringSize(message)
|
|
15
|
-
: buffersize(message));
|
|
16
|
-
const output = new Uint8Array(size);
|
|
17
|
-
const bufferView = new BufferView(output);
|
|
18
|
-
bufferView.writeU64(id);
|
|
19
|
-
if (typeof message === "string") {
|
|
20
|
-
bufferView.writeU32(WEBSOCKET_MESSAGE_KIND_STRING);
|
|
21
|
-
encodeString(message, bufferView);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
bufferView.writeU32(WEBSOCKET_MESSAGE_KIND_BYTES);
|
|
25
|
-
encodeBuffer(message, bufferView);
|
|
26
|
-
}
|
|
27
|
-
return output;
|
|
28
|
-
}
|
|
29
|
-
;
|
|
30
|
-
//# sourceMappingURL=encode-websocket-message.js.map
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type DatabaseStore from "#database/Store";
|
|
2
|
-
import type API from "#wasm/API";
|
|
3
|
-
import type Instantiation from "#wasm/Instantiation";
|
|
4
|
-
import type Tagged from "#wasm/Tagged";
|
|
5
|
-
import MaybePromise from "@rcompat/type/MaybePromise";
|
|
6
|
-
import StoreSchema from "pema/StoreSchema";
|
|
7
|
-
type Init = {
|
|
8
|
-
filename: string;
|
|
9
|
-
imports?: WebAssembly.Imports;
|
|
10
|
-
stores: Record<string, DatabaseStore<StoreSchema>>;
|
|
11
|
-
};
|
|
12
|
-
export type { API };
|
|
13
|
-
export type AnyWasmValue = number | bigint | Tagged<"Request", number>;
|
|
14
|
-
export type AnyWasmReturnValue = MaybePromise<AnyWasmValue | undefined | void>;
|
|
15
|
-
export type AnyWasmFunction<Args extends readonly AnyWasmValue[], R extends AnyWasmReturnValue> = (...args: Args) => R;
|
|
16
|
-
export declare const wrapPromising: <Args extends readonly AnyWasmValue[], R extends AnyWasmReturnValue>(fn: AnyWasmFunction<Args, R>) => AnyWasmFunction<Args, R>;
|
|
17
|
-
export declare const wrapSuspending: <Args extends readonly AnyWasmValue[], R extends AnyWasmReturnValue>(fn: AnyWasmFunction<Args, R>, alt: AnyWasmFunction<Args, R>) => WebAssembly.ImportValue;
|
|
18
|
-
declare global {
|
|
19
|
-
namespace WebAssembly {
|
|
20
|
-
const promising: undefined | (<Args extends readonly AnyWasmValue[], R extends AnyWasmReturnValue>(fn: AnyWasmFunction<Args, R>) => AnyWasmFunction<Args, R>);
|
|
21
|
-
class Suspending<T> {
|
|
22
|
-
constructor(fn: T);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Instantiate a WASM module from a file reference and the given web assembly
|
|
28
|
-
* imports.
|
|
29
|
-
*
|
|
30
|
-
* @param ref The file reference to the WASM module.
|
|
31
|
-
* @param imports The imports to pass to the WASM module when instantiating it.
|
|
32
|
-
* @returns The instantiated WASM module, its exports, and the API that Primate
|
|
33
|
-
* exposes to the WASM module.
|
|
34
|
-
*/
|
|
35
|
-
declare const instantiate: (args: Init) => Promise<Instantiation<number, number>>;
|
|
36
|
-
export default instantiate;
|
|
37
|
-
//# sourceMappingURL=instantiate.d.ts.map
|