one 1.1.316 → 1.1.318
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/serve.cjs +5 -3
- package/dist/cjs/serve.cjs.map +1 -1
- package/dist/cjs/serve.native.js +5 -3
- package/dist/cjs/serve.native.js.map +2 -2
- package/dist/cjs/utils/getPageExport.cjs +19 -7
- package/dist/cjs/utils/getPageExport.cjs.map +1 -1
- package/dist/cjs/utils/getPageExport.native.js +18 -4
- package/dist/cjs/utils/getPageExport.native.js.map +2 -2
- package/dist/cjs/vite/createFileSystemRouter.cjs +7 -7
- package/dist/cjs/vite/createFileSystemRouter.cjs.map +1 -1
- package/dist/cjs/vite/createFileSystemRouter.native.js +12 -12
- package/dist/cjs/vite/createFileSystemRouter.native.js.map +2 -2
- package/dist/cjs/vite/one.cjs +3 -1
- package/dist/cjs/vite/one.cjs.map +1 -1
- package/dist/cjs/vite/one.native.js +6 -1
- package/dist/cjs/vite/one.native.js.map +2 -2
- package/dist/esm/serve.js +5 -3
- package/dist/esm/serve.js.map +1 -1
- package/dist/esm/serve.mjs +5 -3
- package/dist/esm/serve.mjs.map +1 -1
- package/dist/esm/serve.native.js +5 -3
- package/dist/esm/serve.native.js.map +2 -2
- package/dist/esm/utils/getPageExport.js +13 -2
- package/dist/esm/utils/getPageExport.js.map +1 -1
- package/dist/esm/utils/getPageExport.mjs +19 -7
- package/dist/esm/utils/getPageExport.mjs.map +1 -1
- package/dist/esm/utils/getPageExport.native.js +18 -4
- package/dist/esm/utils/getPageExport.native.js.map +2 -2
- package/dist/esm/vite/createFileSystemRouter.js +9 -9
- package/dist/esm/vite/createFileSystemRouter.js.map +1 -1
- package/dist/esm/vite/createFileSystemRouter.mjs +7 -7
- package/dist/esm/vite/createFileSystemRouter.mjs.map +1 -1
- package/dist/esm/vite/createFileSystemRouter.native.js +12 -12
- package/dist/esm/vite/createFileSystemRouter.native.js.map +2 -2
- package/dist/esm/vite/one.js +12 -1
- package/dist/esm/vite/one.js.map +1 -1
- package/dist/esm/vite/one.mjs +4 -2
- package/dist/esm/vite/one.mjs.map +1 -1
- package/dist/esm/vite/one.native.js +7 -2
- package/dist/esm/vite/one.native.js.map +2 -2
- package/package.json +7 -7
- package/src/serve.ts +5 -2
- package/src/utils/getPageExport.ts +21 -2
- package/src/vite/createFileSystemRouter.tsx +12 -12
- package/src/vite/one.ts +17 -3
- package/src/vite/types.ts +7 -0
- package/types/utils/getPageExport.d.ts +1 -1
- package/types/utils/getPageExport.d.ts.map +1 -1
- package/types/vite/one.d.ts.map +1 -1
- package/types/vite/types.d.ts +6 -0
- package/types/vite/types.d.ts.map +1 -1
@@ -3,7 +3,7 @@ import events from "node:events";
|
|
3
3
|
import path, { dirname, resolve } from "node:path";
|
4
4
|
import { loadConfigFromFile } from "vite";
|
5
5
|
import tsconfigPaths from "vite-tsconfig-paths";
|
6
|
-
import { getOptimizeDeps, getOptionsFilled, isWebEnvironment, loadEnv } from "vxrn";
|
6
|
+
import { autoPreBundleDepsForSsrPlugin, getOptimizeDeps, getOptionsFilled, isWebEnvironment, loadEnv } from "vxrn";
|
7
7
|
import { CACHE_KEY } from "../constants";
|
8
8
|
import "../polyfills-server";
|
9
9
|
import { existsAsync } from "../utils/existsAsync";
|
@@ -17,7 +17,7 @@ import { vitePluginSsrCss } from "./vitePluginSsrCss";
|
|
17
17
|
events.setMaxListeners(1e3);
|
18
18
|
globalThis.__vxrnEnableNativeEnv = !0;
|
19
19
|
function one() {
|
20
|
-
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _options_config;
|
20
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _options_config, _options_ssr;
|
21
21
|
oneOptions = options, ((_options_config = options.config) === null || _options_config === void 0 ? void 0 : _options_config.ensureTSConfig) !== !1 && ensureTSConfig(), globalThis.__vxrnPluginConfig__ = options;
|
22
22
|
var { optimizeDeps } = getOptimizeDeps("build"), optimizeIds = optimizeDeps.include, optimizeIdRegex = new RegExp(
|
23
23
|
// santize ids for regex
|
@@ -34,6 +34,11 @@ function one() {
|
|
34
34
|
};
|
35
35
|
}
|
36
36
|
},
|
37
|
+
...!((_options_ssr = options.ssr) === null || _options_ssr === void 0) && _options_ssr.disableAutoDepsPreBundling ? [] : [
|
38
|
+
autoPreBundleDepsForSsrPlugin({
|
39
|
+
root: vxrnOptions?.root || process.cwd()
|
40
|
+
})
|
41
|
+
],
|
37
42
|
// proxy because you cant add a plugin inside a plugin
|
38
43
|
new Proxy({
|
39
44
|
name: "one:tsconfig-paths",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/vite/Users/n8/one/packages/one/src/vite/one.ts"],
|
4
|
-
"mappings": "AAAA,SAASA,mBAAmB;AAC5B,OAAOC,YAAY;AACnB,OAAOC,QAAQC,SAASC,eAAe;AACvC,SAA0DC,0BAA0B;AACpF,OAAOC,mBAAmB;AAC1B,
|
5
|
-
"names": ["resolvePath", "events", "path", "dirname", "resolve", "loadConfigFromFile", "tsconfigPaths", "getOptimizeDeps", "getOptionsFilled", "isWebEnvironment", "loadEnv", "CACHE_KEY", "existsAsync", "clientTreeShakePlugin", "createFileSystemRouter", "ensureTSConfig", "fixDependenciesPlugin", "generateTypesForRoutes", "createVirtualEntry", "virtualEntryId", "vitePluginSsrCss", "setMaxListeners", "globalThis", "__vxrnEnableNativeEnv", "one", "options", "oneOptions", "config", "optimizeDeps", "optimizeIds", "include", "optimizeIdRegex", "RegExp", "map", "id", "replace", "join", "tsConfigPathsPlugin", "vxrnOptions", "clientEnvDefine", "mode", "devAndProdPlugins", "name", "define", "Proxy", "configIncoming", "pathsConfig", "tsConfigPaths", "plugins", "flat", "some", "p", "configResolved", "resolveId", "get", "target", "key", "thisArg", "Reflect", "enforce", "alias", "tslib", "web", "defaultRenderMode", "JSON", "stringify", "setupFile", "
|
4
|
+
"mappings": "AAAA,SAASA,mBAAmB;AAC5B,OAAOC,YAAY;AACnB,OAAOC,QAAQC,SAASC,eAAe;AACvC,S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UAEX,SAASE,KAAK;AACZC,oBAAQC,KAAK,uBAAuBF,GAAAA;UACtC;QACF;MACF;IACF;IAEAxF,iBAAiB;MACf2F,SAAS;QAAC5F;;IACZ,CAAA;;AAEJ;AAEA,IAAIO,aAAuC;AAE3C,eAAesF,kBAAkBC,SAA2B;AAC1D,MAAI,CAACvF,YAAY;AACf,QAAI,CAACuF,QAAS,OAAM,IAAIC,MAAM,yCAAyC;AACvE,UAAMC,mBAAmBF,OAAAA;EAC3B;AACA,MAAI,CAACvF;AACH,UAAM,IAAIwF,MAAM,4BAA4B;AAE9C,SAAOxF;AACT;AAEA,eAAsByF,mBAAmBF,SAA0B;AACjE,MAAMG,QAAQ,MAAMhH,mBAAmB;IACrCoC,MAAM;IACNyE;EACF,CAAA;AACA,MAAI,CAACG;AACH,UAAM,IAAIF,MAAM,sBAAsBnE,QAAQC,IAAG,CAAA,kCAAoC;AAEvF,MAAMqE,eAAeL,kBAAAA;AACrB,MAAI,CAACK;AACH,UAAM,IAAIH,MAAM,yCAAyC;AAE3D,SAAOG;AACT;",
|
5
|
+
"names": ["resolvePath", "events", "path", "dirname", "resolve", "loadConfigFromFile", "tsconfigPaths", "autoPreBundleDepsForSsrPlugin", "getOptimizeDeps", "getOptionsFilled", "isWebEnvironment", "loadEnv", "CACHE_KEY", "existsAsync", "clientTreeShakePlugin", "createFileSystemRouter", "ensureTSConfig", "fixDependenciesPlugin", "generateTypesForRoutes", "createVirtualEntry", "virtualEntryId", "vitePluginSsrCss", "setMaxListeners", "globalThis", "__vxrnEnableNativeEnv", "one", "options", "oneOptions", "config", "optimizeDeps", "optimizeIds", "include", "optimizeIdRegex", "RegExp", "map", "id", "replace", "join", "tsConfigPathsPlugin", "vxrnOptions", "clientEnvDefine", "mode", "devAndProdPlugins", "name", "define", "ssr", "disableAutoDepsPreBundling", "root", "process", "cwd", "Proxy", "configIncoming", "pathsConfig", "tsConfigPaths", "plugins", "flat", "some", "p", "configResolved", "resolveId", "get", "target", "key", "thisArg", "Reflect", "enforce", "alias", "tslib", "web", "defaultRenderMode", "JSON", "stringify", "setupFile", "env", "NODE_ENV", "server", "url", "environments", "client", "ios", "android", "zero", "TESTING", "REPLICACHE_VERSION", "ZERO_VERSION", "hotUpdate", "modules", "m", "relativePath", "relative", "rootDir", "split", "sep", "acceptedHmrExports", "Set", "__vxrnAddNativePlugins", "__vxrnAddWebPluginsProd", "deps", "app", "sharedNativeConfig", "react", "applyToEnvironment", "environment", "importer", "shouldOptimize", "test", "absolutePath", "webPath", "directoryPath", "err", "console", "warn", "entries", "getUserOneOptions", "command", "Error", "loadUserOneOptions", "found", "foundOptions"]
|
6
6
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "one",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.318",
|
4
4
|
"source": "src/index.ts",
|
5
5
|
"types": "./types/index.d.ts",
|
6
6
|
"sideEffects": false,
|
@@ -91,14 +91,14 @@
|
|
91
91
|
"@react-navigation/native-stack": "~6.9.13",
|
92
92
|
"@react-navigation/routers": "~6.1.9",
|
93
93
|
"@ungap/structured-clone": "^1.2.0",
|
94
|
-
"@vxrn/resolve": "1.1.
|
95
|
-
"@vxrn/tslib-lite": "1.1.
|
96
|
-
"@vxrn/universal-color-scheme": "1.1.
|
97
|
-
"@vxrn/use-isomorphic-layout-effect": "1.1.
|
94
|
+
"@vxrn/resolve": "1.1.318",
|
95
|
+
"@vxrn/tslib-lite": "1.1.318",
|
96
|
+
"@vxrn/universal-color-scheme": "1.1.318",
|
97
|
+
"@vxrn/use-isomorphic-layout-effect": "1.1.318",
|
98
98
|
"babel-dead-code-elimination": "^1.0.6",
|
99
99
|
"citty": "^0.1.6",
|
100
100
|
"core-js": "^3.38.1",
|
101
|
-
"create-vxrn": "1.1.
|
101
|
+
"create-vxrn": "1.1.318",
|
102
102
|
"escape-string-regexp": "^5.0.0",
|
103
103
|
"expo-linking": "~6.3.1",
|
104
104
|
"expo-modules-core": "^1.12.24",
|
@@ -120,7 +120,7 @@
|
|
120
120
|
"url-parse": "^1.5.10",
|
121
121
|
"vite": "6.0.0-beta.1",
|
122
122
|
"vite-tsconfig-paths": "^5.0.1",
|
123
|
-
"vxrn": "1.1.
|
123
|
+
"vxrn": "1.1.318",
|
124
124
|
"ws": "^8.18.0",
|
125
125
|
"xxhashjs": "^0.2.2"
|
126
126
|
},
|
package/src/serve.ts
CHANGED
@@ -131,14 +131,14 @@ async function oneServe(
|
|
131
131
|
return await import(apiFile)
|
132
132
|
} catch (err) {
|
133
133
|
console.error(`\n [one] Error importing API route at ${apiFile}:
|
134
|
-
|
134
|
+
|
135
135
|
${err}
|
136
136
|
|
137
137
|
If this is an import error, you can likely fix this by adding this dependency to
|
138
138
|
the "optimizeDeps.include" array in your vite.config.ts.
|
139
139
|
|
140
140
|
🐞 For a better error message run "node" and enter:
|
141
|
-
|
141
|
+
|
142
142
|
import('${apiFile}')\n\n`)
|
143
143
|
return {}
|
144
144
|
}
|
@@ -216,6 +216,9 @@ async function oneServe(
|
|
216
216
|
if (isResponse(response)) {
|
217
217
|
if (isStatusRedirect(response.status)) {
|
218
218
|
const location = `${response.headers.get('location') || ''}`
|
219
|
+
response.headers.forEach((value, key) => {
|
220
|
+
context.header(key, value)
|
221
|
+
})
|
219
222
|
return context.redirect(location, response.status)
|
220
223
|
}
|
221
224
|
|
@@ -1,11 +1,30 @@
|
|
1
|
-
|
1
|
+
const getPageLikeExports = (x: string) => x !== 'loader' && x[0].toUpperCase() === x[0]
|
2
|
+
|
3
|
+
export const getPageExport = (exported: Record<string, any>) => {
|
2
4
|
return (
|
3
5
|
exported.default ||
|
4
6
|
// because HMR fails with default exports, allow exporting something else
|
5
7
|
// we just find the first non-loader export for now...
|
6
8
|
(() => {
|
7
9
|
const keys = Object.keys(exported)
|
8
|
-
|
10
|
+
|
11
|
+
if (process.env.NODE_ENV === 'development') {
|
12
|
+
const upperCaseExports = keys.filter(getPageLikeExports)
|
13
|
+
if (upperCaseExports.length > 1) {
|
14
|
+
console.warn(`Warning: You've exported more than one uppercase non-default export.
|
15
|
+
|
16
|
+
If there is no default export, One uses the first capitalized non-default export.
|
17
|
+
This is because React Refresh, the hot reloading library, does not work on default
|
18
|
+
exports, so you may prefer to use non-default exports. But exporting multiple can
|
19
|
+
cause issues, as browser clients and server runtimes may not sort the export keys
|
20
|
+
the same.
|
21
|
+
|
22
|
+
Be sure to only export a single capitalized non-default export per-route.
|
23
|
+
`)
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
const nonLoader = keys.find(getPageLikeExports)
|
9
28
|
if (nonLoader) {
|
10
29
|
return exported[nonLoader]
|
11
30
|
}
|
@@ -304,6 +304,18 @@ export function createFileSystemRouter(options: One.PluginOptions): Plugin {
|
|
304
304
|
}
|
305
305
|
|
306
306
|
if (typeof reply !== 'string' && isResponse(reply)) {
|
307
|
+
reply.headers.forEach((value, key) => {
|
308
|
+
if (key === 'set-cookie') {
|
309
|
+
// for some reason it wasnt doing working without this?
|
310
|
+
const cookies = value.split(', ')
|
311
|
+
for (const cookie of cookies) {
|
312
|
+
res.appendHeader('Set-Cookie', cookie)
|
313
|
+
}
|
314
|
+
} else {
|
315
|
+
res.setHeader(key, value)
|
316
|
+
}
|
317
|
+
})
|
318
|
+
|
307
319
|
if (isStatusRedirect(reply.status)) {
|
308
320
|
const location = `${reply.headers.get('location') || ''}`
|
309
321
|
console.info(` ↦ Redirect ${location}`)
|
@@ -320,18 +332,6 @@ export function createFileSystemRouter(options: One.PluginOptions): Plugin {
|
|
320
332
|
res.statusCode = reply.status
|
321
333
|
res.statusMessage = reply.statusText
|
322
334
|
|
323
|
-
reply.headers.forEach((value, key) => {
|
324
|
-
if (key === 'set-cookie') {
|
325
|
-
// for some reason it wasnt doing working without this?
|
326
|
-
const cookies = value.split(', ')
|
327
|
-
for (const cookie of cookies) {
|
328
|
-
res.appendHeader('Set-Cookie', cookie)
|
329
|
-
}
|
330
|
-
} else {
|
331
|
-
res.setHeader(key, value)
|
332
|
-
}
|
333
|
-
})
|
334
|
-
|
335
335
|
let outString = ''
|
336
336
|
|
337
337
|
if (reply.body) {
|
package/src/vite/one.ts
CHANGED
@@ -3,7 +3,13 @@ import events from 'node:events'
|
|
3
3
|
import path, { dirname, resolve } from 'node:path'
|
4
4
|
import { type Plugin, type PluginOption, type UserConfig, loadConfigFromFile } from 'vite'
|
5
5
|
import tsconfigPaths from 'vite-tsconfig-paths'
|
6
|
-
import {
|
6
|
+
import {
|
7
|
+
autoPreBundleDepsForSsrPlugin,
|
8
|
+
getOptimizeDeps,
|
9
|
+
getOptionsFilled,
|
10
|
+
isWebEnvironment,
|
11
|
+
loadEnv,
|
12
|
+
} from 'vxrn'
|
7
13
|
import { CACHE_KEY } from '../constants'
|
8
14
|
import '../polyfills-server'
|
9
15
|
import { existsAsync } from '../utils/existsAsync'
|
@@ -56,6 +62,14 @@ export function one(options: One.PluginOptions = {}): PluginOption {
|
|
56
62
|
},
|
57
63
|
},
|
58
64
|
|
65
|
+
...(options.ssr?.disableAutoDepsPreBundling
|
66
|
+
? []
|
67
|
+
: [
|
68
|
+
autoPreBundleDepsForSsrPlugin({
|
69
|
+
root: vxrnOptions?.root || process.cwd(),
|
70
|
+
}),
|
71
|
+
]),
|
72
|
+
|
59
73
|
// proxy because you cant add a plugin inside a plugin
|
60
74
|
new Proxy(
|
61
75
|
{
|
@@ -265,10 +279,10 @@ export function one(options: One.PluginOptions = {}): PluginOption {
|
|
265
279
|
config() {
|
266
280
|
return {
|
267
281
|
define: {
|
268
|
-
...options.app?.key && {
|
282
|
+
...(options.app?.key && {
|
269
283
|
'process.env.ONE_APP_NAME': JSON.stringify(options.app.key),
|
270
284
|
'import.meta.env.ONE_APP_NAME': JSON.stringify(options.app.key),
|
271
|
-
},
|
285
|
+
}),
|
272
286
|
|
273
287
|
'process.env.ONE_CACHE_KEY': JSON.stringify(CACHE_KEY),
|
274
288
|
'import.meta.env.ONE_CACHE_KEY': JSON.stringify(CACHE_KEY),
|
package/src/vite/types.ts
CHANGED
@@ -123,6 +123,13 @@ export namespace One {
|
|
123
123
|
deps?: FixDependencies
|
124
124
|
|
125
125
|
afterBuild?: (props: AfterBuildProps) => void | Promise<void>
|
126
|
+
|
127
|
+
ssr?: {
|
128
|
+
/**
|
129
|
+
* Do not automatically scan for dependencies to pre-bundle for SSR.
|
130
|
+
*/
|
131
|
+
disableAutoDepsPreBundling?: boolean
|
132
|
+
}
|
126
133
|
}
|
127
134
|
|
128
135
|
export interface RouteContext {
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const getPageExport: (exported: any) => any;
|
1
|
+
export declare const getPageExport: (exported: Record<string, any>) => any;
|
2
2
|
//# sourceMappingURL=getPageExport.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getPageExport.d.ts","sourceRoot":"","sources":["../../src/utils/getPageExport.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"getPageExport.d.ts","sourceRoot":"","sources":["../../src/utils/getPageExport.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,aAAc,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QA8B1D,CAAA"}
|
package/types/vite/one.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"one.d.ts","sourceRoot":"","sources":["../../src/vite/one.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,YAAY,EAAuC,MAAM,MAAM,CAAA;
|
1
|
+
{"version":3,"file":"one.d.ts","sourceRoot":"","sources":["../../src/vite/one.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,YAAY,EAAuC,MAAM,MAAM,CAAA;AAU1F,OAAO,qBAAqB,CAAA;AAO5B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AASlC,wBAAgB,GAAG,CAAC,OAAO,GAAE,GAAG,CAAC,aAAkB,GAAG,YAAY,CAsUjE;AAeD,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,8BAalE"}
|
package/types/vite/types.d.ts
CHANGED
@@ -99,6 +99,12 @@ export declare namespace One {
|
|
99
99
|
};
|
100
100
|
deps?: FixDependencies;
|
101
101
|
afterBuild?: (props: AfterBuildProps) => void | Promise<void>;
|
102
|
+
ssr?: {
|
103
|
+
/**
|
104
|
+
* Do not automatically scan for dependencies to pre-bundle for SSR.
|
105
|
+
*/
|
106
|
+
disableAutoDepsPreBundling?: boolean;
|
107
|
+
};
|
102
108
|
};
|
103
109
|
interface RouteContext {
|
104
110
|
keys(): string[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/vite/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AACjF,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EACR,eAAe,IAAI,mBAAmB,EACtC,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EAClB,MAAM,MAAM,CAAA;AAEb,yBAAiB,GAAG,CAAC;IACnB,KAAY,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,aAAa,CAAC,GAAG,aAAa,CAAA;IAE5E,KAAY,eAAe,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAA;IAEnD,KAAY,SAAS,GAAG,eAAe,GAAG,KAAK,GAAG,QAAQ,CAAA;IAE1D,KAAY,YAAY,GAAG;QACzB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;KAC7C,CAAA;IAED,KAAY,eAAe,GAAG;QAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAA;KACpD,CAAA;IAED,KAAY,aAAa,GAAG;QAC1B;;;;;WAKG;QACH,IAAI,CAAC,EAAE,OAAO,CAAA;QAEd;;;;WAIG;QACH,SAAS,CAAC,EAAE,MAAM,C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