@crowdedkingdoms/crowdyjs 17.13.0-dev.1 → 18.0.0-dev.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.
Files changed (284) hide show
  1. package/MIGRATION.md +163 -1
  2. package/README.md +142 -146
  3. package/dist/crowdy-client.d.ts +12 -31
  4. package/dist/crowdy-client.d.ts.map +1 -1
  5. package/dist/crowdy-client.js +15 -37
  6. package/dist/crowdy-dsh/bridge.d.ts.map +1 -1
  7. package/dist/crowdy-dsh/bridge.js +3 -6
  8. package/dist/crowdy-studio/controller.d.ts +59 -57
  9. package/dist/crowdy-studio/controller.d.ts.map +1 -1
  10. package/dist/crowdy-studio/controller.js +268 -206
  11. package/dist/crowdy-studio/diagnostics.d.ts +3 -12
  12. package/dist/crowdy-studio/diagnostics.d.ts.map +1 -1
  13. package/dist/crowdy-studio/dom-shell.d.ts +2 -4
  14. package/dist/crowdy-studio/dom-shell.d.ts.map +1 -1
  15. package/dist/crowdy-studio/dom-shell.js +16 -47
  16. package/dist/crowdy-studio/embed/hud-layer.d.ts +1 -1
  17. package/dist/crowdy-studio/embed/panel.d.ts +3 -12
  18. package/dist/crowdy-studio/embed/panel.d.ts.map +1 -1
  19. package/dist/crowdy-studio/embed/panel.js +3 -6
  20. package/dist/crowdy-studio/index.d.ts +1 -3
  21. package/dist/crowdy-studio/index.d.ts.map +1 -1
  22. package/dist/crowdy-studio/index.js +0 -2
  23. package/dist/crowdy-studio/models.d.ts +3 -4
  24. package/dist/crowdy-studio/models.d.ts.map +1 -1
  25. package/dist/crowdy-studio/starter-projects.d.ts +8 -4
  26. package/dist/crowdy-studio/starter-projects.d.ts.map +1 -1
  27. package/dist/crowdy-studio/starter-projects.js +83 -100
  28. package/dist/domains/appAccess.d.ts +14 -1
  29. package/dist/domains/appAccess.d.ts.map +1 -1
  30. package/dist/domains/appAccess.js +37 -1
  31. package/dist/domains/exec.d.ts +162 -15
  32. package/dist/domains/exec.d.ts.map +1 -1
  33. package/dist/domains/exec.js +180 -18
  34. package/dist/domains/host.d.ts +3 -3
  35. package/dist/domains/host.js +3 -3
  36. package/dist/domains/marketplace.d.ts +9 -58
  37. package/dist/domains/marketplace.d.ts.map +1 -1
  38. package/dist/domains/marketplace.js +9 -106
  39. package/dist/domains/playerWallet.d.ts +6 -12
  40. package/dist/domains/playerWallet.d.ts.map +1 -1
  41. package/dist/domains/playerWallet.js +6 -21
  42. package/dist/errors.d.ts +7 -13
  43. package/dist/errors.d.ts.map +1 -1
  44. package/dist/errors.js +6 -10
  45. package/dist/generated/graphql.d.ts +1384 -7977
  46. package/dist/generated/graphql.d.ts.map +1 -1
  47. package/dist/generated/graphql.js +22 -321
  48. package/dist/grid-mods/exec-client-halves.d.ts +156 -0
  49. package/dist/grid-mods/exec-client-halves.d.ts.map +1 -0
  50. package/dist/grid-mods/exec-client-halves.js +356 -0
  51. package/dist/grid-mods/grid-host-calls.d.ts +29 -15
  52. package/dist/grid-mods/grid-host-calls.d.ts.map +1 -1
  53. package/dist/grid-mods/grid-host-calls.js +40 -44
  54. package/dist/grid-mods/index.d.ts +1 -0
  55. package/dist/grid-mods/index.d.ts.map +1 -1
  56. package/dist/grid-mods/index.js +1 -0
  57. package/dist/grid-mods/mod-runtime.d.ts +21 -6
  58. package/dist/grid-mods/mod-runtime.d.ts.map +1 -1
  59. package/dist/grid-mods/mod-runtime.js +6 -2
  60. package/dist/grid-scope.d.ts +0 -188
  61. package/dist/grid-scope.d.ts.map +1 -1
  62. package/dist/grid-scope.js +0 -69
  63. package/dist/index.d.ts +12 -18
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +11 -16
  66. package/dist/kit/actions.d.ts +5 -9
  67. package/dist/kit/actions.d.ts.map +1 -1
  68. package/dist/kit/actions.js +5 -9
  69. package/dist/kit/index.d.ts +2 -33
  70. package/dist/kit/index.d.ts.map +1 -1
  71. package/dist/kit/index.js +1 -32
  72. package/dist/kit/kit.d.ts +8 -208
  73. package/dist/kit/kit.d.ts.map +1 -1
  74. package/dist/kit/kit.js +5 -163
  75. package/dist/kit/social.d.ts +1 -3
  76. package/dist/kit/social.d.ts.map +1 -1
  77. package/dist/kit/social.js +1 -3
  78. package/dist/kit/wire.d.ts +16 -5
  79. package/dist/kit/wire.d.ts.map +1 -1
  80. package/dist/kit/wire.js +19 -5
  81. package/dist/live-coding/assets/browser-authoring-index.json +1 -1
  82. package/dist/live-coding/assets/manifest.json +1 -1
  83. package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -1
  84. package/dist/live-coding/browser-authoring-index.generated.js +1496 -4386
  85. package/dist/live-coding/rust-analysis.d.ts.map +1 -1
  86. package/dist/live-coding/rust-analysis.js +31 -23
  87. package/dist/player-runtime/client-host-calls.d.ts +8 -0
  88. package/dist/player-runtime/client-host-calls.d.ts.map +1 -0
  89. package/dist/player-runtime/client-host-calls.js +28 -0
  90. package/dist/player-runtime/glue-runtime.d.ts +27 -10
  91. package/dist/player-runtime/glue-runtime.d.ts.map +1 -1
  92. package/dist/player-runtime/glue-runtime.js +40 -45
  93. package/dist/player-runtime/glue-sab.d.ts +2 -2
  94. package/dist/player-runtime/glue-sab.js +2 -2
  95. package/dist/player-runtime/player-code-broker.d.ts +80 -24
  96. package/dist/player-runtime/player-code-broker.d.ts.map +1 -1
  97. package/dist/player-runtime/player-code-broker.js +169 -41
  98. package/dist/player-runtime/player-glue-worker.d.ts +8 -8
  99. package/dist/player-runtime/player-glue-worker.d.ts.map +1 -1
  100. package/dist/player-runtime/player-glue-worker.js +26 -9
  101. package/dist/stores/actors.d.ts +12 -2
  102. package/dist/stores/actors.d.ts.map +1 -1
  103. package/dist/stores/actors.js +43 -18
  104. package/dist/stores/chunks.d.ts +12 -0
  105. package/dist/stores/chunks.d.ts.map +1 -1
  106. package/dist/stores/chunks.js +112 -39
  107. package/dist/stores/durable.d.ts.map +1 -1
  108. package/dist/stores/durable.js +2 -1
  109. package/dist/stores/inbox.d.ts +1 -1
  110. package/dist/stores/inbox.d.ts.map +1 -1
  111. package/dist/stores/index.d.ts +0 -11
  112. package/dist/stores/index.d.ts.map +1 -1
  113. package/dist/stores/index.js +0 -4
  114. package/dist/stores/session.d.ts +0 -2
  115. package/dist/stores/session.d.ts.map +1 -1
  116. package/package.json +1 -1
  117. package/dist/crowdy-studio/model-lint-log.d.ts +0 -76
  118. package/dist/crowdy-studio/model-lint-log.d.ts.map +0 -1
  119. package/dist/crowdy-studio/model-lint-log.js +0 -93
  120. package/dist/crowdy-studio/model-lint.d.ts +0 -61
  121. package/dist/crowdy-studio/model-lint.d.ts.map +0 -1
  122. package/dist/crowdy-studio/model-lint.js +0 -45
  123. package/dist/domains/compute.d.ts +0 -208
  124. package/dist/domains/compute.d.ts.map +0 -1
  125. package/dist/domains/compute.js +0 -274
  126. package/dist/domains/controlPlane.d.ts +0 -38
  127. package/dist/domains/controlPlane.d.ts.map +0 -1
  128. package/dist/domains/controlPlane.js +0 -43
  129. package/dist/domains/gameModel.d.ts +0 -1174
  130. package/dist/domains/gameModel.d.ts.map +0 -1
  131. package/dist/domains/gameModel.js +0 -1333
  132. package/dist/domains/playerCompute.d.ts +0 -91
  133. package/dist/domains/playerCompute.d.ts.map +0 -1
  134. package/dist/domains/playerCompute.js +0 -136
  135. package/dist/domains/playerModel.d.ts +0 -20
  136. package/dist/domains/playerModel.d.ts.map +0 -1
  137. package/dist/domains/playerModel.js +0 -54
  138. package/dist/kit/abilities.d.ts +0 -66
  139. package/dist/kit/abilities.d.ts.map +0 -1
  140. package/dist/kit/abilities.js +0 -71
  141. package/dist/kit/blueprints/combat.d.ts +0 -81
  142. package/dist/kit/blueprints/combat.d.ts.map +0 -1
  143. package/dist/kit/blueprints/combat.js +0 -357
  144. package/dist/kit/blueprints/core.d.ts +0 -222
  145. package/dist/kit/blueprints/core.d.ts.map +0 -1
  146. package/dist/kit/blueprints/core.js +0 -185
  147. package/dist/kit/blueprints/decks.d.ts +0 -50
  148. package/dist/kit/blueprints/decks.d.ts.map +0 -1
  149. package/dist/kit/blueprints/decks.js +0 -163
  150. package/dist/kit/blueprints/economy.d.ts +0 -88
  151. package/dist/kit/blueprints/economy.d.ts.map +0 -1
  152. package/dist/kit/blueprints/economy.js +0 -533
  153. package/dist/kit/blueprints/guild.d.ts +0 -51
  154. package/dist/kit/blueprints/guild.d.ts.map +0 -1
  155. package/dist/kit/blueprints/guild.js +0 -50
  156. package/dist/kit/blueprints/index.d.ts +0 -23
  157. package/dist/kit/blueprints/index.d.ts.map +0 -1
  158. package/dist/kit/blueprints/index.js +0 -22
  159. package/dist/kit/blueprints/inventory.d.ts +0 -84
  160. package/dist/kit/blueprints/inventory.d.ts.map +0 -1
  161. package/dist/kit/blueprints/inventory.js +0 -257
  162. package/dist/kit/blueprints/leaderboards.d.ts +0 -49
  163. package/dist/kit/blueprints/leaderboards.d.ts.map +0 -1
  164. package/dist/kit/blueprints/leaderboards.js +0 -126
  165. package/dist/kit/blueprints/liveops.d.ts +0 -42
  166. package/dist/kit/blueprints/liveops.d.ts.map +0 -1
  167. package/dist/kit/blueprints/liveops.js +0 -170
  168. package/dist/kit/blueprints/locks.d.ts +0 -82
  169. package/dist/kit/blueprints/locks.d.ts.map +0 -1
  170. package/dist/kit/blueprints/locks.js +0 -155
  171. package/dist/kit/blueprints/loot.d.ts +0 -90
  172. package/dist/kit/blueprints/loot.d.ts.map +0 -1
  173. package/dist/kit/blueprints/loot.js +0 -229
  174. package/dist/kit/blueprints/matches.d.ts +0 -84
  175. package/dist/kit/blueprints/matches.d.ts.map +0 -1
  176. package/dist/kit/blueprints/matches.js +0 -349
  177. package/dist/kit/blueprints/moderation.d.ts +0 -32
  178. package/dist/kit/blueprints/moderation.d.ts.map +0 -1
  179. package/dist/kit/blueprints/moderation.js +0 -140
  180. package/dist/kit/blueprints/npcs.d.ts +0 -78
  181. package/dist/kit/blueprints/npcs.d.ts.map +0 -1
  182. package/dist/kit/blueprints/npcs.js +0 -125
  183. package/dist/kit/blueprints/plots.d.ts +0 -63
  184. package/dist/kit/blueprints/plots.d.ts.map +0 -1
  185. package/dist/kit/blueprints/plots.js +0 -151
  186. package/dist/kit/blueprints/progression.d.ts +0 -68
  187. package/dist/kit/blueprints/progression.d.ts.map +0 -1
  188. package/dist/kit/blueprints/progression.js +0 -324
  189. package/dist/kit/blueprints/quests.d.ts +0 -72
  190. package/dist/kit/blueprints/quests.d.ts.map +0 -1
  191. package/dist/kit/blueprints/quests.js +0 -285
  192. package/dist/kit/blueprints/worldsim.d.ts +0 -91
  193. package/dist/kit/blueprints/worldsim.d.ts.map +0 -1
  194. package/dist/kit/blueprints/worldsim.js +0 -468
  195. package/dist/kit/combat.d.ts +0 -141
  196. package/dist/kit/combat.d.ts.map +0 -1
  197. package/dist/kit/combat.js +0 -196
  198. package/dist/kit/decks.d.ts +0 -157
  199. package/dist/kit/decks.d.ts.map +0 -1
  200. package/dist/kit/decks.js +0 -186
  201. package/dist/kit/director.d.ts +0 -88
  202. package/dist/kit/director.d.ts.map +0 -1
  203. package/dist/kit/director.js +0 -86
  204. package/dist/kit/economy.d.ts +0 -289
  205. package/dist/kit/economy.d.ts.map +0 -1
  206. package/dist/kit/economy.js +0 -427
  207. package/dist/kit/engine.d.ts +0 -48
  208. package/dist/kit/engine.d.ts.map +0 -1
  209. package/dist/kit/engine.js +0 -113
  210. package/dist/kit/features.d.ts +0 -60
  211. package/dist/kit/features.d.ts.map +0 -1
  212. package/dist/kit/features.js +0 -65
  213. package/dist/kit/instances.d.ts +0 -52
  214. package/dist/kit/instances.d.ts.map +0 -1
  215. package/dist/kit/instances.js +0 -60
  216. package/dist/kit/inventory.d.ts +0 -129
  217. package/dist/kit/inventory.d.ts.map +0 -1
  218. package/dist/kit/inventory.js +0 -200
  219. package/dist/kit/leaderboards.d.ts +0 -86
  220. package/dist/kit/leaderboards.d.ts.map +0 -1
  221. package/dist/kit/leaderboards.js +0 -133
  222. package/dist/kit/liveops.d.ts +0 -112
  223. package/dist/kit/liveops.d.ts.map +0 -1
  224. package/dist/kit/liveops.js +0 -183
  225. package/dist/kit/loot.d.ts +0 -128
  226. package/dist/kit/loot.d.ts.map +0 -1
  227. package/dist/kit/loot.js +0 -160
  228. package/dist/kit/matches.d.ts +0 -301
  229. package/dist/kit/matches.d.ts.map +0 -1
  230. package/dist/kit/matches.js +0 -458
  231. package/dist/kit/matchmaking.d.ts +0 -57
  232. package/dist/kit/matchmaking.d.ts.map +0 -1
  233. package/dist/kit/matchmaking.js +0 -59
  234. package/dist/kit/minigames.d.ts +0 -30
  235. package/dist/kit/minigames.d.ts.map +0 -1
  236. package/dist/kit/minigames.js +0 -38
  237. package/dist/kit/mobs.d.ts +0 -90
  238. package/dist/kit/mobs.d.ts.map +0 -1
  239. package/dist/kit/mobs.js +0 -98
  240. package/dist/kit/moderation.d.ts +0 -73
  241. package/dist/kit/moderation.d.ts.map +0 -1
  242. package/dist/kit/moderation.js +0 -103
  243. package/dist/kit/movement.d.ts +0 -78
  244. package/dist/kit/movement.d.ts.map +0 -1
  245. package/dist/kit/movement.js +0 -103
  246. package/dist/kit/notifications.d.ts +0 -45
  247. package/dist/kit/notifications.d.ts.map +0 -1
  248. package/dist/kit/notifications.js +0 -67
  249. package/dist/kit/npcs.d.ts +0 -226
  250. package/dist/kit/npcs.d.ts.map +0 -1
  251. package/dist/kit/npcs.js +0 -141
  252. package/dist/kit/objects.d.ts +0 -116
  253. package/dist/kit/objects.d.ts.map +0 -1
  254. package/dist/kit/objects.js +0 -119
  255. package/dist/kit/pets.d.ts +0 -85
  256. package/dist/kit/pets.d.ts.map +0 -1
  257. package/dist/kit/pets.js +0 -96
  258. package/dist/kit/plots.d.ts +0 -85
  259. package/dist/kit/plots.d.ts.map +0 -1
  260. package/dist/kit/plots.js +0 -113
  261. package/dist/kit/progression.d.ts +0 -181
  262. package/dist/kit/progression.d.ts.map +0 -1
  263. package/dist/kit/progression.js +0 -265
  264. package/dist/kit/quests.d.ts +0 -171
  265. package/dist/kit/quests.d.ts.map +0 -1
  266. package/dist/kit/quests.js +0 -237
  267. package/dist/kit/racing.d.ts +0 -85
  268. package/dist/kit/racing.d.ts.map +0 -1
  269. package/dist/kit/racing.js +0 -99
  270. package/dist/kit/shared.d.ts +0 -73
  271. package/dist/kit/shared.d.ts.map +0 -1
  272. package/dist/kit/shared.js +0 -101
  273. package/dist/kit/telemetry.d.ts +0 -66
  274. package/dist/kit/telemetry.d.ts.map +0 -1
  275. package/dist/kit/telemetry.js +0 -133
  276. package/dist/kit/territory.d.ts +0 -97
  277. package/dist/kit/territory.d.ts.map +0 -1
  278. package/dist/kit/territory.js +0 -114
  279. package/dist/kit/worldsim.d.ts +0 -263
  280. package/dist/kit/worldsim.d.ts.map +0 -1
  281. package/dist/kit/worldsim.js +0 -268
  282. package/dist/stores/model.d.ts +0 -81
  283. package/dist/stores/model.d.ts.map +0 -1
  284. package/dist/stores/model.js +0 -163
