@hook-sdk/template 0.23.1 → 0.23.2

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.cts CHANGED
@@ -208,26 +208,27 @@ type AppRootProps = AppRootSlots & {
208
208
  declare function AppRoot(props: AppRootProps): react_jsx_runtime.JSX.Element;
209
209
 
210
210
  /**
211
- * Build-time + runtime gate for dev-only tools (e.g. <DevSkipOnboardingFab>).
211
+ * Runtime gate for dev-only tools (e.g. <DevSkipOnboardingFab>).
212
212
  *
213
- * Two independent signals must agree:
213
+ * History:
214
+ * v0.23.0 / v0.23.1 also gated on `import.meta.env.VITE_HOOK_DEV_TOOLS`.
215
+ * That was intended as a build-time DCE signal so the dev module would
216
+ * tree-shake out of prod bundles. Empirically vite's static replacement
217
+ * does NOT apply to template code consumed from node_modules when the
218
+ * creator app uses `build.lib` mode — every consumer ended up with
219
+ * `undefined !== '1'` → DCE killed the FAB from STAGING bundles too.
214
220
  *
215
- * 1. Build-time: `import.meta.env.VITE_HOOK_DEV_TOOLS === '1'`. Vite folds
216
- * this constant at the consumer app's build time when unset, the
217
- * entire dev tree is tree-shaken from the prod bundle. Set
218
- * `VITE_HOOK_DEV_TOOLS=1` only in the staging build env.
221
+ * Pragmatic fix: drop the env gate and rely on the runtime hostname
222
+ * check alone. The FAB code now ships in prod bundles too (~5 KB), but
223
+ * it never renders on prod hostnames because `.staging.` / `localhost`
224
+ * is the only path that returns `true`. Visual safety = hostname check
225
+ * at render. Compliance / privacy = no real user can ever trigger the
226
+ * auto-signup branch on a `usehook.net` (prod) origin.
219
227
  *
220
- * 2. Runtime: hostname must be staging-ish. Belt-and-suspenders against
221
- * a misconfigured build that somehow ships the FAB to prod.
222
- *
223
- * IMPORTANT: the env access MUST be the literal token
224
- * `import.meta.env.VITE_HOOK_DEV_TOOLS`. Vite's static replacement is a
225
- * text substitution that only fires on this exact form. Going through a
226
- * local alias (`const meta = import.meta; meta.env.X`) defeats the
227
- * substitution and the consumer bundle ends up with `undefined` regardless
228
- * of what the build env actually has set. See `../vite-env.d.ts` for the
229
- * ambient ImportMeta augmentation that keeps TypeScript happy without a
230
- * cast at the access site.
228
+ * If a creator app wants the build-time DCE back, the consumer's
229
+ * `vite.config.ts` `define` block must explicitly substitute
230
+ * `import.meta.env.VITE_HOOK_DEV_TOOLS` — vite's auto-replacement skips
231
+ * `node_modules` in lib mode.
231
232
  */
232
233
  declare function isDevToolsEnabled(): boolean;
233
234
 
package/dist/index.d.ts CHANGED
@@ -208,26 +208,27 @@ type AppRootProps = AppRootSlots & {
208
208
  declare function AppRoot(props: AppRootProps): react_jsx_runtime.JSX.Element;
209
209
 
210
210
  /**
211
- * Build-time + runtime gate for dev-only tools (e.g. <DevSkipOnboardingFab>).
211
+ * Runtime gate for dev-only tools (e.g. <DevSkipOnboardingFab>).
212
212
  *
213
- * Two independent signals must agree:
213
+ * History:
214
+ * v0.23.0 / v0.23.1 also gated on `import.meta.env.VITE_HOOK_DEV_TOOLS`.
215
+ * That was intended as a build-time DCE signal so the dev module would
216
+ * tree-shake out of prod bundles. Empirically vite's static replacement
217
+ * does NOT apply to template code consumed from node_modules when the
218
+ * creator app uses `build.lib` mode — every consumer ended up with
219
+ * `undefined !== '1'` → DCE killed the FAB from STAGING bundles too.
214
220
  *
215
- * 1. Build-time: `import.meta.env.VITE_HOOK_DEV_TOOLS === '1'`. Vite folds
216
- * this constant at the consumer app's build time when unset, the
217
- * entire dev tree is tree-shaken from the prod bundle. Set
218
- * `VITE_HOOK_DEV_TOOLS=1` only in the staging build env.
221
+ * Pragmatic fix: drop the env gate and rely on the runtime hostname
222
+ * check alone. The FAB code now ships in prod bundles too (~5 KB), but
223
+ * it never renders on prod hostnames because `.staging.` / `localhost`
224
+ * is the only path that returns `true`. Visual safety = hostname check
225
+ * at render. Compliance / privacy = no real user can ever trigger the
226
+ * auto-signup branch on a `usehook.net` (prod) origin.
219
227
  *
220
- * 2. Runtime: hostname must be staging-ish. Belt-and-suspenders against
221
- * a misconfigured build that somehow ships the FAB to prod.
222
- *
223
- * IMPORTANT: the env access MUST be the literal token
224
- * `import.meta.env.VITE_HOOK_DEV_TOOLS`. Vite's static replacement is a
225
- * text substitution that only fires on this exact form. Going through a
226
- * local alias (`const meta = import.meta; meta.env.X`) defeats the
227
- * substitution and the consumer bundle ends up with `undefined` regardless
228
- * of what the build env actually has set. See `../vite-env.d.ts` for the
229
- * ambient ImportMeta augmentation that keeps TypeScript happy without a
230
- * cast at the access site.
228
+ * If a creator app wants the build-time DCE back, the consumer's
229
+ * `vite.config.ts` `define` block must explicitly substitute
230
+ * `import.meta.env.VITE_HOOK_DEV_TOOLS` — vite's auto-replacement skips
231
+ * `node_modules` in lib mode.
231
232
  */
232
233
  declare function isDevToolsEnabled(): boolean;
233
234
 
package/dist/index.js CHANGED
@@ -2099,7 +2099,6 @@ function I18nProvider({
2099
2099
 
2100
2100
  // src/dev/env.ts
2101
2101
  function isDevToolsEnabled() {
2102
- if (import.meta.env.VITE_HOOK_DEV_TOOLS !== "1") return false;
2103
2102
  if (typeof window === "undefined") return false;
2104
2103
  const host = window.location.hostname;
2105
2104
  return host.includes(".staging.") || host === "localhost" || host === "127.0.0.1";