@webquark/core 1.1.0-dev.9 → 1.1.1-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/dist/browser/components/q-control-group.d.ts +1 -0
  2. package/dist/browser/components/q-control-group.js +1 -0
  3. package/dist/browser/components/q-divider.d.ts +1 -0
  4. package/dist/browser/components/q-divider.js +1 -0
  5. package/dist/browser/components/q-slider.d.ts +1 -0
  6. package/dist/browser/components/q-slider.js +1 -0
  7. package/dist/browser/components/q-syntax-view.d.ts +1 -0
  8. package/dist/browser/components/q-syntax-view.js +1 -0
  9. package/dist/browser/webquark.css +1 -1
  10. package/dist/playground/assets/reel-motion.webm +0 -0
  11. package/dist/playground/build/p-014c2f4a.entry.js +1 -0
  12. package/dist/playground/build/p-0389577c.entry.js +1 -0
  13. package/dist/playground/build/p-041e17c1.entry.js +1 -0
  14. package/dist/playground/build/p-0479c571.entry.js +1 -0
  15. package/dist/playground/build/p-0ebca9be.entry.js +1 -0
  16. package/dist/playground/build/{p-fe8c634a.entry.js → p-1bf375f7.entry.js} +2 -2
  17. package/dist/playground/build/{p-6bfffa79.entry.js → p-20dc3ab5.entry.js} +1 -1
  18. package/dist/playground/build/p-28d3348f.entry.js +1 -0
  19. package/dist/playground/build/p-35c177d3.entry.js +1 -0
  20. package/dist/playground/build/{p-99d785ca.entry.js → p-3a60086d.entry.js} +1 -1
  21. package/dist/playground/build/{p-3bc4629c.entry.js → p-3ab798aa.entry.js} +1 -1
  22. package/dist/playground/build/{p-9e78b796.entry.js → p-3b580baf.entry.js} +1 -1
  23. package/dist/playground/build/{p-888e46a8.entry.js → p-3b65f787.entry.js} +1 -1
  24. package/dist/playground/build/p-45f6e9ec.css +1 -0
  25. package/dist/playground/build/p-4bf610f8.entry.js +1 -0
  26. package/dist/playground/build/{p-4d61b70d.entry.js → p-4d30227e.entry.js} +1 -1
  27. package/dist/playground/build/{p-70d9ffde.entry.js → p-4de536ae.entry.js} +1 -1
  28. package/dist/playground/build/{p-90b0858c.entry.js → p-4e4d70c9.entry.js} +1 -1
  29. package/dist/playground/build/p-4efeb7c9.entry.js +1 -0
  30. package/dist/playground/build/{p-dd115868.entry.js → p-51b3d71b.entry.js} +1 -1
  31. package/dist/playground/build/p-778b6bbb.entry.js +1 -0
  32. package/dist/playground/build/{p-f63b7214.entry.js → p-7da78b2f.entry.js} +1 -1
  33. package/dist/playground/build/{p-9ff7e5a4.entry.js → p-7f8f986b.entry.js} +1 -1
  34. package/dist/playground/build/p-8253c742.entry.js +1 -0
  35. package/dist/playground/build/{p-059daa8a.entry.js → p-9a1ddeb7.entry.js} +1 -1
  36. package/dist/playground/build/p-B610wOGe.js +1 -0
  37. package/dist/playground/build/p-BxxU73QQ.js +1 -0
  38. package/dist/playground/build/p-CIMzZPQO.js +3 -0
  39. package/dist/playground/build/p-CfR85WgM.js +13 -0
  40. package/dist/playground/build/{p-Dhsn99q4.js → p-D8p28N9s.js} +1 -1
  41. package/dist/playground/build/p-DbzjRzhu.js +1 -0
  42. package/dist/playground/build/{p-BOdNg0jc.js → p-DeOEN0si.js} +1 -1
  43. package/dist/playground/build/{p-d0fbd2b1.entry.js → p-a2b1de23.entry.js} +1 -1
  44. package/dist/playground/build/{p-48fb5228.entry.js → p-a55edc17.entry.js} +1 -1
  45. package/dist/playground/build/p-a8808020.entry.js +1 -0
  46. package/dist/playground/build/{p-f4f97e74.entry.js → p-b1084b3c.entry.js} +1 -1
  47. package/dist/playground/build/{p-36118d90.entry.js → p-b6c4dff4.entry.js} +1 -1
  48. package/dist/playground/build/p-b962e950.entry.js +1 -0
  49. package/dist/playground/build/{p-023f8437.entry.js → p-bc369cd6.entry.js} +1 -1
  50. package/dist/playground/build/p-c119a8ea.entry.js +1 -0
  51. package/dist/playground/build/p-c6b77e9a.entry.js +1 -0
  52. package/dist/playground/build/{p-030ecde3.entry.js → p-ca1c03b4.entry.js} +1 -1
  53. package/dist/playground/build/{p-8ece2c62.entry.js → p-ce436162.entry.js} +1 -1
  54. package/dist/playground/build/{p-0aa74ad6.entry.js → p-d0a47a7c.entry.js} +1 -1
  55. package/dist/playground/build/{p-fec6fe0a.entry.js → p-e1fbc8fc.entry.js} +1 -1
  56. package/dist/playground/build/{p-09cca7b9.entry.js → p-e32833ce.entry.js} +1 -1
  57. package/dist/playground/build/p-e369a4aa.entry.js +1 -0
  58. package/dist/playground/build/p-e4430c61.entry.js +1 -0
  59. package/dist/playground/build/{p-f9ad63ff.entry.js → p-e9c0052b.entry.js} +1 -1
  60. package/dist/playground/build/{p-f1bac94c.entry.js → p-f5c4ca18.entry.js} +1 -1
  61. package/dist/playground/build/{p-64096386.entry.js → p-f6683126.entry.js} +1 -1
  62. package/dist/playground/build/{p-DWO-pleQ.js → p-ojSDiptZ.js} +1 -1
  63. package/dist/playground/build/webquark.css +1 -1
  64. package/dist/playground/build/webquark.esm.js +1 -1
  65. package/dist/playground/css/base.css +17 -44
  66. package/dist/playground/formatters/prettier/LICENSE +7 -0
  67. package/dist/playground/formatters/prettier/THIRD-PARTY-NOTICES.md +7941 -0
  68. package/dist/playground/formatters/prettier/html-fragment.mjs +1 -0
  69. package/dist/playground/formatters/prettier/html-fragment.mjs.gz +0 -0
  70. package/dist/playground/formatters/prettier/languages/angular.mjs +1 -0
  71. package/dist/playground/formatters/prettier/languages/angular.mjs.gz +0 -0
  72. package/dist/playground/formatters/prettier/languages/css.mjs +1 -0
  73. package/dist/playground/formatters/prettier/languages/css.mjs.gz +0 -0
  74. package/dist/playground/formatters/prettier/languages/flow.mjs +1 -0
  75. package/dist/playground/formatters/prettier/languages/flow.mjs.gz +0 -0
  76. package/dist/playground/formatters/prettier/languages/graphql.mjs +1 -0
  77. package/dist/playground/formatters/prettier/languages/graphql.mjs.gz +0 -0
  78. package/dist/playground/formatters/prettier/languages/handlebars.mjs +1 -0
  79. package/dist/playground/formatters/prettier/languages/handlebars.mjs.gz +0 -0
  80. package/dist/playground/formatters/prettier/languages/html.mjs +1 -0
  81. package/dist/playground/formatters/prettier/languages/html.mjs.gz +0 -0
  82. package/dist/playground/formatters/prettier/languages/javascript.mjs +1 -0
  83. package/dist/playground/formatters/prettier/languages/javascript.mjs.gz +0 -0
  84. package/dist/playground/formatters/prettier/languages/json-stringify.mjs +1 -0
  85. package/dist/playground/formatters/prettier/languages/json-stringify.mjs.gz +0 -0
  86. package/dist/playground/formatters/prettier/languages/json.mjs +1 -0
  87. package/dist/playground/formatters/prettier/languages/json.mjs.gz +0 -0
  88. package/dist/playground/formatters/prettier/languages/json5.mjs +1 -0
  89. package/dist/playground/formatters/prettier/languages/json5.mjs.gz +0 -0
  90. package/dist/playground/formatters/prettier/languages/jsonc.mjs +1 -0
  91. package/dist/playground/formatters/prettier/languages/jsonc.mjs.gz +0 -0
  92. package/dist/playground/formatters/prettier/languages/jsx.mjs +1 -0
  93. package/dist/playground/formatters/prettier/languages/jsx.mjs.gz +0 -0
  94. package/dist/playground/formatters/prettier/languages/less.mjs +1 -0
  95. package/dist/playground/formatters/prettier/languages/less.mjs.gz +0 -0
  96. package/dist/playground/formatters/prettier/languages/lwc.mjs +1 -0
  97. package/dist/playground/formatters/prettier/languages/lwc.mjs.gz +0 -0
  98. package/dist/playground/formatters/prettier/languages/markdown.mjs +1 -0
  99. package/dist/playground/formatters/prettier/languages/markdown.mjs.gz +0 -0
  100. package/dist/playground/formatters/prettier/languages/mdx.mjs +1 -0
  101. package/dist/playground/formatters/prettier/languages/mdx.mjs.gz +0 -0
  102. package/dist/playground/formatters/prettier/languages/mjml.mjs +1 -0
  103. package/dist/playground/formatters/prettier/languages/mjml.mjs.gz +0 -0
  104. package/dist/playground/formatters/prettier/languages/postcss.mjs +1 -0
  105. package/dist/playground/formatters/prettier/languages/postcss.mjs.gz +0 -0
  106. package/dist/playground/formatters/prettier/languages/scss.mjs +1 -0
  107. package/dist/playground/formatters/prettier/languages/scss.mjs.gz +0 -0
  108. package/dist/playground/formatters/prettier/languages/tsx.mjs +1 -0
  109. package/dist/playground/formatters/prettier/languages/tsx.mjs.gz +0 -0
  110. package/dist/playground/formatters/prettier/languages/typescript.mjs +1 -0
  111. package/dist/playground/formatters/prettier/languages/typescript.mjs.gz +0 -0
  112. package/dist/playground/formatters/prettier/languages/vue.mjs +1 -0
  113. package/dist/playground/formatters/prettier/languages/vue.mjs.gz +0 -0
  114. package/dist/playground/formatters/prettier/languages/yaml.mjs +1 -0
  115. package/dist/playground/formatters/prettier/languages/yaml.mjs.gz +0 -0
  116. package/dist/playground/formatters/prettier/manifest.json +87 -0
  117. package/dist/playground/formatters/prettier/plugins/acorn.mjs +17 -0
  118. package/dist/playground/formatters/prettier/plugins/acorn.mjs.gz +0 -0
  119. package/dist/playground/formatters/prettier/plugins/angular.mjs +7 -0
  120. package/dist/playground/formatters/prettier/plugins/angular.mjs.gz +0 -0
  121. package/dist/playground/formatters/prettier/plugins/babel.mjs +16 -0
  122. package/dist/playground/formatters/prettier/plugins/babel.mjs.gz +0 -0
  123. package/dist/playground/formatters/prettier/plugins/estree.mjs +44 -0
  124. package/dist/playground/formatters/prettier/plugins/estree.mjs.gz +0 -0
  125. package/dist/playground/formatters/prettier/plugins/flow.mjs +7 -0
  126. package/dist/playground/formatters/prettier/plugins/flow.mjs.gz +0 -0
  127. package/dist/playground/formatters/prettier/plugins/glimmer.mjs +37 -0
  128. package/dist/playground/formatters/prettier/plugins/glimmer.mjs.gz +0 -0
  129. package/dist/playground/formatters/prettier/plugins/graphql.mjs +17 -0
  130. package/dist/playground/formatters/prettier/plugins/graphql.mjs.gz +0 -0
  131. package/dist/playground/formatters/prettier/plugins/html.mjs +25 -0
  132. package/dist/playground/formatters/prettier/plugins/html.mjs.gz +0 -0
  133. package/dist/playground/formatters/prettier/plugins/markdown.mjs +70 -0
  134. package/dist/playground/formatters/prettier/plugins/markdown.mjs.gz +0 -0
  135. package/dist/playground/formatters/prettier/plugins/meriyah.mjs +9 -0
  136. package/dist/playground/formatters/prettier/plugins/meriyah.mjs.gz +0 -0
  137. package/dist/playground/formatters/prettier/plugins/postcss.mjs +62 -0
  138. package/dist/playground/formatters/prettier/plugins/postcss.mjs.gz +0 -0
  139. package/dist/playground/formatters/prettier/plugins/typescript.mjs +22 -0
  140. package/dist/playground/formatters/prettier/plugins/typescript.mjs.gz +0 -0
  141. package/dist/playground/formatters/prettier/plugins/yaml.mjs +150 -0
  142. package/dist/playground/formatters/prettier/plugins/yaml.mjs.gz +0 -0
  143. package/dist/playground/formatters/prettier/runtime.d.mts +2 -0
  144. package/dist/playground/formatters/prettier/runtime.mjs +1 -0
  145. package/dist/playground/formatters/prettier/runtime.mjs.gz +0 -0
  146. package/dist/playground/formatters/prettier/standalone.mjs +29 -0
  147. package/dist/playground/formatters/prettier/standalone.mjs.gz +0 -0
  148. package/dist/playground/index.html +1 -1
  149. package/dist/playground/playground/components.manifest.json +54 -41
  150. package/dist/playground/playground/consumer.html +27 -0
  151. package/dist/playground/playground/specs/q-accordion.sandbox.json +38 -0
  152. package/dist/playground/playground/specs/q-alert.sandbox.json +95 -0
  153. package/dist/playground/playground/specs/q-avatar.sandbox.json +39 -6
  154. package/dist/playground/playground/specs/q-banner.sandbox.json +66 -0
  155. package/dist/playground/playground/specs/q-button.sandbox.json +115 -15
  156. package/dist/playground/playground/specs/q-card.sandbox.json +50 -9
  157. package/dist/playground/playground/specs/q-carousel.sandbox.json +109 -6
  158. package/dist/playground/playground/specs/q-chip.sandbox.json +29 -2
  159. package/dist/playground/playground/specs/q-control-group.sandbox.json +30 -0
  160. package/dist/playground/playground/specs/q-conversation-bubble.sandbox.json +13 -2
  161. package/dist/playground/playground/specs/q-data-table.sandbox.json +137 -12
  162. package/dist/playground/playground/specs/q-dialog.sandbox.json +62 -5
  163. package/dist/playground/playground/specs/q-divider.sandbox.json +20 -0
  164. package/dist/playground/playground/specs/q-dropdown.sandbox.json +186 -22
  165. package/dist/playground/playground/specs/q-form.sandbox.json +66 -1
  166. package/dist/playground/playground/specs/q-grid.sandbox.json +37 -1
  167. package/dist/playground/playground/specs/q-icon.sandbox.json +62 -23
  168. package/dist/playground/playground/specs/q-image-comparison.sandbox.json +41 -5
  169. package/dist/playground/playground/specs/q-inline.sandbox.json +41 -0
  170. package/dist/playground/playground/specs/q-input.sandbox.json +77 -5
  171. package/dist/playground/playground/specs/q-link.sandbox.json +213 -17
  172. package/dist/playground/playground/specs/q-map.sandbox.json +434 -28
  173. package/dist/playground/playground/specs/q-media.sandbox.json +85 -0
  174. package/dist/playground/playground/specs/q-navbar.sandbox.json +378 -29
  175. package/dist/playground/playground/specs/q-pagination.sandbox.json +89 -0
  176. package/dist/playground/playground/specs/q-panel.sandbox.json +63 -2
  177. package/dist/playground/playground/specs/q-progress.sandbox.json +37 -11
  178. package/dist/playground/playground/specs/q-quantity-selector.sandbox.json +15 -3
  179. package/dist/playground/playground/specs/q-radio-group.sandbox.json +94 -14
  180. package/dist/playground/playground/specs/q-reel.sandbox.json +22 -5
  181. package/dist/playground/playground/specs/q-scrollable.sandbox.json +16 -0
  182. package/dist/playground/playground/specs/q-section.sandbox.json +69 -0
  183. package/dist/playground/playground/specs/q-sidepanel.sandbox.json +271 -12
  184. package/dist/playground/playground/specs/q-slider.sandbox.json +104 -0
  185. package/dist/playground/playground/specs/q-stack.sandbox.json +13 -2
  186. package/dist/playground/playground/specs/q-step-diagram-item.sandbox.json +101 -0
  187. package/dist/playground/playground/specs/q-step-diagram.sandbox.json +29 -1
  188. package/dist/playground/playground/specs/q-syntax-box.sandbox.json +85 -8
  189. package/dist/playground/playground/specs/q-syntax-view.sandbox.json +45 -0
  190. package/dist/playground/playground/specs/q-tabs.sandbox.json +164 -0
  191. package/dist/playground/playground/specs/q-textarea.sandbox.json +50 -0
  192. package/dist/playground/playground/specs/q-thumbnail.sandbox.json +67 -0
  193. package/dist/playground/playground/specs/q-toast.sandbox.json +19 -8
  194. package/dist/playground/playground/specs/q-toggle.sandbox.json +22 -2
  195. package/dist/playground/playground/specs/q-toolbar.sandbox.json +55 -0
  196. package/dist/playground/playground/specs/q-tooltip.sandbox.json +18 -2
  197. package/dist/playground/playground.js +3986 -2002
  198. package/dist/playground/presets.html +70 -15
  199. package/dist/playground/views/tooling/tooling.html +5 -5
  200. package/package.json +4 -4
  201. package/scripts/webquark-serve.js +3 -82
  202. package/scripts/wq-changelog.js +0 -0
  203. package/scripts/wq-switch/README.md +52 -15
  204. package/scripts/wq-switch/dist/index.js +1 -1200
  205. package/scripts/wq-switch/dist/setup.js +1 -894
  206. package/dist/playground/build/p-04c8cb9e.entry.js +0 -1
  207. package/dist/playground/build/p-0ae43d6c.entry.js +0 -1
  208. package/dist/playground/build/p-0c3aac3f.entry.js +0 -1
  209. package/dist/playground/build/p-144ef339.entry.js +0 -1
  210. package/dist/playground/build/p-296fbdb1.entry.js +0 -1
  211. package/dist/playground/build/p-5f232b44.entry.js +0 -13
  212. package/dist/playground/build/p-6e28cfe2.entry.js +0 -1
  213. package/dist/playground/build/p-91fff6b6.entry.js +0 -1
  214. package/dist/playground/build/p-923dac41.entry.js +0 -1
  215. package/dist/playground/build/p-97a89cae.entry.js +0 -1
  216. package/dist/playground/build/p-B4Mg1xEw.js +0 -1
  217. package/dist/playground/build/p-B5ElFlHv.js +0 -3
  218. package/dist/playground/build/p-Bj2RJb2E.js +0 -1
  219. package/dist/playground/build/p-ByfrUWx1.js +0 -1
  220. package/dist/playground/build/p-c523ec6f.entry.js +0 -1
  221. package/dist/playground/build/p-c923c9c0.js +0 -1
  222. package/dist/playground/build/p-d0253d64.entry.js +0 -1
  223. package/dist/playground/build/p-e0bb74ae.css +0 -1
  224. package/dist/playground/build/p-f98f9439.entry.js +0 -1
  225. package/dist/playground/build/p-fe200f68.entry.js +0 -1
  226. package/dist/playground/views/tooling/adoption/CHANGELOG.md +0 -13
  227. package/dist/playground/views/tooling/adoption/README.md +0 -47
  228. package/dist/playground/views/tooling/adoption/changelog.config.ts +0 -12
  229. package/dist/playground/views/tooling/adoption/docs/changelog/unreleased/README.md +0 -3
  230. package/dist/playground/views/tooling/adoption/docs/changelog/unreleased/images/release-panel.svg +0 -7
  231. package/dist/playground/views/tooling/adoption/docs/changelog/unreleased/visuals.json +0 -16
  232. package/dist/playground/views/tooling/adoption/docs/changelog/v0.1.0/README.md +0 -3
  233. package/dist/playground/views/tooling/adoption/generate.ts +0 -13
  234. package/dist/playground/views/tooling/adoption/package.json +0 -10
  235. package/dist/playground/views/tooling/adoption/serve.ts +0 -24
  236. package/dist/playground/views/tooling/adoption/viewer.html +0 -16
  237. package/dist/playground/views/tooling/adoption/viewer.js +0 -54
