@qwik.dev/devtools 0.0.2 → 0.0.4

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 (136) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -47
  3. package/dist/component/_virtual/_commonjsHelpers.qwik.cjs +6 -0
  4. package/dist/component/_virtual/_commonjsHelpers.qwik.mjs +6 -0
  5. package/dist/component/devtools.css.qwik.cjs +3 -0
  6. package/dist/component/devtools.css.qwik.mjs +4 -0
  7. package/dist/component/devtools.qwik.cjs +537 -0
  8. package/dist/component/devtools.qwik.mjs +537 -0
  9. package/dist/component/index.qwik.cjs +4 -0
  10. package/dist/component/index.qwik.mjs +4 -0
  11. package/dist/component/lib-types/devtools/src/index.d.ts +1 -0
  12. package/dist/component/lib-types/devtools/src/utils/location.d.ts +1 -0
  13. package/dist/component/node_modules/.pnpm/@qwikest_icons@0.0.13_@builder.io_qwik@1.11.0_vite@5.4.10_@types_node@20.14.11__/node_modules/@qwikest/icons/lib/hi.qwik.qwik.cjs +60 -0
  14. package/dist/component/node_modules/.pnpm/@qwikest_icons@0.0.13_@builder.io_qwik@1.11.0_vite@5.4.10_@types_node@20.14.11__/node_modules/@qwikest/icons/lib/hi.qwik.qwik.mjs +60 -0
  15. package/dist/component/node_modules/.pnpm/@qwikest_icons@0.0.13_@builder.io_qwik@1.11.0_vite@5.4.10_@types_node@20.14.11__/node_modules/@qwikest/icons/lib/lu.qwik.qwik.cjs +32 -0
  16. package/dist/component/node_modules/.pnpm/@qwikest_icons@0.0.13_@builder.io_qwik@1.11.0_vite@5.4.10_@types_node@20.14.11__/node_modules/@qwikest/icons/lib/lu.qwik.qwik.mjs +32 -0
  17. package/dist/component/node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.qwik.cjs +54 -0
  18. package/dist/component/node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.qwik.mjs +54 -0
  19. package/dist/component/node_modules/.pnpm/birpc@0.2.19/node_modules/birpc/dist/index.qwik.cjs +128 -0
  20. package/dist/component/node_modules/.pnpm/birpc@0.2.19/node_modules/birpc/dist/index.qwik.mjs +128 -0
  21. package/dist/component/node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.qwik.cjs +149 -0
  22. package/dist/component/node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.qwik.mjs +150 -0
  23. package/dist/component/node_modules/.pnpm/copy-anything@3.0.5/node_modules/copy-anything/dist/index.qwik.cjs +36 -0
  24. package/dist/component/node_modules/.pnpm/copy-anything@3.0.5/node_modules/copy-anything/dist/index.qwik.mjs +36 -0
  25. package/dist/component/node_modules/.pnpm/dree@5.1.5/node_modules/dree/bundled/lib/esm/index.esm.qwik.cjs +12 -0
  26. package/dist/component/node_modules/.pnpm/dree@5.1.5/node_modules/dree/bundled/lib/esm/index.esm.qwik.mjs +12 -0
  27. package/dist/component/node_modules/.pnpm/is-what@4.1.16/node_modules/is-what/dist/index.qwik.cjs +17 -0
  28. package/dist/component/node_modules/.pnpm/is-what@4.1.16/node_modules/is-what/dist/index.qwik.mjs +17 -0
  29. package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/assert-valid-pattern.qwik.cjs +12 -0
  30. package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/assert-valid-pattern.qwik.mjs +12 -0
  31. package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/ast.qwik.cjs +513 -0
  32. package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/ast.qwik.mjs +513 -0
  33. package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/brace-expressions.qwik.cjs +110 -0
  34. package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/brace-expressions.qwik.mjs +110 -0
  35. package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/escape.qwik.cjs +6 -0
  36. package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/escape.qwik.mjs +6 -0
  37. package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/index.qwik.cjs +738 -0
  38. package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/index.qwik.mjs +738 -0
  39. package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/unescape.qwik.cjs +6 -0
  40. package/dist/component/node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/unescape.qwik.mjs +6 -0
  41. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/accessDeep.qwik.cjs +120 -0
  42. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/accessDeep.qwik.mjs +120 -0
  43. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/class-registry.qwik.cjs +23 -0
  44. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/class-registry.qwik.mjs +23 -0
  45. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/custom-transformer-registry.qwik.cjs +18 -0
  46. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/custom-transformer-registry.qwik.mjs +18 -0
  47. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/double-indexed-kv.qwik.cjs +23 -0
  48. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/double-indexed-kv.qwik.mjs +23 -0
  49. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/index.qwik.cjs +91 -0
  50. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/index.qwik.mjs +91 -0
  51. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/is.qwik.cjs +51 -0
  52. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/is.qwik.mjs +51 -0
  53. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/pathstringifier.qwik.cjs +30 -0
  54. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/pathstringifier.qwik.mjs +30 -0
  55. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/plainer.qwik.cjs +148 -0
  56. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/plainer.qwik.mjs +148 -0
  57. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/registry.qwik.cjs +28 -0
  58. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/registry.qwik.mjs +28 -0
  59. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/transformer.qwik.cjs +203 -0
  60. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/transformer.qwik.mjs +203 -0
  61. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/util.qwik.cjs +47 -0
  62. package/dist/component/node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/util.qwik.mjs +47 -0
  63. package/dist/component/node_modules/.pnpm/vite-hot-client@0.2.4_vite@5.4.10_@types_node@20.14.11_/node_modules/vite-hot-client/dist/index.qwik.cjs +35 -0
  64. package/dist/component/node_modules/.pnpm/vite-hot-client@0.2.4_vite@5.4.10_@types_node@20.14.11_/node_modules/vite-hot-client/dist/index.qwik.mjs +35 -0
  65. package/dist/component/packages/kit/src/client.qwik.cjs +18 -0
  66. package/dist/component/packages/kit/src/client.qwik.mjs +18 -0
  67. package/dist/component/packages/kit/src/context.qwik.cjs +20 -0
  68. package/dist/component/packages/kit/src/context.qwik.mjs +20 -0
  69. package/dist/component/packages/kit/src/globals.qwik.cjs +6 -0
  70. package/dist/component/packages/kit/src/globals.qwik.mjs +6 -0
  71. package/dist/plugin/index.cjs +10504 -0
  72. package/dist/plugin/index.mjs +10492 -0
  73. package/package.json +24 -43
  74. package/lib/index.qwik.cjs +0 -4
  75. package/lib/index.qwik.mjs +0 -4
  76. package/lib/kit/context.qwik.cjs +0 -16
  77. package/lib/kit/context.qwik.mjs +0 -16
  78. package/lib/kit/globals.qwik.cjs +0 -6
  79. package/lib/kit/globals.qwik.mjs +0 -6
  80. package/lib/kit/server.qwik.cjs +0 -18
  81. package/lib/kit/server.qwik.mjs +0 -18
  82. package/lib/plugin/assets/index.qwik.cjs +0 -67
  83. package/lib/plugin/assets/index.qwik.mjs +0 -67
  84. package/lib/plugin/index.qwik.cjs +0 -49
  85. package/lib/plugin/index.qwik.mjs +0 -49
  86. package/lib/plugin/npm/index.qwik.cjs +0 -19
  87. package/lib/plugin/npm/index.qwik.mjs +0 -19
  88. package/lib/plugin/routes/index.qwik.cjs +0 -17
  89. package/lib/plugin/routes/index.qwik.mjs +0 -17
  90. package/lib/plugin/rpc/index.qwik.cjs +0 -14
  91. package/lib/plugin/rpc/index.qwik.mjs +0 -14
  92. package/lib-types/index.d.ts +0 -1
  93. package/lib-types/plugin/assets/index.d.ts +0 -5
  94. package/lib-types/plugin/components/index.d.ts +0 -0
  95. package/lib-types/plugin/index.d.ts +0 -2
  96. package/lib-types/plugin/npm/index.d.ts +0 -5
  97. package/lib-types/plugin/routes/index.d.ts +0 -5
  98. package/lib-types/plugin/rpc/index.d.ts +0 -3
  99. package/lib-types/plugin/types/index.d.ts +0 -5
  100. package/src/devtools.css +0 -558
  101. package/src/devtools.tsx +0 -411
  102. package/src/entry.dev.tsx +0 -17
  103. package/src/entry.ssr.tsx +0 -25
  104. package/src/index.ts +0 -1
  105. package/src/kit/client.ts +0 -21
  106. package/src/kit/constants.ts +0 -1
  107. package/src/kit/context.ts +0 -42
  108. package/src/kit/globals.ts +0 -22
  109. package/src/kit/index.ts +0 -4
  110. package/src/kit/server.ts +0 -21
  111. package/src/kit/shared.ts +0 -11
  112. package/src/kit/types.ts +0 -48
  113. package/src/plugin/assets/index.ts +0 -126
  114. package/src/plugin/components/index.ts +0 -0
  115. package/src/plugin/index.ts +0 -50
  116. package/src/plugin/npm/index.ts +0 -24
  117. package/src/plugin/routes/index.ts +0 -16
  118. package/src/plugin/rpc/index.ts +0 -14
  119. package/src/plugin/types/index.ts +0 -6
  120. package/src/root.tsx +0 -15
  121. /package/{lib-types → dist/component/lib-types/devtools/src}/devtools.d.ts +0 -0
  122. /package/{lib-types → dist/component/lib-types/devtools/src}/entry.dev.d.ts +0 -0
  123. /package/{lib-types → dist/component/lib-types/devtools/src}/entry.ssr.d.ts +0 -0
  124. /package/{lib-types → dist/component/lib-types/devtools/src}/root.d.ts +0 -0
  125. /package/{lib-types/kit → dist/component/lib-types/kit/src}/client.d.ts +0 -0
  126. /package/{lib-types/kit → dist/component/lib-types/kit/src}/constants.d.ts +0 -0
  127. /package/{lib-types/kit → dist/component/lib-types/kit/src}/context.d.ts +0 -0
  128. /package/{lib-types/kit → dist/component/lib-types/kit/src}/globals.d.ts +0 -0
  129. /package/{lib-types/kit → dist/component/lib-types/kit/src}/index.d.ts +0 -0
  130. /package/{lib-types/kit → dist/component/lib-types/kit/src}/server.d.ts +0 -0
  131. /package/{lib-types/kit → dist/component/lib-types/kit/src}/shared.d.ts +0 -0
  132. /package/{lib-types/kit → dist/component/lib-types/kit/src}/types.d.ts +0 -0
  133. /package/{lib/kit → dist/component/packages/kit/src}/constants.qwik.cjs +0 -0
  134. /package/{lib/kit → dist/component/packages/kit/src}/constants.qwik.mjs +0 -0
  135. /package/{lib/kit → dist/component/packages/kit/src}/shared.qwik.cjs +0 -0
  136. /package/{lib/kit → dist/component/packages/kit/src}/shared.qwik.mjs +0 -0
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const core = require("@qwik.dev/core");
4
+ const LuFolderTree = (props) => /* @__PURE__ */ core._jsxS("svg", {
5
+ ...props,
6
+ children: [
7
+ /* @__PURE__ */ core._jsxQ("path", null, {
8
+ d: "M13 10h7a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z"
9
+ }, null, 3, null),
10
+ /* @__PURE__ */ core._jsxQ("path", null, {
11
+ d: "M13 21h7a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.88a1 1 0 0 1-.9-.55l-.44-.9a1 1 0 0 0-.9-.55H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z"
12
+ }, null, 3, null),
13
+ /* @__PURE__ */ core._jsxQ("path", null, {
14
+ d: "M3 3v2c0 1.1.9 2 2 2h3"
15
+ }, null, 3, null),
16
+ /* @__PURE__ */ core._jsxQ("path", null, {
17
+ d: "M3 3v13c0 1.1.9 2 2 2h3"
18
+ }, null, 3, null)
19
+ ]
20
+ }, {
21
+ "data-qwikest-icon": true,
22
+ fill: "none",
23
+ height: "1em",
24
+ stroke: "currentColor",
25
+ "stroke-linecap": "round",
26
+ "stroke-linejoin": "round",
27
+ "stroke-width": "2",
28
+ viewBox: "0 0 24 24",
29
+ width: "1em",
30
+ xmlns: "http://www.w3.org/2000/svg"
31
+ }, 0, "Sp_0");
32
+ exports.LuFolderTree = LuFolderTree;
@@ -0,0 +1,32 @@
1
+ import { _jsxS, _jsxQ } from "@qwik.dev/core";
2
+ const LuFolderTree = (props) => /* @__PURE__ */ _jsxS("svg", {
3
+ ...props,
4
+ children: [
5
+ /* @__PURE__ */ _jsxQ("path", null, {
6
+ d: "M13 10h7a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z"
7
+ }, null, 3, null),
8
+ /* @__PURE__ */ _jsxQ("path", null, {
9
+ d: "M13 21h7a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.88a1 1 0 0 1-.9-.55l-.44-.9a1 1 0 0 0-.9-.55H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z"
10
+ }, null, 3, null),
11
+ /* @__PURE__ */ _jsxQ("path", null, {
12
+ d: "M3 3v2c0 1.1.9 2 2 2h3"
13
+ }, null, 3, null),
14
+ /* @__PURE__ */ _jsxQ("path", null, {
15
+ d: "M3 3v13c0 1.1.9 2 2 2h3"
16
+ }, null, 3, null)
17
+ ]
18
+ }, {
19
+ "data-qwikest-icon": true,
20
+ fill: "none",
21
+ height: "1em",
22
+ stroke: "currentColor",
23
+ "stroke-linecap": "round",
24
+ "stroke-linejoin": "round",
25
+ "stroke-width": "2",
26
+ viewBox: "0 0 24 24",
27
+ width: "1em",
28
+ xmlns: "http://www.w3.org/2000/svg"
29
+ }, 0, "Sp_0");
30
+ export {
31
+ LuFolderTree
32
+ };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ var balancedMatch = balanced;
4
+ function balanced(a, b, str) {
5
+ if (a instanceof RegExp) a = maybeMatch(a, str);
6
+ if (b instanceof RegExp) b = maybeMatch(b, str);
7
+ var r = range(a, b, str);
8
+ return r && {
9
+ start: r[0],
10
+ end: r[1],
11
+ pre: str.slice(0, r[0]),
12
+ body: str.slice(r[0] + a.length, r[1]),
13
+ post: str.slice(r[1] + b.length)
14
+ };
15
+ }
16
+ function maybeMatch(reg, str) {
17
+ var m = str.match(reg);
18
+ return m ? m[0] : null;
19
+ }
20
+ balanced.range = range;
21
+ function range(a, b, str) {
22
+ var begs, beg, left, right, result;
23
+ var ai = str.indexOf(a);
24
+ var bi = str.indexOf(b, ai + 1);
25
+ var i = ai;
26
+ if (ai >= 0 && bi > 0) {
27
+ if (a === b) {
28
+ return [ai, bi];
29
+ }
30
+ begs = [];
31
+ left = str.length;
32
+ while (i >= 0 && !result) {
33
+ if (i == ai) {
34
+ begs.push(i);
35
+ ai = str.indexOf(a, i + 1);
36
+ } else if (begs.length == 1) {
37
+ result = [begs.pop(), bi];
38
+ } else {
39
+ beg = begs.pop();
40
+ if (beg < left) {
41
+ left = beg;
42
+ right = bi;
43
+ }
44
+ bi = str.indexOf(b, i + 1);
45
+ }
46
+ i = ai < bi && ai >= 0 ? ai : bi;
47
+ }
48
+ if (begs.length) {
49
+ result = [left, right];
50
+ }
51
+ }
52
+ return result;
53
+ }
54
+ exports.balancedMatch = balancedMatch;
@@ -0,0 +1,54 @@
1
+ var balancedMatch = balanced;
2
+ function balanced(a, b, str) {
3
+ if (a instanceof RegExp) a = maybeMatch(a, str);
4
+ if (b instanceof RegExp) b = maybeMatch(b, str);
5
+ var r = range(a, b, str);
6
+ return r && {
7
+ start: r[0],
8
+ end: r[1],
9
+ pre: str.slice(0, r[0]),
10
+ body: str.slice(r[0] + a.length, r[1]),
11
+ post: str.slice(r[1] + b.length)
12
+ };
13
+ }
14
+ function maybeMatch(reg, str) {
15
+ var m = str.match(reg);
16
+ return m ? m[0] : null;
17
+ }
18
+ balanced.range = range;
19
+ function range(a, b, str) {
20
+ var begs, beg, left, right, result;
21
+ var ai = str.indexOf(a);
22
+ var bi = str.indexOf(b, ai + 1);
23
+ var i = ai;
24
+ if (ai >= 0 && bi > 0) {
25
+ if (a === b) {
26
+ return [ai, bi];
27
+ }
28
+ begs = [];
29
+ left = str.length;
30
+ while (i >= 0 && !result) {
31
+ if (i == ai) {
32
+ begs.push(i);
33
+ ai = str.indexOf(a, i + 1);
34
+ } else if (begs.length == 1) {
35
+ result = [begs.pop(), bi];
36
+ } else {
37
+ beg = begs.pop();
38
+ if (beg < left) {
39
+ left = beg;
40
+ right = bi;
41
+ }
42
+ bi = str.indexOf(b, i + 1);
43
+ }
44
+ i = ai < bi && ai >= 0 ? ai : bi;
45
+ }
46
+ if (begs.length) {
47
+ result = [left, right];
48
+ }
49
+ }
50
+ return result;
51
+ }
52
+ export {
53
+ balancedMatch as b
54
+ };
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const DEFAULT_TIMEOUT = 6e4;
4
+ function defaultSerialize(i) {
5
+ return i;
6
+ }
7
+ const defaultDeserialize = defaultSerialize;
8
+ const { clearTimeout, setTimeout } = globalThis;
9
+ const random = Math.random.bind(Math);
10
+ function createBirpc(functions, options) {
11
+ const {
12
+ post,
13
+ on,
14
+ off = () => {
15
+ },
16
+ eventNames = [],
17
+ serialize = defaultSerialize,
18
+ deserialize = defaultDeserialize,
19
+ resolver,
20
+ bind = "rpc",
21
+ timeout = DEFAULT_TIMEOUT
22
+ } = options;
23
+ const rpcPromiseMap = /* @__PURE__ */ new Map();
24
+ let _promise;
25
+ let closed = false;
26
+ const rpc = new Proxy({}, {
27
+ get(_, method) {
28
+ if (method === "$functions")
29
+ return functions;
30
+ if (method === "$close")
31
+ return close;
32
+ if (method === "then" && !eventNames.includes("then") && !("then" in functions))
33
+ return void 0;
34
+ const sendEvent = (...args) => {
35
+ post(serialize({ m: method, a: args, t: "q" }));
36
+ };
37
+ if (eventNames.includes(method)) {
38
+ sendEvent.asEvent = sendEvent;
39
+ return sendEvent;
40
+ }
41
+ const sendCall = async (...args) => {
42
+ if (closed)
43
+ throw new Error(`[birpc] rpc is closed, cannot call "${method}"`);
44
+ if (_promise) {
45
+ try {
46
+ await _promise;
47
+ } finally {
48
+ _promise = void 0;
49
+ }
50
+ }
51
+ return new Promise((resolve, reject) => {
52
+ const id = nanoid();
53
+ let timeoutId;
54
+ if (timeout >= 0) {
55
+ timeoutId = setTimeout(() => {
56
+ try {
57
+ options.onTimeoutError?.(method, args);
58
+ throw new Error(`[birpc] timeout on calling "${method}"`);
59
+ } catch (e) {
60
+ reject(e);
61
+ }
62
+ rpcPromiseMap.delete(id);
63
+ }, timeout);
64
+ if (typeof timeoutId === "object")
65
+ timeoutId = timeoutId.unref?.();
66
+ }
67
+ rpcPromiseMap.set(id, { resolve, reject, timeoutId, method });
68
+ post(serialize({ m: method, a: args, i: id, t: "q" }));
69
+ });
70
+ };
71
+ sendCall.asEvent = sendEvent;
72
+ return sendCall;
73
+ }
74
+ });
75
+ function close() {
76
+ closed = true;
77
+ rpcPromiseMap.forEach(({ reject, method }) => {
78
+ reject(new Error(`[birpc] rpc is closed, cannot call "${method}"`));
79
+ });
80
+ rpcPromiseMap.clear();
81
+ off(onMessage);
82
+ }
83
+ async function onMessage(data, ...extra) {
84
+ const msg = deserialize(data);
85
+ if (msg.t === "q") {
86
+ const { m: method, a: args } = msg;
87
+ let result, error;
88
+ const fn = resolver ? resolver(method, functions[method]) : functions[method];
89
+ if (!fn) {
90
+ error = new Error(`[birpc] function "${method}" not found`);
91
+ } else {
92
+ try {
93
+ result = await fn.apply(bind === "rpc" ? rpc : functions, args);
94
+ } catch (e) {
95
+ error = e;
96
+ }
97
+ }
98
+ if (msg.i) {
99
+ if (error && options.onError)
100
+ options.onError(error, method, args);
101
+ post(serialize({ t: "s", i: msg.i, r: result, e: error }), ...extra);
102
+ }
103
+ } else {
104
+ const { i: ack, r: result, e: error } = msg;
105
+ const promise = rpcPromiseMap.get(ack);
106
+ if (promise) {
107
+ clearTimeout(promise.timeoutId);
108
+ if (error)
109
+ promise.reject(error);
110
+ else
111
+ promise.resolve(result);
112
+ }
113
+ rpcPromiseMap.delete(ack);
114
+ }
115
+ }
116
+ _promise = on(onMessage);
117
+ return rpc;
118
+ }
119
+ const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
120
+ function nanoid(size = 21) {
121
+ let id = "";
122
+ let i = size;
123
+ while (i--)
124
+ id += urlAlphabet[random() * 64 | 0];
125
+ return id;
126
+ }
127
+ exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
128
+ exports.createBirpc = createBirpc;
@@ -0,0 +1,128 @@
1
+ const DEFAULT_TIMEOUT = 6e4;
2
+ function defaultSerialize(i) {
3
+ return i;
4
+ }
5
+ const defaultDeserialize = defaultSerialize;
6
+ const { clearTimeout, setTimeout } = globalThis;
7
+ const random = Math.random.bind(Math);
8
+ function createBirpc(functions, options) {
9
+ const {
10
+ post,
11
+ on,
12
+ off = () => {
13
+ },
14
+ eventNames = [],
15
+ serialize = defaultSerialize,
16
+ deserialize = defaultDeserialize,
17
+ resolver,
18
+ bind = "rpc",
19
+ timeout = DEFAULT_TIMEOUT
20
+ } = options;
21
+ const rpcPromiseMap = /* @__PURE__ */ new Map();
22
+ let _promise;
23
+ let closed = false;
24
+ const rpc = new Proxy({}, {
25
+ get(_, method) {
26
+ if (method === "$functions")
27
+ return functions;
28
+ if (method === "$close")
29
+ return close;
30
+ if (method === "then" && !eventNames.includes("then") && !("then" in functions))
31
+ return void 0;
32
+ const sendEvent = (...args) => {
33
+ post(serialize({ m: method, a: args, t: "q" }));
34
+ };
35
+ if (eventNames.includes(method)) {
36
+ sendEvent.asEvent = sendEvent;
37
+ return sendEvent;
38
+ }
39
+ const sendCall = async (...args) => {
40
+ if (closed)
41
+ throw new Error(`[birpc] rpc is closed, cannot call "${method}"`);
42
+ if (_promise) {
43
+ try {
44
+ await _promise;
45
+ } finally {
46
+ _promise = void 0;
47
+ }
48
+ }
49
+ return new Promise((resolve, reject) => {
50
+ const id = nanoid();
51
+ let timeoutId;
52
+ if (timeout >= 0) {
53
+ timeoutId = setTimeout(() => {
54
+ try {
55
+ options.onTimeoutError?.(method, args);
56
+ throw new Error(`[birpc] timeout on calling "${method}"`);
57
+ } catch (e) {
58
+ reject(e);
59
+ }
60
+ rpcPromiseMap.delete(id);
61
+ }, timeout);
62
+ if (typeof timeoutId === "object")
63
+ timeoutId = timeoutId.unref?.();
64
+ }
65
+ rpcPromiseMap.set(id, { resolve, reject, timeoutId, method });
66
+ post(serialize({ m: method, a: args, i: id, t: "q" }));
67
+ });
68
+ };
69
+ sendCall.asEvent = sendEvent;
70
+ return sendCall;
71
+ }
72
+ });
73
+ function close() {
74
+ closed = true;
75
+ rpcPromiseMap.forEach(({ reject, method }) => {
76
+ reject(new Error(`[birpc] rpc is closed, cannot call "${method}"`));
77
+ });
78
+ rpcPromiseMap.clear();
79
+ off(onMessage);
80
+ }
81
+ async function onMessage(data, ...extra) {
82
+ const msg = deserialize(data);
83
+ if (msg.t === "q") {
84
+ const { m: method, a: args } = msg;
85
+ let result, error;
86
+ const fn = resolver ? resolver(method, functions[method]) : functions[method];
87
+ if (!fn) {
88
+ error = new Error(`[birpc] function "${method}" not found`);
89
+ } else {
90
+ try {
91
+ result = await fn.apply(bind === "rpc" ? rpc : functions, args);
92
+ } catch (e) {
93
+ error = e;
94
+ }
95
+ }
96
+ if (msg.i) {
97
+ if (error && options.onError)
98
+ options.onError(error, method, args);
99
+ post(serialize({ t: "s", i: msg.i, r: result, e: error }), ...extra);
100
+ }
101
+ } else {
102
+ const { i: ack, r: result, e: error } = msg;
103
+ const promise = rpcPromiseMap.get(ack);
104
+ if (promise) {
105
+ clearTimeout(promise.timeoutId);
106
+ if (error)
107
+ promise.reject(error);
108
+ else
109
+ promise.resolve(result);
110
+ }
111
+ rpcPromiseMap.delete(ack);
112
+ }
113
+ }
114
+ _promise = on(onMessage);
115
+ return rpc;
116
+ }
117
+ const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
118
+ function nanoid(size = 21) {
119
+ let id = "";
120
+ let i = size;
121
+ while (i--)
122
+ id += urlAlphabet[random() * 64 | 0];
123
+ return id;
124
+ }
125
+ export {
126
+ DEFAULT_TIMEOUT,
127
+ createBirpc
128
+ };
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ const _commonjsHelpers = require("../../../../../_virtual/_commonjsHelpers.qwik.cjs");
3
+ const index = require("../../../balanced-match@1.0.2/node_modules/balanced-match/index.qwik.cjs");
4
+ var balanced = index.balancedMatch;
5
+ var braceExpansion = expandTop;
6
+ var escSlash = "\0SLASH" + Math.random() + "\0";
7
+ var escOpen = "\0OPEN" + Math.random() + "\0";
8
+ var escClose = "\0CLOSE" + Math.random() + "\0";
9
+ var escComma = "\0COMMA" + Math.random() + "\0";
10
+ var escPeriod = "\0PERIOD" + Math.random() + "\0";
11
+ function numeric(str) {
12
+ return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
13
+ }
14
+ function escapeBraces(str) {
15
+ return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
16
+ }
17
+ function unescapeBraces(str) {
18
+ return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
19
+ }
20
+ function parseCommaParts(str) {
21
+ if (!str)
22
+ return [""];
23
+ var parts = [];
24
+ var m = balanced("{", "}", str);
25
+ if (!m)
26
+ return str.split(",");
27
+ var pre = m.pre;
28
+ var body = m.body;
29
+ var post = m.post;
30
+ var p = pre.split(",");
31
+ p[p.length - 1] += "{" + body + "}";
32
+ var postParts = parseCommaParts(post);
33
+ if (post.length) {
34
+ p[p.length - 1] += postParts.shift();
35
+ p.push.apply(p, postParts);
36
+ }
37
+ parts.push.apply(parts, p);
38
+ return parts;
39
+ }
40
+ function expandTop(str) {
41
+ if (!str)
42
+ return [];
43
+ if (str.substr(0, 2) === "{}") {
44
+ str = "\\{\\}" + str.substr(2);
45
+ }
46
+ return expand(escapeBraces(str), true).map(unescapeBraces);
47
+ }
48
+ function embrace(str) {
49
+ return "{" + str + "}";
50
+ }
51
+ function isPadded(el) {
52
+ return /^-?0\d/.test(el);
53
+ }
54
+ function lte(i, y) {
55
+ return i <= y;
56
+ }
57
+ function gte(i, y) {
58
+ return i >= y;
59
+ }
60
+ function expand(str, isTop) {
61
+ var expansions = [];
62
+ var m = balanced("{", "}", str);
63
+ if (!m) return [str];
64
+ var pre = m.pre;
65
+ var post = m.post.length ? expand(m.post, false) : [""];
66
+ if (/\$$/.test(m.pre)) {
67
+ for (var k = 0; k < post.length; k++) {
68
+ var expansion = pre + "{" + m.body + "}" + post[k];
69
+ expansions.push(expansion);
70
+ }
71
+ } else {
72
+ var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
73
+ var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
74
+ var isSequence = isNumericSequence || isAlphaSequence;
75
+ var isOptions = m.body.indexOf(",") >= 0;
76
+ if (!isSequence && !isOptions) {
77
+ if (m.post.match(/,.*\}/)) {
78
+ str = m.pre + "{" + m.body + escClose + m.post;
79
+ return expand(str);
80
+ }
81
+ return [str];
82
+ }
83
+ var n;
84
+ if (isSequence) {
85
+ n = m.body.split(/\.\./);
86
+ } else {
87
+ n = parseCommaParts(m.body);
88
+ if (n.length === 1) {
89
+ n = expand(n[0], false).map(embrace);
90
+ if (n.length === 1) {
91
+ return post.map(function(p) {
92
+ return m.pre + n[0] + p;
93
+ });
94
+ }
95
+ }
96
+ }
97
+ var N;
98
+ if (isSequence) {
99
+ var x = numeric(n[0]);
100
+ var y = numeric(n[1]);
101
+ var width = Math.max(n[0].length, n[1].length);
102
+ var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
103
+ var test = lte;
104
+ var reverse = y < x;
105
+ if (reverse) {
106
+ incr *= -1;
107
+ test = gte;
108
+ }
109
+ var pad = n.some(isPadded);
110
+ N = [];
111
+ for (var i = x; test(i, y); i += incr) {
112
+ var c;
113
+ if (isAlphaSequence) {
114
+ c = String.fromCharCode(i);
115
+ if (c === "\\")
116
+ c = "";
117
+ } else {
118
+ c = String(i);
119
+ if (pad) {
120
+ var need = width - c.length;
121
+ if (need > 0) {
122
+ var z = new Array(need + 1).join("0");
123
+ if (i < 0)
124
+ c = "-" + z + c.slice(1);
125
+ else
126
+ c = z + c;
127
+ }
128
+ }
129
+ }
130
+ N.push(c);
131
+ }
132
+ } else {
133
+ N = [];
134
+ for (var j = 0; j < n.length; j++) {
135
+ N.push.apply(N, expand(n[j], false));
136
+ }
137
+ }
138
+ for (var j = 0; j < N.length; j++) {
139
+ for (var k = 0; k < post.length; k++) {
140
+ var expansion = pre + N[j] + post[k];
141
+ if (!isTop || isSequence || expansion)
142
+ expansions.push(expansion);
143
+ }
144
+ }
145
+ }
146
+ return expansions;
147
+ }
148
+ const expand$1 = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(braceExpansion);
149
+ module.exports = expand$1;