@inlang/paraglide-js 2.13.1 → 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.
Files changed (104) hide show
  1. package/dist/compiler/compile-bundle.js +2 -2
  2. package/dist/compiler/compile-bundle.test.js +1 -1
  3. package/dist/compiler/compile-local-variable.d.ts.map +1 -1
  4. package/dist/compiler/compile-local-variable.js +48 -4
  5. package/dist/compiler/compile-local-variable.js.map +1 -1
  6. package/dist/compiler/compile-local-variable.test.js +76 -0
  7. package/dist/compiler/compile-local-variable.test.js.map +1 -1
  8. package/dist/compiler/compile-project.test.js +83 -0
  9. package/dist/compiler/compile-project.test.js.map +1 -1
  10. package/dist/compiler/compile.test.js +31 -0
  11. package/dist/compiler/compile.test.js.map +1 -1
  12. package/dist/compiler/compiler-options.d.ts +8 -6
  13. package/dist/compiler/compiler-options.d.ts.map +1 -1
  14. package/dist/compiler/runtime/assert-is-locale.d.ts +2 -2
  15. package/dist/compiler/runtime/assert-is-locale.d.ts.map +1 -1
  16. package/dist/compiler/runtime/assert-is-locale.js +1 -1
  17. package/dist/compiler/runtime/assert-is-locale.test.js +1 -2
  18. package/dist/compiler/runtime/assert-is-locale.test.js.map +1 -1
  19. package/dist/compiler/runtime/create-runtime.d.ts.map +1 -1
  20. package/dist/compiler/runtime/create-runtime.js +8 -122
  21. package/dist/compiler/runtime/create-runtime.js.map +1 -1
  22. package/dist/compiler/runtime/extract-locale-from-cookie.d.ts +2 -2
  23. package/dist/compiler/runtime/extract-locale-from-cookie.js +1 -1
  24. package/dist/compiler/runtime/extract-locale-from-header.d.ts +13 -1
  25. package/dist/compiler/runtime/extract-locale-from-header.d.ts.map +1 -1
  26. package/dist/compiler/runtime/extract-locale-from-header.js +1 -2
  27. package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -1
  28. package/dist/compiler/runtime/extract-locale-from-navigator.d.ts +11 -0
  29. package/dist/compiler/runtime/extract-locale-from-navigator.d.ts.map +1 -1
  30. package/dist/compiler/runtime/extract-locale-from-navigator.js +1 -2
  31. package/dist/compiler/runtime/extract-locale-from-navigator.js.map +1 -1
  32. package/dist/compiler/runtime/extract-locale-from-request-async.d.ts +1 -30
  33. package/dist/compiler/runtime/extract-locale-from-request-async.d.ts.map +1 -1
  34. package/dist/compiler/runtime/extract-locale-from-request-async.js +2 -1
  35. package/dist/compiler/runtime/extract-locale-from-request-async.js.map +1 -1
  36. package/dist/compiler/runtime/extract-locale-from-request.d.ts +1 -19
  37. package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -1
  38. package/dist/compiler/runtime/extract-locale-from-request.js +2 -1
  39. package/dist/compiler/runtime/extract-locale-from-request.js.map +1 -1
  40. package/dist/compiler/runtime/extract-locale-from-url.js +2 -2
  41. package/dist/compiler/runtime/generate-static-localized-urls.d.ts.map +1 -1
  42. package/dist/compiler/runtime/generate-static-localized-urls.js +1 -0
  43. package/dist/compiler/runtime/generate-static-localized-urls.js.map +1 -1
  44. package/dist/compiler/runtime/get-locale.d.ts +2 -35
  45. package/dist/compiler/runtime/get-locale.d.ts.map +1 -1
  46. package/dist/compiler/runtime/get-locale.js +3 -3
  47. package/dist/compiler/runtime/get-url-origin.d.ts +1 -9
  48. package/dist/compiler/runtime/get-url-origin.d.ts.map +1 -1
  49. package/dist/compiler/runtime/get-url-origin.js +1 -1
  50. package/dist/compiler/runtime/is-locale.d.ts +3 -2
  51. package/dist/compiler/runtime/is-locale.d.ts.map +1 -1
  52. package/dist/compiler/runtime/is-locale.js +2 -1
  53. package/dist/compiler/runtime/is-locale.js.map +1 -1
  54. package/dist/compiler/runtime/localize-url.d.ts +7 -0
  55. package/dist/compiler/runtime/localize-url.d.ts.map +1 -1
  56. package/dist/compiler/runtime/localize-url.js +2 -1
  57. package/dist/compiler/runtime/localize-url.js.map +1 -1
  58. package/dist/compiler/runtime/set-locale.d.ts.map +1 -1
  59. package/dist/compiler/runtime/set-locale.js +1 -2
  60. package/dist/compiler/runtime/set-locale.js.map +1 -1
  61. package/dist/compiler/runtime/should-redirect.d.ts +2 -2
  62. package/dist/compiler/runtime/should-redirect.d.ts.map +1 -1
  63. package/dist/compiler/runtime/strategy.d.ts +6 -6
  64. package/dist/compiler/runtime/strategy.d.ts.map +1 -1
  65. package/dist/compiler/runtime/strategy.js +3 -3
  66. package/dist/compiler/runtime/type-definitions.d.ts +97 -0
  67. package/dist/compiler/runtime/type-definitions.d.ts.map +1 -0
  68. package/dist/compiler/runtime/type-definitions.js +150 -0
  69. package/dist/compiler/runtime/type-definitions.js.map +1 -0
  70. package/dist/compiler/runtime/variables.d.ts +2 -2
  71. package/dist/compiler/runtime/variables.d.ts.map +1 -1
  72. package/dist/compiler/runtime/variables.js +2 -2
  73. package/dist/compiler/runtime/variables.js.map +1 -1
  74. package/dist/compiler/server/create-server-file.d.ts.map +1 -1
  75. package/dist/compiler/server/create-server-file.js.map +1 -1
  76. package/dist/compiler/server/middleware.d.ts +6 -17
  77. package/dist/compiler/server/middleware.d.ts.map +1 -1
  78. package/dist/compiler/server/middleware.js +11 -20
  79. package/dist/compiler/server/middleware.js.map +1 -1
  80. package/dist/compiler/types.d.ts +1 -77
  81. package/dist/compiler/types.d.ts.map +1 -1
  82. package/dist/services/env-variables/create-index-file.js +0 -1
  83. package/dist/services/env-variables/create-index-file.js.map +1 -1
  84. package/dist/services/env-variables/index.d.ts +0 -1
  85. package/dist/services/env-variables/index.d.ts.map +1 -1
  86. package/dist/services/env-variables/index.js +1 -2
  87. package/dist/services/env-variables/index.js.map +1 -1
  88. package/package.json +2 -2
  89. package/dist/services/telemetry/capture.d.ts +0 -15
  90. package/dist/services/telemetry/capture.d.ts.map +0 -1
  91. package/dist/services/telemetry/capture.js +0 -72
  92. package/dist/services/telemetry/capture.js.map +0 -1
  93. package/dist/services/telemetry/capture.test.d.ts +0 -2
  94. package/dist/services/telemetry/capture.test.d.ts.map +0 -1
  95. package/dist/services/telemetry/capture.test.js +0 -41
  96. package/dist/services/telemetry/capture.test.js.map +0 -1
  97. package/dist/services/telemetry/stack-detection.d.ts +0 -40
  98. package/dist/services/telemetry/stack-detection.d.ts.map +0 -1
  99. package/dist/services/telemetry/stack-detection.js +0 -78
  100. package/dist/services/telemetry/stack-detection.js.map +0 -1
  101. package/dist/services/telemetry/stack-detection.test.d.ts +0 -2
  102. package/dist/services/telemetry/stack-detection.test.d.ts.map +0 -1
  103. package/dist/services/telemetry/stack-detection.test.js +0 -37
  104. package/dist/services/telemetry/stack-detection.test.js.map +0 -1
