@tolgee/core 5.0.0-alpha.1 → 5.0.0-alpha.3

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 (56) hide show
  1. package/README.md +174 -0
  2. package/README.njk.md +61 -0
  3. package/dist/tolgee.cjs.js +185 -143
  4. package/dist/tolgee.cjs.js.map +1 -1
  5. package/dist/tolgee.cjs.min.js +1 -1
  6. package/dist/tolgee.cjs.min.js.map +1 -1
  7. package/dist/tolgee.esm.js +185 -143
  8. package/dist/tolgee.esm.js.map +1 -1
  9. package/dist/tolgee.esm.min.mjs +1 -1
  10. package/dist/tolgee.esm.min.mjs.map +1 -1
  11. package/dist/tolgee.umd.js +185 -143
  12. package/dist/tolgee.umd.js.map +1 -1
  13. package/dist/tolgee.umd.min.js +1 -1
  14. package/dist/tolgee.umd.min.js.map +1 -1
  15. package/lib/Controller/Controller.d.ts +8 -4
  16. package/lib/Controller/Events/EventEmitter.d.ts +1 -1
  17. package/lib/Controller/Events/EventEmitterSelective.d.ts +1 -1
  18. package/lib/Controller/Events/Events.d.ts +1 -0
  19. package/lib/Controller/Plugins/Plugins.d.ts +4 -4
  20. package/lib/Controller/State/State.d.ts +2 -1
  21. package/lib/Controller/State/initState.d.ts +13 -2
  22. package/lib/{Tolgee.d.ts → TolgeeCore.d.ts} +13 -4
  23. package/lib/helpers.d.ts +1 -0
  24. package/lib/index.d.ts +1 -1
  25. package/lib/types/events.d.ts +2 -2
  26. package/lib/types/index.d.ts +1 -1
  27. package/lib/types/plugin.d.ts +6 -9
  28. package/package.json +2 -2
  29. package/src/Controller/Controller.ts +5 -4
  30. package/src/Controller/Events/EventEmitter.ts +6 -2
  31. package/src/Controller/Events/EventEmitterSelective.test.ts +23 -0
  32. package/src/Controller/Events/EventEmitterSelective.ts +8 -5
  33. package/src/Controller/Events/Events.ts +19 -8
  34. package/src/Controller/Plugins/Plugins.ts +66 -63
  35. package/src/Controller/State/initState.ts +16 -1
  36. package/src/{Tolgee.ts → TolgeeCore.ts} +12 -3
  37. package/src/__test/backend.test.ts +2 -2
  38. package/src/__test/cache.test.ts +6 -3
  39. package/src/__test/client.test.ts +2 -2
  40. package/src/__test/events.test.ts +30 -5
  41. package/src/__test/format.simple.test.ts +2 -14
  42. package/src/__test/formatError.test.ts +61 -0
  43. package/src/__test/initialization.test.ts +4 -4
  44. package/src/__test/languageDetection.test.ts +8 -8
  45. package/src/__test/languageStorage.test.ts +10 -11
  46. package/src/__test/languages.test.ts +8 -8
  47. package/src/__test/loading.test.ts +2 -2
  48. package/src/__test/namespaces.fallback.test.ts +5 -5
  49. package/src/__test/namespaces.test.ts +4 -4
  50. package/src/__test/options.test.ts +3 -3
  51. package/src/__test/plugins.test.ts +4 -4
  52. package/src/helpers.ts +8 -0
  53. package/src/index.ts +1 -1
  54. package/src/types/events.ts +2 -2
  55. package/src/types/index.ts +1 -1
  56. package/src/types/plugin.ts +12 -12
