@asapjs/socket 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/.pnp.cjs +12184 -0
  2. package/.vscode/extensions.json +5 -0
  3. package/.vscode/settings.json +8 -0
  4. package/.yarn/cache/@asapjs-core-npm-0.0.9-12cd56a7e9-ef1ef42553.zip +0 -0
  5. package/.yarn/cache/@colors-colors-npm-1.5.0-875af3a8b4-d64d5260be.zip +0 -0
  6. package/.yarn/cache/@dabh-diagnostics-npm-2.0.3-0f2cd64f24-4879600c55.zip +0 -0
  7. package/.yarn/cache/@socket.io-component-emitter-npm-3.1.0-3f778351c2-db069d9542.zip +0 -0
  8. package/.yarn/cache/@types-body-parser-npm-1.19.2-f845b7b538-e17840c7d7.zip +0 -0
  9. package/.yarn/cache/@types-connect-npm-3.4.35-7337eee0a3-fe81351470.zip +0 -0
  10. package/.yarn/cache/@types-cookie-npm-0.4.1-274a704dc6-3275534ed6.zip +0 -0
  11. package/.yarn/cache/@types-cors-npm-2.8.13-4b8ac1068f-7ef197ea19.zip +0 -0
  12. package/.yarn/cache/@types-debug-npm-4.1.7-f54c81f8db-0a7b89d8ed.zip +0 -0
  13. package/.yarn/cache/@types-express-npm-4.17.13-0e12fe9c24-12a2a0e6c4.zip +0 -0
  14. package/.yarn/cache/@types-express-serve-static-core-npm-4.17.28-608d4aa166-826489811a.zip +0 -0
  15. package/.yarn/cache/@types-mime-npm-1.3.2-ea71878ab3-0493368244.zip +0 -0
  16. package/.yarn/cache/@types-ms-npm-0.7.31-ea3b89342b-daadd354ae.zip +0 -0
  17. package/.yarn/cache/@types-node-npm-17.0.23-167849e796-a351755473.zip +0 -0
  18. package/.yarn/cache/@types-node-npm-18.11.17-897ad73ae4-1933afd068.zip +0 -0
  19. package/.yarn/cache/@types-qs-npm-6.9.7-4a3e6ca0d0-7fd6f9c250.zip +0 -0
  20. package/.yarn/cache/@types-range-parser-npm-1.2.4-23d797fbde-b7c0dfd508.zip +0 -0
  21. package/.yarn/cache/@types-serve-static-npm-1.13.10-5434e2c519-eaca858739.zip +0 -0
  22. package/.yarn/cache/@types-validator-npm-13.7.2-a51e56b9bb-e679261dd5.zip +0 -0
  23. package/.yarn/cache/accepts-npm-1.3.8-9a812371c9-50c43d32e7.zip +0 -0
  24. package/.yarn/cache/array-flatten-npm-1.1.1-9d94ad5f1d-a9925bf351.zip +0 -0
  25. package/.yarn/cache/async-npm-3.2.3-e9d6b79c88-c4bee57ab2.zip +0 -0
  26. package/.yarn/cache/balanced-match-npm-1.0.2-a53c126459-9706c088a2.zip +0 -0
  27. package/.yarn/cache/base64id-npm-2.0.0-ef4afeee0a-581b1d37e6.zip +0 -0
  28. package/.yarn/cache/body-parser-npm-1.19.2-33c5bfcb21-7f777ea656.zip +0 -0
  29. package/.yarn/cache/body-parser-npm-1.20.0-1820eff49a-12fffdeac8.zip +0 -0
  30. package/.yarn/cache/brace-expansion-npm-1.1.11-fb95eb05ad-faf34a7bb0.zip +0 -0
  31. package/.yarn/cache/bytes-npm-3.1.2-28b8643004-e4bcd3948d.zip +0 -0
  32. package/.yarn/cache/call-bind-npm-1.0.2-c957124861-f8e31de9d1.zip +0 -0
  33. package/.yarn/cache/color-convert-npm-1.9.3-1fe690075e-fd7a64a17c.zip +0 -0
  34. package/.yarn/cache/color-name-npm-1.1.3-728b7b5d39-09c5d3e33d.zip +0 -0
  35. package/.yarn/cache/color-name-npm-1.1.4-025792b0ea-b044585952.zip +0 -0
  36. package/.yarn/cache/color-npm-3.2.1-568cf1014f-f81220e8b7.zip +0 -0
  37. package/.yarn/cache/color-string-npm-1.9.0-75382c0441-93c6678b84.zip +0 -0
  38. package/.yarn/cache/colorspace-npm-1.1.4-f01655548a-bb3934ef3c.zip +0 -0
  39. package/.yarn/cache/concat-map-npm-0.0.1-85a921b7ee-902a9f5d89.zip +0 -0
  40. package/.yarn/cache/content-disposition-npm-0.5.4-2d93678616-afb9d545e2.zip +0 -0
  41. package/.yarn/cache/content-type-npm-1.0.4-3b1a5ca16b-3d93585fda.zip +0 -0
  42. package/.yarn/cache/cookie-npm-0.4.2-7761894d5f-a00833c998.zip +0 -0
  43. package/.yarn/cache/cookie-signature-npm-1.0.6-93f325f7f0-f4e1b0a98a.zip +0 -0
  44. package/.yarn/cache/cors-npm-2.8.5-c9935a2d12-ced838404c.zip +0 -0
  45. package/.yarn/cache/debug-npm-2.6.9-7d4cb597dc-d2f51589ca.zip +0 -0
  46. package/.yarn/cache/debug-npm-4.3.4-4513954577-3dbad3f94e.zip +0 -0
  47. package/.yarn/cache/depd-npm-1.1.2-b0c8414da7-6b406620d2.zip +0 -0
  48. package/.yarn/cache/depd-npm-2.0.0-b6c51a4b43-abbe19c768.zip +0 -0
  49. package/.yarn/cache/destroy-npm-1.0.4-a2203e01cb-da9ab4961d.zip +0 -0
  50. package/.yarn/cache/destroy-npm-1.2.0-6a511802e2-0acb300b74.zip +0 -0
  51. package/.yarn/cache/dottie-npm-2.0.2-ef16765a8f-046a581803.zip +0 -0
  52. package/.yarn/cache/ee-first-npm-1.1.1-33f8535b39-1b4cac778d.zip +0 -0
  53. package/.yarn/cache/enabled-npm-2.0.0-bf5d96c9d8-9d256d89f4.zip +0 -0
  54. package/.yarn/cache/encodeurl-npm-1.0.2-f8c8454c41-e50e3d508c.zip +0 -0
  55. package/.yarn/cache/engine.io-npm-6.2.1-1486b58c4b-626d7a77f2.zip +0 -0
  56. package/.yarn/cache/engine.io-parser-npm-5.0.4-27a510b395-d4ad0cef6f.zip +0 -0
  57. package/.yarn/cache/escape-html-npm-1.0.3-376c22ee74-6213ca9ae0.zip +0 -0
  58. package/.yarn/cache/etag-npm-1.8.1-54a3b989d9-571aeb3dbe.zip +0 -0
  59. package/.yarn/cache/express-npm-4.17.3-889f836f0d-967e53b74a.zip +0 -0
  60. package/.yarn/cache/fecha-npm-4.2.1-40d84f7733-2699347494.zip +0 -0
  61. package/.yarn/cache/finalhandler-npm-1.1.2-55a75d6b53-617880460c.zip +0 -0
  62. package/.yarn/cache/fn.name-npm-1.1.0-b472333184-e357144f48.zip +0 -0
  63. package/.yarn/cache/forwarded-npm-0.2.0-6473dabe35-fd27e2394d.zip +0 -0
  64. package/.yarn/cache/fresh-npm-0.5.2-ad2bb4c0a2-13ea8b08f9.zip +0 -0
  65. package/.yarn/cache/fs-npm-0.0.1-security-5060b47e87-53c6230e1f.zip +0 -0
  66. package/.yarn/cache/fs.realpath-npm-1.0.0-c8f05d8126-99ddea01a7.zip +0 -0
  67. package/.yarn/cache/function-bind-npm-1.1.1-b56b322ae9-b32fbaebb3.zip +0 -0
  68. package/.yarn/cache/get-intrinsic-npm-1.1.1-7e868745da-a9fe2ca8fa.zip +0 -0
  69. package/.yarn/cache/glob-npm-7.2.0-bb4644d239-78a8ea9423.zip +0 -0
  70. package/.yarn/cache/has-npm-1.0.3-b7f00631c1-b9ad53d53b.zip +0 -0
  71. package/.yarn/cache/has-symbols-npm-1.0.3-1986bff2c4-a054c40c63.zip +0 -0
  72. package/.yarn/cache/http-errors-npm-1.8.1-fb60d9f6ae-d3c7e7e776.zip +0 -0
  73. package/.yarn/cache/http-errors-npm-2.0.0-3f1c503428-9b0a378266.zip +0 -0
  74. package/.yarn/cache/http-npm-0.0.1-security-62a9711fac-c45a4e2771.zip +0 -0
  75. package/.yarn/cache/iconv-lite-npm-0.4.24-c5c4ac6695-bd9f120f5a.zip +0 -0
  76. package/.yarn/cache/inflection-npm-1.13.2-85fd80437c-e7ad055938.zip +0 -0
  77. package/.yarn/cache/inflight-npm-1.0.6-ccedb4b908-f4f76aa072.zip +0 -0
  78. package/.yarn/cache/inherits-npm-2.0.4-c66b3957a0-4a48a73384.zip +0 -0
  79. package/.yarn/cache/ipaddr.js-npm-1.9.1-19ae7878b4-f88d382598.zip +0 -0
  80. package/.yarn/cache/is-arrayish-npm-0.3.2-f856180f79-977e64f54d.zip +0 -0
  81. package/.yarn/cache/is-stream-npm-2.0.1-c802db55e7-b8e05ccdf9.zip +0 -0
  82. package/.yarn/cache/jwt-simple-npm-0.5.6-85a0092e17-fa10ffd655.zip +0 -0
  83. package/.yarn/cache/kuler-npm-2.0.0-19e74c9695-9e10b5a165.zip +0 -0
  84. package/.yarn/cache/lodash-npm-4.17.21-6382451519-eb835a2e51.zip +0 -0
  85. package/.yarn/cache/logform-npm-2.4.0-8b1d55d47a-e75ccccc1a.zip +0 -0
  86. package/.yarn/cache/lru-cache-npm-7.8.0-b7fa238db4-7cc046276b.zip +0 -0
  87. package/.yarn/cache/media-typer-npm-0.3.0-8674f8f0f5-af1b38516c.zip +0 -0
  88. package/.yarn/cache/merge-descriptors-npm-1.0.1-615287aaa8-5abc259d2a.zip +0 -0
  89. package/.yarn/cache/methods-npm-1.1.2-92f6fdb39b-0917ff4041.zip +0 -0
  90. package/.yarn/cache/mime-db-npm-1.52.0-b5371d6fd2-0d99a03585.zip +0 -0
  91. package/.yarn/cache/mime-npm-1.6.0-60ae95038a-fef25e3926.zip +0 -0
  92. package/.yarn/cache/mime-types-npm-2.1.35-dd9ea9f3e2-89a5b7f1de.zip +0 -0
  93. package/.yarn/cache/minimatch-npm-3.1.2-9405269906-c154e56640.zip +0 -0
  94. package/.yarn/cache/moment-npm-2.29.2-7e4b405a08-ee850b5776.zip +0 -0
  95. package/.yarn/cache/moment-timezone-npm-0.5.34-e4fe2d01f6-12a1d3d52e.zip +0 -0
  96. package/.yarn/cache/ms-npm-2.0.0-9e1101a471-0e6a22b8b7.zip +0 -0
  97. package/.yarn/cache/ms-npm-2.1.2-ec0c1512ff-673cdb2c31.zip +0 -0
  98. package/.yarn/cache/ms-npm-2.1.3-81ff3cfac1-aa92de6080.zip +0 -0
  99. package/.yarn/cache/negotiator-npm-0.6.3-9d50e36171-b8ffeb1e26.zip +0 -0
  100. package/.yarn/cache/object-assign-npm-4.1.1-1004ad6dec-fcc6e4ea8c.zip +0 -0
  101. package/.yarn/cache/object-inspect-npm-1.12.0-d064fa559a-2b36d4001a.zip +0 -0
  102. package/.yarn/cache/on-finished-npm-2.3.0-4ce92f72c6-1db595bd96.zip +0 -0
  103. package/.yarn/cache/on-finished-npm-2.4.1-907af70f88-d20929a25e.zip +0 -0
  104. package/.yarn/cache/once-npm-1.4.0-ccf03ef07a-cd0a885013.zip +0 -0
  105. package/.yarn/cache/one-time-npm-1.0.0-aeaad5e524-fd008d7e99.zip +0 -0
  106. package/.yarn/cache/parseurl-npm-1.3.3-1542397e00-407cee8e0a.zip +0 -0
  107. package/.yarn/cache/path-is-absolute-npm-1.0.1-31bc695ffd-060840f92c.zip +0 -0
  108. package/.yarn/cache/path-to-regexp-npm-0.1.7-2605347373-69a14ea24d.zip +0 -0
  109. package/.yarn/cache/pg-connection-string-npm-2.5.0-1ee5de9ab9-a6f3a068f7.zip +0 -0
  110. package/.yarn/cache/proxy-addr-npm-2.0.7-dae6552872-29c6990ce9.zip +0 -0
  111. package/.yarn/cache/qs-npm-6.10.3-172e1a3fb7-0fac5e6c71.zip +0 -0
  112. package/.yarn/cache/qs-npm-6.9.7-3f3fa3ac7b-5bbd263332.zip +0 -0
  113. package/.yarn/cache/range-parser-npm-1.2.1-1a470fa390-0a268d4fea.zip +0 -0
  114. package/.yarn/cache/raw-body-npm-2.4.3-8e0a306e17-d2961fa3c7.zip +0 -0
  115. package/.yarn/cache/raw-body-npm-2.5.1-9dd1d9fff9-5362adff15.zip +0 -0
  116. package/.yarn/cache/readable-stream-npm-3.6.0-23a4a5eb56-d4ea81502d.zip +0 -0
  117. package/.yarn/cache/retry-as-promised-npm-5.0.0-305d61b9d1-4d17e0597f.zip +0 -0
  118. package/.yarn/cache/safe-buffer-npm-5.2.1-3481c8aa9b-b99c4b41fd.zip +0 -0
  119. package/.yarn/cache/safe-stable-stringify-npm-2.3.1-5e1888c3a7-a0a0bad029.zip +0 -0
  120. package/.yarn/cache/safer-buffer-npm-2.1.2-8d5c0b705e-cab8f25ae6.zip +0 -0
  121. package/.yarn/cache/semver-npm-7.3.6-9e6a4b1c17-9845f96b22.zip +0 -0
  122. package/.yarn/cache/send-npm-0.17.2-73a3dbeba6-c28f36deb4.zip +0 -0
  123. package/.yarn/cache/sequelize-npm-6.18.0-8dd1e76012-fc540d165e.zip +0 -0
  124. package/.yarn/cache/sequelize-pool-npm-7.1.0-670df81ecb-b11d06d02d.zip +0 -0
  125. package/.yarn/cache/sequelize-typescript-npm-2.1.3-512be8fd59-e6e2757600.zip +0 -0
  126. package/.yarn/cache/serve-static-npm-1.14.2-3ce50bb5ff-d97f3183b1.zip +0 -0
  127. package/.yarn/cache/setprototypeof-npm-1.2.0-0fedbdcd3a-be18cbbf70.zip +0 -0
  128. package/.yarn/cache/side-channel-npm-1.0.4-e1f38b9e06-351e41b947.zip +0 -0
  129. package/.yarn/cache/simple-swizzle-npm-0.2.2-8dee37fad1-a7f3f2ab5c.zip +0 -0
  130. package/.yarn/cache/socket.io-adapter-npm-2.4.0-36a74a6ea1-a84639946d.zip +0 -0
  131. package/.yarn/cache/socket.io-npm-4.5.4-888fc15f6d-b5456d361b.zip +0 -0
  132. package/.yarn/cache/socket.io-parser-npm-4.2.1-7ef513b498-2582202f22.zip +0 -0
  133. package/.yarn/cache/socketio-jwt-auth-npm-0.1.0-b3fd2c6724-430e9d6cc2.zip +0 -0
  134. package/.yarn/cache/stack-trace-npm-0.0.10-9460b173e1-473036ad32.zip +0 -0
  135. package/.yarn/cache/statuses-npm-1.5.0-f88f91b2e9-c469b9519d.zip +0 -0
  136. package/.yarn/cache/statuses-npm-2.0.1-81d2b97fee-18c7623fdb.zip +0 -0
  137. package/.yarn/cache/string_decoder-npm-1.3.0-2422117fd0-8417646695.zip +0 -0
  138. package/.yarn/cache/text-hex-npm-1.0.0-22389e4d56-1138f68adc.zip +0 -0
  139. package/.yarn/cache/toidentifier-npm-1.0.1-f759712599-952c29e2a8.zip +0 -0
  140. package/.yarn/cache/toposort-class-npm-1.0.1-aefabde69e-c5e3229d48.zip +0 -0
  141. package/.yarn/cache/triple-beam-npm-1.3.0-eda4e2a46c-7d7b77d862.zip +0 -0
  142. package/.yarn/cache/type-is-npm-1.6.18-6dee4d4961-2c8e47675d.zip +0 -0
  143. package/.yarn/cache/typescript-npm-4.6.3-1493ebc82b-255bb26c8c.zip +0 -0
  144. package/.yarn/cache/typescript-patch-587448dd9c-6bf45caf84.zip +0 -0
  145. package/.yarn/cache/unpipe-npm-1.0.0-2ed2a3c2bf-4fa18d8d8d.zip +0 -0
  146. package/.yarn/cache/util-deprecate-npm-1.0.2-e3fe1a219c-474acf1146.zip +0 -0
  147. package/.yarn/cache/utils-merge-npm-1.0.1-363bbdfbca-c810954932.zip +0 -0
  148. package/.yarn/cache/uuid-npm-8.3.2-eca0baba53-5575a8a75c.zip +0 -0
  149. package/.yarn/cache/validator-npm-13.7.0-624277e841-2b83283de1.zip +0 -0
  150. package/.yarn/cache/vary-npm-1.1.2-b49f70ae63-ae0123222c.zip +0 -0
  151. package/.yarn/cache/winston-npm-3.7.2-5336ad5eff-f1f1a860d2.zip +0 -0
  152. package/.yarn/cache/winston-transport-npm-4.5.0-e10bfb2169-a56e5678a8.zip +0 -0
  153. package/.yarn/cache/wkx-npm-0.5.0-fca5152cd8-47b27387de.zip +0 -0
  154. package/.yarn/cache/wrappy-npm-1.0.2-916de4d4b3-159da4805f.zip +0 -0
  155. package/.yarn/cache/ws-npm-8.2.3-03a35b8ad7-c869296ccb.zip +0 -0
  156. package/.yarn/cache/xtend-npm-4.0.2-7f2375736e-ac5dfa738b.zip +0 -0
  157. package/.yarn/install-state.gz +0 -0
  158. package/.yarn/sdks/integrations.yml +5 -0
  159. package/.yarn/sdks/typescript/bin/tsc +20 -0
  160. package/.yarn/sdks/typescript/bin/tsserver +20 -0
  161. package/.yarn/sdks/typescript/lib/tsc.js +20 -0
  162. package/.yarn/sdks/typescript/lib/tsserver.js +223 -0
  163. package/.yarn/sdks/typescript/lib/tsserverlibrary.js +223 -0
  164. package/.yarn/sdks/typescript/lib/typescript.js +20 -0
  165. package/.yarn/sdks/typescript/package.json +6 -0
  166. package/dist/socket/index.d.ts +5 -4
  167. package/dist/socket/index.d.ts.map +1 -1
  168. package/dist/socket/index.js +6 -43
  169. package/dist/socket/index.js.map +1 -1
  170. package/dist/types/index.d.ts +10 -6
  171. package/dist/types/index.d.ts.map +1 -1
  172. package/package.json +3 -3
