@ikas/component-cli 1.4.0-beta.23 → 1.4.0-beta.231

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 (211) hide show
  1. package/dist/build-tools.d.ts +37 -0
  2. package/dist/build-tools.d.ts.map +1 -0
  3. package/dist/build-tools.js +36 -0
  4. package/dist/build-tools.js.map +1 -0
  5. package/dist/commands/add-sections-to-page.d.ts +3 -0
  6. package/dist/commands/add-sections-to-page.d.ts.map +1 -0
  7. package/dist/commands/add-sections-to-page.js +39 -0
  8. package/dist/commands/add-sections-to-page.js.map +1 -0
  9. package/dist/commands/add-to-page.js +1 -1
  10. package/dist/commands/add-to-page.js.map +1 -1
  11. package/dist/commands/add.d.ts.map +1 -1
  12. package/dist/commands/add.js +11 -2
  13. package/dist/commands/add.js.map +1 -1
  14. package/dist/commands/build.d.ts.map +1 -1
  15. package/dist/commands/build.js +23 -170
  16. package/dist/commands/build.js.map +1 -1
  17. package/dist/commands/config-texts.d.ts +39 -0
  18. package/dist/commands/config-texts.d.ts.map +1 -0
  19. package/dist/commands/config-texts.js +192 -0
  20. package/dist/commands/config-texts.js.map +1 -0
  21. package/dist/commands/config.d.ts +45 -0
  22. package/dist/commands/config.d.ts.map +1 -1
  23. package/dist/commands/config.js +1205 -154
  24. package/dist/commands/config.js.map +1 -1
  25. package/dist/commands/create-design-tokens.d.ts +24 -0
  26. package/dist/commands/create-design-tokens.d.ts.map +1 -0
  27. package/dist/commands/create-design-tokens.js +388 -0
  28. package/dist/commands/create-design-tokens.js.map +1 -0
  29. package/dist/commands/create-global-variable.d.ts +3 -0
  30. package/dist/commands/create-global-variable.d.ts.map +1 -0
  31. package/dist/commands/create-global-variable.js +73 -0
  32. package/dist/commands/create-global-variable.js.map +1 -0
  33. package/dist/commands/create-page.d.ts +3 -0
  34. package/dist/commands/create-page.d.ts.map +1 -0
  35. package/dist/commands/create-page.js +31 -0
  36. package/dist/commands/create-page.js.map +1 -0
  37. package/dist/commands/delete-page.d.ts +3 -0
  38. package/dist/commands/delete-page.d.ts.map +1 -0
  39. package/dist/commands/delete-page.js +28 -0
  40. package/dist/commands/delete-page.js.map +1 -0
  41. package/dist/commands/delete-theme-globals.d.ts +4 -0
  42. package/dist/commands/delete-theme-globals.d.ts.map +1 -0
  43. package/dist/commands/delete-theme-globals.js +50 -0
  44. package/dist/commands/delete-theme-globals.js.map +1 -0
  45. package/dist/commands/dev.d.ts.map +1 -1
  46. package/dist/commands/dev.js +328 -39
  47. package/dist/commands/dev.js.map +1 -1
  48. package/dist/commands/enable-builtin-pages.d.ts +3 -0
  49. package/dist/commands/enable-builtin-pages.d.ts.map +1 -0
  50. package/dist/commands/enable-builtin-pages.js +28 -0
  51. package/dist/commands/enable-builtin-pages.js.map +1 -0
  52. package/dist/commands/get-component-props.d.ts +3 -0
  53. package/dist/commands/get-component-props.d.ts.map +1 -0
  54. package/dist/commands/get-component-props.js +32 -0
  55. package/dist/commands/get-component-props.js.map +1 -0
  56. package/dist/commands/get-page-by-type.d.ts +3 -0
  57. package/dist/commands/get-page-by-type.d.ts.map +1 -0
  58. package/dist/commands/get-page-by-type.js +25 -0
  59. package/dist/commands/get-page-by-type.js.map +1 -0
  60. package/dist/commands/get-section-values.d.ts +3 -0
  61. package/dist/commands/get-section-values.d.ts.map +1 -0
  62. package/dist/commands/get-section-values.js +43 -0
  63. package/dist/commands/get-section-values.js.map +1 -0
  64. package/dist/commands/import.js +1 -1
  65. package/dist/commands/import.js.map +1 -1
  66. package/dist/commands/list-builtin-pages.d.ts +3 -0
  67. package/dist/commands/list-builtin-pages.d.ts.map +1 -0
  68. package/dist/commands/list-builtin-pages.js +28 -0
  69. package/dist/commands/list-builtin-pages.js.map +1 -0
  70. package/dist/commands/list-entities.d.ts +3 -0
  71. package/dist/commands/list-entities.d.ts.map +1 -0
  72. package/dist/commands/list-entities.js +32 -0
  73. package/dist/commands/list-entities.js.map +1 -0
  74. package/dist/commands/list-imported.js +1 -1
  75. package/dist/commands/list-imported.js.map +1 -1
  76. package/dist/commands/list-page-sections.d.ts +3 -0
  77. package/dist/commands/list-page-sections.d.ts.map +1 -0
  78. package/dist/commands/list-page-sections.js +31 -0
  79. package/dist/commands/list-page-sections.js.map +1 -0
  80. package/dist/commands/list-pages.js +1 -1
  81. package/dist/commands/list-pages.js.map +1 -1
  82. package/dist/commands/list-theme-globals.d.ts +3 -0
  83. package/dist/commands/list-theme-globals.d.ts.map +1 -0
  84. package/dist/commands/list-theme-globals.js +22 -0
  85. package/dist/commands/list-theme-globals.js.map +1 -0
  86. package/dist/commands/list-translations.d.ts +3 -0
  87. package/dist/commands/list-translations.d.ts.map +1 -0
  88. package/dist/commands/list-translations.js +33 -0
  89. package/dist/commands/list-translations.js.map +1 -0
  90. package/dist/commands/move-page-section.d.ts +3 -0
  91. package/dist/commands/move-page-section.d.ts.map +1 -0
  92. package/dist/commands/move-page-section.js +62 -0
  93. package/dist/commands/move-page-section.js.map +1 -0
  94. package/dist/commands/publish-theme.d.ts +3 -0
  95. package/dist/commands/publish-theme.d.ts.map +1 -0
  96. package/dist/commands/publish-theme.js +29 -0
  97. package/dist/commands/publish-theme.js.map +1 -0
  98. package/dist/commands/publish.d.ts.map +1 -1
  99. package/dist/commands/publish.js +72 -3
  100. package/dist/commands/publish.js.map +1 -1
  101. package/dist/commands/remove-page-section.d.ts +3 -0
  102. package/dist/commands/remove-page-section.d.ts.map +1 -0
  103. package/dist/commands/remove-page-section.js +40 -0
  104. package/dist/commands/remove-page-section.js.map +1 -0
  105. package/dist/commands/search-products.d.ts +3 -0
  106. package/dist/commands/search-products.d.ts.map +1 -0
  107. package/dist/commands/search-products.js +40 -0
  108. package/dist/commands/search-products.js.map +1 -0
  109. package/dist/commands/translation-languages.d.ts +3 -0
  110. package/dist/commands/translation-languages.d.ts.map +1 -0
  111. package/dist/commands/translation-languages.js +43 -0
  112. package/dist/commands/translation-languages.js.map +1 -0
  113. package/dist/commands/update-builtin-page-prop.d.ts +3 -0
  114. package/dist/commands/update-builtin-page-prop.d.ts.map +1 -0
  115. package/dist/commands/update-builtin-page-prop.js +49 -0
  116. package/dist/commands/update-builtin-page-prop.js.map +1 -0
  117. package/dist/commands/update-global-variable.d.ts +3 -0
  118. package/dist/commands/update-global-variable.d.ts.map +1 -0
  119. package/dist/commands/update-global-variable.js +70 -0
  120. package/dist/commands/update-global-variable.js.map +1 -0
  121. package/dist/commands/update-page-sections.d.ts +3 -0
  122. package/dist/commands/update-page-sections.d.ts.map +1 -0
  123. package/dist/commands/update-page-sections.js +42 -0
  124. package/dist/commands/update-page-sections.js.map +1 -0
  125. package/dist/commands/update-section-prop.d.ts +3 -0
  126. package/dist/commands/update-section-prop.d.ts.map +1 -0
  127. package/dist/commands/update-section-prop.js +81 -0
  128. package/dist/commands/update-section-prop.js.map +1 -0
  129. package/dist/commands/update-translations.d.ts +3 -0
  130. package/dist/commands/update-translations.d.ts.map +1 -0
  131. package/dist/commands/update-translations.js +45 -0
  132. package/dist/commands/update-translations.js.map +1 -0
  133. package/dist/commands/upload-image.d.ts +3 -0
  134. package/dist/commands/upload-image.d.ts.map +1 -0
  135. package/dist/commands/upload-image.js +38 -0
  136. package/dist/commands/upload-image.js.map +1 -0
  137. package/dist/commands/upload-images.d.ts +3 -0
  138. package/dist/commands/upload-images.d.ts.map +1 -0
  139. package/dist/commands/upload-images.js +48 -0
  140. package/dist/commands/upload-images.js.map +1 -0
  141. package/dist/index.d.ts.map +1 -1
  142. package/dist/index.js +66 -1
  143. package/dist/index.js.map +1 -1
  144. package/dist/types.d.ts +77 -0
  145. package/dist/types.d.ts.map +1 -1
  146. package/dist/utils/archive-project.d.ts +50 -0
  147. package/dist/utils/archive-project.d.ts.map +1 -0
  148. package/dist/utils/archive-project.js +178 -0
  149. package/dist/utils/archive-project.js.map +1 -0
  150. package/dist/utils/compile.d.ts +17 -2
  151. package/dist/utils/compile.d.ts.map +1 -1
  152. package/dist/utils/compile.js +742 -109
  153. package/dist/utils/compile.js.map +1 -1
  154. package/dist/utils/component-helpers.d.ts +236 -4
  155. package/dist/utils/component-helpers.d.ts.map +1 -1
  156. package/dist/utils/component-helpers.js +656 -37
  157. package/dist/utils/component-helpers.js.map +1 -1
  158. package/dist/utils/css-import-resolver.d.ts +4 -1
  159. package/dist/utils/css-import-resolver.d.ts.map +1 -1
  160. package/dist/utils/css-import-resolver.js +9 -1
  161. package/dist/utils/css-import-resolver.js.map +1 -1
  162. package/dist/utils/dev-server-auth.d.ts +28 -0
  163. package/dist/utils/dev-server-auth.d.ts.map +1 -0
  164. package/dist/utils/dev-server-auth.js +79 -0
  165. package/dist/utils/dev-server-auth.js.map +1 -0
  166. package/dist/utils/editor-action-client.d.ts +20 -3
  167. package/dist/utils/editor-action-client.d.ts.map +1 -1
  168. package/dist/utils/editor-action-client.js +81 -19
  169. package/dist/utils/editor-action-client.js.map +1 -1
  170. package/dist/utils/esm-transform.d.ts +30 -0
  171. package/dist/utils/esm-transform.d.ts.map +1 -1
  172. package/dist/utils/esm-transform.js +169 -2
  173. package/dist/utils/esm-transform.js.map +1 -1
  174. package/dist/utils/find-component-for-file.d.ts +12 -0
  175. package/dist/utils/find-component-for-file.d.ts.map +1 -0
  176. package/dist/utils/find-component-for-file.js +24 -0
  177. package/dist/utils/find-component-for-file.js.map +1 -0
  178. package/dist/utils/forbid-deep-imports.d.ts +3 -0
  179. package/dist/utils/forbid-deep-imports.d.ts.map +1 -0
  180. package/dist/utils/forbid-deep-imports.js +54 -0
  181. package/dist/utils/forbid-deep-imports.js.map +1 -0
  182. package/dist/utils/forbid-external-packages.d.ts +26 -0
  183. package/dist/utils/forbid-external-packages.d.ts.map +1 -0
  184. package/dist/utils/forbid-external-packages.js +99 -0
  185. package/dist/utils/forbid-external-packages.js.map +1 -0
  186. package/dist/utils/i18n.d.ts +98 -0
  187. package/dist/utils/i18n.d.ts.map +1 -0
  188. package/dist/utils/i18n.js +408 -0
  189. package/dist/utils/i18n.js.map +1 -0
  190. package/dist/utils/load-image.d.ts +16 -0
  191. package/dist/utils/load-image.d.ts.map +1 -0
  192. package/dist/utils/load-image.js +50 -0
  193. package/dist/utils/load-image.js.map +1 -0
  194. package/dist/utils/storefront-t.d.ts +17 -0
  195. package/dist/utils/storefront-t.d.ts.map +1 -0
  196. package/dist/utils/storefront-t.js +187 -0
  197. package/dist/utils/storefront-t.js.map +1 -0
  198. package/dist/utils/vendor-storefront.d.ts +13 -0
  199. package/dist/utils/vendor-storefront.d.ts.map +1 -0
  200. package/dist/utils/vendor-storefront.js +91 -0
  201. package/dist/utils/vendor-storefront.js.map +1 -0
  202. package/dist/utils/websocket-server.d.ts +165 -7
  203. package/dist/utils/websocket-server.d.ts.map +1 -1
  204. package/dist/utils/websocket-server.js +326 -45
  205. package/dist/utils/websocket-server.js.map +1 -1
  206. package/package.json +19 -2
  207. package/templates/add/section.css +11 -0
  208. package/dist/commands/create.d.ts +0 -4
  209. package/dist/commands/create.d.ts.map +0 -1
  210. package/dist/commands/create.js +0 -176
  211. package/dist/commands/create.js.map +0 -1
