jazz-vue 0.8.6
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 +1000 -0
- package/LICENSE.txt +19 -0
- package/README.md +3 -0
- package/dist/ProgressiveImg.vue.d.ts +27 -0
- package/dist/auth/DemoAuthBasicUI.vue.d.ts +9 -0
- package/dist/auth/useDemoAuth.d.ts +56 -0
- package/dist/createJazzVueApp.d.ts +29 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +361 -0
- package/package.json +31 -0
- package/src/ProgressiveImg.vue +82 -0
- package/src/auth/DemoAuthBasicUI.vue +123 -0
- package/src/auth/useDemoAuth.ts +77 -0
- package/src/createJazzVueApp.ts +347 -0
- package/src/index.ts +4 -0
- package/tsconfig.json +20 -0
- package/vite.config.ts +27 -0
@@ -0,0 +1,123 @@
|
|
1
|
+
<template>
|
2
|
+
<div
|
3
|
+
:style="containerStyle"
|
4
|
+
>
|
5
|
+
<div v-if="state.state === 'loading'">Loading...</div>
|
6
|
+
<template v-else-if="state.state === 'ready'">
|
7
|
+
<h1 :style="{ color: darkMode ? '#fff' : '#000', textAlign: 'center' }">
|
8
|
+
{{ appName }}
|
9
|
+
</h1>
|
10
|
+
<div v-for="error in state.errors" :key="error" style="color: red">
|
11
|
+
{{ error }}
|
12
|
+
</div>
|
13
|
+
<form
|
14
|
+
@submit.prevent="signUp"
|
15
|
+
style="display: flex; flex-direction: column; gap: 0.5rem;"
|
16
|
+
>
|
17
|
+
<input
|
18
|
+
v-model="username"
|
19
|
+
placeholder="Display name"
|
20
|
+
autoComplete="webauthn"
|
21
|
+
:style="inputStyle"
|
22
|
+
/>
|
23
|
+
<input
|
24
|
+
type="submit"
|
25
|
+
value="Sign up"
|
26
|
+
:style="buttonStyle"
|
27
|
+
/>
|
28
|
+
</form>
|
29
|
+
<div
|
30
|
+
v-if="state.existingUsers.length > 0"
|
31
|
+
style="display: flex; flex-direction: column; gap: 0.5rem;"
|
32
|
+
>
|
33
|
+
<p
|
34
|
+
:style="{
|
35
|
+
color: darkMode ? '#e2e2e2' : '#000',
|
36
|
+
textAlign: 'center',
|
37
|
+
paddingTop: '0.5rem',
|
38
|
+
borderTop: '1px solid',
|
39
|
+
borderColor: darkMode ? '#111' : '#e2e2e2',
|
40
|
+
}"
|
41
|
+
>
|
42
|
+
Log in as
|
43
|
+
</p>
|
44
|
+
<button
|
45
|
+
v-for="user in state.existingUsers"
|
46
|
+
:key="user"
|
47
|
+
@click="logInAs(user)"
|
48
|
+
type="button"
|
49
|
+
:aria-label="`Log in as ${user}`"
|
50
|
+
:style="loginButtonStyle"
|
51
|
+
>
|
52
|
+
{{ user }}
|
53
|
+
</button>
|
54
|
+
</div>
|
55
|
+
</template>
|
56
|
+
</div>
|
57
|
+
</template>
|
58
|
+
|
59
|
+
<script setup lang="ts">
|
60
|
+
import { computed, ref } from "vue";
|
61
|
+
import { DemoAuthState } from "./useDemoAuth.js";
|
62
|
+
|
63
|
+
const props = defineProps<{
|
64
|
+
appName: string;
|
65
|
+
state: DemoAuthState;
|
66
|
+
}>();
|
67
|
+
|
68
|
+
const username = ref("");
|
69
|
+
const darkMode = computed(
|
70
|
+
() =>
|
71
|
+
window.matchMedia &&
|
72
|
+
window.matchMedia("(prefers-color-scheme: dark)").matches,
|
73
|
+
);
|
74
|
+
|
75
|
+
const containerStyle = computed(() => ({
|
76
|
+
minHeight: "100vh",
|
77
|
+
display: "flex",
|
78
|
+
flexDirection: "column" as const,
|
79
|
+
justifyContent: "center",
|
80
|
+
alignItems: "center",
|
81
|
+
width: "100%",
|
82
|
+
padding: "1rem",
|
83
|
+
maxWidth: "100vw",
|
84
|
+
gap: "2rem",
|
85
|
+
margin: "0",
|
86
|
+
...(darkMode.value ? { background: "#000" } : {}),
|
87
|
+
}));
|
88
|
+
|
89
|
+
const inputStyle = computed(() => ({
|
90
|
+
border: darkMode.value ? "2px solid #444" : "2px solid #ddd",
|
91
|
+
padding: "11px 8px",
|
92
|
+
borderRadius: "6px",
|
93
|
+
background: darkMode.value ? "#000" : "#fff",
|
94
|
+
color: darkMode.value ? "#fff" : "#000",
|
95
|
+
}));
|
96
|
+
|
97
|
+
const buttonStyle = computed(() => ({
|
98
|
+
padding: "13px 5px",
|
99
|
+
border: "none",
|
100
|
+
borderRadius: "6px",
|
101
|
+
cursor: "pointer",
|
102
|
+
background: darkMode.value ? "#444" : "#ddd",
|
103
|
+
color: darkMode.value ? "#fff" : "#000",
|
104
|
+
}));
|
105
|
+
|
106
|
+
const loginButtonStyle = computed(() => ({
|
107
|
+
background: darkMode.value ? "#0d0d0d" : "#eee",
|
108
|
+
color: darkMode.value ? "#fff" : "#000",
|
109
|
+
padding: "0.5rem",
|
110
|
+
border: "none",
|
111
|
+
borderRadius: "6px",
|
112
|
+
}));
|
113
|
+
|
114
|
+
const signUp = () => {
|
115
|
+
(props.state as DemoAuthState & { state: "ready" }).signUp(username.value);
|
116
|
+
username.value = "";
|
117
|
+
};
|
118
|
+
|
119
|
+
const logInAs = (user: string) => {
|
120
|
+
(props.state as DemoAuthState & { state: "ready" }).logInAs(user);
|
121
|
+
};
|
122
|
+
</script>
|
123
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import { AgentSecret } from "cojson";
|
2
|
+
import { BrowserDemoAuth } from "jazz-browser";
|
3
|
+
import { Account, ID } from "jazz-tools";
|
4
|
+
import { onUnmounted, reactive, ref } from "vue";
|
5
|
+
import { logoutHandler } from "../createJazzVueApp.js";
|
6
|
+
|
7
|
+
export type DemoAuthState = (
|
8
|
+
| {
|
9
|
+
state: "uninitialized";
|
10
|
+
}
|
11
|
+
| {
|
12
|
+
state: "loading";
|
13
|
+
}
|
14
|
+
| {
|
15
|
+
state: "ready";
|
16
|
+
existingUsers: string[];
|
17
|
+
signUp: (username: string) => void;
|
18
|
+
logInAs: (existingUser: string) => void;
|
19
|
+
}
|
20
|
+
| {
|
21
|
+
state: "signedIn";
|
22
|
+
logOut: () => void;
|
23
|
+
}
|
24
|
+
) & {
|
25
|
+
errors: string[];
|
26
|
+
};
|
27
|
+
|
28
|
+
/** @category Auth Providers */
|
29
|
+
export function useDemoAuth({
|
30
|
+
seedAccounts,
|
31
|
+
}: {
|
32
|
+
seedAccounts?: {
|
33
|
+
[name: string]: { accountID: ID<Account>; accountSecret: AgentSecret };
|
34
|
+
};
|
35
|
+
} = {}) {
|
36
|
+
const state = reactive<DemoAuthState>({
|
37
|
+
state: "loading",
|
38
|
+
errors: [],
|
39
|
+
});
|
40
|
+
|
41
|
+
const authMethod = ref(
|
42
|
+
new BrowserDemoAuth(
|
43
|
+
{
|
44
|
+
onReady: ({ signUp, existingUsers, logInAs }) => {
|
45
|
+
state.state = "ready";
|
46
|
+
(state as DemoAuthState & { state: "ready" }).signUp = signUp;
|
47
|
+
(state as DemoAuthState & { state: "ready" }).existingUsers =
|
48
|
+
existingUsers;
|
49
|
+
(state as DemoAuthState & { state: "ready" }).logInAs = logInAs;
|
50
|
+
state.errors = [];
|
51
|
+
},
|
52
|
+
onSignedIn: ({ logOut }) => {
|
53
|
+
state.state = "signedIn";
|
54
|
+
(state as DemoAuthState & { state: "signedIn" }).logOut = () => {
|
55
|
+
logOut();
|
56
|
+
state.state = "ready";
|
57
|
+
state.errors = [];
|
58
|
+
};
|
59
|
+
state.errors = [];
|
60
|
+
logoutHandler.value = (
|
61
|
+
state as DemoAuthState & { state: "signedIn" }
|
62
|
+
).logOut;
|
63
|
+
},
|
64
|
+
onError: (error) => {
|
65
|
+
state.errors.push(error.toString());
|
66
|
+
},
|
67
|
+
},
|
68
|
+
seedAccounts,
|
69
|
+
),
|
70
|
+
);
|
71
|
+
onUnmounted(() => {
|
72
|
+
if (state.state === "signedIn") {
|
73
|
+
logoutHandler.value = undefined;
|
74
|
+
}
|
75
|
+
});
|
76
|
+
return { authMethod, state };
|
77
|
+
}
|
@@ -0,0 +1,347 @@
|
|
1
|
+
import {
|
2
|
+
BrowserContext,
|
3
|
+
BrowserGuestContext,
|
4
|
+
consumeInviteLinkFromWindowLocation,
|
5
|
+
createJazzBrowserContext,
|
6
|
+
} from "jazz-browser";
|
7
|
+
import {
|
8
|
+
Account,
|
9
|
+
AnonymousJazzAgent,
|
10
|
+
AuthMethod,
|
11
|
+
CoValue,
|
12
|
+
CoValueClass,
|
13
|
+
DeeplyLoaded,
|
14
|
+
DepthsIn,
|
15
|
+
ID,
|
16
|
+
subscribeToCoValue,
|
17
|
+
} from "jazz-tools";
|
18
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
19
|
+
import {
|
20
|
+
Component,
|
21
|
+
ComputedRef,
|
22
|
+
PropType,
|
23
|
+
Ref,
|
24
|
+
ShallowRef,
|
25
|
+
computed,
|
26
|
+
defineComponent,
|
27
|
+
inject,
|
28
|
+
onMounted,
|
29
|
+
onUnmounted,
|
30
|
+
provide,
|
31
|
+
ref,
|
32
|
+
shallowRef,
|
33
|
+
toRaw,
|
34
|
+
watch,
|
35
|
+
} from "vue";
|
36
|
+
|
37
|
+
export const logoutHandler = ref<() => void>();
|
38
|
+
|
39
|
+
export interface JazzVueApp<Acc extends Account> {
|
40
|
+
JazzProvider: Component;
|
41
|
+
|
42
|
+
useAccount(): { me: ComputedRef<Acc>; logOut: () => void };
|
43
|
+
useAccount<D extends DepthsIn<Acc>>(
|
44
|
+
depth: D,
|
45
|
+
): {
|
46
|
+
me: ComputedRef<DeeplyLoaded<Acc, D> | undefined>;
|
47
|
+
logOut: () => void;
|
48
|
+
};
|
49
|
+
|
50
|
+
useAccountOrGuest(): { me: ComputedRef<Acc | AnonymousJazzAgent> };
|
51
|
+
useAccountOrGuest<D extends DepthsIn<Acc>>(
|
52
|
+
depth: D,
|
53
|
+
): {
|
54
|
+
me: ComputedRef<DeeplyLoaded<Acc, D> | undefined | AnonymousJazzAgent>;
|
55
|
+
};
|
56
|
+
|
57
|
+
useCoState<V extends CoValue, D>(
|
58
|
+
Schema: CoValueClass<V>,
|
59
|
+
id: ID<V> | undefined,
|
60
|
+
depth?: D & DepthsIn<V>,
|
61
|
+
): Ref<DeeplyLoaded<V, D> | undefined>;
|
62
|
+
|
63
|
+
useAcceptInvite<V extends CoValue>(args: {
|
64
|
+
invitedObjectSchema: CoValueClass<V>;
|
65
|
+
onAccept: (projectID: ID<V>) => void;
|
66
|
+
forValueHint?: string;
|
67
|
+
}): void;
|
68
|
+
}
|
69
|
+
|
70
|
+
const JazzContextSymbol = Symbol("JazzContext");
|
71
|
+
|
72
|
+
export function createJazzVueApp<Acc extends Account>({
|
73
|
+
AccountSchema = Account as any,
|
74
|
+
} = {}): JazzVueApp<Acc> {
|
75
|
+
const JazzProvider = defineComponent({
|
76
|
+
name: "JazzProvider",
|
77
|
+
props: {
|
78
|
+
auth: {
|
79
|
+
type: [String, Object] as PropType<AuthMethod | "guest">,
|
80
|
+
required: true,
|
81
|
+
},
|
82
|
+
peer: {
|
83
|
+
type: String as PropType<`wss://${string}` | `ws://${string}`>,
|
84
|
+
required: true,
|
85
|
+
},
|
86
|
+
storage: {
|
87
|
+
type: String as PropType<"indexedDB" | "singleTabOPFS">,
|
88
|
+
default: undefined,
|
89
|
+
},
|
90
|
+
},
|
91
|
+
setup(props, { slots }) {
|
92
|
+
const ctx = ref<BrowserContext<Acc> | BrowserGuestContext | undefined>(
|
93
|
+
undefined,
|
94
|
+
);
|
95
|
+
|
96
|
+
const key = ref(0);
|
97
|
+
|
98
|
+
provide(JazzContextSymbol, ctx);
|
99
|
+
|
100
|
+
const initializeContext = async () => {
|
101
|
+
if (ctx.value) {
|
102
|
+
ctx.value.done?.();
|
103
|
+
ctx.value = undefined;
|
104
|
+
}
|
105
|
+
|
106
|
+
try {
|
107
|
+
const context = await createJazzBrowserContext<Acc>(
|
108
|
+
props.auth === "guest"
|
109
|
+
? { peer: props.peer, storage: props.storage }
|
110
|
+
: {
|
111
|
+
AccountSchema,
|
112
|
+
auth: props.auth,
|
113
|
+
peer: props.peer,
|
114
|
+
storage: props.storage,
|
115
|
+
},
|
116
|
+
);
|
117
|
+
|
118
|
+
ctx.value = {
|
119
|
+
...context,
|
120
|
+
logOut: () => {
|
121
|
+
logoutHandler.value?.();
|
122
|
+
// context.logOut();
|
123
|
+
key.value += 1;
|
124
|
+
},
|
125
|
+
};
|
126
|
+
} catch (e) {
|
127
|
+
console.error("Error creating Jazz browser context:", e);
|
128
|
+
}
|
129
|
+
};
|
130
|
+
|
131
|
+
onMounted(() => {
|
132
|
+
void initializeContext();
|
133
|
+
});
|
134
|
+
|
135
|
+
watch(
|
136
|
+
() => key.value,
|
137
|
+
async () => {
|
138
|
+
await initializeContext();
|
139
|
+
},
|
140
|
+
);
|
141
|
+
|
142
|
+
onUnmounted(() => {
|
143
|
+
if (ctx.value) ctx.value.done?.();
|
144
|
+
});
|
145
|
+
|
146
|
+
return () => (ctx.value ? slots.default?.() : null);
|
147
|
+
},
|
148
|
+
});
|
149
|
+
|
150
|
+
function useJazzContext() {
|
151
|
+
const context =
|
152
|
+
inject<Ref<BrowserContext<Acc> | BrowserGuestContext>>(JazzContextSymbol);
|
153
|
+
if (!context) {
|
154
|
+
throw new Error("useJazzContext must be used within a JazzProvider");
|
155
|
+
}
|
156
|
+
return context;
|
157
|
+
}
|
158
|
+
|
159
|
+
function useAccount(): { me: ComputedRef<Acc>; logOut: () => void };
|
160
|
+
function useAccount<D extends DepthsIn<Acc>>(
|
161
|
+
depth: D,
|
162
|
+
): {
|
163
|
+
me: ComputedRef<DeeplyLoaded<Acc, D> | undefined>;
|
164
|
+
logOut: () => void;
|
165
|
+
};
|
166
|
+
function useAccount<D extends DepthsIn<Acc>>(
|
167
|
+
depth?: D,
|
168
|
+
): {
|
169
|
+
me: ComputedRef<Acc | DeeplyLoaded<Acc, D> | undefined>;
|
170
|
+
logOut: () => void;
|
171
|
+
} {
|
172
|
+
const context = useJazzContext();
|
173
|
+
|
174
|
+
if (!context.value) {
|
175
|
+
throw new Error("useAccount must be used within a JazzProvider");
|
176
|
+
}
|
177
|
+
|
178
|
+
if (!("me" in context.value)) {
|
179
|
+
throw new Error(
|
180
|
+
"useAccount can't be used in a JazzProvider with auth === 'guest' - consider using useAccountOrGuest()",
|
181
|
+
);
|
182
|
+
}
|
183
|
+
|
184
|
+
const me = useCoState<Acc, D>(
|
185
|
+
context.value.me.constructor as CoValueClass<Acc>,
|
186
|
+
context.value.me.id,
|
187
|
+
depth,
|
188
|
+
);
|
189
|
+
|
190
|
+
return {
|
191
|
+
me: computed(() => {
|
192
|
+
const value =
|
193
|
+
depth === undefined
|
194
|
+
? me.value || toRaw((context.value as BrowserContext<Acc>).me)
|
195
|
+
: me.value;
|
196
|
+
|
197
|
+
return value ? toRaw(value) : value;
|
198
|
+
}),
|
199
|
+
logOut: context.value.logOut,
|
200
|
+
};
|
201
|
+
}
|
202
|
+
|
203
|
+
function useAccountOrGuest(): { me: ComputedRef<Acc | AnonymousJazzAgent> };
|
204
|
+
function useAccountOrGuest<D extends DepthsIn<Acc>>(
|
205
|
+
depth: D,
|
206
|
+
): {
|
207
|
+
me: ComputedRef<DeeplyLoaded<Acc, D> | undefined | AnonymousJazzAgent>;
|
208
|
+
};
|
209
|
+
function useAccountOrGuest<D extends DepthsIn<Acc>>(
|
210
|
+
depth?: D,
|
211
|
+
): {
|
212
|
+
me: ComputedRef<
|
213
|
+
Acc | DeeplyLoaded<Acc, D> | undefined | AnonymousJazzAgent
|
214
|
+
>;
|
215
|
+
} {
|
216
|
+
const context = useJazzContext();
|
217
|
+
|
218
|
+
if (!context.value) {
|
219
|
+
throw new Error("useAccountOrGuest must be used within a JazzProvider");
|
220
|
+
}
|
221
|
+
|
222
|
+
const contextMe = "me" in context.value ? context.value.me : undefined;
|
223
|
+
|
224
|
+
const me = useCoState<Acc, D>(
|
225
|
+
contextMe?.constructor as CoValueClass<Acc>,
|
226
|
+
contextMe?.id,
|
227
|
+
depth,
|
228
|
+
);
|
229
|
+
|
230
|
+
if ("me" in context.value) {
|
231
|
+
return {
|
232
|
+
me: computed(() =>
|
233
|
+
depth === undefined
|
234
|
+
? me.value || toRaw((context.value as BrowserContext<Acc>).me)
|
235
|
+
: me.value,
|
236
|
+
),
|
237
|
+
};
|
238
|
+
} else {
|
239
|
+
return {
|
240
|
+
me: computed(() => toRaw((context.value as BrowserGuestContext).guest)),
|
241
|
+
};
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
245
|
+
function useCoState<V extends CoValue, D>(
|
246
|
+
Schema: CoValueClass<V>,
|
247
|
+
id: ID<V> | undefined,
|
248
|
+
depth: D & DepthsIn<V> = [] as D & DepthsIn<V>,
|
249
|
+
): Ref<DeeplyLoaded<V, D> | undefined> {
|
250
|
+
const state: ShallowRef<DeeplyLoaded<V, D> | undefined> =
|
251
|
+
shallowRef(undefined);
|
252
|
+
const context = useJazzContext();
|
253
|
+
|
254
|
+
if (!context.value) {
|
255
|
+
throw new Error("useCoState must be used within a JazzProvider");
|
256
|
+
}
|
257
|
+
|
258
|
+
let unsubscribe: (() => void) | undefined;
|
259
|
+
|
260
|
+
watch(
|
261
|
+
[() => id, () => context, () => Schema, () => depth],
|
262
|
+
() => {
|
263
|
+
if (unsubscribe) unsubscribe();
|
264
|
+
|
265
|
+
if (!id) return;
|
266
|
+
|
267
|
+
unsubscribe = subscribeToCoValue(
|
268
|
+
Schema,
|
269
|
+
id,
|
270
|
+
"me" in context.value
|
271
|
+
? toRaw(context.value.me)
|
272
|
+
: toRaw(context.value.guest),
|
273
|
+
depth,
|
274
|
+
(value) => {
|
275
|
+
state.value = value;
|
276
|
+
},
|
277
|
+
);
|
278
|
+
},
|
279
|
+
{ immediate: true },
|
280
|
+
);
|
281
|
+
|
282
|
+
onUnmounted(() => {
|
283
|
+
if (unsubscribe) unsubscribe();
|
284
|
+
});
|
285
|
+
|
286
|
+
const computedState = computed(() => state.value);
|
287
|
+
|
288
|
+
return computedState;
|
289
|
+
}
|
290
|
+
|
291
|
+
function useAcceptInvite<V extends CoValue>({
|
292
|
+
invitedObjectSchema,
|
293
|
+
onAccept,
|
294
|
+
forValueHint,
|
295
|
+
}: {
|
296
|
+
invitedObjectSchema: CoValueClass<V>;
|
297
|
+
onAccept: (projectID: ID<V>) => void;
|
298
|
+
forValueHint?: string;
|
299
|
+
}): void {
|
300
|
+
const context = useJazzContext();
|
301
|
+
|
302
|
+
if (!context.value) {
|
303
|
+
throw new Error("useAcceptInvite must be used within a JazzProvider");
|
304
|
+
}
|
305
|
+
|
306
|
+
if (!("me" in context.value)) {
|
307
|
+
throw new Error(
|
308
|
+
"useAcceptInvite can't be used in a JazzProvider with auth === 'guest'.",
|
309
|
+
);
|
310
|
+
}
|
311
|
+
|
312
|
+
const runInviteAcceptance = () => {
|
313
|
+
const result = consumeInviteLinkFromWindowLocation({
|
314
|
+
as: toRaw((context.value as BrowserContext<Acc>).me),
|
315
|
+
invitedObjectSchema,
|
316
|
+
forValueHint,
|
317
|
+
});
|
318
|
+
|
319
|
+
result
|
320
|
+
.then((res) => res && onAccept(res.valueID))
|
321
|
+
.catch((e) => {
|
322
|
+
console.error("Failed to accept invite", e);
|
323
|
+
});
|
324
|
+
};
|
325
|
+
|
326
|
+
onMounted(() => {
|
327
|
+
runInviteAcceptance();
|
328
|
+
});
|
329
|
+
|
330
|
+
watch(
|
331
|
+
() => onAccept,
|
332
|
+
(newOnAccept, oldOnAccept) => {
|
333
|
+
if (newOnAccept !== oldOnAccept) {
|
334
|
+
runInviteAcceptance();
|
335
|
+
}
|
336
|
+
},
|
337
|
+
);
|
338
|
+
}
|
339
|
+
|
340
|
+
return {
|
341
|
+
JazzProvider,
|
342
|
+
useAccount,
|
343
|
+
useAccountOrGuest,
|
344
|
+
useCoState,
|
345
|
+
useAcceptInvite,
|
346
|
+
};
|
347
|
+
}
|
package/src/index.ts
ADDED
package/tsconfig.json
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "ES2020",
|
4
|
+
"module": "ESNext",
|
5
|
+
"lib": ["ESNext", "DOM"],
|
6
|
+
"skipLibCheck": true,
|
7
|
+
"moduleResolution": "bundler",
|
8
|
+
"moduleDetection": "force",
|
9
|
+
"jsx": "preserve",
|
10
|
+
"jsxImportSource": "vue",
|
11
|
+
"strict": true,
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
13
|
+
"noUncheckedIndexedAccess": true,
|
14
|
+
"esModuleInterop": true,
|
15
|
+
"declaration": true,
|
16
|
+
"isolatedModules": true
|
17
|
+
},
|
18
|
+
"include": ["src/**/*.ts", "src/**/*.vue"],
|
19
|
+
"exclude": ["node_modules", "dist", "vite.config.ts"]
|
20
|
+
}
|
package/vite.config.ts
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
import path from "path";
|
2
|
+
import vue from "@vitejs/plugin-vue";
|
3
|
+
import { defineConfig } from "vite";
|
4
|
+
import dts from "vite-plugin-dts";
|
5
|
+
|
6
|
+
export default defineConfig({
|
7
|
+
// @ts-expect-error types
|
8
|
+
plugins: [vue(), dts({ include: ["src/**/*.ts"], outDir: "dist" })],
|
9
|
+
build: {
|
10
|
+
lib: {
|
11
|
+
entry: path.resolve(__dirname, "src/index.ts"),
|
12
|
+
name: "JazzVue",
|
13
|
+
formats: ["es"],
|
14
|
+
fileName: (format) => `index.js`,
|
15
|
+
},
|
16
|
+
rollupOptions: {
|
17
|
+
external: ["vue", "jazz-browser", "jazz-tools"],
|
18
|
+
output: {
|
19
|
+
globals: {
|
20
|
+
vue: "Vue",
|
21
|
+
"jazz-browser": "JazzBrowser",
|
22
|
+
"jazz-tools": "JazzTools",
|
23
|
+
},
|
24
|
+
},
|
25
|
+
},
|
26
|
+
},
|
27
|
+
});
|