@dcl-regenesislabs/sdk-commands 0.0.0-stage → 7.0.0-42707159203.commit-ff138cd

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 (250) hide show
  1. package/.dclrc +19 -0
  2. package/LICENSE +201 -0
  3. package/README.md +106 -2
  4. package/dist/commands/build/index.d.ts +23 -0
  5. package/dist/commands/build/index.js +80 -0
  6. package/dist/commands/build/index.js.map +1 -0
  7. package/dist/commands/code-to-composite/asset-migrator.d.ts +25 -0
  8. package/dist/commands/code-to-composite/asset-migrator.js +238 -0
  9. package/dist/commands/code-to-composite/asset-migrator.js.map +1 -0
  10. package/dist/commands/code-to-composite/code-commenter.d.ts +11 -0
  11. package/dist/commands/code-to-composite/code-commenter.js +87 -0
  12. package/dist/commands/code-to-composite/code-commenter.js.map +1 -0
  13. package/dist/commands/code-to-composite/composite-generator.d.ts +6 -0
  14. package/dist/commands/code-to-composite/composite-generator.js +65 -0
  15. package/dist/commands/code-to-composite/composite-generator.js.map +1 -0
  16. package/dist/commands/code-to-composite/index.d.ts +16 -0
  17. package/dist/commands/code-to-composite/index.js +130 -0
  18. package/dist/commands/code-to-composite/index.js.map +1 -0
  19. package/dist/commands/code-to-composite/name-generator.d.ts +9 -0
  20. package/dist/commands/code-to-composite/name-generator.js +139 -0
  21. package/dist/commands/code-to-composite/name-generator.js.map +1 -0
  22. package/dist/commands/code-to-composite/scene-executor.d.ts +15 -0
  23. package/dist/commands/code-to-composite/scene-executor.js +421 -0
  24. package/dist/commands/code-to-composite/scene-executor.js.map +1 -0
  25. package/dist/commands/deploy/analytics-features.d.ts +4 -0
  26. package/dist/commands/deploy/analytics-features.js +11 -0
  27. package/dist/commands/deploy/analytics-features.js.map +1 -0
  28. package/dist/commands/deploy/deployment.d.ts +51 -0
  29. package/dist/commands/deploy/deployment.js +122 -0
  30. package/dist/commands/deploy/deployment.js.map +1 -0
  31. package/dist/commands/deploy/index.d.ts +37 -0
  32. package/dist/commands/deploy/index.js +312 -0
  33. package/dist/commands/deploy/index.js.map +1 -0
  34. package/dist/commands/deploy/routes.d.ts +27 -0
  35. package/dist/commands/deploy/routes.js +144 -0
  36. package/dist/commands/deploy/routes.js.map +1 -0
  37. package/dist/commands/deploy/state.d.ts +60 -0
  38. package/dist/commands/deploy/state.js +144 -0
  39. package/dist/commands/deploy/state.js.map +1 -0
  40. package/dist/commands/deploy/upload.d.ts +23 -0
  41. package/dist/commands/deploy/upload.js +120 -0
  42. package/dist/commands/deploy/upload.js.map +1 -0
  43. package/dist/commands/deploy/utils.d.ts +131 -0
  44. package/dist/commands/deploy/utils.js +432 -0
  45. package/dist/commands/deploy/utils.js.map +1 -0
  46. package/dist/commands/export-static/index.d.ts +27 -0
  47. package/dist/commands/export-static/index.js +155 -0
  48. package/dist/commands/export-static/index.js.map +1 -0
  49. package/dist/commands/get-context-files/index.d.ts +12 -0
  50. package/dist/commands/get-context-files/index.js +119 -0
  51. package/dist/commands/get-context-files/index.js.map +1 -0
  52. package/dist/commands/init/download-github-folder.d.ts +2 -0
  53. package/dist/commands/init/download-github-folder.js +69 -0
  54. package/dist/commands/init/download-github-folder.js.map +1 -0
  55. package/dist/commands/init/index.d.ts +18 -0
  56. package/dist/commands/init/index.js +98 -0
  57. package/dist/commands/init/index.js.map +1 -0
  58. package/dist/commands/init/project.d.ts +7 -0
  59. package/dist/commands/init/project.js +36 -0
  60. package/dist/commands/init/project.js.map +1 -0
  61. package/dist/commands/init/repos.d.ts +4 -0
  62. package/dist/commands/init/repos.js +21 -0
  63. package/dist/commands/init/repos.js.map +1 -0
  64. package/dist/commands/pack-smart-wearable/index.d.ts +16 -0
  65. package/dist/commands/pack-smart-wearable/index.js +108 -0
  66. package/dist/commands/pack-smart-wearable/index.js.map +1 -0
  67. package/dist/commands/quests/index.d.ts +28 -0
  68. package/dist/commands/quests/index.js +271 -0
  69. package/dist/commands/quests/index.js.map +1 -0
  70. package/dist/commands/quests/types.d.ts +41 -0
  71. package/dist/commands/quests/types.js +3 -0
  72. package/dist/commands/quests/types.js.map +1 -0
  73. package/dist/commands/quests/utils.d.ts +20 -0
  74. package/dist/commands/quests/utils.js +253 -0
  75. package/dist/commands/quests/utils.js.map +1 -0
  76. package/dist/commands/start/data-layer/fs.d.ts +8 -0
  77. package/dist/commands/start/data-layer/fs.js +73 -0
  78. package/dist/commands/start/data-layer/fs.js.map +1 -0
  79. package/dist/commands/start/data-layer/rpc.d.ts +8 -0
  80. package/dist/commands/start/data-layer/rpc.js +54 -0
  81. package/dist/commands/start/data-layer/rpc.js.map +1 -0
  82. package/dist/commands/start/data-layer/ws.d.ts +4 -0
  83. package/dist/commands/start/data-layer/ws.js +17 -0
  84. package/dist/commands/start/data-layer/ws.js.map +1 -0
  85. package/dist/commands/start/explorer-alpha.d.ts +19 -0
  86. package/dist/commands/start/explorer-alpha.js +109 -0
  87. package/dist/commands/start/explorer-alpha.js.map +1 -0
  88. package/dist/commands/start/index.d.ts +46 -0
  89. package/dist/commands/start/index.js +300 -0
  90. package/dist/commands/start/index.js.map +1 -0
  91. package/dist/commands/start/server/endpoints.d.ts +5 -0
  92. package/dist/commands/start/server/endpoints.js +417 -0
  93. package/dist/commands/start/server/endpoints.js.map +1 -0
  94. package/dist/commands/start/server/file-watch-notifier.d.ts +12 -0
  95. package/dist/commands/start/server/file-watch-notifier.js +96 -0
  96. package/dist/commands/start/server/file-watch-notifier.js.map +1 -0
  97. package/dist/commands/start/server/realm.d.ts +7 -0
  98. package/dist/commands/start/server/realm.js +58 -0
  99. package/dist/commands/start/server/realm.js.map +1 -0
  100. package/dist/commands/start/server/routes.d.ts +6 -0
  101. package/dist/commands/start/server/routes.js +77 -0
  102. package/dist/commands/start/server/routes.js.map +1 -0
  103. package/dist/commands/start/server/ws.d.ts +11 -0
  104. package/dist/commands/start/server/ws.js +19 -0
  105. package/dist/commands/start/server/ws.js.map +1 -0
  106. package/dist/commands/start/types.d.ts +16 -0
  107. package/dist/commands/start/types.js +3 -0
  108. package/dist/commands/start/types.js.map +1 -0
  109. package/dist/commands/start/utils.d.ts +8 -0
  110. package/dist/commands/start/utils.js +57 -0
  111. package/dist/commands/start/utils.js.map +1 -0
  112. package/dist/components/analytics.d.ts +105 -0
  113. package/dist/components/analytics.js +76 -0
  114. package/dist/components/analytics.js.map +1 -0
  115. package/dist/components/config.d.ts +18 -0
  116. package/dist/components/config.js +58 -0
  117. package/dist/components/config.js.map +1 -0
  118. package/dist/components/eth.d.ts +2 -0
  119. package/dist/components/eth.js +6 -0
  120. package/dist/components/eth.js.map +1 -0
  121. package/dist/components/exit-signal.d.ts +5 -0
  122. package/dist/components/exit-signal.js +21 -0
  123. package/dist/components/exit-signal.js.map +1 -0
  124. package/dist/components/fetch.d.ts +6 -0
  125. package/dist/components/fetch.js +9 -0
  126. package/dist/components/fetch.js.map +1 -0
  127. package/dist/components/fs.d.ts +18 -0
  128. package/dist/components/fs.js +85 -0
  129. package/dist/components/fs.js.map +1 -0
  130. package/dist/components/index.d.ts +14 -0
  131. package/dist/components/index.js +25 -0
  132. package/dist/components/index.js.map +1 -0
  133. package/dist/components/log.d.ts +24 -0
  134. package/dist/components/log.js +67 -0
  135. package/dist/components/log.js.map +1 -0
  136. package/dist/generated/decentraland/common/border_rect.gen.d.ts +49 -0
  137. package/dist/generated/decentraland/common/border_rect.gen.js +199 -0
  138. package/dist/generated/decentraland/common/border_rect.gen.js.map +1 -0
  139. package/dist/generated/decentraland/common/vectors.gen.d.ts +71 -0
  140. package/dist/generated/decentraland/common/vectors.gen.js +334 -0
  141. package/dist/generated/decentraland/common/vectors.gen.js.map +1 -0
  142. package/dist/generated/decentraland/realm/about.gen.d.ts +229 -0
  143. package/dist/generated/decentraland/realm/about.gen.js +1175 -0
  144. package/dist/generated/decentraland/realm/about.gen.js.map +1 -0
  145. package/dist/generated/decentraland/sdk/development/local_development.gen.d.ts +70 -0
  146. package/dist/generated/decentraland/sdk/development/local_development.gen.js +278 -0
  147. package/dist/generated/decentraland/sdk/development/local_development.gen.js.map +1 -0
  148. package/dist/index.d.ts +2 -0
  149. package/dist/index.js +37 -0
  150. package/dist/index.js.map +1 -0
  151. package/dist/linker-dapp/routes.d.ts +32 -0
  152. package/dist/linker-dapp/routes.js +140 -0
  153. package/dist/linker-dapp/routes.js.map +1 -0
  154. package/dist/locales/en.json +84 -0
  155. package/dist/locales/es.json +84 -0
  156. package/dist/locales/zh.json +84 -0
  157. package/dist/logic/account.d.ts +6 -0
  158. package/dist/logic/account.js +25 -0
  159. package/dist/logic/account.js.map +1 -0
  160. package/dist/logic/args.d.ts +6 -0
  161. package/dist/logic/args.js +25 -0
  162. package/dist/logic/args.js.map +1 -0
  163. package/dist/logic/beautiful-logs.d.ts +14 -0
  164. package/dist/logic/beautiful-logs.js +55 -0
  165. package/dist/logic/beautiful-logs.js.map +1 -0
  166. package/dist/logic/bundle.d.ts +47 -0
  167. package/dist/logic/bundle.js +573 -0
  168. package/dist/logic/bundle.js.map +1 -0
  169. package/dist/logic/catalyst-requests.d.ts +20 -0
  170. package/dist/logic/catalyst-requests.js +54 -0
  171. package/dist/logic/catalyst-requests.js.map +1 -0
  172. package/dist/logic/commands.d.ts +3 -0
  173. package/dist/logic/commands.js +30 -0
  174. package/dist/logic/commands.js.map +1 -0
  175. package/dist/logic/composite.d.ts +15 -0
  176. package/dist/logic/composite.js +105 -0
  177. package/dist/logic/composite.js.map +1 -0
  178. package/dist/logic/config.d.ts +24 -0
  179. package/dist/logic/config.js +88 -0
  180. package/dist/logic/config.js.map +1 -0
  181. package/dist/logic/coordinates.d.ts +14 -0
  182. package/dist/logic/coordinates.js +31 -0
  183. package/dist/logic/coordinates.js.map +1 -0
  184. package/dist/logic/dcl-ignore.d.ts +8 -0
  185. package/dist/logic/dcl-ignore.js +53 -0
  186. package/dist/logic/dcl-ignore.js.map +1 -0
  187. package/dist/logic/debounce.d.ts +1 -0
  188. package/dist/logic/debounce.js +11 -0
  189. package/dist/logic/debounce.js.map +1 -0
  190. package/dist/logic/error.d.ts +7 -0
  191. package/dist/logic/error.js +13 -0
  192. package/dist/logic/error.js.map +1 -0
  193. package/dist/logic/exec.d.ts +12 -0
  194. package/dist/logic/exec.js +40 -0
  195. package/dist/logic/exec.js.map +1 -0
  196. package/dist/logic/fetch.d.ts +25 -0
  197. package/dist/logic/fetch.js +42 -0
  198. package/dist/logic/fetch.js.map +1 -0
  199. package/dist/logic/fs.d.ts +33 -0
  200. package/dist/logic/fs.js +57 -0
  201. package/dist/logic/fs.js.map +1 -0
  202. package/dist/logic/future.d.ts +6 -0
  203. package/dist/logic/future.js +14 -0
  204. package/dist/logic/future.js.map +1 -0
  205. package/dist/logic/get-free-port.d.ts +1 -0
  206. package/dist/logic/get-free-port.js +70 -0
  207. package/dist/logic/get-free-port.js.map +1 -0
  208. package/dist/logic/lang.d.ts +7 -0
  209. package/dist/logic/lang.js +41 -0
  210. package/dist/logic/lang.js.map +1 -0
  211. package/dist/logic/open.d.ts +1 -0
  212. package/dist/logic/open.js +41 -0
  213. package/dist/logic/open.js.map +1 -0
  214. package/dist/logic/portable-experience-sw-validations.d.ts +18 -0
  215. package/dist/logic/portable-experience-sw-validations.js +48 -0
  216. package/dist/logic/portable-experience-sw-validations.js.map +1 -0
  217. package/dist/logic/project-files.d.ts +40 -0
  218. package/dist/logic/project-files.js +158 -0
  219. package/dist/logic/project-files.js.map +1 -0
  220. package/dist/logic/project-validations.d.ts +45 -0
  221. package/dist/logic/project-validations.js +143 -0
  222. package/dist/logic/project-validations.js.map +1 -0
  223. package/dist/logic/promise-utils.d.ts +1 -0
  224. package/dist/logic/promise-utils.js +20 -0
  225. package/dist/logic/promise-utils.js.map +1 -0
  226. package/dist/logic/prompts.d.ts +23 -0
  227. package/dist/logic/prompts.js +74 -0
  228. package/dist/logic/prompts.js.map +1 -0
  229. package/dist/logic/realm.d.ts +3 -0
  230. package/dist/logic/realm.js +32 -0
  231. package/dist/logic/realm.js.map +1 -0
  232. package/dist/logic/runtime-script.d.ts +42 -0
  233. package/dist/logic/runtime-script.js +217 -0
  234. package/dist/logic/runtime-script.js.map +1 -0
  235. package/dist/logic/runtime-script.ts +270 -0
  236. package/dist/logic/scene-validations.d.ts +35 -0
  237. package/dist/logic/scene-validations.js +135 -0
  238. package/dist/logic/scene-validations.js.map +1 -0
  239. package/dist/logic/script-module.d.ts.template +87 -0
  240. package/dist/logic/workspace-validations.d.ts +27 -0
  241. package/dist/logic/workspace-validations.js +136 -0
  242. package/dist/logic/workspace-validations.js.map +1 -0
  243. package/dist/run-command.d.ts +7 -0
  244. package/dist/run-command.js +95 -0
  245. package/dist/run-command.js.map +1 -0
  246. package/dist/run-dapp.d.ts +23 -0
  247. package/dist/run-dapp.js +66 -0
  248. package/dist/run-dapp.js.map +1 -0
  249. package/package.json +74 -3
  250. package/scripts/postinstall.js +17 -0
