browser-extension-manager 1.3.46 → 1.3.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-extension-manager",
3
- "version": "1.3.46",
3
+ "version": "1.3.48",
4
4
  "description": "Browser Extension Manager dependency manager",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
@@ -32,6 +32,9 @@
32
32
  "ext": "bin/browser-extension-manager",
33
33
  "mgr": "bin/browser-extension-manager"
34
34
  },
35
+ "files": [
36
+ "dist"
37
+ ],
35
38
  "preparePackage": {
36
39
  "input": "./src",
37
40
  "output": "./dist",
@@ -91,7 +94,7 @@
91
94
  "npm-api": "^1.0.1",
92
95
  "sass": "^1.98.0",
93
96
  "through2": "^4.0.2",
94
- "web-manager": "^4.1.35",
97
+ "web-manager": "^4.1.36",
95
98
  "webpack": "^5.105.4",
96
99
  "wonderful-fetch": "^2.0.4",
97
100
  "wonderful-version": "^1.3.2",
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- v22/*
package/CHANGELOG.md DELETED
@@ -1,156 +0,0 @@
1
- # CHANGELOG
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6
-
7
- ## Changelog Categories
8
-
9
- - `BREAKING` for breaking changes.
10
- - `Added` for new features.
11
- - `Changed` for changes in existing functionality.
12
- - `Deprecated` for soon-to-be removed features.
13
- - `Removed` for now removed features.
14
- - `Fixed` for any bug fixes.
15
- - `Security` in case of vulnerabilities.
16
-
17
- ---
18
- ## [1.3.44] - 2026-04-01
19
- ### Changed
20
- - Bumped `@anthropic-ai/claude-agent-sdk` from ^0.2.76 to ^0.2.90
21
- - Bumped `@babel/preset-env` from ^7.29.0 to ^7.29.2
22
- - Bumped `dotenv` from ^17.3.1 to ^17.4.0
23
- - Bumped `lodash` from ^4.17.23 to ^4.18.1
24
- - Bumped `minimatch` from ^10.2.4 to ^10.2.5
25
- - Bumped `web-manager` from ^4.1.28 to ^4.1.33
26
- - Bumped `ws` from ^8.19.0 to ^8.20.0
27
-
28
- ## [1.3.43] - 2026-03-16
29
- ### Added
30
- - Set `private: true` on consuming projects during setup to prevent accidental npm publishes
31
-
32
- ## [1.3.42] - 2026-03-15
33
- ### Changed
34
- - Bumped `node-powertools` from ^2.3.2 to ^3.0.0
35
- - Bumped `wonderful-fetch` from ^1.3.4 to ^2.0.4
36
- - Bumped `web-manager` from ^4.1.27 to ^4.1.28
37
- - Bumped `prepare-package` from ^1.2.6 to ^2.0.7
38
- - Added `preparePackage.type: "copy"` config to package.json
39
-
40
- ## [1.3.40] - 2026-03-14
41
- ### Changed
42
- - Migrated `app` references to `brand` namespace (`this.app` → `this.brand.id`, `options.app.id` → `options.brand.id`)
43
- - Nested brand image properties under `brand.images.*` (`brandmark`, `wordmark`, `combomark`)
44
-
45
- ## [1.3.17] - 2025-12-23
46
- ### Changed
47
- - Auth system now uses messaging instead of `chrome.storage` for cross-context sync
48
- - Background.js is the source of truth; contexts sync via `bxm:syncAuth` message on load
49
- - Fresh custom tokens fetched from server only when context UID differs from background UID
50
-
51
- ### Fixed
52
- - Auth failures caused by expired custom tokens (tokens no longer stored, fetched fresh when needed)
53
-
54
- ## [1.3.0] - 2025-12-16
55
-
56
- ### Added
57
- - Multi-target builds for Chromium, Firefox, and Opera with automatic manifest adjustments
58
- - Chromium build uses `background.service_worker`, Firefox build uses `background.scripts`
59
- - Opera build auto-resolves `__MSG_*__` placeholders in `short_name` (Opera enforces 12-char limit including placeholder text)
60
- - Browser-specific `TARGETS` config object with `adjustManifest()` functions for each target
61
- - Opera loading instructions in BUILD_INSTRUCTIONS.md
62
-
63
- ### Changed
64
- - Packaged output structure changed from `packaged/raw/` to `packaged/{chromium,firefox,opera}/raw/`
65
- - Extension zip moved from `packaged/extension.zip` to `packaged/{chromium,firefox,opera}/extension.zip`
66
- - `package.js` now creates separate builds for each browser target using configurable `TARGETS` object
67
- - `publish.js` uses target-specific paths (chromium zip for Chrome/Edge, firefox raw for Firefox, opera zip for Opera)
68
- - `audit.js` audits chromium build (code is identical between targets)
69
- - Manifest compilation now uses 3-step process: apply defaults → target adjustments → cleanup
70
-
71
- ### Fixed
72
- - Packaged extensions no longer include `.scss`, `.sass`, `.ts`, or `.DS_Store` files (caused store rejections)
73
-
74
- ## [1.1.13] - 2025-11-26
75
- ### Added
76
- - Default `.env` file with publish credential templates for all stores
77
- - Intelligent line-based merging for `.gitignore` and `.env` files with section markers
78
- - Template variable support for `.yml` and `.yaml` files
79
-
80
- ### Changed
81
- - Credentials now read from `.env` file instead of config (better security)
82
- - `.gitignore` and `.env` files use section markers to separate defaults from custom values
83
- - Template transform now passes `versions` data for workflow templating
84
-
85
- ## [1.1.6] - 2025-11-14
86
- ### Added
87
- - Bootstrap exposure to `window.bootstrap` in all UI components (popup, options, sidepanel, page)
88
- - `@popperjs/core` dependency for Bootstrap's Dropdown, Tooltip, and Popover components
89
- - Project-specific JS files to webpack watch paths for improved hot reloading
90
-
91
- ### Changed
92
- - Modernized content.js manager from prototype-based to ES6 class syntax with async/await
93
- - Updated affiliatizer import to use dynamic import in content.js
94
- - Improved logging consistency across all manager classes
95
-
96
- ## [1.1.1] - 2025-11-13
97
- ### Changed
98
- - Simplified build.js configuration generation by removing webManager config overrides
99
- - Improved theme JS file watching in webpack config
100
- - Updated Firebase dependencies to latest versions (firebase 12.6.0)
101
-
102
- ### Added
103
- - Cache busting support for CSS/JS includes in page template (?cb={{ cacheBust }})
104
- - build.js script loading to page template for runtime configuration
105
- - web-manager watch path for improved development workflow
106
-
107
- ### Fixed
108
- - Removed verbose logging in background.js initialization
109
- - Browser caching issues during development with cache-busted resource URLs
110
-
111
- ## [1.1.0] - 2025-11-13
112
- ### BREAKING
113
- - Complete CSS architecture overhaul - projects using old structure will need migration
114
- - Removed static Bootstrap CSS files in favor of SCSS source compilation
115
- - Changed default file structure for consuming projects
116
-
117
- ### Added
118
- - Modular component-based CSS architecture
119
- - New main entry point: `browser-extension-manager.scss`
120
- - Core CSS modules: initialize, utilities, animations
121
- - Component-specific CSS directories with bundle support
122
- - Full Bootstrap 5 SCSS source integration
123
- - Classy theme with custom design system
124
- - Theme template (`_template/`) for creating new themes
125
- - New component managers: popup, options, sidepanel, page
126
- - HTML template system via `page-template.html`
127
- - Views directory structure for organized HTML templates
128
- - Component-specific override system in defaults
129
- - New gulp tasks: `html.js`, `audit.js`
130
- - Webpack plugin to strip dev-only code blocks
131
- - `gulp-filter` dependency for advanced build filtering
132
- - Package exports for all component managers
133
-
134
- ### Changed
135
- - Upgraded Bootstrap theme to use full source (scss/) instead of compiled CSS
136
- - Refactored defaults structure with component-specific organization
137
- - Reorganized project architecture for better modularity
138
- - Updated build system to support new component architecture
139
-
140
- ### Removed
141
- - `fontawesome.scss` (moved to component-specific imports)
142
- - `main.scss` (replaced by component system)
143
- - Static Bootstrap CSS/JS files (now compiled from source)
144
- - Legacy HTML pages in `src/defaults/src/pages/`
145
- - Legacy asset structure in defaults
146
- - Obsolete `themes.js` gulp task
147
- - Old static JavaScript files (background.js, popup.js, etc. in defaults)
148
-
149
- ### Fixed
150
- - Improved maintainability with modular architecture
151
- - Better theme customization support
152
- - Enhanced build process for component isolation
153
-
154
- ## [1.0.0] - 2024-06-19
155
- ### Added
156
- - Initial release of the project 🚀
package/CLAUDE.md DELETED
@@ -1,818 +0,0 @@
1
- # Browser Extension Manager (BXM)
2
-
3
- ## Identity
4
-
5
- Browser Extension Manager (BXM) is a comprehensive framework for building modern browser extensions. It provides a template-based development system with built-in build tools, component architecture, theming support, and best practices for creating cross-browser extensions.
6
-
7
- ## Quick Start
8
-
9
- ### For Consuming Projects (Extensions Built Using BXM)
10
- 1. Run `npx bxm setup` to initialize the project
11
- 2. Run `npm start` to start development
12
- 3. Load `packaged/raw/` directory in browser as unpacked extension
13
- 4. Edit files in `src/` - changes auto-reload via WebSocket
14
-
15
- ### For Framework Development (This Repository)
16
- 1. Run `npm start` to watch and compile framework changes
17
- 2. Test changes in a consuming project by linking: `npm link` (in BXM) then `npm link browser-extension-manager` (in consuming project)
18
- 3. Changes in `src/` compile to `dist/` automatically
19
-
20
- ## Architecture Overview
21
-
22
- ### Component-Based System
23
-
24
- Extensions are organized around **components**, each representing a distinct part:
25
-
26
- **Core Components:**
27
- - `background` - Service worker (background script)
28
- - `popup` - Browser action popup
29
- - `options` - Options/settings page
30
- - `sidepanel` - Chrome side panel
31
- - `content` - Content scripts injected into web pages
32
- - `pages` - Custom extension pages (e.g., dashboard, welcome)
33
- - `offscreen` - Persistent offscreen document (WebSocket, long-running tasks)
34
-
35
- **Each component has three parts:**
36
- 1. **View** - HTML in `src/views/[component]/index.html`
37
- 2. **Styles** - SCSS in `src/assets/css/components/[component]/index.scss`
38
- 3. **Script** - JS in `src/assets/js/components/[component]/index.js`
39
-
40
- **Compilation output:**
41
- - `dist/views/[component]/index.html`
42
- - `dist/assets/css/components/[component].bundle.css`
43
- - `dist/assets/js/components/[component].bundle.js`
44
-
45
- ### Two-Tier Architecture
46
-
47
- **Framework Layer** (`src/` in this repository):
48
- - Core framework code and components
49
- - Default templates and configurations
50
- - Build system and tooling
51
- - Published to npm as `browser-extension-manager`
52
-
53
- **Project Layer** (consuming extension projects):
54
- - User's extension-specific code
55
- - Overrides and customizations
56
- - Receives defaults from `src/defaults/` via the `defaults` gulp task
57
-
58
- ## Framework Structure (This Repository)
59
-
60
- ```
61
- browser-extension-manager/
62
- ├── src/ # Framework source code
63
- │ ├── assets/ # Framework assets
64
- │ │ ├── css/ # SCSS framework
65
- │ │ │ ├── browser-extension-manager.scss # Main entry point
66
- │ │ │ ├── core/ # Core styles (utilities, animations, initialize)
67
- │ │ │ ├── components/ # Component-specific styles (popup, options, content, pages)
68
- │ │ │ └── bundles/ # Custom bundle SCSS files
69
- │ │ ├── js/ # JavaScript framework
70
- │ │ │ └── main.js
71
- │ │ ├── themes/ # Theme system
72
- │ │ │ ├── _template/ # Template for creating new themes
73
- │ │ │ ├── bootstrap/ # Bootstrap theme (full Bootstrap 5 source)
74
- │ │ │ └── classy/ # Classy theme (Bootstrap + custom design system)
75
- │ │ └── vendor/ # Vendor assets
76
- │ ├── defaults/ # Default project structure (copied to consuming projects)
77
- │ │ ├── src/
78
- │ │ │ ├── assets/
79
- │ │ │ │ ├── css/
80
- │ │ │ │ │ ├── main.scss # Global styles entry point
81
- │ │ │ │ │ └── components/ # Component-specific overrides
82
- │ │ │ │ ├── js/
83
- │ │ │ │ │ └── components/ # Component JavaScript
84
- │ │ │ │ ├── images/
85
- │ │ │ │ └── vendor/
86
- │ │ │ ├── views/ # HTML views (templates)
87
- │ │ │ ├── manifest.json # Extension manifest (user-editable)
88
- │ │ │ └── _locales/ # Internationalization
89
- │ │ ├── hooks/ # Build hooks
90
- │ │ ├── config/ # Configuration files
91
- │ │ └── CLAUDE.md # Project documentation template
92
- │ ├── config/ # Framework configuration
93
- │ │ ├── manifest.json # Default manifest configuration
94
- │ │ └── page-template.html # HTML template for views
95
- │ ├── gulp/ # Build system
96
- │ │ ├── main.js # Gulp entry point
97
- │ │ ├── tasks/ # Gulp tasks
98
- │ │ │ ├── defaults.js # Copy default files to project
99
- │ │ │ ├── distribute.js # Distribute project files to dist/
100
- │ │ │ ├── sass.js # Compile SCSS
101
- │ │ │ ├── webpack.js # Bundle JavaScript
102
- │ │ │ ├── html.js # Process HTML views
103
- │ │ │ ├── icons.js # Generate icon sizes
104
- │ │ │ ├── package.js # Package extension for distribution
105
- │ │ │ ├── audit.js # Run audits
106
- │ │ │ └── serve.js # Development server
107
- │ │ └── plugins/ # Custom plugins
108
- │ │ └── webpack/
109
- │ │ └── strip-dev-blocks.js # Strip dev-only code
110
- │ ├── lib/ # Utility libraries
111
- │ │ ├── extension.js # Cross-browser extension API wrapper
112
- │ │ ├── logger.js # Logging utility
113
- │ │ └── logger-lite.js # Lightweight logger
114
- │ ├── commands/ # CLI commands
115
- │ │ ├── setup.js # Setup project
116
- │ │ ├── clean.js # Clean build artifacts
117
- │ │ └── version.js # Version management
118
- │ ├── build.js # Build manager class
119
- │ ├── background.js # Background script manager
120
- │ ├── popup.js # Popup manager
121
- │ ├── options.js # Options manager
122
- │ ├── sidepanel.js # Sidepanel manager
123
- │ ├── page.js # Page manager
124
- │ ├── content.js # Content script manager
125
- │ └── cli.js # CLI entry point
126
- ├── dist/ # Compiled framework (published to npm)
127
- ├── bin/ # CLI binaries
128
- │ └── browser-extension-manager
129
- ├── package.json
130
- └── CLAUDE.md # This file
131
- ```
132
-
133
- ## Consuming Project Structure
134
-
135
- When users create a project using BXM, they get this structure:
136
-
137
- ```
138
- my-extension/
139
- ├── src/
140
- │ ├── assets/
141
- │ │ ├── css/
142
- │ │ │ ├── main.scss # Global styles
143
- │ │ │ └── components/ # Component-specific styles
144
- │ │ ├── js/
145
- │ │ │ └── components/ # Component JavaScript
146
- │ │ ├── images/
147
- │ │ │ └── icon.png # Source icon (1024x1024)
148
- │ │ └── vendor/
149
- │ ├── views/ # HTML templates
150
- │ ├── _locales/ # i18n translations
151
- │ └── manifest.json # Extension manifest
152
- ├── config/
153
- │ └── config.json # BXM configuration
154
- ├── hooks/
155
- │ ├── build:pre.js # Pre-build hook
156
- │ └── build:post.js # Post-build hook
157
- ├── dist/ # Compiled files (gitignored)
158
- ├── packaged/ # Packaged extension (gitignored)
159
- │ ├── raw/ # Load this in browser
160
- │ └── extension.zip # Production build
161
- └── package.json
162
- ```
163
-
164
- ## Development Instructions
165
-
166
- ### Creating a New Component
167
-
168
- When adding a new component type to the framework:
169
-
170
- 1. **Create framework component styles:**
171
- ```
172
- src/assets/css/components/[component]/index.scss
173
- ```
174
-
175
- 2. **Create default template files:**
176
- ```
177
- src/defaults/src/assets/css/components/[component]/index.scss
178
- src/defaults/src/assets/js/components/[component]/index.js
179
- src/defaults/src/views/[component]/index.html
180
- ```
181
-
182
- 3. **Create manager class (if needed):**
183
- ```javascript
184
- // src/[component].js
185
- const Manager = require('./build.js');
186
-
187
- class ComponentManager extends Manager {
188
- constructor(options) {
189
- super(options);
190
- }
191
- }
192
-
193
- module.exports = ComponentManager;
194
- ```
195
-
196
- 4. **Export in package.json:**
197
- ```json
198
- {
199
- "exports": {
200
- "./component": "./dist/component.js"
201
- }
202
- }
203
- ```
204
-
205
- ### Modifying the Build System
206
-
207
- **Key gulp tasks:**
208
-
209
- - **defaults** ([gulp/tasks/defaults.js](src/gulp/tasks/defaults.js)) - Copies template files from `dist/defaults/` to consuming projects
210
- - **distribute** ([gulp/tasks/distribute.js](src/gulp/tasks/distribute.js)) - Copies project files to `dist/`
211
- - **sass** ([gulp/tasks/sass.js](src/gulp/tasks/sass.js)) - Compiles SCSS with sophisticated load path system
212
- - **webpack** ([gulp/tasks/webpack.js](src/gulp/tasks/webpack.js)) - Bundles JavaScript with Babel
213
- - **html** ([gulp/tasks/html.js](src/gulp/tasks/html.js)) - Processes HTML views into templates (see HTML Templating below)
214
- - **package** ([gulp/tasks/package.js](src/gulp/tasks/package.js)) - Creates packaged extension
215
-
216
- ### HTML Templating
217
-
218
- HTML views in `src/views/` are processed through a two-step templating system using `{{ }}` brackets.
219
-
220
- **Available variables:**
221
- - `{{ brand.name }}` - Brand name from config
222
- - `{{ brand.url }}` - Brand URL from config
223
- - `{{ page.name }}` - Component name (e.g., `popup`, `pages/index`)
224
- - `{{ page.path }}` - Full view path
225
- - `{{ page.title }}` - Page title (defaults to brand name)
226
- - `{{ theme.appearance }}` - Theme appearance (`dark` or `light`)
227
- - `{{ cacheBust }}` - Cache-busting timestamp
228
-
229
- **Example usage in views:**
230
- ```html
231
- <a href="{{ brand.url }}/pricing">Upgrade to Premium</a>
232
- <p>Welcome to {{ brand.name }}</p>
233
- ```
234
-
235
- **How it works:**
236
- 1. Your view file (`src/views/[component]/index.html`) is templated first
237
- 2. The result is injected into [page-template.html](src/config/page-template.html)
238
- 3. The outer template is processed with the same variables
239
-
240
- - **serve** ([gulp/tasks/serve.js](src/gulp/tasks/serve.js)) - WebSocket server for live reload
241
-
242
- ### Modifying Themes
243
-
244
- **Theme location:** [src/assets/themes/](src/assets/themes/)
245
-
246
- **Available themes:**
247
- - `bootstrap` - Pure Bootstrap 5.3+
248
- - `classy` - Bootstrap + custom design system
249
- - `_template` - Template for new themes
250
-
251
- **Theme structure:**
252
- ```
253
- src/assets/themes/[theme-id]/
254
- ├── _config.scss # Theme variables (with !default)
255
- ├── _theme.scss # Theme entry point
256
- ├── scss/ # Theme-specific SCSS
257
- └── js/ # Theme-specific JS
258
- ```
259
-
260
- **To create a new theme:**
261
- 1. Copy `_template/` to new directory
262
- 2. Customize `_config.scss` variables
263
- 3. Add theme-specific styles in `scss/`
264
- 4. Users activate via `config/config.json`
265
-
266
- ### Working with the Defaults System
267
-
268
- **Location:** [src/defaults/](src/defaults/)
269
-
270
- **How it works:**
271
- 1. Files in `src/defaults/` are the starter template
272
- 2. During build, they're copied to `dist/defaults/`
273
- 3. When users run `npx bxm setup`, files copy from `dist/defaults/` to their project
274
- 4. File behavior controlled by `FILE_MAP` in [gulp/tasks/defaults.js](src/gulp/tasks/defaults.js)
275
-
276
- **File map rules:**
277
- ```javascript
278
- const FILE_MAP = {
279
- 'src/**/*': { overwrite: false }, // Never overwrite user code
280
- 'hooks/**/*': { overwrite: false }, // Never overwrite hooks
281
- '.nvmrc': { template: { node: '22' } }, // Template with data
282
- // ...
283
- };
284
- ```
285
-
286
- **Rule types:**
287
- - `overwrite: false` - Never replace if exists
288
- - `overwrite: true` - Always update
289
- - `skip: function` - Dynamic skip logic
290
- - `template: data` - Run templating
291
- - `name: function` - Rename file
292
-
293
- ### CSS Architecture
294
-
295
- **Main entry:** [src/assets/css/browser-extension-manager.scss](src/assets/css/browser-extension-manager.scss)
296
-
297
- **Core modules:**
298
- - [core/_initialize.scss](src/assets/css/core/_initialize.scss) - Base resets
299
- - [core/_utilities.scss](src/assets/css/core/_utilities.scss) - Utility classes
300
- - [core/_animations.scss](src/assets/css/core/_animations.scss) - Animations
301
-
302
- **Component system:**
303
- Each component can have framework defaults in `src/assets/css/components/[name]/index.scss`
304
-
305
- **Load path resolution:**
306
- 1. Framework CSS (`node_modules/browser-extension-manager/dist/assets/css`)
307
- 2. Active theme (`node_modules/browser-extension-manager/dist/assets/themes/[theme-id]`)
308
- 3. Project dist (`dist/assets/css`)
309
- 4. node_modules
310
-
311
- This enables:
312
- ```scss
313
- @use 'browser-extension-manager' as * with ($primary: #5B47FB);
314
- @use 'theme' as *; // Resolves to active theme
315
- @use 'components/popup' as *; // Import default component styles
316
- ```
317
-
318
- ### JavaScript Architecture
319
-
320
- **Manager classes:** [src/background.js](src/background.js), [src/popup.js](src/popup.js), [src/options.js](src/options.js), [src/sidepanel.js](src/sidepanel.js), [src/page.js](src/page.js), [src/content.js](src/content.js)
321
-
322
- **Extension API wrapper:** [src/lib/extension.js](src/lib/extension.js)
323
-
324
- A universal/agnostic API wrapper that enables cross-browser extension development. Write your extension once and it works on Chrome, Firefox, Edge, and other browsers.
325
-
326
- **How it works:**
327
- - Detects and normalizes APIs from `chrome.*`, `browser.*`, and `window.*` namespaces
328
- - Automatically selects the correct API based on what's available in the current browser
329
- - Exports a singleton with unified access to all extension APIs
330
-
331
- **Supported APIs:**
332
- `action`, `alarms`, `bookmarks`, `browsingData`, `browserAction`, `certificateProvider`, `commands`, `contentSettings`, `contextMenus`, `cookies`, `debugger`, `declarativeContent`, `declarativeNetRequest`, `devtools`, `dns`, `documentScan`, `downloads`, `enterprise`, `events`, `extension`, `extensionTypes`, `fileBrowserHandler`, `fileSystemProvider`, `fontSettings`, `gcm`, `history`, `i18n`, `identity`, `idle`, `input`, `instanceID`, `management`, `notifications`, `offscreen`, `omnibox`, `pageAction`, `permissions`, `platformKeys`, `power`, `printerProvider`, `privacy`, `proxy`, `runtime`, `scripting`, `search`, `sessions`, `sidePanel`, `storage`, `tabGroups`, `tabs`, `topSites`, `tts`, `ttsEngine`, `userScripts`, `vpnProvider`, `wallpaper`, `webNavigation`, `webRequest`, `windows`
333
-
334
- **Usage:**
335
- ```javascript
336
- // Exposed via manager - no separate import needed
337
- const Manager = new (require('browser-extension-manager/popup'));
338
-
339
- Manager.initialize().then(() => {
340
- const { extension } = Manager;
341
-
342
- // Works on Chrome, Firefox, Edge, etc.
343
- extension.tabs.query({ active: true }, (tabs) => { ... });
344
- extension.storage.get('key', (result) => { ... });
345
- extension.runtime.sendMessage({ type: 'hello' });
346
- });
347
- ```
348
-
349
- **Storage normalization:**
350
- The wrapper automatically resolves `storage` to `storage.sync` if available, falling back to `storage.local`.
351
-
352
- **Auth Helpers:** [src/lib/auth-helpers.js](src/lib/auth-helpers.js)
353
-
354
- Provides cross-context auth synchronization and reusable auth UI event handlers.
355
-
356
- ### Cross-Context Auth Architecture
357
-
358
- **Background.js is the source of truth** for authentication. Browser extensions have multiple isolated JavaScript contexts (background, popup, options, pages, sidepanel) - each runs its own Firebase instance. BXM syncs them via messaging (no storage).
359
-
360
- **Sign-in Flow:**
361
- ```
362
- User clicks .auth-signin-btn
363
- → openAuthPage() opens https://{authDomain}/token?authSourceTabId=123
364
- → Website authenticates, redirects to /token?authToken=xxx
365
- → background.js tabs.onUpdated detects authDomain URL with authToken param
366
- → background.js signs in with signInWithCustomToken()
367
- → background.js broadcasts token to all open contexts via postMessage()
368
- → Closes the /token tab, reactivates original tab
369
- → Open contexts receive broadcast and sign in with the token
370
- ```
371
-
372
- **Context Load Flow:**
373
- ```
374
- Context loads (popup, page, options, sidepanel)
375
- → Web Manager initializes, waits for auth to settle via auth.listen({once: true})
376
- → Sends bxm:syncAuth message to background with local UID
377
- → Background compares UIDs:
378
- → Same UID (including both null) → already in sync, no action
379
- → Different UID → background fetches fresh custom token from server, sends to context
380
- → Background signed out, context signed in → tells context to sign out
381
- ```
382
-
383
- **Sign-out Flow:**
384
- ```
385
- User clicks .auth-signout-btn
386
- → Web Manager signs out that context's Firebase
387
- → setupSignOutListener() detects sign-out, sends bxm:signOut to background
388
- → background.js signs out its Firebase
389
- → background.js broadcasts bxm:signOut to all other contexts
390
- → All contexts sign out
391
- ```
392
-
393
- **Key Implementation Details:**
394
-
395
- 1. **No storage**: Auth state is NOT stored in `chrome.storage`. Firebase persists sessions in IndexedDB per context. Web Manager handles UI bindings.
396
-
397
- 2. **Firebase in service workers**: Static ES6 imports are required. Dynamic `import()` fails with webpack chunking in service workers.
398
-
399
- 3. **Config path**: `authDomain` is at `config.firebase.app.config.authDomain` (loaded via BXM_BUILD_JSON).
400
-
401
- 4. **Required permission**: `tabs` permission needed for `tabs.onUpdated` listener.
402
-
403
- **Functions:**
404
- - `syncWithBackground(context)` - Compares context's UID with background's UID on load, syncs if different
405
- - `setupAuthBroadcastListener(context)` - Listens for sign-in/sign-out broadcasts from background
406
- - `setupSignOutListener(context)` - Notifies background when context signs out
407
- - `setupAuthEventListeners(context)` - Sets up delegated click handlers for auth buttons
408
- - `openAuthPage(context, options)` - Opens auth page on the website with authSourceTabId for tab restoration
409
-
410
- **Auth Button CSS Classes:**
411
-
412
- Add these classes to your HTML elements to enable automatic auth handling:
413
-
414
- | Class | Description | Action |
415
- |-------|-------------|--------|
416
- | `.auth-signin-btn` | Sign in button | Opens `/token` page on website (authDomain) |
417
- | `.auth-signout-btn` | Sign out button | Handled by Web Manager (triggers storage sync via auth listener) |
418
- | `.auth-account-btn` | Account button | Opens `/account` page on website |
419
-
420
- **Example usage:**
421
- ```html
422
- <!-- Sign In Button (shown when logged out) -->
423
- <button class="btn auth-signin-btn" data-wm-bind="@show !auth.user">
424
- Sign In
425
- </button>
426
-
427
- <!-- Account Dropdown (shown when logged in) -->
428
- <div data-wm-bind="@show auth.user" hidden>
429
- <a class="auth-account-btn" href="#">Account</a>
430
- <button class="auth-signout-btn">Sign Out</button>
431
- </div>
432
- ```
433
-
434
- **Reactive bindings:**
435
- - `data-wm-bind="@show auth.user"` - Show when logged in
436
- - `data-wm-bind="@show !auth.user"` - Show when logged out
437
- - `data-wm-bind="@text auth.user.displayName"` - Display user's name
438
- - `data-wm-bind="@text auth.user.email"` - Display user's email
439
- - `data-wm-bind="@attr src auth.user.photoURL"` - Set avatar image src
440
-
441
- **Logger:** [src/lib/logger.js](src/lib/logger.js)
442
- - Full logging utility
443
- - [src/lib/logger-lite.js](src/lib/logger-lite.js) for lightweight contexts
444
-
445
- **Template replacement:**
446
- Webpack plugin replaces markers during build:
447
- - `%%% version %%%` → package version
448
- - `%%% brand.name %%%` → brand name
449
- - `%%% environment %%%` → 'production' or 'development'
450
- - `%%% liveReloadPort %%%` → WebSocket port
451
- - `%%% webManagerConfiguration %%%` → JSON config
452
-
453
- ### Build Hooks System
454
-
455
- **Hook locations:**
456
- - `hooks/build:pre.js` - Before packaging
457
- - `hooks/build:post.js` - After packaging
458
-
459
- **Hook structure:**
460
- ```javascript
461
- module.exports = async function (index) {
462
- // index contains build information
463
- console.log('Hook running...');
464
- };
465
- ```
466
-
467
- **Implementation:** [src/gulp/tasks/package.js](src/gulp/tasks/package.js) loads and executes hooks
468
-
469
- ### CLI System
470
-
471
- **Entry point:** [bin/browser-extension-manager](bin/browser-extension-manager)
472
-
473
- **CLI implementation:** [src/cli.js](src/cli.js)
474
-
475
- **Commands:** [src/commands/](src/commands/)
476
- - [setup.js](src/commands/setup.js) - Initialize project
477
- - [clean.js](src/commands/clean.js) - Clean build artifacts
478
- - [version.js](src/commands/version.js) - Show version
479
-
480
- **Aliases in package.json:**
481
- ```json
482
- {
483
- "bin": {
484
- "ext": "bin/browser-extension-manager",
485
- "xm": "bin/browser-extension-manager",
486
- "bxm": "bin/browser-extension-manager",
487
- "browser-extension-manager": "bin/browser-extension-manager"
488
- }
489
- }
490
- ```
491
-
492
- ## Best Practices for Framework Development
493
-
494
- ### File Organization
495
-
496
- 1. **Keep framework code in src/** - Never edit `dist/` directly
497
- 2. **Use modular design** - Per Ian's standards, build modular code, not one giant file
498
- 3. **Maintain defaults/** - Keep template files up-to-date
499
- 4. **Document changes** - Update CLAUDE.md
500
-
501
- ### Coding Standards (Per Ian's Preferences)
502
-
503
- **Short-circuit pattern:**
504
- ```javascript
505
- // Good
506
- const $el = document.querySelector('...');
507
- if (!$el) {
508
- return;
509
- }
510
- // Long code block
511
-
512
- // Bad
513
- if ($el) {
514
- // Long code block
515
- }
516
- ```
517
-
518
- **Logical operators:**
519
- ```javascript
520
- // Good
521
- const a = b
522
- || c
523
- || d;
524
-
525
- // Bad
526
- const a = b ||
527
- c ||
528
- d;
529
- ```
530
-
531
- **DOM element naming:**
532
- ```javascript
533
- const $submitBtn = document.querySelector('#submit');
534
- const $emailInput = document.querySelector('#email');
535
- ```
536
-
537
- **File operations:**
538
- ```javascript
539
- // Prefer fs-jetpack
540
- const jetpack = require('fs-jetpack');
541
- jetpack.write('file.txt', 'content');
542
- ```
543
-
544
- ### Backwards Compatibility
545
-
546
- **Per Ian's instructions:**
547
- - **DO NOT** make changes backwards compatible unless explicitly requested
548
- - Most changes are for unreleased code or local development
549
- - If we develop something and change it later, just change it - don't maintain old way
550
- - Only add backwards compatibility when specifically asked
551
-
552
- ### Version Control
553
-
554
- **Commit:**
555
- - `src/` - All framework source code
556
- - `package.json` - Package configuration
557
- - Documentation (CLAUDE.md)
558
-
559
- **Ignore:**
560
- - `dist/` - Compiled framework (generated by prepare-package)
561
- - `node_modules/`
562
-
563
- ## Testing Changes
564
-
565
- ### Local Testing
566
-
567
- 1. **Make changes in src/**
568
- 2. **Compile:** `npm start` (watches and compiles to dist/)
569
- 3. **Link locally:**
570
- ```bash
571
- npm link
572
- ```
573
- 4. **In consuming project:**
574
- ```bash
575
- npm link browser-extension-manager
576
- npm start
577
- ```
578
- 5. **Test in browser:**
579
- Load `packaged/raw/` directory
580
-
581
- ### Testing Build System
582
-
583
- **Test individual gulp tasks:**
584
- ```bash
585
- cd consuming-project/
586
- npm run gulp -- [task-name]
587
- ```
588
-
589
- **Available tasks:**
590
- - `defaults` - Test template copying
591
- - `sass` - Test SCSS compilation
592
- - `webpack` - Test JS bundling
593
- - `html` - Test HTML processing
594
- - `package` - Test extension packaging
595
-
596
- ### Testing CLI
597
-
598
- **In this repository:**
599
- ```bash
600
- ./bin/browser-extension-manager setup
601
- ./bin/browser-extension-manager clean
602
- ./bin/browser-extension-manager version
603
- ```
604
-
605
- **Or via npm:**
606
- ```bash
607
- npx bxm setup
608
- npx bxm clean
609
- npx bxm version
610
- ```
611
-
612
- ## Publishing Updates
613
-
614
- ### Preparation
615
-
616
- 1. **Update version** in [package.json](package.json)
617
- 2. **Compile framework:**
618
- ```bash
619
- npm run prepare
620
- ```
621
- 3. **Test in consuming project**
622
- 4. **Update documentation** if needed
623
-
624
- ### Publishing to npm
625
-
626
- ```bash
627
- npm publish
628
- ```
629
-
630
- **Published package includes:**
631
- - `dist/` - Compiled framework
632
- - `bin/` - CLI binaries
633
- - `package.json`
634
- - `README.md`
635
-
636
- **Excluded via .npmignore:**
637
- - `src/` - Source code (users don't need this)
638
- - Development files
639
-
640
- ## Common Development Tasks
641
-
642
- ### Adding a Utility Class
643
-
644
- **Location:** [src/assets/css/core/_utilities.scss](src/assets/css/core/_utilities.scss)
645
-
646
- ```scss
647
- // Add new utility
648
- .shadow-lg {
649
- box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
650
- }
651
- ```
652
-
653
- ### Adding a Theme Variable
654
-
655
- **Location:** [src/assets/themes/classy/_config.scss](src/assets/themes/classy/_config.scss) (or relevant theme)
656
-
657
- ```scss
658
- $new-color: #FF6B6B !default;
659
-
660
- // Make available to consumers
661
- @forward '../bootstrap/scss/bootstrap.scss' with (
662
- $new-color: $new-color
663
- );
664
- ```
665
-
666
- ### Adding a Webpack Alias
667
-
668
- **Location:** [src/gulp/tasks/webpack.js](src/gulp/tasks/webpack.js)
669
-
670
- ```javascript
671
- resolve: {
672
- alias: {
673
- '__new_alias__': path.resolve(paths.root, 'path/to/directory'),
674
- }
675
- }
676
- ```
677
-
678
- ### Adding a Template Replacement
679
-
680
- **Location:** [src/gulp/tasks/webpack.js](src/gulp/tasks/webpack.js)
681
-
682
- ```javascript
683
- new ReplacePlugin({
684
- patterns: [
685
- {
686
- find: /%%% newVariable %%%/g,
687
- replacement: 'value'
688
- }
689
- ]
690
- })
691
- ```
692
-
693
- ### Modifying Default Manifest
694
-
695
- **Location:** [src/config/manifest.json](src/config/manifest.json)
696
-
697
- ```json5
698
- {
699
- // Add new default permission
700
- permissions: [
701
- 'storage',
702
- 'newPermission'
703
- ]
704
- }
705
- ```
706
-
707
- **Compilation:** [src/gulp/tasks/package.js](src/gulp/tasks/package.js) merges user manifest with defaults
708
-
709
- ## Troubleshooting Framework Development
710
-
711
- ### Changes not appearing in consuming project
712
-
713
- 1. **Rebuild framework:** `npm run prepare`
714
- 2. **Reinstall in consuming project:** `npm install browser-extension-manager@latest`
715
- 3. **Or use local link:** `npm link` (in BXM) then `npm link browser-extension-manager` (in project)
716
-
717
- ### Gulp task errors
718
-
719
- 1. **Check task file:** [src/gulp/tasks/](src/gulp/tasks/)
720
- 2. **Verify paths** are correct
721
- 3. **Check for syntax errors**
722
- 4. **Test task individually:** `npm run gulp -- task-name`
723
-
724
- ### SCSS compilation errors
725
-
726
- 1. **Check load paths** in [src/gulp/tasks/sass.js](src/gulp/tasks/sass.js)
727
- 2. **Verify theme structure**
728
- 3. **Check for circular imports**
729
- 4. **Test with minimal SCSS** to isolate issue
730
-
731
- ### Template replacement not working
732
-
733
- 1. **Check pattern** in [src/gulp/tasks/webpack.js](src/gulp/tasks/webpack.js)
734
- 2. **Verify replacement value** is correct
735
- 3. **Check if file is processed** by webpack
736
-
737
- ## Notable Dependencies
738
-
739
- ### Web Manager
740
- BXM integrates **Web Manager** for Firebase, analytics, and web services functionality. Each component manager initializes Web Manager automatically with configuration from `config/config.json`.
741
-
742
- **Web Manager API:**
743
- - Study the Web Manager API and documentation in the sibling repository
744
- - Location: `../web-manager/` (relative to this project)
745
- - GitHub: https://github.com/itw-creative-works/web-manager
746
- - npm: https://www.npmjs.com/package/web-manager
747
-
748
- **Usage in BXM:**
749
- ```javascript
750
- const Manager = new (require('browser-extension-manager/popup'));
751
-
752
- Manager.initialize().then(() => {
753
- const { webManager } = Manager;
754
-
755
- // Web Manager provides:
756
- // - Firebase (Firestore, Auth, Storage, etc.)
757
- // - Analytics
758
- // - User management
759
- // - Utilities
760
- const db = webManager.libraries.firebase.firestore();
761
- });
762
- ```
763
-
764
- ### Other Key Dependencies
765
- - **Gulp** - Build system and task automation
766
- - **Webpack** - JavaScript bundling with Babel transpilation
767
- - **Sass** - CSS preprocessing with advanced features
768
- - **fs-jetpack** - File operations (per Ian's preference)
769
- - **wonderful-fetch** - HTTP requests
770
- - **wonderful-version** - Version management
771
- - **ws** - WebSocket server for live reload
772
-
773
- ## Resources
774
-
775
- - **GitHub**: https://github.com/itw-creative-works/browser-extension-manager
776
- - **npm**: https://www.npmjs.com/package/browser-extension-manager
777
- - **Chrome Extensions**: https://developer.chrome.com/docs/extensions/
778
- - **Firefox Add-ons**: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions
779
-
780
- ## Key Files Reference
781
-
782
- **Build System:**
783
- - [src/gulp/main.js](src/gulp/main.js) - Gulp entry point
784
- - [src/gulp/tasks/](src/gulp/tasks/) - All build tasks
785
- - [src/build.js](src/build.js) - Build manager base class
786
-
787
- **Manager Classes:**
788
- - [src/background.js](src/background.js) - Background script manager
789
- - [src/popup.js](src/popup.js) - Popup manager
790
- - [src/options.js](src/options.js) - Options manager
791
- - [src/sidepanel.js](src/sidepanel.js) - Sidepanel manager
792
- - [src/page.js](src/page.js) - Custom page manager
793
- - [src/content.js](src/content.js) - Content script manager
794
-
795
- **Utilities:**
796
- - [src/lib/extension.js](src/lib/extension.js) - Cross-browser API wrapper
797
- - [src/lib/auth-helpers.js](src/lib/auth-helpers.js) - Cross-context auth sync (see Auth Architecture section above)
798
- - [src/lib/logger.js](src/lib/logger.js) - Logging utility
799
- - [src/cli.js](src/cli.js) - CLI implementation
800
-
801
- **Auth System (Cross-Context):**
802
- - [src/background.js](src/background.js) - Source of truth; `handleSyncAuth()`, `handleSignOut()`, `broadcastAuthToken()`
803
- - [src/lib/auth-helpers.js](src/lib/auth-helpers.js) - `syncWithBackground()`, `setupAuthBroadcastListener()`, `setupSignOutListener()`
804
-
805
- **CSS Framework:**
806
- - [src/assets/css/browser-extension-manager.scss](src/assets/css/browser-extension-manager.scss) - Main entry
807
- - [src/assets/css/core/](src/assets/css/core/) - Core styles
808
- - [src/assets/css/components/](src/assets/css/components/) - Component styles
809
- - [src/assets/themes/](src/assets/themes/) - Theme system
810
-
811
- **Templates:**
812
- - [src/defaults/](src/defaults/) - Project starter template
813
- - [src/config/manifest.json](src/config/manifest.json) - Default manifest
814
- - [src/config/page-template.html](src/config/page-template.html) - HTML template
815
-
816
- **CLI:**
817
- - [bin/browser-extension-manager](bin/browser-extension-manager) - CLI entry
818
- - [src/commands/](src/commands/) - CLI commands
package/TODO.md DELETED
@@ -1,14 +0,0 @@
1
- TODO
2
- - make a special part of WM that has default and custom classes to pass into that replace in the html, it should do txt and inputs
3
-
4
- WM
5
- - year (currently wm-year, but change it)
6
-
7
- BXM
8
- - extension version (currently bxm-version, but change it)
9
- - BINDINGS
10
-
11
- TODO
12
- handle auth by redirecting to the config website url
13
-
14
-