@primate/svelte 0.21.4 → 0.23.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.
Files changed (49) hide show
  1. package/lib/app.d.ts +5 -0
  2. package/lib/index.d.ts +3 -0
  3. package/lib/private/client/Data.d.ts +5 -0
  4. package/lib/private/client/Data.js +2 -0
  5. package/lib/private/client/Payload.d.ts +7 -0
  6. package/lib/private/client/Payload.js +2 -0
  7. package/lib/private/client/app.d.ts +5 -0
  8. package/lib/private/client/app.js +23 -0
  9. package/lib/private/client/field.d.ts +34 -0
  10. package/lib/private/client/field.js +32 -0
  11. package/lib/private/client/form.d.ts +23 -0
  12. package/lib/private/client/form.js +41 -0
  13. package/lib/private/client/index.d.ts +51 -10
  14. package/lib/private/client/index.js +4 -26
  15. package/lib/private/client/root.d.ts +33 -0
  16. package/lib/private/client/root.js +20 -0
  17. package/lib/private/create-root.js +9 -3
  18. package/lib/private/default.d.ts +7 -0
  19. package/lib/private/{Default.js → default.js} +12 -10
  20. package/lib/private/init.d.ts +5 -0
  21. package/lib/private/init.js +14 -0
  22. package/lib/private/request/store.d.ts +4 -0
  23. package/lib/private/request/store.js +3 -0
  24. package/lib/private/runtime.d.ts +7 -0
  25. package/lib/private/runtime.js +4 -0
  26. package/lib/public/app.d.ts +2 -0
  27. package/lib/public/app.js +2 -0
  28. package/lib/public/browser.d.ts +1 -1
  29. package/lib/public/browser.js +1 -1
  30. package/lib/public/client.d.ts +2 -0
  31. package/lib/public/client.js +2 -0
  32. package/lib/public/default.d.ts +1 -3
  33. package/lib/public/default.js +1 -2
  34. package/lib/public/runtime.d.ts +1 -3
  35. package/lib/public/runtime.js +1 -2
  36. package/package.json +23 -16
  37. package/lib/private/Default.d.ts +0 -18
  38. package/lib/private/Runtime.d.ts +0 -12
  39. package/lib/private/Runtime.js +0 -14
  40. package/lib/private/client/ValidateState.d.ts +0 -8
  41. package/lib/private/client/ValidateState.js +0 -2
  42. package/lib/private/client/Validated.d.ts +0 -8
  43. package/lib/private/client/Validated.js +0 -2
  44. package/lib/private/client/validate.d.ts +0 -25
  45. package/lib/private/client/validate.js +0 -28
  46. package/lib/public/Validated.d.ts +0 -2
  47. package/lib/public/Validated.js +0 -2
  48. package/lib/public/validate.d.ts +0 -2
  49. package/lib/public/validate.js +0 -2