@@ -0,0 +1,187 @@
1
+ import * as fs from "fs";
2
+ import { createRequire } from "module";
3
+ import * as path from "path";
4
+ import { generateI18nRuntime, I18N_DEFAULT_FILE, i18nDir, readI18n, } from "./i18n.js";
5
+ const STOREFRONT = "@ikas/bp-storefront";
6
+ const SOURCE_FILE = /\.[cm]?[jt]sx?$/;
7
+ const LOADERS = {
8
+ ".ts": "ts",
9
+ ".mts": "ts",
10
+ ".cts": "ts",
11
+ ".tsx": "tsx",
12
+ ".jsx": "jsx",
13
+ };
14
+ /** The project's own TypeScript (the build type-checks with it), else one the CLI can reach. */
15
+ function loadTypeScript(root) {
16
+ const from = [path.join(root, "package.json"), import.meta.url];
17
+ const found = from.reduce((ts, base) => {
18
+ if (ts)
19
+ return ts;
20
+ try {
21
+ return createRequire(base)("typescript");
22
+ }
23
+ catch {
24
+ return undefined;
25
+ }
26
+ }, undefined);
27
+ if (!found)
28
+ throw new Error(`import { t } from "${STOREFRONT}" needs the project's TypeScript: install it (npm i -D typescript).`);
29
+ return found;
30
+ }
31
+ /**
32
+ * `source` with `t` imported from the project's UI texts module (`i18nModule`) in place of `@ikas/bp-storefront`,
33
+ * whose shared runtime has no `t`: each project reads its own texts. The other imports stay as they are, on the
34
+ * same lines. `null`: nothing to change. Throws on a form that would read `t` from the shared runtime.
35
+ */
36
+ export function rewriteStorefrontT(ts, source, fileName, i18nModule) {
37
+ if (!source.includes(STOREFRONT))
38
+ return null;
39
+ const file = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true);
40
+ const isStorefront = (specifier) => !!specifier &&
41
+ ts.isStringLiteral(specifier) &&
42
+ specifier.text === STOREFRONT;
43
+ const fail = (node, problem) => {
44
+ const { line } = file.getLineAndCharacterOfPosition(node.getStart(file));
45
+ throw new Error(`${path.basename(fileName)}:${line + 1}: ${problem} Import it by name: import { t } from "${STOREFRONT}".`);
46
+ };
47
+ const needProject = (node) => {
48
+ if (!i18nModule)
49
+ fail(node, `t needs the project's ikas.config.json (its projectId): run the build in the project.`);
50
+ };
51
+ // A namespace import's `t` would be read from the shared runtime: `S.t`, `S["t"]`, `const { t } = S`
52
+ const namespaces = new Set();
53
+ const edits = [];
54
+ file.statements.forEach((statement) => {
55
+ if (ts.isExportDeclaration(statement) &&
56
+ isStorefront(statement.moduleSpecifier) &&
57
+ !statement.isTypeOnly) {
58
+ const clause = statement.exportClause;
59
+ const named = clause && ts.isNamedExports(clause)
60
+ ? clause.elements.some((e) => !e.isTypeOnly && (e.propertyName ?? e.name).text === "t")
61
+ : !clause && !!i18nModule;
62
+ if (named)
63
+ fail(statement, `t cannot be re-exported from "${STOREFRONT}" (it has no t at runtime).`);
64
+ return;
65
+ }
66
+ if (!ts.isImportDeclaration(statement) ||
67
+ !isStorefront(statement.moduleSpecifier))
68
+ return;
69
+ const clause = statement.importClause;
70
+ if (!clause || clause.isTypeOnly || !clause.namedBindings)
71
+ return;
72
+ const bindings = clause.namedBindings;
73
+ if (ts.isNamespaceImport(bindings)) {
74
+ namespaces.add(bindings.name.text);
75
+ return;
76
+ }
77
+ const tImports = bindings.elements.filter((e) => !e.isTypeOnly && (e.propertyName ?? e.name).text === "t");
78
+ if (!tImports.length)
79
+ return;
80
+ needProject(statement);
81
+ const rest = bindings.elements
82
+ .filter((e) => !tImports.includes(e))
83
+ .map((e) => e.getText(file));
84
+ const head = [
85
+ clause.name?.text,
86
+ rest.length ? `{ ${rest.join(", ")} }` : undefined,
87
+ ].filter(Boolean);
88
+ const kept = head.length
89
+ ? `import ${head.join(", ")} from "${STOREFRONT}"; `
90
+ : "";
91
+ const names = tImports
92
+ .map((e) => (e.name.text === "t" ? "t" : `t as ${e.name.text}`))
93
+ .join(", ");
94
+ const original = source.slice(statement.getStart(file), statement.getEnd());
95
+ edits.push({
96
+ start: statement.getStart(file),
97
+ end: statement.getEnd(),
98
+ // On the import's own lines: the code below keeps its line numbers
99
+ text: `${kept}import { ${names} } from ${JSON.stringify(i18nModule)};${"\n".repeat(original.split("\n").length - 1)}`,
100
+ });
101
+ });
102
+ if (namespaces.size) {
103
+ const visit = (node) => {
104
+ const isNamespace = (e) => ts.isIdentifier(e) && namespaces.has(e.text);
105
+ if (ts.isPropertyAccessExpression(node) &&
106
+ isNamespace(node.expression) &&
107
+ node.name.text === "t")
108
+ fail(node, `t is not read through a namespace import of "${STOREFRONT}".`);
109
+ if (ts.isElementAccessExpression(node) &&
110
+ isNamespace(node.expression) &&
111
+ ts.isStringLiteralLike(node.argumentExpression) &&
112
+ node.argumentExpression.text === "t")
113
+ fail(node, `t is not read through a namespace import of "${STOREFRONT}".`);
114
+ if (ts.isVariableDeclaration(node) &&
115
+ node.initializer &&
116
+ isNamespace(node.initializer) &&
117
+ ts.isObjectBindingPattern(node.name) &&
118
+ node.name.elements.some((e) => (e.propertyName ?? e.name).text === "t"))
119
+ fail(node, `t is not read through a namespace import of "${STOREFRONT}".`);
120
+ ts.forEachChild(node, visit);
121
+ };
122
+ visit(file);
123
+ }
124
+ if (!edits.length)
125
+ return null;
126
+ return edits
127
+ .sort((a, b) => b.start - a.start)
128
+ .reduce((text, edit) => text.slice(0, edit.start) + edit.text + text.slice(edit.end), source);
129
+ }
130
+ /** The module the build gives `t` from: the project's texts and their `t`, made from its i18n files. */
131
+ // Under the CLI's own virtual package, which the package rules allow
132
+ export const UI_TEXTS_MODULE = "@ikas/component-utils/ui-texts";
133
+ /**
134
+ * Binds `import { t } from "@ikas/bp-storefront"` to a `t` reading the project's own UI texts, made from its i18n
135
+ * files (`UI_TEXTS_MODULE`, never written to the project): the storefront runtime is shared by every project on a
136
+ * store, so a `t` there could not tell whose text a key is. The generated `index.d.ts` types that `t`.
137
+ */
138
+ export function storefrontTPlugin(root = process.cwd()) {
139
+ return {
140
+ name: "ikas-storefront-t",
141
+ setup(build) {
142
+ let config;
143
+ try {
144
+ config = JSON.parse(fs.readFileSync(path.join(root, "ikas.config.json"), "utf-8"));
145
+ }
146
+ catch {
147
+ // No project config: nothing to bind
148
+ }
149
+ const dir = config ? i18nDir(config, root) : null;
150
+ const hasTexts = !!dir && fs.existsSync(path.join(dir, `${I18N_DEFAULT_FILE}.json`));
151
+ build.onResolve({ filter: /^@ikas\/component-utils\/ui-texts$/ }, (args) => ({
152
+ path: args.path,
153
+ namespace: "ikas-ui-texts",
154
+ }));
155
+ build.onLoad({ filter: /.*/, namespace: "ikas-ui-texts" }, () => ({
156
+ // Read at each build: a changed base text (its `index.d.ts` rewritten) recompiles in dev
157
+ // No texts of its own yet: t still reads the store's (`ikas:<key>`)
158
+ contents: generateI18nRuntime(config.projectId, hasTexts ? readI18n(dir).base : {}),
159
+ loader: "js",
160
+ resolveDir: root,
161
+ }));
162
+ let ts;
163
+ build.onLoad({ filter: SOURCE_FILE }, (args) => {
164
+ if (args.path.split(path.sep).includes("node_modules"))
165
+ return undefined;
166
+ const source = fs.readFileSync(args.path, "utf-8");
167
+ if (!source.includes(STOREFRONT))
168
+ return undefined;
169
+ try {
170
+ ts ??= loadTypeScript(root);
171
+ const contents = rewriteStorefrontT(ts, source, args.path, config?.projectId ? UI_TEXTS_MODULE : null);
172
+ if (contents === null)
173
+ return undefined;
174
+ return {
175
+ contents,
176
+ loader: LOADERS[path.extname(args.path)] ?? "js",
177
+ resolveDir: path.dirname(args.path),
178
+ };
179
+ }
180
+ catch (e) {
181
+ return { errors: [{ text: e.message }] };
182
+ }
183
+ });
184
+ },
185
+ };
186
+ }
187
+ //# sourceMappingURL=storefront-t.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storefront-t.js","sourceRoot":"","sources":["../../src/utils/storefront-t.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAI7B,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,OAAO,EACP,QAAQ,GACT,MAAM,WAAW,CAAC;AAEnB,MAAM,UAAU,GAAG,qBAAqB,CAAC;AACzC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAEtC,MAAM,OAAO,GAA2B;IACtC,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,KAAK;CACd,CAAC;AAEF,gGAAgG;AAChG,SAAS,cAAc,CAAC,IAAY;IAClC,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChE,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAwB,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;QAC5D,IAAI,EAAE;YAAE,OAAO,EAAE,CAAC;QAClB,IAAI,CAAC;YACH,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3C,CAAC;QAAC,MAAM,CA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oBAAE,OAAO,SAAS,CAAC;gBACnD,IAAI,CAAC;oBACH,EAAE,KAAK,cAAc,CAAC,IAAI,CAAC,CAAC;oBAC5B,MAAM,QAAQ,GAAG,kBAAkB,CACjC,EAAE,EACF,MAAM,EACN,IAAI,CAAC,IAAI,EACT,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAC3C,CAAC;oBACF,IAAI,QAAQ,KAAK,IAAI;wBAAE,OAAO,SAAS,CAAC;oBACxC,OAAO;wBACL,QAAQ;wBACR,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI;wBAChD,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;qBACpC,CAAC;gBACJ,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAG,CAAW,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;gBACtD,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Plugin } from "esbuild";
2
+ export declare function isVendoredDependencyFile(file: string): boolean;
3
+ /**
4
+ * Bundle the storefront SDK into the component artifact.
5
+ *
6
+ * Deep imports stay forbidden for *component* source — the public contract is still "import only
7
+ * from the package root", and a component reaching into `/src/...` is still a bug worth failing
8
+ * on. But the SDK's own modules deep-import each other constantly (97 lazy `import()` calls into
9
+ * `@ikas/bp-storefront-api/src/__api/...` alone), and those are internal business. So the rule is
10
+ * keyed on who is importing, not on what is imported.
11
+ */
12
+ export declare function vendorStorefrontPlugin(): Plugin;
13
+ //# sourceMappingURL=vendor-storefront.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vendor-storefront.d.ts","sourceRoot":"","sources":["../../src/utils/vendor-storefront.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAqCtC,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAK9D;AAqBD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CA+B/C"}
@@ -0,0 +1,91 @@
1
+ import * as fs from "fs";
2
+ import * as os from "os";
3
+ import * as path from "path";
4
+ /**
5
+ * Compile the storefront SDK *into* the artifact instead of resolving it against the host.
6
+ *
7
+ * The default path (`forbidDeepStorefrontImportsPlugin`) leaves `@ikas/bp-storefront*` external,
8
+ * so a theme has to hand the component every named export it uses at runtime. That makes the set
9
+ * of names a contract between two independently-released things: publish a component that reaches
10
+ * for a name older themes lack and the page renders an error box for every visitor, with nothing
11
+ * to fall back to.
12
+ *
13
+ * Vendoring removes the contract rather than versioning it. The artifact carries the SDK code it
14
+ * was built against, so what a host must still provide shrinks to the handful of packages that
15
+ * genuinely have to be shared (`preact`, `preact/hooks`, `mobx` — see the externals in compile.ts)
16
+ * and cannot grow when we add a feature.
17
+ *
18
+ * The trade is duplication: a page rendering a vendored component ships this code even though the
19
+ * theme already has its own copy. That is the point — the two copies are free to be different
20
+ * versions.
21
+ */
22
+ /** `@ikas/bp-storefront` and its siblings, with an optional subpath. */
23
+ const VENDORED_PKG = /^(@ikas\/bp-storefront(?:-(?:models|config|api|api-client))?)(\/.*)?$/;
24
+ /**
25
+ * True for files that belong to a vendored dependency rather than to component source.
26
+ *
27
+ * Two shapes, because the SDK resolves differently depending on where the build runs: an npm
28
+ * install puts it under `node_modules/@ikas/bp-storefront*`, while inside this monorepo npm
29
+ * workspaces symlink it and esbuild reports the real path under `packages/storefront*`.
30
+ */
31
+ const VENDORED_FILE = /[\\/](?:node_modules[\\/]@ikas[\\/]bp-storefront[^\\/]*|packages[\\/]storefront(?:-(?:api|api-client|config|models))?)[\\/]/;
32
+ export function isVendoredDependencyFile(file) {
33
+ if (!file)
34
+ return false;
35
+ // Anything already inside node_modules is a transitive dependency of a package we chose to
36
+ // vendor, not something a component author wrote — the allowlist has no say over it.
37
+ return file.includes(`${path.sep}node_modules${path.sep}`) || VENDORED_FILE.test(file);
38
+ }
39
+ /**
40
+ * Stand-in for `isomorphic-fetch`, which the SDK imports in three places.
41
+ *
42
+ * That package pulls `node-fetch` in, which references `global` and dies in a browser with
43
+ * "global is not defined" — a failure the monorepo never sees while the SDK is merely *external*,
44
+ * because nothing bundles it there. Vendoring is exactly what makes it reachable, so it has to be
45
+ * aliased away here rather than left to be discovered at runtime.
46
+ *
47
+ * Both build targets already have a native `fetch` (browsers, and Node 18+ for the SSR build), so
48
+ * the shim is a forwarder. It calls through `globalThis` on every invocation instead of capturing
49
+ * the function, which keeps `this` correct (a bare reference throws "Illegal invocation") and lets
50
+ * a host install a polyfill after this module is evaluated.
51
+ */
52
+ const FETCH_SHIM = path.join(os.tmpdir(), "ikas-vendored-fetch-shim.mjs");
53
+ fs.writeFileSync(FETCH_SHIM, "const f = (...args) => globalThis.fetch(...args);\nexport default f;\nexport { f as fetch };\n");
54
+ /**
55
+ * Bundle the storefront SDK into the component artifact.
56
+ *
57
+ * Deep imports stay forbidden for *component* source — the public contract is still "import only
58
+ * from the package root", and a component reaching into `/src/...` is still a bug worth failing
59
+ * on. But the SDK's own modules deep-import each other constantly (97 lazy `import()` calls into
60
+ * `@ikas/bp-storefront-api/src/__api/...` alone), and those are internal business. So the rule is
61
+ * keyed on who is importing, not on what is imported.
62
+ */
63
+ export function vendorStorefrontPlugin() {
64
+ return {
65
+ name: "ikas-vendor-storefront",
66
+ setup(build) {
67
+ build.onResolve({ filter: /^isomorphic-fetch$/ }, () => ({ path: FETCH_SHIM }));
68
+ build.onResolve({ filter: VENDORED_PKG }, (args) => {
69
+ const [, root, subpath] = args.path.match(VENDORED_PKG);
70
+ if (subpath && subpath !== "/" && !isVendoredDependencyFile(args.importer)) {
71
+ return {
72
+ errors: [
73
+ {
74
+ text: `Deep import "${args.path}" is not allowed. Import only from the package root ` +
75
+ `"${root}" — e.g. import { saveCouponCode, getCart } from "${root}". ` +
76
+ `Subpaths like "/dist/..." or "/src/..." are private and may be renamed without ` +
77
+ `notice. If a helper seems missing from the root, it almost always has a public ` +
78
+ `name there (coupon code, for instance, is getCouponCodeForm / ` +
79
+ `setCouponCodeFormCouponCode / submitCouponCodeForm).`,
80
+ },
81
+ ],
82
+ };
83
+ }
84
+ // Returning nothing hands the specifier back to esbuild's normal resolution, which is
85
+ // what pulls the source into the bundle. The default path returns `external: true` here.
86
+ return undefined;
87
+ });
88
+ },
89
+ };
90
+ }
91
+ //# sourceMappingURL=vendor-storefront.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vendor-storefront.js","sourceRoot":"","sources":["../../src/utils/vendor-storefront.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;;;;;;;;;;;;;;;;GAiBG;AAEH,wEAAwE;AACxE,MAAM,YAAY,GAAG,uEAAuE,CAAC;AAE7F;;;;;;GAMG;AACH,MAAM,aAAa,GACjB,6HAA6H,CAAC;AAEhI,MAAM,UAAU,wBAAwB,CAAC,IAAY;IACnD,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACxB,2FAA2F;IAC3F,qFAAqF;IACrF,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,GAAG,eAAe,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzF,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,8BAA8B,CAAC,CAAC;AAC1E,EAAE,CAAC,aAAa,CACd,UAAU,EACV,gGAAgG,CACjG,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO;QACL,IAAI,EAAE,wBAAwB;QAC9B,KAAK,CAAC,KAAK;YACT,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,oBAAoB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;YAEhF,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;gBACjD,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAE,CAAC;gBAEzD,IAAI,OAAO,IAAI,OAAO,KAAK,GAAG,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC3E,OAAO;wBACL,MAAM,EAAE;4BACN;gCACE,IAAI,EACF,gBAAgB,IAAI,CAAC,IAAI,sDAAsD;oCAC/E,IAAI,IAAI,qDAAqD,IAAI,KAAK;oCACtE,iFAAiF;oCACjF,iFAAiF;oCACjF,gEAAgE;oCAChE,sDAAsD;6BACzD;yBACF;qBACF,CAAC;gBACJ,CAAC;gBAED,sFAAsF;gBACtF,yFAAyF;gBACzF,OAAO,SAAS,CAAC;YACnB,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,5 +1,6 @@
1
- import type { ComponentProp } from "../types.js";
2
- import type { IThemePropGroupData } from "./component-helpers.js";
1
+ import type { ComponentProp, ThemeSettingMeta } from "../types.js";
2
+ import type { IThemePropGroupData, WrapperTechnicalTexts } from "./component-helpers.js";
3
+ import type { I18nTree, IProjectI18nData } from "./i18n.js";
3
4
  /**
4
5
  * Shared module data sent to editors (chunk extracted by code splitting)
5
6
  */