package/README.md ADDED
@@ -0,0 +1,174 @@
1
+ <!-- This file was generated using pnpm generate-readmes script
2
+
3
+ Don't edit this file. Edit the README.md.njk. Macros can be found in readmeMacros/macros.njk
4
+
5
+ -->
6
+
7
+
8
+ <h1 align="center" style="border-bottom: none">
9
+ <b>
10
+ <a href="https://tolgee.io">Tolgee JS Core</a><br>
11
+ </b>
12
+ The Core of Tolgee JS integrations
13
+ <br>
14
+ </h1>
15
+
16
+ <div align="center">
17
+
18
+ [![Logo](https://user-images.githubusercontent.com/18496315/188628892-33fcc282-26f1-4035-8105-95952bd93de9.svg)](https://tolgee.io)
19
+
20
+ Tolgee is an open-source alternative to Crowdin, Phrase, or Lokalise with its very own revolutionary integrations.
21
+
22
+ ![test workflow](https://github.com/tolgee/tolgee-js/actions/workflows/test.yml/badge.svg)
23
+
24
+ ![@tolgee/core version](https://img.shields.io/npm/v/@tolgee/core?label=@tolgee/core)
25
+
26
+ ![types typescript](https://img.shields.io/badge/Types-Typescript-blue)
27
+ ![typescript](https://img.shields.io/github/languages/top/tolgee/tolgee-js)
28
+ ![licence](https://img.shields.io/github/license/tolgee/tolgee-js)
29
+ [![github stars](https://img.shields.io/github/stars/tolgee/tolgee-js?style=social&label=Tolgee%20JS)](https://github.com/tolgee/tolgee-js)
30
+ [![github stars](https://img.shields.io/github/stars/tolgee/server?style=social&label=Tolgee%20Server)](https://github.com/tolgee/server)
31
+ [![Github discussions](https://img.shields.io/github/discussions/tolgee/tolgee-platform)](https://github.com/tolgee/tolgee-platform/discussions)
32
+ </div>
33
+
34
+ <div align="center">
35
+
36
+ [<img src="https://img.shields.io/badge/-Facebook-424549?style=social&logo=facebook" height=25 />](https://www.facebook.com/Tolgee.i18n)
37
+ [<img src="https://img.shields.io/badge/-Twitter-424549?style=social&logo=twitter" height=25 />](https://twitter.com/Tolgee_i18n)
38
+ [<img src="https://img.shields.io/badge/-Linkedin-424549?style=social&logo=linkedin" height=25 />](https://www.linkedin.com/company/tolgee)
39
+
40
+ **Become part of the family. Join [slack channel <img src="https://img.shields.io/badge/-Tolgee Comunity-424549?style=social&logo=slack" height=25 />](https://join.slack.com/t/tolgeecommunity/shared_invite/zt-195isb5u8-_RcSRgVJfvgsPpOBIok~IQ)**
41
+
42
+ </div>
43
+
44
+
45
+
46
+ ## What is Tolgee JS Core?
47
+ It's the core library of Tolgee JS integrations containing the platform-agnostic parts of the Tolgee JS.
48
+ For more information about Tolgee JS integrations, visit the [docs](https://tolgee.io/js-sdk/5.0.0-alpha.1/).
49
+
50
+
51
+ ## Quick links
52
+ - [Tolgee JS SDK docs](https://tolgee.io/js-sdk)
53
+ - [Tolgee Website](https://tolgee.io)
54
+ - Product (Learn more about the great features)
55
+ - [Dev tools](https://tolgee.io/features/dev-tools)
56
+ - [Translation assistance](https://tolgee.io/features/translation-assistance)
57
+ - [Collaboration](https://tolgee.io/features/collaboration)
58
+ - Integrations (Learn how to integrate Tolgee with your favorite technology)
59
+ - [React](https://tolgee.io/integrations/react)
60
+ - [Angular](https://tolgee.io/integrations/angular)
61
+ - [Vue](https://tolgee.io/integrations/vue)
62
+ - [Svelte](https://tolgee.io/integrations/svelte)
63
+ - [Next.js](https://tolgee.io/integrations/next)
64
+ - [Gatsby](https://tolgee.io/integrations/gatsby)
65
+ - [More...](https://tolgee.io/integrations/all)
66
+ - [Tolgee platform docs](https://tolgee.io/platform)
67
+
68
+
69
+ ## You should not use this package directly for usage in the web browser
70
+
71
+ If you use Tolgee on the web, use [@tolgee/web](https://github.com/tolgee/tolgee-js/tree/main/packages/web) package, which extends this package with web-related functionality.
72
+
73
+ This package is platform-agnostic, so it contains only the most general functionality.
74
+
75
+
76
+ ## Installation
77
+
78
+ ```
79
+ npm install @tolgee/core
80
+ ```
81
+
82
+
83
+ ## Usage
84
+
85
+ First, create a Tolgee instance and run it.
86
+
87
+ ```ts
88
+ import { TolgeeCore } from "@tolgee/core";
89
+
90
+ const tg = TolgeeCore()
91
+ .use(...)
92
+ .init(...)
93
+
94
+ tg.run();
95
+ ```
96
+
97
+ To learn more, check [the docs](https://tolgee.io/js-sdk/5.0.0-alpha.1/).
98
+
99
+
100
+ ## Why to use Tolgee?
101
+ Because it saves a lot of time, you would spend on localization tasks without it. Because it enables you to provide perfectly translated software.
102
+
103
+ ### Features
104
+
105
+ - All-in-one localization solution for your JS application 🙌
106
+ - Out-of-box in-context localization 🎉
107
+ - Automated screenshot generation 📷
108
+ - Translation management platform 🎈
109
+ - Open-source 🔥
110
+
111
+ ![Frame 47](https://user-images.githubusercontent.com/18496315/188637819-ac4eb02d-7859-4ca8-9807-27818a52782d.png)
112
+ Read more on the [Tolgee website](https://tolgee.io)
113
+
114
+
115
+ ## Development
116
+
117
+ We welcome your PRs.
118
+
119
+ To develop the package locally:
120
+ 1. Clone [the repository](https://github.com/tolgee/tolgee-js)
121
+ 1. Install the packages in the repository root
122
+ ```
123
+ pnpm install
124
+ ```
125
+
126
+
127
+ 1. Run web or any integration development script
128
+ ```
129
+ pnpm develop:react
130
+ ```
131
+ or
132
+ ```
133
+ pnpm develop:web
134
+ ```
135
+ This runs the development suite of this monorepo for the specific integration. The changes in each dependency package are
136
+ automatically built and propagated to the test application, which you can open and play within the browser.
137
+
138
+
139
+
140
+
141
+ ### Testing
142
+
143
+ To run Jest tests of this package, execute
144
+ ```
145
+ npm run test
146
+ ```
147
+ In the `/packages/core` directory.
148
+
149
+
150
+ ### End-to-end (e2e) testing
151
+
152
+ Each integration is end-to-end tested via cypress. The tests are defined in `/e2e/cypress/e2e` directory.
153
+
154
+ To run the e2e tests, run
155
+ ```
156
+ pnpm run e2e run <integration>
157
+ ```
158
+ E.g.
159
+ ```
160
+ pnpm run e2e run web
161
+ ```
162
+
163
+ To open and play with e2e tests, run:
164
+ ```
165
+ pnpm run e2e open <integration>
166
+ ```
167
+
168
+
169
+ ## Contributors
170
+
171
+ <a href="https://github.com/tolgee/tolgee-platform/graphs/contributors">
172
+ <img alt="contributors" src="https://contrib.rocks/image?repo=tolgee/tolgee-js"/>
173
+ </a>
174
+
package/README.njk.md ADDED
@@ -0,0 +1,61 @@
1
+ {% import "../../readmeMacros/macros.njk.md" as macros %}
2
+
3
+ {{ macros.header('Tolgee JS Core', 'The Core of Tolgee JS integrations', packageName) }}
4
+
5
+ ## What is Tolgee JS Core?
6
+ It's the core library of Tolgee JS integrations containing the platform-agnostic parts of the Tolgee JS.
7
+ For more information about Tolgee JS integrations, visit the [docs]({{ macros.v5link() }}).
8
+
9
+ {{ macros.links() }}
10
+
11
+ ## You should not use this package directly for usage in the web browser
12
+
13
+ If you use Tolgee on the web, use [@tolgee/web](https://github.com/tolgee/tolgee-js/tree/main/packages/web) package, which extends this package with web-related functionality.
14
+
15
+ This package is platform-agnostic, so it contains only the most general functionality.
16
+
17
+ {{ macros.installation('core') }}
18
+
19
+ ## Usage
20
+
21
+ First, create a Tolgee instance and run it.
22
+
23
+ ```ts
24
+ import { TolgeeCore } from "@tolgee/core";
25
+
26
+ const tg = TolgeeCore()
27
+ .use(...)
28
+ .init(...)
29
+
30
+ tg.run();
31
+ ```
32
+
33
+ To learn more, check [the docs]({{ macros.v5link() }}).
34
+
35
+ {{ macros.why() }}
36
+
37
+ ## Development
38
+ {{ macros.developmentInstallation() }}
39
+ {{ macros.developmentCore() }}
40
+
41
+ {{ macros.developmentTesting('/packages/core') }}
42
+
43
+ ### End-to-end (e2e) testing
44
+
45
+ Each integration is end-to-end tested via cypress. The tests are defined in `/e2e/cypress/e2e` directory.
46
+
47
+ To run the e2e tests, run
48
+ ```
49
+ pnpm run e2e run <integration>
50
+ ```
51
+ E.g.
52
+ ```
53
+ pnpm run e2e run web
54
+ ```
55
+
56
+ To open and play with e2e tests, run:
57
+ ```
58
+ pnpm run e2e open <integration>
59
+ ```
60
+
61
+ {{ macros.contributors() }}