@qwik.dev/core 2.0.0-beta.17 → 2.0.0-beta.19

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 (51) hide show
  1. package/bindings/qwik.darwin-arm64.node +0 -0
  2. package/bindings/qwik.linux-x64-gnu.node +0 -0
  3. package/bindings/qwik.win32-x64-msvc.node +0 -0
  4. package/bindings/qwik_wasm_bg.wasm +0 -0
  5. package/dist/backpatch/package.json +1 -1
  6. package/dist/build/package.json +1 -1
  7. package/dist/cli.mjs +57 -57
  8. package/dist/core-internal.d.ts +32 -32
  9. package/dist/core.min.mjs +1 -1
  10. package/dist/core.mjs +1234 -788
  11. package/dist/core.mjs.map +1 -1
  12. package/dist/core.prod.mjs +815 -553
  13. package/dist/loader/index.mjs +2 -2
  14. package/dist/loader/package.json +1 -1
  15. package/dist/optimizer.mjs +1007 -1000
  16. package/dist/qwikloader.debug.js +1 -1
  17. package/dist/qwikloader.js +1 -1
  18. package/dist/server.mjs +65 -106
  19. package/dist/starters/adapters/cloudflare-workers/README.md +52 -0
  20. package/dist/starters/adapters/cloudflare-workers/adapters/cloudflare-workers/vite.config.ts +15 -0
  21. package/dist/starters/adapters/cloudflare-workers/gitignore +3 -0
  22. package/dist/starters/adapters/cloudflare-workers/package.json +31 -0
  23. package/dist/starters/adapters/cloudflare-workers/public/.assetsignore +4 -0
  24. package/dist/starters/adapters/cloudflare-workers/public/_headers +11 -0
  25. package/dist/starters/adapters/cloudflare-workers/public/_redirects +1 -0
  26. package/dist/starters/adapters/cloudflare-workers/src/entry.cloudflare-pages.tsx +23 -0
  27. package/dist/starters/adapters/cloudflare-workers/worker-configuration.d.ts +5 -0
  28. package/dist/starters/adapters/cloudflare-workers/wrangler.jsonc +41 -0
  29. package/dist/starters/adapters/express/package.json +1 -1
  30. package/dist/starters/features/compiled-i18n/package.json +37 -0
  31. package/dist/starters/features/compiled-i18n/src/components/locale-selector/locale-selector.tsx +30 -0
  32. package/dist/starters/features/{localize → compiled-i18n}/src/entry.ssr.tsx +7 -2
  33. package/dist/starters/features/compiled-i18n/src/routes/plugin@compiled-i18n.ts +28 -0
  34. package/dist/starters/features/csr/package.json +1 -1
  35. package/dist/starters/features/cypress/src/actions/example.action.ts +5 -0
  36. package/dist/starters/features/cypress/src/components/example/example.cy.tsx +50 -8
  37. package/dist/starters/features/cypress/src/components/example/example.tsx +13 -3
  38. package/dist/starters/features/cypress/src/loaders/example.loader.ts +5 -0
  39. package/dist/starters/features/playwright/playwright-report/index.html +0 -19
  40. package/dist/testing/index.d.ts +11 -11
  41. package/dist/testing/index.mjs +2966 -2498
  42. package/dist/testing/package.json +1 -1
  43. package/package.json +14 -11
  44. package/bindings/qwik.darwin-x64.node +0 -0
  45. package/bindings/qwik.wasm.cjs +0 -471
  46. package/dist/starters/features/localize/package.json +0 -37
  47. package/dist/starters/features/localize/src/locales/message.en.json +0 -8
  48. package/dist/starters/features/localize/src/locales/message.it.json +0 -8
  49. package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +0 -94
  50. package/dist/starters/features/localize/src/routes/[locale]/index.tsx +0 -52
  51. package/dist/starters/features/localize/src/routes/[locale]/layout.tsx +0 -12
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwik.dev/core/testing",
3
- "version": "2.0.0-beta.17-dev+c34c237",
3
+ "version": "2.0.0-beta.19-dev+0d046fb",
4
4
  "main": "index.mjs",