@@ -1,895 +1,2 @@
1
1
  #!/usr/bin/env node
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- function __accessProp(key) {
8
- return this[key];
9
- }
10
- var __toESMCache_node;
11
- var __toESMCache_esm;
12
- var __toESM = (mod, isNodeMode, target) => {
13
- var canCache = mod != null && typeof mod === "object";
14
- if (canCache) {
15
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
- var cached = cache.get(mod);
17
- if (cached)
18
- return cached;
19
- }
20
- target = mod != null ? __create(__getProtoOf(mod)) : {};
21
- const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
- if (mod && typeof mod === "object" || typeof mod === "function") {
23
- for (let key of __getOwnPropNames(mod))
24
- if (!__hasOwnProp.call(to, key))
25
- __defProp(to, key, {
26
- get: __accessProp.bind(mod, key),
27
- enumerable: true
28
- });
29
- }
30
- if (canCache)
31
- cache.set(mod, to);
32
- return to;
33
- };
34
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
35
-
36
- // node_modules/.bun/cmd-shim@8.0.0/node_modules/cmd-shim/lib/to-batch-syntax.js
37
- var require_to_batch_syntax = __commonJS(function(exports2) {
38
- exports2.replaceDollarWithPercentPair = replaceDollarWithPercentPair;
39
- exports2.convertToSetCommand = convertToSetCommand;
40
- exports2.convertToSetCommands = convertToSetCommands;
41
- function convertToSetCommand(key, value) {
42
- var line = "";
43
- key = key || "";
44
- key = key.trim();
45
- value = value || "";
46
- value = value.trim();
47
- if (key && value && value.length > 0) {
48
- line = "@SET " + key + "=" + replaceDollarWithPercentPair(value) + `\r
49
- `;
50
- }
51
- return line;
52
- }
53
- function extractVariableValuePairs(declarations) {
54
- var pairs = {};
55
- declarations.map(function(declaration) {
56
- var split = declaration.split("=");
57
- pairs[split[0]] = split[1];
58
- });
59
- return pairs;
60
- }
61
- function convertToSetCommands(variableString) {
62
- var variableValuePairs = extractVariableValuePairs(variableString.split(" "));
63
- var variableDeclarationsAsBatch = "";
64
- Object.keys(variableValuePairs).forEach(function(key) {
65
- variableDeclarationsAsBatch += convertToSetCommand(key, variableValuePairs[key]);
66
- });
67
- return variableDeclarationsAsBatch;
68
- }
69
- function replaceDollarWithPercentPair(value) {
70
- var dollarExpressions = /\$\{?([^$@#?\- \t{}:]+)\}?/g;
71
- var result = "";
72
- var startIndex = 0;
73
- do {
74
- var match = dollarExpressions.exec(value);
75
- if (match) {
76
- var betweenMatches = value.substring(startIndex, match.index) || "";
77
- result += betweenMatches + "%" + match[1] + "%";
78
- startIndex = dollarExpressions.lastIndex;
79
- }
80
- } while (dollarExpressions.lastIndex > 0);
81
- result += value.slice(startIndex);
82
- return result;
83
- }
84
- });
85
-
86
- // node_modules/.bun/cmd-shim@8.0.0/node_modules/cmd-shim/lib/index.js
87
- var require_lib = __commonJS(function(exports2, module2) {
88
- var {
89
- chmod,
90
- mkdir,
91
- readFile,
92
- stat,
93
- unlink,
94
- writeFile
95
- } = require("fs/promises");
96
- var { dirname, relative } = require("path");
97
- var toBatchSyntax = require_to_batch_syntax();
98
- var shebangExpr = /^#!\s*(?:\/usr\/bin\/env\s+(?:-S\s+)?((?:[^ \t=]+=[^ \t=]+\s+)*))?([^ \t]+)(.*)$/;
99
- var cmdShimIfExists = (from, to) => stat(from).then(() => cmdShim(from, to), () => {});
100
- var rm = (path) => unlink(path).catch(() => {});
101
- var cmdShim = (from, to) => stat(from).then(() => cmdShim_(from, to));
102
- var cmdShim_ = (from, to) => Promise.all([
103
- rm(to),
104
- rm(to + ".cmd"),
105
- rm(to + ".ps1")
106
- ]).then(() => writeShim(from, to));
107
- var writeShim = (from, to) => mkdir(dirname(to), { recursive: true }).then(() => readFile(from, "utf8")).then((data) => {
108
- const firstLine = data.trim().split(/\r*\n/)[0];
109
- const shebang = firstLine.match(shebangExpr);
110
- if (!shebang) {
111
- return writeShim_(from, to);
112
- }
113
- const vars = shebang[1] || "";
114
- const prog = shebang[2];
115
- const args = shebang[3] || "";
116
- return writeShim_(from, to, prog, args, vars);
117
- }, () => writeShim_(from, to));
118
- var writeShim_ = (from, to, prog, args, variables) => {
119
- let shTarget = relative(dirname(to), from);
120
- let target = shTarget.split("/").join("\\");
121
- let longProg;
122
- let shProg = prog && prog.split("\\").join("/");
123
- let shLongProg;
124
- let pwshProg = shProg && `"${shProg}$exe"`;
125
- let pwshLongProg;
126
- shTarget = shTarget.split("\\").join("/");
127
- args = args || "";
128
- variables = variables || "";
129
- if (!prog) {
130
- prog = `"%dp0%\\${target}"`;
131
- shProg = `"$basedir/${shTarget}"`;
132
- pwshProg = shProg;
133
- args = "";
134
- target = "";
135
- shTarget = "";
136
- } else {
137
- longProg = `"%dp0%\\${prog}.exe"`;
138
- shLongProg = `"$basedir/${prog}"`;
139
- pwshLongProg = `"$basedir/${prog}$exe"`;
140
- target = `"%dp0%\\${target}"`;
141
- shTarget = `"$basedir/${shTarget}"`;
142
- }
143
- const head = `@ECHO off\r
144
- ` + `GOTO start\r
145
- ` + `:find_dp0\r
146
- ` + `SET dp0=%~dp0\r
147
- ` + `EXIT /b\r
148
- ` + `:start\r
149
- ` + `SETLOCAL\r
150
- ` + `CALL :find_dp0\r
151
- `;
152
- let cmd;
153
- if (longProg) {
154
- shLongProg = shLongProg.trim();
155
- args = args.trim();
156
- const variablesBatch = toBatchSyntax.convertToSetCommands(variables);
157
- cmd = head + variablesBatch + `\r
158
- ` + `IF EXIST ${longProg} (\r
159
- ` + ` SET "_prog=${longProg.replace(/(^")|("$)/g, "")}"\r
160
- ` + `) ELSE (\r
161
- ` + ` SET "_prog=${prog.replace(/(^")|("$)/g, "")}"\r
162
- ` + ` SET PATHEXT=%PATHEXT:;.JS;=;%\r
163
- ` + `)\r
164
- ` + `\r
165
- ` + "endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & " + `"%_prog%" ${args} ${target} %*\r
166
- `;
167
- } else {
168
- cmd = `${head}${prog} ${args} ${target} %*\r
169
- `;
170
- }
171
- let sh = `#!/bin/sh
172
- `;
173
- sh = sh + `basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
174
- ` + `
175
- ` + "case `uname` in\n" + ` *CYGWIN*|*MINGW*|*MSYS*)
176
- ` + ` if command -v cygpath > /dev/null 2>&1; then
177
- ` + ' basedir=`cygpath -w "$basedir"`\n' + ` fi
178
- ` + ` ;;
179
- ` + `esac
180
- ` + `
181
- `;
182
- if (shLongProg) {
183
- sh = sh + `if [ -x ${shLongProg} ]; then
184
- ` + ` exec ${variables}${shLongProg} ${args} ${shTarget} "$@"
185
- ` + `else
186
- ` + ` exec ${variables}${shProg} ${args} ${shTarget} "$@"
187
- ` + `fi
188
- `;
189
- } else {
190
- sh = sh + `exec ${shProg} ${args} ${shTarget} "$@"
191
- `;
192
- }
193
- let pwsh = `#!/usr/bin/env pwsh
194
- ` + `$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
195
- ` + `
196
- ` + `$exe=""
197
- ` + `if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
198
- ` + ` # Fix case when both the Windows and Linux builds of Node
199
- ` + ` # are installed in the same directory
200
- ` + ` $exe=".exe"
201
- ` + `}
202
- `;
203
- if (shLongProg) {
204
- pwsh = pwsh + `$ret=0
205
- ` + `if (Test-Path ${pwshLongProg}) {
206
- ` + ` # Support pipeline input
207
- ` + ` if ($MyInvocation.ExpectingInput) {
208
- ` + ` $input | & ${pwshLongProg} ${args} ${shTarget} $args
209
- ` + ` } else {
210
- ` + ` & ${pwshLongProg} ${args} ${shTarget} $args
211
- ` + ` }
212
- ` + ` $ret=$LASTEXITCODE
213
- ` + `} else {
214
- ` + ` # Support pipeline input
215
- ` + ` if ($MyInvocation.ExpectingInput) {
216
- ` + ` $input | & ${pwshProg} ${args} ${shTarget} $args
217
- ` + ` } else {
218
- ` + ` & ${pwshProg} ${args} ${shTarget} $args
219
- ` + ` }
220
- ` + ` $ret=$LASTEXITCODE
221
- ` + `}
222
- ` + `exit $ret
223
- `;
224
- } else {
225
- pwsh = pwsh + `# Support pipeline input
226
- ` + `if ($MyInvocation.ExpectingInput) {
227
- ` + ` $input | & ${pwshProg} ${args} ${shTarget} $args
228
- ` + `} else {
229
- ` + ` & ${pwshProg} ${args} ${shTarget} $args
230
- ` + `}
231
- ` + `exit $LASTEXITCODE
232
- `;
233
- }
234
- return Promise.all([
235
- writeFile(to + ".ps1", pwsh, "utf8"),
236
- writeFile(to + ".cmd", cmd, "utf8"),
237
- writeFile(to, sh, "utf8")
238
- ]).then(() => chmodShim(to));
239
- };
240
- var chmodShim = (to) => Promise.all([
241
- chmod(to, 493),
242
- chmod(to + ".cmd", 493),
243
- chmod(to + ".ps1", 493)
244
- ]);
245
- module2.exports = cmdShim;
246
- cmdShim.ifExists = cmdShimIfExists;
247
- });
248
-
249
- // node_modules/.bun/read-cmd-shim@6.0.0/node_modules/read-cmd-shim/lib/index.js
250
- var require_lib2 = __commonJS(function(exports2, module2) {
251
- var fs = require("fs");
252
- var { promisify } = require("util");
253
- var { readFileSync } = fs;
254
- var readFile = promisify(fs.readFile);
255
- var extractPath = (path, cmdshimContents) => {
256
- if (/[.]cmd$/.test(path)) {
257
- return extractPathFromCmd(cmdshimContents);
258
- } else if (/[.]ps1$/.test(path)) {
259
- return extractPathFromPowershell(cmdshimContents);
260
- } else {
261
- return extractPathFromCygwin(cmdshimContents);
262
- }
263
- };
264
- var extractPathFromPowershell = (cmdshimContents) => {
265
- const matches = cmdshimContents.match(/"[$]basedir[/]([^"]+?)"\s+[$]args/);
266
- return matches && matches[1];
267
- };
268
- var extractPathFromCmd = (cmdshimContents) => {
269
- const matches = cmdshimContents.match(/"%(?:~dp0|dp0%)\\([^"]+?)"\s+%[*]/);
270
- return matches && matches[1];
271
- };
272
- var extractPathFromCygwin = (cmdshimContents) => {
273
- const matches = cmdshimContents.match(/"[$]basedir[/]([^"]+?)"\s+"[$]@"/);
274
- return matches && matches[1];
275
- };
276
- var wrapError = (thrown, newError) => {
277
- newError.message = thrown.message;
278
- newError.code = thrown.code;
279
- newError.path = thrown.path;
280
- return newError;
281
- };
282
- var notaShim = (path, er) => {
283
- if (!er) {
284
- er = new Error;
285
- Error.captureStackTrace(er, notaShim);
286
- }
287
- er.code = "ENOTASHIM";
288
- er.message = `Can't read shim path from '${path}', ` + `it doesn't appear to be a cmd-shim`;
289
- return er;
290
- };
291
- var readCmdShim = (path) => {
292
- const er = new Error;
293
- Error.captureStackTrace(er, readCmdShim);
294
- return readFile(path).then((contents) => {
295
- const destination = extractPath(path, contents.toString());
296
- if (destination) {
297
- return destination;
298
- }
299
- throw notaShim(path, er);
300
- }, (readFileEr) => {
301
- throw wrapError(readFileEr, er);
302
- });
303
- };
304
- var readCmdShimSync = (path) => {
305
- const contents = readFileSync(path);
306
- const destination = extractPath(path, contents.toString());
307
- if (!destination) {
308
- throw notaShim(path);
309
- }
310
- return destination;
311
- };
312
- readCmdShim.sync = readCmdShimSync;
313
- module2.exports = readCmdShim;
314
- });
315
-
316
- // scripts/wq-switch/config.ts
317
- var import_node_fs = require("node:fs");
318
- var import_node_path2 = require("node:path");
319
-
320
- // scripts/wq-switch/paths.ts
321
- var import_node_path = require("node:path");
322
- function projectPaths(root) {
323
- const directory = import_node_path.join(root, ".webquark");
324
- const stateDirectory = import_node_path.join(directory, "state");
325
- return {
326
- directory,
327
- config: import_node_path.join(directory, ".webquark.json"),
328
- packages: import_node_path.join(directory, "generated", "packages"),
329
- state: import_node_path.join(stateDirectory, "state.json"),
330
- journal: import_node_path.join(stateDirectory, "journal.json")
331
- };
332
- }
333
-
334
- // scripts/wq-switch/config.ts
335
- var names = ["@webquark/core", "@webquark/browser", "@webquark/tooling", "@webquark/angular", "@webquark/react"];
336
- var packageDirectories = {
337
- "@webquark/core": "packages/core",
338
- "@webquark/browser": "packages/browser/components",
339
- "@webquark/tooling": "packages/tooling",
340
- "@webquark/angular": "packages/browser/angular",
341
- "@webquark/react": "packages/browser/react"
342
- };
343
- var localDependencies = {
344
- "@webquark/core": ["@webquark/browser", "@webquark/tooling"],
345
- "@webquark/browser": [],
346
- "@webquark/tooling": [],
347
- "@webquark/angular": ["@webquark/browser"],
348
- "@webquark/react": ["@webquark/browser"]
349
- };
350
- function readWebQuarkConfig(root) {
351
- const file = projectPaths(root).config;
352
- if (!import_node_fs.existsSync(file))
353
- return {};
354
- const value = json(file);
355
- if (!value || typeof value !== "object" || Array.isArray(value))
356
- throw new Error(`Invalid ${file}; expected a JSON object.`);
357
- return value;
358
- }
359
- function readSwitchConfig(root) {
360
- const document = readWebQuarkConfig(root);
361
- const value = document["wq-switch"];
362
- if (value === undefined)
363
- return;
364
- if (!value || typeof value !== "object" || Array.isArray(value) || value.version !== 1 || typeof value.source !== "string" || value.preferredVersion !== undefined && typeof value.preferredVersion !== "string") {
365
- throw new Error(`Invalid WebQuark wq-switch configuration; existing configuration was not overwritten.`);
366
- }
367
- return value;
368
- }
369
- function json(file) {
370
- return JSON.parse(import_node_fs.readFileSync(file, "utf8"));
371
- }
372
- function manifest(root) {
373
- return json(import_node_path2.join(root, "package.json"));
374
- }
375
- function writeJson(file, value) {
376
- import_node_fs.mkdirSync(import_node_path2.dirname(file), { recursive: true });
377
- const temporary = `${file}.${process.pid}.tmp`;
378
- import_node_fs.writeFileSync(temporary, JSON.stringify(value, null, 2) + `
379
- `);
380
- import_node_fs.renameSync(temporary, file);
381
- }
382
- function consumerRoot(cwd = process.cwd()) {
383
- let root = import_node_path2.resolve(cwd);
384
- while (!import_node_fs.existsSync(import_node_path2.join(root, "package.json"))) {
385
- const parent = import_node_path2.dirname(root);
386
- if (parent === root)
387
- throw new Error("Run this command inside the consuming project.");
388
- root = parent;
389
- }
390
- const pkg = manifest(root);
391
- if (names.includes(pkg.name) || pkg.private && pkg.scripts?.["packages:build"])
392
- throw new Error("Run wq-switch in the consuming app, not the WebQuark repository.");
393
- return import_node_fs.realpathSync(root);
394
- }
395
- function validateSource(source) {
396
- const root = import_node_fs.realpathSync(import_node_path2.resolve(source));
397
- const pkg = manifest(root);
398
- if (!pkg.private || !pkg.scripts?.["packages:build"] || !names.every((name) => import_node_fs.existsSync(import_node_path2.join(root, packageDirectories[name], "package.json")) && manifest(import_node_path2.join(root, packageDirectories[name])).name === name)) {
399
- throw new Error("Source must be the private WebQuark repository root, with packages:build and all five package manifests.");
400
- }
401
- return root;
402
- }
403
- function sourceFor(root) {
404
- const config = readSwitchConfig(root);
405
- if (!config)
406
- throw new Error("First run: wq-setup");
407
- if (!config.source.trim())
408
- throw new Error('Set source inside "wq-switch" in .webquark/.webquark.json to your WebQuark repository, or run wq-setup --source "path/to/WebQuark".');
409
- return validateSource(import_node_path2.resolve(root, config.source));
410
- }
411
- function selectedPackages(root) {
412
- const pkg = manifest(root);
413
- const dependencies = { ...pkg.dependencies, ...pkg.devDependencies };
414
- const selected = new Set(names.filter((name) => dependencies[name]));
415
- if (!selected.size)
416
- throw new Error("The consuming project must declare a WebQuark package.");
417
- for (const name of selected)
418
- for (const dependency of localDependencies[name])
419
- selected.add(dependency);
420
- return names.filter((name) => selected.has(name));
421
- }
422
-
423
- // scripts/wq-switch/commands/setup.ts
424
- var import_node_fs4 = require("node:fs");
425
- var import_node_path5 = require("node:path");
426
-
427
- // scripts/wq-switch/state.ts
428
- var import_node_fs3 = require("node:fs");
429
- var import_node_path4 = require("node:path");
430
- var import_node_crypto2 = require("node:crypto");
431
- var import_node_os = require("node:os");
432
-
433
- // scripts/wq-switch/bins.ts
434
- var import_node_fs2 = require("node:fs");
435
- var import_node_crypto = require("node:crypto");
436
- var import_node_path3 = require("node:path");
437
- var import_cmd_shim = __toESM(require_lib());
438
- var import_read_cmd_shim = __toESM(require_lib2());
439
- var extensions = process.platform === "win32" ? ["", ".cmd", ".ps1", ".exe", ".bunx"] : [""];
440
- function validName(name) {
441
- return /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(name) && !/^(con|prn|aux|nul|com\d|lpt\d)(\.|$)/i.test(name);
442
- }
443
- function snapshot(file) {
444
- if (!present(file))
445
- return null;
446
- const stat = import_node_fs2.lstatSync(file);
447
- if (stat.isSymbolicLink())
448
- return { link: import_node_fs2.readlinkSync(file) };
449
- if (!stat.isFile())
450
- throw new Error(`Unexpected launcher entry: ${file}`);
451
- return { data: import_node_fs2.readFileSync(file).toString("base64"), mode: stat.mode & 511 };
452
- }
453
- function same(a, b) {
454
- return JSON.stringify(a) === JSON.stringify(b);
455
- }
456
- function activeArtifact(entry) {
457
- return entry.active === undefined ? entry.original : entry.active;
458
- }
459
- function validateBins(root, bins = []) {
460
- const seen = new Set;
461
- for (const entry of bins) {
462
- const name = import_node_path3.relative(import_node_path3.join(root, "node_modules", ".bin"), entry.file);
463
- if (!validName(name) || entry.file !== import_node_path3.join(root, "node_modules", ".bin", name) || seen.has(entry.file.toLowerCase()))
464
- throw new Error("Invalid switch launcher path.");
465
- seen.add(entry.file.toLowerCase());
466
- for (const value of [entry.original, activeArtifact(entry)]) {
467
- if (value !== null && (!value || typeof value !== "object" || ("link" in value ? typeof value.link !== "string" : typeof value.data !== "string" || !Number.isInteger(value.mode) || value.mode < 0 || value.mode > 511)))
468
- throw new Error("Invalid switch launcher artifact.");
469
- }
470
- }
471
- }
472
- function assertBins(state) {
473
- for (const entry of state.bins ?? []) {
474
- if (!same(snapshot(entry.file), activeArtifact(entry)))
475
- throw new Error(`Launcher changed by another install: ${entry.file}. Refusing to overwrite it.`);
476
- }
477
- }
478
- function put(file, value) {
479
- if (value === null) {
480
- if (present(file))
481
- import_node_fs2.unlinkSync(file);
482
- return;
483
- }
484
- import_node_fs2.mkdirSync(import_node_path3.dirname(file), { recursive: true });
485
- const temporary = `${file}.wq-${import_node_crypto.randomUUID()}.tmp`;
486
- try {
487
- if ("link" in value)
488
- import_node_fs2.symlinkSync(value.link, temporary, "file");
489
- else {
490
- import_node_fs2.writeFileSync(temporary, Buffer.from(value.data, "base64"), { flag: "wx" });
491
- import_node_fs2.chmodSync(temporary, value.mode);
492
- }
493
- import_node_fs2.renameSync(temporary, file);
494
- } finally {
495
- if (present(temporary))
496
- import_node_fs2.unlinkSync(temporary);
497
- }
498
- }
499
- function changeBin(operation, rollback = false) {
500
- const expected = rollback ? operation.after : operation.before;
501
- const desired = rollback ? operation.before : operation.after;
502
- const actual = snapshot(operation.file);
503
- if (same(actual, desired))
504
- return;
505
- if (!same(actual, expected))
506
- throw new Error(`Launcher changed during switching: ${operation.file}. Refusing to overwrite it.`);
507
- put(operation.file, desired);
508
- }
509
- function binOperations(previous, next) {
510
- const entries = next?.bins ?? previous?.bins ?? [];
511
- return entries.map((entry) => ({ file: entry.file, before: previous?.bins?.find((old) => old.file === entry.file) ? activeArtifact(previous.bins.find((old) => old.file === entry.file)) : entry.original, after: next ? activeArtifact(entry) : entry.original }));
512
- }
513
- function targets(state, originals = false) {
514
- const bins = new Map;
515
- for (const entry of state.entries) {
516
- const directory = originals ? entry.identity ? present(entry.backup) ? entry.backup : entry.slot : entry.original : entry.target;
517
- if (!directory || !import_node_fs2.existsSync(import_node_path3.join(directory, "package.json")))
518
- continue;
519
- for (const [name, path] of Object.entries(manifest(directory).bin ?? {})) {
520
- if (!validName(name))
521
- throw new Error(`Invalid package binary name: ${name}`);
522
- const target = import_node_path3.resolve(directory, path);
523
- if (!within(directory, target) || !import_node_fs2.existsSync(target) || !import_node_fs2.statSync(target).isFile())
524
- throw new Error(`Invalid package binary target: ${target}`);
525
- if (!bins.has(name))
526
- bins.set(name, target);
527
- else if (name !== "wq-changelog" || entry.name !== "@webquark/tooling")
528
- throw new Error(`Duplicate package binary: ${name}`);
529
- }
530
- }
531
- return bins;
532
- }
533
- function owned(file, value, allowed) {
534
- if ("link" in value)
535
- return allowed.has(import_node_path3.resolve(import_node_path3.dirname(file), value.link));
536
- if (/\.(exe|bunx)$/i.test(file)) {
537
- const companion = file.replace(/\.(exe|bunx)$/i, ".bunx");
538
- if (!import_node_fs2.existsSync(companion))
539
- return false;
540
- const path = import_node_fs2.readFileSync(companion).toString("utf16le").match(/^([^"\0]+)"\0/)?.[1];
541
- return !!path && allowed.has(import_node_path3.resolve(import_node_path3.dirname(file), "..", path));
542
- }
543
- try {
544
- return allowed.has(import_node_path3.resolve(import_node_path3.dirname(file), import_read_cmd_shim.default.sync(file)));
545
- } catch {
546
- return false;
547
- }
548
- }
549
- async function stageBins(root, next) {
550
- const previous = readState(root);
551
- if (previous)
552
- assertBins(previous);
553
- const desired = targets(next), original = targets(previous ?? next, true);
554
- const old = new Map((previous?.bins ?? []).map((entry) => [entry.file, entry]));
555
- const names = new Set([...desired.keys(), ...original.keys()]);
556
- const staging = import_node_path3.join(next.generation, "node_modules", ".bin");
557
- import_node_fs2.mkdirSync(staging, { recursive: true });
558
- for (const [name, target] of desired) {
559
- const file = import_node_path3.join(staging, name);
560
- if (process.platform === "win32")
561
- await import_cmd_shim.default(target, file);
562
- else {
563
- import_node_fs2.chmodSync(target, import_node_fs2.lstatSync(target).mode | 73);
564
- if (present(file))
565
- import_node_fs2.unlinkSync(file);
566
- import_node_fs2.symlinkSync(import_node_path3.relative(staging, target), file, "file");
567
- }
568
- }
569
- const bins = [];
570
- for (const name of names) {
571
- const allowed = new Set;
572
- for (const entry of next.entries) {
573
- for (const directory of [entry.slot, entry.target, entry.original, entry.backup]) {
574
- if (!directory || !import_node_fs2.existsSync(import_node_path3.join(directory, "package.json")))
575
- continue;
576
- const path = manifest(directory).bin?.[name];
577
- if (path) {
578
- allowed.add(import_node_path3.resolve(directory, path));
579
- allowed.add(import_node_path3.resolve(entry.slot, path));
580
- }
581
- }
582
- }
583
- const desiredTarget = desired.get(name);
584
- const stableTarget = desiredTarget && import_node_path3.resolve(root, "node_modules", import_node_path3.relative(import_node_path3.join(next.generation, "node_modules"), desiredTarget));
585
- const runtime = desiredTarget && import_node_fs2.readFileSync(desiredTarget, "utf8").match(/^#!\/usr\/bin\/env[ \t]+(node|bun)[ \t]*(?:\r?\n|$)/)?.[1];
586
- const retainBun = process.platform === "win32" && stableTarget && [".exe", ".bunx"].every((extension) => {
587
- const file = import_node_path3.join(root, "node_modules", ".bin", name + extension);
588
- const value = snapshot(file);
589
- return value !== null && owned(file, value, new Set([stableTarget]));
590
- }) && runtime && import_node_fs2.readFileSync(import_node_path3.join(root, "node_modules", ".bin", name + ".bunx")).toString("utf16le").includes(`"\x00${runtime} `);
591
- const running = process.argv[1] && import_node_fs2.existsSync(process.argv[1]) ? import_node_fs2.realpathSync(process.argv[1]) : "";
592
- if (process.platform === "win32" && !retainBun && present(import_node_path3.join(root, "node_modules", ".bin", name + ".exe")) && [...allowed].some((target) => import_node_fs2.existsSync(target) && import_node_fs2.realpathSync(target) === running)) {
593
- throw new Error(`The currently running Windows launcher would change: ${name}. Run the checkout's scripts/wq-switch/dist/index.js with node and retry.`);
594
- }
595
- for (const extension of extensions) {
596
- const file = import_node_path3.join(root, "node_modules", ".bin", name + extension), current = snapshot(file);
597
- const saved = old.get(file);
598
- if (!saved && current && !owned(file, current, allowed))
599
- throw new Error(`Foreign launcher collision: ${file}. Refusing to overwrite it.`);
600
- const active = retainBun && [".exe", ".bunx"].includes(extension) ? current : snapshot(import_node_path3.join(staging, name + extension));
601
- const baseline = saved ? saved.original : current;
602
- bins.push({ file, original: baseline, ...!same(active, baseline) ? { active } : {} });
603
- old.delete(file);
604
- }
605
- }
606
- for (const saved of old.values())
607
- bins.push({ ...saved, active: null });
608
- next.bins = bins;
609
- validateBins(root, bins);
610
- }
611
-
612
- // scripts/wq-switch/state.ts
613
- function identity(file) {
614
- const stat = import_node_fs3.statSync(file);
615
- return `${stat.dev}:${stat.ino}`;
616
- }
617
- function present(file) {
618
- try {
619
- import_node_fs3.lstatSync(file);
620
- return true;
621
- } catch (error) {
622
- if (error.code === "ENOENT")
623
- return false;
624
- throw error;
625
- }
626
- }
627
- function within(parent, child) {
628
- const r = import_node_path4.relative(parent, child);
629
- return r !== "" && !r.startsWith("..") && !import_node_path4.isAbsolute(r);
630
- }
631
- function linkTarget(file) {
632
- if (!present(file) || !import_node_fs3.lstatSync(file).isSymbolicLink())
633
- return null;
634
- return import_node_path4.resolve(import_node_path4.dirname(file), import_node_fs3.readlinkSync(file));
635
- }
636
- function link(target, file) {
637
- import_node_fs3.mkdirSync(import_node_path4.dirname(file), { recursive: true });
638
- import_node_fs3.symlinkSync(target, file, process.platform === "win32" ? "junction" : "dir");
639
- }
640
- function validateState(root, state, paths) {
641
- if (state.version !== 1 || !Array.isArray(state.entries))
642
- throw new Error("Unsupported switch state.");
643
- if (!within(paths.packages, state.generation))
644
- throw new Error("Invalid switch generation path; refusing filesystem changes.");
645
- for (const entry of state.entries) {
646
- if (!names.includes(entry.name) || entry.slot !== import_node_path4.join(root, "node_modules", entry.name) || import_node_path4.dirname(entry.backup) !== import_node_path4.dirname(entry.slot) || !entry.backup.startsWith(entry.slot + ".wq-original-") || !within(state.generation, entry.target))
647
- throw new Error("Invalid switch state paths; refusing filesystem changes.");
648
- }
649
- validateBins(root, state.bins);
650
- }
651
- function readState(root) {
652
- const paths = projectPaths(root);
653
- if (!import_node_fs3.existsSync(paths.state))
654
- return null;
655
- const state = json(paths.state);
656
- validateState(root, state, paths);
657
- return state;
658
- }
659
- function saveState(state, paths) {
660
- if (state)
661
- writeJson(paths.state, state);
662
- else if (import_node_fs3.existsSync(paths.state))
663
- import_node_fs3.unlinkSync(paths.state);
664
- }
665
- function assertActive(state) {
666
- for (const entry of state.entries) {
667
- if (linkTarget(entry.slot) !== entry.target)
668
- throw new Error(`${entry.name} was changed by another install. Refusing to overwrite it.`);
669
- if (entry.identity && (!present(entry.backup) || identity(entry.backup) !== entry.identity))
670
- throw new Error(`Original package backup is missing or changed: ${entry.backup}`);
671
- }
672
- assertBins(state);
673
- }
674
- function hasJournal(root) {
675
- return import_node_fs3.existsSync(projectPaths(root).journal);
676
- }
677
- function removeExpectedLink(slot, expected) {
678
- if (linkTarget(slot) !== expected)
679
- throw new Error(`Package connection changed: ${slot}`);
680
- import_node_fs3.unlinkSync(slot);
681
- }
682
- function validateJournal(root, journal, paths) {
683
- if (journal.previous)
684
- validateState(root, journal.previous, paths);
685
- if (journal.next)
686
- validateState(root, journal.next, paths);
687
- const entries = [...journal.previous?.entries ?? [], ...journal.next?.entries ?? []];
688
- for (const op of journal.operations) {
689
- const matching = entries.filter((entry) => entry.slot === op.slot);
690
- if (!matching.length || op.move && !matching.some((entry) => entry.backup === op.move) || [op.before, op.after].some((target) => target !== null && !matching.some((entry) => entry.target === target)))
691
- throw new Error("Invalid recovery journal.");
692
- }
693
- if (JSON.stringify(journal.bins ?? []) !== JSON.stringify(binOperations(journal.previous, journal.next)))
694
- throw new Error("Invalid launcher recovery journal.");
695
- }
696
- function recover(root) {
697
- const paths = projectPaths(root);
698
- if (!import_node_fs3.existsSync(paths.journal))
699
- return;
700
- const journal = json(paths.journal);
701
- validateJournal(root, journal, paths);
702
- for (const operation of [...journal.bins ?? []].reverse())
703
- changeBin(operation, true);
704
- for (const op of [...journal.operations].reverse()) {
705
- if (op.move) {
706
- const entry = journal.next.entries.find((entry) => entry.slot === op.slot);
707
- if (!entry.identity) {
708
- if (present(op.slot))
709
- removeExpectedLink(op.slot, op.after);
710
- continue;
711
- }
712
- if (present(op.move)) {
713
- if (present(op.slot))
714
- removeExpectedLink(op.slot, op.after);
715
- import_node_fs3.renameSync(op.move, op.slot);
716
- } else if (!present(op.slot) || identity(op.slot) !== entry.identity)
717
- throw new Error(`Recovery needs the original package: ${op.slot}`);
718
- } else if (op.after === null) {
719
- const entry = journal.previous.entries.find((entry) => entry.slot === op.slot);
720
- if (entry.identity && !present(entry.backup)) {
721
- if (!present(op.slot) || identity(op.slot) !== entry.identity)
722
- throw new Error(`Recovery found an unexpected package: ${op.slot}`);
723
- import_node_fs3.renameSync(op.slot, entry.backup);
724
- }
725
- if (!present(op.slot))
726
- link(op.before, op.slot);
727
- else if (linkTarget(op.slot) !== op.before)
728
- throw new Error(`Recovery found an unexpected connection: ${op.slot}`);
729
- } else {
730
- const current = linkTarget(op.slot);
731
- if (current === op.after)
732
- removeExpectedLink(op.slot, op.after);
733
- else if (present(op.slot) && current !== op.before)
734
- throw new Error(`Recovery found an unexpected connection: ${op.slot}`);
735
- if (!present(op.slot))
736
- link(op.before, op.slot);
737
- }
738
- }
739
- saveState(journal.previous, paths);
740
- import_node_fs3.unlinkSync(paths.journal);
741
- }
742
- function activate(root, next) {
743
- const paths = projectPaths(root);
744
- validateState(root, next, paths);
745
- const previous = readState(root);
746
- if (previous)
747
- assertActive(previous);
748
- const operations = next.entries.map((entry) => {
749
- const old = previous?.entries.find((old) => old.name === entry.name);
750
- if (!old && (present(entry.backup) || (entry.identity ? !present(entry.slot) || identity(entry.slot) !== entry.identity : present(entry.slot))))
751
- throw new Error(`Original connection changed: ${entry.name}`);
752
- return { slot: entry.slot, before: old?.target ?? null, after: entry.target, ...old ? {} : { move: entry.backup } };
753
- });
754
- const bins = binOperations(previous, next);
755
- writeJson(paths.journal, { previous, next, operations, bins });
756
- try {
757
- for (const op of operations) {
758
- if (op.move) {
759
- if (present(op.slot))
760
- import_node_fs3.renameSync(op.slot, op.move);
761
- } else
762
- removeExpectedLink(op.slot, op.before);
763
- link(op.after, op.slot);
764
- }
765
- for (const operation of bins)
766
- changeBin(operation);
767
- saveState(next, paths);
768
- import_node_fs3.unlinkSync(paths.journal);
769
- } catch (error) {
770
- recover(root);
771
- throw error;
772
- }
773
- }
774
- function restore(root) {
775
- const paths = projectPaths(root);
776
- const previous = readState(root);
777
- if (!previous)
778
- return;
779
- assertActive(previous);
780
- const operations = previous.entries.map((entry) => ({ slot: entry.slot, before: entry.target, after: null }));
781
- const bins = binOperations(previous, null);
782
- writeJson(paths.journal, { previous, next: null, operations, bins });
783
- try {
784
- for (const entry of previous.entries) {
785
- removeExpectedLink(entry.slot, entry.target);
786
- if (entry.identity)
787
- import_node_fs3.renameSync(entry.backup, entry.slot);
788
- }
789
- for (const operation of bins)
790
- changeBin(operation);
791
- saveState(null, paths);
792
- import_node_fs3.unlinkSync(paths.journal);
793
- } catch (error) {
794
- recover(root);
795
- throw error;
796
- }
797
- }
798
- function originalEntry(root, name, target) {
799
- const slot = import_node_path4.join(root, "node_modules", name);
800
- return { name, slot, backup: `${slot}.wq-original-${import_node_crypto2.randomUUID()}`, original: present(slot) ? import_node_fs3.realpathSync(slot) : "", identity: present(slot) ? identity(slot) : "", target };
801
- }
802
- async function locked(key, action) {
803
- const file = import_node_path4.join(import_node_os.tmpdir(), `wq-switch-${import_node_crypto2.createHash("sha256").update(key.toLowerCase()).digest("hex")}.lock`);
804
- const content = JSON.stringify({ pid: process.pid, id: import_node_crypto2.randomUUID() });
805
- try {
806
- import_node_fs3.writeFileSync(file, content, { flag: "wx" });
807
- } catch (error) {
808
- if (error.code !== "EEXIST")
809
- throw error;
810
- const previous = import_node_fs3.readFileSync(file, "utf8");
811
- const { pid } = JSON.parse(previous);
812
- let alive = true;
813
- try {
814
- process.kill(pid, 0);
815
- } catch (e) {
816
- if (e.code === "ESRCH")
817
- alive = false;
818
- }
819
- if (alive)
820
- throw new Error(`Another switch/build is running (PID ${pid}).`);
821
- if (import_node_fs3.readFileSync(file, "utf8") !== previous)
822
- throw new Error("Lock changed; retry.");
823
- import_node_fs3.unlinkSync(file);
824
- import_node_fs3.writeFileSync(file, content, { flag: "wx" });
825
- }
826
- try {
827
- return await action();
828
- } finally {
829
- if (import_node_fs3.existsSync(file) && import_node_fs3.readFileSync(file, "utf8") === content)
830
- import_node_fs3.unlinkSync(file);
831
- }
832
- }
833
-
834
- // scripts/wq-switch/commands/setup.ts
835
- function setup(root, source) {
836
- const selected = selectedPackages(root);
837
- if (hasJournal(root))
838
- throw new Error("Run wq-switch npm to recover the interrupted switch before changing configuration.");
839
- if (readState(root))
840
- throw new Error("Stop the dev server and run wq-switch npm before changing configuration.");
841
- const file = projectPaths(root).config;
842
- const document = readWebQuarkConfig(root);
843
- const previous = readSwitchConfig(root);
844
- const pkg = manifest(root);
845
- const scripts = { "wq-sandbox": "wq-sandbox", "wq-switch": "wq-switch", "wq-check": "wq-switch check" };
846
- for (const [name, command] of Object.entries(scripts)) {
847
- if (pkg.scripts?.[name] && pkg.scripts[name] !== command)
848
- throw new Error(`package.json already has a custom ${name} script. Rename it before running setup; no files were changed.`);
849
- }
850
- const config = {
851
- ...previous,
852
- version: 1,
853
- source: source === undefined ? previous?.source ?? "" : validateSource(import_node_path5.resolve(root, source)),
854
- preferredVersion: previous?.preferredVersion ?? selected.map((name) => pkg.dependencies?.[name] ?? pkg.devDependencies?.[name]).find(Boolean)
855
- };
856
- writeJson(file, { ...document, "wq-switch": config });
857
- writeJson(import_node_path5.join(root, "package.json"), { ...pkg, scripts: { ...pkg.scripts, ...scripts } });
858
- const ignore = import_node_path5.join(root, ".gitignore");
859
- const current = import_node_fs4.existsSync(ignore) ? import_node_fs4.readFileSync(ignore, "utf8") : "";
860
- const missing = ["/.webquark/", "/node_modules/"].filter((line) => !current.split(/\r?\n/).includes(line));
861
- if (missing.length)
862
- import_node_fs4.appendFileSync(ignore, `
863
- # Local WebQuark development
864
- ` + missing.join(`
865
- `) + `
866
- `);
867
- console.log(`Created/updated .webquark/.webquark.json and package scripts.
868
- Preferred release: ${config.preferredVersion}
869
- ${config.source ? `Source: ${config.source}
870
- Next: bun run wq-switch local` : "Next: fill in wq-switch.source in .webquark/.webquark.json before switching locally."}
871
- Sandbox: bun run wq-sandbox
872
- Status: bun run wq-switch status`);
873
- }
874
-
875
- // scripts/wq-switch/setup.ts
876
- async function main() {
877
- const args = process.argv.slice(2);
878
- const help = `wq-setup [--source <path>]
879
- Creates .webquark/.webquark.json and wq-sandbox/wq-switch/wq-check package scripts in the consuming project.`;
880
- if (args.length === 1 && ["--help", "-h"].includes(args[0])) {
881
- console.log(help);
882
- return;
883
- }
884
- if (args.length && (args.length !== 2 || args[0] !== "--source"))
885
- throw new Error(help);
886
- const root = consumerRoot();
887
- await locked(`consumer:${root}`, async () => {
888
- recover(root);
889
- setup(root, args[1]);
890
- });
891
- }
892
- main().catch((error) => {
893
- console.error(`wq-setup: ${error.message}`);
894
- process.exitCode = 1;
895
- });
2
+ require('@webquark/tooling/wq-setup');