@link-foundation/ui-devmode 0.0.0-stage → 0.0.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.
Files changed (46) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +353 -2
  3. package/package.json +78 -4
  4. package/src/activation.js +235 -0
  5. package/src/adapter.js +92 -0
  6. package/src/agent-instruction.d.ts +6 -0
  7. package/src/agent-instruction.js +17 -0
  8. package/src/agent-instruction.txt +8 -0
  9. package/src/apply-shared.js +135 -0
  10. package/src/comments/commands.js +77 -0
  11. package/src/comments/geometry.js +65 -0
  12. package/src/comments/index.d.ts +93 -0
  13. package/src/comments/index.js +205 -0
  14. package/src/comments/model.js +359 -0
  15. package/src/comments/picking.js +154 -0
  16. package/src/comments/style.js +36 -0
  17. package/src/comments/view.js +250 -0
  18. package/src/comments/voice.js +64 -0
  19. package/src/defaults-dialog.js +120 -0
  20. package/src/details.js +159 -0
  21. package/src/editors.js +194 -0
  22. package/src/export.js +50 -0
  23. package/src/foreign/adapter.js +166 -0
  24. package/src/foreign/apply.js +89 -0
  25. package/src/foreign/entry.js +173 -0
  26. package/src/foreign/index.d.ts +32 -0
  27. package/src/foreign/injected.js +6 -0
  28. package/src/foreign/persist.js +54 -0
  29. package/src/foreign/properties.js +126 -0
  30. package/src/foreign/runtime.js +67 -0
  31. package/src/index.d.ts +204 -0
  32. package/src/index.js +201 -0
  33. package/src/inspector-css.js +106 -0
  34. package/src/inspector.js +342 -0
  35. package/src/inspector.lino +50 -0
  36. package/src/messages.js +113 -0
  37. package/src/model.d.ts +101 -0
  38. package/src/model.js +473 -0
  39. package/src/overlay.js +91 -0
  40. package/src/policy.js +222 -0
  41. package/src/read-asset.browser.js +8 -0
  42. package/src/read-asset.js +10 -0
  43. package/src/session.js +555 -0
  44. package/src/share.js +23 -0
  45. package/src/validate.js +170 -0
  46. package/src/views.js +328 -0
