@naeil/ui 0.8.0 → 0.10.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/CHANGELOG.md +24 -1
- package/DESIGN.md +5 -1
- package/README.md +6 -6
- package/dist/{chunk-ULZPJI5X.js → chunk-F7XM5HJ4.js} +40 -154
- package/dist/{chunk-WA5D7UI2.js → chunk-GQO6NMXK.js} +267 -2
- package/dist/components/index.js +12 -3
- package/dist/components/naeil-footer.d.ts +3 -3
- package/dist/components/naeil-footer.js +14 -11
- package/dist/components/naeil-header.d.ts +7 -9
- package/dist/components/naeil-header.js +2 -2
- package/dist/lib/ui-release.d.ts +1 -1
- package/dist/lib/ui-release.js +1 -1
- package/dist/naeil-locale/checker.d.ts +16 -0
- package/dist/naeil-locale/checker.js +91 -0
- package/dist/naeil-locale/chrome.d.ts +150 -0
- package/dist/naeil-locale/chrome.js +2385 -0
- package/dist/naeil-locale/chunk-D37JHNUN.js +56 -0
- package/dist/naeil-locale/chunk-N3ETBM74.js +24 -0
- package/dist/naeil-locale/chunk-QWHIELL2.js +161 -0
- package/dist/naeil-locale/chunk-YQ5OJWBF.js +53 -0
- package/dist/naeil-locale/client.d.ts +70 -0
- package/dist/naeil-locale/client.js +382 -0
- package/dist/naeil-locale/en-ZC66VDHP.js +86 -0
- package/dist/naeil-locale/index.d.ts +40 -0
- package/dist/naeil-locale/index.js +111 -0
- package/dist/naeil-locale/ja-DKIEQUG7.js +86 -0
- package/dist/naeil-locale/ko-CY6663RZ.js +86 -0
- package/dist/naeil-locale/messages-BQ-fnCAJ.d.ts +166 -0
- package/dist/naeil-locale/messages.d.ts +1 -0
- package/dist/naeil-locale/messages.js +14 -0
- package/dist/naeil-locale/server.d.ts +75 -0
- package/dist/naeil-locale/server.js +172 -0
- package/dist/source/components/naeil-footer-core.d.ts +16 -0
- package/dist/source/components/naeil-footer-core.js +93 -0
- package/dist/source/components/naeil-footer.d.ts +6 -11
- package/dist/source/components/naeil-footer.js +4 -75
- package/dist/source/components/naeil-header-account-core.d.ts +26 -0
- package/dist/source/components/naeil-header-account-core.js +98 -0
- package/dist/source/components/naeil-header-account.d.ts +6 -22
- package/dist/source/components/naeil-header-account.js +5 -81
- package/dist/source/components/naeil-header-content.d.ts +102 -109
- package/dist/source/components/naeil-header-content.js +6 -142
- package/dist/source/components/naeil-header-core.d.ts +59 -0
- package/dist/source/components/naeil-header-core.js +231 -0
- package/dist/source/components/naeil-header-data.d.ts +11 -0
- package/dist/source/components/naeil-header-data.js +14 -0
- package/dist/source/components/naeil-header.d.ts +10 -51
- package/dist/source/components/naeil-header.js +9 -200
- package/dist/source/components/naeil-messages-context.d.ts +94 -0
- package/dist/source/components/naeil-messages-context.js +16 -0
- package/dist/source/components/naeil-standalone-messages.d.ts +11 -0
- package/dist/source/components/naeil-standalone-messages.js +13 -0
- package/dist/source/i18n/routing.d.ts +22 -20
- package/dist/source/lib/ui-release.d.ts +1 -1
- package/dist/source/lib/ui-release.js +1 -1
- package/dist/source/naeil-locale/messages/en.json +78 -0
- package/dist/source/naeil-locale/messages/ja.json +78 -0
- package/dist/source/naeil-locale/messages/ko.json +78 -0
- package/docs/components/README.md +1 -1
- package/docs/components/application-layout.md +24 -6
- package/docs/components/common.md +2 -2
- package/docs/components/naeil-header.md +10 -4
- package/docs/components/naeil-locale.md +46 -0
- package/docs/design/v2-migration.md +8 -4
- package/docs/package-release.md +27 -6
- package/package.json +34 -6
- package/src/styles/components.css +17 -0
- /package/dist/{naeil-header-content-BvISJ4RV.d.ts → naeil-header-data-BvISJ4RV.d.ts} +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertLocale
|
|
3
|
+
} from "./chunk-QWHIELL2.js";
|
|
4
|
+
import {
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "./chunk-N3ETBM74.js";
|
|
7
|
+
|
|
8
|
+
// src/naeil-locale/messages.ts
|
|
9
|
+
var sharedLoaders = {
|
|
10
|
+
en: () => import("./en-ZC66VDHP.js"),
|
|
11
|
+
ko: () => import("./ko-CY6663RZ.js"),
|
|
12
|
+
ja: () => import("./ja-DKIEQUG7.js")
|
|
13
|
+
};
|
|
14
|
+
function unwrap(value) {
|
|
15
|
+
return "default" in value && typeof value.default === "object" ? value.default : value;
|
|
16
|
+
}
|
|
17
|
+
async function loadSharedMessages(locale) {
|
|
18
|
+
return unwrap(await sharedLoaders[assertLocale(locale)]());
|
|
19
|
+
}
|
|
20
|
+
function validateNamespace(namespace) {
|
|
21
|
+
if (!/^[A-Za-z][A-Za-z0-9_]*$/.test(namespace) || ["naeil", "constructor", "prototype"].includes(namespace)) throw new Error("Application message namespace conflicts with the shared namespace");
|
|
22
|
+
}
|
|
23
|
+
function mergeLocaleMessages(shared, application, namespace) {
|
|
24
|
+
validateNamespace(namespace);
|
|
25
|
+
if (Object.keys(application).length !== 1 || !Object.hasOwn(application, namespace) || !application[namespace] || typeof application[namespace] !== "object") throw new Error(`Messages must contain only the ${namespace} namespace`);
|
|
26
|
+
if (Object.hasOwn(shared, namespace)) throw new Error(`Duplicate message namespace: ${namespace}`);
|
|
27
|
+
return __spreadValues(__spreadValues({}, shared), application);
|
|
28
|
+
}
|
|
29
|
+
function createLocaleMessageLoader(options) {
|
|
30
|
+
validateNamespace(options.namespace);
|
|
31
|
+
return async function loadMessages(locale) {
|
|
32
|
+
assertLocale(locale);
|
|
33
|
+
const [shared, application] = await Promise.all([loadSharedMessages(locale), options.messages[locale]().then(unwrap)]);
|
|
34
|
+
return mergeLocaleMessages(shared, application, options.namespace);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function recoverMissingMessages(selected, english, onMissing, prefix = "") {
|
|
38
|
+
const result = __spreadValues({}, selected);
|
|
39
|
+
for (const [key, value] of Object.entries(english)) {
|
|
40
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
41
|
+
if (!Object.hasOwn(result, key) || typeof value === "string" && (typeof result[key] !== "string" || !result[key])) {
|
|
42
|
+
onMissing(path);
|
|
43
|
+
result[key] = value;
|
|
44
|
+
} else if (typeof value === "object") {
|
|
45
|
+
result[key] = recoverMissingMessages(typeof result[key] === "object" ? result[key] : {}, value, onMissing, path);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
loadSharedMessages,
|
|
53
|
+
mergeLocaleMessages,
|
|
54
|
+
createLocaleMessageLoader,
|
|
55
|
+
recoverMissingMessages
|
|
56
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
__spreadValues,
|
|
23
|
+
__spreadProps
|
|
24
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadProps,
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "./chunk-N3ETBM74.js";
|
|
5
|
+
|
|
6
|
+
// src/naeil-locale/routing.ts
|
|
7
|
+
var naeilLocales = ["en", "ko", "ja"];
|
|
8
|
+
var defaultLocale = "en";
|
|
9
|
+
var naeilRouting = {
|
|
10
|
+
locales: naeilLocales,
|
|
11
|
+
defaultLocale,
|
|
12
|
+
localePrefix: "as-needed",
|
|
13
|
+
localeDetection: false,
|
|
14
|
+
localeCookie: false,
|
|
15
|
+
alternateLinks: false
|
|
16
|
+
};
|
|
17
|
+
function isNaeilLocale(value) {
|
|
18
|
+
return typeof value === "string" && naeilLocales.includes(value);
|
|
19
|
+
}
|
|
20
|
+
function assertLocale(value) {
|
|
21
|
+
if (!isNaeilLocale(value)) throw new Error("Unsupported naeil locale");
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
var origins = {
|
|
25
|
+
main: "https://naeil.dev",
|
|
26
|
+
jev: "https://jev.naeil.dev",
|
|
27
|
+
estimate: "https://abestimate.naeil.dev"
|
|
28
|
+
};
|
|
29
|
+
var protocolPrefixes = ["/api", "/auth", "/_next", "/_vercel", "/.well-known", "/health", "/invite", "/return", "/webhook", "/images", "/fonts"];
|
|
30
|
+
var protocolFiles = ["/favicon.ico", "/icon.svg", "/apple-icon.png", "/robots.txt", "/sitemap.xml"];
|
|
31
|
+
function defineLocaleService(service) {
|
|
32
|
+
var _a, _b, _c, _d;
|
|
33
|
+
if (origins[service.id] !== service.origin) throw new Error("Service origin must match the exact owned origin");
|
|
34
|
+
const paths = service.routes.map((route) => typeof route === "string" ? route : route.path);
|
|
35
|
+
if (!paths.length || new Set(paths).size !== paths.length) throw new Error("Route inventory is empty or duplicated");
|
|
36
|
+
for (const path of paths) {
|
|
37
|
+
if (!/^\/(?:[A-Za-z0-9._~-]+|\[[A-Za-z][A-Za-z0-9_]*\])(?:\/(?:[A-Za-z0-9._~-]+|\[[A-Za-z][A-Za-z0-9_]*\]))*$/.test(path) && path !== "/") throw new Error(`Invalid registered route: ${path}`);
|
|
38
|
+
if (/^\/(?:en|ko|ja)(?:\/|$)/.test(path) || isProtocolPath(path, service) && !((_a = service.uiProtocolExceptions) == null ? void 0 : _a.includes(path)) || path.split("/").some((segment) => segment === "." || segment === "..")) throw new Error(`Locale/protocol path cannot be a UI route: ${path}`);
|
|
39
|
+
}
|
|
40
|
+
for (const exception of (_b = service.uiProtocolExceptions) != null ? _b : []) if (exception.includes("[") || !paths.includes(exception)) throw new Error("Protocol UI exceptions must be exact registered routes");
|
|
41
|
+
return Object.freeze(__spreadProps(__spreadValues({}, service), { routes: Object.freeze(service.routes.map((route) => typeof route === "string" ? route : Object.freeze(__spreadValues({}, route)))), protocolPrefixes: Object.freeze([...(_c = service.protocolPrefixes) != null ? _c : []]), uiProtocolExceptions: Object.freeze([...(_d = service.uiProtocolExceptions) != null ? _d : []]) }));
|
|
42
|
+
}
|
|
43
|
+
var main = defineLocaleService({ id: "main", origin: origins.main, routes: ["/", "/projects", "/design", "/blog", "/blog/[slug]", "/login", { path: "/login/change-password", protected: true }] });
|
|
44
|
+
var naeilServices = {
|
|
45
|
+
main,
|
|
46
|
+
site: main,
|
|
47
|
+
jev: defineLocaleService({ id: "jev", origin: origins.jev, routes: [{ path: "/", protected: true }, "/login"] }),
|
|
48
|
+
estimate: defineLocaleService({ id: "estimate", origin: origins.estimate, uiProtocolExceptions: ["/auth/complete"], routes: ["/", "/estimates", "/estimates/[id]", "/compare", "/settings", "/calendar", "/calendar-preview", "/calendar-preview/estimates", "/calendar-preview/estimates/[id]"].map((path) => ({ path, protected: true })).concat([{ path: "/login", protected: false }, { path: "/access-denied", protected: false }, { path: "/auth/complete", protected: false }]) })
|
|
49
|
+
};
|
|
50
|
+
function getLocaleService(service) {
|
|
51
|
+
return typeof service === "string" ? naeilServices[service] : service;
|
|
52
|
+
}
|
|
53
|
+
function isProtocolPath(path, service) {
|
|
54
|
+
var _a;
|
|
55
|
+
return [...protocolPrefixes, ...(_a = service.protocolPrefixes) != null ? _a : []].some((prefix) => path === prefix || path.startsWith(prefix + "/")) || protocolFiles.includes(path);
|
|
56
|
+
}
|
|
57
|
+
function matchRoute(service, pathname) {
|
|
58
|
+
const segments = pathname.split("/");
|
|
59
|
+
for (const route of service.routes) {
|
|
60
|
+
const record = typeof route === "string" ? { path: route } : route;
|
|
61
|
+
const expected = record.path.split("/");
|
|
62
|
+
if (expected.length === segments.length && expected.every((part, index) => part === segments[index] || /^\[[A-Za-z][A-Za-z0-9_]*\]$/.test(part) && !!segments[index])) return record;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function invalid(reason, status = 404, locale) {
|
|
66
|
+
return __spreadValues({ kind: "invalid", status, reason }, locale ? { locale } : {});
|
|
67
|
+
}
|
|
68
|
+
function splitInput(input, origin) {
|
|
69
|
+
if (!input || /[\u0000-\u0020\u007f\\]/.test(input)) return;
|
|
70
|
+
let path = input;
|
|
71
|
+
if (!path.startsWith("/")) {
|
|
72
|
+
if (!path.startsWith(origin + "/") && path !== origin) return;
|
|
73
|
+
path = path.slice(origin.length) || "/";
|
|
74
|
+
}
|
|
75
|
+
if (path.startsWith("//")) return;
|
|
76
|
+
const hashAt = path.indexOf("#");
|
|
77
|
+
const hash = hashAt < 0 ? "" : path.slice(hashAt);
|
|
78
|
+
const withoutHash = hashAt < 0 ? path : path.slice(0, hashAt);
|
|
79
|
+
const queryAt = withoutHash.indexOf("?");
|
|
80
|
+
return { pathname: queryAt < 0 ? withoutHash : withoutHash.slice(0, queryAt), search: queryAt < 0 ? "" : withoutHash.slice(queryAt), hash };
|
|
81
|
+
}
|
|
82
|
+
function safePath(path) {
|
|
83
|
+
if (!path.startsWith("/") || path.includes("//")) return false;
|
|
84
|
+
return path.split("/").every((segment) => {
|
|
85
|
+
try {
|
|
86
|
+
const decoded = decodeURIComponent(segment);
|
|
87
|
+
return !/[\u0000-\u001f\u007f/\\%?#]/.test(decoded) && decoded !== "." && decoded !== ".." && (!/^(?:en|ko|ja|api|auth|_next|invite|return|webhook)$/.test(decoded) || decoded === segment);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function stripLegacyLang(search) {
|
|
94
|
+
const retained = search.slice(1).split("&").filter((part) => {
|
|
95
|
+
try {
|
|
96
|
+
return decodeURIComponent(part.split("=")[0].replace(/\+/g, " ")) !== "lang";
|
|
97
|
+
} catch (e) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return retained.length && retained.join("&") ? "?" + retained.join("&") : "";
|
|
102
|
+
}
|
|
103
|
+
function prefixPath(path, locale) {
|
|
104
|
+
return locale === "en" ? path : `/${locale}${path === "/" ? "" : path}`;
|
|
105
|
+
}
|
|
106
|
+
function resolveLocaleUrl(inputService, input) {
|
|
107
|
+
var _a, _b;
|
|
108
|
+
const service = getLocaleService(inputService);
|
|
109
|
+
const parts = splitInput(input, service.origin);
|
|
110
|
+
if (!parts || !safePath(parts.pathname)) return invalid("Malformed or encoded path");
|
|
111
|
+
const rawPathname = parts.pathname;
|
|
112
|
+
const pathname = rawPathname !== "/" && rawPathname.endsWith("/") ? rawPathname.slice(0, -1) : rawPathname;
|
|
113
|
+
if (isProtocolPath(pathname, service) && !((_a = service.uiProtocolExceptions) == null ? void 0 : _a.includes(pathname))) return { kind: "protocol", pathname };
|
|
114
|
+
const segments = pathname.split("/");
|
|
115
|
+
const explicit = isNaeilLocale(segments[1]);
|
|
116
|
+
const pathLocale = explicit ? segments[1] : void 0;
|
|
117
|
+
const logicalPath = explicit ? "/" + segments.slice(2).join("/") : pathname;
|
|
118
|
+
if (/^\/(?:en|ko|ja)(?:\/|$)/.test(logicalPath) || isProtocolPath(logicalPath, service) && !((_b = service.uiProtocolExceptions) == null ? void 0 : _b.includes(logicalPath))) return invalid("Nested locale or localized protocol path", 404, pathLocale);
|
|
119
|
+
const route = matchRoute(service, logicalPath);
|
|
120
|
+
if (!route) return invalid("Unregistered UI route", 404, pathLocale);
|
|
121
|
+
const legacy = service.id !== "main";
|
|
122
|
+
const languages = new URLSearchParams(parts.search).getAll("lang");
|
|
123
|
+
if (legacy && languages.length && (languages.length !== 1 || !isNaeilLocale(languages[0]))) return invalid("Invalid legacy language", 400, pathLocale);
|
|
124
|
+
const locale = pathLocale != null ? pathLocale : legacy && languages.length ? languages[0] : "en";
|
|
125
|
+
const search = legacy ? stripLegacyLang(parts.search) : parts.search;
|
|
126
|
+
const canonicalPath = prefixPath(logicalPath, locale) + search + parts.hash;
|
|
127
|
+
const originalPath = rawPathname + parts.search + parts.hash;
|
|
128
|
+
return { kind: "ui", locale, logicalPath, route, canonicalPath, originalPath, alias: canonicalPath !== originalPath };
|
|
129
|
+
}
|
|
130
|
+
function localePath(inputService, unlocalizedRoute, locale) {
|
|
131
|
+
assertLocale(locale);
|
|
132
|
+
const service = getLocaleService(inputService);
|
|
133
|
+
const parts = splitInput(unlocalizedRoute, service.origin);
|
|
134
|
+
if (!parts || /^\/(?:en|ko|ja)(?:\/|$)/.test(parts.pathname)) throw new Error("localePath requires an unlocalized route");
|
|
135
|
+
const result = resolveLocaleUrl(service, parts.pathname);
|
|
136
|
+
if (result.kind !== "ui") throw new Error("Unregistered UI destination");
|
|
137
|
+
return prefixPath(result.logicalPath, locale) + (service.id === "main" ? parts.search : stripLegacyLang(parts.search)) + parts.hash;
|
|
138
|
+
}
|
|
139
|
+
function localeHref(service, unlocalizedRoute, locale) {
|
|
140
|
+
return getLocaleService(service).origin + localePath(service, unlocalizedRoute, locale);
|
|
141
|
+
}
|
|
142
|
+
function sameLogicalRoute(service, left, right) {
|
|
143
|
+
const a = resolveLocaleUrl(service, left), b = resolveLocaleUrl(service, right);
|
|
144
|
+
if (a.kind !== "ui" || b.kind !== "ui") return false;
|
|
145
|
+
return a.logicalPath === b.logicalPath && a.canonicalPath.slice(prefixPath(a.logicalPath, a.locale).length) === b.canonicalPath.slice(prefixPath(b.logicalPath, b.locale).length);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export {
|
|
149
|
+
naeilLocales,
|
|
150
|
+
defaultLocale,
|
|
151
|
+
naeilRouting,
|
|
152
|
+
isNaeilLocale,
|
|
153
|
+
assertLocale,
|
|
154
|
+
defineLocaleService,
|
|
155
|
+
naeilServices,
|
|
156
|
+
getLocaleService,
|
|
157
|
+
resolveLocaleUrl,
|
|
158
|
+
localePath,
|
|
159
|
+
localeHref,
|
|
160
|
+
sameLogicalRoute
|
|
161
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// src/components/naeil-messages-context.tsx
|
|
35
|
+
import { createContext, useContext } from "react";
|
|
36
|
+
import { jsx } from "react/jsx-runtime";
|
|
37
|
+
var NaeilMessages = createContext(null);
|
|
38
|
+
function NaeilMessagesProvider({ locale, messages, children }) {
|
|
39
|
+
return /* @__PURE__ */ jsx(NaeilMessages.Provider, { value: { locale, messages }, children });
|
|
40
|
+
}
|
|
41
|
+
function useNaeilMessages(locale) {
|
|
42
|
+
const value = useContext(NaeilMessages);
|
|
43
|
+
if (!value || value.locale !== locale) throw new Error("Naeil chrome requires messages for its current locale");
|
|
44
|
+
return value.messages;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
__spreadValues,
|
|
49
|
+
__spreadProps,
|
|
50
|
+
__objRest,
|
|
51
|
+
NaeilMessagesProvider,
|
|
52
|
+
useNaeilMessages
|
|
53
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/** Opt-in owned-service routing. The legacy public i18n/routing entry is unchanged. */
|
|
5
|
+
declare const naeilLocales: readonly ["en", "ko", "ja"];
|
|
6
|
+
type NaeilLocale = (typeof naeilLocales)[number];
|
|
7
|
+
type NaeilServiceId = "main" | "jev" | "estimate";
|
|
8
|
+
interface NaeilRoute {
|
|
9
|
+
path: string;
|
|
10
|
+
protected?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface NaeilLocaleService {
|
|
13
|
+
id: NaeilServiceId;
|
|
14
|
+
origin: string;
|
|
15
|
+
routes: readonly (string | NaeilRoute)[];
|
|
16
|
+
protocolPrefixes?: readonly string[];
|
|
17
|
+
/** Explicitly audited UI routes within an otherwise protected namespace. */
|
|
18
|
+
uiProtocolExceptions?: readonly string[];
|
|
19
|
+
}
|
|
20
|
+
type LocaleServiceInput = NaeilLocaleService | NaeilServiceId;
|
|
21
|
+
|
|
22
|
+
interface LocaleIntent {
|
|
23
|
+
token: number;
|
|
24
|
+
locale: NaeilLocale;
|
|
25
|
+
href: string;
|
|
26
|
+
startedAt: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface LocaleMessages {
|
|
30
|
+
[key: string]: string | LocaleMessages;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type LocaleTransitionError = "timeout" | "navigation-failed" | "unsupported-route";
|
|
34
|
+
interface LocaleChangeOptions {
|
|
35
|
+
/** A locale-neutral registered route, e.g. a translated blog listing fallback. */
|
|
36
|
+
route?: string;
|
|
37
|
+
/** Alternatively supply a fully built same-service canonical destination. */
|
|
38
|
+
href?: string;
|
|
39
|
+
}
|
|
40
|
+
interface LocaleController {
|
|
41
|
+
pending: boolean;
|
|
42
|
+
intent: LocaleIntent | undefined;
|
|
43
|
+
error: LocaleTransitionError | undefined;
|
|
44
|
+
changeLocale: (locale: NaeilLocale, options?: LocaleChangeOptions) => boolean;
|
|
45
|
+
retry: () => boolean;
|
|
46
|
+
cancel: () => void;
|
|
47
|
+
}
|
|
48
|
+
interface NaeilLocaleControllerProps {
|
|
49
|
+
service: LocaleServiceInput;
|
|
50
|
+
children: ReactNode;
|
|
51
|
+
/** Activate only after the receiver/auth rollout receipts are complete. */
|
|
52
|
+
preferenceWritesEnabled?: boolean;
|
|
53
|
+
transitionTimeoutMs?: number;
|
|
54
|
+
}
|
|
55
|
+
/** Lives in app/layout above [locale] and above remounting presentation. */
|
|
56
|
+
declare function NaeilLocaleController({ service, children, preferenceWritesEnabled, transitionTimeoutMs }: NaeilLocaleControllerProps): react_jsx_runtime.JSX.Element;
|
|
57
|
+
declare function useLocaleController(): LocaleController;
|
|
58
|
+
interface NaeilLocaleProviderProps {
|
|
59
|
+
locale: NaeilLocale;
|
|
60
|
+
messages: LocaleMessages;
|
|
61
|
+
children: ReactNode;
|
|
62
|
+
timeZone?: string;
|
|
63
|
+
now?: Date;
|
|
64
|
+
}
|
|
65
|
+
/** Mounted in app/[locale]/layout with messages for only the requested service. */
|
|
66
|
+
declare function NaeilLocaleProvider({ locale: input, messages, children, timeZone, now }: NaeilLocaleProviderProps): react_jsx_runtime.JSX.Element;
|
|
67
|
+
/** Keep active through locale navigation, including failed-RSC document fallback. */
|
|
68
|
+
declare function useLocaleBeforeUnload(unsafeToLeave: boolean | (() => boolean)): void;
|
|
69
|
+
|
|
70
|
+
export { type LocaleChangeOptions, type LocaleController, type LocaleTransitionError, NaeilLocaleController, type NaeilLocaleControllerProps, NaeilLocaleProvider, type NaeilLocaleProviderProps, useLocaleBeforeUnload, useLocaleController };
|