@@ -1,185 +0,0 @@
1
- /** Serialize a {@link KitInvokePolicy} tree to the wire `invokePolicyJson`. */
2
- export function kitPolicyJson(policy) {
3
- return JSON.stringify(policy);
4
- }
5
- /** Convert `PascalCase`/`camelCase` to `snake_case` for derived names. */
6
- export function toSnakeCase(name) {
7
- return name
8
- .replace(/([a-z0-9])([A-Z])/g, '$1_$2')
9
- .replace(/[\s-]+/g, '_')
10
- .toLowerCase();
11
- }
12
- /**
13
- * Merge blueprints into a single `gameModelSeed` payload plus the automation
14
- * upserts, rejecting duplicate type, property, function, or automation names
15
- * across blueprints (a duplicate almost always means two blueprints need
16
- * distinct prefixes/type names).
17
- */
18
- export function mergeBlueprints(appId, blueprints, options = {}) {
19
- const containerTypes = [];
20
- const propertyDefinitions = [];
21
- const functions = [];
22
- const containers = [];
23
- const edges = [];
24
- const automations = [];
25
- const automationTriggers = [];
26
- const seenTypes = new Map();
27
- const seenProps = new Map();
28
- const seenFunctions = new Map();
29
- const seenAutomations = new Map();
30
- const seenTempIds = new Map();
31
- const claim = (seen, key, blueprintName, kind) => {
32
- const existing = seen.get(key);
33
- if (existing !== undefined) {
34
- throw new Error(`Blueprint '${blueprintName}' redefines ${kind} '${key}' already defined by blueprint '${existing}'`);
35
- }
36
- seen.set(key, blueprintName);
37
- };
38
- for (const blueprint of blueprints) {
39
- for (const type of blueprint.containerTypes ?? []) {
40
- claim(seenTypes, type.typeName, blueprint.name, 'container type');
41
- containerTypes.push(type);
42
- }
43
- for (const prop of blueprint.propertyDefinitions ?? []) {
44
- claim(seenProps, `${prop.containerTypeName}.${prop.key}`, blueprint.name, 'property');
45
- propertyDefinitions.push(prop);
46
- }
47
- for (const fn of blueprint.functions ?? []) {
48
- claim(seenFunctions, fn.name, blueprint.name, 'function');
49
- functions.push(fn);
50
- }
51
- for (const container of blueprint.containers ?? []) {
52
- claim(seenTempIds, container.tempId, blueprint.name, 'container tempId');
53
- containers.push(container);
54
- }
55
- edges.push(...(blueprint.edges ?? []));
56
- for (const automation of blueprint.automations ?? []) {
57
- claim(seenAutomations, automation.name, blueprint.name, 'automation');
58
- automations.push({ ...automation, appId });
59
- }
60
- for (const trigger of blueprint.automationTriggers ?? []) {
61
- automationTriggers.push({ ...trigger, appId });
62
- }
63
- }
64
- const seedInput = {
65
- appId,
66
- ...(options.sessionId !== undefined ? { sessionId: options.sessionId } : {}),
67
- ...(containerTypes.length ? { containerTypes } : {}),
68
- ...(propertyDefinitions.length ? { propertyDefinitions } : {}),
69
- ...(functions.length ? { functions } : {}),
70
- ...(containers.length ? { containers } : {}),
71
- ...(edges.length ? { edges } : {}),
72
- };
73
- return { seedInput, automations, automationTriggers };
74
- }
75
- /**
76
- * Concatenate several blueprints into ONE composite blueprint (a plain
77
- * client-side merge of the definition arrays — no collision checks; those
78
- * happen in {@link mergeBlueprints} at deploy). Used by composite builders
79
- * such as `guildBlueprint` that bundle other builders' output under a single
80
- * name.
81
- */
82
- export function composeBlueprints(name, blueprints) {
83
- const out = { name };
84
- for (const bp of blueprints) {
85
- if (bp.containerTypes?.length) {
86
- out.containerTypes = [...(out.containerTypes ?? []), ...bp.containerTypes];
87
- }
88
- if (bp.propertyDefinitions?.length) {
89
- out.propertyDefinitions = [
90
- ...(out.propertyDefinitions ?? []),
91
- ...bp.propertyDefinitions,
92
- ];
93
- }
94
- if (bp.functions?.length) {
95
- out.functions = [...(out.functions ?? []), ...bp.functions];
96
- }
97
- if (bp.containers?.length) {
98
- out.containers = [...(out.containers ?? []), ...bp.containers];
99
- }
100
- if (bp.edges?.length) {
101
- out.edges = [...(out.edges ?? []), ...bp.edges];
102
- }
103
- if (bp.automations?.length) {
104
- out.automations = [...(out.automations ?? []), ...bp.automations];
105
- }
106
- if (bp.automationTriggers?.length) {
107
- out.automationTriggers = [
108
- ...(out.automationTriggers ?? []),
109
- ...bp.automationTriggers,
110
- ];
111
- }
112
- }
113
- return out;
114
- }
115
- /**
116
- * The function-level fields a {@link KitTrustedAuthority} compiles to.
117
- * `extraCondition` (when given) is AND'ed into the policy.
118
- */
119
- export function trustedAuthorityFields(authority, extraCondition) {
120
- const rule = authority === 'server'
121
- ? { type: 'allow' }
122
- : authority === 'host'
123
- ? { type: 'is_host' }
124
- : authority === 'automation'
125
- ? { type: 'is_automation' }
126
- : authority === 'owner'
127
- ? { type: 'owner_of_self' }
128
- : authority.custom;
129
- const policy = extraCondition
130
- ? { type: 'and', rules: [rule, { type: 'condition', expression: extraCondition }] }
131
- : rule;
132
- return {
133
- invokePolicyJson: kitPolicyJson(policy),
134
- ...(authority === 'server' ? { invokeScope: 'server' } : {}),
135
- ...(authority === 'automation' ? { autonomousInvocable: true } : {}),
136
- };
137
- }
138
- /**
139
- * AND extra policy rules into a base policy (skipping empties) — the
140
- * composition point for `policyExtra` options such as
141
- * `plotBlueprint({ buyPolicyExtra: featureGate('land_owner') })`.
142
- */
143
- export function andPolicies(base, ...extra) {
144
- const extras = extra.filter((r) => r !== undefined);
145
- if (extras.length === 0)
146
- return base;
147
- return { type: 'and', rules: [base, ...extras] };
148
- }
149
- /**
150
- * A `tier_feature` policy leaf: the caller's access tier must hold `feature`
151
- * (defined via `kit.features.define` and granted with
152
- * `kit.features.grantToTier`). Pass it to any builder's `*policyExtra`
153
- * option to monetization-gate that function.
154
- */
155
- export function featureGate(feature) {
156
- return { type: 'tier_feature', feature };
157
- }
158
- /**
159
- * Expression fragment asserting that `ownerExpr` (an `owner_user_id`-style
160
- * property read) equals a user-id expression (usually the injected
161
- * `$caller_user_id` / `$self_owner_id` system params), honoring
162
- * {@link KitOwnerIdKind}.
163
- */
164
- export function ownerEquals(ownerExpr, userExpr, kind = 'int') {
165
- return kind === 'string'
166
- ? `${ownerExpr} == to_string(${userExpr})`
167
- : `${ownerExpr} == ${userExpr}`;
168
- }
169
- /**
170
- * Expression fragment asserting that `ownerExpr` (an `owner_user_id`-style
171
- * property read) equals the calling user, honoring {@link KitOwnerIdKind}.
172
- */
173
- export function ownerEqualsCaller(ownerExpr, kind = 'int') {
174
- return ownerEquals(ownerExpr, '$caller_user_id', kind);
175
- }
176
- /** The `SeedPropertyDefInput` for a kit-standard owner mirror property. */
177
- export function ownerMirrorProperty(containerTypeName, kind = 'int') {
178
- return {
179
- containerTypeName,
180
- key: 'owner_user_id',
181
- valueType: kind,
182
- defaultValueJson: kind === 'string' ? '""' : '0',
183
- description: "Mirror of the container owner's user id (kit convention: expressions cannot read container ownership).",
184
- };
185
- }
@@ -1,50 +0,0 @@
1
- import { type KitBlueprint, type KitOwnerIdKind } from './core.js';
2
- /** Options for {@link decksBlueprint}. */
3
- export interface DecksBlueprintOptions {
4
- /** Prefix for the type/function names. Defaults to none. */
5
- typePrefix?: string;
6
- /**
7
- * Turn-based mode: adds `is_current_turn` to draw/play/discard, so only
8
- * the player whose session turn it is may act. Defaults to false.
9
- */
10
- turnBased?: boolean;
11
- /**
12
- * Fan-out cap of the manual shuffle automation (raise it above your
13
- * largest deck size). Defaults to 200.
14
- */
15
- shuffleMaxTargets?: number;
16
- /** Owner-mirror typing (see the kit convention). Defaults to `'int'`. */
17
- ownerIdKind?: KitOwnerIdKind;
18
- }
19
- /** Names derived by {@link decksBlueprint} for a given prefix. */
20
- export interface DecksNames {
21
- cardDefType: string;
22
- cardType: string;
23
- drawFn: string;
24
- playFn: string;
25
- discardFn: string;
26
- assignPositionFn: string;
27
- shuffleAutomation: string;
28
- }
29
- /** Compute the type/function names a decks blueprint (and its runtime helper) uses. */
30
- export declare function decksNames(typePrefix?: string): DecksNames;
31
- /**
32
- * Blueprint for **cards & hidden information**: an admin `CardDef` catalog
33
- * and session-scoped `CardInstance`s whose `card_id` carries
34
- * **`visibility: "owner"`** — the two-property hidden-info trick: only the
35
- * owner's reads include `card_id`, while the public `revealed_card_id` stays
36
- * empty until the card is played/discarded (the play function copies it in
37
- * the same transaction). Opponents can see a card EXISTS in your hand, not
38
- * what it is — enforced by read filtering, not client discipline.
39
- *
40
- * Shuffling is honest about the platform: expressions can't index arrays, so
41
- * decks are ordered by a `position` int dealt by `assign_position`
42
- * (`rand_int(0, 1000000)` per card) via a **manual, type-fan-out
43
- * automation** — `kit.decks.shuffle()` runs it (admin), and drawing takes
44
- * the owner's lowest-position deck card ("top of deck"; the runtime picks
45
- * it, the server enforces the zone transition and ownership).
46
- *
47
- * Runtime counterpart: `client.kit(appId).decks`.
48
- */
49
- export declare function decksBlueprint(options?: DecksBlueprintOptions): KitBlueprint;
50
- //# sourceMappingURL=decks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decks.d.ts","sourceRoot":"","sources":["../../../src/kit/blueprints/decks.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,KAAK,YAAY,EAEjB,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AAEnB,0CAA0C;AAC1C,MAAM,WAAW,qBAAqB;IACpC,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yEAAyE;IACzE,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B;AAED,kEAAkE;AAClE,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,uFAAuF;AACvF,wBAAgB,UAAU,CAAC,UAAU,SAAK,GAAG,UAAU,CAWtD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,YAAY,CAoJhF"}
@@ -1,163 +0,0 @@
1
- import { kitPolicyJson, ownerMirrorProperty, toSnakeCase, } from './core.js';
2
- /** Compute the type/function names a decks blueprint (and its runtime helper) uses. */
3
- export function decksNames(typePrefix = '') {
4
- const fnPrefix = typePrefix ? `${toSnakeCase(typePrefix)}_` : '';
5
- return {
6
- cardDefType: `${typePrefix}CardDef`,
7
- cardType: `${typePrefix}CardInstance`,
8
- drawFn: `${fnPrefix}draw_card`,
9
- playFn: `${fnPrefix}play_card`,
10
- discardFn: `${fnPrefix}discard_card`,
11
- assignPositionFn: `${fnPrefix}assign_position`,
12
- shuffleAutomation: `${fnPrefix.replace(/_/g, '-')}deck-shuffle`,
13
- };
14
- }
15
- /**
16
- * Blueprint for **cards & hidden information**: an admin `CardDef` catalog
17
- * and session-scoped `CardInstance`s whose `card_id` carries
18
- * **`visibility: "owner"`** — the two-property hidden-info trick: only the
19
- * owner's reads include `card_id`, while the public `revealed_card_id` stays
20
- * empty until the card is played/discarded (the play function copies it in
21
- * the same transaction). Opponents can see a card EXISTS in your hand, not
22
- * what it is — enforced by read filtering, not client discipline.
23
- *
24
- * Shuffling is honest about the platform: expressions can't index arrays, so
25
- * decks are ordered by a `position` int dealt by `assign_position`
26
- * (`rand_int(0, 1000000)` per card) via a **manual, type-fan-out
27
- * automation** — `kit.decks.shuffle()` runs it (admin), and drawing takes
28
- * the owner's lowest-position deck card ("top of deck"; the runtime picks
29
- * it, the server enforces the zone transition and ownership).
30
- *
31
- * Runtime counterpart: `client.kit(appId).decks`.
32
- */
33
- export function decksBlueprint(options = {}) {
34
- const { typePrefix = '', turnBased = false, shuffleMaxTargets = 200, ownerIdKind: kind = 'int', } = options;
35
- const names = decksNames(typePrefix);
36
- const playerPolicy = (condition) => {
37
- const rules = [
38
- { type: 'owner_of_self' },
39
- ...(turnBased ? [{ type: 'is_current_turn' }] : []),
40
- { type: 'condition', expression: condition },
41
- ];
42
- return kitPolicyJson({ type: 'and', rules });
43
- };
44
- const propertyDefinitions = [
45
- {
46
- containerTypeName: names.cardDefType,
47
- key: 'card_id',
48
- valueType: 'string',
49
- description: 'Stable card identifier (rules data lives on the def).',
50
- },
51
- ownerMirrorProperty(names.cardType, kind),
52
- {
53
- containerTypeName: names.cardType,
54
- key: 'card_id',
55
- valueType: 'string',
56
- defaultValueJson: '""',
57
- visibility: 'owner',
58
- description: "WHICH card this is — owner-visible only (the hidden-information half of the two-property trick); opponents' reads omit it.",
59
- },
60
- {
61
- containerTypeName: names.cardType,
62
- key: 'revealed_card_id',
63
- valueType: 'string',
64
- defaultValueJson: '""',
65
- description: 'The public half: empty while the card hides in deck/hand, copied from card_id when played or discarded.',
66
- },
67
- {
68
- containerTypeName: names.cardType,
69
- key: 'zone',
70
- valueType: 'string',
71
- defaultValueJson: '"deck"',
72
- description: "Card zone: 'deck' | 'hand' | 'board' | 'discard'.",
73
- },
74
- {
75
- containerTypeName: names.cardType,
76
- key: 'position',
77
- valueType: 'int',
78
- defaultValueJson: '0',
79
- description: 'Deck order (lowest = top), dealt by the shuffle automation via rand_int.',
80
- },
81
- ];
82
- const functions = [
83
- {
84
- name: names.drawFn,
85
- containerTypeName: names.cardType,
86
- returnType: 'string',
87
- mutations: [{ target: 'self', property: 'zone', expression: '"hand"' }],
88
- returnExpression: 'self.zone',
89
- invokePolicyJson: playerPolicy('self.zone == "deck"'),
90
- description: 'Draw a card you own from your deck into your hand (the runtime picks the lowest-position deck card — "top of deck"); card_id stays owner-visible.',
91
- },
92
- {
93
- name: names.playFn,
94
- containerTypeName: names.cardType,
95
- returnType: 'string',
96
- mutations: [
97
- { target: 'self', property: 'zone', expression: '"board"' },
98
- { target: 'self', property: 'revealed_card_id', expression: 'self.card_id' },
99
- ],
100
- returnExpression: 'self.revealed_card_id',
101
- invokePolicyJson: playerPolicy('self.zone == "hand"'),
102
- description: 'Play a card from your hand: the zone flip AND the public reveal (revealed_card_id = card_id) commit together.',
103
- },
104
- {
105
- name: names.discardFn,
106
- containerTypeName: names.cardType,
107
- returnType: 'string',
108
- mutations: [
109
- { target: 'self', property: 'zone', expression: '"discard"' },
110
- { target: 'self', property: 'revealed_card_id', expression: 'self.card_id' },
111
- ],
112
- returnExpression: 'self.revealed_card_id',
113
- invokePolicyJson: playerPolicy('self.zone == "hand" || self.zone == "board"'),
114
- description: 'Discard a card face-up (discard piles are public information).',
115
- },
116
- {
117
- name: names.assignPositionFn,
118
- containerTypeName: names.cardType,
119
- returnType: 'int',
120
- mutations: [
121
- { target: 'self', property: 'position', expression: 'rand_int(0, 1000000)' },
122
- ],
123
- returnExpression: 'self.position',
124
- invokePolicyJson: kitPolicyJson({ type: 'is_automation' }),
125
- autonomousInvocable: true,
126
- description: 'Shuffle step (automation-only): deals this card a random deck position — the supported server-side shuffle pattern (expressions cannot permute arrays).',
127
- },
128
- ];
129
- const automations = [
130
- {
131
- name: names.shuffleAutomation,
132
- functionName: names.assignPositionFn,
133
- targetMode: 'type',
134
- targetTypeName: names.cardType,
135
- triggerType: 'manual',
136
- maxTargets: shuffleMaxTargets,
137
- selectorJson: JSON.stringify({
138
- selfWhere: [{ key: 'zone', op: '==', value: 'deck' }],
139
- }),
140
- description: 'Manual shuffle: fans assign_position out over every deck-zone card (run via gameModelRunAutomation / kit.decks.shuffle).',
141
- },
142
- ];
143
- return {
144
- name: names.cardType,
145
- containerTypes: [
146
- {
147
- typeName: names.cardDefType,
148
- displayName: names.cardDefType,
149
- instantiableBy: 'admin',
150
- description: 'Studio card catalog row.',
151
- },
152
- {
153
- typeName: names.cardType,
154
- displayName: names.cardType,
155
- instantiableBy: 'member',
156
- description: 'One card in play: hidden while in deck/hand (owner-visible card_id), public once revealed.',
157
- },
158
- ],
159
- propertyDefinitions,
160
- functions,
161
- automations,
162
- };
163
- }
@@ -1,88 +0,0 @@
1
- import { type KitBlueprint, type KitOwnerIdKind, type KitTrustedAuthority } from './core.js';
2
- /** Options for {@link economyBlueprint}. */
3
- export interface EconomyBlueprintOptions {
4
- /**
5
- * Prefix applied to the container type names (`'Black'` → `BlackWallet` /
6
- * `BlackShopListing` / …) and, snake-cased, to the function names
7
- * (`black_earn_gold`, …). Lets several economies coexist. Defaults to none.
8
- */
9
- typePrefix?: string;
10
- /**
11
- * Currency property names on the wallet, one int property (default 0) per
12
- * entry, each with `earn_<c>` / `spend_<c>` functions. Defaults to
13
- * `['gold']`.
14
- */
15
- currencies?: string[];
16
- /**
17
- * The wallet currency shops and market listings are priced in. Defaults to
18
- * the first entry of `currencies`. (Expressions cannot pick a wallet
19
- * property dynamically, so one deployment trades in one currency; deploy a
20
- * prefixed second blueprint for a second shop currency.)
21
- */
22
- shopCurrency?: string;
23
- /**
24
- * Who may mint currency via `earn_<c>`. Trusted grants should be `'server'`
25
- * (app admins / studio backend, the default), `'host'`, or
26
- * `'automation'` — never plain players. Defaults to `'server'`.
27
- */
28
- earnAuthority?: KitTrustedAuthority;
29
- /**
30
- * How `owner_user_id` mirrors are typed on the stack containers this
31
- * economy guards (see the kit owner-mirroring convention). Defaults to
32
- * `'int'` (the kit standard).
33
- */
34
- ownerIdKind?: KitOwnerIdKind;
35
- /**
36
- * When set, adds a `restock_listing` automation that periodically raises
37
- * every listing's `stock` (by `amount`, clamped to `max_stock`) — the NPC
38
- * trader restock pattern.
39
- */
40
- restock?: {
41
- intervalMs: number;
42
- amount?: number;
43
- };
44
- }
45
- /** Names derived by {@link economyBlueprint} for a given prefix. */
46
- export interface EconomyNames {
47
- walletType: string;
48
- listingType: string;
49
- tradeType: string;
50
- marketType: string;
51
- /** Snake-cased function-name prefix (empty without a `typePrefix`). */
52
- fnPrefix: string;
53
- buyListingFn: string;
54
- acceptTradeFn: string;
55
- cancelTradeFn: string;
56
- buyMarketFn: string;
57
- cancelMarketFn: string;
58
- restockFn: string;
59
- restockAutomation: string;
60
- }
61
- /** Compute the type/function names an economy blueprint (and its runtime helper) uses. */
62
- export declare function economyNames(typePrefix?: string): EconomyNames;
63
- /** The earn/spend function name for one currency. */
64
- export declare function economyCurrencyFn(verb: 'earn' | 'spend', currency: string, typePrefix?: string): string;
65
- /**
66
- * Blueprint for a server-authoritative **economy**: per-player `Wallet`
67
- * containers (one int property per currency), an admin `ShopListing` catalog
68
- * with an atomic `buy_listing` (wallet debit + stock decrement + item grant
69
- * in ONE invoke), escrow `TradeOffer` swaps, and a player-to-player
70
- * `MarketListing` flow (buyer wallet → seller wallet + stack transfer, all
71
- * in one transaction).
72
- *
73
- * Anti-duplication is structural: every movement of currency or items is a
74
- * single function invocation whose condition guards check balances, stock,
75
- * item identity, and ownership mirrors server-side — never split a spend and
76
- * a grant across two invokes. Trusted mints (`earn_<c>`) default to
77
- * `invokeScope: "server"` (app admins only).
78
- *
79
- * Trade/market guards verify stack ownership through the kit-standard
80
- * `owner_user_id` mirror property on the stack type (the inventory blueprint
81
- * defines it; set it via `InventoryKit.createStack({ ownerUserId })`), and
82
- * pin the offer creator via the injected `$self_owner_id` — the server-truth
83
- * owner of the offer/listing container.
84
- *
85
- * Runtime counterpart: `client.kit(appId).economy`.
86
- */
87
- export declare function economyBlueprint(options?: EconomyBlueprintOptions): KitBlueprint;
88
- //# sourceMappingURL=economy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"economy.d.ts","sourceRoot":"","sources":["../../../src/kit/blueprints/economy.ts"],"names":[],"mappings":"AAIA,OAAO,EAQL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACzB,MAAM,WAAW,CAAC;AAEnB,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC;;;;OAIG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B;;;;OAIG;IACH,OAAO,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACnD;AAED,oEAAoE;AACpE,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,0FAA0F;AAC1F,wBAAgB,YAAY,CAAC,UAAU,SAAK,GAAG,YAAY,CAgB1D;AAED,qDAAqD;AACrD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,GAAG,OAAO,EACtB,QAAQ,EAAE,MAAM,EAChB,UAAU,SAAK,GACd,MAAM,CAGR;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,uBAA4B,GACpC,YAAY,CAyfd"}