jazz-tools 0.7.0-alpha.0 → 0.7.0-alpha.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. package/.eslintrc.cjs +8 -1
  2. package/.turbo/turbo-build.log +79 -9
  3. package/CHANGELOG.md +76 -0
  4. package/dist/coValues/account.js +171 -0
  5. package/dist/coValues/account.js.map +1 -0
  6. package/dist/coValues/coList.js +246 -0
  7. package/dist/coValues/coList.js.map +1 -0
  8. package/dist/coValues/coMap.js +235 -0
  9. package/dist/coValues/coMap.js.map +1 -0
  10. package/dist/coValues/coStream.js +263 -0
  11. package/dist/coValues/coStream.js.map +1 -0
  12. package/dist/coValues/extensions/imageDef.js +14 -11
  13. package/dist/coValues/extensions/imageDef.js.map +1 -1
  14. package/dist/coValues/group.js +71 -0
  15. package/dist/coValues/group.js.map +1 -0
  16. package/dist/coValues/interfaces.js +61 -0
  17. package/dist/coValues/interfaces.js.map +1 -0
  18. package/dist/implementation/errors.js.map +1 -0
  19. package/dist/implementation/inspect.js +2 -0
  20. package/dist/implementation/inspect.js.map +1 -0
  21. package/dist/{refs.js → implementation/refs.js} +16 -15
  22. package/dist/implementation/refs.js.map +1 -0
  23. package/dist/implementation/schema.js +41 -0
  24. package/dist/implementation/schema.js.map +1 -0
  25. package/dist/{subscriptionScope.js → implementation/subscriptionScope.js} +1 -1
  26. package/dist/implementation/subscriptionScope.js.map +1 -0
  27. package/dist/index.js +10 -29
  28. package/dist/index.js.map +1 -1
  29. package/dist/internal.js +13 -0
  30. package/dist/internal.js.map +1 -0
  31. package/dist/tests/coList.test.js +22 -22
  32. package/dist/tests/coList.test.js.map +1 -1
  33. package/dist/tests/coMap.test.js +140 -46
  34. package/dist/tests/coMap.test.js.map +1 -1
  35. package/dist/tests/coStream.test.js +55 -49
  36. package/dist/tests/coStream.test.js.map +1 -1
  37. package/package.json +11 -4
  38. package/src/coValues/account.ts +327 -0
  39. package/src/coValues/coList.ts +391 -0
  40. package/src/coValues/coMap.ts +413 -0
  41. package/src/coValues/coStream.ts +404 -0
  42. package/src/coValues/extensions/imageDef.ts +20 -16
  43. package/src/coValues/group.ts +139 -0
  44. package/src/coValues/interfaces.ts +218 -0
  45. package/src/implementation/inspect.ts +2 -0
  46. package/src/{refs.ts → implementation/refs.ts} +53 -39
  47. package/src/implementation/schema.ts +124 -0
  48. package/src/{subscriptionScope.ts → implementation/subscriptionScope.ts} +11 -13
  49. package/src/index.ts +14 -57
  50. package/src/internal.ts +15 -0
  51. package/src/tests/coList.test.ts +23 -25
  52. package/src/tests/coMap.test.ts +140 -53
  53. package/src/tests/coStream.test.ts +76 -68
  54. package/dist/coValueInterfaces.js +0 -8
  55. package/dist/coValueInterfaces.js.map +0 -1
  56. package/dist/coValues/account/account.js +0 -11
  57. package/dist/coValues/account/account.js.map +0 -1
  58. package/dist/coValues/account/accountOf.js +0 -150
  59. package/dist/coValues/account/accountOf.js.map +0 -1
  60. package/dist/coValues/account/migration.js +0 -4
  61. package/dist/coValues/account/migration.js.map +0 -1
  62. package/dist/coValues/coList/coList.js +0 -2
  63. package/dist/coValues/coList/coList.js.map +0 -1
  64. package/dist/coValues/coList/coListOf.js +0 -235
  65. package/dist/coValues/coList/coListOf.js.map +0 -1
  66. package/dist/coValues/coList/internalDocs.js +0 -2
  67. package/dist/coValues/coList/internalDocs.js.map +0 -1
  68. package/dist/coValues/coMap/coMap.js +0 -2
  69. package/dist/coValues/coMap/coMap.js.map +0 -1
  70. package/dist/coValues/coMap/coMapOf.js +0 -262
  71. package/dist/coValues/coMap/coMapOf.js.map +0 -1
  72. package/dist/coValues/coMap/internalDocs.js +0 -2
  73. package/dist/coValues/coMap/internalDocs.js.map +0 -1
  74. package/dist/coValues/coStream/coStream.js +0 -2
  75. package/dist/coValues/coStream/coStream.js.map +0 -1
  76. package/dist/coValues/coStream/coStreamOf.js +0 -244
  77. package/dist/coValues/coStream/coStreamOf.js.map +0 -1
  78. package/dist/coValues/construction.js +0 -34
  79. package/dist/coValues/construction.js.map +0 -1
  80. package/dist/coValues/group/group.js +0 -2
  81. package/dist/coValues/group/group.js.map +0 -1
  82. package/dist/coValues/group/groupOf.js +0 -109
  83. package/dist/coValues/group/groupOf.js.map +0 -1
  84. package/dist/coValues/resolution.js +0 -66
  85. package/dist/coValues/resolution.js.map +0 -1
  86. package/dist/errors.js.map +0 -1
  87. package/dist/refs.js.map +0 -1
  88. package/dist/schemaHelpers.js +0 -14
  89. package/dist/schemaHelpers.js.map +0 -1
  90. package/dist/subscriptionScope.js.map +0 -1
  91. package/dist/tests/types.test.js +0 -33
  92. package/dist/tests/types.test.js.map +0 -1
  93. package/src/coValueInterfaces.ts +0 -105
  94. package/src/coValues/account/account.ts +0 -106
  95. package/src/coValues/account/accountOf.ts +0 -284
  96. package/src/coValues/account/migration.ts +0 -12
  97. package/src/coValues/coList/coList.ts +0 -57
  98. package/src/coValues/coList/coListOf.ts +0 -377
  99. package/src/coValues/coList/internalDocs.ts +0 -1
  100. package/src/coValues/coMap/coMap.ts +0 -110
  101. package/src/coValues/coMap/coMapOf.ts +0 -451
  102. package/src/coValues/coMap/internalDocs.ts +0 -1
  103. package/src/coValues/coStream/coStream.ts +0 -63
  104. package/src/coValues/coStream/coStreamOf.ts +0 -404
  105. package/src/coValues/construction.ts +0 -110
  106. package/src/coValues/group/group.ts +0 -27
  107. package/src/coValues/group/groupOf.ts +0 -183
  108. package/src/coValues/resolution.ts +0 -111
  109. package/src/schemaHelpers.ts +0 -72
  110. package/src/tests/types.test.ts +0 -37
  111. /package/dist/{errors.js → implementation/errors.js} +0 -0
  112. /package/src/{errors.ts → implementation/errors.ts} +0 -0