@@ -0,0 +1,223 @@
1
+ #!/usr/bin/env node
2
+
3
+ const {existsSync} = require(`fs`);
4
+ const {createRequire} = require(`module`);
5
+ const {resolve} = require(`path`);
6
+
7
+ const relPnpApiPath = "../../../../.pnp.cjs";
8
+
9
+ const absPnpApiPath = resolve(__dirname, relPnpApiPath);
10
+ const absRequire = createRequire(absPnpApiPath);
11
+
12
+ const moduleWrapper = tsserver => {
13
+ if (!process.versions.pnp) {
14
+ return tsserver;
15
+ }
16
+
17
+ const {isAbsolute} = require(`path`);
18
+ const pnpApi = require(`pnpapi`);
19
+
20
+ const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//);
21
+ const isPortal = str => str.startsWith("portal:/");
22
+ const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`);
23
+
24
+ const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
25
+ return `${locator.name}@${locator.reference}`;
26
+ }));
27
+
28
+ // VSCode sends the zip paths to TS using the "zip://" prefix, that TS
29
+ // doesn't understand. This layer makes sure to remove the protocol
30
+ // before forwarding it to TS, and to add it back on all returned paths.
31
+
32
+ function toEditorPath(str) {
33
+ // We add the `zip:` prefix to both `.zip/` paths and virtual paths
34
+ if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) {
35
+ // We also take the opportunity to turn virtual paths into physical ones;
36
+ // this makes it much easier to work with workspaces that list peer
37
+ // dependencies, since otherwise Ctrl+Click would bring us to the virtual
38
+ // file instances instead of the real ones.
39
+ //
40
+ // We only do this to modules owned by the the dependency tree roots.
41
+ // This avoids breaking the resolution when jumping inside a vendor
42
+ // with peer dep (otherwise jumping into react-dom would show resolution
43
+ // errors on react).
44
+ //
45
+ const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str;
46
+ if (resolved) {
47
+ const locator = pnpApi.findPackageLocator(resolved);
48
+ if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) {
49
+ str = resolved;
50
+ }
51
+ }
52
+
53
+ str = normalize(str);
54
+
55
+ if (str.match(/\.zip\//)) {
56
+ switch (hostInfo) {
57
+ // Absolute VSCode `Uri.fsPath`s need to start with a slash.
58
+ // VSCode only adds it automatically for supported schemes,
59
+ // so we have to do it manually for the `zip` scheme.
60
+ // The path needs to start with a caret otherwise VSCode doesn't handle the protocol
61
+ //
62
+ // Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
63
+ //
64
+ // 2021-10-08: VSCode changed the format in 1.61.
65
+ // Before | ^zip:/c:/foo/bar.zip/package.json
66
+ // After | ^/zip//c:/foo/bar.zip/package.json
67
+ //
68
+ // 2022-04-06: VSCode changed the format in 1.66.
69
+ // Before | ^/zip//c:/foo/bar.zip/package.json
70
+ // After | ^/zip/c:/foo/bar.zip/package.json
71
+ //
72
+ // 2022-05-06: VSCode changed the format in 1.68
73
+ // Before | ^/zip/c:/foo/bar.zip/package.json
74
+ // After | ^/zip//c:/foo/bar.zip/package.json
75
+ //
76
+ case `vscode <1.61`: {
77
+ str = `^zip:${str}`;
78
+ } break;
79
+
80
+ case `vscode <1.66`: {
81
+ str = `^/zip/${str}`;
82
+ } break;
83
+
84
+ case `vscode <1.68`: {
85
+ str = `^/zip${str}`;
86
+ } break;
87
+
88
+ case `vscode`: {
89
+ str = `^/zip/${str}`;
90
+ } break;
91
+
92
+ // To make "go to definition" work,
93
+ // We have to resolve the actual file system path from virtual path
94
+ // and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
95
+ case `coc-nvim`: {
96
+ str = normalize(resolved).replace(/\.zip\//, `.zip::`);
97
+ str = resolve(`zipfile:${str}`);
98
+ } break;
99
+
100
+ // Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server)
101
+ // We have to resolve the actual file system path from virtual path,
102
+ // everything else is up to neovim
103
+ case `neovim`: {
104
+ str = normalize(resolved).replace(/\.zip\//, `.zip::`);
105
+ str = `zipfile://${str}`;
106
+ } break;
107
+
108
+ default: {
109
+ str = `zip:${str}`;
110
+ } break;
111
+ }
112
+ }
113
+ }
114
+
115
+ return str;
116
+ }
117
+
118
+ function fromEditorPath(str) {
119
+ switch (hostInfo) {
120
+ case `coc-nvim`: {
121
+ str = str.replace(/\.zip::/, `.zip/`);
122
+ // The path for coc-nvim is in format of /<pwd>/zipfile:/<pwd>/.yarn/...
123
+ // So in order to convert it back, we use .* to match all the thing
124
+ // before `zipfile:`
125
+ return process.platform === `win32`
126
+ ? str.replace(/^.*zipfile:\//, ``)
127
+ : str.replace(/^.*zipfile:/, ``);
128
+ } break;
129
+
130
+ case `neovim`: {
131
+ str = str.replace(/\.zip::/, `.zip/`);
132
+ // The path for neovim is in format of zipfile:///<pwd>/.yarn/...
133
+ return str.replace(/^zipfile:\/\//, ``);
134
+ } break;
135
+
136
+ case `vscode`:
137
+ default: {
138
+ return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`)
139
+ } break;
140
+ }
141
+ }
142
+
143
+ // Force enable 'allowLocalPluginLoads'
144
+ // TypeScript tries to resolve plugins using a path relative to itself
145
+ // which doesn't work when using the global cache
146
+ // https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238
147
+ // VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but
148
+ // TypeScript already does local loads and if this code is running the user trusts the workspace
149
+ // https://github.com/microsoft/vscode/issues/45856
150
+ const ConfiguredProject = tsserver.server.ConfiguredProject;
151
+ const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype;
152
+ ConfiguredProject.prototype.enablePluginsWithOptions = function() {
153
+ this.projectService.allowLocalPluginLoads = true;
154
+ return originalEnablePluginsWithOptions.apply(this, arguments);
155
+ };
156
+
157
+ // And here is the point where we hijack the VSCode <-> TS communications
158
+ // by adding ourselves in the middle. We locate everything that looks
159
+ // like an absolute path of ours and normalize it.
160
+
161
+ const Session = tsserver.server.Session;
162
+ const {onMessage: originalOnMessage, send: originalSend} = Session.prototype;
163
+ let hostInfo = `unknown`;
164
+
165
+ Object.assign(Session.prototype, {
166
+ onMessage(/** @type {string | object} */ message) {
167
+ const isStringMessage = typeof message === 'string';
168
+ const parsedMessage = isStringMessage ? JSON.parse(message) : message;
169
+
170
+ if (
171
+ parsedMessage != null &&
172
+ typeof parsedMessage === `object` &&
173
+ parsedMessage.arguments &&
174
+ typeof parsedMessage.arguments.hostInfo === `string`
175
+ ) {
176
+ hostInfo = parsedMessage.arguments.hostInfo;
177
+ if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) {
178
+ const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match(
179
+ // The RegExp from https://semver.org/ but without the caret at the start
180
+ /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
181
+ ) ?? []).map(Number)
182
+
183
+ if (major === 1) {
184
+ if (minor < 61) {
185
+ hostInfo += ` <1.61`;
186
+ } else if (minor < 66) {
187
+ hostInfo += ` <1.66`;
188
+ } else if (minor < 68) {
189
+ hostInfo += ` <1.68`;
190
+ }
191
+ }
192
+ }
193
+ }
194
+
195
+ const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => {
196
+ return typeof value === 'string' ? fromEditorPath(value) : value;
197
+ });
198
+
199
+ return originalOnMessage.call(
200
+ this,
201
+ isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON)
202
+ );
203
+ },
204
+
205
+ send(/** @type {any} */ msg) {
206
+ return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => {
207
+ return typeof value === `string` ? toEditorPath(value) : value;
208
+ })));
209
+ }
210
+ });
211
+
212
+ return tsserver;
213
+ };
214
+
215
+ if (existsSync(absPnpApiPath)) {
216
+ if (!process.versions.pnp) {
217
+ // Setup the environment to be able to require typescript/lib/tsserver.js
218
+ require(absPnpApiPath).setup();
219
+ }
220
+ }
221
+
222
+ // Defer to the real typescript/lib/tsserver.js your application uses
223
+ module.exports = moduleWrapper(absRequire(`typescript/lib/tsserver.js`));
@@ -0,0 +1,223 @@
1
+ #!/usr/bin/env node
2
+
3
+ const {existsSync} = require(`fs`);
4
+ const {createRequire} = require(`module`);
5
+ const {resolve} = require(`path`);
6
+
7
+ const relPnpApiPath = "../../../../.pnp.cjs";
8
+
9
+ const absPnpApiPath = resolve(__dirname, relPnpApiPath);
10
+ const absRequire = createRequire(absPnpApiPath);
11
+
12
+ const moduleWrapper = tsserver => {
13
+ if (!process.versions.pnp) {
14
+ return tsserver;
15
+ }
16
+
17
+ const {isAbsolute} = require(`path`);
18
+ const pnpApi = require(`pnpapi`);
19
+
20
+ const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//);
21
+ const isPortal = str => str.startsWith("portal:/");
22
+ const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`);
23
+
24
+ const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
25
+ return `${locator.name}@${locator.reference}`;
26
+ }));
27
+
28
+ // VSCode sends the zip paths to TS using the "zip://" prefix, that TS
29
+ // doesn't understand. This layer makes sure to remove the protocol
30
+ // before forwarding it to TS, and to add it back on all returned paths.
31
+
32
+ function toEditorPath(str) {
33
+ // We add the `zip:` prefix to both `.zip/` paths and virtual paths
34
+ if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) {
35
+ // We also take the opportunity to turn virtual paths into physical ones;
36
+ // this makes it much easier to work with workspaces that list peer
37
+ // dependencies, since otherwise Ctrl+Click would bring us to the virtual
38
+ // file instances instead of the real ones.
39
+ //
40
+ // We only do this to modules owned by the the dependency tree roots.
41
+ // This avoids breaking the resolution when jumping inside a vendor
42
+ // with peer dep (otherwise jumping into react-dom would show resolution
43
+ // errors on react).
44
+ //
45
+ const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str;
46
+ if (resolved) {
47
+ const locator = pnpApi.findPackageLocator(resolved);
48
+ if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) {
49
+ str = resolved;
50
+ }
51
+ }
52
+
53
+ str = normalize(str);
54
+
55
+ if (str.match(/\.zip\//)) {
56
+ switch (hostInfo) {
57
+ // Absolute VSCode `Uri.fsPath`s need to start with a slash.
58
+ // VSCode only adds it automatically for supported schemes,
59
+ // so we have to do it manually for the `zip` scheme.
60
+ // The path needs to start with a caret otherwise VSCode doesn't handle the protocol
61
+ //
62
+ // Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
63
+ //
64
+ // 2021-10-08: VSCode changed the format in 1.61.
65
+ // Before | ^zip:/c:/foo/bar.zip/package.json
66
+ // After | ^/zip//c:/foo/bar.zip/package.json
67
+ //
68
+ // 2022-04-06: VSCode changed the format in 1.66.
69
+ // Before | ^/zip//c:/foo/bar.zip/package.json
70
+ // After | ^/zip/c:/foo/bar.zip/package.json
71
+ //
72
+ // 2022-05-06: VSCode changed the format in 1.68
73
+ // Before | ^/zip/c:/foo/bar.zip/package.json
74
+ // After | ^/zip//c:/foo/bar.zip/package.json
75
+ //
76
+ case `vscode <1.61`: {
77
+ str = `^zip:${str}`;
78
+ } break;
79
+
80
+ case `vscode <1.66`: {
81
+ str = `^/zip/${str}`;
82
+ } break;
83
+
84
+ case `vscode <1.68`: {
85
+ str = `^/zip${str}`;
86
+ } break;
87
+
88
+ case `vscode`: {
89
+ str = `^/zip/${str}`;
90
+ } break;
91
+
92
+ // To make "go to definition" work,
93
+ // We have to resolve the actual file system path from virtual path
94
+ // and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
95
+ case `coc-nvim`: {
96
+ str = normalize(resolved).replace(/\.zip\//, `.zip::`);
97
+ str = resolve(`zipfile:${str}`);
98
+ } break;
99
+
100
+ // Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server)
101
+ // We have to resolve the actual file system path from virtual path,
102
+ // everything else is up to neovim
103
+ case `neovim`: {
104
+ str = normalize(resolved).replace(/\.zip\//, `.zip::`);
105
+ str = `zipfile://${str}`;
106
+ } break;
107
+
108
+ default: {
109
+ str = `zip:${str}`;
110
+ } break;
111
+ }
112
+ }
113
+ }
114
+
115
+ return str;
116
+ }
117
+
118
+ function fromEditorPath(str) {
119
+ switch (hostInfo) {
120
+ case `coc-nvim`: {
121
+ str = str.replace(/\.zip::/, `.zip/`);
122
+ // The path for coc-nvim is in format of /<pwd>/zipfile:/<pwd>/.yarn/...
123
+ // So in order to convert it back, we use .* to match all the thing
124
+ // before `zipfile:`
125
+ return process.platform === `win32`
126
+ ? str.replace(/^.*zipfile:\//, ``)
127
+ : str.replace(/^.*zipfile:/, ``);
128
+ } break;
129
+
130
+ case `neovim`: {
131
+ str = str.replace(/\.zip::/, `.zip/`);
132
+ // The path for neovim is in format of zipfile:///<pwd>/.yarn/...
133
+ return str.replace(/^zipfile:\/\//, ``);
134
+ } break;
135
+
136
+ case `vscode`:
137
+ default: {
138
+ return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`)
139
+ } break;
140
+ }
141
+ }
142
+
143
+ // Force enable 'allowLocalPluginLoads'
144
+ // TypeScript tries to resolve plugins using a path relative to itself
145
+ // which doesn't work when using the global cache
146
+ // https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238
147
+ // VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but
148
+ // TypeScript already does local loads and if this code is running the user trusts the workspace
149
+ // https://github.com/microsoft/vscode/issues/45856
150
+ const ConfiguredProject = tsserver.server.ConfiguredProject;
151
+ const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype;
152
+ ConfiguredProject.prototype.enablePluginsWithOptions = function() {
153
+ this.projectService.allowLocalPluginLoads = true;
154
+ return originalEnablePluginsWithOptions.apply(this, arguments);
155
+ };
156
+
157
+ // And here is the point where we hijack the VSCode <-> TS communications
158
+ // by adding ourselves in the middle. We locate everything that looks
159
+ // like an absolute path of ours and normalize it.
160
+
161
+ const Session = tsserver.server.Session;
162
+ const {onMessage: originalOnMessage, send: originalSend} = Session.prototype;
163
+ let hostInfo = `unknown`;
164
+
165
+ Object.assign(Session.prototype, {
166
+ onMessage(/** @type {string | object} */ message) {
167
+ const isStringMessage = typeof message === 'string';
168
+ const parsedMessage = isStringMessage ? JSON.parse(message) : message;
169
+
170
+ if (
171
+ parsedMessage != null &&
172
+ typeof parsedMessage === `object` &&
173
+ parsedMessage.arguments &&
174
+ typeof parsedMessage.arguments.hostInfo === `string`
175
+ ) {
176
+ hostInfo = parsedMessage.arguments.hostInfo;
177
+ if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) {
178
+ const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match(
179
+ // The RegExp from https://semver.org/ but without the caret at the start
180
+ /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
181
+ ) ?? []).map(Number)
182
+
183
+ if (major === 1) {
184
+ if (minor < 61) {
185
+ hostInfo += ` <1.61`;
186
+ } else if (minor < 66) {
187
+ hostInfo += ` <1.66`;
188
+ } else if (minor < 68) {
189
+ hostInfo += ` <1.68`;
190
+ }
191
+ }
192
+ }
193
+ }
194
+
195
+ const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => {
196
+ return typeof value === 'string' ? fromEditorPath(value) : value;
197
+ });
198
+
199
+ return originalOnMessage.call(
200
+ this,
201
+ isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON)
202
+ );
203
+ },
204
+
205
+ send(/** @type {any} */ msg) {
206
+ return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => {
207
+ return typeof value === `string` ? toEditorPath(value) : value;
208
+ })));
209
+ }
210
+ });
211
+
212
+ return tsserver;
213
+ };
214
+
215
+ if (existsSync(absPnpApiPath)) {
216
+ if (!process.versions.pnp) {
217
+ // Setup the environment to be able to require typescript/lib/tsserverlibrary.js
218
+ require(absPnpApiPath).setup();
219
+ }
220
+ }
221
+
222
+ // Defer to the real typescript/lib/tsserverlibrary.js your application uses
223
+ module.exports = moduleWrapper(absRequire(`typescript/lib/tsserverlibrary.js`));
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+
3
+ const {existsSync} = require(`fs`);
4
+ const {createRequire} = require(`module`);
5
+ const {resolve} = require(`path`);
6
+
7
+ const relPnpApiPath = "../../../../.pnp.cjs";
8
+
9
+ const absPnpApiPath = resolve(__dirname, relPnpApiPath);
10
+ const absRequire = createRequire(absPnpApiPath);
11
+
12
+ if (existsSync(absPnpApiPath)) {
13
+ if (!process.versions.pnp) {
14
+ // Setup the environment to be able to require typescript/lib/typescript.js
15
+ require(absPnpApiPath).setup();
16
+ }
17
+ }
18
+
19
+ // Defer to the real typescript/lib/typescript.js your application uses
20
+ module.exports = absRequire(`typescript/lib/typescript.js`);
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "typescript",
3
+ "version": "4.6.3-sdk",
4
+ "main": "./lib/typescript.js",
5
+ "type": "commonjs"
6
+ }
@@ -1,10 +1,11 @@
1
- import { Server } from 'http';
2
- import { AuthOption, ExecuteFunction, RouteRequest, SocketOption } from 'src/types';
1
+ import { Server as httpServer } from 'http';
2
+ import { Server as SocketServer } from 'socket.io';
3
+ import { ExecuteFunction, RouteRequest, SocketOption } from 'src/types';
3
4
  export declare const createSocket: (request: RouteRequest, execute: ExecuteFunction) => any;
4
- export declare const socketInit: (server: Server, options: SocketOption, authOption?: AuthOption | undefined) => any;
5
+ export declare const socketInit: (server: httpServer, options: SocketOption) => SocketServer<import("socket.io/dist/typed-events").DefaultEventsMap, import("socket.io/dist/typed-events").DefaultEventsMap, import("socket.io/dist/typed-events").DefaultEventsMap, any> | undefined;
5
6
  export declare const getSocketIO: () => any | undefined;
6
7
  export declare const socketSendTo: (to: string, event: string, data: any) => any;
7
8
  export declare const socketSendAll: (event: string, data: any) => any;
8
9
  export declare const loadPath: (path: string, subPath: string) => Promise<void>;
9
- export declare const initSocketModule: (server: Server, dirname: string) => Promise<boolean>;
10
+ export declare const initSocketModule: (server: httpServer, dirname: string) => Promise<boolean>;
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/socket/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAW,UAAU,EAAc,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAOzG,eAAO,MAAM,YAAY,YAAa,YAAY,WAAW,eAAe,KAAG,GAK9E,CAAC;AAEF,eAAO,MAAM,UAAU,WAAY,MAAM,WAAW,YAAY,6CAwD/D,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,GAAG,GAAG,SAEpC,CAAC;AAEF,eAAO,MAAM,YAAY,OAAQ,MAAM,SAAS,MAAM,QAAQ,GAAG,QAEhE,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,MAAM,QAAQ,GAAG,QAErD,CAAC;AAEF,eAAO,MAAM,QAAQ,SAAgB,MAAM,WAAW,MAAM,kBAU3D,CAAC;AAEF,eAAO,MAAM,gBAAgB,WAAkB,MAAM,WAAW,MAAM,KAAG,QAAQ,OAAO,CAIvF,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/socket/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAuB,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAO7F,eAAO,MAAM,YAAY,YAAa,YAAY,WAAW,eAAe,KAAG,GAK9E,CAAC;AAEF,eAAO,MAAM,UAAU,WAAY,UAAU,WAAW,YAAY,0MAqBnE,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,GAAG,GAAG,SAEpC,CAAC;AAEF,eAAO,MAAM,YAAY,OAAQ,MAAM,SAAS,MAAM,QAAQ,GAAG,QAEhE,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,MAAM,QAAQ,GAAG,QAErD,CAAC;AAEF,eAAO,MAAM,QAAQ,SAAgB,MAAM,WAAW,MAAM,kBAU3D,CAAC;AAEF,eAAO,MAAM,gBAAgB,WAAkB,UAAU,WAAW,MAAM,KAAG,QAAQ,OAAO,CAI3F,CAAC"}
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.initSocketModule = exports.loadPath = exports.socketSendAll = exports.socketSendTo = exports.getSocketIO = exports.socketInit = exports.createSocket = void 0;
16
16
  const core_1 = require("@asapjs/core");
17
17
  const fs_1 = __importDefault(require("fs"));
18
+ const socket_io_1 = require("socket.io");
18
19
  const config = {
19
20
  container: undefined,
20
21
  listeners: [],
@@ -26,53 +27,15 @@ const createSocket = (request, execute) => {
26
27
  });
27
28
  };
28
29
  exports.createSocket = createSocket;
29
- const socketInit = (server, options, authOption) => {
30
+ const socketInit = (server, options) => {
30
31
  if (config.container)
31
32
  return;
32
- const io = require('socket.io')(server);
33
- if (options.adapter) {
34
- io.adapter(options.adapter);
35
- }
36
- if (authOption) {
37
- const auth = authOption;
38
- if (authOption.jwt_secret && authOption.handler) {
39
- const jwtAuth = require('socketio-jwt-auth');
40
- const handler = auth.handler();
41
- const jwtHandler = jwtAuth.authenticate({ secret: auth.jwt_secret, algorithm: 'HS256' }, function (payload, done) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- try {
44
- const user = yield handler(payload);
45
- if (user) {
46
- return done(null, user);
47
- }
48
- else {
49
- return done();
50
- }
51
- }
52
- catch (e) {
53
- return done(e);
54
- }
55
- });
56
- });
57
- io.use(jwtHandler);
58
- }
59
- }
33
+ const io = new socket_io_1.Server(server);
60
34
  io.on('connection', (socket) => {
61
35
  const user = socket.request.user;
62
- if (authOption) {
63
- console.log('Authentication passed!', user === null || user === void 0 ? void 0 : user.id);
64
- // now you can access user info through socket.request.user
65
- // socket.request.user.logged_in will be set to true if the user was authenticated
66
- socket.emit('success', {
67
- message: 'success logged in',
68
- user: socket.request.user,
69
- });
70
- }
71
- else {
72
- socket.emit('success', {
73
- message: 'success connected',
74
- });
75
- }
36
+ socket.emit('success', {
37
+ message: 'success connected',
38
+ });
76
39
  config.listeners.map((item) => {
77
40
  socket.on(item.request.path, (body) => __awaiter(void 0, void 0, void 0, function* () {
78
41
  yield item.execute(socket, { body, user });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/socket/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAyC;AAGzC,4CAAoB;AAGpB,MAAM,MAAM,GAAe;IACzB,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,EAAE;CACd,CAAC;AAEK,MAAM,YAAY,GAAG,CAAC,OAAqB,EAAE,OAAwB,EAAO,EAAE;IACnF,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;QACpB,OAAO;Q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,OAAO,EAAE,EAAE,CAAC,CAAC;IAC5B,MAAM,IAAA,kBAAU,EAAC,MAAM,EAAE,IAAA,gBAAS,GAAS,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC;AACd,CAAC,CAAA,CAAC;AAJW,QAAA,gBAAgB,oBAI3B"}
@@ -1,7 +1,5 @@
1
+ import { Socket } from 'socket.io';
1
2
  export declare type AsyncFunction<A, O> = (args: A) => Promise<O>;
2
- export interface RoutePath {
3
- path: string;
4
- }
5
3
  export interface SocketOption {
6
4
  adapter?: unknown;
7
5
  listener?: (socket: unknown) => void;
@@ -13,13 +11,16 @@ export interface AuthOption {
13
11
  }
14
12
  export interface ConfigSpec {
15
13
  container?: any;
16
- listeners: any[];
14
+ listeners: {
15
+ request: RouteRequest;
16
+ execute: ExecuteFunction;
17
+ }[];
17
18
  }
18
19
  export interface AppUser {
19
20
  id?: number;
20
21
  }
21
22
  export interface RouteRequest {
22
- uri: string | RoutePath;
23
+ path: string;
23
24
  roles?: string[];
24
25
  }
25
26
  export interface ExecuteArgs {
@@ -31,5 +32,8 @@ export interface ExecuteArgs {
31
32
  };
32
33
  user?: AppUser;
33
34
  }
34
- export declare type ExecuteFunction = ((args: ExecuteArgs) => Promise<unknown> | unknown) & ((req: any, res: any, next: any) => Promise<unknown> | unknown | void);
35
+ export declare type ExecuteFunction = (socket: Socket, ExecuteArgs: {
36
+ body: any;
37
+ user: any;
38
+ }) => Promise<unknown> | unknown | void;
35
39
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAE1D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;CAId;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,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,CAAC;AAE1D,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,SAAS,EAAE;QAAE,OAAO,EAAE,YAAY,CAAC;QAAC,OAAO,EAAE,eAAe,CAAA;KAAE,EAAE,CAAC;CAClE;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAClC,IAAI,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,oBAAY,eAAe,GAAG,CAC5B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE;IAAE,IAAI,EAAE,GAAG,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,KAClC,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@asapjs/socket",
3
- "version": "0.0.4",
3
+ "version": "0.1.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
- "build": "./node_modules/typescript/bin/tsc",
7
+ "build": "tsc",
8
8
  "localinstall": "yarn build && cp -r ./dist /Users/seungmin/projects/pangaia/pangaia-b4c-ms-shop/node_modules/@asapjs/sequelize/"
9
9
  },
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
13
  "http": "^0.0.1-security",
14
- "socket.io": "^2.4.1",
14
+ "socket.io": "4.5.4",
15
15
  "socket.io-adapter": "^2.3.1",
16
16
  "socketio-jwt-auth": "^0.1.0"
17
17
  },