@@ -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
- const script = `<script>globalThis.__paraglide_ssr = { ${messages.join(",")} }</script>`;
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 designed to be used in
211
- * environments like Cloudflare Workers where AsyncLocalStorage is not available.
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS;IACpE,uBAAuB;IAEvB,IAAI,OAAO,CAAC,yBAAyB,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACpD,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;QAClC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;QAC3C,MAAM,U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UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,+CAA+C;QAEpF,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE;YAC5B,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,OAAO,EAAE,UAAU;SACnB,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,wBAAwB,CAAC,OAAO;IACxC,IAAI,CAAC;QACJ,mFAAmF;QACnF,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACR,IAAI,CAAC;YACJ,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,OAAO,CAAC;QAChB,CAAC;IACF,CAAC;AACF,CAAC;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"}
@@ -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;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAE/E,MAAM,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3D,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AAEpE,MAAM,MAAM,gBAAgB,GAAG;IAC9B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,UAAU,EAAE,uBAAuB,CAAC;IACpC,QAAQ,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAEnE,MAAM,MAAM,eAAe,CAC1B,MAAM,EACN,OAAO,EACP,MAAM,SAAS,mBAAmB,GAA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AY,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;;;yBAGwB,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;0BAC1C,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
+ {"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,6 +1,5 @@
1
1
  export declare const ENV_VARIABLES: {
2
2
  PARJS_APP_ID: string;
3
- PARJS_POSTHOG_TOKEN: undefined;
4
3
  PARJS_PACKAGE_VERSION: string;
5
4
  };
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/env-variables/index.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa;;;;CAIzB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/env-variables/index.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa;;;CAGzB,CAAA"}
@@ -1,6 +1,5 @@
1
1
  export const ENV_VARIABLES = {
2
2
  PARJS_APP_ID: "library.inlang.paraglideJs",
3
- PARJS_POSTHOG_TOKEN: undefined,
4
- PARJS_PACKAGE_VERSION: "2.13.1",
3
+ PARJS_PACKAGE_VERSION: "2.14.0",
5
4
  };
6
5
  //# sourceMappingURL=index.js.map
@@ -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;IAC1C,mBAAmB,EAAE,SAAS;IAC/B,qBAAqB,EAAE,QAAQ;CAC/B,CAAA"}
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.13.1",
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.8.3",
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,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=capture.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"capture.test.d.ts","sourceRoot":"","sources":["../../../src/services/telemetry/capture.test.ts"],"names":[],"mappings":""}
@@ -1,41 +0,0 @@
1
- import { expect, test, vi } from "vitest";
2
- import { capture } from "./capture.js";
3
- test("it should not capture if telemetry is off", async () => {
4
- // @ts-expect-error - global.fetch is not defined
5
- global.fetch = vi.fn(() => Promise.resolve());
6
- vi.mock("../env-variables/index.js", async () => {
7
- return {
8
- ENV_VARIABLES: {
9
- PARJS_POSTHOG_TOKEN: "mock-defined",
10
- },
11
- };
12
- });
13
- await capture("PARAGLIDE-JS compile executed", {
14
- projectId: "test",
15
- settings: {
16
- telemetry: "off",
17
- },
18
- properties: {},
19
- });
20
- expect(global.fetch).not.toHaveBeenCalled();
21
- });
22
- test("it should not capture if telemetry is NOT off", async () => {
23
- // @ts-expect-error - global.fetch is not defined
24
- global.fetch = vi.fn(() => Promise.resolve());
25
- vi.mock("../env-variables/index.js", async () => {
26
- return {
27
- ENV_VARIABLES: {
28
- PARJS_POSTHOG_TOKEN: "mock-defined",
29
- },
30
- };
31
- });
32
- await capture("PARAGLIDE-JS compile executed", {
33
- projectId: "test",
34
- settings: {
35
- telemetry: undefined,
36
- },
37
- properties: {},
38
- });
39
- expect(global.fetch).toHaveBeenCalled();
40
- });
41
- //# sourceMappingURL=capture.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"capture.test.js","sourceRoot":"","sources":["../../../src/services/telemetry/capture.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,IAAI,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;IAC5D,iDAAiD;IACjD,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAE9C,EAAE,CAAC,IAAI,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QAC/C,OAAO;YACN,aAAa,EAAE;gBACd,mBAAmB,EAAE,cAAc;aACnC;SACD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,+BAA+B,EAAE;QAC9C,SAAS,EAAE,MAAM;QACjB,QAAQ,EAAE;YACT,SAAS,EAAE,KAAK;SAChB;QACD,UAAU,EAAE,EAAE;KACd,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;AAC7C,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;IAChE,iDAAiD;IACjD,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAE9C,EAAE,CAAC,IAAI,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QAC/C,OAAO;YACN,aAAa,EAAE;gBACd,mBAAmB,EAAE,cAAc;aACnC;SACD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,+BAA+B,EAAE;QAC9C,SAAS,EAAE,MAAM;QACjB,QAAQ,EAAE;YACT,SAAS,EAAE,SAAS;SACpB;QACD,UAAU,EAAE,EAAE;KACd,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACzC,CAAC,CAAC,CAAC"}
@@ -1,40 +0,0 @@
1
- /**
2
- * A list of packages that we consider relevant for stack detection.
3
- *
4
- * We (Loris & Nils) decided against using _all_ packages because that would be too much unnecessary data
5
- * that would slow down queries.
6
- */
7
- declare const RelevantPackages: readonly ["next", "solid", "solid-start", "svelte", "@sveltejs/kit", "vue", "nuxt", "react", "react-native", "remix", "astro", "react", "react-router", "vite", "vike", "webpack", "rollup", "esbuild", "qwick", "parcel", "lit", "@angular/core"];
8
- type RelevantPackage = (typeof RelevantPackages)[number];
9
- export type StackInfo = {
10
- /**
11
- * A map of relevant packages to their versions.
12
- */
13
- packages: {
14
- [packageName in RelevantPackage]?: string;
15
- };
16
- };
17
- /**
18
- * Returns information about the tech-stack used based on the package.json.
19
- * It will return an object with a map of relevant packages and their versions
20
- * as the `packages` property.
21
- *
22
- * If no interestring packages are found, the `packages` property will be an empty object.
23
- * If an error occurs, the `packages` property will be an empty object.
24
- *
25
- * @example
26
- *
27
- * ```ts
28
- * {
29
- * "packages": {
30
- * "next": "^14.0.0",
31
- * "react": "^17.0.0"
32
- * }
33
- * }
34
- * ```
35
- *
36
- * @param packageJson The JSON parsed package.json file.
37
- */
38
- export declare function getStackInfo(packageJson: unknown): StackInfo;
39
- export {};
40
- //# sourceMappingURL=stack-detection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stack-detection.d.ts","sourceRoot":"","sources":["../../../src/services/telemetry/stack-detection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,QAAA,MAAM,gBAAgB,oPAuBZ,CAAC;AAEX,KAAK,eAAe,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,MAAM,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,QAAQ,EAAE;SACR,WAAW,IAAI,eAAe,CAAC,CAAC,EAAE,MAAM;KACzC,CAAC;CACF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,OAAO,GAAG,SAAS,CA2B5D"}
@@ -1,78 +0,0 @@
1
- /**
2
- * A list of packages that we consider relevant for stack detection.
3
- *
4
- * We (Loris & Nils) decided against using _all_ packages because that would be too much unnecessary data
5
- * that would slow down queries.
6
- */
7
- const RelevantPackages = [
8
- "next",
9
- "solid",
10
- "solid-start",
11
- "svelte",
12
- "@sveltejs/kit",
13
- "vue",
14
- "nuxt",
15
- "react",
16
- "react-native",
17
- "remix",
18
- "astro",
19
- "react",
20
- "react-router",
21
- "vite",
22
- "vike",
23
- "webpack",
24
- "rollup",
25
- "esbuild",
26
- "qwick",
27
- "parcel",
28
- "lit",
29
- "@angular/core",
30
- ];
31
- /**
32
- * Returns information about the tech-stack used based on the package.json.
33
- * It will return an object with a map of relevant packages and their versions
34
- * as the `packages` property.
35
- *
36
- * If no interestring packages are found, the `packages` property will be an empty object.
37
- * If an error occurs, the `packages` property will be an empty object.
38
- *
39
- * @example
40
- *
41
- * ```ts
42
- * {
43
- * "packages": {
44
- * "next": "^14.0.0",
45
- * "react": "^17.0.0"
46
- * }
47
- * }
48
- * ```
49
- *
50
- * @param packageJson The JSON parsed package.json file.
51
- */
52
- export function getStackInfo(packageJson) {
53
- const packages = {};
54
- try {
55
- const pkg = packageJson;
56
- const dependencies = pkg?.dependencies ?? {};
57
- const devDependencies = pkg?.devDependencies ?? {};
58
- const peerDependencies = pkg?.peerDependencies ?? {};
59
- const allDependencies = {
60
- ...dependencies,
61
- ...devDependencies,
62
- ...peerDependencies,
63
- };
64
- for (const dependencyName of RelevantPackages) {
65
- if (dependencyName in allDependencies) {
66
- const dependencyVersion = allDependencies[dependencyName];
67
- if (typeof dependencyVersion !== "string")
68
- continue;
69
- packages[dependencyName] = dependencyVersion;
70
- }
71
- }
72
- return { packages };
73
- }
74
- catch {
75
- return { packages };
76
- }
77
- }
78
- //# sourceMappingURL=stack-detection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stack-detection.js","sourceRoot":"","sources":["../../../src/services/telemetry/stack-detection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG;IACxB,MAAM;IACN,OAAO;IACP,aAAa;IACb,QAAQ;IACR,eAAe;IACf,KAAK;IACL,MAAM;IACN,OAAO;IACP,cAAc;IACd,OAAO;IACP,OAAO;IACP,OAAO;IACP,cAAc;IACd,MAAM;IACN,MAAM;IACN,SAAS;IACT,QAAQ;IACR,SAAS;IACT,OAAO;IACP,QAAQ;IACR,KAAK;IACL,eAAe;CACN,CAAC;AAaX;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,YAAY,CAAC,WAAoB;IAChD,MAAM,QAAQ,GAAkD,EAAE,CAAC;IAEnE,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,WAAqC,CAAC;QAClD,MAAM,YAAY,GAAG,GAAG,EAAE,YAAY,IAAI,EAAE,CAAC;QAC7C,MAAM,eAAe,GAAG,GAAG,EAAE,eAAe,IAAI,EAAE,CAAC;QACnD,MAAM,gBAAgB,GAAG,GAAG,EAAE,gBAAgB,IAAI,EAAE,CAAC;QAErD,MAAM,eAAe,GAAG;YACvB,GAAG,YAAY;YACf,GAAG,eAAe;YAClB,GAAG,gBAAgB;SACnB,CAAC;QAEF,KAAK,MAAM,cAAc,IAAI,gBAAgB,EAAE,CAAC;YAC/C,IAAI,cAAc,IAAI,eAAe,EAAE,CAAC;gBACvC,MAAM,iBAAiB,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;gBAC1D,IAAI,OAAO,iBAAiB,KAAK,QAAQ;oBAAE,SAAS;gBACpD,QAAQ,CAAC,cAAc,CAAC,GAAG,iBAAiB,CAAC;YAC9C,CAAC;QACF,CAAC;QAED,OAAO,EAAE,QAAQ,EAAE,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,QAAQ,EAAE,CAAC;IACrB,CAAC;AACF,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=stack-detection.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stack-detection.test.d.ts","sourceRoot":"","sources":["../../../src/services/telemetry/stack-detection.test.ts"],"names":[],"mappings":""}
@@ -1,37 +0,0 @@
1
- import { getStackInfo } from "./stack-detection.js";
2
- import { it as test, expect } from "vitest";
3
- test("detects sveltekit", async () => {
4
- const SvelteKitPackageJson = JSON.parse(`{
5
- "name": "@inlang/paraglide-sveltekit-example",
6
- "version": "0.0.1",
7
- "private": true,
8
- "scripts": {
9
- "_dev": "vite dev",
10
- "build": "vite build",
11
- "test": "vite build",
12
- "preview": "vite preview",
13
- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
14
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
15
- },
16
- "devDependencies": {
17
- "@inlang/paraglide-js": "workspace:*",
18
- "@inlang/paraglide-sveltekit": "workspace:*",
19
- "@sveltejs/adapter-auto": "^3.0.0",
20
- "@sveltejs/adapter-static": "^2.0.3",
21
- "@sveltejs/kit": "^2.4.3",
22
- "@sveltejs/vite-plugin-svelte": "^3.0.0",
23
- "mdsvex": "^0.11.0",
24
- "svelte": "^4.2.7",
25
- "svelte-check": "^3.6.0",
26
- "vite": "^5.0.3"
27
- },
28
- "type": "module"
29
- }`);
30
- const stack = getStackInfo(SvelteKitPackageJson);
31
- expect(Object.keys(stack.packages)).toEqual([
32
- "svelte",
33
- "@sveltejs/kit",
34
- "vite",
35
- ]);
36
- });
37
- //# sourceMappingURL=stack-detection.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stack-detection.test.js","sourceRoot":"","sources":["../../../src/services/telemetry/stack-detection.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE5C,IAAI,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;IACpC,MAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;UAyB/B,CAAC,CAAC;IAEX,MAAM,KAAK,GAAG,YAAY,CAAC,oBAAoB,CAAC,CAAC;IACjD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;QAC3C,QAAQ;QACR,eAAe;QACf,MAAM;KACN,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}