@salesforce/vite-plugin-ui-bundle 10.1.0 → 10.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAqB,MAAM,EAAiB,MAAM,MAAM,CAAC;AAUrE,MAAM,WAAW,aAAa;IAC7B,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,OAAO,GAAE,aAAkB,GAAG,MAAM,EAAE,CAkR5E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,KAAK,EAAqB,MAAM,EAAiB,MAAM,MAAM,CAAC;AASrE,MAAM,WAAW,aAAa;IAC7B,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,OAAO,GAAE,aAAkB,GAAG,MAAM,EAAE,CAkR5E"}
package/dist/index.js CHANGED
@@ -1,93 +1,8 @@
1
1
  import fs from "node:fs";
2
2
  import { loadManifest, getOrgInfo } from "@salesforce/ui-bundle/app";
3
- import { getDesignModeScriptContent } from "@salesforce/ui-bundle/design";
4
3
  import { createProxyHandler, injectLivePreviewScript } from "@salesforce/ui-bundle/proxy";
5
- import { declare } from "@babel/helper-plugin-utils";
6
- function resolveColumn(loc, babelCode, originalSource) {
7
- if (!originalSource || !babelCode) return loc.column;
8
- const babelLine = babelCode.split("\n")[loc.line - 1];
9
- const originalLine = originalSource.split("\n")[loc.line - 1];
10
- if (!babelLine || !originalLine) return loc.column;
11
- const contentFromColumn = babelLine.slice(loc.column);
12
- if (contentFromColumn) {
13
- const idx = originalLine.indexOf(contentFromColumn);
14
- if (idx >= 0) return idx;
15
- }
16
- const babelIndent = babelLine.length - babelLine.trimStart().length;
17
- const originalIndent = originalLine.length - originalLine.trimStart().length;
18
- const offset = babelIndent - originalIndent;
19
- return Math.max(0, loc.column - offset);
20
- }
21
- const reactDesignTimeLocatorBabelPlugin = declare((api) => {
22
- api.assertVersion(7);
23
- const t = api.types;
24
- function isReactFragmentName(nameNode) {
25
- if (t.isJSXIdentifier(nameNode) && nameNode.name === "Fragment") return true;
26
- if (t.isJSXMemberExpression(nameNode) && t.isJSXIdentifier(nameNode.object, { name: "React" }) && t.isJSXIdentifier(nameNode.property, { name: "Fragment" })) {
27
- return true;
28
- }
29
- return false;
30
- }
31
- function hasAttr(openingElement, name) {
32
- return openingElement.attributes.some((attr) => {
33
- return t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name) && attr.name.name === name;
34
- });
35
- }
36
- function addAttr(openingElement, name, value) {
37
- if (hasAttr(openingElement, name)) return;
38
- openingElement.attributes.push(
39
- t.jsxAttribute(t.jsxIdentifier(name), t.stringLiteral(String(value)))
40
- );
41
- }
42
- return {
43
- name: "babel-plugin-react-design-time-locator",
44
- visitor: {
45
- JSXElement(path, state) {
46
- const openingElement = path.node.openingElement;
47
- if (isReactFragmentName(openingElement.name)) return;
48
- if (!t.isJSXIdentifier(openingElement.name) && !t.isJSXMemberExpression(openingElement.name)) {
49
- return;
50
- }
51
- let tagHead = "";
52
- if (t.isJSXIdentifier(openingElement.name)) {
53
- tagHead = openingElement.name.name;
54
- } else if (t.isJSXMemberExpression(openingElement.name)) {
55
- tagHead = openingElement.name.property?.name ?? "";
56
- }
57
- if (!tagHead) return;
58
- const filename = state?.file?.opts?.filename;
59
- if (!filename || filename.includes("node_modules")) return;
60
- const excludePaths = state.opts?.excludePaths ?? [];
61
- if (excludePaths.some((p) => filename.includes(p))) return;
62
- const children = path.node.children ?? [];
63
- const relevantChildren = children.filter((child) => {
64
- return !(t.isJSXText(child) && child.value.trim() === "");
65
- });
66
- let textType = "none";
67
- if (relevantChildren.length === 1) {
68
- const child = relevantChildren[0];
69
- if (t.isJSXText(child)) {
70
- textType = "static";
71
- } else if (t.isJSXExpressionContainer(child)) {
72
- textType = "dynamic";
73
- } else {
74
- textType = "element";
75
- }
76
- } else if (relevantChildren.length > 1) {
77
- textType = "mixed";
78
- }
79
- const loc = path.node.loc;
80
- if (loc?.start) {
81
- const originalSource = state.opts?.originalSource;
82
- const column = resolveColumn(loc.start, state.file?.code, originalSource);
83
- const source = `${filename}:${loc.start.line}:${column}`;
84
- addAttr(openingElement, "data-source-file", source);
85
- }
86
- addAttr(openingElement, "data-text-type", textType);
87
- }
88
- }
89
- };
90
- });
4
+ import { getRuntimeScriptContent } from "@salesforce/ui-design-mode/runtime";
5
+ import reactDesignTimeLocatorBabelPlugin from "@salesforce/ui-design-mode/source-locator/react";
91
6
  const DEFAULT_PORT = 5173;