package/.eslintrc.cjs CHANGED
@@ -19,6 +19,13 @@ module.exports = {
19
19
  { argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
20
20
  ],
21
21
  "@typescript-eslint/no-floating-promises": "error",
22
- "@typescript-eslint/no-explicit-any": "warn"
22
+ "@typescript-eslint/no-explicit-any": "warn",
23
+ "@typescript-eslint/consistent-type-imports": [
24
+ "error",
25
+ {
26
+ prefer: "type-imports",
27
+ disallowTypeAnnotations: false,
28
+ },
29
+ ],
23
30
  },
24
31
  };
@@ -1,24 +1,94 @@
1
1
 
2
- > jazz-js@0.6.1 build /Users/anselm/jazz/jazz/packages/jazz-js
2
+ > jazz-tools@0.7.0-alpha.10 build /Users/anselm/jazz/jazz/packages/jazz-tools
3
3
  > npm run lint && rm -rf ./dist && tsc --sourceMap --outDir dist
4
4
 
5
5
 
6
- > jazz-js@0.6.1 lint
6
+ > jazz-tools@0.7.0-alpha.10 lint
7
7
  > eslint src/**/*.ts
8
8
 
9
9
 
10
- /Users/anselm/jazz/jazz/packages/jazz-js/src/tests/binaryCoStream.test.ts
11
- 0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override
10
+ /Users/anselm/jazz/jazz/packages/jazz-tools/src/coValues/account.ts
11
+ 48:21 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
12
+ 59:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
13
+ 97:22 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
14
+ 106:22 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
15
+ 180:11 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
16
+ 239:24 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
17
+ 257:67 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
18
+ 260:67 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
19
+ 311:12 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
20
+ 317:29 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
21
+ 317:39 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
22
+
23
+ /Users/anselm/jazz/jazz/packages/jazz-tools/src/coValues/coList.ts
24
+ 31:62 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
25
+ 35:56 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
26
+ 57:21 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
27
+ 89:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
28
+ 236:71 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
29
+ 241:75 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
30
+ 274:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
31
+
32
+ /Users/anselm/jazz/jazz/packages/jazz-tools/src/coValues/coMap.ts
33
+ 27:50 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
34
+ 27:68 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
35
+ 55:20 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
36
+ 56:18 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
37
+ 92:21 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
38
+ 116:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
39
+ 212:44 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
40
+ 230:56 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
41
+ 256:38 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
42
+ 283:42 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
43
+
44
+ /Users/anselm/jazz/jazz/packages/jazz-tools/src/coValues/coStream.ts
45
+ 43:66 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
46
+ 47:58 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
47
+ 64:21 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
48
+ 164:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
49
+
50
+ /Users/anselm/jazz/jazz/packages/jazz-tools/src/coValues/group.ts
51
+ 33:21 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
52
+ 48:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
53
+ 79:22 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
54
+ 86:22 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
55
+ 91:23 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
56
+
57
+ /Users/anselm/jazz/jazz/packages/jazz-tools/src/coValues/interfaces.ts
58
+ 15:19 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
59
+ 18:71 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
60
+ 57:62 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
61
+ 73:15 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
62
+ 75:18 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
63
+ 78:34 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
64
+ 81:39 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
65
+ 105:27 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
66
+ 207:24 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
67
+
68
+ /Users/anselm/jazz/jazz/packages/jazz-tools/src/implementation/schema.ts
69
+ 33:61 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
70
+ 36:61 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
71
+ 39:71 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
72
+ 44:58 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
73
+ 70:68 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
74
+ 79:5 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
75
+ 80:5 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
76
+ 84:17 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
77
+ 85:17 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
78
+ 119:11 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
79
+ 124:7 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
80
+
81
+ /Users/anselm/jazz/jazz/packages/jazz-tools/src/implementation/subscriptionScope.ts
82
+ 6:23 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
12
83
 
