@inlang/paraglide-js 2.13.2 → 2.14.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/dist/compiler/compile-bundle.js +2 -2
- package/dist/compiler/compile-bundle.test.js +1 -1
- package/dist/compiler/compile.test.js +31 -0
- package/dist/compiler/compile.test.js.map +1 -1
- package/dist/compiler/compiler-options.d.ts +8 -6
- package/dist/compiler/compiler-options.d.ts.map +1 -1
- package/dist/compiler/runtime/assert-is-locale.d.ts +2 -2
- package/dist/compiler/runtime/assert-is-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/assert-is-locale.js +1 -1
- package/dist/compiler/runtime/assert-is-locale.test.js +1 -2
- package/dist/compiler/runtime/assert-is-locale.test.js.map +1 -1
- package/dist/compiler/runtime/create-runtime.d.ts.map +1 -1
- package/dist/compiler/runtime/create-runtime.js +8 -122
- package/dist/compiler/runtime/create-runtime.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-cookie.d.ts +2 -2
- package/dist/compiler/runtime/extract-locale-from-cookie.js +1 -1
- package/dist/compiler/runtime/extract-locale-from-header.d.ts +13 -1
- package/dist/compiler/runtime/extract-locale-from-header.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-header.js +1 -2
- package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-navigator.d.ts +11 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-navigator.js +1 -2
- package/dist/compiler/runtime/extract-locale-from-navigator.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-request-async.d.ts +1 -30
- package/dist/compiler/runtime/extract-locale-from-request-async.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-request-async.js +2 -1
- package/dist/compiler/runtime/extract-locale-from-request-async.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-request.d.ts +1 -19
- package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-request.js +2 -1
- package/dist/compiler/runtime/extract-locale-from-request.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-url.js +2 -2
- package/dist/compiler/runtime/generate-static-localized-urls.d.ts.map +1 -1
- package/dist/compiler/runtime/generate-static-localized-urls.js +1 -0
- package/dist/compiler/runtime/generate-static-localized-urls.js.map +1 -1
- package/dist/compiler/runtime/get-locale.d.ts +2 -35
- package/dist/compiler/runtime/get-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/get-locale.js +3 -3
- package/dist/compiler/runtime/get-url-origin.d.ts +1 -9
- package/dist/compiler/runtime/get-url-origin.d.ts.map +1 -1
- package/dist/compiler/runtime/get-url-origin.js +1 -1
- package/dist/compiler/runtime/is-locale.d.ts +3 -2
- package/dist/compiler/runtime/is-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/is-locale.js +2 -1
- package/dist/compiler/runtime/is-locale.js.map +1 -1
- package/dist/compiler/runtime/localize-url.d.ts +7 -0
- package/dist/compiler/runtime/localize-url.d.ts.map +1 -1
- package/dist/compiler/runtime/localize-url.js +2 -1
- package/dist/compiler/runtime/localize-url.js.map +1 -1
- package/dist/compiler/runtime/set-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/set-locale.js +1 -2
- package/dist/compiler/runtime/set-locale.js.map +1 -1
- package/dist/compiler/runtime/should-redirect.d.ts +2 -2
- package/dist/compiler/runtime/should-redirect.d.ts.map +1 -1
- package/dist/compiler/runtime/strategy.d.ts +6 -6
- package/dist/compiler/runtime/strategy.d.ts.map +1 -1
- package/dist/compiler/runtime/strategy.js +3 -3
- package/dist/compiler/runtime/type-definitions.d.ts +97 -0
- package/dist/compiler/runtime/type-definitions.d.ts.map +1 -0
- package/dist/compiler/runtime/type-definitions.js +150 -0
- package/dist/compiler/runtime/type-definitions.js.map +1 -0
- package/dist/compiler/runtime/variables.d.ts +2 -2
- package/dist/compiler/runtime/variables.d.ts.map +1 -1
- package/dist/compiler/runtime/variables.js +2 -2
- package/dist/compiler/runtime/variables.js.map +1 -1
- package/dist/compiler/server/create-server-file.d.ts.map +1 -1
- package/dist/compiler/server/create-server-file.js.map +1 -1
- package/dist/compiler/server/middleware.d.ts +6 -17
- package/dist/compiler/server/middleware.d.ts.map +1 -1
- package/dist/compiler/server/middleware.js +11 -20
- package/dist/compiler/server/middleware.js.map +1 -1
- package/dist/compiler/types.d.ts +1 -77
- package/dist/compiler/types.d.ts.map +1 -1
- package/dist/services/env-variables/create-index-file.js +0 -1
- package/dist/services/env-variables/create-index-file.js.map +1 -1
- package/dist/services/env-variables/index.d.ts +0 -1
- package/dist/services/env-variables/index.d.ts.map +1 -1
- package/dist/services/env-variables/index.js +1 -2
- package/dist/services/env-variables/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/services/telemetry/capture.d.ts +0 -15
- package/dist/services/telemetry/capture.d.ts.map +0 -1
- package/dist/services/telemetry/capture.js +0 -72
- package/dist/services/telemetry/capture.js.map +0 -1
- package/dist/services/telemetry/capture.test.d.ts +0 -2
- package/dist/services/telemetry/capture.test.d.ts.map +0 -1
- package/dist/services/telemetry/capture.test.js +0 -41
- package/dist/services/telemetry/capture.test.js.map +0 -1
- package/dist/services/telemetry/stack-detection.d.ts +0 -40
- package/dist/services/telemetry/stack-detection.d.ts.map +0 -1
- package/dist/services/telemetry/stack-detection.js +0 -78
- package/dist/services/telemetry/stack-detection.js.map +0 -1
- package/dist/services/telemetry/stack-detection.test.d.ts +0 -2
- package/dist/services/telemetry/stack-detection.test.d.ts.map +0 -1
- package/dist/services/telemetry/stack-detection.test.js +0 -37
- package/dist/services/telemetry/stack-detection.test.js.map +0 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// ------ TYPES ------
|
|
2
|
+
export {};
|
|
3
|
+
/**
|
|
4
|
+
* A locale that is available in the project.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* setLocale(request.locale as Locale)
|
|
8
|
+
*
|
|
9
|
+
* @typedef {string} Locale
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* A branded type representing a localized string.
|
|
13
|
+
*
|
|
14
|
+
* Message functions return this type instead of \`string\`, enabling TypeScript
|
|
15
|
+
* to distinguish translated strings from regular strings at compile time.
|
|
16
|
+
* This allows you to enforce that only properly localized content is used
|
|
17
|
+
* in your UI components.
|
|
18
|
+
*
|
|
19
|
+
* Since \`LocalizedString\` is a branded subtype of \`string\`, it remains fully
|
|
20
|
+
* backward compatible—you can pass it anywhere a \`string\` is expected.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Enforce localized strings in your components
|
|
24
|
+
* function PageTitle(props: { title: LocalizedString }) {
|
|
25
|
+
* return <h1>{props.title}</h1>
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* // ✅ Correct: using a message function
|
|
29
|
+
* <PageTitle title={m.welcome_title()} />
|
|
30
|
+
*
|
|
31
|
+
* // ❌ Type error: raw strings are not LocalizedString
|
|
32
|
+
* <PageTitle title="Welcome" />
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // LocalizedString is assignable to string (backward compatible)
|
|
36
|
+
* const localized: LocalizedString = m.greeting()
|
|
37
|
+
* const str: string = localized // ✅ works fine
|
|
38
|
+
*
|
|
39
|
+
* // But string is not assignable to LocalizedString
|
|
40
|
+
* const raw: LocalizedString = "Hello" // ❌ Type error
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Catches accidental string concatenation
|
|
44
|
+
* function showMessage(msg: LocalizedString) { ... }
|
|
45
|
+
*
|
|
46
|
+
* showMessage(m.hello()) // ✅
|
|
47
|
+
* showMessage("Hello " + userName) // ❌ Type error
|
|
48
|
+
* showMessage(m.hello_user({ name: userName })) // ✅ use params instead
|
|
49
|
+
*
|
|
50
|
+
* @typedef {string & { readonly __brand: 'LocalizedString' }} LocalizedString
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* A single markup option passed to a tag instance.
|
|
54
|
+
*
|
|
55
|
+
* @typedef {{
|
|
56
|
+
* name: string;
|
|
57
|
+
* value: unknown;
|
|
58
|
+
* }} MessageMarkupOption
|
|
59
|
+
*/
|
|
60
|
+
/**
|
|
61
|
+
* A single static markup attribute attached to a tag instance.
|
|
62
|
+
*
|
|
63
|
+
* @typedef {{
|
|
64
|
+
* name: string;
|
|
65
|
+
* value: string | true;
|
|
66
|
+
* }} MessageMarkupAttribute
|
|
67
|
+
*/
|
|
68
|
+
/**
|
|
69
|
+
* Record of markup options for a tag instance.
|
|
70
|
+
*
|
|
71
|
+
* @typedef {Record<string, unknown>} MessageMarkupOptions
|
|
72
|
+
*/
|
|
73
|
+
/**
|
|
74
|
+
* Record of markup attributes for a tag instance.
|
|
75
|
+
*
|
|
76
|
+
* @typedef {Record<string, string | true>} MessageMarkupAttributes
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* Type-level schema for a single markup tag.
|
|
80
|
+
*
|
|
81
|
+
* @typedef {{
|
|
82
|
+
* options: MessageMarkupOptions;
|
|
83
|
+
* attributes: MessageMarkupAttributes;
|
|
84
|
+
* children: boolean;
|
|
85
|
+
* }} MessageMarkupTag
|
|
86
|
+
*/
|
|
87
|
+
/**
|
|
88
|
+
* Type-level schema for all markup tags in a message.
|
|
89
|
+
*
|
|
90
|
+
* @typedef {Record<string, MessageMarkupTag>} MessageMarkupSchema
|
|
91
|
+
*/
|
|
92
|
+
/**
|
|
93
|
+
* Type-only metadata attached to compiled message functions.
|
|
94
|
+
*
|
|
95
|
+
* @template Inputs
|
|
96
|
+
* @template Options
|
|
97
|
+
* @template {MessageMarkupSchema} [Markup = MessageMarkupSchema]
|
|
98
|
+
* @typedef {{
|
|
99
|
+
* readonly __paraglide?: {
|
|
100
|
+
* inputs: Inputs;
|
|
101
|
+
* options: Options;
|
|
102
|
+
* markup: Markup;
|
|
103
|
+
* };
|
|
104
|
+
* }} MessageMetadata
|
|
105
|
+
*/
|
|
106
|
+
/**
|
|
107
|
+
* A compiled, framework-neutral message part.
|
|
108
|
+
*
|
|
109
|
+
* @typedef {{
|
|
110
|
+
* type: "text";
|
|
111
|
+
* value: string;
|
|
112
|
+
* } | {
|
|
113
|
+
* type: "markup-start";
|
|
114
|
+
* name: string;
|
|
115
|
+
* options: MessageMarkupOptions;
|
|
116
|
+
* attributes: MessageMarkupAttributes;
|
|
117
|
+
* } | {
|
|
118
|
+
* type: "markup-end";
|
|
119
|
+
* name: string;
|
|
120
|
+
* options: MessageMarkupOptions;
|
|
121
|
+
* attributes: MessageMarkupAttributes;
|
|
122
|
+
* } | {
|
|
123
|
+
* type: "markup-standalone";
|
|
124
|
+
* name: string;
|
|
125
|
+
* options: MessageMarkupOptions;
|
|
126
|
+
* attributes: MessageMarkupAttributes;
|
|
127
|
+
* }} MessagePart
|
|
128
|
+
*/
|
|
129
|
+
/**
|
|
130
|
+
* A message function is a message for a specific locale.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* m.hello({ name: 'world' })
|
|
134
|
+
*
|
|
135
|
+
* @typedef {(inputs?: Record<string, never>) => LocalizedString} MessageFunction
|
|
136
|
+
*/
|
|
137
|
+
/**
|
|
138
|
+
* A message bundle function that selects the message to be returned.
|
|
139
|
+
*
|
|
140
|
+
* Uses `getLocale()` under the hood to determine the locale with an option.
|
|
141
|
+
*
|
|
142
|
+
* @template {string} T
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* import { m } from './messages.js'
|
|
146
|
+
* m.hello({ name: 'world', { locale: "en" } })
|
|
147
|
+
*
|
|
148
|
+
* @typedef {(params: Record<string, never>, options: { locale: T }) => LocalizedString} MessageBundleFunction
|
|
149
|
+
*/
|
|
150
|
+
//# sourceMappingURL=type-definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-definitions.js","sourceRoot":"","sources":["../../../src/compiler/runtime/type-definitions.js"],"names":[],"mappings":"AAAA,sBAAsB;;AAEtB;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH;;;;;;;GAOG;AAEH;;;;;;;GAOG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;;;;GAQG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;GAOG;AAEH;;;;;;;;;;;;GAYG"}
|
|
@@ -43,7 +43,7 @@ export const baseLocale: "en";
|
|
|
43
43
|
* throw new Error('Locale is not available');
|
|
44
44
|
* }
|
|
45
45
|
*/
|
|
46
|
-
export const locales: readonly [
|
|
46
|
+
export const locales: readonly string[];
|
|
47
47
|
/** @type {string} */
|
|
48
48
|
export const cookieName: string;
|
|
49
49
|
/** @type {number} */
|
|
@@ -75,7 +75,7 @@ export const routeStrategies: Array<{
|
|
|
75
75
|
/**
|
|
76
76
|
* The used URL patterns.
|
|
77
77
|
*
|
|
78
|
-
* @type {Array<{ pattern: string, localized: Array<[Locale, string]> }>
|
|
78
|
+
* @type {Array<{ pattern: string, localized: Array<[Locale, string]> }>}
|
|
79
79
|
*/
|
|
80
80
|
export const urlPatterns: Array<{
|
|
81
81
|
pattern: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/variables.js"],"names":[],"mappings":"AA2FA;;;;;;;;GAQG;AACH,uCAHW,MAAM,GAAG,GAAG,GACV,OAAO,QAAQ,CAa3B;AAED;;;;;GAKG;AACH,+CAHW,MAAM,GAAG,GAAG,GACV,OAAO,CAInB;AAkCD;;;;;;;;;GASG;AACH,wDAFW,0BAA0B,GAAG,SAAS,QAIhD;AAvKD;;;;;;;GAOG;AACH,yBAA0B,IAAI,CAAC;AAE/B;;;;;;;GAOG;AACH,
|
|
1
|
+
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../../src/compiler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EtD,iCAAiC;AAEjC,uCAFW,MAAM,GAAG,SAAS,CAEqB;AAgBlD,8CAA+C,KAAK,CAAC;AAErD,2CAA4C,KAAK,CAAC;AAElD,uDAAwD,KAAK,CAAC;AAE9D,0DAA2D,KAAK,CAAC;AAEjE,kDAAmD,KAAK,CAAC;AAEzD,qDAAsD,KAAK,CAAC;yCAvD/C;IACR,QAAQ,IAAI;QACV,MAAM,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KACzB,GAAG,SAAS,CAAC;IACf,GAAG,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAC,EAC3E,EAAE,EAAE,GAAG,KAAK,GAAG,CAAA;CACjB"}
|
|
@@ -15,7 +15,7 @@ export const baseLocale = "en";
|
|
|
15
15
|
* throw new Error('Locale is not available');
|
|
16
16
|
* }
|
|
17
17
|
*/
|
|
18
|
-
export const locales = /** @type {
|
|
18
|
+
export const locales = /** @type {readonly string[]} */ (["en", "de"]);
|
|
19
19
|
/** @type {string} */
|
|
20
20
|
export const cookieName = "<cookie-name>";
|
|
21
21
|
/** @type {number} */
|
|
@@ -43,7 +43,7 @@ export const routeStrategies = [];
|
|
|
43
43
|
/**
|
|
44
44
|
* The used URL patterns.
|
|
45
45
|
*
|
|
46
|
-
* @type {Array<{ pattern: string, localized: Array<[Locale, string]> }>
|
|
46
|
+
* @type {Array<{ pattern: string, localized: Array<[Locale, string]> }>}
|
|
47
47
|
*/
|
|
48
48
|
export const urlPatterns = [];
|
|
49
49
|
/** @type {string | undefined} */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.js","sourceRoot":"","sources":["../../../src/compiler/runtime/variables.js"],"names":[],"m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3D,MAAM,CAAC,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAEtD,iCAAiC;AACjC,oDAAoD;AACpD,MAAM,CAAC,MAAM,wBAAwB,GAAG,SAAS,CAAC;AAElD;;;;;;;;;GASG;AACH,MAAM,UAAU,gCAAgC,CAAC,KAAK;IACrD,uBAAuB,GAAG,KAAK,CAAC;AACjC,CAAC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,CAAC;AAErD,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC;AAElD,MAAM,CAAC,MAAM,wCAAwC,GAAG,KAAK,CAAC;AAE9D,MAAM,CAAC,MAAM,2CAA2C,GAAG,KAAK,CAAC;AAEjE,MAAM,CAAC,MAAM,mCAAmC,GAAG,KAAK,CAAC;AAEzD,MAAM,CAAC,MAAM,sCAAsC,GAAG,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-server-file.d.ts","sourceRoot":"","sources":["../../../src/compiler/server/create-server-file.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-server-file.d.ts","sourceRoot":"","sources":["../../../src/compiler/server/create-server-file.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACtC,eAAe,EAAE,0BAA0B,EAAE,CAAC;IAC9C,eAAe,EAAE;QAChB,qCAAqC,EAAE,WAAW,CACjD,eAAe,CAAC,uCAAuC,CAAC,CACxD,CAAC;QACF,wBAAwB,EAAE,WAAW,CACpC,eAAe,CAAC,0BAA0B,CAAC,CAC3C,CAAC;KACF,CAAC;CACF,GAAG,MAAM,CAiDT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-server-file.js","sourceRoot":"","sources":["../../../src/compiler/server/create-server-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-server-file.js","sourceRoot":"","sources":["../../../src/compiler/server/create-server-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAUhC;IACA,IAAI,IAAI,GAAG;;;EAGV,UAAU,CAAC,iBAAiB,CAAC;CAC9B,CAAC;IAED,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;IAC1D,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC1D,IAAI,WAAW,KAAK,CAAC,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACd,qEAAqE,CACrE,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG,GAAG,MAAM,IAAI,CAAC;IAClC,MAAM,sBAAsB,GAAG,IAAI,CAAC,eAAe,CAAC,wBAAwB;QAC3E,CAAC,CAAC;YACA,GAAG,MAAM,yCAAyC;YAClD,GAAG,WAAW,0EAA0E;YACxF,GAAG,MAAM,GAAG;SACZ;QACF,CAAC,CAAC;YACA,GAAG,MAAM,8EAA8E;YACvF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AC,IAAI,MAAM,CAAC,OAAO,CACrD,cAAc,CAAC,QAAQ,CACvB,EAAE,CAAC;YACH,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,eAAe,CAAC,IAAI;iBAC7C,OAAO,CAAC,gBAAgB,YAAY,KAAK,EAAE,EAAE,CAAC;iBAC9C,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACrB,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,UAAU,CAAC,IAAY;IAC/B,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;IACtE,oDAAoD;IACpD,MAAM,WAAW,GAAG,8CAA8C,CAAC;IACnE,MAAM,cAAc,GAAG,8BAA8B,CAAC;IACtD,MAAM,mBAAmB,GAAG,iCAAiC,CAAC;IAC9D,OAAO,IAAI;SACT,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;SACxB,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SAC3B,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;SAChC,IAAI,EAAE,CAAC;AACV,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Server middleware that handles locale-based routing and request processing.
|
|
3
3
|
*
|
|
4
|
+
* Configure `disableAsyncLocalStorage` when generating Paraglide with
|
|
5
|
+
* `paraglideVitePlugin()` or `compile()`, not when calling
|
|
6
|
+
* `paraglideMiddleware()`. Keep AsyncLocalStorage enabled by default and
|
|
7
|
+
* only disable it for runtimes that lack `AsyncLocalStorage` support and
|
|
8
|
+
* guarantee request isolation.
|
|
9
|
+
*
|
|
4
10
|
* This middleware performs several key functions:
|
|
5
11
|
*
|
|
6
12
|
* 1. Determines the locale for the incoming request using configured strategies
|
|
@@ -50,23 +56,6 @@
|
|
|
50
56
|
*
|
|
51
57
|
* @example
|
|
52
58
|
* ```typescript
|
|
53
|
-
* // Usage in serverless environments like Cloudflare Workers
|
|
54
|
-
* // ⚠️ WARNING: This should ONLY be used in serverless environments like Cloudflare Workers.
|
|
55
|
-
* // Disabling AsyncLocalStorage in traditional server environments risks cross-request pollution where state from
|
|
56
|
-
* // one request could leak into another concurrent request.
|
|
57
|
-
* export default {
|
|
58
|
-
* fetch: async (request) => {
|
|
59
|
-
* return paraglideMiddleware(
|
|
60
|
-
* request,
|
|
61
|
-
* ({ request, locale }) => handleRequest(request, locale),
|
|
62
|
-
* { disableAsyncLocalStorage: true }
|
|
63
|
-
* );
|
|
64
|
-
* }
|
|
65
|
-
* };
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```typescript
|
|
70
59
|
* // Usage with frameworks that handle URL localization/delocalization themselves
|
|
71
60
|
* //
|
|
72
61
|
* // Some frameworks like TanStack Router handle URL localization and delocalization
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/compiler/server/middleware.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/compiler/server/middleware.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AACH,oCAjEa,CAAC,WAEH,OAAO,WACP,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,cAAc,EAAE,MAAM,CAAA;CAAE,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,cAKrF;IAAE,UAAU,EAAC,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAA;CAAE,GACzC,OAAO,CAAC,QAAQ,CAAC,CAqK7B"}
|
|
@@ -2,6 +2,12 @@ import * as runtime from "./runtime.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Server middleware that handles locale-based routing and request processing.
|
|
4
4
|
*
|
|
5
|
+
* Configure `disableAsyncLocalStorage` when generating Paraglide with
|
|
6
|
+
* `paraglideVitePlugin()` or `compile()`, not when calling
|
|
7
|
+
* `paraglideMiddleware()`. Keep AsyncLocalStorage enabled by default and
|
|
8
|
+
* only disable it for runtimes that lack `AsyncLocalStorage` support and
|
|
9
|
+
* guarantee request isolation.
|
|
10
|
+
*
|
|
5
11
|
* This middleware performs several key functions:
|
|
6
12
|
*
|
|
7
13
|
* 1. Determines the locale for the incoming request using configured strategies
|
|
@@ -51,23 +57,6 @@ import * as runtime from "./runtime.js";
|
|
|
51
57
|
*
|
|
52
58
|
* @example
|
|
53
59
|
* ```typescript
|
|
54
|
-
* // Usage in serverless environments like Cloudflare Workers
|
|
55
|
-
* // ⚠️ WARNING: This should ONLY be used in serverless environments like Cloudflare Workers.
|
|
56
|
-
* // Disabling AsyncLocalStorage in traditional server environments risks cross-request pollution where state from
|
|
57
|
-
* // one request could leak into another concurrent request.
|
|
58
|
-
* export default {
|
|
59
|
-
* fetch: async (request) => {
|
|
60
|
-
* return paraglideMiddleware(
|
|
61
|
-
* request,
|
|
62
|
-
* ({ request, locale }) => handleRequest(request, locale),
|
|
63
|
-
* { disableAsyncLocalStorage: true }
|
|
64
|
-
* );
|
|
65
|
-
* }
|
|
66
|
-
* };
|
|
67
|
-
* ```
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
60
|
* // Usage with frameworks that handle URL localization/delocalization themselves
|
|
72
61
|
* //
|
|
73
62
|
* // Some frameworks like TanStack Router handle URL localization and delocalization
|
|
@@ -162,7 +151,9 @@ export async function paraglideMiddleware(request, resolve, callbacks) {
|
|
|
162
151
|
/** @type {[string, import("./runtime.js").Locale]} */ (messageCall.split(":"));
|
|
163
152
|
messages.push(`${id}: ${compiledBundles[id]?.[locale]}`);
|
|
164
153
|
}
|
|
165
|
-
|
|
154
|
+
// Prevent translated content from terminating the inline script tag.
|
|
155
|
+
const escapedMessages = messages.join(",").replace(/<\/(script)/gi, "<\\/$1");
|
|
156
|
+
const script = `<script>globalThis.__paraglide = globalThis.__paraglide ?? {}; globalThis.__paraglide.ssr = { ${escapedMessages} }</script>`;
|
|
166
157
|
// Insert the script before the closing head tag
|
|
167
158
|
const newBody = body.replace("</head>", `${script}</head>`);
|
|
168
159
|
// Create a new response with the modified body
|
|
@@ -207,8 +198,8 @@ function cloneRequestWithFallback(request) {
|
|
|
207
198
|
* native AsyncLocalStorage is not available or disabled.
|
|
208
199
|
*
|
|
209
200
|
* This mock implementation mimics the behavior of the native AsyncLocalStorage
|
|
210
|
-
* but doesn't require the async_hooks module. It's
|
|
211
|
-
*
|
|
201
|
+
* but doesn't require the async_hooks module. It's used as a fallback when
|
|
202
|
+
* the runtime does not expose AsyncLocalStorage or when it has been disabled.
|
|
212
203
|
*
|
|
213
204
|
* @returns {import("./runtime.js").ParaglideAsyncLocalStorage}
|
|
214
205
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/compiler/server/middleware.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/compiler/server/middleware.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS;IACpE,uBAAuB;IAEvB,IAAI,OAAO,CAAC,yBAAyB,CAAC,OAAO,CAAC,GAAG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AC;AAED;;;;;;;;;GASG;AACH,SAAS,2BAA2B;IACnC,kBAAkB;IAClB,IAAI,YAAY,GAAG,SAAS,CAAC;IAC7B,OAAO;QACN,QAAQ;YACP,OAAO,YAAY,CAAC;QACrB,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ;YACxB,YAAY,GAAG,KAAK,CAAC;YACrB,IAAI,CAAC;gBACJ,OAAO,MAAM,QAAQ,EAAE,CAAC;YACzB,CAAC;oBAAS,CAAC;gBACV,YAAY,GAAG,SAAS,CAAC;YAC1B,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC;AAED,oEAAoE;AACpE,KAAK,2BAA2B,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,EAAE,CAAC"}
|
package/dist/compiler/types.d.ts
CHANGED
|
@@ -4,81 +4,5 @@ export type Compiled<Node> = {
|
|
|
4
4
|
/** The code generated to implement the AST node */
|
|
5
5
|
code: string;
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
* A branded type representing a localized string.
|
|
9
|
-
* Provides compile-time safety to distinguish translated from untranslated strings.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import { m } from './paraglide/messages.js'
|
|
14
|
-
* import type { LocalizedString } from '@inlang/paraglide-js'
|
|
15
|
-
*
|
|
16
|
-
* const greeting: LocalizedString = m.hello() // ✓ Type-safe
|
|
17
|
-
* const raw: LocalizedString = "Hello" // ✗ Type error
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export type LocalizedString = string & {
|
|
21
|
-
readonly __brand: "LocalizedString";
|
|
22
|
-
};
|
|
23
|
-
export type MessageMarkupOption = {
|
|
24
|
-
name: string;
|
|
25
|
-
value: unknown;
|
|
26
|
-
};
|
|
27
|
-
export type MessageMarkupAttribute = {
|
|
28
|
-
name: string;
|
|
29
|
-
value: string | true;
|
|
30
|
-
};
|
|
31
|
-
export type MessageMarkupOptions = Record<string, unknown>;
|
|
32
|
-
export type MessageMarkupAttributes = Record<string, string | true>;
|
|
33
|
-
export type MessageMarkupTag = {
|
|
34
|
-
options: MessageMarkupOptions;
|
|
35
|
-
attributes: MessageMarkupAttributes;
|
|
36
|
-
children: boolean;
|
|
37
|
-
};
|
|
38
|
-
export type MessageMarkupSchema = Record<string, MessageMarkupTag>;
|
|
39
|
-
export type MessageMetadata<Inputs, Options, Markup extends MessageMarkupSchema = MessageMarkupSchema> = {
|
|
40
|
-
readonly __paraglide?: {
|
|
41
|
-
inputs: Inputs;
|
|
42
|
-
options: Options;
|
|
43
|
-
markup: Markup;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
export type MessagePart = {
|
|
47
|
-
type: "text";
|
|
48
|
-
value: string;
|
|
49
|
-
} | {
|
|
50
|
-
type: "markup-start";
|
|
51
|
-
name: string;
|
|
52
|
-
options: MessageMarkupOptions;
|
|
53
|
-
attributes: MessageMarkupAttributes;
|
|
54
|
-
} | {
|
|
55
|
-
type: "markup-end";
|
|
56
|
-
name: string;
|
|
57
|
-
options: MessageMarkupOptions;
|
|
58
|
-
attributes: MessageMarkupAttributes;
|
|
59
|
-
} | {
|
|
60
|
-
type: "markup-standalone";
|
|
61
|
-
name: string;
|
|
62
|
-
options: MessageMarkupOptions;
|
|
63
|
-
attributes: MessageMarkupAttributes;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* A message function is a message for a specific locale.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* m.hello({ name: 'world' })
|
|
70
|
-
*/
|
|
71
|
-
export type MessageFunction = (inputs?: Record<string, never>) => LocalizedString;
|
|
72
|
-
/**
|
|
73
|
-
* A message bundle function that selects the message to be returned.
|
|
74
|
-
*
|
|
75
|
-
* Uses `getLocale()` under the hood to determine the locale with an option.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* import { m } from './messages.js'
|
|
79
|
-
* m.hello({ name: 'world', { locale: "en" } })
|
|
80
|
-
*/
|
|
81
|
-
export type MessageBundleFunction<T extends string> = (params: Record<string, never>, options: {
|
|
82
|
-
locale: T;
|
|
83
|
-
}) => LocalizedString;
|
|
7
|
+
export type { LocalizedString, MessageMarkupOption, MessageMarkupAttribute, MessageMarkupOptions, MessageMarkupAttributes, MessageMarkupTag, MessageMarkupSchema, MessageMetadata, MessagePart, MessageFunction, MessageBundleFunction, } from "./runtime/type-definitions.js";
|
|
84
8
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/compiler/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,CAAC,IAAI,IAAI;IAC5B,4BAA4B;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/compiler/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,CAAC,IAAI,IAAI;IAC5B,4BAA4B;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,YAAY,EACX,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,eAAe,EACf,qBAAqB,GACrB,MAAM,+BAA+B,CAAC"}
|
|
@@ -14,7 +14,6 @@ const packageJson = JSON.parse(await fs.readFile(path.resolve(dirname, "../../..
|
|
|
14
14
|
await fs.writeFile(dirname + "/index.ts", `
|
|
15
15
|
export const ENV_VARIABLES = {
|
|
16
16
|
PARJS_APP_ID: "library.inlang.paraglideJs",
|
|
17
|
-
PARJS_POSTHOG_TOKEN: ${ifDefined(process.env.PUBLIC_POSTHOG_TOKEN)},
|
|
18
17
|
PARJS_PACKAGE_VERSION: ${ifDefined(packageJson.version)},
|
|
19
18
|
}
|
|
20
19
|
`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-index-file.js","sourceRoot":"","sources":["../../../src/services/env-variables/create-index-file.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC7B,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,uBAAuB,CAAC,EAAE,OAAO,CAAC,CAC1E,CAAC;AAEF,MAAM,EAAE,CAAC,SAAS,CACjB,OAAO,GAAG,WAAW,EACrB;;;
|
|
1
|
+
{"version":3,"file":"create-index-file.js","sourceRoot":"","sources":["../../../src/services/env-variables/create-index-file.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC7B,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,uBAAuB,CAAC,EAAE,OAAO,CAAC,CAC1E,CAAC;AAEF,MAAM,EAAE,CAAC,SAAS,CACjB,OAAO,GAAG,WAAW,EACrB;;;0BAGyB,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC;;CAEvD,CACA,CAAC;AAEF,qDAAqD;AAErD;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAAK;IACvB,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AACzC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/env-variables/index.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/env-variables/index.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa;;;CAGzB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/env-variables/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,YAAY,EAAE,4BAA4B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/env-variables/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,YAAY,EAAE,4BAA4B;IAC3C,qBAAqB,EAAE,QAAQ;CAC/B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inlang/paraglide-js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.14.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"typedoc": "0.28.12",
|
|
49
49
|
"typedoc-plugin-markdown": "4.7.0",
|
|
50
50
|
"typedoc-plugin-missing-exports": "4.0.0",
|
|
51
|
-
"typescript": "5.
|
|
51
|
+
"typescript": "5.9.2",
|
|
52
52
|
"vitest": "3.1.4"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ProjectSettings } from "@inlang/sdk";
|
|
2
|
-
/**
|
|
3
|
-
* Capture an event.
|
|
4
|
-
*
|
|
5
|
-
* - manually calling the PostHog API because the SDKs were not platform angostic (and generally bloated)
|
|
6
|
-
*/
|
|
7
|
-
export declare const capture: (event: "PARAGLIDE-JS compile executed", args: {
|
|
8
|
-
projectId: string;
|
|
9
|
-
/**
|
|
10
|
-
* Please use snake_case for property names.
|
|
11
|
-
*/
|
|
12
|
-
properties: Record<string, any>;
|
|
13
|
-
settings: Pick<ProjectSettings, "telemetry">;
|
|
14
|
-
}) => Promise<void>;
|
|
15
|
-
//# sourceMappingURL=capture.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../../src/services/telemetry/capture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GACnB,OAAO,+BAA+B,EACtC,MAAM;IACL,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;CAC7C,kBA8BD,CAAC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { ENV_VARIABLES } from "../env-variables/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Capture an event.
|
|
4
|
-
*
|
|
5
|
-
* - manually calling the PostHog API because the SDKs were not platform angostic (and generally bloated)
|
|
6
|
-
*/
|
|
7
|
-
export const capture = async (event, args) => {
|
|
8
|
-
if (args.settings.telemetry === "off") {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
else if (ENV_VARIABLES.PARJS_POSTHOG_TOKEN === undefined) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
try {
|
|
15
|
-
await fetch("https://eu.posthog.com/capture/", {
|
|
16
|
-
method: "POST",
|
|
17
|
-
body: JSON.stringify({
|
|
18
|
-
api_key: ENV_VARIABLES.PARJS_POSTHOG_TOKEN,
|
|
19
|
-
event,
|
|
20
|
-
// id is "unknown" because no user information is available
|
|
21
|
-
distinct_id: "unknown",
|
|
22
|
-
properties: {
|
|
23
|
-
$groups: { project: args.projectId },
|
|
24
|
-
...args.properties,
|
|
25
|
-
},
|
|
26
|
-
}),
|
|
27
|
-
});
|
|
28
|
-
await identifyProject({
|
|
29
|
-
projectId: args.projectId,
|
|
30
|
-
// using the id for now as a name but can be changed in the future
|
|
31
|
-
// we need at least one property to make a project visible in the dashboar
|
|
32
|
-
properties: { name: args.projectId },
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
// captureError(e);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Identifying a project is needed.
|
|
41
|
-
*
|
|
42
|
-
* Otherwise, the project will not be visible in the PostHog dashboard.
|
|
43
|
-
*/
|
|
44
|
-
const identifyProject = async (args) => {
|
|
45
|
-
// do not send events if the token is not set
|
|
46
|
-
// (assuming this eases testing)
|
|
47
|
-
if (ENV_VARIABLES.PARJS_POSTHOG_TOKEN === undefined) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
await fetch("https://eu.posthog.com/capture/", {
|
|
52
|
-
method: "POST",
|
|
53
|
-
body: JSON.stringify({
|
|
54
|
-
api_key: ENV_VARIABLES.PARJS_POSTHOG_TOKEN,
|
|
55
|
-
event: "$groupidentify",
|
|
56
|
-
// id is "unknown" because no user information is available
|
|
57
|
-
distinct_id: "unknown",
|
|
58
|
-
properties: {
|
|
59
|
-
$group_type: "project",
|
|
60
|
-
$group_key: args.projectId,
|
|
61
|
-
$group_set: {
|
|
62
|
-
...args.properties,
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
//
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
//# sourceMappingURL=capture.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../../../src/services/telemetry/capture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAC3B,KAAsC,EACtC,IAOC,EACA,EAAE;IACH,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,KAAK,KAAK,EAAE,CAAC;QACvC,OAAO;IACR,CAAC;SAAM,IAAI,aAAa,CAAC,mBAAmB,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO;IACR,CAAC;IACD,IAAI,CAAC;QACJ,MAAM,KAAK,CAAC,iCAAiC,EAAE;YAC9C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACpB,OAAO,EAAE,aAAa,CAAC,mBAAmB;gBAC1C,KAAK;gBACL,2DAA2D;gBAC3D,WAAW,EAAE,SAAS;gBACtB,UAAU,EAAE;oBACX,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE;oBACpC,GAAG,IAAI,CAAC,UAAU;iBAClB;aACD,CAAC;SACF,CAAC,CAAC;QACH,MAAM,eAAe,CAAC;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,kEAAkE;YAClE,0EAA0E;YAC1E,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE;SACpC,CAAC,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACR,mBAAmB;IACpB,CAAC;AACF,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,eAAe,GAAG,KAAK,EAAE,IAM9B,EAAE,EAAE;IACJ,6CAA6C;IAC7C,gCAAgC;IAChC,IAAI,aAAa,CAAC,mBAAmB,KAAK,SAAS,EAAE,CAAC;QACrD,OAAO;IACR,CAAC;IACD,IAAI,CAAC;QACJ,MAAM,KAAK,CAAC,iCAAiC,EAAE;YAC9C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACpB,OAAO,EAAE,aAAa,CAAC,mBAAmB;gBAC1C,KAAK,EAAE,gBAAgB;gBACvB,2DAA2D;gBAC3D,WAAW,EAAE,SAAS;gBACtB,UAAU,EAAE;oBACX,WAAW,EAAE,SAAS;oBACtB,UAAU,EAAE,IAAI,CAAC,SAAS;oBAC1B,UAAU,EAAE;wBACX,GAAG,IAAI,CAAC,UAAU;qBAClB;iBACD;aACD,CAAC;SACF,CAAC,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACR,EAAE;IACH,CAAC;AACF,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capture.test.d.ts","sourceRoot":"","sources":["../../../src/services/telemetry/capture.test.ts"],"names":[],"mappings":""}
|