@lapwy/next 0.0.0-stage → 0.1.0

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
@@ -1,3 +1,23 @@
1
- # Temporary Holding Version
1
+ # @lapwy/next
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ lapwy for Next.js (App Router or Pages Router).
4
+
5
+ ```sh
6
+ npm install @lapwy/next
7
+ ```
8
+
9
+ ```jsx
10
+ // app/layout.tsx
11
+ import { Lapwy } from "@lapwy/next";
12
+
13
+ <body>{children}<Lapwy site="lw_…" /></body>
14
+ ```
15
+
16
+ ```js
17
+ // in a client component
18
+ import { track } from "@lapwy/next";
19
+
20
+ track("signup", { plan: "pro" });
21
+ ```
22
+
23
+ This is a client module. Also exported: `useLapwy`, `page`, `consent` and `notFound`.
package/dist/index.cjs ADDED
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.tsx
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ Lapwy: () => Lapwy,
25
+ consent: () => import_js.consent,
26
+ notFound: () => import_js.notFound,
27
+ page: () => import_js.page,
28
+ track: () => import_js.track,
29
+ useLapwy: () => useLapwy
30
+ });
31
+ module.exports = __toCommonJS(src_exports);
32
+ var import_react = require("react");
33
+ var import_js = require("@lapwy/js");
34
+ function Lapwy(props) {
35
+ const { site, endpoint, cookie, release, api: apiHosts, pages, path } = props;
36
+ (0, import_react.useEffect)(() => {
37
+ (0, import_js.init)({ site, endpoint, cookie, release, api: apiHosts, pages, path, sdk: "next-0.2" });
38
+ }, []);
39
+ return null;
40
+ }
41
+ var api = { track: import_js.track, page: import_js.page, consent: import_js.consent, notFound: import_js.notFound };
42
+ function useLapwy() {
43
+ return api;
44
+ }
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ Lapwy,
48
+ consent,
49
+ notFound,
50
+ page,
51
+ track,
52
+ useLapwy
53
+ });
@@ -0,0 +1,7 @@
1
+ import { consent, notFound, page, track, type Options, type Tracker } from "@lapwy/js";
2
+ export type LapwyProps = Omit<Options, "sdk">;
3
+ /** Starts tracking when it mounts. Renders nothing. Put it once in the root layout. */
4
+ export declare function Lapwy(props: LapwyProps): null;
5
+ /** track, page and consent, for client components. */
6
+ export declare function useLapwy(): Tracker;
7
+ export { track, page, consent, notFound };
@@ -0,0 +1,7 @@
1
+ import { consent, notFound, page, track, type Options, type Tracker } from "@lapwy/js";
2
+ export type LapwyProps = Omit<Options, "sdk">;
3
+ /** Starts tracking when it mounts. Renders nothing. Put it once in the root layout. */
4
+ export declare function Lapwy(props: LapwyProps): null;
5
+ /** track, page and consent, for client components. */
6
+ export declare function useLapwy(): Tracker;
7
+ export { track, page, consent, notFound };
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ "use client";
2
+
3
+ // src/index.tsx
4
+ import { useEffect } from "react";
5
+ import { consent, init, notFound, page, track } from "@lapwy/js";
6
+ function Lapwy(props) {
7
+ const { site, endpoint, cookie, release, api: apiHosts, pages, path } = props;
8
+ useEffect(() => {
9
+ init({ site, endpoint, cookie, release, api: apiHosts, pages, path, sdk: "next-0.2" });
10
+ }, []);
11
+ return null;
12
+ }
13
+ var api = { track, page, consent, notFound };
14
+ function useLapwy() {
15
+ return api;
16
+ }
17
+ export {
18
+ Lapwy,
19
+ consent,
20
+ notFound,
21
+ page,
22
+ track,
23
+ useLapwy
24
+ };
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "@lapwy/next",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "lapwy for Next.js (App Router and Pages Router): the <Lapwy> component and track().",
5
+ "license": "UNLICENSED",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "main": "./dist/index.cjs",
12
+ "module": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "import": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "require": {
21
+ "types": "./dist/index.d.cts",
22
+ "default": "./dist/index.cjs"
23
+ }
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "dependencies": {
28
+ "@lapwy/js": "^0.1.0"
29
+ },
30
+ "peerDependencies": {
31
+ "next": ">=13",
32
+ "react": ">=18"
33
+ },
34
+ "peerDependenciesMeta": {
35
+ "next": {
36
+ "optional": true
37
+ }
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "scripts": {
43
+ "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/cts-types.mjs"
44
+ }
6
45
  }