@salesforce/angular-plugin-ui-bundle 11.35.6 → 11.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  export type { SalesforceOptions, Middleware } from "./types.ts";
7
7
  export type { ApiVersionResult } from "./plugins/api-version.ts";
8
8
  export { createApiVersionPlugin } from "./plugins/api-version.ts";
9
+ export { createGraphQLCodegenPlugin } from "./plugins/graphql-codegen.ts";
9
10
  export { DEFAULT_API_VERSION, DEFAULT_PORT, getPort } from "./utils.ts";
10
11
  export { createProxyMiddleware } from "./middleware/proxy.ts";
11
12
  export { createHtmlMiddleware } from "./middleware/html.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAChE,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAChE,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
6
  export { createApiVersionPlugin } from "./plugins/api-version.js";
7
+ export { createGraphQLCodegenPlugin } from "./plugins/graphql-codegen.js";
7
8
  export { DEFAULT_API_VERSION, DEFAULT_PORT, getPort } from "./utils.js";
8
9
  export { createProxyMiddleware } from "./middleware/proxy.js";
9
10
  export { createHtmlMiddleware } from "./middleware/html.js";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+ import type { Plugin } from "esbuild";
7
+ /**
8
+ * esbuild plugin that runs GraphQL codegen during onStart.
9
+ * Skips execution when ANY of the following is true:
10
+ * - schema.graphql or codegen.yml is missing from cwd
11
+ * - No GraphQL-containing source files are found
12
+ * - Combined content signature is unchanged since the last successful run
13
+ *
14
+ * Never throws — warnings are logged to console so the dev server stays alive.
15
+ */
16
+ export declare function createGraphQLCodegenPlugin(): Plugin;
17
+ //# sourceMappingURL=graphql-codegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql-codegen.d.ts","sourceRoot":"","sources":["../../src/plugins/graphql-codegen.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,SAAS,CAAC;AAenD;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAkGnD"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+ import { createHash } from "node:crypto";
7
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
8
+ import { join, resolve } from "node:path";
9
+ const GRAPHQL_PATTERN = /\/\*\s*GraphQL\s*\*\/|gql`/;
10
+ function sha256(content) {
11
+ return createHash("sha256").update(content).digest("hex");
12
+ }
13
+ /**
14
+ * esbuild plugin that runs GraphQL codegen during onStart.
15
+ * Skips execution when ANY of the following is true:
16
+ * - schema.graphql or codegen.yml is missing from cwd
17
+ * - No GraphQL-containing source files are found
18
+ * - Combined content signature is unchanged since the last successful run
19
+ *
20
+ * Never throws — warnings are logged to console so the dev server stays alive.
21
+ */
22
+ export function createGraphQLCodegenPlugin() {
23
+ let previousSignature;
24
+ const docCache = new Map();
25
+ let schemaCache;
26
+ function schemaHash(schemaPath) {
27
+ const st = statSync(schemaPath);
28
+ if (!schemaCache || schemaCache.mtimeMs !== st.mtimeMs || schemaCache.size !== st.size) {
29
+ schemaCache = {
30
+ mtimeMs: st.mtimeMs,
31
+ size: st.size,
32
+ hash: sha256(readFileSync(schemaPath, "utf-8")),
33
+ };
34
+ }
35
+ return schemaCache.hash;
36
+ }
37
+ /**
38
+ * Content signature over the schema plus every GraphQL document under src.
39
+ * Stat-gates each file so only files whose (mtime, size) changed are read
40
+ * and re-classified. Returns undefined when no GraphQL documents exist.
41
+ */
42
+ function computeSignature(cwd, schemaPath) {
43
+ const srcDir = join(cwd, "src");
44
+ if (!existsSync(srcDir))
45
+ return undefined;
46
+ const entries = readdirSync(srcDir, { recursive: true, encoding: "utf-8" });
47
+ const seen = new Set();
48
+ const documentHashes = [];
49
+ for (const rel of entries) {
50
+ const isGraphql = rel.endsWith(".graphql");
51
+ const isTs = rel.endsWith(".ts");
52
+ if (!isGraphql && !isTs)
53
+ continue;
54
+ const fullPath = join(srcDir, rel);
55
+ const st = statSync(fullPath);
56
+ seen.add(rel);
57
+ let entry = docCache.get(rel);
58
+ if (!entry || entry.mtimeMs !== st.mtimeMs || entry.size !== st.size) {
59
+ const content = readFileSync(fullPath, "utf-8");
60
+ const isDocument = isGraphql || GRAPHQL_PATTERN.test(content);
61
+ entry = {
62
+ mtimeMs: st.mtimeMs,
63
+ size: st.size,
64
+ isDocument,
65
+ contentHash: isDocument ? sha256(content) : "",
66
+ };
67
+ docCache.set(rel, entry);
68
+ }
69
+ if (entry.isDocument)
70
+ documentHashes.push(entry.contentHash);
71
+ }
72
+ // Evict deleted files so their disappearance moves the signature.
73
+ for (const key of docCache.keys()) {
74
+ if (!seen.has(key))
75
+ docCache.delete(key);
76
+ }
77
+ if (documentHashes.length === 0)
78
+ return undefined;
79
+ // Sort content hashes (not paths): signature depends only on the set
80
+ // of document contents, so a rename with identical content is a no-op.
81
+ documentHashes.sort();
82
+ const sig = createHash("sha256");
83
+ sig.update(schemaHash(schemaPath));
84
+ for (const h of documentHashes)
85
+ sig.update(h);
86
+ return sig.digest("hex");
87
+ }
88
+ return {
89
+ name: "@salesforce/angular-plugin-ui-bundle:graphql-codegen",
90
+ setup(build) {
91
+ build.onStart(async () => {
92
+ const cwd = process.cwd();
93
+ const schemaPath = resolve(cwd, "../../../../../schema.graphql");
94
+ const codegenPath = resolve(cwd, "codegen.yml");
95
+ if (!existsSync(schemaPath) || !existsSync(codegenPath))
96
+ return;
97
+ try {
98
+ const currentSignature = computeSignature(cwd, schemaPath);
99
+ if (currentSignature === undefined || currentSignature === previousSignature)
100
+ return;
101
+ const { generate, loadContext } = await import("@graphql-codegen/cli");
102
+ const ctx = await loadContext(codegenPath);
103
+ await generate({ ...ctx.getConfig(), watch: false, silent: true });
104
+ previousSignature = currentSignature;
105
+ }
106
+ catch (err) {
107
+ console.warn("[graphql-codegen] Codegen failed (dev server unaffected):", err.message);
108
+ }
109
+ });
110
+ },
111
+ };
112
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@salesforce/angular-plugin-ui-bundle",
3
3
  "description": "Angular CLI plugin for Salesforce UI Bundles",
4
- "version": "11.35.6",
4
+ "version": "11.36.0",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -29,7 +29,7 @@
29
29
  "test:coverage": "vitest run --coverage"
30
30
  },
31
31
  "dependencies": {
32
- "@salesforce/ui-bundle": "^11.35.6",
32
+ "@salesforce/ui-bundle": "^11.36.0",
33
33
  "chokidar": "^4.0.0"
34
34
  },
35
35
  "devDependencies": {
@@ -39,7 +39,8 @@
39
39
  "vitest": "^4.0.6"
40
40
  },
41
41
  "peerDependencies": {
42
- "@angular-builders/custom-esbuild": "^21.0.0"
42
+ "@angular-builders/custom-esbuild": "^21.0.0",
43
+ "@graphql-codegen/cli": "^6.1.0"
43
44
  },
44
45
  "engines": {
45
46
  "node": ">=20.0.0"