@salesforce/storefront-next-dev 0.1.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.
Files changed (33) hide show
  1. package/LICENSE.txt +181 -0
  2. package/README.md +302 -0
  3. package/dist/cartridge-services/index.d.ts +60 -0
  4. package/dist/cartridge-services/index.d.ts.map +1 -0
  5. package/dist/cartridge-services/index.js +954 -0
  6. package/dist/cartridge-services/index.js.map +1 -0
  7. package/dist/cli.js +3373 -0
  8. package/dist/configs/react-router.config.d.ts +13 -0
  9. package/dist/configs/react-router.config.d.ts.map +1 -0
  10. package/dist/configs/react-router.config.js +36 -0
  11. package/dist/configs/react-router.config.js.map +1 -0
  12. package/dist/extensibility/templates/install-instructions.mdc.hbs +192 -0
  13. package/dist/extensibility/templates/uninstall-instructions.mdc.hbs +137 -0
  14. package/dist/index.d.ts +327 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +2606 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/mrt/sfnext-server-chunk-DUt5XHAg.mjs +1 -0
  19. package/dist/mrt/sfnext-server-jiti-DjnmHo-6.mjs +10 -0
  20. package/dist/mrt/sfnext-server-jiti-DjnmHo-6.mjs.map +1 -0
  21. package/dist/mrt/ssr.d.ts +19 -0
  22. package/dist/mrt/ssr.d.ts.map +1 -0
  23. package/dist/mrt/ssr.mjs +246 -0
  24. package/dist/mrt/ssr.mjs.map +1 -0
  25. package/dist/mrt/streamingHandler.d.ts +11 -0
  26. package/dist/mrt/streamingHandler.d.ts.map +1 -0
  27. package/dist/mrt/streamingHandler.mjs +255 -0
  28. package/dist/mrt/streamingHandler.mjs.map +1 -0
  29. package/dist/react-router/Scripts.d.ts +36 -0
  30. package/dist/react-router/Scripts.d.ts.map +1 -0
  31. package/dist/react-router/Scripts.js +68 -0
  32. package/dist/react-router/Scripts.js.map +1 -0
  33. package/package.json +157 -0
