@cowliss/cli 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.
Files changed (31) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +105 -0
  3. package/dist/guest/constants-OZrYz4I2.d.ts +42 -0
  4. package/dist/guest/driver-BOe7jBFw.js +5647 -0
  5. package/dist/guest/driver.d.ts +21 -0
  6. package/dist/guest/driver.js +3 -0
  7. package/dist/guest/emails.d.ts +24 -0
  8. package/dist/guest/emails.js +0 -0
  9. package/dist/guest/index-heC1gFE_.d.ts +296 -0
  10. package/dist/guest/journeys-CxuS-mHn.js +571 -0
  11. package/dist/guest/journeys.d.ts +127 -0
  12. package/dist/guest/journeys.js +3 -0
  13. package/dist/guest/prelude.d.ts +1 -0
  14. package/dist/guest/prelude.js +91 -0
  15. package/dist/guest/wasi.d.ts +6 -0
  16. package/dist/guest/wasi.js +43 -0
  17. package/dist/index.js +11235 -0
  18. package/examples/abandoned-checkout/emails/abandoned-checkout.tsx +104 -0
  19. package/examples/abandoned-checkout/journeys/abandoned-checkout.ts +39 -0
  20. package/examples/abandoned-checkout/scenarios/abandoned-checkout.recovered.json +10 -0
  21. package/examples/abandoned-checkout/scenarios/abandoned-checkout.timeout.json +16 -0
  22. package/examples/activity-decay/journeys/activity-decay.ts +36 -0
  23. package/examples/activity-decay/scenarios/activity-decay.json +8 -0
  24. package/examples/cross-app-pitch/emails/cross-app-pitch.tsx +77 -0
  25. package/examples/cross-app-pitch/journeys/cross-app-pitch.ts +30 -0
  26. package/examples/cross-app-pitch/scenarios/cross-app-pitch.json +16 -0
  27. package/examples/winback/emails/winback.tsx +78 -0
  28. package/examples/winback/journeys/winback.ts +33 -0
  29. package/examples/winback/scenarios/winback.json +18 -0
  30. package/package.json +82 -0
  31. package/project/tsconfig.json +18 -0
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,91 @@
1
+ //#region src/guest/prelude.ts
2
+ const STDERR = 2;
3
+ function port() {
4
+ return {
5
+ onmessage: null,
6
+ postMessage() {},
7
+ close() {}
8
+ };
9
+ }
10
+ /**
11
+ * The scheme, authority, path, query, and fragment split of RFC 3986
12
+ * appendix B, tightened to require a scheme: a string without one is what
13
+ * the constructor rejects.
14
+ */
15
+ const URL_PARTS = /^([A-Za-z][A-Za-z0-9+.-]*):(?:\/\/([^/?#]*))?([^?#]*)(\?[^#]*)?(#.*)?$/;
16
+ /** Schemes whose `origin` is the scheme and authority rather than "null". */
17
+ const SPECIAL = [
18
+ "http:",
19
+ "https:",
20
+ "ws:",
21
+ "wss:",
22
+ "ftp:"
23
+ ];
24
+ /**
25
+ * ponytail: a regex split, not a WHATWG parser. No IDNA, no percent
26
+ * normalisation, no `searchParams`, and no resolution of a relative input
27
+ * against a base. Swap in `whatwg-url` if a tenant ever hits a false
28
+ * negative; it is not here today because it would land in the bundle of
29
+ * every template and every journey.
30
+ */
31
+ var GuestURL = class {
32
+ href;
33
+ protocol;
34
+ hostname;
35
+ port;
36
+ pathname;
37
+ search;
38
+ hash;
39
+ constructor(input, base) {
40
+ if (base !== void 0) throw new TypeError("Invalid URL: this sandbox resolves no relative URLs, so `new URL(input, base)` needs an absolute `input`");
41
+ const raw = String(input).trim();
42
+ const parts = /\s/.test(raw) ? null : URL_PARTS.exec(raw);
43
+ if (parts === null) throw new TypeError("Invalid URL");
44
+ const authority = parts[2];
45
+ const path = parts[3] ?? "";
46
+ this.protocol = `${(parts[1] ?? "").toLowerCase()}:`;
47
+ const hostPort = (authority ?? "").split("@").pop() ?? "";
48
+ const colon = hostPort.lastIndexOf(":");
49
+ const split = colon > hostPort.lastIndexOf("]") ? colon : -1;
50
+ this.hostname = (split === -1 ? hostPort : hostPort.slice(0, split)).toLowerCase();
51
+ this.port = split === -1 ? "" : hostPort.slice(split + 1);
52
+ this.pathname = path === "" && authority !== void 0 ? "/" : path;
53
+ this.search = parts[4] ?? "";
54
+ this.hash = parts[5] ?? "";
55
+ this.href = `${this.protocol}${authority === void 0 ? "" : `//${this.host}`}${this.pathname}${this.search}${this.hash}`;
56
+ }
57
+ get host() {
58
+ return this.port === "" ? this.hostname : `${this.hostname}:${this.port}`;
59
+ }
60
+ get origin() {
61
+ return SPECIAL.includes(this.protocol) ? `${this.protocol}//${this.host}` : "null";
62
+ }
63
+ toString() {
64
+ return this.href;
65
+ }
66
+ toJSON() {
67
+ return this.href;
68
+ }
69
+ };
70
+ if (typeof Javy !== "undefined") {
71
+ const globals = globalThis;
72
+ globals.MessageChannel ??= function MessageChannel() {
73
+ this.port1 = port();
74
+ this.port2 = port();
75
+ };
76
+ globals.URL ??= GuestURL;
77
+ const encoder = new TextEncoder();
78
+ const write = (parts) => {
79
+ Javy.IO.writeSync(STDERR, encoder.encode(`${parts.map((part) => String(part)).join(" ")}\n`));
80
+ };
81
+ for (const level of [
82
+ "log",
83
+ "info",
84
+ "warn",
85
+ "error",
86
+ "debug",
87
+ "trace"
88
+ ]) console[level] = (...parts) => write(parts);
89
+ }
90
+
91
+ //#endregion
@@ -0,0 +1,6 @@
1
+ import { GuestModule } from "./driver.js";
2
+ //#region src/guest/wasi.d.ts
3
+ /** Drives one invocation of the module this bundle was built for. */
4
+ declare function main(module: GuestModule): void;
5
+ //#endregion
6
+ export { main };
@@ -0,0 +1,43 @@
1
+ import { t as runGuest } from "./driver-BOe7jBFw.js";
2
+
3
+ //#region src/guest/wasi.ts
4
+ const STDIN = 0;
5
+ const STDOUT = 1;
6
+ const STDERR = 2;
7
+ const CHUNK_BYTES = 65536;
8
+ function readStdin() {
9
+ const chunks = [];
10
+ let total = 0;
11
+ for (;;) {
12
+ const chunk = new Uint8Array(CHUNK_BYTES);
13
+ const read = Javy.IO.readSync(STDIN, chunk);
14
+ if (read <= 0) break;
15
+ chunks.push(chunk.subarray(0, read));
16
+ total += read;
17
+ }
18
+ const input = new Uint8Array(total);
19
+ let offset = 0;
20
+ for (const chunk of chunks) {
21
+ input.set(chunk, offset);
22
+ offset += chunk.length;
23
+ }
24
+ return new TextDecoder().decode(input);
25
+ }
26
+ function write(fd, text) {
27
+ Javy.IO.writeSync(fd, new TextEncoder().encode(text));
28
+ }
29
+ /** Drives one invocation of the module this bundle was built for. */
30
+ function main(module) {
31
+ const fail = (error) => {
32
+ write(STDERR, error instanceof Error ? error.message : String(error));
33
+ throw error;
34
+ };
35
+ try {
36
+ runGuest(module, JSON.parse(readStdin())).then((output) => write(STDOUT, JSON.stringify(output))).catch(fail);
37
+ } catch (error) {
38
+ fail(error);
39
+ }
40
+ }
41
+
42
+ //#endregion
43
+ export { main };