5
5
  "types": "index.d.ts",
6
6
  "private": true,
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
1
  {
2
2
  "name": "@qwik.dev/core",
3
3
  "description": "An open source framework for building instant loading web apps at any scale, without the extra effort.",
4
- "version": "2.0.0-beta.17",
4
+ "version": "2.0.0-beta.19",
5
5
  "author": "Qwik Team",
6
6
  "bin": {
7
7
  "qwik": "./qwik-cli.mjs"
8
8
  },
9
9
  "bugs": "https://github.com/QwikDev/qwik/issues",
10
10
  "dependencies": {
11
- "csstype": "^3.1.3",
12
- "launch-editor": "^2.11.1",
13
- "rollup": "^4.52.4",
14
- "ts-morph": "23.0.0"
11
+ "csstype": "^3.2.3",
12
+ "launch-editor": "^2.12.0",
13
+ "rollup": "^4.55.1",
14
+ "ts-morph": "27.0.2"
15
15
  },
16
16
  "devDependencies": {
17
- "@croct/json5-parser": "0.2.1",
17
+ "@croct/json5-parser": "0.2.2",
18
18
  "domino": "2.1.6",
19
19
  "ignore": "5.3.1",
20
20
  "image-size": "1.2.1",
21
21
  "kleur": "4.1.5",
22
- "prettier": "3.6.2",
23
- "vitest": "4.0.1",
24
- "@qwik.dev/dom": "2.1.19",
25
- "@qwik.dev/core": "2.0.0-beta.17"
22
+ "prettier": "3.7.4",
23
+ "vitest": "4.0.16",
24
+ "@qwik.dev/core": "2.0.0-beta.19",
25
+ "@qwik.dev/dom": "2.1.19"
26
26
  },
27
27
  "engines": {
28
28
  "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
@@ -171,7 +171,10 @@
171
171
  "url": "https://github.com/QwikDev/qwik.git",
172
172
  "directory": "packages/qwik"
173
173
  },
174
- "sideEffects": false,
174
+ "sideEffects": [
175
+ "./src/testing/vdom-diff.unit-util.ts",
176
+ "./src/testing/mocks.ts"
177
+ ],
175
178
  "type": "module",
176
179
  "types": "./public.d.ts",
177
180
  "scripts": {
Binary file
@@ -1,471 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
6
- let wasm;
7
-
8
- function addToExternrefTable0(obj) {
9
- const idx = wasm.__externref_table_alloc();
10
- wasm.__wbindgen_export_2.set(idx, obj);
11
- return idx;
12
- }
13
-
14
- function handleError(f, args) {
15
- try {
16
- return f.apply(this, args);
17
- } catch (e) {
18
- const idx = addToExternrefTable0(e);
19
- wasm.__wbindgen_exn_store(idx);
20
- }
21
- }
22
-
23
- function debugString(val) {
24
- // primitive types
25
- const type = typeof val;
26
- if (type == 'number' || type == 'boolean' || val == null) {
27
- return `${val}`;
28
- }
29
- if (type == 'string') {
30
- return `"${val}"`;
31
- }
32
- if (type == 'symbol') {
33
- const description = val.description;
34
- if (description == null) {
35
- return 'Symbol';
36
- } else {
37
- return `Symbol(${description})`;
38
- }
39
- }
40
- if (type == 'function') {
41
- const name = val.name;
42
- if (typeof name == 'string' && name.length > 0) {
43
- return `Function(${name})`;
44
- } else {
45
- return 'Function';
46
- }
47
- }
48
- // objects
49
- if (Array.isArray(val)) {
50
- const length = val.length;
51
- let debug = '[';
52
- if (length > 0) {
53
- debug += debugString(val[0]);
54
- }
55
- for(let i = 1; i < length; i++) {
56
- debug += ', ' + debugString(val[i]);
57
- }
58
- debug += ']';
59
- return debug;
60
- }
61
- // Test for built-in
62
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
63
- let className;
64
- if (builtInMatches && builtInMatches.length > 1) {
65
- className = builtInMatches[1];
66
- } else {
67
- // Failed to match the standard '[object ClassName]'
68
- return toString.call(val);
69
- }
70
- if (className == 'Object') {
71
- // we're a user defined class or Object
72
- // JSON.stringify avoids problems with cycles, and is generally much
73
- // easier than looping through ownProperties of `val`.
74
- try {
75
- return 'Object(' + JSON.stringify(val) + ')';
76
- } catch (_) {
77
- return 'Object';
78
- }
79
- }
80
- // errors
81
- if (val instanceof Error) {
82
- return `${val.name}: ${val.message}\n${val.stack}`;
83
- }
84
- // TODO we could test for more things here, like `Set`s and `Map`s.
85
- return className;
86
- }
87
-
88
- let WASM_VECTOR_LEN = 0;
89
-
90
- let cachedUint8ArrayMemory0 = null;
91
-
92
- function getUint8ArrayMemory0() {
93
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
94
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
95
- }
96
- return cachedUint8ArrayMemory0;
97
- }
98
-
99
- const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
100
-
101
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
102
- ? function (arg, view) {
103
- return cachedTextEncoder.encodeInto(arg, view);
104
- }
105
- : function (arg, view) {
106
- const buf = cachedTextEncoder.encode(arg);
107
- view.set(buf);
108
- return {
109
- read: arg.length,
110
- written: buf.length
111
- };
112
- });
113
-
114
- function passStringToWasm0(arg, malloc, realloc) {
115
-
116
- if (realloc === undefined) {
117
- const buf = cachedTextEncoder.encode(arg);
118
- const ptr = malloc(buf.length, 1) >>> 0;
119
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
120
- WASM_VECTOR_LEN = buf.length;
121
- return ptr;
122
- }
123
-
124
- let len = arg.length;
125
- let ptr = malloc(len, 1) >>> 0;
126
-
127
- const mem = getUint8ArrayMemory0();
128
-
129
- let offset = 0;
130
-
131
- for (; offset < len; offset++) {
132
- const code = arg.charCodeAt(offset);
133
- if (code > 0x7F) break;
134
- mem[ptr + offset] = code;
135
- }
136
-
137
- if (offset !== len) {
138
- if (offset !== 0) {
139
- arg = arg.slice(offset);
140
- }
141
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
142
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
143
- const ret = encodeString(arg, view);
144
-
145
- offset += ret.written;
146
- ptr = realloc(ptr, len, offset, 1) >>> 0;
147
- }
148
-
149
- WASM_VECTOR_LEN = offset;
150
- return ptr;
151
- }
152
-
153
- let cachedDataViewMemory0 = null;
154
-
155
- function getDataViewMemory0() {
156
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
157
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
158
- }
159
- return cachedDataViewMemory0;
160
- }
161
-
162
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
163
-
164
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
165
- function getStringFromWasm0(ptr, len) {
166
- ptr = ptr >>> 0;
167
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
168
- }
169
-
170
- function isLikeNone(x) {
171
- return x === undefined || x === null;
172
- }
173
-
174
- function takeFromExternrefTable0(idx) {
175
- const value = wasm.__wbindgen_export_2.get(idx);
176
- wasm.__externref_table_dealloc(idx);
177
- return value;
178
- }
179
- /**
180
- * @param {any} config_val
181
- * @returns {any}
182
- */
183
- function transform_modules(config_val) {
184
- const ret = wasm.transform_modules(config_val);
185
- if (ret[2]) {
186
- throw takeFromExternrefTable0(ret[1]);
187
- }
188
- return takeFromExternrefTable0(ret[0]);
189
- }
190
-
191
- async function __wbg_load(module, imports) {
192
- if (typeof Response === 'function' && module instanceof Response) {
193
- if (typeof WebAssembly.instantiateStreaming === 'function') {
194
- try {
195
- return await WebAssembly.instantiateStreaming(module, imports);
196
-
197
- } catch (e) {
198
- if (module.headers.get('Content-Type') != 'application/wasm') {
199
- console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
200
-
201
- } else {
202
- throw e;
203
- }
204
- }
205
- }
206
-
207
- const bytes = await module.arrayBuffer();
208
- return await WebAssembly.instantiate(bytes, imports);
209
-
210
- } else {
211
- const instance = await WebAssembly.instantiate(module, imports);
212
-
213
- if (instance instanceof WebAssembly.Instance) {
214
- return { instance, module };
215
-
216
- } else {
217
- return instance;
218
- }
219
- }
220
- }
221
-
222
- function __wbg_get_imports() {
223
- const imports = {};
224
- imports.wbg = {};
225
- imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
226
- const ret = arg0.buffer;
227
- return ret;
228
- };
229
- imports.wbg.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
230
- const ret = arg0.call(arg1);
231
- return ret;
232
- }, arguments) };
233
- imports.wbg.__wbg_done_769e5ede4b31c67b = function(arg0) {
234
- const ret = arg0.done;
235
- return ret;
236
- };
237
- imports.wbg.__wbg_entries_3265d4158b33e5dc = function(arg0) {
238
- const ret = Object.entries(arg0);
239
- return ret;
240
- };
241
- imports.wbg.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
242
- const ret = Reflect.get(arg0, arg1);
243
- return ret;
244
- }, arguments) };
245
- imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
246
- const ret = arg0[arg1 >>> 0];
247
- return ret;
248
- };
249
- imports.wbg.__wbg_getwithrefkey_1dc361bd10053bfe = function(arg0, arg1) {
250
- const ret = arg0[arg1];
251
- return ret;
252
- };
253
- imports.wbg.__wbg_instanceof_ArrayBuffer_e14585432e3737fc = function(arg0) {
254
- let result;
255
- try {
256
- result = arg0 instanceof ArrayBuffer;
257
- } catch (_) {
258
- result = false;
259
- }
260
- const ret = result;
261
- return ret;
262
- };
263
- imports.wbg.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function(arg0) {
264
- let result;
265
- try {
266
- result = arg0 instanceof Uint8Array;
267
- } catch (_) {
268
- result = false;
269
- }
270
- const ret = result;
271
- return ret;
272
- };
273
- imports.wbg.__wbg_isArray_a1eab7e0d067391b = function(arg0) {
274
- const ret = Array.isArray(arg0);
275
- return ret;
276
- };
277
- imports.wbg.__wbg_iterator_9a24c88df860dc65 = function() {
278
- const ret = Symbol.iterator;
279
- return ret;
280
- };
281
- imports.wbg.__wbg_length_a446193dc22c12f8 = function(arg0) {
282
- const ret = arg0.length;
283
- return ret;
284
- };
285
- imports.wbg.__wbg_length_e2d2a49132c1b256 = function(arg0) {
286
- const ret = arg0.length;
287
- return ret;
288
- };
289
- imports.wbg.__wbg_new_405e22f390576ce2 = function() {
290
- const ret = new Object();
291
- return ret;
292
- };
293
- imports.wbg.__wbg_new_78feb108b6472713 = function() {
294
- const ret = new Array();
295
- return ret;
296
- };
297
- imports.wbg.__wbg_new_a12002a7f91c75be = function(arg0) {
298
- const ret = new Uint8Array(arg0);
299
- return ret;
300
- };
301
- imports.wbg.__wbg_next_25feadfc0913fea9 = function(arg0) {
302
- const ret = arg0.next;
303
- return ret;
304
- };
305
- imports.wbg.__wbg_next_6574e1a8a62d1055 = function() { return handleError(function (arg0) {
306
- const ret = arg0.next();
307
- return ret;
308
- }, arguments) };
309
- imports.wbg.__wbg_set_37837023f3d740e8 = function(arg0, arg1, arg2) {
310
- arg0[arg1 >>> 0] = arg2;
311
- };
312
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
313
- arg0[arg1] = arg2;
314
- };
315
- imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
316
- arg0.set(arg1, arg2 >>> 0);
317
- };
318
- imports.wbg.__wbg_value_cd1ffa7b1ab794f1 = function(arg0) {
319
- const ret = arg0.value;
320
- return ret;
321
- };
322
- imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
323
- const ret = BigInt.asUintN(64, arg0);
324
- return ret;
325
- };
326
- imports.wbg.__wbindgen_boolean_get = function(arg0) {
327
- const v = arg0;
328
- const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
329
- return ret;
330
- };
331
- imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
332
- const ret = debugString(arg1);
333
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
334
- const len1 = WASM_VECTOR_LEN;
335
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
336
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
337
- };
338
- imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
339
- const ret = new Error(getStringFromWasm0(arg0, arg1));
340
- return ret;
341
- };
342
- imports.wbg.__wbindgen_in = function(arg0, arg1) {
343
- const ret = arg0 in arg1;
344
- return ret;
345
- };
346
- imports.wbg.__wbindgen_init_externref_table = function() {
347
- const table = wasm.__wbindgen_export_2;
348
- const offset = table.grow(4);
349
- table.set(0, undefined);
350
- table.set(offset + 0, undefined);
351
- table.set(offset + 1, null);
352
- table.set(offset + 2, true);
353
- table.set(offset + 3, false);
354
- };
355
- imports.wbg.__wbindgen_is_function = function(arg0) {
356
- const ret = typeof(arg0) === 'function';
357
- return ret;
358
- };
359
- imports.wbg.__wbindgen_is_object = function(arg0) {
360
- const val = arg0;
361
- const ret = typeof(val) === 'object' && val !== null;
362
- return ret;
363
- };
364
- imports.wbg.__wbindgen_is_string = function(arg0) {
365
- const ret = typeof(arg0) === 'string';
366
- return ret;
367
- };
368
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
369
- const ret = arg0 === undefined;
370
- return ret;
371
- };
372
- imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
373
- const ret = arg0 == arg1;
374
- return ret;
375
- };
376
- imports.wbg.__wbindgen_memory = function() {
377
- const ret = wasm.memory;
378
- return ret;
379
- };
380
- imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
381
- const obj = arg1;
382
- const ret = typeof(obj) === 'number' ? obj : undefined;
383
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
384
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
385
- };
386
- imports.wbg.__wbindgen_number_new = function(arg0) {
387
- const ret = arg0;
388
- return ret;
389
- };
390
- imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
391
- const obj = arg1;
392
- const ret = typeof(obj) === 'string' ? obj : undefined;
393
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
394
- var len1 = WASM_VECTOR_LEN;
395
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
396
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
397
- };
398
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
399
- const ret = getStringFromWasm0(arg0, arg1);
400
- return ret;
401
- };
402
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
403
- throw new Error(getStringFromWasm0(arg0, arg1));
404
- };
405
-
406
- return imports;
407
- }
408
-
409
- function __wbg_finalize_init(instance, module) {
410
- wasm = instance.exports;
411
- __wbg_init.__wbindgen_wasm_module = module;
412
- cachedDataViewMemory0 = null;
413
- cachedUint8ArrayMemory0 = null;
414
-
415
-
416
- wasm.__wbindgen_start();
417
- return wasm;
418
- }
419
-
420
- function initSync(module) {
421
- if (wasm !== undefined) return wasm;
422
-
423
-
424
- if (typeof module !== 'undefined') {
425
- if (Object.getPrototypeOf(module) === Object.prototype) {
426
- ({module} = module);
427
- } else {
428
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead');
429
- }
430
- }
431
-
432
- const imports = __wbg_get_imports();
433
-
434
- if (!(module instanceof WebAssembly.Module)) {
435
- module = new WebAssembly.Module(module);
436
- }
437
-
438
- const instance = new WebAssembly.Instance(module, imports);
439
-
440
- return __wbg_finalize_init(instance, module);
441
- }
442
-
443
- async function __wbg_init(module_or_path) {
444
- if (wasm !== undefined) return wasm;
445
-
446
-
447
- if (typeof module_or_path !== 'undefined') {
448
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
449
- ({module_or_path} = module_or_path);
450
- } else {
451
- console.warn('using deprecated parameters for the initialization function; pass a single object instead');
452
- }
453
- }
454
-
455
- if (typeof module_or_path === 'undefined') {
456
- module_or_path = new URL('qwik_wasm_bg.wasm', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('qwik.wasm.cjs', document.baseURI).href)));
457
- }
458
- const imports = __wbg_get_imports();
459
-
460
- if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
461
- module_or_path = fetch(module_or_path);
462
- }
463
-
464
- const { instance, module } = await __wbg_load(await module_or_path, imports);
465
-
466
- return __wbg_finalize_init(instance, module);
467
- }
468
-
469
- exports.default = __wbg_init;
470
- exports.initSync = initSync;
471
- exports.transform_modules = transform_modules;
@@ -1,37 +0,0 @@
1
- {
2
- "description": "Add i18n $localize in your Qwik app",
3
- "__qwik__": {
4
- "displayName": "Integration: i18n $localize (compile time translations)",
5
- "priority": -10,
6
- "viteConfig": {},
7
- "docs": [
8
- "https://qwik.dev/docs/integrations/i18n/#localize",
9
- "https://github.com/mhevery/qwik-i18n",
10
- "https://angular.io/api/localize/init/$localize"
11
- ],
12
- "nextSteps": {
13
- "title": "Next Steps",
14
- "lines": [
15
- " - /src/routes/[locale]: New public route showcasing i18n $localize integration",
16
- "",
17
- " Check out the i18n $localize docs for more info:",
18
- " - https://qwik.dev/docs/integrations/i18n/#localize",
19
- " - https://github.com/mhevery/qwik-i18n",
20
- " - https://angular.io/api/localize/init/$localize"
21
- ]
22
- }
23
- },
24
- "dependencies": {
25
- "@angular/localize": "^18.2.13"
26
- },
27
- "devDependencies": {
28
- "@angular/compiler": "^18.2.13",
29
- "@angular/compiler-cli": "^18.2.13"
30
- },
31
- "scripts": {
32
- "build.client": "vite build && npm run i18n-translate",
33
- "prei18n-extract": "vite build",
34
- "i18n-extract": "node_modules/.bin/localize-extract -s \"dist/build/*.js\" -f json -o src/locales/message.en.json",
35
- "i18n-translate": "node_modules/.bin/localize-translate -s \"*.js\" -t src/locales/message.*.json -o dist/build/{{LOCALE}} -r ./dist/build"
36
- }
37
- }
@@ -1,8 +0,0 @@
1
- {
2
- "locale": "en",
3
- "translations": {
4
- "1573294495032945047": "Hello from {$PH}!",
5
- "8569626659814641312": "Use the following links to change the translation.",
6
- "6563882999249543998": "Translation is performed as part of the build step so translated strings are inlined into the application, there is no need to load or look them up at runtime. However, these advantages mean that the user cannot change the language without refreshing the page."
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- {
2
- "locale": "it",
3
- "translations": {
4
- "1573294495032945047": "Un saluto da {$PH}!",
5
- "8569626659814641312": "Usa i seguenti link per cambiare la traduzione.",
6
- "6563882999249543998": "La traduzione viene eseguita come parte della fase di build e le stringhe tradotte vengono integrate nell'applicazione, non è necessario caricarle o cercarle in fase di runtime.\nTuttavia, questi vantaggi significano che l'utente non può cambiare la lingua senza ricaricare la pagina."
7
- }
8
- }
@@ -1,94 +0,0 @@
1
- import { loadTranslations } from "@angular/localize";
2
- import "@angular/localize/init";
3
- import { $, getLocale, useOnDocument, withLocale } from "@qwik.dev/core";
4
- import type { RenderOptions } from "@qwik.dev/core/server";
5
-
6
- // You must declare all your locales here
7
- import EN from "../../locales/message.en.json";
8
- import IT from "../../locales/message.it.json";
9
-
10
- // Make sure it's obvious when the default locale was selected
11
- const DEFAULT_LOCALE = "en";
12
-
13
- /**
14
- * This file is left for the developer to customize to get the behavior they want for localization.
15
- */
16
-
17
- /// Declare location where extra types will be stored.
18
- const $localizeFn = $localize as any as {
19
- TRANSLATIONS: Record<string, any>;
20
- TRANSLATION_BY_LOCALE: Map<string, Record<string, any>>;
21
- };
22
-
23
- /**
24
- * This solution uses the `@angular/localize` package for translations, however out of the box
25
- * `$localize` works with a single translation only. This code adds support for multiple locales
26
- * concurrently. It does this by intercepting the `TRANSLATIONS` property read and returning
27
- * appropriate translation based on the current locale which is store in the `usEnvDate('local')`.
28
- */
29
-
30
- if (!$localizeFn.TRANSLATION_BY_LOCALE) {
31
- $localizeFn.TRANSLATION_BY_LOCALE = new Map([["", {}]]);
32
- Object.defineProperty($localize, "TRANSLATIONS", {
33
- get: function () {
34
- const locale = getLocale(DEFAULT_LOCALE);
35
- let translations = $localizeFn.TRANSLATION_BY_LOCALE.get(locale);
36
- if (!translations) {
37
- $localizeFn.TRANSLATION_BY_LOCALE.set(locale, (translations = {}));
38
- }
39
- return translations;
40
- },
41
- });
42
- }
43
-
44
- /**
45
- * Function used to load all translations variants.
46
- */
47
- export function initTranslations() {
48
- [EN, IT].forEach(({ translations, locale }) => {
49
- withLocale(locale, () => loadTranslations(translations));
50
- });
51
- }
52
-
53
- /**
54
- * Function used to examine the request and determine the locale to use.
55
- *
56
- * This function is meant to be used with `RenderOptions.locale` property
57
- *
58
- * @returns The locale to use which will be stored in the `useEnvData('locale')`.
59
- */
60
- export function extractLang(locale: string): string {
61
- return locale && $localizeFn.TRANSLATION_BY_LOCALE.has(locale)
62
- ? locale
63
- : DEFAULT_LOCALE;
64
- }
65
-
66
- /**
67
- * Function used to determine the base URL to use for loading the chunks in the browser.
68
- *
69
- * The function returns `/build` in dev mode or `/build/<locale>` in prod mode.
70
- *
71
- * This function is meant to be used with `RenderOptions.base` property
72
- *
73
- * @returns The base URL to use for loading the chunks in the browser.
74
- */
75
- export function extractBase({ serverData }: RenderOptions): string {
76
- if (import.meta.env.DEV) {
77
- return `${import.meta.env.BASE_URL}build`;
78
- } else {
79
- return `${import.meta.env.BASE_URL}build/` + serverData!.locale;
80
- }
81
- }
82
-
83
- export function useI18n() {
84
- if (import.meta.env.DEV) {
85
- // During development only, load all translations in memory when the app starts on the client.
86
-
87
- useOnDocument("qinit", $(initTranslations));
88
- }
89
- }
90
-
91
- // We always need the translations on the server
92
- if (import.meta.env.SSR) {
93
- initTranslations();
94
- }