@@ -0,0 +1,327 @@
1
+ import { Project } from "ts-morph";
2
+ import { Express } from "express";
3
+ import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
4
+ import { ServerBuild } from "react-router";
5
+
6
+ //#region src/plugins/staticRegistry.d.ts
7
+
8
+ /**
9
+ * Configuration options for the static registry plugin
10
+ */
11
+ interface StaticRegistryPluginConfig {
12
+ /**
13
+ * Path to the components directory to scan
14
+ * @default 'src/components'
15
+ */
16
+ componentPath?: string;
17
+ /**
18
+ * Path to the registry file to update
19
+ * Note: The registry file must contain STATIC_REGISTRY_START and STATIC_REGISTRY_END markers
20
+ * and must export a 'registry' variable (or use registryIdentifier to specify a different name)
21
+ * @default 'src/lib/registry.ts'
22
+ */
23
+ registryPath?: string;
24
+ /**
25
+ * Name of the registry variable to use in generated code
26
+ * @default 'registry'
27
+ */
28
+ registryIdentifier?: string;
29
+ /**
30
+ * Whether to fail the build on registry generation errors
31
+ * @default true
32
+ */
33
+ failOnError?: boolean;
34
+ /**
35
+ * Enable verbose logging
36
+ * @default false
37
+ */
38
+ verbose?: boolean;
39
+ }
40
+ //#endregion
41
+ //#region src/plugins/eventInstrumentationValidator.d.ts
42
+
43
+ /**
44
+ * Configuration options for the event instrumentation validator plugin
45
+ */
46
+ interface EventInstrumentationValidatorConfig {
47
+ /**
48
+ * Path to config module relative to project root
49
+ * @default 'config.server.ts'
50
+ */
51
+ configPath?: string;
52
+ /**
53
+ * Directories to scan for trackEvent calls relative to project root
54
+ * @default ['src']
55
+ */
56
+ scanPaths?: string[];
57
+ /**
58
+ * Whether to fail the build on missing instrumentation
59
+ * @default false (warning only)
60
+ */
61
+ failOnMissing?: boolean;
62
+ /**
63
+ * Enable verbose logging
64
+ * @default false
65
+ */
66
+ verbose?: boolean;
67
+ }
68
+ //#endregion
69
+ //#region src/plugin.d.ts
70
+
71
+ /**
72
+ * Configuration options for the Storefront Next Vite plugin.
73
+ */
74
+ interface StorefrontNextPluginsConfig {
75
+ /**
76
+ * Enable human-readable chunk file names for easier debugging in production builds.
77
+ * When enabled, chunk files will be named based on their source location
78
+ * rather than just the file name and random hashes.
79
+ *
80
+ * This is useful to identify the chunk files and is usually used in development,
81
+ * in conjunction with the bundle analyzer.
82
+ *
83
+ * Example:
84
+ *
85
+ * ```
86
+ * (package)-(pkg-name)-index.[hash].js
87
+ * (components)-(ui)-(inputs)-(TextField)-index.[hash].js
88
+ * ```
89
+ *
90
+ * Instead of:
91
+ *
92
+ * ```
93
+ * index.[hash].js
94
+ * ```
95
+ *
96
+ * @default false
97
+ */
98
+ readableChunkNames?: boolean;
99
+ /**
100
+ * Configuration for the static registry plugin that automatically generates
101
+ * component registrations based on @Component decorators.
102
+ *
103
+ * Set to `false` to disable the static registry plugin entirely.
104
+ *
105
+ * @default { componentPath: 'src/components', registryPath: 'src/lib/registry.ts' }
106
+ */
107
+ staticRegistry?: StaticRegistryPluginConfig;
108
+ /**
109
+ * Configuration for the event instrumentation validator plugin that validates
110
+ * all enabled analytics event toggles have corresponding trackEvent() calls.
111
+ *
112
+ * Set to `false` to disable the validator entirely.
113
+ *
114
+ * @default { configPath: 'config.server.ts', scanPaths: ['src'], failOnMissing: false }
115
+ */
116
+ eventInstrumentationValidator?: EventInstrumentationValidatorConfig | false;
117
+ }
118
+ /**
119
+ * Storefront Next Vite plugin that powers the React Router RSC app.
120
+ * Supports building and optimizing for the managed runtime environment.
121
+ *
122
+ * @param config - Configuration options for the plugin
123
+ * @returns {Plugin[]} An array of Vite plugins for Storefront Next functionality
124
+ *
125
+ * @example
126
+ * // With default options
127
+ * export default defineConfig({
128
+ * plugins: [storefrontNextPlugins()]
129
+ * })
130
+ *
131
+ * @example
132
+ * // Disable readable chunk names
133
+ * export default defineConfig({
134
+ * plugins: [storefrontNextPlugins({ readableChunkNames: false })]
135
+ * })
136
+ */
137
+ declare function storefrontNextPlugins(config?: StorefrontNextPluginsConfig): Plugin[];
138
+ //#endregion
139
+ //#region src/plugins/transformPlugins.d.ts
140
+ declare function transformPluginPlaceholderPlugin(): {
141
+ name: string;
142
+ enforce: "pre";
143
+ configResolved(config: ResolvedConfig): void;
144
+ buildStart(): void;
145
+ transform(code: string, id: string): {
146
+ code: string;
147
+ map: null;
148
+ } | null;
149
+ };
150
+ //#endregion
151
+ //#region src/types.d.ts
152
+
153
+ interface PushOptions {
154
+ projectDirectory: string;
155
+ buildDirectory?: string;
156
+ message?: string;
157
+ projectSlug?: string;
158
+ target?: string;
159
+ cloudOrigin?: string;
160
+ credentialsFile?: string;
161
+ user?: string;
162
+ key?: string;
163
+ wait?: boolean;
164
+ }
165
+ //#endregion
166
+ //#region src/commands/push.d.ts
167
+ /**
168
+ * Main function to push bundle to Managed Runtime
169
+ */
170
+ declare function push(options: PushOptions): Promise<void>;
171
+ //#endregion
172
+ //#region src/server/config.d.ts
173
+ /**
174
+ * Server configuration extracted from environment variables
175
+ */
176
+ interface ServerConfig {
177
+ commerce: {
178
+ api: {
179
+ shortCode: string;
180
+ organizationId: string;
181
+ clientId: string;
182
+ siteId: string;
183
+ proxy: string;
184
+ };
185
+ };
186
+ }
187
+ /**
188
+ * This is a temporary function before we move the config implementation from
189
+ * template-retail-rsc-app to the SDK.
190
+ *
191
+ * @ TODO: Remove this function after we move the config implementation from
192
+ * template-retail-rsc-app to the SDK.
193
+ *
194
+ */
195
+ declare function loadConfigFromEnv(): ServerConfig;
196
+ /**
197
+ * Load storefront-next project configuration from config.server.ts.
198
+ * Requires projectDirectory to be provided.
199
+ *
200
+ * @param projectDirectory - Project directory to load config.server.ts from
201
+ * @throws Error if config.server.ts is not found or invalid
202
+ */
203
+ declare function loadProjectConfig(projectDirectory: string): Promise<ServerConfig>;
204
+ //#endregion
205
+ //#region src/server/modes.d.ts
206
+ /**
207
+ * Copyright 2026 Salesforce, Inc.
208
+ *
209
+ * Licensed under the Apache License, Version 2.0 (the "License");
210
+ * you may not use this file except in compliance with the License.
211
+ * You may obtain a copy of the License at
212
+ *
213
+ * http://www.apache.org/licenses/LICENSE-2.0
214
+ *
215
+ * Unless required by applicable law or agreed to in writing, software
216
+ * distributed under the License is distributed on an "AS IS" BASIS,
217
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
218
+ * See the License for the specific language governing permissions and
219
+ * limitations under the License.
220
+ */
221
+ type ServerMode = 'development' | 'preview' | 'production';
222
+ /**
223
+ * Feature flags for each server mode
224
+ */
225
+ interface ServerModeFeatures {
226
+ /** Enable Commerce API proxy middleware to forward /mobify/proxy/api requests to SCAPI */
227
+ enableProxy: boolean;
228
+ /** Enable static file serving from build/client directory */
229
+ enableStaticServing: boolean;
230
+ /** Enable gzip/brotli compression middleware for responses */
231
+ enableCompression: boolean;
232
+ /** Enable HTTP request/response logging */
233
+ enableLogging: boolean;
234
+ /** Enable patching of asset URLs with bundle path (for CDN deployment) */
235
+ enableAssetUrlPatching: boolean;
236
+ }
237
+ //#endregion
238
+ //#region src/server/index.d.ts
239
+ interface ServerOptions extends Partial<ServerModeFeatures> {
240
+ /** Server mode: development (with Vite), preview (preview), or production (minimal) */
241
+ mode: ServerMode;
242
+ /** Project root directory (optional, defaults to process.cwd()) */
243
+ projectDirectory?: string;
244
+ /** Server configuration (optional, will load from env vars if not provided) */
245
+ config?: ServerConfig;
246
+ /** Server port (optional, for logging) */
247
+ port?: number;
248
+ /** Vite dev server instance (required for development mode) */
249
+ vite?: ViteDevServer;
250
+ /** React Router server build (required for preview/production modes) */
251
+ build?: ServerBuild;
252
+ /** Enable streaming of responses */
253
+ streaming?: boolean;
254
+ }
255
+ /**
256
+ * Create a unified Express server for development, preview, or production mode
257
+ */
258
+ declare function createServer(options: ServerOptions): Promise<Express>;
259
+ //#endregion
260
+ //#region src/extensibility/extension-config.d.ts
261
+ /**
262
+ * Copyright 2026 Salesforce, Inc.
263
+ *
264
+ * Licensed under the Apache License, Version 2.0 (the "License");
265
+ * you may not use this file except in compliance with the License.
266
+ * You may obtain a copy of the License at
267
+ *
268
+ * http://www.apache.org/licenses/LICENSE-2.0
269
+ *
270
+ * Unless required by applicable law or agreed to in writing, software
271
+ * distributed under the License is distributed on an "AS IS" BASIS,
272
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
273
+ * See the License for the specific language governing permissions and
274
+ * limitations under the License.
275
+ */
276
+ type ExtensionMeta = {
277
+ name: string;
278
+ description: string;
279
+ installationInstructions: string;
280
+ uninstallationInstructions: string;
281
+ folder: string;
282
+ dependencies: string[];
283
+ defaultOn?: boolean;
284
+ };
285
+ declare const ExtensionConfig: {
286
+ extensions: Record<string, ExtensionMeta>;
287
+ };
288
+ //#endregion
289
+ //#region src/extensibility/trim-extensions.d.ts
290
+ type ExtensionsSelection = Record<string, boolean>;
291
+ declare function trimExtensions(directory: string, selectedExtensions?: Partial<ExtensionsSelection>, extensionConfig?: typeof ExtensionConfig, verboseOverride?: boolean): void;
292
+ //#endregion
293
+ //#region src/cartridge-services/generate-cartridge.d.ts
294
+ /**
295
+ * Options for generateMetadata function
296
+ */
297
+ interface GenerateMetadataOptions {
298
+ /**
299
+ * Optional array of specific file paths to process.
300
+ * If provided, only these files will be processed and existing cartridge files will NOT be deleted.
301
+ * If omitted, the entire src/ directory will be scanned and all existing cartridge files will be deleted first.
302
+ */
303
+ filePaths?: string[];
304
+ /**
305
+ * Whether to run ESLint with --fix on generated JSON files to format them according to project settings.
306
+ * Defaults to true.
307
+ */
308
+ lintFix?: boolean;
309
+ /**
310
+ * If true, scans files and reports what would be generated without actually writing any files or deleting directories.
311
+ * Defaults to false.
312
+ */
313
+ dryRun?: boolean;
314
+ }
315
+ /**
316
+ * Result returned by generateMetadata function
317
+ */
318
+ interface GenerateMetadataResult {
319
+ componentsGenerated: number;
320
+ pageTypesGenerated: number;
321
+ aspectsGenerated: number;
322
+ totalFiles: number;
323
+ }
324
+ declare function generateMetadata(projectDirectory: string, metadataDirectory: string, options?: GenerateMetadataOptions): Promise<GenerateMetadataResult>;
325
+ //#endregion
326
+ export { type GenerateMetadataOptions, type GenerateMetadataResult, type PushOptions, type StorefrontNextPluginsConfig, createServer, storefrontNextPlugins as default, generateMetadata, loadConfigFromEnv, loadProjectConfig, push, transformPluginPlaceholderPlugin, trimExtensions };
327
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":["ExtensionMeta","ExtensionConfig","Record","default"],"sources":["../src/plugins/staticRegistry.ts","../src/plugins/eventInstrumentationValidator.ts","../src/plugin.ts","../src/plugins/transformPlugins.ts","../src/types.ts","../src/commands/push.ts","../src/server/config.ts","../src/server/modes.ts","../src/server/index.ts","../src/extensibility/extension-config.d.ts","../src/extensibility/trim-extensions.ts","../src/cartridge-services/generate-cartridge.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport type ExtensionMeta = {\n name: string;\n description: string;\n installationInstructions: string;\n uninstallationInstructions: string;\n folder: string;\n dependencies: string[];\n defaultOn?: boolean;\n};\n\ndeclare const ExtensionConfig: {\n extensions: Record<string, ExtensionMeta>;\n};\n\nexport default ExtensionConfig;\n"],"mappings":";;;;;;;;;;AOeY,UPsCK,0BAAA,COtCK;EAKL;;;;ECYA,aAAA,CAAA,EAAc,MAAA;EAAgB;;;;;;EAAD,YAAA,CAAA,EAAA,MAAA;EA0BxB;;;;EAA6C,kBAAA,CAAA,EAAA,MAAA;;;;AC3CnE;EAUcC,WAAAA,CAAAA,EAAAA,OAEb;;;;ACJqD;EAW9B,OAAA,CAAA,EAAA,OAAc;;;;;;;;APRtB,UFFC,mCAAA,CEWc;;;;ACc/B;;;;AChBA;;;;ACXA;AAoBA;AAuDA;;;;AClFA;AAKA;;;;;;;AJMA;;UDKiB,2BAAA;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