@xnetjs/data 0.0.2 → 0.1.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.
- package/README.md +112 -0
- package/dist/account-MWNCH4GJ.js +12 -0
- package/dist/account-ledger-R2GAFJL6.js +38 -0
- package/dist/auth/index.d.ts +420 -0
- package/dist/auth/index.js +102 -0
- package/dist/budget-NN7P35XP.js +12 -0
- package/dist/canvas-6WYBNH53.js +10 -0
- package/dist/channel-AT3LQF4A.js +12 -0
- package/dist/chat-message-DSVO72B3.js +10 -0
- package/dist/chunk-2ZNJWIQG.js +84 -0
- package/dist/chunk-3J3HILXO.js +46 -0
- package/dist/chunk-3RUDVTMH.js +5543 -0
- package/dist/chunk-4EYKGTSQ.js +49 -0
- package/dist/chunk-53F4PRNC.js +32 -0
- package/dist/chunk-5EXHNXPL.js +48 -0
- package/dist/{chunk-BQBPA5HS.js → chunk-5HC5NO57.js} +16 -2
- package/dist/chunk-6KLGA6IR.js +47 -0
- package/dist/chunk-6OMG4I7M.js +41 -0
- package/dist/chunk-7PDRDSFH.js +69 -0
- package/dist/chunk-BQLQSWKZ.js +232 -0
- package/dist/chunk-BY5O6LNC.js +380 -0
- package/dist/chunk-DCTRX6II.js +40 -0
- package/dist/{chunk-VYR5GPJP.js → chunk-DWEXKD6E.js} +9 -3
- package/dist/chunk-EBNMV2VO.js +896 -0
- package/dist/chunk-FVEACSKE.js +102 -0
- package/dist/chunk-GU6THOAB.js +45 -0
- package/dist/chunk-H4GA4BBK.js +75 -0
- package/dist/chunk-IJ44LR7N.js +76 -0
- package/dist/chunk-J4ANIXIV.js +402 -0
- package/dist/chunk-JDFNMFOZ.js +45 -0
- package/dist/chunk-K7DOZWWT.js +1811 -0
- package/dist/chunk-KQAT4XBL.js +49 -0
- package/dist/chunk-KQUALW4O.js +183 -0
- package/dist/chunk-LYSWLCOI.js +47 -0
- package/dist/chunk-MBTUO3ZL.js +65 -0
- package/dist/chunk-NI4FHG2K.js +52 -0
- package/dist/chunk-OCMSAKWV.js +78 -0
- package/dist/chunk-OGJCRNGE.js +57 -0
- package/dist/chunk-OPPHF3TF.js +143 -0
- package/dist/{chunk-IDMBCRUC.js → chunk-OSAWNZVM.js} +1 -1
- package/dist/chunk-PMUQACPY.js +33 -0
- package/dist/chunk-PNESGUH5.js +63 -0
- package/dist/chunk-Q3IEGH4B.js +51 -0
- package/dist/chunk-QJW5LDP4.js +52 -0
- package/dist/chunk-QWFTRZQT.js +142 -0
- package/dist/{chunk-SZC345Z2.js → chunk-RL64OJJ5.js} +1025 -1110
- package/dist/chunk-S5RP5RKY.js +416 -0
- package/dist/chunk-S6U6TCMN.js +722 -0
- package/dist/chunk-SVNGSZZA.js +69 -0
- package/dist/chunk-T5AZAOG5.js +54 -0
- package/dist/chunk-TCTZW4A6.js +42 -0
- package/dist/chunk-U64CW73O.js +109 -0
- package/dist/chunk-UDWKWTAX.js +6526 -0
- package/dist/chunk-UQM3G5A2.js +148 -0
- package/dist/chunk-VQ7JHB67.js +57 -0
- package/dist/chunk-W7EBL7ZU.js +73 -0
- package/dist/chunk-WEPK7SZF.js +65 -0
- package/dist/chunk-XHEA5UER.js +75 -0
- package/dist/chunk-XMSKJ5PV.js +66 -0
- package/dist/chunk-XROI44ZP.js +64 -0
- package/dist/chunk-Y3S5SRVM.js +45 -0
- package/dist/chunk-YEFKQYKA.js +43 -0
- package/dist/chunk-YSUIXD2Y.js +105 -0
- package/dist/chunk-ZCOFZY5M.js +70 -0
- package/dist/chunk-ZLU4Y3O2.js +50 -0
- package/dist/chunk-ZPZ7XDA6.js +54 -0
- package/dist/chunk-ZZ6TWKGS.js +40 -0
- package/dist/clone-C0Jhk2UN.d.ts +2205 -0
- package/dist/comment-QSWYAQVS.js +10 -0
- package/dist/crm-L5RYAAF3.js +68 -0
- package/dist/dashboard-JMKTTRA7.js +10 -0
- package/dist/database/index.d.ts +882 -0
- package/dist/database/index.js +523 -0
- package/dist/database-GIXSPZJW.js +10 -0
- package/dist/database-field-3EPAMZUR.js +10 -0
- package/dist/database-row-6Q6TRVE4.js +10 -0
- package/dist/database-select-option-BBBJFLLH.js +10 -0
- package/dist/database-view-5PLSOBI2.js +10 -0
- package/dist/experiment-DOVOZ34Y.js +10 -0
- package/dist/external-item-P2E5X7BZ.js +14 -0
- package/dist/external-reference-7BSFF6SA.js +8 -0
- package/dist/feed-2IXHHP6O.js +12 -0
- package/dist/feed-item-DPE6LN7I.js +12 -0
- package/dist/folder-6KM3KYD5.js +21 -0
- package/dist/game-5AK5XWBR.js +50 -0
- package/dist/grant-WTQSNT5A.js +8 -0
- package/dist/grant-expiration-cleaner-CY6BcmlR.d.ts +249 -0
- package/dist/import-batch-IXBJLQPJ.js +12 -0
- package/dist/inbox-state-E5NSVOGP.js +12 -0
- package/dist/index.d.ts +224 -4548
- package/dist/index.js +2252 -4754
- package/dist/map-RG5Y3CPC.js +10 -0
- package/dist/media-asset-QTCGLIZA.js +8 -0
- package/dist/memory-PNRTMBZO.js +12 -0
- package/dist/metric-65SVOX5C.js +10 -0
- package/dist/milestone-XEO6ZGDG.js +12 -0
- package/dist/moderation-FFHETMRB.js +30 -0
- package/dist/observation-2Y3QKUXM.js +10 -0
- package/dist/page-2V27JGKJ.js +10 -0
- package/dist/posting-GBOSZCMZ.js +12 -0
- package/dist/profile-BLLDWIDK.js +8 -0
- package/dist/project-CQL5LN26.js +10 -0
- package/dist/query-ast-C3m6kZYv.d.ts +226 -0
- package/dist/reaction-T2DTJBBV.js +10 -0
- package/dist/registry-DunPv__d.d.ts +99 -0
- package/dist/saved-view-4R2DBCL3.js +10 -0
- package/dist/schema/index.d.ts +6489 -0
- package/dist/schema/index.js +677 -0
- package/dist/schema-extension-LNRF2YRD.js +18 -0
- package/dist/space-IJU24PBH.js +42 -0
- package/dist/space-membership-DEUMM7NV.js +14 -0
- package/dist/store/index.d.ts +518 -0
- package/dist/store/index.js +135 -0
- package/dist/store-DtIDjk7c.d.ts +355 -0
- package/dist/sync/awareness.d.ts +69 -0
- package/dist/sync/awareness.js +20 -0
- package/dist/system-ILHCZOVO.js +38 -0
- package/dist/tag-SKCHM3U5.js +16 -0
- package/dist/task-7AOBP7WC.js +16 -0
- package/dist/task-view-NUGKELJP.js +10 -0
- package/dist/transaction-ZDSEGDIR.js +12 -0
- package/dist/transcription-PSCLDAGX.js +12 -0
- package/dist/types-S-BJAKyK.d.ts +1576 -0
- package/dist/updates.d.ts +44 -0
- package/dist/updates.js +16 -0
- package/dist/user-widget-RLY2N46A.js +8 -0
- package/dist/view-types-DSde-uT_.d.ts +316 -0
- package/package.json +32 -9
- package/dist/canvas-HSIKIQFK.js +0 -7
- package/dist/chunk-2L5ZUGG5.js +0 -53
- package/dist/chunk-4MTS5KAQ.js +0 -22
- package/dist/chunk-GZHARFKC.js +0 -25
- package/dist/chunk-WKIKJTI2.js +0 -45
- package/dist/comment-277JD7DV.js +0 -7
- package/dist/database-W3KEHLI3.js +0 -7
- package/dist/database-row-3O2QSNZN.js +0 -7
- package/dist/grant-QVZ454YC.js +0 -7
- package/dist/page-O4WTOIEO.js +0 -7
- package/dist/task-SEKAYJH7.js +0 -7
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spaceCascadeAuthorization
|
|
3
|
+
} from "./chunk-OCMSAKWV.js";
|
|
4
|
+
import {
|
|
5
|
+
defineSchema,
|
|
6
|
+
json,
|
|
7
|
+
relation,
|
|
8
|
+
select,
|
|
9
|
+
text
|
|
10
|
+
} from "./chunk-EBNMV2VO.js";
|
|
11
|
+
|
|
12
|
+
// src/schema/schemas/task-view.ts
|
|
13
|
+
var TaskViewSchema = defineSchema({
|
|
14
|
+
name: "TaskView",
|
|
15
|
+
namespace: "xnet://xnet.fyi/",
|
|
16
|
+
properties: {
|
|
17
|
+
/** Display name */
|
|
18
|
+
name: text({ required: true, maxLength: 200 }),
|
|
19
|
+
/** View type */
|
|
20
|
+
type: select({
|
|
21
|
+
options: [
|
|
22
|
+
{ id: "list", name: "List" },
|
|
23
|
+
{ id: "board", name: "Board" },
|
|
24
|
+
{ id: "triage", name: "Triage" },
|
|
25
|
+
{ id: "calendar", name: "Calendar" },
|
|
26
|
+
{ id: "timeline", name: "Timeline" }
|
|
27
|
+
],
|
|
28
|
+
default: "list"
|
|
29
|
+
}),
|
|
30
|
+
/** Filter tree (FilterGroup over Task properties) — whole-tree LWW */
|
|
31
|
+
filters: json({}),
|
|
32
|
+
/** Sort list (SortConfig[]) — whole-list LWW */
|
|
33
|
+
sorts: json({}),
|
|
34
|
+
/** Group-by task property (e.g. 'status' | 'assignee' | 'priority') */
|
|
35
|
+
groupBy: text({ maxLength: 100 }),
|
|
36
|
+
/** Collapsed group keys */
|
|
37
|
+
collapsedGroups: json({}),
|
|
38
|
+
/** Scope the view to a project (absent = workspace-wide) */
|
|
39
|
+
project: relation({ target: "xnet://xnet.fyi/Project@1.0.0" }),
|
|
40
|
+
/** Fractional index for view tab ordering */
|
|
41
|
+
sortKey: text({ required: true })
|
|
42
|
+
},
|
|
43
|
+
// Inherits access from its home Space (exploration 0181/0192).
|
|
44
|
+
authorization: spaceCascadeAuthorization("project")
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
TaskViewSchema
|
|
49
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineSchema,
|
|
3
|
+
json,
|
|
4
|
+
text
|
|
5
|
+
} from "./chunk-EBNMV2VO.js";
|
|
6
|
+
import {
|
|
7
|
+
presets
|
|
8
|
+
} from "./chunk-RL64OJJ5.js";
|
|
9
|
+
|
|
10
|
+
// src/schema/schemas/user-widget.ts
|
|
11
|
+
var UserWidgetSchema = defineSchema({
|
|
12
|
+
name: "UserWidget",
|
|
13
|
+
namespace: "xnet://xnet.fyi/",
|
|
14
|
+
properties: {
|
|
15
|
+
/** Display name shown in the widget picker */
|
|
16
|
+
name: text({ required: true, maxLength: 200 }),
|
|
17
|
+
/** Short picker description */
|
|
18
|
+
description: text({ maxLength: 1e3 }),
|
|
19
|
+
/** Widget source: defines render(props) returning a SafeNode tree */
|
|
20
|
+
code: text({ required: true, maxLength: 1e5 }),
|
|
21
|
+
/** Config fields driving the auto-generated editor — whole-value LWW */
|
|
22
|
+
configFields: json({}),
|
|
23
|
+
/** Default tile size in 12-column grid units — whole-value LWW */
|
|
24
|
+
defaultSize: json({})
|
|
25
|
+
},
|
|
26
|
+
// Standalone/personal content: owner-only by default (exploration 0192).
|
|
27
|
+
authorization: presets.private()
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
UserWidgetSchema
|
|
32
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spaceCascadeAuthorization
|
|
3
|
+
} from "./chunk-OCMSAKWV.js";
|
|
4
|
+
import {
|
|
5
|
+
created,
|
|
6
|
+
createdBy,
|
|
7
|
+
date,
|
|
8
|
+
defineSchema,
|
|
9
|
+
relation,
|
|
10
|
+
text,
|
|
11
|
+
url
|
|
12
|
+
} from "./chunk-EBNMV2VO.js";
|
|
13
|
+
|
|
14
|
+
// src/schema/schemas/feed-item.ts
|
|
15
|
+
var FEED_ITEM_SCHEMA_IRI = "xnet://xnet.fyi/FeedItem@1.0.0";
|
|
16
|
+
var FeedItemSchema = defineSchema({
|
|
17
|
+
name: "FeedItem",
|
|
18
|
+
namespace: "xnet://xnet.fyi/",
|
|
19
|
+
properties: {
|
|
20
|
+
/** The Feed this entry came from. */
|
|
21
|
+
feed: relation({ target: "xnet://xnet.fyi/Feed@1.0.0" }),
|
|
22
|
+
/** Entry title. */
|
|
23
|
+
title: text({ required: true, maxLength: 1e3 }),
|
|
24
|
+
/** Canonical link to the entry. */
|
|
25
|
+
link: url({}),
|
|
26
|
+
/** Stable feed entry id (`<guid>`/`<id>`), used to de-duplicate re-polls. */
|
|
27
|
+
guid: text({ maxLength: 1e3 }),
|
|
28
|
+
/** Short summary / description. */
|
|
29
|
+
summary: text({ maxLength: 5e3 }),
|
|
30
|
+
/** Full content body in markdown/HTML-stripped text, when available. */
|
|
31
|
+
content: text({}),
|
|
32
|
+
/** Entry author, when advertised. */
|
|
33
|
+
author: text({ maxLength: 500 }),
|
|
34
|
+
/** When the entry was published (Unix ms). */
|
|
35
|
+
publishedAt: date({ includeTime: true }),
|
|
36
|
+
/** The home Space — drives the authorization cascade. */
|
|
37
|
+
space: relation({ target: "xnet://xnet.fyi/Space@1.0.0" }),
|
|
38
|
+
createdAt: created(),
|
|
39
|
+
createdBy: createdBy()
|
|
40
|
+
},
|
|
41
|
+
document: void 0,
|
|
42
|
+
authorization: spaceCascadeAuthorization()
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
FEED_ITEM_SCHEMA_IRI,
|
|
47
|
+
FeedItemSchema
|
|
48
|
+
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spaceCascadeAuthorization
|
|
3
|
+
} from "./chunk-OCMSAKWV.js";
|
|
1
4
|
import {
|
|
2
5
|
checkbox,
|
|
3
6
|
created,
|
|
@@ -5,11 +8,12 @@ import {
|
|
|
5
8
|
date,
|
|
6
9
|
defineSchema,
|
|
7
10
|
file,
|
|
11
|
+
json,
|
|
8
12
|
person,
|
|
9
13
|
relation,
|
|
10
14
|
select,
|
|
11
15
|
text
|
|
12
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-EBNMV2VO.js";
|
|
13
17
|
|
|
14
18
|
// src/schema/schemas/comment.ts
|
|
15
19
|
var CommentSchema = defineSchema({
|
|
@@ -44,8 +48,16 @@ var CommentSchema = defineSchema({
|
|
|
44
48
|
// ─── Content ───────────────────────────────────────────────────────────────
|
|
45
49
|
/** Comment body in GitHub-flavored markdown (stored as plain text) */
|
|
46
50
|
content: text({ required: true, maxLength: 1e4 }),
|
|
51
|
+
/** Workspace-wide labels from inline #hashtag pills (exploration 0169) */
|
|
52
|
+
tags: relation({ target: "xnet://xnet.fyi/Tag@1.0.0", multiple: true }),
|
|
47
53
|
/** Optional file attachments */
|
|
48
54
|
attachments: file({ multiple: true }),
|
|
55
|
+
/**
|
|
56
|
+
* Structured mentions ({ dids, room? }) — populated by the composer when
|
|
57
|
+
* mention pills are inserted (exploration 0168). Additive and optional;
|
|
58
|
+
* legacy text-parsed mentions (commentReferences.ts) remain as fallback.
|
|
59
|
+
*/
|
|
60
|
+
mentions: json({}),
|
|
49
61
|
// ─── Pseudo Reply-To (for UI, not structural threading) ────────────────────
|
|
50
62
|
/** DID of user being replied to (UI hint) */
|
|
51
63
|
replyToUser: person({}),
|
|
@@ -68,7 +80,9 @@ var CommentSchema = defineSchema({
|
|
|
68
80
|
createdBy: createdBy()
|
|
69
81
|
},
|
|
70
82
|
// Comments are plain text + markdown, no collaborative Y.Doc needed
|
|
71
|
-
document: void 0
|
|
83
|
+
document: void 0,
|
|
84
|
+
// Inherits access from its home Space (exploration 0181/0192).
|
|
85
|
+
authorization: spaceCascadeAuthorization("target")
|
|
72
86
|
});
|
|
73
87
|
|
|
74
88
|
export {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkbox,
|
|
3
|
+
created,
|
|
4
|
+
createdBy,
|
|
5
|
+
defineSchema,
|
|
6
|
+
text
|
|
7
|
+
} from "./chunk-EBNMV2VO.js";
|
|
8
|
+
import {
|
|
9
|
+
presets
|
|
10
|
+
} from "./chunk-RL64OJJ5.js";
|
|
11
|
+
|
|
12
|
+
// src/schema/schemas/tag.ts
|
|
13
|
+
var TAG_SCHEMA_IRI = "xnet://xnet.fyi/Tag@1.0.0";
|
|
14
|
+
var MAX_TAG_NAME_LENGTH = 80;
|
|
15
|
+
var TagSchema = defineSchema({
|
|
16
|
+
name: "Tag",
|
|
17
|
+
namespace: "xnet://xnet.fyi/",
|
|
18
|
+
properties: {
|
|
19
|
+
/** Normalized lowercase name, no leading '#' (see normalizeTagName) */
|
|
20
|
+
name: text({ required: true, maxLength: MAX_TAG_NAME_LENGTH }),
|
|
21
|
+
/** Pill/badge color token */
|
|
22
|
+
color: text({ maxLength: 30 }),
|
|
23
|
+
/** Optional description shown on the tag page */
|
|
24
|
+
description: text({ maxLength: 500 }),
|
|
25
|
+
/** Archived tags are hidden from pickers but references keep working */
|
|
26
|
+
archived: checkbox({ default: false }),
|
|
27
|
+
createdAt: created(),
|
|
28
|
+
createdBy: createdBy()
|
|
29
|
+
},
|
|
30
|
+
document: void 0,
|
|
31
|
+
// Standalone/personal content: owner-only by default (exploration 0192).
|
|
32
|
+
authorization: presets.private()
|
|
33
|
+
});
|
|
34
|
+
function normalizeTagName(raw) {
|
|
35
|
+
return raw.replace(/^#+/, "").trim().toLowerCase().replace(/\s+/g, "-").replace(/[^\p{L}\p{N}\-_./]/gu, "").replace(/-{2,}/g, "-").slice(0, MAX_TAG_NAME_LENGTH);
|
|
36
|
+
}
|
|
37
|
+
function isValidTagName(name) {
|
|
38
|
+
return name.length > 0 && name === normalizeTagName(name);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
TAG_SCHEMA_IRI,
|
|
43
|
+
MAX_TAG_NAME_LENGTH,
|
|
44
|
+
TagSchema,
|
|
45
|
+
normalizeTagName,
|
|
46
|
+
isValidTagName
|
|
47
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spaceCascadeAuthorization
|
|
3
|
+
} from "./chunk-OCMSAKWV.js";
|
|
4
|
+
import {
|
|
5
|
+
defineSchema,
|
|
6
|
+
relation,
|
|
7
|
+
text
|
|
8
|
+
} from "./chunk-EBNMV2VO.js";
|
|
9
|
+
|
|
10
|
+
// src/schema/schemas/database-select-option.ts
|
|
11
|
+
var DatabaseSelectOptionSchema = defineSchema({
|
|
12
|
+
name: "DatabaseSelectOption",
|
|
13
|
+
namespace: "xnet://xnet.fyi/",
|
|
14
|
+
properties: {
|
|
15
|
+
/** Parent field (must be a select/multiSelect field) */
|
|
16
|
+
field: relation({
|
|
17
|
+
target: "xnet://xnet.fyi/DatabaseField@1.0.0",
|
|
18
|
+
required: true
|
|
19
|
+
}),
|
|
20
|
+
/**
|
|
21
|
+
* Parent database (denormalized from the field) so all options for a
|
|
22
|
+
* database load in a single indexed query.
|
|
23
|
+
*/
|
|
24
|
+
database: relation({
|
|
25
|
+
target: "xnet://xnet.fyi/Database@2.0.0",
|
|
26
|
+
required: true
|
|
27
|
+
}),
|
|
28
|
+
/** Display name (the tag text) */
|
|
29
|
+
name: text({ required: true, maxLength: 100 }),
|
|
30
|
+
/** Display color (SelectColor union; enforced in field-operations) */
|
|
31
|
+
color: text({ maxLength: 20 }),
|
|
32
|
+
/** Fractional index for option ordering in pickers */
|
|
33
|
+
sortKey: text({ required: true })
|
|
34
|
+
},
|
|
35
|
+
// Inherits access from its home Space (exploration 0181/0192).
|
|
36
|
+
authorization: spaceCascadeAuthorization("database")
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
DatabaseSelectOptionSchema
|
|
41
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/sync/awareness.ts
|
|
2
|
+
import { Awareness } from "y-protocols/awareness";
|
|
3
|
+
function createAwareness(doc) {
|
|
4
|
+
return new Awareness(doc);
|
|
5
|
+
}
|
|
6
|
+
function setLocalPresence(awareness, presence) {
|
|
7
|
+
awareness.setLocalState(presence);
|
|
8
|
+
}
|
|
9
|
+
function clearLocalPresence(awareness) {
|
|
10
|
+
awareness.setLocalState(null);
|
|
11
|
+
}
|
|
12
|
+
function getRemotePresences(awareness) {
|
|
13
|
+
const states = awareness.getStates();
|
|
14
|
+
const result = /* @__PURE__ */ new Map();
|
|
15
|
+
states.forEach((state, clientId) => {
|
|
16
|
+
if (state && clientId !== awareness.clientID) {
|
|
17
|
+
result.set(clientId, state);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
function getAllPresences(awareness) {
|
|
23
|
+
const states = awareness.getStates();
|
|
24
|
+
const result = /* @__PURE__ */ new Map();
|
|
25
|
+
states.forEach((state, clientId) => {
|
|
26
|
+
if (state) {
|
|
27
|
+
result.set(clientId, state);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
function onPresenceChange(awareness, callback) {
|
|
33
|
+
awareness.on("change", callback);
|
|
34
|
+
return () => awareness.off("change", callback);
|
|
35
|
+
}
|
|
36
|
+
function getLocalClientId(awareness) {
|
|
37
|
+
return awareness.clientID;
|
|
38
|
+
}
|
|
39
|
+
function generateUserColor() {
|
|
40
|
+
const colors = [
|
|
41
|
+
"#F44336",
|
|
42
|
+
"#E91E63",
|
|
43
|
+
"#9C27B0",
|
|
44
|
+
"#673AB7",
|
|
45
|
+
"#3F51B5",
|
|
46
|
+
"#2196F3",
|
|
47
|
+
"#03A9F4",
|
|
48
|
+
"#00BCD4",
|
|
49
|
+
"#009688",
|
|
50
|
+
"#4CAF50",
|
|
51
|
+
"#8BC34A",
|
|
52
|
+
"#CDDC39",
|
|
53
|
+
"#FFC107",
|
|
54
|
+
"#FF9800",
|
|
55
|
+
"#FF5722"
|
|
56
|
+
];
|
|
57
|
+
return colors[Math.floor(Math.random() * colors.length)];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
createAwareness,
|
|
62
|
+
setLocalPresence,
|
|
63
|
+
clearLocalPresence,
|
|
64
|
+
getRemotePresences,
|
|
65
|
+
getAllPresences,
|
|
66
|
+
onPresenceChange,
|
|
67
|
+
getLocalClientId,
|
|
68
|
+
generateUserColor
|
|
69
|
+
};
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spaceCascadeAuthorization
|
|
3
|
+
} from "./chunk-OCMSAKWV.js";
|
|
4
|
+
import {
|
|
5
|
+
date,
|
|
6
|
+
defineSchema,
|
|
7
|
+
file,
|
|
8
|
+
json,
|
|
9
|
+
money,
|
|
10
|
+
number,
|
|
11
|
+
relation,
|
|
12
|
+
select,
|
|
13
|
+
text
|
|
14
|
+
} from "./chunk-EBNMV2VO.js";
|
|
15
|
+
|
|
16
|
+
// src/schema/schemas/game.ts
|
|
17
|
+
var GAME_NAMESPACE = "xnet://xnet.fyi/";
|
|
18
|
+
var PLAYER_IDENTITY_SCHEMA_IRI = "xnet://xnet.fyi/PlayerIdentity@1.0.0";
|
|
19
|
+
var INVENTORY_SCHEMA_IRI = "xnet://xnet.fyi/Inventory@1.0.0";
|
|
20
|
+
var GAME_ITEM_SCHEMA_IRI = "xnet://xnet.fyi/GameItem@1.0.0";
|
|
21
|
+
var ACHIEVEMENT_SCHEMA_IRI = "xnet://xnet.fyi/Achievement@1.0.0";
|
|
22
|
+
var MATCH_SESSION_SCHEMA_IRI = "xnet://xnet.fyi/MatchSession@1.0.0";
|
|
23
|
+
var GAME_ECONOMY_ENTRY_SCHEMA_IRI = "xnet://xnet.fyi/GameEconomyEntry@1.0.0";
|
|
24
|
+
var GAME_ASSET_SCHEMA_IRI = "xnet://xnet.fyi/GameAsset@1.0.0";
|
|
25
|
+
var SPACE_TARGET = "xnet://xnet.fyi/Space@1.0.0";
|
|
26
|
+
var GAME_ASSET_MIME_TYPES = [
|
|
27
|
+
"model/gltf-binary",
|
|
28
|
+
// .glb
|
|
29
|
+
"model/gltf+json",
|
|
30
|
+
// .gltf
|
|
31
|
+
"model/vnd.usdz+zip",
|
|
32
|
+
// .usdz
|
|
33
|
+
"model/vnd.usd",
|
|
34
|
+
// .usd
|
|
35
|
+
"model/vnd.usda"
|
|
36
|
+
// .usda
|
|
37
|
+
];
|
|
38
|
+
var VISIBILITY_OPTIONS = [
|
|
39
|
+
{ id: "inherit", name: "Inherit", color: "gray" },
|
|
40
|
+
{ id: "private", name: "Private", color: "gray" },
|
|
41
|
+
{ id: "unlisted", name: "Unlisted", color: "yellow" },
|
|
42
|
+
{ id: "public", name: "Public", color: "green" }
|
|
43
|
+
];
|
|
44
|
+
var visibility = () => select({ options: VISIBILITY_OPTIONS, default: "inherit" });
|
|
45
|
+
var space = () => relation({ target: SPACE_TARGET });
|
|
46
|
+
var PlayerIdentitySchema = defineSchema({
|
|
47
|
+
name: "PlayerIdentity",
|
|
48
|
+
namespace: GAME_NAMESPACE,
|
|
49
|
+
properties: {
|
|
50
|
+
/** Display / gamer name. */
|
|
51
|
+
displayName: text({ required: true, maxLength: 200 }),
|
|
52
|
+
/** The player's own XNet `did:key` — the portable login across publishers. */
|
|
53
|
+
did: text({ maxLength: 512 }),
|
|
54
|
+
/** Avatar asset (glTF/USD), stored by reference. */
|
|
55
|
+
avatarAsset: file({ accept: [...GAME_ASSET_MIME_TYPES] }),
|
|
56
|
+
/** The title this identity is "homed" in (origin game). */
|
|
57
|
+
homeGame: text({ maxLength: 200 }),
|
|
58
|
+
/** Short bio / status the player chooses to surface in-game. */
|
|
59
|
+
bio: text({ maxLength: 2e3 }),
|
|
60
|
+
space: space(),
|
|
61
|
+
visibility: visibility()
|
|
62
|
+
},
|
|
63
|
+
document: void 0,
|
|
64
|
+
authorization: spaceCascadeAuthorization()
|
|
65
|
+
});
|
|
66
|
+
var ITEM_RARITIES = [
|
|
67
|
+
{ id: "common", name: "Common", color: "gray" },
|
|
68
|
+
{ id: "uncommon", name: "Uncommon", color: "green" },
|
|
69
|
+
{ id: "rare", name: "Rare", color: "blue" },
|
|
70
|
+
{ id: "epic", name: "Epic", color: "purple" },
|
|
71
|
+
{ id: "legendary", name: "Legendary", color: "orange" }
|
|
72
|
+
];
|
|
73
|
+
var GameItemSchema = defineSchema({
|
|
74
|
+
name: "GameItem",
|
|
75
|
+
namespace: GAME_NAMESPACE,
|
|
76
|
+
properties: {
|
|
77
|
+
name: text({ required: true, maxLength: 300 }),
|
|
78
|
+
rarity: select({ options: ITEM_RARITIES, default: "common" }),
|
|
79
|
+
/** The title that minted the item (provenance for cross-game portability). */
|
|
80
|
+
sourceGame: text({ maxLength: 200 }),
|
|
81
|
+
/** Visual/3D asset (glTF/USD), by reference. */
|
|
82
|
+
asset: file({ accept: [...GAME_ASSET_MIME_TYPES] }),
|
|
83
|
+
/** Stack count for fungible items. */
|
|
84
|
+
quantity: number({ integer: true, min: 0 }),
|
|
85
|
+
/** Opaque, engine-interpreted attribute bag (stats, sockets, bindings). */
|
|
86
|
+
attributes: json({}),
|
|
87
|
+
space: space(),
|
|
88
|
+
visibility: visibility()
|
|
89
|
+
},
|
|
90
|
+
document: void 0,
|
|
91
|
+
authorization: spaceCascadeAuthorization()
|
|
92
|
+
});
|
|
93
|
+
var InventorySchema = defineSchema({
|
|
94
|
+
name: "Inventory",
|
|
95
|
+
namespace: GAME_NAMESPACE,
|
|
96
|
+
properties: {
|
|
97
|
+
/** Whose inventory this is. */
|
|
98
|
+
owner: relation({ target: PLAYER_IDENTITY_SCHEMA_IRI }),
|
|
99
|
+
label: text({ maxLength: 200 }),
|
|
100
|
+
/** Held items. */
|
|
101
|
+
items: relation({ target: GAME_ITEM_SCHEMA_IRI, multiple: true }),
|
|
102
|
+
space: space(),
|
|
103
|
+
visibility: visibility()
|
|
104
|
+
},
|
|
105
|
+
document: void 0,
|
|
106
|
+
authorization: spaceCascadeAuthorization()
|
|
107
|
+
});
|
|
108
|
+
var AchievementSchema = defineSchema({
|
|
109
|
+
name: "Achievement",
|
|
110
|
+
namespace: GAME_NAMESPACE,
|
|
111
|
+
properties: {
|
|
112
|
+
name: text({ required: true, maxLength: 300 }),
|
|
113
|
+
description: text({ maxLength: 2e3 }),
|
|
114
|
+
player: relation({ target: PLAYER_IDENTITY_SCHEMA_IRI }),
|
|
115
|
+
game: text({ maxLength: 200 }),
|
|
116
|
+
unlockedAt: date({}),
|
|
117
|
+
/** Gamerscore-style point value. */
|
|
118
|
+
points: number({ integer: true, min: 0 }),
|
|
119
|
+
space: space(),
|
|
120
|
+
visibility: visibility()
|
|
121
|
+
},
|
|
122
|
+
document: void 0,
|
|
123
|
+
authorization: spaceCascadeAuthorization()
|
|
124
|
+
});
|
|
125
|
+
var MATCH_RESULTS = [
|
|
126
|
+
{ id: "win", name: "Win", color: "green" },
|
|
127
|
+
{ id: "loss", name: "Loss", color: "red" },
|
|
128
|
+
{ id: "draw", name: "Draw", color: "gray" },
|
|
129
|
+
{ id: "incomplete", name: "Incomplete", color: "yellow" }
|
|
130
|
+
];
|
|
131
|
+
var MatchSessionSchema = defineSchema({
|
|
132
|
+
name: "MatchSession",
|
|
133
|
+
namespace: GAME_NAMESPACE,
|
|
134
|
+
properties: {
|
|
135
|
+
game: text({ required: true, maxLength: 200 }),
|
|
136
|
+
player: relation({ target: PLAYER_IDENTITY_SCHEMA_IRI }),
|
|
137
|
+
result: select({ options: MATCH_RESULTS }),
|
|
138
|
+
score: number({}),
|
|
139
|
+
startedAt: date({}),
|
|
140
|
+
endedAt: date({}),
|
|
141
|
+
/** Opaque per-match stat bag (mode, map, kills, etc.). */
|
|
142
|
+
stats: json({}),
|
|
143
|
+
space: space(),
|
|
144
|
+
visibility: visibility()
|
|
145
|
+
},
|
|
146
|
+
document: void 0,
|
|
147
|
+
authorization: spaceCascadeAuthorization()
|
|
148
|
+
});
|
|
149
|
+
var GameEconomyEntrySchema = defineSchema({
|
|
150
|
+
name: "GameEconomyEntry",
|
|
151
|
+
namespace: GAME_NAMESPACE,
|
|
152
|
+
properties: {
|
|
153
|
+
player: relation({ target: PLAYER_IDENTITY_SCHEMA_IRI }),
|
|
154
|
+
/** Currency code / soft-currency name (e.g. `V-Bucks`, `gold`). */
|
|
155
|
+
currency: text({ required: true, maxLength: 60 }),
|
|
156
|
+
/** Signed amount, integer minor units — reconciles via `@xnetjs/ledger`. */
|
|
157
|
+
amount: money({ required: true }),
|
|
158
|
+
/** What caused the entry (purchase, reward, trade). */
|
|
159
|
+
reason: text({ maxLength: 500 }),
|
|
160
|
+
game: text({ maxLength: 200 }),
|
|
161
|
+
occurredAt: date({}),
|
|
162
|
+
space: space(),
|
|
163
|
+
visibility: visibility()
|
|
164
|
+
},
|
|
165
|
+
document: void 0,
|
|
166
|
+
authorization: spaceCascadeAuthorization()
|
|
167
|
+
});
|
|
168
|
+
var GAME_ASSET_FORMATS = [
|
|
169
|
+
{ id: "glb", name: "glTF (binary)" },
|
|
170
|
+
{ id: "gltf", name: "glTF (JSON)" },
|
|
171
|
+
{ id: "usd", name: "OpenUSD" },
|
|
172
|
+
{ id: "usdz", name: "USDZ" },
|
|
173
|
+
{ id: "other", name: "Other" }
|
|
174
|
+
];
|
|
175
|
+
var GameAssetSchema = defineSchema({
|
|
176
|
+
name: "GameAsset",
|
|
177
|
+
namespace: GAME_NAMESPACE,
|
|
178
|
+
properties: {
|
|
179
|
+
title: text({ required: true, maxLength: 300 }),
|
|
180
|
+
/** The asset payload, by reference (CID) — never parsed by XNet. */
|
|
181
|
+
file: file({ required: true, accept: [...GAME_ASSET_MIME_TYPES] }),
|
|
182
|
+
format: select({ options: GAME_ASSET_FORMATS, default: "glb" }),
|
|
183
|
+
sourceGame: text({ maxLength: 200 }),
|
|
184
|
+
description: text({ maxLength: 2e3 }),
|
|
185
|
+
space: space(),
|
|
186
|
+
visibility: visibility()
|
|
187
|
+
},
|
|
188
|
+
document: void 0,
|
|
189
|
+
authorization: spaceCascadeAuthorization()
|
|
190
|
+
});
|
|
191
|
+
var GAME_SCHEMA_IRIS = [
|
|
192
|
+
PLAYER_IDENTITY_SCHEMA_IRI,
|
|
193
|
+
INVENTORY_SCHEMA_IRI,
|
|
194
|
+
GAME_ITEM_SCHEMA_IRI,
|
|
195
|
+
ACHIEVEMENT_SCHEMA_IRI,
|
|
196
|
+
MATCH_SESSION_SCHEMA_IRI,
|
|
197
|
+
GAME_ECONOMY_ENTRY_SCHEMA_IRI,
|
|
198
|
+
GAME_ASSET_SCHEMA_IRI
|
|
199
|
+
];
|
|
200
|
+
var gameSchemas = [
|
|
201
|
+
PlayerIdentitySchema,
|
|
202
|
+
GameItemSchema,
|
|
203
|
+
InventorySchema,
|
|
204
|
+
AchievementSchema,
|
|
205
|
+
MatchSessionSchema,
|
|
206
|
+
GameEconomyEntrySchema,
|
|
207
|
+
GameAssetSchema
|
|
208
|
+
];
|
|
209
|
+
|
|
210
|
+
export {
|
|
211
|
+
GAME_NAMESPACE,
|
|
212
|
+
PLAYER_IDENTITY_SCHEMA_IRI,
|
|
213
|
+
INVENTORY_SCHEMA_IRI,
|
|
214
|
+
GAME_ITEM_SCHEMA_IRI,
|
|
215
|
+
ACHIEVEMENT_SCHEMA_IRI,
|
|
216
|
+
MATCH_SESSION_SCHEMA_IRI,
|
|
217
|
+
GAME_ECONOMY_ENTRY_SCHEMA_IRI,
|
|
218
|
+
GAME_ASSET_SCHEMA_IRI,
|
|
219
|
+
GAME_ASSET_MIME_TYPES,
|
|
220
|
+
PlayerIdentitySchema,
|
|
221
|
+
ITEM_RARITIES,
|
|
222
|
+
GameItemSchema,
|
|
223
|
+
InventorySchema,
|
|
224
|
+
AchievementSchema,
|
|
225
|
+
MATCH_RESULTS,
|
|
226
|
+
MatchSessionSchema,
|
|
227
|
+
GameEconomyEntrySchema,
|
|
228
|
+
GAME_ASSET_FORMATS,
|
|
229
|
+
GameAssetSchema,
|
|
230
|
+
GAME_SCHEMA_IRIS,
|
|
231
|
+
gameSchemas
|
|
232
|
+
};
|