@@ -51,6 +52,13 @@ export interface ICodeComponentData {
51
52
  typeId?: string;
52
53
  /** For ENUM props — the enum type ID from TypeStore */
53
54
  enumTypeId?: string;
55
+ /** For NUMBER_RANGE props — slider config (min/max/interval/unit) */
56
+ numberRangeData?: {
57
+ min?: number;
58
+ max?: number;
59
+ interval?: number;
60
+ unit?: string;
61
+ };
54
62
  /** For COMPONENT/COMPONENT_LIST props — map of variable keys to { id, typeId } */
55
63
  privateVarMap?: Record<string, {
56
64
  id: string;
@@ -58,6 +66,29 @@ export interface ICodeComponentData {
58
66
  }>;
59
67
  /** For COMPONENT/COMPONENT_LIST props — restrict which components can be selected */
60
68
  filteredComponentIds?: string[];
69
+ /**
70
+ * Conditional visibility. Resolved from the config's `requiredProp` (a NAME) at broadcast time
71
+ * into the id the editor addresses props by.
72
+ */
73
+ requiredPropId?: string;
74
+ /** For a BOOLEAN gate — which state of `requiredPropId` shows this prop. Defaults to `true`. */
75
+ requiredPropValue?: boolean;
76
+ /** For an ENUM gate — the option's id. */
77
+ requiredEnumOptionId?: string;
78
+ /** For an ENUM gate — the option value `requiredPropId` must hold. */
79
+ requiredEnumOptionValue?: string;
80
+ /** The label and description in an editor language (`en`), from the config's `translations`. */
81
+ translations?: Array<{
82
+ locale: string;
83
+ displayName?: string;
84
+ description?: string;
85
+ }>;
86
+ }>;
87
+ /** The name in an editor language, a store language's default prop values; from the config's `translations`. */
88
+ translations?: Array<{
89
+ locale: string;
90
+ name?: string;
91
+ propValues?: Record<string, unknown>;
61
92
  }>;
62
93
  compiledServerJs: string;
63
94
  compiledClientJs: string;
@@ -78,10 +109,18 @@ export interface ICodeComponentData {
78
109
  id: string;
79
110
  name: string;
80
111
  description?: string;
112
+ requiredProp?: string;
113
+ requiredPropValue?: boolean;
114
+ requiredEnumOptionId?: string;
115
+ requiredEnumOptionValue?: string;
81
116
  children?: Array<{
82
117
  id: string;
83
118
  name: string;
84
119
  description?: string;
120
+ requiredProp?: string;
121
+ requiredPropValue?: boolean;
122
+ requiredEnumOptionId?: string;
123
+ requiredEnumOptionValue?: string;
85
124
  }>;
86
125
  }>;
87
126
  /** Custom IType definitions referenced by this component's props (for portability across projects) */
@@ -105,6 +144,17 @@ export type DevServerMessage = {
105
144
  components: ICodeComponentData[];
106
145
  sharedModules?: ISharedModuleData[];
107
146
  globalStyles?: IGlobalStyleData;
147
+ /** The project's UI texts; `null` when it has none */
148
+ i18n?: IProjectI18nData | null;
149
+ warnings?: string[];
150
+ timestamp: number;
151
+ };
152
+ } | {
153
+ /** The project's UI texts changed (their files, or the config's `i18n`) */
154
+ type: "i18n-update";
155
+ payload: {
156
+ i18n: IProjectI18nData | null;
157
+ warnings?: string[];
108
158
  timestamp: number;
109
159
  };
110
160
  } | {
@@ -151,7 +201,7 @@ export type DevServerMessage = {
151
201
  } | {
152
202
  type: "editor-action";
153
203
  requestId: string;
154
- action: "list-pages" | "list-imported-components" | "import-component" | "add-section-to-page";
204
+ action: "list-pages" | "list-imported-components" | "import-component" | "add-section-to-page" | "add-sections-to-page" | "list-page-sections" | "get-section-values" | "get-section-values-locale" | "get-section-values-routing" | "get-component-props" | "update-section-prop" | "update-section-prop-locale" | "update-section-prop-routing" | "upload-image" | "search-products" | "list-entities" | "get-page-by-type" | "update-page-sections" | "update-page-sections-locale" | "update-page-sections-routing" | "upload-images";
155
205
  payload?: any;
156
206
  } | {
157
207
  type: "editor-action-result";
@@ -159,6 +209,12 @@ export type DevServerMessage = {
159
209
  success: boolean;
160
210
  payload?: any;
161
211
  error?: string;
212
+ /**
213
+ * Server-generated transient failure: the editor handling the action is
214
+ * gone or not back yet. Safe to resend the SAME requestId — the editor
215
+ * deduplicates by it, so a retry can never run the action twice.
216
+ */
217
+ retryable?: boolean;
162
218
  };
163
219
  /**
164
220
  * Messages from editor to dev server
@@ -169,6 +225,24 @@ export type EditorMessage = {
169
225
  type: "request-state";
170
226
  } | {
171
227
  type: "ping";
228
+ } | {
229
+ type: "editor-hello";
230
+ payload?: {
231
+ /** Human-readable identity shown when several tabs are connected. */
232
+ label?: string;
233
+ /** True when the tab is visible at the time of sending. */
234
+ visible?: boolean;
235
+ /**
236
+ * Theme the tab is editing. When connected tabs disagree, an
237
+ * `editor-action` is refused instead of mutating an arbitrary theme.
238
+ */
239
+ themeId?: string;
240
+ /**
241
+ * Stable per-tab id (survives reconnects, dies with the tab). Lets a
242
+ * retried `editor-action` be pinned back to the tab that first got it.
243
+ */
244
+ tabId?: string;
245
+ };
172
246
  } | {
173
247
  type: "create-component";
174
248
  requestId: string;
@@ -208,6 +282,10 @@ export type EditorMessage = {
208
282
  name: string;
209
283
  description?: string;
210
284
  parentGroupId?: string;
285
+ requiredProp?: string;
286
+ requiredPropValue?: boolean;
287
+ requiredEnumOptionId?: string;
288
+ requiredEnumOptionValue?: string;
211
289
  };
212
290
  };