13
- /Users/anselm/jazz/jazz/packages/jazz-js/src/tests/coList.test.ts
84
+ /Users/anselm/jazz/jazz/packages/jazz-tools/src/tests/coList.test.ts
14
85
  0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override
15
86
 
16
- /Users/anselm/jazz/jazz/packages/jazz-js/src/tests/coMap.test.ts
87
+ /Users/anselm/jazz/jazz/packages/jazz-tools/src/tests/coMap.test.ts
17
88
  0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override
18
89
 
19
- /Users/anselm/jazz/jazz/packages/jazz-js/src/tests/coStream.test.ts
90
+ /Users/anselm/jazz/jazz/packages/jazz-tools/src/tests/coStream.test.ts
20
91
  0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override
21
92
 
22
- 4 problems (0 errors, 4 warnings)
93
+ 61 problems (0 errors, 61 warnings)
23
94
 
24
-  ELIFECYCLE  Command failed.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,81 @@
1
1
  # jazz-autosub
2
2
 
3
+ ## 0.7.0-alpha.11
4
+
5
+ ### Patch Changes
6
+
7
+ - Support stricter TS lint rules
8
+ - Updated dependencies
9
+ - cojson@0.7.0-alpha.11
10
+
11
+ ## 0.7.0-alpha.10
12
+
13
+ ### Patch Changes
14
+
15
+ - Clean up API more & re-add jazz-nodejs
16
+ - Updated dependencies
17
+ - cojson@0.7.0-alpha.10
18
+
19
+ ## 0.7.0-alpha.9
20
+
21
+ ### Patch Changes
22
+
23
+ - Even friendlier for subclassing CoMap
24
+
25
+ ## 0.7.0-alpha.8
26
+
27
+ ### Patch Changes
28
+
29
+ - More subclass-friendly types in CoMap
30
+
31
+ ## 0.7.0-alpha.7
32
+
33
+ ### Patch Changes
34
+
35
+ - Consistent proxy based API
36
+ - Updated dependencies
37
+ - cojson@0.7.0-alpha.7
38
+
39
+ ## 0.7.0-alpha.6
40
+
41
+ ### Patch Changes
42
+
43
+ - CoMap fix
44
+
45
+ ## 0.7.0-alpha.5
46
+
47
+ ### Patch Changes
48
+
49
+ - Refactoring
50
+ - Updated dependencies
51
+ - cojson@0.7.0-alpha.5
52
+
53
+ ## 0.7.0-alpha.4
54
+
55
+ ### Patch Changes
56
+
57
+ - Make refs on list more precise
58
+
59
+ ## 0.7.0-alpha.3
60
+
61
+ ### Patch Changes
62
+
63
+ - Make refs type more precise
64
+
65
+ ## 0.7.0-alpha.2
66
+
67
+ ### Patch Changes
68
+
69
+ - Get rid of Co namespace
70
+
71
+ ## 0.7.0-alpha.1
72
+
73
+ ### Patch Changes
74
+
75
+ - Use effect schema much less
76
+ - Updated dependencies
77
+ - cojson@0.7.0-alpha.1
78
+
3
79
  ## 0.7.0-alpha.0
