@loadbare/app 0.12.0 → 0.13.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/dist/build/assemble.d.ts.map +1 -1
- package/dist/build/assemble.js +57 -1
- package/dist/build/assemble.js.map +1 -1
- package/dist/build/cli.js +2 -1
- package/dist/build/cli.js.map +1 -1
- package/dist/build/elements.d.ts +9 -1
- package/dist/build/elements.d.ts.map +1 -1
- package/dist/build/elements.js +50 -0
- package/dist/build/elements.js.map +1 -1
- package/dist/build/origins.d.ts +2 -0
- package/dist/build/origins.d.ts.map +1 -1
- package/dist/build/origins.js +1 -1
- package/dist/build/origins.js.map +1 -1
- package/dist/core/lb-constants.d.ts +24 -1
- package/dist/core/lb-constants.d.ts.map +1 -1
- package/dist/core/lb-constants.js +71 -0
- package/dist/core/lb-constants.js.map +1 -1
- package/dist/core/lb-types.d.ts +47 -18
- package/dist/core/lb-types.d.ts.map +1 -1
- package/dist/core/lb-types.js +74 -11
- package/dist/core/lb-types.js.map +1 -1
- package/dist/hub/lb-apply.d.ts +37 -15
- package/dist/hub/lb-apply.d.ts.map +1 -1
- package/dist/hub/lb-apply.js +598 -56
- package/dist/hub/lb-apply.js.map +1 -1
- package/dist/hub/lb-hub.browser.d.ts.map +1 -1
- package/dist/hub/lb-hub.browser.js +61 -14
- package/dist/hub/lb-hub.browser.js.map +1 -1
- package/dist/server/lb-express.d.ts +6 -4
- package/dist/server/lb-express.d.ts.map +1 -1
- package/dist/server/lb-express.js +32 -14
- package/dist/server/lb-express.js.map +1 -1
- package/dist/server/lb-server.d.ts +49 -10
- package/dist/server/lb-server.d.ts.map +1 -1
- package/dist/server/lb-server.js +76 -34
- package/dist/server/lb-server.js.map +1 -1
- package/docs/TECHREF-1.0.md +292 -92
- package/docs/comparison.md +11 -9
- package/docs/possible-ideas.md +188 -0
- package/docs/reference/chrome.md +7 -1
- package/docs/reference/custom-elements.md +37 -38
- package/docs/reference/data-binding.md +102 -13
- package/docs/reference/page-files.md +25 -16
- package/docs/reference/server.md +4 -0
- package/docs/reference/widgets.md +94 -24
- package/docs/roadmap.md +10 -6
- package/docs/testing.md +21 -10
- package/package.json +2 -3
- package/skills/loadbare-app/SKILL.md +43 -24
- package/skills/loadbare-app/references/TECHREF-1.0.md +292 -92
- package/skills/loadbare-app/references/chrome.md +7 -1
- package/skills/loadbare-app/references/custom-elements.md +37 -38
- package/skills/loadbare-app/references/data-binding.md +102 -13
- package/skills/loadbare-app/references/page-files.md +25 -16
- package/skills/loadbare-app/references/server.md +4 -0
- package/skills/loadbare-app/references/widgets.md +94 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lb-constants.d.ts","sourceRoot":"","sources":["../../core/lb-constants.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,UAAU,aAAa,CAAC;AAKrC,eAAO,MAAM,WAAW,cAAc,CAAC;AAavC,eAAO,MAAM,SAAS,YAAY,CAAC;AAInC,eAAO,MAAM,QAAQ,MAAM,CAAC;AAK5B,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAKnD,eAAO,MAAM,cAAc,iBAAiB,CAAC;AAM7C,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAI3C,eAAO,MAAM,QAAQ,kBAAuB,CAAC;AAK7C,eAAO,MAAM,oBAAoB,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"lb-constants.d.ts","sourceRoot":"","sources":["../../core/lb-constants.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,UAAU,aAAa,CAAC;AAKrC,eAAO,MAAM,WAAW,cAAc,CAAC;AAavC,eAAO,MAAM,SAAS,YAAY,CAAC;AAInC,eAAO,MAAM,QAAQ,MAAM,CAAC;AAK5B,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAKnD,eAAO,MAAM,cAAc,iBAAiB,CAAC;AAM7C,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAI3C,eAAO,MAAM,QAAQ,kBAAuB,CAAC;AA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AClD,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD,eAAO,MAAM,eAAe,8DAIlB,CAAC;AAKX,eAAO,MAAM,UAAU,2BAA4B,CAAC;AAGpD,eAAO,MAAM,QAAQ,QAAQ,CAAC;AAC9B,eAAO,MAAM,SAAS,SAAS,CAAC;AAKhC,eAAO,MAAM,SAAS,WAAW,CAAC;AAClC,eAAO,MAAM,eAAe,YAAY,CAAC;AACzC,eAAO,MAAM,qBAAqB,kBAAkB,CAAC;AACrD,eAAO,MAAM,uBAAuB,oBAAoB,CAAC;AAGzD,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAI3C,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAG3C,eAAO,MAAM,gBAAgB,mBAAmB,CAAC;AAMjD,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAK3C,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAGnD,eAAO,MAAM,SAAS,YAAY,CAAC;AAInC,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAK/C,eAAO,MAAM,oBAAoB,6KAUvB,CAAC;AAQX,eAAO,MAAM,YAAY,WAAW,CAAC;AASrC,eAAO,MAAM,WAAW,QAAQ,CAAC;AAIjC,eAAO,MAAM,qBAAqB,QAAS,CAAC"}
|
|
@@ -48,6 +48,71 @@ export const LIVE_ROW = `[${ATTR_ROW_LIVE}]`;
|
|
|
48
48
|
// it holds, so "no members yet" is a stylesheet rule rather than a
|
|
49
49
|
// conditional in every widget.
|
|
50
50
|
export const ATTR_QUERY_ROW_COUNT = "lb-query-row-count";
|
|
51
|
+
// --- Order and groups (docs/reference/data-binding.md) -------------------
|
|
52
|
+
// A `rows` query's order is a rule over its columns, and the hub places every
|
|
53
|
+
// live row by it. A group is a run of rows sharing the order's leading term.
|
|
54
|
+
// On a `<template>` inside an element naming a query: a group template. Its
|
|
55
|
+
// content holds the group's heading and exactly one nested `<template>`,
|
|
56
|
+
// which is where the group's contents go: the next group template, or, at
|
|
57
|
+
// the innermost level, the row template. The nth group template breaks on
|
|
58
|
+
// the order's nth term. The markup's nesting decides whether the contents
|
|
59
|
+
// land inside the heading's element or beside it.
|
|
60
|
+
export const ATTR_GROUP = "lb-group";
|
|
61
|
+
// Stamped by the hub on each top-level element of a group it built, and on
|
|
62
|
+
// nothing else, as ATTR_ROW_LIVE is on a live row.
|
|
63
|
+
export const ATTR_GROUP_LIVE = "lb-group-live";
|
|
64
|
+
// Stamped beside ATTR_GROUP_LIVE: the column the group breaks on, and its
|
|
65
|
+
// value there.
|
|
66
|
+
export const ATTR_GROUP_COLUMN = "lb-group-column";
|
|
67
|
+
export const ATTR_GROUP_VALUE = "lb-group-value";
|
|
68
|
+
// Selects a group's element, as LIVE_ROW selects a live row.
|
|
69
|
+
export const LIVE_GROUP = `[${ATTR_GROUP_LIVE}]`;
|
|
70
|
+
// Aggregates, written on any element in a group template or in the element
|
|
71
|
+
// naming the query: the hub sets the element from the rows of the nearest
|
|
72
|
+
// group around it, or of the whole list outside any group. `lb-count` takes
|
|
73
|
+
// no value; the others name the column they aggregate.
|
|
74
|
+
export const ATTR_COUNT = "lb-count";
|
|
75
|
+
export const ATTR_SUM = "lb-sum";
|
|
76
|
+
export const ATTR_AVG = "lb-avg";
|
|
77
|
+
export const ATTR_MIN = "lb-min";
|
|
78
|
+
export const ATTR_MAX = "lb-max";
|
|
79
|
+
export const AGGREGATES = [
|
|
80
|
+
ATTR_COUNT,
|
|
81
|
+
ATTR_SUM,
|
|
82
|
+
ATTR_AVG,
|
|
83
|
+
ATTR_MIN,
|
|
84
|
+
ATTR_MAX,
|
|
85
|
+
];
|
|
86
|
+
// The query parm that carries the user's order for one query: this prefix,
|
|
87
|
+
// then the query's name. It replaces the order the server declared. It is
|
|
88
|
+
// the one parm Loadbare gives a meaning, and it still reaches `contextFor`.
|
|
89
|
+
export const ORDER_PARM_PREFIX = "lb-order-";
|
|
90
|
+
// Written before a column in an order, it sorts that column descending.
|
|
91
|
+
export const ORDER_DESCENDING = "-";
|
|
92
|
+
// --- What happened to a row (docs/reference/data-binding.md) ------------
|
|
93
|
+
// Every change the hub makes to a list is one a stylesheet can see, so an
|
|
94
|
+
// application animates with CSS alone. The first three are cleared when the
|
|
95
|
+
// hub next touches the row, and a stamp applied again is removed and added
|
|
96
|
+
// as two changes, so an animation keyed to it plays again.
|
|
97
|
+
// The row was created when the hub last touched it.
|
|
98
|
+
export const ATTR_ROW_CREATED = "lb-row-created";
|
|
99
|
+
// The row's values changed when the hub last touched it.
|
|
100
|
+
export const ATTR_ROW_CHANGED = "lb-row-changed";
|
|
101
|
+
// The row moved when the hub last touched it, because the order put it
|
|
102
|
+
// somewhere else. A copy stays behind where it was, leaving.
|
|
103
|
+
export const ATTR_ROW_MOVED = "lb-row-moved";
|
|
104
|
+
// What a request from this page did to the row: one of the three values
|
|
105
|
+
// below. Cleared at every landing of the row's query, so a script reading it
|
|
106
|
+
// after a landing reads only what that landing did.
|
|
107
|
+
export const ATTR_ROW_REQUESTED = "lb-row-requested";
|
|
108
|
+
export const REQUESTED_CREATED = "created";
|
|
109
|
+
export const REQUESTED_CHANGED = "changed";
|
|
110
|
+
export const REQUESTED_MOVED = "moved";
|
|
111
|
+
// A row or a group on its way out. It is no longer live, takes no input, and
|
|
112
|
+
// is removed once the animations running on it have finished, at once when
|
|
113
|
+
// there are none.
|
|
114
|
+
export const ATTR_ROW_LEAVING = "lb-row-leaving";
|
|
115
|
+
export const ATTR_GROUP_LEAVING = "lb-group-leaving";
|
|
51
116
|
// --- Requests (docs/reference/data-binding.md) --------------------------
|
|
52
117
|
// Names the request an element issues when it commits: a form on submit, a
|
|
53
118
|
// control on change, anything else on click.
|
|
@@ -83,6 +148,10 @@ export const LB_ROW_REQUESTS = [
|
|
|
83
148
|
REQUEST_ROW_UPDATE,
|
|
84
149
|
REQUEST_ROW_DELETE,
|
|
85
150
|
];
|
|
151
|
+
// Loadbare also owns every method name on a custom element that begins with
|
|
152
|
+
// `lb` and a capital. These are the ones it calls (the RowsHost interface in
|
|
153
|
+
// core/lb-types.ts); the builder refuses a script that declares any other.
|
|
154
|
+
export const LB_METHODS = ["lbRowsLanded"];
|
|
86
155
|
// --- Kinds --------------------------------------------------------------
|
|
87
156
|
export const KIND_ROW = "row";
|
|
88
157
|
export const KIND_ROWS = "rows";
|
|
@@ -121,6 +190,8 @@ export const DEVELOPER_ATTRIBUTES = [
|
|
|
121
190
|
ATTR_QUERY,
|
|
122
191
|
ATTR_COLUMN,
|
|
123
192
|
ATTR_SHOW,
|
|
193
|
+
ATTR_GROUP,
|
|
194
|
+
...AGGREGATES,
|
|
124
195
|
ATTR_REQUEST,
|
|
125
196
|
ATTR_URL_LINK,
|
|
126
197
|
ATTR_URL_PUSH,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lb-constants.js","sourceRoot":"","sources":["../../core/lb-constants.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2DAA2D;AAC3D,kCAAkC;AAElC,4EAA4E;AAC5E,wEAAwE;AACxE,uEAAuE;AACvE,2EAA2E;AAC3E,2BAA2B;AAE3B,wEAAwE;AACxE,yDAAyD;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC;AAErC,wEAAwE;AACxE,2EAA2E;AAC3E,mCAAmC;AACnC,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;AAEvC,4EAA4E;AAC5E,2EAA2E;AAC3E,4BAA4B;AAC5B,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,yEAAyE;AACzE,2EAA2E;AAC3E,6EAA6E;AAC7E,8EAA8E;AAC9E,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC;AAEnC,qEAAqE;AACrE,kEAAkE;AAClE,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CAAC;AAE5B,0EAA0E;AAC1E,2EAA2E;AAC3E,yBAAyB;AACzB,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD,0E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,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AAErC,0EAA0E;AAC1E,wEAAwE;AACxE,wEAAwE;AACxE,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,iEAAiE;AACjE,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC;AAEjC,4EAA4E;AAC5E,kEAAkE;AAClE,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC","sourcesContent":["// Every Loadbare attribute name lives here. Nothing writes one as a string\n// literal — not a widget, not a page host, not a test. See\n// docs/reference/data-binding.md.\n\n// --- Landing (docs/reference/data-binding.md) ----------------------------\n// Everything is a query. The server answers every request with response\n// items, one per query, and each carries the query's kind and key. The\n// markup names a query and the columns it shows; it never repeats what the\n// server already declared.\n\n// Names the query whose rows land in an element's content. A nested one\n// begins a new query: what is inside it is that query's.\nexport const ATTR_QUERY = \"lb-query\";\n\n// The column an element shows, read from the nearest ancestor row. On a\n// control the hub sets its value, and gathers it back under this name when\n// the control's request is issued.\nexport const ATTR_COLUMN = \"lb-column\";\n\n// The column that decides whether an element is present: `null` and `false`\n// are off, and every other value is on. It reads from the nearest ancestor\n// row, as ATTR_COLUMN does.\n//\n// An element that is off is moved into a `<template>` carrying this attribute\n// and the same column, standing where the element stood, and moved back out\n// when the column turns on. The builder ships every such element already\n// inside its template. A developer writes this attribute on an element and\n// never on a template: the template form is Loadbare's, and holds the absent\n// branch in the document so the hub holds nothing. Landing reaches inside it,\n// so a branch that returns is already current; nothing else does.\nexport const ATTR_SHOW = \"lb-show\";\n\n// Written before the column in ATTR_SHOW, it reverses the condition:\n// `lb-show=\"!chosen\"` is present while `chosen` is null or false.\nexport const SHOW_NOT = \"!\";\n\n// Stamped by the hub on every element it sets from a column: the value it\n// set, so a stylesheet can select on it and a custom element that is not a\n// control can render it.\nexport const ATTR_COLUMN_VALUE = \"lb-column-value\";\n\n// Stamped by the hub on each live row, and on an element a `row` lands on\n// itself: the row's key. The key column is the query's, declared by the\n// server and carried by every response item.\nexport const ATTR_KEY_VALUE = \"lb-key-value\";\n\n// Stamped by the hub on each live row, and on nothing else: the element it\n// cloned from a row template. A key alone does not say so, because an\n// element a `row` lands on carries one too, and a live row may name a query\n// of its own, so neither the key nor `lb-query` tells the two apart.\nexport const ATTR_ROW_LIVE = \"lb-row-live\";\n\n// Selects a live row. Anything that walks rows — reconciliation, gathering,\n// a custom element's own placement — finds them with this and nothing else.\nexport const LIVE_ROW = `[${ATTR_ROW_LIVE}]`;\n\n// Stamped by the hub on an element with a row template: how many live rows\n// it holds, so \"no members yet\" is a stylesheet rule rather than a\n// conditional in every widget.\nexport const ATTR_QUERY_ROW_COUNT = \"lb-query-row-count\";\n\n// --- Requests (docs/reference/data-binding.md) --------------------------\n// Names the request an element issues when it commits: a form on submit, a\n// control on change, anything else on click.\nexport const ATTR_REQUEST = \"lb-request\";\n\n// Every request travels as one bubbling event of this name, whoever issued\n// it, so an ancestor may stop it.\nexport const LB_EVENT_NAME = \"lb-request\";\n\n// The counterpart of LB_EVENT_NAME: raised on the element that committed,\n// once what the request brought back has landed or the round trip has\n// failed. It bubbles, so the element that cares about the outcome need not\n// be the one that committed.\nexport const LB_DONE_EVENT_NAME = \"lb-request-done\";\n\n// Stamped on the element that issued a request while its round trip is in\n// flight, alongside aria-busy. A commit on an element carrying it is ignored.\nexport const ATTR_REQUEST_PENDING = \"lb-request-pending\";\n\n// Stamped on the element that issued a request when its round trip failed —\n// a non-2xx response, a thrown application error, or a timeout, all alike.\n// Cleared at the start of that element's next request.\nexport const ATTR_REQUEST_ERROR = \"lb-request-error\";\n\n// --- Reserved names ----------------------------------------------------\n// Loadbare owns every name beginning with this prefix: attribute names, the\n// values of its attributes, query names, request names, the column names of\n// its own queries, custom element names and event names. The server refuses\n// a page that declares a query or a request so named.\nexport const LB_RESERVED_PREFIX = \"lb-\";\n\n// The requests Loadbare provides. Each runs the page's crud declaration for\n// the request's query.\nexport const REQUEST_ROW_INSERT = \"lb-row-insert\";\nexport const REQUEST_ROW_UPDATE = \"lb-row-update\";\nexport const REQUEST_ROW_DELETE = \"lb-row-delete\";\n\nexport const LB_ROW_REQUESTS = [\n REQUEST_ROW_INSERT,\n REQUEST_ROW_UPDATE,\n REQUEST_ROW_DELETE,\n] as const;\n\n// --- Kinds --------------------------------------------------------------\nexport const KIND_ROW = \"row\";\nexport const KIND_ROWS = \"rows\";\n\n// --- The URL (docs/reference/chrome.md) ---------------------------------\n// The query the hub serves: one row, keyed by the path, whose other columns\n// are the query parms.\nexport const URL_QUERY = \"lb-url\";\nexport const URL_COLUMN_PATH = \"lb-path\";\nexport const URL_COLUMN_PAGE_LABEL = \"lb-page-label\";\nexport const URL_COLUMN_PAGE_UNKNOWN = \"lb-page-unknown\";\n\n// On an `<a>`: a plain primary click sets `lb-path` from the `href`.\nexport const ATTR_URL_LINK = \"lb-url-link\";\n\n// On an element with `lb-request`: its update of `lb-url` pushes a history\n// entry instead of replacing one.\nexport const ATTR_URL_PUSH = \"lb-url-push\";\n\n// On a `<dialog>`: the hub calls showModal() when `lb-page-unknown` is true.\nexport const ATTR_URL_UNKNOWN = \"lb-url-unknown\";\n\n// --- Build time (docs/reference/custom-elements.md) ---------------------\n// Marks the element in an element file whose children receive the rest of\n// the custom element's content. An attribute rather than an element because\n// HTML content models discard foreign elements inside <select> and <table>.\nexport const ATTR_EXP_SLOT = \"lb-exp-slot\";\n\n// One name in two positions. In an element file it marks a destination; on a\n// `<template>` in the custom element's content it names the destination\n// that template is for, and the template's content moves into it.\nexport const ATTR_EXP_TEMPLATE = \"lb-exp-template\";\n\n// A page ships as <template lb-page=\"<stub>\">.\nexport const ATTR_PAGE = \"lb-page\";\n\n// Stamped by the builder beside ATTR_PAGE: the text content of the page\n// file's `<title>`, which the builder removes.\nexport const ATTR_PAGE_TITLE = \"lb-page-title\";\n\n// The attributes a developer writes. The builder refuses any other `lb-`\n// attribute in markup: the rest are stamps, written by the hub or the\n// builder and never by hand or by script.\nexport const DEVELOPER_ATTRIBUTES = [\n ATTR_QUERY,\n ATTR_COLUMN,\n ATTR_SHOW,\n ATTR_REQUEST,\n ATTR_URL_LINK,\n ATTR_URL_PUSH,\n ATTR_URL_UNKNOWN,\n] as const;\n\n// The hub's own tag. It is exempt from the rule every other LB-* tag\n// follows: expansion does not require it to have a definition (build/expand.ts),\n// and the client build does not require it to have a script of its own\n// (build/elements.ts) — it is the framework's live element, always present,\n// registered once by the package's main entry point, not a widget an\n// application discovers or declares.\nexport const HUB_TAG_NAME = \"lb-hub\";\n\n// --- Wire --------------------------------------------------------------\n// One path, one method: everything the hub asks of the server is a POST\n// below this path. The page's stub follows it, and the query string the\n// browser is showing rides after that verbatim, so `/accounts?acct=23` asks\n// as `POST /lb/accounts?acct=23` and the server always knows what URL the\n// browser is showing. Navigation is therefore the only GET an application\n// serves, which is what leaves the page name space unrestricted.\nexport const LB_ENDPOINT = \"/lb\";\n\n// A client-side deadline for one round trip. fetch() has no deadline of its\n// own; past this the request is aborted and treated as a failure.\nexport const LB_REQUEST_TIMEOUT_MS = 10_000;\n"]}
|
|
1
|
+
{"version":3,"file":"lb-constants.js","sourceRoot":"","sources":["../../core/lb-constants.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2DAA2D;AAC3D,kCAAkC;AAElC,4EAA4E;AAC5E,wEAAwE;AACxE,uEAAuE;AACvE,2EAA2E;AAC3E,2BAA2B;AAE3B,wEAAwE;AACxE,yDAAyD;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC;AAErC,wEAAwE;AACxE,2EAA2E;AAC3E,mCAAmC;AACnC,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;AAEvC,4EAA4E;AAC5E,2EAA2E;AAC3E,4BAA4B;AAC5B,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,yEAAyE;AACzE,2EAA2E;AAC3E,6EAA6E;AAC7E,8EAA8E;AAC9E,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,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AEzD,qEAAqE;AACrE,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;AAE3C,2EAA2E;AAC3E,kCAAkC;AAClC,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;AAE3C,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAEjD,2EAA2E;AAC3E,0EAA0E;AAC1E,4EAA4E;AAC5E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;AAE3C,6EAA6E;AAC7E,wEAAwE;AACxE,kEAAkE;AAClE,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD,+CAA+C;AAC/C,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC;AAEnC,wEAAwE;AACxE,+CAA+C;AAC/C,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC;AAE/C,yEAAyE;AACzE,sEAAsE;AACtE,0CAA0C;AAC1C,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,UAAU;IACV,WAAW;IACX,SAAS;IACT,UAAU;IACV,GAAG,UAAU;IACb,YAAY;IACZ,aAAa;IACb,aAAa;IACb,gBAAgB;CACR,CAAC;AAEX,qEAAqE;AACrE,iFAAiF;AACjF,uEAAuE;AACvE,4EAA4E;AAC5E,qEAAqE;AACrE,qCAAqC;AACrC,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AAErC,0EAA0E;AAC1E,wEAAwE;AACxE,wEAAwE;AACxE,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,iEAAiE;AACjE,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC;AAEjC,4EAA4E;AAC5E,kEAAkE;AAClE,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC","sourcesContent":["// Every Loadbare attribute name lives here. Nothing writes one as a string\n// literal — not a widget, not a page host, not a test. See\n// docs/reference/data-binding.md.\n\n// --- Landing (docs/reference/data-binding.md) ----------------------------\n// Everything is a query. The server answers every request with response\n// items, one per query, and each carries the query's kind and key. The\n// markup names a query and the columns it shows; it never repeats what the\n// server already declared.\n\n// Names the query whose rows land in an element's content. A nested one\n// begins a new query: what is inside it is that query's.\nexport const ATTR_QUERY = \"lb-query\";\n\n// The column an element shows, read from the nearest ancestor row. On a\n// control the hub sets its value, and gathers it back under this name when\n// the control's request is issued.\nexport const ATTR_COLUMN = \"lb-column\";\n\n// The column that decides whether an element is present: `null` and `false`\n// are off, and every other value is on. It reads from the nearest ancestor\n// row, as ATTR_COLUMN does.\n//\n// An element that is off is moved into a `<template>` carrying this attribute\n// and the same column, standing where the element stood, and moved back out\n// when the column turns on. The builder ships every such element already\n// inside its template. A developer writes this attribute on an element and\n// never on a template: the template form is Loadbare's, and holds the absent\n// branch in the document so the hub holds nothing. Landing reaches inside it,\n// so a branch that returns is already current; nothing else does.\nexport const ATTR_SHOW = \"lb-show\";\n\n// Written before the column in ATTR_SHOW, it reverses the condition:\n// `lb-show=\"!chosen\"` is present while `chosen` is null or false.\nexport const SHOW_NOT = \"!\";\n\n// Stamped by the hub on every element it sets from a column: the value it\n// set, so a stylesheet can select on it and a custom element that is not a\n// control can render it.\nexport const ATTR_COLUMN_VALUE = \"lb-column-value\";\n\n// Stamped by the hub on each live row, and on an element a `row` lands on\n// itself: the row's key. The key column is the query's, declared by the\n// server and carried by every response item.\nexport const ATTR_KEY_VALUE = \"lb-key-value\";\n\n// Stamped by the hub on each live row, and on nothing else: the element it\n// cloned from a row template. A key alone does not say so, because an\n// element a `row` lands on carries one too, and a live row may name a query\n// of its own, so neither the key nor `lb-query` tells the two apart.\nexport const ATTR_ROW_LIVE = \"lb-row-live\";\n\n// Selects a live row. Anything that walks rows — reconciliation, gathering,\n// a custom element's own placement — finds them with this and nothing else.\nexport const LIVE_ROW = `[${ATTR_ROW_LIVE}]`;\n\n// Stamped by the hub on an element with a row template: how many live rows\n// it holds, so \"no members yet\" is a stylesheet rule rather than a\n// conditional in every widget.\nexport const ATTR_QUERY_ROW_COUNT = \"lb-query-row-count\";\n\n// --- Order and groups (docs/reference/data-binding.md) -------------------\n// A `rows` query's order is a rule over its columns, and the hub places every\n// live row by it. A group is a run of rows sharing the order's leading term.\n\n// On a `<template>` inside an element naming a query: a group template. Its\n// content holds the group's heading and exactly one nested `<template>`,\n// which is where the group's contents go: the next group template, or, at\n// the innermost level, the row template. The nth group template breaks on\n// the order's nth term. The markup's nesting decides whether the contents\n// land inside the heading's element or beside it.\nexport const ATTR_GROUP = \"lb-group\";\n\n// Stamped by the hub on each top-level element of a group it built, and on\n// nothing else, as ATTR_ROW_LIVE is on a live row.\nexport const ATTR_GROUP_LIVE = \"lb-group-live\";\n\n// Stamped beside ATTR_GROUP_LIVE: the column the group breaks on, and its\n// value there.\nexport const ATTR_GROUP_COLUMN = \"lb-group-column\";\nexport const ATTR_GROUP_VALUE = \"lb-group-value\";\n\n// Selects a group's element, as LIVE_ROW selects a live row.\nexport const LIVE_GROUP = `[${ATTR_GROUP_LIVE}]`;\n\n// Aggregates, written on any element in a group template or in the element\n// naming the query: the hub sets the element from the rows of the nearest\n// group around it, or of the whole list outside any group. `lb-count` takes\n// no value; the others name the column they aggregate.\nexport const ATTR_COUNT = \"lb-count\";\nexport const ATTR_SUM = \"lb-sum\";\nexport const ATTR_AVG = \"lb-avg\";\nexport const ATTR_MIN = \"lb-min\";\nexport const ATTR_MAX = \"lb-max\";\n\nexport const AGGREGATES = [\n ATTR_COUNT,\n ATTR_SUM,\n ATTR_AVG,\n ATTR_MIN,\n ATTR_MAX,\n] as const;\n\n// The query parm that carries the user's order for one query: this prefix,\n// then the query's name. It replaces the order the server declared. It is\n// the one parm Loadbare gives a meaning, and it still reaches `contextFor`.\nexport const ORDER_PARM_PREFIX = \"lb-order-\";\n\n// Written before a column in an order, it sorts that column descending.\nexport const ORDER_DESCENDING = \"-\";\n\n// --- What happened to a row (docs/reference/data-binding.md) ------------\n// Every change the hub makes to a list is one a stylesheet can see, so an\n// application animates with CSS alone. The first three are cleared when the\n// hub next touches the row, and a stamp applied again is removed and added\n// as two changes, so an animation keyed to it plays again.\n\n// The row was created when the hub last touched it.\nexport const ATTR_ROW_CREATED = \"lb-row-created\";\n\n// The row's values changed when the hub last touched it.\nexport const ATTR_ROW_CHANGED = \"lb-row-changed\";\n\n// The row moved when the hub last touched it, because the order put it\n// somewhere else. A copy stays behind where it was, leaving.\nexport const ATTR_ROW_MOVED = \"lb-row-moved\";\n\n// What a request from this page did to the row: one of the three values\n// below. Cleared at every landing of the row's query, so a script reading it\n// after a landing reads only what that landing did.\nexport const ATTR_ROW_REQUESTED = \"lb-row-requested\";\nexport const REQUESTED_CREATED = \"created\";\nexport const REQUESTED_CHANGED = \"changed\";\nexport const REQUESTED_MOVED = \"moved\";\n\n// A row or a group on its way out. It is no longer live, takes no input, and\n// is removed once the animations running on it have finished, at once when\n// there are none.\nexport const ATTR_ROW_LEAVING = \"lb-row-leaving\";\nexport const ATTR_GROUP_LEAVING = \"lb-group-leaving\";\n\n// --- Requests (docs/reference/data-binding.md) --------------------------\n// Names the request an element issues when it commits: a form on submit, a\n// control on change, anything else on click.\nexport const ATTR_REQUEST = \"lb-request\";\n\n// Every request travels as one bubbling event of this name, whoever issued\n// it, so an ancestor may stop it.\nexport const LB_EVENT_NAME = \"lb-request\";\n\n// The counterpart of LB_EVENT_NAME: raised on the element that committed,\n// once what the request brought back has landed or the round trip has\n// failed. It bubbles, so the element that cares about the outcome need not\n// be the one that committed.\nexport const LB_DONE_EVENT_NAME = \"lb-request-done\";\n\n// Stamped on the element that issued a request while its round trip is in\n// flight, alongside aria-busy. A commit on an element carrying it is ignored.\nexport const ATTR_REQUEST_PENDING = \"lb-request-pending\";\n\n// Stamped on the element that issued a request when its round trip failed —\n// a non-2xx response, a thrown application error, or a timeout, all alike.\n// Cleared at the start of that element's next request.\nexport const ATTR_REQUEST_ERROR = \"lb-request-error\";\n\n// --- Reserved names ----------------------------------------------------\n// Loadbare owns every name beginning with this prefix: attribute names, the\n// values of its attributes, query names, request names, the column names of\n// its own queries, custom element names and event names. The server refuses\n// a page that declares a query or a request so named.\nexport const LB_RESERVED_PREFIX = \"lb-\";\n\n// The requests Loadbare provides. Each runs the page's crud declaration for\n// the request's query.\nexport const REQUEST_ROW_INSERT = \"lb-row-insert\";\nexport const REQUEST_ROW_UPDATE = \"lb-row-update\";\nexport const REQUEST_ROW_DELETE = \"lb-row-delete\";\n\nexport const LB_ROW_REQUESTS = [\n REQUEST_ROW_INSERT,\n REQUEST_ROW_UPDATE,\n REQUEST_ROW_DELETE,\n] as const;\n\n// Loadbare also owns every method name on a custom element that begins with\n// `lb` and a capital. These are the ones it calls (the RowsHost interface in\n// core/lb-types.ts); the builder refuses a script that declares any other.\nexport const LB_METHODS = [\"lbRowsLanded\"] as const;\n\n// --- Kinds --------------------------------------------------------------\nexport const KIND_ROW = \"row\";\nexport const KIND_ROWS = \"rows\";\n\n// --- The URL (docs/reference/chrome.md) ---------------------------------\n// The query the hub serves: one row, keyed by the path, whose other columns\n// are the query parms.\nexport const URL_QUERY = \"lb-url\";\nexport const URL_COLUMN_PATH = \"lb-path\";\nexport const URL_COLUMN_PAGE_LABEL = \"lb-page-label\";\nexport const URL_COLUMN_PAGE_UNKNOWN = \"lb-page-unknown\";\n\n// On an `<a>`: a plain primary click sets `lb-path` from the `href`.\nexport const ATTR_URL_LINK = \"lb-url-link\";\n\n// On an element with `lb-request`: its update of `lb-url` pushes a history\n// entry instead of replacing one.\nexport const ATTR_URL_PUSH = \"lb-url-push\";\n\n// On a `<dialog>`: the hub calls showModal() when `lb-page-unknown` is true.\nexport const ATTR_URL_UNKNOWN = \"lb-url-unknown\";\n\n// --- Build time (docs/reference/custom-elements.md) ---------------------\n// Marks the element in an element file whose children receive the rest of\n// the custom element's content. An attribute rather than an element because\n// HTML content models discard foreign elements inside <select> and <table>.\nexport const ATTR_EXP_SLOT = \"lb-exp-slot\";\n\n// One name in two positions. In an element file it marks a destination; on a\n// `<template>` in the custom element's content it names the destination\n// that template is for, and the template's content moves into it.\nexport const ATTR_EXP_TEMPLATE = \"lb-exp-template\";\n\n// A page ships as <template lb-page=\"<stub>\">.\nexport const ATTR_PAGE = \"lb-page\";\n\n// Stamped by the builder beside ATTR_PAGE: the text content of the page\n// file's `<title>`, which the builder removes.\nexport const ATTR_PAGE_TITLE = \"lb-page-title\";\n\n// The attributes a developer writes. The builder refuses any other `lb-`\n// attribute in markup: the rest are stamps, written by the hub or the\n// builder and never by hand or by script.\nexport const DEVELOPER_ATTRIBUTES = [\n ATTR_QUERY,\n ATTR_COLUMN,\n ATTR_SHOW,\n ATTR_GROUP,\n ...AGGREGATES,\n ATTR_REQUEST,\n ATTR_URL_LINK,\n ATTR_URL_PUSH,\n ATTR_URL_UNKNOWN,\n] as const;\n\n// The hub's own tag. It is exempt from the rule every other LB-* tag\n// follows: expansion does not require it to have a definition (build/expand.ts),\n// and the client build does not require it to have a script of its own\n// (build/elements.ts) — it is the framework's live element, always present,\n// registered once by the package's main entry point, not a widget an\n// application discovers or declares.\nexport const HUB_TAG_NAME = \"lb-hub\";\n\n// --- Wire --------------------------------------------------------------\n// One path, one method: everything the hub asks of the server is a POST\n// below this path. The page's stub follows it, and the query string the\n// browser is showing rides after that verbatim, so `/accounts?acct=23` asks\n// as `POST /lb/accounts?acct=23` and the server always knows what URL the\n// browser is showing. Navigation is therefore the only GET an application\n// serves, which is what leaves the page name space unrestricted.\nexport const LB_ENDPOINT = \"/lb\";\n\n// A client-side deadline for one round trip. fetch() has no deadline of its\n// own; past this the request is aborted and treated as a failure.\nexport const LB_REQUEST_TIMEOUT_MS = 10_000;\n"]}
|
package/dist/core/lb-types.d.ts
CHANGED
|
@@ -12,11 +12,11 @@ export type Row = Record<string, unknown>;
|
|
|
12
12
|
* Part of a `rows` query's answer — see docs/reference/server.md, "Queries".
|
|
13
13
|
*
|
|
14
14
|
* Rows named here are added or updated, keys in `drop` are removed, and
|
|
15
|
-
* anything unnamed is left alone
|
|
16
|
-
* order
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* anything unnamed is left alone. The hub places what it names by the
|
|
16
|
+
* query's order. Add and remove are one result rather than two because the
|
|
17
|
+
* interesting cases are both at once — a row whose sort key changed has to
|
|
18
|
+
* move, a swap is one out and one in — and two messages would paint the
|
|
19
|
+
* intermediate state.
|
|
20
20
|
*/
|
|
21
21
|
export interface Patch {
|
|
22
22
|
rows?: Row[];
|
|
@@ -25,8 +25,9 @@ export interface Patch {
|
|
|
25
25
|
/** A query's kind, declared by the server and carried by every answer. */
|
|
26
26
|
export type Kind = typeof KIND_ROW | typeof KIND_ROWS;
|
|
27
27
|
/**
|
|
28
|
-
* What a `rows` query answers with: all rows,
|
|
29
|
-
*
|
|
28
|
+
* What a `rows` query answers with: all rows, or a patch. `Array.isArray`
|
|
29
|
+
* tells the two apart. All rows arrive in the order the server chose, which
|
|
30
|
+
* is the order they show in when the query declares none.
|
|
30
31
|
*/
|
|
31
32
|
export type RowsResult = Row[] | Patch;
|
|
32
33
|
export declare function isPatch(result: RowsResult): result is Patch;
|
|
@@ -42,6 +43,9 @@ export type HubData = Record<string, HubResult>;
|
|
|
42
43
|
* One query's answer on the wire: its name, its kind, its key's column name,
|
|
43
44
|
* and exactly one of a row, all rows, or a patch. A patch answers a `rows`
|
|
44
45
|
* query only.
|
|
46
|
+
*
|
|
47
|
+
* A `rows` query also carries what it declared about order: the order the
|
|
48
|
+
* server gives it, and whether the query reads the order parm itself.
|
|
45
49
|
*/
|
|
46
50
|
export interface ResponseItem {
|
|
47
51
|
query: string;
|
|
@@ -50,6 +54,8 @@ export interface ResponseItem {
|
|
|
50
54
|
row?: Row;
|
|
51
55
|
rows?: Row[];
|
|
52
56
|
patch?: Patch;
|
|
57
|
+
order?: string;
|
|
58
|
+
serverSortedByUrl?: boolean;
|
|
53
59
|
}
|
|
54
60
|
/** Every response the server sends: a page load and a request alike. */
|
|
55
61
|
export type HubResponse = ResponseItem[];
|
|
@@ -98,7 +104,7 @@ export declare function pageNameFor(path: string): string;
|
|
|
98
104
|
* Where a row for `lb-url` leads, from a page and its query parms.
|
|
99
105
|
*
|
|
100
106
|
* A column whose name begins with `lb-` is Loadbare's, and never a query
|
|
101
|
-
* parm; every other column is one. An `lb-path` naming another page enters
|
|
107
|
+
* parm, except an order parm, which is one; every other column is one. An `lb-path` naming another page enters
|
|
102
108
|
* it with only the parms the row names. Otherwise the named parms are set,
|
|
103
109
|
* or taken out when empty, and the rest are kept.
|
|
104
110
|
*
|
|
@@ -106,27 +112,50 @@ export declare function pageNameFor(path: string): string;
|
|
|
106
112
|
* and the hub writes the URL it names. The two must agree, or what the page
|
|
107
113
|
* shows would differ from what the address bar says.
|
|
108
114
|
*/
|
|
115
|
+
/** One term of an order: a column, and whether it sorts descending. */
|
|
116
|
+
export interface OrderTerm {
|
|
117
|
+
column: string;
|
|
118
|
+
descending: boolean;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* An order's terms, from its text: columns separated by commas, each
|
|
122
|
+
* descending when it begins with `-`. Throws on a term that names no column.
|
|
123
|
+
* An empty text is no order.
|
|
124
|
+
*/
|
|
125
|
+
export declare function parseOrder(text: string): OrderTerm[];
|
|
126
|
+
/** The query parm carrying the user's order for a query. */
|
|
127
|
+
export declare function orderParm(query: string): string;
|
|
128
|
+
/**
|
|
129
|
+
* Compare two column values, ascending.
|
|
130
|
+
*
|
|
131
|
+
* A value compares by its JSON type, and nothing is guessed: numbers
|
|
132
|
+
* numerically, booleans false before true, strings as the user's language
|
|
133
|
+
* orders them. A number that arrives as a string sorts as a string, so a
|
|
134
|
+
* numeric sort column is sent as a JSON number. Null and a missing value
|
|
135
|
+
* sort after everything, as Postgres sorts them ascending, and so first
|
|
136
|
+
* descending.
|
|
137
|
+
*/
|
|
138
|
+
export declare function compareValues(a: unknown, b: unknown): number;
|
|
139
|
+
/** Compare two rows by an order's terms. */
|
|
140
|
+
export declare function compareRows(a: Row, b: Row, terms: OrderTerm[]): number;
|
|
109
141
|
export declare function nextLocation(page: string, parms: URLSearchParams, row: Row): {
|
|
110
142
|
page: string;
|
|
111
143
|
parms: URLSearchParams;
|
|
112
144
|
moved: boolean;
|
|
113
145
|
};
|
|
114
146
|
/**
|
|
115
|
-
* The
|
|
147
|
+
* The hook a custom element holding rows may implement.
|
|
116
148
|
*
|
|
117
|
-
* The hub reconciles every row
|
|
118
|
-
*
|
|
119
|
-
* the hub does not own, so
|
|
120
|
-
* exactly that — see docs/reference/custom-elements.md.
|
|
149
|
+
* The hub reconciles and places every row itself, by the query's order, so a
|
|
150
|
+
* custom element reacts to rows and never places them. It is a method on an
|
|
151
|
+
* element the hub does not own, so it carries the `lb` prefix Loadbare
|
|
152
|
+
* reserves for exactly that — see docs/reference/custom-elements.md.
|
|
121
153
|
*/
|
|
122
154
|
export interface RowsHost {
|
|
123
155
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* rows accumulate in the order they arrive.
|
|
156
|
+
* Called once after a result has landed, with every row in place and
|
|
157
|
+
* every stamp set: for anything the element derives from its rows.
|
|
127
158
|
*/
|
|
128
|
-
lbPlaceRow?(el: Element, row: Row, template: HTMLTemplateElement): void;
|
|
129
|
-
/** Called once after a whole result has landed, for derived scaffolding. */
|
|
130
159
|
lbRowsLanded?(): void;
|
|
131
160
|
}
|
|
132
161
|
//# sourceMappingURL=lb-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lb-types.d.ts","sourceRoot":"","sources":["../../core/lb-types.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EACR,SAAS,
|
|
1
|
+
{"version":3,"file":"lb-types.d.ts","sourceRoot":"","sources":["../../core/lb-types.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EACR,SAAS,EAMV,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;GAOG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM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CAAC,IAAI,IAAI,CAAC;CACvB"}
|
package/dist/core/lb-types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
2
|
// The wire vocabulary. Shared by browser and server.
|
|
3
|
-
import { LB_RESERVED_PREFIX, LB_ROW_REQUESTS, URL_COLUMN_PATH, } from "./lb-constants.js";
|
|
3
|
+
import { LB_RESERVED_PREFIX, LB_ROW_REQUESTS, ORDER_DESCENDING, ORDER_PARM_PREFIX, URL_COLUMN_PATH, } from "./lb-constants.js";
|
|
4
4
|
export function isPatch(result) {
|
|
5
5
|
return !Array.isArray(result);
|
|
6
6
|
}
|
|
@@ -37,22 +37,85 @@ export function pageNameFor(path) {
|
|
|
37
37
|
return name === "" ? "index" : name;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
* An order's terms, from its text: columns separated by commas, each
|
|
41
|
+
* descending when it begins with `-`. Throws on a term that names no column.
|
|
42
|
+
* An empty text is no order.
|
|
43
|
+
*/
|
|
44
|
+
export function parseOrder(text) {
|
|
45
|
+
if (text.trim() === "")
|
|
46
|
+
return [];
|
|
47
|
+
return text.split(",").map((raw) => {
|
|
48
|
+
const term = raw.trim();
|
|
49
|
+
const descending = term.startsWith(ORDER_DESCENDING);
|
|
50
|
+
const column = descending ? term.slice(ORDER_DESCENDING.length) : term;
|
|
51
|
+
if (column === "" || column.startsWith(ORDER_DESCENDING)) {
|
|
52
|
+
throw new Error(`the order '${text}' has a term naming no column`);
|
|
53
|
+
}
|
|
54
|
+
return { column, descending };
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** The query parm carrying the user's order for a query. */
|
|
58
|
+
export function orderParm(query) {
|
|
59
|
+
return ORDER_PARM_PREFIX + query;
|
|
60
|
+
}
|
|
61
|
+
/** Strings compare as the user's language orders them. */
|
|
62
|
+
const collator = new Intl.Collator();
|
|
63
|
+
/** How a value sorts among values of other types: by its JSON type. */
|
|
64
|
+
function rank(value) {
|
|
65
|
+
switch (typeof value) {
|
|
66
|
+
case "boolean":
|
|
67
|
+
return 0;
|
|
68
|
+
case "number":
|
|
69
|
+
return 1;
|
|
70
|
+
case "string":
|
|
71
|
+
return 2;
|
|
72
|
+
default:
|
|
73
|
+
return 3;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Compare two column values, ascending.
|
|
46
78
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
79
|
+
* A value compares by its JSON type, and nothing is guessed: numbers
|
|
80
|
+
* numerically, booleans false before true, strings as the user's language
|
|
81
|
+
* orders them. A number that arrives as a string sorts as a string, so a
|
|
82
|
+
* numeric sort column is sent as a JSON number. Null and a missing value
|
|
83
|
+
* sort after everything, as Postgres sorts them ascending, and so first
|
|
84
|
+
* descending.
|
|
50
85
|
*/
|
|
86
|
+
export function compareValues(a, b) {
|
|
87
|
+
const missingA = a === null || a === undefined;
|
|
88
|
+
const missingB = b === null || b === undefined;
|
|
89
|
+
if (missingA || missingB)
|
|
90
|
+
return missingA === missingB ? 0 : missingA ? 1 : -1;
|
|
91
|
+
const ra = rank(a);
|
|
92
|
+
const rb = rank(b);
|
|
93
|
+
if (ra !== rb)
|
|
94
|
+
return ra - rb;
|
|
95
|
+
if (typeof a === "number")
|
|
96
|
+
return a - b;
|
|
97
|
+
if (typeof a === "boolean")
|
|
98
|
+
return Number(a) - Number(b);
|
|
99
|
+
if (typeof a === "string")
|
|
100
|
+
return collator.compare(a, b);
|
|
101
|
+
return collator.compare(JSON.stringify(a), JSON.stringify(b));
|
|
102
|
+
}
|
|
103
|
+
/** Compare two rows by an order's terms. */
|
|
104
|
+
export function compareRows(a, b, terms) {
|
|
105
|
+
for (const { column, descending } of terms) {
|
|
106
|
+
const c = compareValues(a[column], b[column]);
|
|
107
|
+
if (c !== 0)
|
|
108
|
+
return descending ? -c : c;
|
|
109
|
+
}
|
|
110
|
+
return 0;
|
|
111
|
+
}
|
|
51
112
|
export function nextLocation(page, parms, row) {
|
|
52
113
|
const named = {};
|
|
53
114
|
for (const [name, value] of Object.entries(row)) {
|
|
54
|
-
if (name.startsWith(LB_RESERVED_PREFIX)
|
|
115
|
+
if (name.startsWith(LB_RESERVED_PREFIX) &&
|
|
116
|
+
!name.startsWith(ORDER_PARM_PREFIX)) {
|
|
55
117
|
continue;
|
|
118
|
+
}
|
|
56
119
|
named[name] = value === null || value === undefined ? "" : String(value);
|
|
57
120
|
}
|
|
58
121
|
const path = row[URL_COLUMN_PATH];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lb-types.js","sourceRoot":"","sources":["../../core/lb-types.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,qDAAqD;AAErD,OAAO,EAGL,kBAAkB,EAClB,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAoC3B,MAAM,UAAU,OAAO,CAAC,MAAkB;IACxC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAuDD,+DAA+D;AAC/D,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAQ,eAAqC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAuB,EACvB,KAA6B;IAE7B,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;IACzC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,EAAE;YAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;;YAC/B,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IACD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QUESTS,\n URL_COLUMN_PATH,\n} from \"./lb-constants.js\";\n\n/**\n * One row: its columns, by name.\n *\n * A value is whatever the server serialized. The hub knows nothing about its\n * type and enforces nothing: it hands each value to the browser untouched,\n * and the browser renders it as it sees fit. What a number, a date or a null\n * should look like is the application's decision, made in the query.\n */\nexport type Row = Record<string, unknown>;\n\n/**\n * Part of a `rows` query's answer — see docs/reference/server.md, \"Queries\".\n *\n * Rows named here are added or updated, keys in `drop` are removed, and\n * anything unnamed is left alone: its contents, and its place in whatever\n * order the widget is keeping. Add and remove are one result rather than two\n * because the interesting cases are both at once — a row whose sort key\n * changed has to move, a swap is one out and one in — and two messages would\n * paint the intermediate state.\n */\nexport interface Patch {\n rows?: Row[];\n drop?: unknown[];\n}\n\n/** A query's kind, declared by the server and carried by every answer. */\nexport type Kind = typeof KIND_ROW | typeof KIND_ROWS;\n\n/**\n * What a `rows` query answers with: all rows, which is also their order, or\n * a patch. `Array.isArray` tells the two apart.\n */\nexport type RowsResult = Row[] | Patch;\n\nexport function isPatch(result: RowsResult): result is Patch {\n return !Array.isArray(result);\n}\n\n/** What any one query answers with, as the application writes it. */\nexport type HubResult = Row | RowsResult;\n\n/**\n * What application code hands the engine: answers by query name. The engine\n * turns each into a response item, adding the kind and key the query\n * declared.\n */\nexport type HubData = Record<string, HubResult>;\n\n/**\n * One query's answer on the wire: its name, its kind, its key's column name,\n * and exactly one of a row, all rows, or a patch. A patch answers a `rows`\n * query only.\n */\nexport interface ResponseItem {\n query: string;\n kind: Kind;\n key: string;\n row?: Row;\n rows?: Row[];\n patch?: Patch;\n}\n\n/** Every response the server sends: a page load and a request alike. */\nexport type HubResponse = ResponseItem[];\n\n/**\n * Every request has one shape. The name picks the handler; the rest is\n * present when the hub found it.\n */\nexport interface HubRequest {\n name: string;\n query?: string;\n key?: string;\n values?: Record<string, string>;\n}\n\n/**\n * The detail of the `lb-request-done` event: the request as the hub\n * completed and sent it, and what came of it. `items` is every response\n * item that landed because of it, in the order it landed. `error` is set\n * when the request's own round trip failed, and then nothing landed.\n */\nexport interface HubRequestDone {\n request: HubRequest;\n items: ResponseItem[];\n error?: Error;\n}\n\n/** The fields a handler receives: the request, less its name. */\nexport type RequestFields = Omit<HubRequest, \"name\">;\n\n/** Whether a name is one of the requests Loadbare provides. */\nexport function isRowRequest(name: string): boolean {\n return (LB_ROW_REQUESTS as readonly string[]).includes(name);\n}\n\n/**\n * A query string with some parms set, and the rest as they were. An empty\n * value takes its parm out, since empty is every parm's default and a\n * default is left out of the URL.\n *\n * One rule on both sides of the wire: the hub applies it to the address bar,\n * and the server to the query string it loads the page at after a request\n * returned `lb-url`. The two must agree, or what the page shows would differ\n * from what the address bar says.\n */\nexport function withQueryParms(\n search: URLSearchParams,\n parms: Record<string, string>,\n): URLSearchParams {\n const next = new URLSearchParams(search);\n for (const [name, value] of Object.entries(parms)) {\n if (value === \"\") next.delete(name);\n else next.set(name, value);\n }\n return next;\n}\n\n/**\n * A path names a page by its stub, and nothing finer. The bare path resolves\n * to `index`, the same convention a static file server follows.\n */\nexport function pageNameFor(path: string): string {\n const name = path.replace(/^\\/+|\\/+$/g, \"\");\n return name === \"\" ? \"index\" : name;\n}\n\n/**\n * Where a row for `lb-url` leads, from a page and its query parms.\n *\n * A column whose name begins with `lb-` is Loadbare's, and never a query\n * parm; every other column is one. An `lb-path` naming another page enters\n * it with only the parms the row names. Otherwise the named parms are set,\n * or taken out when empty, and the rest are kept.\n *\n * One rule on both sides of the wire: the server loads the page it names,\n * and the hub writes the URL it names. The two must agree, or what the page\n * shows would differ from what the address bar says.\n */\nexport function nextLocation(\n page: string,\n parms: URLSearchParams,\n row: Row,\n): { page: string; parms: URLSearchParams; moved: boolean } {\n const named: Record<string, string> = {};\n for (const [name, value] of Object.entries(row)) {\n if (name.startsWith(LB_RESERVED_PREFIX)) continue;\n named[name] = value === null || value === undefined ? \"\" : String(value);\n }\n const path = row[URL_COLUMN_PATH];\n const next = typeof path === \"string\" ? pageNameFor(path) : page;\n const moved = next !== page;\n return {\n page: next,\n parms: withQueryParms(moved ? new URLSearchParams() : parms, named),\n moved,\n };\n}\n\n/**\n * The two hooks a custom element holding rows may implement, both optional.\n *\n * The hub reconciles every row template itself, so a custom element supplies\n * placement and scaffolding and nothing else. They are methods on an element\n * the hub does not own, so they carry the `lb` prefix Loadbare reserves for\n * exactly that — see docs/reference/custom-elements.md.\n */\nexport interface RowsHost {\n /**\n * Where a live row belongs, called with the row detached on its first\n * appearance. Without it a row lands immediately before the template, so\n * rows accumulate in the order they arrive.\n */\n lbPlaceRow?(el: Element, row: Row, template: HTMLTemplateElement): void;\n\n /** Called once after a whole result has landed, for derived scaffolding. */\n lbRowsLanded?(): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"lb-types.js","sourceRoot":"","sources":["../../core/lb-types.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,qDAAqD;AAErD,OAAO,EAGL,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAqC3B,MAAM,UAAU,OAAO,CAAC,MAAkB;IACxC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AA4DD,+DAA+D;AAC/D,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAQ,eAAqC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAuB,EACvB,KAA6B;IAE7B,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;IACzC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,EAAE;YAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;;YAC/B,IAAI,CAAC,GAAG,CAAC,IAAI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,KAAK,CAAC;QACnE,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["/// <reference lib=\"dom\" />\n\n// The wire vocabulary. Shared by browser and server.\n\nimport {\n KIND_ROW,\n KIND_ROWS,\n LB_RESERVED_PREFIX,\n LB_ROW_REQUESTS,\n ORDER_DESCENDING,\n ORDER_PARM_PREFIX,\n URL_COLUMN_PATH,\n} from \"./lb-constants.js\";\n\n/**\n * One row: its columns, by name.\n *\n * A value is whatever the server serialized. The hub knows nothing about its\n * type and enforces nothing: it hands each value to the browser untouched,\n * and the browser renders it as it sees fit. What a number, a date or a null\n * should look like is the application's decision, made in the query.\n */\nexport type Row = Record<string, unknown>;\n\n/**\n * Part of a `rows` query's answer — see docs/reference/server.md, \"Queries\".\n *\n * Rows named here are added or updated, keys in `drop` are removed, and\n * anything unnamed is left alone. The hub places what it names by the\n * query's order. Add and remove are one result rather than two because the\n * interesting cases are both at once — a row whose sort key changed has to\n * move, a swap is one out and one in — and two messages would paint the\n * intermediate state.\n */\nexport interface Patch {\n rows?: Row[];\n drop?: unknown[];\n}\n\n/** A query's kind, declared by the server and carried by every answer. */\nexport type Kind = typeof KIND_ROW | typeof KIND_ROWS;\n\n/**\n * What a `rows` query answers with: all rows, or a patch. `Array.isArray`\n * tells the two apart. All rows arrive in the order the server chose, which\n * is the order they show in when the query declares none.\n */\nexport type RowsResult = Row[] | Patch;\n\nexport function isPatch(result: RowsResult): result is Patch {\n return !Array.isArray(result);\n}\n\n/** What any one query answers with, as the application writes it. */\nexport type HubResult = Row | RowsResult;\n\n/**\n * What application code hands the engine: answers by query name. The engine\n * turns each into a response item, adding the kind and key the query\n * declared.\n */\nexport type HubData = Record<string, HubResult>;\n\n/**\n * One query's answer on the wire: its name, its kind, its key's column name,\n * and exactly one of a row, all rows, or a patch. A patch answers a `rows`\n * query only.\n *\n * A `rows` query also carries what it declared about order: the order the\n * server gives it, and whether the query reads the order parm itself.\n */\nexport interface ResponseItem {\n query: string;\n kind: Kind;\n key: string;\n row?: Row;\n rows?: Row[];\n patch?: Patch;\n order?: string;\n serverSortedByUrl?: boolean;\n}\n\n/** Every response the server sends: a page load and a request alike. */\nexport type HubResponse = ResponseItem[];\n\n/**\n * Every request has one shape. The name picks the handler; the rest is\n * present when the hub found it.\n */\nexport interface HubRequest {\n name: string;\n query?: string;\n key?: string;\n values?: Record<string, string>;\n}\n\n/**\n * The detail of the `lb-request-done` event: the request as the hub\n * completed and sent it, and what came of it. `items` is every response\n * item that landed because of it, in the order it landed. `error` is set\n * when the request's own round trip failed, and then nothing landed.\n */\nexport interface HubRequestDone {\n request: HubRequest;\n items: ResponseItem[];\n error?: Error;\n}\n\n/** The fields a handler receives: the request, less its name. */\nexport type RequestFields = Omit<HubRequest, \"name\">;\n\n/** Whether a name is one of the requests Loadbare provides. */\nexport function isRowRequest(name: string): boolean {\n return (LB_ROW_REQUESTS as readonly string[]).includes(name);\n}\n\n/**\n * A query string with some parms set, and the rest as they were. An empty\n * value takes its parm out, since empty is every parm's default and a\n * default is left out of the URL.\n *\n * One rule on both sides of the wire: the hub applies it to the address bar,\n * and the server to the query string it loads the page at after a request\n * returned `lb-url`. The two must agree, or what the page shows would differ\n * from what the address bar says.\n */\nexport function withQueryParms(\n search: URLSearchParams,\n parms: Record<string, string>,\n): URLSearchParams {\n const next = new URLSearchParams(search);\n for (const [name, value] of Object.entries(parms)) {\n if (value === \"\") next.delete(name);\n else next.set(name, value);\n }\n return next;\n}\n\n/**\n * A path names a page by its stub, and nothing finer. The bare path resolves\n * to `index`, the same convention a static file server follows.\n */\nexport function pageNameFor(path: string): string {\n const name = path.replace(/^\\/+|\\/+$/g, \"\");\n return name === \"\" ? \"index\" : name;\n}\n\n/**\n * Where a row for `lb-url` leads, from a page and its query parms.\n *\n * A column whose name begins with `lb-` is Loadbare's, and never a query\n * parm, except an order parm, which is one; every other column is one. An `lb-path` naming another page enters\n * it with only the parms the row names. Otherwise the named parms are set,\n * or taken out when empty, and the rest are kept.\n *\n * One rule on both sides of the wire: the server loads the page it names,\n * and the hub writes the URL it names. The two must agree, or what the page\n * shows would differ from what the address bar says.\n */\n/** One term of an order: a column, and whether it sorts descending. */\nexport interface OrderTerm {\n column: string;\n descending: boolean;\n}\n\n/**\n * An order's terms, from its text: columns separated by commas, each\n * descending when it begins with `-`. Throws on a term that names no column.\n * An empty text is no order.\n */\nexport function parseOrder(text: string): OrderTerm[] {\n if (text.trim() === \"\") return [];\n return text.split(\",\").map((raw) => {\n const term = raw.trim();\n const descending = term.startsWith(ORDER_DESCENDING);\n const column = descending ? term.slice(ORDER_DESCENDING.length) : term;\n if (column === \"\" || column.startsWith(ORDER_DESCENDING)) {\n throw new Error(`the order '${text}' has a term naming no column`);\n }\n return { column, descending };\n });\n}\n\n/** The query parm carrying the user's order for a query. */\nexport function orderParm(query: string): string {\n return ORDER_PARM_PREFIX + query;\n}\n\n/** Strings compare as the user's language orders them. */\nconst collator = new Intl.Collator();\n\n/** How a value sorts among values of other types: by its JSON type. */\nfunction rank(value: unknown): number {\n switch (typeof value) {\n case \"boolean\":\n return 0;\n case \"number\":\n return 1;\n case \"string\":\n return 2;\n default:\n return 3;\n }\n}\n\n/**\n * Compare two column values, ascending.\n *\n * A value compares by its JSON type, and nothing is guessed: numbers\n * numerically, booleans false before true, strings as the user's language\n * orders them. A number that arrives as a string sorts as a string, so a\n * numeric sort column is sent as a JSON number. Null and a missing value\n * sort after everything, as Postgres sorts them ascending, and so first\n * descending.\n */\nexport function compareValues(a: unknown, b: unknown): number {\n const missingA = a === null || a === undefined;\n const missingB = b === null || b === undefined;\n if (missingA || missingB) return missingA === missingB ? 0 : missingA ? 1 : -1;\n const ra = rank(a);\n const rb = rank(b);\n if (ra !== rb) return ra - rb;\n if (typeof a === \"number\") return a - (b as number);\n if (typeof a === \"boolean\") return Number(a) - Number(b);\n if (typeof a === \"string\") return collator.compare(a, b as string);\n return collator.compare(JSON.stringify(a), JSON.stringify(b));\n}\n\n/** Compare two rows by an order's terms. */\nexport function compareRows(a: Row, b: Row, terms: OrderTerm[]): number {\n for (const { column, descending } of terms) {\n const c = compareValues(a[column], b[column]);\n if (c !== 0) return descending ? -c : c;\n }\n return 0;\n}\n\nexport function nextLocation(\n page: string,\n parms: URLSearchParams,\n row: Row,\n): { page: string; parms: URLSearchParams; moved: boolean } {\n const named: Record<string, string> = {};\n for (const [name, value] of Object.entries(row)) {\n if (\n name.startsWith(LB_RESERVED_PREFIX) &&\n !name.startsWith(ORDER_PARM_PREFIX)\n ) {\n continue;\n }\n named[name] = value === null || value === undefined ? \"\" : String(value);\n }\n const path = row[URL_COLUMN_PATH];\n const next = typeof path === \"string\" ? pageNameFor(path) : page;\n const moved = next !== page;\n return {\n page: next,\n parms: withQueryParms(moved ? new URLSearchParams() : parms, named),\n moved,\n };\n}\n\n/**\n * The hook a custom element holding rows may implement.\n *\n * The hub reconciles and places every row itself, by the query's order, so a\n * custom element reacts to rows and never places them. It is a method on an\n * element the hub does not own, so it carries the `lb` prefix Loadbare\n * reserves for exactly that — see docs/reference/custom-elements.md.\n */\nexport interface RowsHost {\n /**\n * Called once after a result has landed, with every row in place and\n * every stamp set: for anything the element derives from its rows.\n */\n lbRowsLanded?(): void;\n}\n"]}
|
package/dist/hub/lb-apply.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare function within(root: Element, selector: string): Element[];
|
|
|
30
30
|
* ancestor, so its own `lb-column` reads from the row around it and is left
|
|
31
31
|
* alone here.
|
|
32
32
|
*/
|
|
33
|
-
export declare function applyRow(root: Element, row: Row, liveRow?: boolean): void;
|
|
33
|
+
export declare function applyRow(root: Element, row: Row, liveRow?: boolean, stop?: string): void;
|
|
34
34
|
/**
|
|
35
35
|
* The row template: the first `<template>` among the element's descendants,
|
|
36
36
|
* outside any nested `lb-query`. A template holding an absent branch is not a
|
|
@@ -38,32 +38,54 @@ export declare function applyRow(root: Element, row: Row, liveRow?: boolean): vo
|
|
|
38
38
|
* live row comes first in document order.
|
|
39
39
|
*/
|
|
40
40
|
export declare function templateIn(el: Element): HTMLTemplateElement | null;
|
|
41
|
+
/** How a list of rows lands: in what order, and whether a request asked. */
|
|
42
|
+
export interface RowsOptions {
|
|
43
|
+
/** The order to place rows by, as an order's text. */
|
|
44
|
+
order?: string;
|
|
45
|
+
/** The landing answers a request from this page. */
|
|
46
|
+
requested?: boolean;
|
|
47
|
+
}
|
|
41
48
|
/**
|
|
42
49
|
* Land rows through a row template.
|
|
43
50
|
*
|
|
44
|
-
* All rows decide membership
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* position.
|
|
51
|
+
* All rows decide membership: a row whose key did not arrive leaves. A patch
|
|
52
|
+
* disturbs only what it names — a row it did not mention keeps its contents,
|
|
53
|
+
* and keeps its place unless a row the patch named now sorts around it.
|
|
48
54
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
55
|
+
* Every live row is placed by the order. With none, all rows show in the
|
|
56
|
+
* order they arrived, and a patch's new rows go last. A row moves only when
|
|
57
|
+
* the order put it somewhere else, so landing the same rows again moves
|
|
58
|
+
* nothing.
|
|
53
59
|
*/
|
|
54
|
-
export declare function applyRows(el: Element, template: HTMLTemplateElement, keyColumn: string, result: RowsResult): void;
|
|
60
|
+
export declare function applyRows(el: Element, template: HTMLTemplateElement, keyColumn: string, result: RowsResult, options?: RowsOptions): void;
|
|
61
|
+
/** The answer kept for a query, as all of its rows. */
|
|
62
|
+
export declare function keptAnswer(root: ParentNode, query: string): ResponseItem | undefined;
|
|
55
63
|
/**
|
|
56
64
|
* Drop what landing kept for a root. The hub calls it when it replaces the
|
|
57
65
|
* page, since another page's query of the same name is another query.
|
|
58
66
|
*/
|
|
59
67
|
export declare function forget(root: ParentNode): void;
|
|
68
|
+
/** How response items land. */
|
|
69
|
+
export interface LandOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Queries that may have nowhere to land without a warning: the hub's own
|
|
72
|
+
* `lb-url` lands wherever a chrome or page names it, and nowhere otherwise.
|
|
73
|
+
*/
|
|
74
|
+
quiet?: readonly string[];
|
|
75
|
+
/** The user's order for a query, which replaces the server's. */
|
|
76
|
+
orderFor?: (query: string) => string | undefined;
|
|
77
|
+
/** The items answer a request from this page. */
|
|
78
|
+
requested?: boolean;
|
|
79
|
+
}
|
|
60
80
|
/**
|
|
61
81
|
* Land response items. Every answer arrives through here, and is kept for
|
|
62
82
|
* `root`, so that what arrives after it is filled from it — see forget().
|
|
63
|
-
*
|
|
64
|
-
* `quiet` names queries that may have nowhere to land without a warning: the
|
|
65
|
-
* hub's own `lb-url` lands wherever a chrome or page names it, and nowhere
|
|
66
|
-
* otherwise.
|
|
67
83
|
*/
|
|
68
|
-
export declare function applyResponse(root: ParentNode, items: ResponseItem[],
|
|
84
|
+
export declare function applyResponse(root: ParentNode, items: ResponseItem[], options?: LandOptions): void;
|
|
85
|
+
/**
|
|
86
|
+
* Land a query's kept answer again, as all of its rows: what the hub does
|
|
87
|
+
* when the user's order for it changes and the rows themselves have not.
|
|
88
|
+
* False when no answer is kept.
|
|
89
|
+
*/
|
|
90
|
+
export declare function reland(root: ParentNode, query: string): boolean;
|
|
69
91
|
//# sourceMappingURL=lb-apply.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lb-apply.d.ts","sourceRoot":"","sources":["../../hub/lb-apply.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lb-apply.d.ts","sourceRoot":"","sources":["../../hub/lb-apply.ts"],"names":[],"mappings":"AAsEA,OAAO,EAOL,KAAK,YAAY,EACjB,KAAK,GAAG,EAER,KAAK,UAAU,EAChB,MAAM,qBAAqB,CAAC;AA0B7B,mEAAmE;AACnE,MAAM,WAAW,OAAQ,SAAQ,OAAO;IACtC,KAAK,EAAE,MAAM,CAAC;CACf;AAiBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAGrD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAA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