@inlang/paraglide-js 2.8.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -30
- package/dist/bundler-plugins/rollup.d.ts +1 -1
- package/dist/bundler-plugins/rollup.d.ts.map +1 -1
- package/dist/bundler-plugins/unplugin.d.ts.map +1 -1
- package/dist/bundler-plugins/unplugin.js +5 -0
- package/dist/bundler-plugins/unplugin.js.map +1 -1
- package/dist/compiler/compile-bundle.js +1 -1
- package/dist/compiler/compile-bundle.js.map +1 -1
- package/dist/compiler/compile-bundle.test.js +2 -2
- package/dist/compiler/compile-local-variable.d.ts.map +1 -1
- package/dist/compiler/compile-local-variable.js +2 -1
- package/dist/compiler/compile-local-variable.js.map +1 -1
- package/dist/compiler/compile-local-variable.test.js +14 -0
- package/dist/compiler/compile-local-variable.test.js.map +1 -1
- package/dist/compiler/compile-message.d.ts.map +1 -1
- package/dist/compiler/compile-message.js +2 -1
- package/dist/compiler/compile-message.js.map +1 -1
- package/dist/compiler/compile-message.test.js +36 -0
- package/dist/compiler/compile-message.test.js.map +1 -1
- package/dist/compiler/compile-pattern.d.ts.map +1 -1
- package/dist/compiler/compile-pattern.js +2 -1
- package/dist/compiler/compile-pattern.js.map +1 -1
- package/dist/compiler/compile-pattern.test.js +17 -0
- package/dist/compiler/compile-pattern.test.js.map +1 -1
- package/dist/compiler/compile-project.d.ts.map +1 -1
- package/dist/compiler/compile-project.js +2 -0
- package/dist/compiler/compile-project.js.map +1 -1
- package/dist/compiler/compile-project.test.js +36 -1
- package/dist/compiler/compile-project.test.js.map +1 -1
- package/dist/compiler/compiler-options.d.ts +34 -0
- package/dist/compiler/compiler-options.d.ts.map +1 -1
- package/dist/compiler/create-paraglide.d.ts.map +1 -1
- package/dist/compiler/create-paraglide.js +2 -0
- package/dist/compiler/create-paraglide.js.map +1 -1
- package/dist/compiler/create-readme.js +1 -1
- package/dist/compiler/jsdoc-types.d.ts.map +1 -1
- package/dist/compiler/jsdoc-types.js +5 -1
- package/dist/compiler/jsdoc-types.js.map +1 -1
- package/dist/compiler/jsdoc-types.test.js +7 -0
- package/dist/compiler/jsdoc-types.test.js.map +1 -1
- package/dist/compiler/output-structure/locale-modules.d.ts.map +1 -1
- package/dist/compiler/output-structure/locale-modules.js +4 -3
- package/dist/compiler/output-structure/locale-modules.js.map +1 -1
- package/dist/compiler/output-structure/locale-modules.test.js +28 -1
- package/dist/compiler/output-structure/locale-modules.test.js.map +1 -1
- package/dist/compiler/output-structure/message-modules.js +1 -1
- package/dist/compiler/output-structure/message-modules.js.map +1 -1
- package/dist/compiler/runtime/create-runtime.d.ts +1 -0
- package/dist/compiler/runtime/create-runtime.d.ts.map +1 -1
- package/dist/compiler/runtime/create-runtime.js +1 -0
- package/dist/compiler/runtime/create-runtime.js.map +1 -1
- package/dist/compiler/runtime/generate-static-localized-urls.d.ts +36 -15
- package/dist/compiler/runtime/generate-static-localized-urls.d.ts.map +1 -1
- package/dist/compiler/runtime/generate-static-localized-urls.js +36 -15
- package/dist/compiler/runtime/generate-static-localized-urls.js.map +1 -1
- package/dist/compiler/runtime/get-locale.d.ts +12 -6
- package/dist/compiler/runtime/get-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/get-locale.js +16 -7
- package/dist/compiler/runtime/get-locale.js.map +1 -1
- package/dist/compiler/runtime/get-locale.test.js +13 -0
- package/dist/compiler/runtime/get-locale.test.js.map +1 -1
- package/dist/compiler/runtime/localize-href.d.ts +4 -1
- package/dist/compiler/runtime/localize-href.d.ts.map +1 -1
- package/dist/compiler/runtime/localize-href.js +4 -1
- package/dist/compiler/runtime/localize-href.js.map +1 -1
- package/dist/compiler/runtime/localize-url.d.ts +4 -0
- package/dist/compiler/runtime/localize-url.d.ts.map +1 -1
- package/dist/compiler/runtime/localize-url.js +4 -0
- package/dist/compiler/runtime/localize-url.js.map +1 -1
- package/dist/compiler/runtime/set-locale.d.ts +8 -6
- package/dist/compiler/runtime/set-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/set-locale.js +8 -6
- package/dist/compiler/runtime/set-locale.js.map +1 -1
- package/dist/compiler/runtime/should-redirect.d.ts +2 -0
- package/dist/compiler/runtime/should-redirect.d.ts.map +1 -1
- package/dist/compiler/runtime/should-redirect.js +2 -0
- package/dist/compiler/runtime/should-redirect.js.map +1 -1
- package/dist/compiler/runtime/strategy.d.ts +4 -0
- package/dist/compiler/runtime/strategy.d.ts.map +1 -1
- package/dist/compiler/runtime/strategy.js +4 -0
- package/dist/compiler/runtime/strategy.js.map +1 -1
- package/dist/compiler/runtime/type.d.ts +1 -0
- package/dist/compiler/runtime/type.d.ts.map +1 -1
- package/dist/compiler/runtime/variables.d.ts +2 -0
- package/dist/compiler/runtime/variables.d.ts.map +1 -1
- package/dist/compiler/runtime/variables.js +3 -0
- package/dist/compiler/runtime/variables.js.map +1 -1
- package/dist/compiler/server/create-server-file.d.ts +1 -0
- package/dist/compiler/server/create-server-file.d.ts.map +1 -1
- package/dist/compiler/server/create-server-file.js +29 -1
- package/dist/compiler/server/create-server-file.js.map +1 -1
- package/dist/compiler/server/middleware.d.ts +2 -0
- package/dist/compiler/server/middleware.d.ts.map +1 -1
- package/dist/compiler/server/middleware.js +5 -7
- package/dist/compiler/server/middleware.js.map +1 -1
- package/dist/compiler/variable-access.d.ts +4 -0
- package/dist/compiler/variable-access.d.ts.map +1 -0
- package/dist/compiler/variable-access.js +15 -0
- package/dist/compiler/variable-access.js.map +1 -0
- package/dist/services/env-variables/index.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/variables.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/variables.js"],"names":[],"mappings":"AA4EA;;;;;;;;;GASG;AACH,wDAFW,0BAA0B,GAAG,SAAS,QAIhD;AAxFD;;;;;;;GAO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AC,CAAA;KAAC,EAC3E,EAAE,EAAE,GAAG,KAAK,GAAG,CAAA;CACjB"}
|
|
@@ -57,6 +57,9 @@ export let serverAsyncLocalStorage = undefined;
|
|
|
57
57
|
export const disableAsyncLocalStorage = false;
|
|
58
58
|
export const experimentalMiddlewareLocaleSplitting = false;
|
|
59
59
|
export const isServer = typeof window === "undefined";
|
|
60
|
+
/** @type {Locale | undefined} */
|
|
61
|
+
// @ts-ignore - injected by bundlers at compile time
|
|
62
|
+
export const experimentalStaticLocale = undefined;
|
|
60
63
|
/**
|
|
61
64
|
* Sets the server side async local storage.
|
|
62
65
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.js","sourceRoot":"","sources":["../../../src/compiler/runtime/variables.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,oBAAoB,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAE3D,qBAAqB;AACrB,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC;AAE1C,qBAAqB;AACrB,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;AAE/C,qBAAqB;AACrB,MAAM,CAAC,MAAM,YAAY,GAAG,iBAAiB,CAAC;AAE9C,qBAAqB;AACrB,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAE9B;;;;;;;;;;GAUG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,IAAI,uBAAuB,GAAG,SAAS,CAAC;AAE/C,MAAM,CAAC,MAAM,wBAAwB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W,GAAG,EAAE,CAAC;AAE9B;;;;;;;;;;GAUG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,IAAI,uBAAuB,GAAG,SAAS,CAAC;AAE/C,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAE9C,MAAM,CAAC,MAAM,qCAAqC,GAAG,KAAK,CAAC;AAE3D,MAAM,CAAC,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAEtD,iCAAiC;AACjC,oDAAoD;AACpD,MAAM,CAAC,MAAM,wBAAwB,GAAG,SAAS,CAAC;AAElD;;;;;;;;;GASG;AACH,MAAM,UAAU,gCAAgC,CAAC,KAAK;IACrD,uBAAuB,GAAG,KAAK,CAAC;AACjC,CAAC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,CAAC;AAErD,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC;AAElD,MAAM,CAAC,MAAM,wCAAwC,GAAG,KAAK,CAAC;AAE9D,MAAM,CAAC,MAAM,2CAA2C,GAAG,KAAK,CAAC;AAEjE,MAAM,CAAC,MAAM,mCAAmC,GAAG,KAAK,CAAC;AAEzD,MAAM,CAAC,MAAM,sCAAsC,GAAG,KAAK,CAAC"}
|
|
@@ -7,6 +7,7 @@ export declare function createServerFile(args: {
|
|
|
7
7
|
compiledBundles: CompiledBundleWithMessages[];
|
|
8
8
|
compilerOptions: {
|
|
9
9
|
experimentalMiddlewareLocaleSplitting: NonNullable<CompilerOptions["experimentalMiddlewareLocaleSplitting"]>;
|
|
10
|
+
disableAsyncLocalStorage: NonNullable<CompilerOptions["disableAsyncLocalStorage"]>;
|
|
10
11
|
};
|
|
11
12
|
}): string;
|
|
12
13
|
//# sourceMappingURL=create-server-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-server-file.d.ts","sourceRoot":"","sources":["../../../src/compiler/server/create-server-file.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACtC,eAAe,EAAE,0BAA0B,EAAE,CAAC;IAC9C,eAAe,EAAE;QAChB,qCAAqC,EAAE,WAAW,CACjD,eAAe,CAAC,uCAAuC,CAAC,CACxD,CAAC;KACF,CAAC;CACF,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"create-server-file.d.ts","sourceRoot":"","sources":["../../../src/compiler/server/create-server-file.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACtC,eAAe,EAAE,0BAA0B,EAAE,CAAC;IAC9C,eAAe,EAAE;QAChB,qCAAqC,EAAE,WAAW,CACjD,eAAe,CAAC,uCAAuC,CAAC,CACxD,CAAC;QACF,wBAAwB,EAAE,WAAW,CACpC,eAAe,CAAC,0BAA0B,CAAC,CAC3C,CAAC;KACF,CAAC;CACF,GAAG,MAAM,CAiDT"}
|
|
@@ -9,10 +9,38 @@ import * as runtime from "./runtime.js";
|
|
|
9
9
|
|
|
10
10
|
${injectCode("./middleware.js")}
|
|
11
11
|
`;
|
|
12
|
+
const asyncLocalStorageMarker = "// %async-local-storage";
|
|
13
|
+
const markerIndex = code.indexOf(asyncLocalStorageMarker);
|
|
14
|
+
if (markerIndex === -1) {
|
|
15
|
+
throw new Error("Expected a single %async-local-storage marker in server middleware.");
|
|
16
|
+
}
|
|
17
|
+
const lineStart = code.lastIndexOf("\n", markerIndex) + 1;
|
|
18
|
+
const indent = code.slice(lineStart, markerIndex).replace(/\t/g, " ");
|
|
19
|
+
const innerIndent = `${indent} `;
|
|
20
|
+
const asyncLocalStorageBlock = args.compilerOptions.disableAsyncLocalStorage
|
|
21
|
+
? [
|
|
22
|
+
`${indent}if (!runtime.serverAsyncLocalStorage) {`,
|
|
23
|
+
`${innerIndent}runtime.overwriteServerAsyncLocalStorage(createMockAsyncLocalStorage());`,
|
|
24
|
+
`${indent}}`,
|
|
25
|
+
]
|
|
26
|
+
: [
|
|
27
|
+
`${indent}if (!runtime.disableAsyncLocalStorage && !runtime.serverAsyncLocalStorage) {`,
|
|
28
|
+
`${innerIndent}const { AsyncLocalStorage } = await import("async_hooks");`,
|
|
29
|
+
`${innerIndent}runtime.overwriteServerAsyncLocalStorage(new AsyncLocalStorage());`,
|
|
30
|
+
`${indent}} else if (!runtime.serverAsyncLocalStorage) {`,
|
|
31
|
+
`${innerIndent}runtime.overwriteServerAsyncLocalStorage(createMockAsyncLocalStorage());`,
|
|
32
|
+
`${indent}}`,
|
|
33
|
+
];
|
|
34
|
+
const lineEnd = code.indexOf("\n", markerIndex);
|
|
35
|
+
const endOfMarkerLine = lineEnd === -1 ? code.length : lineEnd + 1;
|
|
36
|
+
code =
|
|
37
|
+
code.slice(0, lineStart) +
|
|
38
|
+
`${asyncLocalStorageBlock.join("\n")}\n` +
|
|
39
|
+
code.slice(endOfMarkerLine);
|
|
12
40
|
if (args.compilerOptions.experimentalMiddlewareLocaleSplitting) {
|
|
13
41
|
code = code.replace("const compiledBundles = {};", `const compiledBundles = ${JSON.stringify(createCompiledMessagesObject(args.compiledBundles))};`);
|
|
14
42
|
}
|
|
15
|
-
return code;
|
|
43
|
+
return code.replace(/\t/g, " ");
|
|
16
44
|
}
|
|
17
45
|
function createCompiledMessagesObject(compiledBundles) {
|
|
18
46
|
const result = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-server-file.js","sourceRoot":"","sources":["../../../src/compiler/server/create-server-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"create-server-file.js","sourceRoot":"","sources":["../../../src/compiler/server/create-server-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAUhC;IACA,IAAI,IAAI,GAAG;;;EAGV,UAAU,CAAC,iBAAiB,CAAC;CAC9B,CAAC;IAED,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;IAC1D,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC1D,IAAI,WAAW,KAAK,CAAC,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACd,qEAAqE,CACrE,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG,GAAG,MAAM,IAAI,CAAC;IAClC,MAAM,sBAAsB,GAAG,IAAI,CAAC,eAAe,CAAC,wBAAwB;QAC3E,CAAC,CAAC;YACA,GAAG,MAAM,yCAAyC;YAClD,GAAG,WAAW,0EAA0E;YACxF,GAAG,MAAM,GAAG;SACZ;QACF,CAAC,CAAC;YACA,GAAG,MAAM,8EAA8E;YACvF,GAAG,WAAW,4DAA4D;YAC1E,GAAG,WAAW,oEAAoE;YAClF,GAAG,MAAM,gDAAgD;YACzD,GAAG,WAAW,0EAA0E;YACxF,GAAG,MAAM,GAAG;SACZ,CAAC;IAEJ,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IA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EAAE,CAAC;iBAC9C,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACrB,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,UAAU,CAAC,IAAY;IAC/B,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;IACtE,oDAAoD;IACpD,MAAM,WAAW,GAAG,8CAA8C,CAAC;IACnE,MAAM,cAAc,GAAG,8BAA8B,CAAC;IACtD,MAAM,mBAAmB,GAAG,iCAAiC,CAAC;IAC9D,OAAO,IAAI;SACT,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;SACxB,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SAC3B,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;SAChC,IAAI,EAAE,CAAC;AACV,CAAC"}
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* - If URL doesn't match the determined locale, redirects to localized URL (only for document requests)
|
|
14
14
|
* - De-localizes URLs before passing to server (e.g., `/fr/about` → `/about`)
|
|
15
15
|
*
|
|
16
|
+
* @see https://inlang.com/m/gerre34r/library-inlang-paraglideJs/middleware
|
|
17
|
+
*
|
|
16
18
|
* @template T - The return type of the resolve function
|
|
17
19
|
*
|
|
18
20
|
* @param {Request} request - The incoming request object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/compiler/server/middleware.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/compiler/server/middleware.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkGG;AACH,oCAlFa,CAAC,WAEH,OAAO,WACP,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,cAAc,EAAE,MAAM,CAAA;CAAE,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,cAKrF;IAAE,UAAU,EAAC,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAA;CAAE,GACzC,OAAO,CAAC,QAAQ,CAAC,CA+K7B"}
|
|
@@ -14,6 +14,8 @@ import * as runtime from "./runtime.js";
|
|
|
14
14
|
* - If URL doesn't match the determined locale, redirects to localized URL (only for document requests)
|
|
15
15
|
* - De-localizes URLs before passing to server (e.g., `/fr/about` → `/about`)
|
|
16
16
|
*
|
|
17
|
+
* @see https://inlang.com/m/gerre34r/library-inlang-paraglideJs/middleware
|
|
18
|
+
*
|
|
17
19
|
* @template T - The return type of the resolve function
|
|
18
20
|
*
|
|
19
21
|
* @param {Request} request - The incoming request object
|
|
@@ -97,13 +99,7 @@ import * as runtime from "./runtime.js";
|
|
|
97
99
|
* ```
|
|
98
100
|
*/
|
|
99
101
|
export async function paraglideMiddleware(request, resolve, callbacks) {
|
|
100
|
-
|
|
101
|
-
const { AsyncLocalStorage } = await import("async_hooks");
|
|
102
|
-
runtime.overwriteServerAsyncLocalStorage(new AsyncLocalStorage());
|
|
103
|
-
}
|
|
104
|
-
else if (!runtime.serverAsyncLocalStorage) {
|
|
105
|
-
runtime.overwriteServerAsyncLocalStorage(createMockAsyncLocalStorage());
|
|
106
|
-
}
|
|
102
|
+
// %async-local-storage
|
|
107
103
|
const decision = await runtime.shouldRedirect({ request });
|
|
108
104
|
const locale = decision.locale;
|
|
109
105
|
const origin = new URL(request.url).origin;
|
|
@@ -211,6 +207,8 @@ function createMockAsyncLocalStorage() {
|
|
|
211
207
|
},
|
|
212
208
|
};
|
|
213
209
|
}
|
|
210
|
+
// Used in generated server.js when async local storage is disabled.
|
|
211
|
+
void createMockAsyncLocalStorage;
|
|
214
212
|
/**
|
|
215
213
|
* The compiled messages for the server middleware.
|
|
216
214
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/compiler/server/middleware.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/compiler/server/middleware.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS;IACpE,uBAAuB;IAEvB,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC/B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IAE3C,4DAA4D;IAC5D,6DAA6D;IAC7D,IACC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,UAAU;QACpD,QAAQ,CAAC,cAAc;QACvB,QAAQ,CAAC,WAAW,EACnB,CAAC;QACF,+EAA+E;QAC/E,qCAAqC;QACrC,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACpD,OAAO,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAAC;QACrC,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE;YACnC,MAAM,EAA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;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable-access.d.ts","sourceRoot":"","sources":["../../src/compiler/variable-access.ts"],"names":[],"mappings":"AAIA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKvD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { escapeForDoubleQuoteString } from "../services/codegen/escape.js";
|
|
2
|
+
const identifierPattern = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
3
|
+
export function isValidIdentifier(name) {
|
|
4
|
+
return identifierPattern.test(name);
|
|
5
|
+
}
|
|
6
|
+
export function quotePropertyKey(name) {
|
|
7
|
+
return `"${escapeForDoubleQuoteString(name)}"`;
|
|
8
|
+
}
|
|
9
|
+
export function compileInputAccess(name) {
|
|
10
|
+
if (isValidIdentifier(name)) {
|
|
11
|
+
return `i?.${name}`;
|
|
12
|
+
}
|
|
13
|
+
return `i?.[${quotePropertyKey(name)}]`;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=variable-access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable-access.js","sourceRoot":"","sources":["../../src/compiler/variable-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,MAAM,iBAAiB,GAAG,4BAA4B,CAAC;AAEvD,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC7C,OAAO,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,OAAO,IAAI,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC9C,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,MAAM,IAAI,EAAE,CAAC;IACrB,CAAC;IACD,OAAO,OAAO,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC;AACzC,CAAC"}
|