cursor-park 0.0.1

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.
@@ -0,0 +1,334 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { library } from './assets/svgs';
8
+ import { MouseCursor } from './cursor';
9
+ import { ReactiveElement, css, property } from './reactive-element';
10
+ import { clamp, inlineSVG } from './utils';
11
+ export class CursorObject extends ReactiveElement {
12
+ static { this.acquiredObject = null; }
13
+ #cursor = null;
14
+ get cursor() {
15
+ return this.#cursor;
16
+ }
17
+ constructor() {
18
+ super();
19
+ this.addEventListener('click', this.#onAcquireClick);
20
+ }
21
+ acquireCursor(x, y) {
22
+ if (this.#cursor === null)
23
+ return;
24
+ CursorObject.acquiredObject?.releaseCursor();
25
+ CursorObject.acquiredObject = this;
26
+ this.#cursor.x = x;
27
+ this.#cursor.y = y;
28
+ this.appendChild(this.#cursor);
29
+ console.log('acquire', this);
30
+ }
31
+ releaseCursor() {
32
+ console.log('release', this);
33
+ if (this.cursor == null)
34
+ return;
35
+ this.cursor.action = '';
36
+ this.cursor.remove();
37
+ this.#cursor = null;
38
+ CursorObject.acquiredObject = null;
39
+ }
40
+ #onAcquireClick = (event) => {
41
+ event.preventDefault();
42
+ event.stopPropagation();
43
+ event.stopImmediatePropagation();
44
+ if (this.#cursor) {
45
+ this.releaseCursor();
46
+ }
47
+ else {
48
+ this.#cursor = MouseCursor.self;
49
+ // compute point of click relative to the objects bounding box (which has to account for scroll)
50
+ const rect = this.getBoundingClientRect();
51
+ const x = event.pageX - (rect.x + window.scrollX);
52
+ const y = event.pageY - (rect.y + window.scrollY);
53
+ this.acquireCursor(x, y);
54
+ }
55
+ };
56
+ }
57
+ export class CursorBench extends CursorObject {
58
+ static { this.tagName = 'cursor-bench'; }
59
+ static { this.styles = css `
60
+ :host {
61
+ display: block;
62
+ position: relative;
63
+ aspect-ratio: 2.04;
64
+ width: 85px;
65
+ user-select: none;
66
+ }
67
+
68
+ img {
69
+ width: 100%;
70
+ height: 100%;
71
+ }
72
+
73
+ ::slotted(mouse-cursor) {
74
+ top: 50% !important;
75
+ translate: 0 -72%;
76
+ }
77
+ `; }
78
+ #img = document.createElement('img');
79
+ createRenderRoot() {
80
+ const root = super.createRenderRoot();
81
+ const url = new URL('./assets/bench.png', import.meta.url);
82
+ this.#img.src = url.toString();
83
+ this.#img.alt = 'A tiny metal casted bench.';
84
+ root.append(this.#img, document.createElement('slot'));
85
+ return root;
86
+ }
87
+ acquireCursor(x, y) {
88
+ super.acquireCursor(x, y);
89
+ // Shift the cursor over by 1/3 because the sprite is slightly bigger than it's outline.
90
+ this.cursor.x = clamp(0, x, this.offsetWidth) - this.cursor.offsetWidth / 3;
91
+ this.cursor.y = 0;
92
+ this.cursor.action = 'sitting';
93
+ document.addEventListener('keydown', this.#onKeydown);
94
+ document.addEventListener('keyup', this.#onKeyup);
95
+ }
96
+ releaseCursor() {
97
+ document.removeEventListener('keydown', this.#onKeydown);
98
+ document.removeEventListener('keyup', this.#onKeyup);
99
+ super.releaseCursor();
100
+ }
101
+ #onKeydown = (event) => {
102
+ if (this.cursor === null)
103
+ return;
104
+ if (event.code === 'ArrowLeft') {
105
+ event.preventDefault();
106
+ if (this.cursor.x > 3)
107
+ this.#animateCursor(-2);
108
+ }
109
+ else if (event.code === 'ArrowRight') {
110
+ event.preventDefault();
111
+ if (this.cursor.x + this.cursor.offsetWidth <= this.offsetWidth)
112
+ this.#animateCursor(2);
113
+ }
114
+ else if (event.code === 'ArrowUp') {
115
+ event.preventDefault();
116
+ this.cursor.action = 'sitting-forwards';
117
+ }
118
+ else if (event.code === 'ArrowDown') {
119
+ event.preventDefault();
120
+ this.cursor.action = 'sitting-backwards';
121
+ }
122
+ };
123
+ #onKeyup = (event) => {
124
+ if (this.cursor === null)
125
+ return;
126
+ if (event.code === 'ArrowUp' || event.code === 'ArrowDown') {
127
+ this.cursor.action = 'sitting';
128
+ }
129
+ };
130
+ #animateCursor(delta) {
131
+ if (this.cursor === null)
132
+ return;
133
+ this.cursor.x += delta;
134
+ }
135
+ }
136
+ export class CursorLibrary extends CursorObject {
137
+ constructor() {
138
+ super(...arguments);
139
+ this.#img = document.createElement('img');
140
+ this.#books = document.createElement('div');
141
+ this.#slot = document.createElement('slot');
142
+ this.#clickZone = document.createElement('click-zone');
143
+ this.src = '';
144
+ }
145
+ static { this.tagName = 'cursor-library'; }
146
+ static { this.styles = css `
147
+ :host {
148
+ display: block;
149
+ position: relative;
150
+ /* 20 x 38 */
151
+ aspect-ratio: 0.53;
152
+ height: 80px;
153
+ user-select: none;
154
+ }
155
+
156
+ click-zone {
157
+ display: block;
158
+ position: absolute;
159
+ height: 100%;
160
+ width: 150%;
161
+ top: -25%;
162
+ right: 100%;
163
+ background: rgba(0, 0, 0, 0.15);
164
+ border-radius: 5px;
165
+ opacity: 0;
166
+ transition: opacity 0.2s ease-out;
167
+ }
168
+
169
+ img {
170
+ height: 100%;
171
+ width: 100%;
172
+ }
173
+
174
+ ::slotted(mouse-cursor) {
175
+ translate: -50% 0%;
176
+ }
177
+
178
+ div {
179
+ font-size: 16px;
180
+ pointer-events: none;
181
+ text-align: center;
182
+ opacity: 0;
183
+ position: absolute;
184
+ top: -75px;
185
+ bottom: -75px;
186
+ left: 125%;
187
+ background: #deeade;
188
+ border-radius: 4px;
189
+ transition: opacity 200ms ease-out;
190
+ box-sizing: border-box;
191
+ overflow: auto;
192
+ z-index: 2;
193
+ box-shadow: 3px 4px 8px 0px rgba(0, 0, 0, 0.5);
194
+ z-index: calc(Infinity);
195
+ padding: 12px 64px 4px 20px;
196
+
197
+ align-items: flex-end;
198
+ display: flex !important;
199
+ gap: 2px;
200
+ list-style-type: none;
201
+
202
+ ::slotted(a),
203
+ a {
204
+ writing-mode: vertical-rl;
205
+ text-orientation: mixed;
206
+ border-radius: 3px;
207
+ overflow: hidden;
208
+ color: white;
209
+ padding: 9px 4px;
210
+ line-height: 1.5;
211
+ text-decoration: none;
212
+ cursor: unset;
213
+ box-shadow: 1px 1px 3px 0px rgba(0, 0, 0, 0.5);
214
+ }
215
+
216
+ ::slotted(a:hover),
217
+ a:hover {
218
+ text-decoration: underline;
219
+ }
220
+
221
+ ::slotted(a:nth-child(even)),
222
+ a:nth-child(even) {
223
+ background: #3ebc1b;
224
+ }
225
+
226
+ ::slotted(a:nth-child(odd)),
227
+ a:nth-child(odd) {
228
+ background: #ff0000;
229
+ }
230
+
231
+ ::slotted(a:nth-child(2n + 1)),
232
+ a:nth-child(2n + 1) {
233
+ rotate: 2deg;
234
+ translate: -2px;
235
+ margin-left: 2px;
236
+ background: #286e75;
237
+ }
238
+
239
+ ::slotted(a:nth-child(3n)),
240
+ a:nth-child(3n) {
241
+ rotate: -1deg;
242
+ translate: 1px;
243
+ margin-left: 1px;
244
+ background: #d3d382;
245
+ color: black;
246
+ }
247
+
248
+ ::slotted(a:first-child),
249
+ a:first-child {
250
+ rotate: 8deg;
251
+ translate: -8px;
252
+ margin-left: 8px;
253
+ background: #ff0000;
254
+ }
255
+
256
+ ::slotted(a:last-of-type),
257
+ a:last-of-type {
258
+ rotate: -8deg;
259
+ translate: 8px;
260
+ background: #d3d382;
261
+ }
262
+ }
263
+ `; }
264
+ #img;
265
+ #books;
266
+ #slot;
267
+ #clickZone;
268
+ createRenderRoot() {
269
+ const root = super.createRenderRoot();
270
+ this.#books.appendChild(this.#slot);
271
+ this.#books.addEventListener('click', (e) => e.stopPropagation());
272
+ this.#img.src = inlineSVG(library());
273
+ const cursorSlot = document.createElement('slot');
274
+ cursorSlot.name = 'cursor';
275
+ root.append(cursorSlot, this.#clickZone, this.#img, this.#books);
276
+ return root;
277
+ }
278
+ update(changedProperties) {
279
+ super.update(changedProperties);
280
+ if (changedProperties.has('src')) {
281
+ if (this.src === '')
282
+ return;
283
+ const url = URL.parse(this.src);
284
+ if (url?.hostname === 'semble.so') {
285
+ const [, profile, identifier, collections, rkey] = url.pathname.split('/');
286
+ console.log('url', profile, identifier, collections, rkey);
287
+ if (profile === 'profile' && identifier && collections === 'collections' && rkey) {
288
+ this.#loadSembleCollection(identifier, rkey);
289
+ }
290
+ }
291
+ }
292
+ }
293
+ async #loadSembleCollection(identifier, rkey) {
294
+ const response = await fetch(`https://api.semble.so/xrpc/network.cosmik.collection.getByAtUri?handle=${identifier}&recordKey=${rkey}&page=1&limit=15`);
295
+ if (!response.ok)
296
+ return;
297
+ const collection = await response.json();
298
+ const links = collection.urlCards.map(({ cardContent }) => ({
299
+ url: cardContent.url,
300
+ title: cardContent.title || cardContent.description,
301
+ }));
302
+ this.#createLinks(links);
303
+ }
304
+ #createLinks(links) {
305
+ const anchors = links.map((link) => {
306
+ const a = document.createElement('a');
307
+ a.href = link.url;
308
+ a.textContent = link.title.length < 60 ? link.title : link.title.slice(0, 57) + '...';
309
+ a.target = '_blank';
310
+ const size = -2.5 * link.title.length + 70;
311
+ a.style.fontSize = `${clamp(12, size, 18)}px`;
312
+ return a;
313
+ });
314
+ this.#slot.append(...anchors);
315
+ console.log(anchors);
316
+ }
317
+ acquireCursor(x, y) {
318
+ super.acquireCursor(x, y);
319
+ this.cursor.slot = 'cursor';
320
+ this.cursor.action = 'looking-down';
321
+ this.#books.style.opacity = '0.9';
322
+ this.#books.style.pointerEvents = 'all';
323
+ }
324
+ releaseCursor() {
325
+ this.cursor.slot = '';
326
+ this.#books.style.opacity = '0';
327
+ this.#books.style.pointerEvents = '';
328
+ super.releaseCursor();
329
+ }
330
+ }
331
+ __decorate([
332
+ property({ type: String, reflect: true })
333
+ ], CursorLibrary.prototype, "src", void 0);
334
+ //# sourceMappingURL=objects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objects.js","sourceRoot":"","sources":["../src/objects.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,QAAQ,EAAuB,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,OAAO,YAAa,SAAQ,eAAe;aACxC,mBAAc,GAAwB,IAAI,CAAC;IAElD,OAAO,GAAuB,IAAI,CAAC;IAEnC,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;QACE,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;IACvD,CAAC;IAED,aAAa,CAAC,CAAS,EAAE,CAAS;QAChC,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI;YAAE,OAAO;QAElC,YAAY,CAAC,cAAc,EAAE,aAAa,EAAE,CAAC;QAC7C,YAAY,CAAC,cAAc,GAAG,IAAI,CAAC;QAEnC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,aAAa;QACX,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC7B,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI;YAAE,OAAO;QAEhC,IAAI,CAAC,MAAM,CAAC,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AAC,MAAO,CAAC,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,GAAG,EAAE,CAAC;QAErC,KAAK,CAAC,aAAa,EAAE,CAAC;IACxB,CAAC;CACF;AAnF4C;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAU"}
@@ -0,0 +1,12 @@
1
+ import { ReactiveElement as RE } from '@lit/reactive-element';
2
+ export { css, type PropertyValues, unsafeCSS } from '@lit/reactive-element';
3
+ export { property } from '@lit/reactive-element/decorators.js';
4
+ export declare class ReactiveElement extends RE {
5
+ /** Defines the name of the custom element, must include a hyphen or it will error out when defined.
6
+ * Defaults to a kebab-case version of the PascalCase class name
7
+ */
8
+ static tagName: string;
9
+ /** Defines the custom element with the global CustomElementRegistry, ignored if called more than once. Errors if no tagName is defined or it doesn't include a hyphen. */
10
+ static define(): void;
11
+ }
12
+ //# sourceMappingURL=reactive-element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactive-element.d.ts","sourceRoot":"","sources":["../src/reactive-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,GAAG,EAAE,KAAK,cAAc,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAE/D,qBAAa,eAAgB,SAAQ,EAAE;IACrC;;OAEG;IACH,MAAM,CAAC,OAAO,SAAM;IAEpB,0KAA0K;IAC1K,MAAM,CAAC,MAAM,SAUZ;CACF"}
@@ -0,0 +1,21 @@
1
+ import { ReactiveElement as RE } from '@lit/reactive-element';
2
+ export { css, unsafeCSS } from '@lit/reactive-element';
3
+ export { property } from '@lit/reactive-element/decorators.js';
4
+ export class ReactiveElement extends RE {
5
+ /** Defines the name of the custom element, must include a hyphen or it will error out when defined.
6
+ * Defaults to a kebab-case version of the PascalCase class name
7
+ */
8
+ static { this.tagName = ''; }
9
+ /** Defines the custom element with the global CustomElementRegistry, ignored if called more than once. Errors if no tagName is defined or it doesn't include a hyphen. */
10
+ static define() {
11
+ if (!this.tagName)
12
+ this.tagName = this.name
13
+ .replace(/([A-Z])/g, '-$1')
14
+ .toLowerCase()
15
+ .slice(1);
16
+ if (customElements.get(this.tagName))
17
+ return;
18
+ customElements.define(this.tagName, this);
19
+ }
20
+ }
21
+ //# sourceMappingURL=reactive-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactive-element.js","sourceRoot":"","sources":["../src/reactive-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,GAAG,EAAuB,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAE/D,MAAM,OAAO,eAAgB,SAAQ,EAAE;IACrC;;OAEG;aACI,YAAO,GAAG,EAAE,CAAC;IAEpB,0KAA0K;IAC1K,MAAM,CAAC,MAAM;QACX,IAAI,CAAC,IAAI,CAAC,OAAO;YACf,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI;iBACrB,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;iBAC1B,WAAW,EAAE;iBACb,KAAK,CAAC,CAAC,CAAC,CAAC;QAEd,IAAI,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;YAAE,OAAO;QAE7C,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ export declare const CURSOR_COLOR: string;
2
+ export declare const CURSOR_SCALE: number;
3
+ export declare const clamp: (min: number, value: number, max: number) => number;
4
+ export declare const inlineSVG: (svg: string) => string;
5
+ export declare const convertSVGIntoCssURL: (svg: string) => string;
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,YAAY,QAAoD,CAAC;AAC9E,eAAO,MAAM,YAAY,QAAoD,CAAC;AAC9E,eAAO,MAAM,KAAK,QAAS,MAAM,SAAS,MAAM,OAAO,MAAM,WAAwC,CAAC;AACtG,eAAO,MAAM,SAAS,QAAS,MAAM,WAAyD,CAAC;AAC/F,eAAO,MAAM,oBAAoB,QAAS,MAAM,WAA+B,CAAC"}
package/dist/utils.js ADDED
@@ -0,0 +1,27 @@
1
+ const COLORS = [
2
+ '#447F59',
3
+ '#A10314',
4
+ '#FB546E',
5
+ '#8750C9',
6
+ '#E601B2',
7
+ '#c44601',
8
+ '#f57600',
9
+ '#0073e6',
10
+ '#054fb9',
11
+ '#5ba300',
12
+ '#89ce00',
13
+ '#0073e6',
14
+ '#e6308a',
15
+ '#009eb0',
16
+ '#b51963',
17
+ '#f57600',
18
+ '#00b4c5',
19
+ '#5928ed',
20
+ ];
21
+ const SCALES = [1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3];
22
+ export const CURSOR_COLOR = COLORS[Math.floor(Math.random() * COLORS.length)];
23
+ export const CURSOR_SCALE = SCALES[Math.floor(Math.random() * SCALES.length)];
24
+ export const clamp = (min, value, max) => Math.min(Math.max(value, min), max);
25
+ export const inlineSVG = (svg) => `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
26
+ export const convertSVGIntoCssURL = (svg) => `url('${inlineSVG(svg)}')`;
27
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IACb,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;CACV,CAAC;AACF,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9E,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9E,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,GAAW,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AACtG,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,2BAA2B,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;AAC/F,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,QAAQ,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "cursor-park",
3
+ "author": "Christopher Shank <chris.shank.23@gmail.com>",
4
+ "version": "0.0.1",
5
+ "description": "Primitives to make personal websites feel more like public space.",
6
+ "keywords": [
7
+ "cursors",
8
+ "free library",
9
+ "bench"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/ChrisShank/cursor-benches.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/ChrisShank/cursor-benches/issues"
17
+ },
18
+ "homepage": "https://github.com/ChrisShank/cursor-benches/tree/main/packages/cursor-park",
19
+ "license": "MIT",
20
+ "type": "module",
21
+ "exports": {
22
+ ".": {
23
+ "import": "./dist/index.js",
24
+ "types": "./dist/index.d.ts"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "src"
30
+ ],
31
+ "scripts": {
32
+ "dev": "vite demo",
33
+ "build:demo": "vite build demo",
34
+ "build": "tsc --build --pretty && cp ./src/assets/*.png ./dist/assets",
35
+ "publish": "npm run build && npm publish"
36
+ },
37
+ "dependencies": {
38
+ "lit": "^3.3.2"
39
+ },
40
+ "devDependencies": {
41
+ "typescript": "^7.0.0",
42
+ "vite": "^8.0.12"
43
+ }
44
+ }
Binary file