4
80
 
5
81
  ### Minor Changes
@@ -0,0 +1,171 @@
1
+ var _a;
2
+ import { LocalNode } from "cojson";
3
+ import { Context } from "effect";
4
+ import { CoValueBase, Profile, Ref, SchemaInit, inspect, subscriptionsScopes, } from "../internal.js";
5
+ export class Account extends CoValueBase {
6
+ get _schema() {
7
+ return this.constructor._schema;
8
+ }
9
+ get _owner() {
10
+ return this;
11
+ }
12
+ get _loadedAs() {
13
+ return this.isMe
14
+ ? this
15
+ : _a.fromNode(this._raw.core.node);
16
+ }
17
+ get _refs() {
18
+ const profileID = this._raw.get("profile");
19
+ const rootID = this._raw.get("root");
20
+ return {
21
+ profile: profileID &&
22
+ new Ref(profileID, this._loadedAs, this._schema.profile),
23
+ root: rootID &&
24
+ new Ref(rootID, this._loadedAs, this._schema.root),
25
+ };
26
+ }
27
+ constructor(_init, options) {
28
+ super();
29
+ this.acceptInvite = (async (valueID, inviteSecret, coValueClass) => {
30
+ if (!this.isMe) {
31
+ throw new Error("Only a controlled account can accept invites");
32
+ }
33
+ await this._raw.acceptInvite(valueID, inviteSecret);
34
+ return coValueClass.load(valueID, {
35
+ as: this,
36
+ });
37
+ });
38
+ if (!("fromRaw" in options)) {
39
+ throw new Error("Can only construct account from raw or with .create()");
40
+ }
41
+ this.isMe = options.fromRaw.id == options.fromRaw.core.node.account.id;
42
+ Object.defineProperties(this, {
43
+ id: {
44
+ value: options.fromRaw.id,
45
+ enumerable: false,
46
+ },
47
+ _raw: { value: options.fromRaw, enumerable: false },
48
+ });
49
+ if (this.isMe) {
50
+ this.sessionID =
51
+ options.fromRaw.core.node.currentSessionID;
52
+ }
53
+ return new Proxy(this, AccountAndGroupProxyHandler);
54
+ }
55
+ myRole() {
56
+ if (this.isMe) {
57
+ return "admin";
58
+ }
59
+ }
60
+ static async create(options) {
61
+ const { node } = await LocalNode.withNewlyCreatedAccount({
62
+ ...options,
63
+ migration: async (rawAccount) => {
64
+ const account = new this(undefined, {
65
+ fromRaw: rawAccount,
66
+ });
67
+ await account.migrate?.();
68
+ },
69
+ });
70
+ return this.fromNode(node);
71
+ }
72
+ static async become(options) {
73
+ const node = await LocalNode.withLoadedAccount({
74
+ accountID: options.accountID,
75
+ accountSecret: options.accountSecret,
76
+ sessionID: options.sessionID,
77
+ peersToLoadFrom: options.peersToLoadFrom,
78
+ migration: async (rawAccount) => {
79
+ const account = new this(undefined, {
80
+ fromRaw: rawAccount,
81
+ });
82
+ await account.migrate?.();
83
+ },
84
+ });
85
+ return this.fromNode(node);
86
+ }
87
+ static fromNode(node) {
88
+ return new this(undefined, {
89
+ fromRaw: node.account,
90
+ });
91
+ }
92
+ toJSON() {
93
+ return {
94
+ id: this.id,
95
+ _type: this._type,
96
+ };
97
+ }
98
+ [inspect]() {
99
+ return this.toJSON();
100
+ }
101
+ }
102
+ _a = Account;
103
+ (() => {
104
+ _a._schema = {
105
+ profile: { ref: () => Profile },
106
+ root: { json: true },
107
+ };
108
+ })();
109
+ export const AccountAndGroupProxyHandler = {
110
+ get(target, key, receiver) {
111
+ if (key === "profile") {
112
+ const ref = target._refs.profile;
113
+ return ref ? ref.accessFrom(receiver) : undefined;
114
+ }
115
+ else if (key === "root") {
116
+ const ref = target._refs.root;
117
+ return ref ? ref.accessFrom(receiver) : undefined;
118
+ }
119
+ else {
120
+ return Reflect.get(target, key, receiver);
121
+ }
122
+ },
123
+ set(target, key, value, receiver) {
124
+ var _b;
125
+ if ((key === "profile" || key === "root") &&
126
+ typeof value === "object" &&
127
+ SchemaInit in value) {
128
+ (_b = target.constructor)._schema || (_b._schema = {});
129
+ target.constructor._schema[key] =
130
+ value[SchemaInit];
131
+ return true;
132
+ }
133
+ else if (key === "profile") {
134
+ if (value) {
135
+ target._raw.set("profile", value.id);
136
+ }
137
+ subscriptionsScopes.get(receiver)?.onRefAccessedOrSet(value.id);
138
+ return true;
139
+ }
140
+ else if (key === "root") {
141
+ if (value) {
142
+ target._raw.set("root", value.id);
143
+ }
144
+ subscriptionsScopes.get(receiver)?.onRefAccessedOrSet(value.id);
145
+ return true;
146
+ }
147
+ else {
148
+ return Reflect.set(target, key, value, receiver);
149
+ }
150
+ },
151
+ defineProperty(target, key, descriptor) {
152
+ var _b;
153
+ if ((key === "profile" || key === "root") &&
154
+ typeof descriptor.value === "object" &&
155
+ SchemaInit in descriptor.value) {
156
+ (_b = target.constructor)._schema || (_b._schema = {});
157
+ target.constructor._schema[key] =
158
+ descriptor.value[SchemaInit];
159
+ return true;
160
+ }
161
+ else {
162
+ return Reflect.defineProperty(target, key, descriptor);
163
+ }
164
+ },
165
+ };
166
+ export class AccountCtx extends Context.Tag("Account")() {
167
+ }
168
+ export function isControlledAccount(account) {
169
+ return account.isMe;
170
+ }
171
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/coValues/account.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAYnC,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAYjC,OAAO,EACH,WAAW,EACX,OAAO,EACP,GAAG,EACH,UAAU,EACV,OAAO,EACP,mBAAmB,GACtB,MAAM,gBAAgB,C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chemaInit, co, inspect, isRefEncoded, makeRefs, } from "../internal.js";
4
+ import { Schema as EffectSchema } from "@effect/schema";
5
+ export class CoList extends Array {
6
+ static Of(item) {
7
+ var _b, _c;
8
+ return _c = class CoListOf extends _a {
9
+ constructor() {
10
+ super(...arguments);
11
+ this[_b] = item;
12
+ }
13
+ },
14
+ _b = co.items,
15
+ _c;
16
+ }
17
+ /** @deprecated Use UPPERCASE `CoList.Of` instead! */
18
+ static of(..._args) {
19
+ throw new Error("Can't use Array.of with CoLists");
20
+ }
21
+ get _schema() {
22
+ return this.constructor._schema;
23
+ }
24
+ get _owner() {
25
+ return this._raw.group instanceof RawAccount
26
+ ? Account.fromRaw(this._raw.group)
27
+ : Group.fromRaw(this._raw.group);
28
+ }
29
+ get _refs() {
30
+ return makeRefs((idx) => this._raw.get(idx), () => Array.from({ length: this._raw.entries().length }, (_, idx) => idx), this._loadedAs, (_idx) => this._schema[ItemsSym]);
31
+ }
32
+ get _edits() {
33
+ throw new Error("Not implemented");
34
+ }
35
+ get _loadedAs() {
36
+ return Account.fromNode(this._raw.core.node);
37
+ }
38
+ static get [Symbol.species]() {
39
+ return Array;
40
+ }
41
+ constructor(init, options) {
42
+ super();
43
+ if (!options) {
44
+ throw new Error("Must provide options");
45
+ }
46
+ if (init && "owner" in options) {
47
+ this[InitValues] = {
48
+ init,
49
+ owner: options.owner,
50
+ };
51
+ }
52
+ else if ("fromRaw" in options) {
53
+ Object.defineProperties(this, {
54
+ id: {
55
+ value: options.fromRaw.id,
56
+ enumerable: false,
57
+ },
58
+ _raw: { value: options.fromRaw, enumerable: false },
59
+ });
60
+ }
61
+ return new Proxy(this, CoListProxyHandler);
62
+ }
63
+ push(...items) {
64
+ for (const item of toRawItems(items, this._schema[ItemsSym])) {
65
+ this._raw.append(item);
66
+ }
67
+ return this._raw.entries().length;
68
+ }
69
+ unshift(...items) {
70
+ for (const item of toRawItems(items, this._schema[ItemsSym])) {
71
+ this._raw.prepend(item);
72
+ }
73
+ return this._raw.entries().length;
74
+ }
75
+ pop() {
76
+ const last = this[this.length - 1];
77
+ this._raw.delete(this.length - 1);
78
+ return last;
79
+ }
80
+ shift() {
81
+ const first = this[0];
82
+ this._raw.delete(0);
83
+ return first;
84
+ }
85
+ splice(start, deleteCount, ...items) {
86
+ const deleted = this.slice(start, start + deleteCount);
87
+ for (let idxToDelete = start + deleteCount; idxToDelete > start; idxToDelete--) {
88
+ this._raw.delete(idxToDelete);
89
+ }
90
+ let appendAfter = start;
91
+ for (const item of toRawItems(items, this._schema[ItemsSym])) {
92
+ this._raw.append(item, appendAfter);
93
+ appendAfter++;
94
+ }
95
+ return deleted;
96
+ }
97
+ toJSON() {
98
+ const itemDescriptor = this._schema[ItemsSym];
99
+ if (itemDescriptor === "json") {
100
+ return this._raw.asArray();
101
+ }
102
+ else if ("encoded" in itemDescriptor) {
103
+ return this._raw
104
+ .asArray()
105
+ .map((e) => EffectSchema.encodeSync(itemDescriptor.encoded)(e));
106
+ }
107
+ else if (isRefEncoded(itemDescriptor)) {
108
+ return this.map((item) => item?.toJSON());
109
+ }
110
+ else {
111
+ return [];
112
+ }
113
+ }
114
+ [inspect]() {
115
+ return this.toJSON();
116
+ }
117
+ static fromRaw(raw) {
118
+ return new this(undefined, { fromRaw: raw });
119
+ }
120
+ static schema(def) {
121
+ this._schema || (this._schema = {});
122
+ Object.assign(this._schema, def);
123
+ }
124
+ }
125
+ _a = CoList;
126
+ (() => {
127
+ _a.prototype._type = "CoList";
128
+ })();
129
+ (() => {
130
+ _a.prototype.subscribe = CoValueBase.prototype.subscribe;
131
+ })();
132
+ (() => {
133
+ _a.prototype.subscribeEf = CoValueBase.prototype.subscribeEf;
134
+ })();
135
+ CoList.loadEf = CoValueBase.loadEf;
136
+ CoList.load = CoValueBase.load;
137
+ CoList.subscribeEf = CoValueBase.subscribeEf;
138
+ CoList.subscribe = CoValueBase.subscribe;
139
+ function toRawItems(items, itemDescriptor) {
140
+ const rawItems = itemDescriptor === "json"
141
+ ? items
142
+ : "encoded" in itemDescriptor
143
+ ? items?.map((e) => EffectSchema.encodeSync(itemDescriptor.encoded)(e))
144
+ : isRefEncoded(itemDescriptor)
145
+ ? items?.map((v) => v.id)
146
+ : (() => {
147
+ throw new Error("Invalid element descriptor");
148
+ })();
149
+ return rawItems;
150
+ }
151
+ function init(list) {
152
+ if (list[InitValues]) {
153
+ const { init, owner } = list[InitValues];
154
+ const raw = owner._raw.createList(toRawItems(init, list._schema[ItemsSym]));
155
+ Object.defineProperties(list, {
156
+ id: {
157
+ value: raw.id,
158
+ enumerable: false,
159
+ },
160
+ _raw: { value: raw, enumerable: false },
161
+ });
162
+ delete list[InitValues];
163
+ }
164
+ }
165
+ const CoListProxyHandler = {
166
+ get(target, key, receiver) {
167
+ if (typeof key === "string" && !isNaN(+key)) {
168
+ const itemDescriptor = target._schema[ItemsSym];
169
+ const rawValue = target._raw.get(Number(key));
170
+ if (itemDescriptor === "json") {
171
+ return rawValue;
172
+ }
173
+ else if ("encoded" in itemDescriptor) {
174
+ return rawValue === undefined
175
+ ? undefined
176
+ : EffectSchema.decodeSync(itemDescriptor.encoded)(rawValue);
177
+ }
178
+ else if (isRefEncoded(itemDescriptor)) {
179
+ return rawValue === undefined
180
+ ? undefined
181
+ : new Ref(rawValue, target._loadedAs, itemDescriptor).accessFrom(receiver);
182
+ }
183
+ }
184
+ else if (key === "length") {
185
+ return target._raw.entries().length;
186
+ }
187
+ else {
188
+ return Reflect.get(target, key, receiver);
189
+ }
190
+ },
191
+ set(target, key, value, receiver) {
192
+ var _b;
193
+ if (key === ItemsSym &&
194
+ typeof value === "object" &&
195
+ SchemaInit in value) {
196
+ (_b = target.constructor)._schema || (_b._schema = {});
197
+ target.constructor._schema[ItemsSym] =
198
+ value[SchemaInit];
199
+ init(target);
200
+ return true;
201
+ }
202
+ if (typeof key === "string" && !isNaN(+key)) {
203
+ const itemDescriptor = target._schema[ItemsSym];
204
+ let rawValue;
205
+ if (itemDescriptor === "json") {
206
+ rawValue = value;
207
+ }
208
+ else if ("encoded" in itemDescriptor) {
209
+ rawValue = EffectSchema.encodeSync(itemDescriptor.encoded)(value);
210
+ }
211
+ else if (isRefEncoded(itemDescriptor)) {
212
+ rawValue = value.id;
213
+ }
214
+ target._raw.replace(Number(key), rawValue);
215
+ return true;
216
+ }
217
+ else {
218
+ return Reflect.set(target, key, value, receiver);
219
+ }
220
+ },
221
+ defineProperty(target, key, descriptor) {
222
+ var _b;
223
+ if (descriptor.value &&
224
+ key === ItemsSym &&
225
+ typeof descriptor.value === "object" &&
226
+ SchemaInit in descriptor.value) {
227
+ (_b = target.constructor)._schema || (_b._schema = {});
228
+ target.constructor._schema[ItemsSym] =
229
+ descriptor.value[SchemaInit];
230
+ init(target);
231
+ return true;
232
+ }
233
+ else {
234
+ return Reflect.defineProperty(target, key, descriptor);
235
+ }
236
+ },
237
+ has(target, key) {
238
+ if (typeof key === "string" && !isNaN(+key)) {
239
+ return Number(key) < target._raw.entries().length;
240
+ }
241
+ else {
242
+ return Reflect.has(target, key);
243
+ }
244
+ },
245
+ };
246
+ //# sourceMappingURL=coList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coList.js","sourceRoot":"","sources":["../../src/coValues/coList.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAcpC,OAAO,EACH,OAAO,EACP,WAAW,EACX,KAAK,EACL,UAAU,EACV,QAAQ,EACR,GAAG,EACH,UAAU,EACV,EAAE,EACF,OAAO,EACP,YAAY,EACZ,QAAQ,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAExD,MAAM,OAAO,MACT,SAAQ,KAAW;IAGnB,MAAM,CAAC,EAAE,CACL,IAAsB;;QAEtB,YAAO,MAAM,QAAS,SAAQ,EAAY;gBAAnC;;oBACH,QAAU,GAAG,IAAI,CAAC;gBACtB,CAAC;aAAA;iBADI,EAAE,CAAC,KAAK;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