@@ -0,0 +1,417 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.setupEcs6Endpoints = setupEcs6Endpoints;
37
+ const path = __importStar(require("path"));
38
+ const stream_1 = require("stream");
39
+ const sdk_1 = require("@dcl/schemas/dist/sdk");
40
+ const schemas_1 = require("@dcl/schemas");
41
+ const crypto_1 = require("crypto");
42
+ const catalyst_requests_1 = require("../../../logic/catalyst-requests");
43
+ const project_files_1 = require("../../../logic/project-files");
44
+ const config_1 = require("../../../logic/config");
45
+ async function setupEcs6Endpoints(components, router, workspace) {
46
+ const catalystUrl = new URL(await (0, config_1.getCatalystBaseUrl)(components));
47
+ // handle old preview scene.json DEPRECATED
48
+ router.get('/scene.json', async () => {
49
+ return {
50
+ headers: { 'content-type': 'application/json' },
51
+ body: components.fs.createReadStream(path.join(workspace.projects[0].workingDirectory, 'scene.json'))
52
+ };
53
+ });
54
+ router.get('/lambdas/explore/realms', async (ctx) => {
55
+ return {
56
+ body: [
57
+ {
58
+ serverName: 'localhost',
59
+ url: `http://${ctx.url.host}`,
60
+ layer: 'stub',
61
+ usersCount: 0,
62
+ maxUsers: 100,
63
+ userParcels: []
64
+ }
65
+ ]
66
+ };
67
+ });
68
+ router.get('/lambdas/contracts/servers', async (ctx) => {
69
+ return {
70
+ body: [
71
+ {
72
+ address: `http://${ctx.url.host}`,
73
+ owner: '0x0000000000000000000000000000000000000000',
74
+ id: '0x0000000000000000000000000000000000000000000000000000000000000000'
75
+ }
76
+ ]
77
+ };
78
+ });
79
+ router.get('/lambdas/profiles', async (ctx, next) => {
80
+ const baseUrl = `${ctx.url.protocol}//${ctx.url.host}/content/contents`;
81
+ try {
82
+ const previewWearables = await getAllPreviewWearables(components, workspace, {
83
+ baseUrl
84
+ });
85
+ if (previewWearables.length === 1) {
86
+ const u = new URL(ctx.url.toString());
87
+ u.host = catalystUrl.host;
88
+ u.protocol = catalystUrl.protocol;
89
+ u.port = catalystUrl.port;
90
+ const req = await components.fetch.fetch(u.toString(), {
91
+ headers: {
92
+ connection: 'close'
93
+ },
94
+ method: ctx.request.method,
95
+ body: ctx.request.method === 'get' ? undefined : ctx.request.body,
96
+ duplex: 'half'
97
+ });
98
+ const deployedProfile = (await req.json());
99
+ if (deployedProfile?.length === 1) {
100
+ deployedProfile[0].avatars[0].avatar.wearables.push(...previewWearables.map(($) => $.id));
101
+ return {
102
+ headers: {
103
+ 'content-type': req.headers.get('content-type') || 'application/binary'
104
+ },
105
+ body: deployedProfile
106
+ };
107
+ }
108
+ }
109
+ }
110
+ catch (err) {
111
+ components.logger.warn(`Failed to catch profile and fill with preview wearables.`);
112
+ components.logger.error(err);
113
+ }
114
+ return next();
115
+ });
116
+ router.all('/lambdas/:path+', async (ctx) => {
117
+ const u = new URL(ctx.url.toString());
118
+ u.host = catalystUrl.host;
119
+ u.protocol = catalystUrl.protocol;
120
+ u.port = catalystUrl.port;
121
+ const req = await components.fetch.fetch(u.toString(), {
122
+ headers: {
123
+ connection: 'close'
124
+ },
125
+ method: ctx.request.method,
126
+ body: ctx.request.method === 'get' ? undefined : ctx.request.body,
127
+ duplex: 'half'
128
+ });
129
+ return {
130
+ headers: {
131
+ 'content-type': req.headers.get('content-type') || 'application/binary'
132
+ },
133
+ // `req.body` is a web ReadableStream; convert it to a Node stream so the
134
+ // http-server can pipe it (it only handles Node streams / Buffers / strings).
135
+ body: req.body ? stream_1.Readable.fromWeb(req.body) : undefined
136
+ };
137
+ });
138
+ router.post('/content/entities', async (ctx) => {
139
+ const res = await components.fetch.fetch(`${catalystUrl.toString()}/content/entities`, {
140
+ method: 'post',
141
+ body: ctx.request.body,
142
+ duplex: 'half'
143
+ });
144
+ // undici decompresses the body but leaves the original content-encoding /
145
+ // content-length headers in place; forwarding them would make the client
146
+ // re-decode (or truncate to the compressed length) the already-decoded body.
147
+ // fetch() responses carry immutable Headers, so filter instead of delete.
148
+ const headers = Object.fromEntries(res.headers);
149
+ delete headers['content-encoding'];
150
+ delete headers['content-length'];
151
+ return {
152
+ status: res.status,
153
+ headers,
154
+ body: res.body ? stream_1.Readable.fromWeb(res.body) : undefined
155
+ };
156
+ });
157
+ router.all('/explorer/:path+', async (ctx) => {
158
+ const u = new URL(ctx.url.toString());
159
+ u.host = catalystUrl.host;
160
+ u.protocol = catalystUrl.protocol;
161
+ u.port = catalystUrl.port;
162
+ const req = await components.fetch.fetch(u.toString(), {
163
+ headers: { connection: 'close' },
164
+ method: ctx.request.method,
165
+ body: ctx.request.method === 'get' ? undefined : ctx.request.body,
166
+ duplex: 'half'
167
+ });
168
+ return {
169
+ headers: {
170
+ 'content-type': req.headers.get('content-type') || 'application/json'
171
+ },
172
+ // `req.body` is a web ReadableStream; convert it to a Node stream so the
173
+ // http-server can pipe it (it only handles Node streams / Buffers / strings).
174
+ body: req.body ? stream_1.Readable.fromWeb(req.body) : undefined
175
+ };
176
+ });
177
+ router.get('/feature-flags/:file', async (ctx) => {
178
+ const res = await components.fetch.fetch(`https://feature-flags.decentraland.zone/${ctx.params.file}`, {
179
+ headers: {
180
+ connection: 'close'
181
+ }
182
+ });
183
+ return {
184
+ body: await res.arrayBuffer()
185
+ };
186
+ });
187
+ // TODO: get workspace scenes & wearables...
188
+ await serveFolders(components, router, workspace);
189
+ }
190
+ async function serveFolders(components, router, workspace) {
191
+ const catalystUrl = await (0, config_1.getCatalystBaseUrl)(components);
192
+ router.get('/content/contents/:hash', async (ctx, next) => {
193
+ if (ctx.params.hash && ctx.params.hash.startsWith('b64-')) {
194
+ // Strips the machineId suffix that was added during encoding and, for content-versioned
195
+ // ids, the embedded mtime — the server always serves the file's current bytes.
196
+ const fullPath = path.resolve((0, project_files_1.b64HashDecodingFunction)(ctx.params.hash));
197
+ // find a project that we are talking about. NOTE: this filter is not exhaustive
198
+ // relative paths should be used instead
199
+ const baseProject = workspace.projects.find((project) => fullPath.startsWith(project.workingDirectory));
200
+ // only return files IF the file is within a baseFolder
201
+ if (!baseProject) {
202
+ return next();
203
+ }
204
+ if (path.resolve(fullPath) === path.resolve(baseProject.workingDirectory)) {
205
+ // if we are talking about the root directory, then we must return the json of the entity
206
+ const entity = await fakeEntityV3FromProject(components, baseProject, previewHashingFunction(components, baseProject));
207
+ if (!entity)
208
+ return { status: 404 };
209
+ return {
210
+ headers: {
211
+ 'x-timestamp': Date.now().toString(),
212
+ 'x-sent': 'true',
213
+ 'cache-control': 'no-cache,private,max-age=1'
214
+ },
215
+ body: entity
216
+ };
217
+ }
218
+ if (!(await components.fs.fileExists(fullPath)))
219
+ return { status: 404 };
220
+ if (await components.fs.directoryExists(fullPath))
221
+ return { status: 404 };
222
+ return {
223
+ headers: {
224
+ 'x-timestamp': Date.now().toString(),
225
+ 'x-sent': 'true',
226
+ 'cache-control': 'no-cache,private,max-age=1'
227
+ },
228
+ body: components.fs.createReadStream(fullPath)
229
+ };
230
+ }
231
+ return next();
232
+ });
233
+ async function pointerRequestHandler(pointers) {
234
+ if (!pointers || pointers.length === 0) {
235
+ return [];
236
+ }
237
+ const requestedPointers = new Set(pointers && typeof pointers === 'string' ? [pointers] : pointers);
238
+ const resultEntities = await getSceneJson(components, workspace, Array.from(requestedPointers));
239
+ const remote = await (0, catalyst_requests_1.fetchEntityByPointer)(components, catalystUrl.toString(), pointers.filter(($) => !$.match(/-?\d+,-?\d+/)));
240
+ const serverEntities = Array.isArray(remote.deployments) ? remote.deployments : [];
241
+ return [...resultEntities, ...serverEntities];
242
+ }
243
+ // REVIEW RESPONSE FORMAT
244
+ router.get('/content/entities/scene', async (ctx) => {
245
+ return {
246
+ body: await pointerRequestHandler(ctx.url.searchParams.getAll('pointer'))
247
+ };
248
+ });
249
+ // REVIEW RESPONSE FORMAT
250
+ router.post('/content/entities/active', async (ctx) => {
251
+ const body = await ctx.request.json();
252
+ return {
253
+ body: await pointerRequestHandler(body.pointers)
254
+ };
255
+ });
256
+ router.get('/preview-wearables/:id', async (ctx) => {
257
+ const baseUrl = `${ctx.url.protocol}//${ctx.url.host}/content/contents`;
258
+ const wearables = await getAllPreviewWearables(components, workspace, {
259
+ baseUrl
260
+ });
261
+ const wearableId = ctx.params.id;
262
+ return {
263
+ body: {
264
+ ok: true,
265
+ data: wearables.filter((wearable) => wearable.id === wearableCache.get(wearableId))
266
+ }
267
+ };
268
+ });
269
+ router.get('/preview-wearables', async (ctx) => {
270
+ const baseUrl = `${ctx.url.protocol}//${ctx.url.host}/content/contents`;
271
+ return {
272
+ body: {
273
+ ok: true,
274
+ data: await getAllPreviewWearables(components, workspace, { baseUrl })
275
+ }
276
+ };
277
+ });
278
+ }
279
+ async function getAllPreviewWearables(components, workspace, { baseUrl }) {
280
+ // NOTE: the explorers should use the /entities/active endpoint to retrieve the wearables. This endpoint should be removed
281
+ const wearablePathArray = [];
282
+ for (const project of workspace.projects) {
283
+ if (project.kind === 'smart-wearable') {
284
+ const wearableJsonPath = path.resolve(project.workingDirectory, 'wearable.json');
285
+ if (await components.fs.fileExists(wearableJsonPath)) {
286
+ wearablePathArray.push(wearableJsonPath);
287
+ }
288
+ }
289
+ }
290
+ const ret = [];
291
+ for (const project of workspace.projects) {
292
+ try {
293
+ if (project.kind === 'smart-wearable')
294
+ ret.push(await serveWearable(components, project, baseUrl));
295
+ }
296
+ catch (err) {
297
+ components.logger.error(`Couldn't mock the wearable ${project.workingDirectory}. Please verify the correct format and scheme.` + err);
298
+ }
299
+ }
300
+ return ret;
301
+ }
302
+ const wearableCache = new Map();
303
+ async function serveWearable(components, project, baseUrl) {
304
+ const wearableJsonPath = path.join(project.workingDirectory, 'wearable.json');
305
+ const wearableJson = JSON.parse((await components.fs.readFile(wearableJsonPath)).toString());
306
+ if (!sdk_1.WearableJson.validate(wearableJson)) {
307
+ const errors = (sdk_1.WearableJson.validate.errors || []).map((a) => `${a.data} ${a.message}`).join('');
308
+ components.logger.error(`Unable to validate wearable.json properly, please check it.` + errors);
309
+ throw new Error(`Invalid wearable.json (${wearableJsonPath})`);
310
+ }
311
+ const projectFiles = await (0, project_files_1.getProjectPublishableFilesWithHashes)(components, project.workingDirectory, async ($) => (0, project_files_1.b64HashingFunction)($));
312
+ const contentFiles = (0, project_files_1.projectFilesToContentMappings)(project.workingDirectory, projectFiles);
313
+ const thumbnailFiltered = contentFiles.filter(($) => $.file === 'thumbnail.png');
314
+ const thumbnail = thumbnailFiltered.length > 0 && thumbnailFiltered[0].hash && `${baseUrl}/${thumbnailFiltered[0].hash}`;
315
+ // Set wearable ID.
316
+ const sceneHash = (0, project_files_1.b64HashingFunction)(project.workingDirectory);
317
+ const wearableId = wearableCache.get(sceneHash) ?? `urn:${(0, crypto_1.randomUUID)()}`;
318
+ wearableCache.set(sceneHash, wearableId);
319
+ const representations = wearableJson.data.representations.map((representation) => ({
320
+ ...representation,
321
+ mainFile: `male/${representation.mainFile}`,
322
+ contents: contentFiles.map(($) => ({
323
+ key: `male/${$?.file}`,
324
+ url: `${baseUrl}/${$?.hash}`,
325
+ hash: $?.hash
326
+ }))
327
+ }));
328
+ return {
329
+ id: wearableId,
330
+ rarity: wearableJson.rarity,
331
+ i18n: [{ code: 'en', text: wearableJson.name }],
332
+ description: wearableJson.description,
333
+ thumbnail: thumbnail || '',
334
+ image: thumbnail || '',
335
+ collectionAddress: '0x0',
336
+ baseUrl: `${baseUrl}/`,
337
+ name: wearableJson.name || '',
338
+ data: {
339
+ category: wearableJson.data.category,
340
+ replaces: [],
341
+ hides: [],
342
+ tags: [],
343
+ representations: representations
344
+ // scene: hashedFiles as any,
345
+ }
346
+ };
347
+ }
348
+ async function getSceneJson(components, workspace, pointers) {
349
+ const requestedPointers = new Set(pointers);
350
+ const resultEntities = [];
351
+ const allDeployments = await Promise.all(workspace.projects.map((project) => fakeEntityV3FromProject(components, project, previewHashingFunction(components, project))));
352
+ // Walk projects in workspace order; when parcels overlap, the first project wins.
353
+ // Claimed pointers are removed so later projects are only emitted for parcels they still own.
354
+ for (const deployment of allDeployments) {
355
+ if (deployment && deployment.pointers.some((p) => requestedPointers.has(p))) {
356
+ deployment.pointers.forEach((p) => requestedPointers.delete(p));
357
+ resultEntities.push(deployment);
358
+ }
359
+ }
360
+ return resultEntities;
361
+ }
362
+ // Preview ids for a project's files embed each file's mtime, so the id — and every client cache
363
+ // key derived from it — changes whenever the file changes. The project directory's own id (the
364
+ // scene/entity id) stays path-only: the scene identity must be stable across edits.
365
+ function previewHashingFunction(components, project) {
366
+ return async (filePath) => filePath === project.workingDirectory
367
+ ? (0, project_files_1.b64HashingFunction)(filePath)
368
+ : (0, project_files_1.b64ContentVersionedHashingFunction)(filePath, (await components.fs.stat(filePath)).mtimeMs);
369
+ }
370
+ async function fakeEntityV3FromProject(components, project, hashingFunction) {
371
+ const projectFiles = await (0, project_files_1.getProjectPublishableFilesWithHashes)(components, project.workingDirectory, hashingFunction);
372
+ const contentFiles = (0, project_files_1.projectFilesToContentMappings)(project.workingDirectory, projectFiles);
373
+ if (project.kind === 'scene') {
374
+ const sceneJsonPath = path.resolve(project.workingDirectory, 'scene.json');
375
+ const sdkVersion = await (0, config_1.getInstalledPackageVersion)(components, '@dcl/sdk', project.workingDirectory);
376
+ const sceneJson = { sdkVersion, ...JSON.parse(await components.fs.readFile(sceneJsonPath, 'utf-8')) };
377
+ const { base, parcels } = sceneJson.scene;
378
+ const pointers = new Set();
379
+ pointers.add(base);
380
+ parcels.forEach(($) => pointers.add($));
381
+ return {
382
+ version: 'v3',
383
+ type: schemas_1.EntityType.SCENE,
384
+ id: await hashingFunction(project.workingDirectory),
385
+ pointers: Array.from(pointers),
386
+ timestamp: Date.now(),
387
+ metadata: sceneJson,
388
+ content: contentFiles
389
+ };
390
+ }
391
+ else if (project.kind === 'smart-wearable') {
392
+ const wearableJsonPath = path.resolve(project.workingDirectory, 'wearable.json');
393
+ try {
394
+ const wearableJson = JSON.parse(await components.fs.readFile(wearableJsonPath, 'utf-8'));
395
+ if (!sdk_1.WearableJson.validate(wearableJson)) {
396
+ const errors = (sdk_1.WearableJson.validate.errors || []).map((a) => `${a.data} ${a.message}`).join('');
397
+ components.logger.error(`Unable to validate wearable.json properly, please check its schema.` + errors);
398
+ components.logger.error(`Invalid wearable.json (${wearableJsonPath})`);
399
+ }
400
+ return {
401
+ version: 'v3',
402
+ type: schemas_1.EntityType.WEARABLE,
403
+ id: await hashingFunction(project.workingDirectory),
404
+ pointers: Array.from([await hashingFunction(project.workingDirectory)]),
405
+ timestamp: Date.now(),
406
+ metadata: wearableJson,
407
+ content: contentFiles
408
+ };
409
+ }
410
+ catch (err) {
411
+ components.logger.error(`Unable to load wearable.json`);
412
+ components.logger.error(err);
413
+ }
414
+ }
415
+ return null;
416
+ }
417
+ //# sourceMappingURL=endpoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.js","sourceRoot":"","sources":["../../../../src/commands/start/server/endpoints.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,gDAsKC;AA9LD,2CAA4B;AAC5B,mCAAiC;AACjC,+CAAoD;AACpD,0CAAmE;AACnE,mCAAmC;AAGnC,wEAAuE;AAEvE,gEAMqC;AACrC,kDAAsF;AAQ/E,KAAK,UAAU,kBAAkB,CACtC,UAAyB,EACzB,MAAiC,EACjC,SAAoB;IAEpB,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,IAAA,2BAAkB,EAAC,UAAU,CAAC,CAAC,CAAA;IAEjE,2CAA2C;IAC3C,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;QACnC,OAAO;YACL,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;SACtG,CAAA;IACH,CAAC,CAAC,CAAA;IAE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'ws';
2
+ import { PreviewComponents } from '../types';
3
+ import { ProjectUnion } from '../../../logic/project-validations';
4
+ /**
5
+ * This function gets file modification events and sends them to all the connected
6
+ * websockets, it is used to hot-reload assets of the scene.
7
+ */
8
+ export declare function wireFileWatcherToWebSockets(components: Pick<PreviewComponents, 'fs' | 'ws' | 'logger'>, projectRoot: string, projectKind: ProjectUnion['kind']): Promise<void>;
9
+ /**
10
+ * @deprecated legacy JSON protocol, consumed by Bevy and Godot explorers
11
+ */
12
+ export declare function __LEGACY__updateScene(dir: string, clients: Set<WebSocket>, projectKind: ProjectUnion['kind']): void;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.wireFileWatcherToWebSockets = wireFileWatcherToWebSockets;
7
+ exports.__LEGACY__updateScene = __LEGACY__updateScene;
8
+ const schemas_1 = require("@dcl/schemas");
9
+ const path_1 = __importDefault(require("path"));
10
+ const ws_1 = require("ws");
11
+ const chokidar_1 = __importDefault(require("chokidar"));
12
+ const dcl_ignore_1 = require("../../../logic/dcl-ignore");
13
+ const routes_1 = require("./routes");
14
+ const project_files_1 = require("../../../logic/project-files");
15
+ const local_development_gen_1 = require("../../../generated/decentraland/sdk/development/local_development.gen");
16
+ const debounce_1 = require("../../../logic/debounce");
17
+ /**
18
+ * This function gets file modification events and sends them to all the connected
19
+ * websockets, it is used to hot-reload assets of the scene.
20
+ */
21
+ async function wireFileWatcherToWebSockets(components, projectRoot, projectKind) {
22
+ const ignored = await (0, dcl_ignore_1.getDCLIgnorePatterns)(components, projectRoot);
23
+ const sceneId = (0, project_files_1.b64HashingFunction)(projectRoot);
24
+ chokidar_1.default
25
+ .watch(path_1.default.resolve(projectRoot), {
26
+ atomic: false,
27
+ ignored,
28
+ ignoreInitial: false,
29
+ cwd: projectRoot
30
+ })
31
+ .on('unlink', (file) => {
32
+ removeModel(sceneId, file);
33
+ })
34
+ .on('all', (0, debounce_1.debounce)(async (_, file) => {
35
+ updateScene(sceneId, file);
36
+ // Legacy JSON protocol: still the only one Bevy and Godot explorers understand.
37
+ // Remove once both consume the protobuf WsSceneMessage.
38
+ __LEGACY__updateScene(projectRoot, routes_1.sceneUpdateClients, projectKind);
39
+ }, 800));
40
+ }
41
+ function isGLTFModel(file) {
42
+ if (!file)
43
+ return false;
44
+ return file.toLowerCase().endsWith('.glb') || file.toLowerCase().endsWith('.gltf');
45
+ }
46
+ function updateScene(sceneId, file) {
47
+ let message;
48
+ if (isGLTFModel(file)) {
49
+ message = {
50
+ $case: 'updateModel',
51
+ updateModel: { hash: (0, project_files_1.b64HashingFunction)(file), sceneId, src: file, type: local_development_gen_1.UpdateModelType.UMT_CHANGE }
52
+ };
53
+ }
54
+ else {
55
+ message = {
56
+ $case: 'updateScene',
57
+ updateScene: { sceneId }
58
+ };
59
+ }
60
+ sendSceneMessage({ message });
61
+ }
62
+ function removeModel(sceneId, file) {
63
+ if (isGLTFModel(file)) {
64
+ const sceneMessage = {
65
+ message: {
66
+ $case: 'updateModel',
67
+ updateModel: { sceneId, src: file, hash: (0, project_files_1.b64HashingFunction)(file), type: local_development_gen_1.UpdateModelType.UMT_REMOVE }
68
+ }
69
+ };
70
+ sendSceneMessage(sceneMessage);
71
+ }
72
+ }
73
+ function sendSceneMessage(sceneMessage) {
74
+ const message = local_development_gen_1.WsSceneMessage.encode(sceneMessage).finish();
75
+ for (const client of routes_1.sceneUpdateClients) {
76
+ if (client.readyState === ws_1.WebSocket.OPEN) {
77
+ client.send(message, { binary: true });
78
+ }
79
+ }
80
+ }
81
+ /**
82
+ * @deprecated legacy JSON protocol, consumed by Bevy and Godot explorers
83
+ */
84
+ function __LEGACY__updateScene(dir, clients, projectKind) {
85
+ for (const client of clients) {
86
+ if (client.readyState === ws_1.WebSocket.OPEN) {
87
+ const message = {
88
+ type: schemas_1.sdk.SCENE_UPDATE,
89
+ payload: { sceneId: (0, project_files_1.b64HashingFunction)(dir), sceneType: projectKind }
90
+ };
91
+ client.send(schemas_1.sdk.UPDATE, { binary: false });
92
+ client.send(JSON.stringify(message), { binary: false });
93
+ }
94
+ }
95
+ }
96
+ //# sourceMappingURL=file-watch-notifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-watch-notifier.js","sourceRoot":"","sources":["../../../../src/commands/start/server/file-watch-notifier.ts"],"names":[],"mappings":";;;;;AAmBA,kEA2BC;AAgDD,sDAYC;AA1GD,0CAAkC;AAClC,gDAAuB;AACvB,2BAA8B;AAC9B,wDAA+B;AAC/B,0DAAgE;AAEhE,qCAA6C;AAE7C,gEAAiE;AACjE,iHAG8E;AAC9E,sDAAkD;AAElD;;;GAGG;AACI,KAAK,UAAU,2BAA2B,CAC/C,UAA2D,EAC3D,WAAmB,EACnB,WAAiC;IAEjC,MAAM,OAAO,GAAG,MAAM,IAAA,iCAAoB,EAAC,UAAU,EAAE,WAAW,CAAC,CAAA;IACnE,MAAM,OAAO,GAAG,IAAA,kCAAkB,EAAC,WAAW,CAAC,CAAA;IAE/C,kBAAQ;SACL,KAAK,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QAChC,MAAM,EAAE,KAAK;QACb,OAAO;QACP,aAAa,EAAE,KAAK;QACpB,GAAG,EAAE,WAAW;KACjB,CAAC;SACD,EAAE,CAAC,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAE;QAC7B,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAC5B,CAAC,CAAC;SACD,EAAE,CACD,KAAK,EACL,IAAA,mBAAQ,EAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;QACzB,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAC1B,gFAAgF;QAChF,wDAAwD;QACxD,qBAAqB,CAAC,WAAW,EAAE,2BAAkB,EAAE,WAAW,CAAC,CAAA;IACrE,CAAC,EAAE,GAA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AAC,MAAM,EAAE,CAAA;IAC5D,KAAK,MAAM,MAAM,IAAI,2BAAkB,EAAE,CAAC;QACxC,IAAI,MAAM,CAAC,UAAU,KAAK,cAAS,CAAC,IAAI,EAAE,CAAC;YACzC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;QACxC,CAAC;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CAAC,GAAW,EAAE,OAAuB,EAAE,WAAiC;IAC3G,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,UAAU,KAAK,cAAS,CAAC,IAAI,EAAE,CAAC;YACzC,MAAM,OAAO,GAAoB;gBAC/B,IAAI,EAAE,aAAG,CAAC,YAAY;gBACtB,OAAO,EAAE,EAAE,OAAO,EAAE,IAAA,kCAAkB,EAAC,GAAG,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE;aACtE,CAAA;YAED,MAAM,CAAC,IAAI,CAAC,aAAG,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;YAC1C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;QACzD,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { PreviewComponents } from '../types';
2
+ import { Router } from '@well-known-components/http-server';
3
+ /**
4
+ * This module handles the BFF mock and communications server for the preview mode.
5
+ * It runs using @dcl/mini-comms implementing RFC-5
6
+ */
7
+ export declare function setupRealmAndComms(components: PreviewComponents, router: Router<PreviewComponents>, localSceneParcels?: string[]): void;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupRealmAndComms = setupRealmAndComms;
4
+ const handle_linear_protocol_1 = require("@dcl/mini-comms/dist/logic/handle-linear-protocol");
5
+ const ws_1 = require("@well-known-components/http-server/dist/ws");
6
+ /**
7
+ * This module handles the BFF mock and communications server for the preview mode.
8
+ * It runs using @dcl/mini-comms implementing RFC-5
9
+ */
10
+ function setupRealmAndComms(components, router, localSceneParcels = []) {
11
+ router.get('/about', async (ctx) => {
12
+ const host = ctx.url.host;
13
+ const body = {
14
+ acceptingUsers: true,
15
+ bff: { healthy: false, publicUrl: host },
16
+ comms: {
17
+ healthy: true,
18
+ protocol: 'v3',
19
+ fixedAdapter: `ws-room:${ctx.url.protocol.replace(/^http/, 'ws')}//${host}/mini-comms/room-1`
20
+ },
21
+ configurations: {
22
+ networkId: 0,
23
+ globalScenesUrn: [],
24
+ localSceneParcels,
25
+ scenesUrn: [],
26
+ realmName: 'LocalPreview'
27
+ },
28
+ content: {
29
+ healthy: true,
30
+ publicUrl: `${ctx.url.protocol}//${ctx.url.host}/content`
31
+ },
32
+ lambdas: {
33
+ healthy: true,
34
+ publicUrl: `${ctx.url.protocol}//${ctx.url.host}/lambdas`
35
+ },
36
+ healthy: true
37
+ };
38
+ return { body };
39
+ });
40
+ router.get('/mini-comms/:roomId', async (ctx) => {
41
+ return (0, ws_1.upgradeWebSocketResponse)((ws) => {
42
+ if (ws.protocol === 'rfc5' || ws.protocol === 'rfc4') {
43
+ ws.on('error', (error) => {
44
+ components.logger.error(error);
45
+ ws.close();
46
+ });
47
+ ws.on('close', () => {
48
+ components.logger.debug('Websocket closed');
49
+ });
50
+ (0, handle_linear_protocol_1.handleSocketLinearProtocol)(components, ws, ctx.params.roomId).catch((err) => {
51
+ components.logger.info(err);
52
+ ws.close();
53
+ });
54
+ }
55
+ });
56
+ });
57
+ }
58
+ //# sourceMappingURL=realm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"realm.js","sourceRoot":"","sources":["../../../../src/commands/start/server/realm.ts"],"names":[],"mappings":";;AAWA,gDAwDC;AAnED,8FAA8F;AAI9F,mEAAqF;AAErF;;;GAGG;AAEH,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AAQ,KAAK,MAAM,EAAE,CAAC;gBACrD,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAU,EAAE,EAAE;oBAC5B,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;oBAC9B,EAAE,CAAC,KAAK,EAAE,CAAA;gBACZ,CAAC,CAAC,CAAA;gBAEF,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;oBAClB,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;gBAC7C,CAAC,CAAC,CAAA;gBAEF,IAAA,mDAA0B,EAAC,UAAU,EAAE,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,GAAQ,EAAE,EAAE;oBAC/E,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;oBAC3B,EAAE,CAAC,KAAK,EAAE,CAAA;gBACZ,CAAC,CAAC,CAAA;YACJ,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { WebSocket } from 'ws';
2
+ import { Workspace } from '../../../logic/workspace-validations';
3
+ import { DataLayer } from '../data-layer/rpc';
4
+ import { PreviewComponents } from '../types';
5
+ export declare const sceneUpdateClients: Set<WebSocket>;
6
+ export declare function wireRouter(components: PreviewComponents, workspace: Workspace, dataLayer?: DataLayer): Promise<void>;