@fragno-dev/example-fragment 0.0.16 → 0.0.18

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @fragno-dev/example-fragment
2
2
 
3
+ ## 0.0.18
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [aabd6d2]
8
+ - @fragno-dev/core@0.1.10
9
+
10
+ ## 0.0.17
11
+
12
+ ### Patch Changes
13
+
14
+ - 5ea24d2: refactor: improve Fragment builder and instatiator
15
+ - Updated dependencies [e848208]
16
+ - Updated dependencies [7276378]
17
+ - Updated dependencies [5ea24d2]
18
+ - Updated dependencies [f22c503]
19
+ - @fragno-dev/core@0.1.9
20
+
3
21
  ## 0.0.16
4
22
 
5
23
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fragno-dev/example-fragment",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "exports": {
5
5
  ".": {
6
6
  "development": {
@@ -58,7 +58,7 @@
58
58
  "type": "module",
59
59
  "dependencies": {
60
60
  "zod": "^4.0.5",
61
- "@fragno-dev/core": "0.1.8"
61
+ "@fragno-dev/core": "0.1.10"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "typescript": "^5.9.3",
@@ -70,8 +70,15 @@
70
70
  "devDependencies": {
71
71
  "@types/node": "^22",
72
72
  "@fragno-private/typescript-config": "0.0.1",
73
- "@fragno-dev/unplugin-fragno": "0.0.3"
73
+ "@fragno-dev/unplugin-fragno": "0.0.6"
74
74
  },
75
+ "repository": {
76
+ "type": "git",
77
+ "url": "https://github.com/rejot-dev/fragno.git",
78
+ "directory": "example-fragments/example-fragment"
79
+ },
80
+ "homepage": "https://fragno.dev",
81
+ "license": "MIT",
75
82
  "scripts": {
76
83
  "build": "tsdown",
77
84
  "build:watch": "tsdown --watch",
@@ -1,6 +1,6 @@
1
1
  import { useFragno } from "@fragno-dev/core/react";
2
2
  import { createExampleFragmentClients } from "..";
3
- import type { FragnoPublicClientConfig } from "@fragno-dev/core";
3
+ import type { FragnoPublicClientConfig } from "@fragno-dev/core/client";
4
4
 
5
5
  export function createExampleFragmentClient(config: FragnoPublicClientConfig = {}) {
6
6
  return useFragno(createExampleFragmentClients(config));
@@ -1,6 +1,6 @@
1
1
  import { useFragno } from "@fragno-dev/core/solid";
2
2
  import { createExampleFragmentClients } from "..";
3
- import type { FragnoPublicClientConfig } from "@fragno-dev/core";
3
+ import type { FragnoPublicClientConfig } from "@fragno-dev/core/client";
4
4
 
5
5
  export function createExampleFragmentClient(config: FragnoPublicClientConfig = {}) {
6
6
  return useFragno(createExampleFragmentClients(config));
@@ -1,6 +1,6 @@
1
1
  import { useFragno } from "@fragno-dev/core/svelte";
2
2
  import { createExampleFragmentClients } from "..";
3
- import type { FragnoPublicClientConfig } from "@fragno-dev/core";
3
+ import type { FragnoPublicClientConfig } from "@fragno-dev/core/client";
4
4
 
5
5
  export function createExampleFragmentClient(config: FragnoPublicClientConfig = {}) {
6
6
  return useFragno(createExampleFragmentClients(config));
@@ -1,6 +1,6 @@
1
1
  import { useFragno } from "@fragno-dev/core/vanilla";
2
2
  import { createExampleFragmentClients } from "..";
3
- import type { FragnoPublicClientConfig } from "@fragno-dev/core";
3
+ import type { FragnoPublicClientConfig } from "@fragno-dev/core/client";
4
4
 
5
5
  export function createExampleFragmentClient(config: FragnoPublicClientConfig = {}) {
6
6
  return useFragno(createExampleFragmentClients(config));
package/src/client/vue.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { useFragno } from "@fragno-dev/core/vue";
2
2
  import { createExampleFragmentClients } from "..";
3
- import type { FragnoPublicClientConfig } from "@fragno-dev/core";
3
+ import type { FragnoPublicClientConfig } from "@fragno-dev/core/client";
4
4
 
5
5
  export function createExampleFragmentClient(config: FragnoPublicClientConfig = {}) {
6
6
  return useFragno(createExampleFragmentClients(config));
package/src/index.ts CHANGED
@@ -1,12 +1,6 @@
1
- import {
2
- defineFragment,
3
- defineRoute,
4
- defineRoutes,
5
- createFragment,
6
- type FragnoPublicClientConfig,
7
- type FragnoPublicConfig,
8
- } from "@fragno-dev/core";
9
- import { createClientBuilder } from "@fragno-dev/core/client";
1
+ import { defineFragment, instantiate, type FragnoPublicConfig } from "@fragno-dev/core";
2
+ import { defineRoutes } from "@fragno-dev/core/route";
3
+ import { createClientBuilder, type FragnoPublicClientConfig } from "@fragno-dev/core/client";
10
4
  import { z } from "zod";
11
5
 
12
6
  import { readFile } from "node:fs/promises";
@@ -21,10 +15,6 @@ type ExampleRouteConfig = {
21
15
  initialData: string;
22
16
  };
23
17
 
24
- type ExampleRouteDeps = {
25
- serverSideData: { value: string };
26
- };
27
-
28
18
  const getHashFromHostsFileData = async () => {
29
19
  const hostsPath =
30
20
  platform() === "win32" ? "C:\\Windows\\System32\\drivers\\etc\\hosts" : "/etc/hosts";
@@ -37,8 +27,22 @@ const getHashFromHostsFileData = async () => {
37
27
  }
38
28
  };
39
29
 
40
- const exampleRoutesFactory = defineRoutes<ExampleRouteConfig, ExampleRouteDeps>().create(
41
- ({ deps }) => {
30
+ const exampleFragmentDefinition = defineFragment<ExampleFragmentServerConfig>("example-fragment")
31
+ .withDependencies(({ config }) => {
32
+ return {
33
+ serverSideData: { value: config.initialData ?? "Hello World! This is a server-side data." },
34
+ };
35
+ })
36
+ .providesBaseService(({ deps }) => {
37
+ return {
38
+ getData: () => deps.serverSideData.value,
39
+ getHashFromHostsFileData,
40
+ };
41
+ })
42
+ .build();
43
+
44
+ const exampleRoutesFactory = defineRoutes(exampleFragmentDefinition).create(
45
+ ({ defineRoute, deps }) => {
42
46
  const { serverSideData } = deps;
43
47
 
44
48
  return [
@@ -98,19 +102,6 @@ const exampleRoutesFactory = defineRoutes<ExampleRouteConfig, ExampleRouteDeps>(
98
102
  },
99
103
  );
100
104
 
101
- const exampleFragmentDefinition = defineFragment<ExampleFragmentServerConfig>("example-fragment")
102
- .withDependencies(({ config }) => {
103
- return {
104
- serverSideData: { value: config.initialData ?? "Hello World! This is a server-side data." },
105
- };
106
- })
107
- .providesService(({ deps }) => {
108
- return {
109
- getData: () => deps.serverSideData.value,
110
- getHashFromHostsFileData,
111
- };
112
- });
113
-
114
105
  export function createExampleFragment(
115
106
  serverConfig: ExampleFragmentServerConfig = {},
116
107
  options: FragnoPublicConfig = {},
@@ -119,12 +110,11 @@ export function createExampleFragment(
119
110
  initialData: serverConfig.initialData ?? "Hello World! This is a server-side data.",
120
111
  };
121
112
 
122
- return createFragment(
123
- exampleFragmentDefinition,
124
- { ...serverConfig, ...config },
125
- [exampleRoutesFactory],
126
- options,
127
- );
113
+ return instantiate(exampleFragmentDefinition)
114
+ .withConfig(config)
115
+ .withRoutes([exampleRoutesFactory]) //
116
+ .withOptions(options)
117
+ .build();
128
118
  }
129
119
 
130
120
  export function createExampleFragmentClients(fragnoConfig: FragnoPublicClientConfig) {
@@ -136,4 +126,4 @@ export function createExampleFragmentClients(fragnoConfig: FragnoPublicClientCon
136
126
  useSampleMutator: b.createMutator("POST", "/sample"),
137
127
  };
138
128
  }
139
- export type { FragnoRouteConfig } from "@fragno-dev/core/api";
129
+ export type { FragnoRouteConfig } from "@fragno-dev/core";