92
7
  const DEFAULT_API_VERSION = "65.0";
93
8
  function getCodeBuilderBasePath(proxyUri, port) {
@@ -261,7 +176,7 @@ function uiBundlePlugin(options = {}) {
261
176
  const urlPath = stripUrlQuery(req.url);
262
177
  if (urlPath.endsWith("/_sfdc/design-mode-interactions.js")) {
263
178
  try {
264
- const script = getDesignModeScriptContent();
179
+ const script = getRuntimeScriptContent();
265
180
  if (script !== null) {
266
181
  res.setHeader("Content-Type", "application/javascript");
267
182
  res.setHeader("Cache-Control", "no-cache");
@@ -269,7 +184,7 @@ function uiBundlePlugin(options = {}) {
269
184
  return;
270
185
  }
271
186
  console.error(
272
- `[ui-bundle-plugin] Design mode script not found. Run 'npm run build:design' in @salesforce/ui-bundle.`
187
+ `[ui-bundle-plugin] Design mode runtime script not found. Run 'npm run build' in @salesforce/ui-design-mode.`
273
188
  );
274
189
  res.writeHead(404);
275
190
  res.end("Design mode script not found");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@salesforce/vite-plugin-ui-bundle",
3
3
  "description": "Vite plugin for Salesforce UI Bundles",
4
- "version": "10.1.0",
4
+ "version": "10.2.1",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -27,12 +27,11 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@babel/core": "^7.28.4",
30
- "@babel/helper-plugin-utils": "^7.28.3",
31
- "@salesforce/ui-bundle": "^10.1.0"
30
+ "@salesforce/ui-bundle": "^10.2.1",
31
+ "@salesforce/ui-design-mode": "^10.2.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/babel__core": "^7.20.5",
35
- "@types/babel__helper-plugin-utils": "^7.10.3",
36
35
  "vite": "^7.0.0",
37
36
  "vite-plugin-dts": "^4.5.4",
38
37
  "vitest": "^4.0.6"
@@ -1,13 +0,0 @@
1
- /**
2
- * Copyright (c) 2026, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
- declare const reactDesignTimeLocatorBabelPlugin: (api: object, options: Record<string, any> | null | undefined, dirname: string) => {
7
- name: string;
8
- visitor: {
9
- JSXElement(this: import('@babel/core').PluginPass, path: any, state: any): void;
10
- };
11
- };
12
- export default reactDesignTimeLocatorBabelPlugin;
13
- //# sourceMappingURL=reactDesignTimeLocatorBabelPlugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactDesignTimeLocatorBabelPlugin.d.ts","sourceRoot":"","sources":["../../src/babel/reactDesignTimeLocatorBabelPlugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA4CH,QAAA,MAAM,iCAAiC;;;iEAiCnB,GAAG,SAAS,GAAG;;CA0EjC,CAAC;AAEH,eAAe,iCAAiC,CAAC"}