@inlang/paraglide-js 1.2.1 → 1.2.2

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,14 +1,10 @@
1
- <!-- ![Paraglide JS header image](https://cdn.jsdelivr.net/gh/opral/monorepo@latest/inlang/source-code/paraglide/paraglide-js/assets/paraglide-js-header.png) -->
2
-
3
- [<img src="https://cdn.loom.com/sessions/thumbnails/a8365ec4fa2c4f6bbbf4370cf22dd7f6-with-play.gif" width="100%" /> Watch the pre-release demo of Paraglide JS](https://www.youtube.com/watch?v=-YES3CCAG90)
4
-
5
- Attention: The following features are missing and will be added in the upcoming weeks:
1
+ [<img src="https://cdn.loom.com/sessions/thumbnails/a8365ec4fa2c4f6bbbf4370cf22dd7f6-with-play.gif" width="100%" /> Watch the demo of Paraglide JS](https://www.youtube.com/watch?v=-YES3CCAG90)
6
2
 
7
- - [ ] Support for pluralization
3
+ <!-- ![Paraglide JS header image](https://cdn.jsdelivr.net/gh/opral/monorepo@latest/inlang/source-code/paraglide/paraglide-js/assets/paraglide-js-header.png) -->
8
4
 
9
- # The i18n library that you can set up within 3 lines of code
5
+ # Simple, adaptable, and tiny i18n library for JS
10
6
 
11
- Type in the following command into your terminal to get started immediately:
7
+ Get started instantly with the following command:
12
8
 
13
9
  ```bash
14
10
  npx @inlang/paraglide-js@latest init
@@ -18,7 +14,7 @@ npx @inlang/paraglide-js@latest init
18
14
 
19
15
  <doc-features>
20
16
  <doc-feature title="No unused translations" image="https://cdn.jsdelivr.net/gh/opral/monorepo@latest/inlang/source-code/paraglide/paraglide-js/assets/unused-translations.png"></doc-feature>
21
- <doc-feature title="Reduced payload" image="https://cdn.jsdelivr.net/gh/opral/monorepo@latest/inlang/source-code/paraglide/paraglide-js/assets/reduced-payload.png"></doc-feature>
17
+ <doc-feature title="Minimal payload" image="https://cdn.jsdelivr.net/gh/opral/monorepo@latest/inlang/source-code/paraglide/paraglide-js/assets/reduced-payload.png"></doc-feature>
22
18
  <doc-feature title="Typesafety" image="https://cdn.jsdelivr.net/gh/opral/monorepo@latest/inlang/source-code/paraglide/paraglide-js/assets/typesafe.png"></doc-feature>
23
19
  </doc-features>
24
20
 
@@ -29,7 +25,6 @@ npx @inlang/paraglide-js@latest init
29
25
 
30
26
  Treeshaking gives us superpowers. With it, each page of your app only loads the messages that it actually uses. Incremental loading like this would usually take hours of manual tweaking to get right. With Paraglide-JS you get it for free. Say goodbye to huge bundles.
31
27
 
32
-
33
28
  # Getting started
34
29
 
35
30
  ### 1. Initialize paraglide-js
@@ -40,37 +35,28 @@ You can initialize paraglide-js by running the following command in your termina
40
35
  npx @inlang/paraglide-js@latest init
41
36
  ```
42
37
 
43
- ### 2. Select an adapter (if required)
38
+ This will:
39
+
40
+ 1. Install the necessary dependencies
41
+ 2. Call the Paraglide compiler in your `build` script
42
+ 3. Set up any necessary configuration files
44
43
 
45
- Having an adapter is recommended but not required if you want to use paraglide-js with a framework. If you don't use a framework, you can skip this step.
44
+ ### 2. Set up an adapter (optional)
45
+
46
+ Adapters are framework specific integrations for Paraglide. If you are using a framework, using an adapter is recommended (but not required). If you don't use a framework, you can skip this step.
46
47
 
47
48
  <doc-links>
48
- <doc-link title="Adapter for Svelte" icon="simple-icons:svelte" href="https://github.com/opral/monorepo/tree/main/inlang/source-code/paraglide/paraglide-js-adapter-svelte/example" description="Go to GitHub example"></doc-link>
49
- <doc-link title="Adapter for SolidJS" icon="tabler:brand-solidjs" href="https://inlang.com/m/n860p17j/library-inlang-paraglideJsAdapterSolidStart" description="Go to Adapter"></doc-link>
49
+ <doc-link title="Adapter for SvelteKit" icon="simple-icons:svelte" href="https://inlang.com/m/dxnzrydw/library-inlang-paraglideJsAdapterSvelteKit" description="Go to Library"></doc-link>
50
+ <doc-link title="Adapter for SolidJS" icon="tabler:brand-solidjs" href="https://inlang.com/m/n860p17j/library-inlang-paraglideJsAdapterSolidStart" description="Go to Library"></doc-link>
50
51
  <doc-link title="Adapter for NextJS" icon="tabler:brand-nextjs" href="https://github.com/opral/monorepo/tree/main/inlang/source-code/paraglide/paraglide-js-adapter-next" description="Go to GitHub example"></doc-link>
51
52
  <doc-link title="Adapter for Vite" icon="tabler:brand-vite" href="https://github.com/opral/monorepo/tree/main/inlang/source-code/paraglide/paraglide-js-adapter-vite" description="Go to GitHub"></doc-link>
52
53
  </doc-links>
53
54
 
54
55
  #### Alternatively, [you can write your own adapter](#writing-an-adapter)
55
56
 
56
- ### 3. Add the `compile` script to your `package.json`
57
-
58
- > If you are using `@inlang/paraglide-js-adapter-vite`, you can skip this step.
59
-
60
- You can customize the `compile` script to your needs. For example, you can add a `--watch` flag to watch for changes, if you have installed a watcher.
61
-
62
- ```json
63
- {
64
- "scripts": {
65
- "compile": "paraglide-js compile --project ./project.inlang",
66
- "watch": "paraglide-js compile --project ./project.inlang --watch"
67
- }
68
- }
69
- ```
70
-
71
57
  # Usage
72
58
 
73
- Running the `compile` script will generate a `src/paraglide` folder. This folder contains all the code that you need to use paraglide-js.
59
+ Running your `build` script will generate a `src/paraglide` folder. This folder contains all the code that you need to use paraglide-js.
74
60
  Throughout this guide, you will see imports from `./paraglide/*`. These are all to this folder.
75
61
 
76
62
  > Tip: If you are using a bundler, you can set up an alias to `./src/paraglide` to make the imports shorter. We recommend `$paraglide/*`
@@ -83,8 +69,8 @@ The compiled messages are placed in `./paraglide/messages.js`. You can import th
83
69
  // m is a namespace that contains all messages of your project
84
70
  // a bundler like rollup or webpack only bundles
85
71
  // the messages that are used
86
- import * as m from "./paraglide/messages"
87
- import { setLanguageTag } from "./paraglide/runtime"
72
+ import * as m from "./paraglide/messages.js"
73
+ import { setLanguageTag } from "./paraglide/runtime.js"
88
74
 
89
75
  // use a message
90
76
  m.hello() // Hello world!
@@ -101,7 +87,7 @@ m.loginHeader({ name: "Samuel" }) // Hallo Samuel, bitte melde dich an, um fortz
101
87
  If you want to dynamically choose between a set of messages, you can create a record of messages and index into it. Note that this will not be tree-shaken by your bundler.
102
88
 
103
89
  ```js
104
- import * as m from "./paraglide/messages"
90
+ import * as m from "./paraglide/messages.js"
105
91
 
106
92
  const season = {
107
93
  spring: m.spring,
@@ -113,24 +99,25 @@ const season = {
113
99
  const msg = season["spring"]() // Hello spring!
114
100
  ```
115
101
 
116
- Paraglide JS provides five exports in `./paraglide/runtime.js`:
102
+ Paraglide JS provides several exports from `./paraglide/runtime.js`:
117
103
 
118
- | Variable | Description |
119
- | -------------------------- | --------------------------------------------------------------------- |
120
- | `sourceLanguageTag` | The source language tag of the project |
121
- | `availableLanguageTags` | All language tags of the current project |
122
- | `languageTag()` | Returns the language tag of the current user |
123
- | `setLanguageTag()` | Sets the language tag of the current user |
124
- | `onSetLanguageTag()` | Registers a listener that is called whenever the language tag changes |
125
- | `isAvailableLanguageTag()` | Checks if a value is a valid language tag |
104
+ | Variable | Description |
105
+ | --------------------------- | --------------------------------------------------------------------- |
106
+ | `sourceLanguageTag` | The source language tag of the project |
107
+ | `availableLanguageTags` | All language tags of the current project |
108
+ | `type AvailableLanguageTag` | An Type representing a valid language tag |
109
+ | `languageTag()` | Returns the language tag of the current user |
110
+ | `setLanguageTag()` | Sets the language tag of the current user |
111
+ | `onSetLanguageTag()` | Registers a listener that is called whenever the language tag changes |
112
+ | `isAvailableLanguageTag()` |  Checks if a value is a valid language tag |
126
113
 
127
114
  ## Setting the language
128
115
 
129
- You can set the current [language tag](/m/8y8sxj09/library-inlang-languageTag) by calling `setLanguageTag()`. Any subsequent calls to either `languageTag()` or a message function will return the new language tag.
116
+ You can set the current [language tag](https://www.inlang.com/m/8y8sxj09/library-inlang-languageTag) by calling `setLanguageTag()`. Any subsequent calls to either `languageTag()` or a message function will return the new language tag.
130
117
 
131
118
  ```js
132
- import { setLanguageTag } from "./paraglide/runtime"
133
- import * as m from "./paraglide/messages"
119
+ import { setLanguageTag } from "./paraglide/runtime.js"
120
+ import * as m from "./paraglide/messages.js"
134
121
 
135
122
  setLanguageTag("de")
136
123
  m.hello() // Hallo Welt!
@@ -139,15 +126,26 @@ setLanguageTag("en")
139
126
  m.hello() // Hello world!
140
127
  ```
141
128
 
142
- The [language tag](/m/8y8sxj09/library-inlang-languageTag) is global, so you need to be careful with it on the server to make sure multiple requests don't interfere with each other. That's why we recommend using an adapter for your framework. Adapters integrate with the framework's lifecycle and ensure that the language tag is managed correctly.
129
+ The [language tag](https://www.inlang.com/m/8y8sxj09/library-inlang-languageTag) is global, so you need to be careful with it on the server to make sure multiple requests don't interfere with each other. That's why we recommend using an adapter for your framework. Adapters integrate with the framework's lifecycle and ensure that the language tag is managed correctly.
130
+
131
+ ## Adding Languages
132
+
133
+ You can define which languages you want to support in `./project.inlang/settings.json`. Just edit the `languageTags` array.
134
+
135
+ ```json
136
+ // project.inlang/settings.json
137
+ {
138
+ "languageTags": ["en", "de"]
139
+ }
140
+ ```
143
141
 
144
142
  ## Reacting to a language change
145
143
 
146
- You can react to a language change by calling `onSetLanguageTag()`. This function is called whenever the [language tag](/m/8y8sxj09/library-inlang-languageTag) changes.
144
+ You can react to a language change by registering a callback using `onSetLanguageTag()`. This function is called whenever the [language tag](https://www.inlang.com/m/8y8sxj09/library-inlang-languageTag) changes.
147
145
 
148
146
  ```js
149
- import { setLanguageTag, onSetLanguageTag } from "./paraglide/runtime"
150
- import * as m from "./paraglide/messages"
147
+ import { setLanguageTag, onSetLanguageTag } from "./paraglide/runtime.js"
148
+ import * as m from "./paraglide/messages.js"
151
149
 
152
150
  onSetLanguageTag((newLanguageTag) => {
153
151
  console.log(`The language changed to ${newLanguageTag}`)
@@ -166,17 +164,17 @@ The main use case for `onSetLanguageTag()` is to trigger a rerender of your app'
166
164
 
167
165
  ## Forcing a language
168
166
 
169
- It's common that you need to force a message to be in a certain language, especially on the server. You can do this by passing an options object to the message function as a
167
+ It's common that you need to force a message to be in a certain language, especially on the server and during tests. You can do this by passing an options object to the message function as a
170
168
  second parameter.
171
169
 
172
170
  ```js
173
- import * as m from "./paraglide/messages"
171
+ import * as m from "./paraglide/messages.js"
174
172
  const msg = m.hello({ name: "Samuel" }, { languageTag: "de" }) // Hallo Samuel!
175
173
  ```
176
174
 
177
175
  ## Usage with a Bundler
178
176
 
179
- We provide a few bundler plugins to make it easier to use paraglide-js with a bundler. If you
177
+ We provide bundler plugins to make it easier to use Paraglide with a bundler. If you
180
178
  are using one of these bundlers, we recommed using the corresponding plugin.
181
179
 
182
180
  - [Rollup](https://github.com/opral/monorepo/tree/main/inlang/source-code/paraglide/paraglide-js-adapter-rollup)
@@ -187,28 +185,29 @@ These plugins make sure to rerun the `compile` script whenever you build your pr
187
185
 
188
186
  # Playground
189
187
 
190
- You can find many examples for how to use paraglide on codesandbox:
188
+ You can find many examples for how to use paraglide on codesandbox, or in [our GitHub repository](https://github.com/opral/monorepo/tree/main/inlang/source-code/paraglide).
191
189
 
192
190
  <doc-links>
193
- <doc-link title="Svelte + Paraglide JS" icon="lucide:codesandbox" href="https://dub.sh/paraglide-playground-svelte" description="Play around with Svelte and Paraglide JS"></doc-link>
191
+ <doc-link title="Svelte + Paraglide JS" icon="lucide:codesandbox" href="https://stackblitz.com/~/github.com/LorisSigrist/paraglide-sveltekit-example" description="Play around with Svelte and Paraglide JS"></doc-link>
192
+ <doc-link title="Astro + Paraglide JS" icon="lucide:codesandbox" href="https://stackblitz.com/~/github.com/LorisSigrist/paraglide-astro-example" description="Play around with Astro and Paraglide JS"></doc-link>
194
193
  </doc-links>
195
194
 
196
195
  # Architecture
197
196
 
198
197
  Inlang Paraglide JS leverages a compiler to emit vanilla JavaScript functions.
199
198
 
200
- The emitted functions are often referred to as "message functions". By emitting message functions, inlang Paraglide JS eliminates a class of edge cases while also being simpler, faster, and more reliable than other i18n libraries. The compiled runtime contains less than 50 LOC (lines of code) and is less than 1kb gzipped.
199
+ The emitted functions are referred to as "message functions". By emitting message functions, inlang Paraglide JS eliminates a whole class of edge cases while also being simpler, faster, and more reliable than other i18n libraries. The compiled runtime contains less than 50 LOC (lines of code) and is less than 300 bytes minified & gzipped.
201
200
 
202
201
  ![paraglide JS architecture](https://cdn.jsdelivr.net/gh/opral/monorepo@latest/inlang/source-code/paraglide/paraglide-js/assets/architecture.svg)
203
202
 
204
203
  Inlang Paraglide-JS consists of four main parts:
205
204
 
206
- | Part | Description |
207
- | ------------ | -------------------------------------------------------------------------- |
208
- | **Compiler** | Compiles messages into tree-shakable message functions |
209
- | **Messages** | The compiled tree-shakable message functions |
210
- | **Runtime** | A runtime that resolves the [language tag](/m/8y8sxj09/library-inlang-languageTag) of the current user |
211
- | **Adapter** | (if required) An adapter that adjusts the runtime for different frameworks |
205
+ | Part | Description |
206
+ | ------------ | ---------------------------------------------------------------------------------------------------------------------------- |
207
+ | **Compiler** | Compiles messages into tree-shakable message functions |
208
+ | **Messages** | The compiled tree-shakable message functions |
209
+ | **Runtime** | A runtime that resolves the [language tag](https://www.inlang.com/m/8y8sxj09/library-inlang-languageTag) of the current user |
210
+ | **Adapter** | (optional) An adapter that adjusts the runtime for different frameworks |
212
211
 
213
212
  ## Compiler
214
213
 
@@ -229,19 +228,16 @@ The compiler loads an inlang project and compiles the messages into tree-shakabl
229
228
  **Output**
230
229
 
231
230
  ```js
232
- // src/paraglide/messages.js
231
+ // src/paraglide/messages/en.js
233
232
 
234
233
  /**
235
234
  * @param {object} params
236
235
  * @param {string} params.name
237
236
  */
238
- function hello({ name }) {
239
- return `Hello ${name}!`
240
- }
237
+ export const hello = (params) => `Hello ${params.name}!`
241
238
 
242
- function loginButton() {
243
- return "Login"
244
- }
239
+ /** ... */
240
+ export const loginButton = () => "Login"
245
241
  ```
246
242
 
247
243
  ## Messages
@@ -257,25 +253,21 @@ Three compiled message functions exist in an example project.
257
253
  ```js
258
254
  // src/paraglide/messages.js
259
255
 
260
- export function hello(params) {
261
- return `Hello ${params.name}!`
262
- }
256
+ /** ... */
257
+ export const hello = (params) => `Hello ${params.name}!`
263
258
 
264
- export function loginButton() {
265
- return "Login"
266
- }
259
+ /** ... */
260
+ export const loginButton = () => "Login"
267
261
 
268
- export function loginHeader(params) {
269
- return `Hello ${params.name}, please login to continue.`
270
- }
262
+ /** ... */
263
+ export const loginHeader = (params) => `Hello ${params.name}, please login to continue.`
271
264
  ```
272
265
 
273
266
  Only the message `hello` is used in the source code.
274
267
 
275
268
  ```js
276
- // source/index.js
277
-
278
- import * as m from "./paraglide/messages"
269
+ // src/my-code.js
270
+ import * as m from "../paraglide/messages.js"
279
271
 
280
272
  console.log(m.hello({ name: "Samuel" }))
281
273
  ```
@@ -283,37 +275,25 @@ console.log(m.hello({ name: "Samuel" }))
283
275
  The bundler tree shakes (removes) `loginButton` and `loginHeader` and only includes `hello` in the output.
284
276
 
285
277
  ```js
286
- // output/index.js
287
-
288
- function hello(params) {
289
- return `Hello ${params.name}!`
290
- }
278
+ // dist/my-code.js
279
+ const hello = (params) => `Hello ${params.name}!`
291
280
 
292
281
  console.log(hello({ name: "Samuel" }))
293
282
  ```
294
283
 
295
- ## Runtime
296
-
297
- View the source of `./paraglide/runtime.js` to find the latest runtime API and documentation.
298
-
299
- ## Adapter
300
-
301
- Paraglide-JS can be adapted to any framework or environment by calling `setLanguageTag()` and `onSetLanguageTag()`.
302
-
303
- 1. `setLanguageTag()` can be used to set a getter function for the [language tag](/m/8y8sxj09/library-inlang-languageTag). The getter function can be used to resolve server-side language tags or to resolve the language tag from a global state management library like Redux or Vuex.
304
- 2. `onSetLanguageTag()` can be used to trigger side-effects such as updating the UI, or requesting the site in the new language from the server.
305
-
306
284
  # Writing an Adapter
307
285
 
286
+ Paraglide can be adapted to any framework or environment by calling `setLanguageTag()` and `onSetLanguageTag()`.
287
+
308
288
  The following example adapts Paraglide-JS to a fictitious metaframework like NextJS, SolidStart, SvelteKit, or Nuxt.
309
289
 
310
- The goal is to provide a high-level understanding of how to adapt Paraglide-JS to a framework. Besides this example, we recommend viewing the source-code of available adapters. In general, only two functions need to be called to adapt Paraglide-JS to a framework:
290
+ The goal is to provide a high-level understanding of how to adapt Paraglide to a framework. Besides this example, we recommend viewing the source-code of available adapters. In general, only two functions need to be called to adapt Paraglide to a framework:
311
291
 
312
- 1. `setLanguageTag()`: to set the [language tag](/m/8y8sxj09/library-inlang-languageTag)
313
- 2. `onSetLanguageTag()`: to trigger a side-effect when the language changes
292
+ 1. `setLanguageTag()` can be used to set a getter function for the [language tag](https://www.inlang.com/m/8y8sxj09/library-inlang-languageTag). The getter function can be used to resolve server-side language tags or to resolve the language tag from a global state management library like Redux or Vuex.
293
+ 2. `onSetLanguageTag()` can be used to trigger side-effects such as updating the UI, or requesting the site in the new language from the server.
314
294
 
315
295
  ```tsx
316
- import { setLanguageTag, onSetLanguageTag } from "./paraglide/runtime"
296
+ import { setLanguageTag, onSetLanguageTag } from "../paraglide/runtime.js"
317
297
  import { isServer, request, render } from "@example/framework"
318
298
 
319
299
  // On a server, the language tag needs to be resolved on a
@@ -358,15 +338,28 @@ We are grateful for all the support we get from the community. Here are just a f
358
338
  Of course we are open to and value criticism as well. If you have any feedback, please let us know directly on [GitHub](https://github.com/opral/monorepo/discussions/1464)
359
339
 
360
340
  <doc-comments>
341
+ <doc-comment text="Just tried Paraglide JS from @inlangHQ. This is how i18n should be done! Totally new level of DX for both implementation and managing translations! Superb support for SvelteKit as well ⭐" author="Patrik Engborg" icon="mdi:twitter" data-source="https://twitter.com/patrikengborg/status/1747260930873053674"></doc-comment>
361
342
  <doc-comment text="The lib is great guys!" author="ktarmyshov" icon="mdi:github"></doc-comment>
362
343
  <doc-comment text="Thank you for that huge work you have done and still doing!" author="ZerdoX-x" icon="mdi:github"></doc-comment>
363
344
  <doc-comment text="[...] the switch between the sdk-js and paraglide has been pretty great! " author="albbus" icon="mdi:discord"></doc-comment>
364
345
  <doc-comment text="Thanks for all the great work @Samuel Stroschein" author="Willem" icon="mdi:discord"></doc-comment>
365
346
  </doc-comments>
366
347
 
348
+ # Roadmap
349
+
350
+ Of course, we're not done yet! We plan on adding the following features to Paraglide JS in the upcoming weeks:
351
+
352
+ - [ ] Pluralization ([Join the Discussion](https://github.com/opral/monorepo/discussions/2025))
353
+ - [ ] Formatting of numbers and dates ([Join the Discussion](https://github.com/opral/monorepo/discussions/992))
354
+ - [ ] Markup Placeholders ([Join the Discussion](https://github.com/opral/monorepo/discussions/913))
355
+
367
356
  # Talks
368
357
 
369
358
  - [Svelte Summit Spring 2023](https://www.youtube.com/watch?v=Y6IbPfMU1xM)
370
359
  - [Svelte Summit Fall 2023](https://www.youtube.com/watch?v=-YES3CCAG90)
371
360
  - Web Zurich December 2023
372
361
  - [Svelte London January 2024](https://www.youtube.com/watch?v=eswNQiq4T2w&t=646s)
362
+
363
+ # Pricing
364
+
365
+ <doc-dev-tool-pricing></doc-dev-tool-pricing>
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,4 @@
1
+ Paraglide is a CLI at it's heart & therefore doesn't have a real JS entry point. This
2
+ means that NPM doesn't show the TS icon on the package, which may lead people to believe
3
+ it's not typesafe. To sidestep this we added an empty export. We don't think this is dishonest,
4
+ because both paraglide's source code and it's output are fully typed.
package/dist/index.js CHANGED
@@ -5808,7 +5808,7 @@ var require_dist_node2 = __commonJS({
5808
5808
  }
5809
5809
  return obj;
5810
5810
  }
5811
- function merge(defaults, route, options) {
5811
+ function merge2(defaults, route, options) {
5812
5812
  var _a;
5813
5813
  if (typeof route === "string") {
5814
5814
  let [method, url] = route.split(" ");
@@ -6055,15 +6055,15 @@ var require_dist_node2 = __commonJS({
6055
6055
  );
6056
6056
  }
6057
6057
  function endpointWithDefaults(defaults, route, options) {
6058
- return parse(merge(defaults, route, options));
6058
+ return parse(merge2(defaults, route, options));
6059
6059
  }
6060
6060
  function withDefaults(oldDefaults, newDefaults) {
6061
- const DEFAULTS2 = merge(oldDefaults, newDefaults);
6061
+ const DEFAULTS2 = merge2(oldDefaults, newDefaults);
6062
6062
  const endpoint2 = endpointWithDefaults.bind(null, DEFAULTS2);
6063
6063
  return Object.assign(endpoint2, {
6064
6064
  DEFAULTS: DEFAULTS2,
6065
6065
  defaults: withDefaults.bind(null, DEFAULTS2),
6066
- merge: merge.bind(null, DEFAULTS2),
6066
+ merge: merge2.bind(null, DEFAULTS2),
6067
6067
  parse
6068
6068
  });
6069
6069
  }
@@ -23967,7 +23967,7 @@ async function hash(inputStr) {
23967
23967
  }
23968
23968
 
23969
23969
  // ../../../../lix/source-code/client/dist/openRepository.js
23970
- var { clone, listRemotes, status, statusMatrix, push, pull, currentBranch, add, log, listServerRefs, checkout, addRemote, fetch: gitFetch, commit: isoCommit, findRoot } = isoGit;
23970
+ var { clone, listRemotes, status, statusMatrix, push, pull, currentBranch, add, log, listServerRefs, checkout, addRemote, fetch: gitFetch, commit: isoCommit, findRoot, merge } = isoGit;
23971
23971
  var verbose = false;
23972
23972
  var whitelistedExperimentalRepos = [
23973
23973
  "inlang/example",
@@ -23988,6 +23988,12 @@ async function findRepoRoot(args) {
23988
23988
  async function openRepository(url, args) {
23989
23989
  var _a;
23990
23990
  const rawFs = args.nodeishFs;
23991
+ if (!url) {
23992
+ throw new Error("repo url is required, use file:// for local repos");
23993
+ }
23994
+ if (verbose && typeof window !== "undefined") {
23995
+ window["rawFs"] = rawFs;
23996
+ }
23991
23997
  const [errors, setErrors] = createSignal4([]);
23992
23998
  let doLixClone = false;
23993
23999
  let branchName = args.branch;
@@ -24011,8 +24017,8 @@ async function openRepository(url, args) {
24011
24017
  }
24012
24018
  }
24013
24019
  const { protocol, lixHost, repoHost, owner, repoName, username, password } = parseLixUri(url);
24014
- if (username || password) {
24015
- console.error("username and password are not supported yet");
24020
+ if (verbose && (username || password)) {
24021
+ console.warn("username and password and providers other than github are not supported yet. Only local commands will work.");
24016
24022
  }
24017
24023
  const gitProxyUrl = lixHost ? `${protocol}//${lixHost}/git-proxy/` : "";
24018
24024
  const gitHubProxyUrl = lixHost ? `${protocol}//${lixHost}/github-proxy/` : "";
@@ -24139,7 +24145,7 @@ async function openRepository(url, args) {
24139
24145
  const repo = await this;
24140
24146
  const { isFork, parent } = await repo.getMeta();
24141
24147
  if (!isFork) {
24142
- return { error: "could not get fork origin or repo not a fork" };
24148
+ return { error: "could not get fork upstream or repo not a fork" };
24143
24149
  }
24144
24150
  const forkFs = withLazyFetching({
24145
24151
  nodeishFs: rawFs,
@@ -24147,6 +24153,14 @@ async function openRepository(url, args) {
24147
24153
  description: "forkStatus",
24148
24154
  intercept: delayedAction
24149
24155
  });
24156
+ const useBranchName = await isoGit.currentBranch({
24157
+ fs: forkFs,
24158
+ dir,
24159
+ fullname: false
24160
+ });
24161
+ if (!useBranchName) {
24162
+ return { error: "could not get fork status for detached head" };
24163
+ }
24150
24164
  await addRemote({
24151
24165
  dir,
24152
24166
  remote: "upstream",
@@ -24158,7 +24172,7 @@ async function openRepository(url, args) {
24158
24172
  depth: 1,
24159
24173
  singleBranch: true,
24160
24174
  dir,
24161
- ref: branchName,
24175
+ ref: useBranchName,
24162
24176
  remote: "upstream",
24163
24177
  http: makeHttpClient({ verbose, description: "forkStatus" }),
24164
24178
  fs: forkFs
@@ -24166,26 +24180,18 @@ async function openRepository(url, args) {
24166
24180
  } catch (err) {
24167
24181
  return { error: err };
24168
24182
  }
24169
- const branch = await isoGit.currentBranch({
24170
- fs: forkFs,
24171
- dir,
24172
- fullname: false
24173
- });
24174
- if (typeof branch !== "string") {
24175
- return { error: "could not get current branch" };
24176
- }
24177
24183
  const currentUpstreamCommit = await isoGit.resolveRef({
24178
24184
  fs: forkFs,
24179
24185
  dir: "/",
24180
- ref: "upstream/" + branch
24186
+ ref: "upstream/" + useBranchName
24181
24187
  });
24182
24188
  const currentOriginCommit = await isoGit.resolveRef({
24183
24189
  fs: forkFs,
24184
24190
  dir: "/",
24185
- ref: branch
24191
+ ref: useBranchName
24186
24192
  });
24187
24193
  if (currentUpstreamCommit === currentOriginCommit) {
24188
- return { ahead: 0, behind: 0 };
24194
+ return { ahead: 0, behind: 0, conflicts: false };
24189
24195
  }
24190
24196
  const res = github.request("GET /repos/{owner}/{repo}/compare/{base}...{head}", {
24191
24197
  owner,
@@ -24200,7 +24206,40 @@ async function openRepository(url, args) {
24200
24206
  if ("error" in compare || !("data" in compare)) {
24201
24207
  return { error: compare.error || "could not diff repos on github" };
24202
24208
  }
24203
- return { ahead: compare.data.ahead_by, behind: compare.data.behind_by };
24209
+ await gitFetch({
24210
+ depth: compare.data.behind_by + 1,
24211
+ remote: "upstream",
24212
+ singleBranch: true,
24213
+ dir,
24214
+ ref: useBranchName,
24215
+ http: makeHttpClient({ verbose, description: "forkStatus" }),
24216
+ fs: forkFs
24217
+ });
24218
+ await gitFetch({
24219
+ depth: compare.data.ahead_by + 1,
24220
+ singleBranch: true,
24221
+ ref: useBranchName,
24222
+ dir,
24223
+ http: makeHttpClient({ verbose, description: "forkStatus" }),
24224
+ corsProxy: gitProxyUrl,
24225
+ fs: forkFs
24226
+ });
24227
+ let conflicts = false;
24228
+ try {
24229
+ await merge({
24230
+ fs: forkFs,
24231
+ author: { name: "lix" },
24232
+ dir,
24233
+ ours: useBranchName,
24234
+ dryRun: true,
24235
+ theirs: "upstream/" + useBranchName,
24236
+ noUpdateBranch: true,
24237
+ abortOnConflict: true
24238
+ });
24239
+ } catch (err) {
24240
+ conflicts = true;
24241
+ }
24242
+ return { ahead: compare.data.ahead_by, behind: compare.data.behind_by, conflicts };
24204
24243
  },
24205
24244
  statusMatrix(cmdArgs) {
24206
24245
  return statusMatrix({
@@ -24418,7 +24457,7 @@ async function openRepository(url, args) {
24418
24457
  if (lastHashInPage) {
24419
24458
  firstCommitHash = lastHashInPage;
24420
24459
  }
24421
- if (commits.length < 50) {
24460
+ if (commits.length < 550) {
24422
24461
  break;
24423
24462
  }
24424
24463
  }
@@ -24490,9 +24529,8 @@ async function generateProjectId(args) {
24490
24529
  return void 0;
24491
24530
  }
24492
24531
  const firstCommitHash = await args.repo.getFirstCommitHash();
24493
- const originHash = await args.repo.getOrigin({ safeHashOnly: true });
24494
24532
  if (firstCommitHash) {
24495
- return hash(`${firstCommitHash + args.projectPath + originHash}`);
24533
+ return hash(`${firstCommitHash + args.projectPath}`);
24496
24534
  }
24497
24535
  return void 0;
24498
24536
  }
@@ -24529,6 +24567,33 @@ var capture = async (event, args) => {
24529
24567
  }
24530
24568
  };
24531
24569
 
24570
+ // ../../sdk/dist/telemetry/groupIdentify.js
24571
+ init_define_ENV_DEFINED_IN_BUILD_STEP();
24572
+ var identifyProject = async (args) => {
24573
+ if (ENV_VARIABLES.PUBLIC_POSTHOG_TOKEN === void 0) {
24574
+ return;
24575
+ }
24576
+ try {
24577
+ await fetch("https://eu.posthog.com/capture/", {
24578
+ method: "POST",
24579
+ body: JSON.stringify({
24580
+ api_key: ENV_VARIABLES.PUBLIC_POSTHOG_TOKEN,
24581
+ event: "$groupidentify",
24582
+ // id is "unknown" because no user information is available
24583
+ distinct_id: "unknown",
24584
+ properties: {
24585
+ $group_type: "project",
24586
+ $group_key: args.projectId,
24587
+ $group_set: {
24588
+ ...args.properties
24589
+ }
24590
+ }
24591
+ })
24592
+ });
24593
+ } catch (e) {
24594
+ }
24595
+ };
24596
+
24532
24597
  // ../../sdk/dist/loadProject.js
24533
24598
  var settingsCompiler = import_compiler3.TypeCompiler.Compile(ProjectSettings);
24534
24599
  async function loadProject(args) {
@@ -24543,14 +24608,7 @@ Valid examples:
24543
24608
  - "/path/to/green-elephant.inlang
24544
24609
  `, { argument: "projectPath" });
24545
24610
  }
24546
- let fs2;
24547
- if (args.nodeishFs) {
24548
- fs2 = args.nodeishFs;
24549
- } else if (args.repo) {
24550
- fs2 = args.repo.nodeishFs;
24551
- } else {
24552
- throw new LoadProjectInvalidArgument(`Repo missing from arguments.`, { argument: "repo" });
24553
- }
24611
+ const fs2 = args.repo.nodeishFs;
24554
24612
  const nodeishFs = createNodeishFsWithAbsolutePaths({
24555
24613
  projectPath,
24556
24614
  nodeishFs: fs2
@@ -24675,6 +24733,14 @@ Valid examples:
24675
24733
  let projectLoadedCapturedAlready = false;
24676
24734
  if (projectId && projectLoadedCapturedAlready === false) {
24677
24735
  projectLoadedCapturedAlready = true;
24736
+ await identifyProject({
24737
+ projectId,
24738
+ properties: {
24739
+ // using the id for now as a name but can be changed in the future
24740
+ // we need at least one property to make a project visible in the dashboard
24741
+ name: projectId
24742
+ }
24743
+ });
24678
24744
  await capture("SDK loaded project", {
24679
24745
  projectId,
24680
24746
  properties: {
@@ -24687,6 +24753,7 @@ Valid examples:
24687
24753
  });
24688
24754
  }
24689
24755
  return {
24756
+ id: projectId,
24690
24757
  installed: {
24691
24758
  plugins: createSubscribable(() => installedPlugins()),
24692
24759
  messageLintRules: createSubscribable(() => installedMessageLintRules())
@@ -24835,6 +24902,7 @@ var solidAdapter = (project, arg) => {
24835
24902
  return arg.from(observable2(signal));
24836
24903
  };
24837
24904
  return {
24905
+ id: project.id,
24838
24906
  customApi: convert(project.customApi),
24839
24907
  settings: convert(project.settings),
24840
24908
  errors: convert(project.errors),
@@ -25242,7 +25310,7 @@ var messageIndexFunction = (args) => {
25242
25310
  * This message has been compiled by [inlang paraglide](https://inlang.com/m/gerre34r/library-inlang-paraglideJs).
25243
25311
  *
25244
25312
  * - Don't edit the message's code. Use the [inlang ide extension](https://inlang.com/m/r7kp499g/app-inlang-ideExtension),
25245
- * the [web editor](https://inlang.com/m/tdozzpar/app-inlang-editor) instead, or edit the translation files manually.
25313
+ * the [web editor](https://inlang.com/m/tdozzpar/app-inlang-finkLocalizationEditor) instead, or edit the translation files manually.
25246
25314
  *
25247
25315
  * - The params are NonNullable<unknown> because the inlang SDK does not provide information on the type of a param (yet).
25248
25316
  *
@@ -25290,7 +25358,7 @@ init_define_ENV_DEFINED_IN_BUILD_STEP();
25290
25358
  var import_dotenv = __toESM(require_main(), 1);
25291
25359
  var privateEnv = getPrivateEnvVariables();
25292
25360
  function getPrivateEnvVariables() {
25293
- if (typeof process === "undefined") {
25361
+ if (typeof process === "undefined" || typeof process.cwd === "undefined") {
25294
25362
  return new Proxy(
25295
25363
  {},
25296
25364
  {
@@ -25311,7 +25379,7 @@ function getPrivateEnvVariables() {
25311
25379
 
25312
25380
  // ../../env-variables/dist/runtime/publicEnv.js
25313
25381
  init_define_ENV_DEFINED_IN_BUILD_STEP();
25314
- var define_PUBLIC_ENV_DEFINED_IN_BUILD_STEP_default = { PUBLIC_IS_DEV: "false", PUBLIC_GIT_PROXY_BASE_URL: "https://git.inlang.com", PUBLIC_POSTHOG_TOKEN: "phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz", PUBLIC_ALLOWED_AUTH_URLS: "https://inlang.com,https://manage.inlang.com,https://fink.inlang.com", PUBLIC_SERVER_BASE_URL: "https://inlang.com", PUBLIC_WEBSITE_SENTRY_DSN: "https://6ba3cb3bad464dd9a7f8700ed636c07a@o4504345873285120.ingest.sentry.io/4504346044006400", PUBLIC_HCAPTCHA_SITEKEY: "353a039d-fc34-40a6-a81d-91720e8851b0", PUBLIC_LIX_GITHUB_APP_NAME: "inlang", PUBLIC_LIX_GITHUB_APP_CLIENT_ID: "Iv1.436da58906364f96" };
25382
+ var define_PUBLIC_ENV_DEFINED_IN_BUILD_STEP_default = { PUBLIC_IS_DEV: "false", PUBLIC_GIT_PROXY_BASE_URL: "https://git.inlang.com", PUBLIC_POSTHOG_TOKEN: "phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz", PUBLIC_ALLOWED_AUTH_URLS: "https://inlang.com,https://manage.inlang.com,https://fink.inlang.com", PUBLIC_SERVER_BASE_URL: "https://inlang.com", PUBLIC_FINK_SENTRY_DSN: "https://00c275e250bb5a103cda12a76e5a7d98@o4504345873285120.ingest.sentry.io/4506599134461952", PUBLIC_WEBSITE_SENTRY_DSN: "https://6ba3cb3bad464dd9a7f8700ed636c07a@o4504345873285120.ingest.sentry.io/4504346044006400", PUBLIC_HCAPTCHA_SITEKEY: "353a039d-fc34-40a6-a81d-91720e8851b0", PUBLIC_LIX_GITHUB_APP_NAME: "inlang", PUBLIC_LIX_GITHUB_APP_CLIENT_ID: "Iv1.436da58906364f96" };
25315
25383
  var publicEnv = new Proxy({}, {
25316
25384
  get(target, prop) {
25317
25385
  if (typeof prop === "string" && prop.startsWith("PUBLIC_") === false) {
@@ -29075,6 +29143,7 @@ var publicEnvVariablesSchema = z.object({
29075
29143
  PUBLIC_LIX_GITHUB_APP_NAME: z.string(),
29076
29144
  PUBLIC_GIT_PROXY_BASE_URL: z.string().startsWith("http").regex(/^(?!.*\/$).+$/, "Must not end with a slash").describe(`Must be a url including protocol`),
29077
29145
  PUBLIC_WEBSITE_SENTRY_DSN: z.string().optional().describe("DSN for Sentry (in the browser)"),
29146
+ PUBLIC_FINK_SENTRY_DSN: z.string().optional().describe("DSN for Sentry (in the fink)"),
29078
29147
  PUBLIC_POSTHOG_TOKEN: z.string().optional(),
29079
29148
  PUBLIC_SERVER_BASE_URL: z.string().url().regex(/^(?!.*\/$).+$/, "Must not end with a slash").describe("The base url of the server e.g. https://inlang.com"),
29080
29149
  PUBLIC_ALLOWED_AUTH_URLS: z.string().describe("List of allowed base urls eg https://inlang.com,https://manage.inlang.com"),
@@ -29106,7 +29175,7 @@ var posthog = new PostHog(publicEnv.PUBLIC_POSTHOG_TOKEN ?? "placeholder", {
29106
29175
  });
29107
29176
  var telemetry = new Proxy(posthog, {
29108
29177
  get(target, prop) {
29109
- if (publicEnv.PUBLIC_POSTHOG_TOKEN === void 0) {
29178
+ if (!publicEnv.PUBLIC_POSTHOG_TOKEN) {
29110
29179
  return () => void 0;
29111
29180
  } else if (prop === "capture") {
29112
29181
  return capture2;
@@ -29115,6 +29184,9 @@ var telemetry = new Proxy(posthog, {
29115
29184
  }
29116
29185
  });
29117
29186
  function capture2(args) {
29187
+ if (!publicEnv.PUBLIC_POSTHOG_TOKEN) {
29188
+ return;
29189
+ }
29118
29190
  return posthog.capture({
29119
29191
  ...args,
29120
29192
  distinctId: "unknown"
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "@inlang/paraglide-js",
3
3
  "type": "module",
4
- "version": "1.2.1",
4
+ "version": "1.2.2",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
9
  "author": "inlang <hello@inlang.com> (https://inlang.com/)",
10
+ "homepage": "https://github.com/opral/monorepo/tree/main/inlang/source-code/paraglide/paraglide-js",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/opral/monorepo.git",
14
+ "directory": "inlang/source-code/paraglide/paraglide-js"
15
+ },
10
16
  "keywords": [
11
17
  "paraglide",
12
18
  "javascript i18n",
@@ -21,14 +27,19 @@
21
27
  "vue",
22
28
  "angular",
23
29
  "nextjs",
24
- "next i18n"
30
+ "next i18n",
31
+ "astro",
32
+ "astro i18n",
33
+ "solid",
34
+ "solidstart"
25
35
  ],
26
36
  "bin": {
27
37
  "paraglide-js": "./bin/run.js"
28
38
  },
29
39
  "files": [
30
40
  "./dist",
31
- "./bin"
41
+ "./bin",
42
+ "./default"
32
43
  ],
33
44
  "dependencies": {
34
45
  "commander": "11.1.0",
@@ -45,7 +56,7 @@
45
56
  "@rollup/plugin-virtual": "3.0.1",
46
57
  "@ts-morph/bootstrap": "0.20.0",
47
58
  "@types/minimist": "1.2.3",
48
- "@types/node": "^20.11.2",
59
+ "@types/node": "^20.11.4",
49
60
  "@vitest/coverage-v8": "0.34.3",
50
61
  "cross-env": "^7.0.3",
51
62
  "esbuild": "^0.19.7",
@@ -54,13 +65,17 @@
54
65
  "typescript": "5.2.2",
55
66
  "vitest": "0.34.3",
56
67
  "@inlang/env-variables": "0.2.0",
57
- "@inlang/sdk": "0.23.0",
58
- "@inlang/telemetry": "0.3.4",
59
- "@lix-js/client": "0.5.0",
60
- "@lix-js/fs": "0.5.0",
68
+ "@inlang/telemetry": "0.3.9",
69
+ "@lix-js/fs": "0.6.0",
70
+ "@lix-js/client": "0.8.0",
71
+ "@inlang/sdk": "0.26.1",
61
72
  "@inlang/plugin-message-format": "2.0.0"
62
73
  },
63
74
  "exports": {
75
+ ".": {
76
+ "import": "./default/index.js",
77
+ "types": "./default/index.d.ts"
78
+ },
64
79
  "./internal": {
65
80
  "import": "./dist/index.js",
66
81
  "types": "./dist/index.d.ts"