@primate/core 0.4.6 → 0.6.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 +771 -6
- package/lib/private/App.js +49 -16
- package/lib/private/Binder.d.ts +2 -2
- package/lib/private/Flags.d.ts +8 -4
- package/lib/private/Module.d.ts +4 -16
- package/lib/private/Module.js +1 -17
- package/lib/private/app/EnvSchema.d.ts +5 -0
- package/lib/private/app/EnvSchema.js +2 -0
- package/lib/private/app/Facade.browser.d.ts +11 -0
- package/lib/private/app/Facade.browser.js +19 -0
- package/lib/private/app/Facade.d.ts +811 -0
- package/lib/private/app/Facade.js +56 -0
- package/lib/private/asset/Asset.d.ts +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 +19 -10
- package/lib/private/build/client/plugin/app-request.d.ts +4 -0
- package/lib/private/build/client/plugin/app-request.js +19 -0
- package/lib/private/build/client/plugin/view.d.ts +4 -0
- package/lib/private/build/client/plugin/view.js +13 -0
- package/lib/private/build/hook.d.ts +1 -2
- package/lib/private/build/hook.js +25 -19
- package/lib/private/build/index.d.ts +2 -1
- package/lib/private/build/index.js +27 -27
- package/lib/private/build/presets.d.ts +10 -0
- package/lib/private/build/presets.js +39 -0
- package/lib/private/build/server/index.js +10 -14
- package/lib/private/build/server/plugin/app-request.d.ts +4 -0
- package/lib/private/build/server/plugin/app-request.js +19 -0
- 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/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} +12 -12
- package/lib/private/build/server/plugin/native-addons.js +10 -11
- package/lib/private/build/server/plugin/node-imports.js +2 -2
- package/lib/private/build/server/plugin/route.js +4 -4
- package/lib/private/build/server/plugin/store.js +11 -33
- package/lib/private/build/server/plugin/stores.js +12 -9
- package/lib/private/build/server/plugin/view.js +5 -5
- 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/build/shared/plugin/app-request.d.ts +4 -0
- package/lib/private/build/shared/plugin/app-request.js +19 -0
- package/lib/private/bye.js +2 -3
- package/lib/private/client/Data.d.ts +3 -2
- package/lib/private/client/Render.d.ts +8 -0
- package/lib/private/{frontend → client}/ServerData.d.ts +1 -1
- package/lib/private/client/ServerView.d.ts +4 -0
- package/lib/private/client/ValidateInit.d.ts +1 -3
- package/lib/private/client/ValidationError.d.ts +1 -1
- package/lib/private/{frontend → client}/View.d.ts +1 -1
- package/lib/private/{frontend → client}/ViewOptions.d.ts +1 -1
- package/lib/private/{frontend → client}/ViewResponse.d.ts +2 -2
- package/lib/private/client/app.js +3 -3
- package/lib/private/client/boot.d.ts +5 -0
- package/lib/private/client/boot.js +64 -0
- package/lib/private/client/create-form.d.ts +32 -0
- package/lib/private/client/create-form.js +123 -0
- package/lib/private/client/extract-issues.d.ts +4 -0
- package/lib/private/client/extract-issues.js +21 -0
- package/lib/private/client/http.d.ts +13 -0
- package/lib/private/client/http.js +57 -0
- package/lib/private/client/index.d.ts +23 -0
- package/lib/private/client/index.js +16 -0
- package/lib/private/client/navigate.d.ts +13 -0
- package/lib/private/client/navigate.js +67 -0
- package/lib/private/client/root.d.ts +9 -0
- package/lib/private/client/root.js +11 -0
- package/lib/private/client/submit.d.ts +2 -0
- package/lib/private/client/submit.js +41 -0
- 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 +7 -21
- package/lib/private/config/index.js +4 -1
- package/lib/private/config/schema.d.ts +82 -22
- package/lib/private/config/schema.js +25 -7
- package/lib/private/cookie.d.ts +12 -6
- package/lib/private/cookie.js +10 -14
- package/lib/private/db/As.d.ts +10 -0
- package/lib/private/db/DB.d.ts +49 -0
- package/lib/private/db/DB.js +3 -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 +33 -0
- package/lib/private/db/MemoryDB.js +335 -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 +25 -0
- package/lib/private/db/common.js +67 -0
- package/lib/private/db/errors.d.ts +104 -0
- package/lib/private/db/errors.js +237 -0
- package/lib/private/db/migrate/apply.d.ts +2 -0
- package/lib/private/db/migrate/apply.js +32 -0
- package/lib/private/db/migrate/bundle.d.ts +3 -0
- package/lib/private/db/migrate/bundle.js +22 -0
- package/lib/private/db/migrate/create.d.ts +2 -0
- package/lib/private/db/migrate/create.js +154 -0
- package/lib/private/db/migrate/index.d.ts +10 -0
- package/lib/private/db/migrate/index.js +6 -0
- package/lib/private/db/migrate/status.d.ts +2 -0
- package/lib/private/db/migrate/status.js +38 -0
- package/lib/private/db/migrate/store.d.ts +5 -0
- package/lib/private/db/migrate/store.js +33 -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.js +2 -0
- package/lib/private/db/test.d.ts +4 -0
- package/lib/private/db/test.js +1750 -0
- package/lib/private/errors.d.ts +88 -0
- package/lib/private/errors.js +211 -0
- package/lib/private/frontend.d.ts +72 -0
- package/lib/private/frontend.js +245 -0
- package/lib/private/hash.js +0 -1
- package/lib/private/i18n/Catalog.d.ts +5 -2
- package/lib/private/i18n/Formatter.js +21 -9
- package/lib/private/i18n/errors.d.ts +16 -0
- package/lib/private/i18n/errors.js +27 -0
- 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/module.d.ts +3 -0
- package/lib/private/i18n/module.js +115 -0
- 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 +10 -5
- 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 +19 -0
- package/lib/private/index.d.ts +14 -0
- package/lib/private/index.js +2 -0
- package/lib/private/log.d.ts +1 -0
- package/lib/private/log.js +15 -14
- package/lib/private/module/Hook.d.ts +1 -1
- package/lib/private/module/Next.d.ts +1 -1
- package/lib/private/module/Setup.d.ts +21 -0
- package/lib/private/module/Setup.js +2 -0
- package/lib/private/module/create.d.ts +16 -0
- package/lib/private/module/create.js +28 -0
- package/lib/private/orm/ExtractSchema.d.ts +9 -0
- package/lib/private/orm/ExtractSchema.js +2 -0
- package/lib/private/orm/ForeignKey.d.ts +14 -0
- package/lib/private/orm/ForeignKey.js +25 -0
- package/lib/private/orm/PrimaryKey.d.ts +17 -0
- package/lib/private/orm/PrimaryKey.js +38 -0
- package/lib/private/orm/StoreInput.d.ts +10 -0
- package/lib/private/orm/StoreInput.js +2 -0
- package/lib/private/orm/key.d.ts +8 -0
- package/lib/private/orm/key.js +8 -0
- package/lib/private/orm/parse.d.ts +13 -0
- package/lib/private/orm/parse.js +29 -0
- package/lib/private/orm/relation.d.ts +43 -0
- package/lib/private/orm/relation.js +26 -0
- package/lib/private/orm/store.d.ts +187 -0
- package/lib/private/orm/store.js +542 -0
- package/lib/private/paths.d.ts +2 -2
- package/lib/private/paths.js +3 -3
- package/lib/private/request/RequestBag.d.ts +5 -1
- package/lib/private/request/RequestBag.js +16 -9
- package/lib/private/request/RequestBody.d.ts +6 -11
- package/lib/private/request/RequestBody.js +51 -59
- package/lib/private/request/RequestContext.d.ts +12 -0
- package/lib/private/request/RequestContext.js +31 -0
- package/lib/private/request/RequestFacade.d.ts +11 -6
- package/lib/private/request/RequestPublic.d.ts +9 -0
- package/lib/private/request/RequestPublic.js +2 -0
- package/lib/private/request/RequestView.d.ts +11 -0
- package/lib/private/request/RequestView.js +3 -0
- package/lib/private/request/handle.d.ts +4 -0
- package/lib/private/request/handle.js +18 -0
- package/lib/private/request/parse.d.ts +2 -2
- package/lib/private/request/parse.js +55 -16
- package/lib/private/request/route.js +37 -22
- package/lib/private/request/router.d.ts +1 -1
- package/lib/private/request/router.js +22 -50
- package/lib/private/{database/symbol/wrap.d.ts → request/sContext.d.ts} +1 -1
- package/lib/private/request/sContext.js +2 -0
- package/lib/private/request/storage.d.ts +4 -0
- package/lib/private/request/storage.js +5 -0
- package/lib/private/response/ResponseFunction.d.ts +2 -3
- 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/error.d.ts +1 -1
- package/lib/private/response/error.js +1 -1
- package/lib/private/response/json.d.ts +1 -1
- package/lib/private/response/json.js +2 -2
- package/lib/private/response/redirect.d.ts +5 -5
- package/lib/private/response/redirect.js +9 -10
- package/lib/private/response/respond.js +16 -17
- 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 +3 -3
- package/lib/private/response/view.js +7 -14
- package/lib/private/response/ws.d.ts +1 -1
- 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 +6 -2
- package/lib/private/route/router.js +32 -18
- package/lib/private/route/wrap.js +2 -2
- package/lib/private/serve/App.d.ts +11 -25
- package/lib/private/serve/App.js +138 -120
- package/lib/private/serve/Init.d.ts +5 -5
- package/lib/private/serve/dev-module.d.ts +2 -0
- package/lib/private/serve/dev-module.js +34 -0
- package/lib/private/serve/hook.d.ts +1 -2
- package/lib/private/serve/hook.js +2 -9
- package/lib/private/serve/index.d.ts +1 -1
- package/lib/private/serve/index.js +36 -2
- package/lib/private/server/TAG.d.ts +3 -0
- package/lib/private/server/TAG.js +2 -0
- package/lib/private/server/index.d.ts +5 -0
- package/lib/private/server/index.js +6 -0
- package/lib/private/session/Data.d.ts +1 -2
- package/lib/private/session/SessionHandle.d.ts +1 -1
- package/lib/private/session/SessionHandle.js +11 -9
- package/lib/private/session/index.d.ts +3 -4
- package/lib/private/session/module.d.ts +3 -0
- package/lib/private/session/module.js +114 -0
- package/lib/private/session/schema.d.ts +17 -9
- package/lib/private/session/schema.js +11 -6
- 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/Manager.js +6 -12
- 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 +3 -0
- package/lib/public/client.js +2 -0
- package/lib/public/db/MemoryDB.d.ts +2 -0
- package/lib/public/db/MemoryDB.js +2 -0
- package/lib/public/db/errors.d.ts +2 -0
- package/lib/public/db/errors.js +2 -0
- package/lib/public/db/migrate.d.ts +2 -0
- package/lib/public/db/migrate.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/frontend.d.ts +3 -0
- package/lib/public/frontend.js +2 -0
- package/lib/public/index.d.ts +2 -0
- package/lib/public/index.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/store.d.ts +2 -0
- package/lib/public/orm/store.js +2 -0
- package/lib/public/request/server.d.ts +5 -0
- package/lib/public/request/server.js +7 -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/lib/public/server.d.ts +3 -0
- package/lib/public/server.js +2 -0
- package/package.json +40 -30
- package/lib/private/AppError.d.ts +0 -4
- package/lib/private/AppError.js +0 -8
- package/lib/private/backend/Module.d.ts +0 -18
- package/lib/private/backend/Module.js +0 -22
- package/lib/private/backend/TAG.d.ts +0 -3
- package/lib/private/backend/TAG.js +0 -2
- 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/build/server/plugin/store-wrap.d.ts +0 -4
- package/lib/private/build/server/plugin/store-wrap.js +0 -33
- package/lib/private/client/spa/index.d.ts +0 -6
- package/lib/private/client/spa/index.js +0 -201
- 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/fail.d.ts +0 -3
- package/lib/private/fail.js +0 -5
- package/lib/private/frontend/Module.d.ts +0 -62
- package/lib/private/frontend/Module.js +0 -250
- package/lib/private/frontend/Render.d.ts +0 -9
- package/lib/private/frontend/ServerView.d.ts +0 -5
- package/lib/private/i18n/Module.d.ts +0 -16
- package/lib/private/i18n/Module.js +0 -122
- package/lib/private/i18n/index.d.ts +0 -28
- package/lib/private/i18n/index.js +0 -236
- package/lib/private/module/BuildHook.d.ts +0 -5
- package/lib/private/module/BuildHook.js +0 -2
- package/lib/private/module/NextBuild.d.ts +0 -5
- package/lib/private/module/NextBuild.js +0 -2
- package/lib/private/module/NextServe.d.ts +0 -5
- package/lib/private/module/NextServe.js +0 -2
- package/lib/private/reducer.d.ts +0 -24
- package/lib/private/reducer.js +0 -10
- package/lib/private/route/guard.d.ts +0 -4
- package/lib/private/route/guard.js +0 -22
- package/lib/private/serve/module/Dev.d.ts +0 -11
- package/lib/private/serve/module/Dev.js +0 -28
- package/lib/private/serve/module/Handle.d.ts +0 -10
- package/lib/private/serve/module/Handle.js +0 -15
- package/lib/private/session/SessionModule.d.ts +0 -14
- package/lib/private/session/SessionModule.js +0 -122
- 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/App.d.ts +0 -2
- package/lib/public/App.js +0 -2
- package/lib/public/AppError.d.ts +0 -2
- package/lib/public/AppError.js +0 -2
- package/lib/public/BuildApp.d.ts +0 -2
- package/lib/public/BuildApp.js +0 -2
- package/lib/public/BuildHook.d.ts +0 -2
- package/lib/public/BuildHook.js +0 -2
- package/lib/public/Database.d.ts +0 -2
- package/lib/public/Database.js +0 -2
- package/lib/public/Mode.d.ts +0 -2
- package/lib/public/Mode.js +0 -2
- package/lib/public/Module.d.ts +0 -2
- package/lib/public/Module.js +0 -2
- package/lib/public/Next.d.ts +0 -2
- package/lib/public/Next.js +0 -2
- package/lib/public/NextBuild.d.ts +0 -2
- package/lib/public/NextBuild.js +0 -2
- package/lib/public/NextHandle.d.ts +0 -2
- package/lib/public/NextHandle.js +0 -2
- package/lib/public/NextRoute.d.ts +0 -3
- package/lib/public/NextRoute.js +0 -2
- package/lib/public/NextServe.d.ts +0 -2
- package/lib/public/NextServe.js +0 -2
- package/lib/public/ServeApp.d.ts +0 -2
- package/lib/public/ServeApp.js +0 -2
- package/lib/public/Target.d.ts +0 -2
- package/lib/public/Target.js +0 -2
- package/lib/public/backend/Module.d.ts +0 -2
- package/lib/public/backend/Module.js +0 -2
- package/lib/public/backend/TAG.d.ts +0 -2
- package/lib/public/backend/TAG.js +0 -2
- package/lib/public/client/Data.d.ts +0 -2
- package/lib/public/client/Data.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/spa.d.ts +0 -2
- package/lib/public/client/spa.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/fail.d.ts +0 -2
- package/lib/public/fail.js +0 -2
- package/lib/public/frontend/Module.d.ts +0 -2
- package/lib/public/frontend/Module.js +0 -2
- package/lib/public/frontend/Publish.d.ts +0 -2
- package/lib/public/frontend/Publish.js +0 -2
- package/lib/public/frontend/Render.d.ts +0 -2
- package/lib/public/frontend/Render.js +0 -2
- package/lib/public/frontend/ViewResponse.d.ts +0 -2
- package/lib/public/frontend/ViewResponse.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/{frontend → client}/Publish.d.ts +0 -0
- /package/lib/private/{frontend → client}/Publish.js +0 -0
- /package/lib/private/{frontend → client}/Render.js +0 -0
- /package/lib/private/{frontend → client}/ServerData.js +0 -0
- /package/lib/private/{frontend → client}/ServerView.js +0 -0
- /package/lib/private/{frontend → client}/View.js +0 -0
- /package/lib/private/{frontend → client}/ViewOptions.js +0 -0
- /package/lib/private/{frontend → client}/ViewResponse.js +0 -0
- /package/lib/private/client/{spa/storage.d.ts → storage.d.ts} +0 -0
- /package/lib/private/client/{spa/storage.js → storage.js} +0 -0
- /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.d.ts +0 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { FileRef } from "@rcompat/fs";
|
|
2
|
+
import type ParseError from "pema/ParseError";
|
|
3
|
+
declare function app_reserved_directory(directory: string): import("@rcompat/error").TemplateError;
|
|
4
|
+
declare function app_duplicate_module(name: string): import("@rcompat/error").TemplateError;
|
|
5
|
+
declare function build_missing_binary_addon(): import("@rcompat/error").TemplateError;
|
|
6
|
+
declare function build_missing_route(route: string, file: FileRef): import("@rcompat/error").TemplateError;
|
|
7
|
+
declare function build_multiple_db_drivers(drivers: string[]): import("@rcompat/error").TemplateError;
|
|
8
|
+
declare function build_live_reload_failed(filename: string, cause: Error): import("@rcompat/error").TemplateError;
|
|
9
|
+
declare function build_previous_build_exists(file: FileRef): import("@rcompat/error").TemplateError;
|
|
10
|
+
declare function config_tsconfig_has_paths(): import("@rcompat/error").TemplateError;
|
|
11
|
+
declare function config_file_missing(): import("@rcompat/error").TemplateError;
|
|
12
|
+
declare function config_file_empty(file: FileRef): import("@rcompat/error").TemplateError;
|
|
13
|
+
declare function config_file_error(file: FileRef, cause: Error): import("@rcompat/error").TemplateError;
|
|
14
|
+
declare function config_missing(property: string): import("@rcompat/error").TemplateError;
|
|
15
|
+
declare function frontend_missing(view: string, module?: string): import("@rcompat/error").TemplateError;
|
|
16
|
+
declare function frontend_missing_app_js(): import("@rcompat/error").TemplateError;
|
|
17
|
+
declare function request_unsupported_mime(path: string, mime: string): import("@rcompat/error").TemplateError;
|
|
18
|
+
declare function request_unparsable_mime(path: string, mime: string, cause: Error): import("@rcompat/error").TemplateError;
|
|
19
|
+
declare function request_unexpected_body(expected: string, actual: string): import("@rcompat/error").TemplateError;
|
|
20
|
+
declare function request_bag_missing_key(bag: string, key: string): import("@rcompat/error").TemplateError;
|
|
21
|
+
declare function response_invalid_body(body: string): import("@rcompat/error").TemplateError;
|
|
22
|
+
declare function hook_route_functions_not_allowed(file: string): import("@rcompat/error").TemplateError;
|
|
23
|
+
declare function hook_not_allowed(file: string): import("@rcompat/error").TemplateError;
|
|
24
|
+
declare function hook_unused(file: string): import("@rcompat/error").TemplateError;
|
|
25
|
+
declare function hook_reused_next(): import("@rcompat/error").TemplateError;
|
|
26
|
+
declare function hook_no_return(): import("@rcompat/error").TemplateError;
|
|
27
|
+
declare function hook_bad_return(): import("@rcompat/error").TemplateError;
|
|
28
|
+
declare function session_missing_id(): import("@rcompat/error").TemplateError;
|
|
29
|
+
declare function session_id_string(): import("@rcompat/error").TemplateError;
|
|
30
|
+
declare function session_id_data(): import("@rcompat/error").TemplateError;
|
|
31
|
+
declare function target_missing(target: string, targets: string[]): import("@rcompat/error").TemplateError;
|
|
32
|
+
declare function target_duplicate(target: string): import("@rcompat/error").TemplateError;
|
|
33
|
+
declare function route_missing_verb(route: string, verb: string): import("@rcompat/error").TemplateError;
|
|
34
|
+
declare function route_invalid_special_file(route: string): import("@rcompat/error").TemplateError;
|
|
35
|
+
declare function route_invalid_parameter(route: string, parameter: string): import("@rcompat/error").TemplateError;
|
|
36
|
+
declare function route_invalid_characters(route: string, regexp: RegExp): import("@rcompat/error").TemplateError;
|
|
37
|
+
declare function view_missing(view: string): import("@rcompat/error").TemplateError;
|
|
38
|
+
declare function view_missing_default_export(view: string): import("@rcompat/error").TemplateError;
|
|
39
|
+
declare function view_duplicate_extension(extension: string): import("@rcompat/error").TemplateError;
|
|
40
|
+
declare function view_error(view: string, cause: Error): import("@rcompat/error").TemplateError;
|
|
41
|
+
declare function env_invalid_schema(cause: ParseError): import("@rcompat/error").TemplateError;
|
|
42
|
+
declare function env_missing_key(key: string): import("@rcompat/error").TemplateError;
|
|
43
|
+
declare const errors: {
|
|
44
|
+
env_invalid_schema: typeof env_invalid_schema;
|
|
45
|
+
env_missing_key: typeof env_missing_key;
|
|
46
|
+
view_missing: typeof view_missing;
|
|
47
|
+
view_missing_default_export: typeof view_missing_default_export;
|
|
48
|
+
view_duplicate_extension: typeof view_duplicate_extension;
|
|
49
|
+
view_error: typeof view_error;
|
|
50
|
+
target_missing: typeof target_missing;
|
|
51
|
+
target_duplicate: typeof target_duplicate;
|
|
52
|
+
session_missing_id: typeof session_missing_id;
|
|
53
|
+
session_id_string: typeof session_id_string;
|
|
54
|
+
session_id_data: typeof session_id_data;
|
|
55
|
+
hook_route_functions_not_allowed: typeof hook_route_functions_not_allowed;
|
|
56
|
+
hook_not_allowed: typeof hook_not_allowed;
|
|
57
|
+
hook_unused: typeof hook_unused;
|
|
58
|
+
hook_reused_next: typeof hook_reused_next;
|
|
59
|
+
hook_no_return: typeof hook_no_return;
|
|
60
|
+
hook_bad_return: typeof hook_bad_return;
|
|
61
|
+
response_invalid_body: typeof response_invalid_body;
|
|
62
|
+
request_unsupported_mime: typeof request_unsupported_mime;
|
|
63
|
+
request_unparsable_mime: typeof request_unparsable_mime;
|
|
64
|
+
request_unexpected_body: typeof request_unexpected_body;
|
|
65
|
+
request_bag_missing_key: typeof request_bag_missing_key;
|
|
66
|
+
route_missing_verb: typeof route_missing_verb;
|
|
67
|
+
route_invalid_special_file: typeof route_invalid_special_file;
|
|
68
|
+
route_invalid_parameter: typeof route_invalid_parameter;
|
|
69
|
+
route_invalid_characters: typeof route_invalid_characters;
|
|
70
|
+
frontend_missing: typeof frontend_missing;
|
|
71
|
+
frontend_missing_app_js: typeof frontend_missing_app_js;
|
|
72
|
+
config_file_missing: typeof config_file_missing;
|
|
73
|
+
config_missing: typeof config_missing;
|
|
74
|
+
config_tsconfig_has_paths: typeof config_tsconfig_has_paths;
|
|
75
|
+
config_file_empty: typeof config_file_empty;
|
|
76
|
+
config_file_error: typeof config_file_error;
|
|
77
|
+
build_missing_binary_addon: typeof build_missing_binary_addon;
|
|
78
|
+
build_missing_route: typeof build_missing_route;
|
|
79
|
+
build_multiple_db_drivers: typeof build_multiple_db_drivers;
|
|
80
|
+
build_live_reload_failed: typeof build_live_reload_failed;
|
|
81
|
+
build_previous_build_exists: typeof build_previous_build_exists;
|
|
82
|
+
app_reserved_directory: typeof app_reserved_directory;
|
|
83
|
+
app_duplicate_module: typeof app_duplicate_module;
|
|
84
|
+
};
|
|
85
|
+
export type Code = keyof typeof errors;
|
|
86
|
+
export declare const Code: { [K in Code]: K; };
|
|
87
|
+
export default errors;
|
|
88
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import error from "@rcompat/error";
|
|
2
|
+
const t = error.template;
|
|
3
|
+
function app_reserved_directory(directory) {
|
|
4
|
+
return t `cannot build to ${directory}, reserved directory`;
|
|
5
|
+
}
|
|
6
|
+
function app_duplicate_module(name) {
|
|
7
|
+
return t `module ${name} loaded twice`;
|
|
8
|
+
}
|
|
9
|
+
const APP = error.coded({
|
|
10
|
+
app_reserved_directory,
|
|
11
|
+
app_duplicate_module,
|
|
12
|
+
});
|
|
13
|
+
function build_missing_binary_addon() {
|
|
14
|
+
return t `could not find matching binary addon`;
|
|
15
|
+
}
|
|
16
|
+
function build_missing_route(route, file) {
|
|
17
|
+
return t `cannot find route source for ${route} under ${file.path}`;
|
|
18
|
+
}
|
|
19
|
+
function build_multiple_db_drivers(drivers) {
|
|
20
|
+
const defaults = ["index.ts", "index.js", "default.ts", "default.js"];
|
|
21
|
+
return t `multiple database drivers ${drivers}, add one of ${defaults}`;
|
|
22
|
+
}
|
|
23
|
+
function build_live_reload_failed(filename, cause) {
|
|
24
|
+
return t `failed to live-reload ${filename}: ${cause}`;
|
|
25
|
+
}
|
|
26
|
+
function build_previous_build_exists(file) {
|
|
27
|
+
return t `${file.path} exists but does not contain a previous build`;
|
|
28
|
+
}
|
|
29
|
+
const BUILD = error.coded({
|
|
30
|
+
build_missing_binary_addon,
|
|
31
|
+
build_missing_route,
|
|
32
|
+
build_multiple_db_drivers,
|
|
33
|
+
build_live_reload_failed,
|
|
34
|
+
build_previous_build_exists,
|
|
35
|
+
});
|
|
36
|
+
function config_tsconfig_has_paths() {
|
|
37
|
+
return t `tsconfig.json exists with paths, remove config paths`;
|
|
38
|
+
}
|
|
39
|
+
function config_file_missing() {
|
|
40
|
+
return t `missing ${"config/app.ts"}`;
|
|
41
|
+
}
|
|
42
|
+
function config_file_empty(file) {
|
|
43
|
+
return t `${file.path}: empty config file`;
|
|
44
|
+
}
|
|
45
|
+
function config_file_error(file, cause) {
|
|
46
|
+
return t `error in config file ${file.path}: ${cause}`;
|
|
47
|
+
}
|
|
48
|
+
function config_missing(property) {
|
|
49
|
+
return t `${property} not configured`;
|
|
50
|
+
}
|
|
51
|
+
const CONFIG = error.coded({
|
|
52
|
+
config_file_missing,
|
|
53
|
+
config_missing,
|
|
54
|
+
config_tsconfig_has_paths,
|
|
55
|
+
config_file_empty,
|
|
56
|
+
config_file_error,
|
|
57
|
+
});
|
|
58
|
+
function frontend_missing(view, module) {
|
|
59
|
+
if (module === undefined)
|
|
60
|
+
return t `no frontend for ${view}`;
|
|
61
|
+
const pkg_name = `@primate/${module}`;
|
|
62
|
+
return t `no frontend for ${view}, did you configure ${pkg_name}?`;
|
|
63
|
+
}
|
|
64
|
+
function frontend_missing_app_js() {
|
|
65
|
+
return t `could not find ${"app.js"} in assets`;
|
|
66
|
+
}
|
|
67
|
+
const FRONTEND = error.coded({
|
|
68
|
+
frontend_missing,
|
|
69
|
+
frontend_missing_app_js,
|
|
70
|
+
});
|
|
71
|
+
function request_unsupported_mime(path, mime) {
|
|
72
|
+
return t `${path}: unsupported MIME type ${mime}`;
|
|
73
|
+
}
|
|
74
|
+
function request_unparsable_mime(path, mime, cause) {
|
|
75
|
+
return t `${path}: unparsable MIME type ${mime} (${cause})`;
|
|
76
|
+
}
|
|
77
|
+
function request_unexpected_body(expected, actual) {
|
|
78
|
+
return t `request body: expected ${expected}, got ${actual}`;
|
|
79
|
+
}
|
|
80
|
+
function request_bag_missing_key(bag, key) {
|
|
81
|
+
return t `${bag} has no key ${key}`;
|
|
82
|
+
}
|
|
83
|
+
const REQUEST = error.coded({
|
|
84
|
+
request_unsupported_mime,
|
|
85
|
+
request_unparsable_mime,
|
|
86
|
+
request_unexpected_body,
|
|
87
|
+
request_bag_missing_key,
|
|
88
|
+
});
|
|
89
|
+
function response_invalid_body(body) {
|
|
90
|
+
return t `invalid body ${body} returned from route`;
|
|
91
|
+
}
|
|
92
|
+
const RESPONSE = error.coded({
|
|
93
|
+
response_invalid_body,
|
|
94
|
+
});
|
|
95
|
+
function hook_route_functions_not_allowed(file) {
|
|
96
|
+
return t `${file}: route functions may not be used inside +hook files`;
|
|
97
|
+
}
|
|
98
|
+
function hook_not_allowed(file) {
|
|
99
|
+
return t `${file}: hook functions may only be used inside +hook files`;
|
|
100
|
+
}
|
|
101
|
+
function hook_unused(file) {
|
|
102
|
+
return t `${file}: did not register any hooks (call hook(...))`;
|
|
103
|
+
}
|
|
104
|
+
function hook_reused_next() {
|
|
105
|
+
return t `hook called next() more than once`;
|
|
106
|
+
}
|
|
107
|
+
const advice = "return next(request);";
|
|
108
|
+
function hook_no_return() {
|
|
109
|
+
return t `hook called next() without returning; did you forget ${advice}?`;
|
|
110
|
+
}
|
|
111
|
+
function hook_bad_return() {
|
|
112
|
+
return t `hook must return a response-like value or ${advice}`;
|
|
113
|
+
}
|
|
114
|
+
const HOOK = error.coded({
|
|
115
|
+
hook_route_functions_not_allowed,
|
|
116
|
+
hook_not_allowed,
|
|
117
|
+
hook_unused,
|
|
118
|
+
hook_reused_next,
|
|
119
|
+
hook_no_return,
|
|
120
|
+
hook_bad_return,
|
|
121
|
+
});
|
|
122
|
+
function session_missing_id() {
|
|
123
|
+
return t `session store must have a session_id field`;
|
|
124
|
+
}
|
|
125
|
+
function session_id_string() {
|
|
126
|
+
return t `session store session_id must be a string type`;
|
|
127
|
+
}
|
|
128
|
+
function session_id_data() {
|
|
129
|
+
return t `"both ${"id"} and ${"data"} must be defined or undefined`;
|
|
130
|
+
}
|
|
131
|
+
const SESSION = error.coded({
|
|
132
|
+
session_missing_id,
|
|
133
|
+
session_id_string,
|
|
134
|
+
session_id_data,
|
|
135
|
+
});
|
|
136
|
+
function target_missing(target, targets) {
|
|
137
|
+
return t `no target ${target}, available targets ${targets}`;
|
|
138
|
+
}
|
|
139
|
+
function target_duplicate(target) {
|
|
140
|
+
return t `cannot add target ${target} twice`;
|
|
141
|
+
}
|
|
142
|
+
const TARGET = error.coded({
|
|
143
|
+
target_missing,
|
|
144
|
+
target_duplicate,
|
|
145
|
+
});
|
|
146
|
+
function route_missing_verb(route, verb) {
|
|
147
|
+
return t `${route} has no verb ${verb}`;
|
|
148
|
+
}
|
|
149
|
+
function route_invalid_special_file(route) {
|
|
150
|
+
return t `${route} is not a valid special file`;
|
|
151
|
+
}
|
|
152
|
+
function route_invalid_parameter(route, parameter) {
|
|
153
|
+
return t `${route} has an invalid parameter ${parameter}`;
|
|
154
|
+
}
|
|
155
|
+
function route_invalid_characters(route, regexp) {
|
|
156
|
+
return t `${route} may only contain any of ${regexp.source.slice(1, -1)}`;
|
|
157
|
+
}
|
|
158
|
+
const ROUTE = error.coded({
|
|
159
|
+
route_missing_verb,
|
|
160
|
+
route_invalid_special_file,
|
|
161
|
+
route_invalid_parameter,
|
|
162
|
+
route_invalid_characters,
|
|
163
|
+
});
|
|
164
|
+
function view_missing(view) {
|
|
165
|
+
return t `no view ${view}`;
|
|
166
|
+
}
|
|
167
|
+
function view_missing_default_export(view) {
|
|
168
|
+
return t `${view} must export a default component`;
|
|
169
|
+
}
|
|
170
|
+
function view_duplicate_extension(extension) {
|
|
171
|
+
return t `duplicate file extension ${extension}`;
|
|
172
|
+
}
|
|
173
|
+
function view_error(view, cause) {
|
|
174
|
+
return t `${view} error: ${cause}`;
|
|
175
|
+
}
|
|
176
|
+
const VIEW = error.coded({
|
|
177
|
+
view_missing,
|
|
178
|
+
view_missing_default_export,
|
|
179
|
+
view_duplicate_extension,
|
|
180
|
+
view_error,
|
|
181
|
+
});
|
|
182
|
+
function env_invalid_schema(cause) {
|
|
183
|
+
const issues = cause.issues
|
|
184
|
+
.map(i => ` ${i.path.replace(/^\//, "")}: ${i.message}`)
|
|
185
|
+
.join("\n");
|
|
186
|
+
return t `environment variables failed validation:\n${issues}`;
|
|
187
|
+
}
|
|
188
|
+
function env_missing_key(key) {
|
|
189
|
+
return t `environment variable ${key} is not defined`;
|
|
190
|
+
}
|
|
191
|
+
const ENV = error.coded({
|
|
192
|
+
env_invalid_schema,
|
|
193
|
+
env_missing_key,
|
|
194
|
+
});
|
|
195
|
+
const errors = {
|
|
196
|
+
...APP,
|
|
197
|
+
...BUILD,
|
|
198
|
+
...CONFIG,
|
|
199
|
+
...FRONTEND,
|
|
200
|
+
...ROUTE,
|
|
201
|
+
...REQUEST,
|
|
202
|
+
...RESPONSE,
|
|
203
|
+
...HOOK,
|
|
204
|
+
...SESSION,
|
|
205
|
+
...TARGET,
|
|
206
|
+
...VIEW,
|
|
207
|
+
...ENV,
|
|
208
|
+
};
|
|
209
|
+
export const Code = Object.fromEntries(Object.keys(errors).map(k => [k, k]));
|
|
210
|
+
export default errors;
|
|
211
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type App from "#App";
|
|
2
|
+
import type BuildApp from "#build/App";
|
|
3
|
+
import type Render from "#client/Render";
|
|
4
|
+
import type ServerView from "#client/ServerView";
|
|
5
|
+
import type ViewOptions from "#client/ViewOptions";
|
|
6
|
+
import type Module from "#Module";
|
|
7
|
+
import type RequestFacade from "#request/RequestFacade";
|
|
8
|
+
import type ServeApp from "#serve/App";
|
|
9
|
+
import type { FileRef } from "@rcompat/fs";
|
|
10
|
+
import type { Dict, MaybePromise, Unpack } from "@rcompat/type";
|
|
11
|
+
import type { ObjectType } from "pema";
|
|
12
|
+
export type { Module };
|
|
13
|
+
declare const base_schema: ObjectType<import("pema").NormalizeSchemaObject<{
|
|
14
|
+
readonly extensions: import("pema").OptionalType<import("pema").ArrayType<import("pema").StringType>>;
|
|
15
|
+
readonly spa: import("pema").DefaultType<import("pema").BooleanType, true>;
|
|
16
|
+
readonly ssr: import("pema").DefaultType<import("pema").BooleanType, true>;
|
|
17
|
+
}>, {
|
|
18
|
+
extensions: string[] | undefined;
|
|
19
|
+
spa: boolean;
|
|
20
|
+
ssr: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
type C = typeof base_schema.Complement;
|
|
23
|
+
type Options<E extends C> = typeof base_schema.infer & E["infer"];
|
|
24
|
+
type On<A, E extends C> = (app: A, options: Options<E>) => MaybePromise<void>;
|
|
25
|
+
export interface Init<S = ServerView, E extends C = ObjectType<never>> {
|
|
26
|
+
name: string;
|
|
27
|
+
extensions: string[];
|
|
28
|
+
layouts: boolean;
|
|
29
|
+
client: boolean;
|
|
30
|
+
conditions?: string[];
|
|
31
|
+
render?: Render<S>;
|
|
32
|
+
root?: {
|
|
33
|
+
create: (depth: number, i18n_active: boolean) => string;
|
|
34
|
+
};
|
|
35
|
+
compile?: {
|
|
36
|
+
client?: (text: string, file: FileRef, root: boolean) => MaybePromise<{
|
|
37
|
+
css?: null | string;
|
|
38
|
+
js: string;
|
|
39
|
+
}>;
|
|
40
|
+
server?: (text: string, file: FileRef) => MaybePromise<string>;
|
|
41
|
+
};
|
|
42
|
+
css?: {
|
|
43
|
+
filter: RegExp;
|
|
44
|
+
};
|
|
45
|
+
transform?: (input: {
|
|
46
|
+
body: string;
|
|
47
|
+
head: string;
|
|
48
|
+
headers: Dict<string>;
|
|
49
|
+
app: ServeApp;
|
|
50
|
+
options: ViewOptions;
|
|
51
|
+
request: RequestFacade;
|
|
52
|
+
}) => MaybePromise<{
|
|
53
|
+
body: string;
|
|
54
|
+
head?: string;
|
|
55
|
+
headers?: Dict<string>;
|
|
56
|
+
partial?: boolean;
|
|
57
|
+
}>;
|
|
58
|
+
schema?: E;
|
|
59
|
+
onInit?: On<App, E>;
|
|
60
|
+
onBuild?: On<BuildApp, E>;
|
|
61
|
+
onServe?: On<ServeApp, E>;
|
|
62
|
+
}
|
|
63
|
+
export default function frontend_module<S = ServerView, E extends C = ObjectType<never>>(init: Init<S, E>): (input?: E extends ObjectType<never, never> ? {
|
|
64
|
+
extensions?: string[] | undefined;
|
|
65
|
+
spa?: boolean | undefined;
|
|
66
|
+
ssr?: boolean | undefined;
|
|
67
|
+
} | undefined : Unpack<({
|
|
68
|
+
extensions?: string[] | undefined;
|
|
69
|
+
spa?: boolean | undefined;
|
|
70
|
+
ssr?: boolean | undefined;
|
|
71
|
+
} | undefined) & E["input"]>) => Module;
|
|
72
|
+
//# sourceMappingURL=frontend.d.ts.map
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import E from "#errors";
|
|
2
|
+
import inline from "#inline";
|
|
3
|
+
import location from "#location";
|
|
4
|
+
import hash from "@rcompat/crypto/hash";
|
|
5
|
+
import fn from "@rcompat/fn";
|
|
6
|
+
import fs from "@rcompat/fs";
|
|
7
|
+
import { MIME, Status } from "@rcompat/http";
|
|
8
|
+
import p from "pema";
|
|
9
|
+
const base_schema = p({
|
|
10
|
+
extensions: p.array(p.string).optional(),
|
|
11
|
+
spa: p.boolean.default(true),
|
|
12
|
+
ssr: p.boolean.default(true),
|
|
13
|
+
});
|
|
14
|
+
export default function frontend_module(init) {
|
|
15
|
+
const _render = init.render ?? (async (view, props) => ({ body: await view(props) }));
|
|
16
|
+
const rootname = `root_${init.name}`;
|
|
17
|
+
const module_name = init.name;
|
|
18
|
+
const conditions = init.conditions ?? [];
|
|
19
|
+
const schema = base_schema.extend(init.schema ?? {});
|
|
20
|
+
async function normalize(path) {
|
|
21
|
+
const file = fs.ref(path);
|
|
22
|
+
const basename = path.slice(0, -file.fullExtension.length);
|
|
23
|
+
return `p_${await hash(`${basename}.${module_name}`)}`;
|
|
24
|
+
}
|
|
25
|
+
return (input) => {
|
|
26
|
+
const options = schema.parse(input);
|
|
27
|
+
const spa = options.spa;
|
|
28
|
+
const extensions = options.extensions ?? init.extensions;
|
|
29
|
+
let mode = "development";
|
|
30
|
+
function ssr() {
|
|
31
|
+
return options.ssr && (mode !== "development" || !init.client);
|
|
32
|
+
}
|
|
33
|
+
function load(name, props, app) {
|
|
34
|
+
if (!ssr())
|
|
35
|
+
return { view: null, name, props };
|
|
36
|
+
const view = app.loadView(name);
|
|
37
|
+
return { view, name, props };
|
|
38
|
+
}
|
|
39
|
+
async function render(server, client, app) {
|
|
40
|
+
const { body, head = "", headers = {} } = ssr()
|
|
41
|
+
? await _render(server.view, server.props)
|
|
42
|
+
: { body: "", head: "" };
|
|
43
|
+
if (!init.client) {
|
|
44
|
+
if (app.mode === "development") {
|
|
45
|
+
const asset = app.assets.find(a => a.src?.includes("app") && a.src.endsWith(".js"));
|
|
46
|
+
if (asset === undefined)
|
|
47
|
+
throw E.frontend_missing_app_js();
|
|
48
|
+
const app_script = `<script type="module" src="${asset.src}"></script>`;
|
|
49
|
+
return { body, head: head.concat(app_script), headers };
|
|
50
|
+
}
|
|
51
|
+
return { body, head, headers };
|
|
52
|
+
}
|
|
53
|
+
const app_asset = app.assets.find(asset => asset.src?.includes("app") && asset.src.endsWith(".js"));
|
|
54
|
+
if (app_asset === undefined)
|
|
55
|
+
throw E.frontend_missing_app_js();
|
|
56
|
+
const app_script = `<script type="module" src="${app_asset.src}"></script>`;
|
|
57
|
+
const props = JSON.stringify({ frontend: init.name, ...client });
|
|
58
|
+
const hydrated = await inline(props, MIME.APPLICATION_JSON, "hydration");
|
|
59
|
+
const script_src = [hydrated.integrity];
|
|
60
|
+
return {
|
|
61
|
+
body,
|
|
62
|
+
head: head.concat(app_script, hydrated.head),
|
|
63
|
+
headers: app.headers({ "script-src": script_src }),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function respond(view, props = {}, options = {}) {
|
|
67
|
+
return async (app, { as_layout, layouts = [] } = {}, request) => {
|
|
68
|
+
if (as_layout)
|
|
69
|
+
return load(view, props, app);
|
|
70
|
+
const views = (await Promise.all(layouts
|
|
71
|
+
.map(layout => layout(app, { as_layout: true }, request))))
|
|
72
|
+
// set the actual page as the last view
|
|
73
|
+
.concat(load(view, props, app));
|
|
74
|
+
const $request = request.toJSON();
|
|
75
|
+
const $props = init.layouts
|
|
76
|
+
? {
|
|
77
|
+
views: await fn.async.map(views, ({ name }) => normalize(name)),
|
|
78
|
+
props: views.map(c => c.props),
|
|
79
|
+
request: $request,
|
|
80
|
+
}
|
|
81
|
+
: { props, request: $request };
|
|
82
|
+
const client = {
|
|
83
|
+
view: init.layouts ? "root" : await normalize(view),
|
|
84
|
+
spa: spa,
|
|
85
|
+
ssr: ssr(),
|
|
86
|
+
mode: app.mode,
|
|
87
|
+
...$props,
|
|
88
|
+
};
|
|
89
|
+
if (spa && request.headers.try("Accept") === MIME.APPLICATION_JSON) {
|
|
90
|
+
const json_body = JSON.stringify(client);
|
|
91
|
+
return new Response(json_body, {
|
|
92
|
+
headers: {
|
|
93
|
+
...app.headers(),
|
|
94
|
+
"Content-Type": MIME.APPLICATION_JSON,
|
|
95
|
+
"Content-Length": String(app.body_length(json_body)),
|
|
96
|
+
"Cache-Control": "no-store",
|
|
97
|
+
},
|
|
98
|
+
status: options.status ?? Status.OK,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (!ssr()) {
|
|
102
|
+
const { head } = await render({ view: null, props: {} }, client, app);
|
|
103
|
+
return app.view({ body: "<div id=\"app\"></div>", head, ...options });
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const server = init.layouts
|
|
107
|
+
? {
|
|
108
|
+
view: app.loadView(rootname),
|
|
109
|
+
props: {
|
|
110
|
+
views: views.map(c => c.view),
|
|
111
|
+
props: views.map(c => c.props),
|
|
112
|
+
request: $request,
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
: {
|
|
116
|
+
view: app.loadView(view),
|
|
117
|
+
props,
|
|
118
|
+
request: $request,
|
|
119
|
+
};
|
|
120
|
+
const base = await render(server, client, app);
|
|
121
|
+
const { body, head = base.head, headers = base.headers, partial = options.partial, } = await init.transform?.({ ...base, app, options, request })
|
|
122
|
+
?? { ...base, partial: undefined };
|
|
123
|
+
return app.view({ body, head, headers, partial, ...options });
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
throw E.view_error(`${location.views}/${view}`, error);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
;
|
|
131
|
+
return {
|
|
132
|
+
name: module_name,
|
|
133
|
+
setup({ onInit, onBuild, onServe }) {
|
|
134
|
+
onInit(async (app) => {
|
|
135
|
+
await init.onInit?.(app, options);
|
|
136
|
+
mode = app.mode;
|
|
137
|
+
});
|
|
138
|
+
onBuild(async (app) => {
|
|
139
|
+
await init.onBuild?.(app, options);
|
|
140
|
+
const build_ssr = options.ssr &&
|
|
141
|
+
(app.mode !== "development" || !init.client);
|
|
142
|
+
const compile_server = init.compile?.server;
|
|
143
|
+
const compile_client = init.compile?.client;
|
|
144
|
+
// prebuild
|
|
145
|
+
extensions.forEach(e => {
|
|
146
|
+
app.bind(e, async (file, { context }) => {
|
|
147
|
+
if (context === "views" && !build_ssr)
|
|
148
|
+
return "";
|
|
149
|
+
// production: just compile to JS, don't bundle yet
|
|
150
|
+
if (compile_server !== undefined) {
|
|
151
|
+
return await compile_server(await file.text(), file);
|
|
152
|
+
}
|
|
153
|
+
return await file.text();
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
// build
|
|
157
|
+
if (init.root !== undefined && compile_server !== undefined) {
|
|
158
|
+
const source = await compile_server(init.root.create(app.depth(), app.i18n_active), fs.ref(`root:${module_name}`));
|
|
159
|
+
app.addRoot(rootname, source);
|
|
160
|
+
}
|
|
161
|
+
// publsh
|
|
162
|
+
if (app.mode === "development") {
|
|
163
|
+
app.frontends.set(module_name, [...extensions]);
|
|
164
|
+
}
|
|
165
|
+
if (compile_client !== undefined) {
|
|
166
|
+
if (init.client) {
|
|
167
|
+
app.frontends.set(module_name, [...extensions]);
|
|
168
|
+
conditions.forEach(c => app.conditions.add(c));
|
|
169
|
+
}
|
|
170
|
+
app.plugin("client", {
|
|
171
|
+
name: module_name,
|
|
172
|
+
setup(build) {
|
|
173
|
+
const resolveDir = app.root.path;
|
|
174
|
+
const css_cache = new Map();
|
|
175
|
+
if (init.root !== undefined) {
|
|
176
|
+
const root = init.root;
|
|
177
|
+
const filter = new RegExp(`^${module_name}:root`);
|
|
178
|
+
build.onResolve({ filter }, ({ path }) => {
|
|
179
|
+
return { namespace: `${module_name}`, path };
|
|
180
|
+
});
|
|
181
|
+
build.onLoad({ filter }, async () => {
|
|
182
|
+
const contents = (await compile_client(root.create(app.depth(), app.i18n_active), fs.ref("/tmp"), true)).js;
|
|
183
|
+
return contents.length > 0 ? {
|
|
184
|
+
contents,
|
|
185
|
+
loader: "js",
|
|
186
|
+
resolveDir,
|
|
187
|
+
} : null;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (init.css !== undefined) {
|
|
191
|
+
build.onResolve({ filter: new RegExp(`^${module_name}:css:`) }, args => {
|
|
192
|
+
return { path: args.path, namespace: `${module_name}-css` };
|
|
193
|
+
});
|
|
194
|
+
build.onLoad({ filter: /.*/, namespace: `${module_name}-css` }, args => {
|
|
195
|
+
const contents = css_cache.get(args.path);
|
|
196
|
+
return contents ? { contents, loader: "css" } : null;
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
const views_filter = new RegExp(`^${module_name}:views`);
|
|
200
|
+
const views_base = app.root.join(location.views);
|
|
201
|
+
build.onResolve({ filter: views_filter }, ({ path }) => {
|
|
202
|
+
return { namespace: `${module_name}`, path };
|
|
203
|
+
});
|
|
204
|
+
build.onLoad({ filter: views_filter }, async () => {
|
|
205
|
+
const views = await views_base.files({
|
|
206
|
+
recursive: true,
|
|
207
|
+
filter: c => extensions.includes(c.fullExtension),
|
|
208
|
+
});
|
|
209
|
+
let contents = "";
|
|
210
|
+
for (const view of views) {
|
|
211
|
+
const { path } = view.debase(views_base, "/");
|
|
212
|
+
contents += `export { default as ${await normalize(path)} }
|
|
213
|
+
from "view:${path}";\n`;
|
|
214
|
+
}
|
|
215
|
+
return { contents, resolveDir: app.root.path };
|
|
216
|
+
});
|
|
217
|
+
const filter = new RegExp(`(${extensions.map(e => e.replace(".", "\\.")).join("|")})$`);
|
|
218
|
+
build.onLoad({ filter }, async (args) => {
|
|
219
|
+
const file = fs.ref(args.path);
|
|
220
|
+
// compile file to JavaScript and potentially CSS
|
|
221
|
+
const compiled = await compile_client(await file.text(), file, false);
|
|
222
|
+
let contents = compiled.js;
|
|
223
|
+
if (init.css !== undefined
|
|
224
|
+
&& compiled.css !== null
|
|
225
|
+
&& compiled.css !== undefined
|
|
226
|
+
&& compiled.css !== "") {
|
|
227
|
+
const css_path = `${module_name}:css:${args.path}`;
|
|
228
|
+
css_cache.set(css_path, compiled.css);
|
|
229
|
+
contents += `\nimport "${css_path}";`;
|
|
230
|
+
}
|
|
231
|
+
return { contents };
|
|
232
|
+
});
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
onServe(async (app) => {
|
|
238
|
+
await init.onServe?.(app, options);
|
|
239
|
+
extensions.forEach(extension => app.frontend(extension, respond));
|
|
240
|
+
});
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
//# sourceMappingURL=frontend.js.map
|
package/lib/private/hash.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type Dict from "@rcompat/type
|
|
2
|
-
type
|
|
1
|
+
import type { Dict } from "@rcompat/type";
|
|
2
|
+
type CatalogValue = string | {
|
|
3
|
+
[key: string]: CatalogValue;
|
|
4
|
+
} | CatalogValue[];
|
|
5
|
+
type Catalog = Dict<CatalogValue>;
|
|
3
6
|
export type { Catalog as default };
|
|
4
7
|
//# sourceMappingURL=Catalog.d.ts.map
|