@primate/vue 0.14.0 → 0.16.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 (48) hide show
  1. package/lib/app.d.ts +5 -0
  2. package/lib/index.d.ts +2 -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 +32 -0
  10. package/lib/private/client/{validate.js → field.js} +5 -5
  11. package/lib/private/client/form.d.ts +22 -0
  12. package/lib/private/client/form.js +41 -0
  13. package/lib/private/client/index.d.ts +47 -10
  14. package/lib/private/client/index.js +4 -33
  15. package/lib/private/client/root.d.ts +21 -0
  16. package/lib/private/client/root.js +27 -0
  17. package/lib/private/compile.js +5 -4
  18. package/lib/private/create-root.js +7 -3
  19. package/lib/private/default.d.ts +7 -0
  20. package/lib/private/default.js +15 -0
  21. package/lib/private/init.d.ts +5 -0
  22. package/lib/private/init.js +15 -0
  23. package/lib/private/request/store.d.ts +74 -0
  24. package/lib/private/request/store.js +4 -0
  25. package/lib/private/runtime.d.ts +7 -0
  26. package/lib/private/runtime.js +4 -0
  27. package/lib/public/app.d.ts +73 -0
  28. package/lib/public/app.js +4 -0
  29. package/lib/public/browser.d.ts +1 -1
  30. package/lib/public/browser.js +1 -1
  31. package/lib/public/client.d.ts +2 -0
  32. package/lib/public/client.js +2 -0
  33. package/lib/public/default.d.ts +1 -3
  34. package/lib/public/default.js +1 -2
  35. package/lib/public/runtime.d.ts +1 -3
  36. package/lib/public/runtime.js +1 -2
  37. package/package.json +22 -15
  38. package/lib/private/Default.d.ts +0 -16
  39. package/lib/private/Default.js +0 -20
  40. package/lib/private/Runtime.d.ts +0 -11
  41. package/lib/private/Runtime.js +0 -16
  42. package/lib/private/client/Validated.d.ts +0 -11
  43. package/lib/private/client/Validated.js +0 -2
  44. package/lib/private/client/validate.d.ts +0 -25
  45. package/lib/public/Validated.d.ts +0 -2
  46. package/lib/public/Validated.js +0 -2
  47. package/lib/public/validate.d.ts +0 -2
  48. package/lib/public/validate.js +0 -2
