@posthog/browser-common 0.2.0 → 0.2.1

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/README.md CHANGED
@@ -96,10 +96,12 @@ if (flags && (await flags.getFeatureFlag('beta-ui'))) {
96
96
  }
97
97
  ```
98
98
 
99
- A token is implementation-free, so importing it never pulls the provider's code
100
- into your bundle — each extension stays independently tree-shakable and lazily
101
- loadable. An extension that provides a capability declares its token(s) in
102
- `provides`.
99
+ A token is an implementation-free branded string, so importing it never pulls
100
+ the provider's code into your bundle — each extension stays independently
101
+ tree-shakable and lazily loadable. Use a package-qualified runtime string, such
102
+ as `posthog.featureFlags`, that is globally unique and stable so separately
103
+ compiled scripts resolve the same capability. An extension that provides a
104
+ capability declares its token(s) in `provides`.
103
105
 
104
106
  ## Utilities
105
107
 
package/dist/config.js CHANGED
@@ -26,7 +26,7 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  default: ()=>__WEBPACK_DEFAULT_EXPORT__
28
28
  });
29
- const packageVersion = "0.2.0";
29
+ const packageVersion = "0.2.1";
30
30
  const Config = {
31
31
  DEBUG: false,
32
32
  LIB_VERSION: packageVersion,
package/dist/config.mjs CHANGED
@@ -1,4 +1,4 @@
1
- const packageVersion = "0.2.0";
1
+ const packageVersion = "0.2.1";
2
2
  const Config = {
3
3
  DEBUG: false,
4
4
  LIB_VERSION: packageVersion,
package/dist/token.d.ts CHANGED
@@ -1,21 +1,22 @@
1
+ /** Phantom brand carrying the capability type without emitting runtime code. */
2
+ declare const extensionTokenType: unique symbol;
1
3
  /**
2
- * A typed, implementation-free key for resolving an extension that provides a
3
- * capability. Declared as a shared `const` next to the providing extension's
4
+ * A typed, implementation-free string for resolving an extension that provides
5
+ * a capability. Declared as a shared `const` next to the providing extension's
4
6
  * interface:
5
7
  *
6
8
  * ```ts
7
9
  * export interface FeatureFlagsExtension extends Extension { … }
8
- * export const FeatureFlags: ExtensionToken<FeatureFlagsExtension> = { name: 'featureFlags' }
10
+ * export const FeatureFlags = 'posthog.featureFlags' as ExtensionToken<FeatureFlagsExtension>
9
11
  * ```
10
12
  *
11
13
  * A token holds no implementation, so importing one never pulls the provider's
12
- * code into the consumer's bundle. The registry is keyed by token identity
13
- * (the shared object reference), so provider and consumer must import the same
14
- * exported token; `name` is for diagnostics only.
14
+ * code into the consumer's bundle. Its generic brand lets `getExtension` infer
15
+ * the provided type, while its runtime string value remains stable across
16
+ * independently compiled scripts. Token strings must be globally unique and
17
+ * stable for the lifetime of the capability contract.
15
18
  */
16
- export interface ExtensionToken<T> {
17
- /** Human-readable capability name used only for diagnostics. */
18
- readonly name: string;
19
- /** Phantom: carries the provided type for inference; never present at runtime. */
20
- readonly __provides?: T;
21
- }
19
+ export type ExtensionToken<T> = string & {
20
+ readonly [extensionTokenType]: T;
21
+ };
22
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/browser-common",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Internal shared browser utilities and extension primitives for PostHog Browser SDKs",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -57,8 +57,8 @@
57
57
  }
58
58
  },
59
59
  "dependencies": {
60
- "@posthog/core": "^1.44.0",
61
- "@posthog/types": "^1.397.1"
60
+ "@posthog/types": "^1.398.0",
61
+ "@posthog/core": "^1.45.1"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@rslib/core": "0.10.6",