213
291
  } | {
@@ -219,6 +297,10 @@ export type EditorMessage = {
219
297
  propGroup: {
220
298
  name?: string;
221
299
  description?: string;
300
+ requiredProp?: string;
301
+ requiredPropValue?: boolean;
302
+ requiredEnumOptionId?: string;
303
+ requiredEnumOptionValue?: string;
222
304
  };
223
305
  };
224
306
  } | {
@@ -247,6 +329,22 @@ export type EditorMessage = {
247
329
  /** Zero-based index inside the target parent's children list (or root list). Appends when omitted. */
248
330
  index?: number;
249
331
  };
332
+ } | {
333
+ /** The editor saved a dev component's technical texts (Editor Texts page). */
334
+ type: "update-translations";
335
+ requestId: string;
336
+ payload: {
337
+ componentId: string;
338
+ } & WrapperTechnicalTexts;
339
+ } | {
340
+ /** The editor saved the project's UI texts (Store Translations page): the base ones and the sent languages' */
341
+ type: "update-i18n";
342
+ requestId: string;
343
+ payload: {
344
+ projectId: string;
345
+ base: I18nTree;
346
+ locales: Record<string, I18nTree>;
347
+ };
250
348
  } | {
251
349
  type: "sync-types";
252
350
  payload: {
@@ -259,6 +357,8 @@ export type EditorMessage = {
259
357
  enumOptions?: Record<string, string>;
260
358
  }>;
261
359
  customTypes?: Array<Record<string, any>>;
360
+ /** Theme global variables (Styles panel) — drives the typed key union in global-types.ts. */
361
+ themeSettings?: Array<ThemeSettingMeta>;
262
362
  };
263
363
  } | {
264
364
  type: "request-types";
@@ -283,10 +383,22 @@ export type EditorMessage = {
283
383
  payload: {
284
384
  enumId: string;
285
385
  };
386
+ } | {
387
+ type: "archive-project";
388
+ requestId: string;
389
+ payload: {
390
+ /** Extra directory / file names to leave out, on top of node_modules & co. */
391
+ exclude?: string[];
392
+ /**
393
+ * Local id → published id table applied to the archived source text, so a
394
+ * store downloading it gets a project that already speaks its own ids.
395
+ */
396
+ rewriteIds?: Record<string, string>;
397
+ };
286
398
  } | {
287
399
  type: "editor-action";
288
400
  requestId: string;
289
- action: "list-pages" | "list-imported-components" | "import-component" | "add-section-to-page";
401
+ action: "list-pages" | "list-imported-components" | "import-component" | "add-section-to-page" | "add-sections-to-page" | "list-page-sections" | "get-section-values" | "get-section-values-locale" | "get-section-values-routing" | "get-component-props" | "update-section-prop" | "update-section-prop-locale" | "update-section-prop-routing" | "upload-image" | "search-products" | "list-entities" | "get-page-by-type" | "update-page-sections" | "update-page-sections-locale" | "update-page-sections-routing" | "upload-images";
290
402
  payload?: any;
291
403
  } | {
292
404
  type: "editor-action-result";
@@ -303,6 +415,9 @@ export interface EditorMessageHandlers {
303
415
  components: ICodeComponentData[];
304
416
  sharedModules: ISharedModuleData[];
305
417
  globalStyles?: IGlobalStyleData;
418
+ i18n?: IProjectI18nData | null;
419
+ /** What the editor shows as a warning: UI texts left out, translations the config holds wrong. */
420
+ warnings?: string[];
306
421
  };
307
422
  onCreateComponent?: (name: string, type?: "component" | "section") => Promise<{
308
423
  id: string;
@@ -315,14 +430,28 @@ export interface EditorMessageHandlers {
315
430
  name: string;
316
431
  description?: string;
317
432
  parentGroupId?: string;
433
+ requiredProp?: string;
434
+ requiredPropValue?: boolean;
435
+ requiredEnumOptionId?: string;
436
+ requiredEnumOptionValue?: string;
318
437
  }) => Promise<void>;
319
438
  onUpdatePropGroup?: (componentId: string, propGroupId: string, propGroup: {
320
439
  name?: string;
321
440
  description?: string;
441
+ requiredProp?: string;
442
+ requiredPropValue?: boolean;
443
+ requiredEnumOptionId?: string;
444
+ requiredEnumOptionValue?: string;
322
445
  }) => Promise<void>;
323
446
  onDeletePropGroup?: (componentId: string, propGroupId: string) => Promise<void>;
324
447
  onMovePropToGroup?: (componentId: string, propName: string, groupId: string | null) => Promise<void>;
325
448
  onMovePropGroup?: (componentId: string, propGroupId: string, parentGroupId: string | null, index?: number) => Promise<void>;
449
+ /** The editor saved a dev component's technical texts (Editor Texts page): write them to the config. */
450
+ onUpdateTranslations?: (componentId: string, texts: WrapperTechnicalTexts) => Promise<void>;
451
+ onUpdateI18n?: (projectId: string, texts: {
452
+ base: I18nTree;
453
+ locales: Record<string, I18nTree>;
454
+ }) => Promise<void>;
326
455
  onSyncTypes?: (types: Array<{
327
456
  id: string;
328
457
  name: string;
@@ -330,7 +459,7 @@ export interface EditorMessageHandlers {
330
459
  category: "type" | "enum";
331
460
  sectionAllowed: boolean;
332
461
  enumOptions?: Record<string, string>;
333
- }>, customTypes?: Array<Record<string, any>>) => void;
462
+ }>, customTypes?: Array<Record<string, any>>, themeSettings?: Array<ThemeSettingMeta>) => void;
334
463
  onRequestTypes?: () => Array<{
335
464
  id: string;
336
465
  name: string;
@@ -344,6 +473,18 @@ export interface EditorMessageHandlers {
344
473
  }>;
345
474
  onUpdateEnum?: (enumId: string, name?: string, enumOptions?: Record<string, string>) => Promise<void>;
346
475
  onDeleteEnum?: (enumId: string) => Promise<void>;
476
+ onArchiveProject?: (payload: {
477
+ exclude?: string[];
478
+ rewriteIds?: Record<string, string>;
479
+ }) => Promise<ArchiveProjectCommandResult>;
480
+ }
481
+ export interface ArchiveProjectCommandResult {
482
+ /** Folder that was archived (the dev server's cwd). */
483
+ rootDir: string;
484
+ size: number;
485
+ fileCount: number;
486
+ /** The zip itself, base64 — the editor hands it to the ikas backend. */
487
+ contentBase64: string;
347
488
  }
348
489
  /**
349
490
  * Dev server WebSocket manager
@@ -351,10 +492,13 @@ export interface EditorMessageHandlers {
351
492
  export declare class DevServerWebSocket {
352
493
  private wss;
353
494
  private httpServer;
354
- private clients;
355
495
  private port;
356
496
  private pendingEditorActions;
357
- constructor(port?: number);
497
+ private clientInfo;
498
+ private forwardedEditorActions;
499
+ /** What a control client sends to drive the editor (see `writeDevServerToken`); none: every action is refused. */
500
+ private token;
501
+ constructor(port?: number, token?: string);
358
502
  /**
359
503
  * Start the WebSocket server
360
504
  */
@@ -369,6 +513,20 @@ export declare class DevServerWebSocket {
369
513
  * dead socket.
370
514
  */
371
515
  private dropPendingEditorActionsForClient;
516
+ /**
517
+ * Pick the single editor that should run an `editor-action`, preferring the
518
+ * tab the user is looking at: most recently visible, then most recently
519
+ * active. Control clients are never targets.
520
+ *
521
+ * The server has no theme identity of its own, so ambiguity is refused, not
522
+ * guessed at: tabs reporting DIFFERENT themes → `conflictingThemes`; a tab
523
+ * with NO theme identity (old build or still loading) next to identified
524
+ * ones → `hasUnidentified` — that tab could be on any theme, and routing
525
+ * either way risks silently mutating the wrong one. Only an unambiguous
526
+ * pool (all identified with one theme, or all unidentified legacy tabs) is
527
+ * ranked.
528
+ */
529
+ private pickEditorActionTarget;
372
530
  /**
373
531
  * Send message to a specific client
374
532
  */