package/lib/app.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ declare module "app:vue" {
2
+ import type { RequestPublic } from "@primate/core";
3
+ import type { Ref } from "vue";
4
+ export function useRequest(): Ref<RequestPublic>;
5
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import "./app.d.ts";
2
+ export { default } from "./public/default";
@@ -0,0 +1,5 @@
1
+ import type { Data as CoreData } from "@primate/core/client";
2
+ import type Payload from "#client/Payload";
3
+ type Data = CoreData<Payload>;
4
+ export default Data;
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 default Payload;
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 VueApp {
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
+ export default class VueApp {
4
+ static mount(_view, data) {
5
+ let app = root[data.ssr ? "ssr" : "csr"](root.toProps(data));
6
+ app.mount("#app");
7
+ if (data.spa) {
8
+ const start = () => client.boot((next, update) => {
9
+ app.unmount();
10
+ app = root.csr(root.toProps(next, update));
11
+ app.mount("#app");
12
+ 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,32 @@
1
+ import { type ValidateUpdater, type ValidationError } from "@primate/core/client";
2
+ import { type Ref } from "vue";
3
+ type Validated<T> = {
4
+ error: Ref<null | ValidationError>;
5
+ loading: Ref<boolean>;
6
+ update: (updater: ValidateUpdater<T>) => Promise<void>;
7
+ value: Ref<T>;
8
+ };
9
+ declare const field: <T>(initial: T) => {
10
+ delete: (url: string, options?: {
11
+ headers?: import("@rcompat/type").Dict<string>;
12
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
13
+ path?: import("@rcompat/type").JSONPointer;
14
+ } | undefined) => Validated<T>;
15
+ patch: (url: string, options?: {
16
+ headers?: import("@rcompat/type").Dict<string>;
17
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
18
+ path?: import("@rcompat/type").JSONPointer;
19
+ } | undefined) => Validated<T>;
20
+ post: (url: string, options?: {
21
+ headers?: import("@rcompat/type").Dict<string>;
22
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
23
+ path?: import("@rcompat/type").JSONPointer;
24
+ } | undefined) => Validated<T>;
25
+ put: (url: string, options?: {
26
+ headers?: import("@rcompat/type").Dict<string>;
27
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
28
+ path?: import("@rcompat/type").JSONPointer;
29
+ } | undefined) => Validated<T>;
30
+ };
31
+ export default field;
32
+ //# sourceMappingURL=field.d.ts.map
@@ -1,5 +1,4 @@
1
- import toValidated from "@primate/core/client/toValidated";
2
- import validate from "@primate/core/client/validate";
1
+ import client from "@primate/core/client";
3
2
  import { ref } from "vue";
4
3
  function useValidate(init) {
5
4
  const value = ref(init.initial);
@@ -12,7 +11,7 @@ function useValidate(init) {
12
11
  loading.value = true;
13
12
  error.value = null;
14
13
  try {
15
- await validate(init, next);
14
+ await client.validateField(init, next);
16
15
  }
17
16
  catch (e) {
18
17
  // rollback
@@ -25,5 +24,6 @@ function useValidate(init) {
25
24
  }
26
25
  return { error, loading, update, value };
27
26
  }
28
- export default toValidated(useValidate);
29
- //# sourceMappingURL=validate.js.map
27
+ const field = client.toValidated(useValidate);
28
+ export default field;
29
+ //# sourceMappingURL=field.js.map
@@ -0,0 +1,22 @@
1
+ import type { FormInit } from "@primate/core/client";
2
+ import type { Dict } from "@rcompat/type";
3
+ type FormView<Values extends Dict> = {
4
+ id: string;
5
+ submitting: boolean;
6
+ submitted: boolean;
7
+ submit: (event?: Event) => Promise<void>;
8
+ errors: readonly string[];
9
+ field: <K extends keyof Values & string>(name: K) => {
10
+ name: string;
11
+ value: Values[K];
12
+ error: string | null;
13
+ errors: readonly string[];
14
+ };
15
+ };
16
+ type Initial<Values extends Dict> = FormInit & {
17
+ initial?: Values;
18
+ };
19
+ declare function form<Values extends Dict>(init: Initial<Values>): FormView<Values>;
20
+ declare function form(init?: FormInit): FormView<Dict>;
21
+ export default form;
22
+ //# sourceMappingURL=form.d.ts.map
@@ -0,0 +1,41 @@
1
+ import core from "@primate/core/client";
2
+ import { onUnmounted, shallowRef } from "vue";
3
+ function form(init) {
4
+ const { initial, ...form_init } = (init ?? {});
5
+ const controller = core.createForm(form_init);
6
+ const values = (initial ?? {});
7
+ const snapshot = shallowRef(controller.read());
8
+ const unsub = controller.subscribe((next) => {
9
+ snapshot.value = next;
10
+ });
11
+ onUnmounted(unsub);
12
+ return {
13
+ get id() {
14
+ return snapshot.value.id;
15
+ },
16
+ get submitting() {
17
+ return snapshot.value.submitting;
18
+ },
19
+ get submitted() {
20
+ return snapshot.value.submitted;
21
+ },
22
+ submit(event) {
23
+ return controller.submit(event);
24
+ },
25
+ get errors() {
26
+ return snapshot.value.errors.form;
27
+ },
28
+ field(name) {
29
+ const key = name;
30
+ const errors = snapshot.value.errors.fields[key] ?? [];
31
+ return {
32
+ name: key,
33
+ value: values[name],
34
+ error: errors[0] ?? null,
35
+ errors,
36
+ };
37
+ },
38
+ };
39
+ }
40
+ export default form;
41
+ //# sourceMappingURL=form.js.map
@@ -1,11 +1,48 @@
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 VueClient {
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
+ error: import("vue").Ref<null | import("@primate/core/client").ValidationError>;
11
+ loading: import("vue").Ref<boolean>;
12
+ update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
13
+ value: import("vue").Ref<T, T>;
14
+ };
15
+ patch: (url: string, options?: {
16
+ headers?: import("@rcompat/type").Dict<string>;
17
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
18
+ path?: import("@rcompat/type").JSONPointer;
19
+ } | undefined) => {
20
+ error: import("vue").Ref<null | import("@primate/core/client").ValidationError>;
21
+ loading: import("vue").Ref<boolean>;
22
+ update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
23
+ value: import("vue").Ref<T, T>;
24
+ };
25
+ post: (url: string, options?: {
26
+ headers?: import("@rcompat/type").Dict<string>;
27
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
28
+ path?: import("@rcompat/type").JSONPointer;
29
+ } | undefined) => {
30
+ error: import("vue").Ref<null | import("@primate/core/client").ValidationError>;
31
+ loading: import("vue").Ref<boolean>;
32
+ update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
33
+ value: import("vue").Ref<T, T>;
34
+ };
35
+ put: (url: string, options?: {
36
+ headers?: import("@rcompat/type").Dict<string>;
37
+ map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
38
+ path?: import("@rcompat/type").JSONPointer;
39
+ } | undefined) => {
40
+ error: import("vue").Ref<null | import("@primate/core/client").ValidationError>;
41
+ loading: import("vue").Ref<boolean>;
42
+ update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
43
+ value: import("vue").Ref<T, T>;
44
+ };
45
+ };
46
+ };
47
+ export default client;
11
48
  //# sourceMappingURL=index.d.ts.map
@@ -1,34 +1,5 @@
1
- import spa from "@primate/core/client/spa";
2
- import { createSSRApp } from "vue";
3
- import root from "vue:root";
4
- import * as views from "vue:views";
5
- export default class VueClient {
6
- static mount(_view, data) {
7
- const resolve = (names) => names.map((n) => views[n]);
8
- let app = createSSRApp(root, {
9
- p: {
10
- views: resolve(data.views),
11
- props: data.props,
12
- request: data.request,
13
- update: undefined,
14
- },
15
- });
16
- app.mount("#app");
17
- if (data.spa) {
18
- window.addEventListener("DOMContentLoaded", () => spa((next, update) => {
19
- app.unmount();
20
- app = createSSRApp(root, {
21
- p: {
22
- views: resolve(next.views),
23
- props: next.props,
24
- request: next.request,
25
- update,
26
- },
27
- });
28
- app.mount("#app");
29
- update?.();
30
- }));
31
- }
32
- }
33
- }
1
+ import field from "#client/field";
2
+ import form from "#client/form";
3
+ const client = { form, field };
4
+ export default client;
34
5
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,21 @@
1
+ import type Data from "#client/Data";
2
+ import type { Dict } from "@rcompat/type";
3
+ import type { App, Component } from "vue";
4
+ export type RootProps = {
5
+ views: Component[];
6
+ props: Dict[];
7
+ request: Data["request"] & {
8
+ url: URL;
9
+ };
10
+ update?: () => void;
11
+ };
12
+ declare function toProps(data: Data, update?: () => void): RootProps;
13
+ declare function csr(props: RootProps): App;
14
+ declare function ssr(props: RootProps): App;
15
+ declare const root: {
16
+ toProps: typeof toProps;
17
+ csr: typeof csr;
18
+ ssr: typeof ssr;
19
+ };
20
+ export default root;
21
+ //# sourceMappingURL=root.d.ts.map
@@ -0,0 +1,27 @@
1
+ import { createApp, createSSRApp } from "vue";
2
+ import RootView from "vue:root";
3
+ import * as Views from "vue:views";
4
+ function toProps(data, update) {
5
+ return {
6
+ views: data.views.map((name) => Views[name]),
7
+ props: data.props,
8
+ request: {
9
+ ...data.request,
10
+ url: new URL(data.request.url),
11
+ },
12
+ update,
13
+ };
14
+ }
15
+ function csr(props) {
16
+ return createApp(RootView, { p: props });
17
+ }
18
+ function ssr(props) {
19
+ return createSSRApp(RootView, { p: props });
20
+ }
21
+ const root = {
22
+ toProps,
23
+ csr,
24
+ ssr,
25
+ };
26
+ export default root;
27
+ //# sourceMappingURL=root.js.map
@@ -1,5 +1,5 @@
1
- import typescript from "@rcompat/build/preset/typescript";
2
- import transform from "@rcompat/build/sync/transform";
1
+ import presets from "@primate/core/build/presets";
2
+ import transform from "@primate/core/build/transform";
3
3
  import { compileScript, compileTemplate, parse, } from "vue/compiler-sfc";
4
4
  const genDefaultAs = "__SCRIPT__";
5
5
  const id_size = 8;
@@ -17,7 +17,8 @@ export default {
17
17
  const { has_script, inline, is_typescript } = analyze(descriptor);
18
18
  let module;
19
19
  if (inline) {
20
- // For <script setup>, compile with inlineTemplate to get both script and render
20
+ // for <script setup>, compile with inlineTemplate to get both script and
21
+ // render
21
22
  const script = compileScript(descriptor, {
22
23
  genDefaultAs,
23
24
  id,
@@ -44,7 +45,7 @@ export default {
44
45
  export default { ...__SCRIPT__, render };
45
46
  `;
46
47
  }
47
- return is_typescript ? transform(module, typescript).code : module;
48
+ return is_typescript ? transform(module, presets.typescript).code : module;
48
49
  },
49
50
  };
50
51
  //# sourceMappingURL=compile.js.map
@@ -11,9 +11,12 @@ export default (depth, i18n_active) => {
11
11
  }
12
12
  };
13
13
  const body = depth > 0 ? build_view(0) : "h(\"div\")";
14
- const vueImports = `import {
15
- defineComponent, h${i18n_active ? ", ref, onMounted, onUnmounted" : ""}
16
- } from "vue";`;
14
+ const vueImports = `
15
+ import {
16
+ defineComponent, h${i18n_active ? ", ref, onMounted, onUnmounted" : ""}
17
+ } from "vue";
18
+ import { setRequest } from "@primate/vue/app";
19
+ `;
17
20
  const i18nImports = i18n_active
18
21
  ? `
19
22
  import t from "#i18n";
@@ -45,6 +48,7 @@ export default defineComponent({
45
48
  ${i18nSetup}
46
49
  return () => {
47
50
  const p = props.p;
51
+ setRequest(props.p.request);
48
52
  return ${body};
49
53
  };
50
54
  },
@@ -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
@@ -0,0 +1,15 @@
1
+ import compile from "#compile";
2
+ import create_root from "#create-root";
3
+ import init from "#init";
4
+ import frontend from "@primate/core/frontend";
5
+ export default frontend({
6
+ ...init,
7
+ root: {
8
+ create: create_root,
9
+ },
10
+ compile: {
11
+ client: (text, _, root) => ({ js: root ? text : compile.server(text) }),
12
+ server: (text, file) => file.path.startsWith("root:") ? text : compile.server(text),
13
+ },
14
+ });
15
+ //# sourceMappingURL=default.js.map
@@ -0,0 +1,5 @@
1
+ import type { Init } from "@primate/core/frontend";
2
+ import { type Renderer } from "vue";
3
+ declare const module: Init<Renderer>;
4
+ export default module;
5
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { createSSRApp } from "vue";
2
+ import { renderToString } from "vue/server-renderer";
3
+ const module = {
4
+ name: "vue",
5
+ extensions: [".vue"],
6
+ layouts: true,
7
+ client: true,
8
+ async render(view, props) {
9
+ const app = createSSRApp(view, { p: { ...props } });
10
+ const html = await renderToString(app);
11
+ return { body: `<div id="app">${html}</div>` };
12
+ },
13
+ };
14
+ export default module;
15
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1,74 @@
1
+ import type { RequestPublic } from "@primate/core";
2
+ declare const store: import("vue").Ref<{
3
+ cookies: import("@rcompat/type").Dict<string>;
4
+ headers: import("@rcompat/type").Dict<string>;
5
+ query: import("@rcompat/type").Dict<string>;
6
+ url: {
7
+ hash: string;
8
+ host: string;
9
+ hostname: string;
10
+ href: string;
11
+ toString: () => string;
12
+ readonly origin: string;
13
+ password: string;
14
+ pathname: string;
15
+ port: string;
16
+ protocol: string;
17
+ search: string;
18
+ readonly searchParams: {
19
+ readonly size: number;
20
+ append: (name: string, value: string) => void;
21
+ delete: (name: string, value?: string) => void;
22
+ get: (name: string) => string | null;
23
+ getAll: (name: string) => string[];
24
+ has: (name: string, value?: string) => boolean;
25
+ set: (name: string, value: string) => void;
26
+ sort: () => void;
27
+ toString: () => string;
28
+ forEach: (callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any) => void;
29
+ entries: () => URLSearchParamsIterator<[string, string]>;
30
+ keys: () => URLSearchParamsIterator<string>;
31
+ values: () => URLSearchParamsIterator<string>;
32
+ [Symbol.iterator]: () => URLSearchParamsIterator<[string, string]>;
33
+ };
34
+ username: string;
35
+ toJSON: () => string;
36
+ };
37
+ }, RequestPublic | {
38
+ cookies: import("@rcompat/type").Dict<string>;
39
+ headers: import("@rcompat/type").Dict<string>;
40
+ query: import("@rcompat/type").Dict<string>;
41
+ url: {
42
+ hash: string;
43
+ host: string;
44
+ hostname: string;
45
+ href: string;
46
+ toString: () => string;
47
+ readonly origin: string;
48
+ password: string;
49
+ pathname: string;
50
+ port: string;
51
+ protocol: string;
52
+ search: string;
53
+ readonly searchParams: {
54
+ readonly size: number;
55
+ append: (name: string, value: string) => void;
56
+ delete: (name: string, value?: string) => void;
57
+ get: (name: string) => string | null;
58
+ getAll: (name: string) => string[];
59
+ has: (name: string, value?: string) => boolean;
60
+ set: (name: string, value: string) => void;
61
+ sort: () => void;
62
+ toString: () => string;
63
+ forEach: (callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any) => void;
64
+ entries: () => URLSearchParamsIterator<[string, string]>;
65
+ keys: () => URLSearchParamsIterator<string>;
66
+ values: () => URLSearchParamsIterator<string>;
67
+ [Symbol.iterator]: () => URLSearchParamsIterator<[string, string]>;
68
+ };
69
+ username: string;
70
+ toJSON: () => string;
71
+ };
72
+ }>;
73
+ export default store;
74
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1,4 @@
1
+ import { ref } from "vue";
2
+ const store = ref(undefined);
3
+ export default store;
4
+ //# 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,73 @@
1
+ export declare function useRequest(): import("vue").Ref<{
2
+ cookies: import("@rcompat/type").Dict<string>;
3
+ headers: import("@rcompat/type").Dict<string>;
4
+ query: import("@rcompat/type").Dict<string>;
5
+ url: {
6
+ hash: string;
7
+ host: string;
8
+ hostname: string;
9
+ href: string;
10
+ toString: () => string;
11
+ readonly origin: string;
12
+ password: string;
13
+ pathname: string;
14
+ port: string;
15
+ protocol: string;
16
+ search: string;
17
+ readonly searchParams: {
18
+ readonly size: number;
19
+ append: (name: string, value: string) => void;
20
+ delete: (name: string, value?: string) => void;
21
+ get: (name: string) => string | null;
22
+ getAll: (name: string) => string[];
23
+ has: (name: string, value?: string) => boolean;
24
+ set: (name: string, value: string) => void;
25
+ sort: () => void;
26
+ toString: () => string;
27
+ forEach: (callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any) => void;
28
+ entries: () => URLSearchParamsIterator<[string, string]>;
29
+ keys: () => URLSearchParamsIterator<string>;
30
+ values: () => URLSearchParamsIterator<string>;
31
+ [Symbol.iterator]: () => URLSearchParamsIterator<[string, string]>;
32
+ };
33
+ username: string;
34
+ toJSON: () => string;
35
+ };
36
+ }, import("@primate/core/index").RequestPublic | {
37
+ cookies: import("@rcompat/type").Dict<string>;
38
+ headers: import("@rcompat/type").Dict<string>;
39
+ query: import("@rcompat/type").Dict<string>;
40
+ url: {
41
+ hash: string;
42
+ host: string;
43
+ hostname: string;
44
+ href: string;
45
+ toString: () => string;
46
+ readonly origin: string;
47
+ password: string;
48
+ pathname: string;
49
+ port: string;
50
+ protocol: string;
51
+ search: string;
52
+ readonly searchParams: {
53
+ readonly size: number;
54
+ append: (name: string, value: string) => void;
55
+ delete: (name: string, value?: string) => void;
56
+ get: (name: string) => string | null;
57
+ getAll: (name: string) => string[];
58
+ has: (name: string, value?: string) => boolean;
59
+ set: (name: string, value: string) => void;
60
+ sort: () => void;
61
+ toString: () => string;
62
+ forEach: (callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any) => void;
63
+ entries: () => URLSearchParamsIterator<[string, string]>;
64
+ keys: () => URLSearchParamsIterator<string>;
65
+ values: () => URLSearchParamsIterator<string>;
66
+ [Symbol.iterator]: () => URLSearchParamsIterator<[string, string]>;
67
+ };
68
+ username: string;
69
+ toJSON: () => string;
70
+ };
71
+ }>;
72
+ export declare const setRequest: (value: any) => void;
73
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1,4 @@
1
+ import store from "#request/store";
2
+ export function useRequest() { return store; }
3
+ export const setRequest = (value) => { store.value = value; };
4
+ //# 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,49 +1,56 @@
1
1
  {
2
2
  "name": "@primate/vue",
3
- "version": "0.14.0",
4
- "description": "Primate Vue frontend",
3
+ "version": "0.16.0",
4
+ "description": "Vue for Primate",
5
5
  "homepage": "https://primate.run/docs/frontend/vue",
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/vue"
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/build": "^0.15.0",
20
- "@primate/core": "^0.4.0"
21
+ "@primate/core": "^0.6.0"
22
+ },
23
+ "devDependencies": {
24
+ "@rcompat/type": "^0.11.1",
25
+ "@primate/test": "^0.0.0"
21
26
  },
22
27
  "peerDependencies": {
23
28
  "vue": "3",
24
- "primate": "^0.35.0"
29
+ "primate": "^0.37.0"
25
30
  },
26
- "type": "module",
27
31
  "imports": {
28
32
  "#*": {
29
- "apekit": "./src/private/*.ts",
33
+ "@primate/source": "./src/private/*.ts",
30
34
  "default": "./lib/private/*.js"
31
35
  }
32
36
  },
33
37
  "exports": {
34
38
  ".": {
39
+ "types": "./lib/index.d.ts",
40
+ "@primate/source": "./src/public/default.ts",
35
41
  "browser": "./lib/public/browser.js",
36
42
  "runtime": "./lib/public/runtime.js",
37
43
  "default": "./lib/public/default.js"
38
44
  },
39
45
  "./*": {
40
- "apekit": "./src/public/*.ts",
46
+ "@primate/source": "./src/public/*.ts",
41
47
  "default": "./lib/public/*.js"
42
48
  }
43
49
  },
44
50
  "scripts": {
45
- "build": "npm run clean && tsc",
51
+ "build": "npm run clean && tsc && cp src/types/{app,index}.d.ts lib",
46
52
  "clean": "rm -rf ./lib",
47
- "lint": "eslint ."
53
+ "lint": "eslint .",
54
+ "test": "npx proby"
48
55
  }
49
56
  }
@@ -1,16 +0,0 @@
1
- import Runtime from "#Runtime";
2
- import type BuildApp from "@primate/core/BuildApp";
3
- import type NextBuild from "@primate/core/NextBuild";
4
- export default class Default extends Runtime {
5
- compile: {
6
- client: (text: string, _: unknown, root: boolean) => {
7
- js: string;
8
- };
9
- server: (text: string) => string;
10
- };
11
- root: {
12
- create: (depth: number, i18n_active: boolean) => string;
13
- };
14
- build(app: BuildApp, next: NextBuild): Promise<BuildApp>;
15
- }
16
- //# sourceMappingURL=Default.d.ts.map
@@ -1,20 +0,0 @@
1
- import compile from "#compile";
2
- import create_root from "#create-root";
3
- import Runtime from "#Runtime";
4
- export default class Default extends Runtime {
5
- compile = {
6
- client: (text, _, root) => ({ js: root ? text : compile.server(text) }),
7
- server: (text) => compile.server(text),
8
- };
9
- root = {
10
- create: create_root,
11
- };
12
- async build(app, next) {
13
- this.prebuild(app);
14
- const source = this.root.create(app.depth(), app.i18n_active);
15
- app.addRoot(this.rootname, source);
16
- this.publish(app);
17
- return next(app);
18
- }
19
- }
20
- //# sourceMappingURL=Default.js.map
@@ -1,11 +0,0 @@
1
- import FrontendModule from "@primate/core/frontend/Module";
2
- import type Render from "@primate/core/frontend/Render";
3
- import { type Renderer } from "vue";
4
- export default class Runtime extends FrontendModule<Renderer> {
5
- name: string;
6
- defaultExtensions: string[];
7
- layouts: boolean;
8
- client: boolean;
9
- render: Render<Renderer>;
10
- }
11
- //# sourceMappingURL=Runtime.d.ts.map
@@ -1,16 +0,0 @@
1
- import FrontendModule from "@primate/core/frontend/Module";
2
- import { createSSRApp } from "vue";
3
- import { renderToString } from "vue/server-renderer";
4
- export default class Runtime extends FrontendModule {
5
- name = "vue";
6
- defaultExtensions = [".vue"];
7
- layouts = true;
8
- client = true;
9
- render = async (view, props) => {
10
- const app = createSSRApp(view, { p: { ...props } });
11
- const html = await renderToString(app);
12
- return { body: `<div id="app">${html}</div>` };
13
- };
14
- }
15
- ;
16
- //# sourceMappingURL=Runtime.js.map
@@ -1,11 +0,0 @@
1
- import type ValidateUpdater from "@primate/core/client/ValidateUpdater";
2
- import type ValidationError from "@primate/core/client/ValidationError";
3
- import { type Ref } from "vue";
4
- type Validated<T> = {
5
- error: Ref<null | ValidationError>;
6
- loading: Ref<boolean>;
7
- update: (updater: ValidateUpdater<T>) => Promise<void>;
8
- value: Ref<T>;
9
- };
10
- export type { Validated as default };
11
- //# 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,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