package/lib/app.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ declare module "app:svelte" {
2
+ import type { RequestPublic } from "@primate/core";
3
+ import type { Writable } from "svelte/store";
4
+ export const request: Writable<RequestPublic>;
5
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import "./app.d.ts";
2
+
3
+ export { default } from "./public/default";
@@ -0,0 +1,5 @@
1
+ import type Payload from "#client/Payload";
2
+ import type { Data } from "@primate/core/client";
3
+ type SvelteData = Data<Payload>;
4
+ export type { SvelteData as default };
5
+ //# sourceMappingURL=Data.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Data.js.map
@@ -0,0 +1,7 @@
1
+ import type { Dict } from "@rcompat/type";
2
+ type Payload = {
3
+ views: string[];
4
+ props: Dict[];
5
+ };
6
+ export type { Payload as default };
7
+ //# sourceMappingURL=Payload.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Payload.js.map
@@ -0,0 +1,5 @@
1
+ import type Data from "#client/Data";
2
+ export default class SvelteApp {
3
+ static mount(_view: string, data: Data): void;
4
+ }
5
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1,23 @@
1
+ import root from "#client/root";
2
+ import client from "@primate/core/client";
3
+ import RootView from "svelte:root";
4
+ export default class SvelteApp {
5
+ static mount(_view, data) {
6
+ const Root = root[data.ssr ? "ssr" : "csr"](RootView, {
7
+ props: { p: root.toProps(data) },
8
+ target: document.body,
9
+ });
10
+ if (data.spa) {
11
+ const start = () => client.boot((_data, update) => {
12
+ Root.p = { ...root.toProps(_data), update };
13
+ });
14
+ if (document.readyState === "loading") {
15
+ window.addEventListener("DOMContentLoaded", start, { once: true });
16
+ }
17
+ else {
18
+ start();
19
+ }
20
+ }
21
+ }
22
+ }
23
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1,34 @@
1
+ import { type ValidateUpdater, type ValidationError } from "@primate/core/client";
2
+ import { type Readable } from "svelte/store";
3
+ type ValidateState<T> = {
4
+ error: null | ValidationError;
5
+ loading: boolean;
6
+ value: T;
7
+ };
8
+ type Validated<T> = {
9
+ update: (updater: ValidateUpdater<T>) => Promise<void>;
10
+ } & Readable<ValidateState<T>>;
11
+ declare const field: <T>(initial: T) => {
12
+ delete: (url: string, options?: {
13
+ headers?: import("@rcompat/type").Dict<string>;
14
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
15
+ path?: import("@rcompat/type").JSONPointer;
16
+ } | undefined) => Validated<T>;
17
+ patch: (url: string, options?: {
18
+ headers?: import("@rcompat/type").Dict<string>;
19
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
20
+ path?: import("@rcompat/type").JSONPointer;
21
+ } | undefined) => Validated<T>;
22
+ post: (url: string, options?: {
23
+ headers?: import("@rcompat/type").Dict<string>;
24
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
25
+ path?: import("@rcompat/type").JSONPointer;
26
+ } | undefined) => Validated<T>;
27
+ put: (url: string, options?: {
28
+ headers?: import("@rcompat/type").Dict<string>;
29
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
30
+ path?: import("@rcompat/type").JSONPointer;
31
+ } | undefined) => Validated<T>;
32
+ };
33
+ export default field;
34
+ //# sourceMappingURL=field.d.ts.map
@@ -0,0 +1,32 @@
1
+ import client from "@primate/core/client";
2
+ import { writable } from "svelte/store";
3
+ function useValidate(init) {
4
+ let current = init.initial;
5
+ const { set, subscribe, update } = writable({
6
+ error: null,
7
+ loading: false,
8
+ value: current,
9
+ });
10
+ async function $update(updater) {
11
+ let previous;
12
+ update((s) => {
13
+ previous = s.value;
14
+ const next_value = updater(s.value);
15
+ current = next_value;
16
+ return { ...s, error: null, loading: true, value: next_value };
17
+ });
18
+ try {
19
+ await client.validateField(init, current);
20
+ update((s) => ({ ...s, loading: false }));
21
+ }
22
+ catch (e) {
23
+ // rollback
24
+ current = previous;
25
+ set({ error: e, loading: false, value: previous });
26
+ }
27
+ }
28
+ return { subscribe, update: $update };
29
+ }
30
+ const field = client.toValidated(useValidate);
31
+ export default field;
32
+ //# sourceMappingURL=field.js.map
@@ -0,0 +1,23 @@
1
+ import type { FormInit } from "@primate/core/client";
2
+ import type { Dict } from "@rcompat/type";
3
+ import type { Readable } from "svelte/store";
4
+ type SvelteFormView<Values extends Dict> = {
5
+ id: string;
6
+ submitting: boolean;
7
+ submitted: boolean;
8
+ submit: (event?: Event) => Promise<void>;
9
+ errors: readonly string[];
10
+ field: <K extends keyof Values & string>(name: K) => {
11
+ name: string;
12
+ value: Values[K];
13
+ error: string | null;
14
+ errors: readonly string[];
15
+ };
16
+ };
17
+ type Initial<Values extends Dict> = FormInit & {
18
+ initial?: Values;
19
+ };
20
+ declare function form<Values extends Dict>(init: Initial<Values>): Readable<SvelteFormView<Values>>;
21
+ declare function form(init?: FormInit): Readable<SvelteFormView<Dict>>;
22
+ export default form;
23
+ //# sourceMappingURL=form.d.ts.map
@@ -0,0 +1,41 @@
1
+ import client from "@primate/core/client";
2
+ import { writable } from "svelte/store";
3
+ function form(init) {
4
+ const { initial, ...form_init } = init ?? {};
5
+ const controller = client.createForm(form_init);
6
+ const values = initial ?? {};
7
+ const make_view = (snapshot) => {
8
+ const form_errors = snapshot.errors.form;
9
+ return {
10
+ id: snapshot.id,
11
+ submitting: snapshot.submitting,
12
+ submitted: snapshot.submitted,
13
+ submit: controller.submit,
14
+ errors: form_errors,
15
+ field(name) {
16
+ const key = name;
17
+ const errors = snapshot.errors.fields[key] ?? [];
18
+ return {
19
+ name: key,
20
+ value: values[name],
21
+ error: errors[0] ?? null,
22
+ errors,
23
+ };
24
+ },
25
+ };
26
+ };
27
+ const initial_view = make_view({
28
+ ...controller.read(),
29
+ submit: controller.submit,
30
+ });
31
+ const { subscribe, set } = writable(initial_view);
32
+ controller.subscribe((snapshot) => {
33
+ set(make_view({
34
+ ...snapshot,
35
+ submit: controller.submit,
36
+ }));
37
+ });
38
+ return { subscribe };
39
+ }
40
+ export default form;
41
+ //# sourceMappingURL=form.js.map
@@ -1,11 +1,52 @@
1
- import type ClientData from "@primate/core/client/Data";
2
- import type Dict from "@rcompat/type/Dict";
3
- type Data = ClientData<{
4
- views: string[];
5
- props: Dict[];
6
- }>;
7
- export default class SvelteClient {
8
- static mount(_view: string, data: ClientData<Data>): void;
9
- }
10
- export {};
1
+ import form from "#client/form";
2
+ declare const client: {
3
+ form: typeof form;
4
+ field: <T>(initial: T) => {
5
+ delete: (url: string, options?: {
6
+ headers?: import("@rcompat/type").Dict<string>;
7
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
8
+ path?: import("@rcompat/type").JSONPointer;
9
+ } | undefined) => {
10
+ update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
11
+ } & import("svelte/store").Readable<{
12
+ error: null | import("@primate/core/client").ValidationError;
13
+ loading: boolean;
14
+ value: T;
15
+ }>;
16
+ patch: (url: string, options?: {
17
+ headers?: import("@rcompat/type").Dict<string>;
18
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
19
+ path?: import("@rcompat/type").JSONPointer;
20
+ } | undefined) => {
21
+ update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
22
+ } & import("svelte/store").Readable<{
23
+ error: null | import("@primate/core/client").ValidationError;
24
+ loading: boolean;
25
+ value: T;
26
+ }>;
27
+ post: (url: string, options?: {
28
+ headers?: import("@rcompat/type").Dict<string>;
29
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
30
+ path?: import("@rcompat/type").JSONPointer;
31
+ } | undefined) => {
32
+ update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
33
+ } & import("svelte/store").Readable<{
34
+ error: null | import("@primate/core/client").ValidationError;
35
+ loading: boolean;
36
+ value: T;
37
+ }>;
38
+ put: (url: string, options?: {
39
+ headers?: import("@rcompat/type").Dict<string>;
40
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
41
+ path?: import("@rcompat/type").JSONPointer;
42
+ } | undefined) => {
43
+ update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
44
+ } & import("svelte/store").Readable<{
45
+ error: null | import("@primate/core/client").ValidationError;
46
+ loading: boolean;
47
+ value: T;
48
+ }>;
49
+ };
50
+ };
51
+ export default client;
11
52
  //# sourceMappingURL=index.d.ts.map
@@ -1,27 +1,5 @@
1
- import spa from "@primate/core/client/spa";
2
- import { hydrate, mount } from "svelte";
3
- import root from "svelte:root";
4
- import * as views from "svelte:views";
5
- const make_props = (data) => ({
6
- views: data.views.map(name => views[name]),
7
- props: data.props,
8
- request: {
9
- ...data.request,
10
- url: new URL(location.href),
11
- },
12
- update: () => undefined,
13
- });
14
- export default class SvelteClient {
15
- static mount(_view, data) {
16
- const _root = (data.ssr ? hydrate : mount)(root, {
17
- props: {
18
- p: make_props(data),
19
- },
20
- target: document.body,
21
- });
22
- data.spa && window.addEventListener("DOMContentLoaded", () => spa((_data, update) => {
23
- _root.p = { ...make_props(_data), update };
24
- }));
25
- }
26
- }
1
+ import form from "#client/form";
2
+ import field from "#client/field";
3
+ const client = { form, field };
4
+ export default client;
27
5
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,33 @@
1
+ import type Data from "#client/Data";
2
+ import type { Dict } from "@rcompat/type";
3
+ import { hydrate, mount } from "svelte";
4
+ import type { Component } from "svelte";
5
+ type ViewComponent = Component<any>;
6
+ export type RootProps = {
7
+ views: ViewComponent[];
8
+ props: Dict[];
9
+ request: Data["request"] & {
10
+ url: URL;
11
+ };
12
+ update?: () => void;
13
+ };
14
+ declare function toProps(data: Data): {
15
+ views: Component<{}, {}, string>[];
16
+ props: Dict[];
17
+ request: {
18
+ url: URL;
19
+ context: Dict;
20
+ cookies: Dict<string>;
21
+ headers: Dict<string>;
22
+ path: Dict<string>;
23
+ query: Dict<string>;
24
+ };
25
+ update: () => undefined;
26
+ };
27
+ declare const root: {
28
+ toProps: typeof toProps;
29
+ ssr: typeof hydrate;
30
+ csr: typeof mount;
31
+ };
32
+ export default root;
33
+ //# sourceMappingURL=root.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { hydrate, mount } from "svelte";
2
+ import * as views from "svelte:views";
3
+ function toProps(data) {
4
+ return {
5
+ views: data.views.map(name => views[name]),
6
+ props: data.props,
7
+ request: {
8
+ ...data.request,
9
+ url: new URL(data.request.url),
10
+ },
11
+ update: () => undefined,
12
+ };
13
+ }
14
+ const root = {
15
+ toProps,
16
+ ssr: hydrate,
17
+ csr: mount,
18
+ };
19
+ export default root;
20
+ //# sourceMappingURL=root.js.map
@@ -3,13 +3,13 @@ export default (depth, i18n_active) => {
3
3
  const body = Array.from({ length: n }, (_, i) => i - 1)
4
4
  .reduceRight((child, _, i) => `
5
5
  {#if p.views[${i + 1}]}
6
- <svelte:component this={p.views[${i}]} request={p.request} {...p.props[${i}]}>
6
+ <svelte:component this={p.views[${i}]} {...p.props[${i}]}>
7
7
  ${child}
8
8
  </svelte:component>
9
9
  {:else}
10
- <svelte:component this={p.views[${i}]} request={p.request} {...p.props[${i}]}/>
10
+ <svelte:component this={p.views[${i}]} {...p.props[${i}]}/>
11
11
  {/if}
12
- `, `<svelte:component this={p.views[${n}]} request={p.request} {...p.props[${n}]}/>`);
12
+ `, `<svelte:component this={p.views[${n}]} {...p.props[${n}]}/>`);
13
13
  const i18nImports = i18n_active
14
14
  ? `
15
15
  import t from "#i18n";
@@ -30,15 +30,21 @@ export default (depth, i18n_active) => {
30
30
  <script>
31
31
  import { afterUpdate, setContext } from "svelte";
32
32
  import context_name from "@primate/svelte/context-name";
33
+ import { request } from "@primate/svelte/app";
33
34
  ${i18nImports}
34
35
 
35
36
  export let p;
36
37
 
37
38
  setContext(context_name, p.request.context);
38
39
 
40
+ const { context, path, ...public_request } = p.request;
41
+ request.set(public_request);
42
+
39
43
  ${i18nInit}
40
44
 
41
45
  afterUpdate(() => {
46
+ const { context, path, ...public_request } = p.request;
47
+ request.set(public_request);
42
48
  p.update?.();
43
49
  });
44
50
  </script>
@@ -0,0 +1,7 @@
1
+ declare const _default: (input?: {
2
+ extensions?: string[] | undefined;
3
+ spa?: boolean | undefined;
4
+ ssr?: boolean | undefined;
5
+ } | undefined) => import("@primate/core/frontend").Module;
6
+ export default _default;
7
+ //# sourceMappingURL=default.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import create_root from "#create-root";
2
- import Runtime from "#Runtime";
2
+ import init from "#init";
3
+ import frontend from "@primate/core/frontend";
3
4
  import esbuild from "esbuild";
4
5
  import { compile, compileModule } from "svelte/compiler";
5
6
  const strip = (code) => {
@@ -8,14 +9,15 @@ const strip = (code) => {
8
9
  format: "esm",
9
10
  }).code;
10
11
  };
11
- export default class Default extends Runtime {
12
- root = {
12
+ export default frontend({
13
+ ...init,
14
+ root: {
13
15
  create: create_root,
14
- };
15
- css = {
16
+ },
17
+ css: {
16
18
  filter: /\.sveltecss$/,
17
- };
18
- compile = {
19
+ },
20
+ compile: {
19
21
  client: (text, file) => {
20
22
  const accessors = true;
21
23
  const { css, js } = file.path.endsWith(".js") || file.path.endsWith(".ts")
@@ -31,6 +33,6 @@ export default class Default extends Runtime {
31
33
  : compile(text, { generate: "server" });
32
34
  return js.code;
33
35
  },
34
- };
35
- }
36
- //# sourceMappingURL=Default.js.map
36
+ },
37
+ });
38
+ //# sourceMappingURL=default.js.map
@@ -0,0 +1,5 @@
1
+ import type { Init } from "@primate/core/frontend";
2
+ import type { Component } from "svelte";
3
+ declare const module: Init<Component>;
4
+ export default module;
5
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { render } from "svelte/server";
2
+ const module = {
3
+ name: "svelte",
4
+ extensions: [".svelte.js", ".svelte.ts", ".svelte"],
5
+ layouts: true,
6
+ client: true,
7
+ render(view, props) {
8
+ const { head, html } = render(view, { props: { p: { ...props } } });
9
+ return { body: html, head };
10
+ },
11
+ conditions: ["svelte"],
12
+ };
13
+ export default module;
14
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1,4 @@
1
+ import type { RequestPublic } from "@primate/core";
2
+ declare const _default: import("svelte/store").Writable<RequestPublic>;
3
+ export default _default;
4
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { writable } from "svelte/store";
2
+ export default writable();
3
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1,7 @@
1
+ declare const _default: (input?: {
2
+ extensions?: string[] | undefined;
3
+ spa?: boolean | undefined;
4
+ ssr?: boolean | undefined;
5
+ } | undefined) => import("@primate/core/frontend").Module;
6
+ export default _default;
7
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1,4 @@
1
+ import init from "#init";
2
+ import frontend from "@primate/core/frontend";
3
+ export default frontend(init);
4
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1,2 @@
1
+ export { default as request } from "#request/store";
2
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default as request } from "#request/store";
2
+ //# sourceMappingURL=app.js.map
@@ -1,2 +1,2 @@
1
- export { default } from "#client/index";
1
+ export { default } from "#client/app";
2
2
  //# sourceMappingURL=browser.d.ts.map
@@ -1,2 +1,2 @@
1
- export { default } from "#client/index";
1
+ export { default } from "#client/app";
2
2
  //# sourceMappingURL=browser.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#client/index";
2
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#client/index";
2
+ //# sourceMappingURL=client.js.map
@@ -1,4 +1,2 @@
1
- import Default from "#Default";
2
- declare const _default: (options?: typeof Default.input) => Default;
3
- export default _default;
1
+ export { default } from "#default";
4
2
  //# sourceMappingURL=default.d.ts.map
@@ -1,3 +1,2 @@
1
- import Default from "#Default";
2
- export default (options) => new Default(options);
1
+ export { default } from "#default";
3
2
  //# sourceMappingURL=default.js.map
@@ -1,4 +1,2 @@
1
- import Runtime from "#Runtime";
2
- declare const _default: (options?: typeof Runtime.input) => Runtime;
3
- export default _default;
1
+ export { default } from "#runtime";
4
2
  //# sourceMappingURL=runtime.d.ts.map
@@ -1,3 +1,2 @@
1
- import Runtime from "#Runtime";
2
- export default (options) => new Runtime(options);
1
+ export { default } from "#runtime";
3
2
  //# sourceMappingURL=runtime.js.map
package/package.json CHANGED
@@ -1,50 +1,57 @@
1
1
  {
2
2
  "name": "@primate/svelte",
3
- "version": "0.21.4",
4
- "description": "Primate Svelte frontend",
3
+ "version": "0.23.0",
4
+ "description": "Svelte for Primate",
5
5
  "homepage": "https://primate.run/docs/frontend/svelte",
6
6
  "bugs": "https://github.com/primate-run/primate/issues",
7
+ "type": "module",
7
8
  "license": "MIT",
8
- "files": [
9
- "/lib/**/*.js",
10
- "/lib/**/*.d.ts",
11
- "!/**/*.spec.*"
12
- ],
13
9
  "repository": {
14
10
  "type": "git",
15
11
  "url": "https://github.com/primate-run/primate",
16
12
  "directory": "packages/svelte"
17
13
  },
14
+ "files": [
15
+ "/lib/**/*.js",
16
+ "/lib/**/*.d.ts",
17
+ "!/**/*.spec.*"
18
+ ],
19
+ "types": "lib/index.d.ts",
18
20
  "dependencies": {
19
- "@rcompat/fs": "^0.22.3",
20
- "esbuild": "^0.27.2",
21
- "@primate/core": "^0.4.5"
21
+ "esbuild": "^0.28.0",
22
+ "@primate/core": "^0.6.0"
23
+ },
24
+ "devDependencies": {
25
+ "@rcompat/type": "^0.11.1",
26
+ "@primate/test": "^0.0.0"
22
27
  },
23
28
  "peerDependencies": {
24
29
  "svelte": "5",
25
- "primate": "^0.35.1"
30
+ "primate": "^0.37.0"
26
31
  },
27
- "type": "module",
28
32
  "imports": {
29
33
  "#*": {
30
- "apekit": "./src/private/*.ts",
34
+ "@primate/source": "./src/private/*.ts",
31
35
  "default": "./lib/private/*.js"
32
36
  }
33
37
  },
34
38
  "exports": {
35
39
  ".": {
40
+ "types": "./lib/index.d.ts",
41
+ "@primate/source": "./src/public/default.ts",
36
42
  "browser": "./lib/public/browser.js",
37
43
  "runtime": "./lib/public/runtime.js",
38
44
  "default": "./lib/public/default.js"
39
45
  },
40
46
  "./*": {
41
- "apekit": "./src/public/*.ts",
47
+ "@primate/source": "./src/public/*.ts",
42
48
  "default": "./lib/public/*.js"
43
49
  }
44
50
  },
45
51
  "scripts": {
46
- "build": "npm run clean && tsc",
52
+ "build": "npm run clean && tsc && cp src/types/app.d.ts lib && cp src/types/index.d.ts lib",
47
53
  "clean": "rm -rf ./lib",
48
- "lint": "eslint ."
54
+ "lint": "eslint .",
55
+ "test": "npx proby"
49
56
  }
50
57
  }
@@ -1,18 +0,0 @@
1
- import Runtime from "#Runtime";
2
- import type FileRef from "@rcompat/fs/FileRef";
3
- export default class Default extends Runtime {
4
- root: {
5
- create: (depth: number, i18n_active: boolean) => string;
6
- };
7
- css: {
8
- filter: RegExp;
9
- };
10
- compile: {
11
- client: (text: string, file: FileRef) => {
12
- css: string;
13
- js: string;
14
- };
15
- server: (text: string, file?: FileRef) => string;
16
- };
17
- }
18
- //# sourceMappingURL=Default.d.ts.map
@@ -1,12 +0,0 @@
1
- import FrontendModule from "@primate/core/frontend/Module";
2
- import type Render from "@primate/core/frontend/Render";
3
- import type { Component } from "svelte";
4
- export default class Runtime extends FrontendModule<Component> {
5
- name: string;
6
- defaultExtensions: string[];
7
- layouts: boolean;
8
- client: boolean;
9
- render: Render<Component>;
10
- conditions: string[];
11
- }
12
- //# sourceMappingURL=Runtime.d.ts.map
@@ -1,14 +0,0 @@
1
- import FrontendModule from "@primate/core/frontend/Module";
2
- import { render } from "svelte/server";
3
- export default class Runtime extends FrontendModule {
4
- name = "svelte";
5
- defaultExtensions = [".svelte.js", ".svelte.ts", ".svelte"];
6
- layouts = true;
7
- client = true;
8
- render = (view, props) => {
9
- const { head, html } = render(view, { props: { p: { ...props } } });
10
- return { body: html, head };
11
- };
12
- conditions = ["svelte"];
13
- }
14
- //# sourceMappingURL=Runtime.js.map
@@ -1,8 +0,0 @@
1
- import type ValidationError from "@primate/core/client/ValidationError";
2
- type ValidateState<T> = {
3
- error: null | ValidationError;
4
- loading: boolean;
5
- value: T;
6
- };
7
- export type { ValidateState as default };
8
- //# sourceMappingURL=ValidateState.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ValidateState.js.map
@@ -1,8 +0,0 @@
1
- import type ValidateState from "#client/ValidateState";
2
- import type ValidateUpdater from "@primate/core/client/ValidateUpdater";
3
- import type { Readable } from "svelte/store";
4
- type Validated<T> = {
5
- update: (updater: ValidateUpdater<T>) => Promise<void>;
6
- } & Readable<ValidateState<T>>;
7
- export type { Validated as default };
8
- //# sourceMappingURL=Validated.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Validated.js.map
@@ -1,25 +0,0 @@
1
- import type Validated from "#client/Validated";
2
- declare const _default: <T>(initial: T) => {
3
- delete: (url: string, options?: {
4
- headers?: import("@rcompat/type/Dict").default<string>;
5
- map?: ((v: T) => import("@rcompat/type/JSONValue").default) | undefined;
6
- path?: import("@rcompat/type/JSONPointer").default;
7
- } | undefined) => Validated<T>;
8
- patch: (url: string, options?: {
9
- headers?: import("@rcompat/type/Dict").default<string>;
10
- map?: ((v: T) => import("@rcompat/type/JSONValue").default) | undefined;
11
- path?: import("@rcompat/type/JSONPointer").default;
12
- } | undefined) => Validated<T>;
13
- post: (url: string, options?: {
14
- headers?: import("@rcompat/type/Dict").default<string>;
15
- map?: ((v: T) => import("@rcompat/type/JSONValue").default) | undefined;
16
- path?: import("@rcompat/type/JSONPointer").default;
17
- } | undefined) => Validated<T>;
18
- put: (url: string, options?: {
19
- headers?: import("@rcompat/type/Dict").default<string>;
20
- map?: ((v: T) => import("@rcompat/type/JSONValue").default) | undefined;
21
- path?: import("@rcompat/type/JSONPointer").default;
22
- } | undefined) => Validated<T>;
23
- };
24
- export default _default;
25
- //# sourceMappingURL=validate.d.ts.map
@@ -1,28 +0,0 @@
1
- import toValidated from "@primate/core/client/toValidated";
2
- import validate from "@primate/core/client/validate";
3
- import { get, writable } from "svelte/store";
4
- function useValidate(init) {
5
- const { set, subscribe, update } = writable({
6
- error: null,
7
- loading: false,
8
- value: init.initial,
9
- });
10
- async function $update(updater) {
11
- let previous;
12
- update((s) => {
13
- previous = s.value;
14
- return { ...s, error: null, loading: true, value: updater(s.value) };
15
- });
16
- try {
17
- await validate(init, get({ subscribe }).value);
18
- update(s => ({ ...s, loading: false }));
19
- }
20
- catch (e) {
21
- // rollback
22
- set({ error: e, loading: false, value: previous });
23
- }
24
- }
25
- return { subscribe, update: $update };
26
- }
27
- export default toValidated(useValidate);
28
- //# sourceMappingURL=validate.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "#client/Validated";
2
- //# sourceMappingURL=Validated.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Validated.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "#client/validate";
2
- //# sourceMappingURL=validate.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "#client/validate";
2
- //# sourceMappingURL=validate.js.map