@beworke/pixel-bemony-react 0.1.0-rc.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/CHANGELOG.md +17 -0
- package/README.md +140 -0
- package/RELEASE_CANDIDATE.md +32 -0
- package/dist/index.cjs.js +150 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.mts +37 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.esm.js +128 -0
- package/dist/index.esm.js.map +1 -0
- package/package.json +59 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog — `@beworke/pixel-bemony-react`
|
|
2
|
+
|
|
3
|
+
## 0.1.0-rc.1 — First public RC
|
|
4
|
+
|
|
5
|
+
Primeira publicação npm para validação em apps React/Next.js.
|
|
6
|
+
|
|
7
|
+
### Highlights
|
|
8
|
+
|
|
9
|
+
- `PixelProvider` + `usePixel` sobre `bootstrapBemonyPixel`
|
|
10
|
+
- Peers: `react` / `react-dom` (>=18) e `@beworke/pixel-bemony` (>=0.1.0-rc.1)
|
|
11
|
+
- Tags npm: `rc` + `latest`
|
|
12
|
+
|
|
13
|
+
## 0.0.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- MVP: `PixelProvider` + `usePixel` sobre `bootstrapBemonyPixel`
|
package/README.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# @beworke/pixel-bemony-react
|
|
2
|
+
|
|
3
|
+
Camada React mínima sobre [`@beworke/pixel-bemony`](../pixel-bemony) — Provider + hook, sem instanciar o Core (`@beworke/pixel`).
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
App React/Next.js
|
|
7
|
+
↓
|
|
8
|
+
@beworke/pixel-bemony-react
|
|
9
|
+
↓
|
|
10
|
+
@beworke/pixel-bemony
|
|
11
|
+
↓
|
|
12
|
+
@beworke/pixel
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Instalação
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @beworke/pixel-bemony-react@rc
|
|
19
|
+
# ou versão fixa:
|
|
20
|
+
pnpm add @beworke/pixel-bemony-react@0.1.0-rc.1
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Peers: `react` / `react-dom` (>=18) e `@beworke/pixel-bemony` (>=0.1.0-rc.1).
|
|
24
|
+
|
|
25
|
+
## Provider
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
'use client';
|
|
29
|
+
|
|
30
|
+
import { PixelProvider } from '@beworke/pixel-bemony-react';
|
|
31
|
+
import type { BootstrapBemonyPixelOptions } from '@beworke/pixel-bemony-react';
|
|
32
|
+
|
|
33
|
+
const options: BootstrapBemonyPixelOptions = {
|
|
34
|
+
environment: 'production',
|
|
35
|
+
scenario: 'checkout',
|
|
36
|
+
platform: {
|
|
37
|
+
pixelId: 'pix_123',
|
|
38
|
+
allowedDomains: ['checkout.example.com'],
|
|
39
|
+
},
|
|
40
|
+
page: {
|
|
41
|
+
funnelId: 'fun_123',
|
|
42
|
+
funnelStepId: 'step_123',
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export function Providers({ children }: React.PropsWithChildren) {
|
|
47
|
+
return <PixelProvider options={options}>{children}</PixelProvider>;
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Consumo
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
'use client';
|
|
55
|
+
|
|
56
|
+
import { usePixel } from '@beworke/pixel-bemony-react';
|
|
57
|
+
|
|
58
|
+
export function Checkout() {
|
|
59
|
+
const { pixel, ready, status, error } = usePixel();
|
|
60
|
+
|
|
61
|
+
if (status === 'initializing') {
|
|
62
|
+
return <p>Initializing Pixel...</p>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (error) {
|
|
66
|
+
return <p>Pixel initialization failed.</p>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<button
|
|
71
|
+
disabled={!ready}
|
|
72
|
+
onClick={() => {
|
|
73
|
+
pixel?.trackPaymentMethod({ paymentMethod: 'CREDIT_CARD' });
|
|
74
|
+
}}
|
|
75
|
+
>
|
|
76
|
+
Continue
|
|
77
|
+
</button>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`usePixel` fora do `PixelProvider` lança:
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
usePixel must be used within a PixelProvider.
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Next.js App Router
|
|
89
|
+
|
|
90
|
+
- `PixelProvider` é um Client Component (`'use client'`).
|
|
91
|
+
- O `layout.tsx` pode permanecer Server Component.
|
|
92
|
+
- Envolva `children` com um componente intermediário `Providers`.
|
|
93
|
+
- `usePixel` só em Client Components.
|
|
94
|
+
|
|
95
|
+
## Lifecycle
|
|
96
|
+
|
|
97
|
+
1. Estado inicial: `idle` → no efeito do cliente: `initializing`.
|
|
98
|
+
2. Bootstrap via `bootstrapBemonyPixel` (singleton por `window` no `pixel-bemony`).
|
|
99
|
+
3. Sucesso → `ready` + instância; falha → `error` + `Error` normalizado.
|
|
100
|
+
4. Options são capturadas na montagem (`useRef`). Objetos inline a cada render **não** reinicializam.
|
|
101
|
+
5. Mudança semântica das options após o mount: aviso em development; reinit dinâmico fora do MVP.
|
|
102
|
+
|
|
103
|
+
### Strict Mode
|
|
104
|
+
|
|
105
|
+
React 18+ Strict Mode (dev) faz mount → cleanup → mount. Estratégia:
|
|
106
|
+
|
|
107
|
+
- **Ref-count** de ownership no módulo.
|
|
108
|
+
- **Destroy adiado** (`setTimeout(0)`): o cleanup da primeira montagem agenda destroy; o remount imediato cancela o timer e reutiliza pending/instância do store do browser.
|
|
109
|
+
- Não destruir no cleanup de forma síncrona (evita matar a segunda montagem).
|
|
110
|
+
|
|
111
|
+
### Múltiplos Providers
|
|
112
|
+
|
|
113
|
+
Na mesma `window`, vários `PixelProvider` **compartilham** a mesma instância bootstrapada (política alinhada ao singleton do `pixel-bemony`). Destroy global só quando o ref-count volta a 0.
|
|
114
|
+
|
|
115
|
+
## SSR
|
|
116
|
+
|
|
117
|
+
- Importar o pacote não acessa `window`/`document`.
|
|
118
|
+
- Bootstrap só dentro de `useEffect` (cliente).
|
|
119
|
+
- Render no servidor deixa status `idle` / `ready: false`.
|
|
120
|
+
|
|
121
|
+
## Limitações do MVP
|
|
122
|
+
|
|
123
|
+
Ainda **não** existem:
|
|
124
|
+
|
|
125
|
+
- `useCustomer`, `useCheckout`, `useCatalog`, `useJourney`, `usePageContext`, `useTrack`
|
|
126
|
+
- componentes declarativos de tracking / `PixelScript`
|
|
127
|
+
- integração específica com Server Components / Suspense
|
|
128
|
+
- reinit dinâmico por mudança de options
|
|
129
|
+
- catálogo remoto / seleção automática de price
|
|
130
|
+
- estado comercial duplicado no React
|
|
131
|
+
|
|
132
|
+
Tipos avançados: importe de `@beworke/pixel-bemony` ou `@beworke/pixel-bemony/browser`.
|
|
133
|
+
|
|
134
|
+
## Status UI
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
type PixelProviderStatus = 'idle' | 'initializing' | 'ready' | 'error';
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`error` no Context é o status de falha do Provider (não confundir com `BemonyPixel.getState() === 'failed'`).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Release Candidate — `@beworke/pixel-bemony-react`
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
| Item | Decisão |
|
|
6
|
+
|---|---|
|
|
7
|
+
| Publish npm | **Sim** — RC pública para validação |
|
|
8
|
+
| Versão | `0.1.0-rc.1` |
|
|
9
|
+
| Naming | `@beworke/pixel-bemony-react` |
|
|
10
|
+
| Tags npm | `rc` + `latest` |
|
|
11
|
+
|
|
12
|
+
## Compatibilidade
|
|
13
|
+
|
|
14
|
+
| Pacote | Intervalo |
|
|
15
|
+
|---|---|
|
|
16
|
+
| `@beworke/pixel-bemony` (peer) | `>=0.1.0-rc.1` |
|
|
17
|
+
| `react` / `react-dom` | `>=18` |
|
|
18
|
+
| Dependência no workspace | `workspace:*` (pnpm publish reescreve) |
|
|
19
|
+
|
|
20
|
+
## Checklist
|
|
21
|
+
|
|
22
|
+
1. `pnpm --filter @beworke/pixel-bemony-react lint`
|
|
23
|
+
2. `pnpm --filter @beworke/pixel-bemony-react type-check`
|
|
24
|
+
3. `pnpm --filter @beworke/pixel-bemony-react test`
|
|
25
|
+
4. `pnpm --filter @beworke/pixel-bemony-react build`
|
|
26
|
+
5. `pnpm --filter @beworke/pixel-bemony-react publish:rc`
|
|
27
|
+
6. `npm view @beworke/pixel-bemony-react dist-tags` → `rc` e `latest` = `0.1.0-rc.1`
|
|
28
|
+
|
|
29
|
+
## Fora desta RC
|
|
30
|
+
|
|
31
|
+
- Versão estável `0.1.0` (sem sufixo)
|
|
32
|
+
- Hooks avançados / SSR helpers extras
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
PixelProvider: () => PixelProvider,
|
|
24
|
+
usePixel: () => usePixel
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(src_exports);
|
|
27
|
+
|
|
28
|
+
// src/provider/PixelProvider.tsx
|
|
29
|
+
var import_browser2 = require("@beworke/pixel-bemony/browser");
|
|
30
|
+
var import_react2 = require("react");
|
|
31
|
+
|
|
32
|
+
// src/provider/bootstrapOwnership.ts
|
|
33
|
+
var import_browser = require("@beworke/pixel-bemony/browser");
|
|
34
|
+
var ownerCount = 0;
|
|
35
|
+
var destroyTimer = null;
|
|
36
|
+
function acquireBootstrapOwnership() {
|
|
37
|
+
if (destroyTimer !== null) {
|
|
38
|
+
clearTimeout(destroyTimer);
|
|
39
|
+
destroyTimer = null;
|
|
40
|
+
}
|
|
41
|
+
ownerCount += 1;
|
|
42
|
+
}
|
|
43
|
+
function releaseBootstrapOwnership() {
|
|
44
|
+
ownerCount = Math.max(0, ownerCount - 1);
|
|
45
|
+
if (ownerCount > 0) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (destroyTimer !== null) {
|
|
49
|
+
clearTimeout(destroyTimer);
|
|
50
|
+
}
|
|
51
|
+
destroyTimer = setTimeout(() => {
|
|
52
|
+
destroyTimer = null;
|
|
53
|
+
if (ownerCount === 0) {
|
|
54
|
+
void (0, import_browser.destroyBootstrappedBemonyPixel)().catch(() => {
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}, 0);
|
|
58
|
+
}
|
|
59
|
+
function warnIfOptionsChanged(initial, next) {
|
|
60
|
+
if (initial === next) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
console.warn?.(
|
|
64
|
+
"[PixelProvider] options mudaram ap\xF3s o mount. Reinit din\xE2mico est\xE1 fora do MVP; a inst\xE2ncia atual permanece."
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/provider/normalizeError.ts
|
|
69
|
+
function normalizeError(cause) {
|
|
70
|
+
if (cause instanceof Error) {
|
|
71
|
+
return cause;
|
|
72
|
+
}
|
|
73
|
+
return new Error(String(cause));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// src/provider/PixelContext.ts
|
|
77
|
+
var import_react = require("react");
|
|
78
|
+
var PixelContext = (0, import_react.createContext)(null);
|
|
79
|
+
|
|
80
|
+
// src/provider/PixelProvider.tsx
|
|
81
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
82
|
+
function PixelProvider({
|
|
83
|
+
children,
|
|
84
|
+
options
|
|
85
|
+
}) {
|
|
86
|
+
const optionsRef = (0, import_react2.useRef)(options);
|
|
87
|
+
const [pixel, setPixel] = (0, import_react2.useState)(null);
|
|
88
|
+
const [status, setStatus] = (0, import_react2.useState)("idle");
|
|
89
|
+
const [error, setError] = (0, import_react2.useState)(null);
|
|
90
|
+
(0, import_react2.useEffect)(() => {
|
|
91
|
+
warnIfOptionsChanged(optionsRef.current, options);
|
|
92
|
+
}, [options]);
|
|
93
|
+
(0, import_react2.useEffect)(() => {
|
|
94
|
+
let active = true;
|
|
95
|
+
acquireBootstrapOwnership();
|
|
96
|
+
setStatus("initializing");
|
|
97
|
+
setError(null);
|
|
98
|
+
const existing = (0, import_browser2.getBootstrappedBemonyPixel)();
|
|
99
|
+
if (existing && existing.getState() === "ready") {
|
|
100
|
+
setPixel(existing);
|
|
101
|
+
setStatus("ready");
|
|
102
|
+
}
|
|
103
|
+
const boot = (0, import_browser2.getBootstrappedBemonyPixelPending)() ?? (0, import_browser2.bootstrapBemonyPixel)(optionsRef.current);
|
|
104
|
+
boot.then((instance) => {
|
|
105
|
+
if (!active) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
setPixel(instance);
|
|
109
|
+
setStatus("ready");
|
|
110
|
+
setError(null);
|
|
111
|
+
}).catch((cause) => {
|
|
112
|
+
if (!active) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
setPixel(null);
|
|
116
|
+
setStatus("error");
|
|
117
|
+
setError(normalizeError(cause));
|
|
118
|
+
});
|
|
119
|
+
return () => {
|
|
120
|
+
active = false;
|
|
121
|
+
releaseBootstrapOwnership();
|
|
122
|
+
};
|
|
123
|
+
}, []);
|
|
124
|
+
const value = (0, import_react2.useMemo)(
|
|
125
|
+
() => ({
|
|
126
|
+
pixel,
|
|
127
|
+
status,
|
|
128
|
+
ready: status === "ready" && pixel !== null,
|
|
129
|
+
error
|
|
130
|
+
}),
|
|
131
|
+
[pixel, status, error]
|
|
132
|
+
);
|
|
133
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PixelContext.Provider, { value, children });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/hooks/usePixel.ts
|
|
137
|
+
var import_react3 = require("react");
|
|
138
|
+
function usePixel() {
|
|
139
|
+
const value = (0, import_react3.useContext)(PixelContext);
|
|
140
|
+
if (!value) {
|
|
141
|
+
throw new Error("usePixel must be used within a PixelProvider.");
|
|
142
|
+
}
|
|
143
|
+
return value;
|
|
144
|
+
}
|
|
145
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
146
|
+
0 && (module.exports = {
|
|
147
|
+
PixelProvider,
|
|
148
|
+
usePixel
|
|
149
|
+
});
|
|
150
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/provider/PixelProvider.tsx","../src/provider/bootstrapOwnership.ts","../src/provider/normalizeError.ts","../src/provider/PixelContext.ts","../src/hooks/usePixel.ts"],"sourcesContent":["export { PixelProvider } from './provider/PixelProvider';\nexport { usePixel } from './hooks/usePixel';\n\nexport type {\n PixelContextValue,\n PixelProviderProps,\n PixelProviderStatus,\n UsePixelResult,\n} from './types';\n\nexport type { BootstrapBemonyPixelOptions } from '@beworke/pixel-bemony/browser';\nexport type { BemonyPixel } from '@beworke/pixel-bemony';\n","'use client';\n\nimport {\n bootstrapBemonyPixel,\n getBootstrappedBemonyPixel,\n getBootstrappedBemonyPixelPending,\n} from '@beworke/pixel-bemony/browser';\nimport type { BemonyPixel } from '@beworke/pixel-bemony';\nimport { useEffect, useMemo, useRef, useState, type ReactElement } from 'react';\nimport type { PixelProviderProps, PixelProviderStatus } from '../types';\nimport {\n acquireBootstrapOwnership,\n releaseBootstrapOwnership,\n warnIfOptionsChanged,\n} from './bootstrapOwnership';\nimport { normalizeError } from './normalizeError';\nimport { PixelContext } from './PixelContext';\n\nexport function PixelProvider({\n children,\n options,\n}: PixelProviderProps): ReactElement {\n const optionsRef = useRef(options);\n const [pixel, setPixel] = useState<BemonyPixel | null>(null);\n const [status, setStatus] = useState<PixelProviderStatus>('idle');\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n warnIfOptionsChanged(optionsRef.current, options);\n }, [options]);\n\n useEffect(() => {\n let active = true;\n acquireBootstrapOwnership();\n setStatus('initializing');\n setError(null);\n\n const existing = getBootstrappedBemonyPixel();\n if (existing && existing.getState() === 'ready') {\n setPixel(existing);\n setStatus('ready');\n }\n\n const boot =\n getBootstrappedBemonyPixelPending() ??\n bootstrapBemonyPixel(optionsRef.current);\n\n boot\n .then(instance => {\n if (!active) {\n return;\n }\n setPixel(instance);\n setStatus('ready');\n setError(null);\n })\n .catch((cause: unknown) => {\n if (!active) {\n return;\n }\n setPixel(null);\n setStatus('error');\n setError(normalizeError(cause));\n });\n\n return () => {\n active = false;\n releaseBootstrapOwnership();\n };\n }, []);\n\n const value = useMemo(\n () => ({\n pixel,\n status,\n ready: status === 'ready' && pixel !== null,\n error,\n }),\n [pixel, status, error]\n );\n\n return (\n <PixelContext.Provider value={value}>{children}</PixelContext.Provider>\n );\n}\n","/**\n * Ownership compartilhado do bootstrap Bemony na mesma `window`.\n *\n * - Vários Providers / Strict Mode mount→cleanup→mount compartilham a instância.\n * - Destroy global só quando o ref-count volta a 0 (com defer para Strict Mode).\n */\n\nimport {\n destroyBootstrappedBemonyPixel,\n type BootstrapBemonyPixelOptions,\n} from '@beworke/pixel-bemony/browser';\n\nlet ownerCount = 0;\nlet destroyTimer: ReturnType<typeof setTimeout> | null = null;\n\n/** @internal — testes */\nexport function getBootstrapOwnerCountForTests(): number {\n return ownerCount;\n}\n\n/** @internal — testes */\nexport function resetBootstrapOwnershipForTests(): void {\n ownerCount = 0;\n if (destroyTimer !== null) {\n clearTimeout(destroyTimer);\n destroyTimer = null;\n }\n}\n\nexport function acquireBootstrapOwnership(): void {\n if (destroyTimer !== null) {\n clearTimeout(destroyTimer);\n destroyTimer = null;\n }\n ownerCount += 1;\n}\n\n/**\n * Libera ownership. Se ninguém mais possui, agenda destroy após um tick\n * (cancela se Strict Mode remountar imediatamente).\n */\nexport function releaseBootstrapOwnership(): void {\n ownerCount = Math.max(0, ownerCount - 1);\n if (ownerCount > 0) {\n return;\n }\n if (destroyTimer !== null) {\n clearTimeout(destroyTimer);\n }\n destroyTimer = setTimeout(() => {\n destroyTimer = null;\n if (ownerCount === 0) {\n void destroyBootstrappedBemonyPixel().catch(() => {\n // cleanup isolado\n });\n }\n }, 0);\n}\n\n/**\n * Options de montagem — o Provider não reage a mudanças de referência.\n * Em development, avisa se as options mudarem após o mount.\n */\nexport function warnIfOptionsChanged(\n initial: BootstrapBemonyPixelOptions,\n next: BootstrapBemonyPixelOptions\n): void {\n if (initial === next) {\n return;\n }\n // Development-only hint; safe no-op if console is unavailable.\n console.warn?.(\n '[PixelProvider] options mudaram após o mount. Reinit dinâmico está fora do MVP; a instância atual permanece.'\n );\n}\n","export function normalizeError(cause: unknown): Error {\n if (cause instanceof Error) {\n return cause;\n }\n return new Error(String(cause));\n}\n","'use client';\n\nimport { createContext } from 'react';\nimport type { PixelContextValue } from '../types';\n\n/**\n * `null` = fora do Provider (usePixel lança).\n * Valor válido sempre vem do PixelProvider.\n */\nexport const PixelContext = createContext<PixelContextValue | null>(null);\n","'use client';\n\nimport { useContext } from 'react';\nimport { PixelContext } from '../provider/PixelContext';\nimport type { UsePixelResult } from '../types';\n\n/**\n * Consome a instância `BemonyPixel` do `PixelProvider`.\n * Deve ser usado apenas em Client Components.\n */\nexport function usePixel(): UsePixelResult {\n const value = useContext(PixelContext);\n if (!value) {\n throw new Error('usePixel must be used within a PixelProvider.');\n }\n return value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAAA,kBAIO;AAEP,IAAAC,gBAAwE;;;ACDxE,qBAGO;AAEP,IAAI,aAAa;AACjB,IAAI,eAAqD;AAgBlD,SAAS,4BAAkC;AAChD,MAAI,iBAAiB,MAAM;AACzB,iBAAa,YAAY;AACzB,mBAAe;AAAA,EACjB;AACA,gBAAc;AAChB;AAMO,SAAS,4BAAkC;AAChD,eAAa,KAAK,IAAI,GAAG,aAAa,CAAC;AACvC,MAAI,aAAa,GAAG;AAClB;AAAA,EACF;AACA,MAAI,iBAAiB,MAAM;AACzB,iBAAa,YAAY;AAAA,EAC3B;AACA,iBAAe,WAAW,MAAM;AAC9B,mBAAe;AACf,QAAI,eAAe,GAAG;AACpB,eAAK,+CAA+B,EAAE,MAAM,MAAM;AAAA,MAElD,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC;AACN;AAMO,SAAS,qBACd,SACA,MACM;AACN,MAAI,YAAY,MAAM;AACpB;AAAA,EACF;AAEA,UAAQ;AAAA,IACN;AAAA,EACF;AACF;;;AC1EO,SAAS,eAAe,OAAuB;AACpD,MAAI,iBAAiB,OAAO;AAC1B,WAAO;AAAA,EACT;AACA,SAAO,IAAI,MAAM,OAAO,KAAK,CAAC;AAChC;;;ACHA,mBAA8B;AAOvB,IAAM,mBAAe,4BAAwC,IAAI;;;AHyEpE;AAhEG,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AACF,GAAqC;AACnC,QAAM,iBAAa,sBAAO,OAAO;AACjC,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAA6B,IAAI;AAC3D,QAAM,CAAC,QAAQ,SAAS,QAAI,wBAA8B,MAAM;AAChE,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAAuB,IAAI;AAErD,+BAAU,MAAM;AACd,yBAAqB,WAAW,SAAS,OAAO;AAAA,EAClD,GAAG,CAAC,OAAO,CAAC;AAEZ,+BAAU,MAAM;AACd,QAAI,SAAS;AACb,8BAA0B;AAC1B,cAAU,cAAc;AACxB,aAAS,IAAI;AAEb,UAAM,eAAW,4CAA2B;AAC5C,QAAI,YAAY,SAAS,SAAS,MAAM,SAAS;AAC/C,eAAS,QAAQ;AACjB,gBAAU,OAAO;AAAA,IACnB;AAEA,UAAM,WACJ,mDAAkC,SAClC,sCAAqB,WAAW,OAAO;AAEzC,SACG,KAAK,cAAY;AAChB,UAAI,CAAC,QAAQ;AACX;AAAA,MACF;AACA,eAAS,QAAQ;AACjB,gBAAU,OAAO;AACjB,eAAS,IAAI;AAAA,IACf,CAAC,EACA,MAAM,CAAC,UAAmB;AACzB,UAAI,CAAC,QAAQ;AACX;AAAA,MACF;AACA,eAAS,IAAI;AACb,gBAAU,OAAO;AACjB,eAAS,eAAe,KAAK,CAAC;AAAA,IAChC,CAAC;AAEH,WAAO,MAAM;AACX,eAAS;AACT,gCAA0B;AAAA,IAC5B;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,YAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,OAAO,WAAW,WAAW,UAAU;AAAA,MACvC;AAAA,IACF;AAAA,IACA,CAAC,OAAO,QAAQ,KAAK;AAAA,EACvB;AAEA,SACE,4CAAC,aAAa,UAAb,EAAsB,OAAe,UAAS;AAEnD;;;AIlFA,IAAAC,gBAA2B;AAQpB,SAAS,WAA2B;AACzC,QAAM,YAAQ,0BAAW,YAAY;AACrC,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,+CAA+C;AAAA,EACjE;AACA,SAAO;AACT;","names":["import_browser","import_react","import_react"]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ReactNode, ReactElement } from 'react';
|
|
2
|
+
import { BemonyPixel } from '@beworke/pixel-bemony';
|
|
3
|
+
export { BemonyPixel } from '@beworke/pixel-bemony';
|
|
4
|
+
import { BootstrapBemonyPixelOptions } from '@beworke/pixel-bemony/browser';
|
|
5
|
+
export { BootstrapBemonyPixelOptions } from '@beworke/pixel-bemony/browser';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Estado do Provider React (UI).
|
|
9
|
+
* Diferente de `BemonyPixel.getState()` (`failed` no wrapper).
|
|
10
|
+
* Aqui usamos `error` para falha de bootstrap no Context.
|
|
11
|
+
*/
|
|
12
|
+
type PixelProviderStatus = 'idle' | 'initializing' | 'ready' | 'error';
|
|
13
|
+
type PixelContextValue = {
|
|
14
|
+
pixel: BemonyPixel | null;
|
|
15
|
+
status: PixelProviderStatus;
|
|
16
|
+
ready: boolean;
|
|
17
|
+
error: Error | null;
|
|
18
|
+
};
|
|
19
|
+
type PixelProviderProps = {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Opções de bootstrap (`BootstrapBemonyPixelOptions`).
|
|
23
|
+
* Capturadas na montagem — mudanças posteriores não reinicializam (MVP).
|
|
24
|
+
*/
|
|
25
|
+
options: BootstrapBemonyPixelOptions;
|
|
26
|
+
};
|
|
27
|
+
type UsePixelResult = PixelContextValue;
|
|
28
|
+
|
|
29
|
+
declare function PixelProvider({ children, options, }: PixelProviderProps): ReactElement;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Consome a instância `BemonyPixel` do `PixelProvider`.
|
|
33
|
+
* Deve ser usado apenas em Client Components.
|
|
34
|
+
*/
|
|
35
|
+
declare function usePixel(): UsePixelResult;
|
|
36
|
+
|
|
37
|
+
export { type PixelContextValue, PixelProvider, type PixelProviderProps, type PixelProviderStatus, type UsePixelResult, usePixel };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ReactNode, ReactElement } from 'react';
|
|
2
|
+
import { BemonyPixel } from '@beworke/pixel-bemony';
|
|
3
|
+
export { BemonyPixel } from '@beworke/pixel-bemony';
|
|
4
|
+
import { BootstrapBemonyPixelOptions } from '@beworke/pixel-bemony/browser';
|
|
5
|
+
export { BootstrapBemonyPixelOptions } from '@beworke/pixel-bemony/browser';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Estado do Provider React (UI).
|
|
9
|
+
* Diferente de `BemonyPixel.getState()` (`failed` no wrapper).
|
|
10
|
+
* Aqui usamos `error` para falha de bootstrap no Context.
|
|
11
|
+
*/
|
|
12
|
+
type PixelProviderStatus = 'idle' | 'initializing' | 'ready' | 'error';
|
|
13
|
+
type PixelContextValue = {
|
|
14
|
+
pixel: BemonyPixel | null;
|
|
15
|
+
status: PixelProviderStatus;
|
|
16
|
+
ready: boolean;
|
|
17
|
+
error: Error | null;
|
|
18
|
+
};
|
|
19
|
+
type PixelProviderProps = {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Opções de bootstrap (`BootstrapBemonyPixelOptions`).
|
|
23
|
+
* Capturadas na montagem — mudanças posteriores não reinicializam (MVP).
|
|
24
|
+
*/
|
|
25
|
+
options: BootstrapBemonyPixelOptions;
|
|
26
|
+
};
|
|
27
|
+
type UsePixelResult = PixelContextValue;
|
|
28
|
+
|
|
29
|
+
declare function PixelProvider({ children, options, }: PixelProviderProps): ReactElement;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Consome a instância `BemonyPixel` do `PixelProvider`.
|
|
33
|
+
* Deve ser usado apenas em Client Components.
|
|
34
|
+
*/
|
|
35
|
+
declare function usePixel(): UsePixelResult;
|
|
36
|
+
|
|
37
|
+
export { type PixelContextValue, PixelProvider, type PixelProviderProps, type PixelProviderStatus, type UsePixelResult, usePixel };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// src/provider/PixelProvider.tsx
|
|
2
|
+
import {
|
|
3
|
+
bootstrapBemonyPixel,
|
|
4
|
+
getBootstrappedBemonyPixel,
|
|
5
|
+
getBootstrappedBemonyPixelPending
|
|
6
|
+
} from "@beworke/pixel-bemony/browser";
|
|
7
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
8
|
+
|
|
9
|
+
// src/provider/bootstrapOwnership.ts
|
|
10
|
+
import {
|
|
11
|
+
destroyBootstrappedBemonyPixel
|
|
12
|
+
} from "@beworke/pixel-bemony/browser";
|
|
13
|
+
var ownerCount = 0;
|
|
14
|
+
var destroyTimer = null;
|
|
15
|
+
function acquireBootstrapOwnership() {
|
|
16
|
+
if (destroyTimer !== null) {
|
|
17
|
+
clearTimeout(destroyTimer);
|
|
18
|
+
destroyTimer = null;
|
|
19
|
+
}
|
|
20
|
+
ownerCount += 1;
|
|
21
|
+
}
|
|
22
|
+
function releaseBootstrapOwnership() {
|
|
23
|
+
ownerCount = Math.max(0, ownerCount - 1);
|
|
24
|
+
if (ownerCount > 0) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (destroyTimer !== null) {
|
|
28
|
+
clearTimeout(destroyTimer);
|
|
29
|
+
}
|
|
30
|
+
destroyTimer = setTimeout(() => {
|
|
31
|
+
destroyTimer = null;
|
|
32
|
+
if (ownerCount === 0) {
|
|
33
|
+
void destroyBootstrappedBemonyPixel().catch(() => {
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}, 0);
|
|
37
|
+
}
|
|
38
|
+
function warnIfOptionsChanged(initial, next) {
|
|
39
|
+
if (initial === next) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
console.warn?.(
|
|
43
|
+
"[PixelProvider] options mudaram ap\xF3s o mount. Reinit din\xE2mico est\xE1 fora do MVP; a inst\xE2ncia atual permanece."
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/provider/normalizeError.ts
|
|
48
|
+
function normalizeError(cause) {
|
|
49
|
+
if (cause instanceof Error) {
|
|
50
|
+
return cause;
|
|
51
|
+
}
|
|
52
|
+
return new Error(String(cause));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/provider/PixelContext.ts
|
|
56
|
+
import { createContext } from "react";
|
|
57
|
+
var PixelContext = createContext(null);
|
|
58
|
+
|
|
59
|
+
// src/provider/PixelProvider.tsx
|
|
60
|
+
import { jsx } from "react/jsx-runtime";
|
|
61
|
+
function PixelProvider({
|
|
62
|
+
children,
|
|
63
|
+
options
|
|
64
|
+
}) {
|
|
65
|
+
const optionsRef = useRef(options);
|
|
66
|
+
const [pixel, setPixel] = useState(null);
|
|
67
|
+
const [status, setStatus] = useState("idle");
|
|
68
|
+
const [error, setError] = useState(null);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
warnIfOptionsChanged(optionsRef.current, options);
|
|
71
|
+
}, [options]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
let active = true;
|
|
74
|
+
acquireBootstrapOwnership();
|
|
75
|
+
setStatus("initializing");
|
|
76
|
+
setError(null);
|
|
77
|
+
const existing = getBootstrappedBemonyPixel();
|
|
78
|
+
if (existing && existing.getState() === "ready") {
|
|
79
|
+
setPixel(existing);
|
|
80
|
+
setStatus("ready");
|
|
81
|
+
}
|
|
82
|
+
const boot = getBootstrappedBemonyPixelPending() ?? bootstrapBemonyPixel(optionsRef.current);
|
|
83
|
+
boot.then((instance) => {
|
|
84
|
+
if (!active) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
setPixel(instance);
|
|
88
|
+
setStatus("ready");
|
|
89
|
+
setError(null);
|
|
90
|
+
}).catch((cause) => {
|
|
91
|
+
if (!active) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
setPixel(null);
|
|
95
|
+
setStatus("error");
|
|
96
|
+
setError(normalizeError(cause));
|
|
97
|
+
});
|
|
98
|
+
return () => {
|
|
99
|
+
active = false;
|
|
100
|
+
releaseBootstrapOwnership();
|
|
101
|
+
};
|
|
102
|
+
}, []);
|
|
103
|
+
const value = useMemo(
|
|
104
|
+
() => ({
|
|
105
|
+
pixel,
|
|
106
|
+
status,
|
|
107
|
+
ready: status === "ready" && pixel !== null,
|
|
108
|
+
error
|
|
109
|
+
}),
|
|
110
|
+
[pixel, status, error]
|
|
111
|
+
);
|
|
112
|
+
return /* @__PURE__ */ jsx(PixelContext.Provider, { value, children });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/hooks/usePixel.ts
|
|
116
|
+
import { useContext } from "react";
|
|
117
|
+
function usePixel() {
|
|
118
|
+
const value = useContext(PixelContext);
|
|
119
|
+
if (!value) {
|
|
120
|
+
throw new Error("usePixel must be used within a PixelProvider.");
|
|
121
|
+
}
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
PixelProvider,
|
|
126
|
+
usePixel
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/provider/PixelProvider.tsx","../src/provider/bootstrapOwnership.ts","../src/provider/normalizeError.ts","../src/provider/PixelContext.ts","../src/hooks/usePixel.ts"],"sourcesContent":["'use client';\n\nimport {\n bootstrapBemonyPixel,\n getBootstrappedBemonyPixel,\n getBootstrappedBemonyPixelPending,\n} from '@beworke/pixel-bemony/browser';\nimport type { BemonyPixel } from '@beworke/pixel-bemony';\nimport { useEffect, useMemo, useRef, useState, type ReactElement } from 'react';\nimport type { PixelProviderProps, PixelProviderStatus } from '../types';\nimport {\n acquireBootstrapOwnership,\n releaseBootstrapOwnership,\n warnIfOptionsChanged,\n} from './bootstrapOwnership';\nimport { normalizeError } from './normalizeError';\nimport { PixelContext } from './PixelContext';\n\nexport function PixelProvider({\n children,\n options,\n}: PixelProviderProps): ReactElement {\n const optionsRef = useRef(options);\n const [pixel, setPixel] = useState<BemonyPixel | null>(null);\n const [status, setStatus] = useState<PixelProviderStatus>('idle');\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n warnIfOptionsChanged(optionsRef.current, options);\n }, [options]);\n\n useEffect(() => {\n let active = true;\n acquireBootstrapOwnership();\n setStatus('initializing');\n setError(null);\n\n const existing = getBootstrappedBemonyPixel();\n if (existing && existing.getState() === 'ready') {\n setPixel(existing);\n setStatus('ready');\n }\n\n const boot =\n getBootstrappedBemonyPixelPending() ??\n bootstrapBemonyPixel(optionsRef.current);\n\n boot\n .then(instance => {\n if (!active) {\n return;\n }\n setPixel(instance);\n setStatus('ready');\n setError(null);\n })\n .catch((cause: unknown) => {\n if (!active) {\n return;\n }\n setPixel(null);\n setStatus('error');\n setError(normalizeError(cause));\n });\n\n return () => {\n active = false;\n releaseBootstrapOwnership();\n };\n }, []);\n\n const value = useMemo(\n () => ({\n pixel,\n status,\n ready: status === 'ready' && pixel !== null,\n error,\n }),\n [pixel, status, error]\n );\n\n return (\n <PixelContext.Provider value={value}>{children}</PixelContext.Provider>\n );\n}\n","/**\n * Ownership compartilhado do bootstrap Bemony na mesma `window`.\n *\n * - Vários Providers / Strict Mode mount→cleanup→mount compartilham a instância.\n * - Destroy global só quando o ref-count volta a 0 (com defer para Strict Mode).\n */\n\nimport {\n destroyBootstrappedBemonyPixel,\n type BootstrapBemonyPixelOptions,\n} from '@beworke/pixel-bemony/browser';\n\nlet ownerCount = 0;\nlet destroyTimer: ReturnType<typeof setTimeout> | null = null;\n\n/** @internal — testes */\nexport function getBootstrapOwnerCountForTests(): number {\n return ownerCount;\n}\n\n/** @internal — testes */\nexport function resetBootstrapOwnershipForTests(): void {\n ownerCount = 0;\n if (destroyTimer !== null) {\n clearTimeout(destroyTimer);\n destroyTimer = null;\n }\n}\n\nexport function acquireBootstrapOwnership(): void {\n if (destroyTimer !== null) {\n clearTimeout(destroyTimer);\n destroyTimer = null;\n }\n ownerCount += 1;\n}\n\n/**\n * Libera ownership. Se ninguém mais possui, agenda destroy após um tick\n * (cancela se Strict Mode remountar imediatamente).\n */\nexport function releaseBootstrapOwnership(): void {\n ownerCount = Math.max(0, ownerCount - 1);\n if (ownerCount > 0) {\n return;\n }\n if (destroyTimer !== null) {\n clearTimeout(destroyTimer);\n }\n destroyTimer = setTimeout(() => {\n destroyTimer = null;\n if (ownerCount === 0) {\n void destroyBootstrappedBemonyPixel().catch(() => {\n // cleanup isolado\n });\n }\n }, 0);\n}\n\n/**\n * Options de montagem — o Provider não reage a mudanças de referência.\n * Em development, avisa se as options mudarem após o mount.\n */\nexport function warnIfOptionsChanged(\n initial: BootstrapBemonyPixelOptions,\n next: BootstrapBemonyPixelOptions\n): void {\n if (initial === next) {\n return;\n }\n // Development-only hint; safe no-op if console is unavailable.\n console.warn?.(\n '[PixelProvider] options mudaram após o mount. Reinit dinâmico está fora do MVP; a instância atual permanece.'\n );\n}\n","export function normalizeError(cause: unknown): Error {\n if (cause instanceof Error) {\n return cause;\n }\n return new Error(String(cause));\n}\n","'use client';\n\nimport { createContext } from 'react';\nimport type { PixelContextValue } from '../types';\n\n/**\n * `null` = fora do Provider (usePixel lança).\n * Valor válido sempre vem do PixelProvider.\n */\nexport const PixelContext = createContext<PixelContextValue | null>(null);\n","'use client';\n\nimport { useContext } from 'react';\nimport { PixelContext } from '../provider/PixelContext';\nimport type { UsePixelResult } from '../types';\n\n/**\n * Consome a instância `BemonyPixel` do `PixelProvider`.\n * Deve ser usado apenas em Client Components.\n */\nexport function usePixel(): UsePixelResult {\n const value = useContext(PixelContext);\n if (!value) {\n throw new Error('usePixel must be used within a PixelProvider.');\n }\n return value;\n}\n"],"mappings":";AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,WAAW,SAAS,QAAQ,gBAAmC;;;ACDxE;AAAA,EACE;AAAA,OAEK;AAEP,IAAI,aAAa;AACjB,IAAI,eAAqD;AAgBlD,SAAS,4BAAkC;AAChD,MAAI,iBAAiB,MAAM;AACzB,iBAAa,YAAY;AACzB,mBAAe;AAAA,EACjB;AACA,gBAAc;AAChB;AAMO,SAAS,4BAAkC;AAChD,eAAa,KAAK,IAAI,GAAG,aAAa,CAAC;AACvC,MAAI,aAAa,GAAG;AAClB;AAAA,EACF;AACA,MAAI,iBAAiB,MAAM;AACzB,iBAAa,YAAY;AAAA,EAC3B;AACA,iBAAe,WAAW,MAAM;AAC9B,mBAAe;AACf,QAAI,eAAe,GAAG;AACpB,WAAK,+BAA+B,EAAE,MAAM,MAAM;AAAA,MAElD,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC;AACN;AAMO,SAAS,qBACd,SACA,MACM;AACN,MAAI,YAAY,MAAM;AACpB;AAAA,EACF;AAEA,UAAQ;AAAA,IACN;AAAA,EACF;AACF;;;AC1EO,SAAS,eAAe,OAAuB;AACpD,MAAI,iBAAiB,OAAO;AAC1B,WAAO;AAAA,EACT;AACA,SAAO,IAAI,MAAM,OAAO,KAAK,CAAC;AAChC;;;ACHA,SAAS,qBAAqB;AAOvB,IAAM,eAAe,cAAwC,IAAI;;;AHyEpE;AAhEG,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AACF,GAAqC;AACnC,QAAM,aAAa,OAAO,OAAO;AACjC,QAAM,CAAC,OAAO,QAAQ,IAAI,SAA6B,IAAI;AAC3D,QAAM,CAAC,QAAQ,SAAS,IAAI,SAA8B,MAAM;AAChE,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAuB,IAAI;AAErD,YAAU,MAAM;AACd,yBAAqB,WAAW,SAAS,OAAO;AAAA,EAClD,GAAG,CAAC,OAAO,CAAC;AAEZ,YAAU,MAAM;AACd,QAAI,SAAS;AACb,8BAA0B;AAC1B,cAAU,cAAc;AACxB,aAAS,IAAI;AAEb,UAAM,WAAW,2BAA2B;AAC5C,QAAI,YAAY,SAAS,SAAS,MAAM,SAAS;AAC/C,eAAS,QAAQ;AACjB,gBAAU,OAAO;AAAA,IACnB;AAEA,UAAM,OACJ,kCAAkC,KAClC,qBAAqB,WAAW,OAAO;AAEzC,SACG,KAAK,cAAY;AAChB,UAAI,CAAC,QAAQ;AACX;AAAA,MACF;AACA,eAAS,QAAQ;AACjB,gBAAU,OAAO;AACjB,eAAS,IAAI;AAAA,IACf,CAAC,EACA,MAAM,CAAC,UAAmB;AACzB,UAAI,CAAC,QAAQ;AACX;AAAA,MACF;AACA,eAAS,IAAI;AACb,gBAAU,OAAO;AACjB,eAAS,eAAe,KAAK,CAAC;AAAA,IAChC,CAAC;AAEH,WAAO,MAAM;AACX,eAAS;AACT,gCAA0B;AAAA,IAC5B;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,OAAO,WAAW,WAAW,UAAU;AAAA,MACvC;AAAA,IACF;AAAA,IACA,CAAC,OAAO,QAAQ,KAAK;AAAA,EACvB;AAEA,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAe,UAAS;AAEnD;;;AIlFA,SAAS,kBAAkB;AAQpB,SAAS,WAA2B;AACzC,QAAM,QAAQ,WAAW,YAAY;AACrC,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,+CAA+C;AAAA,EACjE;AACA,SAAO;AACT;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@beworke/pixel-bemony-react",
|
|
3
|
+
"version": "0.1.0-rc.1",
|
|
4
|
+
"description": "Camada React/Next.js sobre @beworke/pixel-bemony — PixelProvider e usePixel",
|
|
5
|
+
"main": "./dist/index.cjs.js",
|
|
6
|
+
"module": "./dist/index.esm.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.esm.js",
|
|
12
|
+
"require": "./dist/index.cjs.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"CHANGELOG.md",
|
|
19
|
+
"RELEASE_CANDIDATE.md"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@beworke/pixel-bemony": "0.1.0-rc.1"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@beworke/pixel-bemony": ">=0.1.0-rc.1",
|
|
26
|
+
"react": ">=18",
|
|
27
|
+
"react-dom": ">=18"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@testing-library/react": "^16.3.0",
|
|
34
|
+
"@types/react": "^19",
|
|
35
|
+
"@types/react-dom": "^19",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
37
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
38
|
+
"eslint": "^8.0.0",
|
|
39
|
+
"eslint-config-prettier": "^9.0.0",
|
|
40
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
41
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
42
|
+
"happy-dom": "^20.0.0",
|
|
43
|
+
"prettier": "^3.0.0",
|
|
44
|
+
"react": "19.2.4",
|
|
45
|
+
"react-dom": "19.2.4",
|
|
46
|
+
"rimraf": "^6.0.1",
|
|
47
|
+
"tsup": "^8.5.0",
|
|
48
|
+
"typescript": "^5.0.0",
|
|
49
|
+
"vitest": "^4.0.18"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsup",
|
|
53
|
+
"test": "vitest run",
|
|
54
|
+
"type-check": "tsc --noEmit",
|
|
55
|
+
"lint": "eslint src tests --ext .ts,.tsx",
|
|
56
|
+
"clean": "rimraf dist coverage",
|
|
57
|
+
"publish:rc": "pnpm publish --access public --tag rc --no-git-checks && npm dist-tag add @beworke/pixel-bemony-react@$(node -p \"require('./package.json').version\") latest"
|
|
58
|
+
}
|
|
59
|
+
}
|