@@ -0,0 +1,173 @@
1
+ import { openSession } from '../session.js';
2
+ import { defaultPolicy } from '../policy.js';
3
+ import { translator } from '../messages.js';
4
+ import { createForeignAdapter } from './adapter.js';
5
+ import {
6
+ loadOverrides,
7
+ saveOverrides,
8
+ localStorageAdapter,
9
+ chromeStorageAdapter,
10
+ commentStorage,
11
+ } from './persist.js';
12
+
13
+ /** Open/toggle the same inspector over a foreign page. No page globals in extension world. */
14
+ export async function mountForeignDevMode({
15
+ window = globalThis.window,
16
+ storage,
17
+ layout,
18
+ } = {}) {
19
+ if (window.linkUiForeignDevMode) {
20
+ await window.linkUiForeignDevMode.toggle();
21
+ return window.linkUiForeignDevMode;
22
+ }
23
+ const document = window.document;
24
+ const host = document.createElement('ui-foreign-devmode');
25
+ host.style.cssText =
26
+ 'all:initial;position:fixed;inset:0;z-index:2147483647;pointer-events:none';
27
+ const shadow = host.attachShadow({ mode: 'open' });
28
+ const ignore = (node) =>
29
+ node === host || shadow.contains(node) || node.getRootNode?.() === shadow;
30
+ storage ??= globalThis.chrome?.storage?.local
31
+ ? chromeStorageAdapter(globalThis.chrome.storage.local)
32
+ : localStorageAdapter({
33
+ getItem: (key) => window.localStorage.getItem(key),
34
+ setItem: (key, value) => window.localStorage.setItem(key, value),
35
+ });
36
+ const comments = await commentStorage(storage, window.location);
37
+ const adapter = createForeignAdapter({ root: document.body, ignore });
38
+ let session;
39
+ let opening;
40
+ let destroyed = false;
41
+ let pendingSave = Promise.resolve();
42
+ let storageError = null;
43
+ let restoreError = null;
44
+ try {
45
+ adapter.restore(await loadOverrides(storage, window.location));
46
+ } catch (error) {
47
+ restoreError = error.message;
48
+ }
49
+ const save = () => {
50
+ const text = adapter.exportOverrides().text;
51
+ pendingSave = pendingSave
52
+ .catch(() => {})
53
+ .then(() => saveOverrides(storage, window.location, text))
54
+ .catch((error) => {
55
+ storageError = error.message;
56
+ });
57
+ };
58
+ const unsubscribe = adapter.observe(save);
59
+ const controller = {
60
+ adapter,
61
+ host,
62
+ get isOpen() {
63
+ return Boolean(session);
64
+ },
65
+ get storageError() {
66
+ return storageError ?? comments.storageError;
67
+ },
68
+ get restoreError() {
69
+ return restoreError ?? comments.restoreError;
70
+ },
71
+ whenSaved: () =>
72
+ Promise.all([pendingSave, comments.whenSaved()]).then(() => {}),
73
+ async open() {
74
+ if (destroyed) {
75
+ return false;
76
+ }
77
+ if (session) {
78
+ return true;
79
+ }
80
+ if (opening) {
81
+ return await opening;
82
+ }
83
+ opening = (async () => {
84
+ document.body.append(host);
85
+ session = await openSession({
86
+ window,
87
+ root: document.body,
88
+ config: adapter.config,
89
+ adapter,
90
+ container: shadow,
91
+ layout,
92
+ commentOptions: { storage: comments },
93
+ policy: defaultPolicy(),
94
+ t: translator(),
95
+ onInspector(inspector) {
96
+ inspector.host.style.pointerEvents = 'auto';
97
+ const toolbar =
98
+ inspector.shadow.querySelector('ui-devmode-toolbar');
99
+ for (const [label, getText] of [
100
+ ['Copy overrides as LiNo', () => adapter.exportOverrides().text],
101
+ [
102
+ 'Copy subtree as LiNo',
103
+ () => adapter.subtree(session?.getSelection()?.id),
104
+ ],
105
+ ]) {
106
+ const button = document.createElement('button');
107
+ button.type = 'button';
108
+ button.textContent = label;
109
+ button.addEventListener('click', () => {
110
+ try {
111
+ copyExport(window, getText(), inspector);
112
+ } catch (error) {
113
+ inspector.announce(error.message);
114
+ }
115
+ });
116
+ toolbar.append(button);
117
+ }
118
+ },
119
+ onClose() {
120
+ session = null;
121
+ host.remove();
122
+ },
123
+ });
124
+ return true;
125
+ })().finally(() => {
126
+ opening = null;
127
+ });
128
+ return await opening;
129
+ },
130
+ close() {
131
+ session?.close();
132
+ },
133
+ async toggle() {
134
+ if (session) {
135
+ controller.close();
136
+ return false;
137
+ }
138
+ return await controller.open();
139
+ },
140
+ select: (id) => session?.select(id),
141
+ getSelection: () => session?.getSelection() ?? null,
142
+ setProperty: (id, name, value) => adapter.applyProperty(id, name, value),
143
+ exportOverrides: () => adapter.exportOverrides(),
144
+ exportSubtree: (id = session?.getSelection()?.id) => adapter.subtree(id),
145
+ async destroy() {
146
+ destroyed = true;
147
+ controller.close();
148
+ unsubscribe();
149
+ adapter.destroy();
150
+ await controller.whenSaved();
151
+ delete window.linkUiForeignDevMode;
152
+ },
153
+ };
154
+ window.linkUiForeignDevMode = controller;
155
+ await controller.open();
156
+ return controller;
157
+ }
158
+
159
+ async function copyExport(window, text, inspector) {
160
+ const document = window.document;
161
+ try {
162
+ await window.navigator.clipboard.writeText(text);
163
+ inspector.announce('Copied');
164
+ } catch {
165
+ const area = document.createElement('textarea');
166
+ area.setAttribute('aria-label', 'LiNo export');
167
+ area.value = text;
168
+ inspector.panel('source').append(area);
169
+ inspector.showView('source');
170
+ area.focus();
171
+ area.select();
172
+ }
173
+ }
@@ -0,0 +1,32 @@
1
+ export interface ForeignStorage {
2
+ getItem(key: string): Promise<string | null>;
3
+ setItem(key: string, value: string): Promise<unknown>;
4
+ }
5
+ export interface ForeignController {
6
+ readonly host: HTMLElement;
7
+ readonly isOpen: boolean;
8
+ readonly storageError: string | null;
9
+ readonly restoreError: string | null;
10
+ readonly adapter: {
11
+ tree(): object;
12
+ nodeFor(id: string): Node | null;
13
+ idFor(node: Node): string | null;
14
+ applyProperty(id: string, name: string, value: string): { layer: string };
15
+ observe(callback: () => void): () => void;
16
+ };
17
+ open(): Promise<boolean>;
18
+ close(): void;
19
+ toggle(): Promise<boolean>;
20
+ select(id: string | null): string | null | undefined;
21
+ getSelection(): { id: string; type: string } | null;
22
+ setProperty(id: string, name: string, value: string): { layer: string };
23
+ exportOverrides(): { text: string; count: number; links: unknown[] };
24
+ exportSubtree(id?: string): string;
25
+ whenSaved(): Promise<void>;
26
+ destroy(): Promise<void>;
27
+ }
28
+ export function mountForeignDevMode(options?: {
29
+ window?: Window;
30
+ storage?: ForeignStorage;
31
+ layout?: string;
32
+ }): Promise<ForeignController>;
@@ -0,0 +1,6 @@
1
+ import layout from '../inspector.lino?raw';
2
+ import { mountForeignDevMode } from './entry.js';
3
+ // Serialize repeated toolbar clicks while the inspector is opening.
4
+ globalThis.linkUiForeignReady = Promise.resolve(globalThis.linkUiForeignReady)
5
+ .catch(() => {})
6
+ .then(() => mountForeignDevMode({ layout }));
@@ -0,0 +1,54 @@
1
+ /** Each delivery channel implements async getItem/setItem of LiNo text. */
2
+ export const storageKey = (location) =>
3
+ `link-ui-devmode:${location.origin}:${location.pathname}`;
4
+ export const localStorageAdapter = (storage) => ({
5
+ getItem: async (key) => await storage.getItem(key),
6
+ setItem: async (key, value) => await storage.setItem(key, value),
7
+ });
8
+ export const chromeStorageAdapter = (storage) => ({
9
+ getItem: async (key) => (await storage.get(key))[key] ?? null,
10
+ setItem: async (key, value) => await storage.set({ [key]: value }),
11
+ });
12
+ export async function loadOverrides(storage, location) {
13
+ return (await storage.getItem(storageKey(location))) ?? '';
14
+ }
15
+ export async function saveOverrides(storage, location, overrides) {
16
+ await storage.setItem(storageKey(location), overrides);
17
+ }
18
+
19
+ /** Cache reads for the synchronous panel and serialize delivery-channel writes. */
20
+ export async function commentStorage(storage, location) {
21
+ const key = `${storageKey(location)}:comments`;
22
+ let text = null;
23
+ let restoreError = null;
24
+ let storageError = null;
25
+ let pending = Promise.resolve();
26
+ try {
27
+ text = await storage.getItem(key);
28
+ } catch (error) {
29
+ restoreError = error.message;
30
+ }
31
+ return {
32
+ get restoreError() {
33
+ return restoreError;
34
+ },
35
+ get storageError() {
36
+ return storageError;
37
+ },
38
+ whenSaved: () => pending,
39
+ getItem() {
40
+ if (restoreError) {
41
+ throw new Error(restoreError);
42
+ }
43
+ return text;
44
+ },
45
+ setItem(_key, value) {
46
+ text = value;
47
+ const write = pending.then(() => storage.setItem(key, value));
48
+ pending = write.catch((error) => {
49
+ storageError = error.message;
50
+ });
51
+ return write;
52
+ },
53
+ };
54
+ }
@@ -0,0 +1,126 @@
1
+ import { formatValues } from '../model.js';
2
+ import { checkProperty, readProperty } from './apply.js';
3
+ const nameOf = (op) =>
4
+ op.key === null || op.key === undefined ? op.name : `${op.name} ${op.key}`;
5
+
6
+ export function updateOriginals(originals, nodeMap) {
7
+ for (const original of originals.values()) {
8
+ const node = nodeMap.get(original.id);
9
+ if (node && node !== original.node) {
10
+ original.node = node;
11
+ original.value = readProperty(node, original.name);
12
+ original.priority = original.name.startsWith('style ')
13
+ ? node.style.getPropertyPriority(original.name.slice(6))
14
+ : '';
15
+ }
16
+ }
17
+ }
18
+ export function baseDocument(nodeMap, originals) {
19
+ return [...nodeMap].map(([id, node]) => {
20
+ const properties = [];
21
+ const added = new Set();
22
+ const add = (label, value) => {
23
+ if (added.has(label)) {
24
+ return;
25
+ }
26
+ added.add(label);
27
+ const original = originals.get(JSON.stringify([id, label]));
28
+ value = original ? original.value : value;
29
+ if (value === null || value === undefined) {
30
+ return;
31
+ }
32
+ const [name, key] = label.split(' ');
33
+ properties.push({ name, values: key ? [key, value] : [value] });
34
+ };
35
+ if (node.nodeType === 3 || (node.nodeType === 1 && !node.children.length)) {
36
+ add('text', node.textContent);
37
+ }
38
+ if (node.nodeType === 1) {
39
+ for (const attr of node.attributes) {
40
+ if (attr.name !== 'style') {
41
+ add(`attr ${attr.name}`, attr.value);
42
+ }
43
+ }
44
+ for (let i = 0; i < node.style.length; i++) {
45
+ const name = node.style.item(i);
46
+ add(`style ${name}`, node.style.getPropertyValue(name));
47
+ }
48
+ for (const original of originals.values()) {
49
+ if (original.id === id) {
50
+ add(original.name, original.value);
51
+ }
52
+ }
53
+ }
54
+ return {
55
+ id,
56
+ kind: 'foreign-node',
57
+ positional: [],
58
+ properties,
59
+ children: [],
60
+ unknown: [],
61
+ };
62
+ });
63
+ }
64
+ export function foreignRows(adapter, config, allOps, id) {
65
+ const node = adapter.nodeFor(id);
66
+ if (!node) {
67
+ return [];
68
+ }
69
+ const names = new Set();
70
+ if (
71
+ node.nodeType === 3 ||
72
+ (node.nodeType === 1 &&
73
+ !node.children.length &&
74
+ !['script', 'style'].includes(node.localName))
75
+ ) {
76
+ names.add('text');
77
+ }
78
+ if (node.nodeType === 1) {
79
+ for (const attr of node.attributes) {
80
+ if (attr.name !== 'style') {
81
+ names.add(`attr ${attr.name}`);
82
+ }
83
+ }
84
+ for (const prop of Array.from({ length: node.style.length }, (_, i) =>
85
+ node.style.item(i)
86
+ )) {
87
+ names.add(`style ${prop}`);
88
+ }
89
+ names.add('attr title');
90
+ names.add('style color');
91
+ for (const op of allOps().filter((op) => op.id === id)) {
92
+ names.add(nameOf(op));
93
+ }
94
+ }
95
+ return [...names].flatMap((label) => {
96
+ const value = readProperty(node, label) ?? '';
97
+ try {
98
+ checkProperty(node, label, value);
99
+ } catch {
100
+ return [];
101
+ }
102
+ const [name, key = null] = label.split(' ');
103
+ const changed = [...allOps()]
104
+ .reverse()
105
+ .find((op) => op.id === id && nameOf(op) === label);
106
+ return [
107
+ {
108
+ name,
109
+ key,
110
+ label,
111
+ type: 'string',
112
+ editor: 'string',
113
+ value: [value],
114
+ text: formatValues([value]),
115
+ layer: changed
116
+ ? config.valueIn('session', id, name, key ?? undefined)
117
+ ? 'session'
118
+ : 'user'
119
+ : 'site',
120
+ changed: Boolean(changed),
121
+ locked: false,
122
+ writable: true,
123
+ },
124
+ ];
125
+ });
126
+ }
@@ -0,0 +1,67 @@
1
+ import { readPatch } from '@link-foundation/ui-config';
2
+
3
+ export function restoreOverrides(adapter, text) {
4
+ const patch = readPatch(text, { keyedProps: ['attr', 'style'] });
5
+ if (patch.diagnostics.some((d) => d.severity === 'error')) {
6
+ throw new Error('Invalid saved overrides');
7
+ }
8
+ const rejected = [];
9
+ for (const op of patch.ops) {
10
+ try {
11
+ if (op.op !== 'set' || op.values.length !== 1) {
12
+ throw new Error('Expected one set value');
13
+ }
14
+ const name = op.key === null ? op.name : `${op.name} ${op.key}`;
15
+ adapter.applyProperty(op.id, name, op.values[0]);
16
+ } catch (error) {
17
+ rejected.push({ op, message: error.message });
18
+ }
19
+ }
20
+ return rejected;
21
+ }
22
+
23
+ export function treeView(document, subscribe) {
24
+ return {
25
+ get: (id) => document().byId.get(id),
26
+ roots: () => document().roots.map((node) => node.id),
27
+ children: (id) =>
28
+ (document().byId.get(id)?.children ?? []).map((node) => node.id),
29
+ parentOf: (id) =>
30
+ [...document().byId.values()].find((node) =>
31
+ node.children.some((child) => child.id === id)
32
+ )?.id ?? null,
33
+ toDocument: document,
34
+ subscribe,
35
+ };
36
+ }
37
+
38
+ export function observeDom(root, ignore, refresh, delay) {
39
+ const window = root.ownerDocument.defaultView;
40
+ let timer;
41
+ const observer = new window.MutationObserver((records) => {
42
+ if (
43
+ !records.some(
44
+ (record) =>
45
+ !ignore(record.target) &&
46
+ (record.type !== 'childList' ||
47
+ [...record.addedNodes, ...record.removedNodes].some(
48
+ (node) => !ignore(node)
49
+ ))
50
+ )
51
+ ) {
52
+ return;
53
+ }
54
+ window.clearTimeout(timer);
55
+ timer = window.setTimeout(refresh, delay);
56
+ });
57
+ observer.observe(root, {
58
+ subtree: true,
59
+ childList: true,
60
+ attributes: true,
61
+ characterData: true,
62
+ });
63
+ return () => {
64
+ observer.disconnect();
65
+ window.clearTimeout(timer);
66
+ };
67
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,204 @@
1
+ /// <reference lib="dom" />
2
+
3
+ /**
4
+ * Type declarations of `@link-foundation/ui-devmode` (see README.md).
5
+ */
6
+
7
+ /** The entry points that may open dev mode. */
8
+ export type EntryPoint = 'shortcut' | 'url-parameter' | 'element';
9
+ /** The layers dev mode may write. */
10
+ export type WritableLayer = 'user' | 'session';
11
+
12
+ export interface PolicyWarning {
13
+ /** `unknown-key`, `unknown-entry`, `unknown-layer`, `read-only-layer`,
14
+ * `bad-value` or `duplicate-policy`. */
15
+ code: string;
16
+ severity: 'warning';
17
+ message: string;
18
+ at: Record<string, unknown>;
19
+ }
20
+
21
+ export interface DevModePolicy {
22
+ enabled: boolean;
23
+ entry: ReadonlySet<EntryPoint>;
24
+ /** The key combination, `Alt+Shift+D` by default. */
25
+ shortcut: string;
26
+ /** The layers dev mode writes, lowest first. */
27
+ writeLayers: readonly WritableLayer[];
28
+ /** Ids of read-only elements (their descendants are read-only too). */
29
+ lockedElements: ReadonlySet<string>;
30
+ repository?: string;
31
+ siteConfig?: string;
32
+ comfortKeys: ReadonlySet<string>;
33
+ warnings: readonly PolicyWarning[];
34
+ }
35
+
36
+ export const POLICY_KIND: 'dev-mode';
37
+ export const ENTRY_POINTS: readonly EntryPoint[];
38
+ export const WRITABLE_LAYERS: readonly WritableLayer[];
39
+ export const DEFAULT_SHORTCUT: 'Alt+Shift+D';
40
+ export function defaultPolicy(): DevModePolicy;
41
+ /** Read a `(name: dev-mode …)` policy from Links Notation text, a ui-core
42
+ * document or nodes. */
43
+ export function parseDevModePolicy(links: string | object): DevModePolicy;
44
+
45
+ export interface Shortcut {
46
+ altKey: boolean;
47
+ shiftKey: boolean;
48
+ ctrlKey: boolean;
49
+ metaKey: boolean;
50
+ /** A `KeyboardEvent.code`, such as `KeyD`. */
51
+ code: string;
52
+ }
53
+
54
+ export const URL_PARAMETER: 'ui-dev';
55
+ export const ELEMENT_NAME: 'ui-dev-mode';
56
+ export const REQUEST_EVENT: 'ui-dev-mode-request';
57
+ export function parseShortcut(text: string): Shortcut;
58
+ export function matchesShortcut(
59
+ event: Pick<
60
+ KeyboardEvent,
61
+ 'code' | 'altKey' | 'shiftKey' | 'ctrlKey' | 'metaKey'
62
+ >,
63
+ shortcut: Shortcut
64
+ ): boolean;
65
+ export function isEditableTarget(node: unknown): boolean;
66
+ export function shouldActivate(input: {
67
+ url: string | URL;
68
+ policy: DevModePolicy;
69
+ hasElement?: boolean;
70
+ }): boolean;
71
+ export function installActivation(options: {
72
+ window: Window & typeof globalThis;
73
+ policy: DevModePolicy;
74
+ onActivate: (entry: EntryPoint) => void;
75
+ onToggle?: (entry: EntryPoint) => void;
76
+ }): () => void;
77
+
78
+ export const MESSAGES: Readonly<Record<string, string>>;
79
+ export function message(
80
+ table: Readonly<Record<string, string>>,
81
+ key: string,
82
+ params?: Record<string, string | number>
83
+ ): string;
84
+ export function translator(
85
+ table?: Readonly<Record<string, string>>
86
+ ): (key: string, params?: Record<string, string | number>) => string;
87
+
88
+ /** The name of the global handle of an open dev mode. */
89
+ export const GLOBAL_NAME: 'linkUiDevMode';
90
+
91
+ /** `globalThis.linkUiDevMode`, present only while dev mode is open. */
92
+ export interface DevModeHandle {
93
+ select(id: string | null): string | null;
94
+ getSelection(): { id: string; type: string } | null;
95
+ setProperty(
96
+ id: string,
97
+ name: string,
98
+ value: unknown
99
+ ): {
100
+ id: string;
101
+ name: string;
102
+ key: string | null;
103
+ layer: WritableLayer;
104
+ values: readonly unknown[];
105
+ };
106
+ close(): void;
107
+ }
108
+
109
+ declare global {
110
+ // eslint-disable-next-line no-var
111
+ var linkUiDevMode: DevModeHandle | undefined;
112
+ }
113
+
114
+ export interface MountDevModeOptions {
115
+ /** The container ui-dom rendered into. */
116
+ root: Element;
117
+ /** The ui-config configuration of the page, bound to its store. */
118
+ config: object;
119
+ /** A policy object, Links Notation text, a ui-core document or nodes. */
120
+ policy?: string | object | DevModePolicy;
121
+ /** The store `mountDocument` returned. */
122
+ store?: object;
123
+ /** The handle `mountDocument` returned. */
124
+ handle?: { nodeFor?: (id: string) => Element | null };
125
+ styles?: string | object[];
126
+ tokens?: string | Map<string, object>;
127
+ theme?: string;
128
+ animations?: string | object[];
129
+ vocabulary?: object;
130
+ messages?: Record<string, string>;
131
+ commentOptions?: Pick<
132
+ import('@link-foundation/ui-devmode/comments').MountCommentsOptions,
133
+ 'storage' | 'storageKey' | 'text' | 'messages' | 'trace'
134
+ >;
135
+ /** The inspector layout (Links Notation); `inspector.lino` by default. */
136
+ layout?: string;
137
+ window?: Window & typeof globalThis;
138
+ onOpen?: () => void;
139
+ onClose?: () => void;
140
+ }
141
+
142
+ export interface DevModeController {
143
+ readonly policy: DevModePolicy;
144
+ readonly isOpen: boolean;
145
+ /** Open dev mode (loads the inspector the first time). */
146
+ open(): Promise<boolean>;
147
+ close(): void;
148
+ toggle(): Promise<boolean>;
149
+ select(id: string | null): Promise<string | null>;
150
+ /** Close dev mode and remove its entry points. */
151
+ destroy(): void;
152
+ }
153
+
154
+ export function mountDevMode(options: MountDevModeOptions): DevModeController;
155
+
156
+ export interface OverrideExport {
157
+ text: string;
158
+ links: import('@link-foundation/ui-core').RawValue[];
159
+ count: number;
160
+ }
161
+ export function exportOverrides(
162
+ config: import('@link-foundation/ui-config').Config,
163
+ options?: {
164
+ id?: string;
165
+ base?: string;
166
+ layers?: WritableLayer[];
167
+ }
168
+ ): OverrideExport;
169
+ export const URL_BUDGET: 8192;
170
+ export const BACKUP_KEY: 'ui-overrides:before-the-link';
171
+ export function encodeShareHash(text: string): string;
172
+ export function decodeShareHash(hash: string): string | null;
173
+ export function shareUrl(
174
+ location: string | URL | Pick<Location, 'href'>,
175
+ text: string
176
+ ): { url: string; tooLong: boolean };
177
+ export interface ValidationSchema {
178
+ document: import('@link-foundation/ui-core').UiDocument;
179
+ vocabulary?: import('@link-foundation/ui-core').Vocabulary;
180
+ }
181
+ export interface ValidationReport {
182
+ links: import('@link-foundation/ui-core').RawValue[];
183
+ rejected: { link: unknown; reason: string }[];
184
+ }
185
+ export function validateOverrides(
186
+ text: string,
187
+ options: {
188
+ schema: ValidationSchema | import('@link-foundation/ui-core').UiDocument;
189
+ policy?: DevModePolicy;
190
+ }
191
+ ): ValidationReport;
192
+ export function applySharedOverrides(options: {
193
+ config: import('@link-foundation/ui-config').Config;
194
+ location?: Location;
195
+ history?: History;
196
+ storage: Pick<Storage, 'setItem'>;
197
+ schema?: ValidationSchema | import('@link-foundation/ui-core').UiDocument;
198
+ policy?: DevModePolicy;
199
+ text?: string;
200
+ document?: Document;
201
+ t?: ReturnType<typeof translator>;
202
+ }):
203
+ | (ValidationReport & { applied: boolean; keep(): void; discard(): void })
204
+ | null;