@omg-dev/vite-plugin 0.4.29 → 0.4.30

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.mjs CHANGED
@@ -457,29 +457,6 @@ function isAppEntry(id, root) {
457
457
  }
458
458
  //#endregion
459
459
  //#region src/index.ts
460
- async function pwaDeclaresSubpathExport(resolve, importer, subpath) {
461
- try {
462
- const rootEntry = await resolve("@omg-dev/pwa", importer);
463
- if (!rootEntry?.id) return false;
464
- let dir = path.dirname(rootEntry.id.split("?")[0]);
465
- for (let i = 0; i < 12; i++) {
466
- const pkgPath = path.join(dir, "package.json");
467
- if (fs.existsSync(pkgPath)) try {
468
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
469
- if (pkg.name === "@omg-dev/pwa") {
470
- const exp = pkg.exports;
471
- return !!exp && typeof exp === "object" && subpath in exp;
472
- }
473
- } catch {}
474
- const parent = path.dirname(dir);
475
- if (parent === dir) break;
476
- dir = parent;
477
- }
478
- return false;
479
- } catch {
480
- return false;
481
- }
482
- }
483
460
  function vibes(opts = {}) {
484
461
  let resolvedRoot;
485
462
  let config;
@@ -487,7 +464,6 @@ function vibes(opts = {}) {
487
464
  const pwaEnabled = opts.pwa !== false;
488
465
  const pwaOpts = typeof opts.pwa === "object" ? opts.pwa : {};
489
466
  let pwaAutoInjected = false;
490
- let remixCtaInjected = false;
491
467
  const feedbackEnabled = opts.feedback !== false;
492
468
  let feedbackInjected = false;
493
469
  const brandBadgeEnabled = opts.brandBadge !== false;
@@ -1032,12 +1008,6 @@ window.__VIBES_AUTH_SESSION_URL = "/__vibes/auth/session";
1032
1008
  pwaAutoInjected = true;
1033
1009
  imports.push(`import "@omg-dev/pwa/auto";`);
1034
1010
  }
1035
- if (pwaEnabled && !brandBadgeEnabled && !remixCtaInjected) {
1036
- if (await pwaDeclaresSubpathExport((source, importer) => this.resolve(source, importer), id, "./remix-cta")) {
1037
- remixCtaInjected = true;
1038
- imports.push(`import "@omg-dev/pwa/remix-cta";`);
1039
- }
1040
- }
1041
1011
  if (imports.length === 0) return null;
1042
1012
  return {
1043
1013
  code: `${code}\n${imports.join("\n")}\n`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omg-dev/vite-plugin",
3
- "version": "0.4.29",
3
+ "version": "0.4.30",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -15,8 +15,8 @@
15
15
  "build": "vp pack src/index.ts --no-fail-on-warn"
16
16
  },
17
17
  "dependencies": {
18
- "@omg-dev/server": "0.4.29",
19
- "@omg-dev/schema": "0.4.29",
18
+ "@omg-dev/server": "0.4.30",
19
+ "@omg-dev/schema": "0.4.30",
20
20
  "ws": "^8.18.0"
21
21
  },
22
22
  "devDependencies": {
@@ -71,17 +71,15 @@ describe("brand badge injection", () => {
71
71
  expect(context.warnings.some((w) => w.includes("brand badge"))).toBe(true)
72
72
  })
73
73
 
74
- test("badge ON bundles feedback + remix: no standalone imports injected", async () => {
74
+ test("badge ON bundles feedback: no standalone feedback import injected", async () => {
75
75
  // brand badge default ON, with feedback + pwa also on. The badge carries
76
- // feedback (button-less) and the "Make it mine" CTA itself, so the
77
- // standalone feedback/auto + remix-cta imports must NOT be appended.
76
+ // feedback (button-less), so standalone feedback/auto must not be appended.
78
77
  const plugin = vibes({ root: ROOT })
79
78
  const configResolved = plugin.configResolved as (cfg: unknown) => void
80
79
  configResolved({ command: "build", root: ROOT })
81
80
  const out = await runTransform(plugin, "export default 1", ENTRY, ctx())
82
81
  expect(out?.code).toContain(BRAND_IMPORT)
83
82
  expect(out?.code).not.toContain(`import "@omg-dev/sdk/feedback/auto";`)
84
- expect(out?.code).not.toContain(`import "@omg-dev/pwa/remix-cta";`)
85
83
  })
86
84
 
87
85
  test("serve mode never injects the badge", async () => {
package/src/index.ts CHANGED
@@ -46,47 +46,6 @@ export interface VibesOptions {
46
46
  brandBadge?: boolean
47
47
  }
48
48
 
49
- // Resolve @omg-dev/pwa for `importer` and report whether its package.json declares
50
- // the given subpath (e.g. "./remix-cta") in its `exports` map. Used to keep the
51
- // build-time CTA injection skew-safe: an older baked @omg-dev/pwa that predates a
52
- // subpath export must NOT get the import appended, or the bundle fails to resolve.
53
- // Returns false on any resolution / parse hiccup — the CTA is additive, so when
54
- // in doubt we skip it rather than risk breaking the user's build.
55
- async function pwaDeclaresSubpathExport(
56
- resolve: (source: string, importer: string) => Promise<{ id: string } | null>,
57
- importer: string,
58
- subpath: string,
59
- ): Promise<boolean> {
60
- try {
61
- // Resolve the always-present root export, then walk up to the owning
62
- // package.json. We can't resolve "@omg-dev/pwa/package.json" directly because
63
- // an older exports map may not expose "./package.json".
64
- const rootEntry = await resolve("@omg-dev/pwa", importer)
65
- if (!rootEntry?.id) return false
66
- let dir = path.dirname(rootEntry.id.split("?")[0])
67
- for (let i = 0; i < 12; i++) {
68
- const pkgPath = path.join(dir, "package.json")
69
- if (fs.existsSync(pkgPath)) {
70
- try {
71
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"))
72
- if (pkg.name === "@omg-dev/pwa") {
73
- const exp = pkg.exports
74
- return !!exp && typeof exp === "object" && subpath in exp
75
- }
76
- } catch {
77
- // Unreadable/!JSON package.json — keep climbing toward the real one.
78
- }
79
- }
80
- const parent = path.dirname(dir)
81
- if (parent === dir) break
82
- dir = parent
83
- }
84
- return false
85
- } catch {
86
- return false
87
- }
88
- }
89
-
90
49
  // ── Plugin ────────────────────────────────────────────────────────────────────
91
50
 
92
51
  export default function vibes(opts: VibesOptions = {}): Plugin {
@@ -97,7 +56,6 @@ export default function vibes(opts: VibesOptions = {}): Plugin {
97
56
  const pwaEnabled = opts.pwa !== false
98
57
  const pwaOpts: PwaOptions = typeof opts.pwa === "object" ? opts.pwa : {}
99
58
  let pwaAutoInjected = false
100
- let remixCtaInjected = false
101
59
 
102
60
  const feedbackEnabled = opts.feedback !== false
103
61
  let feedbackInjected = false
@@ -813,11 +771,8 @@ window.__VIBES_AUTH_SESSION_URL = "/__vibes/auth/session";
813
771
  },
814
772
 
815
773
  // ── transform ─────────────────────────────────────────────────────────────
816
- // Published builds get two side-effect imports appended to the app entry:
774
+ // Published builds get platform side-effect imports appended to the app entry:
817
775
  // - @omg-dev/pwa/auto — the soft install prompt (gated by autoPrompt)
818
- // - @omg-dev/pwa/remix-cta — the "Make your own" remix bridge (always on
819
- // when pwa is enabled; self-gates on the baked
820
- // VITE_APP_SLUG, so it's inert if not published)
821
776
  // Build-time injection (not template source) so both survive agent rewrites
822
777
  // of main.tsx and never load in dev preview.
823
778
  async transform(code: string, id: string) {
@@ -879,33 +834,6 @@ window.__VIBES_AUTH_SESSION_URL = "/__vibes/auth/session";
879
834
  }
880
835
  }
881
836
 
882
- // "Make your own" remix CTA — independent of autoPrompt. It self-gates at
883
- // runtime on import.meta.env.VITE_APP_SLUG (baked by the orchestrator on
884
- // deploy), so it renders nothing on a non-published build.
885
- //
886
- // Skew guard: the remix-cta subpath shipped in @omg-dev/pwa >= 0.4.16. An app
887
- // whose baked @omg-dev/pwa predates it (e.g. 0.4.12) has no "./remix-cta" in
888
- // its exports map, so injecting the import hard-fails the build with
889
- // "Errored while resolving @omg-dev/pwa/remix-cta". this.resolve() alone is not
890
- // a reliable gate across this version skew, so only inject once we've
891
- // confirmed the resolved package actually declares the subpath export.
892
- //
893
- // The brand badge (default on) now hosts "Make it mine" itself: same omg
894
- // mark, remix CTA first, and it collapses to the plain branding badge on
895
- // dismiss. So only inject the standalone remix-cta when the brand badge is
896
- // off — otherwise we'd render two corner pills with the same intent.
897
- if (pwaEnabled && !brandBadgeEnabled && !remixCtaInjected) {
898
- const exported = await pwaDeclaresSubpathExport(
899
- (source, importer) => this.resolve(source, importer),
900
- id,
901
- "./remix-cta",
902
- )
903
- if (exported) {
904
- remixCtaInjected = true
905
- imports.push(`import "@omg-dev/pwa/remix-cta";`)
906
- }
907
- }
908
-
909
837
  if (imports.length === 0) return null
910
838
  return { code: `${code}\n${imports.join("\n")}\n`, map: null }
911
839
  },